Skip to content

Commit b2ea19f

Browse files
authored
Add a small lowering test with an imported argument. (#4529)
We don't have much import coverage at present, but this seems worth a tiny bit of validation. I believe the LLVM IR is currently correct.
1 parent a720921 commit b2ea19f

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

toolchain/lower/testdata/packages/cross_package_call.carbon

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@
1212

1313
package A;
1414
namespace NS;
15+
1516
fn NS.F() {}
1617

18+
fn NS.G(x: i32) -> i32 { return x; }
19+
1720
// --- b.carbon
1821

1922
import A;
2023

21-
fn G() { A.NS.F(); }
24+
fn F() { A.NS.F(); }
25+
26+
fn G() -> i32 { return A.NS.G(1); }
2227

2328
// CHECK:STDOUT: ; ModuleID = 'a.carbon'
2429
// CHECK:STDOUT: source_filename = "a.carbon"
@@ -28,37 +33,55 @@ fn G() { A.NS.F(); }
2833
// CHECK:STDOUT: ret void, !dbg !7
2934
// CHECK:STDOUT: }
3035
// CHECK:STDOUT:
36+
// CHECK:STDOUT: define i32 @_CG.NS.A(i32 %x) !dbg !8 {
37+
// CHECK:STDOUT: entry:
38+
// CHECK:STDOUT: ret i32 %x, !dbg !9
39+
// CHECK:STDOUT: }
40+
// CHECK:STDOUT:
3141
// CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
3242
// CHECK:STDOUT: !llvm.dbg.cu = !{!2}
3343
// CHECK:STDOUT:
3444
// CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
3545
// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
3646
// CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
3747
// CHECK:STDOUT: !3 = !DIFile(filename: "a.carbon", directory: "")
38-
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.NS.A", scope: null, file: !3, line: 4, type: !5, spFlags: DISPFlagDefinition, unit: !2)
48+
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.NS.A", scope: null, file: !3, line: 5, type: !5, spFlags: DISPFlagDefinition, unit: !2)
3949
// CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
4050
// CHECK:STDOUT: !6 = !{}
41-
// CHECK:STDOUT: !7 = !DILocation(line: 4, column: 1, scope: !4)
51+
// CHECK:STDOUT: !7 = !DILocation(line: 5, column: 1, scope: !4)
52+
// CHECK:STDOUT: !8 = distinct !DISubprogram(name: "G", linkageName: "_CG.NS.A", scope: null, file: !3, line: 7, type: !5, spFlags: DISPFlagDefinition, unit: !2)
53+
// CHECK:STDOUT: !9 = !DILocation(line: 7, column: 26, scope: !8)
4254
// CHECK:STDOUT: ; ModuleID = 'b.carbon'
4355
// CHECK:STDOUT: source_filename = "b.carbon"
4456
// CHECK:STDOUT:
45-
// CHECK:STDOUT: define void @_CG.Main() !dbg !4 {
57+
// CHECK:STDOUT: define void @_CF.Main() !dbg !4 {
4658
// CHECK:STDOUT: entry:
4759
// CHECK:STDOUT: call void @_CF.NS.A(), !dbg !7
4860
// CHECK:STDOUT: ret void, !dbg !8
4961
// CHECK:STDOUT: }
5062
// CHECK:STDOUT:
5163
// CHECK:STDOUT: declare void @_CF.NS.A()
5264
// CHECK:STDOUT:
65+
// CHECK:STDOUT: define i32 @_CG.Main() !dbg !9 {
66+
// CHECK:STDOUT: entry:
67+
// CHECK:STDOUT: %G.call = call i32 @_CG.NS.A(i32 1), !dbg !10
68+
// CHECK:STDOUT: ret i32 %G.call, !dbg !11
69+
// CHECK:STDOUT: }
70+
// CHECK:STDOUT:
71+
// CHECK:STDOUT: declare i32 @_CG.NS.A(i32)
72+
// CHECK:STDOUT:
5373
// CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
5474
// CHECK:STDOUT: !llvm.dbg.cu = !{!2}
5575
// CHECK:STDOUT:
5676
// CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
5777
// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
5878
// CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
5979
// CHECK:STDOUT: !3 = !DIFile(filename: "b.carbon", directory: "")
60-
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main", scope: null, file: !3, line: 4, type: !5, spFlags: DISPFlagDefinition, unit: !2)
80+
// CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 4, type: !5, spFlags: DISPFlagDefinition, unit: !2)
6181
// CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
6282
// CHECK:STDOUT: !6 = !{}
6383
// CHECK:STDOUT: !7 = !DILocation(line: 4, column: 10, scope: !4)
6484
// CHECK:STDOUT: !8 = !DILocation(line: 4, column: 1, scope: !4)
85+
// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main", scope: null, file: !3, line: 6, type: !5, spFlags: DISPFlagDefinition, unit: !2)
86+
// CHECK:STDOUT: !10 = !DILocation(line: 6, column: 24, scope: !9)
87+
// CHECK:STDOUT: !11 = !DILocation(line: 6, column: 17, scope: !9)

0 commit comments

Comments
 (0)