Skip to content

Commit 57ddf09

Browse files
committed
Merge branch 'amd-staging' into amd/dev/epilking/fix-540933
2 parents d265b24 + 659e9cd commit 57ddf09

File tree

746 files changed

+15142
-18671
lines changed

Some content is hidden

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

746 files changed

+15142
-18671
lines changed

amd/comgr/src/comgr-compiler.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -810,10 +810,16 @@ amd_comgr_status_t AMDGPUCompiler::createTmpDirs() {
810810
return AMD_COMGR_STATUS_SUCCESS;
811811
}
812812

813+
amd_comgr_status_t AMDGPUCompiler::removeTmpDirs() {
814+
if (TmpDir.empty()) {
815+
return AMD_COMGR_STATUS_SUCCESS;
816+
}
817+
ProfilePoint Point("RemoveDir");
818+
819+
#ifdef _WIN32
813820
// On windows fs::remove_directories takes huge time so use fs::remove.
814-
amd_comgr_status_t removeDirectory(const StringRef DirName) {
815821
std::error_code EC;
816-
for (fs::directory_iterator Dir(DirName, EC), DirEnd; Dir != DirEnd && !EC;
822+
for (fs::directory_iterator Dir(TmpDir, EC), DirEnd; Dir != DirEnd && !EC;
817823
Dir.increment(EC)) {
818824
const StringRef Path = Dir->path();
819825

@@ -843,25 +849,16 @@ amd_comgr_status_t removeDirectory(const StringRef DirName) {
843849
}
844850
}
845851

846-
if (fs::remove(DirName)) {
852+
if (fs::remove(TmpDir)) {
847853
return AMD_COMGR_STATUS_ERROR;
848854
}
849855

850856
return AMD_COMGR_STATUS_SUCCESS;
851-
}
852-
853-
amd_comgr_status_t AMDGPUCompiler::removeTmpDirs() {
854-
if (TmpDir.empty()) {
855-
return AMD_COMGR_STATUS_SUCCESS;
856-
}
857-
ProfilePoint Point("RemoveDir");
858-
#ifndef _WIN32
857+
#else
859858
if (fs::remove_directories(TmpDir)) {
860859
return AMD_COMGR_STATUS_ERROR;
861860
}
862861
return AMD_COMGR_STATUS_SUCCESS;
863-
#else
864-
return removeDirectory(TmpDir);
865862
#endif
866863
}
867864

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@ class DataAggregator : public DataReader {
236236

237237
/// Launch a perf subprocess with given args and save output for later
238238
/// parsing.
239-
void launchPerfProcess(StringRef Name, PerfProcessInfo &PPI,
240-
const char *ArgsString, bool Wait);
239+
void launchPerfProcess(StringRef Name, PerfProcessInfo &PPI, StringRef Args);
241240

242241
/// Delete all temporary files created to hold the output generated by spawned
243242
/// subprocesses during the aggregation job

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 48 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -197,34 +197,27 @@ void DataAggregator::start() {
197197

198198
if (opts::BasicAggregation) {
199199
launchPerfProcess("events without LBR", MainEventsPPI,
200-
"script -F pid,event,ip",
201-
/*Wait = */ false);
200+
"script -F pid,event,ip");
202201
} else if (!opts::ITraceAggregation.empty()) {
203202
// Disable parsing memory profile from trace data, unless requested by user.
204203
if (!opts::ParseMemProfile.getNumOccurrences())
205204
opts::ParseMemProfile = false;
206-
207-
std::string ItracePerfScriptArgs = llvm::formatv(
208-
"script -F pid,brstack --itrace={0}", opts::ITraceAggregation);
209205
launchPerfProcess("branch events with itrace", MainEventsPPI,
210-
ItracePerfScriptArgs.c_str(),
211-
/*Wait = */ false);
206+
"script -F pid,brstack --itrace=" +
207+
opts::ITraceAggregation);
212208
} else {
213-
launchPerfProcess("branch events", MainEventsPPI, "script -F pid,brstack",
214-
/*Wait = */ false);
209+
launchPerfProcess("branch events", MainEventsPPI, "script -F pid,brstack");
215210
}
216211

217212
if (opts::ParseMemProfile)
218-
launchPerfProcess("mem events", MemEventsPPI, "script -F pid,event,addr,ip",
219-
/*Wait = */ false);
213+
launchPerfProcess("mem events", MemEventsPPI,
214+
"script -F pid,event,addr,ip");
220215

221216
launchPerfProcess("process events", MMapEventsPPI,
222-
"script --show-mmap-events --no-itrace",
223-
/*Wait = */ false);
217+
"script --show-mmap-events --no-itrace");
224218

225219
launchPerfProcess("task events", TaskEventsPPI,
226-
"script --show-task-events --no-itrace",
227-
/*Wait = */ false);
220+
"script --show-task-events --no-itrace");
228221
}
229222

