[PATCH] D67945: LowerTypeTests: Rename local functions to avoid collisions with identically named functions in ThinLTO modules.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 23 18:08:13 PDT 2019
pcc created this revision.
pcc added a reviewer: eugenis.
Herald added subscribers: dexonsmith, hiraditya, inglorion.
Herald added a project: LLVM.
Without this we can encounter link errors or incorrect behaviour
at runtime as a result of the wrong function being referenced.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D67945
Files:
llvm/lib/Transforms/IPO/LowerTypeTests.cpp
llvm/test/Transforms/LowerTypeTests/export-rename-local.ll
Index: llvm/test/Transforms/LowerTypeTests/export-rename-local.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/LowerTypeTests/export-rename-local.ll
@@ -0,0 +1,15 @@
+; RUN: opt -S %s -lowertypetests -lowertypetests-summary-action=export -lowertypetests-read-summary=%S/Inputs/exported-funcs.yaml | FileCheck %s
+
+; CHECK: define internal void @external_addrtaken.1()
+; CHECK: declare {{.*}} void @external_addrtaken.cfi()
+
+target triple = "x86_64-unknown-linux"
+
+define internal void @external_addrtaken() !type !1 {
+ ret void
+}
+
+!cfi.functions = !{!0}
+
+!0 = !{!"external_addrtaken", i8 0, !1}
+!1 = !{i64 0, !"typeid1"}
Index: llvm/lib/Transforms/IPO/LowerTypeTests.cpp
===================================================================
--- llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -1887,6 +1887,14 @@
CfiFunctionLinkage Linkage = P.second.Linkage;
MDNode *FuncMD = P.second.FuncMD;
Function *F = M.getFunction(FunctionName);
+ if (F && F->hasLocalLinkage()) {
+ // Locally defined function that happens to have the same name as a
+ // function defined in a ThinLTO module. Rename it to move it out of
+ // the way of the external reference that we're about to create.
+ F->setName(F->getName() + ".1");
+ F = nullptr;
+ }
+
if (!F)
F = Function::Create(
FunctionType::get(Type::getVoidTy(M.getContext()), false),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67945.221452.patch
Type: text/x-patch
Size: 1565 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190924/f58bba21/attachment.bin>
More information about the llvm-commits
mailing list