llvm / llvm/llvm-project

avx512vlcd-builtins.c/avx512cd-builtins.c tests sometimes crashing in stage 2 on Arm 32-bit Linux

Open
#172,994 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backend:ARM clang:bytecode test-suite
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

This presumably started with https://github.com/llvm/llvm-project/pull/163293 but it only being a second stage failure (it passes in stage 1) suggests that it is some pre-existing code generation problem.

I reproduced this today with a 2 stage build of main at `db075a8ff73f7ebe87f66680ff64fd033f374ed9`. clang 20.1.8 building a stage 1 clang, then stage 1 clang re-building clang for stage 2.

This crash does not always happen, one example of a crash is https://lab.llvm.org/buildbot/#/builders/79/builds/2531.

```
# .---command stderr------------
# | PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
# | Stack dump:
# | 0. Program arguments: /home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang -cc1 -internal-isystem /home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/lib/clang/22/include -nostdsysteminc -x c++ -flax-vector-conversions=none -ffreestanding /home/tcwg-buildbot/worker/clang-armv7-2stage/llvm/clang/test/CodeGen/X86/avx512cd-builtins.c -triple=x86_64-apple-darwin -target-feature +avx512cd -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter
# | 1. /home/tcwg-buildbot/worker/clang-armv7-2stage/llvm/clang/test/CodeGen/X86/avx512cd-builtins.c:21:1 : current parser token 'static_assert'
# | #0 0x0c6f7100 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x3be7100)
# | #1 0x0c6f4664 llvm::sys::RunSignalHandlers() (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x3be4664)
# | #2 0x0c6f80cc SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
# | #3 0xf00dd6f0 __default_rt_sa_restorer ./signal/../sysdeps/unix/sysv/linux/arm/sigrestorer.S:80:0
# | #4 0x0f9a77bc clang::interp::interp__builtin_ia32_vpconflict(clang::interp::InterpState&, clang::interp::CodePtr, clang::CallExpr const*) InterpBuiltin.cpp:0:0
# | #5 0x0f986d00 clang::interp::InterpretBuiltin(clang::interp::InterpState&, clang::interp::CodePtr, clang::CallExpr const*, unsigned int) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x6e76d00)
# | #6 0x0f9dd00c clang::interp::Interpret(clang::interp::InterpState&) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x6ecd00c)
# | #7 0x0f9e1518 clang::interp::Call(clang::interp::InterpState&, clang::interp::CodePtr, clang::interp::Function const*, unsigned int) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x6ed1518)
# | #8 0x0fc74f78 clang::interp::Compiler::VisitCallExpr(clang::CallExpr const*) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x7164f78)
# | #9 0x0fc763a4 clang::interp::Compiler::visitCallArgs(llvm::ArrayRef, clang::FunctionDecl const*, bool, bool) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x71663a4)
# | #10 0x0fc74da4 clang::interp::Compiler::VisitCallExpr(clang::CallExpr const*) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x7164da4)
# | #11 0x0fc8e1d8 clang::interp::Compiler::visit(clang::Expr const*) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x717e1d8)
# | #12 0x0fc8b1d4 clang::interp::Compiler::visitExpr(clang::Expr const*, bool) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x717b1d4)
# | #13 0x0f86e690 clang::interp::EvalEmitter::interpretExpr(clang::Expr const*, bool, bool) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x6d5e690)
# | #14 0x0f8652a0 clang::interp::Context::evaluateAsRValue(clang::interp::State&, clang::Expr const*, clang::APValue&) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x6d552a0)
# | #15 0x0f7645e4 EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) ExprConstant.cpp:0:0
# | #16 0x0f75fb24 clang::Expr::EvaluateAsRValue(clang::Expr::EvalResult&, clang::ASTContext const&, bool) const (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x6c4fb24)
# | #17 0x0eba6224 clang::Sema::VerifyIntegerConstantExpression(clang::Expr*, llvm::APSInt*, clang::Sema::VerifyICEDiagnoser&, clang::AllowFoldKind) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x6096224)
# | #18 0x0eba31d8 clang::Sema::VerifyIntegerConstantExpression(clang::Expr*, llvm::APSInt*, unsigned int, clang::AllowFoldKind) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x60931d8)
# | #19 0x0eb12e78 clang::Sema::BuildStaticAssertDeclaration(clang::SourceLocation, clang::Expr*, clang::Expr*, clang::SourceLocation, bool) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x6002e78)
# | #20 0x0eb12cf8 clang::Sema::ActOnStaticAssertDeclaration(clang::SourceLocation, clang::Expr*, clang::Expr*, clang::SourceLocation) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x6002cf8)
# | #21 0x0e7768a8 clang::Parser::ParseStaticAssertDeclaration(clang::SourceLocation&) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x5c668a8)
# | #22 0x0e74e998 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x5c3e998)
# | #23 0x0e724f48 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x5c14f48)
# | #24 0x0e722ed8 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x5c12ed8)
# | #25 0x0e7159b0 clang::ParseAST(clang::Sema&, bool, bool) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x5c059b0)
# | #26 0x0d18130c clang::FrontendAction::Execute() (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x467130c)
# | #27 0x0d0f6420 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x45e6420)
# | #28 0x0d26ed34 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0x475ed34)
# | #29 0x0953336c cc1_main(llvm::ArrayRef, char const*, void*) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0xa2336c)
# | #30 0x0952f468 ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
# | #31 0x0952e4cc clang_main(int, char**, llvm::ToolContext const&) (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0xa1e4cc)
# | #32 0x0953ebb4 main (/home/tcwg-buildbot/worker/clang-armv7-2stage/stage2/bin/clang+0xa2ebb4)
# | #33 0xf00cd7d6 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
# | #34 0xf00cd886 call_init ./csu/libc-start.c:128:20
# | #35 0xf00cd886 __libc_start_main ./csu/libc-start.c:379:
```
The stack trace is identical but for specific addresses in both cases.

I have reduced this with creduce to:
```
typedef long long a __attribute__((__vector_size__(32)));
a constexpr c(a e) { return __builtin_ia32_vpconflictdi_256(e); }
a constexpr d(a, char, a e) { return c(e); }
bool f((d({}, 5, {}), 5));
```
Compile command:
```
/home/david.spickett/build-llvm-arm-stage2/bin/clang -cc1 -internal-isystem /home/david.spickett/build-llvm-arm-stage2/lib/clang/22/include -nostdsysteminc -x c++ -flax-vector-conversions=none -ffreestanding bug.c -triple=i386-apple-darwin -target-feature +avx512vl -target-feature +avx512cd -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reduced reproducer and compile command in the issue, then inspect clang::interp::interp__builtin_ia32_vpconflict and the referenced CodeGen/X86/avx512cd-builtins.c and avx512vlcd-builtins.c tests. Compare stage 1 and stage 2 behavior on Arm 32-bit Linux. Done means the reduced case and the affected tests no longer crash during constant evaluation.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, linux
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.