summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-08-16 01:54:32 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-08-16 01:54:32 +0000
commit0c39d40c8b1e3ef028b4082593896e24633a66d7 (patch)
treeb70be8489bdd6a050bc50bc3497cf9f585fa3e48 /llvm/test
parent1b44db22c6e378080539a35ce1fd1f9b1f85c9b1 (diff)
downloadbcm5719-llvm-0c39d40c8b1e3ef028b4082593896e24633a66d7.tar.gz
bcm5719-llvm-0c39d40c8b1e3ef028b4082593896e24633a66d7.zip
IR: Don't add inbounds to GEPs of extern_weak variables
Global variables that have `extern_weak` linkage may be null, so it's incorrect to add `inbounds` when constant folding. This also fixes a bug when parsing global aliases, whose forward reference placeholders are global variables with `extern_weak` linkage. If GEPs to these aliases are encountered before the alias itself, the GEPs would incorrectly gain the `inbounds` keyword as well. llvm-svn: 215803
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Assembler/ConstantExprNoFold.ll12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/test/Assembler/ConstantExprNoFold.ll b/llvm/test/Assembler/ConstantExprNoFold.ll
index d21441372bf..04ad3f5b130 100644
--- a/llvm/test/Assembler/ConstantExprNoFold.ll
+++ b/llvm/test/Assembler/ConstantExprNoFold.ll
@@ -25,3 +25,15 @@ target datalayout = "p:32:32"
; CHECK: @E = global i64 addrspace(1)* addrspacecast (i64* @A to i64 addrspace(1)*)
@E = global i64 addrspace(1)* addrspacecast(i64* @A to i64 addrspace(1)*)
+
+; Don't add an inbounds on @weak.gep, since @weak may be null.
+; CHECK: @weak.gep = global i32* getelementptr (i32* @weak, i32 1)
+@weak.gep = global i32* getelementptr (i32* @weak, i32 1)
+@weak = extern_weak global i32
+
+; Don't add an inbounds on @glob.a3, since it's not inbounds.
+; CHECK: @glob.a3 = alias getelementptr (i32* @glob.a2, i32 1)
+@glob = global i32 0
+@glob.a3 = alias getelementptr (i32* @glob.a2, i32 1)
+@glob.a2 = alias getelementptr (i32* @glob.a1, i32 1)
+@glob.a1 = alias i32* @glob
OpenPOWER on IntegriCloud