diff options
author | Vedant Kumar <vsk@apple.com> | 2019-01-28 19:13:37 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2019-01-28 19:13:37 +0000 |
commit | 1c3694a4d47be9dcf635d2dda6f70928a3bd2f25 (patch) | |
tree | 9a9e679b2013430df6079981ba5f3d16e9e7bbb4 /llvm/lib/Transforms/Utils/CodeExtractor.cpp | |
parent | 4f8c82281daf583f38a383cf54fbf3e6a48d653c (diff) | |
download | bcm5719-llvm-1c3694a4d47be9dcf635d2dda6f70928a3bd2f25.tar.gz bcm5719-llvm-1c3694a4d47be9dcf635d2dda6f70928a3bd2f25.zip |
[CodeExtractor] Add support for the `swifterror` attribute
When passing a `swifterror` argument or alloca as an input to an
extraction region, mark the input parameter `swifterror`.
llvm-svn: 352408
Diffstat (limited to 'llvm/lib/Transforms/Utils/CodeExtractor.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/CodeExtractor.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp index 03e2b9db078..da227570179 100644 --- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp +++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp @@ -961,11 +961,18 @@ CallInst *CodeExtractor::emitCallAndSwitchStatement(Function *newFunction, CallInst *call = nullptr; // Add inputs as params, or to be filled into the struct - for (Value *input : inputs) + unsigned ArgNo = 0; + SmallVector<unsigned, 1> SwiftErrorArgs; + for (Value *input : inputs) { if (AggregateArgs) StructValues.push_back(input); - else + else { params.push_back(input); + if (input->isSwiftError()) + SwiftErrorArgs.push_back(ArgNo); + } + ++ArgNo; + } // Create allocas for the outputs for (Value *output : outputs) { @@ -1021,6 +1028,12 @@ CallInst *CodeExtractor::emitCallAndSwitchStatement(Function *newFunction, } codeReplacer->getInstList().push_back(call); + // Set swifterror parameter attributes. + for (unsigned SwiftErrArgNo : SwiftErrorArgs) { + call->addParamAttr(SwiftErrArgNo, Attribute::SwiftError); + newFunction->addParamAttr(SwiftErrArgNo, Attribute::SwiftError); + } + Function::arg_iterator OutputArgBegin = newFunction->arg_begin(); unsigned FirstOut = inputs.size(); if (!AggregateArgs) |