@@ -919,12 +919,11 @@ void make_anywhere_function(
919
919
// writes pointers to gc_roots prior to garbage collection
920
920
static void store_ptrs_for_gc (
921
921
unsigned nroots, llvm::Module *module , llvm::Type *root_ty,
922
- llvm::Constant *arr, llvm::Instruction *are_block_val ,
923
- llvm::BasicBlock *collect, std::vector<llvm::Value *> const &roots,
922
+ llvm::Constant *arr, llvm::BasicBlock *collect ,
923
+ std::vector<llvm::Value *> const &roots,
924
924
std::vector<value_type> const &types,
925
925
std::vector<llvm::Type *> const &ptr_types,
926
- std::vector<std::pair<llvm::Value *, llvm::Type *>> &root_ptrs,
927
- std::vector<llvm::Value *> &are_block) {
926
+ std::vector<std::pair<llvm::Value *, llvm::Type *>> &root_ptrs) {
928
927
auto *zero
929
928
= llvm::ConstantInt::get (llvm::Type::getInt64Ty (module ->getContext ()), 0 );
930
929
llvm::Type *voidptrptr = llvm::PointerType::getUnqual (
@@ -935,87 +934,48 @@ static void store_ptrs_for_gc(
935
934
{zero, llvm::ConstantInt::get (
936
935
llvm::Type::getInt64Ty (module ->getContext ()), i)},
937
936
" " , collect);
938
- llvm::Value *is_block = nullptr ;
939
- llvm::Value *are_block_ptr = nullptr ;
940
937
switch (types[i].cat ) {
941
938
case sort_category::Map:
942
- is_block = llvm::CallInst::Create (
939
+ llvm::CallInst::Create (
943
940
get_or_insert_function (
944
941
module , " store_map_for_gc" ,
945
942
llvm::Type::getInt1Ty (module ->getContext ()), voidptrptr,
946
943
ptr_types[i]),
947
- {ptr, roots[i]}, " is_block" , collect);
948
- are_block_ptr = llvm::GetElementPtrInst::CreateInBounds (
949
- llvm::Type::getInt1Ty (module ->getContext ()), are_block_val,
950
- {llvm::ConstantInt::get (
951
- llvm::Type::getInt64Ty (module ->getContext ()), i)},
952
- " " , collect);
953
- new llvm::StoreInst (is_block, are_block_ptr, collect);
944
+ {ptr, roots[i]}, " " , collect);
954
945
root_ptrs.emplace_back (ptr, ptr_types[i]);
955
- are_block.push_back (is_block);
956
946
break ;
957
947
case sort_category::RangeMap:
958
- is_block = llvm::CallInst::Create (
948
+ llvm::CallInst::Create (
959
949
get_or_insert_function (
960
950
module , " store_rangemap_for_gc" ,
961
951
llvm::Type::getInt1Ty (module ->getContext ()), voidptrptr,
962
952
ptr_types[i]),
963
- {ptr, roots[i]}, " is_block" , collect);
964
- are_block_ptr = llvm::GetElementPtrInst::CreateInBounds (
965
- llvm::Type::getInt1Ty (module ->getContext ()), are_block_val,
966
- {llvm::ConstantInt::get (
967
- llvm::Type::getInt64Ty (module ->getContext ()), i)},
968
- " " , collect);
969
- new llvm::StoreInst (is_block, are_block_ptr, collect);
953
+ {ptr, roots[i]}, " " , collect);
970
954
root_ptrs.emplace_back (ptr, ptr_types[i]);
971
- are_block.push_back (is_block);
972
955
break ;
973
956
case sort_category::List:
974
- is_block = llvm::CallInst::Create (
957
+ llvm::CallInst::Create (
975
958
get_or_insert_function (
976
959
module , " store_list_for_gc" ,
977
960
llvm::Type::getInt1Ty (module ->getContext ()), voidptrptr,
978
961
ptr_types[i]),
979
- {ptr, roots[i]}, " is_block" , collect);
980
- are_block_ptr = llvm::GetElementPtrInst::CreateInBounds (
981
- llvm::Type::getInt1Ty (module ->getContext ()), are_block_val,
982
- {llvm::ConstantInt::get (
983
- llvm::Type::getInt64Ty (module ->getContext ()), i)},
984
- " " , collect);
985
- new llvm::StoreInst (is_block, are_block_ptr, collect);
962
+ {ptr, roots[i]}, " " , collect);
986
963
root_ptrs.emplace_back (ptr, ptr_types[i]);
987
- are_block.push_back (is_block);
988
964
break ;
989
965
case sort_category::Set:
990
- is_block = llvm::CallInst::Create (
966
+ llvm::CallInst::Create (
991
967
get_or_insert_function (
992
968
module , " store_set_for_gc" ,
993
969
llvm::Type::getInt1Ty (module ->getContext ()), voidptrptr,
994
970
ptr_types[i]),
995
- {ptr, roots[i]}, " is_block" , collect);
996
- are_block_ptr = llvm::GetElementPtrInst::CreateInBounds (
997
- llvm::Type::getInt1Ty (module ->getContext ()), are_block_val,
998
- {llvm::ConstantInt::get (
999
- llvm::Type::getInt64Ty (module ->getContext ()), i)},
1000
- " " , collect);
1001
- new llvm::StoreInst (is_block, are_block_ptr, " " , collect);
971
+ {ptr, roots[i]}, " " , collect);
1002
972
root_ptrs.emplace_back (ptr, ptr_types[i]);
1003
- are_block.push_back (is_block);
1004
973
break ;
1005
974
default :
1006
975
auto *casted = new llvm::BitCastInst (
1007
976
ptr, llvm::PointerType::getUnqual (ptr_types[i]), " " , collect);
1008
977
new llvm::StoreInst (roots[i], casted, collect);
1009
- are_block_ptr = llvm::GetElementPtrInst::CreateInBounds (
1010
- llvm::Type::getInt1Ty (module ->getContext ()), are_block_val,
1011
- {llvm::ConstantInt::get (
1012
- llvm::Type::getInt64Ty (module ->getContext ()), i)},
1013
- " " , collect);
1014
- new llvm::StoreInst (
1015
- llvm::ConstantInt::getFalse (module ->getContext ()), are_block_ptr, " " ,
1016
- collect);
1017
978
root_ptrs.emplace_back (casted, ptr_types[i]);
1018
- are_block.push_back (nullptr );
1019
979
break ;
1020
980
}
1021
981
}
@@ -1028,8 +988,7 @@ static void load_ptrs_for_gc(
1028
988
llvm::BasicBlock *collect, llvm::BasicBlock *merge,
1029
989
std::vector<llvm::Value *> &phis, std::vector<llvm::Value *> const &roots,
1030
990
std::vector<std::pair<llvm::Value *, llvm::Type *>> const &root_ptrs,
1031
- std::vector<value_type> const &types,
1032
- std::vector<llvm::Value *> const &are_block) {
991
+ std::vector<value_type> const &types) {
1033
992
llvm::Type *voidptrptr = llvm::PointerType::getUnqual (
1034
993
llvm::PointerType::getUnqual (module ->getContext ()));
1035
994
unsigned i = 0 ;
@@ -1041,28 +1000,28 @@ static void load_ptrs_for_gc(
1041
1000
get_or_insert_function (
1042
1001
module , " load_map_for_gc" , pointee_ty, voidptrptr,
1043
1002
llvm::Type::getInt1Ty (module ->getContext ())),
1044
- {ptr, are_block[i] }, " " , collect);
1003
+ {ptr}, " " , collect);
1045
1004
break ;
1046
1005
case sort_category::RangeMap:
1047
1006
loaded = llvm::CallInst::Create (
1048
1007
get_or_insert_function (
1049
1008
module , " load_rangemap_for_gc" , pointee_ty, voidptrptr,
1050
1009
llvm::Type::getInt1Ty (module ->getContext ())),
1051
- {ptr, are_block[i] }, " " , collect);
1010
+ {ptr}, " " , collect);
1052
1011
break ;
1053
1012
case sort_category::List:
1054
1013
loaded = llvm::CallInst::Create (
1055
1014
get_or_insert_function (
1056
1015
module , " load_list_for_gc" , pointee_ty, voidptrptr,
1057
1016
llvm::Type::getInt1Ty (module ->getContext ())),
1058
- {ptr, are_block[i] }, " " , collect);
1017
+ {ptr}, " " , collect);
1059
1018
break ;
1060
1019
case sort_category::Set:
1061
1020
loaded = llvm::CallInst::Create (
1062
1021
get_or_insert_function (
1063
1022
module , " load_set_for_gc" , pointee_ty, voidptrptr,
1064
1023
llvm::Type::getInt1Ty (module ->getContext ())),
1065
- {ptr, are_block[i] }, " " , collect);
1024
+ {ptr}, " " , collect);
1066
1025
break ;
1067
1026
default : loaded = new llvm::LoadInst (pointee_ty, ptr, " " , collect);
1068
1027
}
@@ -1133,18 +1092,10 @@ std::pair<std::vector<llvm::Value *>, llvm::BasicBlock *> step_function_header(
1133
1092
llvm::PointerType::getUnqual (module ->getContext ()), 256 );
1134
1093
auto *arr = module ->getOrInsertGlobal (" gc_roots" , root_ty);
1135
1094
std::vector<std::pair<llvm::Value *, llvm::Type *>> root_ptrs;
1136
- std::vector<llvm::Value *> are_block;
1137
- auto *are_block_val = create_malloc (
1138
- collect, llvm::Type::getInt64Ty (block->getContext ()),
1139
- llvm::Type::getInt1Ty (module ->getContext ()),
1140
- llvm::ConstantInt::get (llvm::Type::getInt64Ty (module ->getContext ()), 1 ),
1141
- llvm::ConstantInt::get (
1142
- llvm::Type::getInt64Ty (module ->getContext ()), nroots),
1143
- nullptr );
1144
1095
1145
1096
store_ptrs_for_gc (
1146
- nroots, module , root_ty, arr, are_block_val, collect, roots, types,
1147
- ptr_types, root_ptrs, are_block );
1097
+ nroots, module , root_ty, arr, collect, roots, types, ptr_types ,
1098
+ root_ptrs);
1148
1099
std::vector<llvm::Constant *> elements;
1149
1100
i = 0 ;
1150
1101
for (auto cat : types) {
@@ -1199,13 +1150,12 @@ std::pair<std::vector<llvm::Value *>, llvm::BasicBlock *> step_function_header(
1199
1150
{arr,
1200
1151
llvm::ConstantInt::get (
1201
1152
llvm::Type::getInt8Ty (module ->getContext ()), nroots),
1202
- llvm::ConstantExpr::getBitCast (layout, ptr_ty), are_block_val },
1153
+ llvm::ConstantExpr::getBitCast (layout, ptr_ty)},
1203
1154
" " , collect);
1204
1155
set_debug_loc (call);
1205
1156
std::vector<llvm::Value *> phis;
1206
1157
load_ptrs_for_gc (
1207
- module , check_collect, collect, merge, phis, roots, root_ptrs, types,
1208
- are_block);
1158
+ module , check_collect, collect, merge, phis, roots, root_ptrs, types);
1209
1159
llvm::BranchInst::Create (merge, collect);
1210
1160
i = 0 ;
1211
1161
unsigned root_idx = 0 ;
0 commit comments