mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 09:34:42 +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:
+2
-2
@@ -101,7 +101,7 @@ fn Test(a: A) -> C {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
|
||||
// CHECK:STDOUT: define void @"_CF:thunk:I.4b54445be9b10a0e.Main:61ea2aba74ab3bf1:I.Main"(ptr sret({ i32 }) %return, ptr %a) #1 !dbg !25 {
|
||||
// CHECK:STDOUT: define weak_odr void @"_CF:thunk:I.4b54445be9b10a0e.Main:61ea2aba74ab3bf1:I.Main"(ptr sret({ i32 }) %return, ptr %a) #1 !dbg !25 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.loc20_19.1.temp = alloca { i32 }, align 4, !dbg !28
|
||||
// CHECK:STDOUT: %.4.temp = alloca { i32 }, align 4, !dbg !29
|
||||
@@ -301,7 +301,7 @@ fn Test(a: A) -> C {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
|
||||
// CHECK:STDOUT: define void @"_CF:thunk:I.c81631f865470482.Main:X.Main:I.Main"(ptr sret({ i32 }) %return, ptr %a) #1 !dbg !13 {
|
||||
// CHECK:STDOUT: define weak_odr void @"_CF:thunk:I.c81631f865470482.Main:X.Main:I.Main"(ptr sret({ i32 }) %return, ptr %a) #1 !dbg !13 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.loc9_19.1.temp = alloca { i32 }, align 4, !dbg !16
|
||||
// CHECK:STDOUT: %.4.temp = alloca { i32 }, align 4, !dbg !17
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ fn CallCallGeneric(c: C(()), b: B) -> A {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
|
||||
// CHECK:STDOUT: define void @"_CF:thunk:I.4b54445be9b10a0e.Main:61ea2aba74ab3bf1:I.Main"(ptr sret({ i32 }) %return, ptr %a) #1 !dbg !25 {
|
||||
// CHECK:STDOUT: define weak_odr void @"_CF:thunk:I.4b54445be9b10a0e.Main:61ea2aba74ab3bf1:I.Main"(ptr sret({ i32 }) %return, ptr %a) #1 !dbg !25 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.loc20_19.1.temp = alloca { i32 }, align 4, !dbg !28
|
||||
// CHECK:STDOUT: %.4.temp = alloca { i32 }, align 4, !dbg !29
|
||||
|
||||
Reference in New Issue
Block a user