[PATCH] D85362: [CMake] Print the autodetected host linker version

2020-08-05 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG633e3dacf27e: [CMake] Print the autodetected host linker 
version (authored by phosek).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85362/new/

https://reviews.llvm.org/D85362

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -424,15 +424,15 @@
 RESULT_VARIABLE HAD_ERROR
 OUTPUT_VARIABLE LD_V_OUTPUT
   )
-  if (NOT HAD_ERROR)
-if ("${LD_V_OUTPUT}" MATCHES ".*ld64-([0-9.]+).*")
-  string(REGEX REPLACE ".*ld64-([0-9.]+).*" "\\1" HOST_LINK_VERSION 
${LD_V_OUTPUT})
-elseif ("${LD_V_OUTPUT}" MATCHES "[^0-9]*([0-9.]+).*")
-  string(REGEX REPLACE "[^0-9]*([0-9.]+).*" "\\1" HOST_LINK_VERSION 
${LD_V_OUTPUT})
-endif()
-  else()
+  if (HAD_ERROR)
 message(FATAL_ERROR "${CMAKE_LINKER} failed with status ${HAD_ERROR}")
   endif()
+  if ("${LD_V_OUTPUT}" MATCHES ".*ld64-([0-9.]+).*")
+string(REGEX REPLACE ".*ld64-([0-9.]+).*" "\\1" HOST_LINK_VERSION 
${LD_V_OUTPUT})
+  elseif ("${LD_V_OUTPUT}" MATCHES "[^0-9]*([0-9.]+).*")
+string(REGEX REPLACE "[^0-9]*([0-9.]+).*" "\\1" HOST_LINK_VERSION 
${LD_V_OUTPUT})
+  endif()
+  message(STATUS "Host linker version: ${HOST_LINK_VERSION}")
 endif()
 
 include(CMakeParseArguments)


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -424,15 +424,15 @@
 RESULT_VARIABLE HAD_ERROR
 OUTPUT_VARIABLE LD_V_OUTPUT
   )
-  if (NOT HAD_ERROR)
-if ("${LD_V_OUTPUT}" MATCHES ".*ld64-([0-9.]+).*")
-  string(REGEX REPLACE ".*ld64-([0-9.]+).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT})
-elseif ("${LD_V_OUTPUT}" MATCHES "[^0-9]*([0-9.]+).*")
-  string(REGEX REPLACE "[^0-9]*([0-9.]+).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT})
-endif()
-  else()
+  if (HAD_ERROR)
 message(FATAL_ERROR "${CMAKE_LINKER} failed with status ${HAD_ERROR}")
   endif()
+  if ("${LD_V_OUTPUT}" MATCHES ".*ld64-([0-9.]+).*")
+string(REGEX REPLACE ".*ld64-([0-9.]+).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT})
+  elseif ("${LD_V_OUTPUT}" MATCHES "[^0-9]*([0-9.]+).*")
+string(REGEX REPLACE "[^0-9]*([0-9.]+).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT})
+  endif()
+  message(STATUS "Host linker version: ${HOST_LINK_VERSION}")
 endif()
 
 include(CMakeParseArguments)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 633e3da - [CMake] Print the autodetected host linker version

2020-08-05 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2020-08-05T20:22:28-07:00
New Revision: 633e3dacf27ea4950b7067803502490597ba96e0

URL: 
https://github.com/llvm/llvm-project/commit/633e3dacf27ea4950b7067803502490597ba96e0
DIFF: 
https://github.com/llvm/llvm-project/commit/633e3dacf27ea4950b7067803502490597ba96e0.diff

LOG: [CMake] Print the autodetected host linker version

There's no easy way to find out what the autodetected version is, but
sometimes it may be useful to confirm that the right version is being
used. Print it as CMake status message.

Differential Revision: https://reviews.llvm.org/D85362

Added: 


Modified: 
clang/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 7baf93cbf792..5ac0e6b6ef0c 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -424,15 +424,15 @@ if (APPLE)
 RESULT_VARIABLE HAD_ERROR
 OUTPUT_VARIABLE LD_V_OUTPUT
   )
-  if (NOT HAD_ERROR)
-if ("${LD_V_OUTPUT}" MATCHES ".*ld64-([0-9.]+).*")
-  string(REGEX REPLACE ".*ld64-([0-9.]+).*" "\\1" HOST_LINK_VERSION 
${LD_V_OUTPUT})
-elseif ("${LD_V_OUTPUT}" MATCHES "[^0-9]*([0-9.]+).*")
-  string(REGEX REPLACE "[^0-9]*([0-9.]+).*" "\\1" HOST_LINK_VERSION 
${LD_V_OUTPUT})
-endif()
-  else()
+  if (HAD_ERROR)
 message(FATAL_ERROR "${CMAKE_LINKER} failed with status ${HAD_ERROR}")
   endif()
+  if ("${LD_V_OUTPUT}" MATCHES ".*ld64-([0-9.]+).*")
+string(REGEX REPLACE ".*ld64-([0-9.]+).*" "\\1" HOST_LINK_VERSION 
${LD_V_OUTPUT})
+  elseif ("${LD_V_OUTPUT}" MATCHES "[^0-9]*([0-9.]+).*")
+string(REGEX REPLACE "[^0-9]*([0-9.]+).*" "\\1" HOST_LINK_VERSION 
${LD_V_OUTPUT})
+  endif()
+  message(STATUS "Host linker version: ${HOST_LINK_VERSION}")
 endif()
 
 include(CMakeParseArguments)



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


[PATCH] D85309: [WIP][clang][Driver] Support GNU ld on Solaris

2020-08-05 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Please find a suitable test file (clang/test/Driver/solaris-*.c) and add some 
tests there (for example, solaris-ld.c)
The challenge is that CLANG_ENABLE_GLD is not a default configuration, so 
leaving out tests may be fine.




Comment at: clang/CMakeLists.txt:281
 
+option(CLANG_ENABLE_GLD "Default to GNU ld." OFF)
+

Mention SOLARIS in the variable name? Users on other OSes don't need to read 
the description of this variable.

It will also make the abbreviation `GLD` more legitimate. GLD isn't a 
well-recognized abbreviation for GNU ld.



Comment at: clang/lib/Driver/ToolChains/Solaris.cpp:252
+  // FIXME: Hack around /usr/gnu/bin/ld being configure with --with-sysroot.
+  return "/vol/gcc/bin/gld-2.35";
+  //return "/usr/gnu/bin/ld";

The hard-coded version doesn't sound great.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85309/new/

https://reviews.llvm.org/D85309

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


[PATCH] D84412: [clang][Driver] Don't hardcode --as-needed/--no-as-needed on Illumos

2020-08-05 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84412/new/

https://reviews.llvm.org/D84412

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


[PATCH] D85390: [Clang] Add note for bad conversion when expression is of forward-declared type

2020-08-05 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu created this revision.
zequanwu added a reviewer: hans.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
zequanwu requested review of this revision.

I think one note to speficify the forward declaretion location should be 
enough. Two notes might be too noisy.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85390

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/Modules/namespaces.cpp
  clang/test/SemaCXX/elaborated-type-specifier.cpp


Index: clang/test/SemaCXX/elaborated-type-specifier.cpp
===
--- clang/test/SemaCXX/elaborated-type-specifier.cpp
+++ clang/test/SemaCXX/elaborated-type-specifier.cpp
@@ -26,7 +26,7 @@
 }
 
 void test_X_elab(NS::X x) {
-  struct S4 *s4 = 0;
+  struct S4 *s4 = 0; // expected-note{{forward declaration of 'S4'}}
   x.test_elab2(s4); // expected-error{{cannot initialize a parameter of type 
'NS::S4 *' with an lvalue of type 'struct S4 *'}}
 }
 
Index: clang/test/Modules/namespaces.cpp
===
--- clang/test/Modules/namespaces.cpp
+++ clang/test/Modules/namespaces.cpp
@@ -78,7 +78,8 @@
 
 // expected-note@Inputs/namespaces-right.h:60 {{passing argument to parameter 
here}}
 // expected-note@Inputs/namespaces-right.h:67 {{passing argument to parameter 
here}}
-
+// expected-note@Inputs/namespaces-left.h:63 {{forward declaration of 
'N11::(anonymous namespace)::Foo'}}
+// expected-note@Inputs/namespaces-left.h:70 {{forward declaration of 
'N12::(anonymous namespace)::Foo'}}
 // Test that bringing in one name from an overload set does not hide the rest.
 void testPartialImportOfOverloadSet() {
   void (*p)() = N13::p;
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -8707,6 +8707,12 @@
 if (entity.getKind() == InitializedEntity::EK_Result)
   S.EmitRelatedResultTypeNoteForReturn(destType);
   }
+  QualType fromType = op->getType();
+  auto *fromDecl = fromType.getTypePtr()->getPointeeCXXRecordDecl();
+  if (fromDecl && !fromDecl->hasDefinition() && !fromDecl->isInvalidDecl() &&
+  fromDecl->getDeclKind() == Decl::CXXRecord)
+S.Diag(fromDecl->getLocation(), diag::note_forward_declaration)
+<< S.getASTContext().getTagDeclType(fromDecl);
 }
 
 static void diagnoseListInit(Sema , const InitializedEntity ,


Index: clang/test/SemaCXX/elaborated-type-specifier.cpp
===
--- clang/test/SemaCXX/elaborated-type-specifier.cpp
+++ clang/test/SemaCXX/elaborated-type-specifier.cpp
@@ -26,7 +26,7 @@
 }
 
 void test_X_elab(NS::X x) {
-  struct S4 *s4 = 0;
+  struct S4 *s4 = 0; // expected-note{{forward declaration of 'S4'}}
   x.test_elab2(s4); // expected-error{{cannot initialize a parameter of type 'NS::S4 *' with an lvalue of type 'struct S4 *'}}
 }
 
Index: clang/test/Modules/namespaces.cpp
===
--- clang/test/Modules/namespaces.cpp
+++ clang/test/Modules/namespaces.cpp
@@ -78,7 +78,8 @@
 
 // expected-note@Inputs/namespaces-right.h:60 {{passing argument to parameter here}}
 // expected-note@Inputs/namespaces-right.h:67 {{passing argument to parameter here}}
-
+// expected-note@Inputs/namespaces-left.h:63 {{forward declaration of 'N11::(anonymous namespace)::Foo'}}
+// expected-note@Inputs/namespaces-left.h:70 {{forward declaration of 'N12::(anonymous namespace)::Foo'}}
 // Test that bringing in one name from an overload set does not hide the rest.
 void testPartialImportOfOverloadSet() {
   void (*p)() = N13::p;
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -8707,6 +8707,12 @@
 if (entity.getKind() == InitializedEntity::EK_Result)
   S.EmitRelatedResultTypeNoteForReturn(destType);
   }
+  QualType fromType = op->getType();
+  auto *fromDecl = fromType.getTypePtr()->getPointeeCXXRecordDecl();
+  if (fromDecl && !fromDecl->hasDefinition() && !fromDecl->isInvalidDecl() &&
+  fromDecl->getDeclKind() == Decl::CXXRecord)
+S.Diag(fromDecl->getLocation(), diag::note_forward_declaration)
+<< S.getASTContext().getTagDeclType(fromDecl);
 }
 
 static void diagnoseListInit(Sema , const InitializedEntity ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85311: [analyzer][tests] Understand when diagnostics change between builds

2020-08-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Thx!

This is one of the scripts that really deserves tests outside of buildbots. 
Like, it's not uncommon to use it "by hand".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85311/new/

https://reviews.llvm.org/D85311

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


[PATCH] D85362: [CMake] Print the autodetected host linker version

2020-08-05 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai accepted this revision.
smeenai added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85362/new/

https://reviews.llvm.org/D85362

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


[PATCH] D67422: [analyzer] NFC: Move path diagnostic consumer implementations to libAnalysis.

2020-08-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 283461.
NoQ marked 2 inline comments as done.
NoQ added a comment.

Fxd.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67422/new/

https://reviews.llvm.org/D67422

Files:
  clang/include/clang/Analysis/PathDiagnosticConsumers.def
  clang/include/clang/Analysis/PathDiagnosticConsumers.h
  clang/include/clang/StaticAnalyzer/Core/Analyses.def
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
  clang/lib/Analysis/CMakeLists.txt
  clang/lib/Analysis/HTMLPathDiagnosticConsumer.cpp
  clang/lib/Analysis/PlistHTMLPathDiagnosticConsumer.cpp
  clang/lib/Analysis/PlistPathDiagnosticConsumer.cpp
  clang/lib/Analysis/SarifPathDiagnosticConsumer.cpp
  clang/lib/Analysis/TextPathDiagnosticConsumer.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -21,6 +21,7 @@
 #include "clang/Analysis/CallGraph.h"
 #include "clang/Analysis/CodeInjector.h"
 #include "clang/Analysis/PathDiagnostic.h"
+#include "clang/Analysis/PathDiagnosticConsumers.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/CrossTU/CrossTranslationUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
@@ -30,7 +31,6 @@
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
-#include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "llvm/ADT/PostOrderIterator.h"
@@ -152,7 +152,7 @@
   case PD_##NAME:  \
 CREATEFN(Opts->getDiagOpts(), PathConsumers, OutDir, PP, CTU); \
 break;
-#include "clang/StaticAnalyzer/Core/Analyses.def"
+#include "clang/Analysis/PathDiagnosticConsumers.def"
 default:
   llvm_unreachable("Unknown analyzer output type!");
 }
Index: clang/lib/StaticAnalyzer/Core/CMakeLists.txt
===
--- clang/lib/StaticAnalyzer/Core/CMakeLists.txt
+++ clang/lib/StaticAnalyzer/Core/CMakeLists.txt
@@ -30,16 +30,13 @@
   ExprEngineCallAndReturn.cpp
   ExprEngineObjC.cpp
   FunctionSummary.cpp
-  HTMLDiagnostics.cpp
   LoopUnrolling.cpp
   LoopWidening.cpp
   MemRegion.cpp
-  PlistDiagnostics.cpp
   ProgramState.cpp
   RangeConstraintManager.cpp
   RangedConstraintManager.cpp
   RegionStore.cpp
-  SarifDiagnostics.cpp
   SimpleConstraintManager.cpp
   SimpleSValBuilder.cpp
   SMTConstraintManager.cpp
@@ -47,7 +44,6 @@
   SValBuilder.cpp
   SVals.cpp
   SymbolManager.cpp
