Skip to content

Commit

Permalink
Merge branch 'llvm:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
gchatelet authored Sep 20, 2023
2 parents b315008 + fe5c185 commit 22f84ba
Show file tree
Hide file tree
Showing 259 changed files with 7,272 additions and 2,608 deletions.
6 changes: 3 additions & 3 deletions clang/docs/OpenMPSupport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ General improvements


GPU devices support
====================
===================

Data-sharing modes
------------------
Expand Down Expand Up @@ -204,7 +204,7 @@ implementation.
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
| misc | library shutdown (omp_pause_resource[_all]) | :good:`done` | D55078 |
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
| misc | metadirectives | :part:`mostly done` | D91944 |
| misc | metadirectives | :part:`mostly done` | D91944 |
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
| misc | conditional modifier for lastprivate clause | :good:`done` | |
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
Expand Down Expand Up @@ -267,7 +267,7 @@ implementation.
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
| device | indirect clause on declare target directive | :none:`unclaimed` | |
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
| device | allow virtual functions calls for mapped object on device | :part:`partial` | |
| device | allow virtual functions calls for mapped object on device | :part:`partial` | |
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
| device | interop construct | :part:`partial` | parsing/sema done: D98558, D98834, D98815 |
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
Expand Down
3 changes: 3 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ Bug Fixes to C++ Support
a non-template inner-class between the function and the class template.
(`#65810 <https://github.com/llvm/llvm-project/issues/65810>`_)

