Home | History | Annotate | Download | only in LCSSA
      1 ; RUN: opt -S -lcssa < %s | FileCheck %s
      2 
      3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
      4 target triple = "x86_64-unknown-linux-gnu"
      5 
      6 ; Reproducer for PR39019.
      7 ;
      8 ; Verify that the llvm.dbg.value in the %for.cond.cleanup2 block is rewritten
      9 ; to use the PHI node for %add that is created by LCSSA.
     10 
     11 ; CHECK-LABEL: for.cond.cleanup2:
     12 ; CHECK-NEXT: [[PN:%[^ ]*]] = phi i32 [ %add.lcssa, %for.cond.cleanup1 ]
     13 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[PN]], metadata [[VAR:![0-9]+]], metadata !DIExpression())
     14 ; CHECK-NEXT: call void @bar(i32 [[PN]])
     15 
     16 ; CHECK-LABEL: for.body:
     17 ; CHECK: %add = add nsw i32 0, 2
     18 ; CHECK: call void @llvm.dbg.value(metadata i32 %add, metadata [[VAR]], metadata !DIExpression())
     19 
     20 ; CHECK: [[VAR]] = !DILocalVariable(name: "sum",
     21 
     22 ; Function Attrs: nounwind
     23 define void @foo() #0 !dbg !6 {
     24 entry:
     25   br label %for.cond.preheader, !dbg !12
     26 
     27 for.cond.preheader:                               ; preds = %for.cond.cleanup1, %entry
     28   br label %for.body, !dbg !12
     29 
     30 for.cond.cleanup2:                                ; preds = %for.cond.cleanup1
     31   call void @llvm.dbg.value(metadata i32 %add, metadata !9, metadata !DIExpression()), !dbg !12
     32   tail call void @bar(i32 %add) #0, !dbg !12
     33   ret void, !dbg !12
     34 
     35 for.cond.cleanup1:                                ; preds = %for.body
     36   br i1 false, label %for.cond.preheader, label %for.cond.cleanup2, !dbg !12
     37 
     38 for.body:                                         ; preds = %for.body, %for.cond.preheader
     39   %add = add nsw i32 0, 2, !dbg !12
     40   call void @llvm.dbg.value(metadata i32 %add, metadata !9, metadata !DIExpression()), !dbg !12
     41   br i1 false, label %for.body, label %for.cond.cleanup1, !dbg !12
     42 }
     43 
     44 ; Function Attrs: nounwind
     45 declare void @bar(i32) #0
     46 
     47 ; Function Attrs: nounwind readnone speculatable
     48 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
     49 
     50 attributes #0 = { nounwind }
     51 attributes #1 = { nounwind readnone speculatable }
     52 
     53 !llvm.dbg.cu = !{!0}
     54 !llvm.module.flags = !{!3, !4}
     55 !llvm.ident = !{!5}
     56 
     57 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 8.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !2)
     58 !1 = !DIFile(filename: "foo.c", directory: "/")
     59 !2 = !{}
     60 !3 = !{i32 2, !"Dwarf Version", i32 4}
     61 !4 = !{i32 2, !"Debug Info Version", i32 3}
     62 !5 = !{!"clang version 8.0.0"}
     63 !6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 10, type: !7, isLocal: false, isDefinition: true, scopeLine: 10, isOptimized: true, unit: !0, retainedNodes: !8)
     64 !7 = !DISubroutineType(types: !2)
     65 !8 = !{!9}
     66 !9 = !DILocalVariable(name: "sum", scope: !10, file: !1, line: 11, type: !11)
     67 !10 = !DILexicalBlockFile(scope: !6, file: !1, discriminator: 0)
     68 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
     69 !12 = !DILocation(line: 0, scope: !10)
     70