diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2013-03-02 11:23:34 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2013-03-02 11:23:34 +0000 |
commit | 6e3d46014d6960f2c698153ac0765a3e58d1bad4 (patch) | |
tree | f7a68538597144f5cf64602bcf241ba668a97df7 /llvm/lib/Analysis/MemoryBuiltins.cpp | |
parent | 336ec56081e775f9355bcc40f93ead0572bdc7c5 (diff) | |
download | bcm5719-llvm-6e3d46014d6960f2c698153ac0765a3e58d1bad4.tar.gz bcm5719-llvm-6e3d46014d6960f2c698153ac0765a3e58d1bad4.zip |
add getUnderlyingObjectSize()
this is similar to getObjectSize(), but doesnt subtract the offset
tweak the BasicAA code accordingly (per PR14988)
llvm-svn: 176407
Diffstat (limited to 'llvm/lib/Analysis/MemoryBuiltins.cpp')
-rw-r--r-- | llvm/lib/Analysis/MemoryBuiltins.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp index 0fc05505ddb..90f5811289c 100644 --- a/llvm/lib/Analysis/MemoryBuiltins.cpp +++ b/llvm/lib/Analysis/MemoryBuiltins.cpp @@ -360,6 +360,26 @@ bool llvm::getObjectSize(const Value *Ptr, uint64_t &Size, const DataLayout *TD, return true; } +/// \brief Compute the size of the underlying object pointed by Ptr. Returns +/// true and the object size in Size if successful, and false otherwise. +/// If RoundToAlign is true, then Size is rounded up to the aligment of allocas, +/// byval arguments, and global variables. +bool llvm::getUnderlyingObjectSize(const Value *Ptr, uint64_t &Size, + const DataLayout *TD, + const TargetLibraryInfo *TLI, + bool RoundToAlign) { + if (!TD) + return false; + + ObjectSizeOffsetVisitor Visitor(TD, TLI, Ptr->getContext(), RoundToAlign); + SizeOffsetType Data = Visitor.compute(const_cast<Value*>(Ptr)); + if (!Visitor.knownSize(Data)) + return false; + + Size = Data.first.getZExtValue(); + return true; +} + STATISTIC(ObjectVisitorArgument, "Number of arguments with unsolved size and offset"); |