- Fix a crash when calling a non-constant immediate function
in the initializer of a static data member.
(`#65985 <https://github.com/llvm/llvm-project/issues/65985>_`).
- Clang now properly converts static lambda call operator to function
pointers on win32.
(`#62594 <https://github.com/llvm/llvm-project/issues/62594>`_)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class DependencyScanningFilesystemLocalCache {
public:
/// Returns entry associated with the filename or nullptr if none is found.
const CachedFileSystemEntry *findEntryByFilename(StringRef Filename) const {
assert(llvm::sys::path::is_absolute_gnu(Filename));
auto It = Cache.find(Filename);
return It == Cache.end() ? nullptr : It->getValue();
}
Expand All @@ -224,6 +225,7 @@ class DependencyScanningFilesystemLocalCache {
const CachedFileSystemEntry &
insertEntryForFilename(StringRef Filename,
const CachedFileSystemEntry &Entry) {
assert(llvm::sys::path::is_absolute_gnu(Filename));
const auto *InsertedEntry = Cache.insert({Filename, &Entry}).first->second;
assert(InsertedEntry == &Entry && "entry already present");
return *InsertedEntry;
Expand Down Expand Up @@ -282,13 +284,14 @@ class DependencyScanningWorkerFilesystem : public llvm::vfs::ProxyFileSystem {
public:
DependencyScanningWorkerFilesystem(
DependencyScanningFilesystemSharedCache &SharedCache,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS)
: ProxyFileSystem(std::move(FS)), SharedCache(SharedCache) {}
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS);

llvm::ErrorOr<llvm::vfs::Status> status(const Twine &Path) override;
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
openFileForRead(const Twine &Path) override;

std::error_code setCurrentWorkingDirectory(const Twine &Path) override;

/// Returns entry for the given filename.
///
/// Attempts to use the local and shared caches first, then falls back to
Expand All @@ -304,8 +307,11 @@ class DependencyScanningWorkerFilesystem : public llvm::vfs::ProxyFileSystem {
/// For a filename that's not yet associated with any entry in the caches,
/// uses the underlying filesystem to either look up the entry based in the
/// shared cache indexed by unique ID, or creates new entry from scratch.
/// \p FilenameForLookup will always be an absolute path, and different than
/// \p OriginalFilename if \p OriginalFilename is relative.
llvm::ErrorOr<const CachedFileSystemEntry &>
computeAndStoreResult(StringRef Filename);
computeAndStoreResult(StringRef OriginalFilename,
StringRef FilenameForLookup);

/// Scan for preprocessor directives for the given entry if necessary and
/// returns a wrapper object with reference semantics.
Expand Down Expand Up @@ -388,6 +394,12 @@ class DependencyScanningWorkerFilesystem : public llvm::vfs::ProxyFileSystem {
/// The local cache is used by the worker thread to cache file system queries
/// locally instead of querying the global cache every time.
DependencyScanningFilesystemLocalCache LocalCache;

/// The working directory to use for making relative paths absolute before
/// using them for cache lookups.
llvm::ErrorOr<std::string> WorkingDirForCacheLookup;

void updateWorkingDirForCacheLookup();
};

} // end namespace dependencies
Expand Down
13 changes: 7 additions & 6 deletions clang/lib/Analysis/FlowSensitive/Transfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,17 +531,18 @@ class TransferVisitor : public ConstStmtVisitor<TransferVisitor> {
auto *LocDst =
cast_or_null<RecordStorageLocation>(Env.getStorageLocation(*Arg0));

if (LocSrc == nullptr || LocDst == nullptr)
return;

// The assignment operators are different from the type of the destination
// in this model (i.e. in one of their base classes). This must be very rare
// and we just bail.
// in this model (i.e. in one of their base classes). This must be very
// rare and we just bail.
if (Method->getThisObjectType().getCanonicalType().getUnqualifiedType() !=
LocDst->getType().getCanonicalType().getUnqualifiedType())
return;

if (LocSrc != nullptr && LocDst != nullptr) {
copyRecord(*LocSrc, *LocDst, Env);
Env.setStorageLocation(*S, *LocDst);
}
copyRecord(*LocSrc, *LocDst, Env);
Env.setStorageLocation(*S, *LocDst);
}
}

Expand Down
7 changes: 6 additions & 1 deletion clang/lib/Headers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ add_header_target("loongarch-resource-headers" "${loongarch_files}")
add_header_target("mips-resource-headers" "${mips_msa_files}")
add_header_target("ppc-resource-headers" "${ppc_files};${ppc_wrapper_files}")
add_header_target("ppc-htm-resource-headers" "${ppc_htm_files}")
add_header_target("riscv-resource-headers" "${riscv_files};${riscv_generated_files}")
add_header_target("riscv-resource-headers" "${riscv_files};${riscv_generated_files};${sifive_files}")
add_header_target("systemz-resource-headers" "${systemz_files}")
add_header_target("ve-resource-headers" "${ve_files}")
add_header_target("webassembly-resource-headers" "${webassembly_files}")
Expand Down Expand Up @@ -623,6 +623,11 @@ install(
EXCLUDE_FROM_ALL
COMPONENT riscv-resource-headers)

install(
FILES ${sifive_files}
DESTINATION ${header_install_dir}
COMPONENT riscv-resource-headers)

install(
FILES ${systemz_files}
DESTINATION ${header_install_dir}
Expand Down
12 changes: 10 additions & 2 deletions clang/lib/Parse/ParseDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3232,13 +3232,21 @@ ExprResult Parser::ParseCXXMemberInitializer(Decl *D, bool IsFunction,
assert(Tok.isOneOf(tok::equal, tok::l_brace) &&
"Data member initializer not starting with '=' or '{'");

bool IsFieldInitialization = isa_and_present<FieldDecl>(D);

EnterExpressionEvaluationContext Context(
Actions,
isa_and_present<FieldDecl>(D)
IsFieldInitialization
? Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed
: Sema::ExpressionEvaluationContext::PotentiallyEvaluated,
D);
Actions.ExprEvalContexts.back().InImmediateEscalatingFunctionContext = true;

// CWG2760
// Default member initializers used to initialize a base or member subobject
// [...] are considered to be part of the function body
Actions.ExprEvalContexts.back().InImmediateEscalatingFunctionContext =
IsFieldInitialization;

if (TryConsumeToken(tok::equal, EqualLoc)) {
if (Tok.is(tok::kw_delete)) {
// In principle, an initializer of '= delete p;' is legal, but it will
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ DependencyScanningFilesystemSharedCache::
DependencyScanningFilesystemSharedCache::CacheShard &
DependencyScanningFilesystemSharedCache::getShardForFilename(
StringRef Filename) const {
assert(llvm::sys::path::is_absolute_gnu(Filename));
return CacheShards[llvm::hash_value(Filename) % NumShards];
}

Expand All @@ -109,6 +110,7 @@ DependencyScanningFilesystemSharedCache::getShardForUID(
const CachedFileSystemEntry *
DependencyScanningFilesystemSharedCache::CacheShard::findEntryByFilename(
StringRef Filename) const {
assert(llvm::sys::path::is_absolute_gnu(Filename));
std::lock_guard<std::mutex> LockGuard(CacheLock);
auto It = EntriesByFilename.find(Filename);
return It == EntriesByFilename.end() ? nullptr : It->getValue();
Expand Down Expand Up @@ -189,6 +191,14 @@ static bool shouldCacheStatFailures(StringRef Filename) {
return shouldScanForDirectivesBasedOnExtension(Filename);
}

DependencyScanningWorkerFilesystem::DependencyScanningWorkerFilesystem(
DependencyScanningFilesystemSharedCache &SharedCache,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS)
: ProxyFileSystem(std::move(FS)), SharedCache(SharedCache),
WorkingDirForCacheLookup(llvm::errc::invalid_argument) {
updateWorkingDirForCacheLookup();
}

bool DependencyScanningWorkerFilesystem::shouldScanForDirectives(
StringRef Filename) {
return shouldScanForDirectivesBasedOnExtension(Filename);
Expand All @@ -215,44 +225,62 @@ DependencyScanningWorkerFilesystem::findEntryByFilenameWithWriteThrough(
}

llvm::ErrorOr<const CachedFileSystemEntry &>
DependencyScanningWorkerFilesystem::computeAndStoreResult(StringRef Filename) {
llvm::ErrorOr<llvm::vfs::Status> Stat = getUnderlyingFS().status(Filename);
DependencyScanningWorkerFilesystem::computeAndStoreResult(
StringRef OriginalFilename, StringRef FilenameForLookup) {
llvm::ErrorOr<llvm::vfs::Status> Stat =
getUnderlyingFS().status(OriginalFilename);
if (!Stat) {
if (!shouldCacheStatFailures(Filename))
if (!shouldCacheStatFailures(OriginalFilename))
return Stat.getError();
const auto &Entry =
getOrEmplaceSharedEntryForFilename(Filename, Stat.getError());
return insertLocalEntryForFilename(Filename, Entry);
getOrEmplaceSharedEntryForFilename(FilenameForLookup, Stat.getError());
return insertLocalEntryForFilename(FilenameForLookup, Entry);
}

if (const auto *Entry = findSharedEntryByUID(*Stat))
return insertLocalEntryForFilename(Filename, *Entry);
return insertLocalEntryForFilename(FilenameForLookup, *Entry);

auto TEntry =
Stat->isDirectory() ? TentativeEntry(*Stat) : readFile(Filename);
Stat->isDirectory() ? TentativeEntry(*Stat) : readFile(OriginalFilename);

const CachedFileSystemEntry *SharedEntry = [&]() {
if (TEntry) {
const auto &UIDEntry = getOrEmplaceSharedEntryForUID(std::move(*TEntry));
return &getOrInsertSharedEntryForFilename(Filename, UIDEntry);
return &getOrInsertSharedEntryForFilename(FilenameForLookup, UIDEntry);
}
return &getOrEmplaceSharedEntryForFilename(Filename, TEntry.getError());
return &getOrEmplaceSharedEntryForFilename(FilenameForLookup,
TEntry.getError());
}();

return insertLocalEntryForFilename(Filename, *SharedEntry);
return insertLocalEntryForFilename(FilenameForLookup, *SharedEntry);
}

llvm::ErrorOr<EntryRef>
DependencyScanningWorkerFilesystem::getOrCreateFileSystemEntry(
StringRef Filename, bool DisableDirectivesScanning) {
if (const auto *Entry = findEntryByFilenameWithWriteThrough(Filename))
return scanForDirectivesIfNecessary(*Entry, Filename,
StringRef OriginalFilename, bool DisableDirectivesScanning) {
StringRef FilenameForLookup;
SmallString<256> PathBuf;
if (llvm::sys::path::is_absolute_gnu(OriginalFilename)) {
FilenameForLookup = OriginalFilename;
} else if (!WorkingDirForCacheLookup) {
return WorkingDirForCacheLookup.getError();
} else {
StringRef RelFilename = OriginalFilename;
RelFilename.consume_front("./");
PathBuf = *WorkingDirForCacheLookup;
llvm::sys::path::append(PathBuf, RelFilename);
FilenameForLookup = PathBuf.str();
}
assert(llvm::sys::path::is_absolute_gnu(FilenameForLookup));
if (const auto *Entry =
findEntryByFilenameWithWriteThrough(FilenameForLookup))
return scanForDirectivesIfNecessary(*Entry, OriginalFilename,
DisableDirectivesScanning)
.unwrapError();
auto MaybeEntry = computeAndStoreResult(Filename);
auto MaybeEntry = computeAndStoreResult(OriginalFilename, FilenameForLookup);
if (!MaybeEntry)
return MaybeEntry.getError();
return scanForDirectivesIfNecessary(*MaybeEntry, Filename,
return scanForDirectivesIfNecessary(*MaybeEntry, OriginalFilename,
DisableDirectivesScanning)
.unwrapError();
}
Expand Down Expand Up @@ -330,3 +358,24 @@ DependencyScanningWorkerFilesystem::openFileForRead(const Twine &Path) {
return Result.getError();
return DepScanFile::create(Result.get());
}

std::error_code DependencyScanningWorkerFilesystem::setCurrentWorkingDirectory(
const Twine &Path) {
std::error_code EC = ProxyFileSystem::setCurrentWorkingDirectory(Path);
updateWorkingDirForCacheLookup();
return EC;
}

void DependencyScanningWorkerFilesystem::updateWorkingDirForCacheLookup() {
llvm::ErrorOr<std::string> CWD =
getUnderlyingFS().getCurrentWorkingDirectory();
if (!CWD) {
WorkingDirForCacheLookup = CWD.getError();
} else if (!llvm::sys::path::is_absolute_gnu(*CWD)) {
WorkingDirForCacheLookup = llvm::errc::invalid_argument;
} else {
WorkingDirForCacheLookup = *CWD;
}
assert(!WorkingDirForCacheLookup ||
llvm::sys::path::is_absolute_gnu(*WorkingDirForCacheLookup));
}
38 changes: 38 additions & 0 deletions clang/test/ClangScanDeps/relative-filenames.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json

// RUN: clang-scan-deps -compilation-database %t/cdb.json -format make -j 1 > %t/result.txt
// RUN: FileCheck %s -input-file=%t/result.txt

// CHECK: {{/|\\}}dir1{{/|\\}}t1.c
// CHECK: {{/|\\}}dir1{{/|\\}}head.h
// CHECK: {{/|\\}}dir2{{/|\\}}t2.c
// CHECK: {{/|\\}}dir2{{/|\\}}head.h

//--- cdb.json.template
[
{
"directory": "DIR/dir1",
"command": "clang -fsyntax-only t1.c",
"file": "t1.c"
},
{
"directory": "DIR/dir2",
"command": "clang -fsyntax-only t2.c",
"file": "t2.c"
}
]

//--- dir1/t1.c
#include "head.h"

//--- dir1/head.h
#ifndef BBB
#define BBB
#endif

//--- dir2/t2.c
#include "head.h"

//--- dir2/head.h
4 changes: 2 additions & 2 deletions clang/test/CodeGen/coverage-profile-raw-version.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// RUN: %clang_cc1 -debug-info-kind=standalone -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -debug-info-kind=standalone -mllvm -debug-info-correlate -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -o - %s | FileCheck %s --check-prefix=DEBUG_INFO

// CHECK: @__llvm_profile_raw_version = {{.*}}constant i64 8
// DEBUG_INFO: @__llvm_profile_raw_version = {{.*}}constant i64 576460752303423496
// CHECK: @__llvm_profile_raw_version = {{.*}}constant i64 9
// DEBUG_INFO: @__llvm_profile_raw_version = {{.*}}constant i64 576460752303423497

int main() {
return 0;
Expand Down
6 changes: 6 additions & 0 deletions clang/test/Headers/riscv-sifive-header.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// RUN: %clang_cc1 -triple riscv64 -target-feature +v %s
// REQUIRES: riscv-registered-target

// expected-no-diagnostics

#include <sifive_vector.h>
Loading

0 comments on commit 22f84ba

Please sign in to comment.