Skip to content

Commit f22f41e

Browse files
committed
Handle review comments.
Added isSpecialSymbol to check for symbols which don't require debug info.
1 parent 3122f82 commit f22f41e

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

flang/include/flang/Optimizer/Support/InternalNames.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ struct NameUniquer {
184184

185185
static std::string replaceSpecialSymbols(const std::string &name);
186186

187+
/// Returns true if the passed name denotes a special symbol (e.g. global
188+
/// symbol generated for derived type description).
189+
static bool isSpecialSymbol(llvm::StringRef name);
190+
187191
private:
188192
static std::string intAsString(std::int64_t i);
189193
static std::string doKind(std::int64_t kind);

flang/lib/Optimizer/Support/InternalNames.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,3 +411,7 @@ fir::NameUniquer::dropTypeConversionMarkers(llvm::StringRef mangledTypeName) {
411411
std::string fir::NameUniquer::replaceSpecialSymbols(const std::string &name) {
412412
return std::regex_replace(name, std::regex{"\\."}, "X");
413413
}
414+
415+
bool fir::NameUniquer::isSpecialSymbol(llvm::StringRef name) {
416+
return !name.empty() && (name[0] == '.' || name[0] == 'X');
417+
}

flang/lib/Optimizer/Transforms/AddDebugInfo.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,7 @@ void AddDebugInfoPass::handleGlobalOp(fir::GlobalOp globalOp,
211211
if (result.first != fir::NameUniquer::NameKind::VARIABLE)
212212
return;
213213

214-
// Discard entries that describe a derived type. They start with either '.' or
215-
// 'X'. We filter both of them out. Note that NameUniquer makes the name lower
216-
// case so user variables should be safe. It would be better if result of the
217-
// deconstruct had a flag for such values so that we dont have to look at
218-
// string values.
219-
if (!result.second.name.empty() &&
220-
(result.second.name[0] == '.' || result.second.name[0] == 'X'))
214+
if (fir::NameUniquer::isSpecialSymbol(result.second.name))
221215
return;
222216

223217
unsigned line = getLineFromLoc(globalOp.getLoc());
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
! RUN: %flang_fc1 -emit-llvm -debug-info-kind=standalone %s -o - | FileCheck %s
22

33
module m
4-
integer XcX
4+
integer XcX
55
end
66

77
! Test that global starting with 'X' don't get filtered.
8-
CHECK: !DIGlobalVariable(name: "xcx", linkageName: "_QMmExcx"{{.*}})
8+
! CHECK: !DIGlobalVariable(name: "xcx", linkageName: "_QMmExcx"{{.*}})

0 commit comments

Comments
 (0)