1 //===-- main.cpp ------------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 void __attribute__((noinline)) tail_call_sink() {
12 x++; //% self.filecheck("bt", "main.cpp", "-check-prefix=TAIL-CALL-SINK")
13 // TAIL-CALL-SINK: frame #0: 0x{{[0-9a-f]+}} a.out`tail_call_sink() at main.cpp:[[@LINE-1]]:4 [opt]
14 // TAIL-CALL-SINK-NEXT: func3{{.*}} [opt] [artificial]
15 // TAIL-CALL-SINK-NEXT: main{{.*}} [opt]
17 // TODO: The backtrace should include inlinable_function_which_tail_calls.
20 void __attribute__((always_inline)) inlinable_function_which_tail_calls() {
24 void __attribute__((noinline)) func3() {
25 inlinable_function_which_tail_calls();
28 void __attribute__((always_inline)) inline_sink() {
29 x++; //% self.filecheck("bt", "main.cpp", "-check-prefix=INLINE-SINK")
30 // INLINE-SINK: frame #0: 0x{{[0-9a-f]+}} a.out`func2() [inlined] inline_sink() at main.cpp:[[@LINE-1]]:4 [opt]
31 // INLINE-SINK-NEXT: func2{{.*}} [opt]
32 // INLINE-SINK-NEXT: func1{{.*}} [opt] [artificial]
33 // INLINE-SINK-NEXT: main{{.*}} [opt]
36 void __attribute__((noinline)) func2() { inline_sink(); /* inlined */ }
38 void __attribute__((noinline)) func1() { func2(); /* tail */ }
40 int __attribute__((disable_tail_calls)) main() {
41 // First, call a function that tail-calls a function, which itself inlines
45 // Next, call a function which contains an inlined tail-call.