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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17094 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-10-17 17:48:59 +00:00
parent 611fb259ba
commit 665825e58e
2 changed files with 22 additions and 12 deletions

View File

@ -523,7 +523,9 @@ void CWriter::printConstant(Constant *CPV) {
abort(); abort();
} }
} else if (isa<UndefValue>(CPV) && CPV->getType()->isFirstClassType()) { } else if (isa<UndefValue>(CPV) && CPV->getType()->isFirstClassType()) {
Out << "0"; Out << "((";
printType(Out, CPV->getType());
Out << ")/*UNDEF*/0)";
return; return;
} }
@ -1234,11 +1236,14 @@ void CWriter::printPHICopiesForSuccessors(BasicBlock *CurBlock,
SI != E; ++SI) SI != E; ++SI)
for (BasicBlock::iterator I = SI->begin(); isa<PHINode>(I); ++I) { for (BasicBlock::iterator I = SI->begin(); isa<PHINode>(I); ++I) {
PHINode *PN = cast<PHINode>(I); PHINode *PN = cast<PHINode>(I);
// now we have to do the printing // Now we have to do the printing.
Out << std::string(Indent, ' '); Value *IV = PN->getIncomingValueForBlock(CurBlock);
Out << " " << Mang->getValueName(I) << "__PHI_TEMPORARY = "; if (!isa<UndefValue>(IV)) {
writeOperand(PN->getIncomingValue(PN->getBasicBlockIndex(CurBlock))); Out << std::string(Indent, ' ');
Out << "; /* for PHI node */\n"; Out << " " << Mang->getValueName(I) << "__PHI_TEMPORARY = ";
writeOperand(IV);
Out << "; /* for PHI node */\n";
}
} }
} }

View File

@ -523,7 +523,9 @@ void CWriter::printConstant(Constant *CPV) {
abort(); abort();
} }
} else if (isa<UndefValue>(CPV) && CPV->getType()->isFirstClassType()) { } else if (isa<UndefValue>(CPV) && CPV->getType()->isFirstClassType()) {
Out << "0"; Out << "((";
printType(Out, CPV->getType());
Out << ")/*UNDEF*/0)";
return; return;
} }
@ -1234,11 +1236,14 @@ void CWriter::printPHICopiesForSuccessors(BasicBlock *CurBlock,
SI != E; ++SI) SI != E; ++SI)
for (BasicBlock::iterator I = SI->begin(); isa<PHINode>(I); ++I) { for (BasicBlock::iterator I = SI->begin(); isa<PHINode>(I); ++I) {
PHINode *PN = cast<PHINode>(I); PHINode *PN = cast<PHINode>(I);
// now we have to do the printing // Now we have to do the printing.
Out << std::string(Indent, ' '); Value *IV = PN->getIncomingValueForBlock(CurBlock);
Out << " " << Mang->getValueName(I) << "__PHI_TEMPORARY = "; if (!isa<UndefValue>(IV)) {
writeOperand(PN->getIncomingValue(PN->getBasicBlockIndex(CurBlock))); Out << std::string(Indent, ' ');
Out << "; /* for PHI node */\n"; Out << " " << Mang->getValueName(I) << "__PHI_TEMPORARY = ";
writeOperand(IV);
Out << "; /* for PHI node */\n";
}
} }
} }