Skip to content

Commit b7efaf3

Browse files
committed
Add a new interface function to_string for ThinOrFullLTOPhase
1 parent bbe924f commit b7efaf3

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

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

0 commit comments

Comments
 (0)