Skip to content

ICE with alias attribute and placeholder for return type deduction #33335

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

Open
hubert-reinterpretcast opened this issue Jul 29, 2017 · 2 comments
Labels
bugzilla Issues migrated from bugzilla c++14 clang:codegen IR generation bugs: mangling, exceptions, etc. confirmed Verified by a second party crash-on-valid

Comments

@hubert-reinterpretcast
Copy link
Collaborator

hubert-reinterpretcast commented Jul 29, 2017

Bugzilla Link 33988
Version trunk
OS All
CC @AaronBallman,@hfinkel

Extended Description

Clang ICEs when an alias is defined using a placeholder type.

SOURCE ():

extern "C" auto bar() { return 0; }
auto f() __attribute__((__alias__("bar")));

COMPILER INVOCATION:

clang++ -cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o /dev/null -x c++ -std=c++14 -

ACTUAL OUTPUT:

<stdin>:1:17: warning: 'bar' has C-linkage specified, but returns user-defined type 'auto' which is incompatible with C
extern "C" auto bar() { return 0; }
                ^
#&#8203;0 0x00000000019f9454 PrintStackTraceSignalHandler(void*) (/opt/wandbox/clang-head/bin/clang+++0x19f9454)
#&#8203;1 0x00000000019f9726 SignalHandler(int) (/opt/wandbox/clang-head/bin/clang+++0x19f9726)
#&#8203;2 0x00007f3e34096390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#&#8203;3 0x0000000001626c0a llvm::FunctionType::get(llvm::Type*, llvm::ArrayRef<llvm::Type*>, bool) (/opt/wandbox/clang-head/bin/clang+++0x1626c0a)
#&#8203;4 0x0000000001c83e97 clang::CodeGen::CodeGenTypes::GetFunctionType(clang::CodeGen::CGFunctionInfo const&) (/opt/wandbox/clang-head/bin/clang+++0x1c83e97)
#&#8203;5 0x0000000001c127d4 clang::CodeGen::CodeGenTypes::ConvertFunctionType(clang::QualType, clang::FunctionDecl const*) (/opt/wandbox/clang-head/bin/clang+++0x1c127d4)
#&#8203;6 0x0000000001c10df0 clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/opt/wandbox/clang-head/bin/clang+++0x1c10df0)
#&#8203;7 0x0000000001c10be0 clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType) (/opt/wandbox/clang-head/bin/clang+++0x1c10be0)
#&#8203;8 0x0000000001bc9a51 clang::CodeGen::CodeGenModule::EmitAliasDefinition(clang::GlobalDecl) (/opt/wandbox/clang-head/bin/clang+++0x1bc9a51)
#&#8203;9 0x0000000001bccaf6 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/opt/wandbox/clang-head/bin/clang+++0x1bccaf6)
#&#8203;10 0x00000000021c2d8f (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/wandbox/clang-head/bin/clang+++0x21c2d8f)
#&#8203;11 0x00000000021c0553 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/wandbox/clang-head/bin/clang+++0x21c0553)
#&#8203;12 0x000000000264bc74 clang::ParseAST(clang::Sema&, bool, bool) (/opt/wandbox/clang-head/bin/clang+++0x264bc74)
#&#8203;13 0x0000000001ed7f0f clang::FrontendAction::Execute() (/opt/wandbox/clang-head/bin/clang+++0x1ed7f0f)
#&#8203;14 0x0000000001e99ab8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/wandbox/clang-head/bin/clang+++0x1e99ab8)
#&#8203;15 0x0000000001f610ee clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/wandbox/clang-head/bin/clang+++0x1f610ee)
#&#8203;16 0x0000000000851ff2 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/wandbox/clang-head/bin/clang+++0x851ff2)
#&#8203;17 0x0000000000850f18 main (/opt/wandbox/clang-head/bin/clang+++0x850f18)
#&#8203;18 0x00007f3e32e05830 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20830)
#&#8203;19 0x000000000084de79 _start (/opt/wandbox/clang-head/bin/clang+++0x84de79)
Stack dump:
0.      Program arguments: /opt/wandbox/clang-head/bin/clang++ -cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o /dev/null -x c++ -std=c++14 -
1.      <eof> parser at end of file
2.      <stdin>:2:6: LLVM IR generation of declaration 'f'

EXPECTED OUTPUT:

(clean compile)

COMPILER VERSION INFO (clang++ -v):

