mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-22 20:32:38 +00:00
Give Carbon thunks for C++ callers linkonce_odr linkage (#8022)
This allows two C++ callers to the same Carbon function, written in different Carbon files, to generate thunks that won't collide/duplicate symbol at link time - instead the thunks get deduplicated silently by the linker.
This commit is contained in:
1 parent
8fc87ebf76
commit
5c9ab26d74
16 files changed
+239
-33
No files matched your search
@@ -84,7 +84,7 @@ void f() {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_COneArg__carbon_thunk.OneArg.Main(ptr noundef nonnull align 1 %_, ptr noundef nonnull align 4 dereferenceable(4) %_1) unnamed_addr #5 !dbg !19 {
|
||||
// CHECK:STDOUT: define linkonce_odr void @_COneArg__carbon_thunk.OneArg.Main(ptr noundef nonnull align 1 %_, ptr noundef nonnull align 4 dereferenceable(4) %_1) unnamed_addr #5 !dbg !19 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.loc6_28.2 = load i32, ptr %_1, align 4, !dbg !22
|
||||
// CHECK:STDOUT: call void @_COneArg.OneArg.Main(ptr %_, i32 %.loc6_28.2), !dbg !22
|
||||
|
||||
@@ -125,7 +125,7 @@ void CallF() {
|
||||
// CHECK:STDOUT: declare void @_CF.OtherFunction(i32)
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_CF__carbon_thunk.OtherFunction(ptr noundef nonnull align 4 dereferenceable(4) %_) #2 !dbg !41 {
|
||||
// CHECK:STDOUT: define linkonce_odr void @_CF__carbon_thunk.OtherFunction(ptr noundef nonnull align 4 dereferenceable(4) %_) #2 !dbg !41 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.1 = load i32, ptr %_, align 4, !dbg !43
|
||||
// CHECK:STDOUT: call void @_CF.OtherFunction(i32 %.1), !dbg !43
|
||||
@@ -135,7 +135,7 @@ void CallF() {
|
||||
// CHECK:STDOUT: declare void @_CF.FirstFunction(i32)
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_CF__carbon_thunk.FirstFunction(ptr noundef nonnull align 4 dereferenceable(4) %_) #2 !dbg !45 {
|
||||
// CHECK:STDOUT: define linkonce_odr void @_CF__carbon_thunk.FirstFunction(ptr noundef nonnull align 4 dereferenceable(4) %_) #2 !dbg !45 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.1 = load i32, ptr %_, align 4, !dbg !47
|
||||
// CHECK:STDOUT: call void @_CF.FirstFunction(i32 %.1), !dbg !47
|
||||
|
||||
@@ -212,7 +212,7 @@ fn CallCallBase() { Cpp.CallBase(); }
|
||||
// CHECK:STDOUT: declare void @_CNoArgs.Other()
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_CNoArgs__carbon_thunk.Other() #2 !dbg !42 {
|
||||
// CHECK:STDOUT: define linkonce_odr void @_CNoArgs__carbon_thunk.Other() #2 !dbg !42 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @_CNoArgs.Other(), !dbg !43
|
||||
// CHECK:STDOUT: ret void, !dbg !43
|
||||
@@ -221,7 +221,7 @@ fn CallCallBase() { Cpp.CallBase(); }
|
||||
// CHECK:STDOUT: declare void @_CBoolArg.Other(i1)
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_CBoolArg__carbon_thunk.Other(ptr noundef nonnull align 1 dereferenceable(1) %_) #2 !dbg !44 {
|
||||
// CHECK:STDOUT: define linkonce_odr void @_CBoolArg__carbon_thunk.Other(ptr noundef nonnull align 1 dereferenceable(1) %_) #2 !dbg !44 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.1 = load i8, ptr %_, align 1, !dbg !46
|
||||
// CHECK:STDOUT: %.11 = trunc i8 %.1 to i1, !dbg !46
|
||||
@@ -232,7 +232,7 @@ fn CallCallBase() { Cpp.CallBase(); }
|
||||
// CHECK:STDOUT: declare void @_CIntArg.Other(i32)
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_CIntArg__carbon_thunk.Other(ptr noundef nonnull align 4 dereferenceable(4) %_) #2 !dbg !48 {
|
||||
// CHECK:STDOUT: define linkonce_odr void @_CIntArg__carbon_thunk.Other(ptr noundef nonnull align 4 dereferenceable(4) %_) #2 !dbg !48 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.1 = load i32, ptr %_, align 4, !dbg !50
|
||||
// CHECK:STDOUT: call void @_CIntArg.Other(i32 %.1), !dbg !50
|
||||
@@ -242,7 +242,7 @@ fn CallCallBase() { Cpp.CallBase(); }
|
||||
// CHECK:STDOUT: declare void @_CFloatArg.Other(float)
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_CFloatArg__carbon_thunk.Other(ptr noundef nonnull align 4 dereferenceable(4) %_) #2 !dbg !52 {
|
||||
// CHECK:STDOUT: define linkonce_odr void @_CFloatArg__carbon_thunk.Other(ptr noundef nonnull align 4 dereferenceable(4) %_) #2 !dbg !52 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.1 = load float, ptr %_, align 4, !dbg !54
|
||||
// CHECK:STDOUT: call void @_CFloatArg.Other(float %.1), !dbg !54
|
||||
@@ -252,7 +252,7 @@ fn CallCallBase() { Cpp.CallBase(); }
|
||||
// CHECK:STDOUT: declare i32 @_CIntReturn.Other()
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_CIntReturn__carbon_thunk.Other(ptr noundef nonnull align 4 dereferenceable(4) %_) #2 !dbg !56 {
|
||||
// CHECK:STDOUT: define linkonce_odr void @_CIntReturn__carbon_thunk.Other(ptr noundef nonnull align 4 dereferenceable(4) %_) #2 !dbg !56 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %IntReturn.call = call i32 @_CIntReturn.Other(), !dbg !58
|
||||
// CHECK:STDOUT: store i32 %IntReturn.call, ptr %_, align 4, !dbg !58
|
||||
@@ -329,7 +329,7 @@ fn CallCallBase() { Cpp.CallBase(); }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_CF__carbon_thunk.Main() #1 !dbg !77 {
|
||||
// CHECK:STDOUT: define linkonce_odr void @_CF__carbon_thunk.Main() #1 !dbg !77 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @_CF.Main(), !dbg !78
|
||||
// CHECK:STDOUT: ret void, !dbg !78
|
||||
@@ -409,7 +409,7 @@ fn CallCallBase() { Cpp.CallBase(); }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_Cbase__carbon_thunk.Main() #1 !dbg !86 {
|
||||
// CHECK:STDOUT: define linkonce_odr void @_Cbase__carbon_thunk.Main() #1 !dbg !86 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @_Cbase.Main(), !dbg !87
|
||||
// CHECK:STDOUT: ret void, !dbg !87
|
||||
|
||||
@@ -196,14 +196,14 @@ fn Run() {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_CF__carbon_thunk.26f2099a79512a5d.Main(ptr noundef nonnull align 1 %_) #6 !dbg !42 {
|
||||
// CHECK:STDOUT: define linkonce_odr void @_CF__carbon_thunk.26f2099a79512a5d.Main(ptr noundef nonnull align 1 %_) #6 !dbg !42 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @_CF.Main.6662a1ffb773360a(ptr %_), !dbg !44
|
||||
// CHECK:STDOUT: ret void, !dbg !44
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_CF__carbon_thunk.7a3b9f04ddf4269e.Main(ptr noundef nonnull align 1 %_) #6 !dbg !46 {
|
||||
// CHECK:STDOUT: define linkonce_odr void @_CF__carbon_thunk.7a3b9f04ddf4269e.Main(ptr noundef nonnull align 1 %_) #6 !dbg !46 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @_CF.Main.d53b17eed3ce903c(ptr %_), !dbg !48
|
||||
// CHECK:STDOUT: ret void, !dbg !48
|
||||
|
||||
+2
-2
@@ -84,7 +84,7 @@ fn H() -> i32 { return Cpp.G(); }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @"\01__CF__carbon_thunk.Main"(ptr noundef nonnull align 4 dereferenceable(4) %_, ptr noundef nonnull align 4 dereferenceable(4) %_1) #3 !dbg !26 {
|
||||
// CHECK:STDOUT: define linkonce_odr void @"\01__CF__carbon_thunk.Main"(ptr noundef nonnull align 4 dereferenceable(4) %_, ptr noundef nonnull align 4 dereferenceable(4) %_1) #3 !dbg !26 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.loc6 = load i32, ptr %_, align 4, !dbg !29
|
||||
// CHECK:STDOUT: %F.call = call i32 @_CF.Main(i32 %.loc6), !dbg !29
|
||||
@@ -222,7 +222,7 @@ fn H() -> i32 { return Cpp.G(); }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define noundef ptr @"\01__CC__carbon_thunk.C.Main"(ptr noundef nonnull returned align 4 dereferenceable(4) %_, ptr noundef nonnull align 4 dereferenceable(4) %_1) unnamed_addr #6 !dbg !74 {
|
||||
// CHECK:STDOUT: define linkonce_odr noundef ptr @"\01__CC__carbon_thunk.C.Main"(ptr noundef nonnull returned align 4 dereferenceable(4) %_, ptr noundef nonnull align 4 dereferenceable(4) %_1) unnamed_addr #6 !dbg !74 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.loc7_24.2 = load i32, ptr %_1, align 4, !dbg !77
|
||||
// CHECK:STDOUT: call void @_CC.C.Main(ptr %_, i32 %.loc7_24.2), !dbg !77
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
|
||||
//
|
||||
// AUTOUPDATE
|
||||
// TIP: To test this file alone, run:
|
||||
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/interop/cpp/function/export/multiple_files.carbon
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/interop/cpp/function/export/multiple_files.carbon
|
||||
|
||||
// Each file that exports a Carbon function to C++ emits its own copy of the
|
||||
// Carbon thunk for that function, so the thunk must have linkonce_odr linkage
|
||||
// to avoid duplicate symbols when the files are linked together.
|
||||
|
||||
// --- other.carbon
|
||||
|
||||
package Other;
|
||||
|
||||
fn Identity(n: i32) -> i32 {
|
||||
return n;
|
||||
}
|
||||
|
||||
// --- a.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Other;
|
||||
import Cpp inline '''
|
||||
int UseA() { return Carbon::Other::Identity(3); }
|
||||
''';
|
||||
|
||||
// --- b.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Other;
|
||||
import Cpp inline '''
|
||||
int UseB() { return Carbon::Other::Identity(4); }
|
||||
''';
|
||||
|
||||
// CHECK:STDOUT: ; ---
|
||||
// CHECK:STDOUT: ; ModuleID = 'other.carbon'
|
||||
// CHECK:STDOUT: source_filename = "other.carbon"
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define i32 @_CIdentity.Other(i32 %n) #0 !dbg !23 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret i32 %n, !dbg !29
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: attributes #0 = { nounwind }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !llvm.dbg.cu = !{!19}
|
||||
// CHECK:STDOUT: !llvm.module.flags = !{!2, !3}
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
|
||||
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
// CHECK:STDOUT: !18 = !DIFile(filename: "other.carbon", directory: "")
|
||||
// CHECK:STDOUT: !19 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !18, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
|
||||
// CHECK:STDOUT: !20 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
||||
// CHECK:STDOUT: !21 = !{!20, !20}
|
||||
// CHECK:STDOUT: !22 = !DISubroutineType(types: !21)
|
||||
// CHECK:STDOUT: !23 = distinct !DISubprogram(name: "Identity", linkageName: "_CIdentity.Other", scope: null, file: !18, line: 4, type: !22, spFlags: DISPFlagDefinition, unit: !19, retainedNodes: !30)
|
||||
// CHECK:STDOUT: !24 = !DILocalVariable(arg: 1, scope: !23, type: !20)
|
||||
// CHECK:STDOUT: !29 = !DILocation(line: 5, column: 3, scope: !23)
|
||||
// CHECK:STDOUT: !30 = !{!24}
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; ---
|
||||
// CHECK:STDOUT: ; ModuleID = 'a.carbon'
|
||||
// CHECK:STDOUT: source_filename = "a.carbon"
|
||||
// CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
|
||||
// CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: mustprogress uwtable
|
||||
// CHECK:STDOUT: define dso_local noundef i32 @_Z4UseAv() #0 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %call = call noundef i32 @_ZN6Carbon5OtherL8IdentityEi(i32 noundef 3)
|
||||
// CHECK:STDOUT: ret i32 %call
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable
|
||||
// CHECK:STDOUT: define internal noundef i32 @_ZN6Carbon5OtherL8IdentityEi(i32 noundef %0) #1 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %retval = alloca i32, align 4
|
||||
// CHECK:STDOUT: %.addr = alloca i32, align 4
|
||||
// CHECK:STDOUT: store i32 %0, ptr %.addr, align 4, !tbaa !43
|
||||
// CHECK:STDOUT: call void @_CIdentity__carbon_thunk.Other(ptr noundef nonnull align 4 dereferenceable(4) %.addr, ptr noundef nonnull align 4 dereferenceable(4) %retval)
|
||||
// CHECK:STDOUT: %1 = load i32, ptr %retval, align 4
|
||||
// CHECK:STDOUT: ret i32 %1
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: declare i32 @_CIdentity.Other(i32)
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define linkonce_odr void @_CIdentity__carbon_thunk.Other(ptr noundef nonnull align 4 dereferenceable(4) %_, ptr noundef nonnull align 4 dereferenceable(4) %_1) #2 !dbg !35 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.1 = load i32, ptr %_, align 4, !dbg !38
|
||||
// CHECK:STDOUT: %Identity.call = call i32 @_CIdentity.Other(i32 %.1), !dbg !38
|
||||
// CHECK:STDOUT: store i32 %Identity.call, ptr %_1, align 4, !dbg !38
|
||||
// CHECK:STDOUT: ret void, !dbg !38
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
// CHECK:STDOUT: attributes #1 = { alwaysinline mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
// CHECK:STDOUT: attributes #2 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !llvm.dbg.cu = !{!32}
|
||||
// CHECK:STDOUT: !llvm.module.flags = !{!44, !45, !46, !2, !3}
|
||||
// CHECK:STDOUT: !llvm.errno.tbaa = !{!48}
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
|
||||
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
// CHECK:STDOUT: !18 = !DIFile(filename: "other.carbon", directory: "")
|
||||
// CHECK:STDOUT: !20 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
||||
// CHECK:STDOUT: !31 = !DIFile(filename: "a.carbon", directory: "")
|
||||
// CHECK:STDOUT: !32 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !31, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
|
||||
// CHECK:STDOUT: !33 = !{null, !20, !20}
|
||||
// CHECK:STDOUT: !34 = !DISubroutineType(types: !33)
|
||||
// CHECK:STDOUT: !35 = distinct !DISubprogram(name: "Identity__carbon_thunk", linkageName: "_CIdentity__carbon_thunk.Other", scope: null, file: !18, line: 4, type: !34, spFlags: DISPFlagDefinition, unit: !32, retainedNodes: !39)
|
||||
// CHECK:STDOUT: !36 = !DILocalVariable(arg: 1, scope: !35, type: !20)
|
||||
// CHECK:STDOUT: !37 = !DILocalVariable(arg: 2, scope: !35, type: !20)
|
||||
// CHECK:STDOUT: !38 = !DILocation(line: 4, column: 1, scope: !35)
|
||||
// CHECK:STDOUT: !39 = !{!36, !37}
|
||||
// CHECK:STDOUT: !40 = !{!"Simple C++ TBAA"}
|
||||
// CHECK:STDOUT: !41 = !{!"omnipotent char", !40, i64 0}
|
||||
// CHECK:STDOUT: !42 = !{!"int", !41, i64 0}
|
||||
// CHECK:STDOUT: !43 = !{!42, !42, i64 0}
|
||||
// CHECK:STDOUT: !44 = !{i32 8, !"PIC Level", i32 2}
|
||||
// CHECK:STDOUT: !45 = !{i32 7, !"PIE Level", i32 2}
|
||||
// CHECK:STDOUT: !46 = !{i32 7, !"uwtable", i32 2}
|
||||
// CHECK:STDOUT: !47 = !{!"__libc_errno", !42, i64 0}
|
||||
// CHECK:STDOUT: !48 = !{!47, !42, i64 0}
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; ---
|
||||
// CHECK:STDOUT: ; ModuleID = 'b.carbon'
|
||||
// CHECK:STDOUT: source_filename = "b.carbon"
|
||||
// CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
|
||||
// CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: mustprogress uwtable
|
||||
// CHECK:STDOUT: define dso_local noundef i32 @_Z4UseBv() #0 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %call = call noundef i32 @_ZN6Carbon5OtherL8IdentityEi(i32 noundef 4)
|
||||
// CHECK:STDOUT: ret i32 %call
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable
|
||||
// CHECK:STDOUT: define internal noundef i32 @_ZN6Carbon5OtherL8IdentityEi(i32 noundef %0) #1 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %retval = alloca i32, align 4
|
||||
// CHECK:STDOUT: %.addr = alloca i32, align 4
|
||||
// CHECK:STDOUT: store i32 %0, ptr %.addr, align 4, !tbaa !43
|
||||
// CHECK:STDOUT: call void @_CIdentity__carbon_thunk.Other(ptr noundef nonnull align 4 dereferenceable(4) %.addr, ptr noundef nonnull align 4 dereferenceable(4) %retval)
|
||||
// CHECK:STDOUT: %1 = load i32, ptr %retval, align 4
|
||||
// CHECK:STDOUT: ret i32 %1
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: declare i32 @_CIdentity.Other(i32)
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define linkonce_odr void @_CIdentity__carbon_thunk.Other(ptr noundef nonnull align 4 dereferenceable(4) %_, ptr noundef nonnull align 4 dereferenceable(4) %_1) #2 !dbg !51 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.1 = load i32, ptr %_, align 4, !dbg !54
|
||||
// CHECK:STDOUT: %Identity.call = call i32 @_CIdentity.Other(i32 %.1), !dbg !54
|
||||
// CHECK:STDOUT: store i32 %Identity.call, ptr %_1, align 4, !dbg !54
|
||||
// CHECK:STDOUT: ret void, !dbg !54
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
// CHECK:STDOUT: attributes #1 = { alwaysinline mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
// CHECK:STDOUT: attributes #2 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !llvm.dbg.cu = !{!50}
|
||||
// CHECK:STDOUT: !llvm.module.flags = !{!44, !45, !46, !2, !3}
|
||||
// CHECK:STDOUT: !llvm.errno.tbaa = !{!48}
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
|
||||
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
// CHECK:STDOUT: !18 = !DIFile(filename: "other.carbon", directory: "")
|
||||
// CHECK:STDOUT: !20 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
||||
// CHECK:STDOUT: !33 = !{null, !20, !20}
|
||||
// CHECK:STDOUT: !34 = !DISubroutineType(types: !33)
|
||||
// CHECK:STDOUT: !40 = !{!"Simple C++ TBAA"}
|
||||
// CHECK:STDOUT: !41 = !{!"omnipotent char", !40, i64 0}
|
||||
// CHECK:STDOUT: !42 = !{!"int", !41, i64 0}
|
||||
// CHECK:STDOUT: !43 = !{!42, !42, i64 0}
|
||||
// CHECK:STDOUT: !44 = !{i32 8, !"PIC Level", i32 2}
|
||||
// CHECK:STDOUT: !45 = !{i32 7, !"PIE Level", i32 2}
|
||||
// CHECK:STDOUT: !46 = !{i32 7, !"uwtable", i32 2}
|
||||
// CHECK:STDOUT: !47 = !{!"__libc_errno", !42, i64 0}
|
||||
// CHECK:STDOUT: !48 = !{!47, !42, i64 0}
|
||||
// CHECK:STDOUT: !49 = !DIFile(filename: "b.carbon", directory: "")
|
||||
// CHECK:STDOUT: !50 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !49, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
|
||||
// CHECK:STDOUT: !51 = distinct !DISubprogram(name: "Identity__carbon_thunk", linkageName: "_CIdentity__carbon_thunk.Other", scope: null, file: !18, line: 4, type: !34, spFlags: DISPFlagDefinition, unit: !50, retainedNodes: !55)
|
||||
// CHECK:STDOUT: !52 = !DILocalVariable(arg: 1, scope: !51, type: !20)
|
||||
// CHECK:STDOUT: !53 = !DILocalVariable(arg: 2, scope: !51, type: !20)
|
||||
// CHECK:STDOUT: !54 = !DILocation(line: 4, column: 1, scope: !51)
|
||||
// CHECK:STDOUT: !55 = !{!52, !53}
|
||||
// CHECK:STDOUT:
|
||||
Reference in new issue
Block a user