Skip to content

Commit fe85b4a

Browse files
authored
Merge pull request #33916 from JuliaLang/jn/llvm9-10
llvm: supporting work for using v9 and v10-dev
2 parents ce29ec5 + 4363c55 commit fe85b4a

16 files changed

+225
-262
lines changed

src/ccall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1981,7 +1981,7 @@ jl_cgval_t function_sig_t::emit_a_ccall(
19811981
// ARM and AArch64 can use a LLVM type larger than the julia type.
19821982
// When this happens, cast through memory.
19831983
auto slot = emit_static_alloca(ctx, resultTy);
1984-
slot->setAlignment(boxalign);
1984+
slot->setAlignment(Align(boxalign));
19851985
ctx.builder.CreateAlignedStore(result, slot, boxalign);
19861986
emit_memcpy(ctx, strct, tbaa, slot, tbaa, rtsz, boxalign, tbaa);
19871987
}

src/cgutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2265,7 +2265,7 @@ static AllocaInst *try_emit_union_alloca(jl_codectx_t &ctx, jl_uniontype_t *ut,
22652265
Type *AT = ArrayType::get(IntegerType::get(jl_LLVMContext, 8 * min_align), (nbytes + min_align - 1) / min_align);
22662266
AllocaInst *lv = emit_static_alloca(ctx, AT);
22672267
if (align > 1)
2268-
lv->setAlignment(align);
2268+
lv->setAlignment(Align(align));
22692269
return lv;
22702270
}
22712271
return NULL;

src/clangsa/GCChecker.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
#else
1818
#include "clang/StaticAnalyzer/Core/CheckerRegistry.h"
1919
#endif
20+
2021
#include <iostream>
22+
#include <memory>
2123

2224
#if defined(__GNUC__)
2325
# define USED_FUNC __attribute__((used))
@@ -28,12 +30,18 @@
2830
# define USED_FUNC
2931
#endif
3032

