diff options
| author | 2019-06-23 21:36:31 +0000 | |
|---|---|---|
| committer | 2019-06-23 21:36:31 +0000 | |
| commit | 23f101f37937a1bd4a29726cab2f76e0fb038b35 (patch) | |
| tree | f7da7d6b32c2e07114da399150bfa88d72187012 /gnu/llvm/tools/clang/lib/CodeGen/CGAtomic.cpp | |
| parent | sort previous; ok deraadt (diff) | |
| download | wireguard-openbsd-23f101f37937a1bd4a29726cab2f76e0fb038b35.tar.xz wireguard-openbsd-23f101f37937a1bd4a29726cab2f76e0fb038b35.zip | |
Import LLVM 8.0.0 release including clang, lld and lldb.
Diffstat (limited to 'gnu/llvm/tools/clang/lib/CodeGen/CGAtomic.cpp')
| -rw-r--r-- | gnu/llvm/tools/clang/lib/CodeGen/CGAtomic.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/gnu/llvm/tools/clang/lib/CodeGen/CGAtomic.cpp b/gnu/llvm/tools/clang/lib/CodeGen/CGAtomic.cpp index b34bcdc1fc3..24056a449de 100644 --- a/gnu/llvm/tools/clang/lib/CodeGen/CGAtomic.cpp +++ b/gnu/llvm/tools/clang/lib/CodeGen/CGAtomic.cpp @@ -18,7 +18,7 @@ #include "TargetInfo.h" #include "clang/AST/ASTContext.h" #include "clang/CodeGen/CGFunctionInfo.h" -#include "clang/Sema/SemaDiagnostic.h" +#include "clang/Frontend/FrontendDiagnostic.h" #include "llvm/ADT/DenseMap.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/Intrinsics.h" @@ -765,11 +765,15 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) { std::tie(sizeChars, alignChars) = getContext().getTypeInfoInChars(AtomicTy); uint64_t Size = sizeChars.getQuantity(); unsigned MaxInlineWidthInBits = getTarget().getMaxAtomicInlineWidth(); - bool UseLibcall = ((Ptr.getAlignment() % sizeChars) != 0 || - getContext().toBits(sizeChars) > MaxInlineWidthInBits); - if (UseLibcall) - CGM.getDiags().Report(E->getLocStart(), diag::warn_atomic_op_misaligned); + bool Oversized = getContext().toBits(sizeChars) > MaxInlineWidthInBits; + bool Misaligned = (Ptr.getAlignment() % sizeChars) != 0; + bool UseLibcall = Misaligned | Oversized; + + if (UseLibcall) { + CGM.getDiags().Report(E->getBeginLoc(), diag::warn_atomic_op_misaligned) + << !Oversized; + } llvm::Value *Order = EmitScalarExpr(E->getOrder()); llvm::Value *Scope = @@ -923,6 +927,15 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) { UseOptimizedLibcall = true; break; + case AtomicExpr::AO__atomic_load: + case AtomicExpr::AO__atomic_store: + case AtomicExpr::AO__atomic_exchange: + case AtomicExpr::AO__atomic_compare_exchange: + // Use the generic version if we don't know that the operand will be + // suitably aligned for the optimized version. + if (Misaligned) + break; + LLVM_FALLTHROUGH; case AtomicExpr::AO__c11_atomic_load: case AtomicExpr::AO__c11_atomic_store: case AtomicExpr::AO__c11_atomic_exchange: @@ -934,14 +947,11 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) { case AtomicExpr::AO__opencl_atomic_compare_exchange_weak: case AtomicExpr::AO__opencl_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. + // FIXME: Size == 16 optimized library functions exist too. if (Size == 1 || Size == 2 || Size == 4 || Size == 8) UseOptimizedLibcall = true; break; |
