xref: /aosp_15_r20/external/llvm/test/DebugInfo/ARM/lowerbdgdeclare_vla.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt  -instcombine %s -S | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker;
3*9880d681SAndroid Build Coastguard Worker; Generate me from:
4*9880d681SAndroid Build Coastguard Worker; clang -cc1 -triple thumbv7-apple-ios7.0.0 -S -target-abi apcs-gnu -gdwarf-2 -Os test.c -o test.ll -emit-llvm
5*9880d681SAndroid Build Coastguard Worker; void run(float r)
6*9880d681SAndroid Build Coastguard Worker; {
7*9880d681SAndroid Build Coastguard Worker;   int count = r;
8*9880d681SAndroid Build Coastguard Worker;   float vla[count];
9*9880d681SAndroid Build Coastguard Worker;   vla[0] = r;
10*9880d681SAndroid Build Coastguard Worker;   for (int i = 0; i < count; i++)
11*9880d681SAndroid Build Coastguard Worker;     vla[i] /= r;
12*9880d681SAndroid Build Coastguard Worker; }
13*9880d681SAndroid Build Coastguard Worker; rdar://problem/15464571
14*9880d681SAndroid Build Coastguard Worker;
15*9880d681SAndroid Build Coastguard Worker; ModuleID = 'test.c'
16*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32"
17*9880d681SAndroid Build Coastguard Workertarget triple = "thumbv7-apple-ios8.0.0"
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind optsize readnone
20*9880d681SAndroid Build Coastguard Workerdefine void @run(float %r) #0 !dbg !4 {
21*9880d681SAndroid Build Coastguard Workerentry:
22*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.dbg.declare(metadata float %r, metadata !11, metadata !DIExpression()), !dbg !22
23*9880d681SAndroid Build Coastguard Worker  %conv = fptosi float %r to i32, !dbg !23
24*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.dbg.declare(metadata i32 %conv, metadata !12, metadata !DIExpression()), !dbg !23
25*9880d681SAndroid Build Coastguard Worker  %vla = alloca float, i32 %conv, align 4, !dbg !24
26*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.dbg.declare(metadata float* %vla, metadata !14, metadata !DIExpression(DW_OP_deref)), !dbg !24
27*9880d681SAndroid Build Coastguard Worker; The VLA alloca should be described by a dbg.declare:
28*9880d681SAndroid Build Coastguard Worker; CHECK: call void @llvm.dbg.declare(metadata float* %vla, metadata ![[VLA:.*]], metadata {{.*}})
29*9880d681SAndroid Build Coastguard Worker; The VLA alloca and following store into the array should not be lowered to like this:
30*9880d681SAndroid Build Coastguard Worker; CHECK-NOT:  call void @llvm.dbg.value(metadata float %r, i64 0, metadata ![[VLA]])
31*9880d681SAndroid Build Coastguard Worker; the backend interprets this as "vla has the location of %r".
32*9880d681SAndroid Build Coastguard Worker  store float %r, float* %vla, align 4, !dbg !25, !tbaa !26
33*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !18, metadata !DIExpression()), !dbg !30
34*9880d681SAndroid Build Coastguard Worker  %cmp8 = icmp sgt i32 %conv, 0, !dbg !30
35*9880d681SAndroid Build Coastguard Worker  br i1 %cmp8, label %for.body, label %for.end, !dbg !30
36*9880d681SAndroid Build Coastguard Worker
37*9880d681SAndroid Build Coastguard Workerfor.body:                                         ; preds = %entry, %for.body.for.body_crit_edge
38*9880d681SAndroid Build Coastguard Worker  %0 = phi float [ %.pre, %for.body.for.body_crit_edge ], [ %r, %entry ]
39*9880d681SAndroid Build Coastguard Worker  %i.09 = phi i32 [ %inc, %for.body.for.body_crit_edge ], [ 0, %entry ]
40*9880d681SAndroid Build Coastguard Worker  %arrayidx2 = getelementptr inbounds float, float* %vla, i32 %i.09, !dbg !31
41*9880d681SAndroid Build Coastguard Worker  %div = fdiv float %0, %r, !dbg !31
42*9880d681SAndroid Build Coastguard Worker  store float %div, float* %arrayidx2, align 4, !dbg !31, !tbaa !26
43*9880d681SAndroid Build Coastguard Worker  %inc = add nsw i32 %i.09, 1, !dbg !30
44*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.dbg.value(metadata i32 %inc, i64 0, metadata !18, metadata !DIExpression()), !dbg !30
45*9880d681SAndroid Build Coastguard Worker  %exitcond = icmp eq i32 %inc, %conv, !dbg !30
46*9880d681SAndroid Build Coastguard Worker  br i1 %exitcond, label %for.end, label %for.body.for.body_crit_edge, !dbg !30
47*9880d681SAndroid Build Coastguard Worker
48*9880d681SAndroid Build Coastguard Workerfor.body.for.body_crit_edge:                      ; preds = %for.body
49*9880d681SAndroid Build Coastguard Worker  %arrayidx2.phi.trans.insert = getelementptr inbounds float, float* %vla, i32 %inc
50*9880d681SAndroid Build Coastguard Worker  %.pre = load float, float* %arrayidx2.phi.trans.insert, align 4, !dbg !31, !tbaa !26
51*9880d681SAndroid Build Coastguard Worker  br label %for.body, !dbg !30
52*9880d681SAndroid Build Coastguard Worker
53*9880d681SAndroid Build Coastguard Workerfor.end:                                          ; preds = %for.body, %entry
54*9880d681SAndroid Build Coastguard Worker  ret void, !dbg !32
55*9880d681SAndroid Build Coastguard Worker}
56*9880d681SAndroid Build Coastguard Worker
57*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone
58*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.declare(metadata, metadata, metadata) #1
59*9880d681SAndroid Build Coastguard Worker
60*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone
61*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
62*9880d681SAndroid Build Coastguard Worker
63*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind optsize readnone "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
64*9880d681SAndroid Build Coastguard Workerattributes #1 = { nounwind readnone }
65*9880d681SAndroid Build Coastguard Worker
66*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0}
67*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!20, !33}
68*9880d681SAndroid Build Coastguard Worker!llvm.ident = !{!21}
69*9880d681SAndroid Build Coastguard Worker
70*9880d681SAndroid Build Coastguard Worker!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.4 ", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
71*9880d681SAndroid Build Coastguard Worker!1 = !DIFile(filename: "<unknown>", directory: "/Volumes/Data/radar/15464571")
72*9880d681SAndroid Build Coastguard Worker!2 = !{}
73*9880d681SAndroid Build Coastguard Worker!4 = distinct !DISubprogram(name: "run", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 2, file: !5, scope: !6, type: !7, variables: !10)
74*9880d681SAndroid Build Coastguard Worker!5 = !DIFile(filename: "test.c", directory: "/Volumes/Data/radar/15464571")
75*9880d681SAndroid Build Coastguard Worker!6 = !DIFile(filename: "test.c", directory: "/Volumes/Data/radar/15464571")
76*9880d681SAndroid Build Coastguard Worker!7 = !DISubroutineType(types: !8)
77*9880d681SAndroid Build Coastguard Worker!8 = !{null, !9}
78*9880d681SAndroid Build Coastguard Worker!9 = !DIBasicType(tag: DW_TAG_base_type, name: "float", size: 32, align: 32, encoding: DW_ATE_float)
79*9880d681SAndroid Build Coastguard Worker!10 = !{!11, !12, !14, !18}
80*9880d681SAndroid Build Coastguard Worker!11 = !DILocalVariable(name: "r", line: 1, arg: 1, scope: !4, file: !6, type: !9)
81*9880d681SAndroid Build Coastguard Worker!12 = !DILocalVariable(name: "count", line: 3, scope: !4, file: !6, type: !13)
82*9880d681SAndroid Build Coastguard Worker!13 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
83*9880d681SAndroid Build Coastguard Worker!14 = !DILocalVariable(name: "vla", line: 4, scope: !4, file: !6, type: !15)
84*9880d681SAndroid Build Coastguard Worker!15 = !DICompositeType(tag: DW_TAG_array_type, align: 32, baseType: !9, elements: !16)
85*9880d681SAndroid Build Coastguard Worker!16 = !{!17}
86*9880d681SAndroid Build Coastguard Worker!17 = !DISubrange(count: -1)
87*9880d681SAndroid Build Coastguard Worker!18 = !DILocalVariable(name: "i", line: 6, scope: !19, file: !6, type: !13)
88*9880d681SAndroid Build Coastguard Worker!19 = distinct !DILexicalBlock(line: 6, column: 0, file: !5, scope: !4)
89*9880d681SAndroid Build Coastguard Worker!20 = !{i32 2, !"Dwarf Version", i32 2}
90*9880d681SAndroid Build Coastguard Worker!21 = !{!"clang version 3.4 "}
91*9880d681SAndroid Build Coastguard Worker!22 = !DILocation(line: 1, scope: !4)
92*9880d681SAndroid Build Coastguard Worker!23 = !DILocation(line: 3, scope: !4)
93*9880d681SAndroid Build Coastguard Worker!24 = !DILocation(line: 4, scope: !4)
94*9880d681SAndroid Build Coastguard Worker!25 = !DILocation(line: 5, scope: !4)
95*9880d681SAndroid Build Coastguard Worker!26 = !{!27, !27, i64 0}
96*9880d681SAndroid Build Coastguard Worker!27 = !{!"float", !28, i64 0}
97*9880d681SAndroid Build Coastguard Worker!28 = !{!"omnipotent char", !29, i64 0}
98*9880d681SAndroid Build Coastguard Worker!29 = !{!"Simple C/C++ TBAA"}
99*9880d681SAndroid Build Coastguard Worker!30 = !DILocation(line: 6, scope: !19)
100*9880d681SAndroid Build Coastguard Worker!31 = !DILocation(line: 7, scope: !19)
101*9880d681SAndroid Build Coastguard Worker!32 = !DILocation(line: 8, scope: !4)
102*9880d681SAndroid Build Coastguard Worker!33 = !{i32 1, !"Debug Info Version", i32 3}
103