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

tudasc / TypeART / 13955121336

19 Mar 2025 07:30PM UTC coverage: 88.842%. First build
13955121336

push

github

web-flow
Merge PR #167 from tudasc/devel

1174 of 1361 new or added lines in 49 files covered. (86.26%)

4212 of 4741 relevant lines covered (88.84%)

261950.04 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) {
384✔
27
  module.print(out_s, nullptr);
384✔
28
}
384✔
29

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

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

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

50
namespace typeart::util::module {
51

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

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

60
  if (!source.has_filename()) {
384✔
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());
384✔
66
  LOG_DEBUG("Dumping to file " << source_ll);
67

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

75
  detail::dump_module(module, file_out);
384✔
76
  file_out.close();
384✔
77
}
6,236✔
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