codegenprep-value.ll 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ; RUN: opt -codegenprepare -S %s | FileCheck %s
  2. ;
  3. ; Generated from the following source with:
  4. ; clang -O2 -g -S -emit-llvm -mllvm -stop-after=indirectbr-expand test.cpp
  5. ;
  6. ; extern void use(int);
  7. ; extern int foo(long long);
  8. ;
  9. ; void test(int p)
  10. ; {
  11. ; int i = p + 4;
  12. ; (void)foo(i); // sign extension of i
  13. ; if (p)
  14. ; return;
  15. ; use(i); // use of original i
  16. ; }
  17. ;
  18. ; PR39845: Check that CodeGenPrepare does not drop the reference to a local when it is
  19. ; sign-extended and used later.
  20. ;
  21. ; CHECK: define{{.*}}test
  22. ; CHECK: call{{.*}}dbg.value(metadata i32 %p
  23. ; CHECK: call{{.*}}dbg.value(metadata i32 %add
  24. ;
  25. define dso_local void @_Z4testi(i32 %p) local_unnamed_addr !dbg !7 {
  26. entry:
  27. call void @llvm.dbg.value(metadata i32 %p, metadata !12, metadata !DIExpression()), !dbg !14
  28. %add = add nsw i32 %p, 4, !dbg !15
  29. call void @llvm.dbg.value(metadata i32 %add, metadata !13, metadata !DIExpression()), !dbg !16
  30. %conv = sext i32 %add to i64, !dbg !17
  31. %call = tail call i32 @_Z3foox(i64 %conv), !dbg !18
  32. %tobool = icmp eq i32 %p, 0, !dbg !19
  33. br i1 %tobool, label %if.end, label %cleanup, !dbg !21
  34. if.end:
  35. tail call void @_Z3usei(i32 %add), !dbg !22
  36. br label %cleanup, !dbg !23
  37. cleanup:
  38. ret void, !dbg !23
  39. }
  40. declare dso_local i32 @_Z3foox(i64) local_unnamed_addr
  41. declare dso_local void @_Z3usei(i32) local_unnamed_addr
  42. declare void @llvm.dbg.value(metadata, metadata, metadata)
  43. !llvm.dbg.cu = !{!0}
  44. !llvm.module.flags = !{!3, !4, !5}
  45. !llvm.ident = !{!6}
  46. !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 8.0.0 (trunk 348209)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
  47. !1 = !DIFile(filename: "test.cpp", directory: "/home/test/src")
  48. !2 = !{}
  49. !3 = !{i32 2, !"Dwarf Version", i32 4}
  50. !4 = !{i32 2, !"Debug Info Version", i32 3}
  51. !5 = !{i32 1, !"wchar_size", i32 4}
  52. !6 = !{!"clang version 8.0.0 (trunk 348209)"}
  53. !7 = distinct !DISubprogram(name: "test", linkageName: "_Z4testi", scope: !1, file: !1, line: 4, type: !8, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
  54. !8 = !DISubroutineType(types: !9)
  55. !9 = !{null, !10}
  56. !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
  57. !11 = !{!12, !13}
  58. !12 = !DILocalVariable(name: "p", arg: 1, scope: !7, file: !1, line: 4, type: !10)
  59. !13 = !DILocalVariable(name: "i", scope: !7, file: !1, line: 6, type: !10)
  60. !14 = !DILocation(line: 4, column: 15, scope: !7)
  61. !15 = !DILocation(line: 6, column: 13, scope: !7)
  62. !16 = !DILocation(line: 6, column: 7, scope: !7)
  63. !17 = !DILocation(line: 7, column: 13, scope: !7)
  64. !18 = !DILocation(line: 7, column: 9, scope: !7)
  65. !19 = !DILocation(line: 8, column: 7, scope: !20)
  66. !20 = distinct !DILexicalBlock(scope: !7, file: !1, line: 8, column: 7)
  67. !21 = !DILocation(line: 8, column: 7, scope: !7)
  68. !22 = !DILocation(line: 10, column: 3, scope: !7)
  69. !23 = !DILocation(line: 11, column: 1, scope: !7)