clang version 6.0.0 (https://github.com/llvm-mirror/clang.git 7617352ce7f8b221d531dce1f95f2ee78e57cfac) (https://github.com/llvm-mirror/llvm.git 38e69b8dcf7aa24ceaf101ea2cde4d1f8f47ecb0)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@llvmbot llvmbot added the confirmed Verified by a second party label Jan 26, 2022
@wheatman
Copy link
Contributor

This still crashes on post 16 trunk(9094b3b)
https://godbolt.org/z/1GqzbP6jz

code

extern "C" auto bar() { return 0; }
auto f() __attribute__((__alias__("bar")));

dump

<source>:1:17: warning: 'bar' has C-linkage specified, but returns user-defined type 'auto' which is incompatible with C [-Wreturn-type-c-linkage]
    1 | extern "C" auto bar() { return 0; }
      |                 ^
undeduced type in IR-generation
UNREACHABLE executed at /root/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:234!
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-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++14 <source>
1.	<eof> parser at end of file
2.	<source>:2:6: LLVM IR generation of declaration 'f'
 #0 0x00000000036df178 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36df178)
 #1 0x00000000036dce3c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36dce3c)
 #2 0x00000000036261f8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f1237e3f420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f123790200b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007f12378e1859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x000000000363149a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x363149a)
 #7 0x0000000003a5d49a clang::CodeGen::CodeGenFunction::getEvaluationKind(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a5d49a)
 #8 0x0000000003bb5d4f clang::CodeGen::isAggregateTypeForABI(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bb5d4f)
 #9 0x0000000003b9ff46 (anonymous namespace)::X86_64ABIInfo::getIndirectReturnResult(clang::QualType) const X86.cpp:0:0
#10 0x0000000003baa58b (anonymous namespace)::X86_64ABIInfo::computeInfo(clang::CodeGen::CGFunctionInfo&) const X86.cpp:0:0
#11 0x0000000003d52aaf clang::CodeGen::CodeGenTypes::arrangeLLVMFunctionInfo(clang::CanQual<clang::Type>, clang::CodeGen::FnInfoOpts, llvm::ArrayRef<clang::CanQual<clang::Type>>, clang::FunctionType::ExtInfo, llvm::ArrayRef<clang::FunctionType::ExtParameterInfo>, clang::CodeGen::RequiredArgs) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d52aaf)
#12 0x0000000003d56799 arrangeLLVMFunctionInfo(clang::CodeGen::CodeGenTypes&, bool, llvm::SmallVectorImpl<clang::CanQual<clang::Type>>&, clang::CanQual<clang::FunctionProtoType>) CGCall.cpp:0:0
#13 0x0000000003d56b9f clang::CodeGen::CodeGenTypes::arrangeFreeFunctionType(clang::CanQual<clang::FunctionProtoType>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d56b9f)
#14 0x0000000003b1a230 clang::CodeGen::CodeGenTypes::ConvertFunctionTypeInternal(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b1a230)
#15 0x0000000003b1b455 clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b1b455)
#16 0x0000000003b1c5e9 clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b1c5e9)
#17 0x0000000003ad1413 clang::CodeGen::CodeGenModule::EmitAliasDefinition(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ad1413)
#18 0x0000000003ace24b clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ace24b)
#19 0x0000000003ad7a23 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#20 0x00000000049437b6 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#21 0x00000000049343c8 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49343c8)
#22 0x0000000005e39364 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5e39364)
#23 0x0000000004940668 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4940668)
#24 0x00000000041a7f39 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41a7f39)
#25 0x0000000004128d3e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4128d3e)
#26 0x000000000428727e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x428727e)
#27 0x0000000000bdaf7e cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbdaf7e)
#28 0x0000000000bd2b0a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#29 0x0000000003f89619 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
#30 0x00000000036266a4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36266a4)
#31 0x0000000003f89c0f 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
#32 0x0000000003f51f55 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f51f55)
#33 0x0000000003f529bd clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f529bd)
#34 0x0000000003f5a8e5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f5a8e5)
#35 0x0000000000bd86ec clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbd86ec)
#36 0x0000000000ad3c51 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xad3c51)
#37 0x00007f12378e3083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#38 0x0000000000bd25ee _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbd25ee)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134

@wheatman wheatman added clang:codegen IR generation bugs: mangling, exceptions, etc. crash-on-valid labels Sep 19, 2023
@llvmbot
Copy link
Member

llvmbot commented Sep 19, 2023

@llvm/issue-subscribers-clang-codegen

| | | | --- | --- | | Bugzilla Link | [33988](https://llvm.org/bz33988) | | Version | trunk | | OS | All | | CC | @AaronBallman,@hfinkel |

Extended Description

Clang ICEs when an alias is defined using a placeholder type.

SOURCE (<stdin>):

extern "C" auto bar() { return 0; }
auto f() attribute((alias("bar")));

COMPILER INVOCATION:

clang++ -cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o /dev/null -x c++ -std=c++14 -

ACTUAL OUTPUT:

<stdin>:1:17: warning: 'bar' has C-linkage specified, but returns user-defined type 'auto' which is incompatible with C
extern "C" auto bar() { return 0; }
^
#&#8203;0 0x00000000019f9454 PrintStackTraceSignalHandler(void*) (/opt/wandbox/clang-head/bin/clang+++0x19f9454)
#&#8203;1 0x00000000019f9726 SignalHandler(int) (/opt/wandbox/clang-head/bin/clang+++0x19f9726)
#&#8203;2 0x00007f3e34096390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#&#8203;3 0x0000000001626c0a llvm::FunctionType::get(llvm::Type*, llvm::ArrayRef<llvm::Type*>, bool) (/opt/wandbox/clang-head/bin/clang+++0x1626c0a)
#&#8203;4 0x0000000001c83e97 clang::CodeGen::CodeGenTypes::GetFunctionType(clang::CodeGen::CGFunctionInfo const&) (/opt/wandbox/clang-head/bin/clang+++0x1c83e97)
#&#8203;5 0x0000000001c127d4 clang::CodeGen::CodeGenTypes::ConvertFunctionType(clang::QualType, clang::FunctionDecl const*) (/opt/wandbox/clang-head/bin/clang+++0x1c127d4)
#&#8203;6 0x0000000001c10df0 clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/opt/wandbox/clang-head/bin/clang+++0x1c10df0)
#&#8203;7 0x0000000001c10be0 clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType) (/opt/wandbox/clang-head/bin/clang+++0x1c10be0)
#&#8203;8 0x0000000001bc9a51 clang::CodeGen::CodeGenModule::EmitAliasDefinition(clang::GlobalDecl) (/opt/wandbox/clang-head/bin/clang+++0x1bc9a51)
#&#8203;9 0x0000000001bccaf6 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/opt/wandbox/clang-head/bin/clang+++0x1bccaf6)
#&#8203;10 0x00000000021c2d8f (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/wandbox/clang-head/bin/clang+++0x21c2d8f)
#&#8203;11 0x00000000021c0553 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/wandbox/clang-head/bin/clang+++0x21c0553)
#&#8203;12 0x000000000264bc74 clang::ParseAST(clang::Sema&, bool, bool) (/opt/wandbox/clang-head/bin/clang+++0x264bc74)
#&#8203;13 0x0000000001ed7f0f clang::FrontendAction::Execute() (/opt/wandbox/clang-head/bin/clang+++0x1ed7f0f)
#&#8203;14 0x0000000001e99ab8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/wandbox/clang-head/bin/clang+++0x1e99ab8)
#&#8203;15 0x0000000001f610ee clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/wandbox/clang-head/bin/clang+++0x1f610ee)
#&#8203;16 0x0000000000851ff2 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/wandbox/clang-head/bin/clang+++0x851ff2)
#&#8203;17 0x0000000000850f18 main (/opt/wandbox/clang-head/bin/clang+++0x850f18)
#&#8203;18 0x00007f3e32e05830 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20830)
#&#8203;19 0x000000000084de79 _start (/opt/wandbox/clang-head/bin/clang+++0x84de79)
Stack dump:
0. Program arguments: /opt/wandbox/clang-head/bin/clang++ -cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o /dev/null -x c++ -std=c++14 -

  1.  &lt;eof&gt; parser at end of file
    
  2.  &lt;stdin&gt;:2:6: LLVM IR generation of declaration 'f'
    

EXPECTED OUTPUT:

(clean compile)

COMPILER VERSION INFO (clang++ -v):

clang version 6.0.0 (https://github.com/llvm-mirror/clang.git 7617352ce7f8b221d531dce1f95f2ee78e57cfac) (https://github.com/llvm-mirror/llvm.git 38e69b8)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++14 clang:codegen IR generation bugs: mangling, exceptions, etc. confirmed Verified by a second party crash-on-valid
Projects
None yet
Development

No branches or pull requests

3 participants