Skip to content

[IR] Lazily initialize the class to pass name mapping (NFC) #96321

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 1 commit into from
Jun 24, 2024

Conversation

nikic
Copy link
Contributor

@nikic nikic commented Jun 21, 2024

Initializing this map is somewhat expensive (especially for O0), so we currently only do it if certain flags are used. I would like to make use of it for crash dumps (#96078), where we don't know in advance whether it will be needed or not.

This patch changes the initialization to a lazy approach, where a callback is registered that does the actual initialization. The callbacks will be run the first time the pass name is requested.

This way there is no compile-time impact if the mapping is not used.

Initializing this map is somewhat expensive (especially for O0),
so we currently only do it if certain flags are used. I would
like to make use of it for crash dumps (llvm#96078), where I don't
know in advance whether it will be needed or not.

This patch changes the initialization to a lazy approach, where
a callback is registered that does the actual initialization.
The callbacks will be run the first time the pass name is requested.
@llvmbot
Copy link
Member

llvmbot commented Jun 21, 2024

@llvm/pr-subscribers-backend-amdgpu
@llvm/pr-subscribers-backend-x86
@llvm/pr-subscribers-backend-nvptx
@llvm/pr-subscribers-llvm-ir

@llvm/pr-subscribers-backend-aarch64

Author: Nikita Popov (nikic)

Changes

Initializing this map is somewhat expensive (especially for O0), so we currently only do it if certain flags are used. I would like to make use of it for crash dumps (#96078), where we don't know in advance whether it will be needed or not.

This patch changes the initialization to a lazy approach, where a callback is registered that does the actual initialization. The callbacks will be run the first time the pass name is requested.

This way there is no compile-time impact if the mapping is not used.


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

17 Files Affected:

  • (modified) llvm/include/llvm/IR/PassInstrumentation.h (+6)
  • (modified) llvm/include/llvm/Passes/TargetPassRegistry.inc (+4-3)
  • (modified) llvm/include/llvm/Target/TargetMachine.h (+1-2)
  • (modified) llvm/lib/IR/PassInstrumentation.cpp (+5)
  • (modified) llvm/lib/Passes/PassBuilder.cpp (+4-15)
  • (modified) llvm/lib/Target/AArch64/AArch64TargetMachine.cpp (+1-2)
  • (modified) llvm/lib/Target/AArch64/AArch64TargetMachine.h (+1-2)
  • (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp (+1-2)
  • (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h (+1-2)
  • (modified) llvm/lib/Target/BPF/BPFTargetMachine.cpp (+1-2)
  • (modified) llvm/lib/Target/BPF/BPFTargetMachine.h (+1-2)
  • (modified) llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp (+1-2)
  • (modified) llvm/lib/Target/Hexagon/HexagonTargetMachine.h (+1-2)
  • (modified) llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp (+1-2)
  • (modified) llvm/lib/Target/NVPTX/NVPTXTargetMachine.h (+1-2)
  • (modified) llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp (+1-2)
  • (modified) llvm/lib/Target/X86/X86TargetMachine.h (+1-2)
diff --git a/llvm/include/llvm/IR/PassInstrumentation.h b/llvm/include/llvm/IR/PassInstrumentation.h
index ff5e54427814d..f2eb8a95b7881 100644
--- a/llvm/include/llvm/IR/PassInstrumentation.h
+++ b/llvm/include/llvm/IR/PassInstrumentation.h
@@ -149,6 +149,11 @@ class PassInstrumentationCallbacks {
     AnalysesClearedCallbacks.emplace_back(std::move(C));
   }
 
+  template <typename CallableT>
+  void registerClassToPassNameCallback(CallableT C) {
+    ClassToPassNameCallbacks.emplace_back(std::move(C));
+  }
+
   /// Add a class name to pass name mapping for use by pass instrumentation.
   void addClassToPassName(StringRef ClassName, StringRef PassName);
   /// Get the pass name for a given pass class name.
@@ -185,6 +190,7 @@ class PassInstrumentationCallbacks {
   SmallVector<llvm::unique_function<AnalysesClearedFunc>, 4>
       AnalysesClearedCallbacks;
 
+  SmallVector<llvm::unique_function<void ()>, 4> ClassToPassNameCallbacks;
   DenseMap<StringRef, std::string> ClassToPassName;
 };
 
diff --git a/llvm/include/llvm/Passes/TargetPassRegistry.inc b/llvm/include/llvm/Passes/TargetPassRegistry.inc
index b618331c69988..aa5066920cb7c 100644
--- a/llvm/include/llvm/Passes/TargetPassRegistry.inc
+++ b/llvm/include/llvm/Passes/TargetPassRegistry.inc
@@ -21,9 +21,9 @@
 #error "must provide <Target>PassRegistry.def"
 #endif
 
-if (PopulateClassToPassNames) {
-  auto *PIC = PB.getPassInstrumentationCallbacks();
-
+auto *PIC = PB.getPassInstrumentationCallbacks();
+if (PIC) {
+  PIC->registerClassToPassNameCallback([PIC]() {
 #define ADD_CLASS_PASS_TO_PASS_NAME(NAME, CREATE_PASS)                         \
   PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
 #define ADD_CLASS_PASS_TO_PASS_NAME_WITH_PARAMS(NAME, CLASS)                   \
@@ -69,6 +69,7 @@ if (PopulateClassToPassNames) {
 #undef MACHINE_FUNCTION_PASS_WITH_PARAMS
 #undef ADD_CLASS_PASS_TO_PASS_NAME
 #undef ADD_CLASS_PASS_TO_PASS_NAME_WITH_PARAMS
+  });
 }
 
 #define ADD_PASS(NAME, CREATE_PASS)                                            \
diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h
index f09c3b2b347c5..b8e56c755fbda 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -369,8 +369,7 @@ class TargetMachine {
 
   /// Allow the target to modify the pass pipeline.
   // TODO: Populate all pass names by using <Target>PassRegistry.def.
-  virtual void registerPassBuilderCallbacks(PassBuilder &,
-                                            bool PopulateClassToPassNames) {}
+  virtual void registerPassBuilderCallbacks(PassBuilder &) {}
 
   /// Allow the target to register alias analyses with the AAManager for use
   /// with the new pass manager. Only affects the "default" AAManager.
diff --git a/llvm/lib/IR/PassInstrumentation.cpp b/llvm/lib/IR/PassInstrumentation.cpp
index 86c82a131fd2c..0c4e7698d9fa8 100644
--- a/llvm/lib/IR/PassInstrumentation.cpp
+++ b/llvm/lib/IR/PassInstrumentation.cpp
@@ -24,6 +24,11 @@ void PassInstrumentationCallbacks::addClassToPassName(StringRef ClassName,
 
 StringRef
 PassInstrumentationCallbacks::getPassNameForClassName(StringRef ClassName) {
+  if (!ClassToPassNameCallbacks.empty()) {
+    for (auto &Fn : ClassToPassNameCallbacks)
+      Fn();
+    ClassToPassNameCallbacks.clear();
+  }
   return ClassToPassName[ClassName];
 }
 
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index af83e2261a333..2c5f5bd82d3c3 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -324,18 +324,6 @@ AnalysisKey NoOpLoopAnalysis::Key;
 
 namespace {
 
-/// Whether or not we should populate a PassInstrumentationCallbacks's class to
-/// pass name map.
-///
-/// This is for optimization purposes so we don't populate it if we never use
-/// it. This should be updated if new pass instrumentation wants to use the map.
-/// We currently only use this for --print-before/after.
-bool shouldPopulateClassToPassNames() {
-  return PrintPipelinePasses || !printBeforePasses().empty() ||
-         !printAfterPasses().empty() || !isFilterPassesEmpty() ||
-         TargetPassConfig::hasLimitedCodeGenPipeline();
-}
-
 // A pass for testing -print-on-crash.
 // DO NOT USE THIS EXCEPT FOR TESTING!
 class TriggerCrashPass : public PassInfoMixin<TriggerCrashPass> {
@@ -414,10 +402,10 @@ PassBuilder::PassBuilder(TargetMachine *TM, PipelineTuningOptions PTO,
                          std::optional<PGOOptions> PGOOpt,
                          PassInstrumentationCallbacks *PIC)
     : TM(TM), PTO(PTO), PGOOpt(PGOOpt), PIC(PIC) {
-  bool ShouldPopulateClassToPassNames = PIC && shouldPopulateClassToPassNames();
   if (TM)
-    TM->registerPassBuilderCallbacks(*this, ShouldPopulateClassToPassNames);
-  if (ShouldPopulateClassToPassNames) {
+    TM->registerPassBuilderCallbacks(*this);
+  if (PIC) {
+    PIC->registerClassToPassNameCallback([PIC]() {
 #define MODULE_PASS(NAME, CREATE_PASS)                                         \
   PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
 #define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS)      \
@@ -451,6 +439,7 @@ PassBuilder::PassBuilder(TargetMachine *TM, PipelineTuningOptions PTO,
 #define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS)                               \
   PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
 #include "llvm/Passes/MachinePassRegistry.def"
+    });
   }
 }
 
diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
index 8c924e7c937cd..37ce07d4a09de 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
@@ -554,8 +554,7 @@ class AArch64PassConfig : public TargetPassConfig {
 
 } // end anonymous namespace
 
-void AArch64TargetMachine::registerPassBuilderCallbacks(
-    PassBuilder &PB, bool PopulateClassToPassNames) {
+void AArch64TargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
 
   PB.registerLateLoopOptimizationsEPCallback(
       [=](LoopPassManager &LPM, OptimizationLevel Level) {
diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.h b/llvm/lib/Target/AArch64/AArch64TargetMachine.h
index e396d9204716a..1a470ca87127c 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetMachine.h
+++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.h
@@ -43,8 +43,7 @@ class AArch64TargetMachine : public LLVMTargetMachine {
   // Pass Pipeline Configuration
   TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
 
-  void registerPassBuilderCallbacks(PassBuilder &PB,
-                                    bool PopulateClassToPassNames) override;
+  void registerPassBuilderCallbacks(PassBuilder &PB) override;
 
   TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
 
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index 2e7d5cdfc3fe9..8bda424604906 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -658,8 +658,7 @@ Error AMDGPUTargetMachine::buildCodeGenPipeline(
   return CGPB.buildPipeline(MPM, Out, DwoOut, FileType);
 }
 
-void AMDGPUTargetMachine::registerPassBuilderCallbacks(
-    PassBuilder &PB, bool PopulateClassToPassNames) {
+void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
 
 #define GET_PASS_REGISTRY "AMDGPUPassRegistry.def"
 #include "llvm/Passes/TargetPassRegistry.inc"
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
index 98b0bc034b5be..0f74fbc22fa84 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
@@ -58,8 +58,7 @@ class AMDGPUTargetMachine : public LLVMTargetMachine {
                              const CGPassBuilderOption &Opts,
                              PassInstrumentationCallbacks *PIC) override;
 
-  void registerPassBuilderCallbacks(PassBuilder &PB,
-                                    bool PopulateClassToPassNames) override;
+  void registerPassBuilderCallbacks(PassBuilder &PB) override;
   void registerDefaultAliasAnalyses(AAManager &) override;
 
   /// Get the integer value of a null pointer in the given address space.
diff --git a/llvm/lib/Target/BPF/BPFTargetMachine.cpp b/llvm/lib/Target/BPF/BPFTargetMachine.cpp
index 7b73c9f4a1e4c..7d91fa8bb824c 100644
--- a/llvm/lib/Target/BPF/BPFTargetMachine.cpp
+++ b/llvm/lib/Target/BPF/BPFTargetMachine.cpp
@@ -113,8 +113,7 @@ static Expected<bool> parseBPFPreserveStaticOffsetOptions(StringRef Params) {
                                             "BPFPreserveStaticOffsetPass");
 }
 
-void BPFTargetMachine::registerPassBuilderCallbacks(
-    PassBuilder &PB, bool PopulateClassToPassNames) {
+void BPFTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
 #define GET_PASS_REGISTRY "BPFPassRegistry.def"
 #include "llvm/Passes/TargetPassRegistry.inc"
 
diff --git a/llvm/lib/Target/BPF/BPFTargetMachine.h b/llvm/lib/Target/BPF/BPFTargetMachine.h
index 0a28394463b26..4e6adc722e76a 100644
--- a/llvm/lib/Target/BPF/BPFTargetMachine.h
+++ b/llvm/lib/Target/BPF/BPFTargetMachine.h
@@ -42,8 +42,7 @@ class BPFTargetMachine : public LLVMTargetMachine {
     return TLOF.get();
   }
 
-  void registerPassBuilderCallbacks(PassBuilder &PB,
-                                    bool PopulateClassToPassNames) override;
+  void registerPassBuilderCallbacks(PassBuilder &PB) override;
 };
 }
 
diff --git a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
index e4886506de19c..b362285d4f16e 100644
--- a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
@@ -312,8 +312,7 @@ HexagonTargetMachine::getSubtargetImpl(const Function &F) const {
   return I.get();
 }
 
-void HexagonTargetMachine::registerPassBuilderCallbacks(
-    PassBuilder &PB, bool PopulateClassToPassNames) {
+void HexagonTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
 #define GET_PASS_REGISTRY "HexagonPassRegistry.def"
 #include "llvm/Passes/TargetPassRegistry.inc"
 
diff --git a/llvm/lib/Target/Hexagon/HexagonTargetMachine.h b/llvm/lib/Target/Hexagon/HexagonTargetMachine.h
index 34ff45b6acf34..6e9a78b766504 100644
--- a/llvm/lib/Target/Hexagon/HexagonTargetMachine.h
+++ b/llvm/lib/Target/Hexagon/HexagonTargetMachine.h
@@ -35,8 +35,7 @@ class HexagonTargetMachine : public LLVMTargetMachine {
   ~HexagonTargetMachine() override;
   const HexagonSubtarget *getSubtargetImpl(const Function &F) const override;
 
-  void registerPassBuilderCallbacks(PassBuilder &PB,
-                                    bool PopulateClassToPassNames) override;
+  void registerPassBuilderCallbacks(PassBuilder &PB) override;
   TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
   TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
 
diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
index b60a1d747af79..152f200b9d0f3 100644
--- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
@@ -224,8 +224,7 @@ void NVPTXTargetMachine::registerDefaultAliasAnalyses(AAManager &AAM) {
   AAM.registerFunctionAnalysis<NVPTXAA>();
 }
 
-void NVPTXTargetMachine::registerPassBuilderCallbacks(
-    PassBuilder &PB, bool PopulateClassToPassNames) {
+void NVPTXTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
 #define GET_PASS_REGISTRY "NVPTXPassRegistry.def"
 #include "llvm/Passes/TargetPassRegistry.inc"
 
diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
index 870ea20c26f3f..2b88da67a50f9 100644
--- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
+++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
@@ -66,8 +66,7 @@ class NVPTXTargetMachine : public LLVMTargetMachine {
 
   void registerDefaultAliasAnalyses(AAManager &AAM) override;
 
-  void registerPassBuilderCallbacks(PassBuilder &PB,
-                                    bool PopulateClassToPassNames) override;
+  void registerPassBuilderCallbacks(PassBuilder &PB) override;
 
   TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
 
diff --git a/llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp b/llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp
index 9819bfd129855..d979517e12af6 100644
--- a/llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp
+++ b/llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp
@@ -50,8 +50,7 @@ Error X86CodeGenPassBuilder::addInstSelector(AddMachinePass &addPass) const {
 
 } // namespace
 
-void X86TargetMachine::registerPassBuilderCallbacks(
-    PassBuilder &PB, bool PopulateClassToPassNames) {
+void X86TargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
 #define GET_PASS_REGISTRY "X86PassRegistry.def"
 #include "llvm/Passes/TargetPassRegistry.inc"
 }
diff --git a/llvm/lib/Target/X86/X86TargetMachine.h b/llvm/lib/Target/X86/X86TargetMachine.h
index 916445c74bb90..ec4a93e9c9d4b 100644
--- a/llvm/lib/Target/X86/X86TargetMachine.h
+++ b/llvm/lib/Target/X86/X86TargetMachine.h
@@ -66,8 +66,7 @@ class X86TargetMachine final : public LLVMTargetMachine {
                                 SMDiagnostic &Error,
                                 SMRange &SourceRange) const override;
 
-  void registerPassBuilderCallbacks(PassBuilder &PB,
-                                    bool PopulateClassToPassNames) override;
+  void registerPassBuilderCallbacks(PassBuilder &PB) override;
 
   Error buildCodeGenPipeline(ModulePassManager &, raw_pwrite_stream &,
                              raw_pwrite_stream *, CodeGenFileType,

Copy link
Contributor

@aeubanks aeubanks left a comment

Choose a reason for hiding this comment

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

nice, thanks!

@nikic nikic merged commit 957dc43 into llvm:main Jun 24, 2024
10 of 13 checks passed
@nikic nikic deleted the newpm-pass-names-lazy branch June 24, 2024 07:40
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 24, 2024

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-sie-win running on sie-win-worker while building llvm at step 6 "build-unified-tree".

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

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

Step 6 (build-unified-tree) failure: build (failure)
...
[3253/4659] Building CXX object tools\lld\MachO\CMakeFiles\lldMachO.dir\ICF.cpp.obj
[3254/4659] Building CXX object tools\lld\MachO\CMakeFiles\lldMachO.dir\SymbolTable.cpp.obj
[3255/4659] Building CXX object tools\lld\MachO\CMakeFiles\lldMachO.dir\ExportTrie.cpp.obj
[3256/4659] Building CXX object tools\lld\MachO\CMakeFiles\lldMachO.dir\SyntheticSections.cpp.obj
[3257/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\CastToStructChecker.cpp.obj
[3258/4659] Building CXX object tools\lld\wasm\CMakeFiles\lldWasm.dir\WriterUtils.cpp.obj
[3259/4659] Building CXX object tools\lld\MachO\CMakeFiles\lldMachO.dir\SectionPriorities.cpp.obj
[3260/4659] Building CXX object tools\lld\MachO\CMakeFiles\lldMachO.dir\Dwarf.cpp.obj
[3261/4659] Building CXX object tools\lld\MinGW\CMakeFiles\lldMinGW.dir\Driver.cpp.obj
[3262/4659] Building CXX object lib\Target\X86\CMakeFiles\LLVMX86CodeGen.dir\X86CodeGenPassBuilder.cpp.obj
FAILED: lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86CodeGenPassBuilder.cpp.obj 
C:\bin\ccache.exe C:\PROGRA~2\MICROS~1\2019\BUILDT~1\VC\Tools\MSVC\1429~1.301\bin\HostX64\x64\cl.exe  /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib\Target\X86 -IZ:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\lib\Target\X86 -Iinclude -IZ:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Folib\Target\X86\CMakeFiles\LLVMX86CodeGen.dir\X86CodeGenPassBuilder.cpp.obj /Fdlib\Target\X86\CMakeFiles\LLVMX86CodeGen.dir\LLVMX86CodeGen.pdb /FS -c Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\lib\Target\X86\X86CodeGenPassBuilder.cpp
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\lib\Target\X86\X86PassRegistry.def(18): error C3493: 'this' cannot be implicitly captured because no default capture mode has been specified
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\lib\Target\X86\X86PassRegistry.def(18): error C2440: '<function-style-cast>': cannot convert from 'const llvm::X86TargetMachine::registerPassBuilderCallbacks::<lambda_a9c2e3c3cb853196aeda3fee6c7f362f>' to 'llvm::X86ISelDAGToDAGPass'
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\lib\Target\X86\X86PassRegistry.def(18): note: No constructor could take the source type, or constructor overload resolution was ambiguous
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\lib\Target\X86\X86PassRegistry.def(18): error C2651: 'unknown-type': left of '::' must be a class, struct or union
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\lib\Target\X86\X86PassRegistry.def(18): error C2144: syntax error: 'unknown-type' should be preceded by ')'
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\lib\Target\X86\X86PassRegistry.def(18): error C2660: 'llvm::PassInstrumentationCallbacks::addClassToPassName': function does not take 0 arguments
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\include\llvm/IR/PassInstrumentation.h(158): note: see declaration of 'llvm::PassInstrumentationCallbacks::addClassToPassName'
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\lib\Target\X86\X86PassRegistry.def(18): error C2144: syntax error: 'unknown-type' should be preceded by ';'
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\lib\Target\X86\X86PassRegistry.def(18): error C2062: type 'unknown-type' unexpected
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\lib\Target\X86\X86PassRegistry.def(18): error C2039: 'name': is not a member of '`global namespace''
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\llvm\lib\Target\X86\X86PassRegistry.def(18): error C2059: syntax error: ')'
[3263/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\CXXSelfAssignmentChecker.cpp.obj
[3264/4659] Building CXX object lib\Target\X86\CMakeFiles\LLVMX86CodeGen.dir\X86FastISel.cpp.obj
[3265/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\EnumCastOutOfRangeChecker.cpp.obj
[3266/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\DebugContainerModeling.cpp.obj
[3267/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\DebugIteratorModeling.cpp.obj
[3268/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\DynamicTypeChecker.cpp.obj
[3269/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\DirectIvarAssignment.cpp.obj
[3270/4659] Building CXX object lib\Target\X86\CMakeFiles\LLVMX86CodeGen.dir\X86IndirectThunks.cpp.obj
[3271/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\DebugCheckers.cpp.obj
[3272/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\DeadStoresChecker.cpp.obj
[3273/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\FuchsiaHandleChecker.cpp.obj
[3274/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\FixedAddressChecker.cpp.obj
[3275/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\ErrnoModeling.cpp.obj
[3276/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\ErrnoTesterChecker.cpp.obj
[3277/4659] Building CXX object lib\Target\X86\CMakeFiles\LLVMX86CodeGen.dir\X86Subtarget.cpp.obj
[3278/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\ErrnoChecker.cpp.obj
[3279/4659] Building CXX object lib\Target\X86\CMakeFiles\LLVMX86CodeGen.dir\X86ISelDAGToDAG.cpp.obj
[3280/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\DereferenceChecker.cpp.obj
[3281/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\ExprInspectionChecker.cpp.obj
[3282/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\GCDAntipatternChecker.cpp.obj
[3283/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\DivZeroChecker.cpp.obj
[3284/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\DynamicTypePropagation.cpp.obj
[3285/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\GenericTaintChecker.cpp.obj
[3286/4659] Building CXX object tools\clang\lib\StaticAnalyzer\Checkers\CMakeFiles\obj.clangStaticAnalyzerCheckers.dir\GTestChecker.cpp.obj
[3287/4659] Building CXX object lib\Target\X86\CMakeFiles\LLVMX86CodeGen.dir\X86PartialReduction.cpp.obj
[3288/4659] Building CXX object lib\Target\X86\CMakeFiles\LLVMX86CodeGen.dir\X86InstrInfo.cpp.obj

MaskRay added a commit that referenced this pull request Jun 24, 2024
nikic added a commit that referenced this pull request Jun 24, 2024
…96321)"

My attempt to fix the Windows build made things worse,
revert entirely for now.

This reverts commit e7137f2.
This reverts commit 6eaf204.
This reverts commit 957dc43.
nikic added a commit to nikic/llvm-project that referenced this pull request Jun 24, 2024
…lvm#96321)

Use [=] instead of [PIC] capture. On Windows, the "this" uses
inside decltype result in an error otherwise. We can't explicitly
capture "this", because it would result in warnings for the cases
where it isn't used.

My previous attempt to fix this used [&], which obviously causes
lifetime issues instead...

-----

Initializing this map is somewhat expensive (especially for O0), so we
currently only do it if certain flags are used. I would like to make use
of it for crash dumps (llvm#96078), where we don't know in advance whether
it will be needed or not.

This patch changes the initialization to a lazy approach, where a
callback is registered that does the actual initialization. The
callbacks will be run the first time the pass name is requested.

This way there is no compile-time impact if the mapping is not used.
nikic added a commit that referenced this pull request Jun 24, 2024
…96321) (#96462)

On MSVC the `this` uses inside `decltype` require a lambda capture. On
clang they result in an unused capture warning instead. Add the capture
and suppress the warning with `(void)this`.

-----

Initializing this map is somewhat expensive (especially for O0), so we
currently only do it if certain flags are used. I would like to make use
of it for crash dumps (#96078), where we don't know in advance whether
it will be needed or not.

This patch changes the initialization to a lazy approach, where a
callback is registered that does the actual initialization. The
callbacks will be run the first time the pass name is requested.

This way there is no compile-time impact if the mapping is not used.
WenleiHe added a commit to pytorch/pytorch that referenced this pull request Jun 28, 2024
…)"

This reverts commit 20f394f.

LLVM upstream changed the pass builder API again, so registerPassBuilderCallbacks no longer takes extra boolean for PopulateClassToPassNames. Update accordingly
Relevant LLVM upstream change:
llvm/llvm-project#96321
llvm/llvm-project#96462
pytorchmergebot pushed a commit to pytorch/pytorch that referenced this pull request Jun 29, 2024
)

This reverts commit 20f394f (#117086)

LLVM upstream changed the pass builder API again, so registerPassBuilderCallbacks no longer takes extra boolean for PopulateClassToPassNames. Update accordingly.

Relevant LLVM upstream change:
llvm/llvm-project#96321
llvm/llvm-project#96462

Pull Request resolved: #129797
Approved by: https://github.com/dcci
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
Initializing this map is somewhat expensive (especially for O0), so we
currently only do it if certain flags are used. I would like to make use
of it for crash dumps (llvm#96078), where we don't know in advance whether
it will be needed or not.

This patch changes the initialization to a lazy approach, where a
callback is registered that does the actual initialization. The
callbacks will be run the first time the pass name is requested.

This way there is no compile-time impact if the mapping is not used.
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
…lvm#96321)"

My attempt to fix the Windows build made things worse,
revert entirely for now.

This reverts commit e7137f2.
This reverts commit 6eaf204.
This reverts commit 957dc43.
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
…lvm#96321) (llvm#96462)

On MSVC the `this` uses inside `decltype` require a lambda capture. On
clang they result in an unused capture warning instead. Add the capture
and suppress the warning with `(void)this`.

-----

Initializing this map is somewhat expensive (especially for O0), so we
currently only do it if certain flags are used. I would like to make use
of it for crash dumps (llvm#96078), where we don't know in advance whether
it will be needed or not.

This patch changes the initialization to a lazy approach, where a
callback is registered that does the actual initialization. The
callbacks will be run the first time the pass name is requested.

This way there is no compile-time impact if the mapping is not used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants