Hoist runtime checks in the loop nest if they will cause an exception like event. Such events are recognized as blocks with an unreachable terminator possibly (but only) preceded by a function calls which will never return. No other instructions are allowed in these exception blocks and they have to be executed conditionally. As there won't be a statement build for these blocks and the control that flows into them is never flowing into another block we basically model the SCoP as if they would never be executed. Also in the generated AST and consequently IR they will simply disappear. To be sound we add the assumption that no such block can ever be executed to our assumed context. + ubsan out of bound handling will be treated as exception block.
Details
- Reviewers
Meinersbur grosser
Diff Detail
Event Timeline
Hi Johannes,
this patch looks nice and clean! Very cool. Just some smaller comments inline. Besides those, I think it would be good to add an ASAN test case and a multi-dimensional array test case.
Best,
Tobias
lib/Analysis/ScopDetection.cpp | ||
---|---|---|
320 | Also, It does not seem to matter what the instructions do. As long as the block is unreachable, I think we can decide to ignore it. | |
322 | I generally prefer to have 'return false' as the default at the end and then only return true for the cases we indeed want to handle. Also, it is unclear to me why the last three checks are needed. You seem to very detailed check that this is really an exception block. I would just handle anything that ends in an unreachable as such. | |
401 | I would not check the content of an exception block at all. It will anyhow never be executed. | |
929 | I would skip exception blocks already here. There content does not really matter, no? | |
test/ScopInfo/BoundChecks/single-loop.ll | ||
32 | Nice! |
I am missing a definition (in the source) what a "exception-like block" is and why it can be ignored.
Also, why is UBSan special that it cannot be handled like other exception-like blocks?
Can you give an motivating example?
include/polly/ScopDetection.h | ||
---|---|---|
349 | Wouldn't it be better to define static methods as normal functions unless it needs access private static members? | |
lib/Analysis/ScopDetection.cpp | ||
299 | Judging from when the code calling this, this has nothing to do with exceptions (i.e. "invoke" statement), but just error condition checking. | |
300 | empty line? | |
305 | Isn't it possible that __ubsan_handle_out_of_bounds is merged with other code on the same condition? | |
323 | Could you elaborate why all these conditions are necessary? | |
401 | isValidExceptionBlock also requires that the block has an unreachable terminator, which probably doesn't matter here. Also, what about such (stupid) code? abort() __ubsan_handle_out_of_bounds() br somewhere_else | |
710 | unrelated change |
@grosser @Meinersbur Thanks for the comments! I'll push an updated value directly into the repo.
lib/Analysis/ScopDetection.cpp | ||
---|---|---|
300 | Yes. | |
305 | That does not matter for the whole scheme. We will never model or execute the block anyway. | |
323 | Simplified and listed conditions in header description. | |
401 | Simplified this wrt to the comments from Tobias. |
Wouldn't it be better to define static methods as normal functions unless it needs access private static members?