aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
diff options
context:
space:
mode:
authorAlok Kumar Sharma <AlokKumar.Sharma@amd.com>2020-09-11 11:11:39 +0530
committerSourabh Singh Tomar <SourabhSingh.Tomar@amd.com>2020-09-11 11:12:49 +0530
commite45b0708ae81ace27de53f12b32a80601cb12bf3 (patch)
tree59587048e68b851478979b21f6657c2c1a849934 /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
parentda9244882804ec6479aac70334fd7f7b4baf855e (diff)
downloadllvm-e45b0708ae81ace27de53f12b32a80601cb12bf3.zip
llvm-e45b0708ae81ace27de53f12b32a80601cb12bf3.tar.gz
llvm-e45b0708ae81ace27de53f12b32a80601cb12bf3.tar.bz2
[DebugInfo] Fixing CodeView assert related to lowerBound field of DISubrange.
This is to fix CodeView build failure https://bugs.llvm.org/show_bug.cgi?id=47287 after DIsSubrange upgrade D80197 Assert condition is now removed and Count is calculated in case LowerBound is absent or zero and Count or UpperBound is constant. If Count is unknown it is later handled as VLA (currently Count is set to zero). Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D87406
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index b388e43..bcace62 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -1578,11 +1578,16 @@ TypeIndex CodeViewDebug::lowerTypeArray(const DICompositeType *Ty) {
assert(Element->getTag() == dwarf::DW_TAG_subrange_type);
const DISubrange *Subrange = cast<DISubrange>(Element);
- assert(!Subrange->getRawLowerBound() &&
- "codeview doesn't support subranges with lower bounds");
int64_t Count = -1;
- if (auto *CI = Subrange->getCount().dyn_cast<ConstantInt*>())
- Count = CI->getSExtValue();
+ // Calculate the count if either LowerBound is absent or is zero and
+ // either of Count or UpperBound are constant.
+ auto *LI = Subrange->getLowerBound().dyn_cast<ConstantInt *>();
+ if (!Subrange->getRawLowerBound() || (LI && (LI->getSExtValue() == 0))) {
+ if (auto *CI = Subrange->getCount().dyn_cast<ConstantInt*>())
+ Count = CI->getSExtValue();
+ else if (auto *UI = Subrange->getUpperBound().dyn_cast<ConstantInt*>())
+ Count = UI->getSExtValue() + 1; // LowerBound is zero
+ }
// Forward declarations of arrays without a size and VLAs use a count of -1.
// Emit a count of zero in these cases to match what MSVC does for arrays