Skip to content

Commit f879a0a

Browse files
committed
Add a new interface function to_string for ThinOrFullLTOPhase
1 parent dc736ad commit f879a0a

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
@@ -1380,21 +1380,7 @@ static bool runImpl(Module &M, AnalysisGetter &AG, TargetMachine &TM,
13801380
Attributor A(Functions, InfoCache, AC);
13811381

13821382
LLVM_DEBUG({
1383-
auto PhaseToString = [](ThinOrFullLTOPhase LTOPhase) -> StringRef {
1384-
switch (LTOPhase) {
1385-
case ThinOrFullLTOPhase::None:
1386-
return "None";
1387-
case ThinOrFullLTOPhase::ThinLTOPreLink:
1388-
return "ThinLTOPreLink";
1389-
case ThinOrFullLTOPhase::ThinLTOPostLink:
1390-
return "ThinLTOPostLink";
1391-
case ThinOrFullLTOPhase::FullLTOPreLink:
1392-
return "FullLTOPreLink";
1393-
case ThinOrFullLTOPhase::FullLTOPostLink:
1394-
return "FullLTOPostLink";
1395-
}
1396-
};
1397-
StringRef LTOPhaseStr = PhaseToString(LTOPhase);
1383+
StringRef LTOPhaseStr = to_string(LTOPhase);
13981384
dbgs() << "[AMDGPUAttributor] Running at phase " << LTOPhaseStr << '\n'
13991385
<< "[AMDGPUAttributor] Module " << M.getName() << " is "
14001386
<< (AC.IsClosedWorldModule ? "" : "not ")

0 commit comments

Comments
 (0)