[PATCH] D74606: [clangd] Add add commit characters to the server capabilities

2020-02-18 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2a095ff6f502: [clangd] Add add commit characters to the 
server capabilities (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74606

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/initialize-params.test


Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -7,6 +7,7 @@
 # CHECK-NEXT:"capabilities": {
 # CHECK-NEXT:  "codeActionProvider": true,
 # CHECK-NEXT:  "completionProvider": {
+# CHECK-NEXT:"allCommitCharacters": " 

[clang-tools-extra] 2a095ff - [clangd] Add add commit characters to the server capabilities

2020-02-18 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-02-19T08:32:00+01:00
New Revision: 2a095ff6f5028b7612dae50358a2f6939b6cdc9f

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

LOG: [clangd] Add add commit characters to the server capabilities

Summary:
Make it more convinient for the clients to select completion items by
providing a set of default characters (punctuation).

Related issue: https://github.com/clangd/clangd/issues/284

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/test/initialize-params.test

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 93609a8852db..c31a0a417ebe 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -559,6 +559,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
,
 {"codeActionProvider", std::move(CodeActionProvider)},
 {"completionProvider",
  llvm::json::Object{
+ {"allCommitCharacters", " 

[PATCH] D74606: [clangd] Add add commit characters to the server capabilities

2020-02-18 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 245331.
kbobyrev added a comment.

Add pipe and single quote to commit characters.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74606

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/initialize-params.test


Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -7,6 +7,7 @@
 # CHECK-NEXT:"capabilities": {
 # CHECK-NEXT:  "codeActionProvider": true,
 # CHECK-NEXT:  "completionProvider": {
+# CHECK-NEXT:"allCommitCharacters": " 

[PATCH] D74814: IR printing for single function with the new pass manager.

2020-02-18 Thread Hongtao Yu via Phabricator via cfe-commits
hoyFB created this revision.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.
hoyFB added a reviewer: wenlei.
hoyFB added a subscriber: wenlei.

The IR printing always prints out all functions in a module with the new pass 
manager, even with -filter-print-funcs specified. This is being fixed in this 
change. However, there are two exceptions, i.e, with user-specified wildcast 
switch -filter-print-funcs=* or -print-module-scope, under which IR of all 
functions should be printed.

Test Plan:
make check-clang
make check-llvm


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74814

Files:
  clang/test/Misc/print-single-function.c
  llvm/lib/Passes/StandardInstrumentations.cpp


Index: llvm/lib/Passes/StandardInstrumentations.cpp
===
--- llvm/lib/Passes/StandardInstrumentations.cpp
+++ llvm/lib/Passes/StandardInstrumentations.cpp
@@ -70,16 +70,24 @@
   llvm_unreachable("Unknown IR unit");
 }
 
-void printIR(const Module *M, StringRef Banner, StringRef Extra = StringRef()) 
{
-  dbgs() << Banner << Extra << "\n";
-  M->print(dbgs(), nullptr, false);
-}
 void printIR(const Function *F, StringRef Banner,
  StringRef Extra = StringRef()) {
   if (!llvm::isFunctionInPrintList(F->getName()))
 return;
   dbgs() << Banner << Extra << "\n" << static_cast(*F);
 }
+
+void printIR(const Module *M, StringRef Banner, StringRef Extra = StringRef()) 
{
+  if (llvm::isFunctionInPrintList("*") || llvm::forcePrintModuleIR()) {
+dbgs() << Banner << Extra << "\n";
+M->print(dbgs(), nullptr, false);
+  } else {
+for (const auto  : M->functions()) {
+  printIR(, Banner, Extra);
+}
+  }
+}
+
 void printIR(const LazyCallGraph::SCC *C, StringRef Banner,
  StringRef Extra = StringRef()) {
   bool BannerPrinted = false;
Index: clang/test/Misc/print-single-function.c
===
--- /dev/null
+++ clang/test/Misc/print-single-function.c
@@ -0,0 +1,21 @@
+// Testing single function IR printing with the new pass manager.  there are 
two exceptions, i.e, with user-specified wildcast switch -filter-print-funcs=* 
or -print-module-scope, under which IR of all functions should be printed.
+// RUN: %clang_cc1 -emit-llvm -fexperimental-new-pass-manager -mllvm 
-print-after-all -mllvm -filter-print-funcs=foo %s -o %t 2>&1 | FileCheck %s 
--check-prefix=FOO
+// RUN: %clang_cc1 -emit-llvm -fexperimental-new-pass-manager -mllvm 
-print-after-all -mllvm -filter-print-funcs=foo %s -mllvm -print-module-scope 
-o %t 2>&1 | FileCheck %s --check-prefix=ALL
+// RUN: %clang_cc1 -emit-llvm -fexperimental-new-pass-manager -mllvm 
-print-after-all -mllvm -filter-print-funcs=* %s -o %t 2>&1 | FileCheck %s 
--check-prefix=ALL
+
+// FOO: *** IR Dump After AlwaysInlinerPass ***
+// FOO: define void @foo()
+// FOO-NOT: define void @bar()
+
+// ALL: *** IR Dump After AlwaysInlinerPass ***
+// ALL-NEXT: ; ModuleID =
+// ALL: define void @foo()
+// ALL: define void @bar()
+
+void bar() {
+  return;
+}
+
+void foo() {
+  bar();
+}


Index: llvm/lib/Passes/StandardInstrumentations.cpp
===
--- llvm/lib/Passes/StandardInstrumentations.cpp
+++ llvm/lib/Passes/StandardInstrumentations.cpp
@@ -70,16 +70,24 @@
   llvm_unreachable("Unknown IR unit");
 }
 
-void printIR(const Module *M, StringRef Banner, StringRef Extra = StringRef()) {
-  dbgs() << Banner << Extra << "\n";
-  M->print(dbgs(), nullptr, false);
-}
 void printIR(const Function *F, StringRef Banner,
  StringRef Extra = StringRef()) {
   if (!llvm::isFunctionInPrintList(F->getName()))
 return;
   dbgs() << Banner << Extra << "\n" << static_cast(*F);
 }
+
+void printIR(const Module *M, StringRef Banner, StringRef Extra = StringRef()) {
+  if (llvm::isFunctionInPrintList("*") || llvm::forcePrintModuleIR()) {
+dbgs() << Banner << Extra << "\n";
+M->print(dbgs(), nullptr, false);
+  } else {
+for (const auto  : M->functions()) {
+  printIR(, Banner, Extra);
+}
+  }
+}
+
 void printIR(const LazyCallGraph::SCC *C, StringRef Banner,
  StringRef Extra = StringRef()) {
   bool BannerPrinted = false;
Index: clang/test/Misc/print-single-function.c
===
--- /dev/null
+++ clang/test/Misc/print-single-function.c
@@ -0,0 +1,21 @@
+// Testing single function IR printing with the new pass manager.  there are two exceptions, i.e, with user-specified wildcast switch -filter-print-funcs=* or -print-module-scope, under which IR of all functions should be printed.
+// RUN: %clang_cc1 -emit-llvm -fexperimental-new-pass-manager -mllvm -print-after-all -mllvm -filter-print-funcs=foo %s -o %t 2>&1 | FileCheck %s --check-prefix=FOO
+// RUN: %clang_cc1 -emit-llvm -fexperimental-new-pass-manager -mllvm -print-after-all -mllvm 

[PATCH] D74757: Fix compiler extension in standalone mode

2020-02-18 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 245327.
serge-sans-paille added a comment.

Take @Meinersbur review into account.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74757

Files:
  clang/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/CMakeLists.txt

Index: llvm/cmake/modules/CMakeLists.txt
===
--- llvm/cmake/modules/CMakeLists.txt
+++ llvm/cmake/modules/CMakeLists.txt
@@ -136,6 +136,7 @@
 FILES_MATCHING PATTERN *.cmake
 PATTERN .svn EXCLUDE
 PATTERN LLVMConfig.cmake EXCLUDE
+PATTERN LLVMConfigExtensions.cmake EXCLUDE
 PATTERN LLVMConfigVersion.cmake EXCLUDE
 PATTERN LLVM-Config.cmake EXCLUDE
 PATTERN GetHostTriple.cmake EXCLUDE)
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -873,63 +873,62 @@
 if (TARGET intrinsics_gen)
   add_dependencies(obj.${name} intrinsics_gen)
 endif()
-message(STATUS "Registering ${name} as a pass plugin (static build: ${LLVM_${name_upper}_LINK_INTO_TOOLS})")
-set_property(GLOBAL APPEND PROPERTY LLVM_COMPILE_EXTENSIONS ${name})
+set_property(GLOBAL APPEND PROPERTY LLVM_STATIC_EXTENSIONS ${name})
   elseif(NOT ARG_NO_MODULE)
 add_llvm_library(${name} MODULE ${ARG_UNPARSED_ARGUMENTS})
   else()
 add_llvm_library(${name} OBJECT ${ARG_UNPARSED_ARGUMENTS})
   endif()
+  message(STATUS "Registering ${name} as a pass plugin (static build: ${LLVM_${name_upper}_LINK_INTO_TOOLS})")
 
 endfunction(add_llvm_pass_plugin)
 
-# process_llvm_pass_plugins([NO_GEN])
+# process_llvm_pass_plugins([GEN_CONFIG])
 #
 # Correctly set lib dependencies between plugins and tools, based on tools
 # registered with the ENABLE_PLUGINS option.
 #
-# Unless NO_GEN option is set, also generate X Macro file for extension
+# if GEN_CONFIG option is set, also generate X Macro file for extension
 # handling. It provides a HANDLE_EXTENSION(extension_namespace, ExtensionProject)
 # call for each extension allowing client code to define
 # HANDLE_EXTENSION to have a specific code be run for each extension.
 #
 function(process_llvm_pass_plugins)
   cmake_parse_arguments(ARG
-  "NO_GEN" "" ""
+  "GEN_CONFIG" "" ""
 ${ARGN})
 
+  if(ARG_GEN_CONFIG)
+  get_property(LLVM_STATIC_EXTENSIONS GLOBAL PROPERTY LLVM_STATIC_EXTENSIONS)
+  else()
+  include(LLVMConfigExtensions)
+  endif()
+
   # Add static plugins to each plugin target.
-  get_property(LLVM_EXTENSIONS GLOBAL PROPERTY LLVM_COMPILE_EXTENSIONS)
-  foreach(llvm_extension ${LLVM_EXTENSIONS})
-string(TOUPPER ${llvm_extension} llvm_extension_upper)
-string(TOLOWER ${llvm_extension} llvm_extension_lower)
-
-if(LLVM_${llvm_extension_upper}_LINK_INTO_TOOLS)
-  get_property(llvm_plugin_targets GLOBAL PROPERTY LLVM_PLUGIN_TARGETS)
-  foreach(llvm_plugin_target ${llvm_plugin_targets})
-set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY LINK_LIBRARIES ${llvm_extension})
-set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${llvm_extension})
-  endforeach()
-else()
-  add_llvm_library(${llvm_extension_lower} MODULE obj.${llvm_extension_lower})
-endif()
+  foreach(llvm_extension ${LLVM_STATIC_EXTENSIONS})
+get_property(llvm_plugin_targets GLOBAL PROPERTY LLVM_PLUGIN_TARGETS)
+foreach(llvm_plugin_target ${llvm_plugin_targets})
+  set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY LINK_LIBRARIES ${llvm_extension})
+  set_property(TARGET ${llvm_plugin_target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${llvm_extension})
+endforeach()
   endforeach()
 
-  # Eventually generate the extension header.
-  if(NOT ARG_NO_GEN)
-  file(WRITE "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "//extension handlers\n")
-  foreach(llvm_extension ${LLVM_EXTENSIONS})
-string(TOLOWER ${llvm_extension} llvm_extension_lower)
-
-string(TOUPPER ${llvm_extension} llvm_extension_upper)
-string(SUBSTRING ${llvm_extension_upper} 0 1 llvm_extension_upper_first)
-string(SUBSTRING ${llvm_extension_lower} 1 -1 llvm_extension_lower_tail)
-string(CONCAT llvm_extension_project ${llvm_extension_upper_first} ${llvm_extension_lower_tail})
-
-if(LLVM_${llvm_extension_upper}_LINK_INTO_TOOLS)
-  file(APPEND "${LLVM_BINARY_DIR}/include/llvm/Support/Extension.def.tmp" "HANDLE_EXTENSION(${llvm_extension_project})\n")
-endif()
+  # Eventually generate the extension header, and store config to a cmake file
+  # for usage in third-party configuration.
+  if(ARG_GEN_CONFIG)
+  set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
+  set(llvm_cmake_builddir 

[PATCH] D74813: [RFC] Add hash of block contents to function block names

2020-02-18 Thread Alex Borcan via Phabricator via cfe-commits
alexbdv created this revision.
alexbdv added reviewers: MaskRay, vsk, JonasToth, ruiu.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Function blocks don't have a name specified in source code. Currently their 
symbol name is based on the parent function's name and an index. 
Ex: _ZN1Parent_Funciton_block_invoke_1
One issue that happens with the current naming scheme is that in subsequent 
builds, the name of the function block can change even if the function block or 
the parent function has changed. This presents issues for tools that use symbol 
names to identify changes in source code / tracking of binary metrics.

The proposed solution here is to add a flag (default=off) that enables adding a 
hash of the block contents to the block name. 
Ex: _ZN1Parent_Funciton_block_invoke_38172  (38172 is the hash)
Therefore, the function block name will only change if its content or the 
parent function name changes. And will now remain stable regardless if new 
function blocks are added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74813

Files:
  clang/include/clang/AST/Mangle.h
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/Mangle.cpp
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2817,6 +2817,9 @@
   Opts.ExternCNoUnwind = Args.hasArg(OPT_fexternc_nounwind);
   Opts.TraditionalCPP = Args.hasArg(OPT_traditional_cpp);
 
+  Opts.ObjCEnableHashFuncBlockNames =
+  Args.hasArg(OPT_enable_hash_in_objc_func_block_names);
+
   Opts.RTTI = Opts.CPlusPlus && !Args.hasArg(OPT_fno_rtti);
   Opts.RTTIData = Opts.RTTI && !Args.hasArg(OPT_fno_rtti_data);
   Opts.Blocks = Args.hasArg(OPT_fblocks) || (Opts.OpenCL
Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -24,11 +24,61 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Mangler.h"
-#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/ErrorHandling.h"	
+#include "llvm/Support/MD5.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
 
+static std::string getBlockIDByHash(const BlockDecl *BD,
+unsigned discriminator) {
+  Stmt *stmt = BD ? BD->getBody() : nullptr;
+
+  std::string strOutBuff;
+  llvm::raw_string_ostream strOutStream(strOutBuff);
+
+  strOutStream << "_block_invoke";
+
+  if (!stmt) {
+if (discriminator)
+  strOutStream << "_" << discriminator + 1;
+
+return strOutBuff;
+  }
+
+  std::string strStmtBuff;
+  llvm::raw_string_ostream strStmtStream(strStmtBuff);
+
+  // Dump the statement IR to a text stream for hasing
+  stmt->dump(strStmtStream);
+  strStmtBuff = strStmtStream.str();
+
+  // Strip out addresses
+  char *ptr = [1];
+  while (*ptr) {
+if (*ptr == 'x' && *(ptr - 1) == '0') {
+  ptr++;
+  while ((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'a' && *ptr <= 'f')) {
+*ptr = '_';
+ptr++;
+  }
+  continue;
+}
+ptr++;
+  }
+
+  // Hash the statement string
+  llvm::MD5 Hash;
+  llvm::MD5::MD5Result Result;
+
+  Hash.update(strStmtBuff);
+  Hash.final(Result);
+
+  strOutStream << "_" << *(unsigned short *)
+  return strOutBuff;
+}
+
+
 // FIXME: For blocks we currently mimic GCC's mangling scheme, which leaves
 // much to be desired. Come up with a better mangling scheme.
 
@@ -37,6 +87,12 @@
 const BlockDecl *BD,
 raw_ostream ) {
   unsigned discriminator = Context.getBlockId(BD, true);
+  	
+  if (Context.shouldAddHashOfBlockToName()) {
+Out << "__" << Outer << getBlockIDByHash(BD, discriminator);
+return;
+  }
+
   if (discriminator == 0)
 Out << "__" << Outer << "_block_invoke";
   else
@@ -89,6 +145,10 @@
 return CCM_Vector;
   }
 }
+	
+bool MangleContext::shouldAddHashOfBlockToName() {
+  return getASTContext().getLangOpts().ObjCEnableHashFuncBlockNames;
+}
 
 bool MangleContext::shouldMangleDeclName(const NamedDecl *D) {
   const ASTContext  = getASTContext();
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1349,6 +1349,8 @@
 def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
   Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Write minimized bitcode to  for the ThinLTO thin link only">;
+def enable_hash_in_objc_func_block_names : Flag<["-"], "enable-hash-in-objc-func-block-names">, Flags<[CC1Option]>, Group,
+  HelpText<"For objc function blocks - enable adding a hash of the block in the blocks's name">;
 def 

[PATCH] D71903: [Coroutines][6/6] Clang schedules new passes

2020-02-18 Thread Brian Gesiak via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG048239e46e49: [Coroutines][6/6] Clang schedules new passes 
(authored by modocache).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71903

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp

Index: clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
===
--- /dev/null
+++ clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
@@ -0,0 +1,57 @@
+// Tests that coroutine passes are added to and run by the new pass manager
+// pipeline, at -O0 and above.
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null \
+// RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts \
+// RUN:   -O0 %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null \
+// RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts \
+// RUN:   -O1 %s 2>&1 | FileCheck %s
+//
+// CHECK: Starting llvm::Module pass manager run.
+// CHECK: Running pass:{{.*}}CoroEarlyPass
+//
+// The first coro-split pass enqueues a second run of the entire CGSCC pipeline.
+// CHECK: Starting CGSCC pass manager run.
+// CHECK: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on (_Z3foov)
+// CHECK: Finished CGSCC pass manager run.
+//
+// The second coro-split pass splits coroutine 'foo' into funclets
+// 'foo.resume', 'foo.destroy', and 'foo.cleanup'.
+// CHECK: Starting CGSCC pass manager run.
+// CHECK: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on (_Z3foov)
+// CHECK: Finished CGSCC pass manager run.
+//
+// CHECK: Running pass:{{.*}}CoroCleanupPass
+// CHECK: Finished llvm::Module pass manager run.
+
+namespace std {
+namespace experimental {
+
+struct handle {};
+
+struct awaitable {
+  bool await_ready() { return true; }
+  void await_suspend(handle) {}
+  bool await_resume() { return true; }
+};
+
+template  struct coroutine_handle {
+  static handle from_address(void *address) { return {}; }
+};
+
+template  struct coroutine_traits {
+  struct promise_type {
+awaitable initial_suspend() { return {}; }
+awaitable final_suspend() { return {}; }
+void return_void() {}
+T get_return_object() { return T(); }
+void unhandled_exception() {}
+  };
+};
+} // namespace experimental
+} // namespace std
+
+void foo() { co_return; }
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -49,6 +49,10 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Transforms/Coroutines.h"
+#include "llvm/Transforms/Coroutines/CoroCleanup.h"
+#include "llvm/Transforms/Coroutines/CoroEarly.h"
+#include "llvm/Transforms/Coroutines/CoroElide.h"
+#include "llvm/Transforms/Coroutines/CoroSplit.h"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/LowerTypeTests.h"
@@ -957,6 +961,22 @@
   }
 }
 
+static void addCoroutinePassesAtO0(ModulePassManager ,
+   const LangOptions ,
+   const CodeGenOptions ) {
+  if (!LangOpts.Coroutines)
+return;
+
+  MPM.addPass(createModuleToFunctionPassAdaptor(CoroEarlyPass()));
+
+  CGSCCPassManager CGPM(CodeGenOpts.DebugPassManager);
+  CGPM.addPass(CoroSplitPass());
+  CGPM.addPass(createCGSCCToFunctionPassAdaptor(CoroElidePass()));
+  MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
+
+  MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass()));
+}
+
 static void addSanitizersAtO0(ModulePassManager ,
   const Triple ,
   const LangOptions ,
@@ -1076,6 +1096,7 @@
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
   PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
   PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+  PTO.Coroutines = LangOpts.Coroutines;
 
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI;
@@ -1279,6 +1300,7 @@
 }
 
 if (CodeGenOpts.OptimizationLevel == 0) {
+  addCoroutinePassesAtO0(MPM, LangOpts, CodeGenOpts);
   addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 048239e - [Coroutines][6/6] Clang schedules new passes

2020-02-18 Thread Brian Gesiak via cfe-commits

Author: Brian Gesiak
Date: 2020-02-19T01:03:28-05:00
New Revision: 048239e46e490d441f21f3e26073ec38f19e8a10

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

LOG: [Coroutines][6/6] Clang schedules new passes

Summary:
Depends on https://reviews.llvm.org/D71902.

The last in a series of six patches that ports the LLVM coroutines
passes to the new pass manager infrastructure.

This patch has Clang schedule the new coroutines passes when the
`-fexperimental-new-pass-manager` option is used. With this and the
previous 5 patches, Clang is capable of building and successfully
running the test suite of large coroutines projects such as
https://github.com/lewissbaker/cppcoro with
`ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=On`.

Reviewers: GorNishanov, lewissbaker, chandlerc, junparser

Subscribers: EricWF, cfe-commits, llvm-commits

Tags: #clang

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

Added: 
clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp

Modified: 
clang/lib/CodeGen/BackendUtil.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 6c71cf793c0f..b244fd499fb0 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -49,6 +49,10 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Transforms/Coroutines.h"
+#include "llvm/Transforms/Coroutines/CoroCleanup.h"
+#include "llvm/Transforms/Coroutines/CoroEarly.h"
+#include "llvm/Transforms/Coroutines/CoroElide.h"
+#include "llvm/Transforms/Coroutines/CoroSplit.h"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/LowerTypeTests.h"
@@ -957,6 +961,22 @@ static PassBuilder::OptimizationLevel mapToLevel(const 
CodeGenOptions ) {
   }
 }
 
+static void addCoroutinePassesAtO0(ModulePassManager ,
+   const LangOptions ,
+   const CodeGenOptions ) {
+  if (!LangOpts.Coroutines)
+return;
+
+  MPM.addPass(createModuleToFunctionPassAdaptor(CoroEarlyPass()));
+
+  CGSCCPassManager CGPM(CodeGenOpts.DebugPassManager);
+  CGPM.addPass(CoroSplitPass());
+  CGPM.addPass(createCGSCCToFunctionPassAdaptor(CoroElidePass()));
+  MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
+
+  MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass()));
+}
+
 static void addSanitizersAtO0(ModulePassManager ,
   const Triple ,
   const LangOptions ,
@@ -1076,6 +1096,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
   PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
   PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+  PTO.Coroutines = LangOpts.Coroutines;
 
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI;
@@ -1279,6 +1300,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 }
 
 if (CodeGenOpts.OptimizationLevel == 0) {
+  addCoroutinePassesAtO0(MPM, LangOpts, CodeGenOpts);
   addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);
 }
   }

diff  --git a/clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp 
b/clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
new file mode 100644
index ..aed2cf13f892
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
@@ -0,0 +1,57 @@
+// Tests that coroutine passes are added to and run by the new pass manager
+// pipeline, at -O0 and above.
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
\
+// RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts 
\
+// RUN:   -O0 %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
\
+// RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts 
\
+// RUN:   -O1 %s 2>&1 | FileCheck %s
+//
+// CHECK: Starting llvm::Module pass manager run.
+// CHECK: Running pass:{{.*}}CoroEarlyPass
+//
+// The first coro-split pass enqueues a second run of the entire CGSCC 
pipeline.
+// CHECK: Starting CGSCC pass manager run.
+// CHECK: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on (_Z3foov)
+// CHECK: Finished CGSCC pass manager run.
+//
+// The second coro-split pass splits coroutine 'foo' into funclets
+// 'foo.resume', 'foo.destroy', and 'foo.cleanup'.
+// CHECK: Starting CGSCC pass manager run.
+// CHECK: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on (_Z3foov)
+// CHECK: Finished CGSCC pass manager run.
+//
+// CHECK: Running pass:{{.*}}CoroCleanupPass
+// CHECK: Finished llvm::Module 

[PATCH] D69868: Allow "callbr" to return non-void values

2020-02-18 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D69868#1881985 , @void wrote:

> It's been almost a month since the last comments on this review. If you need 
> more time, please comment here. Otherwise, I will submit this with the 
> current approvals by the end of the week.


Explicit ping @nickdesaulniers, who blocked this, and @jyknight and @rnk, both 
explicitly requested by @MaskRay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69868



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


[PATCH] D69868: Allow "callbr" to return non-void values

2020-02-18 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

It's been almost a month since the last comments on this review. If you need 
more time, please comment here. Otherwise, I will submit this with the current 
approvals by the end of the week.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69868



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


[PATCH] D72231: [Sema] Adds the pointer-to-int-cast diagnostic

