summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorBrian Gesiak <modocache@gmail.com>2018-04-02 23:39:40 +0000
committerBrian Gesiak <modocache@gmail.com>2018-04-02 23:39:40 +0000
commit64521bed0d7f44ab06fc7ae2f7bc05955c7211fd (patch)
tree23d52f870ca16847e1967b8fe755fc2bf860bcb9 /llvm/lib
parentbae4856d31d7316e854e4222b224cf6ca26b9aa2 (diff)
downloadbcm5719-llvm-64521bed0d7f44ab06fc7ae2f7bc05955c7211fd.tar.gz
bcm5719-llvm-64521bed0d7f44ab06fc7ae2f7bc05955c7211fd.zip
[Coroutines] Avoid assert splitting hidden coros
Summary: When attempting to split a coroutine with 'hidden' visibility (for example, a C++ coroutine that is inlined when compiled with the option '-fvisibility-inlines-hidden'), LLVM would hit an assertion in include/llvm/IR/GlobalValue.h:240: "local linkage requires default visibility". The issue is that the visibility is copied from the source of the function split in the `CloneFunctionInto` function, but the linkage is not. To fix, create the new function first with external linkage, then copy the linkage from the original function *after* `CloneFunctionInto` is called. Since `GlobalValue::setLinkage` in turn calls `maybeSetDsoLocal`, the explicit call to `setDSOLocal` can be removed in CoroSplit.cpp. Test Plan: check-llvm Reviewers: GorNishanov, lewissbaker, EricWF, majnemer, rnk Reviewed By: rnk Subscribers: llvm-commits, eric_niebler Differential Revision: https://reviews.llvm.org/D44185 llvm-svn: 329033
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Coroutines/CoroSplit.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index f122fe6f079..6ab56f25e8b 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -250,7 +250,7 @@ static Function *createClone(Function &F, Twine Suffix, coro::Shape &Shape,
auto *FnTy = cast<FunctionType>(FnPtrTy->getElementType());
Function *NewF =
- Function::Create(FnTy, GlobalValue::LinkageTypes::InternalLinkage,
+ Function::Create(FnTy, GlobalValue::LinkageTypes::ExternalLinkage,
F.getName() + Suffix, M);
NewF->addParamAttr(0, Attribute::NonNull);
NewF->addParamAttr(0, Attribute::NoAlias);
@@ -265,7 +265,7 @@ static Function *createClone(Function &F, Twine Suffix, coro::Shape &Shape,
SmallVector<ReturnInst *, 4> Returns;
CloneFunctionInto(NewF, &F, VMap, /*ModuleLevelChanges=*/true, Returns);
- NewF->setDSOLocal(true);
+ NewF->setLinkage(GlobalValue::LinkageTypes::InternalLinkage);
// Remove old returns.
for (ReturnInst *Return : Returns)
OpenPOWER on IntegriCloud