circt icon indicating copy to clipboard operation
circt copied to clipboard

[HWToLLVM] ArrayGet lowering produces out-of-bounds memory access

Open fabianschuiki opened this issue 1 year ago • 0 comments

Array get/slice lowering patterns in HW-to-LLVM generate unguarded loads, potentially loading values from invalid memory locations:

https://github.com/llvm/circt/blob/ce9877c55544937aec68b2a5b099ccef788168ba/lib/Conversion/HWToLLVM/HWToLLVM.cpp#L136-L176

In case the index is not a power of two, we should probably add an scf.if here to only perform the load if it is within the range of the array.

fabianschuiki avatar Apr 24 '24 18:04 fabianschuiki