[PATCH] D52415: Add atomicrmw operation to error messages
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 24 07:21:41 PDT 2018
arsenm created this revision.
arsenm added a reviewer: reames.
Herald added subscribers: jfb, wdng.
arsenm added a dependency: D52414: IR: Move AtomicRMW string names into class.
arsenm added a dependent revision: D52416: Allow FP types for atomicrmw xchg.
https://reviews.llvm.org/D52415
Files:
lib/AsmParser/LLParser.cpp
lib/IR/Verifier.cpp
test/Assembler/invalid-atomicrmw-add-must-be-integer-type.ll
Index: test/Assembler/invalid-atomicrmw-add-must-be-integer-type.ll
===================================================================
--- /dev/null
+++ test/Assembler/invalid-atomicrmw-add-must-be-integer-type.ll
@@ -0,0 +1,7 @@
+; RUN: not llvm-as -disable-output %s 2>&1 | FileCheck %s
+
+; CHECK: error: atomicrmw add operand must be an integer
+define void @f(float* %ptr) {
+ atomicrmw add float* %ptr, float 1.0 seq_cst
+ ret void
+}
Index: lib/IR/Verifier.cpp
===================================================================
--- lib/IR/Verifier.cpp
+++ lib/IR/Verifier.cpp
@@ -3348,17 +3348,19 @@
"atomicrmw instructions must be atomic.", &RMWI);
Assert(RMWI.getOrdering() != AtomicOrdering::Unordered,
"atomicrmw instructions cannot be unordered.", &RMWI);
+ auto Op = RMWI.getOperation();
PointerType *PTy = dyn_cast<PointerType>(RMWI.getOperand(0)->getType());
Assert(PTy, "First atomicrmw operand must be a pointer.", &RMWI);
Type *ElTy = PTy->getElementType();
- Assert(ElTy->isIntegerTy(), "atomicrmw operand must have integer type!",
+ Assert(ElTy->isIntegerTy(), "atomicrmw " +
+ AtomicRMWInst::getOperationName(Op) +
+ " operand must have integer type!",
&RMWI, ElTy);
checkAtomicMemAccessSize(ElTy, &RMWI);
Assert(ElTy == RMWI.getOperand(1)->getType(),
"Argument value type does not match pointer operand type!", &RMWI,
ElTy);
- Assert(AtomicRMWInst::FIRST_BINOP <= RMWI.getOperation() &&
- RMWI.getOperation() <= AtomicRMWInst::LAST_BINOP,
+ Assert(AtomicRMWInst::FIRST_BINOP <= Op && Op <= AtomicRMWInst::LAST_BINOP,
"Invalid binary operation!", &RMWI);
visitInstruction(RMWI);
}
Index: lib/AsmParser/LLParser.cpp
===================================================================
--- lib/AsmParser/LLParser.cpp
+++ lib/AsmParser/LLParser.cpp
@@ -6721,8 +6721,13 @@
return Error(PtrLoc, "atomicrmw operand must be a pointer");
if (cast<PointerType>(Ptr->getType())->getElementType() != Val->getType())
return Error(ValLoc, "atomicrmw value and pointer type do not match");
- if (!Val->getType()->isIntegerTy())
- return Error(ValLoc, "atomicrmw operand must be an integer");
+
+ if (!Val->getType()->isIntegerTy()) {
+ return Error(ValLoc, "atomicrmw " +
+ AtomicRMWInst::getOperationName(Operation) +
+ " operand must be an integer");
+ }
+
unsigned Size = Val->getType()->getPrimitiveSizeInBits();
if (Size < 8 || (Size & (Size - 1)))
return Error(ValLoc, "atomicrmw operand must be power-of-two byte-sized"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52415.166661.patch
Type: text/x-patch
Size: 2617 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180924/ca1f0bf9/attachment.bin>
More information about the llvm-commits
mailing list