<div dir="ltr">FYI :)<div><br><div>Here is the back trace when emitting the error:<div><div><br></div><div>  * frame #0: 0x000000010271ea30 clang`clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(this=0x00007fff5fbf8c58, FD=0x000000010f214260, BuiltinID=1483, E=0x000000010f214500, ReturnValue=ReturnValueSlot at 0x00007fff5fbf5fe0) + 49360 at CGBuiltin.cpp:2033</div><div>    frame #1: 0x000000010283f76f clang`clang::CodeGen::CodeGenFunction::EmitCallExpr(this=0x00007fff5fbf8c58, E=0x000000010f214500, ReturnValue=ReturnValueSlot at 0x00007fff5fbf6990) + 447 at CGExpr.cpp:3506</div><div>    frame #2: 0x000000010288ae23 clang`(anonymous namespace)::ScalarExprEmitter::VisitCallExpr(this=0x00007fff5fbf7380, E=0x000000010f214500) + 163 at CGExprScalar.cpp:326</div><div>    frame #3: 0x0000000102885d52 clang`clang::StmtVisitorBase<clang::make_ptr, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(this=0x00007fff5fbf7380, S=0x000000010f214500) + 2866 at StmtNodes.inc:311</div><div>    frame #4: 0x000000010287f479 clang`(anonymous namespace)::ScalarExprEmitter::Visit(this=0x00007fff5fbf7380, E=0x000000010f214500) + 73 at CGExprScalar.cpp:205</div><div>    frame #5: 0x0000000102892a4f clang`(anonymous namespace)::ScalarExprEmitter::VisitCastExpr(this=0x00007fff5fbf7380, CE=0x000000010f214548) + 655 at CGExprScalar.cpp:1391</div><div>    frame #6: 0x00000001028927ae clang`(anonymous namespace)::ScalarExprEmitter::VisitExplicitCastExpr(this=0x00007fff5fbf7380, E=0x000000010f214548) + 62 at CGExprScalar.cpp:318</div><div>    frame #7: 0x000000010288af48 clang`clang::StmtVisitorBase<clang::make_ptr, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::VisitCStyleCastExpr(this=0x00007fff5fbf7380, S=0x000000010f214548) + 40 at StmtNodes.inc:351</div><div>    frame #8: 0x0000000102885dde clang`clang::StmtVisitorBase<clang::make_ptr, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(this=0x00007fff5fbf7380, S=0x000000010f214548) + 3006 at StmtNodes.inc:351</div><div>    frame #9: 0x000000010287f479 clang`(anonymous namespace)::ScalarExprEmitter::Visit(this=0x00007fff5fbf7380, E=0x000000010f214548) + 73 at CGExprScalar.cpp:205</div><div>    frame #10: 0x000000010287f3e0 clang`clang::CodeGen::CodeGenFunction::EmitScalarExpr(this=0x00007fff5fbf8c58, E=0x000000010f214548, IgnoreResultAssign=false) + 192 at CGExprScalar.cpp:3463</div><div>    frame #11: 0x0000000102828146 clang`clang::CodeGen::CodeGenFunction::EmitAnyExprToMem(this=0x00007fff5fbf8c58, E=0x000000010f214548, Location=Address at 0x00007fff5fbf7630, Quals=(Mask = 0), IsInit=false) + 502 at CGExpr.cpp:188</div><div>    frame #12: 0x0000000102969778 clang`clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(this=0x00007fff5fbf8c58, S=0x000000010f214570, GetLast=true, AggSlot=AggValueSlot at 0x00007fff5fbf7700) + 552 at CGStmt.cpp:327</div><div>    frame #13: 0x00000001029688e9 clang`clang::CodeGen::CodeGenFunction::EmitCompoundStmt(this=0x00007fff5fbf8c58, S=0x000000010f214570, GetLast=true, AggSlot=AggValueSlot at 0x00007fff5fbf77d0) + 297 at CGStmt.cpp:293</div><div>    frame #14: 0x000000010288e9e5 clang`(anonymous namespace)::ScalarExprEmitter::VisitStmtExpr(this=0x00007fff5fbf8410, E=0x000000010f214598) + 197 at CGExprScalar.cpp:1598</div><div>    frame #15: 0x000000010288646e clang`clang::StmtVisitorBase<clang::make_ptr, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(this=0x00007fff5fbf8410, S=0x000000010f214598) + 4686 at StmtNodes.inc:735</div><div>    frame #16: 0x000000010287f479 clang`(anonymous namespace)::ScalarExprEmitter::Visit(this=0x00007fff5fbf8410, E=0x000000010f214598) + 73 at CGExprScalar.cpp:205</div><div>    frame #17: 0x0000000102889df0 clang`(anonymous namespace)::ScalarExprEmitter::VisitUnaryExtension(this=0x00007fff5fbf8410, E=0x000000010f2145b8) + 48 at CGExprScalar.cpp:382</div><div>    frame #18: 0x00000001028857bb clang`clang::StmtVisitorBase<clang::make_ptr, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(this=0x00007fff5fbf8410, S=0x000000010f2145b8) + 1435 at StmtVisitor.h:96</div><div>    frame #19: 0x000000010287f479 clang`(anonymous namespace)::ScalarExprEmitter::Visit(this=0x00007fff5fbf8410, E=0x000000010f2145b8) + 73 at CGExprScalar.cpp:205</div><div>    frame #20: 0x0000000102892a4f clang`(anonymous namespace)::ScalarExprEmitter::VisitCastExpr(this=0x00007fff5fbf8410, CE=0x000000010f2145d8) + 655 at CGExprScalar.cpp:1391</div><div>    frame #21: 0x000000010288b098 clang`clang::StmtVisitorBase<clang::make_ptr, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::VisitImplicitCastExpr(this=0x00007fff5fbf8410, S=0x000000010f2145d8) + 40 at StmtNodes.inc:405</div><div>    frame #22: 0x0000000102885ea2 clang`clang::StmtVisitorBase<clang::make_ptr, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(this=0x00007fff5fbf8410, S=0x000000010f2145d8) + 3202 at StmtNodes.inc:405</div><div>    frame #23: 0x000000010287f479 clang`(anonymous namespace)::ScalarExprEmitter::Visit(this=0x00007fff5fbf8410, E=0x000000010f2145d8) + 73 at CGExprScalar.cpp:205</div><div>    frame #24: 0x000000010287f3e0 clang`clang::CodeGen::CodeGenFunction::EmitScalarExpr(this=0x00007fff5fbf8c58, E=0x000000010f2145d8, IgnoreResultAssign=false) + 192 at CGExprScalar.cpp:3463</div><div>    frame #25: 0x000000010295e9df clang`clang::CodeGen::CodeGenFunction::EmitReturnStmt(this=0x00007fff5fbf8c58, S=0x000000010f2145f0) + 927 at CGStmt.cpp:979</div><div>    frame #26: 0x000000010295c611 clang`clang::CodeGen::CodeGenFunction::EmitStmt(this=0x00007fff5fbf8c58, S=0x000000010f2145f0) + 993 at CGStmt.cpp:139</div><div>    frame #27: 0x00000001029695d5 clang`clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(this=0x00007fff5fbf8c58, S=0x000000010f214608, GetLast=false, AggSlot=AggValueSlot at 0x00007fff5fbf8850) + 133 at CGStmt.cpp:303</div><div>    frame #28: 0x00000001029b8d14 clang`clang::CodeGen::CodeGenFunction::EmitFunctionBody(this=0x00007fff5fbf8c58, Args=0x00007fff5fbf8b20, Body=0x000000010f214608) + 116 at CodeGenFunction.cpp:850</div><div>    frame #29: 0x00000001029b95ac clang`clang::CodeGen::CodeGenFunction::GenerateCode(this=0x00007fff5fbf8c58, GD=GlobalDecl at 0x00007fff5fbf8aa8, Fn=0x0000000117495b98, FnInfo=0x0000000117495ab0) + 1900 at CodeGenFunction.cpp:967</div><div>    frame #30: 0x00000001029d5791 clang`clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(this=0x000000010d83d600, GD=GlobalDecl at 0x00007fff5fbf8c50, GV=0x0000000117495b98) + 577 at CodeGenModule.cpp:2648</div><div>    frame #31: 0x00000001029cf77d clang`clang::CodeGen::CodeGenModule::EmitGlobalDefinition(this=0x000000010d83d600, GD=GlobalDecl at 0x00007fff5fbf96b8, GV=0x0000000117495b98) + 733 at CodeGenModule.cpp:1651</div><div>    frame #32: 0x00000001029c7fae clang`clang::CodeGen::CodeGenModule::EmitDeferred(this=0x000000010d83d600) + 1166 at CodeGenModule.cpp:1198</div><div>    frame #33: 0x00000001029c800a clang`clang::CodeGen::CodeGenModule::EmitDeferred(this=0x000000010d83d600) + 1258 at CodeGenModule.cpp:1204</div><div>    frame #34: 0x00000001029c6ec6 clang`clang::CodeGen::CodeGenModule::Release(this=0x000000010d83d600) + 54 at CodeGenModule.cpp:360</div><div>    frame #35: 0x0000000102b567d2 clang`(anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(this=0x000000010c6138b0, Ctx=0x000000010d838400) + 562 at ModuleBuilder.cpp:210</div><div>    frame #36: 0x00000001029ac8ea clang`clang::BackendConsumer::HandleTranslationUnit(this=0x000000010c613750, C=0x000000010d838400) + 202 at CodeGenAction.cpp:141</div><div>    frame #37: 0x0000000103edb49f clang`clang::ParseAST(S=0x000000010d862600, PrintStats=false, SkipFunctionBodies=false) + 1295 at ParseAST.cpp:168</div><div>    frame #38: 0x0000000102f24b1f clang`clang::ASTFrontendAction::ExecuteAction(this=0x000000010c60aeb0) + 511 at FrontendAction.cpp:545</div><div>    frame #39: 0x00000001029ab027 clang`clang::CodeGenAction::ExecuteAction(this=0x000000010c60aeb0) + 6343 at CodeGenAction.cpp:807</div><div>    frame #40: 0x0000000102f24080 clang`clang::FrontendAction::Execute(this=0x000000010c60aeb0) + 112 at FrontendAction.cpp:446</div><div>    frame #41: 0x0000000102e75468 clang`clang::CompilerInstance::ExecuteAction(this=0x000000010c60a1b0, Act=0x000000010c60aeb0) + 1592 at CompilerInstance.cpp:846</div><div>    frame #42: 0x0000000102fb3bba clang`clang::ExecuteCompilerInvocation(Clang=0x000000010c60a1b0) + 4410 at ExecuteCompilerInvocation.cpp:222</div><div>    frame #43: 0x000000010001596e clang`cc1_main(Argv=ArrayRef<const char *> at 0x00007fff5fbfbde0, Argv0=0x00007fff5fbff770, MainAddr=0x0000000100001f70) + 4926 at cc1_main.cpp:116</div><div>    frame #44: 0x0000000100005324 clang`ExecuteCC1Tool(argv=ArrayRef<const char *> at 0x00007fff5fbfcd00, Tool=(Data = "", Length = 0)) + 500 at driver.cpp:303</div><div>    frame #45: 0x0000000100002cdd clang`main(argc_=90, argv_=0x00007fff5fbff380) + 3245 at driver.cpp:370</div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 28, 2016 at 11:43 AM, Eric Christopher <span dir="ltr"><<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I'm also just curious how we got all the way to here without having the error emitted and compilation stopped?<span class="HOEnZb"><font color="#888888"><div><br></div></font></span><div><span class="HOEnZb"><font color="#888888">-eric</font></span><div><div class="h5"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Jan 28, 2016 at 9:53 AM Justin Bogner <<a href="mailto:mail@justinbogner.com" target="_blank">mail@justinbogner.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Manman Ren via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> writes:<br>
> manmanren created this revision.<br>
> manmanren added reviewers: echristo, rafael, ahatanak.<br>
> manmanren added a subscriber: cfe-commits.<br>
><br>
> It can happen that frontend emits error message when releasing the<br>
> builder. When that happens, we emit the error message and continue to<br>
> invoke backend.<br>
> Backend will then crash.<br>
><br>
> The fix is quite simple, we check for errors after releasing the builder.<br>
><br>
> <a href="http://reviews.llvm.org/D16564" rel="noreferrer" target="_blank">http://reviews.llvm.org/D16564</a><br>
><br>
> Files:<br>
>   lib/CodeGen/ModuleBuilder.cpp<br>
>   test/CodeGen/target-builtin-error-3.c<br>
><br>
><br>
> Index: test/CodeGen/target-builtin-error-3.c<br>
> ===================================================================<br>
> --- test/CodeGen/target-builtin-error-3.c<br>
> +++ test/CodeGen/target-builtin-error-3.c<br>
> @@ -0,0 +1,28 @@<br>
> +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -S -verify -o - -target-feature +avx<br>
> +<br>
> +// RUN: not %clang_cc1 %s -triple=x86_64-apple-darwin -emit-obj -target-feature +avx 2> %t.err<br>
> +// RUN: FileCheck < %t.err %s<br>
> +// CHECK: 1 error generated<br>
> +<br>
> +typedef unsigned short uint16_t;<br>
> +typedef long long __m128i __attribute__((__vector_size__(16)));<br>
> +typedef float __v8sf __attribute__ ((__vector_size__ (32)));<br>
> +typedef float __m256 __attribute__ ((__vector_size__ (32)));<br>
> +typedef uint16_t half;<br>
> +typedef __attribute__ ((ext_vector_type( 8),__aligned__( 16))) half half8;<br>
> +typedef __attribute__ ((ext_vector_type(16),__aligned__( 32))) half half16;<br>
> +typedef __attribute__ ((ext_vector_type(16),__aligned__( 2))) half half16U;<br>
> +typedef __attribute__ ((ext_vector_type( 8),__aligned__( 32))) float float8;<br>
> +typedef __attribute__ ((ext_vector_type(16),__aligned__( 64))) float float16;<br>
> +static inline half8 __attribute__((__overloadable__)) convert_half( float8 a ) {<br>
> +  return __extension__ ({ __m256 __a = (a); (__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)__a, (0x00)); }); // expected-error {{'__builtin_ia32_vcvtps2ph256' needs target feature f16c}}<br>
> +}<br>
> +static inline half16 __attribute__((__overloadable__)) convert_half( float16 a ) {<br>
> +  half16 r;<br>
> +  r.lo = convert_half( a.lo);<br>
> +  return r;<br>
> +}<br>
> +void avx_test( uint16_t *destData, float16 argbF)<br>
> +{<br>
> +   ((half16U*)destData)[0] = convert_half(argbF);<br>
> +}<br>
> Index: lib/CodeGen/ModuleBuilder.cpp<br>
> ===================================================================<br>
> --- lib/CodeGen/ModuleBuilder.cpp<br>
> +++ lib/CodeGen/ModuleBuilder.cpp<br>
> @@ -208,6 +208,14 @@<br>
><br>
>        if (Builder)<br>
>          Builder->Release();<br>
> +<br>
> +      // Builder->Release can cause diagnostics to be generated.<br>
<br>
This comment's a bit confusing. Isn't it more like "If errors occurred<br>
while building the module, we need to stop here before invoking the<br>
backend", or something like that?<br>
<br>
> +      if (Diags.hasErrorOccurred()) {<br>
> +        if (Builder)<br>
> +          Builder->clear();<br>
> +        M.reset();<br>
> +        return;<br>
> +      }<br>
>      }<br>
><br>
>      void CompleteTentativeDefinition(VarDecl *D) override {<br>
><br>
</blockquote></div></div></div></div></div>
</blockquote></div><br></div>