Skip to content

[DA] add testcase #116631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2025
Merged

[DA] add testcase #116631

merged 2 commits into from
Jan 29, 2025

Conversation

sebpop
Copy link
Contributor

@sebpop sebpop commented Nov 18, 2024

Make sure the testcase for this bug continues to work: #31196

@llvmbot
Copy link
Member

llvmbot commented Nov 18, 2024

@llvm/pr-subscribers-testing-tools

@llvm/pr-subscribers-llvm-analysis

Author: Sebastian Pop (sebpop)

Changes

Make sure the testcase for this bug continues to work: #31196


Full diff: https://github.com/llvm/llvm-project/pull/116631.diff

1 Files Affected:

  • (added) llvm/test/Analysis/DependenceAnalysis/PR31848.ll (+67)
diff --git a/llvm/test/Analysis/DependenceAnalysis/PR31848.ll b/llvm/test/Analysis/DependenceAnalysis/PR31848.ll
new file mode 100644
index 00000000000000..02e7c54f9e941d
--- /dev/null
+++ b/llvm/test/Analysis/DependenceAnalysis/PR31848.ll
@@ -0,0 +1,67 @@
+; RUN: opt < %s -disable-output "-passes=print<da>" -aa-pipeline=basic-aa 2>&1 \
+; RUN: | FileCheck %s
+
+define void @foo(i32* nocapture %A, i32 %n) {
+entry:
+  %n.cmp = icmp sgt i32 %n, 0
+  br i1 %n.cmp, label %for.j.header, label %exit
+
+for.j.header:
+  %j= phi i32 [ %j.inc, %for.j.latch ], [ 0, %entry ]
+  br label %for.i.header
+
+for.i.header:
+  %i = phi i32 [ %i.inc, %for.i.latch ], [ 0, %for.j.header ]
+  br label %for.di.header
+
+for.di.header:
+  %di = phi i32 [ -1, %for.i.header ], [ %di.inc, %for.di.latch ]
+  %di.add = add nsw i32 %di, %i
+  br label %for.dj.header
+
+for.dj.header:
+  %dj = phi i32 [ -1, %for.di.header ], [ %dj.inc, %body ]
+  %dj.add = add nsw i32 %dj, %j
+  br label %while.x
+
+while.x:
+  %x = phi i32 [ %di.add, %for.dj.header ], [ %x.inc, %while.x ]
+  %x.cmp = icmp slt i32 %x, 0
+  %x.inc = add nsw i32 %x, %n
+  br i1 %x.cmp, label %while.x, label %while.y
+
+while.y:
+  %y = phi i32 [ %y.inc, %while.y ], [ %dj.add, %while.x ]
+  %y.cmp = icmp slt i32 %y, 0
+  %y.inc = add nsw i32 %y, %n
+  br i1 %y.cmp, label %while.y, label %body
+
+body:
+  %mul = mul nsw i32 %y, %n
+  %add = add nsw i32 %mul, %x
+  %idxprom = sext i32 %add to i64
+  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %idxprom
+; CHECK: da analyze - output [* * * *]
+  store i32 7, i32* %arrayidx, align 4
+  %dj.inc = add nsw i32 %dj, 1
+  %dj.exitcond = icmp eq i32 %dj.inc, 2
+  br i1 %dj.exitcond, label %for.di.latch, label %for.dj.header
+
+for.di.latch:
+  %di.inc = add nsw i32 %di, 1
+  %di.exitcond = icmp eq i32 %di.inc, 2
+  br i1 %di.exitcond, label %for.i.latch, label %for.di.header
+
+for.i.latch:
+  %i.inc = add nuw nsw i32 %i, 1
+  %i.exitcond = icmp eq i32 %i.inc, %n
+  br i1 %i.exitcond, label %for.j.latch, label %for.i.header
+
+for.j.latch:
+  %j.inc = add nuw nsw i32 %j, 1
+  %j.exitcond = icmp eq i32 %j.inc, %n
+  br i1 %j.exitcond, label %exit, label %for.j.header
+
+exit:
+  ret void
+}

Copy link
Collaborator

@sjoerdmeijer sjoerdmeijer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a test case is always a good thing, so LGTM.

