mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-11 14:33:41 +00:00
interp: support const getelementptr with non-zero first offset
This is uncommon, but it does happen if the source pointer is a bitcast of a global. For example, if a struct is cast to an i8*, it's possible to index beyond what would appear to be the size of the pointer (i8*).
This commit is contained in:
committed by
Ron Evans
parent
0704794def
commit
27cbb53538
Vendored
+8
@@ -3,6 +3,8 @@ target triple = "x86_64--linux"
|
||||
|
||||
@intToPtrResult = global i8 0
|
||||
@ptrToIntResult = global i8 0
|
||||
@someArray = internal global {i16, i8, i8} zeroinitializer
|
||||
@someArrayPointer = global i8* zeroinitializer
|
||||
|
||||
define void @runtime.initAll() {
|
||||
call void @main.init()
|
||||
@@ -12,6 +14,7 @@ define void @runtime.initAll() {
|
||||
define internal void @main.init() {
|
||||
call void @testIntToPtr()
|
||||
call void @testPtrToInt()
|
||||
call void @testConstGEP()
|
||||
ret void
|
||||
}
|
||||
|
||||
@@ -40,3 +43,8 @@ b:
|
||||
store i8 2, i8* @ptrToIntResult
|
||||
ret void
|
||||
}
|
||||
|
||||
define internal void @testConstGEP() {
|
||||
store i8* getelementptr inbounds (i8, i8* bitcast ({i16, i8, i8}* @someArray to i8*), i32 2), i8** @someArrayPointer
|
||||
ret void
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user