Skip to content
Permalink
Browse files

[MERGE #6198 @nhat-nguyen] Fix missing logic in UpdateImplicitCallBai…

…lOutKind due to bad merge

Merge pull request #6198 from nhat-nguyen:merge
  • Loading branch information...
nhat-nguyen committed Jul 11, 2019
2 parents 1b20111 + 50d3848 commit 174fc46007a9ab1a909cfca51988491e2e8de67f
Showing with 7 additions and 59 deletions.
  1. +7 −58 lib/Backend/BackwardPass.cpp
  2. +0 −1 lib/Backend/BackwardPass.h
@@ -2467,7 +2467,7 @@ BackwardPass::DeadStoreImplicitCallBailOut(IR::Instr * instr, bool hasLiveFields
}

bool
BackwardPass::UpdateImplicitCallBailOutKind(IR::Instr *const instr, bool needsBailOutOnImplicitCall, bool needsLazyBailOut)
BackwardPass::UpdateImplicitCallBailOutKind(IR::Instr* const instr, bool needsBailOutOnImplicitCall, bool needsLazyBailOut)
{
Assert(instr);
Assert(instr->HasBailOutInfo());
@@ -2481,7 +2481,7 @@ BackwardPass::UpdateImplicitCallBailOutKind(IR::Instr *const instr, bool needsBa
"The lazy bailout bit should be present at this point. We might have removed it incorrectly."
);

const IR::BailOutKind bailOutKindWithBits = instr->GetBailOutKind();
IR::BailOutKind bailOutKindWithBits = instr->GetBailOutKind();

const bool hasMarkTempObject = bailOutKindWithBits & IR::BailOutMarkTempObject;

@@ -2490,7 +2490,8 @@ BackwardPass::UpdateImplicitCallBailOutKind(IR::Instr *const instr, bool needsBa
// of `needsBailOutOnImplicitCall`.
if (hasMarkTempObject)
{
instr->SetBailOutKind(bailOutKindWithBits & ~IR::BailOutMarkTempObject);
bailOutKindWithBits &= ~IR::BailOutMarkTempObject;
instr->SetBailOutKind(bailOutKindWithBits);
}

if (needsBailOutOnImplicitCall)
@@ -2518,9 +2519,10 @@ BackwardPass::UpdateImplicitCallBailOutKind(IR::Instr *const instr, bool needsBa
}

const IR::BailOutKind bailOutKindWithoutBits = instr->GetBailOutKindNoBits();

if (hasMarkTempObject)
if (!instr->GetBailOutInfo()->canDeadStore)
{
// revisit if canDeadStore is used for anything other than BailOutMarkTempObject
Assert(hasMarkTempObject);
// Don't remove the implicit call pre op bailout for mark temp object.
Assert(bailOutKindWithoutBits == IR::BailOutOnImplicitCallsPreOp);
return true;
@@ -4369,59 +4371,6 @@ BackwardPass::TraceBlockUses(BasicBlock * block, bool isStart)

#endif

bool
BackwardPass::UpdateImplicitCallBailOutKind(IR::Instr *const instr, bool needsBailOutOnImplicitCall)
{
Assert(instr);
Assert(instr->HasBailOutInfo());

IR::BailOutKind implicitCallBailOutKind = needsBailOutOnImplicitCall ? IR::BailOutOnImplicitCalls : IR::BailOutInvalid;

IR::BailOutKind instrBailOutKind = instr->GetBailOutKind();
if (instrBailOutKind & IR::BailOutMarkTempObject)
{
// Remove the mark temp object bit, as we don't need it after the dead store pass
instrBailOutKind &= ~IR::BailOutMarkTempObject;
instr->SetBailOutKind(instrBailOutKind);

if (!instr->GetBailOutInfo()->canDeadStore)
{
return true;
}
}

const IR::BailOutKind instrImplicitCallBailOutKind = instrBailOutKind & ~IR::BailOutKindBits;
if(instrImplicitCallBailOutKind == IR::BailOutOnImplicitCallsPreOp)
{
if(needsBailOutOnImplicitCall)
{
implicitCallBailOutKind = IR::BailOutOnImplicitCallsPreOp;
}
}
else if(instrImplicitCallBailOutKind != IR::BailOutOnImplicitCalls && instrImplicitCallBailOutKind != IR::BailOutInvalid)
{
// This bailout kind (the value of 'instrImplicitCallBailOutKind') must guarantee that implicit calls will not happen.
// If it doesn't make such a guarantee, it must be possible to merge this bailout kind with an implicit call bailout
// kind, and therefore should be part of BailOutKindBits.
Assert(!needsBailOutOnImplicitCall);
return true;
}

if(instrImplicitCallBailOutKind == implicitCallBailOutKind)
{
return true;
}

const IR::BailOutKind newBailOutKind = instrBailOutKind - instrImplicitCallBailOutKind + implicitCallBailOutKind;
if(newBailOutKind == IR::BailOutInvalid)
{
return false;
}

instr->SetBailOutKind(newBailOutKind);
return true;
}

bool
BackwardPass::ProcessNoImplicitCallUses(IR::Instr *const instr)
{
@@ -78,7 +78,6 @@ class BackwardPass
#endif

static bool UpdateImplicitCallBailOutKind(IR::Instr *const instr, bool needsBailOutOnImplicitCall, bool needsLazyBailOut);
static bool UpdateImplicitCallBailOutKind(IR::Instr* const instr, bool needsBailOutOnImplicitCall);

bool ProcessNoImplicitCallUses(IR::Instr *const instr);
void ProcessNoImplicitCallDef(IR::Instr *const instr);

0 comments on commit 174fc46

Please sign in to comment.
You can’t perform that action at this time.