[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:16:02 PDT 2021
aeubanks created this revision.
aeubanks added reviewers: nikic, Prazek.
Herald added subscribers: dexonsmith, hiraditya.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
As specified by https://llvm.org/docs/LangRef.html#invariant-group-metadata.
Repository:
rG LLVM Github Monorepo
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 (MDNode *IG = I.getMetadata(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.370356.patch
Type: text/x-patch
Size: 1225 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210902/b17f6563/attachment.bin>
More information about the llvm-commits
mailing list