[PATCH] D86657: Add new hidden option -print-crash-IR that prints out IR that caused opt pipeline to crash

Yevgeny Rouban via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 30 22:14:44 PDT 2020


yrouban added inline comments.
Herald added a subscriber: danielkiss.


================
Comment at: llvm/lib/Passes/StandardInstrumentations.cpp:207-210
+std::string SavedIR = "*** Dump of IR Before Last Pass Unknown ***";
+
+// Crash handler registered when print-on-crash is specified.
+void crashedIRReporter(void *) { dbgs() << SavedIR; }
----------------
I would suggest that :
1. SavedIR is an instance field of PrintCrashIRInstrumentation.
2. There is a global set of live PrintCrashIRInstrumentation. Every instance is added in its constructor and deleted in its destructor. The add and delete operations are synchronized.
3. For all live PrintCrashIRInstrumentation instances the crashedIRReporter prints whatever it is supposed to print.


================
Comment at: llvm/lib/Passes/StandardInstrumentations.cpp:375
+
+  PIC.registerBeforePassCallback([](StringRef PassID, Any IR) {
+    SavedIR.clear();
----------------
this must be done for every call of //registerCallbacks// disregard to //HandlerRegistered//.



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86657/new/

https://reviews.llvm.org/D86657



More information about the llvm-commits mailing list