This is an archive of the discontinued LLVM Phabricator instance.

[MSAN] Add handleCountZeroes for ctlz and cttz.
ClosedPublic

Authored by kda on Oct 22 2022, 2:26 AM.

Details

Summary

This addresses a bug where vector versions of ctlz are creating false positive reports.

Depends on D136369

Diff Detail

Event Timeline

kda created this revision.Oct 22 2022, 2:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 22 2022, 2:26 AM
kda requested review of this revision.Oct 22 2022, 2:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 22 2022, 2:26 AM
eugenis added inline comments.Oct 24 2022, 10:54 AM
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
2974

isn't this implementation strictly better than default? It handles the second operand correctly.

2976

Is there a problem with scalable vectors? You could just use Type::isVectorTy() otherwise.

2994

use CreateIsNull

kda updated this revision to Diff 470281.Oct 24 2022, 1:45 PM
kda marked an inline comment as done.

updated for input from eugenis.

LGTM, but I'd merge the two changes. I don't really see the point of submitting a test for the broken behavior first.

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
2982

This line seems unnecessary.

kda added a comment.Oct 24 2022, 3:48 PM

LGTM, but I'd merge the two changes. I don't really see the point of submitting a test for the broken behavior first.

The test does not demonstrate "broken" behavior but rather shows what is generated before my change.
I will keep them separate as I would like to show how my code changes what is generated.

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
2974

Agreed. I added this comment (conditional) prior to adding handling of second parameter.

2976

dropped (see previous comment).

2982

Oh. Again, I rearranged the code and forgot about this dangling item. I originally had the OR outside the conditional, thus I needed a BoolZeroPoison that was passive.

Removed.

kda updated this revision to Diff 470308.Oct 24 2022, 3:57 PM

removed unused line

LGTM, but I'd merge the two changes. I don't really see the point of submitting a test for the broken behavior first.

Actually I rely like splitting stuff like this
the effect of non-NFC part is very visible

vitalybuka accepted this revision.Oct 24 2022, 4:24 PM

LGTM with nits

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
2975

Operand -> Src to match the name in LangRef

2978

CreateIsNull like you do below is less code

2983

cast<> and it can be only the Constant
then you can remove assert() as cast<> already has one

2983

constOperant -> Poison (or something similar to the name in LangRef)
Note: vars are capitalized

This revision is now accepted and ready to land.Oct 24 2022, 4:24 PM
kda updated this revision to Diff 470326.Oct 24 2022, 5:09 PM
kda marked 4 inline comments as done.

improvements based on vitalybuka feedback

kda retitled this revision from [MSAN] Add handleCountZeroes for vector versions of ctlz and cttz. to [MSAN] Add handleCountZeroes for ctlz and cttz..Oct 24 2022, 5:28 PM
kda updated this revision to Diff 470331.Oct 24 2022, 5:30 PM

rebase.

This revision was landed with ongoing or failed builds.Oct 24 2022, 5:31 PM
This revision was automatically updated to reflect the committed changes.