[llvm] [RISC-V] Adjust trampoline code for branch control flow protection (PR #141949)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 3 09:58:22 PDT 2025
================
@@ -8295,9 +8296,22 @@ SDValue RISCVTargetLowering::lowerINIT_TRAMPOLINE(SDValue Op,
// 16: <StaticChainOffset>
// 24: <FunctionAddressOffset>
// 32:
-
- constexpr unsigned StaticChainOffset = 16;
- constexpr unsigned FunctionAddressOffset = 24;
+ // Offset with branch control flow protection enabled:
+ // 0: lpad <imm20>
+ // 4: auipc t3, 0
+ // 8: ld t2, 28(t3)
+ // 12: ld t3, 20(t3)
+ // 16: jalr t2
+ // 20: <StaticChainOffset>
+ // 28: <FunctionAddressOffset>
+ // 36:
+
+ const bool HasCFBranch =
+ Subtarget.hasStdExtZicfilp() &&
+ DAG.getMMI()->getModule()->getModuleFlag("cf-protection-branch");
----------------
topperc wrote:
Oh it was in #142344. Can we use `DAG.getMachineFunction()..getFunction().getParent()->getModuleFlag` here? Then we don't need to include MachineModuleInfo.h
https://github.com/llvm/llvm-project/pull/141949
More information about the llvm-commits
mailing list