This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Remove condition that could never be true
ClosedPublic

Authored by psmith on Apr 4 2020, 8:57 AM.

Details

Summary

From Arm v8 Architecture Reference Manual F5.1.84 LDREXD The ldrexd instruction in Arm state has the following conditions:

t = UInt(Rt); t2 = t + 1; n = UInt(Rn);
if Rt<0> == '1' || t2 == 15 || n == 15 then UNPREDICTABLE;

In essence when Rt is odd or if Rt is 14 (making t2 15). In the implementation when the pair is the UNPREDICTABLE R14_R15 we would ideally return SOFT_FAIL. We can't because there is no R14_R15 value for us to return so we fail early returning FAIL. The early return for registers outside the bounds of the table means the check for Rt == 14 (0xE) redundant which causes a static analyzer to flag the condition as never being true.

To fix the warning I've removed the check and replaced with a comment explaining the difference with the specification.

Fixes pr41660 https://bugs.llvm.org/show_bug.cgi?id=41660

Diff Detail

Event Timeline

psmith created this revision.Apr 4 2020, 8:57 AM

Thanks for fixing the warning. LGTM but an ARM specialist should accept based on the test case.

nickdesaulniers accepted this revision.Apr 6 2020, 9:59 AM

Thanks for the citation. I verified in https://static.docs.arm.com/ddi0487/fa/DDI0487F_a_armv8_arm.pdf pdf page 4449 that <Rt> must be even-numbered and not R14.

This revision is now accepted and ready to land.Apr 6 2020, 9:59 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2020, 2:10 AM