mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Give thunks weak_odr linkage. (#7525)
We can end up emitting the same thunk from multiple compilations in some cases -- in particular, when the thunk is wrapping a function that is either synthesized by the compiler or imported from C++. When this happens, we will have multiple-definition link errors unless we allow redefinitions across multiple files. It'd be nice to detect when we need to do this and when we don't, but that's a bit tricky to do in practice. Ideally, in fact, we would use a different strategy, and emit the thunks as discardable definitions in each compilation that *uses* them. But for now emitting them with weak_odr linkage seems like a good way to make progress.
This commit is contained in:
@@ -84,7 +84,7 @@ fn Packed(n: i32) {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
|
||||
// CHECK:STDOUT: define void @"_COp:thunk:Default.c846b89dd79c7366.Core:NaturallyAligned.Cpp"(ptr sret([4 x i8]) %return) #2 !dbg !25 {
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp:thunk:Default.c846b89dd79c7366.Core:NaturallyAligned.Cpp"(ptr sret([4 x i8]) %return) #2 !dbg !25 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @_ZN16NaturallyAlignedC1Ev.carbon_thunk.(ptr %return), !dbg !29
|
||||
// CHECK:STDOUT: ret void, !dbg !29
|
||||
@@ -114,7 +114,7 @@ fn Packed(n: i32) {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
|
||||
// CHECK:STDOUT: define void @"_COp:thunk:Default.52e7708693d29223.Core:ExtraAlignment.Cpp"(ptr sret([16 x i8]) %return) #2 !dbg !39 {
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp:thunk:Default.52e7708693d29223.Core:ExtraAlignment.Cpp"(ptr sret([16 x i8]) %return) #2 !dbg !39 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @_ZN14ExtraAlignmentC1Ev.carbon_thunk.(ptr %return), !dbg !40
|
||||
// CHECK:STDOUT: ret void, !dbg !40
|
||||
@@ -144,7 +144,7 @@ fn Packed(n: i32) {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
|
||||
// CHECK:STDOUT: define void @"_COp:thunk:Default.ca2b917a39954a06.Core:Packed.Cpp"(ptr sret([4 x i8]) %return) #2 !dbg !50 {
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp:thunk:Default.ca2b917a39954a06.Core:Packed.Cpp"(ptr sret([4 x i8]) %return) #2 !dbg !50 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @_ZN6PackedC1Ev.carbon_thunk.(ptr %return), !dbg !51
|
||||
// CHECK:STDOUT: ret void, !dbg !51
|
||||
|
||||
Reference in New Issue
Block a user