Skip to content

Commit c308d90

Browse files
zdukaPetr Maj
and
Petr Maj
authored
Extra assertions in RS4GC (llvm#71201)
Adds assertion that the base/derived pointers are of the same size. --------- Co-authored-by: Petr Maj <[email protected]>
1 parent 0ca830e commit c308d90

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,13 +1251,21 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &Cache,
12511251
VerifyStates();
12521252
#endif
12531253

1254+
// get the data layout to compare the sizes of base/derived pointer values
1255+
[[maybe_unused]] auto &DL =
1256+
cast<llvm::Instruction>(Def)->getModule()->getDataLayout();
12541257
// Cache all of our results so we can cheaply reuse them
12551258
// NOTE: This is actually two caches: one of the base defining value
12561259
// relation and one of the base pointer relation! FIXME
12571260
for (auto Pair : States) {
12581261
auto *BDV = Pair.first;
12591262
Value *Base = Pair.second.getBaseValue();
12601263
assert(BDV && Base);
1264+
// Whenever we have a derived ptr(s), their base
1265+
// ptr(s) must be of the same size, not necessarily the same type
1266+
assert(DL.getTypeAllocSize(BDV->getType()) ==
1267+
DL.getTypeAllocSize(Base->getType()) &&
1268+
"Derived and base values should have same size");
12611269
// Only values that do not have known bases or those that have differing
12621270
// type (scalar versus vector) from a possible known base should be in the
12631271
// lattice.

0 commit comments

Comments
 (0)