[llvm] [BasicBlockUtils] Remove redundant llvm.dbg instructions after blocks to reduce compile time (PR #89069)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 19 20:15:57 PDT 2024
https://github.com/coderchenlin updated https://github.com/llvm/llvm-project/pull/89069
>From 6ade1a901b892dcb868664a04b0f93a98024d73f Mon Sep 17 00:00:00 2001
From: coderchenlin <chenlin048830 at gmail.com>
Date: Wed, 17 Apr 2024 21:01:52 +0800
Subject: [PATCH] [BasicBlockUtils] Remove redundant llvm.dbg instructions
after blocks merged
There will generate more redundant llvm.dbg instructions when compiling
with "-g" flag, and increase compile time. The issue is happened after
loop-unroll pass.`
Fixes #89073.
---
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp | 4 ++++
llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-inlined.ll | 1 -
llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue.ll | 1 -
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index 5aa59acfa6df99..cbf66ce2796db8 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -333,6 +333,10 @@ bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU,
// Finally, erase the old block and update dominator info.
DeleteDeadBlock(BB, DTU);
+ // Remove redundant "llvm.dbg" instrunctions after blocks merged.
+ if (PredBB->getParent()->getSubprogram())
+ RemoveRedundantDbgInstrs(PredBB);
+
return true;
}
diff --git a/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-inlined.ll b/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-inlined.ll
index e00d1daf71de58..5af73e789f11ce 100644
--- a/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-inlined.ll
+++ b/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-inlined.ll
@@ -9,7 +9,6 @@ init:
; CHECK: %vala = load i64, ptr %ptr
; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %vala, metadata [[MD:![0-9]*]]
-; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %vala, metadata [[MD]]
; CHECK-NEXT: %valbmasked = and i64 %vala, 1
a: ; preds = %init
diff --git a/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue.ll b/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue.ll
index af7da45ec089cc..c5d723c4e3dd61 100644
--- a/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue.ll
+++ b/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue.ll
@@ -47,7 +47,6 @@ define i1 @hoist_with_debug2(i32 %x) !dbg !22 {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp ugt i32 [[X:%.*]], 2
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[X]], metadata [[META21:![0-9]+]], metadata !DIExpression()), !dbg [[DBG23:![0-9]+]]
-; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[X]], metadata [[META21]], metadata !DIExpression()), !dbg [[DBG23]]
; CHECK-NEXT: [[DOT:%.*]] = select i1 [[TOBOOL_NOT]], i1 false, i1 true
; CHECK-NEXT: ret i1 [[DOT]]
;
More information about the llvm-commits
mailing list