Skip to content

[Clang][OpenMP] Clang crashes with OpenMP reduction pragma #77535

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

Closed
rkchang opened this issue Jan 9, 2024 · 10 comments · Fixed by #84135
Closed

[Clang][OpenMP] Clang crashes with OpenMP reduction pragma #77535

rkchang opened this issue Jan 9, 2024 · 10 comments · Fixed by #84135
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. clang:openmp OpenMP related changes to Clang crash Prefer [crash-on-valid] or [crash-on-invalid] good first issue https://github.com/llvm/llvm-project/contribute

Comments

@rkchang
Copy link
Contributor

rkchang commented Jan 9, 2024

I simplified the arguments a bit and ran it through godbolt: https://godbolt.org/z/W6Y587bKK

Here's the original:
Preprocessed source

# 1 "<built-in>"
# 1 "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c"
int
foo ()
{
  int r = 0;
  #pragma omp scope reduction(+:r)      /* { dg-error "reduction variable 'r' is private in outer context" } */
  r++;
  return r;
}

Run script

# Crash reproducer for clang version 18.0.0git ([email protected]:llvm/llvm-project.git 25e0dc92a1df906d6e42c66a32f1fa764f1acabd)
# Driver args: "-c" "-fopenmp" "-fcrash-diagnostics-dir=trigger/diagnostics" "-fsanitize=undefined,address" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c" "-o" "/tmp/exe_tid7.o"
# Original command:  "/home/rkchang/dev/omp/compilers/llvm_install/bin/clang-18" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-mllvm" "-crash-diagnostics-dir=trigger/diagnostics" "-fcoverage-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-resource-dir" "/home/rkchang/dev/omp/compilers/llvm_install/lib/clang/18" "-internal-isystem" "/home/rkchang/dev/omp/compilers/llvm_install/lib/clang/18/include" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-ferror-limit" "19" "-fopenmp" "-fsanitize=address,alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr" "-fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound,vptr" "-fno-sanitize-memory-param-retval" "-fsanitize-address-use-after-scope" "-fsanitize-address-globals-dead-stripping" "-fno-assume-sane-operator-new" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "/tmp/exe_tid7.o" "-x" "c" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c"
 "/home/rkchang/dev/omp/compilers/llvm_install/bin/clang-18" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-mllvm" "-crash-diagnostics-dir=trigger/diagnostics" "-fcoverage-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-ferror-limit" "19" "-fopenmp" "-fsanitize=address,alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr" "-fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound,vptr" "-fno-sanitize-memory-param-retval" "-fsanitize-address-use-after-scope" "-fsanitize-address-globals-dead-stripping" "-fno-assume-sane-operator-new" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-x" "c" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440-3e7b76.c"
❯ ~/dev/omp/compilers/llvm_install/bin/clang -c -fopenmp -fcrash-diagnostics-dir='trigger/diagnostics' -fsanitize=undefined,address ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c -o /tmp/exe_tid7.o

scope not supported with FE outlining
UNREACHABLE executed at /home/rkchang/dev/omp/compilers/llvm-project/clang/lib/CodeGen/CGStmt.cpp:413!
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/rkchang/dev/omp/compilers/llvm_install/bin/clang -c -fopenmp -fcrash-diagnostics-dir=trigger/diagnostics -fsanitize=undefined,address ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c -o /tmp/exe_tid7.o
1.      <eof> parser at end of file
2.      Per-file LLVM IR generation
3.      ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c:5:1: Generating code for declaration 'foo'
 #0 0x0000563ab1ecab50 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x418db50)
 #1 0x0000563ab1ec7f5f llvm::sys::RunSignalHandlers() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x418af5f)
 #2 0x0000563ab1e0c178 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f0daa242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f0daa2969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f0daa2969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f0daa2969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f0daa242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f0daa2287f3 abort ./stdlib/abort.c:81:7
 #9 0x0000563ab1e167be (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x40d97be)
