64 lines · plain
1; Verify functionality of NVPTXGenericToNVVM.cpp pass.2;3; RUN: opt < %s -march nvptx64 -S -generic-to-nvvm | FileCheck %s4; RUN: opt < %s -march nvptx64 -S -passes='generic-to-nvvm' | FileCheck %s5 6target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"7target triple = "nvptx64-nvidia-cuda"8 9; Generic space variables should be converted to global space AKA addrspace(1).10; The debug info reference should be preserved.11; CHECK-DAG: @static_var = {{.*}}addrspace(1) {{.*}} !dbg !{{[0-9]+}}12@static_var = externally_initialized global i8 0, align 1, !dbg !413; CHECK-DAG: @.str = {{.*}}addrspace(1)14@.str = private unnamed_addr constant [4 x i8] c"XXX\00", align 115 16; Function Attrs: convergent17define void @func() !dbg !8 {18;CHECK-LABEL: @func()19;CHECK-SAME: !dbg [[FUNCNODE:![0-9]+]]20entry:21; References to the variables must be converted back to generic address space.22; CHECK-DAG: addrspacecast (ptr addrspace(1) @.str to ptr)23 %0 = load i8, ptr @.str, align 124 call void @extfunc(i8 signext %0)25; CHECK-DAG: addrspacecast (ptr addrspace(1) @static_var to ptr)26 %1 = load i8, ptr @static_var, align 127 call void @extfunc(i8 signext %1)28 ret void29; CHECK: ret void30}31 32declare void @extfunc(i8 signext)33 34!llvm.dbg.cu = !{!0}35; CHECK: !llvm.dbg.cu = !{[[CUNODE:![0-9]+]]}36!llvm.module.flags = !{!6, !7}37 38!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1,39 producer: "clang version 4.0.0",40 isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3)41; CHECK-DAG: [[CUNODE]] = distinct !DICompileUnit({{.*}} globals: [[GLOBALSNODE:![0-9]+]]42!1 = !DIFile(filename: "foo.cu", directory: "/usr/local/google/home/tra/work/llvm/build/gpu/debug")43!2 = !{}44!3 = !{!4}45; Find list of global variables and make sure it's the one used by DICompileUnit46; CHECK-DAG: [[GLOBALSNODE]] = !{[[GVNODE:![0-9]+]]}47!4 = !DIGlobalVariableExpression(var: !DIGlobalVariable(name: "static_var", scope: !0, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true), expr: !DIExpression())48; Debug info must be updated to reflect new address space.49; CHECK-DAG: [[GVNODE]] = !DIGlobalVariableExpression(var: [[GVVAR:.*]], expr: !DIExpression())50; CHECK-DAG: [[GVVAR]] = !DIGlobalVariable(name: "static_var", scope: [[CUNODE]],{{.*}} 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]] = !DISubroutineType63!10 = !{null}64