[llvm] r239308 - Fix assertion failure in global-merge with unused ConstantExpr
Oliver Stannard
oliver.stannard at arm.com
Mon Jun 8 09:55:32 PDT 2015
Author: olista01
Date: Mon Jun 8 11:55:31 2015
New Revision: 239308
URL: http://llvm.org/viewvc/llvm-project?rev=239308&view=rev
Log:
Fix assertion failure in global-merge with unused ConstantExpr
The global-merge pass was crashing because it assumes that all ConstantExprs
(reached via the global variables that they use) have at least one user.
I haven't worked out a way to test this, as an unused ConstantExpr cannot be
represented by serialised IR, and global-merge can only be run in llc, which
does not run any passes which can make a ConstantExpr dead.
This (reduced to the point of silliness) C code triggers this bug when compiled
for arm-none-eabi at -O1:
static a = 7;
static volatile b[10] = {&a};
c;
main() {
c = 0;
for (; c < 10;)
printf(b[c]);
}
Differential Revision: http://reviews.llvm.org/D10314
Modified:
llvm/trunk/lib/CodeGen/GlobalMerge.cpp
Modified: llvm/trunk/lib/CodeGen/GlobalMerge.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalMerge.cpp?rev=239308&r1=239307&r2=239308&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalMerge.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalMerge.cpp Mon Jun 8 11:55:31 2015
@@ -280,6 +280,8 @@ bool GlobalMerge::doMerge(SmallVectorImp
// users, so look through ConstantExpr...
Use *UI, *UE;
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(U.getUser())) {
+ if (CE->use_empty())
+ continue;
UI = &*CE->use_begin();
UE = nullptr;
} else if (isa<Instruction>(U.getUser())) {
More information about the llvm-commits
mailing list