-  TextDiagnostics.cpp
   WorkList.cpp
 
   LINK_LIBS
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -301,7 +301,7 @@
 AnalysisDiagClients Value = llvm::StringSwitch(Name)
 #define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATFN) \
   .Case(CMDFLAG, PD_##NAME)
-#include "clang/StaticAnalyzer/Core/Analyses.def"
+#include "clang/Analysis/PathDiagnosticConsumers.def"
   .Default(NUM_ANALYSIS_DIAG_CLIENTS);
 if (Value == NUM_ANALYSIS_DIAG_CLIENTS) {
   Diags.Report(diag::err_drv_invalid_value)
Index: clang/lib/Analysis/TextPathDiagnosticConsumer.cpp
===
--- clang/lib/Analysis/TextPathDiagnosticConsumer.cpp
+++ clang/lib/Analysis/TextPathDiagnosticConsumer.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "clang/Analysis/PathDiagnostic.h"
+#include "clang/Analysis/PathDiagnosticConsumers.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
 #include "clang/CrossTU/CrossTranslationUnit.h"
@@ -18,7 +19,6 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
-#include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallPtrSet.h"
Index: clang/lib/Analysis/SarifPathDiagnosticConsumer.cpp

[PATCH] D67422: [analyzer] NFC: Move path diagnostic consumer implementations to libAnalysis.

2020-08-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/Analysis/PlistHTMLPathDiagnosticConsumer.cpp:25
+PathDiagnosticConsumerOptions DiagOpts, PathDiagnosticConsumers ,
+const std::string , const Preprocessor ,
+const cross_tu::CrossTranslationUnitContext ) {

vsavchenko wrote:
> As long as it is a new function, I guess we should definitely keep names 
> according to the **Coding Standards**
It's not new but sure!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67422/new/

https://reviews.llvm.org/D67422

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


[PATCH] D85384: [X86] Add basic support for -mtune command line option in clang

2020-08-05 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: echristo, RKSimon, spatel, efriedma.
Herald added a subscriber: dang.
craig.topper requested review of this revision.

Building on the backend support from D85165 . 
This parses the command line option in the driver, passes it on to CC1 and adds 
a function attribute.

Still need to support tune on the target attribute.
Need to use "generic" as the tuning by default. But need to change generic in 
the backend first.
Need to set tune if march is specified and mtune isn't.
May need to disable getHostCPUName's ability to guess CPU name from features 
when it doesn't have a family/model match for mtune=native. That's what gcc 
appears to do.


https://reviews.llvm.org/D85384

Files:
  clang/include/clang/Basic/TargetOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/tune-cpu.c
  clang/test/Driver/x86-mtune.c
  clang/test/Misc/target-invalid-cpu-note.c

Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -32,6 +32,30 @@
 // X86_64-SAME: athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1,
 // X86_64-SAME: btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64
 
+// RUN: not %clang_cc1 -triple i386--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_X86
+// TUNE_X86: error: unknown target CPU 'not-a-cpu'
+// TUNE_X86: note: valid target CPU values are: i386, i486, winchip-c6, winchip2, c3,
+// TUNE_X86-SAME: i586, pentium, pentium-mmx, pentiumpro, i686, pentium2, pentium3,
+// TUNE_X86-SAME: pentium3m, pentium-m, c3-2, yonah, pentium4, pentium4m, prescott,
+// TUNE_X86-SAME: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont,
+// TUNE_X86-SAME: nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge,
+// TUNE_X86-SAME: core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512,
+// TUNE_X86-SAME: skx, cascadelake, cooperlake, cannonlake, icelake-client, icelake-server, tigerlake, knl, knm, lakemont, k6, k6-2, k6-3,
+// TUNE_X86-SAME: athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64,
+// TUNE_X86-SAME: athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10,
+// TUNE_X86-SAME: barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2,
+// TUNE_X86-SAME: x86-64, geode
+
+// RUN: not %clang_cc1 -triple x86_64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_X86_64
+// TUNE_X86_64: error: unknown target CPU 'not-a-cpu'
+// TUNE_X86_64: note: valid target CPU values are: nocona, core2, penryn, bonnell,
+// TUNE_X86_64-SAME: atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere,
+// TUNE_X86_64-SAME: sandybridge, corei7-avx, ivybridge, core-avx-i, haswell,
+// TUNE_X86_64-SAME: core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake,
+// TUNE_X86_64-SAME: icelake-client, icelake-server, tigerlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3,
+// TUNE_X86_64-SAME: athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1,
+// TUNE_X86_64-SAME: btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64
+
 // RUN: not %clang_cc1 -triple nvptx--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix NVPTX
 // NVPTX: error: unknown target CPU 'not-a-cpu'
 // NVPTX: note: valid target CPU values are: sm_20, sm_21, sm_30, sm_32, sm_35,
Index: clang/test/Driver/x86-mtune.c
===
--- /dev/null
+++ clang/test/Driver/x86-mtune.c
@@ -0,0 +1,5 @@
+// Ensure we support the -mtune flag.
+//
+// RUN: %clang -target x86_64-unknown-unknown -c -### %s -mtune=nocona 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=nocona
+// nocona: "-tune-cpu" "nocona"
Index: clang/test/CodeGen/tune-cpu.c
===
--- /dev/null
+++ clang/test/CodeGen/tune-cpu.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple i686-linux-gnu -target-cpu i686 -tune-cpu nehalem -emit-llvm %s -o - | FileCheck %s
+
+int baz(int a) { return 4; }
+
+// CHECK: baz{{.*}} #0
+// CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87" "tune-cpu"="nehalem"
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3649,6 +3649,7 @@
   Opts.EABIVersion = EABIVersion;
   }
   Opts.CPU = std::string(Args.getLastArgValue(OPT_target_cpu));
+  Opts.TuneCPU = std::string(Args.getLastArgValue(OPT_tune_cpu));
   Opts.FPMath = 

[PATCH] D85097: [Sema] add warning for comparisons like 'x<=y<=z'

2020-08-05 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers added a comment.

I added prototype fixits per request by Roman, updated the LIT test, and added 
an additional RUN line (one for -Wparentheses and one for 
-Wcompare-op-parentheses). Also filed 
https://bugs.llvm.org/show_bug.cgi?id=47010 to follow up on the FIXME cases at 
the bottom of the LIT since they are out of scope for this change. Thanks for 
the feedback and comments so far, I look forward to driving this change to 
completion.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85097/new/

https://reviews.llvm.org/D85097

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


[PATCH] D85097: [Sema] add warning for comparisons like 'x<=y<=z'

2020-08-05 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 283447.
vabridgers added a comment.

added prototype fixits for review.
added additional RUN test case.
filed https://bugs.llvm.org/show_bug.cgi?id=47010 for other 
warnings improvement post landing of this patch, after lgtm


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85097/new/

https://reviews.llvm.org/D85097

Files:
  clang/docs/DiagnosticsReference.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Misc/warning-wall.c
  clang/test/Sema/warn-compare-op-parentheses.c

Index: clang/test/Sema/warn-compare-op-parentheses.c
===
--- /dev/null
+++ clang/test/Sema/warn-compare-op-parentheses.c
@@ -0,0 +1,245 @@
+// RUN: %clang_cc1 -fsyntax-only -Wcompare-op-parentheses -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wparentheses -verify %s
+
+int tests(int p1, int p2, int p3, int p4, int p5, int p6) {
+  int b = 0;
+  b = p1 < p2 < p3;
+  // expected-warning@-1 {{comparisons like 'x<=y<=z' are interpreted as '(x<=y ? 1 : 0) <= z'}}
+  // expected-note@-2 {{place parentheses around the '<' comparison to silence this warning}}
+  // expected-note@-3 {{place parentheses around the '<' comparison to silence this warning}}
+  // expected-note@-4 {{seperate the expression into two clauses to give it the intended mathematical meaning}}
+  b = p1 < p2 <= p3;
+  // expected-warning@-1 {{comparisons like 'x<=y<=z' are interpreted as '(x<=y ? 1 : 0) <= z'}}
+  // expected-note@-2 {{place parentheses around the '<' comparison to silence this warning}}
+  // expected-note@-3 {{place parentheses around the '<=' comparison to silence this warning}}
+  // expected-note@-4 {{seperate the expression into two clauses to give it the intended mathematical meaning}}
+  b = p1 <= p2 <= p3;
+  // expected-warning@-1 {{comparisons like 'x<=y<=z' are interpreted as '(x<=y ? 1 : 0) <= z'}}
+  // expected-note@-2 {{place parentheses around the '<=' comparison to silence this warning}}
+  // expected-note@-3 {{place parentheses around the '<=' comparison to silence this warning}}
+  // expected-note@-4 {{seperate the expression into two clauses to give it the intended mathematical meaning}}
+  b = p1 <= p2 < p3;
+  // expected-warning@-1 {{comparisons like 'x<=y<=z' are interpreted as '(x<=y ? 1 : 0) <= z'}}
+  // expected-note@-2 {{place parentheses around the '<=' comparison to silence this warning}}
+  // expected-note@-3 {{place parentheses around the '<' comparison to silence this warning}}
+  // expected-note@-4 {{seperate the expression into two clauses to give it the intended mathematical meaning}}
+
+  b = p1 > p2 > p3;
+  // expected-warning@-1 {{comparisons like 'x<=y<=z' are interpreted as '(x<=y ? 1 : 0) <= z'}}
+  // expected-note@-2 {{place parentheses around the '>' comparison to silence this warning}}
+  // expected-note@-3 {{place parentheses around the '>' comparison to silence this warning}}
+  // expected-note@-4 {{seperate the expression into two clauses to give it the intended mathematical meaning}}
+  b = p1 > p2 >= p3;
+  // expected-warning@-1 {{comparisons like 'x<=y<=z' are interpreted as '(x<=y ? 1 : 0) <= z'}}
+  // expected-note@-2 {{place parentheses around the '>' comparison to silence this warning}}
+  // expected-note@-3 {{place parentheses around the '>=' comparison to silence this warning}}
+  // expected-note@-4 {{seperate the expression into two clauses to give it the intended mathematical meaning}}
+  b = p1 >= p2 >= p3;
+  // expected-warning@-1 {{comparisons like 'x<=y<=z' are interpreted as '(x<=y ? 1 : 0) <= z'}}
+  // expected-note@-2 {{place parentheses around the '>=' comparison to silence this warning}}
+  // expected-note@-3 {{place parentheses around the '>=' comparison to silence this warning}}
+  // expected-note@-4 {{seperate the expression into two clauses to give it the intended mathematical meaning}}
+  b = p1 >= p2 > p3;
+  // expected-warning@-1 {{comparisons like 'x<=y<=z' are interpreted as '(x<=y ? 1 : 0) <= z'}}
+  // expected-note@-2 {{place parentheses around the '>=' comparison to silence this warning}}
+  // expected-note@-3 {{place parentheses around the '>' comparison to silence this warning}}
+  // expected-note@-4 {{seperate the expression into two clauses to give it the intended mathematical meaning}}
+
+  b = p1 > p2 < p3;
+  // expected-warning@-1 {{comparisons like 'x<=y<=z' are interpreted as '(x<=y ? 1 : 0) <= z'}}
+  // expected-note@-2 {{place parentheses around the '>' comparison to silence this warning}}
+  // expected-note@-3 {{place parentheses around the '<' comparison to silence this warning}}
+  // expected-note@-4 {{seperate the expression into two clauses to give it the intended mathematical meaning}}
+  b = p1 p3;
+  // expected-warning@-1 {{comparisons like 'x<=y<=z' are interpreted as '(x<=y ? 1 : 0) <= 

[PATCH] D82837: [Analyzer][WebKit] UncountedLambdaCaptureChecker

2020-08-05 Thread Jan Korous via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG820e8d8656ec: [Analyzer][WebKit] 
UncountedLambdaCaptureChecker (authored by jkorous).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82837/new/

https://reviews.llvm.org/D82837

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
  clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp

Index: clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
===
--- /dev/null
+++ clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=webkit.UncountedLambdaCapturesChecker %s 2>&1 | FileCheck %s --strict-whitespace
+#include "mock-types.h"
+
+void raw_ptr() {
+  RefCountable* ref_countable = nullptr;
+  auto foo1 = [ref_countable](){};
+  // CHECK: warning: Captured raw-pointer 'ref_countable' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker]
+  // CHECK-NEXT:{{^}}  auto foo1 = [ref_countable](){};
+  // CHECK-NEXT:{{^}}   ^
+  auto foo2 = [_countable](){};
+  // CHECK: warning: Captured raw-pointer 'ref_countable' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker]
+  auto foo3 = [&](){ ref_countable = nullptr; };
+  // CHECK: warning: Implicitly captured raw-pointer 'ref_countable' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker]
+  // CHECK-NEXT:{{^}}  auto foo3 = [&](){ ref_countable = nullptr; };
+  // CHECK-NEXT:{{^}} ^
+  auto foo4 = [=](){ (void) ref_countable; };
+  // CHECK: warning: Implicitly captured raw-pointer 'ref_countable' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker]
+}
+
+void references() {
+  RefCountable automatic;
+  RefCountable& ref_countable_ref = automatic;
+
+  auto foo1 = [ref_countable_ref](){};
+  // CHECK: warning: Captured reference 'ref_countable_ref' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker]
+  auto foo2 = [_countable_ref](){};
+  // CHECK: warning: Captured reference 'ref_countable_ref' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker]
+  auto foo3 = [&](){ (void) ref_countable_ref; };
+  // CHECK: warning: Implicitly captured reference 'ref_countable_ref' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker]
+  auto foo4 = [=](){ (void) ref_countable_ref; };
+  // CHECK: warning: Implicitly captured reference 'ref_countable_ref' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker]
+}
+
+void quiet() {
+// This code is not expected to trigger any warnings.
+  {
+RefCountable automatic;
+RefCountable _countable_ref = automatic;
+  }
+
+  auto foo3 = [&]() {};
+  auto foo4 = [=]() {};
+  RefCountable *ref_countable = nullptr;
+}
Index: clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
===
--- /dev/null
+++ clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
@@ -0,0 +1,106 @@
+//===- UncountedLambdaCapturesChecker.cpp *- C++ -*-==//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DiagOutputUtils.h"
+#include "PtrTypesSemantics.h"
+#include "clang/AST/CXXInheritance.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class UncountedLambdaCapturesChecker
+: public Checker> {
+private:
+  BugType Bug{this, "Lambda capture of uncounted variable",
+  "WebKit coding guidelines"};
+  mutable BugReporter *BR;
+
+public:
+  void checkASTDecl(const TranslationUnitDecl *TUD, AnalysisManager ,
+BugReporter ) const {
+BR = 
+
+// The calls to checkAST* from AnalysisConsumer don't
+// visit template instantiations or lambda classes. We
+// want to visit those, so we make our own RecursiveASTVisitor.
+struct LocalVisitor : public RecursiveASTVisitor {
+  const UncountedLambdaCapturesChecker *Checker;
+  explicit LocalVisitor(const UncountedLambdaCapturesChecker *Checker)
+  : Checker(Checker) {
+assert(Checker);

[clang] 820e8d8 - [Analyzer][WebKit] UncountedLambdaCaptureChecker

2020-08-05 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-08-05T15:23:55-08:00
New Revision: 820e8d8656ecf65ba29ea27c794c833f230c2698

URL: 
https://github.com/llvm/llvm-project/commit/820e8d8656ecf65ba29ea27c794c833f230c2698
DIFF: 
https://github.com/llvm/llvm-project/commit/820e8d8656ecf65ba29ea27c794c833f230c2698.diff

LOG: [Analyzer][WebKit] UncountedLambdaCaptureChecker

Differential Revision: https://reviews.llvm.org/D82837

Added: 
clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp

Modified: 
clang/docs/analyzer/checkers.rst
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index 1583da7aff09..3b378f735ebc 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -1423,6 +1423,25 @@ Raw pointers and references to uncounted types can't be 
used as class members. O
// ...
  };
 
+.. _webkit-UncountedLambdaCapturesChecker:
+
+webkit.UncountedLambdaCapturesChecker
+"
+Raw pointers and references to uncounted types can't be captured in lambdas. 
Only ref-counted types are allowed.
+
+.. code-block:: cpp
+
+ struct RefCntbl {
+   void ref() {}
+   void deref() {}
+ };
+
+ void foo(RefCntbl* a, RefCntbl& b) {
+   [&, a](){ // warn about 'a'
+ do_something(b); // warn about 'b'
+   };
+ };
+
 .. _alpha-checkers:
 
 Experimental Checkers

diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index cbd925400328..a444843c5006 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1654,6 +1654,10 @@ def NoUncountedMemberChecker : 
Checker<"NoUncountedMemberChecker">,
   HelpText<"Check for no uncounted member variables.">,
   Documentation;
 
+def UncountedLambdaCapturesChecker : Checker<"UncountedLambdaCapturesChecker">,
+  HelpText<"Check uncounted lambda captures.">,
+  Documentation;
+
 } // end webkit
 
 let ParentPackage = WebKitAlpha in {

diff  --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
index 9be1fdeb3ebf..31f971e33cb2 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -127,6 +127,7 @@ add_clang_library(clangStaticAnalyzerCheckers
   WebKit/PtrTypesSemantics.cpp
   WebKit/RefCntblBaseVirtualDtorChecker.cpp
   WebKit/UncountedCallArgsChecker.cpp
+  WebKit/UncountedLambdaCapturesChecker.cpp
 
   LINK_LIBS
   clangAST

diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
new file mode 100644
index ..0a387592d350
--- /dev/null
+++ 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
@@ -0,0 +1,106 @@
+//===- UncountedLambdaCapturesChecker.cpp *- C++ 
-*-==//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DiagOutputUtils.h"
+#include "PtrTypesSemantics.h"
+#include "clang/AST/CXXInheritance.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class UncountedLambdaCapturesChecker
+: public Checker> {
+private:
+  BugType Bug{this, "Lambda capture of uncounted variable",
+  "WebKit coding guidelines"};
+  mutable BugReporter *BR;
+
+public:
+  void checkASTDecl(const TranslationUnitDecl *TUD, AnalysisManager ,
+BugReporter ) const {
+BR = 
+
+// The calls to checkAST* from AnalysisConsumer don't
+// visit template instantiations or lambda classes. We
+// want to visit those, so we make our own RecursiveASTVisitor.
+struct LocalVisitor : public RecursiveASTVisitor {
+  const UncountedLambdaCapturesChecker *Checker;
+  explicit LocalVisitor(const UncountedLambdaCapturesChecker *Checker)
+  : Checker(Checker) {
+assert(Checker);
+  }
+
+  bool shouldVisitTemplateInstantiations() const { return true; }
+  bool shouldVisitImplicitCode() const { return false; }
+
+  bool VisitLambdaExpr(LambdaExpr *L) {
+

[clang] 1adc494 - [CMake] Simplify CMake handling for zlib

2020-08-05 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2020-08-05T16:07:11-07:00
New Revision: 1adc494bce44f6004994deed61b30d4b71fe1d05

URL: 
https://github.com/llvm/llvm-project/commit/1adc494bce44f6004994deed61b30d4b71fe1d05
DIFF: 
https://github.com/llvm/llvm-project/commit/1adc494bce44f6004994deed61b30d4b71fe1d05.diff

LOG: [CMake] Simplify CMake handling for zlib

Rather than handling zlib handling manually, use find_package from CMake
to find zlib properly. Use this to normalize the LLVM_ENABLE_ZLIB,
HAVE_ZLIB, HAVE_ZLIB_H. Furthermore, require zlib if LLVM_ENABLE_ZLIB is
set to YES, which requires the distributor to explicitly select whether
zlib is enabled or not. This simplifies the CMake handling and usage in
the rest of the tooling.

This is a reland of abb0075 with all followup changes and fixes that
should address issues that were reported in PR44780.

Differential Revision: https://reviews.llvm.org/D79219

Added: 


Modified: 
clang/test/CMakeLists.txt
clang/test/lit.site.cfg.py.in
compiler-rt/test/lit.common.configured.in
lld/test/CMakeLists.txt
lld/test/lit.site.cfg.py.in
lldb/cmake/modules/LLDBStandalone.cmake
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
llvm/cmake/config-ix.cmake
llvm/cmake/modules/LLVMConfig.cmake.in
llvm/include/llvm/Config/config.h.cmake
llvm/lib/Support/CMakeLists.txt
llvm/lib/Support/CRC.cpp
llvm/lib/Support/Compression.cpp
llvm/test/CMakeLists.txt
llvm/test/lit.site.cfg.py.in
llvm/unittests/Support/CompressionTest.cpp
llvm/utils/gn/secondary/clang/test/BUILD.gn
llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn
llvm/utils/gn/secondary/lld/test/BUILD.gn
llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
llvm/utils/gn/secondary/llvm/test/BUILD.gn

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 38bbc5be90d5..334a90498d0d 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -9,15 +9,6 @@ endif ()
 
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR 
${LLVM_RUNTIME_OUTPUT_INTDIR})
 
-if(CLANG_BUILT_STANDALONE)
-  # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This
-  # value is forced to 0 if zlib was not found, so it is fine to use it
-  # instead of HAVE_LIBZ (not recorded).
-  if(LLVM_ENABLE_ZLIB)
-set(HAVE_LIBZ 1)
-  endif()
-endif()
-
 llvm_canonicalize_cmake_booleans(
   CLANG_BUILD_EXAMPLES
   CLANG_ENABLE_ARCMT
@@ -25,7 +16,7 @@ llvm_canonicalize_cmake_booleans(
   CLANG_SPAWN_CC1
   ENABLE_BACKTRACES
   ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
-  HAVE_LIBZ
+  LLVM_ENABLE_ZLIB
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
   LLVM_ENABLE_PLUGINS
   LLVM_ENABLE_THREADS)

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index d9b5b2f2592e..286ea06d798c 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -16,7 +16,7 @@ config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.host_cxx = "@CMAKE_CXX_COMPILER@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.have_zlib = @HAVE_LIBZ@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.clang_arcmt = @CLANG_ENABLE_ARCMT@
 config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@

diff  --git a/compiler-rt/test/lit.common.configured.in 
b/compiler-rt/test/lit.common.configured.in
index 1f746c067b84..000bf9b98470 100644
--- a/compiler-rt/test/lit.common.configured.in
+++ b/compiler-rt/test/lit.common.configured.in
@@ -57,7 +57,7 @@ elif config.android:
 else:
   set_default("target_suffix", "-%s" % config.target_arch)
 
-set_default("have_zlib", "@HAVE_LIBZ@")
+set_default("have_zlib", "@LLVM_ENABLE_ZLIB@")
 set_default("libcxx_used", "@LLVM_LIBCXX_USED@")
 
 # LLVM tools dir can be passed in lit parameters, so try to

diff  --git a/lld/test/CMakeLists.txt b/lld/test/CMakeLists.txt
index 74b29f5d65b8..52e6118ba876 100644
--- a/lld/test/CMakeLists.txt
+++ b/lld/test/CMakeLists.txt
@@ -4,17 +4,8 @@ set(LLVM_BUILD_MODE "%(build_mode)s")
 set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s")
 set(LLVM_LIBS_DIR 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/%(build_config)s")
 
-if(LLD_BUILT_STANDALONE)
-  # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This
-  # value is forced to 0 if zlib was not found, so it is fine to use it
-  # instead of HAVE_LIBZ (not recorded).
-  if(LLVM_ENABLE_ZLIB)
-set(HAVE_LIBZ 1)
-  endif()
-endif()
-
 llvm_canonicalize_cmake_booleans(
-  HAVE_LIBZ
+  LLVM_ENABLE_ZLIB
   LLVM_LIBXML2_ENABLED
   )
 

diff  --git a/lld/test/lit.site.cfg.py.in b/lld/test/lit.site.cfg.py.in
index 4aa2fcda73bb..3d4c51f4ab64 100644
--- a/lld/test/lit.site.cfg.py.in
+++ b/lld/test/lit.site.cfg.py.in
@@ 

[PATCH] D80416: [RFC][OpenCL] Set fp contract flag on -cl-mad-enable

2020-08-05 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

Is this still necessary?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80416/new/

https://reviews.llvm.org/D80416

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


[PATCH] D85367: [clang, test, Darwin] Fix tests expecting Darwin target

2020-08-05 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre created this revision.
thopre added reviewers: zixuw, arphaman, ributzka, steven_wu, dexonsmith.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.
thopre requested review of this revision.

Clang tests Driver/apple-arm64-arch.c and
Driver/darwin-warning-options.c test Darwin driver functionality but
only require the host system to be Darwin. This leads the tests to fail
when building a cross-compiler on Darwin and to be marked unsupported
when cross-compiling to Darwin from another system. This commit changes
the requirements for those tests to require the target to be Darwin.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85367

Files:
  clang/test/Driver/apple-arm64-arch.c
  clang/test/Driver/darwin-warning-options.c


Index: clang/test/Driver/darwin-warning-options.c
===
--- clang/test/Driver/darwin-warning-options.c
+++ clang/test/Driver/darwin-warning-options.c
@@ -1,4 +1,4 @@
-// REQUIRES: system-darwin
+// REQUIRES: darwin
 
 // Always error about undefined 'TARGET_OS_*' macros on Darwin.
 // RUN: %clang -### %s 2>&1 | FileCheck %s
Index: clang/test/Driver/apple-arm64-arch.c
===
--- clang/test/Driver/apple-arm64-arch.c
+++ clang/test/Driver/apple-arm64-arch.c
@@ -1,7 +1,7 @@
 // RUN: env SDKROOT="/" %clang -arch arm64 -c -### %s 2>&1 | \
 // RUN:   FileCheck %s
 //
-// REQUIRES: system-darwin
+// REQUIRES: darwin
 // XFAIL: apple-silicon-mac
 //
 // CHECK: "-triple" "arm64-apple-ios{{[0-9.]+}}"


Index: clang/test/Driver/darwin-warning-options.c
===
--- clang/test/Driver/darwin-warning-options.c
+++ clang/test/Driver/darwin-warning-options.c
@@ -1,4 +1,4 @@
-// REQUIRES: system-darwin
+// REQUIRES: darwin
 
 // Always error about undefined 'TARGET_OS_*' macros on Darwin.
 // RUN: %clang -### %s 2>&1 | FileCheck %s
Index: clang/test/Driver/apple-arm64-arch.c
===
--- clang/test/Driver/apple-arm64-arch.c
+++ clang/test/Driver/apple-arm64-arch.c
@@ -1,7 +1,7 @@
 // RUN: env SDKROOT="/" %clang -arch arm64 -c -### %s 2>&1 | \
 // RUN:   FileCheck %s
 //
-// REQUIRES: system-darwin
+// REQUIRES: darwin
 // XFAIL: apple-silicon-mac
 //
 // CHECK: "-triple" "arm64-apple-ios{{[0-9.]+}}"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-08-05 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 283406.
jfb marked 5 inline comments as done.
jfb added a comment.

Remove restrict, update docs, call isCompleteType


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79279/new/

https://reviews.llvm.org/D79279

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-overloaded-memfns.c
  clang/test/CodeGen/ubsan-builtin-checks.c
  clang/test/CodeGen/ubsan-builtin-ctz-clz.c
  clang/test/CodeGen/ubsan-builtin-mem_overloaded.c
  clang/test/CodeGenObjC/builtin-memfns.m
  clang/test/Sema/builtin-overloaded-memfns.cpp
  clang/test/SemaCXX/constexpr-string.cpp
  compiler-rt/lib/ubsan/ubsan_handlers.cpp
  compiler-rt/lib/ubsan/ubsan_handlers.h
  compiler-rt/test/ubsan/TestCases/Misc/builtins-ctz-clz.cpp
  compiler-rt/test/ubsan/TestCases/Misc/builtins-mem_overloaded.cpp
  compiler-rt/test/ubsan/TestCases/Misc/builtins.cpp

Index: compiler-rt/test/ubsan/TestCases/Misc/builtins.cpp
===
--- compiler-rt/test/ubsan/TestCases/Misc/builtins.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-// REQUIRES: arch=x86_64
-//
-// RUN: %clangxx -fsanitize=builtin -w %s -O3 -o %t
-// RUN: %run %t 2>&1 | FileCheck %s --check-prefix=RECOVER
-// RUN: %clangxx -fsanitize=builtin -fno-sanitize-recover=builtin -w %s -O3 -o %t.abort
-// RUN: not %run %t.abort 2>&1 | FileCheck %s --check-prefix=ABORT
-
-void check_ctz(int n) {
-  // ABORT: builtins.cpp:[[@LINE+2]]:17: runtime error: passing zero to ctz(), which is not a valid argument
-  // RECOVER: builtins.cpp:[[@LINE+1]]:17: runtime error: passing zero to ctz(), which is not a valid argument
-  __builtin_ctz(n);
-
-  // RECOVER: builtins.cpp:[[@LINE+1]]:18: runtime error: passing zero to ctz(), which is not a valid argument
-  __builtin_ctzl(n);
-
-  // RECOVER: builtins.cpp:[[@LINE+1]]:19: runtime error: passing zero to ctz(), which is not a valid argument
-  __builtin_ctzll(n);
-}
-
-void check_clz(int n) {
-  // RECOVER: builtins.cpp:[[@LINE+1]]:17: runtime error: passing zero to clz(), which is not a valid argument
-  __builtin_clz(n);
-
-  // RECOVER: builtins.cpp:[[@LINE+1]]:18: runtime error: passing zero to clz(), which is not a valid argument
-  __builtin_clzl(n);
-
-  // RECOVER: builtins.cpp:[[@LINE+1]]:19: runtime error: passing zero to clz(), which is not a valid argument
-  __builtin_clzll(n);
-}
-
-int main() {
-  check_ctz(0);
-  check_clz(0);
-  return 0;
-}
Index: compiler-rt/test/ubsan/TestCases/Misc/builtins-mem_overloaded.cpp
===
--- /dev/null
+++ compiler-rt/test/ubsan/TestCases/Misc/builtins-mem_overloaded.cpp
@@ -0,0 +1,93 @@
+// RUN: %clangxx -fsanitize=builtin -w %s -O3 -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+using uintptr_t = __UINTPTR_TYPE__;
+using size_t = __SIZE_TYPE__;
+
+void check_memcpy_align(char *dst_aligned, char *dst_misaligned, const char *src_aligned, const char *src_misaligned, size_t sz) {
+  // OK.
+  __builtin_memcpy_overloaded(dst_aligned, src_aligned, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:31: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memcpy_overloaded(dst_misaligned, src_aligned, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:44: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memcpy_overloaded(dst_aligned, src_misaligned, sz, 2);
+}
+
+void check_memmove_align(char *dst_aligned, char *dst_misaligned, const char *src_aligned, const char *src_misaligned, size_t sz) {
+  // OK.
+  __builtin_memmove_overloaded(dst_aligned, src_aligned, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:32: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memmove_overloaded(dst_misaligned, src_aligned, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:45: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memmove_overloaded(dst_aligned, src_misaligned, sz, 2);
+}
+
+void check_memset_align(char *dst_aligned, char *dst_misaligned, size_t sz) {
+  // OK.
+  __builtin_memset_overloaded(dst_aligned, 0, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:31: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  

[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-08-05 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D79279#2197118 , @rsmith wrote:

> Two observations that are new to me in this review:
>
> 1. We already treat all builtins as being overloaded on address space.
> 2. The revised patch treats `__builtin_mem*_overloaded` as being overloaded 
> *only* on address space, volatility, and atomicity. (We've tuned the design 
> to a point where the other qualifiers don't matter any more.)
>
> So, we're adding three features here: overloading on (a) address space, (b) 
> volatility, and (c) atomicity. (a) is already available in the 
> non-`_overloaded` form, and we seem to be approaching agreement that (b) 
> should be available in the non-`_overloaded` form too. So that only leaves 
> (c), which is really not `_overloaded` but `_atomic`.
>
> Based on those observations I'm now thinking that we might prefer a somewhat 
> different approach (but one that should require only minimal changes to the 
> patch in front of us). Specifically:
>
> 1. Stop treating lib builtins (eg, plain `memcpy`) as overloaded on address 
> space. That's a (pre-existing) conformance bug, at least for the Embedded C 
> TR.
> 2. Keep `__builtin_` forms of lib builtins overloaded on address space. (No 
> change.)
> 3. Also overload `__builtin_` forms of lib builtins on volatility where it 
> makes sense, instead of adding new builtin names `__builtin_mem*_overloaded`.
> 4. Add a new name for the builtin for the atomic forms of `memcpy` and 
> `memset` (`__builtin_memcpy_unordered_atomic` maybe?).
> 5. Convert the "trivial types" check from an error to a warning and apply it 
> to all the mem* overloads. (Though I think we might actually already have 
> such a check, so this might only require extending it to cover the atomic 
> builtin.)
>
> What do you think?

That's fine with me, but as John noted that's inconsistent with what he thought 
builtins allowed (i.e. `#define memcpy(dst, src, sz) __builtin_memcpy(dst, src, 
sz)`. If that's Not A Thing then your plan works. If it is then we need to tune 
it a bit.

Also note that the `_atomic` builtin also needs to support some overloading, at 
least for address spaces (and maybe `volatile` in the future).

So, let me know what you'd both rather see, so I don't ping-pong code too much.




Comment at: clang/docs/LanguageExtensions.rst:2434
+* ``volatile``
+* ``restrict``
+* ``__unaligned``

rsmith wrote:
> Does `restrict` really make sense here? It seems like the only difference it 
> could possibly make would be to treat `memcpy` as `memmove` if either operand 
> is marked restrict, but
> (a) if the caller wants that, they can just use `memcpy` directly, and
> (b) it's not correct to propagate restrict-ness from the caller to the callee 
> anyway, because restrict-ness is really a property of the declaration of the 
> identifier in its scope, not a property of its type:
> ```
> void f(void *restrict p) {
>   __builtin_memmove(p, p + 1, 4);
> }
> ```
> (c) a restrict qualifier on the pointee type is irrelevant to memcpy and a 
> restrict qualifier on the pointer type isn't part of QUAL.
I dropped `restrict`.



Comment at: clang/docs/LanguageExtensions.rst:2435
+* ``restrict``
+* ``__unaligned``
+* non-default address spaces

rsmith wrote:
> I don't think ``__unaligned`` matters any more. We always take the actual 
> alignment inferred from the pointer arguments, just like we do for 
> non-overloaded `memcpy`.
It's still allowed as a qualifier, though.



Comment at: clang/lib/Sema/SemaChecking.cpp:5732
+
+if (!DstValTy.isTriviallyCopyableType(Context) && !DstValTy->isVoidType())
+  return ExprError(Diag(TheCall->getBeginLoc(),

rsmith wrote:
> You need to call `Sema::isCompleteType` first before asking this question, in 
> order to trigger class instantiation when necessary in C++. (Likewise for the 
> checks in the previous function.)
Before the condition, right? LMK if I added the right thing!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79279/new/

https://reviews.llvm.org/D79279

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


[PATCH] D84600: [Analyzer] Support note tags for smart ptr checker

2020-08-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp:110
+  SmartPtrChecker *Checker = Mgr.registerChecker();
+  NullDereferenceBugTypePtr = >NullDereferenceBugType;
 }

vrnithinkumar wrote:
> xazax.hun wrote:
> > NoQ wrote:
> > > vrnithinkumar wrote:
> > > > NoQ wrote:
> > > > > Wait, i don't understand again. You're taking the bug type from that 
> > > > > checker and using it in that checker. Why did you need to make it 
> > > > > global? I thought your problem was about capturing the bug type from 
> > > > > the //raw// null dereference checker?
> > > > > Wait, i don't understand again. You're taking the bug type from that 
> > > > > checker and using it in that checker. Why did you need to make it 
> > > > > global? I thought your problem was about capturing the bug type from 
> > > > > the //raw// null dereference checker?
> > > > 
> > > > The check for bug type is in `SmartPtrModeling` but the bug type is 
> > > > defined in `SmartPtrChecker`
> > > Aha, ok, i misunderstood again. So i guess we didn't need a new header 
> > > then. That said, it's an interesting layering violation that we encounter 
> > > in this design: it used to be up to the checker to attach a visitor and 
> > > so should be activating a note tag, but note tags are part of modeling, 
> > > not checking.
> > > 
> > > I guess that's just how it is and it's the responsibility of the checkers 
> > > to inform the modeling about bug types. I guess the ultimate API could 
> > > look like `BugReport->activateNoteTag(NoteTagTag TT)` (where `TT` is a 
> > > crying smiley that cries about "tag tags" T_T). But that's a story for 
> > > another time.
> > I hope we will be able to figure out a nicer solution at some point. But I 
> > do not have a better alternative now, so I am ok with committing as is.
> > 
> > The API Artem is suggesting looks good to me (although it is out of scope 
> > for the GSoC). But I think that might not solve the problem of how multiple 
> > checkers should share the information about those tags. (Or at least I do 
> > not see how.)
> > 
> > Note that if we had both checks in the same file we might be able to work 
> > this problem around using `CheckerManager::getChecker`. I am not suggesting 
> > merging them, only wanted to point out.
> >  So i guess we didn't need a new header then.
> So we should remove the `NullDereference.h` and add the inter checker api to 
> get the BugType to `SmartPtr.h`?
> 
> >  I guess the ultimate API could look like 
> > `BugReport->activateNoteTag(NoteTagTag TT)`
> Do we have to make these api changes on this review? Or some follow up 
> changes?
> So we should remove the `NullDereference.h` and add the inter checker api to 
> get the BugType to `SmartPtr.h`?
Yes.

> Do we have to make these api changes on this review? Or some follow up 
> changes?
You don't have to do this at all; i think you have enough stuff on your plate. 
But if you like you can put up another patch later.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84600/new/

https://reviews.llvm.org/D84600

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


[clang] 076b120 - CFG: Destroy temporaries in (a, b) expression in the correct order.

2020-08-05 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-08-05T14:52:53-07:00
New Revision: 076b120bebfd727b502208601012a44ab2e1028e

URL: 
https://github.com/llvm/llvm-project/commit/076b120bebfd727b502208601012a44ab2e1028e
DIFF: 
https://github.com/llvm/llvm-project/commit/076b120bebfd727b502208601012a44ab2e1028e.diff

LOG: CFG: Destroy temporaries in (a,b) expression in the correct order.

Added: 


Modified: 
clang/lib/Analysis/CFG.cpp
clang/test/Analysis/cfg.cpp

Removed: 




diff  --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index fc74226951a4..cde0bf448ecb 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -4773,11 +4773,11 @@ CFGBlock 
*CFGBuilder::VisitChildrenForTemporaryDtors(Stmt *E,
 CFGBlock *CFGBuilder::VisitBinaryOperatorForTemporaryDtors(
 BinaryOperator *E, bool ExternallyDestructed, TempDtorContext ) {
   if (E->isCommaOp()) {
-// For comma operator LHS expression is visited
-// before RHS expression. For destructors visit them in reverse order.
-CFGBlock *RHSBlock = VisitForTemporaryDtors(E->getRHS(), 
ExternallyDestructed, Context);
+// For the comma operator, the LHS expression is evaluated before the RHS
+// expression, so prepend temporary destructors for the LHS first.
 CFGBlock *LHSBlock = VisitForTemporaryDtors(E->getLHS(), false, Context);
-return LHSBlock ? LHSBlock : RHSBlock;
+CFGBlock *RHSBlock = VisitForTemporaryDtors(E->getRHS(), 
ExternallyDestructed, Context);
+return RHSBlock ? RHSBlock : LHSBlock;
   }
 
   if (E->isLogicalOp()) {
@@ -4798,19 +4798,15 @@ CFGBlock 
*CFGBuilder::VisitBinaryOperatorForTemporaryDtors(
   }
 
   if (E->isAssignmentOp()) {
-// For assignment operator (=) LHS expression is visited
-// before RHS expression. For destructors visit them in reverse order.
+// For assignment operators, the RHS expression is evaluated before the LHS
+// expression, so prepend temporary destructors for the RHS first.
 CFGBlock *RHSBlock = VisitForTemporaryDtors(E->getRHS(), false, Context);
 CFGBlock *LHSBlock = VisitForTemporaryDtors(E->getLHS(), false, Context);
 return LHSBlock ? LHSBlock : RHSBlock;
   }
 
-  // For any other binary operator RHS expression is visited before
-  // LHS expression (order of children). For destructors visit them in reverse
-  // order.
-  CFGBlock *LHSBlock = VisitForTemporaryDtors(E->getLHS(), false, Context);
-  CFGBlock *RHSBlock = VisitForTemporaryDtors(E->getRHS(), false, Context);
-  return RHSBlock ? RHSBlock : LHSBlock;
+  // Any other operator is visited normally.
+  return VisitChildrenForTemporaryDtors(E, ExternallyDestructed, Context);
 }
 
 CFGBlock *CFGBuilder::VisitCXXBindTemporaryExprForTemporaryDtors(

diff  --git a/clang/test/Analysis/cfg.cpp b/clang/test/Analysis/cfg.cpp
index 0159a3c0488c..5f2b365eeb4e 100644
--- a/clang/test/Analysis/cfg.cpp
+++ b/clang/test/Analysis/cfg.cpp
@@ -575,6 +575,24 @@ int vla_evaluate(int x) {
   return x;
 }
 
+// CHECK-LABEL: void CommaTemp::f()
+// CHECK:   [B1]
+// CHECK-NEXT:1: CommaTemp::A() (CXXConstructExpr,
+// CHECK-NEXT:2: [B1.1] (BindTemporary)
+// CHECK-NEXT:3: CommaTemp::B() (CXXConstructExpr,
+// CHECK-NEXT:4: [B1.3] (BindTemporary)
+// CHECK-NEXT:5: ... , [B1.4]
+// CHECK-NEXT:6: ~CommaTemp::B() (Temporary object destructor)
+// CHECK-NEXT:7: ~CommaTemp::A() (Temporary object destructor)
+namespace CommaTemp {
+  struct A { ~A(); };
+  struct B { ~B(); };
+  void f();
+}
+void CommaTemp::f() {
+  A(), B();
+}
+
 // CHECK-LABEL: template<> int *PR18472()
 // CHECK: [B2 (ENTRY)]
 // CHECK-NEXT:   Succs (1): B1



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


[PATCH] D84600: [Analyzer] Support note tags for smart ptr checker

2020-08-05 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp:110
+  SmartPtrChecker *Checker = Mgr.registerChecker();
+  NullDereferenceBugTypePtr = >NullDereferenceBugType;
 }

xazax.hun wrote:
> NoQ wrote:
> > vrnithinkumar wrote:
> > > NoQ wrote:
> > > > Wait, i don't understand again. You're taking the bug type from that 
> > > > checker and using it in that checker. Why did you need to make it 
> > > > global? I thought your problem was about capturing the bug type from 
> > > > the //raw// null dereference checker?
> > > > Wait, i don't understand again. You're taking the bug type from that 
> > > > checker and using it in that checker. Why did you need to make it 
> > > > global? I thought your problem was about capturing the bug type from 
> > > > the //raw// null dereference checker?
> > > 
> > > The check for bug type is in `SmartPtrModeling` but the bug type is 
> > > defined in `SmartPtrChecker`
> > Aha, ok, i misunderstood again. So i guess we didn't need a new header 
> > then. That said, it's an interesting layering violation that we encounter 
> > in this design: it used to be up to the checker to attach a visitor and so 
> > should be activating a note tag, but note tags are part of modeling, not 
> > checking.
> > 
> > I guess that's just how it is and it's the responsibility of the checkers 
> > to inform the modeling about bug types. I guess the ultimate API could look 
> > like `BugReport->activateNoteTag(NoteTagTag TT)` (where `TT` is a crying 
> > smiley that cries about "tag tags" T_T). But that's a story for another 
> > time.
> I hope we will be able to figure out a nicer solution at some point. But I do 
> not have a better alternative now, so I am ok with committing as is.
> 
> The API Artem is suggesting looks good to me (although it is out of scope for 
> the GSoC). But I think that might not solve the problem of how multiple 
> checkers should share the information about those tags. (Or at least I do not 
> see how.)
> 
> Note that if we had both checks in the same file we might be able to work 
> this problem around using `CheckerManager::getChecker`. I am not suggesting 
> merging them, only wanted to point out.
>  So i guess we didn't need a new header then.
So we should remove the `NullDereference.h` and add the inter checker api to 
get the BugType to `SmartPtr.h`?

>  I guess the ultimate API could look like 
> `BugReport->activateNoteTag(NoteTagTag TT)`
Do we have to make these api changes on this review? Or some follow up changes?



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:352
+// Gets the SVal to track for a smart pointer memory region
+SVal SmartPtrModeling::getSValForRegion(const CallEvent ,
+CheckerContext ) const {

xazax.hun wrote:
> I am a bit unhappy with this function.
> I feel like it does not really have a purpose. It returns the null constant 
> for default constructor calls, for every other case it just returns the first 
> argument. The branch we have in this function would completely go away if we 
> would inline this to all the call sites and the result would be a single line 
> each place. I'd rather just remove this function.
Also we have to assert that we are adding a pointer value to TrackedRegionMap.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84600/new/

https://reviews.llvm.org/D84600

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


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-08-05 Thread JF Bastien via Phabricator via cfe-commits
jfb added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:2446
+order in which they occur (and in which they are observable) can only be
+guaranteed using appropriate fences around the function call. Element size must
+therefore be a lock-free size for the target architecture. It is a runtime

rjmccall wrote:
> jfb wrote:
> > rjmccall wrote:
> > > "*The* element size must..."  But I would suggest using "access size" 
> > > consistently rather than "element size".
> > I'm being consistent with the naming for IR, which uses "element" as well. 
> > I'm not enamored with the naming, but wanted to point out the purposeful 
> > consistency to make sure you preferred "access size". Without precedent I 
> > would indeed prefer "access size", but have a slight preference for 
> > consistency here. This is extremely weakly held preference.
> > 
> > (I fixed "the").
> IR naming is generally random fluff plucked from the mind of an inspired 
> compiler engineer.  User documentation is the point where we're supposed to 
> put our bad choices behind us and do something that makes sense to users. :)
"access size" it is :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79279/new/

https://reviews.llvm.org/D79279

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


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-08-05 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 283402.
jfb marked an inline comment as done.
jfb added a comment.

Use 'access size' instead of 'element size'.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79279/new/

https://reviews.llvm.org/D79279

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-overloaded-memfns.c
  clang/test/CodeGen/ubsan-builtin-checks.c
  clang/test/CodeGen/ubsan-builtin-ctz-clz.c
  clang/test/CodeGen/ubsan-builtin-mem_overloaded.c
  clang/test/CodeGenObjC/builtin-memfns.m
  clang/test/Sema/builtin-overloaded-memfns.cpp
  clang/test/SemaCXX/constexpr-string.cpp
  compiler-rt/lib/ubsan/ubsan_handlers.cpp
  compiler-rt/lib/ubsan/ubsan_handlers.h
  compiler-rt/test/ubsan/TestCases/Misc/builtins-ctz-clz.cpp
  compiler-rt/test/ubsan/TestCases/Misc/builtins-mem_overloaded.cpp
  compiler-rt/test/ubsan/TestCases/Misc/builtins.cpp

Index: compiler-rt/test/ubsan/TestCases/Misc/builtins.cpp
===
--- compiler-rt/test/ubsan/TestCases/Misc/builtins.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-// REQUIRES: arch=x86_64
-//
-// RUN: %clangxx -fsanitize=builtin -w %s -O3 -o %t
-// RUN: %run %t 2>&1 | FileCheck %s --check-prefix=RECOVER
-// RUN: %clangxx -fsanitize=builtin -fno-sanitize-recover=builtin -w %s -O3 -o %t.abort
-// RUN: not %run %t.abort 2>&1 | FileCheck %s --check-prefix=ABORT
-
-void check_ctz(int n) {
-  // ABORT: builtins.cpp:[[@LINE+2]]:17: runtime error: passing zero to ctz(), which is not a valid argument
-  // RECOVER: builtins.cpp:[[@LINE+1]]:17: runtime error: passing zero to ctz(), which is not a valid argument
-  __builtin_ctz(n);
-
-  // RECOVER: builtins.cpp:[[@LINE+1]]:18: runtime error: passing zero to ctz(), which is not a valid argument
-  __builtin_ctzl(n);
-
-  // RECOVER: builtins.cpp:[[@LINE+1]]:19: runtime error: passing zero to ctz(), which is not a valid argument
-  __builtin_ctzll(n);
-}
-
-void check_clz(int n) {
-  // RECOVER: builtins.cpp:[[@LINE+1]]:17: runtime error: passing zero to clz(), which is not a valid argument
-  __builtin_clz(n);
-
-  // RECOVER: builtins.cpp:[[@LINE+1]]:18: runtime error: passing zero to clz(), which is not a valid argument
-  __builtin_clzl(n);
-
-  // RECOVER: builtins.cpp:[[@LINE+1]]:19: runtime error: passing zero to clz(), which is not a valid argument
-  __builtin_clzll(n);
-}
-
-int main() {
-  check_ctz(0);
-  check_clz(0);
-  return 0;
-}
Index: compiler-rt/test/ubsan/TestCases/Misc/builtins-mem_overloaded.cpp
===
--- /dev/null
+++ compiler-rt/test/ubsan/TestCases/Misc/builtins-mem_overloaded.cpp
@@ -0,0 +1,93 @@
+// RUN: %clangxx -fsanitize=builtin -w %s -O3 -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+using uintptr_t = __UINTPTR_TYPE__;
+using size_t = __SIZE_TYPE__;
+
+void check_memcpy_align(char *dst_aligned, char *dst_misaligned, const char *src_aligned, const char *src_misaligned, size_t sz) {
+  // OK.
+  __builtin_memcpy_overloaded(dst_aligned, src_aligned, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:31: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memcpy_overloaded(dst_misaligned, src_aligned, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:44: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memcpy_overloaded(dst_aligned, src_misaligned, sz, 2);
+}
+
+void check_memmove_align(char *dst_aligned, char *dst_misaligned, const char *src_aligned, const char *src_misaligned, size_t sz) {
+  // OK.
+  __builtin_memmove_overloaded(dst_aligned, src_aligned, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:32: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memmove_overloaded(dst_misaligned, src_aligned, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:45: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memmove_overloaded(dst_aligned, src_misaligned, sz, 2);
+}
+
+void check_memset_align(char *dst_aligned, char *dst_misaligned, size_t sz) {
+  // OK.
+  __builtin_memset_overloaded(dst_aligned, 0, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:31: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  

[PATCH] D85324: [z/OS] Add z/OS Target and define macros

2020-08-05 Thread Tatyana Krasnukha via Phabricator via cfe-commits
tatyana-krasnukha added a comment.

I'm not familiar with the z/OS target, so I cannot check the correctness of the 
target-specific changes. The overall patch looks good.




Comment at: clang/lib/Basic/Targets/OSTargets.h:780
+public:
+  ZOSTargetInfo(const llvm::Triple , const TargetOptions )
+  : OSTargetInfo(Triple, Opts) {}

It is possible to use inheriting constructor here instead (i.e. `using 
OSTargetInfo::OSTargetInfo;`).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85324/new/

https://reviews.llvm.org/D85324

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


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-08-05 Thread JF Bastien via Phabricator via cfe-commits
jfb added inline comments.



Comment at: compiler-rt/lib/ubsan/ubsan_handlers.cpp:659
+ uptr PtrOrSize) {
   GET_REPORT_OPTIONS(true);
+  handleInvalidBuiltin(Data, Opts, PtrOrSize);

vsk wrote:
> It looks like `__ubsan_handle_invalid_builtin` is meant to be recoverable, so 
> I think this should be `GET_REPORT_OPTIONS(false)`. Marking this 
> unrecoverable makes it impossible to suppress redundant diagnostics at the 
> same source location. It looks this isn't code you've added: feel free to 
> punt this to me. If you don't mind folding in a fix, adding a test would be 
> simple (perform UB in a loop and verify only one diagnostic is printed).
I folded this into the patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79279/new/

https://reviews.llvm.org/D79279

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


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-08-05 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 283400.
jfb marked an inline comment as done.
jfb added a comment.

Add loop test requested by Vedant


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79279/new/

https://reviews.llvm.org/D79279

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-overloaded-memfns.c
  clang/test/CodeGen/ubsan-builtin-checks.c
  clang/test/CodeGen/ubsan-builtin-ctz-clz.c
  clang/test/CodeGen/ubsan-builtin-mem_overloaded.c
  clang/test/CodeGenObjC/builtin-memfns.m
  clang/test/Sema/builtin-overloaded-memfns.cpp
  clang/test/SemaCXX/constexpr-string.cpp
  compiler-rt/lib/ubsan/ubsan_handlers.cpp
  compiler-rt/lib/ubsan/ubsan_handlers.h
  compiler-rt/test/ubsan/TestCases/Misc/builtins-ctz-clz.cpp
  compiler-rt/test/ubsan/TestCases/Misc/builtins-mem_overloaded.cpp
  compiler-rt/test/ubsan/TestCases/Misc/builtins.cpp

Index: compiler-rt/test/ubsan/TestCases/Misc/builtins.cpp
===
--- compiler-rt/test/ubsan/TestCases/Misc/builtins.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-// REQUIRES: arch=x86_64
-//
-// RUN: %clangxx -fsanitize=builtin -w %s -O3 -o %t
-// RUN: %run %t 2>&1 | FileCheck %s --check-prefix=RECOVER
-// RUN: %clangxx -fsanitize=builtin -fno-sanitize-recover=builtin -w %s -O3 -o %t.abort
-// RUN: not %run %t.abort 2>&1 | FileCheck %s --check-prefix=ABORT
-
-void check_ctz(int n) {
-  // ABORT: builtins.cpp:[[@LINE+2]]:17: runtime error: passing zero to ctz(), which is not a valid argument
-  // RECOVER: builtins.cpp:[[@LINE+1]]:17: runtime error: passing zero to ctz(), which is not a valid argument
-  __builtin_ctz(n);
-
-  // RECOVER: builtins.cpp:[[@LINE+1]]:18: runtime error: passing zero to ctz(), which is not a valid argument
-  __builtin_ctzl(n);
-
-  // RECOVER: builtins.cpp:[[@LINE+1]]:19: runtime error: passing zero to ctz(), which is not a valid argument
-  __builtin_ctzll(n);
-}
-
-void check_clz(int n) {
-  // RECOVER: builtins.cpp:[[@LINE+1]]:17: runtime error: passing zero to clz(), which is not a valid argument
-  __builtin_clz(n);
-
-  // RECOVER: builtins.cpp:[[@LINE+1]]:18: runtime error: passing zero to clz(), which is not a valid argument
-  __builtin_clzl(n);
-
-  // RECOVER: builtins.cpp:[[@LINE+1]]:19: runtime error: passing zero to clz(), which is not a valid argument
-  __builtin_clzll(n);
-}
-
-int main() {
-  check_ctz(0);
-  check_clz(0);
-  return 0;
-}
Index: compiler-rt/test/ubsan/TestCases/Misc/builtins-mem_overloaded.cpp
===
--- /dev/null
+++ compiler-rt/test/ubsan/TestCases/Misc/builtins-mem_overloaded.cpp
@@ -0,0 +1,93 @@
+// RUN: %clangxx -fsanitize=builtin -w %s -O3 -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+using uintptr_t = __UINTPTR_TYPE__;
+using size_t = __SIZE_TYPE__;
+
+void check_memcpy_align(char *dst_aligned, char *dst_misaligned, const char *src_aligned, const char *src_misaligned, size_t sz) {
+  // OK.
+  __builtin_memcpy_overloaded(dst_aligned, src_aligned, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:31: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memcpy_overloaded(dst_misaligned, src_aligned, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:44: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memcpy_overloaded(dst_aligned, src_misaligned, sz, 2);
+}
+
+void check_memmove_align(char *dst_aligned, char *dst_misaligned, const char *src_aligned, const char *src_misaligned, size_t sz) {
+  // OK.
+  __builtin_memmove_overloaded(dst_aligned, src_aligned, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:32: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memmove_overloaded(dst_misaligned, src_aligned, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:45: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memmove_overloaded(dst_aligned, src_misaligned, sz, 2);
+}
+
+void check_memset_align(char *dst_aligned, char *dst_misaligned, size_t sz) {
+  // OK.
+  __builtin_memset_overloaded(dst_aligned, 0, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:31: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memset_overloaded(dst_misaligned, 0, sz, 

[PATCH] D84534: [AIX] Static init frontend recovery and backend support

2020-08-05 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 283396.
Xiangling_L marked 2 inline comments as done.
Xiangling_L added a comment.

Added descriptions for struct and functions;
Addressed other comments;


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84534/new/

https://reviews.llvm.org/D84534

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
  clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
  clang/test/CodeGenCXX/aix-static-init.cpp
  clang/unittests/CodeGen/IncrementalProcessingTest.cpp
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
  llvm/test/CodeGen/PowerPC/aix-static-init-default-priority.ll
  llvm/test/CodeGen/PowerPC/aix-static-init-key-object.ll
  llvm/test/CodeGen/PowerPC/aix-static-init-no-unique-module-id.ll
  llvm/test/CodeGen/PowerPC/aix-static-init-non-default-priority.ll

Index: llvm/test/CodeGen/PowerPC/aix-static-init-non-default-priority.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-static-init-non-default-priority.ll
@@ -0,0 +1,10 @@
+; RUN: not llc -mtriple powerpc-ibm-aix-xcoff < %s 2>&1 | FileCheck %s
+; RUN: not llc -mtriple powerpc64-ibm-aix-xcoff < %s 2>&1 | FileCheck %s
+
+@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 655, void ()* @foo, i8* null }]
+
+define void @foo() {
+  ret void
+}
+
+// CHECK: LLVM ERROR: prioritized sinit and sterm functions are not yet supported
Index: llvm/test/CodeGen/PowerPC/aix-static-init-no-unique-module-id.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-static-init-no-unique-module-id.ll
@@ -0,0 +1,7 @@
+; RUN: not llc -mtriple powerpc-ibm-aix-xcoff < %s 2>&1 | FileCheck %s
+; RUN: not llc -mtriple powerpc64-ibm-aix-xcoff < %s 2>&1 | FileCheck %s
+
+@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @foo, i8* null }]
+@llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @bar, i8* null }]
+
+// CHECK: LLVM ERROR: cannot produce a unique identifier for this module based on strong external symbols
Index: llvm/test/CodeGen/PowerPC/aix-static-init-key-object.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-static-init-key-object.ll
@@ -0,0 +1,12 @@
+; RUN: not llc -mtriple powerpc-ibm-aix-xcoff < %s 2>&1 | FileCheck %s
+; RUN: not llc -mtriple powerpc64-ibm-aix-xcoff < %s 2>&1 | FileCheck %s
+
+@v = global i8 0
+
+@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @foo, i8* @v}]
+
+define void @foo() {
+  ret void
+}
+
+// CHECK: LLVM ERROR: associated data of XXStructor list is not yet supported on AIX
Index: llvm/test/CodeGen/PowerPC/aix-static-init-default-priority.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-static-init-default-priority.ll
@@ -0,0 +1,60 @@
+; RUN: llc -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s
+; RUN: llc -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck %s
+
+@llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @init1, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @init2, i8* null }]
+@llvm.global_dtors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @destruct1, i8* null }, { i32, void ()*, i8* } { i32 65535, void ()* @destruct2, i8* null }]
+
+define i32 @extFunc() {
+entry:
+  ret i32 3
+}
+
+define internal void @init1() {
+  ret void
+}
+
+define internal void @destruct1() {
+  ret void
+}
+
+define internal void @init2() {
+  ret void
+}
+
+define internal void @destruct2() {
+  ret void
+}
+
+; CHECK:   .lglobl	init1[DS]
+; CHECK:   .lglobl	.init1
+; CHECK:   .csect init1[DS]
+; CHECK: __sinit8000_clang_ac404299654d2af7eae71e75c17f7c9b_0: # @init1
+; CHECK: .init1:
+; CHECK: .__sinit8000_clang_ac404299654d2af7eae71e75c17f7c9b_0:
+; CHECK:   .lglobl	destruct1[DS]
+; CHECK:   .lglobl	.destruct1
+; CHECK:   .csect destruct1[DS]
+; CHECK: __sterm8000_clang_ac404299654d2af7eae71e75c17f7c9b_0: # @destruct1
+; CHECK: .destruct1:
+; CHECK: .__sterm8000_clang_ac404299654d2af7eae71e75c17f7c9b_0:
+; CHECK:   .lglobl	init2[DS]
+; CHECK:   .lglobl	.init2
+; CHECK:   .csect init2[DS]
+; CHECK: __sinit8000_clang_ac404299654d2af7eae71e75c17f7c9b_1: # @init2
+; CHECK: .init2:
+; CHECK: .__sinit8000_clang_ac404299654d2af7eae71e75c17f7c9b_1:
+; CHECK:   .lglobl	

[PATCH] D84534: [AIX] Static init frontend recovery and backend support

2020-08-05 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L marked 7 inline comments as done.
Xiangling_L added inline comments.



Comment at: llvm/include/llvm/CodeGen/AsmPrinter.h:466
+
+  bool preprocessStructorList(const DataLayout , const Constant *List,
+  SmallVector );

jasonliu wrote:
> A doxygen comment describe what this function does, and what its return value 
> means, and mention `Structors` is an output argument.
> By looking at what this function does, it seems `buildStructorList` is a 
> better name.
I meant to and should've named this function to `preprocessXXStructorList`, let 
me know if you still prefer `buildStructorList`. And if you do, since the 
underneath of `SmallVector` is a variable-sized array, maybe we should try 
`buildSortedStructorArray`?



Comment at: llvm/test/CodeGen/PowerPC/aix-static-init-key-object.ll:6
+
+@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, 
void ()*, i8* } { i32 65535, void ()* @foo, i8* @v}]
+

jasonliu wrote:
> Adding this test case would looks like we already decided how to handle .ref 
> in clang and llvm. But in fact, we haven't. I would prefer not having this 
> test.
As we discussed offline, I would adjust the error message instead.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84534/new/

https://reviews.llvm.org/D84534

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


[PATCH] D85362: [CMake] Print the autodetected host linker version

2020-08-05 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr accepted this revision.
mcgrathr added a comment.
This revision is now accepted and ready to land.

That's a great start.  IMHO we should give the driver a way to print out its 
embedded value too.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85362/new/

https://reviews.llvm.org/D85362

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


[PATCH] D85362: [CMake] Print the autodetected host linker version

2020-08-05 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: smeenai, beanz.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.
phosek requested review of this revision.

There's no easy way to find out what the autodetected version is, but
sometimes it may be useful to confirm that the right version is being
used. Print it as CMake status message.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85362

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -424,15 +424,15 @@
 RESULT_VARIABLE HAD_ERROR
 OUTPUT_VARIABLE LD_V_OUTPUT
   )
-  if (NOT HAD_ERROR)
-if ("${LD_V_OUTPUT}" MATCHES ".*ld64-([0-9.]+).*")
-  string(REGEX REPLACE ".*ld64-([0-9.]+).*" "\\1" HOST_LINK_VERSION 
${LD_V_OUTPUT})
-elseif ("${LD_V_OUTPUT}" MATCHES "[^0-9]*([0-9.]+).*")
-  string(REGEX REPLACE "[^0-9]*([0-9.]+).*" "\\1" HOST_LINK_VERSION 
${LD_V_OUTPUT})
-endif()
-  else()
+  if (HAD_ERROR)
 message(FATAL_ERROR "${CMAKE_LINKER} failed with status ${HAD_ERROR}")
   endif()
+  if ("${LD_V_OUTPUT}" MATCHES ".*ld64-([0-9.]+).*")
+string(REGEX REPLACE ".*ld64-([0-9.]+).*" "\\1" HOST_LINK_VERSION 
${LD_V_OUTPUT})
+  elseif ("${LD_V_OUTPUT}" MATCHES "[^0-9]*([0-9.]+).*")
+string(REGEX REPLACE "[^0-9]*([0-9.]+).*" "\\1" HOST_LINK_VERSION 
${LD_V_OUTPUT})
+  endif()
+  message(STATUS "Host linker version: ${HOST_LINK_VERSION}")
 endif()
 
 include(CMakeParseArguments)


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -424,15 +424,15 @@
 RESULT_VARIABLE HAD_ERROR
 OUTPUT_VARIABLE LD_V_OUTPUT
   )
-  if (NOT HAD_ERROR)
-if ("${LD_V_OUTPUT}" MATCHES ".*ld64-([0-9.]+).*")
-  string(REGEX REPLACE ".*ld64-([0-9.]+).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT})
-elseif ("${LD_V_OUTPUT}" MATCHES "[^0-9]*([0-9.]+).*")
-  string(REGEX REPLACE "[^0-9]*([0-9.]+).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT})
-endif()
-  else()
+  if (HAD_ERROR)
 message(FATAL_ERROR "${CMAKE_LINKER} failed with status ${HAD_ERROR}")
   endif()
+  if ("${LD_V_OUTPUT}" MATCHES ".*ld64-([0-9.]+).*")
+string(REGEX REPLACE ".*ld64-([0-9.]+).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT})
+  elseif ("${LD_V_OUTPUT}" MATCHES "[^0-9]*([0-9.]+).*")
+string(REGEX REPLACE "[^0-9]*([0-9.]+).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT})
+  endif()
+  message(STATUS "Host linker version: ${HOST_LINK_VERSION}")
 endif()
 
 include(CMakeParseArguments)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-08-05 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 283390.
jfb added a comment.

Do UBSan change suggested by Vedant.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79279/new/

https://reviews.llvm.org/D79279

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-overloaded-memfns.c
  clang/test/CodeGen/ubsan-builtin-checks.c
  clang/test/CodeGen/ubsan-builtin-ctz-clz.c
  clang/test/CodeGen/ubsan-builtin-mem_overloaded.c
  clang/test/CodeGenObjC/builtin-memfns.m
  clang/test/Sema/builtin-overloaded-memfns.cpp
  clang/test/SemaCXX/constexpr-string.cpp
  compiler-rt/lib/ubsan/ubsan_handlers.cpp
  compiler-rt/lib/ubsan/ubsan_handlers.h
  compiler-rt/test/ubsan/TestCases/Misc/builtins-ctz-clz.cpp
  compiler-rt/test/ubsan/TestCases/Misc/builtins-mem_overloaded.cpp
  compiler-rt/test/ubsan/TestCases/Misc/builtins.cpp

Index: compiler-rt/test/ubsan/TestCases/Misc/builtins.cpp
===
--- compiler-rt/test/ubsan/TestCases/Misc/builtins.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-// REQUIRES: arch=x86_64
-//
-// RUN: %clangxx -fsanitize=builtin -w %s -O3 -o %t
-// RUN: %run %t 2>&1 | FileCheck %s --check-prefix=RECOVER
-// RUN: %clangxx -fsanitize=builtin -fno-sanitize-recover=builtin -w %s -O3 -o %t.abort
-// RUN: not %run %t.abort 2>&1 | FileCheck %s --check-prefix=ABORT
-
-void check_ctz(int n) {
-  // ABORT: builtins.cpp:[[@LINE+2]]:17: runtime error: passing zero to ctz(), which is not a valid argument
-  // RECOVER: builtins.cpp:[[@LINE+1]]:17: runtime error: passing zero to ctz(), which is not a valid argument
-  __builtin_ctz(n);
-
-  // RECOVER: builtins.cpp:[[@LINE+1]]:18: runtime error: passing zero to ctz(), which is not a valid argument
-  __builtin_ctzl(n);
-
-  // RECOVER: builtins.cpp:[[@LINE+1]]:19: runtime error: passing zero to ctz(), which is not a valid argument
-  __builtin_ctzll(n);
-}
-
-void check_clz(int n) {
-  // RECOVER: builtins.cpp:[[@LINE+1]]:17: runtime error: passing zero to clz(), which is not a valid argument
-  __builtin_clz(n);
-
-  // RECOVER: builtins.cpp:[[@LINE+1]]:18: runtime error: passing zero to clz(), which is not a valid argument
-  __builtin_clzl(n);
-
-  // RECOVER: builtins.cpp:[[@LINE+1]]:19: runtime error: passing zero to clz(), which is not a valid argument
-  __builtin_clzll(n);
-}
-
-int main() {
-  check_ctz(0);
-  check_clz(0);
-  return 0;
-}
Index: compiler-rt/test/ubsan/TestCases/Misc/builtins-mem_overloaded.cpp
===
--- /dev/null
+++ compiler-rt/test/ubsan/TestCases/Misc/builtins-mem_overloaded.cpp
@@ -0,0 +1,93 @@
+// RUN: %clangxx -fsanitize=builtin -w %s -O3 -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+using uintptr_t = __UINTPTR_TYPE__;
+using size_t = __SIZE_TYPE__;
+
+void check_memcpy_align(char *dst_aligned, char *dst_misaligned, const char *src_aligned, const char *src_misaligned, size_t sz) {
+  // OK.
+  __builtin_memcpy_overloaded(dst_aligned, src_aligned, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:31: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memcpy_overloaded(dst_misaligned, src_aligned, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:44: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memcpy_overloaded(dst_aligned, src_misaligned, sz, 2);
+}
+
+void check_memmove_align(char *dst_aligned, char *dst_misaligned, const char *src_aligned, const char *src_misaligned, size_t sz) {
+  // OK.
+  __builtin_memmove_overloaded(dst_aligned, src_aligned, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:32: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memmove_overloaded(dst_misaligned, src_aligned, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:45: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memmove_overloaded(dst_aligned, src_misaligned, sz, 2);
+}
+
+void check_memset_align(char *dst_aligned, char *dst_misaligned, size_t sz) {
+  // OK.
+  __builtin_memset_overloaded(dst_aligned, 0, sz, 2);
+  // CHECK: builtins-mem_overloaded.cpp:[[@LINE+1]]:31: runtime error: passing pointer 0x{{[0-9a-f]*}} with invalid alignment 1 into __builtin_mem*_overloaded, element size 2
+  __builtin_memset_overloaded(dst_misaligned, 0, sz, 2);
+}
+
+void 

[PATCH] D85324: [z/OS] Add z/OS Target and define macros

2020-08-05 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/Basic/Targets/OSTargets.h:732
+Builder.defineMacro("_OPEN_DEFAULT");
+Builder.defineMacro("_UNIX03_WITHDRAWN");
+Builder.defineMacro("__370__");

This is not defined by z/OS XL C/C++. It seems that this is more of a macro to 
be defined by a user application (perhaps as part of its configuration/port for 
z/OS) and less a macro that should be predefined by the compiler.



Comment at: clang/lib/Basic/Targets/OSTargets.h:750
+
+if (Opts.C11 || Opts.GNUMode)
+  Builder.defineMacro("__IBM_UTF_LITERAL");

Shouldn't UTF literals be reported as being enabled under strict C++11?



Comment at: clang/lib/Basic/Targets/OSTargets.h:753
+
+if (Opts.C11 || (Opts.GNUMode && !Opts.CPlusPlus))
+  Builder.defineMacro("__IBMC_GENERIC");

Is this consistent with `__has_extension` with respect to `-pedantic-errors`?
That is, `-pedantic-errors` causes `__has_extension` to report the value that 
`__has_feature` would report. Compiler Explorer link: 
https://godbolt.org/z/EEn8rr

Same question for all of the other IBM-style feature test macros.



Comment at: clang/lib/Basic/Targets/OSTargets.h:758
+  Builder.defineMacro("__DLL__");
+  // Macro __wchar_t exposes the definition of wchar_t data type
+  // in system headers.

Should the comment instead say that `__wchar_t` should be defined so that the 
system headers do not try to declare `wchar_t` as a typedef?



Comment at: clang/lib/Basic/Targets/OSTargets.h:761
+  Builder.defineMacro("__wchar_t");
+  Builder.defineMacro("_XOPEN_SOURCE", "600");
+}

Same comment as before re: macros that should be declared by the application.



Comment at: clang/lib/Basic/Targets/OSTargets.h:764
+
+if (Opts.C11 || Opts.CPlusPlus11 || Opts.GNUMode) 
+  Builder.defineMacro("__IBMC_NORETURN");

I don't see the relation between C++11 and `_Noreturn`. It's an extension in 
C++ that's available under, e.g., `-std=c++03`.



Comment at: clang/lib/Basic/Targets/OSTargets.h:767
+
+if (Opts.C11 || (Opts.GNUMode && Opts.CPlusPlus)) {
+  Builder.defineMacro("__IBM_CHAR16_T__");

`char16_t` is not a keyword in C11, so `__IBM_CHAR16_T__` should not be defined 
for C. Same re: `char32_t`.

Also, `char16_t` and `char32_t` are indeed keywords in C++11.



Comment at: clang/lib/Basic/Targets/OSTargets.h:770
+  Builder.defineMacro("__IBM_CHAR32_T__");
+  Builder.defineMacro("__IBMCPP_UTF_LITERAL__");
+}

The "IBMCPP" macro should not be defined in C modes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85324/new/

https://reviews.llvm.org/D85324

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


[clang] f496950 - [WebAssembly] Fix types in wasm_simd128.h and add tests

2020-08-05 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2020-08-05T14:00:01-07:00
New Revision: f496950001c47724867912d863858db0a81b4309

URL: 
https://github.com/llvm/llvm-project/commit/f496950001c47724867912d863858db0a81b4309
DIFF: 
https://github.com/llvm/llvm-project/commit/f496950001c47724867912d863858db0a81b4309.diff

LOG: [WebAssembly] Fix types in wasm_simd128.h and add tests

47f7174ffa changed the types used in the Wasm SIMD builtin functions,
but not all of their uses in wasm_simd128.h were updated. This commit
fixes wasm_simd128.h and adds tests to make sure similar problems do
not pass uncaught in the future.

Differential Revision: https://reviews.llvm.org/D85347

Added: 
clang/test/Headers/wasm.c
clang/test/Headers/wasm.cpp

Modified: 
clang/lib/Headers/wasm_simd128.h

Removed: 




diff  --git a/clang/lib/Headers/wasm_simd128.h 
b/clang/lib/Headers/wasm_simd128.h
index b15264607d93..ac88516ac924 100644
--- a/clang/lib/Headers/wasm_simd128.h
+++ b/clang/lib/Headers/wasm_simd128.h
@@ -279,7 +279,7 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_i8x16_splat(int8_t __a) {
   (__builtin_wasm_extract_lane_s_i8x16((__i8x16)(__a), __i))
 
 #define wasm_u8x16_extract_lane(__a, __i)  
\
-  (__builtin_wasm_extract_lane_u_i8x16((__i8x16)(__a), __i))
+  (__builtin_wasm_extract_lane_u_i8x16((__u8x16)(__a), __i))
 
 #define wasm_i8x16_replace_lane(__a, __i, __b) 
\
   ((v128_t)__builtin_wasm_replace_lane_i8x16((__i8x16)(__a), __i, __b))
@@ -292,7 +292,7 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_i16x8_splat(int16_t __a) {
   (__builtin_wasm_extract_lane_s_i16x8((__i16x8)(__a), __i))
 
 #define wasm_u16x8_extract_lane(__a, __i)  
\
-  (__builtin_wasm_extract_lane_u_i16x8((__i16x8)(__a), __i))
+  (__builtin_wasm_extract_lane_u_i16x8((__u16x8)(__a), __i))
 
 #define wasm_i16x8_replace_lane(__a, __i, __b) 
\
   ((v128_t)__builtin_wasm_replace_lane_i16x8((__i16x8)(__a), __i, __b))
@@ -622,8 +622,8 @@ wasm_i8x16_add_saturate(v128_t __a, v128_t __b) {
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u8x16_add_saturate(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_add_saturate_u_i8x16((__i8x16)__a,
- (__i8x16)__b);
+  return (v128_t)__builtin_wasm_add_saturate_u_i8x16((__u8x16)__a,
+ (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_sub(v128_t __a,
@@ -639,8 +639,8 @@ wasm_i8x16_sub_saturate(v128_t __a, v128_t __b) {
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u8x16_sub_saturate(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_sub_saturate_u_i8x16((__i8x16)__a,
- (__i8x16)__b);
+  return (v128_t)__builtin_wasm_sub_saturate_u_i8x16((__u8x16)__a,
+ (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min(v128_t __a,
@@ -650,7 +650,7 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_i8x16_min(v128_t __a,
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_min(v128_t __a,
v128_t __b) {
-  return (v128_t)__builtin_wasm_min_u_i8x16((__i8x16)__a, (__i8x16)__b);
+  return (v128_t)__builtin_wasm_min_u_i8x16((__u8x16)__a, (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_max(v128_t __a,
@@ -660,12 +660,12 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_i8x16_max(v128_t __a,
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_max(v128_t __a,
v128_t __b) {
-  return (v128_t)__builtin_wasm_max_u_i8x16((__i8x16)__a, (__i8x16)__b);
+  return (v128_t)__builtin_wasm_max_u_i8x16((__u8x16)__a, (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_avgr(v128_t __a,
 v128_t __b) {
-  return (v128_t)__builtin_wasm_avgr_u_i8x16((__i8x16)__a, (__i8x16)__b);
+  return (v128_t)__builtin_wasm_avgr_u_i8x16((__u8x16)__a, (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_abs(v128_t __a) {
@@ -712,8 +712,8 @@ wasm_i16x8_add_saturate(v128_t __a, v128_t __b) {
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u16x8_add_saturate(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_add_saturate_u_i16x8((__i16x8)__a,
- (__i16x8)__b);
+  return (v128_t)__builtin_wasm_add_saturate_u_i16x8((__u16x8)__a,
+ (__u16x8)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_sub(v128_t __a,
@@ -729,8 +729,8 @@ wasm_i16x8_sub_saturate(v128_t __a, v128_t __b) {
 
 

[PATCH] D85347: [WebAssembly] Fix types in wasm_simd128.h and add tests

2020-08-05 Thread Thomas Lively via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf496950001c4: [WebAssembly] Fix types in wasm_simd128.h and 
add tests (authored by tlively).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85347/new/

https://reviews.llvm.org/D85347

Files:
  clang/lib/Headers/wasm_simd128.h
  clang/test/Headers/wasm.c
  clang/test/Headers/wasm.cpp

Index: clang/test/Headers/wasm.cpp
===
--- /dev/null
+++ clang/test/Headers/wasm.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding %s -verify
+// expected-no-diagnostics
+
+#if defined(__wasm__) && defined(__wasm_simd128__)
+
+extern "C++" {
+#include 
+}
+
+#endif
Index: clang/test/Headers/wasm.c
===
--- /dev/null
+++ clang/test/Headers/wasm.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding %s -verify
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding -flax-vector-conversions=none %s -verify
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding -x c++ %s -verify
+// expected-no-diagnostics
+
+#if defined(__wasm__) && defined(__wasm_simd128__)
+
+#include 
+
+// Test that macros are correct as well
+int main() {
+  v128_t v;
+  v = wasm_i8x16_const(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+  v = wasm_i16x8_const(0, 1, 2, 3, 4, 5, 6, 7);
+  v = wasm_i32x4_const(0, 1, 2, 3);
+  v = wasm_i64x2_const(0, 1);
+  v = wasm_f32x4_const(0.0, 1.0, 2.0, 3.0);
+  v = wasm_f64x2_const(0.0, 1.0);
+
+  int8_t i8 = wasm_i8x16_extract_lane(v, 0);
+  uint8_t u8 = wasm_u8x16_extract_lane(v, 15);
+  v = wasm_i8x16_replace_lane(v, 0, 42);
+
+  int16_t i16 = wasm_i16x8_extract_lane(v, 0);
+  uint16_t u16 = wasm_u16x8_extract_lane(v, 7);
+  v = wasm_i16x8_replace_lane(v, 0, 42);
+
+  int32_t i32 = wasm_i32x4_extract_lane(v, 0);
+  v = wasm_i32x4_replace_lane(v, 0, 42);
+
+  int64_t i64 = wasm_i64x2_extract_lane(v, 0);
+  v = wasm_i64x2_replace_lane(v, 0, 42);
+
+  float f32 = wasm_f32x4_extract_lane(v, 0);
+  v = wasm_f32x4_replace_lane(v, 0, 42.0);
+
+  double f64 = wasm_f64x2_extract_lane(v, 0);
+  v = wasm_f64x2_replace_lane(v, 0, 42.0);
+
+  wasm_v8x16_shuffle(v, v, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+  wasm_v16x8_shuffle(v, v, 0, 1, 2, 3, 4, 5, 6, 7);
+  wasm_v32x4_shuffle(v, v, 0, 1, 2, 3);
+  wasm_v64x2_shuffle(v, v, 0, 1);
+
+  return 0;
+}
+
+#endif
Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -279,7 +279,7 @@
   (__builtin_wasm_extract_lane_s_i8x16((__i8x16)(__a), __i))
 
 #define wasm_u8x16_extract_lane(__a, __i)  \
-  (__builtin_wasm_extract_lane_u_i8x16((__i8x16)(__a), __i))
+  (__builtin_wasm_extract_lane_u_i8x16((__u8x16)(__a), __i))
 
 #define wasm_i8x16_replace_lane(__a, __i, __b) \
   ((v128_t)__builtin_wasm_replace_lane_i8x16((__i8x16)(__a), __i, __b))
@@ -292,7 +292,7 @@
   (__builtin_wasm_extract_lane_s_i16x8((__i16x8)(__a), __i))
 
 #define wasm_u16x8_extract_lane(__a, __i)  \
-  (__builtin_wasm_extract_lane_u_i16x8((__i16x8)(__a), __i))
+  (__builtin_wasm_extract_lane_u_i16x8((__u16x8)(__a), __i))
 
 #define wasm_i16x8_replace_lane(__a, __i, __b) \
   ((v128_t)__builtin_wasm_replace_lane_i16x8((__i16x8)(__a), __i, __b))
@@ -622,8 +622,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u8x16_add_saturate(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_add_saturate_u_i8x16((__i8x16)__a,
- (__i8x16)__b);
+  return (v128_t)__builtin_wasm_add_saturate_u_i8x16((__u8x16)__a,
+ (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_sub(v128_t __a,
@@ -639,8 +639,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u8x16_sub_saturate(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_sub_saturate_u_i8x16((__i8x16)__a,
- (__i8x16)__b);
+  return (v128_t)__builtin_wasm_sub_saturate_u_i8x16((__u8x16)__a,
+ (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min(v128_t __a,
@@ -650,7 +650,7 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_min(v128_t __a,
v128_t __b) {
-  return 

[PATCH] D85287: Extend -Wtautological-bitwise-compare "bitwise or with non-zero value" warnings

2020-08-05 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg added a comment.

My naive assumption was that this warning had initially been restricted to 
integer literals and enumerators to avoid false positives.  Hence my 
conservative approach of extending merely to constant integer expressions for 
now.  Maybe Richard as the original author of the warning (IIUC) can shed some 
light on that original restriction?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85287/new/

https://reviews.llvm.org/D85287

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


[PATCH] D85347: [WebAssembly] Fix types in wasm_simd128.h and add tests

2020-08-05 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: clang/test/Headers/wasm.cpp:1
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 
-fsyntax-only -ffreestanding %s -verify
+// expected-no-diagnostics

sunfish wrote:
> This test currently passes on trunk without the bug fix here. Could you add a 
> -flax-vector-conversions=none line, similar to the C test, which is the case 
> that the patch here fixes?
I think it's ok that this doesn't test with `-flax-vector-conversions=none`, 
since that's already tested in the .c file. This pattern of testing is copied 
from x86intrin.{c,cpp} and that's how this works in those files as well. This 
.cpp file only exists to additionally test the header contents with `extern 
"C++"` around them AFAICT.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85347/new/

https://reviews.llvm.org/D85347

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


[PATCH] D85191: [AST] Get field size in chars rather than bits in RecordLayoutBuilder.

2020-08-05 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> If the intent is for getTypeInfo to always return sizes that are multiples of 
> the char size, then the design should be inverted and getTypeInfo should 
> simply be calling getTypeInfoInChars and multiply that result by the char 
> size. But that isn't how it works.

The reason it doesn't work this way is just that someone made the wrong choice 
a decade ago, and nobody has spent the time to rewrite it since.  Patch welcome.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85191/new/

https://reviews.llvm.org/D85191

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


[PATCH] D85347: [WebAssembly] Fix types in wasm_simd128.h and add tests

2020-08-05 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 283373.
tlively added a comment.

- Fix and test macros as well


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85347/new/

https://reviews.llvm.org/D85347

Files:
  clang/lib/Headers/wasm_simd128.h
  clang/test/Headers/wasm.c
  clang/test/Headers/wasm.cpp

Index: clang/test/Headers/wasm.cpp
===
--- /dev/null
+++ clang/test/Headers/wasm.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding %s -verify
+// expected-no-diagnostics
+
+#if defined(__wasm__) && defined(__wasm_simd128__)
+
+extern "C++" {
+#include 
+}
+
+#endif
Index: clang/test/Headers/wasm.c
===
--- /dev/null
+++ clang/test/Headers/wasm.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding %s -verify
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding -flax-vector-conversions=none %s -verify
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding -x c++ %s -verify
+// expected-no-diagnostics
+
+#if defined(__wasm__) && defined(__wasm_simd128__)
+
+#include 
+
+// Test that macros are correct as well
+int main() {
+  v128_t v;
+  v = wasm_i8x16_const(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+  v = wasm_i16x8_const(0, 1, 2, 3, 4, 5, 6, 7);
+  v = wasm_i32x4_const(0, 1, 2, 3);
+  v = wasm_i64x2_const(0, 1);
+  v = wasm_f32x4_const(0.0, 1.0, 2.0, 3.0);
+  v = wasm_f64x2_const(0.0, 1.0);
+
+  int8_t i8 = wasm_i8x16_extract_lane(v, 0);
+  uint8_t u8 = wasm_u8x16_extract_lane(v, 15);
+  v = wasm_i8x16_replace_lane(v, 0, 42);
+
+  int16_t i16 = wasm_i16x8_extract_lane(v, 0);
+  uint16_t u16 = wasm_u16x8_extract_lane(v, 7);
+  v = wasm_i16x8_replace_lane(v, 0, 42);
+
+  int32_t i32 = wasm_i32x4_extract_lane(v, 0);
+  v = wasm_i32x4_replace_lane(v, 0, 42);
+
+  int64_t i64 = wasm_i64x2_extract_lane(v, 0);
+  v = wasm_i64x2_replace_lane(v, 0, 42);
+
+  float f32 = wasm_f32x4_extract_lane(v, 0);
+  v = wasm_f32x4_replace_lane(v, 0, 42.0);
+
+  double f64 = wasm_f64x2_extract_lane(v, 0);
+  v = wasm_f64x2_replace_lane(v, 0, 42.0);
+
+  wasm_v8x16_shuffle(v, v, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+  wasm_v16x8_shuffle(v, v, 0, 1, 2, 3, 4, 5, 6, 7);
+  wasm_v32x4_shuffle(v, v, 0, 1, 2, 3);
+  wasm_v64x2_shuffle(v, v, 0, 1);
+
+  return 0;
+}
+
+#endif
Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -279,7 +279,7 @@
   (__builtin_wasm_extract_lane_s_i8x16((__i8x16)(__a), __i))
 
 #define wasm_u8x16_extract_lane(__a, __i)  \
-  (__builtin_wasm_extract_lane_u_i8x16((__i8x16)(__a), __i))
+  (__builtin_wasm_extract_lane_u_i8x16((__u8x16)(__a), __i))
 
 #define wasm_i8x16_replace_lane(__a, __i, __b) \
   ((v128_t)__builtin_wasm_replace_lane_i8x16((__i8x16)(__a), __i, __b))
@@ -292,7 +292,7 @@
   (__builtin_wasm_extract_lane_s_i16x8((__i16x8)(__a), __i))
 
 #define wasm_u16x8_extract_lane(__a, __i)  \
-  (__builtin_wasm_extract_lane_u_i16x8((__i16x8)(__a), __i))
+  (__builtin_wasm_extract_lane_u_i16x8((__u16x8)(__a), __i))
 
 #define wasm_i16x8_replace_lane(__a, __i, __b) \
   ((v128_t)__builtin_wasm_replace_lane_i16x8((__i16x8)(__a), __i, __b))
@@ -622,8 +622,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u8x16_add_saturate(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_add_saturate_u_i8x16((__i8x16)__a,
- (__i8x16)__b);
+  return (v128_t)__builtin_wasm_add_saturate_u_i8x16((__u8x16)__a,
+ (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_sub(v128_t __a,
@@ -639,8 +639,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u8x16_sub_saturate(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_sub_saturate_u_i8x16((__i8x16)__a,
- (__i8x16)__b);
+  return (v128_t)__builtin_wasm_sub_saturate_u_i8x16((__u8x16)__a,
+ (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min(v128_t __a,
@@ -650,7 +650,7 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_min(v128_t __a,
v128_t __b) {
-  return (v128_t)__builtin_wasm_min_u_i8x16((__i8x16)__a, (__i8x16)__b);
+  return (v128_t)__builtin_wasm_min_u_i8x16((__u8x16)__a, (__u8x16)__b);
 }
 
 static __inline__ v128_t 

[PATCH] D85354: [clangd] Reduce availability of extract function

2020-08-05 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

This patch introduces hoisting detection logic into prepare state with
a partial AST traversal of the enclosing function.

We had some complaints from the users about this code action being almost always
available but failing most of the time. Hopefully this should reduce that noise.

The latency/correctness tradeoff is a bunch of hand-waving, but at least today
we don't have any other actions that are available on selection of statements,
so when we get to do the traversal it is quite likely that all the other checks
will bail out early. But this is still up for discussion, I am happy to abandon
the patch if you believe this is not practical.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85354

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -592,6 +592,8 @@
   EXPECT_EQ(apply("auto lam = [](){ [[int x;]] }; "), "unavailable");
   // Partial statements aren't extracted.
   EXPECT_THAT(apply("int [[x = 0]];"), "unavailable");
+  // FIXME: Support hoisting.
+  EXPECT_THAT(apply(" [[int a = 5;]] a++; "), "unavailable");
 
   // Ensure that end of Zone and Beginning of PostZone being adjacent doesn't
   // lead to break being included in the extraction zone.
@@ -599,8 +601,6 @@
   // FIXME: ExtractFunction should be unavailable inside loop construct
   // initializer/condition.
   EXPECT_THAT(apply(" for([[int i = 0;]];);"), HasSubstr("extracted"));
-  // Don't extract because needs hoisting.
-  EXPECT_THAT(apply(" [[int a = 5;]] a++; "), StartsWith("fail"));
   // Extract certain return
   EXPECT_THAT(apply(" if(true) [[{ return; }]] "), HasSubstr("extracted"));
   // Don't extract uncertain return
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -47,6 +47,7 @@
 //===--===//
 
 #include "AST.h"
+#include "FindTarget.h"
 #include "ParsedAST.h"
 #include "Selection.h"
 #include "SourceCode.h"
@@ -54,6 +55,7 @@
 #include "support/Logger.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
@@ -65,6 +67,7 @@
 #include "clang/Tooling/Refactoring/Extract/SourceExtraction.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator_range.h"
@@ -152,6 +155,9 @@
   const FunctionDecl *EnclosingFunction = nullptr;
   // The half-open file range of the enclosing function.
   SourceRange EnclosingFuncRange;
+  // Set of statements that form the ExtractionZone.
+  llvm::DenseSet RootStmts;
+
   SourceLocation getInsertionPoint() const {
 return EnclosingFuncRange.getBegin();
   }
@@ -159,10 +165,6 @@
   // The last root statement is important to decide where we need to insert a
   // semicolon after the extraction.
   const Node *getLastRootStmt() const { return Parent->Children.back(); }
-  void generateRootStmts();
-
-private:
-  llvm::DenseSet RootStmts;
 };
 
 // Whether the code in the extraction zone is guaranteed to return, assuming
@@ -185,12 +187,6 @@
   return RootStmts.find(S) != RootStmts.end();
 }
 
-// Generate RootStmts set
-void ExtractionZone::generateRootStmts() {
-  for (const Node *Child : Parent->Children)
-RootStmts.insert(Child->ASTNode.get());
-}
-
 // Finds the function in which the zone lies.
 const FunctionDecl *findEnclosingFunction(const Node *CommonAnc) {
   // Walk up the SelectionTree until we find a function Decl
@@ -281,7 +277,46 @@
 ExtZone.ZoneRange = *ZoneRange;
   if (ExtZone.EnclosingFuncRange.isInvalid() || ExtZone.ZoneRange.isInvalid())
 return llvm::None;
-  ExtZone.generateRootStmts();
+
+  // Make sure declarations inside extraction zone are not accessed afterwards.
+  // This performs a partial AST traversal proportional to the size of the
+  // enclosing function, so it is possibly expensive. But, if we made it so far
+  // this is likely to be only action we are going to offer, so performing a
+  // single AST traversal shouldn't be too bad.
+  // FIXME: Get rid of the following checks once we have support 

[PATCH] D85236: [CUDA] Work around a bug in rint() caused by a broken implementation provided by CUDA.

2020-08-05 Thread Artem Belevich via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7d057efddc00: [CUDA] Work around a bug in rint/nearbyint 
caused by a broken implementation… (authored by tra).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85236/new/

https://reviews.llvm.org/D85236

Files:
  clang/lib/Headers/__clang_cuda_math.h


Index: clang/lib/Headers/__clang_cuda_math.h
===
--- clang/lib/Headers/__clang_cuda_math.h
+++ clang/lib/Headers/__clang_cuda_math.h
@@ -195,8 +195,8 @@
 __DEVICE__ int min(int __a, int __b) { return __nv_min(__a, __b); }
 __DEVICE__ double modf(double __a, double *__b) { return __nv_modf(__a, __b); }
 __DEVICE__ float modff(float __a, float *__b) { return __nv_modff(__a, __b); }
-__DEVICE__ double nearbyint(double __a) { return __nv_nearbyint(__a); }
-__DEVICE__ float nearbyintf(float __a) { return __nv_nearbyintf(__a); }
+__DEVICE__ double nearbyint(double __a) { return __builtin_nearbyint(__a); }
+__DEVICE__ float nearbyintf(float __a) { return __builtin_nearbyintf(__a); }
 __DEVICE__ double nextafter(double __a, double __b) {
   return __nv_nextafter(__a, __b);
 }
@@ -249,8 +249,9 @@
 __DEVICE__ float rhypotf(float __a, float __b) {
   return __nv_rhypotf(__a, __b);
 }
-__DEVICE__ double rint(double __a) { return __nv_rint(__a); }
-__DEVICE__ float rintf(float __a) { return __nv_rintf(__a); }
+// __nv_rint* in libdevice is buggy and produces incorrect results.
+__DEVICE__ double rint(double __a) { return __builtin_rint(__a); }
+__DEVICE__ float rintf(float __a) { return __builtin_rintf(__a); }
 __DEVICE__ double rnorm(int __a, const double *__b) {
   return __nv_rnorm(__a, __b);
 }


Index: clang/lib/Headers/__clang_cuda_math.h
===
--- clang/lib/Headers/__clang_cuda_math.h
+++ clang/lib/Headers/__clang_cuda_math.h
@@ -195,8 +195,8 @@
 __DEVICE__ int min(int __a, int __b) { return __nv_min(__a, __b); }
 __DEVICE__ double modf(double __a, double *__b) { return __nv_modf(__a, __b); }
 __DEVICE__ float modff(float __a, float *__b) { return __nv_modff(__a, __b); }
-__DEVICE__ double nearbyint(double __a) { return __nv_nearbyint(__a); }
-__DEVICE__ float nearbyintf(float __a) { return __nv_nearbyintf(__a); }
+__DEVICE__ double nearbyint(double __a) { return __builtin_nearbyint(__a); }
+__DEVICE__ float nearbyintf(float __a) { return __builtin_nearbyintf(__a); }
 __DEVICE__ double nextafter(double __a, double __b) {
   return __nv_nextafter(__a, __b);
 }
@@ -249,8 +249,9 @@
 __DEVICE__ float rhypotf(float __a, float __b) {
   return __nv_rhypotf(__a, __b);
 }
-__DEVICE__ double rint(double __a) { return __nv_rint(__a); }
-__DEVICE__ float rintf(float __a) { return __nv_rintf(__a); }
+// __nv_rint* in libdevice is buggy and produces incorrect results.
+__DEVICE__ double rint(double __a) { return __builtin_rint(__a); }
+__DEVICE__ float rintf(float __a) { return __builtin_rintf(__a); }
 __DEVICE__ double rnorm(int __a, const double *__b) {
   return __nv_rnorm(__a, __b);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7d057ef - [CUDA] Work around a bug in rint/nearbyint caused by a broken implementation provided by CUDA.

2020-08-05 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2020-08-05T13:13:48-07:00
New Revision: 7d057efddc00ba7d03e6e684f23dd9b09fbd0527

URL: 
https://github.com/llvm/llvm-project/commit/7d057efddc00ba7d03e6e684f23dd9b09fbd0527
DIFF: 
https://github.com/llvm/llvm-project/commit/7d057efddc00ba7d03e6e684f23dd9b09fbd0527.diff

LOG: [CUDA] Work around a bug in rint/nearbyint caused by a broken 
implementation provided by CUDA.

Normally math functions are forwarded to __nv_* counterparts provided by CUDA's
libdevice bitcode. However, __nv_rint*()/__nv_nearbyint*() functions there have
a bug -- they use round() which rounds *up* instead of rounding towards the
nearest integer, so we end up with rint(2.5f) producing 3.0 instead of expected
2.0. The broken bitcode is not actually used by NVCC itself, which has both a
work-around in CUDA headers and, in recent versions, uses correct
implementations in NVCC's built-ins.

This patch implements equivalent workaround and directs rint*/nearbyint* to
__builtin_* variants that produce correct results.

Differential Revision: https://reviews.llvm.org/D85236

Added: 


Modified: 
clang/lib/Headers/__clang_cuda_math.h

Removed: 




diff  --git a/clang/lib/Headers/__clang_cuda_math.h 
b/clang/lib/Headers/__clang_cuda_math.h
index 332e616702ac..acb26ad345d5 100644
--- a/clang/lib/Headers/__clang_cuda_math.h
+++ b/clang/lib/Headers/__clang_cuda_math.h
@@ -195,8 +195,8 @@ __DEVICE__ int max(int __a, int __b) { return __nv_max(__a, 
__b); }
 __DEVICE__ int min(int __a, int __b) { return __nv_min(__a, __b); }
 __DEVICE__ double modf(double __a, double *__b) { return __nv_modf(__a, __b); }
 __DEVICE__ float modff(float __a, float *__b) { return __nv_modff(__a, __b); }
-__DEVICE__ double nearbyint(double __a) { return __nv_nearbyint(__a); }
-__DEVICE__ float nearbyintf(float __a) { return __nv_nearbyintf(__a); }
+__DEVICE__ double nearbyint(double __a) { return __builtin_nearbyint(__a); }
+__DEVICE__ float nearbyintf(float __a) { return __builtin_nearbyintf(__a); }
 __DEVICE__ double nextafter(double __a, double __b) {
   return __nv_nextafter(__a, __b);
 }
@@ -249,8 +249,9 @@ __DEVICE__ double rhypot(double __a, double __b) {
 __DEVICE__ float rhypotf(float __a, float __b) {
   return __nv_rhypotf(__a, __b);
 }
-__DEVICE__ double rint(double __a) { return __nv_rint(__a); }
-__DEVICE__ float rintf(float __a) { return __nv_rintf(__a); }
+// __nv_rint* in libdevice is buggy and produces incorrect results.
+__DEVICE__ double rint(double __a) { return __builtin_rint(__a); }
+__DEVICE__ float rintf(float __a) { return __builtin_rintf(__a); }
 __DEVICE__ double rnorm(int __a, const double *__b) {
   return __nv_rnorm(__a, __b);
 }



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


[PATCH] D85191: [AST] Get field size in chars rather than bits in RecordLayoutBuilder.

2020-08-05 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

In D85191#2196863 , @rsmith wrote:

> In D85191#2195923 , @ebevhan wrote:
>
>> In D85191#2193645 , @rsmith wrote:
>>
 This is not ideal, since it makes the calculations char size dependent, 
 and breaks for sizes that are not a multiple of the char size.
>>>
>>> How can we have a non-bitfield member whose size is not a multiple of the 
>>> size of a char?
>>
>> Downstream, we have fixed-point types that are 24 bits large, but where the 
>> char size is 16. The type then takes up 2 chars, where 8 of the bits are 
>> padding. The only way in Clang to express that the width of the bit 
>> representation of a type should be smaller than the number of chars it takes 
>> up in memory -- and consequently, produce an `i24` in IR -- is to return a 
>> non-charsize multiple from getTypeInfo.
>
> This violates the C and C++ language rules, which require the size of every 
> type to be a multiple of the size of char. A type with 24 value bits and 8 
> padding bits should report a type size of 32 bits, just like `bool` reports a 
> size of `CHAR_BIT` bits despite having only 1 value bit, and x86_64 `long 
> double` reports a type size of 128 bits despite having only 80 value bits.

I don't see that it breaks the language rules. The sizeof result for the 24 bit 
type should be 2 in the target described by @ebevhan  (two 16-bit bytes). But I 
imagine that without this patch it is reported as 24/16=1, right?

So isn't the problem that toCharUnitsFromBits is rounding down when given a 
bitsize that isn't a multiple of CHAR_BIT? Would it perhaps make sense to let 
it round up instead?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85191/new/

https://reviews.llvm.org/D85191

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


[PATCH] D85347: [WebAssembly] Fix types in wasm_simd128.h and add tests

2020-08-05 Thread Dan Gohman via Phabricator via cfe-commits
sunfish accepted this revision.
sunfish added a comment.
This revision is now accepted and ready to land.

Ah, it seems the reason I didn't see this is that I wasn't using 
`-flax-vector-conversions=none`. Thanks for fixing this!




Comment at: clang/test/Headers/wasm.cpp:1
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 
-fsyntax-only -ffreestanding %s -verify
+// expected-no-diagnostics

This test currently passes on trunk without the bug fix here. Could you add a 
-flax-vector-conversions=none line, similar to the C test, which is the case 
that the patch here fixes?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85347/new/

https://reviews.llvm.org/D85347

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


[PATCH] D85236: [CUDA] Work around a bug in rint() caused by a broken implementation provided by CUDA.

2020-08-05 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 283359.
tra edited the summary of this revision.
tra added a comment.

Also fixed the same bug in nearbyint().


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85236/new/

https://reviews.llvm.org/D85236

Files:
  clang/lib/Headers/__clang_cuda_math.h


Index: clang/lib/Headers/__clang_cuda_math.h
===
--- clang/lib/Headers/__clang_cuda_math.h
+++ clang/lib/Headers/__clang_cuda_math.h
@@ -195,8 +195,8 @@
 __DEVICE__ int min(int __a, int __b) { return __nv_min(__a, __b); }
 __DEVICE__ double modf(double __a, double *__b) { return __nv_modf(__a, __b); }
 __DEVICE__ float modff(float __a, float *__b) { return __nv_modff(__a, __b); }
-__DEVICE__ double nearbyint(double __a) { return __nv_nearbyint(__a); }
-__DEVICE__ float nearbyintf(float __a) { return __nv_nearbyintf(__a); }
+__DEVICE__ double nearbyint(double __a) { return __builtin_nearbyint(__a); }
+__DEVICE__ float nearbyintf(float __a) { return __builtin_nearbyintf(__a); }
 __DEVICE__ double nextafter(double __a, double __b) {
   return __nv_nextafter(__a, __b);
 }
@@ -249,8 +249,9 @@
 __DEVICE__ float rhypotf(float __a, float __b) {
   return __nv_rhypotf(__a, __b);
 }
-__DEVICE__ double rint(double __a) { return __nv_rint(__a); }
-__DEVICE__ float rintf(float __a) { return __nv_rintf(__a); }
+// __nv_rint* in libdevice is buggy and produces incorrect results.
+__DEVICE__ double rint(double __a) { return __builtin_rint(__a); }
+__DEVICE__ float rintf(float __a) { return __builtin_rintf(__a); }
 __DEVICE__ double rnorm(int __a, const double *__b) {
   return __nv_rnorm(__a, __b);
 }


Index: clang/lib/Headers/__clang_cuda_math.h
===
--- clang/lib/Headers/__clang_cuda_math.h
+++ clang/lib/Headers/__clang_cuda_math.h
@@ -195,8 +195,8 @@
 __DEVICE__ int min(int __a, int __b) { return __nv_min(__a, __b); }
 __DEVICE__ double modf(double __a, double *__b) { return __nv_modf(__a, __b); }
 __DEVICE__ float modff(float __a, float *__b) { return __nv_modff(__a, __b); }
-__DEVICE__ double nearbyint(double __a) { return __nv_nearbyint(__a); }
-__DEVICE__ float nearbyintf(float __a) { return __nv_nearbyintf(__a); }
+__DEVICE__ double nearbyint(double __a) { return __builtin_nearbyint(__a); }
+__DEVICE__ float nearbyintf(float __a) { return __builtin_nearbyintf(__a); }
 __DEVICE__ double nextafter(double __a, double __b) {
   return __nv_nextafter(__a, __b);
 }
@@ -249,8 +249,9 @@
 __DEVICE__ float rhypotf(float __a, float __b) {
   return __nv_rhypotf(__a, __b);
 }
-__DEVICE__ double rint(double __a) { return __nv_rint(__a); }
-__DEVICE__ float rintf(float __a) { return __nv_rintf(__a); }
+// __nv_rint* in libdevice is buggy and produces incorrect results.
+__DEVICE__ double rint(double __a) { return __builtin_rint(__a); }
+__DEVICE__ float rintf(float __a) { return __builtin_rintf(__a); }
 __DEVICE__ double rnorm(int __a, const double *__b) {
   return __nv_rnorm(__a, __b);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83261: [OPENMP]Redesign of OMPExecutableDirective representation.

2020-08-05 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:3329
   }
-  OMPDeclareMapperDecl *NewDMD = 
SemaRef.ActOnOpenMPDeclareMapperDirectiveStart(
-  /*S=*/nullptr, Owner, D->getDeclName(), SubstMapperTy, D->getLocation(),

Meinersbur wrote:
> The refactoring of ActOnOpenMPDeclareMapperDirective seems unrelated.
These changes are required by the redesign of the declare mapper representation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83261/new/

https://reviews.llvm.org/D83261

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


[PATCH] D85351: [Analyzer] Fix for `ExprEngine::computeObjectUnderConstruction()` for base and delegating consturctor initializers

2020-08-05 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: NoQ, vsavchenko.
baloghadamsoftware added a project: clang.
Herald added subscribers: ASDenysPetrov, martong, steakhal, Charusso, dkrupp, 
donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, whisperity.
Herald added a reviewer: Szelethus.
baloghadamsoftware requested review of this revision.

For /C++/ constructor initializers `ExprEngine:computeUnderConstruction()` 
asserts that they are all member initializers. This is not neccessarily true 
when this function is used to get the return value for the construction context 
thus attempts to fetch return values of base and delegating constructor 
initializers result in assertions. This small patch fixes this issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85351

Files:
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp


Index: clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp
===
--- clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp
+++ clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp
@@ -54,16 +54,33 @@
   R"(class C {
  public:
C(int nn): n(nn) {}
+   explicit C(): C(0) {}
virtual ~C() {}
  private:
int n;
  };
 
+ class D: public C {
+ public:
+   D(int nn): C(nn) {}
+   virtual ~D() {}
+ };
+
  C returnC(int m) {
C c(m);
return c;
  }
 
+ C returnC() {
+   C c;
+   return c;
+ }
+
+ D returnD(int m) {
+   D d(m);
+   return d;
+ }
+
  void foo() {
C c = returnC(1); 
  })"));
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -132,10 +132,11 @@
 case ConstructionContext::SimpleConstructorInitializerKind: {
   const auto *ICC = cast(CC);
   const auto *Init = ICC->getCXXCtorInitializer();
-  assert(Init->isAnyMemberInitializer());
   const CXXMethodDecl *CurCtor = cast(LCtx->getDecl());
   Loc ThisPtr = SVB.getCXXThis(CurCtor, LCtx->getStackFrame());
   SVal ThisVal = State->getSVal(ThisPtr);
+  if (Init->isBaseInitializer() || Init->isDelegatingInitializer())
+return ThisVal;
 
   const ValueDecl *Field;
   SVal FieldVal;
@@ -364,6 +365,8 @@
 case ConstructionContext::CXX17ElidedCopyConstructorInitializerKind:
 case ConstructionContext::SimpleConstructorInitializerKind: {
   const auto *ICC = cast(CC);
+  const auto *Init = ICC->getCXXCtorInitializer();
+  assert(Init->isAnyMemberInitializer());
   return addObjectUnderConstruction(State, ICC->getCXXCtorInitializer(),
 LCtx, V);
 }


Index: clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp
===
--- clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp
+++ clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp
@@ -54,16 +54,33 @@
   R"(class C {
  public:
C(int nn): n(nn) {}
+   explicit C(): C(0) {}
virtual ~C() {}
  private:
int n;
  };
 
+ class D: public C {
+ public:
+   D(int nn): C(nn) {}
+   virtual ~D() {}
+ };
+
  C returnC(int m) {
C c(m);
return c;
  }
 
+ C returnC() {
+   C c;
+   return c;
+ }
+
+ D returnD(int m) {
+   D d(m);
+   return d;
+ }
+
  void foo() {
C c = returnC(1); 
  })"));
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -132,10 +132,11 @@
 case 

[PATCH] D83261: [OPENMP]Redesign of OMPExecutableDirective representation.

2020-08-05 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

I think the ActOnOpenMPDeclareMapperDirective changes should be separated into 
its own patch. Otherwise, LGTM.




Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:3329
   }
-  OMPDeclareMapperDecl *NewDMD = 
SemaRef.ActOnOpenMPDeclareMapperDirectiveStart(
-  /*S=*/nullptr, Owner, D->getDeclName(), SubstMapperTy, D->getLocation(),

The refactoring of ActOnOpenMPDeclareMapperDirective seems unrelated.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83261/new/

https://reviews.llvm.org/D83261

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


[clang] 105608a - [AMDGPU] Added missing gfx1031 cases to CGOpenMPRuntimeGPU.cpp

2020-08-05 Thread Stanislav Mekhanoshin via cfe-commits

Author: Stanislav Mekhanoshin
Date: 2020-08-05T12:39:03-07:00
New Revision: 105608a4c2821ca8f8340104614c1176ed1ed82d

URL: 
https://github.com/llvm/llvm-project/commit/105608a4c2821ca8f8340104614c1176ed1ed82d
DIFF: 
https://github.com/llvm/llvm-project/commit/105608a4c2821ca8f8340104614c1176ed1ed82d.diff

LOG: [AMDGPU] Added missing gfx1031 cases to CGOpenMPRuntimeGPU.cpp

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 452eb15eb8d1..9440758a85b6 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -5014,6 +5014,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(
   case CudaArch::GFX1011:
   case CudaArch::GFX1012:
   case CudaArch::GFX1030:
+  case CudaArch::GFX1031:
   case CudaArch::UNKNOWN:
 break;
   case CudaArch::LAST:
@@ -5074,6 +5075,7 @@ static std::pair 
getSMsBlocksPerSM(CodeGenModule ) {
   case CudaArch::GFX1011:
   case CudaArch::GFX1012:
   case CudaArch::GFX1030:
+  case CudaArch::GFX1031:
   case CudaArch::UNKNOWN:
 break;
   case CudaArch::LAST:



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


[PATCH] D85347: [WebAssembly] Fix types in wasm_simd128.h and add tests

2020-08-05 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 283348.
tlively added a comment.

- Fix


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85347/new/

https://reviews.llvm.org/D85347

Files:
  clang/lib/Headers/wasm_simd128.h
  clang/test/Headers/wasm.c
  clang/test/Headers/wasm.cpp

Index: clang/test/Headers/wasm.cpp
===
--- /dev/null
+++ clang/test/Headers/wasm.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding %s -verify
+// expected-no-diagnostics
+
+#if defined(__wasm__) && defined(__wasm_simd128__)
+
+extern "C++" {
+#include 
+}
+
+#endif
Index: clang/test/Headers/wasm.c
===
--- /dev/null
+++ clang/test/Headers/wasm.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding %s -verify
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding -flax-vector-conversions=none %s -verify
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding -x c++ %s -verify
+// expected-no-diagnostics
+
+#if defined(__wasm__) && defined(__wasm_simd128__)
+
+#include 
+
+#endif
Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -622,8 +622,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u8x16_add_saturate(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_add_saturate_u_i8x16((__i8x16)__a,
- (__i8x16)__b);
+  return (v128_t)__builtin_wasm_add_saturate_u_i8x16((__u8x16)__a,
+ (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_sub(v128_t __a,
@@ -639,8 +639,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u8x16_sub_saturate(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_sub_saturate_u_i8x16((__i8x16)__a,
- (__i8x16)__b);
+  return (v128_t)__builtin_wasm_sub_saturate_u_i8x16((__u8x16)__a,
+ (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min(v128_t __a,
@@ -650,7 +650,7 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_min(v128_t __a,
v128_t __b) {
-  return (v128_t)__builtin_wasm_min_u_i8x16((__i8x16)__a, (__i8x16)__b);
+  return (v128_t)__builtin_wasm_min_u_i8x16((__u8x16)__a, (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_max(v128_t __a,
@@ -660,12 +660,12 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_max(v128_t __a,
v128_t __b) {
-  return (v128_t)__builtin_wasm_max_u_i8x16((__i8x16)__a, (__i8x16)__b);
+  return (v128_t)__builtin_wasm_max_u_i8x16((__u8x16)__a, (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_avgr(v128_t __a,
 v128_t __b) {
-  return (v128_t)__builtin_wasm_avgr_u_i8x16((__i8x16)__a, (__i8x16)__b);
+  return (v128_t)__builtin_wasm_avgr_u_i8x16((__u8x16)__a, (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_abs(v128_t __a) {
@@ -712,8 +712,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u16x8_add_saturate(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_add_saturate_u_i16x8((__i16x8)__a,
- (__i16x8)__b);
+  return (v128_t)__builtin_wasm_add_saturate_u_i16x8((__u16x8)__a,
+ (__u16x8)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_sub(v128_t __a,
@@ -729,8 +729,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u16x8_sub_saturate(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_sub_saturate_u_i16x8((__i16x8)__a,
- (__i16x8)__b);
+  return (v128_t)__builtin_wasm_sub_saturate_u_i16x8((__u16x8)__a,
+ (__u16x8)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_mul(v128_t __a,
@@ -745,7 +745,7 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_min(v128_t __a,
v128_t __b) {
-  return (v128_t)__builtin_wasm_min_u_i16x8((__i16x8)__a, (__i16x8)__b);
+  return (v128_t)__builtin_wasm_min_u_i16x8((__u16x8)__a, (__u16x8)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_max(v128_t __a,
@@ -755,12 +755,12 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS 

[clang] ea7d0e2 - [AMDGPU] gfx1031 target

2020-08-05 Thread Stanislav Mekhanoshin via cfe-commits

Author: Stanislav Mekhanoshin
Date: 2020-08-05T12:36:26-07:00
New Revision: ea7d0e2996ec6b72a08dbef26dadf217458ab382

URL: 
https://github.com/llvm/llvm-project/commit/ea7d0e2996ec6b72a08dbef26dadf217458ab382
DIFF: 
https://github.com/llvm/llvm-project/commit/ea7d0e2996ec6b72a08dbef26dadf217458ab382.diff

LOG: [AMDGPU] gfx1031 target

Differential Revision: https://reviews.llvm.org/D85337

Added: 


Modified: 
clang/include/clang/Basic/Cuda.h
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/NVPTX.cpp
clang/test/CodeGenOpenCL/amdgpu-features.cl
clang/test/Driver/amdgpu-macros.cl
clang/test/Driver/amdgpu-mcpu.cl
llvm/docs/AMDGPUUsage.rst
llvm/include/llvm/BinaryFormat/ELF.h
llvm/include/llvm/Support/TargetParser.h
llvm/lib/ObjectYAML/ELFYAML.cpp
llvm/lib/Support/TargetParser.cpp
llvm/lib/Target/AMDGPU/GCNProcessors.td
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-fmad.s32.mir
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.global.atomic.csub.ll
llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll
llvm/test/CodeGen/AMDGPU/hsa-note-no-func.ll
llvm/test/CodeGen/AMDGPU/idot8s.ll
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.atomic.csub.ll
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.sdot4.ll
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.sdot8.ll
llvm/test/MC/AMDGPU/gfx1030_err.s
llvm/test/MC/AMDGPU/gfx1030_new.s
llvm/test/MC/Disassembler/AMDGPU/gfx1030_dasm_new.txt
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Cuda.h 
b/clang/include/clang/Basic/Cuda.h
index 1716325a99312..19301e825bcfd 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -75,6 +75,7 @@ enum class CudaArch {
   GFX1011,
   GFX1012,
   GFX1030,
+  GFX1031,
   LAST,
 };
 

diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index e147045110a99..57351c7557082 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -174,6 +174,7 @@ bool AMDGPUTargetInfo::initFeatureMap(
   // XXX - What does the member GPU mean if device name string passed here?
   if (isAMDGCN(getTriple())) {
 switch (llvm::AMDGPU::parseArchAMDGCN(CPU)) {
+case GK_GFX1031:
 case GK_GFX1030:
   Features["ci-insts"] = true;
   Features["dot1-insts"] = true;

diff  --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index 18c3c83703310..ef61b8f78946c 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -201,6 +201,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions 
,
   case CudaArch::GFX1011:
   case CudaArch::GFX1012:
   case CudaArch::GFX1030:
+  case CudaArch::GFX1031:
   case CudaArch::LAST:
 break;
   case CudaArch::UNKNOWN:

diff  --git a/clang/test/CodeGenOpenCL/amdgpu-features.cl 
b/clang/test/CodeGenOpenCL/amdgpu-features.cl
index 4c26163237980..93357a48eb89a 100644
--- a/clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ b/clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -14,6 +14,7 @@
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1011 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1011 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1012 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1012 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1030 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1030 %s
+// RUN: %clang_cc1 -triple amdgcn -target-cpu gfx1031 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX1031 %s
 
 // GFX600-NOT: "target-features"
 // GFX601-NOT: "target-features"
@@ -26,5 +27,6 @@
 // GFX1011: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
 // GFX1012: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
 // GFX1030: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-3-insts,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
+// GFX1031: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-3-insts,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
 
 kernel void test() {}

diff  --git a/clang/test/Driver/amdgpu-macros.cl 
b/clang/test/Driver/amdgpu-macros.cl
index 24d2fead28d5e..ae46e85f94794 100644
--- a/clang/test/Driver/amdgpu-macros.cl
+++ b/clang/test/Driver/amdgpu-macros.cl
@@ -181,6 +181,7 @@
 // RUN: %clang -E -dM -target amdgcn -mcpu=gfx1011 %s 2>&1 | FileCheck 
--check-prefixes=ARCH-GCN,GFX1011 %s
 // 

LLVM buildmaster and LVM lab machines will be unavailable today at 6:00 pm PST

2020-08-05 Thread Galina Kistanova via cfe-commits
Hello everyone,


LLVM buildmaster and LVM lab machines will be unavailable today Wednesday,
August 5th at 6:00 pm PST due to Network maintenance.

The planned maintenance duration is 30 minutes.

Thank you for understanding.


Thanks


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


[PATCH] D85347: [WebAssembly] Fix types in wasm_simd128.h and add tests

2020-08-05 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
Herald added subscribers: cfe-commits, sunfish, jgravelle-google, sbc100, 
dschuff.
Herald added a project: clang.
tlively requested review of this revision.
Herald added a subscriber: aheejin.

47f7174ffa 
 changed 
the types used in the Wasm SIMD builtin functions,
but not all of their uses in wasm_simd128.h were updated. This commit
fixes wasm_simd128.h and adds tests to make sure similar problems do
not pass uncaught in the future.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85347

Files:
  clang/lib/Headers/wasm_simd128.h
  clang/test/Headers/wasm.c
  clang/test/Headers/wasm.cpp

Index: clang/test/Headers/wasm.cpp
===
--- /dev/null
+++ clang/test/Headers/wasm.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding %s -verify
+// expected-no-diagnostics
+
+#if defined(__wasm__) && defined(__wasm_simd128__)
+
+extern "C++" {
+#include 
+}
+
+#endif
Index: clang/test/Headers/wasm.c
===
--- /dev/null
+++ clang/test/Headers/wasm.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding %s -verify
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding -flax-vector-conversions=none %s -verify
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 -fsyntax-only -ffreestanding -x c++ %s -verify
+// expected-no-diagnostics
+
+#if defined(__wasm__) && defined(__wasm_simd128__)
+
+#include 
+
+#endif
Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -622,8 +622,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u8x16_add_saturate(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_add_saturate_u_i8x16((__i8x16)__a,
- (__i8x16)__b);
+  return (v128_t)__builtin_wasm_add_saturate_u_i8x16((__u8x16)__a,
+ (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_sub(v128_t __a,
@@ -640,7 +640,7 @@
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u8x16_sub_saturate(v128_t __a, v128_t __b) {
   return (v128_t)__builtin_wasm_sub_saturate_u_i8x16((__i8x16)__a,
- (__i8x16)__b);
+ (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min(v128_t __a,
@@ -650,7 +650,7 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_min(v128_t __a,
v128_t __b) {
-  return (v128_t)__builtin_wasm_min_u_i8x16((__i8x16)__a, (__i8x16)__b);
+  return (v128_t)__builtin_wasm_min_u_i8x16((__u8x16)__a, (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_max(v128_t __a,
@@ -660,12 +660,12 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_max(v128_t __a,
v128_t __b) {
-  return (v128_t)__builtin_wasm_max_u_i8x16((__i8x16)__a, (__i8x16)__b);
+  return (v128_t)__builtin_wasm_max_u_i8x16((__u8x16)__a, (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_avgr(v128_t __a,
 v128_t __b) {
-  return (v128_t)__builtin_wasm_avgr_u_i8x16((__i8x16)__a, (__i8x16)__b);
+  return (v128_t)__builtin_wasm_avgr_u_i8x16((__u8x16)__a, (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_abs(v128_t __a) {
@@ -712,8 +712,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u16x8_add_saturate(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_add_saturate_u_i16x8((__i16x8)__a,
- (__i16x8)__b);
+  return (v128_t)__builtin_wasm_add_saturate_u_i16x8((__u16x8)__a,
+ (__u16x8)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_sub(v128_t __a,
@@ -729,8 +729,8 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS
 wasm_u16x8_sub_saturate(v128_t __a, v128_t __b) {
-  return (v128_t)__builtin_wasm_sub_saturate_u_i16x8((__i16x8)__a,
- (__i16x8)__b);
+  return (v128_t)__builtin_wasm_sub_saturate_u_i16x8((__u16x8)__a,
+ (__u16x8)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_mul(v128_t __a,
@@ -745,7 +745,7 @@
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u16x8_min(v128_t __a,
   

[PATCH] D85330: [SyntaxTree] Extend the syntax tree dump

2020-08-05 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/lib/Tooling/Syntax/Tree.cpp:158
   if (!Marks.empty())
 OS << Marks << ": ";
 

Maybe the marks should be moved after the primary identifier of the node, WDYT? 
That would be more consistent with AST dump: first the node kind, then all its 
info.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85330/new/

https://reviews.llvm.org/D85330

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


[PATCH] D79744: clang: Use byref for aggregate kernel arguments

2020-08-05 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 283345.
arsenm added a comment.

Reword comment


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79744/new/

https://reviews.llvm.org/D79744

Files:
  clang/include/clang/CodeGen/CGFunctionInfo.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGenCUDA/kernel-args.cu
  clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl

Index: clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
+++ clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
@@ -67,7 +67,6 @@
 int i2;
 } struct_of_structs_arg_t;
 
-// CHECK: %union.transparent_u = type { i32 }
 typedef union
 {
   int b1;
@@ -237,7 +236,7 @@
 // CHECK: void @kernel_struct_of_structs_arg(%struct.struct_of_structs_arg %arg1.coerce)
 __kernel void kernel_struct_of_structs_arg(struct_of_structs_arg_t arg1) { }
 
-// CHECK: void @test_kernel_transparent_union_arg(%union.transparent_u %u.coerce)
+// CHECK: void @test_kernel_transparent_union_arg(i32 %u.coerce)
 __kernel void test_kernel_transparent_union_arg(transparent_u u) { }
 
 // CHECK: void @kernel_single_array_element_struct_arg(%struct.single_array_element_struct_arg %arg1.coerce)
Index: clang/test/CodeGenCUDA/kernel-args.cu
===
--- clang/test/CodeGenCUDA/kernel-args.cu
+++ clang/test/CodeGenCUDA/kernel-args.cu
@@ -8,14 +8,14 @@
   int a[32];
 };
 
-// AMDGCN: define amdgpu_kernel void @_Z6kernel1A(%struct.A %x.coerce)
+// AMDGCN: define amdgpu_kernel void @_Z6kernel1A(%struct.A addrspace(4)* byref(%struct.A) align 4 %{{.+}})
 // NVPTX: define void @_Z6kernel1A(%struct.A* byval(%struct.A) align 4 %x)
 __global__ void kernel(A x) {
 }
 
 class Kernel {
 public:
-  // AMDGCN: define amdgpu_kernel void @_ZN6Kernel12memberKernelE1A(%struct.A %x.coerce)
+  // AMDGCN: define amdgpu_kernel void @_ZN6Kernel12memberKernelE1A(%struct.A addrspace(4)* byref(%struct.A) align 4 %{{.+}})
   // NVPTX: define void @_ZN6Kernel12memberKernelE1A(%struct.A* byval(%struct.A) align 4 %x)
   static __global__ void memberKernel(A x){}
   template static __global__ void templateMemberKernel(T x) {}
@@ -29,11 +29,11 @@
 
 void test() {
   Kernel K;
-  // AMDGCN: define amdgpu_kernel void @_Z14templateKernelI1AEvT_(%struct.A %x.coerce)
+  // AMDGCN: define amdgpu_kernel void @_Z14templateKernelI1AEvT_(%struct.A addrspace(4)* byref(%struct.A) align 4 %{{.+}}
   // NVPTX: define void @_Z14templateKernelI1AEvT_(%struct.A* byval(%struct.A) align 4 %x)
   launch((void*)templateKernel);
 
-  // AMDGCN: define amdgpu_kernel void @_ZN6Kernel20templateMemberKernelI1AEEvT_(%struct.A %x.coerce)
+  // AMDGCN: define amdgpu_kernel void @_ZN6Kernel20templateMemberKernelI1AEEvT_(%struct.A addrspace(4)* byref(%struct.A) align 4 %{{.+}}
   // NVPTX: define void @_ZN6Kernel20templateMemberKernelI1AEEvT_(%struct.A* byval(%struct.A) align 4 %x)
   launch((void*)Kernel::templateMemberKernel);
 }
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -257,6 +257,11 @@
<< " ByVal=" << getIndirectByVal()
<< " Realign=" << getIndirectRealign();
 break;
+  case IndirectAliased:
+OS << "Indirect Align=" << getIndirectAlign().getQuantity()
+   << " AadrSpace=" << getIndirectAddrSpace()
+   << " Realign=" << getIndirectRealign();
+break;
   case Expand:
 OS << "Expand";
 break;
@@ -1989,6 +1994,7 @@
   case ABIArgInfo::InAlloca:
 return true;
   case ABIArgInfo::Ignore:
+  case ABIArgInfo::IndirectAliased:
 return false;
   case ABIArgInfo::Indirect:
   case ABIArgInfo::Direct:
@@ -8790,18 +8796,31 @@
 
   // TODO: Can we omit empty structs?
 
-  llvm::Type *LTy = nullptr;
   if (const Type *SeltTy = isSingleElementStruct(Ty, getContext()))
-LTy = CGT.ConvertType(QualType(SeltTy, 0));
+Ty = QualType(SeltTy, 0);
 
+  llvm::Type *OrigLTy = CGT.ConvertType(Ty);
+  llvm::Type *LTy = OrigLTy;
   if (getContext().getLangOpts().HIP) {
-if (!LTy)
-  LTy = CGT.ConvertType(Ty);
 LTy = coerceKernelArgumentType(
-LTy, /*FromAS=*/getContext().getTargetAddressSpace(LangAS::Default),
+OrigLTy, /*FromAS=*/getContext().getTargetAddressSpace(LangAS::Default),
 /*ToAS=*/getContext().getTargetAddressSpace(LangAS::cuda_device));
   }
 
+  // FIXME: Should also use this for OpenCL, but it requires addressing the
+  // problem of kernels being called.
+  //
+  // FIXME: This doesn't apply the optimization of coercing pointers in structs
+  // to global address space when using byref. This would require implementing a
+  // new kind of coercion of the in-memory type when for indirect arguments.
+  if (!getContext().getLangOpts().OpenCL && LTy == OrigLTy &&
+  isAggregateTypeForABI(Ty)) {
+

[PATCH] D84600: [Analyzer] Support note tags for smart ptr checker

2020-08-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:199
+} else {
+  const auto *TrackingExpr = getFirstArgExpr(Call);
+  C.addTransition(State, C.getNoteTag([ThisRegion, TrackingExpr](

xazax.hun wrote:
> I am a bit confused. As far as I understand we ALWAYS add the note tag below, 
> regardless of the first argument being null.
> I think I do understand that we only trigger this note tag when there is a 
> null dereference but consider the code below:
> 
> ```
> void f(int *p) {
>   std::unique_ptr u(p); // p is not always null here.
>   if (!p) {
> *u; // p is always null here
>   }
> }
> ```
> 
> Do we ant to output the message that the smart pointer is constructed using a 
> null value? While this is technically true, there is a later event in the 
> path that uncovers the fact that `p` is null.
> 
> @NoQ what do you think? I do not have any strong feelings about this, I only 
> wonder how users would react to a bug report like that.
Indeed, nice!! We can only proclaim the pointer to be null if it's known to be 
null in the current state. I.e., if previous steps of the report indicated that 
it's null. If it's discovered to be null later, we cannot call it null yet. I 
think we should check the current state and say "is constructed using a null 
value" if it's already null or simply "is constructed" if it's not yet known to 
be null.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84600/new/

https://reviews.llvm.org/D84600

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


[PATCH] D85287: Extend -Wtautological-bitwise-compare "bitwise or with non-zero value" warnings

2020-08-05 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose added a comment.

Nothing seems too mysterious here, but why limit to `constexpr` instead of 
anything where Clang can see a constant value, which would make it work in C as 
well? (If you're allowing `constexpr`, you're already allowing arbitrary work.)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85287/new/

https://reviews.llvm.org/D85287

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


[PATCH] D85252: [Driver] Accept -fno-lto in clang-cl

2020-08-05 Thread Arthur Eubanks via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8dc43852e4a8: [Driver] Accept -fno-lto in clang-cl (authored 
by aeubanks).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85252/new/

https://reviews.llvm.org/D85252

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -586,6 +586,9 @@
 // RUN: %clang_cl -### /c -flto -- %s 2>&1 | FileCheck -check-prefix=LTO %s
 // LTO: -flto
 
+// RUN: %clang_cl -### /c -flto -fno-lto -- %s 2>&1 | FileCheck 
-check-prefix=LTO-NO %s
+// LTO-NO-NOT: "-flto"
+
 // RUN: %clang_cl -### /c -flto=thin -- %s 2>&1 | FileCheck 
-check-prefix=LTO-THIN %s
 // LTO-THIN: -flto=thin
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1351,7 +1351,7 @@
   HelpText<"Set LTO mode to either 'full' or 'thin'">, Values<"thin,full">;
 def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Enable LTO in 'full' mode">;
-def fno_lto : Flag<["-"], "fno-lto">, Group,
+def fno_lto : Flag<["-"], "fno-lto">, Flags<[CoreOption, CC1Option]>, 
Group,
   HelpText<"Disable LTO mode (default)">;
 def flto_jobs_EQ : Joined<["-"], "flto-jobs=">,
   Flags<[CC1Option]>, Group,


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -586,6 +586,9 @@
 // RUN: %clang_cl -### /c -flto -- %s 2>&1 | FileCheck -check-prefix=LTO %s
 // LTO: -flto
 
+// RUN: %clang_cl -### /c -flto -fno-lto -- %s 2>&1 | FileCheck -check-prefix=LTO-NO %s
+// LTO-NO-NOT: "-flto"
+
 // RUN: %clang_cl -### /c -flto=thin -- %s 2>&1 | FileCheck -check-prefix=LTO-THIN %s
 // LTO-THIN: -flto=thin
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1351,7 +1351,7 @@
   HelpText<"Set LTO mode to either 'full' or 'thin'">, Values<"thin,full">;
 def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Enable LTO in 'full' mode">;
-def fno_lto : Flag<["-"], "fno-lto">, Group,
+def fno_lto : Flag<["-"], "fno-lto">, Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Disable LTO mode (default)">;
 def flto_jobs_EQ : Joined<["-"], "flto-jobs=">,
   Flags<[CC1Option]>, Group,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8dc4385 - [Driver] Accept -fno-lto in clang-cl

2020-08-05 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2020-08-05T12:24:10-07:00
New Revision: 8dc43852e4a8a5c6680d52aa6e73a75aef5a5954

URL: 
https://github.com/llvm/llvm-project/commit/8dc43852e4a8a5c6680d52aa6e73a75aef5a5954
DIFF: 
https://github.com/llvm/llvm-project/commit/8dc43852e4a8a5c6680d52aa6e73a75aef5a5954.diff

LOG: [Driver] Accept -fno-lto in clang-cl

Some compiler-rt tests check for the presence of the compiler accepting
-fno-lto to add that flag. Otherwise some tests don't link due to
-flto mismatch between compiling and linking.

$ cmake ... -DLLVM_ENABLE_LTO=Thin ...
$ ninja 
projects/compiler-rt/lib/sanitizer_common/tests/Sanitizer-x86_64-Test.exe
previously failed, now links.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D85252

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index fcb5c030755e..786a3c362842 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1351,7 +1351,7 @@ def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, 
CC1Option]>, Group, Values<"thin,full">;
 def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Enable LTO in 'full' mode">;
-def fno_lto : Flag<["-"], "fno-lto">, Group,
+def fno_lto : Flag<["-"], "fno-lto">, Flags<[CoreOption, CC1Option]>, 
Group,
   HelpText<"Disable LTO mode (default)">;
 def flto_jobs_EQ : Joined<["-"], "flto-jobs=">,
   Flags<[CC1Option]>, Group,

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index d0c48ae41d9a..bc4cab0f949f 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -586,6 +586,9 @@
 // RUN: %clang_cl -### /c -flto -- %s 2>&1 | FileCheck -check-prefix=LTO %s
 // LTO: -flto
 
+// RUN: %clang_cl -### /c -flto -fno-lto -- %s 2>&1 | FileCheck 
-check-prefix=LTO-NO %s
+// LTO-NO-NOT: "-flto"
+
 // RUN: %clang_cl -### /c -flto=thin -- %s 2>&1 | FileCheck 
-check-prefix=LTO-THIN %s
 // LTO-THIN: -flto=thin
 



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


[PATCH] D83338: [PowerPC][Power10] Implemented Vector Shift Builtins

2020-08-05 Thread Amy Kwan via Phabricator via cfe-commits
amyk added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1100
+
+if (Subtarget.isISA3_1()) {
+  setOperationAction(ISD::SRA, MVT::v1i128, Legal);

amyk wrote:
> No brackets are needed here.
> 
> Also, I think it might make sense to move this block into the previous 
> `hasP9Altivec` condition since in there it has:
> ```
>   setOperationAction(ISD::SHL, MVT::v1i128, Legal);
>   setOperationAction(ISD::SRL, MVT::v1i128, Legal);
> ```
Oops, I made that comment above since I thought you were putting the block 
inside a `hasP9Altivec` block. Sorry. 

Maybe you can move this condition right underneath the `hasP9Altivec` block 
that contains the `SHL/SRL` to be closer to those instructions. 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83338/new/

https://reviews.llvm.org/D83338

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


[PATCH] D85301: [clang-tidy] Fix crashes in bugprone-bad-signal-to-kill-thread check.

2020-08-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

while this patch fixes multiple issues (as described in the message), I'd 
suggest splitting it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85301/new/

https://reviews.llvm.org/D85301

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


[PATCH] D85319: [analyzer][RFC] Get info from the LLVM IR for precision

2020-08-05 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp:720
+  F->getAttributes().hasFnAttribute(llvm::Attribute::ReadOnly))
+return;
+

NoQ wrote:
> Before i forget: you still need to conjure the return value.
Good catch, thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85319/new/

https://reviews.llvm.org/D85319

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


[PATCH] D75181: [AArch64] Handle BTI/PAC in case of generated functions.

2020-08-05 Thread Momchil Velikov via Phabricator via cfe-commits
chill added a comment.

In D75181#2193447 , @danielkiss wrote:

> I don't see any other alternative option, I'm open to any other idea.

My original idea was to pass options to LLVM. I'll come up with a patch in a 
day or two (if it works) and then we'll see.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75181/new/

https://reviews.llvm.org/D75181

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


[clang-tools-extra] 618db68 - [clangd][NFC] Delete dead code in ExtractFunction code action

2020-08-05 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-08-05T21:14:39+02:00
New Revision: 618db6803d6c8b453abe6a1e92938ee20ac3aff6

URL: 
https://github.com/llvm/llvm-project/commit/618db6803d6c8b453abe6a1e92938ee20ac3aff6
DIFF: 
https://github.com/llvm/llvm-project/commit/618db6803d6c8b453abe6a1e92938ee20ac3aff6.diff

LOG: [clangd][NFC] Delete dead code in ExtractFunction code action

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
index dd62670646c4..895afbb116f1 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -480,17 +480,6 @@ CapturedZoneInfo captureZoneInfo(const ExtractionZone 
) {
 CurNumberOfSwitch += Increment;
 }
 
-// Decrement CurNumberOf{NestedLoops,Switch} if statement is {Loop,Switch}
-// and inside Extraction Zone.
-void decrementLoopSwitchCounters(Stmt *S) {
-  if (CurrentLocation != ZoneRelative::Inside)
-return;
-  if (isLoop(S))
-CurNumberOfNestedLoops--;
-  else if (isa(S))
-CurNumberOfSwitch--;
-}
-
 bool VisitDecl(Decl *D) {
   Info.createDeclInfo(D, CurrentLocation);
   return true;



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


[PATCH] D85113: [ABI][NFC] Fix the confusion of ByVal and ByRef argument names

2020-08-05 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85113/new/

https://reviews.llvm.org/D85113

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


[PATCH] D83325: [Sema] Be more thorough when unpacking the AS-qualified pointee for a pointer conversion.

2020-08-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

There's no way to do that, no.  Stripping sugar down to the point where you 
don't have that qualifier anymore is the best we can do.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83325/new/

https://reviews.llvm.org/D83325

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


[PATCH] D85315: [AIX][Clang] Add C++ linker option to the driver toolchain

2020-08-05 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:152
 
+  if (getToolChain().ShouldLinkCXXStdlib(Args))
+getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);

This is commonly added before `-lc`, etc. To be consistent with other targets, 
please switch the order of this block with the previous one.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:210
+  case ToolChain::CST_Libstdcxx:
+llvm_unreachable("linking libstdc++ unimplemented.");
+  }

Should this be a `report_fatal_error`? Note that the error message should not 
have a period at the end in that case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85315/new/

https://reviews.llvm.org/D85315

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


[PATCH] D85319: [analyzer] Get info from the LLVM IR for precision

2020-08-05 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D85319#2197104 , @rjmccall wrote:

> This seems a huge architectural change that we need to talk about.

Yes, sure. I am open to and welcome any discussions and suggestions. This patch 
is just a prototype to demonstrate the usability and feasibility. As @NoQ 
indicated there is a relevant discussion 
 in cfe-dev, 
maybe it's better to discuss there because of the bigger visibility.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85319/new/

https://reviews.llvm.org/D85319

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


[clang-tools-extra] d3ac301 - [clangd] Disable define out-of-line code action on templates

2020-08-05 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-08-05T20:57:28+02:00
New Revision: d3ac30188666b182daa87d23533543543b789e97

URL: 
https://github.com/llvm/llvm-project/commit/d3ac30188666b182daa87d23533543543b789e97
DIFF: 
https://github.com/llvm/llvm-project/commit/d3ac30188666b182daa87d23533543543b789e97.diff

LOG: [clangd] Disable define out-of-line code action on templates

Differential Revision: https://reviews.llvm.org/D85310

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
clang-tools-extra/clangd/unittests/TweakTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
index d37d37740799..9f68e248197e 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -122,9 +122,8 @@ getFunctionSourceAfterReplacements(const FunctionDecl *FD,
   if (!OrigFuncRange)
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"Couldn't get range for function.");
-  // Include template parameter list.
-  if (auto *FTD = FD->getDescribedFunctionTemplate())
-OrigFuncRange->setBegin(FTD->getBeginLoc());
+  assert(!FD->getDescribedFunctionTemplate() &&
+ "Define out-of-line doesn't apply to function templates.");
 
   // Get new begin and end positions for the qualified function definition.
   unsigned FuncBegin = SM.getFileOffset(OrigFuncRange->getBegin());
@@ -387,6 +386,13 @@ class DefineOutline : public Tweak {
 Source->isOutOfLine())
   return false;
 
+// Bail out if this is a function template or specialization, as their
+// definitions need to be visible in all including translation units.
+if (auto *PT = Source->getDescribedFunctionTemplate())
+  return false;
+if (auto *TSI = Source->getTemplateSpecializationInfo())
+  return false;
+
 // Bail out in templated classes, as it is hard to spell the class name, 
i.e
 // if the template parameter is unnamed.
 if (auto *MD = llvm::dyn_cast(Source)) {

diff  --git a/clang-tools-extra/clangd/unittests/TweakTests.cpp 
b/clang-tools-extra/clangd/unittests/TweakTests.cpp
index 791965160055..200a53c690b6 100644
--- a/clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2008,6 +2008,13 @@ TEST_F(DefineOutlineTest, TriggersOnFunctionDecl) {
   EXPECT_UNAVAILABLE(R"cpp(
 template  struct Foo { void fo^o(){} };
 )cpp");
+
+  // Not available on function templates and specializations, as definition 
must
+  // be visible to all translation units.
+  EXPECT_UNAVAILABLE(R"cpp(
+template  void fo^o() {};
+template <> void fo^o() {};
+  )cpp");
 }
 
 TEST_F(DefineOutlineTest, FailsWithoutSource) {
@@ -2037,27 +2044,6 @@ TEST_F(DefineOutlineTest, ApplyTest) {
   "void foo() ;",
   "void foo() { return; }",
   },
-  // Templated function.
-  {
-  "template  void fo^o(T, T x) { return; }",
-  "template  void foo(T, T x) ;",
-  "template  void foo(T, T x) { return; }",
-  },
-  {
-  "template  void fo^o() { return; }",
-  "template  void foo() ;",
-  "template  void foo() { return; }",
-  },
-  // Template specialization.
-  {
-  R"cpp(
-template  void foo();
-template <> void fo^o() { return; })cpp",
-  R"cpp(
-template  void foo();
-template <> void foo() ;)cpp",
-  "template <> void foo() { return; }",
-  },
   // Default args.
   {
   "void fo^o(int x, int y = 5, int = 2, int (*foo)(int) = nullptr) {}",



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


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-08-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I thought part of the point of `__builtin_memcpy` was so that C library headers 
could do `#define memcpy(x, y, z) __builtin_memcpy(x, y, z)`.  If so, the 
conformance issue touches `__builtin_memcpy` as well, not just calls to the 
library builtin.

If that's not true, or if we're willing to ignore it, I agree that making 
`__builtin_memcpy` do the right thing for qualifiers in general is the right 
thing to do.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79279/new/

https://reviews.llvm.org/D79279

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


[PATCH] D85310: [clangd] Disable define out-of-line code action on templates

2020-08-05 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd3ac30188666: [clangd] Disable define out-of-line code 
action on templates (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85310/new/

https://reviews.llvm.org/D85310

Files:
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2008,6 +2008,13 @@
   EXPECT_UNAVAILABLE(R"cpp(
 template  struct Foo { void fo^o(){} };
 )cpp");
+
+  // Not available on function templates and specializations, as definition 
must
+  // be visible to all translation units.
+  EXPECT_UNAVAILABLE(R"cpp(
+template  void fo^o() {};
+template <> void fo^o() {};
+  )cpp");
 }
 
 TEST_F(DefineOutlineTest, FailsWithoutSource) {
@@ -2037,27 +2044,6 @@
   "void foo() ;",
   "void foo() { return; }",
   },
-  // Templated function.
-  {
-  "template  void fo^o(T, T x) { return; }",
-  "template  void foo(T, T x) ;",
-  "template  void foo(T, T x) { return; }",
-  },
-  {
-  "template  void fo^o() { return; }",
-  "template  void foo() ;",
-  "template  void foo() { return; }",
-  },
-  // Template specialization.
-  {
-  R"cpp(
-template  void foo();
-template <> void fo^o() { return; })cpp",
-  R"cpp(
-template  void foo();
-template <> void foo() ;)cpp",
-  "template <> void foo() { return; }",
-  },
   // Default args.
   {
   "void fo^o(int x, int y = 5, int = 2, int (*foo)(int) = nullptr) {}",
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -122,9 +122,8 @@
   if (!OrigFuncRange)
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"Couldn't get range for function.");
-  // Include template parameter list.
-  if (auto *FTD = FD->getDescribedFunctionTemplate())
-OrigFuncRange->setBegin(FTD->getBeginLoc());
+  assert(!FD->getDescribedFunctionTemplate() &&
+ "Define out-of-line doesn't apply to function templates.");
 
   // Get new begin and end positions for the qualified function definition.
   unsigned FuncBegin = SM.getFileOffset(OrigFuncRange->getBegin());
@@ -387,6 +386,13 @@
 Source->isOutOfLine())
   return false;
 
+// Bail out if this is a function template or specialization, as their
+// definitions need to be visible in all including translation units.
+if (auto *PT = Source->getDescribedFunctionTemplate())
+  return false;
+if (auto *TSI = Source->getTemplateSpecializationInfo())
+  return false;
+
 // Bail out in templated classes, as it is hard to spell the class name, 
i.e
 // if the template parameter is unnamed.
 if (auto *MD = llvm::dyn_cast(Source)) {


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2008,6 +2008,13 @@
   EXPECT_UNAVAILABLE(R"cpp(
 template  struct Foo { void fo^o(){} };
 )cpp");
+
+  // Not available on function templates and specializations, as definition must
+  // be visible to all translation units.
+  EXPECT_UNAVAILABLE(R"cpp(
+template  void fo^o() {};
+template <> void fo^o() {};
+  )cpp");
 }
 
 TEST_F(DefineOutlineTest, FailsWithoutSource) {
@@ -2037,27 +2044,6 @@
   "void foo() ;",
   "void foo() { return; }",
   },
-  // Templated function.
-  {
-  "template  void fo^o(T, T x) { return; }",
-  "template  void foo(T, T x) ;",
-  "template  void foo(T, T x) { return; }",
-  },
-  {
-  "template  void fo^o() { return; }",
-  "template  void foo() ;",
-  "template  void foo() { return; }",
-  },
-  // Template specialization.
-  {
-  R"cpp(
-template  void foo();
-template <> void fo^o() { return; })cpp",
-  R"cpp(
-template  void foo();
-template <> void foo() ;)cpp",
-  "template <> void foo() { return; }",
-  },
   // Default args.
   {
   "void fo^o(int x, int y = 5, int = 2, int (*foo)(int) = nullptr) {}",
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp

[PATCH] D85319: [analyzer] Get info from the LLVM IR for precision

2020-08-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Thanks.  It'd be a good idea to mention that this is contingent on that 
discussion in the patch summary.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85319/new/

https://reviews.llvm.org/D85319

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


[PATCH] D85319: [analyzer] Get info from the LLVM IR for precision

2020-08-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D85319#2197104 , @rjmccall wrote:

> This seems a huge architectural change that we need to talk about.

Absolutely.

I believe the relevant discussion is at 
http://lists.llvm.org/pipermail/cfe-dev/2020-August/066426.html.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85319/new/

https://reviews.llvm.org/D85319

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


[PATCH] D79744: clang: Use byref for aggregate kernel arguments

2020-08-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:8816
+  // FIXME: Should use byref when promoting pointers in structs, but this
+  // requires adding implementing the coercion.
+  if (!getContext().getLangOpts().OpenCL && LTy == OrigLTy &&

arsenm wrote:
> rjmccall wrote:
> > arsenm wrote:
> > > rjmccall wrote:
> > > > I don't see why you'd use `byref` when promoting pointers in structs.  
> > > > Maybe it works as a hack with your backend, but it seems *extremely* 
> > > > special-case and should not be hacked into the general infrastructure.
> > > The whole point is to reinterpret the address space of the pointers in 
> > > memory since we know if it's a kernel argument it has to be an 
> > > addrspace(1) pointer or garbage. We can't infer the address space of a 
> > > generic pointer loaded from memory.
> > > 
> > > byref doesn't change that, it just makes the fact that these are passed 
> > > in memory explicit
> > `byref` is interpreted by your backend passes as an instruction that the 
> > argument value is actually the address of an object that's passed to the 
> > kernel by value, so you need to expand the memory in the kernel argument 
> > marshalling.  Why would that be something you'd want to trigger when 
> > passing a struct with a pointer in it?  You're not going to recursively 
> > copy and pass down the pointee values of those pointers.
> Because all arguments are really passed byref, we're just not at the point 
> yet where we can switch all IR arguments to use byref for all arguments. All 
> of the relevant properties are really always on the in-memory value. 
> 
> The promotion this is talking about is really orthogonal to the IR mechanism 
> used for passing kernel arguments. This promotion is because the language 
> only exposes generic pointers. In the context of a pointer inside a struct 
> passed as a kernel argument, we semantically know the address space of any 
> valid pointers must be global. You could not produce a valid generic pointer 
> from another address space here. The pointers/structs are still the same size 
> and layout, but coercing the in-memory address space is semantically more 
> useful to the optimizer
I understand that the promotion is orthogonal to the IR mechanism used for 
passing kernel arguments, which is exactly why I'm asking why there's a comment 
saying that we should "use byref when promoting pointers in struct", because I 
have no idea what that's supposed to mean when the pointer is just a part of 
the value being passed.

It sounds like what you want is to maybe customize the code that's emitted to 
copy a byref parameter into a parameter variable when the parameter type is a 
struct containing a pointer you want to promote.  But that doesn't really have 
anything to do with `byref`; if you weren't using `byref`, you'd still want a 
similar customization when creating the parameter variable.  So it seems to me 
that the comment is still off-target.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79744/new/

https://reviews.llvm.org/D79744

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


[PATCH] D85319: [analyzer] Get info from the LLVM IR for precision

2020-08-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp:720
+  F->getAttributes().hasFnAttribute(llvm::Attribute::ReadOnly))
+return;
+

Before i forget: you still need to conjure the return value.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85319/new/

https://reviews.llvm.org/D85319

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


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-08-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Two observations that are new to me in this review:

1. We already treat all builtins as being overloaded on address space.
2. The revised patch treats `__builtin_mem*_overloaded` as being overloaded 
*only* on address space, volatility, and atomicity. (We've tuned the design to 
a point where the other qualifiers don't matter any more.)

So, we're adding three features here: overloading on (a) address space, (b) 
volatility, and (c) atomicity. (a) is already available in the 
non-`_overloaded` form, and we seem to be approaching agreement that (b) should 
be available in the non-`_overloaded` form too. So that only leaves (c), which 
is really not `_overloaded` but `_atomic`.

Based on those observations I'm now thinking that we might prefer a somewhat 
different approach (but one that should require only minimal changes to the 
patch in front of us). Specifically:

1. Stop treating lib builtins (eg, plain `memcpy`) as overloaded on address 
space. That's a (pre-existing) conformance bug, at least for the Embedded C TR.
2. Keep `__builtin_` forms of lib builtins overloaded on address space. (No 
change.)
3. Also overload `__builtin_` forms of lib builtins on volatility where it 
makes sense, instead of adding new builtin names `__builtin_mem*_overloaded`.
4. Add a new name for the builtin for the atomic forms of `memcpy` and `memset` 
(`__builtin_memcpy_unordered_atomic` maybe?).
5. Convert the "trivial types" check from an error to a warning and apply it to 
all the mem* overloads. (Though I think we might actually already have such a 
check, so this might only require extending it to cover the atomic builtin.)

What do you think?




Comment at: clang/docs/LanguageExtensions.rst:2434
+* ``volatile``
+* ``restrict``
+* ``__unaligned``

Does `restrict` really make sense here? It seems like the only difference it 
could possibly make would be to treat `memcpy` as `memmove` if either operand 
is marked restrict, but
(a) if the caller wants that, they can just use `memcpy` directly, and
(b) it's not correct to propagate restrict-ness from the caller to the callee 
anyway, because restrict-ness is really a property of the declaration of the 
identifier in its scope, not a property of its type:
```
void f(void *restrict p) {
  __builtin_memmove(p, p + 1, 4);
}
```
(c) a restrict qualifier on the pointee type is irrelevant to memcpy and a 
restrict qualifier on the pointer type isn't part of QUAL.



Comment at: clang/docs/LanguageExtensions.rst:2435
+* ``restrict``
+* ``__unaligned``
+* non-default address spaces

I don't think ``__unaligned`` matters any more. We always take the actual 
alignment inferred from the pointer arguments, just like we do for 
non-overloaded `memcpy`.



Comment at: clang/docs/LanguageExtensions.rst:2455-2456
+
+The overloaded builtins expect both destination and source to be trivially
+copyable types.
+





Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2639-2640
   case Builtin::BI__builtin_mempcpy: {
+QualType DestTy = getPtrArgType(CGM, E, 0);
+QualType SrcTy = getPtrArgType(CGM, E, 1);
 Address Dest = EmitPointerWithAlignment(E->getArg(0));

jfb wrote:
> rsmith wrote:
> > jfb wrote:
> > > rsmith wrote:
> > > > Looking through implicit conversions in `getPtrArgType` here will 
> > > > change the code we generate for cases like:
> > > > 
> > > > ```
> > > > void f(volatile void *p, volatile void *q) {
> > > >   memcpy(p, q, 4);
> > > > }
> > > > ```
> > > > 
> > > > ... (in C, where we permit such implicit conversions) to use a volatile 
> > > > memcpy intrinsic. Is that an intentional change?
> > > I'm confused... what's the difference that this makes for the 
> > > pre-existing builtins? My intent was to get the `QualType` 
> > > unconditionally, but I can conditionalize it if needed... However this 
> > > ought to make no difference:
> > > ```
> > > static QualType getPtrArgType(CodeGenModule , const CallExpr *E,
> > >   unsigned ArgNo) {
> > >   QualType ArgTy = E->getArg(ArgNo)->IgnoreImpCasts()->getType();
> > >   if (ArgTy->isArrayType())
> > > return CGM.getContext().getAsArrayType(ArgTy)->getElementType();
> > >   if (ArgTy->isObjCObjectPointerType())
> > > return 
> > > ArgTy->castAs()->getPointeeType();
> > >   return ArgTy->castAs()->getPointeeType();
> > > }
> > > ```
> > > and indeed I can't see the example you provided change in IR from one to 
> > > the other. The issue I'm working around is that getting it 
> > > unconditionally would make ObjC code sad when `id` is passed in as I 
> > > outlined above.
> > The example I gave should produce a non-volatile memcpy, and used to do so 
> > (we passed `false` as the fourth parameter to `CreateMemCpy`). With this 
> > patch, `getPtrArgType`will strip off the implicit conversion from `volatile 
> > void*` to `void*` in the 

[PATCH] D84979: [analyzer][NFC] Refine CStringLength modeling API

2020-08-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker/CStringLength.h:42
+LLVM_NODISCARD Optional
+getCStringLength(CheckerContext , const ProgramStateRef , SVal Buf);
+

Just pass by value then. It's already a "Ref".



Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker/CStringLength.h:50
+
+LLVM_DUMP_METHOD void dumpCStringLengths(const ProgramStateRef State,
  raw_ostream  = llvm::errs(),

This `const` does nothing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84979/new/

https://reviews.llvm.org/D84979

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


[PATCH] D79744: clang: Use byref for aggregate kernel arguments

2020-08-05 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:8816
+  // FIXME: Should use byref when promoting pointers in structs, but this
+  // requires adding implementing the coercion.
+  if (!getContext().getLangOpts().OpenCL && LTy == OrigLTy &&

rjmccall wrote:
> arsenm wrote:
> > rjmccall wrote:
> > > I don't see why you'd use `byref` when promoting pointers in structs.  
> > > Maybe it works as a hack with your backend, but it seems *extremely* 
> > > special-case and should not be hacked into the general infrastructure.
> > The whole point is to reinterpret the address space of the pointers in 
> > memory since we know if it's a kernel argument it has to be an addrspace(1) 
> > pointer or garbage. We can't infer the address space of a generic pointer 
> > loaded from memory.
> > 
> > byref doesn't change that, it just makes the fact that these are passed in 
> > memory explicit
> `byref` is interpreted by your backend passes as an instruction that the 
> argument value is actually the address of an object that's passed to the 
> kernel by value, so you need to expand the memory in the kernel argument 
> marshalling.  Why would that be something you'd want to trigger when passing 
> a struct with a pointer in it?  You're not going to recursively copy and pass 
> down the pointee values of those pointers.
Because all arguments are really passed byref, we're just not at the point yet 
where we can switch all IR arguments to use byref for all arguments. All of the 
relevant properties are really always on the in-memory value. 

The promotion this is talking about is really orthogonal to the IR mechanism 
used for passing kernel arguments. This promotion is because the language only 
exposes generic pointers. In the context of a pointer inside a struct passed as 
a kernel argument, we semantically know the address space of any valid pointers 
must be global. You could not produce a valid generic pointer from another 
address space here. The pointers/structs are still the same size and layout, 
but coercing the in-memory address space is semantically more useful to the 
optimizer


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79744/new/

https://reviews.llvm.org/D79744

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


[PATCH] D85319: [analyzer] Get info from the LLVM IR for precision

2020-08-05 Thread John McCall via Phabricator via cfe-commits
rjmccall requested changes to this revision.
rjmccall added a comment.
This revision now requires changes to proceed.

This seems a huge architectural change that we need to talk about.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85319/new/

https://reviews.llvm.org/D85319

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


[clang] 7ad60f6 - [clang-format] fix BreakBeforeBraces.MultiLine with for each macros

2020-08-05 Thread Mitchell Balan via cfe-commits

Author: Mitchell Balan
Date: 2020-08-05T14:31:42-04:00
New Revision: 7ad60f6452ff483912776ef6eda4e28c60d9da6e

URL: 
https://github.com/llvm/llvm-project/commit/7ad60f6452ff483912776ef6eda4e28c60d9da6e
DIFF: 
https://github.com/llvm/llvm-project/commit/7ad60f6452ff483912776ef6eda4e28c60d9da6e.diff

LOG: [clang-format] fix BreakBeforeBraces.MultiLine with for each macros
Summary:
The MultiLine option in BreakBeforeBraces was only handling standard
control statement, leading to invalid indentation with for each macros:

Previous behavior:

/* invalid: brace should be on the same line */
Q_FOREACH(int a; list)
{
foo();
}

/* valid */
Q_FOREACH(int longVariable;
  list)
{
foo();
}

To fix this, simply add the TT_ForEachMacro kind in the list of
recognized control statements for the multiline option.

This is a fix for https://bugs.llvm.org/show_bug.cgi?id=44632

Reviewers: MyDeveloperDay, mitchell-stellar

Reviewed by: mitchell-stellar

Contributed by: vthib

Subscribers: cfe-commits

Tags: #clang, #clang-format, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D85304

Added: 


Modified: 
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index ec0c628fe750..d8f718306a45 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -309,7 +309,8 @@ class LineJoiner {
 // Try to merge a control statement block with left brace wrapped
 if (I[1]->First->is(tok::l_brace) &&
 (TheLine->First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_for,
- tok::kw_switch, tok::kw_try, tok::kw_do) ||
+ tok::kw_switch, tok::kw_try, tok::kw_do,
+ TT_ForEachMacro) ||
  (TheLine->First->is(tok::r_brace) && TheLine->First->Next &&
   TheLine->First->Next->isOneOf(tok::kw_else, tok::kw_catch))) &&
 Style.BraceWrapping.AfterControlStatement ==

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 83dd5bbba911..d8642062fb6f 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -1663,6 +1663,20 @@ TEST_F(FormatTest, MultiLineControlStatements) {
 "  foo();\n"
 "}",
 format("for(int i=0;i<10;++i){foo();}", Style));
+  EXPECT_EQ("foreach (int i,\n"
+" list)\n"
+"{\n"
+"  foo();\n"
+"}",
+format("foreach(int i, list){foo();}", Style));
+  Style.ColumnLimit =
+  40; // to concentrate at brace wrapping, not line wrap due to column 
limit
+  EXPECT_EQ("foreach (int i, list) {\n"
+"  foo();\n"
+"}",
+format("foreach(int i, list){foo();}", Style));
+  Style.ColumnLimit =
+  20; // to concentrate at brace wrapping, not line wrap due to column 
limit
   EXPECT_EQ("while (foo || bar ||\n"
 "   baz)\n"
 "{\n"



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


[PATCH] D85304: [clang-format] fix BreakBeforeBraces.MultiLine with for each macros

2020-08-05 Thread Mitchell via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7ad60f6452ff: [clang-format] fix BreakBeforeBraces.MultiLine 
with for each macros (authored by mitchell-stellar).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85304/new/

https://reviews.llvm.org/D85304

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1663,6 +1663,20 @@
 "  foo();\n"
 "}",
 format("for(int i=0;i<10;++i){foo();}", Style));
+  EXPECT_EQ("foreach (int i,\n"
+" list)\n"
+"{\n"
+"  foo();\n"
+"}",
+format("foreach(int i, list){foo();}", Style));
+  Style.ColumnLimit =
+  40; // to concentrate at brace wrapping, not line wrap due to column 
limit
+  EXPECT_EQ("foreach (int i, list) {\n"
+"  foo();\n"
+"}",
+format("foreach(int i, list){foo();}", Style));
+  Style.ColumnLimit =
+  20; // to concentrate at brace wrapping, not line wrap due to column 
limit
   EXPECT_EQ("while (foo || bar ||\n"
 "   baz)\n"
 "{\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -309,7 +309,8 @@
 // Try to merge a control statement block with left brace wrapped
 if (I[1]->First->is(tok::l_brace) &&
 (TheLine->First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_for,
- tok::kw_switch, tok::kw_try, tok::kw_do) ||
+ tok::kw_switch, tok::kw_try, tok::kw_do,
+ TT_ForEachMacro) ||
  (TheLine->First->is(tok::r_brace) && TheLine->First->Next &&
   TheLine->First->Next->isOneOf(tok::kw_else, tok::kw_catch))) &&
 Style.BraceWrapping.AfterControlStatement ==


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1663,6 +1663,20 @@
 "  foo();\n"
 "}",
 format("for(int i=0;i<10;++i){foo();}", Style));
+  EXPECT_EQ("foreach (int i,\n"
+" list)\n"
+"{\n"
+"  foo();\n"
+"}",
+format("foreach(int i, list){foo();}", Style));
+  Style.ColumnLimit =
+  40; // to concentrate at brace wrapping, not line wrap due to column limit
+  EXPECT_EQ("foreach (int i, list) {\n"
+"  foo();\n"
+"}",
+format("foreach(int i, list){foo();}", Style));
+  Style.ColumnLimit =
+  20; // to concentrate at brace wrapping, not line wrap due to column limit
   EXPECT_EQ("while (foo || bar ||\n"
 "   baz)\n"
 "{\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -309,7 +309,8 @@
 // Try to merge a control statement block with left brace wrapped
 if (I[1]->First->is(tok::l_brace) &&
 (TheLine->First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_for,
- tok::kw_switch, tok::kw_try, tok::kw_do) ||
+ tok::kw_switch, tok::kw_try, tok::kw_do,
+ TT_ForEachMacro) ||
  (TheLine->First->is(tok::r_brace) && TheLine->First->Next &&
   TheLine->First->Next->isOneOf(tok::kw_else, tok::kw_catch))) &&
 Style.BraceWrapping.AfterControlStatement ==
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-08-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:2446
+order in which they occur (and in which they are observable) can only be
+guaranteed using appropriate fences around the function call. Element size must
+therefore be a lock-free size for the target architecture. It is a runtime

jfb wrote:
> rjmccall wrote:
> > "*The* element size must..."  But I would suggest using "access size" 
> > consistently rather than "element size".
> I'm being consistent with the naming for IR, which uses "element" as well. 
> I'm not enamored with the naming, but wanted to point out the purposeful 
> consistency to make sure you preferred "access size". Without precedent I 
> would indeed prefer "access size", but have a slight preference for 
> consistency here. This is extremely weakly held preference.
> 
> (I fixed "the").
IR naming is generally random fluff plucked from the mind of an inspired 
compiler engineer.  User documentation is the point where we're supposed to put 
our bad choices behind us and do something that makes sense to users. :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79279/new/

https://reviews.llvm.org/D79279

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


[PATCH] D79744: clang: Use byref for aggregate kernel arguments

2020-08-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:1997
   case ABIArgInfo::Ignore:
+  case ABIArgInfo::IndirectAliased:
 return false;

arsenm wrote:
> arsenm wrote:
> > rjmccall wrote:
> > > arsenm wrote:
> > > > rjmccall wrote:
> > > > > In principle, this can be `inreg` just as much as Indirect can.
> > > > The IR verifier currently will reject byref + inreg
> > > Why?  `inreg` is essentially orthogonal.
> > Mostly inherited from the other similar attribute handling. It can be 
> > lifted if there's a use
> Plus the name here is isArgInAlloca; this is not necessarily passed in an 
> alloca
I agree that we don't need to update this.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:8816
+  // FIXME: Should use byref when promoting pointers in structs, but this
+  // requires adding implementing the coercion.
+  if (!getContext().getLangOpts().OpenCL && LTy == OrigLTy &&

arsenm wrote:
> rjmccall wrote:
> > I don't see why you'd use `byref` when promoting pointers in structs.  
> > Maybe it works as a hack with your backend, but it seems *extremely* 
> > special-case and should not be hacked into the general infrastructure.
> The whole point is to reinterpret the address space of the pointers in memory 
> since we know if it's a kernel argument it has to be an addrspace(1) pointer 
> or garbage. We can't infer the address space of a generic pointer loaded from 
> memory.
> 
> byref doesn't change that, it just makes the fact that these are passed in 
> memory explicit
`byref` is interpreted by your backend passes as an instruction that the 
argument value is actually the address of an object that's passed to the kernel 
by value, so you need to expand the memory in the kernel argument marshalling.  
Why would that be something you'd want to trigger when passing a struct with a 
pointer in it?  You're not going to recursively copy and pass down the pointee 
values of those pointers.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79744/new/

https://reviews.llvm.org/D79744

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


[PATCH] D85330: [SyntaxTree] Extend the syntax tree dump

2020-08-05 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 283305.
eduucaldas added a comment.

Rollback strOfLeaf


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85330/new/

https://reviews.llvm.org/D85330

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -159,7 +159,8 @@
  << "Source file has syntax errors, they were printed to the test "
 "log";
 }
-std::string Actual = std::string(StringRef(Root->dump(*Arena)).trim());
+std::string Actual =
+std::string(StringRef(Root->dump(Arena->sourceManager())).trim());
 // EXPECT_EQ shows the diff between the two strings if they are different.
 EXPECT_EQ(Tree.trim().str(), Actual);
 if (Actual != Tree.trim().str()) {
Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -135,46 +135,46 @@
 }
 
 namespace {
-static void dumpTokens(llvm::raw_ostream , ArrayRef Tokens,
-   const SourceManager ) {
-  assert(!Tokens.empty());
-  bool First = true;
-  for (const auto  : Tokens) {
-if (!First)
-  OS << " ";
-else
-  First = false;
-// Handle 'eof' separately, calling text() on it produces an empty string.
-if (T.kind() == tok::eof) {
-  OS << "";
-  continue;
-}
-OS << T.text(SM);
-  }
+static void dumpLeaf(llvm::raw_ostream , const syntax::Leaf *L,
+ const SourceManager ) {
+  assert(L);
+  const auto *Token = L->token();
+  assert(Token);
+  // Handle 'eof' separately, calling text() on it produces an empty string.
+  if (Token->kind() == tok::eof)
+OS << "";
+  else
+OS << Token->text(SM);
 }
 
-static void dumpTree(llvm::raw_ostream , const syntax::Node *N,
- const syntax::Arena , std::vector IndentMask) {
+static void dumpNode(llvm::raw_ostream , const syntax::Node *N,
+ const SourceManager , std::vector IndentMask) {
   std::string Marks;
   if (!N->isOriginal())
 Marks += "M";
-  if (N->role() == syntax::NodeRole::Detached)
-Marks += "*"; // FIXME: find a nice way to print other roles.
   if (!N->canModify())
 Marks += "I";
   if (!Marks.empty())
 OS << Marks << ": ";
 
   if (auto *L = llvm::dyn_cast(N)) {
-dumpTokens(OS, *L->token(), A.sourceManager());
+OS << "'";
+dumpLeaf(OS, L, SM);
+OS << "'";
+if (L->role() != syntax::NodeRole::Unknown)
+  OS << " " << L->role();
 OS << "\n";
 return;
   }
 
   auto *T = llvm::cast(N);
-  OS << T->kind() << "\n";
+  OS << T->kind();
+  if (T->role() != syntax::NodeRole::Unknown)
+OS << " " << T->role();
+  OS << "\n";
 
-  for (auto It = T->firstChild(); It != nullptr; It = It->nextSibling()) {
+  for (const auto *It = T->firstChild(); It != nullptr;
+   It = It->nextSibling()) {
 for (bool Filled : IndentMask) {
   if (Filled)
 OS << "| ";
@@ -188,28 +188,27 @@
   OS << "|-";
   IndentMask.push_back(true);
 }
-dumpTree(OS, It, A, IndentMask);
+dumpNode(OS, It, SM, IndentMask);
 IndentMask.pop_back();
   }
 }
 } // namespace
 
-std::string syntax::Node::dump(const Arena ) const {
+std::string syntax::Node::dump(const SourceManager ) const {
   std::string Str;
   llvm::raw_string_ostream OS(Str);
-  dumpTree(OS, this, A, /*IndentMask=*/{});
+  dumpNode(OS, this, SM, /*IndentMask=*/{});
   return std::move(OS.str());
 }
 
-std::string syntax::Node::dumpTokens(const Arena ) const {
+std::string syntax::Node::dumpTokens(const SourceManager ) const {
   std::string Storage;
   llvm::raw_string_ostream OS(Storage);
   traverse(this, [&](const syntax::Node *N) {
-auto *L = llvm::dyn_cast(N);
-if (!L)
-  return;
-::dumpTokens(OS, *L->token(), A.sourceManager());
-OS << " ";
+if (auto *L = llvm::dyn_cast(N)) {
+  dumpLeaf(OS, L, SM);
+  OS << " ";
+}
   });
   return OS.str();
 }
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -526,7 +526,7 @@
 R += std::string(llvm::formatv(
 "- '{0}' covers '{1}'+{2} tokens\n", It->second->kind(),
 It->first->text(A.sourceManager()), CoveredTokens));
-R += It->second->dump(A);
+R += It->second->dump(A.sourceManager());
   }
   return R;
 }
Index: clang/include/clang/Tooling/Syntax/Tree.h
===
--- 

[PATCH] D85304: [clang-format] fix BreakBeforeBraces.MultiLine with for each macros

2020-08-05 Thread Mitchell via Phabricator via cfe-commits
mitchell-stellar accepted this revision.
mitchell-stellar added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85304/new/

https://reviews.llvm.org/D85304

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


[PATCH] D85318: [clangd] Hide "swap if branch" tweak

2020-08-05 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9a7b8b22a75c: [clangd] Hide swap if branch tweak 
(authored by hokein).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85318/new/

https://reviews.llvm.org/D85318

Files:
  clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp


Index: clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
@@ -40,6 +40,7 @@
   Expected apply(const Selection ) override;
   std::string title() const override { return "Swap if branches"; }
   Intent intent() const override { return Refactor; }
+  bool hidden() const override { return true; }
 
 private:
   const IfStmt *If = nullptr;


Index: clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
@@ -40,6 +40,7 @@
   Expected apply(const Selection ) override;
   std::string title() const override { return "Swap if branches"; }
   Intent intent() const override { return Refactor; }
+  bool hidden() const override { return true; }
 
 private:
   const IfStmt *If = nullptr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 9a7b8b2 - [clangd] Hide "swap if branch" tweak

2020-08-05 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-08-05T20:03:21+02:00
New Revision: 9a7b8b22a75c4b5a065775a75a6a3dd2718ac970

URL: 
https://github.com/llvm/llvm-project/commit/9a7b8b22a75c4b5a065775a75a6a3dd2718ac970
DIFF: 
https://github.com/llvm/llvm-project/commit/9a7b8b22a75c4b5a065775a75a6a3dd2718ac970.diff

LOG: [clangd] Hide "swap if branch" tweak

This tweak is more like a demo, and doesn't provide much value in
practice.

Differential Revision: https://reviews.llvm.org/D85318

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
index 2422743019a1..d6966e699fdb 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
@@ -40,6 +40,7 @@ class SwapIfBranches : public Tweak {
   Expected apply(const Selection ) override;
   std::string title() const override { return "Swap if branches"; }
   Intent intent() const override { return Refactor; }
+  bool hidden() const override { return true; }
 
 private:
   const IfStmt *If = nullptr;



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


[clang] 2143a90 - Fix _ExtInt(1) to be a i1 in memory.

2020-08-05 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2020-08-05T10:54:51-07:00
New Revision: 2143a90b34a7846369127e762cec5917d5e1a5bd

URL: 
https://github.com/llvm/llvm-project/commit/2143a90b34a7846369127e762cec5917d5e1a5bd
DIFF: 
https://github.com/llvm/llvm-project/commit/2143a90b34a7846369127e762cec5917d5e1a5bd.diff

LOG: Fix _ExtInt(1) to be a i1 in memory.

The _ExtInt(1) in getTypeForMem was hitting the bool logic for expanding
to an 8 bit value.  The result was an assert, or store i1 %0, i8* %2, align 1
since the parameter IS an i1.  This patch changes the 'forMem' test to
exclude ext-int from the bool test.

Added: 


Modified: 
clang/lib/CodeGen/CodeGenTypes.cpp
clang/test/CodeGen/ext-int.c

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenTypes.cpp 
b/clang/lib/CodeGen/CodeGenTypes.cpp
index d431c0263666..cad63fee4570 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -93,7 +93,8 @@ llvm::Type *CodeGenTypes::ConvertTypeForMem(QualType T, bool 
ForBitField) {
 
   // If this is a bool type, or an ExtIntType in a bitfield representation,
   // map this integer to the target-specified size.
-  if ((ForBitField && T->isExtIntType()) || R->isIntegerTy(1))
+  if ((ForBitField && T->isExtIntType()) ||
+  (!T->isExtIntType() && R->isIntegerTy(1)))
 return llvm::IntegerType::get(getLLVMContext(),
   (unsigned)Context.getTypeSize(T));
 

diff  --git a/clang/test/CodeGen/ext-int.c b/clang/test/CodeGen/ext-int.c
index 196bb810b61a..d8e763283bfd 100644
--- a/clang/test/CodeGen/ext-int.c
+++ b/clang/test/CodeGen/ext-int.c
@@ -45,3 +45,16 @@ void OffsetOfTest() {
   // LIN32: store i32 2097156, i32* %{{.+}}
   // WIN32: store i32 2097160, i32* %{{.+}}
 }
+
+void Size1ExtIntParam(unsigned _ExtInt(1) A) {
+  // CHECK: define {{.*}}void @Size1ExtIntParam(i1{{.*}}  %[[PARAM:.+]])
+  // CHECK: %[[PARAM_ADDR:.+]] = alloca i1
+  // CHECK: %[[B:.+]] = alloca [5 x i1]
+  // CHECK: store i1 %[[PARAM]], i1* %[[PARAM_ADDR]]
+  unsigned _ExtInt(1) B[5];
+
+  // CHECK: %[[PARAM_LOAD:.+]] = load i1, i1* %[[PARAM_ADDR]]
+  // CHECK: %[[IDX:.+]] = getelementptr inbounds [5 x i1], [5 x i1]* %[[B]]
+  // CHECK: store i1 %[[PARAM_LOAD]], i1* %[[IDX]]
+  B[2] = A;
+}



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


[PATCH] D85276: [PGO][CUDA][HIP] Skip generating profile on the device stub and wrong-side functions.

2020-08-05 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/CodeGen/CodeGenPGO.cpp:839-840
 
+  // Skip host-only functions in the CUDA device compilation and device-only
+  // functions in the host compilation.
+  if (CGM.getLangOpts().CUDA &&

hliao wrote:
> tra wrote:
> > We will still have around some functions that may never be used on the host 
> > side (HD functions referenced from device code only).  I'm not sure if 
> > that's a problem for profiling, though. I wonder if we can somehow tie 
> > `skipRegionMappingForDecl` to whether we've actually codegen'ed the 
> > function. 
> Skipping wrong-side functions here just makes the report not confusing as 
> these functions are not emitted at all and are supposed never running on the 
> host/device side. If we still create the mapping for them, e.g., we may 
> report they have 0 runs instead of reporting nothing (just like comments 
> between function.) That looks a little bit confusing.
> It seems the current PGO adds everything for coverage mapping and late prune 
> them based on checks here. Just try to follow that logic to skip wrong-side 
> functions. If we need to revise the original logic and generate coverage 
> mapping for emitted functions only, the change here is unnecessary.
I'd add a comment here that this 'filter' is just a rough best-effort 
approximation that still allows some effectively device-only Decls through.
The output should still be correct, even though the functions will never be 
used. Maybe add a TODO to deal with it if/when we know if the Decl was 
codegen'ed.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85276/new/

https://reviews.llvm.org/D85276

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


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-08-05 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: compiler-rt/lib/ubsan/ubsan_handlers.cpp:659
+ uptr PtrOrSize) {
   GET_REPORT_OPTIONS(true);
+  handleInvalidBuiltin(Data, Opts, PtrOrSize);

It looks like `__ubsan_handle_invalid_builtin` is meant to be recoverable, so I 
think this should be `GET_REPORT_OPTIONS(false)`. Marking this unrecoverable 
makes it impossible to suppress redundant diagnostics at the same source 
location. It looks this isn't code you've added: feel free to punt this to me. 
If you don't mind folding in a fix, adding a test would be simple (perform UB 
in a loop and verify only one diagnostic is printed).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79279/new/

https://reviews.llvm.org/D79279

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


[PATCH] D85316: [SyntaxTree] Proposition of new tree dump

2020-08-05 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

LGTM!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85316/new/

https://reviews.llvm.org/D85316

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


[PATCH] D85316: [SyntaxTree] Proposition of new tree dump

2020-08-05 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 283298.
eduucaldas added a comment.

Answering comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85316/new/

https://reviews.llvm.org/D85316

Files:
  clang/unittests/Tooling/Syntax/TreeTest.cpp


Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -308,45 +308,45 @@
 }
 )cpp",
   R"txt(
-*: TranslationUnit
+TranslationUnit Detached
 `-SimpleDeclaration
-  |-int
-  |-SimpleDeclarator
-  | |-main
+  |-'int'
+  |-SimpleDeclarator SimpleDeclaration_declarator
+  | |-'main'
   | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
   `-CompoundStatement
-|-{
-|-IfStatement
-| |-if
-| |-(
+|-'{' OpenParen
+|-IfStatement CompoundStatement_statement
+| |-'if' IntroducerKeyword
+| |-'('
 | |-IntegerLiteralExpression
-| | `-1
-| |-)
-| `-CompoundStatement
-|   |-{
-|   `-}
-|-IfStatement
-| |-if
-| |-(
+| | `-'1' LiteralToken
+| |-')'
+| `-CompoundStatement IfStatement_thenStatement
+|   |-'{' OpenParen
+|   `-'}' CloseParen
+|-IfStatement CompoundStatement_statement
+| |-'if' IntroducerKeyword
+| |-'('
 | |-IntegerLiteralExpression
-| | `-1
-| |-)
-| |-CompoundStatement
-| | |-{
-| | `-}
-| |-else
-| `-IfStatement
-|   |-if
-|   |-(
+| | `-'1' LiteralToken
+| |-')'
+| |-CompoundStatement IfStatement_thenStatement
+| | |-'{' OpenParen
+| | `-'}' CloseParen
+| |-'else' IfStatement_elseKeyword
+| `-IfStatement IfStatement_elseStatement
+|   |-'if' IntroducerKeyword
+|   |-'('
 |   |-IntegerLiteralExpression
-|   | `-0
-|   |-)
-|   `-CompoundStatement
-| |-{
-| `-}
-`-}
+|   | `-'0' LiteralToken
+|   |-')'
+|   `-CompoundStatement IfStatement_thenStatement
+| |-'{' OpenParen
+| `-'}' CloseParen
+`-'}' CloseParen
 )txt"));
 }
 


Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -308,45 +308,45 @@
 }
 )cpp",
   R"txt(
-*: TranslationUnit
+TranslationUnit Detached
 `-SimpleDeclaration
-  |-int
-  |-SimpleDeclarator
-  | |-main
+  |-'int'
+  |-SimpleDeclarator SimpleDeclaration_declarator
+  | |-'main'
   | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
+  |   |-'(' OpenParen
+  |   `-')' CloseParen
   `-CompoundStatement
-|-{
-|-IfStatement
-| |-if
-| |-(
+|-'{' OpenParen
+|-IfStatement CompoundStatement_statement
+| |-'if' IntroducerKeyword
+| |-'('
 | |-IntegerLiteralExpression
-| | `-1
-| |-)
-| `-CompoundStatement
-|   |-{
-|   `-}
-|-IfStatement
-| |-if
-| |-(
+| | `-'1' LiteralToken
+| |-')'
+| `-CompoundStatement IfStatement_thenStatement
+|   |-'{' OpenParen
+|   `-'}' CloseParen
+|-IfStatement CompoundStatement_statement
+| |-'if' IntroducerKeyword
+| |-'('
 | |-IntegerLiteralExpression
-| | `-1
-| |-)
-| |-CompoundStatement
-| | |-{
-| | `-}
-| |-else
-| `-IfStatement
-|   |-if
-|   |-(
+| | `-'1' LiteralToken
+| |-')'
+| |-CompoundStatement IfStatement_thenStatement
+| | |-'{' OpenParen
+| | `-'}' CloseParen
+| |-'else' IfStatement_elseKeyword
+| `-IfStatement IfStatement_elseStatement
+|   |-'if' IntroducerKeyword
+|   |-'('
 |   |-IntegerLiteralExpression
-|   | `-0
-|   |-)
-|   `-CompoundStatement
-| |-{
-| `-}
-`-}
+|   | `-'0' LiteralToken
+|   |-')'
+|   `-CompoundStatement IfStatement_thenStatement
+| |-'{' OpenParen
+| `-'}' CloseParen
+`-'}' CloseParen
 )txt"));
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82756: Port some floating point options to new option marshalling infrastructure

2020-08-05 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added inline comments.



Comment at: clang/test/CodeGen/fp-function-attrs.cpp:2
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -ffast-math -ffinite-math-only 
-menable-unsafe-fp-math \
+// RUN:   -menable-no-infs -menable-no-nans -fno-signed-zeros 
-freciprocal-math \
+// RUN:   -fapprox-func -mreassociate -ffp-contract=fast -emit-llvm -o - %s | 
FileCheck %s

Anastasia wrote:
> dang wrote:
> > Anastasia wrote:
> > > dang wrote:
> > > > Anastasia wrote:
> > > > > Not clear why do you need to pass these extra flags now?
> > > > Previously passing -ffast-math to CC1 implied all these other flags. I 
> > > > am trying to make CC1 option parsing as simple as possible, so that we 
> > > > can then make it easy to generate a command line from a 
> > > > CompilerInvocation instance. You can refer to [[ 
> > > > http://lists.llvm.org/pipermail/cfe-dev/2020-May/065421.html | 
> > > > http://lists.llvm.org/pipermail/cfe-dev/2020-May/065421.html ]] for 
> > > > more details on why we want to be able to do this
> > > Just to understand, there used to be implied flags and it made the manual 
> > > command line use of clang more compact and easy... Is the idea now to 
> > > change those compound flags such that individul flags always need to be 
> > > passed?
> > > 
> > > Although I thought you are still adding the implicit flags:
> > > 
> > >   {options::OPT_cl_fast_relaxed_math,
> > >[&](const Arg *Arg) {
> > >  RenderArg(Arg);
> > > 
> > >  CmdArgs.push_back(GetArgString(options::OPT_cl_mad_enable));
> > >  CmdArgs.push_back(GetArgString(options::OPT_ffast_math));
> > >  
> > > CmdArgs.push_back(GetArgString(options::OPT_ffinite_math_only));
> > >  CmdArgs.push_back(
> > >  GetArgString(options::OPT_menable_unsafe_fp_math));
> > >  CmdArgs.push_back(GetArgString(options::OPT_mreassociate));
> > >  
> > > CmdArgs.push_back(GetArgString(options::OPT_menable_no_nans));
> > >  CmdArgs.push_back(
> > >  GetArgString(options::OPT_menable_no_infinities));
> > >  
> > > CmdArgs.push_back(GetArgString(options::OPT_fno_signed_zeros));
> > >  
> > > CmdArgs.push_back(GetArgString(options::OPT_freciprocal_math));
> > >  CmdArgs.push_back(GetArgString(options::OPT_fapprox_func));
> > >}}
> > > 
> > > Do I just misunderstand something?
> > The command line of the driver doesn't change. This patch only affects what 
> > CC1 understands, now CC1 doesn't know anymore that `-cl-fast-relaxed-math` 
> > implies all these other options so the driver is responsible for specifying 
> > them when it constructs the CC1 command line.
> > 
> > To summarize, the clang driver command line isn't affected by this patch 
> > and it shouldn't be so let me know if something is wrong there. However, 
> > manually constructed `clang -cc1` invocations need to specify the all the 
> > implied flags manually now.
> Yes I understand, however, I am wondering whether this is intuitive because 
> it seems the behavior of clang with `-cc1` and without will be different if 
> the same `-cl-fast-relaxed-math` flag is passed.
> 
> I also find adding all the flags manually is too verbode if 
> `-cl-fast-relaxed-math` assumes to enable all the extra setting.
My understanding is that `-cc1` is an internal interface, so end-users should 
never use `-cc1` directly and/or rely on itss interface. It is already the case 
that flags mean very different things to the driver and `-cc1` for example 
"--target=" and "-triple". Furthermore, this impacted very few tests which 
leads me to believe that few compiler developers actually rely on this behavior.

Do you think this would be a major inconvenience to compiler developers to have 
to manually expand it out?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82756/new/

https://reviews.llvm.org/D82756

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


[PATCH] D85330: [SyntaxTree] Extend the syntax tree dump

2020-08-05 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Functional changes in the dump:

- Surround Leaf tokens with `'`
- Append `Node` dumps  with `NodeRole` information, except for unknown roles

Non-functional changes:

- `::dumpTokens(llvm::raw_ostream, ArrayRef, const SourceManager 
)` always received as parameter a `syntax::Token *` pointing to 
`Leaf::token()`. Changed the function to `strOfLeaf(syntax::Leaf *, const 
SourceManager&)`
- `dumpTree` acted on a Node, rename to `dumpNode`

TODO:
Adapt all the tree dumps in `TreeTest.cpp` to this new format.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85330

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -159,7 +159,8 @@
  << "Source file has syntax errors, they were printed to the test "
 "log";
 }
-std::string Actual = std::string(StringRef(Root->dump(*Arena)).trim());
+std::string Actual =
+std::string(StringRef(Root->dump(Arena->sourceManager())).trim());
 // EXPECT_EQ shows the diff between the two strings if they are different.
 EXPECT_EQ(Tree.trim().str(), Actual);
 if (Actual != Tree.trim().str()) {
Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -135,46 +135,43 @@
 }
 
 namespace {
-static void dumpTokens(llvm::raw_ostream , ArrayRef Tokens,
-   const SourceManager ) {
-  assert(!Tokens.empty());
-  bool First = true;
-  for (const auto  : Tokens) {
-if (!First)
-  OS << " ";
-else
-  First = false;
-// Handle 'eof' separately, calling text() on it produces an empty string.
-if (T.kind() == tok::eof) {
-  OS << "";
-  continue;
-}
-OS << T.text(SM);
-  }
+static llvm::StringRef strOfLeaf(const syntax::Leaf *L,
+ const SourceManager ) {
+  assert(L);
+  const auto *Token = L->token();
+  assert(Token);
+  // Handle 'eof' separately, calling text() on it produces an empty string.
+  if (Token->kind() == tok::eof)
+return "";
+  return Token->text(SM);
 }
 
-static void dumpTree(llvm::raw_ostream , const syntax::Node *N,
- const syntax::Arena , std::vector IndentMask) {
+static void dumpNode(llvm::raw_ostream , const syntax::Node *N,
+ const SourceManager , std::vector IndentMask) {
   std::string Marks;
   if (!N->isOriginal())
 Marks += "M";
-  if (N->role() == syntax::NodeRole::Detached)
-Marks += "*"; // FIXME: find a nice way to print other roles.
   if (!N->canModify())
 Marks += "I";
   if (!Marks.empty())
 OS << Marks << ": ";
 
   if (auto *L = llvm::dyn_cast(N)) {
-dumpTokens(OS, *L->token(), A.sourceManager());
+OS << "'" << strOfLeaf(L, SM) << "'";
+if (L->role() != syntax::NodeRole::Unknown)
+  OS << " " << L->role();
 OS << "\n";
 return;
   }
 
   auto *T = llvm::cast(N);
-  OS << T->kind() << "\n";
+  OS << T->kind();
+  if (T->role() != syntax::NodeRole::Unknown)
+OS << " " << T->role();
+  OS << "\n";
 
-  for (auto It = T->firstChild(); It != nullptr; It = It->nextSibling()) {
+  for (const auto *It = T->firstChild(); It != nullptr;
+   It = It->nextSibling()) {
 for (bool Filled : IndentMask) {
   if (Filled)
 OS << "| ";
@@ -188,28 +185,26 @@
   OS << "|-";
   IndentMask.push_back(true);
 }
-dumpTree(OS, It, A, IndentMask);
+dumpNode(OS, It, SM, IndentMask);
 IndentMask.pop_back();
   }
 }
 } // namespace
 
-std::string syntax::Node::dump(const Arena ) const {
+std::string syntax::Node::dump(const SourceManager ) const {
   std::string Str;
   llvm::raw_string_ostream OS(Str);
-  dumpTree(OS, this, A, /*IndentMask=*/{});
+  dumpNode(OS, this, SM, /*IndentMask=*/{});
   return std::move(OS.str());
 }
 
-std::string syntax::Node::dumpTokens(const Arena ) const {
+std::string syntax::Node::dumpTokens(const SourceManager ) const {
   std::string Storage;
   llvm::raw_string_ostream OS(Storage);
   traverse(this, [&](const syntax::Node *N) {
-auto *L = llvm::dyn_cast(N);
-if (!L)
-  return;
-::dumpTokens(OS, *L->token(), A.sourceManager());
-OS << " ";
+if (auto *L = llvm::dyn_cast(N)) {
+  OS << strOfLeaf(L, SM) << " ";
+}
   });
   return OS.str();
 }
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ 

[PATCH] D85276: [PGO][CUDA][HIP] Skip generating profile on the device stub and wrong-side functions.

2020-08-05 Thread Michael Liao via Phabricator via cfe-commits
hliao added inline comments.



Comment at: clang/lib/CodeGen/CodeGenPGO.cpp:839-840
 
+  // Skip host-only functions in the CUDA device compilation and device-only
+  // functions in the host compilation.
+  if (CGM.getLangOpts().CUDA &&

tra wrote:
> We will still have around some functions that may never be used on the host 
> side (HD functions referenced from device code only).  I'm not sure if that's 
> a problem for profiling, though. I wonder if we can somehow tie 
> `skipRegionMappingForDecl` to whether we've actually codegen'ed the function. 
Skipping wrong-side functions here just makes the report not confusing as these 
functions are not emitted at all and are supposed never running on the 
host/device side. If we still create the mapping for them, e.g., we may report 
they have 0 runs instead of reporting nothing (just like comments between 
function.) That looks a little bit confusing.
It seems the current PGO adds everything for coverage mapping and late prune 
them based on checks here. Just try to follow that logic to skip wrong-side 
functions. If we need to revise the original logic and generate coverage 
mapping for emitted functions only, the change here is unnecessary.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85276/new/

https://reviews.llvm.org/D85276

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


[PATCH] D85252: [Driver] Accept -fno-lto in clang-cl

2020-08-05 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm

In general when -ffoo is supported by clang-cl, -fno-foo should be too, so this 
makes sense.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85252/new/

https://reviews.llvm.org/D85252

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


[PATCH] D85324: [z/OS] Add z/OS Target and define macros

2020-08-05 Thread Abhina Sreeskantharajan via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 283290.
abhina.sreeskantharajan added a reviewer: MaskRay.
abhina.sreeskantharajan added a comment.

Thanks MaskRay, I removed the extra braces.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85324/new/

https://reviews.llvm.org/D85324

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/Preprocessor/init.c

Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -5630,6 +5630,45 @@
 // S390X:#define __s390__ 1
 // S390X:#define __s390x__ 1
 //
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS %s
+// RUN: %clang_cc1 -x c -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-C %s
+// RUN: %clang_cc1 -E -dM -std=gnu99 -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS %s
+// RUN: %clang_cc1 -E -dM -std=gnu11 -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS %s
+// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-CXX %s
+// RUN: %clang_cc1 -x c -std=c99 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-C99 %s
+// RUN: %clang_cc1 -x c++ -std=c++11 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-CXX %s
+// RUN: %clang_cc1 -x c++ -std=c++14 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-CXX %s
+// RUN: %clang_cc1 -x c++ -std=gnu++11 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-CXX -check-prefix S390X-ZOS-GXX %s
+// RUN: %clang_cc1 -x c++ -std=gnu++14 -E -dM -ffreestanding -triple=s390x-none-zos -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X-ZOS -check-prefix S390X-ZOS-CXX -check-prefix S390X-ZOS-GXX %s
+//
+// S390X-ZOS-GXX:#define _EXT 1
+// S390X-ZOS-C99:#define _ISOC99_SOURCE 1
+// S390X-ZOS:#define _LONG_LONG 1
+// S390X-ZOS-GXX:#define _MI_BUILTIN 1
+// S390X-ZOS:#define _OPEN_DEFAULT 1
+// S390X-ZOS:#define _UNIX03_WITHDRAWN 1
+// S390X-ZOS-CXX:#define _XOPEN_SOURCE 600
+// S390X-ZOS:#define __370__ 1
+// S390X-ZOS:#define __64BIT__ 1
+// S390X-ZOS:#define __BFP__ 1
+// S390X-ZOS:#define __BOOL__ 1
+// S390X-ZOS-CXX:#define __DLL__ 1
+// S390X-ZOS-C:#define __IBMC_GENERIC 1
+// S390X-ZOS-C:#define __IBMC_NORETURN 1
+// S390X-ZOS-C:#define __IBM_UTF_LITERAL 1
+// S390X-ZOS-GXX:#define __IBMCPP_UTF_LITERAL__ 1
+// S390X-ZOS-GXX:#define __IBMC_NORETURN 1
+// S390X-ZOS-GXX:#define __IBM_CHAR16_T__ 1
+// S390X-ZOS-GXX:#define __IBM_CHAR32_T__ 1
+// S390X-ZOS:#define __LONGNAME__ 1
+// S390X-ZOS:#define __MVS__ 1
+// S390X-ZOS:#define __THW_370__ 1
+// S390X-ZOS:#define __THW_BIG_ENDIAN__ 1
+// S390X-ZOS:#define __TOS_390__ 1
+// S390X-ZOS:#define __TOS_MVS__ 1
+// S390X-ZOS:#define __XPLINK__ 1
+// S390X-ZOS-CXX:#define __wchar_t 1
+//
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=sparc-none-none < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-DEFAULT %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=sparc-rtems-elf < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-DEFAULT %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=sparc-none-netbsd < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-NETOPENBSD %s
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -721,6 +721,66 @@
   bool hasInt128Type() const override { return false; }
 };
 
+// z/OS target
+template 
+class LLVM_LIBRARY_VISIBILITY ZOSTargetInfo : public OSTargetInfo {
+protected:
+  void getOSDefines(const LangOptions , const llvm::Triple ,
+MacroBuilder ) const override {
+Builder.defineMacro("_LONG_LONG");
+Builder.defineMacro("_OPEN_DEFAULT");
+Builder.defineMacro("_UNIX03_WITHDRAWN");
+Builder.defineMacro("__370__");
+Builder.defineMacro("__BFP__");
+Builder.defineMacro("__BOOL__");
+Builder.defineMacro("__LONGNAME__");
+

[PATCH] D85191: [AST] Get field size in chars rather than bits in RecordLayoutBuilder.

2020-08-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D85191#2195923 , @ebevhan wrote:

> In D85191#2193645 , @rsmith wrote:
>
>>> This is not ideal, since it makes the calculations char size dependent, and 
>>> breaks for sizes that are not a multiple of the char size.
>>
>> How can we have a non-bitfield member whose size is not a multiple of the 
>> size of a char?
>
> Downstream, we have fixed-point types that are 24 bits large, but where the 
> char size is 16. The type then takes up 2 chars, where 8 of the bits are 
> padding. The only way in Clang to express that the width of the bit 
> representation of a type should be smaller than the number of chars it takes 
> up in memory -- and consequently, produce an `i24` in IR -- is to return a 
> non-charsize multiple from getTypeInfo.

This violates the C and C++ language rules, which require the size of every 
type to be a multiple of the size of char. A type with 24 value bits and 8 
padding bits should report a type size of 32 bits, just like `bool` reports a 
size of `CHAR_BIT` bits despite having only 1 value bit, and x86_64 `long 
double` reports a type size of 128 bits despite having only 80 value bits.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85191/new/

https://reviews.llvm.org/D85191

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


[PATCH] D82582: [SVE] Remove calls to VectorType::getNumElements from clang

2020-08-05 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau planned changes to this revision.
ctetreau added a comment.

I plan to investigate the changes proposed by @c-rhodes. I'm a bit swamped 
right now so it may take a bit.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82582/new/

https://reviews.llvm.org/D82582

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


[PATCH] D85324: [z/OS] Add z/OS Target and define macros

2020-08-05 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Basic/Targets/OSTargets.h:745
+if (this->PointerWidth == 64) {
+  Builder.defineMacro("__64BIT__");
+}

anirudhp wrote:
> abhina.sreeskantharajan wrote:
> > anirudhp wrote:
> > > What about the `__LP64__` and the `_LP64` macros?
> > These two are already added in the common code, so it would be redundant to 
> > add them again.
> Alright Thanks! 
Omit braces

https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85324/new/

https://reviews.llvm.org/D85324

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


  1   2   3   >