@@ -31,7 +31,7 @@ func (b *builder) createLookupBoundsCheck(arrayLen, index llvm.Value) {
3131
3232 // Now do the bounds check: index >= arrayLen
3333 outOfBounds := b .CreateICmp (llvm .IntUGE , index , arrayLen , "" )
34- b .createRuntimeAssert (outOfBounds , "lookup" , "lookupPanic" , false )
34+ b .createRuntimeAssert (outOfBounds , "lookup" , "lookupPanic" , true )
3535}
3636
3737// createSliceBoundsCheck emits a bounds check before a slicing operation to make
@@ -230,7 +230,7 @@ func (b *builder) createDivideByZeroCheck(y llvm.Value) {
230230
231231// createRuntimeAssert is a common function to create a new branch on an assert
232232// 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 ) {
234234 // Check whether we can resolve this check at compile time.
235235 if ! assert .IsAConstantInt ().IsNil () {
236236 val := assert .ZExtValue ()
@@ -245,23 +245,17 @@ func (b *builder) createRuntimeAssert(assert llvm.Value, blockPrefix, assertFunc
245245 // current insert position.
246246 faultBlock := b .ctx .AddBasicBlock (b .llvmFn , blockPrefix + ".throw" )
247247 nextBlock := b .insertBasicBlock (blockPrefix + ".next" )
248- b .blockExits [b .currentBlock ] = nextBlock // adjust outgoing block for phi nodes
249248
250249 // Now branch to the out-of-bounds or the regular block.
251250 b .CreateCondBr (assert , faultBlock , nextBlock )
252251
253252 // Fail: the assert triggered so panic.
254253 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 )
262255 b .CreateUnreachable ()
263256
264257 // Ok: assert didn't trigger so continue normally.
258+ b .blockExits [b .currentBlock ] = nextBlock // adjust outgoing block for phi nodes
265259 b .SetInsertPointAtEnd (nextBlock )
266260}
267261
0 commit comments