Skip to content

Commit c8433a5

Browse files
author
Davide Italiano
committed
[GlobalISel] Remove debug locations when emitting constants.
The tl;dr story is that this causes jumps in the emitted line tables, even at `-O0`. We could at some point consider more fancy solutions to preserve locations, but it doesn't seem to be worth the effort for now. <rdar://problem/62460788> Differential Revision: https://reviews.llvm.org/D78947
1 parent fd624e6 commit c8433a5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ MachineInstrBuilder MachineIRBuilder::buildConstant(const DstOp &Res,
290290
}
291291

292292
auto Const = buildInstr(TargetOpcode::G_CONSTANT);
293+
Const->setDebugLoc(DebugLoc());
293294
Res.addDefToMIB(*getMRI(), Const);
294295
Const.addCImm(&Val);
295296
return Const;

llvm/test/CodeGen/AArch64/GlobalISel/constant-dbg-loc.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2-
; RUN: llc -mtriple aarch64 -O0 -stop-after=irtranslator -global-isel -verify-machineinstrs %s -o - 2>&1 | FileCheck %s
2+
; RUN: llc -mtriple aarch64 -O0 -stop-after=irtranslator -global-isel -verify-machineinstrs %s -o - 2>&1 | FileCheck --match-full-lines %s
33
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
44
target triple = "arm64-apple-ios5.0.0"
55

@@ -13,8 +13,8 @@ define i32 @main() #0 !dbg !14 {
1313
; CHECK: successors: %bb.2(0x40000000), %bb.3(0x40000000)
1414
; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
1515
; CHECK: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @var1, debug-location !DILocation(line: 0, scope: !18)
16-
; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1, debug-location !DILocation(line: 0, scope: !18)
17-
; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 2, debug-location !DILocation(line: 0, scope: !22)
16+
; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
17+
; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
1818
; CHECK: [[GV1:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @var2, debug-location !DILocation(line: 0, scope: !22)
1919
; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0.retval
2020
; CHECK: G_STORE [[C]](s32), [[FRAME_INDEX]](p0) :: (store 4 into %ir.retval)

0 commit comments

Comments
 (0)