Skip to content

Commit 9106759

Browse files
committed
Merge from 'main' to 'sycl-web' (383 commits)
CONFLICT (content): Merge conflict in clang/test/CodeGenSYCL/address-space-conversions.cpp
2 parents aeb53f7 + f540044 commit 9106759

File tree

1,258 files changed

+52346
-24109
lines changed

Some content is hidden

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

1,258 files changed

+52346
-24109
lines changed

.github/new-prs-labeler.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,26 @@ backend:PowerPC:
846846
- clang/lib/Driver/ToolChains/Arch/PPC.*
847847
- clang/test/CodeGen/PowerPC/**
848848

849+
backend:SystemZ:
850+
- llvm/include/llvm/BinaryFormat/ELFRelocs/SystemZ*
851+
- llvm/include/llvm/BinaryFormat/GOFF.h
852+
- llvm/include/llvm/IR/IntrinsicsSystemZ.td
853+
- llvm/lib/Target/SystemZ/**
854+
- llvm/test/Analysis/**/SystemZ/**
855+
- llvm/test/CodeGen/SystemZ/**
856+
- llvm/test/DebugInfo/SystemZ/**
857+
- llvm/test/ExecutionEngine/**/SystemZ/**
858+
- llvm/test/MC/Disassembler/SystemZ/**
859+
- llvm/test/MC/GOFF/**
860+
- llvm/test/MC/SystemZ/**
861+
- llvm/test/Transforms/**/SystemZ/**
862+
- clang/include/clang/Basic/BuiltinsSystemZ.*
863+
- clang/lib/Basic/Targets/SystemZ.*
864+
- clang/lib/CodeGen/Targets/SystemZ.cpp
865+
- clang/lib/Driver/ToolChains/ZOS*
866+
- clang/lib/Driver/ToolChains/Arch/SystemZ.*
867+
- clang/test/CodeGen/SystemZ/**
868+
849869
third-party:unittests:
850870
- third-party/unittests/**
851871

bolt/include/bolt/Core/BinarySection.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,7 @@ class BinarySection {
139139
Alignment = NewAlignment;
140140
ELFType = NewELFType;
141141
ELFFlags = NewELFFlags;
142-
OutputSize = NewSize;
143-
OutputContents = StringRef(reinterpret_cast<const char *>(NewData),
144-
NewData ? NewSize : 0);
145-
IsFinalized = true;
142+
updateContents(NewData, NewSize);
146143
}
147144

148145
public:
@@ -484,9 +481,18 @@ class BinarySection {
484481
void flushPendingRelocations(raw_pwrite_stream &OS,
485482
SymbolResolverFuncTy Resolver);
486483

487-
/// Change contents of the section.
488-
void updateContents(const uint8_t *Data, size_t NewSize) {
489-
OutputContents = StringRef(reinterpret_cast<const char *>(Data), NewSize);
484+
/// Change contents of the section. Unless the section has a valid SectionID,
485+
/// the memory passed in \p NewData will be managed by the instance of
486+
/// BinarySection.
487+
void updateContents(const uint8_t *NewData, size_t NewSize) {
488+
if (getOutputData() && !hasValidSectionID() &&
489+
(!hasSectionRef() ||
490+
OutputContents.data() != getContentsOrQuit(Section).data())) {
491+
delete[] getOutputData();
492+
}
493+
494+
OutputContents = StringRef(reinterpret_cast<const char *>(NewData),
495+
NewData ? NewSize : 0);
490496
OutputSize = NewSize;
491497
IsFinalized = true;
492498
}

bolt/include/bolt/Core/DIEBuilder.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class DIEBuilder {
124124
std::vector<std::unique_ptr<DIEAbbrev>> Abbreviations;
125125
BinaryContext &BC;
126126
DWARFContext *DwarfContext{nullptr};
127-
bool IsDWO{false};
127+
DWARFUnit *SkeletonCU{nullptr};
128128
uint64_t UnitSize{0};
129129
llvm::DenseSet<uint64_t> AllProcessed;
130130

@@ -264,8 +264,12 @@ class DIEBuilder {
264264
/// current Section.
265265
DIE *constructDIEFast(DWARFDie &DDie, DWARFUnit &U, uint32_t UnitId);
266266

267+
/// Returns true if this DIEBUilder is for DWO Unit.
268+
bool isDWO() const { return SkeletonCU != nullptr; }
269+
267270
public:
268-
DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext, bool IsDWO = false);
271+
DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext,
272+
DWARFUnit *SkeletonCU = nullptr);
269273

270274
/// Returns enum to what we are currently processing.
271275
ProcessingType getCurrentProcessingState() { return getState().Type; }

bolt/include/bolt/Core/DebugData.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,16 @@ class DebugStrOffsetsWriter {
450450
return std::move(StrOffsetsBuffer);
451451
}
452452

453-
private:
454453
/// Initializes Buffer and Stream.
455454
void initialize(DWARFUnit &Unit);
456455

456+
/// Clear data.
457+
void clear() {
458+
IndexToAddressMap.clear();
459+
StrOffsets.clear();
460+
}
461+
462+
private:
457463
std::unique_ptr<DebugStrOffsetsBufferVector> StrOffsetsBuffer;
458464
std::unique_ptr<raw_svector_ostream> StrOffsetsStream;
459465
std::map<uint32_t, uint32_t> IndexToAddressMap;

bolt/lib/Core/BinarySection.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -190,18 +190,7 @@ void BinarySection::flushPendingRelocations(raw_pwrite_stream &OS,
190190
clearList(PendingRelocations);
191191
}
192192

193-
BinarySection::~BinarySection() {
194-
if (isReordered()) {
195-
delete[] getData();
196-
return;
197-
}
198-
199-
if (!isAllocatable() && !hasValidSectionID() &&
200-
(!hasSectionRef() ||
201-
OutputContents.data() != getContentsOrQuit(Section).data())) {
202-
delete[] getOutputData();
203-
}
204-
}
193+
BinarySection::~BinarySection() { updateContents(nullptr, 0); }
205194

206195
void BinarySection::clearRelocations() { clearList(Relocations); }
207196

bolt/lib/Core/DIEBuilder.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ void DIEBuilder::constructFromUnit(DWARFUnit &DU) {
179179
}
180180

181181
DIEBuilder::DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext,
182-
bool IsDWO)
183-
: BC(BC), DwarfContext(DwarfContext), IsDWO(IsDWO) {}
182+
DWARFUnit *SkeletonCU)
183+
: BC(BC), DwarfContext(DwarfContext), SkeletonCU(SkeletonCU) {}
184184

185185
static unsigned int getCUNum(DWARFContext *DwarfContext, bool IsDWO) {
186186
unsigned int CUNum = IsDWO ? DwarfContext->getNumDWOCompileUnits()
@@ -204,11 +204,11 @@ void DIEBuilder::buildTypeUnits(DebugStrOffsetsWriter *StrOffsetWriter,
204204
true);
205205
}
206206
}
207-
const unsigned int CUNum = getCUNum(DwarfContext, IsDWO);
207+
const unsigned int CUNum = getCUNum(DwarfContext, isDWO());
208208
getState().CloneUnitCtxMap.resize(CUNum);
209209
DWARFContext::unit_iterator_range CU4TURanges =
210-
IsDWO ? DwarfContext->dwo_types_section_units()
211-
: DwarfContext->types_section_units();
210+
isDWO() ? DwarfContext->dwo_types_section_units()
211+
: DwarfContext->types_section_units();
212212

213213
getState().Type = ProcessingType::DWARF4TUs;
214214
for (std::unique_ptr<DWARFUnit> &DU : CU4TURanges)
@@ -218,8 +218,8 @@ void DIEBuilder::buildTypeUnits(DebugStrOffsetsWriter *StrOffsetWriter,
218218
constructFromUnit(*DU.get());
219219

220220
DWARFContext::unit_iterator_range CURanges =
221-
IsDWO ? DwarfContext->dwo_info_section_units()
222-
: DwarfContext->info_section_units();
221+
isDWO() ? DwarfContext->dwo_info_section_units()
222+
: DwarfContext->info_section_units();
223223

224224
// This handles DWARF4 CUs and DWARF5 CU/TUs.
225225
// Creating a vector so that for reference handling only DWARF5 CU/TUs are
@@ -242,11 +242,11 @@ void DIEBuilder::buildCompileUnits(const bool Init) {
242242
if (Init)
243243
BuilderState.reset(new State());
244244

245-
unsigned int CUNum = getCUNum(DwarfContext, IsDWO);
245+
unsigned int CUNum = getCUNum(DwarfContext, isDWO());
246246
getState().CloneUnitCtxMap.resize(CUNum);
247247
DWARFContext::unit_iterator_range CURanges =
248-
IsDWO ? DwarfContext->dwo_info_section_units()
249-
: DwarfContext->info_section_units();
248+
isDWO() ? DwarfContext->dwo_info_section_units()
249+
: DwarfContext->info_section_units();
250250

251251
// This handles DWARF4 CUs and DWARF5 CU/TUs.
252252
// Creating a vector so that for reference handling only DWARF5 CU/TUs are

bolt/lib/Core/DebugData.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,7 @@ void DebugStrOffsetsWriter::finalizeSection(DWARFUnit &Unit,
909909
}
910910

911911
StrOffsetSectionWasModified = false;
912-
IndexToAddressMap.clear();
913-
StrOffsets.clear();
912+
clear();
914913
}
915914

916915
void DebugStrWriter::create() {

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ void DWARFRewriter::updateDebugInfo() {
709709
: LegacyRangesSectionWriter.get();
710710
// Skipping CUs that failed to load.
711711
if (SplitCU) {
712-
DIEBuilder DWODIEBuilder(BC, &(*SplitCU)->getContext(), true);
712+
DIEBuilder DWODIEBuilder(BC, &(*SplitCU)->getContext(), Unit);
713713
DWODIEBuilder.buildDWOUnit(**SplitCU);
714714
std::string DWOName = updateDWONameCompDir(
715715
*Unit, *DIEBlder, *DIEBlder->getUnitDIEbyUnit(*Unit));

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4092,12 +4092,9 @@ void RewriteInstance::rewriteNoteSections() {
40924092
return getNewValueForSymbol(S->getName());
40934093
});
40944094

4095-
// Set/modify section info.
4096-
BinarySection &NewSection = BC->registerOrUpdateNoteSection(
4097-
SectionName, SectionData, Size, Section.sh_addralign,
4098-
!BSec->isWritable(), BSec->getELFType());
4099-
NewSection.setOutputAddress(0);
4100-
NewSection.setOutputFileOffset(NextAvailableOffset);
4095+
// Section contents are no longer needed, but we need to update the size so
4096+
// that it will be reflected in the section header table.
4097+
BSec->updateContents(nullptr, Size);
41014098

41024099
NextAvailableOffset += Size;
41034100
}

bolt/unittests/Core/BinaryContext.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ TEST_P(BinaryContextTester, FlushPendingRelocCALL26) {
7777
// 12: bl func2
7878
// 16: func2
7979

80-
char Data[20] = {};
80+
constexpr size_t DataSize = 20;
81+
uint8_t *Data = new uint8_t[DataSize];
8182
BinarySection &BS = BC->registerOrUpdateSection(
82-
".text", ELF::SHT_PROGBITS, ELF::SHF_EXECINSTR | ELF::SHF_ALLOC,
83-
(uint8_t *)Data, sizeof(Data), 4);
83+
".text", ELF::SHT_PROGBITS, ELF::SHF_EXECINSTR | ELF::SHF_ALLOC, Data,
84+
DataSize, 4);
8485
MCSymbol *RelSymbol1 = BC->getOrCreateGlobalSymbol(4, "Func1");
8586
ASSERT_TRUE(RelSymbol1);
8687
BS.addRelocation(8, RelSymbol1, ELF::R_AARCH64_CALL26, 0, 0, true);
@@ -89,7 +90,7 @@ TEST_P(BinaryContextTester, FlushPendingRelocCALL26) {
8990
BS.addRelocation(12, RelSymbol2, ELF::R_AARCH64_CALL26, 0, 0, true);
9091

9192
std::error_code EC;
92-
SmallVector<char> Vect(sizeof(Data));
93+
SmallVector<char> Vect(DataSize);
9394
raw_svector_ostream OS(Vect);
9495

9596
BS.flushPendingRelocations(OS, [&](const MCSymbol *S) {

clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,22 @@ AST_MATCHER_FUNCTION_P(StatementMatcher, isConstRefReturningMethodCall,
8686
const auto MethodDecl =
8787
cxxMethodDecl(returns(hasCanonicalType(matchers::isReferenceToConst())))
8888
.bind(MethodDeclId);
89-
const auto ReceiverExpr = declRefExpr(to(varDecl().bind(ObjectArgId)));
89+
const auto ReceiverExpr =
90+
ignoringParenImpCasts(declRefExpr(to(varDecl().bind(ObjectArgId))));
91+
const auto OnExpr = anyOf(
92+
// Direct reference to `*this`: `a.f()` or `a->f()`.
93+
ReceiverExpr,
94+
// Access through dereference, typically used for `operator[]`: `(*a)[3]`.
95+
unaryOperator(hasOperatorName("*"), hasUnaryOperand(ReceiverExpr)));
9096
const auto ReceiverType =
9197
hasCanonicalType(recordType(hasDeclaration(namedDecl(
9298
unless(matchers::matchesAnyListedName(ExcludedContainerTypes))))));
9399

94-
return expr(anyOf(
95-
cxxMemberCallExpr(callee(MethodDecl), on(ReceiverExpr),
96-
thisPointerType(ReceiverType)),
97-
cxxOperatorCallExpr(callee(MethodDecl), hasArgument(0, ReceiverExpr),
98-
hasArgument(0, hasType(ReceiverType)))));
100+
return expr(
101+
anyOf(cxxMemberCallExpr(callee(MethodDecl), on(OnExpr),
102+
thisPointerType(ReceiverType)),
103+
cxxOperatorCallExpr(callee(MethodDecl), hasArgument(0, OnExpr),
104+
hasArgument(0, hasType(ReceiverType)))));
99105
}
100106

101107
AST_MATCHER_FUNCTION(StatementMatcher, isConstRefReturningFunctionCall) {
@@ -136,10 +142,11 @@ AST_MATCHER_FUNCTION_P(StatementMatcher, initializerReturnsReferenceToConst,
136142
static bool isInitializingVariableImmutable(
137143
const VarDecl &InitializingVar, const Stmt &BlockStmt, ASTContext &Context,
138144
const std::vector<StringRef> &ExcludedContainerTypes) {
139-
if (!isOnlyUsedAsConst(InitializingVar, BlockStmt, Context))
145+
QualType T = InitializingVar.getType().getCanonicalType();
146+
if (!isOnlyUsedAsConst(InitializingVar, BlockStmt, Context,
147+
T->isPointerType() ? 1 : 0))
140148
return false;
141149

142-
QualType T = InitializingVar.getType().getCanonicalType();
143150
// The variable is a value type and we know it is only used as const. Safe
144151
// to reference it and avoid the copy.
145152
if (!isa<ReferenceType, PointerType>(T))
@@ -273,7 +280,9 @@ void UnnecessaryCopyInitialization::check(
273280
VarDeclStmt.isSingleDecl() && !NewVar.getLocation().isMacroID();
274281
const bool IsVarUnused = isVariableUnused(NewVar, BlockStmt, *Result.Context);
275282
const bool IsVarOnlyUsedAsConst =
276-
isOnlyUsedAsConst(NewVar, BlockStmt, *Result.Context);
283+
isOnlyUsedAsConst(NewVar, BlockStmt, *Result.Context,
284+
// `NewVar` is always of non-pointer type.
285+
0);
277286
const CheckContext Context{
278287
NewVar, BlockStmt, VarDeclStmt, *Result.Context,
279288
IssueFix, IsVarUnused, IsVarOnlyUsedAsConst};

clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,13 @@ def main():
300300
"the main file of each translation unit are always "
301301
"displayed.",
302302
)
303+
parser.add_argument(
304+
"-source-filter",
305+
default=None,
306+
help="Regular expression matching the names of the "
307+
"source files from compilation database to output "
308+
"diagnostics from.",
309+
)
303310
parser.add_argument(
304311
"-line-filter",
305312
default=None,
@@ -462,6 +469,19 @@ def main():
462469
[make_absolute(entry["file"], entry["directory"]) for entry in database]
463470
)
464471

472+
# Filter source files from compilation database.
473+
if args.source_filter:
474+
try:
475+
source_filter_re = re.compile(args.source_filter)
476+
except:
477+
print(
478+
"Error: unable to compile regex from arg -source-filter:",
479+
file=sys.stderr,
480+
)
481+
traceback.print_exc()
482+
sys.exit(1)
483+
files = {f for f in files if source_filter_re.match(f)}
484+
465485
max_task = args.j
466486
if max_task == 0:
467487
max_task = multiprocessing.cpu_count()

0 commit comments

Comments
 (0)