<div dir="ltr">I'm also just curious how we got all the way to here without having the error emitted and compilation stopped?<div><br></div><div>-eric<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">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>