Skip to content

[LTO] Turn ImportMapTy into a proper class (NFC) #105748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

kazutakahirata
Copy link
Contributor

This patch turns type alias ImportMapTy into a proper class to provide
a more intuitive interface like:

ImportList.addDefinition(...)

as opposed to:

FunctionImporter::addDefinition(ImportList, ...)

Also, this patch requires all non-const accesses to go through
addDefinition, maybeAddDeclaration, and addGUID while providing const
accesses via:

const ImportMapTyImpl &getImportMap() const { return ImportMap; }

I realize ImportMapTy may not be the best name as a class (maybe OK as
a type alias). I am not renaming ImportMapTy in this patch at least
because there are 47 mentions of ImportMapTy under llvm/.

This patch turns type alias ImportMapTy into a proper class to provide
a more intuitive interface like:

  ImportList.addDefinition(...)

as opposed to:

  FunctionImporter::addDefinition(ImportList, ...)

Also, this patch requires all non-const accesses to go through
addDefinition, maybeAddDeclaration, and addGUID while providing const
accesses via:

  const ImportMapTyImpl &getImportMap() const { return ImportMap; }

I realize ImportMapTy may not be the best name as a class (maybe OK as
a type alias).  I am not renaming ImportMapTy in this patch at least
because there are 47 mentions of ImportMapTy under llvm/.
@llvmbot llvmbot added LTO Link time optimization (regular/full LTO or ThinLTO) llvm:transforms labels Aug 22, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 22, 2024

@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-lto

Author: Kazu Hirata (kazutakahirata)

Changes

This patch turns type alias ImportMapTy into a proper class to provide
a more intuitive interface like:

ImportList.addDefinition(...)

as opposed to:

FunctionImporter::addDefinition(ImportList, ...)

Also, this patch requires all non-const accesses to go through
addDefinition, maybeAddDeclaration, and addGUID while providing const
accesses via:

const ImportMapTyImpl &getImportMap() const { return ImportMap; }

I realize ImportMapTy may not be the best name as a class (maybe OK as
a type alias). I am not renaming ImportMapTy in this patch at least
because there are 47 mentions of ImportMapTy under llvm/.


Full diff: https://github.com/llvm/llvm-project/pull/105748.diff

5 Files Affected:

  • (modified) llvm/include/llvm/Transforms/IPO/FunctionImport.h (+33-28)
  • (modified) llvm/lib/LTO/LTO.cpp (+5-4)
  • (modified) llvm/lib/LTO/LTOBackend.cpp (+1-2)
  • (modified) llvm/lib/Transforms/IPO/FunctionImport.cpp (+28-32)
  • (modified) llvm/tools/llvm-link/llvm-link.cpp (+2-3)