2020-02-18 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

In D72231#1881855 , @rjmccall wrote:

> In D72231#1881797 , @nickdesaulniers 
> wrote:
>
> > In D72231#1881784 , @rjmccall 
> > wrote:
> >
> > > In D72231#1881760 , 
> > > @nickdesaulniers wrote:
> > >
> > > > In D72231#1879347 , @rjmccall 
> > > > wrote:
> > > >
> > > > > In D72231#1878528 , 
> > > > > @nathanchance wrote:
> > > > >
> > > > > > There appear to a be semantic difference between GCC and clang with 
> > > > > > the current version of this patch which results in a lot of 
> > > > > > additional warnings in the Linux kernel: 
> > > > > > https://godbolt.org/z/eHFJd8
> > > > >
> > > > >
> > > > > Warning about casting to an enum seems clearly correct and in scope 
> > > > > for this warning.  Warning about casting to `_Bool` seems clearly 
> > > > > incorrect and should not be warned about at all.
> > > >
> > > >
> > > > Maybe we should only warn if the size of the `void*` is smaller than 
> > > > the size of the `enum`? (32b `void*`, 64b `enum`)? 
> > > > https://godbolt.org/z/oAts-u
> > > >
> > > > Otherwise this warning creates a massive mess for us to clean up, and I 
> > > > suspect Linux kernel developers will just end up disabling the warning.
> > >
> > >
> > > If deployment is easier if we split out a subgroup that we can turn off, 
> > > that seems fine.  But I don't see any good abstract justification for 
> > > warning about a cast to `int` and not a cast to an `int`-sized `enum`.  
> > > What would the reasoning be, just that the latter "couldn't possibly" be 
> > > intended to preserve the original pointer value, so it must be an opaque 
> > > value being represented as a `void*`?  That seems pretty weak to me.
> >
> >
> > Less about enums, more about casts to/from void*, since you might use that 
> > in place of a union that would be too large to describe.  Specifically, 
> > this `struct` is used throughout the kernel for most drivers: 
> > https://elixir.bootlin.com/linux/v5.5.4/source/include/linux/mod_devicetable.h#L260
> >   It is exceedingly common to stuff whatever data in there: 
> > https://elixir.bootlin.com/linux/v5.5.4/source/drivers/ata/ahci_brcm.c#L428 
> > so long as the driver is careful not to reinterpret the data as the 
> > incorrect type.  Describing such a union for ever possible enum packed in 
> > there would not be fun.
>
>
> No, I understand the pattern, but they must have already done some sort of 
> pass over the code to make it warning-clean when they're working with a 
> smaller integer type.  Or do they just in practice never store smaller 
> integers in there, whereas it's hard to control size with an enum?


Yes, if the data is a regular `int`, rather than an `enum`, all of the 
callsites either cast to `long` or `uintptr_t` (which is typedef'd in the 
kernel to `unsigned long`). There are a lot fewer of those spots in the kernel 
(at least from my super quick `rg` search), most of the spots use an `enum`, 
maybe to purposefully avoid this warning? Most, if not all the sites, only 
store a number that is less than 5 because they use that number to determine 
exactly which device is present from the match data so the driver can handle 
different quirks with things like case statements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72231



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


[PATCH] D74812: [Sema] Teach -Warm-interrupt-safety about func ptrs

