@@ -5,6 +5,7 @@ target triple = "wasm32-unknown-unknown-wasm"
5
5
6
6
@runtime.stackChainStart = internal global %runtime.stackChainObject* null
7
7
@someGlobal = global i8 3
8
+ @ptrGlobal = global i8** null
8
9
9
10
declare void @runtime.trackPointer (i8* nocapture readonly )
10
11
@@ -25,9 +26,9 @@ define i8* @needsStackSlots() {
25
26
%ptr = call i8* @runtime.alloc (i32 4 , i8* null )
26
27
%4 = getelementptr { %runtime.stackChainObject* , i32 , i8* }, { %runtime.stackChainObject* , i32 , i8* }* %gc.stackobject , i32 0 , i32 2
27
28
store i8* %ptr , i8** %4 , align 4
28
- store %runtime.stackChainObject* %1 , %runtime.stackChainObject** @runtime.stackChainStart , align 4
29
29
call void @someArbitraryFunction ()
30
30
%val = load i8 , i8* @someGlobal , align 1
31
+ store %runtime.stackChainObject* %1 , %runtime.stackChainObject** @runtime.stackChainStart , align 4
31
32
ret i8* %ptr
32
33
}
33
34
@@ -75,8 +76,8 @@ define i8* @fibNext(i8* %x, i8* %y) {
75
76
%out.alloc = call i8* @runtime.alloc (i32 1 , i8* null )
76
77
%4 = getelementptr { %runtime.stackChainObject* , i32 , i8* }, { %runtime.stackChainObject* , i32 , i8* }* %gc.stackobject , i32 0 , i32 2
77
78
store i8* %out.alloc , i8** %4 , align 4
78
- store %runtime.stackChainObject* %1 , %runtime.stackChainObject** @runtime.stackChainStart , align 4
79
79
store i8 %out.val , i8* %out.alloc , align 1
80
+ store %runtime.stackChainObject* %1 , %runtime.stackChainObject** @runtime.stackChainStart , align 4
80
81
ret i8* %out.alloc
81
82
}
82
83
@@ -141,3 +142,37 @@ define void @testGEPBitcast() {
141
142
define void @someArbitraryFunction () {
142
143
ret void
143
144
}
145
+
146
+ define void @earlyPopRegression () {
147
+ %gc.stackobject = alloca { %runtime.stackChainObject* , i32 , i8* }, align 8
148
+ store { %runtime.stackChainObject* , i32 , i8* } { %runtime.stackChainObject* null , i32 1 , i8* null }, { %runtime.stackChainObject* , i32 , i8* }* %gc.stackobject , align 4
149
+ %1 = load %runtime.stackChainObject* , %runtime.stackChainObject** @runtime.stackChainStart , align 4
150
+ %2 = getelementptr { %runtime.stackChainObject* , i32 , i8* }, { %runtime.stackChainObject* , i32 , i8* }* %gc.stackobject , i32 0 , i32 0
151
+ store %runtime.stackChainObject* %1 , %runtime.stackChainObject** %2 , align 4
152
+ %3 = bitcast { %runtime.stackChainObject* , i32 , i8* }* %gc.stackobject to %runtime.stackChainObject*
153
+ store %runtime.stackChainObject* %3 , %runtime.stackChainObject** @runtime.stackChainStart , align 4
154
+ %x.alloc = call i8* @runtime.alloc (i32 4 , i8* null )
155
+ %4 = getelementptr { %runtime.stackChainObject* , i32 , i8* }, { %runtime.stackChainObject* , i32 , i8* }* %gc.stackobject , i32 0 , i32 2
156
+ store i8* %x.alloc , i8** %4 , align 4
157
+ %x = bitcast i8* %x.alloc to i8**
158
+ call void @allocAndSave (i8** %x )
159
+ store %runtime.stackChainObject* %1 , %runtime.stackChainObject** @runtime.stackChainStart , align 4
160
+ ret void
161
+ }
162
+
163
+ define void @allocAndSave (i8** %x ) {
164
+ %gc.stackobject = alloca { %runtime.stackChainObject* , i32 , i8* }, align 8
165
+ store { %runtime.stackChainObject* , i32 , i8* } { %runtime.stackChainObject* null , i32 1 , i8* null }, { %runtime.stackChainObject* , i32 , i8* }* %gc.stackobject , align 4
166
+ %1 = load %runtime.stackChainObject* , %runtime.stackChainObject** @runtime.stackChainStart , align 4
167
+ %2 = getelementptr { %runtime.stackChainObject* , i32 , i8* }, { %runtime.stackChainObject* , i32 , i8* }* %gc.stackobject , i32 0 , i32 0
168
+ store %runtime.stackChainObject* %1 , %runtime.stackChainObject** %2 , align 4
169
+ %3 = bitcast { %runtime.stackChainObject* , i32 , i8* }* %gc.stackobject to %runtime.stackChainObject*
170
+ store %runtime.stackChainObject* %3 , %runtime.stackChainObject** @runtime.stackChainStart , align 4
171
+ %y = call i8* @runtime.alloc (i32 4 , i8* null )
172
+ %4 = getelementptr { %runtime.stackChainObject* , i32 , i8* }, { %runtime.stackChainObject* , i32 , i8* }* %gc.stackobject , i32 0 , i32 2
173
+ store i8* %y , i8** %4 , align 4
174
+ store i8* %y , i8** %x , align 4
175
+ store i8** %x , i8*** @ptrGlobal , align 4
176
+ store %runtime.stackChainObject* %1 , %runtime.stackChainObject** @runtime.stackChainStart , align 4
177
+ ret void
178
+ }
0 commit comments