|
25 | 25 | #include "llvm/Analysis/ProfileSummaryInfo.h"
|
26 | 26 | #include "llvm/CodeGen/Analysis.h"
|
27 | 27 | #include "llvm/CodeGen/BranchFoldingPass.h"
|
28 |
| -#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h" |
29 | 28 | #include "llvm/CodeGen/MBFIWrapper.h"
|
30 | 29 | #include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
|
31 | 30 | #include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
|
|
48 | 47 | #include "llvm/IR/Function.h"
|
49 | 48 | #include "llvm/InitializePasses.h"
|
50 | 49 | #include "llvm/MC/LaneBitmask.h"
|
| 50 | +#include "llvm/MC/MCInstrDesc.h" |
| 51 | +#include "llvm/MC/MCInstrInfo.h" |
51 | 52 | #include "llvm/MC/MCRegisterInfo.h"
|
52 | 53 | #include "llvm/Pass.h"
|
53 | 54 | #include "llvm/Support/BlockFrequency.h"
|
@@ -2080,15 +2081,18 @@ bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) {
|
2080 | 2081 | // Merge the debug locations, and hoist and kill the debug instructions from
|
2081 | 2082 | // both branches. FIXME: We could probably try harder to preserve some debug
|
2082 | 2083 | // instructions (but at least this isn't producing wrong locations).
|
2083 |
| - MachineIRBuilder MIRBuilder(*MBB, Loc); |
| 2084 | + MachineInstrBuilder MIRBuilder(*MBB->getParent(), Loc); |
2084 | 2085 | auto HoistAndKillDbgInstr =
|
2085 |
| - [&MIRBuilder](MachineBasicBlock::iterator DI, |
2086 |
| - MachineBasicBlock::iterator InsertBefore) { |
| 2086 | + [MBB](MachineBasicBlock::iterator DI, |
| 2087 | + MachineBasicBlock::iterator InsertBefore) { |
2087 | 2088 | assert(DI->isDebugInstr() && "Expected a debug instruction");
|
2088 | 2089 | 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); |
2092 | 2096 | return;
|
2093 | 2097 | }
|
2094 | 2098 |
|
|
0 commit comments