blob: 70991989038fee543114c14b9072e08590566542 [file] [log] [blame]
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -use-dbg-addr -passes='sroa<preserve-cfg>' -S < %s | FileCheck %s --check-prefixes=CHECK,CHECK-PRESERVE-CFG
; RUN: opt -use-dbg-addr -passes='sroa<modify-cfg>' -S < %s | FileCheck %s --check-prefixes=CHECK,CHECK-MODIFY-CFG
; ModuleID = '<stdin>'
source_filename = "newvars.c"
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc19.0.24215"
%struct.Pair = type { i32, i32 }
@pair = internal global %struct.Pair zeroinitializer
; Function Attrs: nounwind uwtable
define void @if_else(i32 %cond, i32 %a, i32 %b) !dbg !8 {
; CHECK-LABEL: @if_else(
; CHECK-NEXT: entry:
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[A:%.*]], metadata [[META20:![0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg [[DBG21:![0-9]+]]
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[B:%.*]], metadata [[META20]], metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32)), !dbg [[DBG21]]
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[COND:%.*]], 0, !dbg [[DBG22:![0-9]+]]
; CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]], !dbg [[DBG24:![0-9]+]]
; CHECK: if.then:
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 0, metadata [[META20]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg [[DBG21]]
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[A]], metadata [[META20]], metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32)), !dbg [[DBG21]]
; CHECK-NEXT: br label [[IF_END:%.*]], !dbg [[DBG25:![0-9]+]]
; CHECK: if.else:
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[B]], metadata [[META20]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg [[DBG21]]
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 0, metadata [[META20]], metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32)), !dbg [[DBG21]]
; CHECK-NEXT: br label [[IF_END]]
; CHECK: if.end:
; CHECK-NEXT: [[P_SROA_4_0:%.*]] = phi i32 [ [[A]], [[IF_THEN]] ], [ 0, [[IF_ELSE]] ], !dbg [[DBG27:![0-9]+]]
; CHECK-NEXT: [[P_SROA_0_0:%.*]] = phi i32 [ 0, [[IF_THEN]] ], [ [[B]], [[IF_ELSE]] ], !dbg [[DBG27]]
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[P_SROA_0_0]], metadata [[META20]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg [[DBG21]]
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[P_SROA_4_0]], metadata [[META20]], metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32)), !dbg [[DBG21]]
; CHECK-NEXT: store i32 [[P_SROA_0_0]], ptr @pair, align 4, !dbg [[DBG28:![0-9]+]]
; CHECK-NEXT: store i32 [[P_SROA_4_0]], ptr getelementptr inbounds (i8, ptr @pair, i64 4), align 4, !dbg [[DBG28]]
; CHECK-NEXT: ret void
;
entry:
%p = alloca %struct.Pair, align 4
call void @llvm.dbg.addr(metadata ptr %p, metadata !20, metadata !DIExpression()), !dbg !26
store i32 %a, ptr %p, align 4, !dbg !28
%y = getelementptr inbounds %struct.Pair, ptr %p, i32 0, i32 1, !dbg !34
store i32 %b, ptr %y, align 4, !dbg !35
%tobool = icmp ne i32 %cond, 0, !dbg !37
br i1 %tobool, label %if.then, label %if.else, !dbg !39
if.then: ; preds = %entry
store i32 0, ptr %p, align 4, !dbg !42
%y2 = getelementptr inbounds %struct.Pair, ptr %p, i32 0, i32 1, !dbg !43
store i32 %a, ptr %y2, align 4, !dbg !44
br label %if.end, !dbg !45
if.else: ; preds = %entry
store i32 %b, ptr %p, align 4, !dbg !48
%y4 = getelementptr inbounds %struct.Pair, ptr %p, i32 0, i32 1, !dbg !49
store i32 0, ptr %y4, align 4, !dbg !50
br label %if.end
if.end: ; preds = %if.else, %if.then
call void @llvm.memcpy.p0.p0.i64(ptr align 4 @pair, ptr align 4 %p, i64 8, i1 false), !dbg !51
ret void
}
; Function Attrs: argmemonly nounwind
declare void @llvm.memcpy.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1) #2
; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.addr(metadata, metadata, metadata)
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5, !6}
!llvm.ident = !{!7}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
!1 = !DIFile(filename: "newvars.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild")
!2 = !{}
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 2}
!6 = !{i32 7, !"PIC Level", i32 2}
!7 = !{!"clang version 6.0.0 "}
!8 = distinct !DISubprogram(name: "if_else", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !16)
!9 = !DISubroutineType(types: !10)
!10 = !{!11, !14, !14, !14}
!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Pair", file: !1, line: 1, size: 64, elements: !12)
!12 = !{!13, !15}
!13 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !11, file: !1, line: 1, baseType: !14, size: 32)
!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!15 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !11, file: !1, line: 1, baseType: !14, size: 32, offset: 32)
!16 = !{!17, !18, !19, !20}
!17 = !DILocalVariable(name: "b", arg: 3, scope: !8, file: !1, line: 2, type: !14)
!18 = !DILocalVariable(name: "a", arg: 2, scope: !8, file: !1, line: 2, type: !14)
!19 = !DILocalVariable(name: "cond", arg: 1, scope: !8, file: !1, line: 2, type: !14)
!20 = !DILocalVariable(name: "p", scope: !8, file: !1, line: 3, type: !11)
!22 = !DILocation(line: 2, column: 42, scope: !8)
!23 = !DILocation(line: 2, column: 35, scope: !8)
!24 = !DILocation(line: 2, column: 25, scope: !8)
!25 = !DILocation(line: 3, column: 3, scope: !8)
!26 = !DILocation(line: 3, column: 15, scope: !8)
!27 = !DILocation(line: 4, column: 5, scope: !8)
!28 = !DILocation(line: 4, column: 7, scope: !8)
!29 = !{!30, !31, i64 0}
!30 = !{!"Pair", !31, i64 0, !31, i64 4}
!31 = !{!"int", !32, i64 0}
!32 = !{!"omnipotent char", !33, i64 0}
!33 = !{!"Simple C/C++ TBAA"}
!34 = !DILocation(line: 5, column: 5, scope: !8)
!35 = !DILocation(line: 5, column: 7, scope: !8)
!36 = !{!30, !31, i64 4}
!37 = !DILocation(line: 6, column: 7, scope: !38)
!38 = distinct !DILexicalBlock(scope: !8, file: !1, line: 6, column: 7)
!39 = !DILocation(line: 6, column: 7, scope: !8)
!40 = !DILocation(line: 7, column: 7, scope: !41)
!41 = distinct !DILexicalBlock(scope: !38, file: !1, line: 6, column: 13)
!42 = !DILocation(line: 7, column: 9, scope: !41)
!43 = !DILocation(line: 8, column: 7, scope: !41)
!44 = !DILocation(line: 8, column: 9, scope: !41)
!45 = !DILocation(line: 9, column: 3, scope: !41)
!46 = !DILocation(line: 10, column: 7, scope: !47)
!47 = distinct !DILexicalBlock(scope: !38, file: !1, line: 9, column: 10)
!48 = !DILocation(line: 10, column: 9, scope: !47)
!49 = !DILocation(line: 11, column: 7, scope: !47)
!50 = !DILocation(line: 11, column: 9, scope: !47)
!51 = !DILocation(line: 13, column: 10, scope: !8)
!52 = !{i64 0, i64 4, !53, i64 4, i64 4, !53}
!53 = !{!31, !31, i64 0}
!54 = !DILocation(line: 14, column: 1, scope: !8)
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; CHECK-MODIFY-CFG: {{.*}}
; CHECK-PRESERVE-CFG: {{.*}}