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
|
// Test inlining of functions marked with pragma(inline)
// RUN: %ldc %s -I%S -c -output-ll -O0 -of=%t.O0.ll && FileCheck %s --check-prefix OPTNONE < %t.O0.ll
// RUN: %ldc %s -I%S -c -output-ll -O3 -of=%t.O3.ll && FileCheck %s --check-prefix OPT3 < %t.O3.ll
extern (C): // simplify mangling for easier matching
int dummy;
// OPTNONE-LABEL: define{{.*}} @never_inline
// OPTNONE-SAME: #[[NEVER:[0-9]+]]
pragma(inline, false) int never_inline()
{
dummy = 111;
return 222;
}
int external();
// OPTNONE-LABEL: define{{.*}} @always_inline
// OPTNONE-SAME: #[[ALWAYS:[0-9]+]]
pragma(inline, true) int always_inline()
{
int a;
foreach (i; 1 .. 10)
{
foreach (ii; 1 .. 10)
{
foreach (iii; 1 .. 10)
{
a += i * external();
}
}
}
dummy = 444;
return a;
}
// OPTNONE-LABEL: define{{.*}} @foo
// OPTNONE-SAME: #[[FOO:[0-9]+]]
int foo()
{
return 333;
}
// OPT3-LABEL: define{{.*}} @call_always_inline
int call_always_inline()
{
// OPT3-NOT: call {{.*}} @always_inline()
// OPT3: ret
return always_inline();
}
// OPT3-LABEL: define{{.*}} @call_never_inline
int call_never_inline()
{
// OPT3: call {{.*}} @never_inline()
// OPT3: ret
return never_inline();
}
// OPTNONE-NOT: attributes #[[FOO]] ={{.*}} alwaysinline
// OPTNONE-NOT: attributes #[[FOO]] ={{.*}} noinline
// OPTNONE-NOT: attributes #[[NEVER]] ={{.*}} alwaysinline
// OPTNONE-NOT: attributes #[[ALWAYS]] ={{.*}} noinline
// OPTNONE-DAG: attributes #[[NEVER]] ={{.*}} noinline
// OPTNONE-DAG: attributes #[[ALWAYS]] ={{.*}} alwaysinline
|