Skip to content

Bug fixes#192

Merged
jj16791 merged 6 commits intomainfrom
Bug-fixes
Oct 1, 2021
Merged

Bug fixes#192
jj16791 merged 6 commits intomainfrom
Bug-fixes

Conversation

@mutalibmohammed
Copy link
Copy Markdown
Contributor

When SimEng flushes an instruction that sets multiple destinations as same register, the rewinding of register renaming fails. This is because the order of applying rewinding by historyTable_ is in the wrong way.

Ultimately, it keeps the wrong physical register (which was freed) in mappingTable_. Therefore, the order of calling rewind() was reversed to have the correct order of updating mappingTable_ with historyTable_.

In FetchUnit::tick, If the pc_ was not aligned to the blockSize boundary and the fetchBuffer_ was empty, the fetchData would not be copied but used directly as an optimization. However, if the fetchData was not enough to start decoding right away, the function would exit and the fetchData would be lost. To fix the bug, the optimization was removed and fetchData is always copied onto the fetchBuffer_. There was no observed performance difference.

Additionally, the pointer to the buffer passed to predecode is not guaranteed to be aligned. This caused misalignment bugs as aarch64::predecode was expecting it to be 4 byte aligned. A workaround proposed by @FinnWilkinson fixed the bug by copying the buffer into a local variable.

The ROR implementation was found to be buggy, hence a modified version using modular arithmetic was implemented.

@jj16791
Copy link
Copy Markdown
Contributor

jj16791 commented Sep 16, 2021

#rerun tests

Copy link
Copy Markdown
Contributor

@FinnWilkinson FinnWilkinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good to me

@jj16791
Copy link
Copy Markdown
Contributor

jj16791 commented Sep 25, 2021

#rerun tests

Copy link
Copy Markdown
Contributor

@seunghun1ee seunghun1ee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

Copy link
Copy Markdown
Contributor

@seunghun1ee seunghun1ee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a bug that can be critical, so I commit the fix straight to this branch.
Please have a look

Comment thread src/lib/arch/aarch64/InstructionMetadata.cc
@seunghun1ee seunghun1ee added the bug Something isn't working label Oct 1, 2021
Copy link
Copy Markdown
Contributor

@FinnWilkinson FinnWilkinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good

seunghun1ee and others added 6 commits October 1, 2021 15:17
Reversing the order of rewinding was done to rewind destination
registers in correct history order.

This change prevents register alias table leaving wrong mapping
on rewinding. Ultimately, this fixes the issue where some operands
get their values from incorrect register because of the wrong mapping.
If the pc_ was not aligned to blockSize boundary and the
fetchBuffer_ was empty, the fetchData would not be copied
but used directly as an optimization. However, if the fetchData
was not enough to start decoding, the function would exit and
the fetchData would be loss.

To fix the bug, the optimization was removed and fetchData is
always copied onto the fetchBuffer_. The optimization did not
provide any performance improvement on the M1 Mac Mini.
The new ror implementation only works for type widths that are
a power of 2. Instead of using arithmetic substraction, we are
computing the modular inverse of amount (mod type_width).

Using modular inverse instead of subtraction will not cause
undefined behaviour when amount is 0. That is the only difference.
On decode, operand 0 of RET was set to LR.
This was problematic as it always used LR even if an operand was given.
To stop this, `InstructionMetadata.cc` now sets operand 0 of RET as LR
only when `operandCount` is zero.
@jj16791 jj16791 merged commit 9e0b874 into main Oct 1, 2021
@jj16791 jj16791 mentioned this pull request Oct 5, 2021
@seunghun1ee seunghun1ee mentioned this pull request Oct 5, 2021
@jj16791 jj16791 deleted the Bug-fixes branch December 16, 2021 10:21
@jj16791 jj16791 restored the Bug-fixes branch December 16, 2021 10:21
@jj16791 jj16791 deleted the Bug-fixes branch December 16, 2021 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants