200 lines · plain
1; RUN: opt -S -p globalopt < %s | FileCheck %s2 3;; Generated at -g from:4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5;;MODULE mymod6;; IMPLICIT NONE7;; INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(14, 200)8;;CONTAINS9;; FUNCTION foo(arg)10;; REAL(KIND=dp), DIMENSION(3, 3), INTENT(IN) :: arg11;; INTEGER, DIMENSION(3) :: foo12;; foo = bar(arg)13;; END FUNCTION foo14;; FUNCTION bar(arg)15;; REAL(KIND=dp), DIMENSION(3, 3), INTENT(IN) :: arg16;; INTEGER, DIMENSION(3) :: bar17;; REAL(KIND=dp) :: rvar(3)18;; rvar = arg(1,:)19;; IF(rvar(1) == 0._dp) print *,"IF"20;; bar = FLOOR(rvar)21;; END FUNCTION bar22;;END MODULE mymod23;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;24 25%struct.BSS3 = type <{ [24 x i8] }>26 27@.BSS3 = internal unnamed_addr global %struct.BSS3 zeroinitializer, align 32, !dbg !0, !dbg !7, !dbg !2928;CHECK: @.BSS3.0 = internal unnamed_addr global double 0.000000e+00, align 32, !dbg ![[GVE1:.*]], !dbg ![[GVE2:.*]]29;CHECK: @.BSS3.1 = internal unnamed_addr global double 0.000000e+00, align 8, !dbg ![[GVE3:.*]], !dbg ![[GVE4:.*]], !dbg ![[GVE6:.*]]30;CHECK: @.BSS3.2 = internal unnamed_addr global double 0.000000e+00, align 16, !dbg ![[GVE5:.*]]31 32@.C363_mymod_bar_ = internal constant [2 x i8] c"IF"33@.C330_mymod_bar_ = internal constant i32 034@.C360_mymod_bar_ = internal constant i32 635@.C357_mymod_bar_ = internal constant [9 x i8] c"frag1.f90"36@.C359_mymod_bar_ = internal constant i32 1537 38define float @mymod_() local_unnamed_addr {39.L.entry:40 ret float undef41}42 43define void @mymod_foo_(ptr noalias nocapture writeonly %foo, ptr noalias nocapture readonly %arg) local_unnamed_addr !dbg !22 {44L.entry:45 tail call void @llvm.experimental.noalias.scope.decl(metadata !23)46 tail call void @llvm.experimental.noalias.scope.decl(metadata !26)47 %0 = bitcast ptr %arg to ptr48 %1 = load double, ptr %0, align 8, !noalias !2349 store double %1, ptr @.BSS3, align 32, !noalias !2850 %2 = getelementptr i64, ptr %arg, i64 351 %3 = bitcast ptr %2 to ptr52 %4 = load double, ptr %3, align 8, !alias.scope !26, !noalias !2353 store double %4, ptr getelementptr inbounds (%struct.BSS3, ptr @.BSS3, i64 0, i32 0, i64 8), align 8, !noalias !2854 %5 = getelementptr i64, ptr %arg, i64 655 %6 = bitcast ptr %5 to ptr56 %7 = load double, ptr %6, align 8, !alias.scope !26, !noalias !2357 store double %7, ptr getelementptr inbounds (%struct.BSS3, ptr @.BSS3, i64 0, i32 0, i64 16), align 16, !noalias !2858 %8 = fcmp une double %1, 0.000000e+0059 br i1 %8, label %L.LB3_377.i, label %L.LB3_417.i60 61L.LB3_417.i: ; preds = %L.entry62 tail call void (ptr, ptr, i64, ...) @f90io_src_info03a(ptr @.C359_mymod_bar_, ptr @.C357_mymod_bar_, i64 9), !noalias !2863 %9 = tail call i32 (ptr, ptr, ptr, ptr, ...) @f90io_print_init(ptr @.C360_mymod_bar_, ptr null, ptr @.C330_mymod_bar_, ptr @.C330_mymod_bar_), !noalias !2864 %10 = tail call i32 (ptr, i32, i64, ...) @f90io_sc_ch_ldw(ptr @.C363_mymod_bar_, i32 14, i64 2), !noalias !2865 %11 = tail call i32 (...) @f90io_ldw_end(), !noalias !2866 %.pre = load double, ptr @.BSS3, align 32, !noalias !2867 %.pre1 = load double, ptr getelementptr inbounds (%struct.BSS3, ptr @.BSS3, i64 0, i32 0, i64 8), align 8, !noalias !2868 %.pre2 = load double, ptr getelementptr inbounds (%struct.BSS3, ptr @.BSS3, i64 0, i32 0, i64 16), align 16, !noalias !2869 br label %L.LB3_377.i70 71L.LB3_377.i: ; preds = %L.LB3_417.i, %L.entry72 %12 = phi double [ %.pre2, %L.LB3_417.i ], [ %7, %L.entry ]73 %13 = phi double [ %.pre1, %L.LB3_417.i ], [ %4, %L.entry ]74 %14 = phi double [ %.pre, %L.LB3_417.i ], [ %1, %L.entry ]75 %15 = bitcast ptr %foo to ptr76 %16 = tail call double @llvm.floor.f64(double %14)77 %17 = fptosi double %16 to i3278 %18 = bitcast ptr %foo to ptr79 store i32 %17, ptr %18, align 4, !alias.scope !23, !noalias !2680 %19 = tail call double @llvm.floor.f64(double %13)81 %20 = fptosi double %19 to i3282 %21 = getelementptr i8, ptr %15, i64 483 %22 = bitcast ptr %21 to ptr84 store i32 %20, ptr %22, align 4, !alias.scope !23, !noalias !2685 %23 = tail call double @llvm.floor.f64(double %12)86 %24 = fptosi double %23 to i3287 %25 = getelementptr i64, ptr %foo, i64 188 %26 = bitcast ptr %25 to ptr89 store i32 %24, ptr %26, align 4, !alias.scope !23, !noalias !2690 ret void91}92 93define void @mymod_bar_(ptr noalias nocapture writeonly %bar, ptr noalias nocapture readonly %arg) local_unnamed_addr !dbg !9 {94L.entry:95 %0 = bitcast ptr %arg to ptr96 %1 = load double, ptr %0, align 897 store double %1, ptr @.BSS3, align 3298 %2 = getelementptr i64, ptr %arg, i64 399 %3 = bitcast ptr %2 to ptr100 %4 = load double, ptr %3, align 8101 store double %4, ptr getelementptr inbounds (%struct.BSS3, ptr @.BSS3, i64 0, i32 0, i64 8), align 8102 %5 = getelementptr i64, ptr %arg, i64 6103 %6 = bitcast ptr %5 to ptr104 %7 = load double, ptr %6, align 8105 store double %7, ptr getelementptr inbounds (%struct.BSS3, ptr @.BSS3, i64 0, i32 0, i64 16), align 16106 %8 = fcmp une double %1, 0.000000e+00107 br i1 %8, label %L.LB3_377, label %L.LB3_417108 109L.LB3_417: ; preds = %L.entry110 tail call void (ptr, ptr, i64, ...) @f90io_src_info03a(ptr @.C359_mymod_bar_, ptr @.C357_mymod_bar_, i64 9)111 %9 = tail call i32 (ptr, ptr, ptr, ptr, ...) @f90io_print_init(ptr @.C360_mymod_bar_, ptr null, ptr @.C330_mymod_bar_, ptr @.C330_mymod_bar_)112 %10 = tail call i32 (ptr, i32, i64, ...) @f90io_sc_ch_ldw(ptr @.C363_mymod_bar_, i32 14, i64 2)113 %11 = tail call i32 (...) @f90io_ldw_end()114 %.pre = load double, ptr @.BSS3, align 32115 %.pre1 = load double, ptr getelementptr inbounds (%struct.BSS3, ptr @.BSS3, i64 0, i32 0, i64 8), align 8116 %.pre2 = load double, ptr getelementptr inbounds (%struct.BSS3, ptr @.BSS3, i64 0, i32 0, i64 16), align 16117 br label %L.LB3_377118 119L.LB3_377: ; preds = %L.LB3_417, %L.entry120 %12 = phi double [ %.pre2, %L.LB3_417 ], [ %7, %L.entry ]121 %13 = phi double [ %.pre1, %L.LB3_417 ], [ %4, %L.entry ]122 %14 = phi double [ %.pre, %L.LB3_417 ], [ %1, %L.entry ]123 %15 = bitcast ptr %bar to ptr124 %16 = tail call double @llvm.floor.f64(double %14)125 %17 = fptosi double %16 to i32126 %18 = bitcast ptr %bar to ptr127 store i32 %17, ptr %18, align 4128 %19 = tail call double @llvm.floor.f64(double %13)129 %20 = fptosi double %19 to i32130 %21 = getelementptr i8, ptr %15, i64 4131 %22 = bitcast ptr %21 to ptr132 store i32 %20, ptr %22, align 4133 %23 = tail call double @llvm.floor.f64(double %12)134 %24 = fptosi double %23 to i32135 %25 = getelementptr i64, ptr %bar, i64 1136 %26 = bitcast ptr %25 to ptr137 store i32 %24, ptr %26, align 4138 ret void139}140 141declare signext i32 @f90io_ldw_end(...) local_unnamed_addr142 143declare signext i32 @f90io_sc_ch_ldw(...) local_unnamed_addr144 145declare signext i32 @f90io_print_init(...) local_unnamed_addr146 147declare void @f90io_src_info03a(...) local_unnamed_addr148 149; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn150declare double @llvm.floor.f64(double)151 152; Function Attrs: inaccessiblememonly nocallback nofree nosync nounwind willreturn153declare void @llvm.experimental.noalias.scope.decl(metadata)154 155!llvm.module.flags = !{!20, !21}156!llvm.dbg.cu = !{!3}157 158; CHECK-DAG: ![[GVE1]] = !DIGlobalVariableExpression(var: ![[GV1:.*]], expr: !DIExpression(DW_OP_LLVM_fragment, 0, 64))159; CHECK-DAG: ![[GV1]] = distinct !DIGlobalVariable(name: "bar1"160; CHECK-DAG: ![[GVE2]] = !DIGlobalVariableExpression(var: ![[GV2:.*]], expr: !DIExpression(DW_OP_LLVM_fragment, 0, 64))161; CHECK-DAG: ![[GV2]] = distinct !DIGlobalVariable(name: "rvar"162; CHECK-DAG: ![[GVE3]] = !DIGlobalVariableExpression(var: ![[GV1]], expr: !DIExpression(DW_OP_LLVM_fragment, 64, 32))163; CHECK-DAG: ![[GVE4]] = !DIGlobalVariableExpression(var: ![[GV2]], expr: !DIExpression(DW_OP_LLVM_fragment, 64, 64))164; CHECK-DAG: ![[GVE5]] = !DIGlobalVariableExpression(var: ![[GV2]], expr: !DIExpression(DW_OP_LLVM_fragment, 128, 64))165; CHECK-DAG: ![[GVE6]] = !DIGlobalVariableExpression(var: ![[GV3:.*]], expr: !DIExpression(DW_OP_LLVM_fragment, 32, 32))166; CHECK-DAG: ![[GV3]] = distinct !DIGlobalVariable(name: "ivar"167 168!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())169!1 = distinct !DIGlobalVariable(name: "bar1", scope: !2, file: !4, type: !12, isLocal: true, isDefinition: true)170!2 = !DIModule(scope: !3, name: "mymod", isDecl: true)171!3 = distinct !DICompileUnit(language: DW_LANG_Fortran90, file: !4, producer: " F90 Flang - 1.5 2017-05-01", isOptimized: true, flags: "'+flang -g -O3 -S -emit-llvm -o -O1'", runtimeVersion: 0, emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5, nameTableKind: None)172!4 = !DIFile(filename: "global-sra-struct-part-overlap-segment_0.f90", directory: "/tmp")173!5 = !{}174!6 = !{!0, !7, !29}175!7 = !DIGlobalVariableExpression(var: !8, expr: !DIExpression())176!8 = distinct !DIGlobalVariable(name: "rvar", scope: !9, file: !4, line: 13, type: !19, isLocal: true, isDefinition: true)177!9 = distinct !DISubprogram(name: "bar", scope: !2, file: !4, line: 10, type: !10, scopeLine: 10, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !3)178!10 = !DISubroutineType(types: !11)179!11 = !{null, !12, !16}180!12 = !DICompositeType(tag: DW_TAG_array_type, baseType: !13, size: 96, align: 32, elements: !14)181!13 = !DIBasicType(name: "integer", size: 32, align: 32, encoding: DW_ATE_signed)182!14 = !{!15}183!15 = !DISubrange(lowerBound: 1, upperBound: 3)184!16 = !DICompositeType(tag: DW_TAG_array_type, baseType: !17, size: 576, align: 64, elements: !18)185!17 = !DIBasicType(name: "double precision", size: 64, align: 64, encoding: DW_ATE_float)186!18 = !{!15, !15}187!19 = !DICompositeType(tag: DW_TAG_array_type, baseType: !17, size: 192, align: 64, elements: !14)188!20 = !{i32 2, !"Dwarf Version", i32 4}189!21 = !{i32 2, !"Debug Info Version", i32 3}190!22 = distinct !DISubprogram(name: "foo", scope: !2, file: !4, line: 5, type: !10, scopeLine: 5, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !3)191!23 = !{!24}192!24 = distinct !{!24, !25, !"mymod_bar_: %bar"}193!25 = distinct !{!25, !"mymod_bar_"}194!26 = !{!27}195!27 = distinct !{!27, !25, !"mymod_bar_: %arg"}196!28 = !{!24, !27}197!29 = !DIGlobalVariableExpression(var: !30, expr: !DIExpression(DW_OP_plus_uconst, 4))198!30 = distinct !DIGlobalVariable(name: "ivar", scope: !9, file: !4, line: 13, type: !31, isLocal: true, isDefinition: true)199!31 = !DIBasicType(name: "integer*8", size: 64, align: 32, encoding: DW_ATE_signed)200