summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetLoweringBase.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2025-07-18 13:26:00 -0700
committerPeter Collingbourne <peter@pcc.me.uk>2025-07-18 13:26:00 -0700
commit9bf3524731070cadc6175707314f3b6ca37190d5 (patch)
tree86dcab7604336b01ae938fe81062c29ff69efba8 /llvm/lib/CodeGen/TargetLoweringBase.cpp
parent3a84c15cc13b6daf8e812592898ab6c7f19091a9 (diff)
parent4f43f0606c3d7e1ce6d069583b5e59f036e112ce (diff)
Created using spr 1.3.6-beta.1
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringBase.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringBase.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp
index 6feeb19bb858..d4a34555ed82 100644
--- a/llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -1965,15 +1965,26 @@ TargetLoweringBase::getDefaultSafeStackPointerLocation(IRBuilderBase &IRB,
Value *
TargetLoweringBase::getSafeStackPointerLocation(IRBuilderBase &IRB) const {
+ // FIXME: Can this triple check be replaced with SAFESTACK_POINTER_ADDRESS
+ // being available?
if (!TM.getTargetTriple().isAndroid())
return getDefaultSafeStackPointerLocation(IRB, true);
- // Android provides a libc function to retrieve the address of the current
- // thread's unsafe stack pointer.
Module *M = IRB.GetInsertBlock()->getParent()->getParent();
auto *PtrTy = PointerType::getUnqual(M->getContext());
+
+ const char *SafestackPointerAddressName =
+ getLibcallName(RTLIB::SAFESTACK_POINTER_ADDRESS);
+ if (!SafestackPointerAddressName) {
+ M->getContext().emitError(
+ "no libcall available for safestack pointer address");
+ return PoisonValue::get(PtrTy);
+ }
+
+ // Android provides a libc function to retrieve the address of the current
+ // thread's unsafe stack pointer.
FunctionCallee Fn =
- M->getOrInsertFunction("__safestack_pointer_address", PtrTy);
+ M->getOrInsertFunction(SafestackPointerAddressName, PtrTy);
return IRB.CreateCall(Fn);
}