diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp index 304254879082f339f1ecfc6234304a59f48507e2..fa641c17f0e80af6bff6b4b7191c5fca724b2d7d 100644 --- a/src/base/SMPFunction.cpp +++ b/src/base/SMPFunction.cpp @@ -1935,6 +1935,11 @@ void SMPFunction::SetStackFrameInfo(void) { // saving of registers other than EBP happens AFTER local stack allocation. // A Windows version of the function would expect to see the pushing // of ESI and EDI AFTER the sub esp,34h statement. + +// How many irrelevant insts in the first basic block should we see before deciding that frame allocation is finished? +#define STARS_POST_CALL_NONALLOC_INSTR_LIMIT 10 // after function call seen +#define STARS_NONALLOC_INSTR_LIMIT 30 // after this many irrelevant insts even if no calls + bool SMPFunction::MDFixFrameInfo(void) { int SavedRegsSize = 0; int OtherPushesSize = 0; // besides callee-saved regs @@ -1945,6 +1950,8 @@ bool SMPFunction::MDFixFrameInfo(void) { bool FoundAllocInstr = false; // found simple alloc, e.g. subtraction from stack pointer bool DebugFlag = (0 == strcmp("__libc_csu_init", this->GetFuncName())); bool CallSeen = false; + uint16_t PostCallNonAllocInstructions = 0; + uint16_t NonAllocatingInstructions = 0; STARS_ea_t CallAddr = STARS_BADADDR; STARS_ea_t SaveAddr = this->GetStartAddr(); // keeps most recent best value for stack frame allocation instr list<pair<STARS_ea_t, int> > AllocPointsList; // list of pair<InstAddr, bytes allocated on stack at that addr> @@ -2102,6 +2109,22 @@ bool SMPFunction::MDFixFrameInfo(void) { ESPintoEBP = true; } } + else { + ++NonAllocatingInstructions; + if (CallSeen) { + ++PostCallNonAllocInstructions; + if (STARS_POST_CALL_NONALLOC_INSTR_LIMIT <= PostCallNonAllocInstructions) { + SMP_msg("INFO: Stopping search of first block after call for frame allocations at %llx\n", + (unsigned long long) InstAddr); + break; + } + } + if (STARS_NONALLOC_INSTR_LIMIT <= NonAllocatingInstructions) { + SMP_msg("INFO: Stopping search of first block for frame allocations at %llx\n", + (unsigned long long) InstAddr); + break; + } + } } // end for all instructions in the first basic block this->LocalVarsSize = (STARS_asize_t) AllocValue + (STARS_asize_t) OtherAllocsSize; diff --git a/tests/commit/trimmed-sorted-save-busybox.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-busybox.psexe.annot.REMOVED.git-id index 5a877f18c171465bde3b2ad9a6806e71ec99231d..235faeff13b81fcdf274688958a353b44b781eb2 100644 --- a/tests/commit/trimmed-sorted-save-busybox.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-busybox.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -08b231581017a39f0e53a0b3072765de12e090be \ No newline at end of file +b2dc2595edb765cb3b9e6bfdf6d7dc7af5b28601 \ No newline at end of file diff --git a/tests/commit/trimmed-sorted-save-nginx.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-nginx.psexe.annot.REMOVED.git-id index 3c735a86d27597e9f1595119e57c1c941b3a95f1..492ae9544b2de60fd1d0113df51251b50d8743ff 100644 --- a/tests/commit/trimmed-sorted-save-nginx.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-nginx.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -4f6eabd018db2b90ccac7e3be3a98c3729f40c28 \ No newline at end of file +9d1acf8d25ff0689b7a3211816c1f673b84854c4 \ No newline at end of file diff --git a/tests/commit/trimmed-sorted-save-openssl.psexe.annot.REMOVED.git-id b/tests/commit/trimmed-sorted-save-openssl.psexe.annot.REMOVED.git-id index dee4ffb4b264a90cedd1ec303f9b4bdd2172e51c..c81df73f3db754996160fcd217509d41bd295098 100644 --- a/tests/commit/trimmed-sorted-save-openssl.psexe.annot.REMOVED.git-id +++ b/tests/commit/trimmed-sorted-save-openssl.psexe.annot.REMOVED.git-id @@ -1 +1 @@ -f5dadddb8f6dd2f81e75244dee3650f9ec4d24b1 \ No newline at end of file +2efb0ff9a9b3cb592176ae3a969a388e396cc512 \ No newline at end of file