[llvm] 3b54aa9 - freeze does not change the constant property
Danila Malyutin via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 14 09:53:43 PDT 2022
Author: Danila Malyutin
Date: 2022-06-14T19:53:26+03:00
New Revision: 3b54aa9eab823f8edc8eaae4fba8e6f646ff5f91
URL: https://github.com/llvm/llvm-project/commit/3b54aa9eab823f8edc8eaae4fba8e6f646ff5f91
DIFF: https://github.com/llvm/llvm-project/commit/3b54aa9eab823f8edc8eaae4fba8e6f646ff5f91.diff
LOG: freeze does not change the constant property
Traverse through freeze when checking if base is constant
Differential Revision: https://reviews.llvm.org/D127744
Added:
Modified:
llvm/lib/IR/SafepointIRVerifier.cpp
llvm/test/SafepointIRVerifier/hidden-constant-base.ll
Removed:
################################################################################
diff --git a/llvm/lib/IR/SafepointIRVerifier.cpp b/llvm/lib/IR/SafepointIRVerifier.cpp
index 4cc3334fbccd2..5d3fa28f7d0a2 100644
--- a/llvm/lib/IR/SafepointIRVerifier.cpp
+++ b/llvm/lib/IR/SafepointIRVerifier.cpp
@@ -363,6 +363,11 @@ static enum BaseType getBaseType(const Value *Val) {
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.
diff --git a/llvm/test/SafepointIRVerifier/hidden-constant-base.ll b/llvm/test/SafepointIRVerifier/hidden-constant-base.ll
index 129e00430dc9b..eb03dda823d11 100644
--- a/llvm/test/SafepointIRVerifier/hidden-constant-base.ll
+++ b/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 @@ bb8: ; preds = %bb4
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()
More information about the llvm-commits
mailing list