compiler: fix invalid incoming block in complex typeassert flow

A single *ssa.BasicBlock may be split in multiple LLVM basic blocks due
to typeassert instructions. This means the incoming block and outgoing
block are different. PHI nodes need to get the result from the outgoing
block, which was fixed before, but incoming branches need to branch to
the incoming block, not the outgoing block.

Branching to the outgoing block led to a LLVM verification error when
compiling the fmt package.

Originally found in (*fmt.pp).handleMethods.
This commit is contained in:
Ayke van Laethem
2018-10-23 14:59:44 +02:00
parent 96f74ec153
commit 6c6a43310a
3 changed files with 32 additions and 15 deletions
+13
View File
@@ -20,6 +20,8 @@ func main() {
println("Stringer.String():", s.String())
var itf interface{} = s
println("Stringer.(*Thing).String():", itf.(Stringer).String())
println("nested switch:", nestedSwitch('v', 3))
}
func printItf(val interface{}) {
@@ -46,6 +48,17 @@ func printItf(val interface{}) {
}
}
func nestedSwitch(verb rune, arg interface{}) bool {
switch verb {
case 'v', 's':
switch arg.(type) {
case int:
return true
}
}
return false
}
type Thing struct {
name string
}
+1
View File
@@ -16,3 +16,4 @@ is Tuple: 0 8 16 24
SmallPair.Print: 3 5
Stringer.String(): foo
Stringer.(*Thing).String(): foo
nested switch: true