IR: Don't add inbounds to GEPs of extern_weak variables
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sat, 16 Aug 2014 01:54:32 +0000 (01:54 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sat, 16 Aug 2014 01:54:32 +0000 (01:54 +0000)
commit7a5cb43115ba3c87ac04511c804d0993aa28ddc2
tree123218f5fd369183c5a75abbf69940626e8b82ee
parent89cea3c36b451d5a06d51b3101052f9faea91211
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215803 91177308-0d34-0410-b5e6-96231b3b80d8
lib/IR/ConstantFold.cpp
test/Assembler/ConstantExprNoFold.ll