[clang] [Driver] Make ELF -nopie specific to OpenBSD (PR #72578)
MaskRay wrote: > -nopie is for the linker. We only use -fno-pie for the compiler. OK. Then it seems that the driver option `-nopie` for linking should be removed even for OpenBSD? https://github.com/llvm/llvm-project/pull/72578 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Interp] Implement __builtin_classify_type (PR #71972)
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/71972 >From 2aedc41694c554900c87993f77cbc87ae6ed52ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Fri, 10 Nov 2023 19:33:21 +0100 Subject: [PATCH] [clang][Interp] Implement __builtin_classify_type --- clang/lib/AST/ExprConstShared.h | 58 clang/lib/AST/ExprConstant.cpp | 38 + clang/lib/AST/Interp/ByteCodeEmitter.cpp | 15 +++-- clang/lib/AST/Interp/ByteCodeExprGen.cpp | 10 ++-- clang/lib/AST/Interp/Function.cpp| 5 +- clang/lib/AST/Interp/Function.h | 5 +- clang/lib/AST/Interp/Interp.cpp | 3 + clang/lib/AST/Interp/InterpBuiltin.cpp | 21 +++ clang/test/Sema/builtin-classify-type.c | 1 + clang/test/SemaCXX/builtin-classify-type.cpp | 1 + 10 files changed, 111 insertions(+), 46 deletions(-) create mode 100644 clang/lib/AST/ExprConstShared.h diff --git a/clang/lib/AST/ExprConstShared.h b/clang/lib/AST/ExprConstShared.h new file mode 100644 index 000..53ec9c6c7a3ef2e --- /dev/null +++ b/clang/lib/AST/ExprConstShared.h @@ -0,0 +1,58 @@ +//===--- ExprConstShared.h - Shared consetxpr functionality *- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// Shared functionality between the new constant expression +// interpreter (AST/Interp/) and the current one (ExprConstant.cpp). +// +//===--===// + +#ifndef LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H +#define LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H + +namespace clang { +class QualType; +class LangOptions; +} // namespace clang +using namespace clang; +/// Values returned by __builtin_classify_type, chosen to match the values +/// produced by GCC's builtin. +enum class GCCTypeClass { + None = -1, + Void = 0, + Integer = 1, + // GCC reserves 2 for character types, but instead classifies them as + // integers. + Enum = 3, + Bool = 4, + Pointer = 5, + // GCC reserves 6 for references, but appears to never use it (because + // expressions never have reference type, presumably). + PointerToDataMember = 7, + RealFloat = 8, + Complex = 9, + // GCC reserves 10 for functions, but does not use it since GCC version 6 due + // to decay to pointer. (Prior to version 6 it was only used in C++ mode). + // GCC claims to reserve 11 for pointers to member functions, but *actually* + // uses 12 for that purpose, same as for a class or struct. Maybe it + // internally implements a pointer to member as a struct? Who knows. + PointerToMemberFunction = 12, // Not a bug, see above. + ClassOrStruct = 12, + Union = 13, + // GCC reserves 14 for arrays, but does not use it since GCC version 6 due to + // decay to pointer. (Prior to version 6 it was only used in C++ mode). + // GCC reserves 15 for strings, but actually uses 5 (pointer) for string + // literals. + // Lang = 16, + // OpaqueType = 17, + BitInt = 18 +}; + +GCCTypeClass EvaluateBuiltinClassifyType(QualType T, + const LangOptions ); + +#endif diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 4fb444e3b9f7e1b..3a41e9718bb5875 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -32,6 +32,7 @@ // //===--===// +#include "ExprConstShared.h" #include "Interp/Context.h" #include "Interp/Frame.h" #include "Interp/State.h" @@ -11492,43 +11493,10 @@ bool IntExprEvaluator::CheckReferencedDecl(const Expr* E, const Decl* D) { return false; } -/// Values returned by __builtin_classify_type, chosen to match the values -/// produced by GCC's builtin. -enum class GCCTypeClass { - None = -1, - Void = 0, - Integer = 1, - // GCC reserves 2 for character types, but instead classifies them as - // integers. - Enum = 3, - Bool = 4, - Pointer = 5, - // GCC reserves 6 for references, but appears to never use it (because - // expressions never have reference type, presumably). - PointerToDataMember = 7, - RealFloat = 8, - Complex = 9, - // GCC reserves 10 for functions, but does not use it since GCC version 6 due - // to decay to pointer. (Prior to version 6 it was only used in C++ mode). - // GCC claims to reserve 11 for pointers to member functions, but *actually* - // uses 12 for that purpose, same as for a class or struct. Maybe it - // internally implements a pointer to member as a struct? Who knows. - PointerToMemberFunction = 12, // Not a bug, see above. - ClassOrStruct = 12, - Union = 13, - // GCC reserves 14 for arrays, but does not use it since GCC
[clang] [clang] Add bitint classification for __builtin_classify_type (PR #72036)
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/72036 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ea31662 - [clang] Add bitint classification for __builtin_classify_type (#72036)
Author: Timm Baeder Date: 2023-11-17T08:31:25+01:00 New Revision: ea316625d1c984d63610a580b138c800115bfd86 URL: https://github.com/llvm/llvm-project/commit/ea316625d1c984d63610a580b138c800115bfd86 DIFF: https://github.com/llvm/llvm-project/commit/ea316625d1c984d63610a580b138c800115bfd86.diff LOG: [clang] Add bitint classification for __builtin_classify_type (#72036) See #71911 Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/AST/ExprConstant.cpp clang/test/Sema/builtin-classify-type.c clang/test/SemaCXX/builtin-classify-type.cpp Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 31ebe89fb0cafd6..739831ddfb3e49a 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -219,6 +219,8 @@ Non-comprehensive list of changes in this release determined at runtime. * The ``__datasizeof`` keyword has been added. It is similar to ``sizeof`` except that it returns the size of a type ignoring tail padding. +* ``__builtin_classify_type()`` now classifies ``_BitInt`` values as the return value ``18``, + to match GCC 14's behavior. New Compiler Flags -- diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 373972eb6cab11b..4fb444e3b9f7e1b 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -11520,6 +11520,9 @@ enum class GCCTypeClass { // decay to pointer. (Prior to version 6 it was only used in C++ mode). // GCC reserves 15 for strings, but actually uses 5 (pointer) for string // literals. + // Lang = 16, + // OpaqueType = 17, + BitInt = 18 }; /// EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way @@ -11652,11 +11655,13 @@ EvaluateBuiltinClassifyType(QualType T, const LangOptions ) { case Type::ObjCInterface: case Type::ObjCObjectPointer: case Type::Pipe: - case Type::BitInt: // GCC classifies vectors as None. We follow its lead and classify all // other types that don't fit into the regular classification the same way. return GCCTypeClass::None; + case Type::BitInt: +return GCCTypeClass::BitInt; + case Type::LValueReference: case Type::RValueReference: llvm_unreachable("invalid type for expression"); diff --git a/clang/test/Sema/builtin-classify-type.c b/clang/test/Sema/builtin-classify-type.c index a222ac8af0e32fd..9a4de34e823f231 100644 --- a/clang/test/Sema/builtin-classify-type.c +++ b/clang/test/Sema/builtin-classify-type.c @@ -11,7 +11,8 @@ enum gcc_type_class { function_type_class, method_type_class, record_type_class, union_type_class, array_type_class, string_type_class, - lang_type_class + lang_type_class, opaque_type_class, + bitint_type_class }; void foo(void) { @@ -45,6 +46,7 @@ void foo(void) { vint32_t3 vt5; typedef _BitInt(64) vint64_t3 __attribute__((vector_size(16))); vint64_t3 vt6; + _BitInt(16) bitint; _Atomic int atomic_i; _Atomic double atomic_d; @@ -70,6 +72,7 @@ void foo(void) { int a17[__builtin_classify_type(atomic_d) == real_type_class ? 1 : -1]; int a18[__builtin_classify_type(complex_i) == complex_type_class ? 1 : -1]; int a19[__builtin_classify_type(complex_d) == complex_type_class ? 1 : -1]; + int a20[__builtin_classify_type(bitint) == bitint_type_class ? 1 : -1]; } extern int (^p)(void); diff --git a/clang/test/SemaCXX/builtin-classify-type.cpp b/clang/test/SemaCXX/builtin-classify-type.cpp index ebc81425e401f11..ed5430960001002 100644 --- a/clang/test/SemaCXX/builtin-classify-type.cpp +++ b/clang/test/SemaCXX/builtin-classify-type.cpp @@ -11,7 +11,8 @@ enum gcc_type_class { function_type_class, method_type_class, record_type_class, union_type_class, array_type_class, string_type_class, - lang_type_class + lang_type_class, opaque_type_class, + bitint_type_class }; class cl { @@ -42,6 +43,7 @@ void foo() { _Atomic double atomic_d; _Complex int complex_i; _Complex double complex_d; + _BitInt(32) bitint; int a1[__builtin_classify_type(f()) == void_type_class ? 1 : -1]; int a2[__builtin_classify_type(i) == integer_type_class ? 1 : -1]; @@ -65,5 +67,6 @@ void foo() { int a20[__builtin_classify_type(atomic_d) == real_type_class ? 1 : -1]; int a21[__builtin_classify_type(complex_i) == complex_type_class ? 1 : -1]; int a22[__builtin_classify_type(complex_d) == complex_type_class ? 1 : -1]; + int a23[__builtin_classify_type(bitint) == bitint_type_class ? 1 : -1]; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Print static_assert values of arithmetic binary operators (PR #71671)
tbaederr wrote: Ping https://github.com/llvm/llvm-project/pull/71671 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Interp] Implement __builtin_bitreverse (PR #71687)
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/71687 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 3defe8f - [clang][Interp] Implement __builtin_bitreverse (#71687)
Author: Timm Baeder Date: 2023-11-17T08:29:13+01:00 New Revision: 3defe8facc55431c040f964802588473e2d4452b URL: https://github.com/llvm/llvm-project/commit/3defe8facc55431c040f964802588473e2d4452b DIFF: https://github.com/llvm/llvm-project/commit/3defe8facc55431c040f964802588473e2d4452b.diff LOG: [clang][Interp] Implement __builtin_bitreverse (#71687) Since the return value of this function is slightly more involved than the void/bool/int/size_t return values we've seen so far, also refactor this. Added: Modified: clang/lib/AST/Interp/InterpBuiltin.cpp clang/test/AST/Interp/builtin-functions.cpp Removed: diff --git a/clang/lib/AST/Interp/InterpBuiltin.cpp b/clang/lib/AST/Interp/InterpBuiltin.cpp index 8c5efe2df909b34..bb3e13599b01d4e 100644 --- a/clang/lib/AST/Interp/InterpBuiltin.cpp +++ b/clang/lib/AST/Interp/InterpBuiltin.cpp @@ -59,13 +59,54 @@ static void pushInt(InterpState , int32_t Val) { llvm_unreachable("Int isn't 16 or 32 bit?"); } -static bool retInt(InterpState , CodePtr OpPC, APValue ) { - PrimType IntType = getIntPrimType(S); - if (IntType == PT_Sint32) -return Ret(S, OpPC, Result); - else if (IntType == PT_Sint16) -return Ret(S, OpPC, Result); - llvm_unreachable("Int isn't 16 or 32 bit?"); +static void pushAPSInt(InterpState , const APSInt ) { + bool Signed = Val.isSigned(); + + if (Signed) { +switch (Val.getBitWidth()) { +case 64: + S.Stk.push>( + Integral<64, true>::from(Val.getSExtValue())); + break; +case 32: + S.Stk.push>( + Integral<32, true>::from(Val.getSExtValue())); + break; +case 16: + S.Stk.push>( + Integral<16, true>::from(Val.getSExtValue())); + break; +case 8: + S.Stk.push>( + Integral<8, true>::from(Val.getSExtValue())); + break; +default: + llvm_unreachable("Invalid integer bitwidth"); +} +return; + } + + // Unsigned. + switch (Val.getBitWidth()) { + case 64: +S.Stk.push>( +Integral<64, false>::from(Val.getZExtValue())); +break; + case 32: +S.Stk.push>( +Integral<32, false>::from(Val.getZExtValue())); +break; + case 16: +S.Stk.push>( +Integral<16, false>::from(Val.getZExtValue())); +break; + case 8: +S.Stk.push>( +Integral<8, false>::from(Val.getZExtValue())); +break; + default: +llvm_unreachable("Invalid integer bitwidth"); + } } static void pushSizeT(InterpState , uint64_t Val) { @@ -87,20 +128,29 @@ static void pushSizeT(InterpState , uint64_t Val) { } } -static bool retSizeT(InterpState , CodePtr OpPC, APValue ) { - const TargetInfo = S.getCtx().getTargetInfo(); - unsigned SizeTWidth = TI.getTypeWidth(TI.getSizeType()); - - switch (SizeTWidth) { - case 64: -return Ret(S, OpPC, Result); - case 32: -return Ret(S, OpPC, Result); - case 16: -return Ret(S, OpPC, Result); +static bool retPrimValue(InterpState , CodePtr OpPC, APValue , + std::optional ) { + if (!T) +return RetVoid(S, OpPC, Result); + +#define RET_CASE(X) \ + case X: \ +return Ret(S, OpPC, Result); + switch (*T) { +RET_CASE(PT_Float); +RET_CASE(PT_Bool); +RET_CASE(PT_Sint8); +RET_CASE(PT_Uint8); +RET_CASE(PT_Sint16); +RET_CASE(PT_Uint16); +RET_CASE(PT_Sint32); +RET_CASE(PT_Uint32); +RET_CASE(PT_Sint64); +RET_CASE(PT_Uint64); + default: +llvm_unreachable("Unsupported return type for builtin function"); } - - llvm_unreachable("size_t isn't 64 or 32 bit?"); +#undef RET_CASE } static bool interp__builtin_strcmp(InterpState , CodePtr OpPC, @@ -457,40 +507,55 @@ static bool interp__builtin_clrsb(InterpState , CodePtr OpPC, return true; } +static bool interp__builtin_bitreverse(InterpState , CodePtr OpPC, + const InterpFrame *Frame, + const Function *Func, + const CallExpr *Call) { + PrimType ArgT = *S.getContext().classify(Call->getArg(0)->getType()); + APSInt Val = peekToAPSInt(S.Stk, ArgT); + pushAPSInt(S, APSInt(Val.reverseBits(), /*IsUnsigned=*/true)); + return true; +} + bool InterpretBuiltin(InterpState , CodePtr OpPC, const Function *F, const CallExpr *Call) { InterpFrame *Frame = S.Current; APValue Dummy; + QualType ReturnType = Call->getCallReturnType(S.getCtx()); + std::optional ReturnT = S.getContext().classify(ReturnType); + // If classify failed, we assume void. + assert(ReturnT || ReturnType->isVoidType()); + switch (F->getBuiltinID()) { case Builtin::BI__builtin_is_constant_evaluated: S.Stk.push(Boolean::from(S.inConstantContext())); -return Ret(S, OpPC, Dummy); +
[clang] [mlir] [lld] [llvm] [flang] [ELF] Merge exportDynamic into versionId (PR #71272)
MaskRay wrote: Obsoleted by 255ea486085fca79d21eb0082594579abdbd89d0 (#72208). In Bazel, `linkopts` on a `cc_library` target is propagated to an executable. If a cc_library specifies `--version-script`, with this patch the executable will export certain symbols. Breaking GNU compatibility is probably not great and #72208 is superior. https://github.com/llvm/llvm-project/pull/71272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[mlir] [lld] [flang] [clang] [llvm] [ELF] Merge exportDynamic into versionId (PR #71272)
https://github.com/MaskRay closed https://github.com/llvm/llvm-project/pull/71272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Interp] Implement IntegralAP::{div, rem} (PR #72614)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/72614.diff 2 Files Affected: - (modified) clang/lib/AST/Interp/IntegralAP.h (+8-4) - (modified) clang/test/AST/Interp/intap.cpp (+18) ``diff diff --git a/clang/lib/AST/Interp/IntegralAP.h b/clang/lib/AST/Interp/IntegralAP.h index 9019f32e6cef2a3..17fc0695c98bb70 100644 --- a/clang/lib/AST/Interp/IntegralAP.h +++ b/clang/lib/AST/Interp/IntegralAP.h @@ -208,14 +208,18 @@ template class IntegralAP final { } static bool rem(IntegralAP A, IntegralAP B, unsigned OpBits, IntegralAP *R) { -// FIXME: Implement. -assert(false); +if constexpr (Signed) + *R = IntegralAP(A.V.srem(B.V)); +else + *R = IntegralAP(A.V.urem(B.V)); return false; } static bool div(IntegralAP A, IntegralAP B, unsigned OpBits, IntegralAP *R) { -// FIXME: Implement. -assert(false); +if constexpr (Signed) + *R = IntegralAP(A.V.sdiv(B.V)); +else + *R = IntegralAP(A.V.udiv(B.V)); return false; } diff --git a/clang/test/AST/Interp/intap.cpp b/clang/test/AST/Interp/intap.cpp index c93ec331296647b..30cff785fb34cf7 100644 --- a/clang/test/AST/Interp/intap.cpp +++ b/clang/test/AST/Interp/intap.cpp @@ -44,6 +44,24 @@ static_assert(MulA * MulB == 50, ""); // ref-error {{not an integral constant ex static_assert(MulA * 5 == 25, ""); static_assert(-1 * MulB == -7, ""); + +constexpr _BitInt(4) DivA = 2; +constexpr _BitInt(2) DivB = 1; +static_assert(DivA / DivB == 2, ""); + +constexpr _BitInt(4) DivC = DivA / 0; // ref-error {{must be initialized by a constant expression}} \ + // ref-note {{division by zero}} \ + // expected-error {{must be initialized by a constant expression}} \ + // expected-note {{division by zero}} + +constexpr _BitInt(7) RemA = 47; +constexpr _BitInt(6) RemB = 9; +static_assert(RemA % RemB == 2, ""); +static_assert(RemA % 0 == 1, ""); // ref-error {{not an integral constant expression}} \ + // ref-note {{division by zero}} \ + // expected-error {{not an integral constant expression}} \ + // expected-note {{division by zero}} + namespace APCast { constexpr _BitInt(10) A = 1; constexpr _BitInt(11) B = A; `` https://github.com/llvm/llvm-project/pull/72614 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Interp] Implement IntegralAP::{div, rem} (PR #72614)
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/72614 None >From 5fe32770c2c95cb8c7604983edc264f16edf5821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 16 Nov 2023 18:05:17 +0100 Subject: [PATCH] [clang][Interp] Implement IntegralAP::{div, rem} --- clang/lib/AST/Interp/IntegralAP.h | 12 clang/test/AST/Interp/intap.cpp | 18 ++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/clang/lib/AST/Interp/IntegralAP.h b/clang/lib/AST/Interp/IntegralAP.h index 9019f32e6cef2a3..17fc0695c98bb70 100644 --- a/clang/lib/AST/Interp/IntegralAP.h +++ b/clang/lib/AST/Interp/IntegralAP.h @@ -208,14 +208,18 @@ template class IntegralAP final { } static bool rem(IntegralAP A, IntegralAP B, unsigned OpBits, IntegralAP *R) { -// FIXME: Implement. -assert(false); +if constexpr (Signed) + *R = IntegralAP(A.V.srem(B.V)); +else + *R = IntegralAP(A.V.urem(B.V)); return false; } static bool div(IntegralAP A, IntegralAP B, unsigned OpBits, IntegralAP *R) { -// FIXME: Implement. -assert(false); +if constexpr (Signed) + *R = IntegralAP(A.V.sdiv(B.V)); +else + *R = IntegralAP(A.V.udiv(B.V)); return false; } diff --git a/clang/test/AST/Interp/intap.cpp b/clang/test/AST/Interp/intap.cpp index c93ec331296647b..30cff785fb34cf7 100644 --- a/clang/test/AST/Interp/intap.cpp +++ b/clang/test/AST/Interp/intap.cpp @@ -44,6 +44,24 @@ static_assert(MulA * MulB == 50, ""); // ref-error {{not an integral constant ex static_assert(MulA * 5 == 25, ""); static_assert(-1 * MulB == -7, ""); + +constexpr _BitInt(4) DivA = 2; +constexpr _BitInt(2) DivB = 1; +static_assert(DivA / DivB == 2, ""); + +constexpr _BitInt(4) DivC = DivA / 0; // ref-error {{must be initialized by a constant expression}} \ + // ref-note {{division by zero}} \ + // expected-error {{must be initialized by a constant expression}} \ + // expected-note {{division by zero}} + +constexpr _BitInt(7) RemA = 47; +constexpr _BitInt(6) RemB = 9; +static_assert(RemA % RemB == 2, ""); +static_assert(RemA % 0 == 1, ""); // ref-error {{not an integral constant expression}} \ + // ref-note {{division by zero}} \ + // expected-error {{not an integral constant expression}} \ + // expected-note {{division by zero}} + namespace APCast { constexpr _BitInt(10) A = 1; constexpr _BitInt(11) B = A; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 894a387 - [clang][Interp][NFC] Properly implement IntegralAP::from(IntegralAP)
Author: Timm Bäder Date: 2023-11-17T08:04:30+01:00 New Revision: 894a38753e8c4cfef7a1dae17a76b405208b2708 URL: https://github.com/llvm/llvm-project/commit/894a38753e8c4cfef7a1dae17a76b405208b2708 DIFF: https://github.com/llvm/llvm-project/commit/894a38753e8c4cfef7a1dae17a76b405208b2708.diff LOG: [clang][Interp][NFC] Properly implement IntegralAP::from(IntegralAP) This used to just pass on the given parameter, but we need to respect the given bit width. Added: Modified: clang/lib/AST/Interp/IntegralAP.h Removed: diff --git a/clang/lib/AST/Interp/IntegralAP.h b/clang/lib/AST/Interp/IntegralAP.h index bd665959cf3dcc4..9019f32e6cef2a3 100644 --- a/clang/lib/AST/Interp/IntegralAP.h +++ b/clang/lib/AST/Interp/IntegralAP.h @@ -102,7 +102,12 @@ template class IntegralAP final { template static IntegralAP from(IntegralAP V, unsigned NumBits = 0) { -return IntegralAP(V.V); +if (NumBits == 0) + NumBits = V.bitWidth(); + +if constexpr (InputSigned) + return IntegralAP(V.V.sextOrTrunc(NumBits)); +return IntegralAP(V.V.zextOrTrunc(NumBits)); } template ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PowerPC] Disable float128 on AIX in Clang (PR #67298)
https://github.com/bzEq approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/67298 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] [libunwind] [openmp] [flang] [lld] [libc] [mlir] [llvm] [lldb] [libcxx] [clang] [compiler-rt] Fix Logical expression used for merged conditional if in FlattenCFG pass (PR #72522)
@@ -450,9 +450,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> ) { if (!CompareIfRegionBlock(IfTrue1, IfTrue2, SecondEntryBlock)) return false; } else if (IfTrue1 == FirstEntryBlock) { -// The then-path is empty, so we must use "and" operation to combine the +// The else-path is empty, so we must use "or" operation to combine the // conditions. -CombineOp = BinaryOperator::And; +CombineOp = BinaryOperator::Or; arsenm wrote: The existing tests should not have the inputs changed. You should add new tests https://github.com/llvm/llvm-project/pull/72522 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Reapply Handle templated operators with reversed arguments (PR #72213)
shafik wrote: So currently implementations differ here: https://godbolt.org/z/11331KW6e This feels related to [cwg2804](https://wg21.link/cwg2804) which is not live yet but can be found [here](https://cplusplus.github.io/CWG/issues/2804.html). I can find the discussion on this from Kona but we ended up sending this to EWG b/c it was not clear what the right fixes for all the related issues are and we wanted design feedback. CC @zygoloid @AaronBallman https://github.com/llvm/llvm-project/pull/72213 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [libcxx] [clang] [compiler-rt] fix python SyntaxWarnings in check-all output (PR #72538)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/72538 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lld] [libunwind] [openmp] [libcxx] [llvm] [clang] [libc] [lldb] [compiler-rt] [flang] [mlir] [libcxxabi] Fix Logical expression used for merged conditional if in FlattenCFG pass (PR #72522)
https://github.com/mahtohappy updated https://github.com/llvm/llvm-project/pull/72522 >From ce4f4fc02e25359c8f38ff9ecf2a2d82aa90df72 Mon Sep 17 00:00:00 2001 From: mahtohappy Date: Thu, 16 Nov 2023 06:53:24 -0800 Subject: [PATCH 1/3] Fix Logical expression used for merged conditional if --- llvm/lib/Transforms/Utils/FlattenCFG.cpp | 8 llvm/test/Transforms/Util/flattencfg.ll | 22 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/llvm/lib/Transforms/Utils/FlattenCFG.cpp b/llvm/lib/Transforms/Utils/FlattenCFG.cpp index 1925b91c4da7ec1..5f8cd12c1d50856 100644 --- a/llvm/lib/Transforms/Utils/FlattenCFG.cpp +++ b/llvm/lib/Transforms/Utils/FlattenCFG.cpp @@ -436,9 +436,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> ) { bool InvertCond2 = false; BinaryOperator::BinaryOps CombineOp; if (IfFalse1 == FirstEntryBlock) { -// The else-path is empty, so we must use "or" operation to combine the +// The then-path is empty, so we must use "and" operation to combine the // conditions. -CombineOp = BinaryOperator::Or; +CombineOp = BinaryOperator::And; if (IfFalse2 != SecondEntryBlock) { if (IfTrue2 != SecondEntryBlock) return false; @@ -450,9 +450,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> ) { if (!CompareIfRegionBlock(IfTrue1, IfTrue2, SecondEntryBlock)) return false; } else if (IfTrue1 == FirstEntryBlock) { -// The then-path is empty, so we must use "and" operation to combine the +// The else-path is empty, so we must use "or" operation to combine the // conditions. -CombineOp = BinaryOperator::And; +CombineOp = BinaryOperator::Or; if (IfTrue2 != SecondEntryBlock) { if (IfFalse2 != SecondEntryBlock) return false; diff --git a/llvm/test/Transforms/Util/flattencfg.ll b/llvm/test/Transforms/Util/flattencfg.ll index 4a4d4279f360d6a..0fd285be2715b80 100644 --- a/llvm/test/Transforms/Util/flattencfg.ll +++ b/llvm/test/Transforms/Util/flattencfg.ll @@ -10,12 +10,12 @@ define void @test_not_crash(i32 %in_a) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[CMP0:%.*]] = icmp eq i32 [[IN_A]], -1 ; CHECK-NEXT:[[CMP1:%.*]] = icmp ne i32 [[IN_A]], 0 -; CHECK-NEXT:[[COND0:%.*]] = and i1 [[CMP0]], [[CMP1]] +; CHECK-NEXT:[[COND0:%.*]] = or i1 [[CMP0]], [[CMP1]] ; CHECK-NEXT:br i1 [[COND0]], label [[B0:%.*]], label [[B1:%.*]] ; CHECK: b0: ; CHECK-NEXT:[[CMP2:%.*]] = icmp eq i32 [[IN_A]], 0 ; CHECK-NEXT:[[CMP3:%.*]] = icmp ne i32 [[IN_A]], 1 -; CHECK-NEXT:[[COND1:%.*]] = or i1 [[CMP2]], [[CMP3]] +; CHECK-NEXT:[[COND1:%.*]] = and i1 [[CMP2]], [[CMP3]] ; CHECK-NEXT:br i1 [[COND1]], label [[EXIT:%.*]], label [[B1]] ; CHECK: b1: ; CHECK-NEXT:br label [[EXIT]] @@ -25,13 +25,13 @@ define void @test_not_crash(i32 %in_a) #0 { entry: %cmp0 = icmp eq i32 %in_a, -1 %cmp1 = icmp ne i32 %in_a, 0 - %cond0 = and i1 %cmp0, %cmp1 + %cond0 = or i1 %cmp0, %cmp1 br i1 %cond0, label %b0, label %b1 b0:; preds = %entry %cmp2 = icmp eq i32 %in_a, 0 %cmp3 = icmp ne i32 %in_a, 1 - %cond1 = or i1 %cmp2, %cmp3 + %cond1 = and i1 %cmp2, %cmp3 br i1 %cond1, label %exit, label %b1 b1: ; preds = %entry, %b0 @@ -47,7 +47,7 @@ define void @test_not_crash2(float %a, float %b) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[TMP0:%.*]] = fcmp ult float [[A]], 1.00e+00 ; CHECK-NEXT:[[TMP1:%.*]] = fcmp ult float [[B]], 1.00e+00 -; CHECK-NEXT:[[TMP2:%.*]] = and i1 [[TMP0]], [[TMP1]] +; CHECK-NEXT:[[TMP2:%.*]] = or i1 [[TMP0]], [[TMP1]] ; CHECK-NEXT:br i1 [[TMP2]], label [[BB4:%.*]], label [[BB3:%.*]] ; CHECK: bb3: ; CHECK-NEXT:br label [[BB4]] @@ -78,7 +78,7 @@ define void @test_not_crash3(i32 %a) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[A_EQ_0:%.*]] = icmp eq i32 [[A]], 0 ; CHECK-NEXT:[[A_EQ_1:%.*]] = icmp eq i32 [[A]], 1 -; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[A_EQ_0]], [[A_EQ_1]] +; CHECK-NEXT:[[TMP0:%.*]] = and i1 [[A_EQ_0]], [[A_EQ_1]] ; CHECK-NEXT:br i1 [[TMP0]], label [[BB2:%.*]], label [[BB3:%.*]] ; CHECK: bb2: ; CHECK-NEXT:br label [[BB3]] @@ -114,7 +114,7 @@ define void @test_then(i32 %x, i32 %y, i32 %z) { ; CHECK-NEXT: entry.x: ; CHECK-NEXT:[[CMP_X:%.*]] = icmp ne i32 [[X]], 0 ; CHECK-NEXT:[[CMP_Y:%.*]] = icmp ne i32 [[Y]], 0 -; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[CMP_X]], [[CMP_Y]] +; CHECK-NEXT:[[TMP0:%.*]] = and i1 [[CMP_X]], [[CMP_Y]] ; CHECK-NEXT:br i1 [[TMP0]], label [[IF_THEN_Y:%.*]], label [[EXIT:%.*]] ; CHECK: if.then.y: ; CHECK-NEXT:store i32 [[Z]], ptr @g, align 4 @@ -148,7 +148,7 @@ define void @test_else(i32 %x, i32 %y, i32 %z) { ; CHECK-NEXT: entry.x: ; CHECK-NEXT:[[CMP_X:%.*]] = icmp eq i32 [[X]], 0 ; CHECK-NEXT:[[CMP_Y:%.*]] = icmp eq i32 [[Y]], 0 -; CHECK-NEXT:
[lld] [libunwind] [openmp] [libcxx] [llvm] [clang] [libc] [lldb] [compiler-rt] [flang] [mlir] [libcxxabi] Fix Logical expression used for merged conditional if in FlattenCFG pass (PR #72522)
https://github.com/mahtohappy updated https://github.com/llvm/llvm-project/pull/72522 >From ce4f4fc02e25359c8f38ff9ecf2a2d82aa90df72 Mon Sep 17 00:00:00 2001 From: mahtohappy Date: Thu, 16 Nov 2023 06:53:24 -0800 Subject: [PATCH 1/2] Fix Logical expression used for merged conditional if --- llvm/lib/Transforms/Utils/FlattenCFG.cpp | 8 llvm/test/Transforms/Util/flattencfg.ll | 22 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/llvm/lib/Transforms/Utils/FlattenCFG.cpp b/llvm/lib/Transforms/Utils/FlattenCFG.cpp index 1925b91c4da7ec1..5f8cd12c1d50856 100644 --- a/llvm/lib/Transforms/Utils/FlattenCFG.cpp +++ b/llvm/lib/Transforms/Utils/FlattenCFG.cpp @@ -436,9 +436,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> ) { bool InvertCond2 = false; BinaryOperator::BinaryOps CombineOp; if (IfFalse1 == FirstEntryBlock) { -// The else-path is empty, so we must use "or" operation to combine the +// The then-path is empty, so we must use "and" operation to combine the // conditions. -CombineOp = BinaryOperator::Or; +CombineOp = BinaryOperator::And; if (IfFalse2 != SecondEntryBlock) { if (IfTrue2 != SecondEntryBlock) return false; @@ -450,9 +450,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> ) { if (!CompareIfRegionBlock(IfTrue1, IfTrue2, SecondEntryBlock)) return false; } else if (IfTrue1 == FirstEntryBlock) { -// The then-path is empty, so we must use "and" operation to combine the +// The else-path is empty, so we must use "or" operation to combine the // conditions. -CombineOp = BinaryOperator::And; +CombineOp = BinaryOperator::Or; if (IfTrue2 != SecondEntryBlock) { if (IfFalse2 != SecondEntryBlock) return false; diff --git a/llvm/test/Transforms/Util/flattencfg.ll b/llvm/test/Transforms/Util/flattencfg.ll index 4a4d4279f360d6a..0fd285be2715b80 100644 --- a/llvm/test/Transforms/Util/flattencfg.ll +++ b/llvm/test/Transforms/Util/flattencfg.ll @@ -10,12 +10,12 @@ define void @test_not_crash(i32 %in_a) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[CMP0:%.*]] = icmp eq i32 [[IN_A]], -1 ; CHECK-NEXT:[[CMP1:%.*]] = icmp ne i32 [[IN_A]], 0 -; CHECK-NEXT:[[COND0:%.*]] = and i1 [[CMP0]], [[CMP1]] +; CHECK-NEXT:[[COND0:%.*]] = or i1 [[CMP0]], [[CMP1]] ; CHECK-NEXT:br i1 [[COND0]], label [[B0:%.*]], label [[B1:%.*]] ; CHECK: b0: ; CHECK-NEXT:[[CMP2:%.*]] = icmp eq i32 [[IN_A]], 0 ; CHECK-NEXT:[[CMP3:%.*]] = icmp ne i32 [[IN_A]], 1 -; CHECK-NEXT:[[COND1:%.*]] = or i1 [[CMP2]], [[CMP3]] +; CHECK-NEXT:[[COND1:%.*]] = and i1 [[CMP2]], [[CMP3]] ; CHECK-NEXT:br i1 [[COND1]], label [[EXIT:%.*]], label [[B1]] ; CHECK: b1: ; CHECK-NEXT:br label [[EXIT]] @@ -25,13 +25,13 @@ define void @test_not_crash(i32 %in_a) #0 { entry: %cmp0 = icmp eq i32 %in_a, -1 %cmp1 = icmp ne i32 %in_a, 0 - %cond0 = and i1 %cmp0, %cmp1 + %cond0 = or i1 %cmp0, %cmp1 br i1 %cond0, label %b0, label %b1 b0:; preds = %entry %cmp2 = icmp eq i32 %in_a, 0 %cmp3 = icmp ne i32 %in_a, 1 - %cond1 = or i1 %cmp2, %cmp3 + %cond1 = and i1 %cmp2, %cmp3 br i1 %cond1, label %exit, label %b1 b1: ; preds = %entry, %b0 @@ -47,7 +47,7 @@ define void @test_not_crash2(float %a, float %b) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[TMP0:%.*]] = fcmp ult float [[A]], 1.00e+00 ; CHECK-NEXT:[[TMP1:%.*]] = fcmp ult float [[B]], 1.00e+00 -; CHECK-NEXT:[[TMP2:%.*]] = and i1 [[TMP0]], [[TMP1]] +; CHECK-NEXT:[[TMP2:%.*]] = or i1 [[TMP0]], [[TMP1]] ; CHECK-NEXT:br i1 [[TMP2]], label [[BB4:%.*]], label [[BB3:%.*]] ; CHECK: bb3: ; CHECK-NEXT:br label [[BB4]] @@ -78,7 +78,7 @@ define void @test_not_crash3(i32 %a) #0 { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[A_EQ_0:%.*]] = icmp eq i32 [[A]], 0 ; CHECK-NEXT:[[A_EQ_1:%.*]] = icmp eq i32 [[A]], 1 -; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[A_EQ_0]], [[A_EQ_1]] +; CHECK-NEXT:[[TMP0:%.*]] = and i1 [[A_EQ_0]], [[A_EQ_1]] ; CHECK-NEXT:br i1 [[TMP0]], label [[BB2:%.*]], label [[BB3:%.*]] ; CHECK: bb2: ; CHECK-NEXT:br label [[BB3]] @@ -114,7 +114,7 @@ define void @test_then(i32 %x, i32 %y, i32 %z) { ; CHECK-NEXT: entry.x: ; CHECK-NEXT:[[CMP_X:%.*]] = icmp ne i32 [[X]], 0 ; CHECK-NEXT:[[CMP_Y:%.*]] = icmp ne i32 [[Y]], 0 -; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[CMP_X]], [[CMP_Y]] +; CHECK-NEXT:[[TMP0:%.*]] = and i1 [[CMP_X]], [[CMP_Y]] ; CHECK-NEXT:br i1 [[TMP0]], label [[IF_THEN_Y:%.*]], label [[EXIT:%.*]] ; CHECK: if.then.y: ; CHECK-NEXT:store i32 [[Z]], ptr @g, align 4 @@ -148,7 +148,7 @@ define void @test_else(i32 %x, i32 %y, i32 %z) { ; CHECK-NEXT: entry.x: ; CHECK-NEXT:[[CMP_X:%.*]] = icmp eq i32 [[X]], 0 ; CHECK-NEXT:[[CMP_Y:%.*]] = icmp eq i32 [[Y]], 0 -; CHECK-NEXT:
[openmp] [libcxx] [llvm] [clang] [libc] [lldb] [flang] [mlir] Fix Logical expression used for merged conditional if in FlattenCFG pass (PR #72522)
@@ -450,9 +450,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> ) { if (!CompareIfRegionBlock(IfTrue1, IfTrue2, SecondEntryBlock)) return false; } else if (IfTrue1 == FirstEntryBlock) { -// The then-path is empty, so we must use "and" operation to combine the +// The else-path is empty, so we must use "or" operation to combine the // conditions. -CombineOp = BinaryOperator::And; +CombineOp = BinaryOperator::Or; mahtohappy wrote: Even I had my doubts about it, but the testcase this issue had seems to give correct results on executions(output) with the changes and from my understanding the changes are correct. I'm hoping the the original author or reviewer will take a look. From my side, I'll try to regenerate all the patterns in the testcase in c file and execute and see if they're giving correct output on execution. https://github.com/llvm/llvm-project/pull/72522 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][driver] Add \/../include/c++/v1 to include path on Darwin (PR #70817)
ilg-ul wrote: The CI passed. Do we need a second review, or the PR can be merged? https://github.com/llvm/llvm-project/pull/70817 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libc] [clang-tools-extra] [flang] [clang] [llvm] [compiler-rt] [libcxx] [lld] [mlir] [lldb] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)
@@ -0,0 +1,31 @@ +//===- SPIRVToLLVMIRTranslation.cpp - Translate SPIRV to LLVM IR --===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +// +// This file implements a translation between the MLIR SPIRV dialect and +// LLVM IR. +// +//===--===// + +#include "mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h" +#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h" +#include "mlir/IR/BuiltinAttributes.h" +#include "mlir/IR/Operation.h" +#include "mlir/Target/LLVMIR/ModuleTranslation.h" + +using namespace mlir; +using namespace mlir::LLVM; + +void mlir::registerSPIRVDialectTranslation(DialectRegistry ) { + registry.insert(); joker-eph wrote: I'm confused here: there is no translation interface. https://github.com/llvm/llvm-project/pull/71430 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libc] [clang-tools-extra] [flang] [clang] [llvm] [compiler-rt] [libcxx] [lld] [mlir] [lldb] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)
@@ -61,6 +63,7 @@ registerAllGPUToLLVMIRTranslations(DialectRegistry ) { registerLLVMDialectTranslation(registry); registerNVVMDialectTranslation(registry); registerROCDLDialectTranslation(registry); + registerSPIRVDialectTranslation(registry); joker-eph wrote: Trying to understand... What is the unit test that requires this? https://github.com/llvm/llvm-project/pull/71430 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Enable OpenCL hostcall printf (WIP) (PR #72556)
https://github.com/vikramRH edited https://github.com/llvm/llvm-project/pull/72556 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AMDGPU] Treat printf as builtin for OpenCL (PR #72554)
https://github.com/vikramRH updated https://github.com/llvm/llvm-project/pull/72554 >From 9833353ab6d7bb9716883b89f4e8b90285c1a60c Mon Sep 17 00:00:00 2001 From: Vikram Date: Fri, 10 Nov 2023 09:39:41 + Subject: [PATCH] [AMDGPU] Treat printf as builtin for OpenCL --- clang/include/clang/Basic/BuiltinsAMDGPU.def | 8 clang/lib/AST/Decl.cpp | 7 +++ clang/lib/Basic/Targets/AMDGPU.cpp | 3 +++ clang/lib/CodeGen/CGBuiltin.cpp | 5 + 4 files changed, 23 insertions(+) diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index a19c8bd5f219ec6..1799c72806bfdd4 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -21,6 +21,10 @@ #if defined(BUILTIN) && !defined(TARGET_BUILTIN) # define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS) #endif + +#if defined(BUILTIN) && !defined(LANGBUILTIN) +#define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS) +#endif //===--===// // SI+ only builtins. //===--===// @@ -406,5 +410,9 @@ TARGET_BUILTIN(__builtin_amdgcn_cvt_pk_fp8_f32, "iffiIb", "nc", "fp8-insts") TARGET_BUILTIN(__builtin_amdgcn_cvt_sr_bf8_f32, "ifiiIi", "nc", "fp8-insts") TARGET_BUILTIN(__builtin_amdgcn_cvt_sr_fp8_f32, "ifiiIi", "nc", "fp8-insts") +// OpenCL +LANGBUILTIN(printf, "icC*4.", "fp:0:", ALL_OCL_LANGUAGES) + #undef BUILTIN #undef TARGET_BUILTIN +#undef LANGBUILTIN diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index c5c2edf1bfe3aba..2597422bdd521a0 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -49,6 +49,7 @@ #include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/Specifiers.h" +#include "clang/Basic/TargetBuiltins.h" #include "clang/Basic/TargetCXXABI.h" #include "clang/Basic/TargetInfo.h" #include "clang/Basic/Visibility.h" @@ -3598,6 +3599,12 @@ unsigned FunctionDecl::getBuiltinID(bool ConsiderWrapperFunctions) const { if (!ConsiderWrapperFunctions && getStorageClass() == SC_Static) return 0; + // AMDGCN implementation supports printf as a builtin + // for OpenCL + if (Context.getTargetInfo().getTriple().isAMDGCN() && + Context.getLangOpts().OpenCL && BuiltinID == AMDGPU::BIprintf) +return BuiltinID; + // OpenCL v1.2 s6.9.f - The library functions defined in // the C99 standard headers are not available. if (Context.getLangOpts().OpenCL && diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp b/clang/lib/Basic/Targets/AMDGPU.cpp index 409ae32ab424215..0cf6daee87c4a4c 100644 --- a/clang/lib/Basic/Targets/AMDGPU.cpp +++ b/clang/lib/Basic/Targets/AMDGPU.cpp @@ -91,6 +91,9 @@ static constexpr Builtin::Info BuiltinInfo[] = { {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, #define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) \ + { #ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, LANG } \ + , #include "clang/Basic/BuiltinsAMDGPU.def" }; diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 09309a3937fb613..d7a4b895f3432ca 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -2458,6 +2458,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, ().getLongDoubleFormat() == ::APFloat::IEEEquad()) BuiltinID = mutateLongDoubleBuiltin(BuiltinID); + // Mutate the printf builtin ID so that we use the same CodeGen path for + // HIP and OpenCL with AMDGPU targets. + if (getTarget().getTriple().isAMDGCN() && BuiltinID == AMDGPU::BIprintf) +BuiltinID = Builtin::BIprintf; + // If the builtin has been declared explicitly with an assembler label, // disable the specialized emitting below. Ideally we should communicate the // rename in IR, or at least avoid generating the intrinsic calls that are ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang] [llvm] Remove unused LoopInfo from InlineSpiller and SpillPlacement (NFC) (PR #71874)
https://github.com/MatzeB closed https://github.com/llvm/llvm-project/pull/71874 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AMDGPU] Treat printf as builtin for OpenCL (PR #72554)
vikramRH wrote: > Any tests? Can you explain why it's not sufficient to do this lowering in the > AMDGPU pass? I intended these changes to be part of https://github.com/llvm/llvm-project/pull/72556, but it seemed too many changes at one place, so I extracted this part out for ease of review. This cannot be merged standalone and has to be with 72556 , the tests are also part of that patch (This really should have been a stack of patches :( ). Also for AMDGPU pass, I plan to remove that altogether and handle all printf lowering at one place during clang Codegen. since we now use a compiler option to switch between different implementations, This makes a lot more sense I feel. https://github.com/llvm/llvm-project/pull/72554 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AMDGPU] Treat printf as builtin for OpenCL (PR #72554)
@@ -406,5 +410,9 @@ TARGET_BUILTIN(__builtin_amdgcn_cvt_pk_fp8_f32, "iffiIb", "nc", "fp8-insts") TARGET_BUILTIN(__builtin_amdgcn_cvt_sr_bf8_f32, "ifiiIi", "nc", "fp8-insts") TARGET_BUILTIN(__builtin_amdgcn_cvt_sr_fp8_f32, "ifiiIi", "nc", "fp8-insts") +// OpenCL +LANGBUILTIN(printf, "icC*4.", "fp:0:", ALL_OCL_LANGUAGES) vikramRH wrote: This is specifically to recognize the OpenCL version of printf (where fmt string arg is a pointer to const address space) as a builtin. The hack to generic builtin is just a option that I had as I did not want to add a new case to builtin expansion code (since the API used by both OpenCL and HIP are same ), however Im okay with adding a new case too if you feel it makes more sense. https://github.com/llvm/llvm-project/pull/72554 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AMDGPU] Treat printf as builtin for OpenCL (PR #72554)
@@ -2458,6 +2458,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, ().getLongDoubleFormat() == ::APFloat::IEEEquad()) BuiltinID = mutateLongDoubleBuiltin(BuiltinID); + // Mutate the printf builtin ID so that we use the same CodeGen path for + // HIP and OpenCL with AMDGPU targets. + if (getTarget().getTriple().isAMDGCN() && BuiltinID == AMDGPU::BIprintf) + BuiltinID = Builtin::BIprintf; vikramRH wrote: @jhuber6 , I had your implementation in mind when I wrote this, The printf wont be expanded by clang with "-fno-builtin" and users would still have an option to use a lib variant if need be. This also makes this more elegant as we would not have to hack the "fno-builtin" handling into the implementation, this is part of clang builtin handling. https://github.com/llvm/llvm-project/pull/72554 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Handle Flang in same manner between Gnu and *BSD/Solaris ToolChain (PR #70429)
brad0 wrote: So with https://github.com/llvm/llvm-project/pull/72601, once that goes in I can update this with RUN line updates to test. It fails as expected without this. https://github.com/llvm/llvm-project/pull/70429 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #72607)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff b034da7dad150a54661557cc3f712948b1e474e4 26a20b1c3594676b138395f91143356d87ec72cd -- clang/test/SemaCXX/constexpr-vectors-access-elements.cpp clang/lib/AST/ExprConstant.cpp clang/lib/AST/Interp/State.h clang/test/CodeGenCXX/temporaries.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 7468dc5c71..486dd41335 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -2782,9 +2782,9 @@ static bool EvalAndBitcastToAPInt(EvalInfo , const Expr *E, } unsigned BaseEltSize = EltAsInt.getBitWidth(); if (BigEndian) -Res |= EltAsInt.zextOrTrunc(VecSize).rotr(i*EltSize+BaseEltSize); +Res |= EltAsInt.zextOrTrunc(VecSize).rotr(i * EltSize + BaseEltSize); else -Res |= EltAsInt.zextOrTrunc(VecSize).rotl(i*EltSize); +Res |= EltAsInt.zextOrTrunc(VecSize).rotl(i * EltSize); } return true; } @@ -3242,8 +3242,8 @@ static bool HandleLValueIndirectMember(EvalInfo , const Expr *E, } /// Get the size of the given type in char units. -static bool HandleSizeof(EvalInfo , SourceLocation Loc, - QualType Type, CharUnits ) { +static bool HandleSizeof(EvalInfo , SourceLocation Loc, QualType Type, + CharUnits ) { // sizeof(void), __alignof__(void), sizeof(function) = 1 as a gcc // extension. if (Type->isVoidType() || Type->isFunctionType()) { @@ -3872,7 +3872,7 @@ findSubobject(EvalInfo , const Expr *E, const CompleteObject , if (Index >= ObjType->castAs()->getNumElements()) { if (Info.getLangOpts().CPlusPlus11) Info.FFDiag(E, diag::note_constexpr_access_past_end) -<< handler.AccessKind; + << handler.AccessKind; else Info.FFDiag(E); return handler.failed(); @@ -10653,9 +10653,9 @@ bool VectorExprEvaluator::VisitCastExpr(const CastExpr *E) { for (unsigned i = 0; i < NElts; i++) { llvm::APInt Elt; if (BigEndian) - Elt = SValInt.rotl(i*EltSize+EltSize).zextOrTrunc(EltSize); + Elt = SValInt.rotl(i * EltSize + EltSize).zextOrTrunc(EltSize); else - Elt = SValInt.rotr(i*EltSize).zextOrTrunc(EltSize); + Elt = SValInt.rotr(i * EltSize).zextOrTrunc(EltSize); Elts.push_back(APValue(APSInt(Elt, !EltTy->isSignedIntegerType(; } } else { `` https://github.com/llvm/llvm-project/pull/72607 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #72607)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Yuanfang Chen (yuanfang-chen) Changes Supports both v[0] and v.x/v.r/v.s0 syntax. Selecting multiple elements is left as a future work. --- Full diff: https://github.com/llvm/llvm-project/pull/72607.diff 4 Files Affected: - (modified) clang/lib/AST/ExprConstant.cpp (+95-3) - (modified) clang/lib/AST/Interp/State.h (+2-1) - (modified) clang/test/CodeGenCXX/temporaries.cpp (+21-22) - (added) clang/test/SemaCXX/constexpr-vectors-access-elements.cpp (+29) ``diff diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index eea0827d6f7a8a1..7468dc5c71fa895 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -436,6 +436,16 @@ namespace { MostDerivedArraySize = 2; MostDerivedPathLength = Entries.size(); } +void addVectorUnchecked(QualType EltTy, uint64_t Size, uint64_t Idx) { + Entries.push_back(PathEntry::ArrayIndex(Idx)); + + // This is technically a most-derived object, though in practice this + // is unlikely to matter. + MostDerivedType = EltTy; + MostDerivedIsArrayElement = true; + MostDerivedArraySize = Size; + MostDerivedPathLength = Entries.size(); +} void diagnoseUnsizedArrayPointerArithmetic(EvalInfo , const Expr *E); void diagnosePointerArithmetic(EvalInfo , const Expr *E, const APSInt ); @@ -1714,6 +1724,11 @@ namespace { if (checkSubobject(Info, E, Imag ? CSK_Imag : CSK_Real)) Designator.addComplexUnchecked(EltTy, Imag); } +void addVectorElement(EvalInfo , const Expr *E, QualType EltTy, + uint64_t Size, uint64_t Idx) { + if (checkSubobject(Info, E, CSK_VectorElement)) +Designator.addVectorUnchecked(EltTy, Size, Idx); +} void clearIsNullPointer() { IsNullPtr = false; } @@ -3294,6 +3309,19 @@ static bool HandleLValueComplexElement(EvalInfo , const Expr *E, return true; } +static bool HandleLValueVectorElement(EvalInfo , const Expr *E, + LValue , QualType EltTy, + uint64_t Size, uint64_t Idx) { + if (Idx) { +CharUnits SizeOfElement; +if (!HandleSizeof(Info, E->getExprLoc(), EltTy, SizeOfElement)) + return false; +LVal.Offset += SizeOfElement * Idx; + } + LVal.addVectorElement(Info, E, EltTy, Size, Idx); + return true; +} + /// Try to evaluate the initializer for a variable declaration. /// /// \param Info Information about the ongoing evaluation. @@ -3839,6 +3867,21 @@ findSubobject(EvalInfo , const Expr *E, const CompleteObject , return handler.found(Index ? O->getComplexFloatImag() : O->getComplexFloatReal(), ObjType); } +} else if (ObjType->isVectorType()) { + uint64_t Index = Sub.Entries[I].getAsArrayIndex(); + if (Index >= ObjType->castAs()->getNumElements()) { +if (Info.getLangOpts().CPlusPlus11) + Info.FFDiag(E, diag::note_constexpr_access_past_end) +<< handler.AccessKind; +else + Info.FFDiag(E); +return handler.failed(); + } + + ObjType = ObjType->castAs()->getElementType(); + + assert(I == N - 1 && "extracting subobject of scalar?"); + return handler.found(O->getVectorElt(Index), ObjType); } else if (const FieldDecl *Field = getAsField(Sub.Entries[I])) { if (Field->isMutable() && !Obj.mayAccessMutableMembers(Info, handler.AccessKind)) { @@ -8294,6 +8337,7 @@ class LValueExprEvaluator bool VisitCXXTypeidExpr(const CXXTypeidExpr *E); bool VisitCXXUuidofExpr(const CXXUuidofExpr *E); bool VisitArraySubscriptExpr(const ArraySubscriptExpr *E); + bool VisitExtVectorElementExpr(const ExtVectorElementExpr *E); bool VisitUnaryDeref(const UnaryOperator *E); bool VisitUnaryReal(const UnaryOperator *E); bool VisitUnaryImag(const UnaryOperator *E); @@ -8607,15 +8651,63 @@ bool LValueExprEvaluator::VisitMemberExpr(const MemberExpr *E) { return LValueExprEvaluatorBaseTy::VisitMemberExpr(E); } +bool LValueExprEvaluator::VisitExtVectorElementExpr( +const ExtVectorElementExpr *E) { + bool Success = true; + + APValue Val; + if (!Evaluate(Val, Info, E->getBase())) { +if (!Info.noteFailure()) + return false; +Success = false; + } + + SmallVector Indices; + E->getEncodedElementAccess(Indices); + // FIXME: support accessing more than one element + if (Indices.size() > 1) +return false; + + if (Success) { +Result.setFrom(Info.Ctx, Val); +const VectorType *VT = E->getBase()->getType()->castAs(); +HandleLValueVectorElement(Info, E, Result, VT->getElementType(), + VT->getNumElements(), Indices[0]); + } + + return Success; +} + bool LValueExprEvaluator::VisitArraySubscriptExpr(const ArraySubscriptExpr *E) { - // FIXME: Deal with vectors
[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #72607)
https://github.com/yuanfang-chen created https://github.com/llvm/llvm-project/pull/72607 Supports both v[0] and v.x/v.r/v.s0 syntax. Selecting multiple elements is left as a future work. >From 26a20b1c3594676b138395f91143356d87ec72cd Mon Sep 17 00:00:00 2001 From: Yuanfang Chen Date: Fri, 17 Nov 2023 03:16:38 + Subject: [PATCH] [clang][ExprConst] allow single element access of vector object to be constant expression Supports both v[0] and v.x/v.r/v.s0 syntax. Selecting multiple elements is left as a future work. --- clang/lib/AST/ExprConstant.cpp| 98 ++- clang/lib/AST/Interp/State.h | 3 +- clang/test/CodeGenCXX/temporaries.cpp | 43 .../constexpr-vectors-access-elements.cpp | 29 ++ 4 files changed, 147 insertions(+), 26 deletions(-) create mode 100644 clang/test/SemaCXX/constexpr-vectors-access-elements.cpp diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index eea0827d6f7a8a1..7468dc5c71fa895 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -436,6 +436,16 @@ namespace { MostDerivedArraySize = 2; MostDerivedPathLength = Entries.size(); } +void addVectorUnchecked(QualType EltTy, uint64_t Size, uint64_t Idx) { + Entries.push_back(PathEntry::ArrayIndex(Idx)); + + // This is technically a most-derived object, though in practice this + // is unlikely to matter. + MostDerivedType = EltTy; + MostDerivedIsArrayElement = true; + MostDerivedArraySize = Size; + MostDerivedPathLength = Entries.size(); +} void diagnoseUnsizedArrayPointerArithmetic(EvalInfo , const Expr *E); void diagnosePointerArithmetic(EvalInfo , const Expr *E, const APSInt ); @@ -1714,6 +1724,11 @@ namespace { if (checkSubobject(Info, E, Imag ? CSK_Imag : CSK_Real)) Designator.addComplexUnchecked(EltTy, Imag); } +void addVectorElement(EvalInfo , const Expr *E, QualType EltTy, + uint64_t Size, uint64_t Idx) { + if (checkSubobject(Info, E, CSK_VectorElement)) +Designator.addVectorUnchecked(EltTy, Size, Idx); +} void clearIsNullPointer() { IsNullPtr = false; } @@ -3294,6 +3309,19 @@ static bool HandleLValueComplexElement(EvalInfo , const Expr *E, return true; } +static bool HandleLValueVectorElement(EvalInfo , const Expr *E, + LValue , QualType EltTy, + uint64_t Size, uint64_t Idx) { + if (Idx) { +CharUnits SizeOfElement; +if (!HandleSizeof(Info, E->getExprLoc(), EltTy, SizeOfElement)) + return false; +LVal.Offset += SizeOfElement * Idx; + } + LVal.addVectorElement(Info, E, EltTy, Size, Idx); + return true; +} + /// Try to evaluate the initializer for a variable declaration. /// /// \param Info Information about the ongoing evaluation. @@ -3839,6 +3867,21 @@ findSubobject(EvalInfo , const Expr *E, const CompleteObject , return handler.found(Index ? O->getComplexFloatImag() : O->getComplexFloatReal(), ObjType); } +} else if (ObjType->isVectorType()) { + uint64_t Index = Sub.Entries[I].getAsArrayIndex(); + if (Index >= ObjType->castAs()->getNumElements()) { +if (Info.getLangOpts().CPlusPlus11) + Info.FFDiag(E, diag::note_constexpr_access_past_end) +<< handler.AccessKind; +else + Info.FFDiag(E); +return handler.failed(); + } + + ObjType = ObjType->castAs()->getElementType(); + + assert(I == N - 1 && "extracting subobject of scalar?"); + return handler.found(O->getVectorElt(Index), ObjType); } else if (const FieldDecl *Field = getAsField(Sub.Entries[I])) { if (Field->isMutable() && !Obj.mayAccessMutableMembers(Info, handler.AccessKind)) { @@ -8294,6 +8337,7 @@ class LValueExprEvaluator bool VisitCXXTypeidExpr(const CXXTypeidExpr *E); bool VisitCXXUuidofExpr(const CXXUuidofExpr *E); bool VisitArraySubscriptExpr(const ArraySubscriptExpr *E); + bool VisitExtVectorElementExpr(const ExtVectorElementExpr *E); bool VisitUnaryDeref(const UnaryOperator *E); bool VisitUnaryReal(const UnaryOperator *E); bool VisitUnaryImag(const UnaryOperator *E); @@ -8607,15 +8651,63 @@ bool LValueExprEvaluator::VisitMemberExpr(const MemberExpr *E) { return LValueExprEvaluatorBaseTy::VisitMemberExpr(E); } +bool LValueExprEvaluator::VisitExtVectorElementExpr( +const ExtVectorElementExpr *E) { + bool Success = true; + + APValue Val; + if (!Evaluate(Val, Info, E->getBase())) { +if (!Info.noteFailure()) + return false; +Success = false; + } + + SmallVector Indices; + E->getEncodedElementAccess(Indices); + // FIXME: support accessing more than one element + if (Indices.size() > 1) +return false; + + if (Success) { +
[clang] [-Wunsafe-buffer-usage] Add FixableGadget for AddAssign in UnspecifiedUntypedContext (PR #71862)
@@ -1766,6 +1812,48 @@ fixUPCAddressofArraySubscriptWithSpan(const UnaryOperator *Node) { FixItHint::CreateReplacement(Node->getSourceRange(), SS.str())}; } +std::optional +UUCAddAssignGadget::getFixits(const Strategy ) const { + DeclUseList DREs = getClaimedVarUseSites(); + + if (DREs.size() != 1) +return std::nullopt; // In cases of `Ptr += n` where `Ptr` is not a DRE, we + // give up + if (const VarDecl *VD = dyn_cast(DREs.front()->getDecl())) { +if (S.lookup(VD) == Strategy::Kind::Span) { + FixItList Fixes; + std::stringstream SS; + const Stmt *AddAssignNode = getBaseStmt(); + StringRef varName = VD->getName(); + const ASTContext = VD->getASTContext(); + + if (!isNonNegativeIntegerExpr(Offset, VD, Ctx)) +return std::nullopt; + + // To transform UUC(p += n) to UUC(p = p.subspan(..)): + SS << varName.data() << " = " << varName.data() << ".subspan"; haoNoQ wrote: > _"Ironic. We could save others from `.data()` but not ourselves."_ On a serious note though, it looks like `StringRef.data()` is a plain `const char *` that isn't guaranteed to be null-terminated. And `std::stringstream` probably expects it to be null-terminated, because there's no other bounds information available to it. So I'm quite worried about an actual overrun in this case. Worth noting that `StringRef.str()` is safer than `StringRef.data()` because it produces a `std::string`, but of course this requires an unnecessary deep copy. I think the usual idiom in LLVM is ``` llvm::SmallString<128> Str; llvm::raw_svector_ostream SS(Str); SS << varName << ...; ``` because custom streams consume `llvm::StringRef` naturally. Though for such simple operations I think it's perfectly fine to just use `+`: ``` std::string S = varName.str() + " = " + varName + ".subspan"; if (NotParenExpr) S += "("; ``` https://github.com/llvm/llvm-project/pull/71862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [-Wunsafe-buffer-usage] Add FixableGadget for AddAssign in UnspecifiedUntypedContext (PR #71862)
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/71862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [-Wunsafe-buffer-usage] Add FixableGadget for AddAssign in UnspecifiedUntypedContext (PR #71862)
https://github.com/haoNoQ commented: Aha, yes, this is exactly what I had in mind with the fix-around-it thing! I found one more nitpick, but I think everything else looks great! https://github.com/llvm/llvm-project/pull/71862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
@@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -verify -fsyntax-only %s yuxuanchen1997 wrote: Can it be more elaborate like `GH70735-member-template-specialization.cpp`? https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [-Wunsafe-buffer-usage] Add FixableGadget for AddAssign in UnspecifiedUntypedContext (PR #71862)
@@ -0,0 +1,55 @@ +// RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage \ +// RUN:-fsafe-buffer-usage-suggestions \ +// RUN:-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +void foo(int * , int *); + +void add_assign_test(unsigned int n, int *a, int y) { + int *p = new int[10]; + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:11}:"std::span p" + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:12-[[@LINE-2]]:12}:"{" + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:23-[[@LINE-3]]:23}:", 10}" + p += 2; + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:9}:"p = p.subspan(2)" haoNoQ wrote: Wait never mind, offset is exactly what we need lol. I'm the one who got confused about what the intended behavior is, was thinking about the scenario where we're forcing a bounds check before calling `.data()` which is completely unrelated. Everything looks correct: https://godbolt.org/z/MWGEj4cT8 https://github.com/llvm/llvm-project/pull/71862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix crashes in AlignArrayOfStructures (PR #72520)
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/72520 >From efdf321e9447e8b3f1c27ccdf6da842107deb6dd Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Thu, 16 Nov 2023 06:36:41 -0800 Subject: [PATCH 1/2] [clang-format] Fix crashes in AlignArrayOfStructures Fixed #55493. Fixed #68431. --- clang/lib/Format/WhitespaceManager.cpp | 4 +++- clang/lib/Format/WhitespaceManager.h | 2 +- clang/unittests/Format/FormatTest.cpp | 18 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp index 32d8b97cc8dadb1..3bc6915b8df0a70 100644 --- a/clang/lib/Format/WhitespaceManager.cpp +++ b/clang/lib/Format/WhitespaceManager.cpp @@ -1316,6 +1316,8 @@ void WhitespaceManager::alignArrayInitializersRightJustified( auto Offset = std::distance(Cells.begin(), CellIter); for (const auto *Next = CellIter->NextColumnElement; Next; Next = Next->NextColumnElement) { + if (RowCount >= CellDescs.CellCounts.size()) +break; auto *Start = (Cells.begin() + RowCount * CellDescs.CellCounts[0]); auto *End = Start + Offset; ThisNetWidth = getNetWidth(Start, End, CellDescs.InitialSpaces); @@ -1379,7 +1381,7 @@ void WhitespaceManager::alignArrayInitializersLeftJustified( auto Offset = std::distance(Cells.begin(), CellIter); for (const auto *Next = CellIter->NextColumnElement; Next; Next = Next->NextColumnElement) { - if (RowCount > CellDescs.CellCounts.size()) + if (RowCount >= CellDescs.CellCounts.size()) break; auto *Start = (Cells.begin() + RowCount * CellDescs.CellCounts[0]); auto *End = Start + Offset; diff --git a/clang/lib/Format/WhitespaceManager.h b/clang/lib/Format/WhitespaceManager.h index df7e9add1cd446f..69398fe411502f1 100644 --- a/clang/lib/Format/WhitespaceManager.h +++ b/clang/lib/Format/WhitespaceManager.h @@ -317,7 +317,7 @@ class WhitespaceManager { auto Offset = std::distance(CellStart, CellStop); for (const auto *Next = CellStop->NextColumnElement; Next; Next = Next->NextColumnElement) { - if (RowCount > MaxRowCount) + if (RowCount >= MaxRowCount) break; auto Start = (CellStart + RowCount * CellCount); auto End = Start + Offset; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index a12a20359c2fad2..cd4c93e8427723f 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -21140,6 +21140,24 @@ TEST_F(FormatTest, CatchAlignArrayOfStructuresLeftAlignment) { "that really, in any just world, ought to be split over multiple " "lines\"},{-1, 93463, \"world\"},{7, 5, \"!!\"},};", Style); + + Style.ColumnLimit = 25; + verifyNoCrash("Type object[X][Y] = {\n" +"{{val}, {val}, {val}},\n" +"{{val}, {val}, // some comment\n" +" {val}}\n" +"};", +Style); + + Style.ColumnLimit = 120; + verifyNoCrash( + "T v[] {\n" + "{ A::aaa, " + "A::, 1, 0.0f, " + "\"" + "\" },\n" + "};", + Style); } TEST_F(FormatTest, UnderstandsPragmas) { >From 4a73cc6c52be6824d34f4ba5608a008a3dfdedf0 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Thu, 16 Nov 2023 18:46:23 -0800 Subject: [PATCH 2/2] Added tests from #54815 and #55269. --- clang/unittests/Format/FormatTest.cpp | 15 +++ 1 file changed, 15 insertions(+) diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index cd4c93e8427723f..a579746fd4b68e8 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -20709,6 +20709,12 @@ TEST_F(FormatTest, CatchExceptionReferenceBinding) { TEST_F(FormatTest, CatchAlignArrayOfStructuresRightAlignment) { auto Style = getLLVMStyle(); Style.AlignArrayOfStructures = FormatStyle::AIAS_Right; + + verifyNoCrash("f({\n" +"table({}, table({{\"\", false}}, {}))\n" +"});", +Style); + Style.AlignConsecutiveAssignments.Enabled = true; Style.AlignConsecutiveDeclarations.Enabled = true; verifyFormat("struct test demo[] = {\n" @@ -21142,6 +21148,15 @@ TEST_F(FormatTest, CatchAlignArrayOfStructuresLeftAlignment) { Style); Style.ColumnLimit = 25; + verifyNoCrash("Type foo{\n" +"{\n" +"1, // A\n" +"2, // B\n" +"3, // C\n" +"},\n" +"\"hello\",\n" +"};", +Style);
[lldb] [libcxx] [openmp] [libc] [mlir] [clang] [llvm] [flang] Fix Logical expression used for merged conditional if in FlattenCFG pass (PR #72522)
@@ -25,13 +25,13 @@ define void @test_not_crash(i32 %in_a) #0 { entry: %cmp0 = icmp eq i32 %in_a, -1 %cmp1 = icmp ne i32 %in_a, 0 - %cond0 = and i1 %cmp0, %cmp1 + %cond0 = or i1 %cmp0, %cmp1 br i1 %cond0, label %b0, label %b1 b0:; preds = %entry %cmp2 = icmp eq i32 %in_a, 0 %cmp3 = icmp ne i32 %in_a, 1 - %cond1 = or i1 %cmp2, %cmp3 arsenm wrote: Why is this changing the original test? I would expect additional tests, and updates to the existing functions https://github.com/llvm/llvm-project/pull/72522 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [flang] [clang] [lldb] [libcxx] [openmp] [mlir] [libc] Fix Logical expression used for merged conditional if in FlattenCFG pass (PR #72522)
@@ -450,9 +450,9 @@ bool FlattenCFGOpt::MergeIfRegion(BasicBlock *BB, IRBuilder<> ) { if (!CompareIfRegionBlock(IfTrue1, IfTrue2, SecondEntryBlock)) return false; } else if (IfTrue1 == FirstEntryBlock) { -// The then-path is empty, so we must use "and" operation to combine the +// The else-path is empty, so we must use "or" operation to combine the // conditions. -CombineOp = BinaryOperator::And; +CombineOp = BinaryOperator::Or; arsenm wrote: Was this really just completely backwards? https://github.com/llvm/llvm-project/pull/72522 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Introduce _LIBUNWIND_TRACE_DWARF_EVAL for increased baremetal friendliness (PR #72040)
@@ -381,24 +381,22 @@ typename A::pint_t DwarfInstructions::evaluateExpression(pint_t expression, A , const R , pint_t initialStackValue) { - const bool log = false; pint_t p = expression; pint_t expressionEnd = expression + 20; // temp, until len read pint_t length = (pint_t)addressSpace.getULEB128(p, expressionEnd); expressionEnd = p + length; - if (log) -fprintf(stderr, "evaluateExpression(): length=%" PRIu64 "\n", -(uint64_t)length); + _LIBUNWIND_TRACE_DWARF_EVAL("evaluateExpression(): length=%" PRIu64 "\n", + (uint64_t)length); pint_t stack[100]; pint_t *sp = stack; *(++sp) = initialStackValue; while (p < expressionEnd) { -if (log) { - for (pint_t *t = sp; t > stack; --t) { -fprintf(stderr, "sp[] = 0x%" PRIx64 "\n", (uint64_t)(*t)); - } +#if _LIBUNWIND_TRACING_DWARF_EVAL michael-kenzel wrote: makes sense, I'll just leave the test as-is. https://github.com/llvm/llvm-project/pull/72040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][Driver] Support -nodefaultlibs, -nostartfiles and -nostdlib (PR #72601)
llvmbot wrote: @llvm/pr-subscribers-flang-driver @llvm/pr-subscribers-clang Author: Brad Smith (brad0) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/72601.diff 2 Files Affected: - (modified) clang/include/clang/Driver/Options.td (+6-3) - (modified) flang/test/Driver/dynamic-linker.f90 (+34-2) ``diff diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 811550416110b3d..a0eb04a5cd9c6a7 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5131,7 +5131,8 @@ def : Flag<["-"], "nocudalib">, Alias; def gpulibc : Flag<["-"], "gpulibc">, Visibility<[ClangOption, CC1Option]>, HelpText<"Link the LLVM C Library for GPUs">; def nogpulibc : Flag<["-"], "nogpulibc">, Visibility<[ClangOption, CC1Option]>; -def nodefaultlibs : Flag<["-"], "nodefaultlibs">; +def nodefaultlibs : Flag<["-"], "nodefaultlibs">, + Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>; def nodriverkitlib : Flag<["-"], "nodriverkitlib">; def nofixprebinding : Flag<["-"], "nofixprebinding">; def nolibc : Flag<["-"], "nolibc">; @@ -5141,7 +5142,8 @@ def no_pie : Flag<["-"], "no-pie">, Visibility<[ClangOption, FlangOption]>, Alia def noprebind : Flag<["-"], "noprebind">; def noprofilelib : Flag<["-"], "noprofilelib">; def noseglinkedit : Flag<["-"], "noseglinkedit">; -def nostartfiles : Flag<["-"], "nostartfiles">, Group; +def nostartfiles : Flag<["-"], "nostartfiles">, Group, + Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>; def nostdinc : Flag<["-"], "nostdinc">, Visibility<[ClangOption, CLOption, DXCOption]>, Group; def nostdlibinc : Flag<["-"], "nostdlibinc">, Group; @@ -5149,7 +5151,8 @@ def nostdincxx : Flag<["-"], "nostdinc++">, Visibility<[ClangOption, CC1Option]> Group, HelpText<"Disable standard #include directories for the C++ standard library">, MarshallingInfoNegativeFlag>; -def nostdlib : Flag<["-"], "nostdlib">, Group; +def nostdlib : Flag<["-"], "nostdlib">, Group, + Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>; def nostdlibxx : Flag<["-"], "nostdlib++">; def object : Flag<["-"], "object">; def o : JoinedOrSeparate<["-"], "o">, diff --git a/flang/test/Driver/dynamic-linker.f90 b/flang/test/Driver/dynamic-linker.f90 index 2745822dc107769..432e0cd586f1118 100644 --- a/flang/test/Driver/dynamic-linker.f90 +++ b/flang/test/Driver/dynamic-linker.f90 @@ -1,5 +1,5 @@ -! Verify that certain linker flags are known to the frontend and are passed on -! to the linker. +! Verify that certain linker flags are known to the frontend and are passed or +! not passed on to the linker. ! RUN: %flang -### --target=x86_64-linux-gnu -rpath /path/to/dir -shared \ ! RUN: -static %s 2>&1 | FileCheck \ @@ -18,3 +18,35 @@ ! MSVC-LINKER-OPTIONS: "{{.*}}link.exe" ! MSVC-LINKER-OPTIONS-SAME: "-dll" ! MSVC-LINKER-OPTIONS-SAME: "-rpath" "/path/to/dir" + +! RUN: %flang -### --target=x86_64-unknown-freebsd -nostdlib %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTDLIB %s +! RUN: %flang -### --target=x86_64-unknown-netbsd -nostdlib %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTDLIB %s +! RUN: %flang -### --target=i386-pc-solaris2.11 -nostdlib %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTDLIB %s + +! NOSTDLIB: "{{.*}}ld{{(.exe)?}}" +! NOSTDLIB-NOT: crt* +! NOSTDLIB-NOT: "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" + +! RUN: %flang -### --target=x86_64-unknown-freebsd -nodefaultlibs %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NODEFAULTLIBS %s +! RUN: %flang -### --target=x86_64-unknown-netbsd -nodefaultlibs %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NODEFAULTLIBS %s +! RUN: %flang -### --target=i386-pc-solaris2.11 -nodefaultlibs %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NODEFAULTLIBS %s + +! NODEFAULTLIBS: "{{.*}}ld{{(.exe)?}}" +! NODEFAULTLIBS-NOT: "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" + +! RUN: %flang -### --target=x86_64-unknown-freebsd -nostartfiles %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTARTFILES %s +! RUN: %flang -### --target=x86_64-unknown-netbsd -nostartfiles %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTARTFILES %s +! RUN: %flang -### --target=i386-pc-solaris2.11 -nostartfiles %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTARTFILES %s + +! NOSTARTFILES: "{{.*}}ld{{(.exe)?}}" +! NOSTARTFILES-NOT: crt* +! NOSTARTFILES: "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" `` https://github.com/llvm/llvm-project/pull/72601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][Driver] Support -nodefaultlibs, -nostartfiles and -nostdlib (PR #72601)
https://github.com/brad0 created https://github.com/llvm/llvm-project/pull/72601 None >From b4ab77671af5b073b0335ba212b7c8b105367c1d Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Wed, 15 Nov 2023 14:24:11 -0500 Subject: [PATCH] [flang][Driver] Support -nodefaultlibs, -nostartfiles and -nostdlib --- clang/include/clang/Driver/Options.td | 9 --- flang/test/Driver/dynamic-linker.f90 | 36 +-- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 811550416110b3d..a0eb04a5cd9c6a7 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5131,7 +5131,8 @@ def : Flag<["-"], "nocudalib">, Alias; def gpulibc : Flag<["-"], "gpulibc">, Visibility<[ClangOption, CC1Option]>, HelpText<"Link the LLVM C Library for GPUs">; def nogpulibc : Flag<["-"], "nogpulibc">, Visibility<[ClangOption, CC1Option]>; -def nodefaultlibs : Flag<["-"], "nodefaultlibs">; +def nodefaultlibs : Flag<["-"], "nodefaultlibs">, + Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>; def nodriverkitlib : Flag<["-"], "nodriverkitlib">; def nofixprebinding : Flag<["-"], "nofixprebinding">; def nolibc : Flag<["-"], "nolibc">; @@ -5141,7 +5142,8 @@ def no_pie : Flag<["-"], "no-pie">, Visibility<[ClangOption, FlangOption]>, Alia def noprebind : Flag<["-"], "noprebind">; def noprofilelib : Flag<["-"], "noprofilelib">; def noseglinkedit : Flag<["-"], "noseglinkedit">; -def nostartfiles : Flag<["-"], "nostartfiles">, Group; +def nostartfiles : Flag<["-"], "nostartfiles">, Group, + Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>; def nostdinc : Flag<["-"], "nostdinc">, Visibility<[ClangOption, CLOption, DXCOption]>, Group; def nostdlibinc : Flag<["-"], "nostdlibinc">, Group; @@ -5149,7 +5151,8 @@ def nostdincxx : Flag<["-"], "nostdinc++">, Visibility<[ClangOption, CC1Option]> Group, HelpText<"Disable standard #include directories for the C++ standard library">, MarshallingInfoNegativeFlag>; -def nostdlib : Flag<["-"], "nostdlib">, Group; +def nostdlib : Flag<["-"], "nostdlib">, Group, + Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>; def nostdlibxx : Flag<["-"], "nostdlib++">; def object : Flag<["-"], "object">; def o : JoinedOrSeparate<["-"], "o">, diff --git a/flang/test/Driver/dynamic-linker.f90 b/flang/test/Driver/dynamic-linker.f90 index 2745822dc107769..432e0cd586f1118 100644 --- a/flang/test/Driver/dynamic-linker.f90 +++ b/flang/test/Driver/dynamic-linker.f90 @@ -1,5 +1,5 @@ -! Verify that certain linker flags are known to the frontend and are passed on -! to the linker. +! Verify that certain linker flags are known to the frontend and are passed or +! not passed on to the linker. ! RUN: %flang -### --target=x86_64-linux-gnu -rpath /path/to/dir -shared \ ! RUN: -static %s 2>&1 | FileCheck \ @@ -18,3 +18,35 @@ ! MSVC-LINKER-OPTIONS: "{{.*}}link.exe" ! MSVC-LINKER-OPTIONS-SAME: "-dll" ! MSVC-LINKER-OPTIONS-SAME: "-rpath" "/path/to/dir" + +! RUN: %flang -### --target=x86_64-unknown-freebsd -nostdlib %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTDLIB %s +! RUN: %flang -### --target=x86_64-unknown-netbsd -nostdlib %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTDLIB %s +! RUN: %flang -### --target=i386-pc-solaris2.11 -nostdlib %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTDLIB %s + +! NOSTDLIB: "{{.*}}ld{{(.exe)?}}" +! NOSTDLIB-NOT: crt* +! NOSTDLIB-NOT: "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" + +! RUN: %flang -### --target=x86_64-unknown-freebsd -nodefaultlibs %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NODEFAULTLIBS %s +! RUN: %flang -### --target=x86_64-unknown-netbsd -nodefaultlibs %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NODEFAULTLIBS %s +! RUN: %flang -### --target=i386-pc-solaris2.11 -nodefaultlibs %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NODEFAULTLIBS %s + +! NODEFAULTLIBS: "{{.*}}ld{{(.exe)?}}" +! NODEFAULTLIBS-NOT: "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" + +! RUN: %flang -### --target=x86_64-unknown-freebsd -nostartfiles %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTARTFILES %s +! RUN: %flang -### --target=x86_64-unknown-netbsd -nostartfiles %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTARTFILES %s +! RUN: %flang -### --target=i386-pc-solaris2.11 -nostartfiles %s 2>&1 | FileCheck \ +! RUN: --check-prefixes=NOSTARTFILES %s + +! NOSTARTFILES: "{{.*}}ld{{(.exe)?}}" +! NOSTARTFILES-NOT: crt* +! NOSTARTFILES: "-lFortran_main" "-lFortranRuntime" "-lFortranDecimal" "-lm" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Replace getAs with castAs, dyn_cast with cast (NFC) (PR #72600)
llvmbot wrote: @llvm/pr-subscribers-clang @llvm/pr-subscribers-flang-openmp Author: Mike Rice (mikerice1969) Changes Make the code clear that nullptrs are not expected. --- Full diff: https://github.com/llvm/llvm-project/pull/72600.diff 2 Files Affected: - (modified) clang/lib/AST/ASTContext.cpp (+2-2) - (modified) llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp (+2-2) ``diff diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4f54791b4c1e5ce..1c893d008cb49f3 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -4014,8 +4014,8 @@ QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts, assert(vecType->isBuiltinType() || (vecType->isBitIntType() && // Only support _BitInt elements with byte-sized power of 2 NumBits. - llvm::isPowerOf2_32(vecType->getAs()->getNumBits()) && - vecType->getAs()->getNumBits() >= 8)); + llvm::isPowerOf2_32(vecType->castAs()->getNumBits()) && + vecType->castAs()->getNumBits() >= 8)); // Check if we've already instantiated a vector of this type. llvm::FoldingSetNodeID ID; diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp index ad6b0188390d88f..d04645e89f92843 100644 --- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -4402,7 +4402,7 @@ static void updateNVPTXMetadata(Function , StringRef Name, int32_t Value, // Update the "maxntidx" metadata for NVIDIA, or add it. MDNode *ExistingOp = getNVPTXMDNode(Kernel, Name); if (ExistingOp) { -auto *OldVal = dyn_cast(ExistingOp->getOperand(2)); +auto *OldVal = cast(ExistingOp->getOperand(2)); int32_t OldLimit = cast(OldVal->getValue())->getZExtValue(); ExistingOp->replaceOperandWith( 2, ConstantAsMetadata::get(ConstantInt::get( @@ -4441,7 +4441,7 @@ OpenMPIRBuilder::readThreadBoundsForKernel(const Triple , Function ) { } if (MDNode *ExistingOp = getNVPTXMDNode(Kernel, "maxntidx")) { -auto *OldVal = dyn_cast(ExistingOp->getOperand(2)); +auto *OldVal = cast(ExistingOp->getOperand(2)); int32_t UB = cast(OldVal->getValue())->getZExtValue(); return {0, ThreadLimit ? std::min(ThreadLimit, UB) : UB}; } `` https://github.com/llvm/llvm-project/pull/72600 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Enable OpenCL hostcall printf (WIP) (PR #72556)
@@ -170,20 +173,46 @@ static Value *appendString(IRBuilder<> , Value *Desc, Value *Arg, return callAppendStringN(Builder, Desc, Arg, Length, IsLast); } +static Value *appendVectorArg(IRBuilder<> , Value *Desc, Value *Arg, + bool IsLast, bool IsBuffered) { + assert(Arg->getType()->isVectorTy() && "incorrent append* function"); + auto VectorTy = dyn_cast(Arg->getType()); + auto Zero = Builder.getInt64(0); + if (VectorTy) { +for (unsigned int i = 0; i < VectorTy->getNumElements() - 1; i++) { + auto Val = Builder.CreateExtractElement(Arg, i); + Desc = callAppendArgs(Builder, Desc, 1, +fitArgInto64Bits(Builder, Val, IsBuffered), Zero, +Zero, Zero, Zero, Zero, Zero, false); +} + +auto Val = +Builder.CreateExtractElement(Arg, VectorTy->getNumElements() - 1); +return callAppendArgs(Builder, Desc, 1, + fitArgInto64Bits(Builder, Val, IsBuffered), Zero, + Zero, Zero, Zero, Zero, Zero, IsLast); + } + return nullptr; +} + static Value *processArg(IRBuilder<> , Value *Desc, Value *Arg, - bool SpecIsCString, bool IsLast) { + bool SpecIsCString, bool IsVector, bool IsLast, + bool IsBuffered) { if (SpecIsCString && isa(Arg->getType())) { return appendString(Builder, Desc, Arg, IsLast); - } - // If the format specifies a string but the argument is not, the frontend will - // have printed a warning. We just rely on undefined behaviour and send the - // argument anyway. - return appendArg(Builder, Desc, Arg, IsLast); + } else if (IsVector) { arsenm wrote: No else after return https://github.com/llvm/llvm-project/pull/72556 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Enable OpenCL hostcall printf (WIP) (PR #72556)
@@ -170,20 +173,46 @@ static Value *appendString(IRBuilder<> , Value *Desc, Value *Arg, return callAppendStringN(Builder, Desc, Arg, Length, IsLast); } +static Value *appendVectorArg(IRBuilder<> , Value *Desc, Value *Arg, + bool IsLast, bool IsBuffered) { + assert(Arg->getType()->isVectorTy() && "incorrent append* function"); + auto VectorTy = dyn_cast(Arg->getType()); + auto Zero = Builder.getInt64(0); + if (VectorTy) { +for (unsigned int i = 0; i < VectorTy->getNumElements() - 1; i++) { + auto Val = Builder.CreateExtractElement(Arg, i); + Desc = callAppendArgs(Builder, Desc, 1, +fitArgInto64Bits(Builder, Val, IsBuffered), Zero, +Zero, Zero, Zero, Zero, Zero, false); +} + +auto Val = arsenm wrote: Value * https://github.com/llvm/llvm-project/pull/72556 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] Enable OpenCL hostcall printf (WIP) (PR #72556)
@@ -278,7 +310,13 @@ static Value *callBufferedPrintfStart( StringData(StringRef(), LenWithNull, LenWithNullAligned, false)); } } else { - int AllocSize = M->getDataLayout().getTypeAllocSize(Args[i]->getType()); + int AllocSize = 0; + if (OCLVectors.test(i)) { +auto VecArg = dyn_cast(Args[i]->getType()); +assert(VecArg && "invalid vector specifier"); +AllocSize = VecArg->getNumElements() * 8; + } else +AllocSize = M->getDataLayout().getTypeAllocSize(Args[i]->getType()); arsenm wrote: Don't understand this split vector handling. Just always use getTypeAllocSize? https://github.com/llvm/llvm-project/pull/72556 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Enable OpenCL hostcall printf (WIP) (PR #72556)
@@ -278,7 +310,13 @@ static Value *callBufferedPrintfStart( StringData(StringRef(), LenWithNull, LenWithNullAligned, false)); } } else { - int AllocSize = M->getDataLayout().getTypeAllocSize(Args[i]->getType()); + int AllocSize = 0; + if (OCLVectors.test(i)) { +auto VecArg = dyn_cast(Args[i]->getType()); +assert(VecArg && "invalid vector specifier"); arsenm wrote: cast<> instead of dyn_cast + assert https://github.com/llvm/llvm-project/pull/72556 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] Replace getAs with castAs, dyn_cast with cast (NFC) (PR #72600)
https://github.com/mikerice1969 created https://github.com/llvm/llvm-project/pull/72600 Make the code clear that nullptrs are not expected. >From da715ea17cd3a23894826eac8cc8f7cd880b5e02 Mon Sep 17 00:00:00 2001 From: Mike Rice Date: Thu, 16 Nov 2023 18:30:47 -0800 Subject: [PATCH] Replace getAs with castAs, dyn_cast with cast (NFC) Make the code clear that nullptrs are not expected. --- clang/lib/AST/ASTContext.cpp | 4 ++-- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4f54791b4c1e5ce..1c893d008cb49f3 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -4014,8 +4014,8 @@ QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts, assert(vecType->isBuiltinType() || (vecType->isBitIntType() && // Only support _BitInt elements with byte-sized power of 2 NumBits. - llvm::isPowerOf2_32(vecType->getAs()->getNumBits()) && - vecType->getAs()->getNumBits() >= 8)); + llvm::isPowerOf2_32(vecType->castAs()->getNumBits()) && + vecType->castAs()->getNumBits() >= 8)); // Check if we've already instantiated a vector of this type. llvm::FoldingSetNodeID ID; diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp index ad6b0188390d88f..d04645e89f92843 100644 --- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -4402,7 +4402,7 @@ static void updateNVPTXMetadata(Function , StringRef Name, int32_t Value, // Update the "maxntidx" metadata for NVIDIA, or add it. MDNode *ExistingOp = getNVPTXMDNode(Kernel, Name); if (ExistingOp) { -auto *OldVal = dyn_cast(ExistingOp->getOperand(2)); +auto *OldVal = cast(ExistingOp->getOperand(2)); int32_t OldLimit = cast(OldVal->getValue())->getZExtValue(); ExistingOp->replaceOperandWith( 2, ConstantAsMetadata::get(ConstantInt::get( @@ -4441,7 +4441,7 @@ OpenMPIRBuilder::readThreadBoundsForKernel(const Triple , Function ) { } if (MDNode *ExistingOp = getNVPTXMDNode(Kernel, "maxntidx")) { -auto *OldVal = dyn_cast(ExistingOp->getOperand(2)); +auto *OldVal = cast(ExistingOp->getOperand(2)); int32_t UB = cast(OldVal->getValue())->getZExtValue(); return {0, ThreadLimit ? std::min(ThreadLimit, UB) : UB}; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] Enable OpenCL hostcall printf (WIP) (PR #72556)
@@ -170,20 +173,46 @@ static Value *appendString(IRBuilder<> , Value *Desc, Value *Arg, return callAppendStringN(Builder, Desc, Arg, Length, IsLast); } +static Value *appendVectorArg(IRBuilder<> , Value *Desc, Value *Arg, arsenm wrote: All of the codegen changes here should be a separate commit https://github.com/llvm/llvm-project/pull/72556 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AMDGPU] Treat printf as builtin for OpenCL (PR #72554)
@@ -406,5 +410,9 @@ TARGET_BUILTIN(__builtin_amdgcn_cvt_pk_fp8_f32, "iffiIb", "nc", "fp8-insts") TARGET_BUILTIN(__builtin_amdgcn_cvt_sr_bf8_f32, "ifiiIi", "nc", "fp8-insts") TARGET_BUILTIN(__builtin_amdgcn_cvt_sr_fp8_f32, "ifiiIi", "nc", "fp8-insts") +// OpenCL +LANGBUILTIN(printf, "icC*4.", "fp:0:", ALL_OCL_LANGUAGES) arsenm wrote: Why do you need to define a new target builtin, just to hack it to the generic lang builtin later? Just handle the existing printf builtin? https://github.com/llvm/llvm-project/pull/72554 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Introduce _LIBUNWIND_TRACE_DWARF_EVAL for increased baremetal friendliness (PR #72040)
@@ -381,24 +381,22 @@ typename A::pint_t DwarfInstructions::evaluateExpression(pint_t expression, A , const R , pint_t initialStackValue) { - const bool log = false; pint_t p = expression; pint_t expressionEnd = expression + 20; // temp, until len read pint_t length = (pint_t)addressSpace.getULEB128(p, expressionEnd); expressionEnd = p + length; - if (log) -fprintf(stderr, "evaluateExpression(): length=%" PRIu64 "\n", -(uint64_t)length); + _LIBUNWIND_TRACE_DWARF_EVAL("evaluateExpression(): length=%" PRIu64 "\n", + (uint64_t)length); pint_t stack[100]; pint_t *sp = stack; *(++sp) = initialStackValue; while (p < expressionEnd) { -if (log) { - for (pint_t *t = sp; t > stack; --t) { -fprintf(stderr, "sp[] = 0x%" PRIx64 "\n", (uint64_t)(*t)); - } +#if _LIBUNWIND_TRACING_DWARF_EVAL ldionne wrote: We normally don't output like that from the tests, but I am not aware of any mechanism available from libunwind to conditionally output information. FWIW I think it would be reasonable for your patch not to change that test (even though it would be a barrier for porting the tests to bare metal). https://github.com/llvm/llvm-project/pull/72040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libcxxabi] Remove deprecated warning from cmake files (PR #72595)
https://github.com/ldionne closed https://github.com/llvm/llvm-project/pull/72595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] 09ac2ec - Remove deprecated warning from cmake files (#72595)
Author: Tacet Date: 2023-11-16T21:20:12-05:00 New Revision: 09ac2ec3ad368f82e6b0814a6427b2cb93591ef6 URL: https://github.com/llvm/llvm-project/commit/09ac2ec3ad368f82e6b0814a6427b2cb93591ef6 DIFF: https://github.com/llvm/llvm-project/commit/09ac2ec3ad368f82e6b0814a6427b2cb93591ef6.diff LOG: Remove deprecated warning from cmake files (#72595) `LIBCXXABI_SYSROOT`, `LIBCXXABI_TARGET_TRIPLE` and `LIBCXXABI_GCC_TOOLCHAIN` are not supported anymore. Based on the comment, the warning should be removed after branching for LLVM 15. Added: Modified: libcxxabi/CMakeLists.txt libunwind/CMakeLists.txt Removed: diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index 6fd4f02c750f5bb..efe830bd2ad6659 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -88,11 +88,6 @@ else() set(LIBCXXABI_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") endif() -# TODO: Remove this after branching for LLVM 15 -if(LIBCXXABI_SYSROOT OR LIBCXXABI_TARGET_TRIPLE OR LIBCXXABI_GCC_TOOLCHAIN) - message(WARNING "LIBCXXABI_SYSROOT, LIBCXXABI_TARGET_TRIPLE and LIBCXXABI_GCC_TOOLCHAIN are not supported anymore, please use the native CMake equivalents instead") -endif() - set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.") set(LIBCXXABI_LIBRARY_VERSION "1.0" CACHE STRING "Version of libc++abi. This will be reflected in the name of the shared \ diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 84f8ce296a7410b..248e888619e40ba 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -63,11 +63,6 @@ cmake_dependent_option(LIBUNWIND_INSTALL_SHARED_LIBRARY "Install the shared libunwind library." ON "LIBUNWIND_ENABLE_SHARED;LIBUNWIND_INSTALL_LIBRARY" OFF) -# TODO: Remove this after branching for LLVM 15 -if(LIBUNWIND_SYSROOT OR LIBUNWIND_TARGET_TRIPLE OR LIBUNWIND_GCC_TOOLCHAIN) - message(WARNING "LIBUNWIND_SYSROOT, LIBUNWIND_TARGET_TRIPLE and LIBUNWIND_GCC_TOOLCHAIN are not supported anymore, please use the native CMake equivalents instead") -endif() - if(MINGW) set(LIBUNWIND_DEFAULT_TEST_CONFIG "llvm-libunwind-mingw.cfg.in") elseif (LIBUNWIND_ENABLE_SHARED) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libcxxabi] Remove deprecated warning from cmake files (PR #72595)
https://github.com/ldionne approved this pull request. Thanks a bunch for the cleanup! We often forget these but it always feels great to find one and clean it up! https://github.com/llvm/llvm-project/pull/72595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libcxxabi] Remove deprecated warning from cmake files (PR #72595)
https://github.com/AdvenamTacet edited https://github.com/llvm/llvm-project/pull/72595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libcxxabi] [NFC] Remove deprecated warning from cmake files (PR #72595)
llvmbot wrote: @llvm/pr-subscribers-libunwind @llvm/pr-subscribers-libcxxabi Author: Tacet (AdvenamTacet) Changes `LIBCXXABI_SYSROOT`, `LIBCXXABI_TARGET_TRIPLE` and `LIBCXXABI_GCC_TOOLCHAIN` are not supported anymore. Based on the comment, the warning should be removed after branching for LLVM 15. --- Full diff: https://github.com/llvm/llvm-project/pull/72595.diff 2 Files Affected: - (modified) libcxxabi/CMakeLists.txt (-5) - (modified) libunwind/CMakeLists.txt (-5) ``diff diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index 6fd4f02c750f5bb..efe830bd2ad6659 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -88,11 +88,6 @@ else() set(LIBCXXABI_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") endif() -# TODO: Remove this after branching for LLVM 15 -if(LIBCXXABI_SYSROOT OR LIBCXXABI_TARGET_TRIPLE OR LIBCXXABI_GCC_TOOLCHAIN) - message(WARNING "LIBCXXABI_SYSROOT, LIBCXXABI_TARGET_TRIPLE and LIBCXXABI_GCC_TOOLCHAIN are not supported anymore, please use the native CMake equivalents instead") -endif() - set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.") set(LIBCXXABI_LIBRARY_VERSION "1.0" CACHE STRING "Version of libc++abi. This will be reflected in the name of the shared \ diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 84f8ce296a7410b..248e888619e40ba 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -63,11 +63,6 @@ cmake_dependent_option(LIBUNWIND_INSTALL_SHARED_LIBRARY "Install the shared libunwind library." ON "LIBUNWIND_ENABLE_SHARED;LIBUNWIND_INSTALL_LIBRARY" OFF) -# TODO: Remove this after branching for LLVM 15 -if(LIBUNWIND_SYSROOT OR LIBUNWIND_TARGET_TRIPLE OR LIBUNWIND_GCC_TOOLCHAIN) - message(WARNING "LIBUNWIND_SYSROOT, LIBUNWIND_TARGET_TRIPLE and LIBUNWIND_GCC_TOOLCHAIN are not supported anymore, please use the native CMake equivalents instead") -endif() - if(MINGW) set(LIBUNWIND_DEFAULT_TEST_CONFIG "llvm-libunwind-mingw.cfg.in") elseif (LIBUNWIND_ENABLE_SHARED) `` https://github.com/llvm/llvm-project/pull/72595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libcxxabi] [NFC] Remove deprecated warning from cmake files (PR #72595)
https://github.com/AdvenamTacet created https://github.com/llvm/llvm-project/pull/72595 `LIBCXXABI_SYSROOT`, `LIBCXXABI_TARGET_TRIPLE` and `LIBCXXABI_GCC_TOOLCHAIN` are not supported anymore. Based on the comment, the warning should be removed after branching for LLVM 15. >From 5ac6d886dfcbcec26d34ef4b086f4e077dee2410 Mon Sep 17 00:00:00 2001 From: Advenam Tacet Date: Fri, 17 Nov 2023 03:09:59 +0100 Subject: [PATCH] [NFC] Remove deprecated warning from cmake files `LIBCXXABI_SYSROOT`, `LIBCXXABI_TARGET_TRIPLE` and `LIBCXXABI_GCC_TOOLCHAIN` are not supported anymore. Based on the comment, the warning should be removed after branching for LLVM 15. --- libcxxabi/CMakeLists.txt | 5 - libunwind/CMakeLists.txt | 5 - 2 files changed, 10 deletions(-) diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index 6fd4f02c750f5bb..efe830bd2ad6659 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -88,11 +88,6 @@ else() set(LIBCXXABI_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") endif() -# TODO: Remove this after branching for LLVM 15 -if(LIBCXXABI_SYSROOT OR LIBCXXABI_TARGET_TRIPLE OR LIBCXXABI_GCC_TOOLCHAIN) - message(WARNING "LIBCXXABI_SYSROOT, LIBCXXABI_TARGET_TRIPLE and LIBCXXABI_GCC_TOOLCHAIN are not supported anymore, please use the native CMake equivalents instead") -endif() - set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.") set(LIBCXXABI_LIBRARY_VERSION "1.0" CACHE STRING "Version of libc++abi. This will be reflected in the name of the shared \ diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 84f8ce296a7410b..248e888619e40ba 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -63,11 +63,6 @@ cmake_dependent_option(LIBUNWIND_INSTALL_SHARED_LIBRARY "Install the shared libunwind library." ON "LIBUNWIND_ENABLE_SHARED;LIBUNWIND_INSTALL_LIBRARY" OFF) -# TODO: Remove this after branching for LLVM 15 -if(LIBUNWIND_SYSROOT OR LIBUNWIND_TARGET_TRIPLE OR LIBUNWIND_GCC_TOOLCHAIN) - message(WARNING "LIBUNWIND_SYSROOT, LIBUNWIND_TARGET_TRIPLE and LIBUNWIND_GCC_TOOLCHAIN are not supported anymore, please use the native CMake equivalents instead") -endif() - if(MINGW) set(LIBUNWIND_DEFAULT_TEST_CONFIG "llvm-libunwind-mingw.cfg.in") elseif (LIBUNWIND_ENABLE_SHARED) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix crashes in AlignArrayOfStructures (PR #72520)
https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/72520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Introduce _LIBUNWIND_TRACE_DWARF_EVAL for increased baremetal friendliness (PR #72040)
https://github.com/michael-kenzel edited https://github.com/llvm/llvm-project/pull/72040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Support -mcmodel= for LoongArch (PR #72514)
SixWeining wrote: > > And AFAIK, gcc side doesn't plan to implement the "large" code model. > > Why did we distinguish "large" and "extreme" in the first place? If we don't > need a different "large" code model then I guess we should make it an alias > of "extreme" for GCC too. @ChenghuaXu @chenglulu326 What do you think? https://github.com/llvm/llvm-project/pull/72514 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LinkerWrapper] Support device binaries in multiple link jobs (PR #72442)
@@ -156,19 +157,51 @@ class OffloadBinary : public Binary { /// owns its memory. class OffloadFile : public OwningBinary { public: + /// An ordered pair of the target triple and the architecture. using TargetID = std::pair; OffloadFile(std::unique_ptr Binary, std::unique_ptr Buffer) : OwningBinary(std::move(Binary), std::move(Buffer)) {} + Expected copy() const { +std::unique_ptr Buffer = MemoryBuffer::getMemBufferCopy( +getBinary()->getMemoryBufferRef().getBuffer()); +auto NewBinaryOrErr = OffloadBinary::create(*Buffer); +if (!NewBinaryOrErr) + return NewBinaryOrErr.takeError(); +return OffloadFile(std::move(*NewBinaryOrErr), std::move(Buffer)); + } + /// We use the Triple and Architecture pair to group linker inputs together. /// This conversion function lets us use these inputs in a hash-map. operator TargetID() const { return std::make_pair(getBinary()->getTriple(), getBinary()->getArch()); } }; +/// Queries if the target \p LHS is compatible with \p RHS for linking purposes. +inline bool areTargetsCompatible(const OffloadFile::TargetID LHS, + const OffloadFile::TargetID RHS) { + if (LHS == RHS) +return true; + + // If the target is AMD we check the target IDs for compatibility. A target id + // is a string conforming to the folowing BNF syntax: + // + // target-id ::= ' ( : ( '+' | '-' ) )*' + // + // This is used to link mutually compatible architectures together. + llvm::Triple T(LHS.first); + if (!T.isAMDGPU()) +return false; + + // The targets are compatible if the architecture is a subset of the other. + if (RHS.second.contains(LHS.second)) +return true; + return false; arsenm wrote: return RHS.second.contains https://github.com/llvm/llvm-project/pull/72442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Introduce _LIBUNWIND_TRACE_DWARF_EVAL for increased baremetal friendliness (PR #72040)
https://github.com/michael-kenzel converted_to_draft https://github.com/llvm/llvm-project/pull/72040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Introduce _LIBUNWIND_TRACE_DWARF_EVAL for increased baremetal friendliness (PR #72040)
https://github.com/michael-kenzel edited https://github.com/llvm/llvm-project/pull/72040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Introduce _LIBUNWIND_TRACE_DWARF_EVAL for increased baremetal friendliness (PR #72040)
https://github.com/michael-kenzel edited https://github.com/llvm/llvm-project/pull/72040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Introduce _LIBUNWIND_TRACE_DWARF_EVAL for increased baremetal friendliness (PR #72040)
https://github.com/michael-kenzel edited https://github.com/llvm/llvm-project/pull/72040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [llvm] Remove unused LoopInfo from InlineSpiller and SpillPlacement (NFC) (PR #71874)
https://github.com/arsenm approved this pull request. https://github.com/llvm/llvm-project/pull/71874 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Introduce _LIBUNWIND_TRACE_DWARF_EVAL for increased baremetal friendliness (PR #72040)
https://github.com/michael-kenzel edited https://github.com/llvm/llvm-project/pull/72040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Introduce _LIBUNWIND_TRACE_DWARF_EVAL for increased baremetal friendliness (PR #72040)
@@ -381,24 +381,22 @@ typename A::pint_t DwarfInstructions::evaluateExpression(pint_t expression, A , const R , pint_t initialStackValue) { - const bool log = false; pint_t p = expression; pint_t expressionEnd = expression + 20; // temp, until len read pint_t length = (pint_t)addressSpace.getULEB128(p, expressionEnd); expressionEnd = p + length; - if (log) -fprintf(stderr, "evaluateExpression(): length=%" PRIu64 "\n", -(uint64_t)length); + _LIBUNWIND_TRACE_DWARF_EVAL("evaluateExpression(): length=%" PRIu64 "\n", + (uint64_t)length); pint_t stack[100]; pint_t *sp = stack; *(++sp) = initialStackValue; while (p < expressionEnd) { -if (log) { - for (pint_t *t = sp; t > stack; --t) { -fprintf(stderr, "sp[] = 0x%" PRIx64 "\n", (uint64_t)(*t)); - } +#if _LIBUNWIND_TRACING_DWARF_EVAL michael-kenzel wrote: Actually, there seems to be more of the same: https://github.com/llvm/llvm-project/blob/d97981c98a70ebeaa8901f34921b0a69a068ff5d/libunwind/src/UnwindCursor.hpp#L1714 I just overlooked that since that path wasn't being built in my setup. I'll update this patch to do the same thing for this code too and remove the `` includes. https://github.com/llvm/llvm-project/pull/72040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Introduce _LIBUNWIND_TRACE_DWARF_EVAL for increased baremetal friendliness (PR #72040)
https://github.com/michael-kenzel edited https://github.com/llvm/llvm-project/pull/72040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Introduce _LIBUNWIND_TRACE_DWARF_EVAL for increased baremetal friendliness (PR #72040)
@@ -381,24 +381,22 @@ typename A::pint_t DwarfInstructions::evaluateExpression(pint_t expression, A , const R , pint_t initialStackValue) { - const bool log = false; pint_t p = expression; pint_t expressionEnd = expression + 20; // temp, until len read pint_t length = (pint_t)addressSpace.getULEB128(p, expressionEnd); expressionEnd = p + length; - if (log) -fprintf(stderr, "evaluateExpression(): length=%" PRIu64 "\n", -(uint64_t)length); + _LIBUNWIND_TRACE_DWARF_EVAL("evaluateExpression(): length=%" PRIu64 "\n", + (uint64_t)length); pint_t stack[100]; pint_t *sp = stack; *(++sp) = initialStackValue; while (p < expressionEnd) { -if (log) { - for (pint_t *t = sp; t > stack; --t) { -fprintf(stderr, "sp[] = 0x%" PRIx64 "\n", (uint64_t)(*t)); - } +#if _LIBUNWIND_TRACING_DWARF_EVAL ldionne wrote: Yeah, I think that sounds like the best approach to me (i.e. removing `` everywhere except in `"config.h"`). You can do it in this patch or in a follow-up, I don't mind. https://github.com/llvm/llvm-project/pull/72040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang] [InstCombine] Convert or concat to fshl if opposite or concat exists (PR #68502)
HaohaiWen wrote: I'd like to merge it. Please let me know if you have more concern. https://github.com/llvm/llvm-project/pull/68502 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Introduce _LIBUNWIND_TRACE_DWARF_EVAL for increased baremetal friendliness (PR #72040)
https://github.com/michael-kenzel edited https://github.com/llvm/llvm-project/pull/72040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Introduce _LIBUNWIND_TRACE_DWARF_EVAL for increased baremetal friendliness (PR #72040)
@@ -381,24 +381,22 @@ typename A::pint_t DwarfInstructions::evaluateExpression(pint_t expression, A , const R , pint_t initialStackValue) { - const bool log = false; pint_t p = expression; pint_t expressionEnd = expression + 20; // temp, until len read pint_t length = (pint_t)addressSpace.getULEB128(p, expressionEnd); expressionEnd = p + length; - if (log) -fprintf(stderr, "evaluateExpression(): length=%" PRIu64 "\n", -(uint64_t)length); + _LIBUNWIND_TRACE_DWARF_EVAL("evaluateExpression(): length=%" PRIu64 "\n", + (uint64_t)length); pint_t stack[100]; pint_t *sp = stack; *(++sp) = initialStackValue; while (p < expressionEnd) { -if (log) { - for (pint_t *t = sp; t > stack; --t) { -fprintf(stderr, "sp[] = 0x%" PRIx64 "\n", (uint64_t)(*t)); - } +#if _LIBUNWIND_TRACING_DWARF_EVAL michael-kenzel wrote: good question. I think it might be a good idea to completely remove `#include ` everywhere unless some logging is active. I can try to add that. Though maybe this should be a separate PR since I think if we do this, we should do this in the library as a whole? It seems to be included in a majority of the files. Though all those includes are kinda redundant since they all include `"config.h"` anyways, which already includes ``. I guess we could just conditionally include `` in `"config.h"` only when logging is active and remove the include everywhere else? https://github.com/llvm/llvm-project/pull/72040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Introduce scoped variants of GNU atomic functions (PR #72280)
jhuber6 wrote: > > The underlying implementation is a string literal in the LLVM syncscope > > argument, but the problem is that this isn't standardized at all and varies > > between backends potentially > > We don't have to use the same set of strings as syncscope if that doesn't > make sense. I don't think there's much of a point to making them strings if it's not directly invoking the syncscope name for the backend. Realistically as long as we give them descriptive names we can just ignore ones that don't apply on various targets. Like right now you can use these scoped variants in x64 code but it has no effect. Either that or we could use logic to go to the next heirarchy level that makes sense. As always, naming stuff is hard. https://github.com/llvm/llvm-project/pull/72280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Introduce scoped variants of GNU atomic functions (PR #72280)
efriedma-quic wrote: > The underlying implementation is a string literal in the LLVM syncscope > argument, but the problem is that this isn't standardized at all and varies > between backends potentially We don't have to use the same set of strings as syncscope if that doesn't make sense. https://github.com/llvm/llvm-project/pull/72280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 49795d2 - [Driver][NFC] A bit more const for OpenBSD and DragonFly
Author: Brad Smith Date: 2023-11-15T19:36:56-05:00 New Revision: 49795d27761b9f398302354acd30980a319b1502 URL: https://github.com/llvm/llvm-project/commit/49795d27761b9f398302354acd30980a319b1502 DIFF: https://github.com/llvm/llvm-project/commit/49795d27761b9f398302354acd30980a319b1502.diff LOG: [Driver][NFC] A bit more const for OpenBSD and DragonFly Added: Modified: clang/lib/Driver/ToolChains/DragonFly.cpp clang/lib/Driver/ToolChains/OpenBSD.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/DragonFly.cpp b/clang/lib/Driver/ToolChains/DragonFly.cpp index b13449bf778fa9f..9942fc632e0a917 100644 --- a/clang/lib/Driver/ToolChains/DragonFly.cpp +++ b/clang/lib/Driver/ToolChains/DragonFly.cpp @@ -57,11 +57,11 @@ void dragonfly::Linker::ConstructJob(Compilation , const JobAction , const auto = static_cast(getToolChain()); const Driver = ToolChain.getDriver(); const llvm::Triple::ArchType Arch = ToolChain.getArch(); + const bool Static = Args.hasArg(options::OPT_static); + const bool Shared = Args.hasArg(options::OPT_shared); + const bool Profiling = Args.hasArg(options::OPT_pg); + const bool Pie = Args.hasArg(options::OPT_pie); ArgStringList CmdArgs; - bool Static = Args.hasArg(options::OPT_static); - bool Shared = Args.hasArg(options::OPT_shared); - bool Profiling = Args.hasArg(options::OPT_pg); - bool Pie = Args.hasArg(options::OPT_pie); if (!D.SysRoot.empty()) CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot)); diff --git a/clang/lib/Driver/ToolChains/OpenBSD.cpp b/clang/lib/Driver/ToolChains/OpenBSD.cpp index 5d06cd8ab0bad16..c8f02161d8311e3 100644 --- a/clang/lib/Driver/ToolChains/OpenBSD.cpp +++ b/clang/lib/Driver/ToolChains/OpenBSD.cpp @@ -33,9 +33,9 @@ void openbsd::Assembler::ConstructJob(Compilation , const JobAction , const auto = static_cast(getToolChain()); const Driver = ToolChain.getDriver(); const llvm::Triple = ToolChain.getTriple(); + ArgStringList CmdArgs; claimNoWarnArgs(Args); - ArgStringList CmdArgs; switch (ToolChain.getArch()) { case llvm::Triple::x86: @@ -112,13 +112,13 @@ void openbsd::Linker::ConstructJob(Compilation , const JobAction , const auto = static_cast(getToolChain()); const Driver = ToolChain.getDriver(); const llvm::Triple::ArchType Arch = ToolChain.getArch(); - ArgStringList CmdArgs; - bool Static = Args.hasArg(options::OPT_static); - bool Shared = Args.hasArg(options::OPT_shared); - bool Profiling = Args.hasArg(options::OPT_pg); - bool Pie = Args.hasArg(options::OPT_pie); - bool Nopie = Args.hasArg(options::OPT_nopie); + const bool Static = Args.hasArg(options::OPT_static); + const bool Shared = Args.hasArg(options::OPT_shared); + const bool Profiling = Args.hasArg(options::OPT_pg); + const bool Pie = Args.hasArg(options::OPT_pie); + const bool Nopie = Args.hasArg(options::OPT_nopie); const bool Relocatable = Args.hasArg(options::OPT_r); + ArgStringList CmdArgs; // Silence warning for "clang -g foo.o -o foo" Args.ClaimAllArgs(options::OPT_g_Group); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[compiler-rt] [clang] [lldb] [llvm] [libcxx] [lld] [mlir] [clang-tools-extra] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)
ldionne wrote: Gentle ping. There's outstanding feedback to address on this review. @ZijunZhaoCCK if you don't think you'll have time to pursue this PR anymore, it's all good but please let us know so we can assign it to someone else! https://github.com/llvm/llvm-project/pull/66963 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Introduce _LIBUNWIND_TRACE_DWARF_EVAL for increased baremetal friendliness (PR #72040)
https://github.com/ldionne approved this pull request. This looks like an improvement to me. I have a comment/question about the `stdio.h` include which is now dangling, but apart from that I'm happy with the patch. https://github.com/llvm/llvm-project/pull/72040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Introduce _LIBUNWIND_TRACE_DWARF_EVAL for increased baremetal friendliness (PR #72040)
@@ -381,24 +381,22 @@ typename A::pint_t DwarfInstructions::evaluateExpression(pint_t expression, A , const R , pint_t initialStackValue) { - const bool log = false; pint_t p = expression; pint_t expressionEnd = expression + 20; // temp, until len read pint_t length = (pint_t)addressSpace.getULEB128(p, expressionEnd); expressionEnd = p + length; - if (log) -fprintf(stderr, "evaluateExpression(): length=%" PRIu64 "\n", -(uint64_t)length); + _LIBUNWIND_TRACE_DWARF_EVAL("evaluateExpression(): length=%" PRIu64 "\n", + (uint64_t)length); pint_t stack[100]; pint_t *sp = stack; *(++sp) = initialStackValue; while (p < expressionEnd) { -if (log) { - for (pint_t *t = sp; t > stack; --t) { -fprintf(stderr, "sp[] = 0x%" PRIx64 "\n", (uint64_t)(*t)); - } +#if _LIBUNWIND_TRACING_DWARF_EVAL ldionne wrote: Not attached to this line: do we want to remove the `` include in this file then? But we'd need to include it from `config.h`? https://github.com/llvm/llvm-project/pull/72040 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix crashes in AlignArrayOfStructures (PR #72520)
@@ -1316,6 +1316,8 @@ void WhitespaceManager::alignArrayInitializersRightJustified( auto Offset = std::distance(Cells.begin(), CellIter); for (const auto *Next = CellIter->NextColumnElement; Next; Next = Next->NextColumnElement) { + if (RowCount >= CellDescs.CellCounts.size()) +break; owenca wrote: I intentionally made it the same as lines 1384-1385 below so that lines 1315-1323 would remain copy-pasted from lines 1380-1388. This will make future refactoring easier. https://github.com/llvm/llvm-project/pull/72520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Handle lambdas in QualifierAlignment (PR #72456)
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/72456 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f0ad9ea - [clang-format] Handle lambdas in QualifierAlignment (#72456)
Author: Owen Pan Date: 2023-11-16T15:00:09-08:00 New Revision: f0ad9ea36ad65cec8c5e5d1d59c00192b87f287d URL: https://github.com/llvm/llvm-project/commit/f0ad9ea36ad65cec8c5e5d1d59c00192b87f287d DIFF: https://github.com/llvm/llvm-project/commit/f0ad9ea36ad65cec8c5e5d1d59c00192b87f287d.diff LOG: [clang-format] Handle lambdas in QualifierAlignment (#72456) Fixed #62780. Added: Modified: clang/lib/Format/QualifierAlignmentFixer.cpp clang/lib/Format/QualifierAlignmentFixer.h clang/unittests/Format/QualifierFixerTest.cpp Removed: diff --git a/clang/lib/Format/QualifierAlignmentFixer.cpp b/clang/lib/Format/QualifierAlignmentFixer.cpp index e2fab1c1e3c2a37..84941746f0df71b 100644 --- a/clang/lib/Format/QualifierAlignmentFixer.cpp +++ b/clang/lib/Format/QualifierAlignmentFixer.cpp @@ -535,14 +535,21 @@ LeftRightQualifierAlignmentFixer::analyze( SmallVectorImpl , FormatTokenLexer ) { tooling::Replacements Fixes; - const AdditionalKeywords = Tokens.getKeywords(); - const SourceManager = Env.getSourceManager(); AffectedRangeMgr.computeAffectedLines(AnnotatedLines); + fixQualifierAlignment(AnnotatedLines, Tokens, Fixes); + return {Fixes, 0}; +} +void LeftRightQualifierAlignmentFixer::fixQualifierAlignment( +SmallVectorImpl , FormatTokenLexer , +tooling::Replacements ) { + const AdditionalKeywords = Tokens.getKeywords(); + const SourceManager = Env.getSourceManager(); tok::TokenKind QualifierToken = getTokenFromQualifier(Qualifier); assert(QualifierToken != tok::identifier && "Unrecognised Qualifier"); for (AnnotatedLine *Line : AnnotatedLines) { +fixQualifierAlignment(Line->Children, Tokens, Fixes); if (!Line->Affected || Line->InPPDirective) continue; FormatToken *First = Line->First; @@ -565,7 +572,6 @@ LeftRightQualifierAlignmentFixer::analyze( } } } - return {Fixes, 0}; } void prepareLeftRightOrderingForQualifierAlignmentFixer( diff --git a/clang/lib/Format/QualifierAlignmentFixer.h b/clang/lib/Format/QualifierAlignmentFixer.h index a72d135179f1ece..e922d8005595103 100644 --- a/clang/lib/Format/QualifierAlignmentFixer.h +++ b/clang/lib/Format/QualifierAlignmentFixer.h @@ -52,6 +52,10 @@ class LeftRightQualifierAlignmentFixer : public TokenAnalyzer { static tok::TokenKind getTokenFromQualifier(const std::string ); + void fixQualifierAlignment(SmallVectorImpl , + FormatTokenLexer , + tooling::Replacements ); + const FormatToken *analyzeRight(const SourceManager , const AdditionalKeywords , tooling::Replacements , diff --git a/clang/unittests/Format/QualifierFixerTest.cpp b/clang/unittests/Format/QualifierFixerTest.cpp index a56323a88f4a04d..324366ca7f5e511 100644 --- a/clang/unittests/Format/QualifierFixerTest.cpp +++ b/clang/unittests/Format/QualifierFixerTest.cpp @@ -357,6 +357,9 @@ TEST_F(QualifierFixerTest, RightQualifier) { verifyFormat("void f(std::integral auto const );", "void f(const std::integral auto );", Style); + verifyFormat("auto lambda = [] { int const i = 0; };", + "auto lambda = [] { const int i = 0; };", Style); + verifyFormat("Foo const> P;\n#if 0\n#else\n#endif", "Foo> P;\n#if 0\n#else\n#endif", Style); @@ -663,6 +666,9 @@ TEST_F(QualifierFixerTest, LeftQualifier) { verifyFormat("void f(const std::integral auto );", "void f(std::integral auto const );", Style); + verifyFormat("auto lambda = [] { const int i = 0; };", + "auto lambda = [] { int const i = 0; };", Style); + verifyFormat("Foo> P;\n#if 0\n#else\n#endif", "Foo const> P;\n#if 0\n#else\n#endif", Style); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Make ELF -nopie specific to OpenBSD (PR #72578)
brad0 wrote: -nopie is for the linker. We only use -fno-pie for the compiler. https://github.com/llvm/llvm-project/pull/72578 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AVR] make the AVR ABI Swift compatible (PR #72298)
rjmccall wrote: Right, that would be the way to test it. I don't know much about AVR, but you should also look at some of the parameters to the lowering (e.g. how many max values it's okay to break an aggregate into) and make sure you're happy with them. https://github.com/llvm/llvm-project/pull/72298 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
@@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -verify -fsyntax-only %s shafik wrote: Normally we put lone tests for a specific bug report in its own file e.g. GH70735.cpp for this case or we find a test that covers a similar area and put the test in a namespace named after the issue e.g. GH70735. https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
https://github.com/shafik commented: This makes some sense but I am not familiar enough with this area. https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix finding instantiated decls for class template specializations during instantiation (PR #72346)
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/72346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AVR] make the AVR ABI Swift compatible (PR #72298)
efriedma-quic wrote: See also #71986 https://github.com/llvm/llvm-project/pull/72298 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AVR] make the AVR ABI Swift compatible (PR #72298)
efriedma-quic wrote: Can you not test this by checking an `__attribute__((swiftcall))` function works in C? https://github.com/llvm/llvm-project/pull/72298 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Make ELF -nopie specific to OpenBSD (PR #72578)
llvmbot wrote: @llvm/pr-subscribers-clang-driver Author: Fangrui Song (MaskRay) Changes -no-pie[1]/-nopie is rarely used and among the rare uses almost everwhere uses -no-pie, since GCC does not recognize -nopie. However, OpenBSD seems to prefer -nopie. Therefore, make -nopie specific to OpenBSD to prevent newer ToolChains (Solaris, SerenityOS) from cargo culting and copying -nopie. [1]: https://reviews.llvm.org/D35462 --- Full diff: https://github.com/llvm/llvm-project/pull/72578.diff 6 Files Affected: - (modified) clang/include/clang/Driver/Options.td (+1-1) - (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+3-7) - (modified) clang/lib/Driver/ToolChains/OpenBSD.cpp (+1-1) - (modified) clang/lib/Driver/ToolChains/Solaris.cpp (+2-5) - (modified) clang/test/Driver/android-pie.c (-2) - (modified) clang/test/Driver/pic.c (+3-3) ``diff diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 811550416110b3d..654bf8be78d6259 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5137,7 +5137,7 @@ def nofixprebinding : Flag<["-"], "nofixprebinding">; def nolibc : Flag<["-"], "nolibc">; def nomultidefs : Flag<["-"], "nomultidefs">; def nopie : Flag<["-"], "nopie">, Visibility<[ClangOption, FlangOption]>; -def no_pie : Flag<["-"], "no-pie">, Visibility<[ClangOption, FlangOption]>, Alias; +def no_pie : Flag<["-"], "no-pie">, Visibility<[ClangOption, FlangOption]>; def noprebind : Flag<["-"], "noprebind">; def noprofilelib : Flag<["-"], "noprofilelib">; def noseglinkedit : Flag<["-"], "noseglinkedit">; diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index ba95ce9c5a28153..2b1e8f02cf66388 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -294,9 +294,7 @@ static const char *getLDMOption(const llvm::Triple , const ArgList ) { static bool getStaticPIE(const ArgList , const ToolChain ) { bool HasStaticPIE = Args.hasArg(options::OPT_static_pie); - // -no-pie is an alias for -nopie. So, handling -nopie takes care of - // -no-pie as well. - if (HasStaticPIE && Args.hasArg(options::OPT_nopie)) { + if (HasStaticPIE && Args.hasArg(options::OPT_no_pie)) { const Driver = TC.getDriver(); const llvm::opt::OptTable = D.getOpts(); StringRef StaticPIEName = Opts.getOptionName(options::OPT_static_pie); @@ -443,10 +441,8 @@ void tools::gnutools::Linker::ConstructJob(Compilation , const JobAction , if (Args.hasArg(options::OPT_rdynamic)) CmdArgs.push_back("-export-dynamic"); if (!IsShared) { - Arg *A = Args.getLastArg(options::OPT_pie, options::OPT_no_pie, - options::OPT_nopie); - IsPIE = A ? A->getOption().matches(options::OPT_pie) -: ToolChain.isPIEDefault(Args); + IsPIE = Args.hasFlag(options::OPT_pie, options::OPT_no_pie, + ToolChain.isPIEDefault(Args)); if (IsPIE) CmdArgs.push_back("-pie"); CmdArgs.push_back("-dynamic-linker"); diff --git a/clang/lib/Driver/ToolChains/OpenBSD.cpp b/clang/lib/Driver/ToolChains/OpenBSD.cpp index 5d06cd8ab0bad16..e883838e2dc9317 100644 --- a/clang/lib/Driver/ToolChains/OpenBSD.cpp +++ b/clang/lib/Driver/ToolChains/OpenBSD.cpp @@ -117,7 +117,7 @@ void openbsd::Linker::ConstructJob(Compilation , const JobAction , bool Shared = Args.hasArg(options::OPT_shared); bool Profiling = Args.hasArg(options::OPT_pg); bool Pie = Args.hasArg(options::OPT_pie); - bool Nopie = Args.hasArg(options::OPT_nopie); + bool Nopie = Args.hasArg(options::OPT_no_pie, options::OPT_nopie); const bool Relocatable = Args.hasArg(options::OPT_r); // Silence warning for "clang -g foo.o -o foo" diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp b/clang/lib/Driver/ToolChains/Solaris.cpp index 96757f07a54974f..485730da7df1f8c 100644 --- a/clang/lib/Driver/ToolChains/Solaris.cpp +++ b/clang/lib/Driver/ToolChains/Solaris.cpp @@ -49,11 +49,8 @@ static bool getPIE(const ArgList , const ToolChain ) { Args.hasArg(options::OPT_r)) return false; - Arg *A = Args.getLastArg(options::OPT_pie, options::OPT_no_pie, - options::OPT_nopie); - if (!A) -return TC.isPIEDefault(Args); - return A->getOption().matches(options::OPT_pie); + return Args.hasFlag(options::OPT_pie, options::OPT_no_pie, + TC.isPIEDefault(Args)); } // FIXME: Need to handle CLANG_DEFAULT_LINKER here? diff --git a/clang/test/Driver/android-pie.c b/clang/test/Driver/android-pie.c index 8620e185654586c..01720edf98fb170 100644 --- a/clang/test/Driver/android-pie.c +++ b/clang/test/Driver/android-pie.c @@ -36,8 +36,6 @@ // RUN: %clang %s -### -o %t.o 2>&1 -no-pie --target=arm-linux-androideabi24 \ // RUN: | FileCheck --check-prefix=NO-PIE %s -// RUN: %clang %s -### -o %t.o 2>&1 -nopie --target=arm-linux-androideabi24 \ -// RUN: |
[clang] [Driver] Make ELF -nopie specific to OpenBSD (PR #72578)
https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/72578 -no-pie[1]/-nopie is rarely used and among the rare uses almost everwhere uses -no-pie, since GCC does not recognize -nopie. However, OpenBSD seems to prefer -nopie. Therefore, make -nopie specific to OpenBSD to prevent newer ToolChains (Solaris, SerenityOS) from cargo culting and copying -nopie. [1]: https://reviews.llvm.org/D35462 >From 2135d365c1820a23826d16293cc59a65b0ae847e Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 16 Nov 2023 14:09:09 -0800 Subject: [PATCH] [Driver] Make ELF -nopie specific to OpenBSD -no-pie[1]/-nopie is rarely used and among the rare uses almost everwhere uses -no-pie, since GCC does not recognize -nopie. However, OpenBSD seems to prefer -nopie. Therefore, make -nopie specific to OpenBSD to prevent newer ToolChains (Solaris, SerenityOS) from cargo culting and copying -nopie. [1]: https://reviews.llvm.org/D35462 --- clang/include/clang/Driver/Options.td | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 10 +++--- clang/lib/Driver/ToolChains/OpenBSD.cpp | 2 +- clang/lib/Driver/ToolChains/Solaris.cpp | 7 ++- clang/test/Driver/android-pie.c | 2 -- clang/test/Driver/pic.c | 6 +++--- 6 files changed, 10 insertions(+), 19 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 811550416110b3d..654bf8be78d6259 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5137,7 +5137,7 @@ def nofixprebinding : Flag<["-"], "nofixprebinding">; def nolibc : Flag<["-"], "nolibc">; def nomultidefs : Flag<["-"], "nomultidefs">; def nopie : Flag<["-"], "nopie">, Visibility<[ClangOption, FlangOption]>; -def no_pie : Flag<["-"], "no-pie">, Visibility<[ClangOption, FlangOption]>, Alias; +def no_pie : Flag<["-"], "no-pie">, Visibility<[ClangOption, FlangOption]>; def noprebind : Flag<["-"], "noprebind">; def noprofilelib : Flag<["-"], "noprofilelib">; def noseglinkedit : Flag<["-"], "noseglinkedit">; diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index ba95ce9c5a28153..2b1e8f02cf66388 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -294,9 +294,7 @@ static const char *getLDMOption(const llvm::Triple , const ArgList ) { static bool getStaticPIE(const ArgList , const ToolChain ) { bool HasStaticPIE = Args.hasArg(options::OPT_static_pie); - // -no-pie is an alias for -nopie. So, handling -nopie takes care of - // -no-pie as well. - if (HasStaticPIE && Args.hasArg(options::OPT_nopie)) { + if (HasStaticPIE && Args.hasArg(options::OPT_no_pie)) { const Driver = TC.getDriver(); const llvm::opt::OptTable = D.getOpts(); StringRef StaticPIEName = Opts.getOptionName(options::OPT_static_pie); @@ -443,10 +441,8 @@ void tools::gnutools::Linker::ConstructJob(Compilation , const JobAction , if (Args.hasArg(options::OPT_rdynamic)) CmdArgs.push_back("-export-dynamic"); if (!IsShared) { - Arg *A = Args.getLastArg(options::OPT_pie, options::OPT_no_pie, - options::OPT_nopie); - IsPIE = A ? A->getOption().matches(options::OPT_pie) -: ToolChain.isPIEDefault(Args); + IsPIE = Args.hasFlag(options::OPT_pie, options::OPT_no_pie, + ToolChain.isPIEDefault(Args)); if (IsPIE) CmdArgs.push_back("-pie"); CmdArgs.push_back("-dynamic-linker"); diff --git a/clang/lib/Driver/ToolChains/OpenBSD.cpp b/clang/lib/Driver/ToolChains/OpenBSD.cpp index 5d06cd8ab0bad16..e883838e2dc9317 100644 --- a/clang/lib/Driver/ToolChains/OpenBSD.cpp +++ b/clang/lib/Driver/ToolChains/OpenBSD.cpp @@ -117,7 +117,7 @@ void openbsd::Linker::ConstructJob(Compilation , const JobAction , bool Shared = Args.hasArg(options::OPT_shared); bool Profiling = Args.hasArg(options::OPT_pg); bool Pie = Args.hasArg(options::OPT_pie); - bool Nopie = Args.hasArg(options::OPT_nopie); + bool Nopie = Args.hasArg(options::OPT_no_pie, options::OPT_nopie); const bool Relocatable = Args.hasArg(options::OPT_r); // Silence warning for "clang -g foo.o -o foo" diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp b/clang/lib/Driver/ToolChains/Solaris.cpp index 96757f07a54974f..485730da7df1f8c 100644 --- a/clang/lib/Driver/ToolChains/Solaris.cpp +++ b/clang/lib/Driver/ToolChains/Solaris.cpp @@ -49,11 +49,8 @@ static bool getPIE(const ArgList , const ToolChain ) { Args.hasArg(options::OPT_r)) return false; - Arg *A = Args.getLastArg(options::OPT_pie, options::OPT_no_pie, - options::OPT_nopie); - if (!A) -return TC.isPIEDefault(Args); - return A->getOption().matches(options::OPT_pie); + return Args.hasFlag(options::OPT_pie, options::OPT_no_pie, + TC.isPIEDefault(Args)); } // FIXME: Need to handle CLANG_DEFAULT_LINKER
[clang] [Clang] Introduce scoped variants of GNU atomic functions (PR #72280)
jhuber6 wrote: > > I figured we can just treat these as clang extensions for the time being. > > We already have two variants that are more or less redundant for specific > > use-cases, (OpenCL and HIP), which should be able to be removed after this. > > I'm not sure what you mean here. If you mean that users are expected to use > the OpenCL/HIP/etc. standard APIs, and you only expect to use these as part > of language runtimes, then maybe we don't care so much if it's clang-only. They should be available to users, but this level of programming is highly compiler-dependent already so I don't see it as much different. > It might be worth considering using string literals instead of numbers for > the different scopes. It removes any question of whether the list of scopes > is complete and the order of of numbers on the list. And it doesn't require > defining a bunch of new preprocessor macros. The underlying implementation is a string literal in the LLVM `syncscope` argument, but the problem is that this isn't standardized at all and varies between backends potentially. I suppose we could think of this are more literally "target the LLVM `syncscope` argument". I'd like something that's "reasonably" consistent between targets since a lot of this can be shared as simple hierarchy. it would be really annoying if each target had to define separate strings for something that's mostly common in concept. https://github.com/llvm/llvm-project/pull/72280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add support for Cortex-A520, Cortex-A720 and Cortex-X4 CPUs (PR #72395)
https://github.com/jthackray closed https://github.com/llvm/llvm-project/pull/72395 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 066c452 - [AArch64] Add support for Cortex-A520, Cortex-A720 and Cortex-X4 CPUs (#72395)
Author: Jonathan Thackray Date: 2023-11-16T22:08:58Z New Revision: 066c4524bc1d91b49048e7f05dc6e045bb3c9eef URL: https://github.com/llvm/llvm-project/commit/066c4524bc1d91b49048e7f05dc6e045bb3c9eef DIFF: https://github.com/llvm/llvm-project/commit/066c4524bc1d91b49048e7f05dc6e045bb3c9eef.diff LOG: [AArch64] Add support for Cortex-A520, Cortex-A720 and Cortex-X4 CPUs (#72395) Cortex-A520, Cortex-A720 and Cortex-X4 are Armv9.2 AArch64 CPUs. Technical Reference Manual for Cortex-A520: https://developer.arm.com/documentation/102517/latest/ Technical Reference Manual for Cortex-A720: https://developer.arm.com/documentation/102530/latest/ Technical Reference Manual for Cortex-X4: https://developer.arm.com/documentation/102484/latest/ Patch co-authored by: Sivan Shani Added: Modified: clang/docs/ReleaseNotes.rst clang/test/Driver/aarch64-mcpu.c clang/test/Misc/target-invalid-cpu-note.c llvm/docs/ReleaseNotes.rst llvm/include/llvm/TargetParser/AArch64TargetParser.h llvm/lib/Target/AArch64/AArch64.td llvm/lib/Target/AArch64/AArch64Subtarget.cpp llvm/lib/Target/AArch64/AArch64Subtarget.h llvm/lib/TargetParser/Host.cpp llvm/unittests/TargetParser/TargetParserTest.cpp Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index ed1a978b5382d71..31ebe89fb0cafd6 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -760,6 +760,12 @@ Arm and AArch64 Support - New AArch64 asm constraints have been added for r8-r11(Uci) and r12-r15(Ucj). + Support has been added for the following processors (-mcpu identifiers in parenthesis): + + * Arm Cortex-A520 (cortex-a520). + * Arm Cortex-A720 (cortex-a720). + * Arm Cortex-X4 (cortex-x4). + Android Support ^^^ diff --git a/clang/test/Driver/aarch64-mcpu.c b/clang/test/Driver/aarch64-mcpu.c index 321d3a739b35350..511482a420da268 100644 --- a/clang/test/Driver/aarch64-mcpu.c +++ b/clang/test/Driver/aarch64-mcpu.c @@ -44,12 +44,16 @@ // CORTEXX1C: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-x1c" // RUN: %clang --target=aarch64 -mcpu=cortex-x3 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEXX3 %s // CORTEXX3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-x3" +// RUN: %clang --target=aarch64 -mcpu=cortex-x4 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEX-X4 %s +// CORTEX-X4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-x4" // RUN: %clang --target=aarch64 -mcpu=cortex-a78 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEXA78 %s // CORTEXA78: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a78" // RUN: %clang --target=aarch64 -mcpu=cortex-a78c -### -c %s 2>&1 | FileCheck -check-prefix=CORTEX-A78C %s // CORTEX-A78C: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a78c" // RUN: %clang --target=aarch64 -mcpu=cortex-a715 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEX-A715 %s // CORTEX-A715: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a715" +// RUN: %clang --target=aarch64 -mcpu=cortex-a720 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEX-A720 %s +// CORTEX-A720: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a720" // RUN: %clang --target=aarch64 -mcpu=neoverse-e1 -### -c %s 2>&1 | FileCheck -check-prefix=NEOVERSE-E1 %s // NEOVERSE-E1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "neoverse-e1" // RUN: %clang --target=aarch64 -mcpu=neoverse-v1 -### -c %s 2>&1 | FileCheck -check-prefix=NEOVERSE-V1 %s @@ -62,6 +66,8 @@ // NEOVERSE-N2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "neoverse-n2" // RUN: %clang --target=aarch64 -mcpu=neoverse-512tvb -### -c %s 2>&1 | FileCheck -check-prefix=NEOVERSE-512TVB %s // NEOVERSE-512TVB: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "neoverse-512tvb" +// RUN: %clang --target=aarch64 -mcpu=cortex-a520 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEX-A520 %s +// CORTEX-A520: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a520" // RUN: %clang --target=aarch64 -mcpu=cortex-r82 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEXR82 %s // CORTEXR82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-r82" diff --git a/clang/test/Misc/target-invalid-cpu-note.c b/clang/test/Misc/target-invalid-cpu-note.c index 8e91eb4c62dd259..25ff51e071b69b3 100644 --- a/clang/test/Misc/target-invalid-cpu-note.c +++ b/clang/test/Misc/target-invalid-cpu-note.c @@ -5,11 +5,11 @@ // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AARCH64 // AARCH64: error: unknown target CPU 'not-a-cpu' -// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76,
[clang] [Clang] Introduce scoped variants of GNU atomic functions (PR #72280)
efriedma-quic wrote: > I figured we can just treat these as clang extensions for the time being. We > already have two variants that are more or less redundant for specific > use-cases, (OpenCL and HIP), which should be able to be removed after this. I'm not sure what you mean here. If you mean that users are expected to use the OpenCL/HIP/etc. standard APIs, and you only expect to use these as part of language runtimes, then maybe we don't care so much if it's clang-only. -- It might be worth considering using string literals instead of numbers for the different scopes. It removes any question of whether the list of scopes is complete and the order of of numbers on the list. And it doesn't require defining a bunch of new preprocessor macros. https://github.com/llvm/llvm-project/pull/72280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [ClangModule] Fix decl-params-determinisim test after serialization change (PR #72572)
https://github.com/cachemeifyoucan updated https://github.com/llvm/llvm-project/pull/72572 >From 89938936f2e021360e3889548608e76022c3d73b Mon Sep 17 00:00:00 2001 From: Steven Wu Date: Thu, 16 Nov 2023 13:21:27 -0800 Subject: [PATCH 1/2] [ClangModule] Fix decl-params-determinisim test after serialization change Fix decl-params-determinisim test after 48be81e1 packed some information in the clang module. The test is to make sure the decls are appearing in a strict ordering and it relies on check the correct field in the bitcode format. Add more explanation in the comments to help future updates when serialization format affects this test. --- clang/test/Modules/decl-params-determinisim.m | 19 ++- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/clang/test/Modules/decl-params-determinisim.m b/clang/test/Modules/decl-params-determinisim.m index ccad40b98d8edf4..be8c92e587cade1 100644 --- a/clang/test/Modules/decl-params-determinisim.m +++ b/clang/test/Modules/decl-params-determinisim.m @@ -23,27 +23,28 @@ /// NOTE: This test case is on determinism of TypeID for function declaration. /// Change related to TypeID (or PredefinedTypeIDs) will affect the result and -/// will require update for this test case. +/// will require update for this test case. Currently, TypeID is at op6 and the +/// test checks the IDs are in strict ordering. // CHECK: From c13f8684239281896d3d3572ea90b9b1e941d755 Mon Sep 17 00:00:00 2001 From: Steven Wu Date: Thu, 16 Nov 2023 14:01:30 -0800 Subject: [PATCH 2/2] fixup! [ClangModule] Fix decl-params-determinisim test after serialization change --- clang/test/Modules/decl-params-determinisim.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/Modules/decl-params-determinisim.m b/clang/test/Modules/decl-params-determinisim.m index be8c92e587cade1..351403d9af947e2 100644 --- a/clang/test/Modules/decl-params-determinisim.m +++ b/clang/test/Modules/decl-params-determinisim.m @@ -19,7 +19,7 @@ // RUN: diff %t1.pcm %t2.pcm /// Spot check entries to make sure they are in current ordering. -/// op13 encodes the anonymous decl number which should be in order. +/// op6 encodes the anonymous decl number which should be in order. /// NOTE: This test case is on determinism of TypeID for function declaration. /// Change related to TypeID (or PredefinedTypeIDs) will affect the result and ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang-tools-extra] [clang] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)
https://github.com/GeorgeHuyubo edited https://github.com/llvm/llvm-project/pull/71769 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [ClangModule] Fix decl-params-determinisim test after serialization change (PR #72572)
https://github.com/jansvoboda11 approved this pull request. LGTM with little nit. https://github.com/llvm/llvm-project/pull/72572 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lldb] [clang] [llvm] [clang-tools-extra] Add new API in SBTarget for loading core from SBFile (PR #71769)
@@ -627,7 +628,7 @@ class Target : public std::enable_shared_from_this, // used. const lldb::ProcessSP (lldb::ListenerSP listener_sp, llvm::StringRef plugin_name, - const FileSpec *crash_file, + lldb::FileSP crash_file, bool can_connect); GeorgeHuyubo wrote: If we move the open file code into Target.cpp, it's hard to handle error. Now in these 4 locations we have slightly different ways to report the error when the file is failed to open. ``` if (!file) { result.AppendErrorWithFormatv( "Failed to open the core file '{0}': '{1}.'\n", core_file.GetPath(), llvm::toString(file.takeError())); } ``` https://github.com/llvm/llvm-project/pull/71769 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits