Skip to content

Commit 78d6846

Browse files
committed
Merge "merge main into amd-staging" into amd-staging
2 parents 20f7f9d + 1695464 commit 78d6846

File tree

306 files changed

+18299
-5627
lines changed

Some content is hidden

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

306 files changed

+18299
-5627
lines changed

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ foreach(target armv6m-none-eabi;armv7m-none-eabi;armv8m.main-none-eabi;armv8.1m.
333333
foreach(lang C;CXX;ASM)
334334
# TODO: The preprocessor defines workaround various issues in libc and libc++ integration.
335335
# These should be addressed and removed over time.
336-
set(RUNTIMES_${target}_CMAKE_${lang}_local_flags "--target=${target} -Wno-atomic-alignment \"-Dvfprintf(stream, format, vlist)=vprintf(format, vlist)\" \"-Dfprintf(stream, format, ...)=printf(format)\" \"-Dgettimeofday(tv, tz)\" -D_LIBCPP_PRINT=1")
336+
set(RUNTIMES_${target}_CMAKE_${lang}_local_flags "--target=${target} -Wno-atomic-alignment \"-Dvfprintf(stream, format, vlist)=vprintf(format, vlist)\" \"-Dfprintf(stream, format, ...)=printf(format)\" -D_LIBCPP_PRINT=1")
337337
if(NOT ${target} STREQUAL "aarch64-none-elf")
338338
set(RUNTIMES_${target}_CMAKE_${lang}_local_flags "${RUNTIMES_${target}_CMAKE_${lang}_local_flags} -mthumb")
339339
endif()
@@ -394,7 +394,7 @@ foreach(target riscv32-unknown-elf)
394394
foreach(lang C;CXX;ASM)
395395
# TODO: The preprocessor defines workaround various issues in libc and libc++ integration.
396396
# These should be addressed and removed over time.
397-
set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} -march=rv32imafc -mabi=ilp32f -Wno-atomic-alignment \"-Dvfprintf(stream, format, vlist)=vprintf(format, vlist)\" \"-Dfprintf(stream, format, ...)=printf(format)\" \"-Dgettimeofday(tv, tz)\" -D_LIBCPP_PRINT=1" CACHE STRING "")
397+
set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} -march=rv32imafc -mabi=ilp32f -Wno-atomic-alignment \"-Dvfprintf(stream, format, vlist)=vprintf(format, vlist)\" \"-Dfprintf(stream, format, ...)=printf(format)\" -D_LIBCPP_PRINT=1" CACHE STRING "")
398398
endforeach()
399399
foreach(type SHARED;MODULE;EXE)
400400
set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,10 @@ Sanitizers
12091209
<https://clang.llvm.org/docs/SanitizerSpecialCaseList.html>`_. See that link
12101210
for examples.
12111211

1212+
- Introduced an experimental Type Sanitizer, activated by using the
1213+
``-fsanitize=type`` flag. This sanitizer detects violations of C/C++ type-based
1214+
aliasing rules.
1215+
12121216
Python Binding Changes
12131217
----------------------
12141218
- Fixed an issue that led to crashes when calling ``Type.get_exception_specification_kind``.

