Skip to content

Commit 5e045a1

Browse files
vchuravyKristofferC
authored andcommitted
[LateLowerGC] Change undef FCA into zeroinit (#43867)
(cherry picked from commit 88b1f92)
1 parent 3582fd7 commit 5e045a1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/llvm-late-gc-lowering.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,6 +2246,18 @@ bool LateLowerGCFrame::CleanupIR(Function &F, State *S) {
22462246
I->setMetadata(LLVMContext::MD_tbaa, MutableTBAA);
22472247
}
22482248
}
2249+
// FCA chains created by SROA start with an undef value
2250+
// if the type contains an tracked pointer that can lead to a partial
2251+
// initialisation and LateLower might have inserted an extractvalue
2252+
// of an undef field. Fix this by changing it to start with an zero-init
2253+
if (auto *IV = dyn_cast<InsertValueInst>(*&it)) {
2254+
Value *SourceAggregate = IV->getAggregateOperand();
2255+
if (isa<UndefValue>(SourceAggregate)) {
2256+
IV->setOperand(IV->getAggregateOperandIndex(), ConstantAggregateZero::get(IV->getType()));
2257+
ChangesMade = true;
2258+
}
2259+
}
2260+
22492261
auto *CI = dyn_cast<CallInst>(&*it);
22502262
if (!CI) {
22512263
++it;

0 commit comments

Comments
 (0)