230223
void DataAggregator::abort() {
@@ -246,13 +239,13 @@ void DataAggregator::abort() {
246239
}
247240

248241
void DataAggregator::launchPerfProcess(StringRef Name, PerfProcessInfo &PPI,
249-
const char *ArgsString, bool Wait) {
242+
StringRef Args) {
250243
SmallVector<StringRef, 4> Argv;
251244

252245
outs() << "PERF2BOLT: spawning perf job to read " << Name << '\n';
253246
Argv.push_back(PerfPath.data());
254247

255-
StringRef(ArgsString).split(Argv, ' ');
248+
Args.split(Argv, ' ');
256249
Argv.push_back("-f");
257250
Argv.push_back("-i");
258251
Argv.push_back(Filename.c_str());
@@ -286,64 +279,45 @@ void DataAggregator::launchPerfProcess(StringRef Name, PerfProcessInfo &PPI,
286279
<< "\n";
287280
});
288281

289-
if (Wait)
290-
PPI.PI.ReturnCode = sys::ExecuteAndWait(PerfPath.data(), Argv,
291-
/*envp*/ std::nullopt, Redirects);
292-
else
293-
PPI.PI = sys::ExecuteNoWait(PerfPath.data(), Argv, /*envp*/ std::nullopt,
294-
Redirects);
282+
PPI.PI = sys::ExecuteNoWait(PerfPath.data(), Argv, /*envp*/ std::nullopt,
283+
Redirects);
295284
}
296285

