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/Bitcode | |
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/Bitcode')
-rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.cpp | 9 | ||||
-rw-r--r-- | lib/Bitcode/Writer/BitcodeWriter.cpp | 3 |
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 178eaf082e..74e8439141 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2994,8 +2994,13 @@ error_code BitcodeReader::ParseFunctionBody(Function *F) { I = CallInst::Create(Callee, Args); InstructionList.push_back(I); cast<CallInst>(I)->setCallingConv( - static_cast<CallingConv::ID>(CCInfo>>1)); - cast<CallInst>(I)->setTailCall(CCInfo & 1); + static_cast<CallingConv::ID>((~(1U << 14) & CCInfo) >> 1)); + CallInst::TailCallKind TCK = CallInst::TCK_None; + if (CCInfo & 1) + TCK = CallInst::TCK_Tail; + if (CCInfo & (1 << 14)) + TCK = CallInst::TCK_MustTail; + cast<CallInst>(I)->setTailCallKind(TCK); cast<CallInst>(I)->setAttributes(PAL); break; } diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index 62dba41460..92965fa7e4 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -1469,7 +1469,8 @@ static void WriteInstruction(const Instruction &I, unsigned InstID, Code = bitc::FUNC_CODE_INST_CALL; Vals.push_back(VE.getAttributeID(CI.getAttributes())); - Vals.push_back((CI.getCallingConv() << 1) | unsigned(CI.isTailCall())); + Vals.push_back((CI.getCallingConv() << 1) | unsigned(CI.isTailCall()) | + unsigned(CI.isMustTailCall()) << 14); PushValueAndType(CI.getCalledValue(), InstID, Vals, VE); // Callee // Emit value #'s for the fixed parameters. |