| Adrian Prantl | 8e10fdb | 2013-11-18 23:04:38 +0000 | [diff] [blame] | 1 | ; 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' | 
|  | 16 | target 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 | target triple = "thumbv7-apple-ios8.0.0" | 
|  | 18 |  | 
|  | 19 | ; Function Attrs: nounwind optsize readnone | 
|  | 20 | define void @run(float %r) #0 { | 
|  | 21 | entry: | 
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 22 | tail call void @llvm.dbg.declare(metadata float %r, metadata !11, metadata !{!"0x102"}), !dbg !22 | 
| Adrian Prantl | 8e10fdb | 2013-11-18 23:04:38 +0000 | [diff] [blame] | 23 | %conv = fptosi float %r to i32, !dbg !23 | 
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 24 | tail call void @llvm.dbg.declare(metadata i32 %conv, metadata !12, metadata !{!"0x102"}), !dbg !23 | 
| Adrian Prantl | 8e10fdb | 2013-11-18 23:04:38 +0000 | [diff] [blame] | 25 | %vla = alloca float, i32 %conv, align 4, !dbg !24 | 
| Adrian Prantl | 5883af3 | 2015-01-19 17:57:29 +0000 | [diff] [blame] | 26 | tail call void @llvm.dbg.declare(metadata float* %vla, metadata !14, metadata !{!"0x102\006"}), !dbg !24 | 
| Adrian Prantl | 8e10fdb | 2013-11-18 23:04:38 +0000 | [diff] [blame] | 27 | ; The VLA alloca should be described by a dbg.declare: | 
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 28 | ; CHECK: call void @llvm.dbg.declare(metadata float* %vla, metadata ![[VLA:.*]], metadata {{.*}}) | 
| Adrian Prantl | 8e10fdb | 2013-11-18 23:04:38 +0000 | [diff] [blame] | 29 | ; The VLA alloca and following store into the array should not be lowered to like this: | 
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 30 | ; CHECK-NOT:  call void @llvm.dbg.value(metadata float %r, i64 0, metadata ![[VLA]]) | 
| Adrian Prantl | 8e10fdb | 2013-11-18 23:04:38 +0000 | [diff] [blame] | 31 | ; the backend interprets this as "vla has the location of %r". | 
|  | 32 | store float %r, float* %vla, align 4, !dbg !25, !tbaa !26 | 
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 33 | tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !18, metadata !{!"0x102"}), !dbg !30 | 
| Adrian Prantl | 8e10fdb | 2013-11-18 23:04:38 +0000 | [diff] [blame] | 34 | %cmp8 = icmp sgt i32 %conv, 0, !dbg !30 | 
|  | 35 | br i1 %cmp8, label %for.body, label %for.end, !dbg !30 | 
|  | 36 |  | 
|  | 37 | for.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 Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 40 | %arrayidx2 = getelementptr inbounds float, float* %vla, i32 %i.09, !dbg !31 | 
| Adrian Prantl | 8e10fdb | 2013-11-18 23:04:38 +0000 | [diff] [blame] | 41 | %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 | 
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 44 | tail call void @llvm.dbg.value(metadata i32 %inc, i64 0, metadata !18, metadata !{!"0x102"}), !dbg !30 | 
| Adrian Prantl | 8e10fdb | 2013-11-18 23:04:38 +0000 | [diff] [blame] | 45 | %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 |  | 
|  | 48 | for.body.for.body_crit_edge:                      ; preds = %for.body | 
| David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 49 | %arrayidx2.phi.trans.insert = getelementptr inbounds float, float* %vla, i32 %inc | 
| Adrian Prantl | 8e10fdb | 2013-11-18 23:04:38 +0000 | [diff] [blame] | 50 | %.pre = load float* %arrayidx2.phi.trans.insert, align 4, !dbg !31, !tbaa !26 | 
|  | 51 | br label %for.body, !dbg !30 | 
|  | 52 |  | 
|  | 53 | for.end:                                          ; preds = %for.body, %entry | 
|  | 54 | ret void, !dbg !32 | 
|  | 55 | } | 
|  | 56 |  | 
|  | 57 | ; Function Attrs: nounwind readnone | 
| Adrian Prantl | 87b7eb9 | 2014-10-01 18:55:02 +0000 | [diff] [blame] | 58 | declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 | 
| Adrian Prantl | 8e10fdb | 2013-11-18 23:04:38 +0000 | [diff] [blame] | 59 |  | 
|  | 60 | ; Function Attrs: nounwind readnone | 
| Adrian Prantl | 87b7eb9 | 2014-10-01 18:55:02 +0000 | [diff] [blame] | 61 | declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 | 
| Adrian Prantl | 8e10fdb | 2013-11-18 23:04:38 +0000 | [diff] [blame] | 62 |  | 
|  | 63 | attributes #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 | attributes #1 = { nounwind readnone } | 
|  | 65 |  | 
|  | 66 | !llvm.dbg.cu = !{!0} | 
| Manman Ren | 409558f | 2013-11-22 21:49:45 +0000 | [diff] [blame] | 67 | !llvm.module.flags = !{!20, !33} | 
| Adrian Prantl | 8e10fdb | 2013-11-18 23:04:38 +0000 | [diff] [blame] | 68 | !llvm.ident = !{!21} | 
|  | 69 |  | 
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 70 | !0 = !{!"0x11\0012\00clang version 3.4 \001\00\000\00\000", !1, !2, !2, !3, !2, !2} ; [ DW_TAG_compile_unit ] [/Volumes/Data/radar/15464571/<unknown>] [DW_LANG_C99] | 
|  | 71 | !1 = !{!"<unknown>", !"/Volumes/Data/radar/15464571"} | 
|  | 72 | !2 = !{i32 0} | 
|  | 73 | !3 = !{!4} | 
|  | 74 | !4 = !{!"0x2e\00run\00run\00\001\000\001\000\006\00256\001\002", !5, !6, !7, null, void (float)* @run, null, null, !10} ; [ DW_TAG_subprogram ] [line 1] [def] [scope 2] [run] | 
|  | 75 | !5 = !{!"test.c", !"/Volumes/Data/radar/15464571"} | 
|  | 76 | !6 = !{!"0x29", !5}          ; [ DW_TAG_file_type ] [/Volumes/Data/radar/15464571/test.c] | 
|  | 77 | !7 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !8, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] | 
|  | 78 | !8 = !{null, !9} | 
|  | 79 | !9 = !{!"0x24\00float\000\0032\0032\000\000\004", null, null} ; [ DW_TAG_base_type ] [float] [line 0, size 32, align 32, offset 0, enc DW_ATE_float] | 
|  | 80 | !10 = !{!11, !12, !14, !18} | 
|  | 81 | !11 = !{!"0x101\00r\0016777217\000", !4, !6, !9} ; [ DW_TAG_arg_variable ] [r] [line 1] | 
|  | 82 | !12 = !{!"0x100\00count\003\000", !4, !6, !13} ; [ DW_TAG_auto_variable ] [count] [line 3] | 
|  | 83 | !13 = !{!"0x24\00int\000\0032\0032\000\000\005", null, null} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] | 
| Adrian Prantl | 5883af3 | 2015-01-19 17:57:29 +0000 | [diff] [blame] | 84 | !14 = !{!"0x100\00vla\004\000", !4, !6, !15} ; [ DW_TAG_auto_variable ] [vla] [line 4] | 
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 85 | !15 = !{!"0x1\00\000\000\0032\000\000", null, null, !9, !16, i32 0, null, null, null} ; [ DW_TAG_array_type ] [line 0, size 0, align 32, offset 0] [from float] | 
|  | 86 | !16 = !{!17} | 
|  | 87 | !17 = !{!"0x21\000\00-1"}       ; [ DW_TAG_subrange_type ] [unbounded] | 
|  | 88 | !18 = !{!"0x100\00i\006\000", !19, !6, !13} ; [ DW_TAG_auto_variable ] [i] [line 6] | 
|  | 89 | !19 = !{!"0xb\006\000\000", !5, !4} ; [ DW_TAG_lexical_block ] [/Volumes/Data/radar/15464571/test.c] | 
|  | 90 | !20 = !{i32 2, !"Dwarf Version", i32 2} | 
|  | 91 | !21 = !{!"clang version 3.4 "} | 
| Duncan P. N. Exon Smith | 9885469 | 2015-01-14 22:27:36 +0000 | [diff] [blame] | 92 | !22 = !MDLocation(line: 1, scope: !4) | 
|  | 93 | !23 = !MDLocation(line: 3, scope: !4) | 
|  | 94 | !24 = !MDLocation(line: 4, scope: !4) | 
|  | 95 | !25 = !MDLocation(line: 5, scope: !4) | 
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 96 | !26 = !{!27, !27, i64 0} | 
|  | 97 | !27 = !{!"float", !28, i64 0} | 
|  | 98 | !28 = !{!"omnipotent char", !29, i64 0} | 
|  | 99 | !29 = !{!"Simple C/C++ TBAA"} | 
| Duncan P. N. Exon Smith | 9885469 | 2015-01-14 22:27:36 +0000 | [diff] [blame] | 100 | !30 = !MDLocation(line: 6, scope: !19) | 
|  | 101 | !31 = !MDLocation(line: 7, scope: !19) | 
|  | 102 | !32 = !MDLocation(line: 8, scope: !4) | 
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 103 | !33 = !{i32 1, !"Debug Info Version", i32 2} |