@@ -4512,6 +4512,19 @@ llvm::Constant *CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
4512
4512
return Resolver;
4513
4513
}
4514
4514
4515
+ bool CodeGenModule::shouldDropDLLAttribute (const Decl *D,
4516
+ const llvm::GlobalValue *GV) const {
4517
+ auto SC = GV->getDLLStorageClass ();
4518
+ if (SC == llvm::GlobalValue::DefaultStorageClass)
4519
+ return false ;
4520
+ const Decl *MRD = D->getMostRecentDecl ();
4521
+ return (((SC == llvm::GlobalValue::DLLImportStorageClass &&
4522
+ !MRD->hasAttr <DLLImportAttr>()) ||
4523
+ (SC == llvm::GlobalValue::DLLExportStorageClass &&
4524
+ !MRD->hasAttr <DLLExportAttr>())) &&
4525
+ !shouldMapVisibilityToDLLExport (cast<NamedDecl>(MRD)));
4526
+ }
4527
+
4515
4528
// / GetOrCreateLLVMFunction - If the specified mangled name is not in the
4516
4529
// / module, create and return an llvm Function with the specified type. If there
4517
4530
// / is something in the module with the specified name, return it potentially
@@ -4564,8 +4577,7 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
4564
4577
}
4565
4578
4566
4579
// Handle dropped DLL attributes.
4567
- if (D && !D->hasAttr <DLLImportAttr>() && !D->hasAttr <DLLExportAttr>() &&
4568
- !shouldMapVisibilityToDLLExport (cast_or_null<NamedDecl>(D))) {
4580
+ if (D && shouldDropDLLAttribute (D, Entry)) {
4569
4581
Entry->setDLLStorageClass (llvm::GlobalValue::DefaultStorageClass);
4570
4582
setDSOLocal (Entry);
4571
4583
}
@@ -4859,8 +4871,7 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, llvm::Type *Ty,
4859
4871
}
4860
4872
4861
4873
// Handle dropped DLL attributes.
4862
- if (D && !D->hasAttr <DLLImportAttr>() && !D->hasAttr <DLLExportAttr>() &&
4863
- !shouldMapVisibilityToDLLExport (D))
4874
+ if (D && shouldDropDLLAttribute (D, Entry))
4864
4875
Entry->setDLLStorageClass (llvm::GlobalValue::DefaultStorageClass);
4865
4876
4866
4877
if (LangOpts.OpenMP && !LangOpts.OpenMPSimd && D)
0 commit comments