mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-09-11 15:09:32 +00:00
runtime: require explicit GC layouts
This commit is contained in:
Vendored
+13
-13
@@ -7,7 +7,7 @@ declare nonnull ptr @runtime.alloc(i32, ptr)
|
||||
|
||||
; Test allocating a single int (i32) that should be allocated on the stack.
|
||||
define void @testInt() {
|
||||
%alloc = call align 4 ptr @runtime.alloc(i32 4, ptr null)
|
||||
%alloc = call align 4 ptr @runtime.alloc(i32 4, ptr inttoptr (i32 3 to ptr))
|
||||
store i32 5, ptr %alloc
|
||||
ret void
|
||||
}
|
||||
@@ -15,7 +15,7 @@ define void @testInt() {
|
||||
; Test allocating an array of 3 i16 values that should be allocated on the
|
||||
; stack.
|
||||
define i16 @testArray() {
|
||||
%alloc = call align 2 ptr @runtime.alloc(i32 6, ptr null)
|
||||
%alloc = call align 2 ptr @runtime.alloc(i32 6, ptr inttoptr (i32 3 to ptr))
|
||||
%alloc.1 = getelementptr i16, ptr %alloc, i32 1
|
||||
store i16 5, ptr %alloc.1
|
||||
%alloc.2 = getelementptr i16, ptr %alloc, i32 2
|
||||
@@ -25,15 +25,15 @@ define i16 @testArray() {
|
||||
|
||||
; Test allocating objects with an unknown alignment.
|
||||
define void @testUnknownAlign() {
|
||||
%alloc32 = call ptr @runtime.alloc(i32 32, ptr null)
|
||||
%alloc32 = call ptr @runtime.alloc(i32 32, ptr inttoptr (i32 3 to ptr))
|
||||
store i8 5, ptr %alloc32
|
||||
%alloc24 = call ptr @runtime.alloc(i32 24, ptr null)
|
||||
%alloc24 = call ptr @runtime.alloc(i32 24, ptr inttoptr (i32 3 to ptr))
|
||||
store i16 5, ptr %alloc24
|
||||
%alloc12 = call ptr @runtime.alloc(i32 12, ptr null)
|
||||
%alloc12 = call ptr @runtime.alloc(i32 12, ptr inttoptr (i32 3 to ptr))
|
||||
store i16 5, ptr %alloc12
|
||||
%alloc6 = call ptr @runtime.alloc(i32 6, ptr null)
|
||||
%alloc6 = call ptr @runtime.alloc(i32 6, ptr inttoptr (i32 3 to ptr))
|
||||
store i16 5, ptr %alloc6
|
||||
%alloc3 = call ptr @runtime.alloc(i32 3, ptr null)
|
||||
%alloc3 = call ptr @runtime.alloc(i32 3, ptr inttoptr (i32 3 to ptr))
|
||||
store i16 5, ptr %alloc3
|
||||
ret void
|
||||
}
|
||||
@@ -41,27 +41,27 @@ define void @testUnknownAlign() {
|
||||
; Call a function that will let the pointer escape, so the heap-to-stack
|
||||
; transform shouldn't be applied.
|
||||
define void @testEscapingCall() {
|
||||
%alloc = call align 4 ptr @runtime.alloc(i32 4, ptr null)
|
||||
%alloc = call align 4 ptr @runtime.alloc(i32 4, ptr inttoptr (i32 3 to ptr))
|
||||
%val = call ptr @escapeIntPtr(ptr %alloc)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @testEscapingCall2() {
|
||||
%alloc = call align 4 ptr @runtime.alloc(i32 4, ptr null)
|
||||
%alloc = call align 4 ptr @runtime.alloc(i32 4, ptr inttoptr (i32 3 to ptr))
|
||||
%val = call ptr @escapeIntPtrSometimes(ptr %alloc, ptr %alloc)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Call a function that doesn't let the pointer escape.
|
||||
define void @testNonEscapingCall() {
|
||||
%alloc = call align 4 ptr @runtime.alloc(i32 4, ptr null)
|
||||
%alloc = call align 4 ptr @runtime.alloc(i32 4, ptr inttoptr (i32 3 to ptr))
|
||||
%val = call ptr @noescapeIntPtr(ptr %alloc)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Return the allocated value, which lets it escape.
|
||||
define ptr @testEscapingReturn() {
|
||||
%alloc = call align 4 ptr @runtime.alloc(i32 4, ptr null)
|
||||
%alloc = call align 4 ptr @runtime.alloc(i32 4, ptr inttoptr (i32 3 to ptr))
|
||||
ret ptr %alloc
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ define void @testNonEscapingLoop() {
|
||||
entry:
|
||||
br label %loop
|
||||
loop:
|
||||
%alloc = call align 4 ptr @runtime.alloc(i32 4, ptr null)
|
||||
%alloc = call align 4 ptr @runtime.alloc(i32 4, ptr inttoptr (i32 3 to ptr))
|
||||
%ptr = call ptr @noescapeIntPtr(ptr %alloc)
|
||||
%result = icmp eq ptr null, %ptr
|
||||
br i1 %result, label %loop, label %end
|
||||
@@ -80,7 +80,7 @@ end:
|
||||
|
||||
; Test a zero-sized allocation.
|
||||
define void @testZeroSizedAlloc() {
|
||||
%alloc = call align 1 ptr @runtime.alloc(i32 0, ptr null)
|
||||
%alloc = call align 1 ptr @runtime.alloc(i32 0, ptr inttoptr (i32 3 to ptr))
|
||||
%ptr = call ptr @noescapeIntPtr(ptr %alloc)
|
||||
ret void
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user