[llvm] dafbf1c - [Attributor] Convert test to opaque pointers (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 30 06:58:49 PDT 2023
Author: Nikita Popov
Date: 2023-06-30T15:58:41+02:00
New Revision: dafbf1c1e55440aaace93679cfe8778783722443
URL: https://github.com/llvm/llvm-project/commit/dafbf1c1e55440aaace93679cfe8778783722443
DIFF: https://github.com/llvm/llvm-project/commit/dafbf1c1e55440aaace93679cfe8778783722443.diff
LOG: [Attributor] Convert test to opaque pointers (NFC)
The loads and stores of the global are now optimized, as the relevant
parts of the function signatures match.
Added:
Modified:
llvm/test/Transforms/Attributor/misc_crash.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/Attributor/misc_crash.ll b/llvm/test/Transforms/Attributor/misc_crash.ll
index f2755e3f7fb38..ce2295b4fff16 100644
--- a/llvm/test/Transforms/Attributor/misc_crash.ll
+++ b/llvm/test/Transforms/Attributor/misc_crash.ll
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
-; RUN: opt -opaque-pointers=0 -passes=attributor -S %s | FileCheck %s
+; RUN: opt -passes=attributor -S %s | FileCheck %s
@var1 = internal global [1 x i32] undef
@var2 = internal global i32 0
@@ -8,76 +8,72 @@
; CHECK: @[[VAR1:[a-zA-Z0-9_$"\\.-]+]] = internal global [1 x i32] undef
; CHECK: @[[VAR2:[a-zA-Z0-9_$"\\.-]+]] = internal global i32 0
;.
-define i32 addrspace(1)* @foo(i32 addrspace(4)* %arg) {
+define ptr addrspace(1) @foo(ptr addrspace(4) %arg) {
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
; CHECK-LABEL: define {{[^@]+}}@foo
-; CHECK-SAME: (i32 addrspace(4)* nofree readnone [[ARG:%.*]]) #[[ATTR0:[0-9]+]] {
+; CHECK-SAME: (ptr addrspace(4) nofree readnone [[ARG:%.*]]) #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[TMP0:%.*]] = addrspacecast i32 addrspace(4)* [[ARG]] to i32 addrspace(1)*
-; CHECK-NEXT: ret i32 addrspace(1)* [[TMP0]]
+; CHECK-NEXT: [[TMP0:%.*]] = addrspacecast ptr addrspace(4) [[ARG]] to ptr addrspace(1)
+; CHECK-NEXT: ret ptr addrspace(1) [[TMP0]]
;
entry:
- %0 = addrspacecast i32 addrspace(4)* %arg to i32 addrspace(1)*
- ret i32 addrspace(1)* %0
+ %0 = addrspacecast ptr addrspace(4) %arg to ptr addrspace(1)
+ ret ptr addrspace(1) %0
}
-define i32* @func1() {
+define ptr @func1() {
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
; CHECK-LABEL: define {{[^@]+}}@func1
; CHECK-SAME: () #[[ATTR0]] {
-; CHECK-NEXT: ret i32* getelementptr inbounds ([1 x i32], [1 x i32]* @var1, i32 0, i32 0)
+; CHECK-NEXT: ret ptr @var1
;
- %ptr = call i32* @func1a([1 x i32]* @var1)
- ret i32* %ptr
+ %ptr = call ptr @func1a(ptr @var1)
+ ret ptr %ptr
}
-define internal i32* @func1a([1 x i32]* %arg) {
- %ptr = getelementptr inbounds [1 x i32], [1 x i32]* %arg, i64 0, i64 0
- ret i32* %ptr
+define internal ptr @func1a(ptr %arg) {
+ ret ptr %arg
}
-define internal void @func2a(i32* %0) {
+define internal void @func2a(ptr %0) {
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
; CHECK-LABEL: define {{[^@]+}}@func2a
-; CHECK-SAME: (i32* nocapture nofree nonnull writeonly align 4 dereferenceable(4) [[TMP0:%.*]]) #[[ATTR1:[0-9]+]] {
-; CHECK-NEXT: store i32 0, i32* @var2, align 4
+; CHECK-SAME: (ptr nocapture nofree nonnull writeonly align 4 dereferenceable(4) [[TMP0:%.*]]) #[[ATTR1:[0-9]+]] {
; CHECK-NEXT: ret void
;
- store i32 0, i32* %0
+ store i32 0, ptr %0
ret void
}
define i32 @func2() {
-; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
+; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
; CHECK-LABEL: define {{[^@]+}}@func2
-; CHECK-SAME: () #[[ATTR2:[0-9]+]] {
-; CHECK-NEXT: [[TMP1:%.*]] = tail call i32 (i32*, ...) bitcast (void (i32*)* @func2a to i32 (i32*, ...)*)(i32* nonnull align 4 dereferenceable(4) @var2) #[[ATTR3:[0-9]+]]
-; CHECK-NEXT: [[TMP2:%.*]] = load i32, i32* @var2, align 4
-; CHECK-NEXT: ret i32 [[TMP2]]
+; CHECK-SAME: () #[[ATTR1]] {
+; CHECK-NEXT: [[TMP1:%.*]] = tail call i32 (ptr, ...) @func2a(ptr nocapture nofree nonnull writeonly align 4 dereferenceable(4) undef) #[[ATTR2:[0-9]+]]
+; CHECK-NEXT: ret i32 0
;
- %1 = tail call i32 (i32*, ...) bitcast (void (i32*)* @func2a to i32 (i32*, ...)*)(i32* @var2)
- %2 = load i32, i32* @var2
+ %1 = tail call i32 (ptr, ...) @func2a(ptr @var2)
+ %2 = load i32, ptr @var2
ret i32 %2
}
define i32 @func3(i1 %false) {
-; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
+; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
; CHECK-LABEL: define {{[^@]+}}@func3
-; CHECK-SAME: (i1 [[FALSE:%.*]]) #[[ATTR2]] {
-; CHECK-NEXT: [[TMP1:%.*]] = tail call i32 (i32*, ...) bitcast (void (i32*)* @func2a to i32 (i32*, ...)*)(i32* nonnull align 4 dereferenceable(4) @var2) #[[ATTR3]]
+; CHECK-SAME: (i1 [[FALSE:%.*]]) #[[ATTR1]] {
+; CHECK-NEXT: [[TMP1:%.*]] = tail call i32 (ptr, ...) @func2a(ptr nocapture nofree nonnull writeonly align 4 dereferenceable(4) undef) #[[ATTR3:[0-9]+]]
; CHECK-NEXT: br i1 [[FALSE]], label [[USE_BB:%.*]], label [[RET_BB:%.*]]
; CHECK: use_bb:
; CHECK-NEXT: ret i32 [[TMP1]]
; CHECK: ret_bb:
-; CHECK-NEXT: [[TMP2:%.*]] = load i32, i32* @var2, align 4
-; CHECK-NEXT: ret i32 [[TMP2]]
+; CHECK-NEXT: ret i32 0
;
- %1 = tail call i32 (i32*, ...) bitcast (void (i32*)* @func2a to i32 (i32*, ...)*)(i32* @var2)
+ %1 = tail call i32 (ptr, ...) @func2a(ptr @var2)
br i1 %false, label %use_bb, label %ret_bb
use_bb:
ret i32 %1
ret_bb:
- %2 = load i32, i32* @var2
+ %2 = load i32, ptr @var2
ret i32 %2
}
@@ -94,16 +90,16 @@ define internal void @func5(i32 %0) {
; CHECK-LABEL: define {{[^@]+}}@func5() {
; CHECK-NEXT: br label [[BLOCK:%.*]]
; CHECK: block:
-; CHECK-NEXT: call void @func6(i8* blockaddress(@func5, [[BLOCK]]))
+; CHECK-NEXT: call void @func6(ptr blockaddress(@func5, [[BLOCK]]))
; CHECK-NEXT: ret void
;
- %tmp = alloca i8*
+ %tmp = alloca ptr
br label %block
block:
- store i8* blockaddress(@func5, %block), i8** %tmp
- %addr = load i8*, i8** %tmp
- call void @func6(i8* %addr)
+ store ptr blockaddress(@func5, %block), ptr %tmp
+ %addr = load ptr, ptr %tmp
+ call void @func6(ptr %addr)
ret void
}
@@ -111,28 +107,27 @@ define i16 @foo3() {
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
; CHECK-LABEL: define {{[^@]+}}@foo3
; CHECK-SAME: () #[[ATTR0]] {
-; CHECK-NEXT: [[CALL:%.*]] = call i16 bitcast (i16 (i16*, i16)* @bar3 to i16 ()*)() #[[ATTR4:[0-9]+]]
+; CHECK-NEXT: [[CALL:%.*]] = call i16 @bar3() #[[ATTR3]]
; CHECK-NEXT: ret i16 [[CALL]]
;
- %call = call i16 bitcast (i16 (i16*, i16) * @bar3 to i16 () *)()
+ %call = call i16 @bar3()
ret i16 %call
}
-define internal i16 @bar3(i16* %p1, i16 %p2) {
+define internal i16 @bar3(ptr %p1, i16 %p2) {
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
; CHECK-LABEL: define {{[^@]+}}@bar3
-; CHECK-SAME: (i16* nocapture nofree readnone [[P1:%.*]], i16 returned [[P2:%.*]]) #[[ATTR0]] {
+; CHECK-SAME: (ptr nocapture nofree readnone [[P1:%.*]], i16 returned [[P2:%.*]]) #[[ATTR0]] {
; CHECK-NEXT: ret i16 [[P2]]
;
ret i16 %p2
}
; CHECK-LABEL: declare {{[^@]+}}@func6
-; CHECK-SAME: (i8*)
-declare void @func6(i8*)
+; CHECK-SAME: (ptr)
+declare void @func6(ptr)
;.
; CHECK: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
; CHECK: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }
-; CHECK: attributes #[[ATTR2]] = { mustprogress nofree norecurse nosync nounwind willreturn }
-; CHECK: attributes #[[ATTR3]] = { nofree nosync nounwind willreturn memory(write) }
-; CHECK: attributes #[[ATTR4]] = { nofree nosync nounwind willreturn memory(none) }
+; CHECK: attributes #[[ATTR2]] = { nofree nosync nounwind willreturn memory(write) }
+; CHECK: attributes #[[ATTR3]] = { nofree nosync nounwind willreturn }
;.
More information about the llvm-commits
mailing list