[PATCH] [llgo] irgen: do not emit an extra terminator for panic thunks
Peter Collingbourne
peter at pcc.me.uk
Wed Dec 17 18:42:26 PST 2014
Hi axw,
Found with GoSmith.
http://reviews.llvm.org/D6714
Files:
irgen/builtins.go
irgen/ssa.go
test/irgen/go-panic.go
Index: irgen/builtins.go
===================================================================
--- irgen/builtins.go
+++ irgen/builtins.go
@@ -110,7 +110,9 @@
return newValue(llv, eface)
}
-func (fr *frame) callPanic(arg *govalue) {
+func (fr *frame) callPanic(arg *govalue, term bool) {
fr.runtime.panic.call(fr, arg.value)
- fr.builder.CreateUnreachable()
+ if term {
+ fr.builder.CreateUnreachable()
+ }
}
Index: irgen/ssa.go
===================================================================
--- irgen/ssa.go
+++ irgen/ssa.go
@@ -1079,7 +1079,7 @@
case *ssa.Panic:
arg := fr.value(instr.X)
- fr.callPanic(arg)
+ fr.callPanic(arg, true)
case *ssa.Phi:
typ := instr.Type()
@@ -1190,7 +1190,7 @@
return nil
case "panic":
- fr.callPanic(fr.value(args[0]))
+ fr.callPanic(fr.value(args[0]), false)
return nil
case "recover":
Index: test/irgen/go-panic.go
===================================================================
--- /dev/null
+++ test/irgen/go-panic.go
@@ -0,0 +1,10 @@
+// RUN: llgo -S -emit-llvm -o - %s | FileCheck %s
+
+package foo
+
+func F() {
+ // CHECK: call void @__go_panic
+ // CHECK-NEXT: ret void
+ // CHECK-NEXT: }
+ go panic("")
+}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6714.17418.patch
Type: text/x-patch
Size: 1197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141218/7f71adfb/attachment.bin>
More information about the llvm-commits
mailing list