Add register Mips::GP to the list of reserved registers if target is bare-metal

to prevent it from being clobbered. mips uses $gp to access small data section.

This bug was originally reported by Carl Norum.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162340 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Akira Hatanaka
2012-08-22 03:18:13 +00:00
parent 6522a9e04b
commit e7338cd550
7 changed files with 34 additions and 7 deletions

View File

@ -60,9 +60,10 @@ bool MipsTargetObjectFile::
IsGlobalInSmallSection(const GlobalValue *GV, const TargetMachine &TM,
SectionKind Kind) const {
// Only use small section for non linux targets.
const MipsSubtarget &Subtarget = TM.getSubtarget<MipsSubtarget>();
if (Subtarget.isLinux())
// Return if small section is not available.
if (!Subtarget.useSmallSection())
return false;
// Only global variables, not functions.