File: main.cpp

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (42 lines) | stat: -rw-r--r-- 1,491 bytes parent folder | download | duplicates (8)
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
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
  // CHECK-NEXT: frame #1: 0x{{[0-9a-f]+}} a.out`func3() at main.cpp:26:3
  // CHECK-SAME: [artificial]
  // CHECK-NEXT: frame #2: 0x{{[0-9a-f]+}} a.out`func2()
  // CHECK-NEXT: frame #3: 0x{{[0-9a-f]+}} a.out`func1() at main.cpp:35:3
  // CHECK-SAME: [artificial]
  // CHECK-NEXT: frame #4: 0x{{[0-9a-f]+}} a.out`main
  // In the GNU style, the artificial frames will point after the tail call
  // instruction. In v5 they should point to the instruction itself.
  //% frame1 = self.thread().GetFrameAtIndex(1)
  //% func3 = frame1.GetFunction()
  //% func3_insns = func3.GetInstructions(self.target())
  //% self.trace("func3:\n%s"%func3_insns)
  //% last_insn = func3_insns.GetInstructionAtIndex(func3_insns.GetSize()-1)
  //% addr = last_insn.GetAddress()
  //% if "GNU" in self.name: addr.OffsetAddress(last_insn.GetByteSize())
  //% self.assertEqual(frame1.GetPCAddress(), addr)
}

void __attribute__((noinline)) func3() {
  x++;
  sink(); /* tail */
}

void __attribute__((disable_tail_calls, noinline)) func2() {
  func3(); /* regular */
}

void __attribute__((noinline)) func1() {
  x++;
  func2(); /* tail */
}

int __attribute__((disable_tail_calls)) main() {
  // DEBUG: self.runCmd("log enable lldb step -f /tmp/lldbstep.log")
  func1(); /* regular */
  return 0;
}