[2/2] Add testcase for backward threading from never-executed entry edges [PR105679]
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_simplebootstrap_build--master-aarch64-bootstrap |
success
|
Build passed
|
Commit Message
r13-1891-g49ba4fdeb648c1 made the backward threader reject paths
whose entry edge is probably never executed, but landed without a
testcase. Add one retroactively.
[Also AI generated.]
Assisted-by: Claude Fable 5 (Anthropic)
OK?
gcc/testsuite/ChangeLog:
PR tree-optimization/105679
PR tree-optimization/126906
* gcc.dg/tree-ssa/pr105679.c: New test.
---
gcc/testsuite/gcc.dg/tree-ssa/pr105679.c | 33 ++++++++++++++++++++++++
1 file changed, 33 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr105679.c
Comments
On 9/2/26 6:07 AM, Aldy Hernandez wrote:
> r13-1891-g49ba4fdeb648c1 made the backward threader reject paths
> whose entry edge is probably never executed, but landed without a
> testcase. Add one retroactively.
>
> [Also AI generated.]
>
> Assisted-by: Claude Fable 5 (Anthropic)
>
> OK?
>
> gcc/testsuite/ChangeLog:
>
> PR tree-optimization/105679
> PR tree-optimization/126906
> * gcc.dg/tree-ssa/pr105679.c: New test.
It took me a minute to realize that the sanitizer is what's inserting
the irq > 31 check. I might have tried to guide towards exposing the
code generated by sanitization to make the testcase clearer, but it's
not worth it IMHO to do it now.
OK.
jeff
new file mode 100644
@@ -0,0 +1,33 @@
+/* PR tree-optimization/105679 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Warray-bounds -fno-strict-overflow -fsanitize=shift -fsanitize-coverage=trace-pc -fdump-tree-threadfull1-details" } */
+
+/* Reduced with cvise from attachment 53010: the Linux kernel hit spurious
+ -Warray-bounds warnings with -fsanitize=shift. The sanitizer's
+ shift-out-of-bounds check for 1 << irq gives the irq > 31 branch a precise
+ never-executed count; the backward threader nevertheless used that block as
+ a thread entry, isolating a never-executed path on which irq > 31 indexes
+ the 2-element array and drawing the bogus warning. The bare shift statement
+ only exists to feed the sanitizer.
+
+ r13-1891 (the PR105679 fix) rejects paths whose entry edge is probably never
+ executed. This test FAILs before that commit and PASSes with it. */
+
+struct many_objects
+{
+ int array[2];
+} instance;
+
+int entry;
+
+int
+work (unsigned int irq)
+{
+ 1 << irq;
+ entry = instance.array[irq]; /* { dg-bogus "above array bounds" } */
+ if (irq)
+ return 0;
+ return 1;
+}
+
+/* { dg-final { scan-tree-dump "path entry is probably never executed" "threadfull1" } } */