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