Skip to content

Commit 8810fc8

Browse files
committed
replace MachineIRBuilder with BuildMI
1 parent 997c260 commit 8810fc8

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"
@@ -49,6 +48,8 @@
4948
#include "llvm/IR/Function.h"
5049
#include "llvm/InitializePasses.h"
5150
#include "llvm/MC/LaneBitmask.h"
51+
#include "llvm/MC/MCInstrDesc.h"
52+
#include "llvm/MC/MCInstrInfo.h"
5253
#include "llvm/MC/MCRegisterInfo.h"
5354
#include "llvm/Pass.h"
5455
#include "llvm/Support/BlockFrequency.h"
@@ -2087,15 +2088,18 @@ bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) {
20872088
// Merge the debug locations, and hoist and kill the debug instructions from
20882089
// both branches. FIXME: We could probably try harder to preserve some debug
20892090
// instructions (but at least this isn't producing wrong locations).
2090-
MachineIRBuilder MIRBuilder(*MBB, Loc);
2091+
MachineInstrBuilder MIRBuilder(*MBB->getParent(), Loc);
20912092
auto HoistAndKillDbgInstr =
2092-
[&MIRBuilder](MachineBasicBlock::iterator DI,
2093-
MachineBasicBlock::iterator InsertBefore) {
2093+
[MBB](MachineBasicBlock::iterator DI,
2094+
MachineBasicBlock::iterator InsertBefore) {
20942095
assert(DI->isDebugInstr() && "Expected a debug instruction");
20952096
if (DI->isDebugRef()) {
2096-
MIRBuilder.setDebugLoc(DI->getDebugLoc());
2097-
MIRBuilder.buildDirectDbgValue(0, DI->getDebugVariable(),
2098-
DI->getDebugExpression());
2097+
const TargetInstrInfo *TII =
2098+
MBB->getParent()->getSubtarget().getInstrInfo();
2099+
const MCInstrDesc &DBGV = TII->get(TargetOpcode::DBG_VALUE);
2100+
DI = BuildMI(*MBB->getParent(), DI->getDebugLoc(), DBGV, false, 0,
2101+
DI->getDebugVariable(), DI->getDebugExpression());
2102+
MBB->insert(InsertBefore, &*DI);
20992103
return;
21002104
}
21012105

0 commit comments

Comments
 (0)