[PATCH] D47494: [LowerTypeTests] Discard extern_weak linkage for definitions

Vlad Tsyrklevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 29 13:03:26 PDT 2018


vlad.tsyrklevich created this revision.
vlad.tsyrklevich added a reviewer: pcc.
Herald added subscribers: llvm-commits, mehdi_amini.

Fix PR37625. It's possible for an extern_weak declaration to be emitted
to the merged module when a definition exists in the ThinLTO portion of
the build; discard the linkage on the declaration in that case.
(otherwise we copy the linkage to the alias to the jumptable and fail)


Repository:
  rL LLVM

https://reviews.llvm.org/D47494

Files:
  lib/Transforms/IPO/LowerTypeTests.cpp
  test/Transforms/LowerTypeTests/pr37625.ll


Index: test/Transforms/LowerTypeTests/pr37625.ll
===================================================================
--- /dev/null
+++ test/Transforms/LowerTypeTests/pr37625.ll
@@ -0,0 +1,14 @@
+; RUN: opt -S -lowertypetests -lowertypetests-summary-action=export -lowertypetests-read-summary=%S/Inputs/use-typeid1-typeid2.yaml -lowertypetests-write-summary=%t < %s | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare !type !2 extern_weak void @h(i8)
+
+!cfi.functions = !{!0, !1}
+
+!0 = !{!"h", i8 2, !2}
+!1 = !{!"h", i8 0, !2}
+!2 = !{i64 0, !"typeid1"}
+
+; CHECK-DAG: @h = alias void (i8), bitcast
Index: lib/Transforms/IPO/LowerTypeTests.cpp
===================================================================
--- lib/Transforms/IPO/LowerTypeTests.cpp
+++ lib/Transforms/IPO/LowerTypeTests.cpp
@@ -1716,6 +1716,11 @@
           F->clearMetadata();
         }
 
+        // Update the linkage for extern_weak declarations when a definition
+        // exists.
+        if (Linkage == CFL_Definition && F->hasExternalWeakLinkage())
+          F->setLinkage(GlobalValue::ExternalLinkage);
+
         // If the function in the full LTO module is a declaration, replace its
         // type metadata with the type metadata we found in cfi.functions. That
         // metadata is presumed to be more accurate than the metadata attached


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47494.148970.patch
Type: text/x-patch
Size: 1417 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180529/28573741/attachment.bin>


More information about the llvm-commits mailing list