]> granicus.if.org Git - clang/commitdiff
Give thunks the same linkage as their original methods.
authorAnders Carlsson <andersca@mac.com>
Sat, 27 Mar 2010 20:50:27 +0000 (20:50 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 27 Mar 2010 20:50:27 +0000 (20:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99729 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGVtable.cpp
test/CodeGenCXX/thunks.cpp

index 65788259e64fc70f90578a5f39b7ea9dfbc79404..4bdda985aa7423907a778d5c11ec6077c3eebcf9 100644 (file)
@@ -3867,14 +3867,7 @@ void CodeGenFunction::GenerateThunk(llvm::Function *Fn, GlobalDecl GD,
   CXXThisDecl->Destroy(getContext());
   
   // Set the right linkage.
-  llvm::GlobalValue::LinkageTypes ThunkLinkage;
-  
-  if (CGM.getFunctionLinkage(MD) == llvm::Function::InternalLinkage)
-    ThunkLinkage = llvm::Function::InternalLinkage;
-  else
-    ThunkLinkage = llvm::Function::WeakAnyLinkage;
-  
-  Fn->setLinkage(ThunkLinkage);
+  Fn->setLinkage(CGM.getFunctionLinkage(MD));
   
   // Set the right visibility.
   CGM.setGlobalVisibility(Fn, MD);
index 2389839921b67e4ddf9d1b00a7259bae713c84c0..b91ba3239b1e12c649440c47b99fe30dfc42e92b 100644 (file)
@@ -18,7 +18,7 @@ struct C : A, B {
   virtual void f();
 };
 
-// CHECK: define weak void @_ZThn8_N5Test11C1fEv(
+// CHECK: define void @_ZThn8_N5Test11C1fEv(
 void C::f() { }
 
 }
@@ -36,7 +36,7 @@ struct B : virtual A {
   virtual void f();
 };
 
-// CHECK: define weak void @_ZTv0_n24_N5Test21B1fEv(
+// CHECK: define void @_ZTv0_n24_N5Test21B1fEv(
 void B::f() { }
 
 }
@@ -58,7 +58,7 @@ struct B : A {
   virtual V2 *f();
 };
 
-// CHECK: define weak %{{.*}}* @_ZTch0_v0_n24_N5Test31B1fEv(
+// CHECK: define %{{.*}}* @_ZTch0_v0_n24_N5Test31B1fEv(
 V2 *B::f() { return 0; }
 
 }
@@ -81,11 +81,14 @@ struct __attribute__((visibility("protected"))) C : A, B {
   virtual void f();
 };
 
-// CHECK: define weak protected void @_ZThn8_N5Test41C1fEv(
+// CHECK: define protected void @_ZThn8_N5Test41C1fEv(
 void C::f() { }
 
 }
 
+// This is from Test5:
+// CHECK: define linkonce_odr void @_ZTv0_n24_N5Test51B1fEv
+
 // Check that the thunk gets internal linkage.
 namespace {
 
@@ -114,3 +117,21 @@ void f() {
   
   c.f();
 }
+
+namespace Test5 {
+
+// Check that the thunk for 'B::f' gets the same linkage as the function itself.
+struct A {
+  virtual void f();
+};
+
+struct B : virtual A {
+  virtual void f() { }
+};
+
+void f(B b) {
+  b.f();
+}
+}
+
+