This is an archive of the discontinued LLVM Phabricator instance.

[CFLAA] Try to be less conservative on more functions
ClosedPublic

Authored by grievejia on Jun 19 2016, 5:53 PM.

Details

Summary

I've changed the criteria of marking a function f external from "f->hasLocalLinkage()" to "f->isInterposable()". I think the former is overly conservative since it only handles functions with internal or private linkage type, yet all we want for non-external functions is that they can't be overwritten while linking. If my thought turns out to be wrong, I'm happy to switch it back.

Diff Detail

Event Timeline

grievejia updated this revision to Diff 61231.Jun 19 2016, 5:53 PM
grievejia retitled this revision from to [CFLAA] Try to be less conservative on more functions.
grievejia updated this object.
grievejia added a subscriber: llvm-commits.
sanjoy added a subscriber: sanjoy.Jun 19 2016, 10:44 PM

Drop by comment

lib/Analysis/CFLAliasAnalysis.cpp
380

If this is doing inter-procedural alias analysis, then you need to use Fn-> hasExactDefinition().

grievejia updated this revision to Diff 61251.Jun 20 2016, 7:30 AM
grievejia marked an inline comment as done.

Change isInterposable() to !hasExactDefinition()

lib/Analysis/CFLAliasAnalysis.cpp
380

Thank you so much for pointing that out!

sanjoy requested changes to this revision.Jun 20 2016, 9:27 AM
sanjoy added a reviewer: sanjoy.
sanjoy added inline comments.
lib/Analysis/CFLAliasAnalysis.cpp
380

hasExactDefinition checks for isDeclaration. You should just be able to replace isFunctionExternal(F) with F->hasExactDefinition().

This revision now requires changes to proceed.Jun 20 2016, 9:27 AM
grievejia updated this revision to Diff 61262.Jun 20 2016, 9:49 AM
grievejia edited edge metadata.
grievejia marked an inline comment as done.

Remove Fn->isDeclaration().

Also, a test xfail was just discovered in the dependent patch. It could be removed in this patch, as the diff shows.

grievejia added inline comments.Jun 20 2016, 9:53 AM
lib/Analysis/CFLAliasAnalysis.cpp
380

I think I'll just keep isFunctionExternal() here, in case other alias analysis-specific checks are needed.

george.burgess.iv edited edge metadata.

I'm assuming Sanjoy's fine with this, so LGTM -- thanks for splitting this out.

sanjoy accepted this revision.Jun 20 2016, 11:38 AM
sanjoy edited edge metadata.

I'm assuming Sanjoy's fine with this, so LGTM -- thanks for splitting this out.

Yes, this looks fine.

This revision is now accepted and ready to land.Jun 20 2016, 11:38 AM

It seems that applying this patch on top of D21475 causes test/Analysis/CFLAliasAnalysis/basic-interproc-ret.ll to fail.

The output I get from the test suite is:

test/Analysis/CFLAliasAnalysis/basic-interproc-ret.ll:8:10: error: expected string not found in input
; CHECK: 3 no alias responses
         ^
<stdin>:5:2: note: scanning from here
 4 no alias responses (100.0%)
 ^

And the output I get from running the test directly is

Function: test2: 2 pointers, 0 call sites
Function: test: 3 pointers, 1 call sites
===== Alias Analysis Evaluator Report =====
  4 Total Alias Queries Performed
  4 no alias responses (100.0%)
  0 may alias responses (0.0%)
  0 partial alias responses (0.0%)
  0 must alias responses (0.0%)
  Alias Analysis Evaluator Pointer Alias Summary: 100%/0%/0%/0%
  3 Total ModRef Queries Performed
  1 no mod/ref responses (33.3%)
  0 mod responses (0.0%)
  0 ref responses (0.0%)
  2 mod & ref responses (66.6%)
  Alias Analysis Evaluator Mod/Ref Summary: 33%/0%/0%/66%

Is this intentional? (If so, no need to re-upload the diff; I can just tweak the test to expect 4 NoAlias responses)

Interesting. I remembered that I deleted this prticular test case in the previous patch (what it tests has already been covered by other cases). It is likely that I messed up something and the removal was not included. I'm ok with either a fix or a removal of it.

Thank you so much for bringing this up, by the way!

This revision was automatically updated to reflect the committed changes.