[llvm] [ARM] mlong-calls generate PIC code using GOT #39970 (PR #147313)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 7 15:50:12 PDT 2025
================
@@ -2815,13 +2815,20 @@ ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
auto PtrVt = getPointerTy(DAG.getDataLayout());
if (Subtarget->genLongCalls()) {
- assert((!isPositionIndependent() || Subtarget->isTargetWindows()) &&
- "long-calls codegen is not position independent!");
// Handle a global address or an external symbol. If it's not one of
// those, the target's already in a register, so we don't need to do
// anything extra.
if (isa<GlobalAddressSDNode>(Callee)) {
- if (Subtarget->genExecuteOnly()) {
+ if (isPositionIndependent() && !Subtarget->isTargetWindows() &&
+ !Subtarget->genExecuteOnly()) {
+ SDValue G = DAG.getTargetGlobalAddress(
+ GVal, dl, PtrVt, 0, GVal->isDSOLocal() ? 0 : ARMII::MO_GOT);
+ Callee = DAG.getNode(ARMISD::WrapperPIC, dl, PtrVt, G);
+ if (!GVal->isDSOLocal())
+ Callee =
+ DAG.getLoad(PtrVt, dl, DAG.getEntryNode(), Callee,
+ MachinePointerInfo::getGOT(DAG.getMachineFunction()));
+ } else if (Subtarget->genExecuteOnly()) {
----------------
efriedma-quic wrote:
Does the execute-only codepath work correctly with PIC?
https://github.com/llvm/llvm-project/pull/147313
More information about the llvm-commits
mailing list