[llvm] [CodeGen] Add another method to CFIInstBuilder (PR #136270)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 17 23:56:55 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-msp430
Author: Sergei Barannikov (s-barannikov)
<details>
<summary>Changes</summary>
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
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();
``````````
</details>
https://github.com/llvm/llvm-project/pull/136270
More information about the llvm-commits
mailing list