This is an archive of the discontinued LLVM Phabricator instance.

[Verifier] Move some atomicrmw/cmpxchg checks to instruction creation
ClosedPublic

Authored by aeubanks on May 19 2021, 1:37 PM.

Details

Summary

These checks already exist as asserts when creating the corresponding
instruction. Anybody creating these instructions already need to take
care to not break these checks.

Move the checks for success/failure ordering in cmpxchg from the
verifier to the LLParser and BitcodeReader plus an assert.

Add some tests for cmpxchg ordering. The .bc files are created from the
.ll files with an llvm-as with these checks disabled.

Diff Detail

Event Timeline

aeubanks created this revision.May 19 2021, 1:37 PM
aeubanks requested review of this revision.May 19 2021, 1:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 19 2021, 1:37 PM
dblaikie added inline comments.May 19 2021, 3:52 PM
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
5146–5149

Does this have test coverage?

aeubanks added inline comments.May 19 2021, 5:49 PM
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
5146–5149

no, it's the thing mentioned in the description

adding test coverage would require a bitcode file that was generated by a modified LLVM that allows this to bypass the LLParser/verifier

so this probably isn't an issue in practice since it's always been invalid, so there shouldn't be any bitcode out there that hits this
I guess I could just remove this check

dblaikie added inline comments.May 19 2021, 8:17 PM
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
5146–5149

We should still handle invalid bitcode/shouldn't be able to create undefined situations through invalid bitcode.

So I'd say this needs a test - I assume there are other invalid bitcode tests somewhere around ?

Happy to help create one if you like.

aeubanks updated this revision to Diff 347096.May 21 2021, 12:08 PM

factor out cmpxchg ordering checks
add more bc tests

aeubanks retitled this revision from [Verifier] Remove some redundant checks to [Verifier] Move some atomicrmw/cmpxchg checks to instruction creation.May 21 2021, 12:09 PM
aeubanks edited the summary of this revision. (Show Details)
dblaikie accepted this revision.May 21 2021, 12:30 PM

Looks good, thanks!

This revision is now accepted and ready to land.May 21 2021, 12:30 PM