[AssumeBundleQueries] Remove unused code (#203927)

Some of the utilities in AssumeBundleQueris was only ever used in tests
for them, so there isn't much point in keeping the code around.
diff --git a/llvm/include/llvm/Analysis/AssumeBundleQueries.h b/llvm/include/llvm/Analysis/AssumeBundleQueries.h
index 2af8232..10def2c 100644
--- a/llvm/include/llvm/Analysis/AssumeBundleQueries.h
+++ b/llvm/include/llvm/Analysis/AssumeBundleQueries.h
@@ -31,24 +31,6 @@
   ABA_Argument = 1,
 };
 
-/// Query the operand bundle of an llvm.assume to find a single attribute of
-/// the specified kind applied on a specified Value.
-///
-/// This has a non-constant complexity. It should only be used when a single
-/// attribute is going to be queried.
-///
-/// Return true iff the queried attribute was found.
-/// If ArgVal is set. the argument will be stored to ArgVal.
-LLVM_ABI bool hasAttributeInAssume(AssumeInst &Assume, Value *IsOn,
-                                   StringRef AttrName,
-                                   uint64_t *ArgVal = nullptr);
-inline bool hasAttributeInAssume(AssumeInst &Assume, Value *IsOn,
-                                 Attribute::AttrKind Kind,
-                                 uint64_t *ArgVal = nullptr) {
-  return hasAttributeInAssume(Assume, IsOn,
-                              Attribute::getNameFromAttrKind(Kind), ArgVal);
-}
-
 template <> struct DenseMapInfo<Attribute::AttrKind> {
   static unsigned getHashValue(Attribute::AttrKind AK) {
     return hash_combine(AK);
@@ -78,9 +60,8 @@
     DenseMap<RetainedKnowledgeKey, Assume2KnowledgeMap>;
 
 /// Insert into the map all the informations contained in the operand bundles of
-/// the llvm.assume. This should be used instead of hasAttributeInAssume when
-/// many queries are going to be made on the same llvm.assume.
-/// String attributes are not inserted in the map.
+/// the llvm.assume. This should be used when many queries are going to be made
+/// on the same llvm.assume. String attributes are not inserted in the map.
 /// If the IR changes the map will be outdated.
 LLVM_ABI void fillMapFromAssume(AssumeInst &Assume,
                                 RetainedKnowledgeMap &Result);
diff --git a/llvm/lib/Analysis/AssumeBundleQueries.cpp b/llvm/lib/Analysis/AssumeBundleQueries.cpp
index 2c05d2b..81bebe3 100644
--- a/llvm/lib/Analysis/AssumeBundleQueries.cpp
+++ b/llvm/lib/Analysis/AssumeBundleQueries.cpp
@@ -40,33 +40,6 @@
   return (Assume.op_begin() + BOI.Begin + Idx)->get();
 }
 
-bool llvm::hasAttributeInAssume(AssumeInst &Assume, Value *IsOn,
-                                StringRef AttrName, uint64_t *ArgVal) {
-  assert(Attribute::isExistingAttribute(AttrName) &&
-         "this attribute doesn't exist");
-  assert((ArgVal == nullptr || Attribute::isIntAttrKind(
-                                   Attribute::getAttrKindFromName(AttrName))) &&
-         "requested value for an attribute that has no argument");
-  if (Assume.bundle_op_infos().empty())
-    return false;
-
-  for (auto &BOI : Assume.bundle_op_infos()) {
-    if (BOI.Tag->getKey() != AttrName)
-      continue;
-    if (IsOn && (BOI.End - BOI.Begin <= ABA_WasOn ||
-                 IsOn != getValueFromBundleOpInfo(Assume, BOI, ABA_WasOn)))
-      continue;
-    if (ArgVal) {
-      assert(BOI.End - BOI.Begin > ABA_Argument);
-      *ArgVal =
-          cast<ConstantInt>(getValueFromBundleOpInfo(Assume, BOI, ABA_Argument))
-              ->getZExtValue();
-    }
-    return true;
-  }
-  return false;
-}
-
 void llvm::fillMapFromAssume(AssumeInst &Assume, RetainedKnowledgeMap &Result) {
   for (auto &Bundles : Assume.bundle_op_infos()) {
     std::pair<Value *, Attribute::AttrKind> Key{
diff --git a/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp b/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
index 8c20b00..6a55454 100644
--- a/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
+++ b/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
@@ -40,174 +40,6 @@
   }
 }
 
-bool hasMatchesExactlyAttributes(AssumeInst *Assume, Value *WasOn,
-                                 StringRef AttrToMatch) {
-  Regex Reg(AttrToMatch);
-  SmallVector<StringRef, 1> Matches;
-  for (StringRef Attr : {
-#define GET_ATTR_NAMES
-#define ATTRIBUTE_ALL(ENUM_NAME, DISPLAY_NAME) StringRef(#DISPLAY_NAME),
-#include "llvm/IR/Attributes.inc"
-       }) {
-    bool ShouldHaveAttr = Reg.match(Attr, &Matches) && Matches[0] == Attr;
-    if (ShouldHaveAttr != hasAttributeInAssume(*Assume, WasOn, Attr))
-      return false;
-  }
-  return true;
-}
-
-bool hasTheRightValue(AssumeInst *Assume, Value *WasOn,
-                      Attribute::AttrKind Kind, unsigned Value) {
-  uint64_t ArgVal = 0;
-  if (!hasAttributeInAssume(*Assume, WasOn, Kind, &ArgVal))
-    return false;
-  if (ArgVal != Value)
-    return false;
-  return true;
-}
-
-TEST(AssumeQueryAPI, hasAttributeInAssume) {
-  EnableKnowledgeRetention.setValue(true);
-  StringRef Head =
-      "declare void @llvm.assume(i1)\n"
-      "declare void @func(ptr, ptr, ptr)\n"
-      "declare void @func1(ptr, ptr, ptr, ptr)\n"
-      "declare void @func_many(ptr) \"no-jump-tables\" nounwind "
-      "\"less-precise-fpmad\" willreturn norecurse\n"
-      "define void @test(ptr %P, ptr %P1, ptr %P2, ptr %P3) {\n";
-  StringRef Tail = "ret void\n"
-                   "}";
-  std::vector<std::pair<StringRef, llvm::function_ref<void(Instruction *)>>>
-      Tests;
-  Tests.push_back(std::make_pair(
-      "call void @func(ptr nonnull align 4 dereferenceable(16) %P, ptr align "
-      "8 noalias %P1, ptr align 8 noundef %P2)\n",
-      [](Instruction *I) {
-        auto *Assume = buildAssumeFromInst(I);
-        Assume->insertBefore(I->getIterator());
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, I->getOperand(0),
-                                       "(nonnull|align|dereferenceable)"));
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, I->getOperand(1),
-                                       "()"));
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, I->getOperand(2),
-                                       "(align|noundef)"));
-        ASSERT_TRUE(hasTheRightValue(Assume, I->getOperand(0),
-                                     Attribute::AttrKind::Dereferenceable, 16));
-        ASSERT_TRUE(hasTheRightValue(Assume, I->getOperand(0),
-                                     Attribute::AttrKind::Alignment, 4));
-        ASSERT_TRUE(hasTheRightValue(Assume, I->getOperand(0),
-                                     Attribute::AttrKind::Alignment, 4));
-      }));
-  Tests.push_back(std::make_pair(
-      "call void @func1(ptr nonnull align 32 dereferenceable(48) %P, ptr "
-      "nonnull "
-      "align 8 dereferenceable(28) %P, ptr nonnull align 64 "
-      "dereferenceable(4) "
-      "%P, ptr nonnull align 16 dereferenceable(12) %P)\n",
-      [](Instruction *I) {
-        auto *Assume = buildAssumeFromInst(I);
-        Assume->insertBefore(I->getIterator());
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, I->getOperand(0),
-                                       "(nonnull|align|dereferenceable)"));
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, I->getOperand(1),
-                                       "(nonnull|align|dereferenceable)"));
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, I->getOperand(2),
-                                       "(nonnull|align|dereferenceable)"));
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, I->getOperand(3),
-                                       "(nonnull|align|dereferenceable)"));
-        ASSERT_TRUE(hasTheRightValue(Assume, I->getOperand(0),
-                                     Attribute::AttrKind::Dereferenceable, 48));
-        ASSERT_TRUE(hasTheRightValue(Assume, I->getOperand(0),
-                                     Attribute::AttrKind::Alignment, 64));
-        ASSERT_TRUE(hasTheRightValue(Assume, I->getOperand(1),
-                                     Attribute::AttrKind::Alignment, 64));
-      }));
-  Tests.push_back(
-      std::make_pair("call void @llvm.assume(i1 true)\n", [](Instruction *I) {
-        auto *Assume = cast<AssumeInst>(I);
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, nullptr, ""));
-      }));
-  Tests.push_back(std::make_pair(
-      "call void @func1(ptr readnone align 32 "
-      "dereferenceable(48) noalias %P, ptr "
-      "align 8 dereferenceable(28) %P1, ptr align 64 "
-      "dereferenceable(4) "
-      "%P2, ptr nonnull align 16 dereferenceable(12) %P3)\n",
-      [](Instruction *I) {
-        auto *Assume = buildAssumeFromInst(I);
-        Assume->insertBefore(I->getIterator());
-        ASSERT_TRUE(hasMatchesExactlyAttributes(
-            Assume, I->getOperand(0),
-            "(align|dereferenceable)"));
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, I->getOperand(1),
-                                       "(align|dereferenceable)"));
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, I->getOperand(2),
-                                       "(align|dereferenceable)"));
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, I->getOperand(3),
-                                       "(nonnull|align|dereferenceable)"));
-        ASSERT_TRUE(hasTheRightValue(Assume, I->getOperand(0),
-                                     Attribute::AttrKind::Alignment, 32));
-        ASSERT_TRUE(hasTheRightValue(Assume, I->getOperand(0),
-                                     Attribute::AttrKind::Dereferenceable, 48));
-        ASSERT_TRUE(hasTheRightValue(Assume, I->getOperand(1),
-                                     Attribute::AttrKind::Dereferenceable, 28));
-        ASSERT_TRUE(hasTheRightValue(Assume, I->getOperand(1),
-                                     Attribute::AttrKind::Alignment, 8));
-        ASSERT_TRUE(hasTheRightValue(Assume, I->getOperand(2),
-                                     Attribute::AttrKind::Alignment, 64));
-        ASSERT_TRUE(hasTheRightValue(Assume, I->getOperand(2),
-                                     Attribute::AttrKind::Dereferenceable, 4));
-        ASSERT_TRUE(hasTheRightValue(Assume, I->getOperand(3),
-                                     Attribute::AttrKind::Alignment, 16));
-        ASSERT_TRUE(hasTheRightValue(Assume, I->getOperand(3),
-                                     Attribute::AttrKind::Dereferenceable, 12));
-      }));
-
-  Tests.push_back(std::make_pair(
-      "call void @func1(ptr readnone align 32 "
-      "dereferenceable(48) noalias %P, ptr "
-      "align 8 dereferenceable(28) %P1, ptr align 64 "
-      "dereferenceable(4) "
-      "%P2, ptr nonnull align 16 dereferenceable(12) %P3)\n",
-      [](Instruction *I) {
-        auto *Assume = buildAssumeFromInst(I);
-        Assume->insertBefore(I->getIterator());
-        I->getOperand(1)->dropDroppableUses();
-        I->getOperand(2)->dropDroppableUses();
-        I->getOperand(3)->dropDroppableUses();
-        ASSERT_TRUE(hasMatchesExactlyAttributes(
-            Assume, I->getOperand(0),
-            "(align|dereferenceable)"));
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, I->getOperand(1),
-                                       ""));
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, I->getOperand(2),
-                                       ""));
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, I->getOperand(3),
-                                       ""));
-        ASSERT_TRUE(hasTheRightValue(Assume, I->getOperand(0),
-                                     Attribute::AttrKind::Alignment, 32));
-        ASSERT_TRUE(hasTheRightValue(Assume, I->getOperand(0),
-                                     Attribute::AttrKind::Dereferenceable, 48));
-      }));
-  Tests.push_back(std::make_pair(
-      "call void @func(ptr nonnull align 4 dereferenceable(16) %P, ptr align "
-      "8 noalias %P1, ptr %P1)\n",
-      [](Instruction *I) {
-        auto *Assume = buildAssumeFromInst(I);
-        Assume->insertBefore(I->getIterator());
-        Value *New = I->getFunction()->getArg(3);
-        Value *Old = I->getOperand(0);
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, New, ""));
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, Old,
-                                       "(nonnull|align|dereferenceable)"));
-        Old->replaceAllUsesWith(New);
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, New,
-                                       "(nonnull|align|dereferenceable)"));
-        ASSERT_TRUE(hasMatchesExactlyAttributes(Assume, Old, ""));
-      }));
-  RunTest(Head, Tail, Tests);
-}
-
 static bool FindExactlyAttributes(RetainedKnowledgeMap &Map, Value *WasOn,
                                  StringRef AttrToMatch) {
   Regex Reg(AttrToMatch);