compiler, runtime: add layout parameter to runtime.alloc

This layout parameter is currently always nil and ignored, but will
eventually contain a pointer to a memory layout.

This commit also adds module verification to the transform tests, as I
found out that it didn't (and therefore didn't initially catch all
bugs).
This commit is contained in:
Ayke van Laethem
2021-07-09 14:01:37 +02:00
committed by Ron Evans
parent c454568688
commit f24a93c51d
38 changed files with 99 additions and 89 deletions
+9 -9
View File
@@ -3,11 +3,11 @@ target triple = "armv7m-none-eabi"
@runtime.zeroSizedAlloc = internal global i8 0, align 1
declare nonnull i8* @runtime.alloc(i32)
declare nonnull i8* @runtime.alloc(i32, i8*)
; Test allocating a single int (i32) that should be allocated on the stack.
define void @testInt() {
%1 = call i8* @runtime.alloc(i32 4)
%1 = call i8* @runtime.alloc(i32 4, i8* null)
%2 = bitcast i8* %1 to i32*
store i32 5, i32* %2
ret void
@@ -16,7 +16,7 @@ define void @testInt() {
; Test allocating an array of 3 i16 values that should be allocated on the
; stack.
define i16 @testArray() {
%1 = call i8* @runtime.alloc(i32 6)
%1 = call i8* @runtime.alloc(i32 6, i8* null)
%2 = bitcast i8* %1 to i16*
%3 = getelementptr i16, i16* %2, i32 1
store i16 5, i16* %3
@@ -28,14 +28,14 @@ define i16 @testArray() {
; Call a function that will let the pointer escape, so the heap-to-stack
; transform shouldn't be applied.
define void @testEscapingCall() {
%1 = call i8* @runtime.alloc(i32 4)
%1 = call i8* @runtime.alloc(i32 4, i8* null)
%2 = bitcast i8* %1 to i32*
%3 = call i32* @escapeIntPtr(i32* %2)
ret void
}
define void @testEscapingCall2() {
%1 = call i8* @runtime.alloc(i32 4)
%1 = call i8* @runtime.alloc(i32 4, i8* null)
%2 = bitcast i8* %1 to i32*
%3 = call i32* @escapeIntPtrSometimes(i32* %2, i32* %2)
ret void
@@ -43,7 +43,7 @@ define void @testEscapingCall2() {
; Call a function that doesn't let the pointer escape.
define void @testNonEscapingCall() {
%1 = call i8* @runtime.alloc(i32 4)
%1 = call i8* @runtime.alloc(i32 4, i8* null)
%2 = bitcast i8* %1 to i32*
%3 = call i32* @noescapeIntPtr(i32* %2)
ret void
@@ -51,7 +51,7 @@ define void @testNonEscapingCall() {
; Return the allocated value, which lets it escape.
define i32* @testEscapingReturn() {
%1 = call i8* @runtime.alloc(i32 4)
%1 = call i8* @runtime.alloc(i32 4, i8* null)
%2 = bitcast i8* %1 to i32*
ret i32* %2
}
@@ -61,7 +61,7 @@ define void @testNonEscapingLoop() {
entry:
br label %loop
loop:
%0 = call i8* @runtime.alloc(i32 4)
%0 = call i8* @runtime.alloc(i32 4, i8* null)
%1 = bitcast i8* %0 to i32*
%2 = call i32* @noescapeIntPtr(i32* %1)
%3 = icmp eq i32* null, %2
@@ -72,7 +72,7 @@ end:
; Test a zero-sized allocation.
define void @testZeroSizedAlloc() {
%1 = call i8* @runtime.alloc(i32 0)
%1 = call i8* @runtime.alloc(i32 0, i8* null)
%2 = bitcast i8* %1 to i32*
%3 = call i32* @noescapeIntPtr(i32* %2)
ret void