[llvm] [BOLT][AArch64] Fixed indirect call instrumentation snippet (PR #141918)

YongKang Zhu via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 6 11:18:23 PST 2025


================
@@ -2459,43 +2495,58 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
   createInstrumentedIndCallHandlerEntryBB(const MCSymbol *InstrTrampoline,
                                           const MCSymbol *IndCallHandler,
                                           MCContext *Ctx) override {
-    // Code sequence used to check whether InstrTampoline was initialized
+    // Code sequence used to check whether InstrTrampoline was initialized
     // and call it if so, returns via IndCallHandler
     //   stp     x0, x1, [sp, #-16]!
----------------
yozhu wrote:

We can also remove this `stp` instruction, as well as the corresponding `ldr` in the exit snippet.

And because the save and restore of `nzcv` have been moved into the `SAVE_ALL` and `RESTORE_ALL` macro's, the exit snippet will contain only one `ret` instruction.  We can replace the `b IndCallHandler` with `ret`, replace the `b.eq IndCallHandler` with `b.eq <label_to_the_ret_instruction>`, and remove the exit snippet, like

adrp     x0, InstrTrampoline
ldr        x0, [x0, #lo12:InstrTrampoline]
subs    x0, x0, #0x0
b.eq    .LtmpRet
str       x30, [p, #-16]!
blr       x0
ldr       x30, [sp], #16
.LtmpRet:
            ret

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


More information about the llvm-commits mailing list