[PATCH] D22598: [CFLAA] Add support for field offset in CFLGraph

Jia Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 20 14:50:02 PDT 2016


grievejia created this revision.
grievejia added reviewers: george.burgess.iv, hfinkel.
grievejia added a subscriber: llvm-commits.

This patch introduces no functional changes.

We used to treat GEPs like bitcasts and ignore the offsets. Such an approach is inadequate if we were to move to a field-sensitive analysis. We use accumulateConstantOffset() in this patch to keep track of field offsets in CFLGraphBuilder when the given gep can be decomposed into a base and a constant offset. 

To call accumulateConstantOffset() we need to perform a cast to GEPOperator in visitGetElementPtrInst(). This cast will fail when visitGetElementPtrInst() gets a ConstantExpr disguised as a GetElementPtrInst as its argument. I'm not 100% sure what the reason for the casting failure is, but a deeper problem here is that we handle ConstantExprs by casting them into their corresponding Instructions, and such a treatment is very hacky and fragile. I ended up fixing the problem by rewriting visitConstExpr() and letting it do its job in a proper manner. 

More patches on field-sensitivity will come in the near future.

https://reviews.llvm.org/D22598

Files:
  lib/Analysis/CFLGraph.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22598.64768.patch
Type: text/x-patch
Size: 6665 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160720/27ac3993/attachment.bin>


More information about the llvm-commits mailing list