Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit f02b39c

Browse files
committed
Merging r309594:
------------------------------------------------------------------------ r309594 | majnemer | 2017-07-31 10:47:07 -0700 (Mon, 31 Jul 2017) | 4 lines [IPSCCP] Guard a user of getInitializer with hasDefinitiveInitializer We are not allowed to reason about an initializer value without first consulting hasDefinitiveInitializer. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_50@309827 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 09c8b06 commit f02b39c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/Transforms/Scalar/SCCP.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,8 @@ static bool runIPSCCP(Module &M, const DataLayout &DL,
17901790
// variables that do not have their 'addresses taken'. If they don't have
17911791
// their addresses taken, we can propagate constants through them.
17921792
for (GlobalVariable &G : M.globals())
1793-
if (!G.isConstant() && G.hasLocalLinkage() && !AddressIsTaken(&G))
1793+
if (!G.isConstant() && G.hasLocalLinkage() &&
1794+
G.hasDefinitiveInitializer() && !AddressIsTaken(&G))
17941795
Solver.TrackValueOfGlobalVariable(&G);
17951796

17961797
// Solve for constants.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; RUN: opt -S -ipsccp < %s | FileCheck %s
2+
@d = internal externally_initialized global i32 0, section ".openbsd.randomdata", align 4
3+
4+
; CHECK-LABEL: @test1(
5+
define i32 @test1() {
6+
entry:
7+
%load = load i32, i32* @d, align 4
8+
ret i32 %load
9+
; CHECK: %[[load:.*]] = load i32, i32* @d, align 4
10+
; CHECK: ret i32 %[[load]]
11+
}

0 commit comments

Comments
 (0)