#10 0x0000563ab22510e9 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x45140e9)
#11 0x0000563ab2257054 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x451a054)
#12 0x0000563ab2224ff5 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44e7ff5)
#13 0x0000563ab2238c54 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44fbc54)
#14 0x0000563ab21deb79 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44a1b79)
#15 0x0000563ab21d8b75 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x449bb75)
#16 0x0000563ab21e400b clang::CodeGen::CodeGenModule::EmitDeferred() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44a700b)
#17 0x0000563ab21e6844 clang::CodeGen::CodeGenModule::Release() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44a9844)
#18 0x0000563ab284e0d2 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#19 0x0000563ab284ca33 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4b0fa33)
#20 0x0000563ab4704409 clang::ParseAST(clang::Sema&, bool, bool) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x69c7409)
#21 0x0000563ab2c2fe39 clang::FrontendAction::Execute() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4ef2e39)
#22 0x0000563ab2ba75d5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4e6a5d5)
#23 0x0000563ab2d0ab95 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4fcdb95)
#24 0x0000563ab091fff9 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2be2ff9)
#25 0x0000563ab0917863 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#26 0x0000563ab29e871d void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#27 0x0000563ab1e0c640 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x40cf640)
#28 0x0000563ab29e8f9e clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#29 0x0000563ab29aa05a clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4c6d05a)
#30 0x0000563ab29aab2d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4c6db2d)
#31 0x0000563ab29b6624 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4c79624)
#32 0x0000563ab091cda0 clang_main(int, char**, llvm::ToolContext const&) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2bdfda0)
#33 0x0000563ab092d343 main (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2bf0343)
#34 0x00007f0daa229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#35 0x00007f0daa229e40 call_init ./csu/../csu/libc-start.c:128:20
#36 0x00007f0daa229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#37 0x0000563ab09164a5 _start (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2bd94a5)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 18.0.0git ([email protected]:llvm/llvm-project.git 25e0dc92a1df906d6e42c66a32f1fa764f1acabd)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/rkchang/dev/omp/compilers/llvm_install/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: trigger/diagnostics/ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440-4ea7e8.c
clang: note: diagnostic msg: trigger/diagnostics/ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440-4ea7e8.sh
clang: note: diagnostic msg: 

********************
@github-actions github-actions bot added the clang Clang issues not falling into any other category label Jan 9, 2024
@EugeneZelenko EugeneZelenko added openmp clang:codegen IR generation bugs: mangling, exceptions, etc. crash Prefer [crash-on-valid] or [crash-on-invalid] and removed clang Clang issues not falling into any other category labels Jan 9, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 9, 2024

@llvm/issue-subscribers-clang-codegen

Author: Raymond Chang (rkchang)

I simplified the arguments a bit and ran it through godbolt: https://godbolt.org/z/W6Y587bKK

Here's the original:
Preprocessed source

# 1 "&lt;built-in&gt;"
# 1 "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c"
int
foo ()
{
  int r = 0;
  #pragma omp scope reduction(+:r)      /* { dg-error "reduction variable 'r' is private in outer context" } */
  r++;
  return r;
}

Run script

# Crash reproducer for clang version 18.0.0git (git@<!-- -->github.com:llvm/llvm-project.git 25e0dc92a1df906d6e42c66a32f1fa764f1acabd)
# Driver args: "-c" "-fopenmp" "-fcrash-diagnostics-dir=trigger/diagnostics" "-fsanitize=undefined,address" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c" "-o" "/tmp/exe_tid7.o"
# Original command:  "/home/rkchang/dev/omp/compilers/llvm_install/bin/clang-18" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-mllvm" "-crash-diagnostics-dir=trigger/diagnostics" "-fcoverage-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-resource-dir" "/home/rkchang/dev/omp/compilers/llvm_install/lib/clang/18" "-internal-isystem" "/home/rkchang/dev/omp/compilers/llvm_install/lib/clang/18/include" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-ferror-limit" "19" "-fopenmp" "-fsanitize=address,alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr" "-fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound,vptr" "-fno-sanitize-memory-param-retval" "-fsanitize-address-use-after-scope" "-fsanitize-address-globals-dead-stripping" "-fno-assume-sane-operator-new" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "/tmp/exe_tid7.o" "-x" "c" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c"
 "/home/rkchang/dev/omp/compilers/llvm_install/bin/clang-18" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-mllvm" "-crash-diagnostics-dir=trigger/diagnostics" "-fcoverage-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-ferror-limit" "19" "-fopenmp" "-fsanitize=address,alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr" "-fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound,vptr" "-fno-sanitize-memory-param-retval" "-fsanitize-address-use-after-scope" "-fsanitize-address-globals-dead-stripping" "-fno-assume-sane-operator-new" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-x" "c" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440-3e7b76.c"
❯ ~/dev/omp/compilers/llvm_install/bin/clang -c -fopenmp -fcrash-diagnostics-dir='trigger/diagnostics' -fsanitize=undefined,address ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c -o /tmp/exe_tid7.o