297286
void DataAggregator::processFileBuildID(StringRef FileBuildID) {
287+
auto WarningCallback = [](int ReturnCode, StringRef ErrBuf) {
288+
errs() << "PERF-ERROR: return code " << ReturnCode << "\n" << ErrBuf;
289+
};
290+
298291
PerfProcessInfo BuildIDProcessInfo;
299-
launchPerfProcess("buildid list",
300-
BuildIDProcessInfo,
301-
"buildid-list",
302-
/*Wait = */true);
303-
304-
if (BuildIDProcessInfo.PI.ReturnCode != 0) {
305-
ErrorOr<std::unique_ptr<MemoryBuffer>> MB =
306-
MemoryBuffer::getFileOrSTDIN(BuildIDProcessInfo.StderrPath.data());
307-
StringRef ErrBuf = (*MB)->getBuffer();
308-
309-
errs() << "PERF-ERROR: return code " << BuildIDProcessInfo.PI.ReturnCode
310-
<< '\n';
311-
errs() << ErrBuf;
292+
launchPerfProcess("buildid list", BuildIDProcessInfo, "buildid-list");
293+
if (prepareToParse("buildid", BuildIDProcessInfo, WarningCallback))
312294
return;
313-
}
314295

315-
ErrorOr<std::unique_ptr<MemoryBuffer>> MB =
316-
MemoryBuffer::getFileOrSTDIN(BuildIDProcessInfo.StdoutPath.data());
317-
if (std::error_code EC = MB.getError()) {
318-
errs() << "Cannot open " << BuildIDProcessInfo.StdoutPath.data() << ": "
319-
<< EC.message() << "\n";
296+
std::optional<StringRef> FileName = getFileNameForBuildID(FileBuildID);
297+
if (FileName && *FileName == sys::path::filename(BC->getFilename())) {
298+
outs() << "PERF2BOLT: matched build-id and file name\n";
320299
return;
321300
}
322301

323-
FileBuf = std::move(*MB);
324-
ParsingBuf = FileBuf->getBuffer();
325-
326-
std::optional<StringRef> FileName = getFileNameForBuildID(FileBuildID);
327-
if (!FileName) {
328-
if (hasAllBuildIDs()) {
329-
errs() << "PERF2BOLT-ERROR: failed to match build-id from perf output. "
330-
"This indicates the input binary supplied for data aggregation "
331-
"is not the same recorded by perf when collecting profiling "
332-
"data, or there were no samples recorded for the binary. "
333-
"Use -ignore-build-id option to override.\n";
334-
if (!opts::IgnoreBuildID)
335-
abort();
336-
} else {
337-
errs() << "PERF2BOLT-WARNING: build-id will not be checked because perf "
338-
"data was recorded without it\n";
339-
return;
340-
}
341-
} else if (*FileName != llvm::sys::path::filename(BC->getFilename())) {
302+
if (FileName) {
342303
errs() << "PERF2BOLT-WARNING: build-id matched a different file name\n";
343304
BuildIDBinaryName = std::string(*FileName);
344-
} else {
345-
outs() << "PERF2BOLT: matched build-id and file name\n";
305+
return;
346306
}
307+
308+
if (!hasAllBuildIDs()) {
309+
errs() << "PERF2BOLT-WARNING: build-id will not be checked because perf "
310+
"data was recorded without it\n";
311+
return;
312+
}
313+
314+
errs() << "PERF2BOLT-ERROR: failed to match build-id from perf output. "
315+
"This indicates the input binary supplied for data aggregation "
316+
"is not the same recorded by perf when collecting profiling "
317+
"data, or there were no samples recorded for the binary. "
318+
"Use -ignore-build-id option to override.\n";
319+
if (!opts::IgnoreBuildID)
320+
abort();
347321
}
348322

349323
bool DataAggregator::checkPerfDataMagic(StringRef FileName) {
@@ -432,14 +406,24 @@ int DataAggregator::prepareToParse(StringRef Name, PerfProcessInfo &Process,
432406
std::string Error;
433407
outs() << "PERF2BOLT: waiting for perf " << Name
434408
<< " collection to finish...\n";
435-
sys::ProcessInfo PI = sys::Wait(Process.PI, std::nullopt, &Error);
409+
std::optional<sys::ProcessStatistics> PS;
410+
sys::ProcessInfo PI = sys::Wait(Process.PI, std::nullopt, &Error, &PS);
436411

437412
if (!Error.empty()) {
438413
errs() << "PERF-ERROR: " << PerfPath << ": " << Error << "\n";
439414
deleteTempFiles();
440415
exit(1);
441416
}
442417

418+
LLVM_DEBUG({
419+
const float UserSec = 1.f * PS->UserTime.count() / 1e6;
420+
const float TotalSec = 1.f * PS->TotalTime.count() / 1e6;
421+
const float PeakGiB = 1.f * PS->PeakMemory / (1 << 20);
422+
dbgs() << formatv("Finished in {0:f2}s user time, {1:f2}s total time, "
423+
"{2:f2} GiB peak RSS\n",
424+
UserSec, TotalSec, PeakGiB);
425+
});
426+
443427
if (PI.ReturnCode != 0) {
444428
ErrorOr<std::unique_ptr<MemoryBuffer>> ErrorMB =
445429
MemoryBuffer::getFileOrSTDIN(Process.StderrPath.data());

clang-tools-extra/clang-tidy/bugprone/MisleadingSetterOfReferenceCheck.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ void MisleadingSetterOfReferenceCheck::check(
5050
const MatchFinder::MatchResult &Result) {
5151
const auto *Found = Result.Nodes.getNodeAs<CXXMethodDecl>("bad-set-function");
5252
const auto *Member = Result.Nodes.getNodeAs<FieldDecl>("member");
53+
assert(Found != nullptr);
54+
assert(Member != nullptr);
5355

5456
diag(Found->getBeginLoc(),
5557
"function '%0' can be mistakenly used in order to change the "
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
:orphan:
22
:template: clangd_redirect.html
3-
:redirect_target: https://clangd.llvm.org/design.html
3+
:redirect_target: https://clangd.llvm.org/design/

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ C Language Changes
249249
- The ``[[clang::assume()]]`` attribute is now correctly recognized in C. The
250250
``__attribute__((assume()))`` form has always been supported, so the fix is
251251
specific to the attribute syntax used.
252+
- The ``clang-cl`` driver now recognizes ``/std:clatest`` and sets the language
253+
mode to C23. (#GH147233)
252254

253255
C2y Feature Support
254256
^^^^^^^^^^^^^^^^^^^
@@ -306,6 +308,8 @@ C23 Feature Support
306308
which clarified how Clang is handling underspecified object declarations.
307309
- Clang now accepts single variadic parameter in type-name. It's a part of
308310
`WG14 N2975 <https://open-std.org/JTC1/SC22/WG14/www/docs/n2975.pdf>`_
311+
- Fixed a bug with handling the type operand form of ``typeof`` when it is used
312+
to specify a fixed underlying type for an enumeration. #GH146351
309313

310314
C11 Feature Support
311315
^^^^^^^^^^^^^^^^^^^
@@ -687,6 +691,8 @@ Improvements to Clang's diagnostics
687691
false positives in exception-heavy code, though only simple patterns
688692
are currently recognized.
689693

694+
- Clang now accepts ``@tparam`` comments on variable template partial
695+
specializations. (#GH144775)
690696

691697
Improvements to Clang's time-trace
692698
----------------------------------

clang/include/clang/AST/ExprCXX.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class CXXOperatorCallExpr final : public CallExpr {
8484
friend class ASTStmtReader;
8585
friend class ASTStmtWriter;
8686

87-
SourceRange Range;
87+
SourceLocation BeginLoc;
8888

8989
// CXXOperatorCallExpr has some trailing objects belonging
9090
// to CallExpr. See CallExpr for the details.
@@ -158,9 +158,9 @@ class CXXOperatorCallExpr final : public CallExpr {
158158
: getOperatorLoc();
159159
}
160160

161-
SourceLocation getBeginLoc() const { return Range.getBegin(); }
162-
SourceLocation getEndLoc() const { return Range.getEnd(); }
163-
SourceRange getSourceRange() const { return Range; }
161+
SourceLocation getBeginLoc() const { return BeginLoc; }
162+
SourceLocation getEndLoc() const { return getSourceRangeImpl().getEnd(); }
163+
SourceRange getSourceRange() const { return getSourceRangeImpl(); }
164164

165165
static bool classof(const Stmt *T) {
166166
return T->getStmtClass() == CXXOperatorCallExprClass;

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,9 +1530,11 @@ def OpenMPPre51Compat : DiagGroup<"pre-openmp-51-compat">;
15301530
def OpenMP51Ext : DiagGroup<"openmp-51-extensions">;
15311531
def OpenMPExtensions : DiagGroup<"openmp-extensions">;
15321532
def OpenMPTargetException : DiagGroup<"openmp-target-exception">;
1533+
def OpenMPFuture : DiagGroup<"openmp-future">;
15331534
def OpenMP : DiagGroup<"openmp", [
15341535
SourceUsesOpenMP, OpenMPClauses, OpenMPLoopForm, OpenMPTarget,
1535-
OpenMPMapping, OpenMP51Ext, OpenMPExtensions, OpenMPTargetException
1536+
OpenMPMapping, OpenMP51Ext, OpenMPExtensions, OpenMPTargetException,
1537+
OpenMPFuture
15361538
]>;
15371539

15381540
// OpenACC warnings.

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,9 @@ def err_omp_multiple_step_or_linear_modifier : Error<
14881488
"multiple %select{'step size'|'linear modifier'}0 found in linear clause">;
14891489
def err_omp_deprecate_old_syntax: Error<
14901490
"old syntax '%0' on '%1' clause was deprecated, use new syntax '%2'">;
1491+
def warn_omp_future_directive_spelling: Warning<
1492+
"directive spelling '%0' is introduced in a later OpenMP version">,
1493+
InGroup<OpenMPFuture>;
14911494
def warn_pragma_expected_colon_r_paren : Warning<
14921495
"missing ':' or ')' after %0 - ignoring">, InGroup<IgnoredPragmas>;
14931496
def err_omp_unknown_directive : Error<

clang/include/clang/Basic/SourceManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,8 @@ class SourceManager : public RefCountedBase<SourceManager> {
719719
/// Positive FileIDs are indexes into this table. Entry 0 indicates an invalid
720720
/// expansion.
721721
SmallVector<SrcMgr::SLocEntry, 0> LocalSLocEntryTable;
722+
/// An in-parallel offset table, merely used for speeding up FileID lookup.
723+
SmallVector<SourceLocation::UIntTy> LocalLocOffsetTable;
722724

723725
/// The table of SLocEntries that are loaded from other modules.
724726
///

0 commit comments

Comments
 (0)