diff options
Diffstat (limited to 'llvm/tools/llvm-exegesis')
23 files changed, 70 insertions, 46 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp b/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp index 2c13dd5..0e73ada 100644 --- a/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp +++ b/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp @@ -112,7 +112,7 @@ namespace { // Use X19 as the loop counter register since it's a callee-saved register // that's available for temporary use. -constexpr const MCPhysReg kDefaultLoopCounterReg = AArch64::X19; +constexpr MCPhysReg kDefaultLoopCounterReg = AArch64::X19; class ExegesisAArch64Target : public ExegesisTarget { public: diff --git a/llvm/tools/llvm-exegesis/lib/Analysis.cpp b/llvm/tools/llvm-exegesis/lib/Analysis.cpp index fb84328..f3bf9690 100644 --- a/llvm/tools/llvm-exegesis/lib/Analysis.cpp +++ b/llvm/tools/llvm-exegesis/lib/Analysis.cpp @@ -446,7 +446,7 @@ void Analysis::printClusterRawHtml(const BenchmarkClustering::ClusterId &Id, } // namespace exegesis -static constexpr const char kHtmlHead[] = R"( +static constexpr char kHtmlHead[] = R"( <head> <title>llvm-exegesis Analysis Results</title> <style> diff --git a/llvm/tools/llvm-exegesis/lib/Assembler.cpp b/llvm/tools/llvm-exegesis/lib/Assembler.cpp index fd7924d..163f141 100644 --- a/llvm/tools/llvm-exegesis/lib/Assembler.cpp +++ b/llvm/tools/llvm-exegesis/lib/Assembler.cpp @@ -44,8 +44,8 @@ namespace llvm { namespace exegesis { -static constexpr const char ModuleID[] = "ExegesisInfoTest"; -static constexpr const char FunctionID[] = "foo"; +static constexpr char ModuleID[] = "ExegesisInfoTest"; +static constexpr char FunctionID[] = "foo"; static const Align kFunctionAlignment(4096); // Fills the given basic block with register setup code, and returns true if diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp index 1823a53..c6164b6 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp @@ -21,9 +21,9 @@ #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" -static constexpr const char kIntegerPrefix[] = "i_0x"; -static constexpr const char kDoublePrefix[] = "f_"; -static constexpr const char kInvalidOperand[] = "INVALID"; +static constexpr char kIntegerPrefix[] = "i_0x"; +static constexpr char kDoublePrefix[] = "f_"; +static constexpr char kInvalidOperand[] = "INVALID"; namespace llvm { @@ -202,7 +202,7 @@ struct CustomMappingTraits<std::map<exegesis::ValidationEvent, int64_t>> { Io.setError("Key is not a valid validation event"); return; } - Io.mapRequired(KeyStr.str().c_str(), VI[*Key]); + Io.mapRequired(KeyStr, VI[*Key]); } static void output(IO &Io, std::map<exegesis::ValidationEvent, int64_t> &VI) { @@ -245,8 +245,8 @@ template <> struct SequenceElementTraits<exegesis::RegisterValue> { }; template <> struct ScalarTraits<exegesis::RegisterValue> { - static constexpr const unsigned kRadix = 16; - static constexpr const bool kSigned = false; + static constexpr unsigned kRadix = 16; + static constexpr bool kSigned = false; static void output(const exegesis::RegisterValue &RV, void *Ctx, raw_ostream &Out) { diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp index 1fd0a15..a86be13 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp @@ -27,7 +27,6 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Program.h" #include "llvm/Support/Signals.h" -#include "llvm/Support/SystemZ/zOSSupport.h" #include <cmath> #include <memory> #include <string> @@ -155,7 +154,7 @@ private: #ifdef LLVM_ON_UNIX // See "Exit Status for Commands": // https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xcu_chap02.html - constexpr const int kSigOffset = 128; + constexpr int kSigOffset = 128; return make_error<SnippetSignal>(CRC.RetCode - kSigOffset); #else // The exit code of the process on windows is not meaningful as a @@ -877,7 +876,7 @@ Error BenchmarkRunner::getValidationCountersToRun( return Error::success(); } -BenchmarkRunner::FunctionExecutor::~FunctionExecutor() {} +BenchmarkRunner::FunctionExecutor::~FunctionExecutor() = default; } // namespace exegesis } // namespace llvm diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h index e688b81..16d3c9c 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h @@ -73,8 +73,8 @@ public: // Scratch space to run instructions that touch memory. struct ScratchSpace { - static constexpr const size_t kAlignment = 1024; - static constexpr const size_t kSize = 1 << 20; // 1MB. + static constexpr size_t kAlignment = 1024; + static constexpr size_t kSize = 1 << 20; // 1MB. ScratchSpace() : UnalignedPtr(std::make_unique<char[]>(kSize + kAlignment)), AlignedPtr( diff --git a/llvm/tools/llvm-exegesis/lib/Clustering.h b/llvm/tools/llvm-exegesis/lib/Clustering.h index 9d6c110..2b0f5b4 100644 --- a/llvm/tools/llvm-exegesis/lib/Clustering.h +++ b/llvm/tools/llvm-exegesis/lib/Clustering.h @@ -67,11 +67,11 @@ public: ClusterId(size_t Id, bool IsUnstable = false) : Id_(Id), IsUnstable_(IsUnstable) {} - static constexpr const size_t kMaxValid = + static constexpr size_t kMaxValid = (std::numeric_limits<size_t>::max() >> 1) - 4; - static constexpr const size_t kNoise = kMaxValid + 1; - static constexpr const size_t kError = kMaxValid + 2; - static constexpr const size_t kUndef = kMaxValid + 3; + static constexpr size_t kNoise = kMaxValid + 1; + static constexpr size_t kError = kMaxValid + 2; + static constexpr size_t kUndef = kMaxValid + 3; size_t Id_ : (std::numeric_limits<size_t>::digits - 1); size_t IsUnstable_ : 1; diff --git a/llvm/tools/llvm-exegesis/lib/Error.cpp b/llvm/tools/llvm-exegesis/lib/Error.cpp index 2908df2..9024ba5 100644 --- a/llvm/tools/llvm-exegesis/lib/Error.cpp +++ b/llvm/tools/llvm-exegesis/lib/Error.cpp @@ -10,7 +10,6 @@ #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX #ifdef LLVM_ON_UNIX -#include "llvm/Support/SystemZ/zOSSupport.h" #include <string.h> #endif // LLVM_ON_UNIX diff --git a/llvm/tools/llvm-exegesis/lib/Error.h b/llvm/tools/llvm-exegesis/lib/Error.h index 9b71fe8..c899023 100644 --- a/llvm/tools/llvm-exegesis/lib/Error.h +++ b/llvm/tools/llvm-exegesis/lib/Error.h @@ -81,7 +81,7 @@ private: struct PerfCounterNotFullyEnabled : public ErrorInfo<PerfCounterNotFullyEnabled> { static char ID; - PerfCounterNotFullyEnabled() {} + PerfCounterNotFullyEnabled() = default; void log(raw_ostream &OS) const override; diff --git a/llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp b/llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp index 66c770d..b544ae7 100644 --- a/llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp +++ b/llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp @@ -8,7 +8,6 @@ #include "MCInstrDescView.h" -#include <iterator> #include <tuple> #include "llvm/ADT/STLExtras.h" @@ -120,7 +119,7 @@ Instruction::create(const MCInstrInfo &InstrInfo, Operand.IsDef = (OpIndex < Description->getNumDefs()); Operand.IsEarlyClobber = (Description->getOperandConstraint(OpIndex, MCOI::EARLY_CLOBBER) != -1); - // TODO(gchatelet): Handle isLookupPtrRegClass. + // TODO(gchatelet): Handle LookupRegClassByHwMode. if (OpInfo.RegClass >= 0) Operand.Tracker = &RATC.getRegisterClass(OpInfo.RegClass); int TiedToIndex = Description->getOperandConstraint(OpIndex, MCOI::TIED_TO); diff --git a/llvm/tools/llvm-exegesis/lib/ParallelSnippetGenerator.cpp b/llvm/tools/llvm-exegesis/lib/ParallelSnippetGenerator.cpp index 79a585e..aa40913 100644 --- a/llvm/tools/llvm-exegesis/lib/ParallelSnippetGenerator.cpp +++ b/llvm/tools/llvm-exegesis/lib/ParallelSnippetGenerator.cpp @@ -350,7 +350,5 @@ ParallelSnippetGenerator::generateCodeTemplates( return Result; } -constexpr const size_t ParallelSnippetGenerator::kMinNumDifferentAddresses; - } // namespace exegesis } // namespace llvm diff --git a/llvm/tools/llvm-exegesis/lib/ParallelSnippetGenerator.h b/llvm/tools/llvm-exegesis/lib/ParallelSnippetGenerator.h index 8a6b856..d3c85c0 100644 --- a/llvm/tools/llvm-exegesis/lib/ParallelSnippetGenerator.h +++ b/llvm/tools/llvm-exegesis/lib/ParallelSnippetGenerator.h @@ -28,7 +28,7 @@ public: generateCodeTemplates(InstructionTemplate Variant, const BitVector &ForbiddenRegisters) const override; - static constexpr const size_t kMinNumDifferentAddresses = 6; + static constexpr size_t kMinNumDifferentAddresses = 6; private: // Instantiates memory operands within a snippet. diff --git a/llvm/tools/llvm-exegesis/lib/PerfHelper.h b/llvm/tools/llvm-exegesis/lib/PerfHelper.h index 4a825b2..744e3c2 100644 --- a/llvm/tools/llvm-exegesis/lib/PerfHelper.h +++ b/llvm/tools/llvm-exegesis/lib/PerfHelper.h @@ -21,7 +21,6 @@ #include <cstdint> #include <functional> -#include <memory> #ifdef _MSC_VER typedef int pid_t; diff --git a/llvm/tools/llvm-exegesis/lib/RISCV/Target.cpp b/llvm/tools/llvm-exegesis/lib/RISCV/Target.cpp index ea830bd..6eeb07f 100644 --- a/llvm/tools/llvm-exegesis/lib/RISCV/Target.cpp +++ b/llvm/tools/llvm-exegesis/lib/RISCV/Target.cpp @@ -819,6 +819,15 @@ void ExegesisRISCVTarget::fillMemoryOperands(InstructionTemplate &IT, assert(MemOp.isReg() && "Memory operand expected to be register"); + unsigned Opcode = I.getOpcode(); + if (Opcode == RISCV::C_LDSP || Opcode == RISCV::C_LWSP || + Opcode == RISCV::C_SDSP || Opcode == RISCV::C_SWSP) { + IT.getValueFor(I.Operands[0]) = MCOperand::createReg(RISCV::X2); + // Force base register to SP (X2) + IT.getValueFor(MemOp) = MCOperand::createReg(RISCV::X2); + return; + } + IT.getValueFor(MemOp) = MCOperand::createReg(Reg); } @@ -855,10 +864,17 @@ Error ExegesisRISCVTarget::randomizeTargetMCOperand( // 5-bit unsigned immediate value. AssignedValue = MCOperand::createImm(randomIndex(31)); break; + case RISCVOp::OPERAND_SIMM12_LO: + case RISCVOp::OPERAND_UIMM20_LUI: + case RISCVOp::OPERAND_UIMM20_AUIPC: + case RISCVOp::OPERAND_BARE_SIMM32: + AssignedValue = MCOperand::createImm(0); + break; default: if (OperandType >= RISCVOp::OPERAND_FIRST_RISCV_IMM && OperandType <= RISCVOp::OPERAND_LAST_RISCV_IMM) AssignedValue = MCOperand::createImm(0); + break; } return Error::success(); } diff --git a/llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp b/llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp index 707e6ee..71b2d71 100644 --- a/llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp +++ b/llvm/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp @@ -142,7 +142,12 @@ static void appendCodeTemplates(const LLVMState &State, return; ET.fillMemoryOperands(Variant, ScratchMemoryRegister, 0); - Variant.getValueFor(DefOp) = MCOperand::createReg(ScratchMemoryRegister); + + // Only force the def register to ScratchMemoryRegister if the target + // hasn't assigned a value yet. + MCOperand &DefVal = Variant.getValueFor(DefOp); + if (!DefVal.isValid()) + DefVal = MCOperand::createReg(ScratchMemoryRegister); CodeTemplate CT; CT.Execution = ExecutionModeBit; diff --git a/llvm/tools/llvm-exegesis/lib/SnippetGenerator.cpp b/llvm/tools/llvm-exegesis/lib/SnippetGenerator.cpp index 7023f1b..86d4e19 100644 --- a/llvm/tools/llvm-exegesis/lib/SnippetGenerator.cpp +++ b/llvm/tools/llvm-exegesis/lib/SnippetGenerator.cpp @@ -21,9 +21,17 @@ #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/Program.h" +#define DEBUG_TYPE "snippet-generator" + namespace llvm { namespace exegesis { +static cl::opt<unsigned> + RandomGeneratorSeed("random-generator-seed", + cl::desc("The seed value to use for the random number " + "generator when generating snippets."), + cl::init(0)); + std::vector<CodeTemplate> getSingleton(CodeTemplate &&CT) { std::vector<CodeTemplate> Result; Result.push_back(std::move(CT)); @@ -188,7 +196,11 @@ generateUnconstrainedCodeTemplates(const InstructionTemplate &Variant, std::mt19937 &randomGenerator() { static std::random_device RandomDevice; - static std::mt19937 RandomGenerator(RandomDevice()); + unsigned RandomSeed = RandomGeneratorSeed.getNumOccurrences() + ? RandomGeneratorSeed + : RandomDevice(); + LLVM_DEBUG(dbgs() << "Using random seed " << RandomSeed << ".\n"); + static std::mt19937 RandomGenerator(RandomSeed); return RandomGenerator; } diff --git a/llvm/tools/llvm-exegesis/lib/SnippetGenerator.h b/llvm/tools/llvm-exegesis/lib/SnippetGenerator.h index 770e4e8..1ef0beb 100644 --- a/llvm/tools/llvm-exegesis/lib/SnippetGenerator.h +++ b/llvm/tools/llvm-exegesis/lib/SnippetGenerator.h @@ -25,7 +25,6 @@ #include "llvm/MC/MCInst.h" #include "llvm/Support/Error.h" #include <cstdlib> -#include <memory> #include <vector> namespace llvm { diff --git a/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp b/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp index 80f5ce4..37dcc7c 100644 --- a/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp +++ b/llvm/tools/llvm-exegesis/lib/SnippetRepetitor.cpp @@ -131,7 +131,7 @@ private: } // namespace -SnippetRepetitor::~SnippetRepetitor() {} +SnippetRepetitor::~SnippetRepetitor() = default; std::unique_ptr<const SnippetRepetitor> SnippetRepetitor::Create(Benchmark::RepetitionModeE Mode, diff --git a/llvm/tools/llvm-exegesis/lib/SubprocessMemory.h b/llvm/tools/llvm-exegesis/lib/SubprocessMemory.h index 572d1085..52ee980 100644 --- a/llvm/tools/llvm-exegesis/lib/SubprocessMemory.h +++ b/llvm/tools/llvm-exegesis/lib/SubprocessMemory.h @@ -32,8 +32,8 @@ namespace exegesis { class SubprocessMemory { public: - static constexpr const size_t AuxiliaryMemoryOffset = 1; - static constexpr const size_t AuxiliaryMemorySize = 4096; + static constexpr size_t AuxiliaryMemoryOffset = 1; + static constexpr size_t AuxiliaryMemorySize = 4096; // Gets the thread ID for the calling thread. static long getCurrentTID(); diff --git a/llvm/tools/llvm-exegesis/lib/Target.cpp b/llvm/tools/llvm-exegesis/lib/Target.cpp index fc5f82f..2ad6c5a 100644 --- a/llvm/tools/llvm-exegesis/lib/Target.cpp +++ b/llvm/tools/llvm-exegesis/lib/Target.cpp @@ -23,7 +23,7 @@ cl::OptionCategory Options("llvm-exegesis options"); cl::OptionCategory BenchmarkOptions("llvm-exegesis benchmark options"); cl::OptionCategory AnalysisOptions("llvm-exegesis analysis options"); -ExegesisTarget::~ExegesisTarget() {} // anchor. +ExegesisTarget::~ExegesisTarget() = default; // anchor. static ExegesisTarget *FirstTarget = nullptr; @@ -215,7 +215,7 @@ const PfmCountersInfo &ExegesisTarget::getDummyPfmCounters() const { return PfmCountersInfo::Dummy; } -ExegesisTarget::SavedState::~SavedState() {} // anchor. +ExegesisTarget::SavedState::~SavedState() = default; // anchor. namespace { diff --git a/llvm/tools/llvm-exegesis/lib/UopsBenchmarkRunner.h b/llvm/tools/llvm-exegesis/lib/UopsBenchmarkRunner.h index ef47b7f..74a18da 100644 --- a/llvm/tools/llvm-exegesis/lib/UopsBenchmarkRunner.h +++ b/llvm/tools/llvm-exegesis/lib/UopsBenchmarkRunner.h @@ -30,7 +30,7 @@ public: ExecutionMode, ValCounters) {} ~UopsBenchmarkRunner() override; - static constexpr const size_t kMinNumDifferentAddresses = 6; + static constexpr size_t kMinNumDifferentAddresses = 6; private: Expected<std::vector<BenchmarkMeasure>> diff --git a/llvm/tools/llvm-exegesis/lib/X86/Target.cpp b/llvm/tools/llvm-exegesis/lib/X86/Target.cpp index b4437f7..3f2b911 100644 --- a/llvm/tools/llvm-exegesis/lib/X86/Target.cpp +++ b/llvm/tools/llvm-exegesis/lib/X86/Target.cpp @@ -28,7 +28,6 @@ #include "llvm/TargetParser/Host.h" #include <memory> -#include <string> #include <vector> #if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) && \ !defined(_M_ARM64EC) @@ -278,9 +277,9 @@ static Expected<std::vector<CodeTemplate>> generateLEATemplatesCommon( assert(X86II::getMemoryOperandNo(Instr.Description.TSFlags) == 1 && "invalid LEA"); - constexpr const int kDestOp = 0; - constexpr const int kBaseOp = 1; - constexpr const int kIndexOp = 3; + constexpr int kDestOp = 0; + constexpr int kBaseOp = 1; + constexpr int kIndexOp = 3; auto PossibleDestRegs = Instr.Operands[kDestOp].getRegisterAliasing().sourceBits(); remove(PossibleDestRegs, ForbiddenRegisters); @@ -548,7 +547,7 @@ private: void initStack(unsigned Bytes); - static constexpr const unsigned kF80Bytes = 10; // 80 bits. + static constexpr unsigned kF80Bytes = 10; // 80 bits. APInt Constant_; std::vector<MCInst> Instructions; @@ -864,13 +863,13 @@ const MCPhysReg ExegesisX86Target::kUnavailableRegistersSSE[12] = { // We're using one of R8-R15 because these registers are never hardcoded in // instructions (e.g. MOVS writes to EDI, ESI, EDX), so they have less // conflicts. -constexpr const MCPhysReg kDefaultLoopCounterReg = X86::R8; +constexpr MCPhysReg kDefaultLoopCounterReg = X86::R8; } // namespace void ExegesisX86Target::addTargetSpecificPasses(PassManagerBase &PM) const { // Lowers FP pseudo-instructions, e.g. ABS_Fp32 -> ABS_F. - PM.add(createX86FloatingPointStackifierPass()); + PM.add(createX86FPStackifierLegacyPass()); } MCRegister ExegesisX86Target::getScratchMemoryRegister(const Triple &TT) const { @@ -1110,9 +1109,9 @@ std::vector<MCInst> ExegesisX86Target::setRegTo(const MCSubtargetInfo &STI, #ifdef __linux__ #ifdef __arm__ -static constexpr const uintptr_t VAddressSpaceCeiling = 0xC0000000; +static constexpr uintptr_t VAddressSpaceCeiling = 0xC0000000; #else -static constexpr const uintptr_t VAddressSpaceCeiling = 0x0000800000000000; +static constexpr uintptr_t VAddressSpaceCeiling = 0x0000800000000000; #endif void generateRoundToNearestPage(unsigned int Register, diff --git a/llvm/tools/llvm-exegesis/lib/X86/X86Counter.cpp b/llvm/tools/llvm-exegesis/lib/X86/X86Counter.cpp index 05b6562..9dc6c76 100644 --- a/llvm/tools/llvm-exegesis/lib/X86/X86Counter.cpp +++ b/llvm/tools/llvm-exegesis/lib/X86/X86Counter.cpp @@ -27,7 +27,6 @@ #include <cstdint> #include <limits> #include <memory> -#include <vector> #include <poll.h> #include <sys/mman.h> |
