[llvm] abf1ed7 - [globalisel][cse] Merge debug locations when CSE'ing
Daniel Sanders via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 28 14:25:37 PDT 2020
Author: Daniel Sanders
Date: 2020-07-28T14:25:26-07:00
New Revision: abf1ed70d60f4e8dffc53c9bb2cdb1e4be9fe888
URL: https://github.com/llvm/llvm-project/commit/abf1ed70d60f4e8dffc53c9bb2cdb1e4be9fe888
DIFF: https://github.com/llvm/llvm-project/commit/abf1ed70d60f4e8dffc53c9bb2cdb1e4be9fe888.diff
LOG: [globalisel][cse] Merge debug locations when CSE'ing
Reviewed By: aditya_nandakumar
Differential Revision: https://reviews.llvm.org/D78388
Added:
Modified:
llvm/lib/CodeGen/GlobalISel/CSEMIRBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/CSEMIRBuilder.cpp b/llvm/lib/CodeGen/GlobalISel/CSEMIRBuilder.cpp
index 6f8fd309e1b5..9048583ff728 100644
--- a/llvm/lib/CodeGen/GlobalISel/CSEMIRBuilder.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CSEMIRBuilder.cpp
@@ -13,6 +13,7 @@
#include "llvm/CodeGen/GlobalISel/CSEMIRBuilder.h"
#include "llvm/CodeGen/GlobalISel/GISelChangeObserver.h"
+#include "llvm/IR/DebugInfoMetadata.h"
using namespace llvm;
@@ -134,6 +135,21 @@ CSEMIRBuilder::generateCopiesIfRequired(ArrayRef<DstOp> DstOps,
if (Op.getDstOpKind() == DstOp::DstType::Ty_Reg)
return buildCopy(Op.getReg(), MIB.getReg(0));
}
+
+ // If we didn't generate a copy then we're re-using an existing node directly
+ // instead of emitting any code. Merge the debug location we wanted to emit
+ // into the instruction we're CSE'ing with. Debug locations arent part of the
+ // profile so we don't need to recompute it.
+ if (getDebugLoc()) {
+ GISelChangeObserver *Observer = getState().Observer;
+ if (Observer)
+ Observer->changingInstr(*MIB);
+ MIB->setDebugLoc(
+ DILocation::getMergedLocation(MIB->getDebugLoc(), getDebugLoc()));
+ if (Observer)
+ Observer->changedInstr(*MIB);
+ }
+
return MIB;
}
More information about the llvm-commits
mailing list