summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Bitcode/LLVMBitCodes.h4
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp13
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp2
-rw-r--r--llvm/test/Bitcode/cmpxchg.3.6.ll13
-rw-r--r--llvm/test/Bitcode/cmpxchg.3.6.ll.bcbin0 -> 488 bytes
5 files changed, 25 insertions, 7 deletions
diff --git a/llvm/include/llvm/Bitcode/LLVMBitCodes.h b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
index 2db9d809c4f..fe6d3662954 100644
--- a/llvm/include/llvm/Bitcode/LLVMBitCodes.h
+++ b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
@@ -336,7 +336,7 @@ namespace bitc {
FUNC_CODE_DEBUG_LOC = 35, // DEBUG_LOC: [Line,Col,ScopeVal, IAVal]
FUNC_CODE_INST_FENCE = 36, // FENCE: [ordering, synchscope]
- FUNC_CODE_INST_CMPXCHG = 37, // CMPXCHG: [ptrty,ptr,cmp,new, align, vol,
+ FUNC_CODE_INST_CMPXCHG_OLD = 37, // CMPXCHG: [ptrty,ptr,cmp,new, align, vol,
// ordering, synchscope]
FUNC_CODE_INST_ATOMICRMW = 38, // ATOMICRMW: [ptrty,ptr,val, operation,
// align, vol,
@@ -350,6 +350,8 @@ namespace bitc {
FUNC_CODE_INST_GEP = 43, // GEP: [inbounds, n x operands]
FUNC_CODE_INST_STORE = 44, // STORE: [ptrty,ptr,valty,val, align, vol]
FUNC_CODE_INST_STOREATOMIC = 45, // STORE: [ptrty,ptr,val, align, vol
+ FUNC_CODE_INST_CMPXCHG = 46, // CMPXCHG: [ptrty,ptr,valty,cmp,new, align,
+ // vol,ordering,synchscope]
};
enum UseListCodes {
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 1e9a8eb7fd1..cc554a91bea 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -4146,17 +4146,20 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
InstructionList.push_back(I);
break;
}
+ case bitc::FUNC_CODE_INST_CMPXCHG_OLD:
case bitc::FUNC_CODE_INST_CMPXCHG: {
// CMPXCHG:[ptrty, ptr, cmp, new, vol, successordering, synchscope,
// failureordering?, isweak?]
unsigned OpNum = 0;
Value *Ptr, *Cmp, *New;
if (getValueTypePair(Record, OpNum, NextValueNo, Ptr) ||
- popValue(Record, OpNum, NextValueNo,
- cast<PointerType>(Ptr->getType())->getElementType(), Cmp) ||
- popValue(Record, OpNum, NextValueNo,
- cast<PointerType>(Ptr->getType())->getElementType(), New) ||
- (Record.size() < OpNum + 3 || Record.size() > OpNum + 5))
+ (BitCode == bitc::FUNC_CODE_INST_CMPXCHG
+ ? getValueTypePair(Record, OpNum, NextValueNo, Cmp)
+ : popValue(Record, OpNum, NextValueNo,
+ cast<PointerType>(Ptr->getType())->getElementType(),
+ Cmp)) ||
+ popValue(Record, OpNum, NextValueNo, Cmp->getType(), New) ||
+ Record.size() < OpNum + 3 || Record.size() > OpNum + 5)
return Error("Invalid record");
AtomicOrdering SuccessOrdering = GetDecodedOrdering(Record[OpNum+1]);
if (SuccessOrdering == NotAtomic || SuccessOrdering == Unordered)
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 840b75e496f..b6444b2d060 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -1917,7 +1917,7 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
case Instruction::AtomicCmpXchg:
Code = bitc::FUNC_CODE_INST_CMPXCHG;
PushValueAndType(I.getOperand(0), InstID, Vals, VE); // ptrty + ptr
- pushValue(I.getOperand(1), InstID, Vals, VE); // cmp.
+ PushValueAndType(I.getOperand(1), InstID, Vals, VE); // cmp.
pushValue(I.getOperand(2), InstID, Vals, VE); // newval.
Vals.push_back(cast<AtomicCmpXchgInst>(I).isVolatile());
Vals.push_back(GetEncodedOrdering(
diff --git a/llvm/test/Bitcode/cmpxchg.3.6.ll b/llvm/test/Bitcode/cmpxchg.3.6.ll
new file mode 100644
index 00000000000..bec51a128c3
--- /dev/null
+++ b/llvm/test/Bitcode/cmpxchg.3.6.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-dis < %s.bc | FileCheck %s
+
+define void @f2(i32* %x, i32 %y.orig, i32 %z) {
+entry:
+ br label %a
+b:
+ cmpxchg i32* %x, i32 %y, i32 %z acquire acquire
+; CHECK: cmpxchg i32* %x, i32 %y, i32 %z acquire acquire
+ ret void
+a:
+ %y = add i32 %y.orig, 1
+ br label %a
+}
diff --git a/llvm/test/Bitcode/cmpxchg.3.6.ll.bc b/llvm/test/Bitcode/cmpxchg.3.6.ll.bc
new file mode 100644
index 00000000000..1c66f934324
--- /dev/null
+++ b/llvm/test/Bitcode/cmpxchg.3.6.ll.bc
Binary files differ
OpenPOWER on IntegriCloud