diff options
| author | Chris Lattner <sabre@nondot.org> | 2011-05-22 07:15:13 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2011-05-22 07:15:13 +0000 |
| commit | 1a1acc21914555e4ffbd9fb6194749e3780fd1c2 (patch) | |
| tree | 44b25529de6ca49a8ba5e720b6835aafe89e94df | |
| parent | 93e0f19f1d64feea12bb51f96fdf47a7ab7557d9 (diff) | |
| download | bcm5719-llvm-1a1acc21914555e4ffbd9fb6194749e3780fd1c2.tar.gz bcm5719-llvm-1a1acc21914555e4ffbd9fb6194749e3780fd1c2.zip | |
fix PR9856, an incorrectly conservative assertion: a global can be
"stored once" even if its address is compared.
llvm-svn: 131849
| -rw-r--r-- | llvm/lib/Transforms/IPO/GlobalOpt.cpp | 6 | ||||
| -rw-r--r-- | llvm/test/Transforms/GlobalOpt/crash.ll | 14 |
2 files changed, 17 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp index ded58aca75f..9d98bb156b4 100644 --- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -799,7 +799,8 @@ static bool OptimizeAwayTrappingUsesOfLoads(GlobalVariable *GV, Constant *LV) { // If we get here we could have other crazy uses that are transitively // loaded. 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()) { if (Constant *SOVC = dyn_cast<Constant>(StoredOnceVal)) { if (GV->getInitializer()->getType() != SOVC->getType()) - SOVC = - ConstantExpr::getBitCast(SOVC, GV->getInitializer()->getType()); + SOVC = ConstantExpr::getBitCast(SOVC, GV->getInitializer()->getType()); // Optimize away any trapping uses of the loaded value. if (OptimizeAwayTrappingUsesOfLoads(GV, SOVC)) diff --git a/llvm/test/Transforms/GlobalOpt/crash.ll b/llvm/test/Transforms/GlobalOpt/crash.ll index 9da5a5e3c93..366a874f735 100644 --- a/llvm/test/Transforms/GlobalOpt/crash.ll +++ b/llvm/test/Transforms/GlobalOpt/crash.ll @@ -64,3 +64,17 @@ define void @memset_with_strange_user() ssp { ret void } 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 +} + |

