[libclc] r315170 - ldexp: Fix double precision function return type

2017-10-07 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Sat Oct  7 23:56:14 2017
New Revision: 315170

URL: http://llvm.org/viewvc/llvm-project?rev=315170&view=rev
Log:
ldexp: Fix double precision function return type

Fixes ~1200 external calls from nvtpx library.

Reviewer: Jeroen Ketema
Signed-off-by: Jan Vesely 

Modified:
libclc/trunk/generic/include/math/clc_ldexp.h

Modified: libclc/trunk/generic/include/math/clc_ldexp.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/math/clc_ldexp.h?rev=315170&r1=315169&r2=315170&view=diff
==
--- libclc/trunk/generic/include/math/clc_ldexp.h (original)
+++ libclc/trunk/generic/include/math/clc_ldexp.h Sat Oct  7 23:56:14 2017
@@ -2,5 +2,5 @@ _CLC_DEF _CLC_OVERLOAD float __clc_ldexp
 
 #ifdef cl_khr_fp64
   #pragma OPENCL EXTENSION cl_khr_fp64 : enable
-  _CLC_DEF _CLC_OVERLOAD float __clc_ldexp(double, int);
+  _CLC_DEF _CLC_OVERLOAD double __clc_ldexp(double, int);
 #endif


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36562: [Bitfield] Make the bitfield a separate location if it has width of legal integer type and its bit offset is naturally aligned for the type

2017-10-07 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: include/clang/Basic/DiagnosticDriverKinds.td:335
+def warn_drv_fine_grained_bitfield_accesses_ignored : Warning<
+  "option '-ffine-grained-bitfield-accesses' cannot be enabled together with 
sanitizer; flag ignored">,
+  InGroup;

with a sanitizer



Comment at: include/clang/Driver/Options.td:1041
+  "ffine-grained-bitfield-accesses">, Group, Flags<[CC1Option]>,
+  HelpText<"Use separate access for bitfields with legal widths and 
alignments.">;
+def fno_fine_grained_bitfield_accesses : Flag<["-"],

access -> accesses



Comment at: include/clang/Driver/Options.td:1044
+  "fno-fine-grained-bitfield-accesses">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Use a big integer wrap for a consecutive run of bitfields.">;
+

Use large-integer access for consecutive bitfield runs.



Comment at: include/clang/Frontend/CodeGenOptions.def:182
 CODEGENOPT(SoftFloat , 1, 0) ///< -soft-float.
+CODEGENOPT(FineGrainedBitfieldAccesses, 1, 0) ///< Use separate access for 
bitfields
+  ///< with legal widths and 
alignments.

These lines are too long.



