summaryrefslogtreecommitdiff
path: root/compiler/optimizing/code_generator_mips.cc
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2016-09-06 09:07:05 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-09-06 09:07:05 +0000
commit9d185da3bef8caf015d3dbf4ad79c520af7ce3b1 (patch)
tree201297d954dce1a78b8deec5e88760888359419f /compiler/optimizing/code_generator_mips.cc
parent9c66d9487f398399ee2a0ad09b75394b55cbbde4 (diff)
parent58320ce35715f2814700707a9d35ad5055fff9ce (diff)
Merge "MIPS32: Ensure preservation of RA in leaf methods if it's clobbered"
Diffstat (limited to 'compiler/optimizing/code_generator_mips.cc')
-rw-r--r--compiler/optimizing/code_generator_mips.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/compiler/optimizing/code_generator_mips.cc b/compiler/optimizing/code_generator_mips.cc
index b0737751a7..36bb55ab12 100644
--- a/compiler/optimizing/code_generator_mips.cc
+++ b/compiler/optimizing/code_generator_mips.cc
@@ -666,16 +666,17 @@ void CodeGeneratorMIPS::ComputeSpillMask() {
if ((fpu_spill_mask_ != 0) && (POPCOUNT(core_spill_mask_) % 2 != 0)) {
core_spill_mask_ |= (1 << ZERO);
}
+}
+
+bool CodeGeneratorMIPS::HasAllocatedCalleeSaveRegisters() const {
// If RA is clobbered by PC-relative operations on R2 and it's the only spilled register
- // (this can happen in leaf methods), artificially spill the ZERO register in order to
- // force explicit saving and restoring of RA. RA isn't saved/restored when it's the only
- // spilled register.
+ // (this can happen in leaf methods), force CodeGenerator::InitializeCodeGeneration()
+ // into the path that creates a stack frame so that RA can be explicitly saved and restored.
+ // RA can't otherwise be saved/restored when it's the only spilled register.
// TODO: Can this be improved? It causes creation of a stack frame (while RA might be
// saved in an unused temporary register) and saving of RA and the current method pointer
// in the frame.
- if (clobbered_ra_ && core_spill_mask_ == (1u << RA) && fpu_spill_mask_ == 0) {
- core_spill_mask_ |= (1 << ZERO);
- }
+ return CodeGenerator::HasAllocatedCalleeSaveRegisters() || clobbered_ra_;
}
static dwarf::Reg DWARFReg(Register reg) {
@@ -698,6 +699,9 @@ void CodeGeneratorMIPS::GenerateFrameEntry() {
}
if (HasEmptyFrame()) {
+ CHECK_EQ(fpu_spill_mask_, 0u);
+ CHECK_EQ(core_spill_mask_, 1u << RA);
+ CHECK(!clobbered_ra_);
return;
}
@@ -731,6 +735,7 @@ void CodeGeneratorMIPS::GenerateFrameEntry() {
}
// Store the current method pointer.
+ // TODO: can we not do this if RequiresCurrentMethod() returns false?
__ StoreToOffset(kStoreWord, kMethodRegisterArgument, SP, kCurrentMethodStackOffset);
}