Skip to content

Commit 485c7e5

Browse files
committed
Process variable only if full debug info is requested.
1 parent 743681c commit 485c7e5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

flang/lib/Optimizer/Transforms/AddDebugInfo.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,11 @@ void AddDebugInfoPass::runOnOperation() {
210210
llvm::dwarf::getLanguage("DW_LANG_Fortran95"), fileAttr, producer,
211211
isOptimized, debugLevel);
212212

213-
for (auto globalOp : module.getOps<fir::GlobalOp>())
214-
handleGlobalOp(globalOp, fileAttr, cuAttr);
213+
if (debugLevel == mlir::LLVM::DIEmissionKind::Full) {
214+
// Process 'GlobalOp' only if full debug info is requested.
215+
for (auto globalOp : module.getOps<fir::GlobalOp>())
216+
handleGlobalOp(globalOp, fileAttr, cuAttr);
217+
}
215218

216219
module.walk([&](mlir::func::FuncOp funcOp) {
217220
mlir::Location l = funcOp->getLoc();

flang/test/Transforms/debug-module-2.f90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
! RUN: %flang_fc1 -emit-llvm -debug-info-kind=standalone %s -o - | FileCheck %s
2+
! RUN: %flang_fc1 -emit-llvm -debug-info-kind=line-tables-only %s -o - | FileCheck --check-prefix=LINEONLY %s
23

34
! CHECK-DAG: ![[FILE:.*]] = !DIFile(filename: {{.*}}debug-module-2.f90{{.*}})
45
! CHECK-DAG: ![[FILE2:.*]] = !DIFile(filename: {{.*}}debug-module-2.f90{{.*}})
@@ -35,3 +36,4 @@ program test
3536
end program test
3637

3738
! CHECK-DAG: ![[GLOBALS]] = !{![[GLIX]], ![[GLRX]]}
39+
! LINEONLY-NOT: DIGlobalVariable

0 commit comments

Comments
 (0)