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

Unified Diff: src/IceCfg.cpp

Issue 2095763002: Instrumented local variables and implemented runtime. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fixed alloca sort and cleaned test Created 4 years, 6 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 | « src/IceCfg.h ('k') | src/IceInstrumentation.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 a113b95d47948ddd03c1bbe7bd864c2aa3642bd5..8fe56375b8c967637d2eac14ae1efde7c789d0d4 100644
--- a/src/IceCfg.cpp
+++ b/src/IceCfg.cpp
@@ -645,17 +645,17 @@ void Cfg::doArgLowering() {
getTarget()->lowerArguments();
}
-void Cfg::sortAndCombineAllocas(CfgVector<Inst *> &Allocas,
+void Cfg::sortAndCombineAllocas(CfgVector<InstAlloca *> &Allocas,
uint32_t CombinedAlignment, InstList &Insts,
AllocaBaseVariableType BaseVariableType) {
if (Allocas.empty())
return;
// Sort by decreasing alignment.
- std::sort(Allocas.begin(), Allocas.end(), [](Inst *I1, Inst *I2) {
- auto *A1 = llvm::dyn_cast<InstAlloca>(I1);
- auto *A2 = llvm::dyn_cast<InstAlloca>(I2);
- return A1->getAlignInBytes() > A2->getAlignInBytes();
- });
+ std::stable_sort(Allocas.begin(), Allocas.end(),
+ [](InstAlloca *A1, InstAlloca *A2) {
+ return A1->getAlignInBytes() >= A2->getAlignInBytes();
Karl 2016/06/27 21:38:10 For stable sort, shouldn't this be >?
tlively 2016/06/27 22:13:24 Done.
+ });
+
// Process the allocas in order of decreasing stack alignment. This allows
// us to pack less-aligned pieces after more-aligned ones, resulting in less
// stack growth. It also allows there to be at most one stack alignment "and"
@@ -746,6 +746,8 @@ void Cfg::processAllocas(bool SortAndCombine) {
bool HasLargeAlignment = false;
bool HasDynamicAllocation = false;
for (Inst &Instr : EntryNode->getInsts()) {
+ if (Instr.isDeleted())
+ continue;
if (auto *Alloca = llvm::dyn_cast<InstAlloca>(&Instr)) {
uint32_t AlignmentParam = Alloca->getAlignInBytes();
if (AlignmentParam > StackAlignment)
@@ -769,6 +771,8 @@ void Cfg::processAllocas(bool SortAndCombine) {
if (Node == EntryNode)
continue;
for (Inst &Instr : Node->getInsts()) {
+ if (Instr.isDeleted())
+ continue;
if (llvm::isa<InstAlloca>(&Instr)) {
// Allocations outside the entry block require a frame pointer.
HasDynamicAllocation = true;
@@ -784,13 +788,15 @@ void Cfg::processAllocas(bool SortAndCombine) {
// Collect the Allocas into the two vectors.
// Allocas in the entry block that have constant size and alignment less
// than or equal to the function's stack alignment.
- CfgVector<Inst *> FixedAllocas;
+ CfgVector<InstAlloca *> FixedAllocas;
// Allocas in the entry block that have constant size and alignment greater
// than the function's stack alignment.
- CfgVector<Inst *> AlignedAllocas;
+ CfgVector<InstAlloca *> AlignedAllocas;
// Maximum alignment used by any alloca.
uint32_t MaxAlignment = StackAlignment;
for (Inst &Instr : EntryNode->getInsts()) {
+ if (Instr.isDeleted())
+ continue;
if (auto *Alloca = llvm::dyn_cast<InstAlloca>(&Instr)) {
if (!llvm::isa<Constant>(Alloca->getSizeInBytes()))
continue;
« no previous file with comments | « src/IceCfg.h ('k') | src/IceInstrumentation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698