I plan on adding memcpy optimizations in the GlobalISel pipeline, but we can't do that unless we delay lowering to actual function calls. This patch changes the translator to generate G_INTRINSIC_W_SIDE_EFFECTS for these functions, and then have each target specify that using the new custom legalizer for intrinsics hook that they want it expanded it a libcall.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | ||
---|---|---|
1142–1143 ↗ | (On Diff #210444) | I would expect these to be passed through |
llvm/lib/CodeGen/GlobalISel/Utils.cpp | ||
---|---|---|
408 ↗ | (On Diff #210462) | I've been using MI.getOperand(MI.getNumExplicitDefs()).getIntrinsicID() for this. I've been considering just adding getIntrinsicID() to MachineInstr directly |
llvm/lib/CodeGen/GlobalISel/Utils.cpp | ||
---|---|---|
408 ↗ | (On Diff #210462) | I'll try that now. |
Sigh, I think we also need to pass through the alignments of the src and dest parameters. SelectionDAG does this during building using MemCpyInst::{getDestAlignment(),getSrcAlignment()} and I think we currently lose that information during translation.
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | ||
---|---|---|
1148 ↗ | (On Diff #210679) | Should these get 1/2 mem operands? |
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | ||
---|---|---|
1148 ↗ | (On Diff #210679) | Maybe for the alignments? I'm not sure about the volatile flag though, it seems to apply to the whole intrinsic not to specific pointer. |
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | ||
---|---|---|
1148 ↗ | (On Diff #210679) | Size, alignment, and IR object. I. guess you would have to propagate the volatile to both |
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | ||
---|---|---|
1148 ↗ | (On Diff #210679) | Worth a try. However the size would have to be a lie, since the memory accessed would be potentially unknown. Perhaps that doesn't matter as it's an intrinsic and any code dealing with it would need to know not to never try to use the size info. |
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | ||
---|---|---|
1148 ↗ | (On Diff #210679) | I guess you could preserve the size in the static case? I'm not sure if MMOs allow unknown size. Preserving the alignment and address space is important at least |
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | ||
---|---|---|
1148 ↗ | (On Diff #210679) | I decided to leave the size as just 1 in every case, I think it's better than sometimes having correct information. |