aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Module.cpp
diff options
context:
space:
mode:
authorStephen Tozer <stephen.tozer@sony.com>2024-02-26 18:22:05 +0000
committerGitHub <noreply@github.com>2024-02-26 18:22:05 +0000
commit0b398256b3f72204ad1f7c625efe4990204e898a (patch)
treea7f1c9bdfcd0f4c9942ff1dcbf4b180179cce1fb /llvm/lib/IR/Module.cpp
parent3aec947b671bf3a2c00ef7d29557db687af8ff7c (diff)
downloadllvm-0b398256b3f72204ad1f7c625efe4990204e898a.zip
llvm-0b398256b3f72204ad1f7c625efe4990204e898a.tar.gz
llvm-0b398256b3f72204ad1f7c625efe4990204e898a.tar.bz2
[RemoveDIs] Print non-intrinsic debug info in textual IR output (#79281)
This patch adds support for printing the proposed non-instruction debug info ("RemoveDIs") out to textual IR. This patch does not add any bitcode support, parsing support, or documentation. Printing of the new format is controlled by a flag added in this patch, `--write-experimental-debuginfo`, which defaults to false. The new format will be printed *iff* this flag is true, so whether we use the IR format is completely independent of whether we use non-instruction debug info during LLVM passes (which is controlled by the `--try-experimental-debuginfo-iterators` flag). Even with the flag disabled, some existing tests need to be updated, as this patch causes debug intrinsic declarations to be changed in a round trip, such that they always appear at the end of a module and have no attributes (this has no functional change on the module). The design of this new IR format was proposed previously on Discourse, and any further discussion about the design can still be contributed there: https://discourse.llvm.org/t/rfc-debuginfo-proposed-changes-to-the-textual-ir-representation-for-debug-values/73491
Diffstat (limited to 'llvm/lib/IR/Module.cpp')
-rw-r--r--llvm/lib/IR/Module.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index 1946db2..a8696ed 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -85,6 +85,28 @@ Module::~Module() {
IFuncList.clear();
}
+void Module::removeDebugIntrinsicDeclarations() {
+ auto *DeclareIntrinsicFn =
+ Intrinsic::getDeclaration(this, Intrinsic::dbg_declare);
+ assert((!isMaterialized() || DeclareIntrinsicFn->hasZeroLiveUses()) &&
+ "Debug declare intrinsic should have had uses removed.");
+ DeclareIntrinsicFn->eraseFromParent();
+ auto *ValueIntrinsicFn =
+ Intrinsic::getDeclaration(this, Intrinsic::dbg_value);
+ assert((!isMaterialized() || ValueIntrinsicFn->hasZeroLiveUses()) &&
+ "Debug value intrinsic should have had uses removed.");
+ ValueIntrinsicFn->eraseFromParent();
+ auto *AssignIntrinsicFn =
+ Intrinsic::getDeclaration(this, Intrinsic::dbg_assign);
+ assert((!isMaterialized() || AssignIntrinsicFn->hasZeroLiveUses()) &&
+ "Debug assign intrinsic should have had uses removed.");
+ AssignIntrinsicFn->eraseFromParent();
+ auto *LabelntrinsicFn = Intrinsic::getDeclaration(this, Intrinsic::dbg_label);
+ assert((!isMaterialized() || LabelntrinsicFn->hasZeroLiveUses()) &&
+ "Debug label intrinsic should have had uses removed.");
+ LabelntrinsicFn->eraseFromParent();
+}
+
std::unique_ptr<RandomNumberGenerator>
Module::createRNG(const StringRef Name) const {
SmallString<32> Salt(Name);