-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extra assertions in RS4GC #71201
Extra assertions in RS4GC #71201
Conversation
@llvm/pr-subscribers-llvm-transforms Author: Petr Maj (zduka) ChangesAdds assertion that the base/derived pointers are of the same size. Full diff: https://github.com/llvm/llvm-project/pull/71201.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
index 63ee11295e9c032..35945a8fb577545 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,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");
// 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.
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM w/ nit.
Co-authored-by: annamthomas <anna@azul.com>
Thank you! |
Adds assertion that the base/derived pointers are of the same size.