def _order_pases(self, passes):
        passes = set(passes)
        pass_deps = {}
        for opt in passes:
            _, before, after = self._known_passes[opt]
            if opt not in pass_deps:
                pass_deps[opt] = set()
            for after_pass in after:
                pass_deps[opt].add(after_pass)
            for other in before:
                if other not in passes:
                    continue
                if other not in pass_deps:
                    pass_deps[other] = set()
                pass_deps[other].add(opt)
        return toposort_flatten(pass_deps)