mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[OpaquePtr] Make cmpxchg work with opaque pointers
Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D102745
This commit is contained in:
parent
764e5745a3
commit
208107dd2c
@ -7591,10 +7591,14 @@ int LLParser::parseCmpXchg(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
"cmpxchg failure ordering cannot include release semantics");
|
||||
if (!Ptr->getType()->isPointerTy())
|
||||
return error(PtrLoc, "cmpxchg operand must be a pointer");
|
||||
if (cast<PointerType>(Ptr->getType())->getElementType() != Cmp->getType())
|
||||
if (!cast<PointerType>(Ptr->getType())
|
||||
->isOpaqueOrPointeeTypeMatches(Cmp->getType()))
|
||||
return error(CmpLoc, "compare value and pointer type do not match");
|
||||
if (cast<PointerType>(Ptr->getType())->getElementType() != New->getType())
|
||||
if (!cast<PointerType>(Ptr->getType())
|
||||
->isOpaqueOrPointeeTypeMatches(New->getType()))
|
||||
return error(NewLoc, "new value and pointer type do not match");
|
||||
if (Cmp->getType() != New->getType())
|
||||
return error(NewLoc, "compare value and new value type do not match");
|
||||
if (!New->getType()->isFirstClassType())
|
||||
return error(NewLoc, "cmpxchg operand must be a first class value");
|
||||
|
||||
|
@ -1548,12 +1548,14 @@ void AtomicCmpXchgInst::Init(Value *Ptr, Value *Cmp, Value *NewVal,
|
||||
"All operands must be non-null!");
|
||||
assert(getOperand(0)->getType()->isPointerTy() &&
|
||||
"Ptr must have pointer type!");
|
||||
assert(getOperand(1)->getType() ==
|
||||
cast<PointerType>(getOperand(0)->getType())->getElementType()
|
||||
&& "Ptr must be a pointer to Cmp type!");
|
||||
assert(getOperand(2)->getType() ==
|
||||
cast<PointerType>(getOperand(0)->getType())->getElementType()
|
||||
&& "Ptr must be a pointer to NewVal type!");
|
||||
assert(cast<PointerType>(getOperand(0)->getType())
|
||||
->isOpaqueOrPointeeTypeMatches(getOperand(1)->getType()) &&
|
||||
"Ptr must be a pointer to Cmp type!");
|
||||
assert(cast<PointerType>(getOperand(0)->getType())
|
||||
->isOpaqueOrPointeeTypeMatches(getOperand(2)->getType()) &&
|
||||
"Ptr must be a pointer to NewVal type!");
|
||||
assert(getOperand(1)->getType() == getOperand(2)->getType() &&
|
||||
"Cmp type and NewVal type must be same!");
|
||||
assert(SuccessOrdering != AtomicOrdering::NotAtomic &&
|
||||
"AtomicCmpXchg instructions must be atomic!");
|
||||
assert(FailureOrdering != AtomicOrdering::NotAtomic &&
|
||||
|
@ -3847,15 +3847,16 @@ void Verifier::visitAtomicCmpXchgInst(AtomicCmpXchgInst &CXI) {
|
||||
|
||||
PointerType *PTy = dyn_cast<PointerType>(CXI.getOperand(0)->getType());
|
||||
Assert(PTy, "First cmpxchg operand must be a pointer.", &CXI);
|
||||
Type *ElTy = PTy->getElementType();
|
||||
Assert(ElTy->isIntOrPtrTy(),
|
||||
"cmpxchg operand must have integer or pointer type", ElTy, &CXI);
|
||||
checkAtomicMemAccessSize(ElTy, &CXI);
|
||||
Assert(ElTy == CXI.getOperand(1)->getType(),
|
||||
Type *ElTy = CXI.getOperand(1)->getType();
|
||||
Assert(PTy->isOpaqueOrPointeeTypeMatches(ElTy),
|
||||
"Expected value type does not match pointer operand type!", &CXI,
|
||||
ElTy);
|
||||
Assert(ElTy == CXI.getOperand(2)->getType(),
|
||||
"Stored value type does not match pointer operand type!", &CXI, ElTy);
|
||||
"Stored value type does not match expected value operand type!", &CXI,
|
||||
ElTy);
|
||||
Assert(ElTy->isIntOrPtrTy(),
|
||||
"cmpxchg operand must have integer or pointer type", ElTy, &CXI);
|
||||
checkAtomicMemAccessSize(ElTy, &CXI);
|
||||
visitInstruction(CXI);
|
||||
}
|
||||
|
||||
|
7
test/Assembler/opaque-ptr-cmpxchg.ll
Normal file
7
test/Assembler/opaque-ptr-cmpxchg.ll
Normal file
@ -0,0 +1,7 @@
|
||||
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: compare value and new value type do not match
|
||||
define void @cmpxchg(ptr %p, i32 %a, i64 %b) {
|
||||
%val_success = cmpxchg ptr %p, i32 %a, i64 %b acq_rel monotonic
|
||||
ret void
|
||||
}
|
@ -48,3 +48,11 @@ define void @gep(ptr %a) {
|
||||
%b = getelementptr i8, ptr %a, i32 2
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: define void @cmpxchg(ptr %p, i32 %a, i32 %b)
|
||||
; CHECK: %val_success = cmpxchg ptr %p, i32 %a, i32 %b acq_rel monotonic
|
||||
; CHECK: ret void
|
||||
define void @cmpxchg(ptr %p, i32 %a, i32 %b) {
|
||||
%val_success = cmpxchg ptr %p, i32 %a, i32 %b acq_rel monotonic
|
||||
ret void
|
||||
}
|
||||
|
@ -11,3 +11,9 @@ define void @store(ptr %a, i32 %i) {
|
||||
store i32 %i, ptr %a
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: @cmpxchg
|
||||
define void @cmpxchg(ptr %p, i32 %a, i32 %b) {
|
||||
%val_success = cmpxchg ptr %p, i32 %a, i32 %b acq_rel monotonic
|
||||
ret void
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user