[cfe-commits] r46519 - in /cfe/trunk: CodeGen/CGExprScalar.cpp test/CodeGen/boolassign.c
Eli Friedman
eli.friedman at gmail.com
Tue Jan 29 10:13:51 PST 2008
Author: efriedma
Date: Tue Jan 29 12:13:51 2008
New Revision: 46519
URL: http://llvm.org/viewvc/llvm-project?rev=46519&view=rev
Log:
Fix a bug where CodeGen would attempt to erase an instruction that was
already used.
Added:
cfe/trunk/test/CodeGen/boolassign.c
Modified:
cfe/trunk/CodeGen/CGExprScalar.cpp
Modified: cfe/trunk/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExprScalar.cpp?rev=46519&r1=46518&r2=46519&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/CodeGen/CGExprScalar.cpp Tue Jan 29 12:13:51 2008
@@ -320,7 +320,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;
}
}
Added: cfe/trunk/test/CodeGen/boolassign.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/boolassign.c?rev=46519&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/boolassign.c (added)
+++ cfe/trunk/test/CodeGen/boolassign.c Tue Jan 29 12:13:51 2008
@@ -0,0 +1,6 @@
+// RUN: clang %s -emit-llvm
+
+int testBoolAssign(void) {
+int ss;
+if ((ss = ss && ss)) {}
+}
More information about the cfe-commits
mailing list