Skip to content

[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

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions llvm/tools/llvm-exegesis/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
# Has side effect of defining LLVM_EXEGESIS_TARGETS
add_subdirectory(lib)

set(LLVM_LINK_COMPONENTS
AllTargetsAsmParsers
AllTargetsCodeGens
AllTargetsDescs
AllTargetsDisassemblers
AllTargetsInfos
CodeGenTypes
MC
MCParser
Support
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")
Comment on lines +14 to +18
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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!

endforeach()

add_llvm_tool(llvm-exegesis
DISABLE_LLVM_LINK_LLVM_DYLIB
llvm-exegesis.cpp
Expand All @@ -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})
Expand Down
20 changes: 13 additions & 7 deletions llvm/tools/llvm-exegesis/llvm-exegesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
Loading