Fix SelectionDAG Graph Printing on Windows
authorJustice Adams <justice.adams@sony.com>
Tue, 5 May 2020 23:58:44 +0000 (16:58 -0700)
committerReid Kleckner <rnk@google.com>
Wed, 6 May 2020 00:01:05 +0000 (17:01 -0700)
commit89c7451c35919a95aa654c6ff5204d3ceb37dd3d
tree9a910d294ba41e9b05eef9238fcb79957a31dae5
parent0274c797c65a720010aee7f40cff621cd993ba15
Fix SelectionDAG Graph Printing on Windows

Currently, when compiling to IR (presumably at the clang level) LLVM
mangles symbols and sometimes they have illegal file characters
including `?`'s in them. This causes a problem when building a graph via
llc on Windows because the code currently passes the machine function
name all the way down to the Windows API which frequently returns error
123  **ERROR_INVALID_NAME**
https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-

Thus, we need to remove those illegal characters from the machine
function name before generating a graph, which is the purpose of this
patch.
https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file

I've created a static helper function replace_illegal_filename_chars
which within GraphWriter.cpp to help with replacing illegal file
character names before generating a dot graph filename.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D76863
llvm/include/llvm/Support/GraphWriter.h
llvm/lib/Support/GraphWriter.cpp