[PATCH] D49362: [ThinLTO] Internalize read only globals

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 14 08:00:24 PST 2018


tejohnson added a comment.

In https://reviews.llvm.org/D49362#1297188, @steven_wu wrote:

> I reverted this in r346768.
>
> I think this is indeed a caching problem. There are some dylib/binary in clang projects that toggles whether to enable the recovery context but some does not. I can reproduce the issue by thin link libclang.dylib first, then link clang-func-mapping on Darwin.
>  libclang.dylib thinks the file scope variable gCrashRecoveryEnabled not read-only, so it promotes it.
>  clang-func-mapping thinks gCrashRecoveryEnabled read-only, so it internalize and constant propagate the variable but ParseAST.o in the cache is still expecting gCrashRecoveryEnabled to be available.
>
> Let me know if you need more information.


Thinking through this example, I'm not sure what is going on. This patch did change the cache key computation to include the read only bit from the global var summary of anything defined or imported. Since gCrashRecoveryEnabled is a static in CrashRecoveryContext.cpp, it must have been imported into ParseAST.o, which means that the read only bit on the associated gvar summary should have been hashed into ParseAST.o's cache key. So presumably we shouldn't have had a cache hit for ParseAST.o (built when the read only bit is not set on gCrashRecoveryEnabled) when thin linking clang-func-mapping which has this bit set for that variable.

Even if the variable was originally externally visible, in order for it to be marked read only by the thin link it would have had to have been imported at all use sites. Which means that any referencing module had to have it in the import set (and therefore would have hashed the read only bit) in the thin link where it was marked read only. So I am not sure offhand why we could ever share a referencing object between a link where it was read only and another link where it is not...   Hopefully Eugene can figure out what is going wrong here.


Repository:
  rL LLVM

https://reviews.llvm.org/D49362





More information about the llvm-commits mailing list