This is an archive of the discontinued LLVM Phabricator instance.

[CFLAA] Add an initial implementation of field-sensitivity to CFLAndersAliasAnalyiss
AbandonedPublic

Authored by grievejia on Jul 22 2016, 8:21 PM.

Details

Summary

This patch teaches CFLAnders to perform field offset arithmetic when propagating reachability along assignment edges.The only tricky part here is to get the plus/minus signs of those offsets right. Other than that, the analysis logic doesn't need to change too much.

Vurrent implementation should suffice for intra-procedural field-sensitive analysis. Unfortunately if we move to inter-procedural case, the correctness of the analysis is lost. The reason is that our current interprocedural analysis framework can only record ExternalRelations of the form "X = Y + Offset", where X and Y are InterfaceValues. Field-sensitive inter-procedural function summary often encounters relations of the form "*X = *(Y + Offset)", and there is no way to describe such a relation in the function summary without introducing any temporaries. In fact, even if the function summary knows how to describe those relations, for CFLGraph we have the same problem.

This is not a fundamentally hard problem to solve, but it is annoying in the sense that it's hard to get around it with just simple hacks. I am still figuring out a way to solve the aforementioned problem with as little modification to the current codebase as possible. My intuition is that no matter what I do, the change is not going to be small. So I'll just check in the intraprocedural analysis works to ease the burden of code review.

Diff Detail

Event Timeline

grievejia updated this revision to Diff 65208.Jul 22 2016, 8:21 PM
grievejia retitled this revision from to [CFLAA] Add an initial implementation of field-sensitivity to CFLAndersAliasAnalyiss.
grievejia updated this object.
grievejia added a subscriber: llvm-commits.

So I'll just check in the intraprocedural analysis works to ease the burden of code review.

Thank you :)

lib/Analysis/AliasAnalysisSummary.h
148

If we get many more of these, it may be nice to just have a cflaa::PointerOffset type (or whatever) with operators that know how to handle checking for unknown. If only because it would make it more difficult to cause subtle bugs.

lib/Analysis/CFLAndersAliasAnalysis.cpp
145

Please rebase; Having DenseMapInfo outside of namespace llvm { upset GCC and made it issue warnings. :)

458

Until we make it correct, would it make sense to put an assert(not_using_broken_params && "This won't produce correct output for ${case}.")? Or will that loudly break lots of things?

grievejia added inline comments.Jul 25 2016, 4:01 PM
lib/Analysis/AliasAnalysisSummary.h
148

Agreed. The addOffset() and subOffset() functions are just quick helpers I wrote to get things going. At some point we may want to switch to a dedicated newtype.

lib/Analysis/CFLAndersAliasAnalysis.cpp
458

Unfortunately I think compared to those cases where this work, there are far more cases where this doesn't work :(

I'm going to abandon this patch for now, since committing into the codebase will just break CFLAnders and I don't think it can be fixed quickly in the near future. I'll bring it back once I get a better understanding of how to properly construct a field-sensitive function summary.

grievejia abandoned this revision.Jul 25 2016, 4:02 PM