This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking] Avoid blind cast from Operator to Instruction
ClosedPublic

Authored by bjope on Mar 22 2020, 4:35 AM.

Details

Summary

Avoid blind cast from Operator to ExtractElementInst in
computeKnownBitsFromOperator. This resulted in some crashes
in downstream fuzzy testing. Instead we use getOperand directly
on the Operator when accessing the vector/index operands.

Haven't seen any problems with InsertElement and ShuffleVector,
but I believe those could be used in constant expressions as well.
So the same kind of fix as for ExtractElement was also applied for
InsertElement.

When it comes to ShuffleVector we now simply bail out if a dynamic
cast of the Operator to ShuffleVectorInst fails. I've got no
reproducer indicating problems for ShuffleVector, and a fix would be
slightly more complicated as getShuffleDemandedElts is involved.

Diff Detail

Event Timeline

bjope created this revision.Mar 22 2020, 4:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 22 2020, 4:35 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
RKSimon accepted this revision.Mar 22 2020, 6:34 AM

LGTM

llvm/lib/Analysis/ValueTracking.cpp
1743
if (!Shuf) {
  Known.resetAll();
  return;
}
1804

clang-format

This revision is now accepted and ready to land.Mar 22 2020, 6:34 AM
bjope marked 2 inline comments as done.Mar 22 2020, 6:47 AM
bjope added inline comments.
llvm/lib/Analysis/ValueTracking.cpp
1743

Yes, thanks!

This revision was automatically updated to reflect the committed changes.