Skip to content

Commit

Permalink
[VPlan] Fix stack-use-after-scope in VPInstruction::generate (NFC).
Browse files Browse the repository at this point in the history
Fix stack-use-after-scope introduced in 0678e20 by pulling out
the vector to a dedicated variable.

Should fix ASan/MSan failures, including
https://lab.llvm.org/buildbot/#/builders/169/builds/6111.
  • Loading branch information
fhahn committed Dec 6, 2024
1 parent a46ee73 commit 1091fad
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,8 @@ Value *VPInstruction::generate(VPTransformState &State) {
NewPhi->addIncoming(IncomingFromVPlanPred, VPlanPred);
// TODO: Predecessors are temporarily reversed to reduce test changes.
// Remove it and update remaining tests after functional change landed.
for (auto *OtherPred :

This comment has been minimized.

Copy link
@ayalz

ayalz Dec 6, 2024

Collaborator

Just for completeness (reversal is temporary): a reverse iterator over the predecessors could have been used instead.

reverse(to_vector(predecessors(Builder.GetInsertBlock())))) {
auto Predecessors = to_vector(predecessors(Builder.GetInsertBlock()));
for (auto *OtherPred : reverse(Predecessors)) {
assert(OtherPred != VPlanPred &&
"VPlan predecessors should not be connected yet");
NewPhi->addIncoming(IncomingFromOtherPreds, OtherPred);
Expand Down

0 comments on commit 1091fad

Please sign in to comment.