From 74d4553b12d6c862a95d681bb34efc9d547b26e8 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Thu, 9 Jun 2016 14:23:38 +0000 Subject: [PATCH] [CodeGen] Change getSDagStackGuard to get an internal sym. Fixes a crash in the backend during an LTO build of rtld(1) in FreeBSD. llvm-svn: 272262 --- lib/CodeGen/TargetLoweringBase.cpp | 2 +- test/CodeGen/Generic/stackguard-internal.ll | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/CodeGen/Generic/stackguard-internal.ll 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