summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Instructions.cpp
diff options
context:
space:
mode:
authorBjorn Pettersson <bjorn.a.pettersson@ericsson.com>2018-06-26 06:17:00 +0000
committerBjorn Pettersson <bjorn.a.pettersson@ericsson.com>2018-06-26 06:17:00 +0000
commit550517bcabcd7633d288dac41c21dc7bf03ba1db (patch)
treebc6bf611dd7ff5bf2481ded9d27df4f0abc66c1f /llvm/lib/IR/Instructions.cpp
parentda2e2caa6c99ae067a26a0b56f976303be17d71c (diff)
downloadbcm5719-llvm-550517bcabcd7633d288dac41c21dc7bf03ba1db.tar.gz
bcm5719-llvm-550517bcabcd7633d288dac41c21dc7bf03ba1db.zip
Improve ConvertDebugDeclareToDebugValue
Summary: This is a follow-up to r334830 and r335031. In the valueCoversEntireFragment check we now also handle the situation when there is a variable length array (VLA) involved, and the length of the array has been reduced to a constant. The ConvertDebugDeclareToDebugValue functions that are related to PHI nodes and load instructions now avoid inserting dbg.value intrinsics when the value does not, for certain, cover the variable/fragment that should be described. In r334830 we assumed that the value always covered the entire var/fragment and we had assertions in the code to show that assumption. However, those asserts failed when compiling code with VLAs, so we removed the asserts in r335031. Now when we know that the valueCoversEntireFragment check can fail also for PHI/Load instructions we avoid to insert the faulty dbg.value intrinsic in such situations. Compared to the Store instruction scenario we simply drop the dbg.value here (as the variable does not change its value due to PHI/Load, so an earlier dbg.value describing the variable should still be valid). Reviewers: aprantl, vsk, efriedma Reviewed By: aprantl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D48547 llvm-svn: 335580
Diffstat (limited to 'llvm/lib/IR/Instructions.cpp')
-rw-r--r--llvm/lib/IR/Instructions.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 58d377c47f6..e0ad0d1ea1f 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -45,6 +45,22 @@
using namespace llvm;
//===----------------------------------------------------------------------===//
+// AllocaInst Class
+//===----------------------------------------------------------------------===//
+
+Optional<uint64_t>
+AllocaInst::getAllocationSizeInBits(const DataLayout &DL) const {
+ uint64_t Size = DL.getTypeAllocSizeInBits(getAllocatedType());
+ if (isArrayAllocation()) {
+ auto C = dyn_cast<ConstantInt>(getArraySize());
+ if (!C)
+ return None;
+ Size *= C->getZExtValue();
+ }
+ return Size;
+}
+
+//===----------------------------------------------------------------------===//
// CallSite Class
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud