@@ -326,24 +326,19 @@ static llvm::Value *get_arg_value(
326
326
case sort_category::Bool:
327
327
case sort_category::MInt: {
328
328
auto *val_ty = getvalue_type (cat, mod);
329
- auto *cast = new llvm::BitCastInst (arg, ptr_ty, " " , case_block);
330
- auto *load = new llvm::LoadInst (val_ty, cast, " " , case_block);
329
+ auto *load = new llvm::LoadInst (val_ty, arg, " " , case_block);
331
330
arg = load;
332
331
break ;
333
332
}
334
333
case sort_category::Map:
335
334
case sort_category::RangeMap:
336
335
case sort_category::List:
337
336
case sort_category::Set:
338
- arg = new llvm::BitCastInst (arg, ptr_ty, " " , case_block);
339
- break ;
340
337
case sort_category::Int:
341
338
case sort_category::Float:
342
339
case sort_category::StringBuffer:
343
340
case sort_category::Symbol:
344
- case sort_category::Variable:
345
- arg = new llvm::BitCastInst (arg, getvalue_type (cat, mod), " " , case_block);
346
- break ;
341
+ case sort_category::Variable: break ;
347
342
case sort_category::MapIter:
348
343
case sort_category::SetIter:
349
344
case sort_category::Uncomputed: abort ();
@@ -386,19 +381,15 @@ static std::pair<llvm::Value *, llvm::BasicBlock *> get_eval(
386
381
case sort_category::Map:
387
382
case sort_category::RangeMap:
388
383
case sort_category::List:
389
- case sort_category::Set:
390
- retval = new llvm::BitCastInst (
391
- result, ptr_ty, " " , creator.get_current_block ());
392
- break ;
384
+ case sort_category::Set: retval = result; break ;
393
385
case sort_category::Bool:
394
386
case sort_category::MInt: {
395
387
auto *malloc = create_malloc (
396
388
creator.get_current_block (),
397
389
llvm::ConstantExpr::getSizeOf (result->getType ()),
398
390
get_or_insert_function (mod, " malloc" , ptr_ty, ptr_ty));
399
391
new llvm::StoreInst (result, malloc, creator.get_current_block ());
400
- retval = new llvm::BitCastInst (
401
- malloc, ptr_ty, " " , creator.get_current_block ());
392
+ retval = malloc;
402
393
break ;
403
394
}
404
395
case sort_category::MapIter:
@@ -554,8 +545,7 @@ static void emit_get_token(kore_definition *definition, llvm::Module *module) {
554
545
case_block, llvm::ConstantExpr::getSizeOf (compare->getType ()),
555
546
get_or_insert_function (module , " malloc" , ptr_ty, ptr_ty));
556
547
new llvm::StoreInst (compare, malloc, case_block);
557
- auto *result = new llvm::BitCastInst (malloc, ptr_ty, " " , case_block);
558
- phi->addIncoming (result, case_block);
548
+ phi->addIncoming (malloc, case_block);
559
549
llvm::BranchInst::Create (merge_block, case_block);
560
550
break ;
561
551
}
@@ -568,8 +558,7 @@ static void emit_get_token(kore_definition *definition, llvm::Module *module) {
568
558
module , " init_float" , llvm::Type::getVoidTy (ctx), ptr_ty, ptr_ty);
569
559
llvm::CallInst::Create (
570
560
init_float, {term, func->arg_begin () + 2 }, " " , case_block);
571
- auto *cast = new llvm::BitCastInst (term, ptr_ty, " " , case_block);
572
- phi->addIncoming (cast, case_block);
561
+ phi->addIncoming (term, case_block);
573
562
llvm::BranchInst::Create (merge_block, case_block);
574
563
break ;
575
564
}
@@ -611,9 +600,8 @@ static void emit_get_token(kore_definition *definition, llvm::Module *module) {
611
600
*case_block, llvm::CmpInst::ICMP_EQ, call, zero32);
612
601
auto *abort_block = llvm::BasicBlock::Create (ctx, " invalid_int" , func);
613
602
add_abort (abort_block, module );
614
- auto *cast = new llvm::BitCastInst (term, ptr_ty, " " , case_block);
615
603
llvm::BranchInst::Create (merge_block, abort_block, icmp, case_block);
616
- phi->addIncoming (cast , case_block);
604
+ phi->addIncoming (term , case_block);
617
605
break ;
618
606
}
619
607
case sort_category::Variable:
@@ -661,9 +649,8 @@ static void emit_get_token(kore_definition *definition, llvm::Module *module) {
661
649
llvm::CallInst::Create (
662
650
memcpy, {str_ptr, func->arg_begin () + 2 , func->arg_begin () + 1 }, " " ,
663
651
current_block);
664
- auto *cast = new llvm::BitCastInst (block, ptr_ty, " " , current_block);
665
652
llvm::BranchInst::Create (merge_block, current_block);
666
- phi->addIncoming (cast , current_block);
653
+ phi->addIncoming (block , current_block);
667
654
llvm::ReturnInst::Create (ctx, phi, merge_block);
668
655
merge_block->insertInto (func);
669
656
}
@@ -777,16 +764,14 @@ static void get_store(
777
764
llvm::Value *arguments_array = func->arg_begin () + 1 ;
778
765
int idx = 0 ;
779
766
auto *block_type = get_block_type (module , definition, symbol);
780
- auto *cast = new llvm::BitCastInst (
781
- func->arg_begin (), llvm::PointerType::getUnqual (ctx), " " , case_block);
782
767
for (auto const &sort : symbol->get_arguments ()) {
783
768
value_type cat = dynamic_cast <kore_composite_sort *>(sort.get ())
784
769
->get_category (definition);
785
770
llvm::Value *arg
786
771
= get_arg_value (arguments_array, idx, case_block, cat, module );
787
772
llvm::Type *arg_ty = get_arg_type (cat, module );
788
773
llvm::Value *child_ptr = llvm::GetElementPtrInst::CreateInBounds (
789
- block_type, cast ,
774
+ block_type, func-> arg_begin () ,
790
775
{zero, llvm::ConstantInt::get (
791
776
llvm::Type::getInt32Ty (ctx),
792
777
get_block_offset (definition, symbol, idx++))},
@@ -896,7 +881,6 @@ static void get_visitor(
896
881
llvm::Function *func = case_block->getParent ();
897
882
int idx = 0 ;
898
883
auto *block_type = get_block_type (module , definition, symbol);
899
- auto *cast = new llvm::BitCastInst (func->arg_begin (), ptr_ty, " " , case_block);
900
884
unsigned i = 0 ;
901
885
902
886
auto *state_ptr = func->arg_end () - 1 ;
@@ -905,7 +889,7 @@ static void get_visitor(
905
889
auto *composite_sort = dynamic_cast <kore_composite_sort *>(sort.get ());
906
890
value_type cat = composite_sort->get_category (definition);
907
891
llvm::Value *child_ptr = llvm::GetElementPtrInst::CreateInBounds (
908
- block_type, cast ,
892
+ block_type, func-> arg_begin () ,
909
893
{zero, llvm::ConstantInt::get (
910
894
llvm::Type::getInt32Ty (ctx),
911
895
get_block_offset (definition, symbol, idx++))},
0 commit comments