-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[RemoveDIs] Print non-intrinsic debug info in textual IR output #79281
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
Changes from all commits
44a3527
b7d9744
5ae0123
bd6df6b
ee1f6e7
8e4f1c6
398d000
ce9525d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,25 @@ std::string doSystemDiff(StringRef Before, StringRef After, | |
StringRef OldLineFormat, StringRef NewLineFormat, | ||
StringRef UnchangedLineFormat); | ||
|
||
/// Used to temporarily set the debug info format of a function, module, or | ||
/// basic block for the duration of this object's lifetime, after which the | ||
/// prior state will be restored. | ||
template <typename T> class ScopedDbgInfoFormatSetter { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This wants a docu-comment indicating what it's doing -- no need to be detailed as it's unlikely to be a long term facility. |
||
T &Obj; | ||
bool OldState; | ||
|
||
public: | ||
ScopedDbgInfoFormatSetter(T &Obj, bool NewState) | ||
: Obj(Obj), OldState(Obj.IsNewDbgInfoFormat) { | ||
Obj.setIsNewDbgInfoFormat(NewState); | ||
} | ||
~ScopedDbgInfoFormatSetter() { Obj.setIsNewDbgInfoFormat(OldState); } | ||
}; | ||
|
||
template <typename T> | ||
ScopedDbgInfoFormatSetter(T &Obj, bool NewState) | ||
-> ScopedDbgInfoFormatSetter<T>; | ||
|
||
} // namespace llvm | ||
|
||
#endif // LLVM_IR_PRINTPASSES_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,8 @@ | |
|
||
using namespace llvm; | ||
|
||
extern cl::opt<bool> WriteNewDbgInfoFormat; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes llvm/lib/IR depend on llvm/lib/IRPrinter (where this is defined), but the latter already depends on the former. That is, this introduces a cyclic dependency. The definition of this symbol should probably live in this file and be extern in IRPrinter? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree with the analysis. If you link the executable with
(This is from a Bazel build). |
||
|
||
namespace { | ||
|
||
class PrintModulePassWrapper : public ModulePass { | ||
|
@@ -39,11 +41,9 @@ class PrintModulePassWrapper : public ModulePass { | |
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {} | ||
|
||
bool runOnModule(Module &M) override { | ||
// RemoveDIs: there's no textual representation of the DPValue debug-info, | ||
// convert to dbg.values before writing out. | ||
bool IsNewDbgInfoFormat = M.IsNewDbgInfoFormat; | ||
if (IsNewDbgInfoFormat) | ||
M.convertFromNewDbgValues(); | ||
// RemoveDIs: Regardless of the format we've processed this module in, use | ||
// `WriteNewDbgInfoFormat` to determine which format we use to write it. | ||
ScopedDbgInfoFormatSetter FormatSetter(M, WriteNewDbgInfoFormat); | ||
|
||
if (llvm::isFunctionInPrintList("*")) { | ||
if (!Banner.empty()) | ||
|
@@ -62,9 +62,6 @@ class PrintModulePassWrapper : public ModulePass { | |
} | ||
} | ||
|
||
if (IsNewDbgInfoFormat) | ||
M.convertToNewDbgValues(); | ||
|
||
return false; | ||
} | ||
|
||
|
@@ -87,11 +84,9 @@ class PrintFunctionPassWrapper : public FunctionPass { | |
|
||
// This pass just prints a banner followed by the function as it's processed. | ||
bool runOnFunction(Function &F) override { | ||
// RemoveDIs: there's no textual representation of the DPValue debug-info, | ||
// convert to dbg.values before writing out. | ||
bool IsNewDbgInfoFormat = F.IsNewDbgInfoFormat; | ||
if (IsNewDbgInfoFormat) | ||
F.convertFromNewDbgValues(); | ||
// RemoveDIs: Regardless of the format we've processed this function in, use | ||
// `WriteNewDbgInfoFormat` to determine which format we use to write it. | ||
ScopedDbgInfoFormatSetter FormatSetter(F, WriteNewDbgInfoFormat); | ||
|
||
if (isFunctionInPrintList(F.getName())) { | ||
if (forcePrintModuleIR()) | ||
|
@@ -101,9 +96,6 @@ class PrintFunctionPassWrapper : public FunctionPass { | |
OS << Banner << '\n' << static_cast<Value &>(F); | ||
} | ||
|
||
if (IsNewDbgInfoFormat) | ||
F.convertToNewDbgValues(); | ||
|
||
return false; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Brief) Docu-comment wanted