Skip to content

Commit 7c902c2

Browse files
committed
Handled review comments.
Following changes were done. 1. Remove MLIR changes as they have been moved to separate PR. 2. Replace std::map with llvm::StringMap 3. Use a direct for loop instead of module.walk.
1 parent e006b73 commit 7c902c2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

flang/lib/Optimizer/Transforms/AddDebugInfo.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class AddDebugInfoPass : public fir::impl::AddDebugInfoBase<AddDebugInfoPass> {
5757
void runOnOperation() override;
5858

5959
private:
60-
std::map<std::string, mlir::LLVM::DIModuleAttr> moduleMap;
60+
llvm::StringMap<mlir::LLVM::DIModuleAttr> moduleMap;
6161

6262
mlir::LLVM::DIModuleAttr getOrCreateModuleAttr(
6363
const std::string &name, mlir::LLVM::DIFileAttr fileAttr,
@@ -119,7 +119,7 @@ mlir::LLVM::DIModuleAttr AddDebugInfoPass::getOrCreateModuleAttr(
119119
mlir::MLIRContext *context = &getContext();
120120
mlir::LLVM::DIModuleAttr modAttr;
121121
if (auto iter{moduleMap.find(name)}; iter != moduleMap.end())
122-
modAttr = iter->second;
122+
modAttr = iter->getValue();
123123
else {
124124
modAttr = mlir::LLVM::DIModuleAttr::get(
125125
context, fileAttr, scope, mlir::StringAttr::get(context, name),
@@ -209,9 +209,8 @@ void AddDebugInfoPass::runOnOperation() {
209209
llvm::dwarf::getLanguage("DW_LANG_Fortran95"), fileAttr, producer,
210210
isOptimized, debugLevel);
211211

212-
module.walk([&](fir::GlobalOp globalOp) {
212+
for (auto globalOp : module.getOps<fir::GlobalOp>())
213213
handleGlobalOp(globalOp, fileAttr, cuAttr);
214-
});
215214

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

0 commit comments

Comments
 (0)