diff options
| author | Tim Northover <tnorthover@apple.com> | 2019-05-30 18:48:23 +0000 |
|---|---|---|
| committer | Tim Northover <tnorthover@apple.com> | 2019-05-30 18:48:23 +0000 |
| commit | b7141207a483d39b99c2b4da4eb3bb591eca9e1a (patch) | |
| tree | 17be3c9e9f0ba7f9493e2279d5df0e029533d910 /llvm/lib/AsmParser | |
| parent | 7fecdf36cc5b41dc5ad85d58c6e3b97b4fce6d00 (diff) | |
| download | bcm5719-llvm-b7141207a483d39b99c2b4da4eb3bb591eca9e1a.tar.gz bcm5719-llvm-b7141207a483d39b99c2b4da4eb3bb591eca9e1a.zip | |
Reapply: IR: add optional type to 'byval' function parameters
When we switch to opaque pointer types we will need some way to describe
how many bytes a 'byval' parameter should occupy on the stack. This adds
a (for now) optional extra type parameter.
If present, the type must match the pointee type of the argument.
The original commit did not remap byval types when linking modules, which broke
LTO. This version fixes that.
Note to front-end maintainers: if this causes test failures, it's probably
because the "byval" attribute is printed after attributes without any parameter
after this change.
llvm-svn: 362128
Diffstat (limited to 'llvm/lib/AsmParser')
| -rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 24 | ||||
| -rw-r--r-- | llvm/lib/AsmParser/LLParser.h | 1 |
2 files changed, 24 insertions, 1 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 95646675cb2..0a9a09e644d 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -1601,7 +1601,13 @@ bool LLParser::ParseOptionalParamAttrs(AttrBuilder &B) { B.addAlignmentAttr(Alignment); continue; } - case lltok::kw_byval: B.addAttribute(Attribute::ByVal); break; + case lltok::kw_byval: { + Type *Ty; + if (ParseByValWithOptionalType(Ty)) + return true; + B.addByValAttr(Ty); + continue; + } case lltok::kw_dereferenceable: { uint64_t Bytes; if (ParseOptionalDerefAttrBytes(lltok::kw_dereferenceable, Bytes)) @@ -2454,6 +2460,22 @@ bool LLParser::ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList, return false; } +/// ParseByValWithOptionalType +/// ::= byval +/// ::= byval(<ty>) +bool LLParser::ParseByValWithOptionalType(Type *&Result) { + Result = nullptr; + if (!EatIfPresent(lltok::kw_byval)) + return true; + if (!EatIfPresent(lltok::lparen)) + return false; + if (ParseType(Result)) + return true; + if (!EatIfPresent(lltok::rparen)) + return Error(Lex.getLoc(), "expected ')'"); + return false; +} + /// ParseOptionalOperandBundles /// ::= /*empty*/ /// ::= '[' OperandBundle [, OperandBundle ]* ']' diff --git a/llvm/lib/AsmParser/LLParser.h b/llvm/lib/AsmParser/LLParser.h index ad169afb935..ec4a61b5498 100644 --- a/llvm/lib/AsmParser/LLParser.h +++ b/llvm/lib/AsmParser/LLParser.h @@ -339,6 +339,7 @@ namespace llvm { bool ParseFnAttributeValuePairs(AttrBuilder &B, std::vector<unsigned> &FwdRefAttrGrps, bool inAttrGrp, LocTy &BuiltinLoc); + bool ParseByValWithOptionalType(Type *&Result); // Module Summary Index Parsing. bool SkipModuleSummaryEntry(); |

