Skip to content

Commit 12be89d

Browse files
author
Artem Gindinson
committed
Merge from 'main' to 'sycl-web' (#2)
CONFLICT (content): Merge conflict in clang/lib/Frontend/CompilerInvocation.cpp
2 parents 6e9c17b + 64e4dfd commit 12be89d

File tree

343 files changed

+11172
-3054
lines changed

Some content is hidden

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

343 files changed

+11172
-3054
lines changed

clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ TEST(FeatureModulesTest, ContributesTweak) {
3030
return error("not implemented");
3131
}
3232
std::string title() const override { return id(); }
33-
llvm::StringLiteral kind() const override { return ""; };
33+
llvm::StringLiteral kind() const override {
34+
return llvm::StringLiteral("");
35+
};
3436
};
3537

3638
void contributeTweaks(std::vector<std::unique_ptr<Tweak>> &Out) override {

clang/docs/UsersManual.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ generate a reproducer for warnings or errors while using modules.
686686
.. option:: -gen-reproducer
687687

688688
Generates preprocessed source files, a reproducer script and if relevant, a
689-
cache containing: built module pcm's and all headers needed to rebuilt the
689+
cache containing: built module pcm's and all headers needed to rebuild the
690690
same modules.
691691

692692
.. _rpass:

clang/include/clang/AST/DeclBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2378,7 +2378,7 @@ class DeclContext {
23782378

23792379
using udir_iterator_base =
23802380
llvm::iterator_adaptor_base<udir_iterator, lookup_iterator,
2381-
std::random_access_iterator_tag,
2381+
typename lookup_iterator::iterator_category,
23822382
UsingDirectiveDecl *>;
23832383

23842384
struct udir_iterator : udir_iterator_base {

clang/include/clang/Basic/AttrDocs.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4254,7 +4254,9 @@ def UnrollHintDocs : Documentation {
42544254
let Content = [{
42554255
Loop unrolling optimization hints can be specified with ``#pragma unroll`` and
42564256
``#pragma nounroll``. The pragma is placed immediately before a for, while,
4257-
do-while, or c++11 range-based for loop.
4257+
do-while, or c++11 range-based for loop. GCC's loop unrolling hints
4258+
``#pragma GCC unroll`` and ``#pragma GCC nounroll`` are also supported and have
4259+
identical semantics to ``#pragma unroll`` and ``#pragma nounroll``.
42584260

42594261
Specifying ``#pragma unroll`` without a parameter directs the loop unroller to
42604262
attempt to fully unroll the loop if the trip count is known at compile time and

clang/include/clang/Basic/Builtins.def

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ BUILTIN(__builtin_rotateright32, "UZiUZiUZi", "nc")
529529
BUILTIN(__builtin_rotateright64, "UWiUWiUWi", "nc")
530530

531531
// Random GCC builtins
532+
BUILTIN(__builtin_calloc, "v*zz", "nF")
532533
BUILTIN(__builtin_constant_p, "i.", "nctu")
533534
BUILTIN(__builtin_classify_type, "i.", "nctu")
534535
BUILTIN(__builtin___CFStringMakeConstantString, "FC*cC*", "nc")
@@ -542,6 +543,8 @@ BUILTIN(__builtin_bcmp, "ivC*vC*z", "Fn")
542543
BUILTIN(__builtin_bcopy, "vv*v*z", "n")
543544
BUILTIN(__builtin_bzero, "vv*z", "nF")
544545
BUILTIN(__builtin_fprintf, "iP*cC*.", "Fp:1:")
546+
BUILTIN(__builtin_free, "vv*", "nF")
547+
BUILTIN(__builtin_malloc, "v*z", "nF")
545548
BUILTIN(__builtin_memchr, "v*vC*iz", "nF")
546549
BUILTIN(__builtin_memcmp, "ivC*vC*z", "nF")
547550
BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
@@ -577,6 +580,7 @@ BUILTIN(__builtin_wmemchr, "w*wC*wz", "nF")
577580
BUILTIN(__builtin_wmemcmp, "iwC*wC*z", "nF")
578581
BUILTIN(__builtin_wmemcpy, "w*w*wC*z", "nF")
579582
BUILTIN(__builtin_wmemmove, "w*w*wC*z", "nF")
583+
BUILTIN(__builtin_realloc, "v*v*z", "nF")
580584
BUILTIN(__builtin_return_address, "v*IUi", "n")
581585
BUILTIN(__builtin_extract_return_addr, "v*v*", "n")
582586
BUILTIN(__builtin_frame_address, "v*IUi", "n")
@@ -586,8 +590,9 @@ BUILTIN(__builtin_longjmp, "vv**i", "r")
586590
BUILTIN(__builtin_unwind_init, "v", "")
587591
BUILTIN(__builtin_eh_return_data_regno, "iIi", "nc")
588592
BUILTIN(__builtin_snprintf, "ic*zcC*.", "nFp:2:")
589-
BUILTIN(__builtin_vsprintf, "ic*cC*a", "nFP:1:")
593+
BUILTIN(__builtin_sprintf, "ic*cC*.", "nFP:1:")
590594
BUILTIN(__builtin_vsnprintf, "ic*zcC*a", "nFP:2:")
595+
BUILTIN(__builtin_vsprintf, "ic*cC*a", "nFP:1:")
591596
BUILTIN(__builtin_thread_pointer, "v*", "nc")
592597
BUILTIN(__builtin_launder, "v*v*", "nt")
593598
LANGBUILTIN(__builtin_is_constant_evaluated, "b", "n", CXX_LANG)

clang/include/clang/Basic/TargetBuiltins.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,9 @@ namespace clang {
331331
}
332332

333333
static constexpr uint64_t LargestBuiltinID = std::max<uint64_t>(
334-
{NEON::FirstTSBuiltin, ARM::LastTSBuiltin, SVE::FirstTSBuiltin,
335-
AArch64::LastTSBuiltin, BPF::LastTSBuiltin, PPC::LastTSBuiltin,
336-
NVPTX::LastTSBuiltin, AMDGPU::LastTSBuiltin, X86::LastTSBuiltin,
334+
{ARM::LastTSBuiltin, AArch64::LastTSBuiltin, BPF::LastTSBuiltin,
335+
PPC::LastTSBuiltin, NVPTX::LastTSBuiltin, AMDGPU::LastTSBuiltin,
336+
X86::LastTSBuiltin, VE::LastTSBuiltin, RISCV::LastTSBuiltin,
337337
Hexagon::LastTSBuiltin, Mips::LastTSBuiltin, XCore::LastTSBuiltin,
338338
Le64::LastTSBuiltin, SystemZ::LastTSBuiltin,
339339
WebAssembly::LastTSBuiltin});

clang/include/clang/Frontend/CompilerInvocation.h

Lines changed: 57 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@ bool ParseDiagnosticArgs(DiagnosticOptions &Opts, llvm::opt::ArgList &Args,
6161
DiagnosticsEngine *Diags = nullptr,
6262
bool DefaultDiagColor = true);
6363

64-
class CompilerInvocationBase {
64+
/// The base class of CompilerInvocation with reference semantics.
65+
///
66+
/// This class stores option objects behind reference-counted pointers. This is
67+
/// useful for clients that want to keep some option object around even after
68+
/// CompilerInvocation gets destroyed, without making a copy.
69+
///
70+
/// This is a separate class so that we can implement the copy constructor and
71+
/// assignment here and leave them defaulted in the rest of CompilerInvocation.
72+
class CompilerInvocationRefBase {
6573
public:
6674
/// Options controlling the language variant.
6775
std::shared_ptr<LangOptions> LangOpts;
@@ -81,10 +89,12 @@ class CompilerInvocationBase {
8189
/// Options controlling the static analyzer.
8290
AnalyzerOptionsRef AnalyzerOpts;
8391

84-
CompilerInvocationBase();
85-
CompilerInvocationBase(const CompilerInvocationBase &X);
86-
CompilerInvocationBase &operator=(const CompilerInvocationBase &) = delete;
87-
~CompilerInvocationBase();
92+
CompilerInvocationRefBase();
93+
CompilerInvocationRefBase(const CompilerInvocationRefBase &X);
94+
CompilerInvocationRefBase(CompilerInvocationRefBase &&X);
95+
CompilerInvocationRefBase &operator=(CompilerInvocationRefBase X);
96+
CompilerInvocationRefBase &operator=(CompilerInvocationRefBase &&X);
97+
~CompilerInvocationRefBase();
8898

8999
LangOptions *getLangOpts() { return LangOpts.get(); }
90100
const LangOptions *getLangOpts() const { return LangOpts.get(); }
@@ -117,12 +127,9 @@ class CompilerInvocationBase {
117127
AnalyzerOptionsRef getAnalyzerOpts() const { return AnalyzerOpts; }
118128
};
119129

120-
/// Helper class for holding the data necessary to invoke the compiler.
121-
///
122-
/// This class is designed to represent an abstract "invocation" of the
123-
/// compiler, including data such as the include paths, the code generation
124-
/// options, the warning flags, and so on.
125-
class CompilerInvocation : public CompilerInvocationBase {
130+
/// The base class of CompilerInvocation with value semantics.
131+
class CompilerInvocationValueBase {
132+
protected:
126133
MigratorOptions MigratorOpts;
127134

128135
/// Options controlling IRgen and the backend.
@@ -141,9 +148,46 @@ class CompilerInvocation : public CompilerInvocationBase {
141148
PreprocessorOutputOptions PreprocessorOutputOpts;
142149

143150
public:
144-
/// @name Utility Methods
145-
/// @{
151+
MigratorOptions &getMigratorOpts() { return MigratorOpts; }
152+
const MigratorOptions &getMigratorOpts() const { return MigratorOpts; }
153+
154+
CodeGenOptions &getCodeGenOpts() { return CodeGenOpts; }
155+
const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; }
156+
157+
DependencyOutputOptions &getDependencyOutputOpts() {
158+
return DependencyOutputOpts;
159+
}
160+
161+
const DependencyOutputOptions &getDependencyOutputOpts() const {
162+
return DependencyOutputOpts;
163+
}
146164

165+
FileSystemOptions &getFileSystemOpts() { return FileSystemOpts; }
166+
167+
const FileSystemOptions &getFileSystemOpts() const {
168+
return FileSystemOpts;
169+
}
170+
171+
FrontendOptions &getFrontendOpts() { return FrontendOpts; }
172+
const FrontendOptions &getFrontendOpts() const { return FrontendOpts; }
173+
174+
PreprocessorOutputOptions &getPreprocessorOutputOpts() {
175+
return PreprocessorOutputOpts;
176+
}
177+
178+
const PreprocessorOutputOptions &getPreprocessorOutputOpts() const {
179+
return PreprocessorOutputOpts;
180+
}
181+
};
182+
183+
/// Helper class for holding the data necessary to invoke the compiler.
184+
///
185+
/// This class is designed to represent an abstract "invocation" of the
186+
/// compiler, including data such as the include paths, the code generation
187+
/// options, the warning flags, and so on.
188+
class CompilerInvocation : public CompilerInvocationRefBase,
189+
public CompilerInvocationValueBase {
190+
public:
147191
/// Create a compiler invocation from a list of input options.
148192
/// \returns true on success.
149193
///
@@ -199,43 +243,6 @@ class CompilerInvocation : public CompilerInvocationBase {
199243
void generateCC1CommandLine(llvm::SmallVectorImpl<const char *> &Args,
200244
StringAllocator SA) const;
201245

202-
/// @}
203-
/// @name Option Subgroups
204-
/// @{
205-
206-
MigratorOptions &getMigratorOpts() { return MigratorOpts; }
207-
const MigratorOptions &getMigratorOpts() const { return MigratorOpts; }
208-
209-
CodeGenOptions &getCodeGenOpts() { return CodeGenOpts; }
210-
const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; }
211-
212-
DependencyOutputOptions &getDependencyOutputOpts() {
213-
return DependencyOutputOpts;
214-
}
215-
216-
const DependencyOutputOptions &getDependencyOutputOpts() const {
217-
return DependencyOutputOpts;
218-
}
219-
220-
FileSystemOptions &getFileSystemOpts() { return FileSystemOpts; }
221-
222-
const FileSystemOptions &getFileSystemOpts() const {
223-
return FileSystemOpts;
224-
}
225-
226-
FrontendOptions &getFrontendOpts() { return FrontendOpts; }
227-
const FrontendOptions &getFrontendOpts() const { return FrontendOpts; }
228-
229-
PreprocessorOutputOptions &getPreprocessorOutputOpts() {
230-
return PreprocessorOutputOpts;
231-
}
232-
233-
const PreprocessorOutputOptions &getPreprocessorOutputOpts() const {
234-
return PreprocessorOutputOpts;
235-
}
236-
237-
/// @}
238-
239246
private:
240247
static bool CreateFromArgsImpl(CompilerInvocation &Res,
241248
ArrayRef<const char *> CommandLineArgs,

clang/include/clang/Tooling/NodeIntrospection.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,16 @@ class LocationCall : public llvm::ThreadSafeRefCountedBase<LocationCall> {
3838
LocationCall(SharedLocationCall on, std::string name,
3939
LocationCallFlags flags = NoFlags)
4040
: m_flags(flags), m_on(std::move(on)), m_name(std::move(name)) {}
41-
LocationCall(SharedLocationCall on, std::string name,
42-
std::vector<std::string> args, LocationCallFlags flags = NoFlags)
43-
: m_flags(flags), m_on(std::move(on)), m_name(std::move(name)),
44-
m_args(std::move(args)) {}
4541

4642
LocationCall *on() const { return m_on.get(); }
4743
StringRef name() const { return m_name; }
48-
ArrayRef<std::string> args() const { return m_args; }
4944
bool returnsPointer() const { return m_flags & ReturnsPointer; }
5045
bool isCast() const { return m_flags & IsCast; }
5146

5247
private:
5348
LocationCallFlags m_flags;
5449
SharedLocationCall m_on;
5550
std::string m_name;
56-
std::vector<std::string> m_args;
5751
};
5852

5953
class LocationCallFormatterCpp {
@@ -92,6 +86,7 @@ NodeLocationAccessors GetLocations(clang::CXXCtorInitializer const *Object);
9286
NodeLocationAccessors GetLocations(clang::NestedNameSpecifierLoc const *);
9387
NodeLocationAccessors GetLocations(clang::TemplateArgumentLoc const *);
9488
NodeLocationAccessors GetLocations(clang::CXXBaseSpecifier const *);
89+
NodeLocationAccessors GetLocations(clang::TypeLoc const &);
9590
NodeLocationAccessors GetLocations(clang::DynTypedNode const &Node);
9691
} // namespace NodeIntrospection
9792
} // namespace tooling

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17079,8 +17079,8 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
1707917079
case WebAssembly::BI__builtin_wasm_trunc_saturate_s_i32x4_f32x4: {
1708017080
Value *Src = EmitScalarExpr(E->getArg(0));
1708117081
llvm::Type *ResT = ConvertType(E->getType());
17082-
Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_trunc_saturate_signed,
17083-
{ResT, Src->getType()});
17082+
Function *Callee =
17083+
CGM.getIntrinsic(Intrinsic::fptosi_sat, {ResT, Src->getType()});
1708417084
return Builder.CreateCall(Callee, {Src});
1708517085
}
1708617086
case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i32_f32:
@@ -17090,8 +17090,8 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
1709017090
case WebAssembly::BI__builtin_wasm_trunc_saturate_u_i32x4_f32x4: {
1709117091
Value *Src = EmitScalarExpr(E->getArg(0));
1709217092
llvm::Type *ResT = ConvertType(E->getType());
17093-
Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_trunc_saturate_unsigned,
17094-
{ResT, Src->getType()});
17093+
Function *Callee =
17094+
CGM.getIntrinsic(Intrinsic::fptoui_sat, {ResT, Src->getType()});
1709517095
return Builder.CreateCall(Callee, {Src});
1709617096
}
1709717097
case WebAssembly::BI__builtin_wasm_min_f32:
@@ -17487,16 +17487,24 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
1748717487
unsigned IntNo;
1748817488
switch (BuiltinID) {
1748917489
case WebAssembly::BI__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4:
17490-
IntNo = Intrinsic::wasm_trunc_sat_zero_signed;
17490+
IntNo = Intrinsic::fptosi_sat;
1749117491
break;
1749217492
case WebAssembly::BI__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4:
17493-
IntNo = Intrinsic::wasm_trunc_sat_zero_unsigned;
17493+
IntNo = Intrinsic::fptoui_sat;
1749417494
break;
1749517495
default:
1749617496
llvm_unreachable("unexpected builtin ID");
1749717497
}
17498-
Function *Callee = CGM.getIntrinsic(IntNo);
17499-
return Builder.CreateCall(Callee, Vec);
17498+
llvm::Type *SrcT = Vec->getType();
17499+
llvm::Type *TruncT =
17500+
SrcT->getWithNewType(llvm::IntegerType::get(getLLVMContext(), 32));
17501+
Function *Callee = CGM.getIntrinsic(IntNo, {TruncT, SrcT});
17502+
Value *Trunc = Builder.CreateCall(Callee, Vec);
17503+
Value *Splat = Builder.CreateVectorSplat(2, Builder.getInt32(0));
17504+
Value *ConcatMask =
17505+
llvm::ConstantVector::get({Builder.getInt32(0), Builder.getInt32(1),
17506+
Builder.getInt32(2), Builder.getInt32(3)});
17507+
return Builder.CreateShuffleVector(Trunc, Splat, ConcatMask);
1750017508
}
1750117509
case WebAssembly::BI__builtin_wasm_demote_zero_f64x2_f32x4: {
1750217510
Value *Vec = EmitScalarExpr(E->getArg(0));

clang/lib/CodeGen/CGCUDANV.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,28 @@ void CGNVCUDARuntime::transformManagedVars() {
10891089
llvm::Function *CGNVCUDARuntime::finalizeModule() {
10901090
if (CGM.getLangOpts().CUDAIsDevice) {
10911091
transformManagedVars();
1092+
1093+
// Mark ODR-used device variables as compiler used to prevent it from being
1094+
// eliminated by optimization. This is necessary for device variables
1095+
// ODR-used by host functions. Sema correctly marks them as ODR-used no
1096+
// matter whether they are ODR-used by device or host functions.
1097+
//
1098+
// We do not need to do this if the variable has used attribute since it
1099+
// has already been added.
1100+
//
1101+
// Static device variables have been externalized at this point, therefore
1102+
// variables with LLVM private or internal linkage need not be added.
1103+
for (auto &&Info : DeviceVars) {
1104+
auto Kind = Info.Flags.getKind();
1105+
if (!Info.Var->isDeclaration() &&
1106+
!llvm::GlobalValue::isLocalLinkage(Info.Var->getLinkage()) &&
1107+
(Kind == DeviceVarFlags::Variable ||
1108+
Kind == DeviceVarFlags::Surface ||
1109+
Kind == DeviceVarFlags::Texture) &&
1110+
Info.D->isUsed() && !Info.D->hasAttr<UsedAttr>()) {
1111+
CGM.addCompilerUsedGlobal(Info.Var);
1112+
}
1113+
}
10921114
return nullptr;
10931115
}
10941116
return makeModuleCtorFunction();

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void CodeGenFunction::CGFPOptionsRAII::ConstructorHelper(FPOptions FPFeatures) {
175175

176176
auto mergeFnAttrValue = [&](StringRef Name, bool Value) {
177177
auto OldValue =
178-
CGF.CurFn->getFnAttribute(Name).getValueAsString() == "true";
178+
CGF.CurFn->getFnAttribute(Name).getValueAsBool();
179179
auto NewValue = OldValue & Value;
180180
if (OldValue != NewValue)
181181
CGF.CurFn->addFnAttr(Name, llvm::toStringRef(NewValue));

clang/lib/Driver/ToolChains/RISCVToolchain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,14 @@ void RISCV::Linker::ConstructJob(Compilation &C, const JobAction &JA,
181181
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
182182
}
183183

184+
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
185+
184186
Args.AddAllArgs(CmdArgs, options::OPT_L);
185187
ToolChain.AddFilePathLibArgs(Args, CmdArgs);
186188
Args.AddAllArgs(CmdArgs,
187189
{options::OPT_T_Group, options::OPT_e, options::OPT_s,
188190
options::OPT_t, options::OPT_Z_Flag, options::OPT_r});
189191

190-
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
191-
192192
// TODO: add C++ includes and libs if compiling C++.
193193

194194
if (!Args.hasArg(options::OPT_nostdlib) &&

0 commit comments

Comments
 (0)