scope not supported with FE outlining
UNREACHABLE executed at /home/rkchang/dev/omp/compilers/llvm-project/clang/lib/CodeGen/CGStmt.cpp:413!
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/rkchang/dev/omp/compilers/llvm_install/bin/clang -c -fopenmp -fcrash-diagnostics-dir=trigger/diagnostics -fsanitize=undefined,address ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c -o /tmp/exe_tid7.o
1.      &lt;eof&gt; parser at end of file
2.      Per-file LLVM IR generation
3.      ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c:5:1: Generating code for declaration 'foo'
 #<!-- -->0 0x0000563ab1ecab50 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x418db50)
 #<!-- -->1 0x0000563ab1ec7f5f llvm::sys::RunSignalHandlers() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x418af5f)
 #<!-- -->2 0x0000563ab1e0c178 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #<!-- -->3 0x00007f0daa242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->4 0x00007f0daa2969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #<!-- -->5 0x00007f0daa2969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #<!-- -->6 0x00007f0daa2969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #<!-- -->7 0x00007f0daa242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #<!-- -->8 0x00007f0daa2287f3 abort ./stdlib/abort.c:81:7
 #<!-- -->9 0x0000563ab1e167be (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x40d97be)
#<!-- -->10 0x0000563ab22510e9 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef&lt;clang::Attr const*&gt;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x45140e9)
#<!-- -->11 0x0000563ab2257054 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&amp;, bool, clang::CodeGen::AggValueSlot) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x451a054)
#<!-- -->12 0x0000563ab2224ff5 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44e7ff5)
#<!-- -->13 0x0000563ab2238c54 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44fbc54)
#<!-- -->14 0x0000563ab21deb79 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44a1b79)
#<!-- -->15 0x0000563ab21d8b75 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x449bb75)
#<!-- -->16 0x0000563ab21e400b clang::CodeGen::CodeGenModule::EmitDeferred() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44a700b)
#<!-- -->17 0x0000563ab21e6844 clang::CodeGen::CodeGenModule::Release() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44a9844)
#<!-- -->18 0x0000563ab284e0d2 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&amp;) ModuleBuilder.cpp:0:0
#<!-- -->19 0x0000563ab284ca33 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4b0fa33)
#<!-- -->20 0x0000563ab4704409 clang::ParseAST(clang::Sema&amp;, bool, bool) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x69c7409)
#<!-- -->21 0x0000563ab2c2fe39 clang::FrontendAction::Execute() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4ef2e39)
#<!-- -->22 0x0000563ab2ba75d5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4e6a5d5)
#<!-- -->23 0x0000563ab2d0ab95 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4fcdb95)
#<!-- -->24 0x0000563ab091fff9 cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2be2ff9)
#<!-- -->25 0x0000563ab0917863 ExecuteCC1Tool(llvm::SmallVectorImpl&lt;char const*&gt;&amp;, llvm::ToolContext const&amp;) driver.cpp:0:0
#<!-- -->26 0x0000563ab29e871d void llvm::function_ref&lt;void ()&gt;::callback_fn&lt;clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const::'lambda'()&gt;(long) Job.cpp:0:0
#<!-- -->27 0x0000563ab1e0c640 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref&lt;void ()&gt;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x40cf640)
#<!-- -->28 0x0000563ab29e8f9e clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const (.part.0) Job.cpp:0:0
#<!-- -->29 0x0000563ab29aa05a clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4c6d05a)
#<!-- -->30 0x0000563ab29aab2d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;, bool) const (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4c6db2d)
#<!-- -->31 0x0000563ab29b6624 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4c79624)
#<!-- -->32 0x0000563ab091cda0 clang_main(int, char**, llvm::ToolContext const&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2bdfda0)
#<!-- -->33 0x0000563ab092d343 main (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2bf0343)
#<!-- -->34 0x00007f0daa229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#<!-- -->35 0x00007f0daa229e40 call_init ./csu/../csu/libc-start.c:128:20
#<!-- -->36 0x00007f0daa229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#<!-- -->37 0x0000563ab09164a5 _start (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2bd94a5)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 18.0.0git (git@<!-- -->github.com:llvm/llvm-project.git 25e0dc92a1df906d6e42c66a32f1fa764f1acabd)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/rkchang/dev/omp/compilers/llvm_install/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: trigger/diagnostics/ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440-4ea7e8.c
clang: note: diagnostic msg: trigger/diagnostics/ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440-4ea7e8.sh
clang: note: diagnostic msg: 

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

@llvmbot
Copy link
Member

llvmbot commented Jan 9, 2024

@llvm/issue-subscribers-openmp

Author: Raymond Chang (rkchang)

I simplified the arguments a bit and ran it through godbolt: https://godbolt.org/z/W6Y587bKK

Here's the original:
Preprocessed source

# 1 "&lt;built-in&gt;"
# 1 "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c"
int
foo ()
{
  int r = 0;
  #pragma omp scope reduction(+:r)      /* { dg-error "reduction variable 'r' is private in outer context" } */
  r++;
  return r;
}