2020-02-18 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs marked an inline comment as done.
jroelofs added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:5931
+  if (Caller->hasAttr()) {
+const Decl *CalleeDecl = FDecl;
+if (const auto *UO = dyn_cast(Fn->IgnoreParens())) {

This feels very fragile, and I know is missing at least one case. Is there a 
better way to reliably get at the typedef's attributes from here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74812



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


[PATCH] D74812: [Sema] Teach -Warm-interrupt-safety about func ptrs

2020-02-18 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs created this revision.
jroelofs added reviewers: efriedma, weimingz, EricWF.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.

Fixes:

  https://bugs.llvm.org/show_bug.cgi?id=35527
  https://bugs.llvm.org/show_bug.cgi?id=35528


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74812

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/arm-interrupt-attr.c

Index: clang/test/Sema/arm-interrupt-attr.c
===
--- clang/test/Sema/arm-interrupt-attr.c
+++ clang/test/Sema/arm-interrupt-attr.c
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 %s -triple arm-apple-darwin  -target-feature +vfp2 -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple thumb-apple-darwin  -target-feature +vfp3 -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple armeb-none-eabi  -target-feature +vfp4 -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple thumbeb-none-eabi  -target-feature +neon -verify -fsyntax-only
-// RUN: %clang_cc1 %s -triple thumbeb-none-eabi -target-feature +neon -target-feature +soft-float -DSOFT -verify -fsyntax-only
+// RUN: %clang_cc1 %s -Warm-interrupt-safety -triple arm-apple-darwin  -target-feature +vfp2 -verify -fsyntax-only
+// RUN: %clang_cc1 %s -Warm-interrupt-safety -triple thumb-apple-darwin  -target-feature +vfp3 -verify -fsyntax-only
+// RUN: %clang_cc1 %s -Warm-interrupt-safety -triple armeb-none-eabi  -target-feature +vfp4 -verify -fsyntax-only
+// RUN: %clang_cc1 %s -Warm-interrupt-safety -triple thumbeb-none-eabi  -target-feature +neon -verify -fsyntax-only
+// RUN: %clang_cc1 %s -Warm-interrupt-safety -triple thumbeb-none-eabi -target-feature +neon -target-feature +soft-float -DSOFT -verify -fsyntax-only
 
 __attribute__((interrupt(IRQ))) void foo() {} // expected-error {{'interrupt' attribute requires a string}}
 __attribute__((interrupt("irq"))) void foo1() {} // expected-warning {{'interrupt' attribute argument not supported: irq}}
@@ -26,24 +26,36 @@
   callee2();
 }
 
-#ifndef SOFT
 __attribute__((interrupt("IRQ"))) void caller2() {
+#ifndef SOFT
   callee1(); // expected-warning {{call to function without interrupt attribute could clobber interruptee's VFP registers}}
-  callee2();
-}
-
-void (*callee3)();
-__attribute__((interrupt("IRQ"))) void caller3() {
-  callee3(); // expected-warning {{call to function without interrupt attribute could clobber interruptee's VFP registers}}
-}
 #else
-__attribute__((interrupt("IRQ"))) void caller2() {
   callee1();
+#endif
   callee2();
 }
 
 void (*callee3)();
 __attribute__((interrupt("IRQ"))) void caller3() {
+#ifndef SOFT
+  callee3(); // expected-warning {{call to function without interrupt attribute could clobber interruptee's VFP registers}}
+#else
   callee3();
+#endif
 }
+
+void __attribute__((interrupt("IRQ"))) bugzilla35527() {
+  typedef void __attribute__((interrupt("IRQ"))) (*interrupt_callback_t)(int i, void *ctx);
+  interrupt_callback_t interrupt_callee;
+  interrupt_callee(42, 0);
+  (interrupt_callee)(42, 0);
+  (*interrupt_callee)(42, 0);
+
+  typedef void (*callback_t)(int i, void *ctx);
+  callback_t callee;
+#ifndef SOFT
+  callee(37, 0); // expected-warning {{call to function without interrupt attribute could clobber interruptee's VFP registers}}
+#else
+  callee(37, 0);
 #endif
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -5925,12 +5925,20 @@
   // so there's some risk when calling out to non-interrupt handler functions
   // that the callee might not preserve them. This is easy to diagnose here,
   // but can be very challenging to debug.
-  if (auto *Caller = getCurFunctionDecl())
-if (Caller->hasAttr()) {
-  bool VFP = Context.getTargetInfo().hasFeature("vfp");
-  if (VFP && (!FDecl || !FDecl->hasAttr()))
-Diag(Fn->getExprLoc(), diag::warn_arm_interrupt_calling_convention);
-}
+  if (Context.getTargetInfo().hasFeature("vfp"))
+if (auto *Caller = getCurFunctionDecl())
+  if (Caller->hasAttr()) {
+const Decl *CalleeDecl = FDecl;
+if (const auto *UO = dyn_cast(Fn->IgnoreParens())) {
+  if (const auto *TT =
+  dyn_cast(UO->getSubExpr()->getType()))
+CalleeDecl = TT->getDecl();
+} else if (const auto *TT = Fn->getType()->getAs()) {
+  CalleeDecl = TT->getDecl();
+}
+if (!CalleeDecl || !CalleeDecl->hasAttr())
+  Diag(Fn->getExprLoc(), diag::warn_arm_interrupt_calling_convention);
+  }
 
   // Promote the function operand.
   // We special-case function promotion here because we only allow promoting
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td

[PATCH] D73242: [WPD/LowerTypeTests] Delay lowering/removal of type tests until after ICP

2020-02-18 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

There seems to be still an issue with this patch, when linking the LLVM unit 
tests on a two-stage build, it ends with:

  FAILED: tools/clang/unittests/StaticAnalyzer/StaticAnalysisTests.exe
  cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe 
--intdir=tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir
 --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe 
--mt=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\mt.exe --manifests  -- 
D:\llvm-project\buildninjaRel\bin\lld-link.exe /nologo 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\AnalyzerOptionsTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\CallDescriptionTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\StoreTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\RegisterCustomCheckersTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\SymbolReaperTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\D_\llvm-project\llvm\resources\windows_version_resource.rc.res
  /out:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.exe 
/implib:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.lib 
/pdb:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.pdb /version:0.0  
/machine:x64 -fuse-ld=lld /STACK:1000 /DEBUG /OPT:REF /OPT:ICF 
/lldltocache:D:/llvm-project/buildninjaRelMiMalloc/lto.cache /INCREMENTAL:NO 
/subsystem:console  lib\LLVMSupport.lib  lib\LLVMSupport.lib  
lib\gtest_main.lib  lib\gtest.lib  lib\clangBasic.lib  lib\clangAnalysis.lib  
lib\clangAST.lib  lib\clangASTMatchers.lib  lib\clangCrossTU.lib  
lib\clangFrontend.lib  lib\clangSerialization.lib  
lib\clangStaticAnalyzerCore.lib  lib\clangStaticAnalyzerFrontend.lib  
lib\clangTooling.lib  lib\clangStaticAnalyzerCheckers.lib  
lib\clangStaticAnalyzerCore.lib  lib\clangCrossTU.lib  lib\clangIndex.lib  
lib\clangFrontend.lib  lib\clangParse.lib  lib\clangSerialization.lib  
lib\clangSema.lib  lib\clangAnalysis.lib  lib\clangASTMatchers.lib  
lib\clangEdit.lib  lib\clangDriver.lib  version.lib  lib\LLVMOption.lib  
lib\clangFormat.lib  lib\clangToolingInclusions.lib  lib\clangToolingCore.lib  
lib\clangAST.lib  lib\LLVMFrontendOpenMP.lib  lib\LLVMTransformUtils.lib  
lib\LLVMAnalysis.lib  lib\LLVMProfileData.lib  lib\LLVMObject.lib  
lib\LLVMBitReader.lib  lib\LLVMMCParser.lib  lib\LLVMTextAPI.lib  
lib\clangRewrite.lib  lib\clangLex.lib  lib\clangBasic.lib  lib\LLVMCore.lib  
lib\LLVMRemarks.lib  lib\LLVMBitstreamReader.lib  lib\LLVMMC.lib  
lib\LLVMBinaryFormat.lib  lib\LLVMDebugInfoCodeView.lib  
lib\LLVMDebugInfoMSF.lib  lib\LLVMSupport.lib  psapi.lib  shell32.lib  
ole32.lib  uuid.lib  advapi32.lib  delayimp.lib  -delayload:shell32.dll  
-delayload:ole32.dll  lib\LLVMDemangle.lib  kernel32.lib user32.lib gdi32.lib 
winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib 
advapi32.lib && cd ."
  LINK: command "D:\llvm-project\buildninjaRel\bin\lld-link.exe /nologo 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\AnalyzerOptionsTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\CallDescriptionTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\StoreTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\RegisterCustomCheckersTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\SymbolReaperTest.cpp.obj
 
tools\clang\unittests\StaticAnalyzer\CMakeFiles\StaticAnalysisTests.dir\D_\llvm-project\llvm\resources\windows_version_resource.rc.res
 /out:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.exe 
/implib:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.lib 
/pdb:tools\clang\unittests\StaticAnalyzer\StaticAnalysisTests.pdb /version:0.0 
/machine:x64 -fuse-ld=lld /STACK:1000 /DEBUG /OPT:REF /OPT:ICF 
/lldltocache:D:/llvm-project/buildninjaRelMiMalloc/lto.cache /INCREMENTAL:NO 
/subsystem:console lib\LLVMSupport.lib lib\LLVMSupport.lib lib\gtest_main.lib 
lib\gtest.lib lib\clangBasic.lib lib\clangAnalysis.lib lib\clangAST.lib 
lib\clangASTMatchers.lib lib\clangCrossTU.lib lib\clangFrontend.lib 
lib\clangSerialization.lib lib\clangStaticAnalyzerCore.lib 
lib\clangStaticAnalyzerFrontend.lib lib\clangTooling.lib 
lib\clangStaticAnalyzerCheckers.lib lib\clangStaticAnalyzerCore.lib 
lib\clangCrossTU.lib lib\clangIndex.lib lib\clangFrontend.lib 
lib\clangParse.lib lib\clangSerialization.lib lib\clangSema.lib 
lib\clangAnalysis.lib lib\clangASTMatchers.lib lib\clangEdit.lib 
lib\clangDriver.lib version.lib lib\LLVMOption.lib lib\clangFormat.lib 
lib\clangToolingInclusions.lib lib\clangToolingCore.lib lib\clangAST.lib 
lib\LLVMFrontendOpenMP.lib lib\LLVMTransformUtils.lib lib\LLVMAnalysis.lib 
lib\LLVMProfileData.lib 

[clang] 061f3a5 - P0593R6: Pseudo-destructor expressions end object lifetimes.

2020-02-18 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-02-18T18:41:03-08:00
New Revision: 061f3a50dd824f1eb2394d0f699f3f2ee374b21a

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

LOG: P0593R6: Pseudo-destructor expressions end object lifetimes.

This only has an observable effect on constant evaluation.

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/test/CXX/expr/expr.const/p2-0x.cpp
clang/test/SemaCXX/constant-expression-cxx2a.cpp
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 641368ebfdd9..9a31b64eedda 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -1417,6 +1417,31 @@ static bool isFormalAccess(AccessKinds AK) {
   return isAnyAccess(AK) && AK != AK_Construct && AK != AK_Destroy;
 }
 
+/// Is this kind of axcess valid on an indeterminate object value?
+static bool isValidIndeterminateAccess(AccessKinds AK) {
+  switch (AK) {
+  case AK_Read:
+  case AK_Increment:
+  case AK_Decrement:
+// These need the object's value.
+return false;
+
+  case AK_ReadObjectRepresentation:
+  case AK_Assign:
+  case AK_Construct:
+  case AK_Destroy:
+// Construction and destruction don't need the value.
+return true;
+
+  case AK_MemberCall:
+  case AK_DynamicCast:
+  case AK_TypeId:
+// These aren't really meaningful on scalars.
+return true;
+  }
+  llvm_unreachable("unknown access kind");
+}
+
 namespace {
   struct ComplexValue {
   private:
@@ -3201,9 +3226,8 @@ findSubobject(EvalInfo , const Expr *E, const 
CompleteObject ,
   for (unsigned I = 0, N = Sub.Entries.size(); /**/; ++I) {
 // Reading an indeterminate value is undefined, but assigning over one is 
OK.
 if ((O->isAbsent() && !(handler.AccessKind == AK_Construct && I == N)) ||
-(O->isIndeterminate() && handler.AccessKind != AK_Construct &&
- handler.AccessKind != AK_Assign &&
- handler.AccessKind != AK_ReadObjectRepresentation)) {
+(O->isIndeterminate() &&
+ !isValidIndeterminateAccess(handler.AccessKind))) {
   if (!Info.checkingPotentialConstantExpression())
 Info.FFDiag(E, diag::note_constexpr_access_uninit)
 << handler.AccessKind << O->isIndeterminate();
@@ -5476,6 +5500,8 @@ static bool EvaluateArgs(ArrayRef Args, 
ArgVector ,
 }
 }
   }
+  // FIXME: This is the wrong evaluation order for an assignment operator
+  // called via operator syntax.
   for (unsigned Idx = 0; Idx < Args.size(); Idx++) {
 if (!Evaluate(ArgValues[Idx], Info, Args[Idx])) {
   // If we're checking for a potential constant expression, evaluate all
@@ -6936,10 +6962,8 @@ class ExprEvaluatorBase
   } else if (const auto *PDE = dyn_cast(Callee)) {
 if (!Info.getLangOpts().CPlusPlus2a)
   Info.CCEDiag(PDE, diag::note_constexpr_pseudo_destructor);
-// FIXME: If pseudo-destructor calls ever start ending the lifetime of
-// their callee, we should start calling HandleDestruction here.
-// For now, we just evaluate the object argument and discard it.
-return EvaluateObjectArgument(Info, PDE->getBase(), ThisVal);
+return EvaluateObjectArgument(Info, PDE->getBase(), ThisVal) &&
+   HandleDestruction(Info, PDE, ThisVal, PDE->getDestroyedType());
   } else
 return Error(Callee);
   FD = Member;

diff  --git a/clang/test/CXX/expr/expr.const/p2-0x.cpp 
b/clang/test/CXX/expr/expr.const/p2-0x.cpp
index cc6380e044fb..c418767f8d12 100644
--- a/clang/test/CXX/expr/expr.const/p2-0x.cpp
+++ b/clang/test/CXX/expr/expr.const/p2-0x.cpp
@@ -424,8 +424,26 @@ namespace PseudoDtor {
   int k;
   typedef int I;
   struct T {
-int n : (k.~I(), 1); // cxx11-warning {{constant expression}} cxx11-note 
{{pseudo-destructor}}
+int n : (k.~I(), 1); // expected-error {{constant expression}} 
expected-note {{visible outside that expression}}
   };
+
+  // FIXME: It's unclear whether this should be accepted in C++20 mode. The 
parameter is destroyed twice here.
+  constexpr int f(int a = 1) { // cxx11-error {{constant expression}}
+return (
+a.~I(), // cxx11-note 2{{pseudo-destructor}}
+0);
+  }
+  static_assert(f() == 0, ""); // cxx11-error {{constant expression}} 
cxx11-note {{in call}}
+
+  // This is OK in C++20: the union has no active member after the
+  // pseudo-destructor call, so the union destructor has no effect.
+  union U { int x; };
+  constexpr int g(U u = {1}) { // cxx11-error {{constant expression}}
+return (
+u.x.~I(), // cxx11-note 2{{pseudo-destructor}}
+0);
+  }
+  static_assert(g() == 0, ""); // cxx11-error {{constant expression}} 
cxx11-note {{in call}}
 }
 
 // - increment or decrement operations 

[PATCH] D74811: [Driver] Escape the program path for -frecord-command-line

2020-02-18 Thread Ravi Ramaseshan via Phabricator via cfe-commits
ravi-ramaseshan created this revision.
ravi-ramaseshan added reviewers: scott.linder, rjmccall.
Herald added a project: clang.

Similar to the rest of the command line that is recorded, the program
path must also have spaces and backslashes escaped. Without this
parsing the recorded command line becomes hard on platforms like
Windows where spaces and backslashes are common.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74811

Files:
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5880,7 +5880,7 @@
   Arg->render(Args, OriginalArgs);
 
 SmallString<256> Flags;
-Flags += Exec;
+EscapeSpacesAndBackslashes(Exec, Flags);
 for (const char *OriginalArg : OriginalArgs) {
   SmallString<128> EscapedArg;
   EscapeSpacesAndBackslashes(OriginalArg, EscapedArg);
@@ -6788,7 +6788,7 @@
 
 SmallString<256> Flags;
 const char *Exec = getToolChain().getDriver().getClangProgramPath();
-Flags += Exec;
+EscapeSpacesAndBackslashes(Exec, Flags);
 for (const char *OriginalArg : OriginalArgs) {
   SmallString<128> EscapedArg;
   EscapeSpacesAndBackslashes(OriginalArg, EscapedArg);


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5880,7 +5880,7 @@
   Arg->render(Args, OriginalArgs);
 
 SmallString<256> Flags;
-Flags += Exec;
+EscapeSpacesAndBackslashes(Exec, Flags);
 for (const char *OriginalArg : OriginalArgs) {
   SmallString<128> EscapedArg;
   EscapeSpacesAndBackslashes(OriginalArg, EscapedArg);
@@ -6788,7 +6788,7 @@
 
 SmallString<256> Flags;
 const char *Exec = getToolChain().getDriver().getClangProgramPath();
-Flags += Exec;
+EscapeSpacesAndBackslashes(Exec, Flags);
 for (const char *OriginalArg : OriginalArgs) {
   SmallString<128> EscapedArg;
   EscapeSpacesAndBackslashes(OriginalArg, EscapedArg);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 28728bf - Fix a signed/unsigned warning promoted to error.

2020-02-18 Thread Eric Christopher via cfe-commits

Author: Eric Christopher
Date: 2020-02-18T17:49:22-08:00
New Revision: 28728bf06f556dc8be5bc1fa77129906ba68

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

LOG: Fix a signed/unsigned warning promoted to error.

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
index d365bbbe3c43..2938e2b9c7cd 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -86,7 +86,7 @@ static bool checkParamDeclOfAncestorCallExprHasRValueRefType(
   if (const clang::CallExpr *TheCallExpr =
   tryGetCallExprAncestorForCxxConstructExpr(TheCxxConstructExpr,
 Context)) {
-for (int i = 0; i < TheCallExpr->getNumArgs(); ++i) {
+for (unsigned i = 0; i < TheCallExpr->getNumArgs(); ++i) {
   const Expr *Arg = TheCallExpr->getArg(i);
   if (Arg->getSourceRange() == TheCxxConstructExpr->getSourceRange()) {
 if (const auto *TheCallExprFuncProto =



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


[PATCH] D72231: [Sema] Adds the pointer-to-int-cast diagnostic

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D72231#1881855 , @rjmccall wrote:

> No, I understand the pattern, but they must have already done some sort of 
> pass over the code to make it warning-clean when they're working with a 
> smaller integer type.  Or do they just in practice never store smaller 
> integers in there, whereas it's hard to control size with an enum?


Unsure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72231



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


[clang] 492d4a9 - [NFC] Update the testcase clang_f_opts.c for the removed options

2020-02-18 Thread Jim Lin via cfe-commits

Author: Jim Lin
Date: 2020-02-19T09:28:41+08:00
New Revision: 492d4a992d88516da471b60ecd9a37ea80dbf9a4

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

LOG: [NFC] Update the testcase clang_f_opts.c for the removed options

Added: 


Modified: 
clang/test/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/test/Driver/clang_f_opts.c 
b/clang/test/Driver/clang_f_opts.c
index 3d0d74ba5ab9..6fb820a9938d 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -364,9 +364,6 @@
 // RUN: -frename-registers\
 // RUN: -fschedule-insns2 \
 // RUN: -fsingle-precision-constant   \
-// RUN: -ftree_loop_im\
-// RUN: -ftree_loop_ivcanon   \
-// RUN: -ftree_loop_linear\
 // RUN: -funsafe-loop-optimizations   \
 // RUN: -fuse-linker-plugin   \
 // RUN: -fvect-cost-model \



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


[PATCH] D73649: [CodeComplete] Member completion for concept-constrained types.

2020-02-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 3 inline comments as done.
sammccall added inline comments.



Comment at: clang/lib/Sema/CodeCompleteConsumer.cpp:592
 }
+for (const FixItHint  : Results[I].FixIts) {
+  const SourceLocation BLoc = FixIt.RemoveRange.getBegin();

(This is just a fix to the -code-complete-at testing facility: it wasn't 
printing fixits for RK_Pattern completions)



Comment at: clang/test/CodeCompletion/concepts.cpp:34
+  // RUN: | FileCheck %s -check-prefix=DOT -implicit-check-not=xxx_t
+  // DOT: Pattern : [#convertible_to#]aaa()
+  // DOT: Pattern : bb() (requires fix-it: {{.*}} to "->")

nridge wrote:
> Doesn't the presence of the `x` mean we should only get results that start 
> with `x`?
> 
> (Or, if "column 5" actually means we're completing right after the dot, why 
> is the `x` present in the testcase at all -- just so that the line is 
> syntactically well formed?)
Yeah we're completing before the x.
And in fact it doesn't matter, since clang's internal completion engine doesn't 
filter the results using the incomplete identifier (which is what lets clangd 
apply its own fuzzy-matching rules).

I think this is well-enough understood around the CodeCompletion tests and I 
tend to worry about incomplete lines confusing the parser (I don't want to 
repeat this function decl 3 times!), but I can try to drop these if you think 
it makes a big difference.



Comment at: clang/test/CodeCompletion/concepts.cpp:35
+  // DOT: Pattern : [#convertible_to#]aaa()
+  // DOT: Pattern : bb() (requires fix-it: {{.*}} to "->")
+  // DOT: Pattern : bbb()

nridge wrote:
> Should we be taking completions from just one branch of a logical-or in a 
> requirement?
> 
> To simplify the scenario a bit:
> 
> ```
> template 
>   requires (requires(T t) { t.foo(); } || requires(T t) { t.bar(); })
> void f(T t) {
>   t.^
> }
> ```
> 
> Do we want to be offering both `foo()` and `bar()` as completions here? 
> Logically, it seems we only ought to offer completions from expressions that 
> appear in _both_ branches of the logical-or (so, if `t.foo()` appeared as a 
> requirement in both branches, we could offer `foo()`).
Strictly speaking yes, a function is only guaranteed available if it's in both 
branches.

In practice I think this behavior would be no more useful (probably less 
useful), and obviously more complicated to implement (as we have to track 
result sets for subexpressions to intersect them).

AIUI the language has no way to force you to only use properties guaranteed by 
the constraints. So it's perfectly plausible to write something like (forgive 
suspicious syntax)
```template  requires Dumpable || Printable
void output(const T ) {
  if constexpr (Dumpable)
val.dump();
  else
val.print();
}```

Or even cases where the same expression is valid in all cases but we lose track 
of that somehow (e.g. T is either a dumb pointer or a smart pointer to a 
constrained type, and our analysis fails on the smart pointer case).

Basically I think we're desperate enough for information in these scenarios 
that we'll accept a little inaccuracy :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73649



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


[PATCH] D72231: [Sema] Adds the pointer-to-int-cast diagnostic

2020-02-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D72231#1881797 , @nickdesaulniers 
wrote:

> In D72231#1881784 , @rjmccall wrote:
>
> > In D72231#1881760 , 
> > @nickdesaulniers wrote:
> >
> > > In D72231#1879347 , @rjmccall 
> > > wrote:
> > >
> > > > In D72231#1878528 , 
> > > > @nathanchance wrote:
> > > >
> > > > > There appear to a be semantic difference between GCC and clang with 
> > > > > the current version of this patch which results in a lot of 
> > > > > additional warnings in the Linux kernel: https://godbolt.org/z/eHFJd8
> > > >
> > > >
> > > > Warning about casting to an enum seems clearly correct and in scope for 
> > > > this warning.  Warning about casting to `_Bool` seems clearly incorrect 
> > > > and should not be warned about at all.
> > >
> > >
> > > Maybe we should only warn if the size of the `void*` is smaller than the 
> > > size of the `enum`? (32b `void*`, 64b `enum`)? 
> > > https://godbolt.org/z/oAts-u
> > >
> > > Otherwise this warning creates a massive mess for us to clean up, and I 
> > > suspect Linux kernel developers will just end up disabling the warning.
> >
> >
> > If deployment is easier if we split out a subgroup that we can turn off, 
> > that seems fine.  But I don't see any good abstract justification for 
> > warning about a cast to `int` and not a cast to an `int`-sized `enum`.  
> > What would the reasoning be, just that the latter "couldn't possibly" be 
> > intended to preserve the original pointer value, so it must be an opaque 
> > value being represented as a `void*`?  That seems pretty weak to me.
>
>
> Less about enums, more about casts to/from void*, since you might use that in 
> place of a union that would be too large to describe.  Specifically, this 
> `struct` is used throughout the kernel for most drivers: 
> https://elixir.bootlin.com/linux/v5.5.4/source/include/linux/mod_devicetable.h#L260
>   It is exceedingly common to stuff whatever data in there: 
> https://elixir.bootlin.com/linux/v5.5.4/source/drivers/ata/ahci_brcm.c#L428 
> so long as the driver is careful not to reinterpret the data as the incorrect 
> type.  Describing such a union for ever possible enum packed in there would 
> not be fun.


No, I understand the pattern, but they must have already done some sort of pass 
over the code to make it warning-clean when they're working with a smaller 
integer type.  Or do they just in practice never store smaller integers in 
there, whereas it's hard to control size with an enum?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72231



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


[PATCH] D74790: [Sema][CodeComplete] Handle symlinks for include code completion

2020-02-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks! I can't see this being a performance problem (famous last words...)




Comment at: clang/lib/Sema/SemaCodeComplete.cpp:8780
+
+  // We need to manually resolve symlinks since the directory_iterator
+  // doesn't do it for us. Alternatively we could use a heuristic such as

I think we can state the problem more directly here:

To know whether a symlink should be treated as file or a directory, we have to 
stat it.
This is cheap enough as there shouldn't be many symlinks.

(I think we can drop the heuristic idea from the comment, it was a silly 
premature optimization)



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:8784
+  // symlinks.
+  auto Type = It->type();
+  if (Type == llvm::sys::fs::file_type::symlink_file) {

nit: expand auto here, "type" is vague and `It` is already auto



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:8786
+  if (Type == llvm::sys::fs::file_type::symlink_file) {
+auto FileStatus = FS.status(It->path());
+if (FileStatus) {

nit: inline (`if (auto FileStatus = ...)`)
drop braces around inner if


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74790



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


[PATCH] D74807: Add cl_khr_mipmap_image_writes as supported to AMDGPU

2020-02-18 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: b-sumner.
Herald added subscribers: kerbowa, t-tye, tpr, dstuttard, nhaehnle, wdng, 
jvesely, kzhuravl.

https://reviews.llvm.org/D74807

Files:
  clang/lib/Basic/Targets/AMDGPU.h


Index: clang/lib/Basic/Targets/AMDGPU.h
===
--- clang/lib/Basic/Targets/AMDGPU.h
+++ clang/lib/Basic/Targets/AMDGPU.h
@@ -263,6 +263,7 @@
   Opts.support("cl_khr_int64_base_atomics");
   Opts.support("cl_khr_int64_extended_atomics");
   Opts.support("cl_khr_mipmap_image");
+  Opts.support("cl_khr_mipmap_image_writes");
   Opts.support("cl_khr_subgroups");
   Opts.support("cl_khr_3d_image_writes");
   Opts.support("cl_amd_media_ops");


Index: clang/lib/Basic/Targets/AMDGPU.h
===
--- clang/lib/Basic/Targets/AMDGPU.h
+++ clang/lib/Basic/Targets/AMDGPU.h
@@ -263,6 +263,7 @@
   Opts.support("cl_khr_int64_base_atomics");
   Opts.support("cl_khr_int64_extended_atomics");
   Opts.support("cl_khr_mipmap_image");
+  Opts.support("cl_khr_mipmap_image_writes");
   Opts.support("cl_khr_subgroups");
   Opts.support("cl_khr_3d_image_writes");
   Opts.support("cl_amd_media_ops");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72825: Remove unused option that gcc ignored

2020-02-18 Thread Jim Lin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGea789f819f26: Remove unused option that gcc ignored 
(authored by Jim).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72825

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/clang_f_opts.c


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -291,9 +291,6 @@
 // RUN: -frename-registers\
 // RUN: -fschedule-insns2 \
 // RUN: -fsingle-precision-constant   \
-// RUN: -ftree_loop_im\
-// RUN: -ftree_loop_ivcanon   \
-// RUN: -ftree_loop_linear\
 // RUN: -funsafe-loop-optimizations   \
 // RUN: -fuse-linker-plugin   \
 // RUN: -fvect-cost-model \
@@ -431,9 +428,6 @@
 // CHECK-WARNING-DAG: optimization flag '-frename-registers' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fschedule-insns2' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fsingle-precision-constant' is not 
supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_im' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_ivcanon' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_linear' is not supported
 // CHECK-WARNING-DAG: optimization flag '-funsafe-loop-optimizations' is not 
supported
 // CHECK-WARNING-DAG: optimization flag '-fuse-linker-plugin' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fvect-cost-model' is not supported
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3325,9 +3325,6 @@
 defm tls_model : BooleanFFlag<"tls-model">, Group;
 defm tracer : BooleanFFlag<"tracer">, 
Group;
 defm tree_dce : BooleanFFlag<"tree-dce">, 
Group;
-defm tree_loop_im : BooleanFFlag<"tree_loop_im">,  
Group;
-defm tree_loop_ivcanon : BooleanFFlag<"tree_loop_ivcanon">,  
Group;
-defm tree_loop_linear : BooleanFFlag<"tree_loop_linear">,  
Group;
 defm tree_salias : BooleanFFlag<"tree-salias">, Group;
 defm tree_ter : BooleanFFlag<"tree-ter">, 
Group;
 defm tree_vectorizer_verbose : BooleanFFlag<"tree-vectorizer-verbose">, 
Group;


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -291,9 +291,6 @@
 // RUN: -frename-registers\
 // RUN: -fschedule-insns2 \
 // RUN: -fsingle-precision-constant   \
-// RUN: -ftree_loop_im\
-// RUN: -ftree_loop_ivcanon   \
-// RUN: -ftree_loop_linear\
 // RUN: -funsafe-loop-optimizations   \
 // RUN: -fuse-linker-plugin   \
 // RUN: -fvect-cost-model \
@@ -431,9 +428,6 @@
 // CHECK-WARNING-DAG: optimization flag '-frename-registers' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fschedule-insns2' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fsingle-precision-constant' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_im' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_ivcanon' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_linear' is not supported
 // CHECK-WARNING-DAG: optimization flag '-funsafe-loop-optimizations' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fuse-linker-plugin' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fvect-cost-model' is not supported
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3325,9 +3325,6 @@
 defm tls_model : BooleanFFlag<"tls-model">, Group;
 defm tracer : BooleanFFlag<"tracer">, Group;
 defm tree_dce : BooleanFFlag<"tree-dce">, Group;
-defm tree_loop_im : BooleanFFlag<"tree_loop_im">,  Group;
-defm tree_loop_ivcanon : BooleanFFlag<"tree_loop_ivcanon">,  Group;

[clang] ea789f8 - Remove unused option that gcc ignored

2020-02-18 Thread Jim Lin via cfe-commits

Author: Jim Lin
Date: 2020-02-19T08:36:07+08:00
New Revision: ea789f819f26a1b003a1bf07466fc9fa2fe558ec

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

LOG: Remove unused option that gcc ignored

Reviewers: efriedma, MaskRay

Reviewed By: efriedma, MaskRay

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 1a42925ca530..4104a4ae6ed0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3325,9 +3325,6 @@ defm strength_reduce :
 defm tls_model : BooleanFFlag<"tls-model">, Group;
 defm tracer : BooleanFFlag<"tracer">, 
Group;
 defm tree_dce : BooleanFFlag<"tree-dce">, 
Group;
-defm tree_loop_im : BooleanFFlag<"tree_loop_im">,  
Group;
-defm tree_loop_ivcanon : BooleanFFlag<"tree_loop_ivcanon">,  
Group;
-defm tree_loop_linear : BooleanFFlag<"tree_loop_linear">,  
Group;
 defm tree_salias : BooleanFFlag<"tree-salias">, Group;
 defm tree_ter : BooleanFFlag<"tree-ter">, 
Group;
 defm tree_vectorizer_verbose : BooleanFFlag<"tree-vectorizer-verbose">, 
Group;

diff  --git a/clang/test/Driver/clang_f_opts.c 
b/clang/test/Driver/clang_f_opts.c
index 970b4e934e78..3d0d74ba5ab9 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -291,9 +291,6 @@
 // RUN: -frename-registers\
 // RUN: -fschedule-insns2 \
 // RUN: -fsingle-precision-constant   \
-// RUN: -ftree_loop_im\
-// RUN: -ftree_loop_ivcanon   \
-// RUN: -ftree_loop_linear\
 // RUN: -funsafe-loop-optimizations   \
 // RUN: -fuse-linker-plugin   \
 // RUN: -fvect-cost-model \
@@ -431,9 +428,6 @@
 // CHECK-WARNING-DAG: optimization flag '-frename-registers' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fschedule-insns2' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fsingle-precision-constant' is not 
supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_im' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_ivcanon' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_linear' is not supported
 // CHECK-WARNING-DAG: optimization flag '-funsafe-loop-optimizations' is not 
supported
 // CHECK-WARNING-DAG: optimization flag '-fuse-linker-plugin' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fvect-cost-model' is not supported



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


[PATCH] D74806: [analyzer] NFCi: Refactor CStringChecker: use strongly typed internal API

2020-02-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: NoQ, baloghadamsoftware, Szelethus.
steakhal added a project: clang.
Herald added subscribers: cfe-commits, martong, Charusso, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, whisperity.
Herald added a reviewer: rengolin.
steakhal edited the summary of this revision.
steakhal updated this revision to Diff 245300.
steakhal added a comment.

Upload the right diff.


CStringChecker is a huge beast.

My effort in improving the analyzer regarding taint analysis is humbled by 
multiple factors.
I wanted to extend the diagnostics of the CStringChecker with taintedness.

In the long run, the diagnostic emitting parts of the `GenericTaintChecker` 
would be migrated to multiple checkers, leaving it's responsibility only to 
*model* taint propagation.
Eg. the `GenericTaintChecker::checkTaintedBufferSize` functionality will be 
mostly part of the CStringChecker.

This plan requires the `CStringChecker` to be refactored to support a more 
flexible reporting mechanism.

This patch does only refactorings, such:

- eliminates always `false` parameters (like `WarnAboutSize`)
- reduces the number of parameters
- makes strong types differentiating *source* and *destination* buffers (same 
with size expressions)
- binds the argument expression and the index, making diagnostics accurate and 
easy to emit
- removes a bunch of default parameters to make it more readable
- remove random `const char *` warning message parameters, making clear where 
and what is going to be emitted

Note that:

- `CheckBufferAccess` now checks *only* one buffer, this removed about 100 LOC 
code duplication
- not every function was refactored to use the /new/ strongly typed API, since 
the CString related functions are really closely coupled monolithic beasts, I 
will refactor them separately
- all tests are preserved and passing; only *the message changed at some 
places*. In my opinion, these messages are holding the same information.

I would also highlight that this refactoring caught a bug in 
`clang/test/Analysis/string.c:454` where the diagnostic did not reflect 
reality. This catch backs my effort on simplifying this monolithic 
CStringChecker.


Repository:
  rC Clang

https://reviews.llvm.org/D74806

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/bsd-string.c
  clang/test/Analysis/bstring.c
  clang/test/Analysis/null-deref-ps-region.c
  clang/test/Analysis/string.c

Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -353,7 +353,7 @@
 void strcpy_overflow(char *y) {
   char x[4];
   if (strlen(y) == 4)
-strcpy(x, y); // expected-warning{{String copy function overflows destination buffer}}
+strcpy(x, y); // expected-warning{{String copy function overflows the destination buffer}}
 }
 #endif
 
@@ -394,7 +394,7 @@
 void stpcpy_overflow(char *y) {
   char x[4];
   if (strlen(y) == 4)
-stpcpy(x, y); // expected-warning{{String copy function overflows destination buffer}}
+stpcpy(x, y); // expected-warning{{String copy function overflows the destination buffer}}
 }
 #endif
 
@@ -451,19 +451,19 @@
 void strcat_overflow_0(char *y) {
   char x[4] = "12";
   if (strlen(y) == 4)
-strcat(x, y); // expected-warning{{String copy function overflows destination buffer}}
+strcat(x, y); // expected-warning{{String concatenation function overflows the destination buffer}}
 }
 
 void strcat_overflow_1(char *y) {
   char x[4] = "12";
   if (strlen(y) == 3)
-strcat(x, y); // expected-warning{{String copy function overflows destination buffer}}
+strcat(x, y); // expected-warning{{String concatenation function overflows the destination buffer}}
 }
 
 void strcat_overflow_2(char *y) {
   char x[4] = "12";
   if (strlen(y) == 2)
-strcat(x, y); // expected-warning{{String copy function overflows destination buffer}}
+strcat(x, y); // expected-warning{{String concatenation function overflows the destination buffer}}
 }
 #endif
 
@@ -547,25 +547,28 @@
 // of the C-string checker.
 void cstringchecker_bounds_nocrash() {
   char *p = malloc(2);
-  strncpy(p, "AAA", sizeof("AAA")); // expected-warning {{Size argument is greater than the length of the destination buffer}}
+  strncpy(p, "AAA", sizeof("AAA"));
+  // expected-warning@-1 {{String copy function overflows the destination buffer}}
   free(p);
 }
 
 void strncpy_overflow(char *y) {
   char x[4];
   if (strlen(y) == 4)
-strncpy(x, y, 5); // expected-warning{{Size argument is greater than the length of the destination buffer}}
+strncpy(x, y, 5);
+// expected-warning@-1 {{String copy function overflows the destination buffer}}
 #ifndef VARIANT
-  // expected-warning@-2{{size argument is too large; destination buffer has size 4, but size argument is 5}}
+// expected-warning@-3 {{size argument is too large; destination 

[PATCH] D74806: [analyzer] NFCi: Refactor CStringChecker: use strongly typed internal API

2020-02-18 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 245300.
steakhal added a comment.

Upload the right diff.


Repository:
  rC Clang

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

https://reviews.llvm.org/D74806

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/bsd-string.c
  clang/test/Analysis/bstring.c
  clang/test/Analysis/null-deref-ps-region.c
  clang/test/Analysis/string.c

Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -353,7 +353,7 @@
 void strcpy_overflow(char *y) {
   char x[4];
   if (strlen(y) == 4)
-strcpy(x, y); // expected-warning{{String copy function overflows destination buffer}}
+strcpy(x, y); // expected-warning{{String copy function overflows the destination buffer}}
 }
 #endif
 
@@ -394,7 +394,7 @@
 void stpcpy_overflow(char *y) {
   char x[4];
   if (strlen(y) == 4)
-stpcpy(x, y); // expected-warning{{String copy function overflows destination buffer}}
+stpcpy(x, y); // expected-warning{{String copy function overflows the destination buffer}}
 }
 #endif
 
@@ -451,19 +451,19 @@
 void strcat_overflow_0(char *y) {
   char x[4] = "12";
   if (strlen(y) == 4)
-strcat(x, y); // expected-warning{{String copy function overflows destination buffer}}
+strcat(x, y); // expected-warning{{String concatenation function overflows the destination buffer}}
 }
 
 void strcat_overflow_1(char *y) {
   char x[4] = "12";
   if (strlen(y) == 3)
-strcat(x, y); // expected-warning{{String copy function overflows destination buffer}}
+strcat(x, y); // expected-warning{{String concatenation function overflows the destination buffer}}
 }
 
 void strcat_overflow_2(char *y) {
   char x[4] = "12";
   if (strlen(y) == 2)
-strcat(x, y); // expected-warning{{String copy function overflows destination buffer}}
+strcat(x, y); // expected-warning{{String concatenation function overflows the destination buffer}}
 }
 #endif
 
@@ -547,25 +547,28 @@
 // of the C-string checker.
 void cstringchecker_bounds_nocrash() {
   char *p = malloc(2);
-  strncpy(p, "AAA", sizeof("AAA")); // expected-warning {{Size argument is greater than the length of the destination buffer}}
+  strncpy(p, "AAA", sizeof("AAA"));
+  // expected-warning@-1 {{String copy function overflows the destination buffer}}
   free(p);
 }
 
 void strncpy_overflow(char *y) {
   char x[4];
   if (strlen(y) == 4)
-strncpy(x, y, 5); // expected-warning{{Size argument is greater than the length of the destination buffer}}
+strncpy(x, y, 5);
+// expected-warning@-1 {{String copy function overflows the destination buffer}}
 #ifndef VARIANT
-  // expected-warning@-2{{size argument is too large; destination buffer has size 4, but size argument is 5}}
+// expected-warning@-3 {{size argument is too large; destination buffer has size 4, but size argument is 5}}
 #endif
 }
 
 void strncpy_no_overflow(char *y) {
   char x[4];
   if (strlen(y) == 3)
-strncpy(x, y, 5); // expected-warning{{Size argument is greater than the length of the destination buffer}}
+strncpy(x, y, 5);
+// expected-warning@-1 {{String copy function overflows the destination buffer}}
 #ifndef VARIANT
-  // expected-warning@-2{{size argument is too large; destination buffer has size 4, but size argument is 5}}
+// expected-warning@-3 {{size argument is too large; destination buffer has size 4, but size argument is 5}}
 #endif
 }
 
@@ -575,7 +578,8 @@
 
   char x[4];
   if (strlen(y) == 3)
-strncpy(x, y, n); // expected-warning{{Size argument is greater than the length of the destination buffer}}
+strncpy(x, y, n);
+  // expected-warning@-1 {{String copy function overflows the destination buffer}}
 }
 #endif
 
@@ -658,25 +662,29 @@
 void strncat_overflow_0(char *y) {
   char x[4] = "12";
   if (strlen(y) == 4)
-strncat(x, y, strlen(y)); // expected-warning{{Size argument is greater than the free space in the destination buffer}}
+strncat(x, y, strlen(y));
+  // expected-warning@-1 {{String concatenation function overflows the destination buffer}}
 }
 
 void strncat_overflow_1(char *y) {
   char x[4] = "12";
   if (strlen(y) == 3)
-strncat(x, y, strlen(y)); // expected-warning{{Size argument is greater than the free space in the destination buffer}}
+strncat(x, y, strlen(y));
+  // expected-warning@-1 {{String concatenation function overflows the destination buffer}}
 }
 
 void strncat_overflow_2(char *y) {
   char x[4] = "12";
   if (strlen(y) == 2)
-strncat(x, y, strlen(y)); // expected-warning{{Size argument is greater than the free space in the destination buffer}}
+strncat(x, y, strlen(y));
+  // expected-warning@-1 {{String concatenation function overflows the destination buffer}}
 }
 
 void strncat_overflow_3(char *y) {
   char x[4] = "12";
   if (strlen(y) == 4)
-strncat(x, y, 2); // expected-warning{{Size argument is greater 

[PATCH] D74015: [AIX][Frontend] C++ ABI customizations for AIX boilerplate

2020-02-18 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added a comment.

In D74015#1880847 , @cebowleratibm 
wrote:

> From my perspective, the only issue holding this up is settling on the name.  
> I'd like to hammer that out and get this committed.


It looks everyone agrees on `XL` so far. As for your other suggestion `IBMXL`, 
if your intention is to clarify this ABI is IBM product specific, I think a 
good practice we can do is to leave a comment when we defined it as Microsoft 
does.


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

https://reviews.llvm.org/D74015



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


[PATCH] D72231: [Sema] Adds the pointer-to-int-cast diagnostic

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D72231#1881784 , @rjmccall wrote:

> In D72231#1881760 , @nickdesaulniers 
> wrote:
>
> > In D72231#1879347 , @rjmccall 
> > wrote:
> >
> > > In D72231#1878528 , 
> > > @nathanchance wrote:
> > >
> > > > There appear to a be semantic difference between GCC and clang with the 
> > > > current version of this patch which results in a lot of additional 
> > > > warnings in the Linux kernel: https://godbolt.org/z/eHFJd8
> > >
> > >
> > > Warning about casting to an enum seems clearly correct and in scope for 
> > > this warning.  Warning about casting to `_Bool` seems clearly incorrect 
> > > and should not be warned about at all.
> >
> >
> > Maybe we should only warn if the size of the `void*` is smaller than the 
> > size of the `enum`? (32b `void*`, 64b `enum`)? https://godbolt.org/z/oAts-u
> >
> > Otherwise this warning creates a massive mess for us to clean up, and I 
> > suspect Linux kernel developers will just end up disabling the warning.
>
>
> If deployment is easier if we split out a subgroup that we can turn off, that 
> seems fine.  But I don't see any good abstract justification for warning 
> about a cast to `int` and not a cast to an `int`-sized `enum`.  What would 
> the reasoning be, just that the latter "couldn't possibly" be intended to 
> preserve the original pointer value, so it must be an opaque value being 
> represented as a `void*`?  That seems pretty weak to me.


Less about enums, more about casts to/from void*, since you might use that in 
place of a union that would be too large to describe.  Specifically, this 
`struct` is used throughout the kernel for most drivers: 
https://elixir.bootlin.com/linux/v5.5.4/source/include/linux/mod_devicetable.h#L260
  It is exceedingly common to stuff whatever data in there: 
https://elixir.bootlin.com/linux/v5.5.4/source/drivers/ata/ahci_brcm.c#L428 so 
long as the driver is careful not to reinterpret the data as the incorrect 
type.  Describing such a union for ever possible enum packed in there would not 
be fun.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72231



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


[clang] 24ad121 - Add -std=c++20 flag, replace C++2a with C++20 throughout the Clang

2020-02-18 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-02-18T16:16:37-08:00
New Revision: 24ad121582454e625bdad125c90d9ac0dae948c8

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

LOG: Add -std=c++20 flag, replace C++2a with C++20 throughout the Clang
user interface and documentation, and update __cplusplus for C++20.

WG21 considers the C++20 standard to be finished (even though it still
has some more steps to pass through in the ISO process).

The old flag names are accepted for compatibility, as usual, and we
still have lots of references to C++2a in comments and identifiers;
those can be cleaned up separately.

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/include/clang/Basic/DiagnosticASTKinds.td
clang/include/clang/Basic/DiagnosticCommonKinds.td
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/LangStandards.def
clang/include/clang/Basic/StmtNodes.td
clang/lib/Frontend/InitPreprocessor.cpp
clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp
clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp
clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
clang/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p1.cpp
clang/test/CXX/drs/dr2xx.cpp
clang/test/CXX/drs/dr6xx.cpp
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
clang/test/Driver/unknown-std.cpp
clang/test/Lexer/cxx2a-spaceship.cpp
clang/test/Lexer/cxx2a_keyword_as_cxx17.cpp
clang/test/Parser/cxx1z-decomposition.cpp
clang/test/Parser/cxx2a-concept-declaration.cpp
clang/test/Parser/cxx2a-inline-nested-namespace-definition.cpp
clang/test/Parser/explicit-bool.cpp
clang/test/Preprocessor/init.c
clang/test/SemaCXX/cxx17-compat.cpp
clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
clang/test/SemaCXX/cxx1z-decomposition.cpp
clang/test/SemaCXX/cxx2a-compat.cpp
clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
clang/test/SemaCXX/member-init.cpp
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index adef8bb433a1..7c7f86214a83 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -122,7 +122,7 @@ of ``cxx_rvalue_references``.
 ``__has_cpp_attribute``
 ---
 
-This function-like macro is available in C++2a by default, and is provided as 
an
+This function-like macro is available in C++20 by default, and is provided as 
an
 extension in earlier language standards. It takes a single argument that is the
 name of a double-square-bracket-style attribute. The argument can either be a
 single identifier or a scoped identifier. If the attribute is supported, a

diff  --git a/clang/include/clang/Basic/DiagnosticASTKinds.td 
b/clang/include/clang/Basic/DiagnosticASTKinds.td
index c0b737b08a72..48bafeeff208 100644
--- a/clang/include/clang/Basic/DiagnosticASTKinds.td
+++ b/clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -13,7 +13,7 @@ def note_expr_divide_by_zero : Note<"division by zero">;
 def note_constexpr_invalid_cast : Note<
   "%select{reinterpret_cast|dynamic_cast|cast that performs the conversions of"
   " a reinterpret_cast|cast from %1}0 is not allowed in a constant expression"
-  "%select{| in C++ standards before C++2a||}0">;
+  "%select{| in C++ standards before C++20||}0">;
 def note_constexpr_invalid_downcast : Note<
   "cannot cast object of dynamic type %0 to type %1">;
 def note_constexpr_overflow : Note<
@@ -33,7 +33,7 @@ def note_constexpr_no_return : Note<
   "control reached end of constexpr function">;
 def note_constexpr_virtual_call : Note<
   "cannot evaluate call to virtual function in a constant expression "
-  "in C++ standards before C++2a">;
+  "in C++ standards before C++20">;
 def note_constexpr_pure_virtual_call : Note<
   "pure virtual function %q0 called">;
 def note_constexpr_polymorphic_unknown_dynamic_type : Note<
@@ -105,7 +105,7 @@ def note_constexpr_var_init_non_constant : Note<
   "initializer of %0 is not a constant expression">;
 def note_constexpr_typeid_polymorphic : Note<
   "typeid applied to expression of polymorphic type %0 is "
-  "not allowed in a constant expression in C++ standards before C++2a">;
+  "not allowed in a constant expression in C++ standards before C++20">;
 def note_constexpr_void_comparison : Note<
   "comparison between unequal pointers to void has unspecified result">;
 def note_constexpr_temporary_here : Note<"temporary created 

[PATCH] D72231: [Sema] Adds the pointer-to-int-cast diagnostic

2020-02-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D72231#1881760 , @nickdesaulniers 
wrote:

> In D72231#1879347 , @rjmccall wrote:
>
> > In D72231#1878528 , @nathanchance 
> > wrote:
> >
> > > There appear to a be semantic difference between GCC and clang with the 
> > > current version of this patch which results in a lot of additional 
> > > warnings in the Linux kernel: https://godbolt.org/z/eHFJd8
> >
> >
> > Warning about casting to an enum seems clearly correct and in scope for 
> > this warning.  Warning about casting to `_Bool` seems clearly incorrect and 
> > should not be warned about at all.
>
>
> Maybe we should only warn if the size of the `void*` is smaller than the size 
> of the `enum`? (32b `void*`, 64b `enum`)? https://godbolt.org/z/oAts-u
>
> Otherwise this warning creates a massive mess for us to clean up, and I 
> suspect Linux kernel developers will just end up disabling the warning.


If deployment is easier if we split out a subgroup that we can turn off, that 
seems fine.  But I don't see any good abstract justification for warning about 
a cast to `int` and not a cast to an `int`-sized `enum`.  What would the 
reasoning be, just that the latter "couldn't possibly" be intended to preserve 
the original pointer value, so it must be an opaque value being represented as 
a `void*`?  That seems pretty weak to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72231



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


[PATCH] D74801: [ADT][NFC] SCCIterator: Change hasLoop() to hasCycle()

2020-02-18 Thread Stefanos Baziotis via Phabricator via cfe-commits
baziotis updated this revision to Diff 245295.
baziotis edited the summary of this revision.
baziotis added a comment.

Self-cycle to self-loop


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

https://reviews.llvm.org/D74801

Files:
  clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
  llvm/include/llvm/ADT/SCCIterator.h
  llvm/lib/IR/ModuleSummaryIndex.cpp
  llvm/tools/opt/PrintSCC.cpp


Index: llvm/tools/opt/PrintSCC.cpp
===
--- llvm/tools/opt/PrintSCC.cpp
+++ llvm/tools/opt/PrintSCC.cpp
@@ -79,7 +79,7 @@
 for (std::vector::const_iterator I = nextSCC.begin(),
E = nextSCC.end(); I != E; ++I)
   errs() << (*I)->getName() << ", ";
-if (nextSCC.size() == 1 && SCCI.hasLoop())
+if (nextSCC.size() == 1 && SCCI.hasCycle())
   errs() << " (Has self-loop).";
   }
   errs() << "\n";
@@ -101,7 +101,7 @@
E = nextSCC.end(); I != E; ++I)
   errs() << ((*I)->getFunction() ? (*I)->getFunction()->getName()
  : "external node") << ", ";
-if (nextSCC.size() == 1 && SCCI.hasLoop())
+if (nextSCC.size() == 1 && SCCI.hasCycle())
   errs() << " (Has self-loop).";
   }
   errs() << "\n";
Index: llvm/lib/IR/ModuleSummaryIndex.cpp
===
--- llvm/lib/IR/ModuleSummaryIndex.cpp
+++ llvm/lib/IR/ModuleSummaryIndex.cpp
@@ -300,7 +300,7 @@
   if (V.getSummaryList().size())
 F = cast(V.getSummaryList().front().get());
   O << " " << (F == nullptr ? "External" : "") << " " << 
utostr(V.getGUID())
-<< (I.hasLoop() ? " (has loop)" : "") << "\n";
+<< (I.hasCycle() ? " (has cycle)" : "") << "\n";
 }
 O << "}\n";
   }
Index: llvm/include/llvm/ADT/SCCIterator.h
===
--- llvm/include/llvm/ADT/SCCIterator.h
+++ llvm/include/llvm/ADT/SCCIterator.h
@@ -124,11 +124,11 @@
 return CurrentSCC;
   }
 
-  /// Test if the current SCC has a loop.
+  /// Test if the current SCC has a cycle.
   ///
   /// If the SCC has more than one node, this is trivially true.  If not, it 
may
-  /// still contain a loop if the node has an edge back to itself.
-  bool hasLoop() const;
+  /// still contain a cycle if the node has an edge back to itself.
+  bool hasCycle() const;
 
   /// This informs the \c scc_iterator that the specified \c Old node
   /// has been deleted, and \c New is to be used in its place.
@@ -212,7 +212,7 @@
 }
 
 template 
-bool scc_iterator::hasLoop() const {
+bool scc_iterator::hasCycle() const {
 assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!");
 if (CurrentSCC.size() > 1)
   return true;
Index: clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
@@ -265,7 +265,7 @@
   for (llvm::scc_iterator SCCI = llvm::scc_begin(),
SCCE = llvm::scc_end();
SCCI != SCCE; ++SCCI) {
-if (!SCCI.hasLoop()) // We only care about cycles, not standalone nodes.
+if (!SCCI.hasCycle()) // We only care about cycles, not standalone nodes.
   continue;
 handleSCC(*SCCI);
   }


Index: llvm/tools/opt/PrintSCC.cpp
===
--- llvm/tools/opt/PrintSCC.cpp
+++ llvm/tools/opt/PrintSCC.cpp
@@ -79,7 +79,7 @@
 for (std::vector::const_iterator I = nextSCC.begin(),
E = nextSCC.end(); I != E; ++I)
   errs() << (*I)->getName() << ", ";
-if (nextSCC.size() == 1 && SCCI.hasLoop())
+if (nextSCC.size() == 1 && SCCI.hasCycle())
   errs() << " (Has self-loop).";
   }
   errs() << "\n";
@@ -101,7 +101,7 @@
E = nextSCC.end(); I != E; ++I)
   errs() << ((*I)->getFunction() ? (*I)->getFunction()->getName()
  : "external node") << ", ";
-if (nextSCC.size() == 1 && SCCI.hasLoop())
+if (nextSCC.size() == 1 && SCCI.hasCycle())
   errs() << " (Has self-loop).";
   }
   errs() << "\n";
Index: llvm/lib/IR/ModuleSummaryIndex.cpp
===
--- llvm/lib/IR/ModuleSummaryIndex.cpp
+++ llvm/lib/IR/ModuleSummaryIndex.cpp
@@ -300,7 +300,7 @@
   if (V.getSummaryList().size())
 F = cast(V.getSummaryList().front().get());
   O << " " << (F == nullptr ? "External" : "") << " " << utostr(V.getGUID())
-<< (I.hasLoop() ? " (has loop)" : "") << "\n";
+<< (I.hasCycle() ? " (has cycle)" : "") << "\n";
 }
 O << "}\n";
   }
Index: llvm/include/llvm/ADT/SCCIterator.h
===
--- llvm/include/llvm/ADT/SCCIterator.h
+++ llvm/include/llvm/ADT/SCCIterator.h
@@ -124,11 +124,11 @@
 return 

[PATCH] D72231: [Sema] Adds the pointer-to-int-cast diagnostic

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D72231#1879347 , @rjmccall wrote:

> In D72231#1878528 , @nathanchance 
> wrote:
>
> > There appear to a be semantic difference between GCC and clang with the 
> > current version of this patch which results in a lot of additional warnings 
> > in the Linux kernel: https://godbolt.org/z/eHFJd8
>
>
> Warning about casting to an enum seems clearly correct and in scope for this 
> warning.  Warning about casting to `_Bool` seems clearly incorrect and should 
> not be warned about at all.


Maybe we should only warn if the size of the `void*` is smaller than the size 
of the `enum`? (32b `void*`, 64b `enum`)? https://godbolt.org/z/oAts-u

Otherwise this warning creates a massive mess for us to clean up, and I suspect 
Linux kernel developers will just end up disabling the warning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72231



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


[PATCH] D74801: [ADT][NFC] SCCIterator: Change hasLoop() to hasCycle()

2020-02-18 Thread Stefanos Baziotis via Phabricator via cfe-commits
baziotis marked an inline comment as done.
baziotis added inline comments.



Comment at: llvm/tools/opt/PrintSCC.cpp:82-83
   errs() << (*I)->getName() << ", ";
-if (nextSCC.size() == 1 && SCCI.hasLoop())
-  errs() << " (Has self-loop).";
+if (nextSCC.size() == 1 && SCCI.hasCycle())
+  errs() << " (Has self-cycle).";
   }

lebedev.ri wrote:
> baziotis wrote:
> > lebedev.ri wrote:
> > > err, i was specifically talking about this
> > Maybe we can keep the "Has self-loop here".
> Then this would look good to me
Ok, uploading new diff in a bit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74801



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


[PATCH] D74698: [Driver] -pg -mfentry should respect target specific decisions for -mframe-pointer=all

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8b9cb1208124: [Driver] -pg -mfentry should respect target 
specific decisions for -mframe… (authored by nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/mfentry.c


Index: clang/test/Driver/mfentry.c
===
--- clang/test/Driver/mfentry.c
+++ clang/test/Driver/mfentry.c
@@ -1,9 +1,19 @@
 // RUN: %clang -target s390x -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target i386 -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64 -c -### %s -mfentry 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O0 -### -E %s 2>&1 | 
FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 
-fno-omit-frame-pointer -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 -### -E %s 2>&1 | 
FileCheck -check-prefix=NOFP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O0 -### -E %s 2>&1 | FileCheck 
-check-prefix=FP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O2 -fno-omit-frame-pointer -### -E 
%s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O2 -### -E %s 2>&1 | FileCheck 
-check-prefix=FP %s
 
 // CHECK: "-mfentry"
 
 // RUN: %clang -target powerpc64le -c -### %s -mfentry 2>&1 | FileCheck 
--check-prefix=ERR %s
 
 // ERR: error: unsupported option '-mfentry' for target 'powerpc64le'
+
+// FP: "-mframe-pointer=all"
+// NOFP: "-mframe-pointer=none"
+void foo(void) {}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 


Index: clang/test/Driver/mfentry.c
===
--- clang/test/Driver/mfentry.c
+++ clang/test/Driver/mfentry.c
@@ -1,9 +1,19 @@
 // RUN: %clang -target s390x -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target i386 -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64 -c -### %s -mfentry 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O0 -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 -fno-omit-frame-pointer -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 -### -E %s 2>&1 | FileCheck -check-prefix=NOFP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O0 -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O2 -fno-omit-frame-pointer -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O2 -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
 
 // CHECK: "-mfentry"
 
 // RUN: %clang -target powerpc64le -c -### %s -mfentry 2>&1 | FileCheck --check-prefix=ERR %s
 
 // ERR: error: unsupported option '-mfentry' for target 'powerpc64le'
+
+// FP: "-mframe-pointer=all"
+// NOFP: "-mframe-pointer=none"
+void foo(void) {}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 

[PATCH] D74801: [ADT][NFC] SCCIterator: Change hasLoop() to hasCycle()

2020-02-18 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: llvm/tools/opt/PrintSCC.cpp:82-83
   errs() << (*I)->getName() << ", ";
-if (nextSCC.size() == 1 && SCCI.hasLoop())
-  errs() << " (Has self-loop).";
+if (nextSCC.size() == 1 && SCCI.hasCycle())
+  errs() << " (Has self-cycle).";
   }

baziotis wrote:
> lebedev.ri wrote:
> > err, i was specifically talking about this
> Maybe we can keep the "Has self-loop here".
Then this would look good to me


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74801



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


[clang] 8b9cb12 - [Driver] -pg -mfentry should respect target specific decisions for -mframe-pointer=all

2020-02-18 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2020-02-18T15:33:46-08:00
New Revision: 8b9cb120812449dbe67d2252ebf619c4c9cac816

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

LOG: [Driver] -pg -mfentry should respect target specific decisions for 
-mframe-pointer=all

Summary:
$ clang -O2 -pg -mfentry foo.c

was adding frame pointers to all functions. This was exposed via
compiling the Linux kernel for x86_64 with CONFIG_FUNCTION_TRACER
enabled.

-pg was unconditionally setting the equivalent of -fno-omit-frame-pointer,
regardless of the presence of -mfentry or optimization level.  After this
patch, frame pointers will only be omitted at -O0 or if
-fno-omit-frame-pointer is explicitly set for -pg -mfentry.

See also:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=3c5273a96ba8dbf98c40bc6d9d0a1587b4cfedb2;hp=c9d75a48c4ea63ab27ccdb40f993236289b243f2#patch2
(modification to ix86_frame_pointer_required())

Fixes: pr/44934

Reviewers: void, manojgupta, dberris, MaskRay, hfinkel

Reviewed By: MaskRay

Subscribers: cfe-commits, llozano, niravd, srhines

Tags: #clang

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/mfentry.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index d1197556aeef..1d9e741f4cf8 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@ static bool mustUseNonLeafFramePointerForTarget(const 
llvm::Triple ) {
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 

diff  --git a/clang/test/Driver/mfentry.c b/clang/test/Driver/mfentry.c
index ee402ea1b73d..34ef9d9ca11b 100644
--- a/clang/test/Driver/mfentry.c
+++ b/clang/test/Driver/mfentry.c
@@ -1,9 +1,19 @@
 // RUN: %clang -target s390x -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target i386 -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64 -c -### %s -mfentry 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O0 -### -E %s 2>&1 | 
FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 
-fno-omit-frame-pointer -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 -### -E %s 2>&1 | 
FileCheck -check-prefix=NOFP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O0 -### -E %s 2>&1 | FileCheck 
-check-prefix=FP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O2 -fno-omit-frame-pointer -### -E 
%s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O2 -### -E %s 2>&1 | FileCheck 
-check-prefix=FP %s
 
 // CHECK: "-mfentry"
 
 // RUN: %clang -target powerpc64le -c -### %s -mfentry 2>&1 | FileCheck 
--check-prefix=ERR %s
 
 // ERR: error: unsupported option '-mfentry' for target 'powerpc64le'
+
+// FP: "-mframe-pointer=all"
+// NOFP: "-mframe-pointer=none"
+void foo(void) {}



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


[PATCH] D74801: [ADT][NFC] SCCIterator: Change hasLoop() to hasCycle()

2020-02-18 Thread Stefanos Baziotis via Phabricator via cfe-commits
baziotis marked an inline comment as done.
baziotis added a comment.

In D74801#1881693 , @lebedev.ri wrote:

> While i certainly agree that it's kinda confusing, i'm not really sure this 
> is conceptually correct change.
>  https://en.wikipedia.org/wiki/Loop_(graph_theory)
>
> > In graph theory, a loop (also called a self-loop or a "buckle") is an edge 
> > that connects a vertex to itself. A simple graph contains no loops.
>
> which is exactly the case here.
>
> https://en.wikipedia.org/wiki/Cycle_(graph_theory)
>  seems more generic than that.


Yes, I agree, but it was the closest word I could find that is not "loop" but 
still gets the point across. I mean technically maybe the better term would be 
"hasALoopButNotNecessarilyANormalLoop()" but well... :P
In any case, that was an experience of mine as a newcomer. If you think it's 
not worth it, so be it. :)




Comment at: llvm/tools/opt/PrintSCC.cpp:82-83
   errs() << (*I)->getName() << ", ";
-if (nextSCC.size() == 1 && SCCI.hasLoop())
-  errs() << " (Has self-loop).";
+if (nextSCC.size() == 1 && SCCI.hasCycle())
+  errs() << " (Has self-cycle).";
   }

lebedev.ri wrote:
> err, i was specifically talking about this
Maybe we can keep the "Has self-loop here".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74801



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


[PATCH] D74801: [ADT][NFC] SCCIterator: Change hasLoop() to hasCycle()

2020-02-18 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: llvm/tools/opt/PrintSCC.cpp:82-83
   errs() << (*I)->getName() << ", ";
-if (nextSCC.size() == 1 && SCCI.hasLoop())
-  errs() << " (Has self-loop).";
+if (nextSCC.size() == 1 && SCCI.hasCycle())
+  errs() << " (Has self-cycle).";
   }

err, i was specifically talking about this



Comment at: llvm/tools/opt/PrintSCC.cpp:104-105
  : "external node") << ", ";
-if (nextSCC.size() == 1 && SCCI.hasLoop())
-  errs() << " (Has self-loop).";
+if (nextSCC.size() == 1 && SCCI.hasCycle())
+  errs() << " (Has self-cycle).";
   }

And this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74801



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


[PATCH] D73649: [CodeComplete] Member completion for concept-constrained types.

2020-02-18 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Thanks for looking at this! Sorry for the late response, I was travelling for a 
few weeks.

So far I've only had a chance to look at the tests.




Comment at: clang/test/CodeCompletion/concepts.cpp:34
+  // RUN: | FileCheck %s -check-prefix=DOT -implicit-check-not=xxx_t
+  // DOT: Pattern : [#convertible_to#]aaa()
+  // DOT: Pattern : bb() (requires fix-it: {{.*}} to "->")

Doesn't the presence of the `x` mean we should only get results that start with 
`x`?

(Or, if "column 5" actually means we're completing right after the dot, why is 
the `x` present in the testcase at all -- just so that the line is 
syntactically well formed?)



Comment at: clang/test/CodeCompletion/concepts.cpp:35
+  // DOT: Pattern : [#convertible_to#]aaa()
+  // DOT: Pattern : bb() (requires fix-it: {{.*}} to "->")
+  // DOT: Pattern : bbb()

Should we be taking completions from just one branch of a logical-or in a 
requirement?

To simplify the scenario a bit:

```
template 
  requires (requires(T t) { t.foo(); } || requires(T t) { t.bar(); })
void f(T t) {
  t.^
}
```

Do we want to be offering both `foo()` and `bar()` as completions here? 
Logically, it seems we only ought to offer completions from expressions that 
appear in _both_ branches of the logical-or (so, if `t.foo()` appeared as a 
requirement in both branches, we could offer `foo()`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73649



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


[PATCH] D74801: [ADT][NFC] SCCIterator: Change hasLoop() to hasCycle()

2020-02-18 Thread Stefanos Baziotis via Phabricator via cfe-commits
baziotis added a subscriber: jdoerfert.
baziotis added a comment.

In D74801#1881679 , @efriedma wrote:

> Seems fine.


Great, thanks and to @jdoerfert!
Any way I can find the correct reviewers next time?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74801



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


[PATCH] D74801: [ADT][NFC] SCCIterator: Change hasLoop() to hasCycle()

2020-02-18 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

While i certainly agree that it's kinda confusing, i'm not really sure this is 
conceptually correct change.
https://en.wikipedia.org/wiki/Loop_(graph_theory)

> In graph theory, a loop (also called a self-loop or a "buckle") is an edge 
> that connects a vertex to itself. A simple graph contains no loops.

which is exactly the case here.

https://en.wikipedia.org/wiki/Cycle_(graph_theory)
seems more generic than that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74801



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


[PATCH] D74801: [ADT][NFC] SCCIterator: Change hasLoop() to hasCycle()

2020-02-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

Seems fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74801



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


[PATCH] D74801: [ADT] SCCIterator: Change hasLoop() to hasCycle()

2020-02-18 Thread Stefanos Baziotis via Phabricator via cfe-commits
baziotis created this revision.
baziotis added reviewers: dexonsmith, lattner, timshen, chandlerc.
Herald added subscribers: llvm-commits, cfe-commits, arphaman, hiraditya.
Herald added projects: clang, LLVM.

Not a super important change but yesterday I had to look in this function and 
initially it was misleading. I thought it tests if there's a loop that 
satisfies the criteria in the loop terminology 
(https://llvm.org/docs/LoopTerminology.html). Loop is a special term I think so 
maybe the term cycle is better.

P.S.: I hope I added the correct reviewers, which were those I found in the git 
blame.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74801

Files:
  clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
  llvm/include/llvm/ADT/SCCIterator.h
  llvm/lib/IR/ModuleSummaryIndex.cpp
  llvm/tools/opt/PrintSCC.cpp


Index: llvm/tools/opt/PrintSCC.cpp
===
--- llvm/tools/opt/PrintSCC.cpp
+++ llvm/tools/opt/PrintSCC.cpp
@@ -79,8 +79,8 @@
 for (std::vector::const_iterator I = nextSCC.begin(),
E = nextSCC.end(); I != E; ++I)
   errs() << (*I)->getName() << ", ";
-if (nextSCC.size() == 1 && SCCI.hasLoop())
-  errs() << " (Has self-loop).";
+if (nextSCC.size() == 1 && SCCI.hasCycle())
+  errs() << " (Has self-cycle).";
   }
   errs() << "\n";
 
@@ -101,8 +101,8 @@
E = nextSCC.end(); I != E; ++I)
   errs() << ((*I)->getFunction() ? (*I)->getFunction()->getName()
  : "external node") << ", ";
-if (nextSCC.size() == 1 && SCCI.hasLoop())
-  errs() << " (Has self-loop).";
+if (nextSCC.size() == 1 && SCCI.hasCycle())
+  errs() << " (Has self-cycle).";
   }
   errs() << "\n";
 
Index: llvm/lib/IR/ModuleSummaryIndex.cpp
===
--- llvm/lib/IR/ModuleSummaryIndex.cpp
+++ llvm/lib/IR/ModuleSummaryIndex.cpp
@@ -300,7 +300,7 @@
   if (V.getSummaryList().size())
 F = cast(V.getSummaryList().front().get());
   O << " " << (F == nullptr ? "External" : "") << " " << 
utostr(V.getGUID())
-<< (I.hasLoop() ? " (has loop)" : "") << "\n";
+<< (I.hasCycle() ? " (has cycle)" : "") << "\n";
 }
 O << "}\n";
   }
Index: llvm/include/llvm/ADT/SCCIterator.h
===
--- llvm/include/llvm/ADT/SCCIterator.h
+++ llvm/include/llvm/ADT/SCCIterator.h
@@ -124,11 +124,11 @@
 return CurrentSCC;
   }
 
