summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGAtomic.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CGAtomic.cpp')
-rw-r--r--clang/lib/CodeGen/CGAtomic.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp
index 1ef5d1035a0..4e52c3630c7 100644
--- a/clang/lib/CodeGen/CGAtomic.cpp
+++ b/clang/lib/CodeGen/CGAtomic.cpp
@@ -1295,10 +1295,23 @@ bool CodeGenFunction::LValueIsSuitableForInlineAtomic(LValue LV) {
/// 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).
- bool AtomicIsInline = getContext().getTargetInfo().hasBuiltinAtomic(
- getContext().getTypeSize(Ty), getContext().getTypeAlign(Ty));
- return CGM.getCodeGenOpts().MSVolatile && IsVolatile && AtomicIsInline;
+ 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) >
+ getContext().getTypeSize(getContext().getIntPtrType()))
+ return false;
+ return true;
}
RValue CodeGenFunction::EmitAtomicLoad(LValue LV, SourceLocation SL,
OpenPOWER on IntegriCloud