Run script

# Crash reproducer for clang version 18.0.0git (git@<!-- -->github.com:llvm/llvm-project.git 25e0dc92a1df906d6e42c66a32f1fa764f1acabd)
# Driver args: "-c" "-fopenmp" "-fcrash-diagnostics-dir=trigger/diagnostics" "-fsanitize=undefined,address" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c" "-o" "/tmp/exe_tid7.o"
# Original command:  "/home/rkchang/dev/omp/compilers/llvm_install/bin/clang-18" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-mllvm" "-crash-diagnostics-dir=trigger/diagnostics" "-fcoverage-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-resource-dir" "/home/rkchang/dev/omp/compilers/llvm_install/lib/clang/18" "-internal-isystem" "/home/rkchang/dev/omp/compilers/llvm_install/lib/clang/18/include" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-ferror-limit" "19" "-fopenmp" "-fsanitize=address,alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr" "-fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound,vptr" "-fno-sanitize-memory-param-retval" "-fsanitize-address-use-after-scope" "-fsanitize-address-globals-dead-stripping" "-fno-assume-sane-operator-new" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "/tmp/exe_tid7.o" "-x" "c" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c"
 "/home/rkchang/dev/omp/compilers/llvm_install/bin/clang-18" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-mllvm" "-crash-diagnostics-dir=trigger/diagnostics" "-fcoverage-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-ferror-limit" "19" "-fopenmp" "-fsanitize=address,alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr" "-fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound,vptr" "-fno-sanitize-memory-param-retval" "-fsanitize-address-use-after-scope" "-fsanitize-address-globals-dead-stripping" "-fno-assume-sane-operator-new" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-x" "c" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440-3e7b76.c"
❯ ~/dev/omp/compilers/llvm_install/bin/clang -c -fopenmp -fcrash-diagnostics-dir='trigger/diagnostics' -fsanitize=undefined,address ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c -o /tmp/exe_tid7.o

scope not supported with FE outlining
UNREACHABLE executed at /home/rkchang/dev/omp/compilers/llvm-project/clang/lib/CodeGen/CGStmt.cpp:413!
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/rkchang/dev/omp/compilers/llvm_install/bin/clang -c -fopenmp -fcrash-diagnostics-dir=trigger/diagnostics -fsanitize=undefined,address ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c -o /tmp/exe_tid7.o
1.      &lt;eof&gt; parser at end of file
2.      Per-file LLVM IR generation
3.      ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c:5:1: Generating code for declaration 'foo'
 #<!-- -->0 0x0000563ab1ecab50 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x418db50)
 #<!-- -->1 0x0000563ab1ec7f5f llvm::sys::RunSignalHandlers() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x418af5f)
 #<!-- -->2 0x0000563ab1e0c178 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #<!-- -->3 0x00007f0daa242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->4 0x00007f0daa2969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #<!-- -->5 0x00007f0daa2969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #<!-- -->6 0x00007f0daa2969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #<!-- -->7 0x00007f0daa242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #<!-- -->8 0x00007f0daa2287f3 abort ./stdlib/abort.c:81:7
 #<!-- -->9 0x0000563ab1e167be (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x40d97be)