-  /// Test if the current SCC has a loop.
+  /// Test if the current SCC has a cycle.
   ///
   /// If the SCC has more than one node, this is trivially true.  If not, it 
may
-  /// still contain a loop if the node has an edge back to itself.
-  bool hasLoop() const;
+  /// still contain a cycle if the node has an edge back to itself.
+  bool hasCycle() const;
 
   /// This informs the \c scc_iterator that the specified \c Old node
   /// has been deleted, and \c New is to be used in its place.
@@ -212,7 +212,7 @@
 }
 
 template 
-bool scc_iterator::hasLoop() const {
+bool scc_iterator::hasCycle() const {
 assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!");
 if (CurrentSCC.size() > 1)
   return true;
Index: clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
@@ -265,7 +265,7 @@
   for (llvm::scc_iterator SCCI = llvm::scc_begin(),
SCCE = llvm::scc_end();
SCCI != SCCE; ++SCCI) {
-if (!SCCI.hasLoop()) // We only care about cycles, not standalone nodes.
+if (!SCCI.hasCycle()) // We only care about cycles, not standalone nodes.
   continue;
 handleSCC(*SCCI);
   }


Index: llvm/tools/opt/PrintSCC.cpp
===
--- llvm/tools/opt/PrintSCC.cpp
+++ llvm/tools/opt/PrintSCC.cpp
@@ -79,8 +79,8 @@
 for (std::vector::const_iterator I = nextSCC.begin(),
E = nextSCC.end(); I != E; ++I)
   errs() << (*I)->getName() << ", ";
-if (nextSCC.size() == 1 && SCCI.hasLoop())
-  errs() << " (Has self-loop).";
+if (nextSCC.size() == 1 && SCCI.hasCycle())
+  errs() << " (Has self-cycle).";
   }
   errs() << "\n";
 
@@ -101,8 +101,8 @@
E = nextSCC.end(); I != E; ++I)
   errs() << ((*I)->getFunction() ? (*I)->getFunction()->getName()
  : "external node") << ", ";
