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

2025-06-19 Thread Jameson Nash via cfe-commits
https://github.com/vtjnash updated https://github.com/llvm/llvm-project/pull/143958 >From 450eb079e97f1a20ab2547567d81c176fec06cfb Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 12 Jun 2025 18:48:00 + Subject: [PATCH 01/12] [instcombine] remove dead loads, such as memcpy from undef

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

2025-06-18 Thread Jameson Nash via cfe-commits
https://github.com/vtjnash updated https://github.com/llvm/llvm-project/pull/143958 >From 450eb079e97f1a20ab2547567d81c176fec06cfb Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 12 Jun 2025 18:48:00 + Subject: [PATCH 01/12] [instcombine] remove dead loads, such as memcpy from undef

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

2025-06-13 Thread Jameson Nash via cfe-commits
https://github.com/vtjnash updated https://github.com/llvm/llvm-project/pull/143958 >From 0d309ccbde665a033976a9eaa9f84c284765825c Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 12 Jun 2025 18:48:00 + Subject: [PATCH 1/9] [instcombine] remove dead loads, such as memcpy from undef

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

2025-06-13 Thread Jameson Nash via cfe-commits
vtjnash wrote: Sorry for the continued stream of comments, but it turns out this test is supposed to crash, per 41895843b5915bb78e9d02aa711fa10f7174db43, so I've removed the XFAIL and fixed the test invocation to avoid the crash https://github.com/llvm/llvm-p

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

2025-06-13 Thread Jameson Nash via cfe-commits
https://github.com/vtjnash updated https://github.com/llvm/llvm-project/pull/143958 >From 0d309ccbde665a033976a9eaa9f84c284765825c Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 12 Jun 2025 18:48:00 + Subject: [PATCH 1/7] [instcombine] remove dead loads, such as memcpy from undef

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

2025-06-12 Thread Jameson Nash via cfe-commits
vtjnash wrote: I've tried to adjust most of those to avoid alloca, though it is triggering some sort of bug with `simplify_before_foldAndOfICmps` which I'll have to investigate later https://github.com/llvm/llvm-project/pull/143958 ___

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

2025-06-12 Thread Jameson Nash via cfe-commits
https://github.com/vtjnash updated https://github.com/llvm/llvm-project/pull/143958 >From 0d309ccbde665a033976a9eaa9f84c284765825c Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 12 Jun 2025 18:48:00 + Subject: [PATCH 1/5] [instcombine] remove dead loads, such as memcpy from undef

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

2025-06-12 Thread Jameson Nash via cfe-commits
https://github.com/vtjnash updated https://github.com/llvm/llvm-project/pull/143958 >From 0d309ccbde665a033976a9eaa9f84c284765825c Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 12 Jun 2025 18:48:00 + Subject: [PATCH 1/4] [instcombine] remove dead loads, such as memcpy from undef

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

2025-06-12 Thread Jameson Nash 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 Jameson Nash 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 Jameson Nash 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-12 Thread Jameson Nash via cfe-commits
https://github.com/vtjnash updated https://github.com/llvm/llvm-project/pull/143958 >From 0d309ccbde665a033976a9eaa9f84c284765825c Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 12 Jun 2025 18:48:00 + Subject: [PATCH 1/3] [instcombine] remove dead loads, such as memcpy from undef

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

2025-06-12 Thread Jameson Nash via cfe-commits
https://github.com/vtjnash created https://github.com/llvm/llvm-project/pull/143958 @nikic The implements our discussion in https://github.com/llvm/llvm-project/pull/143782#discussion_r2142720376, extending `isAllocSiteRemovable` to be able to check if the ModRef info indicates the alloca is

