File: indirect_byval_rewrite.d

package info (click to toggle)
ldc 1%3A1.40.0-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 63,308 kB
  • sloc: cpp: 85,368; ansic: 21,877; makefile: 1,705; sh: 1,018; asm: 584; objc: 135; exp: 48; python: 12
file content (36 lines) | stat: -rw-r--r-- 1,353 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Ensures efficient indirect by-value passing via IndirectByvalRewrite.

// REQUIRES: target_X86

// RUN: %ldc -mtriple=x86_64-windows-msvc -output-ll -of=%t.ll %s && FileCheck %s < %t.ll

struct Big { size_t a, b; }
struct WithPostblit { Big b; this(this) {} }

Big makeBig() { return Big(123, 456); }

void foo(Big, WithPostblit, Big, WithPostblit);

// CHECK: define {{.*}}_D22indirect_byval_rewrite3bar
void bar()
{
    // CHECK:      %bigLValue = alloca %indirect_byval_rewrite.Big
    Big bigLValue;
    // CHECK-NEXT: %withPostblitLValue = alloca %indirect_byval_rewrite.WithPostblit
    WithPostblit withPostblitLValue;

    // * 1st arg: bigLValue bitcopy, copied by IndirectByvalRewrite
    // CHECK-NEXT: %.hidden_copy_for_IndirectByvalRewrite = alloca %indirect_byval_rewrite.Big
    // * 2nd arg: temporary withPostblitLValue copy (copied by frontend, incl. postblit)
    // CHECK-NEXT: %__copytmp{{[0-9]*}} = alloca %indirect_byval_rewrite.WithPostblit
    // * 3rd arg: sret temporary filled by makeBig()
    // CHECK-NEXT: %.sret_tmp = alloca %indirect_byval_rewrite.Big
    // * 4th arg: WithPostblit() literal
    // CHECK-NEXT: %.structliteral = alloca %indirect_byval_rewrite.WithPostblit
    foo(bigLValue, withPostblitLValue, makeBig(), WithPostblit());

    // no more allocas!
    // CHECK-NOT: alloca

    // CHECK: ret void
}