Skip to content

Commit

Permalink
[llvm-c][test] Convert tests to opaque pointers
Browse files Browse the repository at this point in the history
echo.ll is unchanged to test typed pointers.
  • Loading branch information
MaskRay committed Jun 3, 2022
1 parent ee1cf1f commit 8d84684
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 74 deletions.
4 changes: 2 additions & 2 deletions llvm/test/Bindings/llvm-c/atomics.ll
@@ -1,10 +1,10 @@
; RUN: llvm-as < %s | llvm-dis > %t.orig
; RUN: llvm-as < %s | llvm-c-test --echo > %t.echo
; RUN: llvm-as < %s | llvm-c-test --echo --opaque-pointers > %t.echo
; RUN: diff -w %t.orig %t.echo

define i32 @main() {
%1 = alloca i32, align 4
%2 = cmpxchg i32* %1, i32 2, i32 3 seq_cst acquire
%2 = cmpxchg ptr %1, i32 2, i32 3 seq_cst acquire
%3 = extractvalue { i32, i1 } %2, 0
ret i32 %3
}
2 changes: 1 addition & 1 deletion llvm/test/Bindings/llvm-c/echo.ll
@@ -1,5 +1,5 @@
; RUN: llvm-as < %s | llvm-dis > %t.orig
; RUN: llvm-as < %s | llvm-c-test --echo > %t.echo
; RUN: llvm-as < %s | llvm-c-test --echo --no-opaque-pointers > %t.echo
; RUN: diff -w %t.orig %t.echo
;
; RUN: llvm-as -opaque-pointers < %s | llvm-dis -opaque-pointers > %t.orig_opaque
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/Bindings/llvm-c/freeze.ll
@@ -1,11 +1,11 @@
; RUN: llvm-as < %s | llvm-dis > %t.orig
; RUN: llvm-as < %s | llvm-c-test --echo > %t.echo
; RUN: llvm-as < %s | llvm-c-test --echo --opaque-pointers > %t.echo
; RUN: diff -w %t.orig %t.echo

%struct.T = type { i32, i32 }

