Skip to content

Commit

Permalink
Merge branch 'amd-staging' of ssh://gerrit-git.amd.com:29418/lightnin…
Browse files Browse the repository at this point in the history
…g/ec/llvm-project into amd-staging
  • Loading branch information
searlmc1 committed May 2, 2024
2 parents fc06b37 + 59a2734 commit c013d6b
Show file tree
Hide file tree
Showing 225 changed files with 24,150 additions and 1,011 deletions.
3 changes: 2 additions & 1 deletion clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ Changes in existing checks

- Improved :doc:`misc-const-correctness
<clang-tidy/checks/misc/const-correctness>` check by avoiding infinite recursion
for recursive forwarding reference.
for recursive functions with forwarding reference parameters and reference
variables which refer to themselves.

- Improved :doc:`misc-definitions-in-headers
<clang-tidy/checks/misc/definitions-in-headers>` check by replacing the local
Expand Down
5 changes: 5 additions & 0 deletions clang/include/clang/Basic/DiagnosticParseKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -1438,13 +1438,18 @@ def err_omp_decl_in_declare_simd_variant : Error<
def err_omp_sink_and_source_iteration_not_allowd: Error<" '%0 %select{sink:|source:}1' must be with '%select{omp_cur_iteration - 1|omp_cur_iteration}1'">;
def err_omp_unknown_map_type : Error<
"incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'">;
def err_omp_more_one_map_type : Error<"map type is already specified">;
def note_previous_map_type_specified_here
: Note<"map type '%0' is previous specified here">;
def err_omp_unknown_map_type_modifier : Error<
"incorrect map type modifier, expected one of: 'always', 'close', 'mapper'"
"%select{|, 'present'|, 'present', 'iterator'}0%select{|, 'ompx_hold'}1">;
def err_omp_map_type_missing : Error<
"missing map type">;
def err_omp_map_type_modifier_missing : Error<
"missing map type modifier">;
def err_omp_map_modifier_specification_list : Error<
"empty modifier-specification-list is not allowed">;
def err_omp_declare_simd_inbranch_notinbranch : Error<
"unexpected '%0' clause, '%1' is specified already">;
def err_omp_expected_clause_argument
Expand Down
9 changes: 9 additions & 0 deletions clang/include/clang/Serialization/ASTWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ class StoredDeclsList;
class SwitchCase;
class Token;

namespace SrcMgr {
class FileInfo;
} // namespace SrcMgr

/// Writes an AST file containing the contents of a translation unit.
///
/// The ASTWriter class produces a bitstream containing the serialized
Expand Down Expand Up @@ -490,6 +494,11 @@ class ASTWriter : public ASTDeserializationListener,
/// during \c SourceManager serialization.
void computeNonAffectingInputFiles();

/// Some affecting files can be included from files that are not affecting.
/// This function erases source locations pointing into such files.
SourceLocation getAffectingIncludeLoc(const SourceManager &SourceMgr,
const SrcMgr::FileInfo &File);

/// Returns an adjusted \c FileID, accounting for any non-affecting input
/// files.
FileID getAdjustedFileID(FileID FID) const;
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/Analysis/ExprMutationAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,17 @@ const Stmt *ExprMutationAnalyzer::Analyzer::findMutationMemoized(
if (Memoized != MemoizedResults.end())
return Memoized->second;

// Assume Exp is not mutated before analyzing Exp.
MemoizedResults[Exp] = nullptr;
if (isUnevaluated(Exp))
return MemoizedResults[Exp] = nullptr;
return nullptr;

for (const auto &Finder : Finders) {
if (const Stmt *S = (this->*Finder)(Exp))
return MemoizedResults[Exp] = S;
}

return MemoizedResults[Exp] = nullptr;
return nullptr;
}

const Stmt *
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ add_clang_library(clangBasic
DEPENDS
omp_gen
ClangDriverOptions
# These generated headers are included transitively.
ARMTargetParserTableGen
AArch64TargetParserTableGen
)

