diff options
author | Sanjay Patel <spatel@rotateright.com> | 2019-10-01 21:25:36 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2019-10-01 21:25:36 +0000 |
commit | 9738fd63877136eb1ffffb74ad78ea77861c88fe (patch) | |
tree | 6a4aa2c545360d0375297a76981aa1162510fe5b /llvm/lib/Transforms/Utils | |
parent | 081e9df1e1874078a46d3421ce7a3fca55b23259 (diff) | |
download | bcm5719-llvm-9738fd63877136eb1ffffb74ad78ea77861c88fe.tar.gz bcm5719-llvm-9738fd63877136eb1ffffb74ad78ea77861c88fe.zip |
[BypassSlowDivision][CodeGenPrepare] avoid crashing on unused code (PR43514)
https://bugs.llvm.org/show_bug.cgi?id=43514
llvm-svn: 373394
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r-- | llvm/lib/Transforms/Utils/BypassSlowDivision.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp b/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp index df299f673f6..9a6761040bd 100644 --- a/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp +++ b/llvm/lib/Transforms/Utils/BypassSlowDivision.cpp @@ -448,13 +448,17 @@ bool llvm::bypassSlowDivision(BasicBlock *BB, DivCacheTy PerBBDivCache; bool MadeChange = false; - Instruction* Next = &*BB->begin(); + Instruction *Next = &*BB->begin(); while (Next != nullptr) { // We may add instructions immediately after I, but we want to skip over // them. - Instruction* I = Next; + Instruction *I = Next; Next = Next->getNextNode(); + // Ignore dead code to save time and avoid bugs. + if (I->hasNUses(0)) + continue; + FastDivInsertionTask Task(I, BypassWidths); if (Value *Replacement = Task.getReplacement(PerBBDivCache)) { I->replaceAllUsesWith(Replacement); |