]> granicus.if.org Git - clang/commitdiff
CodeGen: Do not give local-linkage functions externally available linkage, even tempo...
authorPeter Collingbourne <peter@pcc.me.uk>
Wed, 1 Jul 2015 02:10:26 +0000 (02:10 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Wed, 1 Jul 2015 02:10:26 +0000 (02:10 +0000)
When an internal-linkage thunk is code gen'd, CodeGenVTables::emitThunk
will first be called with ForVTable=true (which incorrectly set the
thunk's linkage to available_externally under the Itanium ABI) and later
with ForVTable=false (which reset it to internal). Because we will always
see a call with ForVTable=false, this incorrect linkage never ended up in
the final IR. However, the temporary presence of this linkage caused us
to give such functions a comdat as a result of code introduced in r241102.
To avoid this, check that the thunk is externally visible before giving it
available_externally linkage.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241136 91177308-0d34-0410-b5e6-96231b3b80d8

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

index d7dfe8bfa2047b910fbf190f0b240fad9f1fbc0f..fa86e52ec804a76607be4c3f6fec3ceca5e7f11d 100644 (file)
@@ -219,7 +219,7 @@ public:
                        bool ReturnAdjustment) override {
     // Allow inlining of thunks by emitting them with available_externally
     // linkage together with vtables when needed.
-    if (ForVTable)
+    if (ForVTable && !Thunk->hasLocalLinkage())
       Thunk->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage);
   }
 
index 2287d65a286d5977f83a6ecbe94e562a001c35b2..0e97255cc6fa373320147a1612c022f9079324d0 100644 (file)
@@ -365,6 +365,7 @@ namespace Test15 {
 
 // This is from Test5:
 // CHECK-LABEL: define internal void @_ZThn8_N6Test4B12_GLOBAL__N_11C1fEv(
+// CHECK-NOT: comdat
 // CHECK-LABEL: define linkonce_odr void @_ZTv0_n24_N5Test51B1fEv
 
 // This is from Test10: