Lorenzo Casalino via llvm-dev
2019-Oct-06 22:01 UTC
[llvm-dev] [ARM][Thumb2InstrInfo]: "XXXOffsetOpcode" may return PHI as default opcode
hi, while inserting a new instruction handling a frame index, 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" matches, 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. Let me know your thoughts about it, and if it is worth to issue a patch. Best regards, -- Lorenzo