# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mcpu=corei7 -no-stack-coloring=false -run-pass=stack-coloring -o - %s | FileCheck %s
# Difference between test_1 and test_2 is that there is a DBG_VALUE in test_1.
# If transformation is debug invariant the resulting LEA instruction should be
# the same (i.e. we should reuse the same stack slot).
--- |
; ModuleID = '<stdin>'
source_filename = "StackColoring-dbg-invariance.ll"
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.8.0"
; Function Attrs: argmemonly nofree nosync nounwind willreturn
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0
; Function Attrs: argmemonly nofree nosync nounwind willreturn
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0
define i32 @test_1(i32 %in) #1 !dbg !5 {
entry:
%a1 = alloca [14 x ptr], align 8
%a4 = alloca [11 x ptr], align 8
call void @llvm.dbg.value(metadata ptr %a4, metadata !9, metadata !DIExpression()), !dbg !11
ret i32 0
}
define i32 @test_2(i32 %in) #1 !dbg !12 {
entry:
%a1 = alloca [14 x ptr], align 8
%a4 = alloca [11 x ptr], align 8
ret i32 0
}
; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
declare void @llvm.dbg.value(metadata, metadata, metadata) #2
attributes #0 = { argmemonly nofree nosync nounwind willreturn "target-cpu"="corei7" }
attributes #1 = { "target-cpu"="corei7" }
!llvm.dbg.cu = !{!0}
!llvm.debugify = !{!2, !3}
!llvm.module.flags = !{!4}
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
!1 = !DIFile(filename: "StackColoring-dbg-invariance.ll", directory: "/")
!2 = !{i32 27}
!3 = !{i32 18}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = distinct !DISubprogram(name: "test_1", linkageName: "test_1", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
!6 = !DISubroutineType(types: !7)
!7 = !{}
!8 = !{!9}
!9 = !DILocalVariable(name: "4", scope: !5, file: !1, line: 4, type: !10)
!10 = !DIBasicType(name: "ty64", size: 64, encoding: DW_ATE_unsigned)
!11 = !DILocation(line: 4, column: 1, scope: !5)
!12 = distinct !DISubprogram(name: "test_2", linkageName: "test_2", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
...
---
name: test_1
alignment: 16
tracksRegLiveness: true
stack:
- { id: 0, name: a1, type: default, offset: 0, size: 112, alignment: 8,
stack-id: default, callee-saved-register: '', callee-saved-restored: true,
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
- { id: 3, name: a4, type: default, offset: 0, size: 88, alignment: 8,
stack-id: default, callee-saved-register: '', callee-saved-restored: true,
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
body: |
bb.0.entry:
liveins: $edi
; CHECK-LABEL: name: test_1
; CHECK: liveins: $edi
; CHECK: DBG_VALUE %stack.0.a1, $noreg, !9, !DIExpression(), debug-location !11
; CHECK: [[LEA64r:%[0-9]+]]:gr64 = LEA64r %stack.0.a1, 1, $noreg, 0, $noreg
; CHECK: [[LEA64r1:%[0-9]+]]:gr64 = LEA64r %stack.0.a1, 1, $noreg, 0, $noreg
; CHECK: RET 0
DBG_VALUE %stack.3.a4, $noreg, !9, !DIExpression(), debug-location !11
LIFETIME_START %stack.3.a4
LIFETIME_START %stack.0.a1
%0:gr64 = LEA64r %stack.0.a1, 1, $noreg, 0, $noreg
LIFETIME_END %stack.0.a1
%1:gr64 = LEA64r %stack.3.a4, 1, $noreg, 0, $noreg
LIFETIME_END %stack.3.a4
RET 0
...
---
name: test_2
alignment: 16
tracksRegLiveness: true
stack:
- { id: 0, name: a1, type: default, offset: 0, size: 112, alignment: 8,
stack-id: default, callee-saved-register: '', callee-saved-restored: true,
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
- { id: 3, name: a4, type: default, offset: 0, size: 88, alignment: 8,
stack-id: default, callee-saved-register: '', callee-saved-restored: true,
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
body: |
bb.0.entry:
liveins: $edi
; CHECK-LABEL: name: test_2
; CHECK: liveins: $edi
; CHECK: [[LEA64r:%[0-9]+]]:gr64 = LEA64r %stack.0.a1, 1, $noreg, 0, $noreg
; CHECK: [[LEA64r1:%[0-9]+]]:gr64 = LEA64r %stack.0.a1, 1, $noreg, 0, $noreg
; CHECK: RET 0
LIFETIME_START %stack.3.a4
LIFETIME_START %stack.0.a1
%0:gr64 = LEA64r %stack.0.a1, 1, $noreg, 0, $noreg
LIFETIME_END %stack.0.a1
%1:gr64 = LEA64r %stack.3.a4, 1, $noreg, 0, $noreg
LIFETIME_END %stack.3.a4
RET 0
...