@@ -31,7 +31,7 @@ func (b *builder) createLookupBoundsCheck(arrayLen, index llvm.Value) {
31
31
32
32
// Now do the bounds check: index >= arrayLen
33
33
outOfBounds := b .CreateICmp (llvm .IntUGE , index , arrayLen , "" )
34
- b .createRuntimeAssert (outOfBounds , "lookup" , "lookupPanic" , false )
34
+ b .createRuntimeAssert (outOfBounds , "lookup" , "lookupPanic" , true )
35
35
}
36
36
37
37
// createSliceBoundsCheck emits a bounds check before a slicing operation to make
@@ -230,7 +230,7 @@ func (b *builder) createDivideByZeroCheck(y llvm.Value) {
230
230
231
231
// createRuntimeAssert is a common function to create a new branch on an assert
232
232
// bool, calling an assert func if the assert value is true (1).
233
- func (b * builder ) createRuntimeAssert (assert llvm.Value , blockPrefix , assertFunc string , invoke bool ) {
233
+ func (b * builder ) createRuntimeAssert (assert llvm.Value , blockPrefix , assertFunc string , isInvoke bool ) {
234
234
// Check whether we can resolve this check at compile time.
235
235
if ! assert .IsAConstantInt ().IsNil () {
236
236
val := assert .ZExtValue ()
@@ -245,23 +245,17 @@ func (b *builder) createRuntimeAssert(assert llvm.Value, blockPrefix, assertFunc
245
245
// current insert position.
246
246
faultBlock := b .ctx .AddBasicBlock (b .llvmFn , blockPrefix + ".throw" )
247
247
nextBlock := b .insertBasicBlock (blockPrefix + ".next" )
248
- b .blockExits [b .currentBlock ] = nextBlock // adjust outgoing block for phi nodes
249
248
250
249
// Now branch to the out-of-bounds or the regular block.
251
250
b .CreateCondBr (assert , faultBlock , nextBlock )
252
251
253
252
// Fail: the assert triggered so panic.
254
253
b .SetInsertPointAtEnd (faultBlock )
255
- if invoke {
256
- // This runtime panic is recoverable.
257
- b .createRuntimeInvoke (assertFunc , nil , "" )
258
- } else {
259
- // This runtime panic is not recoverable.
260
- b .createRuntimeCall (assertFunc , nil , "" )
261
- }
254
+ b .createRuntimeCallCommon (assertFunc , nil , "" , isInvoke )
262
255
b .CreateUnreachable ()
263
256
264
257
// Ok: assert didn't trigger so continue normally.
258
+ b .blockExits [b .currentBlock ] = nextBlock // adjust outgoing block for phi nodes
265
259
b .SetInsertPointAtEnd (nextBlock )
266
260
}
267
261
0 commit comments