Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion llvm/lib/LTO/LTO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ static cl::opt<bool>

extern cl::opt<bool> CodeGenDataThinLTOTwoRounds;

extern cl::opt<bool> ForceImportAll;

namespace llvm {
/// Enable global value internalization in LTO.
cl::opt<bool> EnableLTOInternalization(
Expand Down Expand Up @@ -406,8 +408,11 @@ static void thinLTOResolvePrevailingGUID(
Visibility = S->getVisibility();
}
// Alias and aliasee can't be turned into available_externally.
// When force-import-all is used, it indicates that object linking is not
// supported by the target. In this case, we can't change the linkage as
// well in case the global is converted to declaration.
else if (!isa<AliasSummary>(S.get()) &&
!GlobalInvolvedWithAlias.count(S.get()))
!GlobalInvolvedWithAlias.count(S.get()) && !ForceImportAll)
S->setLinkage(GlobalValue::AvailableExternallyLinkage);

// For ELF, set visibility to the computed visibility from summaries. We
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Transforms/IPO/FunctionImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ STATISTIC(NumImportedModules, "Number of modules imported from");
STATISTIC(NumDeadSymbols, "Number of dead stripped symbols in index");
STATISTIC(NumLiveSymbols, "Number of live symbols in index");

cl::opt<bool>
ForceImportAll("force-import-all", cl::init(false), cl::Hidden,
cl::desc("Import functions with noinline attribute"));

/// Limit on instruction count of imported functions.
static cl::opt<unsigned> ImportInstrLimit(
"import-instr-limit", cl::init(100), cl::Hidden, cl::value_desc("N"),
Expand All @@ -80,10 +84,6 @@ static cl::opt<int> ImportCutoff(
"import-cutoff", cl::init(-1), cl::Hidden, cl::value_desc("N"),
cl::desc("Only import first N functions if N>=0 (default -1)"));

static cl::opt<bool>
ForceImportAll("force-import-all", cl::init(false), cl::Hidden,
cl::desc("Import functions with noinline attribute"));

static cl::opt<float>
ImportInstrFactor("import-instr-evolution-factor", cl::init(0.7),
cl::Hidden, cl::value_desc("x"),
Expand Down
13 changes: 13 additions & 0 deletions llvm/test/ThinLTO/AMDGPU/Inputs/in-f1.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
define void @f1(ptr %v) #0 {
entry:
call void @weak_common(ptr %v)
ret void
}

define weak hidden void @weak_common(ptr %v) #0 {
entry:
store i32 12345, ptr %v
ret void
}

attributes #0 = { noinline }
27 changes: 27 additions & 0 deletions llvm/test/ThinLTO/AMDGPU/force-import-all.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
; RUN: opt -mtriple=amdgcn-amd-amdhsa -module-summary %s -o %t.main.bc
; RUN: opt -mtriple=amdgcn-amd-amdhsa -module-summary %p/Inputs/in-f1.ll -o %t.in.bc
; RUN: llvm-lto -thinlto-action=run -force-import-all %t.main.bc %t.in.bc --thinlto-save-temps=%t.2.
; RUN: llvm-dis %t.2.0.3.imported.bc -o - | FileCheck --check-prefix=MOD1 %s
; RUN: llvm-dis %t.2.1.3.imported.bc -o - | FileCheck --check-prefix=MOD2 %s

define void @f0(ptr %p) #0 {
entry:
call void @f1(ptr %p)
ret void
}

define weak hidden void @weak_common(ptr %v) #0 {
entry:
store i32 12345, ptr %v
ret void
}

declare void @f1(ptr)

attributes #0 = { noinline }

; MOD1: define weak hidden void @weak_common
; MOD1: define available_externally void @f1

; MOD2: define void @f1
; MOD2: define weak hidden void @weak_common
2 changes: 2 additions & 0 deletions llvm/test/ThinLTO/AMDGPU/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
if not "AMDGPU" in config.root.targets:
config.unsupported = True