mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
interp: add regression test for partial store aliasing
Adds a third init function to the store testdata: an initial partial store puts the buffer into the current memory view, then a partial load is followed by another partial store at the same offset, and finally the loaded value is written to a separate global. The expected output captures the current (incorrect) behavior of the in-place partial store optimization: the loaded value gets corrupted by the subsequent in-place store. The next commit fixes this.
This commit is contained in:
Vendored
+17
@@ -4,11 +4,14 @@ target triple = "x86_64--linux"
|
||||
@overlap.buf = global [4 x i8] c"\01\02\03\04"
|
||||
@alias.src = global [4 x i8] c"\05\06\07\08"
|
||||
@alias.dst = global [2 x i8] zeroinitializer
|
||||
@reload.buf = global [4 x i8] c"\01\02\03\04"
|
||||
@reload.out = global [2 x i8] zeroinitializer
|
||||
|
||||
define void @runtime.initAll() unnamed_addr {
|
||||
entry:
|
||||
call void @overlap.init(ptr undef)
|
||||
call void @alias.init(ptr undef)
|
||||
call void @reload.init(ptr undef)
|
||||
ret void
|
||||
}
|
||||
|
||||
@@ -30,3 +33,17 @@ entry:
|
||||
store i8 9, ptr @alias.dst
|
||||
ret void
|
||||
}
|
||||
|
||||
define internal void @reload.init(ptr %context) unnamed_addr {
|
||||
entry:
|
||||
; First store makes reload.buf writable in the current memory view.
|
||||
%tail = getelementptr [4 x i8], ptr @reload.buf, i32 0, i32 3
|
||||
store i8 9, ptr %tail
|
||||
; Partial load whose result may share the underlying buffer.
|
||||
%val = load i16, ptr @reload.buf
|
||||
; Subsequent in-place partial store; this must not corrupt %val.
|
||||
store i8 99, ptr @reload.buf
|
||||
; Write the originally-loaded value to a separate global.
|
||||
store i16 %val, ptr @reload.out
|
||||
ret void
|
||||
}
|
||||
|
||||
Vendored
+2
@@ -4,6 +4,8 @@ target triple = "x86_64--linux"
|
||||
@overlap.buf = local_unnamed_addr global [4 x i8] c"\01\01\02\09"
|
||||
@alias.src = local_unnamed_addr global [4 x i8] c"\05\06\07\08"
|
||||
@alias.dst = local_unnamed_addr global [2 x i8] c"\09\07"
|
||||
@reload.buf = local_unnamed_addr global [4 x i8] c"c\02\03\09"
|
||||
@reload.out = local_unnamed_addr global [2 x i8] c"c\02"
|
||||
|
||||
define void @runtime.initAll() unnamed_addr {
|
||||
entry:
|
||||
|
||||
Reference in New Issue
Block a user