[PATCH] D109182: [Verifier] Only allow invariant.group metadata on stores and loads
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 2 12:17:09 PDT 2021
aeubanks updated this revision to Diff 370357.
aeubanks added a comment.
update
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109182/new/
https://reviews.llvm.org/D109182
Files:
llvm/lib/IR/Verifier.cpp
llvm/test/Verifier/invariant.group.ll
Index: llvm/test/Verifier/invariant.group.ll
===================================================================
--- /dev/null
+++ llvm/test/Verifier/invariant.group.ll
@@ -0,0 +1,14 @@
+; RUN: not opt -passes=verify -disable-output < %s 2>&1 | FileCheck %s
+
+; CHECK: invariant.group metadata is only for loads and stores
+; CHECK-NEXT: alloca
+; CHECK-NEXT: invariant.group metadata is only for loads and stores
+; CHECK-NEXT: ret void
+define void @f() {
+ %a = alloca i32, !invariant.group !0
+ %b = load i32, i32* %a, !invariant.group !0
+ store i32 43, i32* %a, !invariant.group !0
+ ret void, !invariant.group !0
+}
+
+!0 = !{}
Index: llvm/lib/IR/Verifier.cpp
===================================================================
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -4470,6 +4470,11 @@
visitRangeMetadata(I, Range, I.getType());
}
+ if (I.hasMetadata(LLVMContext::MD_invariant_group)) {
+ Assert(isa<LoadInst>(I) || isa<StoreInst>(I),
+ "invariant.group metadata is only for loads and stores", &I);
+ }
+
if (I.getMetadata(LLVMContext::MD_nonnull)) {
Assert(I.getType()->isPointerTy(), "nonnull applies only to pointer types",
&I);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109182.370357.patch
Type: text/x-patch
Size: 1212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210902/c7c83730/attachment.bin>
More information about the llvm-commits
mailing list