1 ; RUN: opt %loadPolly %s -polly-process-unprofitable -polly-codegen-ppcg -polly-acc-dump-kernel-ir \
2 ; RUN: | FileCheck --check-prefix=KERNEL-IR %s
6 ; KERNEL-IR: define ptx_kernel void @FUNC_vec_add_1_SCOP_0_KERNEL_0(i8 addrspace(1)* %MemRef_arr, i32 %N) #0 {
8 ; The instruction marked <<<LeakyInst>>> is copied into the GPUModule,
9 ; with changes only to the parameters to access data on the device instead of
10 ; the host, i.e., MemRef_arr becomes polly.access.cast.MemRef_arr. Since the
11 ; instruction is annotated with a DILocation, copying the instruction also copies
12 ; the metadata into the GPUModule. This stops codegenerating the ptx_kernel by
13 ; failing the verification of the Module in GPUNodeBuilder::finalize, due to the
14 ; copied DICompileUnit not being listed in a llvm.dbg.cu which was neither copied
17 ; https://reviews.llvm.org/D35630 removes this debug metadata before the
18 ; instruction is copied to the GPUModule.
21 ; void vec_add_1(int N, int arr[N]) {
23 ; for( i=0 ; i<N ; i++) arr[i] += 1;
26 source_filename = "vec_add_1.c"
27 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
28 target triple = "x86_64-unknown-linux-gnu"
30 define void @vec_add_1(i32 %N, i32* %arr) !dbg !7 {
32 call void @llvm.dbg.value(metadata i32 %N, i64 0, metadata !13, metadata !16), !dbg !17
33 call void @llvm.dbg.value(metadata i32* %arr, i64 0, metadata !14, metadata !16), !dbg !18
34 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !15, metadata !16), !dbg !19
35 %tmp = sext i32 %N to i64, !dbg !20
36 br label %for.cond, !dbg !20
38 for.cond: ; preds = %for.inc, %entry
39 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
40 call void @llvm.dbg.value(metadata i32 undef, i64 0, metadata !15, metadata !16), !dbg !19
41 %cmp = icmp slt i64 %indvars.iv, %tmp, !dbg !22
42 br i1 %cmp, label %for.body, label %for.end, !dbg !24
44 for.body: ; preds = %for.cond
45 %arrayidx = getelementptr inbounds i32, i32* %arr, i64 %indvars.iv, !dbg !25
46 %tmp1 = load i32, i32* %arrayidx, align 4, !dbg !26, !tbaa !27
47 %add = add nsw i32 %tmp1, 1, !dbg !26 ; <<<LeakyInst>>>
48 store i32 %add, i32* %arrayidx, align 4, !dbg !26, !tbaa !27
49 br label %for.inc, !dbg !25
51 for.inc: ; preds = %for.body
52 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !31
53 call void @llvm.dbg.value(metadata !2, i64 0, metadata !15, metadata !16), !dbg !19
54 br label %for.cond, !dbg !32, !llvm.loop !33
56 for.end: ; preds = %for.cond
60 declare void @llvm.dbg.declare(metadata, metadata, metadata)
62 declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
66 !llvm.module.flags = !{!3, !4, !5}
69 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 5.0.0 (http://llvm.org/git/clang.git 23e042ffe07a923db2dbebf4d2a3692c5a454fee) (http://llvm.org/git/llvm.git 39c5686a1f54884f12120927b1753a750fdb5e02)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
70 !1 = !DIFile(filename: "vec_add_1.c", directory: "/tmp")
72 !3 = !{i32 2, !"Dwarf Version", i32 4}
73 !4 = !{i32 2, !"Debug Info Version", i32 3}
74 !5 = !{i32 1, !"wchar_size", i32 4}
75 !6 = !{!"clang version 5.0.0 (http://llvm.org/git/clang.git 23e042ffe07a923db2dbebf4d2a3692c5a454fee) (http://llvm.org/git/llvm.git 39c5686a1f54884f12120927b1753a750fdb5e02)"}
76 !7 = distinct !DISubprogram(name: "vec_add_1", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !12)
77 !8 = !DISubroutineType(types: !9)
78 !9 = !{null, !10, !11}
79 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
80 !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)
81 !12 = !{!13, !14, !15}
82 !13 = !DILocalVariable(name: "N", arg: 1, scope: !7, file: !1, line: 1, type: !10)
83 !14 = !DILocalVariable(name: "arr", arg: 2, scope: !7, file: !1, line: 1, type: !11)
84 !15 = !DILocalVariable(name: "i", scope: !7, file: !1, line: 2, type: !10)
86 !17 = !DILocation(line: 1, column: 20, scope: !7)
87 !18 = !DILocation(line: 1, column: 27, scope: !7)
88 !19 = !DILocation(line: 2, column: 7, scope: !7)
89 !20 = !DILocation(line: 3, column: 8, scope: !21)
90 !21 = distinct !DILexicalBlock(scope: !7, file: !1, line: 3, column: 3)
91 !22 = !DILocation(line: 3, column: 15, scope: !23)
92 !23 = distinct !DILexicalBlock(scope: !21, file: !1, line: 3, column: 3)
93 !24 = !DILocation(line: 3, column: 3, scope: !21)
94 !25 = !DILocation(line: 3, column: 25, scope: !23)
95 !26 = !DILocation(line: 3, column: 32, scope: !23)
96 !27 = !{!28, !28, i64 0}
97 !28 = !{!"int", !29, i64 0}
98 !29 = !{!"omnipotent char", !30, i64 0}
99 !30 = !{!"Simple C/C++ TBAA"}
100 !31 = !DILocation(line: 3, column: 21, scope: !23)
101 !32 = !DILocation(line: 3, column: 3, scope: !23)
102 !33 = distinct !{!33, !24, !34}
103 !34 = !DILocation(line: 3, column: 35, scope: !21)
104 !35 = !DILocation(line: 4, column: 1, scope: !7)