diff options
| author | George Burgess IV <george.burgess.iv@gmail.com> | 2018-07-09 22:21:16 +0000 |
|---|---|---|
| committer | George Burgess IV <george.burgess.iv@gmail.com> | 2018-07-09 22:21:16 +0000 |
| commit | 3fbfa9c40377f1af163070dd4a44d1b39dd661a4 (patch) | |
| tree | 1c42e650b87f8e82a706c668db994220c4494590 /llvm/lib/Analysis/MemoryBuiltins.cpp | |
| parent | 87a615d6fa6add8f35240b4c288a4cef3bc2f0fc (diff) | |
| download | bcm5719-llvm-3fbfa9c40377f1af163070dd4a44d1b39dd661a4.tar.gz bcm5719-llvm-3fbfa9c40377f1af163070dd4a44d1b39dd661a4.zip | |
Make llvm.objectsize more conservative with null
In non-zero address spaces, we were reporting that an object at `null`
always occupies zero bytes. This is incorrect in many cases, so just
return `unknown` in those cases for now.
Differential Revision: https://reviews.llvm.org/D48860
llvm-svn: 336611
Diffstat (limited to 'llvm/lib/Analysis/MemoryBuiltins.cpp')
| -rw-r--r-- | llvm/lib/Analysis/MemoryBuiltins.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp index deacdb9e324..686ad294378 100644 --- a/llvm/lib/Analysis/MemoryBuiltins.cpp +++ b/llvm/lib/Analysis/MemoryBuiltins.cpp @@ -642,7 +642,14 @@ SizeOffsetType ObjectSizeOffsetVisitor::visitCallSite(CallSite CS) { SizeOffsetType ObjectSizeOffsetVisitor::visitConstantPointerNull(ConstantPointerNull& CPN) { - if (Options.NullIsUnknownSize && CPN.getType()->getAddressSpace() == 0) + // If null is unknown, there's nothing we can do. Additionally, non-zero + // address spaces can make use of null, so we don't presume to know anything + // about that. + // + // TODO: How should this work with address space casts? We currently just drop + // them on the floor, but it's unclear what we should do when a NULL from + // addrspace(1) gets casted to addrspace(0) (or vice-versa). + if (Options.NullIsUnknownSize || CPN.getType()->getAddressSpace()) return unknown(); return std::make_pair(Zero, Zero); } |

