[clang] [SPARC][clang] Add -m(no-)v8plus flags handling (PR #98713)
@@ -179,6 +179,13 @@ void sparc::getSparcTargetFeatures(const Driver , const ArgList , Features.push_back("-hard-quad-float"); } + if (Arg *A = Args.getLastArg(options::OPT_mv8plus, options::OPT_mno_v8plus)) { +if (A->getOption().matches(options::OPT_mv8plus)) koachan wrote: Ah, I see. In that case, would making these a no-op flag okay for now? As far as I understand it that would still be a compliant implementation, no? Codegen, etc. changes will happen in future patches but I can amend this one to include a placeholder `v8plus` feature bit in the backend. What do you think about it? (Some background: I am currently only looking to include this in clang because Linux passes `-mv8plus` when building 32-bit objects since some of its inline asm uses 64-bit registers, but otherwise it doesn't care if compiler-generated code uses them or not) https://github.com/llvm/llvm-project/pull/98713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] Reapply "[Clang] Implement resolution for CWG1835 (#92957, #98547)" (PR #100425)
https://github.com/sdkrystian edited https://github.com/llvm/llvm-project/pull/100425 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] Reapply "[Clang] Implement resolution for CWG1835 (#92957, #98547)" (PR #100425)
@@ -1779,6 +1779,42 @@ void Parser::checkPotentialAngleBracket(ExprResult ) { Priority); } +bool Parser::isMissingTemplateKeywordBeforeScope(bool AnnotateInvalid) { + assert(Tok.is(tok::coloncolon)); + Sema::DisableTypoCorrectionRAII DTC(Actions); + ColonProtectionRAIIObject ColonProtection(*this); + + SourceLocation StartLoc = Tok.getLocation(); + if (TryAnnotateTypeOrScopeToken()) +return true; + if (Tok.isSimpleTypeSpecifier(getLangOpts())) +return false; + CXXScopeSpec SS; + ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr, + /*ObjectHasErrors=*/false, + /*EnteringContext=*/false); + ExprResult Result = tryParseCXXIdExpression(SS, /*isAddressOfOperand=*/false); sdkrystian wrote: > Parsing the same expression twice could also be problematic in some cases -- > for example, if it contains a lambda, we might assign it the wrong mangling > number. Can we arrange things such that for a valid program, we only parse > the expression once? @zygoloid That already is the case: ```cpp template struct A { constexpr static int x = 0; template using B = A; }; template struct B { constexpr static int x = 0; }; template void f(T t) { t.A<0>::template B::x; // ok, interpreted as '((t.A) < 0) > ::template B::x' // lambda expression is only parsed once t.A<0>::template C::x; // warning: use 'template' keyword to treat 'A' as a dependent template name // lambda expression is parsed twice } ``` https://github.com/llvm/llvm-project/pull/100425 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix assertion failure during conversion function overload resolution. (PR #98671)
katzdm wrote: @zygoloid Friendly ping here, if you have a chance to take another look. https://github.com/llvm/llvm-project/pull/98671 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SPARC][clang] Add -m(no-)v8plus flags handling (PR #98713)
https://github.com/s-barannikov edited https://github.com/llvm/llvm-project/pull/98713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AIX] Turn on `#pragma mc_func` check by default (PR #101336)
https://github.com/chenzheng1030 commented: LGTM. Please wait for @AaronBallman 's approval. Thanks https://github.com/llvm/llvm-project/pull/101336 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AIX] Turn on `#pragma mc_func` check by default (PR #101336)
@@ -562,7 +562,7 @@ void AIX::addClangTargetOptions( CC1Args.push_back("-fno-sized-deallocation"); if (Args.hasFlag(options::OPT_ferr_pragma_mc_func_aix, - options::OPT_fno_err_pragma_mc_func_aix, false)) + options::OPT_fno_err_pragma_mc_func_aix, true)) chenzheng1030 wrote: Your code is the correct one. Thanks for pointing this out. https://github.com/llvm/llvm-project/pull/101336 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV][VLS] Support RISCV VLS calling convention (PR #100346)
https://github.com/4vtomat updated https://github.com/llvm/llvm-project/pull/100346 >From 15161b0b7637d52b6285624a4bf9f52a6664082c Mon Sep 17 00:00:00 2001 From: Brandon Wu Date: Sun, 21 Jul 2024 09:49:11 -0700 Subject: [PATCH 1/5] [RISCV][VLS] Support RISCV VLS calling convention This patch adds a function attribute `riscv_vls_cc` for RISCV VLS calling convention which takes 0 or 1 argument, the argument is the `ABI_VLEN` which is the `VLEN` for passing the fixed-vector arguments, it wraps the argument as a scalable vector(VLA) using the `ABI_VLEN` and uses the corresponding mechanism to handle it. The range of `ABI_VLEN` is [32, 65536], if not specified, the default value is 128. An option `-mriscv-abi-vlen=N` is also added to specify the `ABI_VLEN` globally, it's used for every functions are being compiled, however if both function attribute and option are specified, the function attribute has higher priority than the option which means the function attribute overwrites the `ABI_VLEN` specified by the option. Here is an example of VLS argument passing: Non-VLS call: ``` void original_call(__attribute__((vector_size(16))) int arg) {} => define void @original_call(i128 noundef %arg) { entry: ... ret void } ``` VLS call: ``` void __attribute__((riscv_vls_cc(256))) vls_call(__attribute__((vector_size(16))) int arg) {} => define riscv_vls_cc void @vls_call( %arg) { entry: ... ret void } } ``` The first Non-VLS call passes generic vector argument of 16 bytes by flattened integer. On the contrary, the VLS call uses `ABI_VLEN=256` which wraps the vector to where the number of scalable vector elements is calaulated by: `ORIG_ELTS * RVV_BITS_PER_BLOCK / ABI_VLEN`. Note: ORIG_ELTS = Vector Size / Type Size = 128 / 32 = 4. --- clang/include/clang-c/Index.h | 1 + clang/include/clang/AST/Type.h| 26 +-- clang/include/clang/AST/TypeProperties.td | 7 +- clang/include/clang/Basic/Attr.td | 8 ++ clang/include/clang/Basic/AttrDocs.td | 11 +++ clang/include/clang/Basic/Specifiers.h| 1 + clang/include/clang/CodeGen/CGFunctionInfo.h | 9 ++- clang/include/clang/Driver/Options.td | 2 + clang/lib/AST/ASTContext.cpp | 2 + clang/lib/AST/ItaniumMangle.cpp | 1 + clang/lib/AST/Type.cpp| 2 + clang/lib/AST/TypePrinter.cpp | 6 ++ clang/lib/Basic/Targets/RISCV.cpp | 1 + clang/lib/CodeGen/CGCall.cpp | 5 ++ clang/lib/CodeGen/CGDebugInfo.cpp | 2 + clang/lib/CodeGen/Targets/RISCV.cpp | 73 --- clang/lib/Driver/ToolChains/Arch/RISCV.cpp| 4 + clang/lib/Sema/SemaDeclAttr.cpp | 30 +++- clang/lib/Sema/SemaType.cpp | 17 - .../RISCV/riscv-vector-callingconv-llvm-ir.c | 24 ++ .../riscv-vector-callingconv-llvm-ir.cpp | 14 .../CodeGen/RISCV/riscv-vector-callingconv.c | 16 .../RISCV/riscv-vector-callingconv.cpp| 17 + clang/tools/libclang/CXType.cpp | 1 + llvm/include/llvm/AsmParser/LLToken.h | 1 + llvm/include/llvm/BinaryFormat/Dwarf.def | 1 + llvm/include/llvm/IR/CallingConv.h| 3 + llvm/lib/AsmParser/LLLexer.cpp| 1 + llvm/lib/AsmParser/LLParser.cpp | 4 + llvm/lib/IR/AsmWriter.cpp | 3 + llvm/lib/Target/RISCV/RISCVFeatures.td| 9 +++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 1 + llvm/lib/Target/RISCV/RISCVSubtarget.h| 1 + 33 files changed, 265 insertions(+), 39 deletions(-) diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index 115f5ab090f96..159f21846fc3b 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -3005,6 +3005,7 @@ enum CXCallingConv { CXCallingConv_M68kRTD = 19, CXCallingConv_PreserveNone = 20, CXCallingConv_RISCVVectorCall = 21, + CXCallingConv_RISCVVLSCall = 22, CXCallingConv_Invalid = 100, CXCallingConv_Unexposed = 200 diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 72723c7c56e07..bb3956b1d2094 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -1942,7 +1942,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { /// Extra information which affects how the function is called, like /// regparm and the calling convention. LLVM_PREFERRED_TYPE(CallingConv) -unsigned ExtInfo : 13; +unsigned ExtInfo : 17; /// The ref-qualifier associated with a \c FunctionProtoType. /// @@ -4395,6 +4395,8 @@ class FunctionType : public Type { // | CC |noreturn|produces|nocallersavedregs|regparm|nocfcheck|cmsenscall| // |0 .. 4| 5|6 | 7 |8 .. 10|11 |12 | +// |RISCV-ABI-VLEN| +// |13..17| // //
[clang] [llvm] [RISCV][VLS] Support RISCV VLS calling convention (PR #100346)
@@ -4768,6 +4768,15 @@ static void handleCallConvAttr(Sema , Decl *D, const ParsedAttr ) { case ParsedAttr::AT_RISCVVectorCC: D->addAttr(::new (S.Context) RISCVVectorCCAttr(S.Context, AL)); return; + case ParsedAttr::AT_RISCVVLSCC: { +// If the riscv_abi_vlen doesn't have any argument, default ABI_VLEN is 128. +unsigned VectorLength = 128; +if (AL.getNumArgs() && +!S.checkUInt32Argument(AL, AL.getArgAsExpr(0), VectorLength)) + return; 4vtomat wrote: I guess no, I'll check it here. https://github.com/llvm/llvm-project/pull/100346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CUDA] Add 'noconvergent' function and statement attribute (PR #100637)
https://github.com/darkbuck closed https://github.com/llvm/llvm-project/pull/100637 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] fa84297 - [clang][CUDA] Add 'noconvergent' function and statement attribute
Author: darkbuck Date: 2024-07-31T11:30:48-04:00 New Revision: fa842970027b6d2f0160ad42fa82a872bf8d8600 URL: https://github.com/llvm/llvm-project/commit/fa842970027b6d2f0160ad42fa82a872bf8d8600 DIFF: https://github.com/llvm/llvm-project/commit/fa842970027b6d2f0160ad42fa82a872bf8d8600.diff LOG: [clang][CUDA] Add 'noconvergent' function and statement attribute - For languages following SPMD/SIMT programming model, functions and call sites are marked 'convergent' by default. 'noconvergent' is added in this patch to allow developers to remove that 'convergent' attribute when it's safe. Reviewers: nhaehnle, Sirraide, yxsamliu, Artem-B, ilovepi, jayfoad, ssahasra, arsenm Reviewed By: arsenm Pull Request: https://github.com/llvm/llvm-project/pull/100637 Added: clang/test/SemaCUDA/attr-noconvergent.cu Modified: clang/include/clang/Basic/Attr.td clang/include/clang/Basic/AttrDocs.td clang/lib/CodeGen/CGCall.cpp clang/lib/CodeGen/CGStmt.cpp clang/lib/CodeGen/CodeGenFunction.h clang/lib/Sema/SemaStmtAttr.cpp clang/test/CodeGenCUDA/convergent.cu clang/test/Misc/pragma-attribute-supported-attributes-list.test Removed: diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 46d0a66d59c37..8ac2079099c85 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -2050,6 +2050,17 @@ def Convergent : InheritableAttr { let SimpleHandler = 1; } +def NoConvergent : InheritableAttr { + let Spellings = [Clang<"noconvergent">, Declspec<"noconvergent">]; + let Subjects = SubjectList<[Function, Stmt], WarnDiag, + "functions and statements">; + let LangOpts = [CUDA]; + let Documentation = [NoConvergentDocs]; + let SimpleHandler = 1; +} + +def : MutualExclusions<[Convergent, NoConvergent]>; + def NoInline : DeclOrStmtAttr { let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">, CXX11<"clang", "noinline">, C23<"clang", "noinline">, diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 4b8d520d73893..94c284fc73158 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -1382,6 +1382,34 @@ Sample usage: }]; } +def NoConvergentDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +This attribute prevents a function from being treated as convergent, which +means that optimizations can only move calls to that function to +control-equivalent blocks. If a statement is marked as ``noconvergent`` and +contains calls, it also prevents those calls from being treated as convergent. +In other words, those calls are not restricted to only being moved to +control-equivalent blocks. + +In languages following SPMD/SIMT programming model, e.g., CUDA/HIP, function +declarations and calls are treated as convergent by default for correctness. +This ``noconvergent`` attribute is helpful for developers to prevent them from +being treated as convergent when it's safe. + +.. code-block:: c + + __device__ float bar(float); + __device__ float foo(float) __attribute__((noconvergent)) {} + + __device__ int example(void) { +float x; +[[clang::noconvergent]] x = bar(x); + } + + }]; +} + def NoSplitStackDocs : Documentation { let Category = DocCatFunction; let Content = [{ diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 2f3dd5d01fa6c..ee6e8e0905723 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -2522,6 +2522,9 @@ void CodeGenModule::ConstructAttributeList(StringRef Name, } } } +// Remove 'convergent' if requested. +if (TargetDecl->hasAttr()) + FuncAttrs.removeAttribute(llvm::Attribute::Convergent); } // Add "sample-profile-suffix-elision-policy" attribute for internal linkage @@ -5636,6 +5639,11 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo , Attrs = Attrs.addFnAttribute(getLLVMContext(), llvm::Attribute::AlwaysInline); + // Remove call-site convergent attribute if requested. + if (InNoConvergentAttributedStmt) +Attrs = +Attrs.removeFnAttribute(getLLVMContext(), llvm::Attribute::Convergent); + // Apply some call-site-specific attributes. // TODO: work this into building the attribute set. diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp index e16aa3cdd5506..30b6fce5d016a 100644 --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -723,6 +723,7 @@ void CodeGenFunction::EmitAttributedStmt(const AttributedStmt ) { bool nomerge = false; bool noinline = false; bool alwaysinline = false; + bool noconvergent = false; const CallExpr *musttail = nullptr; for (const auto *A : S.getAttrs()) { @@ -738,6 +739,9 @@ void
[clang] [AIX] Turn on `#pragma mc_func` check by default (PR #101336)
https://github.com/qiongsiwu edited https://github.com/llvm/llvm-project/pull/101336 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][LoongArch] Align global symbol by size (PR #101309)
s-barannikov wrote: > > This looks wrong. Preferred and ABI alignments should be set in ~Triple~. > > ADD: Sorry, I meant DataLayout, of course. > > Thanks for pointing this out. How does data layout affect the alignment of > constant string global variable symbols? They will be aligned to the preferred alignment specified as Y in the "-a:X:Y" part of the data layout, IIRC. https://github.com/llvm/llvm-project/pull/101309 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix amdgpu-arch for dll name on Windows (PR #101350)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Yaxun (Sam) Liu (yxsamliu) Changes Recently HIP runtime changed dll name to amdhip64_n.dll on Windows, where n is ROCm major version number. Fix amdgpu-arch to search for amdhip64_n.dll on Windows. --- Full diff: https://github.com/llvm/llvm-project/pull/101350.diff 2 Files Affected: - (modified) clang/tools/amdgpu-arch/AMDGPUArch.cpp (+3) - (modified) clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp (+108-4) ``diff diff --git a/clang/tools/amdgpu-arch/AMDGPUArch.cpp b/clang/tools/amdgpu-arch/AMDGPUArch.cpp index 7ae57b7877e1f..fefd4f08d5ed2 100644 --- a/clang/tools/amdgpu-arch/AMDGPUArch.cpp +++ b/clang/tools/amdgpu-arch/AMDGPUArch.cpp @@ -21,6 +21,9 @@ static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden); // Mark all our options with this category. static cl::OptionCategory AMDGPUArchCategory("amdgpu-arch options"); +cl::opt Verbose("verbose", cl::desc("Enable verbose output"), + cl::init(false), cl::cat(AMDGPUArchCategory)); + static void PrintVersion(raw_ostream ) { OS << clang::getClangToolFullVersion("amdgpu-arch") << '\n'; } diff --git a/clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp b/clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp index 7338872dbf32f..f9beb5046568c 100644 --- a/clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp +++ b/clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp @@ -11,9 +11,21 @@ // //===--===// +#include "llvm/Support/CommandLine.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/Error.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/Process.h" +#include "llvm/Support/Program.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include + +#ifdef _WIN32 +#include +#endif using namespace llvm; @@ -31,16 +43,108 @@ typedef hipError_t (*hipGetDeviceCount_t)(int *); typedef hipError_t (*hipDeviceGet_t)(int *, int); typedef hipError_t (*hipGetDeviceProperties_t)(hipDeviceProp_t *, int); -int printGPUsByHIP() { +extern cl::opt Verbose; + #ifdef _WIN32 - constexpr const char *DynamicHIPPath = "amdhip64.dll"; +std::vector getSearchPaths() { + std::vector Paths; + + // Get the directory of the current executable + if (auto MainExe = sys::fs::getMainExecutable(nullptr, nullptr); + !MainExe.empty()) +Paths.push_back(sys::path::parent_path(MainExe).str()); + + // Get the system directory + char SystemDirectory[MAX_PATH]; + if (GetSystemDirectoryA(SystemDirectory, MAX_PATH) > 0) { +Paths.push_back(SystemDirectory); + } + + // Get the Windows directory + char WindowsDirectory[MAX_PATH]; + if (GetWindowsDirectoryA(WindowsDirectory, MAX_PATH) > 0) { +Paths.push_back(WindowsDirectory); + } + + // Get the current working directory + SmallVector CWD; + if (sys::fs::current_path(CWD)) +Paths.push_back(std::string(CWD.begin(), CWD.end())); + + // Get the PATH environment variable + if (auto PathEnv = llvm::sys::Process::GetEnv("PATH")) { +SmallVector PathList; +StringRef(*PathEnv).split(PathList, sys::EnvPathSeparator); +for (auto : PathList) + Paths.push_back(Path.str()); + } + + return Paths; +} + +// Custom comparison function for dll name +bool compareVersions(const std::string , const std::string ) { + // Extract version numbers + int versionA = std::stoi(a.substr(a.find_last_of('_') + 1)); + int versionB = std::stoi(b.substr(b.find_last_of('_') + 1)); + return versionA > versionB; +} + +#endif + +// On Windows, prefer amdhip64_n.dll where n is ROCm major version and greater +// value of n takes precedence. If amdhip64_n.dll is not found, fall back to +// amdhip64.dll. The reason is that a normal driver installation only has +// amdhip64_n.dll but we do not know what n is since this progrm may be used +// with a future version of HIP runtime. +// +// On Linux, always use default libamdhip64.so. +std::pair findNewestHIPDLL() { +#ifdef _WIN32 + const char *HipDLLPrefix = "amdhip64_"; + const char *HipDLLSuffix = ".dll"; + + std::vector SearchPaths = getSearchPaths(); + std::vector DLLNames; + + for (const auto : SearchPaths) { +std::error_code EC; +for (sys::fs::directory_iterator DirIt(Dir, EC), DirEnd; + DirIt != DirEnd && !EC; DirIt.increment(EC)) { + StringRef Filename = sys::path::filename(DirIt->path()); + if (Filename.starts_with(HipDLLPrefix) && + Filename.ends_with(HipDLLSuffix)) +DLLNames.push_back(sys::path::convert_to_slash(DirIt->path())); +} +if (!DLLNames.empty()) + break; + } + + if (DLLNames.empty()) +return {"amdhip64.dll", true}; + + std::sort(DLLNames.begin(), DLLNames.end(), compareVersions); + return {DLLNames[0], false}; #else - constexpr const char *DynamicHIPPath = "libamdhip64.so"; + // On Linux, fallback to default shared object + return {"libamdhip64.so", true}; #endif +} +
[clang] [AIX] Turn on `#pragma mc_func` check by default (PR #101336)
@@ -562,7 +562,7 @@ void AIX::addClangTargetOptions( CC1Args.push_back("-fno-sized-deallocation"); if (Args.hasFlag(options::OPT_ferr_pragma_mc_func_aix, - options::OPT_fno_err_pragma_mc_func_aix, false)) + options::OPT_fno_err_pragma_mc_func_aix, true)) qiongsiwu wrote: Good point! Code is revised. I tried the suggested change ``` if (Args.hasArg(options::OPT_fno_err_pragma_mc_func_aix)) CC1Args.push_back("-fno-err-pragma-mc-func-aix"); ``` But it does not handle situations like `-fno-err-pragma-mc-func-aix -ferr-pragma-mc-func-aix` correctly. I think we still need to process both flags in the driver, but we only need to pass `-fno-err-pragma-mc-func-aix` to CC1. Did I miss something? https://github.com/llvm/llvm-project/pull/101336 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix amdgpu-arch for dll name on Windows (PR #101350)
https://github.com/yxsamliu created https://github.com/llvm/llvm-project/pull/101350 Recently HIP runtime changed dll name to amdhip64_n.dll on Windows, where n is ROCm major version number. Fix amdgpu-arch to search for amdhip64_n.dll on Windows. >From 8819e99b64f3293a758f8a81258a25c91fab6ef6 Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Wed, 31 Jul 2024 09:23:05 -0400 Subject: [PATCH] Fix amdgpu-arch for dll name on Windows Recently HIP runtime changed dll name to amdhip64_n.dll on Windows, where n is ROCm major version number. Fix amdgpu-arch to search for amdhip64_n.dll on Windows. --- clang/tools/amdgpu-arch/AMDGPUArch.cpp | 3 + clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp | 112 +++- 2 files changed, 111 insertions(+), 4 deletions(-) diff --git a/clang/tools/amdgpu-arch/AMDGPUArch.cpp b/clang/tools/amdgpu-arch/AMDGPUArch.cpp index 7ae57b7877e1f..fefd4f08d5ed2 100644 --- a/clang/tools/amdgpu-arch/AMDGPUArch.cpp +++ b/clang/tools/amdgpu-arch/AMDGPUArch.cpp @@ -21,6 +21,9 @@ static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden); // Mark all our options with this category. static cl::OptionCategory AMDGPUArchCategory("amdgpu-arch options"); +cl::opt Verbose("verbose", cl::desc("Enable verbose output"), + cl::init(false), cl::cat(AMDGPUArchCategory)); + static void PrintVersion(raw_ostream ) { OS << clang::getClangToolFullVersion("amdgpu-arch") << '\n'; } diff --git a/clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp b/clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp index 7338872dbf32f..f9beb5046568c 100644 --- a/clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp +++ b/clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp @@ -11,9 +11,21 @@ // //===--===// +#include "llvm/Support/CommandLine.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/Error.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/Process.h" +#include "llvm/Support/Program.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include + +#ifdef _WIN32 +#include +#endif using namespace llvm; @@ -31,16 +43,108 @@ typedef hipError_t (*hipGetDeviceCount_t)(int *); typedef hipError_t (*hipDeviceGet_t)(int *, int); typedef hipError_t (*hipGetDeviceProperties_t)(hipDeviceProp_t *, int); -int printGPUsByHIP() { +extern cl::opt Verbose; + #ifdef _WIN32 - constexpr const char *DynamicHIPPath = "amdhip64.dll"; +std::vector getSearchPaths() { + std::vector Paths; + + // Get the directory of the current executable + if (auto MainExe = sys::fs::getMainExecutable(nullptr, nullptr); + !MainExe.empty()) +Paths.push_back(sys::path::parent_path(MainExe).str()); + + // Get the system directory + char SystemDirectory[MAX_PATH]; + if (GetSystemDirectoryA(SystemDirectory, MAX_PATH) > 0) { +Paths.push_back(SystemDirectory); + } + + // Get the Windows directory + char WindowsDirectory[MAX_PATH]; + if (GetWindowsDirectoryA(WindowsDirectory, MAX_PATH) > 0) { +Paths.push_back(WindowsDirectory); + } + + // Get the current working directory + SmallVector CWD; + if (sys::fs::current_path(CWD)) +Paths.push_back(std::string(CWD.begin(), CWD.end())); + + // Get the PATH environment variable + if (auto PathEnv = llvm::sys::Process::GetEnv("PATH")) { +SmallVector PathList; +StringRef(*PathEnv).split(PathList, sys::EnvPathSeparator); +for (auto : PathList) + Paths.push_back(Path.str()); + } + + return Paths; +} + +// Custom comparison function for dll name +bool compareVersions(const std::string , const std::string ) { + // Extract version numbers + int versionA = std::stoi(a.substr(a.find_last_of('_') + 1)); + int versionB = std::stoi(b.substr(b.find_last_of('_') + 1)); + return versionA > versionB; +} + +#endif + +// On Windows, prefer amdhip64_n.dll where n is ROCm major version and greater +// value of n takes precedence. If amdhip64_n.dll is not found, fall back to +// amdhip64.dll. The reason is that a normal driver installation only has +// amdhip64_n.dll but we do not know what n is since this progrm may be used +// with a future version of HIP runtime. +// +// On Linux, always use default libamdhip64.so. +std::pair findNewestHIPDLL() { +#ifdef _WIN32 + const char *HipDLLPrefix = "amdhip64_"; + const char *HipDLLSuffix = ".dll"; + + std::vector SearchPaths = getSearchPaths(); + std::vector DLLNames; + + for (const auto : SearchPaths) { +std::error_code EC; +for (sys::fs::directory_iterator DirIt(Dir, EC), DirEnd; + DirIt != DirEnd && !EC; DirIt.increment(EC)) { + StringRef Filename = sys::path::filename(DirIt->path()); + if (Filename.starts_with(HipDLLPrefix) && + Filename.ends_with(HipDLLSuffix)) +DLLNames.push_back(sys::path::convert_to_slash(DirIt->path())); +} +if (!DLLNames.empty()) + break; + } + + if (DLLNames.empty())
[clang] Revert "[CMake][Fuchsia] Include libunwind and libc++abi in baremetal build" (PR #101340)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `sanitizer-x86_64-linux` running on `sanitizer-buildbot1` while building `clang` at step 2 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/66/builds/2360 Here is the relevant piece of the build log for the reference: ``` Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure) ... [373/378] Generating MSAN_INST_GTEST.gtest-all.cc.x86_64.o [374/378] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64-with-call.o [375/378] Generating Msan-x86_64-with-call-Test [376/378] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64.o [377/378] Generating Msan-x86_64-Test [377/378] Running compiler_rt regression tests llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:276: warning: input '/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/rtsan/X86_64LinuxConfig' contained no tests llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds. -- Testing: 4493 of 10163 tests, 88 workers -- Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60 FAIL: SanitizerCommon-lsan-i386-Linux :: Linux/soft_rss_limit_mb_test.cpp (2942 of 4493) TEST 'SanitizerCommon-lsan-i386-Linux :: Linux/soft_rss_limit_mb_test.cpp' FAILED Exit Code: 1 Command Output (stderr): -- RUN: at line 2: /b/sanitizer-x86_64-linux/build/build_default/./bin/clang --driver-mode=g++ -gline-tables-only -fsanitize=leak -m32 -funwind-tables -I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O2 /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp -o /b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp + /b/sanitizer-x86_64-linux/build/build_default/./bin/clang --driver-mode=g++ -gline-tables-only -fsanitize=leak -m32 -funwind-tables -I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O2 /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp -o /b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp RUN: at line 5: env LSAN_OPTIONS=soft_rss_limit_mb=220:quarantine_size=1:allocator_may_return_null=1 /b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp 2>&1 | FileCheck /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp -check-prefix=CHECK_MAY_RETURN_1 + env LSAN_OPTIONS=soft_rss_limit_mb=220:quarantine_size=1:allocator_may_return_null=1 /b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/lsan-i386-Linux/Linux/Output/soft_rss_limit_mb_test.cpp.tmp + FileCheck /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp -check-prefix=CHECK_MAY_RETURN_1 /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp:68:24: error: CHECK_MAY_RETURN_1: expected string not found in input // CHECK_MAY_RETURN_1: allocating 512 times ^ :52:44: note: scanning from here Some of the malloc calls returned non-null: 247 ^ :52:45: note: possible intended match here Some of the malloc calls returned non-null: 247 ^ Input file: Check file: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/soft_rss_limit_mb_test.cpp -dump-input=help explains the following input dump. Input was: << . . . 47: [256] 48: [320] 49: [384] 50: [448] 51: Some of the malloc calls returned null: 265 52: Some of the malloc calls returned non-null: 247 check:68'0X error: no match found check:68'1 ?possible intended match Step 11 (test compiler-rt debug) failure: test compiler-rt debug (failure) ... [373/378] Generating MSAN_INST_GTEST.gtest-all.cc.x86_64.o [374/378] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.x86_64-with-call.o [375/378] Generating Msan-x86_64-with-call-Test
[clang] [AIX] Turn on `#pragma mc_func` check by default (PR #101336)
https://github.com/qiongsiwu updated https://github.com/llvm/llvm-project/pull/101336 >From e823d1e7eb3357fc5c15b614ac5fd94d331ac630 Mon Sep 17 00:00:00 2001 From: Qiongsi Wu Date: Wed, 31 Jul 2024 10:12:59 -0400 Subject: [PATCH 1/2] Turn on mc_func check by default. --- clang/include/clang/Driver/Options.td | 2 +- clang/include/clang/Lex/PreprocessorOptions.h | 4 ++-- clang/lib/Driver/ToolChains/AIX.cpp | 2 +- clang/test/Preprocessor/pragma_mc_func.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index c8c56dbb51b28..7f6b8ba4d7eeb 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8097,7 +8097,7 @@ def source_date_epoch : Separate<["-"], "source-date-epoch">, } // let Visibility = [CC1Option] defm err_pragma_mc_func_aix : BoolFOption<"err-pragma-mc-func-aix", - PreprocessorOpts<"ErrorOnPragmaMcfuncOnAIX">, DefaultFalse, + PreprocessorOpts<"ErrorOnPragmaMcfuncOnAIX">, DefaultTrue, PosFlag, NegFlag&1 | FileCheck %s // RUN: not %clang --target=powerpc64-ibm-aix -ferr-pragma-mc-func-aix -fsyntax-only \ // RUN: %s 2>&1 | FileCheck %s #pragma mc_func asm_barrier {"6000"} @@ -8,11 +9,10 @@ // RUN: %clang --target=powerpc64-ibm-aix -fno-err-pragma-mc-func-aix -fsyntax-only %s // RUN: %clang --target=powerpc64-ibm-aix -ferr-pragma-mc-func-aix -fsyntax-only \ // RUN:-fno-err-pragma-mc-func-aix %s -// RUN: %clang --target=powerpc64-ibm-aix -fsyntax-only %s // RUN: %clang --target=powerpc64-ibm-aix -Werror=unknown-pragmas \ // RUN: -fno-err-pragma-mc-func-aix -fsyntax-only %s -// Cases where we have errors or warnings. +// Cases on a non-AIX target. // RUN: not %clang --target=powerpc64le-unknown-linux-gnu \ // RUN: -Werror=unknown-pragmas -fno-err-pragma-mc-func-aix -fsyntax-only %s 2>&1 | \ // RUN: FileCheck --check-prefix=UNUSED %s >From 16280f9527a02d61789ca310bd4418fb33112ef2 Mon Sep 17 00:00:00 2001 From: Qiongsi Wu Date: Wed, 31 Jul 2024 11:25:07 -0400 Subject: [PATCH 2/2] Remove unnecessary CC1 option. --- clang/include/clang/Driver/Options.td| 2 +- clang/lib/Driver/ToolChains/AIX.cpp | 6 ++ clang/test/Preprocessor/pragma_mc_func.c | 2 ++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 7f6b8ba4d7eeb..c155ff8e7003d 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8098,7 +8098,7 @@ def source_date_epoch : Separate<["-"], "source-date-epoch">, defm err_pragma_mc_func_aix : BoolFOption<"err-pragma-mc-func-aix", PreprocessorOpts<"ErrorOnPragmaMcfuncOnAIX">, DefaultTrue, - PosFlag, NegFlag>; diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp index f0e7acac688fc..aa51c1a8df58c 100644 --- a/clang/lib/Driver/ToolChains/AIX.cpp +++ b/clang/lib/Driver/ToolChains/AIX.cpp @@ -561,10 +561,8 @@ void AIX::addClangTargetOptions( options::OPT_fno_sized_deallocation)) CC1Args.push_back("-fno-sized-deallocation"); - if (Args.hasFlag(options::OPT_ferr_pragma_mc_func_aix, - options::OPT_fno_err_pragma_mc_func_aix, true)) -CC1Args.push_back("-ferr-pragma-mc-func-aix"); - else + if (!Args.hasFlag(options::OPT_ferr_pragma_mc_func_aix, +options::OPT_fno_err_pragma_mc_func_aix, true)) CC1Args.push_back("-fno-err-pragma-mc-func-aix"); } diff --git a/clang/test/Preprocessor/pragma_mc_func.c b/clang/test/Preprocessor/pragma_mc_func.c index 8d172f8490e25..bf12f7107ff5c 100644 --- a/clang/test/Preprocessor/pragma_mc_func.c +++ b/clang/test/Preprocessor/pragma_mc_func.c @@ -1,6 +1,8 @@ // RUN: not %clang --target=powerpc64-ibm-aix -fsyntax-only %s 2>&1 | FileCheck %s // RUN: not %clang --target=powerpc64-ibm-aix -ferr-pragma-mc-func-aix -fsyntax-only \ // RUN: %s 2>&1 | FileCheck %s +// RUN: not %clang --target=powerpc64-ibm-aix -fno-err-pragma-mc-func-aix \ +// RUN: -ferr-pragma-mc-func-aix -fsyntax-only %s 2>&1 | FileCheck %s #pragma mc_func asm_barrier {"6000"} // CHECK: error: #pragma mc_func is not supported ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix self-capturing `__block` variables (PR #89475)
ille-apple wrote: Ping. https://github.com/llvm/llvm-project/pull/89475 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SPARC][clang] Add -m(no-)v8plus flags handling (PR #98713)
@@ -179,6 +179,13 @@ void sparc::getSparcTargetFeatures(const Driver , const ArgList , Features.push_back("-hard-quad-float"); } + if (Arg *A = Args.getLastArg(options::OPT_mv8plus, options::OPT_mno_v8plus)) { +if (A->getOption().matches(options::OPT_mv8plus)) s-barannikov wrote: > on GCC, `-m[no-]v8plus` also implies that V9 instructions are available (or > not, in case of `-mno-v8plus`) Well, no. Not exactly. Whether or not V9 instructions are available is determined strictly by `-mcpu=v9` (which is the default). In both cases by the first godbolt link instructions are V9 instructions and operate on 64-bit registers. The thing is, you can't use the upper half of these registers, which makes instructions such as MULX useless. There are, however, other instructions introduced in V9 that are useful -- 32-bit atomics for instance. Also note that `-mno-v8plus` is the default and passing it explicitly won't change the behavior (unless you specified `-mv8plus` prior to it). https://github.com/llvm/llvm-project/pull/98713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AIX] Turn on `#pragma mc_func` check by default (PR #101336)
@@ -562,7 +562,7 @@ void AIX::addClangTargetOptions( CC1Args.push_back("-fno-sized-deallocation"); if (Args.hasFlag(options::OPT_ferr_pragma_mc_func_aix, - options::OPT_fno_err_pragma_mc_func_aix, false)) + options::OPT_fno_err_pragma_mc_func_aix, true)) chenzheng1030 wrote: Since the preprocessor has a default value, can we avoid the cc1 option if the value here matches the default value inside the preprocessor, like: ``` if (Args.hasArg(options::OPT_fno_err_pragma_mc_func_aix)) CC1Args.push_back("-fno-err-pragma-mc-func-aix"); ``` (no need to pass `-ferr-pragma-mc-func-aix` as it is the default inside preprocessor.) https://github.com/llvm/llvm-project/pull/101336 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [OpenMP] OpenMP 5.1 "assume" directive parsing support (PR #92731)
@@ -2013,6 +2064,184 @@ class OMPMergeableClause : public OMPClause { } }; +/// This represents the 'absent' clause in the '#pragma omp assume' +/// directive. +/// +/// \code +/// #pragma omp assume absent() +/// \endcode +/// In this example directive '#pragma omp assume' has an 'absent' clause. +class OMPAbsentClause final +: public OMPDirectiveListClause, + private llvm::TrailingObjects { + friend OMPDirectiveListClause; + friend TrailingObjects; + +public: + /// Build 'absent' clause. + /// + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param EndLoc Ending location of the clause. + /// \param NumKinds Number of directive kinds listed in the clause. + OMPAbsentClause(SourceLocation StartLoc, SourceLocation LParenLoc, + SourceLocation EndLoc, unsigned NumKinds) + : OMPDirectiveListClause( +llvm::omp::OMPC_absent, StartLoc, LParenLoc, EndLoc, NumKinds) {} + + /// Build an empty clause. + OMPAbsentClause(unsigned NumKinds) + : OMPDirectiveListClause( +llvm::omp::OMPC_absent, SourceLocation(), SourceLocation(), +SourceLocation(), NumKinds) {} + alexey-bataev wrote: These constructions must be private/protected https://github.com/llvm/llvm-project/pull/92731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [OpenMP] OpenMP 5.1 "assume" directive parsing support (PR #92731)
@@ -2013,6 +2064,184 @@ class OMPMergeableClause : public OMPClause { } }; +/// This represents the 'absent' clause in the '#pragma omp assume' +/// directive. +/// +/// \code +/// #pragma omp assume absent() +/// \endcode +/// In this example directive '#pragma omp assume' has an 'absent' clause. +class OMPAbsentClause final +: public OMPDirectiveListClause, + private llvm::TrailingObjects { + friend OMPDirectiveListClause; + friend TrailingObjects; + +public: + /// Build 'absent' clause. + /// + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param EndLoc Ending location of the clause. + /// \param NumKinds Number of directive kinds listed in the clause. + OMPAbsentClause(SourceLocation StartLoc, SourceLocation LParenLoc, + SourceLocation EndLoc, unsigned NumKinds) + : OMPDirectiveListClause( +llvm::omp::OMPC_absent, StartLoc, LParenLoc, EndLoc, NumKinds) {} + + /// Build an empty clause. + OMPAbsentClause(unsigned NumKinds) + : OMPDirectiveListClause( +llvm::omp::OMPC_absent, SourceLocation(), SourceLocation(), +SourceLocation(), NumKinds) {} + + static OMPAbsentClause *Create(const ASTContext , + ArrayRef DKVec, + SourceLocation Loc, SourceLocation LLoc, + SourceLocation RLoc); + + static OMPAbsentClause *CreateEmpty(const ASTContext , unsigned NumKinds); + + static bool classof(const OMPClause *C) { +return C->getClauseKind() == llvm::omp::OMPC_absent; + } +}; + +/// This represents the 'contains' clause in the '#pragma omp assume' +/// directive. +/// +/// \code +/// #pragma omp assume contains() +/// \endcode +/// In this example directive '#pragma omp assume' has a 'contains' clause. +class OMPContainsClause final +: public OMPDirectiveListClause, + private llvm::TrailingObjects { + friend OMPDirectiveListClause; + friend TrailingObjects; + +public: + /// Build 'contains' clause. + /// + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param EndLoc Ending location of the clause. + /// \param NumKinds Number of directive kinds listed in the clause. + OMPContainsClause(SourceLocation StartLoc, SourceLocation LParenLoc, +SourceLocation EndLoc, unsigned NumKinds) + : OMPDirectiveListClause( +llvm::omp::OMPC_contains, StartLoc, LParenLoc, EndLoc, NumKinds) {} + + /// Build an empty clause. + OMPContainsClause(unsigned NumKinds) + : OMPDirectiveListClause( +llvm::omp::OMPC_contains, SourceLocation(), SourceLocation(), +SourceLocation(), NumKinds) {} + alexey-bataev wrote: Private or protected constructors https://github.com/llvm/llvm-project/pull/92731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [OpenMP] OpenMP 5.1 "assume" directive parsing support (PR #92731)
@@ -2013,6 +2064,184 @@ class OMPMergeableClause : public OMPClause { } }; +/// This represents the 'absent' clause in the '#pragma omp assume' +/// directive. +/// +/// \code +/// #pragma omp assume absent() +/// \endcode +/// In this example directive '#pragma omp assume' has an 'absent' clause. +class OMPAbsentClause final +: public OMPDirectiveListClause, + private llvm::TrailingObjects { + friend OMPDirectiveListClause; + friend TrailingObjects; + +public: + /// Build 'absent' clause. + /// + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param EndLoc Ending location of the clause. + /// \param NumKinds Number of directive kinds listed in the clause. + OMPAbsentClause(SourceLocation StartLoc, SourceLocation LParenLoc, + SourceLocation EndLoc, unsigned NumKinds) + : OMPDirectiveListClause( +llvm::omp::OMPC_absent, StartLoc, LParenLoc, EndLoc, NumKinds) {} + + /// Build an empty clause. + OMPAbsentClause(unsigned NumKinds) + : OMPDirectiveListClause( +llvm::omp::OMPC_absent, SourceLocation(), SourceLocation(), +SourceLocation(), NumKinds) {} + + static OMPAbsentClause *Create(const ASTContext , + ArrayRef DKVec, + SourceLocation Loc, SourceLocation LLoc, + SourceLocation RLoc); + + static OMPAbsentClause *CreateEmpty(const ASTContext , unsigned NumKinds); + + static bool classof(const OMPClause *C) { +return C->getClauseKind() == llvm::omp::OMPC_absent; + } +}; + +/// This represents the 'contains' clause in the '#pragma omp assume' +/// directive. +/// +/// \code +/// #pragma omp assume contains() +/// \endcode +/// In this example directive '#pragma omp assume' has a 'contains' clause. +class OMPContainsClause final +: public OMPDirectiveListClause, + private llvm::TrailingObjects { + friend OMPDirectiveListClause; + friend TrailingObjects; + +public: + /// Build 'contains' clause. + /// + /// \param StartLoc Starting location of the clause. + /// \param LParenLoc Location of '('. + /// \param EndLoc Ending location of the clause. + /// \param NumKinds Number of directive kinds listed in the clause. + OMPContainsClause(SourceLocation StartLoc, SourceLocation LParenLoc, +SourceLocation EndLoc, unsigned NumKinds) + : OMPDirectiveListClause( +llvm::omp::OMPC_contains, StartLoc, LParenLoc, EndLoc, NumKinds) {} + + /// Build an empty clause. + OMPContainsClause(unsigned NumKinds) + : OMPDirectiveListClause( +llvm::omp::OMPC_contains, SourceLocation(), SourceLocation(), +SourceLocation(), NumKinds) {} + + static OMPContainsClause *Create(const ASTContext , + ArrayRef DKVec, + SourceLocation Loc, SourceLocation LLoc, + SourceLocation RLoc); + + static OMPContainsClause *CreateEmpty(const ASTContext , unsigned NumKinds); + + static bool classof(const OMPClause *C) { +return C->getClauseKind() == llvm::omp::OMPC_contains; + } +}; + +/// This represents the 'holds' clause in the '#pragma omp assume' +/// directive. +/// +/// \code +/// #pragma omp assume holds() +/// \endcode +/// In this example directive '#pragma omp assume' has a 'holds' clause. +class OMPHoldsClause final +: public OMPOneStmtClause { + friend class OMPClauseReader; + +public: + /// Build 'holds' clause. + /// + /// \param StartLoc Starting location of the clause. + /// \param EndLoc Ending location of the clause. + OMPHoldsClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc, + SourceLocation EndLoc) + : OMPOneStmtClause(E, StartLoc, LParenLoc, EndLoc) {} + + /// Build an empty clause. + OMPHoldsClause() : OMPOneStmtClause() {} + + Expr *getExpr() const { return getStmtAs(); } + void setExpr(Expr *E) { setStmt(E); } +}; + +/// This represents the 'no_openmp' clause in the '#pragma omp assume' +/// directive. +/// +/// \code +/// #pragma omp assume no_openmp +/// \endcode +/// In this example directive '#pragma omp assume' has a 'no_openmp' clause. +class OMPNoOpenMPClause final +: public OMPNoChildClause { +public: + /// Build 'no_openmp' clause. + /// + /// \param StartLoc Starting location of the clause. + /// \param EndLoc Ending location of the clause. + OMPNoOpenMPClause(SourceLocation StartLoc, SourceLocation EndLoc) + : OMPNoChildClause(StartLoc, EndLoc) {} + + /// Build an empty clause. + OMPNoOpenMPClause() : OMPNoChildClause() {} +}; + +/// This represents the 'no_openmp_routines' clause in the '#pragma omp assume' +/// directive. +/// +/// \code +/// #pragma omp assume no_openmp_routines +/// \endcode +/// In this example directive '#pragma omp assume' has a 'no_openmp_routines' +/// clause. +class
[clang] [llvm] [OpenMP] OpenMP 5.1 "assume" directive parsing support (PR #92731)
@@ -342,6 +342,57 @@ template class OMPVarListClause : public OMPClause { } }; +template class OMPDirectiveListClause : public OMPClause { alexey-bataev wrote: Why do you need this? https://github.com/llvm/llvm-project/pull/92731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [libcxx] [llvm] [cmake] switch to CMake's native `check_{compiler,linker}_flag` (PR #96171)
ldionne wrote: @rorth Please check if this is still broken after https://github.com/llvm/llvm-project/commit/7ab643383fe49d5bb22e45610cb52476bf7a922e https://github.com/llvm/llvm-project/pull/96171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 7ab6433 - [libclang] Use check_linker_flag instead of llvm_check_linker_flag
Author: Louis Dionne Date: 2024-07-31T10:50:34-04:00 New Revision: 7ab643383fe49d5bb22e45610cb52476bf7a922e URL: https://github.com/llvm/llvm-project/commit/7ab643383fe49d5bb22e45610cb52476bf7a922e DIFF: https://github.com/llvm/llvm-project/commit/7ab643383fe49d5bb22e45610cb52476bf7a922e.diff LOG: [libclang] Use check_linker_flag instead of llvm_check_linker_flag Follow-up to #96171 in an attempt to fix the Solaris bots. Added: Modified: clang/tools/libclang/CMakeLists.txt Removed: diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt index 7b634003d11f4..968b46acb784c 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -190,8 +190,8 @@ if(ENABLE_SHARED) include(CheckLinkerFlag) # The Solaris 11.4 linker supports a subset of GNU ld version scripts, # but requires a special option to enable it. - llvm_check_linker_flag(CXX "-Wl,-z,gnu-version-script-compat" - LINKER_SUPPORTS_Z_GNU_VERSION_SCRIPT_COMPAT) + check_linker_flag(CXX "-Wl,-z,gnu-version-script-compat" +LINKER_SUPPORTS_Z_GNU_VERSION_SCRIPT_COMPAT) # Older Solaris (and illumos) linker does not support GNU ld version scripts # and does not support GNU version script compat. if (LINKER_SUPPORTS_Z_GNU_VERSION_SCRIPT_COMPAT) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] AST support for WaveSize attribute. (PR #101240)
@@ -245,6 +274,18 @@ void SemaHLSL::CheckEntryPoint(FunctionDecl *FD) { << llvm::Triple::getEnvironmentTypeName(ST); FD->setInvalidDecl(); } +if (const auto *NT = FD->getAttr()) { python3kgae wrote: Renamed. https://github.com/llvm/llvm-project/pull/101240 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] AST support for WaveSize attribute. (PR #101240)
@@ -245,6 +274,18 @@ void SemaHLSL::CheckEntryPoint(FunctionDecl *FD) { << llvm::Triple::getEnvironmentTypeName(ST); FD->setInvalidDecl(); } +if (const auto *NT = FD->getAttr()) { + if (Ver < VersionTuple(6, 6)) { +Diag(NT->getLocation(), diag::err_hlsl_attribute_in_wrong_shader_model) +<< "wavesize" python3kgae wrote: Fixed. https://github.com/llvm/llvm-project/pull/101240 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL] AST support for WaveSize attribute. (PR #101240)
@@ -12361,6 +12361,21 @@ def warn_hlsl_availability_unavailable : def err_hlsl_export_not_on_function : Error< "export declaration can only be used on functions">; +def err_hlsl_attribute_in_wrong_shader_model: Error< + "attribute %0 requires shader model %1 or greater">; + +def err_hlsl_wavesize_size: Error< + "wavesize arguments must be between 4 and 128 and a power of 2">; +def err_hlsl_wavesize_min_geq_max: Error< + "minimum wavesize value %0 must be less than maximum wavesize value %1">; +def warn_hlsl_wavesize_min_eq_max: Warning< + "wave size range minimum and maximum are equal">, + InGroup, DefaultError; +def err_hlsl_wavesize_pref_size_out_of_range: Error< + "preferred wavesize value %0 must be between %1 and %2">; +def err_hlsl_wavesize_insufficient_shader_model: Error< + "wavesize only takes multiple arguments in shader model 6.8 or higher">; python3kgae wrote: Updated to ``` def err_hlsl_attribute_number_arguments_insufficient_shader_model: Error< "attribute %0 with %1 arguments requires shader model %2 or greater">; ``` https://github.com/llvm/llvm-project/pull/101240 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [libcxx] [llvm] [cmake] switch to CMake's native `check_{compiler,linker}_flag` (PR #96171)
rorth wrote: This patch broke the [Solaris/amd64](https://lab.llvm.org/staging/#/builders/120/builds/485) and [Solaris/sparcv9](https://lab.llvm.org/buildbot/#/builders/13/builds/1287) buildbots. https://github.com/llvm/llvm-project/pull/96171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][OpenMP] Diagnose badly-formed collapsed imperfect loop nests (#60678) (PR #101305)
@@ -9475,6 +9555,36 @@ static Expr *buildPostUpdate(Sema , ArrayRef PostUpdates) { return PostUpdate; } +class ForVarDeclFinder : public RecursiveASTVisitor { alexey-bataev wrote: final class and description https://github.com/llvm/llvm-project/pull/101305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][OpenMP] Diagnose badly-formed collapsed imperfect loop nests (#60678) (PR #101305)
@@ -9475,6 +9555,36 @@ static Expr *buildPostUpdate(Sema , ArrayRef PostUpdates) { return PostUpdate; } +class ForVarDeclFinder : public RecursiveASTVisitor { + int NestingDepth; alexey-bataev wrote: `int NestingDepth = 0;` https://github.com/llvm/llvm-project/pull/101305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][OpenMP] Diagnose badly-formed collapsed imperfect loop nests (#60678) (PR #101305)
@@ -9069,7 +9147,8 @@ static bool checkOpenMPIterationSpace( Expr *OrderedLoopCountExpr, SemaOpenMP::VarsWithInheritedDSAType , llvm::MutableArrayRef ResultIterSpaces, -llvm::MapVector ) { +llvm::MapVector , +const llvm::SmallSet *CollapsedLoopVarDecls) { alexey-bataev wrote: Reference and SmallSetImpl https://github.com/llvm/llvm-project/pull/101305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][OpenMP] Diagnose badly-formed collapsed imperfect loop nests (#60678) (PR #101305)
@@ -7668,6 +7669,47 @@ struct LoopIterationSpace final { Expr *FinalCondition = nullptr; }; +class ForSubExprChecker : public RecursiveASTVisitor { + const llvm::SmallSet *CollapsedLoopVarDecls; + VarDecl *ForbiddenVar; alexey-bataev wrote: `VarDecl *ForbiddenVar = nullptr;` https://github.com/llvm/llvm-project/pull/101305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][OpenMP] Diagnose badly-formed collapsed imperfect loop nests (#60678) (PR #101305)
@@ -7668,6 +7669,47 @@ struct LoopIterationSpace final { Expr *FinalCondition = nullptr; }; +class ForSubExprChecker : public RecursiveASTVisitor { + const llvm::SmallSet *CollapsedLoopVarDecls; + VarDecl *ForbiddenVar; + SourceRange ErrLoc; + +public: + explicit ForSubExprChecker( + const llvm::SmallSet *CollapsedLoopVarDecls) + : CollapsedLoopVarDecls(CollapsedLoopVarDecls), ForbiddenVar(nullptr) {} + + bool shouldVisitImplicitCode() const { return true; } + + bool VisitDeclRefExpr(DeclRefExpr *E) { +ValueDecl *VD = E->getDecl(); +if (!isa(VD)) + return true; +VarDecl *V = VD->getPotentiallyDecomposedVarDecl(); +if (V->getType()->isReferenceType()) { + VarDecl *VD = V->getDefinition(); + if (VD->hasInit()) { +Expr *I = VD->getInit(); +DeclRefExpr *DRE = dyn_cast(I); +if (!DRE) + return true; +V = DRE->getDecl()->getPotentiallyDecomposedVarDecl(); + } +} +Decl *Canon = V->getCanonicalDecl(); +if (CollapsedLoopVarDecls->contains(Canon)) { + ForbiddenVar = V; + ErrLoc = E->getSourceRange(); + return false; +} + +return true; + } + + VarDecl *getForbiddenVar() { return ForbiddenVar; } + SourceRange () { return ErrLoc; } alexey-bataev wrote: const functions https://github.com/llvm/llvm-project/pull/101305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][OpenMP] Diagnose badly-formed collapsed imperfect loop nests (#60678) (PR #101305)
@@ -7668,6 +7669,47 @@ struct LoopIterationSpace final { Expr *FinalCondition = nullptr; }; +class ForSubExprChecker : public RecursiveASTVisitor { + const llvm::SmallSet *CollapsedLoopVarDecls; + VarDecl *ForbiddenVar; + SourceRange ErrLoc; + +public: + explicit ForSubExprChecker( + const llvm::SmallSet *CollapsedLoopVarDecls) + : CollapsedLoopVarDecls(CollapsedLoopVarDecls), ForbiddenVar(nullptr) {} + + bool shouldVisitImplicitCode() const { return true; } alexey-bataev wrote: unused? Drop then https://github.com/llvm/llvm-project/pull/101305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HIP] Fix __clang_hip_cmath.hip for ambiguity (PR #101341)
llvmbot wrote: @llvm/pr-subscribers-backend-x86 Author: Yaxun (Sam) Liu (yxsamliu) Changes If there is a type T which can be converted to both float and double etc but itself is not specialized for __numeric_type, and it is called for math functions eg. fma, it will cause ambiguity with test function of __numeric_type. Since test is not template, this error is not bypassed by SFINAE. This is a design flaw of __numeric_type. This patch fixes clang wrapper header to use SFINAE to avoid such ambiguity. Fixes: SWDEV-461604 Fixes: https://github.com/llvm/llvm-project/issues/101239 --- Full diff: https://github.com/llvm/llvm-project/pull/101341.diff 2 Files Affected: - (modified) clang/lib/Headers/__clang_hip_cmath.h (+6-1) - (modified) clang/test/Headers/__clang_hip_cmath.hip (+19) ``diff diff --git a/clang/lib/Headers/__clang_hip_cmath.h b/clang/lib/Headers/__clang_hip_cmath.h index b52d6b7816611..7d982ad9af7ee 100644 --- a/clang/lib/Headers/__clang_hip_cmath.h +++ b/clang/lib/Headers/__clang_hip_cmath.h @@ -395,7 +395,12 @@ template struct __numeric_type { // No support for long double, use double instead. static double __test(long double); - typedef decltype(__test(declval<_Tp>())) type; + template + static auto __test_impl(int) -> decltype(__test(declval<_U>())); + + template static void __test_impl(...); + + typedef decltype(__test_impl<_Tp>(0)) type; static const bool value = !is_same::value; }; diff --git a/clang/test/Headers/__clang_hip_cmath.hip b/clang/test/Headers/__clang_hip_cmath.hip index ed1030b820627..0c9ff4cdd7808 100644 --- a/clang/test/Headers/__clang_hip_cmath.hip +++ b/clang/test/Headers/__clang_hip_cmath.hip @@ -87,3 +87,22 @@ extern "C" __device__ float test_sin_f32(float x) { extern "C" __device__ float test_cos_f32(float x) { return cos(x); } + +// Check user defined type which can be converted to float and double but not +// specializes __numeric_type will not cause ambiguity diagnostics. +struct user_bfloat16 { + __host__ __device__ user_bfloat16(float); + operator float(); + operator double(); +}; + +namespace user_namespace { + __device__ user_bfloat16 fma(const user_bfloat16 a, const user_bfloat16 b, const user_bfloat16 c) { +return a; + } + + __global__ void test_fma() { +user_bfloat16 a = 1.0f, b = 2.0f; +fma(a, b, b); + } +} `` https://github.com/llvm/llvm-project/pull/101341 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [libcxx] [llvm] [cmake] switch to CMake's native `check_{compiler,linker}_flag` (PR #96171)
https://github.com/ldionne closed https://github.com/llvm/llvm-project/pull/96171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HIP] Fix __clang_hip_cmath.hip for ambiguity (PR #101341)
https://github.com/yxsamliu created https://github.com/llvm/llvm-project/pull/101341 If there is a type T which can be converted to both float and double etc but itself is not specialized for __numeric_type, and it is called for math functions eg. fma, it will cause ambiguity with test function of __numeric_type. Since test is not template, this error is not bypassed by SFINAE. This is a design flaw of __numeric_type. This patch fixes clang wrapper header to use SFINAE to avoid such ambiguity. Fixes: SWDEV-461604 Fixes: https://github.com/llvm/llvm-project/issues/101239 >From 07d6d9392d3ec9f6054f988252da75203b346fd4 Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Tue, 30 Jul 2024 16:51:23 -0400 Subject: [PATCH] [HIP] Fix __clang_hip_cmath.hip for ambiguity If there is a type T which can be converted to both float and double etc but itself is not specialized for __numeric_type, and it is called for math functions eg. fma, it will cause ambiguity with test function of __numeric_type. Since test is not template, this error is not bypassed by SFINAE. This is a design flaw of __numeric_type. This patch fixes clang wrapper header to use SFINAE to avoid such ambiguity. Fixes: SWDEV-461604 Fixes: https://github.com/llvm/llvm-project/issues/101239 --- clang/lib/Headers/__clang_hip_cmath.h| 7 ++- clang/test/Headers/__clang_hip_cmath.hip | 19 +++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/clang/lib/Headers/__clang_hip_cmath.h b/clang/lib/Headers/__clang_hip_cmath.h index b52d6b7816611..7d982ad9af7ee 100644 --- a/clang/lib/Headers/__clang_hip_cmath.h +++ b/clang/lib/Headers/__clang_hip_cmath.h @@ -395,7 +395,12 @@ template struct __numeric_type { // No support for long double, use double instead. static double __test(long double); - typedef decltype(__test(declval<_Tp>())) type; + template + static auto __test_impl(int) -> decltype(__test(declval<_U>())); + + template static void __test_impl(...); + + typedef decltype(__test_impl<_Tp>(0)) type; static const bool value = !is_same::value; }; diff --git a/clang/test/Headers/__clang_hip_cmath.hip b/clang/test/Headers/__clang_hip_cmath.hip index ed1030b820627..0c9ff4cdd7808 100644 --- a/clang/test/Headers/__clang_hip_cmath.hip +++ b/clang/test/Headers/__clang_hip_cmath.hip @@ -87,3 +87,22 @@ extern "C" __device__ float test_sin_f32(float x) { extern "C" __device__ float test_cos_f32(float x) { return cos(x); } + +// Check user defined type which can be converted to float and double but not +// specializes __numeric_type will not cause ambiguity diagnostics. +struct user_bfloat16 { + __host__ __device__ user_bfloat16(float); + operator float(); + operator double(); +}; + +namespace user_namespace { + __device__ user_bfloat16 fma(const user_bfloat16 a, const user_bfloat16 b, const user_bfloat16 c) { +return a; + } + + __global__ void test_fma() { +user_bfloat16 a = 1.0f, b = 2.0f; +fma(a, b, b); + } +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [libcxx] [llvm] [cmake] switch to CMake's native `check_{compiler,linker}_flag` (PR #96171)
https://github.com/ldionne approved this pull request. https://github.com/llvm/llvm-project/pull/96171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Revert "[CMake][Fuchsia] Include libunwind and libc++abi in baremetal build" (PR #101340)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Petr Hosek (petrhosek) Changes Reverts llvm/llvm-project#100908 --- Full diff: https://github.com/llvm/llvm-project/pull/101340.diff 1 Files Affected: - (modified) clang/cmake/caches/Fuchsia-stage2.cmake (+8-34) ``diff diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake index c1d0d7b63f957..75ceb799352f9 100644 --- a/clang/cmake/caches/Fuchsia-stage2.cmake +++ b/clang/cmake/caches/Fuchsia-stage2.cmake @@ -312,7 +312,6 @@ foreach(target armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi) set(BUILTINS_${target}_CMAKE_${lang}_local_flags "${BUILTINS_${target}_CMAKE_${lang}_local_flags} -mfloat-abi=softfp -march=armv8m.main+fp+dsp -mcpu=cortex-m33" CACHE STRING "") endif() set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "${BUILTINS_${target}_CMAKE_${lang}_local_flags}" CACHE STRING "") -set(BUILTINS_${target}_CMAKE_${lang}_FLAGS_MINSIZEREL "-Oz -DNDEBUG" CACHE STRING "") endforeach() foreach(type SHARED;MODULE;EXE) set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") @@ -333,7 +332,6 @@ foreach(target armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi) set(RUNTIMES_${target}_CMAKE_${lang}_local_flags "${RUNTIMES_${target}_CMAKE_${lang}_local_flags} -mfloat-abi=softfp -march=armv8m.main+fp+dsp -mcpu=cortex-m33" CACHE STRING "") endif() set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "${RUNTIMES_${target}_CMAKE_${lang}_local_flags}" CACHE STRING "") -set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS_MINSIZEREL "-Oz -DNDEBUG" CACHE STRING "") endforeach() foreach(type SHARED;MODULE;EXE) set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") @@ -341,23 +339,11 @@ foreach(target armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi) set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "") set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "") set(RUNTIMES_${target}_LIBC_USE_NEW_HEADER_GEN OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_IS_BAREMETAL ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_ENABLE_ASSERTIONS OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_ENABLE_THREADS OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_ENABLE_STATIC ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_REMEMBER_HEAP_ALLOC ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_BAREMETAL ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_ENABLE_ASSERTIONS OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_ENABLE_THREADS OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXX_ABI_UNSTABLE ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "") + set(RUNTIMES_${target}_LIBCXX_CXX_ABI none CACHE STRING "") set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "") set(RUNTIMES_${target}_LIBCXX_LIBC "llvm-libc" CACHE STRING "") set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "") set(RUNTIMES_${target}_LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "") @@ -371,7 +357,7 @@ foreach(target armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi) set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "") set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "") - set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc;libunwind;libcxxabi;libcxx" CACHE STRING "") + set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc;libcxx" CACHE STRING "") endforeach() foreach(target riscv32-unknown-elf) @@ -405,23 +391,11 @@ foreach(target riscv32-unknown-elf) set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "") set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "") set(RUNTIMES_${target}_LIBC_USE_NEW_HEADER_GEN OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_IS_BAREMETAL ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_ENABLE_ASSERTIONS OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_ENABLE_THREADS OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_ENABLE_STATIC ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_REMEMBER_HEAP_ALLOC ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL
[clang] Revert "[CMake][Fuchsia] Include libunwind and libc++abi in baremetal build" (PR #101340)
https://github.com/petrhosek closed https://github.com/llvm/llvm-project/pull/101340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 9b017db - Revert "[CMake][Fuchsia] Include libunwind and libc++abi in baremetal build" (#101340)
Author: Petr Hosek Date: 2024-07-31T07:26:45-07:00 New Revision: 9b017db6be8213a989517b494b56fc711af8bf8c URL: https://github.com/llvm/llvm-project/commit/9b017db6be8213a989517b494b56fc711af8bf8c DIFF: https://github.com/llvm/llvm-project/commit/9b017db6be8213a989517b494b56fc711af8bf8c.diff LOG: Revert "[CMake][Fuchsia] Include libunwind and libc++abi in baremetal build" (#101340) Reverts llvm/llvm-project#100908 Added: Modified: clang/cmake/caches/Fuchsia-stage2.cmake Removed: diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake index c1d0d7b63f957..75ceb799352f9 100644 --- a/clang/cmake/caches/Fuchsia-stage2.cmake +++ b/clang/cmake/caches/Fuchsia-stage2.cmake @@ -312,7 +312,6 @@ foreach(target armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi) set(BUILTINS_${target}_CMAKE_${lang}_local_flags "${BUILTINS_${target}_CMAKE_${lang}_local_flags} -mfloat-abi=softfp -march=armv8m.main+fp+dsp -mcpu=cortex-m33" CACHE STRING "") endif() set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "${BUILTINS_${target}_CMAKE_${lang}_local_flags}" CACHE STRING "") -set(BUILTINS_${target}_CMAKE_${lang}_FLAGS_MINSIZEREL "-Oz -DNDEBUG" CACHE STRING "") endforeach() foreach(type SHARED;MODULE;EXE) set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") @@ -333,7 +332,6 @@ foreach(target armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi) set(RUNTIMES_${target}_CMAKE_${lang}_local_flags "${RUNTIMES_${target}_CMAKE_${lang}_local_flags} -mfloat-abi=softfp -march=armv8m.main+fp+dsp -mcpu=cortex-m33" CACHE STRING "") endif() set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "${RUNTIMES_${target}_CMAKE_${lang}_local_flags}" CACHE STRING "") -set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS_MINSIZEREL "-Oz -DNDEBUG" CACHE STRING "") endforeach() foreach(type SHARED;MODULE;EXE) set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") @@ -341,23 +339,11 @@ foreach(target armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi) set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "") set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "") set(RUNTIMES_${target}_LIBC_USE_NEW_HEADER_GEN OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_IS_BAREMETAL ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_ENABLE_ASSERTIONS OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_ENABLE_THREADS OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_ENABLE_STATIC ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_REMEMBER_HEAP_ALLOC ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_BAREMETAL ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_ENABLE_ASSERTIONS OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_ENABLE_THREADS OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXX_ABI_UNSTABLE ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "") + set(RUNTIMES_${target}_LIBCXX_CXX_ABI none CACHE STRING "") set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "") set(RUNTIMES_${target}_LIBCXX_LIBC "llvm-libc" CACHE STRING "") set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "") set(RUNTIMES_${target}_LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "") @@ -371,7 +357,7 @@ foreach(target armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi) set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "") set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "") - set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc;libunwind;libcxxabi;libcxx" CACHE STRING "") + set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc;libcxx" CACHE STRING "") endforeach() foreach(target riscv32-unknown-elf) @@ -405,23 +391,11 @@ foreach(target riscv32-unknown-elf) set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "") set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "") set(RUNTIMES_${target}_LIBC_USE_NEW_HEADER_GEN OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_IS_BAREMETAL ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_ENABLE_ASSERTIONS OFF CACHE BOOL "") -
[clang] Revert "[CMake][Fuchsia] Include libunwind and libc++abi in baremetal build" (PR #101340)
https://github.com/petrhosek created https://github.com/llvm/llvm-project/pull/101340 Reverts llvm/llvm-project#100908 >From 33647147cc824557560cbb31e2e09cc99ea6e940 Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Wed, 31 Jul 2024 07:26:19 -0700 Subject: [PATCH] =?UTF-8?q?Revert=20"[CMake][Fuchsia]=20Include=20libunwin?= =?UTF-8?q?d=20and=20libc++abi=20in=20baremetal=20build=20(=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 8300eaad0f6c354f40f526f7501b624ffc389e63. --- clang/cmake/caches/Fuchsia-stage2.cmake | 42 + 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake index c1d0d7b63f957..75ceb799352f9 100644 --- a/clang/cmake/caches/Fuchsia-stage2.cmake +++ b/clang/cmake/caches/Fuchsia-stage2.cmake @@ -312,7 +312,6 @@ foreach(target armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi) set(BUILTINS_${target}_CMAKE_${lang}_local_flags "${BUILTINS_${target}_CMAKE_${lang}_local_flags} -mfloat-abi=softfp -march=armv8m.main+fp+dsp -mcpu=cortex-m33" CACHE STRING "") endif() set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "${BUILTINS_${target}_CMAKE_${lang}_local_flags}" CACHE STRING "") -set(BUILTINS_${target}_CMAKE_${lang}_FLAGS_MINSIZEREL "-Oz -DNDEBUG" CACHE STRING "") endforeach() foreach(type SHARED;MODULE;EXE) set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") @@ -333,7 +332,6 @@ foreach(target armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi) set(RUNTIMES_${target}_CMAKE_${lang}_local_flags "${RUNTIMES_${target}_CMAKE_${lang}_local_flags} -mfloat-abi=softfp -march=armv8m.main+fp+dsp -mcpu=cortex-m33" CACHE STRING "") endif() set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "${RUNTIMES_${target}_CMAKE_${lang}_local_flags}" CACHE STRING "") -set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS_MINSIZEREL "-Oz -DNDEBUG" CACHE STRING "") endforeach() foreach(type SHARED;MODULE;EXE) set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") @@ -341,23 +339,11 @@ foreach(target armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi) set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "") set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "") set(RUNTIMES_${target}_LIBC_USE_NEW_HEADER_GEN OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_IS_BAREMETAL ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_ENABLE_ASSERTIONS OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_ENABLE_THREADS OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_ENABLE_STATIC ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_REMEMBER_HEAP_ALLOC ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_BAREMETAL ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_ENABLE_ASSERTIONS OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_ENABLE_THREADS OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") - set(RUNTIMES_${target}_LIBCXX_ABI_UNSTABLE ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "") + set(RUNTIMES_${target}_LIBCXX_CXX_ABI none CACHE STRING "") set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "") set(RUNTIMES_${target}_LIBCXX_LIBC "llvm-libc" CACHE STRING "") set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "") set(RUNTIMES_${target}_LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "") @@ -371,7 +357,7 @@ foreach(target armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m.main-unknown-eabi) set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") set(RUNTIMES_${target}_LLVM_INCLUDE_TESTS OFF CACHE BOOL "") set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "") - set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc;libunwind;libcxxabi;libcxx" CACHE STRING "") + set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "libc;libcxx" CACHE STRING "") endforeach() foreach(target riscv32-unknown-elf) @@ -405,23 +391,11 @@ foreach(target riscv32-unknown-elf) set(RUNTIMES_${target}_LLVM_LIBC_FULL_BUILD ON CACHE BOOL "") set(RUNTIMES_${target}_LIBC_ENABLE_USE_BY_CLANG ON CACHE BOOL "") set(RUNTIMES_${target}_LIBC_USE_NEW_HEADER_GEN OFF CACHE BOOL "") - set(RUNTIMES_${target}_LIBUNWIND_IS_BAREMETAL ON CACHE BOOL "") -
[clang] [Clang][OpenMP] fix issue: Implicit conversion with `pragma omp taskloop` #100536 (PR #101307)
https://github.com/HenryZ16 updated https://github.com/llvm/llvm-project/pull/101307 >From 75879fa7a7e163ea350c11f37b24c0b2f5231c35 Mon Sep 17 00:00:00 2001 From: HenryZ16 <1546169...@qq.com> Date: Wed, 31 Jul 2024 02:34:04 -0600 Subject: [PATCH] fix issue #100536: Implicit conversion with `pragma omp taskloop` --- clang/lib/Sema/SemaOpenMP.cpp | 32 +--- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 4f50efda155fb..ddf1dd9824e04 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -9758,7 +9758,6 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, LastIteration.get(), UB.get()); EUB = SemaRef.BuildBinOp(CurScope, InitLoc, BO_Assign, UB.get(), CondOp.get()); -EUB = SemaRef.ActOnFinishFullExpr(EUB.get(), /*DiscardedValue*/ false); // If we have a combined directive that combines 'distribute', 'for' or // 'simd' we need to be able to access the bounds of the schedule of the @@ -9787,8 +9786,6 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, LastIteration.get(), CombUB.get()); CombEUB = SemaRef.BuildBinOp(CurScope, InitLoc, BO_Assign, CombUB.get(), CombCondOp.get()); - CombEUB = - SemaRef.ActOnFinishFullExpr(CombEUB.get(), /*DiscardedValue*/ false); const CapturedDecl *CD = cast(AStmt)->getCapturedDecl(); // We expect to have at least 2 more parameters than the 'parallel' @@ -9824,7 +9821,6 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, ? LB.get() : SemaRef.ActOnIntegerConstant(SourceLocation(), 0).get(); Init = SemaRef.BuildBinOp(CurScope, InitLoc, BO_Assign, IV.get(), RHS); -Init = SemaRef.ActOnFinishFullExpr(Init.get(), /*DiscardedValue*/ false); if (isOpenMPLoopBoundSharingDirective(DKind)) { Expr *CombRHS = @@ -9836,8 +9832,6 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, : SemaRef.ActOnIntegerConstant(SourceLocation(), 0).get(); CombInit = SemaRef.BuildBinOp(CurScope, InitLoc, BO_Assign, IV.get(), CombRHS); - CombInit = - SemaRef.ActOnFinishFullExpr(CombInit.get(), /*DiscardedValue*/ false); } } @@ -9856,8 +9850,6 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, .BuildBinOp(CurScope, CondLoc, BO_Add, BoundUB, SemaRef.ActOnIntegerConstant(SourceLocation(), 1).get()) .get(); -BoundUB = -SemaRef.ActOnFinishFullExpr(BoundUB, /*DiscardedValue*/ false).get(); } ExprResult Cond = (isOpenMPWorksharingDirective(DKind) || @@ -9885,9 +9877,6 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, CurScope, CondLoc, BO_Add, BoundCombUB, SemaRef.ActOnIntegerConstant(SourceLocation(), 1).get()) .get(); - BoundCombUB = - SemaRef.ActOnFinishFullExpr(BoundCombUB, /*DiscardedValue*/ false) - .get(); } CombCond = SemaRef.BuildBinOp(CurScope, CondLoc, UseStrictCompare ? BO_LT : BO_LE, @@ -9901,7 +9890,6 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, if (!Inc.isUsable()) return 0; Inc = SemaRef.BuildBinOp(CurScope, IncLoc, BO_Assign, IV.get(), Inc.get()); - Inc = SemaRef.ActOnFinishFullExpr(Inc.get(), /*DiscardedValue*/ false); if (!Inc.isUsable()) return 0; @@ -9921,8 +9909,6 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, // LB = LB + ST NextLB = SemaRef.BuildBinOp(CurScope, IncLoc, BO_Assign, LB.get(), NextLB.get()); -NextLB = -SemaRef.ActOnFinishFullExpr(NextLB.get(), /*DiscardedValue*/ false); if (!NextLB.isUsable()) return 0; // UB + ST @@ -9932,8 +9918,6 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, // UB = UB + ST NextUB = SemaRef.BuildBinOp(CurScope, IncLoc, BO_Assign, UB.get(), NextUB.get()); -NextUB = -SemaRef.ActOnFinishFullExpr(NextUB.get(), /*DiscardedValue*/ false); if (!NextUB.isUsable()) return 0; if (isOpenMPLoopBoundSharingDirective(DKind)) { @@ -9944,8 +9928,6 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, // LB = LB + ST CombNextLB = SemaRef.BuildBinOp(CurScope, IncLoc, BO_Assign, CombLB.get(), CombNextLB.get()); - CombNextLB = SemaRef.ActOnFinishFullExpr(CombNextLB.get(), - /*DiscardedValue*/ false); if (!CombNextLB.isUsable()) return 0; // UB + ST @@ -9956,8 +9938,6 @@
[clang] [HLSL] Implement output parameter (PR #101083)
@@ -4689,6 +4719,32 @@ void CodeGenFunction::EmitCallArg(CallArgList , const Expr *E, assert(type->isReferenceType() == E->isGLValue() && "reference binding to unmaterialized r-value!"); + // Add writeback for HLSLOutParamExpr. + if (const HLSLOutArgExpr *OE = dyn_cast(E)) { +LValue LV = EmitLValue(E); +llvm::Type *ElTy = ConvertTypeForMem(LV.getType()); +llvm::Value *Addr, *BaseAddr; +if (LV.isExtVectorElt()) { + llvm::Constant *VecElts = LV.getExtVectorElts(); + BaseAddr = LV.getExtVectorAddress().getBasePointer(); + Addr = Builder.CreateGEP( + ElTy, BaseAddr, + {Builder.getInt32(0), VecElts->getAggregateElement((unsigned)0)}); +} else // LV.getAddress() will assert if this is not a simple LValue. + Addr = BaseAddr = LV.getAddress().getBasePointer(); + +llvm::TypeSize Sz = +CGM.getDataLayout().getTypeAllocSize(ConvertTypeForMem(LV.getType())); + +llvm::Value *LifetimeSize = EmitLifetimeStart(Sz, BaseAddr); + +Address TmpAddr(Addr, ElTy, LV.getAlignment()); +// TODO-HLSLOutArgExp: Fix me!!! llvm-beanz wrote: Doh. I think that's just a stale comment, but let me verify that all the test coverage is correct. https://github.com/llvm/llvm-project/pull/101083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ASTImporter] Remove trailing return testing on lambda proto (PR #101031)
danix800 wrote: > > Here can `ToProcess.append(CurrentS->child_begin(), > > CurrentS->child_end());` add any nullptr into `ToProcess` in this testing > > context? > > I think it is possible, but I could not reproduce this case with the shown > code. We have over 30 C++ open-source projects (including AOSP) in our pipeline to test against potential crashes in the Static Analyzer with CTU enabled, the pipeline can surfaces a few problems in the ASTImporter. I can improve `isAncestorDeclContextOf` if we really can catch crashes. https://github.com/llvm/llvm-project/pull/101031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Implement output parameter (PR #101083)
@@ -5318,3 +5319,13 @@ OMPIteratorExpr *OMPIteratorExpr::CreateEmpty(const ASTContext , alignof(OMPIteratorExpr)); return new (Mem) OMPIteratorExpr(EmptyShell(), NumIterators); } + +HLSLOutArgExpr *HLSLOutArgExpr::Create(const ASTContext , QualType Ty, + Expr *Base, bool IsInOut, Expr *WB, + OpaqueValueExpr *OpV) { + return new (C) HLSLOutArgExpr(Ty, Base, WB, OpV, IsInOut); llvm-beanz wrote: Generally `C.Allocate` is used in contexts where the new operator won't know the full size you're allocating. In some AST nodes we allocate extra space after the node to store trailing pointers to sub-expressions. That can be valuable for reducing the size of the AST if a node can have a variable number of sub-expressions. In this case we always have two sub-expressions, and we always have an `OpaqueValueExpr`. I could reduce the size of the AST node by not caching the `OpaqueValueExpr` and instead traversing down to it when we need it, but I'm unsure that memory savings is worthwhile. https://github.com/llvm/llvm-project/pull/101083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] add support for block commands in clang-doc html output (PR #101108)
@@ -632,6 +633,19 @@ static std::unique_ptr genHTML(const CommentInfo ) { return std::move(ParagraphComment); } + if (I.Kind == "BlockCommandComment") { +auto BlockComment = std::make_unique(HTMLTag::TAG_DIV); +auto Command = std::make_unique(HTMLTag::TAG_DIV, I.Name); +BlockComment->Children.emplace_back(std::move(Command)); +for (const auto : I.Children) { + std::unique_ptr Node = genHTML(*Child); + if (Node) +BlockComment->Children.emplace_back(std::move(Node)); +} +if (BlockComment->Children.empty()) + return nullptr; +return std::move(BlockComment); ilovepi wrote: Do these need to be returned via std::move? Iirc the compiler should do the right thing with return values… The pattern exists elsewhere in this file, it’s not required to change now, but we may want to consider up’s this code to use a more idiomatic style. https://github.com/llvm/llvm-project/pull/101108 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] add support for block commands in clang-doc html output (PR #101108)
@@ -632,6 +633,19 @@ static std::unique_ptr genHTML(const CommentInfo ) { return std::move(ParagraphComment); } + if (I.Kind == "BlockCommandComment") { +auto BlockComment = std::make_unique(HTMLTag::TAG_DIV); +auto Command = std::make_unique(HTMLTag::TAG_DIV, I.Name); +BlockComment->Children.emplace_back(std::move(Command)); ilovepi wrote: You can avoid the move here and just construct in place, right? https://github.com/llvm/llvm-project/pull/101108 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] add support for block commands in clang-doc html output (PR #101108)
@@ -59,32 +59,63 @@ // HTML-SHAPE: class Shape // HTML-SHAPE: Defined at line 8 of file {{.*}}Shape.h +// HTML-SHAPE: brief +// HTML-SHAPE: Abstract base class for shapes. // HTML-SHAPE: Provides a common interface for different types of shapes. // HTML-SHAPE: Functions // HTML-SHAPE: ~Shape // HTML-SHAPE: public void ~Shape() // HTML-SHAPE: Defined at line 13 of file {{.*}}Shape.h +// HTML-SHAPE: brief +// HTML-SHAPE: Virtual destructor. // HTML-SHAPE: area // HTML-SHAPE: public double area() +// HTML-SHAPE: brief +// HTML-SHAPE: Calculates the area of the shape. // HTML-SHAPE: perimeter // HTML-SHAPE: public double perimeter() +// HTML-SHAPE: brief +// HTML-SHAPE: Calculates the perimeter of the shape. +// HTML-SHAPE: return +// HTML-SHAPE: double The perimeter of the shape. -// HTML-CALC: class Calculator -// HTML-CALC: Defined at line 8 of file {{.*}}Calculator.h -// HTML-CALC: Provides basic arithmetic operations. -// HTML-CALC: Functions -// HTML-CALC: add -// HTML-CALC: public int add(int a, int b) -// HTML-CALC: Defined at line 3 of file {{.*}}Calculator.cpp -// HTML-CALC: subtract -// HTML-CALC: public int subtract(int a, int b) -// HTML-CALC: Defined at line 7 of file {{.*}}Calculator.cpp -// HTML-CALC: multiply -// HTML-CALC: public int multiply(int a, int b) -// HTML-CALC: Defined at line 11 of file {{.*}}Calculator.cpp -// HTML-CALC: divide -// HTML-CALC: public double divide(int a, int b) -// HTML-CALC: Defined at line 15 of file {{.*}}Calculator.cpp + +// HTML-CALC: class Calculator ilovepi wrote: Not your problem per de, but why is this line in the diff? AFACT it’s unchanged… https://github.com/llvm/llvm-project/pull/101108 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Implement output parameter (PR #101083)
@@ -4613,14 +4613,13 @@ def HLSLGroupSharedAddressSpace : TypeAttr { let Documentation = [HLSLGroupSharedAddressSpaceDocs]; } -def HLSLParamModifier : TypeAttr { +def HLSLParamModifier : ParameterABIAttr { llvm-beanz wrote: DXC currently parses but ignores the `uniform` keyword. We have an issue to just officially remove it from the language in 202x since it doesn't do anything, so my plan is to not implement it in Clang at all (https://github.com/microsoft/hlsl-specs/issues/135) https://github.com/llvm/llvm-project/pull/101083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AIX] Detect `#pragma mc_func` (PR #99888)
qiongsiwu wrote: > My preference is for this to be on-by-default (then it shows its utility), > and I'd like to see those changes in the 19.x release (which means we'd need > to turn this around fairly quickly as we've already put out rc1). Sounds good! Thanks again for your input @AaronBallman ! https://github.com/llvm/llvm-project/pull/101336 is setup to turn on the check by default. https://github.com/llvm/llvm-project/pull/99888 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AIX] Turn on `#pragma mc_func` check by default (PR #101336)
llvmbot wrote: @llvm/pr-subscribers-clang @llvm/pr-subscribers-backend-powerpc Author: Qiongsi Wu (qiongsiwu) Changes https://github.com/llvm/llvm-project/pull/99888 added a check (and corresponding options) to flag uses of `#pragma mc_func` on AIX. This PR turns on the check by default. --- Full diff: https://github.com/llvm/llvm-project/pull/101336.diff 4 Files Affected: - (modified) clang/include/clang/Driver/Options.td (+1-1) - (modified) clang/include/clang/Lex/PreprocessorOptions.h (+2-2) - (modified) clang/lib/Driver/ToolChains/AIX.cpp (+1-1) - (modified) clang/test/Preprocessor/pragma_mc_func.c (+2-2) ``diff diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index c8c56dbb51b28..7f6b8ba4d7eeb 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8097,7 +8097,7 @@ def source_date_epoch : Separate<["-"], "source-date-epoch">, } // let Visibility = [CC1Option] defm err_pragma_mc_func_aix : BoolFOption<"err-pragma-mc-func-aix", - PreprocessorOpts<"ErrorOnPragmaMcfuncOnAIX">, DefaultFalse, + PreprocessorOpts<"ErrorOnPragmaMcfuncOnAIX">, DefaultTrue, PosFlag, NegFlag&1 | FileCheck %s // RUN: not %clang --target=powerpc64-ibm-aix -ferr-pragma-mc-func-aix -fsyntax-only \ // RUN: %s 2>&1 | FileCheck %s #pragma mc_func asm_barrier {"6000"} @@ -8,11 +9,10 @@ // RUN: %clang --target=powerpc64-ibm-aix -fno-err-pragma-mc-func-aix -fsyntax-only %s // RUN: %clang --target=powerpc64-ibm-aix -ferr-pragma-mc-func-aix -fsyntax-only \ // RUN:-fno-err-pragma-mc-func-aix %s -// RUN: %clang --target=powerpc64-ibm-aix -fsyntax-only %s // RUN: %clang --target=powerpc64-ibm-aix -Werror=unknown-pragmas \ // RUN: -fno-err-pragma-mc-func-aix -fsyntax-only %s -// Cases where we have errors or warnings. +// Cases on a non-AIX target. // RUN: not %clang --target=powerpc64le-unknown-linux-gnu \ // RUN: -Werror=unknown-pragmas -fno-err-pragma-mc-func-aix -fsyntax-only %s 2>&1 | \ // RUN: FileCheck --check-prefix=UNUSED %s `` https://github.com/llvm/llvm-project/pull/101336 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AIX] Turn on `#pragma mc_func` check by default (PR #101336)
https://github.com/qiongsiwu created https://github.com/llvm/llvm-project/pull/101336 https://github.com/llvm/llvm-project/pull/99888 added a check (and corresponding options) to flag uses of `#pragma mc_func` on AIX. This PR turns on the check by default. >From e823d1e7eb3357fc5c15b614ac5fd94d331ac630 Mon Sep 17 00:00:00 2001 From: Qiongsi Wu Date: Wed, 31 Jul 2024 10:12:59 -0400 Subject: [PATCH] Turn on mc_func check by default. --- clang/include/clang/Driver/Options.td | 2 +- clang/include/clang/Lex/PreprocessorOptions.h | 4 ++-- clang/lib/Driver/ToolChains/AIX.cpp | 2 +- clang/test/Preprocessor/pragma_mc_func.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index c8c56dbb51b28..7f6b8ba4d7eeb 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8097,7 +8097,7 @@ def source_date_epoch : Separate<["-"], "source-date-epoch">, } // let Visibility = [CC1Option] defm err_pragma_mc_func_aix : BoolFOption<"err-pragma-mc-func-aix", - PreprocessorOpts<"ErrorOnPragmaMcfuncOnAIX">, DefaultFalse, + PreprocessorOpts<"ErrorOnPragmaMcfuncOnAIX">, DefaultTrue, PosFlag, NegFlag&1 | FileCheck %s // RUN: not %clang --target=powerpc64-ibm-aix -ferr-pragma-mc-func-aix -fsyntax-only \ // RUN: %s 2>&1 | FileCheck %s #pragma mc_func asm_barrier {"6000"} @@ -8,11 +9,10 @@ // RUN: %clang --target=powerpc64-ibm-aix -fno-err-pragma-mc-func-aix -fsyntax-only %s // RUN: %clang --target=powerpc64-ibm-aix -ferr-pragma-mc-func-aix -fsyntax-only \ // RUN:-fno-err-pragma-mc-func-aix %s -// RUN: %clang --target=powerpc64-ibm-aix -fsyntax-only %s // RUN: %clang --target=powerpc64-ibm-aix -Werror=unknown-pragmas \ // RUN: -fno-err-pragma-mc-func-aix -fsyntax-only %s -// Cases where we have errors or warnings. +// Cases on a non-AIX target. // RUN: not %clang --target=powerpc64le-unknown-linux-gnu \ // RUN: -Werror=unknown-pragmas -fno-err-pragma-mc-func-aix -fsyntax-only %s 2>&1 | \ // RUN: FileCheck --check-prefix=UNUSED %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Pass correct alignment for -falign-functions with no argument (PR #101257)
@@ -1982,7 +1982,7 @@ unsigned tools::ParseFunctionAlignment(const ToolChain , return 0; if (A->getOption().matches(options::OPT_falign_functions)) -return 0; +return 4; // log2(16) compnerd wrote: @pogo59 that is documented in the GCC documentation. Many, if not most, of the driver arguments are GCC derived and behave identically. https://github.com/llvm/llvm-project/pull/101257 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] [libcxxabi] [libunwind] [NFC][libc++][libc++abi][libunwind][test] Fix/unify AIX triples used in LIT tests (PR #101196)
@@ -6,7 +6,7 @@ // //===--===// -// REQUIRES: target={{powerpc.*-ibm-aix.*}} +// REQUIRES: target={{.+}}-aix{{.*}} xingxue-ibm wrote: Thanks! https://github.com/llvm/llvm-project/pull/101196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Add GCS support for AArch64 (PR #99335)
john-brawn-arm wrote: Ping https://github.com/llvm/llvm-project/pull/99335 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] [libcxxabi] [libunwind] [NFC][libc++][libc++abi][libunwind][test] Fix/unify AIX triples used in LIT tests (PR #101196)
@@ -6,7 +6,7 @@ // //===--===// -// REQUIRES: target={{powerpc.*-ibm-aix.*}} +// REQUIRES: target={{.+}}-aix{{.*}} ldionne wrote: `libcxx/test/vendor` is a bit mis-named, I guess. It's more like `libcxx/test/vendor-or-extremely-platform-specific-stuff`. I think it makes more sense to keep this here since this test doesn't make sense outside of AIX. https://github.com/llvm/llvm-project/pull/101196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] [libcxxabi] [libunwind] [NFC][libc++][libc++abi][libunwind][test] Fix/unify AIX triples used in LIT tests (PR #101196)
https://github.com/ldionne approved this pull request. https://github.com/llvm/llvm-project/pull/101196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [LTO] enable `ObjCARCContractPass` only on optimized build (PR #101114)
nikic wrote: The pipeline test changes here still look problematic. Can you make the ObjCARCContract pass preserve the DT? https://github.com/llvm/llvm-project/pull/101114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][LoongArch] Align global symbol by size (PR #101309)
heiher wrote: > This looks wrong. Preferred and ABI alignments should be set in ~Triple~. > ADD: Sorry, I meant DataLayout, of course. Thanks for pointing this out. How does data layout affect the alignment of constant string global variable symbols? https://github.com/llvm/llvm-project/pull/101309 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SPARC][clang] Add -m(no-)v8plus flags handling (PR #98713)
@@ -179,6 +179,13 @@ void sparc::getSparcTargetFeatures(const Driver , const ArgList , Features.push_back("-hard-quad-float"); } + if (Arg *A = Args.getLastArg(options::OPT_mv8plus, options::OPT_mno_v8plus)) { +if (A->getOption().matches(options::OPT_mv8plus)) koachan wrote: It is true that those flags primarily control the target environment, however, on GCC, `-m[no-]v8plus` also implies that V9 instructions are available (or not, in case of `-mno-v8plus`) (e.g when multiplying 64-bit numbers: https://godbolt.org/z/5zdWez6qz). Also, unlike `-mx32`, `-m[no-]v8plus` is intended for use with 32-bit target (`-m32`); again, with GCC, `-mv8plus` raises an error with `-m64`, and `-mno-v8plus` is ignored (i.e it still generates 64-bit instructions) (https://godbolt.org/z/PcfMcT8cf). It would be possible to define the flags such that `-m[no-]v8plus` do not touch the V9 feature bit, but I feel like that would defeat the purpose of V8+ environment (that is, to let 32-bit code use some 64-bit V9 instructions). https://github.com/llvm/llvm-project/pull/98713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Update argument checking tablegen code to use a 'full' name (PR #99993)
AaronBallman wrote: > This causes significant compile-time regressions, especially for unoptimized > builds: > https://llvm-compile-time-tracker.com/compare.php?from=39b6900852e7a1187bd742ba5c1387ca1be58e2c=2acf77f987331c05520c5bfd849326909ffce983=instructions:u > > You probably need to separately match the syntax and the name without > constructing a temporary `std::string`. Thank you for identifying this, @nikic! > That should elimate the need for any new std::strings. @AaronBallman does > this sound reasonable? That seems like a good approach to me https://github.com/llvm/llvm-project/pull/3 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Add strict typing to clang Python bindings (#76664) (PR #78114)
DeinAlptraum wrote: I'm planning to do one last split that contains all "logic" changes, after which this PR should contain only actual typing annotations and nothing else. Will open a PR for that other change one of these days https://github.com/llvm/llvm-project/pull/78114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Add strict typing to clang Python bindings (#76664) (PR #78114)
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/78114 >From 04641f7ea15382df2d43fecc32bd1b699e0b2481 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Fri, 12 Jul 2024 15:08:06 +0100 Subject: [PATCH] [libclang/python] Add strict typing to clang Python bindings --- clang/bindings/python/clang/cindex.py | 654 ++ 1 file changed, 364 insertions(+), 290 deletions(-) diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 2038ef6045c7d..32ed0920ff31e 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -71,8 +71,11 @@ from typing import ( Any, Callable, +cast as Tcast, Generic, +Iterator, Optional, +Sequence, Type as TType, TypeVar, TYPE_CHECKING, @@ -81,14 +84,19 @@ if TYPE_CHECKING: from ctypes import _Pointer +from io import TextIOWrapper from typing_extensions import Protocol, TypeAlias StrPath: TypeAlias = TUnion[str, os.PathLike[str]] +InMemoryFile: TypeAlias = ( +"tuple[TUnion[str, os.PathLike[Any]], TUnion[str, TextIOWrapper]]" +) LibFunc: TypeAlias = TUnion[ "tuple[str, Optional[list[Any]]]", "tuple[str, Optional[list[Any]], Any]", "tuple[str, Optional[list[Any]], Any, Callable[..., Any]]", ] +CObjP: TypeAlias = _Pointer[Any] TSeq = TypeVar("TSeq", covariant=True) @@ -147,7 +155,7 @@ def b(x: str | bytes) -> bytes: # object. This is a problem, because it means that from_parameter will see an # integer and pass the wrong value on platforms where int != void*. Work around # this by marshalling object arguments as void**. -c_object_p: TType[_Pointer[Any]] = POINTER(c_void_p) +c_object_p: TType[CObjP] = POINTER(c_void_p) ### Exception Classes ### @@ -183,7 +191,7 @@ class TranslationUnitSaveError(Exception): # Indicates that the translation unit was somehow invalid. ERROR_INVALID_TU = 3 -def __init__(self, enumeration, message): +def __init__(self, enumeration: int, message: str): assert isinstance(enumeration, int) if enumeration < 1 or enumeration > 3: @@ -255,23 +263,25 @@ class SourceLocation(Structure): """ _fields_ = [("ptr_data", c_void_p * 2), ("int_data", c_uint)] -_data = None +_data: tuple[File | None, int, int, int] | None = None -def _get_instantiation(self): +def _get_instantiation(self) -> tuple[File | None, int, int, int]: if self._data is None: f, l, c, o = c_object_p(), c_uint(), c_uint(), c_uint() conf.lib.clang_getInstantiationLocation( self, byref(f), byref(l), byref(c), byref(o) ) if f: -f = File(f) +file = File(f) else: -f = None -self._data = (f, int(l.value), int(c.value), int(o.value)) +file = None +self._data = (file, int(l.value), int(c.value), int(o.value)) return self._data @staticmethod -def from_position(tu, file, line, column): +def from_position( +tu: TranslationUnit, file: File, line: int, column: int +) -> SourceLocation: """ Retrieve the source location associated with a given file/line/column in a particular translation unit. @@ -279,7 +289,7 @@ def from_position(tu, file, line, column): return conf.lib.clang_getLocation(tu, file, line, column) # type: ignore [no-any-return] @staticmethod -def from_offset(tu, file, offset): +def from_offset(tu: TranslationUnit, file: File, offset: int) -> SourceLocation: """Retrieve a SourceLocation from a given character offset. tu -- TranslationUnit file belongs to @@ -289,37 +299,39 @@ def from_offset(tu, file, offset): return conf.lib.clang_getLocationForOffset(tu, file, offset) # type: ignore [no-any-return] @property -def file(self): +def file(self) -> File | None: """Get the file represented by this source location.""" return self._get_instantiation()[0] @property -def line(self): +def line(self) -> int: """Get the line represented by this source location.""" return self._get_instantiation()[1] @property -def column(self): +def column(self) -> int: """Get the column represented by this source location.""" return self._get_instantiation()[2] @property -def offset(self): +def offset(self) -> int: """Get the file offset represented by this source location.""" return self._get_instantiation()[3] @property -def is_in_system_header(self): +def is_in_system_header(self) -> bool: """Returns true if the given source location is in a system header.""" return conf.lib.clang_Location_isInSystemHeader(self) # type:
[clang] [clang] Implement CWG2627 Bit-fields and narrowing conversions (PR #78112)
https://github.com/AaronBallman approved this pull request. Generally LGTM, just a few minor things. Thank you for this! https://github.com/llvm/llvm-project/pull/78112 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Implement CWG2627 Bit-fields and narrowing conversions (PR #78112)
@@ -0,0 +1,44 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -triple x86_64-linux-pc -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -triple x86_64-windows-pc -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -triple i386-linux-pc -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -triple i386-windows-pc -fsyntax-only -verify -std=c++11 %s + +#if __BITINT_MAXWIDTH__ >= 35 AaronBallman wrote: No need for this predicate, it's required to be at least the same width as `long long`. https://github.com/llvm/llvm-project/pull/78112 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Implement CWG2627 Bit-fields and narrowing conversions (PR #78112)
@@ -0,0 +1,44 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -triple x86_64-linux-pc -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -triple x86_64-windows-pc -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -triple i386-linux-pc -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -triple i386-windows-pc -fsyntax-only -verify -std=c++11 %s AaronBallman wrote: Could we get away with two RUN lines instead of four by doing `-triple x86_64` and `-triple i386` and leaving the rest of the triple to the test runner? https://github.com/llvm/llvm-project/pull/78112 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Implement CWG2627 Bit-fields and narrowing conversions (PR #78112)
@@ -0,0 +1,44 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -triple x86_64-linux-pc -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -triple x86_64-windows-pc -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -triple i386-linux-pc -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -triple i386-windows-pc -fsyntax-only -verify -std=c++11 %s + +#if __BITINT_MAXWIDTH__ >= 35 +struct { + _BitInt(35) i : 33; +} x; +struct { + _BitInt(35) i : 34; +} y; +_BitInt(33) xx{ x.i }; +_BitInt(33) yy{ y.i }; +// expected-error@-1 {{non-constant-expression cannot be narrowed from type '_BitInt(35)' to '_BitInt(33)' in initializer list}} +// FIXME-expected-note@-2 {{insert an explicit cast to silence this issue}} +#endif + +#if __BITINT_MAXWIDTH__ >= 3 AaronBallman wrote: Same here https://github.com/llvm/llvm-project/pull/78112 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Implement CWG2627 Bit-fields and narrowing conversions (PR #78112)
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/78112 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][LoongArch] Align global symbol by size (PR #101309)
s-barannikov wrote: This looks wrong. Preferred and ABI alignments should be set in Triple. https://github.com/llvm/llvm-project/pull/101309 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CLANG][AArch64]Add Neon vectors for fpm8_t (PR #99865)
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 9e63632b3274dc1b20502b569e79a311977e0a97 6dd7d08634707fbaf417ae2f9f4315e529045fd4 --extensions cpp,h,c -- clang/test/AST/arm-mfp8.cpp clang/test/CodeGen/arm-mfp8.c clang/test/Sema/arm-mfp8.c clang/test/Sema/arm-mfp8.cpp clang/include/clang/AST/ASTContext.h clang/include/clang/AST/Type.h clang/include/clang/Basic/Specifiers.h clang/include/clang/Basic/TargetBuiltins.h clang/include/clang/Basic/TargetInfo.h clang/include/clang/Sema/DeclSpec.h clang/include/clang/Serialization/ASTBitCodes.h clang/lib/AST/ASTContext.cpp clang/lib/AST/ItaniumMangle.cpp clang/lib/AST/PrintfFormatString.cpp clang/lib/AST/Type.cpp clang/lib/AST/TypeLoc.cpp clang/lib/Basic/TargetInfo.cpp clang/lib/Basic/Targets/AArch64.cpp clang/lib/Basic/Targets/AArch64.h clang/lib/Basic/Targets/ARM.cpp clang/lib/Basic/Targets/ARM.h clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenTypeCache.h clang/lib/CodeGen/CodeGenTypes.cpp clang/lib/CodeGen/ItaniumCXXABI.cpp clang/lib/Index/USRGeneration.cpp clang/lib/Lex/Lexer.cpp clang/lib/Parse/ParseDecl.cpp clang/lib/Parse/ParseExpr.cpp clang/lib/Parse/ParseExprCXX.cpp clang/lib/Parse/ParseTentative.cpp clang/lib/Sema/DeclSpec.cpp clang/lib/Sema/SemaARM.cpp clang/lib/Sema/SemaCast.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaTemplateVariadic.cpp clang/lib/Sema/SemaType.cpp clang/lib/Serialization/ASTCommon.cpp clang/lib/Serialization/ASTReader.cpp clang/utils/TableGen/NeonEmitter.cpp clang/utils/TableGen/TableGen.cpp clang/utils/TableGen/TableGenBackends.h `` View the diff from clang-format here. ``diff diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index fe3234ef85..19101f5a95 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -3800,7 +3800,9 @@ void CXXNameMangler::mangleNeonVectorType(const VectorType *T) { case BuiltinType::Float: EltName = "float32_t"; break; case BuiltinType::Half: EltName = "float16_t"; break; case BuiltinType::BFloat16: EltName = "bfloat16_t"; break; -case BuiltinType::MFloat8: EltName = "mfloat8_t"; break; +case BuiltinType::MFloat8: + EltName = "mfloat8_t"; + break; default: llvm_unreachable("unexpected Neon vector element type"); } diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index 3af64ea55e..59a8124836 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -576,7 +576,8 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T, case DeclSpec::TST_fract: return "_Fract"; case DeclSpec::TST_float16: return "_Float16"; case DeclSpec::TST_float128:return "__float128"; - case DeclSpec::TST_MFloat8: return "__mfp8"; + case DeclSpec::TST_MFloat8: +return "__mfp8"; case DeclSpec::TST_ibm128: return "__ibm128"; case DeclSpec::TST_bool:return Policy.Bool ? "bool" : "_Bool"; case DeclSpec::TST_decimal32: return "_Decimal32"; diff --git a/clang/utils/TableGen/TableGen.cpp b/clang/utils/TableGen/TableGen.cpp index 8eb5b0f35f..f77e16b302 100644 --- a/clang/utils/TableGen/TableGen.cpp +++ b/clang/utils/TableGen/TableGen.cpp @@ -229,7 +229,8 @@ cl::opt Action( clEnumValN(GenArmNeon, "gen-arm-neon", "Generate arm_neon.h for clang"), clEnumValN(GenArmFP16, "gen-arm-fp16", "Generate arm_fp16.h for clang"), clEnumValN(GenArmBF16, "gen-arm-bf16", "Generate arm_bf16.h for clang"), -clEnumValN(GenArmMFloat8, "gen-arm-mfp8", "Generate arm_mfp8.h for clang"), +clEnumValN(GenArmMFloat8, "gen-arm-mfp8", + "Generate arm_mfp8.h for clang"), clEnumValN(GenArmVectorType, "gen-arm-vector-type", "Generate arm_vector_types.h for clang"), clEnumValN(GenArmNeonSema, "gen-arm-neon-sema", `` https://github.com/llvm/llvm-project/pull/99865 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ASTImporter] Remove trailing return testing on lambda proto (PR #101031)
balazske wrote: > Here can `ToProcess.append(CurrentS->child_begin(), CurrentS->child_end());` > add any nullptr into `ToProcess` in this testing context? I think it is possible, but I could not reproduce this case with the shown code. https://github.com/llvm/llvm-project/pull/101031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ASTImporter] Remove trailing return testing on lambda proto (PR #101031)
balazske wrote: This looks like a good fix if there is no other way to detect the "C++11 lambda without parentheses" case. https://github.com/llvm/llvm-project/pull/101031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Add strict typing to clang Python bindings (#76664) (PR #78114)
@@ -255,71 +263,75 @@ class SourceLocation(Structure): """ _fields_ = [("ptr_data", c_void_p * 2), ("int_data", c_uint)] -_data = None +_data: tuple[File | None, int, int, int] | None = None -def _get_instantiation(self): +def _get_instantiation(self) -> tuple[File | None, int, int, int]: if self._data is None: f, l, c, o = c_object_p(), c_uint(), c_uint(), c_uint() conf.lib.clang_getInstantiationLocation( self, byref(f), byref(l), byref(c), byref(o) ) if f: -f = File(f) +file = File(f) else: -f = None -self._data = (f, int(l.value), int(c.value), int(o.value)) +file = None +self._data = (file, int(l.value), int(c.value), int(o.value)) return self._data @staticmethod -def from_position(tu, file, line, column): +def from_position( +tu: TranslationUnit, file: File, line: int, column: int +) -> SourceLocation: """ Retrieve the source location associated with a given file/line/column in a particular translation unit. """ -return conf.lib.clang_getLocation(tu, file, line, column) +return conf.lib.clang_getLocation(tu, file, line, column) # type: ignore [no-any-return] @staticmethod -def from_offset(tu, file, offset): +def from_offset(tu: TranslationUnit, file: File, offset: int) -> SourceLocation: """Retrieve a SourceLocation from a given character offset. tu -- TranslationUnit file belongs to file -- File instance to obtain offset from offset -- Integer character offset within file """ -return conf.lib.clang_getLocationForOffset(tu, file, offset) +return conf.lib.clang_getLocationForOffset(tu, file, offset) # type: ignore [no-any-return] Endilll wrote: This one was merged just now, too. https://github.com/llvm/llvm-project/pull/78114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] type-ignore `Any` returns from library calls (PR #101310)
https://github.com/Endilll closed https://github.com/llvm/llvm-project/pull/101310 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5525566 - [libclang/python] type-ignore `Any` returns from library calls (#101310)
Author: Jannick Kremer Date: 2024-07-31T16:21:43+04:00 New Revision: 55255669077b191043b1a8920107890815151835 URL: https://github.com/llvm/llvm-project/commit/55255669077b191043b1a8920107890815151835 DIFF: https://github.com/llvm/llvm-project/commit/55255669077b191043b1a8920107890815151835.diff LOG: [libclang/python] type-ignore `Any` returns from library calls (#101310) On its own, this change leads to _more_ strict typing errors as the functions are mostly not annotated so far, so the `# type: ignore`s are reported as Unused. This is part of the work leading up to #78114 though, and one of the bigger parts factored out from it, so these will later lead to less strict typing errors as the functions are annotated with return types. Added: Modified: clang/bindings/python/clang/cindex.py Removed: diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index f669c279aab6d..2038ef6045c7d 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -276,7 +276,7 @@ def from_position(tu, file, line, column): Retrieve the source location associated with a given file/line/column in a particular translation unit. """ -return conf.lib.clang_getLocation(tu, file, line, column) +return conf.lib.clang_getLocation(tu, file, line, column) # type: ignore [no-any-return] @staticmethod def from_offset(tu, file, offset): @@ -286,7 +286,7 @@ def from_offset(tu, file, offset): file -- File instance to obtain offset from offset -- Integer character offset within file """ -return conf.lib.clang_getLocationForOffset(tu, file, offset) +return conf.lib.clang_getLocationForOffset(tu, file, offset) # type: ignore [no-any-return] @property def file(self): @@ -311,10 +311,10 @@ def offset(self): @property def is_in_system_header(self): """Returns true if the given source location is in a system header.""" -return conf.lib.clang_Location_isInSystemHeader(self) +return conf.lib.clang_Location_isInSystemHeader(self) # type: ignore [no-any-return] def __eq__(self, other): -return conf.lib.clang_equalLocations(self, other) +return conf.lib.clang_equalLocations(self, other) # type: ignore [no-any-return] def __ne__(self, other): return not self.__eq__(other) @@ -347,7 +347,7 @@ class SourceRange(Structure): # object. @staticmethod def from_locations(start, end): -return conf.lib.clang_getRange(start, end) +return conf.lib.clang_getRange(start, end) # type: ignore [no-any-return] @property def start(self): @@ -355,7 +355,7 @@ def start(self): Return a SourceLocation representing the first character within a source range. """ -return conf.lib.clang_getRangeStart(self) +return conf.lib.clang_getRangeStart(self) # type: ignore [no-any-return] @property def end(self): @@ -363,10 +363,10 @@ def end(self): Return a SourceLocation representing the last character within a source range. """ -return conf.lib.clang_getRangeEnd(self) +return conf.lib.clang_getRangeEnd(self) # type: ignore [no-any-return] def __eq__(self, other): -return conf.lib.clang_equalRanges(self, other) +return conf.lib.clang_equalRanges(self, other) # type: ignore [no-any-return] def __ne__(self, other): return not self.__eq__(other) @@ -429,15 +429,15 @@ def __del__(self): @property def severity(self): -return conf.lib.clang_getDiagnosticSeverity(self) +return conf.lib.clang_getDiagnosticSeverity(self) # type: ignore [no-any-return] @property def location(self): -return conf.lib.clang_getDiagnosticLocation(self) +return conf.lib.clang_getDiagnosticLocation(self) # type: ignore [no-any-return] @property def spelling(self): -return conf.lib.clang_getDiagnosticSpelling(self) +return conf.lib.clang_getDiagnosticSpelling(self) # type: ignore [no-any-return] @property def ranges(self) -> NoSliceSequence[SourceRange]: @@ -451,7 +451,7 @@ def __len__(self) -> int: def __getitem__(self, key: int) -> SourceRange: if key >= len(self): raise IndexError -return conf.lib.clang_getDiagnosticRange(self.diag, key) +return conf.lib.clang_getDiagnosticRange(self.diag, key) # type: ignore [no-any-return] return RangeIterator(self) @@ -494,17 +494,17 @@ def __getitem__(self, key: int) -> Diagnostic: @property def category_number(self): """The category number for this diagnostic or 0 if unavailable.""" -return
[clang] [C11] Claim conformance to WG14 N1396 (PR #101214)
AaronBallman wrote: Thank you! I updated the test and status information; let me know if you'd like to see further adjustments. https://github.com/llvm/llvm-project/pull/101214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] type-ignore `Any` returns from library calls (PR #101310)
https://github.com/Endilll approved this pull request. https://github.com/llvm/llvm-project/pull/101310 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Add strict typing to clang Python bindings (#76664) (PR #78114)
@@ -3257,21 +3323,21 @@ def reparse(self, unsaved_files=None, options=0): if unsaved_files is None: unsaved_files = [] -unsaved_files_array = 0 +unsaved_files_array: int | Array[_CXUnsavedFile] = 0 if len(unsaved_files): unsaved_files_array = (_CXUnsavedFile * len(unsaved_files))() for i, (name, contents) in enumerate(unsaved_files): if hasattr(contents, "read"): contents = contents.read() -contents = b(contents) +binary_contents = b(contents) Endilll wrote: I merged #101308 just now, so you can sidestep the issue by updating this PR with changes from `main`. https://github.com/llvm/llvm-project/pull/78114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Factor out unsaved files processing (PR #101308)
https://github.com/Endilll closed https://github.com/llvm/llvm-project/pull/101308 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 4c670b2 - [libclang/python] Factor out unsaved files processing (#101308)
Author: Jannick Kremer Date: 2024-07-31T16:19:13+04:00 New Revision: 4c670b266a10d613a58b71cc9c3d3a21cb6dc36b URL: https://github.com/llvm/llvm-project/commit/4c670b266a10d613a58b71cc9c3d3a21cb6dc36b DIFF: https://github.com/llvm/llvm-project/commit/4c670b266a10d613a58b71cc9c3d3a21cb6dc36b.diff LOG: [libclang/python] Factor out unsaved files processing (#101308) Factor out the processing of unsaved files into its own function as suggested by @Endilll [here](https://github.com/llvm/llvm-project/pull/78114/files#r1697730196) Added: Modified: clang/bindings/python/clang/cindex.py Removed: diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 72509a8a54f28..f669c279aab6d 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -3011,6 +3011,20 @@ class TranslationUnit(ClangObject): # into the set of code completions returned from this translation unit. PARSE_INCLUDE_BRIEF_COMMENTS_IN_CODE_COMPLETION = 128 +@staticmethod +def process_unsaved_files(unsaved_files) -> Array[_CXUnsavedFile] | None: +unsaved_array = None +if len(unsaved_files): +unsaved_array = (_CXUnsavedFile * len(unsaved_files))() +for i, (name, contents) in enumerate(unsaved_files): +if hasattr(contents, "read"): +contents = contents.read() +binary_contents = b(contents) +unsaved_array[i].name = b(os.fspath(name)) +unsaved_array[i].contents = binary_contents +unsaved_array[i].length = len(binary_contents) +return unsaved_array + @classmethod def from_source( cls, filename, args=None, unsaved_files=None, options=0, index=None @@ -3067,16 +3081,7 @@ def from_source( if len(args) > 0: args_array = (c_char_p * len(args))(*[b(x) for x in args]) -unsaved_array = None -if len(unsaved_files) > 0: -unsaved_array = (_CXUnsavedFile * len(unsaved_files))() -for i, (name, contents) in enumerate(unsaved_files): -if hasattr(contents, "read"): -contents = contents.read() -contents = b(contents) -unsaved_array[i].name = b(os.fspath(name)) -unsaved_array[i].contents = contents -unsaved_array[i].length = len(contents) +unsaved_array = cls.process_unsaved_files(unsaved_files) ptr = conf.lib.clang_parseTranslationUnit( index, @@ -3257,16 +3262,7 @@ def reparse(self, unsaved_files=None, options=0): if unsaved_files is None: unsaved_files = [] -unsaved_files_array = 0 -if len(unsaved_files): -unsaved_files_array = (_CXUnsavedFile * len(unsaved_files))() -for i, (name, contents) in enumerate(unsaved_files): -if hasattr(contents, "read"): -contents = contents.read() -contents = b(contents) -unsaved_files_array[i].name = b(os.fspath(name)) -unsaved_files_array[i].contents = contents -unsaved_files_array[i].length = len(contents) +unsaved_files_array = self.process_unsaved_files(unsaved_files) ptr = conf.lib.clang_reparseTranslationUnit( self, len(unsaved_files), unsaved_files_array, options ) @@ -3329,16 +3325,7 @@ def codeComplete( if unsaved_files is None: unsaved_files = [] -unsaved_files_array = 0 -if len(unsaved_files): -unsaved_files_array = (_CXUnsavedFile * len(unsaved_files))() -for i, (name, contents) in enumerate(unsaved_files): -if hasattr(contents, "read"): -contents = contents.read() -contents = b(contents) -unsaved_files_array[i].name = b(os.fspath(name)) -unsaved_files_array[i].contents = contents -unsaved_files_array[i].length = len(contents) +unsaved_files_array = self.process_unsaved_files(unsaved_files) ptr = conf.lib.clang_codeCompleteAt( self, os.fspath(path), ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Factor out unsaved files processing (PR #101308)
https://github.com/Endilll approved this pull request. https://github.com/llvm/llvm-project/pull/101308 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix crash with multiple non-parenthsized `sizeof` (PR #101297)
https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/101297 >From d75b3cef41c370fef939a347935a4f3ed53c46ea Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Wed, 31 Jul 2024 10:29:04 +0300 Subject: [PATCH 1/3] [clang] Fix crash with multiple non-parenthsized `sizeof` --- clang/lib/Parse/ParseExpr.cpp | 14 +- .../parser-overflow-non-parenthesized.c | 135 ++ 2 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 clang/test/Parser/parser-overflow-non-parenthesized.c diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index e82b565272831..e501d5e91e77d 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -2479,7 +2479,19 @@ Parser::ParseExprAfterUnaryExprOrTypeTrait(const Token , return ExprError(); } -Operand = ParseCastExpression(UnaryExprOnly); +// If we're parsing a chain that consists of keywords that could be +// followed by a non-parenthesized expression, BalancedDelimiterTracker +// is not going to help when the nesting is too deep. In this corner case +// we continue to parse with sufficient stack space to avoid crashing. +if (OpTok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof, + tok::kw_alignof, tok::kw__Alignof) && +Tok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof, +tok::kw_alignof, tok::kw__Alignof)) + Actions.runWithSufficientStackSpace(Tok.getLocation(), [&] { +Operand = ParseCastExpression(UnaryExprOnly); + }); +else + Operand = ParseCastExpression(UnaryExprOnly); } else { // If it starts with a '(', we know that it is either a parenthesized // type-name, or it is a unary-expression that starts with a compound diff --git a/clang/test/Parser/parser-overflow-non-parenthesized.c b/clang/test/Parser/parser-overflow-non-parenthesized.c new file mode 100644 index 0..b6c7485274090 --- /dev/null +++ b/clang/test/Parser/parser-overflow-non-parenthesized.c @@ -0,0 +1,135 @@ +// RUN: %clang_cc1 %s 2>&1 | FileCheck %s + +void f(void) { + // 600 sizeof's + int a = + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof + sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof +
[clang] [llvm] [AArch64] Cleanup existing values in getMemOpInfo (PR #98196)
https://github.com/davemgreen updated https://github.com/llvm/llvm-project/pull/98196 >From b46d892a43b034dd515987f37441fc842710dc62 Mon Sep 17 00:00:00 2001 From: Haowei Wu Date: Wed, 31 Jul 2024 12:12:26 +0100 Subject: [PATCH] Revert "[C++20] [Modules] Always emit the inline builtins" This reverts commit ca8a4111f796fe8533e0af95557875b15becff06. This patch broke clang test on Windows x64 msvc --- clang/lib/CodeGen/CodeGenModule.cpp | 10 +- clang/test/Modules/inline-builtins.cppm | 34 --- .../Target/AArch64/AArch64FrameLowering.cpp | 3 +- llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 257 -- llvm/lib/Target/AArch64/AArch64InstrInfo.h| 5 +- .../CodeGen/AArch64/sched-postidxalias.mir| 63 + 6 files changed, 314 insertions(+), 58 deletions(-) delete mode 100644 clang/test/Modules/inline-builtins.cppm create mode 100644 llvm/test/CodeGen/AArch64/sched-postidxalias.mir diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 5a575c535b505..344a0e538f22a 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -4022,11 +4022,6 @@ bool CodeGenModule::shouldEmitFunction(GlobalDecl GD) { return true; const auto *F = cast(GD.getDecl()); - // Inline builtins declaration must be emitted. They often are fortified - // functions. - if (F->isInlineBuiltinDeclaration()) -return true; - if (CodeGenOpts.OptimizationLevel == 0 && !F->hasAttr()) return false; @@ -4072,6 +4067,11 @@ bool CodeGenModule::shouldEmitFunction(GlobalDecl GD) { } } + // Inline builtins declaration must be emitted. They often are fortified + // functions. + if (F->isInlineBuiltinDeclaration()) +return true; + // PR9614. Avoid cases where the source code is lying to us. An available // externally function should have an equivalent function somewhere else, // but a function that calls itself through asm label/`__builtin_` trickery is diff --git a/clang/test/Modules/inline-builtins.cppm b/clang/test/Modules/inline-builtins.cppm deleted file mode 100644 index 8f41ae2659513..0 --- a/clang/test/Modules/inline-builtins.cppm +++ /dev/null @@ -1,34 +0,0 @@ -// RUN: rm -rf %t -// RUN: split-file %s %t -// RUN: cd %t -// -// RUN: %clang_cc1 -std=c++20 -O3 %t/a.cppm -emit-module-interface -o %t/a.pcm -// RUN: %clang_cc1 -std=c++20 -O3 %t/test.cc -fmodule-file=a=%t/a.pcm \ -// RUN: -emit-llvm -o - | FileCheck %t/test.cc - -//--- memmove.h -typedef long unsigned int size_t; -extern "C" void *memmove (void *__dest, const void *__src, size_t __n) - throw () __attribute__ ((__nonnull__ (1, 2))); -extern "C" __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) void * - memmove (void *__dest, const void *__src, size_t __len) throw () -{ - return __builtin_memmove(__dest, __src, __len); -} - -//--- a.cppm -module; -#include "memmove.h" -export module a; -export using ::memmove; - -//--- test.cc -import a; - -void test() { - int a, b; - unsigned c = 0; - memmove(, , c); -} - -// CHECK-NOT: memmove diff --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp index bd530903bb664..f28511c74dcd6 100644 --- a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp @@ -1487,7 +1487,8 @@ static MachineBasicBlock::iterator convertCalleeSaveRestoreToSPPrePostIncDec( // If the first store isn't right where we want SP then we can't fold the // update in so create a normal arithmetic instruction instead. if (MBBI->getOperand(MBBI->getNumOperands() - 1).getImm() != 0 || - CSStackSizeInc < MinOffset || CSStackSizeInc > MaxOffset) { + CSStackSizeInc < MinOffset * (int64_t)Scale.getFixedValue() || + CSStackSizeInc > MaxOffset * (int64_t)Scale.getFixedValue()) { // If we are destroying the frame, make sure we add the increment after the // last frame operation. if (FrameFlag == MachineInstr::FrameDestroy) diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp index 6cd9a1a817086..0320c6e78ff9c 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -3487,6 +3487,229 @@ MachineInstr *AArch64InstrInfo::emitLdStWithAddr(MachineInstr , "Function must not be called with an addressing mode it can't handle"); } +/// Return true if the opcode is a post-index ld/st instruction, which really +/// loads from base+0. +static bool isPostIndexLdStOpcode(unsigned Opcode) { + switch (Opcode) { + default: +return false; + case AArch64::LD1Fourv16b_POST: + case AArch64::LD1Fourv1d_POST: + case AArch64::LD1Fourv2d_POST: + case AArch64::LD1Fourv2s_POST: + case AArch64::LD1Fourv4h_POST: + case AArch64::LD1Fourv4s_POST: + case AArch64::LD1Fourv8b_POST: + case AArch64::LD1Fourv8h_POST: + case
[clang] [llvm] [RISCV] Add Syntacore SCR4 RV32/64 processors definition (PR #101321)
https://github.com/asi-sc edited https://github.com/llvm/llvm-project/pull/101321 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add Syntacore SCR4 RV32/64 processors definition (PR #101321)
llvmbot wrote: @llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang @llvm/pr-subscribers-backend-risc-v Author: Anton Sidorenko (asi-sc) Changes Syntacore SCR4 is a microcontroller-class processor core that has much in common with SCR3. The most significant difference for compilers is F and D extensions support. Overview: https://syntacore.com/products/scr4 Two CPUs are added: * 'syntacore-scr4-rv32' -- rv32imfdc * 'syntacore-scr4-rv64' -- rv64imafdc Scheduling model will be added in a separate PR. - --- Full diff: https://github.com/llvm/llvm-project/pull/101321.diff 4 Files Affected: - (modified) clang/test/Driver/riscv-cpus.c (+27) - (modified) clang/test/Misc/target-invalid-cpu-note.c (+4-4) - (modified) llvm/docs/ReleaseNotes.rst (+1) - (modified) llvm/lib/Target/RISCV/RISCVProcessors.td (+25) ``diff diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c index 26bcda6468dd2..7a885cde76d6a 100644 --- a/clang/test/Driver/riscv-cpus.c +++ b/clang/test/Driver/riscv-cpus.c @@ -381,3 +381,30 @@ // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr3-rv64 | FileCheck -check-prefix=MTUNE-SYNTACORE-SCR3-RV64 %s // MTUNE-SYNTACORE-SCR3-RV64: "-tune-cpu" "syntacore-scr3-rv64" + +// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=syntacore-scr4-rv32 | FileCheck -check-prefix=MCPU-SYNTACORE-SCR4-RV32 %s +// MCPU-SYNTACORE-SCR4-RV32: "-target-cpu" "syntacore-scr4-rv32" +// MCPU-SYNTACORE-SCR4-RV32-SAME: "-target-feature" "+m" +// MCPU-SYNTACORE-SCR4-RV32-SAME: "-target-feature" "+f" +// MCPU-SYNTACORE-SCR4-RV32-SAME: "-target-feature" "+d" +// MCPU-SYNTACORE-SCR4-RV32-SAME: "-target-feature" "+c" +// MCPU-SYNTACORE-SCR4-RV32-SAME: "-target-feature" "+zicsr" +// MCPU-SYNTACORE-SCR4-RV32-SAME: "-target-feature" "+zifencei" +// MCPU-SYNTACORE-SCR4-RV32-SAME: "-target-abi" "ilp32d" + +// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=syntacore-scr4-rv32 | FileCheck -check-prefix=MTUNE-SYNTACORE-SCR4-RV32 %s +// MTUNE-SYNTACORE-SCR4-RV32: "-tune-cpu" "syntacore-scr4-rv32" + +// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=syntacore-scr4-rv64 | FileCheck -check-prefix=MCPU-SYNTACORE-SCR4-RV64 %s +// MCPU-SYNTACORE-SCR4-RV64: "-target-cpu" "syntacore-scr4-rv64" +// MCPU-SYNTACORE-SCR4-RV64-SAME: "-target-feature" "+m" +// MCPU-SYNTACORE-SCR4-RV64-SAME: "-target-feature" "+a" +// MCPU-SYNTACORE-SCR4-RV64-SAME: "-target-feature" "+f" +// MCPU-SYNTACORE-SCR4-RV64-SAME: "-target-feature" "+d" +// MCPU-SYNTACORE-SCR4-RV64-SAME: "-target-feature" "+c" +// MCPU-SYNTACORE-SCR4-RV64-SAME: "-target-feature" "+zicsr" +// MCPU-SYNTACORE-SCR4-RV64-SAME: "-target-feature" "+zifencei" +// MCPU-SYNTACORE-SCR4-RV64-SAME: "-target-abi" "lp64d" + +// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr4-rv64 | FileCheck -check-prefix=MTUNE-SYNTACORE-SCR4-RV64 %s +// MTUNE-SYNTACORE-SCR4-RV64: "-tune-cpu" "syntacore-scr4-rv64" diff --git a/clang/test/Misc/target-invalid-cpu-note.c b/clang/test/Misc/target-invalid-cpu-note.c index e0757b69242a8..b87bced18cb2b 100644 --- a/clang/test/Misc/target-invalid-cpu-note.c +++ b/clang/test/Misc/target-invalid-cpu-note.c @@ -81,16 +81,16 @@ // RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV32 // RISCV32: error: unknown target CPU 'not-a-cpu' -// RISCV32-NEXT: note: valid target CPU values are: generic-rv32, rocket-rv32, sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, syntacore-scr1-base, syntacore-scr1-max, syntacore-scr3-rv32{{$}} +// RISCV32-NEXT: note: valid target CPU values are: generic-rv32, rocket-rv32, sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, syntacore-scr1-base, syntacore-scr1-max, syntacore-scr3-rv32, syntacore-scr4-rv32{{$}} // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV64 // RISCV64: error: unknown target CPU 'not-a-cpu' -// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, sifive-x280, spacemit-x60, syntacore-scr3-rv64, veyron-v1, xiangshan-nanhu{{$}} +// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, sifive-x280, spacemit-x60, syntacore-scr3-rv64, syntacore-scr4-rv64, veyron-v1, xiangshan-nanhu{{$}} // RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE-RISCV32 // TUNE-RISCV32: error: unknown target CPU 'not-a-cpu' -// TUNE-RISCV32-NEXT: note: valid target CPU values are: generic-rv32, rocket-rv32, sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, syntacore-scr1-base, syntacore-scr1-max, syntacore-scr3-rv32, generic,
[clang] [llvm] [RISCV] Add Syntacore SCR4 RV32/64 processors definition (PR #101321)
https://github.com/asi-sc created https://github.com/llvm/llvm-project/pull/101321 Syntacore SCR4 is a microcontroller-class processor core that has much in common with SCR3. The most significant difference for compilers is F and D extensions support. Overview: https://syntacore.com/products/scr4 Two CPUs are added: * 'syntacore-scr4-rv32' -- rv32imfdc * 'syntacore-scr4-rv64' -- rv64imafdc Scheduling model will be added in a separate PR. - >From 833727a9f23fff71695f4d2a5e7ee3e58ab5449a Mon Sep 17 00:00:00 2001 From: Anton Sidorenko Date: Wed, 3 Jul 2024 19:31:47 +0300 Subject: [PATCH] [RISCV] Add Syntacore SCR4 RV32/64 processors definition Syntacore SCR4 is a microcontroller-class processor core that has much in common with SCR3. The most significant difference for compilers is F and D extensions support. Overview: https://syntacore.com/products/scr4 Two CPUs are added: * 'syntacore-scr4-rv32' -- rv32imfdc * 'syntacore-scr4-rv64' -- rv64imafdc - Co-authored-by: Dmitrii Petrov Co-authored-by: Anton Afanasyev --- clang/test/Driver/riscv-cpus.c| 27 +++ clang/test/Misc/target-invalid-cpu-note.c | 8 +++ llvm/docs/ReleaseNotes.rst| 1 + llvm/lib/Target/RISCV/RISCVProcessors.td | 25 + 4 files changed, 57 insertions(+), 4 deletions(-) diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c index 26bcda6468dd2..7a885cde76d6a 100644 --- a/clang/test/Driver/riscv-cpus.c +++ b/clang/test/Driver/riscv-cpus.c @@ -381,3 +381,30 @@ // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr3-rv64 | FileCheck -check-prefix=MTUNE-SYNTACORE-SCR3-RV64 %s // MTUNE-SYNTACORE-SCR3-RV64: "-tune-cpu" "syntacore-scr3-rv64" + +// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=syntacore-scr4-rv32 | FileCheck -check-prefix=MCPU-SYNTACORE-SCR4-RV32 %s +// MCPU-SYNTACORE-SCR4-RV32: "-target-cpu" "syntacore-scr4-rv32" +// MCPU-SYNTACORE-SCR4-RV32-SAME: "-target-feature" "+m" +// MCPU-SYNTACORE-SCR4-RV32-SAME: "-target-feature" "+f" +// MCPU-SYNTACORE-SCR4-RV32-SAME: "-target-feature" "+d" +// MCPU-SYNTACORE-SCR4-RV32-SAME: "-target-feature" "+c" +// MCPU-SYNTACORE-SCR4-RV32-SAME: "-target-feature" "+zicsr" +// MCPU-SYNTACORE-SCR4-RV32-SAME: "-target-feature" "+zifencei" +// MCPU-SYNTACORE-SCR4-RV32-SAME: "-target-abi" "ilp32d" + +// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=syntacore-scr4-rv32 | FileCheck -check-prefix=MTUNE-SYNTACORE-SCR4-RV32 %s +// MTUNE-SYNTACORE-SCR4-RV32: "-tune-cpu" "syntacore-scr4-rv32" + +// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=syntacore-scr4-rv64 | FileCheck -check-prefix=MCPU-SYNTACORE-SCR4-RV64 %s +// MCPU-SYNTACORE-SCR4-RV64: "-target-cpu" "syntacore-scr4-rv64" +// MCPU-SYNTACORE-SCR4-RV64-SAME: "-target-feature" "+m" +// MCPU-SYNTACORE-SCR4-RV64-SAME: "-target-feature" "+a" +// MCPU-SYNTACORE-SCR4-RV64-SAME: "-target-feature" "+f" +// MCPU-SYNTACORE-SCR4-RV64-SAME: "-target-feature" "+d" +// MCPU-SYNTACORE-SCR4-RV64-SAME: "-target-feature" "+c" +// MCPU-SYNTACORE-SCR4-RV64-SAME: "-target-feature" "+zicsr" +// MCPU-SYNTACORE-SCR4-RV64-SAME: "-target-feature" "+zifencei" +// MCPU-SYNTACORE-SCR4-RV64-SAME: "-target-abi" "lp64d" + +// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr4-rv64 | FileCheck -check-prefix=MTUNE-SYNTACORE-SCR4-RV64 %s +// MTUNE-SYNTACORE-SCR4-RV64: "-tune-cpu" "syntacore-scr4-rv64" diff --git a/clang/test/Misc/target-invalid-cpu-note.c b/clang/test/Misc/target-invalid-cpu-note.c index e0757b69242a8..b87bced18cb2b 100644 --- a/clang/test/Misc/target-invalid-cpu-note.c +++ b/clang/test/Misc/target-invalid-cpu-note.c @@ -81,16 +81,16 @@ // RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV32 // RISCV32: error: unknown target CPU 'not-a-cpu' -// RISCV32-NEXT: note: valid target CPU values are: generic-rv32, rocket-rv32, sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, syntacore-scr1-base, syntacore-scr1-max, syntacore-scr3-rv32{{$}} +// RISCV32-NEXT: note: valid target CPU values are: generic-rv32, rocket-rv32, sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, syntacore-scr1-base, syntacore-scr1-max, syntacore-scr3-rv32, syntacore-scr4-rv32{{$}} // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV64 // RISCV64: error: unknown target CPU 'not-a-cpu' -// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, sifive-x280, spacemit-x60, syntacore-scr3-rv64, veyron-v1, xiangshan-nanhu{{$}} +// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, sifive-x280,
[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)
skatrak wrote: Thank you all for your reviews. I think it should be ok to merge at this point, but I'll wait until tomorrow to give some time in case there are any remaining concerns about this change. https://github.com/llvm/llvm-project/pull/100152 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/100152 >From 3861b28deeb1b558f182f2ab5680b123fd94c005 Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Tue, 23 Jul 2024 16:19:55 +0100 Subject: [PATCH] [Flang][Driver] Introduce -fopenmp-targets offloading option This patch modifies the flang driver to introduce the `-fopenmp-targets` option to the frontend compiler invocations corresponding to the OpenMP host device on offloading-enabled compilations. This option holds the list of offloading triples associated to the compilation and is used by clang to determine whether offloading calls should be generated for the host. --- clang/include/clang/Driver/Options.td | 2 +- clang/lib/Driver/ToolChains/Clang.cpp | 12 +--- clang/lib/Driver/ToolChains/CommonArgs.cpp | 19 +++ clang/lib/Driver/ToolChains/CommonArgs.h | 5 + clang/lib/Driver/ToolChains/Flang.cpp | 3 +++ flang/test/Driver/omp-driver-offload.f90 | 18 ++ 6 files changed, 47 insertions(+), 12 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index c8c56dbb51b28..59c6bb70d75a2 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3532,7 +3532,7 @@ def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, Group, def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group, Flags<[NoArgumentUnused, HelpHidden]>, Visibility<[ClangOption, CC1Option]>; def fopenmp_targets_EQ : CommaJoined<["-"], "fopenmp-targets=">, - Flags<[NoXarchOption]>, Visibility<[ClangOption, CC1Option, FlangOption]>, + Flags<[NoXarchOption]>, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>, HelpText<"Specify comma-separated list of triples OpenMP offloading targets to be supported">; def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">, Group, Flags<[NoArgumentUnused, HelpHidden]>, diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 843d68c85bc59..0f1141ed8bcd9 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -7789,17 +7789,7 @@ void Clang::ConstructJob(Compilation , const JobAction , options::OPT_mno_amdgpu_ieee); } - // For all the host OpenMP offloading compile jobs we need to pass the targets - // information using -fopenmp-targets= option. - if (JA.isHostOffloading(Action::OFK_OpenMP)) { -SmallString<128> Targets("-fopenmp-targets="); - -SmallVector Triples; -auto TCRange = C.getOffloadToolChains(); -std::transform(TCRange.first, TCRange.second, std::back_inserter(Triples), - [](auto TC) { return TC.second->getTripleString(); }); -CmdArgs.push_back(Args.MakeArgString(Targets + llvm::join(Triples, ","))); - } + addOpenMPHostOffloadingArgs(C, JA, Args, CmdArgs); bool VirtualFunctionElimination = Args.hasFlag(options::OPT_fvirtual_function_elimination, diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 1e37d9d348818..487cc8345d7e3 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1244,6 +1244,25 @@ bool tools::addOpenMPRuntime(const Compilation , ArgStringList , return true; } +void tools::addOpenMPHostOffloadingArgs(const Compilation , +const JobAction , +const llvm::opt::ArgList , +llvm::opt::ArgStringList ) { + if (!JA.isHostOffloading(Action::OFK_OpenMP)) +return; + + // For all the host OpenMP offloading compile jobs we need to pass the targets + // information using -fopenmp-targets= option. + constexpr llvm::StringLiteral Targets("-fopenmp-targets="); + + SmallVector Triples; + auto TCRange = C.getOffloadToolChains(); + std::transform(TCRange.first, TCRange.second, std::back_inserter(Triples), + [](auto TC) { return TC.second->getTripleString(); }); + CmdArgs.push_back( + Args.MakeArgString(Twine(Targets) + llvm::join(Triples, ","))); +} + /// Add Fortran runtime libs void tools::addFortranRuntimeLibs(const ToolChain , const ArgList , llvm::opt::ArgStringList ) { diff --git a/clang/lib/Driver/ToolChains/CommonArgs.h b/clang/lib/Driver/ToolChains/CommonArgs.h index 0d3b4d6b783ba..0c97398dfcfa3 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.h +++ b/clang/lib/Driver/ToolChains/CommonArgs.h @@ -119,6 +119,11 @@ bool addOpenMPRuntime(const Compilation , llvm::opt::ArgStringList , bool ForceStaticHostRuntime = false, bool IsOffloadingHost = false, bool GompNeedsRT = false); +/// Adds offloading options for OpenMP host compilation to \p CmdArgs. +void addOpenMPHostOffloadingArgs(const
[clang] [RISCV] full support for riscv_rvv_vector_bits attribute (PR #100110)
@@ -176,477 +177,3110 @@ typedef vbool1_t fixed_bool1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fi typedef vbool2_t fixed_bool2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen/2))); typedef vbool4_t fixed_bool4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen/4))); typedef vbool8_t fixed_bool8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen/8))); -#if __riscv_v_fixed_vlen >= 128 typedef vbool16_t fixed_bool16_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen/16))); -#endif -#if __riscv_v_fixed_vlen >= 256 typedef vbool32_t fixed_bool32_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen/32))); -#endif -#if __riscv_v_fixed_vlen >= 512 typedef vbool64_t fixed_bool64_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen/64))); -#endif template struct S {}; -// CHECK-64: _Z2f11SI9__RVV_VLSIu14__rvv_int8m1_tLj64EEE vbe-sc wrote: Many thanks for your comment: it allowed me to understand this test and find an improvement in `clang/./lib/AST/ItaniumMangle.cpp` for my patch. Fixed https://github.com/llvm/llvm-project/pull/100110 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RISCV] full support for riscv_rvv_vector_bits attribute (PR #100110)
@@ -572,1483 +1121,44 @@ void f() { //===--===// // Structs and unions //===--===// -// CHECK-64: %struct.struct_int8m1 = type { <8 x i8> } vbe-sc wrote: Done https://github.com/llvm/llvm-project/pull/100110 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [libcxx] [llvm] [cmake] switch to CMake's native `check_{compiler,linker}_flag` (PR #96171)
h-vetinari wrote: This should be good now I think. Does someone want to approve/merge @ldionne @arichardson et al.? https://github.com/llvm/llvm-project/pull/96171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RISCV] full support for riscv_rvv_vector_bits attribute (PR #100110)
https://github.com/vbe-sc updated https://github.com/llvm/llvm-project/pull/100110 >From 33cfa736bb19c6c8ef2d214ecafbc50605eea5eb Mon Sep 17 00:00:00 2001 From: vb-sc Date: Wed, 31 Jul 2024 13:37:34 +0300 Subject: [PATCH] [RISCV] full support for riscv_rvv_vector_bits attribute --- clang/include/clang/AST/Type.h| 4 + clang/lib/AST/ASTContext.cpp | 33 +++- clang/lib/AST/ItaniumMangle.cpp | 26 ++- clang/lib/AST/JSONNodeDumper.cpp | 3 + clang/lib/AST/TextNodeDumper.cpp | 3 + clang/lib/AST/TypePrinter.cpp | 6 + clang/lib/CodeGen/Targets/RISCV.cpp | 22 ++- clang/lib/Sema/SemaExpr.cpp | 13 +- clang/lib/Sema/SemaType.cpp | 18 +- .../attr-riscv-rvv-vector-bits-less-8-call.c | 178 ++ .../attr-riscv-rvv-vector-bits-less-8-cast.c | 123 .../attr-rvv-vector-bits-bitcast-less-8.c | 106 +++ .../RISCV/attr-rvv-vector-bits-globals.c | 36 ++-- .../RISCV/attr-rvv-vector-bits-types.c| 78 .../riscv-mangle-rvv-fixed-vectors.cpp| 20 +- clang/test/Sema/attr-riscv-rvv-vector-bits.c | 18 +- 16 files changed, 587 insertions(+), 100 deletions(-) create mode 100644 clang/test/CodeGen/RISCV/attr-riscv-rvv-vector-bits-less-8-call.c create mode 100644 clang/test/CodeGen/RISCV/attr-riscv-rvv-vector-bits-less-8-cast.c create mode 100644 clang/test/CodeGen/RISCV/attr-rvv-vector-bits-bitcast-less-8.c diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 25defea58c2dc..a9a87ac5837f1 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -3981,6 +3981,10 @@ enum class VectorKind { /// is RISC-V RVV fixed-length mask vector RVVFixedLengthMask, + + RVVFixedLengthMask_1, + RVVFixedLengthMask_2, + RVVFixedLengthMask_4 }; /// Represents a GCC generic vector type. This type is created using diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 7af9ea7105bb0..1b7aed3b9dba8 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1983,7 +1983,10 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { // Adjust the alignment for fixed-length SVE predicates. Align = 16; else if (VT->getVectorKind() == VectorKind::RVVFixedLengthData || - VT->getVectorKind() == VectorKind::RVVFixedLengthMask) + VT->getVectorKind() == VectorKind::RVVFixedLengthMask || + VT->getVectorKind() == VectorKind::RVVFixedLengthMask_1 || + VT->getVectorKind() == VectorKind::RVVFixedLengthMask_2 || + VT->getVectorKind() == VectorKind::RVVFixedLengthMask_4) // Adjust the alignment for fixed-length RVV vectors. Align = std::min(64, Width); break; @@ -9896,7 +9899,13 @@ bool ASTContext::areCompatibleVectorTypes(QualType FirstVec, First->getVectorKind() != VectorKind::RVVFixedLengthData && Second->getVectorKind() != VectorKind::RVVFixedLengthData && First->getVectorKind() != VectorKind::RVVFixedLengthMask && - Second->getVectorKind() != VectorKind::RVVFixedLengthMask) + Second->getVectorKind() != VectorKind::RVVFixedLengthMask && + First->getVectorKind() != VectorKind::RVVFixedLengthMask_1 && + Second->getVectorKind() != VectorKind::RVVFixedLengthMask_1 && + First->getVectorKind() != VectorKind::RVVFixedLengthMask_2 && + Second->getVectorKind() != VectorKind::RVVFixedLengthMask_2 && + First->getVectorKind() != VectorKind::RVVFixedLengthMask_4 && + Second->getVectorKind() != VectorKind::RVVFixedLengthMask_4) return true; return false; @@ -10014,7 +10023,25 @@ bool ASTContext::areCompatibleRVVTypes(QualType FirstType, BuiltinVectorTypeInfo Info = getBuiltinVectorTypeInfo(BT); return FirstType->isRVVVLSBuiltinType() && Info.ElementType == BoolTy && - getTypeSize(SecondType) == getRVVTypeSize(*this, BT); + getTypeSize(SecondType) == ((getRVVTypeSize(*this, BT))); +} +if (VT->getVectorKind() == VectorKind::RVVFixedLengthMask_1) { + BuiltinVectorTypeInfo Info = getBuiltinVectorTypeInfo(BT); + return FirstType->isRVVVLSBuiltinType() && + Info.ElementType == BoolTy && + getTypeSize(SecondType) == ((getRVVTypeSize(*this, BT) * 8)); +} +if (VT->getVectorKind() == VectorKind::RVVFixedLengthMask_2) { + BuiltinVectorTypeInfo Info = getBuiltinVectorTypeInfo(BT); + return FirstType->isRVVVLSBuiltinType() && + Info.ElementType == BoolTy && + getTypeSize(SecondType) == ((getRVVTypeSize(*this, BT)) * 4); +} +if (VT->getVectorKind() == VectorKind::RVVFixedLengthMask_4) { + BuiltinVectorTypeInfo Info = getBuiltinVectorTypeInfo(BT); +
[clang] [SPARC][clang] Add -m(no-)v8plus flags handling (PR #98713)
https://github.com/s-barannikov edited https://github.com/llvm/llvm-project/pull/98713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SPARC][clang] Add -m(no-)v8plus flags handling (PR #98713)
https://github.com/s-barannikov edited https://github.com/llvm/llvm-project/pull/98713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SPARC][clang] Add -m(no-)v8plus flags handling (PR #98713)
@@ -179,6 +179,13 @@ void sparc::getSparcTargetFeatures(const Driver , const ArgList , Features.push_back("-hard-quad-float"); } + if (Arg *A = Args.getLastArg(options::OPT_mv8plus, options::OPT_mno_v8plus)) { +if (A->getOption().matches(options::OPT_mv8plus)) s-barannikov wrote: Either way, the order of `-m8plus` relative to `-mcpu` shouldn't matter (one sets the environment, the other sets an ISA). https://github.com/llvm/llvm-project/pull/98713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SPARC][clang] Add -m(no-)v8plus flags handling (PR #98713)
@@ -179,6 +179,13 @@ void sparc::getSparcTargetFeatures(const Driver , const ArgList , Features.push_back("-hard-quad-float"); } + if (Arg *A = Args.getLastArg(options::OPT_mv8plus, options::OPT_mno_v8plus)) { +if (A->getOption().matches(options::OPT_mv8plus)) s-barannikov wrote: This is quite confusing. `-m[no]-v8plus` is an environment option, similar to X86's `-mx32`, but imposes more restrictions. `-mcpu=v9 -mno-v8plus` should be equivalent to just `-mcpu=v9` because 64-bit environment is the default for 64-bit ISA. `-mv8plus` enables 32-bit environment and therefore should restrict the compiler from using the whole set of V9 features. That is, I would expect it to disable something rather than to enable `v9`, which should already be set by `-mcpu=v9`. https://github.com/llvm/llvm-project/pull/98713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits