-
Notifications
You must be signed in to change notification settings - Fork 15k
Description
Bugzilla Link | 42032 |
Version | trunk |
OS | Windows NT |
Reporter | LLVM Bugzilla Contributor |
CC | @aemerson,@dsandersllvm,@qcolombet |
Extended Description
isObviouslySafeToFold reports that any neighbouring instructions can "obviously" be folded.
However, globalisel folds without ensuring deletion (as their values may still be live), and so volatile operations can be duplicated erroneously.
One possible workaround:
bool InstructionSelector::isObviouslySafeToFold(MachineInstr &MI,
MachineInstr &IntoMI) const {
// Volatile accesses require special handling:
if (MI.mayLoadOrStore()) {
for (auto mem : MI.memoperands()) {
if (mem->isVolatile())
return false;
}
}
// Immediate neighbours are already folded.
if (MI.getParent() == IntoMI.getParent() &&
std::next(MI.getIterator()) == IntoMI.getIterator())
return !MI.mayLoadOrStore() && !MI.hasUnmodeledSideEffects() &&
empty(MI.implicit_operands());
}
But then, maybe it's time to start discussing improving this whole part of the pattern matcher? Given that at the moment only neighbouring ld/st are considered at all (and once fixed, not if volatile)...