1# RUN: llc %s -emit-call-site-info -run-pass=block-placement -tail-dup-placement-threshold=4 -o - | FileCheck %s
2#
3# Test case adapted from test/CodeGen/X86/taildup-heapallocsite.ll.
4
5# CHECK-LABEL: callSites:
6# CHECK-NEXT:   - { bb: 1, offset: 1, fwdArgRegs:
7# CHECK-NEXT:       - { arg: 0, reg: '$rcx' } }
8# CHECK-NEXT:   - { bb: 2, offset: 1, fwdArgRegs:
9# CHECK-NEXT:       - { arg: 0, reg: '$rcx' } }
10
11--- |
12  target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
13  target triple = "x86_64-pc-windows-msvc19.22.27905"
14
15  define dso_local void @taildupit(i32* readonly %size_ptr) {
16  entry:
17    %tobool = icmp eq i32* %size_ptr, null
18    br i1 %tobool, label %cond.end, label %cond.true
19
20  cond.true:                                        ; preds = %entry
21    %0 = load i32, i32* %size_ptr, align 4
22    br label %cond.end
23
24  cond.end:                                         ; preds = %cond.true, %entry
25    %cond = phi i32 [ %0, %cond.true ], [ 1, %entry ]
26    %call = tail call i8* @alloc(i32 %cond)
27    tail call void @f2()
28    ret void
29  }
30
31  declare dso_local i8* @alloc(i32)
32
33  declare dso_local void @f2()
34
35...
36---
37name:            taildupit
38tracksRegLiveness: true
39liveins:
40  - { reg: '$rcx', virtual-reg: '' }
41callSites:
42  - { bb: 3, offset: 0, fwdArgRegs:
43      - { arg: 0, reg: '$rcx' } }
44body:             |
45  bb.0.entry:
46    successors: %bb.1(0x30000000), %bb.2(0x50000000)
47    liveins: $rcx
48
49    $rsp = frame-setup SUB64ri8 $rsp, 40, implicit-def dead $eflags
50    frame-setup SEH_StackAlloc 40
51    frame-setup SEH_EndPrologue
52    TEST64rr renamable $rcx, renamable $rcx, implicit-def $eflags
53    JCC_1 %bb.2, 5, implicit killed $eflags
54
55  bb.1:
56    successors: %bb.3(0x80000000)
57
58    renamable $ecx = MOV32ri 1
59    JMP_1 %bb.3
60
61  bb.2.cond.true:
62    successors: %bb.3(0x80000000)
63    liveins: $rcx
64
65    renamable $ecx = MOV32rm killed renamable $rcx, 1, $noreg, 0, $noreg :: (load (s32) from %ir.size_ptr)
66
67  bb.3.cond.end:
68    liveins: $ecx
69
70    CALL64pcrel32 @alloc, csr_win64, implicit $rsp, implicit $ssp, implicit $ecx, implicit-def $rsp, implicit-def $ssp, implicit-def dead $rax
71    SEH_Epilogue
72    $rsp = frame-destroy ADD64ri8 $rsp, 40, implicit-def dead $eflags
73    TAILJMPd64 @f2, csr_win64, implicit $rsp, implicit $ssp, implicit $rsp, implicit $ssp
74
75...
76