diff options
author | Chris Lattner <sabre@nondot.org> | 2004-10-17 17:48:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-10-17 17:48:59 +0000 |
commit | 621c413a1bff5f76f325c22acf8ee9afed8dc794 (patch) | |
tree | ff19247ed4f87a3ef2c3d69edebbd157ca6dc418 | |
parent | 068555314bcc612605b9f23af2415c31f7f3b4b2 (diff) | |
download | bcm5719-llvm-621c413a1bff5f76f325c22acf8ee9afed8dc794.tar.gz bcm5719-llvm-621c413a1bff5f76f325c22acf8ee9afed8dc794.zip |
The first hunk corrects a bug when printing undef null values. We would print
0->field, which is illegal. Now we print ((foo*)0)->field.
The second hunk is an optimization to not print undefined phi values.
llvm-svn: 17094
-rw-r--r-- | llvm/lib/Target/CBackend/Writer.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/llvm/lib/Target/CBackend/Writer.cpp b/llvm/lib/Target/CBackend/Writer.cpp index bc3f839409c..96eb684d29e 100644 --- a/llvm/lib/Target/CBackend/Writer.cpp +++ b/llvm/lib/Target/CBackend/Writer.cpp @@ -523,7 +523,9 @@ void CWriter::printConstant(Constant *CPV) { abort(); } } else if (isa<UndefValue>(CPV) && CPV->getType()->isFirstClassType()) { - Out << "0"; + Out << "(("; + printType(Out, CPV->getType()); + Out << ")/*UNDEF*/0)"; return; } @@ -1234,11 +1236,14 @@ void CWriter::printPHICopiesForSuccessors(BasicBlock *CurBlock, SI != E; ++SI) for (BasicBlock::iterator I = SI->begin(); isa<PHINode>(I); ++I) { PHINode *PN = cast<PHINode>(I); - // now we have to do the printing - Out << std::string(Indent, ' '); - Out << " " << Mang->getValueName(I) << "__PHI_TEMPORARY = "; - writeOperand(PN->getIncomingValue(PN->getBasicBlockIndex(CurBlock))); - Out << "; /* for PHI node */\n"; + // Now we have to do the printing. + Value *IV = PN->getIncomingValueForBlock(CurBlock); + if (!isa<UndefValue>(IV)) { + Out << std::string(Indent, ' '); + Out << " " << Mang->getValueName(I) << "__PHI_TEMPORARY = "; + writeOperand(IV); + Out << "; /* for PHI node */\n"; + } } } |