Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Julia to LLVM 16 #51720

Merged
merged 30 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
946b6a1
Adopt to LLVM 16
vchuravy Oct 4, 2023
a21c7ed
Bump Julia to LLVM 16
vchuravy Oct 15, 2023
8d92d63
Merge branch 'master' into vc/llvm16_bump
gbaraldi Nov 2, 2023
66ee579
Update to 16.0.6+1 and add removeJuliaAddrSpaces pass
gbaraldi Nov 2, 2023
9ba6de9
Fixup new LLVM 16 issues
gbaraldi Nov 2, 2023
dd44675
Merge branch 'master' into vc/llvm16_bump
gbaraldi Nov 23, 2023
bc918a5
Fix memory attributes with the new syntax
gbaraldi Nov 24, 2023
633e656
Bump llvm build to 16.0.6+2
gbaraldi Nov 24, 2023
63f4afb
Try to fix asan and gcanalyze
gbaraldi Nov 24, 2023
2704710
Update some tests that don't expect opaque pointers
gbaraldi Nov 25, 2023
8b7bc43
Merge branch 'master' into vc/llvm16_bump
gbaraldi Dec 6, 2023
3b5c3ae
Bump LLVM to 16.0.6+3
gbaraldi Dec 11, 2023
89b162c
Actually bump the jlls
gbaraldi Dec 11, 2023
d3dc475
add optional
vtjnash Dec 13, 2023
7ffc66b
fix win32 build?
vtjnash Dec 13, 2023
12a3ad9
Merge remote-tracking branch 'origin/master' into vc/llvm16_bump
vchuravy Dec 15, 2023
22079eb
Fixup checksums
gbaraldi Dec 15, 2023
30aa38f
Correct opaque pointer detection
gbaraldi Dec 18, 2023
a38c099
Try to make ASAN happier
gbaraldi Dec 18, 2023
9cb34c6
Make llvmpasses tests more happy
gbaraldi Dec 19, 2023
471dc6c
Why do I even bother also thanks tim
gbaraldi Dec 20, 2023
91d2069
Fix typo
gbaraldi Dec 20, 2023
e9bf920
Don't remove bfloat16
gbaraldi Dec 20, 2023
4048f7e
Fix Float16 soft-float ABI.
maleadt Dec 21, 2023
bf929df
Merge branch 'master' into vc/llvm16_bump
gbaraldi Dec 21, 2023
4e5b98a
Merge branch 'master' into vc/llvm16_bump
gbaraldi Dec 27, 2023
b61062b
Remove unused code and try to make analyzegc happier
gbaraldi Dec 28, 2023
3687772
More static analyzer fixes
gbaraldi Jan 5, 2024
08014aa
Use reference instead of copying by value
gbaraldi Jan 5, 2024
1d169c5
Use function ref and update version header
gbaraldi Jan 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ JCPPFLAGS_COMMON := -fasynchronous-unwind-tables
JCPPFLAGS_CLANG := $(JCPPFLAGS_COMMON) -mllvm -enable-tail-merge=0
JCPPFLAGS_GCC := $(JCPPFLAGS_COMMON) -fno-tree-tail-merge

JCXXFLAGS_COMMON := -pipe $(fPIC) -fno-rtti -std=c++14
JCXXFLAGS_COMMON := -pipe $(fPIC) -fno-rtti -std=c++17
JCXXFLAGS_CLANG := $(JCXXFLAGS_COMMON) -pedantic
JCXXFLAGS_GCC := $(JCXXFLAGS_COMMON) -fno-gnu-unique

Expand Down
216 changes: 108 additions & 108 deletions deps/checksums/clang

Large diffs are not rendered by default.

216 changes: 108 additions & 108 deletions deps/checksums/lld

Large diffs are not rendered by default.

436 changes: 218 additions & 218 deletions deps/checksums/llvm

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deps/clang.version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## jll artifact
# Clang (paired with LLVM, only here as a JLL download)
CLANG_JLL_NAME := Clang
CLANG_JLL_VER := 15.0.7+10
CLANG_JLL_VER := 16.0.6+3
2 changes: 1 addition & 1 deletion deps/lld.version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## jll artifact
LLD_JLL_NAME := LLD
LLD_JLL_VER := 15.0.7+10
LLD_JLL_VER := 16.0.6+3
4 changes: 2 additions & 2 deletions deps/llvm-tools.version
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## jll artifact
# LLVM_tools (downloads LLVM_jll to get things like `lit` and `opt`)
LLVM_TOOLS_JLL_NAME := LLVM
LLVM_TOOLS_JLL_VER := 15.0.7+10
LLVM_TOOLS_ASSERT_JLL_VER := 15.0.7+10
LLVM_TOOLS_JLL_VER := 16.0.6+3
LLVM_TOOLS_ASSERT_JLL_VER := 16.0.6+3
2 changes: 1 addition & 1 deletion deps/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ endif # USE_PERF_JITEVENTS

