-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm-exegesis] Only link/initialize supported targets (NFC) #95421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
@llvm/pr-subscribers-tools-llvm-exegesis Author: Nikita Popov (nikic) Changesllvm-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. Full diff: https://github.com/llvm/llvm-project/pull/95421.diff 2 Files Affected:
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..584b0608b635f 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);
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable enough to me.
Some buildbots, such as https://lab.llvm.org/buildbot/#/builders/130/builds/35, started failing after this change. |
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a typo here: LLVM_LINK_COMPONTENTS.
Maybe that's what is causing the link failure in some bots.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing that out. I've pushed 8ab3f8a, let's see if that fixes the buildbots.
I think the reason this worked in my testing is that the exegesis targets also depend on the umbrella codegen targets, so it works out okay if BUILD_SHARED_LIBS is not enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That fixed the buildbots, thanks!
) 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.
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.