brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.8 KiB · d3355ef Raw
235 lines · plain
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 %s2; RUN: cat %t.opt.yaml | FileCheck -check-prefix=YAML %s3 4; Emit a remark that reports a store.5define void @store(ptr %dst) {6; CHECK:      Store inserted by -ftrivial-auto-var-init.7; CHECK-NEXT: Store size: 4 bytes.8; YAML-LABEL: --- !Missed9; YAML-NEXT: Pass:            annotation-remarks10; YAML-NEXT: Name:            AutoInitStore11; YAML-NEXT: DebugLoc:12; YAML-NEXT: Function:        store13; YAML-NEXT: Args:14; YAML-NEXT:   - String:          Store inserted by -ftrivial-auto-var-init.15; YAML-NEXT:   - String:          "\nStore size: "16; YAML-NEXT:   - StoreSize:       '4'17; YAML-NEXT:   - String:          ' bytes.'18; YAML-NEXT:   - String:          ' Volatile: '19; YAML-NEXT:   - StoreVolatile:       'false'20; YAML-NEXT:   - String:          .21; YAML-NEXT:   - String:          ' Atomic: '22; YAML-NEXT:   - StoreAtomic:       'false'23; YAML-NEXT:   - String:          .24; YAML-NEXT: ...25  store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)26  ret void27}28 29; Emit a remark that reports a volatile store.30define void @volatile_store(ptr %dst) {31; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.32; CHECK-NEXT: Store size: 4 bytes. Volatile: true.33; YAML-LABEL: --- !Missed34; YAML-NEXT: Pass:            annotation-remarks35; YAML-NEXT: Name:            AutoInitStore36; YAML-NEXT: DebugLoc:37; YAML-NEXT: Function:        volatile_store38; YAML-NEXT: Args:39; YAML-NEXT:   - String:          Store inserted by -ftrivial-auto-var-init.40; YAML-NEXT:   - String:          "\nStore size: "41; YAML-NEXT:   - StoreSize:       '4'42; YAML-NEXT:   - String:          ' bytes.'43; YAML-NEXT:   - String:          ' Volatile: '44; YAML-NEXT:   - StoreVolatile:       'true'45; YAML-NEXT:   - String:          .46; YAML-NEXT:   - String:          ' Atomic: '47; YAML-NEXT:   - StoreAtomic:       'false'48; YAML-NEXT:   - String:          .49; YAML-NEXT: ...50  store volatile i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)51  ret void52}53 54; Emit a remark that reports an atomic store.55define void @atomic_store(ptr %dst) {56; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.57; CHECK-NEXT: Store size: 4 bytes. Atomic: true.58; YAML-LABEL: --- !Missed59; YAML-NEXT: Pass:            annotation-remarks60; YAML-NEXT: Name:            AutoInitStore61; YAML-NEXT: DebugLoc:62; YAML-NEXT: Function:        atomic_store63; YAML-NEXT: Args:64; YAML-NEXT:   - String:          Store inserted by -ftrivial-auto-var-init.65; YAML-NEXT:   - String:          "\nStore size: "66; YAML-NEXT:   - StoreSize:       '4'67; YAML-NEXT:   - String:          ' bytes.'68; YAML-NEXT:   - String:          ' Atomic: '69; YAML-NEXT:   - StoreAtomic:       'true'70; YAML-NEXT:   - String:          .71; YAML-NEXT:   - String:          ' Volatile: '72; YAML-NEXT:   - StoreVolatile:       'false'73; YAML-NEXT:   - String:          .74; YAML-NEXT: ...75  store atomic i32 0, ptr %dst unordered, align 4, !annotation !0, !dbg !DILocation(scope: !4)76  ret void77}78 79; Emit a remark that reports a store to an alloca.80define void @store_alloca() {81; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.82; CHECK-NEXT: Store size: 4 bytes.83; CHECK-NEXT: Variables: dst (4 bytes).84; YAML-LABEL: --- !Missed85; YAML-NEXT: Pass:            annotation-remarks86; YAML-NEXT: Name:            AutoInitStore87; YAML-NEXT: DebugLoc:88; YAML-NEXT: Function:        store_alloca89; YAML-NEXT: Args:90; YAML-NEXT:   - String:          Store inserted by -ftrivial-auto-var-init.91; YAML-NEXT:   - String:          "\nStore size: "92; YAML-NEXT:   - StoreSize:       '4'93; YAML-NEXT:   - String:          ' bytes.'94; YAML-NEXT:   - String:          "\n Written Variables: "95; YAML-NEXT:   - WVarName:        dst96; YAML-NEXT:   - String:          ' ('97; YAML-NEXT:   - WVarSize:        '4'98; YAML-NEXT:   - String:          ' bytes)'99; YAML-NEXT:   - String:          .100; YAML-NEXT:   - String:          ' Volatile: '101; YAML-NEXT:   - StoreVolatile:    'false'102; YAML-NEXT:   - String:          .103; YAML-NEXT:   - String:          ' Atomic: '104; YAML-NEXT:   - StoreAtomic:     'false'105; YAML-NEXT:   - String:          .106; YAML-NEXT: ...107  %dst = alloca i32108  store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)109  ret void110}111 112; Emit a remark that reports a store to an alloca through a GEP.113define void @store_alloca_gep() {114; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.115; CHECK-NEXT: Store size: 4 bytes.116; CHECK-NEXT: Variables: dst (4 bytes).117  %dst = alloca i32118  store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)119  ret void120}121 122; Emit a remark that reports a store to an alloca through a GEP, with ptrtoint+inttoptr in the way.123define void @store_alloca_gep_inttoptr() {124; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.125; CHECK-NEXT: Store size: 4 bytes.126; CHECK-NEXT: Variables: dst (4 bytes).127  %dst = alloca i32128  %p2i = ptrtoint ptr %dst to i64129  %i2p = inttoptr i64 %p2i to ptr130  store i32 0, ptr %i2p, !annotation !0, !dbg !DILocation(scope: !4)131  ret void132}133 134; Emit a remark that reports a store to an alloca through a GEP in an array.135define void @store_alloca_gep_array() {136; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.137; CHECK-NEXT: Store size: 4 bytes.138; CHECK-NEXT: Variables: dst (8 bytes).139  %dst = alloca [2 x i32]140  store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)141  ret void142}143 144; Emit a remark that reports a store to an alloca through a bitcast.145define void @store_alloca_bitcast() {146; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.147; CHECK-NEXT: Store size: 4 bytes.148; CHECK-NEXT: Variables: dst (4 bytes).149  %dst = alloca [2 x i16]150  store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)151  ret void152}153 154; Emit a remark that reports a store to an alloca that has a DILocalVariable155; attached.156define void @store_alloca_di() {157; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.158; CHECK-NEXT: Store size: 4 bytes.159; CHECK-NEXT: Variables: destination (4 bytes).160  %dst = alloca i32161  store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)162  call void @llvm.dbg.declare(metadata ptr %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4)163  ret void164}165 166; Emit a remark that reports a store to an alloca that has more than one167; DILocalVariable attached.168define void @store_alloca_di_multiple() {169; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.170; CHECK-NEXT: Store size: 4 bytes.171; CHECK-NEXT: Variables: destination2 (4 bytes), destination (4 bytes).172  %dst = alloca i32173  store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)174  call void @llvm.dbg.declare(metadata ptr %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4)175  call void @llvm.dbg.declare(metadata ptr %dst, metadata !7, metadata !DIExpression()), !dbg !DILocation(scope: !4)176  ret void177}178 179; Emit a remark that reports a store to a PHI node that can be two different180; allocas.181define void @store_alloca_phi() {182; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.183; CHECK-NEXT: Store size: 4 bytes.184; CHECK-NEXT: Variables: dst2 (4 bytes), dst (4 bytes).185entry:186  %dst = alloca i32187  %dst2 = alloca i32188  %cmp = icmp eq i32 undef, undef189  br i1 %cmp, label %l0, label %l1190l0:191  br label %l2192l1:193  br label %l2194l2:195  %phidst = phi ptr [ %dst, %l0 ], [ %dst2, %l1 ]196  store i32 0, ptr %phidst, !annotation !0, !dbg !DILocation(scope: !4)197  ret void198}199 200; Emit a remark that reports a store to a PHI node that can be two different201; allocas, where one of it has multiple DILocalVariable.202define void @store_alloca_phi_di_multiple() {203; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.204; CHECK-NEXT: Store size: 4 bytes.205; CHECK-NEXT: Variables: dst2 (4 bytes), destination2 (4 bytes), destination (4 bytes).206entry:207  %dst = alloca i32208  %dst2 = alloca i32209  call void @llvm.dbg.declare(metadata ptr %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4)210  call void @llvm.dbg.declare(metadata ptr %dst, metadata !7, metadata !DIExpression()), !dbg !DILocation(scope: !4)211  %cmp = icmp eq i32 undef, undef212  br i1 %cmp, label %l0, label %l1213l0:214  br label %l2215l1:216  br label %l2217l2:218  %phidst = phi ptr [ %dst, %l0 ], [ %dst2, %l1 ]219  store i32 0, ptr %phidst, !annotation !0, !dbg !DILocation(scope: !4)220  ret void221}222 223; Function Attrs: nounwind readnone speculatable willreturn224declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone speculatable willreturn225 226!llvm.module.flags = !{!1}227!0 = !{ !"auto-init" }228!1 = !{i32 2, !"Debug Info Version", i32 3}229!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3)230!3 = !DIFile(filename: "file", directory: "")231!4 = distinct !DISubprogram(name: "function", scope: !3, file: !3, unit: !2)232!5 = !DIBasicType(name: "int", size: 32)233!6 = !DILocalVariable(name: "destination", scope: !4, file: !3, type: !5)234!7 = !DILocalVariable(name: "destination2", scope: !4, file: !3, type: !5)235