• 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

68.57
/lib/passes/instrumentation/InstrumentationHelper.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 "InstrumentationHelper.h"
14

15
#include "support/Logger.h"
16

17
#include "llvm/ADT/ArrayRef.h"
18
#include "llvm/ADT/SmallVector.h"
19
#include "llvm/IR/Constants.h"
20
#include "llvm/IR/DerivedTypes.h"
21
#include "llvm/IR/Module.h"
22
#include "llvm/IR/Type.h"
23
#include "llvm/IR/Value.h"
24
#include "llvm/Support/Casting.h"
25

26
#include <optional>
27

28
namespace typeart {
29

30
using namespace llvm;
31

32
InstrumentationHelper::InstrumentationHelper()  = default;
8,788✔
33
InstrumentationHelper::~InstrumentationHelper() = default;
17,082✔
34

35
llvm::SmallVector<llvm::Type*, 8> InstrumentationHelper::make_signature(const llvm::ArrayRef<llvm::Value*>& args) {
×
36
  llvm::SmallVector<llvm::Type*, 8> types;
×
37
  for (auto* val : args) {
×
38
    types.push_back(val->getType());
×
39
  }
40
  return types;
×
41
}
×
42

43
llvm::Type* InstrumentationHelper::getTypeFor(IType id) {
74,459✔
44
  auto& c = module->getContext();
74,459✔
45
  switch (id) {
74,459✔
46
    case IType::ptr:
47
#if LLVM_VERSION_MAJOR < 15
3,092✔
48
      return Type::getInt8PtrTy(c);
7,046✔
49
#else
50
      // TODO which address space?
51
      return PointerType::get(c, 0);
6,240✔
52
#endif
53
    case IType::function_id:
54
      return Type::getInt32Ty(c);
×
55
    case IType::extent:
56
      return Type::getInt64Ty(c);
34,084✔
57
    case IType::type_id:
58
      [[fallthrough]];
59
    case IType::alloca_id:
60
      return Type::getInt32Ty(c);
17,096✔
61
    case IType::stack_count:
62
      return Type::getInt32Ty(c);
27,089✔
63
    default:
64
      LOG_WARNING("Unknown IType selected.");
×
65
      return nullptr;
×
66
  }
67
}
74,459✔
68

69
llvm::ConstantInt* InstrumentationHelper::getConstantFor(IType id, size_t value) {
39,014✔
70
  const auto make_int = [&]() -> std::optional<ConstantInt*> {
78,028✔
71
    auto itype = dyn_cast_or_null<IntegerType>(getTypeFor(id));
39,014✔
72
    if (itype == nullptr) {
39,014✔
73
      LOG_FATAL("Pointer for the constant type is null, need aborting...");
×
NEW
74
      return {};
×
75
    }
76
    return ConstantInt::get(itype, value);
39,014✔
77
  };
39,014✔
78
  return make_int().value();
39,014✔
79
}
80

81
void InstrumentationHelper::setModule(llvm::Module& m) {
3,118✔
82
  module = &m;
3,118✔
83
}
3,118✔
84

85
llvm::Module* InstrumentationHelper::getModule() const {
642✔
86
  return module;
642✔
87
}
88

89
}  // namespace typeart
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