From 11eb8d88d829a86bfc252628f105c99b1ead73e6 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 21 Apr 2023 12:42:22 +0200 Subject: [PATCH] [NewGVN] Convert tests to opaque pointers (NFC) --- .../NewGVN/2007-07-26-InterlockingLoops.ll | 24 ++++---- llvm/test/Transforms/NewGVN/non-local-offset.ll | 58 +++++++++----------- llvm/test/Transforms/NewGVN/refine-stores.ll | 64 ++++++++++------------ 3 files changed, 67 insertions(+), 79 deletions(-) diff --git a/llvm/test/Transforms/NewGVN/2007-07-26-InterlockingLoops.ll b/llvm/test/Transforms/NewGVN/2007-07-26-InterlockingLoops.ll index 4b1ec38..52b4a59 100644 --- a/llvm/test/Transforms/NewGVN/2007-07-26-InterlockingLoops.ll +++ b/llvm/test/Transforms/NewGVN/2007-07-26-InterlockingLoops.ll @@ -1,15 +1,15 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2 -; RUN: opt -opaque-pointers=0 < %s -passes=newgvn -S | FileCheck %s +; RUN: opt < %s -passes=newgvn -S | FileCheck %s -@last = external global [65 x i32*] +@last = external global [65 x ptr] define i32 @NextRootMove(i32 %wtm, i32 %x, i32 %y, i32 %z) { ; CHECK-LABEL: define i32 @NextRootMove ; CHECK-SAME: (i32 [[WTM:%.*]], i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) { ; CHECK-NEXT: entry: -; CHECK-NEXT: [[A:%.*]] = alloca i32*, align 8 -; CHECK-NEXT: [[TMP17618:%.*]] = load i32*, i32** getelementptr inbounds ([65 x i32*], [65 x i32*]* @last, i32 0, i32 1), align 4 -; CHECK-NEXT: store i32* [[TMP17618]], i32** [[A]], align 8 +; CHECK-NEXT: [[A:%.*]] = alloca ptr, align 8 +; CHECK-NEXT: [[TMP17618:%.*]] = load ptr, ptr getelementptr inbounds ([65 x ptr], ptr @last, i32 0, i32 1), align 4 +; CHECK-NEXT: store ptr [[TMP17618]], ptr [[A]], align 8 ; CHECK-NEXT: br label [[COND_TRUE116:%.*]] ; CHECK: cond_true116: ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X]], [[Y]] @@ -27,9 +27,9 @@ define i32 @NextRootMove(i32 %wtm, i32 %x, i32 %y, i32 %z) { ; CHECK-NEXT: ret i32 0 ; entry: - %A = alloca i32* - %tmp17618 = load i32*, i32** getelementptr ([65 x i32*], [65 x i32*]* @last, i32 0, i32 1), align 4 - store i32* %tmp17618, i32** %A + %A = alloca ptr + %tmp17618 = load ptr, ptr getelementptr ([65 x ptr], ptr @last, i32 0, i32 1), align 4 + store ptr %tmp17618, ptr %A br label %cond_true116 cond_true116: @@ -37,8 +37,8 @@ cond_true116: br i1 %cmp, label %cond_true128, label %cond_true145 cond_true128: - %tmp17625 = load i32*, i32** getelementptr ([65 x i32*], [65 x i32*]* @last, i32 0, i32 1), align 4 - store i32* %tmp17625, i32** %A + %tmp17625 = load ptr, ptr getelementptr ([65 x ptr], ptr @last, i32 0, i32 1), align 4 + store ptr %tmp17625, ptr %A %cmp1 = icmp eq i32 %x, %z br i1 %cmp1 , label %bb98.backedge, label %return.loopexit @@ -46,8 +46,8 @@ bb98.backedge: br label %cond_true116 cond_true145: - %tmp17631 = load i32*, i32** getelementptr ([65 x i32*], [65 x i32*]* @last, i32 0, i32 1), align 4 - store i32* %tmp17631, i32** %A + %tmp17631 = load ptr, ptr getelementptr ([65 x ptr], ptr @last, i32 0, i32 1), align 4 + store ptr %tmp17631, ptr %A br i1 false, label %bb98.backedge, label %return.loopexit return.loopexit: diff --git a/llvm/test/Transforms/NewGVN/non-local-offset.ll b/llvm/test/Transforms/NewGVN/non-local-offset.ll index 5cca68e..a8fc550 100644 --- a/llvm/test/Transforms/NewGVN/non-local-offset.ll +++ b/llvm/test/Transforms/NewGVN/non-local-offset.ll @@ -1,34 +1,34 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2 -; RUN: opt -opaque-pointers=0 -passes=newgvn -S < %s | FileCheck %s +; RUN: opt -passes=newgvn -S < %s | FileCheck %s target datalayout = "e-p:64:64:64" ; GVN should ignore the store to p[1] to see that the load from p[0] is ; fully redundant. -define void @yes(i1 %c, i32* %p, i32* %q) nounwind { +define void @yes(i1 %c, ptr %p, ptr %q) nounwind { ; CHECK-LABEL: define void @yes -; CHECK-SAME: (i1 [[C:%.*]], i32* [[P:%.*]], i32* [[Q:%.*]]) #[[ATTR0:[0-9]+]] { +; CHECK-SAME: (i1 [[C:%.*]], ptr [[P:%.*]], ptr [[Q:%.*]]) #[[ATTR0:[0-9]+]] { ; CHECK-NEXT: entry: -; CHECK-NEXT: store i32 0, i32* [[P]], align 4 -; CHECK-NEXT: [[P1:%.*]] = getelementptr inbounds i32, i32* [[P]], i64 1 -; CHECK-NEXT: store i32 1, i32* [[P1]], align 4 +; CHECK-NEXT: store i32 0, ptr [[P]], align 4 +; CHECK-NEXT: [[P1:%.*]] = getelementptr inbounds i32, ptr [[P]], i64 1 +; CHECK-NEXT: store i32 1, ptr [[P1]], align 4 ; CHECK-NEXT: br i1 [[C]], label [[IF_ELSE:%.*]], label [[IF_THEN:%.*]] ; CHECK: if.then: -; CHECK-NEXT: store i32 0, i32* [[Q]], align 4 +; CHECK-NEXT: store i32 0, ptr [[Q]], align 4 ; CHECK-NEXT: ret void ; CHECK: if.else: ; CHECK-NEXT: ret void ; entry: - store i32 0, i32* %p - %p1 = getelementptr inbounds i32, i32* %p, i64 1 - store i32 1, i32* %p1 + store i32 0, ptr %p + %p1 = getelementptr inbounds i32, ptr %p, i64 1 + store i32 1, ptr %p1 br i1 %c, label %if.else, label %if.then if.then: - %t = load i32, i32* %p - store i32 %t, i32* %q + %t = load i32, ptr %p + store i32 %t, ptr %q ret void if.else: @@ -39,39 +39,35 @@ if.else: ; fully redundant. However, the second load is larger, so it's not a simple ; redundancy. -define void @watch_out_for_size_change(i1 %c, i32* %p, i32* %q) nounwind { +define void @watch_out_for_size_change(i1 %c, ptr %p, ptr %q) nounwind { ; CHECK-LABEL: define void @watch_out_for_size_change -; CHECK-SAME: (i1 [[C:%.*]], i32* [[P:%.*]], i32* [[Q:%.*]]) #[[ATTR0]] { +; CHECK-SAME: (i1 [[C:%.*]], ptr [[P:%.*]], ptr [[Q:%.*]]) #[[ATTR0]] { ; CHECK-NEXT: entry: -; CHECK-NEXT: store i32 0, i32* [[P]], align 4 -; CHECK-NEXT: [[P1:%.*]] = getelementptr inbounds i32, i32* [[P]], i64 1 -; CHECK-NEXT: store i32 1, i32* [[P1]], align 4 +; CHECK-NEXT: store i32 0, ptr [[P]], align 4 +; CHECK-NEXT: [[P1:%.*]] = getelementptr inbounds i32, ptr [[P]], i64 1 +; CHECK-NEXT: store i32 1, ptr [[P1]], align 4 ; CHECK-NEXT: br i1 [[C]], label [[IF_ELSE:%.*]], label [[IF_THEN:%.*]] ; CHECK: if.then: -; CHECK-NEXT: store i32 0, i32* [[Q]], align 4 +; CHECK-NEXT: store i32 0, ptr [[Q]], align 4 ; CHECK-NEXT: ret void ; CHECK: if.else: -; CHECK-NEXT: [[PC:%.*]] = bitcast i32* [[P]] to i64* -; CHECK-NEXT: [[QC:%.*]] = bitcast i32* [[Q]] to i64* -; CHECK-NEXT: [[T64:%.*]] = load i64, i64* [[PC]], align 4 -; CHECK-NEXT: store i64 [[T64]], i64* [[QC]], align 4 +; CHECK-NEXT: [[T64:%.*]] = load i64, ptr [[P]], align 4 +; CHECK-NEXT: store i64 [[T64]], ptr [[Q]], align 4 ; CHECK-NEXT: ret void ; entry: - store i32 0, i32* %p - %p1 = getelementptr inbounds i32, i32* %p, i64 1 - store i32 1, i32* %p1 + store i32 0, ptr %p + %p1 = getelementptr inbounds i32, ptr %p, i64 1 + store i32 1, ptr %p1 br i1 %c, label %if.else, label %if.then if.then: - %t = load i32, i32* %p - store i32 %t, i32* %q + %t = load i32, ptr %p + store i32 %t, ptr %q ret void if.else: - %pc = bitcast i32* %p to i64* - %qc = bitcast i32* %q to i64* - %t64 = load i64, i64* %pc - store i64 %t64, i64* %qc + %t64 = load i64, ptr %p + store i64 %t64, ptr %q ret void } diff --git a/llvm/test/Transforms/NewGVN/refine-stores.ll b/llvm/test/Transforms/NewGVN/refine-stores.ll index 878392e..a45dd1f 100644 --- a/llvm/test/Transforms/NewGVN/refine-stores.ll +++ b/llvm/test/Transforms/NewGVN/refine-stores.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -opaque-pointers=0 < %s -passes=newgvn -S | FileCheck %s +; RUN: opt < %s -passes=newgvn -S | FileCheck %s ;; Now that we do store refinement, we have to verify that we add fake uses ;; when we skip existing stores. ;; We also are testing that various variations that cause stores to move classes @@ -11,11 +11,10 @@ target triple = "x86_64-apple-darwin16.5.0" %struct.eggs = type {} -define void @spam(i32 *%a) { +define void @spam(ptr %a) { ; CHECK-LABEL: @spam( ; CHECK-NEXT: bb: -; CHECK-NEXT: [[FOO:%.*]] = bitcast i32* [[A:%.*]] to %struct.eggs** -; CHECK-NEXT: store %struct.eggs* null, %struct.eggs** [[FOO]], align 8 +; CHECK-NEXT: store ptr null, ptr [[A:%.*]], align 8 ; CHECK-NEXT: br label [[BB1:%.*]] ; CHECK: bb1: ; CHECK-NEXT: br i1 undef, label [[BB3:%.*]], label [[BB2:%.*]] @@ -23,13 +22,12 @@ define void @spam(i32 *%a) { ; CHECK-NEXT: call void @baz() ; CHECK-NEXT: br label [[BB1]] ; CHECK: bb3: -; CHECK-NEXT: store i32 0, i32* undef, align 4 -; CHECK-NEXT: store %struct.eggs* null, %struct.eggs** [[FOO]], align 8 +; CHECK-NEXT: store i32 0, ptr undef, align 4 +; CHECK-NEXT: store ptr null, ptr [[A]], align 8 ; CHECK-NEXT: unreachable ; bb: - %foo = bitcast i32 *%a to %struct.eggs** - store %struct.eggs* null, %struct.eggs** %foo + store ptr null, ptr %a br label %bb1 bb1: ; preds = %bb2, %bb @@ -40,13 +38,13 @@ bb2: ; preds = %bb1 br label %bb1 bb3: ; preds = %bb1 - store i32 0, i32* undef + store i32 0, ptr undef ;; This store is defined by a memoryphi of the call and the first store ;; At first, we will prove it equivalent to the first store above. ;; Then the call will become reachable, and the equivalence will be removed ;; Without it being a use of the first store, we will not update the store ;; to reflect this. - store %struct.eggs* null, %struct.eggs** %foo + store ptr null, ptr %a unreachable } @@ -58,48 +56,46 @@ define void @a() { ; CHECK-NEXT: b: ; CHECK-NEXT: br label [[C:%.*]] ; CHECK: c: -; CHECK-NEXT: store i64 undef, i64* null, align 4 +; CHECK-NEXT: store i64 undef, ptr null, align 4 ; CHECK-NEXT: br label [[E:%.*]] ; CHECK: e: -; CHECK-NEXT: [[G:%.*]] = load i64*, i64** null, align 8 -; CHECK-NEXT: store i64* undef, i64** null, align 8 +; CHECK-NEXT: store ptr undef, ptr null, align 8 ; CHECK-NEXT: br i1 undef, label [[C]], label [[E]] ; b: br label %c c: ; preds = %e, %b - %d = phi i64* [ undef, %b ], [ null, %e ] - store i64 undef, i64* %d + %d = phi ptr [ undef, %b ], [ null, %e ] + store i64 undef, ptr %d br label %e e: ; preds = %e, %c ;; The memory for this load starts out equivalent to just the store in c, we later discover the store after us, and ;; need to make sure the right set of values get marked as changed after memory leaders change - %g = load i64*, i64** null - %0 = bitcast i64* %g to i64* - store i64* undef, i64** null + %g = load ptr, ptr null + store ptr undef, ptr null br i1 undef, label %c, label %e } %struct.hoge = type {} -define void @widget(%struct.hoge* %arg) { +define void @widget(ptr %arg) { ; CHECK-LABEL: @widget( ; CHECK-NEXT: bb: ; CHECK-NEXT: br label [[BB1:%.*]] ; CHECK: bb1: -; CHECK-NEXT: [[TMP:%.*]] = phi %struct.hoge* [ [[ARG:%.*]], [[BB:%.*]] ], [ null, [[BB1]] ] -; CHECK-NEXT: store %struct.hoge* [[TMP]], %struct.hoge** undef, align 8 +; CHECK-NEXT: [[TMP:%.*]] = phi ptr [ [[ARG:%.*]], [[BB:%.*]] ], [ null, [[BB1]] ] +; CHECK-NEXT: store ptr [[TMP]], ptr undef, align 8 ; CHECK-NEXT: br i1 undef, label [[BB1]], label [[BB2:%.*]] ; CHECK: bb2: ; CHECK-NEXT: [[TMP3:%.*]] = phi i64 [ [[TMP8:%.*]], [[BB7:%.*]] ], [ 0, [[BB1]] ] ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[TMP3]], 0 ; CHECK-NEXT: br i1 [[TMP4]], label [[BB7]], label [[BB5:%.*]] ; CHECK: bb5: -; CHECK-NEXT: [[TMP6:%.*]] = load i64, i64* null, align 4 +; CHECK-NEXT: [[TMP6:%.*]] = load i64, ptr null, align 4 ; CHECK-NEXT: call void @quux() -; CHECK-NEXT: store i64 [[TMP6]], i64* undef, align 4 +; CHECK-NEXT: store i64 [[TMP6]], ptr undef, align 4 ; CHECK-NEXT: br label [[BB7]] ; CHECK: bb7: ; CHECK-NEXT: [[TMP8]] = add i64 [[TMP3]], 1 @@ -109,8 +105,8 @@ bb: br label %bb1 bb1: ; preds = %bb1, %bb - %tmp = phi %struct.hoge* [ %arg, %bb ], [ null, %bb1 ] - store %struct.hoge* %tmp, %struct.hoge** undef + %tmp = phi ptr [ %arg, %bb ], [ null, %bb1 ] + store ptr %tmp, ptr undef br i1 undef, label %bb1, label %bb2 bb2: ; preds = %bb7, %bb1 @@ -121,9 +117,9 @@ bb2: ; preds = %bb7, %bb1 bb5: ; preds = %bb2 ;; Originally thought equal to the store that comes after it until the phi edges ;; are completely traversed - %tmp6 = load i64, i64* null + %tmp6 = load i64, ptr null call void @quux() - store i64 %tmp6, i64* undef + store i64 %tmp6, ptr undef br label %bb7 bb7: ; preds = %bb5, %bb2 @@ -142,9 +138,7 @@ define void @b() { ; CHECK: m: ; CHECK-NEXT: unreachable ; CHECK: d: -; CHECK-NEXT: [[G:%.*]] = bitcast %struct.a* [[C]] to i8* -; CHECK-NEXT: [[F:%.*]] = bitcast i8* [[G]] to i32* -; CHECK-NEXT: [[E:%.*]] = load i32, i32* [[F]], align 4 +; CHECK-NEXT: [[E:%.*]] = load i32, ptr [[C]], align 4 ; CHECK-NEXT: br i1 undef, label [[I:%.*]], label [[J:%.*]] ; CHECK: i: ; CHECK-NEXT: br i1 undef, label [[K:%.*]], label [[M:%.*]] @@ -159,14 +153,12 @@ define void @b() { br label %d m: ; preds = %j, %i - store i32 %e, i32* %f + store i32 %e, ptr %h unreachable d: ; preds = %0 - %g = bitcast %struct.a* %c to i8* - %h = getelementptr i8, i8* %g - %f = bitcast i8* %h to i32* - %e = load i32, i32* %f + %h = getelementptr i8, ptr %c + %e = load i32, ptr %h br i1 undef, label %i, label %j i: ; preds = %d @@ -179,7 +171,7 @@ l: ; preds = %k %n = phi i32 [ %e, %k ] ;; Becomes equal and then not equal to the other store, and ;; along the way, the load. - store i32 %n, i32* %f + store i32 %n, ptr %h unreachable j: ; preds = %d -- 2.7.4