[llvm] 4942e78 - [llvm-exegesis] Only link/initialize supported targets (NFC) (#95421)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 14 00:39:19 PDT 2024
Author: Nikita Popov
Date: 2024-06-14T09:39:15+02:00
New Revision: 4942e78271e73d45e971196dc5a9769f94b30060
URL: https://github.com/llvm/llvm-project/commit/4942e78271e73d45e971196dc5a9769f94b30060
DIFF: https://github.com/llvm/llvm-project/commit/4942e78271e73d45e971196dc5a9769f94b30060.diff
LOG: [llvm-exegesis] Only link/initialize supported targets (NFC) (#95421)
llvm-exegesis currently links and initializes all targets, even though
most of them are not supported by llvm-exegesis. This is particularly
unfortunate because llvm-exegesis does not support the LLVM dylib, so
llvm-exegesis essentially ends up doing a complete relink of all of
LLVM, which is not fun if you use LTO.
Instead, only link and initialize the targets that are part of
LLVM_EXEGESIS_TARGETS.
Added:
Modified:
llvm/tools/llvm-exegesis/CMakeLists.txt
llvm/tools/llvm-exegesis/llvm-exegesis.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-exegesis/CMakeLists.txt b/llvm/tools/llvm-exegesis/CMakeLists.txt
index ec418a7d51ecc..c3c4058cf6525 100644
--- a/llvm/tools/llvm-exegesis/CMakeLists.txt
+++ b/llvm/tools/llvm-exegesis/CMakeLists.txt
@@ -1,9 +1,7 @@
+# Has side effect of defining LLVM_EXEGESIS_TARGETS
+add_subdirectory(lib)
+
set(LLVM_LINK_COMPONENTS
- AllTargetsAsmParsers
- AllTargetsCodeGens
- AllTargetsDescs
- AllTargetsDisassemblers
- AllTargetsInfos
CodeGenTypes
MC
MCParser
@@ -11,6 +9,15 @@ set(LLVM_LINK_COMPONENTS
TargetParser
)
+foreach(t ${LLVM_EXEGESIS_TARGETS})
+ string(STRIP ${t} t)
+ list(APPEND LLVM_LINK_COMPONTENTS "LLVM${t}AsmParser")
+ list(APPEND LLVM_LINK_COMPONTENTS "LLVM${t}CodeGen")
+ list(APPEND LLVM_LINK_COMPONTENTS "LLVM${t}Desc")
+ list(APPEND LLVM_LINK_COMPONTENTS "LLVM${t}Disassembler")
+ list(APPEND LLVM_LINK_COMPONTENTS "LLVM${t}Info")
+endforeach()
+
add_llvm_tool(llvm-exegesis
DISABLE_LLVM_LINK_LLVM_DYLIB
llvm-exegesis.cpp
@@ -19,9 +26,6 @@ add_llvm_tool(llvm-exegesis
intrinsics_gen
)
-# Has side effect of defining LLVM_EXEGESIS_TARGETS
-add_subdirectory(lib)
-
# Link all enabled exegesis targets
set(libs)
foreach(t ${LLVM_EXEGESIS_TARGETS})
diff --git a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
index 06e1c7f3c1bbe..e6a43cfc6db51 100644
--- a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
+++ b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp
@@ -470,9 +470,11 @@ void benchmarkMain() {
#endif
}
- InitializeAllAsmPrinters();
- InitializeAllAsmParsers();
InitializeAllExegesisTargets();
+#define LLVM_EXEGESIS(TargetName) \
+ LLVMInitialize##TargetName##AsmPrinter(); \
+ LLVMInitialize##TargetName##AsmParser();
+#include "llvm/Config/TargetExegesis.def"
const LLVMState State =
ExitOnErr(LLVMState::Create(TripleName, MCPU, "", UseDummyPerfCounters));
@@ -621,9 +623,11 @@ static void analysisMain() {
"and --analysis-inconsistencies-output-file must be specified");
}
- InitializeAllAsmPrinters();
- InitializeAllDisassemblers();
InitializeAllExegesisTargets();
+#define LLVM_EXEGESIS(TargetName) \
+ LLVMInitialize##TargetName##AsmPrinter(); \
+ LLVMInitialize##TargetName##Disassembler();
+#include "llvm/Config/TargetExegesis.def"
auto MemoryBuffer = ExitOnFileError(
BenchmarkFile,
@@ -690,9 +694,11 @@ int main(int Argc, char **Argv) {
InitLLVM X(Argc, Argv);
// Initialize targets so we can print them when flag --version is specified.
- InitializeAllTargetInfos();
- InitializeAllTargets();
- InitializeAllTargetMCs();
+#define LLVM_EXEGESIS(TargetName) \
+ LLVMInitialize##TargetName##Target(); \
+ LLVMInitialize##TargetName##TargetInfo(); \
+ LLVMInitialize##TargetName##TargetMC();
+#include "llvm/Config/TargetExegesis.def"
// Register the Target and CPU printer for --version.
cl::AddExtraVersionPrinter(sys::printDefaultTargetAndDetectedCPU);
More information about the llvm-commits
mailing list