Skip to content

Commit

Permalink
[LateLowerGC] Change undef FCA into zeroinit (JuliaLang#43867)
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy authored and LilithHafner committed Mar 8, 2022
1 parent 2263840 commit 5963905
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/llvm-late-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2258,6 +2258,18 @@ bool LateLowerGCFrame::CleanupIR(Function &F, State *S) {
I->setMetadata(LLVMContext::MD_tbaa, MutableTBAA);
}
}
// FCA chains created by SROA start with an undef value
// if the type contains an tracked pointer that can lead to a partial
// initialisation and LateLower might have inserted an extractvalue
// of an undef field. Fix this by changing it to start with an zero-init
if (auto *IV = dyn_cast<InsertValueInst>(*&it)) {
Value *SourceAggregate = IV->getAggregateOperand();
if (isa<UndefValue>(SourceAggregate)) {
IV->setOperand(IV->getAggregateOperandIndex(), ConstantAggregateZero::get(IV->getType()));
ChangesMade = true;
}
}

auto *CI = dyn_cast<CallInst>(&*it);
if (!CI) {
++it;
Expand Down

0 comments on commit 5963905

Please sign in to comment.