xref: /llvm-project/llvm/test/CodeGen/NVPTX/nvvm-annotations-D120129.ll (revision ef8655adc8e025f1614c8540a791560f1a2a6bbc)
1; RUN: llc < %s -mtriple=nvptx64-unknown-unknown | FileCheck %s
2; RUN: %if ptxas %{ llc < %s -mtriple=nvptx64-unknown-unknown | %ptxas-verify %}
3;
4; NVPTXTargetLowering::getFunctionParamOptimizedAlign, which was introduces in
5; D120129, contained a poorly designed assertion checking that a function with
6; internal or private linkage is not a kernel. It relied on invariants that
7; were not actually guaranteed, and that resulted in compiler crash with some
8; CUDA versions (see discussion with @jdoerfert in D120129). This test contains
9; metadata that caused compiler crash and a function with internal linkage
10; which purpose is to let compiler run on path where the crash happened.
11; Metadata was obtained from libdevice.10.bc shipped with cuda-11-0.
12
13
14define internal i32 @foo() {
15  ; CHECK-LABEL: .func (.param .b32 func_retval0) foo()
16  ret i32 42
17}
18
19define i32 @bar() {
20  ; CHECK-LABEL: .visible .func (.param .b32 func_retval0) bar()
21  %x = call i32 @foo()
22  ret i32 %x
23}
24
25!nvvmir.version = !{!0}
26!nvvm.annotations = !{!1, !2, !1, !3, !3, !3, !3, !4, !4, !3}
27
28!0 = !{i32 1, i32 4}
29!1 = !{null, !"align", i32 8}
30!2 = !{null, !"align", i32 8, !"align", i32 65544, !"align", i32 131080}
31!3 = !{null, !"align", i32 16}
32!4 = !{null, !"align", i32 16, !"align", i32 65552, !"align", i32 131088}
33!5 = distinct !{!5, !6}
34!6 = !{!"llvm.loop.unroll.count", i32 1}
35!7 = distinct !{!7, !6}
36