blob: 6ff696698be925a30af177768f6ef81051bf2fbf [file] [log] [blame]
Adrian Prantl8e10fdb2013-11-18 23:04:38 +00001; RUN: opt -instcombine %s -S | FileCheck %s
2;
3; Generate me from:
4; clang -cc1 -triple thumbv7-apple-ios7.0.0 -S -target-abi apcs-gnu -gdwarf-2 -Os test.c -o test.ll -emit-llvm
5; void run(float r)
6; {
7; int count = r;
8; float vla[count];
9; vla[0] = r;
10; for (int i = 0; i < count; i++)
11; vla[i] /= r;
12; }
13; rdar://problem/15464571
14;
15; ModuleID = 'test.c'
16target 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"
17target triple = "thumbv7-apple-ios8.0.0"
18
19; Function Attrs: nounwind optsize readnone
Peter Collingbourned4bff302015-11-05 22:03:56 +000020define void @run(float %r) #0 !dbg !4 {
Adrian Prantl8e10fdb2013-11-18 23:04:38 +000021entry:
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000022 tail call void @llvm.dbg.declare(metadata float %r, metadata !11, metadata !DIExpression()), !dbg !22
Adrian Prantl8e10fdb2013-11-18 23:04:38 +000023 %conv = fptosi float %r to i32, !dbg !23
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000024 tail call void @llvm.dbg.declare(metadata i32 %conv, metadata !12, metadata !DIExpression()), !dbg !23
Adrian Prantl8e10fdb2013-11-18 23:04:38 +000025 %vla = alloca float, i32 %conv, align 4, !dbg !24
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000026 tail call void @llvm.dbg.declare(metadata float* %vla, metadata !14, metadata !DIExpression(DW_OP_deref)), !dbg !24
Adrian Prantl8e10fdb2013-11-18 23:04:38 +000027; The VLA alloca should be described by a dbg.declare:
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000028; CHECK: call void @llvm.dbg.declare(metadata float* %vla, metadata ![[VLA:.*]], metadata {{.*}})
Adrian Prantl8e10fdb2013-11-18 23:04:38 +000029; The VLA alloca and following store into the array should not be lowered to like this:
Adrian Prantlabe04752017-07-28 20:21:02 +000030; CHECK-NOT: call void @llvm.dbg.value(metadata float %r, metadata ![[VLA]])
Adrian Prantl8e10fdb2013-11-18 23:04:38 +000031; the backend interprets this as "vla has the location of %r".
32 store float %r, float* %vla, align 4, !dbg !25, !tbaa !26
Adrian Prantlabe04752017-07-28 20:21:02 +000033 tail call void @llvm.dbg.value(metadata i32 0, metadata !18, metadata !DIExpression()), !dbg !30
Adrian Prantl8e10fdb2013-11-18 23:04:38 +000034 %cmp8 = icmp sgt i32 %conv, 0, !dbg !30
35 br i1 %cmp8, label %for.body, label %for.end, !dbg !30
36
37for.body: ; preds = %entry, %for.body.for.body_crit_edge
38 %0 = phi float [ %.pre, %for.body.for.body_crit_edge ], [ %r, %entry ]
39 %i.09 = phi i32 [ %inc, %for.body.for.body_crit_edge ], [ 0, %entry ]
David Blaikie79e6c742015-02-27 19:29:02 +000040 %arrayidx2 = getelementptr inbounds float, float* %vla, i32 %i.09, !dbg !31
Adrian Prantl8e10fdb2013-11-18 23:04:38 +000041 %div = fdiv float %0, %r, !dbg !31
42 store float %div, float* %arrayidx2, align 4, !dbg !31, !tbaa !26
43 %inc = add nsw i32 %i.09, 1, !dbg !30
Adrian Prantlabe04752017-07-28 20:21:02 +000044 tail call void @llvm.dbg.value(metadata i32 %inc, metadata !18, metadata !DIExpression()), !dbg !30
Adrian Prantl8e10fdb2013-11-18 23:04:38 +000045 %exitcond = icmp eq i32 %inc, %conv, !dbg !30
46 br i1 %exitcond, label %for.end, label %for.body.for.body_crit_edge, !dbg !30
47
48for.body.for.body_crit_edge: ; preds = %for.body
David Blaikie79e6c742015-02-27 19:29:02 +000049 %arrayidx2.phi.trans.insert = getelementptr inbounds float, float* %vla, i32 %inc
David Blaikiea79ac142015-02-27 21:17:42 +000050 %.pre = load float, float* %arrayidx2.phi.trans.insert, align 4, !dbg !31, !tbaa !26
Adrian Prantl8e10fdb2013-11-18 23:04:38 +000051 br label %for.body, !dbg !30
52
53for.end: ; preds = %for.body, %entry
54 ret void, !dbg !32
55}
56
57; Function Attrs: nounwind readnone
Adrian Prantl87b7eb92014-10-01 18:55:02 +000058declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
Adrian Prantl8e10fdb2013-11-18 23:04:38 +000059
60; Function Attrs: nounwind readnone
Adrian Prantlabe04752017-07-28 20:21:02 +000061declare void @llvm.dbg.value(metadata, metadata, metadata) #1
Adrian Prantl8e10fdb2013-11-18 23:04:38 +000062
63attributes #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" }
64attributes #1 = { nounwind readnone }
65
66!llvm.dbg.cu = !{!0}
Manman Ren409558f2013-11-22 21:49:45 +000067!llvm.module.flags = !{!20, !33}
Adrian Prantl8e10fdb2013-11-18 23:04:38 +000068!llvm.ident = !{!21}
69
Adrian Prantl75819ae2016-04-15 15:57:41 +000070!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)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000071!1 = !DIFile(filename: "<unknown>", directory: "/Volumes/Data/radar/15464571")
Duncan P. N. Exon Smith988a7f82015-03-27 20:46:33 +000072!2 = !{}
Shiva Chen2c864552018-05-09 02:40:45 +000073!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, retainedNodes: !10)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000074!5 = !DIFile(filename: "test.c", directory: "/Volumes/Data/radar/15464571")
75!6 = !DIFile(filename: "test.c", directory: "/Volumes/Data/radar/15464571")
76!7 = !DISubroutineType(types: !8)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000077!8 = !{null, !9}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000078!9 = !DIBasicType(tag: DW_TAG_base_type, name: "float", size: 32, align: 32, encoding: DW_ATE_float)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000079!10 = !{!11, !12, !14, !18}
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000080!11 = !DILocalVariable(name: "r", line: 1, arg: 1, scope: !4, file: !6, type: !9)
81!12 = !DILocalVariable(name: "count", line: 3, scope: !4, file: !6, type: !13)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000082!13 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000083!14 = !DILocalVariable(name: "vla", line: 4, scope: !4, file: !6, type: !15)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000084!15 = !DICompositeType(tag: DW_TAG_array_type, align: 32, baseType: !9, elements: !16)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000085!16 = !{!17}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000086!17 = !DISubrange(count: -1)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000087!18 = !DILocalVariable(name: "i", line: 6, scope: !19, file: !6, type: !13)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000088!19 = distinct !DILexicalBlock(line: 6, column: 0, file: !5, scope: !4)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000089!20 = !{i32 2, !"Dwarf Version", i32 2}
90!21 = !{!"clang version 3.4 "}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000091!22 = !DILocation(line: 1, scope: !4)
92!23 = !DILocation(line: 3, scope: !4)
93!24 = !DILocation(line: 4, scope: !4)
94!25 = !DILocation(line: 5, scope: !4)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000095!26 = !{!27, !27, i64 0}
96!27 = !{!"float", !28, i64 0}
97!28 = !{!"omnipotent char", !29, i64 0}
98!29 = !{!"Simple C/C++ TBAA"}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000099!30 = !DILocation(line: 6, scope: !19)
100!31 = !DILocation(line: 7, scope: !19)
101!32 = !DILocation(line: 8, scope: !4)
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000102!33 = !{i32 1, !"Debug Info Version", i32 3}