The TypeSize warning would occur because RuntimePointerChecking::insert
was not scalable vector aware. The fix is to use
ScalarEvolution::getSizeOfExpr to grab the size of types.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
420 ms | linux > HWAddressSanitizer-x86_64.TestCases::sizes.cpp |
Event Timeline
llvm/test/Analysis/LoopAccessAnalysis/runtime-pointer-checking-insert-typesize.ll | ||
---|---|---|
2 | Ideally the tests in this directory would only use -loop-accesses -analyze and no transformation passes. Is that possible? Also, is -mattr=+sve needed? If loop-load-elimination is required, the test should probably go there. Also it might be good to just have all scaleable tests in a single file in the directory> |
Address @fhahn's suggestions.
llvm/test/Analysis/LoopAccessAnalysis/runtime-pointer-checking-insert-typesize.ll | ||
---|---|---|
2 | Thanks for the pointers!
Ah okay -- turns out we can just use -loop-accesses -analyze for the same result. Fixed this.
It's not required. :) |
Address @fhahn's comments.
- IntIdxTy -> IdxTy
- Preserve existing behaviour for non-scalable types.
llvm/lib/Analysis/LoopAccessAnalysis.cpp | ||
---|---|---|
233 | Excellent spot -- I have fixed this. |
llvm/lib/Analysis/LoopAccessAnalysis.cpp | ||
---|---|---|
233 | Not sure how hard it would be to come up with a test, but it would probably be good to have one |
llvm/lib/Analysis/LoopAccessAnalysis.cpp | ||
---|---|---|
233 | Hi @fhahn, sorry for the lag in replying here! I tried to make a test for this but wasn't able to come up with anything that defends against the different behaviour when alloc size != store size. I think I will leave this out from the patch, if that is okay with you? Otherwise, it would be useful to hear your ideas on how we could create such a test. :) |
@fhahn Hi! Do you have any objections to landing this as-is without the additional test? Alternatively, any recommendations on how to test this? 😄
I think you would need to use element types with different store & alloca sizes, like i19 (see https://github.com/llvm/llvm-project/blob/master/llvm/include/llvm/IR/DataLayout.h#L446 for some examples). You should be able to adjust a test with runtime checks (e.g. llvm/test/Analysis/LoopAccessAnalysis/memcheck-off-by-one-error.ll) and update it to use a type like i19 to get such a test. If you decide to use llvm/test/Analysis/LoopAccessAnalysis/memcheck-off-by-one-error.ll, I think some of the casts in the loop body could be stripped.
llvm/test/Analysis/LoopAccessAnalysis/runtime-pointer-checking-insert-typesize.ll | ||
---|---|---|
2 |
Looks like there's another test that runs -loop-load-elim: llvm/test/Analysis/LoopAccessAnalysis/gep-induction-operand-typesize-warning.ll. Could this test also be updated? |
Thank you @fhahn, that comment was super helpful. I've opted to create a new test here because I didn't want to change the relationship between the IR and the C++ at the top of memcheck-off-by-on-error.ll. If you think this is the wrong thing to do, just let me know. 😄
LGTM with the comment adjustment, thanks!
llvm/lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
3544 ↗ | (On Diff #307307) | if you are touching the comment lines, could. you also re-flow the comment? Also, this comment should be moved to the getConstant call, right? Because for scalable vectors we create a constant expression. |
nit: just IdxTy?