Skip to content

Pass UseCASBackend flag to replayCachedResult (cherry-pick https://github.com/apple/llvm-project/pull/8002 to stable/20230725 branch) #8023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions clang/include/clang/Frontend/CompileJobCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ class CompileJobCache {
/// \returns true if finished successfully.
bool finishComputedResult(CompilerInstance &Clang, bool Success);

static llvm::Expected<std::optional<int>> replayCachedResult(
std::shared_ptr<CompilerInvocation> Invok, StringRef WorkingDir,
const llvm::cas::CASID &CacheKey,
cas::CompileJobCacheResult &CachedResult, SmallVectorImpl<char> &DiagText,
bool WriteOutputAsCASID = false, bool UseCASBackend = false,
std::optional<llvm::cas::CASID> *MCOutputID = nullptr);
static llvm::Expected<std::optional<int>>
replayCachedResult(std::shared_ptr<CompilerInvocation> Invok,
StringRef WorkingDir, const llvm::cas::CASID &CacheKey,
cas::CompileJobCacheResult &CachedResult,
SmallVectorImpl<char> &DiagText,
bool WriteOutputAsCASID = false,
std::optional<llvm::cas::CASID> *MCOutputID = nullptr);

class CachingOutputs;

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Frontend/CompileJobCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ Expected<std::optional<int>> CompileJobCache::replayCachedResult(
std::shared_ptr<CompilerInvocation> Invok, StringRef WorkingDir,
const llvm::cas::CASID &CacheKey, cas::CompileJobCacheResult &CachedResult,
SmallVectorImpl<char> &DiagText, bool WriteOutputAsCASID,
bool UseCASBackend, std::optional<llvm::cas::CASID> *OutMCOutputID) {
std::optional<llvm::cas::CASID> *OutMCOutputID) {
CompilerInstance Clang;
Clang.setInvocation(std::move(Invok));
llvm::raw_svector_ostream DiagOS(DiagText);
Expand Down Expand Up @@ -573,7 +573,7 @@ Expected<std::optional<int>> CompileJobCache::replayCachedResult(
std::optional<llvm::cas::CASID> MCOutputID;
ObjectStoreCachingOutputs CachingOutputs(
Clang, WorkingDir, std::move(PrefixMapper), WriteOutputAsCASID,
UseCASBackend, MCOutputID,
Clang.getInvocation().getCodeGenOpts().UseCASBackend, MCOutputID,
/*CAS*/ nullptr, /*Cache*/ nullptr);
if (OutMCOutputID)
*OutMCOutputID = std::move(MCOutputID);
Expand Down
20 changes: 20 additions & 0 deletions clang/test/CAS/mccas-replay.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// RUN: rm -rf %t && mkdir %t

// RUN: %clang -cc1depscan -o %t/args.rsp -cc1-args -cc1 \
// RUN: -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb \
// RUN: -emit-obj -fcas-backend -fcas-path %t/cas %s -o - > /dev/null

// RUN: %clang @%t/args.rsp -o %t/output1.o -Rcompile-job-cache 2> %t/output1.txt

// RUN: cat %t/output1.txt | grep llvmcas | sed \
// RUN: -e "s/^.*miss for '//" \
// RUN: -e "s/' .*$//" > %t/cache-key

// RUN: c-index-test core -replay-cached-job -cas-path %t/cas @%t/cache-key \
// RUN: -working-dir %t -- @%t/args.rsp -o %t/output2.o

// RUN: diff %t/output1.o %t/output2.o

int foo(int x) {
return x+1;
}