Skip to content

Commit c9ab120

Browse files
authored
merge main into amd-staging (llvm#2258)
2 parents a71ebb5 + e2d4604 commit c9ab120

File tree

213 files changed

+3961
-2283
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

213 files changed

+3961
-2283
lines changed

clang-tools-extra/clangd/ModulesBuilder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ bool IsModuleFileUpToDate(PathRef ModuleFilePath,
207207
Preprocessor PP(PPOpts, *Diags, LangOpts, SourceMgr, HeaderInfo,
208208
ModuleLoader);
209209

210-
IntrusiveRefCntPtr<ModuleCache> ModCache =
211-
createCrossProcessModuleCache(HSOpts.BuildSessionTimestamp);
210+
IntrusiveRefCntPtr<ModuleCache> ModCache = createCrossProcessModuleCache();
212211
PCHContainerOperations PCHOperations;
213212
ASTReader Reader(PP, *ModCache, /*ASTContext=*/nullptr,
214213
PCHOperations.getRawReader(), {});

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,6 @@ def IfOp : CIR_Op<"if",
553553
let arguments = (ins CIR_BoolType:$condition);
554554
let regions = (region AnyRegion:$thenRegion, AnyRegion:$elseRegion);
555555
let hasCustomAssemblyFormat=1;
556-
let hasVerifier=1;
557556
let skipDefaultBuilders=1;
558557
let builders = [
559558
OpBuilder<(ins "mlir::Value":$cond, "bool":$withElseRegion,

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ struct MissingFeatures {
9090
static bool opCallArgEvaluationOrder() { return false; }
9191
static bool opCallCallConv() { return false; }
9292
static bool opCallSideEffect() { return false; }
93-
static bool opCallChainCall() { return false; }
9493
static bool opCallNoPrototypeFunc() { return false; }
9594
static bool opCallMustTail() { return false; }
9695
static bool opCallIndirect() { return false; }
@@ -107,6 +106,13 @@ struct MissingFeatures {
107106
static bool opCallLandingPad() { return false; }
108107
static bool opCallContinueBlock() { return false; }
109108

109+
// FnInfoOpts -- This is used to track whether calls are chain calls or
110+
// instance methods. Classic codegen uses chain call to track and extra free
111+
// register for x86 and uses instance method as a condition for a thunk
112+
// generation special case. It's not clear that we need either of these in
113+
// pre-lowering CIR codegen.
114+
static bool opCallFnInfoOpts() { return false; }
115+
110116
// ScopeOp handling
111117
static bool opScopeCleanupRegion() { return false; }
112118

@@ -189,6 +195,12 @@ struct MissingFeatures {
189195
static bool constEmitterArrayILE() { return false; }
190196
static bool constEmitterVectorILE() { return false; }
191197
static bool needsGlobalCtorDtor() { return false; }
198+
static bool emitTypeCheck() { return false; }
199+
static bool cxxabiThisDecl() { return false; }
200+
static bool cxxabiThisAlignment() { return false; }
201+
static bool writebacks() { return false; }
202+
static bool cleanupsToDeactivate() { return false; }
203+
static bool stackBase() { return false; }
192204

193205
// Missing types
194206
static bool dataMemberType() { return false; }

clang/include/clang/Serialization/ModuleCache.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,17 @@ class ModuleCache : public RefCountedBase<ModuleCache> {
3333
virtual std::unique_ptr<llvm::AdvisoryLock>
3434
getLock(StringRef ModuleFilename) = 0;
3535

36+
// TODO: Abstract away timestamps with isUpToDate() and markUpToDate().
3637
// TODO: Consider exposing a "validation lock" API to prevent multiple clients
3738
// concurrently noticing an out-of-date module file and validating its inputs.
3839

39-
/// Checks whether the inputs of the module file were marked as validated.
40-
virtual bool isMarkedUpToDate(StringRef ModuleFilename) = 0;
40+
/// Returns the timestamp denoting the last time inputs of the module file
41+
/// were validated.
42+
virtual std::time_t getModuleTimestamp(StringRef ModuleFilename) = 0;
4143

42-
/// Marks the inputs of the module file as validated.
43-
virtual void markUpToDate(StringRef ModuleFilename) = 0;
44+
/// Updates the timestamp denoting the last time inputs of the module file
45+
/// were validated.
46+
virtual void updateModuleTimestamp(StringRef ModuleFilename) = 0;
4447

4548
/// Returns this process's view of the module cache.
4649
virtual InMemoryModuleCache &getInMemoryModuleCache() = 0;
@@ -55,8 +58,7 @@ class ModuleCache : public RefCountedBase<ModuleCache> {
5558
/// operated on by multiple processes. This instance must be used across all
5659
/// \c CompilerInstance instances participating in building modules for single
5760
/// translation unit in order to share the same \c InMemoryModuleCache.
58-
IntrusiveRefCntPtr<ModuleCache>
59-
createCrossProcessModuleCache(std::time_t BuildSessionTimestamp);
61+
IntrusiveRefCntPtr<ModuleCache> createCrossProcessModuleCache();
6062
} // namespace clang
6163

6264
#endif

clang/include/clang/Serialization/ModuleFile.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,11 @@ class ModuleFile {
270270
// system input files reside at [NumUserInputFiles, InputFilesLoaded.size()).
271271
unsigned NumUserInputFiles = 0;
272272

273-
/// Specifies whether the input files have been validated (i.e. checked
274-
/// whether they are up-to-date).
275-
bool InputFilesValidated = false;
273+
/// If non-zero, specifies the time when we last validated input
274+
/// files. Zero means we never validated them.
275+
///
276+
/// The time is specified in seconds since the start of the Epoch.
277+
uint64_t InputFilesValidationTimestamp = 0;
276278

277279
// === Source Locations ===
278280

clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h"
1313
#include "clang/Tooling/DependencyScanning/InProcessModuleCache.h"
1414
#include "llvm/ADT/BitmaskEnum.h"
15+
#include "llvm/Support/Chrono.h"
1516

1617
namespace clang {
1718
namespace tooling {
@@ -84,7 +85,9 @@ class DependencyScanningService {
8485
DependencyScanningService(
8586
ScanningMode Mode, ScanningOutputFormat Format,
8687
ScanningOptimizations OptimizeArgs = ScanningOptimizations::Default,
87-
bool EagerLoadModules = false, bool TraceVFS = false);
88+
bool EagerLoadModules = false, bool TraceVFS = false,
89+
std::time_t BuildSessionTimestamp =
90+
llvm::sys::toTimeT(std::chrono::system_clock::now()));
8891

8992
ScanningMode getMode() const { return Mode; }
9093

@@ -102,6 +105,8 @@ class DependencyScanningService {
102105

103106
ModuleCacheEntries &getModuleCacheEntries() { return ModCacheEntries; }
104107

108+
std::time_t getBuildSessionTimestamp() const { return BuildSessionTimestamp; }
109+
105110
private:
106111
const ScanningMode Mode;
107112
const ScanningOutputFormat Format;
@@ -115,6 +120,8 @@ class DependencyScanningService {
115120
DependencyScanningFilesystemSharedCache SharedCache;
116121
/// The global module cache entries.
117122
ModuleCacheEntries ModCacheEntries;
123+
/// The build session timestamp.
124+
std::time_t BuildSessionTimestamp;
118125
};
119126

120127
} // end namespace dependencies

clang/include/clang/Tooling/DependencyScanning/InProcessModuleCache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace tooling {
2020
namespace dependencies {
2121
struct ModuleCacheEntry {
2222
std::shared_mutex CompilationMutex;
23-
std::atomic<bool> UpToDate = false;
23+
std::atomic<std::time_t> Timestamp = 0;
2424
};
2525

2626
struct ModuleCacheEntries {

clang/lib/Basic/Targets/AMDGPU.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ static const char *const DataLayoutStringR600 =
3333

3434
static const char *const DataLayoutStringAMDGCN =
3535
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32"
36-
"-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:"
37-
"32-v48:64-v96:128"
38-
"-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1"
39-
"-ni:7:8:9";
36+
"-p7:160:256:256:32-p8:128:128:128:48-p9:192:256:256:32-i64:64-"
37+
"v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-"
38+
"v2048:2048-n32:64-S32-A5-G1-ni:7:8:9";
4039

4140
const LangASMap AMDGPUTargetInfo::AMDGPUDefIsGenMap = {
4241
llvm::AMDGPUAS::FLAT_ADDRESS, // Default
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This provides an abstract class for C++ code generation. Concrete subclasses
10+
// of this implement code generation for specific C++ ABIs.
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
#include "CIRGenCXXABI.h"
15+
#include "CIRGenFunction.h"
16+
17+
#include "clang/AST/Decl.h"
18+
#include "clang/AST/GlobalDecl.h"
19+
20+
using namespace clang;
21+
using namespace clang::CIRGen;
22+
23+
CIRGenCXXABI::~CIRGenCXXABI() {}
24+
25+
void CIRGenCXXABI::buildThisParam(CIRGenFunction &cgf,
26+
FunctionArgList &params) {
27+
const auto *md = cast<CXXMethodDecl>(cgf.curGD.getDecl());
28+
29+
// FIXME: I'm not entirely sure I like using a fake decl just for code
30+
// generation. Maybe we can come up with a better way?
31+
auto *thisDecl =
32+
ImplicitParamDecl::Create(cgm.getASTContext(), nullptr, md->getLocation(),
33+
&cgm.getASTContext().Idents.get("this"),
34+
md->getThisType(), ImplicitParamKind::CXXThis);
35+
params.push_back(thisDecl);
36+
37+
// Classic codegen save thisDecl in CodeGenFunction::CXXABIThisDecl, but it
38+
// doesn't seem to be needed in CIRGen.
39+
assert(!cir::MissingFeatures::cxxabiThisDecl());
40+
41+
// Classic codegen computes the alignment of thisDecl and saves it in
42+
// CodeGenFunction::CXXABIThisAlignment, but it doesn't seem to be needed in
43+
// CIRGen.
44+
assert(!cir::MissingFeatures::cxxabiThisAlignment());
45+
}

clang/lib/CIR/CodeGen/CIRGenCXXABI.h

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifndef LLVM_CLANG_LIB_CIR_CIRGENCXXABI_H
1515
#define LLVM_CLANG_LIB_CIR_CIRGENCXXABI_H
1616

17+
#include "CIRGenCall.h"
1718
#include "CIRGenModule.h"
1819

1920
#include "clang/AST/Mangle.h"
@@ -31,9 +32,33 @@ class CIRGenCXXABI {
3132
// implemented.
3233
CIRGenCXXABI(CIRGenModule &cgm)
3334
: cgm(cgm), mangleContext(cgm.getASTContext().createMangleContext()) {}
34-
~CIRGenCXXABI();
35+
virtual ~CIRGenCXXABI();
3536

3637
public:
38+
/// Get the type of the implicit "this" parameter used by a method. May return
39+
/// zero if no specific type is applicable, e.g. if the ABI expects the "this"
40+
/// parameter to point to some artificial offset in a complete object due to
41+
/// vbases being reordered.
42+
virtual const clang::CXXRecordDecl *
43+
getThisArgumentTypeForMethod(const clang::CXXMethodDecl *md) {
44+
return md->getParent();
45+
}
46+
47+
/// Build a parameter variable suitable for 'this'.
48+
void buildThisParam(CIRGenFunction &cgf, FunctionArgList &params);
49+
50+
/// Returns true if the given constructor or destructor is one of the kinds
51+
/// that the ABI says returns 'this' (only applies when called non-virtually
52+
/// for destructors).
53+
///
54+
/// There currently is no way to indicate if a destructor returns 'this' when
55+
/// called virtually, and CIR generation does not support this case.
56+
virtual bool hasThisReturn(clang::GlobalDecl gd) const { return false; }
57+
58+
virtual bool hasMostDerivedReturn(clang::GlobalDecl gd) const {
59+
return false;
60+
}
61+
3762
/// Gets the mangle context.
3863
clang::MangleContext &getMangleContext() { return *mangleContext; }
3964
};

0 commit comments

Comments
 (0)