1; RUN: opt -passes=annotation-remarks -o /dev/null -S -pass-remarks-output=%t.opt.yaml %s -pass-remarks-missed=annotation-remarks 2>&1 | FileCheck %s 2; RUN: opt --try-experimental-debuginfo-iterators -passes=annotation-remarks -o /dev/null -S -pass-remarks-output=%t.opt.yaml %s -pass-remarks-missed=annotation-remarks 2>&1 | FileCheck %s 3; RUN: cat %t.opt.yaml | FileCheck -check-prefix=YAML %s 4 5; Emit a remark that reports a store. 6define void @store(ptr %dst) { 7; CHECK: Store inserted by -ftrivial-auto-var-init. 8; CHECK-NEXT: Store size: 4 bytes. 9; YAML-LABEL: --- !Missed 10; YAML-NEXT: Pass: annotation-remarks 11; YAML-NEXT: Name: AutoInitStore 12; YAML-NEXT: DebugLoc: 13; YAML-NEXT: Function: store 14; YAML-NEXT: Args: 15; YAML-NEXT: - String: Store inserted by -ftrivial-auto-var-init. 16; YAML-NEXT: - String: "\nStore size: " 17; YAML-NEXT: - StoreSize: '4' 18; YAML-NEXT: - String: ' bytes.' 19; YAML-NEXT: - String: ' Volatile: ' 20; YAML-NEXT: - StoreVolatile: 'false' 21; YAML-NEXT: - String: . 22; YAML-NEXT: - String: ' Atomic: ' 23; YAML-NEXT: - StoreAtomic: 'false' 24; YAML-NEXT: - String: . 25; YAML-NEXT: ... 26 store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4) 27 ret void 28} 29 30; Emit a remark that reports a volatile store. 31define void @volatile_store(ptr %dst) { 32; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init. 33; CHECK-NEXT: Store size: 4 bytes. Volatile: true. 34; YAML-LABEL: --- !Missed 35; YAML-NEXT: Pass: annotation-remarks 36; YAML-NEXT: Name: AutoInitStore 37; YAML-NEXT: DebugLoc: 38; YAML-NEXT: Function: volatile_store 39; YAML-NEXT: Args: 40; YAML-NEXT: - String: Store inserted by -ftrivial-auto-var-init. 41; YAML-NEXT: - String: "\nStore size: " 42; YAML-NEXT: - StoreSize: '4' 43; YAML-NEXT: - String: ' bytes.' 44; YAML-NEXT: - String: ' Volatile: ' 45; YAML-NEXT: - StoreVolatile: 'true' 46; YAML-NEXT: - String: . 47; YAML-NEXT: - String: ' Atomic: ' 48; YAML-NEXT: - StoreAtomic: 'false' 49; YAML-NEXT: - String: . 50; YAML-NEXT: ... 51 store volatile i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4) 52 ret void 53} 54 55; Emit a remark that reports an atomic store. 56define void @atomic_store(ptr %dst) { 57; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init. 58; CHECK-NEXT: Store size: 4 bytes. Atomic: true. 59; YAML-LABEL: --- !Missed 60; YAML-NEXT: Pass: annotation-remarks 61; YAML-NEXT: Name: AutoInitStore 62; YAML-NEXT: DebugLoc: 63; YAML-NEXT: Function: atomic_store 64; YAML-NEXT: Args: 65; YAML-NEXT: - String: Store inserted by -ftrivial-auto-var-init. 66; YAML-NEXT: - String: "\nStore size: " 67; YAML-NEXT: - StoreSize: '4' 68; YAML-NEXT: - String: ' bytes.' 69; YAML-NEXT: - String: ' Atomic: ' 70; YAML-NEXT: - StoreAtomic: 'true' 71; YAML-NEXT: - String: . 72; YAML-NEXT: - String: ' Volatile: ' 73; YAML-NEXT: - StoreVolatile: 'false' 74; YAML-NEXT: - String: . 75; YAML-NEXT: ... 76 store atomic i32 0, ptr %dst unordered, align 4, !annotation !0, !dbg !DILocation(scope: !4) 77 ret void 78} 79 80; Emit a remark that reports a store to an alloca. 81define void @store_alloca() { 82; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init. 83; CHECK-NEXT: Store size: 4 bytes. 84; CHECK-NEXT: Variables: dst (4 bytes). 85; YAML-LABEL: --- !Missed 86; YAML-NEXT: Pass: annotation-remarks 87; YAML-NEXT: Name: AutoInitStore 88; YAML-NEXT: DebugLoc: 89; YAML-NEXT: Function: store_alloca 90; YAML-NEXT: Args: 91; YAML-NEXT: - String: Store inserted by -ftrivial-auto-var-init. 92; YAML-NEXT: - String: "\nStore size: " 93; YAML-NEXT: - StoreSize: '4' 94; YAML-NEXT: - String: ' bytes.' 95; YAML-NEXT: - String: "\n Written Variables: " 96; YAML-NEXT: - WVarName: dst 97; YAML-NEXT: - String: ' (' 98; YAML-NEXT: - WVarSize: '4' 99; YAML-NEXT: - String: ' bytes)' 100; YAML-NEXT: - String: . 101; YAML-NEXT: - String: ' Volatile: ' 102; YAML-NEXT: - StoreVolatile: 'false' 103; YAML-NEXT: - String: . 104; YAML-NEXT: - String: ' Atomic: ' 105; YAML-NEXT: - StoreAtomic: 'false' 106; YAML-NEXT: - String: . 107; YAML-NEXT: ... 108 %dst = alloca i32 109 store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4) 110 ret void 111} 112 113; Emit a remark that reports a store to an alloca through a GEP. 114define void @store_alloca_gep() { 115; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init. 116; CHECK-NEXT: Store size: 4 bytes. 117; CHECK-NEXT: Variables: dst (4 bytes). 118 %dst = alloca i32 119 store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4) 120 ret void 121} 122 123; Emit a remark that reports a store to an alloca through a GEP, with ptrtoint+inttoptr in the way. 124define void @store_alloca_gep_inttoptr() { 125; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init. 126; CHECK-NEXT: Store size: 4 bytes. 127; CHECK-NEXT: Variables: dst (4 bytes). 128 %dst = alloca i32 129 %p2i = ptrtoint ptr %dst to i64 130 %i2p = inttoptr i64 %p2i to ptr 131 store i32 0, ptr %i2p, !annotation !0, !dbg !DILocation(scope: !4) 132 ret void 133} 134 135; Emit a remark that reports a store to an alloca through a GEP in an array. 136define void @store_alloca_gep_array() { 137; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init. 138; CHECK-NEXT: Store size: 4 bytes. 139; CHECK-NEXT: Variables: dst (8 bytes). 140 %dst = alloca [2 x i32] 141 store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4) 142 ret void 143} 144 145; Emit a remark that reports a store to an alloca through a bitcast. 146define void @store_alloca_bitcast() { 147; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init. 148; CHECK-NEXT: Store size: 4 bytes. 149; CHECK-NEXT: Variables: dst (4 bytes). 150 %dst = alloca [2 x i16] 151 store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4) 152 ret void 153} 154 155; Emit a remark that reports a store to an alloca that has a DILocalVariable 156; attached. 157define void @store_alloca_di() { 158; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init. 159; CHECK-NEXT: Store size: 4 bytes. 160; CHECK-NEXT: Variables: destination (4 bytes). 161 %dst = alloca i32 162 store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4) 163 call void @llvm.dbg.declare(metadata ptr %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4) 164 ret void 165} 166 167; Emit a remark that reports a store to an alloca that has more than one 168; DILocalVariable attached. 169define void @store_alloca_di_multiple() { 170; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init. 171; CHECK-NEXT: Store size: 4 bytes. 172; CHECK-NEXT: Variables: destination2 (4 bytes), destination (4 bytes). 173 %dst = alloca i32 174 store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4) 175 call void @llvm.dbg.declare(metadata ptr %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4) 176 call void @llvm.dbg.declare(metadata ptr %dst, metadata !7, metadata !DIExpression()), !dbg !DILocation(scope: !4) 177 ret void 178} 179 180; Emit a remark that reports a store to a PHI node that can be two different 181; allocas. 182define void @store_alloca_phi() { 183; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init. 184; CHECK-NEXT: Store size: 4 bytes. 185; CHECK-NEXT: Variables: dst2 (4 bytes), dst (4 bytes). 186entry: 187 %dst = alloca i32 188 %dst2 = alloca i32 189 %cmp = icmp eq i32 undef, undef 190 br i1 %cmp, label %l0, label %l1 191l0: 192 br label %l2 193l1: 194 br label %l2 195l2: 196 %phidst = phi ptr [ %dst, %l0 ], [ %dst2, %l1 ] 197 store i32 0, ptr %phidst, !annotation !0, !dbg !DILocation(scope: !4) 198 ret void 199} 200 201; Emit a remark that reports a store to a PHI node that can be two different 202; allocas, where one of it has multiple DILocalVariable. 203define void @store_alloca_phi_di_multiple() { 204; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init. 205; CHECK-NEXT: Store size: 4 bytes. 206; CHECK-NEXT: Variables: dst2 (4 bytes), destination2 (4 bytes), destination (4 bytes). 207entry: 208 %dst = alloca i32 209 %dst2 = alloca i32 210 call void @llvm.dbg.declare(metadata ptr %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4) 211 call void @llvm.dbg.declare(metadata ptr %dst, metadata !7, metadata !DIExpression()), !dbg !DILocation(scope: !4) 212 %cmp = icmp eq i32 undef, undef 213 br i1 %cmp, label %l0, label %l1 214l0: 215 br label %l2 216l1: 217 br label %l2 218l2: 219 %phidst = phi ptr [ %dst, %l0 ], [ %dst2, %l1 ] 220 store i32 0, ptr %phidst, !annotation !0, !dbg !DILocation(scope: !4) 221 ret void 222} 223 224; Function Attrs: nounwind readnone speculatable willreturn 225declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone speculatable willreturn 226 227!llvm.module.flags = !{!1} 228!0 = !{ !"auto-init" } 229!1 = !{i32 2, !"Debug Info Version", i32 3} 230!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3) 231!3 = !DIFile(filename: "file", directory: "") 232!4 = distinct !DISubprogram(name: "function", scope: !3, file: !3, unit: !2) 233!5 = !DIBasicType(name: "int", size: 32) 234!6 = !DILocalVariable(name: "destination", scope: !4, file: !3, type: !5) 235!7 = !DILocalVariable(name: "destination2", scope: !4, file: !3, type: !5) 236