<div dir="ltr">Most of these have been broken like this for a long time so I'm not sure. This patch as is depends on r276249 too since we were missing qualifiers in the intrinsics file.</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div>
<br><div class="gmail_quote">On Fri, Jul 22, 2016 at 6:55 AM, Hans Wennborg <span dir="ltr"><<a href="mailto:hans@chromium.org" target="_blank">hans@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Should we merge this to 3.9?<br>
<br>
On Thu, Jul 21, 2016 at 3:38 AM, Craig Topper via cfe-commits<br>
<<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
> Author: ctopper<br>
> Date: Thu Jul 21 02:38:43 2016<br>
> New Revision: 276250<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=276250&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=276250&view=rev</a><br>
> Log:<br>
> [Sema,X86] Add explicit check to ensure that builtins that require x86-64 target throw an error if used on 32-bit target.<br>
><br>
> If these builtins are allowed to go through on a 32-bit target they will fire assertions in the backend.<br>
><br>
> Fixes PR28635.<br>
><br>
> Added:<br>
>     cfe/trunk/test/CodeGen/builtins-x86-disabled.c<br>
> Modified:<br>
>     cfe/trunk/lib/Sema/SemaChecking.cpp<br>
><br>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=276250&r1=276249&r2=276250&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=276250&r1=276249&r2=276250&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)<br>
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Jul 21 02:38:43 2016<br>
> @@ -1597,6 +1597,56 @@ bool Sema::CheckX86BuiltinFunctionCall(u<br>
>      return SemaBuiltinCpuSupports(*this, TheCall);<br>
>    case X86::BI__builtin_ms_va_start:<br>
>      return SemaBuiltinMSVAStart(TheCall);<br>
> +  case X86::BI__builtin_ia32_addcarryx_u64:<br>
> +  case X86::BI__builtin_ia32_addcarry_u64:<br>
> +  case X86::BI__builtin_ia32_subborrow_u64:<br>
> +  case X86::BI__builtin_ia32_readeflags_u64:<br>
> +  case X86::BI__builtin_ia32_writeeflags_u64:<br>
> +  case X86::BI__builtin_ia32_bextr_u64:<br>
> +  case X86::BI__builtin_ia32_bextri_u64:<br>
> +  case X86::BI__builtin_ia32_bzhi_di:<br>
> +  case X86::BI__builtin_ia32_pdep_di:<br>
> +  case X86::BI__builtin_ia32_pext_di:<br>
> +  case X86::BI__builtin_ia32_crc32di:<br>
> +  case X86::BI__builtin_ia32_fxsave64:<br>
> +  case X86::BI__builtin_ia32_fxrstor64:<br>
> +  case X86::BI__builtin_ia32_xsave64:<br>
> +  case X86::BI__builtin_ia32_xrstor64:<br>
> +  case X86::BI__builtin_ia32_xsaveopt64:<br>
> +  case X86::BI__builtin_ia32_xrstors64:<br>
> +  case X86::BI__builtin_ia32_xsavec64:<br>
> +  case X86::BI__builtin_ia32_xsaves64:<br>
> +  case X86::BI__builtin_ia32_rdfsbase64:<br>
> +  case X86::BI__builtin_ia32_rdgsbase64:<br>
> +  case X86::BI__builtin_ia32_wrfsbase64:<br>
> +  case X86::BI__builtin_ia32_wrgsbase64:<br>
> +  case X86::BI__builtin_ia32_pbroadcastb512_gpr_mask:<br>
> +  case X86::BI__builtin_ia32_pbroadcastb256_gpr_mask:<br>
> +  case X86::BI__builtin_ia32_pbroadcastb128_gpr_mask:<br>
> +  case X86::BI__builtin_ia32_vcvtsd2si64:<br>
> +  case X86::BI__builtin_ia32_vcvtsd2usi64:<br>
> +  case X86::BI__builtin_ia32_vcvtss2si64:<br>
> +  case X86::BI__builtin_ia32_vcvtss2usi64:<br>
> +  case X86::BI__builtin_ia32_vcvttsd2si64:<br>
> +  case X86::BI__builtin_ia32_vcvttsd2usi64:<br>
> +  case X86::BI__builtin_ia32_vcvttss2si64:<br>
> +  case X86::BI__builtin_ia32_vcvttss2usi64:<br>
> +  case X86::BI__builtin_ia32_cvtss2si64:<br>
> +  case X86::BI__builtin_ia32_cvttss2si64:<br>
> +  case X86::BI__builtin_ia32_cvtsd2si64:<br>
> +  case X86::BI__builtin_ia32_cvttsd2si64:<br>
> +  case X86::BI__builtin_ia32_cvtsi2sd64:<br>
> +  case X86::BI__builtin_ia32_cvtsi2ss64:<br>
> +  case X86::BI__builtin_ia32_cvtusi2sd64:<br>
> +  case X86::BI__builtin_ia32_cvtusi2ss64:<br>
> +  case X86::BI__builtin_ia32_rdseed64_step: {<br>
> +    // These builtins only work on x86-64 targets.<br>
> +    const llvm::Triple &TT = Context.getTargetInfo().getTriple();<br>
> +    if (TT.getArch() != llvm::Triple::x86_64)<br>
> +      return Diag(TheCall->getCallee()->getLocStart(),<br>
> +                  diag::err_x86_builtin_32_bit_tgt);<br>
> +    return false;<br>
> +  }<br>
>    case X86::BI__builtin_ia32_extractf64x4_mask:<br>
>    case X86::BI__builtin_ia32_extracti64x4_mask:<br>
>    case X86::BI__builtin_ia32_extractf32x8_mask:<br>
><br>
> Added: cfe/trunk/test/CodeGen/builtins-x86-disabled.c<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-x86-disabled.c?rev=276250&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-x86-disabled.c?rev=276250&view=auto</a><br>
> ==============================================================================<br>
> --- cfe/trunk/test/CodeGen/builtins-x86-disabled.c (added)<br>
> +++ cfe/trunk/test/CodeGen/builtins-x86-disabled.c Thu Jul 21 02:38:43 2016<br>
> @@ -0,0 +1,22 @@<br>
> +// REQUIRES: x86-registered-target<br>
> +// RUN: not %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - 2>&1 | FileCheck %s<br>
> +<br>
> +void call_x86_64_builtins(void)<br>
> +{<br>
> +  unsigned long long a = __builtin_ia32_crc32di(0, 0);<br>
> +  unsigned long long b;<br>
> +  unsigned int c = __builtin_ia32_rdseed64_step (&b);<br>
> +  unsigned long long d = __builtin_ia32_bextr_u64 (0, 0);<br>
> +  unsigned long long e = __builtin_ia32_pdep_di(0, 0);<br>
> +  unsigned long long f = __builtin_ia32_pext_di(0, 0);<br>
> +  unsigned long long g = __builtin_ia32_bzhi_di(0, 0);<br>
> +  unsigned long long h;<br>
> +  unsigned long long i = __builtin_ia32_addcarryx_u64(0, 0, 0, &h);<br>
> +  unsigned long long j;<br>
> +  unsigned long long k = __builtin_ia32_addcarry_u64(0, 0, 0, &j);<br>
> +  unsigned long long l;<br>
> +  unsigned long long m = __builtin_ia32_subborrow_u64(0, 0, 0, &l);<br>
> +}<br>
> +<br>
> +// CHECK: error: this builtin is only available on x86-64 targets<br>
> +// CHECK: __builtin_ia32_crc32di<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>