1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature 2; Just run it through opt, no passes needed. 3; RUN: opt < %s -S | FileCheck %s 4 5; ModuleID = 'various_ir_values.c' 6source_filename = "various_ir_values.c" 7target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 8target triple = "x86_64-unknown-linux-gnu" 9 10; Function Attrs: nounwind uwtable 11define dso_local void @foo(i32* %A) #0 !dbg !7 { 12; CHECK-LABEL: define {{[^@]+}}@foo 13; CHECK-SAME: (i32* [[A:%.*]]) #[[ATTR0:[0-9]+]] !dbg [[DBG7:![0-9]+]] { 14; CHECK-NEXT: entry: 15; CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32*, align 8 16; CHECK-NEXT: [[I:%.*]] = alloca i32, align 4 17; CHECK-NEXT: store i32* [[A]], i32** [[A_ADDR]], align 8, !tbaa [[TBAA16:![0-9]+]] 18; CHECK-NEXT: call void @llvm.dbg.declare(metadata i32** [[A_ADDR]], metadata [[META13:![0-9]+]], metadata !DIExpression()), !dbg [[DBG20:![0-9]+]] 19; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32* [[I]] to i8*, !dbg [[DBG21:![0-9]+]] 20; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 4, i8* [[TMP0]]) #[[ATTR3:[0-9]+]], !dbg [[DBG21]] 21; CHECK-NEXT: call void @llvm.dbg.declare(metadata i32* [[I]], metadata [[META14:![0-9]+]], metadata !DIExpression()), !dbg [[DBG22:![0-9]+]] 22; CHECK-NEXT: store i32 0, i32* [[I]], align 4, !dbg [[DBG22]], !tbaa [[TBAA23:![0-9]+]] 23; CHECK-NEXT: br label [[FOR_COND:%.*]], !dbg [[DBG21]] 24; CHECK: for.cond: 25; CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[I]], align 4, !dbg [[DBG25:![0-9]+]], !tbaa [[TBAA23]] 26; CHECK-NEXT: [[TMP2:%.*]] = load i32*, i32** [[A_ADDR]], align 8, !dbg [[DBG27:![0-9]+]], !tbaa [[TBAA16]] 27; CHECK-NEXT: [[TMP3:%.*]] = load i32, i32* [[TMP2]], align 4, !dbg [[DBG28:![0-9]+]], !tbaa [[TBAA23]] 28; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[TMP1]], [[TMP3]], !dbg [[DBG29:![0-9]+]] 29; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_COND_CLEANUP:%.*]], !dbg [[DBG30:![0-9]+]], !prof [[PROF31:![0-9]+]] 30; CHECK: for.cond.cleanup: 31; CHECK-NEXT: [[TMP4:%.*]] = bitcast i32* [[I]] to i8*, !dbg [[DBG32:![0-9]+]] 32; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 4, i8* [[TMP4]]) #[[ATTR3]], !dbg [[DBG32]] 33; CHECK-NEXT: br label [[FOR_END:%.*]] 34; CHECK: for.body: 35; CHECK-NEXT: [[TMP5:%.*]] = load i32*, i32** [[A_ADDR]], align 8, !dbg [[DBG33:![0-9]+]], !tbaa [[TBAA16]] 36; CHECK-NEXT: [[TMP6:%.*]] = load i32, i32* [[I]], align 4, !dbg [[DBG34:![0-9]+]], !tbaa [[TBAA23]] 37; CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[TMP6]] to i64, !dbg [[DBG33]] 38; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[TMP5]], i64 [[IDXPROM]], !dbg [[DBG33]] 39; CHECK-NEXT: store i32 0, i32* [[ARRAYIDX]], align 4, !dbg [[DBG35:![0-9]+]], !tbaa [[TBAA23]] 40; CHECK-NEXT: br label [[FOR_INC:%.*]], !dbg [[DBG33]] 41; CHECK: for.inc: 42; CHECK-NEXT: [[TMP7:%.*]] = load i32, i32* [[I]], align 4, !dbg [[DBG36:![0-9]+]], !tbaa [[TBAA23]] 43; CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[TMP7]], 1, !dbg [[DBG36]] 44; CHECK-NEXT: store i32 [[INC]], i32* [[I]], align 4, !dbg [[DBG36]], !tbaa [[TBAA23]] 45; CHECK-NEXT: br label [[FOR_COND]], !dbg [[DBG32]], !llvm.loop [[LOOP37:![0-9]+]] 46; CHECK: for.end: 47; CHECK-NEXT: ret void, !dbg [[DBG39:![0-9]+]] 48; 49entry: 50 %A.addr = alloca i32*, align 8 51 %i = alloca i32, align 4 52 store i32* %A, i32** %A.addr, align 8, !tbaa !16 53 call void @llvm.dbg.declare(metadata i32** %A.addr, metadata !13, metadata !DIExpression()), !dbg !20 54 %0 = bitcast i32* %i to i8*, !dbg !21 55 call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) #3, !dbg !21 56 call void @llvm.dbg.declare(metadata i32* %i, metadata !14, metadata !DIExpression()), !dbg !22 57 store i32 0, i32* %i, align 4, !dbg !22, !tbaa !23 58 br label %for.cond, !dbg !21 59 60for.cond: ; preds = %for.inc, %entry 61 %1 = load i32, i32* %i, align 4, !dbg !25, !tbaa !23 62 %2 = load i32*, i32** %A.addr, align 8, !dbg !27, !tbaa !16 63 %3 = load i32, i32* %2, align 4, !dbg !28, !tbaa !23 64 %cmp = icmp slt i32 %1, %3, !dbg !29 65 br i1 %cmp, label %for.body, label %for.cond.cleanup, !dbg !30, !prof !61 66 67for.cond.cleanup: ; preds = %for.cond 68 %4 = bitcast i32* %i to i8*, !dbg !31 69 call void @llvm.lifetime.end.p0i8(i64 4, i8* %4) #3, !dbg !31 70 br label %for.end 71 72for.body: ; preds = %for.cond 73 %5 = load i32*, i32** %A.addr, align 8, !dbg !32, !tbaa !16 74 %6 = load i32, i32* %i, align 4, !dbg !33, !tbaa !23 75 %idxprom = sext i32 %6 to i64, !dbg !32 76 %arrayidx = getelementptr inbounds i32, i32* %5, i64 %idxprom, !dbg !32 77 store i32 0, i32* %arrayidx, align 4, !dbg !34, !tbaa !23 78 br label %for.inc, !dbg !32 79 80for.inc: ; preds = %for.body 81 %7 = load i32, i32* %i, align 4, !dbg !35, !tbaa !23 82 %inc = add nsw i32 %7, 1, !dbg !35 83 store i32 %inc, i32* %i, align 4, !dbg !35, !tbaa !23 84 br label %for.cond, !dbg !31, !llvm.loop !36 85 86for.end: ; preds = %for.cond.cleanup 87 ret void, !dbg !38 88} 89 90; Function Attrs: nounwind readnone speculatable willreturn 91declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 92 93; Function Attrs: argmemonly nounwind willreturn 94declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #2 95 96; Function Attrs: argmemonly nounwind willreturn 97declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #2 98 99; Function Attrs: nounwind uwtable 100define dso_local void @bar(i32* %A) #0 !dbg !39 { 101; CHECK-LABEL: define {{[^@]+}}@bar 102; CHECK-SAME: (i32* [[A:%.*]]) #[[ATTR0]] !dbg [[DBG40:![0-9]+]] { 103; CHECK-NEXT: entry: 104; CHECK-NEXT: [[A_ADDR:%.*]] = alloca i32*, align 8 105; CHECK-NEXT: [[I:%.*]] = alloca i32, align 4 106; CHECK-NEXT: store i32* [[A]], i32** [[A_ADDR]], align 8, !tbaa [[TBAA16]] 107; CHECK-NEXT: call void @llvm.dbg.declare(metadata i32** [[A_ADDR]], metadata [[META42:![0-9]+]], metadata !DIExpression()), !dbg [[DBG45:![0-9]+]] 108; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32* [[I]] to i8*, !dbg [[DBG46:![0-9]+]] 109; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 4, i8* [[TMP0]]) #[[ATTR3]], !dbg [[DBG46]] 110; CHECK-NEXT: call void @llvm.dbg.declare(metadata i32* [[I]], metadata [[META43:![0-9]+]], metadata !DIExpression()), !dbg [[DBG47:![0-9]+]] 111; CHECK-NEXT: store i32 0, i32* [[I]], align 4, !dbg [[DBG47]], !tbaa [[TBAA23]] 112; CHECK-NEXT: br label [[FOR_COND:%.*]], !dbg [[DBG46]] 113; CHECK: for.cond: 114; CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[I]], align 4, !dbg [[DBG48:![0-9]+]], !tbaa [[TBAA23]] 115; CHECK-NEXT: [[TMP2:%.*]] = load i32*, i32** [[A_ADDR]], align 8, !dbg [[DBG50:![0-9]+]], !tbaa [[TBAA16]] 116; CHECK-NEXT: [[TMP3:%.*]] = load i32, i32* [[TMP2]], align 4, !dbg [[DBG51:![0-9]+]], !tbaa [[TBAA23]] 117; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[TMP1]], [[TMP3]], !dbg [[DBG52:![0-9]+]] 118; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_COND_CLEANUP:%.*]], !dbg [[DBG53:![0-9]+]] 119; CHECK: for.cond.cleanup: 120; CHECK-NEXT: [[TMP4:%.*]] = bitcast i32* [[I]] to i8*, !dbg [[DBG54:![0-9]+]] 121; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 4, i8* [[TMP4]]) #[[ATTR3]], !dbg [[DBG54]] 122; CHECK-NEXT: br label [[FOR_END:%.*]] 123; CHECK: for.body: 124; CHECK-NEXT: [[TMP5:%.*]] = load i32*, i32** [[A_ADDR]], align 8, !dbg [[DBG55:![0-9]+]], !tbaa [[TBAA16]] 125; CHECK-NEXT: [[TMP6:%.*]] = load i32, i32* [[I]], align 4, !dbg [[DBG56:![0-9]+]], !tbaa [[TBAA23]] 126; CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[TMP6]] to i64, !dbg [[DBG55]] 127; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[TMP5]], i64 [[IDXPROM]], !dbg [[DBG55]] 128; CHECK-NEXT: store i32 0, i32* [[ARRAYIDX]], align 4, !dbg [[DBG57:![0-9]+]], !tbaa [[TBAA23]] 129; CHECK-NEXT: br label [[FOR_INC:%.*]], !dbg [[DBG55]] 130; CHECK: for.inc: 131; CHECK-NEXT: [[TMP7:%.*]] = load i32, i32* [[I]], align 4, !dbg [[DBG58:![0-9]+]], !tbaa [[TBAA23]] 132; CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[TMP7]], 1, !dbg [[DBG58]] 133; CHECK-NEXT: store i32 [[INC]], i32* [[I]], align 4, !dbg [[DBG58]], !tbaa [[TBAA23]] 134; CHECK-NEXT: br label [[FOR_COND]], !dbg [[DBG54]], !llvm.loop [[LOOP59:![0-9]+]] 135; CHECK: for.end: 136; CHECK-NEXT: ret void, !dbg [[DBG61:![0-9]+]] 137; 138entry: 139 %A.addr = alloca i32*, align 8 140 %i = alloca i32, align 4 141 store i32* %A, i32** %A.addr, align 8, !tbaa !16 142 call void @llvm.dbg.declare(metadata i32** %A.addr, metadata !41, metadata !DIExpression()), !dbg !44 143 %0 = bitcast i32* %i to i8*, !dbg !45 144 call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) #3, !dbg !45 145 call void @llvm.dbg.declare(metadata i32* %i, metadata !42, metadata !DIExpression()), !dbg !46 146 store i32 0, i32* %i, align 4, !dbg !46, !tbaa !23 147 br label %for.cond, !dbg !45 148 149for.cond: ; preds = %for.inc, %entry 150 %1 = load i32, i32* %i, align 4, !dbg !47, !tbaa !23 151 %2 = load i32*, i32** %A.addr, align 8, !dbg !49, !tbaa !16 152 %3 = load i32, i32* %2, align 4, !dbg !50, !tbaa !23 153 %cmp = icmp slt i32 %1, %3, !dbg !51 154 br i1 %cmp, label %for.body, label %for.cond.cleanup, !dbg !52 155 156for.cond.cleanup: ; preds = %for.cond 157 %4 = bitcast i32* %i to i8*, !dbg !53 158 call void @llvm.lifetime.end.p0i8(i64 4, i8* %4) #3, !dbg !53 159 br label %for.end 160 161for.body: ; preds = %for.cond 162 %5 = load i32*, i32** %A.addr, align 8, !dbg !54, !tbaa !16 163 %6 = load i32, i32* %i, align 4, !dbg !55, !tbaa !23 164 %idxprom = sext i32 %6 to i64, !dbg !54 165 %arrayidx = getelementptr inbounds i32, i32* %5, i64 %idxprom, !dbg !54 166 store i32 0, i32* %arrayidx, align 4, !dbg !56, !tbaa !23 167 br label %for.inc, !dbg !54 168 169for.inc: ; preds = %for.body 170 %7 = load i32, i32* %i, align 4, !dbg !57, !tbaa !23 171 %inc = add nsw i32 %7, 1, !dbg !57 172 store i32 %inc, i32* %i, align 4, !dbg !57, !tbaa !23 173 br label %for.cond, !dbg !53, !llvm.loop !58 174 175for.end: ; preds = %for.cond.cleanup 176 ret void, !dbg !60 177} 178 179attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "denormal-fp-math"="ieee,ieee" "denormal-fp-math-f32"="ieee,ieee" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } 180attributes #1 = { nounwind readnone speculatable willreturn } 181attributes #2 = { argmemonly nounwind willreturn } 182attributes #3 = { nounwind } 183 184!llvm.dbg.cu = !{!0} 185!llvm.module.flags = !{!3, !4, !5} 186!llvm.ident = !{!6} 187 188!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0 ([email protected]:llvm/llvm-project.git 1d5da8cd30fce1c0a2c2fa6ba656dbfaa36192c8)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) 189!1 = !DIFile(filename: "various_ir_values.c", directory: "/data/build/llvm-project") 190!2 = !{} 191!3 = !{i32 7, !"Dwarf Version", i32 4} 192!4 = !{i32 2, !"Debug Info Version", i32 3} 193!5 = !{i32 1, !"wchar_size", i32 4} 194!6 = !{!"clang version 11.0.0 ([email protected]:llvm/llvm-project.git 1d5da8cd30fce1c0a2c2fa6ba656dbfaa36192c8)"} 195!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12) 196!8 = !DISubroutineType(types: !9) 197!9 = !{null, !10} 198!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64) 199!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 200!12 = !{!13, !14} 201!13 = !DILocalVariable(name: "A", arg: 1, scope: !7, file: !1, line: 1, type: !10) 202!14 = !DILocalVariable(name: "i", scope: !15, file: !1, line: 3, type: !11) 203!15 = distinct !DILexicalBlock(scope: !7, file: !1, line: 3, column: 3) 204!16 = !{!17, !17, i64 0} 205!17 = !{!"any pointer", !18, i64 0} 206!18 = !{!"omnipotent char", !19, i64 0} 207!19 = !{!"Simple C/C++ TBAA"} 208!20 = !DILocation(line: 1, column: 15, scope: !7) 209!21 = !DILocation(line: 3, column: 8, scope: !15) 210!22 = !DILocation(line: 3, column: 12, scope: !15) 211!23 = !{!24, !24, i64 0} 212!24 = !{!"int", !18, i64 0} 213!25 = !DILocation(line: 3, column: 19, scope: !26) 214!26 = distinct !DILexicalBlock(scope: !15, file: !1, line: 3, column: 3) 215!27 = !DILocation(line: 3, column: 24, scope: !26) 216!28 = !DILocation(line: 3, column: 23, scope: !26) 217!29 = !DILocation(line: 3, column: 21, scope: !26) 218!30 = !DILocation(line: 3, column: 3, scope: !15) 219!31 = !DILocation(line: 3, column: 3, scope: !26) 220!32 = !DILocation(line: 4, column: 5, scope: !26) 221!33 = !DILocation(line: 4, column: 7, scope: !26) 222!34 = !DILocation(line: 4, column: 10, scope: !26) 223!35 = !DILocation(line: 3, column: 27, scope: !26) 224!36 = distinct !{!36, !30, !37} 225!37 = !DILocation(line: 4, column: 12, scope: !15) 226!38 = !DILocation(line: 5, column: 1, scope: !7) 227!39 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 7, type: !8, scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !40) 228!40 = !{!41, !42} 229!41 = !DILocalVariable(name: "A", arg: 1, scope: !39, file: !1, line: 7, type: !10) 230!42 = !DILocalVariable(name: "i", scope: !43, file: !1, line: 9, type: !11) 231!43 = distinct !DILexicalBlock(scope: !39, file: !1, line: 9, column: 3) 232!44 = !DILocation(line: 7, column: 15, scope: !39) 233!45 = !DILocation(line: 9, column: 8, scope: !43) 234!46 = !DILocation(line: 9, column: 12, scope: !43) 235!47 = !DILocation(line: 9, column: 19, scope: !48) 236!48 = distinct !DILexicalBlock(scope: !43, file: !1, line: 9, column: 3) 237!49 = !DILocation(line: 9, column: 24, scope: !48) 238!50 = !DILocation(line: 9, column: 23, scope: !48) 239!51 = !DILocation(line: 9, column: 21, scope: !48) 240!52 = !DILocation(line: 9, column: 3, scope: !43) 241!53 = !DILocation(line: 9, column: 3, scope: !48) 242!54 = !DILocation(line: 10, column: 5, scope: !48) 243!55 = !DILocation(line: 10, column: 7, scope: !48) 244!56 = !DILocation(line: 10, column: 10, scope: !48) 245!57 = !DILocation(line: 9, column: 27, scope: !48) 246!58 = distinct !{!58, !52, !59} 247!59 = !DILocation(line: 10, column: 12, scope: !43) 248!60 = !DILocation(line: 11, column: 1, scope: !39) 249!61 = !{!"branch_weights", i32 1, i32 1048575} 250