[llvm] 3e6e096 - [llvm-exegesis] Fix builds due to relanding #76368
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 29 16:40:22 PST 2023
Author: Aiden Grossman
Date: 2023-12-29T16:33:26-08:00
New Revision: 3e6e09609d8cef3c7cc99ced1a043869c8e984b8
URL: https://github.com/llvm/llvm-project/commit/3e6e09609d8cef3c7cc99ced1a043869c8e984b8
DIFF: https://github.com/llvm/llvm-project/commit/3e6e09609d8cef3c7cc99ced1a043869c8e984b8.diff
LOG: [llvm-exegesis] Fix builds due to relanding #76368
Relanding this patch broke some builds (including Windows) due to
certain functions not being guarded by appropriate preprocessor
directives, particularly the loadImmediateSegmentRegister function not
having most of its functionality only enabled on Linux. The previous
relanding addressed issues with headers not being available on
non-x86_64 linux, but neglected to fix issues with the header not being
included, but the function still trying to use it on certain platforms,
such as x86-64 windows.
Added:
Modified:
llvm/tools/llvm-exegesis/lib/X86/Target.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-exegesis/lib/X86/Target.cpp b/llvm/tools/llvm-exegesis/lib/X86/Target.cpp
index 537417c7a0796e..4a9e4f52637876 100644
--- a/llvm/tools/llvm-exegesis/lib/X86/Target.cpp
+++ b/llvm/tools/llvm-exegesis/lib/X86/Target.cpp
@@ -929,6 +929,9 @@ void generateSyscall(long SyscallNumber, std::vector<MCInst> &GeneratedCode) {
constexpr std::array<unsigned, 6> SyscallArgumentRegisters{
X86::RDI, X86::RSI, X86::RDX, X86::R10, X86::R8, X86::R9};
+// The functions below for saving and restoring system call registers are only
+// used when llvm-exegesis is built on Linux.
+#ifdef __linux__
static void saveSyscallRegisters(std::vector<MCInst> &GeneratedCode,
unsigned ArgumentCount) {
assert(ArgumentCount <= 6 &&
@@ -956,10 +959,11 @@ static void restoreSyscallRegisters(std::vector<MCInst> &GeneratedCode,
generateRegisterStackPop(X86::R11, GeneratedCode);
generateRegisterStackPop(X86::RCX, GeneratedCode);
}
+#endif // __linux__
static std::vector<MCInst> loadImmediateSegmentRegister(unsigned Reg,
const APInt &Value) {
-#ifdef __x86_64__
+#if defined(__x86_64__) and defined(__linux__)
assert(Value.getBitWidth() <= 64 && "Value must fit in the register.");
std::vector<MCInst> loadSegmentRegisterCode;
// Preserve the syscall registers here as we don't
@@ -986,7 +990,7 @@ static std::vector<MCInst> loadImmediateSegmentRegister(unsigned Reg,
#else
llvm_unreachable("Loading immediate segment registers is only supported with "
"x86-64 llvm-exegesis");
-#endif
+#endif // defined(__x86_64__) and defined(__linux__)
}
std::vector<MCInst> ExegesisX86Target::setRegTo(const MCSubtargetInfo &STI,
More information about the llvm-commits
mailing list