Page MenuHomePhabricator

Store token literal data in PCH. Avoids disk read on PreProc expansion.
Needs ReviewPublic

Authored by v.g.vassilev on Jul 4 2017, 7:42 AM.

Details

Reviewers
rsmith
Summary

Patch by Axel Naumann!

Diff Detail

Event Timeline

v.g.vassilev created this revision.Jul 4 2017, 7:42 AM
v.g.vassilev added a subscriber: karies.

What would be the best way to test this. Shall we put:

echo '#define LITERAL 42' > HEADER.h

clang++ -std=c++14 -x c++-header -o HEADER.h.pch HEADER.h

chmod a-r HEADER.h

echo 'void f(int); void g() { f(12); }' | clang++ -std=c++14 -Xclang
-fno-validate-pch -include-pch HEADER.h.pch -c -Xclang -emit-llvm -o -
-x c++ -
# works, we see the IR

echo 'void f(int); void g() { f(LITERAL); }' | clang++ -std=c++14
-Xclang -fno-validate-pch -include-pch HEADER.h.pch -c -Xclang
-emit-llvm -o - -x c++ -
fatal error: cannot open file
'/home/axel/build/tmp/clang-repro-PCH-touches-disk-for-literal/HEADER.h':
Permission denied
1 error generated.

Fix StringRef allocation.

rsmith edited edge metadata.Aug 23 2017, 11:45 AM

Seems reasonable to store this with the token. Do you have performance data?

include/clang/Serialization/ASTReader.h
616

Remove this use pointers directly into blob data from the token record (or BumpPtrAllocate the strings using the preprocessor's allocator if there's some reason you can't use blob data).

lib/Serialization/ASTWriter.cpp
4360

Remove this FIXME

Add a test case.