[llvm] Add flags to dump IR to a file before and after LLVM passes (PR #65179)

Anton Korobeynikov via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 1 12:50:25 PDT 2023


================
@@ -69,6 +69,62 @@ class PrintIRInstrumentation {
   unsigned CurrentPassNumber = 0;
 };
 
+class DumpIRInstrumentation {
+public:
+  void registerCallbacks(PassInstrumentationCallbacks &PIC);
+
+private:
+  void dumpBeforePass(StringRef PassID, Any IR);
+  void dumpAfterPass(StringRef PassID, Any IR);
+
+  bool shouldDumpBeforePass(StringRef PassID);
+  bool shouldDumpAfterPass(StringRef PassID);
+
+  PassInstrumentationCallbacks *PIC;
+
+  // The module currently being processed in the pipeline.
+  Module const *CurrentModule = nullptr;
+
+  void pushPass(StringRef PassID, Any IR);
+  void popPass(StringRef PassID);
+
+  SmallString<16> InstrumentationDumpDirectory;
+  StringRef fetchInstrumentationDumpDirectory();
+
+  SmallString<16> fetchCurrentInstrumentationDumpFile(StringRef Suffix);
+
+  // A table to store how many times a given pass has run at the current "nested
+  // level"
+  using PassRunsFrequencyTableT = DenseMap<StringRef, uint>;
----------------
asl wrote:

Use standard types.
```suggestion
  using PassRunsFrequencyTableT = DenseMap<StringRef, unsigned>;
```

https://github.com/llvm/llvm-project/pull/65179


More information about the llvm-commits mailing list