ifeq ($(BUILD_LLDB),1)
ifeq ($(USECLANG),0)
LLVM_CXXFLAGS += -std=c++0x
LLVM_CXXFLAGS += -std=c++17
endif # USECLANG
ifeq ($(LLDB_DISABLE_PYTHON),1)
LLVM_CXXFLAGS += -DLLDB_DISABLE_PYTHON
Expand Down
12 changes: 6 additions & 6 deletions deps/llvm.version
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

## jll artifact
LLVM_JLL_NAME := libLLVM
LLVM_ASSERT_JLL_VER := 15.0.7+10
LLVM_ASSERT_JLL_VER := 16.0.6+3
## source build
# Version number of LLVM
LLVM_VER := 15.0.7
LLVM_VER := 16.0.6
# Git branch name in `LLVM_GIT_URL` repository
LLVM_BRANCH=julia-15.0.7-10
LLVM_BRANCH=julia-16.0.6-2
# Git ref in `LLVM_GIT_URL` repository
LLVM_SHA1=julia-15.0.7-10
LLVM_SHA1=julia-16.0.6-2

## Following options are used to automatically fetch patchset from Julia's fork. This is
## useful if you want to build an external LLVM while still applying Julia's patches.
Expand All @@ -18,6 +18,6 @@ LLVM_APPLY_JULIA_PATCHES := 0
# GitHub repository to use for fetching the Julia patches to apply to LLVM source code.
LLVM_JULIA_DIFF_GITHUB_REPO := https://github.com/llvm/llvm-project
# Base GitHub ref for generating the diff.
LLVM_BASE_REF := llvm:llvmorg-15.0.7
LLVM_BASE_REF := llvm:llvmorg-16.0.6
# Julia fork's GitHub ref for generating the diff.
LLVM_JULIA_REF := JuliaLang:julia-15.0.7-9
LLVM_JULIA_REF := JuliaLang:julia-16.0.6-0
4 changes: 4 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ PUBLIC_HEADER_TARGETS := $(addprefix $(build_includedir)/julia/,$(notdir $(PUBLI
LLVM_LDFLAGS := $(shell $(LLVM_CONFIG_HOST) --ldflags)
LLVM_CXXFLAGS := $(shell $(LLVM_CONFIG_HOST) --cxxflags)

ifeq ($(OS)_$(BINARY),WINNT_32)
LLVM_CXXFLAGS += -I$(SRCDIR)/support/win32-clang-ABI-bug
endif

# llvm-config --cxxflags does not return -DNDEBUG
ifeq ($(shell $(LLVM_CONFIG_HOST) --assertion-mode),OFF)
LLVM_CXXFLAGS += -DNDEBUG
Expand Down
19 changes: 18 additions & 1 deletion src/aotcompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,8 +1049,21 @@ static AOTOutputs add_output_impl(Module &M, TargetMachine &SourceTM, ShardTimer
// but LLVM doesn't let us emit a GlobalAlias to a declaration...
// So for now we inject a definition of these functions that calls our runtime
// functions. We do so after optimization to avoid cloning these functions.

// Float16 conversion routines
#if defined(_CPU_X86_64_) && defined(_OS_DARWIN_) && JL_LLVM_VERSION >= 160000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this dependent on the target triple? Just to preserve the fiction that codegen is cross-compile capable.

// LLVM 16 reverted to soft-float ABI for passing half on x86_64 Darwin
// https://github.com/llvm/llvm-project/commit/2bcf51c7f82ca7752d1bba390a2e0cb5fdd05ca9
injectCRTAlias(M, "__gnu_h2f_ieee", "julia_half_to_float",
FunctionType::get(Type::getFloatTy(M.getContext()), { Type::getInt16Ty(M.getContext()) }, false));
injectCRTAlias(M, "__extendhfsf2", "julia_half_to_float",
FunctionType::get(Type::getFloatTy(M.getContext()), { Type::getInt16Ty(M.getContext()) }, false));
injectCRTAlias(M, "__gnu_f2h_ieee", "julia_float_to_half",
FunctionType::get(Type::getInt16Ty(M.getContext()), { Type::getFloatTy(M.getContext()) }, false));
injectCRTAlias(M, "__truncsfhf2", "julia_float_to_half",
FunctionType::get(Type::getInt16Ty(M.getContext()), { Type::getFloatTy(M.getContext()) }, false));
injectCRTAlias(M, "__truncdfhf2", "julia_double_to_half",
FunctionType::get(Type::getInt16Ty(M.getContext()), { Type::getDoubleTy(M.getContext()) }, false));
#else
injectCRTAlias(M, "__gnu_h2f_ieee", "julia__gnu_h2f_ieee",
FunctionType::get(Type::getFloatTy(M.getContext()), { Type::getHalfTy(M.getContext()) }, false));
injectCRTAlias(M, "__extendhfsf2", "julia__gnu_h2f_ieee",
Expand All @@ -1061,6 +1074,7 @@ static AOTOutputs add_output_impl(Module &M, TargetMachine &SourceTM, ShardTimer
FunctionType::get(Type::getHalfTy(M.getContext()), { Type::getFloatTy(M.getContext()) }, false));
injectCRTAlias(M, "__truncdfhf2", "julia__truncdfhf2",
FunctionType::get(Type::getHalfTy(M.getContext()), { Type::getDoubleTy(M.getContext()) }, false));
#endif

// BFloat16 conversion routines
injectCRTAlias(M, "__truncsfbf2", "julia__truncsfbf2",
Expand Down Expand Up @@ -1361,6 +1375,7 @@ static SmallVector<AOTOutputs, 16> add_output(Module &M, TargetMachine &TM, Stri
for (unsigned i = 0; i < threads; i++) {
std::function<void()> func = [&, i]() {
LLVMContext ctx;
SetOpaquePointer(ctx);
// Lazily deserialize the entire module
timers[i].deserialize.startTimer();
auto EM = getLazyBitcodeModule(MemoryBufferRef(StringRef(serialized.data(), serialized.size()), "Optimized"), ctx);
Expand Down Expand Up @@ -1562,6 +1577,7 @@ void jl_dump_native_impl(void *native_code,
if (z) {
JL_TIMING(NATIVE_AOT, NATIVE_Sysimg);
LLVMContext Context;
SetOpaquePointer(Context);
Module sysimgM("sysimg", Context);
sysimgM.setTargetTriple(TheTriple.str());
sysimgM.setDataLayout(DL);
Expand Down Expand Up @@ -1698,6 +1714,7 @@ void jl_dump_native_impl(void *native_code,
{
JL_TIMING(NATIVE_AOT, NATIVE_Metadata);
LLVMContext Context;
SetOpaquePointer(Context);
Module metadataM("metadata", Context);
metadataM.setTargetTriple(TheTriple.str());
metadataM.setDataLayout(DL);
Expand Down
10 changes: 5 additions & 5 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ static bool is_tupletype_homogeneous(jl_svec_t *t, bool allow_va = false)
}

static bool for_each_uniontype_small(
std::function<void(unsigned, jl_datatype_t*)> f,
llvm::function_ref<void(unsigned, jl_datatype_t*)> f,
jl_value_t *ty,
unsigned &counter)
{
Expand Down Expand Up @@ -4046,12 +4046,12 @@ static jl_cgval_t emit_memoryref(jl_codectx_t &ctx, const jl_cgval_t &ref, jl_cg
Value *mlen = emit_genericmemorylen(ctx, mem, ref.typ);
Value *inbound = ctx.builder.CreateICmpULT(newdata, mlen);
ctx.builder.CreateCondBr(inbound, endBB, failBB);
ctx.f->getBasicBlockList().push_back(failBB);
failBB->insertInto(ctx.f);
ctx.builder.SetInsertPoint(failBB);
ctx.builder.CreateCall(prepare_call(jlboundserror_func),
{ mark_callee_rooted(ctx, boxed(ctx, ref)), i });
ctx.builder.CreateUnreachable();
ctx.f->getBasicBlockList().push_back(endBB);
endBB->insertInto(ctx.f);
ctx.builder.SetInsertPoint(endBB);
}
}
Expand Down Expand Up @@ -4119,12 +4119,12 @@ static jl_cgval_t emit_memoryref(jl_codectx_t &ctx, const jl_cgval_t &ref, jl_cg
Value *inbound = ctx.builder.CreateICmpULT(idx0, mlen);
#endif
ctx.builder.CreateCondBr(inbound, endBB, failBB);
ctx.f->getBasicBlockList().push_back(failBB);
failBB->insertInto(ctx.f);
ctx.builder.SetInsertPoint(failBB);
ctx.builder.CreateCall(prepare_call(jlboundserror_func),
{ mark_callee_rooted(ctx, boxed(ctx, ref)), i });
ctx.builder.CreateUnreachable();
ctx.f->getBasicBlockList().push_back(endBB);
endBB->insertInto(ctx.f);
ctx.builder.SetInsertPoint(endBB);
}
}
Expand Down
16 changes: 10 additions & 6 deletions src/clangsa/GCChecker.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This file is a part of Julia. License is MIT: https://julialang.org/license

#include "clang/AST/Type.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/StaticAnalyzer/Checkers/SValExplainer.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
Expand All @@ -14,6 +15,7 @@
#include "clang/Tooling/Tooling.h"
#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"

#include "llvm/Support/Debug.h"
#include <iostream>
#include <memory>

Expand Down Expand Up @@ -894,9 +896,11 @@ bool GCChecker::isSafepoint(const CallEvent &Call, CheckerContext &C) const {
if (!Decl || !FD) {
if (Callee == nullptr) {
isCalleeSafepoint = true;
} else if (const TypedefType *TDT = dyn_cast<TypedefType>(Callee->getType())) {
isCalleeSafepoint =
!declHasAnnotation(TDT->getDecl(), "julia_not_safepoint");
} else if (const ElaboratedType *ET = dyn_cast<ElaboratedType>(Callee->getType())){
if (const TypedefType *TDT = dyn_cast<TypedefType>(ET->getNamedType())) {
isCalleeSafepoint =
!declHasAnnotation(TDT->getDecl(), "julia_not_safepoint");
}
} else if (const CXXPseudoDestructorExpr *PDE =
dyn_cast<CXXPseudoDestructorExpr>(Callee)) {
// A pseudo-destructor is an expression that looks like a member
Expand Down Expand Up @@ -941,7 +945,7 @@ bool GCChecker::processPotentialSafepoint(const CallEvent &Call,
isGCTrackedType(ParmType->getPointeeType())) {
// This is probably an out parameter. Find the value it refers to now.
SVal Loaded =
State->getSVal(Call.getArgSVal(i).getAs<Loc>().getValue());
State->getSVal(*(Call.getArgSVal(i).getAs<Loc>()));
SpeciallyRootedSymbol = Loaded.getAsSymbol();
continue;
}
Expand Down Expand Up @@ -1520,7 +1524,7 @@ bool GCChecker::evalCall(const CallEvent &Call, CheckerContext &C) const {
}
}
if (FD) {
Loc ItemsLoc = State->getLValue(FD, ArrayList).getAs<Loc>().getValue();
Loc ItemsLoc = *(State->getLValue(FD, ArrayList).getAs<Loc>());
SVal Items = State->getSVal(ItemsLoc);
if (Items.isUnknown()) {
Items = C.getSValBuilder().conjureSymbolVal(
Expand Down Expand Up @@ -1688,7 +1692,7 @@ void GCChecker::checkLocation(SVal SLoc, bool IsLoad, const Stmt *S,
// better than this.
if (IsLoad && (RS = State->get<GCRootMap>(SLoc.getAsRegion()))) {
SymbolRef LoadedSym =
State->getSVal(SLoc.getAs<Loc>().getValue()).getAsSymbol();
State->getSVal(*SLoc.getAs<Loc>()).getAsSymbol();
if (LoadedSym) {
const ValueState *ValS = State->get<GCValueMap>(LoadedSym);
if (!ValS || !ValS->isRooted() || ValS->RootDepth > RS->RootedAtDepth) {
Expand Down
50 changes: 34 additions & 16 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ static const auto jl_alloc_obj_func = new JuliaFunction<TypeFnContextAndSizeT>{
FnAttrs.addAllocKindAttr(AllocFnKind::Alloc);
#endif
#if JL_LLVM_VERSION >= 160000
FnAttrs.addMemoryAttr(MemoryEffects::argMemOnly(ModRefInfo::Ref) | inaccessibleMemOnly(ModRefInfo::ModRef));
FnAttrs.addMemoryAttr(MemoryEffects::argMemOnly(ModRefInfo::Ref) | MemoryEffects::inaccessibleMemOnly(ModRefInfo::ModRef));
#endif
FnAttrs.addAttribute(Attribute::WillReturn);
FnAttrs.addAttribute(Attribute::NoUnwind);
Expand Down Expand Up @@ -1314,7 +1314,7 @@ static const auto jl_allocgenericmemory = new JuliaFunction<TypeFnContextAndSize
AttrBuilder FnAttrs(C);
AttrBuilder RetAttrs(C);
#if JL_LLVM_VERSION >= 160000
FnAttrs.addMemoryAttr(MemoryEffects::inaccessibleMemOnly(ModRefInfo::ModRef) | argMemOnly(MemoryEffects::ModRefInfo::Ref));
FnAttrs.addMemoryAttr(MemoryEffects::inaccessibleMemOnly(ModRefInfo::ModRef) | MemoryEffects::argMemOnly(ModRefInfo::Ref));
#endif
FnAttrs.addAttribute(Attribute::WillReturn);
RetAttrs.addAlignmentAttr(Align(16));
Expand Down Expand Up @@ -1423,11 +1423,24 @@ static const auto gc_loaded_func = new JuliaFunction<>{
[](LLVMContext &C) { return FunctionType::get(PointerType::get(JuliaType::get_prjlvalue_ty(C), AddressSpace::Loaded),
{JuliaType::get_prjlvalue_ty(C), PointerType::get(JuliaType::get_prjlvalue_ty(C), 0)}, false); },
[](LLVMContext &C) {
AttributeSet FnAttrs = Attributes(C, {Attribute::ReadNone, Attribute::NoSync, Attribute::NoUnwind, Attribute::Speculatable, Attribute::WillReturn, Attribute::NoRecurse});
AttributeSet RetAttrs = Attributes(C, {Attribute::NonNull, Attribute::NoUndef});
return AttributeList::get(C, FnAttrs, RetAttrs,
AttrBuilder FnAttrs(C);
FnAttrs.addAttribute(Attribute::NoSync);
FnAttrs.addAttribute(Attribute::NoUnwind);
FnAttrs.addAttribute(Attribute::Speculatable);
FnAttrs.addAttribute(Attribute::WillReturn);
FnAttrs.addAttribute(Attribute::NoRecurse);
#if JL_LLVM_VERSION >= 160000
FnAttrs.addMemoryAttr(MemoryEffects::none());
#else
FnAttrs.addAttribute(Attribute::ReadNone);
#endif
AttrBuilder RetAttrs(C);
RetAttrs.addAttribute(Attribute::NonNull);
RetAttrs.addAttribute(Attribute::NoUndef);
return AttributeList::get(C, AttributeSet::get(C,FnAttrs), AttributeSet::get(C,RetAttrs),
{ Attributes(C, {Attribute::NonNull, Attribute::NoUndef, Attribute::ReadNone, Attribute::NoCapture}),
Attributes(C, {Attribute::NonNull, Attribute::NoUndef, Attribute::ReadNone}) }); },
Attributes(C, {Attribute::NonNull, Attribute::NoUndef, Attribute::ReadNone}) });
},
};

// julia.call represents a call with julia calling convention, it is used as
Expand Down Expand Up @@ -3714,11 +3727,11 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
failBB = BasicBlock::Create(ctx.builder.getContext(), "oob");
endBB = BasicBlock::Create(ctx.builder.getContext(), "load");
ctx.builder.CreateCondBr(ctx.builder.CreateIsNull(mlen), failBB, endBB);
ctx.f->getBasicBlockList().push_back(failBB);
failBB->insertInto(ctx.f);
ctx.builder.SetInsertPoint(failBB);
ctx.builder.CreateCall(prepare_call(jlboundserror_func), { mark_callee_rooted(ctx, mem), ConstantInt::get(ctx.types().T_size, 1) });
ctx.builder.CreateUnreachable();
ctx.f->getBasicBlockList().push_back(endBB);
endBB->insertInto(ctx.f);
ctx.builder.SetInsertPoint(endBB);
}
bool isboxed = layout->flags.arrayelem_isboxed;
Expand Down Expand Up @@ -3787,11 +3800,11 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
failBB = BasicBlock::Create(ctx.builder.getContext(), "oob");
endBB = BasicBlock::Create(ctx.builder.getContext(), "load");
ctx.builder.CreateCondBr(ctx.builder.CreateIsNull(mlen), failBB, endBB);
ctx.f->getBasicBlockList().push_back(failBB);
failBB->insertInto(ctx.f);
ctx.builder.SetInsertPoint(failBB);
ctx.builder.CreateCall(prepare_call(jlboundserror_func), { mark_callee_rooted(ctx, mem), ConstantInt::get(ctx.types().T_size, 1) });
ctx.builder.CreateUnreachable();
ctx.f->getBasicBlockList().push_back(endBB);
endBB->insertInto(ctx.f);
ctx.builder.SetInsertPoint(endBB);
}
emit_typecheck(ctx, val, ety, "memoryset");
Expand Down Expand Up @@ -3891,8 +3904,9 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
BasicBlock *passBB, *endBB, *fromBB;
passBB = BasicBlock::Create(ctx.builder.getContext(), "load");
endBB = BasicBlock::Create(ctx.builder.getContext(), "oob");
ctx.f->getBasicBlockList().push_back(passBB);
ctx.f->getBasicBlockList().push_back(endBB);

passBB->insertInto(ctx.f);
endBB->insertInto(ctx.f);
fromBB = ctx.builder.CreateCondBr(oob, endBB, passBB)->getParent();
ctx.builder.SetInsertPoint(endBB);
result = ctx.builder.CreatePHI(getInt1Ty(ctx.builder.getContext()), 2);
Expand Down Expand Up @@ -5286,9 +5300,9 @@ static void emit_phinode_assign(jl_codectx_t &ctx, ssize_t idx, jl_value_t *r)
Instruction *phi = dest->clone();
phi->insertAfter(dest);
PHINode *Tindex_phi = PHINode::Create(getInt8Ty(ctx.builder.getContext()), jl_array_nrows(edges), "tindex_phi");
BB->getInstList().insert(InsertPt, Tindex_phi);
Tindex_phi->insertInto(BB, InsertPt);
PHINode *ptr_phi = PHINode::Create(ctx.types().T_prjlvalue, jl_array_nrows(edges), "ptr_phi");
BB->getInstList().insert(InsertPt, ptr_phi);
ptr_phi->insertInto(BB, InsertPt);
Value *isboxed = ctx.builder.CreateICmpNE(
ctx.builder.CreateAnd(Tindex_phi, ConstantInt::get(getInt8Ty(ctx.builder.getContext()), UNION_BOX_MARKER)),
ConstantInt::get(getInt8Ty(ctx.builder.getContext()), 0));
Expand All @@ -5306,7 +5320,7 @@ static void emit_phinode_assign(jl_codectx_t &ctx, ssize_t idx, jl_value_t *r)
}
else if (allunbox) {
PHINode *Tindex_phi = PHINode::Create(getInt8Ty(ctx.builder.getContext()), jl_array_nrows(edges), "tindex_phi");
BB->getInstList().insert(InsertPt, Tindex_phi);
Tindex_phi->insertInto(BB, InsertPt);
jl_cgval_t val = mark_julia_slot(NULL, phiType, Tindex_phi, ctx.tbaa().tbaa_stack);
ctx.PhiNodes.push_back(std::make_tuple(val, BB, dest, (PHINode*)NULL, r));
ctx.SAvalues[idx] = val;
Expand Down Expand Up @@ -5340,7 +5354,7 @@ static void emit_phinode_assign(jl_codectx_t &ctx, ssize_t idx, jl_value_t *r)
}
else {
value_phi = PHINode::Create(vtype, jl_array_nrows(edges), "value_phi");
BB->getInstList().insert(InsertPt, value_phi);
value_phi->insertInto(BB, InsertPt);
slot = mark_julia_type(ctx, value_phi, isboxed, phiType);
}
ctx.PhiNodes.push_back(std::make_tuple(slot, BB, dest, value_phi, r));
Expand Down Expand Up @@ -9539,6 +9553,8 @@ char jl_using_perf_jitevents = 0;

int jl_is_timing_passes = 0;

int jl_opaque_ptrs_set = 0;

extern "C" void jl_init_llvm(void)
{
jl_page_size = jl_getpagesize();
Expand Down Expand Up @@ -9596,6 +9612,8 @@ extern "C" void jl_init_llvm(void)
clopt = llvmopts.lookup("opaque-pointers");
if (clopt && clopt->getNumOccurrences() == 0) {
clopt->addOccurrence(1, clopt->ArgStr, "false", true);
} else {
jl_opaque_ptrs_set = 1;
}

clopt = llvmopts.lookup("time-passes");
Expand Down