[llvm] Parse CFI instructions to create SFrame FREs (PR #155496)
Pavel Labath via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 28 10:16:47 PDT 2025
================
@@ -109,91 +107,81 @@ class SFrameEmitterImpl {
MCSymbol *FRESubSectionStart;
MCSymbol *FRESubSectionEnd;
-
- bool setCfaRegister(SFrameFDE &FDE, SFrameFRE &FRE, const MCCFIInstruction &I) {
+ bool setCFARegister(SFrameFRE &FRE, const MCCFIInstruction &I) {
if (I.getRegister() == SPReg) {
- FRE.CfaRegSet = true;
+ FRE.CFARegSet = true;
FRE.FromFP = false;
return true;
- } else if (I.getRegister() == FPReg) {
- FRE.CfaRegSet = true;
+ }
+ if (I.getRegister() == FPReg) {
+ FRE.CFARegSet = true;
FRE.FromFP = true;
return true;
}
Streamer.getContext().reportWarning(
I.getLoc(), "Canonical Frame Address not in stack- or frame-pointer. "
"Omitting SFrame unwind info for this function.");
- FDE.Invalid = true;
return false;
}
- bool isCfaRegisterSet(SFrameFDE &FDE, SFrameFRE &FRE,
- const MCCFIInstruction &I) {
- if (FRE.CfaRegSet)
- return true;
-
- Streamer.getContext().reportWarning(
- I.getLoc(), "Adjusting CFA offset without a base register. "
- "Omitting SFrame unwind info for this function.");
- FDE.Invalid = true;
- return false;
+ bool setCFAOffset(SFrameFRE &FRE, const SMLoc &Loc, size_t Offset) {
+ if (!FRE.CFARegSet) {
+ Streamer.getContext().reportWarning(
+ Loc, "Adjusting CFA offset without a base register. "
+ "Omitting SFrame unwind info for this function.");
+ return false;
+ }
+ FRE.CFAOffset = Offset;
+ return true;
}
// Add the effects of CFI to the current FDE, creating a new FRE when
// necessary.
- void handleCFI(SFrameFDE &FDE, SFrameFRE &FRE, const MCCFIInstruction &CFI) {
+ bool handleCFI(SFrameFDE &FDE, SFrameFRE &FRE, const MCCFIInstruction &CFI) {
switch (CFI.getOperation()) {
case MCCFIInstruction::OpDefCfaRegister:
- setCfaRegister(FDE, FRE, CFI);
- return;
+ return setCFARegister(FRE, CFI);
case MCCFIInstruction::OpDefCfa:
case MCCFIInstruction::OpLLVMDefAspaceCfa:
- if (!setCfaRegister(FDE, FRE, CFI))
- return;
- FRE.CfaOffset = CFI.getOffset();
- return;
+ if (!setCFARegister(FRE, CFI))
+ return false;
+ setCFAOffset(FRE, CFI.getLoc(), CFI.getOffset());
+ return true;
----------------
labath wrote:
Should this be:
```suggestion
return setCFAOffset(FRE, CFI.getLoc(), CFI.getOffset());
```
I guess the difference is that if this was the only error, the code would still go on to produce a (broken) FDE entry.
https://github.com/llvm/llvm-project/pull/155496
More information about the llvm-commits
mailing list