diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2016-05-24 16:09:25 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2016-05-24 16:09:25 +0000 |
| commit | a38c9f1fa58abdbee68672fe7e3748c07962964b (patch) | |
| tree | 545b8166261e176a8b9c866e1391294a26dcbb62 /clang/lib/CodeGen/CGAtomic.cpp | |
| parent | ef88dc8fe4d28976ccd157493066a7f57ba98ce8 (diff) | |
| download | bcm5719-llvm-a38c9f1fa58abdbee68672fe7e3748c07962964b.tar.gz bcm5719-llvm-a38c9f1fa58abdbee68672fe7e3748c07962964b.zip | |
[MS Volatile] Don't make volatile loads/stores to underaligned objects atomic
Underaligned atomic LValues require libcalls which MSVC doesn't have.
MSVC doesn't seem to consider such operations as requiring a barrier
anyway.
This fixes PR27843.
llvm-svn: 270576
Diffstat (limited to 'clang/lib/CodeGen/CGAtomic.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGAtomic.cpp | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp index aa5a32dd521..7b747c13830 100644 --- a/clang/lib/CodeGen/CGAtomic.cpp +++ b/clang/lib/CodeGen/CGAtomic.cpp @@ -1274,31 +1274,11 @@ bool CodeGenFunction::LValueIsSuitableForInlineAtomic(LValue LV) { bool IsVolatile = LV.isVolatile() || hasVolatileMember(LV.getType()); // An atomic is inline if we don't need to use a libcall. bool AtomicIsInline = !AI.shouldUseLibcall(); - return IsVolatile && AtomicIsInline; -} - -/// An type is a candidate for having its loads and stores be made atomic if -/// we are operating under /volatile:ms *and* we know the access is volatile and -/// performing such an operation can be performed without a libcall. -bool CodeGenFunction::typeIsSuitableForInlineAtomic(QualType Ty, - bool IsVolatile) const { - // The operation must be volatile for us to make it atomic. - if (!IsVolatile) - return false; - // The -fms-volatile flag must be passed for us to adopt this behavior. - if (!CGM.getCodeGenOpts().MSVolatile) - return false; - - // An atomic is inline if we don't need to use a libcall (e.g. it is builtin). - if (!getContext().getTargetInfo().hasBuiltinAtomic( - getContext().getTypeSize(Ty), getContext().getTypeAlign(Ty))) - return false; - // MSVC doesn't seem to do this for types wider than a pointer. - if (getContext().getTypeSize(Ty) > + if (getContext().getTypeSize(LV.getType()) > getContext().getTypeSize(getContext().getIntPtrType())) return false; - return true; + return IsVolatile && AtomicIsInline; } RValue CodeGenFunction::EmitAtomicLoad(LValue LV, SourceLocation SL, |