#<!-- -->10 0x0000563ab22510e9 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef&lt;clang::Attr const*&gt;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x45140e9)
#<!-- -->11 0x0000563ab2257054 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&amp;, bool, clang::CodeGen::AggValueSlot) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x451a054)
#<!-- -->12 0x0000563ab2224ff5 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44e7ff5)
#<!-- -->13 0x0000563ab2238c54 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44fbc54)
#<!-- -->14 0x0000563ab21deb79 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44a1b79)
#<!-- -->15 0x0000563ab21d8b75 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x449bb75)
#<!-- -->16 0x0000563ab21e400b clang::CodeGen::CodeGenModule::EmitDeferred() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44a700b)
#<!-- -->17 0x0000563ab21e6844 clang::CodeGen::CodeGenModule::Release() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44a9844)
#<!-- -->18 0x0000563ab284e0d2 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&amp;) ModuleBuilder.cpp:0:0
#<!-- -->19 0x0000563ab284ca33 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4b0fa33)
#<!-- -->20 0x0000563ab4704409 clang::ParseAST(clang::Sema&amp;, bool, bool) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x69c7409)
#<!-- -->21 0x0000563ab2c2fe39 clang::FrontendAction::Execute() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4ef2e39)
#<!-- -->22 0x0000563ab2ba75d5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4e6a5d5)
#<!-- -->23 0x0000563ab2d0ab95 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4fcdb95)
#<!-- -->24 0x0000563ab091fff9 cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2be2ff9)
#<!-- -->25 0x0000563ab0917863 ExecuteCC1Tool(llvm::SmallVectorImpl&lt;char const*&gt;&amp;, llvm::ToolContext const&amp;) driver.cpp:0:0
#<!-- -->26 0x0000563ab29e871d void llvm::function_ref&lt;void ()&gt;::callback_fn&lt;clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const::'lambda'()&gt;(long) Job.cpp:0:0
#<!-- -->27 0x0000563ab1e0c640 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref&lt;void ()&gt;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x40cf640)
#<!-- -->28 0x0000563ab29e8f9e clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const (.part.0) Job.cpp:0:0
#<!-- -->29 0x0000563ab29aa05a clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4c6d05a)
#<!-- -->30 0x0000563ab29aab2d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;, bool) const (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4c6db2d)
#<!-- -->31 0x0000563ab29b6624 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4c79624)
#<!-- -->32 0x0000563ab091cda0 clang_main(int, char**, llvm::ToolContext const&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2bdfda0)
#<!-- -->33 0x0000563ab092d343 main (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2bf0343)
#<!-- -->34 0x00007f0daa229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#<!-- -->35 0x00007f0daa229e40 call_init ./csu/../csu/libc-start.c:128:20
#<!-- -->36 0x00007f0daa229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#<!-- -->37 0x0000563ab09164a5 _start (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2bd94a5)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 18.0.0git (git@<!-- -->github.com:llvm/llvm-project.git 25e0dc92a1df906d6e42c66a32f1fa764f1acabd)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/rkchang/dev/omp/compilers/llvm_install/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: trigger/diagnostics/ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440-4ea7e8.c
clang: note: diagnostic msg: trigger/diagnostics/ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440-4ea7e8.sh
clang: note: diagnostic msg: 

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

@shiltian
Copy link
Contributor

It looks like the feature is not supported yet but it should never crash.

@shiltian shiltian added clang:openmp OpenMP related changes to Clang good first issue https://github.com/llvm/llvm-project/contribute and removed clang:codegen IR generation bugs: mangling, exceptions, etc. labels Feb 25, 2024
@llvmbot
Copy link
Member

llvmbot commented Feb 25, 2024

Hi!

This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:

  1. In the comments of the issue, request for it to be assigned to you.
  2. Fix the issue locally.
  3. Run the test suite locally. Remember that the subdirectories under test/ create fine-grained testing targets, so you can e.g. use make check-clang-ast to only run Clang's AST tests.
  4. Create a Git commit.
  5. Run git clang-format HEAD~1 to format your changes.
  6. Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation.

If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.

@llvmbot
Copy link
Member

llvmbot commented Feb 25, 2024

@llvm/issue-subscribers-good-first-issue

Author: Raymond Chang (rkchang)

I simplified the arguments a bit and ran it through godbolt: https://godbolt.org/z/W6Y587bKK

Here's the original:
Preprocessed source

# 1 "&lt;built-in&gt;"
# 1 "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c"
int
foo ()
{
  int r = 0;
  #pragma omp scope reduction(+:r)      /* { dg-error "reduction variable 'r' is private in outer context" } */
  r++;
  return r;
}

Run script

# Crash reproducer for clang version 18.0.0git (git@<!-- -->github.com:llvm/llvm-project.git 25e0dc92a1df906d6e42c66a32f1fa764f1acabd)
# Driver args: "-c" "-fopenmp" "-fcrash-diagnostics-dir=trigger/diagnostics" "-fsanitize=undefined,address" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c" "-o" "/tmp/exe_tid7.o"
# Original command:  "/home/rkchang/dev/omp/compilers/llvm_install/bin/clang-18" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-mllvm" "-crash-diagnostics-dir=trigger/diagnostics" "-fcoverage-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-resource-dir" "/home/rkchang/dev/omp/compilers/llvm_install/lib/clang/18" "-internal-isystem" "/home/rkchang/dev/omp/compilers/llvm_install/lib/clang/18/include" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-ferror-limit" "19" "-fopenmp" "-fsanitize=address,alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr" "-fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound,vptr" "-fno-sanitize-memory-param-retval" "-fsanitize-address-use-after-scope" "-fsanitize-address-globals-dead-stripping" "-fno-assume-sane-operator-new" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "/tmp/exe_tid7.o" "-x" "c" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c"
 "/home/rkchang/dev/omp/compilers/llvm_install/bin/clang-18" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-mllvm" "-crash-diagnostics-dir=trigger/diagnostics" "-fcoverage-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-ferror-limit" "19" "-fopenmp" "-fsanitize=address,alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr" "-fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound,vptr" "-fno-sanitize-memory-param-retval" "-fsanitize-address-use-after-scope" "-fsanitize-address-globals-dead-stripping" "-fno-assume-sane-operator-new" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-x" "c" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440-3e7b76.c"