[clang] [analyzer] Do not destruct fields of unions (PR #122330)

2025-02-04 Thread Jameson Nash via cfe-commits
https://github.com/vtjnash updated https://github.com/llvm/llvm-project/pull/122330 >From 0293a835a395c2e5a54efd16b70a38e73f116c59 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 9 Jan 2025 17:10:08 + Subject: [PATCH 1/3] [Sema] do not destruct fields of unions The C++ standard proh

[clang] [analyzer] Do not destruct fields of unions (PR #122330)

2025-02-04 Thread Jameson Nash via cfe-commits
@@ -441,3 +441,31 @@ void testLeakBecauseNTTPIsNotDeallocation() { void* p = ::operator new(10); deallocate_via_nttp(p); } // leak-warning{{Potential leak of memory pointed to by 'p'}} + +namespace optional_union { + template + class unique_ptr { +T *q; + public: +

[clang] [analyzer] Do not destruct fields of unions (PR #122330)

2025-02-03 Thread Jameson Nash via cfe-commits
@@ -377,3 +377,27 @@ void directUnknownSymbol() { } } + +void testUnionDtor() { + static int unionDtorCalled; + InlineDtor::cnt = 0; + InlineDtor::dtorCalled = 0; + unionDtorCalled = 0; + { + union UnionDtor { + InlineDtor kind1; + char kind2; +

[clang] [analyzer] Do not destruct fields of unions (PR #122330)

2025-02-03 Thread Jameson Nash via cfe-commits
https://github.com/vtjnash updated https://github.com/llvm/llvm-project/pull/122330 >From 829e1c89ce869f782cb802a1d618003770c0d074 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 9 Jan 2025 17:10:08 + Subject: [PATCH 1/3] [Sema] do not destruct fields of unions The C++ standard proh

[clang] [Sema] do not destruct fields of unions (PR #122330)

2025-01-29 Thread Jameson Nash via cfe-commits
https://github.com/vtjnash updated https://github.com/llvm/llvm-project/pull/122330 >From 829e1c89ce869f782cb802a1d618003770c0d074 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 9 Jan 2025 17:10:08 + Subject: [PATCH 1/2] [Sema] do not destruct fields of unions The C++ standard proh

[clang] [Sema] do not destruct fields of unions (PR #122330)

2025-01-16 Thread Jameson Nash via cfe-commits
vtjnash wrote: This roughly corresponds to 921bd20dddf5080cdb36f39c0162eb63b2d5325e in Sema, I think (@zygoloid). Maybe @tkremenek or @yronglin has done something in this part of the code recently too as reviewers and to merge this? https://github.com/llvm/llvm-project/pull/122330

[clang] [Sema] do not destruct fields of unions (PR #122330)

2025-01-09 Thread Jameson Nash via cfe-commits
https://github.com/vtjnash created https://github.com/llvm/llvm-project/pull/122330 The C++ standard prohibits this implicit destructor call, leading to incorrect reports from clang-analyzer. This causes projects that use std::option (including llvm) to fail the cplusplus.NewDelete test incorr

[clang-tools-extra] [clang-tidy] Enable plugin tests with LLVM_INSTALL_TOOLCHAIN_ONLY (PR #90370)

2024-04-27 Thread Jameson Nash via cfe-commits
vtjnash wrote: I think out of tree builds of clang-tidy (back in the svn days, when people did partial checkouts of individual projects) probably needed this to be able to correctly correctly find the right headers. Maybe standalone builds aren't permitted anymore? I think I mentioned this a b

[clang] 9d59cfc - clang-analyzer plugins require LLVM_ENABLE_PLUGINS also

2022-02-16 Thread Jameson Nash via cfe-commits
Author: Jameson Nash Date: 2022-02-16T11:59:09-05:00 New Revision: 9d59cfc67eadbe4b4088d70f8bbc61c96568d2f1 URL: https://github.com/llvm/llvm-project/commit/9d59cfc67eadbe4b4088d70f8bbc61c96568d2f1 DIFF: https://github.com/llvm/llvm-project/commit/9d59cfc67eadbe4b4088d70f8bbc61c96568d2f1.diff

[clang] 76cad51 - replace clang LLVM_ENABLE_PLUGINS -> CLANG_PLUGIN_SUPPORT in tests

2022-02-09 Thread Jameson Nash via cfe-commits
Author: Jameson Nash Date: 2022-02-09T17:31:34-05:00 New Revision: 76cad51ba700233d6e3492eddcbb466b6adbc2eb URL: https://github.com/llvm/llvm-project/commit/76cad51ba700233d6e3492eddcbb466b6adbc2eb DIFF: https://github.com/llvm/llvm-project/commit/76cad51ba700233d6e3492eddcbb466b6adbc2eb.diff

[clang-tools-extra] 84f137a - Reland "enable plugins for clang-tidy"

2022-02-01 Thread Jameson Nash via cfe-commits
Author: Jameson Nash Date: 2022-02-01T17:37:24-05:00 New Revision: 84f137a590e7de25c4105303e5938c40566c2dfb URL: https://github.com/llvm/llvm-project/commit/84f137a590e7de25c4105303e5938c40566c2dfb DIFF: https://github.com/llvm/llvm-project/commit/84f137a590e7de25c4105303e5938c40566c2dfb.diff

[clang-tools-extra] 3689272 - enable plugins for clang-tidy

2022-01-29 Thread Jameson Nash via cfe-commits
Author: Jameson Nash Date: 2022-01-29T14:21:19-05:00 New Revision: 36892727e4f19a60778e371d78f8fb09d8122c85 URL: https://github.com/llvm/llvm-project/commit/36892727e4f19a60778e371d78f8fb09d8122c85 DIFF: https://github.com/llvm/llvm-project/commit/36892727e4f19a60778e371d78f8fb09d8122c85.diff