This is an archive of the discontinued LLVM Phabricator instance.

[Attributor] Deduce "no-capture" argument attribute
ClosedPublic

Authored by jdoerfert on Mar 28 2019, 1:23 AM.

Details

Summary

Add the no-capture argument attribute deduction to the Attributor
fixpoint framework.

The new string attributed "no-capture-maybe-returned" is introduced to
allow deduction of no-capture through functions that "capture" an
argument but only by "returning" it.

Impact on the statistics (-stats) for LLVM-TS + Spec2006, ~7% more no-capute arguments:

CHANGED: attributor                   NumAttributesManifested                14323 ->      50306 (  +251.225%)                                                                                 
CHANGED: attributor                   NumAttributesValidFixpoint             39780 ->      81666 (  +105.294%)                                                                                 
  ADDED: attributor                   NumFnArgumentNoCapture                   n/a ->      35429
CHANGED: functionattrs                NumNoCapture                           32989 ->          2 (   -99.994%)

Note: both remaining function attribute deductions are deduction of no-capture even though it is already present.

Event Timeline

jdoerfert created this revision.Mar 28 2019, 1:23 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMar 28 2019, 1:23 AM
jdoerfert marked 2 inline comments as done.Mar 28 2019, 5:06 PM
jdoerfert added inline comments.
llvm/test/Transforms/FunctionAttrs/arg_nocapture.ll
86–87

The comments on this one were off from the very beginning, I'll fix them and there won't be a change during this commit.

llvm/test/Transforms/FunctionAttrs/nocapture.ll
137

So, the old FuncAttr deduction interleaves one of two memory behavior deductions with the capture analysis. With this patch capture analysis becomes obsolete, as the attributor added annotations, and certain memory behavior attributes are not detected anymore. There will be a memory behavior detection for the attributor soon which should make this problem go away.

Closed a side-channel through "integers"

jdoerfert edited the summary of this revision. (Show Details)Apr 1 2019, 8:26 AM
sanjoy removed a reviewer: sanjoy.Apr 1 2019, 11:06 AM
jdoerfert updated this revision to Diff 215504.Aug 15 2019, 4:36 PM

Extracted CaptureTracking changes

jdoerfert updated this revision to Diff 215713.Aug 16 2019, 4:30 PM

Add more test coverage and improve capture information based on dereferenceability

jdoerfert updated this revision to Diff 215716.Aug 16 2019, 4:35 PM

Add tests accidentally removed

jdoerfert updated this revision to Diff 217306.Aug 26 2019, 9:52 PM

rebase and update tests

jdoerfert updated this revision to Diff 218109.Aug 30 2019, 8:28 AM

Update tests

uenoku accepted this revision.Sep 2 2019, 4:23 AM

I think the logic is sound. It looks good to me.

llvm/lib/Transforms/IPO/Attributor.cpp
2618

Maybe we need an exact definition for no-capture-maybe-returned in LangRef.

2674

aswell

2761

Why IfNecessary? It seems there is no check.

2819

Align?

2864

liveness liveness

This revision is now accepted and ready to land.Sep 2 2019, 4:23 AM
jdoerfert marked 6 inline comments as done.Sep 3 2019, 1:33 PM
jdoerfert added inline comments.
llvm/lib/Transforms/IPO/Attributor.cpp
2618

I add a flag to disable manifestation in non-testing modes. If we add users we can add it as a enum attribute, for now it is internal.

This revision was automatically updated to reflect the committed changes.
jdoerfert marked an inline comment as done.