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

Unified Diff: src/IceInst.cpp

Issue 2177033002: Subzero: Local variable splitting. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes, mostly renaming. Created 4 years, 5 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/IceInst.h ('k') | src/IceInstX86Base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceInst.cpp
diff --git a/src/IceInst.cpp b/src/IceInst.cpp
index 2d67f377be8278c45e9d9dd84c5656c5e5152db7..2ffb0ccc1316195c87d77f448a84124b19da9e04 100644
--- a/src/IceInst.cpp
+++ b/src/IceInst.cpp
@@ -1090,9 +1090,10 @@ void InstIcmp::reverseConditionAndOperands() {
Condition = InstIcmpAttributes[Condition].Reverse;
std::swap(Srcs[0], Srcs[1]);
}
+
bool checkForRedundantAssign(const Variable *Dest, const Operand *Source) {
const auto *SrcVar = llvm::dyn_cast<const Variable>(Source);
- if (!SrcVar)
+ if (SrcVar == nullptr)
return false;
if (Dest->hasReg() && Dest->getRegNum() == SrcVar->getRegNum()) {
// TODO: On x86-64, instructions like "mov eax, eax" are used to clear the
@@ -1101,6 +1102,8 @@ bool checkForRedundantAssign(const Variable *Dest, const Operand *Source) {
}
if (!Dest->hasReg() && !SrcVar->hasReg()) {
if (!Dest->hasStackOffset() || !SrcVar->hasStackOffset()) {
+ // If called before stack slots have been assigned (i.e. as part of the
+ // dump() routine), conservatively return false.
return false;
}
if (Dest->getStackOffset() != SrcVar->getStackOffset()) {
@@ -1108,6 +1111,15 @@ bool checkForRedundantAssign(const Variable *Dest, const Operand *Source) {
}
return true;
}
+ // For a "v=t" assignment where t has a register, v has a stack slot, and v
+ // has a LinkedTo stack root, and v and t share the same LinkedTo root, return
+ // true. This is because this assignment is effectively reassigning the same
+ // value to the original LinkedTo stack root.
+ if (SrcVar->hasReg() && Dest->hasStackOffset() &&
+ Dest->getLinkedToStackRoot() != nullptr &&
+ Dest->getLinkedToRoot() == SrcVar->getLinkedToRoot()) {
+ return true;
+ }
return false;
}
« no previous file with comments | « src/IceInst.h ('k') | src/IceInstX86Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698