@@ -42,6 +42,8 @@ class JuliaGCAllocator {
42
42
JuliaGCAllocator (CallInst *ptlsStates, Type *T_pjlvalue, MDNode *tbaa) :
43
43
F (*ptlsStates->getParent ()->getParent()),
44
44
M(*F.getParent()),
45
+ T_int1(Type::getInt1Ty(F.getContext())),
46
+ T_int8(Type::getInt8Ty(F.getContext())),
45
47
T_int32(Type::getInt32Ty(F.getContext())),
46
48
T_int64(Type::getInt64Ty(F.getContext())),
47
49
V_null(Constant::getNullValue(T_pjlvalue)),
@@ -69,6 +71,8 @@ class JuliaGCAllocator {
69
71
private:
70
72
Function &F;
71
73
Module &M;
74
+ Type *const T_int1;
75
+ Type *const T_int8;
72
76
Type *const T_int32;
73
77
Type *const T_int64;
74
78
Value *const V_null;
@@ -784,13 +788,16 @@ void allocate_frame()
784
788
}
785
789
else {
786
790
// Initialize the slots for temporary variables to NULL
787
- for (unsigned i = 0 ; i < maxDepth; i++) {
788
- Instruction *argTempi = GetElementPtrInst::Create (LLVM37_param (NULL ) tempSlot, ArrayRef<Value*>(ConstantInt::get (T_int32, i)));
789
- argTempi->insertAfter (last_gcframe_inst);
790
- StoreInst *store = new StoreInst (V_null, argTempi);
791
- store->setMetadata (llvm::LLVMContext::MD_tbaa, tbaa_gcframe);
792
- store->insertAfter (argTempi);
793
- last_gcframe_inst = store;
791
+ if (maxDepth > 0 ) {
792
+ BitCastInst *tempSlot_i8 = new BitCastInst (tempSlot, PointerType::get (T_int8, 0 ), " " , last_gcframe_inst);
793
+ CallInst *zeroing =
794
+ CallInst::Create (Intrinsic::getDeclaration (&M, Intrinsic::memset , {tempSlot_i8->getType (), T_int32}),
795
+ {tempSlot_i8, ConstantInt::get (T_int8, 0 ),
796
+ ConstantInt::get (T_int32, sizeof (jl_value_t *)*maxDepth),
797
+ ConstantInt::get (T_int32, 0 ), ConstantInt::get (T_int1, 0 )});
798
+ zeroing->setMetadata (llvm::LLVMContext::MD_tbaa, tbaa_gcframe);
799
+ zeroing->insertAfter (tempSlot_i8);
800
+ last_gcframe_inst = zeroing;
794
801
}
795
802
796
803
gcframe->setOperand (0 , ConstantInt::get (T_int32, 2 + argSpaceSize + maxDepth)); // fix up the size of the gc frame
0 commit comments