[silcodemotion] For now stash a pointer to EnumCaseDataflowContext in each of the block states that we are tracking.

In a subsequent commit, I will change this to use a trailing objects
implementation so we can just use pointer arithmetic to find the offset. But for
now I am going for simplicity since this is a bug fix.

rdar://36032876
This commit is contained in:
Michael Gottesman
2017-12-18 12:23:26 -08:00
parent 48bb2d16f1
commit 77441fcdd1

View File

@@ -118,6 +118,7 @@ using EnumBBCaseList =
/// Class that performs enum tag state dataflow on the given BB. /// Class that performs enum tag state dataflow on the given BB.
class BBEnumTagDataflowState class BBEnumTagDataflowState
: public SILInstructionVisitor<BBEnumTagDataflowState, bool> { : public SILInstructionVisitor<BBEnumTagDataflowState, bool> {
EnumCaseDataflowContext *Context;
NullablePtr<SILBasicBlock> BB; NullablePtr<SILBasicBlock> BB;
using ValueToCaseSmallBlotMapVectorTy = using ValueToCaseSmallBlotMapVectorTy =
@@ -137,11 +138,7 @@ public:
LLVM_ATTRIBUTE_DEPRECATED(void dump() const LLVM_ATTRIBUTE_USED, LLVM_ATTRIBUTE_DEPRECATED(void dump() const LLVM_ATTRIBUTE_USED,
"only for use within the debugger"); "only for use within the debugger");
bool init(SILBasicBlock *NewBB) { bool init(EnumCaseDataflowContext &Context, SILBasicBlock *NewBB);
assert(NewBB && "NewBB should not be null");
BB = NewBB;
return true;
}
SILBasicBlock *getBB() { return BB.get(); } SILBasicBlock *getBB() { return BB.get(); }
@@ -200,7 +197,7 @@ public:
BBToStateVec.resize(PO->size()); BBToStateVec.resize(PO->size());
unsigned RPOIdx = 0; unsigned RPOIdx = 0;
for (SILBasicBlock *BB : PO->getReversePostOrder()) { for (SILBasicBlock *BB : PO->getReversePostOrder()) {
BBToStateVec[RPOIdx].init(BB); BBToStateVec[RPOIdx].init(*this, BB);
++RPOIdx; ++RPOIdx;
} }
} }
@@ -757,6 +754,14 @@ void BBEnumTagDataflowState::dump() const {
#endif #endif
} }
bool BBEnumTagDataflowState::init(EnumCaseDataflowContext &NewContext,
SILBasicBlock *NewBB) {
assert(NewBB && "NewBB should not be null");
Context = &NewContext;
BB = NewBB;
return true;
}
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Generic Sinking Code // Generic Sinking Code
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//