Skip to content

Commit

Permalink
Merge branch 'vc/llvm16' into vc/llvm16_bump
Browse files Browse the repository at this point in the history
  • Loading branch information
gbaraldi authored Oct 16, 2023
2 parents afb6c31 + 4353ad0 commit 3c789a4
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 28 deletions.
1 change: 0 additions & 1 deletion src/aotcompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ using namespace llvm;
#include "jitlayers.h"
#include "serialize.h"
#include "julia_assert.h"
#include "llvm-codegen-shared.h"
#include "processor.h"

#define DEBUG_TYPE "julia_aotcompile"
Expand Down
14 changes: 6 additions & 8 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@

// support
#include <llvm/ADT/SmallBitVector.h>
#include <llvm/ADT/Optional.h>
#include <llvm/ADT/Statistic.h>
#include <llvm/Support/raw_ostream.h>
#include <llvm/Support/FormattedStream.h>
Expand Down Expand Up @@ -160,7 +159,6 @@ typedef Instruction TerminatorInst;
#endif

#include "jitlayers.h"
#include "llvm-codegen-shared.h"
#include "processor.h"
#include "julia_assert.h"

Expand Down Expand Up @@ -974,7 +972,7 @@ static const auto jlegalx_func = new JuliaFunction<TypeFnContextAndSizeT>{
[](LLVMContext &C, Type *T_size) {
Type *T = PointerType::get(JuliaType::get_jlvalue_ty(C), AddressSpace::Derived);
return FunctionType::get(getInt32Ty(C), {T, T, T_size}, false); },
[](LLVMContext &C) {
[](LLVMContext &C) {
AttrBuilder FnAttrs(C);
#if JL_LLVM_VERSION >= 160000
FnAttrs.addMemoryAttr(MemoryEffects::inaccessibleOrArgMemOnly());
Expand Down Expand Up @@ -1034,7 +1032,7 @@ static const auto jl_typeof_func = new JuliaFunction<>{
return FunctionType::get(T_prjlvalue,
{T_prjlvalue}, false);
},
[](LLVMContext &C) {
[](LLVMContext &C) {
AttrBuilder FnAttrs(C);
#if JL_LLVM_VERSION >= 160000
FnAttrs.addMemoryAttr(MemoryEffects::none());
Expand Down Expand Up @@ -1065,7 +1063,7 @@ static const auto jl_write_barrier_func = new JuliaFunction<>{
return AttributeList::get(C,
AttributeSet::get(C, FnAttrs),
AttributeSet(),
{Attributes(C, {Attribute::ReadOnly})});
{Attributes(C, {Attribute::ReadOnly})});
},
};

Expand Down Expand Up @@ -1130,7 +1128,7 @@ static const auto memcmp_func = new JuliaFunction<TypeFnContextAndSizeT>{
XSTR(memcmp),
[](LLVMContext &C, Type *T_size) { return FunctionType::get(getInt32Ty(C),
{getInt8PtrTy(C), getInt8PtrTy(C), T_size}, false); },
[](LLVMContext &C) {
[](LLVMContext &C) {
AttrBuilder FnAttrs(C);
#if JL_LLVM_VERSION >= 160000
FnAttrs.addMemoryAttr(MemoryEffects::argMemOnly(ModRefInfo::Ref));
Expand Down Expand Up @@ -1253,7 +1251,7 @@ static const auto jlarray_data_owner_func = new JuliaFunction<>{
return FunctionType::get(T_prjlvalue,
{T_prjlvalue}, false);
},
[](LLVMContext &C) {
[](LLVMContext &C) {
AttrBuilder FnAttrs(C);
#if JL_LLVM_VERSION >= 160000
FnAttrs.addMemoryAttr(MemoryEffects::readOnly());
Expand Down Expand Up @@ -1323,7 +1321,7 @@ static const auto pointer_from_objref_func = new JuliaFunction<>{
"julia.pointer_from_objref",
[](LLVMContext &C) { return FunctionType::get(JuliaType::get_pjlvalue_ty(C),
{PointerType::get(JuliaType::get_jlvalue_ty(C), AddressSpace::Derived)}, false); },
[](LLVMContext &C) {
[](LLVMContext &C) {
AttrBuilder FnAttrs(C);
#if JL_LLVM_VERSION >= 160000
FnAttrs.addMemoryAttr(MemoryEffects::none());
Expand Down
1 change: 0 additions & 1 deletion src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

using namespace llvm;

#include "llvm-codegen-shared.h"
#include "jitlayers.h"
#include "julia_assert.h"
#include "processor.h"
Expand Down
15 changes: 1 addition & 14 deletions src/jitlayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,10 @@
#include "julia.h"
#include "julia_internal.h"
#include "platform.h"

#include "llvm-codegen-shared.h"
#include <stack>
#include <queue>

#if JL_LLVM_VERSION >= 160000

#include <optional>

template<typename T>
using Optional = std::optional<T>;
static constexpr std::nullopt_t None = std::nullopt;

#else

#include <llvm/ADT/Optional.h>

#endif

// As of LLVM 13, there are two runtime JIT linker implementations, the older
// RuntimeDyld (used via orc::RTDyldObjectLinkingLayer) and the newer JITLink
Expand Down
17 changes: 16 additions & 1 deletion src/llvm-codegen-shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@
#define STR(csym) #csym
#define XSTR(csym) STR(csym)

#if JL_LLVM_VERSION >= 160000

#include <optional>

template<typename T>
using Optional = std::optional<T>;
static constexpr std::nullopt_t None = std::nullopt;

#else

#include <llvm/ADT/Optional.h>

#endif

enum AddressSpace {
Generic = 0,
Tracked = 10,
Expand Down Expand Up @@ -153,9 +167,10 @@ static inline llvm::MDNode *get_tbaa_const(llvm::LLVMContext &ctxt) {

static inline llvm::Instruction *tbaa_decorate(llvm::MDNode *md, llvm::Instruction *inst)
{
using namespace llvm;
inst->setMetadata(llvm::LLVMContext::MD_tbaa, md);
if (llvm::isa<llvm::LoadInst>(inst) && md && md == get_tbaa_const(md->getContext())) {
inst->setMetadata(llvm::LLVMContext::MD_invariant_load, llvm::MDNode::get(md->getContext(), llvm::None));
inst->setMetadata(llvm::LLVMContext::MD_invariant_load, llvm::MDNode::get(md->getContext(), None));
}
return inst;
}
Expand Down
1 change: 0 additions & 1 deletion src/llvm-cpufeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#include "llvm-version.h"
#include "passes.h"
#include "llvm-codegen-shared.h"

#include <llvm/ADT/Statistic.h>
#include <llvm/IR/Module.h>
Expand Down
4 changes: 2 additions & 2 deletions src/llvm-late-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@ State LateLowerGCFrame::LocalScan(Function &F) {
}
}
#if JL_LLVM_VERSION >= 160000
if (isa<IntrinsicInst>(CI) ||
if (isa<IntrinsicInst>(CI) ||
CI->getMemoryEffects().onlyAccessesArgPointees() ||
CI->getMemoryEffects().onlyReadsMemory()) {
// Intrinsics are never safepoints.
Expand All @@ -1626,7 +1626,7 @@ State LateLowerGCFrame::LocalScan(Function &F) {
#else
if (isa<IntrinsicInst>(CI) ||
CI->hasFnAttr(Attribute::ArgMemOnly) ||
CI->hasFnAttr(Attribute::ReadNone) ||
CI->hasFnAttr(Attribute::ReadNone) ||
CI->hasFnAttr(Attribute::ReadOnly)) {
// Intrinsics are never safepoints.
continue;
Expand Down

0 comments on commit 3c789a4

Please sign in to comment.