Commit f119c097 authored by Ivica Bogosavljevic's avatar Ivica Bogosavljevic Committed by Commit Bot

MIPSR6: Load full address to t9 when calling PIC code

PIC code requires that full function address is available in t9
upon function entry. We disabled some optimizations that cause
problems since they do not load t9 with full function address.

Bug: 
Change-Id: Ie7987c5e2413db04c59547c33a69696e19db4b34
Reviewed-on: https://chromium-review.googlesource.com/806494Reviewed-by: 's avatarMiran Karić <miran.karic@mips.com>
Commit-Queue: Ivica Bogosavljevic <ivica.bogosavljevic@mips.com>
Cr-Commit-Position: refs/heads/master@{#49835}
parent 104a2db3
......@@ -5127,20 +5127,11 @@ void TurboAssembler::PrepareCallCFunction(int num_reg_arguments,
void TurboAssembler::CallCFunction(ExternalReference function,
int num_reg_arguments,
int num_double_arguments) {
if (IsMipsArchVariant(kMips32r6)) {
uint32_t lui_offset, jialc_offset;
UnpackTargetAddressUnsigned(Operand(function).immediate(), lui_offset,
jialc_offset);
if (MustUseReg(Operand(function).rmode())) {
RecordRelocInfo(Operand(function).rmode(), Operand(function).immediate());
}
lui(t9, lui_offset);
CallCFunctionHelper(t9, jialc_offset, num_reg_arguments,
num_double_arguments);
} else {
li(t9, Operand(function));
CallCFunctionHelper(t9, 0, num_reg_arguments, num_double_arguments);
}
// Linux/MIPS convention demands that register t9 contains
// the address of the function being call in case of
// Position independent code
li(t9, Operand(function));
CallCFunctionHelper(t9, 0, num_reg_arguments, num_double_arguments);
}
void TurboAssembler::CallCFunction(Register function, int num_reg_arguments,
......@@ -5197,6 +5188,11 @@ void TurboAssembler::CallCFunctionHelper(Register function_base,
function_base = t9;
}
if (function_offset != 0) {
addiu(t9, t9, function_offset);
function_offset = 0;
}
Call(function_base, function_offset);
int stack_passed_arguments = CalculateStackPassedWords(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment