mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 14:03:39 +00:00
interp: fix phi instruction
I've discovered a bug in the implementation of the PHI instruction in the interp package. This commit fixes the bug. I've found this issue while investigating an issue with maps after running interp per package.
This commit is contained in:
committed by
Ron Evans
parent
b2e72c96f4
commit
c1c3be1aa7
+8
-1
@@ -25,6 +25,7 @@ type function struct {
|
||||
// basicBlock represents a LLVM basic block and contains a slice of
|
||||
// instructions. The last instruction must be a terminator instruction.
|
||||
type basicBlock struct {
|
||||
phiNodes []instruction
|
||||
instructions []instruction
|
||||
}
|
||||
|
||||
@@ -346,7 +347,13 @@ func (r *runner) compileFunction(llvmFn llvm.Value) *function {
|
||||
// This error is handled when actually trying to interpret this
|
||||
// instruction (to not trigger on code that won't be executed).
|
||||
}
|
||||
bb.instructions = append(bb.instructions, inst)
|
||||
if inst.opcode == llvm.PHI {
|
||||
// PHI nodes need to be treated specially, see the comment in
|
||||
// interpreter.go for an explanation.
|
||||
bb.phiNodes = append(bb.phiNodes, inst)
|
||||
} else {
|
||||
bb.instructions = append(bb.instructions, inst)
|
||||
}
|
||||
}
|
||||
}
|
||||
return fn
|
||||
|
||||
Reference in New Issue
Block a user