Skip to content

Commit 517c018

Browse files
Merge branch 'main' into gpuprofdriver
2 parents 3f80999 + 8caeb2e commit 517c018

File tree

52 files changed

+8464
-5534
lines changed

Some content is hidden

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

52 files changed

+8464
-5534
lines changed

clang/test/Driver/sanitizer-ld.c

Lines changed: 75 additions & 63 deletions
Large diffs are not rendered by default.

lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ bool ConnectionFileDescriptor::IsConnected() const {
119119

120120
ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
121121
Status *error_ptr) {
122-
return Connect(
123-
path, [](llvm::StringRef) {}, error_ptr);
122+
return Connect(path, [](llvm::StringRef) {}, error_ptr);
124123
}
125124

126125
ConnectionStatus

lldb/source/Host/posix/DomainSocket.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ Status DomainSocket::Connect(llvm::StringRef name) {
8686
if (error.Fail())
8787
return error;
8888
if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),
89-
(struct sockaddr *)&saddr_un, saddr_un_len) < 0)
89+
(struct sockaddr *)&saddr_un,
90+
saddr_un_len) < 0)
9091
SetLastError(error);
9192

9293
return error;

lldb/source/Host/posix/MainLoopPosix.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class MainLoopPosix::RunImpl {
9999
~RunImpl() = default;
100100

101101
Status Poll();
102+
102103
void ProcessReadEvents();
103104

104105
private:
@@ -159,6 +160,22 @@ MainLoopPosix::RunImpl::RunImpl(MainLoopPosix &loop) : loop(loop) {
159160
read_fds.reserve(loop.m_read_fds.size());
160161
}
161162

163+
static int StartPoll(llvm::MutableArrayRef<struct pollfd> fds,
164+
std::optional<MainLoopPosix::TimePoint> point) {
165+
#if HAVE_PPOLL
166+
return ppoll(fds.data(), fds.size(), ToTimeSpec(point),
167+
/*sigmask=*/nullptr);
168+
#else
169+
using namespace std::chrono;
170+
int timeout = -1;
171+
if (point) {
172+
nanoseconds dur = std::max(*point - steady_clock::now(), nanoseconds(0));
173+
timeout = ceil<milliseconds>(dur).count();
174+
}
175+
return poll(fds.data(), fds.size(), timeout);
176+
#endif
177+
}
178+
162179
Status MainLoopPosix::RunImpl::Poll() {
163180
read_fds.clear();
164181

@@ -169,11 +186,9 @@ Status MainLoopPosix::RunImpl::Poll() {
169186
pfd.revents = 0;
170187
read_fds.push_back(pfd);
171188
}
189+
int ready = StartPoll(read_fds, loop.GetNextWakeupTime());
172190

173-
if (ppoll(read_fds.data(), read_fds.size(),
174-
ToTimeSpec(loop.GetNextWakeupTime()),
175-
/*sigmask=*/nullptr) == -1 &&
176-
errno != EINTR)
191+
if (ready == -1 && errno != EINTR)
177192
return Status(errno, eErrorTypePOSIX);
178193

179194
return Status();

lldb/source/Plugins/Language/ObjC/Cocoa.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include "llvm/ADT/APInt.h"
3232
#include "llvm/ADT/bit.h"
3333

34-
3534
using namespace lldb;
3635
using namespace lldb_private;
3736
using namespace lldb_private::formatters;
@@ -267,21 +266,21 @@ bool lldb_private::formatters::NSIndexSetSummaryProvider(
267266
if (class_name == "NSIndexSet" || class_name == "NSMutableIndexSet") {
268267
// Foundation version 2000 added a bitmask if the index set fit in 64 bits
269268
// and a Tagged Pointer version if the bitmask is small enough to fit in
270-
// the tagged pointer payload.
269+
// the tagged pointer payload.
271270
// It also changed the layout (but not the size) of the set descriptor.
272271

273272
// First check whether this is a tagged pointer. The bitmask will be in
274273
// the payload of the tagged pointer.
275274
uint64_t payload;
276-
if (runtime->GetFoundationVersion() >= 2000
277-
&& descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) {
275+
if (runtime->GetFoundationVersion() >= 2000 &&
276+
descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) {
278277
count = llvm::popcount(payload);
279278
break;
280279
}
281280
// The first 32 bits describe the index set in all cases:
282281
Status error;
283282
uint32_t mode = process_sp->ReadUnsignedIntegerFromMemory(
284-
valobj_addr + ptr_size, 4, 0, error);
283+
valobj_addr + ptr_size, 4, 0, error);
285284
if (error.Fail())
286285
return false;
287286
// Now check if the index is held in a bitmask in the object:
@@ -292,7 +291,7 @@ bool lldb_private::formatters::NSIndexSetSummaryProvider(
292291
if ((mode & 2) == 2) {
293292
// The bitfield is a 64 bit uint at the beginning of the data var.
294293
uint64_t bitfield = process_sp->ReadUnsignedIntegerFromMemory(
295-
valobj_addr + 2 * ptr_size, 8, 0, error);
294+
valobj_addr + 2 * ptr_size, 8, 0, error);
296295
if (error.Fail())
297296
return false;
298297
count = llvm::popcount(bitfield);
@@ -309,7 +308,7 @@ bool lldb_private::formatters::NSIndexSetSummaryProvider(
309308
count = 0;
310309
break;
311310
}
312-
311+
313312
if ((mode & 2) == 2)
314313
mode = 1; // this means the set only has one range
315314
else

lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ size_t ObjectContainerBSDArchive::Archive::ParseObjects() {
8181

8282
std::unique_ptr<llvm::MemoryBuffer> mem_buffer =
8383
llvm::MemoryBuffer::getMemBuffer(
84-
llvm::StringRef((const char *)data.GetDataStart(),
85-
data.GetByteSize()),
86-
llvm::StringRef(),
87-
/*RequiresNullTerminator=*/false);
84+
llvm::StringRef((const char *)data.GetDataStart(),
85+
data.GetByteSize()),
86+
llvm::StringRef(),
87+
/*RequiresNullTerminator=*/false);
8888

8989
auto exp_ar = llvm::object::Archive::create(mem_buffer->getMemBufferRef());
9090
if (!exp_ar) {
@@ -95,7 +95,7 @@ size_t ObjectContainerBSDArchive::Archive::ParseObjects() {
9595

9696
llvm::Error iter_err = llvm::Error::success();
9797
Object obj;
98-
for (const auto &child: llvm_archive->children(iter_err)) {
98+
for (const auto &child : llvm_archive->children(iter_err)) {
9999
obj.Clear();
100100
auto exp_name = child.getName();
101101
if (exp_name) {
@@ -111,7 +111,9 @@ size_t ObjectContainerBSDArchive::Archive::ParseObjects() {
111111
obj.modification_time =
112112
std::chrono::duration_cast<std::chrono::seconds>(
113113
std::chrono::time_point_cast<std::chrono::seconds>(
114-
exp_mtime.get()).time_since_epoch()).count();
114+
exp_mtime.get())
115+
.time_since_epoch())
116+
.count();
115117
} else {
116118
LLDB_LOG_ERROR(l, exp_mtime.takeError(),
117119
"failed to get archive object time: {0}");
@@ -331,21 +333,21 @@ ObjectContainer *ObjectContainerBSDArchive::CreateInstance(
331333
ArchiveType
332334
ObjectContainerBSDArchive::MagicBytesMatch(const DataExtractor &data) {
333335
uint32_t offset = 0;
334-
const char *armag = (const char *)data.PeekData(offset,
335-
sizeof(ar_hdr) + SARMAG);
336+
const char *armag =
337+
(const char *)data.PeekData(offset, sizeof(ar_hdr) + SARMAG);
336338
if (armag == nullptr)
337339
return ArchiveType::Invalid;
338340
ArchiveType result = ArchiveType::Invalid;
339341
if (strncmp(armag, ArchiveMagic, SARMAG) == 0)
340-
result = ArchiveType::Archive;
342+
result = ArchiveType::Archive;
341343
else if (strncmp(armag, ThinArchiveMagic, SARMAG) == 0)
342-
result = ArchiveType::ThinArchive;
344+
result = ArchiveType::ThinArchive;
343345
else
344-
return ArchiveType::Invalid;
346+
return ArchiveType::Invalid;
345347

346348
armag += offsetof(struct ar_hdr, ar_fmag) + SARMAG;
347349
if (strncmp(armag, ARFMAG, 2) == 0)
348-
return result;
350+
return result;
349351
return ArchiveType::Invalid;
350352
}
351353

@@ -443,7 +445,8 @@ size_t ObjectContainerBSDArchive::GetModuleSpecifications(
443445
return 0;
444446

445447
const size_t initial_count = specs.GetSize();
446-
llvm::sys::TimePoint<> file_mod_time = FileSystem::Instance().GetModificationTime(file);
448+
llvm::sys::TimePoint<> file_mod_time =
449+
FileSystem::Instance().GetModificationTime(file);
447450
Archive::shared_ptr archive_sp(
448451
Archive::FindCachedArchive(file, ArchSpec(), file_mod_time, file_offset));
449452
bool set_archive_arch = false;

llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -364,19 +364,16 @@ struct CountedRegion : public CounterMappingRegion {
364364
uint64_t FalseExecutionCount;
365365
bool TrueFolded;
366366
bool FalseFolded;
367-
bool HasSingleByteCoverage;
368367

369-
CountedRegion(const CounterMappingRegion &R, uint64_t ExecutionCount,
370-
bool HasSingleByteCoverage)
368+
CountedRegion(const CounterMappingRegion &R, uint64_t ExecutionCount)
371369
: CounterMappingRegion(R), ExecutionCount(ExecutionCount),
372-
FalseExecutionCount(0), TrueFolded(false), FalseFolded(true),
373-
HasSingleByteCoverage(HasSingleByteCoverage) {}
370+
FalseExecutionCount(0), TrueFolded(false), FalseFolded(true) {}
374371

375372
CountedRegion(const CounterMappingRegion &R, uint64_t ExecutionCount,
376-
uint64_t FalseExecutionCount, bool HasSingleByteCoverage)
373+
uint64_t FalseExecutionCount)
377374
: CounterMappingRegion(R), ExecutionCount(ExecutionCount),
378375
FalseExecutionCount(FalseExecutionCount), TrueFolded(false),
379-
FalseFolded(false), HasSingleByteCoverage(HasSingleByteCoverage) {}
376+
FalseFolded(false) {}
380377
};
381378

382379
/// MCDC Record grouping all information together.
@@ -719,10 +716,9 @@ struct FunctionRecord {
719716
}
720717

721718
void pushRegion(CounterMappingRegion Region, uint64_t Count,
722-
uint64_t FalseCount, bool HasSingleByteCoverage) {
719+
uint64_t FalseCount) {
723720
if (Region.isBranch()) {
724-
CountedBranchRegions.emplace_back(Region, Count, FalseCount,
725-
HasSingleByteCoverage);
721+
CountedBranchRegions.emplace_back(Region, Count, FalseCount);
726722
// If either counter is hard-coded to zero, then this region represents a
727723
// constant-folded branch.
728724
CountedBranchRegions.back().TrueFolded = Region.Count.isZero();
@@ -731,8 +727,7 @@ struct FunctionRecord {
731727
}
732728
if (CountedRegions.empty())
733729
ExecutionCount = Count;
734-
CountedRegions.emplace_back(Region, Count, FalseCount,
735-
HasSingleByteCoverage);
730+
CountedRegions.emplace_back(Region, Count, FalseCount);
736731
}
737732
};
738733

@@ -895,14 +890,19 @@ class CoverageData {
895890
std::vector<CountedRegion> BranchRegions;
896891
std::vector<MCDCRecord> MCDCRecords;
897892

893+
bool SingleByteCoverage = false;
894+
898895
public:
899896
CoverageData() = default;
900897

901-
CoverageData(StringRef Filename) : Filename(Filename) {}
898+
CoverageData(bool Single, StringRef Filename)
899+
: Filename(Filename), SingleByteCoverage(Single) {}
902900

903901
/// Get the name of the file this data covers.
904902
StringRef getFilename() const { return Filename; }
905903

904+
bool getSingleByteCoverage() const { return SingleByteCoverage; }
905+
906906
/// Get an iterator over the coverage segments for this object. The segments
907907
/// are guaranteed to be uniqued and sorted by location.
908908
std::vector<CoverageSegment>::const_iterator begin() const {
@@ -935,6 +935,8 @@ class CoverageMapping {
935935
DenseMap<size_t, SmallVector<unsigned, 0>> FilenameHash2RecordIndices;
936936
std::vector<std::pair<std::string, uint64_t>> FuncHashMismatches;
937937

938+
std::optional<bool> SingleByteCoverage;
939+
938940
CoverageMapping() = default;
939941

940942
// Load coverage records from readers.

llvm/include/llvm/Transforms/IPO/Attributor.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3853,7 +3853,7 @@ struct AANoAlias
38533853

38543854
/// See AbstractAttribute::isValidIRPositionForInit
38553855
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP) {
3856-
if (!IRP.getAssociatedType()->isPtrOrPtrVectorTy())
3856+
if (!IRP.getAssociatedType()->isPointerTy())
38573857
return false;
38583858
return IRAttribute::isValidIRPositionForInit(A, IRP);
38593859
}
@@ -4220,7 +4220,7 @@ struct AADereferenceable
42204220

42214221
/// See AbstractAttribute::isValidIRPositionForInit
42224222
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP) {
4223-
if (!IRP.getAssociatedType()->isPtrOrPtrVectorTy())
4223+
if (!IRP.getAssociatedType()->isPointerTy())
42244224
return false;
42254225
return IRAttribute::isValidIRPositionForInit(A, IRP);
42264226
}
@@ -4364,7 +4364,7 @@ struct AANoCapture
43644364

43654365
/// See AbstractAttribute::isValidIRPositionForInit
43664366
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP) {
4367-
if (!IRP.getAssociatedType()->isPtrOrPtrVectorTy())
4367+
if (!IRP.getAssociatedType()->isPointerTy())
43684368
return false;
43694369
return IRAttribute::isValidIRPositionForInit(A, IRP);
43704370
}
@@ -4635,8 +4635,7 @@ struct AAMemoryBehavior
46354635

46364636
/// See AbstractAttribute::isValidIRPositionForInit
46374637
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP) {
4638-
if (!IRP.isFunctionScope() &&
4639-
!IRP.getAssociatedType()->isPtrOrPtrVectorTy())
4638+
if (!IRP.isFunctionScope() && !IRP.getAssociatedType()->isPointerTy())
46404639
return false;
46414640
return IRAttribute::isValidIRPositionForInit(A, IRP);
46424641
}

llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,6 @@ Error CoverageMapping::loadFunctionRecord(
805805
else
806806
OrigFuncName = getFuncNameWithoutPrefix(OrigFuncName, Record.Filenames[0]);
807807

808-
bool SingleByteCoverage = ProfileReader.hasSingleByteCoverage();
809808
CounterMappingContext Ctx(Record.Expressions);
810809

811810
std::vector<uint64_t> Counts;
@@ -871,10 +870,7 @@ Error CoverageMapping::loadFunctionRecord(
871870
consumeError(std::move(E));
872871
return Error::success();
873872
}
874-
Function.pushRegion(
875-
Region, (SingleByteCoverage && *ExecutionCount ? 1 : *ExecutionCount),
876-
(SingleByteCoverage && *AltExecutionCount ? 1 : *AltExecutionCount),
877-
SingleByteCoverage);
873+
Function.pushRegion(Region, *ExecutionCount, *AltExecutionCount);
878874

879875
// Record ExpansionRegion.
880876
if (Region.Kind == CounterMappingRegion::ExpansionRegion) {
@@ -936,6 +932,9 @@ Error CoverageMapping::loadFunctionRecord(
936932
Error CoverageMapping::loadFromReaders(
937933
ArrayRef<std::unique_ptr<CoverageMappingReader>> CoverageReaders,
938934
IndexedInstrProfReader &ProfileReader, CoverageMapping &Coverage) {
935+
assert(!Coverage.SingleByteCoverage ||
936+
*Coverage.SingleByteCoverage == ProfileReader.hasSingleByteCoverage());
937+
Coverage.SingleByteCoverage = ProfileReader.hasSingleByteCoverage();
939938
for (const auto &CoverageReader : CoverageReaders) {
940939
for (auto RecordOrErr : *CoverageReader) {
941940
if (Error E = RecordOrErr.takeError())
@@ -1296,14 +1295,8 @@ class SegmentBuilder {
12961295
// value for that area.
12971296
// We add counts of the regions of the same kind as the active region
12981297
// to handle the both situations.
1299-
if (I->Kind == Active->Kind) {
1300-
assert(I->HasSingleByteCoverage == Active->HasSingleByteCoverage &&
1301-
"Regions are generated in different coverage modes");
1302-
if (I->HasSingleByteCoverage)
1303-
Active->ExecutionCount = Active->ExecutionCount || I->ExecutionCount;
1304-
else
1305-
Active->ExecutionCount += I->ExecutionCount;
1306-
}
1298+
if (I->Kind == Active->Kind)
1299+
Active->ExecutionCount += I->ExecutionCount;
13071300
}
13081301
return Regions.drop_back(std::distance(++Active, End));
13091302
}
@@ -1396,7 +1389,8 @@ static bool isExpansion(const CountedRegion &R, unsigned FileID) {
13961389
}
13971390

13981391
CoverageData CoverageMapping::getCoverageForFile(StringRef Filename) const {
1399-
CoverageData FileCoverage(Filename);
1392+
assert(SingleByteCoverage);
1393+
CoverageData FileCoverage(*SingleByteCoverage, Filename);
14001394
std::vector<CountedRegion> Regions;
14011395

14021396
// Look up the function records in the given file. Due to hash collisions on
@@ -1460,7 +1454,9 @@ CoverageMapping::getCoverageForFunction(const FunctionRecord &Function) const {
14601454
if (!MainFileID)
14611455
return CoverageData();
14621456

1463-
CoverageData FunctionCoverage(Function.Filenames[*MainFileID]);
1457+
assert(SingleByteCoverage);
1458+
CoverageData FunctionCoverage(*SingleByteCoverage,
1459+
Function.Filenames[*MainFileID]);
14641460
std::vector<CountedRegion> Regions;
14651461
for (const auto &CR : Function.CountedRegions)
14661462
if (CR.FileID == *MainFileID) {
@@ -1487,8 +1483,9 @@ CoverageMapping::getCoverageForFunction(const FunctionRecord &Function) const {
14871483

14881484
CoverageData CoverageMapping::getCoverageForExpansion(
14891485
const ExpansionRecord &Expansion) const {
1486+
assert(SingleByteCoverage);
14901487
CoverageData ExpansionCoverage(
1491-
Expansion.Function.Filenames[Expansion.FileID]);
1488+
*SingleByteCoverage, Expansion.Function.Filenames[Expansion.FileID]);
14921489
std::vector<CountedRegion> Regions;
14931490
for (const auto &CR : Expansion.Function.CountedRegions)
14941491
if (CR.FileID == Expansion.FileID) {

0 commit comments

Comments
 (0)