Skip to content

Commit

Permalink
Merge from 'main' to 'sycl-web' (35 commits)
Browse files Browse the repository at this point in the history
  CONFLICT (content): Merge conflict in llvm/docs/requirements-hashed.txt
  • Loading branch information
qichaogu committed Dec 18, 2024
2 parents bcecde7 + 7153a21 commit 9031d66
Show file tree
Hide file tree
Showing 336 changed files with 14,276 additions and 5,460 deletions.
26 changes: 4 additions & 22 deletions clang/lib/CodeGen/CGDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2031,28 +2031,10 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
// ThisPtr may be null if the member function has an explicit 'this'
// parameter.
if (!ThisPtr.isNull()) {
const CXXRecordDecl *RD = ThisPtr->getPointeeCXXRecordDecl();
if (isa<ClassTemplateSpecializationDecl>(RD)) {
// Create pointer type directly in this case.
const PointerType *ThisPtrTy = cast<PointerType>(ThisPtr);
uint64_t Size = CGM.getContext().getTypeSize(ThisPtrTy);
auto Align = getTypeAlignIfRequired(ThisPtrTy, CGM.getContext());
llvm::DIType *PointeeType =
getOrCreateType(ThisPtrTy->getPointeeType(), Unit);
llvm::DIType *ThisPtrType =
DBuilder.createPointerType(PointeeType, Size, Align);
TypeCache[ThisPtr.getAsOpaquePtr()].reset(ThisPtrType);
// TODO: This and the artificial type below are misleading, the
// types aren't artificial the argument is, but the current
// metadata doesn't represent that.
ThisPtrType = DBuilder.createObjectPointerType(ThisPtrType);
Elts.push_back(ThisPtrType);
} else {
llvm::DIType *ThisPtrType = getOrCreateType(ThisPtr, Unit);
TypeCache[ThisPtr.getAsOpaquePtr()].reset(ThisPtrType);
ThisPtrType = DBuilder.createObjectPointerType(ThisPtrType);
Elts.push_back(ThisPtrType);
}
llvm::DIType *ThisPtrType = getOrCreateType(ThisPtr, Unit);
TypeCache[ThisPtr.getAsOpaquePtr()].reset(ThisPtrType);
ThisPtrType = DBuilder.createObjectPointerType(ThisPtrType);
Elts.push_back(ThisPtrType);
}

// Copy rest of the arguments.
Expand Down
2 changes: 1 addition & 1 deletion clang/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)
COMPONENT compiler-rt)

