Simple testcase:
int ss;
if ((ss = ss && ss)) {}
crashes in codegen trying to erase the value stored into ss.
Patch attached.
-Eli
Index: CodeGen/CGExprScalar.cpp
===================================================================
--- CodeGen/CGExprScalar.cpp (revision 46389)
+++ CodeGen/CGExprScalar.cpp (working copy)
@@ -315,7 +315,11 @@
if (llvm::ZExtInst *ZI = dyn_cast<llvm::ZExtInst>(Src)) {
if (ZI->getOperand(0)->getType() == llvm::Type::Int1Ty) {
Value *Result = ZI->getOperand(0);
- ZI->eraseFromParent();
+ // If there aren't any more uses, zap the instruction to save space.
+ // Note that there can be more uses, for example if this
+ // is the result of an assignment.
+ if (ZI->use_empty())
+ ZI->eraseFromParent();
return Result;
}
}
_______________________________________________
cfe-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev