File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -6547,6 +6547,7 @@ static std::unique_ptr<Module> emit_function(
6547
6547
6548
6548
// Codegen Phi nodes
6549
6549
std::map<BasicBlock *, BasicBlock*> BB_rewrite_map;
6550
+ std::vector<llvm::PHINode*> ToDelete;
6550
6551
for (auto &tup : ctx.PhiNodes ) {
6551
6552
jl_cgval_t phi_result;
6552
6553
PHINode *VN;
@@ -6724,6 +6725,16 @@ static std::unique_ptr<Module> emit_function(
6724
6725
}
6725
6726
}
6726
6727
}
6728
+ // In LLVM IR it is illegal to have phi nodes without incoming values, even if
6729
+ // there are no operands, so delete any such phi nodes
6730
+ if (pred_begin (PhiBB) == pred_end (PhiBB))
6731
+ {
6732
+ if (VN)
6733
+ ToDelete.push_back (VN);
6734
+ if (TindexN)
6735
+ ToDelete.push_back (TindexN);
6736
+ continue ;
6737
+ }
6727
6738
// Julia PHINodes may be incomplete with respect to predecessors, LLVM's may not
6728
6739
Value *VNUndef = nullptr ;
6729
6740
for (auto *pred : predecessors (PhiBB)) {
@@ -6748,6 +6759,11 @@ static std::unique_ptr<Module> emit_function(
6748
6759
}
6749
6760
}
6750
6761
6762
+ for (PHINode *PN : ToDelete) {
6763
+ PN->replaceAllUsesWith (UndefValue::get (PN->getType ()));
6764
+ PN->eraseFromParent ();
6765
+ }
6766
+
6751
6767
UndefAlloca->setOperand (0 , ConstantInt::get (T_size, undef_alloca_bytes));
6752
6768
UndefAlloca->setAlignment (undef_alloca_align);
6753
6769
You can’t perform that action at this time.
0 commit comments