diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2017-08-10 01:07:44 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2017-08-10 01:07:44 +0000 |
commit | 9e6aa3e0fefb3f5df241ba5175c5e0907199bb01 (patch) | |
tree | 81a8ddac77b481ef700ed63ccbe7899d824f5633 /lib/Linker | |
parent | 3c1a9a04858a6ea0558fcbbd480df662fe400c54 (diff) |
Linker: Create a function declaration when moving a non-prevailing alias of function type.
We were previously creating a global variable of function type,
which is invalid IR. This issue was exposed by r304690, in which we
started asserting that global variables were of a valid type.
Fixes PR33462.
Differential Revision: https://reviews.llvm.org/D36438
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310543 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker')
-rw-r--r-- | lib/Linker/IRMover.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Linker/IRMover.cpp b/lib/Linker/IRMover.cpp index f486e525b5e..ee067a912e3 100644 --- a/lib/Linker/IRMover.cpp +++ b/lib/Linker/IRMover.cpp @@ -640,6 +640,10 @@ GlobalValue *IRLinker::copyGlobalValueProto(const GlobalValue *SGV, } else { if (ForDefinition) NewGV = copyGlobalAliasProto(cast<GlobalAlias>(SGV)); + else if (SGV->getValueType()->isFunctionTy()) + NewGV = + Function::Create(cast<FunctionType>(TypeMap.get(SGV->getValueType())), + GlobalValue::ExternalLinkage, SGV->getName(), &DstM); else NewGV = new GlobalVariable( DstM, TypeMap.get(SGV->getValueType()), |