This is an archive of the discontinued LLVM Phabricator instance.

[ARM][Thumb2InstrInfo]: fix default '0' opcode when rewriting frame indeces
ClosedPublic

Authored by DoktorC on Oct 25 2019, 6:36 AM.

Details

Summary

Hi all,

I noticed that the static functions "positiveOffsetOpcode", "negativeOffsetOpcode" and
"ImmediateOffsetOpcode" (lib/Target/ARM/Thumb2InstrInfo.cpp) may return "0"
(PHI generic instruction) as default opcode.

Briefly. the static method is invoked during re-writing of frame indeces
(Prologue/Epilogue emission phase), and is used to determine the right load/store
instruction to handle the offset. This is done via switch statement in the
"XXXOffsetOpcode" static functions.

However, if none of the cases in the "switch" match, the default
opcode is 0; that is, the generic PHI instruction.

PHI instructions do not make sense in the Prologue/Epilogue emission
phase, and I think it would be more appropriate to default the "switch" to a
"llvm_unreachable" statement.

Best regards,
Lorenzo

Diff Detail

Event Timeline

DoktorC created this revision.Oct 25 2019, 6:36 AM
DoktorC edited the summary of this revision. (Show Details)Oct 25 2019, 6:37 AM
tellenbach added inline comments.
llvm/lib/Target/ARM/Thumb2InstrInfo.cpp
369

Could you move the default case at the end of the switch statement? This makes it easier to follow the control-flow.

And please remove the exclamation mark !.

399

Same here

429

Same here

DoktorC updated this revision to Diff 226443.Oct 25 2019, 9:16 AM

Moved the 'default's to the end of switches.
Removed the trailing exclamation marks.

Thank you @tellenbach.

DoktorC marked 3 inline comments as done.Oct 25 2019, 9:17 AM
tellenbach accepted this revision.Oct 28 2019, 4:43 AM

Thanks for addressing the comments, LGTM!

Do you have commit access? If not I can commit this patch for you. In this case please provide firstname lastname <e@mail.com> in order to attribute the patch correctly.

This revision is now accepted and ready to land.Oct 28 2019, 4:43 AM

Do you have commit access?

No, I do not :(

If not I can commit this patch for you. In this case please provide firstname lastname <e@mail.com> in order to attribute the patch correctly.

Here you are: lorenzo casalino <lorenzo.casalino93@gmail.com>

Thank you really much!

This revision was automatically updated to reflect the committed changes.