[llvm] a4e9cfd - [NFC] Fix a potential compile error in `llvm::to_string(ThinOrFullLTOPhase Phase)`
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Fri May 2 10:57:24 PDT 2025
Author: Shilei Tian
Date: 2025-05-02T13:49:40-04:00
New Revision: a4e9cfd117301b662fb3cee52ce3762c525917d3
URL: https://github.com/llvm/llvm-project/commit/a4e9cfd117301b662fb3cee52ce3762c525917d3
DIFF: https://github.com/llvm/llvm-project/commit/a4e9cfd117301b662fb3cee52ce3762c525917d3.diff
LOG: [NFC] Fix a potential compile error in `llvm::to_string(ThinOrFullLTOPhase Phase)`
https://github.com/llvm/llvm-project/pull/123994#discussion_r2071940298
Added:
Modified:
llvm/include/llvm/Pass.h
llvm/lib/IR/Pass.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Pass.h b/llvm/include/llvm/Pass.h
index 9e1d79dc81bbf..921db0b5f7aec 100644
--- a/llvm/include/llvm/Pass.h
+++ b/llvm/include/llvm/Pass.h
@@ -87,20 +87,7 @@ enum class ThinOrFullLTOPhase {
};
#ifndef NDEBUG
-constexpr const char *to_string(ThinOrFullLTOPhase Phase) {
- switch (Phase) {
- case ThinOrFullLTOPhase::None:
- return "None";
- case ThinOrFullLTOPhase::ThinLTOPreLink:
- return "ThinLTOPreLink";
- case ThinOrFullLTOPhase::ThinLTOPostLink:
- return "ThinLTOPostLink";
- case ThinOrFullLTOPhase::FullLTOPreLink:
- return "FullLTOPreLink";
- case ThinOrFullLTOPhase::FullLTOPostLink:
- return "FullLTOPostLink";
- }
-}
+const char *to_string(ThinOrFullLTOPhase Phase);
#endif
//===----------------------------------------------------------------------===//
diff --git a/llvm/lib/IR/Pass.cpp b/llvm/lib/IR/Pass.cpp
index 5701bd7680830..b1b33a517f0ff 100644
--- a/llvm/lib/IR/Pass.cpp
+++ b/llvm/lib/IR/Pass.cpp
@@ -282,3 +282,21 @@ AnalysisUsage &AnalysisUsage::addRequiredTransitiveID(char &ID) {
pushUnique(RequiredTransitive, &ID);
return *this;
}
+
+#ifndef NDEBUG
+const char *llvm::to_string(ThinOrFullLTOPhase Phase) {
+ switch (Phase) {
+ case ThinOrFullLTOPhase::None:
+ return "None";
+ case ThinOrFullLTOPhase::ThinLTOPreLink:
+ return "ThinLTOPreLink";
+ case ThinOrFullLTOPhase::ThinLTOPostLink:
+ return "ThinLTOPostLink";
+ case ThinOrFullLTOPhase::FullLTOPreLink:
+ return "FullLTOPreLink";
+ case ThinOrFullLTOPhase::FullLTOPostLink:
+ return "FullLTOPostLink";
+ }
+ llvm_unreachable("invalid phase");
+}
+#endif
More information about the llvm-commits
mailing list