mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 05:53:39 +00:00
interp: work around AVR function pointers in globals
Not sure how to test this, since we don't really have any AVR tests configured.
This commit is contained in:
committed by
Ron Evans
parent
0f69d016a0
commit
3e6410f323
+8
-1
@@ -903,7 +903,14 @@ func (v rawValue) toLLVMValue(llvmType llvm.Type, mem *memoryView) (llvm.Value,
|
||||
return llvm.Value{}, err
|
||||
}
|
||||
if llvmValue.Type() != llvmType {
|
||||
llvmValue = llvm.ConstBitCast(llvmValue, llvmType)
|
||||
if llvmValue.Type().PointerAddressSpace() != llvmType.PointerAddressSpace() {
|
||||
// Special case for AVR function pointers.
|
||||
// Because go-llvm doesn't have addrspacecast at the moment,
|
||||
// do it indirectly with a ptrtoint/inttoptr pair.
|
||||
llvmValue = llvm.ConstIntToPtr(llvm.ConstPtrToInt(llvmValue, mem.r.uintptrType), llvmType)
|
||||
} else {
|
||||
llvmValue = llvm.ConstBitCast(llvmValue, llvmType)
|
||||
}
|
||||
}
|
||||
return llvmValue, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user