[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...

This commit is contained in:
Tomas Lindquist Olsen
2008-06-14 05:13:49 +02:00
parent 1ae510ae6c
commit de89b4bc6f
10 changed files with 128 additions and 112 deletions

View File

@@ -1,4 +1,5 @@
#include "gen/llvm.h"
#include "llvm/Support/CFG.h"
#include "mtype.h"
#include "aggregate.h"
@@ -735,17 +736,21 @@ void DtoDefineFunc(FuncDeclaration* fd)
// would be nice to figure out how to assert that this is correct
llvm::BasicBlock* lastbb = &func->getBasicBlockList().back();
if (lastbb->empty()) {
if (lastbb->getNumUses() == 0)
lastbb->eraseFromParent();
else {
new llvm::UnreachableInst(lastbb);
/*if (func->getReturnType() == LLType::VoidTy) {
llvm::ReturnInst::Create(lastbb);
}
else {
llvm::ReturnInst::Create(llvm::UndefValue::get(func->getReturnType()), lastbb);
}*/
}
new llvm::UnreachableInst(lastbb);
// if (llvm::pred_begin(lastbb) != llvm::pred_end(lastbb))
// {
// Logger::println("Erasing lastbb");
// lastbb->eraseFromParent();
// }
// else {
// new llvm::UnreachableInst(lastbb);
// // if (func->getReturnType() == LLType::VoidTy) {
// // llvm::ReturnInst::Create(lastbb);
// // }
// // else {
// // llvm::ReturnInst::Create(llvm::UndefValue::get(func->getReturnType()), lastbb);
// // }
// }
}
// if the last block is not terminated we return a null value or void