[flang-commits] [flang] [flang][debug] Add fake use ops for dynamic array dimension variables (PR #200061)
via flang-commits
flang-commits at lists.llvm.org
Tue Jun 2 00:39:04 PDT 2026
================
@@ -331,6 +331,60 @@ void AddDebugInfoPass::handleLocalVariable(Op declOp, llvm::StringRef name,
auto tyAttr =
typeGen.convertType(typeToConvert, fileAttr, scopeAttr, typeGenDeclOp);
+ // Check if tyAttr represents a dynamic Fortran array. If so, create
+ // FakeUseOps to preserve the automatic variables that represent the lower
+ // bound, count, and stride.
+ if (emitFakeUseForDebugVars) {
+ if (auto arrayTy =
+ mlir::dyn_cast<mlir::LLVM::DICompositeTypeAttr>(tyAttr)) {
+ if (arrayTy.getTag() == llvm::dwarf::DW_TAG_array_type) {
+ bool isDynamic = llvm::any_of(
----------------
jeanPerier wrote:
What is actually the point of `isDynamic`? It does not look like it is saving much processing time compared to directly going through the declOp below even if there is nothing to do, and it is adding compilation time when there are fake use to emit.
I would suggest removing it.
https://github.com/llvm/llvm-project/pull/200061
More information about the flang-commits
mailing list