[llvm] [BOLT][BTI] Add MCPlusBuilder::insertBTI (PR #167329)

Peter Waller via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 8 02:01:01 PST 2025


================
@@ -198,6 +198,125 @@ TEST_P(MCPlusBuilderTester, AArch64_BTI) {
   ASSERT_TRUE(BC->MIB->isImplicitBTIC(*II));
 }
 
+TEST_P(MCPlusBuilderTester, AArch64_insertBTI_empty) {
+  if (GetParam() != Triple::aarch64)
+    GTEST_SKIP();
+  BinaryFunction *BF = BC->createInjectedBinaryFunction("BF", true);
+  std::unique_ptr<BinaryBasicBlock> BB = BF->createBasicBlock();
+  MCInst CallInst = MCInstBuilder(AArch64::BR).addReg(AArch64::X16);
+#ifndef NDEBUG
+  ASSERT_DEATH(BC->MIB->insertBTI(*BB, CallInst),
+               "insertBTI should only be called on non-empty BasicBlocks");
+#else
+  BC->MIB->insertBTI(*BB, CallInst);
+  ASSERT(BB->size() == 0);
----------------
peterwaller-arm wrote:

Is ASSERT a valid gtest macro? I think gtest spells it `ASSERT_EQ(BB->size(), 0)` or `ASSERT_TRUE`.
https://google.github.io/googletest/reference/assertions.html


https://github.com/llvm/llvm-project/pull/167329


More information about the llvm-commits mailing list