summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/main.cpp
blob: d3aef19f7a4fe3fc5bc7111d2a3b6c711a2188c9 (plain)
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
//===-- main.cpp ------------------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

volatile int x;

void __attribute__((noinline)) sink() {
  x++; //% self.filecheck("bt", "main.cpp", "-implicit-check-not=artificial")
  // CHECK: frame #0: 0x{{[0-9a-f]+}} a.out`sink() at main.cpp:[[@LINE-1]]:4 [opt]
  // CHECK-NEXT: func2{{.*}} [opt] [artificial]
  // CHECK-NEXT: main{{.*}} [opt]
}

void __attribute__((noinline)) func2() {
  sink(); /* tail */
}

void __attribute__((noinline)) func1() { sink(); /* tail */ }

int __attribute__((disable_tail_calls)) main(int argc, char **) {
  // The sequences `main -> f{1,2} -> sink` are both plausible. Test that
  // return-pc call site info allows lldb to pick the correct sequence.
  func2();
  if (argc == 100)
    func1();
  return 0;
}
OpenPOWER on IntegriCloud