diff options
author | Hans Wennborg <hans@hanshq.net> | 2018-02-02 13:47:07 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2018-02-02 13:47:07 +0000 |
commit | 52d11d163ef739537988545ba54a8b6fc1e18bcb (patch) | |
tree | 3d15b9a7fefe298037d53e19a1281e9278575ab0 | |
parent | 7e8d1e7421f89de424e8ddf40d1948588e0dc3e9 (diff) |
Merging r323536:
------------------------------------------------------------------------
r323536 | arichardson | 2018-01-26 16:56:14 +0100 (Fri, 26 Jan 2018) | 11 lines
[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
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@324087 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/Mips/MipsTargetObjectFile.cpp | 7 | ||||
-rw-r--r-- | test/CodeGen/Mips/unsized-global.ll | 22 |
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/Target/Mips/MipsTargetObjectFile.cpp b/lib/Target/Mips/MipsTargetObjectFile.cpp index 9db6b7b1bcd6..f767c8321988 100644 --- a/lib/Target/Mips/MipsTargetObjectFile.cpp +++ b/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)); } diff --git a/test/CodeGen/Mips/unsized-global.ll b/test/CodeGen/Mips/unsized-global.ll new file mode 100644 index 000000000000..a89ecc1fd1cb --- /dev/null +++ b/test/CodeGen/Mips/unsized-global.ll @@ -0,0 +1,22 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; Check that -mgpopt doesn't crash on unsized externals +; RUN: llc -mtriple=mips64-unknown-freebsd -mattr=+noabicalls -target-abi n64 -mgpopt -o - %s | FileCheck %s + +%struct.a = type opaque + +@b = external global %struct.a, align 1 + +; Function Attrs: norecurse nounwind readnone +define %struct.a* @d() { +; CHECK-LABEL: d: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: lui $1, %highest(b) +; CHECK-NEXT: daddiu $1, $1, %higher(b) +; CHECK-NEXT: dsll $1, $1, 16 +; CHECK-NEXT: daddiu $1, $1, %hi(b) +; CHECK-NEXT: dsll $1, $1, 16 +; CHECK-NEXT: jr $ra +; CHECK-NEXT: daddiu $2, $1, %lo(b) +entry: + ret %struct.a* @b +} |