summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp
diff options
context:
space:
mode:
authorAlexander Richardson <arichardson.kde@gmail.com>2018-01-26 15:56:14 +0000
committerAlexander Richardson <arichardson.kde@gmail.com>2018-01-26 15:56:14 +0000
commit1f9636f3ef64d71a115e4727a28349a9c7962d09 (patch)
tree27d4072a7abd52e4d8b2b36adcbe48acb0023c62 /llvm/lib/Target/Mips/MipsTargetObjectFile.cpp
parentf531cf8964c2d0e49a35bf4f05478b498b2a5fd4 (diff)
downloadbcm5719-llvm-1f9636f3ef64d71a115e4727a28349a9c7962d09.tar.gz
bcm5719-llvm-1f9636f3ef64d71a115e4727a28349a9c7962d09.zip
[MIPS] Don't crash on unsized extern types with -mgpopt
Summary: This fixes an assertion when building the FreeBSD MIPS64 kernel. Reviewers: atanasyan, sdardis, emaste Reviewed By: sdardis Subscribers: krytarowski, llvm-commits Differential Revision: https://reviews.llvm.org/D42571 llvm-svn: 323536
Diffstat (limited to 'llvm/lib/Target/Mips/MipsTargetObjectFile.cpp')
-rw-r--r--llvm/lib/Target/Mips/MipsTargetObjectFile.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp b/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp
index 9db6b7b1bcd..f767c832198 100644
--- a/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp
+++ b/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp
@@ -136,6 +136,13 @@ IsGlobalInSmallSectionImpl(const GlobalObject *GO,
return false;
Type *Ty = GVA->getValueType();
+
+ // It is possible that the type of the global is unsized, i.e. a declaration
+ // of a extern struct. In this case don't presume it is in the small data
+ // section. This happens e.g. when building the FreeBSD kernel.
+ if (!Ty->isSized())
+ return false;
+
return IsInSmallSection(
GVA->getParent()->getDataLayout().getTypeAllocSize(Ty));
}
OpenPOWER on IntegriCloud