Skip to content

Commit 3f2154c

Browse files
authored
merge main into amd-staging (llvm#1877)
2 parents c6ed4c0 + 36e53c7 commit 3f2154c

File tree

125 files changed

+24038
-2523
lines changed

Some content is hidden

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

125 files changed

+24038
-2523
lines changed

clang-tools-extra/clangd/Preamble.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,10 @@ buildPreamble(PathRef FileName, CompilerInvocation CI,
711711
Result->Marks = CapturedInfo.takeMarks();
712712
Result->StatCache = StatCache;
713713
Result->MainIsIncludeGuarded = CapturedInfo.isMainFileIncludeGuarded();
714-
Result->TargetOpts = CI.TargetOpts;
714+
// Move the options instead of copying them. The invocation doesn't need
715+
// them anymore.
716+
Result->TargetOpts =
717+
std::make_unique<TargetOptions>(std::move(CI.getTargetOpts()));
715718
if (PreambleCallback) {
716719
trace::Span Tracer("Running PreambleCallback");
717720
auto Ctx = CapturedInfo.takeLife();
@@ -932,7 +935,7 @@ void PreamblePatch::apply(CompilerInvocation &CI) const {
932935
// ParsedASTTest.PreambleWithDifferentTarget.
933936
// Make sure this is a deep copy, as the same Baseline might be used
934937
// concurrently.
935-
*CI.TargetOpts = *Baseline->TargetOpts;
938+
CI.getTargetOpts() = *Baseline->TargetOpts;
936939

937940
// No need to map an empty file.
938941
if (PatchContents.empty())

clang-tools-extra/clangd/Preamble.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ struct PreambleData {
103103
// Target options used when building the preamble. Changes in target can cause
104104
// crashes when deserializing preamble, this enables consumers to use the
105105
// same target (without reparsing CompileCommand).
106-
std::shared_ptr<TargetOptions> TargetOpts = nullptr;
106+
std::unique_ptr<TargetOptions> TargetOpts = nullptr;
107107
PrecompiledPreamble Preamble;
108108
std::vector<Diag> Diags;
109109
// Processes like code completions and go-to-definitions will need #include

clang-tools-extra/clangd/SystemIncludeExtractor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ bool isValidTarget(llvm::StringRef Triple) {
256256
DiagnosticsEngine Diags(new DiagnosticIDs, new DiagnosticOptions,
257257
new IgnoringDiagConsumer);
258258
llvm::IntrusiveRefCntPtr<TargetInfo> Target =
259-
TargetInfo::CreateTargetInfo(Diags, TargetOpts);
259+
TargetInfo::CreateTargetInfo(Diags, *TargetOpts);
260260
return bool(Target);
261261
}
262262

clang-tools-extra/modularize/ModularizeUtilities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ ModularizeUtilities::ModularizeUtilities(std::vector<std::string> &InputPaths,
5353
Diagnostics(
5454
new DiagnosticsEngine(DiagIDs, DiagnosticOpts.get(), &DC, false)),
5555
TargetOpts(new ModuleMapTargetOptions()),
56-
Target(TargetInfo::CreateTargetInfo(*Diagnostics, TargetOpts)),
56+
Target(TargetInfo::CreateTargetInfo(*Diagnostics, *TargetOpts)),
5757
FileMgr(new FileManager(FileSystemOpts)),
5858
SourceMgr(new SourceManager(*Diagnostics, *FileMgr, false)), HSOpts(),
5959
HeaderInfo(new HeaderSearch(HSOpts, *SourceMgr, *Diagnostics, *LangOpts,

clang/include/clang/Basic/TargetInfo.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ enum OpenCLTypeKind : uint8_t {
224224
///
225225
class TargetInfo : public TransferrableTargetInfo,
226226
public RefCountedBase<TargetInfo> {
227-
std::shared_ptr<TargetOptions> TargetOpts;
227+
TargetOptions *TargetOpts;
228228
llvm::Triple Triple;
229229
protected:
230230
// Target values set by the ctor of the actual target implementation. Default
@@ -310,10 +310,9 @@ class TargetInfo : public TransferrableTargetInfo,
310310
///
311311
/// \param Opts - The options to use to initialize the target. The target may
312312
/// modify the options to canonicalize the target feature information to match
313-
/// what the backend expects.
314-
static TargetInfo *
315-
CreateTargetInfo(DiagnosticsEngine &Diags,
316-
const std::shared_ptr<TargetOptions> &Opts);
313+
/// what the backend expects. These must outlive the returned TargetInfo.
314+
static TargetInfo *CreateTargetInfo(DiagnosticsEngine &Diags,
315+
TargetOptions &Opts);
317316

318317
virtual ~TargetInfo();
319318

clang/include/clang/Frontend/ASTUnit.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ class ASTUnit {
143143
/// Parse available.
144144
std::shared_ptr<CompilerInvocation> CCInvocation;
145145

146+
/// Optional owned invocation, just used to keep the invocation alive for the
147+
/// members initialized in transferASTDataFromCompilerInstance.
148+
std::shared_ptr<CompilerInvocation> ModifiedInvocation;
149+
146150
/// Fake module loader: the AST unit doesn't need to load any modules.
147151
TrivialModuleLoader ModuleLoader;
148152

clang/include/clang/Frontend/CompilerInstance.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ class CompilerInstance : public ModuleLoader {
8888
/// The target being compiled for.
8989
IntrusiveRefCntPtr<TargetInfo> Target;
9090

91+
/// Options for the auxiliary target.
92+
std::unique_ptr<TargetOptions> AuxTargetOpts;
93+
9194
/// Auxiliary Target info.
9295
IntrusiveRefCntPtr<TargetInfo> AuxTarget;
9396

clang/include/clang/Frontend/CompilerInvocation.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ class CompilerInvocation : public CompilerInvocationBase {
268268
/// Base class internals.
269269
/// @{
270270
using CompilerInvocationBase::LangOpts;
271-
using CompilerInvocationBase::TargetOpts;
272271
std::shared_ptr<LangOptions> getLangOptsPtr() { return LangOpts; }
273272
/// @}
274273

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4798,10 +4798,6 @@ bool Compiler<Emitter>::VisitBuiltinCallExpr(const CallExpr *E,
47984798
return true;
47994799
}
48004800

4801-
const Function *Func = getFunction(E->getDirectCallee());
4802-
if (!Func)
4803-
return false;
4804-
48054801
// For these, we're expected to ultimately return an APValue pointing
48064802
// to the CallExpr. This is needed to get the correct codegen.
48074803
if (BuiltinID == Builtin::BI__builtin___CFStringMakeConstantString ||
@@ -4825,15 +4821,15 @@ bool Compiler<Emitter>::VisitBuiltinCallExpr(const CallExpr *E,
48254821
return false;
48264822
}
48274823

4828-
if (!Func->isUnevaluatedBuiltin()) {
4824+
if (!Context::isUnevaluatedBuiltin(BuiltinID)) {
48294825
// Put arguments on the stack.
48304826
for (const auto *Arg : E->arguments()) {
48314827
if (!this->visit(Arg))
48324828
return false;
48334829
}
48344830
}
48354831

4836-
if (!this->emitCallBI(Func, E, BuiltinID, E))
4832+
if (!this->emitCallBI(E, BuiltinID, E))
48374833
return false;
48384834

48394835
if (DiscardResult && !ReturnType->isVoidType()) {

clang/lib/AST/ByteCode/Context.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,3 +450,9 @@ unsigned Context::collectBaseOffset(const RecordDecl *BaseDecl,
450450
const Record *Context::getRecord(const RecordDecl *D) const {
451451
return P->getOrCreateRecord(D);
452452
}
453+
454+
bool Context::isUnevaluatedBuiltin(unsigned ID) {
455+
return ID == Builtin::BI__builtin_classify_type ||
456+
ID == Builtin::BI__builtin_os_log_format_buffer_size ||
457+
ID == Builtin::BI__builtin_constant_p || ID == Builtin::BI__noop;
458+
}

0 commit comments

Comments
 (0)