diff --git a/lib/CodeGen/TargetLoweringBase.cpp b/lib/CodeGen/TargetLoweringBase.cpp index 67b2ee96283..52ab7cf3763 100644 --- a/lib/CodeGen/TargetLoweringBase.cpp +++ b/lib/CodeGen/TargetLoweringBase.cpp @@ -1831,7 +1831,7 @@ void TargetLoweringBase::insertSSPDeclarations(Module &M) const { // 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"); + return M.getGlobalVariable("__stack_chk_guard", true); } Value *TargetLoweringBase::getSSPStackGuardCheck(const Module &M) const { diff --git a/test/CodeGen/Generic/stackguard-internal.ll b/test/CodeGen/Generic/stackguard-internal.ll new file mode 100644 index 00000000000..4b815c98fb1 --- /dev/null +++ b/test/CodeGen/Generic/stackguard-internal.ll @@ -0,0 +1,13 @@ +; Check that the backend doesn't crash. +; RUN: llc -mtriple=x86_64-pc-freebsd %s -o - | FileCheck %s + +@__stack_chk_guard = internal global [8 x i64] zeroinitializer, align 16 + +define void @f() sspstrong { + %tbl = alloca [4 x i64], align 16 + ret void +} + +; CHECK: .type __stack_chk_guard,@object +; CHECK: .local __stack_chk_guard +; CHECK: .comm __stack_chk_guard,64,16