irgen: do not emit an extra terminator for panic thunks

Found with GoSmith.

Differential Revision: http://reviews.llvm.org/D6714

llvm-svn: 224904
This commit is contained in:
Peter Collingbourne 2014-12-28 22:39:01 +00:00
parent 06039218f5
commit b6edff93ae
3 changed files with 16 additions and 4 deletions

View File

@ -110,7 +110,9 @@ func (fr *frame) callRecover(isDeferredRecover bool) *govalue {
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()
}
}

View File

@ -1079,7 +1079,7 @@ func (fr *frame) instruction(instr ssa.Instruction) {
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 @@ func (fr *frame) callBuiltin(typ types.Type, builtin *ssa.Builtin, args []ssa.Va
return nil
case "panic":
fr.callPanic(fr.value(args[0]))
fr.callPanic(fr.value(args[0]), false)
return nil
case "recover":

View File

@ -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("")
}