[clang] [clang-repl] Test explicit emission of dtors in runtime interface builder (NFC) (PR #89734)
Stefan =?utf-8?q?Gränitz?= , Stefan =?utf-8?q?Gränitz?= Message-ID: In-Reply-To: vgvassilev wrote: We generally have to put a switch for the late parsed templates. We have it in some other tests. https://github.com/llvm/llvm-project/pull/89734 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Test explicit emission of dtors in runtime interface builder (NFC) (PR #89734)
weliveindetail wrote: Oh interesting, the Windows test actually fails at this assertion: ``` DC->getLexicalParent() == CurContext && "The next DeclContext should be lexically contained in the current one.", file C:\ws\src\clang\lib\Sema\SemaDecl.cpp, line 1332 ``` @vgvassilev Any ideas? https://github.com/llvm/llvm-project/pull/89734 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Test explicit emission of dtors in runtime interface builder (NFC) (PR #89734)
https://github.com/weliveindetail updated https://github.com/llvm/llvm-project/pull/89734 From 3aef8a0b009b54c4839a323b21cb5b09aa50d035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Tue, 23 Apr 2024 12:23:11 +0200 Subject: [PATCH 1/3] [clang-repl] Add test for explicit emission of dtors in the runtime interface builder --- clang/test/Interpreter/force-codegen-dtor.cpp | 13 + 1 file changed, 13 insertions(+) create mode 100644 clang/test/Interpreter/force-codegen-dtor.cpp diff --git a/clang/test/Interpreter/force-codegen-dtor.cpp b/clang/test/Interpreter/force-codegen-dtor.cpp new file mode 100644 index 0..a299ea46d5eac --- /dev/null +++ b/clang/test/Interpreter/force-codegen-dtor.cpp @@ -0,0 +1,13 @@ +// UNSUPPORTED: system-aix + +// RUN: cat %s | clang-repl | FileCheck %s +int *x = new int(); +template struct GuardX { T * GuardX(T *) : x(x) {}; ~GuardX(); }; +template GuardX::~GuardX() { delete x; x = nullptr; } + +// clang would normally defer codegen for ~GuardX() +// Make sure that RuntimeInterfaceBuilder requests it explicitly +(GuardX(x)) + +// CHECK-NOT: Symbols not found +// CHECK-NOT: _ZN6GuardXIiED2Ev From 398373fb353ece01899c988570fddfb42e535fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Tue, 23 Apr 2024 14:06:57 +0200 Subject: [PATCH 2/3] Add printf in dtor --- clang/test/Interpreter/force-codegen-dtor.cpp | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/clang/test/Interpreter/force-codegen-dtor.cpp b/clang/test/Interpreter/force-codegen-dtor.cpp index a299ea46d5eac..07758bb3fa099 100644 --- a/clang/test/Interpreter/force-codegen-dtor.cpp +++ b/clang/test/Interpreter/force-codegen-dtor.cpp @@ -1,13 +1,17 @@ +// REQUIRES: host-supports-jit // UNSUPPORTED: system-aix // RUN: cat %s | clang-repl | FileCheck %s int *x = new int(); template struct GuardX { T * GuardX(T *) : x(x) {}; ~GuardX(); }; -template GuardX::~GuardX() { delete x; x = nullptr; } -// clang would normally defer codegen for ~GuardX() -// Make sure that RuntimeInterfaceBuilder requests it explicitly +// clang normally defers codegen for this out-of-line ~GuardX(), which would +// cause the JIT to report Symbols not found: [ _ZN6GuardXIiED2Ev ] +extern "C" int printf(const char *, ...); +template GuardX::~GuardX() { delete x; printf("Running dtor\n"); } + +// Let's make sure that the RuntimeInterfaceBuilder requests it explicitly: (GuardX(x)) // CHECK-NOT: Symbols not found -// CHECK-NOT: _ZN6GuardXIiED2Ev +// CHECK: Running dtor From 9e8dd768a5256b4b54d54780328a3853762f1088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Wed, 24 Apr 2024 10:04:53 +0200 Subject: [PATCH 3/3] Fix: GuardX ctor invocation requires explicit template param --- clang/test/Interpreter/force-codegen-dtor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/Interpreter/force-codegen-dtor.cpp b/clang/test/Interpreter/force-codegen-dtor.cpp index 07758bb3fa099..783a8b73426c7 100644 --- a/clang/test/Interpreter/force-codegen-dtor.cpp +++ b/clang/test/Interpreter/force-codegen-dtor.cpp @@ -11,7 +11,7 @@ extern "C" int printf(const char *, ...); template GuardX::~GuardX() { delete x; printf("Running dtor\n"); } // Let's make sure that the RuntimeInterfaceBuilder requests it explicitly: -(GuardX(x)) +(GuardX(x)) // CHECK-NOT: Symbols not found // CHECK: Running dtor ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Test explicit emission of dtors in runtime interface builder (NFC) (PR #89734)
https://github.com/weliveindetail updated https://github.com/llvm/llvm-project/pull/89734 From 085a93919d8f65419cc856fe5584c83d3eceb142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Tue, 23 Apr 2024 12:23:11 +0200 Subject: [PATCH 1/3] [clang-repl] Add test for explicit emission of dtors in the runtime interface builder --- clang/test/Interpreter/force-codegen-dtor.cpp | 13 + 1 file changed, 13 insertions(+) create mode 100644 clang/test/Interpreter/force-codegen-dtor.cpp diff --git a/clang/test/Interpreter/force-codegen-dtor.cpp b/clang/test/Interpreter/force-codegen-dtor.cpp new file mode 100644 index 00..a299ea46d5eac0 --- /dev/null +++ b/clang/test/Interpreter/force-codegen-dtor.cpp @@ -0,0 +1,13 @@ +// UNSUPPORTED: system-aix + +// RUN: cat %s | clang-repl | FileCheck %s +int *x = new int(); +template struct GuardX { T * GuardX(T *) : x(x) {}; ~GuardX(); }; +template GuardX::~GuardX() { delete x; x = nullptr; } + +// clang would normally defer codegen for ~GuardX() +// Make sure that RuntimeInterfaceBuilder requests it explicitly +(GuardX(x)) + +// CHECK-NOT: Symbols not found +// CHECK-NOT: _ZN6GuardXIiED2Ev From 6fab67a6cf689c33a93748c66414050dfdf43d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Tue, 23 Apr 2024 14:06:57 +0200 Subject: [PATCH 2/3] Add printf in dtor --- clang/test/Interpreter/force-codegen-dtor.cpp | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/clang/test/Interpreter/force-codegen-dtor.cpp b/clang/test/Interpreter/force-codegen-dtor.cpp index a299ea46d5eac0..07758bb3fa0991 100644 --- a/clang/test/Interpreter/force-codegen-dtor.cpp +++ b/clang/test/Interpreter/force-codegen-dtor.cpp @@ -1,13 +1,17 @@ +// REQUIRES: host-supports-jit // UNSUPPORTED: system-aix // RUN: cat %s | clang-repl | FileCheck %s int *x = new int(); template struct GuardX { T * GuardX(T *) : x(x) {}; ~GuardX(); }; -template GuardX::~GuardX() { delete x; x = nullptr; } -// clang would normally defer codegen for ~GuardX() -// Make sure that RuntimeInterfaceBuilder requests it explicitly +// clang normally defers codegen for this out-of-line ~GuardX(), which would +// cause the JIT to report Symbols not found: [ _ZN6GuardXIiED2Ev ] +extern "C" int printf(const char *, ...); +template GuardX::~GuardX() { delete x; printf("Running dtor\n"); } + +// Let's make sure that the RuntimeInterfaceBuilder requests it explicitly: (GuardX(x)) // CHECK-NOT: Symbols not found -// CHECK-NOT: _ZN6GuardXIiED2Ev +// CHECK: Running dtor From 3ae15adc8adc17a1a9638530c5ae1eea02ed9429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Wed, 24 Apr 2024 10:04:53 +0200 Subject: [PATCH 3/3] Fix: GuardX ctor invocation requires explicit template param --- clang/test/Interpreter/force-codegen-dtor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/Interpreter/force-codegen-dtor.cpp b/clang/test/Interpreter/force-codegen-dtor.cpp index 07758bb3fa0991..783a8b73426c7b 100644 --- a/clang/test/Interpreter/force-codegen-dtor.cpp +++ b/clang/test/Interpreter/force-codegen-dtor.cpp @@ -11,7 +11,7 @@ extern "C" int printf(const char *, ...); template GuardX::~GuardX() { delete x; printf("Running dtor\n"); } // Let's make sure that the RuntimeInterfaceBuilder requests it explicitly: -(GuardX(x)) +(GuardX(x)) // CHECK-NOT: Symbols not found // CHECK: Running dtor ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Test explicit emission of dtors in runtime interface builder (NFC) (PR #89734)
Stefan =?utf-8?q?Gr=C3=A4nitz?= Message-ID: In-Reply-To: https://github.com/vgvassilev approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/89734 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Test explicit emission of dtors in runtime interface builder (NFC) (PR #89734)
https://github.com/weliveindetail updated https://github.com/llvm/llvm-project/pull/89734 From 085a93919d8f65419cc856fe5584c83d3eceb142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Tue, 23 Apr 2024 12:23:11 +0200 Subject: [PATCH 1/2] [clang-repl] Add test for explicit emission of dtors in the runtime interface builder --- clang/test/Interpreter/force-codegen-dtor.cpp | 13 + 1 file changed, 13 insertions(+) create mode 100644 clang/test/Interpreter/force-codegen-dtor.cpp diff --git a/clang/test/Interpreter/force-codegen-dtor.cpp b/clang/test/Interpreter/force-codegen-dtor.cpp new file mode 100644 index 00..a299ea46d5eac0 --- /dev/null +++ b/clang/test/Interpreter/force-codegen-dtor.cpp @@ -0,0 +1,13 @@ +// UNSUPPORTED: system-aix + +// RUN: cat %s | clang-repl | FileCheck %s +int *x = new int(); +template struct GuardX { T * GuardX(T *) : x(x) {}; ~GuardX(); }; +template GuardX::~GuardX() { delete x; x = nullptr; } + +// clang would normally defer codegen for ~GuardX() +// Make sure that RuntimeInterfaceBuilder requests it explicitly +(GuardX(x)) + +// CHECK-NOT: Symbols not found +// CHECK-NOT: _ZN6GuardXIiED2Ev From 6fab67a6cf689c33a93748c66414050dfdf43d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Tue, 23 Apr 2024 14:06:57 +0200 Subject: [PATCH 2/2] Add printf in dtor --- clang/test/Interpreter/force-codegen-dtor.cpp | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/clang/test/Interpreter/force-codegen-dtor.cpp b/clang/test/Interpreter/force-codegen-dtor.cpp index a299ea46d5eac0..07758bb3fa0991 100644 --- a/clang/test/Interpreter/force-codegen-dtor.cpp +++ b/clang/test/Interpreter/force-codegen-dtor.cpp @@ -1,13 +1,17 @@ +// REQUIRES: host-supports-jit // UNSUPPORTED: system-aix // RUN: cat %s | clang-repl | FileCheck %s int *x = new int(); template struct GuardX { T * GuardX(T *) : x(x) {}; ~GuardX(); }; -template GuardX::~GuardX() { delete x; x = nullptr; } -// clang would normally defer codegen for ~GuardX() -// Make sure that RuntimeInterfaceBuilder requests it explicitly +// clang normally defers codegen for this out-of-line ~GuardX(), which would +// cause the JIT to report Symbols not found: [ _ZN6GuardXIiED2Ev ] +extern "C" int printf(const char *, ...); +template GuardX::~GuardX() { delete x; printf("Running dtor\n"); } + +// Let's make sure that the RuntimeInterfaceBuilder requests it explicitly: (GuardX(x)) // CHECK-NOT: Symbols not found -// CHECK-NOT: _ZN6GuardXIiED2Ev +// CHECK: Running dtor ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Test explicit emission of dtors in runtime interface builder (NFC) (PR #89734)
@@ -0,0 +1,13 @@ +// UNSUPPORTED: system-aix + +// RUN: cat %s | clang-repl | FileCheck %s +int *x = new int(); +template struct GuardX { T * GuardX(T *) : x(x) {}; ~GuardX(); }; +template GuardX::~GuardX() { delete x; x = nullptr; } + +// clang would normally defer codegen for ~GuardX() +// Make sure that RuntimeInterfaceBuilder requests it explicitly +(GuardX(x)) + +// CHECK-NOT: Symbols not found +// CHECK-NOT: _ZN6GuardXIiED2Ev vgvassilev wrote: How about a printf in the dtor? https://github.com/llvm/llvm-project/pull/89734 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Test explicit emission of dtors in runtime interface builder (NFC) (PR #89734)
@@ -0,0 +1,13 @@ +// UNSUPPORTED: system-aix + +// RUN: cat %s | clang-repl | FileCheck %s +int *x = new int(); +template struct GuardX { T * GuardX(T *) : x(x) {}; ~GuardX(); }; +template GuardX::~GuardX() { delete x; x = nullptr; } + +// clang would normally defer codegen for ~GuardX() +// Make sure that RuntimeInterfaceBuilder requests it explicitly +(GuardX(x)) + +// CHECK-NOT: Symbols not found +// CHECK-NOT: _ZN6GuardXIiED2Ev weliveindetail wrote: I'd prefer a check like below that is more explicit, but we recognize expressions for value printing (the thing we parse as "semi-missing") only in trailing statements. If we added the code below, then `(GuardX(x))` is not considered trailing anymore, because we pipe he whole file into clang-repl. ``` #include auto x_addr = static_cast(reinterpret_cast(x)); extern "C" int printf(const char *, ...); printf("0x%016" PRIx64 "\n", x_addr); // CHECK: 0x0 ``` https://github.com/llvm/llvm-project/pull/89734 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Test explicit emission of dtors in runtime interface builder (NFC) (PR #89734)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Stefan Gränitz (weliveindetail) Changes This patch adds test coverage for an edge case that is supported already. --- Full diff: https://github.com/llvm/llvm-project/pull/89734.diff 1 Files Affected: - (added) clang/test/Interpreter/force-codegen-dtor.cpp (+13) ``diff diff --git a/clang/test/Interpreter/force-codegen-dtor.cpp b/clang/test/Interpreter/force-codegen-dtor.cpp new file mode 100644 index 00..a299ea46d5eac0 --- /dev/null +++ b/clang/test/Interpreter/force-codegen-dtor.cpp @@ -0,0 +1,13 @@ +// UNSUPPORTED: system-aix + +// RUN: cat %s | clang-repl | FileCheck %s +int *x = new int(); +template struct GuardX { T * GuardX(T *) : x(x) {}; ~GuardX(); }; +template GuardX::~GuardX() { delete x; x = nullptr; } + +// clang would normally defer codegen for ~GuardX() +// Make sure that RuntimeInterfaceBuilder requests it explicitly +(GuardX(x)) + +// CHECK-NOT: Symbols not found +// CHECK-NOT: _ZN6GuardXIiED2Ev `` https://github.com/llvm/llvm-project/pull/89734 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Test explicit emission of dtors in runtime interface builder (NFC) (PR #89734)
https://github.com/weliveindetail created https://github.com/llvm/llvm-project/pull/89734 This patch adds test coverage for an edge case that is supported already. From 085a93919d8f65419cc856fe5584c83d3eceb142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Tue, 23 Apr 2024 12:23:11 +0200 Subject: [PATCH] [clang-repl] Add test for explicit emission of dtors in the runtime interface builder --- clang/test/Interpreter/force-codegen-dtor.cpp | 13 + 1 file changed, 13 insertions(+) create mode 100644 clang/test/Interpreter/force-codegen-dtor.cpp diff --git a/clang/test/Interpreter/force-codegen-dtor.cpp b/clang/test/Interpreter/force-codegen-dtor.cpp new file mode 100644 index 00..a299ea46d5eac0 --- /dev/null +++ b/clang/test/Interpreter/force-codegen-dtor.cpp @@ -0,0 +1,13 @@ +// UNSUPPORTED: system-aix + +// RUN: cat %s | clang-repl | FileCheck %s +int *x = new int(); +template struct GuardX { T * GuardX(T *) : x(x) {}; ~GuardX(); }; +template GuardX::~GuardX() { delete x; x = nullptr; } + +// clang would normally defer codegen for ~GuardX() +// Make sure that RuntimeInterfaceBuilder requests it explicitly +(GuardX(x)) + +// CHECK-NOT: Symbols not found +// CHECK-NOT: _ZN6GuardXIiED2Ev ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits