[cfe-commits] r92371 - in /cfe/trunk: lib/CodeGen/CGRTTI.cpp test/CodeGenCXX/rtti-linkage.cpp
Anders Carlsson
andersca at mac.com
Thu Dec 31 11:36:25 PST 2009
Author: andersca
Date: Thu Dec 31 13:36:25 2009
New Revision: 92371
URL: http://llvm.org/viewvc/llvm-project?rev=92371&view=rev
Log:
If the key function of a record is inline, then the RTTI data should have weak_odr linkage.
Modified:
cfe/trunk/lib/CodeGen/CGRTTI.cpp
cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp
Modified: cfe/trunk/lib/CodeGen/CGRTTI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRTTI.cpp?rev=92371&r1=92370&r2=92371&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRTTI.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRTTI.cpp Thu Dec 31 13:36:25 2009
@@ -372,6 +372,14 @@
return llvm::GlobalValue::WeakODRLinkage;
}
+ // If the key function is defined, but inlined, then the RTTI descriptor is
+ // emitted with weak_odr linkage.
+ const FunctionDecl* KeyFunctionDefinition;
+ KeyFunction->getBody(KeyFunctionDefinition);
+
+ if (KeyFunctionDefinition->isInlined())
+ return llvm::GlobalValue::WeakODRLinkage;
+
// Otherwise, the RTTI descriptor is emitted with external linkage.
return llvm::GlobalValue::ExternalLinkage;
}
Modified: cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp?rev=92371&r1=92370&r2=92371&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp Thu Dec 31 13:36:25 2009
@@ -24,6 +24,8 @@
// CHECK: _ZTSM1AP1C = internal constant
// CHECK: _ZTIM1AP1C = internal constant
+// CHECK: _ZTS1F = weak_odr constant
+
// CHECK: _ZTSN12_GLOBAL__N_11DE = internal constant
// CHECK: _ZTIN12_GLOBAL__N_11DE = internal constant
// CHECK: _ZTSPN12_GLOBAL__N_11DE = internal constant
@@ -76,6 +78,13 @@
};
+// F has a key function defined in the translation unit, but it is inline so the RTTI
+// data should be emitted with weak_odr linkage.
+struct F {
+ virtual void f();
+};
+
+inline void F::f() { }
const D getD();
const std::type_info &t2() {
More information about the cfe-commits
mailing list