summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Transforms/IPO/LowerTypeTests.cpp5
-rw-r--r--llvm/test/Transforms/LowerTypeTests/pr37625.ll14
2 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index d2545af8502..1e4d3d37aae 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -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
diff --git a/llvm/test/Transforms/LowerTypeTests/pr37625.ll b/llvm/test/Transforms/LowerTypeTests/pr37625.ll
new file mode 100644
index 00000000000..e4b704eadb3
--- /dev/null
+++ b/llvm/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
OpenPOWER on IntegriCloud