Skip to content

Commit 5cb643d

Browse files
committed
Add a new interface function to_string for ThinOrFullLTOPhase
1 parent 529ee2a commit 5cb643d

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

llvm/include/llvm/Pass.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,23 @@ enum class ThinOrFullLTOPhase {
8686
FullLTOPostLink
8787
};
8888

89+
#ifndef NDEBUG
90+
static inline const char *to_string(ThinOrFullLTOPhase Phase) {
91+
switch (Phase) {
92+
case ThinOrFullLTOPhase::None:
93+
return "None";
94+
case ThinOrFullLTOPhase::ThinLTOPreLink:
95+
return "ThinLTOPreLink";
96+
case ThinOrFullLTOPhase::ThinLTOPostLink:
97+
return "ThinLTOPostLink";
98+
case ThinOrFullLTOPhase::FullLTOPreLink:
99+
return "FullLTOPreLink";
100+
case ThinOrFullLTOPhase::FullLTOPostLink:
101+
return "FullLTOPostLink";
102+
}
103+
}
104+
#endif
105+
89106
//===----------------------------------------------------------------------===//
90107
/// Pass interface - Implemented by all 'passes'. Subclass this if you are an
91108
/// interprocedural optimization or you do not fit into any of the more

llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,21 +1374,7 @@ static bool runImpl(Module &M, AnalysisGetter &AG, TargetMachine &TM,
13741374
Attributor A(Functions, InfoCache, AC);
13751375

13761376
LLVM_DEBUG({
1377-
auto PhaseToString = [](ThinOrFullLTOPhase LTOPhase) -> StringRef {
1378-
switch (LTOPhase) {
1379-
case ThinOrFullLTOPhase::None:
1380-
return "None";
1381-
case ThinOrFullLTOPhase::ThinLTOPreLink:
1382-
return "ThinLTOPreLink";
1383-
case ThinOrFullLTOPhase::ThinLTOPostLink:
1384-
return "ThinLTOPostLink";
1385-
case ThinOrFullLTOPhase::FullLTOPreLink:
1386-
return "FullLTOPreLink";
1387-
case ThinOrFullLTOPhase::FullLTOPostLink:
1388-
return "FullLTOPostLink";
1389-
}
1390-
};
1391-
StringRef LTOPhaseStr = PhaseToString(LTOPhase);
1377+
StringRef LTOPhaseStr = to_string(LTOPhase);
13921378
dbgs() << "[AMDGPUAttributor] Running at phase " << LTOPhaseStr << '\n'
13931379
<< "[AMDGPUAttributor] Module " << M.getName() << " is "
13941380
<< (AC.IsClosedWorldModule ? "" : "not ")

0 commit comments

Comments
 (0)