This is an archive of the discontinued LLVM Phabricator instance.

[RS4GC] Strip noalias attribute after statepoint rewrite
ClosedPublic

Authored by igor-laevsky on Oct 23 2015, 5:01 PM.

Details

Summary

We should remove noalias along with dereference and dereference_or_null attributes. Problem is that statepoint could potentially touch the entire heap including noalias objects. For example in this piece of code:

%obj = call noalias %jObject* new_instance(...)
store %val, %obj ; last use of %obj
call gc.statepoint()

Llvm will consider that %obj and statepoint call do not alias and move store after the statepoint.

Diff Detail

Repository
rL LLVM

Event Timeline

igor-laevsky retitled this revision from to [RS4GC] Strip noalias attribute after statepoint rewrite.
igor-laevsky updated this object.
igor-laevsky added a reviewer: sanjoy.
igor-laevsky added a subscriber: llvm-commits.
sanjoy added inline comments.Oct 23 2015, 10:48 PM
include/llvm/IR/Instructions.h
1623 ↗(On Diff #38279)

I'd prefer a name like isNoAlias, since doesNotAlias begs the question "does not alias what?".

And I think the does not alias other parameters bit is not accurate for return values.

lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
118 ↗(On Diff #38279)

Nit: gc.statepoint

test/Transforms/RewriteStatepointsForGC/deref-pointers.ll
71 ↗(On Diff #38279)

Can I ask you to please add these tests to the deopt-bundles directory as well? If that's too much work, please add a "TODO also test for noalias" in deopt-bundles/deref-pointers.ll; and I'll port the tests once they're in tree.

sanjoy requested changes to this revision.Oct 23 2015, 10:49 PM
sanjoy edited edge metadata.
This revision now requires changes to proceed.Oct 23 2015, 10:49 PM
igor-laevsky edited edge metadata.
igor-laevsky marked 2 inline comments as done.
igor-laevsky added inline comments.
include/llvm/IR/Instructions.h
1623 ↗(On Diff #38279)

I intentionally named this similar as the analogous Function method. Besides consistency it is also required for correctness - RemoveNonValidAttrAtIndex should work both on Function's and CallSite's.

In order to solve this I can rename both methods in a separate change. Or alternatively I can restructure code in RS4GC to not rely on similar naming in Function and CallSite.

Bit I am leaning toward leaving things as-is. Llvm lived for quite some time with doesNotAlias naming and probably people already used to it.

I have fixed comment in the updated diff.

sanjoy accepted this revision.Oct 26 2015, 11:25 AM
sanjoy edited edge metadata.
sanjoy added inline comments.
include/llvm/IR/Instructions.h
1623 ↗(On Diff #38442)

Bit I am leaning toward leaving things as-is. Llvm lived for quite some time with doesNotAlias naming and probably people already used to it.

SGTM. :)

This revision is now accepted and ready to land.Oct 26 2015, 11:25 AM
This revision was automatically updated to reflect the committed changes.