aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Gohman <sunfish@mozilla.com>2014-03-04 15:05:27 -0800
committerDan Gohman <sunfish@mozilla.com>2014-03-04 21:19:33 -0800
commitb0180f577b7fd17af324781bfd2ab5b2d66cb204 (patch)
tree67edf13f89401d7f3f5d874bce0832449b475af0
parentb516d172312af1ff8efddfdf1f825897bd4ea9c6 (diff)
Perform alloca coloring only at -O1 and higher.
-rw-r--r--lib/Target/JSBackend/AllocaManager.cpp10
-rw-r--r--lib/Target/JSBackend/AllocaManager.h5
-rw-r--r--lib/Target/JSBackend/JSBackend.cpp11
3 files changed, 18 insertions, 8 deletions
diff --git a/lib/Target/JSBackend/AllocaManager.cpp b/lib/Target/JSBackend/AllocaManager.cpp
index 6c4c49f0d0..4673a34644 100644
--- a/lib/Target/JSBackend/AllocaManager.cpp
+++ b/lib/Target/JSBackend/AllocaManager.cpp
@@ -450,7 +450,8 @@ void AllocaManager::computeFrameOffsets() {
AllocaManager::AllocaManager() {
}
-void AllocaManager::analyze(const Function &Func, const DataLayout &Layout) {
+void AllocaManager::analyze(const Function &Func, const DataLayout &Layout,
+ bool PerformColoring) {
NamedRegionTimer Timer("AllocaManager", TimePassesIsEnabled);
assert(Allocas.empty());
@@ -469,8 +470,11 @@ void AllocaManager::analyze(const Function &Func, const DataLayout &Layout) {
LifetimeStart = M->getFunction(Intrinsic::getName(Intrinsic::lifetime_start));
LifetimeEnd = M->getFunction(Intrinsic::getName(Intrinsic::lifetime_end));
- if ((LifetimeStart && !LifetimeStart->use_empty()) ||
- (LifetimeEnd && !LifetimeEnd->use_empty())) {
+ // If we are optimizing and the module contains any lifetime intrinsics, run
+ // the alloca coloring algorithm.
+ if (PerformColoring &&
+ ((LifetimeStart && !LifetimeStart->use_empty()) ||
+ (LifetimeEnd && !LifetimeEnd->use_empty()))) {
collectMarkedAllocas();
diff --git a/lib/Target/JSBackend/AllocaManager.h b/lib/Target/JSBackend/AllocaManager.h
index 0aafeb4a06..44b07981bc 100644
--- a/lib/Target/JSBackend/AllocaManager.h
+++ b/lib/Target/JSBackend/AllocaManager.h
@@ -144,8 +144,9 @@ class AllocaManager {
public:
AllocaManager();
- /// Analyze the given function and prepare for getReplacement queries.
- void analyze(const Function &Func, const DataLayout &Layout);
+ /// Analyze the given function and prepare for getRepresentative queries.
+ void analyze(const Function &Func, const DataLayout &Layout,
+ bool PerformColoring);
/// Reset all stored state.
void clear();
diff --git a/lib/Target/JSBackend/JSBackend.cpp b/lib/Target/JSBackend/JSBackend.cpp
index b440980010..9bc1764042 100644
--- a/lib/Target/JSBackend/JSBackend.cpp
+++ b/lib/Target/JSBackend/JSBackend.cpp
@@ -139,13 +139,16 @@ namespace {
bool UsesSIMD;
int InvokeState; // cycles between 0, 1 after preInvoke, 2 after call, 0 again after postInvoke. hackish, no argument there.
+ CodeGenOpt::Level OptLevel;
DataLayout *DL;
#include "CallHandlers.h"
public:
static char ID;
- explicit JSWriter(formatted_raw_ostream &o) : ModulePass(ID), Out(o), UniqueNum(0), UsesSIMD(false), InvokeState(0) {}
+ JSWriter(formatted_raw_ostream &o, CodeGenOpt::Level OptLevel)
+ : ModulePass(ID), Out(o), UniqueNum(0), UsesSIMD(false), InvokeState(0),
+ OptLevel(OptLevel) {}
virtual const char *getPassName() const { return "JavaScript backend"; }
@@ -1847,7 +1850,9 @@ void JSWriter::printFunction(const Function *F) {
UsedVars.clear();
UniqueNum = 0;
calculateNativizedVars(F);
- Allocas.analyze(*F, *DL);
+
+ // Do alloca coloring at -O1 and higher.
+ Allocas.analyze(*F, *DL, OptLevel != CodeGenOpt::None);
// Emit the function
@@ -2335,7 +2340,7 @@ bool JSTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
PM.add(createExpandI64Pass());
PM.add(createSimplifyAllocasPass());
- PM.add(new JSWriter(o));
+ PM.add(new JSWriter(o, getOptLevel()));
return false;
}