Current implementation of emitPatchpoint() is very inefficient:
for every FrameIndex operand if creates new MachineInstr with
that operand expanded and all other copies as is.
Since PATCHPOINT/STATEPOINT instructions may have *a lot* of
FrameIndex operands, we end up creating and erasing many
machine instructions. But we can do it in single pass, with only
one new machine instruction generated.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/CodeGen/TargetLoweringBase.cpp | ||
---|---|---|
1030 | You're making this code a lot harder to follow with the whole OperIdx thing, and it only saves one branch per MachineOperand. Please just do if (!llvm::any_of(MI->operands(), [](MachineOperand &Operand) { return Operand.isFI(); }) return MBB; |
Agreed with Eli, simply having two passes over operands would be much cleaner.
I do like the removal of the multi pass copy. Definitely moving in the right direction.
LGTM w/minor change suggested.
llvm/lib/CodeGen/TargetLoweringBase.cpp | ||
---|---|---|
1035 | Minor, optional: I believe you can rewrite this as: |
Seems like this is breaking on buildbot (and also my local checkout): http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/16759
Are you sure? In your logs I see
E:\build_slave\lldb-x64-windows-ninja\llvm-project\llvm\include\llvm/CodeGen/TargetLowering.h(2971): fatal error C1088: Cannot flush compiler intermediate file: 'C:\Users\BUILDS~1\AppData\Local\Temp\_CL_ea8c083eex': No space left on device
which cannot be caused by my fix, I believe ;)
I'll double check buildbot
ah sorry, I guess that might have been the wrong link. My copy pasting skills are flaky.
what I'm seeing is this:
FAILED: lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/TargetLoweringBase.cpp.o /usr/local/bin/c++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/CodeGen -I/home/tcwg-buildslave/worker/clang-cmake-aarch64-quick/llvm/llvm/lib/CodeGen -I/usr/include/libxml2 -Iinclude -I/home/tcwg-buildslave/worker/clang-cmake-aarch64-quick/llvm/llvm/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/TargetLoweringBase.cpp.o -MF lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/TargetLoweringBase.cpp.o.d -o lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/TargetLoweringBase.cpp.o -c /home/tcwg-buildslave/worker/clang-cmake-aarch64-quick/llvm/llvm/lib/CodeGen/TargetLoweringBase.cpp /home/tcwg-buildslave/worker/clang-cmake-aarch64-quick/llvm/llvm/lib/CodeGen/TargetLoweringBase.cpp: In member function ‘llvm::MachineBasicBlock* llvm::TargetLoweringBase::emitPatchPoint(llvm::MachineInstr&, llvm::MachineBasicBlock*) const’: /home/tcwg-buildslave/worker/clang-cmake-aarch64-quick/llvm/llvm/lib/CodeGen/TargetLoweringBase.cpp:1037:30: error: ‘OperIdx’ was not declared in this scope 1037 | MIB.add(MI->getOperand(OperIdx)); | ^~~~~~~ /home/tcwg-buildslave/worker/clang-cmake-aarch64-quick/llvm/llvm/lib/CodeGen/TargetLoweringBase.cpp:1054:30: error: ‘OperIdx’ was not declared in this scope 1054 | MIB.add(MI->getOperand(OperIdx)); | ^~~~~~~ /home/tcwg-buildslave/worker/clang-cmake-aarch64-quick/llvm/llvm/lib/CodeGen/TargetLoweringBase.cpp:1060:30: error: ‘OperIdx’ was not declared in this scope 1060 | MIB.add(MI->getOperand(OperIdx));
You're making this code a lot harder to follow with the whole OperIdx thing, and it only saves one branch per MachineOperand. Please just do if (!llvm::any_of(MI->operands(), [](MachineOperand &Operand) { return Operand.isFI(); }) return MBB;