MCPcopy Create free account
hub / github.com/beefytech/Beef / DoJumpRemovePass

Method DoJumpRemovePass

IDEHelper/Backend/BeMCContext.cpp:11121–11465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11119}
11120
11121bool BeMCContext::DoJumpRemovePass()
11122{
11123 struct LabelStats
11124 {
11125 public:
11126 bool mHasRefs;
11127 bool mForceKeepLabel;
11128 bool mFromMultipleDbgLocs;
11129
11130 // If all branches share the dbgLoc with the first inst then we can potentially do a remap
11131 BeDbgLoc* mRefDbgLoc;
11132
11133 public:
11134 LabelStats()
11135 {
11136 mHasRefs = false;
11137 mForceKeepLabel = false;
11138 mFromMultipleDbgLocs = false;
11139 mRefDbgLoc = NULL;
11140 }
11141 };
11142
11143 bool didWork = false;
11144
11145 SizedArray<LabelStats, 32> labelStats;
11146 labelStats.resize(mCurLabelIdx);
11147 Dictionary<int, int> labelRemaps;
11148
11149 for (auto& switchEntry : mSwitchEntries)
11150 {
11151 labelStats[switchEntry.mBlock->mLabelIdx].mForceKeepLabel = true;
11152 labelStats[switchEntry.mBlock->mLabelIdx].mHasRefs = true;
11153 }
11154
11155 for (auto mcBlock : mBlocks)
11156 {
11157 for (int instIdx = 0; instIdx < (int)mcBlock->mInstructions.size(); instIdx++)
11158 {
11159 auto inst = mcBlock->mInstructions[instIdx];
11160
11161 if (inst->mKind == BeMCInstKind_Label)
11162 {
11163 if (instIdx < (int)mcBlock->mInstructions.size() - 2)
11164 {
11165 auto nextInst = mcBlock->mInstructions[instIdx + 1];
11166 if (nextInst->mDbgLoc != NULL)
11167 {
11168 auto& stats = labelStats[inst->mArg0.mLabelIdx];
11169 if ((stats.mRefDbgLoc != NULL) && (stats.mRefDbgLoc != nextInst->mDbgLoc))
11170 stats.mFromMultipleDbgLocs = true;
11171 else
11172 stats.mRefDbgLoc = nextInst->mDbgLoc;
11173 }
11174 }
11175 }
11176 else
11177 {
11178 auto operands = { &inst->mArg0, &inst->mArg1 };

Callers

nothing calls this directly

Calls 8

BeMCOperandClass · 0.85
IsPsuedoMethod · 0.80
TryGetValueMethod · 0.80
resizeMethod · 0.45
sizeMethod · 0.45
RemoveAtMethod · 0.45
TryAddMethod · 0.45
IsEmptyMethod · 0.45

Tested by

no test coverage detected