target_link_libraries(clangBasic
Expand Down
27 changes: 27 additions & 0 deletions clang/lib/CodeGen/CGCUDANV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,33 @@ void CGNVCUDARuntime::emitDeviceStubBodyNew(CodeGenFunction &CGF,
CGM.CreateRuntimeFunction(FTy, LaunchKernelName);
CGF.EmitCall(FI, CGCallee::forDirect(cudaLaunchKernelFn), ReturnValueSlot(),
LaunchKernelArgs);

// To prevent CUDA device stub functions from being merged by ICF in MSVC
// environment, create an unique global variable for each kernel and write to
// the variable in the device stub.
if (CGM.getContext().getTargetInfo().getCXXABI().isMicrosoft() &&
!CGF.getLangOpts().HIP) {
llvm::Function *KernelFunction = llvm::cast<llvm::Function>(Kernel);
std::string GlobalVarName = (KernelFunction->getName() + ".id").str();

llvm::GlobalVariable *HandleVar =
CGM.getModule().getNamedGlobal(GlobalVarName);
if (!HandleVar) {
HandleVar = new llvm::GlobalVariable(
CGM.getModule(), CGM.Int8Ty,
/*Constant=*/false, KernelFunction->getLinkage(),
llvm::ConstantInt::get(CGM.Int8Ty, 0), GlobalVarName);
HandleVar->setDSOLocal(KernelFunction->isDSOLocal());
HandleVar->setVisibility(KernelFunction->getVisibility());
if (KernelFunction->hasComdat())
HandleVar->setComdat(CGM.getModule().getOrInsertComdat(GlobalVarName));
}

CGF.Builder.CreateAlignedStore(llvm::ConstantInt::get(CGM.Int8Ty, 1),
HandleVar, CharUnits::One(),
/*IsVolatile=*/true);
}

CGF.EmitBranch(EndBlock);

CGF.EmitBlock(EndBlock);
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/CodeGen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ add_clang_library(clangCodeGen
DEPENDS
intrinsics_gen
ClangDriverOptions
# These generated headers are included transitively.
ARMTargetParserTableGen
AArch64TargetParserTableGen

LINK_LIBS
clangAST
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ add_clang_library(clangDriver

DEPENDS
ClangDriverOptions
# These generated headers are included transitively.
ARMTargetParserTableGen
AArch64TargetParserTableGen

LINK_LIBS
clangBasic
Expand Down
19 changes: 17 additions & 2 deletions clang/lib/Headers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ set(llvm_libc_wrapper_files
llvm_libc_wrappers/time.h
)

set(zos_wrapper_files
zos_wrappers/builtins.h
)

include(GetClangResourceDir)
get_clang_resource_dir(output_dir PREFIX ${LLVM_LIBRARY_OUTPUT_INTDIR}/.. SUBDIR include)
set(out_files)
Expand Down Expand Up @@ -374,7 +378,7 @@ endfunction(clang_generate_header)

# Copy header files from the source directory to the build directory
foreach( f ${files} ${cuda_wrapper_files} ${cuda_wrapper_bits_files}
${ppc_wrapper_files} ${openmp_wrapper_files} ${hlsl_files}
${ppc_wrapper_files} ${openmp_wrapper_files} ${zos_wrapper_files} ${hlsl_files}
${llvm_libc_wrapper_files})
copy_header_to_output_dir(${CMAKE_CURRENT_SOURCE_DIR} ${f})
endforeach( f )
Expand Down Expand Up @@ -491,7 +495,7 @@ 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("systemz-resource-headers" "${systemz_files}")
add_header_target("systemz-resource-headers" "${systemz_files};${zos_wrapper_files}")
add_header_target("ve-resource-headers" "${ve_files}")
add_header_target("webassembly-resource-headers" "${webassembly_files}")
add_header_target("x86-resource-headers" "${x86_files}")
Expand Down Expand Up @@ -542,6 +546,11 @@ install(
DESTINATION ${header_install_dir}/openmp_wrappers
COMPONENT clang-resource-headers)

install(
FILES ${zos_wrapper_files}
DESTINATION ${header_install_dir}/zos_wrappers
COMPONENT clang-resource-headers)

#############################################################
# Install rules for separate header lists
install(
Expand Down Expand Up @@ -646,6 +655,12 @@ install(
EXCLUDE_FROM_ALL
COMPONENT systemz-resource-headers)

install(
FILES ${zos_wrapper_files}
DESTINATION ${header_install_dir}/zos_wrappers
EXCLUDE_FROM_ALL
COMPONENT systemz-resource-headers)

install(
FILES ${ve_files}
DESTINATION ${header_install_dir}
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Headers/builtins.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@
#ifndef __BUILTINS_H
#define __BUILTINS_H

#if defined(__MVS__) && __has_include_next(<builtins.h>)
#include_next <builtins.h>
#endif /* __MVS__ */
#endif /* __BUILTINS_H */
5 changes: 5 additions & 0 deletions clang/lib/Headers/float.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef __CLANG_FLOAT_H
#define __CLANG_FLOAT_H

#if defined(__MVS__) && __has_include_next(<float.h>)
#include_next <float.h>
#else

/* If we're on MinGW, fall back to the system's float.h, which might have
* additional definitions provided for Windows.
* For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx
Expand Down Expand Up @@ -165,4 +169,5 @@
# define FLT16_TRUE_MIN __FLT16_TRUE_MIN__
#endif /* __STDC_WANT_IEC_60559_TYPES_EXT__ */

#endif /* __MVS__ */
#endif /* __CLANG_FLOAT_H */
4 changes: 4 additions & 0 deletions clang/lib/Headers/inttypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#if !defined(_AIX) || !defined(_STD_TYPES_T)
#define __CLANG_INTTYPES_H
#endif
#if defined(__MVS__) && __has_include_next(<inttypes.h>)
#include_next <inttypes.h>
#else

#if defined(_MSC_VER) && _MSC_VER < 1800
#error MSVC does not have inttypes.h prior to Visual Studio 2013
Expand Down Expand Up @@ -94,4 +97,5 @@
#define SCNxFAST32 "x"
#endif

#endif /* __MVS__ */
#endif /* __CLANG_INTTYPES_H */
4 changes: 4 additions & 0 deletions clang/lib/Headers/iso646.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

#ifndef __ISO646_H
#define __ISO646_H
#if defined(__MVS__) && __has_include_next(<iso646.h>)
#include_next <iso646.h>
#else

#ifndef __cplusplus
#define and &&
Expand All @@ -24,4 +27,5 @@
#define xor_eq ^=
#endif

#endif /* __MVS__ */
#endif /* __ISO646_H */
5 changes: 5 additions & 0 deletions clang/lib/Headers/limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#ifndef __CLANG_LIMITS_H
#define __CLANG_LIMITS_H

#if defined(__MVS__) && __has_include_next(<limits.h>)
#include_next <limits.h>
#else

/* The system's limits.h may, in turn, try to #include_next GCC's limits.h.
Avert this #include_next madness. */
#if defined __GNUC__ && !defined _GCC_LIMITS_H_
Expand Down Expand Up @@ -122,4 +126,5 @@
#define ULONG_LONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
#endif

#endif /* __MVS__ */
#endif /* __CLANG_LIMITS_H */
5 changes: 5 additions & 0 deletions clang/lib/Headers/stdalign.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef __STDALIGN_H
#define __STDALIGN_H

#if defined(__MVS__) && __has_include_next(<stdalign.h>)
#include_next <stdalign.h>
#else

#if defined(__cplusplus) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ < 202311L)
#ifndef __cplusplus
Expand All @@ -21,4 +25,5 @@
#define __alignof_is_defined 1
#endif /* __STDC_VERSION__ */

#endif /* __MVS__ */
#endif /* __STDALIGN_H */
12 changes: 12 additions & 0 deletions clang/lib/Headers/stdarg.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
defined(__need_va_arg) || defined(__need___va_copy) || \
defined(__need_va_copy)

#if defined(__MVS__) && __has_include_next(<stdarg.h>)
#define __STDARG_H
#undef __need___va_list
#undef __need_va_list
#undef __need_va_arg
#undef __need___va_copy
#undef __need_va_copy
#include_next <stdarg.h>

#else
#if !defined(__need___va_list) && !defined(__need_va_list) && \
!defined(__need_va_arg) && !defined(__need___va_copy) && \
!defined(__need_va_copy)
Expand Down Expand Up @@ -76,4 +86,6 @@
#undef __need_va_copy
#endif /* defined(__need_va_copy) */

#endif /* __MVS__ */

#endif
5 changes: 5 additions & 0 deletions clang/lib/Headers/stdbool.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

#define __bool_true_false_are_defined 1

#if defined(__MVS__) && __has_include_next(<stdbool.h>)
#include_next <stdbool.h>
#else

#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L
/* FIXME: We should be issuing a deprecation warning here, but cannot yet due
* to system headers which include this header file unconditionally.
Expand All @@ -31,4 +35,5 @@
#endif
#endif

#endif /* __MVS__ */
#endif /* __STDBOOL_H */
17 changes: 17 additions & 0 deletions clang/lib/Headers/stddef.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@
defined(__need_unreachable) || defined(__need_max_align_t) || \
defined(__need_offsetof) || defined(__need_wint_t)

#if defined(__MVS__) && __has_include_next(<stddef.h>)
#define __STDDEF_H
#undef __need_ptrdiff_t
#undef __need_size_t
#undef __need_rsize_t
#undef __need_wchar_t
#undef __need_NULL
#undef __need_nullptr_t
#undef __need_unreachable
#undef __need_max_align_t
#undef __need_offsetof
#undef __need_wint_t
#include_next <stddef.h>

#else

#if !defined(__need_ptrdiff_t) && !defined(__need_size_t) && \
!defined(__need_rsize_t) && !defined(__need_wchar_t) && \
!defined(__need_NULL) && !defined(__need_nullptr_t) && \
Expand Down Expand Up @@ -120,4 +136,5 @@ __WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */
#undef __need_wint_t
#endif /* __need_wint_t */

#endif /* __MVS__ */
#endif
5 changes: 5 additions & 0 deletions clang/lib/Headers/stdint.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#define __CLANG_STDINT_H
#endif

#if defined(__MVS__) && __has_include_next(<stdint.h>)
#include_next <stdint.h>
#else

/* If we're hosted, fall back to the system's stdint.h, which might have
* additional definitions.
*/
Expand Down Expand Up @@ -947,4 +951,5 @@ typedef __UINTMAX_TYPE__ uintmax_t;
#endif

#endif /* __STDC_HOSTED__ */
#endif /* __MVS__ */
#endif /* __CLANG_STDINT_H */
6 changes: 6 additions & 0 deletions clang/lib/Headers/stdnoreturn.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@
#ifndef __STDNORETURN_H
#define __STDNORETURN_H

#if defined(__MVS__) && __has_include_next(<stdnoreturn.h>)
#include_next <stdnoreturn.h>
#else

#define noreturn _Noreturn
#define __noreturn_is_defined 1

#endif /* __MVS__ */

#if (defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L) && \
!defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS)
/* The noreturn macro is deprecated in C23. We do not mark it as such because
Expand Down
6 changes: 5 additions & 1 deletion clang/lib/Headers/varargs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@
*/
#ifndef __VARARGS_H
#define __VARARGS_H
#error "Please use <stdarg.h> instead of <varargs.h>"
#if defined(__MVS__) && __has_include_next(<varargs.h>)
#include_next <varargs.h>
#else
#error "Please use <stdarg.h> instead of <varargs.h>"
#endif /* __MVS__ */
#endif
Loading

0 comments on commit c013d6b

Please sign in to comment.