summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2016-12-06 21:52:47 +0000
committerDavide Italiano <davide@freebsd.org>2016-12-06 21:52:47 +0000
commit043e66137c01de5d9f9bf49b471036959018d7d8 (patch)
tree0160254f7195a31744513b58884add8555e44198 /llvm/lib/Transforms/Scalar
parentb792e0694b678e08832d5cfcb52d800c6f1a01aa (diff)
downloadbcm5719-llvm-043e66137c01de5d9f9bf49b471036959018d7d8.tar.gz
bcm5719-llvm-043e66137c01de5d9f9bf49b471036959018d7d8.zip
[BDCE/DebugInfo] Preserve llvm.dbg.value's argument.
BDCE has two phases: 1. It asks SimplifyDemandedBits if all the bits of an instruction are dead, and if so, replaces all its uses with the constant zero. 2. Then, it asks SimplifyDemandedBits again if the instruction is really dead (no side effects etc..) and if so, eliminates it. Now, in 1) if all the bits of an instruction are dead, we may end up replacing a dbg use: %call = tail call i32 (...) @g() #4, !dbg !15 tail call void @llvm.dbg.value(metadata i32 %call, i64 0, metadata !8, metadata !16), !dbg !17 -> %call = tail call i32 (...) @g() #4, !dbg !15 tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !8, metadata !16), !dbg !17 but not eliminating the call because it may have arbitrary side effects. In other words, we lose some debug informations. This patch fixes the problem making sure that BDCE does nothing with the instruction if it has side effects and no non-dbg uses. Differential Revision: https://reviews.llvm.org/D27471 llvm-svn: 288851
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r--llvm/lib/Transforms/Scalar/BDCE.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/BDCE.cpp b/llvm/lib/Transforms/Scalar/BDCE.cpp
index 4f6225f4c7b..1baade43e85 100644
--- a/llvm/lib/Transforms/Scalar/BDCE.cpp
+++ b/llvm/lib/Transforms/Scalar/BDCE.cpp
@@ -39,6 +39,11 @@ static bool bitTrackingDCE(Function &F, DemandedBits &DB) {
SmallVector<Instruction*, 128> Worklist;
bool Changed = false;
for (Instruction &I : instructions(F)) {
+ // If the instruction has side effects and no non-dbg uses,
+ // BDCE should skip it.
+ if (I.mayHaveSideEffects() && I.use_empty())
+ continue;
+
if (I.getType()->isIntegerTy() &&
!DB.getDemandedBits(&I).getBoolValue()) {
// For live instructions that have all dead bits, first make them dead by
OpenPOWER on IntegriCloud