llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.67k stars 11.85k forks source link

[PCH] contents of header file is fully read with -g despite compiling with pch #47117

Open wolfy1961 opened 4 years ago

wolfy1961 commented 4 years ago
Bugzilla Link 47773
Version trunk
OS All
Attachments Test case
CC @pogo59,@zygoloid,@rgal,@yuanfang-chen

Extended Description

With -g the frontend seems to read the contents of a header file in its entirety even when compiling with pch. This happens as part of the effort to establish source locations for entities (a type in the attached test case) for which debug locations are emitted. SourceManager::getPresumedLoc() attempts to compute line numbers and in the process reads the header file.

The attached test case is for linux and uses the utility inotifywait to demonstrate the file access (a stat call does not trigger a notification BTW, only a read).

Set CLANG to a recently built clang and do

make; make all

wolfy1961 commented 4 years ago

It's causing compile time slow down for one of our licensees across thousands of headers. It seems to me that the source information should be available from the AST so that the header does not need to be reopened.

dwblaikie commented 4 years ago

Not entirely clear if this is a bug, though - what problem does this cause/what do you expect to happen instead?

wolfy1961 commented 4 years ago

On a Windows hosted compiler the read can be observed with ProcMon.