1 ; Verify functionality of NVPTXGenericToNVVM.cpp pass.
3 ; RUN: opt < %s -march nvptx64 -S -generic-to-nvvm | FileCheck %s
5 target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
6 target triple = "nvptx64-nvidia-cuda"
8 ; Generic space variables should be converted to global space AKA addrspace(1).
9 ; CHECK-DAG: @static_var = {{.*}}addrspace(1)
10 @static_var = externally_initialized global i8 0, align 1, !dbg !4
11 ; CHECK-DAG: @.str = {{.*}}addrspace(1)
12 @.str = private unnamed_addr constant [4 x i8] c"XXX\00", align 1
14 ; Function Attrs: convergent
15 define void @func() !dbg !8 {
17 ;CHECK-SAME: !dbg [[FUNCNODE:![0-9]+]]
19 ; References to the variables must be converted back to generic address space.
20 ; CHECK-DAG: addrspacecast ([4 x i8] addrspace(1)* @.str to [4 x i8]*)
21 %0 = load i8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), align 1
22 call void @extfunc(i8 signext %0)
23 ; CHECK-DAG: addrspacecast (i8 addrspace(1)* @static_var to i8*)
24 %1 = load i8, i8* @static_var, align 1
25 call void @extfunc(i8 signext %1)
30 declare void @extfunc(i8 signext)
33 ; CHECK: !llvm.dbg.cu = !{[[CUNODE:![0-9]+]]}
34 !llvm.module.flags = !{!6, !7}
36 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1,
37 producer: "clang version 4.0.0",
38 isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3)
39 ; CHECK: [[CUNODE]] = distinct !DICompileUnit({{.*}} globals: [[GLOBALSNODE:![0-9]+]]
40 !1 = !DIFile(filename: "foo.cu", directory: "/usr/local/google/home/tra/work/llvm/build/gpu/debug")
43 ; Find list of global variables and make sure it's the one used by DICompileUnit
44 ; CHECK: [[GLOBALSNODE]] = !{[[GVNODE:![0-9]+]]}
45 !4 = !DIGlobalVariableExpression(var: !DIGlobalVariable(name: "static_var", scope: !0, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true), expr: !DIExpression())
46 ; Debug info must also be updated to reflect new address space.
47 ; CHECK: [[GVNODE]] = !DIGlobalVariableExpression(var: [[GVVAR:.*]], expr: !DIExpression())
48 ; CHECK: [[GVVAR]] = !DIGlobalVariable(name: "static_var"
49 ; CHECK-SAME: scope: [[CUNODE]]
50 ; CHECK-SAME: type: [[TYPENODE:![0-9]+]]
51 !5 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
52 ; CHECK: [[TYPENODE]] = !DIBasicType(name: "char"
53 !6 = !{i32 2, !"Dwarf Version", i32 4}
54 !7 = !{i32 2, !"Debug Info Version", i32 3}
55 !8 = distinct !DISubprogram(name: "foo", linkageName: "func",
56 scope: !1, file: !1, line: 3, type: !9, isLocal: false, isDefinition: true, scopeLine: 3,
57 flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
58 ; CHECK: [[FUNCNODE]] = distinct !DISubprogram(name: "foo",
59 ; CHECK-SAME: type: [[STYPENODE:![0-9]+]]
60 ; CHECK-SAME: unit: [[CUNODE]],
61 !9 = !DISubroutineType(types: !10)
62 ; CHECK: [[STYPENODE]] = !DISubroutineType