[llvm] [ARM] support -mlong-calls -fPIC on arm32 #39970 (PR #147313)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 13 02:24:49 PDT 2025
================
@@ -2839,7 +2846,8 @@ ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
PtrVt, dl, DAG.getEntryNode(), Addr,
MachinePointerInfo::getConstantPool(DAG.getMachineFunction()));
}
- } else if (ExternalSymbolSDNode *S=dyn_cast<ExternalSymbolSDNode>(Callee)) {
+ } else if (ExternalSymbolSDNode *S =
+ dyn_cast<ExternalSymbolSDNode>(Callee)) {
const char *Sym = S->getSymbol();
if (Subtarget->genExecuteOnly()) {
----------------
jiangxuezhi wrote:
Thank you for your suggestion. I have attempted to make the external-symbol code path work with PIC.
During this process, I found that using ARMISD::WrapperPIC caused issues in generating correct SDValues for certain symbols. For example, the following error was triggered:
```
LLVM ERROR: Cannot select: t20: i32 = ARMISD::WrapperPIC TargetExternalSymbol:i32 'memset' [TF=8]
```
This suggests that using the GOT-based approach for PIC is not suitable in this case.
To address this, I instead used the ARMISD::PIC_ADD node to compute PC-relative addresses, which allows proper handling of external symbols under PIC.
In addition, I have added test cases for llvm.memset in:
llvm-project/llvm/test/CodeGen/ARM/subtarget-features-long-calls.ll
Please help review this change — I'd appreciate your feedback on whether this implementation is appropriate.
https://github.com/llvm/llvm-project/pull/147313
More information about the llvm-commits
mailing list