aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-03-13 21:08:06 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-03-13 21:09:54 -0700
commit877c359b56f78caf3e1db5f3baff35520c57af9d (patch)
tree563cdea43a36ade7da0df991197e905132a788ef
parent332bf03ca0d63aefc7cd8a38f938568e0ad77245 (diff)
do not emit code after a switch; fixes #946
-rw-r--r--src/analyzer.js2
-rw-r--r--tests/cases/breakinthemiddle3.ll26
2 files changed, 27 insertions, 1 deletions
diff --git a/src/analyzer.js b/src/analyzer.js
index 926ac9d3..b73cc943 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -18,7 +18,7 @@ function recomputeLines(func) {
// Handy sets
var BRANCH_INVOKE = set('branch', 'invoke');
-var LABEL_ENDERS = set('branch', 'return');
+var LABEL_ENDERS = set('branch', 'return', 'switch');
var SIDE_EFFECT_CAUSERS = set('call', 'invoke', 'atomic');
var UNUNFOLDABLE = set('value', 'structvalue', 'type', 'phiparam');
diff --git a/tests/cases/breakinthemiddle3.ll b/tests/cases/breakinthemiddle3.ll
new file mode 100644
index 00000000..e9173965
--- /dev/null
+++ b/tests/cases/breakinthemiddle3.ll
@@ -0,0 +1,26 @@
+@.str = private constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1]
+
+define linkonce_odr i32 @main() align 2 {
+ %333 = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ %199 = trunc i8 1 to i1 ; [#uses=1]
+ switch i32 %333, label %label999 [
+ i32 1000, label %label995
+ ] ; switch should ignore all code after it in the block
+ ; No predecessors!
+ %a472 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ cleanup
+ %a473 = extractvalue { i8*, i32 } %a472, 0
+ %a474 = extractvalue { i8*, i32 } %a472, 1
+ br label %label999
+
+label995:
+ %333b = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ br label %label999
+
+label999: ; preds = %555
+ ret i32 0
+}
+
+declare i32 @printf(i8*)
+declare i32 @__gxx_personality_v0(...)
+