File: inlining_stdlib.d

package info (click to toggle)
ldc 1%3A1.30.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 59,248 kB
  • sloc: cpp: 61,598; ansic: 14,545; sh: 1,014; makefile: 972; asm: 510; objc: 135; exp: 48; python: 12
file content (34 lines) | stat: -rw-r--r-- 1,084 bytes parent folder | download | duplicates (2)
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
// Test inlining of some standard library functions

// RUN: %ldc %s -c -output-ll -release -O0 -of=%t.O0.ll && FileCheck %s --check-prefix OPT0 < %t.O0.ll
// RUN: %ldc %s -c -output-ll -release -O3 -enable-cross-module-inlining -of=%t.O3.ll && FileCheck %s --check-prefix OPT3 < %t.O3.ll

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

// OPT0-LABEL: define{{.*}} @foo(
// OPT3-LABEL: define{{.*}} @foo(
int foo(size_t i)
{
    // core.bitop.bsf() is force-inlined
    import core.bitop;
    // OPT0: call {{.*}} @llvm.cttz
    // OPT3: call {{.*}} @llvm.cttz
    return bsf(i);
    // OPT0: ret
    // OPT3: ret
}

// OPT0-LABEL: define{{.*}} @ggg(
// OPT3-LABEL: define{{.*}} @ggg(
double ggg(double r)
{
    // std.math.nextDown() is inlined when optimizing
    import std.math;
    // OPT0: call {{.*}} @{{.*}}D3std4math10operations8nextDown
    // OPT3: call {{.*}} @{{.*}}D3std4math10operations6nextUp
    return nextDown(r);
    // OPT0: ret
    // OPT3: ret
}
// OPT0: declare {{.*}}D3std4math10operations8nextDown
// OPT3: declare {{.*}}D3std4math10operations6nextUp