File: inlining_staticvar.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 (69 lines) | stat: -rw-r--r-- 1,796 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
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
67
68
69
// Test cross-module inlining involving static variables

// RUN: %ldc %s -I%S -c -output-ll                  -O3 -of=%t.O3.ll && FileCheck %s --check-prefix OPT3 < %t.O3.ll
// RUN: %ldc %s -I%S -c -output-ll -enable-inlining -O0 -of=%t.O0.ll && FileCheck %s --check-prefix OPT0 < %t.O0.ll
// RUN: %ldc -I%S -enable-inlining %S/inputs/inlinables_staticvar.d -run %s
// RUN: %ldc -I%S -O3              %S/inputs/inlinables_staticvar.d -run %s

import inputs.inlinables_staticvar;

import ldc.attributes;

extern (C): // simplify mangling for easier matching

// Functions are intentionally split and @weak to thwart LLVM constant folding.

void checkModuleScope_1() @weak
{
    addToModuleScopeInline(7);
}
void checkModuleScope_2() @weak
{
    addToModuleScopeOutline(101);
    assert(equalModuleScope(7+101));
}

void checkInsideFunc_1() @weak
{
    assert(addAndCheckInsideFunc(0, 7));
}
void checkInsideFunc_2() @weak
{
    assert(addAndCheckInsideFuncIndirect(7, 101));
    assert(addAndCheckInsideFunc(7+101, 9));
}

void checkInsideNestedFunc_1() @weak
{
    assert(addAndCheckInsideNestedFunc(0, 7));
}
void checkInsideNestedFunc_2() @weak
{
    assert(addAndCheckInsideNestedFuncIndirect(7, 101));
    assert(addAndCheckInsideNestedFunc(7+101, 9));
}

void checkNestedStruct_1() @weak
{
    assert(addAndCheckNestedStruct(0, 7));
}
void checkNestedStruct_2() @weak
{
    assert(addAndCheckNestedStructIndirect(7, 101));
    assert(addAndCheckNestedStruct(7+101, 9));
}

// OPT0-LABEL: define{{.*}} @_Dmain(
// OPT3-LABEL: define{{.*}} @_Dmain(
extern(D)
void main()
{
    checkModuleScope_1();
    checkModuleScope_2();
    checkInsideFunc_1();
    checkInsideFunc_2();
    checkInsideNestedFunc_1();
    checkInsideNestedFunc_2();
    checkNestedStruct_1();
    checkNestedStruct_2();
}