Skip to content

Commit 5984744

Browse files
committed
replace MachineIRBuilder with BuildMI
1 parent 7252b5a commit 5984744

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

llvm/lib/CodeGen/BranchFolding.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "llvm/Analysis/ProfileSummaryInfo.h"
2626
#include "llvm/CodeGen/Analysis.h"
2727
#include "llvm/CodeGen/BranchFoldingPass.h"
28-
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
2928
#include "llvm/CodeGen/MBFIWrapper.h"
3029
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
3130
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
@@ -48,6 +47,8 @@
4847
#include "llvm/IR/Function.h"
4948
#include "llvm/InitializePasses.h"
5049
#include "llvm/MC/LaneBitmask.h"
50+
#include "llvm/MC/MCInstrDesc.h"
51+
#include "llvm/MC/MCInstrInfo.h"
5152
#include "llvm/MC/MCRegisterInfo.h"
5253
#include "llvm/Pass.h"
5354
#include "llvm/Support/BlockFrequency.h"
@@ -2080,15 +2081,18 @@ bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) {
20802081
// Merge the debug locations, and hoist and kill the debug instructions from
20812082
// both branches. FIXME: We could probably try harder to preserve some debug
20822083
// instructions (but at least this isn't producing wrong locations).
2083-
MachineIRBuilder MIRBuilder(*MBB, Loc);
2084+
MachineInstrBuilder MIRBuilder(*MBB->getParent(), Loc);
20842085
auto HoistAndKillDbgInstr =
2085-
[&MIRBuilder](MachineBasicBlock::iterator DI,
2086-
MachineBasicBlock::iterator InsertBefore) {
2086+
[MBB](MachineBasicBlock::iterator DI,
2087+
MachineBasicBlock::iterator InsertBefore) {
20872088
assert(DI->isDebugInstr() && "Expected a debug instruction");
20882089
if (DI->isDebugRef()) {
2089-
MIRBuilder.setDebugLoc(DI->getDebugLoc());
2090-
MIRBuilder.buildDirectDbgValue(0, DI->getDebugVariable(),
2091-
DI->getDebugExpression());
2090+
const TargetInstrInfo *TII =
2091+
MBB->getParent()->getSubtarget().getInstrInfo();
2092+
const MCInstrDesc &DBGV = TII->get(TargetOpcode::DBG_VALUE);
2093+
DI = BuildMI(*MBB->getParent(), DI->getDebugLoc(), DBGV, false, 0,
2094+
DI->getDebugVariable(), DI->getDebugExpression());
2095+
MBB->insert(InsertBefore, &*DI);
20922096
return;
20932097
}
20942098

0 commit comments

Comments
 (0)