Skip to content

Commit 7b18cc2

Browse files
Merge pull request #8023 from rastogishubham/UseCASBackendStable
Pass UseCASBackend flag to replayCachedResult (cherry-pick #8002 to stable/20230725 branch)
2 parents 186d2f0 + e309c92 commit 7b18cc2

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

clang/include/clang/Frontend/CompileJobCache.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,13 @@ class CompileJobCache {
8181
/// \returns true if finished successfully.
8282
bool finishComputedResult(CompilerInstance &Clang, bool Success);
8383

84-
static llvm::Expected<std::optional<int>> replayCachedResult(
85-
std::shared_ptr<CompilerInvocation> Invok, StringRef WorkingDir,
86-
const llvm::cas::CASID &CacheKey,
87-
cas::CompileJobCacheResult &CachedResult, SmallVectorImpl<char> &DiagText,
88-
bool WriteOutputAsCASID = false, bool UseCASBackend = false,
89-
std::optional<llvm::cas::CASID> *MCOutputID = nullptr);
84+
static llvm::Expected<std::optional<int>>
85+
replayCachedResult(std::shared_ptr<CompilerInvocation> Invok,
86+
StringRef WorkingDir, const llvm::cas::CASID &CacheKey,
87+
cas::CompileJobCacheResult &CachedResult,
88+
SmallVectorImpl<char> &DiagText,
89+
bool WriteOutputAsCASID = false,
90+
std::optional<llvm::cas::CASID> *MCOutputID = nullptr);
9091

9192
class CachingOutputs;
9293

clang/lib/Frontend/CompileJobCache.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ Expected<std::optional<int>> CompileJobCache::replayCachedResult(
542542
std::shared_ptr<CompilerInvocation> Invok, StringRef WorkingDir,
543543
const llvm::cas::CASID &CacheKey, cas::CompileJobCacheResult &CachedResult,
544544
SmallVectorImpl<char> &DiagText, bool WriteOutputAsCASID,
545-
bool UseCASBackend, std::optional<llvm::cas::CASID> *OutMCOutputID) {
545+
std::optional<llvm::cas::CASID> *OutMCOutputID) {
546546
CompilerInstance Clang;
547547
Clang.setInvocation(std::move(Invok));
548548
llvm::raw_svector_ostream DiagOS(DiagText);
@@ -573,7 +573,7 @@ Expected<std::optional<int>> CompileJobCache::replayCachedResult(
573573
std::optional<llvm::cas::CASID> MCOutputID;
574574
ObjectStoreCachingOutputs CachingOutputs(
575575
Clang, WorkingDir, std::move(PrefixMapper), WriteOutputAsCASID,
576-
UseCASBackend, MCOutputID,
576+
Clang.getInvocation().getCodeGenOpts().UseCASBackend, MCOutputID,
577577
/*CAS*/ nullptr, /*Cache*/ nullptr);
578578
if (OutMCOutputID)
579579
*OutMCOutputID = std::move(MCOutputID);

clang/test/CAS/mccas-replay.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: rm -rf %t && mkdir %t
2+
3+
// RUN: %clang -cc1depscan -o %t/args.rsp -cc1-args -cc1 \
4+
// RUN: -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb \
5+
// RUN: -emit-obj -fcas-backend -fcas-path %t/cas %s -o - > /dev/null
6+
7+
// RUN: %clang @%t/args.rsp -o %t/output1.o -Rcompile-job-cache 2> %t/output1.txt
8+
9+
// RUN: cat %t/output1.txt | grep llvmcas | sed \
10+
// RUN: -e "s/^.*miss for '//" \
11+
// RUN: -e "s/' .*$//" > %t/cache-key
12+
13+
// RUN: c-index-test core -replay-cached-job -cas-path %t/cas @%t/cache-key \
14+
// RUN: -working-dir %t -- @%t/args.rsp -o %t/output2.o
15+
16+
// RUN: diff %t/output1.o %t/output2.o
17+
18+
int foo(int x) {
19+
return x+1;
20+
}

0 commit comments

Comments
 (0)