Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / cfi / lit.cfg.py
blobf9afc6bc0234f95fcfd89103b98f477a58ff168b
1 import lit.formats
2 import os
4 config.name = "cfi" + config.name_suffix
5 config.suffixes = [".c", ".cpp", ".test"]
6 config.test_source_root = os.path.dirname(__file__)
9 def build_invocation(compile_flags):
10 return " " + " ".join([config.clang] + compile_flags) + " "
13 clang = build_invocation([config.target_cflags])
14 clangxx = build_invocation([config.target_cflags] + config.cxx_mode_flags)
16 config.substitutions.append((r"%clang ", clang + " "))
17 config.substitutions.append((r"%clangxx ", clangxx + " "))
19 if "darwin" in config.available_features:
20 # -fsanitize=cfi is not supported on Darwin hosts
21 config.unsupported = True
22 elif config.lto_supported:
23 clang_cfi = clang + "-fsanitize=cfi "
25 if config.cfi_lit_test_mode == "Devirt":
26 config.available_features.add("devirt")
27 clang_cfi += "-fwhole-program-vtables "
28 config.substitutions.append((r"%expect_crash_unless_devirt ", ""))
29 else:
30 config.substitutions.append(
31 (r"%expect_crash_unless_devirt ", config.expect_crash)
34 cxx = " ".join(config.cxx_mode_flags) + " "
35 diag = "-fno-sanitize-trap=cfi -fsanitize-recover=cfi "
36 non_dso = "-fvisibility=hidden "
37 dso = "-fsanitize-cfi-cross-dso -fvisibility=default "
38 if config.android:
39 dso += "-include " + config.test_source_root + "/cross-dso/util/cfi_stubs.h "
40 config.substitutions.append((r"%clang_cfi ", clang_cfi + non_dso))
41 config.substitutions.append((r"%clangxx_cfi ", clang_cfi + cxx + non_dso))
42 config.substitutions.append((r"%clang_cfi_diag ", clang_cfi + non_dso + diag))
43 config.substitutions.append(
44 (r"%clangxx_cfi_diag ", clang_cfi + cxx + non_dso + diag)
46 config.substitutions.append((r"%clangxx_cfi_dso ", clang_cfi + cxx + dso))
47 config.substitutions.append(
48 (r"%clangxx_cfi_dso_diag ", clang_cfi + cxx + dso + diag)
50 config.substitutions.append(
51 (r"%debug_info_flags", " ".join(config.debug_info_flags))
53 else:
54 config.unsupported = True
56 if config.default_sanitizer_opts:
57 config.environment["UBSAN_OPTIONS"] = ":".join(config.default_sanitizer_opts)
59 if lit_config.params.get("check_supported", None) and config.unsupported:
60 raise BaseException("Tests unsupported")