[llvm] r333604 - [LowerTypeTests] Discard extern_weak linkage for definitions

Vlad Tsyrklevich via llvm-commits llvm-commits at lists.llvm.org
Wed May 30 15:39:53 PDT 2018


Author: vlad.tsyrklevich
Date: Wed May 30 15:39:52 2018
New Revision: 333604

URL: http://llvm.org/viewvc/llvm-project?rev=333604&view=rev
Log:
[LowerTypeTests] Discard extern_weak linkage for definitions

Summary:
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)

Reviewers: pcc

Reviewed By: pcc

Subscribers: mehdi_amini, llvm-commits, kcc

Differential Revision: https://reviews.llvm.org/D47494

Added:
    llvm/trunk/test/Transforms/LowerTypeTests/pr37625.ll
Modified:
    llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp

Modified: llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp?rev=333604&r1=333603&r2=333604&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp Wed May 30 15:39:52 2018
@@ -1716,6 +1716,11 @@ bool LowerTypeTestsModule::lower() {
           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

Added: llvm/trunk/test/Transforms/LowerTypeTests/pr37625.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerTypeTests/pr37625.ll?rev=333604&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/LowerTypeTests/pr37625.ll (added)
+++ llvm/trunk/test/Transforms/LowerTypeTests/pr37625.ll Wed May 30 15:39:52 2018
@@ -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




More information about the llvm-commits mailing list