Skip to content

Commit a25b662

Browse files
[NFC][llvm-exegesis] Remove redundant register initial values argument
This patch removes the redundant RegisterInitialValues parameter from assembleToStream and friends as it is included within the BenchmarkKey struct that is also passed to all the functions that need this information.
1 parent 3f2e670 commit a25b662

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

llvm/tools/llvm-exegesis/lib/Assembler.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ static const Align kFunctionAlignment(4096);
4949

5050
// Fills the given basic block with register setup code, and returns true if
5151
// all registers could be setup correctly.
52-
static bool generateSnippetSetupCode(
53-
const ExegesisTarget &ET, const MCSubtargetInfo *const MSI,
54-
ArrayRef<RegisterValue> RegisterInitialValues, BasicBlockFiller &BBF,
55-
const BenchmarkKey &Key, bool GenerateMemoryInstructions) {
52+
static bool generateSnippetSetupCode(const ExegesisTarget &ET,
53+
const MCSubtargetInfo *const MSI,
54+
BasicBlockFiller &BBF,
55+
const BenchmarkKey &Key,
56+
bool GenerateMemoryInstructions) {
5657
bool IsSnippetSetupComplete = true;
5758
if (GenerateMemoryInstructions) {
5859
BBF.addInstructions(ET.generateMemoryInitialSetup());
@@ -75,7 +76,7 @@ static bool generateSnippetSetupCode(
7576
Register StackPointerRegister = BBF.MF.getSubtarget()
7677
.getTargetLowering()
7778
->getStackPointerRegisterToSaveRestore();
78-
for (const RegisterValue &RV : RegisterInitialValues) {
79+
for (const RegisterValue &RV : Key.RegisterInitialValues) {
7980
if (GenerateMemoryInstructions) {
8081
// If we're generating memory instructions, don't load in the value for
8182
// the register with the stack pointer as it will be used later to finish
@@ -93,7 +94,7 @@ static bool generateSnippetSetupCode(
9394
#ifdef HAVE_LIBPFM
9495
BBF.addInstructions(ET.configurePerfCounter(PERF_EVENT_IOC_RESET, true));
9596
#endif // HAVE_LIBPFM
96-
for (const RegisterValue &RV : RegisterInitialValues) {
97+
for (const RegisterValue &RV : Key.RegisterInitialValues) {
9798
// Load in the stack register now as we're done using it elsewhere
9899
// and need to set the value in preparation for executing the
99100
// snippet.
@@ -242,10 +243,8 @@ BitVector getFunctionReservedRegs(const TargetMachine &TM) {
242243

243244
Error assembleToStream(const ExegesisTarget &ET,
244245
std::unique_ptr<LLVMTargetMachine> TM,
245-
ArrayRef<unsigned> LiveIns,
246-
ArrayRef<RegisterValue> RegisterInitialValues,
247-
const FillFunction &Fill, raw_pwrite_stream &AsmStream,
248-
const BenchmarkKey &Key,
246+
ArrayRef<unsigned> LiveIns, const FillFunction &Fill,
247+
raw_pwrite_stream &AsmStream, const BenchmarkKey &Key,
249248
bool GenerateMemoryInstructions) {
250249
auto Context = std::make_unique<LLVMContext>();
251250
std::unique_ptr<Module> Module =
@@ -275,7 +274,7 @@ Error assembleToStream(const ExegesisTarget &ET,
275274
}
276275

277276
std::vector<unsigned> RegistersSetUp;
278-
for (const auto &InitValue : RegisterInitialValues) {
277+
for (const auto &InitValue : Key.RegisterInitialValues) {
279278
RegistersSetUp.push_back(InitValue.Register);
280279
}
281280
FunctionFiller Sink(MF, std::move(RegistersSetUp));
@@ -294,8 +293,7 @@ Error assembleToStream(const ExegesisTarget &ET,
294293
}
295294

296295
const bool IsSnippetSetupComplete = generateSnippetSetupCode(
297-
ET, TM->getMCSubtargetInfo(), RegisterInitialValues, Entry, Key,
298-
GenerateMemoryInstructions);
296+
ET, TM->getMCSubtargetInfo(), Entry, Key, GenerateMemoryInstructions);
299297

300298
// If the snippet setup is not complete, we disable liveliness tracking. This
301299
// means that we won't know what values are in the registers.

llvm/tools/llvm-exegesis/lib/Assembler.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,8 @@ using FillFunction = std::function<void(FunctionFiller &)>;
9090
// AsmStream, the temporary function is eventually discarded.
9191
Error assembleToStream(const ExegesisTarget &ET,
9292
std::unique_ptr<LLVMTargetMachine> TM,
93-
ArrayRef<unsigned> LiveIns,
94-
ArrayRef<RegisterValue> RegisterInitialValues,
95-
const FillFunction &Fill, raw_pwrite_stream &AsmStreamm,
96-
const BenchmarkKey &Key,
93+
ArrayRef<unsigned> LiveIns, const FillFunction &Fill,
94+
raw_pwrite_stream &AsmStreamm, const BenchmarkKey &Key,
9795
bool GenerateMemoryInstructions);
9896

9997
// Creates an ObjectFile in the format understood by the host.

llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@ Expected<SmallString<0>> BenchmarkRunner::assembleSnippet(
484484
raw_svector_ostream OS(Buffer);
485485
if (Error E = assembleToStream(
486486
State.getExegesisTarget(), State.createTargetMachine(), BC.LiveIns,
487-
BC.Key.RegisterInitialValues,
488487
Repetitor.Repeat(Instructions, MinInstructions, LoopBodySize,
489488
GenerateMemoryInstructions),
490489
OS, BC.Key, GenerateMemoryInstructions)) {

llvm/unittests/tools/llvm-exegesis/Common/AssemblerUtils.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ class MachineFunctionGeneratorBaseTest : public ::testing::Test {
8181
BenchmarkKey Key;
8282
Key.RegisterInitialValues = RegisterInitialValues;
8383
EXPECT_FALSE(assembleToStream(*ET, createTargetMachine(), /*LiveIns=*/{},
84-
RegisterInitialValues, Fill, AsmStream, Key,
85-
false));
84+
Fill, AsmStream, Key, false));
8685
Expected<ExecutableFunction> ExecFunc = ExecutableFunction::create(
8786
createTargetMachine(), getObjectFromBuffer(AsmStream.str()));
8887

0 commit comments

Comments
 (0)