[llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Oct 16 11:12:23 PDT 2004
Changes in directory llvm/lib/Target/CBackend:
Writer.cpp updated: 1.201 -> 1.202
---
Log message:
Add support for unreachable and undef
---
Diffs of the changes: (+10 -2)
Index: llvm/lib/Target/CBackend/Writer.cpp
diff -u llvm/lib/Target/CBackend/Writer.cpp:1.201 llvm/lib/Target/CBackend/Writer.cpp:1.202
--- llvm/lib/Target/CBackend/Writer.cpp:1.201 Mon Oct 11 10:50:40 2004
+++ llvm/lib/Target/CBackend/Writer.cpp Sat Oct 16 13:12:13 2004
@@ -174,6 +174,7 @@
void visitUnwindInst(UnwindInst &I) {
assert(0 && "Lowerinvoke pass didn't work!");
}
+ void visitUnreachableInst(UnreachableInst &I);
void visitPHINode(PHINode &I);
void visitBinaryOperator(Instruction &I);
@@ -521,6 +522,9 @@
<< *CE << "\n";
abort();
}
+ } else if (isa<UndefValue>(CPV) && CPV->getType()->isFirstClassType()) {
+ Out << "0";
+ return;
}
switch (CPV->getType()->getTypeID()) {
@@ -606,7 +610,7 @@
}
case Type::ArrayTyID:
- if (isa<ConstantAggregateZero>(CPV)) {
+ if (isa<ConstantAggregateZero>(CPV) || isa<UndefValue>(CPV)) {
const ArrayType *AT = cast<ArrayType>(CPV->getType());
Out << "{";
if (AT->getNumElements()) {
@@ -625,7 +629,7 @@
break;
case Type::StructTyID:
- if (isa<ConstantAggregateZero>(CPV)) {
+ if (isa<ConstantAggregateZero>(CPV) || isa<UndefValue>(CPV)) {
const StructType *ST = cast<StructType>(CPV->getType());
Out << "{";
if (ST->getNumElements()) {
@@ -1205,6 +1209,10 @@
Out << " }\n";
}
+void CWriter::visitUnreachableInst(UnreachableInst &I) {
+ Out << " /*UNREACHABLE*/\n";
+}
+
bool CWriter::isGotoCodeNecessary(BasicBlock *From, BasicBlock *To) {
/// FIXME: This should be reenabled, but loop reordering safe!!
return true;
More information about the llvm-commits
mailing list