Skip to content

Commit

Permalink
Merge pull request #33389 from JuliaLang/jn/codegengc-cleanup
Browse files Browse the repository at this point in the history
some GCLowering cleanup and add support for FCAs
  • Loading branch information
vtjnash committed Oct 24, 2019
2 parents dbad68d + 3bf20e6 commit 570b508
Show file tree
Hide file tree
Showing 4 changed files with 574 additions and 312 deletions.
11 changes: 11 additions & 0 deletions src/codegen_shared.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// This file is a part of Julia. License is MIT: https://julialang.org/license

#include <utility>
#include <llvm/Support/Debug.h>
#include <llvm/IR/DebugLoc.h>
#include <llvm/IR/IRBuilder.h>

enum AddressSpace {
Generic = 0,
Expand All @@ -17,6 +19,15 @@ enum AddressSpace {
#define JLCALL_F_CC (CallingConv::ID)37 // (jl_value_t *arg0, jl_value_t **argv, uint32_t nargv)
#define JLCALL_F2_CC (CallingConv::ID)38 // (jl_value_t *arg0, jl_value_t **argv, uint32_t nargv, jl_value_t *extra)

// return how many Tracked pointers are in T (count > 0),
// and if there is anything else in T (all == false)
struct CountTrackedPointers {
unsigned count = 0;
bool all = true;
bool derived = false;
CountTrackedPointers(llvm::Type *T);
};

static inline void llvm_dump(llvm::Value *v)
{
v->print(llvm::dbgs(), true);
Expand Down
10 changes: 7 additions & 3 deletions src/llvm-final-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Value *FinalLowerGC::lowerNewGCFrame(CallInst *target, Function &F)
T_prjlvalue,
0,
ConstantInt::get(T_int32, nRoots + 2));
gcframe->setAlignment(16);
gcframe->insertAfter(target);
gcframe->takeName(target);

Expand All @@ -88,17 +89,20 @@ Value *FinalLowerGC::lowerNewGCFrame(CallInst *target, Function &F)
Value *args[4] = {
tempSlot_i8, // dest
ConstantInt::get(Type::getInt8Ty(F.getContext()), 0), // val
ConstantInt::get(T_int32, sizeof(jl_value_t*)*(nRoots+2)), // len
ConstantInt::get(T_int32, sizeof(jl_value_t*) * (nRoots + 2)), // len
ConstantInt::get(Type::getInt1Ty(F.getContext()), 0)}; // volatile
#else
Value *args[5] = {
tempSlot_i8, // dest
ConstantInt::get(Type::getInt8Ty(F.getContext()), 0), // val
ConstantInt::get(T_int32, sizeof(jl_value_t*)*(nRoots+2)), // len
ConstantInt::get(T_int32, 0), // align
ConstantInt::get(T_int32, sizeof(jl_value_t*) * (nRoots + 2)), // len
ConstantInt::get(T_int32, 16), // align
ConstantInt::get(Type::getInt1Ty(F.getContext()), 0)}; // volatile
#endif
CallInst *zeroing = CallInst::Create(memset, makeArrayRef(args));
#if JL_LLVM_VERSION >= 70000
cast<MemSetInst>(zeroing)->setDestAlignment(16);
#endif
zeroing->setMetadata(LLVMContext::MD_tbaa, tbaa_gcframe);
zeroing->insertAfter(tempSlot_i8);

Expand Down
Loading

0 comments on commit 570b508

Please sign in to comment.