This is an archive of the discontinued LLVM Phabricator instance.

[nfc][msan] Group checks per instruction
ClosedPublic

Authored by vitalybuka on Aug 31 2022, 3:58 PM.

Details

Summary

It's a preparation of to combine shadow checks of the same instruction

Diff Detail

Event Timeline

vitalybuka created this revision.Aug 31 2022, 3:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2022, 3:58 PM
vitalybuka requested review of this revision.Aug 31 2022, 3:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2022, 3:58 PM
vitalybuka edited the summary of this revision. (Show Details)
kda added a comment.Aug 31 2022, 4:53 PM

test?

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

I think this yields a stable sort. Is that what you want?
Is there any possibility items could be added in different orders in different runs?
If both are true, then the code generation is non-deterministic.

1319

I wonder if making an implementation that materializes one check would avoid this awkward slicing.

I think you could cook all the logic from materializeInstructionChecks into materializeOneCheck and be done.

test?

It's NFC

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

No, they added in the same order

1319

Not sure what are you asking, the point is to materialize them in batches, so we can combine checks

vitalybuka added inline comments.Aug 31 2022, 5:22 PM
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
1319

Not sure what are you asking, the point is to materialize them in batches, so we can combine checks

D133071 is the reason for slicing

kstoimenov accepted this revision.Sep 1 2022, 10:43 AM
kstoimenov added inline comments.
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
1305–1324

You are trying to dedupe members of the list, right? Isn't it more efficient to use a hash table instead? Wherever you consume this have a hash table, add elements to it and check check if it is already present then just skip over it.

This revision is now accepted and ready to land.Sep 1 2022, 10:43 AM
vitalybuka added inline comments.Sep 1 2022, 11:33 AM
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
1305–1324

Not exactly. I need to handle them together.
For mostly unique items, like here, pretty sure sorting is faster.
However I am concerned with non-determinism of sorting by pointer.

kda accepted this revision.Sep 1 2022, 11:37 AM
This revision was automatically updated to reflect the committed changes.