[llvm] r257493 - [ThinLTO] Handle an external call from an import to an alias in dest
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 12 09:48:44 PST 2016
Author: tejohnson
Date: Tue Jan 12 11:48:44 2016
New Revision: 257493
URL: http://llvm.org/viewvc/llvm-project?rev=257493&view=rev
Log:
[ThinLTO] Handle an external call from an import to an alias in dest
The findExternalCalls routine ignores calls to functions already
defined in the dest module. This was not handling the case where
the definition in the current module is actually an alias to a
function call.
Added:
llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport_alias.ll
llvm/trunk/test/Transforms/FunctionImport/funcimport_alias.ll
Modified:
llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp
Modified: llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp?rev=257493&r1=257492&r2=257493&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp Tue Jan 12 11:48:44 2016
@@ -133,6 +133,8 @@ static void findExternalCalls(const Modu
// Ignore functions already present in the destination module
auto *SrcGV = DestModule.getNamedValue(ImportedName);
if (SrcGV) {
+ if (GlobalAlias *SGA = dyn_cast<GlobalAlias>(SrcGV))
+ SrcGV = SGA->getBaseObject();
assert(isa<Function>(SrcGV) && "Name collision during import");
if (!cast<Function>(SrcGV)->isDeclaration()) {
DEBUG(dbgs() << DestModule.getModuleIdentifier() << ": Ignoring "
Added: llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport_alias.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport_alias.ll?rev=257493&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport_alias.ll (added)
+++ llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport_alias.ll Tue Jan 12 11:48:44 2016
@@ -0,0 +1,7 @@
+declare void @analias()
+
+define void @callanalias() #0 {
+entry:
+ call void @analias()
+ ret void
+}
Added: llvm/trunk/test/Transforms/FunctionImport/funcimport_alias.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionImport/funcimport_alias.ll?rev=257493&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/FunctionImport/funcimport_alias.ll (added)
+++ llvm/trunk/test/Transforms/FunctionImport/funcimport_alias.ll Tue Jan 12 11:48:44 2016
@@ -0,0 +1,25 @@
+; Do setup work for all below tests: generate bitcode and combined index
+; RUN: llvm-as -function-summary %s -o %t.bc
+; RUN: llvm-as -function-summary %p/Inputs/funcimport_alias.ll -o %t2.bc
+; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc %t3.bc
+
+; Do the import now. Ensures that the importer handles an external call
+; from imported callanalias() to a function that is defined already in
+; the dest module, but as an alias.
+; RUN: opt -function-import -summary-file %t3.thinlto.bc %s -S | FileCheck %s
+
+define i32 @main() #0 {
+entry:
+ call void @callanalias()
+ ret i32 0
+}
+
+ at analias = alias void (), void ()* @globalfunc
+
+define void @globalfunc() #0 {
+entry:
+ ret void
+}
+
+declare void @callanalias() #1
+; CHECK-DAG: define available_externally void @callanalias()
More information about the llvm-commits
mailing list