1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-24 00:23:06 +03:00
Files
postgres/src/backend/jit/llvm/llvmjit_wrap.cpp
Thomas Munro 0dceba21d7 jit: Adjust AArch64-only code for LLVM 21.
LLVM 21 changed the arguments of RTDyldObjectLinkingLayer's
constructor, breaking compilation with the backported
SectionMemoryManager from commit 9044fc1d.

cd585864c0

Backpatch-through: 14
Author: Holger Hoffstätte <holger@applied-asynchrony.com>
Reviewed-by: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Discussion: https://postgr.es/m/d25e6e4a-d1b4-84d3-2f8a-6c45b975f53d%40applied-asynchrony.com
2025-11-22 21:21:11 +13:00

67 lines
1.8 KiB
C++

/*-------------------------------------------------------------------------
*
* llvmjit_wrap.cpp
* Parts of the LLVM interface not (yet) exposed to C.
*
* Copyright (c) 2016-2025, PostgreSQL Global Development Group
*
* IDENTIFICATION
* src/backend/lib/llvm/llvmjit_wrap.cpp
*
*-------------------------------------------------------------------------
*/
extern "C"
{
#include "postgres.h"
}
#include <llvm-c/Core.h>
#include <llvm/IR/Function.h>
#include "jit/llvmjit.h"
#include "jit/llvmjit_backport.h"
#ifdef USE_LLVM_BACKPORT_SECTION_MEMORY_MANAGER
#include <llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h>
#include <llvm/ExecutionEngine/SectionMemoryManager.h>
#include "jit/SectionMemoryManager.h"
#include <llvm/Support/CBindingWrapping.h>
#endif
/*
* C-API extensions.
*/
LLVMTypeRef
LLVMGetFunctionReturnType(LLVMValueRef r)
{
return llvm::wrap(llvm::unwrap<llvm::Function>(r)->getReturnType());
}
LLVMTypeRef
LLVMGetFunctionType(LLVMValueRef r)
{
return llvm::wrap(llvm::unwrap<llvm::Function>(r)->getFunctionType());
}
#ifdef USE_LLVM_BACKPORT_SECTION_MEMORY_MANAGER
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(llvm::orc::ExecutionSession, LLVMOrcExecutionSessionRef)
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(llvm::orc::ObjectLayer, LLVMOrcObjectLayerRef);
LLVMOrcObjectLayerRef
LLVMOrcCreateRTDyldObjectLinkingLayerWithSafeSectionMemoryManager(LLVMOrcExecutionSessionRef ES)
{
#if LLVM_VERSION_MAJOR >= 21
return wrap(new llvm::orc::RTDyldObjectLinkingLayer(
*unwrap(ES), [](const llvm::MemoryBuffer&) {
return std::make_unique<llvm::backport::SectionMemoryManager>(nullptr, true);
}));
#else
return wrap(new llvm::orc::RTDyldObjectLinkingLayer(
*unwrap(ES), [] { return std::make_unique<llvm::backport::SectionMemoryManager>(nullptr, true); }));
#endif
}
#endif