diff options
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringBase.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/TargetLoweringBase.cpp | 17 |
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); } |
