forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathllvmcalltest.cpp
32 lines (23 loc) · 845 Bytes
/
llvmcalltest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// This file is a part of Julia. License is MIT: https://julialang.org/license
#include "../src/support/platform.h"
#include "../src/support/dtypes.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/IRBuilder.h"
#include "codegen_shared.h"
using namespace llvm;
extern "C" {
JL_DLLEXPORT llvm::Function *MakeIdentityFunction(llvm::PointerType *AnyTy) {
Type *TrackedTy = PointerType::get(AnyTy->getElementType(), AddressSpace::Tracked);
Module *M = new llvm::Module("shadow", AnyTy->getContext());
Function *F = Function::Create(
FunctionType::get(
TrackedTy, {TrackedTy}, false),
llvm::GlobalValue::ExternalLinkage,
"identity",
M
);
IRBuilder<> Builder(BasicBlock::Create(AnyTy->getContext(), "top", F));
Builder.CreateRet(&*F->arg_begin());
return F;
}
}