Skip to content

Commit

Permalink
Extra assertions in RS4GC (#71201)
Browse files Browse the repository at this point in the history
Adds assertion that the base/derived pointers are of the same size.

---------

Co-authored-by: Petr Maj <pmaj@azul.com>
  • Loading branch information
zduka and Petr Maj committed Nov 23, 2023
1 parent 0ca830e commit c308d90
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1251,13 +1251,21 @@ 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
for (auto Pair : States) {
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 differing
// type (scalar versus vector) from a possible known base should be in the
// lattice.
Expand Down

0 comments on commit c308d90

Please sign in to comment.