[PATCH] D43955: Refactor check for dllimport in the Verifier
Rafael Avila de Espindola via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 1 10:03:27 PST 2018
espindola created this revision.
espindola added a reviewer: echristo.
This avoids duplicated code and now also rejects dllimport aliases.
https://reviews.llvm.org/D43955
Files:
lib/IR/Verifier.cpp
test/Bitcode/compatibility.ll
Index: test/Bitcode/compatibility.ll
===================================================================
--- test/Bitcode/compatibility.ll
+++ test/Bitcode/compatibility.ll
@@ -230,8 +230,6 @@
; Aliases -- DLLStorageClass
@a.dlldefault = default alias i32, i32* @g.dlldefault
; CHECK: @a.dlldefault = alias i32, i32* @g.dlldefault
- at 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
Index: lib/IR/Verifier.cpp
===================================================================
--- lib/IR/Verifier.cpp
+++ lib/IR/Verifier.cpp
@@ -566,10 +566,15 @@
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 @@
}
}
- 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 @@
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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43955.136558.patch
Type: text/x-patch
Size: 2133 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180301/f92ca6ac/attachment.bin>
More information about the llvm-commits
mailing list