|
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"
|
|
49 | 48 | #include "llvm/IR/Function.h"
|
50 | 49 | #include "llvm/InitializePasses.h"
|
51 | 50 | #include "llvm/MC/LaneBitmask.h"
|
| 51 | +#include "llvm/MC/MCInstrDesc.h" |
| 52 | +#include "llvm/MC/MCInstrInfo.h" |
52 | 53 | #include "llvm/MC/MCRegisterInfo.h"
|
53 | 54 | #include "llvm/Pass.h"
|
54 | 55 | #include "llvm/Support/BlockFrequency.h"
|
@@ -2087,15 +2088,18 @@ bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) {
|
2087 | 2088 | // Merge the debug locations, and hoist and kill the debug instructions from
|
2088 | 2089 | // both branches. FIXME: We could probably try harder to preserve some debug
|
2089 | 2090 | // instructions (but at least this isn't producing wrong locations).
|
2090 |
| - MachineIRBuilder MIRBuilder(*MBB, Loc); |
| 2091 | + MachineInstrBuilder MIRBuilder(*MBB->getParent(), Loc); |
2091 | 2092 | auto HoistAndKillDbgInstr =
|
2092 |
| - [&MIRBuilder](MachineBasicBlock::iterator DI, |
2093 |
| - MachineBasicBlock::iterator InsertBefore) { |
| 2093 | + [MBB](MachineBasicBlock::iterator DI, |
| 2094 | + MachineBasicBlock::iterator InsertBefore) { |
2094 | 2095 | assert(DI->isDebugInstr() && "Expected a debug instruction");
|
2095 | 2096 | 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); |
2099 | 2103 | return;
|
2100 | 2104 | }
|
2101 | 2105 |
|
|
0 commit comments