Changeset View
Changeset View
Standalone View
Standalone View
llvm/test/DebugInfo/X86/dbg-value-arg-movement.ll
; RUN: llc -mtriple=x86_64-unknown-unknown -start-after=codegenprepare -stop-before=finalize-isel %s -o - -experimental-debug-variable-locations=false | FileCheck %s | ; RUN: llc -mtriple=x86_64-unknown-unknown -start-after=codegenprepare -stop-before=finalize-isel %s -o - -experimental-debug-variable-locations=false | FileCheck %s --check-prefixes=COMMON,CHECK | ||||
; RUN: llc -mtriple=x86_64-unknown-unknown -start-after=codegenprepare -stop-before=finalize-isel %s -o - -experimental-debug-variable-locations=true | FileCheck %s --check-prefixes=COMMON,INSTRREF | |||||
; Test the movement of dbg.values of arguments. SelectionDAG tries to be | ; Test the movement of dbg.values of arguments. SelectionDAG tries to be | ||||
; helpful and places DBG_VALUEs of Arguments at the start of functions. | ; helpful and places DBG_VALUEs of Arguments at the start of functions. | ||||
; Unfortunately, this doesn't necessarily make sense, as one can specify an | ; Unfortunately, this doesn't necessarily make sense, as one can specify an | ||||
; Argument IR Value as a variable location anywhere in the program. | ; Argument IR Value as a variable location anywhere in the program. | ||||
; | ; | ||||
; Distinguish cases where we want to hoist DBG_VALUEs, and those where we | ; Distinguish cases where we want to hoist DBG_VALUEs, and those where we | ||||
; don't, by whether the referred to variable is a parameter to the current | ; don't, by whether the referred to variable is a parameter to the current | ||||
; function. In the test below, 'xyzzy' is a parameter to an inlined function, | ; function. In the test below, 'xyzzy' is a parameter to an inlined function, | ||||
; but should not be hoisted to the start of the function. | ; but should not be hoisted to the start of the function. | ||||
; | ; | ||||
; With instruction referencing, accuracy becomes more important than coverage, | |||||
; so debug instructions are placed wherever they were in the IR. | |||||
; | |||||
; Original test case, in which 'xyzzy' became unavailable because its DBG_VALUE | ; Original test case, in which 'xyzzy' became unavailable because its DBG_VALUE | ||||
; landed far from any uses, compiled "clang -O2 -g" with inlining, | ; landed far from any uses, compiled "clang -O2 -g" with inlining, | ||||
; | ; | ||||
; int ext(void); | ; int ext(void); | ||||
; | ; | ||||
; int | ; int | ||||
; foo(int xyzzy) | ; foo(int xyzzy) | ||||
; { | ; { | ||||
Show All 13 Lines | |||||
; case 99999: fish = -1; break; | ; case 99999: fish = -1; break; | ||||
; default: fish = 12; | ; default: fish = 12; | ||||
; } | ; } | ||||
; qux %= fish; | ; qux %= fish; | ||||
; qux += foo(baz); | ; qux += foo(baz); | ||||
; return qux; | ; return qux; | ||||
; } | ; } | ||||
; CHECK: [[BAZVAR:![0-9]+]] = !DILocalVariable(name: "baz", | ; COMMON: [[BAZVAR:![0-9]+]] = !DILocalVariable(name: "baz", | ||||
; CHECK: [[XYZVAR:![0-9]+]] = !DILocalVariable(name: "xyzzy", | ; COMMON: [[XYZVAR:![0-9]+]] = !DILocalVariable(name: "xyzzy", | ||||
; Start of MIR function block, | ; Start of MIR function block, | ||||
; CHECK-LABEL: body | ; CHECK-LABEL: body | ||||
; Expect DBG_VALUE of physreg, | ; Expect DBG_VALUE of physreg, | ||||
; CHECK: DBG_VALUE $edi, $noreg, [[BAZVAR]] | ; CHECK: DBG_VALUE $edi, $noreg, [[BAZVAR]] | ||||
; Expect DBG_VALUE of virtreg, | ; Expect DBG_VALUE of virtreg, | ||||
; CHECK: DBG_VALUE [[ARGREG:%[0-9]+]], $noreg, [[BAZVAR]] | ; CHECK: DBG_VALUE [[ARGREG:%[0-9]+]], $noreg, [[BAZVAR]] | ||||
; Label for next block, | ; Label for next block, | ||||
; CHECK-LABEL: bb.1.next | ; CHECK-LABEL: bb.1.next | ||||
; Correctly place dbg.value in the 'next' block. | ; Correctly place dbg.value in the 'next' block. | ||||
; CHECK: DBG_VALUE [[ARGREG]], $noreg, [[XYZVAR]] | ; CHECK: DBG_VALUE [[ARGREG]], $noreg, [[XYZVAR]] | ||||
; INSTRREF-LABEL: body | |||||
; INSTRREF: DBG_PHI $edi, 1 | |||||
; INSTRREF: DBG_VALUE $edi, $noreg, [[BAZVAR]] | |||||
; INSTRREF-LABEL: bb.1.next | |||||
; INSTRREF: DBG_INSTR_REF 1, 0, [[XYZVAR]], | |||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||||
target triple = "x86_64-unknown-linux-gnu" | target triple = "x86_64-unknown-linux-gnu" | ||||
declare i32 @ext() | declare i32 @ext() | ||||
define dso_local i32 @bar(i32, i32) local_unnamed_addr !dbg !7 { | define dso_local i32 @bar(i32, i32) local_unnamed_addr !dbg !7 { | ||||
%3 = srem i32 %1, %0, !dbg !15 | %3 = srem i32 %1, %0, !dbg !15 | ||||
call void @llvm.dbg.value(metadata i32 %0, metadata !12, metadata !DIExpression()), !dbg !16 | call void @llvm.dbg.value(metadata i32 %0, metadata !12, metadata !DIExpression()), !dbg !16 | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |