Skip to content

Commit

Permalink
[NFC][msan] Prepare function to extract main logic (#94880)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalybuka authored Jun 10, 2024
1 parent be06761 commit 4f41698
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4486,10 +4486,15 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
Value *B = I.getCondition();
Value *C = I.getTrueValue();
Value *D = I.getFalseValue();

Value *Sb = getShadow(B);
Value *Sc = getShadow(C);
Value *Sd = getShadow(D);

Value *Ob = MS.TrackOrigins ? getOrigin(B) : nullptr;
Value *Oc = MS.TrackOrigins ? getOrigin(C) : nullptr;
Value *Od = MS.TrackOrigins ? getOrigin(D) : nullptr;

// Result shadow if condition shadow is 0.
Value *Sa0 = IRB.CreateSelect(B, Sc, Sd);
Value *Sa1;
Expand Down Expand Up @@ -4522,10 +4527,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
}
// a = select b, c, d
// Oa = Sb ? Ob : (b ? Oc : Od)
setOrigin(
&I, IRB.CreateSelect(Sb, getOrigin(I.getCondition()),
IRB.CreateSelect(B, getOrigin(I.getTrueValue()),
getOrigin(I.getFalseValue()))));
setOrigin(&I, IRB.CreateSelect(Sb, Ob, IRB.CreateSelect(B, Oc, Od)));
}
}

Expand Down

0 comments on commit 4f41698

Please sign in to comment.