Skip to content

Commit

Permalink
[Tests] Convert Feature tests to opaque pointers (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Dec 13, 2022
1 parent 57f71dc commit 1842a29
Show file tree
Hide file tree
Showing 46 changed files with 351 additions and 366 deletions.
30 changes: 15 additions & 15 deletions llvm/test/Feature/OperandBundles/basic-aa-argmemonly.ll
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
; RUN: opt -S -aa-pipeline=basic-aa -passes=gvn < %s | FileCheck %s

declare void @argmemonly_function(i32 *) argmemonly
declare void @argmemonly_function(ptr) argmemonly

define i32 @test0(i32* %P, i32* noalias %P2) {
define i32 @test0(ptr %P, ptr noalias %P2) {
; CHECK-LABEL: @test0(
%v1 = load i32, i32* %P
; CHECK: %v1 = load i32, i32* %P
call void @argmemonly_function(i32* %P2) [ "tag"() ]
%v1 = load i32, ptr %P
; CHECK: %v1 = load i32, ptr %P
call void @argmemonly_function(ptr %P2) [ "tag"() ]
; CHECK: call void @argmemonly_function(
%v2 = load i32, i32* %P
; CHECK: %v2 = load i32, i32* %P
%v2 = load i32, ptr %P
; CHECK: %v2 = load i32, ptr %P
%diff = sub i32 %v1, %v2
; CHECK: %diff = sub i32 %v1, %v2
ret i32 %diff
; CHECK: ret i32 %diff
}

define i32 @test1(i32* %P, i32* noalias %P2) {
define i32 @test1(ptr %P, ptr noalias %P2) {
; CHECK-LABEL: @test1(
%v1 = load i32, i32* %P
call void @argmemonly_function(i32* %P2) argmemonly [ "tag"() ]
%v1 = load i32, ptr %P
call void @argmemonly_function(ptr %P2) argmemonly [ "tag"() ]
; CHECK: call void @argmemonly_function(
%v2 = load i32, i32* %P
%v2 = load i32, ptr %P
%diff = sub i32 %v1, %v2
ret i32 %diff
; CHECK: ret i32 0
}

define i32 @test2(i32* %P, i32* noalias %P2) {
define i32 @test2(ptr %P, ptr noalias %P2) {
; Note: in this test we //can// GVN %v1 and %v2 into one value in theory. Calls
; with deopt operand bundles are not argmemonly because they *read* the entire
; heap, but they don't write to any location in the heap if the callee does not
Expand All @@ -36,10 +36,10 @@ define i32 @test2(i32* %P, i32* noalias %P2) {
; that %P is not written to at the callsite.

; CHECK-LABEL: @test2(
%v1 = load i32, i32* %P
call void @argmemonly_function(i32* %P2) [ "deopt"() ]
%v1 = load i32, ptr %P
call void @argmemonly_function(ptr %P2) [ "deopt"() ]
; CHECK: call void @argmemonly_function(
%v2 = load i32, i32* %P
%v2 = load i32, ptr %P
%diff = sub i32 %v1, %v2
ret i32 %diff
; CHECK: ret i32 0
Expand Down
48 changes: 24 additions & 24 deletions llvm/test/Feature/OperandBundles/dse.ll
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
; RUN: opt -S -passes=dse < %s | FileCheck %s

declare void @f()
declare noalias i8* @malloc(i32) nounwind
declare noalias ptr @malloc(i32) nounwind

define void @test_0() {
; CHECK-LABEL: @test_0(
%m = call i8* @malloc(i32 24)
tail call void @f() [ "unknown"(i8* %m) ]
; CHECK: store i8 -19, i8* %m
store i8 -19, i8* %m
%m = call ptr @malloc(i32 24)
tail call void @f() [ "unknown"(ptr %m) ]
; CHECK: store i8 -19, ptr %m
store i8 -19, ptr %m
ret void
}

define i8* @test_1() {
define ptr @test_1() {
; CHECK-LABEL: @test_1(
%m = call i8* @malloc(i32 24)
tail call void @f() [ "unknown"(i8* %m) ]
store i8 -19, i8* %m
%m = call ptr @malloc(i32 24)
tail call void @f() [ "unknown"(ptr %m) ]
store i8 -19, ptr %m
tail call void @f()
store i8 101, i8* %m
store i8 101, ptr %m

; CHECK: tail call void @f() [ "unknown"(i8* %m) ]
; CHECK: store i8 -19, i8* %m
; CHECK: tail call void @f() [ "unknown"(ptr %m) ]
; CHECK: store i8 -19, ptr %m
; CHECK: tail call void @f()
; CHECK: store i8 101, i8* %m
; CHECK: store i8 101, ptr %m

ret i8* %m
ret ptr %m
}

define void @test_2() {
; Since the deopt operand bundle does not escape %m (see caveat below), it is
; legal to elide the final store that location.

; CHECK-LABEL: @test_2(
%m = call i8* @malloc(i32 24)
tail call void @f() [ "deopt"(i8* %m) ]
store i8 -19, i8* %m
%m = call ptr @malloc(i32 24)
tail call void @f() [ "deopt"(ptr %m) ]
store i8 -19, ptr %m
ret void

; CHECK: tail call void @f() [ "deopt"(i8* %m) ]
; CHECK: tail call void @f() [ "deopt"(ptr %m) ]
; CHECK-NEXT: ret void
}

define i8* @test_3() {
define ptr @test_3() {
; Since the deopt operand bundle does not escape %m (see caveat below), @f
; cannot observe the stores to %m

; CHECK-LABEL: @test_3(
%m = call i8* @malloc(i32 24)
tail call void @f() [ "deopt"(i8* %m) ]
store i8 -19, i8* %m
%m = call ptr @malloc(i32 24)
tail call void @f() [ "deopt"(ptr %m) ]
store i8 -19, ptr %m
tail call void @f()
store i8 101, i8* %m
ret i8* %m
store i8 101, ptr %m
ret ptr %m
}


Expand Down
52 changes: 26 additions & 26 deletions llvm/test/Feature/OperandBundles/early-cse.ll
Original file line number Diff line number Diff line change
Expand Up @@ -9,90 +9,90 @@
declare void @readonly_function() readonly nounwind willreturn
declare void @readnone_function() readnone nounwind willreturn

define i32 @test0(i32* %x) {
define i32 @test0(ptr %x) {
; CHECK-LABEL: @test0(
; CHECK-NEXT: entry:
; CHECK-NEXT: store i32 100, i32* [[X:%.*]], align 4
; CHECK-NEXT: store i32 100, ptr [[X:%.*]], align 4
; CHECK-NEXT: call void @readonly_function() [ "tag"() ]
; CHECK-NEXT: [[V:%.*]] = load i32, i32* [[X]], align 4
; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[X]], align 4
; CHECK-NEXT: ret i32 [[V]]
;
entry:
store i32 100, i32* %x
store i32 100, ptr %x
call void @readonly_function() [ "tag"() ]

%v = load i32, i32* %x
%v = load i32, ptr %x
ret i32 %v
}

define i32 @test1(i32* %x) {
define i32 @test1(ptr %x) {
; CHECK-LABEL: @test1(
; CHECK-NEXT: entry:
; CHECK-NEXT: store i32 100, i32* [[X:%.*]], align 4
; CHECK-NEXT: store i32 100, ptr [[X:%.*]], align 4
; CHECK-NEXT: ret i32 100
;
entry:
store i32 100, i32* %x
store i32 100, ptr %x
call void @readonly_function() readonly [ "tag"() ]
%v = load i32, i32* %x
%v = load i32, ptr %x
ret i32 %v
}

define i32 @test3(i32* %x) {
define i32 @test3(ptr %x) {
; CHECK-LABEL: @test3(
; CHECK-NEXT: entry:
; CHECK-NEXT: store i32 100, i32* [[X:%.*]], align 4
; CHECK-NEXT: store i32 100, ptr [[X:%.*]], align 4
; CHECK-NEXT: ret i32 100
;
entry:
store i32 100, i32* %x
store i32 100, ptr %x
call void @readonly_function()
%v = load i32, i32* %x
%v = load i32, ptr %x
ret i32 %v
}

define void @test4(i32* %x) {
define void @test4(ptr %x) {
; CHECK-LABEL: @test4(
; CHECK-NEXT: entry:
; CHECK-NEXT: store i32 100, i32* [[X:%.*]], align 4
; CHECK-NEXT: store i32 100, ptr [[X:%.*]], align 4
; CHECK-NEXT: call void @readnone_function() [ "tag"() ]
; CHECK-NEXT: store i32 200, i32* [[X]], align 4
; CHECK-NEXT: store i32 200, ptr [[X]], align 4
; CHECK-NEXT: ret void
;
entry:
store i32 100, i32* %x
store i32 100, ptr %x
call void @readnone_function() [ "tag"() ]
store i32 200, i32* %x
store i32 200, ptr %x
ret void
}

define void @test5(i32* %x) {
define void @test5(ptr %x) {
; CHECK-LABEL: @test5(
; CHECK-NEXT: entry:
; CHECK-NEXT: store i32 200, i32* [[X:%.*]], align 4
; CHECK-NEXT: store i32 200, ptr [[X:%.*]], align 4
; CHECK-NEXT: ret void
;
entry:
store i32 100, i32* %x
store i32 100, ptr %x
call void @readnone_function() readnone [ "tag"() ]
store i32 200, i32* %x
store i32 200, ptr %x
ret void
}

define void @test6(i32* %x) {
define void @test6(ptr %x) {
; The "deopt" operand bundle does not make the call to
; @readonly_function read-write; and so the nounwind readonly call can
; be deleted.
; CHECK-LABEL: @test6(
; CHECK-NEXT: entry:
; CHECK-NEXT: store i32 200, i32* [[X:%.*]], align 4
; CHECK-NEXT: store i32 200, ptr [[X:%.*]], align 4
; CHECK-NEXT: ret void
;
entry:


store i32 100, i32* %x
store i32 100, ptr %x
call void @readonly_function() [ "deopt"() ]
store i32 200, i32* %x
store i32 200, ptr %x
ret void
}
30 changes: 15 additions & 15 deletions llvm/test/Feature/OperandBundles/function-attrs.ll
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,42 @@ declare void @f_readonly() readonly
declare void @f_readnone() readnone
declare void @f_writeonly() writeonly

define void @test_0(i32* %x) {
define void @test_0(ptr %x) {
; FunctionAttrs must not infer readonly / readnone for %x

; CHECK-LABEL: define void @test_0(i32* %x) #3 {
; CHECK-LABEL: define void @test_0(ptr %x) #3 {
entry:
; CHECK: call void @f_readonly() [ "foo"(i32* %x) ]
call void @f_readonly() [ "foo"(i32* %x) ]
; CHECK: call void @f_readonly() [ "foo"(ptr %x) ]
call void @f_readonly() [ "foo"(ptr %x) ]
ret void
}

define void @test_1(i32* %x) {
define void @test_1(ptr %x) {
; FunctionAttrs must not infer readonly / readnone for %x

; CHECK-LABEL: define void @test_1(i32* %x) #4 {
; CHECK-LABEL: define void @test_1(ptr %x) #4 {
entry:
; CHECK: call void @f_readnone() [ "foo"(i32* %x) ]
call void @f_readnone() [ "foo"(i32* %x) ]
; CHECK: call void @f_readnone() [ "foo"(ptr %x) ]
call void @f_readnone() [ "foo"(ptr %x) ]
ret void
}

define void @test_2(i32* %x) {
define void @test_2(ptr %x) {
; FunctionAttrs must not infer writeonly

; CHECK-LABEL: define void @test_2(i32* %x) {
; CHECK-LABEL: define void @test_2(ptr %x) {
entry:
; CHECK: call void @f_writeonly() [ "foo"(i32* %x) ]
call void @f_writeonly() [ "foo"(i32* %x) ]
; CHECK: call void @f_writeonly() [ "foo"(ptr %x) ]
call void @f_writeonly() [ "foo"(ptr %x) ]
ret void
}

define void @test_3(i32* %x) {
define void @test_3(ptr %x) {
; The "deopt" operand bundle does not capture or write to %x.

; CHECK-LABEL: define void @test_3(i32* nocapture readonly %x)
; CHECK-LABEL: define void @test_3(ptr nocapture readonly %x)
entry:
call void @f_readonly() [ "deopt"(i32* %x) ]
call void @f_readonly() [ "deopt"(ptr %x) ]
ret void
}

Expand Down
24 changes: 12 additions & 12 deletions llvm/test/Feature/OperandBundles/pr26510.ll
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@

declare void @foo() readnone

; CHECK-LABEL: define i8* @test(i8* %p)
; CHECK: %a = alloca i8*, align 8
; CHECK: store i8* %p, i8** %a, align 8
; CHECK: call void @foo() [ "abc"(i8** %a) ]
; CHECK: %reload = load i8*, i8** %a, align 8
; CHECK: ret i8* %reload
; CHECK-LABEL: define ptr @test(ptr %p)
; CHECK: %a = alloca ptr, align 8
; CHECK: store ptr %p, ptr %a, align 8
; CHECK: call void @foo() [ "abc"(ptr %a) ]
; CHECK: %reload = load ptr, ptr %a, align 8
; CHECK: ret ptr %reload
; CHECK: }

define i8* @test(i8* %p) {
%a = alloca i8*, align 8
store i8* %p, i8** %a, align 8
call void @foo() ["abc" (i8** %a)]
%reload = load i8*, i8** %a, align 8
ret i8* %reload
define ptr @test(ptr %p) {
%a = alloca ptr, align 8
store ptr %p, ptr %a, align 8
call void @foo() ["abc" (ptr %a)]
%reload = load ptr, ptr %a, align 8
ret ptr %reload
}
24 changes: 12 additions & 12 deletions llvm/test/Feature/alias2.ll
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
@v3 = global [2 x i16] zeroinitializer
; CHECK: @v3 = global [2 x i16] zeroinitializer

@a1 = alias i16, bitcast (i32* @v1 to i16*)
; CHECK: @a1 = alias i16, bitcast (i32* @v1 to i16*)
@a1 = alias i16, ptr @v1
; CHECK: @a1 = alias i16, ptr @v1

@a2 = alias i32, bitcast([1 x i32]* @v2 to i32*)
; CHECK: @a2 = alias i32, getelementptr inbounds ([1 x i32], [1 x i32]* @v2, i32 0, i32 0)
@a2 = alias i32, ptr @v2
; CHECK: @a2 = alias i32, ptr @v2

@a3 = alias i32, addrspacecast (i32* @v1 to i32 addrspace(2)*)
; CHECK: @a3 = alias i32, addrspacecast (i32* @v1 to i32 addrspace(2)*)
@a3 = alias i32, addrspacecast (ptr @v1 to ptr addrspace(2))
; CHECK: @a3 = alias i32, addrspacecast (ptr @v1 to ptr addrspace(2))

@a4 = alias i16, bitcast (i32* @v1 to i16*)
; CHECK: @a4 = alias i16, bitcast (i32* @v1 to i16*)
@a4 = alias i16, ptr @v1
; CHECK: @a4 = alias i16, ptr @v1

@a5 = thread_local(localdynamic) alias i32, i32* @v1
; CHECK: @a5 = thread_local(localdynamic) alias i32, i32* @v1
@a5 = thread_local(localdynamic) alias i32, ptr @v1
; CHECK: @a5 = thread_local(localdynamic) alias i32, ptr @v1

@a6 = alias i16, getelementptr ([2 x i16], [2 x i16]* @v3, i32 1, i32 1)
; CHECK: @a6 = alias i16, getelementptr ([2 x i16], [2 x i16]* @v3, i32 1, i32 1)
@a6 = alias i16, getelementptr ([2 x i16], ptr @v3, i32 1, i32 1)
; CHECK: @a6 = alias i16, getelementptr ([2 x i16], ptr @v3, i32 1, i32 1)
Loading

0 comments on commit 1842a29

Please sign in to comment.