1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00

fix PR9856, an incorrectly conservative assertion: a global can be

"stored once" even if its address is compared.

llvm-svn: 131849
This commit is contained in:
Chris Lattner 2011-05-22 07:15:13 +00:00
parent 6cce3b63ab
commit 98ce5cd957
2 changed files with 17 additions and 3 deletions

View File

@ -799,7 +799,8 @@ static bool OptimizeAwayTrappingUsesOfLoads(GlobalVariable *GV, Constant *LV) {
// If we get here we could have other crazy uses that are transitively // If we get here we could have other crazy uses that are transitively
// loaded. // loaded.
assert((isa<PHINode>(GlobalUser) || isa<SelectInst>(GlobalUser) || assert((isa<PHINode>(GlobalUser) || isa<SelectInst>(GlobalUser) ||
isa<ConstantExpr>(GlobalUser)) && "Only expect load and stores!"); isa<ConstantExpr>(GlobalUser) || isa<CmpInst>(GlobalUser)) &&
"Only expect load and stores!");
} }
} }
@ -1589,8 +1590,7 @@ static bool OptimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal,
GV->getInitializer()->isNullValue()) { GV->getInitializer()->isNullValue()) {
if (Constant *SOVC = dyn_cast<Constant>(StoredOnceVal)) { if (Constant *SOVC = dyn_cast<Constant>(StoredOnceVal)) {
if (GV->getInitializer()->getType() != SOVC->getType()) if (GV->getInitializer()->getType() != SOVC->getType())
SOVC = SOVC = ConstantExpr::getBitCast(SOVC, GV->getInitializer()->getType());
ConstantExpr::getBitCast(SOVC, GV->getInitializer()->getType());
// Optimize away any trapping uses of the loaded value. // Optimize away any trapping uses of the loaded value.
if (OptimizeAwayTrappingUsesOfLoads(GV, SOVC)) if (OptimizeAwayTrappingUsesOfLoads(GV, SOVC))

View File

@ -64,3 +64,17 @@ define void @memset_with_strange_user() ssp {
ret void ret void
} }
declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind
; PR9856
@g_52 = internal global i32** null, align 8
@g_90 = external global i32*, align 8
define void @icmp_user_of_stored_once() nounwind ssp {
entry:
%tmp4 = load i32*** @g_52, align 8
store i32** @g_90, i32*** @g_52
%cmp17 = icmp ne i32*** undef, @g_52
ret void
}