❯ ~/dev/omp/compilers/llvm_install/bin/clang -c -fopenmp -fcrash-diagnostics-dir='trigger/diagnostics' -fsanitize=undefined,address ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c -o /tmp/exe_tid7.o

scope not supported with FE outlining
UNREACHABLE executed at /home/rkchang/dev/omp/compilers/llvm-project/clang/lib/CodeGen/CGStmt.cpp:413!
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/rkchang/dev/omp/compilers/llvm_install/bin/clang -c -fopenmp -fcrash-diagnostics-dir=trigger/diagnostics -fsanitize=undefined,address ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c -o /tmp/exe_tid7.o
1.      &lt;eof&gt; parser at end of file
2.      Per-file LLVM IR generation
3.      ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c:5:1: Generating code for declaration 'foo'
 #<!-- -->0 0x0000563ab1ecab50 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x418db50)
 #<!-- -->1 0x0000563ab1ec7f5f llvm::sys::RunSignalHandlers() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x418af5f)
 #<!-- -->2 0x0000563ab1e0c178 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #<!-- -->3 0x00007f0daa242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->4 0x00007f0daa2969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #<!-- -->5 0x00007f0daa2969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #<!-- -->6 0x00007f0daa2969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #<!-- -->7 0x00007f0daa242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #<!-- -->8 0x00007f0daa2287f3 abort ./stdlib/abort.c:81:7
 #<!-- -->9 0x0000563ab1e167be (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x40d97be)
#<!-- -->10 0x0000563ab22510e9 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef&lt;clang::Attr const*&gt;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x45140e9)
#<!-- -->11 0x0000563ab2257054 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&amp;, bool, clang::CodeGen::AggValueSlot) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x451a054)
#<!-- -->12 0x0000563ab2224ff5 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44e7ff5)
#<!-- -->13 0x0000563ab2238c54 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44fbc54)
#<!-- -->14 0x0000563ab21deb79 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44a1b79)
#<!-- -->15 0x0000563ab21d8b75 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x449bb75)
#<!-- -->16 0x0000563ab21e400b clang::CodeGen::CodeGenModule::EmitDeferred() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44a700b)
#<!-- -->17 0x0000563ab21e6844 clang::CodeGen::CodeGenModule::Release() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44a9844)
#<!-- -->18 0x0000563ab284e0d2 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&amp;) ModuleBuilder.cpp:0:0
#<!-- -->19 0x0000563ab284ca33 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4b0fa33)
#<!-- -->20 0x0000563ab4704409 clang::ParseAST(clang::Sema&amp;, bool, bool) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x69c7409)
#<!-- -->21 0x0000563ab2c2fe39 clang::FrontendAction::Execute() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4ef2e39)
#<!-- -->22 0x0000563ab2ba75d5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4e6a5d5)
#<!-- -->23 0x0000563ab2d0ab95 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4fcdb95)
#<!-- -->24 0x0000563ab091fff9 cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2be2ff9)
#<!-- -->25 0x0000563ab0917863 ExecuteCC1Tool(llvm::SmallVectorImpl&lt;char const*&gt;&amp;, llvm::ToolContext const&amp;) driver.cpp:0:0
#<!-- -->26 0x0000563ab29e871d void llvm::function_ref&lt;void ()&gt;::callback_fn&lt;clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const::'lambda'()&gt;(long) Job.cpp:0:0
#<!-- -->27 0x0000563ab1e0c640 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref&lt;void ()&gt;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x40cf640)
#<!-- -->28 0x0000563ab29e8f9e clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const (.part.0) Job.cpp:0:0
#<!-- -->29 0x0000563ab29aa05a clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4c6d05a)
#<!-- -->30 0x0000563ab29aab2d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;, bool) const (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4c6db2d)
#<!-- -->31 0x0000563ab29b6624 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4c79624)
#<!-- -->32 0x0000563ab091cda0 clang_main(int, char**, llvm::ToolContext const&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2bdfda0)
#<!-- -->33 0x0000563ab092d343 main (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2bf0343)
#<!-- -->34 0x00007f0daa229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#<!-- -->35 0x00007f0daa229e40 call_init ./csu/../csu/libc-start.c:128:20
#<!-- -->36 0x00007f0daa229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#<!-- -->37 0x0000563ab09164a5 _start (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2bd94a5)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 18.0.0git (git@<!-- -->github.com:llvm/llvm-project.git 25e0dc92a1df906d6e42c66a32f1fa764f1acabd)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/rkchang/dev/omp/compilers/llvm_install/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: trigger/diagnostics/ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440-4ea7e8.c
clang: note: diagnostic msg: trigger/diagnostics/ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440-4ea7e8.sh
clang: note: diagnostic msg: 

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

