Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: src/IceCfg.cpp

Issue 1361803002: Subzero: Improve handling of alloca instructions of constant size. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add a couple of basic tests Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/IceInst.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceCfg.cpp
diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp
index 4259b27bcb9f7c8730cd9a3517eab1a27b58c9e1..a72671e31f23d3491619af0a1702000ed9974852 100644
--- a/src/IceCfg.cpp
+++ b/src/IceCfg.cpp
@@ -201,6 +201,27 @@ void Cfg::translate() {
if (auto Var64On32 = llvm::dyn_cast<Variable64On32>(Var))
Var64On32->initHiLo(this);
+ // Figure out which alloca instructions result in storage at known stack frame
+ // offsets. If this is true for all alloca instructions, then a stack pointer
+ // can still be used instead of a frame pointer, freeing up the frame pointer
+ // for normal register allocation. Additionally, for each such alloca, its
+ // address could be rematerialized at each use in terms of the stack/frame
+ // pointer, saving a stack slot and a load from that stack slot.
+ //
+ // This simple implementation is limited to alloca instructions at the start
+ // of the entry node.
+ for (Inst &Instr : getEntryNode()->getInsts()) {
+ if (auto *Alloca = llvm::dyn_cast<InstAlloca>(&Instr)) {
+ if (llvm::isa<Constant>(Alloca->getSizeInBytes())) {
+ Alloca->setKnownFrameOffset();
+ continue;
+ }
+ }
+ // The first instruction that is not an alloca with a constant size stops
+ // the search.
+ break;
+ }
+
// The set of translation passes and their order are determined by the
// target.
getTarget()->translate();
« no previous file with comments | « no previous file | src/IceInst.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698