-if (nextSCC.size() == 1 && SCCI.hasLoop())
-  errs() << " (Has self-loop).";
+if (nextSCC.size() == 1 && SCCI.hasCycle())
+  errs() << " (Has self-cycle).";
   }
   errs() << "\n";
 
Index: llvm/lib/IR/ModuleSummaryIndex.cpp
===
--- llvm/lib/IR/ModuleSummaryIndex.cpp
+++ 

[clang] e28d9ba - PR44958: Allow member calls and typeid / dynamic_cast on mutable objects

2020-02-18 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-02-18T14:57:13-08:00
New Revision: e28d9bae4b3be60e90daa69a2eeb3254c952e051

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

LOG: PR44958: Allow member calls and typeid / dynamic_cast on mutable objects
and objects with mutable subobjects.

The standard wording doesn't really cover these cases; accepting all
such cases seems most in line with what we do in other cases and what
other compilers do. (Essentially this means we're assuming that objects
external to the evaluation are always in-lifetime.)

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/test/SemaCXX/constant-expression-cxx2a.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index dfa9444c59aa..641368ebfdd9 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -3140,6 +3140,13 @@ struct CompleteObject {
   : Base(Base), Value(Value), Type(Type) {}
 
   bool mayAccessMutableMembers(EvalInfo , AccessKinds AK) const {
+// If this isn't a "real" access (eg, if it's just accessing the type
+// info), allow it. We assume the type doesn't change dynamically for
+// subobjects of constexpr objects (even though we'd hit UB here if it
+// did). FIXME: Is this right?
+if (!isAnyAccess(AK))
+  return true;
+
 // In C++14 onwards, it is permitted to read a mutable member whose
 // lifetime began within the evaluation.
 // FIXME: Should we also allow this in C++11?

diff  --git a/clang/test/SemaCXX/constant-expression-cxx2a.cpp 
b/clang/test/SemaCXX/constant-expression-cxx2a.cpp
index 9012f377e1bc..3d5172619dbf 100644
--- a/clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1279,3 +1279,57 @@ namespace value_dependent_init {
 A a = T();
   }
 }
+
+namespace mutable_subobjects {
+  struct A {
+int m;
+mutable int n; // expected-note 2{{here}}
+constexpr int f() const { return m; }
+constexpr int g() const { return n; } // expected-note {{mutable}}
+  };
+
+  constexpr A a = {1, 2};
+  static_assert(a.f() == 1); // OK (PR44958)
+  static_assert(a.g() == 2); // expected-error {{constant}} expected-note {{in 
call}}
+
+  constexpr A b = a; // expected-error {{constant}} expected-note {{read of 
mutable member 'n'}} expected-note {{in call}}
+
+  auto  = typeid(a);
+  auto  = typeid(a.m);
+  auto  = typeid(a.n);
+
+  constexpr void destroy1() { // expected-error {{constexpr}}
+a.~A(); // expected-note {{cannot modify an object that is visible 
outside}}
+  }
+  // FIXME: These should both be rejected once P0593 is implemented.
+  using T = int;
+  constexpr void destroy2() {
+a.m.~T();
+  }
+  constexpr void destroy3() {
+a.n.~T();
+  }
+
+  struct X {
+mutable int n = 0;
+virtual constexpr ~X() {}
+  };
+  struct Y : X {
+  };
+  constexpr Y y;
+  constexpr const X *p = 
+  constexpr const Y *q = dynamic_cast(p);
+
+  // FIXME: It's unclear whether this should be accepted. The dynamic_cast is
+  // undefined after 'z.y.~Y()`, for example. We essentially assume that all
+  // objects that the evaluator can reach have unbounded lifetimes. (We make
+  // the same assumption when evaluating member function calls.)
+  struct Z {
+mutable Y y;
+  };
+  constexpr Z z;
+  constexpr const X *pz = 
+  constexpr const Y *qz = dynamic_cast(pz);
+  auto  = typeid(z.y);
+  static_assert( == (Y));
+}



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


[PATCH] D72825: Remove unused option that gcc ignored

2020-02-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D72825/new/

https://reviews.llvm.org/D72825



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


[PATCH] D74724: [AArch64][SVE] CodeGen of ACLE Builtin Types

2020-02-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D74724



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


[PATCH] D72231: [Sema] Adds the pointer-to-int-cast diagnostic

2020-02-18 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

In D72231#1879347 , @rjmccall wrote:

> Warning about casting to an enum seems clearly correct and in scope for this 
> warning.  Warning about casting to `_Bool` seems clearly incorrect and should 
> not be warned about at all.


Fair enough. There are 97 unique instances of the enum variant of the warning 
across the various configs that I test so I will start sending patches to add 
`uintptr_t` casts to silence it.

https://gist.github.com/nathanchance/2c2892e9e4b411fa78770ed3624812b4


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72231



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


[PATCH] D74795: Make diagnostic reporting more robust in presence of corrupt PCH data.

2020-02-18 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Thanks for working on this!  I have a couple of comments inline.




Comment at: clang/include/clang/Basic/Diagnostic.h:918-927
   /// The ID of the current diagnostic that is in flight.
   ///
   /// This is set to std::numeric_limits::max() when there is no
   /// diagnostic in flight.
   unsigned CurDiagID;
 
+  /// The ID of the current delayed diagnostic being reported.

`CurDelayedDiagID` has a different kind of "in-flight" lifetime than 
`CurDiagID`.  I think the comment here should be more explicit about what 
precisely the variable is doing, and perhaps it should have another name.  Do 
we actually need the ID kept as state?  If not, this would be simpler as:
```
bool IsReportingDelayedDiag = false;
```

Also, a couple of nit-picks:
- Periods at the end of sentences in comments.
- You seem to have dropped out of doxygen comments (`//` instead of `///`).