@shiltian shiltian changed the title Clang trunk crashes with OpenMP reduction pragma [Clang][OpenMP] Clang crashes with OpenMP reduction pragma Feb 25, 2024
@EugeneZelenko EugeneZelenko added clang:codegen IR generation bugs: mangling, exceptions, etc. and removed openmp labels Feb 25, 2024
@llvmbot
Copy link
Member

llvmbot commented Feb 25, 2024

@llvm/issue-subscribers-clang-codegen

Author: Raymond Chang (rkchang)

I simplified the arguments a bit and ran it through godbolt: https://godbolt.org/z/W6Y587bKK

Here's the original:
Preprocessed source

# 1 "&lt;built-in&gt;"
# 1 "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c"
int
foo ()
{
  int r = 0;
  #pragma omp scope reduction(+:r)      /* { dg-error "reduction variable 'r' is private in outer context" } */
  r++;
  return r;
}

Run script

# Crash reproducer for clang version 18.0.0git (git@<!-- -->github.com:llvm/llvm-project.git 25e0dc92a1df906d6e42c66a32f1fa764f1acabd)
# Driver args: "-c" "-fopenmp" "-fcrash-diagnostics-dir=trigger/diagnostics" "-fsanitize=undefined,address" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c" "-o" "/tmp/exe_tid7.o"
# Original command:  "/home/rkchang/dev/omp/compilers/llvm_install/bin/clang-18" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-mllvm" "-crash-diagnostics-dir=trigger/diagnostics" "-fcoverage-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-resource-dir" "/home/rkchang/dev/omp/compilers/llvm_install/lib/clang/18" "-internal-isystem" "/home/rkchang/dev/omp/compilers/llvm_install/lib/clang/18/include" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-ferror-limit" "19" "-fopenmp" "-fsanitize=address,alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr" "-fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound,vptr" "-fno-sanitize-memory-param-retval" "-fsanitize-address-use-after-scope" "-fsanitize-address-globals-dead-stripping" "-fno-assume-sane-operator-new" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "/tmp/exe_tid7.o" "-x" "c" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c"
 "/home/rkchang/dev/omp/compilers/llvm_install/bin/clang-18" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-mllvm" "-crash-diagnostics-dir=trigger/diagnostics" "-fcoverage-compilation-dir=/home/rkchang/dev/omp/trigger/clang" "-ferror-limit" "19" "-fopenmp" "-fsanitize=address,alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr" "-fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound,vptr" "-fno-sanitize-memory-param-retval" "-fsanitize-address-use-after-scope" "-fsanitize-address-globals-dead-stripping" "-fno-assume-sane-operator-new" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-x" "c" "ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440-3e7b76.c"
❯ ~/dev/omp/compilers/llvm_install/bin/clang -c -fopenmp -fcrash-diagnostics-dir='trigger/diagnostics' -fsanitize=undefined,address ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c -o /tmp/exe_tid7.o

scope not supported with FE outlining
UNREACHABLE executed at /home/rkchang/dev/omp/compilers/llvm-project/clang/lib/CodeGen/CGStmt.cpp:413!
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/rkchang/dev/omp/compilers/llvm_install/bin/clang -c -fopenmp -fcrash-diagnostics-dir=trigger/diagnostics -fsanitize=undefined,address ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c -o /tmp/exe_tid7.o
1.      &lt;eof&gt; parser at end of file
2.      Per-file LLVM IR generation
3.      ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440.c:5:1: Generating code for declaration 'foo'
 #<!-- -->0 0x0000563ab1ecab50 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x418db50)
 #<!-- -->1 0x0000563ab1ec7f5f llvm::sys::RunSignalHandlers() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x418af5f)
 #<!-- -->2 0x0000563ab1e0c178 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #<!-- -->3 0x00007f0daa242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->4 0x00007f0daa2969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #<!-- -->5 0x00007f0daa2969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #<!-- -->6 0x00007f0daa2969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #<!-- -->7 0x00007f0daa242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #<!-- -->8 0x00007f0daa2287f3 abort ./stdlib/abort.c:81:7
 #<!-- -->9 0x0000563ab1e167be (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x40d97be)
