[flang-commits] [flang] [flang][debug] Handle array types with variable size/bounds. (PR #110686)
via flang-commits
flang-commits at lists.llvm.org
Thu Oct 3 00:37:41 PDT 2024
================
@@ -78,6 +78,33 @@ static mlir::LLVM::DITypeAttr genPlaceholderType(mlir::MLIRContext *context) {
/*bitSize=*/32, llvm::dwarf::DW_ATE_signed);
}
+// Helper function to create DILocalVariableAttr and DbgValueOp when information
+// about the size or dimension of a variable etc lives in an mlir::Value.
+mlir::LLVM::DILocalVariableAttr DebugTypeGenerator::generateArtificialVariable(
+ mlir::MLIRContext *context, mlir::Value Val,
+ mlir::LLVM::DIFileAttr fileAttr, mlir::LLVM::DIScopeAttr scope,
+ fir::cg::XDeclareOp declOp) {
+ // There can be multiple artificial variable for a single declOp. To help
+ // distinguish then, we pad the name with a counter. This static variable
+ // helps us achieve that.
+ static unsigned varID = 0;
----------------
jeanPerier wrote:
We should really stay away from static variables in MLIR passes that can be multithreaded, if you need a counter, it should either be part of the DebugTypeGenerator, or generated by finding the position of val in declOp.getOperands().
The latest may just be the best to get stability in the debug info. I.e., if some variable is added/changed in a file, it is best if the debug info for the other variables is not changed. Otherwise, this is usually a source of pain in maintaining lit tests files.
https://github.com/llvm/llvm-project/pull/110686
More information about the flang-commits
mailing list