Skip to content

Commit af5cac7

Browse files
committed
[Verifier] Allow vector type in atomic load and store
Vector types on atomics are assumed to be invalid by the verifier. However, this type can be valid if it is lowered by codegen.
1 parent 20bd029 commit af5cac7

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

llvm/lib/IR/Verifier.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -4255,9 +4255,10 @@ void Verifier::visitLoadInst(LoadInst &LI) {
42554255
Check(LI.getOrdering() != AtomicOrdering::Release &&
42564256
LI.getOrdering() != AtomicOrdering::AcquireRelease,
42574257
"Load cannot have Release ordering", &LI);
4258-
Check(ElTy->isIntOrPtrTy() || ElTy->isFloatingPointTy(),
4259-
"atomic load operand must have integer, pointer, or floating point "
4260-
"type!",
4258+
Check(ElTy->isIntOrPtrTy() || ElTy->isFloatingPointTy() ||
4259+
ElTy->isVectorTy(),
4260+
"atomic load operand must have integer, pointer, floating point, "
4261+
"or vector type!",
42614262
ElTy, &LI);
42624263
checkAtomicMemAccessSize(ElTy, &LI);
42634264
} else {
@@ -4281,9 +4282,10 @@ void Verifier::visitStoreInst(StoreInst &SI) {
42814282
Check(SI.getOrdering() != AtomicOrdering::Acquire &&
42824283
SI.getOrdering() != AtomicOrdering::AcquireRelease,
42834284
"Store cannot have Acquire ordering", &SI);
4284-
Check(ElTy->isIntOrPtrTy() || ElTy->isFloatingPointTy(),
4285-
"atomic store operand must have integer, pointer, or floating point "
4286-
"type!",
4285+
Check(ElTy->isIntOrPtrTy() || ElTy->isFloatingPointTy() ||
4286+
ElTy->isVectorTy(),
4287+
"atomic store operand must have integer, pointer, floating point, "
4288+
"or vector type!",
42874289
ElTy, &SI);
42884290
checkAtomicMemAccessSize(ElTy, &SI);
42894291
} else {

llvm/test/Verifier/atomics.ll

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
; RUN: not opt -passes=verify < %s 2>&1 | FileCheck %s
2+
; CHECK: atomic store operand must have integer, pointer, floating point, or vector type!
3+
; CHECK: atomic load operand must have integer, pointer, floating point, or vector type!
24

3-
; CHECK: atomic store operand must have integer, pointer, or floating point type!
4-
; CHECK: atomic load operand must have integer, pointer, or floating point type!
5+
%ty = type { i32 };
56

6-
define void @foo(ptr %P, <1 x i64> %v) {
7-
store atomic <1 x i64> %v, ptr %P unordered, align 8
7+
define void @foo(ptr %P, %ty %v) {
8+
store atomic %ty %v, ptr %P unordered, align 8
89
ret void
910
}
1011

11-
define <1 x i64> @bar(ptr %P) {
12-
%v = load atomic <1 x i64>, ptr %P unordered, align 8
13-
ret <1 x i64> %v
12+
define %ty @bar(ptr %P) {
13+
%v = load atomic %ty, ptr %P unordered, align 8
14+
ret %ty %v
1415
}

0 commit comments

Comments
 (0)