[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)
Stephen Tozer via cfe-commits
cfe-commits at lists.llvm.org
Fri May 10 01:35:30 PDT 2024
SLTozer wrote:
It looks like this is causing crashes when including precompiled headers that contain optnone functions; this can be reproduced with a very short header file and any source file, even a completely empty one. Reproducer follows:
```
$ cat header.h
__attribute__((optnone)) void foo() {}
$ cat src.cpp
// Empty file
$ ./build/bin/clang -x c++-header header.h -o header.pch
$ ./build/bin/clang -c -include-pch header.pch src.cpp
clang: /home/gbtozers/dev/upstream-llvm/clang/lib/Serialization/ASTReader.cpp:8316: void clang::ASTReader::UpdateSema(): Assertion `*FpPragmaCurrentValue == SemaObj->FpPragmaStack.DefaultValue && "Expected a default pragma float_control value"' failed.
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: ./build/bin/clang -c -include-pch header.pch src.cpp
1. <eof> parser at end of file
#0 0x000055db95a49978 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./build/bin/clang+0x7aa2978)
#1 0x000055db95a474ce llvm::sys::RunSignalHandlers() (./build/bin/clang+0x7aa04ce)
#2 0x000055db959ae1a6 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f1c0f348520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007f1c0f39c9fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007f1c0f39c9fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x00007f1c0f39c9fc pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x00007f1c0f348476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007f1c0f32e7f3 abort ./stdlib/abort.c:81:7
#9 0x00007f1c0f32e71b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007f1c0f33fe96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x000055db967f68db clang::ASTReader::UpdateSema() (./build/bin/clang+0x884f8db)
#12 0x000055db980be50c clang::Sema::Initialize() (./build/bin/clang+0xa11750c)
#13 0x000055db97f7a4e3 clang::Parser::Initialize() (./build/bin/clang+0x9fd34e3)
#14 0x000055db97f75373 clang::ParseAST(clang::Sema&, bool, bool) (./build/bin/clang+0x9fce373)
#15 0x000055db966b20cf clang::FrontendAction::Execute() (./build/bin/clang+0x870b0cf)
#16 0x000055db966212cd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (./build/bin/clang+0x867a2cd)
#17 0x000055db9679971e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (./build/bin/clang+0x87f271e)
#18 0x000055db933468bc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (./build/bin/clang+0x539f8bc)
#19 0x000055db9334325d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#20 0x000055db96467159 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::$_0>(long) Job.cpp:0:0
#21 0x000055db959adee6 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (./build/bin/clang+0x7a06ee6)
#22 0x000055db96466892 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (./build/bin/clang+0x84bf892)
#23 0x000055db9641e954 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (./build/bin/clang+0x8477954)
#24 0x000055db9641ee87 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (./build/bin/clang+0x8477e87)
#25 0x000055db9643fcb8 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (./build/bin/clang+0x8498cb8)
#26 0x000055db93342790 clang_main(int, char**, llvm::ToolContext const&) (./build/bin/clang+0x539b790)
#27 0x000055db93353047 main (./build/bin/clang+0x53ac047)
#28 0x00007f1c0f32fd90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#29 0x00007f1c0f32fe40 call_init ./csu/../csu/libc-start.c:128:20
#30 0x00007f1c0f32fe40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#31 0x000055db93340c25 _start (./build/bin/clang+0x5399c25)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 19.0.0git (https://github.com/llvm/llvm-project.git a04624206ddf03dc54d5c372e7eac13575b4124b)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/gbtozers/dev/upstream-llvm/build/bin
Build config: +assertions
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: /tmp/src-520bcb.cpp
clang: note: diagnostic msg: /tmp/src-520bcb.sh
clang: note: diagnostic msg:
********************
```
https://github.com/llvm/llvm-project/pull/85605
More information about the cfe-commits
mailing list