Should we merge this to 3.9?
On Thu, Jul 21, 2016 at 3:38 AM, Craig Topper via cfe-commits <cfe-commits@lists.llvm.org> wrote: > Author: ctopper > Date: Thu Jul 21 02:38:43 2016 > New Revision: 276250 > > URL: http://llvm.org/viewvc/llvm-project?rev=276250&view=rev > Log: > [Sema,X86] Add explicit check to ensure that builtins that require x86-64 > target throw an error if used on 32-bit target. > > If these builtins are allowed to go through on a 32-bit target they will fire > assertions in the backend. > > Fixes PR28635. > > Added: > cfe/trunk/test/CodeGen/builtins-x86-disabled.c > Modified: > cfe/trunk/lib/Sema/SemaChecking.cpp > > Modified: cfe/trunk/lib/Sema/SemaChecking.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=276250&r1=276249&r2=276250&view=diff > ============================================================================== > --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) > +++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Jul 21 02:38:43 2016 > @@ -1597,6 +1597,56 @@ bool Sema::CheckX86BuiltinFunctionCall(u > return SemaBuiltinCpuSupports(*this, TheCall); > case X86::BI__builtin_ms_va_start: > return SemaBuiltinMSVAStart(TheCall); > + case X86::BI__builtin_ia32_addcarryx_u64: > + case X86::BI__builtin_ia32_addcarry_u64: > + case X86::BI__builtin_ia32_subborrow_u64: > + case X86::BI__builtin_ia32_readeflags_u64: > + case X86::BI__builtin_ia32_writeeflags_u64: > + case X86::BI__builtin_ia32_bextr_u64: > + case X86::BI__builtin_ia32_bextri_u64: > + case X86::BI__builtin_ia32_bzhi_di: > + case X86::BI__builtin_ia32_pdep_di: > + case X86::BI__builtin_ia32_pext_di: > + case X86::BI__builtin_ia32_crc32di: > + case X86::BI__builtin_ia32_fxsave64: > + case X86::BI__builtin_ia32_fxrstor64: > + case X86::BI__builtin_ia32_xsave64: > + case X86::BI__builtin_ia32_xrstor64: > + case X86::BI__builtin_ia32_xsaveopt64: > + case X86::BI__builtin_ia32_xrstors64: > + case X86::BI__builtin_ia32_xsavec64: > + case X86::BI__builtin_ia32_xsaves64: > + case X86::BI__builtin_ia32_rdfsbase64: > + case X86::BI__builtin_ia32_rdgsbase64: > + case X86::BI__builtin_ia32_wrfsbase64: > + case X86::BI__builtin_ia32_wrgsbase64: > + case X86::BI__builtin_ia32_pbroadcastb512_gpr_mask: > + case X86::BI__builtin_ia32_pbroadcastb256_gpr_mask: > + case X86::BI__builtin_ia32_pbroadcastb128_gpr_mask: > + case X86::BI__builtin_ia32_vcvtsd2si64: > + case X86::BI__builtin_ia32_vcvtsd2usi64: > + case X86::BI__builtin_ia32_vcvtss2si64: > + case X86::BI__builtin_ia32_vcvtss2usi64: > + case X86::BI__builtin_ia32_vcvttsd2si64: > + case X86::BI__builtin_ia32_vcvttsd2usi64: > + case X86::BI__builtin_ia32_vcvttss2si64: > + case X86::BI__builtin_ia32_vcvttss2usi64: > + case X86::BI__builtin_ia32_cvtss2si64: > + case X86::BI__builtin_ia32_cvttss2si64: > + case X86::BI__builtin_ia32_cvtsd2si64: > + case X86::BI__builtin_ia32_cvttsd2si64: > + case X86::BI__builtin_ia32_cvtsi2sd64: > + case X86::BI__builtin_ia32_cvtsi2ss64: > + case X86::BI__builtin_ia32_cvtusi2sd64: > + case X86::BI__builtin_ia32_cvtusi2ss64: > + case X86::BI__builtin_ia32_rdseed64_step: { > + // These builtins only work on x86-64 targets. > + const llvm::Triple &TT = Context.getTargetInfo().getTriple(); > + if (TT.getArch() != llvm::Triple::x86_64) > + return Diag(TheCall->getCallee()->getLocStart(), > + diag::err_x86_builtin_32_bit_tgt); > + return false; > + } > case X86::BI__builtin_ia32_extractf64x4_mask: > case X86::BI__builtin_ia32_extracti64x4_mask: > case X86::BI__builtin_ia32_extractf32x8_mask: > > Added: cfe/trunk/test/CodeGen/builtins-x86-disabled.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-x86-disabled.c?rev=276250&view=auto > ============================================================================== > --- cfe/trunk/test/CodeGen/builtins-x86-disabled.c (added) > +++ cfe/trunk/test/CodeGen/builtins-x86-disabled.c Thu Jul 21 02:38:43 2016 > @@ -0,0 +1,22 @@ > +// REQUIRES: x86-registered-target > +// RUN: not %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - 2>&1 > | FileCheck %s > + > +void call_x86_64_builtins(void) > +{ > + unsigned long long a = __builtin_ia32_crc32di(0, 0); > + unsigned long long b; > + unsigned int c = __builtin_ia32_rdseed64_step (&b); > + unsigned long long d = __builtin_ia32_bextr_u64 (0, 0); > + unsigned long long e = __builtin_ia32_pdep_di(0, 0); > + unsigned long long f = __builtin_ia32_pext_di(0, 0); > + unsigned long long g = __builtin_ia32_bzhi_di(0, 0); > + unsigned long long h; > + unsigned long long i = __builtin_ia32_addcarryx_u64(0, 0, 0, &h); > + unsigned long long j; > + unsigned long long k = __builtin_ia32_addcarry_u64(0, 0, 0, &j); > + unsigned long long l; > + unsigned long long m = __builtin_ia32_subborrow_u64(0, 0, 0, &l); > +} > + > +// CHECK: error: this builtin is only available on x86-64 targets > +// CHECK: __builtin_ia32_crc32di > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits