diff options
author | Alina Sbirlea <asbirlea@google.com> | 2020-01-23 15:45:37 -0800 |
---|---|---|
committer | Alina Sbirlea <asbirlea@google.com> | 2020-01-23 16:27:32 -0800 |
commit | 1d091742908fddb458023492c43ee4e4492609bc (patch) | |
tree | fc93b145f1bf151adb2f9dd845f884c68b1bb9cd /llvm/lib/Transforms/Utils/Local.cpp | |
parent | 73eaf62463b4a29adf4194685af12d1a5d172987 (diff) | |
download | llvm-1d091742908fddb458023492c43ee4e4492609bc.zip llvm-1d091742908fddb458023492c43ee4e4492609bc.tar.gz llvm-1d091742908fddb458023492c43ee4e4492609bc.tar.bz2 |
[LoopStrengthReduce] Reuse utility method to clean dead instructions. [NFCI]
Create a utility wrapper for the RecursivelyDeleteTriviallyDeadInstructions utility
method, which sets to nullptr the instructions that are not trivially
dead. Use the new method in LoopStrengthReduce.
Alternative: add a bool to the same method; this option adds a marginal
amount of overhead to the other callers, and the method needs to be
updated to return a bool status when it removes/doesn't remove
instructions.
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 10afed3..aad9602 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -450,6 +450,23 @@ bool llvm::RecursivelyDeleteTriviallyDeadInstructions( return true; } +bool llvm::RecursivelyDeleteTriviallyDeadInstructionsPermissive( + SmallVectorImpl<WeakTrackingVH> &DeadInsts, const TargetLibraryInfo *TLI, + MemorySSAUpdater *MSSAU) { + unsigned S = 0, E = DeadInsts.size(), Alive = 0; + for (; S != E; ++S) { + auto *I = cast<Instruction>(DeadInsts[S]); + if (!isInstructionTriviallyDead(I)) { + DeadInsts[S] = nullptr; + ++Alive; + } + } + if (Alive == E) + return false; + RecursivelyDeleteTriviallyDeadInstructions(DeadInsts, TLI, MSSAU); + return true; +} + void llvm::RecursivelyDeleteTriviallyDeadInstructions( SmallVectorImpl<WeakTrackingVH> &DeadInsts, const TargetLibraryInfo *TLI, MemorySSAUpdater *MSSAU) { |