diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-03-02 15:57:43 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-03-02 15:57:43 -0800 |
commit | 689b9334c8c92fed2b94645d17c47078822388cd (patch) | |
tree | 2c57f706f8ae02bc671cdfb61854ab2704870365 | |
parent | dc59054db06864099c1b1051b8ef28a30f13e6c7 (diff) |
tolerate phis that refer to values from unreachable blocks
-rw-r--r-- | lib/Target/JSBackend/ExpandI64.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/Target/JSBackend/ExpandI64.cpp b/lib/Target/JSBackend/ExpandI64.cpp index cc63d01c7f..e595594e41 100644 --- a/lib/Target/JSBackend/ExpandI64.cpp +++ b/lib/Target/JSBackend/ExpandI64.cpp @@ -87,7 +87,14 @@ namespace { // The value can also be a constant, in which case we just // split it, or a function argument, in which case we // map to the proper legalized new arguments - ChunksVec getChunks(Value *V); + // + // @param AllowUnreachable It is possible for phi nodes + // to refer to unreachable blocks, + // which our traversal never + // reaches; this flag lets us + // ignore those - otherwise, + // not finding chunks is fatal + ChunksVec getChunks(Value *V, bool AllowUnreachable=false); Function *Add, *Sub, *Mul, *SDiv, *UDiv, *SRem, *URem, *LShr, *AShr, *Shl, *GetHigh, *SetHigh, *FtoILow, *FtoIHigh, *DtoILow, *DtoIHigh, *SItoF, *UItoF, *SItoD, *UItoD, *BItoD, *BDtoILow, *BDtoIHigh; @@ -902,7 +909,7 @@ bool ExpandI64::splitInst(Instruction *I) { return true; } -ChunksVec ExpandI64::getChunks(Value *V) { +ChunksVec ExpandI64::getChunks(Value *V, bool AllowUnreachable) { assert(isIllegal(V->getType())); unsigned Num = getNumChunks(V->getType()); @@ -928,7 +935,12 @@ ChunksVec ExpandI64::getChunks(Value *V) { return Chunks; } - assert(Splits.find(V) != Splits.end()); + if (Splits.find(V) == Splits.end()) { + if (AllowUnreachable) + return ChunksVec(Num, UndefValue::get(i32)); + errs() << *V << "\n"; + report_fatal_error("could not find chunks for illegal value"); + } assert(Splits[V].size() == Num); return Splits[V]; } @@ -1070,7 +1082,7 @@ bool ExpandI64::runOnModule(Module &M) { ChunksVec OutputChunks = getChunks(PN); for (unsigned j = 0, je = PN->getNumIncomingValues(); j != je; ++j) { Value *Op = PN->getIncomingValue(j); - ChunksVec InputChunks = getChunks(Op); + ChunksVec InputChunks = getChunks(Op, true); for (unsigned k = 0, ke = OutputChunks.size(); k != ke; ++k) { PHINode *NewPN = cast<PHINode>(OutputChunks[k]); NewPN->addIncoming(InputChunks[k], PN->getIncomingBlock(j)); |