diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -1578,8 +1578,13 @@ assert(Element->getTag() == dwarf::DW_TAG_subrange_type); const DISubrange *Subrange = cast(Element); - assert(!Subrange->getRawLowerBound() && - "codeview doesn't support subranges with lower bounds"); + // Codeview supports Subranges with either absent lowerBound or lowerBound + // with constant zero value. Everyting else will be rejected. + auto *LI = Subrange->getLowerBound().dyn_cast(); + assert( + (!Subrange->getRawLowerBound() || (LI && (LI->getSExtValue() == 0))) && + "codeview doesn't support subranges with non zero lower bounds"); + int64_t Count = -1; if (auto *CI = Subrange->getCount().dyn_cast()) Count = CI->getSExtValue();