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
4 changes: 2 additions & 2 deletions llvm/lib/LTO/LTOBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM,
RegisterPassPlugins(Conf.PassPlugins, PB);

std::unique_ptr<TargetLibraryInfoImpl> TLII(
new TargetLibraryInfoImpl(TM->getTargetTriple()));
new TargetLibraryInfoImpl(TM->getTargetTriple(), TM->Options.VecLib));
if (Conf.Freestanding)
TLII->disableAllFunctions();
FAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); });
Expand Down Expand Up @@ -444,7 +444,7 @@ static void codegen(const Config &Conf, TargetMachine *TM,
// keep the pointer and may use it until their destruction. See #138194.
{
legacy::PassManager CodeGenPasses;
TargetLibraryInfoImpl TLII(Mod.getTargetTriple());
TargetLibraryInfoImpl TLII(Mod.getTargetTriple(), TM->Options.VecLib);
CodeGenPasses.add(new TargetLibraryInfoWrapperPass(TLII));
// No need to make index available if the module is empty.
// In theory these passes should not use the index for an empty
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/LTO/ThinLTOCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ static void optimizeModule(Module &TheModule, TargetMachine &TM,
PassBuilder PB(&TM, PTO, PGOOpt, &PIC);

std::unique_ptr<TargetLibraryInfoImpl> TLII(
new TargetLibraryInfoImpl(TM.getTargetTriple()));
new TargetLibraryInfoImpl(TM.getTargetTriple(), TM.Options.VecLib));
if (Freestanding)
TLII->disableAllFunctions();
FAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); });
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/LTO/UpdateCompilerUsed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class PreserveLibCallsAndAsmUsed {
// same names are added to llvm.compiler.used to prevent them from being
// deleted by optimizations.
void initializeLibCalls(const Module &TheModule) {
TargetLibraryInfoImpl TLII(TM.getTargetTriple());
TargetLibraryInfoImpl TLII(TM.getTargetTriple(), TM.Options.VecLib);
TargetLibraryInfo TLI(TLII);

// TargetLibraryInfo has info on C runtime library calls on the current
Expand Down
19 changes: 19 additions & 0 deletions llvm/test/LTO/AArch64/frem-scalable-veclib.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; RUN: opt -module-summary %s -o %t.bc
; RUN: llvm-lto2 run %t.bc -o %t.o -save-temps \
; RUN: -r %t.bc,compute,px \
; RUN: -mcpu=neoverse-v1 -O3 \
; RUN: -vector-library=ArmPL
; RUN: llvm-nm %t.o.1 | FileCheck %s

; This test verifies that the VecLib propagation in LTO prevents a crash
; when compiling scalable vector frem operations.

; CHECK: compute

target triple = "aarch64-unknown-linux-gnu"

define <vscale x 2 x double> @compute(<vscale x 2 x double> %a, <vscale x 2 x double> %b) {
entry:
%rem = frem <vscale x 2 x double> %a, %b
ret <vscale x 2 x double> %rem
}
24 changes: 24 additions & 0 deletions llvm/test/LTO/AArch64/veclib-armpl-lto.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
; RUN: llvm-as %s -o %t.bc
; RUN: llvm-lto -exported-symbol=compute -exported-symbol=armpl_vsinq_f64 -o %t.o %t.bc
; RUN: llvm-nm %t.o | FileCheck %s

; This test ensures that ArmPL vector library functions are preserved through
; the old LTO API (llvm-lto). TargetLibraryInfoImpl in LTO backend passes
; receive the VecLib parameter from TargetMachine Options.

; CHECK: armpl_vsinq_f64
; CHECK: compute

target triple = "aarch64-unknown-linux-gnu"

@llvm.compiler.used = appending global [1 x ptr] [ptr @armpl_vsinq_f64], section "llvm.metadata"

declare aarch64_vector_pcs <2 x double> @armpl_vsinq_f64(<2 x double>)

define void @compute(ptr %out, ptr %in) {
entry:
%v = load <2 x double>, ptr %in, align 16
%result = call aarch64_vector_pcs <2 x double> @armpl_vsinq_f64(<2 x double> %v)
store <2 x double> %result, ptr %out, align 16
ret void
}
26 changes: 26 additions & 0 deletions llvm/test/LTO/AArch64/veclib-armpl-lto2.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
; RUN: opt -module-summary %s -o %t.bc
; RUN: llvm-lto2 run -save-temps -o %t.o %t.bc \
; RUN: -r=%t.bc,compute,px \
; RUN: -r=%t.bc,armpl_vsinq_f64
; RUN: llvm-dis %t.o.1.5.precodegen.bc -o - | FileCheck %s

; This test ensures that ArmPL vector library functions are preserved through
; the new LTO API (llvm-lto2). TargetLibraryInfoImpl in LTO backend passes
; receive the VecLib parameter from TargetMachine Options.

; CHECK: @llvm.compiler.used = appending global [1 x ptr] [ptr @armpl_vsinq_f64]
; CHECK: declare aarch64_vector_pcs <2 x double> @armpl_vsinq_f64(<2 x double>)

target triple = "aarch64-unknown-linux-gnu"

@llvm.compiler.used = appending global [1 x ptr] [ptr @armpl_vsinq_f64], section "llvm.metadata"

declare aarch64_vector_pcs <2 x double> @armpl_vsinq_f64(<2 x double>)

define void @compute(ptr %out, ptr %in) {
entry:
%v = load <2 x double>, ptr %in, align 16
%result = call aarch64_vector_pcs <2 x double> @armpl_vsinq_f64(<2 x double> %v)
store <2 x double> %result, ptr %out, align 16
ret void
}
Loading