[PATCH] D36438: Linker: Create a function declaration when moving a non-prevailing alias of function type.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 9 18:08:42 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL310543: Linker: Create a function declaration when moving a non-prevailing alias of… (authored by pcc).

Changed prior to commit:
  https://reviews.llvm.org/D36438?vs=110123&id=110512#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36438

Files:
  llvm/trunk/lib/Linker/IRMover.cpp
  llvm/trunk/test/LTO/Resolution/X86/function-alias-non-prevailing.ll


Index: llvm/trunk/test/LTO/Resolution/X86/function-alias-non-prevailing.ll
===================================================================
--- llvm/trunk/test/LTO/Resolution/X86/function-alias-non-prevailing.ll
+++ llvm/trunk/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()
+ at foo = weak alias void(), void()* @bar
+
+define internal void @bar() {
+  ret void
+}
+
+define void()* @baz() {
+  ret void()* @foo
+}
Index: llvm/trunk/lib/Linker/IRMover.cpp
===================================================================
--- llvm/trunk/lib/Linker/IRMover.cpp
+++ llvm/trunk/lib/Linker/IRMover.cpp
@@ -640,6 +640,10 @@
   } 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()),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36438.110512.patch
Type: text/x-patch
Size: 1348 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170810/c90e1818/attachment.bin>


More information about the llvm-commits mailing list