HEAD compilation causes gcc internal error

This is gcc4.8.0 compiling HEAD synced on July 22:

/llvm-clang-trunk/src/lib/Transforms/Utils/SimplifyCFG.cpp: In lambda function:
/llvm-clang-trunk/src/lib/Transforms/Utils/SimplifyCFG.cpp:2547:22: internal compiler error: Segmentation fault
return Operator::getOpcode(&I) == Instruction::BitCast &&
^
0x8a11bf crash_signal
…/…/…/src/lnx64/gcc/toplev.c:332
0x59d41e lookup_base(tree_node*, tree_node*, int, base_kind*, int)
…/…/…/src/lnx64/gcc/cp/search.c:199
0x5a968b finish_qualified_id_expr(tree_node*, tree_node*, bool, bool, bool, bool)
…/…/…/src/lnx64/gcc/cp/semantics.c:1786
0x5aa19c finish_id_expression(tree_node*, tree_node*, tree_node*, cp_id_kind*, bool, bool, bool*, bool, bool, bool, bool, char const**, unsigned int)
…/…/…/src/lnx64/gcc/cp/semantics.c:3348
0x558dfd cp_parser_primary_expression
…/…/…/src/lnx64/gcc/cp/parser.c:4394
0x5607e2 cp_parser_postfix_expression
…/…/…/src/lnx64/gcc/cp/parser.c:5629
0x55f14a cp_parser_unary_expression
…/…/…/src/lnx64/gcc/cp/parser.c:6685
0x564007 cp_parser_binary_expression
…/…/…/src/lnx64/gcc/cp/parser.c:7365
0x5644a5 cp_parser_assignment_expression
…/…/…/src/lnx64/gcc/cp/parser.c:7590
0x566052 cp_parser_expression
…/…/…/src/lnx64/gcc/cp/parser.c:7741
0x5598b2 cp_parser_lambda_body
…/…/…/src/lnx64/gcc/cp/parser.c:8632
0x5598b2 cp_parser_lambda_expression
…/…/…/src/lnx64/gcc/cp/parser.c:8194
0x5598b2 cp_parser_primary_expression
…/…/…/src/lnx64/gcc/cp/parser.c:4085
0x5607e2 cp_parser_postfix_expression
…/…/…/src/lnx64/gcc/cp/parser.c:5629
0x55f14a cp_parser_unary_expression
…/…/…/src/lnx64/gcc/cp/parser.c:6685
0x564007 cp_parser_binary_expression
…/…/…/src/lnx64/gcc/cp/parser.c:7365
0x5644a5 cp_parser_assignment_expression
…/…/…/src/lnx64/gcc/cp/parser.c:7590
0x5648c2 cp_parser_constant_expression
…/…/…/src/lnx64/gcc/cp/parser.c:7821
0x57310c cp_parser_init_declarator
…/…/…/src/lnx64/gcc/cp/parser.c:15991
0x57362e cp_parser_simple_declaration
…/…/…/src/lnx64/gcc/cp/parser.c:10567
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

My guess is that you're better off posting this to the GCC mailing list.
It's not LLVM's fault GCC crashed on this. On the other hand, you might
want to try reproducing this with a more recent compiler before
announcing the issue on the GCC side.

Sure this is more likely a gcc bug. However, same toolchain compiled without any problems a week ago. Also, in some organizations, upgrading gcc is very hard if not impossible.

We can definitely accept a non-invasive patch to work around the issue. GCC 4.8 is definitely inside our toolchain support window.

After worked around the problem in SimplifyCFG.cpp (calling isCast() instead of comparing opcode), I hit another gcc crash for FunctionImport.cpp line 480, which I have no idea what’s wrong with the code. “Luckily”, I found gcc4.8.2 and gave it a try, both crashes are gone.

New problem though:

/llvm-clang-trunk/src/tools/clang/lib/CodeGen/CGBuiltin.cpp: In member function ?llvm::Value* clang::CodeGen::CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned int, const clang::CallExpr*)?:
/llvm-clang-trunk/src/tools/clang/lib/CodeGen/CGBuiltin.cpp:7283:39: error: ?r600_rsq? is not a member of ?llvm::Intrinsic?
return emitUnaryBuiltin(*this, E, Intrinsic::r600_rsq);
^
/llvm-clang-trunk/src/tools/clang/lib/CodeGen/CGBuiltin.cpp:7289:39: error: ?AMDGPU_ldexp? is not a member of ?llvm::Intrinsic?
return emitFPIntBuiltin(*this, E, Intrinsic::AMDGPU_ldexp);
^

Actually, if I didn’t configure to target AMDGPU, why bothering compiling these code?

Your clang is out of date. Intrinsics for all targets for now are included in every build

Ah, thanks Matt! Forgot that.