aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-02-13 13:27:16 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-02-13 13:27:16 -0800
commitdc91a56ebfd39c9a3f8c596dfe08e466fe7512be (patch)
tree5c5b7a1d1e0bb1a3ac23440aa9a3426d304f1891
parent04faad37ba15e237c87e58e9914a998a3d7a2ed1 (diff)
parent6f629a513c37587247dc83b961e86c177cef5d6d (diff)
Merge pull request #12 from sunfishcode/incoming
Don't leave behind unreachable blocks with illegal instructions.
-rw-r--r--lib/Transforms/NaCl/ExpandI64.cpp6
-rw-r--r--test/Transforms/NaCl/expand-i64.ll13
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/Transforms/NaCl/ExpandI64.cpp b/lib/Transforms/NaCl/ExpandI64.cpp
index 8f0efb2478..d6c75c0577 100644
--- a/lib/Transforms/NaCl/ExpandI64.cpp
+++ b/lib/Transforms/NaCl/ExpandI64.cpp
@@ -38,6 +38,7 @@
#include "llvm/Pass.h"
#include "llvm/Support/CFG.h"
#include "llvm/Transforms/NaCl.h"
+#include "llvm/Transforms/Utils/Local.h"
#include <map>
#include "llvm/Support/raw_ostream.h"
@@ -1031,6 +1032,11 @@ bool ExpandI64::runOnModule(Module &M) {
Instruction *D = Dead.pop_back_val();
D->eraseFromParent();
}
+
+ // We only visited blocks found by a DFS walk from the entry, so we haven't
+ // visited any unreachable blocks, and they may still contain illegal
+ // instructions at this point. Being unreachable, they can simply be deleted.
+ removeUnreachableBlocks(*Func);
}
// post pass - clean up illegal functions that were legalized. We do this
diff --git a/test/Transforms/NaCl/expand-i64.ll b/test/Transforms/NaCl/expand-i64.ll
index 2997264058..df4804d19b 100644
--- a/test/Transforms/NaCl/expand-i64.ll
+++ b/test/Transforms/NaCl/expand-i64.ll
@@ -270,3 +270,16 @@ define i64 @sext(i32 %x) {
%y = sext i32 %x to i64
ret i64 %y
}
+
+; CHECK: define void @unreachable_blocks(i64* %p) {
+; CHECK-NEXT: ret void
+; CHECK-NEXT: }
+define void @unreachable_blocks(i64* %p) {
+ ret void
+
+dead:
+ %t = load i64* %p
+ %s = add i64 %t, 1
+ store i64 %s, i64* %p
+ ret void
+}