33+
#if LLVM_VERSION_MAJOR >= 10
34+
using std::make_unique;
35+
#else
36+
using llvm::make_unique;
37+
#endif
38+
3139
namespace {
3240
using namespace clang;
3341
using namespace ento;
3442

3543
#define PDP std::shared_ptr<PathDiagnosticPiece>
36-
#define MakePDP llvm::make_unique<PathDiagnosticEventPiece>
44+
#define MakePDP make_unique<PathDiagnosticEventPiece>
3745

3846
class GCChecker : public Checker<eval::Call,
3947
check::BeginFunction,
@@ -387,13 +395,13 @@ PDP GCChecker::GCValueBugVisitor::ExplainNoPropagationFromExpr(const clang::Expr
387395
const ValueState *ValS = N->getState()->get<GCValueMap>(Parent);
388396
assert(ValS);
389397
if (ValS->isPotentiallyFreed()) {
390-
BR.addVisitor(llvm::make_unique<GCValueBugVisitor>(Parent));
398+
BR.addVisitor(make_unique<GCValueBugVisitor>(Parent));
391399
return MakePDP(Pos, "Root not propagated because it may have been freed. Tracking.");
392400
} else if (ValS->isRooted()) {
393-
BR.addVisitor(llvm::make_unique<GCValueBugVisitor>(Parent));
401+
BR.addVisitor(make_unique<GCValueBugVisitor>(Parent));
394402
return MakePDP(Pos, "Root was not propagated due to a bug. Tracking base value.");
395403
} else {
396-
BR.addVisitor(llvm::make_unique<GCValueBugVisitor>(Parent));
404+
BR.addVisitor(make_unique<GCValueBugVisitor>(Parent));
397405
return MakePDP(Pos, "No Root to propagate. Tracking.");
398406
}
399407
}
@@ -506,8 +514,8 @@ void GCChecker::report_error(callback f, CheckerContext &C, const char *message)
506514
if (!BT)
507515
BT.reset(new BugType(this, "Invalid GC thingy",
508516
categories::LogicError));
509-
auto Report = llvm::make_unique<BugReport>(*BT, message, N);
510-
Report->addVisitor(llvm::make_unique<GCBugVisitor>());
517+
auto Report = make_unique<BugReport>(*BT, message, N);
518+
Report->addVisitor(make_unique<GCBugVisitor>());
511519
f(Report.get());
512520
C.emitReport(std::move(Report));
513521
}
@@ -522,10 +530,10 @@ void GCChecker::report_value_error(CheckerContext &C, SymbolRef Sym, const char
522530
if (!BT)
523531
BT.reset(new BugType(this, "Invalid GC thingy",
524532
categories::LogicError));
525-
auto Report = llvm::make_unique<BugReport>(*BT, message, N);
526-
Report->addVisitor(llvm::make_unique<GCValueBugVisitor>(Sym));
527-
Report->addVisitor(llvm::make_unique<GCBugVisitor>());
528-
Report->addVisitor(llvm::make_unique<ConditionBRVisitor>());
533+
auto Report = make_unique<BugReport>(*BT, message, N);
534+
Report->addVisitor(make_unique<GCValueBugVisitor>(Sym));
535+
Report->addVisitor(make_unique<GCBugVisitor>());
536+
Report->addVisitor(make_unique<ConditionBRVisitor>());
529537
if (!range.isInvalid()) {
530538
Report->addRange(range);
531539
}

src/codegen.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2701,7 +2701,7 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
27012701
ConstantAsMetadata::get(ConstantInt::get(T_int8, union_max)) }));
27022702
AllocaInst *lv = emit_static_alloca(ctx, AT);
27032703
if (al > 1)
2704-
lv->setAlignment(al);
2704+
lv->setAlignment(Align(al));
27052705
emit_memcpy(ctx, lv, tbaa_arraybuf, ctx.builder.CreateInBoundsGEP(AT, data, idx), tbaa_arraybuf, elsz, al, false);
27062706
*ret = mark_julia_slot(lv, ety, ctx.builder.CreateNUWAdd(ConstantInt::get(T_int8, 1), tindex), tbaa_arraybuf);
27072707
}
@@ -3156,7 +3156,7 @@ static jl_cgval_t emit_call_specfun_other(jl_codectx_t &ctx, jl_code_instance_t
31563156
case jl_returninfo_t::Union:
31573157
result = emit_static_alloca(ctx, ArrayType::get(T_int8, returninfo.union_bytes));
31583158
if (returninfo.union_align > 1)
3159-
result->setAlignment(returninfo.union_align);
3159+
result->setAlignment(Align(returninfo.union_align));
31603160
argvals[idx] = result;
31613161
idx++;
31623162
break;
@@ -3564,18 +3564,16 @@ static jl_cgval_t emit_varinfo(jl_codectx_t &ctx, jl_varinfo_t &vi, jl_sym_t *va
35643564
AllocaInst *varslot = cast<AllocaInst>(vi.value.V);
35653565
Type *T = varslot->getAllocatedType();
35663566
assert(!varslot->isArrayAllocation() && "variables not expected to be VLA");
3567-
AllocaInst *ssaslot = emit_static_alloca(ctx, T);
3568-
unsigned al = varslot->getAlignment();
3569-
if (al)
3570-
ssaslot->setAlignment(al);
3567+
AllocaInst *ssaslot = cast<AllocaInst>(varslot->clone());
3568+
ssaslot->insertAfter(varslot);
35713569
if (vi.isVolatile) {
35723570
Value *unbox = ctx.builder.CreateLoad(vi.value.V, true);
35733571
ctx.builder.CreateStore(unbox, ssaslot);
35743572
}
35753573
else {
35763574
const DataLayout &DL = jl_data_layout;
35773575
uint64_t sz = DL.getTypeStoreSize(T);
3578-
emit_memcpy(ctx, ssaslot, tbaa_stack, vi.value, sz, al);
3576+
emit_memcpy(ctx, ssaslot, tbaa_stack, vi.value, sz, ssaslot->getAlignment());
35793577
}
35803578
Value *tindex = NULL;
35813579
if (vi.pTIndex)
@@ -5253,7 +5251,7 @@ static Function *gen_invoke_wrapper(jl_method_instance_t *lam, jl_value_t *jlret
52535251
case jl_returninfo_t::Union:
52545252
result = ctx.builder.CreateAlloca(ArrayType::get(T_int8, f.union_bytes));
52555253
if (f.union_align > 1)
5256-
result->setAlignment(f.union_align);
5254+
result->setAlignment(Align(f.union_align));
52575255
args[idx] = result;
52585256
idx++;
52595257
break;
@@ -5708,7 +5706,7 @@ static std::unique_ptr<Module> emit_function(
57085706

57095707
if (returninfo.cc == jl_returninfo_t::Union) {
57105708
f->addAttribute(1, Attribute::getWithDereferenceableBytes(jl_LLVMContext, returninfo.union_bytes));
5711-
f->addAttribute(1, Attribute::getWithAlignment(jl_LLVMContext, returninfo.union_align));
5709+
f->addAttribute(1, Attribute::getWithAlignment(jl_LLVMContext, Align(returninfo.union_align)));
57125710
}
57135711

57145712
#ifdef JL_DEBUG_BUILD

0 commit comments

Comments
 (0)