Refactor check for dllimport in the Verifier.

This avoids duplicated code and now also rejects dllimport aliases.

llvm-svn: 326814
This commit is contained in:
Rafael Espindola 2018-03-06 17:19:23 +00:00
parent 90886e94d7
commit 05bb63bfe0
2 changed files with 6 additions and 13 deletions

View File

@ -566,10 +566,15 @@ void Verifier::visitGlobalValue(const GlobalValue &GV) {
if (GV.isDeclarationForLinker())
Assert(!GV.hasComdat(), "Declaration may not be in a Comdat!", &GV);
if (GV.hasDLLImportStorageClass())
if (GV.hasDLLImportStorageClass()) {
Assert(!GV.isDSOLocal(),
"GlobalValue with DLLImport Storage is dso_local!", &GV);
Assert((GV.isDeclaration() && GV.hasExternalLinkage()) ||
GV.hasAvailableExternallyLinkage(),
"Global is marked as dllimport, but not external", &GV);
}
if (GV.hasLocalLinkage())
Assert(GV.isDSOLocal(),
"GlobalValue with private or internal linkage must be dso_local!",
@ -665,11 +670,6 @@ void Verifier::visitGlobalVariable(const GlobalVariable &GV) {
}
}
Assert(!GV.hasDLLImportStorageClass() ||
(GV.isDeclaration() && GV.hasExternalLinkage()) ||
GV.hasAvailableExternallyLinkage(),
"Global is marked as dllimport, but not external", &GV);
// Visit any debug info attachments.
SmallVector<MDNode *, 1> MDs;
GV.getMetadata(LLVMContext::MD_dbg, MDs);
@ -2193,11 +2193,6 @@ void Verifier::visitFunction(const Function &F) {
Assert(false, "Invalid user of intrinsic instruction!", U);
}
Assert(!F.hasDLLImportStorageClass() ||
(F.isDeclaration() && F.hasExternalLinkage()) ||
F.hasAvailableExternallyLinkage(),
"Function is marked as dllimport, but not external.", &F);
auto *N = F.getSubprogram();
HasDebugInfo = (N != nullptr);
if (!HasDebugInfo)

View File

@ -230,8 +230,6 @@ declare void @g.f1()
; Aliases -- DLLStorageClass
@a.dlldefault = default alias i32, i32* @g.dlldefault
; CHECK: @a.dlldefault = alias i32, i32* @g.dlldefault
@a.dllimport = dllimport alias i32, i32* @g1
; CHECK: @a.dllimport = dllimport alias i32, i32* @g1
@a.dllexport = dllexport alias i32, i32* @g.dllexport
; CHECK: @a.dllexport = dllexport alias i32, i32* @g.dllexport