diff --git a/llvm/include/llvm/Transforms/IPO/FunctionImport.h b/llvm/include/llvm/Transforms/IPO/FunctionImport.h
index 5ab8c6d130b60a..d777d0310d4123 100644
--- a/llvm/include/llvm/Transforms/IPO/FunctionImport.h
+++ b/llvm/include/llvm/Transforms/IPO/FunctionImport.h
@@ -102,7 +102,39 @@ class FunctionImporter {
   /// elsewhere, typically by the in-memory ModuleSummaryIndex the importing
   /// decisions are made from (the module path for each summary is owned by the
   /// index's module path string table).
-  using ImportMapTy = DenseMap<StringRef, FunctionsToImportTy>;
+  class ImportMapTy {
+  public:
+    using ImportMapTyImpl = DenseMap<StringRef, FunctionsToImportTy>;
+
+    enum class AddDefinitionStatus {
+      NoChange,
+      Inserted,
+      ChangedToDefinition,
+    };
+
+    // Add the given GUID to ImportList as a definition.  If the same GUID has
+    // been added as a declaration previously, that entry is overridden.
+    AddDefinitionStatus addDefinition(StringRef FromModule,
+                                      GlobalValue::GUID GUID);
+
+    // Add the given GUID to ImportList as a declaration.  If the same GUID has
+    // been added as a definition previously, that entry takes precedence, and
+    // no change is made.
+    void maybeAddDeclaration(StringRef FromModule, GlobalValue::GUID GUID);
+
+    void addGUID(StringRef FromModule, GlobalValue::GUID GUID,
+                 GlobalValueSummary::ImportKind ImportKind) {
+      if (ImportKind == GlobalValueSummary::Definition)
+        addDefinition(FromModule, GUID);
+      else
+        maybeAddDeclaration(FromModule, GUID);
+    }
+
+    const ImportMapTyImpl &getImportMap() const { return ImportMap; }
+
+  private:
+    ImportMapTyImpl ImportMap;
+  };
 
   /// The set contains an entry for every global value that the module exports.
   /// Depending on the user context, this container is allowed to contain
@@ -122,33 +154,6 @@ class FunctionImporter {
   /// Import functions in Module \p M based on the supplied import list.
   Expected<bool> importFunctions(Module &M, const ImportMapTy &ImportList);
 
-  enum class AddDefinitionStatus {
-    NoChange,
-    Inserted,
-    ChangedToDefinition,
-  };
-
-  // Add the given GUID to ImportList as a definition.  If the same GUID has
-  // been added as a declaration previously, that entry is overridden.
-  static AddDefinitionStatus addDefinition(ImportMapTy &ImportList,
-                                           StringRef FromModule,
-                                           GlobalValue::GUID GUID);
-
-  // Add the given GUID to ImportList as a declaration.  If the same GUID has
-  // been added as a definition previously, that entry takes precedence, and no
-  // change is made.
-  static void maybeAddDeclaration(ImportMapTy &ImportList, StringRef FromModule,
-                                  GlobalValue::GUID GUID);
-
-  static void addGUID(ImportMapTy &ImportList, StringRef FromModule,
-                      GlobalValue::GUID GUID,
-                      GlobalValueSummary::ImportKind ImportKind) {
-    if (ImportKind == GlobalValueSummary::Definition)
-      addDefinition(ImportList, FromModule, GUID);
-    else
-      maybeAddDeclaration(ImportList, FromModule, GUID);
-  }
-
 private:
   /// The summaries index used to trigger importing.
   const ModuleSummaryIndex &Index;
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index e5545860c329d4..ee0193344d5ac9 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -177,7 +177,8 @@ std::string llvm::computeLTOCacheKey(
   // Include the hash for every module we import functions from. The set of
   // imported symbols for each module may affect code generation and is
   // sensitive to link order, so include that as well.
-  using ImportMapIteratorTy = FunctionImporter::ImportMapTy::const_iterator;
+  using ImportMapIteratorTy =
+      FunctionImporter::ImportMapTy::ImportMapTyImpl::const_iterator;
   struct ImportModule {
     ImportMapIteratorTy ModIt;
     const ModuleSummaryIndex::ModuleInfo *ModInfo;
@@ -191,10 +192,10 @@ std::string llvm::computeLTOCacheKey(
   };
 
   std::vector<ImportModule> ImportModulesVector;
-  ImportModulesVector.reserve(ImportList.size());
+  ImportModulesVector.reserve(ImportList.getImportMap().size());
 
-  for (ImportMapIteratorTy It = ImportList.begin(); It != ImportList.end();
-       ++It) {
+  for (ImportMapIteratorTy It = ImportList.getImportMap().begin();
+       It != ImportList.getImportMap().end(); ++It) {
     ImportModulesVector.push_back({It, Index.getModule(It->getFirst())});
   }
   // Order using module hash, to be both independent of module name and
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index ae46d946ae06a6..4e58cd369c3ac9 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -726,8 +726,7 @@ bool lto::initImportList(const Module &M,
       if (Summary->modulePath() == M.getModuleIdentifier())
         continue;
       // Add an entry to provoke importing by thinBackend.
-      FunctionImporter::addGUID(ImportList, Summary->modulePath(), GUID,
-                                Summary->importType());
+      ImportList.addGUID(Summary->modulePath(), GUID, Summary->importType());
     }
   }
   return true;
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp
index 55803670071d16..b26c15b665b590 100644
--- a/llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -334,11 +334,11 @@ using EdgeInfo = std::tuple<const FunctionSummary *, unsigned /* Threshold */>;
 
 } // anonymous namespace
 
-FunctionImporter::AddDefinitionStatus
-FunctionImporter::addDefinition(ImportMapTy &ImportList, StringRef FromModule,
-                                GlobalValue::GUID GUID) {
+FunctionImporter::ImportMapTy::AddDefinitionStatus
+FunctionImporter::ImportMapTy::addDefinition(StringRef FromModule,
+                                             GlobalValue::GUID GUID) {
   auto [It, Inserted] =
-      ImportList[FromModule].try_emplace(GUID, GlobalValueSummary::Definition);
+      ImportMap[FromModule].try_emplace(GUID, GlobalValueSummary::Definition);
   if (Inserted)
     return AddDefinitionStatus::Inserted;
   if (It->second == GlobalValueSummary::Definition)
@@ -347,10 +347,9 @@ FunctionImporter::addDefinition(ImportMapTy &ImportList, StringRef FromModule,
   return AddDefinitionStatus::ChangedToDefinition;
 }
 
-void FunctionImporter::maybeAddDeclaration(ImportMapTy &ImportList,
-                                           StringRef FromModule,
-                                           GlobalValue::GUID GUID) {
-  ImportList[FromModule].try_emplace(GUID, GlobalValueSummary::Declaration);
+void FunctionImporter::ImportMapTy::maybeAddDeclaration(
+    StringRef FromModule, GlobalValue::GUID GUID) {
+  ImportMap[FromModule].try_emplace(GUID, GlobalValueSummary::Declaration);
 }
 
 /// Import globals referenced by a function or other globals that are being
@@ -411,9 +410,8 @@ class GlobalsImporter final {
 
         // If there isn't an entry for GUID, insert <GUID, Definition> pair.
         // Otherwise, definition should take precedence over declaration.
-        if (FunctionImporter::addDefinition(
-                ImportList, RefSummary->modulePath(), VI.getGUID()) !=
-            FunctionImporter::AddDefinitionStatus::Inserted)
+        if (ImportList.addDefinition(RefSummary->modulePath(), VI.getGUID()) !=
+            FunctionImporter::ImportMapTy::AddDefinitionStatus::Inserted)
           break;
 
         // Only update stat and exports if we haven't already imported this
@@ -600,8 +598,7 @@ class WorkloadImportsManager : public ModuleImportsManager {
       LLVM_DEBUG(dbgs() << "[Workload][Including]" << VI.name() << " from "
                         << ExportingModule << " : "
                         << Function::getGUID(VI.name()) << "\n");
-      FunctionImporter::addDefinition(ImportList, ExportingModule,
-                                      VI.getGUID());
+      ImportList.addDefinition(ExportingModule, VI.getGUID());
       GVI.onImportingSummary(*GVS);
       if (ExportLists)
         (*ExportLists)[ExportingModule].insert(VI);
@@ -899,8 +896,7 @@ static void computeImportForFunction(
 
           // Note `ExportLists` only keeps track of exports due to imported
           // definitions.
-          FunctionImporter::maybeAddDeclaration(ImportList, DeclSourceModule,
-                                                VI.getGUID());
+          ImportList.maybeAddDeclaration(DeclSourceModule, VI.getGUID());
         }
         // Update with new larger threshold if this was a retry (otherwise
         // we would have already inserted with NewThreshold above). Also
@@ -949,9 +945,8 @@ static void computeImportForFunction(
 
       // Try emplace the definition entry, and update stats based on insertion
       // status.
-      if (FunctionImporter::addDefinition(ImportList, ExportModulePath,
-                                          VI.getGUID()) !=
-          FunctionImporter::AddDefinitionStatus::NoChange) {
+      if (ImportList.addDefinition(ExportModulePath, VI.getGUID()) !=
+          FunctionImporter::ImportMapTy::AddDefinitionStatus::NoChange) {
         NumImportedFunctionsThinLink++;
         if (IsHotCallsite)
           NumImportedHotFunctionsThinLink++;
@@ -1084,7 +1079,7 @@ numGlobalVarSummaries(const ModuleSummaryIndex &Index,
 // the number of defined function summaries as output parameter.
 static unsigned
 numGlobalVarSummaries(const ModuleSummaryIndex &Index,
-                      FunctionImporter::FunctionsToImportTy &ImportMap,
+                      const FunctionImporter::FunctionsToImportTy &ImportMap,
                       unsigned &DefinedFS) {
   unsigned NumGVS = 0;
   DefinedFS = 0;
@@ -1105,9 +1100,9 @@ static bool checkVariableImport(
     DenseMap<StringRef, FunctionImporter::ExportSetTy> &ExportLists) {
   DenseSet<GlobalValue::GUID> FlattenedImports;
 
-  for (auto &ImportPerModule : ImportLists)
-    for (auto &ExportPerModule : ImportPerModule.second)
-      for (auto &[GUID, Type] : ExportPerModule.second)
+  for (const auto &ImportPerModule : ImportLists)
+    for (const auto &ExportPerModule : ImportPerModule.second.getImportMap())
+      for (const auto &[GUID, Type] : ExportPerModule.second)
         FlattenedImports.insert(GUID);
 
   // Checks that all GUIDs of read/writeonly vars we see in export lists
@@ -1217,9 +1212,10 @@ void llvm::ComputeCrossModuleImport(
     unsigned NumGVS = numGlobalVarSummaries(Index, Exports);
     LLVM_DEBUG(dbgs() << "* Module " << ModName << " exports "
                       << Exports.size() - NumGVS << " functions and " << NumGVS
-                      << " vars. Imports from " << ModuleImports.second.size()
+                      << " vars. Imports from "
+                      << ModuleImports.second.getImportMap().size()
                       << " modules.\n");
-    for (auto &Src : ModuleImports.second) {
+    for (const auto &Src : ModuleImports.second.getImportMap()) {
       auto SrcModName = Src.first;
       unsigned DefinedFS = 0;
       unsigned NumGVSPerMod =
@@ -1240,8 +1236,8 @@ static void dumpImportListForModule(const ModuleSummaryIndex &Index,
                                     StringRef ModulePath,
                                     FunctionImporter::ImportMapTy &ImportList) {
   LLVM_DEBUG(dbgs() << "* Module " << ModulePath << " imports from "
-                    << ImportList.size() << " modules.\n");
-  for (auto &Src : ImportList) {
+                    << ImportList.getImportMap().size() << " modules.\n");
+  for (const auto &Src : ImportList.getImportMap()) {
     auto SrcModName = Src.first;
     unsigned DefinedFS = 0;
     unsigned NumGVSPerMod = numGlobalVarSummaries(Index, Src.second, DefinedFS);
@@ -1306,8 +1302,7 @@ static void ComputeCrossModuleImportForModuleFromIndexForTest(
     if (Summary->modulePath() == ModulePath)
       continue;
     // Add an entry to provoke importing by thinBackend.
-    FunctionImporter::addGUID(ImportList, Summary->modulePath(), GUID,
-                              Summary->importType());
+    ImportList.addGUID(Summary->modulePath(), GUID, Summary->importType());
   }
 #ifndef NDEBUG
   dumpImportListForModule(Index, ModulePath, ImportList);
@@ -1496,7 +1491,7 @@ void llvm::gatherImportedSummariesForModule(
   ModuleToSummariesForIndex[std::string(ModulePath)] =
       ModuleToDefinedGVSummaries.lookup(ModulePath);
   // Include summaries for imports.
-  for (const auto &ILI : ImportList) {
+  for (const auto &ILI : ImportList.getImportMap()) {
     auto &SummariesForIndex = ModuleToSummariesForIndex[std::string(ILI.first)];
 
     const auto &DefinedGVSummaries =
@@ -1777,7 +1772,7 @@ Expected<bool> FunctionImporter::importFunctions(
   IRMover Mover(DestModule);
   // Do the actual import of functions now, one Module at a time
   std::set<StringRef> ModuleNameOrderedList;
-  for (const auto &FunctionsToImportPerModule : ImportList) {
+  for (const auto &FunctionsToImportPerModule : ImportList.getImportMap()) {
     ModuleNameOrderedList.insert(FunctionsToImportPerModule.first);
   }
 
@@ -1792,8 +1787,9 @@ Expected<bool> FunctionImporter::importFunctions(
 
   for (const auto &Name : ModuleNameOrderedList) {
     // Get the module for the import
-    const auto &FunctionsToImportPerModule = ImportList.find(Name);
-    assert(FunctionsToImportPerModule != ImportList.end());
+    const auto &FunctionsToImportPerModule =
+        ImportList.getImportMap().find(Name);
+    assert(FunctionsToImportPerModule != ImportList.getImportMap().end());
     Expected<std::unique_ptr<Module>> SrcModuleOrErr = ModuleLoader(Name);
     if (!SrcModuleOrErr)
       return SrcModuleOrErr.takeError();
diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp
index ef6f85d38fede6..54d38a6ddd6f10 100644
--- a/llvm/tools/llvm-link/llvm-link.cpp
+++ b/llvm/tools/llvm-link/llvm-link.cpp
@@ -381,9 +381,8 @@ static bool importFunctions(const char *argv0, Module &DestModule) {
     // definition, so make the import type definition directly.
     // FIXME: A follow-up patch should add test coverage for import declaration
     // in `llvm-link` CLI (e.g., by introducing a new command line option).
-    FunctionImporter::addDefinition(
-        ImportList, FileNameStringCache.insert(FileName).first->getKey(),
-        F->getGUID());
+    ImportList.addDefinition(
+        FileNameStringCache.insert(FileName).first->getKey(), F->getGUID());
   }
   auto CachedModuleLoader = [&](StringRef Identifier) {
     return ModuleLoaderCache.takeModule(std::string(Identifier));

Copy link
Contributor

@mingmingl-llvm mingmingl-llvm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

// Add the given GUID to ImportList as a declaration. If the same GUID has
// been added as a definition previously, that entry takes precedence, and
// no change is made.
void maybeAddDeclaration(StringRef FromModule, GlobalValue::GUID GUID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: make these two private methods of class ImportMapTy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to keep addDefinition and maybeAddDeclaration public methods so that the intent is clear at the call sites.

@kazutakahirata kazutakahirata merged commit 3563907 into llvm:main Aug 23, 2024
5 of 8 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_thinlto_ImportMapTy branch August 23, 2024 04:56
@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 23, 2024

LLVM Buildbot has detected a new failure on builder sanitizer-aarch64-linux-fuzzer running on sanitizer-buildbot11 while building llvm at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/159/builds/4487

Here is the relevant piece of the build log for the reference:

Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
-- Configuring done (9.3s)
-- Generating done (0.1s)
CMake Warning:
  Manually-specified variables were not used by the project:

    LIBCXX_HAS_GCC_S_LIB


-- Build files have been written to: /home/b/sanitizer-aarch64-linux-fuzzer/build/llvm_build0/runtimes/runtimes-bins/compiler-rt/lib/fuzzer/libcxx_fuzzer_aarch64
[1889/1986] Building CXX object compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.aarch64.dir/ubsan_minimal_handlers.cpp.o
FAILED: compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.aarch64.dir/ubsan_minimal_handlers.cpp.o 
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm_build0/./bin/clang++ --target=aarch64-unknown-linux-gnu -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/compiler-rt/lib/ubsan_minimal/.. -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -Wno-unused-parameter -O3 -DNDEBUG -std=c++17 -march=armv8-a -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -ftrivial-auto-var-init=pattern -nostdinc++ -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS -fno-rtti -MD -MT compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.aarch64.dir/ubsan_minimal_handlers.cpp.o -MF compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.aarch64.dir/ubsan_minimal_handlers.cpp.o.d -o compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.aarch64.dir/ubsan_minimal_handlers.cpp.o -c /home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
fatal error: error in backend: Cannot select: 0xb1dd3d4405e0: v16i8 = insert_subvector 0xb1dd3d440260, 0xb1dd3d1efa70, Constant:i64<10>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
  0xb1dd3d440260: v16i8 = insert_subvector 0xb1dd3d1f03a0, 0xb1dd3d216700, Constant:i64<12>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
    0xb1dd3d1f03a0: v16i8 = insert_vector_elt 0xb1dd3d2167e0, 0xb1dd3d1ef6f0, Constant:i64<9>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
      0xb1dd3d2167e0: v16i8 = insert_vector_elt 0xb1dd3d1ed660, 0xb1dd3d1ed4a0, Constant:i64<8>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
        0xb1dd3d1ed660: v16i8 = insert_vector_elt 0xb1dd3d44a8a0, 0xb1dd3d44a600, Constant:i64<7>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
          0xb1dd3d44a8a0: v16i8 = insert_vector_elt 0xb1dd3d4452b0, 0xb1dd3d44a590, Constant:i64<6>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
            0xb1dd3d4452b0: v16i8 = insert_vector_elt 0xb1dd3d217500, 0xb1dd3d44a520, Constant:i64<5>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
              0xb1dd3d217500: v16i8 = insert_vector_elt 0xb1dd3d440ab0, 0xb1dd3d4433e0, Constant:i64<4>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
                0xb1dd3d440ab0: v16i8 = insert_vector_elt 0xb1dd3d44aad0, 0xb1dd3d445be0, Constant:i64<3>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
                  0xb1dd3d44aad0: v16i8 = insert_vector_elt 0xb1dd3d44aa60, 0xb1dd3d443680, Constant:i64<2>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16



                  0xb1dd3d445be0: i32 = extract_vector_elt 0xb1dd3d44a2f0, Constant:i64<1>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16


                  0xb1dd3d1efc30: i64 = Constant<3>
                0xb1dd3d4433e0: i32 = extract_vector_elt 0xb1dd3d44a360, Constant:i64<0>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
                  0xb1dd3d44a360: v8i16 = insert_subvector undef:v8i16, 0xb1dd3d443290, Constant:i64<0>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:59:23



                  0xb1dd3d1ed5f0: i64 = Constant<0>
                0xb1dd3d1edb30: i64 = Constant<4>
              0xb1dd3d44a520: i32 = extract_vector_elt 0xb1dd3d44a360, Constant:i64<1>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
                0xb1dd3d44a360: v8i16 = insert_subvector undef:v8i16, 0xb1dd3d443290, Constant:i64<0>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:59:23
                  0xb1dd3d44a830: v8i16 = undef
                  0xb1dd3d443290: v4i16 = and 0xb1dd3d4435a0, 0xb1dd3d2173b0, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:59:23


                  0xb1dd3d1ed5f0: i64 = Constant<0>
                0xb1dd3d217110: i64 = Constant<1>
              0xb1dd3d216a10: i64 = Constant<5>
            0xb1dd3d44a590: i32 = extract_vector_elt 0xb1dd3d44a360, Constant:i64<2>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
              0xb1dd3d44a360: v8i16 = insert_subvector undef:v8i16, 0xb1dd3d443290, Constant:i64<0>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:59:23
                0xb1dd3d44a830: v8i16 = undef
                0xb1dd3d443290: v4i16 = and 0xb1dd3d4435a0, 0xb1dd3d2173b0, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:59:23
Step 7 (stage1 build all) failure: stage1 build all (failure)
...
-- Performing Test CXX_SUPPORTS_FSIZED_DEALLOCATION_FLAG - Success
-- check-runtimes does nothing.
-- Configuring done (9.3s)
-- Generating done (0.1s)
CMake Warning:
  Manually-specified variables were not used by the project:

    LIBCXX_HAS_GCC_S_LIB
-- Build files have been written to: /home/b/sanitizer-aarch64-linux-fuzzer/build/llvm_build0/runtimes/runtimes-bins/compiler-rt/lib/fuzzer/libcxx_fuzzer_aarch64
[1889/1986] Building CXX object compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.aarch64.dir/ubsan_minimal_handlers.cpp.o
FAILED: compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.aarch64.dir/ubsan_minimal_handlers.cpp.o 
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm_build0/./bin/clang++ --target=aarch64-unknown-linux-gnu -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/compiler-rt/lib/ubsan_minimal/.. -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -Wno-unused-parameter -O3 -DNDEBUG -std=c++17 -march=armv8-a -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -ftrivial-auto-var-init=pattern -nostdinc++ -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS -fno-rtti -MD -MT compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.aarch64.dir/ubsan_minimal_handlers.cpp.o -MF compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.aarch64.dir/ubsan_minimal_handlers.cpp.o.d -o compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.aarch64.dir/ubsan_minimal_handlers.cpp.o -c /home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp
fatal error: error in backend: Cannot select: 0xb1dd3d4405e0: v16i8 = insert_subvector 0xb1dd3d440260, 0xb1dd3d1efa70, Constant:i64<10>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
  0xb1dd3d440260: v16i8 = insert_subvector 0xb1dd3d1f03a0, 0xb1dd3d216700, Constant:i64<12>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
    0xb1dd3d1f03a0: v16i8 = insert_vector_elt 0xb1dd3d2167e0, 0xb1dd3d1ef6f0, Constant:i64<9>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
      0xb1dd3d2167e0: v16i8 = insert_vector_elt 0xb1dd3d1ed660, 0xb1dd3d1ed4a0, Constant:i64<8>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
        0xb1dd3d1ed660: v16i8 = insert_vector_elt 0xb1dd3d44a8a0, 0xb1dd3d44a600, Constant:i64<7>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
          0xb1dd3d44a8a0: v16i8 = insert_vector_elt 0xb1dd3d4452b0, 0xb1dd3d44a590, Constant:i64<6>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
            0xb1dd3d4452b0: v16i8 = insert_vector_elt 0xb1dd3d217500, 0xb1dd3d44a520, Constant:i64<5>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
              0xb1dd3d217500: v16i8 = insert_vector_elt 0xb1dd3d440ab0, 0xb1dd3d4433e0, Constant:i64<4>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
                0xb1dd3d440ab0: v16i8 = insert_vector_elt 0xb1dd3d44aad0, 0xb1dd3d445be0, Constant:i64<3>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
                  0xb1dd3d44aad0: v16i8 = insert_vector_elt 0xb1dd3d44aa60, 0xb1dd3d443680, Constant:i64<2>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16



                  0xb1dd3d445be0: i32 = extract_vector_elt 0xb1dd3d44a2f0, Constant:i64<1>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16


                  0xb1dd3d1efc30: i64 = Constant<3>
                0xb1dd3d4433e0: i32 = extract_vector_elt 0xb1dd3d44a360, Constant:i64<0>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
                  0xb1dd3d44a360: v8i16 = insert_subvector undef:v8i16, 0xb1dd3d443290, Constant:i64<0>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:59:23



                  0xb1dd3d1ed5f0: i64 = Constant<0>
                0xb1dd3d1edb30: i64 = Constant<4>
              0xb1dd3d44a520: i32 = extract_vector_elt 0xb1dd3d44a360, Constant:i64<1>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
                0xb1dd3d44a360: v8i16 = insert_subvector undef:v8i16, 0xb1dd3d443290, Constant:i64<0>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:59:23
                  0xb1dd3d44a830: v8i16 = undef
                  0xb1dd3d443290: v4i16 = and 0xb1dd3d4435a0, 0xb1dd3d2173b0, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:59:23


                  0xb1dd3d1ed5f0: i64 = Constant<0>
                0xb1dd3d217110: i64 = Constant<1>
              0xb1dd3d216a10: i64 = Constant<5>
            0xb1dd3d44a590: i32 = extract_vector_elt 0xb1dd3d44a360, Constant:i64<2>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60:16
              0xb1dd3d44a360: v8i16 = insert_subvector undef:v8i16, 0xb1dd3d443290, Constant:i64<0>, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:59:23
                0xb1dd3d44a830: v8i16 = undef
                0xb1dd3d443290: v4i16 = and 0xb1dd3d4435a0, 0xb1dd3d2173b0, llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:59:23

cjdb pushed a commit to cjdb/llvm-project that referenced this pull request Aug 23, 2024
This patch turns type alias ImportMapTy into a proper class to provide
a more intuitive interface like:

  ImportList.addDefinition(...)

as opposed to:

  FunctionImporter::addDefinition(ImportList, ...)

Also, this patch requires all non-const accesses to go through
addDefinition, maybeAddDeclaration, and addGUID while providing const
accesses via:

  const ImportMapTyImpl &getImportMap() const { return ImportMap; }

I realize ImportMapTy may not be the best name as a class (maybe OK as
a type alias).  I am not renaming ImportMapTy in this patch at least
because there are 47 mentions of ImportMapTy under llvm/.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:transforms LTO Link time optimization (regular/full LTO or ThinLTO)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants