summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/CBackend/Writer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-10-16 18:12:13 +0000
committerChris Lattner <sabre@nondot.org>2004-10-16 18:12:13 +0000
commit583dfdcf869b63379a7052e4d0f24fe3e4587679 (patch)
tree6c9da9ff3a498e707333cd6f203692a24f34dbf2 /llvm/lib/Target/CBackend/Writer.cpp
parent81a7a23494bca5bae0d8ed9a0daaaa6c1a9ebe63 (diff)
downloadbcm5719-llvm-583dfdcf869b63379a7052e4d0f24fe3e4587679.tar.gz
bcm5719-llvm-583dfdcf869b63379a7052e4d0f24fe3e4587679.zip
Add support for unreachable and undef
llvm-svn: 17048
Diffstat (limited to 'llvm/lib/Target/CBackend/Writer.cpp')
-rw-r--r--llvm/lib/Target/CBackend/Writer.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/Target/CBackend/Writer.cpp b/llvm/lib/Target/CBackend/Writer.cpp
index c4d8c464837..bc3f839409c 100644
--- a/llvm/lib/Target/CBackend/Writer.cpp
+++ b/llvm/lib/Target/CBackend/Writer.cpp
@@ -174,6 +174,7 @@ namespace {
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 @@ void CWriter::printConstant(Constant *CPV) {
<< *CE << "\n";
abort();
}
+ } else if (isa<UndefValue>(CPV) && CPV->getType()->isFirstClassType()) {
+ Out << "0";
+ return;
}
switch (CPV->getType()->getTypeID()) {
@@ -606,7 +610,7 @@ void CWriter::printConstant(Constant *CPV) {
}
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 @@ void CWriter::printConstant(Constant *CPV) {
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 @@ void CWriter::visitSwitchInst(SwitchInst &SI) {
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;
OpenPOWER on IntegriCloud