[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2020-12-17 Thread Sunny via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 312395.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

Files:
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZfinx.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/MC/RISCV/rv32d-invalid.s
  llvm/test/MC/RISCV/rv32zfh-invalid.s
  llvm/test/MC/RISCV/rvzfinx-valid.s

Index: llvm/test/MC/RISCV/rvzfinx-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvzfinx-valid.s
@@ -0,0 +1,333 @@
+# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zfinx %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv64 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zfinx %s \
+# RUN:| llvm-objdump -d --mattr=+experimental-zfinx - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zfinx %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+fmadd.h a0, a1, a2, a3
+# CHECK-INST: fmadd.h a0, a1, a2, a3
+# CHECK-ENCODING: [0x43,0xf5,0xc5,0x6c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 43 f5 c5 6c 
+
+fmsub.h a0, a1, a2, a3
+# CHECK-INST: fmsub.h a0, a1, a2, a3
+# CHECK-ENCODING: [0x47,0xf5,0xc5,0x6c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 47 f5 c5 6c 
+
+fnmsub.h a0, a1, a2, a3
+# CHECK-INST: fnmsub.h a0, a1, a2, a3
+# CHECK-ENCODING: [0x4b,0xf5,0xc5,0x6c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 4b f5 c5 6c 
+
+fnmadd.h a0, a1, a2, a3
+# CHECK-INST: fnmadd.h a0, a1, a2, a3
+# CHECK-ENCODING: [0x4f,0xf5,0xc5,0x6c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 4f f5 c5 6c 
+
+fadd.h a0, a1, a2
+# CHECK-INST: fadd.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xf5,0xc5,0x04]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 f5 c5 04 
+
+fsub.h a0, a1, a2
+# CHECK-INST: fsub.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xf5,0xc5,0x0c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 f5 c5 0c 
+
+fmul.h a0, a1, a2
+# CHECK-INST: fmul.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xf5,0xc5,0x14]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 f5 c5 14 
+
+fdiv.h a0, a1, a2
+# CHECK-INST: fdiv.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xf5,0xc5,0x1c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 f5 c5 1c 
+
+fsqrt.h a0, a1
+# CHECK-INST: fsqrt.h a0, a1
+# CHECK-ENCODING: [0x53,0xf5,0x05,0x5c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 f5 05 5c 
+
+fsgnj.h a0, a1, a2
+# CHECK-INST: fsgnj.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x85,0xc5,0x24]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 85 c5 24 
+
+fsgnjn.h a0, a1, a2
+# CHECK-INST: fsgnjn.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x95,0xc5,0x24]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 95 c5 24 
+
+fsgnjx.h a0, a1, a2
+# CHECK-INST: fsgnjx.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xa5,0xc5,0x24]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 a5 c5 24 
+
+fmin.h a0, a1, a2
+# CHECK-INST: fmin.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x85,0xc5,0x2c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 85 c5 2c 
+
+fmax.h a0, a1, a2
+# CHECK-INST: fmax.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x95,0xc5,0x2c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 95 c5 2c 
+
+feq.h a0, a1, a2
+# CHECK-INST: feq.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xa5,0xc5,0xa4]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 a5 c5 a4 
+
+flt.h a0, a1, a2
+# CHECK-INST: flt.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x95,0xc5,0xa4]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 95 c5 a4 
+
+fle.h a0, a1, a2
+# CHECK-INST: fle.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x85,0xc5,0xa4]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 85 c5 a4 
+
+fclass.h a0, a1
+# CHECK-INST: fclass.h a0, a1
+# CHECK-ENCODING: [0x53,0x95,0x05,0xe4]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 95 05 e4 
+
+fmadd.s a0, a1, a2, a3
+# CHECK-INST: fmadd.s a0, a1, a2, a3
+# CHECK-ENCODING: [0x43,0xf5,0xc5,0x68]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 43 f5 c5 68 
+
+fmsub.s a0, a1, a2, a3
+# CHECK-INST: fmsub.s a0, a1, a2, a3
+# CHECK-ENCODING: [0x47,0xf5,0xc5,0x68]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 47 f5 c5 68 
+
+fnmsub.s a0, a1, a2, a3
+# CHECK-INST: fnmsub.s a0, a1, a2, a3
+# CHECK-ENCODING: [0x4b,0xf5,0xc5,0x68]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 4b f5 c5 68 
+
+fnmadd.s a0, a1, 

[clang] 7f19712 - [clang][nfc] Update comment to match the opening `{`

2020-12-17 Thread Andrzej Warzynski via cfe-commits

Author: Andrzej Warzynski
Date: 2020-12-17T09:04:41Z
New Revision: 7f19712a6a9e65bdc9a9843ea488030bc12f3acc

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

LOG: [clang][nfc] Update comment to match the opening `{`

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 dd23d810e388..f384e0d993c2 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5081,7 +5081,7 @@ def fopenmp_host_ir_file_path : Separate<["-"], 
"fopenmp-host-ir-file-path">,
 def fsycl_is_device : Flag<["-"], "fsycl-is-device">,
   HelpText<"Generate code for SYCL device.">;
 
-} // let Flags = [CC1Option]
+} // let Flags = [CC1Option, NoDriverOption]
 
 
//===--===//
 // cc1as-only Options



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


[PATCH] D92854: [flang][driver] Add support for `-fsyntax-only`

2020-12-17 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski updated this revision to Diff 312400.
awarzynski added a comment.

Rebased on top of main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92854

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/CompilerInstance.h
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CMakeLists.txt
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/syntax-only.f90
  flang/unittests/Frontend/PrintPreprocessedTest.cpp

Index: flang/unittests/Frontend/PrintPreprocessedTest.cpp
===
--- flang/unittests/Frontend/PrintPreprocessedTest.cpp
+++ flang/unittests/Frontend/PrintPreprocessedTest.cpp
@@ -76,4 +76,60 @@
   llvm::sys::fs::remove(inputFile);
   compInst.ClearOutputFiles(/*EraseFiles=*/true);
 }
+
+TEST(FrontendAction, ParseSyntaxOnly) {
+  std::string inputFile = "test-file.f";
+  std::error_code ec;
+
+  // 1. Create the input file for the file manager
+  // AllSources (which is used to manage files inside every compiler instance),
+  // works with paths. This means that it requires a physical file. Create one.
+  std::unique_ptr os{
+  new llvm::raw_fd_ostream(inputFile, ec, llvm::sys::fs::OF_None)};
+  if (ec)
+FAIL() << "Fail to create the file need by the test";
+
+  // Populate the input file with the pre-defined input and flush it.
+  *(os) << "! if_stmt.f90:\n"
+<< "IF (A > 0.0) IF (B < 0.0) A = LOG (A)\n"
+<< "END";
+  os.reset();
+
+  // Get the path of the input file
+  llvm::SmallString<64> cwd;
+  if (std::error_code ec = llvm::sys::fs::current_path(cwd))
+FAIL() << "Failed to obtain the current working directory";
+  std::string testFilePath(cwd.c_str());
+  testFilePath += "/" + inputFile;
+
+  // 2. Prepare the compiler (CompilerInvocation + CompilerInstance)
+  CompilerInstance compInst;
+  compInst.CreateDiagnostics();
+  auto invocation = std::make_shared();
+  invocation->frontendOpts().programAction_ = ParseSyntaxOnly;
+
+  compInst.set_invocation(std::move(invocation));
+  compInst.frontendOpts().inputs_.push_back(
+  FrontendInputFile(testFilePath, Language::Fortran));
+
+  // 3. Set-up the output stream for the semantic diagnostics.
+  llvm::SmallVector outputDiagBuffer;
+  std::unique_ptr outputStream(
+  new llvm::raw_svector_ostream(outputDiagBuffer));
+  compInst.set_semaOutputStream(std::move(outputStream));
+
+  // 4. Execute the ParseSyntaxOnly action
+  bool success = ExecuteCompilerInvocation(&compInst);
+
+  // 5. Validate the expected output
+  EXPECT_FALSE(success);
+  EXPECT_TRUE(!outputDiagBuffer.empty());
+  EXPECT_TRUE(
+  llvm::StringRef(outputDiagBuffer.data())
+  .startswith(
+  ":2:14: error: IF statement is not allowed in IF statement\n"));
+
+  // 6. Clear the input files.
+  llvm::sys::fs::remove(inputFile);
+}
 } // namespace
Index: flang/test/Flang-Driver/syntax-only.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/syntax-only.f90
@@ -0,0 +1,9 @@
+! RUN: not %flang-new -fc1 -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: not %f18 -fparse-only %s 2>&1 | FileCheck %s
+
+! REQUIRES: new-flang-driver
+
+! CHECK: IF statement is not allowed in IF statement
+! CHECK: semantic errors in {{.*}}syntax-only.f90
+IF (A > 0.0) IF (B < 0.0) A = LOG (A)
+END
Index: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -32,6 +32,9 @@
   case PrintPreprocessedInput:
 return std::make_unique();
 break;
+  case ParseSyntaxOnly:
+return std::make_unique();
+break;
   default:
 break;
 // TODO:
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -11,6 +11,7 @@
 #include "flang/Parser/parsing.h"
 #include "flang/Parser/provenance.h"
 #include "flang/Parser/source.h"
+#include "flang/Semantics/semantics.h"
 
 using namespace Fortran::frontend;
 
@@ -68,3 +69,33 @@
 return;
   }
 }
+
+void ParseSyntaxOnlyAction::ExecuteAction() {
+  CompilerInstance &ci = this->instance();
+
+  // TODO: These should be specifiable by users. For now just use the defaults.
+  common::LanguageFeatureControl features;
+  Fortran::common::IntrinsicTypeDefaultKinds defaultKinds;
+
+  // Parse
+  ci.parsing().Parse(llvm::outs());
+  auto &parseTree{*ci.parsing().parseTree()};
+
+  // Prepare semantics
+  Fortran::semantics::SemanticsContext sem

[PATCH] D93296: [clang-format] PR35514 brace-init member initializers in function-try-blocks are not formatted correctly

2020-12-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 312407.
MyDeveloperDay added a comment.

Add additional unit test


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

https://reviews.llvm.org/D93296

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2727,6 +2727,29 @@
"throw;\n"
"  }\n"
"};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1} {\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1}, c{2} {\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1}, c{2} {\n"
+   "{ // New scope.\n"
+   "}\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
 
   // Incomplete try-catch blocks.
   verifyIncompleteFormat("try {} catch (");
@@ -7756,8 +7779,8 @@
   verifyFormat("co_yield -1;");
   verifyFormat("co_return -1;");
 
-  // Check that * is not treated as a binary operator when we set 
PointerAlignment
-  // as PAS_Left after a keyword and not a declaration.
+  // Check that * is not treated as a binary operator when we set
+  // PointerAlignment as PAS_Left after a keyword and not a declaration.
   FormatStyle PASLeftStyle = getLLVMStyle();
   PASLeftStyle.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("co_return *a;", PASLeftStyle);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2050,6 +2050,13 @@
   nextToken();
   if (FormatTok->is(tok::l_paren))
 parseParens();
+  if (FormatTok->Previous && FormatTok->Previous->is(tok::identifier) &&
+  FormatTok->is(tok::l_brace)) {
+do {
+  nextToken();
+} while (!FormatTok->is(tok::r_brace));
+nextToken();
+  }
 
   // In case identifiers were removed by clang-tidy, what might follow is
   // multiple commas in sequence - after the first identifier.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2727,6 +2727,29 @@
"throw;\n"
"  }\n"
"};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1} {\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1}, c{2} {\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1}, c{2} {\n"
+   "{ // New scope.\n"
+   "}\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
 
   // Incomplete try-catch blocks.
   verifyIncompleteFormat("try {} catch (");
@@ -7756,8 +7779,8 @@
   verifyFormat("co_yield -1;");
   verifyFormat("co_return -1;");
 
-  // Check that * is not treated as a binary operator when we set PointerAlignment
-  // as PAS_Left after a keyword and not a declaration.
+  // Check that * is not treated as a binary operator when we set
+  // PointerAlignment as PAS_Left after a keyword and not a declaration.
   FormatStyle PASLeftStyle = getLLVMStyle();
   PASLeftStyle.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("co_return *a;", PASLeftStyle);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2050,6 +2050,13 @@
   nextToken();
   if (FormatTok->is(tok::l_paren))
 parseParens();
+  if (FormatTok->Previous && FormatTok->Previous->is(tok::identifier) &&
+  FormatTok->is(tok::l_brace)) {
+do {
+  nextToken();
+} while (!FormatTok->is(tok::r_brace));
+nextToken();
+  }
 
   // In case identifiers were removed by clang-tidy, what might follow is
   // multiple commas in sequence - after the first id

[clang] db41c0b - [clang-format] PR35514 brace-init member initializers in function-try-blocks are not formatted correctly

2020-12-17 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-12-17T09:39:37Z
New Revision: db41c0b357d55ccd6206ff262dc50ed38f0d5474

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

LOG: [clang-format] PR35514 brace-init member initializers in 
function-try-blocks are not formatted correctly

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

Initializer lists with a try-block are incorrectly formatted.

e.g.

```
Foo(int abc, int def) try : _abc(abc), _def{def}, _ghi{1} {
  callA();
  callB();
} catch (std::exception&) {
}
```

is formatted as:

```
Foo(int abc, int def) try : _abc(abc), _def { def }
, _ghi{1} {
  callA();
  callB();
}
catch (std::exception&) {
}
```

This revision adds support in the parseTryCatch for braced initializers in the 
initializer list

Reviewed By: curdeius, HazardyKnusperkeks

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index ddb3a247429a..4c2ee421d092 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2050,6 +2050,13 @@ void UnwrappedLineParser::parseTryCatch() {
   nextToken();
   if (FormatTok->is(tok::l_paren))
 parseParens();
+  if (FormatTok->Previous && FormatTok->Previous->is(tok::identifier) &&
+  FormatTok->is(tok::l_brace)) {
+do {
+  nextToken();
+} while (!FormatTok->is(tok::r_brace));
+nextToken();
+  }
 
   // In case identifiers were removed by clang-tidy, what might follow is
   // multiple commas in sequence - after the first identifier.

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index a3dbec9a669f..d2aed304f213 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -2727,6 +2727,29 @@ TEST_F(FormatTest, FormatTryCatch) {
"throw;\n"
"  }\n"
"};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1} {\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1}, c{2} {\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1}, c{2} {\n"
+   "{ // New scope.\n"
+   "}\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
 
   // Incomplete try-catch blocks.
   verifyIncompleteFormat("try {} catch (");
@@ -7756,8 +7779,8 @@ TEST_F(FormatTest, UnderstandsUnaryOperators) {
   verifyFormat("co_yield -1;");
   verifyFormat("co_return -1;");
 
-  // Check that * is not treated as a binary operator when we set 
PointerAlignment
-  // as PAS_Left after a keyword and not a declaration.
+  // Check that * is not treated as a binary operator when we set
+  // PointerAlignment as PAS_Left after a keyword and not a declaration.
   FormatStyle PASLeftStyle = getLLVMStyle();
   PASLeftStyle.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("co_return *a;", PASLeftStyle);



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


[PATCH] D93296: [clang-format] PR35514 brace-init member initializers in function-try-blocks are not formatted correctly

2020-12-17 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdb41c0b357d5: [clang-format] PR35514 brace-init member 
initializers in function-try-blocks… (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93296

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2727,6 +2727,29 @@
"throw;\n"
"  }\n"
"};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1} {\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1}, c{2} {\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1}, c{2} {\n"
+   "{ // New scope.\n"
+   "}\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
 
   // Incomplete try-catch blocks.
   verifyIncompleteFormat("try {} catch (");
@@ -7756,8 +7779,8 @@
   verifyFormat("co_yield -1;");
   verifyFormat("co_return -1;");
 
-  // Check that * is not treated as a binary operator when we set 
PointerAlignment
-  // as PAS_Left after a keyword and not a declaration.
+  // Check that * is not treated as a binary operator when we set
+  // PointerAlignment as PAS_Left after a keyword and not a declaration.
   FormatStyle PASLeftStyle = getLLVMStyle();
   PASLeftStyle.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("co_return *a;", PASLeftStyle);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2050,6 +2050,13 @@
   nextToken();
   if (FormatTok->is(tok::l_paren))
 parseParens();
+  if (FormatTok->Previous && FormatTok->Previous->is(tok::identifier) &&
+  FormatTok->is(tok::l_brace)) {
+do {
+  nextToken();
+} while (!FormatTok->is(tok::r_brace));
+nextToken();
+  }
 
   // In case identifiers were removed by clang-tidy, what might follow is
   // multiple commas in sequence - after the first identifier.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2727,6 +2727,29 @@
"throw;\n"
"  }\n"
"};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1} {\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1}, c{2} {\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
+  verifyFormat("class A {\n"
+   "  int a;\n"
+   "  A() try : a(0), b{1}, c{2} {\n"
+   "{ // New scope.\n"
+   "}\n"
+   "  } catch (...) {\n"
+   "throw;\n"
+   "  }\n"
+   "};\n");
 
   // Incomplete try-catch blocks.
   verifyIncompleteFormat("try {} catch (");
@@ -7756,8 +7779,8 @@
   verifyFormat("co_yield -1;");
   verifyFormat("co_return -1;");
 
-  // Check that * is not treated as a binary operator when we set PointerAlignment
-  // as PAS_Left after a keyword and not a declaration.
+  // Check that * is not treated as a binary operator when we set
+  // PointerAlignment as PAS_Left after a keyword and not a declaration.
   FormatStyle PASLeftStyle = getLLVMStyle();
   PASLeftStyle.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("co_return *a;", PASLeftStyle);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2050,6 +2050,13 @@
   nextToken();
   if (FormatTok->is(tok::l_paren))
 parseParens();
+  if (FormatTok->Previous && FormatTok->Previous->is(tok::identifier) &&
+  FormatTok->is(tok::l_brace)) {
+do {
+  nextToken();
+} while (!FormatTok->is(tok::r_brace));
+nextToken();
+

[PATCH] D93221: [ARM] Add clang command line support for -mharden-sls=

2020-12-17 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added a comment.

Why is this restricted to v7-A or later? The DSB and ISB instructions have 
existed since v6T2 and v6M.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93221

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


[PATCH] D93231: [ARM] Adding v8.7-A command-line support for the ARM target

2020-12-17 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard accepted this revision.
ostannard 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/D93231/new/

https://reviews.llvm.org/D93231

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


[clang] 9231045 - Make LLVM build in C++20 mode

2020-12-17 Thread Nuno Lopes via cfe-commits

Author: Barry Revzin
Date: 2020-12-17T10:44:10Z
New Revision: 92310454bf0f1f9686f38afd11756c7d046495c9

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

LOG: Make LLVM build in C++20 mode

Part of the <=> changes in C++20 make certain patterns of writing equality
operators ambiguous with themselves (sorry!).
This patch goes through and adjusts all the comparison operators such that
they should work in both C++17 and C++20 modes. It also makes two other small
C++20-specific changes (adding a constructor to a type that cases to be an
aggregate, and adding casts from u8 literals which no longer have type
const char*).

There were four categories of errors that this review fixes.
Here are canonical examples of them, ordered from most to least common:

// 1) Missing const
namespace missing_const {
struct A {
#ifndef FIXED
bool operator==(A const&);
#else
bool operator==(A const&) const;
#endif
};

bool a = A{} == A{}; // error
}

// 2) Type mismatch on CRTP
namespace crtp_mismatch {
template 
struct Base {
#ifndef FIXED
bool operator==(Derived const&) const;
#else
// in one case changed to taking Base const&
friend bool operator==(Derived const&, Derived const&);
#endif
};

struct D : Base { };

bool b = D{} == D{}; // error
}

// 3) iterator/const_iterator with only mixed comparison
namespace iter_const_iter {
template 
struct iterator {
using const_iterator = iterator;

iterator();

template  = 0>
iterator(iterator const&);

#ifndef FIXED
bool operator==(const_iterator const&) const;
#else
friend bool operator==(iterator const&, iterator const&);
#endif
};

bool c = iterator{} == iterator{} // error
  || iterator{} == iterator{}
  || iterator{} == iterator{}
  || iterator{} == iterator{};
}

// 4) Same-type comparison but only have mixed-type operator
namespace ambiguous_choice {
enum Color { Red };

struct C {
C();
C(Color);
operator Color() const;
bool operator==(Color) const;
friend bool operator==(C, C);
};

bool c = C{} == C{}; // error
bool d = C{} == Red;
}

Differential revision: https://reviews.llvm.org/D78938

Added: 


Modified: 
clang/include/clang/AST/StmtIterator.h
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
llvm/include/llvm/ADT/AllocatorList.h
llvm/include/llvm/ADT/DenseMap.h
llvm/include/llvm/ADT/DenseSet.h
llvm/include/llvm/ADT/DirectedGraph.h
llvm/include/llvm/ADT/STLExtras.h
llvm/include/llvm/ADT/StringMap.h
llvm/include/llvm/ADT/iterator.h
llvm/include/llvm/CodeGen/DIE.h
llvm/include/llvm/CodeGen/LiveInterval.h
llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h
llvm/include/llvm/IR/Attributes.h
llvm/include/llvm/IR/BasicBlock.h
llvm/include/llvm/Object/StackMapParser.h
llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h
llvm/include/llvm/ProfileData/InstrProfReader.h
llvm/include/llvm/Support/BinaryStreamRef.h
llvm/include/llvm/Support/SuffixTree.h
llvm/lib/CodeGen/PeepholeOptimizer.cpp
llvm/lib/IR/Attributes.cpp
llvm/lib/ObjectYAML/DWARFEmitter.cpp
llvm/lib/Transforms/Scalar/GVNHoist.cpp
llvm/tools/llvm-objdump/llvm-objdump.cpp
llvm/unittests/ADT/STLExtrasTest.cpp

Removed: 




diff  --git a/clang/include/clang/AST/StmtIterator.h 
b/clang/include/clang/AST/StmtIterator.h
index 911205347aad..bcdb0df829fb 100644
--- a/clang/include/clang/AST/StmtIterator.h
+++ b/clang/include/clang/AST/StmtIterator.h
@@ -104,12 +104,13 @@ class StmtIteratorImpl : public StmtIteratorBase,
 return tmp;
   }
 
-  bool operator==(const DERIVED& RHS) const {
-return stmt == RHS.stmt && DGI == RHS.DGI && RawVAPtr == RHS.RawVAPtr;
+  friend bool operator==(const DERIVED &LHS, const DERIVED &RHS) {
+return LHS.stmt == RHS.stmt && LHS.DGI == RHS.DGI &&
+   LHS.RawVAPtr == RHS.RawVAPtr;
   }
 
-  bool operator!=(const DERIVED& RHS) const {
-return stmt != RHS.stmt || DGI != RHS.DGI || RawVAPtr != RHS.RawVAPtr;
+  friend bool operator!=(const DERIVED &LHS, const DERIVED &RHS) {
+return !(LHS == RHS);
   }
 
   REFERENCE operator*() const {

diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index c4aa361b8262..db7e967b15ae 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -61,6 +61,12 @@ enum OpenMPDirectiveKindEx {
 struct OpenMPDirectiveKindExWrapper {
   OpenMPDirectiveKindExWrapper(unsigned Value) : Value(Value) {}
   OpenMPDirectiveKindE

[PATCH] D78938: Make LLVM build in C++20 mode

2020-12-17 Thread Nuno Lopes via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG92310454bf0f: Make LLVM build in C++20 mode (authored by 
BRevzin, committed by nlopes).

Changed prior to commit:
  https://reviews.llvm.org/D78938?vs=290023&id=312420#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78938

Files:
  clang/include/clang/AST/StmtIterator.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  llvm/include/llvm/ADT/AllocatorList.h
  llvm/include/llvm/ADT/DenseMap.h
  llvm/include/llvm/ADT/DenseSet.h
  llvm/include/llvm/ADT/DirectedGraph.h
  llvm/include/llvm/ADT/STLExtras.h
  llvm/include/llvm/ADT/StringMap.h
  llvm/include/llvm/ADT/iterator.h
  llvm/include/llvm/CodeGen/DIE.h
  llvm/include/llvm/CodeGen/LiveInterval.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/IR/BasicBlock.h
  llvm/include/llvm/Object/StackMapParser.h
  llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h
  llvm/include/llvm/ProfileData/InstrProfReader.h
  llvm/include/llvm/Support/BinaryStreamRef.h
  llvm/include/llvm/Support/SuffixTree.h
  llvm/lib/CodeGen/PeepholeOptimizer.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/ObjectYAML/DWARFEmitter.cpp
  llvm/lib/Transforms/Scalar/GVNHoist.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/unittests/ADT/STLExtrasTest.cpp

Index: llvm/unittests/ADT/STLExtrasTest.cpp
===
--- llvm/unittests/ADT/STLExtrasTest.cpp
+++ llvm/unittests/ADT/STLExtrasTest.cpp
@@ -472,21 +472,21 @@
 
   // Check fancy pointer overload for unique_ptr
   std::unique_ptr V2 = std::make_unique(0);
-  EXPECT_EQ(V2.get(), to_address(V2));
+  EXPECT_EQ(V2.get(), llvm::to_address(V2));
 
   V2.reset(V1);
-  EXPECT_EQ(V1, to_address(V2));
+  EXPECT_EQ(V1, llvm::to_address(V2));
   V2.release();
 
   // Check fancy pointer overload for shared_ptr
   std::shared_ptr V3 = std::make_shared(0);
   std::shared_ptr V4 = V3;
   EXPECT_EQ(V3.get(), V4.get());
-  EXPECT_EQ(V3.get(), to_address(V3));
-  EXPECT_EQ(V4.get(), to_address(V4));
+  EXPECT_EQ(V3.get(), llvm::to_address(V3));
+  EXPECT_EQ(V4.get(), llvm::to_address(V4));
 
   V3.reset(V1);
-  EXPECT_EQ(V1, to_address(V3));
+  EXPECT_EQ(V1, llvm::to_address(V3));
 }
 
 TEST(STLExtrasTest, partition_point) {
Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -806,19 +806,19 @@
 bool IsASCII = DbgVariables == DVASCII;
 switch (C) {
 case LineChar::RangeStart:
-  return IsASCII ? "^" : u8"\u2548";
+  return IsASCII ? "^" : (const char *)u8"\u2548";
 case LineChar::RangeMid:
-  return IsASCII ? "|" : u8"\u2503";
+  return IsASCII ? "|" : (const char *)u8"\u2503";
 case LineChar::RangeEnd:
-  return IsASCII ? "v" : u8"\u253b";
+  return IsASCII ? "v" : (const char *)u8"\u253b";
 case LineChar::LabelVert:
-  return IsASCII ? "|" : u8"\u2502";
+  return IsASCII ? "|" : (const char *)u8"\u2502";
 case LineChar::LabelCornerNew:
-  return IsASCII ? "/" : u8"\u250c";
+  return IsASCII ? "/" : (const char *)u8"\u250c";
 case LineChar::LabelCornerActive:
-  return IsASCII ? "|" : u8"\u2520";
+  return IsASCII ? "|" : (const char *)u8"\u2520";
 case LineChar::LabelHoriz:
-  return IsASCII ? "-" : u8"\u2500";
+  return IsASCII ? "-" : (const char *)u8"\u2500";
 }
 llvm_unreachable("Unhandled LineChar enum");
   }
Index: llvm/lib/Transforms/Scalar/GVNHoist.cpp
===
--- llvm/lib/Transforms/Scalar/GVNHoist.cpp
+++ llvm/lib/Transforms/Scalar/GVNHoist.cpp
@@ -149,8 +149,8 @@
   // The instruction (VN) which uses the values flowing out of CHI.
   Instruction *I;
 
-  bool operator==(const CHIArg &A) { return VN == A.VN; }
-  bool operator!=(const CHIArg &A) { return !(*this == A); }
+  bool operator==(const CHIArg &A) const { return VN == A.VN; }
+  bool operator!=(const CHIArg &A) const { return !(*this == A); }
 };
 
 using CHIIt = SmallVectorImpl::iterator;
Index: llvm/lib/ObjectYAML/DWARFEmitter.cpp
===
--- llvm/lib/ObjectYAML/DWARFEmitter.cpp
+++ llvm/lib/ObjectYAML/DWARFEmitter.cpp
@@ -650,7 +650,7 @@
 writeInteger((uint8_t)TableEntry.SegSelectorSize, OS, DI.IsLittleEndian);
 
 for (const SegAddrPair &Pair : TableEntry.SegAddrPairs) {
-  if (TableEntry.SegSelectorSize != 0)
+  if (TableEntry.SegSelectorSize != yaml::Hex8{0})
 if (Error Err = writeVariableSizedInteger(Pair.Segment,

[clang] 9ed8e0c - [NFC] Reduce include files dependency and AA header cleanup (part 2).

2020-12-17 Thread via cfe-commits

Author: dfukalov
Date: 2020-12-17T14:04:48+03:00
New Revision: 9ed8e0caab9b6f638e82979f6fdf60d67ce65b92

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

LOG: [NFC] Reduce include files dependency and AA header cleanup (part 2).

Continuing work started in https://reviews.llvm.org/D92489:

Removed a bunch of includes from "AliasAnalysis.h" and "LoopPassManager.h".

Reviewed By: RKSimon

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
lld/MachO/Driver.cpp
llvm/examples/Bye/Bye.cpp
llvm/include/llvm/Analysis/AliasAnalysis.h
llvm/include/llvm/Analysis/BasicAliasAnalysis.h
llvm/include/llvm/Analysis/MemorySSA.h
llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
llvm/lib/Analysis/AliasAnalysis.cpp
llvm/lib/Analysis/MemDepPrinter.cpp
llvm/lib/Analysis/MemorySSA.cpp
llvm/lib/Analysis/ScopedNoAliasAA.cpp
llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
llvm/lib/CodeGen/LiveIntervals.cpp
llvm/lib/LTO/Caching.cpp
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/lib/Transforms/IPO/FunctionAttrs.cpp
llvm/lib/Transforms/IPO/HotColdSplitting.cpp
llvm/lib/Transforms/IPO/Inliner.cpp
llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/lib/Transforms/ObjCARC/ProvenanceAnalysisEvaluator.cpp
llvm/lib/Transforms/Scalar/FlattenCFGPass.cpp
llvm/lib/Transforms/Scalar/Float2Int.cpp
llvm/lib/Transforms/Scalar/LoopDistribute.cpp
llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
llvm/lib/Transforms/Scalar/LoopPassManager.cpp
llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
llvm/lib/Transforms/Utils/LoopVersioning.cpp
llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
llvm/tools/opt/NewPMDriver.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 2dbf30ef171f..b326c643738f 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -18,6 +18,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/StackSafetyAnalysis.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"

diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 030cbef53049..c522a082a306 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -34,6 +34,7 @@
 #include "llvm/LTO/LTO.h"
 #include "llvm/Object/Archive.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"

diff  --git a/llvm/examples/Bye/Bye.cpp b/llvm/examples/Bye/Bye.cpp
index 4e39cd5c660b..78b4363123c3 100644
--- a/llvm/examples/Bye/Bye.cpp
+++ b/llvm/examples/Bye/Bye.cpp
@@ -3,6 +3,7 @@
 #include "llvm/Pass.h"
 #include "llvm/Passes/PassBuilder.h"
 #include "llvm/Passes/PassPlugin.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
 

diff  --git a/llvm/include/llvm/Analysis/AliasAnalysis.h 
b/llvm/include/llvm/Analysis/AliasAnalysis.h
index cc5cec44b455..b84febaeeeaa 100644
--- a/llvm/include/llvm/Analysis/AliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -42,8 +42,6 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Analysis/MemoryLocation.h"
-#include "llvm/IR/Instruction.h"
-#include "llvm/IR/Instructions.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Pass.h"
 #include 
@@ -54,10 +52,17 @@
 namespace llvm {
 
 class AnalysisUsage;
+class AtomicCmpXchgInst;
 class BasicAAResult;
 class BasicBlock;
+class CatchPadInst;
+class CatchReturnInst;
 class DominatorTree;
+class FenceInst;
 class Function;
+class InvokeInst;
+class PreservedAnalyses;
+class TargetLibraryInfo;
 class Value;
 
 /// The possible results of an alias query.
@@ -768,40 +773,7 @@ class AAResults {
AAQueryInfo &AAQI);
   ModRefInfo getModRefInfo(const Instruction *I,
const Optional &OptLoc,
-   AAQueryInfo &AAQIP) {
-if (OptLoc == None) {
-  if (const auto *Call = dyn_cast(I)) {
-return createModRefInfo(getModRefBehavior(Call));
-  }
-}
-
-c

[PATCH] D92852: [NFC] Reduce include files dependency and AA header cleanup (part 2).

2020-12-17 Thread Daniil Fukalov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9ed8e0caab9b: [NFC] Reduce include files dependency and AA 
header cleanup (part 2). (authored by dfukalov).

Changed prior to commit:
  https://reviews.llvm.org/D92852?vs=310509&id=312422#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92852

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  lld/MachO/Driver.cpp
  llvm/examples/Bye/Bye.cpp
  llvm/include/llvm/Analysis/AliasAnalysis.h
  llvm/include/llvm/Analysis/BasicAliasAnalysis.h
  llvm/include/llvm/Analysis/MemorySSA.h
  llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
  llvm/lib/Analysis/AliasAnalysis.cpp
  llvm/lib/Analysis/MemDepPrinter.cpp
  llvm/lib/Analysis/MemorySSA.cpp
  llvm/lib/Analysis/ScopedNoAliasAA.cpp
  llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
  llvm/lib/CodeGen/LiveIntervals.cpp
  llvm/lib/LTO/Caching.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
  llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
  llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
  llvm/lib/Transforms/IPO/FunctionAttrs.cpp
  llvm/lib/Transforms/IPO/HotColdSplitting.cpp
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/ObjCARC/ProvenanceAnalysisEvaluator.cpp
  llvm/lib/Transforms/Scalar/FlattenCFGPass.cpp
  llvm/lib/Transforms/Scalar/Float2Int.cpp
  llvm/lib/Transforms/Scalar/LoopDistribute.cpp
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Scalar/LoopPassManager.cpp
  llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
  llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
  llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
  llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
  llvm/lib/Transforms/Utils/LoopVersioning.cpp
  llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -16,6 +16,7 @@
 #include "PassPrinters.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/CGSCCPassManager.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Bitcode/BitcodeWriterPass.h"
Index: llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
===
--- llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
+++ llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
 #include "llvm/CodeGen/CommandFlags.h"
@@ -18,6 +19,7 @@
 #include "llvm/IR/Verifier.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Passes/PassBuilder.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
Index: llvm/lib/Transforms/Utils/LoopVersioning.cpp
===
--- llvm/lib/Transforms/Utils/LoopVersioning.cpp
+++ llvm/lib/Transforms/Utils/LoopVersioning.cpp
@@ -14,7 +14,6 @@
 
 #include "llvm/Transforms/Utils/LoopVersioning.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/LoopAccessAnalysis.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/MemorySSA.h"
Index: llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
===
--- llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
+++ llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
@@ -22,7 +22,6 @@
 
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/Statistic.h"
-#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/LoopIterator.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/IR/BasicBlock.h"
Index: llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
===
--- llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
+++ llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
@@ -12,7 +12,6 @@
 
 #include "llvm/Transforms/Utils/LoopRotationUtils.h"
 #include "llvm/ADT/Statistic.h"
-#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/AssumptionCache.h"
 #include "llvm/Analysis/BasicAliasAnalysis.h"
 #include "llvm/Analysis/CodeMetrics.h"
Index: llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
===
--- llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ llvm/lib/Trans

[PATCH] D78938: Make LLVM build in C++20 mode

2020-12-17 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

@BRevzin @nlopes This is causing MSVC build failure please can you take a look?

  E:\llvm\llvm-project\llvm\include\llvm/DebugInfo/DWARF/DWARFDie.h(405): note: 
see declaration of 'std::reverse_iterator'
  E:\llvm\llvm-project\llvm\lib\DWARFLinker\DWARFLinker.cpp(383): note: see 
reference to function template instantiation 'bool std::operator 
!=(const 
std::reverse_iterator &,const 
std::reverse_iterator &)' being compiled
  C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Professional\VC\Tools\MSVC\14.28.29333\include\xutility(2086): 
error C2039: '_Get_current': is not a member of 
'std::reverse_iterator'
  E:\llvm\llvm-project\llvm\include\llvm/DebugInfo/DWARF/DWARFDie.h(405): note: 
see declaration of 'std::reverse_iterator'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78938

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


[PATCH] D93227: [clangd] Smarter hover on auto and decltype

2020-12-17 Thread Quentin Chateau via Phabricator via cfe-commits
qchateau updated this revision to Diff 312432.
qchateau added a comment.

- Rebase on master after D92041 
- Remove the usage of the "Documentation" field
- Use the `TypeAlias` Kind on auto and decltype
- Move code related to hover on `this` in a new function
- Update hover on `this` to be consistent with this change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93227

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -379,6 +379,42 @@
  HI.Definition = "class X {}";
}},
 
+  // auto on structured bindings
+  {R"cpp(
+void foo() {
+  int arr[2];
+  [[au^to]] [x, y] = arr;
+}
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "int[2]";
+   }},
+  // auto on structured bindings
+  {R"cpp(
+void foo() {
+  struct S { int x; float y; };
+  [[au^to]] [x, y] = S();
+}
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "struct S";
+   }},
+  // undeduced auto
+  {R"cpp(
+template
+void foo() {
+  [[au^to]] x = T{};
+}
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "/* not deduced */";
+   }},
   // auto on lambda
   {R"cpp(
 void foo() {
@@ -386,8 +422,9 @@
 }
 )cpp",
[](HoverInfo &HI) {
- HI.Name = "(lambda)";
- HI.Kind = index::SymbolKind::Class;
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "(lambda)";
}},
   // auto on template instantiation
   {R"cpp(
@@ -397,8 +434,9 @@
 }
 )cpp",
[](HoverInfo &HI) {
- HI.Name = "Foo";
- HI.Kind = index::SymbolKind::Class;
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "class Foo";
}},
   // auto on specialized template
   {R"cpp(
@@ -409,8 +447,9 @@
 }
 )cpp",
[](HoverInfo &HI) {
- HI.Name = "Foo";
- HI.Kind = index::SymbolKind::Class;
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "class Foo";
}},
 
   // macro
@@ -582,8 +621,9 @@
   }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "Foo";
-HI.Kind = index::SymbolKind::Class;
+HI.Name = "auto";
+HI.Kind = index::SymbolKind::TypeAlias;
+HI.Definition = "class Foo";
   }},
   {// Falls back to primary template, when the type is not instantiated.
R"cpp(
@@ -955,12 +995,9 @@
   llvm::StringRef Tests[] = {
   "^int main() {}",
   "void foo() {^}",
-  R"cpp(// structured binding. Not supported yet
-struct Bar {};
-void foo() {
-  Bar a[2];
-  ^auto [x,y] = a;
-}
+  "decltype(au^to) x = 0;",
+  R"cpp(// Lambda auto parameter. Nothing (Not useful).
+auto lamb = [](a^uto){};
   )cpp",
   R"cpp(// Template auto parameter. Nothing (Not useful).
 template
@@ -1545,9 +1582,9 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "int";
-// FIXME: Should be Builtin/Integral.
-HI.Kind = index::SymbolKind::Unknown;
+HI.Name = "auto";
+HI.Kind = index::SymbolKind::TypeAlias;
+HI.Definition = "int";
   }},
   {
   R"cpp(// Simple initialization with const auto
@@ -1555,14 +1592,22 @@
   const ^[[auto]] i = 1;
 }
   )cpp",