clang/include/clang/Basic/Features.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ FEATURE(numerical_stability_sanitizer, LangOpts.Sanitize.has(SanitizerKind::Nume
102102
FEATURE(memory_sanitizer,
103103
LangOpts.Sanitize.hasOneOf(SanitizerKind::Memory |
104104
SanitizerKind::KernelMemory))
105+
FEATURE(type_sanitizer, LangOpts.Sanitize.has(SanitizerKind::Type))
105106
FEATURE(thread_sanitizer, LangOpts.Sanitize.has(SanitizerKind::Thread))
106107
FEATURE(dataflow_sanitizer, LangOpts.Sanitize.has(SanitizerKind::DataFlow))
107108
FEATURE(scudo, LangOpts.Sanitize.hasOneOf(SanitizerKind::Scudo))

clang/include/clang/Basic/Sanitizers.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ SANITIZER("fuzzer", Fuzzer)
7373
// libFuzzer-required instrumentation, no linking.
7474
SANITIZER("fuzzer-no-link", FuzzerNoLink)
7575

76+
// TypeSanitizer
77+
SANITIZER("type", Type)
78+
7679
// ThreadSanitizer
7780
SANITIZER("thread", Thread)
7881

clang/include/clang/Basic/arm_sme.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,11 @@ let SMETargetGuard = "sme-f8f32" in {
873873
[IsStreaming, IsInOutZA, SetsFPMR, IsOverloadNone], []>;
874874
def SVMLA_FP8_SINGLE_ZA32_VG4x4 : Inst<"svmla[_single]_za32[_mf8]_vg4x4_fpm", "vm4d>", "m", MergeNone, "aarch64_sme_fp8_fmlall_single_za32_vg4x4",
875875
[IsStreaming, IsInOutZA, SetsFPMR, IsOverloadNone], []>;
876+
// FMLALL (multiple)
877+
def SVMLA_FP8_MULTI_ZA32_VG4x2 : Inst<"svmla_za32[_mf8]_vg4x2_fpm", "vm22>", "m", MergeNone, "aarch64_sme_fp8_fmlall_multi_za32_vg4x2",
878+
[IsStreaming, IsInOutZA, SetsFPMR, IsOverloadNone], []>;
879+
def SVMLA_FP8_MULTI_ZA32_VG4x4 : Inst<"svmla_za32[_mf8]_vg4x4_fpm", "vm44>", "m", MergeNone, "aarch64_sme_fp8_fmlall_multi_za32_vg4x4",
880+
[IsStreaming, IsInOutZA, SetsFPMR, IsOverloadNone], []>;
876881
}
877882

878883
let SMETargetGuard = "sme-f8f16" in {
@@ -892,6 +897,11 @@ let SMETargetGuard = "sme-f8f16" in {
892897
[IsStreaming, IsInOutZA, SetsFPMR, IsOverloadNone], []>;
893898
def SVMLA_FP8_SINGLE_ZA16_VG2x4 : Inst<"svmla[_single]_za16[_mf8]_vg2x4_fpm", "vm4d>", "m", MergeNone, "aarch64_sme_fp8_fmlal_single_za16_vg2x4",
894899
[IsStreaming, IsInOutZA, SetsFPMR, IsOverloadNone], []>;
900+
// FMLAL (multiple)
901+
def SVMLA_FP8_MULTI_ZA16_VG2x2 : Inst<"svmla_za16[_mf8]_vg2x2_fpm", "vm22>", "m", MergeNone, "aarch64_sme_fp8_fmlal_multi_za16_vg2x2",
902+
[IsStreaming, IsInOutZA, SetsFPMR, IsOverloadNone], []>;
903+
def SVMLA_FP8_MULTI_ZA16_VG2x4 : Inst<"svmla_za16[_mf8]_vg2x4_fpm", "vm44>", "m", MergeNone, "aarch64_sme_fp8_fmlal_multi_za16_vg2x4",
904+
[IsStreaming, IsInOutZA, SetsFPMR, IsOverloadNone], []>;
895905
}
896906

897907
} // let SVETargetGuard = InvalidMode

clang/include/clang/Driver/Options.td

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3468,6 +3468,9 @@ defm diagnostics_show_line_numbers : BoolFOption<"diagnostics-show-line-numbers"
34683468
NegFlag<SetFalse, [], [ClangOption, CC1Option],
34693469
"Show line numbers in diagnostic code snippets">,
34703470
PosFlag<SetTrue>>;
3471+
def fno_realloc_lhs : Flag<["-"], "fno-realloc-lhs">, Group<f_Group>,
3472+
HelpText<"An allocatable left-hand side of an intrinsic assignment is assumed to be allocated and match the shape/type of the right-hand side">,
3473+
Visibility<[FlangOption, FC1Option]>;
34713474
def fno_stack_protector : Flag<["-"], "fno-stack-protector">, Group<f_Group>,
34723475
HelpText<"Disable the use of stack protectors">;
34733476
def fno_strict_aliasing : Flag<["-"], "fno-strict-aliasing">, Group<f_Group>,
@@ -4384,6 +4387,9 @@ defm stack_size_section : BoolFOption<"stack-size-section",
43844387
PosFlag<SetTrue, [], [ClangOption, CC1Option],
43854388
"Emit section containing metadata on function stack sizes">,
43864389
NegFlag<SetFalse>>;
4390+
def frealloc_lhs : Flag<["-"], "frealloc-lhs">, Group<f_Group>,
4391+
Visibility<[FlangOption, FC1Option]>,
4392+
HelpText<"If an allocatable left-hand side of an intrinsic assignment is unallocated or its shape/type does not match the right-hand side, then it is automatically (re)allocated">;
43874393
def fstack_usage : Flag<["-"], "fstack-usage">, Group<f_Group>,
43884394
HelpText<"Emit .su file containing information on function stack sizes">;
43894395
def stack_usage_file : Separate<["-"], "stack-usage-file">,
@@ -6894,7 +6900,6 @@ defm real_4_real_8 : BooleanFFlag<"real-4-real-8">, Group<gfortran_Group>;
68946900
defm real_8_real_10 : BooleanFFlag<"real-8-real-10">, Group<gfortran_Group>;
68956901
defm real_8_real_16 : BooleanFFlag<"real-8-real-16">, Group<gfortran_Group>;
68966902
defm real_8_real_4 : BooleanFFlag<"real-8-real-4">, Group<gfortran_Group>;
6897-
defm realloc_lhs : BooleanFFlag<"realloc-lhs">, Group<gfortran_Group>;
68986903
defm recursive : BooleanFFlag<"recursive">, Group<gfortran_Group>;
68996904
defm repack_arrays : BooleanFFlag<"repack-arrays">, Group<gfortran_Group>;
69006905
defm second_underscore : BooleanFFlag<"second-underscore">, Group<gfortran_Group>;

clang/include/clang/Driver/SanitizerArgs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class SanitizerArgs {
8787
bool needsHwasanAliasesRt() const {
8888
return needsHwasanRt() && HwasanUseAliases;
8989
}
90+
bool needsTysanRt() const { return Sanitizers.has(SanitizerKind::Type); }
9091
bool needsTsanRt() const { return Sanitizers.has(SanitizerKind::Thread); }
9192
bool needsMsanRt() const { return Sanitizers.has(SanitizerKind::Memory); }
9293
bool needsFuzzer() const { return Sanitizers.has(SanitizerKind::Fuzzer); }

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6483,14 +6483,6 @@ bool Compiler<Emitter>::emitBuiltinBitCast(const CastExpr *E) {
64836483
QualType ToType = E->getType();
64846484
std::optional<PrimType> ToT = classify(ToType);
64856485

6486-
// Bitcasting TO nullptr_t is always fine.
6487-
if (ToType->isNullPtrType()) {
6488-
if (!this->discard(SubExpr))
6489-
return false;
6490-
6491-
return this->emitNullPtr(0, nullptr, E);
6492-
}
6493-
64946486
assert(!ToType->isReferenceType());
64956487

64966488
// Prepare storage for the result in case we discard.
@@ -6523,8 +6515,8 @@ bool Compiler<Emitter>::emitBuiltinBitCast(const CastExpr *E) {
65236515
return false;
65246516
}
65256517

6526-
if (!ToT || ToT == PT_Ptr) {
6527-
if (!this->emitBitCastPtr(E))
6518+
if (!ToT) {
6519+
if (!this->emitBitCast(E))
65286520
return false;
65296521
return DiscardResult ? this->emitPopPtr(E) : true;
65306522
}
@@ -6540,8 +6532,8 @@ bool Compiler<Emitter>::emitBuiltinBitCast(const CastExpr *E) {
65406532
ToType->isSpecificBuiltinType(BuiltinType::Char_U));
65416533
uint32_t ResultBitWidth = std::max(Ctx.getBitWidth(ToType), 8u);
65426534

6543-
if (!this->emitBitCast(*ToT, ToTypeIsUChar || ToType->isStdByteType(),
6544-
ResultBitWidth, TargetSemantics, E))
6535+
if (!this->emitBitCastPrim(*ToT, ToTypeIsUChar || ToType->isStdByteType(),
6536+
ResultBitWidth, TargetSemantics, E))
65456537
return false;
65466538

65476539
if (DiscardResult)

clang/lib/AST/ByteCode/Interp.h

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3030,43 +3030,51 @@ bool CheckNewTypeMismatchArray(InterpState &S, CodePtr OpPC, const Expr *E) {
30303030
bool InvalidNewDeleteExpr(InterpState &S, CodePtr OpPC, const Expr *E);
30313031

30323032
template <PrimType Name, class T = typename PrimConv<Name>::T>
3033-
inline bool BitCast(InterpState &S, CodePtr OpPC, bool TargetIsUCharOrByte,
3034-
uint32_t ResultBitWidth, const llvm::fltSemantics *Sem) {
3033+
inline bool BitCastPrim(InterpState &S, CodePtr OpPC, bool TargetIsUCharOrByte,
3034+
uint32_t ResultBitWidth,
3035+
const llvm::fltSemantics *Sem) {
30353036
const Pointer &FromPtr = S.Stk.pop<Pointer>();
30363037

30373038
if (!CheckLoad(S, OpPC, FromPtr))
30383039
return false;
30393040

3040-
size_t BuffSize = ResultBitWidth / 8;
3041-
llvm::SmallVector<std::byte> Buff(BuffSize);
3042-
bool HasIndeterminateBits = false;
3041+
if constexpr (std::is_same_v<T, Pointer>) {
3042+
// The only pointer type we can validly bitcast to is nullptr_t.
3043+
S.Stk.push<Pointer>();
3044+
return true;
3045+
} else {
30433046

3044-
Bits FullBitWidth(ResultBitWidth);
3045-
Bits BitWidth = FullBitWidth;
3047+
size_t BuffSize = ResultBitWidth / 8;
3048+
llvm::SmallVector<std::byte> Buff(BuffSize);
3049+
bool HasIndeterminateBits = false;
30463050

3047-
if constexpr (std::is_same_v<T, Floating>) {
3048-
assert(Sem);
3049-
BitWidth = Bits(llvm::APFloatBase::getSizeInBits(*Sem));
3050-
}
3051+
Bits FullBitWidth(ResultBitWidth);
3052+
Bits BitWidth = FullBitWidth;
30513053

3052-
if (!DoBitCast(S, OpPC, FromPtr, Buff.data(), BitWidth, FullBitWidth,
3053-
HasIndeterminateBits))
3054-
return false;
3054+
if constexpr (std::is_same_v<T, Floating>) {
3055+
assert(Sem);
3056+
BitWidth = Bits(llvm::APFloatBase::getSizeInBits(*Sem));
3057+
}
30553058

3056-
if (!CheckBitCast(S, OpPC, HasIndeterminateBits, TargetIsUCharOrByte))
3057-
return false;
3059+
if (!DoBitCast(S, OpPC, FromPtr, Buff.data(), BitWidth, FullBitWidth,
3060+
HasIndeterminateBits))
3061+
return false;
30583062

3059-
if constexpr (std::is_same_v<T, Floating>) {
3060-
assert(Sem);
3061-
S.Stk.push<Floating>(T::bitcastFromMemory(Buff.data(), *Sem));
3062-
} else {
3063-
assert(!Sem);
3064-
S.Stk.push<T>(T::bitcastFromMemory(Buff.data(), ResultBitWidth));
3063+
if (!CheckBitCast(S, OpPC, HasIndeterminateBits, TargetIsUCharOrByte))
3064+
return false;
3065+
3066+
if constexpr (std::is_same_v<T, Floating>) {
3067+
assert(Sem);
3068+
S.Stk.push<Floating>(T::bitcastFromMemory(Buff.data(), *Sem));
3069+
} else {
3070+
assert(!Sem);
3071+
S.Stk.push<T>(T::bitcastFromMemory(Buff.data(), ResultBitWidth));
3072+
}
3073+
return true;
30653074
}
3066-
return true;
30673075
}
30683076

3069-
inline bool BitCastPtr(InterpState &S, CodePtr OpPC) {
3077+
inline bool BitCast(InterpState &S, CodePtr OpPC) {
30703078
const Pointer &FromPtr = S.Stk.pop<Pointer>();
30713079
Pointer &ToPtr = S.Stk.peek<Pointer>();
30723080

clang/lib/AST/ByteCode/Opcodes.td

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -839,13 +839,14 @@ def IsConstantContext: Opcode;
839839
def CheckAllocations : Opcode;
840840

841841
def BitCastTypeClass : TypeClass {
842-
let Types = [Uint8, Sint8, Uint16, Sint16, Uint32, Sint32, Uint64, Sint64, IntAP, IntAPS, Bool, Float];
842+
let Types = [Uint8, Sint8, Uint16, Sint16, Uint32, Sint32, Uint64, Sint64,
843+
IntAP, IntAPS, Bool, Float, Ptr];
843844
}
844845

845-
def BitCast : Opcode {
846+
def BitCastPrim : Opcode {
846847
let Types = [BitCastTypeClass];
847848
let Args = [ArgBool, ArgUint32, ArgFltSemantics];
848849
let HasGroup = 1;
849850
}
850851

851-
def BitCastPtr : Opcode;
852+
def BitCast : Opcode;

0 commit comments

Comments
 (0)