r327543 - Set dso_local on external rtti GVs.
Rafael Espindola via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 14 11:14:46 PDT 2018
Author: rafael
Date: Wed Mar 14 11:14:46 2018
New Revision: 327543
URL: http://llvm.org/viewvc/llvm-project?rev=327543&view=rev
Log:
Set dso_local on external rtti GVs.
In this particular case it would be possible to just add an else with
CGM.setDSOLocal(GV), but it seems better to have as many callers as
possible just call setGVProperties so that we can centralize the logic
there.
This patch then makes setGVProperties able to handle null Decls.
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/windows-itanium-exceptions.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=327543&r1=327542&r2=327543&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Mar 14 11:14:46 2018
@@ -707,7 +707,8 @@ void CodeGenModule::setGlobalVisibility(
GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
return;
}
-
+ if (!D)
+ return;
// Set visibility for definitions.
LinkageInfo LV = D->getLinkageAndVisibility();
if (LV.isVisibilityExplicit() || !GV->isDeclarationForLinker())
@@ -797,7 +798,7 @@ void CodeGenModule::setDLLImportDLLExpor
void CodeGenModule::setDLLImportDLLExport(llvm::GlobalValue *GV,
const NamedDecl *D) const {
- if (D->isExternallyVisible()) {
+ if (D && D->isExternallyVisible()) {
if (D->hasAttr<DLLImportAttr>())
GV->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass);
else if (D->hasAttr<DLLExportAttr>() && !GV->isDeclarationForLinker())
Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=327543&r1=327542&r2=327543&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Wed Mar 14 11:14:46 2018
@@ -2616,10 +2616,8 @@ ItaniumRTTIBuilder::GetAddrOfExternalRTT
/*Constant=*/true,
llvm::GlobalValue::ExternalLinkage, nullptr,
Name);
- if (const RecordType *RecordTy = dyn_cast<RecordType>(Ty)) {
- const CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl());
- CGM.setGVProperties(GV, RD);
- }
+ const CXXRecordDecl *RD = Ty->getAsCXXRecordDecl();
+ CGM.setGVProperties(GV, RD);
}
return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy);
Modified: cfe/trunk/test/CodeGenCXX/windows-itanium-exceptions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/windows-itanium-exceptions.cpp?rev=327543&r1=327542&r2=327543&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/windows-itanium-exceptions.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/windows-itanium-exceptions.cpp Wed Mar 14 11:14:46 2018
@@ -10,7 +10,7 @@ void attempt() {
try { except(); } catch (...) { }
}
-// CHECK: @_ZTIi = external constant i8*
+// CHECK: @_ZTIi = external dso_local constant i8*
// CHECK: define {{.*}}void @_Z6exceptv() {{.*}} {
// CHECK: %exception = call {{.*}}i8* @__cxa_allocate_exception(i32 4)
More information about the cfe-commits
mailing list