[llvm] c308d90 - Extra assertions in RS4GC (#71201)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 23 10:41:19 PST 2023
Author: Petr Maj
Date: 2023-11-23T13:41:15-05:00
New Revision: c308d903a8fd479e49271ae9f08f7260ff5f58a7
URL: https://github.com/llvm/llvm-project/commit/c308d903a8fd479e49271ae9f08f7260ff5f58a7
DIFF: https://github.com/llvm/llvm-project/commit/c308d903a8fd479e49271ae9f08f7260ff5f58a7.diff
LOG: Extra assertions in RS4GC (#71201)
Adds assertion that the base/derived pointers are of the same size.
---------
Co-authored-by: Petr Maj <pmaj at azul.com>
Added:
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 21c2b8aa9485fd1..40b4ea92e1ff907 100644
--- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -1251,6 +1251,9 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &Cache,
VerifyStates();
#endif
+ // get the data layout to compare the sizes of base/derived pointer values
+ [[maybe_unused]] auto &DL =
+ cast<llvm::Instruction>(Def)->getModule()->getDataLayout();
// Cache all of our results so we can cheaply reuse them
// NOTE: This is actually two caches: one of the base defining value
// relation and one of the base pointer relation! FIXME
@@ -1258,6 +1261,11 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &Cache,
auto *BDV = Pair.first;
Value *Base = Pair.second.getBaseValue();
assert(BDV && Base);
+ // 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
diff ering
// type (scalar versus vector) from a possible known base should be in the
// lattice.
More information about the llvm-commits
mailing list