interp: always run atomic and volatile loads/stores at runtime

This commit is contained in:
Nia Waldvogel
2022-01-10 14:00:26 -05:00
committed by Ron Evans
parent 0ed34e3cb0
commit aa053b5fb0
3 changed files with 61 additions and 2 deletions
+31
View File
@@ -7,6 +7,9 @@ declare void @externalCall(i64)
@bar.knownAtRuntime = global i64 0
@baz.someGlobal = external global [3 x {i64, i32}]
@baz.someInt = global i32 0
@x.atomicNum = global i32 0
@x.volatileNum = global i32 0
@y.ready = global i32 0
define void @runtime.initAll() unnamed_addr {
entry:
@@ -14,6 +17,8 @@ entry:
call void @foo.init(i8* undef, i8* undef)
call void @bar.init(i8* undef, i8* undef)
call void @main.init(i8* undef, i8* undef)
call void @x.init(i8* undef, i8* undef)
call void @y.init(i8* undef, i8* undef)
ret void
}
@@ -41,3 +46,29 @@ entry:
call void @externalCall(i64 3)
ret void
}
define internal void @x.init(i8* %context, i8* %parentHandle) unnamed_addr {
; Test atomic and volatile memory accesses.
store atomic i32 1, i32* @x.atomicNum seq_cst, align 4
%x = load atomic i32, i32* @x.atomicNum seq_cst, align 4
store i32 %x, i32* @x.atomicNum
%y = load volatile i32, i32* @x.volatileNum
store volatile i32 %y, i32* @x.volatileNum
ret void
}
define internal void @y.init(i8* %context, i8* %parentHandle) unnamed_addr {
entry:
br label %loop
loop:
; Test a wait-loop.
; This function must be reverted.
%val = load atomic i32, i32* @y.ready seq_cst, align 4
%ready = icmp eq i32 %val, 1
br i1 %ready, label %end, label %loop
end:
ret void
}