-  [](HoverInfo &HI) { HI.Name = "int"; }},
+  [](HoverInfo &HI) {
+HI.Name = "auto";
+HI.Kind = index::SymbolKind::TypeAlias;
+HI.Definition = "int";
+  }},
   {
   R"cpp(// Simple initialization with const auto&
 void foo() {
   const ^[[auto]]& i = 1;
 }
   )cpp",
-  [](HoverInfo &HI) { HI.Name = "int"; }},
+  [](HoverInfo &HI) {
+HI.Name = "auto";
+HI.Kind = index::SymbolKind::TypeAlias;
+HI.Definition = "int";
+  }},
   {
   R"cpp(// Simple initialization with auto&
 void foo() {
@@ -1570,7

[PATCH] D93102: [Clang][Sema] Detect section type conflicts between functions and variables

2020-12-17 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson updated this revision to Diff 312434.
tmatheson added a comment.

Minor syntax change, fix CodeGen/attributes.c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93102

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attributes.c
  clang/test/Sema/attr-section.c
  clang/test/SemaCXX/attr-section.cpp
  clang/test/SemaObjC/method-attributes.m

Index: clang/test/SemaObjC/method-attributes.m
===
--- clang/test/SemaObjC/method-attributes.m
+++ clang/test/SemaObjC/method-attributes.m
@@ -99,3 +99,18 @@
 
 + (void) CMethod : (id) Obj __attribute__((section("__TEXT,fee")));
 @end
+
+// Section type conflicts between methods/properties and global variables
+const int global1 __attribute__((section("seg1,sec1"))) = 10; // expected-note {{declared here}} expected-note {{declared here}} expected-note {{declared here}}
+int global2 __attribute__((section("seg2,sec2"))) = 10;   // expected-note {{declared here}} expected-note {{declared here}} expected-note {{declared here}}
+
+@interface section_conflicts : NSObject
+@property int p1 __attribute__((section("seg1,sec1"))); // expected-error {{'p1' causes a section type conflict with 'global1'}}
+@property int p2 __attribute__((section("seg2,sec2"))); // expected-error {{'p2' causes a section type conflict with 'global2'}}
+
+- (void)imethod1 __attribute__((section("seg1,sec1"))); // expected-error {{'imethod1' causes a section type conflict with 'global1'}}
+- (void)imethod2 __attribute__((section("seg2,sec2"))); // expected-error {{'imethod2' causes a section type conflict with 'global2'}}
+
++ (void)cmethod1:(id)Obj __attribute__((section("seg1,sec1"))); // expected-error {{'cmethod1:' causes a section type conflict with 'global1'}}
++ (void)cmethod2:(id)Obj __attribute__((section("seg2,sec2"))); // expected-error {{'cmethod2:' causes a section type conflict with 'global2'}}
+@end
Index: clang/test/SemaCXX/attr-section.cpp
===
--- clang/test/SemaCXX/attr-section.cpp
+++ clang/test/SemaCXX/attr-section.cpp
@@ -42,3 +42,9 @@
   __attribute__((section("baz"))) // expected-warning {{section does not match}}
   void C::f() {}
 }
+
+// Check for section type conflicts between global variables and function templates
+template  __attribute__((section("template_fn1"))) void template_fn1() {} // expected-note {{declared here}}
+const int const_global_var __attribute__((section("template_fn1"))) = 42;   // expected-error {{'const_global_var' causes a section type conflict with 'template_fn1'}}
+int mut_global_var __attribute__((section("template_fn2"))) = 42;   // expected-note {{declared here}}
+template  __attribute__((section("template_fn2"))) void template_fn2() {} // expected-error {{'template_fn2' causes a section type conflict with 'mut_global_var'}}
Index: clang/test/Sema/attr-section.c
===
--- clang/test/Sema/attr-section.c
+++ clang/test/Sema/attr-section.c
@@ -26,9 +26,27 @@
 
 // Not a warning.
 int c;
-int c __attribute__((section("foo,zed")));
+int c __attribute__((section("seg1,sec1")));
 
 // Also OK.
 struct r_debug {};
 extern struct r_debug _r_debug;
 struct r_debug _r_debug __attribute__((nocommon, section(".r_debug,bar")));
+
+// Section type conflicts between functions and variables
+void test3(void) __attribute__((section("seg3,sec3"))); // expected-note {{declared here}}
+void test3(void) {}
+const int const_global_var __attribute__((section("seg3,sec3"))) = 10; // expected-error {{'const_global_var' causes a section type conflict with 'test3'}}
+
+void test4(void) __attribute__((section("seg4,sec4"))); // expected-note {{declared here}}
+void test4(void) {}
+int mut_global_var __attribute__((section("seg4,sec4"))) = 10; // expected-error {{'mut_global_var' causes a section type conflict with 'test4'}}
+
+const int global_seg5sec5 __attribute__((section("seg5,sec5"))) = 10; // expected-note {{declared here}}
+void test5(void) __attribute__((section("seg5,sec5")));   // expected-error {{'test5' causes a section type conflict with 'global_seg5sec5'}}
+void test5(void) {}
+
+void test6(void);
+const int global_seg6sec6 __attribute__((section("seg6,sec6"))) = 10; // expected-note {{declared here}}
+void test6(void) __attribute__((section("seg6,sec6")));   // expected-error {{'test6' causes a section type conflict with 'global_seg6sec6'}}
+void test6(void) {}
Index: clang/test/CodeGen/attributes.c
===
--- clang/test/CodeGen/attributes.c
+++ clang/test/CodeGen/attributes.c
@@ -63,11 +63,11 @@
 // CHECK: call void @t71() [[COLDSITE:#[0-9]+]]
 // CHECK: d

[PATCH] D93227: [clangd] Smarter hover on auto and decltype

2020-12-17 Thread Quentin Chateau via Phabricator via cfe-commits
qchateau added a comment.

> We can't easily add new SymbolKinds (it's an enum we don't own, which we 
> should fix, but that's a yak-shave). But `TypeAlias` almost fits these roles 
> for auto.

Yes I originally wanted to have "deduced-type `auto`" but I realized it would 
not be easy. I did not think of `TypeAlias`, let's use this until we can do 
better.

> (There are other cases: function parameter types `void foo(auto X)` and NTTP 
> types `template  class Y` but we can punt on those)

For now I disabled them (instead of displaying nonsense as we did before). 
Anyway as a user, I have zero useful information to get when hovering on these 
word, I prefer nothing rather than a useless pop-up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93227

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


[clang-tools-extra] 894c476 - [clangd] Add llvm:: qualifier to work around GCC bug. NFC

2020-12-17 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-12-17T12:51:12+01:00
New Revision: 894c4761c67ac850e156a26aa427035a811d7aed

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

LOG: [clangd] Add llvm:: qualifier to work around GCC bug. NFC

Some old GCC versions seem to miss the default template parameter when
using the clang/Basic/LLVM.h forward declarations of SmallVector.

See D92788

Added: 


Modified: 
clang-tools-extra/clangd/Headers.h

Removed: 




diff  --git a/clang-tools-extra/clangd/Headers.h 
b/clang-tools-extra/clangd/Headers.h
index d86a4788f0a6..fd9db5562813 100644
--- a/clang-tools-extra/clangd/Headers.h
+++ b/clang-tools-extra/clangd/Headers.h
@@ -136,7 +136,7 @@ class IncludeStructure {
   unsigned fileIndex(llvm::StringRef Name);
   llvm::StringMap NameToIndex; // Values are file indexes.
   // Maps a file's index to that of the files it includes.
-  llvm::DenseMap> IncludeChildren;
+  llvm::DenseMap> IncludeChildren;
 };
 
 /// Returns a PPCallback that visits all inclusions in the main file.



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


[PATCH] D93428: [AArch64] Add bti note property when compiling asm files with -mbranch-protection=bti

2020-12-17 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss added a comment.

The `.note.gnu.property` is already generated when C/C++ files are compiled 
with `-mbranch-protection=bti`.  
`-mmark-bti-property` is only for assembly file where the `.note.gnu.property` 
should be added manually otherwise.

Do you have any reproducer where C/C++ behaves unexpectedly?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93428

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


[PATCH] D93102: [Clang][Sema] Detect section type conflicts between functions and variables

2020-12-17 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added a comment.

In D93102#2458433 , @aaron.ballman 
wrote:

> LGTM aside from a minor nit. Thank you for the patch! Do you need me to 
> commit on your behalf? If so, are you okay with `Tomas Matheson 
> ` for patch attribution?

Thanks for the review. I will ask for commit access for future but if you could 
commit this one in the meantime that would be appreciated. That's fine for 
attribution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93102

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


[PATCH] D92788: [clangd] NFC: Use SmallVector where possible

2020-12-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Should be fixed in 894c4761c67ac850e156a26aa427035a811d7aed 
, LMK if 
this workaround doesn't work


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92788

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


[PATCH] D93393: [clangd] Ignore the static index refs from the dynamic index files.

2020-12-17 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 312440.
ArcsinX added a comment.

bool SymbolIndex::hasFile(llvm::StringRef) => 
llvm::unique_function SymbolIndex::indexedFiles()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93393

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/Index.h
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/index/Merge.h
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/dex/Dex.h
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DexTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.cpp

Index: clang-tools-extra/clangd/unittests/TestFS.cpp
===
--- clang-tools-extra/clangd/unittests/TestFS.cpp
+++ clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -99,8 +99,9 @@
   llvm::Expected
   getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
   llvm::StringRef HintPath) const override {
-if (!HintPath.startswith(testRoot()))
-  return error("Hint path doesn't start with test root: {0}", HintPath);
+if (!HintPath.empty() && !HintPath.startswith(testRoot()))
+  return error("Hint path is not empty and doesn't start with {0}: {1}",
+   testRoot(), HintPath);
 if (!Body.consume_front("/"))
   return error("Body of an unittest: URI must start with '/'");
 llvm::SmallString<16> Path(Body.begin(), Body.end());
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1237,6 +1237,11 @@
 void relations(const RelationsRequest &Req,
llvm::function_ref
Callback) const override {}
+
+llvm::unique_function indexedFiles() const override {
+  return nullptr;
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
   } PIndex;
   Results = rename({MainCode.point(),
@@ -1285,6 +1290,11 @@
 void relations(const RelationsRequest &,
llvm::function_ref)
 const override {}
+
+llvm::unique_function indexedFiles() const override {
+  return nullptr;
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
 Ref ReturnedRef;
   } DIndex(XRefInBarCC);
Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -224,6 +224,21 @@
   EXPECT_THAT(lookup(*I, SymbolID("ns::nonono")), UnorderedElementsAre());
 }
 
+TEST(MemIndexTest, IndexedFiles) {
+  SymbolSlab Symbols;
+  RefSlab Refs;
+  auto Size = Symbols.bytes() + Refs.bytes();
+  auto Data = std::make_pair(std::move(Symbols), std::move(Refs));
+  llvm::StringSet<> Files = {testPath("foo.cc"), testPath("bar.cc")};
+  MemIndex I(std::move(Data.first), std::move(Data.second), RelationSlab(),
+ std::move(Files), std::move(Data), Size);
+  auto ContainsFile = I.indexedFiles();
+  ASSERT_TRUE(ContainsFile);
+  EXPECT_TRUE(ContainsFile("unittest:///foo.cc"));
+  EXPECT_TRUE(ContainsFile("unittest:///bar.cc"));
+  EXPECT_FALSE(ContainsFile("unittest:///foobar.cc"));
+}
+
 TEST(MemIndexTest, TemplateSpecialization) {
   SymbolSlab::Builder B;
 
@@ -367,7 +382,7 @@
   Test.Code = std::string(Test1Code.code());
   Test.Filename = "test.cc";
   auto AST = Test.build();
-  Dyn.updateMain(Test.Filename, AST);
+  Dyn.updateMain(testPath(Test.Filename), AST);
 
   // Build static index for test.cc.
   Test.HeaderCode = HeaderCode;
@@ -375,7 +390,7 @@
   Test.Filename = "test.cc";
   auto StaticAST = Test.build();
   // Add stale refs for test.cc.
-  StaticIndex.updateMain(Test.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test.Filename), StaticAST);
 
   // Add refs for test2.cc
   Annotations Test2Code(R"(class $Foo[[Foo]] {};)");
@@ -384,7 +399,7 @@
   Test2.Code = std::string(Test2Code.code());
   Test2.Filename = "test2.cc";
   StaticAST = Test2.build();
-  StaticIndex.updateMain(Test2.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test2.Filename), StaticAST);
 
   RefsRequest Request;
   Request.IDs = {Foo.ID};
@@ -403,10 +418,48 @@
   RefSlab::Builder Results2;
   EXPECT_TRUE(
   Merge.refs(Request, [&](const Ref &O) { Results2.insert(Foo.ID, O); }));
-  EXPECT_THAT(std::move(Res

[PATCH] D93393: [clangd] Ignore the static index refs from the dynamic index files.

2020-12-17 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX added a comment.

Thanks for your reply. I have updated the patch (changed signature of 
`hasFile`), but remote-index scenario is not clear for me yet.

In D93393#2458168 , @sammccall wrote:

> Implementing a pseudo-batch form of hasFiles as an RPC for remote-index: we'd 
> need to give up on getting answers for files one-by-one. That would be OK for 
> an N-way merge (since we'd fetch all results before merging, we could build a 
> list). But servers typically index *everything* under a certain directory, so 
> fetching the list of directories and evaluating per-file queries client-side 
> is a cheap and reasonable alternative (that's more accurate than `return 
> false`!)

Seems I need some clarifications here.
Is it should be like this?:

- [client]->[server] Give me all directories and subdirectories
- [client]<-[server] All directories are .

  IndexClient::indexedFiles() {
  
  }

What structure should be used for directories list? I think we can use Trie

Am I right about your suggestion?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93393

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


[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2020-12-17 Thread Sunny via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 312444.

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

https://reviews.llvm.org/D93298

Files:
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZfinx.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/MC/RISCV/rv32d-invalid.s
  llvm/test/MC/RISCV/rv32zfh-invalid.s
  llvm/test/MC/RISCV/rvzfinx-valid.s

Index: llvm/test/MC/RISCV/rvzfinx-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvzfinx-valid.s
@@ -0,0 +1,333 @@
+# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zfinx %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv64 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zfinx %s \
+# RUN:| llvm-objdump -d --mattr=+experimental-zfinx - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zfinx %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+fmadd.h a0, a1, a2, a3
+# CHECK-INST: fmadd.h a0, a1, a2, a3
+# CHECK-ENCODING: [0x43,0xf5,0xc5,0x6c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 43 f5 c5 6c 
+
+fmsub.h a0, a1, a2, a3
+# CHECK-INST: fmsub.h a0, a1, a2, a3
+# CHECK-ENCODING: [0x47,0xf5,0xc5,0x6c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 47 f5 c5 6c 
+
+fnmsub.h a0, a1, a2, a3
+# CHECK-INST: fnmsub.h a0, a1, a2, a3
+# CHECK-ENCODING: [0x4b,0xf5,0xc5,0x6c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 4b f5 c5 6c 
+
+fnmadd.h a0, a1, a2, a3
+# CHECK-INST: fnmadd.h a0, a1, a2, a3
+# CHECK-ENCODING: [0x4f,0xf5,0xc5,0x6c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 4f f5 c5 6c 
+
+fadd.h a0, a1, a2
+# CHECK-INST: fadd.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xf5,0xc5,0x04]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 f5 c5 04 
+
+fsub.h a0, a1, a2
+# CHECK-INST: fsub.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xf5,0xc5,0x0c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 f5 c5 0c 
+
+fmul.h a0, a1, a2
+# CHECK-INST: fmul.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xf5,0xc5,0x14]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 f5 c5 14 
+
+fdiv.h a0, a1, a2
+# CHECK-INST: fdiv.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xf5,0xc5,0x1c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 f5 c5 1c 
+
+fsqrt.h a0, a1
+# CHECK-INST: fsqrt.h a0, a1
+# CHECK-ENCODING: [0x53,0xf5,0x05,0x5c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 f5 05 5c 
+
+fsgnj.h a0, a1, a2
+# CHECK-INST: fsgnj.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x85,0xc5,0x24]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 85 c5 24 
+
+fsgnjn.h a0, a1, a2
+# CHECK-INST: fsgnjn.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x95,0xc5,0x24]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 95 c5 24 
+
+fsgnjx.h a0, a1, a2
+# CHECK-INST: fsgnjx.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xa5,0xc5,0x24]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 a5 c5 24 
+
+fmin.h a0, a1, a2
+# CHECK-INST: fmin.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x85,0xc5,0x2c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 85 c5 2c 
+
+fmax.h a0, a1, a2
+# CHECK-INST: fmax.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x95,0xc5,0x2c]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 95 c5 2c 
+
+feq.h a0, a1, a2
+# CHECK-INST: feq.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0xa5,0xc5,0xa4]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 a5 c5 a4 
+
+flt.h a0, a1, a2
+# CHECK-INST: flt.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x95,0xc5,0xa4]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 95 c5 a4 
+
+fle.h a0, a1, a2
+# CHECK-INST: fle.h a0, a1, a2
+# CHECK-ENCODING: [0x53,0x85,0xc5,0xa4]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 85 c5 a4 
+
+fclass.h a0, a1
+# CHECK-INST: fclass.h a0, a1
+# CHECK-ENCODING: [0x53,0x95,0x05,0xe4]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 53 95 05 e4 
+
+fmadd.s a0, a1, a2, a3
+# CHECK-INST: fmadd.s a0, a1, a2, a3
+# CHECK-ENCODING: [0x43,0xf5,0xc5,0x68]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 43 f5 c5 68 
+
+fmsub.s a0, a1, a2, a3
+# CHECK-INST: fmsub.s a0, a1, a2, a3
+# CHECK-ENCODING: [0x47,0xf5,0xc5,0x68]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 47 f5 c5 68 
+
+fnmsub.s a0, a1, a2, a3
+# CHECK-INST: fnmsub.s a0, a1, a2, a3
+# CHECK-ENCODING: [0x4b,0xf5,0xc5,0x68]
+# CHECK-ERROR: 'Zfinx' (Float in Integer)
+# CHECK-UNKNOWN: 4b f5 c5 68 
+
+fnmadd.s a0, a1, a2, a3
+# CHECK-INST: fnmadd.s a0, a1, 

[PATCH] D93393: [clangd] Ignore the static index refs from the dynamic index files.

2020-12-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks, this should work with some slight tweaks.
Biggest question is if we really need/want to allow this function to be null.




Comment at: clang-tools-extra/clangd/index/Index.h:127
+  /// index or not.
+  virtual llvm::unique_function indexedFiles() const = 0;
+

Maybe to be really explicit, add the lifetime constraint: "The function must 
only be called while the index is alive."



Comment at: clang-tools-extra/clangd/index/Index.h:127
+  /// index or not.
+  virtual llvm::unique_function indexedFiles() const = 0;
+

sammccall wrote:
> Maybe to be really explicit, add the lifetime constraint: "The function must 
> only be called while the index is alive."
it looks below like you allow this to return nullptr. TL;DR: I think we 
probably shouldn't, and just return false with a fixme in RemoteIndex, and 
false without a fixme in ProjectAwareIndex.

If we do this, we should:
 - explicitly call out that possibility, because it's error-prone
 - carefully define the semantics

In the implementations nullptr seems to be used in two ways:
 - to mean "always no", as in ProjectAwareIndex with no project.
 - to mean "always don't-know", as in RemoteIndex. The problem is 

I don't see any reason to use nullptr for "no" instead of returning 
`[](StringRef){return false;}`.
The "don't-know" is more appealing, because the indexes don't have to lie and 
instead the caller handles the ambiguity. The problem is you can't be 
consistent about it. Given a MergedIndex where Static->indexedFiles() is 
non-null and Dynamic->indexFiles() is null, then the answer can be "yes" or 
"don't know" depending on the file, and we can't express that, so we have to 
lie anyway.

We could add a tristate return value for the function, but given that it's 
plausible we could actually implement indexedFiles() for remote index later, I 
think we should just return false in the "don't know" case for now, with a 
FIXME there.



Comment at: clang-tools-extra/clangd/index/MemIndex.cpp:116
+if (!Path)
+  return false;
+return Files.contains(*Path);

need to `consumeError(Path.takeError())` here, or we'll crash in debug mode on 
error



Comment at: clang-tools-extra/clangd/index/Merge.cpp:127
+  return [this](llvm::StringRef FileURI) {
+auto DynamicContainsFile = Dynamic->indexedFiles();
+auto StaticContainsFile = Static->indexedFiles();

this is calling indexedFiles() once for each file we're checking, rather than 
once overall.

You want to move these variables to the capture list instead. (There should be 
no need to capture `this` in the end)



Comment at: clang-tools-extra/clangd/index/ProjectAware.cpp:121
+return Idx->indexedFiles();
+  return nullptr;
+}

(this is definitely-no-files, so as mentioned above `[](StringRef){return 
false;}` seems more appropriate)



Comment at: clang-tools-extra/clangd/index/dex/Dex.cpp:320
+if (!Path)
+  return false;
+return Files.contains(*Path);

and need to consume error here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93393

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


[PATCH] D93393: [clangd] Ignore the static index refs from the dynamic index files.

2020-12-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a subscriber: kbobyrev.
sammccall added a comment.

In D93393#2460066 , @ArcsinX wrote:

> Thanks for your reply. I have updated the patch (changed signature of 
> `hasFile`), but remote-index scenario is not clear for me yet.

Sorry, I didn't see this before comments.

To be clear, I'm *not* asking you to add remote support in this patch, I'm just 
thinking aloud at what it might be like.
The "return false" behavior is fine for now. The remote index is basically at 
the bottom of the stack, so it's mostly moot. And "return false" yields the old 
behavior anyway.

I just want to think aloud about how we can add it on :-)

> In D93393#2458168 , @sammccall wrote:
>
>> Implementing a pseudo-batch form of hasFiles as an RPC for remote-index: 
>> we'd need to give up on getting answers for files one-by-one. That would be 
>> OK for an N-way merge (since we'd fetch all results before merging, we could 
>> build a list). But servers typically index *everything* under a certain 
>> directory, so fetching the list of directories and evaluating per-file 
>> queries client-side is a cheap and reasonable alternative (that's more 
>> accurate than `return false`!)
>
> Seems I need some clarifications here.
> Is it should be like this?:
>
> - [client]->[server] Give me all directories and subdirectories
> - [client]<-[server] All directories are .
>
> (we need this only once)

Right - we could fetch it when the connection goes up, or on every request, or 
even configure it entirely client-side (the client knows about the "mount 
point" of the index and maybe we could assume it's fully-populated). I'm a 
little hazy on this, @kbobyrev @kadircet would know what's best here once back 
from vacation.

>   IndexClient::indexedFiles() {
>list (i.e. full filename starts with a directory from the list)>
>   }
>
> What structure should be used for directories list? I think we can use Trie

Probably just a string or flat list - I think this is exactly one directory 
today, maybe a short list in future.
(We have the assumption of a single root for path-translation purposes, not 
sure if we've seen any need for that root to be "partly-populated" yet. If so 
we may just end up creating one `Index` instance per directory and share stubs 
between them.)

But again, this isn't something you need to build now, unless you're really 
keen :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93393

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


[PATCH] D93452: [clangd] Trim memory after buildINdex

2020-12-17 Thread Quentin Chateau via Phabricator via cfe-commits
qchateau created this revision.
qchateau added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
qchateau requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

This diff addresses the issue of the ever increasing memory usage of clangd. 
The key to understand what happens is to use `malloc_stats()`: malloc arenas 
keep getting bigger, although the actual memory used does not. It seems some 
operations while bulding the indices (both dynamic and background) create this 
problem. Specifically, 'FileSymbols::update' and 'FileSymbols::buildIndex' seem 
especially affected.

This diff adds a call to `malloc_trim(0)` at the end of 
`FileSymbols::buildIndex`.

For reference:
https://github.com/clangd/clangd/issues/251
https://github.com/clangd/clangd/issues/115



I'm not sure how much I'm allowed to use GNU extensions but this diff has been 
a game changer for me and my 8GB RAM laptop.

In any case, I think I've properly diagnosed to issue. Once trimmed, the actual 
memory usage of the process is approximately what clangd reports with the 
"memoryUsage" feature.

The solution is either what I suggest here (use `malloc_trim`) or rework a ton 
of code, change containers and allocators and hope the problem won't happen 
again in the future as we add features.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93452

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp


Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -32,6 +32,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
@@ -40,11 +41,17 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
 namespace {
 
+void trimMemory() {
+  if (malloc_trim(0))
+vlog("Trimmed memory");
+}
+
 SlabTuple indexSymbols(ASTContext &AST, std::shared_ptr PP,
llvm::ArrayRef DeclsToIndex,
const MainFileMacros *MacroRefsToIndex,
@@ -263,6 +270,10 @@
 std::unique_ptr
 FileSymbols::buildIndex(IndexType Type, DuplicateHandling DuplicateHandle,
 size_t *Version) {
+  // Building the index often leaves a lof of freed but unreleased memory
+  // (at the OS level): manually trim the memory after the index is built
+  auto _ = llvm::make_scope_exit(trimMemory);
+
   std::vector> SymbolSlabs;
   std::vector> RefSlabs;
   std::vector> RelationSlabs;


Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -32,6 +32,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
@@ -40,11 +41,17 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
 namespace {
 
+void trimMemory() {
+  if (malloc_trim(0))
+vlog("Trimmed memory");
+}
+
 SlabTuple indexSymbols(ASTContext &AST, std::shared_ptr PP,
llvm::ArrayRef DeclsToIndex,
const MainFileMacros *MacroRefsToIndex,
@@ -263,6 +270,10 @@
 std::unique_ptr
 FileSymbols::buildIndex(IndexType Type, DuplicateHandling DuplicateHandle,
 size_t *Version) {
+  // Building the index often leaves a lof of freed but unreleased memory
+  // (at the OS level): manually trim the memory after the index is built
+  auto _ = llvm::make_scope_exit(trimMemory);
+
   std::vector> SymbolSlabs;
   std::vector> RefSlabs;
   std::vector> RelationSlabs;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86137: Add -Wno-error=unknown flag to clang-format.

2020-12-17 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.
Herald added a subscriber: dexonsmith.

I think the `=` in the option name is confusing the option parser,

  ➜  clang-format --Wno-error=unknown
  clang-format: Unknown command line argument '--Wno-error=unknown'.  Try: 
'clang-format --help'
  clang-format: Did you mean '--Werror=unknown'?

Should the name be changed to `Wno-error-unknown`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

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


[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2020-12-17 Thread Sunny via Phabricator via cfe-commits
achieveartificialintelligence added a comment.

Thanks. I've updated it.


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

https://reviews.llvm.org/D93298

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


[PATCH] D92445: [PowerPC] Add powerpcle target.

2020-12-17 Thread Daniel Kolesa via Phabricator via cfe-commits
q66 added a comment.

I've tested the patch (applied to LLVM11) and can confirm it works. There have 
been some changes/fixes I needed to do, which I already reported on IRC, so I 
will not include them here (Bdragon28 should just be able to apply them and 
push them out)

Right now, I have a full ppcle Linux userland (which can fully compile itself, 
so it's self-hosted), I will be making binary packages available soon (source 
is already available through the Void Linux project) so anyone with a ppc64le 
kernel with a couple of fixes (also available through Void) should be able to 
run a full 32-bit LE environment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92445

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


[PATCH] D92445: [PowerPC] Add powerpcle target.

2020-12-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Basic/Targets/PPC.h:358
   resetDataLayout("E-m:a-p:32:32-i64:64-n32");
+else if ((Triple.getArch() == llvm::Triple::ppcle))
+  resetDataLayout("e-m:e-p:32:32-i64:64-n32");

redundant `()`



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:971
   // PPC has no copy relocations and cannot use a plt entry as a symbol 
address.
-  llvm::Triple::ArchType Arch = TT.getArch();
-  if (Arch == llvm::Triple::ppc || Arch == llvm::Triple::ppc64 ||
-  Arch == llvm::Triple::ppc64le)
+  if (TT.isPPC())
 return false;

Drop this change.

The ppc32 code path was actually dead and I have deleted it about 2 weeks ago.



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:146
+  case llvm::Triple::ppcle:
+if (D.getVFS().exists(SysRoot + "/lib/powerpc-linux-gnu"))
+  return "powerpcle-linux-gnu";

Should it be powerpcle?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92445

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


[PATCH] D93453: [flang][driver] Add support for `-I`

2020-12-17 Thread Faris via Phabricator via cfe-commits
FarisRehman created this revision.
Herald added a reviewer: sscalpone.
Herald added a subscriber: dang.
FarisRehman requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add support for option -I in the Flang driver.
This will allow for included headers in other directories, as the default 
search path is currently the working folder.
The behaviour of this is consistent with the current F18 
 driver.

Summary of changes:

- Add SearchDirectoriesFromI to PreprocessorOptions, to be forwarded into the 
parser's searchDirectories


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93453

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp


Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -165,6 +165,10 @@
   opts.addMacroUndef(A->getValue());
 }
   }
+
+  // Add the ordered list of -I's.
+  for (const auto *A : args.filtered(clang::driver::options::OPT_I))
+opts.SearchDirectoriesFromI.emplace_back(A->getValue());
 }
 
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation &res,
@@ -237,10 +241,15 @@
   auto &fortranOptions = fortranOpts();
   const auto &preprocessorOptions = preprocessorOpts();
 
-  // These defaults are based on the defaults in f18/f18.cpp.
-  std::vector searchDirectories{"."s};
-  fortranOptions.searchDirectories = searchDirectories;
   fortranOptions.isFixedForm = false;
 
   collectMacroDefinitions(fortranOptions, preprocessorOptions);
+
+  // These defaults are based on the defaults in f18/f18.cpp.
+  std::vector searchDirectories{"."s};
+  for (const auto &searchDirectoryFromI :
+  preprocessorOptions.SearchDirectoriesFromI) {
+searchDirectories.emplace_back(searchDirectoryFromI);
+  }
+  fortranOptions.searchDirectories = searchDirectories;
 }
Index: flang/include/flang/Frontend/PreprocessorOptions.h
===
--- flang/include/flang/Frontend/PreprocessorOptions.h
+++ flang/include/flang/Frontend/PreprocessorOptions.h
@@ -10,6 +10,7 @@
 class PreprocessorOptions {
 public:
   std::vector> Macros;
+  std::vector SearchDirectoriesFromI;
 
 public:
   PreprocessorOptions() {}
Index: clang/lib/Driver/ToolChains/Flang.cpp
===
--- clang/lib/Driver/ToolChains/Flang.cpp
+++ clang/lib/Driver/ToolChains/Flang.cpp
@@ -72,6 +72,8 @@
   }
   Args.ClaimAllArgs(options::OPT_D);
 
+  Args.AddAllArgs(CmdArgs, options::OPT_I);
+
   if (Output.isFilename()) {
 CmdArgs.push_back("-o");
 CmdArgs.push_back(Output.getFilename());
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -661,7 +661,7 @@
 HelpText<"Restrict all prior -I flags to double-quoted inclusion and "
  "remove current directory from include path">;
 def I : JoinedOrSeparate<["-"], "I">, Group,
-Flags<[CC1Option,CC1AsOption]>, MetaVarName<"">,
+Flags<[CC1Option,CC1AsOption,FlangOption,FC1Option]>, MetaVarName<"">,
 HelpText<"Add directory to include search path. If there are multiple -I "
  "options, these directories are searched in the order they are "
  "given before the standard system directories are searched. "


Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -165,6 +165,10 @@
   opts.addMacroUndef(A->getValue());
 }
   }
+
+  // Add the ordered list of -I's.
+  for (const auto *A : args.filtered(clang::driver::options::OPT_I))
+opts.SearchDirectoriesFromI.emplace_back(A->getValue());
 }
 
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation &res,
@@ -237,10 +241,15 @@
   auto &fortranOptions = fortranOpts();
   const auto &preprocessorOptions = preprocessorOpts();
 
-  // These defaults are based on the defaults in f18/f18.cpp.
-  std::vector searchDirectories{"."s};
-  fortranOptions.searchDirectories = searchDirectories;
   fortranOptions.isFixedForm = false;
 
   collectMacroDefinitions(fortranOptions, preprocessorOptions);
+
+  // These defaults are based on the defaults in f18/f18.cpp.
+  std::vector searchDirectories{"."s};
+  for (const auto &searchDirectoryFromI :
+  preprocessorOptions.SearchDirectoriesFromI) {
+searchDirectories.emplace_back(searchDirectoryFromI);
+  }
+  fortranOptions.searchDirectories = searchDirectories;
 }
Index: flang/include/flang/Frontend/PreprocessorOptions.h

[PATCH] D93301: [flang][driver] Add support for `-c` and `-emit-obj`

2020-12-17 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski marked an inline comment as done.
awarzynski added a comment.

@clementval & @SouraVX - thank you for your comments! I will upload an updated 
version shortly.




Comment at: clang/include/clang/Driver/Options.td:4329
   HelpText<"Generate machine code, but discard output">;
-def emit_obj : Flag<["-"], "emit-obj">,
-  HelpText<"Emit native object files">;

SouraVX wrote:
> Please correct if I've misunderstood this change ?
> You're removing this option from here(`clang`) and  defining again at line 
> 4631 as a common option to both `clang` `flang` ? 
> +1 to that.
> However this seems out of the purview of this patch. Do you think having this 
> as a separate patch(with specific intent) would be good(For 
> tracking/isolating changes) ?
> Or the least you can do is convey this intent in this patch Summary too.
> I'm happy with either of those :)
> You're removing this option from here(clang) and defining again at line 4631 
> as a common option to both clang flang ? 
Correct :)

> However this seems out of the purview of this patch.
Not quite. Without this change you will get an error when using `-emit-obj`:
```
bin/flang-new -fc1 -emit-obj file.f90
error: unknown argument: '-emit-obj'
```
That's because it wouldn't be parsed here: 
https://github.com/llvm/llvm-project/blob/eba09a2db9eab46832cb7ec7ef0d2c227747772a/flang/lib/Frontend/CompilerInvocation.cpp#L166-L167
(note the definition of `includedFlagsBitmask`). 

I do agree that the Summary should be updated, thanks for pointing that out!



Comment at: clang/include/clang/Driver/Options.td:4629
 
-} // let Flags = [CC1Option]
+} // let Flags = [CC1Option, NoDriverOption]
+

clementval wrote:
> Is it intended to modify the SYCL options? 
This is just updating the comment (so it's just an nfc, SYCL options are not 
affected). 

This closing `}` corresponds to the opening `{` specified here:: 
https://github.com/llvm/llvm-project/blob/eba09a2db9eab46832cb7ec7ef0d2c227747772a/clang/include/clang/Driver/Options.td#L4040.
 So, currently we have this:

```
let Flags = [CC1Option, NoDriverOption] in {
// A lot of code HERE
} // let Flags = [CC1Option]
```

Instead it should be:
```
let Flags = [CC1Option, NoDriverOption] in {
// A lot of code HERE
} // let Flags = [CC1Option, NoDriverOption]
```

I was mislead by this comment while working on this patch, so to me it seemed 
like a _related_ change :) But it isn't and should be extracted into a separate 
patch: 
https://github.com/llvm/llvm-project/commit/7f19712a6a9e65bdc9a9843ea488030bc12f3acc.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:104
   // TODO:
   // case clang::driver::options::OPT_emit_obj:
   // case calng::driver::options::OPT_emit_llvm:

clementval wrote:
> Should you remove this line since you have the case for it?
Yes, thanks for pointing out!



Comment at: flang/test/Flang-Driver/code-gen.f90:15
+
+! CHECK: code-generation is not available yet

SouraVX wrote:
> Since it's an `error` NOT a string(or similar) generated, I would rather have 
> `ERROR` as a string check. This way it is self-evident for end reader.
> Sort of:
> ```! ERROR: code-generation is not available yet```
> 
Yeah, `ERROR` would be better. I wish that we had a prospect of Clang's 
`-verify`. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93301

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


[PATCH] D93301: [flang][driver] Add support for `-c` and `-emit-obj`

2020-12-17 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski updated this revision to Diff 312457.
awarzynski added a comment.

Address PR comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93301

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/code-gen.f90
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/emit-obj.f90
  flang/test/Flang-Driver/phases.f90

Index: flang/test/Flang-Driver/phases.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/phases.f90
@@ -0,0 +1,20 @@
+! RUN: %flang-new -E -ccc-print-phases %s 2>&1 | FileCheck %s --check-prefix=PP
+! RUN: %flang-new -fsyntax-only -ccc-print-phases %s 2>&1 | FileCheck %s --check-prefix=COMPILE
+! RUN: %flang-new -c -ccc-print-phases %s 2>&1 | FileCheck %s --check-prefix=EMIT_OBJ
+
+! REQUIRES: new-flang-driver
+
+! This test verifies the phase control in Flang compiler driver.
+
+! PP: +- 0: input, "{{.*}}phases.f90", f95-cpp-input
+! PP-NEXT: 1: preprocessor, {0}, f95
+
+! COMPILE: +- 0: input, "{{.*}}phases.f90", f95-cpp-input
+! COMPILE-NEXT: 1: preprocessor, {0}, f95
+! COMPILE-NEXT: 2: compiler, {1}, none
+
+! EMIT_OBJ: +- 0: input, "{{.*}}phases.f90", f95-cpp-input
+! EMIT_OBJ-NEXT: 1: preprocessor, {0}, f95
+! EMIT_OBJ-NEXT: 2: compiler, {1}, ir
+! EMIT_OBJ-NEXT: +- 3: backend, {2}, assembler
+! EMIT_OBJ-NEXT: 4: assembler, {3}, object
Index: flang/test/Flang-Driver/emit-obj.f90
===
--- flang/test/Flang-Driver/emit-obj.f90
+++ /dev/null
@@ -1,14 +0,0 @@
-! RUN: not %flang-new  %s 2>&1 | FileCheck %s --check-prefix=ERROR
-! RUN: not %flang-new  -emit-obj %s 2>&1 | FileCheck %s --check-prefix=ERROR
-! RUN: not %flang-new  -fc1 -emit-obj %s 2>&1 | FileCheck %s --check-prefix=ERROR-FC1
-
-! REQUIRES: new-flang-driver
-
-! By default (e.g. when no options like `-E` are passed) flang-new
-! creates a job that corresponds to `-emit-obj`. This option/action is
-! not yet supported. Verify that this is correctly reported as error.
-
-! ERROR: error: unknown argument: '-triple'
-! ERROR: error: unknown argument: '-emit-obj'
-
-! ERROR-FC1: error: unknown argument: '-emit-obj'
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -19,6 +19,7 @@
 ! HELP-EMPTY:
 ! HELP-NEXT:OPTIONS:
 ! HELP-NEXT: -###   Print (but do not run) the commands to run for this compilation
+! HELP-NEXT: -c Only run preprocess, compile, and assemble steps
 ! HELP-NEXT: -E Only run the preprocessor
 ! HELP-NEXT: -fcolor-diagnosticsEnable colors in diagnostics
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
@@ -32,6 +33,7 @@
 ! HELP-FC1:USAGE: flang-new
 ! HELP-FC1-EMPTY:
 ! HELP-FC1-NEXT:OPTIONS:
+! HELP-FC1-NEXT: -emit-obj Emit native object files
 ! HELP-FC1-NEXT: -EOnly run the preprocessor
 ! HELP-FC1-NEXT: -help Display available options
 ! HELP-FC1-NEXT: -o  Write output to 
Index: flang/test/Flang-Driver/driver-help-hidden.f90
===
--- flang/test/Flang-Driver/driver-help-hidden.f90
+++ flang/test/Flang-Driver/driver-help-hidden.f90
@@ -19,6 +19,7 @@
 ! CHECK-EMPTY:
 ! CHECK-NEXT:OPTIONS:
 ! CHECK-NEXT: -###  Print (but do not run) the commands to run for this compilation
+! CHECK-NEXT: -cOnly run preprocess, compile, and assemble steps
 ! CHECK-NEXT: -EOnly run the preprocessor
 ! CHECK-NEXT: -fcolor-diagnosticsEnable colors in diagnostics
 ! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
Index: flang/test/Flang-Driver/code-gen.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/code-gen.f90
@@ -0,0 +1,15 @@
+! RUN: not %flang-new %s 2>&1 | FileCheck %s --check-prefix=ERROR
+! RUN: not %flang-new -c %s 2>&1 | FileCheck %s --check-prefix=ERROR
+! RUN: not %flang-new -emit-obj %s 2>&1 | FileCheck %s --check-prefix=ERROR
+! RUN: not %flang-new -fc1 -emit-obj %s 2>&1 | FileCheck %s --check-prefix=ERROR
+
+! REQUIRES: new-flang-driver
+
+! Although code-generation is not yet available, we do have frontend actions
+! that correspond to `-c` and `-emit-obj`. For now these actions are just a
+! placeholder and running them leads to a driver error. This test makes sure
+! that these actions are indeed run (rather than `-c` or `-emit-obj` being
+! rejected ea

[PATCH] D92800: [Clang] Make nomerge attribute a function attribute as well as a statement attribute.

2020-12-17 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! Thank you for this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92800

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


[PATCH] D91776: [ARM][AAarch64] Initial command-line support for v8.7-A

2020-12-17 Thread Lucas Prates via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc4d851b07903: [ARM][AAarch64] Initial command-line support 
for v8.7-A (authored by pratlucas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91776

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/aarch64-ls64.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/AArch64TargetParser.h
  llvm/lib/Support/AArch64TargetParser.cpp
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -1103,6 +1103,8 @@
   ARMBuildAttrs::CPUArch::v8_A));
   EXPECT_TRUE(testAArch64Arch("armv8.6-a", "generic", "v8.6a",
   ARMBuildAttrs::CPUArch::v8_A));
+  EXPECT_TRUE(testAArch64Arch("armv8.7-a", "generic", "v8.7a",
+  ARMBuildAttrs::CPUArch::v8_A));
 }
 
 bool testAArch64Extension(StringRef CPUName, AArch64::ArchKind AK,
Index: llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
===
--- llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -5354,6 +5354,7 @@
 case AArch64::ArchKind::ARMV8_4A:
 case AArch64::ArchKind::ARMV8_5A:
 case AArch64::ArchKind::ARMV8_6A:
+case AArch64::ArchKind::ARMV8_7A:
 case AArch64::ArchKind::ARMV8R:
   RequestedExtensions.push_back("sm4");
   RequestedExtensions.push_back("sha3");
@@ -5375,6 +5376,7 @@
 case AArch64::ArchKind::ARMV8_4A:
 case AArch64::ArchKind::ARMV8_5A:
 case AArch64::ArchKind::ARMV8_6A:
+case AArch64::ArchKind::ARMV8_7A:
   RequestedExtensions.push_back("nosm4");
   RequestedExtensions.push_back("nosha3");
   RequestedExtensions.push_back("nosha2");
Index: llvm/lib/Support/ARMTargetParser.cpp
===
--- llvm/lib/Support/ARMTargetParser.cpp
+++ llvm/lib/Support/ARMTargetParser.cpp
@@ -154,6 +154,7 @@
   .Case("v8.4a", "v8.4-a")
   .Case("v8.5a", "v8.5-a")
   .Case("v8.6a", "v8.6-a")
+  .Case("v8.7a", "v8.7-a")
   .Case("v8r", "v8-r")
   .Case("v8m.base", "v8-m.base")
   .Case("v8m.main", "v8-m.main")
Index: llvm/lib/Support/AArch64TargetParser.cpp
===
--- llvm/lib/Support/AArch64TargetParser.cpp
+++ llvm/lib/Support/AArch64TargetParser.cpp
@@ -118,6 +118,8 @@
 Features.push_back("+v8.5a");
   if (AK == AArch64::ArchKind::ARMV8_6A)
 Features.push_back("+v8.6a");
+  if (AK == AArch64::ArchKind::ARMV8_7A)
+Features.push_back("+v8.7a");
   if(AK == AArch64::ArchKind::ARMV8R)
 Features.push_back("+v8r");
 
Index: llvm/include/llvm/Support/AArch64TargetParser.h
===
--- llvm/include/llvm/Support/AArch64TargetParser.h
+++ llvm/include/llvm/Support/AArch64TargetParser.h
@@ -62,6 +62,7 @@
   AEK_I8MM =1 << 30,
   AEK_F32MM =   1ULL << 31,
   AEK_F64MM =   1ULL << 32,
+  AEK_LS64 =1ULL << 33,
 };
 
 enum class ArchKind {
Index: llvm/include/llvm/Support/AArch64TargetParser.def
===
--- llvm/include/llvm/Support/AArch64TargetParser.def
+++ llvm/include/llvm/Support/AArch64TargetParser.def
@@ -51,6 +51,13 @@
   AArch64::AEK_RDM  | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
   AArch64::AEK_SM4  | AArch64::AEK_SHA3 | AArch64::AEK_BF16|
   AArch64::AEK_SHA2 | AArch64::AEK_AES  | AArch64::AEK_I8MM))
+AARCH64_ARCH("armv8.7-a", ARMV8_7A, "8.7-A", "v8.7a",
+ ARMBuildAttrs::CPUArch::v8_A, FK_CRYPTO_NEON_FP_ARMV8,
+ (AArch64::AEK_CRC | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE |
+  AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
+  AArch64::AEK_SM4 | AArch64::AEK_SHA3 | AArch64::AEK_BF16 |
+  AArch64::AEK_SHA2 | AArch64::AEK_AES | AArch64::AEK_I8MM))
 // For v8-R, we do not enable crypto and align with GCC that enables a more
 // minimal set of optional architecture extensions.
 AARCH64_ARCH("armv8-r", ARMV8R, "8-R", "v8r",
@@ -99,6 +106,7 @@
 AARCH64_ARCH_EXT_NAME("f32mm",AArch64::AEK_F32MM,   "+f32mm", "-f32mm")
 AARCH64_ARCH_EXT_NAME("f64mm",AArch64::AEK

[clang] c4d851b - [ARM][AAarch64] Initial command-line support for v8.7-A

2020-12-17 Thread Lucas Prates via cfe-commits

Author: Lucas Prates
Date: 2020-12-17T13:47:28Z
New Revision: c4d851b079037e9b7dd3f8613dd1c8a4f3db99fa

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

LOG: [ARM][AAarch64] Initial command-line support for v8.7-A

This introduces command-line support for the 'armv8.7-a' architecture name
(and an alias without the '-', as usual), and for the 'ls64' extension name.

Based on patches written by Simon Tatham.

Reviewed By: ostannard

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

Added: 
clang/test/Driver/aarch64-ls64.c

Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AArch64.h
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Driver/aarch64-cpus.c
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/include/llvm/Support/AArch64TargetParser.h
llvm/lib/Support/AArch64TargetParser.cpp
llvm/lib/Support/ARMTargetParser.cpp
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index c8162dd55220..c1abe8e9f75b 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -196,6 +196,12 @@ void AArch64TargetInfo::getTargetDefinesARMV86A(const 
LangOptions &Opts,
   getTargetDefinesARMV85A(Opts, Builder);
 }
 
+void AArch64TargetInfo::getTargetDefinesARMV87A(const LangOptions &Opts,
+MacroBuilder &Builder) const {
+  // Also include the Armv8.6 defines
+  getTargetDefinesARMV86A(Opts, Builder);
+}
+
 void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
  MacroBuilder &Builder) const {
   // Target identification.
@@ -371,6 +377,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case llvm::AArch64::ArchKind::ARMV8_6A:
 getTargetDefinesARMV86A(Opts, Builder);
 break;
+  case llvm::AArch64::ArchKind::ARMV8_7A:
+getTargetDefinesARMV87A(Opts, Builder);
+break;
   }
 
   // All of the __sync_(bool|val)_compare_and_swap_(1|2|4|8) builtins work.
@@ -411,6 +420,7 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasFP16FML = false;
   HasMTE = false;
   HasTME = false;
+  HasLS64 = false;
   HasMatMul = false;
   HasBFloat16 = false;
   HasSVE2 = false;
@@ -486,6 +496,8 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   ArchKind = llvm::AArch64::ArchKind::ARMV8_5A;
 if (Feature == "+v8.6a")
   ArchKind = llvm::AArch64::ArchKind::ARMV8_6A;
+if (Feature == "+v8.7a")
+  ArchKind = llvm::AArch64::ArchKind::ARMV8_7A;
 if (Feature == "+v8r")
   ArchKind = llvm::AArch64::ArchKind::ARMV8R;
 if (Feature == "+fullfp16")
@@ -504,6 +516,8 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasBFloat16 = true;
 if (Feature == "+lse")
   HasLSE = true;
+if (Feature == "+ls64")
+  HasLS64 = true;
   }
 
   setDataLayout();

diff  --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index a70abb7bfd90..bd576680077e 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -36,6 +36,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   bool HasFP16FML;
   bool HasMTE;
   bool HasTME;
+  bool HasLS64;
   bool HasMatMul;
   bool HasSVE2;
   bool HasSVE2AES;
@@ -81,6 +82,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
MacroBuilder &Builder) const;
   void getTargetDefinesARMV86A(const LangOptions &Opts,
MacroBuilder &Builder) const;
+  void getTargetDefinesARMV87A(const LangOptions &Opts,
+   MacroBuilder &Builder) const;
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override;
 

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 13e4cac292d0..a5e632fd8cdb 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -79,9 +79,10 @@ static bool DecodeAArch64Features(const Driver &D, StringRef 
text,
 else
   return false;
 
-// +sve implies +f32mm if the base architecture is v8.6A
+// +sve implies +f32mm if the base architecture is v8.6A or v8.7A
 // it isn't the case in general that sve implies both f64mm and f32mm
-if ((ArchKind == llvm::AArch64::ArchKind::ARMV8_6A) && Feature == "sve")
+if ((ArchKind == llvm::AArch64::ArchKind::ARMV8_6A ||
+ ArchKind == llvm::AArch64::ArchKind::ARMV8_7A) && Feature ==

[PATCH] D93231: [ARM] Adding v8.7-A command-line support for the ARM target

2020-12-17 Thread Lucas Prates via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc5046ebdf6e4: [ARM] Adding v8.7-A command-line support for 
the ARM target (authored by pratlucas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93231

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Driver/arm-cortex-cpus.c
  clang/test/Preprocessor/arm-target-features.c
  llvm/include/llvm/ADT/Triple.h
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/lib/Support/Triple.cpp
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMPredicates.td
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -26,9 +26,9 @@
 "armv7e-m","armv7em",  "armv8-a", "armv8","armv8a",
 "armv8l",  "armv8.1-a","armv8.1a","armv8.2-a","armv8.2a",
 "armv8.3-a",   "armv8.3a", "armv8.4-a",   "armv8.4a", "armv8.5-a",
-"armv8.5a", "armv8.6-a",   "armv8.6a", "armv8-r", "armv8r",
-"armv8-m.base", "armv8m.base", "armv8-m.main", "armv8m.main", "iwmmxt",
-"iwmmxt2",  "xscale",  "armv8.1-m.main",
+"armv8.5a","armv8.6-a","armv8.6a","armv8.7-a","armv8.7a",
+"armv8-r", "armv8r",   "armv8-m.base","armv8m.base",  "armv8-m.main",
+"armv8m.main", "iwmmxt",   "iwmmxt2", "xscale",   "armv8.1-m.main",
 };
 
 bool testARMCPU(StringRef CPUName, StringRef ExpectedArch,
@@ -443,6 +443,9 @@
   EXPECT_TRUE(
   testARMArch("armv8.6-a", "generic", "v8.6a",
   ARMBuildAttrs::CPUArch::v8_A));
+  EXPECT_TRUE(
+  testARMArch("armv8.7-a", "generic", "v8.7a",
+  ARMBuildAttrs::CPUArch::v8_A));
   EXPECT_TRUE(
   testARMArch("armv8-r", "cortex-r52", "v8r",
   ARMBuildAttrs::CPUArch::v8_R));
@@ -710,7 +713,8 @@
   "v7",   "v7a","v7ve",  "v7hl",   "v7l",   "v7-r",   "v7r",   "v7-m",
   "v7m",  "v7k","v7s",   "v7e-m",  "v7em",  "v8-a",   "v8","v8a",
   "v8l",  "v8.1-a", "v8.1a", "v8.2-a", "v8.2a", "v8.3-a", "v8.3a", "v8.4-a",
-  "v8.4a", "v8.5-a","v8.5a", "v8.6-a", "v8.6a", "v8-r",   "v8m.base", "v8m.main", "v8.1m.main"
+  "v8.4a", "v8.5-a","v8.5a", "v8.6-a", "v8.6a", "v8.7-a", "v8.7a", "v8-r",
+  "v8m.base", "v8m.main", "v8.1m.main"
   };
 
   for (unsigned i = 0; i < array_lengthof(Arch); i++) {
@@ -776,6 +780,7 @@
 case ARM::ArchKind::ARMV8_4A:
 case ARM::ArchKind::ARMV8_5A:
 case ARM::ArchKind::ARMV8_6A:
+case ARM::ArchKind::ARMV8_7A:
   EXPECT_EQ(ARM::ProfileKind::A, ARM::parseArchProfile(ARMArch[i]));
   break;
 default:
Index: llvm/lib/Target/ARM/ARMPredicates.td
===
--- llvm/lib/Target/ARM/ARMPredicates.td
+++ llvm/lib/Target/ARM/ARMPredicates.td
@@ -77,6 +77,8 @@
  AssemblerPredicate<(all_of HasV8_5aOps), "armv8.5a">;
 def HasV8_6a : Predicate<"Subtarget->hasV8_6aOps()">,
  AssemblerPredicate<(all_of HasV8_6aOps), "armv8.6a">;
+def HasV8_7a : Predicate<"Subtarget->hasV8_7aOps()">,
+ AssemblerPredicate<(all_of HasV8_7aOps), "armv8.7a">;
 def NoVFP: Predicate<"!Subtarget->hasVFP2Base()">;
 def HasVFP2  : Predicate<"Subtarget->hasVFP2Base()">,
  AssemblerPredicate<(all_of FeatureVFP2_SP), "VFP2">;
Index: llvm/lib/Target/ARM/ARM.td
===
--- llvm/lib/Target/ARM/ARM.td
+++ llvm/lib/Target/ARM/ARM.td
@@ -535,6 +535,10 @@
[HasV8_5aOps, FeatureBF16,
 FeatureMatMulInt8]>;
 
+def HasV8_7aOps   : SubtargetFeature<"v8.7a", "HasV8_7aOps", "true",
+   "Support ARM v8.7a instructions",
+   [HasV8_6aOps]>;
+
 def HasV8_1MMainlineOps : SubtargetFeature<
"v8.1m.main", "HasV8_1MMainlineOps", "true",
"Support ARM v8-1M Mainline instructions",
@@ -831,6 +835,19 @@
FeatureCRC,
FeatureRAS,
FeatureDotProd]>;
+def ARMv87a   : Architecture<"armv8.7-a", "ARMv86a",  [HasV8_7aOps,
+   FeatureAClass,
+   FeatureDB,
+   FeatureFPARMv8,
+   

[clang] c5046eb - [ARM] Adding v8.7-A command-line support for the ARM target

2020-12-17 Thread Lucas Prates via cfe-commits

Author: Lucas Prates
Date: 2020-12-17T13:48:54Z
New Revision: c5046ebdf6e4be9300677c538ecaa61648c31248

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

LOG: [ARM] Adding v8.7-A command-line support for the ARM target

This extends the command-line support for the 'armv8.7-a' architecture
name to the ARM target.

Based on a patch written by Momchil Velikov.

Reviewed By: ostannard

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

Added: 


Modified: 
clang/lib/Basic/Targets/ARM.cpp
clang/test/Driver/arm-cortex-cpus.c
clang/test/Preprocessor/arm-target-features.c
llvm/include/llvm/ADT/Triple.h
llvm/include/llvm/Support/ARMTargetParser.def
llvm/lib/Support/ARMTargetParser.cpp
llvm/lib/Support/Triple.cpp
llvm/lib/Target/ARM/ARM.td
llvm/lib/Target/ARM/ARMPredicates.td
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 21cfe0107bbb..a2c96ad12a76 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -208,6 +208,8 @@ StringRef ARMTargetInfo::getCPUAttr() const {
 return "8_5A";
   case llvm::ARM::ArchKind::ARMV8_6A:
 return "8_6A";
+  case llvm::ARM::ArchKind::ARMV8_7A:
+return "8_7A";
   case llvm::ARM::ArchKind::ARMV8MBaseline:
 return "8M_BASE";
   case llvm::ARM::ArchKind::ARMV8MMainline:

diff  --git a/clang/test/Driver/arm-cortex-cpus.c 
b/clang/test/Driver/arm-cortex-cpus.c
index a312ccfda5a1..f1ca801c4ddb 100644
--- a/clang/test/Driver/arm-cortex-cpus.c
+++ b/clang/test/Driver/arm-cortex-cpus.c
@@ -352,6 +352,23 @@
 // RUN: %clang -target arm -march=armebv8.6-a -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-V86A %s
 // CHECK-BE-V86A: "-cc1"{{.*}} "-triple" "armebv8.6{{.*}}" "-target-cpu" 
"generic"
 
+// RUN: %clang -target armv8.7a -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V87A %s
+// RUN: %clang -target arm -march=armv8.7a -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V87A %s
+// RUN: %clang -target arm -march=armv8.7-a -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V87A %s
+// RUN: %clang -target arm -march=armv8.7a -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-V87A %s
+// RUN: %clang -target armv8.7a -mlittle-endian -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V87A %s
+// RUN: %clang -target arm -march=armv8.7a -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-V87A %s
+// RUN: %clang -target arm -mlittle-endian -march=armv8.7-a -mlittle-endian 
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V87A %s
+// CHECK-V87A: "-cc1"{{.*}} "-triple" "armv8.7{{.*}}" "-target-cpu" "generic"
+
+// RUN: %clang -target armebv8.7a -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-V87A %s
+// RUN: %clang -target armv8.7a -mbig-endian -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-V87A %s
+// RUN: %clang -target armeb -march=armebv8.7a -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-V87A %s
+// RUN: %clang -target armeb -march=armebv8.7-a -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-V87A %s
+// RUN: %clang -target arm -march=armebv8.7a -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-V87A %s
+// RUN: %clang -target arm -march=armebv8.7-a -mbig-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BE-V87A %s
+// CHECK-BE-V87A: "-cc1"{{.*}} "-triple" "armebv8.7{{.*}}" "-target-cpu" 
"generic"
+
 // Once we have CPUs with optional v8.2-A FP16, we will need a way to turn it
 // on and off. Cortex-A53 is a placeholder for now.
 // RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+fp16 -### -c %s 2>&1 
| FileCheck --check-prefix CHECK-CORTEX-A53-FP16 %s

diff  --git a/clang/test/Preprocessor/arm-target-features.c 
b/clang/test/Preprocessor/arm-target-features.c
index 5eaffa1c372c..9f375162e6ab 100644
--- a/clang/test/Preprocessor/arm-target-features.c
+++ b/clang/test/Preprocessor/arm-target-features.c
@@ -849,6 +849,11 @@
 // CHECK-V86A: #define __ARM_ARCH_8_6A__ 1
 // CHECK-V86A: #define __ARM_ARCH_PROFILE 'A'
 
+// RUN: %clang -target armv8.7a-none-none-eabi -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=CHECK-V87A %s
+// CHECK-V87A: #define __ARM_ARCH 8
+// CHECK-V87A: #define __ARM_ARCH_8_7A__ 1
+// CHECK-V87A: #define __ARM_ARCH_PROFILE 'A'
+
 // RUN: %clang -target arm-none-none-eabi -march=armv7-m -mfpu=softvfp -x c -E 
-dM %s -o - | FileCheck --check-prefix=CHECK-SOFTVFP %s
 // CHECK-SOFTVFP-NOT: #define __ARM_FP 0x
 

diff  --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index 13a35857512a..6e2957f3c32b 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/include/llvm/ADT/Triple.h
@@ -104,6 +104,7 @@ class Triple {
   enum SubArchType {
 NoSubArch,
 
+

[PATCH] D93110: [analyzer] Implement a first version of suppressions via attributes

2020-12-17 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2366
   let Args = [VariadicStringArgument<"DiagnosticIdentifiers">];
   let Documentation = [SuppressDocs];
 }

aaron.ballman wrote:
> The documentation will need to be updated for this. I have no idea if that 
> may be a bit awkward because we're documenting two different suppression 
> mechanisms (that do roughly the same thing).
I decided not to change it yet because I was not sure that this is going to be 
the final solution.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4567
 static void handleSuppressAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
-  if (!checkAttributeAtLeastNumArgs(S, AL, 1))
+  if (AL.isCXX11Attribute() && !checkAttributeAtLeastNumArgs(S, AL, 1))
 return;

aaron.ballman wrote:
> The behavior here will be that `[[gsl::suppress]]` in C++11 mode and 
> `[[clang::suppress]]` in C++11 mode require at least one argument, while 
> `[[clang::supress]]` in C2x mode and `__attribute__((suppress))` in all 
> language modes allow any number of arguments (including zero). That doesn't 
> seem like what you want. I think you need something more like:
> ```
> // The [[gsl::suppress]] spelling requires at least one argument, but the GNU
> // and [[clang::suppress]] spellings do not require any arguments.
> if (AL.hasScope() && AL.getScopeName()->isStr("gsl") &&
> !checkAttributeAtLeastNumArgs(S, AL, 1))
>   return;
> ```
That's much better, thanks!



Comment at: clang/lib/Sema/SemaStmtAttr.cpp:56
 SourceRange Range) {
-  if (A.getNumArgs() < 1) {
+  if (A.isCXX11Attribute() && A.getNumArgs() < 1) {
 S.Diag(A.getLoc(), diag::err_attribute_too_few_arguments) << A << 1;

aaron.ballman wrote:
> Same issue here.
> 
> (In other news, it looks like this attribute could stand to be updated to be 
> a `DeclOrStmtAttr` once D92800 lands -- that's not your problem to solve, 
> more just an observation.)
This is actually something that I wanted to ask out of curiosity, how it works 
as a declaration attribute if it's declared as `StmtAttr`



Comment at: clang/lib/Sema/SemaStmtAttr.cpp:69
 // FIXME: Warn if the rule name is unknown. This is tricky because only
-// clang-tidy knows about available rules.
+// clang-tidy and static analyzer know about available rules.
 DiagnosticIdentifiers.push_back(RuleName);

aaron.ballman wrote:
> 
Sure



Comment at: clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2885
+
+  if (It != Attrs.end()) {
+return cast(*It);

aaron.ballman wrote:
> The coding standard has us elide braces on single-line ifs (same comment 
> applies elsewhere).
Sure!



Comment at: clang/lib/StaticAnalyzer/Core/BugReporter.cpp:2897
+   ASTContext &AC) {
+  PathDiagnosticLocation Location = BR.getLocation();
+

xazax.hun wrote:
> What will this location return? In case of a leak warning, we might get a 
> different instance of the same warning on separate paths. We usually pick the 
> shortest path, but it can change when we slightly alter the source code. 
> Maybe we want the user to put the suppression at the uniqueing location when 
> such location exist? (The allocation in case of a leak warnings.) I think 
> that would result in a better user experience and more robust suppression 
> mechanism. An open question is how to educate the user about the correct way 
> of suppression. Should we emit a suppress location to the user explicitly?
Ah, leaks.  I thought about those, and probably should've mentioned it here.
I think it is counter-intuitive to have separate locations for warnings 
themselves and for suppressions.  Because this would be the first place where 
the user will try to put suppression.  It is not obvious what to do with 
locations when we report that something didn't happen when it should've.  But 
this group of checkers is relatively small, usually we do have a precise 
location where something bad happens.  So, I believe that leaks should be 
addressed separately and not affect design for suppressions for the vast 
majority of checkers.
Speaking of leaks, `RetainReleaseChecker` reports leaks on the allocation and 
they can be suppressed that way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93110

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


[clang-tools-extra] 64badec - [clang-tidy][NFC] Reduce copies of Intrusive..FileSystem

2020-12-17 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-12-17T14:09:08Z
New Revision: 64badecd447f2358812a2e747b2683d34071f5a5

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

LOG: [clang-tidy][NFC] Reduce copies of Intrusive..FileSystem

Swapped a few instances where a move is more optimal or the target doesn't need 
to hold a reference.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index b5f2a1c0fbdb..633655e5e24a 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -101,7 +101,8 @@ class ErrorReporter {
 public:
   ErrorReporter(ClangTidyContext &Context, bool ApplyFixes,
 llvm::IntrusiveRefCntPtr BaseFS)
-  : Files(FileSystemOptions(), BaseFS), DiagOpts(new DiagnosticOptions()),
+  : Files(FileSystemOptions(), std::move(BaseFS)),
+DiagOpts(new DiagnosticOptions()),
 DiagPrinter(new TextDiagnosticPrinter(llvm::outs(), &*DiagOpts)),
 Diags(IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts,
   DiagPrinter),
@@ -319,7 +320,7 @@ class ClangTidyASTConsumer : public MultiplexConsumer {
 ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
 ClangTidyContext &Context,
 IntrusiveRefCntPtr OverlayFS)
-: Context(Context), OverlayFS(OverlayFS),
+: Context(Context), OverlayFS(std::move(OverlayFS)),
   CheckFactories(new ClangTidyCheckFactories) {
   for (ClangTidyModuleRegistry::entry E : ClangTidyModuleRegistry::entries()) {
 std::unique_ptr Module = E.instantiate();
@@ -328,15 +329,16 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
 }
 
 #if CLANG_TIDY_ENABLE_STATIC_ANALYZER
-static void setStaticAnalyzerCheckerOpts(const ClangTidyOptions &Opts,
- AnalyzerOptionsRef AnalyzerOptions) {
+static void
+setStaticAnalyzerCheckerOpts(const ClangTidyOptions &Opts,
+ clang::AnalyzerOptions &AnalyzerOptions) {
   StringRef AnalyzerPrefix(AnalyzerCheckNamePrefix);
   for (const auto &Opt : Opts.CheckOptions) {
 StringRef OptName(Opt.getKey());
 if (!OptName.consume_front(AnalyzerPrefix))
   continue;
 // Analyzer options are always local options so we can ignore priority.
-AnalyzerOptions->Config[OptName] = Opt.getValue().Value;
+AnalyzerOptions.Config[OptName] = Opt.getValue().Value;
   }
 }
 
@@ -432,7 +434,7 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
   AnalyzerOptions->CheckersAndPackages = getAnalyzerCheckersAndPackages(
   Context, Context.canEnableAnalyzerAlphaCheckers());
   if (!AnalyzerOptions->CheckersAndPackages.empty()) {
-setStaticAnalyzerCheckerOpts(Context.getOptions(), AnalyzerOptions);
+setStaticAnalyzerCheckerOpts(Context.getOptions(), *AnalyzerOptions);
 AnalyzerOptions->AnalysisStoreOpt = RegionStoreModel;
 AnalyzerOptions->AnalysisDiagOpt = PD_NONE;
 AnalyzerOptions->AnalyzeNestedBlocks = true;
@@ -539,7 +541,7 @@ runClangTidy(clang::tidy::ClangTidyContext &Context,
   public:
 ActionFactory(ClangTidyContext &Context,
   IntrusiveRefCntPtr BaseFS)
-: ConsumerFactory(Context, BaseFS) {}
+: ConsumerFactory(Context, std::move(BaseFS)) {}
 std::unique_ptr create() override {
   return std::make_unique(&ConsumerFactory);
 }
@@ -570,7 +572,7 @@ runClangTidy(clang::tidy::ClangTidyContext &Context,
 ClangTidyASTConsumerFactory ConsumerFactory;
   };
 
-  ActionFactory Factory(Context, BaseFS);
+  ActionFactory Factory(Context, std::move(BaseFS));
   Tool.run(&Factory);
   return DiagConsumer.take();
 }
@@ -579,7 +581,7 @@ void handleErrors(llvm::ArrayRef Errors,
   ClangTidyContext &Context, bool Fix,
   unsigned &WarningsAsErrorsCount,
   llvm::IntrusiveRefCntPtr BaseFS) {
-  ErrorReporter Reporter(Context, Fix, BaseFS);
+  ErrorReporter Reporter(Context, Fix, std::move(BaseFS));
   llvm::vfs::FileSystem &FileSystem =
   Reporter.getSourceManager().getFileManager().getVirtualFileSystem();
   auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();

diff  --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp 
b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index 2748fd9f74a5..2466b647c68c 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -393,7 +393,7 @@ int clangTidyMain(int argc, const char **argv) {
 getVfsFromFile(VfsOverlay, BaseFS);
 if (!VfsFromFile)
   return 1;
-BaseFS->pushOverlay(VfsFromFile);
+BaseFS->pushOv

[PATCH] D78938: Make LLVM build in C++20 mode

2020-12-17 Thread Nuno Lopes via Phabricator via cfe-commits
nlopes added a comment.

In D78938#2459973 , @RKSimon wrote:

> @BRevzin @nlopes This is causing MSVC build failure please can you take a 
> look?
>
>   E:\llvm\llvm-project\llvm\include\llvm/DebugInfo/DWARF/DWARFDie.h(405): 
> note: see declaration of 'std::reverse_iterator'
>   E:\llvm\llvm-project\llvm\lib\DWARFLinker\DWARFLinker.cpp(383): note: see 
> reference to function template instantiation 'bool std::operator 
> !=(const 
> std::reverse_iterator &,const 
> std::reverse_iterator &)' being compiled
>   C:\Program Files (x86)\Microsoft Visual 
> Studio\2019\Professional\VC\Tools\MSVC\14.28.29333\include\xutility(2086): 
> error C2039: '_Get_current': is not a member of 
> 'std::reverse_iterator'
>   E:\llvm\llvm-project\llvm\include\llvm/DebugInfo/DWARF/DWARFDie.h(405): 
> note: see declaration of 'std::reverse_iterator'

Just saw that you fixed it already. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78938

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


[PATCH] D93110: [analyzer] Implement a first version of suppressions via attributes

2020-12-17 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D93110#2458613 , @aaron.ballman 
wrote:

> Have you explored how this attribute will work with clang frontend 
> diagnostics or clang-tidy diagnostics?

Actually, this attribute is not used anywhere in the codebase (even in 
`clang-tidy`!).  I think that it can be used for warning suppressions as well, 
it is more comfortable than pragmas IMO.  However, I think that the problem of 
false positive or, for that matter, suppressions is much more visible with 
static analysis tools.

> One usability concern I have with adding [[clang::suppress]] is that users 
> are going to want to use it to suppress all the various kinds of diagnostics 
> and not just clang static analyzer warnings.

Documentation will explicitly state that this mechanism is for the clang static 
analyzer and if users would like to use it for others things as well, that 
would prove that it is a good approach and can be fully supported in other 
parts of Clang.

Additionally, I was thinking about third parties developing their own static 
analysis tools using Clang as a parser for C/C++/Obj-C.  They would probably 
also like to use this attribute.  This is one reason why we probably shouldn't 
complain about unknown identifiers used with this attribute.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93110

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


[PATCH] D93458: clang-cl: Remove /Zd flag

2020-12-17 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: aeubanks.
Herald added a subscriber: dang.
thakis requested review of this revision.

cl.exe doesn't understand Zd (in either MSVC 2017 or 2019), so neiter
should we. It used to do the same as `-gline-tables-only` which is
exposed as clang-cl flag as well, so if you want this behavior, use
`gline-tables-only`. That makes it clear that it's a clang-cl-only flag
that won't work with cl.exe.

Motivated by the discussion in D92958 .


https://reviews.llvm.org/D93458

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -538,10 +538,6 @@
 // Z7: "-gcodeview"
 // Z7: "-debug-info-kind=limited"
 
-// RUN: %clang_cl /Zd /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7GMLT %s
-// Z7GMLT: "-gcodeview"
-// Z7GMLT: "-debug-info-kind=line-tables-only"
-
 // RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck 
-check-prefix=ZGMLT %s
 // ZGMLT: "-gcodeview"
 // ZGMLT: "-debug-info-kind=line-tables-only"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -382,8 +382,7 @@
 
   CmdArgs.push_back("-nologo");
 
-  if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7,
-  options::OPT__SLASH_Zd))
+  if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))
 CmdArgs.push_back("-debug");
 
   // Pass on /Brepro if it was passed to the compiler.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6801,10 +6801,9 @@
 CmdArgs.push_back(Args.MakeArgString(Twine(LangOptions::SSPStrong)));
   }
 
-  // Emit CodeView if -Z7, -Zd, or -gline-tables-only are present.
-  if (Arg *DebugInfoArg =
-  Args.getLastArg(options::OPT__SLASH_Z7, options::OPT__SLASH_Zd,
-  options::OPT_gline_tables_only)) {
+  // Emit CodeView if -Z7 or -gline-tables-only are present.
+  if (Arg *DebugInfoArg = Args.getLastArg(options::OPT__SLASH_Z7,
+  options::OPT_gline_tables_only)) {
 *EmitCodeView = true;
 if (DebugInfoArg->getOption().matches(options::OPT__SLASH_Z7))
   *DebugInfoKind = codegenoptions::LimitedDebugInfo;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5351,8 +5351,6 @@
   Alias;
 def _SLASH_Z7 : CLFlag<"Z7">,
   HelpText<"Enable CodeView debug information in object files">;
-def _SLASH_Zd : CLFlag<"Zd">,
-  HelpText<"Emit debug line number tables only">;
 def _SLASH_Zi : CLFlag<"Zi">, Alias<_SLASH_Z7>,
   HelpText<"Like /Z7">;
 def _SLASH_Zp : CLJoined<"Zp">,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -119,6 +119,14 @@
   `nonnull` attribute on `this` for configurations that need it to be nullable.
 - ``-gsplit-dwarf`` no longer implies ``-g2``.
 
+Removed Compiler Flags
+-
+
+The following options no longer exist.
+
+- clang-cl's ``/Zd`` flag no longer exist. But ``-gline-tables-only`` still
+  exists and does the same thing.
+
 New Pragmas in Clang
 
 


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -538,10 +538,6 @@
 // Z7: "-gcodeview"
 // Z7: "-debug-info-kind=limited"
 
-// RUN: %clang_cl /Zd /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7GMLT %s
-// Z7GMLT: "-gcodeview"
-// Z7GMLT: "-debug-info-kind=line-tables-only"
-
 // RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck -check-prefix=ZGMLT %s
 // ZGMLT: "-gcodeview"
 // ZGMLT: "-debug-info-kind=line-tables-only"
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -382,8 +382,7 @@
 
   CmdArgs.push_back("-nologo");
 
-  if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7,
-  options::OPT__SLASH_Zd))
+  if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))
 CmdArgs.push_back("-debug");
 
   // Pass on /Brepro if it was passed to the compiler.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===

[PATCH] D86137: Add -Wno-error=unknown flag to clang-format.

2020-12-17 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor added a comment.

I can reproduce the issue, but not sure what introduced this.

In D86137#2460135 , @njames93 wrote:

> Should the name be changed to `Wno-error-unknown`?

I don't think this should be the solution, as we aimed for the common syntax 
using the `-Wno-error=` style.
I just tried to prepare a patch, changing the way, this is handled, it works 
already in theory, but the formatting of the `--help` page is still slightly 
off (I guess `cl::values` descriptions are supposed to be single line), so I 
guess I have to investigate my formatting options here or move the more 
extensive description somewhere else... if I don't find an obvious solution, I 
guess we can discuss that after I created the patch..

  Clang-format options:
  
--Werror   - If set, changes formatting warnings to errors
--Wno-error=- If set don't error out on the specified 
warning type.
  =unknown -   If set, unknown format options are only 
warned about.
  This can be used to enable formatting, even if the
  configuration contains unknown (newer) options.
  Use with caution, as this might lead to dramatically
  differing format depending on an option being
  supported or not.
--assume-filename= - Override filename used to determine the 
language.
 When reading from stdin, clang-format assumes 
this
 filename to determine the language.
--cursor=- The position of the cursor when invoking
  ...

Btw. is there a way to add tests for command line options, so this won't happen 
unnoticed again?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

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


[PATCH] D93452: [clangd] Trim memory after buildINdex

2020-12-17 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

`malloc_trim` isn't available on windows so this wont work, so this should 
likely be ifdef'd out on windows builds. Side note is this memory failing to 
free behaviour observed on windows?




Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:51
+void trimMemory() {
+  if (malloc_trim(0))
+vlog("Trimmed memory");

It may be helpful to log how many times this call fails to free any memory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93452

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


[clang] 5e31e22 - Remove Python2 fallback and only advertise Python3 in the doc

2020-12-17 Thread via cfe-commits

Author: serge-sans-paille
Date: 2020-12-17T15:40:16+01:00
New Revision: 5e31e226b5b2b682607a6578ff5adb33daf4fe39

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

LOG: Remove Python2 fallback and only advertise Python3 in the doc

Differential Revision: https://www.youtube.com/watch?v=RsL0cipURA0

Added: 


Modified: 
clang/CMakeLists.txt
clang/tools/scan-build-py/README.md
clang/tools/scan-build/bin/set-xcode-analyzer
lld/CMakeLists.txt
lldb/docs/resources/build.rst
llvm/CMakeLists.txt
llvm/docs/GettingStarted.rst
llvm/docs/GettingStartedVS.rst
llvm/docs/HowToBuildOnARM.rst
llvm/docs/TestingGuide.rst

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index f947b820bdac..f1e5a39cfe05 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -135,20 +135,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 COMPONENTS Interpreter)
-if(NOT Python3_Interpreter_FOUND)
-  message(WARNING "Python3 not found, using python2 as a fallback")
-  find_package(Python2 COMPONENTS Interpreter REQUIRED)
-  if(Python2_VERSION VERSION_LESS 2.7)
-message(SEND_ERROR "Python 2.7 or newer is required")
-  endif()
-
-  # Treat python2 as python3
-  add_executable(Python3::Interpreter IMPORTED)
-  set_target_properties(Python3::Interpreter PROPERTIES
-IMPORTED_LOCATION ${Python2_EXECUTABLE})
-  set(Python3_EXECUTABLE ${Python2_EXECUTABLE})
-endif()
+find_package(Python3 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}

diff  --git a/clang/tools/scan-build-py/README.md 
b/clang/tools/scan-build-py/README.md
index 0f89b6fa43d8..63ce0273f22e 100644
--- a/clang/tools/scan-build-py/README.md
+++ b/clang/tools/scan-build-py/README.md
@@ -19,7 +19,7 @@ Should be working on UNIX operating systems.
 Prerequisites
 -
 
-1. **python** interpreter (version 2.7, 3.2, 3.3, 3.4, 3.5).
+1. **python** interpreter (version 3.6 or later).
 
 
 How to use

diff  --git a/clang/tools/scan-build/bin/set-xcode-analyzer 
b/clang/tools/scan-build/bin/set-xcode-analyzer
index c2a65c908598..9faaec1e8e6e 100755
--- a/clang/tools/scan-build/bin/set-xcode-analyzer
+++ b/clang/tools/scan-build/bin/set-xcode-analyzer
@@ -5,8 +5,8 @@
 # This one has the scripting bridge enabled.
 
 import sys
-if sys.version_info < (2, 7):
-print "set-xcode-analyzer requires Python 2.7 or later"
+if sys.version_info < (3, 6):
+print "set-xcode-analyzer requires Python 3.6 or later"
 sys.exit(1)
 
 import os

diff  --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index 82b4b9b9b198..d4e561b50d8f 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -57,20 +57,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   include(CheckAtomic)
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 COMPONENTS Interpreter)
-if(NOT Python3_Interpreter_FOUND)
-  message(WARNING "Python3 not found, using python2 as a fallback")
-  find_package(Python2 COMPONENTS Interpreter REQUIRED)
-  if(Python2_VERSION VERSION_LESS 2.7)
-message(SEND_ERROR "Python 2.7 or newer is required")
-  endif()
-
-  # Treat python2 as python3
-  add_executable(Python3::Interpreter IMPORTED)
-  set_target_properties(Python3::Interpreter PROPERTIES
-IMPORTED_LOCATION ${Python2_EXECUTABLE})
-  set(Python3_EXECUTABLE ${Python2_EXECUTABLE})
-endif()
+find_package(Python3 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}

diff  --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index b4e58ca977a9..8aadd126ed0b 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -73,7 +73,7 @@ commands below.
   > yum install libedit-devel libxml2-devel ncurses-devel python-devel swig
   > sudo apt-get install build-essential subversion swig python3-dev 
libedit-dev libncurses5-dev
   > pkg install swig python
-  > pkgin install swig python27 cmake ninja-build
+  > pkgin install swig python36 cmake ninja-build
   > brew install swig cmake ninja
 
 Note that there's an `incompatibility

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 54009573ed43..ee1b646ab651 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -708,20 +708,7 @@ set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER FALSE CACHE BOOL
 
 include(HandleLLVMOptions)
 
-find_package(Python3 COMPONENTS Interpreter)
-if(NOT Python3_Interpreter_FOUN

[PATCH] D93227: [clangd] Smarter hover on auto and decltype

2020-12-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Agree with all the conclusions you've come to here. Main two issues are:

- the new traversal added to patch up some cases isn't the right approach IMO.
- some accidental regressions

I'd also like to distinguish decltype(auto) from other decltypes, but it's a 
problem with our existing helpers so let's not try that in this patch.




Comment at: clang-tools-extra/clangd/Hover.cpp:618
+  } else {
+CXXRecordDecl *D = QT->getAsCXXRecordDecl();
+if (D && D->isLambda())

You've rewritten this logic compared to the old `getHoverContents(QualType)`, 
and I think there are regressions:
 - We've dropped class documentation (see e.g. 
ac3f9e48421712168884d59cbfe8b294dd76a19b, this is visible in the tests)
 - we're no longer using printName() to print tag-decls, which I expect changes 
e.g. the printing of anyonymous structs which is special-cased in that function 
(we have tests for this but probably not in combination with auto)
 - we're no longer using the printing-policy to print non-tag types, which will 
lead to some random changes

I don't see a reason for these changes, can we revert them?



Comment at: clang-tools-extra/clangd/Hover.cpp:631
+// getDeducedType are handled.
+class ExtraAutoTypeHoverVisitor
+: public RecursiveASTVisitor {

This functionality (reporting the `auto` type in structured bindings, and not 
reporting non-deduced uses of auto) belongs in the getDeducedType() helper 
rather than as a layer on top.
(Especially because it has to be done via an AST traversal rather than 
SelectionTree)

I'd suggest leaving it out of this patch to get this the original change landed 
quickly - this seems like a mostly-unrelated enhancement. But up to you.



Comment at: clang-tools-extra/clangd/Hover.cpp:907
+
+  HI->Name = tok::getTokenName(Tok.kind());
+  HighlightRange = Tok.range(SM).toCharRange(SM);

decltype(auto) and decltype(expr) are fairly different things and ultimately we 
should be displaying them differently I think ("decltype(auto)" vs 
"decltype(...)").

Unfortunately it's awkward because our getDeducedType helper handles both at 
the moment (and so is misnamed, because decltype(expr) isn't deduced at all).

Can you add `// FIXME: distinguish decltype(auto) vs decltype(expr)` and I'll 
do some refactoring later?



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:999
+  "decltype(au^to) x = 0;",
+  R"cpp(// Lambda auto parameter. Nothing (Not useful).
+auto lamb = [](a^uto){};

(not convinced this is fundamentally not useful - the fact that it's a template 
parameter means it's probably worth having a hover card for it at some point. 
But I agree with suppressing it for now)



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:1894
+HI.Definition = "int &&";
+  }},
   {

can we have a decltype test where the result is dependent?
e.g..

```
template 
struct X {
  using Y = ^decltype(T::Z);
};
```

should yield a definition of "" rather than "/* not deduced */".
(Since regular decltype() is not a deduced type)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93227

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


[PATCH] D78938: Make LLVM build in C++20 mode

2020-12-17 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

In D78938#2460360 , @nlopes wrote:

> Just saw that you fixed it already. Thank you!

'Avoided' might be a better term than 'fixed' tbh - I didn't delve much into 
why it was breaking, or what effect it has on  C++20 work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78938

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


[PATCH] D93459: Fix -Wno-error= parsing in clang-format.

2020-12-17 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor created this revision.
fodinabor added reviewers: MyDeveloperDay, JakeMerdichAMD.
fodinabor requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As noted in https://reviews.llvm.org/D86137#2460135 parsing of
the clang-format parameter -Wno-error=unknown fails.
This currently is done by having `-Wno-error=unknown` as an option.
In this patch this is changed to make `-Wno-error=` parse an enum into a bit 
set.
This way the parsing is fixed and also we can possibly add new options easily.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93459

Files:
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -104,18 +104,6 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
-// using the full param name as Wno-error probably won't be a common use case 
in
-// clang-format
-static cl::opt AllowUnknownOptions(
-"Wno-error=unknown",
-cl::desc("If set, unknown format options are only warned about.\n"
- "This can be used to enable formatting, even if the\n"
- "configuration contains unknown (newer) options.\n"
- "Use with caution, as this might lead to dramatically\n"
- "differing format depending on an option being\n"
- "supported or not."),
-cl::init(false), cl::cat(ClangFormatCategory));
-
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -156,6 +144,23 @@
  cl::desc("If set, changes formatting warnings to errors"),
  cl::cat(ClangFormatCategory));
 
+namespace {
+enum class WNoError { Unknown };
+}
+
+static cl::bits WNoErrorList(
+"Wno-error",
+cl::desc("If set don't error out on the specified warning type."),
+cl::values(
+clEnumValN(WNoError::Unknown, "unknown",
+   "If set, unknown format options are only warned about.\n"
+   "This can be used to enable formatting, even if the\n"
+   "configuration contains unknown (newer) options.\n"
+   "Use with caution, as this might lead to dramatically\n"
+   "differing format depending on an option being\n"
+   "supported or not.")),
+cl::cat(ClangFormatCategory));
+
 static cl::opt
 ShowColors("fcolor-diagnostics",
cl::desc("If set, and on a color-capable terminal controls "
@@ -391,7 +396,7 @@
 
   llvm::Expected FormatStyle =
   getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer(),
-   nullptr, AllowUnknownOptions.getValue());
+   nullptr, WNoErrorList.isSet(WNoError::Unknown));
   if (!FormatStyle) {
 llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
 return true;


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -104,18 +104,6 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
-// using the full param name as Wno-error probably won't be a common use case in
-// clang-format
-static cl::opt AllowUnknownOptions(
-"Wno-error=unknown",
-cl::desc("If set, unknown format options are only warned about.\n"
- "This can be used to enable formatting, even if the\n"
- "configuration contains unknown (newer) options.\n"
- "Use with caution, as this might lead to dramatically\n"
- "differing format depending on an option being\n"
- "supported or not."),
-cl::init(false), cl::cat(ClangFormatCategory));
-
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -156,6 +144,23 @@
  cl::desc("If set, changes formatting warnings to errors"),
  cl::cat(ClangFormatCategory));
 
+namespace {
+enum class WNoError { Unknown };
+}
+
+static cl::bits WNoErrorList(
+"Wno-error",
+cl::desc("If set don't error out on the specified warning type."),
+cl::values(
+clEnumValN(WNoError::Unknown, "unknown",
+   "If set, unknown format options are only warned about.\n"
+   "This can be used to enable formatting, even if the\n"
+   "configuration contains unknown (newer) options.\n"
+   "Use with caution, as this might lead to dramatically\n"
+   "differing format depending on an option being\n"
+   "supported or not.")),
+cl::cat(ClangFormatCategory));
+
 static cl::opt
 ShowColors("fcolor-

[PATCH] D93459: Fix -Wno-error= parsing in clang-format.

2020-12-17 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor added a comment.

Quoting my questions from the other review, as it should be more appropriate to 
discuss this here:

The formatting of the `--help` page is still slightly off (I guess `cl::values` 
descriptions are supposed to be single line), so I guess I have to investigate 
my formatting options here or move the more extensive description somewhere 
else...

  Clang-format options:
  
--Werror   - If set, changes formatting warnings to errors
--Wno-error=- If set don't error out on the specified 
warning type.
  =unknown -   If set, unknown format options are only 
warned about.
  This can be used to enable formatting, even if the
  configuration contains unknown (newer) options.
  Use with caution, as this might lead to dramatically
  differing format depending on an option being
  supported or not.
--assume-filename= - Override filename used to determine the 
language.
 When reading from stdin, clang-format assumes 
this
 filename to determine the language.
--cursor=- The position of the cursor when invoking
  ...

Btw. is there a way to add tests for command-line options, so this won't happen 
unnoticed again?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93459

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


[clang] 01089c8 - [InstCombine] Preserve !annotation on newly created instructions.

2020-12-17 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2020-12-17T15:20:23Z
New Revision: 01089c876bff43a7cde1cb9b1ef8c128169ec5b4

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

LOG: [InstCombine] Preserve !annotation on newly created instructions.

If the source instruction has !annotation metadata, all instructions
created during combining should also have it. Tell the builder to
add it.

The !annotation system was discussed on llvm-dev as part of
'RFC: Combining Annotation Metadata and Remarks'
(http://lists.llvm.org/pipermail/llvm-dev/2020-November/146393.html)

This patch is based on an earlier patch by Francis Visoiu Mistrih.

Reviewed By: thegameg, lebedev.ri

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

Added: 


Modified: 
clang/test/CodeGenCXX/auto-var-init.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/annotations.ll

Removed: 




diff  --git a/clang/test/CodeGenCXX/auto-var-init.cpp 
b/clang/test/CodeGenCXX/auto-var-init.cpp
index d50967c40216..761458da9084 100644
--- a/clang/test/CodeGenCXX/auto-var-init.cpp
+++ b/clang/test/CodeGenCXX/auto-var-init.cpp
@@ -597,9 +597,7 @@ TEST_UNINIT(empty, empty);
 // PATTERN-O1: store i8 [[I8]], {{.*}} align 1, !annotation [[AUTO_INIT]]
 // ZERO-LABEL: @test_empty_uninit()
 // ZERO-O0: call void @llvm.memset{{.*}}, i8 0,{{.+}}), !annotation 
[[AUTO_INIT]]
-// ZERO-O1: store i8 0, {{.*}} align 1
-// FIXME: !annotation dropped by optimizations
-// ZERO-O1-NOT: !annotation
+// ZERO-O1: store i8 0, {{.*}} align 1, !annotation [[AUTO_INIT]]
 
 TEST_BRACES(empty, empty);
 // CHECK-LABEL: @test_empty_braces()
@@ -618,9 +616,7 @@ TEST_UNINIT(small, small);
 // PATTERN-O1: store i8 [[I8]], {{.*}} align 1, !annotation [[AUTO_INIT]]
 // ZERO-LABEL: @test_small_uninit()
 // ZERO-O0: call void @llvm.memset{{.*}}, i8 0,{{.+}}), !annotation 
[[AUTO_INIT]]
-// ZERO-O1: store i8 0, {{.*}} align 1
-// FIXME: !annotation dropped by optimizations
-// ZERO-O1-NOT: !annotation
+// ZERO-O1: store i8 0, {{.*}} align 1, !annotation [[AUTO_INIT]]
 
 TEST_BRACES(small, small);
 // CHECK-LABEL: @test_small_braces()
@@ -671,10 +667,8 @@ TEST_UNINIT(smallpartinit, smallpartinit);
 // PATTERN-O1: store i8 42, {{.*}} align 1
 // ZERO-LABEL: @test_smallpartinit_uninit()
 // ZERO-O0: call void @llvm.memset{{.*}}, i8 0,{{.+}}), !annotation 
[[AUTO_INIT]]
-// ZERO-O1-LEGACY: store i16 0, i16* %uninit, align 2
-// ZERO-O1-NEWPM: store i16 0, i16* %uninit, align 2
-// FIXME: !annotation dropped by optimizations
-// ZERO-O1-NOT: !annotation
+// ZERO-O1-LEGACY: store i16 0, i16* %uninit, align 2, !annotation 
[[AUTO_INIT]]
+// ZERO-O1-NEWPM: store i16 0, i16* %uninit, align 2, !annotation [[AUTO_INIT]]
 
 TEST_BRACES(smallpartinit, smallpartinit);
 // CHECK-LABEL: @test_smallpartinit_braces()
@@ -726,14 +720,10 @@ TEST_UNINIT(padded, padded);
 // CHECK-NEXT:  call void @{{.*}}used{{.*}}%uninit)
 // PATTERN-LABEL: @test_padded_uninit()
 // PATTERN-O0: call void @llvm.memcpy{{.*}} 
@__const.test_padded_uninit.uninit{{.+}}), !annotation [[AUTO_INIT]]
-// PATTERN-O1: store i64 [[I64]], i64* %uninit, align 8
-// FIXME: !annotation dropped by optimizations
-// PATTERN-O1-NOT: !annotation
+// PATTERN-O1: store i64 [[I64]], i64* %uninit, align 8, !annotation 
[[AUTO_INIT]]
 // ZERO-LABEL: @test_padded_uninit()
-// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,{{.+}})
-// ZERO-O1: store i64 0, i64* %uninit, align 8
-// FIXME: !annotation dropped by optimizations
-// ZERO-O1-NOT: !annotation
+// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,{{.+}}), !annotation 
[[AUTO_INIT]]
+// ZERO-O1: store i64 0, i64* %uninit, align 8, !annotation [[AUTO_INIT]]
 
 TEST_BRACES(padded, padded);
 // CHECK-LABEL: @test_padded_braces()
@@ -758,15 +748,16 @@ TEST_UNINIT(paddednullinit, paddednullinit);
 // CHECK-NEXT:  call void @{{.*}}used{{.*}}%uninit)
 // PATTERN-LABEL: @test_paddednullinit_uninit()
 // PATTERN-O0: call void @llvm.memcpy{{.*}} 
@__const.test_paddednullinit_uninit.uninit{{.+}}), !annotation [[AUTO_INIT]]
-// PATTERN-O1-LEGACY: store i64 [[I64]], i64* %uninit, align 8
-// PATTERN-O1-NEWPM: store i64 [[I64]], i64* %uninit, align 8
-// FIXME: !annotation dropped by optimizations
-// PATTERN-O1-NOT: !annotation
+// PATTERN-O1-LEGACY: store i64 [[I64]], i64* %uninit, align 8, !annotation 
[[AUTO_INIT]]
+// PATTERN-O1-NEWPM: store i64 [[I64]], i64* %uninit, align 8, !annotation 
[[AUTO_INIT]]
 // ZERO-LABEL: @test_paddednullinit_uninit()
-// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
-// ZERO-O1: store i64 0, i64* %uninit, align 8
+// ZERO-O0: call void @llvm.memset{{.*}}, i8 0, {{.*}}, !annotation 
[[AUTO_INIT]]
+// ZERO-O1-LEGACY: store i64 0, i64* %uninit, align 8, !annotation 
[[AUTO_INIT]]
+// ZERO-O1-NEWPM: store i64 0, i64* %uninit, ali

[PATCH] D91444: [InstCombine] Preserve !annotation on newly created instructions.

2020-12-17 Thread Florian Hahn via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG01089c876bff: [InstCombine] Preserve !annotation on newly 
created instructions. (authored by fhahn).

Changed prior to commit:
  https://reviews.llvm.org/D91444?vs=312216&id=312490#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91444

Files:
  clang/test/CodeGenCXX/auto-var-init.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/annotations.ll

Index: llvm/test/Transforms/InstCombine/annotations.ll
===
--- llvm/test/Transforms/InstCombine/annotations.ll
+++ llvm/test/Transforms/InstCombine/annotations.ll
@@ -49,8 +49,8 @@
 
 define void @copy_1_byte(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @copy_1_byte({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call void @llvm.memcpy.p0i8.p0i8.i32(i8* %d, i8* %s, i32 1, i1 false), !annotation !0
@@ -61,8 +61,8 @@
 
 define void @libcallcopy_1_byte(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @libcallcopy_1_byte({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call i8* @memcpy(i8* %d, i8* %s, i64 1), !annotation !0
@@ -73,8 +73,8 @@
 
 define void @libcallcopy_1_byte_chk(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @libcallcopy_1_byte_chk({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call i8* @__memcpy_chk(i8* %d, i8* %s, i64 1, i64 1), !annotation !0
@@ -85,8 +85,8 @@
 
 define void @move_1_byte(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @move_1_byte({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call void @llvm.memmove.p0i8.p0i8.i32(i8* %d, i8* %s, i32 1, i1 false), !annotation !0
@@ -97,8 +97,8 @@
 
 define void @libcallmove_1_byte(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @libcallmove_1_byte({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call i8* @memmove(i8* %d, i8* %s, i64 1), !annotation !0
@@ -109,8 +109,8 @@
 
 define void @libcallmove_1_byte_chk(i8* %d, i8* %s) {
 ; CHECK-LABEL: define {{.+}} @libcallmove_1_byte_chk({{.+}}
-; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1
-; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1
+; CHECK-NEXT:[[TMP1:%.*]] = load i8, i8* [[S:%.*]], align 1, !annotation [[ANN]]
+; CHECK-NEXT:store i8 [[TMP1]], i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call i8* @__memmove_chk(i8* %d, i8* %s, i64 1, i64 1), !annotation !0
@@ -121,7 +121,7 @@
 
 define void @set_1_byte(i8* %d) {
 ; CHECK-LABEL: define {{.+}} @set_1_byte({{.+}}
-; CHECK-NEXT:store i8 1, i8* [[D:%.*]], align 1
+; CHECK-NEXT:store i8 1, i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call void @llvm.memset.p0i8.i32(i8* %d, i8 1, i32 1, i1 false), !annotation !0
@@ -132,7 +132,7 @@
 
 define void @libcall_set_1_byte(i8* %d) {
 ; CHECK-LABEL: define {{.+}} @libcall_set_1_byte({{.+}}
-; CHECK-NEXT:store i8 1, i8* [[D:%.*]], align 1
+; CHECK-NEXT:store i8 1, i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call i8* @memset(i8* %d, i32 1, i64 1), !annotation !0
@@ -143,7 +143,7 @@
 
 define void @libcall_set_1_byte_chk(i8* %d) {
 ; CHECK-LABEL: define {{.+}} @libcall_set_1_byte_chk({{.+}}
-; CHECK-NEXT:store i8 1, i8* [[D:%.*]], align 1
+; CHECK-NEXT:store i8 1, i8* [[D:%.*]], align 1, !annotation [[ANN]]
 ; CHECK-NEXT:ret void
 ;
   call i8* @__memset_chk(i8* %d, i32

[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2020-12-17 Thread luxufan via Phabricator via cfe-commits
StephenFan added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZfinx.td:102
+: InstAlias;
+

use GPR as instruction operand may cause the codegen part of zfinx report 
errors. Because the GPR has data type i32 or i64, However, the zfinx will deal 
with the data type f64 or f32.


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

https://reviews.llvm.org/D93298

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


[PATCH] D92577: Don't reject tag declarations in for loop clause-1

2020-12-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 312494.
aaron.ballman added a comment.

Updating based on review feedback.


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

https://reviews.llvm.org/D92577

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/Sema/for.c


Index: clang/test/Sema/for.c
===
--- clang/test/Sema/for.c
+++ clang/test/Sema/for.c
@@ -5,3 +5,7 @@
 void b2 (void) { for (void f (void);;); }   // expected-error {{declaration of 
non-local variable}}
 void b3 (void) { for (static int f;;); }// expected-error {{declaration of 
non-local variable}}
 void b4 (void) { for (typedef int f;;); }   // expected-error {{declaration of 
non-local variable}}
+void b5 (void) { for (struct { int i; } s;;); }
+void b6 (void) { for (enum { zero, ten = 10 } i;;); }
+void b7 (void) { for (struct s { int i; };;); } // expected-error 
{{non-variable declaration in 'for' loop}}
+void b8 (void) { for (static struct { int i; } s;;); } // expected-error 
{{declaration of non-local variable}}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -1822,13 +1822,28 @@
   // C99 6.8.5p3: The declaration part of a 'for' statement shall only
   // declare identifiers for objects having storage class 'auto' or
   // 'register'.
-  for (auto *DI : DS->decls()) {
-VarDecl *VD = dyn_cast(DI);
+  for (auto Iter = DS->decl_begin(), End = DS->decl_end(); Iter != End;
+   ++Iter) {
+VarDecl *VD = dyn_cast(*Iter);
 if (VD && VD->isLocalVarDecl() && !VD->hasLocalStorage())
   VD = nullptr;
+
 if (!VD) {
-  Diag(DI->getLocation(), diag::err_non_local_variable_decl_in_for);
-  DI->setInvalidDecl();
+  // It is possible to declare non-variable declarations as part of the
+  // declaration part of a 'for' statement, such as defining a 
structure
+  // or enum type: for (enum { zero, ten } i = zero; i < ten; ++i);
+  if (isa(*Iter)) {
+// The declaration immediately after the tag decl needs to be a
+// variable declaration. We don't care if it's a valid variable
+// declaration because the validity will be checked on the next
+// iteration through the declarations in the group.
+if (Iter + 1 == End || !isa(*(Iter + 1)))
+  Diag((*Iter)->getLocation(), diag::err_non_variable_decl_in_for);
+  } else {
+Diag((*Iter)->getLocation(),
+ diag::err_non_local_variable_decl_in_for);
+(*Iter)->setInvalidDecl();
+  }
 }
   }
 }


Index: clang/test/Sema/for.c
===
--- clang/test/Sema/for.c
+++ clang/test/Sema/for.c
@@ -5,3 +5,7 @@
 void b2 (void) { for (void f (void);;); }   // expected-error {{declaration of non-local variable}}
 void b3 (void) { for (static int f;;); }// expected-error {{declaration of non-local variable}}
 void b4 (void) { for (typedef int f;;); }   // expected-error {{declaration of non-local variable}}
+void b5 (void) { for (struct { int i; } s;;); }
+void b6 (void) { for (enum { zero, ten = 10 } i;;); }
+void b7 (void) { for (struct s { int i; };;); } // expected-error {{non-variable declaration in 'for' loop}}
+void b8 (void) { for (static struct { int i; } s;;); } // expected-error {{declaration of non-local variable}}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -1822,13 +1822,28 @@
   // C99 6.8.5p3: The declaration part of a 'for' statement shall only
   // declare identifiers for objects having storage class 'auto' or
   // 'register'.
-  for (auto *DI : DS->decls()) {
-VarDecl *VD = dyn_cast(DI);
+  for (auto Iter = DS->decl_begin(), End = DS->decl_end(); Iter != End;
+   ++Iter) {
+VarDecl *VD = dyn_cast(*Iter);
 if (VD && VD->isLocalVarDecl() && !VD->hasLocalStorage())
   VD = nullptr;
+
 if (!VD) {
-  Diag(DI->getLocation(), diag::err_non_local_variable_decl_in_for);
-  DI->setInvalidDecl();
+  // It is possible to declare non-variable declarations as part of the
+  // declaration part of a 'for' statement, such as defining a structure
+  // or enum type: for (enum { zero, ten } i = zero; i < ten; ++i);
+  if (isa(*Iter)) {
+// The declaration immediately after the tag decl needs to be a
+// variable declaration. We don't care if it's a valid variable
+// declaration because the validity will be checked on the next
+// iteration through the declarations in the group.
+if (Iter + 1 == End || !isa(*(Iter +

[PATCH] D92577: Don't reject tag declarations in for loop clause-1

2020-12-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D92577#2458903 , @rjmccall wrote:

> Please test that there's actually an object declared and that it's not *just* 
> a tag declaration.

Good catch, I've corrected this and added some more test coverage.


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

https://reviews.llvm.org/D92577

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


[PATCH] D93452: [clangd] Trim memory after buildINdex

2020-12-17 Thread Quentin Chateau via Phabricator via cfe-commits
qchateau added a comment.

> Side note is this memory failing to free behaviour observed on windows?

No idea, I only develop on linux. Looking at the the github issues, it seems 
people that had the issue were also using the linux version...so we can't 
conclude anything about windows




Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:51
+void trimMemory() {
+  if (malloc_trim(0))
+vlog("Trimmed memory");

njames93 wrote:
> It may be helpful to log how many times this call fails to free any memory.
From what I observed, it (almost?) never fails to free memory, although 
sometimes it's only a few kB.
Anyway, are you suggesting to keep track of how many time we call `malloc_trim` 
and how many times it fails ? Or simply logging when it fails ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93452

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


[PATCH] D93393: [clangd] Ignore the static index refs from the dynamic index files.

2020-12-17 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 312497.
ArcsinX added a comment.

Make `indexedFiles()` to return `[](StringRef){return false;}` instead of 
`nullptr`.
Add comments.
Do not call `indexedFiles()` at every file check for `MergeIndex`.
Consume error if `URI::resolve()` fails.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93393

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/Index.h
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/index/Merge.h
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/dex/Dex.h
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DexTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.cpp

Index: clang-tools-extra/clangd/unittests/TestFS.cpp
===
--- clang-tools-extra/clangd/unittests/TestFS.cpp
+++ clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -99,8 +99,9 @@
   llvm::Expected
   getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
   llvm::StringRef HintPath) const override {
-if (!HintPath.startswith(testRoot()))
-  return error("Hint path doesn't start with test root: {0}", HintPath);
+if (!HintPath.empty() && !HintPath.startswith(testRoot()))
+  return error("Hint path is not empty and doesn't start with {0}: {1}",
+   testRoot(), HintPath);
 if (!Body.consume_front("/"))
   return error("Body of an unittest: URI must start with '/'");
 llvm::SmallString<16> Path(Body.begin(), Body.end());
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1237,6 +1237,11 @@
 void relations(const RelationsRequest &Req,
llvm::function_ref
Callback) const override {}
+
+llvm::unique_function indexedFiles() const override {
+  return [](llvm::StringRef) { return false; };
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
   } PIndex;
   Results = rename({MainCode.point(),
@@ -1285,6 +1290,11 @@
 void relations(const RelationsRequest &,
llvm::function_ref)
 const override {}
+
+llvm::unique_function indexedFiles() const override {
+  return [](llvm::StringRef) { return false; };
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
 Ref ReturnedRef;
   } DIndex(XRefInBarCC);
Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -224,6 +224,20 @@
   EXPECT_THAT(lookup(*I, SymbolID("ns::nonono")), UnorderedElementsAre());
 }
 
+TEST(MemIndexTest, IndexedFiles) {
+  SymbolSlab Symbols;
+  RefSlab Refs;
+  auto Size = Symbols.bytes() + Refs.bytes();
+  auto Data = std::make_pair(std::move(Symbols), std::move(Refs));
+  llvm::StringSet<> Files = {testPath("foo.cc"), testPath("bar.cc")};
+  MemIndex I(std::move(Data.first), std::move(Data.second), RelationSlab(),
+ std::move(Files), std::move(Data), Size);
+  auto ContainsFile = I.indexedFiles();
+  EXPECT_TRUE(ContainsFile("unittest:///foo.cc"));
+  EXPECT_TRUE(ContainsFile("unittest:///bar.cc"));
+  EXPECT_FALSE(ContainsFile("unittest:///foobar.cc"));
+}
+
 TEST(MemIndexTest, TemplateSpecialization) {
   SymbolSlab::Builder B;
 
@@ -367,7 +381,7 @@
   Test.Code = std::string(Test1Code.code());
   Test.Filename = "test.cc";
   auto AST = Test.build();
-  Dyn.updateMain(Test.Filename, AST);
+  Dyn.updateMain(testPath(Test.Filename), AST);
 
   // Build static index for test.cc.
   Test.HeaderCode = HeaderCode;
@@ -375,7 +389,7 @@
   Test.Filename = "test.cc";
   auto StaticAST = Test.build();
   // Add stale refs for test.cc.
-  StaticIndex.updateMain(Test.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test.Filename), StaticAST);
 
   // Add refs for test2.cc
   Annotations Test2Code(R"(class $Foo[[Foo]] {};)");
@@ -384,7 +398,7 @@
   Test2.Code = std::string(Test2Code.code());
   Test2.Filename = "test2.cc";
   StaticAST = Test2.build();
-  StaticIndex.updateMain(Test2.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test2.Filename), StaticAST);
 
   RefsRequest Request;
   Request.IDs = {Foo.ID};
@@ -403,10 +417,47 @@
   RefSlab::B

[clang] fb0f728 - [Clang] Make nomerge attribute a function attribute as well as a statement attribute.

2020-12-17 Thread Zequan Wu via cfe-commits

Author: Zequan Wu
Date: 2020-12-17T07:45:38-08:00
New Revision: fb0f7288051eb2745bb9211306f53ff9aa6f73e2

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

LOG: [Clang] Make nomerge attribute a function attribute as well as a statement 
attribute.

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

Added: 


Modified: 
clang/include/clang/AST/Attr.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/CodeGen/attr-nomerge.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/Sema/attr-nomerge.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp
llvm/include/llvm/IR/Attributes.td

Removed: 




diff  --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h
index 8d9fb8f2bf27..e453733ab92c 100644
--- a/clang/include/clang/AST/Attr.h
+++ b/clang/include/clang/AST/Attr.h
@@ -162,6 +162,21 @@ class InheritableAttr : public Attr {
   }
 };
 
+class DeclOrStmtAttr : public InheritableAttr {
+protected:
+  DeclOrStmtAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo,
+ attr::Kind AK, bool IsLateParsed,
+ bool InheritEvenIfAlreadyPresent)
+  : InheritableAttr(Context, CommonInfo, AK, IsLateParsed,
+InheritEvenIfAlreadyPresent) {}
+
+public:
+  static bool classof(const Attr *A) {
+return A->getKind() >= attr::FirstDeclOrStmtAttr &&
+   A->getKind() <= attr::LastDeclOrStmtAttr;
+  }
+};
+
 class InheritableParamAttr : public InheritableAttr {
 protected:
   InheritableParamAttr(ASTContext &Context,

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 7d566e64c99b..ce2ee40dc036 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -570,6 +570,9 @@ class InheritableAttr : Attr {
 /// attributes, but have historically been written on declarations.
 class DeclOrTypeAttr : InheritableAttr;
 
+/// A attribute is either a declaration attribute or a statement attribute.
+class DeclOrStmtAttr : InheritableAttr;
+
 /// A target-specific attribute.  This class is meant to be used as a mixin
 /// with InheritableAttr or Attr depending on the attribute's needs.
 class TargetSpecificAttr {
@@ -1317,9 +1320,12 @@ def Unlikely : StmtAttr {
   let Documentation = [LikelihoodDocs];
 }
 
-def NoMerge : StmtAttr {
+def NoMerge : DeclOrStmtAttr {
   let Spellings = [Clang<"nomerge">];
   let Documentation = [NoMergeDocs];
+  let InheritEvenIfAlreadyPresent = 1;
+  let Subjects = SubjectList<[Function], ErrorDiag, "functions and 
statements">;
+  let SimpleHandler = 1;
 }
 
 def FastCall : DeclOrTypeAttr {

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 4f8cd8ecd86f..c3a412158aba 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -386,7 +386,11 @@ location of certain calls. For example, it will prevent 
tail merging otherwise
 identical code sequences that raise an exception or terminate the program. Tail
 merging normally reduces the precision of source location information, making
 stack traces less useful for debugging. This attribute gives the user control
-over the tradeoff between code size and debug information precision.
+over the tradeoff between code size and debug information precision. 
+
+``nomerge`` attribute can also be used as function attribute to prevent all 
+calls to the specified function from merging. It has no effect on indirect 
+calls.
   }];
 }
 

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 28a7d128505a..bfc7b8e74d8f 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1968,6 +1968,8 @@ void CodeGenModule::ConstructAttributeList(
   FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
 NBA = Fn->getAttr();
   }
+  if (!AttrOnCallSite && TargetDecl->hasAttr())
+FuncAttrs.addAttribute(llvm::Attribute::NoMerge);
 }
 
 // 'const', 'pure' and 'noalias' attributed functions are also nounwind.
@@ -4978,11 +4980,13 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
 Attrs.addAttribute(getLLVMContext(), 
llvm::AttributeList::FunctionIndex,
llvm::Attribute::StrictFP);
 
-  // Add call-site nomerge attribute if exists.
-  if (InNoMergeAttributedStmt)
-Attrs =
-  Attrs.addAttribute(getLLVMContext(), llvm::AttributeList::FunctionIndex,
- llvm::Attribute::NoMerge);
+  // Add nomerge attribute to the call-site if the callee function doesn't have
+  // the attr

[PATCH] D92800: [Clang] Make nomerge attribute a function attribute as well as a statement attribute.

2020-12-17 Thread Zequan Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb0f7288051e: [Clang] Make nomerge attribute a function 
attribute as well as a statement… (authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92800

Files:
  clang/include/clang/AST/Attr.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-nomerge.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-nomerge.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp
  llvm/include/llvm/IR/Attributes.td

Index: llvm/include/llvm/IR/Attributes.td
===
--- llvm/include/llvm/IR/Attributes.td
+++ llvm/include/llvm/IR/Attributes.td
@@ -124,7 +124,7 @@
 /// Function is called early and/or often, so lazy binding isn't worthwhile.
 def NonLazyBind : EnumAttr<"nonlazybind">;
 
-/// Disable merging for call sites
+/// Disable merging for specified functions or call sites.
 def NoMerge : EnumAttr<"nomerge">;
 
 /// Pointer is known to be not null.
Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -2693,6 +2693,7 @@
   { "ATTR", "Attr" },
   { "TYPE_ATTR", "TypeAttr" },
   { "STMT_ATTR", "StmtAttr" },
+  { "DECL_OR_STMT_ATTR", "DeclOrStmtAttr" },
   { "INHERITABLE_ATTR", "InheritableAttr" },
   { "DECL_OR_TYPE_ATTR", "DeclOrTypeAttr" },
   { "INHERITABLE_PARAM_ATTR", "InheritableParamAttr" },
@@ -3779,7 +3780,8 @@
 OS << (Attr.isSubClassOf("TypeAttr") ||
Attr.isSubClassOf("DeclOrTypeAttr")) << ";\n";
 OS << "IsStmt = ";
-OS << Attr.isSubClassOf("StmtAttr") << ";\n";
+OS << (Attr.isSubClassOf("StmtAttr") || Attr.isSubClassOf("DeclOrStmtAttr"))
+   << ";\n";
 OS << "IsKnownToGCC = ";
 OS << IsKnownToGCC(Attr) << ";\n";
 OS << "IsSupportedByPragmaAttribute = ";
Index: clang/test/Sema/attr-nomerge.cpp
===
--- clang/test/Sema/attr-nomerge.cpp
+++ clang/test/Sema/attr-nomerge.cpp
@@ -8,10 +8,10 @@
   int x;
   [[clang::nomerge]] x = 10; // expected-warning {{nomerge attribute is ignored because there exists no call expression inside the statement}}
 
-  [[clang::nomerge]] label: bar(); // expected-error {{'nomerge' attribute cannot be applied to a declaration}}
+  [[clang::nomerge]] label: bar(); // expected-error {{'nomerge' attribute only applies to functions and statements}}
 
 }
 
-int f();
+[[clang::nomerge]] int f();
 
-[[clang::nomerge]] static int i = f(); // expected-error {{'nomerge' attribute cannot be applied to a declaration}}
+[[clang::nomerge]] static int i = f(); // expected-error {{'nomerge' attribute only applies to functions and statements}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -92,6 +92,7 @@
 // CHECK-NEXT: NoEscape (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NoInline (SubjectMatchRule_function)
 // CHECK-NEXT: NoInstrumentFunction (SubjectMatchRule_function)
+// CHECK-NEXT: NoMerge (SubjectMatchRule_function)
 // CHECK-NEXT: NoMicroMips (SubjectMatchRule_function)
 // CHECK-NEXT: NoMips16 (SubjectMatchRule_function)
 // CHECK-NEXT: NoSanitize (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_variable_is_global)
Index: clang/test/CodeGen/attr-nomerge.cpp
===
--- clang/test/CodeGen/attr-nomerge.cpp
+++ clang/test/CodeGen/attr-nomerge.cpp
@@ -1,9 +1,23 @@
 // RUN: %clang_cc1 -S -emit-llvm %s -triple x86_64-unknown-linux-gnu -o - | FileCheck %s
 
-bool bar();
-void f(bool, bool);
+class A {
+public:
+  [[clang::nomerge]] A();
+  [[clang::nomerge]] ~A();
+  [[clang::nomerge]] void f();
+  [[clang::nomerge]] virtual void g();
+  [[clang::nomerge]] static void f1();
+};
 
-void foo(int i) {
+class B : public A {
+public:
+  void g() override;
+};
+
+[[clang::nomerge]] bool bar();
+[[clang::nomerge]] void f(bool, bool);
+
+void foo(int i, A *ap, B *bp) {
   [[clang::nomerge]] bar();
   [[clang::nomerge]] (i = 4, bar());
   [[clang::nomerge]] (void)(bar());
@@ -12,18 +26,68 @@
   [[clang::nomerge]] for (bar(); bar(); bar()) {}
   [[clang::nomerge]] { asm("nop"); }
   bar();
+
+  ap->g();
+  bp->g();
+
+  A a;
+  a.f();
+  a.g();
+  A::f1();
+
+  B b;
+  b.g();
+}
+
+int g(int i);
+
+void something() {
+  g(1);

[PATCH] D93103: Enable the _ExtInt extension on the BPF Target

2020-12-17 Thread Sean Young via Phabricator via cfe-commits
seanyoung added a comment.

Patch submitted 
https://lore.kernel.org/bpf/20201217150102.ga13...@gofer.mess.org/T/#u


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93103

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


[PATCH] D93459: Fix -Wno-error= parsing in clang-format.

2020-12-17 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D93459#2460445 , @fodinabor wrote:

> Btw. is there a way to add tests for command-line options, so this won't 
> happen unnoticed again?

I'd guess some lit tests could be used to verify the command line syntax is 
correct

  // RUN: clang-format --Wno-error=unknown --style=`{UnknownKey: true}` 
--dump-config

If it can't parse that command line, or it maybe parses it incorrectly, 
clang-format will return non-zero and fail the test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93459

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


[PATCH] D93452: [clangd] Trim memory after buildINdex

2020-12-17 Thread Quentin Chateau via Phabricator via cfe-commits
qchateau updated this revision to Diff 312500.
qchateau added a comment.
Herald added a subscriber: mgorny.

Add macro to use malloc_trim only if available


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93452

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/FileIndex.cpp


Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -32,6 +32,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
@@ -41,10 +42,21 @@
 #include 
 #include 
 
+#ifdef HAVE_MALLOC_TRIM
+#include 
+#endif // HAVE_MALLOC_TRIM
+
 namespace clang {
 namespace clangd {
 namespace {
 
+void trimMemory() {
+#ifdef HAVE_MALLOC_TRIM
+  if (malloc_trim(0))
+vlog("Trimmed memory");
+#endif // HAVE_MALLOC_TRIM
+}
+
 SlabTuple indexSymbols(ASTContext &AST, std::shared_ptr PP,
llvm::ArrayRef DeclsToIndex,
const MainFileMacros *MacroRefsToIndex,
@@ -263,6 +275,10 @@
 std::unique_ptr
 FileSymbols::buildIndex(IndexType Type, DuplicateHandling DuplicateHandle,
 size_t *Version) {
+  // Building the index often leaves a lof of freed but unreleased memory
+  // (at the OS level): manually trim the memory after the index is built
+  auto _ = llvm::make_scope_exit(trimMemory);
+
   std::vector> SymbolSlabs;
   std::vector> RefSlabs;
   std::vector> RelationSlabs;
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -154,6 +154,13 @@
   clangdSupport
   )
 
+check_symbol_exists(malloc_trim malloc.h HAVE_MALLOC_TRIM)
+if (HAVE_MALLOC_TRIM)
+  target_compile_definitions(obj.clangDaemon
+PRIVATE HAVE_MALLOC_TRIM
+)
+endif ()
+
 add_subdirectory(refactor/tweaks)
 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
   # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.


Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -32,6 +32,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
@@ -41,10 +42,21 @@
 #include 
 #include 
 
+#ifdef HAVE_MALLOC_TRIM
+#include 
+#endif // HAVE_MALLOC_TRIM
+
 namespace clang {
 namespace clangd {
 namespace {
 
+void trimMemory() {
+#ifdef HAVE_MALLOC_TRIM
+  if (malloc_trim(0))
+vlog("Trimmed memory");
+#endif // HAVE_MALLOC_TRIM
+}
+
 SlabTuple indexSymbols(ASTContext &AST, std::shared_ptr PP,
llvm::ArrayRef DeclsToIndex,
const MainFileMacros *MacroRefsToIndex,
@@ -263,6 +275,10 @@
 std::unique_ptr
 FileSymbols::buildIndex(IndexType Type, DuplicateHandling DuplicateHandle,
 size_t *Version) {
+  // Building the index often leaves a lof of freed but unreleased memory
+  // (at the OS level): manually trim the memory after the index is built
+  auto _ = llvm::make_scope_exit(trimMemory);
+
   std::vector> SymbolSlabs;
   std::vector> RefSlabs;
   std::vector> RelationSlabs;
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -154,6 +154,13 @@
   clangdSupport
   )
 
+check_symbol_exists(malloc_trim malloc.h HAVE_MALLOC_TRIM)
+if (HAVE_MALLOC_TRIM)
+  target_compile_definitions(obj.clangDaemon
+PRIVATE HAVE_MALLOC_TRIM
+)
+endif ()
+
 add_subdirectory(refactor/tweaks)
 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
   # FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93401: [flang][driver] Add support for `-D`, `-U`

2020-12-17 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

@FarisRehman, thank you for working on this! This looks really good and I think 
that it's almost ready. I did leave a few comments, but most are a matter of 
style and should be easy to address.




Comment at: clang/lib/Driver/ToolChains/Flang.cpp:70-71
+  types::ID InputType = Input.getType();
+  if (types::getPreprocessedType(InputType) != types::TY_INVALID) {
+Args.AddAllArgs(CmdArgs, {options::OPT_D, options::OPT_U});
+  }

Clang deals with the preprocessor options in a dedicated method, 
`AddPreprocessingOptions`. See here: 
https://github.com/llvm/llvm-project/blob/eba09a2db9eab46832cb7ec7ef0d2c227747772a/clang/lib/Driver/ToolChains/Clang.cpp#L1077

I feel that it might be a good idea to follow that. The preprocessor options 
(and the corresponding logic) are bound to grow, so we may as well add a 
dedicated method sooner rather than later.



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:73
+  }
+  Args.ClaimAllArgs(options::OPT_D);
+

AFAIK, when you call `AddAllArgs` the corresponding options are eventually 
_claimed_: 
https://github.com/llvm/llvm-project/blob/eba09a2db9eab46832cb7ec7ef0d2c227747772a/llvm/lib/Option/ArgList.cpp#L112
So, IIUC, this line is not needed.



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:77
 
-  const auto& D = C.getDriver();
   // TODO: Replace flang-new with flang once the new driver replaces the

This change is not needed, is it?



Comment at: flang/include/flang/Frontend/CompilerInvocation.h:32
 
+  Fortran::frontend::PreprocessorOptions preprocessorOpts_;
+

1. Could you add a comment explaining what this is for?

2. Could you follow the current semantics used in the file and make it a 
`std::shared_ptr`? Long term we can expect `PreprocessorOptions` to grow big 
and at that point we wouldn't want to copy it too often (especially when 
compiling a lot of files).



Comment at: flang/include/flang/Frontend/CompilerInvocation.h:84
   // compiler driver options in libclangDriver.
-  void SetDefaultFortranOpts();
+  void SetFortranOpts();
 };

IIUC, you are renaming this method because it is finally translating the user 
provided options (i.e. preprocessorOpts()) into Frontend options (i.e. 
`fortranOptions`). However, with your changes this method:
* sets some _sane_ predefined defaults
* adds some stuff from the user (the preprocessor defines)

So it's somewhere in between `SetDefaultFortranOpts` and `SetFortranOpts` (i.e. 
both names are _almost_ accurate). Perhaps splitting this into two methods 
would be better? E.g.:
* `SetDefaultFortranOpts` (leave as is)
* `SetFortranOpts` (implements new functionality, to replace 
`SetDefaultFortranOpts`  eventually)



Comment at: flang/include/flang/Frontend/PreprocessorOptions.h:1
+#ifndef LLVM_FLANG_PREPROCESSOROPTIONS_H
+#define LLVM_FLANG_PREPROCESSOROPTIONS_H

Missing file header: https://llvm.org/docs/CodingStandards.html#file-headers



Comment at: flang/include/flang/Frontend/PreprocessorOptions.h:8
+
+/// PreprocessorOptions - This class is used for passing the various options
+/// used in preprocessor initialization to the parser options.

[nit] No need to repeat the name of the class.



Comment at: flang/include/flang/Frontend/PreprocessorOptions.h:12
+public:
+  std::vector> Macros;
+

[nit] IMO this would be preferred : `/*isUndef=*/bool` 
(https://llvm.org/docs/CodingStandards.html#comment-formatting) (currently you 
have `bool /*isUndef*/`)



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:157
 
+static void ParsePreprocessorArgs(
+Fortran::frontend::PreprocessorOptions &opts, llvm::opt::ArgList &args) {

I couldn't find any notes on naming static functions here: 
https://github.com/llvm/llvm-project/blob/main/flang/docs/C%2B%2Bstyle.md. This 
means that we fallow this: 
https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly.
 So, `parsePreprocessorArgs` instead of `ParsePreprocessorArgs`.

Also, could you add a comment briefly explaining what the method is for? E.g. 
`Parses all preprocessor input arguments and populates the preprocessor options 
accordingly`? Ideally doxygen :) See example here: 
https://github.com/llvm/llvm-project/blob/eba09a2db9eab46832cb7ec7ef0d2c227747772a/flang/include/flang/Frontend/CompilerInstance.h#L158-L163



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:160
+  // Add macros from the command line.
+  for (const auto *A : args.filtered(
+   clang::driver::options::OPT_D, clang::driver::options::OPT_U)) {

Variable names should start with lower case.

[nit] Perhaps `currentArg` instead of `A` for the sake of being explicit?  Or 
`curArg`?



[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-12-17 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:6502
+  // except that it has a non-trivial member *with* the trivial_abi attribute.
+  for (auto Base : D->bases()) {
+if (auto CxxRecord = Base.getType()->getAsCXXRecordDecl())

zoecarver wrote:
> ahatanak wrote:
> > zoecarver wrote:
> > > ahatanak wrote:
> > > > It looks like this patch changes the way `D` is passed in the following 
> > > > code:
> > > > 
> > > > ```
> > > > struct B {
> > > >   int i[4];
> > > >   B();
> > > >   B(const B &) = default;
> > > >   B(B &&);
> > > > };
> > > > 
> > > > struct D : B {
> > > >   D();
> > > >   D(const D &) = default;
> > > >   D(D &&) = delete;
> > > > };
> > > > 
> > > > void testB(B a);
> > > > void testD(D a);
> > > > 
> > > > void testCallB() {
> > > >   B b;
> > > >   testB(b);
> > > > }
> > > > 
> > > > void testCallD() {
> > > >   D d;
> > > >   testD(d);
> > > > }
> > > > ```
> > > > 
> > > > `B` cannot be passed in registers because it has a non-trivial move 
> > > > constructor, whereas `D` can be passed in registers because the move 
> > > > constructor is deleted and the copy constructor is trivial.
> > > > 
> > > > I'm not sure what the best way to handle this is, but I just wanted to 
> > > > point this out.
> > > Hmm. Good catch. One way to fix this would be to simply create a 
> > > `HasPassableSubobject` variable and add that to the conditions below 
> > > (instead of returning false here). But, it seems that `D` isn't passed by 
> > > registers (even though, maybe it should be) on ToT: 
> > > https://godbolt.org/z/4xevW5 
> > > 
> > > Given that, do you think it's OK to return false here, or should I update 
> > > this patch to use the logic I just described (even though that would be a 
> > > nfc)? 
> > The argument is byval, so `D` is passed directly. If you remove `-O3` and 
> > add `-target aarch64`, you'll see that `[2 x i64]` is being passed
> Ah, I see now. Great. Thanks. I'll update the patch. 
Akira's example is legal C++ with no Clang-specific attributes, so its behavior 
is governed by the appropriate platform's ABI doc — there exists one correct 
answer.
At least on x86-64 with the Itanium ABI, GCC and ICC and Clang ToT all agree on 
the answer: `B` and `D` have exactly the same passing convention. If your patch 
breaks that, that's a problem.
Contrariwise, it appears that `B` and `D` have different passing conventions on 
"armv8" according to Clang, and the same passing convention on "ARM64" 
according to GCC: https://godbolt.org/z/j9jzYG
Of course if the programmer adds `[[clang::trivial_abi]]` to one of them, then 
all bets are off, standards-wise, and you're free to figure out a way to pass 
it in registers if you want to. But otherwise I think you have to follow what 
the ABI says.
Bear in mind that I don't really know ABIs other than Itanium/x86-64. Maybe the 
problem here is that other platforms don't have well-defined ABIs and so we get 
to make one up? Maybe everyone except me is already aware that that's what 
we're doing? :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D93452: [clangd] Trim memory after buildINdex

2020-12-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Wow, all abstractions truly are lies. Thanks for the investigation!

After doing some reading[1], my understanding is roughly:

- our pattern of allocations causes glibc malloc to retain a *much* larger heap 
than our outstanding allocations, growing without (or with large) bound
- malloc maintains several arenas and grows each as needed, and only implicitly 
shrinks them "from the top". A lives-forever object at the end of an arena will 
prevent it implicitly shrinking past that point.
- clangd has lives-almost-forever allocations, e.g. when background indexing 
that could be causing this. If we get unlucky and allocate it at a point when 
the arena happens to be really full, it doesn't matter if the arena spends most 
of its time mostly-empty.
- use of multiple threads means more arenas, and thus more fragmentation/waste.
- malloc_trim() is able to free more aggressively, looking "inside" the arenas 
[2]
- this affects glibc malloc only, which explains why we've only had this 
problem reported on linux and we haven't gotten reports from google-internal 
users (our production binaries use tcmalloc)

Some back-of-the-envelope numbers: I guess we grow until we have enough space 
to satisfy every allocation in every arena, so the wasted space/gaps is 
NumArenas times what you expect, which is 8 * NumCores, which can easily be 500 
on a big workstation - if we expect (wild guess) 80% efficiency = 25% overhead 
for a single-threaded app, then this could yield 12500% overhead = 0.8% 
efficiency at the steady state, which is a 100x increase in memory usage. This 
sounds like a plausible explanation for the bug reports (but I'm not an expert 
and am guessing a lot).

[1] particularly: 
https://stackoverflow.com/questions/38644578/understanding-glibc-malloc-trimming
[2] https://man7.org/linux/man-pages/man3/malloc_trim.3.html - see notes 
regarding glibc 2.8

---

So where does this leave us, other than fairly unimpressed with glibc malloc?

Periodic malloc_trim seems like it solves a real problem, one I don't 
personally fully understand but we may never do - I feel convinced we should 
use it anyway. It probably has some overhead, who knows how much.

We need to work out how to guard it not just for glibc, but also for using 
glibc malloc rather than alternative like jemalloc, tcmalloc et al.
(We could *require* the use of an alternative malloc and not fix this, but that 
doesn't seem terribly practical to me)

It's process-wide (not per-thread, and certainly not per-program-module) so the 
fact that slapping it in FileSymbols::buildIndex solves the problem only proves 
that function is called periodically :-)
This is a system-level function, I think we should probably be calling it 
periodically from something top-level like ClangdMain or ClangdLSPServer.
(We could almost slip it in with ClangdLSPServer::maybeExportMemoryProfile(), 
except we don't want to link it to incoming notifications as memory can 
probably grow while silently background indexing)

I think we should pass a nonzero `pad` to malloc_trim of several MB. It only 
affects the main thread, but the main thread is constantly allocating small 
short-lived objects (e.g. JSON encoding/decoding) and cutting it to the bone 
only to have it sbrk again seems pointless.




Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:50
 
+void trimMemory() {
+  if (malloc_trim(0))

this function belongs in `llvm/Support/Process.h`, next to 
Process::GetMallocUsage().

This is full of OS-specific bits (`#ifdef HAVE_MALLINFO`) etc that probably 
guide how we should set this up.



Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:275
+  // (at the OS level): manually trim the memory after the index is built
+  auto _ = llvm::make_scope_exit(trimMemory);
+

I think this should like in ClangdLSPServer, triggered by all of:
 - various events: outgoing notification, incoming notification, 
onBackgroundIndexProgress()
 - an option specified by ClangdMain (I think it might even be cleanest to 
inject a "PeriodicMemoryCleanup" function via ClangdLSPServer::Options)
 - a timer having expired since the last time we called this - maybe a minute?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93452

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


[clang] daf39e3 - [amdgpu] Default to code object v3

2020-12-17 Thread Jon Chesterfield via cfe-commits

Author: Jon Chesterfield
Date: 2020-12-17T16:09:33Z
New Revision: daf39e3f2dba18bd39cd89a1c91bae126a31d4fe

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

LOG: [amdgpu] Default to code object v3

[amdgpu] Default to code object v3
v4 is not yet readily available, and doesn't appear
to be implemented in the back end

Reviewed By: t-tye, yaxunl

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/hip-code-object-version.hip
llvm/docs/AMDGPUUsage.rst

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f384e0d993c2..07f15add28ec 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2909,7 +2909,7 @@ def mexec_model_EQ : Joined<["-"], "mexec-model=">, 
Group;
 
 def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, 
Group,
-  HelpText<"Specify code object ABI version. Defaults to 4. (AMDGPU only)">,
+  HelpText<"Specify code object ABI version. Defaults to 3. (AMDGPU only)">,
   MetaVarName<"">, Values<"2,3,4">;
 
 def mcode_object_v3_legacy : Flag<["-"], "mcode-object-v3">, Group,

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 72bedc16846d..04d0e0771f70 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1549,7 +1549,7 @@ unsigned tools::getOrCheckAMDGPUCodeObjectVersion(
 const Driver &D, const llvm::opt::ArgList &Args, bool Diagnose) {
   const unsigned MinCodeObjVer = 2;
   const unsigned MaxCodeObjVer = 4;
-  unsigned CodeObjVer = 4;
+  unsigned CodeObjVer = 3;
 
   // Emit warnings for legacy options even if they are overridden.
   if (Diagnose) {

diff  --git a/clang/test/Driver/hip-code-object-version.hip 
b/clang/test/Driver/hip-code-object-version.hip
index 51d9004b0cbf..6e4e96688593 100644
--- a/clang/test/Driver/hip-code-object-version.hip
+++ b/clang/test/Driver/hip-code-object-version.hip
@@ -53,7 +53,7 @@
 // RUN:   --offload-arch=gfx906 -nogpulib \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=VD %s
 
-// VD: "-mllvm" "--amdhsa-code-object-version=4"
+// VD: "-mllvm" "--amdhsa-code-object-version=3"
 // VD: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
 
 // Check invalid code object version option.

diff  --git a/llvm/docs/AMDGPUUsage.rst b/llvm/docs/AMDGPUUsage.rst
index 6d3fa7021a7a..c8dda47352ab 100644
--- a/llvm/docs/AMDGPUUsage.rst
+++ b/llvm/docs/AMDGPUUsage.rst
@@ -911,12 +911,12 @@ The AMDGPU backend uses the following ELF header:
 
   * ``ELFABIVERSION_AMDGPU_HSA_V3`` is used to specify the version of AMD HSA
 runtime ABI for code object V3. Specify using the Clang option
-``-mcode-object-version=3``.
+``-mcode-object-version=3``. This is the default code object
+version if not specified.
 
   * ``ELFABIVERSION_AMDGPU_HSA_V4`` is used to specify the version of AMD HSA
 runtime ABI for code object V4. Specify using the Clang option
-``-mcode-object-version=4``. This is the default code object
-version if not specified.
+``-mcode-object-version=4``.
 
   * ``ELFABIVERSION_AMDGPU_PAL`` is used to specify the version of AMD PAL
 runtime ABI.
@@ -2871,10 +2871,6 @@ non-AMD key names should be prefixed by "*vendor-name*.".
 Code Object V3 Metadata
 +++
 
-.. warning::
-  Code object V3 is not the default code object version emitted by this version
-  of LLVM.
-
 Code object V3 to V4 metadata is specified by the ``NT_AMDGPU_METADATA`` note
 record (see :ref:`amdgpu-note-records-v3-v4`).
 
@@ -3279,6 +3275,10 @@ same *vendor-name*.
 Code Object V4 Metadata
 +++
 
+.. warning::
+  Code object V4 is not the default code object version emitted by this version
+  of LLVM.
+
 Code object V4 metadata is the same as
 :ref:`amdgpu-amdhsa-code-object-metadata-v3` with the changes and additions
 defined in table :ref:`amdgpu-amdhsa-code-object-metadata-map-table-v3`.



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


[PATCH] D93258: [amdgpu] Default to code object v3

2020-12-17 Thread Jon Chesterfield via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdaf39e3f2dba: [amdgpu] Default to code object v3 (authored 
by JonChesterfield).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93258

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/hip-code-object-version.hip
  llvm/docs/AMDGPUUsage.rst


Index: llvm/docs/AMDGPUUsage.rst
===
--- llvm/docs/AMDGPUUsage.rst
+++ llvm/docs/AMDGPUUsage.rst
@@ -911,12 +911,12 @@
 
   * ``ELFABIVERSION_AMDGPU_HSA_V3`` is used to specify the version of AMD HSA
 runtime ABI for code object V3. Specify using the Clang option
-``-mcode-object-version=3``.
+``-mcode-object-version=3``. This is the default code object
+version if not specified.
 
   * ``ELFABIVERSION_AMDGPU_HSA_V4`` is used to specify the version of AMD HSA
 runtime ABI for code object V4. Specify using the Clang option
-``-mcode-object-version=4``. This is the default code object
-version if not specified.
+``-mcode-object-version=4``.
 
   * ``ELFABIVERSION_AMDGPU_PAL`` is used to specify the version of AMD PAL
 runtime ABI.
@@ -2871,10 +2871,6 @@
 Code Object V3 Metadata
 +++
 
-.. warning::
-  Code object V3 is not the default code object version emitted by this version
-  of LLVM.
-
 Code object V3 to V4 metadata is specified by the ``NT_AMDGPU_METADATA`` note
 record (see :ref:`amdgpu-note-records-v3-v4`).
 
@@ -3279,6 +3275,10 @@
 Code Object V4 Metadata
 +++
 
+.. warning::
+  Code object V4 is not the default code object version emitted by this version
+  of LLVM.
+
 Code object V4 metadata is the same as
 :ref:`amdgpu-amdhsa-code-object-metadata-v3` with the changes and additions
 defined in table :ref:`amdgpu-amdhsa-code-object-metadata-map-table-v3`.
Index: clang/test/Driver/hip-code-object-version.hip
===
--- clang/test/Driver/hip-code-object-version.hip
+++ clang/test/Driver/hip-code-object-version.hip
@@ -53,7 +53,7 @@
 // RUN:   --offload-arch=gfx906 -nogpulib \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=VD %s
 
-// VD: "-mllvm" "--amdhsa-code-object-version=4"
+// VD: "-mllvm" "--amdhsa-code-object-version=3"
 // VD: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
 
 // Check invalid code object version option.
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1549,7 +1549,7 @@
 const Driver &D, const llvm::opt::ArgList &Args, bool Diagnose) {
   const unsigned MinCodeObjVer = 2;
   const unsigned MaxCodeObjVer = 4;
-  unsigned CodeObjVer = 4;
+  unsigned CodeObjVer = 3;
 
   // Emit warnings for legacy options even if they are overridden.
   if (Diagnose) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2909,7 +2909,7 @@
  HelpText<"Execution model (WebAssembly only)">;
 
 def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, 
Group,
-  HelpText<"Specify code object ABI version. Defaults to 4. (AMDGPU only)">,
+  HelpText<"Specify code object ABI version. Defaults to 3. (AMDGPU only)">,
   MetaVarName<"">, Values<"2,3,4">;
 
 def mcode_object_v3_legacy : Flag<["-"], "mcode-object-v3">, Group,


Index: llvm/docs/AMDGPUUsage.rst
===
--- llvm/docs/AMDGPUUsage.rst
+++ llvm/docs/AMDGPUUsage.rst
@@ -911,12 +911,12 @@
 
   * ``ELFABIVERSION_AMDGPU_HSA_V3`` is used to specify the version of AMD HSA
 runtime ABI for code object V3. Specify using the Clang option
-``-mcode-object-version=3``.
+``-mcode-object-version=3``. This is the default code object
+version if not specified.
 
   * ``ELFABIVERSION_AMDGPU_HSA_V4`` is used to specify the version of AMD HSA
 runtime ABI for code object V4. Specify using the Clang option
-``-mcode-object-version=4``. This is the default code object
-version if not specified.
+``-mcode-object-version=4``.
 
   * ``ELFABIVERSION_AMDGPU_PAL`` is used to specify the version of AMD PAL
 runtime ABI.
@@ -2871,10 +2871,6 @@
 Code Object V3 Metadata
 +++
 
-.. warning::
-  Code object V3 is not the default code object version emitted by this version
-  of LLVM.
-
 Code object V3 to V4 metadata is specified by the ``NT_AMDGPU_METADATA`` note
 record (see :ref:`amdgpu-note-records-v3-v4`).
 
@@ -3279,6 +3275,10 @@
 Code Object V4 Metadata
 

[PATCH] D93393: [clangd] Ignore the static index refs from the dynamic index files.

2020-12-17 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.

Fantastic, thanks so much!




Comment at: clang-tools-extra/clangd/index/Merge.cpp:129
+StaticContainsFile{Static->indexedFiles()}
+  ](llvm::StringRef FileURI) mutable {
+return DynamicContainsFile(FileURI) || StaticContainsFile(FileURI);

Currently the signature says that the returned function is not const/threadsafe.
If you prefer, you can have it be `unique_function`, 
then the contract is that it's const/threadsafe and you don't need `mutable` 
here.

Up to you though, I can't think of a case where we *need* it to be threadsafe.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93393

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


[PATCH] D93393: [clangd] Ignore the static index refs from the dynamic index files.

2020-12-17 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 312508.
ArcsinX added a comment.

Fix comment inside IndexClient::indexedFiles()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93393

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/Index.h
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/index/Merge.h
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/dex/Dex.h
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DexTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.cpp

Index: clang-tools-extra/clangd/unittests/TestFS.cpp
===
--- clang-tools-extra/clangd/unittests/TestFS.cpp
+++ clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -99,8 +99,9 @@
   llvm::Expected
   getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
   llvm::StringRef HintPath) const override {
-if (!HintPath.startswith(testRoot()))
-  return error("Hint path doesn't start with test root: {0}", HintPath);
+if (!HintPath.empty() && !HintPath.startswith(testRoot()))
+  return error("Hint path is not empty and doesn't start with {0}: {1}",
+   testRoot(), HintPath);
 if (!Body.consume_front("/"))
   return error("Body of an unittest: URI must start with '/'");
 llvm::SmallString<16> Path(Body.begin(), Body.end());
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1237,6 +1237,11 @@
 void relations(const RelationsRequest &Req,
llvm::function_ref
Callback) const override {}
+
+llvm::unique_function indexedFiles() const override {
+  return [](llvm::StringRef) { return false; };
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
   } PIndex;
   Results = rename({MainCode.point(),
@@ -1285,6 +1290,11 @@
 void relations(const RelationsRequest &,
llvm::function_ref)
 const override {}
+
+llvm::unique_function indexedFiles() const override {
+  return [](llvm::StringRef) { return false; };
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
 Ref ReturnedRef;
   } DIndex(XRefInBarCC);
Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -224,6 +224,20 @@
   EXPECT_THAT(lookup(*I, SymbolID("ns::nonono")), UnorderedElementsAre());
 }
 
+TEST(MemIndexTest, IndexedFiles) {
+  SymbolSlab Symbols;
+  RefSlab Refs;
+  auto Size = Symbols.bytes() + Refs.bytes();
+  auto Data = std::make_pair(std::move(Symbols), std::move(Refs));
+  llvm::StringSet<> Files = {testPath("foo.cc"), testPath("bar.cc")};
+  MemIndex I(std::move(Data.first), std::move(Data.second), RelationSlab(),
+ std::move(Files), std::move(Data), Size);
+  auto ContainsFile = I.indexedFiles();
+  EXPECT_TRUE(ContainsFile("unittest:///foo.cc"));
+  EXPECT_TRUE(ContainsFile("unittest:///bar.cc"));
+  EXPECT_FALSE(ContainsFile("unittest:///foobar.cc"));
+}
+
 TEST(MemIndexTest, TemplateSpecialization) {
   SymbolSlab::Builder B;
 
@@ -367,7 +381,7 @@
   Test.Code = std::string(Test1Code.code());
   Test.Filename = "test.cc";
   auto AST = Test.build();
-  Dyn.updateMain(Test.Filename, AST);
+  Dyn.updateMain(testPath(Test.Filename), AST);
 
   // Build static index for test.cc.
   Test.HeaderCode = HeaderCode;
@@ -375,7 +389,7 @@
   Test.Filename = "test.cc";
   auto StaticAST = Test.build();
   // Add stale refs for test.cc.
-  StaticIndex.updateMain(Test.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test.Filename), StaticAST);
 
   // Add refs for test2.cc
   Annotations Test2Code(R"(class $Foo[[Foo]] {};)");
@@ -384,7 +398,7 @@
   Test2.Code = std::string(Test2Code.code());
   Test2.Filename = "test2.cc";
   StaticAST = Test2.build();
-  StaticIndex.updateMain(Test2.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test2.Filename), StaticAST);
 
   RefsRequest Request;
   Request.IDs = {Foo.ID};
@@ -403,10 +417,47 @@
   RefSlab::Builder Results2;
   EXPECT_TRUE(
   Merge.refs(Request, [&](const Ref &O) { Results2.insert(Foo.ID, O); }));
-  EXPECT_THAT(std::move(Results2).build(),
-   

[PATCH] D93401: [flang][driver] Add support for `-D`, `-U`

2020-12-17 Thread Tim Keith via Phabricator via cfe-commits
tskeith added inline comments.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:228
+  // Note: GCC drops anything following an end-of-line character.
+  llvm::StringRef::size_type End = MacroBody.find_first_of("\n\r");
+  MacroBody = MacroBody.substr(0, End);

This is a change in behavior from f18, right? If so, the commit message should 
mention it and why it's changing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93401

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


[PATCH] D93428: [AArch64] Add bti note property when compiling asm files with -mbranch-protection=bti

2020-12-17 Thread Stephen Long via Phabricator via cfe-commits
steplong added a comment.

In D93428#2460032 , @danielkiss wrote:

> The `.note.gnu.property` is already generated when C/C++ files are compiled 
> with `-mbranch-protection=bti`.  
> `-mmark-bti-property` is only for assembly file where the 
> `.note.gnu.property` should be added manually otherwise.
>
> Do you have any reproducer where C/C++ behaves unexpectedly?

I think Ana misunderstood the reason for this patch. We haven't seen any 
compilation of C/C++ behaving unexpectedly. -mbranch-protection=bti generates 
the .nute.gnu.property for C/C++ files from our experiments, but doesn't work 
for assembly files. Is there a reason why assembly files have a different flag 
(i.e. -mmark-bti-property) to create the .note.gnu.property with the BTI entry?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93428

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


[PATCH] D93459: Fix -Wno-error= parsing in clang-format.

2020-12-17 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor updated this revision to Diff 312518.
fodinabor added a comment.

Add lit test to ensure behaviour of the -Wno-error=unkown flag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93459

Files:
  clang/test/Format/error-config.cpp
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -104,18 +104,6 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
-// using the full param name as Wno-error probably won't be a common use case 
in
-// clang-format
-static cl::opt AllowUnknownOptions(
-"Wno-error=unknown",
-cl::desc("If set, unknown format options are only warned about.\n"
- "This can be used to enable formatting, even if the\n"
- "configuration contains unknown (newer) options.\n"
- "Use with caution, as this might lead to dramatically\n"
- "differing format depending on an option being\n"
- "supported or not."),
-cl::init(false), cl::cat(ClangFormatCategory));
-
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -156,6 +144,23 @@
  cl::desc("If set, changes formatting warnings to errors"),
  cl::cat(ClangFormatCategory));
 
+namespace {
+enum class WNoError { Unknown };
+}
+
+static cl::bits WNoErrorList(
+"Wno-error",
+cl::desc("If set don't error out on the specified warning type."),
+cl::values(
+clEnumValN(WNoError::Unknown, "unknown",
+   "If set, unknown format options are only warned about.\n"
+   "This can be used to enable formatting, even if the\n"
+   "configuration contains unknown (newer) options.\n"
+   "Use with caution, as this might lead to dramatically\n"
+   "differing format depending on an option being\n"
+   "supported or not.")),
+cl::cat(ClangFormatCategory));
+
 static cl::opt
 ShowColors("fcolor-diagnostics",
cl::desc("If set, and on a color-capable terminal controls "
@@ -391,7 +396,7 @@
 
   llvm::Expected FormatStyle =
   getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer(),
-   nullptr, AllowUnknownOptions.getValue());
+   nullptr, WNoErrorList.isSet(WNoError::Unknown));
   if (!FormatStyle) {
 llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
 return true;
Index: clang/test/Format/error-config.cpp
===
--- /dev/null
+++ clang/test/Format/error-config.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-format %s --Wno-error=unknown --style="{UnknownKey: true}" 2>&1 
| FileCheck %s -check-prefix=CHECK
+// RUN: not clang-format %s --style="{UnknownKey: true}" 2>&1 | FileCheck %s 
-check-prefix=CHECK-FAIL
+
+// CHECK: YAML:1:2: warning: unknown key 'UnknownKey'
+// CHECK-NEXT: {UnknownKey: true}
+// CHECK-NEXT: ^~
+// CHECK-FAIL: YAML:1:2: error: unknown key 'UnknownKey'
+// CHECK-FAIL-NEXT: {UnknownKey: true}
+// CHECK-FAIL-NEXT: ^~
+
+int i ;


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -104,18 +104,6 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
-// using the full param name as Wno-error probably won't be a common use case in
-// clang-format
-static cl::opt AllowUnknownOptions(
-"Wno-error=unknown",
-cl::desc("If set, unknown format options are only warned about.\n"
- "This can be used to enable formatting, even if the\n"
- "configuration contains unknown (newer) options.\n"
- "Use with caution, as this might lead to dramatically\n"
- "differing format depending on an option being\n"
- "supported or not."),
-cl::init(false), cl::cat(ClangFormatCategory));
-
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -156,6 +144,23 @@
  cl::desc("If set, changes formatting warnings to errors"),
  cl::cat(ClangFormatCategory));
 
+namespace {
+enum class WNoError { Unknown };
+}
+
+static cl::bits WNoErrorList(
+"Wno-error",
+cl::desc("If set don't error out on the specified warning type."),
+cl::values(
+clEnumValN(WNoError::Unknown, "unknown",
+   "If set, unknown format options are only warned about.\n"
+   "This can be used to enable formatting, even if 

[PATCH] D93453: [flang][driver] Add support for `-I`

2020-12-17 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

Hi @FarisRehman ! Thank you for working on this! Could you add tests?




Comment at: clang/lib/Driver/ToolChains/Flang.cpp:75
 
+  Args.AddAllArgs(CmdArgs, options::OPT_I);
+

This would ideally go to a dedicated method for parsing preprocessor options.



Comment at: flang/include/flang/Frontend/PreprocessorOptions.h:13
   std::vector> Macros;
+  std::vector SearchDirectoriesFromI;
 

[nit] I'd be tempted to be more explicit here, e.g. 
`SearchDirectoriesFromDashI;`.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:170
+  // Add the ordered list of -I's.
+  for (const auto *A : args.filtered(clang::driver::options::OPT_I))
+opts.SearchDirectoriesFromI.emplace_back(A->getValue());

Lower case, sadly.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:240-243
-  // These defaults are based on the defaults in f18/f18.cpp.
-  std::vector searchDirectories{"."s};
-  fortranOptions.searchDirectories = searchDirectories;
   fortranOptions.isFixedForm = false;

_Moving_ this code seems like _unrelated_ change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93453

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


[PATCH] D93452: [clangd] Trim memory after buildINdex

2020-12-17 Thread Quentin Chateau via Phabricator via cfe-commits
qchateau planned changes to this revision.
qchateau added a comment.

> Periodic malloc_trim seems like it solves a real problem, one I don't 
> personally fully understand but we may never do - I feel convinced we should 
> use it anyway. It probably has some overhead, who knows how much.

It does indeed look like facing the problem from the wrong side (fight the end 
result instead of finding the root cause) but at that point it does solve an 
annoying problem. As I investigated this, I found that replacing `DenseMap` and 
`StringMap` wtih `std::map` mitigates the issue. I think allocating huge chunks 
of contiguous memory temporarily make this issue worse. Not very useful, but 
hey, I'm just sharing what I observed. As I previously said, resolving this 
problem by changing containers or allocators is a lot of work and is not 
guaranteed to actually solve the issue.

> It's process-wide (not per-thread, and certainly not per-program-module) so 
> the fact that slapping it in FileSymbols::buildIndex solves the problem only 
> proves that function is called periodically :-)
> This is a system-level function, I think we should probably be calling it 
> periodically from something top-level like ClangdMain or ClangdLSPServer.
> (We could almost slip it in with ClangdLSPServer::maybeExportMemoryProfile(), 
> except we don't want to link it to incoming notifications as memory can 
> probably grow while silently background indexing)

It can indeed be called somewhere else, I tried a few different placed before 
submitting this diff. That can be change easily, it's not a problem. I'd also 
like to see it at higher level: my first implementation called it periodically, 
inspired from `maybeExportMemoryProfile`, but I got worried by the background 
index filling the RAM while the user is not in front of his computer, 
`onBackgroundIndexProgress` should address this issue.

> I think we should pass a nonzero `pad` to malloc_trim of several MB. It only 
> affects the main thread, but the main thread is constantly allocating small 
> short-lived objects (e.g. JSON encoding/decoding) and cutting it to the bone 
> only to have it sbrk again seems pointless.

Good point


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93452

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


[clang] f500662 - Detect section type conflicts between functions and variables

2020-12-17 Thread Aaron Ballman via cfe-commits

Author: Tomas Matheson
Date: 2020-12-17T11:43:47-05:00
New Revision: f50066292477fb26806336e5604615d0eddde399

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

LOG: Detect section type conflicts between functions and variables

If two variables are declared with __attribute__((section(name))) and
the implicit section types (e.g. read only vs writeable) conflict, an
error is raised. Extend this mechanism so that an error is raised if the
section type implied by a function's __attribute__((section)) conflicts
with that of another variable.

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/CodeGen/attributes.c
clang/test/Sema/attr-section.c
clang/test/SemaCXX/attr-section.cpp
clang/test/SemaObjC/method-attributes.m

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index ff84eb52e96e..0c5d82b3e9aa 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -3086,13 +3086,12 @@ OPT_LIST(V)
   };
 
   struct SectionInfo {
-DeclaratorDecl *Decl;
+NamedDecl *Decl;
 SourceLocation PragmaSectionLocation;
 int SectionFlags;
 
 SectionInfo() = default;
-SectionInfo(DeclaratorDecl *Decl,
-SourceLocation PragmaSectionLocation,
+SectionInfo(NamedDecl *Decl, SourceLocation PragmaSectionLocation,
 int SectionFlags)
 : Decl(Decl), PragmaSectionLocation(PragmaSectionLocation),
   SectionFlags(SectionFlags) {}

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index ff0257634d9d..6b81494e8eff 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -9757,9 +9757,8 @@ class Sema final {
 PSK_CodeSeg,
   };
 
-  bool UnifySection(StringRef SectionName,
-int SectionFlags,
-DeclaratorDecl *TheDecl);
+  bool UnifySection(StringRef SectionName, int SectionFlags,
+NamedDecl *TheDecl);
   bool UnifySection(StringRef SectionName,
 int SectionFlags,
 SourceLocation PragmaSectionLocation);

diff  --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index ae6c3ea7313e..5901bd66b7a6 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -481,9 +481,8 @@ void Sema::ActOnPragmaMSVtorDisp(PragmaMsStackAction Action,
   VtorDispStack.Act(PragmaLoc, Action, StringRef(), Mode);
 }
 
-bool Sema::UnifySection(StringRef SectionName,
-int SectionFlags,
-DeclaratorDecl *Decl) {
+bool Sema::UnifySection(StringRef SectionName, int SectionFlags,
+NamedDecl *Decl) {
   SourceLocation PragmaLocation;
   if (auto A = Decl->getAttr())
 if (A->isImplicit())

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 954388dda82e..7750d713f927 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3081,8 +3081,14 @@ static void handleSectionAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
   }
 
   SectionAttr *NewAttr = S.mergeSectionAttr(D, AL, Str);
-  if (NewAttr)
+  if (NewAttr) {
 D->addAttr(NewAttr);
+if (isa(D))
+  S.UnifySection(NewAttr->getName(),
+ ASTContext::PSF_Execute | ASTContext::PSF_Read,
+ cast(D));
+  }
 }
 
 // This is used for `__declspec(code_seg("segname"))` on a decl.

diff  --git a/clang/test/CodeGen/attributes.c b/clang/test/CodeGen/attributes.c
index f6323e9be548..0c1455d3c612 100644
--- a/clang/test/CodeGen/attributes.c
+++ b/clang/test/CodeGen/attributes.c
@@ -63,11 +63,11 @@ void t72() { t71(); }
 // CHECK: call void @t71() [[COLDSITE:#[0-9]+]]
 // CHECK: declare void @t71() [[COLDDECL:#[0-9]+]]
 
-// CHECK: define void @t10() [[NUW]] section "SECT" {
-void t10(void) __attribute__((section("SECT")));
+// CHECK: define void @t10() [[NUW]] section "xSECT" {
+void t10(void) __attribute__((section("xSECT")));
 void t10(void) {}
-// CHECK: define void @t11() [[NUW]] section "SECT" {
-void __attribute__((section("SECT"))) t11(void) {}
+// CHECK: define void @t11() [[NUW]] section "xSECT" {
+void __attribute__((section("xSECT"))) t11(void) {}
 
 // CHECK: define i32 @t19() [[NUW]] {
 extern int t19(void) __attribute__((weak_import));

diff  --git a/clang/test/Sema/attr-section.c b/clang/test/Sema/attr-section.c
index bc4247411130..509c9752d8c3 100644
--- a/clang/test/Sema/attr-section.c
+++ b/clang/test/Sema/attr-section.c
@@ -26,9 +26,27 @@ extern int a __attribute__((section("foo,zed"))); // 
expected-warning {{section
 
 //

[PATCH] D93102: [Clang][Sema] Detect section type conflicts between functions and variables

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

In D93102#2460034 , @tmatheson wrote:

> In D93102#2458433 , @aaron.ballman 
> wrote:
>
>> LGTM aside from a minor nit. Thank you for the patch! Do you need me to 
>> commit on your behalf? If so, are you okay with `Tomas Matheson 
>> ` for patch attribution?
>
> Thanks for the review. I will ask for commit access for future but if you 
> could commit this one in the meantime that would be appreciated. That's fine 
> for attribution.

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93102

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


[PATCH] D93428: [AArch64] Add bti note property when compiling asm files with -mbranch-protection=bti

2020-12-17 Thread Ana Pazos via Phabricator via cfe-commits
apazos added a comment.

Thanks for clarifying - so the property is being set for C/C++ files but not 
for assembly files. I think it should be set automatically for both when one 
uses clang driver to compile/assemble.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93428

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


[PATCH] D84669: [clang][cli] Port CodeGenOpts simple string flags to new option parsing system

2020-12-17 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

lgtm with the comment.




Comment at: clang/include/clang/Driver/Options.td:2123-2125
 def fpatchable_function_entry_EQ : Joined<["-"], 
"fpatchable-function-entry=">, Group, Flags<[CC1Option]>,
-  MetaVarName<"">, HelpText<"Generate M NOPs before function entry and 
N-M NOPs after function entry">;
+  MetaVarName<"">, HelpText<"Generate M NOPs before function entry and 
N-M NOPs after function entry">,
+  MarshallingInfoStringInt<"CodeGenOpts.PatchableFunctionEntryCount">;

This should have a comment saying that the cc1 semantics are different from the 
driver semantics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84669

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


[PATCH] D93464: [analyzer] Refine suppression mechanism to better support AST checks

2020-12-17 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
Herald added subscribers: steakhal, ASDenysPetrov, martong, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun, mgorny.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This commit slightly changes the way suppressions were checked before.
Instead of going up from statements and expressions, where bugs were
found, and looking for statements and declarations with attributes,
we traverse function bodies once and map locations with suppressions.

This approach can help with the majority of AST checks that report
directly on source locations.  It is not trivial to map locations
back to nodes, so its much easier to map both nodes and suppressions
to locations and reason only on that level.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93464

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugSuppression.h
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/BugSuppression.cpp
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/test/Analysis/suppression-attr.m

Index: clang/test/Analysis/suppression-attr.m
===
--- clang/test/Analysis/suppression-attr.m
+++ clang/test/Analysis/suppression-attr.m
@@ -2,6 +2,9 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=osx.cocoa.MissingSuperCall \
 // RUN:   -analyzer-checker=osx.cocoa.NSError \
+// RUN:   -analyzer-checker=osx.ObjCProperty \
+// RUN:   -analyzer-checker=osx.cocoa.RetainCount \
+// RUN:   -analyzer-checker=alpha.core.CastToStruct \
 // RUN:   -Wno-unused-value -Wno-objc-root-class -verify %s
 
 #define SUPPRESS __attribute__((suppress))
@@ -31,6 +34,9 @@
 + (id)errorWithDomain:(NSString *)domain code:(NSInteger)code userInfo:(NSDictionary *)dict;
 @end
 
+@interface NSMutableString : NSObject
+@end
+
 void dereference_1() {
   int *x = 0;
   *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
@@ -77,6 +83,28 @@
   SUPPRESS int y = *x; // no-warning
 }
 
+void retain_release_leak_1() {
+  [[NSMutableString alloc] init]; // expected-warning{{Potential leak of an object of type 'NSMutableString *'}}
+}
+
+void retain_release_leak_suppression_1() {
+  SUPPRESS { [[NSMutableString alloc] init]; }
+}
+
+void retain_release_leak_2(int cond) {
+  id obj = [[NSMutableString alloc] init]; // expected-warning{{Potential leak of an object stored into 'obj'}}
+  if (cond) {
+[obj release];
+  }
+}
+
+void retain_release_leak__suppression_2(int cond) {
+  SUPPRESS id obj = [[NSMutableString alloc] init];
+  if (cond) {
+[obj release];
+  }
+}
+
 @interface UIResponder : NSObject {
 }
 - (char)resignFirstResponder;
@@ -84,6 +112,7 @@
 
 @interface Test : UIResponder {
 }
+@property(copy) NSMutableString *mutableStr; // expected-warning{{Property of mutable type 'NSMutableString' has 'copy' attribute; an immutable object will be stored instead}}
 @end
 @implementation Test
 
@@ -98,6 +127,7 @@
 
 @interface TestSuppress : UIResponder {
 }
+@property(copy) SUPPRESS NSMutableString *mutableStr;
 @end
 @implementation TestSuppress
 
@@ -108,3 +138,23 @@
 - (void)methodWhichMayFail:(NSError **)error SUPPRESS { // no-warning
 }
 @end
+
+struct AB {
+  int A, B;
+};
+
+struct ABC {
+  int A, B, C;
+};
+
+void ast_checker_1() {
+  struct AB Ab;
+  struct ABC *Abc;
+  Abc = (struct ABC *)&Ab; // expected-warning {{Casting data to a larger structure type and accessing a field can lead to memory access errors or data corruption}}
+}
+
+void ast_checker_suppress_1() {
+  struct AB Ab;
+  struct ABC *Abc;
+  SUPPRESS { Abc = (struct ABC *)&Ab; }
+}
Index: clang/lib/StaticAnalyzer/Core/CMakeLists.txt
===
--- clang/lib/StaticAnalyzer/Core/CMakeLists.txt
+++ clang/lib/StaticAnalyzer/Core/CMakeLists.txt
@@ -11,6 +11,7 @@
   BlockCounter.cpp
   BugReporter.cpp
   BugReporterVisitors.cpp
+  BugSuppression.cpp
   CallEvent.cpp
   Checker.cpp
   CheckerContext.cpp
Index: clang/lib/StaticAnalyzer/Core/BugSuppression.cpp
===
--- /dev/null
+++ clang/lib/StaticAnalyzer/Core/BugSuppression.cpp
@@ -0,0 +1,184 @@
+//===- BugSuppression.cpp - Suppression interface -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/StaticAnalyzer/Core/BugReporter/BugSuppression.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+
+using names

[PATCH] D92290: [clangd] Use clangd's Context mechanism to make the ASTContext of the AST being operated on available everywhere

2020-12-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Sorry for taking a while to get to this...

I'm not sure this is really a helpful use of Context. (Though some would argue 
that there are no good uses, my manager was appalled when we added it...)
Does this enable some future work, or is it reasonable to evaluate this patch 
in isolation?

There's of course no hard-and-fast rules but my checklist is:

- is this some kind of optional input, like overriding some behavior? (i.e. 
forgetting it isn't terrible, and we needn't burden all callers)
- does the parameter otherwise need to be plumbed through many layers, most of 
which don't use it?
- will parameter otherwise need to be added to public interfaces where they 
don't make sense?

Here it's a mandatory input, and the alternative is cluttering a couple of 
layers of purely-private interfaces, so this seems like a lot of magic to avoid 
a fairly small amount of awkwardness.

(The original use cases for context were around VFS state for embedders, where 
*all* these things were true - the lspEncoding() is another place where this is 
IMO a pretty good tradeoff)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92290

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


[PATCH] D93393: [clangd] Ignore the static index refs from the dynamic index files.

2020-12-17 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 312530.
ArcsinX added a comment.

`unique_function indexedFiles() const` => 
`unique_function indexedFiles() const`
`StringRef` => `llvm::StringRef` for consistency


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93393

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/Index.h
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/index/Merge.h
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/dex/Dex.h
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DexTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.cpp

Index: clang-tools-extra/clangd/unittests/TestFS.cpp
===
--- clang-tools-extra/clangd/unittests/TestFS.cpp
+++ clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -99,8 +99,9 @@
   llvm::Expected
   getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
   llvm::StringRef HintPath) const override {
-if (!HintPath.startswith(testRoot()))
-  return error("Hint path doesn't start with test root: {0}", HintPath);
+if (!HintPath.empty() && !HintPath.startswith(testRoot()))
+  return error("Hint path is not empty and doesn't start with {0}: {1}",
+   testRoot(), HintPath);
 if (!Body.consume_front("/"))
   return error("Body of an unittest: URI must start with '/'");
 llvm::SmallString<16> Path(Body.begin(), Body.end());
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1237,6 +1237,12 @@
 void relations(const RelationsRequest &Req,
llvm::function_ref
Callback) const override {}
+
+llvm::unique_function
+indexedFiles() const override {
+  return [](llvm::StringRef) { return false; };
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
   } PIndex;
   Results = rename({MainCode.point(),
@@ -1285,6 +1291,12 @@
 void relations(const RelationsRequest &,
llvm::function_ref)
 const override {}
+
+llvm::unique_function
+indexedFiles() const override {
+  return [](llvm::StringRef) { return false; };
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
 Ref ReturnedRef;
   } DIndex(XRefInBarCC);
Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -224,6 +224,20 @@
   EXPECT_THAT(lookup(*I, SymbolID("ns::nonono")), UnorderedElementsAre());
 }
 
+TEST(MemIndexTest, IndexedFiles) {
+  SymbolSlab Symbols;
+  RefSlab Refs;
+  auto Size = Symbols.bytes() + Refs.bytes();
+  auto Data = std::make_pair(std::move(Symbols), std::move(Refs));
+  llvm::StringSet<> Files = {testPath("foo.cc"), testPath("bar.cc")};
+  MemIndex I(std::move(Data.first), std::move(Data.second), RelationSlab(),
+ std::move(Files), std::move(Data), Size);
+  auto ContainsFile = I.indexedFiles();
+  EXPECT_TRUE(ContainsFile("unittest:///foo.cc"));
+  EXPECT_TRUE(ContainsFile("unittest:///bar.cc"));
+  EXPECT_FALSE(ContainsFile("unittest:///foobar.cc"));
+}
+
 TEST(MemIndexTest, TemplateSpecialization) {
   SymbolSlab::Builder B;
 
@@ -367,7 +381,7 @@
   Test.Code = std::string(Test1Code.code());
   Test.Filename = "test.cc";
   auto AST = Test.build();
-  Dyn.updateMain(Test.Filename, AST);
+  Dyn.updateMain(testPath(Test.Filename), AST);
 
   // Build static index for test.cc.
   Test.HeaderCode = HeaderCode;
@@ -375,7 +389,7 @@
   Test.Filename = "test.cc";
   auto StaticAST = Test.build();
   // Add stale refs for test.cc.
-  StaticIndex.updateMain(Test.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test.Filename), StaticAST);
 
   // Add refs for test2.cc
   Annotations Test2Code(R"(class $Foo[[Foo]] {};)");
@@ -384,7 +398,7 @@
   Test2.Code = std::string(Test2Code.code());
   Test2.Filename = "test2.cc";
   StaticAST = Test2.build();
-  StaticIndex.updateMain(Test2.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test2.Filename), StaticAST);
 
   RefsRequest Request;
   Request.IDs = {Foo.ID};
@@ -403,10 +417,47 @@
   RefSlab::Builder Results2;
   EXPECT_TRUE(
   Merge.refs(Request, [&](con

[PATCH] D84668: [clang][cli] Port TargetOpts simple string based options to new option parsing system

2020-12-17 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

lgtm with the fix above.




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:264-265
 
+template ::value, bool> = true>
+static void denormalizeSimpleEnum(SmallVectorImpl &Args,

jansvoboda11 wrote:
> dexonsmith wrote:
> > Once the template is gone from the `unsigned` overload above, I wonder if 
> > we can use `!std::is_convertible` here, and let the `unsigned` 
> > overload directly catch any enums that aren't strongly typed.
> Unfortunately, `std::is_convertible::value == false` when `T` is 
> an `enum class` (and it's the same for `std::is_constructible T>::value`): .
> 
> I didn't find any type trait in the standard library that would have the same 
> semantics as `static_cast`, but we could use something like 
> this: .
I would suggest instead to just rename the `unsigned` version to 
`denormalizeSimpleEnumImpl` and removing the constraints on this one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84668

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


[PATCH] D93393: [clangd] Ignore the static index refs from the dynamic index files.

2020-12-17 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX marked an inline comment as done.
ArcsinX added a comment.

Thank you for review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93393

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


[PATCH] D84670: [clang][cli] Port HeaderSearch simple string options to new option parsing system

2020-12-17 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

lgtm with nit.




Comment at: clang/include/clang/Driver/Options.td:1815
+  HelpText<"Specify the interval (in seconds) after which a module file will 
be considered unused">,
+  MarshallingInfoStringInt<"HeaderSearchOpts->ModuleCachePruneAfter", "31 * 24 
*60 * 60">;
 def fmodules_search_all : Flag <["-"], "fmodules-search-all">, Group,

Missing a space.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84670

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


[PATCH] D93458: clang-cl: Remove /Zd flag

2020-12-17 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks accepted this revision.
aeubanks added a comment.
This revision is now accepted and ready to land.

lgtm, but perhaps Reid should take a look




Comment at: clang/docs/ReleaseNotes.rst:127
+
+- clang-cl's ``/Zd`` flag no longer exist. But ``-gline-tables-only`` still
+  exists and does the same thing.




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

https://reviews.llvm.org/D93458

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


[PATCH] D84671: [clang][cli] Port LangOpts simple string based options to new option parsing system

2020-12-17 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese 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/D84671/new/

https://reviews.llvm.org/D84671

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


[PATCH] D93079: [OpenMP] Introduce an assumption to ignore possible external callers

2020-12-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 312535.
jdoerfert added a comment.

Rebase on top of D93439 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93079

Files:
  clang/include/clang/Basic/AttrDocs.td
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/test/Transforms/OpenMP/gpu_state_machine_function_ptr_replacement.ll
  openmp/docs/remarks/OptimizationRemarks.rst

Index: openmp/docs/remarks/OptimizationRemarks.rst
===
--- openmp/docs/remarks/OptimizationRemarks.rst
+++ openmp/docs/remarks/OptimizationRemarks.rst
@@ -25,6 +25,13 @@
 modify the linkage and thereby help optimization with a `static` or
 `__attribute__((internal))` function annotation. If changing the linkage is
 impossible, e.g., because there are outside callers on the host, one can split
-the function into an external visible interface which is not compiled for
-the target and an internal implementation which is compiled for the target
-and should be called from within the target region.
+the function into an external visible interface which is not compiled for the
+target and an internal implementation which is compiled for the target and
+should be called from within the target region. Finally,  we provide an
+assumption for the target side which can be spelled either as
+`__attribute__((assume("omp_no_external_caller_in_target_region")))` or as
+OpenMP assumption, i.a., `#pragma omp begin assume
+ext_no_external_caller_in_target_region`. The assumption effectively allows the
+compiler to assume no caller outside the current translation unit will call the
+function from a target region, hence the function is not called from outside
+translation units on the device.
Index: llvm/test/Transforms/OpenMP/gpu_state_machine_function_ptr_replacement.ll
===
--- llvm/test/Transforms/OpenMP/gpu_state_machine_function_ptr_replacement.ll
+++ llvm/test/Transforms/OpenMP/gpu_state_machine_function_ptr_replacement.ll
@@ -7,12 +7,18 @@
 ; #pragma omp parallel
 ; { }
 ; }
+; __attribute__((assume("no_external_callers")))
+; void baz(void) {
+; #pragma omp parallel
+; { }
+; }
 ; void foo(void) {
 ;   #pragma omp target teams
 ;   {
 ; #pragma omp parallel
 ; {}
 ; bar();
+; baz();
 ; #pragma omp parallel
 ; {}
 ;   }
@@ -23,13 +29,16 @@
 ; another kernel.
 
 ; CHECK-DAG: @__omp_outlined__1_wrapper.ID = private constant i8 undef
+; CHECK-DAG: @__omp_outlined__2b_wrapper.ID = private constant i8 undef
 ; CHECK-DAG: @__omp_outlined__3_wrapper.ID = private constant i8 undef
 
 ; CHECK-DAG:   icmp eq i8* %5, @__omp_outlined__1_wrapper.ID
+; CHECK-DAG:   icmp eq i8* %b6, @__omp_outlined__2b_wrapper.ID
 ; CHECK-DAG:   icmp eq i8* %7, @__omp_outlined__3_wrapper.ID
 
 ; CHECK-DAG:   call void @__kmpc_kernel_prepare_parallel(i8* @__omp_outlined__1_wrapper.ID)
-; CHECK-DAG:   call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void ()* @__omp_outlined__2_wrapper to i8*))
+; CHECK-DAG:   call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void ()* @__omp_outlined__2a_wrapper to i8*))
+; CHECK-DAG:   call void @__kmpc_kernel_prepare_parallel(i8* @__omp_outlined__2b_wrapper.ID)
 ; CHECK-DAG:   call void @__kmpc_kernel_prepare_parallel(i8* @__omp_outlined__3_wrapper.ID)
 
 
@@ -69,11 +78,20 @@
 
 .check.next:  ; preds = %.execute.parallel
   %6 = load i8*, i8** %work_fn, align 8
-  %work_match1 = icmp eq i8* %6, bitcast (void ()* @__omp_outlined__2_wrapper to i8*)
-  br i1 %work_match1, label %.execute.fn2, label %.check.next3
+  %work_match1 = icmp eq i8* %6, bitcast (void ()* @__omp_outlined__2a_wrapper to i8*)
+  br i1 %work_match1, label %.execute.fn2a, label %.check.next2
+
+.execute.fn2a: ; preds = %.check.next
+  call void @__omp_outlined__2a_wrapper()
+  br label %.terminate.parallel
+
+.check.next2:  ; preds = %.execute.parallel
+  %b6 = load i8*, i8** %work_fn, align 8
+  %work_match1b = icmp eq i8* %b6, bitcast (void ()* @__omp_outlined__2b_wrapper to i8*)
+  br i1 %work_match1b, label %.execute.fn2b, label %.check.next3
 
-.execute.fn2: ; preds = %.check.next
-  call void @__omp_outlined__2_wrapper()
+.execute.fn2b: ; preds = %.check.next
+  call void @__omp_outlined__2b_wrapper()
   br label %.terminate.parallel
 
 .check.next3: ; preds = %.check.next
@@ -111,6 +129,7 @@
 define internal void @__omp_outlined__() {
   call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void ()* @__omp_outlined__1_wrapper to i8*))
   call void @bar()
+  call void @baz()
   call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void ()* @__omp_outlined__3_wrapper to i8*))
   ret

[PATCH] D84672: [clang][cli] Port PreprocessorOpts simple string based options to new option parsing system

2020-12-17 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese 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/D84672/new/

https://reviews.llvm.org/D84672

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


[PATCH] D93436: [clangd] Print .clang-tidy configuration parsing errors using [ev]?log.

2020-12-17 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.

Nice! From here it seems like mostly a question of plumbing/refactoring on the 
clangd side to be able to surface these diagnostics, similar to how you did it 
with config files.

At some point, particularly if we also support .clang-format files, it might 
even be worth reconsidering if there's a lightweight way to become a 
language-server for such files. Less in order to provide quickfixes and code 
completion (which would be huge effort), and more to be able to surface 
diagnostics for files that are opened in the editor (rather than waiting until 
clangd tries to parse them for some other reason)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93436

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


[PATCH] D93395: [clang][cli] Remove -f[no-]trapping-math from -cc1 command line

2020-12-17 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added a comment.

This looks fine to be as that code is definitely dead. I would wait for 
@SjoerdMeijer in case there's a bug in the existing code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93395

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


[PATCH] D93393: [clangd] Ignore the static index refs from the dynamic index files.

2020-12-17 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 312538.
ArcsinX added a comment.

`StringRef` => `llvm::StringRef` in one more place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93393

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/Index.h
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/MemIndex.h
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/index/Merge.h
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/dex/Dex.h
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DexTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.cpp

Index: clang-tools-extra/clangd/unittests/TestFS.cpp
===
--- clang-tools-extra/clangd/unittests/TestFS.cpp
+++ clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -99,8 +99,9 @@
   llvm::Expected
   getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
   llvm::StringRef HintPath) const override {
-if (!HintPath.startswith(testRoot()))
-  return error("Hint path doesn't start with test root: {0}", HintPath);
+if (!HintPath.empty() && !HintPath.startswith(testRoot()))
+  return error("Hint path is not empty and doesn't start with {0}: {1}",
+   testRoot(), HintPath);
 if (!Body.consume_front("/"))
   return error("Body of an unittest: URI must start with '/'");
 llvm::SmallString<16> Path(Body.begin(), Body.end());
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1237,6 +1237,12 @@
 void relations(const RelationsRequest &Req,
llvm::function_ref
Callback) const override {}
+
+llvm::unique_function
+indexedFiles() const override {
+  return [](llvm::StringRef) { return false; };
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
   } PIndex;
   Results = rename({MainCode.point(),
@@ -1285,6 +1291,12 @@
 void relations(const RelationsRequest &,
llvm::function_ref)
 const override {}
+
+llvm::unique_function
+indexedFiles() const override {
+  return [](llvm::StringRef) { return false; };
+}
+
 size_t estimateMemoryUsage() const override { return 0; }
 Ref ReturnedRef;
   } DIndex(XRefInBarCC);
Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -224,6 +224,20 @@
   EXPECT_THAT(lookup(*I, SymbolID("ns::nonono")), UnorderedElementsAre());
 }
 
+TEST(MemIndexTest, IndexedFiles) {
+  SymbolSlab Symbols;
+  RefSlab Refs;
+  auto Size = Symbols.bytes() + Refs.bytes();
+  auto Data = std::make_pair(std::move(Symbols), std::move(Refs));
+  llvm::StringSet<> Files = {testPath("foo.cc"), testPath("bar.cc")};
+  MemIndex I(std::move(Data.first), std::move(Data.second), RelationSlab(),
+ std::move(Files), std::move(Data), Size);
+  auto ContainsFile = I.indexedFiles();
+  EXPECT_TRUE(ContainsFile("unittest:///foo.cc"));
+  EXPECT_TRUE(ContainsFile("unittest:///bar.cc"));
+  EXPECT_FALSE(ContainsFile("unittest:///foobar.cc"));
+}
+
 TEST(MemIndexTest, TemplateSpecialization) {
   SymbolSlab::Builder B;
 
@@ -367,7 +381,7 @@
   Test.Code = std::string(Test1Code.code());
   Test.Filename = "test.cc";
   auto AST = Test.build();
-  Dyn.updateMain(Test.Filename, AST);
+  Dyn.updateMain(testPath(Test.Filename), AST);
 
   // Build static index for test.cc.
   Test.HeaderCode = HeaderCode;
@@ -375,7 +389,7 @@
   Test.Filename = "test.cc";
   auto StaticAST = Test.build();
   // Add stale refs for test.cc.
-  StaticIndex.updateMain(Test.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test.Filename), StaticAST);
 
   // Add refs for test2.cc
   Annotations Test2Code(R"(class $Foo[[Foo]] {};)");
@@ -384,7 +398,7 @@
   Test2.Code = std::string(Test2Code.code());
   Test2.Filename = "test2.cc";
   StaticAST = Test2.build();
-  StaticIndex.updateMain(Test2.Filename, StaticAST);
+  StaticIndex.updateMain(testPath(Test2.Filename), StaticAST);
 
   RefsRequest Request;
   Request.IDs = {Foo.ID};
@@ -403,10 +417,47 @@
   RefSlab::Builder Results2;
   EXPECT_TRUE(
   Merge.refs(Request, [&](const Ref &O) { Results2.insert(Foo.ID, O); }));
-  EXPECT_THAT(std::move(Results2

[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-12-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Oh yes, somehow I overlooked that, sorry.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2020-12-17 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

In D92361#2459655 , @rjmccall wrote:

> In D92361#2459513 , @zoecarver wrote:
>
>>> I think that as long as the class leaves a copy/move constructor defaulted, 
>>> there's no need for a new trivial_abi attribute.
>>
>> Sorry, I'm not sure I follow. Could you elaborate a bit or provide an 
>> example? What do you mean by "new" trivial_abi attribute?
>
> Sorry, I mean that I think Akira's example should be passed directly.  It 
> shouldn't require its own trivial_abi attribute in order to get the treatment.

No worries. I understand now. The problem we're discussing actually has nothing 
to do with the trivial-abi attribute. We just need to make sure that 
non-trival-abi types are not affected by this change (and it appears they were).




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:6502
+  // except that it has a non-trivial member *with* the trivial_abi attribute.
+  for (auto Base : D->bases()) {
+if (auto CxxRecord = Base.getType()->getAsCXXRecordDecl())

Quuxplusone wrote:
> zoecarver wrote:
> > ahatanak wrote:
> > > zoecarver wrote:
> > > > ahatanak wrote:
> > > > > It looks like this patch changes the way `D` is passed in the 
> > > > > following code:
> > > > > 
> > > > > ```
> > > > > struct B {
> > > > >   int i[4];
> > > > >   B();
> > > > >   B(const B &) = default;
> > > > >   B(B &&);
> > > > > };
> > > > > 
> > > > > struct D : B {
> > > > >   D();
> > > > >   D(const D &) = default;
> > > > >   D(D &&) = delete;
> > > > > };
> > > > > 
> > > > > void testB(B a);
> > > > > void testD(D a);
> > > > > 
> > > > > void testCallB() {
> > > > >   B b;
> > > > >   testB(b);
> > > > > }
> > > > > 
> > > > > void testCallD() {
> > > > >   D d;
> > > > >   testD(d);
> > > > > }
> > > > > ```
> > > > > 
> > > > > `B` cannot be passed in registers because it has a non-trivial move 
> > > > > constructor, whereas `D` can be passed in registers because the move 
> > > > > constructor is deleted and the copy constructor is trivial.
> > > > > 
> > > > > I'm not sure what the best way to handle this is, but I just wanted 
> > > > > to point this out.
> > > > Hmm. Good catch. One way to fix this would be to simply create a 
> > > > `HasPassableSubobject` variable and add that to the conditions below 
> > > > (instead of returning false here). But, it seems that `D` isn't passed 
> > > > by registers (even though, maybe it should be) on ToT: 
> > > > https://godbolt.org/z/4xevW5 
> > > > 
> > > > Given that, do you think it's OK to return false here, or should I 
> > > > update this patch to use the logic I just described (even though that 
> > > > would be a nfc)? 
> > > The argument is byval, so `D` is passed directly. If you remove `-O3` and 
> > > add `-target aarch64`, you'll see that `[2 x i64]` is being passed
> > Ah, I see now. Great. Thanks. I'll update the patch. 
> Akira's example is legal C++ with no Clang-specific attributes, so its 
> behavior is governed by the appropriate platform's ABI doc — there exists one 
> correct answer.
> At least on x86-64 with the Itanium ABI, GCC and ICC and Clang ToT all agree 
> on the answer: `B` and `D` have exactly the same passing convention. If your 
> patch breaks that, that's a problem.
> Contrariwise, it appears that `B` and `D` have different passing conventions 
> on "armv8" according to Clang, and the same passing convention on "ARM64" 
> according to GCC: https://godbolt.org/z/j9jzYG
> Of course if the programmer adds `[[clang::trivial_abi]]` to one of them, 
> then all bets are off, standards-wise, and you're free to figure out a way to 
> pass it in registers if you want to. But otherwise I think you have to follow 
> what the ABI says.
> Bear in mind that I don't really know ABIs other than Itanium/x86-64. Maybe 
> the problem here is that other platforms don't have well-defined ABIs and so 
> we get to make one up? Maybe everyone except me is already aware that that's 
> what we're doing? :)
> At least on x86-64 with the Itanium ABI, GCC and ICC and Clang ToT all agree 
> on the answer: B and D have exactly the same passing convention. If your 
> patch breaks that, that's a problem.

IIUC (and that's a big "if") being trivial for the purposes of a call, does not 
mean it will _always_ be passed through registers. (For example, we'd never 
pass a 512-byte type through registers.) And, I don't think they do have the 
same calling convention, though they are both passed indirectly. As Akira 
rightly pointed out, on ToT `D` has the `byval` attribute indicating that it 
_could_ be passed directly (according to the ABI/standard at least). While it 
might not be an observable change in the assembly, my patch (or at least the 
current version on phab) removes the byval argument. I have a local version 
that fixes this, though, and I'll upload that shortly. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST

[PATCH] D93227: [clangd] Smarter hover on auto and decltype

2020-12-17 Thread Quentin Chateau via Phabricator via cfe-commits
qchateau updated this revision to Diff 312545.
qchateau marked 3 inline comments as done.
qchateau added a comment.

I updated this diff according to your review. There are a few things that may 
still need change but I need your input, see my other comments :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93227

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -379,6 +379,30 @@
  HI.Definition = "class X {}";
}},
 
+  // auto on structured bindings
+  {R"cpp(
+void foo() {
+  struct S { int x; float y; };
+  [[au^to]] [x, y] = S();
+}
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "struct S";
+   }},
+  // undeduced auto
+  {R"cpp(
+template
+void foo() {
+  [[au^to]] x = T{};
+}
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "/* not deduced */";
+   }},
   // auto on lambda
   {R"cpp(
 void foo() {
@@ -386,8 +410,9 @@
 }
 )cpp",
[](HoverInfo &HI) {
- HI.Name = "(lambda)";
- HI.Kind = index::SymbolKind::Class;
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "class(lambda)";
}},
   // auto on template instantiation
   {R"cpp(
@@ -397,8 +422,9 @@
 }
 )cpp",
[](HoverInfo &HI) {
- HI.Name = "Foo";
- HI.Kind = index::SymbolKind::Class;
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "class Foo";
}},
   // auto on specialized template
   {R"cpp(
@@ -409,8 +435,9 @@
 }
 )cpp",
[](HoverInfo &HI) {
- HI.Name = "Foo";
- HI.Kind = index::SymbolKind::Class;
+ HI.Name = "auto";
+ HI.Kind = index::SymbolKind::TypeAlias;
+ HI.Definition = "class Foo";
}},
 
   // macro
@@ -582,8 +609,9 @@
   }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "Foo";
-HI.Kind = index::SymbolKind::Class;
+HI.Name = "auto";
+HI.Kind = index::SymbolKind::TypeAlias;
+HI.Definition = "class Foo";
   }},
   {// Falls back to primary template, when the type is not instantiated.
R"cpp(
@@ -955,20 +983,9 @@
   llvm::StringRef Tests[] = {
   "^int main() {}",
   "void foo() {^}",
-  R"cpp(// structured binding. Not supported yet
-struct Bar {};
-void foo() {
-  Bar a[2];
-  ^auto [x,y] = a;
-}
-  )cpp",
-  R"cpp(// Template auto parameter. Nothing (Not useful).
-template
-void func() {
-}
-void foo() {
-   func<1>();
-}
+  "decltype(au^to) x = 0;",
+  R"cpp(// Lambda auto parameter. Nothing (Not useful).
+auto lamb = [](a^uto){};
   )cpp",
   R"cpp(// non-named decls don't get hover. Don't crash!
 ^static_assert(1, "");
@@ -1545,9 +1562,9 @@
 }
   )cpp",
   [](HoverInfo &HI) {
-HI.Name = "int";
-// FIXME: Should be Builtin/Integral.
-HI.Kind = index::SymbolKind::Unknown;
+HI.Name = "auto";
+HI.Kind = index::SymbolKind::TypeAlias;
+HI.Definition = "int";
   }},
   {
   R"cpp(// Simple initialization with const auto
@@ -1555,14 +1572,22 @@
   const ^[[auto]] i = 1;
 }
   )cpp",
-  [](HoverInfo &HI) { HI.Name = "int"; }},
+  [](HoverInfo &HI) {
+HI.Name = "auto";
+HI.Kind = index::SymbolKind::TypeAlias;
+HI.Definition = "int";
+  }},
   {
   R"cpp(// Simple initialization with const auto&
 void foo() {
   const ^[[auto]]& i = 1;
 }
   )cpp",
-  [](HoverInfo &HI) { HI.Name = "int"; }},
+  [](HoverInfo &HI) {
+HI.Name = "auto";
+HI.Kind = index::SymbolKind::TypeAlias;
+HI.Definition = "int";
+  }},
   {
   R"cpp(// Simple initialization with auto&
 void foo() {
@@ -1570,7 +1595,11 @@
   ^[[auto]]& i = x;
 }
   )cpp",
-  [](HoverInfo &HI) { HI.Name = "int"; }},
+  

[PATCH] D93227: [clangd] Smarter hover on auto and decltype

2020-12-17 Thread Quentin Chateau via Phabricator via cfe-commits
qchateau added inline comments.



Comment at: clang-tools-extra/clangd/Hover.cpp:618
+  } else {
+CXXRecordDecl *D = QT->getAsCXXRecordDecl();
+if (D && D->isLambda())

sammccall wrote:
> You've rewritten this logic compared to the old `getHoverContents(QualType)`, 
> and I think there are regressions:
>  - We've dropped class documentation (see e.g. 
> ac3f9e48421712168884d59cbfe8b294dd76a19b, this is visible in the tests)
>  - we're no longer using printName() to print tag-decls, which I expect 
> changes e.g. the printing of anyonymous structs which is special-cased in 
> that function (we have tests for this but probably not in combination with 
> auto)
>  - we're no longer using the printing-policy to print non-tag types, which 
> will lead to some random changes
> 
> I don't see a reason for these changes, can we revert them?
- I can re-add class documentation, but should it work when `auto` is a pointer 
or a ref ? In that case, I'll need something like your `unwrapType` of 
https://reviews.llvm.org/D93314
- `printName` will print `C` instead of `class C` even if I hack around and 
give it the right `PrintingPolicy`. The problem is that IDE (at least VSCode) 
does not know what `C` is and cannot color it, which looks a nice less nice. Up 
to you !
- I can re-add the printing policy for non-tag types, and add it for tag-types 
if we chose not to use `printName`.



Comment at: clang-tools-extra/clangd/Hover.cpp:631
+// getDeducedType are handled.
+class ExtraAutoTypeHoverVisitor
+: public RecursiveASTVisitor {

sammccall wrote:
> This functionality (reporting the `auto` type in structured bindings, and not 
> reporting non-deduced uses of auto) belongs in the getDeducedType() helper 
> rather than as a layer on top.
> (Especially because it has to be done via an AST traversal rather than 
> SelectionTree)
> 
> I'd suggest leaving it out of this patch to get this the original change 
> landed quickly - this seems like a mostly-unrelated enhancement. But up to 
> you.
I'll remove this. I'll leave out the case of structured bindings for arrays 
(which is really weird and specific), but I guess I'll fix`getDeducedType` to 
return the undeduced `QualType` instead of `None` (which it already does but 
only for return types).



Comment at: clang-tools-extra/clangd/Hover.cpp:907
+
+  HI->Name = tok::getTokenName(Tok.kind());
+  HighlightRange = Tok.range(SM).toCharRange(SM);

sammccall wrote:
> decltype(auto) and decltype(expr) are fairly different things and ultimately 
> we should be displaying them differently I think ("decltype(auto)" vs 
> "decltype(...)").
> 
> Unfortunately it's awkward because our getDeducedType helper handles both at 
> the moment (and so is misnamed, because decltype(expr) isn't deduced at all).
> 
> Can you add `// FIXME: distinguish decltype(auto) vs decltype(expr)` and I'll 
> do some refactoring later?
Sure, I'll add the comment. I'll leave that refactoring to you, I'm not quite 
sure how you intent to achieve it.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:999
+  "decltype(au^to) x = 0;",
+  R"cpp(// Lambda auto parameter. Nothing (Not useful).
+auto lamb = [](a^uto){};

sammccall wrote:
> (not convinced this is fundamentally not useful - the fact that it's a 
> template parameter means it's probably worth having a hover card for it at 
> some point. But I agree with suppressing it for now)
As a user I'd prefer the hover to work over the whole `decltype(auto)` 
expression. But that does not seem quite compatible with the way tokens are 
parsed.

Are you suggesting I remove the test case or should I add a `FIXME` comment ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93227

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


[PATCH] D93428: [AArch64] Add bti note property when compiling asm files with -mbranch-protection=bti

2020-12-17 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss added a comment.

> Is there a reason why assembly files have a different flag (i.e. 
> -mmark-bti-property) to create the .note.gnu.property with the BTI entry?

In assembly the compiler can't guarantee the landing pads are in place, 
therefore it doesn't add it automatically.
The original concept was this the developers should add the landing pads 
wherever needed and by adding the note they mark the file is compatible with 
BTI.
After adding BTI to many assembly code it was clear the note is error prone and 
cumbersome to handle and I thing it provides zero protection against regression 
issues , so the `-mmark-bti-property` is introduced. 
The developers still should add the landing pads but optionally they could mark 
the files in the build system instead of the assembly files. 
The worry is if the assembly file would be marked automatically the produces 
binary probably won't run correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93428

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


[PATCH] D92854: [flang][driver] Add support for `-fsyntax-only`

2020-12-17 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski updated this revision to Diff 312547.
awarzynski added a comment.

Tidy-up include paths

This was pointed out by @CarolineConcatto offline, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92854

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/CompilerInstance.h
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CMakeLists.txt
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/syntax-only.f90
  flang/unittests/Frontend/PrintPreprocessedTest.cpp

Index: flang/unittests/Frontend/PrintPreprocessedTest.cpp
===
--- flang/unittests/Frontend/PrintPreprocessedTest.cpp
+++ flang/unittests/Frontend/PrintPreprocessedTest.cpp
@@ -76,4 +76,60 @@
   llvm::sys::fs::remove(inputFile);
   compInst.ClearOutputFiles(/*EraseFiles=*/true);
 }
+
+TEST(FrontendAction, ParseSyntaxOnly) {
+  std::string inputFile = "test-file.f";
+  std::error_code ec;
+
+  // 1. Create the input file for the file manager
+  // AllSources (which is used to manage files inside every compiler instance),
+  // works with paths. This means that it requires a physical file. Create one.
+  std::unique_ptr os{
+  new llvm::raw_fd_ostream(inputFile, ec, llvm::sys::fs::OF_None)};
+  if (ec)
+FAIL() << "Fail to create the file need by the test";
+
+  // Populate the input file with the pre-defined input and flush it.
+  *(os) << "! if_stmt.f90:\n"
+<< "IF (A > 0.0) IF (B < 0.0) A = LOG (A)\n"
+<< "END";
+  os.reset();
+
+  // Get the path of the input file
+  llvm::SmallString<64> cwd;
+  if (std::error_code ec = llvm::sys::fs::current_path(cwd))
+FAIL() << "Failed to obtain the current working directory";
+  std::string testFilePath(cwd.c_str());
+  testFilePath += "/" + inputFile;
+
+  // 2. Prepare the compiler (CompilerInvocation + CompilerInstance)
+  CompilerInstance compInst;
+  compInst.CreateDiagnostics();
+  auto invocation = std::make_shared();
+  invocation->frontendOpts().programAction_ = ParseSyntaxOnly;
+
+  compInst.set_invocation(std::move(invocation));
+  compInst.frontendOpts().inputs_.push_back(
+  FrontendInputFile(testFilePath, Language::Fortran));
+
+  // 3. Set-up the output stream for the semantic diagnostics.
+  llvm::SmallVector outputDiagBuffer;
+  std::unique_ptr outputStream(
+  new llvm::raw_svector_ostream(outputDiagBuffer));
+  compInst.set_semaOutputStream(std::move(outputStream));
+
+  // 4. Execute the ParseSyntaxOnly action
+  bool success = ExecuteCompilerInvocation(&compInst);
+
+  // 5. Validate the expected output
+  EXPECT_FALSE(success);
+  EXPECT_TRUE(!outputDiagBuffer.empty());
+  EXPECT_TRUE(
+  llvm::StringRef(outputDiagBuffer.data())
+  .startswith(
+  ":2:14: error: IF statement is not allowed in IF statement\n"));
+
+  // 6. Clear the input files.
+  llvm::sys::fs::remove(inputFile);
+}
 } // namespace
Index: flang/test/Flang-Driver/syntax-only.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/syntax-only.f90
@@ -0,0 +1,9 @@
+! RUN: not %flang-new -fc1 -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: not %f18 -fparse-only %s 2>&1 | FileCheck %s
+
+! REQUIRES: new-flang-driver
+
+! CHECK: IF statement is not allowed in IF statement
+! CHECK: semantic errors in {{.*}}syntax-only.f90
+IF (A > 0.0) IF (B < 0.0) A = LOG (A)
+END
Index: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -32,6 +32,9 @@
   case PrintPreprocessedInput:
 return std::make_unique();
 break;
+  case ParseSyntaxOnly:
+return std::make_unique();
+break;
   default:
 break;
 // TODO:
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -7,10 +7,12 @@
 //===--===//
 
 #include "flang/Frontend/FrontendActions.h"
+#include "flang/Common/default-kinds.h"
 #include "flang/Frontend/CompilerInstance.h"
 #include "flang/Parser/parsing.h"
 #include "flang/Parser/provenance.h"
 #include "flang/Parser/source.h"
+#include "flang/Semantics/semantics.h"
 
 using namespace Fortran::frontend;
 
@@ -68,3 +70,33 @@
 return;
   }
 }
+
+void ParseSyntaxOnlyAction::ExecuteAction() {
+  CompilerInstance &ci = this->instance();
+
+  // TODO: These should be specifiable by users. For now just use the def

[clang] c289297 - [PowerPC] Rename the vector pair intrinsics and builtins to replace the _mma_ prefix by _vsx_

2020-12-17 Thread Albion Fung via cfe-commits

Author: Baptiste Saleil
Date: 2020-12-17T13:19:27-05:00
New Revision: c2892978e919bf66535729c70fba73c4c3224548

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

LOG: [PowerPC] Rename the vector pair intrinsics and builtins to replace the 
_mma_ prefix by _vsx_

On PPC, the vector pair instructions are independent from MMA.
This patch renames the vector pair LLVM intrinsics and Clang builtins to 
replace the _mma_ prefix by _vsx_ in their names.
We also move the vector pair type/intrinsic/builtin tests to their own files.

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

Added: 
clang/test/CodeGen/builtins-ppc-pair-mma.c
clang/test/Sema/ppc-pair-mma-types.c
clang/test/SemaCXX/ppc-pair-mma-types.cpp
llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll

Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCInstrPrefix.td
llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
llvm/test/CodeGen/PowerPC/dform-pair-load-store.ll
llvm/test/CodeGen/PowerPC/loop-p10-pair-prepare.ll
llvm/test/CodeGen/PowerPC/mma-intrinsics.ll
llvm/test/CodeGen/PowerPC/mma-outer-product.ll
llvm/test/CodeGen/PowerPC/mma-phi-accs.ll
llvm/test/CodeGen/PowerPC/more-dq-form-prepare.ll

Removed: 
clang/test/CodeGen/builtins-ppc-mma.c
clang/test/Sema/ppc-mma-types.c
clang/test/SemaCXX/ppc-mma-types.cpp
llvm/test/CodeGen/PowerPC/paired-vector-intrinsics-without-mma.ll



diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index 8975d126b897..39c66f5daeb1 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -7,8 +7,9 @@
 
//===--===//
 //
 // This file defines the PowerPC-specific builtin function database.  Users of
-// this file must define the BUILTIN macro or the MMA_BUILTIN macro to make use
-// of this information.
+// this file must define the BUILTIN macro or the CUSTOM_BUILTIN macro to
+// make use of this information. The latter is used for builtins requiring
+// custom code generation and checking.
 //
 
//===--===//
 
@@ -18,9 +19,9 @@
 // The format of this database matches clang/Basic/Builtins.def except for the
 // MMA builtins that are using their own format documented below.
 
-#if defined(BUILTIN) && !defined(MMA_BUILTIN)
-#   define MMA_BUILTIN(ID, TYPES, ACCUMULATE) BUILTIN(__builtin_mma_##ID, 
"i.", "t")
-#elif defined(MMA_BUILTIN) && !defined(BUILTIN)
+#if defined(BUILTIN) && !defined(CUSTOM_BUILTIN)
+#   define CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE) BUILTIN(__builtin_##ID, "i.", 
"t")
+#elif defined(CUSTOM_BUILTIN) && !defined(BUILTIN)
 #   define BUILTIN(ID, TYPES, ATTRS)
 #endif
 
@@ -659,94 +660,94 @@ BUILTIN(__builtin_setflm, "dd", "")
 // Cache built-ins
 BUILTIN(__builtin_dcbf, "vvC*", "")
 
-// MMA built-ins
-// All MMA built-ins are declared here using the MMA_BUILTIN macro. Because
-// these built-ins rely on target-dependent types and to avoid pervasive 
change,
-// they are type checked manually in Sema using custom type descriptors.
-// The first argument of the MMA_BUILTIN macro is the name of the built-in, the
-// second argument specifies the type of the function (result value, then each
-// argument) as follows:
+// Built-ins requiring custom code generation.
+// Because these built-ins rely on target-dependent types and to avoid 
pervasive
+// change, they are type checked manually in Sema using custom type 
descriptors.
+// The first argument of the CUSTOM_BUILTIN macro is the name of the built-in
+// with its prefix, the second argument specifies the type of the function
+// (result value, then each argument) as follows:
 //  i -> Unsigned integer followed by the greatest possible value for that
 //   argument or 0 if no constraint on the value.
 //   (e.g. i15 for a 4-bits value)
-//  v -> void
 //  V -> Vector type used with MMA builtins (vector unsigned char)
-//  W -> MMA vector type followed by the size of the vector type.
+//  W -> PPC Vector type followed by the size of the vector type.
 //   (e.g. W512 for __vector_quad)
+//  any other descriptor -> Fall back to generic type descriptor decoding.
 // The 'C' suffix can be used as a suffix to specify the const type.
 // The '*' suffix can be used as a suffix to specify a pointer to a type.
 // The third argument is set to true if the builtin accumulates its result into
 // i

[PATCH] D91974: [PowerPC] Rename the vector pair intrinsics and builtins to replace the _mma_ prefix by _vsx_

2020-12-17 Thread Albion Fung via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc2892978e919: [PowerPC] Rename the vector pair intrinsics 
and builtins to replace the _mma_… (authored by bsaleil, committed by Conanap).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91974

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-mma.c
  clang/test/CodeGen/builtins-ppc-pair-mma.c
  clang/test/Sema/ppc-mma-types.c
  clang/test/Sema/ppc-pair-mma-types.c
  clang/test/SemaCXX/ppc-mma-types.cpp
  clang/test/SemaCXX/ppc-pair-mma-types.cpp
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
  llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
  llvm/test/CodeGen/PowerPC/dform-pair-load-store.ll
  llvm/test/CodeGen/PowerPC/loop-p10-pair-prepare.ll
  llvm/test/CodeGen/PowerPC/mma-intrinsics.ll
  llvm/test/CodeGen/PowerPC/mma-outer-product.ll
  llvm/test/CodeGen/PowerPC/mma-phi-accs.ll
  llvm/test/CodeGen/PowerPC/more-dq-form-prepare.ll
  llvm/test/CodeGen/PowerPC/paired-vector-intrinsics-without-mma.ll
  llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll

Index: llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll
@@ -0,0 +1,357 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O3 \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr \
+; RUN:   < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O3 \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr -mattr=-mma \
+; RUN:   < %s | FileCheck %s --check-prefix=CHECK-NOMMA
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O3 \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr \
+; RUN:   < %s | FileCheck %s --check-prefix=CHECK-BE
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O3 \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr -mattr=-mma \
+; RUN:   < %s | FileCheck %s --check-prefix=CHECK-BE-NOMMA
+
+; This test also checks that the paired vector intrinsics are available even
+; when MMA is disabled.
+
+; assemble_pair
+declare <256 x i1> @llvm.ppc.vsx.assemble.pair(<16 x i8>, <16 x i8>)
+define void @ass_pair(<256 x i1>* %ptr, <16 x i8> %vc) {
+; CHECK-LABEL: ass_pair:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmr v3, v2
+; CHECK-NEXT:stxv v2, 16(r3)
+; CHECK-NEXT:stxv v3, 0(r3)
+; CHECK-NEXT:blr
+;
+; CHECK-NOMMA-LABEL: ass_pair:
+; CHECK-NOMMA:   # %bb.0: # %entry
+; CHECK-NOMMA-NEXT:vmr v3, v2
+; CHECK-NOMMA-NEXT:stxv v2, 16(r3)
+; CHECK-NOMMA-NEXT:stxv v3, 0(r3)
+; CHECK-NOMMA-NEXT:blr
+;
+; CHECK-BE-LABEL: ass_pair:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:vmr v3, v2
+; CHECK-BE-NEXT:stxv v2, 16(r3)
+; CHECK-BE-NEXT:stxv v2, 0(r3)
+; CHECK-BE-NEXT:blr
+;
+; CHECK-BE-NOMMA-LABEL: ass_pair:
+; CHECK-BE-NOMMA:   # %bb.0: # %entry
+; CHECK-BE-NOMMA-NEXT:vmr v3, v2
+; CHECK-BE-NOMMA-NEXT:stxv v2, 16(r3)
+; CHECK-BE-NOMMA-NEXT:stxv v2, 0(r3)
+; CHECK-BE-NOMMA-NEXT:blr
+entry:
+  %0 = tail call <256 x i1> @llvm.ppc.vsx.assemble.pair(<16 x i8> %vc, <16 x i8> %vc)
+  store <256 x i1> %0, <256 x i1>* %ptr, align 32
+  ret void
+}
+
+; disassemble_pair
+declare { <16 x i8>, <16 x i8> } @llvm.ppc.vsx.disassemble.pair(<256 x i1>)
+define void @disass_pair(<256 x i1>* %ptr1, <16 x i8>* %ptr2, <16 x i8>* %ptr3) {
+; CHECK-LABEL: disass_pair:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:lxv vs1, 0(r3)
+; CHECK-NEXT:lxv vs0, 16(r3)
+; CHECK-NEXT:stxv vs1, 0(r4)
+; CHECK-NEXT:stxv vs0, 0(r5)
+; CHECK-NEXT:blr
+;
+; CHECK-NOMMA-LABEL: disass_pair:
+; CHECK-NOMMA:   # %bb.0: # %entry
+; CHECK-NOMMA-NEXT:lxv vs1, 0(r3)
+; CHECK-NOMMA-NEXT:lxv vs0, 16(r3)
+; CHECK-NOMMA-NEXT:stxv vs1, 0(r4)
+; CHECK-NOMMA-NEXT:stxv vs0, 0(r5)
+; CHECK-NOMMA-NEXT:blr
+;
+; CHECK-BE-LABEL: disass_pair:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:lxv vs1, 16(r3)
+; CHECK-BE-NEXT:lxv vs0, 0(r3)
+; CHECK-BE-NEXT:stxv vs0, 0(r4)
+; CHECK-BE-NEXT:stxv vs1, 0(r5)
+; CHECK-BE-NEXT:blr
+;
+; CHECK-BE-NOMMA-LABEL: disass_pair:
+; CHECK-BE-NOMMA:   # %bb.0: # %entry
+; CHECK-BE-NOMMA-NEXT:lxv vs1, 16(r3)
+; CHECK-BE-NOMMA-NEXT:lxv vs0, 0(r3)
+; CHECK-BE-NOMMA-NEXT:stxv vs0, 0(r4)
+; CHECK-BE-NOMMA-NEXT:stxv vs1, 0(r5)
+; CHECK-BE-NOMMA-NEXT:blr
+entry

[PATCH] D92854: [flang][driver] Add support for `-fsyntax-only`

2020-12-17 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto accepted this revision.
CarolineConcatto added a comment.

Thank you @awarzynski for implementing fsyntax-only. 
It is another feature that the new driver provides, it is nice to see thing 
falling into place.
The patch looks good to me!




Comment at: flang/include/flang/Frontend/FrontendActions.h:13
 #include "flang/Frontend/FrontendAction.h"
+#include "llvm/Support/raw_ostream.h"
 

Do you need this library here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92854

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


  1   2   >