Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang][bytecode] Ignore explicit calls to trivial dtors #112841

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

tbaederr
Copy link
Contributor

This is what the current interpreter does as well.

This is what the current interpreter does as well.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Oct 18, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 18, 2024

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

This is what the current interpreter does as well.


Full diff: https://github.com/llvm/llvm-project/pull/112841.diff

2 Files Affected:

  • (modified) clang/lib/AST/ByteCode/Compiler.cpp (+4)
  • (modified) clang/test/AST/ByteCode/placement-new.cpp (+13)
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 8ca63bf64aa0ef..a71c0dcc9381e8 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4535,6 +4535,10 @@ bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) {
       return VisitBuiltinCallExpr(E, Builtin::BI__builtin_operator_delete);
     }
   }
+  // Explicit calls to trivial destructors
+  if (const auto *DD = dyn_cast_if_present<CXXDestructorDecl>(FuncDecl);
+      DD && DD->isTrivial())
+    return true;
 
   QualType ReturnType = E->getCallReturnType(Ctx.getASTContext());
   std::optional<PrimType> T = classify(ReturnType);
diff --git a/clang/test/AST/ByteCode/placement-new.cpp b/clang/test/AST/ByteCode/placement-new.cpp
index 8e6d802e93295c..5673b5cba3f700 100644
--- a/clang/test/AST/ByteCode/placement-new.cpp
+++ b/clang/test/AST/ByteCode/placement-new.cpp
@@ -311,3 +311,16 @@ constexpr bool change_union_member() {
   return u.b == 2;
 }
 static_assert(change_union_member());
+
+namespace PR48606 {
+  struct A { mutable int n = 0; };
+
+  constexpr bool f() {
+    A a;
+    A *p = &a;
+    p->~A();
+    std::construct_at<A>(p);
+    return true;
+  }
+  static_assert(f());
+}

@tbaederr tbaederr merged commit 9d0616c into llvm:main Oct 18, 2024
9 of 11 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 18, 2024

LLVM Buildbot has detected a new failure on builder clang-cmake-x86_64-avx512-linux running on avx512-intel64 while building clang at step 7 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/133/builds/5383

Here is the relevant piece of the build log for the reference
Step 7 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'LLVM :: ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/lli -jit-kind=orc-lazy -compile-threads=2 -thread-entry hello /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll | /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
+ /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/lli -jit-kind=orc-lazy -compile-threads=2 -thread-entry hello /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
+ /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
lli: /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/llvm/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h:282: llvm::orc::SymbolStringPool::~SymbolStringPool(): Assertion `Pool.empty() && "Dangling references at pool destruction time"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/lli -jit-kind=orc-lazy -compile-threads=2 -thread-entry hello /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
 #0 0x00000000017d4651 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/lli+0x17d4651)
 #1 0x00000000017d1bb4 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007faf015fcdb0 __restore_rt (/lib64/libc.so.6+0x59db0)
 #3 0x00007faf0164942c __pthread_kill_implementation (/lib64/libc.so.6+0xa642c)
 #4 0x00007faf015fcd06 gsignal (/lib64/libc.so.6+0x59d06)
 #5 0x00007faf015cf7d3 abort (/lib64/libc.so.6+0x2c7d3)
 #6 0x00007faf015cf6fb _nl_load_domain.cold (/lib64/libc.so.6+0x2c6fb)
 #7 0x00007faf015f5c86 (/lib64/libc.so.6+0x52c86)
 #8 0x000000000070c56e (/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/lli+0x70c56e)
 #9 0x0000000001296b4a llvm::orc::ExecutorProcessControl::~ExecutorProcessControl() (/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/lli+0x1296b4a)
#10 0x0000000001296ca4 llvm::orc::SelfExecutorProcessControl::~SelfExecutorProcessControl() (/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/lli+0x1296ca4)
#11 0x00000000011e9bc6 llvm::orc::ExecutionSession::~ExecutionSession() (/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/lli+0x11e9bc6)
#12 0x0000000001229fda llvm::orc::LLJIT::~LLJIT() (/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/lli+0x1229fda)
#13 0x000000000122a171 llvm::orc::LLLazyJIT::~LLLazyJIT() (/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/lli+0x122a171)
#14 0x000000000071e9d8 runOrcJIT(char const*) (/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/lli+0x71e9d8)
#15 0x000000000069277c main (/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/lli+0x69277c)
#16 0x00007faf015e7e50 __libc_start_call_main (/lib64/libc.so.6+0x44e50)
#17 0x00007faf015e7efc __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x44efc)
#18 0x000000000070aa05 _start (/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/lli+0x70aa05)
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck /localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll

--

********************


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants