diff --git a/llvm/lib/CheerpWriter/PartialExecuter.cpp b/llvm/lib/CheerpWriter/PartialExecuter.cpp index 667cc2942091..a63f14280a13 100644 --- a/llvm/lib/CheerpWriter/PartialExecuter.cpp +++ b/llvm/lib/CheerpWriter/PartialExecuter.cpp @@ -463,9 +463,6 @@ class PartialInterpreter : public llvm::Interpreter { if (!areOperandsComputed(I)) return true; - if (isa(I) || isa(I)) - return false; - switch (I.getOpcode()) { case Instruction::Br: @@ -516,9 +513,21 @@ class PartialInterpreter : public llvm::Interpreter { // TODO(carlo): Possibly even Loads of Alloca might be proven valid break; } + case Instruction::SRem: + case Instruction::URem: + case Instruction::SDiv: + case Instruction::UDiv: + { + Value *Src2 = I.getOperand(1); + if (isValueComputed(Src2) && getOperandValue(Src2).IntVal.isZero()) + return true; // Division or remainder by zero + return false; // Is a binary operator + } default: { - //Default case is for Instruction to be skipped + if (isa(I) || isa(I)) + return false; + // Default case is for Instruction to be skipped return true; } }