[llvm] 2603dcd - [Test] Add tests showing duplicate PHIs generated by RS4GC (NFC)
Dmitry Makogon via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 13 01:51:29 PDT 2022
Author: Dmitry Makogon
Date: 2022-04-13T15:51:17+07:00
New Revision: 2603dcdd8d482499ad9faf4c2472b0795d317016
URL: https://github.com/llvm/llvm-project/commit/2603dcdd8d482499ad9faf4c2472b0795d317016
DIFF: https://github.com/llvm/llvm-project/commit/2603dcdd8d482499ad9faf4c2472b0795d317016.diff
LOG: [Test] Add tests showing duplicate PHIs generated by RS4GC (NFC)
Added:
llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-14.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-14.ll b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-14.ll
new file mode 100644
index 0000000000000..d98cc52390004
--- /dev/null
+++ b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-14.ll
@@ -0,0 +1,73 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -rewrite-statepoints-for-gc < %s | FileCheck %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @foo() gc "statepoint-example"
+
+; FIXME: In this test case %b6.base, which is inserted by RS4GC, is identical
+; to %b6.
+define i8 addrspace(1)* @test1(i1 %c, i8 addrspace(1)* %b1, i8 addrspace(1)* %b2) gc "statepoint-example" {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT: left:
+; CHECK-NEXT: br i1 [[C:%.*]], label [[LOOP:%.*]], label [[MERGE2:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[B5:%.*]] = phi i8 addrspace(1)* [ [[B2:%.*]], [[LEFT:%.*]] ], [ [[B5]], [[LOOP]] ]
+; CHECK-NEXT: br i1 [[C]], label [[LOOP]], label [[MERGE2]]
+; CHECK: merge2:
+; CHECK-NEXT: [[B6_BASE:%.*]] = phi i8 addrspace(1)* [ [[B1:%.*]], [[LEFT]] ], [ [[B2]], [[LOOP]] ], !is_base_value !0
+; CHECK-NEXT: [[B6:%.*]] = phi i8 addrspace(1)* [ [[B1]], [[LEFT]] ], [ [[B5]], [[LOOP]] ]
+; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* elementtype(void ()) @foo, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i8 addrspace(1)* [[B6]], i8 addrspace(1)* [[B6_BASE]]) ]
+; CHECK-NEXT: [[B6_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
+; CHECK-NEXT: [[B6_BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
+; CHECK-NEXT: ret i8 addrspace(1)* [[B6_RELOCATED]]
+;
+left:
+ br i1 %c, label %loop, label %merge2
+
+loop:
+ %b5 = phi i8 addrspace(1)* [ %b2, %left ], [ %b5, %loop ]
+ br i1 %c, label %loop, label %merge2
+
+merge2:
+ %b6 = phi i8 addrspace(1)* [ %b1, %left ], [ %b5, %loop ]
+ call void @foo() [ "deopt"() ]
+ ret i8 addrspace(1)* %b6
+}
+
+; FIXME: In this test case %b5.base and %b6.base (inserted by RS4GC) are
+; identical to %b5 and %b6 ; correspondingly.
+define i8 addrspace(1)* @test2(i1 %c, i8 addrspace(1)* %b1, i8 addrspace(1)* %b2) gc "statepoint-example" {
+; CHECK-LABEL: @test2(
+; CHECK-NEXT: left:
+; CHECK-NEXT: br i1 [[C:%.*]], label [[LOOP:%.*]], label [[MERGE2:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[B5_BASE:%.*]] = phi i8 addrspace(1)* [ [[B2:%.*]], [[LEFT:%.*]] ], [ [[B5_BASE]], [[LOOP]] ], [ [[B6_BASE_RELOCATED:%.*]], [[MERGE2]] ], !is_base_value !0
+; CHECK-NEXT: [[B5:%.*]] = phi i8 addrspace(1)* [ [[B2]], [[LEFT]] ], [ [[B5]], [[LOOP]] ], [ [[B6_RELOCATED:%.*]], [[MERGE2]] ]
+; CHECK-NEXT: br i1 [[C]], label [[LOOP]], label [[MERGE2]]
+; CHECK: merge2:
+; CHECK-NEXT: [[B6_BASE:%.*]] = phi i8 addrspace(1)* [ [[B1:%.*]], [[LEFT]] ], [ [[B5_BASE]], [[LOOP]] ], !is_base_value !0
+; CHECK-NEXT: [[B6:%.*]] = phi i8 addrspace(1)* [ [[B1]], [[LEFT]] ], [ [[B5]], [[LOOP]] ]
+; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* elementtype(void ()) @foo, i32 0, i32 0, i32 0, i32 0) [ "deopt"(), "gc-live"(i8 addrspace(1)* [[B6_BASE]], i8 addrspace(1)* [[B6]]) ]
+; CHECK-NEXT: [[B6_BASE_RELOCATED]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
+; CHECK-NEXT: [[B6_RELOCATED]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 1)
+; CHECK-NEXT: br i1 [[C]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK: exit:
+; CHECK-NEXT: ret i8 addrspace(1)* [[B6_RELOCATED]]
+;
+left:
+ br i1 %c, label %loop, label %merge2
+
+loop:
+ %b5 = phi i8 addrspace(1)* [ %b2, %left ], [ %b5, %loop ], [ %b6, %merge2 ]
+ br i1 %c, label %loop, label %merge2
+
+merge2:
+ %b6 = phi i8 addrspace(1)* [ %b1, %left ], [ %b5, %loop ]
+ call void @foo() [ "deopt"() ]
+ br i1 %c, label %loop, label %exit
+
+exit:
+ ret i8 addrspace(1)* %b6
+}
More information about the llvm-commits
mailing list