aboutsummaryrefslogtreecommitdiffstats
path: root/dist
diff options
context:
space:
mode:
authorIvan Donchevskii <ivan.donchevskii@qt.io>2017-05-24 15:24:37 +0200
committerNikolai Kosjar <nikolai.kosjar@qt.io>2017-07-13 13:23:46 +0000
commit42ceae5e47d3df7dfe5f7953c46ebd919387f9b6 (patch)
tree88a8a6d320b86bed6b4fc5094356dab7a1883931 /dist
parent7acbef5a904a509f07b4df45f7431d887995c7c0 (diff)
Clang: Add patch improving reparse performance on windows
Patch provides faster preamble loading by improving the handling of diagnostics. Change-Id: I61a79160e0272335d6d4e76478a7a35760cdf9ef Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Diffstat (limited to 'dist')
-rw-r--r--dist/clang/patches/D29755_Cache-FileID-when-translating-diagnostics-in-PCH-files.patch25
-rw-r--r--dist/clang/patches/D33493_Cache-source-locations-on-PCH-loading.patch51
2 files changed, 51 insertions, 25 deletions
diff --git a/dist/clang/patches/D29755_Cache-FileID-when-translating-diagnostics-in-PCH-files.patch b/dist/clang/patches/D29755_Cache-FileID-when-translating-diagnostics-in-PCH-files.patch
deleted file mode 100644
index 41e7c1d2c3..0000000000
--- a/dist/clang/patches/D29755_Cache-FileID-when-translating-diagnostics-in-PCH-files.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-diff --git a/tools/clang/lib/Frontend/ASTUnit.cpp b/tools/clang/lib/Frontend/ASTUnit.cpp
-index d892996..5148a8b 100644
---- a/tools/clang/lib/Frontend/ASTUnit.cpp
-+++ b/tools/clang/lib/Frontend/ASTUnit.cpp
-@@ -2534,6 +2534,8 @@ void ASTUnit::TranslateStoredDiagnostics(
-
- SmallVector<StoredDiagnostic, 4> Result;
- Result.reserve(Diags.size());
-+ const FileEntry *PreviousFE = nullptr;
-+ FileID FID;
- for (const StandaloneDiagnostic &SD : Diags) {
- // Rebuild the StoredDiagnostic.
- if (SD.Filename.empty())
-@@ -2541,7 +2543,10 @@ void ASTUnit::TranslateStoredDiagnostics(
- const FileEntry *FE = FileMgr.getFile(SD.Filename);
- if (!FE)
- continue;
-- FileID FID = SrcMgr.translateFile(FE);
-+ if (FE != PreviousFE) {
-+ FID = SrcMgr.translateFile(FE);
-+ PreviousFE = FE;
-+ }
- SourceLocation FileLoc = SrcMgr.getLocForStartOfFile(FID);
- if (FileLoc.isInvalid())
- continue;
diff --git a/dist/clang/patches/D33493_Cache-source-locations-on-PCH-loading.patch b/dist/clang/patches/D33493_Cache-source-locations-on-PCH-loading.patch
new file mode 100644
index 0000000000..7a781ece28
--- /dev/null
+++ b/dist/clang/patches/D33493_Cache-source-locations-on-PCH-loading.patch
@@ -0,0 +1,51 @@
+diff --git a/tools/clang/include/clang/Frontend/ASTUnit.h b/tools/clang/include/clang/Frontend/ASTUnit.h
+index 04e6dce511..3eaf054139 100644
+--- a/tools/clang/include/clang/Frontend/ASTUnit.h
++++ b/tools/clang/include/clang/Frontend/ASTUnit.h
+@@ -184,6 +184,14 @@ private:
+ /// some number of calls.
+ unsigned PreambleRebuildCounter;
+
++ /// \brief Cache pairs "filename - source location"
++ ///
++ /// Cache contains only source locations from preamble so it is
++ /// guaranteed that they stay valid when the SourceManager is recreated.
++ /// This cache is used when loading preambule to increase performance
++ /// of that loading. It must be cleared when preamble is recreated.
++ llvm::StringMap<SourceLocation> PreambleSrcLocCache;
++
+ public:
+ class PreambleData {
+ const FileEntry *File;
+diff --git a/tools/clang/lib/Frontend/ASTUnit.cpp b/tools/clang/lib/Frontend/ASTUnit.cpp
+index 76fd00a132..c1c2680dcd 100644
+--- a/tools/clang/lib/Frontend/ASTUnit.cpp
++++ b/tools/clang/lib/Frontend/ASTUnit.cpp
+@@ -1142,6 +1142,8 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
+ if (SavedMainFileBuffer)
+ TranslateStoredDiagnostics(getFileManager(), getSourceManager(),
+ PreambleDiagnostics, StoredDiagnostics);
++ else
++ PreambleSrcLocCache.clear();
+
+ if (!Act->Execute())
+ goto error;
+@@ -2544,8 +2546,16 @@ void ASTUnit::TranslateStoredDiagnostics(
+ const FileEntry *FE = FileMgr.getFile(SD.Filename);
+ if (!FE)
+ continue;
+- FileID FID = SrcMgr.translateFile(FE);
+- SourceLocation FileLoc = SrcMgr.getLocForStartOfFile(FID);
++ SourceLocation FileLoc;
++ auto ItFileID = PreambleSrcLocCache.find(SD.Filename);
++ if (ItFileID == PreambleSrcLocCache.end()) {
++ FileID FID = SrcMgr.translateFile(FE);
++ FileLoc = SrcMgr.getLocForStartOfFile(FID);
++ PreambleSrcLocCache[SD.Filename] = FileLoc;
++ } else {
++ FileLoc = ItFileID->getValue();
++ }
++
+ if (FileLoc.isInvalid())
+ continue;
+ SourceLocation L = FileLoc.getLocWithOffset(SD.LocOffset);