fix incorrect typing of globals bitmap

This commit is contained in:
Jaden Weiss
2019-09-12 16:33:14 -04:00
parent e26f0b35e3
commit d975ed9373
+13 -2
View File
@@ -398,10 +398,21 @@ func (c *Compiler) addGlobalsBitmap() bool {
for i, b := range bitmapBytes {
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")
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.SetName("runtime.trackedGlobalsBitmap")