In r248701 "Allow switch instructions in SCoPs" support for switch statements has been introduced, but support for switch statements in loop latches was incomplete. This change completely disables switch statements in loop latches. The original commit changed addLoopBoundsToHeaderDomain to support non-branch terminator instructions, but this change was incorrect: it added a check for BI != null to the if-branch of a condition, but BI was used in the else branch es well. As a result, when a non-branch terminator instruction is encounted a nullptr dereference is triggered. Due to missing test coverage, this bug was overlooked. r249273 "[FIX] Approximate non-affine loops correctly" added code to disallow switch statements for non-affine loops, if they appear in either a loop latch or a loop exit. We adapt this code to now prohibit switch statements in loop latches even if the control condition is affine. We could possibly add support for switch statements in loop latches, but such support should be evaluated and tested separately. This fixes llvm.org/PR30952 Reported-by: Eli Friedman <efriedma@codeaurora.org> llvm-svn: 286426
22 lines
340 B
LLVM
22 lines
340 B
LLVM
; RUN: opt %loadPolly -polly-detect -analyze < %s | FileCheck %s
|
|
|
|
; CHECK-NOT: Valid
|
|
|
|
; Verify that we do not detect loops where the loop latch is a switch statement.
|
|
; Such loops are not yet supported by Polly.
|
|
|
|
define void @f() {
|
|
b:
|
|
br label %d
|
|
|
|
d:
|
|
switch i8 0, label %e [
|
|
i8 71, label %d
|
|
i8 56, label %d
|
|
]
|
|
|
|
e:
|
|
ret void
|
|
}
|
|
|