diff options
author | Eli Friedman <efriedma@codeaurora.org> | 2018-04-21 00:07:46 +0000 |
---|---|---|
committer | Eli Friedman <efriedma@codeaurora.org> | 2018-04-21 00:07:46 +0000 |
commit | 0644130612d89fab74008d01794cd2eb4b6e5bbe (patch) | |
tree | ba25322bec404c3c8caa52475d3334a893c88950 /llvm/lib/CodeGen/TargetLoweringBase.cpp | |
parent | e5d279e6d6018c97dba247e711d6cb846d533733 (diff) | |
download | llvm-0644130612d89fab74008d01794cd2eb4b6e5bbe.zip llvm-0644130612d89fab74008d01794cd2eb4b6e5bbe.tar.gz llvm-0644130612d89fab74008d01794cd2eb4b6e5bbe.tar.bz2 |
[AArch64] Don't crash trying to resolve __stack_chk_guard.
In certain cases, the compiler might try to merge __stack_chk_guard with
another global variable. (Or someone could theoretically define
__stack_chk_guard as an alias.) In that case, make sure we don't crash.
Differential Revision: https://reviews.llvm.org/D45746
llvm-svn: 330495
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringBase.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringBase.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index 53a3918..beeff7d 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -1624,13 +1624,16 @@ Value *TargetLoweringBase::getIRStackGuard(IRBuilder<> &IRB) const { // Currently only support "standard" __stack_chk_guard. // TODO: add LOAD_STACK_GUARD support. void TargetLoweringBase::insertSSPDeclarations(Module &M) const { - M.getOrInsertGlobal("__stack_chk_guard", Type::getInt8PtrTy(M.getContext())); + if (!M.getNamedValue("__stack_chk_guard")) + new GlobalVariable(M, Type::getInt8PtrTy(M.getContext()), false, + GlobalVariable::ExternalLinkage, + nullptr, "__stack_chk_guard"); } // Currently only support "standard" __stack_chk_guard. // TODO: add LOAD_STACK_GUARD support. Value *TargetLoweringBase::getSDagStackGuard(const Module &M) const { - return M.getGlobalVariable("__stack_chk_guard", true); + return M.getNamedValue("__stack_chk_guard"); } Value *TargetLoweringBase::getSSPStackGuardCheck(const Module &M) const { |