LLVM dot-callgraph generates output dotfiles outside of the current directory

LLVM dot-callgraph is one of the LLVM passes that will generate dot files of the program graph. Apart from dot-callgraph, there are also the following passes:

dot pass name Description
dot-callgraph Print call graph to 'dot' file
dot-cfg Print CFG of function to 'dot' file
dot-cfg-only Print CFG of function to 'dot' file (with no function bodies)
dot-dom Print dominance tree of function to 'dot' file
dot-dom-only Print dominance tree of function to 'dot' file (with no function bodies)
dot-postdom Print postdominance tree of function to 'dot' file
dot-postdom-only Print postdominance tree of function to 'dot' file (with no function bodies)
dot-regions Print regions of function to 'dot' file
dot-regions-only Print regions of function to 'dot' file (with no function bodies)
dot-scops Polly - Print Scops of function
dot-scops-only Polly - Print Scops of function (with no function bodies)

I just noticed today that in LLVM 13, dot callgraph is generating the output in the location of the IR ll files instead of the in the current directory. However, all other dot-* passes are still generating the dot files in the current directory. Hence this is an inconsistent behaviour which should be fixed, in my opinion. The changes must be happening between version 10 and 13. I will try to look where and how the changes happen.

This is the output from LLVM 13.

This is the output from LLVM 10.