[PATCH] D38046: [Atomic][X8664] set max atomic inline/promote width according to the target
This revision was automatically updated to reflect the committed changes. Closed by commit rL313992: [Atomic][X8664] set max atomic inline width according to the target (authored by wmi). Changed prior to commit: https://reviews.llvm.org/D38046?vs=116107=116362#toc Repository: rL LLVM https://reviews.llvm.org/D38046 Files: cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/Basic/Targets/X86.h cfe/trunk/test/CodeGenCXX/atomic-inline.cpp cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp cfe/trunk/test/OpenMP/atomic_read_codegen.c cfe/trunk/test/OpenMP/atomic_update_codegen.cpp cfe/trunk/test/OpenMP/atomic_write_codegen.c Index: cfe/trunk/lib/Basic/Targets.cpp === --- cfe/trunk/lib/Basic/Targets.cpp +++ cfe/trunk/lib/Basic/Targets.cpp @@ -620,6 +620,7 @@ Target->setSupportedOpenCLOpts(); Target->setOpenCLExtensionOpts(); + Target->setMaxAtomicWidth(); if (!Target->validateTarget(Diags)) return nullptr; Index: cfe/trunk/lib/Basic/Targets/X86.h === --- cfe/trunk/lib/Basic/Targets/X86.h +++ cfe/trunk/lib/Basic/Targets/X86.h @@ -814,7 +814,7 @@ // x86-64 has atomics up to 16 bytes. MaxAtomicPromoteWidth = 128; -MaxAtomicInlineWidth = 128; +MaxAtomicInlineWidth = 64; } BuiltinVaListKind getBuiltinVaListKind() const override { @@ -872,6 +872,12 @@ HasSizeMismatch); } + void setMaxAtomicWidth() override { +if (hasFeature("cx16")) + MaxAtomicInlineWidth = 128; +return; + } + ArrayRef getTargetBuiltins() const override; }; Index: cfe/trunk/include/clang/Basic/TargetInfo.h === --- cfe/trunk/include/clang/Basic/TargetInfo.h +++ cfe/trunk/include/clang/Basic/TargetInfo.h @@ -448,6 +448,9 @@ /// \brief Return the maximum width lock-free atomic operation which can be /// inlined given the supported features of the given target. unsigned getMaxAtomicInlineWidth() const { return MaxAtomicInlineWidth; } + /// \brief Set the maximum inline or promote width lock-free atomic operation + /// for the given target. + virtual void setMaxAtomicWidth() {} /// \brief Returns true if the given target supports lock-free atomic /// operations at the specified width and alignment. virtual bool hasBuiltinAtomic(uint64_t AtomicSizeInBits, Index: cfe/trunk/test/OpenMP/atomic_read_codegen.c === --- cfe/trunk/test/OpenMP/atomic_read_codegen.c +++ cfe/trunk/test/OpenMP/atomic_read_codegen.c @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s // expected-no-diagnostics // REQUIRES: x86-registered-target #ifndef HEADER Index: cfe/trunk/test/OpenMP/atomic_update_codegen.cpp === --- cfe/trunk/test/OpenMP/atomic_update_codegen.cpp +++ cfe/trunk/test/OpenMP/atomic_update_codegen.cpp @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s // expected-no-diagnostics #ifndef HEADER #define HEADER Index: cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp === --- cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp +++ cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -x c -triple
[PATCH] D38046: [Atomic][X8664] set max atomic inline/promote width according to the target
efriedma accepted this revision. efriedma added a comment. This revision is now accepted and ready to land. LGTM Repository: rL LLVM https://reviews.llvm.org/D38046 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38046: [Atomic][X8664] set max atomic inline/promote width according to the target
wmi updated this revision to Diff 116107. wmi added a comment. Herald added a subscriber: eraman. Address Eli's comments. Repository: rL LLVM https://reviews.llvm.org/D38046 Files: include/clang/Basic/TargetInfo.h lib/Basic/Targets.cpp lib/Basic/Targets/X86.h test/CodeGenCXX/atomic-inline.cpp test/OpenMP/atomic_capture_codegen.cpp test/OpenMP/atomic_read_codegen.c test/OpenMP/atomic_update_codegen.cpp test/OpenMP/atomic_write_codegen.c Index: test/OpenMP/atomic_write_codegen.c === --- test/OpenMP/atomic_write_codegen.c +++ test/OpenMP/atomic_write_codegen.c @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s // expected-no-diagnostics // REQUIRES: x86-registered-target #ifndef HEADER Index: test/OpenMP/atomic_update_codegen.cpp === --- test/OpenMP/atomic_update_codegen.cpp +++ test/OpenMP/atomic_update_codegen.cpp @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s // expected-no-diagnostics #ifndef HEADER #define HEADER Index: test/OpenMP/atomic_read_codegen.c === --- test/OpenMP/atomic_read_codegen.c +++ test/OpenMP/atomic_read_codegen.c @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s // expected-no-diagnostics // REQUIRES: x86-registered-target #ifndef HEADER Index: test/OpenMP/atomic_capture_codegen.cpp === --- test/OpenMP/atomic_capture_codegen.cpp +++ test/OpenMP/atomic_capture_codegen.cpp @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s // expected-no-diagnostics #ifndef HEADER #define HEADER Index: test/CodeGenCXX/atomic-inline.cpp === --- test/CodeGenCXX/atomic-inline.cpp +++ test/CodeGenCXX/atomic-inline.cpp @@ -0,0 +1,69 @@ +// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - -triple=x86_64-linux-gnu | FileCheck %s +// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - -triple=x86_64-linux-gnu -target-cpu core2 | FileCheck %s --check-prefix=CORE2 +// Check the atomic code generation for cpu targets w/wo cx16 support. + +struct alignas(8) AM8 { + int f1, f2; +}; +AM8 m8; +AM8 load8() { + AM8 am; + // CHECK-LABEL: @_Z5load8v + // CHECK: load atomic i64, {{.*}} monotonic + // CORE2-LABEL: @_Z5load8v + // CORE2: load atomic i64,
[PATCH] D38046: [Atomic][X8664] set max atomic inline/promote width according to the target
wmi added inline comments. Comment at: lib/Basic/Targets/X86.h:898 + MaxAtomicPromoteWidth = 64; + MaxAtomicInlineWidth = 64; +} efriedma wrote: > wmi wrote: > > efriedma wrote: > > > I don't think we need to mess with MaxAtomicPromoteWidth? > > > > > > Probably more intuitive to check "if (hasFeature" rather than "if > > > (!hasFeature". > > > > > > Adding a dedicated hook for this seems a bit overkill, but I don't have a > > > better suggestion. > > If 128 bits inline atomic is not supported, what is the point to promote > > atomic type to 128 bits? > MaxAtomicPromoteWidth affects the ABI, so it can't vary based on the target > CPU. That make senses. Thanks for the explanation. Repository: rL LLVM https://reviews.llvm.org/D38046 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38046: [Atomic][X8664] set max atomic inline/promote width according to the target
efriedma added inline comments. Comment at: lib/Basic/Targets/X86.h:898 + MaxAtomicPromoteWidth = 64; + MaxAtomicInlineWidth = 64; +} wmi wrote: > efriedma wrote: > > I don't think we need to mess with MaxAtomicPromoteWidth? > > > > Probably more intuitive to check "if (hasFeature" rather than "if > > (!hasFeature". > > > > Adding a dedicated hook for this seems a bit overkill, but I don't have a > > better suggestion. > If 128 bits inline atomic is not supported, what is the point to promote > atomic type to 128 bits? MaxAtomicPromoteWidth affects the ABI, so it can't vary based on the target CPU. Repository: rL LLVM https://reviews.llvm.org/D38046 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38046: [Atomic][X8664] set max atomic inline/promote width according to the target
wmi added inline comments. Comment at: lib/Basic/Targets/X86.h:898 + MaxAtomicPromoteWidth = 64; + MaxAtomicInlineWidth = 64; +} efriedma wrote: > I don't think we need to mess with MaxAtomicPromoteWidth? > > Probably more intuitive to check "if (hasFeature" rather than "if > (!hasFeature". > > Adding a dedicated hook for this seems a bit overkill, but I don't have a > better suggestion. If 128 bits inline atomic is not supported, what is the point to promote atomic type to 128 bits? Repository: rL LLVM https://reviews.llvm.org/D38046 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38046: [Atomic][X8664] set max atomic inline/promote width according to the target
efriedma added a comment. Needs testcase. Comment at: lib/Basic/Targets/X86.h:898 + MaxAtomicPromoteWidth = 64; + MaxAtomicInlineWidth = 64; +} I don't think we need to mess with MaxAtomicPromoteWidth? Probably more intuitive to check "if (hasFeature" rather than "if (!hasFeature". Adding a dedicated hook for this seems a bit overkill, but I don't have a better suggestion. Repository: rL LLVM https://reviews.llvm.org/D38046 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38046: [Atomic][X8664] set max atomic inline/promote width according to the target
wmi updated this revision to Diff 115945. wmi added a comment. Address Eli's comment. Repository: rL LLVM https://reviews.llvm.org/D38046 Files: include/clang/Basic/TargetInfo.h lib/Basic/Targets.cpp lib/Basic/Targets/X86.h test/OpenMP/atomic_capture_codegen.cpp test/OpenMP/atomic_read_codegen.c test/OpenMP/atomic_update_codegen.cpp test/OpenMP/atomic_write_codegen.c Index: test/OpenMP/atomic_write_codegen.c === --- test/OpenMP/atomic_write_codegen.c +++ test/OpenMP/atomic_write_codegen.c @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s // expected-no-diagnostics // REQUIRES: x86-registered-target #ifndef HEADER Index: test/OpenMP/atomic_update_codegen.cpp === --- test/OpenMP/atomic_update_codegen.cpp +++ test/OpenMP/atomic_update_codegen.cpp @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s // expected-no-diagnostics #ifndef HEADER #define HEADER Index: test/OpenMP/atomic_read_codegen.c === --- test/OpenMP/atomic_read_codegen.c +++ test/OpenMP/atomic_read_codegen.c @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s // expected-no-diagnostics // REQUIRES: x86-registered-target #ifndef HEADER Index: test/OpenMP/atomic_capture_codegen.cpp === --- test/OpenMP/atomic_capture_codegen.cpp +++ test/OpenMP/atomic_capture_codegen.cpp @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s // expected-no-diagnostics #ifndef HEADER #define HEADER Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -620,6 +620,7 @@ Target->setSupportedOpenCLOpts(); Target->setOpenCLExtensionOpts(); + Target->setMaxAtomicWidth(); if (!Target->validateTarget(Diags)) return nullptr; Index: lib/Basic/Targets/X86.h === --- lib/Basic/Targets/X86.h +++ lib/Basic/Targets/X86.h @@ -892,6 +892,14 @@ HasSizeMismatch); } + void setMaxAtomicWidth() override { +if (!hasFeature("cx16")) { + MaxAtomicPromoteWidth = 64; + MaxAtomicInlineWidth = 64; +} +return; + } + ArrayRef