Skip to content

Commit 08a3b29

Browse files
badnikhilthewilsonator
authored andcommitted
DCompute: don't emit array bounds checks for device code
1 parent 9e082b9 commit 08a3b29

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

gen/irstate.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ llvm::Instruction *IRState::CreateCallOrInvoke(LLFunction *Callee,
130130
}
131131

132132
bool IRState::emitArrayBoundsChecks() {
133+
// Bounds checks throw `RangeError`, which is illegal in `@compute` device code
134+
// (and the `_d_arraybounds_index` handler has no device implementation), so
135+
// never emit them for device code.
136+
if (dcomputetarget)
137+
return false;
138+
133139
if (global.params.useArrayBounds != CHECKENABLEsafeonly) {
134140
return global.params.useArrayBounds == CHECKENABLEon;
135141
}

0 commit comments

Comments
 (0)