Encode alignment attribute for cmpxchg
This is a follow up patch to D83136 adding the align attribute to `cmpxchg`. See also D83465 for `atomicrmw`. Differential Revision: https://reviews.llvm.org/D87443
This commit is contained in:
committed by
James Y Knight
parent
d06ab79816
commit
17517f3178
@@ -5085,7 +5085,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
|
||||
}
|
||||
case bitc::FUNC_CODE_INST_CMPXCHG: {
|
||||
// CMPXCHG: [ptrty, ptr, cmp, val, vol, success_ordering, synchscope,
|
||||
// failure_ordering, weak]
|
||||
// failure_ordering, weak, align?]
|
||||
const size_t NumRecords = Record.size();
|
||||
unsigned OpNum = 0;
|
||||
Value *Ptr = nullptr;
|
||||
@@ -5100,10 +5100,14 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
|
||||
return error("Invalid record");
|
||||
|
||||
Value *Val = nullptr;
|
||||
if (popValue(Record, OpNum, NextValueNo, Cmp->getType(), Val) ||
|
||||
NumRecords < OpNum + 3 || NumRecords > OpNum + 5)
|
||||
if (popValue(Record, OpNum, NextValueNo, Cmp->getType(), Val))
|
||||
return error("Invalid record");
|
||||
|
||||
if (NumRecords < OpNum + 3 || NumRecords > OpNum + 6)
|
||||
return error("Invalid record");
|
||||
|
||||
const bool IsVol = Record[OpNum];
|
||||
|
||||
const AtomicOrdering SuccessOrdering =
|
||||
getDecodedOrdering(Record[OpNum + 1]);
|
||||
if (SuccessOrdering == AtomicOrdering::NotAtomic ||
|
||||
@@ -5118,14 +5122,23 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
|
||||
const AtomicOrdering FailureOrdering =
|
||||
getDecodedOrdering(Record[OpNum + 3]);
|
||||
|
||||
const Align Alignment(
|
||||
TheModule->getDataLayout().getTypeStoreSize(Cmp->getType()));
|
||||
const bool IsWeak = Record[OpNum + 4];
|
||||
|
||||
I = new AtomicCmpXchgInst(Ptr, Cmp, Val, Alignment, SuccessOrdering,
|
||||
MaybeAlign Alignment;
|
||||
|
||||
if (NumRecords == (OpNum + 6)) {
|
||||
if (Error Err = parseAlignmentValue(Record[OpNum + 5], Alignment))
|
||||
return Err;
|
||||
}
|
||||
if (!Alignment)
|
||||
Alignment =
|
||||
Align(TheModule->getDataLayout().getTypeStoreSize(Cmp->getType()));
|
||||
|
||||
I = new AtomicCmpXchgInst(Ptr, Cmp, Val, *Alignment, SuccessOrdering,
|
||||
FailureOrdering, SSID);
|
||||
FullTy = StructType::get(Context, {FullTy, Type::getInt1Ty(Context)});
|
||||
cast<AtomicCmpXchgInst>(I)->setVolatile(Record[OpNum]);
|
||||
cast<AtomicCmpXchgInst>(I)->setWeak(Record[OpNum + 4]);
|
||||
cast<AtomicCmpXchgInst>(I)->setVolatile(IsVol);
|
||||
cast<AtomicCmpXchgInst>(I)->setWeak(IsWeak);
|
||||
|
||||
InstructionList.push_back(I);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user