sunk-compare.ll 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ; RUN: opt -S -codegenprepare < %s | FileCheck %s
  2. ;
  3. ; This test case has been generated by hand but is inspired by the
  4. ; observation that compares that are sunk into the basic blocks where
  5. ; their results are used did not retain their debug locs. This caused
  6. ; sample profiling to attribute code to the wrong source lines.
  7. ;
  8. ; We check that the compare instruction retains its debug loc after
  9. ; it is sunk into other.bb by the codegen prepare pass.
  10. ;
  11. ; CHECK: entry:
  12. ; CHECK-NEXT: icmp{{.*}}%x, 0, !dbg ![[MDHANDLE:[0-9]*]]
  13. ; CHECK: ![[MDHANDLE]] = !DILocation(line: 2
  14. ;
  15. target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
  16. define i32 @_Z3fooii(i32 %x, i32 %y) !dbg !5 {
  17. entry:
  18. %cmp17 = icmp sgt i32 %x, 0, !dbg !6
  19. br label %other.bb, !dbg !6
  20. other.bb:
  21. br i1 %cmp17, label %exit1.bb, label %exit2.bb, !dbg !7
  22. exit1.bb:
  23. %0 = add i32 %y, 42, !dbg !8
  24. ret i32 %0, !dbg !8
  25. exit2.bb:
  26. ret i32 44, !dbg !9
  27. }
  28. !llvm.dbg.cu = !{!0}
  29. !llvm.module.flags = !{!3, !4}
  30. !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !2)
  31. !1 = !DIFile(filename: "test.cpp", directory: "/debuginfo/bug/cgp")
  32. !2 = !{}
  33. !3 = !{i32 2, !"Dwarf Version", i32 4}
  34. !4 = !{i32 2, !"Debug Info Version", i32 3}
  35. !5 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 1, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
  36. !6 = !DILocation(line: 2, column: 0, scope: !5)
  37. !7 = !DILocation(line: 3, column: 0, scope: !5)
  38. !8 = !DILocation(line: 4, column: 0, scope: !5)
  39. !9 = !DILocation(line: 5, column: 0, scope: !5)