[all-commits] [llvm/llvm-project] 15692e: [TableGen][SourceMgr] Correctly append filename to...

zero9178 via All-commits all-commits at lists.llvm.org
Mon Jan 9 00:04:28 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 15692e7487b3a96edfe5409c84480ac21d01d768
      https://github.com/llvm/llvm-project/commit/15692e7487b3a96edfe5409c84480ac21d01d768
  Author: Markus Böck <markus.boeck02 at gmail.com>
  Date:   2023-01-09 (Mon, 09 Jan 2023)

  Changed paths:
    M llvm/lib/Support/SourceMgr.cpp

  Log Message:
  -----------
  [TableGen][SourceMgr] Correctly append filename to include directories

The current implementation unconditionally appends the system path separator with the filename to the include directory. This is not correct in edge cases however, such as when specifying `/` as include directory (on Unix systems) or just `\` on Windows.
This patch fixes that by using `sys::path::append`, which already has the required logic to correctly implement this.

While this is technically only a change in the `SourceMgr` class, I think the main user of that class, and the include mechanism, is TableGen.
No test attached because no behavioral difference is observable without trying to access the root directory of the users filesystem.

The motivation for this change is a rather funny story, as this actually fixes a performance problem when running `check-mlir` on Windows.
Some tests for `mlir-pdll-lsp-server` lead to adding `\` as include directory in TableGen (which is a valid absolute path on Windows!). Due to the unconditional append, the created filepath would then be of the form `\\<dir>\...` which is also a valid path on Windows, but is a network path. On my machine it'd then attempt to access the network and find a machine with the name `<dir>` and the file there. This call would take several seconds, leading to some tests in `mlir-pdll-lsp-server` taking 2 minutes on my machine.

Running `check-mlir` after this patch reduces the runtime on my machine from 161 seconds to 6 seconds.

Differential Revision: https://reviews.llvm.org/D141220




More information about the All-commits mailing list