Skip to content

Commit 86f709c

Browse files
authored
[ESIMD] Follow-up fix for ESIMDOptimizeVecArgCallConv memory corruption. (#6908)
#6557 rolled back necessary code, return it back with this patch. Problem somehow reproduced only in internal debug Windows build - the SYCLLowerIR/ESIMD/vec_arg_call_conv.ll test crashed opt. Signed-off-by: Konstantin S Bobrovsky <[email protected]>
1 parent 6b83ad7 commit 86f709c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

llvm/lib/SYCLLowerIR/ESIMD/ESIMDOptimizeVecArgCallConv.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,13 @@ static bool processFunction(Function *F) {
476476
// Optimize the function.
477477
Function *NewF = optimizeFunction(F, OptimizeableParams, NewParamTs);
478478

479+
// Copy users to a separate container, to enable safe eraseFromParent
480+
// within optimizeCall.
481+
SmallVector<User *> FUsers;
482+
std::copy(F->users().begin(), F->users().end(), std::back_inserter(FUsers));
483+
479484
// Optimize calls to the function.
480-
for (auto *U : F->users()) {
485+
for (auto *U : FUsers) {
481486
auto *Call = cast<CallInst>(U);
482487
assert(Call->getCalledFunction() == F);
483488
optimizeCall(Call, NewF, OptimizeableParams);

0 commit comments

Comments
 (0)