From owner-svn-src-projects@freebsd.org Tue Sep 22 20:40:00 2015 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6B4B5A02A4D for ; Tue, 22 Sep 2015 20:40:00 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 509041928; Tue, 22 Sep 2015 20:40:00 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t8MKe0bS029610; Tue, 22 Sep 2015 20:40:00 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t8MKe073029609; Tue, 22 Sep 2015 20:40:00 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201509222040.t8MKe073029609@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Tue, 22 Sep 2015 20:40:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r288127 - projects/clang370-import/contrib/llvm/tools/clang/lib/CodeGen X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2015 20:40:00 -0000 Author: dim Date: Tue Sep 22 20:39:59 2015 New Revision: 288127 URL: https://svnweb.freebsd.org/changeset/base/288127 Log: Pull in r244063 from upstream clang trunk (by James Y Knight): Add missing atomic libcall support. Support for emitting libcalls for __atomic_fetch_nand and __atomic_{add,sub,and,or,xor,nand}_fetch was missing; add it, and some test cases. Differential Revision: http://reviews.llvm.org/D10847 This fixes "cannot compile this atomic library call yet" errors when compiling code which calls the above builtins, on arm < v6. Modified: projects/clang370-import/contrib/llvm/tools/clang/lib/CodeGen/CGAtomic.cpp Modified: projects/clang370-import/contrib/llvm/tools/clang/lib/CodeGen/CGAtomic.cpp ============================================================================== --- projects/clang370-import/contrib/llvm/tools/clang/lib/CodeGen/CGAtomic.cpp Tue Sep 22 20:32:49 2015 (r288126) +++ projects/clang370-import/contrib/llvm/tools/clang/lib/CodeGen/CGAtomic.cpp Tue Sep 22 20:39:59 2015 (r288127) @@ -699,7 +699,7 @@ RValue CodeGenFunction::EmitAtomicExpr(A switch (E->getOp()) { case AtomicExpr::AO__c11_atomic_init: - llvm_unreachable("Already handled!"); + llvm_unreachable("Already handled above with EmitAtomicInit!"); case AtomicExpr::AO__c11_atomic_load: case AtomicExpr::AO__atomic_load_n: @@ -785,20 +785,43 @@ RValue CodeGenFunction::EmitAtomicExpr(A if (UseLibcall) { bool UseOptimizedLibcall = false; switch (E->getOp()) { + case AtomicExpr::AO__c11_atomic_init: + llvm_unreachable("Already handled above with EmitAtomicInit!"); + case AtomicExpr::AO__c11_atomic_fetch_add: case AtomicExpr::AO__atomic_fetch_add: case AtomicExpr::AO__c11_atomic_fetch_and: case AtomicExpr::AO__atomic_fetch_and: case AtomicExpr::AO__c11_atomic_fetch_or: case AtomicExpr::AO__atomic_fetch_or: + case AtomicExpr::AO__atomic_fetch_nand: case AtomicExpr::AO__c11_atomic_fetch_sub: case AtomicExpr::AO__atomic_fetch_sub: case AtomicExpr::AO__c11_atomic_fetch_xor: case AtomicExpr::AO__atomic_fetch_xor: + case AtomicExpr::AO__atomic_add_fetch: + case AtomicExpr::AO__atomic_and_fetch: + case AtomicExpr::AO__atomic_nand_fetch: + case AtomicExpr::AO__atomic_or_fetch: + case AtomicExpr::AO__atomic_sub_fetch: + case AtomicExpr::AO__atomic_xor_fetch: // For these, only library calls for certain sizes exist. UseOptimizedLibcall = true; break; - default: + + case AtomicExpr::AO__c11_atomic_load: + case AtomicExpr::AO__c11_atomic_store: + case AtomicExpr::AO__c11_atomic_exchange: + case AtomicExpr::AO__c11_atomic_compare_exchange_weak: + case AtomicExpr::AO__c11_atomic_compare_exchange_strong: + case AtomicExpr::AO__atomic_load_n: + case AtomicExpr::AO__atomic_load: + case AtomicExpr::AO__atomic_store_n: + case AtomicExpr::AO__atomic_store: + case AtomicExpr::AO__atomic_exchange_n: + case AtomicExpr::AO__atomic_exchange: + case AtomicExpr::AO__atomic_compare_exchange_n: + case AtomicExpr::AO__atomic_compare_exchange: // Only use optimized library calls for sizes for which they exist. if (Size == 1 || Size == 2 || Size == 4 || Size == 8) UseOptimizedLibcall = true; @@ -820,6 +843,9 @@ RValue CodeGenFunction::EmitAtomicExpr(A QualType RetTy; bool HaveRetTy = false; switch (E->getOp()) { + case AtomicExpr::AO__c11_atomic_init: + llvm_unreachable("Already handled!"); + // There is only one libcall for compare an exchange, because there is no // optimisation benefit possible from a libcall version of a weak compare // and exchange. @@ -903,7 +929,49 @@ RValue CodeGenFunction::EmitAtomicExpr(A AddDirectArgument(*this, Args, UseOptimizedLibcall, Val1, MemTy, E->getExprLoc(), sizeChars); break; - default: return EmitUnsupportedRValue(E, "atomic library call"); + // T __atomic_fetch_nand_N(T *mem, T val, int order) + case AtomicExpr::AO__atomic_fetch_nand: + LibCallName = "__atomic_fetch_nand"; + AddDirectArgument(*this, Args, UseOptimizedLibcall, Val1, MemTy, + E->getExprLoc(), sizeChars); + break; + + // T __atomic_add_fetch_N(T *mem, T val, int order) + case AtomicExpr::AO__atomic_add_fetch: + LibCallName = "__atomic_add_fetch"; + AddDirectArgument(*this, Args, UseOptimizedLibcall, Val1, LoweredMemTy, + E->getExprLoc(), sizeChars); + break; + // T __atomic_and_fetch_N(T *mem, T val, int order) + case AtomicExpr::AO__atomic_and_fetch: + LibCallName = "__atomic_and_fetch"; + AddDirectArgument(*this, Args, UseOptimizedLibcall, Val1, MemTy, + E->getExprLoc(), sizeChars); + break; + // T __atomic_or_fetch_N(T *mem, T val, int order) + case AtomicExpr::AO__atomic_or_fetch: + LibCallName = "__atomic_or_fetch"; + AddDirectArgument(*this, Args, UseOptimizedLibcall, Val1, MemTy, + E->getExprLoc(), sizeChars); + break; + // T __atomic_sub_fetch_N(T *mem, T val, int order) + case AtomicExpr::AO__atomic_sub_fetch: + LibCallName = "__atomic_sub_fetch"; + AddDirectArgument(*this, Args, UseOptimizedLibcall, Val1, LoweredMemTy, + E->getExprLoc(), sizeChars); + break; + // T __atomic_xor_fetch_N(T *mem, T val, int order) + case AtomicExpr::AO__atomic_xor_fetch: + LibCallName = "__atomic_xor_fetch"; + AddDirectArgument(*this, Args, UseOptimizedLibcall, Val1, MemTy, + E->getExprLoc(), sizeChars); + break; + // T __atomic_nand_fetch_N(T *mem, T val, int order) + case AtomicExpr::AO__atomic_nand_fetch: + LibCallName = "__atomic_nand_fetch"; + AddDirectArgument(*this, Args, UseOptimizedLibcall, Val1, MemTy, + E->getExprLoc(), sizeChars); + break; } // Optimized functions have the size in their name.