aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/IRSymtab.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Object/IRSymtab.cpp')
-rw-r--r--llvm/lib/Object/IRSymtab.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Object/IRSymtab.cpp b/llvm/lib/Object/IRSymtab.cpp
index a92cb02..e39cb732 100644
--- a/llvm/lib/Object/IRSymtab.cpp
+++ b/llvm/lib/Object/IRSymtab.cpp
@@ -264,9 +264,13 @@ Error Builder::addSymbol(const ModuleSymbolTable &Msymtab,
Sym.Flags |= unsigned(GV->getVisibility()) << storage::Symbol::FB_visibility;
if (Flags & object::BasicSymbolRef::SF_Common) {
+ auto *GVar = dyn_cast<GlobalVariable>(GV);
+ if (!GVar)
+ return make_error<StringError>("Only variables can have common linkage!",
+ inconvertibleErrorCode());
Uncommon().CommonSize = GV->getParent()->getDataLayout().getTypeAllocSize(
GV->getType()->getElementType());
- Uncommon().CommonAlign = GV->getAlignment();
+ Uncommon().CommonAlign = GVar->getAlignment();
}
const GlobalObject *Base = GV->getBaseObject();