11#ifndef PROTEUS_TRANSFORM_SHARED_ARRAY_HPP
12#define PROTEUS_TRANSFORM_SHARED_ARRAY_HPP
14#include <llvm/Analysis/ConstantFolding.h>
15#include <llvm/Demangle/Demangle.h>
16#include <llvm/IR/IRBuilder.h>
17#include <llvm/IR/Verifier.h>
18#include <llvm/Support/Debug.h>
31 for (
auto &
Func : M.functions()) {
34 if (
StrRef.contains(
"proteus::shared_array")) {
36 while (!
Func.user_empty()) {
42 assert(
CB->arg_size() == 2 &&
"Expected 2 arguments: N and sizeof");
45 if (!getConstantValue(
CB->getArgOperand(0),
N, M.getDataLayout()))
47 if (!getConstantValue(
CB->getArgOperand(1),
Sizeof,
52 ArrayType::get(Type::getInt8Ty(M.getContext()),
N *
Sizeof);
55 M,
AType,
false, GlobalValue::InternalLinkage,
56 UndefValue::get(
AType),
".proteus.shared",
nullptr,
77 CB->replaceAllUsesWith(ConstantExpr::getAddrSpaceCast(
79 CB->eraseFromParent();
85 "Broken module found, JIT compilation aborted!");
#define PROTEUS_DBG(x)
Definition Debug.h:9
#define PROTEUS_FATAL_ERROR(x)
Definition Error.h:7
static Config & get()
Definition Config.hpp:298
StringRef getName() const
Definition Func.hpp:231
static void trace(llvm::StringRef Msg)
Definition Logger.hpp:30
static llvm::raw_ostream & logs(const std::string &Name)
Definition Logger.hpp:19
Definition StorageCache.cpp:24
T getRuntimeConstantValue(void *Arg)
Definition CompilerInterfaceRuntimeConstantInfo.h:114