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

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.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D102803
This commit is contained in:
Arthur Eubanks
2021-05-19 13:02:29 -07:00
parent 8110a73164
commit 7a29a12301
14 changed files with 68 additions and 50 deletions

View File

@@ -5143,6 +5143,10 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
? AtomicCmpXchgInst::getStrongestFailureOrdering(SuccessOrdering)
: getDecodedOrdering(Record[OpNum + 3]);
if (FailureOrdering == AtomicOrdering::NotAtomic ||
FailureOrdering == AtomicOrdering::Unordered)
return error("Invalid record");
const Align Alignment(
TheModule->getDataLayout().getTypeStoreSize(Cmp->getType()));
@@ -5192,9 +5196,8 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
const AtomicOrdering SuccessOrdering =
getDecodedOrdering(Record[OpNum + 1]);
if (SuccessOrdering == AtomicOrdering::NotAtomic ||
SuccessOrdering == AtomicOrdering::Unordered)
return error("Invalid record");
if (!AtomicCmpXchgInst::isValidSuccessOrdering(SuccessOrdering))
return error("Invalid cmpxchg success ordering");
const SyncScope::ID SSID = getDecodedSyncScopeID(Record[OpNum + 2]);
@@ -5203,6 +5206,8 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
const AtomicOrdering FailureOrdering =
getDecodedOrdering(Record[OpNum + 3]);
if (!AtomicCmpXchgInst::isValidFailureOrdering(FailureOrdering))
return error("Invalid cmpxchg failure ordering");
const bool IsWeak = Record[OpNum + 4];