# Add top-level targets that build specific compiler-rt runtimes.
set(COMPILER_RT_RUNTIMES fuzzer asan builtins dfsan lsan msan profile tsan ubsan ubsan-minimal)
set(COMPILER_RT_RUNTIMES fuzzer asan builtins dfsan lsan msan profile tsan tysan ubsan ubsan-minimal)
foreach(runtime ${COMPILER_RT_RUNTIMES})
get_ext_project_build_command(build_runtime_cmd ${runtime})
add_custom_target(${runtime}
Expand Down
8 changes: 8 additions & 0 deletions clang/test/Format/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import platform
import lit.formats

# Suffixes supported by clang-format.
config.suffixes = [
".c",
Expand All @@ -19,3 +22,8 @@ config.suffixes = [
".td",
".test"
]

# AIX 'diff' command doesn't support --strip-trailing-cr, but the internal
# python implementation does, so use that for cross platform compatibility
if platform.system() == "AIX":
config.test_format = lit.formats.ShTest()
1 change: 1 addition & 0 deletions compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ else()
set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64} ${S390X}
${LOONGARCH64} ${RISCV64})
endif()
set(ALL_TYSAN_SUPPORTED_ARCH ${X86_64} ${ARM64})
set(ALL_UBSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64}
${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
${LOONGARCH64})
Expand Down
15 changes: 14 additions & 1 deletion compiler-rt/cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ if(APPLE)
set(SANITIZER_COMMON_SUPPORTED_OS osx)
set(PROFILE_SUPPORTED_OS osx)
set(TSAN_SUPPORTED_OS osx)
set(TYSAN_SUPPORTED_OS osx)
set(XRAY_SUPPORTED_OS osx)
set(FUZZER_SUPPORTED_OS osx)
set(ORC_SUPPORTED_OS)
Expand Down Expand Up @@ -593,6 +594,7 @@ if(APPLE)
list(APPEND FUZZER_SUPPORTED_OS ${platform})
list(APPEND ORC_SUPPORTED_OS ${platform})
list(APPEND UBSAN_SUPPORTED_OS ${platform})
list(APPEND TYSAN_SUPPORTED_OS ${platform})
list(APPEND LSAN_SUPPORTED_OS ${platform})
list(APPEND STATS_SUPPORTED_OS ${platform})
endif()
Expand Down Expand Up @@ -651,6 +653,9 @@ if(APPLE)
list_intersect(CTX_PROFILE_SUPPORTED_ARCH
ALL_CTX_PROFILE_SUPPORTED_ARCH
SANITIZER_COMMON_SUPPORTED_ARCH)
list_intersect(TYSAN_SUPPORTED_ARCH
ALL_TYSAN_SUPPORTED_ARCH
SANITIZER_COMMON_SUPPORTED_ARCH)
list_intersect(TSAN_SUPPORTED_ARCH
ALL_TSAN_SUPPORTED_ARCH
SANITIZER_COMMON_SUPPORTED_ARCH)
Expand Down Expand Up @@ -703,6 +708,7 @@ else()
filter_available_targets(PROFILE_SUPPORTED_ARCH ${ALL_PROFILE_SUPPORTED_ARCH})
filter_available_targets(CTX_PROFILE_SUPPORTED_ARCH ${ALL_CTX_PROFILE_SUPPORTED_ARCH})
filter_available_targets(TSAN_SUPPORTED_ARCH ${ALL_TSAN_SUPPORTED_ARCH})
filter_available_targets(TYSAN_SUPPORTED_ARCH ${ALL_TYSAN_SUPPORTED_ARCH})
filter_available_targets(UBSAN_SUPPORTED_ARCH ${ALL_UBSAN_SUPPORTED_ARCH})
filter_available_targets(SAFESTACK_SUPPORTED_ARCH
${ALL_SAFESTACK_SUPPORTED_ARCH})
Expand Down Expand Up @@ -748,7 +754,7 @@ if(COMPILER_RT_SUPPORTED_ARCH)
endif()
message(STATUS "Compiler-RT supported architectures: ${COMPILER_RT_SUPPORTED_ARCH}")

set(ALL_SANITIZERS asan;rtsan;dfsan;msan;hwasan;tsan;safestack;cfi;scudo_standalone;ubsan_minimal;gwp_asan;nsan;asan_abi)
set(ALL_SANITIZERS asan;rtsan;dfsan;msan;hwasan;tsan;tysan;safestack;cfi;scudo_standalone;ubsan_minimal;gwp_asan;nsan;asan_abi)
set(COMPILER_RT_SANITIZERS_TO_BUILD all CACHE STRING
"sanitizers to build if supported on the target (all;${ALL_SANITIZERS})")
list_replace(COMPILER_RT_SANITIZERS_TO_BUILD all "${ALL_SANITIZERS}")
Expand Down Expand Up @@ -843,6 +849,13 @@ else()
set(COMPILER_RT_HAS_CTX_PROFILE FALSE)
endif()

if (COMPILER_RT_HAS_SANITIZER_COMMON AND TYSAN_SUPPORTED_ARCH AND
OS_NAME MATCHES "Linux|Darwin")
set(COMPILER_RT_HAS_TYSAN TRUE)
else()
set(COMPILER_RT_HAS_TYSAN FALSE)
endif()

if (COMPILER_RT_HAS_SANITIZER_COMMON AND TSAN_SUPPORTED_ARCH)
if (OS_NAME MATCHES "Linux|Darwin|FreeBSD|NetBSD")
set(COMPILER_RT_HAS_TSAN TRUE)
Expand Down
64 changes: 64 additions & 0 deletions compiler-rt/lib/tysan/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
include_directories(..)

