File: attr_optstrat.d

package info (click to toggle)
ldc 1%3A1.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 80,880 kB
  • sloc: ansic: 123,899; cpp: 84,038; sh: 1,402; makefile: 1,083; asm: 919; objc: 65; exp: 30; python: 22
file content (66 lines) | stat: -rw-r--r-- 1,365 bytes parent folder | download | duplicates (3)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// RUN: %ldc -I%S -c -output-ll -O3 -of=%t.ll %s && FileCheck %s < %t.ll

import ldc.attributes;

extern (C): // For easier name mangling

int glob1;
int easily_inlinable(int i)
{
    glob1 = i;
    return 2;
}

// CHECK-LABEL: define{{.*}} @call_easily_inlinable(
// CHECK-SAME: #[[OPTNONE:[0-9]+]]
@optStrategy("none")
int call_easily_inlinable(int i)
{
    // CHECK: call {{.*}} @easily_inlinable(
    return easily_inlinable(i);
}

pragma(inline, true) int always_inline()
{
    return 321;
}
// CHECK-LABEL: define{{.*}} @call_always_inline(
@optStrategy("none")
int call_always_inline()
{
    // CHECK-NOT: call {{.*}} @always_inline()
    return always_inline();
    // CHECK: ret i32 321
}

// optnone functions should not be inlined.
int glob2;
@optStrategy("none") void optnone_function(int i)
{
    glob2 = i;
}

// CHECK-LABEL: define{{.*}} @call_optnone(
void call_optnone()
{
    // CHECK: call {{.*}} @optnone_function
    optnone_function(1);
}

// CHECK-LABEL: define{{.*}} @foo(
// CHECK-SAME: #[[OPTSIZE:[0-9]+]]
@optStrategy("optsize")
void foo()
{
}

// CHECK-LABEL: define{{.*}} @foo2(
// CHECK-SAME: #[[MINSIZE:[0-9]+]]
@optStrategy("minsize")
void foo2()
{
}

// CHECK-DAG: attributes #[[OPTNONE]] = {{.*}} noinline {{.*}} optnone
// CHECK-DAG: attributes #[[OPTSIZE]] = {{.*}} optsize
// CHECK-DAG: attributes #[[MINSIZE]] = {{.*}} minsize