[llvm] e65e677 - [globalisel][legalizer] Fix DebugLoc bugs caught by a prototype lost-location verifier
Daniel Sanders via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 1 12:50:41 PDT 2020
Author: Daniel Sanders
Date: 2020-04-01T12:50:18-07:00
New Revision: e65e677ee4eed83a31503b1a7db3fca56f617eae
URL: https://github.com/llvm/llvm-project/commit/e65e677ee4eed83a31503b1a7db3fca56f617eae
DIFF: https://github.com/llvm/llvm-project/commit/e65e677ee4eed83a31503b1a7db3fca56f617eae.diff
LOG: [globalisel][legalizer] Fix DebugLoc bugs caught by a prototype lost-location verifier
The legalizer has a tendency to lose DebugLoc's when expanding or
combining instructions. The verifier that detected these isn't ready
for upstreaming yet but this patch fixes the cases that came up when
applying it to our out-of-tree backend's CodeGen tests.
This pattern comes up a few more times in this file and probably in
the backends too but I'd prefer to fix the others separately (and
preferably when the lost-location verifier detects them).
Added:
Modified:
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index 454a63e674d2..bb144480bbd4 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -634,6 +634,7 @@ LegalizerHelper::libcall(MachineInstr &MI) {
auto &Ctx = MIRBuilder.getMF().getFunction().getContext();
MIRBuilder.setInstr(MI);
+ MIRBuilder.setDebugLoc(MI.getDebugLoc());
switch (MI.getOpcode()) {
default:
@@ -731,6 +732,7 @@ LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalar(MachineInstr &MI,
unsigned TypeIdx,
LLT NarrowTy) {
MIRBuilder.setInstr(MI);
+ MIRBuilder.setDebugLoc(MI.getDebugLoc());
uint64_t SizeOp0 = MRI.getType(MI.getOperand(0).getReg()).getSizeInBits();
uint64_t NarrowSize = NarrowTy.getSizeInBits();
@@ -1596,6 +1598,7 @@ LegalizerHelper::widenScalarInsert(MachineInstr &MI, unsigned TypeIdx,
LegalizerHelper::LegalizeResult
LegalizerHelper::widenScalar(MachineInstr &MI, unsigned TypeIdx, LLT WideTy) {
MIRBuilder.setInstr(MI);
+ MIRBuilder.setDebugLoc(MI.getDebugLoc());
switch (MI.getOpcode()) {
default:
@@ -2188,6 +2191,7 @@ LegalizerHelper::LegalizeResult
LegalizerHelper::lower(MachineInstr &MI, unsigned TypeIdx, LLT Ty) {
using namespace TargetOpcode;
MIRBuilder.setInstr(MI);
+ MIRBuilder.setDebugLoc(MI.getDebugLoc());
switch(MI.getOpcode()) {
default:
@@ -3223,6 +3227,7 @@ LegalizerHelper::fewerElementsVector(MachineInstr &MI, unsigned TypeIdx,
using namespace TargetOpcode;
MIRBuilder.setInstr(MI);
+ MIRBuilder.setDebugLoc(MI.getDebugLoc());
switch (MI.getOpcode()) {
case G_IMPLICIT_DEF:
return fewerElementsVectorImplicitDef(MI, TypeIdx, NarrowTy);
More information about the llvm-commits
mailing list