[llvm-bugs] [Bug 42032] New: [GlobalISel] Volatile load duplication - isObviouslySafeToFold is too eager

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 27 05:00:15 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42032

            Bug ID: 42032
           Summary: [GlobalISel] Volatile load duplication -
                    isObviouslySafeToFold is too eager
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: GlobalISel
          Assignee: unassignedbugs at nondot.org
          Reporter: alex.davies at iinet.net.au
                CC: llvm-bugs at lists.llvm.org, quentin.colombet at gmail.com

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)...

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190527/796c5287/attachment.html>


More information about the llvm-bugs mailing list