transform: update gc-stackslots test to opaque pointers
Этот коммит содержится в:
		
							родитель
							
								
									0ddd65658e
								
							
						
					
					
						коммит
						f8a6e662d8
					
				
					 2 изменённых файлов: 185 добавлений и 198 удалений
				
			
		
							
								
								
									
										123
									
								
								transform/testdata/gc-stackslots.ll
									
										
									
									
										предоставленный
									
									
								
							
							
						
						
									
										123
									
								
								transform/testdata/gc-stackslots.ll
									
										
									
									
										предоставленный
									
									
								
							|  | @ -1,101 +1,99 @@ | ||||||
| target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" | target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" | ||||||
| target triple = "wasm32-unknown-unknown-wasm" | target triple = "wasm32-unknown-unknown-wasm" | ||||||
| 
 | 
 | ||||||
| %runtime.stackChainObject = type { %runtime.stackChainObject*, i32 } | @runtime.stackChainStart = external global ptr | ||||||
| 
 |  | ||||||
| @runtime.stackChainStart = external global %runtime.stackChainObject* |  | ||||||
| @someGlobal = global i8 3 | @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). | ; Generic function that returns a pointer (that must be tracked). | ||||||
| define i8* @getPointer() { | define ptr @getPointer() { | ||||||
|     ret i8* @someGlobal |     ret ptr @someGlobal | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| define i8* @needsStackSlots() { | define ptr @needsStackSlots() { | ||||||
|   ; Tracked pointer. Although, in this case the value is immediately returned |   ; Tracked pointer. Although, in this case the value is immediately returned | ||||||
|   ; so tracking it is not really necessary. |   ; so tracking it is not really necessary. | ||||||
|   %ptr = call i8* @runtime.alloc(i32 4, i8* null) |   %ptr = call ptr @runtime.alloc(i32 4, ptr null) | ||||||
|   call void @runtime.trackPointer(i8* %ptr) |   call void @runtime.trackPointer(ptr %ptr) | ||||||
|   call void @someArbitraryFunction() |   call void @someArbitraryFunction() | ||||||
|   %val = load i8, i8* @someGlobal |   %val = load i8, ptr @someGlobal | ||||||
|   ret i8* %ptr |   ret ptr %ptr | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ; Check some edge cases of pointer tracking. | ; 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 |   ; Only one stack slot should be created for this (but at the moment, one is | ||||||
|   ; created for each call to runtime.trackPointer). |   ; created for each call to runtime.trackPointer). | ||||||
|   %ptr1 = call i8* @getPointer() |   %ptr1 = call ptr @getPointer() | ||||||
|   call void @runtime.trackPointer(i8* %ptr1) |   call void @runtime.trackPointer(ptr %ptr1) | ||||||
|   call void @runtime.trackPointer(i8* %ptr1) |   call void @runtime.trackPointer(ptr %ptr1) | ||||||
|   call void @runtime.trackPointer(i8* %ptr1) |   call void @runtime.trackPointer(ptr %ptr1) | ||||||
| 
 | 
 | ||||||
|   ; Create a pointer that does not need to be tracked (but is tracked). |   ; Create a pointer that does not need to be tracked (but is tracked). | ||||||
|   %ptr2 = getelementptr i8, i8* @someGlobal, i32 0 |   %ptr2 = getelementptr i8, ptr @someGlobal, i32 0 | ||||||
|   call void @runtime.trackPointer(i8* %ptr2) |   call void @runtime.trackPointer(ptr %ptr2) | ||||||
| 
 | 
 | ||||||
|   ; Here is finally the point where an allocation happens. |   ; Here is finally the point where an allocation happens. | ||||||
|   %unused = call i8* @runtime.alloc(i32 4, i8* null) |   %unused = call ptr @runtime.alloc(i32 4, ptr null) | ||||||
|   call void @runtime.trackPointer(i8* %unused) |   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 | ; Return a pointer from a caller. Because it doesn't allocate, no stack objects | ||||||
| ; need to be created. | ; need to be created. | ||||||
| define i8* @noAllocatingFunction() { | define ptr @noAllocatingFunction() { | ||||||
|   %ptr = call i8* @getPointer() |   %ptr = call ptr @getPointer() | ||||||
|   call void @runtime.trackPointer(i8* %ptr) |   call void @runtime.trackPointer(ptr %ptr) | ||||||
|   ret i8* %ptr |   ret ptr %ptr | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| define i8* @fibNext(i8* %x, i8* %y) { | define ptr @fibNext(ptr %x, ptr %y) { | ||||||
|   %x.val = load i8, i8* %x |   %x.val = load i8, ptr %x | ||||||
|   %y.val = load i8, i8* %y |   %y.val = load i8, ptr %y | ||||||
|   %out.val = add i8 %x.val, %y.val |   %out.val = add i8 %x.val, %y.val | ||||||
|   %out.alloc = call i8* @runtime.alloc(i32 1, i8* null) |   %out.alloc = call ptr @runtime.alloc(i32 1, ptr null) | ||||||
|   call void @runtime.trackPointer(i8* %out.alloc) |   call void @runtime.trackPointer(ptr %out.alloc) | ||||||
|   store i8 %out.val, i8* %out.alloc |   store i8 %out.val, ptr %out.alloc | ||||||
|   ret i8* %out.alloc |   ret ptr %out.alloc | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| define i8* @allocLoop() { | define ptr @allocLoop() { | ||||||
| entry: | entry: | ||||||
|   %entry.x = call i8* @runtime.alloc(i32 1, i8* null) |   %entry.x = call ptr @runtime.alloc(i32 1, ptr null) | ||||||
|   call void @runtime.trackPointer(i8* %entry.x) |   call void @runtime.trackPointer(ptr %entry.x) | ||||||
|   %entry.y = call i8* @runtime.alloc(i32 1, i8* null) |   %entry.y = call ptr @runtime.alloc(i32 1, ptr null) | ||||||
|   call void @runtime.trackPointer(i8* %entry.y) |   call void @runtime.trackPointer(ptr %entry.y) | ||||||
|   store i8 1, i8* %entry.y |   store i8 1, ptr %entry.y | ||||||
|   br label %loop |   br label %loop | ||||||
| 
 | 
 | ||||||
| loop: | loop: | ||||||
|   %prev.y = phi i8* [ %entry.y, %entry ], [ %prev.x, %loop ] |   %prev.y = phi ptr [ %entry.y, %entry ], [ %prev.x, %loop ] | ||||||
|   %prev.x = phi i8* [ %entry.x, %entry ], [ %next.x, %loop ] |   %prev.x = phi ptr [ %entry.x, %entry ], [ %next.x, %loop ] | ||||||
|   call void @runtime.trackPointer(i8* %prev.x) |   call void @runtime.trackPointer(ptr %prev.x) | ||||||
|   call void @runtime.trackPointer(i8* %prev.y) |   call void @runtime.trackPointer(ptr %prev.y) | ||||||
|   %next.x = call i8* @fibNext(i8* %prev.x, i8* %prev.y) |   %next.x = call ptr @fibNext(ptr %prev.x, ptr %prev.y) | ||||||
|   call void @runtime.trackPointer(i8* %next.x) |   call void @runtime.trackPointer(ptr %next.x) | ||||||
|   %next.x.val = load i8, i8* %next.x |   %next.x.val = load i8, ptr %next.x | ||||||
|   %loop.done = icmp ult i8 40, %next.x.val |   %loop.done = icmp ult i8 40, %next.x.val | ||||||
|   br i1 %loop.done, label %end, label %loop |   br i1 %loop.done, label %end, label %loop | ||||||
| 
 | 
 | ||||||
| end: | end: | ||||||
|   ret i8* %next.x |   ret ptr %next.x | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| declare [32 x i8]* @arrayAlloc() | declare ptr @arrayAlloc() | ||||||
| 
 | 
 | ||||||
| define void @testGEPBitcast() { | define void @testGEPBitcast() { | ||||||
|   %arr = call [32 x i8]* @arrayAlloc() |   %arr = call ptr @arrayAlloc() | ||||||
|   %arr.bitcast = getelementptr [32 x i8], [32 x i8]* %arr, i32 0, i32 0 |   %arr.bitcast = getelementptr [32 x i8], ptr %arr, i32 0, i32 0 | ||||||
|   call void @runtime.trackPointer(i8* %arr.bitcast) |   call void @runtime.trackPointer(ptr %arr.bitcast) | ||||||
|   %other = call i8* @runtime.alloc(i32 1, i8* null) |   %other = call ptr @runtime.alloc(i32 1, ptr null) | ||||||
|   call void @runtime.trackPointer(i8* %other) |   call void @runtime.trackPointer(ptr %other) | ||||||
|   ret void |   ret void | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -104,18 +102,17 @@ define void @someArbitraryFunction() { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| define void @earlyPopRegression() { | define void @earlyPopRegression() { | ||||||
|   %x.alloc = call i8* @runtime.alloc(i32 4, i8* null) |   %x.alloc = call ptr @runtime.alloc(i32 4, ptr null) | ||||||
|   call void @runtime.trackPointer(i8* %x.alloc) |   call void @runtime.trackPointer(ptr %x.alloc) | ||||||
|   %x = bitcast i8* %x.alloc to i8** |  | ||||||
|   ; At this point the pass used to pop the stack chain, resulting in a potential use-after-free during allocAndSave. |   ; 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 |   ret void | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| define void @allocAndSave(i8** %x) { | define void @allocAndSave(ptr %x) { | ||||||
|   %y = call i8* @runtime.alloc(i32 4, i8* null) |   %y = call ptr @runtime.alloc(i32 4, ptr null) | ||||||
|   call void @runtime.trackPointer(i8* %y) |   call void @runtime.trackPointer(ptr %y) | ||||||
|   store i8* %y, i8** %x |   store ptr %y, ptr %x | ||||||
|   store i8** %x, i8*** @ptrGlobal |   store ptr %x, ptr @ptrGlobal | ||||||
|   ret void |   ret void | ||||||
| } | } | ||||||
							
								
								
									
										258
									
								
								transform/testdata/gc-stackslots.out.ll
									
										
									
									
										предоставленный
									
									
								
							
							
						
						
									
										258
									
								
								transform/testdata/gc-stackslots.out.ll
									
										
									
									
										предоставленный
									
									
								
							|  | @ -1,141 +1,134 @@ | ||||||
| target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" | target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" | ||||||
| target triple = "wasm32-unknown-unknown-wasm" | target triple = "wasm32-unknown-unknown-wasm" | ||||||
| 
 | 
 | ||||||
| %runtime.stackChainObject = type { %runtime.stackChainObject*, i32 } | @runtime.stackChainStart = internal global ptr null | ||||||
| 
 |  | ||||||
| @runtime.stackChainStart = internal global %runtime.stackChainObject* null |  | ||||||
| @someGlobal = global i8 3 | @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() { | define ptr @getPointer() { | ||||||
|   ret i8* @someGlobal |   ret ptr @someGlobal | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| define i8* @needsStackSlots() { | define ptr @needsStackSlots() { | ||||||
|   %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8* }, align 8 |   %gc.stackobject = alloca { ptr, i32, ptr }, align 8 | ||||||
|   store { %runtime.stackChainObject*, i32, i8* } { %runtime.stackChainObject* null, i32 1, i8* null }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, align 4 |   store { ptr, i32, ptr } { ptr null, i32 1, ptr null }, ptr %gc.stackobject, align 4 | ||||||
|   %1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   %1 = load ptr, ptr @runtime.stackChainStart, align 4 | ||||||
|   %2 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 0 |   %2 = getelementptr { ptr, i32, ptr }, ptr %gc.stackobject, i32 0, i32 0 | ||||||
|   store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2, align 4 |   store ptr %1, ptr %2, align 4 | ||||||
|   %3 = bitcast { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject to %runtime.stackChainObject* |   store ptr %gc.stackobject, ptr @runtime.stackChainStart, align 4 | ||||||
|   store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   %ptr = call ptr @runtime.alloc(i32 4, ptr null) | ||||||
|   %ptr = call i8* @runtime.alloc(i32 4, i8* null) |   %3 = getelementptr { ptr, i32, ptr }, ptr %gc.stackobject, i32 0, i32 2 | ||||||
|   %4 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 2 |   store ptr %ptr, ptr %3, align 4 | ||||||
|   store i8* %ptr, i8** %4, align 4 |  | ||||||
|   call void @someArbitraryFunction() |   call void @someArbitraryFunction() | ||||||
|   %val = load i8, i8* @someGlobal, align 1 |   %val = load i8, ptr @someGlobal, align 1 | ||||||
|   store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   store ptr %1, ptr @runtime.stackChainStart, align 4 | ||||||
|   ret i8* %ptr |   ret ptr %ptr | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| define i8* @needsStackSlots2() { | define ptr @needsStackSlots2() { | ||||||
|   %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, align 8 |   %gc.stackobject = alloca { ptr, i32, ptr, ptr, ptr, ptr, ptr }, 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 |   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 %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   %1 = load ptr, ptr @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 |   %2 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 0 | ||||||
|   store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2, align 4 |   store ptr %1, ptr %2, align 4 | ||||||
|   %3 = bitcast { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject to %runtime.stackChainObject* |   store ptr %gc.stackobject, ptr @runtime.stackChainStart, align 4 | ||||||
|   store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   %ptr1 = call ptr @getPointer() | ||||||
|   %ptr1 = call i8* @getPointer() |   %3 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 4 | ||||||
|   %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 ptr %ptr1, ptr %3, align 4 | ||||||
|   store i8* %ptr1, i8** %4, align 4 |   %4 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 3 | ||||||
|   %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 ptr %ptr1, ptr %4, align 4 | ||||||
|   store i8* %ptr1, i8** %5, align 4 |   %5 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 2 | ||||||
|   %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 ptr %ptr1, ptr %5, align 4 | ||||||
|   store i8* %ptr1, i8** %6, align 4 |   %ptr2 = getelementptr i8, ptr @someGlobal, i32 0 | ||||||
|   %ptr2 = getelementptr i8, i8* @someGlobal, i32 0 |   %6 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 5 | ||||||
|   %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 ptr %ptr2, ptr %6, align 4 | ||||||
|   store i8* %ptr2, i8** %7, align 4 |   %unused = call ptr @runtime.alloc(i32 4, ptr null) | ||||||
|   %unused = call i8* @runtime.alloc(i32 4, i8* null) |   %7 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 6 | ||||||
|   %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 ptr %unused, ptr %7, align 4 | ||||||
|   store i8* %unused, i8** %8, align 4 |   store ptr %1, ptr @runtime.stackChainStart, align 4 | ||||||
|   store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   ret ptr %ptr1 | ||||||
|   ret i8* %ptr1 |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| define i8* @noAllocatingFunction() { | define ptr @noAllocatingFunction() { | ||||||
|   %ptr = call i8* @getPointer() |   %ptr = call ptr @getPointer() | ||||||
|   ret i8* %ptr |   ret ptr %ptr | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| define i8* @fibNext(i8* %x, i8* %y) { | define ptr @fibNext(ptr %x, ptr %y) { | ||||||
|   %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8* }, align 8 |   %gc.stackobject = alloca { ptr, i32, ptr }, align 8 | ||||||
|   store { %runtime.stackChainObject*, i32, i8* } { %runtime.stackChainObject* null, i32 1, i8* null }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, align 4 |   store { ptr, i32, ptr } { ptr null, i32 1, ptr null }, ptr %gc.stackobject, align 4 | ||||||
|   %1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   %1 = load ptr, ptr @runtime.stackChainStart, align 4 | ||||||
|   %2 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 0 |   %2 = getelementptr { ptr, i32, ptr }, ptr %gc.stackobject, i32 0, i32 0 | ||||||
|   store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2, align 4 |   store ptr %1, ptr %2, align 4 | ||||||
|   %3 = bitcast { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject to %runtime.stackChainObject* |   store ptr %gc.stackobject, ptr @runtime.stackChainStart, align 4 | ||||||
|   store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   %x.val = load i8, ptr %x, align 1 | ||||||
|   %x.val = load i8, i8* %x, align 1 |   %y.val = load i8, ptr %y, align 1 | ||||||
|   %y.val = load i8, i8* %y, align 1 |  | ||||||
|   %out.val = add i8 %x.val, %y.val |   %out.val = add i8 %x.val, %y.val | ||||||
|   %out.alloc = call i8* @runtime.alloc(i32 1, i8* null) |   %out.alloc = call ptr @runtime.alloc(i32 1, ptr null) | ||||||
|   %4 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 2 |   %3 = getelementptr { ptr, i32, ptr }, ptr %gc.stackobject, i32 0, i32 2 | ||||||
|   store i8* %out.alloc, i8** %4, align 4 |   store ptr %out.alloc, ptr %3, align 4 | ||||||
|   store i8 %out.val, i8* %out.alloc, align 1 |   store i8 %out.val, ptr %out.alloc, align 1 | ||||||
|   store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   store ptr %1, ptr @runtime.stackChainStart, align 4 | ||||||
|   ret i8* %out.alloc |   ret ptr %out.alloc | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| define i8* @allocLoop() { | define ptr @allocLoop() { | ||||||
| entry: | entry: | ||||||
|   %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }, align 8 |   %gc.stackobject = alloca { ptr, i32, ptr, ptr, ptr, ptr, ptr }, 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 |   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 %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   %0 = load ptr, ptr @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 |   %1 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 0 | ||||||
|   store %runtime.stackChainObject* %0, %runtime.stackChainObject** %1, align 4 |   store ptr %0, ptr %1, align 4 | ||||||
|   %2 = bitcast { %runtime.stackChainObject*, i32, i8*, i8*, i8*, i8*, i8* }* %gc.stackobject to %runtime.stackChainObject* |   store ptr %gc.stackobject, ptr @runtime.stackChainStart, align 4 | ||||||
|   store %runtime.stackChainObject* %2, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   %entry.x = call ptr @runtime.alloc(i32 1, ptr null) | ||||||
|   %entry.x = call i8* @runtime.alloc(i32 1, i8* null) |   %2 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 2 | ||||||
|   %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 ptr %entry.x, ptr %2, align 4 | ||||||
|   store i8* %entry.x, i8** %3, align 4 |   %entry.y = call ptr @runtime.alloc(i32 1, ptr null) | ||||||
|   %entry.y = call i8* @runtime.alloc(i32 1, i8* null) |   %3 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 3 | ||||||
|   %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 ptr %entry.y, ptr %3, align 4 | ||||||
|   store i8* %entry.y, i8** %4, align 4 |   store i8 1, ptr %entry.y, align 1 | ||||||
|   store i8 1, i8* %entry.y, align 1 |  | ||||||
|   br label %loop |   br label %loop | ||||||
| 
 | 
 | ||||||
| loop:                                             ; preds = %loop, %entry | loop:                                             ; preds = %loop, %entry | ||||||
|   %prev.y = phi i8* [ %entry.y, %entry ], [ %prev.x, %loop ] |   %prev.y = phi ptr [ %entry.y, %entry ], [ %prev.x, %loop ] | ||||||
|   %prev.x = phi i8* [ %entry.x, %entry ], [ %next.x, %loop ] |   %prev.x = phi ptr [ %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 |   %4 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 5 | ||||||
|   store i8* %prev.y, i8** %5, align 4 |   store ptr %prev.y, ptr %4, 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 |   %5 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 4 | ||||||
|   store i8* %prev.x, i8** %6, align 4 |   store ptr %prev.x, ptr %5, align 4 | ||||||
|   %next.x = call i8* @fibNext(i8* %prev.x, i8* %prev.y) |   %next.x = call ptr @fibNext(ptr %prev.x, ptr %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 |   %6 = getelementptr { ptr, i32, ptr, ptr, ptr, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 6 | ||||||
|   store i8* %next.x, i8** %7, align 4 |   store ptr %next.x, ptr %6, align 4 | ||||||
|   %next.x.val = load i8, i8* %next.x, align 1 |   %next.x.val = load i8, ptr %next.x, align 1 | ||||||
|   %loop.done = icmp ult i8 40, %next.x.val |   %loop.done = icmp ult i8 40, %next.x.val | ||||||
|   br i1 %loop.done, label %end, label %loop |   br i1 %loop.done, label %end, label %loop | ||||||
| 
 | 
 | ||||||
| end:                                              ; preds = %loop | end:                                              ; preds = %loop | ||||||
|   store %runtime.stackChainObject* %0, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   store ptr %0, ptr @runtime.stackChainStart, align 4 | ||||||
|   ret i8* %next.x |   ret ptr %next.x | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| declare [32 x i8]* @arrayAlloc() | declare ptr @arrayAlloc() | ||||||
| 
 | 
 | ||||||
| define void @testGEPBitcast() { | define void @testGEPBitcast() { | ||||||
|   %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8*, i8* }, align 8 |   %gc.stackobject = alloca { ptr, i32, ptr, ptr }, 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 |   store { ptr, i32, ptr, ptr } { ptr null, i32 2, ptr null, ptr null }, ptr %gc.stackobject, align 4 | ||||||
|   %1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   %1 = load ptr, ptr @runtime.stackChainStart, align 4 | ||||||
|   %2 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject, i32 0, i32 0 |   %2 = getelementptr { ptr, i32, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 0 | ||||||
|   store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2, align 4 |   store ptr %1, ptr %2, align 4 | ||||||
|   %3 = bitcast { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject to %runtime.stackChainObject* |   store ptr %gc.stackobject, ptr @runtime.stackChainStart, align 4 | ||||||
|   store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   %arr = call ptr @arrayAlloc() | ||||||
|   %arr = call [32 x i8]* @arrayAlloc() |   %arr.bitcast = getelementptr [32 x i8], ptr %arr, i32 0, i32 0 | ||||||
|   %arr.bitcast = getelementptr [32 x i8], [32 x i8]* %arr, i32 0, i32 0 |   %3 = getelementptr { ptr, i32, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 2 | ||||||
|   %4 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject, i32 0, i32 2 |   store ptr %arr.bitcast, ptr %3, align 4 | ||||||
|   store i8* %arr.bitcast, i8** %4, align 4 |   %other = call ptr @runtime.alloc(i32 1, ptr null) | ||||||
|   %other = call i8* @runtime.alloc(i32 1, i8* null) |   %4 = getelementptr { ptr, i32, ptr, ptr }, ptr %gc.stackobject, i32 0, i32 3 | ||||||
|   %5 = getelementptr { %runtime.stackChainObject*, i32, i8*, i8* }, { %runtime.stackChainObject*, i32, i8*, i8* }* %gc.stackobject, i32 0, i32 3 |   store ptr %other, ptr %4, align 4 | ||||||
|   store i8* %other, i8** %5, align 4 |   store ptr %1, ptr @runtime.stackChainStart, align 4 | ||||||
|   store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |  | ||||||
|   ret void |   ret void | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -144,35 +137,32 @@ define void @someArbitraryFunction() { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| define void @earlyPopRegression() { | define void @earlyPopRegression() { | ||||||
|   %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8* }, align 8 |   %gc.stackobject = alloca { ptr, i32, ptr }, align 8 | ||||||
|   store { %runtime.stackChainObject*, i32, i8* } { %runtime.stackChainObject* null, i32 1, i8* null }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, align 4 |   store { ptr, i32, ptr } { ptr null, i32 1, ptr null }, ptr %gc.stackobject, align 4 | ||||||
|   %1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   %1 = load ptr, ptr @runtime.stackChainStart, align 4 | ||||||
|   %2 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 0 |   %2 = getelementptr { ptr, i32, ptr }, ptr %gc.stackobject, i32 0, i32 0 | ||||||
|   store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2, align 4 |   store ptr %1, ptr %2, align 4 | ||||||
|   %3 = bitcast { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject to %runtime.stackChainObject* |   store ptr %gc.stackobject, ptr @runtime.stackChainStart, align 4 | ||||||
|   store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   %x.alloc = call ptr @runtime.alloc(i32 4, ptr null) | ||||||
|   %x.alloc = call i8* @runtime.alloc(i32 4, i8* null) |   %3 = getelementptr { ptr, i32, ptr }, ptr %gc.stackobject, i32 0, i32 2 | ||||||
|   %4 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 2 |   store ptr %x.alloc, ptr %3, align 4 | ||||||
|   store i8* %x.alloc, i8** %4, align 4 |   call void @allocAndSave(ptr %x.alloc) | ||||||
|   %x = bitcast i8* %x.alloc to i8** |   store ptr %1, ptr @runtime.stackChainStart, align 4 | ||||||
|   call void @allocAndSave(i8** %x) |  | ||||||
|   store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |  | ||||||
|   ret void |   ret void | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| define void @allocAndSave(i8** %x) { | define void @allocAndSave(ptr %x) { | ||||||
|   %gc.stackobject = alloca { %runtime.stackChainObject*, i32, i8* }, align 8 |   %gc.stackobject = alloca { ptr, i32, ptr }, align 8 | ||||||
|   store { %runtime.stackChainObject*, i32, i8* } { %runtime.stackChainObject* null, i32 1, i8* null }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, align 4 |   store { ptr, i32, ptr } { ptr null, i32 1, ptr null }, ptr %gc.stackobject, align 4 | ||||||
|   %1 = load %runtime.stackChainObject*, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   %1 = load ptr, ptr @runtime.stackChainStart, align 4 | ||||||
|   %2 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 0 |   %2 = getelementptr { ptr, i32, ptr }, ptr %gc.stackobject, i32 0, i32 0 | ||||||
|   store %runtime.stackChainObject* %1, %runtime.stackChainObject** %2, align 4 |   store ptr %1, ptr %2, align 4 | ||||||
|   %3 = bitcast { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject to %runtime.stackChainObject* |   store ptr %gc.stackobject, ptr @runtime.stackChainStart, align 4 | ||||||
|   store %runtime.stackChainObject* %3, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |   %y = call ptr @runtime.alloc(i32 4, ptr null) | ||||||
|   %y = call i8* @runtime.alloc(i32 4, i8* null) |   %3 = getelementptr { ptr, i32, ptr }, ptr %gc.stackobject, i32 0, i32 2 | ||||||
|   %4 = getelementptr { %runtime.stackChainObject*, i32, i8* }, { %runtime.stackChainObject*, i32, i8* }* %gc.stackobject, i32 0, i32 2 |   store ptr %y, ptr %3, align 4 | ||||||
|   store i8* %y, i8** %4, align 4 |   store ptr %y, ptr %x, align 4 | ||||||
|   store i8* %y, i8** %x, align 4 |   store ptr %x, ptr @ptrGlobal, align 4 | ||||||
|   store i8** %x, i8*** @ptrGlobal, align 4 |   store ptr %1, ptr @runtime.stackChainStart, align 4 | ||||||
|   store %runtime.stackChainObject* %1, %runtime.stackChainObject** @runtime.stackChainStart, align 4 |  | ||||||
|   ret void |   ret void | ||||||
| } | } | ||||||
|  |  | ||||||
		Загрузка…
	
	Создание таблицы
		
		Сослаться в новой задаче
	
	 Ayke van Laethem
						Ayke van Laethem