[llvm] r313230 - Revert "Invoke GetInlineCost for legality check before inline functions in SampleProfileLoader."
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 13 22:40:33 PDT 2017
Author: vitalybuka
Date: Wed Sep 13 22:40:33 2017
New Revision: 313230
URL: http://llvm.org/viewvc/llvm-project?rev=313230&view=rev
Log:
Revert "Invoke GetInlineCost for legality check before inline functions in SampleProfileLoader."
Patch introduced uninitialized value.
This reverts commit r313195.
Modified:
llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
llvm/trunk/test/Transforms/SampleProfile/Inputs/einline.prof
llvm/trunk/test/Transforms/SampleProfile/early-inline.ll
Modified: llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=313230&r1=313229&r2=313230&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp Wed Sep 13 22:40:33 2017
@@ -28,11 +28,9 @@
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/AssumptionCache.h"
-#include "llvm/Analysis/InlineCost.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/OptimizationDiagnosticInfo.h"
#include "llvm/Analysis/PostDominators.h"
-#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DiagnosticInfo.h"
@@ -150,12 +148,10 @@ class SampleProfileLoader {
public:
SampleProfileLoader(
StringRef Name,
- std::function<AssumptionCache &(Function &)> GetAssumptionCache,
- std::function<TargetTransformInfo &(Function &)> GetTargetTransformInfo)
+ std::function<AssumptionCache &(Function &)> GetAssumptionCache)
: DT(nullptr), PDT(nullptr), LI(nullptr), GetAC(GetAssumptionCache),
- GetTTI(GetTargetTransformInfo), Reader(), Samples(nullptr),
- Filename(Name), ProfileIsValid(false), TotalCollectedSamples(0),
- ORE(nullptr) {}
+ Reader(), Samples(nullptr), Filename(Name), ProfileIsValid(false),
+ TotalCollectedSamples(0), ORE(nullptr) {}
bool doInitialization(Module &M);
bool runOnModule(Module &M, ModuleAnalysisManager *AM);
@@ -229,7 +225,6 @@ protected:
std::unique_ptr<LoopInfo> LI;
std::function<AssumptionCache &(Function &)> GetAC;
- std::function<TargetTransformInfo &(Function &)> GetTTI;
/// \brief Predecessors for each basic block in the CFG.
BlockEdgeMap Predecessors;
@@ -270,11 +265,8 @@ public:
: ModulePass(ID), SampleLoader(Name,
[&](Function &F) -> AssumptionCache & {
return ACT->getAssumptionCache(F);
- },
- [&](Function &F) -> TargetTransformInfo & {
- return TTIWP->getTTI(F);
}),
- ACT(nullptr), TTIWP(nullptr) {
+ ACT(nullptr) {
initializeSampleProfileLoaderLegacyPassPass(
*PassRegistry::getPassRegistry());
}
@@ -289,13 +281,11 @@ public:
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired<AssumptionCacheTracker>();
- AU.addRequired<TargetTransformInfoWrapperPass>();
}
private:
SampleProfileLoader SampleLoader;
AssumptionCacheTracker *ACT;
- TargetTransformInfoWrapperPass *TTIWP;
};
/// Return true if the given callsite is hot wrt to its caller.
@@ -757,25 +747,9 @@ bool SampleProfileLoader::inlineHotFunct
Samples->getTotalSamples() * SampleProfileHotThreshold / 100);
continue;
}
- CallSite CS(DI);
DebugLoc DLoc = I->getDebugLoc();
BasicBlock *BB = I->getParent();
- InlineParams Params;
- Params.ComputeFullInlineCost = true;
- // Checks if there is anything in the reachable portion of the callee at
- // this callsite that makes this inlining potentially illegal. Need to
- // set ComputeFullInlineCost, otherwise getInlineCost may return early
- // when cost exceeds threshold without checking all IRs in the callee.
- // The acutal cost does not matter because we only checks isNever() to
- // see if it is legal to inline the callsite.
- InlineCost Cost = getInlineCost(CS, Params, GetTTI(*CalledFunction), GetAC,
- None, nullptr, nullptr);
- if (Cost.isNever()) {
- ORE->emit(OptimizationRemark(DEBUG_TYPE, "Not inline", DLoc, BB)
- << "incompatible inlining");
- continue;
- }
- if (InlineFunction(CS, IFI)) {
+ if (InlineFunction(CallSite(DI), IFI)) {
LocalChanged = true;
// The call to InlineFunction erases DI, so we can't pass it here.
ORE->emit(OptimizationRemark(DEBUG_TYPE, "HotInline", DLoc, BB)
@@ -1444,7 +1418,6 @@ char SampleProfileLoaderLegacyPass::ID =
INITIALIZE_PASS_BEGIN(SampleProfileLoaderLegacyPass, "sample-profile",
"Sample Profile loader", false, false)
INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
-INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass)
INITIALIZE_PASS_END(SampleProfileLoaderLegacyPass, "sample-profile",
"Sample Profile loader", false, false)
@@ -1510,7 +1483,6 @@ bool SampleProfileLoader::runOnModule(Mo
bool SampleProfileLoaderLegacyPass::runOnModule(Module &M) {
ACT = &getAnalysis<AssumptionCacheTracker>();
- TTIWP = &getAnalysis<TargetTransformInfoWrapperPass>();
return SampleLoader.runOnModule(M, nullptr);
}
@@ -1540,13 +1512,10 @@ PreservedAnalyses SampleProfileLoaderPas
auto GetAssumptionCache = [&](Function &F) -> AssumptionCache & {
return FAM.getResult<AssumptionAnalysis>(F);
};
- auto GetTTI = [&](Function &F) -> TargetTransformInfo & {
- return FAM.getResult<TargetIRAnalysis>(F);
- };
SampleProfileLoader SampleLoader(ProfileFileName.empty() ? SampleProfileFile
: ProfileFileName,
- GetAssumptionCache, GetTTI);
+ GetAssumptionCache);
SampleLoader.doInitialization(M);
Modified: llvm/trunk/test/Transforms/SampleProfile/Inputs/einline.prof
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SampleProfile/Inputs/einline.prof?rev=313230&r1=313229&r2=313230&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SampleProfile/Inputs/einline.prof (original)
+++ llvm/trunk/test/Transforms/SampleProfile/Inputs/einline.prof Wed Sep 13 22:40:33 2017
@@ -1,6 +1,5 @@
_Z3foov:200:100
1: _Z3barv:0
- 2: no_inline:100
3: _Z3barv:100
recursive:200:100
1: recursive:100
Modified: llvm/trunk/test/Transforms/SampleProfile/early-inline.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SampleProfile/early-inline.ll?rev=313230&r1=313229&r2=313230&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SampleProfile/early-inline.ll (original)
+++ llvm/trunk/test/Transforms/SampleProfile/early-inline.ll Wed Sep 13 22:40:33 2017
@@ -12,8 +12,6 @@ define void @_Z3foov() #0 personality i8
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32, align 4
-; CHECK: call void @no_inline
- call void @no_inline(), !dbg !16
; CHECK-NOT: call
call void @_ZL3barv(), !dbg !9
; CHECK-NOT: invoke
@@ -47,16 +45,8 @@ define void @recursive() #0 !dbg !13 {
ret void
}
-; The callee has mismatch attributes to the caller, it should not be inlined
-define void @no_inline() #1 !dbg !17 {
- ret void
-}
-
declare i32 @__gxx_personality_v0(...)
-attributes #0 = {"target-features"="+sse4.1"}
-attributes #1 = {"target-features"="+sse4.2"}
-
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4}
@@ -72,5 +62,3 @@ attributes #1 = {"target-features"="+sse
!13 = distinct !DISubprogram(linkageName: "recursive", scope: !1, file: !1, line: 20, scopeLine: 20, unit: !0)
!14 = !DILocation(line: 21, column: 3, scope: !13)
!15 = !DILocation(line: 22, column: 3, scope: !13)
-!16 = !DILocation(line: 7, column: 3, scope: !6)
-!17 = distinct !DISubprogram(linkageName: "no_inline", scope: !1, file: !1, line: 20, scopeLine: 20, unit: !0)
More information about the llvm-commits
mailing list