-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Don't ignore memcpy in GC root placement #23564
Conversation
#23522 might only be reproducible with |
Can you check this PR locally and see if it fixes your issue? |
Checking. |
src/llvm-late-gc-lowering.cpp
Outdated
@@ -727,8 +727,8 @@ State LateLowerGCFrame::LocalScan(Function &F) { | |||
for (auto it = BB.rbegin(); it != BB.rend(); ++it) { | |||
Instruction &I = *it; | |||
if (CallInst *CI = dyn_cast<CallInst>(&I)) { | |||
if (isa<IntrinsicInst>(CI)) { | |||
// Intrinsics are never GC uses/defs | |||
if (isa<IntrinsicInst>(CI) && !isa<MemIntrinsic>(CI)) { |
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.
I assume this covers other intrinsics that touches memory? (like scatter, gather etc.)?
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.
And maybe add this condition back below where we check pointer_from_objref
and memcmp
so that they won't be treated as safepoints?
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.
Ah, I forgot about scatter and gather. There's probably also some machine specific intrinsic intrinsics that take memory operands. Probably easiest to just check debug and lifetime here (which are the only ones we emit frequently), but still declare all intrinsics as non-safepoint.
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.
Running the script in #23522 102 times without triggering the issue. The llvm IR generated for colon(::Float64, ::Float64, ::Float64)
also looks correct now.
LGTM other than the minor comments above.
Just for fun, the probability that this didn't fix #23522 is smaller than 10^-200 ;-p |
II->getIntrinsicID() == Intrinsic::lifetime_start || | ||
II->getIntrinsicID() == Intrinsic::lifetime_end) { | ||
continue; | ||
} |
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.
This version certainly looks better than the original one, which already looks good to me but you did remind me of a llvm intrinsic that I happened to notice the other day. llvm.load.relative
is the only instruction I've found so far that returns a derived pointer. Probably don't need to worry about it as long as LLVM optimization passes don't emit it?
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.
Thanks, I didn't know about that intrinsic (in my defensive it's only about a year old ;)), but yeah, I don't think we have to worry about it.
If @yuyichao's analysis is correct, should fix #23522, though I've been unable to reproduce the failure myself (perhaps due to differing LLVM versions).