Skip to content

Commit

Permalink
[SelectionDAG] Remove debug locations from ConstantSD(FP)Nodes
Browse files Browse the repository at this point in the history
This removes debug locations from ConstantSDNode and ConstantSDFPNode.

When this kind of node is materialized we no longer create a line table
entry which jumps back to the constant's first point of use. This makes
single-stepping behavior smoother, and it matches the model used by IR,
where Constants have no locations. See this thread for more context:

  http://lists.llvm.org/pipermail/llvm-dev/2018-June/124164.html

I'd like to handle constant BuildVectorSDNodes and to try to eliminate
passing SDLocs to SelectionDAG::getConstant*() in follow-up commits.

Differential Revision: https://reviews.llvm.org/D48468

llvm-svn: 335497
  • Loading branch information
vedantk committed Jun 25, 2018
1 parent dea343d commit b725c69
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 75 deletions.
12 changes: 5 additions & 7 deletions llvm/include/llvm/CodeGen/SelectionDAGNodes.h
Expand Up @@ -1498,9 +1498,8 @@ class ConstantSDNode : public SDNode {

const ConstantInt *Value;

ConstantSDNode(bool isTarget, bool isOpaque, const ConstantInt *val,
const DebugLoc &DL, EVT VT)
: SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, 0, DL,
ConstantSDNode(bool isTarget, bool isOpaque, const ConstantInt *val, EVT VT)
: SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, 0, DebugLoc(),
getSDVTList(VT)),
Value(val) {
ConstantSDNodeBits.IsOpaque = isOpaque;
Expand Down Expand Up @@ -1536,10 +1535,9 @@ class ConstantFPSDNode : public SDNode {

const ConstantFP *Value;

ConstantFPSDNode(bool isTarget, const ConstantFP *val, const DebugLoc &DL,
EVT VT)
: SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 0, DL,
getSDVTList(VT)),
ConstantFPSDNode(bool isTarget, const ConstantFP *val, EVT VT)
: SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 0,
DebugLoc(), getSDVTList(VT)),
Value(val) {}

