Skip to content

Commit

Permalink
Fix undef-bug.ll phi case
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Skvortsov committed Mar 16, 2020
1 parent 3307990 commit 8aeb1b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion llvm/lib/Target/TVM/TVMStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ void Stack::dump() const {
#endif

void Stack::printElement(raw_ostream &OS, const StackVreg &Vreg) const {
if (Vreg.VirtReg == TVMFunctionInfo::UnusedReg) {
if (Vreg.VirtReg == TVMFunctionInfo::UnusedReg ||
Vreg.VirtReg >= TRI->getNumRegs()) {
OS << "x";
return;
}
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/Target/TVM/TVMStackFixup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ StackFixup StackFixup::Diff(const Stack &to, const Stack &from) {

// Generate changes to re-order
assert(llvm::size(unmaskedTo) == llvm::size(curStack));
generateVagonXchgs(rv, curStack, unmaskedTo);
if (llvm::size(curStack) > 0)
generateVagonXchgs(rv, curStack, unmaskedTo);
rv.optimize();
return rv;
}
Expand Down Expand Up @@ -225,6 +226,7 @@ void StackFixup::generateVagonXchgs(StackFixup &rv, const Stack &from,

auto Tr = Train::build(curStack, to);
auto restVagons = llvm::make_range(Tr.Vagons.begin(), Tr.Vagons.end());
assert(restVagons.begin() != restVagons.end());
auto V = *restVagons.begin();
if (V.DeepIdx + 1 == Sz && !V.Inverted) {
restVagons = drop_begin(restVagons, 1);
Expand Down

0 comments on commit 8aeb1b0

Please sign in to comment.