diff --git a/nac3core/src/codegen/test.rs b/nac3core/src/codegen/test.rs index 9b55e872c..2b5d98ae1 100644 --- a/nac3core/src/codegen/test.rs +++ b/nac3core/src/codegen/test.rs @@ -181,23 +181,43 @@ fn test_primitives() { ; ModuleID = 'test' source_filename = \"test\" - define i32 @testing(i32 %0, i32 %1) { + define i32 @testing(i32 %0, i32 %1) !dbg !4 { init: - %add = add i32 %0, %1 - %cmp = icmp eq i32 %add, 1 - br i1 %cmp, label %then, label %else + %add = add i32 %0, %1, !dbg !9 + %cmp = icmp eq i32 %add, 1, !dbg !11 + br i1 %cmp, label %then, label %else, !dbg !11 then: ; preds = %init - br label %cont + br label %cont, !dbg !12 else: ; preds = %init - br label %cont + br label %cont, !dbg !13 cont: ; preds = %else, %then - %if_exp_result.0 = phi i32 [ %0, %then ], [ 0, %else ] - ret i32 %if_exp_result.0 + %if_exp_result.0 = phi i32 [ %0, %then ], [ 0, %else ], !dbg !14 + ret i32 %if_exp_result.0, !dbg !15 } - "} + + !llvm.module.flags = !{!0, !1} + !llvm.dbg.cu = !{!2} + + !0 = !{i32 2, !\"Debug Info Version\", i32 3} + !1 = !{i32 2, !\"Dwarf Version\", i32 4} + !2 = distinct !DICompileUnit(language: DW_LANG_Python, file: !3, producer: \"NAC3\", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) + !3 = !DIFile(filename: \"unknown\", directory: \"\") + !4 = distinct !DISubprogram(name: \"testing\", linkageName: \"testing\", scope: null, file: !3, type: !5, flags: DIFlagPublic, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !2, retainedNodes: !8) + !5 = !DISubroutineType(flags: DIFlagPublic, types: !6) + !6 = !{!7} + !7 = !DIBasicType(name: \"_\", flags: DIFlagPublic) + !8 = !{} + !9 = !DILocation(line: 1, column: 9, scope: !10) + !10 = distinct !DILexicalBlock(scope: !4, file: !3, line: 1, column: 1) + !11 = !DILocation(line: 2, column: 15, scope: !10) + !12 = !DILocation(line: 2, column: 5, scope: !10) + !13 = !DILocation(line: 2, column: 22, scope: !10) + !14 = !DILocation(line: 0, scope: !10) + !15 = !DILocation(line: 3, column: 8, scope: !10) + "} .trim(); assert_eq!(expected, module.print_to_string().to_str().unwrap().trim()); }))); @@ -341,20 +361,40 @@ fn test_simple_call() { let expected = indoc! {" ; ModuleID = 'test' source_filename = \"test\" - - define i32 @testing(i32 %0) { + + define i32 @testing(i32 %0) !dbg !5 { init: - %call = call i32 @foo.0(i32 %0) - %mul = mul i32 %call, 2 - ret i32 %mul + %call = call i32 @foo.0(i32 %0), !dbg !10 + %mul = mul i32 %call, 2, !dbg !12 + ret i32 %mul, !dbg !12 } - - define i32 @foo.0(i32 %0) { + + define i32 @foo.0(i32 %0) !dbg !13 { init: - %add = add i32 %0, 1 - ret i32 %add + %add = add i32 %0, 1, !dbg !14 + ret i32 %add, !dbg !14 } - "} + + !llvm.module.flags = !{!0, !1} + !llvm.dbg.cu = !{!2, !4} + + !0 = !{i32 2, !\"Debug Info Version\", i32 3} + !1 = !{i32 2, !\"Dwarf Version\", i32 4} + !2 = distinct !DICompileUnit(language: DW_LANG_Python, file: !3, producer: \"NAC3\", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) + !3 = !DIFile(filename: \"unknown\", directory: \"\") + !4 = distinct !DICompileUnit(language: DW_LANG_Python, file: !3, producer: \"NAC3\", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) + !5 = distinct !DISubprogram(name: \"testing\", linkageName: \"testing\", scope: null, file: !3, type: !6, flags: DIFlagPublic, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !2, retainedNodes: !9) + !6 = !DISubroutineType(flags: DIFlagPublic, types: !7) + !7 = !{!8} + !8 = !DIBasicType(name: \"_\", flags: DIFlagPublic) + !9 = !{} + !10 = !DILocation(line: 1, column: 9, scope: !11) + !11 = distinct !DILexicalBlock(scope: !5, file: !3, line: 1, column: 1) + !12 = !DILocation(line: 2, column: 12, scope: !11) + !13 = distinct !DISubprogram(name: \"foo.0\", linkageName: \"foo.0\", scope: null, file: !3, type: !6, flags: DIFlagPublic, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !4, retainedNodes: !9) + !14 = !DILocation(line: 1, column: 12, scope: !15) + !15 = distinct !DILexicalBlock(scope: !13, file: !3, line: 1, column: 1) + "} .trim(); assert_eq!(expected, module.print_to_string().to_str().unwrap().trim()); })));