https://github.com/JuliaLang/julia
Raw File
Tip revision: c6da87ff4bc7a855e217856757ad3413cf6d1f79 authored by Alex Arslan on 20 August 2019, 00:03:01 UTC
Set VERSION to 1.2.0 (#32964)
Tip revision: c6da87f
llvmcalltest.cpp
// 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;
}

}
back to top