transform: allow updating tests with -update flag

This should make it much easier to update existing tests.
This commit is contained in:
Ayke van Laethem
2020-04-01 20:49:48 +02:00
committed by Ron Evans
parent 5308e8903e
commit 584e94ce2f
5 changed files with 73 additions and 44 deletions
+14 -21
View File
@@ -29,9 +29,6 @@ declare void @func1Uint8(i8, i8*, i8*)
declare void @func2Uint8(i8, i8*, i8*)
; Call a function of which only one function with this signature is used as a
; function value. This means that lowering it to IR is trivial: simply check
; whether the func value is nil, and if not, call that one function directly.
define void @runFunc1(i8*, i32, i8, i8* %context, i8* %parentHandle) {
entry:
%3 = icmp eq i32 %1, 0
@@ -39,53 +36,49 @@ entry:
%5 = icmp eq void (i8, i8*, i8*)* %4, null
br i1 %5, label %fpcall.nil, label %fpcall.next
fpcall.nil:
fpcall.nil: ; preds = %entry
call void @runtime.nilPanic(i8* undef, i8* null)
unreachable
fpcall.next:
fpcall.next: ; preds = %entry
call void %4(i8 %2, i8* %0, i8* undef)
ret void
}
; There are two functions with this signature used in a func value. That means
; that we'll have to check at runtime which of the two it is (or whether the
; func value is nil). This call will thus be lowered to a switch statement.
define void @runFunc2(i8*, i32, i8, i8* %context, i8* %parentHandle) {
entry:
br i1 false, label %fpcall.nil, label %fpcall.next
fpcall.nil:
fpcall.nil: ; preds = %entry
call void @runtime.nilPanic(i8* undef, i8* null)
unreachable
fpcall.next:
fpcall.next: ; preds = %entry
switch i32 %1, label %func.default [
i32 0, label %func.nil
i32 1, label %func.call1
i32 2, label %func.call2
]
func.nil:
func.nil: ; preds = %fpcall.next
call void @runtime.nilPanic(i8* undef, i8* null)
unreachable
func.call1:
func.call1: ; preds = %fpcall.next
call void @func1Uint8(i8 %2, i8* %0, i8* undef)
br label %func.next
func.call2:
func.call2: ; preds = %fpcall.next
call void @func2Uint8(i8 %2, i8* %0, i8* undef)
br label %func.next
func.next:
func.next: ; preds = %func.call2, %func.call1
ret void
func.default:
func.default: ; preds = %fpcall.next
unreachable
}
; Special case for runtime.makeGoroutine.
define void @sleepFuncValue(i8*, i32, i8* nocapture readnone %context, i8* nocapture readnone %parentHandle) {
entry:
switch i32 %1, label %func.default [
@@ -94,21 +87,21 @@ entry:
i32 2, label %func.call2
]
func.nil:
func.nil: ; preds = %entry
call void @runtime.nilPanic(i8* undef, i8* null)
unreachable
func.call1:
func.call1: ; preds = %entry
call void @"internal/task.start"(i32 ptrtoint (void (i32, i8*, i8*)* @"main$1" to i32), i8* null, i8* undef, i8* null)
br label %func.next
func.call2:
func.call2: ; preds = %entry
call void @"internal/task.start"(i32 ptrtoint (void (i32, i8*, i8*)* @"main$2" to i32), i8* null, i8* undef, i8* null)
br label %func.next
func.next:
func.next: ; preds = %func.call2, %func.call1
ret void
func.default:
func.default: ; preds = %entry
unreachable
}