diff --git a/SMPDataFlowAnalysis.cpp b/SMPDataFlowAnalysis.cpp index b4cdb0b6dfd8001d4ca0e53261822929ecf29f9f..db842c2ec49197b83b35b5628b4bc83b6af91ee3 100644 --- a/SMPDataFlowAnalysis.cpp +++ b/SMPDataFlowAnalysis.cpp @@ -3200,8 +3200,10 @@ SMPOperandType SMPPhiFunction::ConditionalMeetType(SMPBasicBlock *CurrBlock) con if ((BADADDR != DefAddr) && (DefAddr >= CurrBlock->GetFunc()->GetFirstFuncAddr())) { SMPInstr *DefInst = CurrBlock->GetFunc()->GetInstFromAddr(DefAddr); set<DefOrUse, LessDefUse>::iterator DefIter = DefInst->SetDefType(PhiOp, PtrType); +#if 0 SMP_msg("INFO: Converting zeroed reg from NUMERIC to POINTER at %lx for Block at %lx\n", (unsigned long) DefAddr, (unsigned long) BlockStartAddr); +#endif CurrBlock->GetFunc()->ResetProcessedBlocks(); SMPBasicBlock *DefBlock = CurrBlock->GetFunc()->GetBlockFromInstAddr(DefAddr); #if 0 // Causes infinite loops, crashes; need to debug !!!!****!!!! diff --git a/SMPFunction.cpp b/SMPFunction.cpp index 5875d0fa7435f53bb2e946697f3b034b70e189f6..48bffd01416b155bf627d8c153aa14ccbc368196 100644 --- a/SMPFunction.cpp +++ b/SMPFunction.cpp @@ -8619,6 +8619,7 @@ void SMPFunction::MarkFunctionSafe() { bool HasIndirectWrite = false; bool IsIndirectCallTarget = false; // could be called indirectly bool IsTailCallTarget = false; // could be called by jump instruction used as tail call + bool MakesTailCall = false; // problem for Fast Returns, not fo return address safety bool HasNoCallers = this->AllCallSources.empty(); this->ReturnAddrStatus = FUNC_SAFE; @@ -8730,6 +8731,9 @@ void SMPFunction::MarkFunctionSafe() { } continue; } + if ((CurrInst->IsTailCall()) || (CurrInst->IsCondTailCall())) { + MakesTailCall = true; + } if (CurrInst->MDIsPopInstr() || CurrInst->MDIsReturnInstr()) { // ignore pops and returns for the moment continue; @@ -8868,6 +8872,10 @@ void SMPFunction::MarkFunctionSafe() { SMP_msg("INFO: Function at %lx becoming unsafe for fast returns because it has no callers.\n", (unsigned long) this->FirstEA); this->SetUnsafeForFastReturns(true, NO_CALLERS); } + if (MakesTailCall) { + SMP_msg("INFO: Function at %lx becoming unsafe for fast returns because it makes a tail call.\n", (unsigned long) this->FirstEA); + this->SetUnsafeForFastReturns(true, MAKES_TAIL_CALL); + } if (UnsafeReturnAddr) { SMP_msg("INFO: Function at %lx becoming unsafe for fast returns because its return addr is UNSAFE.\n", (unsigned long) this->FirstEA); diff --git a/SMPFunction.h b/SMPFunction.h index 8fdbeaaa7ed0194b541e72343aa490ecc372e85e..26b7d31da90d492a0a292bd8605f50d6eca2fe7b 100644 --- a/SMPFunction.h +++ b/SMPFunction.h @@ -120,7 +120,8 @@ enum UnsafeFastReturnReason { INDIRECTLY_CALLED = 8, NO_CALLERS = 16, TAIL_CALL_TARGET = 32, - RAUNSAFE_CALLEES = 64 + RAUNSAFE_CALLEES = 64, + MAKES_TAIL_CALL = 128 }; enum ControlFlowType { diff --git a/SMPInstr.cpp b/SMPInstr.cpp index b19fbc6fafd88c8d8d69bc8ff0476cb43cf817ef..a7daf19ec97be2e1468a55ce002c7b257b9dec6b 100644 --- a/SMPInstr.cpp +++ b/SMPInstr.cpp @@ -9682,6 +9682,9 @@ void SMPInstr::EmitFastReturnStatus(unsigned short FastReturnStatus) { if (TAIL_CALL_TARGET & FastReturnStatus) { SMP_fprintf(STARS_CallReturnFile, "TAILCALLED "); } + if (MAKES_TAIL_CALL & FastReturnStatus) { + SMP_fprintf(STARS_CallReturnFile, "MAKES_TAIL_CALL "); + } if (RAUNSAFE_CALLEES & FastReturnStatus) { SMP_fprintf(STARS_CallReturnFile, "UNSAFE_CALLEES "); } @@ -10552,6 +10555,8 @@ void SMPInstr::EmitIntegerErrorAnnotations(FILE *InfoAnnotFile, list<size_t> &Lo SSANum = DefIter->GetSSANum(); SMPOperandType DefType = DefIter->GetType(); SMPOperandType MemType; + SMPMetadataType DefMetaStatus = DefIter->GetMetadataStatus(); + bool DefUnusedMetadata = (DEF_METADATA_UNUSED == DefMetaStatus); bool IgnoreOverflow = this->IsBenignOverflow(IdiomCode); uval_t ConstValue = 0; // NOTE: We no longer suppress the IgnoreOverflow annotations. Instead, we print diff --git a/SMPProgram.cpp b/SMPProgram.cpp index 564d62aadc09cf22b86990e72dfc28e097a988c2..60f5debb901227ccb0a88f3bec78962970f10e12 100644 --- a/SMPProgram.cpp +++ b/SMPProgram.cpp @@ -746,18 +746,20 @@ void SMPProgram::Analyze(ProfilerInformation *pi) { if (CurrFunc->StackPtrAnalysisSucceeded() && CurrFunc->HasGoodRTLs() && !CurrFunc->HasIndirectJumps() && !CurrFunc->HasSharedChunks()) { #endif changed |= CurrFunc->InferInterproceduralTypes(); + } #if 0 - if (0 == strcmp("__mktime_internal", CurrFunc->GetFuncName())) { - CurrFunc->Dump(); - } -#endif + if ((!changed || (IterationCounter > STARS_INTERPROCEDURAL_ITERATION_LIMIT)) && (0 == strcmp("__mktime_internal", CurrFunc->GetFuncName()))) { + CurrFunc->Dump(); } +#endif } } while (changed && (IterationCounter <= STARS_INTERPROCEDURAL_ITERATION_LIMIT)); SMP_msg("Interprocedural type inference terminated after iteration %zu changed: %d\n", IterationCounter, changed); #endif - // Free memory not needed to emit annotations, now that type inference is done. + + + // Free memory not needed to emit annotations, now that type inference is done. CurrFunc->FreeUnusedMemory4(); #if SMP_COUNT_MEMORY_ALLOCATIONS