Skip to content

Commit cdb41e4

Browse files
authored
PlaceSafepoints: Fix using default constructed TargetLibraryInfo (#92411)
1 parent ee407e1 commit cdb41e4

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

llvm/include/llvm/Analysis/TargetLibraryInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,10 @@ class TargetLibraryInfoWrapperPass : public ImmutablePass {
633633
explicit TargetLibraryInfoWrapperPass(const Triple &T);
634634
explicit TargetLibraryInfoWrapperPass(const TargetLibraryInfoImpl &TLI);
635635

636+
// FIXME: This should be removed when PlaceSafepoints is fixed to not create a
637+
// PassManager inside a pass.
638+
explicit TargetLibraryInfoWrapperPass(const TargetLibraryInfo &TLI);
639+
636640
TargetLibraryInfo &getTLI(const Function &F) {
637641
FunctionAnalysisManager DummyFAM;
638642
TLI = TLA.run(F, DummyFAM);

llvm/lib/Analysis/TargetLibraryInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,10 @@ TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(
13831383
initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
13841384
}
13851385

1386+
TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(
1387+
const TargetLibraryInfo &TLIOther)
1388+
: TargetLibraryInfoWrapperPass(*TLIOther.Impl) {}
1389+
13861390
AnalysisKey TargetLibraryAnalysis::Key;
13871391

13881392
// Register the basic pass.

llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ bool PlaceSafepointsPass::runImpl(Function &F, const TargetLibraryInfo &TLI) {
288288
// with for the moment.
289289
legacy::FunctionPassManager FPM(F.getParent());
290290
bool CanAssumeCallSafepoints = enableCallSafepoints(F);
291+
292+
FPM.add(new TargetLibraryInfoWrapperPass(TLI));
291293
auto *PBS = new PlaceBackedgeSafepointsLegacyPass(CanAssumeCallSafepoints);
292294
FPM.add(PBS);
293295
FPM.run(F);

llvm/test/Transforms/PlaceSafepoints/libcall.ll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
; RUN: opt -S -passes=place-safepoints < %s | FileCheck %s
1+
; RUN: opt -S -passes=place-safepoints < %s | FileCheck -check-prefixes=CHECK,WITHLDEXPF %s
2+
; RUN: opt -S -passes=place-safepoints -disable-builtin=ldexp < %s | FileCheck %s
3+
24

35
; Libcalls will not contain a safepoint poll, so check that we insert
46
; a safepoint in a loop containing a libcall.
@@ -17,7 +19,8 @@ loop:
1719
; CHECK-NEXT: %x_loop = phi double [ %x, %entry ], [ %x_exp, %loop ]
1820
; CHECK-NEXT: %x_exp = call double @ldexp(double %x_loop, i32 5)
1921
; CHECK-NEXT: %done = fcmp ogt double %x_exp, 1.5
20-
; CHECK-NEXT: call void @do_safepoint
22+
; WITHLDEXPF-NEXT: call void @do_safepoint
23+
; CHECK-NEXT: br
2124
%x_loop = phi double [ %x, %entry ], [ %x_exp, %loop ]
2225
%x_exp = call double @ldexp(double %x_loop, i32 5) nounwind readnone
2326
%done = fcmp ogt double %x_exp, 1.5

0 commit comments

Comments
 (0)