[cfe-commits] r124553 - in /cfe/trunk: lib/CodeGen/CGRTTI.cpp test/CodeGenCXX/rtti-linkage.cpp test/CodeGenCXX/rtti-visibility.cpp
Anders Carlsson
andersca at mac.com
Sat Jan 29 14:10:33 PST 2011
Author: andersca
Date: Sat Jan 29 16:10:32 2011
New Revision: 124553
URL: http://llvm.org/viewvc/llvm-project?rev=124553&view=rev
Log:
When emitting RTTI for a non-class type, compute the visibility of the RTTI data based on the explicit visibility of the type.
Modified:
cfe/trunk/lib/CodeGen/CGRTTI.cpp
cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp
cfe/trunk/test/CodeGenCXX/rtti-visibility.cpp
Modified: cfe/trunk/lib/CodeGen/CGRTTI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRTTI.cpp?rev=124553&r1=124552&r2=124553&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRTTI.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRTTI.cpp Sat Jan 29 16:10:32 2011
@@ -570,11 +570,7 @@
llvm::GlobalVariable *TypeName = GetAddrOfTypeName(Ty, Linkage);
const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
- llvm::Constant *TypeNameAsInt8Ptr =
- llvm::ConstantExpr::getBitCast(TypeName, Int8PtrTy);
-
- bool Hidden = DecideHidden(Ty);
- Fields.push_back(TypeNameAsInt8Ptr);
+ Fields.push_back(llvm::ConstantExpr::getBitCast(TypeName, Int8PtrTy));
switch (Ty->getTypeClass()) {
#define TYPE(Class, Base)
@@ -677,12 +673,21 @@
CGM.setTypeVisibility(GV, RD, CodeGenModule::TVK_ForRTTI);
CGM.setTypeVisibility(TypeName, RD, CodeGenModule::TVK_ForRTTIName);
-
- } else if (Hidden ||
- (CGM.getCodeGenOpts().HiddenWeakVTables &&
- Linkage == llvm::GlobalValue::LinkOnceODRLinkage)) {
- GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
+ } else {
+ Visibility TypeInfoVisibility = DefaultVisibility;
+ if (CGM.getCodeGenOpts().HiddenWeakVTables &&
+ Linkage == llvm::GlobalValue::LinkOnceODRLinkage)
+ TypeInfoVisibility = HiddenVisibility;
+
+ // The type name should have the same visibility as the type itself.
+ Visibility ExplicitVisibility = Ty->getVisibility();
+ TypeName->setVisibility(CodeGenModule::
+ GetLLVMVisibility(ExplicitVisibility));
+
+ TypeInfoVisibility = minVisibility(TypeInfoVisibility, Ty->getVisibility());
+ GV->setVisibility(CodeGenModule::GetLLVMVisibility(TypeInfoVisibility));
}
+
GV->setUnnamedAddr(true);
return llvm::ConstantExpr::getBitCast(GV, Int8PtrTy);
Modified: cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp?rev=124553&r1=124552&r2=124553&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp Sat Jan 29 16:10:32 2011
@@ -4,7 +4,7 @@
#include <typeinfo>
// CHECK-WITH-HIDDEN: _ZTSFN12_GLOBAL__N_11DEvE = internal constant
-// CHECK-WITH-HIDDEN: @_ZTSPK2T4 = linkonce_odr constant
+// CHECK-WITH-HIDDEN: @_ZTSPK2T4 = linkonce_odr hidden constant
// CHECK-WITH-HIDDEN: @_ZTS2T4 = linkonce_odr hidden constant
// CHECK-WITH-HIDDEN: @_ZTI2T4 = linkonce_odr hidden unnamed_addr constant
// CHECK-WITH-HIDDEN: @_ZTIPK2T4 = linkonce_odr hidden unnamed_addr constant
Modified: cfe/trunk/test/CodeGenCXX/rtti-visibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/rtti-visibility.cpp?rev=124553&r1=124552&r2=124553&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/rtti-visibility.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/rtti-visibility.cpp Sat Jan 29 16:10:32 2011
@@ -10,7 +10,7 @@
// A is explicitly marked hidden, so all RTTI data should also be marked hidden.
// CHECK-TEST1: @_ZTSN5Test11AE = linkonce_odr hidden constant
// CHECK-TEST1: @_ZTIN5Test11AE = linkonce_odr hidden unnamed_addr constant
- // CHECK-TEST1: @_ZTSPN5Test11AE = linkonce_odr constant
+ // CHECK-TEST1: @_ZTSPN5Test11AE = linkonce_odr hidden constant
// CHECK-TEST1: @_ZTIPN5Test11AE = linkonce_odr hidden unnamed_addr constant
struct __attribute__((visibility("hidden"))) A { };
More information about the cfe-commits
mailing list