diff gen/functions.cpp @ 262:88252a1af660 trunk

[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
author lindquist
date Sat, 14 Jun 2008 05:13:49 +0200
parents 8dbddae09152
children 665b81613475
line wrap: on
line diff
--- a/gen/functions.cpp	Fri Jun 13 08:21:11 2008 +0200
+++ b/gen/functions.cpp	Sat Jun 14 05:13:49 2008 +0200
@@ -1,4 +1,5 @@
 #include "gen/llvm.h"
+#include "llvm/Support/CFG.h"
 
 #include "mtype.h"
 #include "aggregate.h"
@@ -735,17 +736,21 @@
     // 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