[llvm] 5a08e81 - [RS4GC] Add support for 'freeze' instruction to findBaseDefiningValue

Max Kazantsev via llvm-commits llvm-commits at lists.llvm.org
Fri May 6 06:46:35 PDT 2022


Author: Max Kazantsev
Date: 2022-05-06T20:46:29+07:00
New Revision: 5a08e81779d0c7968558a6aebb989240c98c93a7

URL: https://github.com/llvm/llvm-project/commit/5a08e81779d0c7968558a6aebb989240c98c93a7
DIFF: https://github.com/llvm/llvm-project/commit/5a08e81779d0c7968558a6aebb989240c98c93a7.diff

LOG: [RS4GC] Add support for 'freeze' instruction to findBaseDefiningValue

Because this instruction is a noop, we can simply go through it in
search of the base.

Added: 
    llvm/test/Transforms/RewriteStatepointsForGC/pr55308.ll

Modified: 
    llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
index df884c0aff379..ed0d3f6e4a2e0 100644
--- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -560,6 +560,9 @@ static BaseDefiningValueResult findBaseDefiningValue(Value *I) {
     // The base of this GEP is the base
     return findBaseDefiningValue(GEP->getPointerOperand());
 
+  if (auto *Freeze = dyn_cast<FreezeInst>(I))
+    return findBaseDefiningValue(Freeze->getOperand(0));
+
   if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
     switch (II->getIntrinsicID()) {
     default:

diff  --git a/llvm/test/Transforms/RewriteStatepointsForGC/pr55308.ll b/llvm/test/Transforms/RewriteStatepointsForGC/pr55308.ll
new file mode 100644
index 0000000000000..fba018f977b11
--- /dev/null
+++ b/llvm/test/Transforms/RewriteStatepointsForGC/pr55308.ll
@@ -0,0 +1,25 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -passes=rewrite-statepoints-for-gc -S < %s | FileCheck %s
+
+define void @test() gc "statepoint-example" personality i32* ()* @zot{
+; CHECK-LABEL: @test(
+; CHECK-NEXT:  bb:
+; CHECK-NEXT:    [[TMP:%.*]] = freeze i8 addrspace(1)* undef
+; CHECK-NEXT:    [[TMP3:%.*]] = getelementptr inbounds i8, i8 addrspace(1)* [[TMP]], i64 16
+; CHECK-NEXT:    [[TMP4:%.*]] = bitcast i8 addrspace(1)* [[TMP3]] to i32 addrspace(1)*
+; CHECK-NEXT:    [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* elementtype(void ()) @wibble, i32 0, i32 0, i32 0, i32 0) [ "deopt"() ]
+; CHECK-NEXT:    [[TMP5:%.*]] = getelementptr inbounds i32, i32 addrspace(1)* [[TMP4]], i64 undef
+; CHECK-NEXT:    ret void
+;
+bb:
+  %tmp = freeze i8 addrspace(1)* undef
+  %tmp3 = getelementptr inbounds i8, i8 addrspace(1)* %tmp, i64 16
+  %tmp4 = bitcast i8 addrspace(1)* %tmp3 to i32 addrspace(1)*
+  call void @wibble() #3 [ "deopt"() ]
+  %tmp5 = getelementptr inbounds i32, i32 addrspace(1)* %tmp4, i64 undef
+  ret void
+}
+
+declare i32* @zot()
+
+declare void @wibble()


        


More information about the llvm-commits mailing list