Skip to content

[CodeGen] Add another method to CFIInstBuilder #136270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2025

Conversation

s-barannikov
Copy link
Contributor

Mainly for use by downstream targets, but it can find applications in upstream code as well. Use it in MSP430 so that it doesn't look dead.

Mainly for use by downstream target, but it can find applications in
upstream code as well. Use it in MSP430 so that it doesn't look dead.
@llvmbot
Copy link
Member

llvmbot commented Apr 18, 2025

@llvm/pr-subscribers-backend-msp430

Author: Sergei Barannikov (s-barannikov)

Changes

Mainly for use by downstream targets, but it can find applications in upstream code as well. Use it in MSP430 so that it doesn't look dead.


Full diff: https://github.com/llvm/llvm-project/pull/136270.diff

2 Files Affected:

  • (modified) llvm/include/llvm/CodeGen/CFIInstBuilder.h (+4)
  • (modified) llvm/lib/Target/MSP430/MSP430FrameLowering.cpp (+3-3)
diff --git a/llvm/include/llvm/CodeGen/CFIInstBuilder.h b/llvm/include/llvm/CodeGen/CFIInstBuilder.h
index bf7102eeea497..86e125f11e0c6 100644
--- a/llvm/include/llvm/CodeGen/CFIInstBuilder.h
+++ b/llvm/include/llvm/CodeGen/CFIInstBuilder.h
@@ -71,6 +71,10 @@ class CFIInstBuilder {
     insertCFIInst(MCCFIInstruction::cfiDefCfaOffset(nullptr, Offset));
   }
 
+  void buildAdjustCFAOffset(int64_t Adjustment) const {
+    insertCFIInst(MCCFIInstruction::createAdjustCfaOffset(nullptr, Adjustment));
+  }
+
   void buildOffset(MCRegister Reg, int64_t Offset) const {
     insertCFIInst(MCCFIInstruction::createOffset(
         nullptr, TRI.getDwarfRegNum(Reg, IsEH), Offset));
diff --git a/llvm/lib/Target/MSP430/MSP430FrameLowering.cpp b/llvm/lib/Target/MSP430/MSP430FrameLowering.cpp
index 39f4324286efd..bc24b3239b43a 100644
--- a/llvm/lib/Target/MSP430/MSP430FrameLowering.cpp
+++ b/llvm/lib/Target/MSP430/MSP430FrameLowering.cpp
@@ -14,6 +14,7 @@
 #include "MSP430InstrInfo.h"
 #include "MSP430MachineFunctionInfo.h"
 #include "MSP430Subtarget.h"
+#include "llvm/CodeGen/CFIInstBuilder.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -406,9 +407,8 @@ MachineBasicBlock::iterator MSP430FrameLowering::eliminateCallFramePseudoInstr(
               .addReg(MSP430::SP)
               .addImm(CalleeAmt);
       if (!hasFP(MF)) {
-        DebugLoc DL = I->getDebugLoc();
-        BuildCFI(MBB, I, DL,
-                 MCCFIInstruction::createAdjustCfaOffset(nullptr, CalleeAmt));
+        CFIInstBuilder(MBB, I, MachineInstr::NoFlags)
+            .buildAdjustCFAOffset(CalleeAmt);
       }
       // The SRW implicit def is dead.
       New->getOperand(3).setIsDead();

Copy link
Collaborator

@asl asl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@s-barannikov s-barannikov merged commit d149631 into llvm:main Apr 18, 2025
13 checks passed
@s-barannikov s-barannikov deleted the cfi/adjust-cfa-offset branch April 18, 2025 07:50
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Mainly for use by downstream targets, but it can find applications in
upstream code as well. Use it in MSP430 so that it doesn't look dead.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Mainly for use by downstream targets, but it can find applications in
upstream code as well. Use it in MSP430 so that it doesn't look dead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants