aboutsummaryrefslogtreecommitdiffhomepage
path: root/transform
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2023-03-16 19:51:24 +0100
committerDamian Gryski <[email protected]>2023-03-16 13:46:03 -0700
commitf8a6e662d8fc5feaa38b2500be6e9fbb6f0a4817 (patch)
tree922c40de505e4e852be3271d673c0dc6bcfe33d5 /transform
parent0ddd65658e3feaf1828e4ff3d9342d435a6a2bb1 (diff)
downloadtinygo-f8a6e662d8fc5feaa38b2500be6e9fbb6f0a4817.tar.gz
tinygo-f8a6e662d8fc5feaa38b2500be6e9fbb6f0a4817.zip
transform: update gc-stackslots test to opaque pointers
Diffstat (limited to 'transform')
-rw-r--r--transform/testdata/gc-stackslots.ll125
-rw-r--r--transform/testdata/gc-stackslots.out.ll258
2 files changed, 185 insertions, 198 deletions
diff --git a/transform/testdata/gc-stackslots.ll b/transform/testdata/gc-stackslots.ll
index c217fb9ad..7f196e9b4 100644
--- a/transform/testdata/gc-stackslots.ll
+++ b/transform/testdata/gc-stackslots.ll
@@ -1,101 +1,99 @@
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown-wasm"
-%runtime.stackChainObject = type { %runtime.stackChainObject*, i32 }
-
[email protected] = external global %runtime.stackChainObject*
[email protected] = external global ptr
@someGlobal = global i8 3
-@ptrGlobal = global i8** null
+@ptrGlobal = global ptr null
-declare void @runtime.trackPointer(i8* nocapture readonly)
+declare void @runtime.trackPointer(ptr nocapture readonly)
-declare noalias nonnull i8* @runtime.alloc(i32, i8*)
+declare noalias nonnull ptr @runtime.alloc(i32, ptr)
; Generic function that returns a pointer (that must be tracked).
-define i8* @getPointer() {
- ret i8* @someGlobal
+define ptr @getPointer() {
+ ret ptr @someGlobal
}
-define i8* @needsStackSlots() {
+define ptr @needsStackSlots() {
; Tracked pointer. Although, in this case the value is immediately returned
; so tracking it is not really necessary.
- %ptr = call i8* @runtime.alloc(i32 4, i8* null)
- call void @runtime.trackPointer(i8* %ptr)
+ %ptr = call ptr @runtime.alloc(i32 4, ptr null)
+ call void @runtime.trackPointer(ptr %ptr)
call void @someArbitraryFunction()
- %val = load i8, i8* @someGlobal
- ret i8* %ptr
+ %val = load i8, ptr @someGlobal
+ ret ptr %ptr
}
; Check some edge cases of pointer tracking.
-define i8* @needsStackSlots2() {
+define ptr @needsStackSlots2() {
; Only one stack slot should be created for this (but at the moment, one is
; created for each call to runtime.trackPointer).
- %ptr1 = call i8* @getPointer()
- call void @runtime.trackPointer(i8* %ptr1)
- call void @runtime.trackPointer(i8* %ptr1)
- call void @runtime.trackPointer(i8* %ptr1)
+ %ptr1 = call ptr @getPointer()
+ call void @runtime.trackPointer(ptr %ptr1)
+ call void @runtime.trackPointer(ptr %ptr1)
+ call void @runtime.trackPointer(ptr %ptr1)
; Create a pointer that does not need to be tracked (but is tracked).
- %ptr2 = getelementptr i8, i8* @someGlobal, i32 0
- call void @runtime.trackPointer(i8* %ptr2)
+ %ptr2 = getelementptr i8, ptr @someGlobal, i32 0
+ call void @runtime.trackPointer(ptr %ptr2)
; Here is finally the point where an allocation happens.
- %unused = call i8* @runtime.alloc(i32 4, i8* null)
- call void @runtime.trackPointer(i8* %unused)
+ %unused = call ptr @runtime.alloc(i32 4, ptr null)
+ call void @runtime.trackPointer(ptr %unused)
- ret i8* %ptr1
+ ret ptr %ptr1
}
; Return a pointer from a caller. Because it doesn't allocate, no stack objects
; need to be created.
-define i8* @noAllocatingFunction() {
- %ptr = call i8* @getPointer()
- call void @runtime.trackPointer(i8* %ptr)
- ret i8* %ptr
+define ptr @noAllocatingFunction() {
+ %ptr = call ptr @getPointer()
+ call void @runtime.trackPointer(ptr %ptr)
+ ret ptr %ptr
}
-define i8* @fibNext(i8* %x, i8* %y) {
- %x.val = load i8, i8* %x
- %y.val = load i8, i8* %y
+define ptr @fibNext(ptr %x, ptr %y) {
+ %x.val = load i8, ptr %x
+ %y.val = load i8, ptr %y
%out.val = add i8 %x.val, %y.val
- %out.alloc = call i8* @runtime.alloc(i32 1, i8* null)
- call void @runtime.trackPointer(i8* %out.alloc)
- store i8 %out.val, i8* %out.alloc
- ret i8* %out.alloc
+ %out.alloc = call ptr @runtime.alloc(i32 1, ptr null)
+ call void @runtime.trackPointer(ptr %out.alloc)
+ store i8 %out.val, ptr %out.alloc
+ ret ptr %out.alloc
}
-define i8* @allocLoop() {
+define ptr @allocLoop() {
entry:
- %entry.x = call i8* @runtime.alloc(i32 1, i8* null)
- call void @runtime.trackPointer(i8* %entry.x)
- %entry.y = call i8* @runtime.alloc(i32 1, i8* null)
- call void @runtime.trackPointer(i8* %entry.y)
- store i8 1, i8* %entry.y
+ %entry.x = call ptr @runtime.alloc(i32 1, ptr null)
+ call void @runtime.trackPointer(ptr %entry.x)
+ %entry.y = call ptr @runtime.alloc(i32 1, ptr null)
+ call void @runtime.trackPointer(ptr %entry.y)
+ store i8 1, ptr %entry.y
br label %loop
loop:
- %prev.y = phi i8* [ %entry.y, %entry ], [ %prev.x, %loop ]
- %prev.x = phi i8* [ %entry.x, %entry ], [ %next.x, %loop ]
- call void @runtime.trackPointer(i8* %prev.x)
- call void @runtime.trackPointer(i8* %prev.y)
- %next.x = call i8* @fibNext(i8* %prev.x, i8* %prev.y)
- call void @runtime.trackPointer(i8* %next.x)
- %next.x.val = load i8, i8* %next.x
+ %prev.y = phi ptr [ %entry.y, %entry ], [ %prev.x, %loop ]
+ %prev.x = phi ptr [ %entry.x, %entry ], [ %next.x, %loop ]
+ call void @runtime.trackPointer(ptr %prev.x)
+ call void @runtime.trackPointer(ptr %prev.y)
+ %next.x = call ptr @fibNext(ptr %prev.x, ptr %prev.y)
+ call void @runtime.trackPointer(ptr %next.x)
+ %next.x.val = load i8, ptr %next.x
%loop.done = icmp ult i8 40, %next.x.val
br i1 %loop.done, label %end, label %loop
end:
- ret i8* %next.x
+ ret ptr %next.x
}
-declare [32 x i8]* @arrayAlloc()
+declare ptr @arrayAlloc()
define void @testGEPBitcast() {
- %arr = call [32 x i8]* @arrayAlloc()
- %arr.bitcast = getelementptr [32 x i8], [32 x i8]* %arr, i32 0, i32 0
- call void @runtime.trackPointer(i8* %arr.bitcast)
- %other = call i8* @runtime.alloc(i32 1, i8* null)
- call void @runtime.trackPointer(i8* %other)
+ %arr = call ptr @arrayAlloc()
+ %arr.bitcast = getelementptr [32 x i8], ptr %arr, i32 0, i32 0
+ call void @runtime.trackPointer(ptr %arr.bitcast)
+ %other = call ptr @runtime.alloc(i32 1, ptr null)
+ call void @runtime.trackPointer(ptr %other)
ret void
}
@@ -104,18 +102,17 @@ define void @someArbitraryFunction() {
}
define void @earlyPopRegression() {
- %x.alloc = call i8* @runtime.alloc(i32 4, i8* null)
- call void @runtime.trackPointer(i8* %x.alloc)
- %x = bitcast i8* %x.alloc to i8**
+ %x.alloc = call ptr @runtime.alloc(i32 4, ptr null)
+ call void @runtime.trackPointer(ptr %x.alloc)
; At this point the pass used to pop the stack chain, resulting in a potential use-after-free during allocAndSave.
- musttail call void @allocAndSave(i8** %x)
+ musttail call void @allocAndSave(ptr %x.alloc)
ret void
}
-define void @allocAndSave(i8** %x) {
- %y = call i8* @runtime.alloc(i32 4, i8* null)
- call void @runtime.trackPointer(i8* %y)
- store i8* %y, i8** %x
- store i8** %x, i8*** @ptrGlobal
+define void @allocAndSave(ptr %x) {
+ %y = call ptr @runtime.alloc(i32 4, ptr null)
+ call void @runtime.trackPointer(ptr %y)
+ store ptr %y, ptr %x
+ store ptr %x, ptr @ptrGlobal
ret void
-} \ No newline at end of file
+}
diff --git a/transform/testdata/gc-stackslots.out.ll b/transform/testdata/gc-stackslots.out.ll
index 83d1c841b..f80d0c96c 100644
--- a/transform/testdata/gc-stackslots.out.ll
+++ b/transform/testdata/gc-stackslots.out.ll
@@ -1,141 +1,134 @@
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown-wasm"
-%runtime.stackChainObject = type { %runtime.stackChainObject*, i32 }
-
[email protected] = internal global %runtime.stackChainObject* null
[email protected] = internal global ptr null
@someGlobal = global i8 3
-@ptrGlobal = global i8** null
+@ptrGlobal = global ptr null
-declare void @runtime.trackPointer(i8* nocapture readonly)
+declare void @runtime.trackPointer(ptr nocapture readonly)
-declare noalias nonnull i8* @runtime.alloc(i32, i8*)
+declare noalias nonnull ptr @runtime.alloc(i32, ptr)
-define i8* @getPointer() {
- ret i8* @someGlobal
+define ptr @getPointer() {
+ ret ptr @someGlobal
}
-define i8* @needsStackSlots() {
- %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8* }, align 8
- store { %runtime.stackChainObject*, i32, i8* } { %runtime.stackChainObject* null, i32 1, i8* null }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, align 4
- %1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- %2 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 0
- store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2, align 4
- %3 = bitcast { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject to %runtime.stackChainObject*
- store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- %ptr = call i8* @runtime.alloc(i32 4, i8* null)
- %4 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 2
- store i8* %ptr, i8** %4, align 4
+define ptr @needsStackSlots() {
+ %gc.stackobject = alloca { ptr, i32, ptr }, align 8
+ store { ptr, i32, ptr } { ptr null, i32 1, ptr null }, ptr %gc.stackobject, align 4
+ %1 = load ptr, ptr @runtime.stackChainStart, align 4
+ %2 = getelementptr { ptr, i32, ptr }, ptr %gc.stackobject, i32 0, i32 0
+ store ptr %1, ptr %2, align 4
+ store ptr %gc.stackobject, ptr @runtime.stackChainStart, align 4
+ %ptr = call ptr @runtime.alloc(i32 4, ptr null)
+ %3 = getelementptr { ptr, i32, ptr }, ptr %gc.stackobject, i32 0, i32 2
+ store ptr %ptr, ptr %3, align 4
call void @someArbitraryFunction()
- %val = load i8, i8* @someGlobal, align 1
- store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- ret i8* %ptr
+ %val = load i8, ptr @someGlobal, align 1
+ store ptr %1, ptr @runtime.stackChainStart, align 4
+ ret ptr %ptr
}
-define i8* @needsStackSlots2() {
- %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, align 8
- store { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* } { %runtime.stackChainObject* null, i32 5, i8* null, i8* null, i8* null, i8* null, i8* null }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, align 4
- %1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- %2 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 0
- store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2, align 4
- %3 = bitcast { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject to %runtime.stackChainObject*
- store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- %ptr1 = call i8* @getPointer()
- %4 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 4
- store i8* %ptr1, i8** %4, align 4
- %5 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 3
- store i8* %ptr1, i8** %5, align 4
- %6 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 2
- store i8* %ptr1, i8** %6, align 4
- %ptr2 = getelementptr i8, i8* @someGlobal, i32 0
- %7 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 5
- store i8* %ptr2, i8** %7, align 4
- %unused = call i8* @runtime.alloc(i32 4, i8* null)
- %8 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 6
- store i8* %unused, i8** %8, align 4
- store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- ret i8* %ptr1
+define ptr @needsStackSlots2() {
+ %gc.stackobject = alloca { ptr, i32, ptr, ptr, ptr, ptr, ptr }, align 8
+ store { ptr, i32, ptr, ptr, ptr, ptr, ptr } { ptr null, i32 5, ptr null, ptr null, ptr null, ptr null, ptr null }, ptr %gc.stackobject, align 4
+ %1 = load ptr, ptr @runtime.stackChainStart, align 4
+ %2 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 0
+ store ptr %1, ptr %2, align 4
+ store ptr %gc.stackobject, ptr @runtime.stackChainStart, align 4
+ %ptr1 = call ptr @getPointer()
+ %3 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 4
+ store ptr %ptr1, ptr %3, align 4
+ %4 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 3
+ store ptr %ptr1, ptr %4, align 4
+ %5 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 2
+ store ptr %ptr1, ptr %5, align 4
+ %ptr2 = getelementptr i8, ptr @someGlobal, i32 0
+ %6 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 5
+ store ptr %ptr2, ptr %6, align 4
+ %unused = call ptr @runtime.alloc(i32 4, ptr null)
+ %7 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 6
+ store ptr %unused, ptr %7, align 4
+ store ptr %1, ptr @runtime.stackChainStart, align 4
+ ret ptr %ptr1
}
-define i8* @noAllocatingFunction() {
- %ptr = call i8* @getPointer()
- ret i8* %ptr
+define ptr @noAllocatingFunction() {
+ %ptr = call ptr @getPointer()
+ ret ptr %ptr
}
-define i8* @fibNext(i8* %x, i8* %y) {
- %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8* }, align 8
- store { %runtime.stackChainObject*, i32, i8* } { %runtime.stackChainObject* null, i32 1, i8* null }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, align 4
- %1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- %2 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 0
- store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2, align 4
- %3 = bitcast { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject to %runtime.stackChainObject*
- store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- %x.val = load i8, i8* %x, align 1
- %y.val = load i8, i8* %y, align 1
+define ptr @fibNext(ptr %x, ptr %y) {
+ %gc.stackobject = alloca { ptr, i32, ptr }, align 8
+ store { ptr, i32, ptr } { ptr null, i32 1, ptr null }, ptr %gc.stackobject, align 4
+ %1 = load ptr, ptr @runtime.stackChainStart, align 4
+ %2 = getelementptr { ptr, i32, ptr }, ptr %gc.stackobject, i32 0, i32 0
+ store ptr %1, ptr %2, align 4
+ store ptr %gc.stackobject, ptr @runtime.stackChainStart, align 4
+ %x.val = load i8, ptr %x, align 1
+ %y.val = load i8, ptr %y, align 1
%out.val = add i8 %x.val, %y.val
- %out.alloc = call i8* @runtime.alloc(i32 1, i8* null)
- %4 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 2
- store i8* %out.alloc, i8** %4, align 4
- store i8 %out.val, i8* %out.alloc, align 1
- store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- ret i8* %out.alloc
+ %out.alloc = call ptr @runtime.alloc(i32 1, ptr null)
+ %3 = getelementptr { ptr, i32, ptr }, ptr %gc.stackobject, i32 0, i32 2
+ store ptr %out.alloc, ptr %3, align 4
+ store i8 %out.val, ptr %out.alloc, align 1
+ store ptr %1, ptr @runtime.stackChainStart, align 4
+ ret ptr %out.alloc
}
-define i8* @allocLoop() {
+define ptr @allocLoop() {
entry:
- %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, align 8
- store { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* } { %runtime.stackChainObject* null, i32 5, i8* null, i8* null, i8* null, i8* null, i8* null }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, align 4
- %0 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- %1 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 0
- store %runtime.stackChainObject* %0, %runtime.stackChainObject** %1, align 4
- %2 = bitcast { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject to %runtime.stackChainObject*
- store %runtime.stackChainObject* %2, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- %entry.x = call i8* @runtime.alloc(i32 1, i8* null)
- %3 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 2
- store i8* %entry.x, i8** %3, align 4
- %entry.y = call i8* @runtime.alloc(i32 1, i8* null)
- %4 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 3
- store i8* %entry.y, i8** %4, align 4
- store i8 1, i8* %entry.y, align 1
+ %gc.stackobject = alloca { ptr, i32, ptr, ptr, ptr, ptr, ptr }, align 8
+ store { ptr, i32, ptr, ptr, ptr, ptr, ptr } { ptr null, i32 5, ptr null, ptr null, ptr null, ptr null, ptr null }, ptr %gc.stackobject, align 4
+ %0 = load ptr, ptr @runtime.stackChainStart, align 4
+ %1 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 0
+ store ptr %0, ptr %1, align 4
+ store ptr %gc.stackobject, ptr @runtime.stackChainStart, align 4
+ %entry.x = call ptr @runtime.alloc(i32 1, ptr null)
+ %2 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 2
+ store ptr %entry.x, ptr %2, align 4
+ %entry.y = call ptr @runtime.alloc(i32 1, ptr null)
+ %3 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 3
+ store ptr %entry.y, ptr %3, align 4
+ store i8 1, ptr %entry.y, align 1
br label %loop
loop: ; preds = %loop, %entry
- %prev.y = phi i8* [ %entry.y, %entry ], [ %prev.x, %loop ]
- %prev.x = phi i8* [ %entry.x, %entry ], [ %next.x, %loop ]
- %5 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 5
- store i8* %prev.y, i8** %5, align 4
- %6 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 4
- store i8* %prev.x, i8** %6, align 4
- %next.x = call i8* @fibNext(i8* %prev.x, i8* %prev.y)
- %7 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject, i32 0, i32 6
- store i8* %next.x, i8** %7, align 4
- %next.x.val = load i8, i8* %next.x, align 1
+ %prev.y = phi ptr [ %entry.y, %entry ], [ %prev.x, %loop ]
+ %prev.x = phi ptr [ %entry.x, %entry ], [ %next.x, %loop ]
+ %4 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 5
+ store ptr %prev.y, ptr %4, align 4
+ %5 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 4
+ store ptr %prev.x, ptr %5, align 4
+ %next.x = call ptr @fibNext(ptr %prev.x, ptr %prev.y)
+ %6 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 6
+ store ptr %next.x, ptr %6, align 4
+ %next.x.val = load i8, ptr %next.x, align 1
%loop.done = icmp ult i8 40, %next.x.val
br i1 %loop.done, label %end, label %loop
end: ; preds = %loop
- store %runtime.stackChainObject* %0, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- ret i8* %next.x
+ store ptr %0, ptr @runtime.stackChainStart, align 4
+ ret ptr %next.x
}
-declare [32 x i8]* @arrayAlloc()
+declare ptr @arrayAlloc()
define void @testGEPBitcast() {
- %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8*, i8* }, align 8
- store { %runtime.stackChainObject*, i32, i8*, i8* } { %runtime.stackChainObject* null, i32 2, i8* null, i8* null }, { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject, align 4
- %1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- %2 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject, i32 0, i32 0
- store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2, align 4
- %3 = bitcast { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject to %runtime.stackChainObject*
- store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- %arr = call [32 x i8]* @arrayAlloc()
- %arr.bitcast = getelementptr [32 x i8], [32 x i8]* %arr, i32 0, i32 0
- %4 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject, i32 0, i32 2
- store i8* %arr.bitcast, i8** %4, align 4
- %other = call i8* @runtime.alloc(i32 1, i8* null)
- %5 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject, i32 0, i32 3
- store i8* %other, i8** %5, align 4
- store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart, align 4
+ %gc.stackobject = alloca { ptr, i32, ptr, ptr }, align 8
+ store { ptr, i32, ptr, ptr } { ptr null, i32 2, ptr null, ptr null }, ptr %gc.stackobject, align 4
+ %1 = load ptr, ptr @runtime.stackChainStart, align 4
+ %2 = getelementptr { ptr, i32, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 0
+ store ptr %1, ptr %2, align 4
+ store ptr %gc.stackobject, ptr @runtime.stackChainStart, align 4
+ %arr = call ptr @arrayAlloc()
+ %arr.bitcast = getelementptr [32 x i8], ptr %arr, i32 0, i32 0
+ %3 = getelementptr { ptr, i32, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 2
+ store ptr %arr.bitcast, ptr %3, align 4
+ %other = call ptr @runtime.alloc(i32 1, ptr null)
+ %4 = getelementptr { ptr, i32, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 3
+ store ptr %other, ptr %4, align 4
+ store ptr %1, ptr @runtime.stackChainStart, align 4
ret void
}
@@ -144,35 +137,32 @@ define void @someArbitraryFunction() {
}
define void @earlyPopRegression() {
- %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8* }, align 8
- store { %runtime.stackChainObject*, i32, i8* } { %runtime.stackChainObject* null, i32 1, i8* null }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, align 4
- %1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- %2 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 0
- store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2, align 4
- %3 = bitcast { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject to %runtime.stackChainObject*
- store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- %x.alloc = call i8* @runtime.alloc(i32 4, i8* null)
- %4 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 2
- store i8* %x.alloc, i8** %4, align 4
- %x = bitcast i8* %x.alloc to i8**
- call void @allocAndSave(i8** %x)
- store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart, align 4
+ %gc.stackobject = alloca { ptr, i32, ptr }, align 8
+ store { ptr, i32, ptr } { ptr null, i32 1, ptr null }, ptr %gc.stackobject, align 4
+ %1 = load ptr, ptr @runtime.stackChainStart, align 4
+ %2 = getelementptr { ptr, i32, ptr }, ptr %gc.stackobject, i32 0, i32 0
+ store ptr %1, ptr %2, align 4
+ store ptr %gc.stackobject, ptr @runtime.stackChainStart, align 4
+ %x.alloc = call ptr @runtime.alloc(i32 4, ptr null)
+ %3 = getelementptr { ptr, i32, ptr }, ptr %gc.stackobject, i32 0, i32 2
+ store ptr %x.alloc, ptr %3, align 4
+ call void @allocAndSave(ptr %x.alloc)
+ store ptr %1, ptr @runtime.stackChainStart, align 4
ret void
}
-define void @allocAndSave(i8** %x) {
- %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8* }, align 8
- store { %runtime.stackChainObject*, i32, i8* } { %runtime.stackChainObject* null, i32 1, i8* null }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, align 4
- %1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- %2 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 0
- store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2, align 4
- %3 = bitcast { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject to %runtime.stackChainObject*
- store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart, align 4
- %y = call i8* @runtime.alloc(i32 4, i8* null)
- %4 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 2
- store i8* %y, i8** %4, align 4
- store i8* %y, i8** %x, align 4
- store i8** %x, i8*** @ptrGlobal, align 4
- store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart, align 4
+define void @allocAndSave(ptr %x) {
+ %gc.stackobject = alloca { ptr, i32, ptr }, align 8
+ store { ptr, i32, ptr } { ptr null, i32 1, ptr null }, ptr %gc.stackobject, align 4
+ %1 = load ptr, ptr @runtime.stackChainStart, align 4
+ %2 = getelementptr { ptr, i32, ptr }, ptr %gc.stackobject, i32 0, i32 0
+ store ptr %1, ptr %2, align 4
+ store ptr %gc.stackobject, ptr @runtime.stackChainStart, align 4
+ %y = call ptr @runtime.alloc(i32 4, ptr null)
+ %3 = getelementptr { ptr, i32, ptr }, ptr %gc.stackobject, i32 0, i32 2
+ store ptr %y, ptr %3, align 4
+ store ptr %y, ptr %x, align 4
+ store ptr %x, ptr @ptrGlobal, align 4
+ store ptr %1, ptr @runtime.stackChainStart, align 4
ret void
}