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

ICE when code contains if consteval and coverage report is enabled #57377

Closed
hanickadot opened this issue Aug 26, 2022 · 17 comments · Fixed by llvm/llvm-project-release-prs#148
Closed

Comments

@hanickadot
Copy link
Contributor

hanickadot commented Aug 26, 2022

https://compiler-explorer.com/z/EoTeeTnEn

constexpr int foo() {
    if consteval {
        return 42;
    } else {
        return 0;
    }
}

int main() {
    return foo();
}

crashes in 14 and current main

crash:

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: /opt/compiler-explorer/clang-14.0.0/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-11.2.0 -fcolor-diagnostics -fno-crash-diagnostics -std=c++2b -fprofile-instr-generate -fcoverage-mapping <source>
1.	<eof> parser at end of file
2.	Per-file LLVM IR generation
3.	<source>:1:15: Generating code for declaration 'foo'
 #0 0x000055eace97de8f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x000055eace97bd60 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x357bd60)
 #2 0x000055eace8b6b78 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007ffaa60c5420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x000055ead153764f clang::Stmt::getBeginLoc() const (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x613764f)
 #5 0x000055eacedf2a8f (anonymous namespace)::CoverageMappingBuilder::getStart(clang::Stmt const*) CoverageMappingGen.cpp:0:0
 #6 0x000055eacedf7b63 (anonymous namespace)::CounterCoverageMappingBuilder::extendRegion(clang::Stmt const*) CoverageMappingGen.cpp:0:0
 #7 0x000055eacedfaee8 clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::CounterCoverageMappingBuilder, void>::Visit(clang::Stmt const*) CoverageMappingGen.cpp:0:0
 #8 0x000055eacedfb82b (anonymous namespace)::CounterCoverageMappingBuilder::VisitStmt(clang::Stmt const*) CoverageMappingGen.cpp:0:0
 #9 0x000055eacedfa11e clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::CounterCoverageMappingBuilder, void>::Visit(clang::Stmt const*) CoverageMappingGen.cpp:0:0
#10 0x000055eacee001ee clang::CodeGen::CoverageMappingGen::emitCounterMapping(clang::Decl const*, llvm::raw_ostream&) (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x3a001ee)
#11 0x000055eacedc05d4 clang::CodeGen::CodeGenPGO::emitCounterRegionMapping(clang::Decl const*) (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x39c05d4)
#12 0x000055eacede4134 clang::CodeGen::CodeGenPGO::assignRegionCounters(clang::GlobalDecl, llvm::Function*) (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x39e4134)
#13 0x000055eaced6fe12 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x396fe12)
#14 0x000055eacedb6918 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x39b6918)
#15 0x000055eacedb3a55 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x39b3a55)
#16 0x000055eacedbaf43 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x39baf43)
#17 0x000055eacedbbd4c clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x39bbd4c)
#18 0x000055eacf907787 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#19 0x000055eacf90551d clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x450551d)
#20 0x000055ead079aa79 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x539aa79)
#21 0x000055eacf905b02 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x4505b02)
#22 0x000055eacf301161 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x3f01161)
#23 0x000055eacf29c2f2 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x3e9c2f2)
#24 0x000055eacf3cc853 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x3fcc853)
#25 0x000055eacc59b1d4 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x119b1d4)
#26 0x000055eacc59718d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#27 0x000055eacf1375f5 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#28 0x000055eace8b7163 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x34b7163)
#29 0x000055eacf1396c8 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x3d396c8)
#30 0x000055eacf10cb1a clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x3d0cb1a)
#31 0x000055eacf10d65f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x3d0d65f)
#32 0x000055eacf116005 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x3d16005)
#33 0x000055eacc4a80b2 main (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x10a80b2)
#34 0x00007ffaa5b73083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#35 0x000055eacc596d0a _start (/opt/compiler-explorer/clang-14.0.0/bin/clang+++0x1196d0a)
clang-14: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
@hanickadot hanickadot changed the title clang 14 & current main crashes when code cotains if consteval and coverage report is enabled ICE when code contains if consteval and coverage report is enabled Aug 26, 2022
@cor3ntin cor3ntin added clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party c++23 labels Aug 26, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 26, 2022

@llvm/issue-subscribers-clang-frontend

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 26, 2022

@llvm/issue-subscribers-c-2b

@cor3ntin cor3ntin added coverage and removed clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Aug 26, 2022
@cor3ntin
Copy link
Contributor

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 26, 2022

@llvm/issue-subscribers-clang-codegen

@cor3ntin cor3ntin added this to the LLVM 15.0.0 Release milestone Aug 26, 2022
@cor3ntin
Copy link
Contributor

/cherry-pick 463e30f

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 26, 2022

Failed to cherry-pick: 463e30f

https://github.com/llvm/llvm-project/actions/runs/2934968042

Please manually backport the fix and push it to your github fork. Once this is done, please add a comment like this:

/branch <user>/<repo>/<branch>

@cor3ntin
Copy link
Contributor

/branch cor3ntin/llvm-project/corentin/fix_ice_in_constexpr_coverage_backport

@tru
Copy link
Collaborator

tru commented Aug 28, 2022

@cor3ntin what's the state of this issue? I think your branch command failed because your own branch contains / (without checking the code). Is this important to get into 15.0.0-final or can it wait for 15.0.1?

@cor3ntin
Copy link
Contributor

If we can get it sooner, great. Otherwise i guess it will have to wait, i won't be able to rename the branch for a while - unless there is a web UI to do that.

@tru
Copy link
Collaborator

tru commented Aug 28, 2022

I can try pulling it over to my fork.

@tru
Copy link
Collaborator

tru commented Aug 28, 2022

/branch tru/llvm-project/fix_ice_in_constexpr_coverage_backport

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 28, 2022

/pull-request llvm/llvm-project-release-prs#132

@tru
Copy link
Collaborator

tru commented Aug 29, 2022

Fix merge problems:

/branch tru/llvm-project/fix_ice_in_constexpr_coverage_backport

@tru
Copy link
Collaborator

tru commented Aug 29, 2022

After discussion in llvm/llvm-project-release-prs#132 - I will move this fix to 15.0.1.

@tru tru modified the milestones: LLVM 15.0.0 Release, LLVM 15.0.1 Aug 29, 2022
cor3ntin added a commit to cor3ntin/llvm-project that referenced this issue Sep 8, 2022
Clang crashes when encountering an `if consteval` statement.
This is the minimum fix not to crash.
The fix is consistent with the current behavior of if constexpr,
which does generate coverage data for the discarded branches.
This is of course not correct and a better solution is
needed for both if constexpr and if consteval.
See llvm#54419.

Fixes llvm#57377

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D132723
@cor3ntin
Copy link
Contributor

cor3ntin commented Sep 8, 2022

/branch cor3ntin/llvm-project/fix_ice_in_constexpr_coverage_backport

1 similar comment
@cor3ntin
Copy link
Contributor

cor3ntin commented Sep 8, 2022

/branch cor3ntin/llvm-project/fix_ice_in_constexpr_coverage_backport

@llvmbot
Copy link
Collaborator

llvmbot commented Sep 8, 2022

/pull-request llvm/llvm-project-release-prs#148

tru pushed a commit that referenced this issue Sep 12, 2022
Clang crashes when encountering an `if consteval` statement.
This is the minimum fix not to crash.
The fix is consistent with the current behavior of if constexpr,
which does generate coverage data for the discarded branches.
This is of course not correct and a better solution is
needed for both if constexpr and if consteval.
See #54419.

Fixes #57377

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D132723
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
5 participants