[PATCH] D109254: [AArch64] Enable CFIInstrInserter
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 3 12:35:53 PDT 2021
MaskRay created this revision.
Herald added subscribers: hiraditya, kristof.beyls.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
A basic block following an exit basic block (with ret) generally has
incorrect CFI.
CFIInstrInserter introduced by `Correct dwarf unwind information in function epilogue` can fix the problem.
I have skepticism whether the fix-up approach is the best, but currently appears
to be the only realistic approach to fix a basic block with epilogue and a basic
block following an epilogue, before we come up with a better scheme.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D109254
Files:
llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
llvm/lib/Target/AArch64/AArch64FrameLowering.h
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/test/CodeGen/AArch64/O0-pipeline.ll
llvm/test/CodeGen/AArch64/O3-pipeline.ll
Index: llvm/test/CodeGen/AArch64/O3-pipeline.ll
===================================================================
--- llvm/test/CodeGen/AArch64/O3-pipeline.ll
+++ llvm/test/CodeGen/AArch64/O3-pipeline.ll
@@ -202,6 +202,7 @@
; CHECK-NEXT: Machine Outliner
; CHECK-NEXT: FunctionPass Manager
; CHECK-NEXT: Unpack machine instruction bundles
+; CHECK-NEXT: Check CFA info and insert CFI instructions if needed
; CHECK-NEXT: Lazy Machine Block Frequency Analysis
; CHECK-NEXT: Machine Optimization Remark Emitter
; CHECK-NEXT: AArch64 Assembly Printer
Index: llvm/test/CodeGen/AArch64/O0-pipeline.ll
===================================================================
--- llvm/test/CodeGen/AArch64/O0-pipeline.ll
+++ llvm/test/CodeGen/AArch64/O0-pipeline.ll
@@ -66,6 +66,7 @@
; CHECK-NEXT: StackMap Liveness Analysis
; CHECK-NEXT: Live DEBUG_VALUE analysis
; CHECK-NEXT: Unpack machine instruction bundles
+; CHECK-NEXT: Check CFA info and insert CFI instructions if needed
; CHECK-NEXT: Lazy Machine Block Frequency Analysis
; CHECK-NEXT: Machine Optimization Remark Emitter
; CHECK-NEXT: AArch64 Assembly Printer
Index: llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
+++ llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
@@ -757,6 +757,10 @@
// SVE bundles move prefixes with destructive operations. BLR_RVMARKER pseudo
// instructions are lowered to bundles as well.
addPass(createUnpackMachineBundles(nullptr));
+
+ const Triple &TT = TM->getTargetTriple();
+ if (TT.isOSBinFormatELF())
+ addPass(createCFIInstrInserter());
}
yaml::MachineFunctionInfo *
Index: llvm/lib/Target/AArch64/AArch64FrameLowering.h
===================================================================
--- llvm/lib/Target/AArch64/AArch64FrameLowering.h
+++ llvm/lib/Target/AArch64/AArch64FrameLowering.h
@@ -126,6 +126,11 @@
orderFrameObjects(const MachineFunction &MF,
SmallVectorImpl<int> &ObjectsToAllocate) const override;
+ int getInitialCFAOffset(const MachineFunction &MF) const override {
+ return 0;
+ }
+ Register getInitialCFARegister(const MachineFunction &MF) const override;
+
private:
/// Returns true if a homogeneous prolog or epilog code can be emitted
/// for the size optimization. If so, HOM_Prolog/HOM_Epilog pseudo
Index: llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
@@ -230,6 +230,11 @@
return ArgumentPopSize;
}
+Register
+AArch64FrameLowering::getInitialCFARegister(const MachineFunction &MF) const {
+ return MF.getSubtarget().getRegisterInfo()->getDwarfRegNum(AArch64::SP, true);
+}
+
static bool produceCompactUnwindFrame(MachineFunction &MF);
static bool needsWinCFI(const MachineFunction &MF);
static StackOffset getSVEStackSize(const MachineFunction &MF);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109254.370650.patch
Type: text/x-patch
Size: 3123 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210903/5d1ac078/attachment.bin>
More information about the llvm-commits
mailing list