[cfe-commits] r99729 - in /cfe/trunk: lib/CodeGen/CGVtable.cpp test/CodeGenCXX/thunks.cpp
Anders Carlsson
andersca at mac.com
Sat Mar 27 13:50:27 PDT 2010
Author: andersca
Date: Sat Mar 27 15:50:27 2010
New Revision: 99729
URL: http://llvm.org/viewvc/llvm-project?rev=99729&view=rev
Log:
Give thunks the same linkage as their original methods.
Modified:
cfe/trunk/lib/CodeGen/CGVtable.cpp
cfe/trunk/test/CodeGenCXX/thunks.cpp
Modified: cfe/trunk/lib/CodeGen/CGVtable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.cpp?rev=99729&r1=99728&r2=99729&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.cpp Sat Mar 27 15:50:27 2010
@@ -3867,14 +3867,7 @@
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);
Modified: cfe/trunk/test/CodeGenCXX/thunks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/thunks.cpp?rev=99729&r1=99728&r2=99729&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/thunks.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/thunks.cpp Sat Mar 27 15:50:27 2010
@@ -18,7 +18,7 @@
virtual void f();
};
-// CHECK: define weak void @_ZThn8_N5Test11C1fEv(
+// CHECK: define void @_ZThn8_N5Test11C1fEv(
void C::f() { }
}
@@ -36,7 +36,7 @@
virtual void f();
};
-// CHECK: define weak void @_ZTv0_n24_N5Test21B1fEv(
+// CHECK: define void @_ZTv0_n24_N5Test21B1fEv(
void B::f() { }
}
@@ -58,7 +58,7 @@
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 @@
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 @@
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();
+}
+}
+
+
More information about the cfe-commits
mailing list