define i32 @f(i32 %arg, <2 x i32> %arg2, float %arg3, <2 x float> %arg4,
i8* %arg5, %struct.T %arg6, [2 x i32] %arg7, { i32, i32 } %arg8) {
ptr %arg5, %struct.T %arg6, [2 x i32] %arg7, { i32, i32 } %arg8) {
%1 = freeze i32 %arg
%2 = freeze i32 10
%3 = freeze i32 %1
Expand All @@ -14,10 +14,10 @@ define i32 @f(i32 %arg, <2 x i32> %arg2, float %arg3, <2 x float> %arg4,
%6 = freeze <2 x i32> %arg2
%7 = freeze float %arg3
%8 = freeze <2 x float> %arg4
%9 = freeze i8* %arg5
%9 = freeze ptr %arg5
%10 = freeze %struct.T %arg6
%11 = freeze [2 x i32] %arg7
%12 = freeze { i32, i32 } %arg8
%13 = freeze i8* null
%13 = freeze ptr null
ret i32 %1
}
91 changes: 44 additions & 47 deletions llvm/test/Bindings/llvm-c/invoke.ll
@@ -1,83 +1,80 @@
; RUN: llvm-as < %s | llvm-dis > %t.orig
; RUN: llvm-as < %s | llvm-c-test --echo > %t.echo
; RUN: llvm-as < %s | llvm-c-test --echo --opaque-pointers > %t.echo
; RUN: diff -w %t.orig %t.echo

%C6object9ClassInfo = type { %C6object9ClassInfo__vtbl*, %C6object9ClassInfo* }
%C6object9ClassInfo__vtbl = type { %C6object9ClassInfo* }
%C6object9Exception__vtbl = type { %C6object9ClassInfo* }
%C6object6Object = type { %C6object6Object__vtbl* }
%C6object6Object__vtbl = type { %C6object9ClassInfo* }
%C6object9Throwable = type { %C6object9Throwable__vtbl* }
%C6object9Throwable__vtbl = type { %C6object9ClassInfo* }

@C6object9ClassInfo__ClassInfo = linkonce_odr constant %C6object9ClassInfo { %C6object9ClassInfo__vtbl* @C6object9ClassInfo__vtblZ, %C6object9ClassInfo* @C6object8TypeInfo__ClassInfo }
@C6object9ClassInfo__vtblZ = linkonce_odr constant %C6object9ClassInfo__vtbl { %C6object9ClassInfo* @C6object9ClassInfo__ClassInfo }
@C6object8TypeInfo__ClassInfo = linkonce_odr constant %C6object9ClassInfo { %C6object9ClassInfo__vtbl* @C6object9ClassInfo__vtblZ, %C6object9ClassInfo* @C6object6Object__ClassInfo }
@C6object6Object__ClassInfo = linkonce_odr constant %C6object9ClassInfo { %C6object9ClassInfo__vtbl* @C6object9ClassInfo__vtblZ, %C6object9ClassInfo* @C6object6Object__ClassInfo }
@C6object9Throwable__ClassInfo = linkonce_odr constant %C6object9ClassInfo { %C6object9ClassInfo__vtbl* @C6object9ClassInfo__vtblZ, %C6object9ClassInfo* @C6object6Object__ClassInfo }
@C6object9Exception__ClassInfo = linkonce_odr constant %C6object9ClassInfo { %C6object9ClassInfo__vtbl* @C6object9ClassInfo__vtblZ, %C6object9ClassInfo* @C6object9Throwable__ClassInfo }
@C6object9Exception__vtblZ = linkonce_odr constant %C6object9Exception__vtbl { %C6object9ClassInfo* @C6object9Exception__ClassInfo }
@C6object5Error__ClassInfo = linkonce_odr constant %C6object9ClassInfo { %C6object9ClassInfo__vtbl* @C6object9ClassInfo__vtblZ, %C6object9ClassInfo* @C6object9Throwable__ClassInfo }

define i32 @_D8test01494mainFMZi() personality i32 (i32, i32, i64, i8*, i8*)* @__sd_eh_personality {
%C6object9ClassInfo = type { ptr, ptr }
%C6object9ClassInfo__vtbl = type { ptr }
%C6object9Exception__vtbl = type { ptr }
%C6object6Object = type { ptr }
%C6object6Object__vtbl = type { ptr }
%C6object9Throwable = type { ptr }
%C6object9Throwable__vtbl = type { ptr }

@C6object9ClassInfo__ClassInfo = linkonce_odr constant %C6object9ClassInfo { ptr @C6object9ClassInfo__vtblZ, ptr @C6object8TypeInfo__ClassInfo }
@C6object9ClassInfo__vtblZ = linkonce_odr constant %C6object9ClassInfo__vtbl { ptr @C6object9ClassInfo__ClassInfo }
@C6object8TypeInfo__ClassInfo = linkonce_odr constant %C6object9ClassInfo { ptr @C6object9ClassInfo__vtblZ, ptr @C6object6Object__ClassInfo }
@C6object6Object__ClassInfo = linkonce_odr constant %C6object9ClassInfo { ptr @C6object9ClassInfo__vtblZ, ptr @C6object6Object__ClassInfo }
@C6object9Throwable__ClassInfo = linkonce_odr constant %C6object9ClassInfo { ptr @C6object9ClassInfo__vtblZ, ptr @C6object6Object__ClassInfo }
@C6object9Exception__ClassInfo = linkonce_odr constant %C6object9ClassInfo { ptr @C6object9ClassInfo__vtblZ, ptr @C6object9Throwable__ClassInfo }
@C6object9Exception__vtblZ = linkonce_odr constant %C6object9Exception__vtbl { ptr @C6object9Exception__ClassInfo }
@C6object5Error__ClassInfo = linkonce_odr constant %C6object9ClassInfo { ptr @C6object9ClassInfo__vtblZ, ptr @C6object9Throwable__ClassInfo }

define i32 @_D8test01494mainFMZi() personality ptr @__sd_eh_personality {
body:
%0 = invoke noalias i8* @_d_allocmemory(i64 8)
%0 = invoke noalias ptr @_d_allocmemory(i64 8)
to label %then unwind label %landingPad

then: ; preds = %body
%1 = bitcast i8* %0 to i8**
store i8* bitcast (%C6object9Exception__vtbl* @C6object9Exception__vtblZ to i8*), i8** %1, align 8
%2 = bitcast i8* %0 to %C6object6Object*
invoke void @_D6object6Object6__ctorFMC6object6ObjectZv(%C6object6Object* %2)
store ptr bitcast (ptr @C6object9Exception__vtblZ to ptr), ptr %0, align 8
invoke void @_D6object6Object6__ctorFMC6object6ObjectZv(ptr %0)
to label %then1 unwind label %landingPad

then1: ; preds = %then
%3 = bitcast i8* %0 to %C6object9Throwable*
invoke void @__sd_eh_throw(%C6object9Throwable* nonnull %3)
invoke void @__sd_eh_throw(ptr nonnull %0)
to label %then2 unwind label %landingPad

then2: ; preds = %then1
unreachable

landingPad: ; preds = %then1, %then, %body
%4 = landingpad { i8*, i32 }
%1 = landingpad { ptr, i32 }
cleanup
catch %C6object9ClassInfo* @C6object5Error__ClassInfo
catch %C6object9ClassInfo* @C6object9Exception__ClassInfo
catch %C6object9ClassInfo* @C6object9Throwable__ClassInfo
%5 = extractvalue { i8*, i32 } %4, 1
%6 = tail call i32 @llvm.eh.typeid.for(i8* nonnull bitcast (%C6object9ClassInfo* @C6object5Error__ClassInfo to i8*))
%7 = icmp eq i32 %6, %5
br i1 %7, label %catch, label %unwind3
catch ptr @C6object5Error__ClassInfo
catch ptr @C6object9Exception__ClassInfo
catch ptr @C6object9Throwable__ClassInfo
%2 = extractvalue { ptr, i32 } %1, 1
%3 = tail call i32 @llvm.eh.typeid.for(ptr nonnull bitcast (ptr @C6object5Error__ClassInfo to ptr))
%4 = icmp eq i32 %3, %2
br i1 %4, label %catch, label %unwind3

catch: ; preds = %unwind5, %unwind3, %landingPad
%merge = phi i32 [ 23, %landingPad ], [ 19, %unwind3 ], [ 13, %unwind5 ]
ret i32 %merge

unwind3: ; preds = %landingPad
%8 = tail call i32 @llvm.eh.typeid.for(i8* nonnull bitcast (%C6object9ClassInfo* @C6object9Exception__ClassInfo to i8*))
%9 = icmp eq i32 %8, %5
br i1 %9, label %catch, label %unwind5
%5 = tail call i32 @llvm.eh.typeid.for(ptr nonnull @C6object9Exception__ClassInfo)
%6 = icmp eq i32 %5, %2
br i1 %6, label %catch, label %unwind5

unwind5: ; preds = %unwind3
%10 = tail call i32 @llvm.eh.typeid.for(i8* nonnull bitcast (%C6object9ClassInfo* @C6object9Throwable__ClassInfo to i8*))
%11 = icmp eq i32 %10, %5
br i1 %11, label %catch, label %unwind7
%7 = tail call i32 @llvm.eh.typeid.for(ptr nonnull @C6object9Throwable__ClassInfo)
%8 = icmp eq i32 %7, %2
br i1 %8, label %catch, label %unwind7

unwind7: ; preds = %unwind5
resume { i8*, i32 } %4
resume { ptr, i32 } %1
}

declare void @_D6object6Object6__ctorFMC6object6ObjectZv(%C6object6Object*)
declare void @_D6object6Object6__ctorFMC6object6ObjectZv(ptr)

declare noalias i8* @_d_allocmemory(i64)
declare noalias ptr @_d_allocmemory(i64)

declare i32 @__sd_eh_personality(i32, i32, i64, i8*, i8*)
declare i32 @__sd_eh_personality(i32, i32, i64, ptr, ptr)

declare void @__sd_eh_throw(%C6object9Throwable* nonnull) #0
declare void @__sd_eh_throw(ptr nonnull) #0

; Function Attrs: nounwind readnone
declare i32 @llvm.eh.typeid.for(i8*) #1
declare i32 @llvm.eh.typeid.for(ptr) #1

attributes #0 = { noreturn }
attributes #1 = { nounwind readnone }
attributes #1 = { nounwind readnone }
40 changes: 20 additions & 20 deletions llvm/test/Bindings/llvm-c/memops.ll
@@ -1,37 +1,37 @@
; RUN: llvm-as < %s | llvm-dis > %t.orig
; RUN: llvm-as < %s | llvm-c-test --echo > %t.echo
; RUN: llvm-as < %s | llvm-c-test --echo --opaque-pointers > %t.echo
; RUN: diff -w %t.orig %t.echo

%S = type { i32, i32 }

define i32 @method(%S* %this, i32 %arg.a, i32 %arg.b) {
define i32 @method(ptr %this, i32 %arg.a, i32 %arg.b) {
%a = alloca i32, align 4
store i32 %arg.a, i32* %a, align 4
store i32 %arg.a, ptr %a, align 4
%b = alloca i32, align 4
store i32 %arg.b, i32* %b
%1 = load i32, i32* %a, align 4
%2 = load i32, i32* %b, align 4
store i32 %arg.b, ptr %b
%1 = load i32, ptr %a, align 4
%2 = load i32, ptr %b, align 4
%3 = add i32 %1, %2
%4 = getelementptr inbounds %S, %S* %this, i32 0, i32 0
%5 = load i32, i32* %4, align 4
%4 = getelementptr inbounds %S, ptr %this, i32 0, i32 0
%5 = load i32, ptr %4, align 4
%6 = add i32 %3, %5
%7 = getelementptr inbounds %S, %S* %this, i32 0, i32 1
%8 = load i32, i32* %7, align 4
%7 = getelementptr inbounds %S, ptr %this, i32 0, i32 1
%8 = load i32, ptr %7, align 4
%9 = add i32 %6, %8
ret i32 %9
}

define i32 @main() {
%s = alloca %S, align 4
store %S zeroinitializer, %S* %s
%1 = getelementptr inbounds %S, %S* %s, i32 0, i32 0
%2 = getelementptr inbounds %S, %S* %s, i32 0, i32 1
store i32 1, i32* %2
store i32 1, i32* %1
%3 = insertvalue { %S*, i32 (%S*, i32, i32)* } undef, %S* %s, 0
%4 = insertvalue { %S*, i32 (%S*, i32, i32)* } %3, i32 (%S*, i32, i32)* @method, 1
%5 = extractvalue { %S*, i32 (%S*, i32, i32)* } %4, 0
%6 = extractvalue { %S*, i32 (%S*, i32, i32)* } %4, 1
%7 = call i32 %6(%S* %5, i32 38, i32 2)
store %S zeroinitializer, ptr %s
%1 = getelementptr inbounds %S, ptr %s, i32 0, i32 0
%2 = getelementptr inbounds %S, ptr %s, i32 0, i32 1
store i32 1, ptr %2
store i32 1, ptr %1
%3 = insertvalue { ptr, ptr } undef, ptr %s, 0
%4 = insertvalue { ptr, ptr } %3, ptr @method, 1
%5 = extractvalue { ptr, ptr } %4, 0
%6 = extractvalue { ptr, ptr } %4, 1
%7 = call i32 %6(ptr %5, i32 38, i32 2)
ret i32 %7
}

0 comments on commit 8d84684

Please sign in to comment.