[PATCH] D79203: Handle indirect calls in preallocated verification
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 30 15:07:28 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3d5275fc05d5: Handle indirect calls in preallocated verification (authored by aeubanks).
Changed prior to commit:
https://reviews.llvm.org/D79203?vs=261344&id=261370#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79203/new/
https://reviews.llvm.org/D79203
Files:
llvm/lib/IR/Verifier.cpp
llvm/test/Verifier/preallocated-valid.ll
Index: llvm/test/Verifier/preallocated-valid.ll
===================================================================
--- llvm/test/Verifier/preallocated-valid.ll
+++ llvm/test/Verifier/preallocated-valid.ll
@@ -14,6 +14,14 @@
ret void
}
+define void @preallocated_indirect(void (i32*)* %f) {
+ %cs = call token @llvm.call.preallocated.setup(i32 1)
+ %x = call i8* @llvm.call.preallocated.arg(token %cs, i32 0) preallocated(i32)
+ %y = bitcast i8* %x to i32*
+ call void %f(i32* preallocated(i32) %y) ["preallocated"(token %cs)]
+ ret void
+}
+
define void @preallocated_setup_without_call() {
%cs = call token @llvm.call.preallocated.setup(i32 1)
%a0 = call i8* @llvm.call.preallocated.arg(token %cs, i32 0) preallocated(i32)
Index: llvm/lib/IR/Verifier.cpp
===================================================================
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -4485,7 +4485,7 @@
Assert(UseCall != nullptr,
"Uses of llvm.call.preallocated.setup must be calls");
const Function *Fn = UseCall->getCalledFunction();
- if (Fn->getIntrinsicID() == Intrinsic::call_preallocated_arg) {
+ if (Fn && Fn->getIntrinsicID() == Intrinsic::call_preallocated_arg) {
auto *AllocArgIndex = dyn_cast<ConstantInt>(UseCall->getArgOperand(1));
Assert(AllocArgIndex != nullptr,
"llvm.call.preallocated.alloc arg index must be a constant");
@@ -4500,8 +4500,8 @@
"llvm.call.preallocated.setup");
FoundCall = true;
size_t NumPreallocatedArgs = 0;
- for (auto &Arg : Fn->args()) {
- if (Arg.hasAttribute(Attribute::Preallocated)) {
+ for (unsigned i = 0; i < UseCall->getNumArgOperands(); i++) {
+ if (UseCall->paramHasAttr(i, Attribute::Preallocated)) {
++NumPreallocatedArgs;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79203.261370.patch
Type: text/x-patch
Size: 1899 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200430/c9f71ccb/attachment.bin>
More information about the llvm-commits
mailing list