Skip to content

Commit 03f842d

Browse files
committed
Merge from 'master' to 'sycl-web' (#1)
Fixed build after D79968 (StoreInst should store Align, not MaybeAlign).
2 parents 9e016ef + 11aa370 commit 03f842d

File tree

527 files changed

+16710
-4608
lines changed

Some content is hidden

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

527 files changed

+16710
-4608
lines changed

clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ class NameLookup {
207207
/// flag indicating the multiple resolutions.
208208
NameLookup findDeclInBases(const CXXRecordDecl &Parent, StringRef DeclName,
209209
bool AggressiveTemplateLookup) {
210+
if (!Parent.hasDefinition())
211+
return NameLookup(nullptr);
210212
if (const NamedDecl *InClassRef = findDecl(Parent, DeclName))
211213
return NameLookup(InClassRef);
212214
const NamedDecl *Found = nullptr;

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
1717
set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
1818
set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "")
1919
set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
20+
set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
2021

2122
set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
2223
if(NOT APPLE)

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,17 +270,49 @@ the configuration (without a prefix: ``Auto``).
270270

271271

272272

273-
**AlignOperands** (``bool``)
273+
**AlignOperands** (``OperandAlignmentStyle``)
274274
If ``true``, horizontally align operands of binary and ternary
275275
expressions.
276276

277-
Specifically, this aligns operands of a single expression that needs to be
278-
split over multiple lines, e.g.:
277+
Possible values:
278+
279+
* ``OAS_DontAlign`` (in configuration: ``DontAlign``)
280+
Do not align operands of binary and ternary expressions.
281+
The wrapped lines are indented ``ContinuationIndentWidth`` spaces from
282+
the start of the line.
283+
284+
* ``OAS_Align`` (in configuration: ``Align``)
285+
Horizontally align operands of binary and ternary expressions.
286+
287+
Specifically, this aligns operands of a single expression that needs
288+
to be split over multiple lines, e.g.:
289+
290+
.. code-block:: c++
291+
292+
int aaa = bbbbbbbbbbbbbbb +
293+
ccccccccccccccc;
294+
295+
When ``BreakBeforeBinaryOperators`` is set, the wrapped operator is
296+
aligned with the operand on the first line.
297+
298+
.. code-block:: c++
299+
300+
int aaa = bbbbbbbbbbbbbbb
301+
+ ccccccccccccccc;
302+
303+
* ``OAS_AlignAfterOperator`` (in configuration: ``AlignAfterOperator``)
304+
Horizontally align operands of binary and ternary expressions.
305+
306+
This is similar to ``AO_Align``, except when
307+
``BreakBeforeBinaryOperators`` is set, the operator is un-indented so
308+
that the wrapped operand is aligned with the operand on the first line.
309+
310+
.. code-block:: c++
311+
312+
int aaa = bbbbbbbbbbbbbbb
313+
+ ccccccccccccccc;
279314

280-
.. code-block:: c++
281315

282-
int aaa = bbbbbbbbbbbbbbb +
283-
ccccccccccccccc;
284316

285317
**AlignTrailingComments** (``bool``)
286318
If ``true``, aligns trailing comments.

clang/include/clang/Basic/BuiltinsBPF.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,8 @@
2020
// Get record field information.
2121
TARGET_BUILTIN(__builtin_preserve_field_info, "Ui.", "t", "")
2222

23+
// Get BTF type id.
24+
TARGET_BUILTIN(__builtin_btf_type_id, "Ui.", "t", "")
25+
2326
#undef BUILTIN
2427
#undef TARGET_BUILTIN

clang/include/clang/Basic/BuiltinsWebAssembly.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i64_f64, "LLid", "nc", "nontrappi
7070
TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i64_f64, "LLid", "nc", "nontrapping-fptoint")
7171

7272
// SIMD builtins
73-
TARGET_BUILTIN(__builtin_wasm_swizzle_v8x16, "V16cV16cV16c", "nc", "unimplemented-simd128")
73+
TARGET_BUILTIN(__builtin_wasm_swizzle_v8x16, "V16cV16cV16c", "nc", "simd128")
7474

7575
TARGET_BUILTIN(__builtin_wasm_extract_lane_s_i8x16, "iV16cIi", "nc", "simd128")
7676
TARGET_BUILTIN(__builtin_wasm_extract_lane_u_i8x16, "iV16cIi", "nc", "simd128")

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10854,6 +10854,8 @@ def err_preserve_field_info_not_field : Error<
1085410854
"__builtin_preserve_field_info argument %0 not a field access">;
1085510855
def err_preserve_field_info_not_const: Error<
1085610856
"__builtin_preserve_field_info argument %0 not a constant">;
10857+
def err_btf_type_id_not_const: Error<
10858+
"__builtin_btf_type_id argument %0 not a constant">;
1085710859

1085810860
def err_bit_cast_non_trivially_copyable : Error<
1085910861
"__builtin_bit_cast %select{source|destination}0 type must be trivially copyable">;

clang/include/clang/Basic/SourceManager.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,11 @@ class SourceManager : public RefCountedBase<SourceManager> {
813813
MainFileID = FID;
814814
}
815815

816+
/// Returns true when the given FileEntry corresponds to the main file.
817+
///
818+
/// The main file should be set prior to calling this function.
819+
bool isMainFile(FileEntryRef SourceFile);
820+
816821
/// Set the file ID for the precompiled preamble.
817822
void setPreambleFileID(FileID Preamble) {
818823
assert(PreambleFileID.isInvalid() && "PreambleFileID already set!");

clang/include/clang/Format/Format.h

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,43 @@ struct FormatStyle {
153153
/// Options for aligning backslashes in escaped newlines.
154154
EscapedNewlineAlignmentStyle AlignEscapedNewlines;
155155

156+
/// Different styles for aligning operands.
157+
enum OperandAlignmentStyle {
158+
/// Do not align operands of binary and ternary expressions.
159+
/// The wrapped lines are indented ``ContinuationIndentWidth`` spaces from
160+
/// the start of the line.
161+
OAS_DontAlign,
162+
/// Horizontally align operands of binary and ternary expressions.
163+
///
164+
/// Specifically, this aligns operands of a single expression that needs
165+
/// to be split over multiple lines, e.g.:
166+
/// \code
167+
/// int aaa = bbbbbbbbbbbbbbb +
168+
/// ccccccccccccccc;
169+
/// \endcode
170+
///
171+
/// When ``BreakBeforeBinaryOperators`` is set, the wrapped operator is
172+
/// aligned with the operand on the first line.
173+
/// \code
174+
/// int aaa = bbbbbbbbbbbbbbb
175+
/// + ccccccccccccccc;
176+
/// \endcode
177+
OAS_Align,
178+
/// Horizontally align operands of binary and ternary expressions.
179+
///
180+
/// This is similar to ``AO_Align``, except when
181+
/// ``BreakBeforeBinaryOperators`` is set, the operator is un-indented so
182+
/// that the wrapped operand is aligned with the operand on the first line.
183+
/// \code
184+
/// int aaa = bbbbbbbbbbbbbbb
185+
/// + ccccccccccccccc;
186+
/// \endcode
187+
OAS_AlignAfterOperator,
188+
};
189+
156190
/// If ``true``, horizontally align operands of binary and ternary
157191
/// expressions.
158-
///
159-
/// Specifically, this aligns operands of a single expression that needs to be
160-
/// split over multiple lines, e.g.:
161-
/// \code
162-
/// int aaa = bbbbbbbbbbbbbbb +
163-
/// ccccccccccccccc;
164-
/// \endcode
165-
bool AlignOperands;
192+
OperandAlignmentStyle AlignOperands;
166193

167194
/// If ``true``, aligns trailing comments.
168195
/// \code

clang/include/clang/Frontend/VerifyDiagnosticConsumer.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,10 @@ class VerifyDiagnosticConsumer: public DiagnosticConsumer,
190190
///
191191
class Directive {
192192
public:
193-
static std::unique_ptr<Directive> create(bool RegexKind,
194-
SourceLocation DirectiveLoc,
195-
SourceLocation DiagnosticLoc,
196-
bool MatchAnyLine, StringRef Text,
197-
unsigned Min, unsigned Max);
193+
static std::unique_ptr<Directive>
194+
create(bool RegexKind, SourceLocation DirectiveLoc,
195+
SourceLocation DiagnosticLoc, bool MatchAnyFileAndLine,
196+
bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max);
198197

199198
public:
200199
/// Constant representing n or more matches.
@@ -205,6 +204,7 @@ class VerifyDiagnosticConsumer: public DiagnosticConsumer,
205204
const std::string Text;
206205
unsigned Min, Max;
207206
bool MatchAnyLine;
207+
bool MatchAnyFileAndLine; // `MatchAnyFileAndLine` implies `MatchAnyLine`.
208208

209209
Directive(const Directive &) = delete;
210210
Directive &operator=(const Directive &) = delete;
@@ -219,9 +219,11 @@ class VerifyDiagnosticConsumer: public DiagnosticConsumer,
219219

220220
protected:
221221
Directive(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc,
222-
bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max)
223-
: DirectiveLoc(DirectiveLoc), DiagnosticLoc(DiagnosticLoc),
224-
Text(Text), Min(Min), Max(Max), MatchAnyLine(MatchAnyLine) {
222+
bool MatchAnyFileAndLine, bool MatchAnyLine, StringRef Text,
223+
unsigned Min, unsigned Max)
224+
: DirectiveLoc(DirectiveLoc), DiagnosticLoc(DiagnosticLoc), Text(Text),
225+
Min(Min), Max(Max), MatchAnyLine(MatchAnyLine || MatchAnyFileAndLine),
226+
MatchAnyFileAndLine(MatchAnyFileAndLine) {
225227
assert(!DirectiveLoc.isInvalid() && "DirectiveLoc is invalid!");
226228
assert((!DiagnosticLoc.isInvalid() || MatchAnyLine) &&
227229
"DiagnosticLoc is invalid!");

clang/lib/Basic/SourceManager.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,14 @@ void SourceManager::clearIDTables() {
389389
createExpansionLoc(SourceLocation(), SourceLocation(), SourceLocation(), 1);
390390
}
391391

392+
bool SourceManager::isMainFile(FileEntryRef SourceFile) {
393+
assert(MainFileID.isValid() && "expected initialized SourceManager");
394+
auto FE = getFileEntryRefForID(MainFileID);
395+
if (!FE)
396+
return false;
397+
return FE->getUID() == SourceFile.getUID();
398+
}
399+
392400
void SourceManager::initializeForReplay(const SourceManager &Old) {
393401
assert(MainFileID.isInvalid() && "expected uninitialized SourceManager");
394402

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,15 +1043,6 @@ static void addSanitizersAtO0(ModulePassManager &MPM,
10431043
const Triple &TargetTriple,
10441044
const LangOptions &LangOpts,
10451045
const CodeGenOptions &CodeGenOpts) {
1046-
if (CodeGenOpts.SanitizeCoverageType ||
1047-
CodeGenOpts.SanitizeCoverageIndirectCalls ||
1048-
CodeGenOpts.SanitizeCoverageTraceCmp) {
1049-
auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
1050-
MPM.addPass(ModuleSanitizerCoveragePass(
1051-
SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
1052-
CodeGenOpts.SanitizeCoverageBlacklistFiles));
1053-
}
1054-
10551046
auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
10561047
MPM.addPass(RequireAnalysisPass<ASanGlobalsMetadataAnalysis, Module>());
10571048
bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
@@ -1292,17 +1283,6 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
12921283
EntryExitInstrumenterPass(/*PostInlining=*/false)));
12931284
});
12941285

1295-
if (CodeGenOpts.SanitizeCoverageType ||
1296-
CodeGenOpts.SanitizeCoverageIndirectCalls ||
1297-
CodeGenOpts.SanitizeCoverageTraceCmp) {
1298-
PB.registerPipelineStartEPCallback([&](ModulePassManager &MPM) {
1299-
auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
1300-
MPM.addPass(ModuleSanitizerCoveragePass(
1301-
SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
1302-
CodeGenOpts.SanitizeCoverageBlacklistFiles));
1303-
});
1304-
}
1305-
13061286
// Register callbacks to schedule sanitizer passes at the appropriate part of
13071287
// the pipeline.
13081288
// FIXME: either handle asan/the remaining sanitizers or error out
@@ -1387,6 +1367,15 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
13871367
}
13881368
}
13891369

1370+
if (CodeGenOpts.SanitizeCoverageType ||
1371+
CodeGenOpts.SanitizeCoverageIndirectCalls ||
1372+
CodeGenOpts.SanitizeCoverageTraceCmp) {
1373+
auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
1374+
MPM.addPass(ModuleSanitizerCoveragePass(
1375+
SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
1376+
CodeGenOpts.SanitizeCoverageBlacklistFiles));
1377+
}
1378+
13901379
if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) {
13911380
bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
13921381
MPM.addPass(HWAddressSanitizerPass(

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 92 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10639,33 +10639,103 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
1063910639

1064010640
Value *CodeGenFunction::EmitBPFBuiltinExpr(unsigned BuiltinID,
1064110641
const CallExpr *E) {
10642-
assert(BuiltinID == BPF::BI__builtin_preserve_field_info &&
10643-
"unexpected ARM builtin");
10642+
assert((BuiltinID == BPF::BI__builtin_preserve_field_info ||
10643+
BuiltinID == BPF::BI__builtin_btf_type_id) &&
10644+
"unexpected BPF builtin");
1064410645

10645-
const Expr *Arg = E->getArg(0);
10646-
bool IsBitField = Arg->IgnoreParens()->getObjectKind() == OK_BitField;
10646+
switch (BuiltinID) {
10647+
default:
10648+
llvm_unreachable("Unexpected BPF builtin");
10649+
case BPF::BI__builtin_preserve_field_info: {
10650+
const Expr *Arg = E->getArg(0);
10651+
bool IsBitField = Arg->IgnoreParens()->getObjectKind() == OK_BitField;
1064710652

10648-
if (!getDebugInfo()) {
10649-
CGM.Error(E->getExprLoc(), "using builtin_preserve_field_info() without -g");
10650-
return IsBitField ? EmitLValue(Arg).getBitFieldPointer()
10651-
: EmitLValue(Arg).getPointer(*this);
10652-
}
10653+
if (!getDebugInfo()) {
10654+
CGM.Error(E->getExprLoc(),
10655+
"using __builtin_preserve_field_info() without -g");
10656+
return IsBitField ? EmitLValue(Arg).getBitFieldPointer()
10657+
: EmitLValue(Arg).getPointer(*this);
10658+
}
10659+
10660+
// Enable underlying preserve_*_access_index() generation.
10661+
bool OldIsInPreservedAIRegion = IsInPreservedAIRegion;
10662+
IsInPreservedAIRegion = true;
10663+
Value *FieldAddr = IsBitField ? EmitLValue(Arg).getBitFieldPointer()
10664+
: EmitLValue(Arg).getPointer(*this);
10665+
IsInPreservedAIRegion = OldIsInPreservedAIRegion;
10666+
10667+
ConstantInt *C = cast<ConstantInt>(EmitScalarExpr(E->getArg(1)));
10668+
Value *InfoKind = ConstantInt::get(Int64Ty, C->getSExtValue());
10669+
10670+
// Built the IR for the preserve_field_info intrinsic.
10671+
llvm::Function *FnGetFieldInfo = llvm::Intrinsic::getDeclaration(
10672+
&CGM.getModule(), llvm::Intrinsic::bpf_preserve_field_info,
10673+
{FieldAddr->getType()});
10674+
return Builder.CreateCall(FnGetFieldInfo, {FieldAddr, InfoKind});
10675+
}
10676+
case BPF::BI__builtin_btf_type_id: {
10677+
Value *FieldVal = nullptr;
10678+
10679+
// The LValue cannot be converted Value in order to be used as the function
10680+
// parameter. If it is a structure, it is the "alloca" result of the LValue
10681+
// (a pointer) is used in the parameter. If it is a simple type,
10682+
// the value will be loaded from its corresponding "alloca" and used as
10683+
// the parameter. In our case, let us just get a pointer of the LValue
10684+
// since we do not really use the parameter. The purpose of parameter
10685+
// is to prevent the generated IR llvm.bpf.btf.type.id intrinsic call,
10686+
// which carries metadata, from being changed.
10687+
bool IsLValue = E->getArg(0)->isLValue();
10688+
if (IsLValue)
10689+
FieldVal = EmitLValue(E->getArg(0)).getPointer(*this);
10690+
else
10691+
FieldVal = EmitScalarExpr(E->getArg(0));
1065310692

10654-
// Enable underlying preserve_*_access_index() generation.
10655-
bool OldIsInPreservedAIRegion = IsInPreservedAIRegion;
10656-
IsInPreservedAIRegion = true;
10657-
Value *FieldAddr = IsBitField ? EmitLValue(Arg).getBitFieldPointer()
10658-
: EmitLValue(Arg).getPointer(*this);
10659-
IsInPreservedAIRegion = OldIsInPreservedAIRegion;
10693+
if (!getDebugInfo()) {
10694+
CGM.Error(E->getExprLoc(), "using __builtin_btf_type_id() without -g");
10695+
return nullptr;
10696+
}
1066010697

10661-
ConstantInt *C = cast<ConstantInt>(EmitScalarExpr(E->getArg(1)));
10662-
Value *InfoKind = ConstantInt::get(Int64Ty, C->getSExtValue());
10698+
// Generate debuginfo type for the first argument.
10699+
llvm::DIType *DbgInfo =
10700+
getDebugInfo()->getOrCreateStandaloneType(E->getArg(0)->getType(),
10701+
E->getArg(0)->getExprLoc());
1066310702

10664-
// Built the IR for the preserve_field_info intrinsic.
10665-
llvm::Function *FnGetFieldInfo = llvm::Intrinsic::getDeclaration(
10666-
&CGM.getModule(), llvm::Intrinsic::bpf_preserve_field_info,
10667-
{FieldAddr->getType()});
10668-
return Builder.CreateCall(FnGetFieldInfo, {FieldAddr, InfoKind});
10703+
ConstantInt *Flag = cast<ConstantInt>(EmitScalarExpr(E->getArg(1)));
10704+
Value *FlagValue = ConstantInt::get(Int64Ty, Flag->getSExtValue());
10705+
10706+
// Built the IR for the btf_type_id intrinsic.
10707+
//
10708+
// In the above, we converted LValue argument to a pointer to LValue.
10709+
// For example, the following
10710+
// int v;
10711+
// C1: __builtin_btf_type_id(v, flag);
10712+
// will be converted to
10713+
// L1: llvm.bpf.btf.type.id(&v, flag)
10714+
// This makes it hard to differentiate from
10715+
// C2: __builtin_btf_type_id(&v, flag);
10716+
// to
10717+
// L2: llvm.bpf.btf.type.id(&v, flag)
10718+
//
10719+
// If both C1 and C2 are present in the code, the llvm may later
10720+
// on do CSE on L1 and L2, which will result in incorrect tagged types.
10721+
//
10722+
// The C1->L1 transformation only happens if the argument of
10723+
// __builtin_btf_type_id() is a LValue. So Let us put whether
10724+
// the argument is an LValue or not into generated IR. This should
10725+
// prevent potential CSE from causing debuginfo type loss.
10726+
//
10727+
// The generated IR intrinsics will hence look like
10728+
// L1: llvm.bpf.btf.type.id(&v, 1, flag) !di_type_for_{v};
10729+
// L2: llvm.bpf.btf.type.id(&v, 0, flag) !di_type_for_{&v};
10730+
Constant *CV = ConstantInt::get(IntTy, IsLValue);
10731+
llvm::Function *FnBtfTypeId = llvm::Intrinsic::getDeclaration(
10732+
&CGM.getModule(), llvm::Intrinsic::bpf_btf_type_id,
10733+
{FieldVal->getType(), CV->getType()});
10734+
CallInst *Fn = Builder.CreateCall(FnBtfTypeId, {FieldVal, CV, FlagValue});
10735+
Fn->setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo);
10736+
return Fn;
10737+
}
10738+
}
1066910739
}
1067010740

1067110741
llvm::Value *CodeGenFunction::

0 commit comments

Comments
 (0)