public:
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Expand Up @@ -1243,7 +1243,7 @@ SDValue SelectionDAG::getConstant(const ConstantInt &Val, const SDLoc &DL,
return SDValue(N, 0);

if (!N) {
N = newSDNode<ConstantSDNode>(isT, isO, Elt, DL.getDebugLoc(), EltVT);
N = newSDNode<ConstantSDNode>(isT, isO, Elt, EltVT);
CSEMap.InsertNode(N, IP);
InsertNode(N);
NewSDValueDbgMsg(SDValue(N, 0), "Creating constant: ", this);
Expand Down Expand Up @@ -1286,7 +1286,7 @@ SDValue SelectionDAG::getConstantFP(const ConstantFP &V, const SDLoc &DL,
return SDValue(N, 0);

if (!N) {
N = newSDNode<ConstantFPSDNode>(isTarget, &V, DL.getDebugLoc(), EltVT);
N = newSDNode<ConstantFPSDNode>(isTarget, &V, EltVT);
CSEMap.InsertNode(N, IP);
InsertNode(N);
}
Expand Down
18 changes: 7 additions & 11 deletions llvm/test/CodeGen/AArch64/machine-outliner-remarks.ll
@@ -1,18 +1,17 @@
; RUN: llc %s -enable-machine-outliner -mtriple=aarch64-unknown-unknown -pass-remarks=machine-outliner -pass-remarks-missed=machine-outliner -o /dev/null 2>&1 | FileCheck %s
; CHECK: machine-outliner-remarks.ll:5:9:
; CHECK: <unknown>:0:0:
; CHECK-SAME: Did not outline 2 instructions from 2 locations.
; CHECK-SAME: Bytes from outlining all occurrences (36) >=
; CHECK-SAME: Unoutlined instruction bytes (16)
; CHECK-SAME: (Also found at: machine-outliner-remarks.ll:13:9)
; CHECK-SAME: (Also found at: <UNKNOWN LOCATION>)
; CHECK: remark: <unknown>:0:0: Saved 20 bytes by outlining 12 instructions
; CHECK-SAME: from 2 locations. (Found at: machine-outliner-remarks.ll:36:1,
; CHECK-SAME: machine-outliner-remarks.ll:27:9)
; CHECK-SAME: from 2 locations. (Found at: <UNKNOWN LOCATION>,
; CHECK-SAME: <UNKNOWN LOCATION>)
; RUN: llc %s -enable-machine-outliner -mtriple=aarch64-unknown-unknown -o /dev/null -pass-remarks-missed=machine-outliner -pass-remarks-output=%t.yaml
; RUN: cat %t.yaml | FileCheck %s -check-prefix=YAML
; YAML: --- !Missed
; YAML-NEXT: Pass: machine-outliner
; YAML-NEXT: Name: NotOutliningCheaper
; YAML-NEXT: DebugLoc: { File: machine-outliner-remarks.ll, Line: 5, Column: 9 }
; YAML-NEXT: Function: dog
; YAML-NEXT: Args:
; YAML-NEXT: - String: 'Did not outline '
Expand All @@ -28,8 +27,7 @@
; YAML-NEXT: - NotOutliningCost: '16'
; YAML-NEXT: - String: ')'
; YAML-NEXT: - String: ' (Also found at: '
; YAML-NEXT: - OtherStartLoc1: 'machine-outliner-remarks.ll:13:9'
; YAML-NEXT: DebugLoc: { File: machine-outliner-remarks.ll, Line: 13, Column: 9 }
; YAML-NEXT: - OtherStartLoc1: '<UNKNOWN LOCATION>'
; YAML-NEXT: - String: ')'
; YAML: --- !Passed
; YAML-NEXT: Pass: machine-outliner
Expand All @@ -46,11 +44,9 @@
; YAML-NEXT: - NumOccurrences: '2'
; YAML-NEXT: - String: ' locations. '
; YAML-NEXT: - String: '(Found at: '
; YAML-NEXT: - StartLoc0: 'machine-outliner-remarks.ll:36:1'
; YAML-NEXT: DebugLoc: { File: machine-outliner-remarks.ll, Line: 36, Column: 1 }
; YAML-NEXT: - StartLoc0: '<UNKNOWN LOCATION>'
; YAML-NEXT: - String: ', '
; YAML-NEXT: - StartLoc1: 'machine-outliner-remarks.ll:27:9'
; YAML-NEXT: DebugLoc: { File: machine-outliner-remarks.ll, Line: 27, Column: 9 }
; YAML-NEXT: - StartLoc1: '<UNKNOWN LOCATION>'
; YAML-NEXT: - String: ')'

define void @dog() #0 !dbg !8 {
Expand Down
13 changes: 10 additions & 3 deletions llvm/test/DebugInfo/ARM/single-constant-use-preserves-dbgloc.ll
Expand Up @@ -9,9 +9,6 @@
; return -1;
; }

; CHECK: .loc 1 6 7
; CHECK: mvn

target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "armv7--linux-gnueabihf"

Expand All @@ -33,7 +30,17 @@ if.then: ; preds = %entry
br label %return, !dbg !18

if.end: ; preds = %entry
; Materialize the constant.
; CHECK: .loc 1 0
; CHECK-NEXT: mvn r0, #0

; The backend performs the store to %retval first, for some reason.
; CHECK-NEXT: .loc 1 7 5
; CHECK-NEXT: str r0, [sp, #4]
store i32 -1, i32* %x, align 4, !dbg !19

; CHECK-NEXT: .loc 1 6 7
; CHECK-NEXT: str r0, [sp]
store i32 -1, i32* %retval, !dbg !20
br label %return, !dbg !20

Expand Down
25 changes: 0 additions & 25 deletions llvm/test/DebugInfo/Generic/constant-sdnodes-have-dbg-location.ll

This file was deleted.

This file was deleted.

8 changes: 4 additions & 4 deletions llvm/test/tools/llvm-objdump/AMDGPU/source-lines.ll
Expand Up @@ -7,10 +7,10 @@
; LINE: source_lines_test:
; LINE-NEXT: ; {{.*}}source-lines.cl:1
; Kernel.
; LINE: ; {{.*}}source-lines.cl:2
; LINE: v_mov_b32_e32 v{{[0-9]+}}, 0x777
; LINE: ; {{.*}}source-lines.cl:3
; LINE: ; {{.*}}source-lines.cl:2
; LINE: v_mov_b32_e32 v{{[0-9]+}}, 0x888
; LINE: ; {{.*}}source-lines.cl:3
; LINE: ; {{.*}}source-lines.cl:4
; LINE: v_add_u32_e32
; LINE: ; {{.*}}source-lines.cl:5
Expand All @@ -23,10 +23,10 @@
; SOURCE: source_lines_test:
; SOURCE-NEXT: ; kernel void source_lines_test(global int *Out) {
; Kernel.
; SOURCE: ; int var0 = 0x777;
; SOURCE: v_mov_b32_e32 v{{[0-9]+}}, 0x777
; SOURCE: ; int var1 = 0x888;
; SOURCE: ; int var0 = 0x777;
; SOURCE: v_mov_b32_e32 v{{[0-9]+}}, 0x888
; SOURCE: ; int var1 = 0x888;
; SOURCE: ; int var2 = var0 + var1;
; SOURCE: v_add_u32_e32
; SOURCE: ; *Out = var2;
Expand Down

0 comments on commit b725c69

Please sign in to comment.