diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-04-24 20:14:34 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-04-24 20:14:34 +0000 |
commit | 710c1a449dd7bee747ecf9c344a6f6d5461a158d (patch) | |
tree | 112a9b219c12b5a90996ac964c861b3526f25266 /lib/AsmParser/LLParser.cpp | |
parent | 870200a833584ca4e05f5d1258265451d8b871eb (diff) | |
download | llvm-710c1a449dd7bee747ecf9c344a6f6d5461a158d.tar.gz llvm-710c1a449dd7bee747ecf9c344a6f6d5461a158d.tar.bz2 llvm-710c1a449dd7bee747ecf9c344a6f6d5461a158d.tar.xz |
Add 'musttail' marker to call instructions
This is similar to the 'tail' marker, except that it guarantees that
tail call optimization will occur. It also comes with convervative IR
verification rules that ensure that tail call optimization is possible.
Reviewers: nicholas
Differential Revision: http://llvm-reviews.chandlerc.com/D3240
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207143 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/LLParser.cpp')
-rw-r--r-- | lib/AsmParser/LLParser.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 7e11aecd92..56422393e4 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -3367,8 +3367,10 @@ int LLParser::ParseInstruction(Instruction *&Inst, BasicBlock *BB, case lltok::kw_shufflevector: return ParseShuffleVector(Inst, PFS); case lltok::kw_phi: return ParsePHI(Inst, PFS); case lltok::kw_landingpad: return ParseLandingPad(Inst, PFS); - case lltok::kw_call: return ParseCall(Inst, PFS, false); - case lltok::kw_tail: return ParseCall(Inst, PFS, true); + // Call. + case lltok::kw_call: return ParseCall(Inst, PFS, CallInst::TCK_None); + case lltok::kw_tail: return ParseCall(Inst, PFS, CallInst::TCK_Tail); + case lltok::kw_musttail: return ParseCall(Inst, PFS, CallInst::TCK_MustTail); // Memory. case lltok::kw_alloca: return ParseAlloc(Inst, PFS); case lltok::kw_load: return ParseLoad(Inst, PFS); @@ -3984,10 +3986,14 @@ bool LLParser::ParseLandingPad(Instruction *&Inst, PerFunctionState &PFS) { } /// ParseCall -/// ::= 'tail'? 'call' OptionalCallingConv OptionalAttrs Type Value +/// ::= 'call' OptionalCallingConv OptionalAttrs Type Value +/// ParameterList OptionalAttrs +/// ::= 'tail' 'call' OptionalCallingConv OptionalAttrs Type Value +/// ParameterList OptionalAttrs +/// ::= 'musttail' 'call' OptionalCallingConv OptionalAttrs Type Value /// ParameterList OptionalAttrs bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS, - bool isTail) { + CallInst::TailCallKind TCK) { AttrBuilder RetAttrs, FnAttrs; std::vector<unsigned> FwdRefAttrGrps; LocTy BuiltinLoc; @@ -3998,7 +4004,8 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS, SmallVector<ParamInfo, 16> ArgList; LocTy CallLoc = Lex.getLoc(); - if ((isTail && ParseToken(lltok::kw_call, "expected 'tail call'")) || + if ((TCK != CallInst::TCK_None && + ParseToken(lltok::kw_call, "expected 'tail call'")) || ParseOptionalCallingConv(CC) || ParseOptionalReturnAttrs(RetAttrs) || ParseType(RetType, RetTypeLoc, true /*void allowed*/) || @@ -4074,7 +4081,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS, AttributeSet PAL = AttributeSet::get(Context, Attrs); CallInst *CI = CallInst::Create(Callee, Args); - CI->setTailCall(isTail); + CI->setTailCallKind(TCK); CI->setCallingConv(CC); CI->setAttributes(PAL); ForwardRefAttrGroups[CI] = FwdRefAttrGrps; |