diff options
author | Dan Gohman <sunfish@google.com> | 2014-02-13 11:47:44 -0800 |
---|---|---|
committer | Dan Gohman <sunfish@google.com> | 2014-02-13 11:47:44 -0800 |
commit | 6f629a513c37587247dc83b961e86c177cef5d6d (patch) | |
tree | 5c5b7a1d1e0bb1a3ac23440aa9a3426d304f1891 | |
parent | 04faad37ba15e237c87e58e9914a998a3d7a2ed1 (diff) |
Don't leave behind unreachable blocks with illegal instructions.
-rw-r--r-- | lib/Transforms/NaCl/ExpandI64.cpp | 6 | ||||
-rw-r--r-- | test/Transforms/NaCl/expand-i64.ll | 13 |
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 +} |