mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-22 10:24:26 +00:00
Add functions for finding ephemeral values
This adds a set of utility functions for collecting 'ephemeral' values. These are LLVM IR values that are used only by @llvm.assume intrinsics (directly or indirectly), and thus will be removed prior to code generation, implying that they should be considered free for certain purposes (like inlining). The inliner's cost analysis, and a few other passes, have been updated to account for ephemeral values using the provided functionality. This functionality is important for the usability of @llvm.assume, because it limits the "non-local" side-effects of adding llvm.assume on inlining, loop unrolling, etc. (these are hints, and do not generate code, so they should not directly contribute to estimates of execution cost). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217335 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -13,6 +13,7 @@
|
||||
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/Analysis/AssumptionTracker.h"
|
||||
#include "llvm/Analysis/CodeMetrics.h"
|
||||
#include "llvm/Analysis/InstructionSimplify.h"
|
||||
#include "llvm/Analysis/LoopPass.h"
|
||||
@ -53,6 +54,7 @@ namespace {
|
||||
|
||||
// LCSSA form makes instruction renaming easier.
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
AU.addRequired<AssumptionTracker>();
|
||||
AU.addPreserved<DominatorTreeWrapperPass>();
|
||||
AU.addRequired<LoopInfo>();
|
||||
AU.addPreserved<LoopInfo>();
|
||||
@ -72,12 +74,14 @@ namespace {
|
||||
unsigned MaxHeaderSize;
|
||||
LoopInfo *LI;
|
||||
const TargetTransformInfo *TTI;
|
||||
AssumptionTracker *AT;
|
||||
};
|
||||
}
|
||||
|
||||
char LoopRotate::ID = 0;
|
||||
INITIALIZE_PASS_BEGIN(LoopRotate, "loop-rotate", "Rotate Loops", false, false)
|
||||
INITIALIZE_AG_DEPENDENCY(TargetTransformInfo)
|
||||
INITIALIZE_PASS_DEPENDENCY(AssumptionTracker)
|
||||
INITIALIZE_PASS_DEPENDENCY(LoopInfo)
|
||||
INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
|
||||
INITIALIZE_PASS_DEPENDENCY(LCSSA)
|
||||
@ -98,6 +102,7 @@ bool LoopRotate::runOnLoop(Loop *L, LPPassManager &LPM) {
|
||||
|
||||
LI = &getAnalysis<LoopInfo>();
|
||||
TTI = &getAnalysis<TargetTransformInfo>();
|
||||
AT = &getAnalysis<AssumptionTracker>();
|
||||
|
||||
// Simplify the loop latch before attempting to rotate the header
|
||||
// upward. Rotation may not be needed if the loop tail can be folded into the
|
||||
@ -323,8 +328,11 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) {
|
||||
// Check size of original header and reject loop if it is very big or we can't
|
||||
// duplicate blocks inside it.
|
||||
{
|
||||
SmallPtrSet<const Value *, 32> EphValues;
|
||||
CodeMetrics::collectEphemeralValues(L, AT, EphValues);
|
||||
|
||||
CodeMetrics Metrics;
|
||||
Metrics.analyzeBasicBlock(OrigHeader, *TTI);
|
||||
Metrics.analyzeBasicBlock(OrigHeader, *TTI, EphValues);
|
||||
if (Metrics.notDuplicatable) {
|
||||
DEBUG(dbgs() << "LoopRotation: NOT rotating - contains non-duplicatable"
|
||||
<< " instructions: "; L->dump());
|
||||
|
Reference in New Issue
Block a user