diff options
author | Than McIntosh <thanm@google.com> | 2018-11-16 14:28:05 +0000 |
---|---|---|
committer | Than McIntosh <thanm@google.com> | 2018-11-16 14:28:05 +0000 |
commit | 4a1c5da7ac063a6a73da973871fb9584fce19104 (patch) | |
tree | 6ed5096a117a730cbb6a6abcdc449e72052ef599 /llvm/lib/IR | |
parent | 705fbd5d4ff5abd39c5fb50c4a55988d78e94b68 (diff) | |
download | bcm5719-llvm-4a1c5da7ac063a6a73da973871fb9584fce19104.tar.gz bcm5719-llvm-4a1c5da7ac063a6a73da973871fb9584fce19104.zip |
[IRVerifier] Allow StructRet in statepoint
Summary:
StructRet attribute is not allowed in vararg calls. The statepoint
intrinsic is vararg, but the wrapped function may be not. Allow
calls of statepoint with StructRet arg, as long as the wrapped
function is not vararg.
Reviewers: thanm, anna
Reviewed By: anna
Subscribers: anna, llvm-commits
Differential Revision: https://reviews.llvm.org/D53602
llvm-svn: 347050
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 899534dd10f..bc2e10c049a 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -1930,6 +1930,7 @@ void Verifier::verifyStatepoint(ImmutableCallSite CS) { // Verify that the types of the call parameter arguments match // the type of the wrapped callee. + AttributeList Attrs = CS.getAttributes(); for (int i = 0; i < NumParams; i++) { Type *ParamType = TargetFuncType->getParamType(i); Type *ArgType = CS.getArgument(5 + i)->getType(); @@ -1937,6 +1938,12 @@ void Verifier::verifyStatepoint(ImmutableCallSite CS) { "gc.statepoint call argument does not match wrapped " "function type", &CI); + + if (TargetFuncType->isVarArg()) { + AttributeSet ArgAttrs = Attrs.getParamAttributes(5 + i); + Assert(!ArgAttrs.hasAttribute(Attribute::StructRet), + "Attribute 'sret' cannot be used for vararg call arguments!", &CI); + } } const int EndCallArgsInx = 4 + NumCallArgs; @@ -2814,8 +2821,13 @@ void Verifier::verifyCallSite(CallSite CS) { SawReturned = true; } - Assert(!ArgAttrs.hasAttribute(Attribute::StructRet), - "Attribute 'sret' cannot be used for vararg call arguments!", I); + // Statepoint intrinsic is vararg but the wrapped function may be not. + // Allow sret here and check the wrapped function in verifyStatepoint. + if (CS.getCalledFunction() == nullptr || + CS.getCalledFunction()->getIntrinsicID() != + Intrinsic::experimental_gc_statepoint) + Assert(!ArgAttrs.hasAttribute(Attribute::StructRet), + "Attribute 'sret' cannot be used for vararg call arguments!", I); if (ArgAttrs.hasAttribute(Attribute::InAlloca)) Assert(Idx == CS.arg_size() - 1, "inalloca isn't on the last argument!", |