[llvm] ee7d315 - [DCE] Always get TargetLibraryInfo
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 17 20:41:23 PST 2020
Author: Arthur Eubanks
Date: 2020-11-17T20:41:05-08:00
New Revision: ee7d315cd939017db6ca6db4827b579e8bd85ec1
URL: https://github.com/llvm/llvm-project/commit/ee7d315cd939017db6ca6db4827b579e8bd85ec1
DIFF: https://github.com/llvm/llvm-project/commit/ee7d315cd939017db6ca6db4827b579e8bd85ec1.diff
LOG: [DCE] Always get TargetLibraryInfo
I don't see any reason not to unconditionally retrieve TLI, it's fairly
cheap.
Fixes calls-errno.ll under NPM.
Reviewed By: asbirlea
Differential Revision: https://reviews.llvm.org/D91476
Added:
Modified:
llvm/lib/Transforms/Scalar/DCE.cpp
llvm/test/Transforms/DCE/calls-errno.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/DCE.cpp b/llvm/lib/Transforms/Scalar/DCE.cpp
index badf0e1503b6..d55adf7c2d12 100644
--- a/llvm/lib/Transforms/Scalar/DCE.cpp
+++ b/llvm/lib/Transforms/Scalar/DCE.cpp
@@ -143,7 +143,7 @@ static bool eliminateDeadCode(Function &F, TargetLibraryInfo *TLI) {
}
PreservedAnalyses DCEPass::run(Function &F, FunctionAnalysisManager &AM) {
- if (!eliminateDeadCode(F, AM.getCachedResult<TargetLibraryAnalysis>(F)))
+ if (!eliminateDeadCode(F, &AM.getResult<TargetLibraryAnalysis>(F)))
return PreservedAnalyses::all();
PreservedAnalyses PA;
@@ -162,13 +162,14 @@ struct DCELegacyPass : public FunctionPass {
if (skipFunction(F))
return false;
- auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
- TargetLibraryInfo *TLI = TLIP ? &TLIP->getTLI(F) : nullptr;
+ TargetLibraryInfo *TLI =
+ &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
return eliminateDeadCode(F, TLI);
}
void getAnalysisUsage(AnalysisUsage &AU) const override {
+ AU.addRequired<TargetLibraryInfoWrapperPass>();
AU.setPreservesCFG();
}
};
diff --git a/llvm/test/Transforms/DCE/calls-errno.ll b/llvm/test/Transforms/DCE/calls-errno.ll
index 376b8d1e5882..77f048c03aa0 100644
--- a/llvm/test/Transforms/DCE/calls-errno.ll
+++ b/llvm/test/Transforms/DCE/calls-errno.ll
@@ -1,4 +1,5 @@
; RUN: opt < %s -dce -S | FileCheck %s
+; RUN: opt < %s -passes=dce -S | FileCheck %s
declare double @acos(double) nounwind
declare double @asin(double) nounwind
More information about the llvm-commits
mailing list