This is an archive of the discontinued LLVM Phabricator instance.

[ARM] tSETEND needs IsThumb
ClosedPublic

Authored by olista01 on Oct 23 2017, 9:54 AM.

Details

Summary

This is the Thumb encoding, so the Requires list must include IsThumb.

No test because we happen to select the ARM one first, but that's just luck.

Diff Detail

Repository
rL LLVM

Event Timeline

olista01 created this revision.Oct 23 2017, 9:54 AM
olista01 updated this revision to Diff 119882.Oct 23 2017, 9:56 AM

Updated patch with more context.

rengolin edited edge metadata.Oct 23 2017, 1:45 PM

Hi Oliver,

I don't understand this one. Can you clarify why it's ok to select the ARM one for thumb code, and if that's ok, what is the problem?

It's _not_ OK to select the Thumb version of this instruction in ARM mode, and that's what this patch is preventing. Normally, the T1I base class sets the Predicates list to [IsThumb], but the Requires class overrides the whole list rather than appending to it, so we need to explicitly include IsThumb in the list here. The ARM version of this instruction does have IsARM in the Predicates list, so doesn't get selected for Thumb targets.

We just happen to not hit this bug at the moment because the ARM version of the instruction appears before this one in the matcher table, but that isn't actually guaranteed by anything, and other patches that I'm working on cause the order to be reversed.

rengolin accepted this revision.Oct 23 2017, 2:42 PM

It's _not_ OK to select the Thumb version of this instruction in ARM mode, and that's what this patch is preventing.

Ok, this makes more sense. :)

Normally, the T1I base class sets the Predicates list to [IsThumb], but the Requires class overrides the whole list rather than appending to it, so we need to explicitly include IsThumb in the list here.

That's ugly! But I agree it's an acceptable fix.

The ARM version of this instruction does have IsARM in the Predicates list, so doesn't get selected for Thumb targets.

So, -mthumb selects this one just because it's the only match, and the ARM selects the arm one, by accident, just because it's the first to match. Gotcha.

We just happen to not hit this bug at the moment because the ARM version of the instruction appears before this one in the matcher table, but that isn't actually guaranteed by anything, and other patches that I'm working on cause the order to be reversed.

Other than changing the order of the td file in a test, I can't see how this could ever be tested.

And since it's an obvious fix, LGTM. Thanks!

This revision is now accepted and ready to land.Oct 23 2017, 2:42 PM
This revision was automatically updated to reflect the committed changes.