diff options
| author | Philip Reames <listmail@philipreames.com> | 2019-07-09 18:56:41 +0000 |
|---|---|---|
| committer | Philip Reames <listmail@philipreames.com> | 2019-07-09 18:56:41 +0000 |
| commit | 3b38b92541d78f4afba2d0bea737e53d2fae4511 (patch) | |
| tree | 61b2b689e4576d076d9ad1699dd6ce7f9a17a764 /llvm/lib/Transforms | |
| parent | 6a4c2e4f0a933f24b9f089e3804072f7733e38eb (diff) | |
| download | bcm5719-llvm-3b38b92541d78f4afba2d0bea737e53d2fae4511.tar.gz bcm5719-llvm-3b38b92541d78f4afba2d0bea737e53d2fae4511.zip | |
[PoisonChecking] Add validation rules for "exact" on sdiv/udiv
As directly stated in the LangRef, no ambiguity here...
llvm-svn: 365538
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Instrumentation/PoisonChecking.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/PoisonChecking.cpp b/llvm/lib/Transforms/Instrumentation/PoisonChecking.cpp index 8406eb5d396..8e4c046c9f8 100644 --- a/llvm/lib/Transforms/Instrumentation/PoisonChecking.cpp +++ b/llvm/lib/Transforms/Instrumentation/PoisonChecking.cpp @@ -151,6 +151,24 @@ static void generatePoisonChecksForBinOp(Instruction &I, } break; } + case Instruction::UDiv: { + if (I.isExact()) { + auto *Check = + B.CreateICmp(ICmpInst::ICMP_NE, B.CreateURem(LHS, RHS), + ConstantInt::get(LHS->getType(), 0)); + Checks.push_back(Check); + } + break; + } + case Instruction::SDiv: { + if (I.isExact()) { + auto *Check = + B.CreateICmp(ICmpInst::ICMP_NE, B.CreateSRem(LHS, RHS), + ConstantInt::get(LHS->getType(), 0)); + Checks.push_back(Check); + } + break; + } }; } |