Comment at: clang/lib/Basic/Diagnostic.cpp:160-161
 void DiagnosticsEngine::ReportDelayed() {
-  unsigned ID = DelayedDiagID;
+  CurDelayedDiagID = DelayedDiagID;
   DelayedDiagID = 0;
+  Report(CurDelayedDiagID) << DelayedDiagArg1 << DelayedDiagArg2

If you take my suggestion, then you wouldn't need to change this line, just add:
```
IsReportingDelayedDiag = true;
```
but would these assertions be valid after your change?
```
assert(DelayedDiagID && "Called without a delayed diagnostic?");
assert(!IsReportingDelayedDiag &&
   "Called while reporting another delayed diagnostic?");
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74795



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


[PATCH] D74769: [AArch64][SVE] Add SVE2 intrinsics for polynomial arithmetic

2020-02-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D74769/new/

https://reviews.llvm.org/D74769



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


[PATCH] D74698: [Driver] -pg -mfentry should respect target specific decisions for -mframe-pointer=all

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Ok, sorry for the excessive churn. I think this now accurately describes the 
logic of how this was expected to work, from the stance of GCC compatibility.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698



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


[PATCH] D74698: [Driver] -pg -mfentry should respect target specific decisions for -mframe-pointer=all

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 245279.
nickdesaulniers added a comment.

- respect target specific frame pointer optimizations


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/mfentry.c


Index: clang/test/Driver/mfentry.c
===
--- clang/test/Driver/mfentry.c
+++ clang/test/Driver/mfentry.c
@@ -1,9 +1,19 @@
 // RUN: %clang -target s390x -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target i386 -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64 -c -### %s -mfentry 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O0 -### -E %s 2>&1 | 
FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 
-fno-omit-frame-pointer -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 -### -E %s 2>&1 | 
FileCheck -check-prefix=NOFP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O0 -### -E %s 2>&1 | FileCheck 
-check-prefix=FP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O2 -fno-omit-frame-pointer -### -E 
%s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O2 -### -E %s 2>&1 | FileCheck 
-check-prefix=FP %s
 
 // CHECK: "-mfentry"
 
 // RUN: %clang -target powerpc64le -c -### %s -mfentry 2>&1 | FileCheck 
--check-prefix=ERR %s
 
 // ERR: error: unsupported option '-mfentry' for target 'powerpc64le'
+
+// FP: "-mframe-pointer=all"
+// NOFP: "-mframe-pointer=none"
+void foo(void) {}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 


Index: clang/test/Driver/mfentry.c
===
--- clang/test/Driver/mfentry.c
+++ clang/test/Driver/mfentry.c
@@ -1,9 +1,19 @@
 // RUN: %clang -target s390x -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target i386 -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64 -c -### %s -mfentry 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O0 -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 -fno-omit-frame-pointer -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 -### -E %s 2>&1 | FileCheck -check-prefix=NOFP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O0 -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O2 -fno-omit-frame-pointer -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O2 -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
 
 // CHECK: "-mfentry"
 
 // RUN: %clang -target powerpc64le -c -### %s -mfentry 2>&1 | FileCheck --check-prefix=ERR %s
 
 // ERR: error: unsupported option '-mfentry' for target 'powerpc64le'
+
+// FP: "-mframe-pointer=all"
+// NOFP: "-mframe-pointer=none"
+void foo(void) {}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D74698: [Driver] -pg -mfentry should respect target specific decisions for -mframe-pointer=all

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers marked an inline comment as done.
nickdesaulniers added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:592
+  if (Args.hasArg(options::OPT_pg) && Args.hasArg(options::OPT_mfentry))
+return false;
 

This hunk does nothing and can be removed. I'll retitle the diff with a better 
explanation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698



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


[clang] cf45742 - [hexagon] Fix testcase issue with windows builder.

2020-02-18 Thread Sid Manning via cfe-commits

Author: Sid Manning
Date: 2020-02-18T16:36:38-06:00
New Revision: cf4574299a279beeb8acb894583962ec0f41286c

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

LOG: [hexagon] Fix testcase issue with windows builder.

Added: 


Modified: 
clang/test/Driver/hexagon-toolchain-elf.c

Removed: 




diff  --git a/clang/test/Driver/hexagon-toolchain-elf.c 
b/clang/test/Driver/hexagon-toolchain-elf.c
index 4af00215ea31..a0bf8cac9668 100644
--- a/clang/test/Driver/hexagon-toolchain-elf.c
+++ b/clang/test/Driver/hexagon-toolchain-elf.c
@@ -587,4 +587,4 @@
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK083 %s
 // CHECK083:  "-isysroot" "/hexagon"
-// CHECK083:  "-internal-externc-isystem" "/hexagon/include"
+// CHECK083:  "-internal-externc-isystem" "/hexagon{{/|}}include"



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


[PATCH] D74795: Make diagnostic reporting more robust in presence of corrupt PCH data.

2020-02-18 Thread Neil MacIntosh via Phabricator via cfe-commits
neilmacintosh created this revision.
neilmacintosh added reviewers: modocache, doug.gregor, hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, dexonsmith, 
ilya-biryukov.
Herald added a project: clang.

When running clangd, I found that occasionally, accessing a
precompiled header would cause an LLVM assertion to fire.

This in turn would cause a diagnostic to try and be emitted,
when the diagnostics machinery would reach back to find 
information from the PCH, it would hit the same problem
that caused the initial assertion. Another assertion would fire and
another delayed diagnostic would be setup to report, and so on.

This recursive sequence would continue until stack overflow, which
would take down clangd.

This small patch works around that possibility by making a delayed
diagnostic more explicit (and therefore testable to avoid recursion).

I tested this against the files in our codebase that hit the
LLVM assertion with clangd and now the assertion clearly reports
and clangd is no longer exhausted by a stack overflow.

Tracking down the underlying problem (hitting the assertion)
is a separate task.

I'm not sure how (or if it's possible) to add a test that would
demonstrate the before/after here. Happy to take advice!


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74795

Files:
  clang/include/clang/Basic/Diagnostic.h
  clang/lib/Basic/Diagnostic.cpp


Index: clang/lib/Basic/Diagnostic.cpp
===
--- clang/lib/Basic/Diagnostic.cpp
+++ clang/lib/Basic/Diagnostic.cpp
@@ -132,6 +132,7 @@
   CurDiagID = std::numeric_limits::max();
   LastDiagLevel = DiagnosticIDs::Ignored;
   DelayedDiagID = 0;
+  CurDelayedDiagID = 0;
 
   // Clear state related to #pragma diagnostic.
   DiagStates.clear();
@@ -146,7 +147,7 @@
 
 void DiagnosticsEngine::SetDelayedDiagnostic(unsigned DiagID, StringRef Arg1,
  StringRef Arg2, StringRef Arg3) {
-  if (DelayedDiagID)
+  if (CurDelayedDiagID || DelayedDiagID)
 return;
 
   DelayedDiagID = DiagID;
@@ -156,9 +157,11 @@
 }
 
 void DiagnosticsEngine::ReportDelayed() {
-  unsigned ID = DelayedDiagID;
+  CurDelayedDiagID = DelayedDiagID;
   DelayedDiagID = 0;
-  Report(ID) << DelayedDiagArg1 << DelayedDiagArg2 << DelayedDiagArg3;
+  Report(CurDelayedDiagID) << DelayedDiagArg1 << DelayedDiagArg2
+   << DelayedDiagArg3;
+  CurDelayedDiagID = 0;
 }
 
 void DiagnosticsEngine::DiagStateMap::appendFirst(DiagState *State) {
@@ -521,7 +524,9 @@
   Clear();
 
   // If there was a delayed diagnostic, emit it now.
-  if (!Force && DelayedDiagID)
+  // unless we are currently emitting a delayed diagnostic,
+  // as that leads to the potential of endless reporting.
+  if (!Force && DelayedDiagID && !CurDelayedDiagID)
 ReportDelayed();
 
   return Emitted;
Index: clang/include/clang/Basic/Diagnostic.h
===
--- clang/include/clang/Basic/Diagnostic.h
+++ clang/include/clang/Basic/Diagnostic.h
@@ -888,7 +888,10 @@
 StringRef Arg2 = "", StringRef Arg3 = "");
 
   /// Clear out the current diagnostic.
-  void Clear() { CurDiagID = std::numeric_limits::max(); }
+  void Clear() {
+CurDiagID = std::numeric_limits::max();
+CurDelayedDiagID = 0;
+  }
 
   /// Return the value associated with this diagnostic flag.
   StringRef getFlagValue() const { return FlagValue; }
@@ -918,6 +921,11 @@
   /// diagnostic in flight.
   unsigned CurDiagID;
 
+  /// The ID of the current delayed diagnostic being reported.
+  //
+  // This is set to 0 when there is no delayed diagnostic in flight
+  unsigned CurDelayedDiagID;
+
   enum {
 /// The maximum number of arguments we can hold.
 ///


Index: clang/lib/Basic/Diagnostic.cpp
===
--- clang/lib/Basic/Diagnostic.cpp
+++ clang/lib/Basic/Diagnostic.cpp
@@ -132,6 +132,7 @@
   CurDiagID = std::numeric_limits::max();
   LastDiagLevel = DiagnosticIDs::Ignored;
   DelayedDiagID = 0;
+  CurDelayedDiagID = 0;
 
   // Clear state related to #pragma diagnostic.
   DiagStates.clear();
@@ -146,7 +147,7 @@
 
 void DiagnosticsEngine::SetDelayedDiagnostic(unsigned DiagID, StringRef Arg1,
  StringRef Arg2, StringRef Arg3) {
-  if (DelayedDiagID)
+  if (CurDelayedDiagID || DelayedDiagID)
 return;
 
   DelayedDiagID = DiagID;
@@ -156,9 +157,11 @@
 }
 
 void DiagnosticsEngine::ReportDelayed() {
-  unsigned ID = DelayedDiagID;
+  CurDelayedDiagID = DelayedDiagID;
   DelayedDiagID = 0;
-  Report(ID) << DelayedDiagArg1 << DelayedDiagArg2 << DelayedDiagArg3;
+  Report(CurDelayedDiagID) << DelayedDiagArg1 << DelayedDiagArg2
+   << DelayedDiagArg3;
+  CurDelayedDiagID = 0;
 }
 
 void DiagnosticsEngine::DiagStateMap::appendFirst(DiagState *State) {
@@ -521,7 +524,9 @@
   Clear();
 
   

[PATCH] D74698: [Driver] -pg shouldn't unconditionally add -mframe-pointer=all w/ -mfentry

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 245274.
nickdesaulniers added a comment.

- drop implicit-check-nots, add check for no os target


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/mfentry.c


Index: clang/test/Driver/mfentry.c
===
--- clang/test/Driver/mfentry.c
+++ clang/test/Driver/mfentry.c
@@ -1,9 +1,19 @@
 // RUN: %clang -target s390x -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target i386 -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64 -c -### %s -mfentry 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O0 -### -E %s 2>&1 | 
FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 
-fno-omit-frame-pointer -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 -### -E %s 2>&1 | 
FileCheck -check-prefix=NOFP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O0 -### -E %s 2>&1 | FileCheck 
-check-prefix=FP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O2 -fno-omit-frame-pointer -### -E 
%s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O2 -### -E %s 2>&1 | FileCheck 
-check-prefix=FP %s
 
 // CHECK: "-mfentry"
 
 // RUN: %clang -target powerpc64le -c -### %s -mfentry 2>&1 | FileCheck 
--check-prefix=ERR %s
 
 // ERR: error: unsupported option '-mfentry' for target 'powerpc64le'
+
+// FP: "-mframe-pointer=all"
+// NOFP: "-mframe-pointer=none"
+void foo(void) {}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -586,6 +586,10 @@
   return false;
 }
   }
+  // If no target OS was specified (so no special rules above related to
+  // optimization levels made a decision...
+  if (Args.hasArg(options::OPT_pg) && Args.hasArg(options::OPT_mfentry))
+return false;
 
   return true;
 }
@@ -6150,7 +6154,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 


Index: clang/test/Driver/mfentry.c
===
--- clang/test/Driver/mfentry.c
+++ clang/test/Driver/mfentry.c
@@ -1,9 +1,19 @@
 // RUN: %clang -target s390x -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target i386 -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64 -c -### %s -mfentry 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O0 -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 -fno-omit-frame-pointer -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 -### -E %s 2>&1 | FileCheck -check-prefix=NOFP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O0 -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O2 -fno-omit-frame-pointer -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
+// RUN: %clang -target x86_64 -pg -mfentry -O2 -### -E %s 2>&1 | FileCheck -check-prefix=FP %s
 
 // CHECK: "-mfentry"
 
 // RUN: %clang -target powerpc64le -c -### %s -mfentry 2>&1 | FileCheck --check-prefix=ERR %s
 
 // ERR: error: unsupported option '-mfentry' for target 'powerpc64le'
+
+// FP: "-mframe-pointer=all"
+// NOFP: "-mframe-pointer=none"
+void foo(void) {}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -586,6 +586,10 @@
   return false;
 }
   }
+  // If no target OS was specified (so no special rules above related to
+  // optimization levels made a decision...
+  if (Args.hasArg(options::OPT_pg) && 

[PATCH] D74698: [Driver] -pg shouldn't unconditionally add -mframe-pointer=all w/ -mfentry

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/test/Driver/mfentry.c:6
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 
-fno-omit-frame-pointer -### -E %s 2>&1 | FileCheck -check-prefix=FP 
--implicit-check-not='"-mframe-pointer=none"' %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 -### -E %s 2>&1 | 
FileCheck -check-prefix=NOFP --implicit-check-not='"-mframe-pointer=all"' %s
 

The only issue left is that `-target x86_64` still produces frame pointers 
since the above `useFramePointerForTargetByDefault()` just returns `true` when 
no target triple OS is specified. Do we care about that case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698



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


[PATCH] D74698: [CodeGen] -pg shouldn't unconditionally add "frame-pointer"="all" fn attr w/ -mfentry

2020-02-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

The title should be changed from CodeGen to Driver

And `fn attr` is no longer appropriate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698



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


[PATCH] D70876: [clang-tidy] Add spuriously-wake-up-functions check

2020-02-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM, do you need me to commit on your behalf?




Comment at: 
clang-tools-extra/test/clang-tidy/bugprone-spuriously-wake-up-functions.c:165
+int main() { return 0; }
\ No newline at end of file


Please add a newline to the end of the file.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D70876



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


[PATCH] D74698: [CodeGen] -pg shouldn't unconditionally add "frame-pointer"="all" fn attr w/ -mfentry

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 245265.
nickdesaulniers added a comment.

- s/gnu-linux/linux-gnu/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/mfentry.c


Index: clang/test/Driver/mfentry.c
===
--- clang/test/Driver/mfentry.c
+++ clang/test/Driver/mfentry.c
@@ -1,9 +1,16 @@
 // RUN: %clang -target s390x -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target i386 -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64 -c -### %s -mfentry 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O0 -### -E %s 2>&1 | 
FileCheck -check-prefix=FP --implicit-check-not='"-mframe-pointer=none"' %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 
-fno-omit-frame-pointer -### -E %s 2>&1 | FileCheck -check-prefix=FP 
--implicit-check-not='"-mframe-pointer=none"' %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 -### -E %s 2>&1 | 
FileCheck -check-prefix=NOFP --implicit-check-not='"-mframe-pointer=all"' %s
 
 // CHECK: "-mfentry"
 
 // RUN: %clang -target powerpc64le -c -### %s -mfentry 2>&1 | FileCheck 
--check-prefix=ERR %s
 
 // ERR: error: unsupported option '-mfentry' for target 'powerpc64le'
+
+// FP: "-mframe-pointer=all"
+// NOFP: "-mframe-pointer=none"
+void foo(void) {}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 


Index: clang/test/Driver/mfentry.c
===
--- clang/test/Driver/mfentry.c
+++ clang/test/Driver/mfentry.c
@@ -1,9 +1,16 @@
 // RUN: %clang -target s390x -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target i386 -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64 -c -### %s -mfentry 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O0 -### -E %s 2>&1 | FileCheck -check-prefix=FP --implicit-check-not='"-mframe-pointer=none"' %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 -fno-omit-frame-pointer -### -E %s 2>&1 | FileCheck -check-prefix=FP --implicit-check-not='"-mframe-pointer=none"' %s
+// RUN: %clang -target x86_64-linux-gnu -pg -mfentry -O2 -### -E %s 2>&1 | FileCheck -check-prefix=NOFP --implicit-check-not='"-mframe-pointer=all"' %s
 
 // CHECK: "-mfentry"
 
 // RUN: %clang -target powerpc64le -c -### %s -mfentry 2>&1 | FileCheck --check-prefix=ERR %s
 
 // ERR: error: unsupported option '-mfentry' for target 'powerpc64le'
+
+// FP: "-mframe-pointer=all"
+// NOFP: "-mframe-pointer=none"
+void foo(void) {}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74698: [CodeGen] -pg shouldn't unconditionally add "frame-pointer"="all" fn attr w/ -mfentry

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 245263.
nickdesaulniers added a comment.

- use -### -E and check for -mframe-pointer={all|none}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/mfentry.c


Index: clang/test/Driver/mfentry.c
===
--- clang/test/Driver/mfentry.c
+++ clang/test/Driver/mfentry.c
@@ -1,9 +1,16 @@
 // RUN: %clang -target s390x -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target i386 -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64 -c -### %s -mfentry 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O0 -### -E -o - %s 2>&1 
| FileCheck -check-prefix=FP --implicit-check-not='"-mframe-pointer=none"' %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O2 
-fno-omit-frame-pointer -### -E -o - %s 2>&1 | FileCheck -check-prefix=FP 
--implicit-check-not='"-mframe-pointer=none"' %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O2 -### -E -o - %s 2>&1 
| FileCheck -check-prefix=NOFP --implicit-check-not='"-mframe-pointer=all"' %s
 
 // CHECK: "-mfentry"
 
 // RUN: %clang -target powerpc64le -c -### %s -mfentry 2>&1 | FileCheck 
--check-prefix=ERR %s
 
 // ERR: error: unsupported option '-mfentry' for target 'powerpc64le'
+
+// FP: "-mframe-pointer=all"
+// NOFP: "-mframe-pointer=none"
+void foo(void) {}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 


Index: clang/test/Driver/mfentry.c
===
--- clang/test/Driver/mfentry.c
+++ clang/test/Driver/mfentry.c
@@ -1,9 +1,16 @@
 // RUN: %clang -target s390x -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target i386 -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64 -c -### %s -mfentry 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O0 -### -E -o - %s 2>&1 | FileCheck -check-prefix=FP --implicit-check-not='"-mframe-pointer=none"' %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O2 -fno-omit-frame-pointer -### -E -o - %s 2>&1 | FileCheck -check-prefix=FP --implicit-check-not='"-mframe-pointer=none"' %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O2 -### -E -o - %s 2>&1 | FileCheck -check-prefix=NOFP --implicit-check-not='"-mframe-pointer=all"' %s
 
 // CHECK: "-mfentry"
 
 // RUN: %clang -target powerpc64le -c -### %s -mfentry 2>&1 | FileCheck --check-prefix=ERR %s
 
 // ERR: error: unsupported option '-mfentry' for target 'powerpc64le'
+
+// FP: "-mframe-pointer=all"
+// NOFP: "-mframe-pointer=none"
+void foo(void) {}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74698: [CodeGen] -pg shouldn't unconditionally add "frame-pointer"="all" fn attr w/ -mfentry

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 245264.
nickdesaulniers added a comment.

- drop -o -


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/mfentry.c


Index: clang/test/Driver/mfentry.c
===
--- clang/test/Driver/mfentry.c
+++ clang/test/Driver/mfentry.c
@@ -1,9 +1,16 @@
 // RUN: %clang -target s390x -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target i386 -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64 -c -### %s -mfentry 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O0 -### -E %s 2>&1 | 
FileCheck -check-prefix=FP --implicit-check-not='"-mframe-pointer=none"' %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O2 
-fno-omit-frame-pointer -### -E %s 2>&1 | FileCheck -check-prefix=FP 
--implicit-check-not='"-mframe-pointer=none"' %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O2 -### -E %s 2>&1 | 
FileCheck -check-prefix=NOFP --implicit-check-not='"-mframe-pointer=all"' %s
 
 // CHECK: "-mfentry"
 
 // RUN: %clang -target powerpc64le -c -### %s -mfentry 2>&1 | FileCheck 
--check-prefix=ERR %s
 
 // ERR: error: unsupported option '-mfentry' for target 'powerpc64le'
+
+// FP: "-mframe-pointer=all"
+// NOFP: "-mframe-pointer=none"
+void foo(void) {}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 


Index: clang/test/Driver/mfentry.c
===
--- clang/test/Driver/mfentry.c
+++ clang/test/Driver/mfentry.c
@@ -1,9 +1,16 @@
 // RUN: %clang -target s390x -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target i386 -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64 -c -### %s -mfentry 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O0 -### -E %s 2>&1 | FileCheck -check-prefix=FP --implicit-check-not='"-mframe-pointer=none"' %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O2 -fno-omit-frame-pointer -### -E %s 2>&1 | FileCheck -check-prefix=FP --implicit-check-not='"-mframe-pointer=none"' %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O2 -### -E %s 2>&1 | FileCheck -check-prefix=NOFP --implicit-check-not='"-mframe-pointer=all"' %s
 
 // CHECK: "-mfentry"
 
 // RUN: %clang -target powerpc64le -c -### %s -mfentry 2>&1 | FileCheck --check-prefix=ERR %s
 
 // ERR: error: unsupported option '-mfentry' for target 'powerpc64le'
+
+// FP: "-mframe-pointer=all"
+// NOFP: "-mframe-pointer=none"
+void foo(void) {}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74698: [CodeGen] -pg shouldn't unconditionally add "frame-pointer"="all" fn attr w/ -mfentry

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 245260.
nickdesaulniers added a comment.

- add explicit target and spacing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/mfentry.c


Index: clang/test/Driver/mfentry.c
===
--- clang/test/Driver/mfentry.c
+++ clang/test/Driver/mfentry.c
@@ -1,9 +1,16 @@
 // RUN: %clang -target s390x -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target i386 -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64 -c -### %s -mfentry 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O0 -emit-llvm -S -o - %s 
| FileCheck -check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O2 
-fno-omit-frame-pointer -emit-llvm -S -o - %s | FileCheck -check-prefix=FP 
--implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O2 -emit-llvm -S -o - %s 
| FileCheck -check-prefix=NOFP --implicit-check-not='"frame-pointer"="all"' %s
 
 // CHECK: "-mfentry"
 
 // RUN: %clang -target powerpc64le -c -### %s -mfentry 2>&1 | FileCheck 
--check-prefix=ERR %s
 
 // ERR: error: unsupported option '-mfentry' for target 'powerpc64le'
+
+// FP: "frame-pointer"="all"
+// NOFP: "frame-pointer"="none"
+void foo(void) {}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 


Index: clang/test/Driver/mfentry.c
===
--- clang/test/Driver/mfentry.c
+++ clang/test/Driver/mfentry.c
@@ -1,9 +1,16 @@
 // RUN: %clang -target s390x -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target i386 -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64 -c -### %s -mfentry 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O0 -emit-llvm -S -o - %s | FileCheck -check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O2 -fno-omit-frame-pointer -emit-llvm -S -o - %s | FileCheck -check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -target x86_64-gnu-linux -pg -mfentry -O2 -emit-llvm -S -o - %s | FileCheck -check-prefix=NOFP --implicit-check-not='"frame-pointer"="all"' %s
 
 // CHECK: "-mfentry"
 
 // RUN: %clang -target powerpc64le -c -### %s -mfentry 2>&1 | FileCheck --check-prefix=ERR %s
 
 // ERR: error: unsupported option '-mfentry' for target 'powerpc64le'
+
+// FP: "frame-pointer"="all"
+// NOFP: "frame-pointer"="none"
+void foo(void) {}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74698: [CodeGen] -pg shouldn't unconditionally add "frame-pointer"="all" fn attr w/ -mfentry

2020-02-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/mfentry.c:5
+// RUN: %clang -pg -mfentry -O0 -emit-llvm -S -o - %s | FileCheck 
-check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -fno-omit-frame-pointer -emit-llvm -S -o - %s 
| FileCheck -check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -emit-llvm -S -o - %s | FileCheck 
-check-prefix=NOFP --implicit-check-not='"frame-pointer"="all"' %s

nickdesaulniers wrote:
> MaskRay wrote:
> > Change `-emit-llvm` to `-###` and delete `--implicit-check-not`. And add 
> > `-target x86_64`, because some targets don't support `-mfentry`.
> > 
> > For IR output, there can be multiple `"frame-pointer"="all"` function 
> > attributes. `--implicit-check-not` helps detect undesired attributes.
> > 
> > For cc1 options, there can't be multiple "frame-pointer" options. So 
> > `--implicit-check-not` is not useful.
> `-target x86_64` seems like a good idea, but `-###` produces:
> 
> ```
> clang-10: warning: argument unused during compilation: '-pg' 
> [-Wunused-command-line-argument]
> clang-10: warning: argument unused during compilation: '-O2' 
> [-Wunused-command-line-argument]
> clang-10: warning: argument unused during compilation: '-mfentry' 
> [-Wunused-command-line-argument]
> ```
> so I don't think we want that. Or am I "holding it wrong?"
It works fine here.

Did you add some other unrelated options during testing? You can drop `-o -` by 
the way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

As a heads up, Linaro's ToolChain Working Group's Linux kernel CI lit up on 
this change. I see it's been reverted (thank you). Please cc me on the updated 
patch and I can help test it against the Linux kernel.

Edit: Link: 
https://ci.linaro.org/job/tcwg_kernel-bisect-llvm-master-arm-mainline-allyesconfig/25/artifact/artifacts/build-a82d3e8a6e67473c94a5ce6345372748e9b61718/03-build_linux/console.log


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

https://reviews.llvm.org/D73534



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


[PATCH] D74790: [Sema][CodeComplete] Handle symlinks for include code completion

2020-02-18 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 245256.
dgoldman added a comment.

- Add test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74790

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/included-symlinks.cpp


Index: clang/test/CodeCompletion/included-symlinks.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/included-symlinks.cpp
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t && mkdir -p %t/real/myproj && mkdir -p %t/links
+// RUN: touch %t/real/foo.h && ln -s %t/real/foo.h %t/links/foo.h
+// RUN: touch %t/real/foobar.h && ln -s %t/real/foobar.h %t/links/foobar.h
+// RUN: touch %t/real/myproj/test.h && ln -s %t/real/myproj %t/links/myproj
+
+// Suggest symlinked header files.
+#include "foo.h"
+// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:7:13 %s 
| FileCheck -check-prefix=CHECK-1 %s
+// CHECK-1: foo.h"
+// CHECK-1: foobar.h"
+
+// Suggest symlinked folder.
+#include "mypr"
+// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:13:13 
%s | FileCheck -check-prefix=CHECK-2 %s
+// CHECK-2: myproj/
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -8776,7 +8776,19 @@
   if (++Count == 2500) // If we happen to hit a huge directory,
 break; // bail out early so we're not too slow.
   StringRef Filename = llvm::sys::path::filename(It->path());
-  switch (It->type()) {
+
+  // We need to manually resolve symlinks since the directory_iterator
+  // doesn't do it for us. Alternatively we could use a heuristic such as
+  // file extension, but this should be okay as long as there aren't many
+  // symlinks.
+  auto Type = It->type();
+  if (Type == llvm::sys::fs::file_type::symlink_file) {
+auto FileStatus = FS.status(It->path());
+if (FileStatus) {
+  Type = FileStatus->getType();
+}
+  }
+  switch (Type) {
   case llvm::sys::fs::file_type::directory_file:
 // All entries in a framework directory must have a ".framework" 
suffix,
 // but the suffix does not appear in the source code's include/import.


Index: clang/test/CodeCompletion/included-symlinks.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/included-symlinks.cpp
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t && mkdir -p %t/real/myproj && mkdir -p %t/links
+// RUN: touch %t/real/foo.h && ln -s %t/real/foo.h %t/links/foo.h
+// RUN: touch %t/real/foobar.h && ln -s %t/real/foobar.h %t/links/foobar.h
+// RUN: touch %t/real/myproj/test.h && ln -s %t/real/myproj %t/links/myproj
+
+// Suggest symlinked header files.
+#include "foo.h"
+// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:7:13 %s | FileCheck -check-prefix=CHECK-1 %s
+// CHECK-1: foo.h"
+// CHECK-1: foobar.h"
+
+// Suggest symlinked folder.
+#include "mypr"
+// RUN: %clang -fsyntax-only -I%t/links -Xclang -code-completion-at=%s:13:13 %s | FileCheck -check-prefix=CHECK-2 %s
+// CHECK-2: myproj/
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -8776,7 +8776,19 @@
   if (++Count == 2500) // If we happen to hit a huge directory,
 break; // bail out early so we're not too slow.
   StringRef Filename = llvm::sys::path::filename(It->path());
-  switch (It->type()) {
+
+  // We need to manually resolve symlinks since the directory_iterator
+  // doesn't do it for us. Alternatively we could use a heuristic such as
+  // file extension, but this should be okay as long as there aren't many
+  // symlinks.
+  auto Type = It->type();
+  if (Type == llvm::sys::fs::file_type::symlink_file) {
+auto FileStatus = FS.status(It->path());
+if (FileStatus) {
+  Type = FileStatus->getType();
+}
+  }
+  switch (Type) {
   case llvm::sys::fs::file_type::directory_file:
 // All entries in a framework directory must have a ".framework" suffix,
 // but the suffix does not appear in the source code's include/import.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74698: [CodeGen] -pg shouldn't unconditionally add "frame-pointer"="all" fn attr w/ -mfentry

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers marked an inline comment as done.
nickdesaulniers added inline comments.



Comment at: clang/test/Driver/mfentry.c:5
+// RUN: %clang -pg -mfentry -O0 -emit-llvm -S -o - %s | FileCheck 
-check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -fno-omit-frame-pointer -emit-llvm -S -o - %s 
| FileCheck -check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -emit-llvm -S -o - %s | FileCheck 
-check-prefix=NOFP --implicit-check-not='"frame-pointer"="all"' %s

MaskRay wrote:
> Change `-emit-llvm` to `-###` and delete `--implicit-check-not`. And add 
> `-target x86_64`, because some targets don't support `-mfentry`.
> 
> For IR output, there can be multiple `"frame-pointer"="all"` function 
> attributes. `--implicit-check-not` helps detect undesired attributes.
> 
> For cc1 options, there can't be multiple "frame-pointer" options. So 
> `--implicit-check-not` is not useful.
`-target x86_64` seems like a good idea, but `-###` produces:

```
clang-10: warning: argument unused during compilation: '-pg' 
[-Wunused-command-line-argument]
clang-10: warning: argument unused during compilation: '-O2' 
[-Wunused-command-line-argument]
clang-10: warning: argument unused during compilation: '-mfentry' 
[-Wunused-command-line-argument]
```
so I don't think we want that. Or am I "holding it wrong?"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698



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


[PATCH] D73916: [clang] Add `forceReload` clangd extension to 'textDocument/didChange'

2020-02-18 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Which client(s) use or plan to use this extension?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73916



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


[PATCH] D74698: [CodeGen] -pg shouldn't unconditionally add "frame-pointer"="all" fn attr w/ -mfentry

2020-02-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/mfentry.c:5
+// RUN: %clang -pg -mfentry -O0 -emit-llvm -S -o - %s | FileCheck 
-check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -fno-omit-frame-pointer -emit-llvm -S -o - %s 
| FileCheck -check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -emit-llvm -S -o - %s | FileCheck 
-check-prefix=NOFP --implicit-check-not='"frame-pointer"="all"' %s

Change `-emit-llvm` to `-###` and delete `--implicit-check-not`. And add 
`-target x86_64`, because some targets don't support `-mfentry`.

For IR output, there can be multiple `"frame-pointer"="all"` function 
attributes. `--implicit-check-not` helps detect undesired attributes.

For cc1 options, there can't be multiple "frame-pointer" options. So 
`--implicit-check-not` is not useful.



Comment at: clang/test/Driver/mfentry.c:14
+
+//FP: "frame-pointer"="all"
+//NOFP: "frame-pointer"="none"

`// FP`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698



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


[PATCH] D74787: [IRBuilder] Always respect inserter/folder

2020-02-18 Thread Nikita Popov via Phabricator via cfe-commits
nikic marked an inline comment as done.
nikic added inline comments.



Comment at: llvm/test/Transforms/InstCombine/saturating-add-sub.ll:2
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -instcombine -S | FileCheck %s
+; RUN: opt < %s -instcombine -instcombine-infinite-loop-threshold=2 -S | 
FileCheck %s
 

Meinersbur wrote:
> IMHO how the folding works internally (folded by IRBuilder instead of 
> InstCombine rule) does not need to be part of a/this regression test. If 
> another test is added to this file requiring 3 rounds, it would raise some 
> confusions.
To clarify, "iterations" here is how often InstCombine runs (with a full 
instruction scan), not how many instructions each run visits. There should be 
at most two iterations, one to perform folds and one to verify the fixpoint. If 
there are more iterations, that's a bug in worklist management. I'm currently 
tracking down all these bugs and annotating tests with 
`-instcombine-infinite-loop-threshold=2` to verify that the issue is indeed 
fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74787



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


[PATCH] D74698: [CodeGen] -pg shouldn't unconditionally add "frame-pointer"="all" fn attr w/ -mfentry

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 245249.
nickdesaulniers added a comment.

- move test from clang/test/CodeGen/fentry to clang/test/Driver/mfentry


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/mfentry.c


Index: clang/test/Driver/mfentry.c
===
--- clang/test/Driver/mfentry.c
+++ clang/test/Driver/mfentry.c
@@ -1,9 +1,16 @@
 // RUN: %clang -target s390x -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target i386 -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64 -c -### %s -mfentry 2>&1 | FileCheck %s
+// RUN: %clang -pg -mfentry -O0 -emit-llvm -S -o - %s | FileCheck 
-check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -fno-omit-frame-pointer -emit-llvm -S -o - %s 
| FileCheck -check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -emit-llvm -S -o - %s | FileCheck 
-check-prefix=NOFP --implicit-check-not='"frame-pointer"="all"' %s
 
 // CHECK: "-mfentry"
 
 // RUN: %clang -target powerpc64le -c -### %s -mfentry 2>&1 | FileCheck 
--check-prefix=ERR %s
 
 // ERR: error: unsupported option '-mfentry' for target 'powerpc64le'
+
+//FP: "frame-pointer"="all"
+//NOFP: "frame-pointer"="none"
+void foo(void) {}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 


Index: clang/test/Driver/mfentry.c
===
--- clang/test/Driver/mfentry.c
+++ clang/test/Driver/mfentry.c
@@ -1,9 +1,16 @@
 // RUN: %clang -target s390x -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target i386 -c -### %s -mfentry 2>&1 | FileCheck %s
 // RUN: %clang -target x86_64 -c -### %s -mfentry 2>&1 | FileCheck %s
+// RUN: %clang -pg -mfentry -O0 -emit-llvm -S -o - %s | FileCheck -check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -fno-omit-frame-pointer -emit-llvm -S -o - %s | FileCheck -check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -emit-llvm -S -o - %s | FileCheck -check-prefix=NOFP --implicit-check-not='"frame-pointer"="all"' %s
 
 // CHECK: "-mfentry"
 
 // RUN: %clang -target powerpc64le -c -### %s -mfentry 2>&1 | FileCheck --check-prefix=ERR %s
 
 // ERR: error: unsupported option '-mfentry' for target 'powerpc64le'
+
+//FP: "frame-pointer"="all"
+//NOFP: "frame-pointer"="none"
+void foo(void) {}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74790: [Sema][CodeComplete] Handle symlinks for include code completion

2020-02-18 Thread David Goldman via Phabricator via cfe-commits
dgoldman created this revision.
dgoldman added a reviewer: sammccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously any symlinks would be ignored since the directory
traversal doesn't follow them.

With this change we now follow symlinks (via a `stat` call
in order to figure out the target type of the symlink if it
is valid).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74790

Files:
  clang/lib/Sema/SemaCodeComplete.cpp


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -8776,7 +8776,19 @@
   if (++Count == 2500) // If we happen to hit a huge directory,
 break; // bail out early so we're not too slow.
   StringRef Filename = llvm::sys::path::filename(It->path());
-  switch (It->type()) {
+
+  // We need to manually resolve symlinks since the directory_iterator
+  // doesn't do it for us. Alternatively we could use a heuristic such as
+  // file extension, but this should be okay as long as there aren't many
+  // symlinks.
+  auto Type = It->type();
+  if (Type == llvm::sys::fs::file_type::symlink_file) {
+auto FileStatus = FS.status(It->path());
+if (FileStatus) {
+  Type = FileStatus->getType();
+}
+  }
+  switch (Type) {
   case llvm::sys::fs::file_type::directory_file:
 // All entries in a framework directory must have a ".framework" 
suffix,
 // but the suffix does not appear in the source code's include/import.


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -8776,7 +8776,19 @@
   if (++Count == 2500) // If we happen to hit a huge directory,
 break; // bail out early so we're not too slow.
   StringRef Filename = llvm::sys::path::filename(It->path());
-  switch (It->type()) {
+
+  // We need to manually resolve symlinks since the directory_iterator
+  // doesn't do it for us. Alternatively we could use a heuristic such as
+  // file extension, but this should be okay as long as there aren't many
+  // symlinks.
+  auto Type = It->type();
+  if (Type == llvm::sys::fs::file_type::symlink_file) {
+auto FileStatus = FS.status(It->path());
+if (FileStatus) {
+  Type = FileStatus->getType();
+}
+  }
+  switch (Type) {
   case llvm::sys::fs::file_type::directory_file:
 // All entries in a framework directory must have a ".framework" suffix,
 // but the suffix does not appear in the source code's include/import.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74698: [CodeGen] -pg shouldn't unconditionally add "frame-pointer"="all" fn attr w/ -mfentry

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 245245.
nickdesaulniers added a comment.

- add test for explicitly re-enabling -fno-omit-frame-pointer at -O2


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/fentry.c


Index: clang/test/CodeGen/fentry.c
===
--- clang/test/CodeGen/fentry.c
+++ clang/test/CodeGen/fentry.c
@@ -2,6 +2,9 @@
 // RUN: %clang_cc1 -pg -mfentry -triple x86_64-unknown-linux-gnu -emit-llvm -o 
- %s | FileCheck %s
 // RUN: %clang_cc1 -mfentry -triple i386-unknown-unknown -emit-llvm -o - %s | 
FileCheck -check-prefix=NOPG %s
 // RUN: %clang_cc1 -mfentry -triple x86_64-unknown-linux-gnu -emit-llvm -o - 
%s | FileCheck -check-prefix=NOPG %s
+// RUN: %clang -pg -mfentry -O0 -emit-llvm -S -o - %s | FileCheck 
-check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -fno-omit-frame-pointer -emit-llvm -S -o - %s 
| FileCheck -check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -emit-llvm -S -o - %s | FileCheck 
-check-prefix=NOFP --implicit-check-not='"frame-pointer"="all"' %s
 
 int foo(void) {
   return 0;
@@ -16,3 +19,5 @@
 //CHECK-NOT: attributes #1 = { {{.*}}"fentry-call"="true"{{.*}} }
 //NOPG-NOT: attributes #0 = { {{.*}}"fentry-call"{{.*}} }
 //NOPG-NOT: attributes #1 = { {{.*}}"fentry-call"{{.*}} }
+//FP: "frame-pointer"="all"
+//NOFP: "frame-pointer"="none"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 


Index: clang/test/CodeGen/fentry.c
===
--- clang/test/CodeGen/fentry.c
+++ clang/test/CodeGen/fentry.c
@@ -2,6 +2,9 @@
 // RUN: %clang_cc1 -pg -mfentry -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -mfentry -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck -check-prefix=NOPG %s
 // RUN: %clang_cc1 -mfentry -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=NOPG %s
+// RUN: %clang -pg -mfentry -O0 -emit-llvm -S -o - %s | FileCheck -check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -fno-omit-frame-pointer -emit-llvm -S -o - %s | FileCheck -check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -emit-llvm -S -o - %s | FileCheck -check-prefix=NOFP --implicit-check-not='"frame-pointer"="all"' %s
 
 int foo(void) {
   return 0;
@@ -16,3 +19,5 @@
 //CHECK-NOT: attributes #1 = { {{.*}}"fentry-call"="true"{{.*}} }
 //NOPG-NOT: attributes #0 = { {{.*}}"fentry-call"{{.*}} }
 //NOPG-NOT: attributes #1 = { {{.*}}"fentry-call"{{.*}} }
+//FP: "frame-pointer"="all"
+//NOFP: "frame-pointer"="none"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74698: [CodeGen] -pg shouldn't unconditionally add "frame-pointer"="all" fn attr w/ -mfentry

2020-02-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/CodeGen/fentry.c:6
+// RUN: %clang -pg -mfentry -O0 -emit-llvm -S -o - %s | FileCheck 
-check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -fno-omit-frame-pointer -emit-llvm -S -o - %s 
| FileCheck -check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -emit-llvm -S -o - %s | FileCheck 
-check-prefix=NOFP --implicit-check-not='"frame-pointer"="all"' %s

Oh, `%clang` tests should be moved to `test/Driver/mfentry.c`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698



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


[PATCH] D74631: [clang][XCOFF] Indicate that XCOFF does not support COMDATs

2020-02-18 Thread David Tenty via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG58817a0783ca: [clang][XCOFF] Indicate that XCOFF does not 
support COMDATs (authored by daltenty).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74631

Files:
  clang/test/CodeGen/xcoff-comdat.cpp
  llvm/docs/LangRef.rst
  llvm/include/llvm/ADT/Triple.h


Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -743,7 +743,7 @@
 
   /// Tests whether the target supports comdat
   bool supportsCOMDAT() const {
-return !isOSBinFormatMachO();
+return !(isOSBinFormatMachO() || isOSBinFormatXCOFF());
   }
 
   /// Tests whether the target uses emulated TLS as default.
Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -910,8 +910,8 @@
 The linker may choose any COMDAT key but the sections must contain the
 same amount of data.
 
-Note that the Mach-O platform doesn't support COMDATs, and ELF and WebAssembly
-only support ``any`` as a selection kind.
+Note that XCOFF and the Mach-O platform don't support COMDATs, and ELF and
+WebAssembly only support ``any`` as a selection kind.
 
 Here is an example of a COMDAT group where a function will only be selected if
 the COMDAT key's section is the largest:
Index: clang/test/CodeGen/xcoff-comdat.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xcoff-comdat.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -emit-llvm -o - %s | FileCheck %s
+
+class a {
+  virtual void d() {}
+  virtual void e();
+};
+void a::e() {}
+
+// CHECK-NOT: = comdat


Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -743,7 +743,7 @@
 
   /// Tests whether the target supports comdat
   bool supportsCOMDAT() const {
-return !isOSBinFormatMachO();
+return !(isOSBinFormatMachO() || isOSBinFormatXCOFF());
   }
 
   /// Tests whether the target uses emulated TLS as default.
Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -910,8 +910,8 @@
 The linker may choose any COMDAT key but the sections must contain the
 same amount of data.
 
-Note that the Mach-O platform doesn't support COMDATs, and ELF and WebAssembly
-only support ``any`` as a selection kind.
+Note that XCOFF and the Mach-O platform don't support COMDATs, and ELF and
+WebAssembly only support ``any`` as a selection kind.
 
 Here is an example of a COMDAT group where a function will only be selected if
 the COMDAT key's section is the largest:
Index: clang/test/CodeGen/xcoff-comdat.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xcoff-comdat.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -emit-llvm -o - %s | FileCheck %s
+
+class a {
+  virtual void d() {}
+  virtual void e();
+};
+void a::e() {}
+
+// CHECK-NOT: = comdat
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74698: [CodeGen] -pg shouldn't add "frame-pointer"="all" fn attr w/ -mfentry

2020-02-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 245241.
nickdesaulniers added a comment.

- prefer implicit-check-not, add test for -O2 vs -O0


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74698

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/fentry.c


Index: clang/test/CodeGen/fentry.c
===
--- clang/test/CodeGen/fentry.c
+++ clang/test/CodeGen/fentry.c
@@ -2,6 +2,8 @@
 // RUN: %clang_cc1 -pg -mfentry -triple x86_64-unknown-linux-gnu -emit-llvm -o 
- %s | FileCheck %s
 // RUN: %clang_cc1 -mfentry -triple i386-unknown-unknown -emit-llvm -o - %s | 
FileCheck -check-prefix=NOPG %s
 // RUN: %clang_cc1 -mfentry -triple x86_64-unknown-linux-gnu -emit-llvm -o - 
%s | FileCheck -check-prefix=NOPG %s
+// RUN: %clang -pg -mfentry -O0 -emit-llvm -S -o - %s | FileCheck 
-check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -emit-llvm -S -o - %s | FileCheck 
-check-prefix=NOFP --implicit-check-not='"frame-pointer"="all"' %s
 
 int foo(void) {
   return 0;
@@ -16,3 +18,5 @@
 //CHECK-NOT: attributes #1 = { {{.*}}"fentry-call"="true"{{.*}} }
 //NOPG-NOT: attributes #0 = { {{.*}}"fentry-call"{{.*}} }
 //NOPG-NOT: attributes #1 = { {{.*}}"fentry-call"{{.*}} }
+//FP: "frame-pointer"="all"
+//NOFP: "frame-pointer"="none"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 


Index: clang/test/CodeGen/fentry.c
===
--- clang/test/CodeGen/fentry.c
+++ clang/test/CodeGen/fentry.c
@@ -2,6 +2,8 @@
 // RUN: %clang_cc1 -pg -mfentry -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -mfentry -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck -check-prefix=NOPG %s
 // RUN: %clang_cc1 -mfentry -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=NOPG %s
+// RUN: %clang -pg -mfentry -O0 -emit-llvm -S -o - %s | FileCheck -check-prefix=FP --implicit-check-not='"frame-pointer"="none"' %s
+// RUN: %clang -pg -mfentry -O2 -emit-llvm -S -o - %s | FileCheck -check-prefix=NOFP --implicit-check-not='"frame-pointer"="all"' %s
 
 int foo(void) {
   return 0;
@@ -16,3 +18,5 @@
 //CHECK-NOT: attributes #1 = { {{.*}}"fentry-call"="true"{{.*}} }
 //NOPG-NOT: attributes #0 = { {{.*}}"fentry-call"{{.*}} }
 //NOPG-NOT: attributes #1 = { {{.*}}"fentry-call"{{.*}} }
+//FP: "frame-pointer"="all"
+//NOFP: "frame-pointer"="none"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+!Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74634: Remove "ELF Only" restriction from section flags

2020-02-18 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa0a1f412fd1d: Remove ELF Only from -f*-sections 
help text (authored by rnk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74634

Files:
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1952,10 +1952,10 @@
 def fzero_initialized_in_bss : Flag<["-"], "fzero-initialized-in-bss">, 
Group;
 def ffunction_sections : Flag<["-"], "ffunction-sections">, Group,
   Flags<[CC1Option]>,
-  HelpText<"Place each function in its own section (ELF Only)">;
+  HelpText<"Place each function in its own section">;
 def fno_function_sections : Flag<["-"], "fno-function-sections">, 
Group;
 def fdata_sections : Flag <["-"], "fdata-sections">, Group,
- Flags<[CC1Option]>, HelpText<"Place each data in its own section (ELF Only)">;
+ Flags<[CC1Option]>, HelpText<"Place each data in its own section">;
 def fno_data_sections : Flag <["-"], "fno-data-sections">, Group;
 def fstack_size_section : Flag<["-"], "fstack-size-section">, Group, 
Flags<[CC1Option]>,
   HelpText<"Emit section containing metadata on function stack sizes">;
@@ -1964,7 +1964,7 @@
 
 def funique_section_names : Flag <["-"], "funique-section-names">,
   Group,
-  HelpText<"Use unique names for text and data sections (ELF Only)">;
+  HelpText<"Use unique names for text and data sections">;
 def fno_unique_section_names : Flag <["-"], "fno-unique-section-names">,
   Group, Flags<[CC1Option]>;
 


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1952,10 +1952,10 @@
 def fzero_initialized_in_bss : Flag<["-"], "fzero-initialized-in-bss">, Group;
 def ffunction_sections : Flag<["-"], "ffunction-sections">, Group,
   Flags<[CC1Option]>,
-  HelpText<"Place each function in its own section (ELF Only)">;
+  HelpText<"Place each function in its own section">;
 def fno_function_sections : Flag<["-"], "fno-function-sections">, Group;
 def fdata_sections : Flag <["-"], "fdata-sections">, Group,
- Flags<[CC1Option]>, HelpText<"Place each data in its own section (ELF Only)">;
+ Flags<[CC1Option]>, HelpText<"Place each data in its own section">;
 def fno_data_sections : Flag <["-"], "fno-data-sections">, Group;
 def fstack_size_section : Flag<["-"], "fstack-size-section">, Group, Flags<[CC1Option]>,
   HelpText<"Emit section containing metadata on function stack sizes">;
@@ -1964,7 +1964,7 @@
 
 def funique_section_names : Flag <["-"], "funique-section-names">,
   Group,
-  HelpText<"Use unique names for text and data sections (ELF Only)">;
+  HelpText<"Use unique names for text and data sections">;
 def fno_unique_section_names : Flag <["-"], "fno-unique-section-names">,
   Group, Flags<[CC1Option]>;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 58817a0 - [clang][XCOFF] Indicate that XCOFF does not support COMDATs

2020-02-18 Thread David Tenty via cfe-commits

Author: David Tenty
Date: 2020-02-18T16:10:11-05:00
New Revision: 58817a0783ca405cd36a312c7ee80e061d1cecc5

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

LOG: [clang][XCOFF] Indicate that XCOFF does not support COMDATs

Summary: XCOFF doesn't support COMDATs, so clang shouldn't emit them.

Reviewers: stevewan, sfertile, Xiangling_L

Reviewed By: sfertile

Subscribers: dschuff, aheejin, dexonsmith, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 
clang/test/CodeGen/xcoff-comdat.cpp

Modified: 
llvm/docs/LangRef.rst
llvm/include/llvm/ADT/Triple.h

Removed: 




diff  --git a/clang/test/CodeGen/xcoff-comdat.cpp 
b/clang/test/CodeGen/xcoff-comdat.cpp
new file mode 100644
index ..7da8d9a2cc22
--- /dev/null
+++ b/clang/test/CodeGen/xcoff-comdat.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -emit-llvm -o - %s | FileCheck %s
+
+class a {
+  virtual void d() {}
+  virtual void e();
+};
+void a::e() {}
+
+// CHECK-NOT: = comdat

diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 2a61e0b19987..d14853a4e0d5 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -910,8 +910,8 @@ The selection kind must be one of the following:
 The linker may choose any COMDAT key but the sections must contain the
 same amount of data.
 
-Note that the Mach-O platform doesn't support COMDATs, and ELF and WebAssembly
-only support ``any`` as a selection kind.
+Note that XCOFF and the Mach-O platform don't support COMDATs, and ELF and
+WebAssembly only support ``any`` as a selection kind.
 
 Here is an example of a COMDAT group where a function will only be selected if
 the COMDAT key's section is the largest:

diff  --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index 76a754d671fb..64ba8d7e21e4 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/include/llvm/ADT/Triple.h
@@ -743,7 +743,7 @@ class Triple {
 
   /// Tests whether the target supports comdat
   bool supportsCOMDAT() const {
-return !isOSBinFormatMachO();
+return !(isOSBinFormatMachO() || isOSBinFormatXCOFF());
   }
 
   /// Tests whether the target uses emulated TLS as default.



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


[clang] a0a1f41 - Remove "ELF Only" from -f*-sections help text

2020-02-18 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-02-18T12:59:50-08:00
New Revision: a0a1f412fd1d86146c5b4ef5b7b66fcc57a8b56b

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

LOG: Remove "ELF Only" from -f*-sections help text

-ffunction-sections and -fdata-sections are well supported by many
object file formats:
- ELF
- COFF
- XCOFF
- wasm
Only MachO ignores this flag.

While here, remove it from -funique-section-names. Wasm honors this
option.

Addresses PR44910.

Reviewed By: hans, aaron.ballman

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index b0e9d9590fde..1a42925ca530 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1952,10 +1952,10 @@ def fwritable_strings : Flag<["-"], 
"fwritable-strings">, Group, Flags<
 def fzero_initialized_in_bss : Flag<["-"], "fzero-initialized-in-bss">, 
Group;
 def ffunction_sections : Flag<["-"], "ffunction-sections">, Group,
   Flags<[CC1Option]>,
-  HelpText<"Place each function in its own section (ELF Only)">;
+  HelpText<"Place each function in its own section">;
 def fno_function_sections : Flag<["-"], "fno-function-sections">, 
Group;
 def fdata_sections : Flag <["-"], "fdata-sections">, Group,
- Flags<[CC1Option]>, HelpText<"Place each data in its own section (ELF Only)">;
+ Flags<[CC1Option]>, HelpText<"Place each data in its own section">;
 def fno_data_sections : Flag <["-"], "fno-data-sections">, Group;
 def fstack_size_section : Flag<["-"], "fstack-size-section">, Group, 
Flags<[CC1Option]>,
   HelpText<"Emit section containing metadata on function stack sizes">;
@@ -1964,7 +1964,7 @@ def fno_stack_size_section : Flag<["-"], 
"fno-stack-size-section">, Group,
   Group,
-  HelpText<"Use unique names for text and data sections (ELF Only)">;
+  HelpText<"Use unique names for text and data sections">;
 def fno_unique_section_names : Flag <["-"], "fno-unique-section-names">,
   Group, Flags<[CC1Option]>;
 



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


[PATCH] D74689: [clang-tidy] Better custom class support for performance-inefficient-vector-operation

2020-02-18 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 245240.
njames93 added a comment.

- Better template support
- Removed excess code
- Refactor alot of the check


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74689

Files:
  clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
  clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
  
clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-vector-operation.cpp
@@ -1,7 +1,11 @@
 // RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- \
-// RUN: -format-style=llvm \
 // RUN: -config='{CheckOptions: \
-// RUN:  [{key: performance-inefficient-vector-operation.EnableProto, value: 1}]}'
+// RUN:  [{key: performance-inefficient-vector-operation.EnableProto, value: 1}, \
+// RUN:   {key: performance-inefficient-vector-operation.VectorLikeClasses, value : MyContainer}, \
+// RUN:   {key: performance-inefficient-vector-operation.SupportedRanges, value : MyContainer}, \
+// RUN:   {key: performance-inefficient-vector-operation.ReserveNames, value : Reserve}, \
+// RUN:   {key: performance-inefficient-vector-operation.AppendNames, value : PushBack}, \
+// RUN:   {key: performance-inefficient-vector-operation.SizeNames, value : Size}, ]}'
 
 namespace std {
 
@@ -359,3 +363,273 @@
 }
   }
 }
+
+namespace OptionsValidMatchDefault {
+template 
+class MyContainer {
+public:
+  unsigned size() const;
+  T *begin() const;
+  T *end() const;
+  void push_back(const T &);
+  void reserve(unsigned);
+};
+
+void foo(const MyContainer ) {
+  MyContainer CC1;
+  // CHECK-FIXES: {{^}}  CC1.reserve(C.size());
+  for (auto I : C) {
+CC1.push_back(I);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'push_back' is called
+  }
+}
+} // namespace OptionsValidMatchDefault
+
+namespace OptionsValidMatchDifferentMethods {
+template 
+class MyContainer {
+public:
+  unsigned Size() const;
+  T *begin() const;
+  T *end() const;
+  void PushBack(const T &);
+  void Reserve(unsigned);
+};
+
+void foo(const MyContainer ) {
+  MyContainer CC2;
+  // CHECK-FIXES: {{^}}  CC2.Reserve(C.Size());
+  for (auto I : C) {
+CC2.PushBack(I);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'PushBack' is called
+  }
+}
+} // namespace OptionsValidMatchDifferentMethods
+
+namespace UnknownContainer {
+template 
+class MyUContainer {
+public:
+  unsigned size() const;
+  T *begin() const;
+  T *end() const;
+  void push_back(const T &);
+  void reserve(unsigned);
+};
+
+void foo(const MyUContainer ) {
+  // MyUContainer isn't specified as a VectorLikeClass in the Config Options
+  MyUContainer CC3;
+  // CHECK-FIXES-NOT: {{^}}  CC3.reserve(C.size());
+  for (auto I : C) {
+CC3.push_back(I);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:5: warning: 'push_back' is called
+  }
+}
+} // namespace UnknownContainer
+
+namespace PrivateMethods {
+namespace Size {
+template 
+class MyContainer {
+  unsigned size() const;
+
+public:
+  T *begin() const;
+  T *end() const;
+  void push_back(const T &);
+  void reserve(unsigned);
+};
+
+void foo(const MyContainer ) {
+  // MyContainer::size is private, so calling it will be invalid
+  MyContainer CC4;
+  // CHECK-FIXES-NOT: {{^}}  CC4.reserve(C.size());
+  for (auto I : C) {
+CC4.push_back(I);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:5: warning: 'push_back' is called
+  }
+}
+} // namespace Size
+namespace Reserve {
+template 
+class MyContainer {
+public:
+  unsigned size() const;
+  T *begin() const;
+  T *end() const;
+  void push_back(const T &);
+
+private:
+  void reserve(unsigned);
+};
+
+void foo(const MyContainer ) {
+  // MyContainer::reserve is private, so calling it will be invalid
+  MyContainer CC5;
+  // CHECK-FIXES-NOT: {{^}}  CC5.reserve(C.size());
+  for (auto I : C) {
+CC5.push_back(I);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:5: warning: 'push_back' is called
+  }
+}
+} // namespace Reserve
+} // namespace PrivateMethods
+
+namespace BadSignatures {
+namespace Size {
+template 
+class MyContainer {
+public:
+  char *size() const;
+  T *begin() const;
+  T *end() const;
+  void push_back(const T &);
+  void reserve(unsigned);
+};
+
+void foo(const MyContainer ) {
+  // MyContainer::size doesn't return an integral type(char *), so ignore this class
+  MyContainer CC6;
+  // CHECK-FIXES-NOT: {{^}}  CC6.reserve(C.size());
+  for (auto I : C) {
+CC6.push_back(I);
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:5: 

[PATCH] D72231: [Sema] Adds the pointer-to-int-cast diagnostic

2020-02-18 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

In D72231#1879347 , @rjmccall wrote:

> In D72231#1878528 , @nathanchance 
> wrote:
>
> > There appear to a be semantic difference between GCC and clang with the 
> > current version of this patch which results in a lot of additional warnings 
> > in the Linux kernel: https://godbolt.org/z/eHFJd8
>
>
> Warning about casting to an enum seems clearly correct and in scope for this 
> warning.  Warning about casting to `_Bool` seems clearly incorrect and should 
> not be warned about at all.


Agreed. I'll look at a followup patch to remove the warning for _Bool.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72231



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


[PATCH] D74784: [driver][darwin] Don't use -platform_version flag by default

2020-02-18 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Code change looks correct to me.  Thanks for the fix!

@arphaman, can you confirm the test changes are reasonable?  My instinct would 
have been, instead of changing all of the 400s to 0s, to just adding a single 
`RUN` line somewhere to confirm we don't do the wrong thing for 0.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74784



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


[PATCH] D74787: [IRBuilder] Always respect inserter/folder

2020-02-18 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

Nice work




Comment at: llvm/test/Transforms/InstCombine/saturating-add-sub.ll:2
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -instcombine -S | FileCheck %s
+; RUN: opt < %s -instcombine -instcombine-infinite-loop-threshold=2 -S | 
FileCheck %s
 

IMHO how the folding works internally (folded by IRBuilder instead of 
InstCombine rule) does not need to be part of a/this regression test. If 
another test is added to this file requiring 3 rounds, it would raise some 
confusions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74787



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


[PATCH] D74033: [clang-tidy] Fix PR#44620 'readability-redundant-string-cstr quick-fix causes invalid code'

2020-02-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I've commit on your behalf in 47282b1b4bf3e18d2e2166b87159115ed520a2aa 
, thank 
you for the patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74033



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


[PATCH] D73138: [libcxx] [test] Correct asserted type in subspan test; subspan with count should never produce dynamic_extent

2020-02-18 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73138



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


[clang-tools-extra] 47282b1 - Fix PR#44620 'readability-redundant-string-cstr quick-fix causes invalid code'

2020-02-18 Thread Aaron Ballman via cfe-commits

Author: Karasev Nikita
Date: 2020-02-18T15:33:52-05:00
New Revision: 47282b1b4bf3e18d2e2166b87159115ed520a2aa

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

LOG: Fix PR#44620 'readability-redundant-string-cstr quick-fix causes invalid 
code'

static void f2(std::string&&) {}
static void f() {
std::string const s;
f2(s.c_str()); // readability-redundant-string-cstr previously warning
}

Skips the problematic AST pattern in the matcher.

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
index 78834914a5cc..d365bbbe3c43 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -61,6 +61,55 @@ formatDereference(const 
ast_matchers::MatchFinder::MatchResult ,
   return (llvm::Twine("*") + Text).str();
 }
 
+// Trying to get CallExpr in which CxxConstructExpr is called.
+static const clang::CallExpr *
+tryGetCallExprAncestorForCxxConstructExpr(const Expr *TheExpr,
+  ASTContext ) {
+  // We skip nodes such as CXXBindTemporaryExpr, MaterializeTemporaryExpr.
+  for (ast_type_traits::DynTypedNode DynParent : Context.getParents(*TheExpr)) 
{
+if (const auto *Parent = DynParent.get()) {
+  if (const auto *TheCallExpr = dyn_cast(Parent))
+return TheCallExpr;
+
+  if (const clang::CallExpr *TheCallExpr =
+  tryGetCallExprAncestorForCxxConstructExpr(Parent, Context))
+return TheCallExpr;
+}
+  }
+
+  return nullptr;
+}
+
+// Check that ParamDecl of CallExprDecl has rvalue type.
+static bool checkParamDeclOfAncestorCallExprHasRValueRefType(
+const Expr *TheCxxConstructExpr, ASTContext ) {
+  if (const clang::CallExpr *TheCallExpr =
+  tryGetCallExprAncestorForCxxConstructExpr(TheCxxConstructExpr,
+Context)) {
+for (int i = 0; i < TheCallExpr->getNumArgs(); ++i) {
+  const Expr *Arg = TheCallExpr->getArg(i);
+  if (Arg->getSourceRange() == TheCxxConstructExpr->getSourceRange()) {
+if (const auto *TheCallExprFuncProto =
+TheCallExpr->getCallee()
+->getType()
+->getPointeeType()
+->getAs()) {
+  if (TheCallExprFuncProto->getParamType(i)->isRValueReferenceType())
+return true;
+}
+  }
+}
+  }
+
+  return false;
+}
+
+AST_MATCHER(CXXConstructExpr,
+matchedParamDeclOfAncestorCallExprHasRValueRefType) {
+  return checkParamDeclOfAncestorCallExprHasRValueRefType(
+  , Finder->getASTContext());
+}
+
 } // end namespace
 
 void RedundantStringCStrCheck::registerMatchers(
@@ -95,9 +144,13 @@ void RedundantStringCStrCheck::registerMatchers(
   .bind("call");
 
   // Detect redundant 'c_str()' calls through a string constructor.
-  Finder->addMatcher(cxxConstructExpr(StringConstructorExpr,
-  hasArgument(0, StringCStrCallExpr)),
- this);
+  // If CxxConstructExpr is the part of some CallExpr we need to
+  // check that matched ParamDecl of the ancestor CallExpr is not rvalue.
+  Finder->addMatcher(
+  cxxConstructExpr(
+  StringConstructorExpr, hasArgument(0, StringCStrCallExpr),
+  unless(matchedParamDeclOfAncestorCallExprHasRValueRefType())),
+  this);
 
   // Detect: 's == str.c_str()'  ->  's == str'
   Finder->addMatcher(

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
index d8434d3ca7c5..1773dc57a8d8 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
@@ -205,3 +205,18 @@ void dummy(const char*) {}
 void invalid(const NotAString ) {
   dummy(s.c_str());
 }
+
+// Test for rvalue std::string.
+void m1(std::string&&) {
+  std::string s;
+
+  m1(s.c_str());
+
+  void (*m1p1)(std::string&&);
+  m1p1 = m1;
+  m1p1(s.c_str());
+
+  using m1tp = void (*)(std::string &&);
+  m1tp m1p2 = m1;
+  m1p2(s.c_str());  
+}



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


[PATCH] D74776: [Hexagon] clang driver should consider --sysroot option when looking for includes

2020-02-18 Thread Sid Manning via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfaa889b23587: [Hexagon] clang driver should consider 
--sysroot option (authored by sidneym).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74776

Files:
  clang/lib/Driver/ToolChains/Hexagon.cpp
  clang/test/Driver/hexagon-toolchain-elf.c


Index: clang/test/Driver/hexagon-toolchain-elf.c
===
--- clang/test/Driver/hexagon-toolchain-elf.c
+++ clang/test/Driver/hexagon-toolchain-elf.c
@@ -577,3 +577,14 @@
 // RUN:   | FileCheck -check-prefix=CHECK082 %s
 // CHECK082-NOT:  -march=
 // CHECK082-NOT:  -mcpu=
+// 
-
+// Passing --sysroot
+// 
-
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   --sysroot=/hexagon \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK083 %s
+// CHECK083:  "-isysroot" "/hexagon"
+// CHECK083:  "-internal-externc-isystem" "/hexagon/include"
Index: clang/lib/Driver/ToolChains/Hexagon.cpp
===
--- clang/lib/Driver/ToolChains/Hexagon.cpp
+++ clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -540,6 +540,13 @@
 return;
 
   const Driver  = getDriver();
+  if (!D.SysRoot.empty()) {
+SmallString<128> P(D.SysRoot);
+llvm::sys::path::append(P, "include");
+addExternCSystemInclude(DriverArgs, CC1Args, P.str());
+return;
+  }
+
   std::string TargetDir = getHexagonTargetDir(D.getInstalledDir(),
   D.PrefixDirs);
   addExternCSystemInclude(DriverArgs, CC1Args, TargetDir + "/hexagon/include");


Index: clang/test/Driver/hexagon-toolchain-elf.c
===
--- clang/test/Driver/hexagon-toolchain-elf.c
+++ clang/test/Driver/hexagon-toolchain-elf.c
@@ -577,3 +577,14 @@
 // RUN:   | FileCheck -check-prefix=CHECK082 %s
 // CHECK082-NOT:  -march=
 // CHECK082-NOT:  -mcpu=
+// -
+// Passing --sysroot
+// -
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   --sysroot=/hexagon \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK083 %s
+// CHECK083:  "-isysroot" "/hexagon"
+// CHECK083:  "-internal-externc-isystem" "/hexagon/include"
Index: clang/lib/Driver/ToolChains/Hexagon.cpp
===
--- clang/lib/Driver/ToolChains/Hexagon.cpp
+++ clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -540,6 +540,13 @@
 return;
 
   const Driver  = getDriver();
+  if (!D.SysRoot.empty()) {
+SmallString<128> P(D.SysRoot);
+llvm::sys::path::append(P, "include");
+addExternCSystemInclude(DriverArgs, CC1Args, P.str());
+return;
+  }
+
   std::string TargetDir = getHexagonTargetDir(D.getInstalledDir(),
   D.PrefixDirs);
   addExternCSystemInclude(DriverArgs, CC1Args, TargetDir + "/hexagon/include");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] faa889b - [Hexagon] clang driver should consider --sysroot option

2020-02-18 Thread Sid Manning via cfe-commits

Author: Sid Manning
Date: 2020-02-18T14:25:55-06:00
New Revision: faa889b2358704c57febf2ad75ad88eec5debf31

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

LOG: [Hexagon] clang driver should consider --sysroot option

Hexagon's clang driver should consider --sysroot option when setting
up include paths.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/test/Driver/hexagon-toolchain-elf.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Hexagon.cpp 
b/clang/lib/Driver/ToolChains/Hexagon.cpp
index 2b9046712a26..25e9f1b6c222 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -540,6 +540,13 @@ void HexagonToolChain::AddClangSystemIncludeArgs(const 
ArgList ,
 return;
 
   const Driver  = getDriver();
+  if (!D.SysRoot.empty()) {
+SmallString<128> P(D.SysRoot);
+llvm::sys::path::append(P, "include");
+addExternCSystemInclude(DriverArgs, CC1Args, P.str());
+return;
+  }
+
   std::string TargetDir = getHexagonTargetDir(D.getInstalledDir(),
   D.PrefixDirs);
   addExternCSystemInclude(DriverArgs, CC1Args, TargetDir + "/hexagon/include");

diff  --git a/clang/test/Driver/hexagon-toolchain-elf.c 
b/clang/test/Driver/hexagon-toolchain-elf.c
index 9b5ebe3c86a4..4af00215ea31 100644
--- a/clang/test/Driver/hexagon-toolchain-elf.c
+++ b/clang/test/Driver/hexagon-toolchain-elf.c
@@ -577,3 +577,14 @@
 // RUN:   | FileCheck -check-prefix=CHECK082 %s
 // CHECK082-NOT:  -march=
 // CHECK082-NOT:  -mcpu=
+// 
-
+// Passing --sysroot
+// 
-
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   --sysroot=/hexagon \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK083 %s
+// CHECK083:  "-isysroot" "/hexagon"
+// CHECK083:  "-internal-externc-isystem" "/hexagon/include"



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


[PATCH] D74631: [clang][XCOFF] Indicate that XCOFF does not support COMDATs

2020-02-18 Thread Sean Fertile via Phabricator via cfe-commits
sfertile accepted this revision.
sfertile added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: llvm/docs/LangRef.rst:913
 
-Note that the Mach-O platform doesn't support COMDATs, and ELF and WebAssembly
-only support ``any`` as a selection kind.
+Note that XCOFF and the Mach-O platform don't support COMDATs, and ELF and
+WebAssembly only support ``any`` as a selection kind.

really minor nit: The current wording sounds a bit odd to my ear. Maybe either 
`XCOFF and Mach-O platforms` or  `XCOFF and Mach-O don't support COMDATs, ...` 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74631



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


[PATCH] D74787: [IRBuilder] Always respect inserter/folder

2020-02-18 Thread Nikita Popov via Phabricator via cfe-commits
nikic created this revision.
nikic added reviewers: nhaehnle, Meinersbur, spatel, lebedev.ri.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, LLVM.

Some IRBuilder methods that were originally defined on IRBuilderBase do not 
respect custom IRBuilder inserters/folders, because those were not accessible 
prior to D73835 . Fix this by making use of 
existing (and now accessible) IRBuilder methods, which will handle 
inserters/folders correctly.

There are some changes in OpenMP tests, where bitcasts now get constant folded. 
I've also highlighted one InstCombine test which now finishes in two rather 
than three iterations, thanks to new instructions being inserted into the 
worklist.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74787

Files:
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/test/Transforms/InstCombine/saturating-add-sub.ll

Index: llvm/test/Transforms/InstCombine/saturating-add-sub.ll
===
--- llvm/test/Transforms/InstCombine/saturating-add-sub.ll
+++ llvm/test/Transforms/InstCombine/saturating-add-sub.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -instcombine -S | FileCheck %s
+; RUN: opt < %s -instcombine -instcombine-infinite-loop-threshold=2 -S | FileCheck %s
 
 ;
 ; Saturating addition.
Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -65,38 +65,19 @@
 return Ptr;
 
   // Otherwise, we need to insert a bitcast.
-  PT = getInt8PtrTy(PT->getAddressSpace());
-  BitCastInst *BCI = new BitCastInst(Ptr, PT, "");
-  BB->getInstList().insert(InsertPt, BCI);
-  SetInstDebugLocation(BCI);
-  return BCI;
+  return CreateBitCast(Ptr, getInt8PtrTy(PT->getAddressSpace()));
 }
 
 static CallInst *createCallHelper(Function *Callee, ArrayRef Ops,
   IRBuilderBase *Builder,
   const Twine  = "",
   Instruction *FMFSource = nullptr) {
-  CallInst *CI = CallInst::Create(Callee, Ops, Name);
+  CallInst *CI = Builder->CreateCall(Callee, Ops, Name);
   if (FMFSource)
 CI->copyFastMathFlags(FMFSource);
-  Builder->GetInsertBlock()->getInstList().insert(Builder->GetInsertPoint(),CI);
-  Builder->SetInstDebugLocation(CI);
   return CI;
 }
 
-static InvokeInst *createInvokeHelper(Function *Invokee, BasicBlock *NormalDest,
-  BasicBlock *UnwindDest,
-  ArrayRef Ops,
-  IRBuilderBase *Builder,
-  const Twine  = "") {
-  InvokeInst *II =
-  InvokeInst::Create(Invokee, NormalDest, UnwindDest, Ops, Name);
-  Builder->GetInsertBlock()->getInstList().insert(Builder->GetInsertPoint(),
-  II);
-  Builder->SetInstDebugLocation(II);
-  return II;
-}
-
 CallInst *IRBuilderBase::CreateMemSet(Value *Ptr, Value *Val, Value *Size,
   MaybeAlign Align, bool isVolatile,
   MDNode *TBAATag, MDNode *ScopeTag,
@@ -696,8 +677,8 @@
   std::vector Args =
   getStatepointArgs(*Builder, ID, NumPatchBytes, ActualInvokee, Flags,
 InvokeArgs, TransitionArgs, DeoptArgs, GCArgs);
-  return createInvokeHelper(FnStatepoint, NormalDest, UnwindDest, Args, Builder,
-Name);
+  return Builder->CreateInvoke(FnStatepoint, NormalDest, UnwindDest, Args,
+   Name);
 }
 
 InvokeInst *IRBuilderBase::CreateGCStatepointInvoke(
Index: clang/test/OpenMP/target_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/target_firstprivate_codegen.cpp
+++ clang/test/OpenMP/target_firstprivate_codegen.cpp
@@ -336,9 +336,8 @@
   }
   // CHECK:  [[PTR_ADDR_REF:%.+]] = load double*, double** [[PTR_ADDR]],
 
-  // CHECK:  [[FP_E_BC:%.+]] = bitcast [[TTII]]* [[FP_E]] to i8*
   // CHECK:  [[E_BC:%.+]] = bitcast [[TTII]]* [[E:%.+]] to i8*
-  // CHECK:  call void @llvm.memcpy.p0i8.p0i8.i{{64|32}}(i8* {{.*}} [[FP_E_BC]], i8* {{.*}} [[E_BC]], i{{64|32}} 8, i1 false)
+  // CHECK:  call void @llvm.memcpy.p0i8.p0i8.i{{64|32}}(i8* {{.*}} bitcast ([[TTII]]* [[FP_E]] to i8*), i8* {{.*}} [[E_BC]], i{{64|32}} 8, i1 false)
   // CHECK:  [[BASE_PTR_GEP3_0:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BASE_PTR_ARR3]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
   // CHECK:  [[BCAST_TOPTR:%.+]] = bitcast i8** [[BASE_PTR_GEP3_0]] to double**
   // CHECK:  store double* [[PTR_ADDR_REF]], double** [[BCAST_TOPTR]],
Index: 

[PATCH] D73138: [libcxx] [test] Correct asserted type in subspan test; subspan with count should never produce dynamic_extent

2020-02-18 Thread Louis Dionne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa7dcbe90cc2d: [libc++] Fix overly complicated test of 
std::spans extent (authored by ldionne).
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.

Changed prior to commit:
  https://reviews.llvm.org/D73138?vs=239423=245236#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73138

Files:
  libcxx/test/std/containers/views/span.sub/subspan.pass.cpp


Index: libcxx/test/std/containers/views/span.sub/subspan.pass.cpp
===
--- libcxx/test/std/containers/views/span.sub/subspan.pass.cpp
+++ libcxx/test/std/containers/views/span.sub/subspan.pass.cpp
@@ -37,13 +37,7 @@
 using S2 = decltype(s2);
 ASSERT_SAME_TYPE(typename Span::value_type, typename S1::value_type);
 ASSERT_SAME_TYPE(typename Span::value_type, typename S2::value_type);
-if constexpr (Count != std::dynamic_extent) {
-static_assert(S1::extent == Count);
-} else if constexpr (Span::extent != std::dynamic_extent) {
-static_assert(S1::extent == Span::extent - Offset);
-} else {
-static_assert(S1::extent == std::dynamic_extent);
-}
+static_assert(S1::extent == Count);
 static_assert(S2::extent == std::dynamic_extent, "");
 return
 s1.data() == s2.data()
@@ -82,13 +76,7 @@
 using S2 = decltype(s2);
 ASSERT_SAME_TYPE(typename Span::value_type, typename S1::value_type);
 ASSERT_SAME_TYPE(typename Span::value_type, typename S2::value_type);
-if constexpr (Count != std::dynamic_extent) {
-static_assert(S1::extent == Count);
-} else if constexpr (Span::extent != std::dynamic_extent) {
-static_assert(S1::extent == Span::extent - Offset);
-} else {
-static_assert(S1::extent == std::dynamic_extent);
-}
+static_assert(S1::extent == Count);
 static_assert(S2::extent == std::dynamic_extent, "");
 assert(s1.data() == s2.data());
 assert(s1.size() == s2.size());


Index: libcxx/test/std/containers/views/span.sub/subspan.pass.cpp
===
--- libcxx/test/std/containers/views/span.sub/subspan.pass.cpp
+++ libcxx/test/std/containers/views/span.sub/subspan.pass.cpp
@@ -37,13 +37,7 @@
 using S2 = decltype(s2);
 ASSERT_SAME_TYPE(typename Span::value_type, typename S1::value_type);
 ASSERT_SAME_TYPE(typename Span::value_type, typename S2::value_type);
-if constexpr (Count != std::dynamic_extent) {
-static_assert(S1::extent == Count);
-} else if constexpr (Span::extent != std::dynamic_extent) {
-static_assert(S1::extent == Span::extent - Offset);
-} else {
-static_assert(S1::extent == std::dynamic_extent);
-}
+static_assert(S1::extent == Count);
 static_assert(S2::extent == std::dynamic_extent, "");
 return
 s1.data() == s2.data()
@@ -82,13 +76,7 @@
 using S2 = decltype(s2);
 ASSERT_SAME_TYPE(typename Span::value_type, typename S1::value_type);
 ASSERT_SAME_TYPE(typename Span::value_type, typename S2::value_type);
-if constexpr (Count != std::dynamic_extent) {
-static_assert(S1::extent == Count);
-} else if constexpr (Span::extent != std::dynamic_extent) {
-static_assert(S1::extent == Span::extent - Offset);
-} else {
-static_assert(S1::extent == std::dynamic_extent);
-}
+static_assert(S1::extent == Count);
 static_assert(S2::extent == std::dynamic_extent, "");
 assert(s1.data() == s2.data());
 assert(s1.size() == s2.size());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74529: [clang-tidy] Added a case to UnconventionalAssignOperatorCheck.

2020-02-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman 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/D74529/new/

https://reviews.llvm.org/D74529



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


[PATCH] D73138: [libcxx] [test] Correct asserted type in subspan test; subspan with count should never produce dynamic_extent

2020-02-18 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

In D73138#1881198 , @BillyONeal wrote:

> @ldionne I think you're correct, though the test there is more complex than 
> it needs to be (because the ==Count cases are the only ever encountered here).


Hmm, yes, you're right! I'll take your patch on top. Thanks!


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

https://reviews.llvm.org/D73138



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


[PATCH] D74033: [clang-tidy] Fix PR#44620 'readability-redundant-string-cstr quick-fix causes invalid code'

2020-02-18 Thread Karasev Nikita via Phabricator via cfe-commits
f00kat added a comment.

Yes, commit please. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74033



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


[PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

The problem may be `-DCLANG_DEFAULT_LINKER=lld`.

(FWIW I really don't like supporting numerous -D configurations and ask authors 
to revert because of some weird -D configurations.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74704



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


[PATCH] D74784: [driver][darwin] Don't use -platform_version flag by default

2020-02-18 Thread dmajor via Phabricator via cfe-commits
dmajor created this revision.
dmajor added reviewers: arphaman, steven_wu, dexonsmith.
dmajor added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

(Note, I don't currently have commit access.)

The code in llvmorg-10-init-12188-g25ce33a6e4f is a breaking change for users 
of older linkers who don't pass a version parameter, which prevents a drop-in 
clang upgrade. Old tools can't know about what future tools will do, so as a 
general principle the burden should be new tools to be compatible by default. 
Also, for comparison, none of the other tests of `Version` within `AddLinkArgs` 
add any new behaviors unless the version is explicitly specified. Therefore, 
this patch changes the `-platform_version` behavior from opt-out to opt-in.

In light of the test fixup in llvmorg-10-init-12213-gbe88a20c900, I've used 
`-mlinker-version=0` instead of doing a straight revert of the additions of 
`-mlinker-version=400`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74784

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-infer-simulator-sdkroot.c
  clang/test/Driver/darwin-ld-platform-version-macos.c
  clang/test/Driver/darwin-ld.c
  clang/test/Driver/darwin-sdkroot.c
  clang/test/Driver/target-triple-deployment.c

Index: clang/test/Driver/target-triple-deployment.c
===
--- clang/test/Driver/target-triple-deployment.c
+++ clang/test/Driver/target-triple-deployment.c
@@ -1,14 +1,14 @@
 // RUN: touch %t.o
-// RUN: %clang -target x86_64-apple-macosx10.4 -mlinker-version=400 -### %t.o 2> %t.log
-// RUN: %clang -target x86_64-apple-darwin9 -mlinker-version=400 -### %t.o 2>> %t.log
-// RUN: %clang -target x86_64-apple-macosx10.7 -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -target x86_64-apple-macosx10.4 -mlinker-version=0 -### %t.o 2> %t.log
+// RUN: %clang -target x86_64-apple-darwin9 -mlinker-version=0 -### %t.o 2>> %t.log
+// RUN: %clang -target x86_64-apple-macosx10.7 -mlinker-version=0 -### %t.o 2>> %t.log
 //
-// RUN: %clang -target armv7-apple-ios -mlinker-version=400 -### %t.o 2>> %t.log
-// RUN: %clang -target armv7-apple-ios0.0 -mlinker-version=400 -### %t.o 2>> %t.log
-// RUN: %clang -target armv7-apple-ios1.2.3 -mlinker-version=400 -### %t.o 2>> %t.log
-// RUN: %clang -target armv7-apple-ios5.0 -mlinker-version=400 -### %t.o 2>> %t.log
-// RUN: %clang -target armv7-apple-ios7.0 -mlinker-version=400 -### %t.o 2>> %t.log
-// RUN: %clang -target arm64-apple-ios -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -target armv7-apple-ios -mlinker-version=0 -### %t.o 2>> %t.log
+// RUN: %clang -target armv7-apple-ios0.0 -mlinker-version=0 -### %t.o 2>> %t.log
+// RUN: %clang -target armv7-apple-ios1.2.3 -mlinker-version=0 -### %t.o 2>> %t.log
+// RUN: %clang -target armv7-apple-ios5.0 -mlinker-version=0 -### %t.o 2>> %t.log
+// RUN: %clang -target armv7-apple-ios7.0 -mlinker-version=0 -### %t.o 2>> %t.log
+// RUN: %clang -target arm64-apple-ios -mlinker-version=0 -### %t.o 2>> %t.log
 //
 // RUN: FileCheck %s < %t.log
 
Index: clang/test/Driver/darwin-sdkroot.c
===
--- clang/test/Driver/darwin-sdkroot.c
+++ clang/test/Driver/darwin-sdkroot.c
@@ -43,7 +43,7 @@
 //
 // RUN: rm -rf %t/SDKs/iPhoneOS8.0.0.sdk
 // RUN: mkdir -p %t/SDKs/iPhoneOS8.0.0.sdk
-// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang -target arm64-apple-darwin -mlinker-version=400 --sysroot="" %s -### 2>&1 \
+// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang -target arm64-apple-darwin -mlinker-version=0 --sysroot="" %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-IPHONE %s
 //
 // CHECK-IPHONE: clang
@@ -55,7 +55,7 @@
 //
 // RUN: rm -rf %t/SDKs/iPhoneSimulator8.0.sdk
 // RUN: mkdir -p %t/SDKs/iPhoneSimulator8.0.sdk
-// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang -target x86_64-apple-darwin -mlinker-version=400 --sysroot="" %s -### 2>&1 \
+// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang -target x86_64-apple-darwin -mlinker-version=0 --sysroot="" %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-SIMULATOR %s
 //
 // CHECK-SIMULATOR: clang
@@ -66,7 +66,7 @@
 //
 // RUN: rm -rf %t/SDKs/MacOSX10.10.0.sdk
 // RUN: mkdir -p %t/SDKs/MacOSX10.10.0.sdk
-// RUN: env SDKROOT=%t/SDKs/MacOSX10.10.0.sdk %clang -target x86_64-apple-darwin -mlinker-version=400 --sysroot="" %s -### 2>&1 \
+// RUN: env SDKROOT=%t/SDKs/MacOSX10.10.0.sdk %clang -target x86_64-apple-darwin -mlinker-version=0 --sysroot="" %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MACOSX %s
 //
 // CHECK-MACOSX: clang
Index: clang/test/Driver/darwin-ld.c
===
--- clang/test/Driver/darwin-ld.c
+++ clang/test/Driver/darwin-ld.c
@@ -11,9 +11,9 @@
 
 // Check linker changes that came with new linkedit format.
 // RUN: touch %t.o
-// RUN: %clang -target i386-apple-darwin9 

[PATCH] D73138: [libcxx] [test] Correct asserted type in subspan test; subspan with count should never produce dynamic_extent

2020-02-18 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal added a comment.

@ldionne I think you're correct, though the test there is more complex than it 
needs to be (because the ==Count cases are the only ever encountered here).


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

https://reviews.llvm.org/D73138



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


[PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-18 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

Reverted through b8bea9346af4f2644c9a1bd29710c5e3efbbd7d3 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74704



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


[PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-18 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

I'll revert and propose an updated patch then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74704



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


[libunwind] 1ae8d81 - [libunwind] Fix memory leak in handling of DW_CFA_remember_state and DW_CFA_restore_state

2020-02-18 Thread Jorge Gorbe Moya via cfe-commits

Author: Jorge Gorbe Moya
Date: 2020-02-18T11:57:18-08:00
New Revision: 1ae8d81147a0724cc972054afbd72943032e4832

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

LOG: [libunwind] Fix memory leak in handling of DW_CFA_remember_state and 
DW_CFA_restore_state

parseInstructions() doesn't always process the whole set of DWARF
instructions for a frame. It will stop once the target PC is reached, or
if malformed instructions are found. So, for example, if we have an
instruction sequence like this:

```

...
DW_CFA_remember_state
...
DW_CFA_advance_loc past the location we're unwinding at (pcoffset in 
parseInstructions() main loop)
...
DW_CFA_restore_state

```

... the saved state will never be freed, even though the
DW_CFA_remember_state opcode has a matching DW_CFA_restore_state later
in the sequence.

This change adds code to free whatever is left on rememberStack after
parsing the CIE and the FDE instructions.

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

Added: 
libunwind/test/remember_state_leak.pass.sh.s

Modified: 
libunwind/src/DwarfParser.hpp

Removed: 




diff  --git a/libunwind/src/DwarfParser.hpp b/libunwind/src/DwarfParser.hpp
index df69c2a4bd23..2994bd7bb41f 100644
--- a/libunwind/src/DwarfParser.hpp
+++ b/libunwind/src/DwarfParser.hpp
@@ -360,13 +360,25 @@ bool CFI_Parser::parseFDEInstructions(A ,
   PrologInfoStackEntry *rememberStack = NULL;
 
   // parse CIE then FDE instructions
-  return parseInstructions(addressSpace, cieInfo.cieInstructions,
-   cieInfo.cieStart + cieInfo.cieLength, cieInfo,
-   (pint_t)(-1), rememberStack, arch, results) &&
- parseInstructions(addressSpace, fdeInfo.fdeInstructions,
-   fdeInfo.fdeStart + fdeInfo.fdeLength, cieInfo,
-   upToPC - fdeInfo.pcStart, rememberStack, arch,
-   results);
+  bool returnValue =
+  parseInstructions(addressSpace, cieInfo.cieInstructions,
+cieInfo.cieStart + cieInfo.cieLength, cieInfo,
+(pint_t)(-1), rememberStack, arch, results) &&
+  parseInstructions(addressSpace, fdeInfo.fdeInstructions,
+fdeInfo.fdeStart + fdeInfo.fdeLength, cieInfo,
+upToPC - fdeInfo.pcStart, rememberStack, arch, 
results);
+
+  // Clean up rememberStack. Even in the case where every DW_CFA_remember_state
+  // is paired with a DW_CFA_restore_state, parseInstructions can skip restore
+  // opcodes if it reaches the target PC and stops interpreting, so we have to
+  // make sure we don't leak memory.
+  while (rememberStack) {
+PrologInfoStackEntry *next = rememberStack->next;
+free(rememberStack);
+rememberStack = next;
+  }
+
+  return returnValue;
 }
 
 /// "run" the DWARF instructions

diff  --git a/libunwind/test/remember_state_leak.pass.sh.s 
b/libunwind/test/remember_state_leak.pass.sh.s
new file mode 100644
index ..821ee926eec8
--- /dev/null
+++ b/libunwind/test/remember_state_leak.pass.sh.s
@@ -0,0 +1,56 @@
+# REQUIRES: x86, linux
+# RUN: %build -target x86_64-unknown-linux-gnu
+# RUN: %run
+
+# The following assembly is a translation of this code:
+#
+#   _Unwind_Reason_Code callback(int, _Unwind_Action, long unsigned int,
+#_Unwind_Exception*, _Unwind_Context*, void*) {
+# return _Unwind_Reason_Code(0);
+#   }
+#
+#   int main() {
+# asm(".cfi_remember_state\n\t");
+# _Unwind_Exception exc;
+# _Unwind_ForcedUnwind(, callback, 0);
+# asm(".cfi_restore_state\n\t");
+#   }
+#
+# When unwinding, the CFI parser will stop parsing opcodes after the current 
PC,
+# so in this case the DW_CFA_restore_state opcode will never be processed and,
+# if the library doesn't clean up properly, the store allocated by
+# DW_CFA_remember_state will be leaked.
+#
+# This test will fail when linked with an asan-enabled libunwind if the
+# remembered state is leaked.
+
+SIZEOF_UNWIND_EXCEPTION = 32
+
+.text
+callback:
+xorl%eax, %eax
+retq
+
+.globlmain# -- Begin function main
+.p2align4, 0x90
+.typemain,@function
+main:   # @main
+.cfi_startproc
+subq$8, %rsp   # Adjust stack alignment
+subq$SIZEOF_UNWIND_EXCEPTION, %rsp
+.cfi_def_cfa_offset 48
+.cfi_remember_state
+movq%rsp, %rdi
+movabsq $callback, %rsi
+xorl%edx, %edx
+callq_Unwind_ForcedUnwind
+.cfi_restore_state
+xorl%eax, %eax
+addq$SIZEOF_UNWIND_EXCEPTION, %rsp
+addq$8, %rsp   # Undo stack alignment adjustment
+.cfi_def_cfa_offset 8
+retq
+.Lfunc_end1:
+.sizemain, 

  1   2   3   >