diff options
author | Bjorn Pettersson <bjorn.a.pettersson@ericsson.com> | 2018-08-21 10:59:50 +0000 |
---|---|---|
committer | Bjorn Pettersson <bjorn.a.pettersson@ericsson.com> | 2018-08-21 10:59:50 +0000 |
commit | d378a39603566404cf098329b368a6fe390016a9 (patch) | |
tree | 37b9b51ccebfc298a36d5e590d1b8ccbd62248f3 /llvm/lib/CodeGen/MachineInstrBundle.cpp | |
parent | 2e4067226bd243e384e71ae45de1275969e7dfe2 (diff) | |
download | llvm-d378a39603566404cf098329b368a6fe390016a9.zip llvm-d378a39603566404cf098329b368a6fe390016a9.tar.gz llvm-d378a39603566404cf098329b368a6fe390016a9.tar.bz2 |
Change how finalizeBundle selects debug location for the BUNDLE instruction
Summary:
Previously a BUNDLE instruction inherited the DebugLoc from the
first instruction in the bundle, even if that DebugLoc had no
DILocation. With this commit this is changed into selecting the
first DebugLoc that has a DILocation, by searching among the
bundled instructions.
The idea is to reduce amount of bundles that are lacking
debug locations.
Reviewers: #debug-info, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: JDevlieghere, mattd, llvm-commits
Differential Revision: https://reviews.llvm.org/D50639
llvm-svn: 340267
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstrBundle.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstrBundle.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineInstrBundle.cpp b/llvm/lib/CodeGen/MachineInstrBundle.cpp index ed16a2b..64407a4 100644 --- a/llvm/lib/CodeGen/MachineInstrBundle.cpp +++ b/llvm/lib/CodeGen/MachineInstrBundle.cpp @@ -105,6 +105,16 @@ bool FinalizeMachineBundles::runOnMachineFunction(MachineFunction &MF) { return llvm::finalizeBundles(MF); } +/// Return the first found DebugLoc that has a DILocation, given a range of +/// instructions. The search range is from FirstMI to LastMI (exclusive). If no +/// DILocation is found, then an empty location is returned. +static DebugLoc getDebugLoc(MachineBasicBlock::instr_iterator FirstMI, + MachineBasicBlock::instr_iterator LastMI) { + for (auto MII = FirstMI; MII != LastMI; ++MII) + if (MII->getDebugLoc().get()) + return MII->getDebugLoc(); + return DebugLoc(); +} /// finalizeBundle - Finalize a machine instruction bundle which includes /// a sequence of instructions starting from FirstMI to LastMI (exclusive). @@ -123,7 +133,7 @@ void llvm::finalizeBundle(MachineBasicBlock &MBB, const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo(); MachineInstrBuilder MIB = - BuildMI(MF, FirstMI->getDebugLoc(), TII->get(TargetOpcode::BUNDLE)); + BuildMI(MF, getDebugLoc(FirstMI, LastMI), TII->get(TargetOpcode::BUNDLE)); Bundle.prepend(MIB); SmallVector<unsigned, 32> LocalDefs; |