Skip to content

Commit adb4c69

Browse files
author
Sergey Dmitrouk
committed
[DebugInfo] Add debug locations to constant SD nodes
This adds debug location to constant nodes of Selection DAG and updates all places that create constants to pass debug locations (see PR13269). Can't guarantee that all locations are correct, but in a lot of cases choice is obvious, so most of them should be. At least all tests pass. Tests for these changes do not cover everything, instead just check it for SDNodes, ARM and AArch64 where it's easy to get incorrect locations on constants. This is not complete fix as FastISel contains workaround for wrong debug locations, which drops locations from instructions on processing constants, but there isn't currently a way to use debug locations from constants there as llvm::Constant doesn't cache it (yet). Although this is a bit different issue, not directly related to these changes. Differential Revision: http://reviews.llvm.org/D9084 llvm-svn: 235977
1 parent ba94562 commit adb4c69

File tree

78 files changed

+4399
-3705
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+4399
-3705
lines changed

llvm/include/llvm/CodeGen/SelectionDAG.h

+25-21
Original file line numberDiff line numberDiff line change
@@ -413,36 +413,40 @@ class SelectionDAG {
413413
//===--------------------------------------------------------------------===//
414414
// Node creation methods.
415415
//
416-
SDValue getConstant(uint64_t Val, EVT VT, bool isTarget = false,
416+
SDValue getConstant(uint64_t Val, SDLoc DL, EVT VT, bool isTarget = false,
417417
bool isOpaque = false);
418-
SDValue getConstant(const APInt &Val, EVT VT, bool isTarget = false,
418+
SDValue getConstant(const APInt &Val, SDLoc DL, EVT VT, bool isTarget = false,
419419
bool isOpaque = false);
420-
SDValue getConstant(const ConstantInt &Val, EVT VT, bool isTarget = false,
421-
bool isOpaque = false);
422-
SDValue getIntPtrConstant(uint64_t Val, bool isTarget = false);
423-
SDValue getTargetConstant(uint64_t Val, EVT VT, bool isOpaque = false) {
424-
return getConstant(Val, VT, true, isOpaque);
420+
SDValue getConstant(const ConstantInt &Val, SDLoc DL, EVT VT,
421+
bool isTarget = false, bool isOpaque = false);
422+
SDValue getIntPtrConstant(uint64_t Val, SDLoc DL, bool isTarget = false);
423+
SDValue getTargetConstant(uint64_t Val, SDLoc DL, EVT VT,
424+
bool isOpaque = false) {
425+
return getConstant(Val, DL, VT, true, isOpaque);
425426
}
426-
SDValue getTargetConstant(const APInt &Val, EVT VT, bool isOpaque = false) {
427-
return getConstant(Val, VT, true, isOpaque);
427+
SDValue getTargetConstant(const APInt &Val, SDLoc DL, EVT VT,
428+
bool isOpaque = false) {
429+
return getConstant(Val, DL, VT, true, isOpaque);
428430
}
429-
SDValue getTargetConstant(const ConstantInt &Val, EVT VT,
431+
SDValue getTargetConstant(const ConstantInt &Val, SDLoc DL, EVT VT,
430432
bool isOpaque = false) {
431-
return getConstant(Val, VT, true, isOpaque);
433+
return getConstant(Val, DL, VT, true, isOpaque);
432434
}
433435
// The forms below that take a double should only be used for simple
434436
// constants that can be exactly represented in VT. No checks are made.
435-
SDValue getConstantFP(double Val, EVT VT, bool isTarget = false);
436-
SDValue getConstantFP(const APFloat& Val, EVT VT, bool isTarget = false);
437-
SDValue getConstantFP(const ConstantFP &CF, EVT VT, bool isTarget = false);
438-
SDValue getTargetConstantFP(double Val, EVT VT) {
439-
return getConstantFP(Val, VT, true);
437+
SDValue getConstantFP(double Val, SDLoc DL, EVT VT, bool isTarget = false);
438+
SDValue getConstantFP(const APFloat& Val, SDLoc DL, EVT VT,
439+
bool isTarget = false);
440+
SDValue getConstantFP(const ConstantFP &CF, SDLoc DL, EVT VT,
441+
bool isTarget = false);
442+
SDValue getTargetConstantFP(double Val, SDLoc DL, EVT VT) {
443+
return getConstantFP(Val, DL, VT, true);
440444
}
441-
SDValue getTargetConstantFP(const APFloat& Val, EVT VT) {
442-
return getConstantFP(Val, VT, true);
445+
SDValue getTargetConstantFP(const APFloat& Val, SDLoc DL, EVT VT) {
446+
return getConstantFP(Val, DL, VT, true);
443447
}
444-
SDValue getTargetConstantFP(const ConstantFP &Val, EVT VT) {
445-
return getConstantFP(Val, VT, true);
448+
SDValue getTargetConstantFP(const ConstantFP &Val, SDLoc DL, EVT VT) {
449+
return getConstantFP(Val, DL, VT, true);
446450
}
447451
SDValue getGlobalAddress(const GlobalValue *GV, SDLoc DL, EVT VT,
448452
int64_t offset = 0, bool isTargetGA = false,
@@ -1117,7 +1121,7 @@ class SelectionDAG {
11171121
/// either of the specified value types.
11181122
SDValue CreateStackTemporary(EVT VT1, EVT VT2);
11191123

1120-
SDValue FoldConstantArithmetic(unsigned Opcode, EVT VT,
1124+
SDValue FoldConstantArithmetic(unsigned Opcode, SDLoc DL, EVT VT,
11211125
SDNode *Cst1, SDNode *Cst2);
11221126

11231127
/// Constant fold a setcc to true or false.

llvm/include/llvm/CodeGen/SelectionDAGISel.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class SelectionDAGISel : public MachineFunctionPass {
199199

200200
/// SelectInlineAsmMemoryOperands - Calls to this are automatically generated
201201
/// by tblgen. Others should not call it.
202-
void SelectInlineAsmMemoryOperands(std::vector<SDValue> &Ops);
202+
void SelectInlineAsmMemoryOperands(std::vector<SDValue> &Ops, SDLoc DL);
203203

204204

205205
public:

llvm/include/llvm/CodeGen/SelectionDAGNodes.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -1361,9 +1361,10 @@ class ShuffleVectorSDNode : public SDNode {
13611361
class ConstantSDNode : public SDNode {
13621362
const ConstantInt *Value;
13631363
friend class SelectionDAG;
1364-
ConstantSDNode(bool isTarget, bool isOpaque, const ConstantInt *val, EVT VT)
1364+
ConstantSDNode(bool isTarget, bool isOpaque, const ConstantInt *val,
1365+
DebugLoc DL, EVT VT)
13651366
: SDNode(isTarget ? ISD::TargetConstant : ISD::Constant,
1366-
0, DebugLoc(), getSDVTList(VT)), Value(val) {
1367+
0, DL, getSDVTList(VT)), Value(val) {
13671368
SubclassData |= (uint16_t)isOpaque;
13681369
}
13691370
public:

0 commit comments

Comments
 (0)