From d10951527a8b59f18c1da2fada71cc89a9815fb6 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 5 Nov 2021 06:57:16 -0700 Subject: [PATCH] Fixed invalid lifetimeStart emission with dynLife vregs --- IDEHelper/Backend/BeMCContext.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/IDEHelper/Backend/BeMCContext.cpp b/IDEHelper/Backend/BeMCContext.cpp index feebe25e..1112dca9 100644 --- a/IDEHelper/Backend/BeMCContext.cpp +++ b/IDEHelper/Backend/BeMCContext.cpp @@ -16748,7 +16748,16 @@ void BeMCContext::Generate(BeFunction* function) auto castedInst = (BeLifetimeEndInst*)inst; auto mcPtr = GetOperand(castedInst->mPtr, false, true); if (mcPtr) - AllocInst(BeMCInstKind_LifetimeStart, mcPtr); + { + auto vregInfo = GetVRegInfo(mcPtr); + if ((vregInfo != NULL) && (vregInfo->mHasDynLife)) + { + // This alloca had an assignment (ie: `mov vregX, [RBP+homeSize0]`) so it must be defined at the mov + // This may indicate incorrectly generated code where we thought an alloca would be in the head but it isn't + } + else + AllocInst(BeMCInstKind_LifetimeStart, mcPtr); + } } break; case BeLifetimeExtendInst::TypeId: