[PATCH] D64954: [IR][Verifier] Allow IntToPtrInst to be !dereferenceable
Ryan Taylor via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 18 15:38:54 PDT 2019
rtaylor created this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Allow IntToPtrInst to carry !dereferenceable metadata tag.
This is valid since !dereferenceable can be only be applied to
pointer type values.
Change-Id: If8a6e3c616f073d51eaff52ab74535c29ed497b4
Repository:
rL LLVM
https://reviews.llvm.org/D64954
Files:
lib/IR/Verifier.cpp
test/Verifier/dereferenceable-md.ll
Index: test/Verifier/dereferenceable-md.ll
===================================================================
--- test/Verifier/dereferenceable-md.ll
+++ test/Verifier/dereferenceable-md.ll
@@ -83,4 +83,10 @@
ret i8* %y
}
; CHECK: dereferenceable, dereferenceable_or_null metadata value must be an i64!
-; CHECK-NEXT: load i8*, i8** %x
\ No newline at end of file
+; CHECK-NEXT: load i8*, i8** %x
+
+define i8* @f_0(i64 %val) {
+ %ptr = inttoptr i64 %val to i8*, !dereferenceable !{!"str"}
+ ret i8* %ptr
+}
+; CHECK-NOT: dereferenceable, dereferenceable_or_null apply only to load instructions, use attributes for calls or invokes
Index: lib/IR/Verifier.cpp
===================================================================
--- lib/IR/Verifier.cpp
+++ lib/IR/Verifier.cpp
@@ -3983,7 +3983,7 @@
void Verifier::visitDereferenceableMetadata(Instruction& I, MDNode* MD) {
Assert(I.getType()->isPointerTy(), "dereferenceable, dereferenceable_or_null "
"apply only to pointer types", &I);
- Assert(isa<LoadInst>(I),
+ Assert((isa<LoadInst>(I) || isa<IntToPtrInst>(I)),
"dereferenceable, dereferenceable_or_null apply only to load"
" instructions, use attributes for calls or invokes", &I);
Assert(MD->getNumOperands() == 1, "dereferenceable, dereferenceable_or_null "
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64954.210691.patch
Type: text/x-patch
Size: 1312 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190718/d1fbb5ba/attachment.bin>
More information about the llvm-commits
mailing list