!9739 fix empty catch

Merge pull request !9739 from zoumujia/20241014
This commit is contained in:
openharmony_ci 2024-10-17 16:02:10 +00:00 committed by Gitee
commit 9087b40536
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 12 additions and 20 deletions

View File

@ -570,12 +570,6 @@ void BytecodeCircuitBuilder::UpdateCFG()
auto &bb = RegionAt(i);
bb.preds.clear();
bb.trys.clear();
ChunkVector<BytecodeRegion *> newSuccs(circuit_->chunk());
for (const auto &succ: bb.succs) {
newSuccs.emplace_back(succ);
}
bb.succs.clear();
bb.succs.insert(bb.succs.end(), newSuccs.begin(), newSuccs.end());
}
for (size_t i = 0; i < graph_.size(); i++) {
auto &bb = RegionAt(i);

View File

@ -593,9 +593,8 @@ size_t FrameStateBuilder::GetNumOfStatePreds(const BytecodeRegion &bb)
}
GateRef FrameStateBuilder::MergeValue(const BytecodeRegion &bb,
[[maybe_unused]]GateRef stateMerge, GateRef currentValue, GateRef nextValue, bool isLoopBack)
GateRef currentValue, GateRef nextValue, bool isLoopBack, bool changedInLoop)
{
ASSERT(IsGateNotEmpty(stateMerge));
ASSERT(IsGateNotEmpty(currentValue));
auto mergedContext = GetMergedBbContext(bb.id);
GateRef result = currentValue;
@ -620,8 +619,9 @@ GateRef FrameStateBuilder::MergeValue(const BytecodeRegion &bb,
}
result = nextValue;
} else if (currentValue != nextValue) {
bool needMergeValues = IsGateNotEmpty(mergedContext->mergeState_);
// build value selector for merge.
if (IsGateNotEmpty(mergedContext->mergeState_)) {
if (needMergeValues) {
size_t numOfIns = acc_.GetNumIns(mergedContext->mergeState_);
auto inList = std::vector<GateRef>(numOfIns + 1, Circuit::NullGate()); // 1: state
auto phi = circuit_->NewGate(
@ -637,7 +637,10 @@ GateRef FrameStateBuilder::MergeValue(const BytecodeRegion &bb,
mergeValueSelector = result = phi;
}
// build value selector for loop begin.
if (IsGateNotEmpty(mergedContext->loopBackState_)) {
// If the register value of the corresponding bit is changed in the loop or
// there is a state that needs to be merged (e.g.Multiple values or branches need to be merged into a phi node)
// need to create or update the phi node.
if (IsGateNotEmpty(mergedContext->loopBackState_) && (changedInLoop || needMergeValues)) {
size_t numOfIns = acc_.GetNumIns(mergedContext->loopBackState_);
auto inList = std::vector<GateRef>(numOfIns + 1, Circuit::NullGate()); // 1: state
auto phi = circuit_->NewGate(
@ -685,9 +688,8 @@ MergeStateDependInfo FrameStateBuilder::GetCorrespondingState(const BytecodeRegi
void FrameStateBuilder::MergeAssignment(const BytecodeRegion &bb, const BytecodeRegion &bbNext)
{
auto mergedContext = GetMergedBbContext(bbNext.id);
auto mergeInfo = GetCorrespondingState(bb, bbNext);
auto stateMerge = mergeInfo.state;
ASSERT(acc_.IsCFGMerge(stateMerge));
[[maybe_unused]] auto mergeInfo = GetCorrespondingState(bb, bbNext);
ASSERT(acc_.IsCFGMerge(mergeInfo.state));
auto liveout = GetFrameLiveoutBefore(bbNext.id);
auto *loopAssignment = GetLoopAssignment(bbNext);
for (size_t i = 0; i < numVregs_; i++) {
@ -707,12 +709,8 @@ void FrameStateBuilder::MergeAssignment(const BytecodeRegion &bb, const Bytecode
ASSERT(!IsGateNotEmpty(next) || current == next);
}
#endif
if (loopAssignment != nullptr && !loopAssignment->TestBit(i) &&
!IsGateNotEmpty(mergedContext->mergeState_)) {
value = current;
} else {
value = MergeValue(bbNext, stateMerge, current, next, bbNext.IsLoopBack(bb));
}
bool changedInLoop = loopAssignment != nullptr && loopAssignment->TestBit(i);
value = MergeValue(bbNext, current, next, bbNext.IsLoopBack(bb), changedInLoop);
mergedContext->SetValuesAt(i, value);
}
}

View File

@ -239,7 +239,7 @@ private:
void DumpLiveState();
size_t GetNumOfStatePreds(const BytecodeRegion &bb);
GateRef MergeValue(const BytecodeRegion &bb,
GateRef stateMerge, GateRef currentValue, GateRef nextValue, bool isLoopBack);
GateRef currentValue, GateRef nextValue, bool isLoopBack, bool changedInLoop);
void NewMerge(const BytecodeRegion &bbNext);
void MergeStateDepend(const BytecodeRegion &bb, const BytecodeRegion &bbNext);
void CopyLiveoutValues(const BytecodeRegion &bbNext, FrameContext* dest, FrameContext* src);