One nit that can be addressed before merging this, some explanations/comments why we expect output [* * * *] would be nice.

@hiraditya hiraditya self-requested a review November 19, 2024 20:02
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a side note, it would be nice to add support for DA to update_analyze_test_checks.py, so we can use generated check lines.

; RUN: opt < %s -disable-output "-passes=print<da>" -aa-pipeline=basic-aa 2>&1 \
; RUN: | FileCheck %s

define void @foo(i32* nocapture %A, i32 %n) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
define void @foo(i32* nocapture %A, i32 %n) {
define void @foo(ptr nocapture %A, i32 %n) {

etc. Convert to opaque pointers please.

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, it would be nice to add a comment to the test to explain what it's guarding against, as it's not super obvious here (looking at the issue, it's a crash).

Make sure the testcase for this bug continues to work:
llvm#31196
%add10 = add nsw i32 %phi9, %phi
br label %bb11

bb11: ; preds = %bb11, %bb8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great to have more descriptive names, so it is easier to read the test and see the loop structure (e.g. loop.1.header for loop headers, %iv for inductions and so on

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just used opt -passes=metarenamer -S a.ll to prepare the testcase with more standard names. I guess we could improve the metarenamer to produce more readable BB and var names.

@sebpop sebpop merged commit 4479a22 into llvm:main Jan 29, 2025
9 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 29, 2025

LLVM Buildbot has detected a new failure on builder openmp-offload-amdgpu-runtime running on omp-vega20-0 while building llvm at step 7 "Add check check-offload".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/30/builds/14883

Here is the relevant piece of the build log for the reference
Step 7 (Add check check-offload) failure: test (failure)
******************** TEST 'libomptarget :: amdgcn-amd-amdhsa :: api/omp_host_call.c' FAILED ********************
Exit Code: 2

Command Output (stdout):
--
# RUN: at line 1
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/clang -fopenmp    -I /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test -I /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src  -nogpulib -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib  -fopenmp-targets=amdgcn-amd-amdhsa /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/api/omp_host_call.c -o /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/api/Output/omp_host_call.c.tmp /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a && /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/api/Output/omp_host_call.c.tmp | /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/FileCheck /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/api/omp_host_call.c
# executed command: /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/clang -fopenmp -I /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test -I /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -nogpulib -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib -fopenmp-targets=amdgcn-amd-amdhsa /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/api/omp_host_call.c -o /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/api/Output/omp_host_call.c.tmp /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a
# note: command had no output on stdout or stderr
# executed command: /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/api/Output/omp_host_call.c.tmp
# note: command had no output on stdout or stderr
# error: command failed with exit status: -11
# executed command: /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/FileCheck /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/api/omp_host_call.c
# .---command stderr------------
# | FileCheck error: '<stdin>' is empty.
# | FileCheck command line:  /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/FileCheck /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/api/omp_host_call.c
# `-----------------------------
# error: command failed with exit status: 2

--

********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 29, 2025

LLVM Buildbot has detected a new failure on builder openmp-offload-libc-amdgpu-runtime running on omp-vega20-1 while building llvm at step 7 "Add check check-offload".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/73/builds/12690

Here is the relevant piece of the build log for the reference
Step 7 (Add check check-offload) failure: 1200 seconds without output running [b'ninja', b'-j 32', b'check-offload'], attempting to kill
...
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/bug53727.cpp (995 of 1005)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/bug47654.cpp (996 of 1005)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/test_libc.cpp (997 of 1005)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/bug50022.cpp (998 of 1005)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/wtime.c (999 of 1005)
PASS: libomptarget :: x86_64-unknown-linux-gnu :: offloading/std_complex_arithmetic.cpp (1000 of 1005)
PASS: libomptarget :: x86_64-unknown-linux-gnu :: offloading/bug49021.cpp (1001 of 1005)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/complex_reduction.cpp (1002 of 1005)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/bug49021.cpp (1003 of 1005)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/std_complex_arithmetic.cpp (1004 of 1005)
command timed out: 1200 seconds without output running [b'ninja', b'-j 32', b'check-offload'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1235.417513

@sebpop sebpop deleted the da-3 branch January 30, 2025 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants