mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-19 03:54:01 +00:00
fix incorrect typing of globals bitmap
This commit is contained in:
+13
-2
@@ -398,10 +398,21 @@ func (c *Compiler) addGlobalsBitmap() bool {
|
|||||||
for i, b := range bitmapBytes {
|
for i, b := range bitmapBytes {
|
||||||
bitmapValues[len(bitmapBytes)-i-1] = llvm.ConstInt(c.ctx.Int8Type(), uint64(b), false)
|
bitmapValues[len(bitmapBytes)-i-1] = llvm.ConstInt(c.ctx.Int8Type(), uint64(b), false)
|
||||||
}
|
}
|
||||||
bitmapArray := llvm.ConstArray(llvm.ArrayType(c.ctx.Int8Type(), len(bitmapBytes)), bitmapValues)
|
bitmapArray := llvm.ConstArray(c.ctx.Int8Type(), bitmapValues)
|
||||||
bitmapNew := llvm.AddGlobal(c.mod, bitmapArray.Type(), "runtime.trackedGlobalsBitmap.tmp")
|
bitmapNew := llvm.AddGlobal(c.mod, bitmapArray.Type(), "runtime.trackedGlobalsBitmap.tmp")
|
||||||
bitmapOld := c.mod.NamedGlobal("runtime.trackedGlobalsBitmap")
|
bitmapOld := c.mod.NamedGlobal("runtime.trackedGlobalsBitmap")
|
||||||
bitmapOld.ReplaceAllUsesWith(bitmapNew)
|
for _, inst := range getUses(bitmapOld) {
|
||||||
|
c.builder.SetInsertPointBefore(inst)
|
||||||
|
bc := c.builder.CreateBitCast(bitmapNew, bitmapOld.Type(), "runtime.trackedGlobalsBitmap.cast")
|
||||||
|
for i := 0; i < inst.OperandsCount(); i++ {
|
||||||
|
if inst.Operand(i) == bitmapOld {
|
||||||
|
inst.SetOperand(i, bc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(getUses(bitmapOld)) > 0 {
|
||||||
|
panic("failed to eliminate tracked globals bitmap representation")
|
||||||
|
}
|
||||||
bitmapNew.SetInitializer(bitmapArray)
|
bitmapNew.SetInitializer(bitmapArray)
|
||||||
bitmapNew.SetName("runtime.trackedGlobalsBitmap")
|
bitmapNew.SetName("runtime.trackedGlobalsBitmap")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user