# Runtime library sources and build flags.
set(TYSAN_SOURCES
tysan.cpp
tysan_interceptors.cpp)
set(TYSAN_COMMON_CFLAGS ${SANITIZER_COMMON_CFLAGS})
append_rtti_flag(OFF TYSAN_COMMON_CFLAGS)
# Prevent clang from generating libc calls.
append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding TYSAN_COMMON_CFLAGS)

add_compiler_rt_object_libraries(RTTysan_dynamic
OS ${SANITIZER_COMMON_SUPPORTED_OS}
ARCHS ${TYSAN_SUPPORTED_ARCH}
SOURCES ${TYSAN_SOURCES}
ADDITIONAL_HEADERS ${TYSAN_HEADERS}
CFLAGS ${TYSAN_DYNAMIC_CFLAGS}
DEFS ${TYSAN_DYNAMIC_DEFINITIONS})


# Static runtime library.
add_compiler_rt_component(tysan)


if(APPLE)
add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINK_FLAGS)

add_compiler_rt_runtime(clang_rt.tysan
SHARED
OS ${SANITIZER_COMMON_SUPPORTED_OS}
ARCHS ${TYSAN_SUPPORTED_ARCH}
OBJECT_LIBS RTTysan_dynamic
RTInterception
RTSanitizerCommon
RTSanitizerCommonLibc
RTSanitizerCommonSymbolizer
CFLAGS ${TYSAN_DYNAMIC_CFLAGS}
LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS}
DEFS ${TYSAN_DYNAMIC_DEFINITIONS}
PARENT_TARGET tysan)

add_compiler_rt_runtime(clang_rt.tysan_static
STATIC
ARCHS ${TYSAN_SUPPORTED_ARCH}
OBJECT_LIBS RTTysan_static
CFLAGS ${TYSAN_CFLAGS}
DEFS ${TYSAN_COMMON_DEFINITIONS}
PARENT_TARGET tysan)
else()
foreach(arch ${TYSAN_SUPPORTED_ARCH})
set(TYSAN_CFLAGS ${TYSAN_COMMON_CFLAGS})
append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE TYSAN_CFLAGS)
add_compiler_rt_runtime(clang_rt.tysan
STATIC
ARCHS ${arch}
SOURCES ${TYSAN_SOURCES}
$<TARGET_OBJECTS:RTInterception.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
CFLAGS ${TYSAN_CFLAGS}
PARENT_TARGET tysan)
endforeach()
endif()
35 changes: 35 additions & 0 deletions compiler-rt/lib/tysan/lit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- Python -*-

import os

# Setup config name.
config.name = 'TypeSanitizer' + getattr(config, 'name_suffix', 'default')

# Setup source root.
config.test_source_root = os.path.dirname(__file__)

# Setup default compiler flags used with -fsanitize=type option.
clang_tysan_cflags = (["-fsanitize=type",
"-mno-omit-leaf-frame-pointer",
"-fno-omit-frame-pointer",
"-fno-optimize-sibling-calls"] +
config.target_cflags +
config.debug_info_flags)
clang_tysan_cxxflags = config.cxx_mode_flags + clang_tysan_cflags

def build_invocation(compile_flags):
return " " + " ".join([config.clang] + compile_flags) + " "

config.substitutions.append( ("%clang_tysan ", build_invocation(clang_tysan_cflags)) )
config.substitutions.append( ("%clangxx_tysan ", build_invocation(clang_tysan_cxxflags)) )

# Default test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']

# TypeSanitizer tests are currently supported on Linux only.
if config.host_os not in ['Linux']:
config.unsupported = True

if config.target_arch != 'aarch64':
config.available_features.add('stable-runtime')

12 changes: 12 additions & 0 deletions compiler-rt/lib/tysan/lit.site.cfg.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@LIT_SITE_CFG_IN_HEADER@

# Tool-specific config options.
config.name_suffix = "@TYSAN_TEST_CONFIG_SUFFIX@"
config.target_cflags = "@TYSAN_TEST_TARGET_CFLAGS@"
config.target_arch = "@TYSAN_TEST_TARGET_ARCH@"

# Load common config for all compiler-rt lit tests.
lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")

# Load tool-specific config that would do the real work.
lit_config.load_config(config, "@TYSAN_LIT_SOURCE_DIR@/lit.cfg")
Loading

0 comments on commit 9031d66

Please sign in to comment.