2016-08-03 04:58:24 +08:00
|
|
|
; Verify functionality of NVPTXGenericToNVVM.cpp pass.
|
|
|
|
;
|
2017-11-03 07:44:20 +08:00
|
|
|
; RUN: opt < %s -march nvptx64 -S -generic-to-nvvm | FileCheck %s
|
2016-08-03 04:58:24 +08:00
|
|
|
|
|
|
|
target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
|
|
|
|
target triple = "nvptx64-nvidia-cuda"
|
|
|
|
|
|
|
|
; Generic space variables should be converted to global space AKA addrspace(1).
|
|
|
|
; CHECK-DAG: @static_var = {{.*}}addrspace(1)
|
2016-09-13 09:12:59 +08:00
|
|
|
@static_var = externally_initialized global i8 0, align 1, !dbg !4
|
2016-08-03 04:58:24 +08:00
|
|
|
; CHECK-DAG: @.str = {{.*}}addrspace(1)
|
|
|
|
@.str = private unnamed_addr constant [4 x i8] c"XXX\00", align 1
|
|
|
|
|
|
|
|
; Function Attrs: convergent
|
|
|
|
define void @func() !dbg !8 {
|
|
|
|
;CHECK-LABEL: @func()
|
|
|
|
;CHECK-SAME: !dbg [[FUNCNODE:![0-9]+]]
|
|
|
|
entry:
|
2018-03-01 07:57:48 +08:00
|
|
|
; References to the variables must be converted back to generic address space.
|
|
|
|
; CHECK-DAG: addrspacecast ([4 x i8] addrspace(1)* @.str to [4 x i8]*)
|
2016-08-03 04:58:24 +08:00
|
|
|
%0 = load i8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), align 1
|
|
|
|
call void @extfunc(i8 signext %0)
|
2018-03-01 07:57:48 +08:00
|
|
|
; CHECK-DAG: addrspacecast (i8 addrspace(1)* @static_var to i8*)
|
2016-08-03 04:58:24 +08:00
|
|
|
%1 = load i8, i8* @static_var, align 1
|
|
|
|
call void @extfunc(i8 signext %1)
|
|
|
|
ret void
|
|
|
|
; CHECK: ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @extfunc(i8 signext)
|
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
|
|
; CHECK: !llvm.dbg.cu = !{[[CUNODE:![0-9]+]]}
|
|
|
|
!llvm.module.flags = !{!6, !7}
|
|
|
|
|
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1,
|
|
|
|
producer: "clang version 4.0.0",
|
|
|
|
isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3)
|
|
|
|
; CHECK: [[CUNODE]] = distinct !DICompileUnit({{.*}} globals: [[GLOBALSNODE:![0-9]+]]
|
|
|
|
!1 = !DIFile(filename: "foo.cu", directory: "/usr/local/google/home/tra/work/llvm/build/gpu/debug")
|
|
|
|
!2 = !{}
|
|
|
|
!3 = !{!4}
|
|
|
|
; Find list of global variables and make sure it's the one used by DICompileUnit
|
|
|
|
; CHECK: [[GLOBALSNODE]] = !{[[GVNODE:![0-9]+]]}
|
2017-08-31 02:06:51 +08:00
|
|
|
!4 = !DIGlobalVariableExpression(var: !DIGlobalVariable(name: "static_var", scope: !0, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true), expr: !DIExpression())
|
2016-08-03 04:58:24 +08:00
|
|
|
; Debug info must also be updated to reflect new address space.
|
2017-08-31 02:06:51 +08:00
|
|
|
; CHECK: [[GVNODE]] = !DIGlobalVariableExpression(var: [[GVVAR:.*]], expr: !DIExpression())
|
2016-12-20 10:09:43 +08:00
|
|
|
; CHECK: [[GVVAR]] = !DIGlobalVariable(name: "static_var"
|
2016-08-03 04:58:24 +08:00
|
|
|
; CHECK-SAME: scope: [[CUNODE]]
|
|
|
|
; CHECK-SAME: type: [[TYPENODE:![0-9]+]]
|
|
|
|
!5 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
|
|
|
|
; CHECK: [[TYPENODE]] = !DIBasicType(name: "char"
|
|
|
|
!6 = !{i32 2, !"Dwarf Version", i32 4}
|
|
|
|
!7 = !{i32 2, !"Debug Info Version", i32 3}
|
|
|
|
!8 = distinct !DISubprogram(name: "foo", linkageName: "func",
|
|
|
|
scope: !1, file: !1, line: 3, type: !9, isLocal: false, isDefinition: true, scopeLine: 3,
|
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
|
|
|
flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
|
2016-08-03 04:58:24 +08:00
|
|
|
; CHECK: [[FUNCNODE]] = distinct !DISubprogram(name: "foo",
|
|
|
|
; CHECK-SAME: type: [[STYPENODE:![0-9]+]]
|
|
|
|
; CHECK-SAME: unit: [[CUNODE]],
|
|
|
|
!9 = !DISubroutineType(types: !10)
|
|
|
|
; CHECK: [[STYPENODE]] = !DISubroutineType
|
|
|
|
!10 = !{null}
|