• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tudasc / TypeART / 13528988609

25 Feb 2025 07:06PM UTC coverage: 88.854% (-1.9%) from 90.735%
13528988609

Pull #163

github

web-flow
Merge e4a2d80f6 into d2e14acc5
Pull Request #163: LLVM 18 support

974 of 1122 new or added lines in 38 files covered. (86.81%)

30 existing lines in 6 files now uncovered.

4201 of 4728 relevant lines covered (88.85%)

190054.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.76
/lib/passes/support/ModuleDumper.cpp
1
// TypeART library
2
//
3
// Copyright (c) 2017-2025 TypeART Authors
4
// Distributed under the BSD 3-Clause license.
5
// (See accompanying file LICENSE.txt or copy at
6
// https://opensource.org/licenses/BSD-3-Clause)
7
//
8
// Project home: https://github.com/tudasc/TypeART
9
//
10
// SPDX-License-Identifier: BSD-3-Clause
11
//
12

13
#include "ModuleDumper.h"
14

15
#include "support/Logger.h"
16

17
#include "llvm/ADT/StringRef.h"
18
#include "llvm/Support/raw_ostream.h"
19

20
#include <cstdlib>
21
#include <filesystem>
22
#include <string_view>
23

24
namespace typeart::util::module::detail {
25

26
void dump_module(const llvm::Module& module, llvm::raw_ostream& out_s) {
288✔
27
  module.print(out_s, nullptr);
288✔
28
}
288✔
29

30
std::string_view gets_source_file(const llvm::Module& module) {
288✔
31
  return module.getSourceFileName();
288✔
32
}
33

34
std::string_view get_file_ext(ModulePhase phase) {
288✔
35
  switch (phase) {
288✔
36
    case ModulePhase::kBase:
37
      return "_base.ll";
72✔
38
    case ModulePhase::kHeap:
39
      return "_heap.ll";
72✔
40
    case ModulePhase::kOpt:
41
      return "_opt.ll";
72✔
42
    case ModulePhase::kStack:
43
      return "_stack.ll";
72✔
44
  }
NEW
45
  return "_unknown.ll";
×
46
}
288✔
47

48
}  // namespace typeart::util::module::detail
49

50
namespace typeart::util::module {
51

52
void dump_module(const llvm::Module& module, ModulePhase phase) {
4,700✔
53
  if (std::getenv("TYPEART_PASS_INTERNAL_EMIT_IR") == nullptr) {
4,700✔
54
    LOG_DEBUG("No dump required")
55
    return;
4,412✔
56
  }
57

58
  const auto source = std::filesystem::path{detail::gets_source_file(module)};
288✔
59

60
  if (!source.has_filename()) {
288✔
NEW
61
    LOG_ERROR("No filename for module")
×
NEW
62
    return;
×
63
  }
64

65
  const auto source_ll = source.parent_path() / (source.stem().string() + detail::get_file_ext(phase).data());
288✔
66
  LOG_DEBUG("Dumping to file " << source_ll);
67

68
  std::error_code error_code;
288✔
69
  llvm::raw_fd_ostream file_out{source_ll.c_str(), error_code};
288✔
70
  if (error_code) {
288✔
NEW
71
    LOG_FATAL("Error while opening file " << error_code.message())
×
NEW
72
    return;
×
73
  }
74

75
  detail::dump_module(module, file_out);
288✔
76
  file_out.close();
288✔
77
}
4,700✔
78

79
}  // namespace typeart::util::module
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc