Skip to content

Commit aff896d

Browse files
committed
[NFC][MSAN] Extract llvm.abs handling into a function
Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D88519
1 parent 14f6bfc commit aff896d

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2638,12 +2638,6 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
26382638
return false;
26392639

26402640
unsigned NumArgOperands = I.getNumArgOperands();
2641-
if (I.getIntrinsicID() == Intrinsic::abs) {
2642-
assert(NumArgOperands == 2);
2643-
// The last argument is just a boolean flag.
2644-
NumArgOperands = 1;
2645-
}
2646-
26472641
for (unsigned i = 0; i < NumArgOperands; ++i) {
26482642
Type *Ty = I.getArgOperand(i)->getType();
26492643
if (Ty != RetTy)
@@ -3236,8 +3230,24 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
32363230
setOriginForNaryOp(I);
32373231
}
32383232

3233+
// Instrument abs intrinsic.
3234+
// handleUnknownIntrinsic can't handle it because of the last
3235+
// is_int_min_poison argument which does not match the result type.
3236+
void handleAbsIntrinsic(IntrinsicInst &I) {
3237+
assert(I.getType()->isIntOrIntVectorTy());
3238+
assert(I.getArgOperand(0)->getType() == I.getType());
3239+
3240+
// FIXME: Handle is_int_min_poison.
3241+
IRBuilder<> IRB(&I);
3242+
setShadow(&I, getShadow(&I, 0));
3243+
setOrigin(&I, getOrigin(&I, 0));
3244+
}
3245+
32393246
void visitIntrinsicInst(IntrinsicInst &I) {
32403247
switch (I.getIntrinsicID()) {
3248+
case Intrinsic::abs:
3249+
handleAbsIntrinsic(I);
3250+
break;
32413251
case Intrinsic::lifetime_start:
32423252
handleLifetimeStart(I);
32433253
break;

0 commit comments

Comments
 (0)