From 6658fce4fcf3547c66e3273d07a12e266d4c4e01 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 4 Jan 2019 21:21:43 +0000 Subject: [BDCE] Remove dead uses of arguments In addition to finding dead uses of instructions, also find dead uses of function arguments, and replace them with zero as well. I'm changing the way the known bits are computed here to remove the coupling between the transfer function and the algorithm. It previously relied on the first op being visited first and computing known bits -- unless the first op is not an instruction, in which case they're computed on the second op. I could have adjusted this to check for "instruction or argument", but I think it's better to avoid the repeated calculation with an explicit flag. Differential Revision: https://reviews.llvm.org/D56247 llvm-svn: 350435 --- llvm/lib/Transforms/Scalar/BDCE.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Scalar/BDCE.cpp b/llvm/lib/Transforms/Scalar/BDCE.cpp index b7312765213..d3c9b9a270a 100644 --- a/llvm/lib/Transforms/Scalar/BDCE.cpp +++ b/llvm/lib/Transforms/Scalar/BDCE.cpp @@ -114,8 +114,7 @@ static bool bitTrackingDCE(Function &F, DemandedBits &DB) { if (!U->getType()->isIntOrIntVectorTy()) continue; - // TODO: We could also find dead non-instruction uses, e.g. arguments. - if (!isa(U)) + if (!isa(U) && !isa(U)) continue; if (!DB.isUseDead(&U)) -- cgit v1.2.3