Skip to content

Commit 3d08764

Browse files
committed
merge main into amd-staging
Change-Id: I7523fb2e59417c86dff2840e78338e8315bc1f47
2 parents d7a876f + c6091cd commit 3d08764

File tree

104 files changed

+3880
-2215
lines changed

Some content is hidden

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

104 files changed

+3880
-2215
lines changed

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -548,20 +548,18 @@ class ASTWriter : public ASTDeserializationListener,
548548
void WriteSubStmt(Stmt *S);
549549

550550
void WriteBlockInfoBlock();
551-
void WriteControlBlock(Preprocessor &PP, ASTContext &Context,
552-
StringRef isysroot);
551+
void WriteControlBlock(Preprocessor &PP, StringRef isysroot);
553552

554553
/// Write out the signature and diagnostic options, and return the signature.
555-
void writeUnhashedControlBlock(Preprocessor &PP, ASTContext &Context);
554+
void writeUnhashedControlBlock(Preprocessor &PP);
556555
ASTFileSignature backpatchSignature();
557556

558557
/// Calculate hash of the pcm content.
559558
std::pair<ASTFileSignature, ASTFileSignature> createSignature() const;
560559
ASTFileSignature createSignatureForNamedModule() const;
561560

562561
void WriteInputFiles(SourceManager &SourceMgr, HeaderSearchOptions &HSOpts);
563-
void WriteSourceManagerBlock(SourceManager &SourceMgr,
564-
const Preprocessor &PP);
562+
void WriteSourceManagerBlock(SourceManager &SourceMgr);
565563
void WritePreprocessor(const Preprocessor &PP, bool IsModule);
566564
void WriteHeaderSearch(const HeaderSearch &HS);
567565
void WritePreprocessorDetail(PreprocessingRecord &PPRec,

clang/lib/AST/ByteCode/DynamicAllocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class DynamicAllocator final {
9797
private:
9898
llvm::DenseMap<const Expr *, AllocationSite> AllocationSites;
9999

100-
using PoolAllocTy = llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator>;
100+
using PoolAllocTy = llvm::BumpPtrAllocator;
101101
PoolAllocTy DescAllocator;
102102

103103
/// Allocates a new descriptor.

clang/lib/AST/ByteCode/Program.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class Program final {
171171
llvm::DenseMap<const void *, unsigned> NativePointerIndices;
172172

173173
/// Custom allocator for global storage.
174-
using PoolAllocTy = llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator>;
174+
using PoolAllocTy = llvm::BumpPtrAllocator;
175175

176176
/// Descriptor + storage for a global object.
177177
///

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,8 +1269,7 @@ ASTFileSignature ASTWriter::backpatchSignature() {
12691269
return Signature;
12701270
}
12711271

1272-
void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
1273-
ASTContext &Context) {
1272+
void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP) {
12741273
using namespace llvm;
12751274

12761275
// Flush first to prepare the PCM hash (signature).
@@ -1323,7 +1322,7 @@ void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
13231322
const auto &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts();
13241323

13251324
// Diagnostic options.
1326-
const auto &Diags = Context.getDiagnostics();
1325+
const auto &Diags = PP.getDiagnostics();
13271326
const DiagnosticOptions &DiagOpts = Diags.getDiagnosticOptions();
13281327
if (!HSOpts.ModulesSkipDiagnosticOptions) {
13291328
#define DIAGOPT(Name, Bits, Default) Record.push_back(DiagOpts.Name);
@@ -1403,10 +1402,12 @@ void ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
14031402
}
14041403

14051404
/// Write the control block.
1406-
void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
1407-
StringRef isysroot) {
1405+
void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
14081406
using namespace llvm;
14091407

1408+
SourceManager &SourceMgr = PP.getSourceManager();
1409+
FileManager &FileMgr = PP.getFileManager();
1410+
14101411
Stream.EnterSubblock(CONTROL_BLOCK_ID, 5);
14111412
RecordData Record;
14121413

@@ -1454,14 +1455,12 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
14541455
SmallString<128> BaseDir;
14551456
if (PP.getHeaderSearchInfo().getHeaderSearchOpts().ModuleFileHomeIsCwd) {
14561457
// Use the current working directory as the base path for all inputs.
1457-
auto CWD =
1458-
Context.getSourceManager().getFileManager().getOptionalDirectoryRef(
1459-
".");
1458+
auto CWD = FileMgr.getOptionalDirectoryRef(".");
14601459
BaseDir.assign(CWD->getName());
14611460
} else {
14621461
BaseDir.assign(WritingModule->Directory->getName());
14631462
}
1464-
cleanPathForOutput(Context.getSourceManager().getFileManager(), BaseDir);
1463+
cleanPathForOutput(FileMgr, BaseDir);
14651464

14661465
// If the home of the module is the current working directory, then we
14671466
// want to pick up the cwd of the build process loading the module, not
@@ -1554,7 +1553,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
15541553

15551554
// Language options.
15561555
Record.clear();
1557-
const LangOptions &LangOpts = Context.getLangOpts();
1556+
const LangOptions &LangOpts = PP.getLangOpts();
15581557
#define LANGOPT(Name, Bits, Default, Description) \
15591558
Record.push_back(LangOpts.Name);
15601559
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
@@ -1591,7 +1590,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
15911590

15921591
// Target options.
15931592
Record.clear();
1594-
const TargetInfo &Target = Context.getTargetInfo();
1593+
const TargetInfo &Target = PP.getTargetInfo();
15951594
const TargetOptions &TargetOpts = Target.getTargetOpts();
15961595
AddString(TargetOpts.Triple, Record);
15971596
AddString(TargetOpts.CPU, Record);
@@ -1609,8 +1608,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
16091608

16101609
// File system options.
16111610
Record.clear();
1612-
const FileSystemOptions &FSOpts =
1613-
Context.getSourceManager().getFileManager().getFileSystemOpts();
1611+
const FileSystemOptions &FSOpts = FileMgr.getFileSystemOpts();
16141612
AddString(FSOpts.WorkingDir, Record);
16151613
Stream.EmitRecord(FILE_SYSTEM_OPTIONS, Record);
16161614

@@ -1675,8 +1673,8 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
16751673
Stream.ExitBlock();
16761674

16771675
// Original file name and file ID
1678-
SourceManager &SM = Context.getSourceManager();
1679-
if (auto MainFile = SM.getFileEntryRefForID(SM.getMainFileID())) {
1676+
if (auto MainFile =
1677+
SourceMgr.getFileEntryRefForID(SourceMgr.getMainFileID())) {
16801678
auto FileAbbrev = std::make_shared<BitCodeAbbrev>();
16811679
FileAbbrev->Add(BitCodeAbbrevOp(ORIGINAL_FILE));
16821680
FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File ID
@@ -1685,16 +1683,15 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
16851683

16861684
Record.clear();
16871685
Record.push_back(ORIGINAL_FILE);
1688-
AddFileID(SM.getMainFileID(), Record);
1686+
AddFileID(SourceMgr.getMainFileID(), Record);
16891687
EmitRecordWithPath(FileAbbrevCode, Record, MainFile->getName());
16901688
}
16911689

16921690
Record.clear();
1693-
AddFileID(SM.getMainFileID(), Record);
1691+
AddFileID(SourceMgr.getMainFileID(), Record);
16941692
Stream.EmitRecord(ORIGINAL_FILE_ID, Record);
16951693

1696-
WriteInputFiles(Context.SourceMgr,
1697-
PP.getHeaderSearchInfo().getHeaderSearchOpts());
1694+
WriteInputFiles(SourceMgr, PP.getHeaderSearchInfo().getHeaderSearchOpts());
16981695
Stream.ExitBlock();
16991696
}
17001697

@@ -2234,8 +2231,7 @@ static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob,
22342231
/// entries for files that we actually need. In the common case (no
22352232
/// errors), we probably won't have to create file entries for any of
22362233
/// the files in the AST.
2237-
void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
2238-
const Preprocessor &PP) {
2234+
void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr) {
22392235
RecordData Record;
22402236

22412237
// Enter the source manager block.
@@ -2323,8 +2319,8 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
23232319
// We add one to the size so that we capture the trailing NULL
23242320
// that is required by llvm::MemoryBuffer::getMemBuffer (on
23252321
// the reader side).
2326-
std::optional<llvm::MemoryBufferRef> Buffer =
2327-
Content->getBufferOrNone(PP.getDiagnostics(), PP.getFileManager());
2322+
std::optional<llvm::MemoryBufferRef> Buffer = Content->getBufferOrNone(
2323+
SourceMgr.getDiagnostics(), SourceMgr.getFileManager());
23282324
StringRef Name = Buffer ? Buffer->getBufferIdentifier() : "";
23292325
Stream.EmitRecordWithBlob(SLocBufferAbbrv, Record,
23302326
StringRef(Name.data(), Name.size() + 1));
@@ -2334,8 +2330,8 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
23342330
if (EmitBlob) {
23352331
// Include the implicit terminating null character in the on-disk buffer
23362332
// if we're writing it uncompressed.
2337-
std::optional<llvm::MemoryBufferRef> Buffer =
2338-
Content->getBufferOrNone(PP.getDiagnostics(), PP.getFileManager());
2333+
std::optional<llvm::MemoryBufferRef> Buffer = Content->getBufferOrNone(
2334+
SourceMgr.getDiagnostics(), SourceMgr.getFileManager());
23392335
if (!Buffer)
23402336
Buffer = llvm::MemoryBufferRef("<<<INVALID BUFFER>>>", "");
23412337
StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
@@ -5371,7 +5367,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
53715367
// SourceLocations or FileIDs depends on it.
53725368
computeNonAffectingInputFiles();
53735369

5374-
writeUnhashedControlBlock(PP, Context);
5370+
writeUnhashedControlBlock(PP);
53755371

53765372
// Don't reuse type ID and Identifier ID from readers for C++ standard named
53775373
// modules since we want to support no-transitive-change model for named
@@ -5433,7 +5429,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
54335429
PrepareWritingSpecialDecls(SemaRef);
54345430

54355431
// Write the control block
5436-
WriteControlBlock(PP, Context, isysroot);
5432+
WriteControlBlock(PP, isysroot);
54375433

54385434
// Write the remaining AST contents.
54395435
Stream.FlushToWord();
@@ -5526,7 +5522,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
55265522
WriteDeclAndTypes(Context);
55275523

55285524
WriteFileDeclIDsMap();
5529-
WriteSourceManagerBlock(Context.getSourceManager(), PP);
5525+
WriteSourceManagerBlock(PP.getSourceManager());
55305526
WriteComments();
55315527
WritePreprocessor(PP, isModule);
55325528
WriteHeaderSearch(PP.getHeaderSearchInfo());

clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,9 @@ class DependencyScanningAction : public tooling::ToolAction {
335335

336336
ScanInstance.getFrontendOpts().GenerateGlobalModuleIndex = false;
337337
ScanInstance.getFrontendOpts().UseGlobalModuleIndex = false;
338-
ScanInstance.getFrontendOpts().ModulesShareFileManager = false;
338+
// This will prevent us compiling individual modules asynchronously since
339+
// FileManager is not thread-safe, but it does improve performance for now.
340+
ScanInstance.getFrontendOpts().ModulesShareFileManager = true;
339341
ScanInstance.getHeaderSearchOpts().ModuleFormat = "raw";
340342
ScanInstance.getHeaderSearchOpts().ModulesIncludeVFSUsage =
341343
any(OptimizeArgs & ScanningOptimizations::VFS);

compiler-rt/cmake/Modules/AddCompilerRT.cmake

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -680,15 +680,17 @@ macro(add_custom_libcxx name prefix)
680680

681681
ExternalProject_Add(${name}
682682
DEPENDS ${name}-clobber ${LIBCXX_DEPS}
683-
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/${name}
683+
PREFIX ${prefix}
684684
SOURCE_DIR ${LLVM_MAIN_SRC_DIR}/../runtimes
685-
BINARY_DIR ${prefix}
685+
BINARY_DIR ${prefix}/build
686686
CMAKE_ARGS ${CMAKE_PASSTHROUGH_VARIABLES}
687687
${compiler_args}
688688
${verbose}
689689
-DCMAKE_C_FLAGS=${LIBCXX_C_FLAGS}
690690
-DCMAKE_CXX_FLAGS=${LIBCXX_CXX_FLAGS}
691691
-DCMAKE_BUILD_TYPE=Release
692+
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
693+
-DCMAKE_INSTALL_MESSAGE=LAZY
692694
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
693695
-DLLVM_ENABLE_RUNTIMES=libcxx|libcxxabi
694696
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF
@@ -701,16 +703,17 @@ macro(add_custom_libcxx name prefix)
701703
-DLIBCXX_INCLUDE_BENCHMARKS=OFF
702704
-DLIBCXX_INCLUDE_TESTS=OFF
703705
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON
706+
-DLLVM_INCLUDE_TESTS=OFF
707+
-DLLVM_INCLUDE_DOCS=OFF
704708
${LIBCXX_CMAKE_ARGS}
705-
INSTALL_COMMAND ""
706-
STEP_TARGETS configure build
709+
STEP_TARGETS configure build install
707710
BUILD_ALWAYS 1
708711
USES_TERMINAL_CONFIGURE 1
709712
USES_TERMINAL_BUILD 1
710713
USES_TERMINAL_INSTALL 1
711714
LIST_SEPARATOR |
712715
EXCLUDE_FROM_ALL TRUE
713-
BUILD_BYPRODUCTS "${prefix}/lib/libc++.a" "${prefix}/lib/libc++abi.a"
716+
INSTALL_BYPRODUCTS "${prefix}/lib/libc++.a" "${prefix}/lib/libc++abi.a"
714717
)
715718

716719
if (CMAKE_GENERATOR MATCHES "Make")

compiler-rt/lib/fuzzer/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ if(OS_NAME MATCHES "Android|Linux|Fuchsia" AND
166166
-DLIBCXX_ABI_NAMESPACE=__Fuzzer
167167
-DLIBCXX_ENABLE_EXCEPTIONS=OFF)
168168
target_compile_options(RTfuzzer.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
169-
add_dependencies(RTfuzzer.${arch} libcxx_fuzzer_${arch}-build)
169+
add_dependencies(RTfuzzer.${arch} libcxx_fuzzer_${arch}-install)
170170
target_compile_options(RTfuzzer_main.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
171-
add_dependencies(RTfuzzer_main.${arch} libcxx_fuzzer_${arch}-build)
171+
add_dependencies(RTfuzzer_main.${arch} libcxx_fuzzer_${arch}-install)
172172
target_compile_options(RTfuzzer_interceptors.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
173-
add_dependencies(RTfuzzer_interceptors.${arch} libcxx_fuzzer_${arch}-build)
173+
add_dependencies(RTfuzzer_interceptors.${arch} libcxx_fuzzer_${arch}-install)
174174
partially_link_libcxx(fuzzer_no_main ${LIBCXX_${arch}_PREFIX} ${arch})
175175
partially_link_libcxx(fuzzer_interceptors ${LIBCXX_${arch}_PREFIX} ${arch})
176176
partially_link_libcxx(fuzzer ${LIBCXX_${arch}_PREFIX} ${arch})

compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,11 @@ size_t PageSize() {
239239
}
240240

241241
void SetThreadName(std::thread &thread, const std::string &name) {
242-
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
243-
defined(_GLIBCXX_GCC_GTHR_POSIX_H)
244-
(void)pthread_setname_np(thread.native_handle(), name.c_str());
245-
#else
242+
#ifndef __MINGW32__
243+
// Not setting the thread name in MinGW environments. MinGW C++ standard
244+
// libraries can either use native Windows threads or pthreads, so we
245+
// don't know with certainty what kind of thread handle we're getting
246+
// from thread.native_handle() here.
246247
typedef HRESULT(WINAPI * proc)(HANDLE, PCWSTR);
247248
HMODULE kbase = GetModuleHandleA("KernelBase.dll");
248249
proc ThreadNameProc = reinterpret_cast<proc>(

compiler-rt/lib/fuzzer/tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ if(COMPILER_RT_DEFAULT_TARGET_ARCH IN_LIST FUZZER_SUPPORTED_ARCH)
6464
COMPILER_RT_LIBCXX_PATH AND
6565
COMPILER_RT_LIBCXXABI_PATH)
6666
file(GLOB libfuzzer_headers ../*.h)
67-
set(LIBFUZZER_TEST_RUNTIME_DEPS libcxx_fuzzer_${arch}-build ${libfuzzer_headers})
67+
set(LIBFUZZER_TEST_RUNTIME_DEPS libcxx_fuzzer_${arch}-install ${libfuzzer_headers})
6868
set(LIBFUZZER_TEST_RUNTIME_CFLAGS -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
6969
set(LIBFUZZER_TEST_RUNTIME_LINK_FLAGS ${LIBCXX_${arch}_PREFIX}/lib/libc++.a)
7070
endif()

compiler-rt/lib/msan/tests/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ macro(msan_compile obj_list source arch kind cflags)
6969
sanitizer_test_compile(
7070
${obj_list} ${source} ${arch}
7171
KIND ${kind}
72-
COMPILE_DEPS ${MSAN_UNITTEST_HEADERS} libcxx_msan_${arch}-build
72+
COMPILE_DEPS ${MSAN_UNITTEST_HEADERS} libcxx_msan_${arch}-install
7373
DEPS msan
7474
CFLAGS -isystem ${MSAN_LIBCXX_DIR}/../include/c++/v1
7575
${MSAN_UNITTEST_INSTRUMENTED_CFLAGS} ${cflags}
@@ -117,10 +117,10 @@ macro(add_msan_tests_for_arch arch kind cflags)
117117
DEPS ${MSAN_INST_LOADABLE_OBJECTS})
118118

119119
set(MSAN_TEST_OBJECTS ${MSAN_INST_TEST_OBJECTS} ${MSAN_INST_GTEST})
120-
set(MSAN_TEST_DEPS ${MSAN_TEST_OBJECTS} libcxx_msan_${arch}-build
120+
set(MSAN_TEST_DEPS ${MSAN_TEST_OBJECTS} libcxx_msan_${arch}-install
121121
${MSAN_LOADABLE_SO}
122-
"${MSAN_LIBCXX_DIR}/libc++.a" "${MSAN_LIBCXX_DIR}/libc++abi.a")
123-
list(APPEND MSAN_TEST_DEPS msan libcxx_msan_${arch}-build)
122+
"${MSAN_LIBCXX_DIR}/libc++.a" "${MSAN_LIBCXX_DIR}/libc++abi.a")
123+
list(APPEND MSAN_TEST_DEPS msan libcxx_msan_${arch}-install)
124124
get_target_flags_for_arch(${arch} TARGET_LINK_FLAGS)
125125
add_compiler_rt_test(MsanUnitTests "Msan-${arch}${kind}-Test" ${arch}
126126
OBJECTS ${MSAN_TEST_OBJECTS} "${MSAN_LIBCXX_DIR}/libc++.a" "${MSAN_LIBCXX_DIR}/libc++abi.a"

compiler-rt/lib/tsan/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if(COMPILER_RT_LIBCXX_PATH AND
3131
DEPS ${TSAN_RUNTIME_LIBRARIES}
3232
CFLAGS ${TARGET_CFLAGS} -fsanitize=thread
3333
USE_TOOLCHAIN)
34-
list(APPEND libcxx_tsan_deps libcxx_tsan_${arch}-build)
34+
list(APPEND libcxx_tsan_deps libcxx_tsan_${arch}-install)
3535
endforeach()
3636

3737
add_custom_target(libcxx_tsan DEPENDS ${libcxx_tsan_deps})

flang/include/flang/Common/Fortran.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ static constexpr IgnoreTKRSet ignoreTKRAll{IgnoreTKR::Type, IgnoreTKR::Kind,
118118
std::string AsFortran(IgnoreTKRSet);
119119

120120
bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr>,
121-
std::optional<CUDADataAttr>, IgnoreTKRSet, bool allowUnifiedMatchingRule,
121+
std::optional<CUDADataAttr>, IgnoreTKRSet, std::optional<std::string> *,
122+
bool allowUnifiedMatchingRule,
122123
const LanguageFeatureControl *features = nullptr);
123124

124125
static constexpr char blankCommonObjectName[] = "__BLNK__";

flang/lib/Common/Fortran.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ std::string AsFortran(IgnoreTKRSet tkr) {
103103
/// dummy argument attribute while `y` represents the actual argument attribute.
104104
bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr> x,
105105
std::optional<CUDADataAttr> y, IgnoreTKRSet ignoreTKR,
106-
bool allowUnifiedMatchingRule, const LanguageFeatureControl *features) {
106+
std::optional<std::string> *warning, bool allowUnifiedMatchingRule,
107+
const LanguageFeatureControl *features) {
107108
bool isCudaManaged{features
108109
? features->IsEnabled(common::LanguageFeature::CudaManaged)
109110
: false};
@@ -134,8 +135,12 @@ bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr> x,
134135
} else {
135136
if (*x == CUDADataAttr::Device) {
136137
if ((y &&
137-
(*y == CUDADataAttr::Managed || *y == CUDADataAttr::Unified)) ||
138+
(*y == CUDADataAttr::Managed || *y == CUDADataAttr::Unified ||
139+
*y == CUDADataAttr::Shared)) ||
138140
(!y && (isCudaUnified || isCudaManaged))) {
141+
if (y && *y == CUDADataAttr::Shared && warning) {
142+
*warning = "SHARED attribute ignored"s;
143+
}
139144
return true;
140145
}
141146
} else if (*x == CUDADataAttr::Managed) {

flang/lib/Evaluate/characteristics.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ bool DummyDataObject::IsCompatibleWith(const DummyDataObject &actual,
371371
}
372372
if (!attrs.test(Attr::Value) &&
373373
!common::AreCompatibleCUDADataAttrs(cudaDataAttr, actual.cudaDataAttr,
374-
ignoreTKR,
374+
ignoreTKR, warning,
375375
/*allowUnifiedMatchingRule=*/false)) {
376376
if (whyNot) {
377377
*whyNot = "incompatible CUDA data attributes";
@@ -1771,7 +1771,7 @@ bool DistinguishUtils::Distinguishable(
17711771
x.intent != common::Intent::In) {
17721772
return true;
17731773
} else if (!common::AreCompatibleCUDADataAttrs(x.cudaDataAttr, y.cudaDataAttr,
1774-
x.ignoreTKR | y.ignoreTKR,
1774+
x.ignoreTKR | y.ignoreTKR, nullptr,
17751775
/*allowUnifiedMatchingRule=*/false)) {
17761776
return true;
17771777
} else if (features_.IsEnabled(

0 commit comments

Comments
 (0)