[DebugInfo] Upgrade DISubragne::count to accept DIExpression also
authorAlok Kumar Sharma <AlokKumar.Sharma@amd.com>
Thu, 25 Mar 2021 11:04:57 +0000 (16:34 +0530)
committerAlok Kumar Sharma <AlokKumar.Sharma@amd.com>
Tue, 30 Mar 2021 03:46:55 +0000 (09:16 +0530)
commit9fb0025f7084db14d16fe5cbe1d799f4ee0020af
tree46a7f12adc88afe9c58668d19cec67b0354d9904
parent90c401cab63459334785f61076d4f05e4e487c1f
[DebugInfo] Upgrade DISubragne::count to accept DIExpression also

This is needed for Fortran assumed shape arrays whose dimensions are
defined as,
  - 'count' is taken from array descriptor passed as parameter by
    caller, access from descriptor is defined by type DIExpression.
  - 'lowerBound' is defined by callee.
The current alternate way represents using upperBound in place of
count, where upperBound is calculated in callee in a temp variable
using lowerBound and count

Representation with count (DIExpression) is not only clearer as
compared to upperBound (DIVariable) but it has another advantage that
variable count is accessed by being parameter has better chance of
survival at higher optimization level than upperBound being local
variable.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D99335
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/DebugInfoMetadata.cpp
llvm/lib/IR/Verifier.cpp
llvm/test/DebugInfo/fortranSubrangeCountExpr.ll [new file with mode: 0644]
llvm/test/Verifier/invalid-disubrange-count-node.ll