For cases where there are no arguments (creating IMPLICIT_DEF), don't attempt to create zero sized arrays.
Details
Diff Detail
Event Timeline
I'm not sure I understand why this change is needed. I'd expect the original version of buildInstr<unsigned>, to expand to:
MachineInstrBuilder buildInstr(unsigned Opc, unsigned &&Ty) { auto MIB = buildInstr(Opc).addDef(getDestFromArg(Ty)); unsigned It[] = {}; for (const auto &i : It) MIB.addUse(i); return MIB; }
which should then optimize to:
MachineInstrBuilder buildInstr(unsigned Opc, unsigned &&Ty) { auto MIB = buildInstr(Opc).addDef(getDestFromArg(Ty)); return MIB; }
which appears to be the same thing the new version expands and optimizes to.
Am I missing something?
Add the ability to accept machine operands to the buildInstr method so it will directly call MIB.add(MO) on that.
@dsanders - the main goal was to avoid the compiler warning of having to create a zero sized array. Now with the splitting of arguments, we can also accept MachineOperands which can directly be added to the instruction.
You mean the unsigned It[] = {};? Ok, that makes sense. The subject line should reflect that though. E.g:
[GISel] Avoid zero-length array when adding uses to instructions that lack them (e.g IMPLICIT_DEF).
include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h | ||
---|---|---|
77–80 | This should be added by the patch that uses it. | |
81 | Just for consistency, should we name this addUsesFromArgs()? | |
84–85 | I think this is missing some std::forward's |
include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h | ||
---|---|---|
77–80 | Will remove this part. Will add it later. |
This should be added by the patch that uses it.