diff --git a/include/base/SMPDataFlowAnalysis.h b/include/base/SMPDataFlowAnalysis.h index a9c783022bdf15e57ce1ee32c76b20010b24a1a1..d05ea504e662c41345dd86bad9cdb157bf6cb95d 100644 --- a/include/base/SMPDataFlowAnalysis.h +++ b/include/base/SMPDataFlowAnalysis.h @@ -230,7 +230,10 @@ bool MDLessRegOpnd(const STARSOpndTypePtr &RegOp1, const STARSOpndTypePtr &RegOp bool MDIsGeneralPurposeReg(const STARSOpndTypePtr &CurrOp); // Hash a global name and SSA number into an int, for use in SMPFunction.GlobalDefAddrBySSA map -int HashGlobalNameAndSSA(const STARSOpndTypePtr &DefOp, int SSANum, bool UseFP = true); +int HashGlobalNameAndSSA(const STARSOpndTypePtr &DefOp, int SSANum); + +// Hash a global name and SSA number into an int, for use in SMPFunction.GlobalDefAddrBySSA map +int64_t HashGlobalStackNameAndSSA(const STARSOpndTypePtr &DefOp, int SSANum, bool UseFP = true); // Are operands equal? bool IsEqOp(const STARSOpndTypePtr &Opnd1, const STARSOpndTypePtr &Opnd2); diff --git a/include/base/SMPFunction.h b/include/base/SMPFunction.h index cfaf746cd87271dd0db902e2a07c083a8248039d..77a609b9d426e671b24745b608c0890f429ea7c1 100644 --- a/include/base/SMPFunction.h +++ b/include/base/SMPFunction.h @@ -580,7 +580,7 @@ private: // If global DEF for that SSA is found in a Phi function, we use block number instead of inst addr // Instruction addresses should never overlap block #s, as block #s start at 0 and top out at a few hundred. // NOTE: We are currently limiting this map to registers, not all global names. - std::map<int, STARS_ea_t> GlobalStackDefAddrBySSA; // map hash of normalized stack offset & SSANum to DEF inst addr + std::map<int64_t, STARS_ea_t> GlobalStackDefAddrBySSA; // map hash of normalized stack offset & SSANum to DEF inst addr std::map<int, struct FineGrainedInfo> GlobalDefFGInfoBySSA; // map hash of global name & SSANum to DEF FG info. // NOTE: We are currently limiting this map to registers, not all global names. diff --git a/src/base/SMPDataFlowAnalysis.cpp b/src/base/SMPDataFlowAnalysis.cpp index 7ae8de560e2e3a6ac333e21f1c5011e5c1d749a7..d92f7fb97e0c3eb8f676608d236999d62addda59 100644 --- a/src/base/SMPDataFlowAnalysis.cpp +++ b/src/base/SMPDataFlowAnalysis.cpp @@ -166,15 +166,19 @@ bool SMPDefsFlags[STARS_NN_last + 1]; bool SMPUsesFlags[STARS_NN_last + 1]; // Hash a global name and SSA number into an int, for use in SMPFunction.GlobalDefAddrBySSA map -int HashGlobalNameAndSSA(const STARSOpndTypePtr &DefOp, int SSANum, bool UseFP) { +int HashGlobalNameAndSSA(const STARSOpndTypePtr &DefOp, int SSANum) { int HashValue = 0; if (DefOp->IsRegOp()) { HashValue = ((SSANum << 16) | ((int)(DefOp->GetReg()))); } - else { - assert(MDIsDirectStackAccessOpnd(DefOp, UseFP)); - HashValue = ((SSANum << 16) | (((int)(DefOp->GetAddr())) & 0xffff)); - } + return HashValue; +} + +// Hash a global name and SSA number into an int, for use in SMPFunction.GlobalDefAddrBySSA map +int64_t HashGlobalStackNameAndSSA(const STARSOpndTypePtr &DefOp, int SSANum, bool UseFP) { + int64_t HashValue = 0; + assert(MDIsDirectStackAccessOpnd(DefOp, UseFP)); + HashValue = ((((int64_t) SSANum) << 32) | (((uint64_t)(DefOp->GetAddr())) & 0xffffffff)); return HashValue; } diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp index ae9e7cb91c6a527ce8e0770bb1ccf84db579d9b0..8ac8e00ef98bbca160cc721f4240911e341b59bf 100644 --- a/src/base/SMPFunction.cpp +++ b/src/base/SMPFunction.cpp @@ -3198,17 +3198,23 @@ bool SMPFunction::MDUpdateFGStackLocInfo(STARS_ea_t InstAddr, const STARSOpndTyp // retrieve DEF addr from GlobalDefAddrBySSA or return STARS_BADADDR STARS_ea_t SMPFunction::GetGlobalDefAddr(const STARSOpndTypePtr &DefOp, int SSANum) { - map<int, STARS_ea_t>::iterator MapResult; STARS_ea_t DefAddr = STARS_BADADDR; // STARS_BADADDR means we did not find it bool RegDef = (DefOp->IsRegOp()); if (RegDef) { int HashedName = HashGlobalNameAndSSA(DefOp, SSANum); - MapResult = this->GlobalDefAddrBySSA.find(HashedName); + map<int, STARS_ea_t>::iterator MapResult = this->GlobalDefAddrBySSA.find(HashedName); if (MapResult != this->GlobalDefAddrBySSA.end()) { // Found it. DefAddr = (STARS_ea_t) MapResult->second; } } + else if (MDIsDirectStackAccessOpnd(DefOp, this->UsesFramePointer())) { + int64_t HashedName = HashGlobalStackNameAndSSA(DefOp, SSANum, this->UsesFramePointer()); + map<int64_t, STARS_ea_t>::iterator MapResult = this->GlobalStackDefAddrBySSA.find(HashedName); + if (MapResult != this->GlobalStackDefAddrBySSA.end()) { // Found it. + DefAddr = (STARS_ea_t) MapResult->second; + } + } else if (MDIsStackAccessOpnd(DefOp, this->UsesFramePointer())) { // Until we get stack operands into the GlobalDefAddrBySSA map, // do a linear search. @@ -7567,16 +7573,17 @@ void SMPFunction::SSARename(int BlockNumber) { SMP_msg("New EAX Phi Def SSANum: %d Block %d\n", NewSSANum, BlockNumber); } // Map the final SSA number to the block number. - int DefHashValue = HashGlobalNameAndSSA(PhiDefOp, NewSSANum); - pair<int, STARS_ea_t> DefMapEntry(DefHashValue, (STARS_PSEUDO_ID_MIN + CurrBlock->GetNumber())); - pair<map<int, STARS_ea_t>::iterator, bool> MapReturnValue; if (RegOpFlag) { - MapReturnValue = this->GlobalDefAddrBySSA.insert(DefMapEntry); + int DefHashValue = HashGlobalNameAndSSA(PhiDefOp, NewSSANum); + pair<int, STARS_ea_t> DefMapEntry(DefHashValue, (STARS_PSEUDO_ID_MIN + CurrBlock->GetNumber())); + pair<map<int, STARS_ea_t>::iterator, bool> MapReturnValue = this->GlobalDefAddrBySSA.insert(DefMapEntry); assert(MapReturnValue.second); } #if STARS_TRACK_STACK_DEF_ADDRS else { - MapReturnValue = this->GlobalStackDefAddrBySSA.insert(DefMapEntry); + int64_t DefHashValue = HashGlobalStackNameAndSSA(PhiDefOp, NewSSANum, this->UsesFramePointer()); + pair<int64_t, STARS_ea_t> DefMapEntry(DefHashValue, ((int64_t)(STARS_PSEUDO_ID_MIN + CurrBlock->GetNumber()))); + pair<map<int64_t, STARS_ea_t>::iterator, bool> MapReturnValue = this->GlobalStackDefAddrBySSA.insert(DefMapEntry); assert(MapReturnValue.second); } #endif @@ -7659,16 +7666,17 @@ void SMPFunction::SSARename(int BlockNumber) { } // Map the final SSA number to the DEF address. - int DefHashValue = HashGlobalNameAndSSA(DefOp, NewSSANum); - pair<int, STARS_ea_t> DefMapEntry(DefHashValue, DefAddr); - pair<map<int, STARS_ea_t>::iterator, bool> MapReturnValue; if (RegOpFlag) { - MapReturnValue = this->GlobalDefAddrBySSA.insert(DefMapEntry); + int DefHashValue = HashGlobalNameAndSSA(DefOp, NewSSANum); + pair<int, STARS_ea_t> DefMapEntry(DefHashValue, DefAddr); + pair<map<int, STARS_ea_t>::iterator, bool> MapReturnValue = this->GlobalDefAddrBySSA.insert(DefMapEntry); assert(MapReturnValue.second); } #if STARS_TRACK_STACK_DEF_ADDRS else { - MapReturnValue = this->GlobalStackDefAddrBySSA.insert(DefMapEntry); + int64_t DefHashValue = HashGlobalStackNameAndSSA(DefOp, NewSSANum, this->UsesFramePointer()); + pair<int64_t, STARS_ea_t> DefMapEntry(DefHashValue, DefAddr); + pair<map<int64_t, STARS_ea_t>::iterator, bool> MapReturnValue = this->GlobalStackDefAddrBySSA.insert(DefMapEntry); assert(MapReturnValue.second); } #endif @@ -9945,6 +9953,7 @@ bool SMPFunction::IsDefUsedInUnsafeMemWrite(STARSOpndTypePtr DefOp, int DefSSANu DefSSANum = HeadItem.first.second; DefAddr = HeadItem.second; DefWorkList.pop_front(); + assert(!DefOp->IsMemOp()); if (!(MDIsStackPtrReg(DefOp->GetReg(), this->UsesFramePointer()))) { // Ensure that we don't have a data dependence loop that causes diff --git a/tests/commit/save-ffmpeg.psexe.infoannot.REMOVED.git-id b/tests/commit/save-ffmpeg.psexe.infoannot.REMOVED.git-id index 5ec59274b04811562072b4b6c24fb58d37c6aab2..b4e0146e548bda448988da498f6133d7e16f513b 100644 --- a/tests/commit/save-ffmpeg.psexe.infoannot.REMOVED.git-id +++ b/tests/commit/save-ffmpeg.psexe.infoannot.REMOVED.git-id @@ -1 +1 @@ -3ab214aa7711f69874c2a6a3c167ad7e7d13c4f1 \ No newline at end of file +d649d83c0e7aad6512d964f66e1f84bf1aa12ec7 \ No newline at end of file diff --git a/tests/commit/save-ls-64bit.psexe.infoannot b/tests/commit/save-ls-64bit.psexe.infoannot index 787fc81763efb53b3a2ff9e01f38d548bb903f30..ff3b8038c69602cea739c5c0d62dcdafabda0664 100644 --- a/tests/commit/save-ls-64bit.psexe.infoannot +++ b/tests/commit/save-ls-64bit.psexe.infoannot @@ -552,8 +552,8 @@ 40d010 4 INSTR CHECK OVERFLOW UNSIGNED 64 R15 ZZ add r15, 1 40d0a0 4 INSTR CHECK OVERFLOW UNSIGNED 64 R15 ZZ add r15, 1 40d149 5 INSTR CHECK UNDERFLOW UNSIGNED 64 RDX ZZ sub rdx, [rsp+68h+var_58] - 40d14e 4 INSTR CHECK OVERFLOW NOFLAGUNSIGNED 64 RCX*8 ZZ IDIOM 32 lea rsi, [rbx+rcx*8]; src - 40d14e 4 INSTR CHECK OVERFLOW NOFLAGUNSIGNED 64 RBX+RCX*8 ZZ IDIOM 32 lea rsi, [rbx+rcx*8]; src + 40d14e 4 INSTR CHECK OVERFLOW NOFLAGUNSIGNED 64 RCX*8 ZZ IDIOM 18 MEMORYSINK lea rsi, [rbx+rcx*8]; src + 40d14e 4 INSTR CHECK OVERFLOW NOFLAGUNSIGNED 64 RBX+RCX*8 ZZ IDIOM 18 MEMORYSINK lea rsi, [rbx+rcx*8]; src 40d1a0 15 FUNC RETURNTYPE RAX 4 40d1a0 15 FUNC INARGS 6 ARG0 4 ARG1 0 ARG2 0 ARG3 0 ARG4 1 ARG5 0 40d1b0 147 FUNC RETURNTYPE RAX 4