Skip to content
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

Merged
merged 1 commit into from
Sep 3, 2017
Merged

Don't ignore memcpy in GC root placement #23564

merged 1 commit into from
Sep 3, 2017

Conversation

Keno
Copy link
Member

@Keno Keno commented Sep 2, 2017

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).

@Keno Keno requested a review from yuyichao September 2, 2017 20:01
@yuyichao
Copy link
Contributor

yuyichao commented Sep 2, 2017

#23522 might only be reproducible with WITH_GC_DEBUG_ENV on. (or at least WITH_GC_SCRUB) The NaN comes from the GC filling possibly unrooted object with 0xff.

@Keno
Copy link
Member Author

Keno commented Sep 2, 2017

Can you check this PR locally and see if it fixes your issue?

@yuyichao
Copy link
Contributor

yuyichao commented Sep 2, 2017

Checking.

@@ -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)) {
Copy link
Contributor

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.)?

Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

@yuyichao yuyichao left a 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.

@yuyichao
Copy link
Contributor

yuyichao commented Sep 2, 2017

Just for fun, the probability that this didn't fix #23522 is smaller than 10^-200 ;-p

@ararslan ararslan added the GC Garbage collector label Sep 2, 2017
@yuyichao yuyichao added the compiler:codegen Generation of LLVM IR and native code label Sep 3, 2017
II->getIntrinsicID() == Intrinsic::lifetime_start ||
II->getIntrinsicID() == Intrinsic::lifetime_end) {
continue;
}
Copy link
Contributor

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?

Copy link
Member Author

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.

@Keno Keno merged commit 9cdec25 into master Sep 3, 2017
@martinholters martinholters deleted the kf/gcmemcpy branch September 3, 2017 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:codegen Generation of LLVM IR and native code GC Garbage collector
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nondeterministic ranges test failure
3 participants