createDivideByZeroCheck asserts that y is not zero. If it is, a runtime panic will be emitted. This follows the Go specification which says that a divide by zero must cause a run time panic.
(y llvm.Value)
| 219 | // will be emitted. This follows the Go specification which says that a divide |
| 220 | // by zero must cause a run time panic. |
| 221 | func (b *builder) createDivideByZeroCheck(y llvm.Value) { |
| 222 | if b.info.nobounds { |
| 223 | return |
| 224 | } |
| 225 | |
| 226 | // isZero = y == 0 |
| 227 | isZero := b.CreateICmp(llvm.IntEQ, y, llvm.ConstInt(y.Type(), 0, false), "") |
| 228 | b.createRuntimeAssert(isZero, "divbyzero", "divideByZeroPanic") |
| 229 | } |
| 230 | |
| 231 | // createRuntimeAssert is a common function to create a new branch on an assert |
| 232 | // bool, calling an assert func if the assert value is true (1). |
no test coverage detected