File: lit.local.cfg

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 (55 lines) | stat: -rw-r--r-- 1,955 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import subprocess
import re
import lit.util


def can_execute_generated_snippets(arch):
    is_host_arch = arch in config.root.host_triple
    # 'native' feature is defined as "host arch == default triple arch"
    is_native_codegen = "native" in config.available_features
    return is_host_arch and is_native_codegen


def can_use_perf_counters(mode, extra_options=[]):
    # We need libpfm to be installed and allow reading perf counters. We can
    # only know that at runtime, so we try to measure an empty code snippet
    # and bail out on error.
    llvm_exegesis_exe = lit.util.which("llvm-exegesis", config.llvm_tools_dir)
    if llvm_exegesis_exe is None:
        print("could not find llvm-exegesis")
        return False
    try:
        return_code = subprocess.call(
            [llvm_exegesis_exe, "-mode", mode, "-snippets-file", "/dev/null"]
            + extra_options,
            stdout=subprocess.DEVNULL,
            stderr=subprocess.DEVNULL,
        )
        return return_code == 0
    except OSError:
        print("could not exec llvm-exegesis")
        return False


for arch in ["aarch64", "mips", "powerpc", "x86_64"]:
    if can_execute_generated_snippets(arch):
        config.available_features.add("exegesis-can-execute-%s" % arch)

if can_use_perf_counters("latency"):
    config.available_features.add("exegesis-can-measure-latency")

if can_use_perf_counters("uops"):
    config.available_features.add("exegesis-can-measure-uops")

if can_execute_generated_snippets("x86_64"):
    # Check for support of LBR format with cycles.
    if can_use_perf_counters(
        "latency", ["-x86-lbr-sample-period", "123", "-repetition-mode", "loop"]
    ):
        config.available_features.add("exegesis-can-measure-latency-lbr")

# The subprocess tests are flaky on some of the builders that support them, so
# they are disabled currently.
#if True:
#    config.available_features.add("exegesis-can-execute-in-subprocess")