#<!-- -->10 0x0000563ab22510e9 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef&lt;clang::Attr const*&gt;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x45140e9)
#<!-- -->11 0x0000563ab2257054 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&amp;, bool, clang::CodeGen::AggValueSlot) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x451a054)
#<!-- -->12 0x0000563ab2224ff5 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44e7ff5)
#<!-- -->13 0x0000563ab2238c54 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44fbc54)
#<!-- -->14 0x0000563ab21deb79 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44a1b79)
#<!-- -->15 0x0000563ab21d8b75 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x449bb75)
#<!-- -->16 0x0000563ab21e400b clang::CodeGen::CodeGenModule::EmitDeferred() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44a700b)
#<!-- -->17 0x0000563ab21e6844 clang::CodeGen::CodeGenModule::Release() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x44a9844)
#<!-- -->18 0x0000563ab284e0d2 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&amp;) ModuleBuilder.cpp:0:0
#<!-- -->19 0x0000563ab284ca33 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4b0fa33)
#<!-- -->20 0x0000563ab4704409 clang::ParseAST(clang::Sema&amp;, bool, bool) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x69c7409)
#<!-- -->21 0x0000563ab2c2fe39 clang::FrontendAction::Execute() (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4ef2e39)
#<!-- -->22 0x0000563ab2ba75d5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4e6a5d5)
#<!-- -->23 0x0000563ab2d0ab95 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4fcdb95)
#<!-- -->24 0x0000563ab091fff9 cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2be2ff9)
#<!-- -->25 0x0000563ab0917863 ExecuteCC1Tool(llvm::SmallVectorImpl&lt;char const*&gt;&amp;, llvm::ToolContext const&amp;) driver.cpp:0:0
#<!-- -->26 0x0000563ab29e871d void llvm::function_ref&lt;void ()&gt;::callback_fn&lt;clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const::'lambda'()&gt;(long) Job.cpp:0:0
#<!-- -->27 0x0000563ab1e0c640 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref&lt;void ()&gt;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x40cf640)
#<!-- -->28 0x0000563ab29e8f9e clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const (.part.0) Job.cpp:0:0
#<!-- -->29 0x0000563ab29aa05a clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4c6d05a)
#<!-- -->30 0x0000563ab29aab2d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;, bool) const (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4c6db2d)
#<!-- -->31 0x0000563ab29b6624 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x4c79624)
#<!-- -->32 0x0000563ab091cda0 clang_main(int, char**, llvm::ToolContext const&amp;) (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2bdfda0)
#<!-- -->33 0x0000563ab092d343 main (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2bf0343)
#<!-- -->34 0x00007f0daa229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#<!-- -->35 0x00007f0daa229e40 call_init ./csu/../csu/libc-start.c:128:20
#<!-- -->36 0x00007f0daa229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#<!-- -->37 0x0000563ab09164a5 _start (/home/rkchang/dev/omp/compilers/llvm_install/bin/clang+0x2bd94a5)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 18.0.0git (git@<!-- -->github.com:llvm/llvm-project.git 25e0dc92a1df906d6e42c66a32f1fa764f1acabd)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/rkchang/dev/omp/compilers/llvm_install/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: trigger/diagnostics/ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440-4ea7e8.c
clang: note: diagnostic msg: trigger/diagnostics/ret134_8bb3be45-13a1-47e9-a46d-089a2e34d440-4ea7e8.sh
clang: note: diagnostic msg: 

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

@Puellaquae
Copy link
Contributor

I'm new to LLVM and interested in working on this issue. Should it result in a compilation error?

@shiltian
Copy link
Contributor

shiltian commented Mar 5, 2024

I'm new to LLVM and interested in working on this issue. Should it result in a compilation error?

Yes.

Puellaquae added a commit to Puellaquae/llvm-project that referenced this issue Mar 6, 2024
@Puellaquae
Copy link
Contributor

I have transformed this assertion into an error. Should I also write a test case for it? In addition, I have noticed that there are four other assertions due to features not being supported yet. I'm uncertain how to reproduce these assertions. Should I also convert these into errors?

@shiltian
Copy link
Contributor

shiltian commented Mar 6, 2024

Yes, get a test case when you submit your PR.

I'd prefer to keep them separated.

efriedma-quic pushed a commit that referenced this issue Jun 9, 2024
…ScopeDirectiveClass case (#77535) (#84135)

Fix #77535, Change unstable assertion into compilation error, and add a
test for it.
@HerrCai0907 HerrCai0907 mentioned this issue Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. clang:openmp OpenMP related changes to Clang crash Prefer [crash-on-valid] or [crash-on-invalid] good first issue https://github.com/llvm/llvm-project/contribute
Projects
None yet
5 participants