diff options
author | Tom Stellard <tstellar@redhat.com> | 2017-11-14 19:47:47 +0000 |
---|---|---|
committer | Tom Stellard <tstellar@redhat.com> | 2017-11-14 19:47:47 +0000 |
commit | 0830004ba84494e664b154beddc1d896c7456da6 (patch) | |
tree | eaa546c17c78aeafa34d39cf9666d3fa8445ba6d | |
parent | a08fd1409b2a4126e537de20a8b83a782b878095 (diff) | |
download | llvm-0830004ba84494e664b154beddc1d896c7456da6.zip llvm-0830004ba84494e664b154beddc1d896c7456da6.tar.gz llvm-0830004ba84494e664b154beddc1d896c7456da6.tar.bz2 |
Merging r310543:
------------------------------------------------------------------------
r310543 | pcc | 2017-08-09 18:07:44 -0700 (Wed, 09 Aug 2017) | 9 lines
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
------------------------------------------------------------------------
llvm-svn: 318181
-rw-r--r-- | llvm/lib/Linker/IRMover.cpp | 4 | ||||
-rw-r--r-- | llvm/test/LTO/Resolution/X86/function-alias-non-prevailing.ll | 17 |
2 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index f486e52..ee067a9 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/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()), diff --git a/llvm/test/LTO/Resolution/X86/function-alias-non-prevailing.ll b/llvm/test/LTO/Resolution/X86/function-alias-non-prevailing.ll new file mode 100644 index 0000000..ab2cefe --- /dev/null +++ b/llvm/test/LTO/Resolution/X86/function-alias-non-prevailing.ll @@ -0,0 +1,17 @@ +; RUN: llvm-as -o %t %s +; RUN: llvm-lto2 run %t -r %t,foo, -r %t,baz,p -o %t2 -save-temps +; RUN: llvm-dis -o - %t2.0.0.preopt.bc | FileCheck %s + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64--fuchsia" + +; CHECK: declare void @foo() +@foo = weak alias void(), void()* @bar + +define internal void @bar() { + ret void +} + +define void()* @baz() { + ret void()* @foo +} |