brintos

brintos / llvm-project-archived public Read only

0
0
Text · 11.9 KiB · c6035ff Raw
192 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 62; RUN: opt -passes=loop-unroll -unroll-runtime -unroll-allow-remainder -unroll-count=4 -unroll-remainder -S %s -o - | FileCheck %s3target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"4target triple = "x86_64-unknown-linux-gnu"5 6@b = common local_unnamed_addr global i32 0, align 4, !dbg !07@a = common local_unnamed_addr global ptr null, align 8, !dbg !68 9; Test that loop remainder unrolling doesn't corrupt debuginfo. This example10; used to cause an assert, but also test that the unrolled backwards branches11; have the same DILocation.12 13define i32 @func_c() local_unnamed_addr #0 !dbg !14 {14;15; CHECK-LABEL: define i32 @func_c(16; CHECK-SAME: ) local_unnamed_addr #[[ATTR0:[0-9]+]] !dbg [[DBG14:![0-9]+]] {17; CHECK-NEXT:  [[ENTRY:.*:]]18; CHECK-NEXT:    [[DOTPR:%.*]] = load i32, ptr @b, align 4, !dbg [[DBG17:![0-9]+]], !tbaa [[INT_TBAA20:![0-9]+]]19; CHECK-NEXT:    [[TOBOOL1:%.*]] = icmp eq i32 [[DOTPR]], 0, !dbg [[DBG24:![0-9]+]]20; CHECK-NEXT:    br i1 [[TOBOOL1]], label %[[FOR_END:.*]], label %[[FOR_BODY_LR_PH:.*]], !dbg [[DBG24]]21; CHECK:       [[FOR_BODY_LR_PH]]:22; CHECK-NEXT:    [[A_PROMOTED:%.*]] = load ptr, ptr @a, align 8, !dbg [[DBG25:![0-9]+]], !tbaa [[ANYPTR_TBAA26:![0-9]+]]23; CHECK-NEXT:    [[TMP0:%.*]] = sub i32 -2, [[DOTPR]], !dbg [[DBG24]]24; CHECK-NEXT:    [[TMP1:%.*]] = and i32 [[TMP0]], -2, !dbg [[DBG24]]25; CHECK-NEXT:    [[TMP2:%.*]] = add i32 [[DOTPR]], [[TMP1]], !dbg [[DBG24]]26; CHECK-NEXT:    [[TMP3:%.*]] = lshr i32 [[TMP0]], 1, !dbg [[DBG24]]27; CHECK-NEXT:    [[TMP4:%.*]] = add nuw i32 [[TMP3]], 1, !dbg [[DBG24]]28; CHECK-NEXT:    [[XTRAITER:%.*]] = and i32 [[TMP4]], 3, !dbg [[DBG24]]29; CHECK-NEXT:    [[LCMP_MOD:%.*]] = icmp ne i32 [[XTRAITER]], 0, !dbg [[DBG24]]30; CHECK-NEXT:    br i1 [[LCMP_MOD]], label %[[FOR_BODY_PROL_PREHEADER:.*]], label %[[FOR_BODY_PROL_LOOPEXIT:.*]], !dbg [[DBG24]]31; CHECK:       [[FOR_BODY_PROL_PREHEADER]]:32; CHECK-NEXT:    br label %[[FOR_BODY_PROL:.*]], !dbg [[DBG24]]33; CHECK:       [[FOR_BODY_PROL]]:34; CHECK-NEXT:    [[ARRAYIDX_PROL:%.*]] = getelementptr inbounds i32, ptr [[A_PROMOTED]], i64 1, !dbg [[DBG28:![0-9]+]]35; CHECK-NEXT:    [[TMP5:%.*]] = load i32, ptr [[ARRAYIDX_PROL]], align 4, !dbg [[DBG28]], !tbaa [[INT_TBAA20]]36; CHECK-NEXT:    [[CONV_PROL:%.*]] = sext i32 [[TMP5]] to i64, !dbg [[DBG28]]37; CHECK-NEXT:    [[TMP6:%.*]] = inttoptr i64 [[CONV_PROL]] to ptr, !dbg [[DBG28]]38; CHECK-NEXT:    [[ADD_PROL:%.*]] = add nsw i32 [[DOTPR]], 2, !dbg [[DBG29:![0-9]+]]39; CHECK-NEXT:    [[PROL_ITER_CMP:%.*]] = icmp ne i32 1, [[XTRAITER]], !dbg [[DBG24]]40; CHECK-NEXT:    br i1 [[PROL_ITER_CMP]], label %[[FOR_BODY_PROL_1:.*]], label %[[FOR_BODY_PROL_LOOPEXIT_UNR_LCSSA:.*]], !dbg [[DBG24]]41; CHECK:       [[FOR_BODY_PROL_1]]:42; CHECK-NEXT:    [[ARRAYIDX_PROL_1:%.*]] = getelementptr inbounds i32, ptr [[TMP6]], i64 1, !dbg [[DBG28]]43; CHECK-NEXT:    [[TMP7:%.*]] = load i32, ptr [[ARRAYIDX_PROL_1]], align 4, !dbg [[DBG28]], !tbaa [[INT_TBAA20]]44; CHECK-NEXT:    [[CONV_PROL_1:%.*]] = sext i32 [[TMP7]] to i64, !dbg [[DBG28]]45; CHECK-NEXT:    [[TMP8:%.*]] = inttoptr i64 [[CONV_PROL_1]] to ptr, !dbg [[DBG28]]46; CHECK-NEXT:    [[ADD_PROL_1:%.*]] = add nsw i32 [[DOTPR]], 4, !dbg [[DBG29]]47; CHECK-NEXT:    [[PROL_ITER_CMP_1:%.*]] = icmp ne i32 2, [[XTRAITER]], !dbg [[DBG24]]48; CHECK-NEXT:    br i1 [[PROL_ITER_CMP_1]], label %[[FOR_BODY_PROL_2:.*]], label %[[FOR_BODY_PROL_LOOPEXIT_UNR_LCSSA]], !dbg [[DBG24]]49; CHECK:       [[FOR_BODY_PROL_2]]:50; CHECK-NEXT:    [[ARRAYIDX_PROL_2:%.*]] = getelementptr inbounds i32, ptr [[TMP8]], i64 1, !dbg [[DBG28]]51; CHECK-NEXT:    [[TMP9:%.*]] = load i32, ptr [[ARRAYIDX_PROL_2]], align 4, !dbg [[DBG28]], !tbaa [[INT_TBAA20]]52; CHECK-NEXT:    [[CONV_PROL_2:%.*]] = sext i32 [[TMP9]] to i64, !dbg [[DBG28]]53; CHECK-NEXT:    [[TMP10:%.*]] = inttoptr i64 [[CONV_PROL_2]] to ptr, !dbg [[DBG28]]54; CHECK-NEXT:    [[ADD_PROL_2:%.*]] = add nsw i32 [[DOTPR]], 6, !dbg [[DBG29]]55; CHECK-NEXT:    br label %[[FOR_BODY_PROL_LOOPEXIT_UNR_LCSSA]], !dbg [[DBG24]]56; CHECK:       [[FOR_BODY_PROL_LOOPEXIT_UNR_LCSSA]]:57; CHECK-NEXT:    [[DOTLCSSA_UNR_PH:%.*]] = phi ptr [ [[TMP6]], %[[FOR_BODY_PROL]] ], [ [[TMP8]], %[[FOR_BODY_PROL_1]] ], [ [[TMP10]], %[[FOR_BODY_PROL_2]] ]58; CHECK-NEXT:    [[DOTUNR_PH:%.*]] = phi ptr [ [[TMP6]], %[[FOR_BODY_PROL]] ], [ [[TMP8]], %[[FOR_BODY_PROL_1]] ], [ [[TMP10]], %[[FOR_BODY_PROL_2]] ]59; CHECK-NEXT:    [[DOTUNR1_PH:%.*]] = phi i32 [ [[ADD_PROL]], %[[FOR_BODY_PROL]] ], [ [[ADD_PROL_1]], %[[FOR_BODY_PROL_1]] ], [ [[ADD_PROL_2]], %[[FOR_BODY_PROL_2]] ]60; CHECK-NEXT:    br label %[[FOR_BODY_PROL_LOOPEXIT]], !dbg [[DBG24]]61; CHECK:       [[FOR_BODY_PROL_LOOPEXIT]]:62; CHECK-NEXT:    [[DOTLCSSA_UNR:%.*]] = phi ptr [ poison, %[[FOR_BODY_LR_PH]] ], [ [[DOTLCSSA_UNR_PH]], %[[FOR_BODY_PROL_LOOPEXIT_UNR_LCSSA]] ]63; CHECK-NEXT:    [[DOTUNR:%.*]] = phi ptr [ [[A_PROMOTED]], %[[FOR_BODY_LR_PH]] ], [ [[DOTUNR_PH]], %[[FOR_BODY_PROL_LOOPEXIT_UNR_LCSSA]] ]64; CHECK-NEXT:    [[DOTUNR1:%.*]] = phi i32 [ [[DOTPR]], %[[FOR_BODY_LR_PH]] ], [ [[DOTUNR1_PH]], %[[FOR_BODY_PROL_LOOPEXIT_UNR_LCSSA]] ]65; CHECK-NEXT:    [[TMP11:%.*]] = icmp ult i32 [[TMP3]], 3, !dbg [[DBG24]]66; CHECK-NEXT:    br i1 [[TMP11]], label %[[FOR_COND_FOR_END_CRIT_EDGE:.*]], label %[[FOR_BODY_LR_PH_NEW:.*]], !dbg [[DBG24]]67; CHECK:       [[FOR_BODY_LR_PH_NEW]]:68; CHECK-NEXT:    br label %[[FOR_BODY:.*]], !dbg [[DBG24]]69; CHECK:       [[FOR_BODY]]:70; CHECK-NEXT:    [[TMP12:%.*]] = phi ptr [ [[DOTUNR]], %[[FOR_BODY_LR_PH_NEW]] ], [ [[TMP21:%.*]], %[[FOR_BODY]] ], !dbg [[DBG28]]71; CHECK-NEXT:    [[TMP13:%.*]] = phi i32 [ [[DOTUNR1]], %[[FOR_BODY_LR_PH_NEW]] ], [ [[ADD_3:%.*]], %[[FOR_BODY]] ]72; CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[TMP12]], i64 1, !dbg [[DBG28]]73; CHECK-NEXT:    [[TMP14:%.*]] = load i32, ptr [[ARRAYIDX]], align 4, !dbg [[DBG28]], !tbaa [[INT_TBAA20]]74; CHECK-NEXT:    [[CONV:%.*]] = sext i32 [[TMP14]] to i64, !dbg [[DBG28]]75; CHECK-NEXT:    [[TMP15:%.*]] = inttoptr i64 [[CONV]] to ptr, !dbg [[DBG28]]76; CHECK-NEXT:    [[ARRAYIDX_1:%.*]] = getelementptr inbounds i32, ptr [[TMP15]], i64 1, !dbg [[DBG28]]77; CHECK-NEXT:    [[TMP16:%.*]] = load i32, ptr [[ARRAYIDX_1]], align 4, !dbg [[DBG28]], !tbaa [[INT_TBAA20]]78; CHECK-NEXT:    [[CONV_1:%.*]] = sext i32 [[TMP16]] to i64, !dbg [[DBG28]]79; CHECK-NEXT:    [[TMP17:%.*]] = inttoptr i64 [[CONV_1]] to ptr, !dbg [[DBG28]]80; CHECK-NEXT:    [[ARRAYIDX_2:%.*]] = getelementptr inbounds i32, ptr [[TMP17]], i64 1, !dbg [[DBG28]]81; CHECK-NEXT:    [[TMP18:%.*]] = load i32, ptr [[ARRAYIDX_2]], align 4, !dbg [[DBG28]], !tbaa [[INT_TBAA20]]82; CHECK-NEXT:    [[CONV_2:%.*]] = sext i32 [[TMP18]] to i64, !dbg [[DBG28]]83; CHECK-NEXT:    [[TMP19:%.*]] = inttoptr i64 [[CONV_2]] to ptr, !dbg [[DBG28]]84; CHECK-NEXT:    [[ARRAYIDX_3:%.*]] = getelementptr inbounds i32, ptr [[TMP19]], i64 1, !dbg [[DBG28]]85; CHECK-NEXT:    [[TMP20:%.*]] = load i32, ptr [[ARRAYIDX_3]], align 4, !dbg [[DBG28]], !tbaa [[INT_TBAA20]]86; CHECK-NEXT:    [[CONV_3:%.*]] = sext i32 [[TMP20]] to i64, !dbg [[DBG28]]87; CHECK-NEXT:    [[TMP21]] = inttoptr i64 [[CONV_3]] to ptr, !dbg [[DBG28]]88; CHECK-NEXT:    [[ADD_3]] = add nsw i32 [[TMP13]], 8, !dbg [[DBG29]]89; CHECK-NEXT:    [[TOBOOL_3:%.*]] = icmp eq i32 [[ADD_3]], 0, !dbg [[DBG24]]90; CHECK-NEXT:    br i1 [[TOBOOL_3]], label %[[FOR_COND_FOR_END_CRIT_EDGE_UNR_LCSSA:.*]], label %[[FOR_BODY]], !dbg [[DBG24]], !llvm.loop [[LOOP30:![0-9]+]]91; CHECK:       [[FOR_COND_FOR_END_CRIT_EDGE_UNR_LCSSA]]:92; CHECK-NEXT:    [[DOTLCSSA_PH:%.*]] = phi ptr [ [[TMP21]], %[[FOR_BODY]] ]93; CHECK-NEXT:    br label %[[FOR_COND_FOR_END_CRIT_EDGE]], !dbg [[DBG24]]94; CHECK:       [[FOR_COND_FOR_END_CRIT_EDGE]]:95; CHECK-NEXT:    [[DOTLCSSA:%.*]] = phi ptr [ [[DOTLCSSA_UNR]], %[[FOR_BODY_PROL_LOOPEXIT]] ], [ [[DOTLCSSA_PH]], %[[FOR_COND_FOR_END_CRIT_EDGE_UNR_LCSSA]] ], !dbg [[DBG28]]96; CHECK-NEXT:    [[TMP22:%.*]] = add i32 [[TMP2]], 2, !dbg [[DBG24]]97; CHECK-NEXT:    store ptr [[DOTLCSSA]], ptr @a, align 8, !dbg [[DBG25]], !tbaa [[ANYPTR_TBAA26]]98; CHECK-NEXT:    store i32 [[TMP22]], ptr @b, align 4, !dbg [[DBG33:![0-9]+]], !tbaa [[INT_TBAA20]]99; CHECK-NEXT:    br label %[[FOR_END]], !dbg [[DBG24]]100; CHECK:       [[FOR_END]]:101; CHECK-NEXT:    ret i32 undef, !dbg [[DBG34:![0-9]+]]102;103entry:104  %.pr = load i32, ptr @b, align 4, !dbg !17, !tbaa !20105  %tobool1 = icmp eq i32 %.pr, 0, !dbg !24106  br i1 %tobool1, label %for.end, label %for.body.lr.ph, !dbg !24107 108for.body.lr.ph:109  %a.promoted = load ptr, ptr @a, align 8, !dbg !25, !tbaa !26110  %0 = sub i32 -2, %.pr, !dbg !24111  %1 = and i32 %0, -2, !dbg !24112  %2 = add i32 %.pr, %1, !dbg !24113  br label %for.body, !dbg !24114 115for.body:116  %3 = phi ptr [ %a.promoted, %for.body.lr.ph ], [ %6, %for.body ], !dbg !28117  %4 = phi i32 [ %.pr, %for.body.lr.ph ], [ %add, %for.body ]118  %arrayidx = getelementptr inbounds i32, ptr %3, i64 1, !dbg !28119  %5 = load i32, ptr %arrayidx, align 4, !dbg !28, !tbaa !20120  %conv = sext i32 %5 to i64, !dbg !28121  %6 = inttoptr i64 %conv to ptr, !dbg !28122  %add = add nsw i32 %4, 2, !dbg !29123  %tobool = icmp eq i32 %add, 0, !dbg !24124  br i1 %tobool, label %for.cond.for.end_crit_edge, label %for.body, !dbg !24, !llvm.loop !30125 126for.cond.for.end_crit_edge:127  %7 = add i32 %2, 2, !dbg !24128  store ptr %6, ptr @a, align 8, !dbg !25, !tbaa !26129  store i32 %7, ptr @b, align 4, !dbg !32, !tbaa !20130  br label %for.end, !dbg !24131 132for.end:133  ret i32 undef, !dbg !33134}135 136define void @func_d() local_unnamed_addr #1 !dbg !34 {137;138; CHECK-LABEL: define void @func_d(139; CHECK-SAME: ) local_unnamed_addr !dbg [[DBG35:![0-9]+]] {140; CHECK-NEXT:  [[ENTRY:.*:]]141; CHECK-NEXT:    ret void, !dbg [[DBG38:![0-9]+]]142;143entry:144  ret void, !dbg !37145}146 147attributes #0 = { norecurse nounwind uwtable }148attributes #0 = { norecurse nounwind readnone uwtable }149 150!llvm.dbg.cu = !{!2}151!llvm.module.flags = !{!10, !11, !12}152!llvm.ident = !{!13}153 154!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())155!1 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 2, type: !9, isLocal: false, isDefinition: true)156!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 6.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)157!3 = !DIFile(filename: "loop.c", directory: "/work/projects/src/tests/unroll-debug-info")158!4 = !{}159!5 = !{!6, !0}160!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())161!7 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 1, type: !8, isLocal: false, isDefinition: true)162!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)163!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)164!10 = !{i32 2, !"Dwarf Version", i32 4}165!11 = !{i32 2, !"Debug Info Version", i32 3}166!12 = !{i32 1, !"wchar_size", i32 4}167!13 = !{!"clang version 6.0.0"}168!14 = distinct !DISubprogram(name: "c", scope: !3, file: !3, line: 3, type: !15, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: true, unit: !2, retainedNodes: !4)169!15 = !DISubroutineType(types: !16)170!16 = !{!9}171!17 = !DILocation(line: 4, column: 12, scope: !18)172!18 = distinct !DILexicalBlock(scope: !19, file: !3, line: 4, column: 5)173!19 = distinct !DILexicalBlock(scope: !14, file: !3, line: 4, column: 5)174!20 = !{!21, !21, i64 0}175!21 = !{!"int", !22, i64 0}176!22 = !{!"omnipotent char", !23, i64 0}177!23 = !{!"Simple C/C++ TBAA"}178!24 = !DILocation(line: 4, column: 5, scope: !19)179!25 = !DILocation(line: 5, column: 13, scope: !18)180!26 = !{!27, !27, i64 0}181!27 = !{!"any pointer", !22, i64 0}182!28 = !DILocation(line: 5, column: 15, scope: !18)183!29 = !DILocation(line: 4, column: 21, scope: !18)184!30 = distinct !{!30, !24, !31}185!31 = !DILocation(line: 5, column: 18, scope: !19)186!32 = !DILocation(line: 4, column: 17, scope: !18)187!33 = !DILocation(line: 6, column: 1, scope: !14)188!34 = distinct !DISubprogram(name: "d", scope: !3, file: !3, line: 7, type: !35, isLocal: false, isDefinition: true, scopeLine: 7, isOptimized: true, unit: !2, retainedNodes: !4)189!35 = !DISubroutineType(types: !36)190!36 = !{null}191!37 = !DILocation(line: 7, column: 11, scope: !34)192