[clang] [llvm] [clang] Reland Add tanf16 builtin and support for tan constrained intrinsic (PR #94559)
farzonl wrote: > Can we change the target-independent bits of the tan() implementation in the > backend so it doesn't require each target to explicitly request that tan() > needs to be expanded? It should be possible to adjust the code in > TargetLoweringBase.cpp a bit so FTAN defaults to being expanded for all types. > It might be better to default FTAN to expand in > > https://github.com/llvm/llvm-project/blob/64c9a1e1266ec7bc4c4896b2df116fa12dbacf15/llvm/lib/CodeGen/TargetLoweringBase.cpp#L960 > > , which seems to only be done for f32/f64/f128 at the moment. I don't think we can default on vector types to Expand as it would expand on vector that are not supported for tan. For example VT in this case is `MVT::all_valuetypes()` That includes integer vectors. https://github.com/llvm/llvm-project/blob/64c9a1e1266ec7bc4c4896b2df116fa12dbacf15/llvm/lib/CodeGen/TargetLoweringBase.cpp#L894 Even if it only included floats it would not necessarily be correct For example in ARM https://github.com/llvm/llvm-project/blob/64c9a1e1266ec7bc4c4896b2df116fa12dbacf15/llvm/lib/Target/ARM/ARMISelLowering.cpp#L324-L325 some cases like MVE it is MVT::v8f16, MVT::v4f32 but for NEON MVT::v2f64, MVT::v4f32, and MVT::v2f32 are supported. Doing it per target seems intential so as to have more precision so only intrinsics that are valid to lower get expanded. https://github.com/llvm/llvm-project/pull/94559 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
arsenm wrote: > I understand the chance of conflict is low. It may be like the chance of > hitting by a meteor. However, if we prefix with `__amdgcn_`, there is no such > risk. And we have the benefit to clearly indicate it is a amdgcn > target-specific type. Should use amdgpu https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
@@ -0,0 +1,95 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu verde -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu tonga -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s + +// CHECK-LABEL: @test_amdgcn_make_buffer_rsrc_p0( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = tail call ptr addrspace(8) @llvm.amdgcn.make.buffer.rsrc.p0(ptr [[P:%.*]], i16 [[STRIDE:%.*]], i32 [[NUM:%.*]], i32 [[FLAGS:%.*]]) +// CHECK-NEXT:ret ptr addrspace(8) [[TMP0]] +// +__buffer_rsrc_t test_amdgcn_make_buffer_rsrc_p0(void *p, short stride, int num, int flags) { + return __builtin_amdgcn_make_buffer_rsrc(p, stride, num, flags); arsenm wrote: The context there is slightly different. They are using the raw descriptor, which is addrspace(7), not 8. But the same stands, it probably should be passable around as a value https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] [test] Skip a test that sets PATH= on Windows (PR #95096)
https://github.com/mstorsjo edited https://github.com/llvm/llvm-project/pull/95096 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f5a93c5 - [clang] [test] Skip a test that sets PATH on Windows (#95096)
Author: Martin Storsjö Date: 2024-06-13T10:46:35+03:00 New Revision: f5a93c5f2a4d0916c975bbf028768d58a29b6b73 URL: https://github.com/llvm/llvm-project/commit/f5a93c5f2a4d0916c975bbf028768d58a29b6b73 DIFF: https://github.com/llvm/llvm-project/commit/f5a93c5f2a4d0916c975bbf028768d58a29b6b73.diff LOG: [clang] [test] Skip a test that sets PATH on Windows (#95096) The same has been done in a couple other existing tests, that also are skipped on Windows (e.g. ld-path.c). Some tests that really do want to test setting the path on Windows does it differently, see e.g. ps4-ps5-linker-win.c. Since a65771fce4a2f25f16d4b3918ad6a11370637f7b, the spirv-toolchain.cl test does one test where PATH is set. Setting PATH does work in some build configurations - however, if built with e.g. llvm-mingw, the built Clang executable depends on libc++.dll (and libunwind.dll) which are found in PATH. If the PATH is overridden, the newly built Clang executable no longer can run. Added: Modified: clang/test/Driver/spirv-toolchain.cl Removed: diff --git a/clang/test/Driver/spirv-toolchain.cl b/clang/test/Driver/spirv-toolchain.cl index de818177cb19f..eff02f809ce83 100644 --- a/clang/test/Driver/spirv-toolchain.cl +++ b/clang/test/Driver/spirv-toolchain.cl @@ -80,10 +80,15 @@ //- // Check llvm-spirv- is used if it is found in PATH. +// +// This test uses the PATH environment variable; on Windows, we may need to retain +// the original path for the built Clang binary to be able to execute (as it is +// used for locating dependent DLLs). Therefore, skip this test on system-windows. +// // RUN: mkdir -p %t/versioned // RUN: touch %t/versioned/llvm-spirv-%llvm-version-major \ // RUN: && chmod +x %t/versioned/llvm-spirv-%llvm-version-major -// RUN: env "PATH=%t/versioned" %clang -### --target=spirv64 -x cl -c %s 2>&1 \ -// RUN: | FileCheck -DVERSION=%llvm-version-major --check-prefix=VERSIONED %s +// RUN: %if !system-windows %{ env "PATH=%t/versioned" %clang -### --target=spirv64 -x cl -c %s 2>&1 \ +// RUN: | FileCheck -DVERSION=%llvm-version-major --check-prefix=VERSIONED %s %} // VERSIONED: {{.*}}llvm-spirv-[[VERSION]] ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] [test] Skip a test that sets PATH= on Windows (PR #95096)
https://github.com/mstorsjo closed https://github.com/llvm/llvm-project/pull/95096 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] added regcall struct by reg support (PR #95257)
efriedma-quic wrote: What you're implementing in this change doesn't seem like it brings us much closer to what the document says. I mean, it handles the specific structs in your testcase, but the algorithm you're using doesn't generalize. https://github.com/llvm/llvm-project/pull/95257 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
arsenm wrote: > Just a note - and maybe this was already discussed above - is there good > reason not to explicitly make this type a 128-bit scalar? The LLVM data > layout already does this I thought this was the 160 bit version? Can we have an opaque-but-sized type? The concern is exposing this as a raw pointer right away https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm][Support] Stop using PWD in current_path (PR #94544)
inaki-amatria wrote: Ping https://github.com/llvm/llvm-project/pull/94544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)
@@ -484,10 +484,31 @@ MC/DC Instrumentation - When instrumenting for Modified Condition/Decision Coverage (MC/DC) using the -clang option ``-fcoverage-mcdc``, users are limited to at most **six** leaf-level -conditions in a boolean expression. A warning will be generated for boolean -expressions that contain more than six, and they will not be instrumented for -MC/DC. +clang option ``-fcoverage-mcdc``, there are two hard limits. + +The maximum number of terms is limited to 32767, which is practical for +handwritten expressions. To be more restrictive in order to enforce coding rules, +use ``-Xclang -fmcdc-max-conditions=n``. Expressions with exceeded condition +counts ``n`` will generate warnings. hanickadot wrote: add something like _"and the expression will be removed from MCDC coverage"_ https://github.com/llvm/llvm-project/pull/82448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)
@@ -14416,7 +14416,7 @@ Syntax: :: declare void @llvm.instrprof.mcdc.tvbitmap.update(ptr , i64 , -i32 ) +i32 ) hanickadot wrote: I saw a pattern across whole PR where you replace bytes with bits ... is it intentional here to have the argument unused instead of something like ? https://github.com/llvm/llvm-project/pull/82448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)
@@ -14416,7 +14416,7 @@ Syntax: :: declare void @llvm.instrprof.mcdc.tvbitmap.update(ptr , i64 , -i32 ) +i32 ) chapuni wrote: I wanted to leave the signature of instrinsics as-is. I will remove it in the next request. (FYI, condupdate is not used) https://github.com/llvm/llvm-project/pull/82448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CodeGen] Return RValue from `EmitVAArg` (PR #94635)
@@ -789,27 +791,37 @@ Address AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr, QualType Ty, OnStackBlock, "vaargs.addr"); if (IsIndirect) -return Address(CGF.Builder.CreateLoad(ResAddr, "vaarg.addr"), ElementTy, - TyAlign); - - return ResAddr; +return CGF.EmitLoadOfAnyValue( +CGF.MakeAddrLValue( +Address(CGF.Builder.CreateLoad(ResAddr, "vaarg.addr"), ElementTy, +TyAlign), +Ty), +Slot); + + return CGF.EmitLoadOfAnyValue(CGF.MakeAddrLValue(ResAddr, Ty), Slot); } -Address AArch64ABIInfo::EmitDarwinVAArg(Address VAListAddr, QualType Ty, -CodeGenFunction &CGF) const { +RValue AArch64ABIInfo::EmitDarwinVAArg(Address VAListAddr, QualType Ty, + CodeGenFunction &CGF, + AggValueSlot Slot) const { // The backend's lowering doesn't support va_arg for aggregates or // illegal vector types. Lower VAArg here for these cases and use // the LLVM va_arg instruction for everything else. if (!isAggregateTypeForABI(Ty) && !isIllegalVectorType(Ty)) -return EmitVAArgInstr(CGF, VAListAddr, Ty, ABIArgInfo::getDirect()); +return CGF.EmitLoadOfAnyValue( +CGF.MakeAddrLValue( +EmitVAArgInstr(CGF, VAListAddr, Ty, ABIArgInfo::getDirect()), Ty), +Slot); uint64_t PointerSize = getTarget().getPointerWidth(LangAS::Default) / 8; CharUnits SlotSize = CharUnits::fromQuantity(PointerSize); // Empty records are ignored for parameter passing purposes. - if (isEmptyRecord(getContext(), Ty, true)) -return Address(CGF.Builder.CreateLoad(VAListAddr, "ap.cur"), - CGF.ConvertTypeForMem(Ty), SlotSize); + if (isEmptyRecord(getContext(), Ty, true)) { +Address ResAddr = Address(CGF.Builder.CreateLoad(VAListAddr, "ap.cur"), Fznamznon wrote: Good point, I didn't think about that. I removed load construction. https://github.com/llvm/llvm-project/pull/94635 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix handling of brace ellison when building deduction guides (PR #94889)
@@ -10918,22 +10944,24 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer( if (!(RD->getDefinition() && RD->isAggregate())) return; QualType Ty = Context.getRecordType(RD); - SmallVector ElementTypes; - - InitListChecker CheckInitList(*this, Entity, ListInit, Ty, ElementTypes); - if (!CheckInitList.HadError()) { + auto BuildAggregateDeductionGuide = [&](MutableArrayRef + ElementTypes, + bool BracedVersion = false) { +if (ElementTypes.empty()) + return; // C++ [over.match.class.deduct]p1.8: // if e_i is of array type and x_i is a braced-init-list, T_i is an // rvalue reference to the declared type of e_i and // C++ [over.match.class.deduct]p1.9: -// if e_i is of array type and x_i is a bstring-literal, T_i is an +// if e_i is of array type and x_i is a string-literal, T_i is an // lvalue reference to the const-qualified declared type of e_i and // C++ [over.match.class.deduct]p1.10: // otherwise, T_i is the declared type of e_i -for (int I = 0, E = ListInit->getNumInits(); +for (int I = 0, E = BracedVersion ? ElementTypes.size() + : ListInit->getNumInits(); I < E && !isa(ElementTypes[I]); ++I) if (ElementTypes[I]->isArrayType()) { -if (isa(ListInit->getInit(I))) +if (isa(ListInit->getInit(I))) cor3ntin wrote: a `designated-initializer-list` is a sequence of element without braces, so this makes sense to me https://github.com/llvm/llvm-project/pull/94889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)
pdherbemont wrote: Ah nice catch! Thank you @aeubanks and @delcypher – I am going to try to understand why (and add a new test) https://github.com/llvm/llvm-project/pull/94216 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix handling of brace ellison when building deduction guides (PR #94889)
https://github.com/cor3ntin approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/94889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix handling of brace ellison when building deduction guides (PR #94889)
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/94889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][SME] Save VG for unwind info when changing streaming-mode (PR #83301)
https://github.com/sdesmalen-arm approved this pull request. Some very minor nits, but overall LGTM. https://github.com/llvm/llvm-project/pull/83301 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][SME] Save VG for unwind info when changing streaming-mode (PR #83301)
@@ -3062,7 +3131,68 @@ bool AArch64FrameLowering::spillCalleeSavedRegisters( Size = 2; Alignment = Align(2); break; +case RegPairInfo::VG: + StrOpc = AArch64::STRXui; + Size = 8; + Alignment = Align(8); + break; +} + +unsigned X0Scratch = AArch64::NoRegister; +if (Reg1 == AArch64::VG) { + // Find an available register to store value of VG to. + Reg1 = findScratchNonCalleeSaveRegister(&MBB); + assert(Reg1 != AArch64::NoRegister); + SMEAttrs Attrs(MF.getFunction()); + + if (Attrs.hasStreamingBody() && !Attrs.hasStreamingInterface() && + AFI->getStreamingVGIdx() == std::numeric_limits::max()) { +// For locally-streaming functions, we need to store both the streaming +// & non-streaming VG. Spill the streaming value first. +BuildMI(MBB, MI, DL, TII.get(AArch64::RDSVLI_XI), Reg1) +.addImm(1) +.setMIFlag(MachineInstr::FrameSetup); +BuildMI(MBB, MI, DL, TII.get(AArch64::UBFMXri), Reg1) +.addReg(Reg1) +.addImm(3) +.addImm(63) +.setMIFlag(MachineInstr::FrameSetup); + +AFI->setStreamingVGIdx(RPI.FrameIdx); + } else { +if (HasSVE) + BuildMI(MBB, MI, DL, TII.get(AArch64::CNTD_XPiI), Reg1) + .addImm(31) + .addImm(1) + .setMIFlag(MachineInstr::FrameSetup); +else { + const AArch64Subtarget &STI = MF.getSubtarget(); + for (const auto &LiveIn : MBB.liveins()) +if (STI.getRegisterInfo()->isSuperOrSubRegisterEq(AArch64::X0, + LiveIn.PhysReg)) + X0Scratch = Reg1; sdesmalen-arm wrote: Is this missing a `break` ? If so, you can write this using any_of, e.g.: ``` if (llvm::any_of(MBB.liveins(), [&STI](const RegisterMaskPair &LiveIn) { return STI.getRegisterInfo()->isSuperOrSubRegisterEq(AArch64::X0, LiveIn.PhysReg); })) X0Scratch = Reg1; ``` https://github.com/llvm/llvm-project/pull/83301 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][SME] Save VG for unwind info when changing streaming-mode (PR #83301)
@@ -3062,7 +3131,68 @@ bool AArch64FrameLowering::spillCalleeSavedRegisters( Size = 2; Alignment = Align(2); break; +case RegPairInfo::VG: + StrOpc = AArch64::STRXui; + Size = 8; + Alignment = Align(8); + break; +} + +unsigned X0Scratch = AArch64::NoRegister; +if (Reg1 == AArch64::VG) { + // Find an available register to store value of VG to. + Reg1 = findScratchNonCalleeSaveRegister(&MBB); + assert(Reg1 != AArch64::NoRegister); + SMEAttrs Attrs(MF.getFunction()); + + if (Attrs.hasStreamingBody() && !Attrs.hasStreamingInterface() && + AFI->getStreamingVGIdx() == std::numeric_limits::max()) { +// For locally-streaming functions, we need to store both the streaming +// & non-streaming VG. Spill the streaming value first. +BuildMI(MBB, MI, DL, TII.get(AArch64::RDSVLI_XI), Reg1) +.addImm(1) +.setMIFlag(MachineInstr::FrameSetup); +BuildMI(MBB, MI, DL, TII.get(AArch64::UBFMXri), Reg1) +.addReg(Reg1) +.addImm(3) +.addImm(63) +.setMIFlag(MachineInstr::FrameSetup); + +AFI->setStreamingVGIdx(RPI.FrameIdx); + } else { +if (HasSVE) + BuildMI(MBB, MI, DL, TII.get(AArch64::CNTD_XPiI), Reg1) + .addImm(31) + .addImm(1) + .setMIFlag(MachineInstr::FrameSetup); +else { + const AArch64Subtarget &STI = MF.getSubtarget(); + for (const auto &LiveIn : MBB.liveins()) +if (STI.getRegisterInfo()->isSuperOrSubRegisterEq(AArch64::X0, + LiveIn.PhysReg)) + X0Scratch = Reg1; + + if (X0Scratch != AArch64::NoRegister) +BuildMI(MBB, MI, DL, TII.get(AArch64::ORRXrr), Reg1) +.addReg(AArch64::XZR) +.addReg(AArch64::X0, RegState::Undef) +.addReg(AArch64::X0, RegState::Implicit) +.setMIFlag(MachineInstr::FrameSetup); + + const uint32_t *RegMask = TRI->getCallPreservedMask( + MF, CallingConv:: + AArch64_SME_ABI_Support_Routines_PreserveMost_From_X1); + BuildMI(MBB, MI, DL, TII.get(AArch64::BL)) + .addExternalSymbol("__arm_get_current_vg") + .addRegMask(RegMask) + .addReg(AArch64::X0, RegState::ImplicitDefine) + .setMIFlag(MachineInstr::FrameSetup); + Reg1 = AArch64::X0; +} +AFI->setVGIdx(RPI.FrameIdx); + } sdesmalen-arm wrote: nit: put `AFI->setVGIdx(RPI.FrameIdx);` in both the `if(HasSVE)` and the `else` branch, and remove a level of indentation? ```suggestion } else if (HasSVE) { BuildMI(MBB, MI, DL, TII.get(AArch64::CNTD_XPiI), Reg1) .addImm(31) .addImm(1) .setMIFlag(MachineInstr::FrameSetup); AFI->setVGIdx(RPI.FrameIdx); } else { const AArch64Subtarget &STI = MF.getSubtarget(); for (const auto &LiveIn : MBB.liveins()) if (STI.getRegisterInfo()->isSuperOrSubRegisterEq(AArch64::X0, LiveIn.PhysReg)) X0Scratch = Reg1; if (X0Scratch != AArch64::NoRegister) BuildMI(MBB, MI, DL, TII.get(AArch64::ORRXrr), Reg1) .addReg(AArch64::XZR) .addReg(AArch64::X0, RegState::Undef) .addReg(AArch64::X0, RegState::Implicit) .setMIFlag(MachineInstr::FrameSetup); const uint32_t *RegMask = TRI->getCallPreservedMask( MF, CallingConv:: AArch64_SME_ABI_Support_Routines_PreserveMost_From_X1); BuildMI(MBB, MI, DL, TII.get(AArch64::BL)) .addExternalSymbol("__arm_get_current_vg") .addRegMask(RegMask) .addReg(AArch64::X0, RegState::ImplicitDefine) .setMIFlag(MachineInstr::FrameSetup); Reg1 = AArch64::X0; AFI->setVGIdx(RPI.FrameIdx); } ``` https://github.com/llvm/llvm-project/pull/83301 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Offload] Introduce the concept of "default streams" (PR #95371)
llvmbot wrote: @llvm/pr-subscribers-offload @llvm/pr-subscribers-clang-driver Author: Johannes Doerfert (jdoerfert) Changes The offload APIs, and the CUDA wrappers in clang, now support "default streams" per thread (and per device). It should be per context but we don't really expose that concept yet. The KernelArguments allow an LLVM/Offload user to provide a "AsyncInfoQueue", which is plugin dependent and can later also be created outside or queried from the runtime. User managed "queues" are kept persistent, thus not returned to the pool once synchronized. The CUDA tests will synchronize via `cudaDeviceSynchronize` before checking the results. Based on https://github.com/llvm/llvm-project/pull/94821. --- Patch is 58.22 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/95371.diff 34 Files Affected: - (modified) clang/include/clang/Basic/LangOptions.def (+1) - (modified) clang/include/clang/Driver/Options.td (+6) - (modified) clang/lib/CodeGen/CGCUDANV.cpp (+62-15) - (modified) clang/lib/Driver/Driver.cpp (+12-7) - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+26-4) - (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+6-1) - (modified) clang/lib/Headers/CMakeLists.txt (+16-3) - (added) clang/lib/Headers/llvm_offload_wrappers/__llvm_offload.h (+31) - (added) clang/lib/Headers/llvm_offload_wrappers/__llvm_offload_device.h (+10) - (added) clang/lib/Headers/llvm_offload_wrappers/__llvm_offload_host.h (+15) - (added) clang/lib/Headers/llvm_offload_wrappers/cuda_runtime.h (+139) - (modified) clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h (+2-4) - (modified) clang/lib/Sema/SemaCUDA.cpp (+3) - (added) clang/test/Driver/cuda-via-liboffload.cu (+23) - (modified) llvm/include/llvm/Frontend/OpenMP/OMPConstants.h (+1-1) - (modified) llvm/include/llvm/Frontend/OpenMP/OMPKinds.def (+1-1) - (modified) llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp (+3-1) - (modified) offload/include/Shared/APITypes.h (+27-15) - (modified) offload/include/omptarget.h (+17-3) - (modified) offload/plugins-nextgen/amdgpu/src/rtl.cpp (+23-10) - (modified) offload/plugins-nextgen/common/src/PluginInterface.cpp (+13-3) - (modified) offload/plugins-nextgen/cuda/src/rtl.cpp (+11-5) - (modified) offload/src/CMakeLists.txt (+1) - (added) offload/src/KernelLanguage/API.cpp (+86) - (modified) offload/src/exports (+5) - (modified) offload/src/interface.cpp (+48-1) - (modified) offload/src/omptarget.cpp (+1-1) - (modified) offload/test/lit.cfg (+1-1) - (added) offload/test/offloading/CUDA/basic_api_malloc_free.cu (+42) - (added) offload/test/offloading/CUDA/basic_api_memcpy.cu (+47) - (added) offload/test/offloading/CUDA/basic_api_memset.cu (+44) - (added) offload/test/offloading/CUDA/basic_launch.cu (+30) - (added) offload/test/offloading/CUDA/basic_launch_blocks_and_threads.cu (+32) - (added) offload/test/offloading/CUDA/basic_launch_multi_arg.cu (+39) ``diff diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 4061451b2150a..8aff98867202e 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -288,6 +288,7 @@ LANGOPT(GPUMaxThreadsPerBlock, 32, 1024, "default max threads per block for kern LANGOPT(GPUDeferDiag, 1, 0, "defer host/device related diagnostic messages for CUDA/HIP") LANGOPT(GPUExcludeWrongSideOverloads, 1, 0, "always exclude wrong side overloads in overloading resolution for CUDA/HIP") LANGOPT(OffloadingNewDriver, 1, 0, "use the new driver for generating offloading code.") +LANGOPT(OffloadViaLLVM, 1, 0, "target LLVM/Offload as portable offloading runtime.") LANGOPT(SYCLIsDevice , 1, 0, "Generate code for SYCL device") LANGOPT(SYCLIsHost, 1, 0, "SYCL host compilation") diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 57f37c5023110..a09d75917ff98 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1275,6 +1275,12 @@ def no_offload_compress : Flag<["--"], "no-offload-compress">; def offload_compression_level_EQ : Joined<["--"], "offload-compression-level=">, Flags<[HelpHidden]>, HelpText<"Compression level for offload device binaries (HIP only)">; + +defm offload_via_llvm : BoolFOption<"offload-via-llvm", + LangOpts<"OffloadViaLLVM">, DefaultFalse, + PosFlag, + NegFlag, + BothFlags<[], [ClangOption], " LLVM/Offload as portable offloading runtime.">>; } // CUDA options diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp index 43dfbbb90dd52..8e32aad88a26d 100644 --- a/clang/lib/CodeGen/CGCUDANV.cpp +++ b/clang/lib/CodeGen/CGCUDANV.cpp @@ -15,10 +15,12 @@ #include "CGCXXABI.h" #include "CodeGenFunction.h" #include "CodeGenModule.h" +#include "clang/AST/CharUnits.h" #include "clang/AST/Decl.h" #include "clang/Basic/Cuda.h" #include "clang/CodeGen/Cod
[clang] [llvm] [Offload] Introduce the concept of "default streams" (PR #95371)
@@ -1125,6 +1125,22 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA, CmdArgs.push_back("__clang_openmp_device_functions.h"); } + if (Args.hasArg(options::OPT_foffload_via_llvm)) { +// Add llvm_wrappers/* to our system include path. This lets us wrap +// standard library headers and other headers. +SmallString<128> P(D.ResourceDir); +llvm::sys::path::append(P, "include"); +llvm::sys::path::append(P, "llvm_offload_wrappers"); arsenm wrote: I think append is variadic and you can do both pieces in one call https://github.com/llvm/llvm-project/pull/95371 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Offload] Introduce the concept of "default streams" (PR #95371)
@@ -1125,6 +1125,22 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA, CmdArgs.push_back("__clang_openmp_device_functions.h"); } + if (Args.hasArg(options::OPT_foffload_via_llvm)) { +// Add llvm_wrappers/* to our system include path. This lets us wrap +// standard library headers and other headers. +SmallString<128> P(D.ResourceDir); +llvm::sys::path::append(P, "include"); +llvm::sys::path::append(P, "llvm_offload_wrappers"); +CmdArgs.push_back("-internal-isystem"); +CmdArgs.push_back(Args.MakeArgString(P)); + +CmdArgs.push_back("-include"); +if (JA.isDeviceOffloading(Action::OFK_OpenMP)) + CmdArgs.push_back("__llvm_offload_device.h"); +else + CmdArgs.push_back("__llvm_offload_host.h"); arsenm wrote: Push pack select of string name? https://github.com/llvm/llvm-project/pull/95371 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] added regcall struct by reg support (PR #95257)
mahesh-attarde wrote: > What you're implementing in this change doesn't seem like it brings us much > closer to what the document says. I mean, it handles the specific structs in > your testcase, but the algorithm you're using doesn't generalize. Can you suggest case which can be useful in generalizing? https://github.com/llvm/llvm-project/pull/95257 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Add winsysroot alias to the GNU driver (PR #95320)
mstorsjo wrote: What's the deal with constantly force-pushing an update to the PR, with the exact same contents? With the massive inflow of commits in LLVM, you can't rebase your branch constantly on top of the latest one many times per day, I would say. And what's going on when #94731 was closed and now this one is reopened? https://github.com/llvm/llvm-project/pull/95320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Offload][CUDA] Add initial cuda_runtime.h overlay (PR #94821)
https://github.com/jdoerfert updated https://github.com/llvm/llvm-project/pull/94821 >From d06585044bd6d2dd76d6110bce933e01fd4b333e Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Mon, 3 Jun 2024 19:52:12 -0700 Subject: [PATCH 1/2] [Offload][CUDA] Allow CUDA kernels to use LLVM/Offload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Through the new `-foffload-via-llvm` flag, CUDA kernels can now be lowered to the LLVM/Offload API. On the Clang side, this is simply done by using the OpenMP offload toolchain and emitting calls to `llvm*` functions to orchestrate the kernel launch rather than `cuda*` functions. These `llvm*` functions are implemented on top of the existing LLVM/Offload API. As we are about to redefine the Offload API, this wil help us in the design process as a second offload language. We do not support any CUDA APIs yet, however, we could: https://www.osti.gov/servlets/purl/1892137 For proper host execution we need to resurrect/rebase https://tianshilei.me/wp-content/uploads/2021/12/llpp-2021.pdf (which was designed for debugging). ``` ❯❯❯ cat test.cu extern "C" { void *llvm_omp_target_alloc_shared(size_t Size, int DeviceNum); void llvm_omp_target_free_shared(void *DevicePtr, int DeviceNum); } __global__ void square(int *A) { *A = 42; } int main(int argc, char **argv) { int DevNo = 0; int *Ptr = reinterpret_cast(llvm_omp_target_alloc_shared(4, DevNo)); *Ptr = 7; printf("Ptr %p, *Ptr %i\n", Ptr, *Ptr); square<<<1, 1>>>(Ptr); printf("Ptr %p, *Ptr %i\n", Ptr, *Ptr); llvm_omp_target_free_shared(Ptr, DevNo); } ❯❯❯ clang++ test.cu -O3 -o test123 -foffload-via-llvm --offload-arch=native ❯❯❯ llvm-objdump --offloading test123 test123:file format elf64-x86-64 OFFLOADING IMAGE [0]: kindelf archgfx90a triple amdgcn-amd-amdhsa produceropenmp ❯❯❯ LIBOMPTARGET_INFO=16 ./test123 Ptr 0x155448ac8000, *Ptr 7 Ptr 0x155448ac8000, *Ptr 42 ``` --- clang/include/clang/Basic/LangOptions.def | 1 + clang/include/clang/Driver/Options.td | 6 ++ clang/lib/CodeGen/CGCUDANV.cpp| 97 --- clang/lib/Driver/Driver.cpp | 19 ++-- clang/lib/Driver/ToolChains/Clang.cpp | 27 +- clang/lib/Driver/ToolChains/CommonArgs.cpp| 7 +- clang/lib/Driver/ToolChains/Cuda.cpp | 27 +++--- clang/lib/Headers/CMakeLists.txt | 18 +++- .../llvm_offload_wrappers/__llvm_offload.h| 31 ++ .../__llvm_offload_device.h | 10 ++ .../__llvm_offload_host.h | 15 +++ .../__clang_openmp_device_functions.h | 9 +- clang/lib/Sema/SemaCUDA.cpp | 3 + clang/test/CodeGenCUDA/offload_via_llvm.cu| 97 +++ clang/test/Driver/cuda-via-liboffload.cu | 23 + offload/include/Shared/APITypes.h | 5 +- offload/include/omptarget.h | 2 +- .../common/src/PluginInterface.cpp| 13 ++- offload/src/CMakeLists.txt| 1 + offload/src/KernelLanguage/API.cpp| 76 +++ offload/src/exports | 3 + offload/test/lit.cfg | 2 +- offload/test/offloading/CUDA/basic_launch.cu | 31 ++ .../CUDA/basic_launch_blocks_and_threads.cu | 32 ++ .../offloading/CUDA/basic_launch_multi_arg.cu | 41 offload/test/offloading/CUDA/kernel_tu.cu.inc | 1 + offload/test/offloading/CUDA/launch_tu.cu | 32 ++ 27 files changed, 576 insertions(+), 53 deletions(-) create mode 100644 clang/lib/Headers/llvm_offload_wrappers/__llvm_offload.h create mode 100644 clang/lib/Headers/llvm_offload_wrappers/__llvm_offload_device.h create mode 100644 clang/lib/Headers/llvm_offload_wrappers/__llvm_offload_host.h create mode 100644 clang/test/CodeGenCUDA/offload_via_llvm.cu create mode 100644 clang/test/Driver/cuda-via-liboffload.cu create mode 100644 offload/src/KernelLanguage/API.cpp create mode 100644 offload/test/offloading/CUDA/basic_launch.cu create mode 100644 offload/test/offloading/CUDA/basic_launch_blocks_and_threads.cu create mode 100644 offload/test/offloading/CUDA/basic_launch_multi_arg.cu create mode 100644 offload/test/offloading/CUDA/kernel_tu.cu.inc create mode 100644 offload/test/offloading/CUDA/launch_tu.cu diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 2dea3cd4d795b..e8d3be7e89dbb 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -288,6 +288,7 @@ LANGOPT(GPUMaxThreadsPerBlock, 32, 1024, "default max threads per block for kern LANGOPT(GPUDeferDiag, 1, 0, "defer host/device related diagnostic messages for CUDA/HIP") LANGOPT(GPUExcludeWrongSideOverloads, 1, 0, "always exclude wrong side overloads in overloading resolution for CUDA/HIP") LANGOPT(OffloadingNewDriver, 1, 0, "use
[clang] [Clang] Fix handling of brace ellison when building deduction guides (PR #94889)
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/94889 >From 217c00f47aaa65b113d1c1cfd93a9c4e1d235c1a Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Sun, 9 Jun 2024 11:49:18 +0800 Subject: [PATCH 1/8] [Clang] Fix two issues of CTAD for aggregates --- clang/lib/Sema/SemaInit.cpp | 56 +++-- clang/test/SemaTemplate/deduction-guide.cpp | 19 +++ 2 files changed, 60 insertions(+), 15 deletions(-) diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 79bdc8e9f8783..de2ea639bbba8 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -313,6 +313,8 @@ class InitListChecker { InitListExpr *FullyStructuredList = nullptr; NoInitExpr *DummyExpr = nullptr; SmallVectorImpl *AggrDeductionCandidateParamTypes = nullptr; + SmallVectorImpl + *AggrDeductionCandidateParamTypesWithoutBraceElision = nullptr; NoInitExpr *getDummyInit() { if (!DummyExpr) @@ -506,14 +508,19 @@ class InitListChecker { Sema &S, const InitializedEntity &Entity, InitListExpr *IL, QualType &T, bool VerifyOnly, bool TreatUnavailableAsInvalid, bool InOverloadResolution = false, - SmallVectorImpl *AggrDeductionCandidateParamTypes = nullptr); + SmallVectorImpl *AggrDeductionCandidateParamTypes = nullptr, + SmallVectorImpl + *AggrDeductionCandidateParamTypesWithoutBraceElision = nullptr); InitListChecker(Sema &S, const InitializedEntity &Entity, InitListExpr *IL, QualType &T, - SmallVectorImpl &AggrDeductionCandidateParamTypes) + SmallVectorImpl &AggrDeductionCandidateParamTypes, + SmallVectorImpl + &AggrDeductionCandidateParamTypesWithoutBraceElision) : InitListChecker(S, Entity, IL, T, /*VerifyOnly=*/true, /*TreatUnavailableAsInvalid=*/false, /*InOverloadResolution=*/false, -&AggrDeductionCandidateParamTypes){}; +&AggrDeductionCandidateParamTypes, +&AggrDeductionCandidateParamTypesWithoutBraceElision) {} bool HadError() { return hadError; } @@ -982,11 +989,15 @@ static bool hasAnyDesignatedInits(const InitListExpr *IL) { InitListChecker::InitListChecker( Sema &S, const InitializedEntity &Entity, InitListExpr *IL, QualType &T, bool VerifyOnly, bool TreatUnavailableAsInvalid, bool InOverloadResolution, -SmallVectorImpl *AggrDeductionCandidateParamTypes) +SmallVectorImpl *AggrDeductionCandidateParamTypes, +SmallVectorImpl +*AggrDeductionCandidateParamTypesWithoutBraceElision) : SemaRef(S), VerifyOnly(VerifyOnly), TreatUnavailableAsInvalid(TreatUnavailableAsInvalid), InOverloadResolution(InOverloadResolution), - AggrDeductionCandidateParamTypes(AggrDeductionCandidateParamTypes) { + AggrDeductionCandidateParamTypes(AggrDeductionCandidateParamTypes), + AggrDeductionCandidateParamTypesWithoutBraceElision( + AggrDeductionCandidateParamTypesWithoutBraceElision) { if (!VerifyOnly || hasAnyDesignatedInits(IL)) { FullyStructuredList = createInitListExpr(T, IL->getSourceRange(), IL->getNumInits()); @@ -1448,13 +1459,17 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity, // brace elision is not considered for any aggregate element that has a // dependent non-array type or an array type with a value-dependent // bound - assert(AggrDeductionCandidateParamTypes); - if (!isa_and_nonnull( + assert(AggrDeductionCandidateParamTypes && + AggrDeductionCandidateParamTypesWithoutBraceElision); + if (!isa_and_present( SemaRef.Context.getAsArrayType(ElemType))) { ++Index; AggrDeductionCandidateParamTypes->push_back(ElemType); return; } + // For array types with known bounds, we still want the brace version even + // though the braces can be elided. + AggrDeductionCandidateParamTypesWithoutBraceElision->push_back(ElemType); } else { InitializationSequence Seq(SemaRef, TmpEntity, Kind, expr, /*TopLevelOfInitList*/ true); @@ -10918,22 +10933,24 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer( if (!(RD->getDefinition() && RD->isAggregate())) return; QualType Ty = Context.getRecordType(RD); - SmallVector ElementTypes; - - InitListChecker CheckInitList(*this, Entity, ListInit, Ty, ElementTypes); - if (!CheckInitList.HadError()) { + auto BuildAggregateDeductionGuide = [&](MutableArrayRef + ElementTypes, + bool BracedVersion = false) { +if (ElementTypes.empty()) + return; // C++ [over.match.class.deduct]p1.8:
[clang] [llvm] [Offload] Introduce the concept of "default streams" (PR #95371)
@@ -1125,6 +1125,22 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA, CmdArgs.push_back("__clang_openmp_device_functions.h"); } + if (Args.hasArg(options::OPT_foffload_via_llvm)) { +// Add llvm_wrappers/* to our system include path. This lets us wrap +// standard library headers and other headers. +SmallString<128> P(D.ResourceDir); +llvm::sys::path::append(P, "include"); +llvm::sys::path::append(P, "llvm_offload_wrappers"); jdoerfert wrote: Sorry, I pushed this first on top of old commits. This was fixed and I updated all my PRs. Since I'm not able to do stacked commits, basically only review the latest one in each PR. https://github.com/llvm/llvm-project/pull/95371 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Clean up macOS version flags (PR #95374)
llvmbot wrote: @llvm/pr-subscribers-clang-static-analyzer-1 Author: Gábor Horváth (Xazax-hun) Changes The -mmacos-version-min flag is preferred over -mmacosx-version-min. This patch makes updates the tests and documentation to make this clear and also adds the missing logic to scan build to handle the new flag. Fixes #86376. --- Patch is 25.39 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/95374.diff 19 Files Affected: - (modified) clang/docs/CommandGuide/clang.rst (+2-2) - (modified) clang/docs/LanguageExtensions.rst (+2-2) - (modified) clang/include/clang/Driver/ToolChain.h (+1-1) - (modified) clang/test/Coverage/targets.c (+1-1) - (modified) clang/test/Driver/arc.c (+1-1) - (modified) clang/test/Driver/arclite-link.c (+4-4) - (modified) clang/test/Driver/darwin-objc-defaults.m (+7-7) - (modified) clang/test/Driver/darwin-stdlib-dont-pass-in-c.c (+1-1) - (modified) clang/test/Driver/darwin-stdlib.cpp (+3-3) - (modified) clang/test/Driver/darwin-version.c (+5-5) - (modified) clang/test/Driver/darwin-xarch.c (+2-2) - (modified) clang/test/Driver/fsanitize.c (+3-3) - (modified) clang/test/Driver/macos-apple-silicon-slice-link-libs-darwin-only.cpp (+2-2) - (modified) clang/test/Driver/sanitizer-ld.c (+2-2) - (modified) clang/test/Driver/stack-protector.c (+7-7) - (modified) clang/test/Index/TestClassForwardDecl.m (+1-1) - (modified) clang/test/Index/c-index-api-loadTU-test.m (+1-1) - (modified) clang/test/Index/c-index-getCursor-test.m (+1-1) - (modified) clang/tools/scan-build/libexec/ccc-analyzer (+1) ``diff diff --git a/clang/docs/CommandGuide/clang.rst b/clang/docs/CommandGuide/clang.rst index 643365215f875..14400c39e9190 100644 --- a/clang/docs/CommandGuide/clang.rst +++ b/clang/docs/CommandGuide/clang.rst @@ -362,7 +362,7 @@ number of cross compilers, or may only support a native target. Specify the architecture to build for (all platforms). -.. option:: -mmacosx-version-min= +.. option:: -mmacos-version-min= When building for macOS, specify the minimum version supported by your application. @@ -723,7 +723,7 @@ ENVIRONMENT .. envvar:: MACOSX_DEPLOYMENT_TARGET - If :option:`-mmacosx-version-min` is unspecified, the default deployment + If :option:`-mmacos-version-min` is unspecified, the default deployment target is read from this environment variable. This option only affects Darwin targets. diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index 1b5db388301f7..9830b35faae12 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -2064,7 +2064,7 @@ Objective-C @available -- It is possible to use the newest SDK but still build a program that can run on -older versions of macOS and iOS by passing ``-mmacosx-version-min=`` / +older versions of macOS and iOS by passing ``-mmacos-version-min=`` / ``-miphoneos-version-min=``. Before LLVM 5.0, when calling a function that exists only in the OS that's @@ -2085,7 +2085,7 @@ When a method that's introduced in the OS newer than the target OS is called, a void my_fun(NSSomeClass* var) { // If fancyNewMethod was added in e.g. macOS 10.12, but the code is -// built with -mmacosx-version-min=10.11, then this unconditional call +// built with -mmacos-version-min=10.11, then this unconditional call // will emit a -Wunguarded-availability warning: [var fancyNewMethod]; } diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index 9789cfacafd78..1f93bd612e9b0 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -639,7 +639,7 @@ class ToolChain { /// ComputeEffectiveClangTriple - Return the Clang triple to use for this /// target, which may take into account the command line arguments. For - /// example, on Darwin the -mmacosx-version-min= command line argument (which + /// example, on Darwin the -mmacos-version-min= command line argument (which /// sets the deployment target) determines the version in the triple passed to /// Clang. virtual std::string ComputeEffectiveClangTriple( diff --git a/clang/test/Coverage/targets.c b/clang/test/Coverage/targets.c index a0ec2836874a6..15110eadb298e 100644 --- a/clang/test/Coverage/targets.c +++ b/clang/test/Coverage/targets.c @@ -14,4 +14,4 @@ // RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-unknown -emit-llvm -o %t %s // clang 1.0 fails to compile Python 2.6 -// RUN: %clang -target x86_64-apple-darwin9 -### -S %s -mmacosx-version-min=10.4 +// RUN: %clang -target x86_64-apple-darwin9 -### -S %s -mmacos-version-min=10.4 diff --git a/clang/test/Driver/arc.c b/clang/test/Driver/arc.c index 6c91a3b1c87c6..e5d1af5225662 100644 --- a/clang/test/Driver/arc.c +++ b/clang/test/Driver/arc.c @@ -3,7 +3,7 @@ // RUN: not %clang -x objective-c++ -target i386-apple-dar
[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [lld] [lldb] [llvm] [mlir] [openmp] [llvm-project] Fix typo "seperate" (PR #95373)
llvmbot wrote: @llvm/pr-subscribers-clang-tools-extra @llvm/pr-subscribers-lldb @llvm/pr-subscribers-lld Author: Jay Foad (jayfoad) Changes --- Patch is 57.75 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/95373.diff 64 Files Affected: - (modified) clang-tools-extra/clangd/TidyProvider.cpp (+5-5) - (modified) clang/include/clang/Frontend/FrontendOptions.h (+1-1) - (modified) clang/include/clang/InstallAPI/DylibVerifier.h (+1-1) - (modified) clang/lib/InstallAPI/Visitor.cpp (+1-1) - (modified) clang/lib/Serialization/ASTWriterStmt.cpp (+1-1) - (modified) compiler-rt/test/dfsan/custom.cpp (+1-1) - (modified) compiler-rt/test/orc/TestCases/Linux/ppc64/trivial-tls-pwr10.test (+1-1) - (modified) flang/examples/FlangOmpReport/yaml_summarizer.py (+1-1) - (modified) flang/lib/Semantics/check-omp-structure.cpp (+5-5) - (modified) flang/test/Driver/mllvm_vs_mmlir.f90 (+1-1) - (modified) libc/src/__support/FPUtil/x86_64/FEnvImpl.h (+1-1) - (modified) libc/src/stdio/printf_core/float_hex_converter.h (+5-5) - (modified) libc/test/src/__support/str_to_float_comparison_test.cpp (+1-1) - (modified) lld/test/wasm/data-segments.ll (+1-1) - (modified) lldb/include/lldb/Expression/DWARFExpressionList.h (+1-1) - (modified) lldb/include/lldb/Target/MemoryTagManager.h (+1-1) - (modified) lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp (+1-1) - (modified) lldb/test/API/CMakeLists.txt (+1-1) - (modified) lldb/test/API/tools/lldb-server/memory-tagging/TestGdbRemoteMemoryTagging.py (+1-1) - (modified) lldb/test/Shell/SymbolFile/DWARF/x86/DW_AT_data_bit_offset-DW_OP_stack_value.s (+1-1) - (modified) llvm/include/llvm/CodeGen/LiveRegUnits.h (+1-1) - (modified) llvm/include/llvm/CodeGen/MIRFormatter.h (+1-1) - (modified) llvm/include/llvm/MC/MCAsmInfo.h (+1-1) - (modified) llvm/include/llvm/Support/raw_socket_stream.h (+1-1) - (modified) llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h (+1-1) - (modified) llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp (+3-3) - (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (+2-2) - (modified) llvm/lib/FileCheck/FileCheck.cpp (+1-1) - (modified) llvm/lib/IR/DebugInfo.cpp (+1-1) - (modified) llvm/lib/MC/MCPseudoProbe.cpp (+1-1) - (modified) llvm/lib/Support/VirtualFileSystem.cpp (+1-1) - (modified) llvm/lib/Support/raw_socket_stream.cpp (+1-1) - (modified) llvm/lib/Target/ARM/ARMISelLowering.cpp (+1-1) - (modified) llvm/lib/Target/RISCV/RISCVMachineFunctionInfo.h (+1-1) - (modified) llvm/lib/TargetParser/RISCVISAInfo.cpp (+1-1) - (modified) llvm/lib/TextAPI/Utils.cpp (+1-1) - (modified) llvm/lib/Transforms/IPO/Attributor.cpp (+2-2) - (modified) llvm/lib/Transforms/IPO/SampleProfileProbe.cpp (+1-1) - (modified) llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp (+1-1) - (modified) llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp (+1-1) - (modified) llvm/test/CodeGen/X86/AMX/amx-greedy-ra.ll (+1-1) - (modified) llvm/test/CodeGen/X86/apx/shift-eflags.ll (+12-12) - (modified) llvm/test/CodeGen/X86/merge-consecutive-stores-nt.ll (+2-2) - (modified) llvm/test/CodeGen/X86/shift-eflags.ll (+12-12) - (modified) llvm/test/Transforms/InstSimplify/constant-fold-fp-denormal.ll (+1-1) - (modified) llvm/test/Transforms/LoopVectorize/LoongArch/defaults.ll (+1-1) - (modified) llvm/test/Transforms/LoopVectorize/RISCV/defaults.ll (+1-1) - (modified) llvm/test/Transforms/SeparateConstOffsetFromGEP/split-gep-or-as-add.ll (+1-1) - (modified) llvm/test/Verifier/alloc-size-failedparse.ll (+1-1) - (modified) llvm/test/tools/llvm-ar/windows-path.test (+1-1) - (modified) llvm/test/tools/llvm-objcopy/ELF/mirror-permissions-win.test (+1-1) - (modified) llvm/tools/llvm-cov/CodeCoverage.cpp (+1-1) - (modified) llvm/tools/llvm-profgen/PerfReader.cpp (+1-1) - (modified) llvm/unittests/Support/Path.cpp (+2-2) - (modified) mlir/include/mlir/Analysis/Presburger/IntegerRelation.h (+1-1) - (modified) mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h (+1-1) - (modified) mlir/include/mlir/Dialect/OpenMP/OpenMPInterfaces.h (+1-1) - (modified) mlir/lib/Analysis/Presburger/PresburgerSpace.cpp (+1-1) - (modified) mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h (+1-1) - (modified) mlir/lib/Dialect/LLVMIR/IR/BasicPtxBuilderInterface.cpp (+1-1) - (modified) mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp (+3-3) - (modified) mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_reduce_custom_prod.mlir (+1-1) - (modified) mlir/test/Target/LLVMIR/omptarget-constant-alloca-raise.mlir (+1-1) - (modified) openmp/tools/Modules/FindOpenMPTarget.cmake (+1-1) ``diff diff --git a/clang-tools-extra/clangd/TidyProvider.cpp b/clang-tools-extra/clangd/TidyProvider.cpp index a4121df30d3df..a87238e0c0938 100644 --- a/clang-tools-extra/clangd/TidyProvider.cpp +++ b/clang-tools-extra/clangd/TidyProvider.cpp @@ -195,10 +195,10 @@ TidyProvider addTidyChecks(llvm
[clang] [serialization] no transitive decl change (PR #92083)
ilya-biryukov wrote: The 10x increase in the time spent reading modules does look surprising and I would need to check if it's related to PCMs becoming larger or is localized to that particular compile. (Even if on a single example). @ChuanqiXu9 do you expect alignment to have such a drastic effect on deserialization time? That would be very surprising to me. The reproducer will take time, could we revert in the meantime? https://github.com/llvm/llvm-project/pull/92083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Add winsysroot alias to the GNU driver (PR #95320)
https://github.com/Andarwinux updated https://github.com/llvm/llvm-project/pull/95320 >From e6a16a19794763917ee49db9b9a0d39690068399 Mon Sep 17 00:00:00 2001 From: Andarwinux <144242044+andarwi...@users.noreply.github.com> Date: Fri, 7 Jun 2024 07:07:40 + Subject: [PATCH] [Driver] Add winsysroot alias to the GNU driver fixes #91216 --- clang/include/clang/Driver/Options.td | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index d44faa55c456f..1cce7a5146dd8 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8569,6 +8569,8 @@ def : Separate<["-"], "Xmicrosoft-windows-sdk-root">, Alias<_SLASH_winsdkdir>; def : Separate<["-"], "Xmicrosoft-windows-sdk-version">, Alias<_SLASH_winsdkversion>; +def : Separate<["-"], "Xmicrosoft-windows-sys-root">, +Alias<_SLASH_winsysroot>; // Ignored: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][SME] Save VG for unwind info when changing streaming-mode (PR #83301)
https://github.com/sdesmalen-arm edited https://github.com/llvm/llvm-project/pull/83301 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][SME] Save VG for unwind info when changing streaming-mode (PR #83301)
@@ -2995,7 +3062,9 @@ bool AArch64FrameLowering::spillCalleeSavedRegisters( ArrayRef CSI, const TargetRegisterInfo *TRI) const { MachineFunction &MF = *MBB.getParent(); const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo(); + AArch64FunctionInfo *AFI = MF.getInfo(); bool NeedsWinCFI = needsWinCFI(MF); + bool HasSVE = MF.getSubtarget().hasSVE(); sdesmalen-arm wrote: nit: this only has one use, which seems quite far away from the definition. Perhaps just inline it? https://github.com/llvm/llvm-project/pull/83301 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Offload] Introduce the concept of "default streams" (PR #95371)
https://github.com/jdoerfert created https://github.com/llvm/llvm-project/pull/95371 The offload APIs, and the CUDA wrappers in clang, now support "default streams" per thread (and per device). It should be per context but we don't really expose that concept yet. The KernelArguments allow an LLVM/Offload user to provide a "AsyncInfoQueue", which is plugin dependent and can later also be created outside or queried from the runtime. User managed "queues" are kept persistent, thus not returned to the pool once synchronized. The CUDA tests will synchronize via `cudaDeviceSynchronize` before checking the results. Based on https://github.com/llvm/llvm-project/pull/94821. >From 36618e65d94ffa3e83464b7d19ff6cd7d5855abf Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Wed, 5 Jun 2024 16:51:51 -0700 Subject: [PATCH 1/5] [Offload][NFCI] Initialize the KernelArgsTy to default values --- offload/include/Shared/APITypes.h | 30 +- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/offload/include/Shared/APITypes.h b/offload/include/Shared/APITypes.h index e8fc27785b6c2..fd315c6b992b9 100644 --- a/offload/include/Shared/APITypes.h +++ b/offload/include/Shared/APITypes.h @@ -89,22 +89,26 @@ struct __tgt_async_info { /// This struct contains all of the arguments to a target kernel region launch. struct KernelArgsTy { - uint32_t Version; // Version of this struct for ABI compatibility. - uint32_t NumArgs; // Number of arguments in each input pointer. - void **ArgBasePtrs; // Base pointer of each argument (e.g. a struct). - void **ArgPtrs; // Pointer to the argument data. - int64_t *ArgSizes; // Size of the argument data in bytes. - int64_t *ArgTypes; // Type of the data (e.g. to / from). - void **ArgNames;// Name of the data for debugging, possibly null. - void **ArgMappers; // User-defined mappers, possibly null. - uint64_t Tripcount; // Tripcount for the teams / distribute loop, 0 otherwise. + uint32_t Version = 0; // Version of this struct for ABI compatibility. + uint32_t NumArgs = 0; // Number of arguments in each input pointer. + void **ArgBasePtrs = + nullptr; // Base pointer of each argument (e.g. a struct). + void **ArgPtrs = nullptr;// Pointer to the argument data. + int64_t *ArgSizes = nullptr; // Size of the argument data in bytes. + int64_t *ArgTypes = nullptr; // Type of the data (e.g. to / from). + void **ArgNames = nullptr; // Name of the data for debugging, possibly null. + void **ArgMappers = nullptr; // User-defined mappers, possibly null. + uint64_t Tripcount = + 0; // Tripcount for the teams / distribute loop, 0 otherwise. struct { uint64_t NoWait : 1; // Was this kernel spawned with a `nowait` clause. uint64_t Unused : 63; - } Flags; - uint32_t NumTeams[3];// The number of teams (for x,y,z dimension). - uint32_t ThreadLimit[3]; // The number of threads (for x,y,z dimension). - uint32_t DynCGroupMem; // Amount of dynamic cgroup memory requested. + } Flags = {0, 0}; + uint32_t NumTeams[3] = {0, 0, + 0}; // The number of teams (for x,y,z dimension). + uint32_t ThreadLimit[3] = {0, 0, + 0}; // The number of threads (for x,y,z dimension). + uint32_t DynCGroupMem = 0; // Amount of dynamic cgroup memory requested. }; static_assert(sizeof(KernelArgsTy().Flags) == sizeof(uint64_t), "Invalid struct size"); >From 3d5c61a78e91ecb379a2bfac71988eaf8e5cd9cd Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Mon, 3 Jun 2024 19:52:12 -0700 Subject: [PATCH 2/5] [Offload][CUDA] Allow CUDA kernels to use LLVM/Offload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Through the new `-foffload-via-llvm` flag, CUDA kernels can now be lowered to the LLVM/Offload API. On the Clang side, this is simply done by using the OpenMP offload toolchain and emitting calls to `llvm*` functions to orchestrate the kernel launch rather than `cuda*` functions. These `llvm*` functions are implemented on top of the existing LLVM/Offload API. As we are about to redefine the Offload API, this wil help us in the design process as a second offload language. We do not support any CUDA APIs yet, however, we could: https://www.osti.gov/servlets/purl/1892137 For proper host execution we need to resurrect/rebase https://tianshilei.me/wp-content/uploads/2021/12/llpp-2021.pdf (which was designed for debugging). ``` ❯❯❯ cat test.cu extern "C" { void *llvm_omp_target_alloc_shared(size_t Size, int DeviceNum); void llvm_omp_target_free_shared(void *DevicePtr, int DeviceNum); } __global__ void square(int *A) { *A = 42; } int main(int argc, char **argv) { int DevNo = 0; int *Ptr = reinterpret_cast(llvm_omp_target_alloc_shared(4, DevNo)); *Ptr = 7; printf("Ptr %p, *Ptr %i\n", Ptr, *Ptr); square<<<1, 1>>>(Ptr); printf("Ptr %p, *Ptr %i\n", Ptr, *Ptr); llvm_omp_targ
[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)
@@ -484,10 +484,31 @@ MC/DC Instrumentation - When instrumenting for Modified Condition/Decision Coverage (MC/DC) using the -clang option ``-fcoverage-mcdc``, users are limited to at most **six** leaf-level -conditions in a boolean expression. A warning will be generated for boolean -expressions that contain more than six, and they will not be instrumented for -MC/DC. +clang option ``-fcoverage-mcdc``, there are two hard limits. + +The maximum number of terms is limited to 32767, which is practical for +handwritten expressions. To be more restrictive in order to enforce coding rules, +use ``-Xclang -fmcdc-max-conditions=n``. Expressions with exceeded condition +counts ``n`` will generate warnings. chapuni wrote: Done. https://github.com/llvm/llvm-project/pull/82448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 8b435c1 - ASTTests: Suppress a warning in -Asserts for #95202 [-Wunused-variable]
Author: NAKAMURA Takumi Date: 2024-06-13T17:34:39+09:00 New Revision: 8b435c18314e62530367a8721883a28c532e02ad URL: https://github.com/llvm/llvm-project/commit/8b435c18314e62530367a8721883a28c532e02ad DIFF: https://github.com/llvm/llvm-project/commit/8b435c18314e62530367a8721883a28c532e02ad.diff LOG: ASTTests: Suppress a warning in -Asserts for #95202 [-Wunused-variable] Added: Modified: clang/unittests/AST/ProfilingTest.cpp Removed: diff --git a/clang/unittests/AST/ProfilingTest.cpp b/clang/unittests/AST/ProfilingTest.cpp index ed81f4e1c5f2f..27a4a197f1cbf 100644 --- a/clang/unittests/AST/ProfilingTest.cpp +++ b/clang/unittests/AST/ProfilingTest.cpp @@ -34,8 +34,10 @@ static auto getClassTemplateRedecls() { Res.push_back(CTD); } assert(Res.size() == 3); +#ifndef NDEBUG for (auto &&I : Res) assert(I->getCanonicalDecl() == Res[0]); +#endif return std::make_tuple(std::move(AST), Res[1], Res[2]); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Offload][CUDA] Allow CUDA kernels to use LLVM/Offload (PR #94549)
https://github.com/jdoerfert updated https://github.com/llvm/llvm-project/pull/94549 >From d06585044bd6d2dd76d6110bce933e01fd4b333e Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Mon, 3 Jun 2024 19:52:12 -0700 Subject: [PATCH] [Offload][CUDA] Allow CUDA kernels to use LLVM/Offload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Through the new `-foffload-via-llvm` flag, CUDA kernels can now be lowered to the LLVM/Offload API. On the Clang side, this is simply done by using the OpenMP offload toolchain and emitting calls to `llvm*` functions to orchestrate the kernel launch rather than `cuda*` functions. These `llvm*` functions are implemented on top of the existing LLVM/Offload API. As we are about to redefine the Offload API, this wil help us in the design process as a second offload language. We do not support any CUDA APIs yet, however, we could: https://www.osti.gov/servlets/purl/1892137 For proper host execution we need to resurrect/rebase https://tianshilei.me/wp-content/uploads/2021/12/llpp-2021.pdf (which was designed for debugging). ``` ❯❯❯ cat test.cu extern "C" { void *llvm_omp_target_alloc_shared(size_t Size, int DeviceNum); void llvm_omp_target_free_shared(void *DevicePtr, int DeviceNum); } __global__ void square(int *A) { *A = 42; } int main(int argc, char **argv) { int DevNo = 0; int *Ptr = reinterpret_cast(llvm_omp_target_alloc_shared(4, DevNo)); *Ptr = 7; printf("Ptr %p, *Ptr %i\n", Ptr, *Ptr); square<<<1, 1>>>(Ptr); printf("Ptr %p, *Ptr %i\n", Ptr, *Ptr); llvm_omp_target_free_shared(Ptr, DevNo); } ❯❯❯ clang++ test.cu -O3 -o test123 -foffload-via-llvm --offload-arch=native ❯❯❯ llvm-objdump --offloading test123 test123:file format elf64-x86-64 OFFLOADING IMAGE [0]: kindelf archgfx90a triple amdgcn-amd-amdhsa produceropenmp ❯❯❯ LIBOMPTARGET_INFO=16 ./test123 Ptr 0x155448ac8000, *Ptr 7 Ptr 0x155448ac8000, *Ptr 42 ``` --- clang/include/clang/Basic/LangOptions.def | 1 + clang/include/clang/Driver/Options.td | 6 ++ clang/lib/CodeGen/CGCUDANV.cpp| 97 --- clang/lib/Driver/Driver.cpp | 19 ++-- clang/lib/Driver/ToolChains/Clang.cpp | 27 +- clang/lib/Driver/ToolChains/CommonArgs.cpp| 7 +- clang/lib/Driver/ToolChains/Cuda.cpp | 27 +++--- clang/lib/Headers/CMakeLists.txt | 18 +++- .../llvm_offload_wrappers/__llvm_offload.h| 31 ++ .../__llvm_offload_device.h | 10 ++ .../__llvm_offload_host.h | 15 +++ .../__clang_openmp_device_functions.h | 9 +- clang/lib/Sema/SemaCUDA.cpp | 3 + clang/test/CodeGenCUDA/offload_via_llvm.cu| 97 +++ clang/test/Driver/cuda-via-liboffload.cu | 23 + offload/include/Shared/APITypes.h | 5 +- offload/include/omptarget.h | 2 +- .../common/src/PluginInterface.cpp| 13 ++- offload/src/CMakeLists.txt| 1 + offload/src/KernelLanguage/API.cpp| 76 +++ offload/src/exports | 3 + offload/test/lit.cfg | 2 +- offload/test/offloading/CUDA/basic_launch.cu | 31 ++ .../CUDA/basic_launch_blocks_and_threads.cu | 32 ++ .../offloading/CUDA/basic_launch_multi_arg.cu | 41 offload/test/offloading/CUDA/kernel_tu.cu.inc | 1 + offload/test/offloading/CUDA/launch_tu.cu | 32 ++ 27 files changed, 576 insertions(+), 53 deletions(-) create mode 100644 clang/lib/Headers/llvm_offload_wrappers/__llvm_offload.h create mode 100644 clang/lib/Headers/llvm_offload_wrappers/__llvm_offload_device.h create mode 100644 clang/lib/Headers/llvm_offload_wrappers/__llvm_offload_host.h create mode 100644 clang/test/CodeGenCUDA/offload_via_llvm.cu create mode 100644 clang/test/Driver/cuda-via-liboffload.cu create mode 100644 offload/src/KernelLanguage/API.cpp create mode 100644 offload/test/offloading/CUDA/basic_launch.cu create mode 100644 offload/test/offloading/CUDA/basic_launch_blocks_and_threads.cu create mode 100644 offload/test/offloading/CUDA/basic_launch_multi_arg.cu create mode 100644 offload/test/offloading/CUDA/kernel_tu.cu.inc create mode 100644 offload/test/offloading/CUDA/launch_tu.cu diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 2dea3cd4d795b..e8d3be7e89dbb 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -288,6 +288,7 @@ LANGOPT(GPUMaxThreadsPerBlock, 32, 1024, "default max threads per block for kern LANGOPT(GPUDeferDiag, 1, 0, "defer host/device related diagnostic messages for CUDA/HIP") LANGOPT(GPUExcludeWrongSideOverloads, 1, 0, "always exclude wrong side overloads in overloading resolution for CUDA/HIP") LANGOPT(OffloadingNewDriver, 1, 0, "use the
[clang] [Clang] Fix handling of brace ellison when building deduction guides (PR #94889)
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/94889 >From 217c00f47aaa65b113d1c1cfd93a9c4e1d235c1a Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Sun, 9 Jun 2024 11:49:18 +0800 Subject: [PATCH 1/8] [Clang] Fix two issues of CTAD for aggregates --- clang/lib/Sema/SemaInit.cpp | 56 +++-- clang/test/SemaTemplate/deduction-guide.cpp | 19 +++ 2 files changed, 60 insertions(+), 15 deletions(-) diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 79bdc8e9f8783..de2ea639bbba8 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -313,6 +313,8 @@ class InitListChecker { InitListExpr *FullyStructuredList = nullptr; NoInitExpr *DummyExpr = nullptr; SmallVectorImpl *AggrDeductionCandidateParamTypes = nullptr; + SmallVectorImpl + *AggrDeductionCandidateParamTypesWithoutBraceElision = nullptr; NoInitExpr *getDummyInit() { if (!DummyExpr) @@ -506,14 +508,19 @@ class InitListChecker { Sema &S, const InitializedEntity &Entity, InitListExpr *IL, QualType &T, bool VerifyOnly, bool TreatUnavailableAsInvalid, bool InOverloadResolution = false, - SmallVectorImpl *AggrDeductionCandidateParamTypes = nullptr); + SmallVectorImpl *AggrDeductionCandidateParamTypes = nullptr, + SmallVectorImpl + *AggrDeductionCandidateParamTypesWithoutBraceElision = nullptr); InitListChecker(Sema &S, const InitializedEntity &Entity, InitListExpr *IL, QualType &T, - SmallVectorImpl &AggrDeductionCandidateParamTypes) + SmallVectorImpl &AggrDeductionCandidateParamTypes, + SmallVectorImpl + &AggrDeductionCandidateParamTypesWithoutBraceElision) : InitListChecker(S, Entity, IL, T, /*VerifyOnly=*/true, /*TreatUnavailableAsInvalid=*/false, /*InOverloadResolution=*/false, -&AggrDeductionCandidateParamTypes){}; +&AggrDeductionCandidateParamTypes, +&AggrDeductionCandidateParamTypesWithoutBraceElision) {} bool HadError() { return hadError; } @@ -982,11 +989,15 @@ static bool hasAnyDesignatedInits(const InitListExpr *IL) { InitListChecker::InitListChecker( Sema &S, const InitializedEntity &Entity, InitListExpr *IL, QualType &T, bool VerifyOnly, bool TreatUnavailableAsInvalid, bool InOverloadResolution, -SmallVectorImpl *AggrDeductionCandidateParamTypes) +SmallVectorImpl *AggrDeductionCandidateParamTypes, +SmallVectorImpl +*AggrDeductionCandidateParamTypesWithoutBraceElision) : SemaRef(S), VerifyOnly(VerifyOnly), TreatUnavailableAsInvalid(TreatUnavailableAsInvalid), InOverloadResolution(InOverloadResolution), - AggrDeductionCandidateParamTypes(AggrDeductionCandidateParamTypes) { + AggrDeductionCandidateParamTypes(AggrDeductionCandidateParamTypes), + AggrDeductionCandidateParamTypesWithoutBraceElision( + AggrDeductionCandidateParamTypesWithoutBraceElision) { if (!VerifyOnly || hasAnyDesignatedInits(IL)) { FullyStructuredList = createInitListExpr(T, IL->getSourceRange(), IL->getNumInits()); @@ -1448,13 +1459,17 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity, // brace elision is not considered for any aggregate element that has a // dependent non-array type or an array type with a value-dependent // bound - assert(AggrDeductionCandidateParamTypes); - if (!isa_and_nonnull( + assert(AggrDeductionCandidateParamTypes && + AggrDeductionCandidateParamTypesWithoutBraceElision); + if (!isa_and_present( SemaRef.Context.getAsArrayType(ElemType))) { ++Index; AggrDeductionCandidateParamTypes->push_back(ElemType); return; } + // For array types with known bounds, we still want the brace version even + // though the braces can be elided. + AggrDeductionCandidateParamTypesWithoutBraceElision->push_back(ElemType); } else { InitializationSequence Seq(SemaRef, TmpEntity, Kind, expr, /*TopLevelOfInitList*/ true); @@ -10918,22 +10933,24 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer( if (!(RD->getDefinition() && RD->isAggregate())) return; QualType Ty = Context.getRecordType(RD); - SmallVector ElementTypes; - - InitListChecker CheckInitList(*this, Entity, ListInit, Ty, ElementTypes); - if (!CheckInitList.HadError()) { + auto BuildAggregateDeductionGuide = [&](MutableArrayRef + ElementTypes, + bool BracedVersion = false) { +if (ElementTypes.empty()) + return; // C++ [over.match.class.deduct]p1.8:
[clang] [llvm] [Offload] Introduce the concept of "default streams" (PR #95371)
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 7adb7aa494247f2492f6207289ad90cb48807517 705de43498aec79565d6469a00a54e65e988faf8 -- clang/lib/Headers/llvm_offload_wrappers/__llvm_offload.h clang/lib/Headers/llvm_offload_wrappers/__llvm_offload_device.h clang/lib/Headers/llvm_offload_wrappers/__llvm_offload_host.h clang/lib/Headers/llvm_offload_wrappers/cuda_runtime.h offload/src/KernelLanguage/API.cpp offload/test/offloading/CUDA/kernel_tu.cu.inc clang/lib/CodeGen/CGCUDANV.cpp clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/Cuda.cpp clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h clang/lib/Sema/SemaCUDA.cpp llvm/include/llvm/Frontend/OpenMP/OMPConstants.h llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp offload/include/Shared/APITypes.h offload/include/omptarget.h offload/plugins-nextgen/amdgpu/src/rtl.cpp offload/plugins-nextgen/common/src/PluginInterface.cpp offload/plugins-nextgen/cuda/src/rtl.cpp offload/src/interface.cpp offload/src/omptarget.cpp `` View the diff from clang-format here. ``diff diff --git a/offload/plugins-nextgen/common/src/PluginInterface.cpp b/offload/plugins-nextgen/common/src/PluginInterface.cpp index ff0f6edfcd..009932ead4 100644 --- a/offload/plugins-nextgen/common/src/PluginInterface.cpp +++ b/offload/plugins-nextgen/common/src/PluginInterface.cpp @@ -553,7 +553,8 @@ Error GenericKernelTy::launch(GenericDeviceTy &GenericDevice, void **ArgPtrs, // Kernel languages don't use indirection. if (KernelArgs.Flags.IsCUDA) { -LaunchParams = *reinterpret_cast(KernelArgs.ArgPtrs); +LaunchParams = +*reinterpret_cast(KernelArgs.ArgPtrs); } else { LaunchParams = prepareArgs(GenericDevice, ArgPtrs, ArgOffsets, KernelArgs.NumArgs, diff --git a/offload/src/KernelLanguage/API.cpp b/offload/src/KernelLanguage/API.cpp index 779751deed..b8b1dbb3d6 100644 --- a/offload/src/KernelLanguage/API.cpp +++ b/offload/src/KernelLanguage/API.cpp @@ -47,7 +47,7 @@ unsigned __llvmPushCallConfiguration(dim3 __grid_size, dim3 __block_size, unsigned __llvmPopCallConfiguration(dim3 *__grid_size, dim3 *__block_size, size_t *__shared_memory, void *__stream) { - __omp_kernel_t &__kernel = __current_kernel; + __omp_kernel_t &__kernel = __current_kernel; *__grid_size = __kernel.__grid_size; *__block_size = __kernel.__block_size; *__shared_memory = __kernel.__shared_memory; `` https://github.com/llvm/llvm-project/pull/95371 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Offload] Introduce the concept of "default streams" (PR #95371)
https://github.com/jdoerfert updated https://github.com/llvm/llvm-project/pull/95371 >From d06585044bd6d2dd76d6110bce933e01fd4b333e Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Mon, 3 Jun 2024 19:52:12 -0700 Subject: [PATCH 1/3] [Offload][CUDA] Allow CUDA kernels to use LLVM/Offload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Through the new `-foffload-via-llvm` flag, CUDA kernels can now be lowered to the LLVM/Offload API. On the Clang side, this is simply done by using the OpenMP offload toolchain and emitting calls to `llvm*` functions to orchestrate the kernel launch rather than `cuda*` functions. These `llvm*` functions are implemented on top of the existing LLVM/Offload API. As we are about to redefine the Offload API, this wil help us in the design process as a second offload language. We do not support any CUDA APIs yet, however, we could: https://www.osti.gov/servlets/purl/1892137 For proper host execution we need to resurrect/rebase https://tianshilei.me/wp-content/uploads/2021/12/llpp-2021.pdf (which was designed for debugging). ``` ❯❯❯ cat test.cu extern "C" { void *llvm_omp_target_alloc_shared(size_t Size, int DeviceNum); void llvm_omp_target_free_shared(void *DevicePtr, int DeviceNum); } __global__ void square(int *A) { *A = 42; } int main(int argc, char **argv) { int DevNo = 0; int *Ptr = reinterpret_cast(llvm_omp_target_alloc_shared(4, DevNo)); *Ptr = 7; printf("Ptr %p, *Ptr %i\n", Ptr, *Ptr); square<<<1, 1>>>(Ptr); printf("Ptr %p, *Ptr %i\n", Ptr, *Ptr); llvm_omp_target_free_shared(Ptr, DevNo); } ❯❯❯ clang++ test.cu -O3 -o test123 -foffload-via-llvm --offload-arch=native ❯❯❯ llvm-objdump --offloading test123 test123:file format elf64-x86-64 OFFLOADING IMAGE [0]: kindelf archgfx90a triple amdgcn-amd-amdhsa produceropenmp ❯❯❯ LIBOMPTARGET_INFO=16 ./test123 Ptr 0x155448ac8000, *Ptr 7 Ptr 0x155448ac8000, *Ptr 42 ``` --- clang/include/clang/Basic/LangOptions.def | 1 + clang/include/clang/Driver/Options.td | 6 ++ clang/lib/CodeGen/CGCUDANV.cpp| 97 --- clang/lib/Driver/Driver.cpp | 19 ++-- clang/lib/Driver/ToolChains/Clang.cpp | 27 +- clang/lib/Driver/ToolChains/CommonArgs.cpp| 7 +- clang/lib/Driver/ToolChains/Cuda.cpp | 27 +++--- clang/lib/Headers/CMakeLists.txt | 18 +++- .../llvm_offload_wrappers/__llvm_offload.h| 31 ++ .../__llvm_offload_device.h | 10 ++ .../__llvm_offload_host.h | 15 +++ .../__clang_openmp_device_functions.h | 9 +- clang/lib/Sema/SemaCUDA.cpp | 3 + clang/test/CodeGenCUDA/offload_via_llvm.cu| 97 +++ clang/test/Driver/cuda-via-liboffload.cu | 23 + offload/include/Shared/APITypes.h | 5 +- offload/include/omptarget.h | 2 +- .../common/src/PluginInterface.cpp| 13 ++- offload/src/CMakeLists.txt| 1 + offload/src/KernelLanguage/API.cpp| 76 +++ offload/src/exports | 3 + offload/test/lit.cfg | 2 +- offload/test/offloading/CUDA/basic_launch.cu | 31 ++ .../CUDA/basic_launch_blocks_and_threads.cu | 32 ++ .../offloading/CUDA/basic_launch_multi_arg.cu | 41 offload/test/offloading/CUDA/kernel_tu.cu.inc | 1 + offload/test/offloading/CUDA/launch_tu.cu | 32 ++ 27 files changed, 576 insertions(+), 53 deletions(-) create mode 100644 clang/lib/Headers/llvm_offload_wrappers/__llvm_offload.h create mode 100644 clang/lib/Headers/llvm_offload_wrappers/__llvm_offload_device.h create mode 100644 clang/lib/Headers/llvm_offload_wrappers/__llvm_offload_host.h create mode 100644 clang/test/CodeGenCUDA/offload_via_llvm.cu create mode 100644 clang/test/Driver/cuda-via-liboffload.cu create mode 100644 offload/src/KernelLanguage/API.cpp create mode 100644 offload/test/offloading/CUDA/basic_launch.cu create mode 100644 offload/test/offloading/CUDA/basic_launch_blocks_and_threads.cu create mode 100644 offload/test/offloading/CUDA/basic_launch_multi_arg.cu create mode 100644 offload/test/offloading/CUDA/kernel_tu.cu.inc create mode 100644 offload/test/offloading/CUDA/launch_tu.cu diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 2dea3cd4d795b..e8d3be7e89dbb 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -288,6 +288,7 @@ LANGOPT(GPUMaxThreadsPerBlock, 32, 1024, "default max threads per block for kern LANGOPT(GPUDeferDiag, 1, 0, "defer host/device related diagnostic messages for CUDA/HIP") LANGOPT(GPUExcludeWrongSideOverloads, 1, 0, "always exclude wrong side overloads in overloading resolution for CUDA/HIP") LANGOPT(OffloadingNewDriver, 1, 0, "use
[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [lld] [lldb] [llvm] [mlir] [openmp] [llvm-project] Fix typo "seperate" (PR #95373)
https://github.com/jayfoad created https://github.com/llvm/llvm-project/pull/95373 None >From 6d326a96d2651f8836b29ff1e3edef022f41549e Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Thu, 13 Jun 2024 09:46:48 +0100 Subject: [PATCH] [llvm-project] Fix typo "seperate" --- clang-tools-extra/clangd/TidyProvider.cpp | 10 .../include/clang/Frontend/FrontendOptions.h | 2 +- .../include/clang/InstallAPI/DylibVerifier.h | 2 +- clang/lib/InstallAPI/Visitor.cpp | 2 +- clang/lib/Serialization/ASTWriterStmt.cpp | 2 +- compiler-rt/test/dfsan/custom.cpp | 2 +- .../Linux/ppc64/trivial-tls-pwr10.test| 2 +- .../FlangOmpReport/yaml_summarizer.py | 2 +- flang/lib/Semantics/check-omp-structure.cpp | 10 flang/test/Driver/mllvm_vs_mmlir.f90 | 2 +- libc/src/__support/FPUtil/x86_64/FEnvImpl.h | 2 +- .../stdio/printf_core/float_hex_converter.h | 10 .../str_to_float_comparison_test.cpp | 2 +- lld/test/wasm/data-segments.ll| 2 +- .../lldb/Expression/DWARFExpressionList.h | 2 +- lldb/include/lldb/Target/MemoryTagManager.h | 2 +- .../NativeRegisterContextLinux_arm64.cpp | 2 +- lldb/test/API/CMakeLists.txt | 2 +- .../TestGdbRemoteMemoryTagging.py | 2 +- .../DW_AT_data_bit_offset-DW_OP_stack_value.s | 2 +- llvm/include/llvm/CodeGen/LiveRegUnits.h | 2 +- llvm/include/llvm/CodeGen/MIRFormatter.h | 2 +- llvm/include/llvm/MC/MCAsmInfo.h | 2 +- llvm/include/llvm/Support/raw_socket_stream.h | 2 +- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h | 2 +- .../CodeGen/AssignmentTrackingAnalysis.cpp| 6 ++--- .../SelectionDAG/SelectionDAGBuilder.cpp | 4 ++-- llvm/lib/FileCheck/FileCheck.cpp | 2 +- llvm/lib/IR/DebugInfo.cpp | 2 +- llvm/lib/MC/MCPseudoProbe.cpp | 2 +- llvm/lib/Support/VirtualFileSystem.cpp| 2 +- llvm/lib/Support/raw_socket_stream.cpp| 2 +- llvm/lib/Target/ARM/ARMISelLowering.cpp | 2 +- .../Target/RISCV/RISCVMachineFunctionInfo.h | 2 +- llvm/lib/TargetParser/RISCVISAInfo.cpp| 2 +- llvm/lib/TextAPI/Utils.cpp| 2 +- llvm/lib/Transforms/IPO/Attributor.cpp| 4 ++-- .../lib/Transforms/IPO/SampleProfileProbe.cpp | 2 +- .../Scalar/RewriteStatepointsForGC.cpp| 2 +- .../Transforms/Utils/LoopUnrollRuntime.cpp| 2 +- llvm/test/CodeGen/X86/AMX/amx-greedy-ra.ll| 2 +- llvm/test/CodeGen/X86/apx/shift-eflags.ll | 24 +-- .../X86/merge-consecutive-stores-nt.ll| 4 ++-- llvm/test/CodeGen/X86/shift-eflags.ll | 24 +-- .../InstSimplify/constant-fold-fp-denormal.ll | 2 +- .../LoopVectorize/LoongArch/defaults.ll | 2 +- .../LoopVectorize/RISCV/defaults.ll | 2 +- .../split-gep-or-as-add.ll| 2 +- llvm/test/Verifier/alloc-size-failedparse.ll | 2 +- llvm/test/tools/llvm-ar/windows-path.test | 2 +- .../ELF/mirror-permissions-win.test | 2 +- llvm/tools/llvm-cov/CodeCoverage.cpp | 2 +- llvm/tools/llvm-profgen/PerfReader.cpp| 2 +- llvm/unittests/Support/Path.cpp | 4 ++-- .../Analysis/Presburger/IntegerRelation.h | 2 +- .../Analysis/Presburger/PresburgerSpace.h | 2 +- .../mlir/Dialect/OpenMP/OpenMPInterfaces.h| 2 +- .../Analysis/Presburger/PresburgerSpace.cpp | 2 +- .../lib/Conversion/GPUCommon/GPUOpsLowering.h | 2 +- .../LLVMIR/IR/BasicPtxBuilderInterface.cpp| 2 +- .../OpenMP/OpenMPToLLVMIRTranslation.cpp | 6 ++--- .../CPU/sparse_reduce_custom_prod.mlir| 2 +- .../omptarget-constant-alloca-raise.mlir | 2 +- openmp/tools/Modules/FindOpenMPTarget.cmake | 2 +- 64 files changed, 106 insertions(+), 106 deletions(-) diff --git a/clang-tools-extra/clangd/TidyProvider.cpp b/clang-tools-extra/clangd/TidyProvider.cpp index a4121df30d3df..a87238e0c0938 100644 --- a/clang-tools-extra/clangd/TidyProvider.cpp +++ b/clang-tools-extra/clangd/TidyProvider.cpp @@ -195,10 +195,10 @@ TidyProvider addTidyChecks(llvm::StringRef Checks, } TidyProvider disableUnusableChecks(llvm::ArrayRef ExtraBadChecks) { - constexpr llvm::StringLiteral Seperator(","); + constexpr llvm::StringLiteral Separator(","); static const std::string BadChecks = llvm::join_items( - Seperator, - // We want this list to start with a seperator to + Separator, + // We want this list to start with a separator to // simplify appending in the lambda. So including an // empty string here will force that. "", @@ -227,7 +227,7 @@ TidyProvider disableUnusableChecks(llvm::ArrayRef ExtraBadChecks) { for (const std::string &Str : ExtraBadChecks) { if (Str.empty()) continue; -Size += Seperator.size(); +Size += Separator.size(); if (LLVM_LIKELY(Str.front()
[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [lld] [lldb] [llvm] [mlir] [openmp] [llvm-project] Fix typo "seperate" (PR #95373)
https://github.com/arsenm approved this pull request. https://github.com/llvm/llvm-project/pull/95373 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Clean up macOS version flags (PR #95374)
https://github.com/Xazax-hun created https://github.com/llvm/llvm-project/pull/95374 The -mmacos-version-min flag is preferred over -mmacosx-version-min. This patch makes updates the tests and documentation to make this clear and also adds the missing logic to scan build to handle the new flag. Fixes #86376. From bbb0e31edbe806c480b37dbe58113f77c2c86e1e Mon Sep 17 00:00:00 2001 From: Gabor Horvath Date: Thu, 13 Jun 2024 09:46:05 +0100 Subject: [PATCH] [clang] Clean up macOS version flags The -mmacos-version-min flag is preferred over -mmacosx-version-min. This patch makes updates the tests and documentation to make this clear and also adds the missing logic to scan build to handle the new flag. Fixes #86376. --- clang/docs/CommandGuide/clang.rst | 4 ++-- clang/docs/LanguageExtensions.rst | 4 ++-- clang/include/clang/Driver/ToolChain.h | 2 +- clang/test/Coverage/targets.c | 2 +- clang/test/Driver/arc.c| 2 +- clang/test/Driver/arclite-link.c | 8 clang/test/Driver/darwin-objc-defaults.m | 14 +++--- clang/test/Driver/darwin-stdlib-dont-pass-in-c.c | 2 +- clang/test/Driver/darwin-stdlib.cpp| 6 +++--- clang/test/Driver/darwin-version.c | 10 +- clang/test/Driver/darwin-xarch.c | 4 ++-- clang/test/Driver/fsanitize.c | 6 +++--- ...s-apple-silicon-slice-link-libs-darwin-only.cpp | 4 ++-- clang/test/Driver/sanitizer-ld.c | 4 ++-- clang/test/Driver/stack-protector.c| 14 +++--- clang/test/Index/TestClassForwardDecl.m| 2 +- clang/test/Index/c-index-api-loadTU-test.m | 2 +- clang/test/Index/c-index-getCursor-test.m | 2 +- clang/tools/scan-build/libexec/ccc-analyzer| 1 + 19 files changed, 47 insertions(+), 46 deletions(-) diff --git a/clang/docs/CommandGuide/clang.rst b/clang/docs/CommandGuide/clang.rst index 643365215f875..14400c39e9190 100644 --- a/clang/docs/CommandGuide/clang.rst +++ b/clang/docs/CommandGuide/clang.rst @@ -362,7 +362,7 @@ number of cross compilers, or may only support a native target. Specify the architecture to build for (all platforms). -.. option:: -mmacosx-version-min= +.. option:: -mmacos-version-min= When building for macOS, specify the minimum version supported by your application. @@ -723,7 +723,7 @@ ENVIRONMENT .. envvar:: MACOSX_DEPLOYMENT_TARGET - If :option:`-mmacosx-version-min` is unspecified, the default deployment + If :option:`-mmacos-version-min` is unspecified, the default deployment target is read from this environment variable. This option only affects Darwin targets. diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index 1b5db388301f7..9830b35faae12 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -2064,7 +2064,7 @@ Objective-C @available -- It is possible to use the newest SDK but still build a program that can run on -older versions of macOS and iOS by passing ``-mmacosx-version-min=`` / +older versions of macOS and iOS by passing ``-mmacos-version-min=`` / ``-miphoneos-version-min=``. Before LLVM 5.0, when calling a function that exists only in the OS that's @@ -2085,7 +2085,7 @@ When a method that's introduced in the OS newer than the target OS is called, a void my_fun(NSSomeClass* var) { // If fancyNewMethod was added in e.g. macOS 10.12, but the code is -// built with -mmacosx-version-min=10.11, then this unconditional call +// built with -mmacos-version-min=10.11, then this unconditional call // will emit a -Wunguarded-availability warning: [var fancyNewMethod]; } diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index 9789cfacafd78..1f93bd612e9b0 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -639,7 +639,7 @@ class ToolChain { /// ComputeEffectiveClangTriple - Return the Clang triple to use for this /// target, which may take into account the command line arguments. For - /// example, on Darwin the -mmacosx-version-min= command line argument (which + /// example, on Darwin the -mmacos-version-min= command line argument (which /// sets the deployment target) determines the version in the triple passed to /// Clang. virtual std::string ComputeEffectiveClangTriple( diff --git a/clang/test/Coverage/targets.c b/clang/test/Coverage/targets.c index a0ec2836874a6..15110eadb298e 100644 --- a/clang/test/Coverage/targets.c +++ b/clang/test/Coverage/targets.c @@ -14,4 +14,4 @@ // RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-unknown -emit-llvm -o %t %s // clang 1.0 fails to compile Python 2.6 -// RUN: %clang -target x86_64-apple-darwin9 -###
[clang] [Clang] Fix handling of brace ellison when building deduction guides (PR #94889)
@@ -1449,7 +1449,21 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity, // dependent non-array type or an array type with a value-dependent // bound assert(AggrDeductionCandidateParamTypes); - if (!isa_and_nonnull( + + // In the presence of a braced-init-list within the initializer, we should + // not fall through to the brace-elision logic, even if the brace elision + // is applicable. Given the example, cor3ntin wrote: ```suggestion // In the presence of a braced-init-list within the initializer, we should // not perform brace-elision, even if brace elision would otherwise be applicable. For example, given: ``` https://github.com/llvm/llvm-project/pull/94889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][NFC] Add a test for CWG2685 (PR #95206)
https://github.com/cor3ntin approved this pull request. https://github.com/llvm/llvm-project/pull/95206 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() [Cont.] (PR #95220)
https://github.com/PBHDK updated https://github.com/llvm/llvm-project/pull/95220 From 37292995de0c5aa87408586749795a97468d4725 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Wed, 17 Apr 2024 16:16:35 +0200 Subject: [PATCH 01/12] Enforce SL.con.3: Add check to replace operator[] with at() on std containers --- .../AvoidBoundsErrorsCheck.cpp| 81 +++ .../AvoidBoundsErrorsCheck.h | 32 .../cppcoreguidelines/CMakeLists.txt | 1 + .../CppCoreGuidelinesTidyModule.cpp | 3 + clang-tools-extra/docs/ReleaseNotes.rst | 5 ++ .../cppcoreguidelines/avoid-bounds-errors.rst | 20 + .../docs/clang-tidy/checks/list.rst | 1 + .../cppcoreguidelines/avoid-bounds-errors.cpp | 66 +++ 8 files changed, 209 insertions(+) create mode 100644 clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp create mode 100644 clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.h create mode 100644 clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-bounds-errors.rst create mode 100644 clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-bounds-errors.cpp diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp new file mode 100644 index 0..524c21b5bdb81 --- /dev/null +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp @@ -0,0 +1,81 @@ +//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy --===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "AvoidBoundsErrorsCheck.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Lex/Lexer.h" + +#include +using namespace clang::ast_matchers; + +namespace clang::tidy::cppcoreguidelines { + +bool isApplicable(const QualType &Type) { + const auto TypeStr = Type.getAsString(); + bool Result = false; + // Only check for containers in the std namespace + if (TypeStr.find("std::vector") != std::string::npos) { +Result = true; + } + if (TypeStr.find("std::array") != std::string::npos) { +Result = true; + } + if (TypeStr.find("std::deque") != std::string::npos) { +Result = true; + } + if (TypeStr.find("std::map") != std::string::npos) { +Result = true; + } + if (TypeStr.find("std::unordered_map") != std::string::npos) { +Result = true; + } + if (TypeStr.find("std::flat_map") != std::string::npos) { +Result = true; + } + // TODO Add std::span with C++26 + return Result; +} + +void AvoidBoundsErrorsCheck::registerMatchers(MatchFinder *Finder) { + Finder->addMatcher( + callExpr(callee(cxxMethodDecl(hasName("operator[]")).bind("f"))) + .bind("x"), + this); +} + +void AvoidBoundsErrorsCheck::check(const MatchFinder::MatchResult &Result) { + const ASTContext &Context = *Result.Context; + const SourceManager &Source = Context.getSourceManager(); + const auto *MatchedExpr = Result.Nodes.getNodeAs("x"); + const auto *MatchedFunction = Result.Nodes.getNodeAs("f"); + const auto Type = MatchedFunction->getThisType(); + if (!isApplicable(Type)) { +return; + } + + // Get original code. + const SourceLocation b(MatchedExpr->getBeginLoc()); + const SourceLocation e(MatchedExpr->getEndLoc()); + const std::string OriginalCode = + Lexer::getSourceText(CharSourceRange::getTokenRange(b, e), Source, + getLangOpts()) + .str(); + const auto Range = SourceRange(b, e); + + // Build replacement. + std::string NewCode = OriginalCode; + const auto BeginOpen = NewCode.find("["); + NewCode.replace(BeginOpen, 1, ".at("); + const auto BeginClose = NewCode.find("]"); + NewCode.replace(BeginClose, 1, ")"); + + diag(MatchedExpr->getBeginLoc(), "Do not use operator[], use at() instead.") + << FixItHint::CreateReplacement(Range, NewCode); +} + +} // namespace clang::tidy::cppcoreguidelines diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.h b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.h new file mode 100644 index 0..f915729cd7bbe --- /dev/null +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.h @@ -0,0 +1,32 @@ +//===--- AvoidBoundsErrorsCheck.h - clang-tidy --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLV
[clang] [clang][CodeGen] Fix EmitInvariantStart for non-zero addrspace (PR #94346)
brunodf-snps wrote: Another round of tagging to try to get a review: @efriedma-quic @asl @AaronBallman can you help with reviewing or getting a reviewer? This should really be a trivial patch, so not much work at all. https://github.com/llvm/llvm-project/pull/94346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Reland Add tanf16 builtin and support for tan constrained intrinsic (PR #94559)
davemgreen wrote: Usually when new ISD nodes are added they are expanded for all types, so that every backend will get at least working code even if it is not optimal. The targets can then come along and override the defaults for the types they are interested in, to get better results. For tan I would expect most vector types would want to scalarize, so marking them as expand would make sense. If more types than are necessary get marked as Expand that shouldn't be an issue, it looks like we already do that for a number of other nodes. https://github.com/llvm/llvm-project/pull/94559 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [serialization] no transitive decl change (PR #92083)
ChuanqiXu9 wrote: > The 10x increase in the time spent reading modules does look surprising and I > would need to check if it's related to PCMs becoming larger or is localized > to that particular compile. (Even if on a single example). It should not related to the size of the PCMs otherwise we will see the regression on X86 too. Another point may be, the proportion is not correct, 25% size increase shouldn't introduce such a big change. BTW, I am working on a patch to mitigate the size issue. And for the different size increase number, it should be related to the specific code bases. Generally, the more references to decls, the more increases. > > @ChuanqiXu9 do you expect alignment to have such a drastic effect on > deserialization time? That would be very surprising to me. The reproducer > will take time, could we revert in the meantime? I won't say 'expected'. I just met some performance regression in AArch64 related to alignments. So I am just guessing it is related to alignments. And for this particular issue, besides reproducer, it should be pretty helpful to have some hotspots data. It might not take too long. For reverting, how about giving it a few days to locate the problem? https://github.com/llvm/llvm-project/pull/92083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)
https://github.com/DeinAlptraum created https://github.com/llvm/llvm-project/pull/95381 Do not allow initialization of enum from negative IDs (e.g. from_id(-1) currently produces the last known variant) Rename duplicate enums: CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE and TypeKind.OBJCCLASS Add tests to cover these cases >From 0a81be569d5a8a4ca0945310804106df70962c64 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Thu, 13 Jun 2024 10:43:52 +0100 Subject: [PATCH] [libclang/python] Fix bugs in custom enum implementation and add tests Do not allow initialization of enum from negative IDs (e.g. from_id(-1) currently produces the last known variant) Rename duplicate enums: CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE and TypeKind.OBJCCLASS Add tests to cover these cases --- clang/bindings/python/clang/cindex.py | 8 +-- .../python/tests/cindex/test_enums.py | 55 +++ 2 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 clang/bindings/python/tests/cindex/test_enums.py diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 302d99dccd77b..b3d51e4d2a668 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -649,7 +649,7 @@ def name(self): @classmethod def from_id(cls, id): -if id >= len(cls._kinds) or cls._kinds[id] is None: +if id < 0 or id >= len(cls._kinds) or cls._kinds[id] is None: raise ValueError("Unknown template argument kind %d" % id) return cls._kinds[id] @@ -1336,7 +1336,7 @@ def __repr__(self): CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(271) # OpenMP teams distribute simd directive. -CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(272) +CursorKind.OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE = CursorKind(272) # OpenMP teams distribute parallel for simd directive. CursorKind.OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE = CursorKind(273) @@ -2215,7 +2215,7 @@ def name(self): @staticmethod def from_id(id): -if id >= len(StorageClass._kinds) or not StorageClass._kinds[id]: +if id < 0 or id >= len(StorageClass._kinds) or not StorageClass._kinds[id]: raise ValueError("Unknown storage class %d" % id) return StorageClass._kinds[id] @@ -2395,7 +2395,7 @@ def __repr__(self): TypeKind.OCLRESERVEID = TypeKind(160) TypeKind.OBJCOBJECT = TypeKind(161) -TypeKind.OBJCCLASS = TypeKind(162) +TypeKind.OBJCTYPEPARAM = TypeKind(162) TypeKind.ATTRIBUTED = TypeKind(163) TypeKind.OCLINTELSUBGROUPAVCMCEPAYLOAD = TypeKind(164) diff --git a/clang/bindings/python/tests/cindex/test_enums.py b/clang/bindings/python/tests/cindex/test_enums.py new file mode 100644 index 0..425c4a8274a17 --- /dev/null +++ b/clang/bindings/python/tests/cindex/test_enums.py @@ -0,0 +1,55 @@ +import unittest + +from clang.cindex import ( +CursorKind, +TemplateArgumentKind, +ExceptionSpecificationKind, +AvailabilityKind, +AccessSpecifier, +TypeKind, +RefQualifierKind, +LinkageKind, +TLSKind, +StorageClass, +) + + +def get_all_kinds(enum): +"""Return all CursorKind enumeration instances.""" +return [x for x in enum._kinds if not x is None] + + +class TestCursorKind(unittest.TestCase): +enums = [ +CursorKind, +TemplateArgumentKind, +ExceptionSpecificationKind, +AvailabilityKind, +AccessSpecifier, +TypeKind, +RefQualifierKind, +LinkageKind, +TLSKind, +StorageClass, +] + +def test_from_id(self): +"""Check that kinds can be constructed from valid IDs""" +for enum in self.enums: +self.assertEqual(enum.from_id(2), enum._kinds[2]) +with self.assertRaises(ValueError): +enum.from_id(len(enum._kinds)) +with self.assertRaises(ValueError): +enum.from_id(-1) + +def test_unique_kinds(self): +"""Check that no kind name has been used multiple times""" +for enum in self.enums: +seen_names = set() +for id in range(len(enum._kinds)): +try: +kind_name = enum.from_id(id).name +except ValueError: +continue +self.assertNotIn(kind_name, seen_names) +seen_names.add(id) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/95381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)
DeinAlptraum wrote: @Endilll I separated the fixes for the enum bugs from the strict typing PR, and added tests that cover these cases. I checked that the tests fail before the fixes and succeed now. https://github.com/llvm/llvm-project/pull/95381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix handling of brace ellison when building deduction guides (PR #94889)
@@ -10918,22 +10944,24 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer( if (!(RD->getDefinition() && RD->isAggregate())) return; QualType Ty = Context.getRecordType(RD); - SmallVector ElementTypes; - - InitListChecker CheckInitList(*this, Entity, ListInit, Ty, ElementTypes); - if (!CheckInitList.HadError()) { + auto BuildAggregateDeductionGuide = [&](MutableArrayRef + ElementTypes, + bool BracedVersion = false) { +if (ElementTypes.empty()) + return; // C++ [over.match.class.deduct]p1.8: // if e_i is of array type and x_i is a braced-init-list, T_i is an // rvalue reference to the declared type of e_i and // C++ [over.match.class.deduct]p1.9: -// if e_i is of array type and x_i is a bstring-literal, T_i is an +// if e_i is of array type and x_i is a string-literal, T_i is an // lvalue reference to the const-qualified declared type of e_i and // C++ [over.match.class.deduct]p1.10: // otherwise, T_i is the declared type of e_i -for (int I = 0, E = ListInit->getNumInits(); +for (int I = 0, E = BracedVersion ? ElementTypes.size() + : ListInit->getNumInits(); I < E && !isa(ElementTypes[I]); ++I) if (ElementTypes[I]->isArrayType()) { -if (isa(ListInit->getInit(I))) +if (isa(ListInit->getInit(I))) hokein wrote: It seems the code is diveraging from the standard. over.match.class.deduct#1.8 says > if e_i is of array type and x_i is a braced-init-list, T_i is an rvalue > reference to the declared type of e_i. And with this change, we will run into this code path if x_i is a `desianged-intializer-list`. https://github.com/llvm/llvm-project/pull/94889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)
@@ -2395,7 +2395,7 @@ def __repr__(self): TypeKind.OCLRESERVEID = TypeKind(160) TypeKind.OBJCOBJECT = TypeKind(161) -TypeKind.OBJCCLASS = TypeKind(162) +TypeKind.OBJCTYPEPARAM = TypeKind(162) DeinAlptraum wrote: This was a duplicate with variant 28 (OBJCCLASS). Corrected name taken from https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html https://github.com/llvm/llvm-project/pull/95381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/95381 >From bfc36e30e84c616adb8ff57754a49a5bb66d1dd9 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Thu, 13 Jun 2024 10:43:52 +0100 Subject: [PATCH] [libclang/python] Fix bugs in custom enum implementation and add tests Do not allow initialization of enum from negative IDs (e.g. from_id(-1) currently produces the last known variant) Rename duplicate enums: CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE and TypeKind.OBJCCLASS Add tests to cover these cases --- clang/bindings/python/clang/cindex.py | 8 +-- .../python/tests/cindex/test_enums.py | 50 +++ 2 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 clang/bindings/python/tests/cindex/test_enums.py diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 302d99dccd77b..b3d51e4d2a668 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -649,7 +649,7 @@ def name(self): @classmethod def from_id(cls, id): -if id >= len(cls._kinds) or cls._kinds[id] is None: +if id < 0 or id >= len(cls._kinds) or cls._kinds[id] is None: raise ValueError("Unknown template argument kind %d" % id) return cls._kinds[id] @@ -1336,7 +1336,7 @@ def __repr__(self): CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(271) # OpenMP teams distribute simd directive. -CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(272) +CursorKind.OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE = CursorKind(272) # OpenMP teams distribute parallel for simd directive. CursorKind.OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE = CursorKind(273) @@ -2215,7 +2215,7 @@ def name(self): @staticmethod def from_id(id): -if id >= len(StorageClass._kinds) or not StorageClass._kinds[id]: +if id < 0 or id >= len(StorageClass._kinds) or not StorageClass._kinds[id]: raise ValueError("Unknown storage class %d" % id) return StorageClass._kinds[id] @@ -2395,7 +2395,7 @@ def __repr__(self): TypeKind.OCLRESERVEID = TypeKind(160) TypeKind.OBJCOBJECT = TypeKind(161) -TypeKind.OBJCCLASS = TypeKind(162) +TypeKind.OBJCTYPEPARAM = TypeKind(162) TypeKind.ATTRIBUTED = TypeKind(163) TypeKind.OCLINTELSUBGROUPAVCMCEPAYLOAD = TypeKind(164) diff --git a/clang/bindings/python/tests/cindex/test_enums.py b/clang/bindings/python/tests/cindex/test_enums.py new file mode 100644 index 0..985d71a4fdcfd --- /dev/null +++ b/clang/bindings/python/tests/cindex/test_enums.py @@ -0,0 +1,50 @@ +import unittest + +from clang.cindex import ( +CursorKind, +TemplateArgumentKind, +ExceptionSpecificationKind, +AvailabilityKind, +AccessSpecifier, +TypeKind, +RefQualifierKind, +LinkageKind, +TLSKind, +StorageClass, +) + + +class TestCursorKind(unittest.TestCase): +enums = [ +CursorKind, +TemplateArgumentKind, +ExceptionSpecificationKind, +AvailabilityKind, +AccessSpecifier, +TypeKind, +RefQualifierKind, +LinkageKind, +TLSKind, +StorageClass, +] + +def test_from_id(self): +"""Check that kinds can be constructed from valid IDs""" +for enum in self.enums: +self.assertEqual(enum.from_id(2), enum._kinds[2]) +with self.assertRaises(ValueError): +enum.from_id(len(enum._kinds)) +with self.assertRaises(ValueError): +enum.from_id(-1) + +def test_unique_kinds(self): +"""Check that no kind name has been used multiple times""" +for enum in self.enums: +seen_names = set() +for id in range(len(enum._kinds)): +try: +kind_name = enum.from_id(id).name +except ValueError: +continue +self.assertNotIn(kind_name, seen_names) +seen_names.add(id) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix handling of brace ellison when building deduction guides (PR #94889)
https://github.com/zyn0217 closed https://github.com/llvm/llvm-project/pull/94889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a144bf2 - [Clang] Fix handling of brace ellison when building deduction guides (#94889)
Author: Younan Zhang Date: 2024-06-13T17:47:03+08:00 New Revision: a144bf2b2511b47fc165755817eda17f79ef5476 URL: https://github.com/llvm/llvm-project/commit/a144bf2b2511b47fc165755817eda17f79ef5476 DIFF: https://github.com/llvm/llvm-project/commit/a144bf2b2511b47fc165755817eda17f79ef5476.diff LOG: [Clang] Fix handling of brace ellison when building deduction guides (#94889) Fixes two issues in two ways: 1) The `braced-init-list` consisted of `initializer-list` and `designated-initializer-list`, and thus the designated initializer is subject to [over.match.class.deduct]p1.8, which means the brace elision is also applicable on it for CTAD deduction guides. 2) When forming a deduction guide where the brace elision is applicable, we should also consider the presence of braces within the initializer. For example, given template struct X { T t[2]; U u[3]; }; X x = {{1, 2}, 3, 4, 5}; we should establish such deduction guide AFAIU: `X(T (&&)[2], U, U, U) -> X`. Fixes https://github.com/llvm/llvm-project/issues/64625 Fixes https://github.com/llvm/llvm-project/issues/83368 Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaInit.cpp clang/test/SemaTemplate/deduction-guide.cpp Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 148ff05008552..8c2f737836a9d 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -846,6 +846,7 @@ Bug Fixes to C++ Support - Fix a crash caused by improper use of ``__array_extent``. (#GH80474) - Fixed several bugs in capturing variables within unevaluated contexts. (#GH63845), (#GH67260), (#GH69307), (#GH88081), (#GH89496), (#GH90669) and (#GH91633). +- Fixed handling of brace ellison when building deduction guides. (#GH64625), (#GH83368). Bug Fixes to AST Handling ^ diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 7244f3ef4e829..e805834c0fd38 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -513,7 +513,7 @@ class InitListChecker { : InitListChecker(S, Entity, IL, T, /*VerifyOnly=*/true, /*TreatUnavailableAsInvalid=*/false, /*InOverloadResolution=*/false, -&AggrDeductionCandidateParamTypes){}; +&AggrDeductionCandidateParamTypes) {} bool HadError() { return hadError; } @@ -1443,7 +1443,21 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity, // dependent non-array type or an array type with a value-dependent // bound assert(AggrDeductionCandidateParamTypes); - if (!isa_and_nonnull( + + // In the presence of a braced-init-list within the initializer, we should + // not perform brace-elision, even if brace elision would otherwise be + // applicable. For example, given: + // + // template struct Foo { + // T t[2]; + // }; + // + // Foo t = {{1, 2}}; + // + // we don't want the (T, T) but rather (T [2]) in terms of the initializer + // {{1, 2}}. + if (isa(expr) || + !isa_and_present( SemaRef.Context.getAsArrayType(ElemType))) { ++Index; AggrDeductionCandidateParamTypes->push_back(ElemType); @@ -10940,14 +10954,14 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer( // if e_i is of array type and x_i is a braced-init-list, T_i is an // rvalue reference to the declared type of e_i and // C++ [over.match.class.deduct]p1.9: -// if e_i is of array type and x_i is a bstring-literal, T_i is an +// if e_i is of array type and x_i is a string-literal, T_i is an // lvalue reference to the const-qualified declared type of e_i and // C++ [over.match.class.deduct]p1.10: // otherwise, T_i is the declared type of e_i for (int I = 0, E = ListInit->getNumInits(); I < E && !isa(ElementTypes[I]); ++I) if (ElementTypes[I]->isArrayType()) { -if (isa(ListInit->getInit(I))) +if (isa(ListInit->getInit(I))) ElementTypes[I] = Context.getRValueReferenceType(ElementTypes[I]); else if (isa( ListInit->getInit(I)->IgnoreParenImpCasts())) diff --git a/clang/test/SemaTemplate/deduction-guide.cpp b/clang/test/SemaTemplate/deduction-guide.cpp index 171c5413feaa7..163b36519950f 100644 --- a/clang/test/SemaTemplate/deduction-guide.cpp +++ b/clang/test/SemaTemplate/deduction-guide.cpp @@ -335,3 +335,142 @@ namespace TTP { // CHECK-NEXT: `-TemplateArgument type 'T':'type-parameter-0-0'{{$}} // CHECK-NEXT:`-TemplateTypeParmType {{.+}} 'T' dependent depth 0 index 0{{$}} // CHECK-NEXT: `-TemplateTypeParm {{.+}} 'T'{{$}} + +namespace GH64625 { +
[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Jannick Kremer (DeinAlptraum) Changes Do not allow initialization of enum from negative IDs (e.g. from_id(-1) currently produces the last known variant) Rename duplicate enums: CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE and TypeKind.OBJCCLASS Add tests to cover these cases --- Full diff: https://github.com/llvm/llvm-project/pull/95381.diff 2 Files Affected: - (modified) clang/bindings/python/clang/cindex.py (+4-4) - (added) clang/bindings/python/tests/cindex/test_enums.py (+55) ``diff diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index 302d99dccd77b..b3d51e4d2a668 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -649,7 +649,7 @@ def name(self): @classmethod def from_id(cls, id): -if id >= len(cls._kinds) or cls._kinds[id] is None: +if id < 0 or id >= len(cls._kinds) or cls._kinds[id] is None: raise ValueError("Unknown template argument kind %d" % id) return cls._kinds[id] @@ -1336,7 +1336,7 @@ def __repr__(self): CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(271) # OpenMP teams distribute simd directive. -CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(272) +CursorKind.OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE = CursorKind(272) # OpenMP teams distribute parallel for simd directive. CursorKind.OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE = CursorKind(273) @@ -2215,7 +2215,7 @@ def name(self): @staticmethod def from_id(id): -if id >= len(StorageClass._kinds) or not StorageClass._kinds[id]: +if id < 0 or id >= len(StorageClass._kinds) or not StorageClass._kinds[id]: raise ValueError("Unknown storage class %d" % id) return StorageClass._kinds[id] @@ -2395,7 +2395,7 @@ def __repr__(self): TypeKind.OCLRESERVEID = TypeKind(160) TypeKind.OBJCOBJECT = TypeKind(161) -TypeKind.OBJCCLASS = TypeKind(162) +TypeKind.OBJCTYPEPARAM = TypeKind(162) TypeKind.ATTRIBUTED = TypeKind(163) TypeKind.OCLINTELSUBGROUPAVCMCEPAYLOAD = TypeKind(164) diff --git a/clang/bindings/python/tests/cindex/test_enums.py b/clang/bindings/python/tests/cindex/test_enums.py new file mode 100644 index 0..425c4a8274a17 --- /dev/null +++ b/clang/bindings/python/tests/cindex/test_enums.py @@ -0,0 +1,55 @@ +import unittest + +from clang.cindex import ( +CursorKind, +TemplateArgumentKind, +ExceptionSpecificationKind, +AvailabilityKind, +AccessSpecifier, +TypeKind, +RefQualifierKind, +LinkageKind, +TLSKind, +StorageClass, +) + + +def get_all_kinds(enum): +"""Return all CursorKind enumeration instances.""" +return [x for x in enum._kinds if not x is None] + + +class TestCursorKind(unittest.TestCase): +enums = [ +CursorKind, +TemplateArgumentKind, +ExceptionSpecificationKind, +AvailabilityKind, +AccessSpecifier, +TypeKind, +RefQualifierKind, +LinkageKind, +TLSKind, +StorageClass, +] + +def test_from_id(self): +"""Check that kinds can be constructed from valid IDs""" +for enum in self.enums: +self.assertEqual(enum.from_id(2), enum._kinds[2]) +with self.assertRaises(ValueError): +enum.from_id(len(enum._kinds)) +with self.assertRaises(ValueError): +enum.from_id(-1) + +def test_unique_kinds(self): +"""Check that no kind name has been used multiple times""" +for enum in self.enums: +seen_names = set() +for id in range(len(enum._kinds)): +try: +kind_name = enum.from_id(id).name +except ValueError: +continue +self.assertNotIn(kind_name, seen_names) +seen_names.add(id) `` https://github.com/llvm/llvm-project/pull/95381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [serialization] no transitive decl change (PR #92083)
ilya-biryukov wrote: To clarify: we observe this regression on x86, not on Arm. @alexfh is now trying to profile the compiler to locate what's going wrong and I will try to poke at PCM files and come up with a reproducer. However, the regressions is definitely real and will block our internal releases, preventing testing of further commits that go in (and these things may pile up). Local revert could be an option, but I'm worried that follow up changes will have conflicts (changing DeclID to 64bit seems like it should, at least potentially, have wide-reaching implications). It is also hard to predict how long it would take to get to the bottom of it, we will still prioritize finding the problem and the reproducer if this commit is reverted, but we won't have to worry about the conflicts and such. I do fully acknowledge that it's frustrating when problems are not found during the review or shortly after commits land, and that not having this upstream may make follow up work more difficult (because of the need to have those commits on a branch and rebase/merge more). We try hard to be prompt with out testing, but sometimes things aren't as fast as we'd like. https://github.com/llvm/llvm-project/pull/92083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)
@@ -1,7 +1,8 @@ -// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify -// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type +// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi aapcs-soft -fsyntax-only -verify=sve-type -typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or -mcpu=}} -typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}} +typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'mve'; specify an appropriate -march= or -mcpu=}} Lukacma wrote: The original idea behind this error message was to preserve original behaviour of the code for MVE, as this patch is only changing NEON. I am thinking that rather than changing the error message to add note about m class architecture, I should revert it to its original form. What do you think ? RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type This run line doesn't generate any error message for neon attributes but only for sve attribute, if that's what you are asking about. https://github.com/llvm/llvm-project/pull/95224 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)
https://github.com/hanickadot edited https://github.com/llvm/llvm-project/pull/82448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)
@@ -2122,20 +2135,70 @@ struct CounterCoverageMappingBuilder subtractCounters(ParentCount, TrueCount)); } - void createDecision(const BinaryOperator *E) { + void createOrCancelDecision(const BinaryOperator *E, unsigned Since) { unsigned NumConds = MCDCBuilder.getTotalConditionsAndReset(E); if (NumConds == 0) return; +// Extract [ID, Conds] to construct the graph. +llvm::SmallVector CondIDs(NumConds); +for (const auto &SR : ArrayRef(SourceRegions).slice(Since)) { + if (SR.isMCDCBranch()) { +auto [ID, Conds] = SR.getMCDCBranchParams(); +CondIDs[ID] = Conds; + } +} + +// Construct the graph and calculate `Indices`. +mcdc::TVIdxBuilder Builder(CondIDs); +unsigned NumTVs = Builder.NumTestVectors; +unsigned MaxTVs = CVM.getCodeGenModule().getCodeGenOpts().MCDCMaxTVs; +assert(MaxTVs < mcdc::TVIdxBuilder::HardMaxTVs); hanickadot wrote: should it be `<=` or `<`? I'm asking because `MaxTVs` seems like a count, not id https://github.com/llvm/llvm-project/pull/82448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] tidy (PR #95384)
https://github.com/HerrCai0907 created https://github.com/llvm/llvm-project/pull/95384 - **[MLIR] Translate DIStringType. (#94480)** - **[clangd] Fix crash with null check for Token at Loc (#94528)** - **[flang][Transforms][NFC] Remove boilerplate from vscale range pass (#94598)** - **[PowerPC] modify the frameaddress case, NFC** - **[PowerPC] return correct frame address for frameaddress intrinsic** - **[ARM] Add NEON support for ISD::ABDS/ABDU nodes. (#94504)** - **[CMake][Release] Use the TXZ cpack generator for binaries (#90138)** - **[DebugInfo] Add DW_OP_LLVM_extract_bits (#93990)** - **Add checks before hoisting out in loop pipelining (#90872)** - **[clang][Interp][NFC] Properly assign block pointer Pointee** - **[clang][Interp] Fix refers_to_enclosing_variable_or_capture DREs** - **[SimplifyCFG] Remove bogus UTC line from test (NFC)** - **[SimplifyCFG] Regenerate switch to lookup tests (NFC)** - **[mlir][vector] Add n-d deinterleave lowering (#94237)** - **[ARM] r11 is reserved when using -mframe-chain=aapcs (#86951)** - **[DAG] Always allow folding XOR patterns to ABS pre-legalization (#94601)** - **fix(mlir/**.py): fix comparison to None (#94019)** - **[ARM] Add support for Cortex-R52+ (#94633)** - **[NFC][LoongArch] Update test for #94590** - **[clang][test] Skip interpreter value test on Arm 32 bit** - **[gn build] Port e622996eddfb** - **[Flang] Handle the newly-added "Reserved" FramePointerKind for 1a5239251ead73ee57f4e2f7fc93433ac7cf18b1** - **[clang][SPIR-V] Add support for AMDGCN flavoured SPIRV (#89796)** - **[BOLT][NFC] Infailable fns return void (#92018)** - **[CodeGen][SDAG] Remove CombinedNodes SmallPtrSet (#94609)** - **[clang][Interp] Check ConstantExpr results for initialization** - **[clang][Interp][NFC] Fix a const-correctness warning** - **[clang][Interp] Limit lambda capture lazy visting to actual captures** - **[serialization] no transitive decl change (#92083)** - **[AMDGPU] Fix interaction between WQM and llvm.amdgcn.init.exec (#93680)** - **[Frontend][OpenMP] Sort all the things in OMP.td, NFC (#94653)** - **[flang][OpenMP] Lower `target .. private(..)` to `omp.private` ops (#94195)** - **[libc] Correctly pass the C++ standard to NVPTX internal builds** - **[mlir][linalg] Support lowering unpack with outer_dims_perm (#94477)** - **[mlir] Add reshape propagation patterns for tensor.pad (#94489)** - **[mlir] Fix bugs in expand_shape patterns after semantics changes (#94631)** - **[ARM] Clean up neon_vabd.ll, vaba.ll and vabd.ll tests a bit. NFC** - **[arm64] Add tan intrinsic lowering (#94545)** - **[AArch64] Add addp from shuffles tests. NFC** - **[Clang] Add timeout for GPU detection utilities (#94751)** - **[RISCV] Codegen support for XCVmem extension (#76916)** - **[MachineOutliner] Sort by Benefit to Cost Ratio (#90264)** - **[memprof] Clean up IndexedMemProfReader (NFC) (#94710)** - **[flang] lower SIZE and SIZEOF for assumed-ranks (#94684)** - **[memprof] Use CallStackRadixTreeBuilder in the V3 format (#94708)** - **[mlir][vector] Remove Emulated Sub-directory (#94742)** - **[gn] port 33a6ce18373ff (check-clang obj2yaml dep)** - **[gn] port cb7690af09b95 (ntdll dep)** - **[KnownBits] Remove `hasConflict()` assertions (#94568)** - **[libc++][test][AIX] Only XFAIL atomic tests for before clang 19 (#94646)** - **[AArch64] Add patterns for add(uzp1(x,y), uzp2(x, y)) -> addp.** - **[LV] Add test with dead load and vector pointer.** - **[libc++][regex] Correctly adjust match prefix for zero-length matches. (#94550)** - **Reapply PR/87550 (#94625)** - **[libc++] Undeprecate shared_ptr atomic access APIs (#92920)** - **[Reassociate] shifttest.ll - generate test checks to replace custom grep expression** - **[flang][runtime] add SHAPE runtime interface (#94702)** - **[flang][OpenMP] Add `--openmp-enable-delayed-privatization-staging` flag (#94749)** - **[OpenMP] Fix passing target id features to AMDGPU offloading (#94765)** - **Fixed grammatical error in "enum specifier" error msg #94443 (#94592)** - **[clang] always use resolved arguments for default argument deduction (#94756)** - **Check if LLD is built when checking if lto_supported (#92752)** - **[mlir][vector][NFC] Make function name more meaningful in lit tests. (#94538)** - **[SDISel][Builder] Fix the instantiation of <1 x bfloat|half> (#94591)** - **[RISCV] Fold (vXi8 (trunc (vselect (setltu, X, 256), X, (sext (setgt X, 0) to vmax+vnclipu. (#94720)** - **[RISCV] Add .insn alias for addresses without the leading immediate. (#94698)** - **Revert "Reapply PR/87550 (#94625)"** - **[AArch64] Add patterns for fadd(uzp1(x,y), uzp2(x, y)) -> faddp.** - **[libc++][NFC] Fix typo** - **[CGSCC] Verify that call graph is valid after iteration (#94692)** - **Fix #pragma (packed, n) not emitting the alignment in debug info (#94673)** - **[clang] Add fixit for using declaration with a (qualified) namespace (#94762)** - **[libc] Add baremetal printf (#94078)** - **[PseudoProbe] Make probe discriminator compatible wit
[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)
@@ -2122,20 +2135,70 @@ struct CounterCoverageMappingBuilder subtractCounters(ParentCount, TrueCount)); } - void createDecision(const BinaryOperator *E) { + void createOrCancelDecision(const BinaryOperator *E, unsigned Since) { unsigned NumConds = MCDCBuilder.getTotalConditionsAndReset(E); if (NumConds == 0) return; +// Extract [ID, Conds] to construct the graph. +llvm::SmallVector CondIDs(NumConds); +for (const auto &SR : ArrayRef(SourceRegions).slice(Since)) { + if (SR.isMCDCBranch()) { +auto [ID, Conds] = SR.getMCDCBranchParams(); +CondIDs[ID] = Conds; + } +} + +// Construct the graph and calculate `Indices`. +mcdc::TVIdxBuilder Builder(CondIDs); +unsigned NumTVs = Builder.NumTestVectors; +unsigned MaxTVs = CVM.getCodeGenModule().getCodeGenOpts().MCDCMaxTVs; +assert(MaxTVs < mcdc::TVIdxBuilder::HardMaxTVs); chapuni wrote: `HardMaxTVs(int_max)` is actually the error code. https://github.com/llvm/llvm-project/pull/82448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)
@@ -2122,20 +2135,70 @@ struct CounterCoverageMappingBuilder subtractCounters(ParentCount, TrueCount)); } - void createDecision(const BinaryOperator *E) { + void createOrCancelDecision(const BinaryOperator *E, unsigned Since) { unsigned NumConds = MCDCBuilder.getTotalConditionsAndReset(E); if (NumConds == 0) return; +// Extract [ID, Conds] to construct the graph. +llvm::SmallVector CondIDs(NumConds); +for (const auto &SR : ArrayRef(SourceRegions).slice(Since)) { + if (SR.isMCDCBranch()) { +auto [ID, Conds] = SR.getMCDCBranchParams(); +CondIDs[ID] = Conds; + } +} + +// Construct the graph and calculate `Indices`. +mcdc::TVIdxBuilder Builder(CondIDs); +unsigned NumTVs = Builder.NumTestVectors; +unsigned MaxTVs = CVM.getCodeGenModule().getCodeGenOpts().MCDCMaxTVs; +assert(MaxTVs < mcdc::TVIdxBuilder::HardMaxTVs); hanickadot wrote: Than I would probably make it `!=` https://github.com/llvm/llvm-project/pull/82448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [serialization] no transitive decl change (PR #92083)
alexfh wrote: To clarify a bit more: the host platform Clang runs on is x86-64 in all cases described here by myself, @joanahalili, @asmok-g, @bgra8 and @ilya-biryukov. What may be specific to aarch64 is a set of headers conditionally-included just when compiling for ARM platforms. As @ilya-biryukov mentioned, I'm now gathering profiles from Clang performing the problematic compilation before and after this patch. https://github.com/llvm/llvm-project/pull/92083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() [Cont.] (PR #95220)
https://github.com/PBHDK edited https://github.com/llvm/llvm-project/pull/95220 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 3f9e2e1 - [NFC][clang-tidy] fix typo in readability-else-after-return
Author: Congcong Cai Date: 2024-06-13T18:24:12+08:00 New Revision: 3f9e2e179a52eb50a2bcff148a5f351a4eddcb37 URL: https://github.com/llvm/llvm-project/commit/3f9e2e179a52eb50a2bcff148a5f351a4eddcb37 DIFF: https://github.com/llvm/llvm-project/commit/3f9e2e179a52eb50a2bcff148a5f351a4eddcb37.diff LOG: [NFC][clang-tidy] fix typo in readability-else-after-return Added: Modified: clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp index 2b185e7594add..f68e1f6926b84 100644 --- a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp @@ -231,7 +231,7 @@ static StringRef getControlFlowString(const Stmt &Stmt) { return "break"; if (isa(Stmt)) return "throw"; - llvm_unreachable("Unknown control flow interruptor"); + llvm_unreachable("Unknown control flow interrupter"); } void ElseAfterReturnCheck::check(const MatchFinder::MatchResult &Result) { @@ -247,12 +247,12 @@ void ElseAfterReturnCheck::check(const MatchFinder::MatchResult &Result) { return; bool IsLastInScope = OuterScope->body_back() == If; - StringRef ControlFlowInterruptor = getControlFlowString(*Interrupt); + const StringRef ControlFlowInterrupter = getControlFlowString(*Interrupt); if (!IsLastInScope && containsDeclInScope(Else)) { if (WarnOnUnfixable) { // Warn, but don't attempt an autofix. - diag(ElseLoc, WarningMessage) << ControlFlowInterruptor; + diag(ElseLoc, WarningMessage) << ControlFlowInterrupter; } return; } @@ -264,7 +264,7 @@ void ElseAfterReturnCheck::check(const MatchFinder::MatchResult &Result) { // If the if statement is the last statement of its enclosing statements // scope, we can pull the decl out of the if statement. DiagnosticBuilder Diag = diag(ElseLoc, WarningMessage) - << ControlFlowInterruptor + << ControlFlowInterrupter << SourceRange(ElseLoc); if (checkInitDeclUsageInElse(If) != nullptr) { Diag << tooling::fixit::createReplacement( @@ -288,7 +288,7 @@ void ElseAfterReturnCheck::check(const MatchFinder::MatchResult &Result) { removeElseAndBrackets(Diag, *Result.Context, Else, ElseLoc); } else if (WarnOnUnfixable) { // Warn, but don't attempt an autofix. - diag(ElseLoc, WarningMessage) << ControlFlowInterruptor; + diag(ElseLoc, WarningMessage) << ControlFlowInterrupter; } return; } @@ -300,7 +300,7 @@ void ElseAfterReturnCheck::check(const MatchFinder::MatchResult &Result) { // If the if statement is the last statement of its enclosing statements // scope, we can pull the decl out of the if statement. DiagnosticBuilder Diag = diag(ElseLoc, WarningMessage) - << ControlFlowInterruptor + << ControlFlowInterrupter << SourceRange(ElseLoc); Diag << tooling::fixit::createReplacement( SourceRange(If->getIfLoc()), @@ -312,13 +312,13 @@ void ElseAfterReturnCheck::check(const MatchFinder::MatchResult &Result) { removeElseAndBrackets(Diag, *Result.Context, Else, ElseLoc); } else if (WarnOnUnfixable) { // Warn, but don't attempt an autofix. - diag(ElseLoc, WarningMessage) << ControlFlowInterruptor; + diag(ElseLoc, WarningMessage) << ControlFlowInterrupter; } return; } DiagnosticBuilder Diag = diag(ElseLoc, WarningMessage) - << ControlFlowInterruptor << SourceRange(ElseLoc); + << ControlFlowInterrupter << SourceRange(ElseLoc); removeElseAndBrackets(Diag, *Result.Context, Else, ElseLoc); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)
@@ -2395,7 +2395,7 @@ def __repr__(self): TypeKind.OCLRESERVEID = TypeKind(160) TypeKind.OBJCOBJECT = TypeKind(161) -TypeKind.OBJCCLASS = TypeKind(162) +TypeKind.OBJCTYPEPARAM = TypeKind(162) Endilll wrote: Same as for OpenMP enum. https://github.com/llvm/llvm-project/pull/95381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)
@@ -0,0 +1,50 @@ +import unittest + +from clang.cindex import ( +CursorKind, +TemplateArgumentKind, +ExceptionSpecificationKind, +AvailabilityKind, +AccessSpecifier, +TypeKind, +RefQualifierKind, +LinkageKind, +TLSKind, +StorageClass, +) + + +class TestCursorKind(unittest.TestCase): +enums = [ +CursorKind, +TemplateArgumentKind, +ExceptionSpecificationKind, +AvailabilityKind, +AccessSpecifier, +TypeKind, +RefQualifierKind, +LinkageKind, +TLSKind, +StorageClass, +] + +def test_from_id(self): +"""Check that kinds can be constructed from valid IDs""" +for enum in self.enums: +self.assertEqual(enum.from_id(2), enum._kinds[2]) +with self.assertRaises(ValueError): +enum.from_id(len(enum._kinds)) +with self.assertRaises(ValueError): +enum.from_id(-1) + +def test_unique_kinds(self): +"""Check that no kind name has been used multiple times""" +for enum in self.enums: +seen_names = set() +for id in range(len(enum._kinds)): +try: +kind_name = enum.from_id(id).name +except ValueError: +continue +self.assertNotIn(kind_name, seen_names) +seen_names.add(id) Endilll wrote: I think you can just add them to the set, and then check whether it has the same length as `enum._kinds`. https://github.com/llvm/llvm-project/pull/95381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)
@@ -1336,7 +1336,7 @@ def __repr__(self): CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(271) # OpenMP teams distribute simd directive. -CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(272) +CursorKind.OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE = CursorKind(272) Endilll wrote: LGTM, but worth an entry in release notes under "potentially breaking changes". https://github.com/llvm/llvm-project/pull/95381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Revert "[clang][NFC] Add a test for CWG2685" (PR #95389)
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/95389 I was wrong: The purpose of CWG2685 is to avoid brace elision on string literals and we should be rejecting the case. Reverts llvm/llvm-project#95206 >From 0e8c9bca863137f14aea2cee0e05d4270b33e0e8 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Thu, 13 Jun 2024 18:53:46 +0800 Subject: [PATCH] Revert "[clang][NFC] Add a test for CWG2685 (#95206)" This reverts commit 3475116e2c37a2c8a69658b36c02871c322da008. --- clang/test/CXX/drs/cwg26xx.cpp | 9 - clang/www/cxx_dr_status.html | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/clang/test/CXX/drs/cwg26xx.cpp b/clang/test/CXX/drs/cwg26xx.cpp index fee3ef16850bf..2b17c8101438d 100644 --- a/clang/test/CXX/drs/cwg26xx.cpp +++ b/clang/test/CXX/drs/cwg26xx.cpp @@ -225,15 +225,6 @@ void m() { } #if __cplusplus >= 202302L - -namespace cwg2685 { // cwg2685: 17 -template -struct A { - T ar[4]; -}; -A a = { "foo" }; -} - namespace cwg2687 { // cwg2687: 18 struct S{ void f(int); diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 8c79708f23abd..5e2ab06701703 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -15918,7 +15918,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/2685.html";>2685 C++23 Aggregate CTAD, string, and brace elision -Clang 17 +Unknown https://cplusplus.github.io/CWG/issues/2686.html";>2686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Revert "[clang][NFC] Add a test for CWG2685" (PR #95389)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Younan Zhang (zyn0217) Changes I was wrong: The purpose of CWG2685 is to avoid brace elision on string literals and we should be rejecting the case. Reverts llvm/llvm-project#95206 --- Full diff: https://github.com/llvm/llvm-project/pull/95389.diff 2 Files Affected: - (modified) clang/test/CXX/drs/cwg26xx.cpp (-9) - (modified) clang/www/cxx_dr_status.html (+1-1) ``diff diff --git a/clang/test/CXX/drs/cwg26xx.cpp b/clang/test/CXX/drs/cwg26xx.cpp index fee3ef16850bf..2b17c8101438d 100644 --- a/clang/test/CXX/drs/cwg26xx.cpp +++ b/clang/test/CXX/drs/cwg26xx.cpp @@ -225,15 +225,6 @@ void m() { } #if __cplusplus >= 202302L - -namespace cwg2685 { // cwg2685: 17 -template -struct A { - T ar[4]; -}; -A a = { "foo" }; -} - namespace cwg2687 { // cwg2687: 18 struct S{ void f(int); diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 8c79708f23abd..5e2ab06701703 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -15918,7 +15918,7 @@ C++ defect report implementation status https://cplusplus.github.io/CWG/issues/2685.html";>2685 C++23 Aggregate CTAD, string, and brace elision -Clang 17 +Unknown https://cplusplus.github.io/CWG/issues/2686.html";>2686 `` https://github.com/llvm/llvm-project/pull/95389 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)
Endilll wrote: Aaron is attending WG14 meeting that is happening this week, so you shouldn't expect him until next week. https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add -mlink-builtin-bitcode option to fc1 (PR #94763)
https://github.com/jsjodin updated https://github.com/llvm/llvm-project/pull/94763 >From adfeb69ba312e971cb4eae71f185f38b1cac9b8f Mon Sep 17 00:00:00 2001 From: Jan Leyonberg Date: Wed, 5 Jun 2024 10:56:41 -0400 Subject: [PATCH 1/4] [flang] Add -mlink-builtin-bitcode option to fc1 This patch enables the -mlink-builtin-bitcode flag in fc1 so that bitcode libraries can be linked in. This is needed for OpenMP offloading libraries. --- clang/include/clang/Driver/Options.td | 9 ++- flang/include/flang/Frontend/CodeGenOptions.h | 4 ++ .../include/flang/Frontend/FrontendActions.h | 5 +- flang/lib/Frontend/CompilerInvocation.cpp | 5 ++ flang/lib/Frontend/FrontendActions.cpp| 56 ++ flang/test/Driver/Inputs/bclib.bc | Bin 0 -> 1700 bytes flang/test/Driver/mlink-builtin-bc.f90| 18 ++ 7 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 flang/test/Driver/Inputs/bclib.bc create mode 100644 flang/test/Driver/mlink-builtin-bc.f90 diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index d44faa55c456f..490538ce753e0 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -7028,6 +7028,12 @@ def as_secure_log_file : Separate<["-"], "as-secure-log-file">, } // let Visibility = [CC1Option, CC1AsOption] +let Visibility = [CC1Option, FC1Option] in { +def mlink_builtin_bitcode : Separate<["-"], "mlink-builtin-bitcode">, + HelpText<"Link and internalize needed symbols from the given bitcode file " + "before performing optimizations.">; +} // let Visibility = [CC1Option, FC1Option] + let Visibility = [CC1Option] in { def llvm_verify_each : Flag<["-"], "llvm-verify-each">, @@ -7130,9 +7136,6 @@ defm constructor_aliases : BoolMOption<"constructor-aliases", " emitting complete constructors and destructors as aliases when possible">>; def mlink_bitcode_file : Separate<["-"], "mlink-bitcode-file">, HelpText<"Link the given bitcode file before performing optimizations.">; -def mlink_builtin_bitcode : Separate<["-"], "mlink-builtin-bitcode">, - HelpText<"Link and internalize needed symbols from the given bitcode file " - "before performing optimizations.">; defm link_builtin_bitcode_postopt: BoolMOption<"link-builtin-bitcode-postopt", CodeGenOpts<"LinkBitcodePostopt">, DefaultFalse, PosFlag OffloadObjects; + /// List of filenames passed in using the -mlink-builtin-bitcode. These + /// are bc libraries that should be linked in and internalized; + std::vector BuiltinBCLibs; + /// The directory where temp files are stored if specified by -save-temps std::optional SaveTempsDir; diff --git a/flang/include/flang/Frontend/FrontendActions.h b/flang/include/flang/Frontend/FrontendActions.h index 7823565eb815f..0a9a9c3401d1d 100644 --- a/flang/include/flang/Frontend/FrontendActions.h +++ b/flang/include/flang/Frontend/FrontendActions.h @@ -223,9 +223,12 @@ class CodeGenAction : public FrontendAction { std::unique_ptr llvmCtx; std::unique_ptr llvmModule; - /// Embeds offload objects given with specified with -fembed-offload-object + /// Embeds offload objects specified with -fembed-offload-object void embedOffloadObjects(); + /// Links in BC libraries spefified with -fmlink-builtin-bitcode + void linkBuiltinBCLibs(); + /// Runs pass pipeline to lower HLFIR into FIR void lowerHLFIRToFIR(); diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index f64a939b785ef..f96d72f1ad691 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -347,6 +347,11 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts, if (auto *a = args.getLastArg(clang::driver::options::OPT_save_temps_EQ)) opts.SaveTempsDir = a->getValue(); + // -mlink-builtin-bitcode + for (auto *a : + args.filtered(clang::driver::options::OPT_mlink_builtin_bitcode)) +opts.BuiltinBCLibs.push_back(a->getValue()); + // -mrelocation-model option. if (const llvm::opt::Arg *a = args.getLastArg(clang::driver::options::OPT_mrelocation_model)) { diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp index b1b6391f1439c..c2e6af58ffd79 100644 --- a/flang/lib/Frontend/FrontendActions.cpp +++ b/flang/lib/Frontend/FrontendActions.cpp @@ -43,6 +43,8 @@ #include "mlir/Target/LLVMIR/ModuleTranslation.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticFrontend.h" +#include "clang/Basic/FileManager.h" +#include "clang/Basic/FileSystemOptions.h" #include "clang/Driver/DriverDiagnostic.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" @@ -54,6 +56,7 @@ #include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/Verifier.h" #include "llvm/IRReader/IRReader.h" +#include "llvm/Linker/Linker.h" #include "llvm/Ob
[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)
https://github.com/Endilll commented: `Sema.h` changes look good. https://github.com/llvm/llvm-project/pull/94981 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [MC/DC][Coverage] Loosen the limit of NumConds from 6 (PR #82448)
https://github.com/chapuni closed https://github.com/llvm/llvm-project/pull/82448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [APFloat] Add APFloat support for FP4 data type (PR #95392)
https://github.com/durga4github created https://github.com/llvm/llvm-project/pull/95392 This patch adds APFloat type support for the E2M1 FP4 datatype. The definitions for this format are detailed in section 5.3.3 of the OCP specification, which can be accessed here: https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf >From db104d4e7479c704a153ff8cbad7c8568e3ffaf3 Mon Sep 17 00:00:00 2001 From: Durgadoss R Date: Wed, 12 Jun 2024 23:55:04 +0530 Subject: [PATCH] [APFloat] Add APFloat support for FP4 data type This patch adds APFloat type support for the E2M1 FP4 datatype. The definitions for this format are detailed in section 5.3.3 of the OCP specification, which can be accessed here: https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf Signed-off-by: Durgadoss R --- clang/lib/AST/MicrosoftMangle.cpp | 1 + llvm/include/llvm/ADT/APFloat.h| 8 + llvm/lib/Support/APFloat.cpp | 25 ++- llvm/unittests/ADT/APFloatTest.cpp | 256 - 4 files changed, 286 insertions(+), 4 deletions(-) diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index ffc5d2d4cd8fc..a863ec7a529b9 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -901,6 +901,7 @@ void MicrosoftCXXNameMangler::mangleFloat(llvm::APFloat Number) { case APFloat::S_FloatTF32: case APFloat::S_Float6E3M2FN: case APFloat::S_Float6E2M3FN: + case APFloat::S_Float4E2M1FN: llvm_unreachable("Tried to mangle unexpected APFloat semantics"); } diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h index a9bb6ccb1..c24eae8da3797 100644 --- a/llvm/include/llvm/ADT/APFloat.h +++ b/llvm/include/llvm/ADT/APFloat.h @@ -197,6 +197,10 @@ struct APFloatBase { // types, there are no infinity or NaN values. The format is detailed in // https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf S_Float6E2M3FN, +// 4-bit floating point number with bit layout S1E2M1. Unlike IEEE-754 +// types, there are no infinity or NaN values. The format is detailed in +// https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf +S_Float4E2M1FN, S_x87DoubleExtended, S_MaxSemantics = S_x87DoubleExtended, @@ -219,6 +223,7 @@ struct APFloatBase { static const fltSemantics &FloatTF32() LLVM_READNONE; static const fltSemantics &Float6E3M2FN() LLVM_READNONE; static const fltSemantics &Float6E2M3FN() LLVM_READNONE; + static const fltSemantics &Float4E2M1FN() LLVM_READNONE; static const fltSemantics &x87DoubleExtended() LLVM_READNONE; /// A Pseudo fltsemantic used to construct APFloats that cannot conflict with @@ -639,6 +644,7 @@ class IEEEFloat final : public APFloatBase { APInt convertFloatTF32APFloatToAPInt() const; APInt convertFloat6E3M2FNAPFloatToAPInt() const; APInt convertFloat6E2M3FNAPFloatToAPInt() const; + APInt convertFloat4E2M1FNAPFloatToAPInt() const; void initFromAPInt(const fltSemantics *Sem, const APInt &api); template void initFromIEEEAPInt(const APInt &api); void initFromHalfAPInt(const APInt &api); @@ -656,6 +662,7 @@ class IEEEFloat final : public APFloatBase { void initFromFloatTF32APInt(const APInt &api); void initFromFloat6E3M2FNAPInt(const APInt &api); void initFromFloat6E2M3FNAPInt(const APInt &api); + void initFromFloat4E2M1FNAPInt(const APInt &api); void assign(const IEEEFloat &); void copySignificand(const IEEEFloat &); @@ -1067,6 +1074,7 @@ class APFloat : public APFloatBase { // Below Semantics do not support {NaN or Inf} case APFloat::S_Float6E3M2FN: case APFloat::S_Float6E2M3FN: +case APFloat::S_Float4E2M1FN: return false; } } diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index 1209bf71a287d..fab3052a9c02e 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -69,8 +69,8 @@ enum class fltNonfiniteBehavior { // encodings do not distinguish between signalling and quiet NaN. NanOnly, - // This behavior is present in Float6E3M2FN and Float6E2M3FN types, - // which do not support Inf or NaN values. + // This behavior is present in Float6E3M2FN, Float6E2M3FN and + // Float4E2M1FN types, which do not support Inf or NaN values. FiniteOnly, }; @@ -147,6 +147,8 @@ static constexpr fltSemantics semFloat6E3M2FN = { 4, -2, 3, 6, fltNonfiniteBehavior::FiniteOnly}; static constexpr fltSemantics semFloat6E2M3FN = { 2, 0, 4, 6, fltNonfiniteBehavior::FiniteOnly}; +static constexpr fltSemantics semFloat4E2M1FN = { +2, 0, 2, 4, fltNonfiniteBehavior::FiniteOnly}; static constexpr fltSemantics semX87DoubleExtended = {16383, -16382, 64, 80}; static constexpr fltSemantics semBogus = {0, 0, 0, 0}; @@ -218,6 +220,8 @@ const llvm::fltSemantics &APFloatBase::EnumToSemantics(Semantics S) {
[clang] [llvm] [APFloat] Add APFloat support for FP4 data type (PR #95392)
llvmbot wrote: @llvm/pr-subscribers-llvm-support Author: Durgadoss R (durga4github) Changes This patch adds APFloat type support for the E2M1 FP4 datatype. The definitions for this format are detailed in section 5.3.3 of the OCP specification, which can be accessed here: https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf --- Patch is 20.06 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/95392.diff 4 Files Affected: - (modified) clang/lib/AST/MicrosoftMangle.cpp (+1) - (modified) llvm/include/llvm/ADT/APFloat.h (+8) - (modified) llvm/lib/Support/APFloat.cpp (+23-2) - (modified) llvm/unittests/ADT/APFloatTest.cpp (+254-2) ``diff diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index ffc5d2d4cd8fc..a863ec7a529b9 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -901,6 +901,7 @@ void MicrosoftCXXNameMangler::mangleFloat(llvm::APFloat Number) { case APFloat::S_FloatTF32: case APFloat::S_Float6E3M2FN: case APFloat::S_Float6E2M3FN: + case APFloat::S_Float4E2M1FN: llvm_unreachable("Tried to mangle unexpected APFloat semantics"); } diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h index a9bb6ccb1..c24eae8da3797 100644 --- a/llvm/include/llvm/ADT/APFloat.h +++ b/llvm/include/llvm/ADT/APFloat.h @@ -197,6 +197,10 @@ struct APFloatBase { // types, there are no infinity or NaN values. The format is detailed in // https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf S_Float6E2M3FN, +// 4-bit floating point number with bit layout S1E2M1. Unlike IEEE-754 +// types, there are no infinity or NaN values. The format is detailed in +// https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf +S_Float4E2M1FN, S_x87DoubleExtended, S_MaxSemantics = S_x87DoubleExtended, @@ -219,6 +223,7 @@ struct APFloatBase { static const fltSemantics &FloatTF32() LLVM_READNONE; static const fltSemantics &Float6E3M2FN() LLVM_READNONE; static const fltSemantics &Float6E2M3FN() LLVM_READNONE; + static const fltSemantics &Float4E2M1FN() LLVM_READNONE; static const fltSemantics &x87DoubleExtended() LLVM_READNONE; /// A Pseudo fltsemantic used to construct APFloats that cannot conflict with @@ -639,6 +644,7 @@ class IEEEFloat final : public APFloatBase { APInt convertFloatTF32APFloatToAPInt() const; APInt convertFloat6E3M2FNAPFloatToAPInt() const; APInt convertFloat6E2M3FNAPFloatToAPInt() const; + APInt convertFloat4E2M1FNAPFloatToAPInt() const; void initFromAPInt(const fltSemantics *Sem, const APInt &api); template void initFromIEEEAPInt(const APInt &api); void initFromHalfAPInt(const APInt &api); @@ -656,6 +662,7 @@ class IEEEFloat final : public APFloatBase { void initFromFloatTF32APInt(const APInt &api); void initFromFloat6E3M2FNAPInt(const APInt &api); void initFromFloat6E2M3FNAPInt(const APInt &api); + void initFromFloat4E2M1FNAPInt(const APInt &api); void assign(const IEEEFloat &); void copySignificand(const IEEEFloat &); @@ -1067,6 +1074,7 @@ class APFloat : public APFloatBase { // Below Semantics do not support {NaN or Inf} case APFloat::S_Float6E3M2FN: case APFloat::S_Float6E2M3FN: +case APFloat::S_Float4E2M1FN: return false; } } diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index 1209bf71a287d..fab3052a9c02e 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -69,8 +69,8 @@ enum class fltNonfiniteBehavior { // encodings do not distinguish between signalling and quiet NaN. NanOnly, - // This behavior is present in Float6E3M2FN and Float6E2M3FN types, - // which do not support Inf or NaN values. + // This behavior is present in Float6E3M2FN, Float6E2M3FN and + // Float4E2M1FN types, which do not support Inf or NaN values. FiniteOnly, }; @@ -147,6 +147,8 @@ static constexpr fltSemantics semFloat6E3M2FN = { 4, -2, 3, 6, fltNonfiniteBehavior::FiniteOnly}; static constexpr fltSemantics semFloat6E2M3FN = { 2, 0, 4, 6, fltNonfiniteBehavior::FiniteOnly}; +static constexpr fltSemantics semFloat4E2M1FN = { +2, 0, 2, 4, fltNonfiniteBehavior::FiniteOnly}; static constexpr fltSemantics semX87DoubleExtended = {16383, -16382, 64, 80}; static constexpr fltSemantics semBogus = {0, 0, 0, 0}; @@ -218,6 +220,8 @@ const llvm::fltSemantics &APFloatBase::EnumToSemantics(Semantics S) { return Float6E3M2FN(); case S_Float6E2M3FN: return Float6E2M3FN(); + case S_Float4E2M1FN: +return Float4E2M1FN(); case S_x87DoubleExtended: return x87DoubleExtended(); } @@ -254,6 +258,8 @@ APFloatBase::SemanticsToEnum(const llvm::fltSemantics &Sem) { return S_Float6E3M2FN; else if (&Sem == &llvm::APFloat::Float6E2M3FN()) retu
[clang] [llvm] [APFloat] Add APFloat support for FP4 data type (PR #95392)
llvmbot wrote: @llvm/pr-subscribers-llvm-adt Author: Durgadoss R (durga4github) Changes This patch adds APFloat type support for the E2M1 FP4 datatype. The definitions for this format are detailed in section 5.3.3 of the OCP specification, which can be accessed here: https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf --- Patch is 20.06 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/95392.diff 4 Files Affected: - (modified) clang/lib/AST/MicrosoftMangle.cpp (+1) - (modified) llvm/include/llvm/ADT/APFloat.h (+8) - (modified) llvm/lib/Support/APFloat.cpp (+23-2) - (modified) llvm/unittests/ADT/APFloatTest.cpp (+254-2) ``diff diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index ffc5d2d4cd8fc..a863ec7a529b9 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -901,6 +901,7 @@ void MicrosoftCXXNameMangler::mangleFloat(llvm::APFloat Number) { case APFloat::S_FloatTF32: case APFloat::S_Float6E3M2FN: case APFloat::S_Float6E2M3FN: + case APFloat::S_Float4E2M1FN: llvm_unreachable("Tried to mangle unexpected APFloat semantics"); } diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h index a9bb6ccb1..c24eae8da3797 100644 --- a/llvm/include/llvm/ADT/APFloat.h +++ b/llvm/include/llvm/ADT/APFloat.h @@ -197,6 +197,10 @@ struct APFloatBase { // types, there are no infinity or NaN values. The format is detailed in // https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf S_Float6E2M3FN, +// 4-bit floating point number with bit layout S1E2M1. Unlike IEEE-754 +// types, there are no infinity or NaN values. The format is detailed in +// https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf +S_Float4E2M1FN, S_x87DoubleExtended, S_MaxSemantics = S_x87DoubleExtended, @@ -219,6 +223,7 @@ struct APFloatBase { static const fltSemantics &FloatTF32() LLVM_READNONE; static const fltSemantics &Float6E3M2FN() LLVM_READNONE; static const fltSemantics &Float6E2M3FN() LLVM_READNONE; + static const fltSemantics &Float4E2M1FN() LLVM_READNONE; static const fltSemantics &x87DoubleExtended() LLVM_READNONE; /// A Pseudo fltsemantic used to construct APFloats that cannot conflict with @@ -639,6 +644,7 @@ class IEEEFloat final : public APFloatBase { APInt convertFloatTF32APFloatToAPInt() const; APInt convertFloat6E3M2FNAPFloatToAPInt() const; APInt convertFloat6E2M3FNAPFloatToAPInt() const; + APInt convertFloat4E2M1FNAPFloatToAPInt() const; void initFromAPInt(const fltSemantics *Sem, const APInt &api); template void initFromIEEEAPInt(const APInt &api); void initFromHalfAPInt(const APInt &api); @@ -656,6 +662,7 @@ class IEEEFloat final : public APFloatBase { void initFromFloatTF32APInt(const APInt &api); void initFromFloat6E3M2FNAPInt(const APInt &api); void initFromFloat6E2M3FNAPInt(const APInt &api); + void initFromFloat4E2M1FNAPInt(const APInt &api); void assign(const IEEEFloat &); void copySignificand(const IEEEFloat &); @@ -1067,6 +1074,7 @@ class APFloat : public APFloatBase { // Below Semantics do not support {NaN or Inf} case APFloat::S_Float6E3M2FN: case APFloat::S_Float6E2M3FN: +case APFloat::S_Float4E2M1FN: return false; } } diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index 1209bf71a287d..fab3052a9c02e 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -69,8 +69,8 @@ enum class fltNonfiniteBehavior { // encodings do not distinguish between signalling and quiet NaN. NanOnly, - // This behavior is present in Float6E3M2FN and Float6E2M3FN types, - // which do not support Inf or NaN values. + // This behavior is present in Float6E3M2FN, Float6E2M3FN and + // Float4E2M1FN types, which do not support Inf or NaN values. FiniteOnly, }; @@ -147,6 +147,8 @@ static constexpr fltSemantics semFloat6E3M2FN = { 4, -2, 3, 6, fltNonfiniteBehavior::FiniteOnly}; static constexpr fltSemantics semFloat6E2M3FN = { 2, 0, 4, 6, fltNonfiniteBehavior::FiniteOnly}; +static constexpr fltSemantics semFloat4E2M1FN = { +2, 0, 2, 4, fltNonfiniteBehavior::FiniteOnly}; static constexpr fltSemantics semX87DoubleExtended = {16383, -16382, 64, 80}; static constexpr fltSemantics semBogus = {0, 0, 0, 0}; @@ -218,6 +220,8 @@ const llvm::fltSemantics &APFloatBase::EnumToSemantics(Semantics S) { return Float6E3M2FN(); case S_Float6E2M3FN: return Float6E2M3FN(); + case S_Float4E2M1FN: +return Float4E2M1FN(); case S_x87DoubleExtended: return x87DoubleExtended(); } @@ -254,6 +258,8 @@ APFloatBase::SemanticsToEnum(const llvm::fltSemantics &Sem) { return S_Float6E3M2FN; else if (&Sem == &llvm::APFloat::Float6E2M3FN()) return S
[clang] [llvm] [APFloat] Add APFloat support for FP4 data type (PR #95392)
https://github.com/durga4github edited https://github.com/llvm/llvm-project/pull/95392 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [APFloat] Add APFloat support for FP4 data type (PR #95392)
durga4github wrote: @ThomasRaoux, Could you please help review this change? https://github.com/llvm/llvm-project/pull/95392 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)
@@ -1336,7 +1336,7 @@ def __repr__(self): CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(271) # OpenMP teams distribute simd directive. -CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(272) +CursorKind.OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE = CursorKind(272) DeinAlptraum wrote: This was a duplicate with variant 271. new name taken from https://clang.llvm.org/doxygen/Index_8h_source.html, line 2011 https://github.com/llvm/llvm-project/pull/95381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 4f09ac7 - Fix off-by-one issue found by post-commit review
Author: Aaron Ballman Date: 2024-06-13T07:48:08-04:00 New Revision: 4f09ac7705b3b24492d521a97571404c2e9a1f8e URL: https://github.com/llvm/llvm-project/commit/4f09ac7705b3b24492d521a97571404c2e9a1f8e DIFF: https://github.com/llvm/llvm-project/commit/4f09ac7705b3b24492d521a97571404c2e9a1f8e.diff LOG: Fix off-by-one issue found by post-commit review Added: Modified: clang/lib/Lex/Lexer.cpp clang/test/Lexer/cxx2c-raw-strings.cpp Removed: diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index c7543a48c0b50..e59c7805b3862 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -2262,7 +2262,6 @@ bool Lexer::LexRawStringLiteral(Token &Result, const char *CurPtr, unsigned PrefixLen = 0; while (PrefixLen != 16 && isRawStringDelimBody(CurPtr[PrefixLen])) { -++PrefixLen; if (!isLexingRawMode() && llvm::is_contained({'$', '@', '`'}, CurPtr[PrefixLen])) { const char *Pos = &CurPtr[PrefixLen]; @@ -2271,6 +2270,7 @@ bool Lexer::LexRawStringLiteral(Token &Result, const char *CurPtr, : diag::ext_cxx26_raw_string_literal_character_set) << StringRef(Pos, 1); } +++PrefixLen; } // If the last character was not a '(', then we didn't lex a valid delimiter. diff --git a/clang/test/Lexer/cxx2c-raw-strings.cpp b/clang/test/Lexer/cxx2c-raw-strings.cpp index a1e971434e244..cf114e57d8bb1 100644 --- a/clang/test/Lexer/cxx2c-raw-strings.cpp +++ b/clang/test/Lexer/cxx2c-raw-strings.cpp @@ -21,4 +21,8 @@ int main() { (void) R"\()\"; // expected-error@-1 {{invalid character '\' in raw string delimiter}} // expected-error@-2 {{expected expression}} + + (void) R"@(foo)@"; + // cxx26-warning@-1 {{'@' in a raw string literal delimiter is incompatible with standards before C++2c}} + // precxx26-warning@-2 {{'@' in a raw string literal delimiter is a C++2c extension}} } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] allow `` `@$ `` in raw string delimiters in C++26 (PR #93216)
@@ -2261,8 +2261,17 @@ bool Lexer::LexRawStringLiteral(Token &Result, const char *CurPtr, unsigned PrefixLen = 0; - while (PrefixLen != 16 && isRawStringDelimBody(CurPtr[PrefixLen])) + while (PrefixLen != 16 && isRawStringDelimBody(CurPtr[PrefixLen])) { ++PrefixLen; +if (!isLexingRawMode() && +llvm::is_contained({'$', '@', '`'}, CurPtr[PrefixLen])) { AaronBallman wrote: Good catch, thank you! I've fixed this in 4f09ac7705b3b24492d521a97571404c2e9a1f8e https://github.com/llvm/llvm-project/pull/93216 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Fix bugs in custom enum implementation and add tests (PR #95381)
https://github.com/DeinAlptraum edited https://github.com/llvm/llvm-project/pull/95381 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" (PR #95399)
https://github.com/Endilll created https://github.com/llvm/llvm-project/pull/95399 This patch implements 2024-05-31 resolution of a tentatively ready issue [CWG2877](https://cplusplus.github.io/CWG/issues/2877.html) "Type-only lookup for using-enum-declarator", which supersedes earlier [CWG2621](https://cplusplus.github.io/CWG/issues/2621.html) "Kind of lookup for `using enum` declarations". Now we perform type-only lookup (not to be confused with type-only context) for `elaborated-enum-declarator`. I also found out that one of our existing tests claimed that a dependent type can be used in `elaborated-enum-declarator`, but that's not the case: > The > [using-enum-declarator](http://eel.is/c++draft/enum.udecl#nt:using-enum-declarator) > shall designate a non-dependent type with a reachable > [enum-specifier](http://eel.is/c++draft/dcl.enum#nt:enum-specifier)[.](http://eel.is/c++draft/enum.udecl#1.sentence-2) >From a7b6a8b667d48d8e70f3e5fcbaaa44a72ad885db Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Thu, 13 Jun 2024 14:35:08 +0300 Subject: [PATCH 1/2] [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" --- clang/include/clang/Sema/Sema.h | 2 +- clang/lib/Parse/ParseDeclCXX.cpp| 44 + clang/lib/Sema/SemaDeclCXX.cpp | 19 ++- clang/test/CXX/drs/cwg26xx.cpp | 5 ++- clang/test/CXX/drs/cwg28xx.cpp | 10 ++ clang/test/SemaCXX/cxx20-using-enum.cpp | 12 --- clang/www/cxx_dr_status.html| 10 -- 7 files changed, 70 insertions(+), 32 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 4d4579fcfd456..ccabd4925b8a3 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -4032,7 +4032,7 @@ class Sema final : public SemaBase { Decl *ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, - SourceLocation IdentLoc, IdentifierInfo &II, + SourceRange TyLoc, const IdentifierInfo &II, ParsedType Ty, CXXScopeSpec *SS = nullptr); Decl *ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 9a4a777f575b2..189fcc5440292 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -692,7 +692,7 @@ bool Parser::ParseUsingDeclarator(DeclaratorContext Context, /// using-enum-declaration: [C++20, dcl.enum] /// 'using' elaborated-enum-specifier ; /// The terminal name of the elaborated-enum-specifier undergoes -/// ordinary lookup +/// type-only lookup /// /// elaborated-enum-specifier: /// 'enum' nested-name-specifier[opt] identifier @@ -738,16 +738,48 @@ Parser::DeclGroupPtrTy Parser::ParseUsingDeclaration( return nullptr; } -if (!Tok.is(tok::identifier)) { +Decl *UED = nullptr; + +if (Tok.is(tok::identifier)) { + IdentifierInfo *IdentInfo = Tok.getIdentifierInfo(); + SourceLocation IdentLoc = ConsumeToken(); + + ParsedType Type = Actions.getTypeName(*IdentInfo, IdentLoc, getCurScope(), &SS, /*isClassName=*/true, + /*HasTrailingDot=*/false, + /*ObjectType=*/nullptr, /*IsCtorOrDtorName=*/false, + /*WantNontrivialTypeSourceInfo=*/true); + + UED = Actions.ActOnUsingEnumDeclaration( + getCurScope(), AS, UsingLoc, UELoc, IdentLoc, *IdentInfo, Type, &SS); +} +else if (Tok.is(tok::annot_template_id)) { + TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok); + + if (TemplateId->mightBeType()) { +AnnotateTemplateIdTokenAsType(SS, ImplicitTypenameContext::No, + /*IsClassName=*/true); + +assert(Tok.is(tok::annot_typename) && "template-id -> type failed"); +TypeResult Type = getTypeAnnotation(Tok); +SourceRange Loc = Tok.getAnnotationRange(); +ConsumeAnnotationToken(); + +UED = Actions.ActOnUsingEnumDeclaration( +getCurScope(), AS, UsingLoc, UELoc, Loc, *TemplateId->Name, Type.get(), &SS); + } + else { +Diag(Tok.getLocation(), diag::err_using_enum_not_enum) +<< TemplateId->Name->getName() +<< SourceRange(TemplateId->TemplateNameLoc, TemplateId->RAngleLoc); + } +} +else { Diag(Tok.getLocation(), diag::err_using_enum_expect_identifier) << Tok.is(tok::kw_enum); SkipUntil(tok::semi); return nullptr; } -IdentifierInfo *IdentInfo = Tok.getIdentifierInfo(); -SourceLocation IdentLoc = ConsumeToken(); -Decl *UED = Actions.ActOnUsingEnumDeclarat
[clang] [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" (PR #95399)
https://github.com/Endilll edited https://github.com/llvm/llvm-project/pull/95399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" (PR #95399)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Vlad Serebrennikov (Endilll) Changes This patch implements 2024-05-31 resolution of a tentatively ready issue [CWG2877](https://cplusplus.github.io/CWG/issues/2877.html) "Type-only lookup for using-enum-declarator", which supersedes earlier [CWG2621](https://cplusplus.github.io/CWG/issues/2621.html) "Kind of lookup for `using enum` declarations". Now we perform type-only lookup (not to be confused with type-only context) for `elaborated-enum-declarator`. I also found out (and fixed) that one of our existing tests claimed that a dependent type can be used in `elaborated-enum-declarator`, but that's not the case: > The [using-enum-declarator](http://eel.is/c++draft/enum.udecl#nt:using-enum-declarator) shall designate a non-dependent type with a reachable [enum-specifier](http://eel.is/c++draft/dcl.enum#nt:enum-specifier)[.](http://eel.is/c++draft/enum.udecl#1.sentence-2) --- Full diff: https://github.com/llvm/llvm-project/pull/95399.diff 7 Files Affected: - (modified) clang/include/clang/Sema/Sema.h (+2-2) - (modified) clang/lib/Parse/ParseDeclCXX.cpp (+37-6) - (modified) clang/lib/Sema/SemaDeclCXX.cpp (+11-10) - (modified) clang/test/CXX/drs/cwg26xx.cpp (+2-3) - (modified) clang/test/CXX/drs/cwg28xx.cpp (+3-7) - (modified) clang/test/SemaCXX/cxx20-using-enum.cpp (+8-4) - (modified) clang/www/cxx_dr_status.html (+2-2) ``diff diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 4d4579fcfd456..dc059f781dcb2 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -4031,8 +4031,8 @@ class Sema final : public SemaBase { const ParsedAttributesView &AttrList); Decl *ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, - SourceLocation EnumLoc, - SourceLocation IdentLoc, IdentifierInfo &II, + SourceLocation EnumLoc, SourceRange TyLoc, + const IdentifierInfo &II, ParsedType Ty, CXXScopeSpec *SS = nullptr); Decl *ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 9a4a777f575b2..51e065a6c6a86 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -692,7 +692,7 @@ bool Parser::ParseUsingDeclarator(DeclaratorContext Context, /// using-enum-declaration: [C++20, dcl.enum] /// 'using' elaborated-enum-specifier ; /// The terminal name of the elaborated-enum-specifier undergoes -/// ordinary lookup +/// type-only lookup /// /// elaborated-enum-specifier: /// 'enum' nested-name-specifier[opt] identifier @@ -738,16 +738,47 @@ Parser::DeclGroupPtrTy Parser::ParseUsingDeclaration( return nullptr; } -if (!Tok.is(tok::identifier)) { +Decl *UED = nullptr; + +if (Tok.is(tok::identifier)) { + IdentifierInfo *IdentInfo = Tok.getIdentifierInfo(); + SourceLocation IdentLoc = ConsumeToken(); + + ParsedType Type = Actions.getTypeName( + *IdentInfo, IdentLoc, getCurScope(), &SS, /*isClassName=*/true, + /*HasTrailingDot=*/false, + /*ObjectType=*/nullptr, /*IsCtorOrDtorName=*/false, + /*WantNontrivialTypeSourceInfo=*/true); + + UED = Actions.ActOnUsingEnumDeclaration( + getCurScope(), AS, UsingLoc, UELoc, IdentLoc, *IdentInfo, Type, &SS); +} else if (Tok.is(tok::annot_template_id)) { + TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok); + + if (TemplateId->mightBeType()) { +AnnotateTemplateIdTokenAsType(SS, ImplicitTypenameContext::No, + /*IsClassName=*/true); + +assert(Tok.is(tok::annot_typename) && "template-id -> type failed"); +TypeResult Type = getTypeAnnotation(Tok); +SourceRange Loc = Tok.getAnnotationRange(); +ConsumeAnnotationToken(); + +UED = Actions.ActOnUsingEnumDeclaration(getCurScope(), AS, UsingLoc, +UELoc, Loc, *TemplateId->Name, +Type.get(), &SS); + } else { +Diag(Tok.getLocation(), diag::err_using_enum_not_enum) +<< TemplateId->Name->getName() +<< SourceRange(TemplateId->TemplateNameLoc, TemplateId->RAngleLoc); + } +} else { Diag(Tok.getLocation(), diag::err_using_enum_expect_identifier) << Tok.is(tok::kw_enum); SkipUntil(tok::semi); return nullptr; } -IdentifierInfo *IdentInfo = Tok.getIdentifierInfo(); -SourceLocation IdentLoc = ConsumeToken(); -Decl *UED = Actions.ActOnUsingEnu
[clang] [llvm] [llvm][Support] Stop using PWD in current_path (PR #94544)
=?utf-8?q?Iñaki?= Amatria Barral Message-ID: In-Reply-To: @@ -17,10 +17,6 @@ // GCNO-LOCATION: "-coverage-notes-file={{.*}}/foo/bar.gcno" // GCNO-LOCATION-REL: "-coverage-notes-file={{.*}}{{/|}}foo/bar.gcno" -/// GCC allows PWD to change the paths. -// RUN: %if system-linux %{ PWD=/proc/self/cwd %clang -### -c --coverage %s -o foo/bar.o 2>&1 | FileCheck --check-prefix=PWD %s %} -// PWD: "-coverage-notes-file=/proc/self/cwd/foo/bar.gcno" "-coverage-data-file=/proc/self/cwd/foo/bar.gcda" AaronBallman wrote: We should not be regressing Clang behavior like this -- at least not without wider buy-in from the Clang community via an RFC. I worry that this change will silently break build scripts relying on the current PWD behavior being consistent between Clang and GCC. https://github.com/llvm/llvm-project/pull/94544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" (PR #95399)
@@ -738,16 +738,47 @@ Parser::DeclGroupPtrTy Parser::ParseUsingDeclaration( return nullptr; } -if (!Tok.is(tok::identifier)) { +Decl *UED = nullptr; + +if (Tok.is(tok::identifier)) { + IdentifierInfo *IdentInfo = Tok.getIdentifierInfo(); + SourceLocation IdentLoc = ConsumeToken(); + + ParsedType Type = Actions.getTypeName( + *IdentInfo, IdentLoc, getCurScope(), &SS, /*isClassName=*/true, + /*HasTrailingDot=*/false, + /*ObjectType=*/nullptr, /*IsCtorOrDtorName=*/false, + /*WantNontrivialTypeSourceInfo=*/true); + + UED = Actions.ActOnUsingEnumDeclaration( + getCurScope(), AS, UsingLoc, UELoc, IdentLoc, *IdentInfo, Type, &SS); +} else if (Tok.is(tok::annot_template_id)) { + TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok); + + if (TemplateId->mightBeType()) { +AnnotateTemplateIdTokenAsType(SS, ImplicitTypenameContext::No, + /*IsClassName=*/true); + +assert(Tok.is(tok::annot_typename) && "template-id -> type failed"); +TypeResult Type = getTypeAnnotation(Tok); +SourceRange Loc = Tok.getAnnotationRange(); +ConsumeAnnotationToken(); + +UED = Actions.ActOnUsingEnumDeclaration(getCurScope(), AS, UsingLoc, +UELoc, Loc, *TemplateId->Name, +Type.get(), &SS); + } else { +Diag(Tok.getLocation(), diag::err_using_enum_not_enum) +<< TemplateId->Name->getName() Endilll wrote: This leads to suboptimal diagnostic when e.g. variable template is put after `using enum`: `using enum A; // expected-error {{A is not an enumerated type}}`. I believe we should tell the user what we see instead of a mildly cryptic "enumeration type is expected." Is there a way to get that out of `TemplateIdAnnotation` that we have here? https://github.com/llvm/llvm-project/pull/95399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" (PR #95399)
@@ -738,16 +738,47 @@ Parser::DeclGroupPtrTy Parser::ParseUsingDeclaration( return nullptr; } -if (!Tok.is(tok::identifier)) { +Decl *UED = nullptr; + +if (Tok.is(tok::identifier)) { + IdentifierInfo *IdentInfo = Tok.getIdentifierInfo(); + SourceLocation IdentLoc = ConsumeToken(); + + ParsedType Type = Actions.getTypeName( + *IdentInfo, IdentLoc, getCurScope(), &SS, /*isClassName=*/true, Endilll wrote: Note that `getTypeName` is now called with `/*isClassName=*/true`. I believe this is how we spell type-only lookup when templates are not involved. https://github.com/llvm/llvm-project/pull/95399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm][Support] Stop using PWD in current_path (PR #94544)
https://github.com/inaki-amatria edited https://github.com/llvm/llvm-project/pull/94544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" (PR #95399)
https://github.com/Endilll edited https://github.com/llvm/llvm-project/pull/95399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" (PR #95399)
https://github.com/Endilll edited https://github.com/llvm/llvm-project/pull/95399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" (PR #95399)
https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/95399 >From a7b6a8b667d48d8e70f3e5fcbaaa44a72ad885db Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Thu, 13 Jun 2024 14:35:08 +0300 Subject: [PATCH 1/3] [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" --- clang/include/clang/Sema/Sema.h | 2 +- clang/lib/Parse/ParseDeclCXX.cpp| 44 + clang/lib/Sema/SemaDeclCXX.cpp | 19 ++- clang/test/CXX/drs/cwg26xx.cpp | 5 ++- clang/test/CXX/drs/cwg28xx.cpp | 10 ++ clang/test/SemaCXX/cxx20-using-enum.cpp | 12 --- clang/www/cxx_dr_status.html| 10 -- 7 files changed, 70 insertions(+), 32 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 4d4579fcfd456..ccabd4925b8a3 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -4032,7 +4032,7 @@ class Sema final : public SemaBase { Decl *ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, - SourceLocation IdentLoc, IdentifierInfo &II, + SourceRange TyLoc, const IdentifierInfo &II, ParsedType Ty, CXXScopeSpec *SS = nullptr); Decl *ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 9a4a777f575b2..189fcc5440292 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -692,7 +692,7 @@ bool Parser::ParseUsingDeclarator(DeclaratorContext Context, /// using-enum-declaration: [C++20, dcl.enum] /// 'using' elaborated-enum-specifier ; /// The terminal name of the elaborated-enum-specifier undergoes -/// ordinary lookup +/// type-only lookup /// /// elaborated-enum-specifier: /// 'enum' nested-name-specifier[opt] identifier @@ -738,16 +738,48 @@ Parser::DeclGroupPtrTy Parser::ParseUsingDeclaration( return nullptr; } -if (!Tok.is(tok::identifier)) { +Decl *UED = nullptr; + +if (Tok.is(tok::identifier)) { + IdentifierInfo *IdentInfo = Tok.getIdentifierInfo(); + SourceLocation IdentLoc = ConsumeToken(); + + ParsedType Type = Actions.getTypeName(*IdentInfo, IdentLoc, getCurScope(), &SS, /*isClassName=*/true, + /*HasTrailingDot=*/false, + /*ObjectType=*/nullptr, /*IsCtorOrDtorName=*/false, + /*WantNontrivialTypeSourceInfo=*/true); + + UED = Actions.ActOnUsingEnumDeclaration( + getCurScope(), AS, UsingLoc, UELoc, IdentLoc, *IdentInfo, Type, &SS); +} +else if (Tok.is(tok::annot_template_id)) { + TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok); + + if (TemplateId->mightBeType()) { +AnnotateTemplateIdTokenAsType(SS, ImplicitTypenameContext::No, + /*IsClassName=*/true); + +assert(Tok.is(tok::annot_typename) && "template-id -> type failed"); +TypeResult Type = getTypeAnnotation(Tok); +SourceRange Loc = Tok.getAnnotationRange(); +ConsumeAnnotationToken(); + +UED = Actions.ActOnUsingEnumDeclaration( +getCurScope(), AS, UsingLoc, UELoc, Loc, *TemplateId->Name, Type.get(), &SS); + } + else { +Diag(Tok.getLocation(), diag::err_using_enum_not_enum) +<< TemplateId->Name->getName() +<< SourceRange(TemplateId->TemplateNameLoc, TemplateId->RAngleLoc); + } +} +else { Diag(Tok.getLocation(), diag::err_using_enum_expect_identifier) << Tok.is(tok::kw_enum); SkipUntil(tok::semi); return nullptr; } -IdentifierInfo *IdentInfo = Tok.getIdentifierInfo(); -SourceLocation IdentLoc = ConsumeToken(); -Decl *UED = Actions.ActOnUsingEnumDeclaration( -getCurScope(), AS, UsingLoc, UELoc, IdentLoc, *IdentInfo, &SS); + if (!UED) { SkipUntil(tok::semi); return nullptr; diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 37f0df2a6a27d..fb9e38d6b5bc9 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -12395,22 +12395,23 @@ Decl *Sema::ActOnUsingDeclaration(Scope *S, AccessSpecifier AS, Decl *Sema::ActOnUsingEnumDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, - SourceLocation IdentLoc, - IdentifierInfo &II, CXXScopeSpec *SS) { + SourceRange TyLoc, const IdentifierI
[clang] [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" (PR #95399)
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/95399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" (PR #95399)
https://github.com/cor3ntin commented: Thanks for the patch Vlad! The general direction looks correct, but i have reservations about the parsing of templates https://github.com/llvm/llvm-project/pull/95399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" (PR #95399)
@@ -738,16 +738,47 @@ Parser::DeclGroupPtrTy Parser::ParseUsingDeclaration( return nullptr; } -if (!Tok.is(tok::identifier)) { +Decl *UED = nullptr; + +if (Tok.is(tok::identifier)) { + IdentifierInfo *IdentInfo = Tok.getIdentifierInfo(); + SourceLocation IdentLoc = ConsumeToken(); + + ParsedType Type = Actions.getTypeName( + *IdentInfo, IdentLoc, getCurScope(), &SS, /*isClassName=*/true, + /*HasTrailingDot=*/false, + /*ObjectType=*/nullptr, /*IsCtorOrDtorName=*/false, + /*WantNontrivialTypeSourceInfo=*/true); + + UED = Actions.ActOnUsingEnumDeclaration( + getCurScope(), AS, UsingLoc, UELoc, IdentLoc, *IdentInfo, Type, &SS); +} else if (Tok.is(tok::annot_template_id)) { + TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok); + + if (TemplateId->mightBeType()) { +AnnotateTemplateIdTokenAsType(SS, ImplicitTypenameContext::No, + /*IsClassName=*/true); + +assert(Tok.is(tok::annot_typename) && "template-id -> type failed"); +TypeResult Type = getTypeAnnotation(Tok); +SourceRange Loc = Tok.getAnnotationRange(); +ConsumeAnnotationToken(); + +UED = Actions.ActOnUsingEnumDeclaration(getCurScope(), AS, UsingLoc, +UELoc, Loc, *TemplateId->Name, +Type.get(), &SS); + } else { +Diag(Tok.getLocation(), diag::err_using_enum_not_enum) +<< TemplateId->Name->getName() cor3ntin wrote: We don't do it for base specifier, so i think this is fine (I suspect improvements would be a bit difficult, maybe by calling `ClassifyName`) https://github.com/llvm/llvm-project/pull/95399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits