[clang] [llvm] [ValueTracking] Return true for AddrSpaceCast in canCreateUndefOrPoison (PR #144686)

2025-06-20 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,24 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 +; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=instcombine %s | FileCheck %s + +; Check that `select B, true, C` isn't optimized to `or B, C`. nik

[clang] [llvm] [ValueTracking] Return true for AddrSpaceCast in canCreateUndefOrPoison (PR #144686)

2025-06-20 Thread Nikita Popov via cfe-commits
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/144686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [ValueTracking] Return true for AddrSpaceCast in canCreateUndefOrPoison (PR #144686)

2025-06-20 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/144686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [ValueTracking] Return true for AddrSpaceCast in canCreateUndefOrPoison (PR #144686)

2025-06-20 Thread Nikita Popov via cfe-commits
nikic wrote: For the purposes of this PR, I think you should only change canCreateUndefOrPoison to return true and just eat the regressions. We can follow up with using isValidAddrSpaceCast() in a followup, because it will be less straightforward. I'm not willing to accept direct use of TTI in

[clang] [llvm] [ValueTracking] Return true for AddrSpaceCast in canCreateUndefOrPoison (PR #144686)

2025-06-20 Thread Nikita Popov via cfe-commits
@@ -10211,8 +10210,18 @@ bool AANoUndef::isImpliedByIR(Attributor &A, const IRPosition &IRP, return true; Value &Val = IRP.getAssociatedValue(); + auto IsTargetGuaranteedNotPoison = [&](Value &V) { +if (auto *ASC = dyn_cast(&V)) { + const auto *TTI = A.getInfo

[clang] [Clang] Verify data layout consistency (PR #144720)

2025-06-19 Thread Nikita Popov via cfe-commits
nikic wrote: @rjmccall From a Clang perspective, largely no -- but not entirely. There are cases when LLVM materializes allocations based on the data layout in ways that are observable and not controllable by Clang. One of these is certain inline asm constraints (which can end up passing const

[clang] [llvm] [InstCombine] remove dead loads, such as memcpy from undef (PR #143958)

2025-06-18 Thread Nikita Popov via cfe-commits
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/143958 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [InstCombine] remove dead loads, such as memcpy from undef (PR #143958)

2025-06-18 Thread Nikita Popov via cfe-commits
@@ -3339,16 +3340,23 @@ static bool isAllocSiteRemovable(Instruction *AI, if (IntrinsicInst *II = dyn_cast(I)) { switch (II->getIntrinsicID()) { default: -return false; +return std::nullopt; case Intrinsic::memmov

[clang] [llvm] [InstCombine] remove dead loads, such as memcpy from undef (PR #143958)

2025-06-18 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/143958 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [SROA] Vector promote some memsets (PR #133301)

2025-06-18 Thread Nikita Popov via cfe-commits
nikic wrote: To make the question more precise, would it make sense to change AMDGPUs unaligned access hook such that https://godbolt.org/z/Gv1j4vjqE will look the same as on X86? That should also fix the motivating problem here. https://github.com/llvm/llvm-project/pull/133301 __

[clang] [Clang] Partially fix m68k alignments (PR #144740)

2025-06-18 Thread Nikita Popov via cfe-commits
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/144740 As the data layout a few lines further up specifies, the int, long and pointer alignment should be 16 instead of the default of 32. The long long alignment is also incorrect, but that would require a change to t

[clang] [Clang] Verify data layout consistency (PR #144720)

2025-06-18 Thread Nikita Popov via cfe-commits
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/144720 Verify that the alignments specified by clang TargetInfo match the alignments specified by LLVM data layout, which will hopefully prevent accidental mismatches in the future. This currently contains opt-outs for

[clang] [llvm] [SROA] Vector promote some memsets (PR #133301)

2025-06-17 Thread Nikita Popov via cfe-commits
nikic wrote: On x86, what we actually end up doing is to combine those to unaligned i64 loads (see https://godbolt.org/z/P5z674x4r), which is probably the best outcome if they are supported. I assume AMDGPU does not support unaligned loads, and that's why you want to have single element loads

[clang] [llvm] [InstCombine] remove dead loads, such as memcpy from undef (PR #143958)

2025-06-16 Thread Nikita Popov via cfe-commits
@@ -3382,6 +3422,17 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) { eraseInstFromFunction(*I); Users[i] = nullptr; // Skip examining in the next loop. } +if (auto *MTI = dyn_cast(I)) { + if (KnowInitZero && getUn

[clang] [llvm] [InstCombine] remove dead loads, such as memcpy from undef (PR #143958)

2025-06-16 Thread Nikita Popov via cfe-commits
nikic wrote: https://github.com/dtcxzyw/llvm-opt-benchmark/pull/2433 has a few cases that regress for a reason that is not immediately obvious to me, if you want to take a look. (But this is overwhelmingly an improvement, so I don't particularly care.) There are a number of test failures for

[clang] [llvm] [InstCombine] remove dead loads, such as memcpy from undef (PR #143958)

2025-06-16 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,63 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -passes='instcombine' -S | FileCheck %s + +; This is a fuzzer-generated test that would assert because +; we'd get into foldAndOfICmps() without running InstSimplify +; on

[clang] [llvm] [InstCombine] remove dead loads, such as memcpy from undef (PR #143958)

2025-06-16 Thread Nikita Popov via cfe-commits
@@ -3382,6 +3418,17 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) { eraseInstFromFunction(*I); Users[i] = nullptr; // Skip examining in the next loop. } +if (auto *MTI = dyn_cast(I)) { + if (KnowInitZero && getUn

[clang] [llvm] [InstCombine] remove dead loads, such as memcpy from undef (PR #143958)

2025-06-16 Thread Nikita Popov via cfe-commits
@@ -3362,10 +3385,23 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) { DIB.reset(new DIBuilder(*MI.getModule(), /*AllowUnresolved=*/false)); } - if (isAllocSiteRemovable(&MI, Users, TLI)) { + // Determine what getInitialValueOfAllocation would return

[clang] [llvm] [InstCombine] remove dead loads, such as memcpy from undef (PR #143958)

2025-06-16 Thread Nikita Popov via cfe-commits
@@ -3283,10 +3285,15 @@ static bool isAllocSiteRemovable(Instruction *AI, case Intrinsic::memcpy: case Intrinsic::memset: { MemIntrinsic *MI = cast(II); -if (MI->isVolatile() || MI->getRawDest() != PI) +if (MI->isVolatile(

[clang] [llvm] [KeyInstr] Add docs (PR #137991)

2025-06-16 Thread Nikita Popov via cfe-commits
nikic wrote: I think you need to add this to either UserGuides.rst or Reference.rst for it to actually appear in the docs? https://github.com/llvm/llvm-project/pull/137991 ___ cfe-commits mailing list cfe-commits@lis

[clang] [llvm] [KeyInstr] Add docs (PR #137991)

2025-06-16 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,120 @@ +# Key Instructions in Clang + +Key Instructions is an LLVM feature that reduces the jumpiness of optimized code debug stepping. This document explains how Clang applies the necessary metadata. + +## Implementation + +See the [LLVM docs](../../llvm/docs/KeyInst

[clang] [llvm] [LLVM][Coro] Add LifetimeMovePass (PR #144319)

2025-06-16 Thread Nikita Popov via cfe-commits
nikic wrote: This pass should have dedicated tests that don't mix in other coro passes. https://github.com/llvm/llvm-project/pull/144319 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/c

[clang] [llvm] [LLVM][Coro] Add LifetimeMovePass (PR #144319)

2025-06-16 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,223 @@ +//===- LifetimeMove.cpp - Narrowing lifetimes -===// +// +// 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: Ap

[clang] [llvm] [LLVM][Coro] Add LifetimeMovePass (PR #144319)

2025-06-16 Thread Nikita Popov via cfe-commits
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/144319 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [LLVM][Coro] Add LifetimeMovePass (PR #144319)

2025-06-16 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,223 @@ +//===- LifetimeMove.cpp - Narrowing lifetimes -===// +// +// 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: Ap

[clang] [llvm] [LLVM][Coro] Add LifetimeMovePass (PR #144319)

2025-06-16 Thread Nikita Popov via cfe-commits
@@ -559,6 +562,7 @@ PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level, FPM.addPass(ADCEPass()); FPM.addPass( SimplifyCFGPass(SimplifyCFGOptions().convertSwitchRangeToICmp(true))); + FPM.addPass(LifetimeMovePass()); nikic wro

[clang] [llvm] [LLVM][Coro] Add LifetimeMovePass (PR #144319)

2025-06-16 Thread Nikita Popov via cfe-commits
@@ -1811,15 +1811,15 @@ def int_coro_promise : Intrinsic<[llvm_ptr_ty], def int_coro_await_suspend_void : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty], - [Throws]>; +

[clang] [llvm] [LLVM][Coro] Add LifetimeMovePass (PR #144319)

2025-06-16 Thread Nikita Popov via cfe-commits
https://github.com/nikic commented: Just some quick drive-by notes. Can this pass result in *observable* changes to allocation addresses? https://github.com/llvm/llvm-project/pull/144319 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-14 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,282 @@ +//===- ABI/Types.h --*- 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: Ap

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-14 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,102 @@ +//===- BPF.cpp ===// +// +// 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: Ap

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-14 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,172 @@ +//===- ABIFunctionInfo.h - ABI Function Information - 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: Ap

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-14 Thread Nikita Popov via cfe-commits
@@ -3,6 +3,7 @@ include(LLVM-Build) # `Demangle', `Support' and `TableGen' libraries are added on the top-level # CMakeLists.txt +# add_subdirectory(ABI) nikic wrote: Should add cmake now that we have cpp files. https://github.com/llvm/llvm-project/pull/1401

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-14 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,172 @@ +//===- ABIFunctionInfo.h - ABI Function Information - 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: Ap

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-14 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,136 @@ +//===- ABIInfo.h - ABI information access & encapsulation - 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: Ap

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-14 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,172 @@ +//===- ABIFunctionInfo.h - ABI Function Information - 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: Ap

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-14 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,172 @@ +//===- ABIFunctionInfo.h - ABI Function Information - 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: Ap

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-14 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,404 @@ +//== QualTypeMapper.cpp - Maps Clang QualType to LLVMABI Types -==// +// +// 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: Ap

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-14 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,136 @@ +//===- ABIInfo.h - ABI information access & encapsulation - 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: Ap

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-14 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,74 @@ +//== QualTypeMapper.h - Maps Clang QualType to LLVMABI Types ---==// +// +// 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: Apa

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-14 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,172 @@ +//===- ABIFunctionInfo.h - ABI Function Information - 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: Ap

[clang] [clang][cmake] Don't pass -fno-strict-aliasing for GCC (PR #144222)

2025-06-14 Thread Nikita Popov via cfe-commits
nikic wrote: To confirm, you do not get any `-Wstrict-aliasing` warnings with modern GCC after this change? https://github.com/llvm/llvm-project/pull/144222 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman

[clang] [llvm] [InstCombine] remove dead loads, such as memcpy from undef (PR #143958)

2025-06-12 Thread Nikita Popov via cfe-commits
@@ -364,20 +364,8 @@ define <2 x i1> @and_ne_with_diff_one_splatvec(<2 x i32> %x) { define void @simplify_before_foldAndOfICmps(ptr %p) { ; CHECK-LABEL: @simplify_before_foldAndOfICmps( -; CHECK-NEXT:[[A8:%.*]] = alloca i16, align 2 -; CHECK-NEXT:[[L7:%.*]] = load i16

[clang] [llvm] [InstCombine] remove dead loads, such as memcpy from undef (PR #143958)

2025-06-12 Thread Nikita Popov via cfe-commits
@@ -3283,10 +3285,15 @@ static bool isAllocSiteRemovable(Instruction *AI, case Intrinsic::memcpy: case Intrinsic::memset: { MemIntrinsic *MI = cast(II); -if (MI->isVolatile() || MI->getRawDest() != PI) +if (MI->isVolatile(

[clang] [llvm] [InstCombine] remove dead loads, such as memcpy from undef (PR #143958)

2025-06-12 Thread Nikita Popov via cfe-commits
@@ -3382,6 +3418,17 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) { eraseInstFromFunction(*I); Users[i] = nullptr; // Skip examining in the next loop. } +if (auto *MTI = dyn_cast(I)) { + if (KnowInitZero && getUn

[clang] [llvm] [InstCombine] remove dead loads, such as memcpy from undef (PR #143958)

2025-06-12 Thread Nikita Popov via cfe-commits
@@ -112,11 +112,7 @@ declare i1 @fn5(ptr byval({ i32, i32 }) align 4 %r) define i1 @test5() { ; CHECK-LABEL: define i1 @test5() { -; CHECK-NEXT:[[TMP1:%.*]] = alloca { i32, i32 }, align 4 nikic wrote: Should replace this alloca with an argument to retain

[clang] [llvm] [InstCombine] remove dead loads, such as memcpy from undef (PR #143958)

2025-06-12 Thread Nikita Popov via cfe-commits
nikic wrote: Need to modify this test to preserve behavior. Also the next one, etc. https://github.com/llvm/llvm-project/pull/143958 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-b

[clang] [llvm] [InstCombine] remove dead loads, such as memcpy from undef (PR #143958)

2025-06-12 Thread Nikita Popov via cfe-commits
@@ -3362,10 +3385,23 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) { DIB.reset(new DIBuilder(*MI.getModule(), /*AllowUnresolved=*/false)); } - if (isAllocSiteRemovable(&MI, Users, TLI)) { + // Determine what getInitialValueOfAllocation would return

[clang] [flang] [llvm] add -floop-fuse to clang and flang (PR #142686)

2025-06-10 Thread Nikita Popov via cfe-commits
https://github.com/nikic requested changes to this pull request. I don't think we should expose clang driver options for passes that are known to have significant issues. If you want to add a `cl::opt` flag to allow scheduling this in the pipeline and accessible for early testing via `-mllvm`,

[clang] [Sema] Implement fix as suggested by FIXME (PR #143142)

2025-06-09 Thread Nikita Popov via cfe-commits
nikic wrote: Looks neutral: https://llvm-compile-time-tracker.com/compare.php?from=e4060d3beab3b525b49baaa15484e3c595740a2f&to=aace43c7cc60347e1853e55ee7c033a19a9a65ea&stat=instructions:u max-rss seems to have an improvement on tramp3d-v4 in multiple configurations, so that's probably not nois

[clang] [llvm] [LLVM][SROA] Teach SROA how to "bitcast" between fixed and scalable vectors. (PR #130973)

2025-06-06 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/130973 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Fix error that reference to PointerType is ambiguous in clang/lib/Analysis/UnsafeBufferUsage.cpp (PR #142966)

2025-06-05 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. LGTM, but I would also consider dropping the "using namespace llvm" instead. This seems a bit unusual for a file in clang/lib/Analysis. https://github.com/llvm/llvm-project/pull/142966 ___ cfe-commi

[clang] [llvm] [NFC][LLVM] Refactor IRBuilder::Create{VScale,ElementCount,TypeSize}. (PR #142803)

2025-06-04 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/142803 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-04 Thread Nikita Popov via cfe-commits
@@ -136,9 +136,69 @@ const llvm::abi::Type *QualTypeMapper::convertRecordType(const RecordType *RT) { if (RD->isUnion()) return convertUnionType(RD); + + // Handle C++ classes with base classes + auto *const CXXRd = dyn_cast(RD); + if (CXXRd && (CXXRd->getNumBases()

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-04 Thread Nikita Popov via cfe-commits
@@ -136,9 +136,69 @@ const llvm::abi::Type *QualTypeMapper::convertRecordType(const RecordType *RT) { if (RD->isUnion()) return convertUnionType(RD); + + // Handle C++ classes with base classes + auto *const CXXRd = dyn_cast(RD); + if (CXXRd && (CXXRd->getNumBases()

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-04 Thread Nikita Popov via cfe-commits
@@ -136,9 +136,69 @@ const llvm::abi::Type *QualTypeMapper::convertRecordType(const RecordType *RT) { if (RD->isUnion()) return convertUnionType(RD); + + // Handle C++ classes with base classes + auto *const CXXRd = dyn_cast(RD); + if (CXXRd && (CXXRd->getNumBases()

[clang] [llvm] Global string alignment (PR #142346)

2025-06-02 Thread Nikita Popov via cfe-commits
https://github.com/nikic commented: I'm not sure this is the right fix for the issue. Just like for allocas, the global variable alignment is a *minimum* required alignment, which can and should be raised by targets if it improves code generation. (The exception to this is if the global has a

[clang] [llvm] Global string alignment (PR #142346)

2025-06-02 Thread Nikita Popov via cfe-commits
@@ -52,7 +52,7 @@ GlobalVariable *IRBuilderBase::CreateGlobalString(StringRef Str, *M, StrConstant->getType(), true, GlobalValue::PrivateLinkage, StrConstant, Name, nullptr, GlobalVariable::NotThreadLocal, AddressSpace); GV->setUnnamedAddr(GlobalValue::UnnamedAd

[clang] [llvm] Global string alignment (PR #142346)

2025-06-02 Thread Nikita Popov via cfe-commits
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/142346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [CodeGen] Move CodeGenPGO behind unique_ptr (NFC) (PR #142155)

2025-06-02 Thread Nikita Popov via cfe-commits
https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/142155 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-01 Thread Nikita Popov via cfe-commits
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/140112 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-01 Thread Nikita Popov via cfe-commits
nikic wrote: QualtypeMapper.h -> QualTypeMapper.h to match the class. https://github.com/llvm/llvm-project/pull/140112 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/lis

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-06-01 Thread Nikita Popov via cfe-commits
https://github.com/nikic commented: One thing still missing here is handling for C++ structs with base classes. https://github.com/llvm/llvm-project/pull/140112 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mail

[clang] [clang] Serialization: support hashing null template arguments (PR #141890)

2025-05-30 Thread Nikita Popov via cfe-commits
nikic wrote: For the record, the manual backport PR is at: https://github.com/llvm/llvm-project/pull/141957 https://github.com/llvm/llvm-project/pull/141890 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman

[clang] [CodeGen] Move CodeGenPGO behind unique_ptr (NFC) (PR #142155)

2025-05-30 Thread Nikita Popov via cfe-commits
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/142155 The InstrProf headers are very expensive. Avoid including them in all of CodeGen/ by making the CodeGenPGO member behind a unqiue_ptr. This reduces clang build time by 0.8%: https://llvm-compile-time-tracker.com/

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-05-30 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,209 @@ +#include "clang/AST/RecordLayout.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/Analyses/ThreadSafetyTIL.h" +#include "clang/Basic/LLVM.h" +#include "clang/Basic/TargetInfo.h" +#include "llvm/ABI/Types.h" +#include "llvm/Support/Alignment.h" +#include

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-05-30 Thread Nikita Popov via cfe-commits
nikic wrote: I think this should be part of the clang/CodeGen library, not a new one. https://github.com/llvm/llvm-project/pull/140112 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-05-30 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,78 @@ +#ifndef LLVM_ABI_QUALTYPE_MAPPER_H +#define LLVM_ABI_QUALTYPE_MAPPER_H nikic wrote: Outdated header guard. https://github.com/llvm/llvm-project/pull/140112 ___ cfe-commits mailing list cfe-commits@lis

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-05-30 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,260 @@ +#ifndef LLVM_ABI_TYPES_H +#define LLVM_ABI_TYPES_H + +#include "llvm/ADT/APFloat.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/Alignment.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/TypeSize.h" +#include +#include + +namespace l

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-05-30 Thread Nikita Popov via cfe-commits
nikic wrote: We should include the license file header in the newly created files: https://llvm.org/docs/CodingStandards.html#file-headers https://github.com/llvm/llvm-project/pull/140112 ___ cfe-commits mailing list

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-05-30 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,260 @@ +#ifndef LLVM_ABI_TYPES_H +#define LLVM_ABI_TYPES_H + +#include "llvm/ADT/APFloat.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/Alignment.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/TypeSize.h" +#include +#include --

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-05-30 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,209 @@ +#include "clang/AST/RecordLayout.h" +#include "clang/AST/Type.h" +#include "clang/Analysis/Analyses/ThreadSafetyTIL.h" +#include "clang/Basic/LLVM.h" +#include "clang/Basic/TargetInfo.h" +#include "llvm/ABI/Types.h" +#include "llvm/Support/Alignment.h" +#include

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-05-30 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,78 @@ +#ifndef LLVM_ABI_QUALTYPE_MAPPER_H +#define LLVM_ABI_QUALTYPE_MAPPER_H + +#include "llvm/IR/DerivedTypes.h" +#include "llvm/Support/Allocator.h" +#include +#include +#include +#include +#include nikic wrote: Should always use `""` for non-s

[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)

2025-05-30 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,78 @@ +#ifndef LLVM_ABI_QUALTYPE_MAPPER_H +#define LLVM_ABI_QUALTYPE_MAPPER_H + +#include "llvm/IR/DerivedTypes.h" +#include "llvm/Support/Allocator.h" +#include +#include +#include +#include +#include + +// Specialization for QualType +template <> struct llvm::Den

[clang] [llvm] [clang][CodeGen][AA] Introduce `!llvm.errno.tbaa` for errno alias disambiguation (PR #125258)

2025-05-29 Thread Nikita Popov via cfe-commits
nikic wrote: It would probably be best to split up the LLVM and the Clang changes. https://github.com/llvm/llvm-project/pull/125258 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang][CodeGen][AA] Introduce `!llvm.errno.tbaa` for errno alias disambiguation (PR #125258)

2025-05-29 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,90 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 +; RUN: opt -S -passes=instcombine < %s | FileCheck %s + +; sinf clobbering errno, but %p cannot alias errno per C/C++ strict aliasing rules via TBAA. +; Hence, can

[clang] [llvm] [clang][CodeGen][AA] Introduce `!llvm.errno.tbaa` for errno alias disambiguation (PR #125258)

2025-05-29 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,90 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 +; RUN: opt -S -passes=instcombine < %s | FileCheck %s + +; sinf clobbering errno, but %p cannot alias errno per C/C++ strict aliasing rules via TBAA. +; Hence, can

[clang] [llvm] [clang][CodeGen][AA] Introduce `!llvm.errno.tbaa` for errno alias disambiguation (PR #125258)

2025-05-29 Thread Nikita Popov via cfe-commits
@@ -970,6 +971,19 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call, } ModRefInfo Result = ArgMR | OtherMR; + + // Refine writes to errno memory. We can safely exclude the errno location if + // the given memory location is an alloca, the size of the memor

[clang] [llvm] [clang][CodeGen][AA] Introduce `!llvm.errno.tbaa` for errno alias disambiguation (PR #125258)

2025-05-29 Thread Nikita Popov via cfe-commits
@@ -970,6 +971,19 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call, } ModRefInfo Result = ArgMR | OtherMR; + + // Refine writes to errno memory. We can safely exclude the errno location if + // the given memory location is an alloca, the size of the memor

[clang] [llvm] [clang][CodeGen][AA] Introduce `!llvm.errno.tbaa` for errno alias disambiguation (PR #125258)

2025-05-29 Thread Nikita Popov via cfe-commits
@@ -970,6 +971,19 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call, } ModRefInfo Result = ArgMR | OtherMR; + + // Refine writes to errno memory. We can safely exclude the errno location if + // the given memory location is an alloca, the size of the memor

[clang] [llvm] [clang][CodeGen][AA] Introduce `!llvm.errno.tbaa` for errno alias disambiguation (PR #125258)

2025-05-29 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,90 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 +; RUN: opt -S -passes=instcombine < %s | FileCheck %s + +; sinf clobbering errno, but %p cannot alias errno per C/C++ strict aliasing rules via TBAA. +; Hence, can

[clang] [llvm] [clang][CodeGen][AA] Introduce `!llvm.errno.tbaa` for errno alias disambiguation (PR #125258)

2025-05-29 Thread Nikita Popov via cfe-commits
@@ -970,6 +971,19 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call, } ModRefInfo Result = ArgMR | OtherMR; + + // Refine writes to errno memory. We can safely exclude the errno location if + // the given memory location is an alloca, the size of the memor

[clang] [llvm] [clang][CodeGen][AA] Introduce `!llvm.errno.tbaa` for errno alias disambiguation (PR #125258)

2025-05-29 Thread Nikita Popov via cfe-commits
@@ -385,6 +386,20 @@ AliasResult TypeBasedAAResult::alias(const MemoryLocation &LocA, return AliasResult::NoAlias; } +AliasResult TypeBasedAAResult::aliasErrno(const MemoryLocation &Loc, + const Module *M) { + if (!shouldUseTBAA())

[clang] [llvm] [clang][CodeGen][AA] Introduce `!llvm.errno.tbaa` for errno alias disambiguation (PR #125258)

2025-05-29 Thread Nikita Popov via cfe-commits
https://github.com/nikic commented: * The metadata should be documented in LangRef. * We should test linking of two modules with the metadata. Both the case where they match and where they don't (e.g. mixing C and C++). IRLinker::linkNamedMDNodes should be the relevant code. (I do wonder whethe

[clang] [llvm] Add support for Windows Secure Hot-Patching (PR #138972)

2025-05-24 Thread Nikita Popov via cfe-commits
@@ -0,0 +1,287 @@ +//===-- WindowsHotPatch.cpp - Support for Windows hotpatching -===// +// +// 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: Ap

[clang] [CMake][Release] Build with -ffat-lto-objects (PR #140381)

2025-05-24 Thread Nikita Popov via cfe-commits
https://github.com/nikic commented: This is an improvement, but should we also strip the bitcode? Otherwise people will still get errors if they try to use the archives if their host clang version is older. https://github.com/llvm/llvm-project/pull/140381 __

[clang] [lld] [llvm] [mlir] [LLVM][Windows] Elide `PrettyStackTrace` output for usage errors (PR #140956)

2025-05-22 Thread Nikita Popov via cfe-commits
@@ -61,11 +61,14 @@ struct ScopedFatalErrorHandler { /// @deprecated Use reportFatalInternalError() or reportFatalUsageError() /// instead. [[noreturn]] LLVM_ABI void report_fatal_error(const char *reason, - bool gen_crash_diag = tru

[clang] [lld] [llvm] [LLVM][Windows] Elide `PrettyStackTrace` output for usage errors (PR #140956)

2025-05-21 Thread Nikita Popov via cfe-commits
@@ -61,11 +61,14 @@ struct ScopedFatalErrorHandler { /// @deprecated Use reportFatalInternalError() or reportFatalUsageError() /// instead. [[noreturn]] LLVM_ABI void report_fatal_error(const char *reason, - bool gen_crash_diag = tru

[clang] [lld] [llvm] [LLVM][Windows] Elide `PrettyStackTrace` output for usage errors (PR #140956)

2025-05-21 Thread Nikita Popov via cfe-commits
https://github.com/nikic requested changes to this pull request. https://github.com/llvm/llvm-project/pull/140956 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lld] [llvm] [LLVM][Windows] Elide `PrettyStackTrace` output for usage errors (PR #140956)

2025-05-21 Thread Nikita Popov via cfe-commits
@@ -61,11 +61,14 @@ struct ScopedFatalErrorHandler { /// @deprecated Use reportFatalInternalError() or reportFatalUsageError() /// instead. [[noreturn]] LLVM_ABI void report_fatal_error(const char *reason, - bool gen_crash_diag = tru

[clang] [llvm] [RISCV] Improve casting between i1 scalable vectors and i8 fixed vectors for -mrvv-vector-bits (PR #139190)

2025-05-14 Thread Nikita Popov via cfe-commits
@@ -1476,8 +1486,14 @@ CoerceScalableToFixed(CodeGenFunction &CGF, llvm::FixedVectorType *ToTy, // If we are casting a scalable i1 predicate vector to a fixed i8 // vector, first bitcast the source. if (FromTy->getElementType()->isIntegerTy(1) && - FromTy->getElemen

[clang-tools-extra] [clangd] Use StringRef::consume_back_insensitive (NFC) (PR #139456)

2025-05-11 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. https://github.com/llvm/llvm-project/pull/139456 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Use std::tie to implement operator< (NFC) (PR #139438)

2025-05-11 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. https://github.com/llvm/llvm-project/pull/139438 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tools-extra] Remove unused local variables (NFC) (PR #139382)

2025-05-10 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. https://github.com/llvm/llvm-project/pull/139382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [BasicAA] Do not decompose past casts with different index width (PR #119365)

2025-05-05 Thread Nikita Popov via cfe-commits
nikic wrote: @liushuyu Thanks for the report, should be fixed by https://github.com/llvm/llvm-project/pull/138528. https://github.com/llvm/llvm-project/pull/119365 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/

[clang] [llvm] [mlir] [ErrorHandling] Add reportFatalInternalError + reportFatalUsageError (NFC) (PR #138251)

2025-05-05 Thread Nikita Popov via cfe-commits
nikic wrote: @optimisan Good point. I've put up https://github.com/llvm/llvm-project/pull/138502 to update the docs. https://github.com/llvm/llvm-project/pull/138251 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bi

[clang] [llvm] [mlir] [ErrorHandling] Add reportFatalInternalError + reportFatalUsageError (NFC) (PR #138251)

2025-05-05 Thread Nikita Popov via cfe-commits
https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/138251 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Remove unused local variables (NFC) (PR #138468)

2025-05-04 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. https://github.com/llvm/llvm-project/pull/138468 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [mlir] [ErrorHandling] Add reportFatalInternalError + reportFatalUsageError (NFC) (PR #138251)

2025-05-02 Thread Nikita Popov via cfe-commits
https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/138251 >From 114ba17da2f522c5fd5045f5030a44fe13b3af27 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 2 May 2025 12:46:48 +0200 Subject: [PATCH 1/6] [ErrorHandling] Add reportFatalInternalError + reportFatalUsage

[clang] [llvm] [IRBuilder] Add versions of createInsertVector/createExtractVector that take a uint64_t index. (PR #138324)

2025-05-02 Thread Nikita Popov via cfe-commits
https://github.com/nikic approved this pull request. https://github.com/llvm/llvm-project/pull/138324 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [mlir] [ErrorHandling] Add reportFatalInternalError + reportFatalUsageError (NFC) (PR #138251)

2025-05-02 Thread Nikita Popov via cfe-commits
@@ -59,22 +59,42 @@ namespace llvm { ~ScopedFatalErrorHandler() { remove_fatal_error_handler(); } }; -/// Reports a serious error, calling any installed error handler. These -/// functions are intended to be used for error conditions which are outside -/// the control of

  1   2   3   4   5   6   7   8   9   10   >