[PATCH] D127743: freeze does not change the constant property

Danila Malyutin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 14 07:38:24 PDT 2022


danilaml created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
danilaml requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Traverse through freeze when checking if base is constant


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127743

Files:
  llvm/lib/IR/SafepointIRVerifier.cpp
  llvm/test/SafepointIRVerifier/hidden-constant-base.ll


Index: llvm/test/SafepointIRVerifier/hidden-constant-base.ll
===================================================================
--- llvm/test/SafepointIRVerifier/hidden-constant-base.ll
+++ llvm/test/SafepointIRVerifier/hidden-constant-base.ll
@@ -1,8 +1,8 @@
-; RUN: opt -safepoint-ir-verifier-print-only -verify-safepoint-ir -S %s 2>&1 | FileCheck %s
+; RUN: opt -safepoint-ir-verifier-print-only -passes='verify<safepoint-ir>' -S %s 2>&1 | FileCheck %s
 
 ; CHECK-LABEL: Verifying gc pointers in function: test
-; CHECK: No illegal uses found by SafepointIRVerifier in: test
-define i8 addrspace(1)* @test(i1 %arg) gc "statepoint-example" {
+; CHECK: No illegal uses found by SafepointIRVerifier in: test_gc_relocate
+define i8 addrspace(1)* @test_gc_relocate(i1 %arg) gc "statepoint-example" {
 bb:
   br label %bb2
 
@@ -25,6 +25,20 @@
   br i1 %arg, label %bb4, label %bb2
 }
 
+; CHECK-LABEL: Verifying gc pointers in function: test
+; CHECK: No illegal uses found by SafepointIRVerifier in: test_freeze_inst
+define void @test_freeze_inst(i32* %ptr) gc "statepoint-example" {
+entry:
+  br label %loop
+
+loop:
+  %vptr = phi i8 addrspace(1)* [ %fptr, %loop ], [ undef, %entry ]
+  %fptr = freeze i8 addrspace(1)* %vptr
+  %statepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* elementtype(void ()) undef, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i8 addrspace(1)* %fptr), "gc-live"(i8 addrspace(1)* %fptr) ]
+  %fptr.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32 0, i32 0) ; (%fptr, %fptr)
+  br label %loop
+}
+
 declare void @widget()
 declare i1 @baz()
 
Index: llvm/lib/IR/SafepointIRVerifier.cpp
===================================================================
--- llvm/lib/IR/SafepointIRVerifier.cpp
+++ llvm/lib/IR/SafepointIRVerifier.cpp
@@ -363,6 +363,11 @@
       Worklist.push_back(GCRelocate->getDerivedPtr());
       continue;
     }
+    if (const auto *FI = dyn_cast<FreezeInst>(V)) {
+      // Freeze does not change null-ness or constant-ness of the value.
+      Worklist.push_back(FI->getOperand(0));
+      continue;
+    }
     if (isa<Constant>(V)) {
       // We found at least one base pointer which is non-null, so this derived
       // pointer is not exclusively derived from null.
@@ -867,6 +872,7 @@
         reportInvalidUse(*RHS, I);
     }
   } else {
+    LLVM_DEBUG(dbgs() << "I: " << I << "\n");
     for (const Value *V : I.operands())
       if (containsGCPtrType(V->getType()) &&
           isNotExclusivelyConstantDerived(V) && !AvailableSet.count(V))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127743.436777.patch
Type: text/x-patch
Size: 2640 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220614/450bd3a8/attachment.bin>


More information about the llvm-commits mailing list