[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)
https://github.com/usx95 closed https://github.com/llvm/llvm-project/pull/88670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/88670 >From 599283c1845a25afe90163a5f0a7a809c622a521 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Sun, 14 Apr 2024 21:21:21 + Subject: [PATCH 1/4] Use pushFullExprCleanup for deferred destroy --- clang/lib/CodeGen/CGDecl.cpp | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 8bdafa7c569b08..3f05ebb561da57 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -2216,8 +2216,11 @@ void CodeGenFunction::pushDestroyAndDeferDeactivation( void CodeGenFunction::pushDestroyAndDeferDeactivation( CleanupKind cleanupKind, Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray) { - pushCleanupAndDeferDeactivation( - cleanupKind, addr, type, destroyer, useEHCleanupForArray); + llvm::Instruction *DominatingIP = + Builder.CreateFlagLoad(llvm::Constant::getNullValue(Int8PtrTy)); + pushDestroy(cleanupKind, addr, type, destroyer, useEHCleanupForArray); + DeferredDeactivationCleanupStack.push_back( + {EHStack.stable_begin(), DominatingIP}); } void CodeGenFunction::pushStackRestore(CleanupKind Kind, Address SPMem) { >From a27c77a1506d8044d55eb6961ba69229cb9c1fd7 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Mon, 15 Apr 2024 12:41:27 + Subject: [PATCH 2/4] Add tests --- .../CodeGenCXX/destory-with-init-list.cpp | 49 +++ 1 file changed, 49 insertions(+) create mode 100644 clang/test/CodeGenCXX/destory-with-init-list.cpp diff --git a/clang/test/CodeGenCXX/destory-with-init-list.cpp b/clang/test/CodeGenCXX/destory-with-init-list.cpp new file mode 100644 index 00..b9495db3a23d6f --- /dev/null +++ b/clang/test/CodeGenCXX/destory-with-init-list.cpp @@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -emit-llvm -fexceptions -o - %s -triple x86_64-linux-gnu | FileCheck -check-prefixes=EH,CHECK %s +// RUN: %clang_cc1 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck -check-prefixes=NOEH,CHECK %s +namespace std { + typedef decltype(sizeof(int)) size_t; + + // libc++'s implementation + template + class initializer_list + { +const _E* __begin_; +size_t__size_; +initializer_list(const _E* __b, size_t __s); + }; +} + +class Object { +public: + Object() = default; + struct KV; + explicit Object(std::initializer_list Properties); +}; + +class Value { +public: + Value(std::initializer_list Elements); + Value(const char *V); + ~Value(); +}; + +class ObjectKey { +public: + ObjectKey(const char *S); + ~ObjectKey(); +}; + +struct Object::KV { + ObjectKey K; + Value V; +}; + +bool foo(); +void bar() { + // Verify we use conditional cleanups. + foo() ? Object{{"key1", {"val1", "val2"}}} : Object{{"key2", "val2"}}; + // CHECK: cond.true: + // EH:invoke void @_ZN9ObjectKeyC1EPKc + // NOEH: call void @_ZN9ObjectKeyC1EPKc + // CHECK: store ptr %K, ptr %cond-cleanup.save +} >From 33fda57e72f08d6f1d30667b10a5c05d2453b34a Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Mon, 15 Apr 2024 18:49:59 + Subject: [PATCH 3/4] Moved test to existing file --- .../CodeGenCXX/control-flow-in-stmt-expr.cpp | 56 ++- .../CodeGenCXX/destory-with-init-list.cpp | 49 2 files changed, 55 insertions(+), 50 deletions(-) delete mode 100644 clang/test/CodeGenCXX/destory-with-init-list.cpp diff --git a/clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp b/clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp index ffde1bd6a724d8..295a9b118ff63d 100644 --- a/clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp +++ b/clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 --std=c++20 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 --std=c++20 -fexceptions -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck -check-prefixes=EH %s +// RUN: %clang_cc1 --std=c++20 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck -check-prefixes=NOEH,CHECK %s struct Printy { Printy(const char *name) : name(name) {} @@ -349,6 +350,59 @@ void NewArrayInit() { // CHECK-NEXT:br label %return } +namespace std { + typedef decltype(sizeof(int)) size_t; + + // libc++'s implementation + template + class initializer_list + { +const _E* __begin_; +size_t__size_; +initializer_list(const _E* __b, size_t __s); + }; +} + +class Object { +public: + Object() = default; + struct KV; + Object(std::initializer_list); + Object(KV); +}; + +class Value { +public: + Value(std::initializer_list); + Value(const char *V); + ~Value(); +}; + +class ObjectKey { +public: + ObjectKey(const char *S); + ~ObjectKey(); +}; + +struct Object::KV { + ObjectKey K; + Value V; +}; + +void DestroyInConditionalCleanup() { + // EH-LABEL: DestroyInConditionalCleanupv() + // NOEH-LABEL: DestroyInConditionalCleanupv() +
[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)
@@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -emit-llvm -fexceptions -o - %s -triple x86_64-linux-gnu | FileCheck -check-prefixes=EH,CHECK %s +// RUN: %clang_cc1 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck -check-prefixes=NOEH,CHECK %s +namespace std { + typedef decltype(sizeof(int)) size_t; + + // libc++'s implementation + template + class initializer_list + { +const _E* __begin_; +size_t__size_; +initializer_list(const _E* __b, size_t __s); + }; +} + +class Object { +public: + Object() = default; + struct KV; + explicit Object(std::initializer_list Properties); +}; + +class Value { +public: + Value(std::initializer_list Elements); usx95 wrote: Great. Thanks. I was able to reduce it further. https://github.com/llvm/llvm-project/pull/88670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/88670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)
@@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -emit-llvm -fexceptions -o - %s -triple x86_64-linux-gnu | FileCheck -check-prefixes=EH,CHECK %s +// RUN: %clang_cc1 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck -check-prefixes=NOEH,CHECK %s +namespace std { + typedef decltype(sizeof(int)) size_t; + + // libc++'s implementation + template + class initializer_list + { +const _E* __begin_; +size_t__size_; +initializer_list(const _E* __b, size_t __s); + }; +} + +class Object { +public: + Object() = default; + struct KV; + explicit Object(std::initializer_list Properties); +}; + +class Value { +public: + Value(std::initializer_list Elements); efriedma-quic wrote: ``` class Object { public: struct KV; Object(KV); }; struct A { A(); ~A(); }; class Value { public: Value(A); Value(const char *V); ~Value(); }; class ObjectKey { public: ObjectKey(const char *S); ~ObjectKey(); }; struct Object::KV { ObjectKey K; Value V; }; bool foo(); void DestroyInConditionalCleanup() { foo() ? Object{{"key1", A()}} : Object{{"key2", "val2"}}; } ``` Not really a big deal either way, though; just a minor cleanup. https://github.com/llvm/llvm-project/pull/88670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)
@@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -emit-llvm -fexceptions -o - %s -triple x86_64-linux-gnu | FileCheck -check-prefixes=EH,CHECK %s +// RUN: %clang_cc1 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck -check-prefixes=NOEH,CHECK %s +namespace std { + typedef decltype(sizeof(int)) size_t; + + // libc++'s implementation + template + class initializer_list + { +const _E* __begin_; +size_t__size_; +initializer_list(const _E* __b, size_t __s); + }; +} + +class Object { +public: + Object() = default; + struct KV; + explicit Object(std::initializer_list Properties); +}; + +class Value { +public: + Value(std::initializer_list Elements); usx95 wrote: Did you try this out ? I cannot reproduce the original crash without `std::initializer_list`. https://github.com/llvm/llvm-project/pull/88670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/88670 >From 599283c1845a25afe90163a5f0a7a809c622a521 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Sun, 14 Apr 2024 21:21:21 + Subject: [PATCH 1/3] Use pushFullExprCleanup for deferred destroy --- clang/lib/CodeGen/CGDecl.cpp | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 8bdafa7c569b08..3f05ebb561da57 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -2216,8 +2216,11 @@ void CodeGenFunction::pushDestroyAndDeferDeactivation( void CodeGenFunction::pushDestroyAndDeferDeactivation( CleanupKind cleanupKind, Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray) { - pushCleanupAndDeferDeactivation( - cleanupKind, addr, type, destroyer, useEHCleanupForArray); + llvm::Instruction *DominatingIP = + Builder.CreateFlagLoad(llvm::Constant::getNullValue(Int8PtrTy)); + pushDestroy(cleanupKind, addr, type, destroyer, useEHCleanupForArray); + DeferredDeactivationCleanupStack.push_back( + {EHStack.stable_begin(), DominatingIP}); } void CodeGenFunction::pushStackRestore(CleanupKind Kind, Address SPMem) { >From a27c77a1506d8044d55eb6961ba69229cb9c1fd7 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Mon, 15 Apr 2024 12:41:27 + Subject: [PATCH 2/3] Add tests --- .../CodeGenCXX/destory-with-init-list.cpp | 49 +++ 1 file changed, 49 insertions(+) create mode 100644 clang/test/CodeGenCXX/destory-with-init-list.cpp diff --git a/clang/test/CodeGenCXX/destory-with-init-list.cpp b/clang/test/CodeGenCXX/destory-with-init-list.cpp new file mode 100644 index 00..b9495db3a23d6f --- /dev/null +++ b/clang/test/CodeGenCXX/destory-with-init-list.cpp @@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -emit-llvm -fexceptions -o - %s -triple x86_64-linux-gnu | FileCheck -check-prefixes=EH,CHECK %s +// RUN: %clang_cc1 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck -check-prefixes=NOEH,CHECK %s +namespace std { + typedef decltype(sizeof(int)) size_t; + + // libc++'s implementation + template + class initializer_list + { +const _E* __begin_; +size_t__size_; +initializer_list(const _E* __b, size_t __s); + }; +} + +class Object { +public: + Object() = default; + struct KV; + explicit Object(std::initializer_list Properties); +}; + +class Value { +public: + Value(std::initializer_list Elements); + Value(const char *V); + ~Value(); +}; + +class ObjectKey { +public: + ObjectKey(const char *S); + ~ObjectKey(); +}; + +struct Object::KV { + ObjectKey K; + Value V; +}; + +bool foo(); +void bar() { + // Verify we use conditional cleanups. + foo() ? Object{{"key1", {"val1", "val2"}}} : Object{{"key2", "val2"}}; + // CHECK: cond.true: + // EH:invoke void @_ZN9ObjectKeyC1EPKc + // NOEH: call void @_ZN9ObjectKeyC1EPKc + // CHECK: store ptr %K, ptr %cond-cleanup.save +} >From 33fda57e72f08d6f1d30667b10a5c05d2453b34a Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Mon, 15 Apr 2024 18:49:59 + Subject: [PATCH 3/3] Moved test to existing file --- .../CodeGenCXX/control-flow-in-stmt-expr.cpp | 56 ++- .../CodeGenCXX/destory-with-init-list.cpp | 49 2 files changed, 55 insertions(+), 50 deletions(-) delete mode 100644 clang/test/CodeGenCXX/destory-with-init-list.cpp diff --git a/clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp b/clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp index ffde1bd6a724d8..295a9b118ff63d 100644 --- a/clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp +++ b/clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 --std=c++20 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 --std=c++20 -fexceptions -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck -check-prefixes=EH %s +// RUN: %clang_cc1 --std=c++20 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck -check-prefixes=NOEH,CHECK %s struct Printy { Printy(const char *name) : name(name) {} @@ -349,6 +350,59 @@ void NewArrayInit() { // CHECK-NEXT:br label %return } +namespace std { + typedef decltype(sizeof(int)) size_t; + + // libc++'s implementation + template + class initializer_list + { +const _E* __begin_; +size_t__size_; +initializer_list(const _E* __b, size_t __s); + }; +} + +class Object { +public: + Object() = default; + struct KV; + Object(std::initializer_list); + Object(KV); +}; + +class Value { +public: + Value(std::initializer_list); + Value(const char *V); + ~Value(); +}; + +class ObjectKey { +public: + ObjectKey(const char *S); + ~ObjectKey(); +}; + +struct Object::KV { + ObjectKey K; + Value V; +}; + +void DestroyInConditionalCleanup() { + // EH-LABEL: DestroyInConditionalCleanupv() + // NOEH-LABEL: DestroyInConditionalCleanupv() +
[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)
@@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -emit-llvm -fexceptions -o - %s -triple x86_64-linux-gnu | FileCheck -check-prefixes=EH,CHECK %s +// RUN: %clang_cc1 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck -check-prefixes=NOEH,CHECK %s +namespace std { + typedef decltype(sizeof(int)) size_t; + + // libc++'s implementation + template + class initializer_list + { +const _E* __begin_; +size_t__size_; +initializer_list(const _E* __b, size_t __s); + }; +} + +class Object { +public: + Object() = default; + struct KV; + explicit Object(std::initializer_list Properties); +}; + +class Value { +public: + Value(std::initializer_list Elements); efriedma-quic wrote: The use of initializer_list here doesn't seem necessary; you could remove it to reduce the size of the testcase. Can we integrate this into an existing test file? https://github.com/llvm/llvm-project/pull/88670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/88670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)
usx95 wrote: @cor3ntin Added tests for crash. https://github.com/llvm/llvm-project/pull/88670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)
https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/88670 >From 599283c1845a25afe90163a5f0a7a809c622a521 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Sun, 14 Apr 2024 21:21:21 + Subject: [PATCH 1/2] Use pushFullExprCleanup for deferred destroy --- clang/lib/CodeGen/CGDecl.cpp | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 8bdafa7c569b08..3f05ebb561da57 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -2216,8 +2216,11 @@ void CodeGenFunction::pushDestroyAndDeferDeactivation( void CodeGenFunction::pushDestroyAndDeferDeactivation( CleanupKind cleanupKind, Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray) { - pushCleanupAndDeferDeactivation( - cleanupKind, addr, type, destroyer, useEHCleanupForArray); + llvm::Instruction *DominatingIP = + Builder.CreateFlagLoad(llvm::Constant::getNullValue(Int8PtrTy)); + pushDestroy(cleanupKind, addr, type, destroyer, useEHCleanupForArray); + DeferredDeactivationCleanupStack.push_back( + {EHStack.stable_begin(), DominatingIP}); } void CodeGenFunction::pushStackRestore(CleanupKind Kind, Address SPMem) { >From a27c77a1506d8044d55eb6961ba69229cb9c1fd7 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Mon, 15 Apr 2024 12:41:27 + Subject: [PATCH 2/2] Add tests --- .../CodeGenCXX/destory-with-init-list.cpp | 49 +++ 1 file changed, 49 insertions(+) create mode 100644 clang/test/CodeGenCXX/destory-with-init-list.cpp diff --git a/clang/test/CodeGenCXX/destory-with-init-list.cpp b/clang/test/CodeGenCXX/destory-with-init-list.cpp new file mode 100644 index 00..b9495db3a23d6f --- /dev/null +++ b/clang/test/CodeGenCXX/destory-with-init-list.cpp @@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -emit-llvm -fexceptions -o - %s -triple x86_64-linux-gnu | FileCheck -check-prefixes=EH,CHECK %s +// RUN: %clang_cc1 -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck -check-prefixes=NOEH,CHECK %s +namespace std { + typedef decltype(sizeof(int)) size_t; + + // libc++'s implementation + template + class initializer_list + { +const _E* __begin_; +size_t__size_; +initializer_list(const _E* __b, size_t __s); + }; +} + +class Object { +public: + Object() = default; + struct KV; + explicit Object(std::initializer_list Properties); +}; + +class Value { +public: + Value(std::initializer_list Elements); + Value(const char *V); + ~Value(); +}; + +class ObjectKey { +public: + ObjectKey(const char *S); + ~ObjectKey(); +}; + +struct Object::KV { + ObjectKey K; + Value V; +}; + +bool foo(); +void bar() { + // Verify we use conditional cleanups. + foo() ? Object{{"key1", {"val1", "val2"}}} : Object{{"key2", "val2"}}; + // CHECK: cond.true: + // EH:invoke void @_ZN9ObjectKeyC1EPKc + // NOEH: call void @_ZN9ObjectKeyC1EPKc + // CHECK: store ptr %K, ptr %cond-cleanup.save +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)
cor3ntin wrote: @usx95 Could you maybe reduce a test from the crash? Thanks! https://github.com/llvm/llvm-project/pull/88670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)
usx95 wrote: This fix is for a wrong refactoring change in https://github.com/llvm/llvm-project/commit/89ba7e183e6e2c64370ed1b963e54c06352211db and I would be inclined towards landing this in a few hours to unblock the build breakage (if there are no review comments). CC: @efriedma-quic https://github.com/llvm/llvm-project/pull/88670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Utkarsh Saxena (usx95) Changes Instead of directly pushing the `Destroy`, we should use `pushFullExprCleanup` which handles conditional branches. This fixes a backend crash due to 89ba7e183e6e2c64370ed1b963e54c06352211db. Tested: ```sh CLANG_DIR=/usr/local/google/home/usx/build $CLANG_DIR/bin/clang++ \ -Itools/clang/tools/extra/clangd \ -I/usr/local/google/home/usx/src/llvm/llvm-project/clang-tools-extra/clangd \ -I/usr/local/google/home/usx/src/llvm/llvm-project/clang-tools-extra/clangd/../include-cleaner/include \ -Itools/clang/tools/extra/clangd/../clang-tidy \ -I/usr/local/google/home/usx/src/llvm/llvm-project/clang/include \ -Itools/clang/include \ -Iinclude \ -I/usr/local/google/home/usx/src/llvm/llvm-project/llvm/include \ -I/usr/local/google/home/usx/src/llvm/llvm-project/clang-tools-extra/pseudo/lib/../include \ -isystem$CLANG_DIR/lib/clang/19/include \ -o /usr/local/google/home/usx/build/bootstrap/tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/ClangdLSPServer.cpp.o \ -c /usr/local/google/home/usx/src/llvm/llvm-project/clang-tools-extra/clangd/ClangdLSPServer.cpp ``` --- Full diff: https://github.com/llvm/llvm-project/pull/88670.diff 1 Files Affected: - (modified) clang/lib/CodeGen/CGDecl.cpp (+5-2) ``diff diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 8bdafa7c569b08..3f05ebb561da57 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -2216,8 +2216,11 @@ void CodeGenFunction::pushDestroyAndDeferDeactivation( void CodeGenFunction::pushDestroyAndDeferDeactivation( CleanupKind cleanupKind, Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray) { - pushCleanupAndDeferDeactivation( - cleanupKind, addr, type, destroyer, useEHCleanupForArray); + llvm::Instruction *DominatingIP = + Builder.CreateFlagLoad(llvm::Constant::getNullValue(Int8PtrTy)); + pushDestroy(cleanupKind, addr, type, destroyer, useEHCleanupForArray); + DeferredDeactivationCleanupStack.push_back( + {EHStack.stable_begin(), DominatingIP}); } void CodeGenFunction::pushStackRestore(CleanupKind Kind, Address SPMem) { `` https://github.com/llvm/llvm-project/pull/88670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)
https://github.com/usx95 ready_for_review https://github.com/llvm/llvm-project/pull/88670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/88670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Use pushFullExprCleanup for deferred destroy (PR #88670)
https://github.com/usx95 created https://github.com/llvm/llvm-project/pull/88670 Instead of directly pushing the `Destroy`, we should use `pushFullExprCleanup` which handles conditional branches. This fixes a backend crash due to 89ba7e183e6e2c64370ed1b963e54c06352211db. Tested: ``` CLANG_DIR=/usr/local/google/home/usx/build $CLANG_DIR/bin/clang++ \ -Itools/clang/tools/extra/clangd \ -I/usr/local/google/home/usx/src/llvm/llvm-project/clang-tools-extra/clangd \ -I/usr/local/google/home/usx/src/llvm/llvm-project/clang-tools-extra/clangd/../include-cleaner/include \ -Itools/clang/tools/extra/clangd/../clang-tidy \ -I/usr/local/google/home/usx/src/llvm/llvm-project/clang/include \ -Itools/clang/include \ -Iinclude \ -I/usr/local/google/home/usx/src/llvm/llvm-project/llvm/include \ -I/usr/local/google/home/usx/src/llvm/llvm-project/clang-tools-extra/pseudo/lib/../include \ -isystem$CLANG_DIR/lib/clang/19/include \ -o /usr/local/google/home/usx/build/bootstrap/tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/ClangdLSPServer.cpp.o \ -c /usr/local/google/home/usx/src/llvm/llvm-project/clang-tools-extra/clangd/ClangdLSPServer.cpp ``` >From 599283c1845a25afe90163a5f0a7a809c622a521 Mon Sep 17 00:00:00 2001 From: Utkarsh Saxena Date: Sun, 14 Apr 2024 21:21:21 + Subject: [PATCH] Use pushFullExprCleanup for deferred destroy --- clang/lib/CodeGen/CGDecl.cpp | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 8bdafa7c569b08..3f05ebb561da57 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -2216,8 +2216,11 @@ void CodeGenFunction::pushDestroyAndDeferDeactivation( void CodeGenFunction::pushDestroyAndDeferDeactivation( CleanupKind cleanupKind, Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray) { - pushCleanupAndDeferDeactivation( - cleanupKind, addr, type, destroyer, useEHCleanupForArray); + llvm::Instruction *DominatingIP = + Builder.CreateFlagLoad(llvm::Constant::getNullValue(Int8PtrTy)); + pushDestroy(cleanupKind, addr, type, destroyer, useEHCleanupForArray); + DeferredDeactivationCleanupStack.push_back( + {EHStack.stable_begin(), DominatingIP}); } void CodeGenFunction::pushStackRestore(CleanupKind Kind, Address SPMem) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits