1 //===- ReduceVirtualRegisters.cpp - Specialized Delta Pass ----------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements a function which calls the Generic Delta pass in order
10 // to simplify virtual registers in MIR.
12 //===----------------------------------------------------------------------===//
14 #include "ReduceVirtualRegisters.h"
16 #include "llvm/CodeGen/MachineModuleInfo.h"
17 #include "llvm/CodeGen/MachineRegisterInfo.h"
21 static void dropRegisterHintsFromFunction(Oracle
&O
, MachineFunction
&MF
) {
22 MachineRegisterInfo
&MRI
= MF
.getRegInfo();
23 for (unsigned I
= 0, E
= MRI
.getNumVirtRegs(); I
!= E
; ++I
) {
24 Register Reg
= Register::index2VirtReg(I
);
26 const std::pair
<unsigned, SmallVector
<Register
, 4>> &Hints
=
27 MRI
.getRegAllocationHints(Reg
);
28 if (Hints
.second
.empty())
32 MRI
.clearSimpleHint(Reg
);
36 static void dropRegisterHintsFromFunctions(Oracle
&O
,
37 ReducerWorkItem
&WorkItem
) {
38 for (const Function
&F
: WorkItem
.getModule()) {
39 if (auto *MF
= WorkItem
.MMI
->getMachineFunction(F
))
40 dropRegisterHintsFromFunction(O
, *MF
);
44 void llvm::reduceVirtualRegisterHintsDeltaPass(TestRunner
&Test
) {
45 runDeltaPass(Test
, dropRegisterHintsFromFunctions
,
46 "Reducing virtual register hints from functions");