Comment at: lib/CodeGen/CGRecordLayoutBuilder.cpp:449
+// Otherwise, try to add bitfields to the run.
+if (Run != FieldEnd && !IsBetterAsSingleFieldRun(Run) &&
+Field != FieldEnd && !IsBetterAsSingleFieldRun(Field) &&

Why do you have the `IsBetterAsSingleFieldRun(Run)` check here (where we'll 
evaluate it multiple times (for all of the fields in the run)). Can't you make 
the predicate above directly?

  // Any non-zero-length bitfield can start a new run.
  if (Field->getBitWidthValue(Context) != 0 &&
   !IsBetterAsSingleFieldRun(Field)) {
Run = Field;
StartBitOffset = getFieldBitOffset(*Field);
...



Repository:
  rL LLVM

https://reviews.llvm.org/D36562



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24933: Enable configuration files in clang

2017-10-07 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

Some suggested improvements to the English in the documentation...




Comment at: docs/UsersManual.rst:700
+
+Configuration files group command line options and allow to specify all of
+them just by referencing the configuration file. They may be used, for

Configuration files group command-line options and allow all of them to be 
specified just by ...



Comment at: docs/UsersManual.rst:702
+them just by referencing the configuration file. They may be used, for
+instance, to collect options required to tune compilation for particular
+target, such as -L, -I, -l, --sysroot, codegen options etc.

instance -> example

"for instance" and "for example" are essentially the same, but for consistency, 
"for example" is much more common in this document, so we should standardize.



Comment at: docs/UsersManual.rst:703
+instance, to collect options required to tune compilation for particular
+target, such as -L, -I, -l, --sysroot, codegen options etc.
+

options, etc.



Comment at: docs/UsersManual.rst:706
+The command line option `--config` can be used to specify configuration
+file in a Clang invocation. For instance:
+

instance -> example



Comment at: docs/UsersManual.rst:714
+If the provided argument contains a directory separator, it is considered as
+a file path, options are read from that file. Otherwise the argument is treated
+as a file name and is searched for sequentially in the directories:

and options are



Comment at: docs/UsersManual.rst:719
+- the directory where Clang executable resides.
+Both user and system directory for configuration files are specified during
+clang build using cmake parameters, CLANG_CONFIG_FILE_USER_DIR and

directory -> directories



Comment at: docs/UsersManual.rst:720
+Both user and system directory for configuration files are specified during
+clang build using cmake parameters, CLANG_CONFIG_FILE_USER_DIR and
+CLANG_CONFIG_FILE_SYSTEM_DIR respectively. The first found file is used. It is

cmake -> CMake



Comment at: docs/UsersManual.rst:721
+clang build using cmake parameters, CLANG_CONFIG_FILE_USER_DIR and
+CLANG_CONFIG_FILE_SYSTEM_DIR respectively. The first found file is used. It is
+an error if the required file cannot be found.

The first file found is used.



Comment at: docs/UsersManual.rst:724
+
+Another way to specify configuration file is to encode it in executable name. 
For
+instance, if Clang executable is named `armv7l-clang` (it may be a symbolic 
link

specify a configuration file



Comment at: docs/UsersManual.rst:725
+Another way to specify configuration file is to encode it in executable name. 
For
+instance, if Clang executable is named `armv7l-clang` (it may be a symbolic 
link
+to `clang`), then Clang will search file `armv7l.cfg` in the directory where 
Clang

if the Clang executable



Comment at: docs/UsersManual.rst:726
+instance, if Clang executable is named `armv7l-clang` (it may be a symbolic 
link
+to `clang`), then Clang will search file `armv7l.cfg` in the directory where 
Clang
+resides.

will search for file



Comment at: docs/UsersManual.rst:729
+
+If driver mode is specified in invocation, Clang tries to find file specific 
for
+the specified mode. For instance, if executable file is `x86_64-clang-cl`, 
Clang

If a driver mode



Comment at: docs/UsersManual.rst:729
+
+If driver mode is specified in invocation, Clang tries to find file specific 
for
+the specified mode. For instance, if executable file is `x86_64-clang-cl`, 
Clang

hfinkel wrote:
> If a driver mode
to find a file



Comment at: docs/UsersManual.rst:730
+If driver mode is specified in invocation, Clang tries to find file specific 
for
+the specified mode. For instance, if executable file is `x86_64-clang-cl`, 
Clang
+first looks for `x86_64-cl.cfg` and if it is not found, looks for `x86_64.cfg'.

if the executable is named `x86_64-clang-cl`



Comment at: docs/UsersManual.rst:733
+
+If command line contains options that effectively changes target architecture
+(these are -m32, -EL and some other) and configuration file starts with 
architecture

If the command line



Comment at: docs/UsersManual.rst:733
+
+If command line contains options that effectively changes target architecture
+(these are -m32, -EL and some other) and configuration file starts with 
architecture

hfinkel wrote:
> If the command line
changes -> change



Comment at: docs/UsersManual.rst:734
+If command line contains options that effecti

[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

2017-10-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 118143.
lebedev.ri added a comment.

Rework `AnalyzeComparison()` and `DiagnoseOutOfRangeComparison()` - avoid that 
fast-return path in `DiagnoseOutOfRangeComparison()`
`AnalyzeComparison()` is now a bit smarter, and it

1. calls `CheckTautologicalComparison()`
2. returns if it diagnosed anything
3. else, calls `DiagnoseOutOfRangeComparison()`
4. returns if it diagnosed anything.

`check-clang-sema` and `check-clang-semacxx` are good.
Stage-2 build still good.


Repository:
  rL LLVM

https://reviews.llvm.org/D38101

Files:
  docs/ReleaseNotes.rst
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/outof-range-constant-compare.c
  test/Sema/tautological-constant-compare.c
  test/Sema/tautological-unsigned-zero-compare.c

Index: test/Sema/tautological-unsigned-zero-compare.c
===
--- test/Sema/tautological-unsigned-zero-compare.c
+++ test/Sema/tautological-unsigned-zero-compare.c
@@ -1,47 +1,370 @@
 // RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s
 // RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DTEST -verify -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-zero-compare -verify -x c++ %s
 
-unsigned value(void);
+unsigned uvalue(void);
+signed int svalue(void);
 
-int main() {
-  unsigned un = value();
+#define macro(val) val
+
+#ifdef __cplusplus
+template
+void TFunc() {
+  // Make sure that we do warn for normal variables in template functions !
+  unsigned char c = svalue();
+#ifdef TEST
+  if (c < 0) // expected-warning {{comparison of unsigned expression < 0 is always false}}
+  return;
+#else
+  if (c < 0)
+  return;
+#endif
+
+  if (c < macro(0))
+  return;
+
+  T v = svalue();
+  if (v < 0)
+  return;
+}
+#endif
+
+int main()
+{
+#ifdef __cplusplus
+  TFunc();
+  TFunc();
+#endif
+
+  unsigned un = uvalue();
 
 #ifdef TEST
+  if (un == 0)
+  return 0;
+  if (un != 0)
+  return 0;
   if (un < 0) // expected-warning {{comparison of unsigned expression < 0 is always false}}
-return 0;
+  return 0;
+  if (un <= 0)
+  return 0;
+  if (un > 0)
+  return 0;
   if (un >= 0) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
-return 0;
+  return 0;
+
+  if (0 == un)
+  return 0;
+  if (0 != un)
+  return 0;
+  if (0 < un)
+  return 0;
   if (0 <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
-return 0;
+  return 0;
   if (0 > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}
-return 0;
-  if (un < 0U) // expected-warning {{comparison of unsigned expression < 0 is always false}}
-return 0;
-  if (un >= 0U) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
-return 0;
-  if (0U <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
-return 0;
-  if (0U > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}
-return 0;
+  return 0;
+  if (0 >= un)
+  return 0;
+
+  if (un == 0UL)
+  return 0;
+  if (un != 0UL)
+  return 0;
+  if (un < 0UL) // expected-warning {{comparison of unsigned expression < 0 is always false}}
+  return 0;
+  if (un <= 0UL)
+  return 0;
+  if (un > 0UL)
+  return 0;
+  if (un >= 0UL) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
+  return 0;
+
+  if (0UL == un)
+  return 0;
+  if (0UL != un)
+  return 0;
+  if (0UL < un)
+  return 0;
+  if (0UL <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}
+  return 0;
+  if (0UL > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}
+  return 0;
+  if (0UL >= un)
+  return 0;
 #else
 // expected-no-diagnostics
+  if (un == 0)
+  return 0;
+  if (un != 0)
+  return 0;
   if (un < 0)
-return 0;
+  return 0;
+  if (un <= 0)
+  return 0;
+  if (un > 0)
+  return 0;
   if (un >= 0)
-return 0;
+  return 0;
+
+  if (0 == un)
+  return 0;
+  if (0 != un)
+  return 0;
+  if (0 < un)
+  return 0;
   if (0 <= un)
-return 0;
+  return 0;
   if (0 > un)
-return 0;
-  if (un < 0U)
-return 0;
-  if (un >= 0U)
-return 0;
-  if (0U <= un)
-return 0;
-  if (0U > un)
-return 0;
+  return 0;
+  if (0 >= un)
+  return 0;
+
+  if (un == 0UL)
+  return 0;
+  if (un != 0UL)
+  return 0;
+  if (un < 0UL)
+  return 0;
+  if (un <= 0UL)
+  return 0;
+  if (un > 0UL)
+  return 0;
+  if (un >= 0UL)
+  return 0;
+
+  if (0UL == un)
+  return 0;
+  if (0UL != un)
+  return 0;
+  if (0UL < un)
+  return 0;
+  if (0UL <= un)
+  return 0;
+  if (0UL > un)
+  return 0;
+  if (0UL 

[PATCH] D37436: Initial implementation of C attributes (WG14 N2137)

2017-10-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:5973-5974
+
+// If there are attributes following the identifier list, parse them and 
+// prohibit them.
+MaybeParseCXX11Attributes(FnAttrs);

rsmith wrote:
> Do you anticipate people trying this? Is the concern here that a function 
> declarator can normally be followed by attributes, and so consistency might 
> imply that we allow attributes on the function declarator after an 
> identifier-list instead?
I don't anticipate this being a common thing for people to try, but it is to 
prevent an ambiguity:
```
void fp(a, b) [[foo]] int a, b; { }
```
Does [[foo]] appertain to the function type or to the declarations `a` and `b`. 
N2165 prohibits attributes from appearing in this location.



Comment at: clang/lib/Parse/ParseTentative.cpp:592
   bool OuterMightBeMessageSend) {
-  if (Tok.is(tok::kw_alignas))
+  if (Tok.is(tok::kw_alignas) && getLangOpts().CPlusPlus11)
 return CAK_AttributeSpecifier;

rsmith wrote:
> This change is redundant. We wouldn't lex a `kw_alignas` token outside C++11.
Ah, I thought that we would hit this case for `_Alignas` as well, but I see 
that's a different keyword. Just to double-check -- we don't expect 
`-fdouble-square-bracket-attributes` to enable `alignas` in C++98, correct?


https://reviews.llvm.org/D37436



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37436: Initial implementation of C attributes (WG14 N2137)

2017-10-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 118141.
aaron.ballman marked 5 inline comments as done.
aaron.ballman added a comment.

Corrected review feedback from Richard.

- Changed the cc1 option to -fdouble-square-bracket-attributes
- Corrected regression with opaque-enum-declarations


https://reviews.llvm.org/D37436

Files:
  ../llvm/tools/clang/include/clang/Basic/Attr.td
  ../llvm/tools/clang/include/clang/Basic/Attributes.h
  ../llvm/tools/clang/include/clang/Basic/LangOptions.def
  ../llvm/tools/clang/include/clang/Driver/Options.td
  ../llvm/tools/clang/include/clang/Parse/Parser.h
  ../llvm/tools/clang/include/clang/Sema/AttributeList.h
  ../llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp
  ../llvm/tools/clang/lib/Lex/Lexer.cpp
  ../llvm/tools/clang/lib/Parse/ParseDecl.cpp
  ../llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp
  ../llvm/tools/clang/lib/Sema/AttributeList.cpp
  ../llvm/tools/clang/test/Misc/ast-dump-c-attr.c
  ../llvm/tools/clang/test/Parser/c2x-attributes.c
  ../llvm/tools/clang/test/Parser/c2x-attributes.m
  ../llvm/tools/clang/test/Sema/attr-deprecated-c2x.c
  ../llvm/tools/clang/utils/TableGen/ClangAttrEmitter.cpp

Index: ../llvm/tools/clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- ../llvm/tools/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ ../llvm/tools/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -58,7 +58,7 @@
 
 assert(V != "GCC" && "Given a GCC spelling, which means this hasn't been"
"flattened!");
-if (V == "CXX11" || V == "Pragma")
+if (V == "CXX11" || V == "C2x" || V == "Pragma")
   NS = Spelling.getValueAsString("Namespace");
 bool Unset;
 K = Spelling.getValueAsBitOrUnset("KnownToGCC", Unset);
@@ -1326,7 +1326,7 @@
 if (Variety == "GNU") {
   Prefix = " __attribute__((";
   Suffix = "))";
-} else if (Variety == "CXX11") {
+} else if (Variety == "CXX11" || Variety == "C2x") {
   Prefix = " [[";
   Suffix = "]]";
   std::string Namespace = Spellings[I].nameSpace();
@@ -2716,10 +2716,14 @@
   // If this is the C++11 variety, also add in the LangOpts test.
   if (Variety == "CXX11")
 Test += " && LangOpts.CPlusPlus11";
+  else if (Variety == "C2x")
+Test += " && LangOpts.DoubleSquareBracketAttributes";
 } else if (Variety == "CXX11")
   // C++11 mode should be checked against LangOpts, which is presumed to be
   // present in the caller.
   Test = "LangOpts.CPlusPlus11";
+else if (Variety == "C2x")
+  Test = "LangOpts.DoubleSquareBracketAttributes";
 
 std::string TestStr =
 !Test.empty() ? Test + " ? " + llvm::itostr(Version) + " : 0" : "1";
@@ -2740,7 +2744,7 @@
   // and declspecs. Then generate a big switch statement for each of them.
   std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
   std::vector Declspec, Microsoft, GNU, Pragma;
-  std::map> CXX;
+  std::map> CXX, C2x;
 
   // Walk over the list of all attributes, and split them out based on the
   // spelling variety.
@@ -2756,6 +2760,8 @@
 Microsoft.push_back(R);
   else if (Variety == "CXX11")
 CXX[SI.nameSpace()].push_back(R);
+  else if (Variety == "C2x")
+C2x[SI.nameSpace()].push_back(R);
   else if (Variety == "Pragma")
 Pragma.push_back(R);
 }
@@ -2775,20 +2781,25 @@
   OS << "case AttrSyntax::Pragma:\n";
   OS << "  return llvm::StringSwitch(Name)\n";
   GenerateHasAttrSpellingStringSwitch(Pragma, OS, "Pragma");
-  OS << "case AttrSyntax::CXX: {\n";
-  // C++11-style attributes are further split out based on the Scope.
-  for (auto I = CXX.cbegin(), E = CXX.cend(); I != E; ++I) {
-if (I != CXX.begin())
-  OS << " else ";
-if (I->first.empty())
-  OS << "if (!Scope || Scope->getName() == \"\") {\n";
-else
-  OS << "if (Scope->getName() == \"" << I->first << "\") {\n";
-OS << "  return llvm::StringSwitch(Name)\n";
-GenerateHasAttrSpellingStringSwitch(I->second, OS, "CXX11", I->first);
-OS << "}";
-  }
-  OS << "\n}\n";
+  auto fn = [&OS](const char *Spelling, const char *Variety,
+  const std::map> &List) {
+OS << "case AttrSyntax::" << Variety << ": {\n";
+// C++11-style attributes are further split out based on the Scope.
+for (auto I = List.cbegin(), E = List.cend(); I != E; ++I) {
+  if (I != List.cbegin())
+OS << " else ";
+  if (I->first.empty())
+OS << "if (!Scope || Scope->getName() == \"\") {\n";
+  else
+OS << "if (Scope->getName() == \"" << I->first << "\") {\n";
+  OS << "  return llvm::StringSwitch(Name)\n";
+  GenerateHasAttrSpellingStringSwitch(I->second, OS, Spelling, I->first);
+  OS << "}";
+}
+OS << "\n}\n";
+  };
+  fn("CXX11", "CXX", CXX);
+  fn("C2x", "C", C2x);
   OS << "}\n";
 }
 
@@ -2809,10 +2820,11 @@
  << StringSwitch(Spellings[I].variety())
 .Case("GNU", 0)
 .Case(

[PATCH] D38667: AMDGPU: Parse r600 CPU name early and expose FMAF capability

2017-10-07 Thread Jan Vesely via Phabricator via cfe-commits
jvesely created this revision.
Herald added subscribers: t-tye, tpr, dstuttard, nhaehnle, wdng, kzhuravl.

Improve amdgcn macro test


Repository:
  rL LLVM

https://reviews.llvm.org/D38667

Files:
  lib/Basic/Targets/AMDGPU.cpp
  test/Preprocessor/predefined-arch-macros.c


Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -2325,10 +2325,20 @@
 // RUN: -target amdgcn-unknown-unknown \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_AMDGCN
 // CHECK_AMDGCN: #define __AMDGCN__ 1
+// CHECK_AMDGCN: #define __HAS_FMAF__ 1
+// CHECK_AMDGCN: #define __HAS_FP64__ 1
+// CHECK_AMDGCN: #define __HAS_LDEXPF__ 1
 
 // Begin r600 tests 
 //
 // RUN: %clang -march=amdgcn -E -dM %s -o - 2>&1 \
 // RUN: -target r600-unknown-unknown \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_R600
 // CHECK_R600: #define __R600__ 1
+// CHECK_R600-NOT: #define __HAS_FMAF__ 1
+
+// RUN: %clang -march=amdgcn -mcpu=cypress -E -dM %s -o - 2>&1 \
+// RUN: -target r600-unknown-unknown \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_R600_FP64
+// CHECK_R600_FP64-DAG: #define __R600__ 1
+// CHECK_R600_FP64-DAG: #define __HAS_FMAF__ 1
Index: lib/Basic/Targets/AMDGPU.cpp
===
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -304,14 +304,20 @@
 
 AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
-: TargetInfo(Triple), GPU(isAMDGCN(Triple) ? GK_GFX6 : GK_R600),
+: TargetInfo(Triple),
+  GPU(isAMDGCN(Triple) ? GK_GFX6 : parseR600Name(Opts.CPU)),
   hasFP64(false), hasFMAF(false), hasLDEXPF(false),
   AS(isGenericZero(Triple)) {
   if (getTriple().getArch() == llvm::Triple::amdgcn) {
 hasFP64 = true;
 hasFMAF = true;
 hasLDEXPF = true;
   }
+  if (getTriple().getArch() == llvm::Triple::r600) {
+if (GPU == GK_EVERGREEN_DOUBLE_OPS || GPU == GK_CAYMAN) {
+  hasFMAF = true;
+}
+  }
   auto IsGenericZero = isGenericZero(Triple);
   resetDataLayout(getTriple().getArch() == llvm::Triple::amdgcn
   ? (IsGenericZero ? DataLayoutStringSIGenericIsZero


Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -2325,10 +2325,20 @@
 // RUN: -target amdgcn-unknown-unknown \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_AMDGCN
 // CHECK_AMDGCN: #define __AMDGCN__ 1
+// CHECK_AMDGCN: #define __HAS_FMAF__ 1
+// CHECK_AMDGCN: #define __HAS_FP64__ 1
+// CHECK_AMDGCN: #define __HAS_LDEXPF__ 1
 
 // Begin r600 tests 
 //
 // RUN: %clang -march=amdgcn -E -dM %s -o - 2>&1 \
 // RUN: -target r600-unknown-unknown \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_R600
 // CHECK_R600: #define __R600__ 1
+// CHECK_R600-NOT: #define __HAS_FMAF__ 1
+
+// RUN: %clang -march=amdgcn -mcpu=cypress -E -dM %s -o - 2>&1 \
+// RUN: -target r600-unknown-unknown \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_R600_FP64
+// CHECK_R600_FP64-DAG: #define __R600__ 1
+// CHECK_R600_FP64-DAG: #define __HAS_FMAF__ 1
Index: lib/Basic/Targets/AMDGPU.cpp
===
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -304,14 +304,20 @@
 
 AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
-: TargetInfo(Triple), GPU(isAMDGCN(Triple) ? GK_GFX6 : GK_R600),
+: TargetInfo(Triple),
+  GPU(isAMDGCN(Triple) ? GK_GFX6 : parseR600Name(Opts.CPU)),
   hasFP64(false), hasFMAF(false), hasLDEXPF(false),
   AS(isGenericZero(Triple)) {
   if (getTriple().getArch() == llvm::Triple::amdgcn) {
 hasFP64 = true;
 hasFMAF = true;
 hasLDEXPF = true;
   }
+  if (getTriple().getArch() == llvm::Triple::r600) {
+if (GPU == GK_EVERGREEN_DOUBLE_OPS || GPU == GK_CAYMAN) {
+  hasFMAF = true;
+}
+  }
   auto IsGenericZero = isGenericZero(Triple);
   resetDataLayout(getTriple().getArch() == llvm::Triple::amdgcn
   ? (IsGenericZero ? DataLayoutStringSIGenericIsZero
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

2017-10-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: lib/Sema/SemaChecking.cpp:8719
+  // Type limit values are handled later by CheckTautologicalComparison().
+  if (IsTypeLimit(S, Other, Constant, ConstValue) && (!OtherIsBooleanType))
 return;

lebedev.ri wrote:
> lebedev.ri wrote:
> > rsmith wrote:
> > > Is this necessary? (Aren't the type limit values always within the range 
> > > of the type in question?)
> > > 
> > > Can we avoid evaluating `Constant` a extra time here? (We already have 
> > > its value in `Value`.)
> > Uhm, good question :)
> > If i remove this, `check-clang-sema` and `check-clang-semacxx` still pass.
> > I agree that it does not make much sense. Initially it was only checking 
> > for `Value == 0`.
> > Git suggests that initially this branch was added by @rtrieu, maybe can 
> > help.
> [[ 
> https://github.com/llvm-mirror/clang/commit/526e627d2bd7e8cbf630526d315c90864898d9ff#diff-93faf32157a807b1b7953f3747db08b6R4332
>  | The most original version of this code ]]
> After some though i think the initial check `Value == 0` was simply to 
> quickly bail out
> out of `DiagnoseOutOfRangeComparison()`, and not waste any time for the 
> obvious case
> (`0`), which can't be out-of-range, ever. So i think the right behaviour 
> could be:
> 1. Either simply restore the original check:
> ```
> // 0 values are handled later by CheckTautologicalComparison().
> if ((Value == 0) && (!OtherIsBooleanType))
>   return;
> ```
> And add a comment there about it
> 2. Or, drop it completely
> 3. Or, perhaps refactor `CheckTautologicalComparison()`, and more or less 
> call it from
>  function `AnalyzeComparison()`, before calling 
> `DiagnoseOutOfRangeComparison()`,
>  thus completely avoiding the need to re-evaluate `Constant` there later 
> on,
>  and simplify the logic in the process.
> 
> I personally think the `3.` *might* be best.
> WDYT?
Tried implementing `3.`.
It won't work, because `DiagnoseOutOfRangeComparison()` needs the `{L,R}HS`
after `IgnoreParenImpCasts()`, and `CheckTautologicalComparison()` is not ok 
with that.
It seems that at most, i could re-use the detection of `RhsConstant`.

So, new options:
1. Either simply restore the original check, and add a comment there about the 
logic behind it
2. Or, drop the check completely
3. Or, move the  `CheckTautologicalComparison()` call before 
`DiagnoseOutOfRangeComparison()`
 And if `DiagnoseOutOfRangeComparison()` has already emitted diagnostic, 
return.
 Much like what `CheckTautologicalComparison()` already does.
 
So i think `3.` is still the best option :)
(tried implementing it, appears to work)


Repository:
  rL LLVM

https://reviews.llvm.org/D38101



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r315149 - Fix signed/unsigned warning

2017-10-07 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Sat Oct  7 05:24:10 2017
New Revision: 315149

URL: http://llvm.org/viewvc/llvm-project?rev=315149&view=rev
Log:
Fix signed/unsigned warning

Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=315149&r1=315148&r2=315149&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Sat Oct  7 05:24:10 2017
@@ -616,7 +616,7 @@ public:
 // Right now the overloaded candidates seem to be provided in a "best fit"
 // order, so I'm not too worried about this.
 SigHelp.activeSignature = 0;
-assert(CurrentArg <= std::numeric_limits::max() &&
+assert(CurrentArg <= (unsigned)std::numeric_limits::max() &&
"too many arguments");
 SigHelp.activeParameter = static_cast(CurrentArg);
 for (unsigned I = 0; I < NumCandidates; ++I) {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libclc] r315147 - Delete empy directory

2017-10-07 Thread Jeroen Ketema via cfe-commits
Author: jketema
Date: Sat Oct  7 02:10:44 2017
New Revision: 315147

URL: http://llvm.org/viewvc/llvm-project?rev=315147&view=rev
Log:
Delete empy directory

Removed:
libclc/trunk/ptx/lib/integer/

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r314571 - [Analyzer] Synthesize function body for std::call_once

2017-10-07 Thread Alexander Kornienko via cfe-commits
This revision might be the cause of
https://bugs.llvm.org/show_bug.cgi?id=34869. I'm still working on a reduced
test case.

On Sat, Sep 30, 2017 at 2:03 AM, George Karpenkov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: george.karpenkov
> Date: Fri Sep 29 17:03:22 2017
> New Revision: 314571
>
> URL: http://llvm.org/viewvc/llvm-project?rev=314571&view=rev
> Log:
> [Analyzer] Synthesize function body for std::call_once
>
> Differential Revision: https://reviews.llvm.org/D37840
>
> Added:
> cfe/trunk/test/Analysis/call_once.cpp
> Modified:
> cfe/trunk/lib/Analysis/BodyFarm.cpp
>
> Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
> Analysis/BodyFarm.cpp?rev=314571&r1=314570&r2=314571&view=diff
> 
> ==
> --- cfe/trunk/lib/Analysis/BodyFarm.cpp (original)
> +++ cfe/trunk/lib/Analysis/BodyFarm.cpp Fri Sep 29 17:03:22 2017
> @@ -14,11 +14,18 @@
>
>  #include "BodyFarm.h"
>  #include "clang/AST/ASTContext.h"
> +#include "clang/AST/CXXInheritance.h"
>  #include "clang/AST/Decl.h"
>  #include "clang/AST/Expr.h"
> +#include "clang/AST/ExprCXX.h"
>  #include "clang/AST/ExprObjC.h"
> +#include "clang/AST/NestedNameSpecifier.h"
>  #include "clang/Analysis/CodeInjector.h"
> +#include "clang/Basic/OperatorKinds.h"
>  #include "llvm/ADT/StringSwitch.h"
> +#include "llvm/Support/Debug.h"
> +
> +#define DEBUG_TYPE "body-farm"
>
>  using namespace clang;
>
> @@ -55,7 +62,9 @@ public:
>CompoundStmt *makeCompound(ArrayRef);
>
>/// Create a new DeclRefExpr for the referenced variable.
> -  DeclRefExpr *makeDeclRefExpr(const VarDecl *D);
> +  DeclRefExpr *makeDeclRefExpr(const VarDecl *D,
> +   bool RefersToEnclosingVariableOrCapture =
> false,
> +   bool GetNonReferenceType = false);
>
>/// Create a new UnaryOperator representing a dereference.
>UnaryOperator *makeDereference(const Expr *Arg, QualType Ty);
> @@ -66,9 +75,24 @@ public:
>/// Create an implicit cast to a builtin boolean type.
>ImplicitCastExpr *makeIntegralCastToBoolean(const Expr *Arg);
>
> -  // Create an implicit cast for lvalue-to-rvaluate conversions.
> +  /// Create an implicit cast for lvalue-to-rvaluate conversions.
>ImplicitCastExpr *makeLvalueToRvalue(const Expr *Arg, QualType Ty);
>
> +  /// Create an implicit cast for lvalue-to-rvaluate conversions.
> +  ImplicitCastExpr *makeLvalueToRvalue(const Expr *Arg,
> +   bool GetNonReferenceType = false);
> +
> +  /// Make RValue out of variable declaration, creating a temporary
> +  /// DeclRefExpr in the process.
> +  ImplicitCastExpr *
> +  makeLvalueToRvalue(const VarDecl *Decl,
> + bool RefersToEnclosingVariableOrCapture = false,
> + bool GetNonReferenceType = false);
> +
> +  /// Create an implicit cast of the given type.
> +  ImplicitCastExpr *makeImplicitCast(const Expr *Arg, QualType Ty,
> + CastKind CK = CK_LValueToRValue);
> +
>/// Create an Objective-C bool literal.
>ObjCBoolLiteralExpr *makeObjCBool(bool Val);
>
> @@ -78,6 +102,18 @@ public:
>/// Create a Return statement.
>ReturnStmt *makeReturn(const Expr *RetVal);
>
> +  /// Create an integer literal.
> +  IntegerLiteral *makeIntegerLiteral(uint64_t value);
> +
> +  /// Create a member expression.
> +  MemberExpr *makeMemberExpression(Expr *base, ValueDecl *MemberDecl,
> +   bool IsArrow = false,
> +   ExprValueKind ValueKind = VK_LValue);
> +
> +  /// Returns a *first* member field of a record declaration with a given
> name.
> +  /// \return an nullptr if no member with such a name exists.
> +  NamedDecl *findMemberField(const CXXRecordDecl *RD, StringRef Name);
> +
>  private:
>ASTContext &C;
>  };
> @@ -106,16 +142,16 @@ CompoundStmt *ASTMaker::makeCompound(Arr
>return new (C) CompoundStmt(C, Stmts, SourceLocation(),
> SourceLocation());
>  }
>
> -DeclRefExpr *ASTMaker::makeDeclRefExpr(const VarDecl *D) {
> -  DeclRefExpr *DR =
> -DeclRefExpr::Create(/* Ctx = */ C,
> -/* QualifierLoc = */ NestedNameSpecifierLoc(),
> -/* TemplateKWLoc = */ SourceLocation(),
> -/* D = */ const_cast(D),
> -/* RefersToEnclosingVariableOrCapture = */ false,
> -/* NameLoc = */ SourceLocation(),
> -/* T = */ D->getType(),
> -/* VK = */ VK_LValue);
> +DeclRefExpr *ASTMaker::makeDeclRefExpr(const VarDecl *D,
> +   bool RefersToEnclosingVariableOrCap
> ture,
> +   bool GetNonReferenceType) {
> +  auto Type = D->getType();
> +  if (GetNonReferenceType)
> +Type = Type.getNonReferenceType();
> +