[llvm] [BOLT][AArch64]support `inline-small-functions` for AArch64 (PR #120187)

Alexey Moksyakov via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 26 07:50:42 PST 2024


================
@@ -133,6 +133,35 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
 public:
   using MCPlusBuilder::MCPlusBuilder;
 
+  MCPhysReg getStackPointer() const override { return AArch64::SP; }
+
+  bool isPush(const MCInst &Inst) const override { return false; }
+
+  bool isPop(const MCInst &Inst) const override { return false; }
+
+  void createCall(MCInst &Inst, const MCSymbol *Target,
+                  MCContext *Ctx) override {
+    createDirectCall(Inst, Target, Ctx, false);
+  }
+
+  bool convertTailCallToCall(MCInst &Inst) override {
+    int NewOpcode;
+    switch (Inst.getOpcode()) {
+    default:
+      return false;
+    case AArch64::B:
+      NewOpcode = AArch64::BL;
+      break;
+    case AArch64::BR:
+      NewOpcode = AArch64::BLR;
+      break;
+    }
+
+    Inst.setOpcode(NewOpcode);
+    removeAnnotation(Inst, MCPlus::MCAnnotation::kTailCall);
----------------
yavtuk wrote:

for each branch we have annotation with offset, I think here we should remove offset because we inlined code to another function and current offset is not valid anymore.
clearOffset(Inst);

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


More information about the llvm-commits mailing list