[llvm] Extra assertions in RS4GC (PR #71201)
Petr Maj via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 3 09:39:38 PDT 2023
https://github.com/zduka created https://github.com/llvm/llvm-project/pull/71201
Adds assertion that the base/derived pointers are of the same size.
>From 5c99f1b2fe5316c7c3c422c18f5836c32abdbd40 Mon Sep 17 00:00:00 2001
From: Petr Maj <pmaj at azul.com>
Date: Fri, 27 Oct 2023 18:31:53 +0200
Subject: [PATCH 1/2] Extra assert added
---
llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
index 63ee11295e9c032..5b8d0344af687e1 100644
--- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -1249,6 +1249,8 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &Cache,
#ifndef NDEBUG
VerifyStates();
+ // get the data layout to compare the sizes of base/derived pointer values
+ auto &DL = cast<llvm::Instruction>(Def)->getModule()->getDataLayout();
#endif
// Cache all of our results so we can cheaply reuse them
@@ -1258,6 +1260,8 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &Cache,
auto *BDV = Pair.first;
Value *Base = Pair.second.getBaseValue();
assert(BDV && Base);
+ // the assumption is that whenever we have a derived ptr(s), their base ptr(s) must be of the same size, not necessarily the same type
+ assert(DL.getTypeAllocSize(BDV->getType()) == DL.getTypeAllocSize(Base->getType()) && "Derived and base values should have same size");
// Only values that do not have known bases or those that have differing
// type (scalar versus vector) from a possible known base should be in the
// lattice.
>From 04a56cfbf02878b09470c1e9727f97ceb9c1fdc2 Mon Sep 17 00:00:00 2001
From: Petr Maj <pmaj at azul.com>
Date: Fri, 27 Oct 2023 18:32:16 +0200
Subject: [PATCH 2/2] fmt
---
llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
index 5b8d0344af687e1..35945a8fb577545 100644
--- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -1249,7 +1249,7 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &Cache,
#ifndef NDEBUG
VerifyStates();
- // get the data layout to compare the sizes of base/derived pointer values
+ // get the data layout to compare the sizes of base/derived pointer values
auto &DL = cast<llvm::Instruction>(Def)->getModule()->getDataLayout();
#endif
@@ -1260,8 +1260,11 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &Cache,
auto *BDV = Pair.first;
Value *Base = Pair.second.getBaseValue();
assert(BDV && Base);
- // the assumption is that whenever we have a derived ptr(s), their base ptr(s) must be of the same size, not necessarily the same type
- assert(DL.getTypeAllocSize(BDV->getType()) == DL.getTypeAllocSize(Base->getType()) && "Derived and base values should have same size");
+ // the assumption is that whenever we have a derived ptr(s), their base
+ // ptr(s) must be of the same size, not necessarily the same type
+ assert(DL.getTypeAllocSize(BDV->getType()) ==
+ DL.getTypeAllocSize(Base->getType()) &&
+ "Derived and base values should have same size");
// Only values that do not have known bases or those that have differing
// type (scalar versus vector) from a possible known base should be in the
// lattice.
More information about the llvm-commits
mailing list