[llvm] [NFC][Bitcode] Remove unused param in DataLayoutCallbackTy (PR #66705)

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 18 14:50:03 PDT 2023


https://github.com/aeubanks created https://github.com/llvm/llvm-project/pull/66705

None

>From 7f8c318737420224f362b8aa301c4d7c1bff0045 Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks at google.com>
Date: Mon, 18 Sep 2023 14:49:11 -0700
Subject: [PATCH] [NFC][Bitcode] Remove unused param in DataLayoutCallbackTy

---
 llvm/include/llvm/AsmParser/LLParser.h          |  6 ++----
 llvm/include/llvm/AsmParser/Parser.h            |  8 ++++----
 llvm/include/llvm/Bitcode/BitcodeReader.h       |  2 +-
 llvm/include/llvm/CodeGen/MIRParser/MIRParser.h |  7 ++++---
 llvm/lib/AsmParser/LLParser.cpp                 |  3 +--
 llvm/lib/AsmParser/Parser.cpp                   |  9 ++++-----
 llvm/lib/Bitcode/Reader/BitcodeReader.cpp       |  4 ++--
 llvm/lib/CodeGen/MIRParser/MIRParser.cpp        |  6 ++----
 llvm/lib/IRReader/IRReader.cpp                  |  6 +++---
 llvm/tools/llc/llc.cpp                          |  4 ++--
 llvm/tools/llvm-as/llvm-as.cpp                  |  2 +-
 llvm/tools/llvm-reduce/ReducerWorkItem.cpp      |  4 ++--
 llvm/tools/opt/opt.cpp                          |  2 +-
 llvm/unittests/AsmParser/AsmParserTest.cpp      | 11 +++++------
 14 files changed, 34 insertions(+), 40 deletions(-)

diff --git a/llvm/include/llvm/AsmParser/LLParser.h b/llvm/include/llvm/AsmParser/LLParser.h
index eca908a24aac7b2..382252a2dc4f177 100644
--- a/llvm/include/llvm/AsmParser/LLParser.h
+++ b/llvm/include/llvm/AsmParser/LLParser.h
@@ -179,10 +179,8 @@ namespace llvm {
           Lex(F, SM, Err, Context), M(M), Index(Index), Slots(Slots),
           BlockAddressPFS(nullptr) {}
     bool Run(
-        bool UpgradeDebugInfo,
-        DataLayoutCallbackTy DataLayoutCallback = [](StringRef, StringRef) {
-          return std::nullopt;
-        });
+        bool UpgradeDebugInfo, DataLayoutCallbackTy DataLayoutCallback =
+                                   [](StringRef) { return std::nullopt; });
 
     bool parseStandaloneConstantValue(Constant *&C, const SlotMapping *Slots);
 
diff --git a/llvm/include/llvm/AsmParser/Parser.h b/llvm/include/llvm/AsmParser/Parser.h
index b3adfd7fd76cfb4..bb259111d63192b 100644
--- a/llvm/include/llvm/AsmParser/Parser.h
+++ b/llvm/include/llvm/AsmParser/Parser.h
@@ -29,7 +29,7 @@ struct SlotMapping;
 class SMDiagnostic;
 class Type;
 
-typedef llvm::function_ref<std::optional<std::string>(StringRef, StringRef)>
+typedef llvm::function_ref<std::optional<std::string>(StringRef)>
     DataLayoutCallbackTy;
 
 /// This function is a main interface to the LLVM Assembly Parser. It parses
@@ -86,7 +86,7 @@ struct ParsedModuleAndIndex {
 ParsedModuleAndIndex parseAssemblyFileWithIndex(
     StringRef Filename, SMDiagnostic &Err, LLVMContext &Context,
     SlotMapping *Slots = nullptr,
-    DataLayoutCallbackTy DataLayoutCallback = [](StringRef, StringRef) {
+    DataLayoutCallbackTy DataLayoutCallback = [](StringRef) {
       return std::nullopt;
     });
 
@@ -127,7 +127,7 @@ parseSummaryIndexAssemblyString(StringRef AsmString, SMDiagnostic &Err);
 std::unique_ptr<Module> parseAssembly(
     MemoryBufferRef F, SMDiagnostic &Err, LLVMContext &Context,
     SlotMapping *Slots = nullptr,
-    DataLayoutCallbackTy DataLayoutCallback = [](StringRef, StringRef) {
+    DataLayoutCallbackTy DataLayoutCallback = [](StringRef) {
       return std::nullopt;
     });
 
@@ -169,7 +169,7 @@ parseSummaryIndexAssembly(MemoryBufferRef F, SMDiagnostic &Err);
 bool parseAssemblyInto(
     MemoryBufferRef F, Module *M, ModuleSummaryIndex *Index, SMDiagnostic &Err,
     SlotMapping *Slots = nullptr,
-    DataLayoutCallbackTy DataLayoutCallback = [](StringRef, StringRef) {
+    DataLayoutCallbackTy DataLayoutCallback = [](StringRef) {
       return std::nullopt;
     });
 
diff --git a/llvm/include/llvm/Bitcode/BitcodeReader.h b/llvm/include/llvm/Bitcode/BitcodeReader.h
index f204060a3a97871..5b140cb86be570d 100644
--- a/llvm/include/llvm/Bitcode/BitcodeReader.h
+++ b/llvm/include/llvm/Bitcode/BitcodeReader.h
@@ -41,7 +41,7 @@ class Value;
 // The first argument is the target triple, the second argument the data layout
 // string from the input, or a default string. It will be used if the callback
 // returns std::nullopt.
-typedef std::function<std::optional<std::string>(StringRef, StringRef)>
+typedef std::function<std::optional<std::string>(StringRef)>
     DataLayoutCallbackFuncTy;
 
 typedef std::function<Type *(unsigned)> GetTypeByIDTy;
diff --git a/llvm/include/llvm/CodeGen/MIRParser/MIRParser.h b/llvm/include/llvm/CodeGen/MIRParser/MIRParser.h
index e1606e7c0ea72d9..1f94f7722602a59 100644
--- a/llvm/include/llvm/CodeGen/MIRParser/MIRParser.h
+++ b/llvm/include/llvm/CodeGen/MIRParser/MIRParser.h
@@ -34,7 +34,7 @@ class MachineModuleInfo;
 class SMDiagnostic;
 class StringRef;
 
-typedef llvm::function_ref<std::optional<std::string>(StringRef, StringRef)>
+typedef llvm::function_ref<std::optional<std::string>(StringRef)>
     DataLayoutCallbackTy;
 
 /// This class initializes machine functions by applying the state loaded from
@@ -52,8 +52,9 @@ class MIRParser {
   /// A new, empty module is created if the LLVM IR isn't present.
   /// \returns nullptr if a parsing error occurred.
   std::unique_ptr<Module>
-  parseIRModule(DataLayoutCallbackTy DataLayoutCallback =
-                    [](StringRef, StringRef) { return std::nullopt; });
+  parseIRModule(DataLayoutCallbackTy DataLayoutCallback = [](StringRef) {
+    return std::nullopt;
+  });
 
   /// Parses MachineFunctions in the MIR file and add them to the given
   /// MachineModuleInfo \p MMI.
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index f1f0cdf746ee12a..2f0ca326671bdd6 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -353,8 +353,7 @@ bool LLParser::parseTargetDefinitions(DataLayoutCallbackTy DataLayoutCallback) {
   }
   // Run the override callback to potentially change the data layout string, and
   // parse the data layout string.
-  if (auto LayoutOverride =
-          DataLayoutCallback(M->getTargetTriple(), TentativeDLStr)) {
+  if (auto LayoutOverride = DataLayoutCallback(M->getTargetTriple())) {
     TentativeDLStr = *LayoutOverride;
     DLStrLoc = {};
   }
diff --git a/llvm/lib/AsmParser/Parser.cpp b/llvm/lib/AsmParser/Parser.cpp
index eded892f358a895..887c1fcffd9688f 100644
--- a/llvm/lib/AsmParser/Parser.cpp
+++ b/llvm/lib/AsmParser/Parser.cpp
@@ -91,10 +91,9 @@ ParsedModuleAndIndex llvm::parseAssemblyWithIndex(MemoryBufferRef F,
                                                   SMDiagnostic &Err,
                                                   LLVMContext &Context,
                                                   SlotMapping *Slots) {
-  return ::parseAssemblyWithIndex(
-      F, Err, Context, Slots,
-      /*UpgradeDebugInfo*/ true,
-      [](StringRef, StringRef) { return std::nullopt; });
+  return ::parseAssemblyWithIndex(F, Err, Context, Slots,
+                                  /*UpgradeDebugInfo*/ true,
+                                  [](StringRef) { return std::nullopt; });
 }
 
 static ParsedModuleAndIndex
@@ -151,7 +150,7 @@ static bool parseSummaryIndexAssemblyInto(MemoryBufferRef F,
   // index, but we need to initialize it.
   LLVMContext unusedContext;
   return LLParser(F.getBuffer(), SM, Err, nullptr, &Index, unusedContext)
-      .Run(true, [](StringRef, StringRef) { return std::nullopt; });
+      .Run(true, [](StringRef) { return std::nullopt; });
 }
 
 std::unique_ptr<ModuleSummaryIndex>
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 1d1ec988a93d847..04dd3749cd9d86c 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -4214,8 +4214,8 @@ Error BitcodeReader::parseModule(uint64_t ResumeBit,
 
     // Apply override
     if (Callbacks.DataLayout) {
-      if (auto LayoutOverride = (*Callbacks.DataLayout)(
-              TheModule->getTargetTriple(), TentativeDataLayoutStr))
+      if (auto LayoutOverride =
+              (*Callbacks.DataLayout)(TheModule->getTargetTriple()))
         TentativeDataLayoutStr = *LayoutOverride;
     }
 
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index b2e570c5e67ec7b..0be3ae6835dc820 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -244,8 +244,7 @@ MIRParserImpl::parseIRModule(DataLayoutCallbackTy DataLayoutCallback) {
     // Create an empty module when the MIR file is empty.
     NoMIRDocuments = true;
     auto M = std::make_unique<Module>(Filename, Context);
-    if (auto LayoutOverride =
-            DataLayoutCallback(M->getTargetTriple(), M->getDataLayoutStr()))
+    if (auto LayoutOverride = DataLayoutCallback(M->getTargetTriple()))
       M->setDataLayout(*LayoutOverride);
     return M;
   }
@@ -268,8 +267,7 @@ MIRParserImpl::parseIRModule(DataLayoutCallbackTy DataLayoutCallback) {
   } else {
     // Create an new, empty module.
     M = std::make_unique<Module>(Filename, Context);
-    if (auto LayoutOverride =
-            DataLayoutCallback(M->getTargetTriple(), M->getDataLayoutStr()))
+    if (auto LayoutOverride = DataLayoutCallback(M->getTargetTriple()))
       M->setDataLayout(*LayoutOverride);
     NoLLVMIR = true;
   }
diff --git a/llvm/lib/IRReader/IRReader.cpp b/llvm/lib/IRReader/IRReader.cpp
index 7885c36a79876a7..43f9ad20d803fd2 100644
--- a/llvm/lib/IRReader/IRReader.cpp
+++ b/llvm/lib/IRReader/IRReader.cpp
@@ -86,9 +86,9 @@ std::unique_ptr<Module> llvm::parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err,
     return std::move(ModuleOrErr.get());
   }
 
-  return parseAssembly(Buffer, Err, Context, nullptr,
-                       Callbacks.DataLayout.value_or(
-                           [](StringRef, StringRef) { return std::nullopt; }));
+  return parseAssembly(
+      Buffer, Err, Context, nullptr,
+      Callbacks.DataLayout.value_or([](StringRef) { return std::nullopt; }));
 }
 
 std::unique_ptr<Module> llvm::parseIRFile(StringRef Filename, SMDiagnostic &Err,
diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index 0ca06cda20b6e66..4760f359352d7bf 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -540,8 +540,8 @@ static int compileModule(char **argv, LLVMContext &Context) {
 
   // If user just wants to list available options, skip module loading
   if (!SkipModule) {
-    auto SetDataLayout = [&](StringRef DataLayoutTargetTriple,
-                             StringRef OldDLStr) -> std::optional<std::string> {
+    auto SetDataLayout =
+        [&](StringRef DataLayoutTargetTriple) -> std::optional<std::string> {
       // If we are supposed to override the target triple, do so now.
       std::string IRTargetTriple = DataLayoutTargetTriple.str();
       if (!TargetTriple.empty())
diff --git a/llvm/tools/llvm-as/llvm-as.cpp b/llvm/tools/llvm-as/llvm-as.cpp
index ef1c50fc2284ece..e6d4780569c310e 100644
--- a/llvm/tools/llvm-as/llvm-as.cpp
+++ b/llvm/tools/llvm-as/llvm-as.cpp
@@ -121,7 +121,7 @@ int main(int argc, char **argv) {
 
   // Parse the file now...
   SMDiagnostic Err;
-  auto SetDataLayout = [](StringRef, StringRef) -> std::optional<std::string> {
+  auto SetDataLayout = [](StringRef) -> std::optional<std::string> {
     if (ClDataLayout.empty())
       return std::nullopt;
     return ClDataLayout;
diff --git a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
index c377fe557cb1692..e2975426d338676 100644
--- a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
+++ b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
@@ -762,8 +762,8 @@ llvm::parseReducerWorkItem(StringRef ToolName, StringRef Filename,
     std::unique_ptr<MIRParser> MParser =
         createMIRParser(std::move(FileOrErr.get()), Ctxt);
 
-    auto SetDataLayout = [&](StringRef DataLayoutTargetTriple,
-                             StringRef OldDLStr) -> std::optional<std::string> {
+    auto SetDataLayout =
+        [&](StringRef DataLayoutTargetTriple) -> std::optional<std::string> {
       // If we are supposed to override the target triple, do so now.
       std::string IRTargetTriple = DataLayoutTargetTriple.str();
       if (!TargetTriple.empty())
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index 9c61fd1f13593c3..28a7f881be6e589 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -520,7 +520,7 @@ int main(int argc, char **argv) {
   std::unique_ptr<ToolOutputFile> RemarksFile = std::move(*RemarksFileOrErr);
 
   // Load the input module...
-  auto SetDataLayout = [](StringRef, StringRef) -> std::optional<std::string> {
+  auto SetDataLayout = [](StringRef) -> std::optional<std::string> {
     if (ClDataLayout.empty())
       return std::nullopt;
     return ClDataLayout;
diff --git a/llvm/unittests/AsmParser/AsmParserTest.cpp b/llvm/unittests/AsmParser/AsmParserTest.cpp
index 77dba5bfd4cae85..c8ef8bb17c4bc7d 100644
--- a/llvm/unittests/AsmParser/AsmParserTest.cpp
+++ b/llvm/unittests/AsmParser/AsmParserTest.cpp
@@ -401,12 +401,11 @@ TEST(AsmParserTest, InvalidDataLayoutStringCallback) {
   // that fixing the DL str from the callback works,
   // and that the resulting module has the correct DL.
   SlotMapping Mapping2;
-  auto Mod2 = parseAssembly(
-      SourceBuffer, Error, Ctx, &Mapping2,
-      [&](StringRef Triple, StringRef DLStr) -> std::optional<std::string> {
-        EXPECT_EQ(DLStr, InvalidDLStr);
-        return std::string{FixedDLStr};
-      });
+  auto Mod2 =
+      parseAssembly(SourceBuffer, Error, Ctx, &Mapping2,
+                    [&](StringRef Triple) -> std::optional<std::string> {
+                      return std::string{FixedDLStr};
+                    });
   ASSERT_TRUE(Mod2 != nullptr);
   EXPECT_EQ(Mod2->getDataLayout(), FixedDL);
 }



More information about the llvm-commits mailing list