Skip to content

Commit

Permalink
Some minimal LLVM15 compat (JuliaLang#44870)
Browse files Browse the repository at this point in the history
just a drive-by as I was trying out some commits on master
  • Loading branch information
Keno authored Apr 14, 2022
1 parent 5808648 commit 190565c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2041,10 +2041,10 @@ static void emit_memcpy_llvm(jl_codectx_t &ctx, Value *dst, MDNode *tbaa_dst, Va
const DataLayout &DL = jl_Module->getDataLayout();
auto srcty = cast<PointerType>(src->getType());
//TODO unsafe nonopaque pointer
auto srcel = srcty->getElementType();
auto srcel = srcty->getPointerElementType();
auto dstty = cast<PointerType>(dst->getType());
//TODO unsafe nonopaque pointer
auto dstel = dstty->getElementType();
auto dstel = dstty->getPointerElementType();
if (srcel->isArrayTy() && srcel->getArrayNumElements() == 1) {
src = ctx.builder.CreateConstInBoundsGEP2_32(srcel, src, 0, 0);
srcel = srcel->getArrayElementType();
Expand Down
13 changes: 12 additions & 1 deletion src/disasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
#include <llvm/Support/CodeGen.h>
#include <llvm/IR/LegacyPassManager.h>

#include <llvm-c/Disassembler.h>

#include "julia.h"
#include "julia_internal.h"
#include "jitlayers.h"
Expand Down Expand Up @@ -899,7 +901,11 @@ static void jl_dump_asm_internal(
std::unique_ptr<MCCodeEmitter> CE;
std::unique_ptr<MCAsmBackend> MAB;
if (ShowEncoding) {
#if JL_LLVM_VERSION >= 150000
CE.reset(TheTarget->createMCCodeEmitter(*MCII, Ctx));
#else
CE.reset(TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx));
#endif
MAB.reset(TheTarget->createMCAsmBackend(*STI, *MRI, Options));
}

Expand Down Expand Up @@ -1231,8 +1237,13 @@ jl_value_t *jl_dump_function_asm_impl(void *F, char raw_mc, const char* asm_vari
std::unique_ptr<MCAsmBackend> MAB(TM->getTarget().createMCAsmBackend(
STI, MRI, TM->Options.MCOptions));
std::unique_ptr<MCCodeEmitter> MCE;
if (binary) // enable MCAsmStreamer::AddEncodingComment printing
if (binary) { // enable MCAsmStreamer::AddEncodingComment printing
#if JL_LLVM_VERSION >= 150000
MCE.reset(TM->getTarget().createMCCodeEmitter(MII, *Context));
#else
MCE.reset(TM->getTarget().createMCCodeEmitter(MII, MRI, *Context));
#endif
}
auto FOut = std::make_unique<formatted_raw_ostream>(asmfile);
std::unique_ptr<MCStreamer> S(TM->getTarget().createAsmStreamer(
*Context, std::move(FOut), true,
Expand Down
4 changes: 2 additions & 2 deletions src/llvm-remove-addrspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AddrspaceRemoveTypeRemapper : public ValueMapTypeRemapper {
else {
//Remove once opaque pointer transition is complete
DstTy = PointerType::get(
remapType(Ty->getElementType()),
remapType(Ty->getPointerElementType()),
ASRemapper(Ty->getAddressSpace()));
}
}
Expand Down Expand Up @@ -161,7 +161,7 @@ class AddrspaceRemoveValueMaterializer : public ValueMaterializer {
auto ptrty = cast<PointerType>(Src->getType()->getScalarType());
//Remove once opaque pointer transition is complete
if (!ptrty->isOpaque()) {
Type *SrcTy = remapType(ptrty->getElementType());
Type *SrcTy = remapType(ptrty->getPointerElementType());
DstV = CE->getWithOperands(Ops, Ty, false, SrcTy);
}
}
Expand Down

0 comments on commit 190565c

Please sign in to comment.