Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
[llvm-exegesis] Fix builds due to relanding #76368
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
boomanaiden154 committed Dec 30, 2023
1 parent 5cc7402 commit 3e6e096
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions llvm/tools/llvm-exegesis/lib/X86/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 3e6e096

Please sign in to comment.