[PATCH] D90316: [FPEnv] Diagnose pragmas FENV_ROUND,_ACCESS and float_control if target does not support StrictFP

2020-10-30 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff accepted this revision.
sepavloff added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: clang/test/Parser/pragma-fp-warn.c:1
+
+// RUN: %clang_cc1 -triple wasm32 -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s

I would propose to add a line with `-triple msp430`. This is a simple core, it 
is unlikely that it gets hardware FP support.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90316

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


[PATCH] D89972: Add pipeline model for HiSilicon's TSV110

2020-10-30 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

I haven't checked the instruction descriptions in detail, but the overall 
structure looks good to me. Perhaps wait a day with committing in case 
@bryanpkc has more comments.


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

https://reviews.llvm.org/D89972

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


[PATCH] D90447: [AMDGPU] Add gfx1033 target

2020-10-30 Thread Tim Renouf via Phabricator via cfe-commits
tpr created this revision.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, kerbowa, 
rupprecht, hiraditya, t-tye, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl, 
arsenm.
Herald added a reviewer: jhenderson.
Herald added projects: clang, LLVM.
tpr requested review of this revision.
Herald added subscribers: MaskRay, wdng.

Change-Id: If2650fc7f31bbdd49c76e74a9ca8e3734d769761


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90447

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/test/CodeGenOpenCL/amdgpu-features.cl
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/amdgpu-mcpu.cl
  llvm/docs/AMDGPUUsage.rst
  llvm/include/llvm/BinaryFormat/ELF.h
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/lib/Support/TargetParser.cpp
  llvm/lib/Target/AMDGPU/GCNProcessors.td
  llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
  llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll
  llvm/test/CodeGen/AMDGPU/hsa-note-no-func.ll
  llvm/test/MC/AMDGPU/gfx1011_dlops.s
  llvm/test/MC/AMDGPU/gfx1030_err.s
  llvm/test/MC/AMDGPU/gfx1030_new.s
  llvm/test/MC/Disassembler/AMDGPU/gfx1011_dasm_dlops.txt
  llvm/test/MC/Disassembler/AMDGPU/gfx1030_dasm_new.txt
  llvm/tools/llvm-readobj/ELFDumper.cpp

Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1786,6 +1786,7 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1030),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1031),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1032),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1033),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_XNACK),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_SRAM_ECC)
 };
Index: llvm/test/MC/Disassembler/AMDGPU/gfx1030_dasm_new.txt
===
--- llvm/test/MC/Disassembler/AMDGPU/gfx1030_dasm_new.txt
+++ llvm/test/MC/Disassembler/AMDGPU/gfx1030_dasm_new.txt
@@ -1,6 +1,7 @@
 # RUN: llvm-mc -arch=amdgcn -mcpu=gfx1030 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
 # RUN: llvm-mc -arch=amdgcn -mcpu=gfx1031 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
 # RUN: llvm-mc -arch=amdgcn -mcpu=gfx1032 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
+# RUN: llvm-mc -arch=amdgcn -mcpu=gfx1033 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
 
 # GFX10: global_load_dword_addtid v1, s[2:3] offset:16
 0x10,0x80,0x58,0xdc,0x00,0x00,0x02,0x01
Index: llvm/test/MC/Disassembler/AMDGPU/gfx1011_dasm_dlops.txt
===
--- llvm/test/MC/Disassembler/AMDGPU/gfx1011_dasm_dlops.txt
+++ llvm/test/MC/Disassembler/AMDGPU/gfx1011_dasm_dlops.txt
@@ -1,5 +1,9 @@
 # RUN: llvm-mc -arch=amdgcn -mcpu=gfx1011 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
 # RUN: llvm-mc -arch=amdgcn -mcpu=gfx1012 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
+# RUN: llvm-mc -arch=amdgcn -mcpu=gfx1030 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
+# RUN: llvm-mc -arch=amdgcn -mcpu=gfx1031 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
+# RUN: llvm-mc -arch=amdgcn -mcpu=gfx1032 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
+# RUN: llvm-mc -arch=amdgcn -mcpu=gfx1033 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
 
 # GFX10: v_dot2_f32_f16 v0, v1, v2, v3   ; encoding: [0x00,0x40,0x13,0xcc,0x01,0x05,0x0e,0x1c]
 0x00,0x40,0x13,0xcc,0x01,0x05,0x0e,0x1c
Index: llvm/test/MC/AMDGPU/gfx1030_new.s
===
--- llvm/test/MC/AMDGPU/gfx1030_new.s
+++ llvm/test/MC/AMDGPU/gfx1030_new.s
@@ -1,6 +1,7 @@
 // RUN: llvm-mc -arch=amdgcn -mcpu=gfx1030 -show-encoding %s | FileCheck --check-prefix=GFX10 %s
 // RUN: llvm-mc -arch=amdgcn -mcpu=gfx1031 -show-encoding %s | FileCheck --check-prefix=GFX10 %s
 // RUN: llvm-mc -arch=amdgcn -mcpu=gfx1032 -show-encoding %s | FileCheck --check-prefix=GFX10 %s
+// RUN: llvm-mc -arch=amdgcn -mcpu=gfx1033 -show-encoding %s | FileCheck --check-prefix=GFX10 %s
 
 global_load_dword_addtid v1, s[2:3] offset:16
 // GFX10: encoding: [0x10,0x80,0x58,0xdc,0x00,0x00,0x02,0x01]
Index: llvm/test/MC/AMDGPU/gfx1030_err.s
===
--- llvm/test/MC/AMDGPU/gfx1030_err.s
+++ llvm/test/MC/AMDGPU/gfx1030_err.s
@@ -1,6 +1,7 @@
 // RUN: not llvm-mc -arch=amdgcn -mcpu=gfx1030 %s 2>&1 | FileCheck --check-prefix=GFX10 --implicit-check-not=error: %s
 // RUN: not llvm-mc -arch=amdgcn -mcpu=gfx1031 %s 2>&1 | FileCheck --check-prefix=GFX10 --implicit-check-not=error: %s
 // RUN: not llvm-mc -arch=amdgcn -mcpu=gfx1032 %s 2>&1 | FileCheck --check-prefix=GFX10 --implicit-check-not=error: %s
+// RUN:

[PATCH] D90291: [clangd] Add lit tests for remote index

2020-10-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!




Comment at: clang-tools-extra/clangd/test/lit.cfg.py:26
  config.clangd_binary_dir + "/benchmarks"))
+config.substitutions.append(('%python',
+ config.python_executable))

we should rather call `lit.llvm.llvm_config.use_default_substitutions()`, 
preferably right after `use_clang()` on line 4.

sorry for the churn, i thought we were already doing this.



Comment at: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py:19
+def main():
+  server_address = 'localhost:'
+  # Grab an available port.

nit: maybe perform the magic after arg parsing ?



Comment at: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py:22
+  with socket() as s:
+s.bind(('', 0))
+server_address += str(s.getsockname()[1])

this still binds the socket to all interfaces, can we specify `localhost` or 
`127.0.0.1` explicitly for the interface address.



Comment at: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py:36
+  ],
+  stderr=subprocess.PIPE)
+

nit: formatting looks off, is this really what yapf offers?



Comment at: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py:39
+  # Wait for the server to warm-up.
+  if not b'Server listening' in index_server_process.stderr.readline():
+sys.exit(1)

i would rather scan through all lines and look for `Server listening on 
$server_addres`. We should be able to either hit the end of stream (i.e. server 
encounters a failure and shuts down) or find the log message we are looking for.

just to make test less reliant on log ordering.



Comment at: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py:51
+  clangd_process.wait()
+  os.kill(index_server_process.pid, 9)
+

can we rather use `signal.SIGXXX` here instead of `9` ?

Also rather than kill, SIGINT might be more applicable. 
https://docs.python.org/3/library/signal.html#signal.SIGKILL claims sigkill is 
not available on windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90291

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


[PATCH] D90447: [AMDGPU] Add gfx1033 target

2020-10-30 Thread Jay Foad via Phabricator via cfe-commits
foad added a comment.

Don't you need to update lib/Object/ELFObjectFile.cpp and 
test/Object/AMDGPU/elf-header-flags-mach.yaml?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90447

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


[PATCH] D90448: [clang] Add type check for explicit instantiation of static data members

2020-10-30 Thread Chuyang Chen via Phabricator via cfe-commits
nomanous created this revision.
nomanous added reviewers: rsmith, chandlerc, Eugene.Zelenko, majnemer, lvoufo.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
nomanous requested review of this revision.

Add type check for explicit instantiation of template classes' static data 
members. This is a buf fix for #38205.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90448

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/SemaCXX/template-explicit-instant-type-mismatch.cpp

Index: clang/test/SemaCXX/template-explicit-instant-type-mismatch.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/template-explicit-instant-type-mismatch.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+template
+class A
+{
+ static T a; //expected-note {{in instantiation of static data member 'A::a' requested here}}
+};
+
+template
+T A::a;
+
+class B
+{ };
+
+template T c; //expected-note {{variable template 'c' declared here}}
+
+template int c; //expected-error {{type 'int' of explicit instantiation of 'c' does not match expected type 'B'}}
+
+template int A::a; //expected-error {{type 'int' of explicit instantiation of 'A::a' does not match expected type 'B'}}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -9977,6 +9977,7 @@
 
 VarDecl *Prev = Previous.getAsSingle();
 VarTemplateDecl *PrevTemplate = Previous.getAsSingle();
+bool IsStaticDataMemberInstantiation = false;
 
 if (!PrevTemplate) {
   if (!Prev || !Prev->isStaticDataMember()) {
@@ -9998,6 +,8 @@
 // FIXME: Can we provide a note showing where this was declared?
 return true;
   }
+
+  IsStaticDataMemberInstantiation = true;
 } else {
   // Explicitly instantiate a variable template.
 
@@ -10090,6 +10093,22 @@
   return true;
 }
 
+// Check the static member's type given in the explicit instantiation
+// definition against the one in the class template. This won't happen in
+// explicit instantiation declaration because the instantiated code won't
+// be generated in that case. Objective C lifetime qualifiers will be
+// automatically added by compiler with option -fobjc-arc so it should be
+// ignored when comparing types.
+if (IsStaticDataMemberInstantiation && TSK==TSK_ExplicitInstantiationDefinition
+&& Prev && !Context.hasSameType(Prev->getType(), R, true)) {
+  Diag(T->getTypeLoc().getBeginLoc(),
+   diag::err_invalid_template_static_data_member_spec_type)
+<< Prev << R << Prev->getType();
+  Diag(Prev->getLocation(), diag::note_template_static_data_member_def_here)
+  <;
+def err_invalid_template_static_data_member_spec_type : Error<"type %1 "
+  "of explicit instantiation of %q0 does not match expected type %2">;
 def err_mismatched_exception_spec_explicit_instantiation : Error<
   "exception specification in explicit instantiation does not match "
   "instantiated one">;
Index: clang/include/clang/AST/ASTContext.h
===
--- clang/include/clang/AST/ASTContext.h
+++ clang/include/clang/AST/ASTContext.h
@@ -2337,8 +2337,19 @@
   CanQualType getCanonicalParamType(QualType T) const;
 
   /// Determine whether the given types \p T1 and \p T2 are equivalent.
-  bool hasSameType(QualType T1, QualType T2) const {
-return getCanonicalType(T1) == getCanonicalType(T2);
+  /// The lifetime qualifier of Objective C can be chosen to be ignored because
+  /// sometimes we don't want to take this into consideration.
+  bool hasSameType(QualType T1, QualType T2, bool IgnoreObjCLifetimeQual = false) const {
+if (!IgnoreObjCLifetimeQual) {
+  return getCanonicalType(T1) == getCanonicalType(T2);
+}
+else {
+  SplitQualType ST1 = getCanonicalType(T1).split();
+  SplitQualType ST2 = getCanonicalType(T2).split();
+  ST1.Quals.removeObjCLifetime();
+  ST2.Quals.removeObjCLifetime();
+  return ST1 == ST2;
+}
   }
   bool hasSameType(const Type *T1, const Type *T2) const {
 return getCanonicalType(T1) == getCanonicalType(T2);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90270: [clangd] Handle absolute/relative path specifications in Config

2020-10-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 301842.
kadircet marked an inline comment as done.
kadircet added a comment.

- Return "." if Path == FragmentDir in conifgRelative.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90270

Files:
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigProvider.cpp
  clang-tools-extra/clangd/ConfigProvider.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
@@ -10,6 +10,7 @@
 #include "ConfigProvider.h"
 #include "ConfigTesting.h"
 #include "TestFS.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/SourceMgr.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -91,7 +92,7 @@
   FS.Files["foo.yaml"] = AddFooWithErr;
 
   CapturedDiags Diags;
-  auto P = Provider::fromYAMLFile(testPath("foo.yaml"), FS);
+  auto P = Provider::fromYAMLFile(testPath("foo.yaml"), /*Directory=*/"", FS);
   auto Cfg = P->getConfig(Params(), Diags.callback());
   EXPECT_THAT(Diags.Diagnostics,
   ElementsAre(DiagMessage("Unknown CompileFlags key Unknown")));
@@ -159,7 +160,7 @@
   Params MustBeFresh;
   MustBeFresh.FreshTime = StartTime + std::chrono::hours(1);
   CapturedDiags Diags;
-  auto P = Provider::fromYAMLFile(testPath("foo.yaml"), FS);
+  auto P = Provider::fromYAMLFile(testPath("foo.yaml"), /*Directory=*/"", FS);
 
   // Initial query always reads, regardless of policy.
   FS.Files["foo.yaml"] = AddFooWithErr;
@@ -187,6 +188,37 @@
   EXPECT_THAT(getAddedArgs(Cfg), IsEmpty());
 }
 
+TEST(ProviderTest, SourceInfo) {
+  MockFS FS;
+
+  FS.Files["baz/foo.yaml"] = R"yaml(
+If:
+  PathMatch: .*
+  PathExclude: bar.h
+CompileFlags:
+  Add: bar
+)yaml";
+  const auto BarPath = testPath("baz/bar.h", llvm::sys::path::Style::posix);
+  CapturedDiags Diags;
+  Params Bar;
+  Bar.Path = BarPath;
+
+  // This should be an absolute match/exclude hence baz/bar.h should not be
+  // excluded.
+  auto P =
+  Provider::fromYAMLFile(testPath("baz/foo.yaml"), /*Directory=*/"", FS);
+  auto Cfg = P->getConfig(Bar, Diags.callback());
+  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("bar"));
+  Diags.Diagnostics.clear();
+
+  // This should be a relative match/exclude hence baz/bar.h should be excluded.
+  P = Provider::fromAncestorRelativeYAMLFiles("foo.yaml", FS);
+  Cfg = P->getConfig(Bar, Diags.callback());
+  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+  EXPECT_THAT(getAddedArgs(Cfg), IsEmpty());
+  Diags.Diagnostics.clear();
+}
 } // namespace
 } // namespace config
 } // namespace clangd
Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -9,8 +9,12 @@
 #include "Config.h"
 #include "ConfigFragment.h"
 #include "ConfigTesting.h"
+#include "TestFS.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Path.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -116,6 +120,62 @@
   "Invalid Background value 'Foo'. Valid values are Build, Skip.")));
 }
 
+TEST_F(ConfigCompileTests, PathSpecMatch) {
+  auto BarPath = llvm::sys::path::convert_to_slash(testPath("foo/bar.h"));
+  Parm.Path = BarPath;
+
+  struct {
+std::string Directory;
+std::string PathSpec;
+bool ShouldMatch;
+  } Cases[] = {
+  {
+  // Absolute path matches.
+  "",
+  llvm::sys::path::convert_to_slash(testPath("foo/bar.h")),
+  true,
+  },
+  {
+  // Absolute path fails.
+  "",
+  llvm::sys::path::convert_to_slash(testPath("bar/bar.h")),
+  false,
+  },
+  {
+  // Relative should fail to match as /foo/bar.h doesn't reside under
+  // /baz/.
+  testPath("baz"),
+  "bar\\.h",
+  false,
+  },
+  {
+  // Relative should pass with /foo as directory.
+  testPath("foo"),
+  "bar\\.h",
+  true,
+  },
+  };
+
+  // PathMatch
+  for (const auto &Case : Cases) {
+Frag = {};
+Frag.If.PathMatch.emplace_back(Case.PathSpec);
+Frag.Source.Directory = Case.Directory;
+EXPECT_EQ(compileAndApply(), Case.ShouldMatch);
+ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+  }
+
+  // PathEclude
+  for (const auto &Case : Cases) {
+SCOPED_TRACE(Case.Directory);
+SCOPED_TRACE(Case.PathSpec);
+Frag = 

[PATCH] D90270: [clangd] Handle absolute/relative path specifications in Config

2020-10-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:51
+return llvm::StringRef();
+  return Path;
+}

sammccall wrote:
> not that if Path == FragmentDir you're going to return "" which means "not 
> under".
> I don't think this can happen yet, but it's a trap for the future...
> 
> You might want the last line to be "return FragmentDir.empty() ? "." : Path".
i think you meant `Path.empty() ? "." : Path`, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90270

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


[PATCH] D89936: [clang-tidy] adding "--config-file=" to specify custom config file.

2020-10-30 Thread Hiral via Phabricator via cfe-commits
Hiralo updated this revision to Diff 301845.
Hiralo added a comment.

clang-tidy: adding "--config-file=" to specify custom config file.

Let clang-tidy to read config from specified file.

This option internally works exactly the same way as --config option
after reading specified config file.

This option works as helper for --config in following few cases:

- when there is shell limitation to read file content to the command line,
- when there is limitation to command line length,
- setting right build dependencies, and
- others

--config-file and --config options are made mutually exclusive.

Example usage:
 $ clang-tidy --config-file=/some/path/myTidyConfigFile --dump-config --
 ...this will read config from /some/path/myTidyConfigFile and

  avoid searching '.clang-tidy' in parent-dirs.

May speed-up tidy runtime since now it will just look-up 
instead of searching ".clang-tidy" in parent-dirs.

Reviewed By: DmitryPolukhin, njames93

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89936

Files:
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-file/config-file
  clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp


Index: clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp
@@ -0,0 +1,2 @@
+// RUN: clang-tidy -config-file=%S/Inputs/config-file/config-file -dump-config 
-- | FileCheck %s -check-prefix=CHECK-BASE
+// CHECK-BASE: Checks: {{.*}}hicpp-uppercase-literal-suffix
Index: 
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-file/config-file
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-file/config-file
@@ -0,0 +1 @@
+Checks: "-*,hicpp-uppercase-literal-suffix"
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -168,6 +168,16 @@
 )"),
cl::init(""), cl::cat(ClangTidyCategory));
 
+static cl::opt ConfigFile("config-file", cl::desc(R"(
+Specify the path of .clang-tidy or custom config file:
+ e.g. --config-file=/some/path/myTidyConfigFile
+This option internally works exactly the same way as
+ --config option after reading specified config file.
+Use either --config-file or --config, not both.
+)"),
+   cl::init(""),
+   cl::cat(ClangTidyCategory));
+
 static cl::opt DumpConfig("dump-config", cl::desc(R"(
 Dumps configuration in the YAML format to
 stdout. This option can be used along with a
@@ -302,19 +312,41 @@
   if (UseColor.getNumOccurrences() > 0)
 OverrideOptions.UseColor = UseColor;
 
-  if (!Config.empty()) {
-if (llvm::ErrorOr ParsedConfig =
-parseConfiguration(Config)) {
+  auto LoadConfig = [&](StringRef Configuration)
+  -> std::unique_ptr {
+llvm::ErrorOr ParsedConfig =
+parseConfiguration(Configuration);
+if (ParsedConfig)
   return std::make_unique(
   GlobalOptions,
   ClangTidyOptions::getDefaults().mergeWith(DefaultOptions, 0),
   *ParsedConfig, OverrideOptions, std::move(FS));
-} else {
-  llvm::errs() << "Error: invalid configuration specified.\n"
-   << ParsedConfig.getError().message() << "\n";
+llvm::errs() << "Error: invalid configuration specified.\n"
+ << ParsedConfig.getError().message() << "\n";
+return nullptr;
+  };
+
+  if (!ConfigFile.empty()) {
+if (!Config.empty()) {
+  llvm::errs() << "Error: --config-file and --config are "
+  "mutually exclusive. Specify only one.\n";
   return nullptr;
 }
+
+llvm::ErrorOr> Text =
+llvm::MemoryBuffer::getFile(ConfigFile.c_str());
+if (std::error_code EC = Text.getError()) {
+  llvm::errs() << "Error: can't read config-file '" << ConfigFile
+   << "': " << EC.message() << "\n";
+  return nullptr;
+}
+
+return LoadConfig((*Text)->getBuffer());
   }
+
+  if (!Config.empty())
+return LoadConfig(Config);
+
   return std::make_unique(GlobalOptions, DefaultOptions,
 OverrideOptions, 
std::move(FS));
 }


Index: clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp
@@ -0,0 +1,2 @@
+// RUN: clang-tidy -config-file=%S/Inputs/config-file/config-fi

[PATCH] D90419: [AMDGPU] Add gfx90c target

2020-10-30 Thread Jay Foad via Phabricator via cfe-commits
foad added inline comments.



Comment at: llvm/docs/AMDGPUUsage.rst:261
+ ``gfx90c``  ``amdgcn``   APU   - xnack
   *TBA*
+  [off]
+   
   .. TODO::

Is xnack really supposed to be off for this target?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90419

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


[PATCH] D89936: [clang-tidy] adding "--config-file=" to specify custom config file.

2020-10-30 Thread Hiral via Phabricator via cfe-commits
Hiralo marked 6 inline comments as done.
Hiralo added inline comments.



Comment at: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:320-324
+if (!Checks.empty()) {
+  llvm::errs() << "Error: --config-file and --checks are mutually "
+  "exclusive. Specify only one.\n";
+  return nullptr;
+}

DmitryPolukhin wrote:
> Hiralo wrote:
> > DmitryPolukhin wrote:
> > > DmitryPolukhin wrote:
> > > > njames93 wrote:
> > > > > I disagree with this check here, `Config` is not mutually exclusive 
> > > > > with `Checks`, `Checks` gets applied atop of `Config`. So the same 
> > > > > should happen when using `ConfigFile` with `Checks`
> > > > +1
> > > Clarify: +1 to @njames93 that we don't need this check.
> > > I disagree with this check here, `Config` is not mutually exclusive with 
> > > `Checks`, `Checks` gets applied atop of `Config`. So the same should 
> > > happen when using `ConfigFile` with `Checks`
> > 
> > ok, will remove these two checks :)
> I think we need to keep the first check. There is no reason to specify both 
> `--config` and `--config-file` or give on of them precedence.
> I think we need to keep the first check. There is no reason to specify both 
> `--config` and `--config-file` or give on of them precedence.

Kept '--config-file' and '--config' mutually exclusive.





Comment at: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:337
+
+Config.assign((*Text)->getBuffer());
+  }

njames93 wrote:
> Hiralo wrote:
> > Hiralo wrote:
> > > DmitryPolukhin wrote:
> > > > DmitryPolukhin wrote:
> > > > > I suggest creating new local variable with text of the config from 
> > > > > `Config` or `ConfigFile` file content i.e. avoid modifying `Config` 
> > > > > itself.
> > > > It doesn't compile and using local variable instead of changing command 
> > > > line option will make this code easier to read and understand:
> > > > ```
> > > > clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:334:12: error: no 
> > > > matching member function for call to 'assign'
> > > > Config.assign((*Text)->getBuffer());
> > > > ~~~^~
> > > > ```
> > > > Could you please fix build and please upload diff with `arc diff` as 
> > > > @njames93 suggested so buildbot can test your changes?
> > > > I suggest creating new local variable with text of the config from 
> > > > `Config` or `ConfigFile` file content i.e. avoid modifying `Config` 
> > > > itself.
> > > 
> > > Sorry! probably I missed this comment!
> > > 
> > > std::string Temp = (*Text)->getBuffer();
> > > Config.assign(Temp); // ???
> > > 
> > > if so how code will enter into below block... because we want to reuse 
> > > code-path of 'Config' correct?
> > > 
> > > if (!Config.empty()) {
> > >  if (llvm::ErrorOr ParsedConfig = 
> > > parseConfiguration(Config)) {
> > > ...
> > > }
> > > 
> > > ?
> > > It doesn't compile and using local variable instead of changing command 
> > > line option will make this code easier to read and understand:
> > > ```
> > > clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:334:12: error: no 
> > > matching member function for call to 'assign'
> > > Config.assign((*Text)->getBuffer());
> > > ~~~^~
> > > ```
> > > Could you please fix build and please upload diff with `arc diff` as 
> > > @njames93 suggested so buildbot can test your changes?
> > 
> > Let me try.
> Could extract the configuration loading into a lambda
> ```
>   auto LoadConfig = [&](StringRef Configuration)
>   -> std::unique_ptr {
> llvm::ErrorOr ParsedConfig =
> parseConfiguration(Configuration);
> if (ParsedConfig)
>   return std::make_unique(
>   GlobalOptions,
>   ClangTidyOptions::getDefaults().mergeWith(DefaultOptions, 0),
>   *ParsedConfig, OverrideOptions, std::move(FS));
> llvm::errs() << "Error: invalid configuration specified.\n"
>  << ParsedConfig.getError().message() << "\n";
> return nullptr;
>   };
> ```
> 
> Then further down
> ```
> if (!ConfigFile.empty()) {
>   ...
>   llvm::ErrorOr> Text =
> llvm::MemoryBuffer::getFile(ConfigFile.c_str());
> if (std::error_code EC = Text.getError()) {
>   llvm::errs() << "Can't read config-file '" << ConfigFile
><< "': " << EC.message() << "\n";
>   return nullptr;
> }
> 
> return LoadConfig((*Text)->getBuffer());
> }
> 
> if (!Config.empty())
>   return LoadConfig(Config);
> ```
> 
> This has the added bonus of not having to needlessly copy the buffer
> > It doesn't compile and using local variable instead of changing command 
> > line option will make this code easier to read and understand:
> > ```
> > clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:334:12: error: no 
> > matching member function for call to 'assign'
> > Config.assign((*Text)->getBuffer());
> > ~~~^~
> > ```
> > Could you please fix build and please upload diff with `a

[PATCH] D90385: Address ABI issues introduced with CXCursor_CXXAddrspaceCastExpr

2020-10-30 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh accepted this revision.
svenvh added a comment.

LGTM.  I also checked that this brings `Index.h` back in sync with 
`bindings/python/clang/cindex.py` again.

We are not exposing `CXCursor_CXXAddrspaceCastExpr` through the python 
bindings, but some other values are missing too so that's beyond the scope of 
this fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90385

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


[PATCH] D90452: [clangd] Respect codeAction.isPreferredSupport in client capabilities

2020-10-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: sammccall, adamcz.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Fixes https://github.com/clangd/clangd/issues/573.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90452

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


Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -445,6 +445,10 @@
   /// textDocument.codeAction.codeActionLiteralSupport.
   bool CodeActionStructure = false;
 
+  /// Client supports isPreferred property on CodeActions.
+  /// textDocument.codeAction.isPreferredSupport.
+  bool CodeActionIsPreferred = false;
+
   /// Client advertises support for the semanticTokens feature.
   /// We support the textDocument/semanticTokens request in any case.
   /// textDocument.semanticTokens
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -346,6 +346,8 @@
 if (auto *CodeAction = TextDocument->getObject("codeAction")) {
   if (CodeAction->getObject("codeActionLiteralSupport"))
 R.CodeActionStructure = true;
+  if (auto IsPreferred = CodeAction->getBoolean("isPreferredSupport"))
+R.CodeActionIsPreferred = *IsPreferred;
 }
 if (auto *DocumentSymbol = TextDocument->getObject("documentSymbol")) {
   if (auto HierarchicalSupport =
Index: clang-tools-extra/clangd/ClangdLSPServer.h
===
--- clang-tools-extra/clangd/ClangdLSPServer.h
+++ clang-tools-extra/clangd/ClangdLSPServer.h
@@ -263,6 +263,9 @@
   CompletionItemKindBitset SupportedCompletionItemKinds;
   /// Whether the client supports CodeAction response objects.
   bool SupportsCodeAction = false;
+  /// Whether the client supports isPreferred property on CodeAction response
+  /// objects.
+  bool SupportsCodeActionIsPreferred = false;
   /// From capabilities of textDocument/documentSymbol.
   bool SupportsHierarchicalDocumentSymbol = false;
   /// Whether the client supports showing file status.
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -532,6 +532,7 @@
   if (Params.capabilities.CompletionItemKinds)
 SupportedCompletionItemKinds |= *Params.capabilities.CompletionItemKinds;
   SupportsCodeAction = Params.capabilities.CodeActionStructure;
+  SupportsCodeActionIsPreferred = Params.capabilities.CodeActionIsPreferred;
   SupportsHierarchicalDocumentSymbol =
   Params.capabilities.HierarchicalDocumentSymbol;
   SupportFileStatus = Params.initializationOptions.FileStatus;
@@ -1029,15 +1030,17 @@
 
 // If there's exactly one quick-fix, call it "preferred".
 // We never consider refactorings etc as preferred.
-CodeAction *OnlyFix = nullptr;
-for (auto &Action : Actions) {
-  if (Action.kind && *Action.kind == CodeAction::QUICKFIX_KIND) {
-if (OnlyFix) {
-  OnlyFix->isPreferred = false;
-  break;
+if (SupportsCodeActionIsPreferred) {
+  CodeAction *OnlyFix = nullptr;
+  for (auto &Action : Actions) {
+if (Action.kind && *Action.kind == CodeAction::QUICKFIX_KIND) {
+  if (OnlyFix) {
+OnlyFix->isPreferred = false;
+break;
+  }
+  Action.isPreferred = true;
+  OnlyFix = &Action;
 }
-Action.isPreferred = true;
-OnlyFix = &Action;
   }
 }
 


Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -445,6 +445,10 @@
   /// textDocument.codeAction.codeActionLiteralSupport.
   bool CodeActionStructure = false;
 
+  /// Client supports isPreferred property on CodeActions.
+  /// textDocument.codeAction.isPreferredSupport.
+  bool CodeActionIsPreferred = false;
+
   /// Client advertises support for the semanticTokens feature.
   /// We support the textDocument/semanticTokens request in any case.
   /// textDocument.semanticTokens
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -346,6 +346,8 @@
 if (auto *CodeAction = TextDoc

[PATCH] D83717: [clang-tidy] Add check fo SEI CERT item ENV32-C

2020-10-30 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added a comment.

In D83717#2279263 , @aaron.ballman 
wrote:

> One of the concerns I have with this not being a flow-sensitive check is that 
> most of the bad situations are not going to be caught by the clang-tidy 
> version of the check. The CERT rules show contrived code examples, but the 
> more frequent issue looks like:
>
>   void cleanup(struct whatever *ptr) {
> assert(ptr); // This potentially calls abort()
> free(ptr->buffer);
> free(ptr);
>   }
>   
>   void some_cleanup_func(void) {
> for (size_t idx = 0; idx < GlobalElementCount; ++idx) {
>   cleanup(GlobalElement[idx]);
> }
>   }
>   
>   void some_exit_handler(void) {
> ...
> some_cleanup_func();
> ...
>   }
>
> The fact that we're not looking through the call sites (even without cross-TU 
> support) means the check isn't going to catch the most problematic cases. You 
> could modify the called function collector to gather this a bit better, but 
> you'd issue false positives in flow-sensitive situations like:
>
>   void some_cleanup_func(void) {
> for (size_t idx = 0; idx < GlobalElementCount; ++idx) {
>   struct whatever *ptr = GlobalElement[idx];
>   if (ptr) {
> // Now we know abort() won't be called
> cleanup(ptr);
>   }
> }
>   }
>
> Have you run this check over any large code bases to see if it currently 
> catches any true positive diagnostics?

I have tried llvm, tmux, curl and tried codesearch.com to look for other 
sources containing `atexit`, but no results were found. So it is hard to see 
whether this flow-sensitive approach would result in many false positives.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83717

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


[PATCH] D89936: [clang-tidy] adding "--config-file=" to specify custom config file.

2020-10-30 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:329-330
+
+  if (!ConfigFile.empty()) {
+if (!Config.empty()) {
+  llvm::errs() << "Error: --config-file and --config are "

nit: Should we be using `Config(File)?.getNumOccurances() > 0` here and below
If someone puts `--config=""` They are specifying a config(file)?, even if its 
empty.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89936

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


[PATCH] D90455: [clangd] Pass parameters to config apply functions

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

This will enable some fragments to apply their features selectively.

Depends on D90270 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90455

Files:
  clang-tools-extra/clangd/ConfigCompile.cpp


Index: clang-tools-extra/clangd/ConfigCompile.cpp
===
--- clang-tools-extra/clangd/ConfigCompile.cpp
+++ clang-tools-extra/clangd/ConfigCompile.cpp
@@ -60,7 +60,8 @@
   std::vector> Conditions;
   // Mutations that this fragment will apply to the configuration.
   // These are invoked only if the conditions are satisfied.
-  std::vector> Apply;
+  std::vector>
+  Apply;
 
   bool operator()(const Params &P, Config &C) const {
 for (const auto &C : Conditions) {
@@ -71,7 +72,7 @@
 }
 dlog("Config fragment {0}: applying {1} rules", this, Apply.size());
 for (const auto &A : Apply)
-  A(C);
+  A(P, C);
 return true;
   }
 };
@@ -208,7 +209,7 @@
   for (auto &A : F.Remove)
 Remove->strip(*A);
   Out.Apply.push_back([Remove(std::shared_ptr(
-  std::move(Remove)))](Config &C) {
+  std::move(Remove)))](const Params &, Config &C) {
 C.CompileFlags.Edits.push_back(
 [Remove](std::vector &Args) {
   Remove->process(Args);
@@ -220,7 +221,7 @@
   std::vector Add;
   for (auto &A : F.Add)
 Add.push_back(std::move(*A));
-  Out.Apply.push_back([Add(std::move(Add))](Config &C) {
+  Out.Apply.push_back([Add(std::move(Add))](const Params &, Config &C) {
 C.CompileFlags.Edits.push_back([Add](std::vector &Args) {
   Args.insert(Args.end(), Add.begin(), Add.end());
 });
@@ -235,7 +236,8 @@
  .map("Build", Config::BackgroundPolicy::Build)
  .map("Skip", Config::BackgroundPolicy::Skip)
  .value())
-Out.Apply.push_back([Val](Config &C) { C.Index.Background = *Val; });
+Out.Apply.push_back(
+[Val](const Params &, Config &C) { C.Index.Background = *Val; });
 }
   }
 
@@ -250,7 +252,8 @@
 FullyQualifiedNamespaces.push_back(Namespace.str());
   }
   Out.Apply.push_back([FullyQualifiedNamespaces(
-  std::move(FullyQualifiedNamespaces))](Config &C) 
{
+  std::move(FullyQualifiedNamespaces))](
+  const Params &, Config &C) {
 C.Style.FullyQualifiedNamespaces.insert(
 C.Style.FullyQualifiedNamespaces.begin(),
 FullyQualifiedNamespaces.begin(), FullyQualifiedNamespaces.end());


Index: clang-tools-extra/clangd/ConfigCompile.cpp
===
--- clang-tools-extra/clangd/ConfigCompile.cpp
+++ clang-tools-extra/clangd/ConfigCompile.cpp
@@ -60,7 +60,8 @@
   std::vector> Conditions;
   // Mutations that this fragment will apply to the configuration.
   // These are invoked only if the conditions are satisfied.
-  std::vector> Apply;
+  std::vector>
+  Apply;
 
   bool operator()(const Params &P, Config &C) const {
 for (const auto &C : Conditions) {
@@ -71,7 +72,7 @@
 }
 dlog("Config fragment {0}: applying {1} rules", this, Apply.size());
 for (const auto &A : Apply)
-  A(C);
+  A(P, C);
 return true;
   }
 };
@@ -208,7 +209,7 @@
   for (auto &A : F.Remove)
 Remove->strip(*A);
   Out.Apply.push_back([Remove(std::shared_ptr(
-  std::move(Remove)))](Config &C) {
+  std::move(Remove)))](const Params &, Config &C) {
 C.CompileFlags.Edits.push_back(
 [Remove](std::vector &Args) {
   Remove->process(Args);
@@ -220,7 +221,7 @@
   std::vector Add;
   for (auto &A : F.Add)
 Add.push_back(std::move(*A));
-  Out.Apply.push_back([Add(std::move(Add))](Config &C) {
+  Out.Apply.push_back([Add(std::move(Add))](const Params &, Config &C) {
 C.CompileFlags.Edits.push_back([Add](std::vector &Args) {
   Args.insert(Args.end(), Add.begin(), Add.end());
 });
@@ -235,7 +236,8 @@
  .map("Build", Config::BackgroundPolicy::Build)
  .map("Skip", Config::BackgroundPolicy::Skip)
  .value())
-Out.Apply.push_back([Val](Config &C) { C.Index.Background = *Val; });
+Out.Apply.push_back(
+[Val](const Params &, Config &C) { C.Index.Background = *Val; });
 }
   }
 
@@ -250,7 +252,8 @@
 FullyQualifiedNamespaces.push_back(Namespace.str());
   }
   Out.Apply

[clang-tools-extra] 888969f - [clangd] Fix MSVC implicit capture build failure.

2020-10-30 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-10-30T11:36:59Z
New Revision: 888969f62abe6df9c9bafd593a6ba345577198b3

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

LOG: [clangd] Fix MSVC implicit capture build failure.

MSVC builds were failing because the constexpr wasn't couldn't be captured by 
the lamdba.

Fix an implicit double to float truncation warning as well.

Added: 


Modified: 
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 
b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index b2534bdf9c19..a7e1c6c48143 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -196,10 +196,10 @@ TEST(DecisionForestRankingModel, ReferencesAffectRanking) 
{
 
 TEST(DecisionForestRankingModel, DecisionForestScorerCallbackTest) {
   clangd::CodeCompleteOptions Opts;
-  constexpr float MagicNumber = 1234.5678;
+  constexpr float MagicNumber = 1234.5678f;
   Opts.RankingModel = CodeCompleteOptions::DecisionForest;
-  Opts.DecisionForestScorer = [](const SymbolQualitySignals &,
- const SymbolRelevanceSignals &, float Base) {
+  Opts.DecisionForestScorer = [&](const SymbolQualitySignals &,
+  const SymbolRelevanceSignals &, float Base) {
 DecisionForestScores Scores;
 Scores.Total = MagicNumber;
 Scores.ExcludingName = MagicNumber;



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


[PATCH] D89936: [clang-tidy] adding "--config-file=" to specify custom config file.

2020-10-30 Thread Hiral via Phabricator via cfe-commits
Hiralo added inline comments.



Comment at: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:329-330
+
+  if (!ConfigFile.empty()) {
+if (!Config.empty()) {
+  llvm::errs() << "Error: --config-file and --config are "

njames93 wrote:
> nit: Should we be using `Config(File)?.getNumOccurances() > 0` here and below
> If someone puts `--config=""` They are specifying a config(file)?, even if 
> its empty.
> nit: Should we be using `Config(File)?.getNumOccurances() > 0` here and below
> If someone puts `--config=""` They are specifying a config(file)?, even if 
> its empty.

Sounds good.

What is expected o/p with -config="" ? 

Currently it works as below...
$ ./myinstall/bin/clang-tidy -config="" --dump-config --
config_occurances =1
config_is_empty = yes


```
Checks:  'clang-diagnostic-*,clang-analyzer-*'

WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
  - key: llvm-else-after-return.WarnOnConditionVariables
...
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89936

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


[PATCH] D89936: [clang-tidy] adding "--config-file=" to specify custom config file.

2020-10-30 Thread Hiral via Phabricator via cfe-commits
Hiralo updated this revision to Diff 301862.
Hiralo added a comment.

clang-tidy: adding "--config-file=" to specify custom config file.

Let clang-tidy to read config from specified file.

This option internally works exactly the same way as --config option
after reading specified config file.

This option works as helper for --config in following few cases:

- when there is shell limitation to read file content to the command line,
- when there is limitation to command line length,
- setting right build dependencies, and
- others

--config-file and --config options are made mutually exclusive.

Example usage:
$ clang-tidy --config-file=/some/path/myTidyConfigFile --dump-config --
...this will read config from /some/path/myTidyConfigFile and

  avoid searching '.clang-tidy' in parent-dirs.

May speed-up tidy runtime since now it will just look-up 
instead of searching ".clang-tidy" in parent-dirs.

Reviewed By: DmitryPolukhin, njames93

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89936

Files:
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-file/config-file
  clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp


Index: clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp
@@ -0,0 +1,2 @@
+// RUN: clang-tidy -config-file=%S/Inputs/config-file/config-file -dump-config 
-- | FileCheck %s -check-prefix=CHECK-BASE
+// CHECK-BASE: Checks: {{.*}}hicpp-uppercase-literal-suffix
Index: 
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-file/config-file
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-file/config-file
@@ -0,0 +1 @@
+Checks: "-*,hicpp-uppercase-literal-suffix"
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -168,6 +168,16 @@
 )"),
cl::init(""), cl::cat(ClangTidyCategory));
 
+static cl::opt ConfigFile("config-file", cl::desc(R"(
+Specify the path of .clang-tidy or custom config file:
+ e.g. --config-file=/some/path/myTidyConfigFile
+This option internally works exactly the same way as
+ --config option after reading specified config file.
+Use either --config-file or --config, not both.
+)"),
+   cl::init(""),
+   cl::cat(ClangTidyCategory));
+
 static cl::opt DumpConfig("dump-config", cl::desc(R"(
 Dumps configuration in the YAML format to
 stdout. This option can be used along with a
@@ -302,19 +312,41 @@
   if (UseColor.getNumOccurrences() > 0)
 OverrideOptions.UseColor = UseColor;
 
-  if (!Config.empty()) {
-if (llvm::ErrorOr ParsedConfig =
-parseConfiguration(Config)) {
+  auto LoadConfig = [&](StringRef Configuration)
+  -> std::unique_ptr {
+llvm::ErrorOr ParsedConfig =
+parseConfiguration(Configuration);
+if (ParsedConfig)
   return std::make_unique(
   GlobalOptions,
   ClangTidyOptions::getDefaults().mergeWith(DefaultOptions, 0),
   *ParsedConfig, OverrideOptions, std::move(FS));
-} else {
-  llvm::errs() << "Error: invalid configuration specified.\n"
-   << ParsedConfig.getError().message() << "\n";
+llvm::errs() << "Error: invalid configuration specified.\n"
+ << ParsedConfig.getError().message() << "\n";
+return nullptr;
+  };
+
+  if (ConfigFile.getNumOccurrences() > 0) {
+if (Config.getNumOccurrences() > 0) {
+  llvm::errs() << "Error: --config-file and --config are "
+  "mutually exclusive. Specify only one.\n";
   return nullptr;
 }
+
+llvm::ErrorOr> Text =
+llvm::MemoryBuffer::getFile(ConfigFile.c_str());
+if (std::error_code EC = Text.getError()) {
+  llvm::errs() << "Error: can't read config-file '" << ConfigFile
+   << "': " << EC.message() << "\n";
+  return nullptr;
+}
+
+return LoadConfig((*Text)->getBuffer());
   }
+
+  if (Config.getNumOccurrences() > 0)
+return LoadConfig(Config);
+
   return std::make_unique(GlobalOptions, DefaultOptions,
 OverrideOptions, 
std::move(FS));
 }


Index: clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-file.cpp
@@ -0,0 +1,2 @@
+// RUN: clang-tidy -

[clang] 52ff86d - [AST] Fix traversal over CXXConstructExpr in Syntactic mode

2020-10-30 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2020-10-30T12:14:41Z
New Revision: 52ff86d25598175d3304498b14c0f6c780e46ae3

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

LOG: [AST] Fix traversal over CXXConstructExpr in Syntactic mode

Summary:
Skip over elidable nodes, and ensure that intermediate
CXXFunctionalCastExpr nodes are also skipped if they are semantic.

Reviewers: klimek, ymandel

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/AST/Expr.cpp
clang/lib/AST/ParentMapContext.cpp
clang/unittests/AST/ASTTraverserTest.cpp
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index c6b2c47a48fb..f55ee20f2476 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -2816,13 +2816,18 @@ Expr *Expr::IgnoreParenNoopCasts(const ASTContext &Ctx) 
{
 
 Expr *Expr::IgnoreUnlessSpelledInSource() {
   auto IgnoreImplicitConstructorSingleStep = [](Expr *E) {
+if (auto *Cast = dyn_cast(E)) {
+  auto *SE = Cast->getSubExpr();
+  if (SE->getSourceRange() == E->getSourceRange())
+return SE;
+}
+
 if (auto *C = dyn_cast(E)) {
   auto NumArgs = C->getNumArgs();
   if (NumArgs == 1 ||
   (NumArgs > 1 && isa(C->getArg(1 {
 Expr *A = C->getArg(0);
-if (A->getSourceRange() == E->getSourceRange() ||
-!isa(C))
+if (A->getSourceRange() == E->getSourceRange() || C->isElidable())
   return A;
   }
 }

diff  --git a/clang/lib/AST/ParentMapContext.cpp 
b/clang/lib/AST/ParentMapContext.cpp
index bae4d016ff6b..c80c8bc23e00 100644
--- a/clang/lib/AST/ParentMapContext.cpp
+++ b/clang/lib/AST/ParentMapContext.cpp
@@ -154,8 +154,13 @@ class ParentMapContext::ParentMap {
 
   auto SR = Child->getSourceRange();
 
+  if (const auto *C = dyn_cast(E)) {
+if (C->getSourceRange() == SR)
+  return true;
+  }
+
   if (const auto *C = dyn_cast(E)) {
-if (C->getSourceRange() == SR || !isa(C))
+if (C->getSourceRange() == SR || C->isElidable())
   return true;
   }
 

diff  --git a/clang/unittests/AST/ASTTraverserTest.cpp 
b/clang/unittests/AST/ASTTraverserTest.cpp
index 2f131c3fd04f..c24b43164cc8 100644
--- a/clang/unittests/AST/ASTTraverserTest.cpp
+++ b/clang/unittests/AST/ASTTraverserTest.cpp
@@ -299,6 +299,34 @@ void template_test() {
 void actual_template_test() {
   template_test<4>();
 }
+
+struct OneParamCtor {
+  explicit OneParamCtor(int);
+};
+struct TwoParamCtor {
+  explicit TwoParamCtor(int, int);
+};
+
+void varDeclCtors() {
+  {
+  auto var1 = OneParamCtor(5);
+  auto var2 = TwoParamCtor(6, 7);
+  }
+  {
+  OneParamCtor var3(5);
+  TwoParamCtor var4(6, 7);
+  }
+  int i = 0;
+  {
+  auto var5 = OneParamCtor(i);
+  auto var6 = TwoParamCtor(i, 7);
+  }
+  {
+  OneParamCtor var7(i);
+  TwoParamCtor var8(i, 7);
+  }
+}
+
 )cpp");
 
   {
@@ -444,6 +472,145 @@ StaticAssertDecl
 `-StringLiteral
 )cpp");
   }
+
+  auto varChecker = [&AST](StringRef varName, StringRef SemanticDump,
+   StringRef SyntacticDump) {
+auto FN = ast_matchers::match(
+functionDecl(
+hasName("varDeclCtors"),
+forEachDescendant(varDecl(hasName(varName)).bind("varDeclCtor"))),
+AST->getASTContext());
+EXPECT_EQ(FN.size(), 1u);
+
+EXPECT_EQ(dumpASTString(TK_AsIs, FN[0].getNodeAs("varDeclCtor")),
+  SemanticDump);
+
+EXPECT_EQ(dumpASTString(TK_IgnoreUnlessSpelledInSource,
+FN[0].getNodeAs("varDeclCtor")),
+  SyntacticDump);
+  };
+
+  varChecker("var1",
+ R"cpp(
+VarDecl 'var1'
+`-ExprWithCleanups
+  `-CXXConstructExpr
+`-MaterializeTemporaryExpr
+  `-CXXFunctionalCastExpr
+`-CXXConstructExpr
+  `-IntegerLiteral
+)cpp",
+ R"cpp(
+VarDecl 'var1'
+`-CXXConstructExpr
+  `-IntegerLiteral
+)cpp");
+
+  varChecker("var2",
+ R"cpp(
+VarDecl 'var2'
+`-ExprWithCleanups
+  `-CXXConstructExpr
+`-MaterializeTemporaryExpr
+  `-CXXTemporaryObjectExpr
+|-IntegerLiteral
+`-IntegerLiteral
+)cpp",
+ R"cpp(
+VarDecl 'var2'
+`-CXXTemporaryObjectExpr
+  |-IntegerLiteral
+  `-IntegerLiteral
+)cpp");
+
+  varChecker("var3",
+ R"cpp(
+VarDecl 'var3'
+`-CXXConstructExpr
+  `-IntegerLiteral
+)cpp",
+ R"cpp(
+VarDecl 'var3'
+`-CXXConstructExpr
+  `-IntegerLiteral
+)cpp");
+
+  varChecker("var4",
+ R"cpp(
+VarDecl 'var4'
+`-CXXConstructExpr
+  |-IntegerLiteral
+  `-IntegerLiteral
+)cpp",
+ R"cpp(
+VarDecl 'var4'
+`-CXXConstructExpr
+  |-IntegerLiteral
+  `-IntegerLiteral
+)cpp"

[PATCH] D82278: Fix traversal over CXXConstructExpr in Syntactic mode

2020-10-30 Thread Stephen Kelly 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 rG52ff86d25598: [AST] Fix traversal over CXXConstructExpr in 
Syntactic mode (authored by stephenkelly).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82278

Files:
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ParentMapContext.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -2088,6 +2088,98 @@
 
   EXPECT_TRUE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource,
  staticAssertDecl(has(integerLiteral());
+
+  Code = R"cpp(
+
+struct OneParamCtor {
+  explicit OneParamCtor(int);
+};
+struct TwoParamCtor {
+  explicit TwoParamCtor(int, int);
+};
+
+void varDeclCtors() {
+  {
+  auto var1 = OneParamCtor(5);
+  auto var2 = TwoParamCtor(6, 7);
+  }
+  {
+  OneParamCtor var3(5);
+  TwoParamCtor var4(6, 7);
+  }
+  int i = 0;
+  {
+  auto var5 = OneParamCtor(i);
+  auto var6 = TwoParamCtor(i, 7);
+  }
+  {
+  OneParamCtor var7(i);
+  TwoParamCtor var8(i, 7);
+  }
+}
+
+)cpp";
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_AsIs, varDecl(hasName("var1"), hasInitializer(hasDescendant(
+ cxxConstructExpr()));
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_AsIs, varDecl(hasName("var2"), hasInitializer(hasDescendant(
+ cxxConstructExpr()));
+  EXPECT_TRUE(matches(
+  Code, traverse(TK_AsIs, varDecl(hasName("var3"),
+  hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code, traverse(TK_AsIs, varDecl(hasName("var4"),
+  hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_AsIs, varDecl(hasName("var5"), hasInitializer(hasDescendant(
+ cxxConstructExpr()));
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_AsIs, varDecl(hasName("var6"), hasInitializer(hasDescendant(
+ cxxConstructExpr()));
+  EXPECT_TRUE(matches(
+  Code, traverse(TK_AsIs, varDecl(hasName("var7"),
+  hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code, traverse(TK_AsIs, varDecl(hasName("var8"),
+  hasInitializer(cxxConstructExpr());
+
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   varDecl(hasName("var1"), hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   varDecl(hasName("var2"), hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   varDecl(hasName("var3"), hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   varDecl(hasName("var4"), hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   varDecl(hasName("var5"), hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   varDecl(hasName("var6"), hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   varDecl(hasName("var7"), hasInitializer(cxxConstructExpr());
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   varDecl(hasName("var8"), hasInitializer(cxxConstructExpr());
 }
 
 template 
@@ -2293,21 +2385,20 @@
  forFunction(functionDecl(hasName("func2"),
   langCxx20OrLater()));
 
-  EXPECT_TRUE(matches(
-  Code,
-  traverse(
-  TK_IgnoreUnlessSpelledInSource,
-  returnStmt(forFunction(functionDecl(hasName("func3"))),
- hasReturnValue(cxxFunctionalCastExpr(
- hasSourceExpression(integerLiteral(equals(42))),
-  langCxx20OrLater()));
+  EXPECT_TRUE(
+  matches(Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   returnStmt(forFunction(functionDecl(hasName("func3"))),
+  hasReturnValue(cxxConstructExpr(hasArgument(
+  0

[PATCH] D89936: [clang-tidy] adding "--config-file=" to specify custom config file.

2020-10-30 Thread Hiral via Phabricator via cfe-commits
Hiralo marked an inline comment as done.
Hiralo added inline comments.



Comment at: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:329-330
+
+  if (!ConfigFile.empty()) {
+if (!Config.empty()) {
+  llvm::errs() << "Error: --config-file and --config are "

Hiralo wrote:
> njames93 wrote:
> > nit: Should we be using `Config(File)?.getNumOccurances() > 0` here and 
> > below
> > If someone puts `--config=""` They are specifying a config(file)?, even if 
> > its empty.
> > nit: Should we be using `Config(File)?.getNumOccurances() > 0` here and 
> > below
> > If someone puts `--config=""` They are specifying a config(file)?, even if 
> > its empty.
> 
> Sounds good.
> 
> What is expected o/p with -config="" ? 
> 
> Currently it works as below...
> $ ./myinstall/bin/clang-tidy -config="" --dump-config --
> config_occurances =1
> config_is_empty = yes
> 
> 
> ```
> Checks:  'clang-diagnostic-*,clang-analyzer-*'
> 
> WarningsAsErrors: ''
> HeaderFilterRegex: ''
> AnalyzeTemporaryDtors: false
> FormatStyle: none
> CheckOptions:
>   - key: llvm-else-after-return.WarnOnConditionVariables
> ...
> ```
> nit: Should we be using `Config(File)?.getNumOccurances() > 0` here and below
> If someone puts `--config=""` They are specifying a config(file)?, even if 
> its empty.

Updated patch...

$ ./myinstall/bin/clang-tidy --config="" --config-file="" --dump-config --
Error: --config-file and --config are mutually exclusive. Specify only one.

Thanks,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89936

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


[PATCH] D89936: [clang-tidy] adding "--config-file=" to specify custom config file.

2020-10-30 Thread Hiral via Phabricator via cfe-commits
Hiralo added inline comments.



Comment at: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:329-330
+
+  if (!ConfigFile.empty()) {
+if (!Config.empty()) {
+  llvm::errs() << "Error: --config-file and --config are "

Hiralo wrote:
> Hiralo wrote:
> > njames93 wrote:
> > > nit: Should we be using `Config(File)?.getNumOccurances() > 0` here and 
> > > below
> > > If someone puts `--config=""` They are specifying a config(file)?, even 
> > > if its empty.
> > > nit: Should we be using `Config(File)?.getNumOccurances() > 0` here and 
> > > below
> > > If someone puts `--config=""` They are specifying a config(file)?, even 
> > > if its empty.
> > 
> > Sounds good.
> > 
> > What is expected o/p with -config="" ? 
> > 
> > Currently it works as below...
> > $ ./myinstall/bin/clang-tidy -config="" --dump-config --
> > config_occurances =1
> > config_is_empty = yes
> > 
> > 
> > ```
> > Checks:  'clang-diagnostic-*,clang-analyzer-*'
> > 
> > WarningsAsErrors: ''
> > HeaderFilterRegex: ''
> > AnalyzeTemporaryDtors: false
> > FormatStyle: none
> > CheckOptions:
> >   - key: llvm-else-after-return.WarnOnConditionVariables
> > ...
> > ```
> > nit: Should we be using `Config(File)?.getNumOccurances() > 0` here and 
> > below
> > If someone puts `--config=""` They are specifying a config(file)?, even if 
> > its empty.
> 
> Updated patch...
> 
> $ ./myinstall/bin/clang-tidy --config="" --config-file="" --dump-config --
> Error: --config-file and --config are mutually exclusive. Specify only one.
> 
> Thanks,
> > nit: Should we be using `Config(File)?.getNumOccurances() > 0` here and 
> > below
> > If someone puts `--config=""` They are specifying a config(file)?, even if 
> > its empty.
> 
> Updated patch...
> 
> $ ./myinstall/bin/clang-tidy --config="" --config-file="" --dump-config --
> Error: --config-file and --config are mutually exclusive. Specify only one.
> 
> Thanks,

and

$ ./myinstall/bin/clang-tidy --config-file="" --dump-config --
Error: can't read config-file '': No such file or directory




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89936

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


[PATCH] D90452: [clangd] Respect codeAction.isPreferredSupport in client capabilities

2020-10-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I hadn't seen the bug, will ask here what the problem is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90452

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


[PATCH] D90452: [clangd] Respect codeAction.isPreferredSupport in client capabilities

2020-10-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Hang on - why do we need to do this?

In general we don't do client feature detection for every piece of 
functionality we have, only when it causes us to behave incompatibly.
And again in general we assume that setting extra properties on JSON objects is 
compatible. (e.g. `score` extensions on code completion).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90452

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


[PATCH] D72218: [clang-tidy] new altera kernel name restriction check

2020-10-30 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 301865.
ffrankies marked an inline comment as done.
ffrankies added a comment.

Implemented changes requested by @aaron.ballman

- Added a helper function that implements the string comparison logic
- Clarified that check is case insensitive
- Removed unused identifiers from 
`KernelNameRestrictionPPCallbacks::InclusionDirective` function


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

https://reviews.llvm.org/D72218

Files:
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp
  clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/altera-kernel-name-restriction.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/KERNEL.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/VHDL.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/Verilog.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/kernel.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/kernel.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/other_Verilog.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/otherdir/vhdl.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/otherthing.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/some/dir/kernel.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/some/kernel.cl/foo.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/some/verilog.cl/foo.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/some/vhdl.cl/foo.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/some_kernel.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/somedir/verilog.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/thing.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/vERILOG.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/verilog.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/vhdl.CL
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/vhdl.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/vhdl_number_two.cl
  clang-tools-extra/test/clang-tidy/checkers/altera-kernel-name-restriction.cpp
  llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/altera/BUILD.gn

Index: llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/altera/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/altera/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/altera/BUILD.gn
@@ -13,6 +13,7 @@
   ]
   sources = [
 "AlteraTidyModule.cpp",
+"KernelNameRestrictionCheck.cpp",
 "StructPackAlignCheck.cpp",
   ]
 }
Index: clang-tools-extra/test/clang-tidy/checkers/altera-kernel-name-restriction.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-kernel-name-restriction.cpp
@@ -0,0 +1,50 @@
+// RUN: %check_clang_tidy %s altera-kernel-name-restriction %t -- -- -I%S/Inputs/altera-kernel-name-restriction
+
+// These are the banned kernel filenames, and should trigger warnings
+#include "kernel.cl"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: including 'kernel.cl' may cause additional compilation errors due to the name of the kernel source file; consider renaming the included kernel source file [altera-kernel-name-restriction]
+#include "Verilog.cl"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: including 'Verilog.cl' may cause additional compilation errors due to the name of the kernel source file; consider renaming the included kernel source file [altera-kernel-name-restriction]
+#include "VHDL.cl"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: including 'VHDL.cl' may cause additional compilation errors due to the name of the kernel source file; consider renaming the included kernel source file [altera-kernel-name-restriction]
+
+// The warning should be triggered regardless of capitalization
+#include "KERNEL.cl"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: including 'KERNEL.cl' may cause additional compilation errors due to the name of the kernel source file; consider renaming the included kernel source file [altera-kernel-name-restriction]
+#include 

[PATCH] D72218: [clang-tidy] new altera kernel name restriction check

2020-10-30 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies marked 3 inline comments as done.
ffrankies added a comment.

@aaron.ballman Can you please commit this on my behalf? My github username is 
ffrankies .

And could you take a look at D72241 altera single work item barrier check 
? It's also been updated and awaiting review.




Comment at: 
clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp:90
+Check.diag(SM.getLocForStartOfFile(SM.getMainFileID()),
+   "Naming your OpenCL kernel source file 'kernel.cl', 
'Verilog.cl'"
+   ", or 'VHDL.cl' could cause compilation errors.");

aaron.ballman wrote:
> aaron.ballman wrote:
> > Similar here, I would word it something like: `compiling a source file 
> > named '%0' may result in additional compilation errors due to the name of 
> > the file; consider renaming the source file`
> The diagnostic here doesn't look quite right. This is the case where the 
> source compiland is named poorly, but the diagnostic is talking about 
> including files. It looks like there's test coverage missing for this.
My bad, I copied this line over the from other diagnostic and didn't change 
"including" to "compiling". Will update shortly



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/altera-kernel-name-restriction.cpp:40
+// The files can still have the forbidden names in them, so long as they're 
not the entire file name
+#include "some_kernel.cl"
+#include "other_Verilog.cl"

aaron.ballman wrote:
> I assume it's also fine if the user does something really weird like: 
> `#include "kernel.cl/foo.h"` ?
Yes, this is fine. The guide only specifies potential errors when the kernel 
source file is named kernel.cl, verilog.cl, or vhdl.cl. 

I've added additional test cases that use these names as directory names below.


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

https://reviews.llvm.org/D72218

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


[PATCH] D90457: [clang][driver] Set LTO mode based on input files

2020-10-30 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: tstellar, sfantao, tejohnson.
Herald added subscribers: cfe-commits, steven_wu, hiraditya, inglorion, mgorny.
Herald added a project: clang.
tbaeder requested review of this revision.

After setting the LTO mode from the -flto option, look at the input files as 
well. If any of them is an object file containing LLVM bitcode,
set the LTO mode to either thin or full, depending on the input file.

This makes the following sample work:

  clang test.c -c -flto
  clang test.o

Which also works when using GCC. Currently this makes non-lld linkers print an 
error, for example when using ld.bfd:

  $ clang test.o
  test.o: file not recognized: file format not recognized
  clang-10: error: linker command failed with exit code 1 (use -v to see 
invocation)




Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90457

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/thinlto_backend.c

Index: clang/test/Driver/thinlto_backend.c
===
--- clang/test/Driver/thinlto_backend.c
+++ clang/test/Driver/thinlto_backend.c
@@ -24,3 +24,13 @@
 // RUN: not %clang -O2 -o %t1.o %s -c -fthinlto-index=%t.thinlto.bc 2>&1 \
 // RUN: | FileCheck %s -check-prefix=CHECK-WARNING
 // CHECK-WARNING: error: option '-fthinlto-index={{.*}}' requires input to be LLVM bitcode
+
+// thinlto enabled without -flto=thin explicitly passed
+// RUN: %clang -O2 %s -c -flto=thin -o %r.o
+// RUN: %clang %r.o -### 2>&1 | FileCheck %s -check-prefix=CHECK-THIN-LTO-ENABLED
+// CHECK-THIN-LTO-ENABLED: -plugin-opt=thinlto
+
+// Same for full LTO
+// RUN: %clang -O2 %s -target x86_64-unknown-linux-gnu -c -flto=full -o %r.o
+// RUN: %clang %r.o -### 2>&1 | FileCheck %s -check-prefix=CHECK-FULL-LTO-ENABLED
+// CHECK-FULL-LTO-ENABLED: LLVMgold
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -64,6 +64,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
@@ -586,6 +587,43 @@
   return Target;
 }
 
+static LTOKind
+getInputLTOMode(const std::pair Input) {
+  // Must be an object file
+  if (Input.first != types::TY_Object)
+return LTOK_None;
+
+  // ... and contain LLVM bitcode
+  for (const char *Filename : Input.second->getValues()) {
+auto Buff = llvm::MemoryBuffer::getFile(Filename);
+if (Buff) {
+  auto R = (*Buff)->getMemBufferRef();
+  Expected LTOInfo = llvm::getBitcodeLTOInfo(R);
+
+  if (LTOInfo)
+return LTOInfo->IsThinLTO ? LTOK_Thin : LTOK_Full;
+
+  llvm::consumeError(LTOInfo.takeError());
+}
+  }
+
+  return LTOK_None;
+}
+
+void Driver::setLTOModeFromInputFiles(const InputList *Inputs) {
+  if (LTOMode != LTOK_None)
+return;
+
+  for (auto Input : *Inputs) {
+auto InputLTOMode = getInputLTOMode(Input);
+
+if (InputLTOMode != LTOK_None) {
+  LTOMode = InputLTOMode;
+  break;
+}
+  }
+}
+
 // Parse the LTO options and record the type of LTO compilation
 // based on which -f(no-)?lto(=.*)? option occurs last.
 void Driver::setLTOMode(const llvm::opt::ArgList &Args) {
@@ -1164,6 +1202,8 @@
   InputList Inputs;
   BuildInputs(C->getDefaultToolChain(), *TranslatedArgs, Inputs);
 
+  setLTOModeFromInputFiles(&Inputs);
+
   // Populate the tool chains for the offloading devices, if any.
   CreateOffloadingDeviceToolChains(*C, Inputs);
 
Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -3,6 +3,7 @@
   Option
   ProfileData
   Support
+  BitReader
   )
 
 if(WIN32)
Index: clang/include/clang/Driver/Driver.h
===
--- clang/include/clang/Driver/Driver.h
+++ clang/include/clang/Driver/Driver.h
@@ -578,6 +578,10 @@
   /// compilation based on which -f(no-)?lto(=.*)? option occurs last.
   void setLTOMode(const llvm::opt::ArgList &Args);
 
+  /// Parse the \p Inputs list for LTO inputs. LTO inputs are object files
+  /// that contain LLVM bitcode
+  void setLTOModeFromInputFiles(const InputList *Inputs);
+
   /// Retrieves a ToolChain for a particular \p Target triple.
   ///
   /// Will cache ToolChains for the life of the driver object, and create them
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90441: [X86] Add support for vex, vex2, vex3, and evex for MASM

2020-10-30 Thread Eric Astor via Phabricator via cfe-commits
epastor added inline comments.



Comment at: clang/test/CodeGen/X86/ms-inline-asm-prefix.c:1
+// RUN:%clang_cc1 %s -ferror-limit 0 -triple=x86_64-pc-widows-msvc 
-target-feature +avx512f -target-feature +avx2 -target-feature +avx512vl 
-fasm-blocks -mllvm -x86-asm-syntax=intel -S -o -  | FileCheck %s -check-prefix 
CHECK
+

pengfei wrote:
> pengfei wrote:
> > pengfei wrote:
> > > Maybe need `// REQUIRES: x86-registered-target`
> > You may need add att check too since you modified the att code.
> Should it be avalible only when `-fms-compatibility`
The triple is misspelled; it should be `x86_64-pc-windows-msvc` (the "n" in 
windows is missing)



Comment at: clang/test/CodeGen/X86/ms-inline-asm-prefix.c:1
+// RUN:%clang_cc1 %s -ferror-limit 0 -triple=x86_64-pc-widows-msvc 
-target-feature +avx512f -target-feature +avx2 -target-feature +avx512vl 
-fasm-blocks -mllvm -x86-asm-syntax=intel -S -o -  | FileCheck %s -check-prefix 
CHECK
+

epastor wrote:
> pengfei wrote:
> > pengfei wrote:
> > > pengfei wrote:
> > > > Maybe need `// REQUIRES: x86-registered-target`
> > > You may need add att check too since you modified the att code.
> > Should it be avalible only when `-fms-compatibility`
> The triple is misspelled; it should be `x86_64-pc-windows-msvc` (the "n" in 
> windows is missing)
A broader question: As written, this applies to anything in Intel syntax. Is 
this an Intel syntax feature, or a MASM feature?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90441

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


Re: [clang] 552c6c2 - PR44406: Follow behavior of array bound constant folding in more recent versions of GCC.

2020-10-30 Thread Nico Weber via cfe-commits
Thanks!

Maybe the diag text for this case could be a bit friendlier :)

On Thu, Oct 29, 2020 at 10:41 PM Richard Smith 
wrote:

> On Thu, 29 Oct 2020 at 19:32, Nico Weber  wrote:
>
>> On Thu, Oct 29, 2020 at 6:10 PM Richard Smith 
>> wrote:
>>
>>> On Thu, 29 Oct 2020 at 08:07, Nico Weber  wrote:
>>>
 Hi Richard,

 this fires on

 thakis@thakis:~/src/llvm-project$ cat foo.m
 static const int gSignals[] = { 0, 1, 2, 3, 4 };
 static const int kNumSignals = sizeof(gSignals) / sizeof(gSignals[0]);
 static int gPreviousSignalHandlers[kNumSignals];

 thakis@thakis:~/src/llvm-project$ out/gn/bin/clang -c foo.m
 foo.m:3:12: warning: variable length array folded to constant array as
 an extension [-Wgnu-folding-constant]
 static int gPreviousSignalHandlers[kNumSignals];
^
 1 warning generated.


 Is that intentional? I don't see the VLA there.

>>>
>>> gPreviousSignalHandlers is a VLA. Unlike C++, C doesn't permit the use
>>> of a 'const int' variable in a constant expression.
>>>
>>
>> What's the suggested alternative?
>>
>
> This should work reliably:
>
> -static const int kNumSignals = sizeof(gSignals) / sizeof(gSignals[0]);
> +enum { kNumSignals = sizeof(gSignals) / sizeof(gSignals[0]) };
>
>
>> On Fri, Oct 16, 2020 at 5:34 PM Richard Smith via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

>
> Author: Richard Smith
> Date: 2020-10-16T14:34:35-07:00
> New Revision: 552c6c2328723a248c2b4d2765f75d49129dff20
>
> URL:
> https://github.com/llvm/llvm-project/commit/552c6c2328723a248c2b4d2765f75d49129dff20
> DIFF:
> https://github.com/llvm/llvm-project/commit/552c6c2328723a248c2b4d2765f75d49129dff20.diff
>
> LOG: PR44406: Follow behavior of array bound constant folding in more
> recent versions of GCC.
>
> Old GCC used to aggressively fold VLAs to constant-bound arrays at
> block
> scope in GNU mode. That's non-conforming, and more modern versions of
> GCC only do this at file scope. Update Clang to do the same.
>
> Also promote the warning for this from off-by-default to on-by-default
> in all cases; more recent versions of GCC likewise warn on this by
> default.
>
> This is still slightly more permissive than GCC, as pointed out in
> PR44406, as we still fold VLAs to constant arrays in structs, but that
> seems justifiable given that we don't support VLA-in-struct (and don't
> intend to ever support it), but GCC does.
>
> Differential Revision: https://reviews.llvm.org/D89523
>
> Added:
>
>
> Modified:
> clang/docs/UsersManual.rst
> clang/include/clang/Basic/DiagnosticSemaKinds.td
> clang/lib/Sema/SemaDecl.cpp
> clang/lib/Sema/SemaType.cpp
> clang/test/CXX/basic/basic.types/p10.cpp
> clang/test/CXX/drs/dr3xx.cpp
> clang/test/CodeGen/vla.c
> clang/test/Misc/warning-flags.c
> clang/test/PCH/cxx-constexpr.cpp
> clang/test/Profile/misexpect-switch-default.c
> clang/test/Profile/misexpect-switch-nonconst.c
> clang/test/Profile/misexpect-switch-only-default-case.c
> clang/test/Profile/misexpect-switch.c
> clang/test/Sema/builtin-assume.c
> clang/test/Sema/builtins.c
> clang/test/Sema/complex-int.c
> clang/test/Sema/const-eval-64.c
> clang/test/Sema/const-eval.c
> clang/test/Sema/darwin-align-cast.c
> clang/test/Sema/decl-in-prototype.c
> clang/test/Sema/gnu-flags.c
> clang/test/Sema/i-c-e.c
> clang/test/Sema/offsetof-64.c
> clang/test/Sema/rounding-math.c
> clang/test/Sema/struct-decl.c
> clang/test/Sema/typedef-variable-type.c
> clang/test/Sema/vla.c
> clang/test/SemaCXX/anonymous-struct.cpp
> clang/test/SemaCXX/constant-expression.cpp
> clang/test/SemaCXX/cxx1z-noexcept-function-type.cpp
> clang/test/SemaCXX/i-c-e-cxx.cpp
> clang/test/SemaObjC/gcc-cast-ext.m
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
> index 473fbb6d8d04..9726a25f7f63 100644
> --- a/clang/docs/UsersManual.rst
> +++ b/clang/docs/UsersManual.rst
> @@ -2502,10 +2502,6 @@ Differences between all ``c*`` and ``gnu*``
> modes:
>  -  The Apple "blocks" extension is recognized by default in ``gnu*``
> modes
> on some platforms; it can be enabled in any mode with the
> ``-fblocks``
> option.
> --  Arrays that are VLA's according to the standard, but which can be
> -   constant folded by the frontend are treated as fixed size arrays.
> -   This occurs for things like "int X[(1, 2)];", which is technically
> a
> -   VLA. ``c*`` modes are strictly compliant a

[clang] 13bfd89 - [clang][FPEnv] Diagnose Strict FP pragmas if target does not support StrictFP

2020-10-30 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-10-30T06:11:25-07:00
New Revision: 13bfd89c4962e738cbe50662013267b33a678b8f

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

LOG: [clang][FPEnv] Diagnose Strict FP pragmas if target does not support 
StrictFP

Reviewers: sepavloff, kpn, aaron.ballman

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

Added: 
clang/test/Parser/pragma-fp-warn.c

Modified: 
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/lib/Parse/ParsePragma.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 24ca8340ef6f..0fd4eb5323de 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1147,6 +1147,9 @@ def warn_stdc_fenv_round_not_supported :
 def warn_stdc_unknown_rounding_mode : Warning<
   "invalid or unsupported rounding mode in '#pragma STDC FENV_ROUND' - 
ignored">,
   InGroup;
+def warn_pragma_fp_ignored : Warning<
+  "'#pragma %0' is not supported on this target - ignored">,
+  InGroup;
 // - #pragma comment
 def err_pragma_comment_malformed : Error<
   "pragma comment requires parenthesized identifier and optional string">;

diff  --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index 36bfeeebfef3..278e6f50deba 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -103,6 +103,12 @@ struct PragmaSTDC_FENV_ACCESSHandler : public 
PragmaHandler {
 
   void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
 Token &Tok) override {
+Token PragmaName = Tok;
+if (!PP.getTargetInfo().hasStrictFP() && !PP.getLangOpts().ExpStrictFP) {
+  PP.Diag(Tok.getLocation(), diag::warn_pragma_fp_ignored)
+  << PragmaName.getIdentifierInfo()->getName();
+  return;
+}
 tok::OnOffSwitch OOS;
 if (PP.LexOnOffSwitch(OOS))
  return;
@@ -2553,6 +2559,12 @@ void 
PragmaFloatControlHandler::HandlePragma(Preprocessor &PP,
  Token &Tok) {
   Sema::PragmaMsStackAction Action = Sema::PSK_Set;
   SourceLocation FloatControlLoc = Tok.getLocation();
+  Token PragmaName = Tok;
+  if (!PP.getTargetInfo().hasStrictFP() && !PP.getLangOpts().ExpStrictFP) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_fp_ignored)
+<< PragmaName.getIdentifierInfo()->getName();
+return;
+  }
   PP.Lex(Tok);
   if (Tok.isNot(tok::l_paren)) {
 PP.Diag(FloatControlLoc, diag::err_expected) << tok::l_paren;
@@ -2952,6 +2964,11 @@ void 
PragmaSTDC_FENV_ROUNDHandler::HandlePragma(Preprocessor &PP,
 Token &Tok) {
   Token PragmaName = Tok;
   SmallVector TokenList;
+  if (!PP.getTargetInfo().hasStrictFP() && !PP.getLangOpts().ExpStrictFP) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_fp_ignored)
+<< PragmaName.getIdentifierInfo()->getName();
+return;
+  }
 
   PP.Lex(Tok);
   if (Tok.isNot(tok::identifier)) {

diff  --git a/clang/test/Parser/pragma-fp-warn.c 
b/clang/test/Parser/pragma-fp-warn.c
new file mode 100644
index ..21a2cccf4d8f
--- /dev/null
+++ b/clang/test/Parser/pragma-fp-warn.c
@@ -0,0 +1,19 @@
+
+// RUN: %clang_cc1 -triple wasm32 -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -triple thumbv7 -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -triple aarch64 -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -DEXPOK -triple x86_64 -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -DEXPOK -triple systemz -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -DEXPOK -triple powerpc -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+#ifdef EXPOK
+// expected-no-diagnostics
+#else
+// expected-warning@+4 {{'#pragma float_control' is not supported on this 
target - ignored}}
+// expected-warning@+5 {{'#pragma FENV_ACCESS' is not supported on this target 
- ignored}}
+// expected-warning@+6 {{'#pragma FENV_ROUND' is not supported on this target 
- ignored}}
+#endif
+#pragma float_control(precise, on)
+
+#pragma STDC FENV_ACCESS OFF
+
+#pragma STDC FENV_ROUND FE_DOWNWARD



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


[PATCH] D90316: [FPEnv] Diagnose pragmas FENV_ROUND,_ACCESS and float_control if target does not support StrictFP

2020-10-30 Thread Melanie Blower via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
mibintc marked an inline comment as done.
Closed by commit rG13bfd89c4962: [clang][FPEnv] Diagnose Strict FP pragmas if 
target does not support StrictFP (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90316

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParsePragma.cpp
  clang/test/Parser/pragma-fp-warn.c


Index: clang/test/Parser/pragma-fp-warn.c
===
--- /dev/null
+++ clang/test/Parser/pragma-fp-warn.c
@@ -0,0 +1,19 @@
+
+// RUN: %clang_cc1 -triple wasm32 -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -triple thumbv7 -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -triple aarch64 -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -DEXPOK -triple x86_64 -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -DEXPOK -triple systemz -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -DEXPOK -triple powerpc -fsyntax-only -Wno-unknown-pragmas 
-Wignored-pragmas -verify %s
+#ifdef EXPOK
+// expected-no-diagnostics
+#else
+// expected-warning@+4 {{'#pragma float_control' is not supported on this 
target - ignored}}
+// expected-warning@+5 {{'#pragma FENV_ACCESS' is not supported on this target 
- ignored}}
+// expected-warning@+6 {{'#pragma FENV_ROUND' is not supported on this target 
- ignored}}
+#endif
+#pragma float_control(precise, on)
+
+#pragma STDC FENV_ACCESS OFF
+
+#pragma STDC FENV_ROUND FE_DOWNWARD
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -103,6 +103,12 @@
 
   void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
 Token &Tok) override {
+Token PragmaName = Tok;
+if (!PP.getTargetInfo().hasStrictFP() && !PP.getLangOpts().ExpStrictFP) {
+  PP.Diag(Tok.getLocation(), diag::warn_pragma_fp_ignored)
+  << PragmaName.getIdentifierInfo()->getName();
+  return;
+}
 tok::OnOffSwitch OOS;
 if (PP.LexOnOffSwitch(OOS))
  return;
@@ -2553,6 +2559,12 @@
  Token &Tok) {
   Sema::PragmaMsStackAction Action = Sema::PSK_Set;
   SourceLocation FloatControlLoc = Tok.getLocation();
+  Token PragmaName = Tok;
+  if (!PP.getTargetInfo().hasStrictFP() && !PP.getLangOpts().ExpStrictFP) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_fp_ignored)
+<< PragmaName.getIdentifierInfo()->getName();
+return;
+  }
   PP.Lex(Tok);
   if (Tok.isNot(tok::l_paren)) {
 PP.Diag(FloatControlLoc, diag::err_expected) << tok::l_paren;
@@ -2952,6 +2964,11 @@
 Token &Tok) {
   Token PragmaName = Tok;
   SmallVector TokenList;
+  if (!PP.getTargetInfo().hasStrictFP() && !PP.getLangOpts().ExpStrictFP) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_fp_ignored)
+<< PragmaName.getIdentifierInfo()->getName();
+return;
+  }
 
   PP.Lex(Tok);
   if (Tok.isNot(tok::identifier)) {
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1147,6 +1147,9 @@
 def warn_stdc_unknown_rounding_mode : Warning<
   "invalid or unsupported rounding mode in '#pragma STDC FENV_ROUND' - 
ignored">,
   InGroup;
+def warn_pragma_fp_ignored : Warning<
+  "'#pragma %0' is not supported on this target - ignored">,
+  InGroup;
 // - #pragma comment
 def err_pragma_comment_malformed : Error<
   "pragma comment requires parenthesized identifier and optional string">;


Index: clang/test/Parser/pragma-fp-warn.c
===
--- /dev/null
+++ clang/test/Parser/pragma-fp-warn.c
@@ -0,0 +1,19 @@
+
+// RUN: %clang_cc1 -triple wasm32 -fsyntax-only -Wno-unknown-pragmas -Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -triple thumbv7 -fsyntax-only -Wno-unknown-pragmas -Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -triple aarch64 -fsyntax-only -Wno-unknown-pragmas -Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -DEXPOK -triple x86_64 -fsyntax-only -Wno-unknown-pragmas -Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -DEXPOK -triple systemz -fsyntax-only -Wno-unknown-pragmas -Wignored-pragmas -verify %s
+// RUN: %clang_cc1 -DEXPOK -triple powerpc -fsyntax-only -Wno-unknown-pragmas -Wignored-pragmas -verify %s
+#ifdef EXPOK
+// expected-no-diagnostics
+#else
+// expected-warning@+4 {{'#pragma float_control' is not supported 

[PATCH] D90448: [clang] Add type check for explicit instantiation of static data members

2020-10-30 Thread Chuyang Chen via Phabricator via cfe-commits
nomanous updated this revision to Diff 301872.
nomanous added a comment.

Change some format.


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

https://reviews.llvm.org/D90448

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/SemaCXX/template-explicit-instant-type-mismatch.cpp

Index: clang/test/SemaCXX/template-explicit-instant-type-mismatch.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/template-explicit-instant-type-mismatch.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+template
+class A
+{
+ static T a; //expected-note {{in instantiation of static data member 'A::a' requested here}}
+};
+
+template
+T A::a;
+
+class B
+{ };
+
+template T c; //expected-note {{variable template 'c' declared here}}
+
+template int c; //expected-error {{type 'int' of explicit instantiation of 'c' does not match expected type 'B'}}
+
+template int A::a; //expected-error {{type 'int' of explicit instantiation of 'A::a' does not match expected type 'B'}}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -9977,6 +9977,7 @@
 
 VarDecl *Prev = Previous.getAsSingle();
 VarTemplateDecl *PrevTemplate = Previous.getAsSingle();
+bool IsStaticDataMemberInstantiation = false;
 
 if (!PrevTemplate) {
   if (!Prev || !Prev->isStaticDataMember()) {
@@ -9998,6 +,8 @@
 // FIXME: Can we provide a note showing where this was declared?
 return true;
   }
+
+  IsStaticDataMemberInstantiation = true;
 } else {
   // Explicitly instantiate a variable template.
 
@@ -10090,6 +10093,23 @@
   return true;
 }
 
+// Check the static member's type given in the explicit instantiation
+// definition against the one in the class template. This won't happen in
+// explicit instantiation declaration because the instantiated code won't
+// be generated in that case. Objective C lifetime qualifiers will be
+// automatically added by compiler with option -fobjc-arc so it should be
+// ignored when comparing types.
+if (IsStaticDataMemberInstantiation &&
+TSK==TSK_ExplicitInstantiationDefinition && Prev &&
+!Context.hasSameType(Prev->getType(), R, true)) {
+  Diag(T->getTypeLoc().getBeginLoc(),
+   diag::err_invalid_template_static_data_member_spec_type)
+  << Prev << R << Prev->getType();
+  Diag(Prev->getLocation(), diag::note_template_static_data_member_def_here)
+  <;
+def err_invalid_template_static_data_member_spec_type : Error<"type %1 "
+  "of explicit instantiation of %q0 does not match expected type %2">;
 def err_mismatched_exception_spec_explicit_instantiation : Error<
   "exception specification in explicit instantiation does not match "
   "instantiated one">;
Index: clang/include/clang/AST/ASTContext.h
===
--- clang/include/clang/AST/ASTContext.h
+++ clang/include/clang/AST/ASTContext.h
@@ -2337,8 +2337,19 @@
   CanQualType getCanonicalParamType(QualType T) const;
 
   /// Determine whether the given types \p T1 and \p T2 are equivalent.
-  bool hasSameType(QualType T1, QualType T2) const {
-return getCanonicalType(T1) == getCanonicalType(T2);
+  /// The lifetime qualifier of Objective C can be chosen to be ignored because
+  /// sometimes we don't want to take this into consideration.
+  bool hasSameType(QualType T1, QualType T2,
+   bool IgnoreObjCLifetimeQual = false) const {
+if (!IgnoreObjCLifetimeQual) {
+  return getCanonicalType(T1) == getCanonicalType(T2);
+} else {
+  SplitQualType ST1 = getCanonicalType(T1).split();
+  SplitQualType ST2 = getCanonicalType(T2).split();
+  ST1.Quals.removeObjCLifetime();
+  ST2.Quals.removeObjCLifetime();
+  return ST1 == ST2;
+}
   }
   bool hasSameType(const Type *T1, const Type *T2) const {
 return getCanonicalType(T1) == getCanonicalType(T2);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] cea69fa - [SVE] Add fatal error for unnamed SVE variadic arguments

2020-10-30 Thread David Sherwood via cfe-commits

Author: David Sherwood
Date: 2020-10-30T13:35:47Z
New Revision: cea69fa4dcc4fcf3be62dba49ad012879d89377d

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

LOG: [SVE] Add fatal error for unnamed SVE variadic arguments

We don't currently support passing unnamed variadic SVE arguments
so I've added a fatal error if we hit such cases to prevent any
silent ABI issues in future.

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

Added: 
clang/test/CodeGen/aarch64-varargs-sve.c
llvm/test/CodeGen/AArch64/sve-varargs-callee-broken.ll
llvm/test/CodeGen/AArch64/sve-varargs-caller-broken.ll
llvm/test/CodeGen/AArch64/sve-varargs.ll

Modified: 
clang/lib/CodeGen/TargetInfo.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index e211a0214eb4..63502ccf7a38 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -5480,6 +5480,11 @@ class AArch64ABIInfo : public SwiftABIInfo {
 
   Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType Ty) const override {
+llvm::Type *BaseTy = CGF.ConvertType(Ty);
+if (isa(BaseTy))
+  llvm::report_fatal_error("Passing SVE types to variadic functions is "
+   "currently not supported");
+
 return Kind == Win64 ? EmitMSVAArg(CGF, VAListAddr, Ty)
  : isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF)
  : EmitAAPCSVAArg(VAListAddr, Ty, CGF);

diff  --git a/clang/test/CodeGen/aarch64-varargs-sve.c 
b/clang/test/CodeGen/aarch64-varargs-sve.c
new file mode 100644
index ..bf57c6e1770a
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-varargs-sve.c
@@ -0,0 +1,21 @@
+// REQUIRES: aarch64-registered-target
+// RUN: not %clang_cc1 -triple aarch64-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -emit-llvm -o - %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-ios7 -target-abi darwinpcs 
-target-feature +sve -fallow-half-arguments-and-returns -emit-llvm -o - %s 2>&1 
| FileCheck %s
+
+// CHECK: Passing SVE types to variadic functions is currently not supported
+
+#include 
+#include 
+
+double foo(char *str, ...) {
+  va_list ap;
+  svfloat64_t v;
+  double x;
+
+  va_start(ap, str);
+  v = va_arg(ap, svfloat64_t);
+  x = va_arg(ap, double);
+  va_end(ap);
+
+  return x + svaddv(svptrue_b8(), v);
+}

diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 1579a28613a3..89713be01c55 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -4807,6 +4807,10 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
 
 for (unsigned i = 0; i != NumArgs; ++i) {
   MVT ArgVT = Outs[i].VT;
+  if (!Outs[i].IsFixed && ArgVT.isScalableVector())
+report_fatal_error("Passing SVE types to variadic functions is "
+   "currently not supported");
+
   ISD::ArgFlagsTy ArgFlags = Outs[i].Flags;
   CCAssignFn *AssignFn = CCAssignFnForCall(CallConv,
/*IsVarArg=*/ !Outs[i].IsFixed);
@@ -6606,6 +6610,10 @@ SDValue AArch64TargetLowering::LowerVAARG(SDValue Op, 
SelectionDAG &DAG) const {
   Chain = VAList.getValue(1);
   VAList = DAG.getZExtOrTrunc(VAList, DL, PtrVT);
 
+  if (VT.isScalableVector())
+report_fatal_error("Passing SVE types to variadic functions is "
+   "currently not supported");
+
   if (Align && *Align > MinSlotSize) {
 VAList = DAG.getNode(ISD::ADD, DL, PtrVT, VAList,
  DAG.getConstant(Align->value() - 1, DL, PtrVT));

diff  --git a/llvm/test/CodeGen/AArch64/sve-varargs-callee-broken.ll 
b/llvm/test/CodeGen/AArch64/sve-varargs-callee-broken.ll
new file mode 100644
index ..cd097d5cbb1d
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/sve-varargs-callee-broken.ll
@@ -0,0 +1,22 @@
+; RUN: not --crash llc -mtriple arm64-apple-ios7 -mattr=+sve < %s 2>&1 | 
FileCheck %s
+
+; CHECK: Passing SVE types to variadic functions is currently not supported
+
+@.str = private unnamed_addr constant [4 x i8] c"fmt\00", align 1
+define void @foo(i8* %fmt, ...) nounwind {
+entry:
+  %fmt.addr = alloca i8*, align 8
+  %args = alloca i8*, align 8
+  %vc = alloca i32, align 4
+  %vv = alloca , align 16
+  store i8* %fmt, i8** %fmt.addr, align 8
+  %args1 = bitcast i8** %args to i8*
+  call void @llvm.va_start(i8* %args1)
+  %0 = va_arg i8** %args, i32
+  store i32 %0, i32* %vc, align 4
+  %1 = va_arg i8** %args, 
+  store  %1, * %vv, align 16
+  ret void
+}
+
+declare void @llvm.va_s

[PATCH] D90230: [SVE] Add fatal error for unnamed SVE variadic arguments

2020-10-30 Thread David Sherwood via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcea69fa4dcc4: [SVE] Add fatal error for unnamed SVE variadic 
arguments (authored by david-arm).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90230

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aarch64-varargs-sve.c
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/test/CodeGen/AArch64/sve-varargs-callee-broken.ll
  llvm/test/CodeGen/AArch64/sve-varargs-caller-broken.ll
  llvm/test/CodeGen/AArch64/sve-varargs.ll

Index: llvm/test/CodeGen/AArch64/sve-varargs.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-varargs.ll
@@ -0,0 +1,26 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s
+; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
+
+; If this check fails please read test/CodeGen/AArch64/README for instructions on how to resolve it.
+; WARN-NOT: warning
+
+declare i32 @sve_printf(i8*, , ...)
+
+@.str_1 = internal constant [6 x i8] c"boo!\0A\00"
+
+define void @foo( %x) {
+; CHECK-LABEL: foo:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:str x30, [sp, #-16]! // 8-byte Folded Spill
+; CHECK-NEXT:.cfi_def_cfa_offset 16
+; CHECK-NEXT:.cfi_offset w30, -16
+; CHECK-NEXT:adrp x0, .str_1
+; CHECK-NEXT:add x0, x0, :lo12:.str_1
+; CHECK-NEXT:bl sve_printf
+; CHECK-NEXT:ldr x30, [sp], #16 // 8-byte Folded Reload
+; CHECK-NEXT:ret
+  %f = getelementptr [6 x i8], [6 x i8]* @.str_1, i64 0, i64 0
+  call i32 (i8*, , ...) @sve_printf(i8* %f,  %x)
+  ret void
+}
Index: llvm/test/CodeGen/AArch64/sve-varargs-caller-broken.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-varargs-caller-broken.ll
@@ -0,0 +1,12 @@
+; RUN: not --crash llc -mtriple aarch64-linux-gnu -mattr=+sve <%s 2>&1 | FileCheck %s
+
+declare i32 @sve_printf(i8*, , ...)
+
+@.str_1 = internal constant [6 x i8] c"boo!\0A\00"
+
+; CHECK: Passing SVE types to variadic functions is currently not supported
+define void @foo( %x) {
+  %f = getelementptr [6 x i8], [6 x i8]* @.str_1, i64 0, i64 0
+  call i32 (i8*, , ...) @sve_printf(i8* %f,  %x,  %x)
+  ret void
+}
Index: llvm/test/CodeGen/AArch64/sve-varargs-callee-broken.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-varargs-callee-broken.ll
@@ -0,0 +1,22 @@
+; RUN: not --crash llc -mtriple arm64-apple-ios7 -mattr=+sve < %s 2>&1 | FileCheck %s
+
+; CHECK: Passing SVE types to variadic functions is currently not supported
+
+@.str = private unnamed_addr constant [4 x i8] c"fmt\00", align 1
+define void @foo(i8* %fmt, ...) nounwind {
+entry:
+  %fmt.addr = alloca i8*, align 8
+  %args = alloca i8*, align 8
+  %vc = alloca i32, align 4
+  %vv = alloca , align 16
+  store i8* %fmt, i8** %fmt.addr, align 8
+  %args1 = bitcast i8** %args to i8*
+  call void @llvm.va_start(i8* %args1)
+  %0 = va_arg i8** %args, i32
+  store i32 %0, i32* %vc, align 4
+  %1 = va_arg i8** %args, 
+  store  %1, * %vv, align 16
+  ret void
+}
+
+declare void @llvm.va_start(i8*) nounwind
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -4807,6 +4807,10 @@
 
 for (unsigned i = 0; i != NumArgs; ++i) {
   MVT ArgVT = Outs[i].VT;
+  if (!Outs[i].IsFixed && ArgVT.isScalableVector())
+report_fatal_error("Passing SVE types to variadic functions is "
+   "currently not supported");
+
   ISD::ArgFlagsTy ArgFlags = Outs[i].Flags;
   CCAssignFn *AssignFn = CCAssignFnForCall(CallConv,
/*IsVarArg=*/ !Outs[i].IsFixed);
@@ -6606,6 +6610,10 @@
   Chain = VAList.getValue(1);
   VAList = DAG.getZExtOrTrunc(VAList, DL, PtrVT);
 
+  if (VT.isScalableVector())
+report_fatal_error("Passing SVE types to variadic functions is "
+   "currently not supported");
+
   if (Align && *Align > MinSlotSize) {
 VAList = DAG.getNode(ISD::ADD, DL, PtrVT, VAList,
  DAG.getConstant(Align->value() - 1, DL, PtrVT));
Index: clang/test/CodeGen/aarch64-varargs-sve.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-varargs-sve.c
@@ -0,0 +1,21 @@
+// REQUIRES: aarch64-registered-target
+// RUN: not %clang_cc1 -triple aarch64-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -emit-llvm -o - %s 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple arm64-apple-ios7 -target-

[clang] ec809e4 - PR47372: Fix Lambda invoker calling conventions

2020-10-30 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2020-10-30T06:39:55-07:00
New Revision: ec809e4cfe0be08b1bab7ba7e6ff905b9430571a

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

LOG: PR47372: Fix Lambda invoker calling conventions

As mentioned in the defect, the lambda static invoker does not follow
the calling convention of the lambda itself, which seems wrong. This
patch ensures that the calling convention of operator() is passed onto
the invoker and conversion-operator type.

This is accomplished by extracting the calling-convention determination
code out into a separate function in order to better reflect the 'thiscall'
work, as well as somewhat better support the future implementation of
https://devblogs.microsoft.com/oldnewthing/20150220-00/?p=44623

For any target (basically just win32) that has a different free and
static function calling convention, this generates BOTH alternatives.
This required some work to get the Windows mangler to work correctly for
this, as well as some tie-breaking for the unary operators.

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

Added: 
clang/test/CodeGenCXX/lambda-conversion-op-cc.cpp
clang/test/SemaCXX/lambda-conversion-op-cc.cpp

Modified: 
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index fc0632f07b51..496caf871a91 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1008,8 +1008,13 @@ class CXXRecordDecl : public RecordDecl {
 
   /// Retrieve the lambda static invoker, the address of which
   /// is returned by the conversion operator, and the body of which
-  /// is forwarded to the lambda call operator.
+  /// is forwarded to the lambda call operator. The version that does not
+  /// take a calling convention uses the 'default' calling convention for free
+  /// functions if the Lambda's calling convention was not modified via
+  /// attribute. Otherwise, it will return the calling convention specified for
+  /// the lambda.
   CXXMethodDecl *getLambdaStaticInvoker() const;
+  CXXMethodDecl *getLambdaStaticInvoker(CallingConv CC) const;
 
   /// Retrieve the generic lambda's template parameter list.
   /// Returns null if the class does not represent a lambda or a generic

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 61ee743a7ab9..4be3c23652e1 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -6597,7 +6597,8 @@ class Sema final {
   /// Get the return type to use for a lambda's conversion function(s) to
   /// function pointer type, given the type of the call operator.
   QualType
-  getLambdaConversionFunctionResultType(const FunctionProtoType *CallOpType);
+  getLambdaConversionFunctionResultType(const FunctionProtoType *CallOpType,
+CallingConv CC);
 
   /// Define the "body" of the conversion from a lambda object to a
   /// function pointer.

diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 3f522450e870..9f8248722002 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -1507,18 +1507,38 @@ CXXMethodDecl *CXXRecordDecl::getLambdaCallOperator() 
const {
 }
 
 CXXMethodDecl* CXXRecordDecl::getLambdaStaticInvoker() const {
-  if (!isLambda()) return nullptr;
+  CXXMethodDecl *CallOp = getLambdaCallOperator();
+  CallingConv CC = CallOp->getType()->getAs()->getCallConv();
+  return getLambdaStaticInvoker(CC);
+}
+
+static DeclContext::lookup_result
+getLambdaStaticInvokers(const CXXRecordDecl &RD) {
+  assert(RD.isLambda() && "Must be a lambda");
   DeclarationName Name =
-&getASTContext().Idents.get(getLambdaStaticInvokerName());
-  DeclContext::lookup_result Invoker = lookup(Name);
-  if (Invoker.empty()) return nullptr;
-  assert(allLookupResultsAreTheSame(Invoker) &&
- "More than one static invoker operator!");
-  NamedDecl *InvokerFun = Invoker.front();
-  if (const auto *InvokerTemplate = dyn_cast(InvokerFun))
+  &RD.getASTContext().Idents.get(getLambdaStaticInvokerName());
+  return RD.lookup(Name);
+}
+
+static CXXMethodDecl *getInvokerAsMethod(NamedDecl *ND) {
+  if (const auto *InvokerTemplate = dyn_cast(ND))
 return cast(InvokerTemplate->getTemplatedDecl());
+  return cast(ND);
+}
+
+CXXMethodDecl *CXXRecordDecl::getLambdaStaticInvoker(CallingConv CC) const {
+  if (!isLambda())
+return nullptr;
+  DeclContext::lookup_result Invoker = getLambdaStaticInvokers(*this);
+

[PATCH] D89559: PR47372: Fix Lambda invoker calling conventions

2020-10-30 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGec809e4cfe0b: PR47372: Fix Lambda invoker calling 
conventions (authored by erichkeane).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89559

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CodeGenCXX/lambda-conversion-op-cc.cpp
  clang/test/SemaCXX/lambda-conversion-op-cc.cpp

Index: clang/test/SemaCXX/lambda-conversion-op-cc.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lambda-conversion-op-cc.cpp
@@ -0,0 +1,190 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-linux-pc %s -verify -DBAD_CONVERSION
+// RUN: %clang_cc1 -fsyntax-only -triple i386-windows-pc %s -verify -DBAD_CONVERSION -DWIN32
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-linux-pc %s -ast-dump | FileCheck %s --check-prefixes=CHECK,LIN64,NODEF
+// RUN: %clang_cc1 -fsyntax-only -triple i386-windows-pc %s -ast-dump -DWIN32 | FileCheck %s --check-prefixes=CHECK,WIN32,NODEF
+
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-linux-pc -fdefault-calling-conv=vectorcall %s -verify -DBAD_VEC_CONVERS
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-linux-pc -fdefault-calling-conv=vectorcall %s -ast-dump | FileCheck %s --check-prefixes=CHECK,VECTDEF
+
+void useage() {
+  auto normal = [](int, float, double) {};// #1
+  auto vectorcall = [](int, float, double) __attribute__((vectorcall)){}; // #2
+#ifdef WIN32
+  auto thiscall = [](int, float, double) __attribute__((thiscall)){}; // #3
+#endif// WIN32
+  auto cdecl = [](int, float, double) __attribute__((cdecl)){};
+
+  auto genericlambda = [](auto a) {};  // #4
+  auto genericvectorcalllambda = [](auto a) __attribute__((vectorcall)){}; // #5
+
+  // None of these should be ambiguous.
+  (void)+normal;
+  (void)+vectorcall;
+#ifdef WIN32
+  (void)+thiscall;
+#endif // WIN32
+  (void)+cdecl;
+
+#ifdef BAD_CONVERSION
+  // expected-error-re@+1 {{invalid argument type {{.*}} to unary expression}}
+  (void)+genericlambda;
+  // expected-error-re@+1 {{invalid argument type {{.*}} to unary expression}}
+  (void)+genericvectorcalllambda;
+#endif // BAD_CONVERSION
+
+  // CHECK: VarDecl {{.*}} normal '
+  // CHECK: LambdaExpr
+  // WIN32: CXXMethodDecl {{.*}} operator() 'void (int, float, double) __attribute__((thiscall)) const'
+  // LIN64: CXXMethodDecl {{.*}} operator() 'void (int, float, double) const'
+  // VECTDEF: CXXMethodDecl {{.*}} operator() 'void (int, float, double) const'
+  // NODEF: CXXConversionDecl {{.*}} operator void (*)(int, float, double) 'void
+  // NODEF: CXXMethodDecl {{.*}} __invoke 'void (int, float, double)' static inline
+  // VECTDEF: CXXConversionDecl {{.*}} operator void (*)(int, float, double) __attribute__((vectorcall)) 'void
+  // VECTDEF: CXXMethodDecl {{.*}} __invoke 'void (int, float, double) __attribute__((vectorcall))' static inline
+
+  // CHECK: VarDecl {{.*}} vectorcall '
+  // CHECK: LambdaExpr
+  // CHECK: CXXMethodDecl {{.*}} operator() 'void (int, float, double) __attribute__((vectorcall)) const'
+  // CHECK: CXXConversionDecl {{.*}} operator void (*)(int, float, double) __attribute__((vectorcall)) 'void
+  // CHECK: CXXMethodDecl {{.*}} __invoke 'void (int, float, double) __attribute__((vectorcall))' static inline
+
+  // WIN32: VarDecl {{.*}} thiscall '
+  // WIN32: LambdaExpr
+  // WIN32: CXXMethodDecl {{.*}} operator() 'void (int, float, double) __attribute__((thiscall)) const'
+  // WIN32: CXXConversionDecl {{.*}} operator void (*)(int, float, double) 'void
+  // WIN32: CXXMethodDecl {{.*}} __invoke 'void (int, float, double)' static inline
+
+  // CHECK: VarDecl {{.*}} cdecl '
+  // CHECK: LambdaExpr
+  // CHECK: CXXMethodDecl {{.*}} operator() 'void (int, float, double) const'
+  // NODEF: CXXConversionDecl {{.*}} operator void (*)(int, float, double) 'void
+  // NODEF: CXXMethodDecl {{.*}} __invoke 'void (int, float, double)' static inline
+  // VECTDEF: CXXConversionDecl {{.*}} operator void (*)(int, float, double) __attribute__((vectorcall)) 'void
+  // VECTDEF: CXXMethodDecl {{.*}} __invoke 'void (int, float, double) __attribute__((vectorcall))' static inline
+
+  // CHECK: VarDecl {{.*}} genericlambda '
+  // CHECK: LambdaExpr
+  //
+  // CHECK: FunctionTemplateDecl {{.*}} operator()
+  // LIN64: CXXMethodDecl {{.*}} operator() 'auto (auto) const' inline
+  // LIN64: CXXMethodDecl {{.*}} operator() 'void (char) const' inline
+  // LIN64: CXXMethodDecl {{.*}} operator() 'void (int) const' inline
+  // WIN32: C

[PATCH] D90459: [WIP][clang] Use RecoveryExpr to suppress secondary diagnostics for typo correction.

2020-10-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
hokein requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90459

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/Modules/submodules-merge-defs.cpp
  clang/test/Sema/PR28181.c
  clang/test/Sema/typo-correction-ambiguity.cpp
  clang/test/Sema/typo-correction-no-hang.cpp
  clang/test/Sema/typo-correction.c
  clang/test/Sema/var-redecl.c
  clang/test/SemaCXX/enum-scoped.cpp
  clang/test/SemaCXX/nested-name-spec.cpp
  clang/test/SemaCXX/typo-correction-crash.cpp
  clang/test/SemaCXX/typo-correction-cxx11.cpp
  clang/test/SemaCXX/typo-correction-delayed.cpp
  clang/test/SemaObjC/error-outof-scope-property-use.m
  clang/test/SemaObjCXX/block-for-lambda-conversion.mm

Index: clang/test/SemaObjCXX/block-for-lambda-conversion.mm
===
--- clang/test/SemaObjCXX/block-for-lambda-conversion.mm
+++ clang/test/SemaObjCXX/block-for-lambda-conversion.mm
@@ -8,7 +8,7 @@
   NSEventMaskLeftMouseDown = 1
 };
 
-static const NSEventType NSFlagsChanged = NSEventTypeFlagsChanged;
+static const NSEventType NSFlagsChanged = NSEventTypeFlagsChanged; // expected-note {{declared here}}
 
 @interface NSObject
 @end
@@ -20,7 +20,7 @@
 
 void test(id weakThis) {
   id m_flagsChangedEventMonitor = [NSEvent
-  addMonitor:NSFlagsChangedMask //expected-error {{use of undeclared identifier 'NSFlagsChangedMask'}}
+  addMonitor:NSFlagsChangedMask // expected-error {{use of undeclared identifier 'NSFlagsChangedMask'; did you mean 'NSFlagsChanged'?}}
  handler:[weakThis](NSEvent *flagsChangedEvent) {
  return flagsChangedEvent;
  }];
Index: clang/test/SemaObjC/error-outof-scope-property-use.m
===
--- clang/test/SemaObjC/error-outof-scope-property-use.m
+++ clang/test/SemaObjC/error-outof-scope-property-use.m
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
 // rdar://13178483
 
-@class NSMutableDictionary; // expected-note {{receiver is instance of class declared here}}
+@class NSMutableDictionary;
 
 @interface LaunchdJobs 
 
@@ -15,8 +15,7 @@
 -(void)job
 {
 
- [uuids_jobs objectForKey]; // expected-error {{use of undeclared identifier 'uuids_jobs'}} \
-// expected-warning {{instance method '-objectForKey' not found}}
+ [uuids_jobs objectForKey]; // expected-error {{use of undeclared identifier 'uuids_jobs'}}
 }
 
 
Index: clang/test/SemaCXX/typo-correction-delayed.cpp
===
--- clang/test/SemaCXX/typo-correction-delayed.cpp
+++ clang/test/SemaCXX/typo-correction-delayed.cpp
@@ -137,13 +137,12 @@
 
 namespace PR21925 {
 struct X {
-  int get() { return 7; }  // expected-note {{'get' declared here}}
+  int get() { return 7; }
 };
 void test() {
   X variable;  // expected-note {{'variable' declared here}}
 
-  // expected-error@+2 {{use of undeclared identifier 'variableX'; did you mean 'variable'?}}
-  // expected-error@+1 {{no member named 'getX' in 'PR21925::X'; did you mean 'get'?}}
+  // expected-error@+1 {{use of undeclared identifier 'variableX'; did you mean 'variable'?}}
   int x = variableX.getX();
 }
 }
@@ -192,10 +191,11 @@
 namespace PR22297 {
 double pow(double x, double y);
 struct TimeTicks {
-  static void Now();  // expected-note {{'Now' declared here}}
+  static void Now();
 };
 void f() {
-  TimeTicks::now();  // expected-error {{no member named 'now' in 'PR22297::TimeTicks'; did you mean 'Now'?}}
+  // FIXME: should correct to Now.
+  TimeTicks::now();  // expected-error {{no member named 'now' in 'PR22297::TimeTicks'}}
 }
 }
 
Index: clang/test/SemaCXX/typo-correction-cxx11.cpp
===
--- clang/test/SemaCXX/typo-correction-cxx11.cpp
+++ clang/test/SemaCXX/typo-correction-cxx11.cpp
@@ -1,7 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
 
 namespace PR23186 {
-decltype(ned);  // expected-error-re {{use of undeclared identifier 'ned'{{$
+// FIXME: what's going on here? suppress the bogus correction of 'ned' to 'new'
+decltype(ned);  // expected-error {{use of undeclared identifier 'ned'; did you mean 'new'}} expected-warning {{declaration does not declare anything}}
 // The code below was triggering an UNREACHABLE in ASTContext::getTypeInfoImpl
 // once the above code failed to recover properly after making the bogus
 // correction of 'ned' to 'new'.
@@ -54,7 +55,7 @@
 
   auto &annotation = *annotations;
   auto new_it = new_annotations.find(5);
-  auto &new_anotation = new_it.second;  // expected-note {{'new_anotation' declared here}}
-  new_annotation->Swap(&annotation);  // expected-error {{use of undeclared identifier 'new_annotation'; did you mean 'new_anotation

[PATCH] D46791: Make -gsplit-dwarf generally available

2020-10-30 Thread Ed Maste via Phabricator via cfe-commits
emaste added a comment.
Herald added a subscriber: arichardson.

running `clang -target x86_64-unknown-freebsd13.0 -split-dwarf foo.c` indeed 
produces a foo.dwo and foo.o w/o invoking objcopy


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

https://reviews.llvm.org/D46791

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


[PATCH] D90419: [AMDGPU] Add gfx90c target

2020-10-30 Thread Tim Renouf via Phabricator via cfe-commits
tpr updated this revision to Diff 301886.
tpr added a comment.

V3: Listed products. Marked as "xnack enabled".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90419

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/CodeGenOpenCL/amdgpu-features.cl
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/amdgpu-mcpu.cl
  llvm/docs/AMDGPUUsage.rst
  llvm/include/llvm/BinaryFormat/ELF.h
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Object/ELFObjectFile.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/lib/Support/TargetParser.cpp
  llvm/lib/Target/AMDGPU/AMDGPU.td
  llvm/lib/Target/AMDGPU/GCNProcessors.td
  llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
  llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll
  llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
  llvm/tools/llvm-readobj/ELFDumper.cpp

Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1779,6 +1779,7 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX906),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX908),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX909),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90C),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1010),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1011),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1012),
Index: llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
===
--- llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
+++ llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
@@ -166,6 +166,10 @@
 # RUN: llvm-readobj -s -file-headers %t.o.42 | FileCheck --check-prefixes=ELF-ALL,ELF-GFX1032 %s
 # RUN: obj2yaml %t.o.42 | FileCheck --check-prefixes=YAML-GFX1032 %s
 
+# RUN: yaml2obj --docnum=43 %s -o %t.o.43
+# RUN: llvm-readobj -s -file-headers %t.o.43 | FileCheck --check-prefixes=ELF-ALL,ELF-GFX90C %s
+# RUN: obj2yaml %t.o.43 | FileCheck --check-prefixes=YAML-GFX90C %s
+
 # ELF-ALL: Flags [
 # ELF-R600:  EF_AMDGPU_MACH_R600_R600 (0x1)
 # ELF-R630:  EF_AMDGPU_MACH_R600_R630 (0x2)
@@ -203,6 +207,7 @@
 # ELF-GFX906:EF_AMDGPU_MACH_AMDGCN_GFX906 (0x2F)
 # ELF-GFX908:EF_AMDGPU_MACH_AMDGCN_GFX908 (0x30)
 # ELF-GFX909:EF_AMDGPU_MACH_AMDGCN_GFX909 (0x31)
+# ELF-GFX90C:EF_AMDGPU_MACH_AMDGCN_GFX90C (0x32)
 # ELF-GFX1010:   EF_AMDGPU_MACH_AMDGCN_GFX1010 (0x33)
 # ELF-GFX1011:   EF_AMDGPU_MACH_AMDGCN_GFX1011 (0x34)
 # ELF-GFX1012:   EF_AMDGPU_MACH_AMDGCN_GFX1012 (0x35)
@@ -247,6 +252,7 @@
 # YAML-GFX906:  Flags: [ EF_AMDGPU_MACH_AMDGCN_GFX906 ]
 # YAML-GFX908:  Flags: [ EF_AMDGPU_MACH_AMDGCN_GFX908 ]
 # YAML-GFX909:  Flags: [ EF_AMDGPU_MACH_AMDGCN_GFX909 ]
+# YAML-GFX90C:  Flags: [ EF_AMDGPU_MACH_AMDGCN_GFX90C ]
 # YAML-GFX1010: Flags: [ EF_AMDGPU_MACH_AMDGCN_GFX1010 ]
 # YAML-GFX1011: Flags: [ EF_AMDGPU_MACH_AMDGCN_GFX1011 ]
 # YAML-GFX1012: Flags: [ EF_AMDGPU_MACH_AMDGCN_GFX1012 ]
@@ -715,3 +721,14 @@
   Machine: EM_AMDGPU
   Flags:   [ EF_AMDGPU_MACH_AMDGCN_GFX1032 ]
 ...
+
+# Doc43
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  OSABI:   ELFOSABI_NONE
+  Type:ET_REL
+  Machine: EM_AMDGPU
+  Flags:   [ EF_AMDGPU_MACH_AMDGCN_GFX90C ]
+...
Index: llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll
===
--- llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll
+++ llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll
@@ -52,6 +52,7 @@
 ; RUN: llc -filetype=obj -march=amdgcn -mcpu=gfx906 < %s | llvm-readobj -file-headers - | FileCheck --check-prefixes=ALL,ARCH-GCN,GFX906 %s
 ; RUN: llc -filetype=obj -march=amdgcn -mcpu=gfx908 < %s | llvm-readobj -file-headers - | FileCheck --check-prefixes=ALL,ARCH-GCN,GFX908 %s
 ; RUN: llc -filetype=obj -march=amdgcn -mcpu=gfx909 < %s | llvm-readobj -file-headers - | FileCheck --check-prefixes=ALL,ARCH-GCN,GFX909 %s
+; RUN: llc -filetype=obj -march=amdgcn -mcpu=gfx90c < %s | llvm-readobj -file-headers - | FileCheck --check-prefixes=ALL,ARCH-GCN,GFX90C %s
 ; RUN: llc -filetype=obj -march=amdgcn -mcpu=gfx1010 < %s | llvm-readobj -file-headers - | FileCheck --check-prefixes=ALL,ARCH-GCN,GFX1010 %s
 ; RUN: llc -filetype=obj -march=amdgcn -mcpu=gfx1011 < %s | llvm-readobj -file-headers - | FileCheck --check-prefixes=ALL,ARCH-GCN,GFX1011 %s
 ; RUN: llc -filetype=obj -march=amdgcn -mcpu=gfx1012 < %s | llvm-readobj -file-headers - | FileCheck --check-prefixes=ALL,ARCH-GCN,GFX1012 %s
@@ -103,6 +104,7 @@
 ; GFX908:EF_AMDGPU_MACH_AMDGCN_GFX908 (0x30)
 ; GFX908-NEXT:   EF_AMDGPU_SRAM_ECC   (0x200)
 ; GFX909:EF_AMDGPU_MACH_AMDG

[clang] bbdbd02 - Address ABI issues introduced with CXCursor_CXXAddrspaceCastExpr

2020-10-30 Thread Marco Antognini via cfe-commits

Author: Marco Antognini
Date: 2020-10-30T14:12:01Z
New Revision: bbdbd020d2c2f315ed1545b23c23ec6ff1abc022

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

LOG: Address ABI issues introduced with CXCursor_CXXAddrspaceCastExpr

Revert values in CXCursorKind as they were before
CXCursor_CXXAddrspaceCastExpr was introduced in a6a237f2046a ([OpenCL]
Added addrspace_cast operator in C++ mode., 2020-05-18).

Insert CXCursor_CXXAddrspaceCastExpr after the last expression in
CXCursorKind using the next available value.

Reviewed By: akyrtzi, svenvh

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

Added: 


Modified: 
clang/include/clang-c/Index.h

Removed: 




diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 4838937c8da6..1c91e059c322 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -33,7 +33,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 60
+#define CINDEX_VERSION_MINOR 61
 
 #define CINDEX_VERSION_ENCODE(major, minor) (((major)*1) + ((minor)*1))
 
@@ -2052,62 +2052,58 @@ enum CXCursorKind {
*/
   CXCursor_CXXFunctionalCastExpr = 128,
 
-  /** OpenCL's addrspace_cast<> expression.
-   */
-  CXCursor_CXXAddrspaceCastExpr = 129,
-
   /** A C++ typeid expression (C++ [expr.typeid]).
*/
-  CXCursor_CXXTypeidExpr = 130,
+  CXCursor_CXXTypeidExpr = 129,
 
   /** [C++ 2.13.5] C++ Boolean Literal.
*/
-  CXCursor_CXXBoolLiteralExpr = 131,
+  CXCursor_CXXBoolLiteralExpr = 130,
 
   /** [C++0x 2.14.7] C++ Pointer Literal.
*/
-  CXCursor_CXXNullPtrLiteralExpr = 132,
+  CXCursor_CXXNullPtrLiteralExpr = 131,
 
   /** Represents the "this" expression in C++
*/
-  CXCursor_CXXThisExpr = 133,
+  CXCursor_CXXThisExpr = 132,
 
   /** [C++ 15] C++ Throw Expression.
*
* This handles 'throw' and 'throw' assignment-expression. When
* assignment-expression isn't present, Op will be null.
*/
-  CXCursor_CXXThrowExpr = 134,
+  CXCursor_CXXThrowExpr = 133,
 
   /** A new expression for memory allocation and constructor calls, e.g:
* "new CXXNewExpr(foo)".
*/
-  CXCursor_CXXNewExpr = 135,
+  CXCursor_CXXNewExpr = 134,
 
   /** A delete expression for memory deallocation and destructor calls,
* e.g. "delete[] pArray".
*/
-  CXCursor_CXXDeleteExpr = 136,
+  CXCursor_CXXDeleteExpr = 135,
 
   /** A unary expression. (noexcept, sizeof, or other traits)
*/
-  CXCursor_UnaryExpr = 137,
+  CXCursor_UnaryExpr = 136,
 
   /** An Objective-C string literal i.e. @"foo".
*/
-  CXCursor_ObjCStringLiteral = 138,
+  CXCursor_ObjCStringLiteral = 137,
 
   /** An Objective-C \@encode expression.
*/
-  CXCursor_ObjCEncodeExpr = 139,
+  CXCursor_ObjCEncodeExpr = 138,
 
   /** An Objective-C \@selector expression.
*/
-  CXCursor_ObjCSelectorExpr = 140,
+  CXCursor_ObjCSelectorExpr = 139,
 
   /** An Objective-C \@protocol expression.
*/
-  CXCursor_ObjCProtocolExpr = 141,
+  CXCursor_ObjCProtocolExpr = 140,
 
   /** An Objective-C "bridged" cast expression, which casts between
* Objective-C pointers and C pointers, transferring ownership in the 
process.
@@ -2116,7 +2112,7 @@ enum CXCursorKind {
*   NSString *str = (__bridge_transfer NSString *)CFCreateString();
* \endcode
*/
-  CXCursor_ObjCBridgedCastExpr = 142,
+  CXCursor_ObjCBridgedCastExpr = 141,
 
   /** Represents a C++0x pack expansion that produces a sequence of
* expressions.
@@ -2131,7 +2127,7 @@ enum CXCursorKind {
* }
* \endcode
*/
-  CXCursor_PackExpansionExpr = 143,
+  CXCursor_PackExpansionExpr = 142,
 
   /** Represents an expression that computes the length of a parameter
* pack.
@@ -2143,7 +2139,7 @@ enum CXCursorKind {
* };
* \endcode
*/
-  CXCursor_SizeOfPackExpr = 144,
+  CXCursor_SizeOfPackExpr = 143,
 
   /* Represents a C++ lambda expression that produces a local function
* object.
@@ -2157,39 +2153,43 @@ enum CXCursorKind {
* }
* \endcode
*/
-  CXCursor_LambdaExpr = 145,
+  CXCursor_LambdaExpr = 144,
 
   /** Objective-c Boolean Literal.
*/
-  CXCursor_ObjCBoolLiteralExpr = 146,
+  CXCursor_ObjCBoolLiteralExpr = 145,
 
   /** Represents the "self" expression in an Objective-C method.
*/
-  CXCursor_ObjCSelfExpr = 147,
+  CXCursor_ObjCSelfExpr = 146,
 
   /** OpenMP 5.0 [2.1.5, Array Section].
*/
-  CXCursor_OMPArraySectionExpr = 148,
+  CXCursor_OMPArraySectionExpr = 147,
 
   /** Represents an @available(...) check.
*/
-  CXCursor_ObjCAvailabilityCheckExpr = 149,
+  CXCursor_ObjCAvailabilityCheckExpr = 148,
 
   /**
* Fixed point literal
*/
-  CXCursor_FixedPointLiteral = 150,
+  CXCursor_FixedPointLiteral = 149,
 
   /** Op

[PATCH] D90385: Address ABI issues introduced with CXCursor_CXXAddrspaceCastExpr

2020-10-30 Thread Marco Antognini 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 rGbbdbd020d2c2: Address ABI issues introduced with 
CXCursor_CXXAddrspaceCastExpr (authored by mantognini).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90385

Files:
  clang/include/clang-c/Index.h

Index: clang/include/clang-c/Index.h
===
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -33,7 +33,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 60
+#define CINDEX_VERSION_MINOR 61
 
 #define CINDEX_VERSION_ENCODE(major, minor) (((major)*1) + ((minor)*1))
 
@@ -2052,62 +2052,58 @@
*/
   CXCursor_CXXFunctionalCastExpr = 128,
 
-  /** OpenCL's addrspace_cast<> expression.
-   */
-  CXCursor_CXXAddrspaceCastExpr = 129,
-
   /** A C++ typeid expression (C++ [expr.typeid]).
*/
-  CXCursor_CXXTypeidExpr = 130,
+  CXCursor_CXXTypeidExpr = 129,
 
   /** [C++ 2.13.5] C++ Boolean Literal.
*/
-  CXCursor_CXXBoolLiteralExpr = 131,
+  CXCursor_CXXBoolLiteralExpr = 130,
 
   /** [C++0x 2.14.7] C++ Pointer Literal.
*/
-  CXCursor_CXXNullPtrLiteralExpr = 132,
+  CXCursor_CXXNullPtrLiteralExpr = 131,
 
   /** Represents the "this" expression in C++
*/
-  CXCursor_CXXThisExpr = 133,
+  CXCursor_CXXThisExpr = 132,
 
   /** [C++ 15] C++ Throw Expression.
*
* This handles 'throw' and 'throw' assignment-expression. When
* assignment-expression isn't present, Op will be null.
*/
-  CXCursor_CXXThrowExpr = 134,
+  CXCursor_CXXThrowExpr = 133,
 
   /** A new expression for memory allocation and constructor calls, e.g:
* "new CXXNewExpr(foo)".
*/
-  CXCursor_CXXNewExpr = 135,
+  CXCursor_CXXNewExpr = 134,
 
   /** A delete expression for memory deallocation and destructor calls,
* e.g. "delete[] pArray".
*/
-  CXCursor_CXXDeleteExpr = 136,
+  CXCursor_CXXDeleteExpr = 135,
 
   /** A unary expression. (noexcept, sizeof, or other traits)
*/
-  CXCursor_UnaryExpr = 137,
+  CXCursor_UnaryExpr = 136,
 
   /** An Objective-C string literal i.e. @"foo".
*/
-  CXCursor_ObjCStringLiteral = 138,
+  CXCursor_ObjCStringLiteral = 137,
 
   /** An Objective-C \@encode expression.
*/
-  CXCursor_ObjCEncodeExpr = 139,
+  CXCursor_ObjCEncodeExpr = 138,
 
   /** An Objective-C \@selector expression.
*/
-  CXCursor_ObjCSelectorExpr = 140,
+  CXCursor_ObjCSelectorExpr = 139,
 
   /** An Objective-C \@protocol expression.
*/
-  CXCursor_ObjCProtocolExpr = 141,
+  CXCursor_ObjCProtocolExpr = 140,
 
   /** An Objective-C "bridged" cast expression, which casts between
* Objective-C pointers and C pointers, transferring ownership in the process.
@@ -2116,7 +2112,7 @@
*   NSString *str = (__bridge_transfer NSString *)CFCreateString();
* \endcode
*/
-  CXCursor_ObjCBridgedCastExpr = 142,
+  CXCursor_ObjCBridgedCastExpr = 141,
 
   /** Represents a C++0x pack expansion that produces a sequence of
* expressions.
@@ -2131,7 +2127,7 @@
* }
* \endcode
*/
-  CXCursor_PackExpansionExpr = 143,
+  CXCursor_PackExpansionExpr = 142,
 
   /** Represents an expression that computes the length of a parameter
* pack.
@@ -2143,7 +2139,7 @@
* };
* \endcode
*/
-  CXCursor_SizeOfPackExpr = 144,
+  CXCursor_SizeOfPackExpr = 143,
 
   /* Represents a C++ lambda expression that produces a local function
* object.
@@ -2157,39 +2153,43 @@
* }
* \endcode
*/
-  CXCursor_LambdaExpr = 145,
+  CXCursor_LambdaExpr = 144,
 
   /** Objective-c Boolean Literal.
*/
-  CXCursor_ObjCBoolLiteralExpr = 146,
+  CXCursor_ObjCBoolLiteralExpr = 145,
 
   /** Represents the "self" expression in an Objective-C method.
*/
-  CXCursor_ObjCSelfExpr = 147,
+  CXCursor_ObjCSelfExpr = 146,
 
   /** OpenMP 5.0 [2.1.5, Array Section].
*/
-  CXCursor_OMPArraySectionExpr = 148,
+  CXCursor_OMPArraySectionExpr = 147,
 
   /** Represents an @available(...) check.
*/
-  CXCursor_ObjCAvailabilityCheckExpr = 149,
+  CXCursor_ObjCAvailabilityCheckExpr = 148,
 
   /**
* Fixed point literal
*/
-  CXCursor_FixedPointLiteral = 150,
+  CXCursor_FixedPointLiteral = 149,
 
   /** OpenMP 5.0 [2.1.4, Array Shaping].
*/
-  CXCursor_OMPArrayShapingExpr = 151,
+  CXCursor_OMPArrayShapingExpr = 150,
 
   /**
* OpenMP 5.0 [2.1.6 Iterators]
*/
-  CXCursor_OMPIteratorExpr = 152,
+  CXCursor_OMPIteratorExpr = 151,
+
+  /** OpenCL's addrspace_cast<> expression.
+   */
+  CXCursor_CXXAddrspaceCastExpr = 152,
 
-  CXCursor_LastExpr = CXCursor_OMPIteratorExpr,
+  CXCursor_LastExpr = CXCursor_CXXAddrspaceCastExpr,
 
   /* Statements */
   CXCursor_FirstStmt = 200,
___
cfe-commits mailing list
cfe-commits@lists.llvm.

[PATCH] D90447: [AMDGPU] Add gfx1033 target

2020-10-30 Thread Tony Tye via Phabricator via cfe-commits
t-tye added inline comments.



Comment at: llvm/docs/AMDGPUUsage.rst:317
+   
  names.
+ ``gfx1033`` ``amdgcn``   dGPU  - wavefrontsize64  
   *TBA*
+  [off]

APU


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90447

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


[PATCH] D90419: [AMDGPU] Add gfx90c target

2020-10-30 Thread Tony Tye via Phabricator via cfe-commits
t-tye accepted this revision.
t-tye 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/D90419/new/

https://reviews.llvm.org/D90419

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


[clang] 71bf9f0 - [clang] add fexperimental-strict-floating-point to test cases that fail on arm and aarch not sure this will work due to commit rG13bfd89c4962

2020-10-30 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2020-10-30T07:30:06-07:00
New Revision: 71bf9f07d514e160ff130eced53248667021829d

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

LOG: [clang] add fexperimental-strict-floating-point to test cases that fail on 
arm and aarch not sure this will work due to commit rG13bfd89c4962

Added: 


Modified: 
clang/test/AST/const-fpfeatures.c
clang/test/CodeGen/fp-floatcontrol-pragma.cpp
clang/test/CodeGen/pragma-fenv_access.c
clang/test/CodeGen/rounding-math.c
clang/test/PCH/pragma-floatcontrol.c
clang/test/Parser/pragma-fenv_round.c

Removed: 




diff  --git a/clang/test/AST/const-fpfeatures.c 
b/clang/test/AST/const-fpfeatures.c
index bf512ff70658..c29afe680999 100644
--- a/clang/test/AST/const-fpfeatures.c
+++ b/clang/test/AST/const-fpfeatures.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -S -emit-llvm -Wno-unknown-pragmas %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -S -emit-llvm -triple 
i386-linux -Wno-unknown-pragmas %s -o - | FileCheck %s
 
 // nextUp(1.F) == 0x1.02p0F
 

diff  --git a/clang/test/CodeGen/fp-floatcontrol-pragma.cpp 
b/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
index 45eb14bccc06..539ad86d6bb8 100644
--- a/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-pragma.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -DEXCEPT=1 -fcxx-exceptions -triple x86_64-linux-gnu 
-emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NS %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -DFENV_ON=1 -triple x86_64-linux-gnu -emit-llvm -o - %s | 
FileCheck -check-prefix=CHECK-FENV %s
-// RUN: %clang_cc1 -triple %itanium_abi_triple -O3 -emit-llvm -o - %s | 
FileCheck -check-prefix=CHECK-O3 %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -DEXCEPT=1 
-fcxx-exceptions -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck 
-check-prefix=CHECK-NS %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -triple 
x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -DFENV_ON=1 -triple 
x86_64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-FENV %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -triple 
%itanium_abi_triple -O3 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-O3 %s
 
 // Verify float_control(precise, off) enables fast math flags on fp operations.
 float fp_precise_1(float a, float b, float c) {

diff  --git a/clang/test/CodeGen/pragma-fenv_access.c 
b/clang/test/CodeGen/pragma-fenv_access.c
index 87d12a3a7ab1..fb7b8b2af61d 100644
--- a/clang/test/CodeGen/pragma-fenv_access.c
+++ b/clang/test/CodeGen/pragma-fenv_access.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -ffp-exception-behavior=strict -triple %itanium_abi_triple 
-emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point 
-ffp-exception-behavior=strict -triple %itanium_abi_triple -emit-llvm %s -o - | 
FileCheck %s
 
 #pragma STDC FENV_ACCESS ON
 

diff  --git a/clang/test/CodeGen/rounding-math.c 
b/clang/test/CodeGen/rounding-math.c
index b2671db0efc8..13ec2fdcaa2e 100644
--- a/clang/test/CodeGen/rounding-math.c
+++ b/clang/test/CodeGen/rounding-math.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -S -emit-llvm -ffp-exception-behavior=strict 
-Wno-unknown-pragmas %s -o - | FileCheck %s
-// RUN: %clang_cc1 -S -emit-llvm -frounding-math -Wno-unknown-pragmas %s -o - 
| FileCheck %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -S -emit-llvm 
-ffp-exception-behavior=strict -Wno-unknown-pragmas %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-strict-floating-point -S -emit-llvm 
-frounding-math -Wno-unknown-pragmas %s -o - | FileCheck %s
 
 float PR47807 = -8.6563630030e-03;
 

diff  --git a/clang/test/PCH/pragma-floatcontrol.c 
b/clang/test/PCH/pragma-floatcontrol.c
index 8be46dbd1655..95f587a7b52b 100644
--- a/clang/test/PCH/pragma-floatcontrol.c
+++ b/clang/test/PCH/pragma-floatcontrol.c
@@ -1,27 +1,27 @@
 // Test this without pch.
-// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only -DSET
-// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only -DPUSH
-// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only -DPUSH_POP
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  %s -include %s 
-verify -fsyntax-only -DSET
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  %s -include %s 
-verify -fsyntax-only -DPUSH
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  %s -include %s 
-verify -fsyntax-only -DPUSH_POP
 
 // Test with pch.
-// RUN: %clang_cc1 %s -DSET -emit-pch -o %t
-// RUN: %clang_cc1 %s -DSET -include-pch %t -emit-llvm -o - | FileCheck 
--check-prefix=CHECK-EBSTRICT %s
-// RUN: %clang_cc1 %s -ffp-contract

[PATCH] D88913: [FPEnv] Use strictfp metadata in casting nodes

2020-10-30 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

I'll see how much I can simplify of the tests.




Comment at: clang/test/CodeGen/exprs-strictfp.c:1
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s 
-ffp-exception-behavior=maytrap -emit-llvm -o - | FileCheck %s

sepavloff wrote:
> No FP casts.
There's an implied cast in the AST, and I'm pretty sure the bits from that are 
used when simplifying this into the fcmp. I'll doublecheck.



Comment at: clang/test/CodeGen/ubsan-conditional-strictfp.c:1
+// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown 
-ffp-exception-behavior=maytrap -emit-llvm -fsanitize=float-divide-by-zero -o - 
| FileCheck %s
+

sepavloff wrote:
> What is the effect of `-fsanitize=float-divide-by-zero`? If it absents does 
> the test change behavior?
An earlier version of this patch did try passing bits all the way down to the 
calls to the IRBuilder. In this version of the patch the sanitizer was required 
to be involved to test one of the places that was changed. I had 100% test 
coverage for that version of the code.

I'll check and see if it is still needed.



Comment at: clang/test/CodeGen/zvector-strictfp.c:9-23
+volatile vector signed char sc, sc2;
+volatile vector unsigned char uc, uc2;
+volatile vector bool char bc, bc2;
+
+volatile vector signed short ss, ss2;
+volatile vector unsigned short us, us2;
+volatile vector bool short bs, bs2;

sepavloff wrote:
> These are integer values, they cannot produce constrained intrinsics. Why 
> they are tested here?
This test is also a holdover from the first version of the patch. It was also 
needed to achieve 100% test coverage with that first version. I'll check and 
see if it is still needed in this v2 version of the patch.


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

https://reviews.llvm.org/D88913

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


[PATCH] D90270: [clangd] Handle absolute/relative path specifications in Config

2020-10-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Still LG but a few more nits




Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:46
 
+// Returns an empty stringref if Path is not under FragmentDir.
+llvm::StringRef configRelative(llvm::StringRef Path,

you should document+verify what this does if FragmentDir is empty, since we are 
triggering that case



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:170
+  [PathMatch(std::move(PathMatch)),
+   FragmentDir(FragmentDirectory)](const Params &P) {
 if (P.Path.empty())

nit: why the rename rather than just capturing?



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:51
+return llvm::StringRef();
+  return Path;
+}

kadircet wrote:
> sammccall wrote:
> > not that if Path == FragmentDir you're going to return "" which means "not 
> > under".
> > I don't think this can happen yet, but it's a trap for the future...
> > 
> > You might want the last line to be "return FragmentDir.empty() ? "." : 
> > Path".
> i think you meant `Path.empty() ? "." : Path`, right?
oops, no I think I meant `(Path.empty() && !FragmentDir.empty() ? "." : Path`.
You don't want configRelative("","") to be ".".

So either that or handle the FragmentDir-is-empty case upfront.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90270

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


[PATCH] D84604: Thread safety analysis: Consider global variables in scope

2020-10-30 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D84604#2363768 , @rupprecht wrote:

> I applied D87194  locally and rebuilt the 
> original source, and not only am I seeing the original issue (also firing on 
> `DoThings()` when it should only be on `DoStuff()`), I'm also seeing: `error: 
> acquiring mutex 'lock' requires negative capability '!lock' 
> [-Werror,-Wthread-safety-negative]`, where `lock` is a local variable, 
> defined as `MutexLock lock(mutex_)`.

Oh yes, I need to rebase this, sorry if I wasted your time. This is still on 
top of the bug that @lebedev.ri pointed out in D84604#2262745 
 and on top of the bug that you 
pointed out.

> I'll work on getting a better repro for this.

Maybe wait a bit with that, I'll add you as reviewer when I've done the rebase 
and then you can try it again. I hope to have covered both locals and static 
members now.

Another issue is linkage, but I'll have to read up on that a bit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84604

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


[PATCH] D87194: Thread safety analysis: Use access specifiers to decide about scope

2020-10-30 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert planned changes to this revision.
aaronpuchert added a comment.

Need to rebase this on top of D84604  plus a 
subsequent fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87194

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


[PATCH] D88233: [clang][aarch64] Address various fixed-length SVE vector operations

2020-10-30 Thread Cullen Rhodes via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
c-rhodes marked an inline comment as done.
Closed by commit rG58d3f0ea4972: [clang][aarch64] Address various fixed-length 
SVE vector operations (authored by c-rhodes).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88233

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/attr-arm-sve-vector-bits.c

Index: clang/test/Sema/attr-arm-sve-vector-bits.c
===
--- clang/test/Sema/attr-arm-sve-vector-bits.c
+++ clang/test/Sema/attr-arm-sve-vector-bits.c
@@ -123,13 +123,56 @@
 void f(int c) {
   fixed_int8_t fs8;
   svint8_t ss8;
+  gnu_int8_t gs8;
 
+  // Check conditional expressions where the result is ambiguous are
+  // ill-formed.
   void *sel __attribute__((unused));
-  sel = c ? ss8 : fs8; // expected-error {{cannot convert between a fixed-length and a sizeless vector}}
-  sel = c ? fs8 : ss8; // expected-error {{cannot convert between a fixed-length and a sizeless vector}}
+  sel = c ? ss8 : fs8; // expected-error {{cannot combine fixed-length and sizeless SVE vectors in expression, result is ambiguous}}
+  sel = c ? fs8 : ss8; // expected-error {{cannot combine fixed-length and sizeless SVE vectors in expression, result is ambiguous}}
 
-  sel = fs8 + ss8; // expected-error {{cannot convert between a fixed-length and a sizeless vector}}
-  sel = ss8 + fs8; // expected-error {{cannot convert between a fixed-length and a sizeless vector}}
+  sel = c ? gs8 : ss8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
+  sel = c ? ss8 : gs8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
+
+  sel = c ? gs8 : fs8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
+  sel = c ? fs8 : gs8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
+
+  // Check binary expressions where the result is ambiguous are ill-formed.
+  ss8 = ss8 + fs8; // expected-error {{cannot combine fixed-length and sizeless SVE vectors in expression, result is ambiguous}}
+  ss8 = ss8 + gs8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
+
+  fs8 = fs8 + ss8; // expected-error {{cannot combine fixed-length and sizeless SVE vectors in expression, result is ambiguous}}
+  fs8 = fs8 + gs8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
+
+  gs8 = gs8 + ss8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
+  gs8 = gs8 + fs8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
+
+  ss8 += fs8; // expected-error {{cannot combine fixed-length and sizeless SVE vectors in expression, result is ambiguous}}
+  ss8 += gs8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
+
+  fs8 += ss8; // expected-error {{cannot combine fixed-length and sizeless SVE vectors in expression, result is ambiguous}}
+  fs8 += gs8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
+
+  gs8 += ss8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
+  gs8 += fs8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
+
+  ss8 = ss8 == fs8; // expected-error {{cannot combine fixed-length and sizeless SVE vectors in expression, result is ambiguous}}
+  ss8 = ss8 == gs8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
+
+  fs8 = fs8 == ss8; // expected-error {{cannot combine fixed-length and sizeless SVE vectors in expression, result is ambiguous}}
+  fs8 = fs8 == gs8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
+
+  gs8 = gs8 == ss8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
+  gs8 = gs8 == fs8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
+
+  ss8 = ss8 & fs8; // expected-error {{invalid operands to binary expression}}
+  ss8 = ss8 & gs8; // expected-error {{invalid operands to binary expression}}
+
+  fs8 = fs8 & ss8; // expected-error {{invalid operands to binary expression}}
+  fs8 = fs8 & gs8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
+
+  gs8 = gs8 & ss8; // expected-error {{invalid operands to binary expression}}
+  gs8 = gs8 & fs8; // expected-error {{cannot combine GNU and SVE vectors in expression, result is ambiguous}}
 }
 
 // --//
@@ -268,3 +311,78 @@
 TEST_CALL(i

[clang] 58d3f0e - [clang][aarch64] Address various fixed-length SVE vector operations

2020-10-30 Thread Cullen Rhodes via cfe-commits

Author: Cullen Rhodes
Date: 2020-10-30T15:10:54Z
New Revision: 58d3f0ea497206950d7bcb22b05d161e834e4396

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

LOG: [clang][aarch64] Address various fixed-length SVE vector operations

This patch adds tests and support for operations on SVE vectors created
by the 'arm_sve_vector_bits' attribute, described by the Arm C Language
Extensions (ACLE, version 00bet6, section 3.7.3.3) for SVE [1].

This covers the following:
* VLSTs support the same forms of element-wise initialization as GNU
  vectors.
* VLSTs support the same built-in C and C++ operators as GNU vectors.
* Conditional and binary expressions containing GNU and SVE vectors
  (fixed or sizeless) are invalid since the ambiguity around the result
  type affects the ABI.

No functional changes were required to support vector initialization and
operators. The functional changes are to address unsupported conditional and
binary expressions.

[1] https://developer.arm.com/documentation/100987/latest

Reviewed By: fpetrogalli

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/ASTContext.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/Sema/attr-arm-sve-vector-bits.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 97cacbe32e5a..47becc959fb2 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2930,8 +2930,10 @@ def err_attribute_invalid_size : Error<
   "vector size not an integral multiple of component size">;
 def err_attribute_zero_size : Error<"zero %0 size">;
 def err_attribute_size_too_large : Error<"%0 size too large">;
-def err_typecheck_vector_not_convertable_sizeless : Error<
-  "cannot convert between a fixed-length and a sizeless vector (%0 and %1)">;
+def err_typecheck_sve_ambiguous : Error<
+  "cannot combine fixed-length and sizeless SVE vectors in expression, result 
is ambiguous (%0 and %1)">;
+def err_typecheck_sve_gnu_ambiguous : Error<
+  "cannot combine GNU and SVE vectors in expression, result is ambiguous (%0 
and %1)">;
 def err_typecheck_vector_not_convertable_implict_truncation : Error<
"cannot convert between %select{scalar|vector}0 type %1 and vector type"
" %2 as implicit conversion would cause truncation">;

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 799629be2f6b..48a0bebc5452 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -8514,7 +8514,11 @@ bool ASTContext::areCompatibleVectorTypes(QualType 
FirstVec,
   First->getVectorKind() != VectorType::AltiVecPixel &&
   First->getVectorKind() != VectorType::AltiVecBool &&
   Second->getVectorKind() != VectorType::AltiVecPixel &&
-  Second->getVectorKind() != VectorType::AltiVecBool)
+  Second->getVectorKind() != VectorType::AltiVecBool &&
+  First->getVectorKind() != VectorType::SveFixedLengthDataVector &&
+  First->getVectorKind() != VectorType::SveFixedLengthPredicateVector &&
+  Second->getVectorKind() != VectorType::SveFixedLengthDataVector &&
+  Second->getVectorKind() != VectorType::SveFixedLengthPredicateVector)
 return true;
 
   return false;

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index fc8846206cd4..576cae969e00 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -9844,6 +9844,44 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, 
ExprResult &RHS,
 }
   }
 
+  // Expressions containing fixed-length and sizeless SVE vectors are invalid
+  // since the ambiguity can affect the ABI.
+  auto IsSveConversion = [](QualType FirstType, QualType SecondType) {
+const VectorType *VecType = SecondType->getAs();
+return FirstType->isSizelessBuiltinType() && VecType &&
+   (VecType->getVectorKind() == VectorType::SveFixedLengthDataVector ||
+VecType->getVectorKind() ==
+VectorType::SveFixedLengthPredicateVector);
+  };
+
+  if (IsSveConversion(LHSType, RHSType) || IsSveConversion(RHSType, LHSType)) {
+Diag(Loc, diag::err_typecheck_sve_ambiguous) << LHSType << RHSType;
+return QualType();
+  }
+
+  // Expressions containing GNU and SVE (fixed or sizeless) vectors are invalid
+  // since the ambiguity can affect the ABI.
+  auto IsSveGnuConversion = [](QualType FirstType, QualType SecondType) {
+const VectorType *FirstVecType = FirstType->getAs();
+const VectorType *SecondVecType = SecondType->getAs();
+
+if (FirstVecType && SecondVecType)
+  return FirstVecType->getVectorKind() == VectorType::GenericVector &&
+ 

[PATCH] D44964: Change order of libclang_rt.profile link for freebsd

2020-10-30 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

Yes, this looks pretty fine to me, but indeed needs a test.


Repository:
  rC Clang

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

https://reviews.llvm.org/D44964

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


[PATCH] D46791: Make -gsplit-dwarf generally available

2020-10-30 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

Correct, clang no longer uses objcopy for this as of D47093 
.


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

https://reviews.llvm.org/D46791

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


[PATCH] D89936: [clang-tidy] adding "--config-file=" to specify custom config file.

2020-10-30 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin accepted this revision.
DmitryPolukhin added a comment.
This revision is now accepted and ready to land.

Looks good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89936

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


[PATCH] D90270: [clangd] Handle absolute/relative path specifications in Config

2020-10-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 301912.
kadircet added a comment.

- Explicitly handle FragmentDir.empty() case by returning Path as-is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90270

Files:
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigProvider.cpp
  clang-tools-extra/clangd/ConfigProvider.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp

Index: clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
@@ -10,6 +10,7 @@
 #include "ConfigProvider.h"
 #include "ConfigTesting.h"
 #include "TestFS.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/SourceMgr.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -91,7 +92,7 @@
   FS.Files["foo.yaml"] = AddFooWithErr;
 
   CapturedDiags Diags;
-  auto P = Provider::fromYAMLFile(testPath("foo.yaml"), FS);
+  auto P = Provider::fromYAMLFile(testPath("foo.yaml"), /*Directory=*/"", FS);
   auto Cfg = P->getConfig(Params(), Diags.callback());
   EXPECT_THAT(Diags.Diagnostics,
   ElementsAre(DiagMessage("Unknown CompileFlags key Unknown")));
@@ -159,7 +160,7 @@
   Params MustBeFresh;
   MustBeFresh.FreshTime = StartTime + std::chrono::hours(1);
   CapturedDiags Diags;
-  auto P = Provider::fromYAMLFile(testPath("foo.yaml"), FS);
+  auto P = Provider::fromYAMLFile(testPath("foo.yaml"), /*Directory=*/"", FS);
 
   // Initial query always reads, regardless of policy.
   FS.Files["foo.yaml"] = AddFooWithErr;
@@ -187,6 +188,37 @@
   EXPECT_THAT(getAddedArgs(Cfg), IsEmpty());
 }
 
+TEST(ProviderTest, SourceInfo) {
+  MockFS FS;
+
+  FS.Files["baz/foo.yaml"] = R"yaml(
+If:
+  PathMatch: .*
+  PathExclude: bar.h
+CompileFlags:
+  Add: bar
+)yaml";
+  const auto BarPath = testPath("baz/bar.h", llvm::sys::path::Style::posix);
+  CapturedDiags Diags;
+  Params Bar;
+  Bar.Path = BarPath;
+
+  // This should be an absolute match/exclude hence baz/bar.h should not be
+  // excluded.
+  auto P =
+  Provider::fromYAMLFile(testPath("baz/foo.yaml"), /*Directory=*/"", FS);
+  auto Cfg = P->getConfig(Bar, Diags.callback());
+  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("bar"));
+  Diags.Diagnostics.clear();
+
+  // This should be a relative match/exclude hence baz/bar.h should be excluded.
+  P = Provider::fromAncestorRelativeYAMLFiles("foo.yaml", FS);
+  Cfg = P->getConfig(Bar, Diags.callback());
+  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+  EXPECT_THAT(getAddedArgs(Cfg), IsEmpty());
+  Diags.Diagnostics.clear();
+}
 } // namespace
 } // namespace config
 } // namespace clangd
Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -9,8 +9,12 @@
 #include "Config.h"
 #include "ConfigFragment.h"
 #include "ConfigTesting.h"
+#include "TestFS.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Path.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -116,6 +120,62 @@
   "Invalid Background value 'Foo'. Valid values are Build, Skip.")));
 }
 
+TEST_F(ConfigCompileTests, PathSpecMatch) {
+  auto BarPath = llvm::sys::path::convert_to_slash(testPath("foo/bar.h"));
+  Parm.Path = BarPath;
+
+  struct {
+std::string Directory;
+std::string PathSpec;
+bool ShouldMatch;
+  } Cases[] = {
+  {
+  // Absolute path matches.
+  "",
+  llvm::sys::path::convert_to_slash(testPath("foo/bar.h")),
+  true,
+  },
+  {
+  // Absolute path fails.
+  "",
+  llvm::sys::path::convert_to_slash(testPath("bar/bar.h")),
+  false,
+  },
+  {
+  // Relative should fail to match as /foo/bar.h doesn't reside under
+  // /baz/.
+  testPath("baz"),
+  "bar\\.h",
+  false,
+  },
+  {
+  // Relative should pass with /foo as directory.
+  testPath("foo"),
+  "bar\\.h",
+  true,
+  },
+  };
+
+  // PathMatch
+  for (const auto &Case : Cases) {
+Frag = {};
+Frag.If.PathMatch.emplace_back(Case.PathSpec);
+Frag.Source.Directory = Case.Directory;
+EXPECT_EQ(compileAndApply(), Case.ShouldMatch);
+ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+  }
+
+  // PathEclude
+  for (const auto &Case : Cases) {
+SCOPED_TRACE(Case.Directory);
+SCOPED_TRACE(Case.PathSpec);
+Frag = {};
+Frag.If.PathExclude

[PATCH] D90270: [clangd] Handle absolute/relative path specifications in Config

2020-10-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked 2 inline comments as done.
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:170
+  [PathMatch(std::move(PathMatch)),
+   FragmentDir(FragmentDirectory)](const Params &P) {
 if (P.Path.empty())

sammccall wrote:
> nit: why the rename rather than just capturing?
because it is actually a member of FragmentCompiler and not a scoped variable :/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90270

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


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

2020-10-30 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 301913.
jansvoboda11 added a comment.
Herald added a subscriber: mgorny.

Added LLVM unit tests, reverted back to `array_pod_sort`.


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

https://reviews.llvm.org/D82756

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/unittests/Option/CMakeLists.txt
  llvm/unittests/Option/OptionMarshallingTest.cpp
  llvm/unittests/Option/Opts.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -435,7 +435,12 @@
   OS << "nullptr";
   };
 
-  std::vector> OptsWithMarshalling;
+  auto IsMarshallingOption = [](const Record &R) {
+return !isa(R.getValueInit("MarshallingKind")) &&
+   !R.getValueAsString("KeyPath").empty();
+  };
+
+  std::vector OptsWithMarshalling;
   for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
 const Record &R = *Opts[I];
 
@@ -443,12 +448,33 @@
 OS << "OPTION(";
 WriteOptRecordFields(OS, R);
 OS << ")\n";
-if (!isa(R.getValueInit("MarshallingKind")))
-  OptsWithMarshalling.push_back(MarshallingKindInfo::create(R));
+if (IsMarshallingOption(R))
+  OptsWithMarshalling.push_back(&R);
   }
   OS << "#endif // OPTION\n";
 
-  for (const auto &KindInfo : OptsWithMarshalling) {
+  auto CmpMarshallingOpts = [](const Record *const *A, const Record *const *B) {
+unsigned AID = (*A)->getID();
+unsigned BID = (*B)->getID();
+
+if (AID < BID)
+  return -1;
+if (AID > BID)
+  return 1;
+return 0;
+  };
+  // The RecordKeeper stores records (options) in lexicographical order, and we
+  // have reordered the options again when generating prefix groups. We need to
+  // restore the original definition order of options with marshalling to honor
+  // the topology of the dependency graph implied by `DefaultAnyOf`.
+  array_pod_sort(OptsWithMarshalling.begin(), OptsWithMarshalling.end(),
+ CmpMarshallingOpts);
+
+  std::vector> MarshallingKindInfos;
+  for (const auto *R : OptsWithMarshalling)
+MarshallingKindInfos.push_back(MarshallingKindInfo::create(*R));
+
+  for (const auto &KindInfo : MarshallingKindInfos) {
 OS << "#ifdef " << KindInfo->MacroName << "\n";
 OS << KindInfo->MacroName << "(";
 WriteOptRecordFields(OS, KindInfo->R);
@@ -463,7 +489,7 @@
   OS << "\n";
   OS << MarshallingStringInfo::ValueTablePreamble;
   std::vector ValueTableNames;
-  for (const auto &KindInfo : OptsWithMarshalling)
+  for (const auto &KindInfo : MarshallingKindInfos)
 if (auto MaybeValueTableName = KindInfo->emitValueTable(OS))
   ValueTableNames.push_back(*MaybeValueTableName);
 
Index: llvm/unittests/Option/Opts.td
===
--- llvm/unittests/Option/Opts.td
+++ llvm/unittests/Option/Opts.td
@@ -44,3 +44,12 @@
 def Blurmpq_eq : Flag<["--"], "blurmp=">;
 
 def DashDash : Option<["--"], "", KIND_REMAINING_ARGS>;
+
+def marshalled_flag_0 : Flag<["-"], "marshalled-flag-0">,
+  MarshallingInfoFlag<"MarshalledFlag0", DefaultAnyOf<[]>>;
+def marshalled_flag_1 : Flag<["-"], "marshalled-flag-1">,
+  MarshallingInfoFlag<"MarshalledFlag1", DefaultAnyOf<[marshalled_flag_0]>>;
+def marshalled_flag_2 : Flag<["-"], "marshalled-flag-2">,
+  MarshallingInfoFlag<"MarshalledFlag2", DefaultAnyOf<[marshalled_flag_0]>>;
+def marshalled_flag_3 : Flag<["-"], "marshalled-flag-3">,
+  MarshallingInfoFlag<"MarshalledFlag3", DefaultAnyOf<[marshalled_flag_1, marshalled_flag_2]>>;
Index: llvm/unittests/Option/OptionMarshallingTest.cpp
===
--- /dev/null
+++ llvm/unittests/Option/OptionMarshallingTest.cpp
@@ -0,0 +1,47 @@
+//===- unittest/Support/OptionMarshallingTest.cpp - OptParserEmitter tests ===//
+//
+// 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 "gtest/gtest.h"
+
+struct OptionWithMarshallingInfo {
+  const char *Name;
+  const char *KeyPath;
+  const char *DefaultValue;
+};
+
+static const OptionWithMarshallingInfo MarshallingTable[] = {
+#define OPTION_WITH_MARSHALLING_FLAG(PREFIX_TYPE, NAME, ID, KIND, GROUP,   \
+ ALIAS, ALIASARGS, FLAGS, PARAM, HELPTEXT, \
+ METAVAR, VALUES, SPELLING, ALWAYS_EMIT,   \
+ KEYPATH, DEFAULT_VALUE, IS_POSITIVE)  \
+  { NAME, #KEYPATH

[PATCH] D89761: Split out llvm/Support/FileSystem/UniqueID.h and clang/Basic/FileEntry.h, NFC

2020-10-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: llvm/include/llvm/Support/FileSystem/UniqueID.h:36
+  bool operator<(const UniqueID &Other) const {
+return std::tie(Device, File) < std::tie(Other.Device, Other.File);
+  }

rnk wrote:
> FYI std::tie is pretty expensive to compile, unfortunately. You also might 
> technically need to include some STL header for it here.
I just sent you https://reviews.llvm.org/D90471 to remove `std::tie`. (Already 
fixed the includes in 44d65efd95b353eeb26440ad2ef9f3bd05f5a927, not sure 
how/why it worked without them locally.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89761

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


[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2020-10-30 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/Sema/SemaStmtAttr.cpp:144
+  assert(ValueExpr && "Attribute must have a valid value expression.");
+  if (S.CheckLoopHintExpr(ValueExpr, St->getBeginLoc()))
+return nullptr;

david-arm wrote:
> fhahn wrote:
> > Is there a way to only accept `fixed_width/scalable` for targets that 
> > support it? Not sure if we have enough information here, but we might be 
> > able to reject it eg per target basis or something
> Hi @fhahn, I think if possible we'd prefer not to reject scalable vectors at 
> this point. Theoretically there is no reason why we can't perform scalable 
> vectorisation for targets that don't have hardware support for scalable 
> vectors. In this case it simply means that vscale is 1. If you want we could 
> add some kind of opt-remark in the vectoriser that says something like 
> "target does not support scalable vectors, vectorising for vscale=1"?
I agree with @david-arm that we shouldn't prevent this in the front-end. Even 
if the architecture may not support scalable vectors natively, there may still 
be reasons to want to create scalable vectors in IR, for example to have more 
portable IR.



Comment at: clang/test/CodeGenCXX/pragma-loop.cpp:166
+#pragma clang loop vectorize_width(16, fixed) interleave_count(4) 
unroll(disable) distribute(disable)
+  do {
+// CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop 
![[LOOP_15:.*]]

out of curiosity, is there a particular reason you're testing it with a 
do-while loop instead of a shorter for-loop like the tests in 
`for_template_constant_expression_test` ?


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

https://reviews.llvm.org/D89031

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


[PATCH] D84362: [NFC] Refactor DiagnosticBuilder and PartialDiagnostic

2020-10-30 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

Hi @rjmccall , thank you for your quick reply!

> It sounds like what you want is a diagnostic library that's almost completely 
> abstracted over the kinds of entities that can be stored in a diagnostic, 
> including the definition of a source location.

No :) We suggested (and that's based on the feedback on cfe-dev) a more basic 
approach. We proposed an abstraction layer that does not require any location 
information, because that's irrelevant in the driver (more on this below). We 
did, intially, suggest re-using and re-factoring `SourceLocation` (and, more 
specifically, `SourceManager`). That direction was explicitely discouraged on 
cfe-dev [3].

> Source locations, supplemental source ranges, and fix-its are all still 
> meaningful concepts in the driver

When we studied the source code of libclangDriver that was not the case. The 
diagnostics in the driver [1] are only used to a very limited extent (compared 
to the frontend) and I've only seen them issued via [2]:

  inline DiagnosticBuilder DiagnosticsEngine::Report(unsigned DiagID) {
return Report(SourceLocation(), DiagID);
  }

i.e. `SourceLocation` is not really used at all. Are we missing something here? 
Is there any place in the libclangDriver (or any tool that's implemented in 
terms of libclangdDriver) that actually requires `SourceLocation`?

We would like to keep the scope of refactoring libclangDriver (and its 
dependencies) to the required minimum. The solution that you suggested would 
mean refactoring an API that's not required by libclangDriver (please correct 
me if I'm missing something here). I'm concerned that any attempts to modify 
`SourceLocation` will be challenged on cfe-dev. It was already suggested that 
we shouldn't need it for what we want to achieve. And indeed, in our simplified 
prototype downstream we were able to avoid using it without affecting the 
driver diagnostics.

Another difficulty with your suggestion is testing. If we were to create some 
abstraction layer above `SourceLocation` - how would we define or test it? 
Again, AFAIK diagnostics in libclangDriver never contain any information with 
respect to source location. So how do we decide what's actually required? This 
would be easy if there was a reference example :)

All in all, I think that this patch will require us to broaden the refactoring 
in a way that otherwise wouldn't be required. And according to the feedback so 
far this will be detrimental to Clang. If we are still in disagreement then 
perhaps we should move this discussion to cfe-dev? I want to make sure that we 
are all aligned on the overall direction and that we don't diverge too much 
from what was already discussed on cfe-dev.

Thanks in advance for your feedback,
-Andrzej

[1]
https://github.com/llvm/llvm-project/blob/3c3071d5e7dd259022d4f5e879fdf9824b9e490c/clang/lib/Driver/OptionUtils.cpp#L26
https://github.com/llvm/llvm-project/blob/3c3071d5e7dd259022d4f5e879fdf9824b9e490c/clang/lib/Driver/Driver.cpp#L270
https://github.com/llvm/llvm-project/blob/3c3071d5e7dd259022d4f5e879fdf9824b9e490c/clang/lib/Driver/Driver.cpp#L275
https://github.com/llvm/llvm-project/blob/3c3071d5e7dd259022d4f5e879fdf9824b9e490c/clang/lib/Driver/Driver.cpp#L1145

[2] 
https://github.com/llvm/llvm-project/blob/3c3071d5e7dd259022d4f5e879fdf9824b9e490c/clang/include/clang/Basic/Diagnostic.h#L1482-L1484

[3] http://lists.llvm.org/pipermail/cfe-dev/2020-June/065766.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84362

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


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

2020-10-30 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

I've added tests for OptParserEmitter. Let me know if you had something more 
detailed in mind.




Comment at: clang/include/clang/Driver/Options.td:1176
+defm reciprocal_math : OptInFFlag< "reciprocal-math", "Allow division 
operations to be reassociated", "", "", [], "LangOpts->AllowRecip">;
+def fapprox_func : Flag<["-"], "fapprox-func">, Group, 
Flags<[CC1Option, NoDriverOption]>,
+  MarshallingInfoFlag<"LangOpts->ApproxFunc", "false">;

dexonsmith wrote:
> jansvoboda11 wrote:
> > dexonsmith wrote:
> > > dang wrote:
> > > > Anastasia wrote:
> > > > > could this also be OptInFFlag?
> > > > The aim was to keep the driver semantics the same as before and this 
> > > > was not something you could control with the driver, so I left it as 
> > > > just a CC1 flag. However if it makes sense to be able to control this 
> > > > from the driver then we can definitely make this `OptInFFLag`.
> > > I think adding a driver flag (if that's the right thing to do) should be 
> > > done separately in a follow-up commit.
> > > 
> > > Also for a separate commit: it would be a great improvement if you could 
> > > have OptIn / OptOut flags that were `-cc1`-only (maybe `CC1OptInFFlag`).
> > > - Both `-fX` and `-fno-X` would be parsed by `-cc1` (and cancel each 
> > > other out).
> > > - Only the non-default one would be generated when serializing to `-cc1` 
> > > from `CompilerInvocation` (for `OptIn`, we'd never generate `-fno-X`).
> > > - Neither would be recognized by the driver.
> > > 
> > > I suggest we might want that for most `-cc11` flags. This would make it 
> > > easier to poke through the driver with `-Xclang` to override `-cc1` 
> > > options the driver adds. Not something we want for end-users, but useful 
> > > for debugging the compiler itself. Currently the workflow is to run the 
> > > driver with `-###`, copy/paste, search for and remove the option you want 
> > > to skip, and finally run the `-cc1` command...
> > > 
> > > The reason I bring it up is that it's possible people will start using 
> > > `OptInFFLag` just in order to get this behaviour, not because they intend 
> > > to add a driver flag.
> > I agree that making all `OptInFFlag` and `OptOutFFlag` driver flags as well 
> > as `-cc1` flags by default is not great. How would we go about deciding 
> > which options are okay to demote to `-cc1`-only? Perhaps those not present 
> > in `ClangCommandLineReference.rst` and driver invocations in tests?
> > How would we go about deciding which options are okay to demote to 
> > `-cc1-only`?
> 
> The key is not to add (or remove) driver options unintentionally. Driver 
> options are `clang`'s public interface, and once an option shows up there 
> we're supposed to support it "forever". We shouldn't be 
> accidentally/incidentally growing that surface area in order to simplify 
> parsing/generating `-cc1` command-lines.
> 
> I based my comment on @dang's reason for not using `OptInFFLag`, which I 
> agree with:
> > The aim was to keep the driver semantics the same as before and this was 
> > not something you could control with the driver, so I left it as just a CC1 
> > flag.
> 
Agreed.



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:468-469
+  // Restore the definition order of marshalling options.
+  array_pod_sort(OptsWithMarshalling.begin(), OptsWithMarshalling.end(),
+ CmpMarshallingOpts);
+

dexonsmith wrote:
> jansvoboda11 wrote:
> > dexonsmith wrote:
> > > I'm curious if this is necessary. If so, how do the options get 
> > > out-of-order?
> > > 
> > > Also, a cleaner way to call `array_pod_sort` would be:
> > > ```
> > > llvm::sort(OptsWithMarshalling, CmpMarshallingOpts);
> > > ```
> > > and I would be tempted to define the lambda inline in the call to 
> > > `llvm::sort`.
> > > 
> > > If it's not necessary, I suggest replacing with an assertion:
> > > ```
> > > assert(llvm::is_sorted(OptsWithMarshalling, ...));
> > > ```
> > 1. The options get out of order during parsing. The `RecordKeeper` stores 
> > records in `std::map, std::less<>>` 
> > that maintains lexicographical order.
> > 
> > 2. Later, they are reordered in this function before prefix groups are 
> > generated: `array_pod_sort(Opts.begin(), Opts.end(), 
> > CompareOptionRecords);`.
> > 
> > 3. Before we generate the marshalling code, we need to restore the 
> > definition order so that we don't use a `LangOpts` or `CodeGenOpts` field 
> > (from `DefaultAnyOf`) before it was initialized.
> > 
> > I've added more detailed explanation to the comment.
> > 
> > I used `array_pod_sort` to be consistent with what's already used here in 
> > `OptParserEmitter.cpp`. I will switch to `llvm::sort` to be more concise if 
> > we don't mind the potential code bloat described here 
> > .
> Thanks for the explanation about the ordering, this makes sens

[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2020-10-30 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: clang/lib/Sema/SemaStmtAttr.cpp:144
+  assert(ValueExpr && "Attribute must have a valid value expression.");
+  if (S.CheckLoopHintExpr(ValueExpr, St->getBeginLoc()))
+return nullptr;

sdesmalen wrote:
> david-arm wrote:
> > fhahn wrote:
> > > Is there a way to only accept `fixed_width/scalable` for targets that 
> > > support it? Not sure if we have enough information here, but we might be 
> > > able to reject it eg per target basis or something
> > Hi @fhahn, I think if possible we'd prefer not to reject scalable vectors 
> > at this point. Theoretically there is no reason why we can't perform 
> > scalable vectorisation for targets that don't have hardware support for 
> > scalable vectors. In this case it simply means that vscale is 1. If you 
> > want we could add some kind of opt-remark in the vectoriser that says 
> > something like "target does not support scalable vectors, vectorising for 
> > vscale=1"?
> I agree with @david-arm that we shouldn't prevent this in the front-end. Even 
> if the architecture may not support scalable vectors natively, there may 
> still be reasons to want to create scalable vectors in IR, for example to 
> have more portable IR.
Hm, I am just a bit worried that it might be a bit confusing to users that do 
not know what scalable vectors are (it is obvious when knowing all about SVE, 
but I would assume most people don't necessarily know what this means). I guess 
that is not the biggest deal, as long `vectorize_width(X, scalable)` works for 
every target.

>  Even if the architecture may not support scalable vectors natively, there 
> may still be reasons to want to create scalable vectors in IR, for example to 
> have more portable IR.

Sure, but there are so many other target-specific things encoded that make the 
IR really un-portable between targets. Granted, it is not impossible to convert 
IR between some architectures (as in arm64_32)


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

https://reviews.llvm.org/D89031

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


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

2020-10-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for working through this.


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

https://reviews.llvm.org/D82756

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


[PATCH] D90447: [AMDGPU] Add gfx1033 target

2020-10-30 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec added a comment.

Missing changes to these files:

clang/include/clang/Basic/Cuda.h
clang/lib/Basic/Cuda.cpp
clang/lib/Basic/Targets/NVPTX.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
llvm/lib/Object/ELFObjectFile.cpp
llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90447

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


[clang] bbe055d - [CodeGen][X86] Remove unused check-prefix in amx inline asm tests

2020-10-30 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-10-30T16:13:45Z
New Revision: bbe055dd73cf3f87e6e6481b5aa36bcc875cbe23

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

LOG: [CodeGen][X86] Remove unused check-prefix in amx inline asm tests

Added: 


Modified: 
clang/test/CodeGen/X86/amx_inline_asm.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/amx_inline_asm.c 
b/clang/test/CodeGen/X86/amx_inline_asm.c
index 9d828f8ac94e..24788adfd2cb 100644
--- a/clang/test/CodeGen/X86/amx_inline_asm.c
+++ b/clang/test/CodeGen/X86/amx_inline_asm.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown  
-target-feature +amx-int8 -target-feature +amx-bf16 -emit-llvm -o - -Wall 
-Werror -pedantic | FileCheck %s --check-prefixes=CHECK,X86_64
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown  
-target-feature +amx-int8 -target-feature +amx-bf16 -emit-llvm -o - -Wall 
-Werror -pedantic | FileCheck %s
 
 void f_tilemul(short a)
 {



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


[clang] fe3d765 - [CodeGen][X86] Tidyup CHECKs on bitscan tests

2020-10-30 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-10-30T16:13:52Z
New Revision: fe3d765ac72ed58cc81cc93d5a1bf0f61491f80d

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

LOG: [CodeGen][X86] Tidyup CHECKs on bitscan tests

Added: 


Modified: 
clang/test/CodeGen/X86/bitscan-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/bitscan-builtins.c 
b/clang/test/CodeGen/X86/bitscan-builtins.c
index 1035d1840852..a5a7808a82a2 100644
--- a/clang/test/CodeGen/X86/bitscan-builtins.c
+++ b/clang/test/CodeGen/X86/bitscan-builtins.c
@@ -8,18 +8,18 @@
 #include 
 
 int test_bit_scan_forward(int a) {
-  return _bit_scan_forward(a);
 // CHECK-LABEL: test_bit_scan_forward
 // CHECK: %[[call:.*]] = call i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)
 // CHECK: ret i32 %[[call]]
+  return _bit_scan_forward(a);
 }
 
 int test_bit_scan_reverse(int a) {
-  return _bit_scan_reverse(a);
 // CHECK-LABEL: test_bit_scan_reverse
 // CHECK:  %[[call:.*]] = call i32 @llvm.ctlz.i32(i32 %{{.*}}, i1 true)
 // CHECK:  %[[sub:.*]] = sub nsw i32 31, %[[call]]
 // CHECK: ret i32 %[[sub]]
+  return _bit_scan_reverse(a);
 }
 
 int test__bsfd(int X) {



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


[clang] 5cdd470 - [CodeGen][X86] Remove unused check-prefix in bitscan tests

2020-10-30 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-10-30T16:13:50Z
New Revision: 5cdd47050408d826d7fb324d9a130cf8e74298e2

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

LOG: [CodeGen][X86] Remove unused check-prefix in bitscan tests

Added: 


Modified: 
clang/test/CodeGen/X86/bitscan-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/bitscan-builtins.c 
b/clang/test/CodeGen/X86/bitscan-builtins.c
index 2fcebf477846..1035d1840852 100644
--- a/clang/test/CodeGen/X86/bitscan-builtins.c
+++ b/clang/test/CodeGen/X86/bitscan-builtins.c
@@ -1,49 +1,48 @@
-// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-unknown 
-emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECKC
-// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s 
-triple=x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECKCPP
-
+// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-unknown 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s 
-triple=x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s
 
 // PR33722
-// RUN: %clang_cc1 -x c -ffreestanding %s -triple x86_64-unknown-unknown 
-fms-extensions -fms-compatibility-version=19.00 -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECKC
-// RUN: %clang_cc1 -x c++ -ffreestanding %s -triple x86_64-unknown-unknown 
-fms-extensions -fms-compatibility-version=19.00 -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECKCPP
+// RUN: %clang_cc1 -x c -ffreestanding %s -triple x86_64-unknown-unknown 
-fms-extensions -fms-compatibility-version=19.00 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -ffreestanding %s -triple x86_64-unknown-unknown 
-fms-extensions -fms-compatibility-version=19.00 -emit-llvm -o - | FileCheck %s
 
 #include 
 
 int test_bit_scan_forward(int a) {
   return _bit_scan_forward(a);
-// CHECKC-LABEL: @test_bit_scan_forward
+// CHECK-LABEL: test_bit_scan_forward
 // CHECK: %[[call:.*]] = call i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)
 // CHECK: ret i32 %[[call]]
 }
 
 int test_bit_scan_reverse(int a) {
   return _bit_scan_reverse(a);
-// CHECKC-LABEL: @test_bit_scan_reverse
+// CHECK-LABEL: test_bit_scan_reverse
 // CHECK:  %[[call:.*]] = call i32 @llvm.ctlz.i32(i32 %{{.*}}, i1 true)
 // CHECK:  %[[sub:.*]] = sub nsw i32 31, %[[call]]
 // CHECK: ret i32 %[[sub]]
 }
 
 int test__bsfd(int X) {
-// CHECKC-LABEL: @test__bsfd
+// CHECK-LABEL: test__bsfd
 // CHECK: %[[call:.*]] = call i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)
   return __bsfd(X);
 }
 
 int test__bsfq(long long X) {
-// CHECKC-LABEL: @test__bsfq
+// CHECK-LABEL: test__bsfq
 // CHECK: %[[call:.*]] = call i64 @llvm.cttz.i64(i64 %{{.*}}, i1 true)
   return __bsfq(X);
 }
 
 int test__bsrd(int X) {
-// CHECKC-LABEL: @test__bsrd
+// CHECK-LABEL: test__bsrd
 // CHECK:  %[[call:.*]] = call i32 @llvm.ctlz.i32(i32 %{{.*}}, i1 true)
 // CHECK:  %[[sub:.*]] = sub nsw i32 31, %[[call]]
   return __bsrd(X);
 }
 
 int test__bsrq(long long X) {
-// CHECKC-LABEL: @test__bsrq
+// CHECK-LABEL: test__bsrq
 // CHECK:  %[[call:.*]] = call i64 @llvm.ctlz.i64(i64 %{{.*}}, i1 true)
 // CHECK:  %[[cast:.*]] = trunc i64 %[[call]] to i32
 // CHECK:  %[[sub:.*]] = sub nsw i32 63, %[[cast]]



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


[clang] 0ff9d8c - [CodeGen][X86] Remove unused check-prefix in bswap tests

2020-10-30 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-10-30T16:13:49Z
New Revision: 0ff9d8c8baa317f4135e08cfe8d64e4b824b7c49

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

LOG: [CodeGen][X86] Remove unused check-prefix in bswap tests

Added: 


Modified: 
clang/test/CodeGen/X86/x86-bswap.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/x86-bswap.c 
b/clang/test/CodeGen/X86/x86-bswap.c
index e952e4f5b127..fb4852c52408 100644
--- a/clang/test/CodeGen/X86/x86-bswap.c
+++ b/clang/test/CodeGen/X86/x86-bswap.c
@@ -1,28 +1,28 @@
-// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin 
-emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECKC
-// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s 
-triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECKCPP
+// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s 
-triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
 
 #include 
 
 int test__bswapd(int X) {
-// CHECKC-LABEL: @test__bswapd
+// CHECK-LABEL: test__bswapd
 // CHECK: call i32 @llvm.bswap.i32
   return __bswapd(X);
 }
 
 int test_bswap(int X) {
-// CHECKC-LABEL: @test_bswap
+// CHECK-LABEL: test_bswap
 // CHECK: call i32 @llvm.bswap.i32
   return _bswap(X);
 }
 
 long test__bswapq(long long X) {
-// CHECKC-LABEL: @test__bswapq
+// CHECK-LABEL: test__bswapq
 // CHECK: call i64 @llvm.bswap.i64
   return __bswapq(X);
 }
 
 long test_bswap64(long long X) {
-// CHECKC-LABEL: @test_bswap64
+// CHECK-LABEL: test_bswap64
 // CHECK: call i64 @llvm.bswap.i64
   return _bswap64(X);
 }



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


[clang] d7389f0 - [CodeGen][X86] Cleanup + remove unused check-prefixes in avx union tests

2020-10-30 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-10-30T16:13:47Z
New Revision: d7389f05ee27e703ac9c0873d3ac183d8d9cf0c5

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

LOG: [CodeGen][X86] Cleanup + remove unused check-prefixes in avx union tests

Added: 


Modified: 
clang/test/CodeGen/X86/avx-union.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/avx-union.c 
b/clang/test/CodeGen/X86/avx-union.c
index 17ffb77300ff..b4f7dc08dfee 100644
--- a/clang/test/CodeGen/X86/avx-union.c
+++ b/clang/test/CodeGen/X86/avx-union.c
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -w -ffreestanding -triple x86_64-linux-gnu -target-feature 
+avx -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=AVX
-// RUN: %clang_cc1 -w -ffreestanding -triple x86_64-linux-gnu -target-feature 
+avx512f -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK 
--check-prefix=AVX512
+// RUN: %clang_cc1 -w -ffreestanding -triple x86_64-linux-gnu -target-feature 
+avx -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,AVX
+// RUN: %clang_cc1 -w -ffreestanding -triple x86_64-linux-gnu -target-feature 
+avx512f -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,AVX512
 
 // Test Clang 11 and earlier behavior
-// RUN: %clang_cc1 -w -ffreestanding -triple x86_64-linux-gnu -target-feature 
+avx -fclang-abi-compat=10.0 -emit-llvm -o - %s | FileCheck %s 
--check-prefix=AVX --check-prefix=CHECK-LEGACY
-// RUN: %clang_cc1 -w -ffreestanding -triple x86_64-linux-gnu -target-feature 
+avx512f -fclang-abi-compat=11.0 -emit-llvm -o - %s | FileCheck %s 
--check-prefix=CHECK-LEGACY --check-prefix=AVX512-LEGACY
-// RUN: %clang_cc1 -w -ffreestanding -triple x86_64-scei-ps4 -target-feature 
+avx -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-LEGACY 
--check-prefix=AVX-LEGACY
+// RUN: %clang_cc1 -w -ffreestanding -triple x86_64-linux-gnu -target-feature 
+avx -fclang-abi-compat=10.0 -emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK-LEGACY,AVX
+// RUN: %clang_cc1 -w -ffreestanding -triple x86_64-linux-gnu -target-feature 
+avx512f -fclang-abi-compat=11.0 -emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK-LEGACY,AVX512-LEGACY
+// RUN: %clang_cc1 -w -ffreestanding -triple x86_64-scei-ps4 -target-feature 
+avx -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-LEGACY
 
 // This tests verifies that a union parameter should pass by a vector 
regitster whose first eightbyte is SSE and the other eightbytes are SSEUP.
 



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


[clang] c44846f - [CodeGen][X86] Cleanup + fix unused check-prefixes in bmi tests

2020-10-30 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-10-30T16:13:54Z
New Revision: c44846f537efb4f996becc6f665af828051a08f6

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

LOG: [CodeGen][X86] Cleanup + fix unused check-prefixes in bmi tests

Added: 


Modified: 
clang/test/CodeGen/X86/bmi-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/bmi-builtins.c 
b/clang/test/CodeGen/X86/bmi-builtins.c
index 409dd40c4a33..81405429b9b6 100644
--- a/clang/test/CodeGen/X86/bmi-builtins.c
+++ b/clang/test/CodeGen/X86/bmi-builtins.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +bmi -emit-llvm -o - -Wall -Werror | FileCheck %s 
--check-prefixes=CHECK,CHECK_TZCNT
-// RUN: %clang_cc1 -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc 
-emit-llvm -o - -Wall -Werror -DTEST_TZCNT | FileCheck %s 
--check-prefix=CHECK-TZCNT
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +bmi -emit-llvm -o - -Wall -Werror | FileCheck %s 
--check-prefixes=CHECK,TZCNT
+// RUN: %clang_cc1 -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc 
-emit-llvm -o - -Wall -Werror -DTEST_TZCNT | FileCheck %s --check-prefix=TZCNT
 
 
 #include 
@@ -15,122 +15,122 @@
 // intrinsics are 
diff erent!
 
 unsigned short test_tzcnt_u16(unsigned short __X) {
-  // CHECK-TZCNT-LABEL: test_tzcnt_u16
-  // CHECK-TZCNT: i16 @llvm.cttz.i16(i16 %{{.*}}, i1 false)
+// TZCNT-LABEL: test_tzcnt_u16
+// TZCNT: i16 @llvm.cttz.i16(i16 %{{.*}}, i1 false)
   return _tzcnt_u16(__X);
 }
 
 unsigned short test__tzcnt_u16(unsigned short __X) {
-  // CHECK-TZCNT-LABEL: test__tzcnt_u16
-  // CHECK-TZCNT: i16 @llvm.cttz.i16(i16 %{{.*}}, i1 false)
+// TZCNT-LABEL: test__tzcnt_u16
+// TZCNT: i16 @llvm.cttz.i16(i16 %{{.*}}, i1 false)
   return __tzcnt_u16(__X);
 }
 
 unsigned int test__tzcnt_u32(unsigned int __X) {
-  // CHECK-TZCNT-LABEL: test__tzcnt_u32
-  // CHECK-TZCNT: i32 @llvm.cttz.i32(i32 %{{.*}}, i1 false)
+// TZCNT-LABEL: test__tzcnt_u32
+// TZCNT: i32 @llvm.cttz.i32(i32 %{{.*}}, i1 false)
   return __tzcnt_u32(__X);
 }
 
 int test_mm_tzcnt_32(unsigned int __X) {
-  // CHECK-TZCNT-LABEL: test_mm_tzcnt_32
-  // CHECK-TZCNT: i32 @llvm.cttz.i32(i32 %{{.*}}, i1 false)
+// TZCNT-LABEL: test_mm_tzcnt_32
+// TZCNT: i32 @llvm.cttz.i32(i32 %{{.*}}, i1 false)
   return _mm_tzcnt_32(__X);
 }
 
 unsigned int test_tzcnt_u32(unsigned int __X) {
-  // CHECK-TZCNT-LABEL: test_tzcnt_u32
-  // CHECK-TZCNT: i32 @llvm.cttz.i32(i32 %{{.*}}, i1 false)
+// TZCNT-LABEL: test_tzcnt_u32
+// TZCNT: i32 @llvm.cttz.i32(i32 %{{.*}}, i1 false)
   return _tzcnt_u32(__X);
 }
 
 #ifdef __x86_64__
 unsigned long long test__tzcnt_u64(unsigned long long __X) {
-  // CHECK-TZCNT-LABEL: test__tzcnt_u64
-  // CHECK-TZCNT: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
+// TZCNT-LABEL: test__tzcnt_u64
+// TZCNT: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
   return __tzcnt_u64(__X);
 }
 
 long long test_mm_tzcnt_64(unsigned long long __X) {
-  // CHECK-TZCNT-LABEL: test_mm_tzcnt_64
-  // CHECK-TZCNT: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
+// TZCNT-LABEL: test_mm_tzcnt_64
+// TZCNT: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
   return _mm_tzcnt_64(__X);
 }
 
 unsigned long long test_tzcnt_u64(unsigned long long __X) {
-  // CHECK-TZCNT-LABEL: test_tzcnt_u64
-  // CHECK-TZCNT: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
+// TZCNT-LABEL: test_tzcnt_u64
+// TZCNT: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
   return _tzcnt_u64(__X);
 }
 #endif
 
 #if !defined(TEST_TZCNT)
 unsigned int test__andn_u32(unsigned int __X, unsigned int __Y) {
-  // CHECK-LABEL: test__andn_u32
-  // CHECK: xor i32 %{{.*}}, -1
-  // CHECK: and i32 %{{.*}}, %{{.*}}
+// CHECK-LABEL: test__andn_u32
+// CHECK: xor i32 %{{.*}}, -1
+// CHECK: and i32 %{{.*}}, %{{.*}}
   return __andn_u32(__X, __Y);
 }
 
 unsigned int test__bextr_u32(unsigned int __X, unsigned int __Y) {
-  // CHECK-LABEL: test__bextr_u32
-  // CHECK: i32 @llvm.x86.bmi.bextr.32(i32 %{{.*}}, i32 %{{.*}})
+// CHECK-LABEL: test__bextr_u32
+// CHECK: i32 @llvm.x86.bmi.bextr.32(i32 %{{.*}}, i32 %{{.*}})
   return __bextr_u32(__X, __Y);
 }
 
 unsigned int test__blsi_u32(unsigned int __X) {
-  // CHECK-LABEL: test__blsi_u32
-  // CHECK: sub i32 0, %{{.*}}
-  // CHECK: and i32 %{{.*}}, %{{.*}}
+// CHECK-LABEL: test__blsi_u32
+// CHECK: sub i32 0, %{{.*}}
+// CHECK: and i32 %{{.*}}, %{{.*}}
   return __blsi_u32(__X);
 }
 
 unsigned int test__blsmsk_u32(unsigned int __X) {
-  // CHECK-LABEL: test__blsmsk_u32
-  // CHECK: sub i32 %{{.*}}, 1
-  // CHECK: xor i32 %{{.*}}, %{{.*}}
+// CHECK-LABEL: test__blsmsk_u32
+// CHECK: sub i32 %{{.*}}, 1
+// CHECK: xor i32 %{{.*}}, %{{.

[clang] 365f46e - [CodeGen][X86] Remove unused check-prefix in movdir tests

2020-10-30 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-10-30T16:23:08Z
New Revision: 365f46efebe09378af57628f38bfe55018451d17

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

LOG: [CodeGen][X86] Remove unused check-prefix in movdir tests

Added: 


Modified: 
clang/test/CodeGen/X86/builtin-movdir.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/builtin-movdir.c 
b/clang/test/CodeGen/X86/builtin-movdir.c
index e13cc776edd6..f1f104db87b4 100644
--- a/clang/test/CodeGen/X86/builtin-movdir.c
+++ b/clang/test/CodeGen/X86/builtin-movdir.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -ffreestanding -Wall -pedantic 
-fno-experimental-new-pass-manager -triple x86_64-unknown-unknown 
-target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | 
FileCheck %s --check-prefix=X86_64 --check-prefix=CHECK
-// RUN: %clang_cc1 -ffreestanding -Wall -pedantic 
-fno-experimental-new-pass-manager -triple i386-unknown-unknown -target-feature 
+movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s 
--check-prefix=X86 --check-prefix=CHECK
-// RUN: %clang_cc1 -ffreestanding -Wall -pedantic 
-fexperimental-new-pass-manager -triple x86_64-unknown-unknown -target-feature 
+movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s 
--check-prefix=X86_64 --check-prefix=CHECK
-// RUN: %clang_cc1 -ffreestanding -Wall -pedantic 
-fexperimental-new-pass-manager -triple i386-unknown-unknown -target-feature 
+movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s 
--check-prefix=X86 --check-prefix=CHECK
+// RUN: %clang_cc1 -ffreestanding -Wall -pedantic 
-fno-experimental-new-pass-manager -triple x86_64-unknown-unknown 
-target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,X86_64
+// RUN: %clang_cc1 -ffreestanding -Wall -pedantic 
-fno-experimental-new-pass-manager -triple i386-unknown-unknown -target-feature 
+movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK
+// RUN: %clang_cc1 -ffreestanding -Wall -pedantic 
-fexperimental-new-pass-manager -triple x86_64-unknown-unknown -target-feature 
+movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,X86_64
+// RUN: %clang_cc1 -ffreestanding -Wall -pedantic 
-fexperimental-new-pass-manager -triple i386-unknown-unknown -target-feature 
+movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK
 
 #include 
 #include 



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


[clang] 973317c - [CodeGen][X86] Remove unused check-prefix in constrained fma tests

2020-10-30 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-10-30T16:23:08Z
New Revision: 973317cc5e4612a85e39dc1ffb20423c96bc9db2

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

LOG: [CodeGen][X86] Remove unused check-prefix in constrained fma tests

Added: 


Modified: 
clang/test/CodeGen/X86/fma-builtins-constrained.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/fma-builtins-constrained.c 
b/clang/test/CodeGen/X86/fma-builtins-constrained.c
index e5c22ec8b80d..6d280a237432 100644
--- a/clang/test/CodeGen/X86/fma-builtins-constrained.c
+++ b/clang/test/CodeGen/X86/fma-builtins-constrained.c
@@ -1,8 +1,8 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu 
-target-feature +fma -O2 -emit-llvm -o - | FileCheck --check-prefix=COMMON 
--check-prefix=COMMONIR --check-prefix=UNCONSTRAINED %s
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu 
-target-feature +fma -ffp-exception-behavior=strict -O2 -emit-llvm -o - | 
FileCheck --check-prefix=COMMON --check-prefix=COMMONIR 
--check-prefix=CONSTRAINED %s
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu 
-target-feature +fma -O2 -S -o - | FileCheck --check-prefix=COMMON 
--check-prefix=CHECK-ASM --check-prefix=CHECK-ASM-UNCONSTRAINED %s
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu 
-target-feature +fma -O2 -ffp-exception-behavior=strict -S -o - | FileCheck 
--check-prefix=COMMON --check-prefix=CHECK-ASM 
--check-prefix=CHECK-ASM-CONSTRAINED %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu 
-target-feature +fma -O2 -emit-llvm -o - | FileCheck %s 
--check-prefixes=COMMON,COMMONIR,UNCONSTRAINED
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu 
-target-feature +fma -ffp-exception-behavior=strict -O2 -emit-llvm -o - | 
FileCheck %s --check-prefixes=COMMON,COMMONIR,CONSTRAINED
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu 
-target-feature +fma -O2 -S -o - | FileCheck %s 
--check-prefixes=COMMON,CHECK-ASM
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu 
-target-feature +fma -O2 -ffp-exception-behavior=strict -S -o - | FileCheck %s 
--check-prefixes=COMMON,CHECK-ASM
 
 #include 
 



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


[PATCH] D88859: APINotes: add APINotesYAMLCompiler

2020-10-30 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/include/clang/APINotes/Types.h:25
+/// auditing.
+enum class EnumExtensibilityKind {
+  None,

compnerd wrote:
> martong wrote:
> > compnerd wrote:
> > > martong wrote:
> > > > compnerd wrote:
> > > > > martong wrote:
> > > > > > This seems a bit redundant to `Attrs.td`. I'd prefer to have the 
> > > > > > structure of an attribute defined only in one place. Why can't we 
> > > > > > directly reuse the types in the generated `Attrs.inc`? In this case
> > > > > > ```
> > > > > > class EnumExtensibilityAttr : public InheritableAttr {
> > > > > > public:
> > > > > >   enum Kind {
> > > > > > Closed,
> > > > > > Open
> > > > > >   };
> > > > > > ```
> > > > > > could perfectly fit, wouldn't it?
> > > > > The none-case here is not the same as missing - it tracks the 
> > > > > explicitly audited case.  I suppose we can change the internal enum 
> > > > > case from `None` to `Audited` if you like.
> > > > I am not sure I can follow. Could you please elaborate what is an 
> > > > "explicit y audited" case?
> > > > https://clang.llvm.org/docs/AttributeReference.html#enum-extensibility 
> > > > mentions only open/closed ...
> > > There are three states consider:
> > > 
> > > ```
> > > enum Unaudited {
> > > };
> > > enum __attribute__((__enum_extensibility__(open))) Open {
> > > };
> > > enum __attribute__((__enum_extensibility__(closed))) Closed {
> > > };
> > > ```
> > > 
> > > The optionality of the value indicates whether the value is present or 
> > > not in the APINotes, not the tri-state nature of the attribute.
> > Ok. Thanks for the explanation.
> > 
> > But how could we describe then `flag_enum`? As a possible extension in the 
> > future (not in this patch).
> > E.g.:
> > ```
> > enum __attribute__((enum_extensibility(open),flag_enum)) OpenFlagEnum {
> >   D0 = 1 << 0, D1 = 1 << 1
> > };
> > ```
> > 
> > Or here
> > ```
> > enum __attribute__((flag_enum)) Foo;
> > ```
> > should `Foo` have an `Audited` or `None` `Kind` here? 
> > 
> > 
> > If we were to add support to `flag_enum` would you create a new enum class 
> > for that here?
> > 
> > Note that I am asking all these questions because I am planning to extend 
> > and add more attributes in the future once the whole APINotes stuff is 
> > landed.
> The questions are reasonable - and we should understand what is missing and 
> what can be done and what cannot be done.
> 
> I think that the use of the metadata is extremely important.  The question 
> is, are there any users who care about recovering that information?  IMO, we 
> should try to represent the input as faithfully as possible, even if that 
> means that we need to replicate the enumerations.  However, if the consumers 
> do not care about the inferred state vs the written state, I don't think that 
> it is an immediate concern if we cannot recover that from the representation, 
> we can simplify and extend as and when needed, especially when we have the 
> feature merged (I think that it is easier once merged only because this is a 
> large feature, and there is a large user base that is using this, which 
> complicates things.  Really, this functionality should have been merged a 
> long time ago, but that is both my own opinion and past), and hopefully in 
> many cases we can do it during review time.
> 
> The tricky bit to remember that there is an additional state that is 
> implicitly being added here, and optionality should reference the contents of 
> the APINotes, not the state in the declaration that is being mutated.
> 
> Is there a good place to write this down? I am willing to add comments 
> explaining this so that the next person (ha, no, not the next person, but me, 
> because I *will* forget) is not tripped up on this nuance.
Thanks for clarifying this. It was not clear for me that these types were to 
represent the YAML file contents. It makes much more sense now.

> Is there a good place to write this down?
I think a file comment right after the license could do it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88859

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


[PATCH] D90336: [Sema] Diagnose annotating `if constexpr` with a likelihood attribute

2020-10-30 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 aside from the point @rjmccall made about the note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90336

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


[PATCH] D89899: [CodeGen] Implement [[likely]] and [[unlikely]] for the iteration statements

2020-10-30 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 aside from a request about the note. Thank you for this!




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3161
+   InGroup;
+def note_attribute_has_no_effect_here : Note<
+  "annotating the %select{infinite loop}0 here">;

As @rjmccall pointed out in the other review, this isn't really a generic note. 
I'd mildly recommend renaming the note and removing the select.


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

https://reviews.llvm.org/D89899

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


[libunwind] 1d7786d - [libunwind] Support DW_CFA_remember/restore_state without heap allocation.

2020-10-30 Thread Daniel Kiss via cfe-commits

Author: Daniel Kiss
Date: 2020-10-30T17:45:20+01:00
New Revision: 1d7786d45f48b4793baf4e4b903c4476f56ffc94

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

LOG: [libunwind] Support DW_CFA_remember/restore_state without heap allocation.

This patch just reorganises the code to make possible to use alloca
instead of malloc. This makes possible to use 
`.cfi_remember_state`/`.cfi_restore_state` on
platforms without heap allocation.
Also it will be safe to backtrace/unwind faults related to the allocator behind 
malloc.
`_LIBUNWIND_REMEMBER_HEAP_ALLOC ` option reenables the heap usage for 
`.cfi_remember_state`/`.cfi_restore_state`.
Define _LIBUNWIND_REMEMBER_STACK_ALLOC to force stack allocation.

Reviewed By: #libunwind, mstorsjo

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

Added: 


Modified: 
libunwind/src/DwarfParser.hpp
libunwind/src/config.h

Removed: 




diff  --git a/libunwind/src/DwarfParser.hpp b/libunwind/src/DwarfParser.hpp
index 86c0522afd3f..4bfd0451ed5a 100644
--- a/libunwind/src/DwarfParser.hpp
+++ b/libunwind/src/DwarfParser.hpp
@@ -135,6 +135,24 @@ class CFI_Parser {
 PrologInfo info;
   };
 
+  struct RememberStack {
+PrologInfoStackEntry *entry;
+RememberStack() : entry(nullptr) {}
+~RememberStack() {
+#if defined(_LIBUNWIND_REMEMBER_CLEANUP_NEEDED)
+  // Clean up rememberStack. Even in the case where every
+  // DW_CFA_remember_state is paired with a DW_CFA_restore_state,
+  // parseInstructions can skip restore opcodes if it reaches the target PC
+  // and stops interpreting, so we have to make sure we don't leak memory.
+  while (entry) {
+PrologInfoStackEntry *next = entry->next;
+_LIBUNWIND_REMEMBER_FREE(entry);
+entry = next;
+  }
+#endif
+}
+  };
+
   static bool findFDE(A &addressSpace, pint_t pc, pint_t ehSectionStart,
   uintptr_t sectionLength, pint_t fdeHint, FDE_Info 
*fdeInfo,
   CIE_Info *cieInfo);
@@ -145,13 +163,6 @@ class CFI_Parser {
int arch, PrologInfo *results);
 
   static const char *parseCIE(A &addressSpace, pint_t cie, CIE_Info *cieInfo);
-
-private:
-  static bool parseInstructions(A &addressSpace, pint_t instructions,
-pint_t instructionsEnd, const CIE_Info 
&cieInfo,
-pint_t pcoffset,
-PrologInfoStackEntry *&rememberStack, int arch,
-PrologInfo *results);
 };
 
 /// Parse a FDE into a CIE_Info and an FDE_Info
@@ -394,418 +405,415 @@ bool CFI_Parser::parseFDEInstructions(A 
&addressSpace,
  const FDE_Info &fdeInfo,
  const CIE_Info &cieInfo, pint_t 
upToPC,
  int arch, PrologInfo *results) {
-  PrologInfoStackEntry *rememberStack = NULL;
-
-  // parse CIE then FDE instructions
-  bool returnValue =
-  parseInstructions(addressSpace, cieInfo.cieInstructions,
-cieInfo.cieStart + cieInfo.cieLength, cieInfo,
-(pint_t)(-1), rememberStack, arch, results) &&
-  parseInstructions(addressSpace, fdeInfo.fdeInstructions,
-fdeInfo.fdeStart + fdeInfo.fdeLength, cieInfo,
-upToPC - fdeInfo.pcStart, rememberStack, arch, 
results);
-
-#if !defined(_LIBUNWIND_NO_HEAP)
-  // Clean up rememberStack. Even in the case where every DW_CFA_remember_state
-  // is paired with a DW_CFA_restore_state, parseInstructions can skip restore
-  // opcodes if it reaches the target PC and stops interpreting, so we have to
-  // make sure we don't leak memory.
-  while (rememberStack) {
-PrologInfoStackEntry *next = rememberStack->next;
-free(rememberStack);
-rememberStack = next;
-  }
-#endif
-
-  return returnValue;
-}
+  // Alloca is used for the allocation of the rememberStack entries. It removes
+  // the dependency on new/malloc but the below for loop can not be refactored
+  // into functions. Entry could be saved during the processing of a CIE and
+  // restored by an FDE.
+  RememberStack rememberStack;
+
+  struct ParseInfo {
+pint_t instructions;
+pint_t instructionsEnd;
+pint_t pcoffset;
+  };
 
-/// "run" the DWARF instructions
-template 
-bool CFI_Parser::parseInstructions(A &addressSpace, pint_t instructions,
-  pint_t instructionsEnd,
-  const CIE_Info &cieInfo, pint_t pcoffset,
-  PrologInfoStackEntry *&rememberStack,
-  int arch, PrologInfo *results) {
-  pint_t p = instructions;
-  

[PATCH] D90447: [AMDGPU] Add gfx1033 target

2020-10-30 Thread Tim Renouf via Phabricator via cfe-commits
tpr updated this revision to Diff 301931.
tpr added a comment.

V2: Update ELFObjectFile.cpp and elf-header-flags-mach.yaml.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90447

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/test/CodeGenOpenCL/amdgpu-features.cl
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/amdgpu-mcpu.cl
  llvm/docs/AMDGPUUsage.rst
  llvm/include/llvm/BinaryFormat/ELF.h
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Object/ELFObjectFile.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/lib/Support/TargetParser.cpp
  llvm/lib/Target/AMDGPU/GCNProcessors.td
  llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
  llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll
  llvm/test/CodeGen/AMDGPU/hsa-note-no-func.ll
  llvm/test/MC/AMDGPU/gfx1011_dlops.s
  llvm/test/MC/AMDGPU/gfx1030_err.s
  llvm/test/MC/AMDGPU/gfx1030_new.s
  llvm/test/MC/Disassembler/AMDGPU/gfx1011_dasm_dlops.txt
  llvm/test/MC/Disassembler/AMDGPU/gfx1030_dasm_new.txt
  llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
  llvm/tools/llvm-readobj/ELFDumper.cpp

Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1786,6 +1786,7 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1030),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1031),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1032),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1033),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_XNACK),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_SRAM_ECC)
 };
Index: llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
===
--- llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
+++ llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
@@ -170,6 +170,10 @@
 # RUN: llvm-readobj -s -file-headers %t.o.43 | FileCheck --check-prefixes=ELF-ALL,ELF-GFX90C %s
 # RUN: obj2yaml %t.o.43 | FileCheck --check-prefixes=YAML-GFX90C %s
 
+# RUN: yaml2obj --docnum=44 %s > %t.o.44
+# RUN: llvm-readobj -s -file-headers %t.o.44 | FileCheck --check-prefixes=ELF-ALL,ELF-GFX1033 %s
+# RUN: obj2yaml %t.o.44 | FileCheck --check-prefixes=YAML-GFX1033 %s
+
 # ELF-ALL: Flags [
 # ELF-R600:  EF_AMDGPU_MACH_R600_R600 (0x1)
 # ELF-R630:  EF_AMDGPU_MACH_R600_R630 (0x2)
@@ -214,6 +218,7 @@
 # ELF-GFX1030:   EF_AMDGPU_MACH_AMDGCN_GFX1030 (0x36)
 # ELF-GFX1031:   EF_AMDGPU_MACH_AMDGCN_GFX1031 (0x37)
 # ELF-GFX1032:   EF_AMDGPU_MACH_AMDGCN_GFX1032 (0x38)
+# ELF-GFX1033:   EF_AMDGPU_MACH_AMDGCN_GFX1033 (0x39)
 # ELF-ALL: ]
 
 # YAML-R600:Flags: [ EF_AMDGPU_MACH_R600_R600 ]
@@ -259,6 +264,7 @@
 # YAML-GFX1030: Flags: [ EF_AMDGPU_MACH_AMDGCN_GFX1030 ]
 # YAML-GFX1031: Flags: [ EF_AMDGPU_MACH_AMDGCN_GFX1031 ]
 # YAML-GFX1032: Flags: [ EF_AMDGPU_MACH_AMDGCN_GFX1032 ]
+# YAML-GFX1033: Flags: [ EF_AMDGPU_MACH_AMDGCN_GFX1033 ]
 
 # Doc1
 --- !ELF
@@ -732,3 +738,14 @@
   Machine: EM_AMDGPU
   Flags:   [ EF_AMDGPU_MACH_AMDGCN_GFX90C ]
 ...
+
+# Doc44
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  OSABI:   ELFOSABI_NONE
+  Type:ET_REL
+  Machine: EM_AMDGPU
+  Flags:   [ EF_AMDGPU_MACH_AMDGCN_GFX1033 ]
+...
Index: llvm/test/MC/Disassembler/AMDGPU/gfx1030_dasm_new.txt
===
--- llvm/test/MC/Disassembler/AMDGPU/gfx1030_dasm_new.txt
+++ llvm/test/MC/Disassembler/AMDGPU/gfx1030_dasm_new.txt
@@ -1,6 +1,7 @@
 # RUN: llvm-mc -arch=amdgcn -mcpu=gfx1030 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
 # RUN: llvm-mc -arch=amdgcn -mcpu=gfx1031 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
 # RUN: llvm-mc -arch=amdgcn -mcpu=gfx1032 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
+# RUN: llvm-mc -arch=amdgcn -mcpu=gfx1033 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
 
 # GFX10: global_load_dword_addtid v1, s[2:3] offset:16
 0x10,0x80,0x58,0xdc,0x00,0x00,0x02,0x01
Index: llvm/test/MC/Disassembler/AMDGPU/gfx1011_dasm_dlops.txt
===
--- llvm/test/MC/Disassembler/AMDGPU/gfx1011_dasm_dlops.txt
+++ llvm/test/MC/Disassembler/AMDGPU/gfx1011_dasm_dlops.txt
@@ -1,5 +1,9 @@
 # RUN: llvm-mc -arch=amdgcn -mcpu=gfx1011 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
 # RUN: llvm-mc -arch=amdgcn -mcpu=gfx1012 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
+# RUN: llvm-mc -arch=amdgcn -mcpu=gfx1030 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
+# RUN: llvm-mc -arch=amdgcn -mcpu=gfx1031 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX10 %s
+# RUN: llvm-mc -arch=amdgcn -mcpu=gfx1032 -disassemble -show-encoding < %s | FileCheck -check-prefix=GFX1

[PATCH] D90121: clang-format: Add a consumer to diagnostics engine

2020-10-30 Thread Kirill Dmitrenko via Phabricator via cfe-commits
dmikis added a comment.

@thakis I've got test working, here's the code:

  // RUN: chmod +w %t.dir || true
  // RUN: rm -rf %t.dir
  // RUN: mkdir %t.dir
  // RUN: cp %s %t.dir/read-only.cpp
  // RUN: chmod -w %t.dir
  // RUN: clang-format -style=LLVM -i %t.dir/read-only.cpp || test $? == 1
  
  int main() {
  return 0; }

There's a difference in how Linux and Windows behaves. Linux unlinks read-only 
file without any errors as long as directory files resides in is writable. 
That's why I run chmod on directory, not the file.

I can't check it on Windows. It seems tests aren't designed to run on windows 
at all because of it's obvious reliance on unix-like environment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90121

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


[PATCH] D89158: [NewPM] Run callbacks added via registerPipelineStartEPCallback under -O0

2020-10-30 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 301937.
aeubanks retitled this revision from "[NewPM] Run callbacks added via 
registerPipelineStartEPCallback under -O0  " to "[NewPM] Run callbacks added 
via registerPipelineStartEPCallback under -O0".
aeubanks added a comment.

revert back to running all callbacks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89158

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/bpf-O0.c
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/test/CodeGen/BPF/optnone-2.ll
  llvm/test/Other/new-pm-O0-ep-callbacks.ll

Index: llvm/test/Other/new-pm-O0-ep-callbacks.ll
===
--- /dev/null
+++ llvm/test/Other/new-pm-O0-ep-callbacks.ll
@@ -0,0 +1,24 @@
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-late-loop-optimizations=no-op-loop -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-loop-optimizer-end=no-op-loop -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-scalar-optimizer-late=no-op-function -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-cgscc-optimizer-late=no-op-cgscc -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-vectorizer-start=no-op-function -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-pipeline-start=no-op-module -passes='default' 2>&1 < %s | FileCheck %s
+; RUN: opt -disable-output -debug-pass-manager -passes-ep-optimizer-last=no-op-function -passes='default' 2>&1 < %s | FileCheck %s
+
+; CHECK: Running pass: NoOp
+
+declare void @bar() local_unnamed_addr
+
+define void @foo(i32 %n) local_unnamed_addr {
+entry:
+  br label %loop
+loop:
+  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
+  %iv.next = add i32 %iv, 1
+  tail call void @bar()
+  %cmp = icmp eq i32 %iv, %n
+  br i1 %cmp, label %exit, label %loop
+exit:
+  ret void
+}
Index: llvm/test/CodeGen/BPF/optnone-2.ll
===
--- llvm/test/CodeGen/BPF/optnone-2.ll
+++ llvm/test/CodeGen/BPF/optnone-2.ll
@@ -1,5 +1,5 @@
 ; RUN: opt < %s -passes='default' | llc -march=bpfel -filetype=asm -o /dev/null -
-; TODO: add -O0 once that's supported
+; RUN: opt < %s -passes='default' | llc -march=bpfel -filetype=asm -o /dev/null -
 
 ; IR generated by
 ; $ cat /tmp/a.c
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -1654,6 +1654,49 @@
   return MPM;
 }
 
+void PassBuilder::runRegisteredEPCallbacks(ModulePassManager &MPM,
+   OptimizationLevel Level,
+   bool DebugLogging) {
+  assert(Level == OptimizationLevel::O0 &&
+ "runRegisteredEPCallbacks should only be used with O0");
+  for (auto &C : PipelineStartEPCallbacks)
+C(MPM);
+  if (!LateLoopOptimizationsEPCallbacks.empty()) {
+LoopPassManager LPM(DebugLogging);
+for (auto &C : LateLoopOptimizationsEPCallbacks)
+  C(LPM, Level);
+MPM.addPass(createModuleToFunctionPassAdaptor(
+createFunctionToLoopPassAdaptor(std::move(LPM;
+  }
+  if (!LoopOptimizerEndEPCallbacks.empty()) {
+LoopPassManager LPM(DebugLogging);
+for (auto &C : LoopOptimizerEndEPCallbacks)
+  C(LPM, Level);
+MPM.addPass(createModuleToFunctionPassAdaptor(
+createFunctionToLoopPassAdaptor(std::move(LPM;
+  }
+  if (!ScalarOptimizerLateEPCallbacks.empty()) {
+FunctionPassManager FPM(DebugLogging);
+for (auto &C : ScalarOptimizerLateEPCallbacks)
+  C(FPM, Level);
+MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
+  }
+  if (!CGSCCOptimizerLateEPCallbacks.empty()) {
+CGSCCPassManager CGPM(DebugLogging);
+for (auto &C : CGSCCOptimizerLateEPCallbacks)
+  C(CGPM, Level);
+MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
+  }
+  if (!VectorizerStartEPCallbacks.empty()) {
+FunctionPassManager FPM(DebugLogging);
+for (auto &C : VectorizerStartEPCallbacks)
+  C(FPM, Level);
+MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
+  }
+  for (auto &C : OptimizerLastEPCallbacks)
+C(MPM, Level);
+}
+
 AAManager PassBuilder::buildDefaultAAPipeline() {
   AAManager AA;
 
@@ -2240,6 +2283,8 @@
 MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass()));
   }
 
+  runRegisteredEPCallbacks(MPM, L, DebugLogging);
+
   // Do nothing else at all!
   return Error::success();
 }
Index: llvm/include/llvm/Passes/PassBuilder.h
===
--- llvm/include/llvm

[PATCH] D89799: [clang][driver] Rename DriverOption as NoXarchOption (NFC)

2020-10-30 Thread Andrzej Warzynski 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 rGe5699b8ff1b6: [clang][driver] Rename DriverOption as 
NoXarchOption (NFC) (authored by awarzynski).

Changed prior to commit:
  https://reviews.llvm.org/D89799?vs=301414&id=301938#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89799

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChain.cpp

Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -1223,15 +1223,18 @@
   //
   // We also want to disallow any options which would alter the
   // driver behavior; that isn't going to work in our model. We
-  // use isDriverOption() as an approximation, although things
-  // like -O4 are going to slip through.
+  // use options::NoXarchOption to control this.
   if (!XarchArg || Index > Prev + 1) {
 getDriver().Diag(diag::err_drv_invalid_Xarch_argument_with_args)
 << A->getAsString(Args);
 return;
-  } else if (XarchArg->getOption().hasFlag(options::DriverOption)) {
-getDriver().Diag(diag::err_drv_invalid_Xarch_argument_isdriver)
-<< A->getAsString(Args);
+  } else if (XarchArg->getOption().hasFlag(options::NoXarchOption)) {
+auto &Diags = getDriver().getDiags();
+unsigned DiagID =
+Diags.getCustomDiagID(DiagnosticsEngine::Error,
+  "invalid Xarch argument: '%0', not all driver "
+  "options can be forwared via Xarch argument");
+Diags.Report(DiagID) << A->getAsString(Args);
 return;
   }
   XarchArg->setBaseArg(A);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -16,9 +16,9 @@
 /
 // Flags
 
-// DriverOption - The option is a "driver" option, and should not be forwarded
-// to other tools.
-def DriverOption : OptionFlag;
+// The option is a "driver"-only option, and should not be forwarded to other
+// tools via `-Xarch` options.
+def NoXarchOption : OptionFlag;
 
 // LinkerInput - The option is a linker input.
 def LinkerInput : OptionFlag;
@@ -294,19 +294,19 @@
   Group, HelpText<"DEBUG/DEVELOPMENT OPTIONS">;
 
 class InternalDriverOpt : Group,
-  Flags<[DriverOption, HelpHidden]>;
+  Flags<[NoXarchOption, HelpHidden]>;
 def driver_mode : Joined<["--"], "driver-mode=">, Group,
-  Flags<[CoreOption, DriverOption, HelpHidden]>,
+  Flags<[CoreOption, NoXarchOption, HelpHidden]>,
   HelpText<"Set the driver mode to either 'gcc', 'g++', 'cpp', or 'cl'">;
 def rsp_quoting : Joined<["--"], "rsp-quoting=">, Group,
-  Flags<[CoreOption, DriverOption, HelpHidden]>,
+  Flags<[CoreOption, NoXarchOption, HelpHidden]>,
   HelpText<"Set the rsp quoting to either 'posix', or 'windows'">;
 def ccc_gcc_name : Separate<["-"], "ccc-gcc-name">, InternalDriverOpt,
   HelpText<"Name for native GCC compiler">,
   MetaVarName<"">;
 
 class InternalDebugOpt : Group,
-  Flags<[DriverOption, HelpHidden, CoreOption]>;
+  Flags<[NoXarchOption, HelpHidden, CoreOption]>;
 def ccc_install_dir : Separate<["-"], "ccc-install-dir">, InternalDebugOpt,
   HelpText<"Simulate installation in the given directory">;
 def ccc_print_phases : Flag<["-"], "ccc-print-phases">, InternalDebugOpt,
@@ -330,7 +330,7 @@
 def gen_cdb_fragment_path: Separate<["-"], "gen-cdb-fragment-path">, InternalDebugOpt,
   HelpText<"Emit a compilation database fragment to the specified directory">;
 
-def _migrate : Flag<["--"], "migrate">, Flags<[DriverOption]>,
+def _migrate : Flag<["--"], "migrate">, Flags<[NoXarchOption]>,
   HelpText<"Run the migrator">;
 def ccc_objcmt_migrate : Separate<["-"], "ccc-objcmt-migrate">,
   InternalDriverOpt,
@@ -377,10 +377,10 @@
 
 // Standard Options
 
-def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[DriverOption, CoreOption]>,
+def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[NoXarchOption, CoreOption]>,
 HelpText<"Print (but do not run) the commands to run for this compilation">;
 def _DASH_DASH : Option<["--"], "", KIND_REMAINING_ARGS>,
-Flags<[DriverOption, CoreOption]>;
+Flags<[NoXarchOption, CoreOption]>;
 def A : JoinedOrSeparate<["-"], "A">, Flags<[RenderJoined]>, Group;
 def B : JoinedOrSeparate<["-"], "B">, MetaVarName<"">,
 HelpText<"Add  to search path for binaries and object files used implicitly">;
@@ -391,14 +391,14 @@
 def D : JoinedOrSeparate<["-"], "D">, Group,
 Flags<[CC1Option]>, MetaVarName<"=">,
 HelpText<"Define  to  (or 1 if  omitted)">;
-def E : Flag<["-"], "E">, Flags<[DriverOption,CC1Option]>, Group,
+def E : Flag<["-"]

[clang] e5699b8 - [clang][driver] Rename DriverOption as NoXarchOption (NFC)

2020-10-30 Thread Andrzej Warzynski via cfe-commits

Author: Andrzej Warzynski
Date: 2020-10-30T17:00:06Z
New Revision: e5699b8ff1b6ea68e77dffb037e1c5d612131580

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

LOG: [clang][driver] Rename DriverOption as NoXarchOption (NFC)

As discussed in [1], ClangFlags::DriverOption is currently only used to
mark options that should not be forwarded to other tools via `-Xarch`
options. This patch renames this flag accordingly and updates the
corresponding driver diagnostic.

A comment in ToolChain::TranslateXarchArgs is also updated to reflect
the change. The original comment referred to isDriverOption(), which is
no longer available.

[1] http://lists.llvm.org/pipermail/cfe-dev/2020-October/066953.html

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Driver.h
clang/include/clang/Driver/Options.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChain.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index a45d9e8ee788..43ee4968dafd 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -121,8 +121,6 @@ def err_drv_missing_argument : Error<
   "argument to '%0' is missing (expected %1 value%s1)">;
 def err_drv_invalid_Xarch_argument_with_args : Error<
   "invalid Xarch argument: '%0', options requiring arguments are unsupported">;
-def err_drv_invalid_Xarch_argument_isdriver : Error<
-  "invalid Xarch argument: '%0', cannot change driver behavior inside Xarch 
argument">;
 def err_drv_Xopenmp_target_missing_triple : Error<
   "cannot deduce implicit triple value for -Xopenmp-target, specify triple 
using -Xopenmp-target=">;
 def err_drv_invalid_Xopenmp_target_with_args : Error<

diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index 7a476199ff7f..74a9cf3dab81 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -314,7 +314,7 @@ class Driver {
 
   const llvm::opt::OptTable &getOpts() const { return getDriverOptTable(); }
 
-  const DiagnosticsEngine &getDiags() const { return Diags; }
+  DiagnosticsEngine &getDiags() const { return Diags; }
 
   llvm::vfs::FileSystem &getVFS() const { return *VFS; }
 

diff  --git a/clang/include/clang/Driver/Options.h 
b/clang/include/clang/Driver/Options.h
index ae188cec93c2..b641f64c3116 100644
--- a/clang/include/clang/Driver/Options.h
+++ b/clang/include/clang/Driver/Options.h
@@ -24,7 +24,7 @@ namespace options {
 /// Flags specifically for clang options.  Must not overlap with
 /// llvm::opt::DriverFlag.
 enum ClangFlags {
-  DriverOption = (1 << 4),
+  NoXarchOption = (1 << 4),
   LinkerInput = (1 << 5),
   NoArgumentUnused = (1 << 6),
   Unsupported = (1 << 7),

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 09996af6f91f..069e5805d999 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -16,9 +16,9 @@ include "llvm/Option/OptParser.td"
 /
 // Flags
 
-// DriverOption - The option is a "driver" option, and should not be forwarded
-// to other tools.
-def DriverOption : OptionFlag;
+// The option is a "driver"-only option, and should not be forwarded to other
+// tools via `-Xarch` options.
+def NoXarchOption : OptionFlag;
 
 // LinkerInput - The option is a linker input.
 def LinkerInput : OptionFlag;
@@ -294,19 +294,19 @@ def internal_debug_Group :
   Group, HelpText<"DEBUG/DEVELOPMENT OPTIONS">;
 
 class InternalDriverOpt : Group,
-  Flags<[DriverOption, HelpHidden]>;
+  Flags<[NoXarchOption, HelpHidden]>;
 def driver_mode : Joined<["--"], "driver-mode=">, Group,
-  Flags<[CoreOption, DriverOption, HelpHidden]>,
+  Flags<[CoreOption, NoXarchOption, HelpHidden]>,
   HelpText<"Set the driver mode to either 'gcc', 'g++', 'cpp', or 'cl'">;
 def rsp_quoting : Joined<["--"], "rsp-quoting=">, Group,
-  Flags<[CoreOption, DriverOption, HelpHidden]>,
+  Flags<[CoreOption, NoXarchOption, HelpHidden]>,
   HelpText<"Set the rsp quoting to either 'posix', or 'windows'">;
 def ccc_gcc_name : Separate<["-"], "ccc-gcc-name">, InternalDriverOpt,
   HelpText<"Name for native GCC compiler">,
   MetaVarName<"">;
 
 class InternalDebugOpt : Group,
-  Flags<[DriverOption, HelpHidden, CoreOption]>;
+  Flags<[NoXarchOption, HelpHidden, CoreOption]>;
 def ccc_install_dir : Separate<["-"], "ccc-install-dir">, InternalDebugOpt,
   HelpText<"Simulate installation in the given directory">;
 def ccc_print_phases : Flag<["-"], "ccc-print-phases">, InternalDebugOpt,
@@ -330,7 +330,7 @@ def gen

[clang] 2e31727 - [NFC] Clean up PassBuilder

2020-10-30 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2020-10-30T10:03:59-07:00
New Revision: 2e31727a884affa11f2955ddfa40590715f144df

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

LOG: [NFC] Clean up PassBuilder

Make DebugLogging a member variable so that users of PassBuilder don't
need to pass it around so much.

Move call to TargetMachine::registerPassBuilderCallbacks() within
PassBuilder so users don't need to remember to call it.

Reviewed By: asbirlea

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/Passes/PassBuilder.h
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def
llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
llvm/tools/opt/NewPMDriver.cpp
llvm/unittests/IR/PassBuilderCallbacksTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 918411b818be..e693d6d05464 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1203,7 +1203,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI(CodeGenOpts.DebugPassManager);
   SI.registerCallbacks(PIC);
-  PassBuilder PB(TM.get(), PTO, PGOOpt, &PIC);
+  PassBuilder PB(CodeGenOpts.DebugPassManager, TM.get(), PTO, PGOOpt, &PIC);
 
   // Attempt to load pass plugins and register their callbacks with PB.
   for (auto &PluginFN : CodeGenOpts.PassPlugins) {
@@ -1241,9 +1241,6 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   PB.registerLoopAnalyses(LAM);
   PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
 
-  if (TM)
-TM->registerPassBuilderCallbacks(PB, CodeGenOpts.DebugPassManager);
-
   ModulePassManager MPM(CodeGenOpts.DebugPassManager);
 
   if (!CodeGenOpts.DisableLLVMPasses) {
@@ -1280,7 +1277,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   if (PGOOpt && (PGOOpt->Action == PGOOptions::IRInstr ||
  PGOOpt->Action == PGOOptions::IRUse))
 PB.addPGOInstrPassesForO0(
-MPM, CodeGenOpts.DebugPassManager,
+MPM,
 /* RunProfileGen */ (PGOOpt->Action == PGOOptions::IRInstr),
 /* IsCS */ false, PGOOpt->ProfileFile,
 PGOOpt->ProfileRemappingFile);
@@ -1407,18 +1404,15 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 });
 
   if (IsThinLTO) {
-MPM = PB.buildThinLTOPreLinkDefaultPipeline(
-Level, CodeGenOpts.DebugPassManager);
+MPM = PB.buildThinLTOPreLinkDefaultPipeline(Level);
 MPM.addPass(CanonicalizeAliasesPass());
 MPM.addPass(NameAnonGlobalPass());
   } else if (IsLTO) {
-MPM = PB.buildLTOPreLinkDefaultPipeline(Level,
-CodeGenOpts.DebugPassManager);
+MPM = PB.buildLTOPreLinkDefaultPipeline(Level);
 MPM.addPass(CanonicalizeAliasesPass());
 MPM.addPass(NameAnonGlobalPass());
   } else {
-MPM = PB.buildPerModuleDefaultPipeline(Level,
-   CodeGenOpts.DebugPassManager);
+MPM = PB.buildPerModuleDefaultPipeline(Level);
   }
 }
 

diff  --git a/llvm/include/llvm/Passes/PassBuilder.h 
b/llvm/include/llvm/Passes/PassBuilder.h
index aef9d9b6bb4c..356b70d368bb 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -118,6 +118,7 @@ class PipelineTuningOptions {
 /// of the built-in passes, and those may reference these members during
 /// construction.
 class PassBuilder {
+  bool DebugLogging;
   TargetMachine *TM;
   PipelineTuningOptions PTO;
   Optional PGOOpt;
@@ -259,11 +260,10 @@ class PassBuilder {
 unsigned getSizeLevel() const { return SizeLevel; }
   };
 
-  explicit PassBuilder(TargetMachine *TM = nullptr,
+  explicit PassBuilder(bool DebugLogging = false, TargetMachine *TM = nullptr,
PipelineTuningOptions PTO = PipelineTuningOptions(),
Optional PGOOpt = None,
-   PassInstrumentationCallbacks *PIC = nullptr)
-  : TM(TM), PTO(PTO), PGOOpt(PGOOpt), PIC(PIC) {}
+   PassInstrumentationCallbacks *PIC = nullptr);
 
   /// Cross register the analysis managers through their proxies.
   ///
@@ -321,8 +321,7 @@ class PassBuilder {
   /// \p Phase indicates the current ThinLTO phase.
   FunctionPassManager
   buildFunctionSimplificationPipeline(OptimizationLevel Level,
-  ThinLTOPhase Phase,
-  bool DebugLogging = false);
+  ThinLTOPhase Phase);
 
   /// Construct the 

[PATCH] D90437: [NFC] Clean up PassBuilder

2020-10-30 Thread Arthur Eubanks 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 rG2e31727a884a: [NFC] Clean up PassBuilder (authored by 
aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90437

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
  llvm/tools/opt/NewPMDriver.cpp
  llvm/unittests/IR/PassBuilderCallbacksTest.cpp

Index: llvm/unittests/IR/PassBuilderCallbacksTest.cpp
===
--- llvm/unittests/IR/PassBuilderCallbacksTest.cpp
+++ llvm/unittests/IR/PassBuilderCallbacksTest.cpp
@@ -439,8 +439,8 @@
   "exit:\n"
   "  ret void\n"
   "}\n")),
-CallbacksHandle(),
-PB(nullptr, PipelineTuningOptions(), None, &CallbacksHandle.Callbacks),
+CallbacksHandle(), PB(false, nullptr, PipelineTuningOptions(), None,
+  &CallbacksHandle.Callbacks),
 PM(true), LAM(true), FAM(true), CGAM(true), AM(true) {
 
 EXPECT_TRUE(&CallbacksHandle.Callbacks ==
Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -140,68 +140,55 @@
 
 /// If one of the EPPipeline command line options was given, register callbacks
 /// for parsing and inserting the given pipeline
-static void registerEPCallbacks(PassBuilder &PB, bool DebugLogging) {
+static void registerEPCallbacks(PassBuilder &PB) {
   if (tryParsePipelineText(PB, PeepholeEPPipeline))
 PB.registerPeepholeEPCallback(
-[&PB, DebugLogging](FunctionPassManager &PM,
-PassBuilder::OptimizationLevel Level) {
+[&PB](FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
   ExitOnError Err("Unable to parse PeepholeEP pipeline: ");
-  Err(PB.parsePassPipeline(PM, PeepholeEPPipeline, DebugLogging));
+  Err(PB.parsePassPipeline(PM, PeepholeEPPipeline));
 });
   if (tryParsePipelineText(PB,
 LateLoopOptimizationsEPPipeline))
 PB.registerLateLoopOptimizationsEPCallback(
-[&PB, DebugLogging](LoopPassManager &PM,
-PassBuilder::OptimizationLevel Level) {
+[&PB](LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
   ExitOnError Err("Unable to parse LateLoopOptimizationsEP pipeline: ");
-  Err(PB.parsePassPipeline(PM, LateLoopOptimizationsEPPipeline,
-   DebugLogging));
+  Err(PB.parsePassPipeline(PM, LateLoopOptimizationsEPPipeline));
 });
   if (tryParsePipelineText(PB, LoopOptimizerEndEPPipeline))
 PB.registerLoopOptimizerEndEPCallback(
-[&PB, DebugLogging](LoopPassManager &PM,
-PassBuilder::OptimizationLevel Level) {
+[&PB](LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
   ExitOnError Err("Unable to parse LoopOptimizerEndEP pipeline: ");
-  Err(PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline,
-   DebugLogging));
+  Err(PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline));
 });
   if (tryParsePipelineText(PB,
 ScalarOptimizerLateEPPipeline))
 PB.registerScalarOptimizerLateEPCallback(
-[&PB, DebugLogging](FunctionPassManager &PM,
-PassBuilder::OptimizationLevel Level) {
+[&PB](FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
   ExitOnError Err("Unable to parse ScalarOptimizerLateEP pipeline: ");
-  Err(PB.parsePassPipeline(PM, ScalarOptimizerLateEPPipeline,
-   DebugLogging));
+  Err(PB.parsePassPipeline(PM, ScalarOptimizerLateEPPipeline));
 });
   if (tryParsePipelineText(PB, CGSCCOptimizerLateEPPipeline))
 PB.registerCGSCCOptimizerLateEPCallback(
-[&PB, DebugLogging](CGSCCPassManager &PM,
-PassBuilder::OptimizationLevel Level) {
+[&PB](CGSCCPassManager &PM, PassBuilder::OptimizationLevel Level) {
   ExitOnError Err("Unable to parse CGSCCOptimizerLateEP pipeline: ");
-  Err(PB.parsePassPipeline(PM, CGSCCOptimizerLateEPPipeline,
-   DebugLogging));
+  Err(PB.parsePassPipeline(PM, CGSCCOptimizerLateEPPipeline));
 });
   if (tryParsePipelineText(PB, VectorizerStartEPPipeline))
 PB.registerVectorizerStartEPCallback(
-[&PB, DebugLogging](FunctionPassManager &PM,
-PassBuild

[clang] 2177e45 - PR47861: Expand dangling reference warning to look through copy

2020-10-30 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-10-30T10:19:50-07:00
New Revision: 2177e4555ab84771c611a3295ab1149af7f79c29

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

LOG: PR47861: Expand dangling reference warning to look through copy
construction, and to assume that assignment operators return *this.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OperatorKinds.h
clang/lib/Sema/SemaInit.cpp
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
clang/test/SemaCXX/conditional-expr.cpp
clang/test/SemaCXX/constant-expression-cxx11.cpp
clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
clang/test/SemaCXX/return-stack-addr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 47becc959fb2..fe6b88321f6b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9077,6 +9077,10 @@ def err_ret_local_block : Error<
 def note_local_var_initializer : Note<
   "%select{via initialization of|binding reference}0 variable "
   "%select{%2 |}1here">;
+def note_lambda_capture_initializer : Note<
+  "%select{implicitly |}2captured%select{| by reference}3"
+  "%select{%select{ due to use|}2 here|"
+  " via initialization of lambda capture %0}1">;
 def note_init_with_default_member_initalizer : Note<
   "initializing field %0 with default member initializer">;
 

diff  --git a/clang/include/clang/Basic/OperatorKinds.h 
b/clang/include/clang/Basic/OperatorKinds.h
index d66189144511..3315df246981 100644
--- a/clang/include/clang/Basic/OperatorKinds.h
+++ b/clang/include/clang/Basic/OperatorKinds.h
@@ -49,6 +49,11 @@ getRewrittenOverloadedOperator(OverloadedOperatorKind Kind) {
   }
 }
 
+/// Determine if this is a compound assignment operator.
+inline bool isCompoundAssignmentOperator(OverloadedOperatorKind Kind) {
+  return Kind >= OO_PlusEqual && Kind <= OO_PipeEqual;
+}
+
 } // end namespace clang
 
 #endif

diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 419b25d278f5..5131ce446d04 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -6710,15 +6710,22 @@ struct IndirectLocalPathEntry {
 VarInit,
 LValToRVal,
 LifetimeBoundCall,
+TemporaryCopy,
+LambdaCaptureInit,
 GslReferenceInit,
 GslPointerInit
   } Kind;
   Expr *E;
-  const Decl *D = nullptr;
+  union {
+const Decl *D = nullptr;
+const LambdaCapture *Capture;
+  };
   IndirectLocalPathEntry() {}
   IndirectLocalPathEntry(EntryKind K, Expr *E) : Kind(K), E(E) {}
   IndirectLocalPathEntry(EntryKind K, Expr *E, const Decl *D)
   : Kind(K), E(E), D(D) {}
+  IndirectLocalPathEntry(EntryKind K, Expr *E, const LambdaCapture *Capture)
+  : Kind(K), E(E), Capture(Capture) {}
 };
 
 using IndirectLocalPath = llvm::SmallVectorImpl;
@@ -6912,6 +6919,26 @@ static bool implicitObjectParamIsLifetimeBound(const 
FunctionDecl *FD) {
 if (ATL.getAttrAs())
   return true;
   }
+
+  // Assume that all assignment operators with a "normal" return type return
+  // *this, that is, an lvalue reference that is the same type as the implicit
+  // object parameter (or the LHS for a non-member operator$=).
+  OverloadedOperatorKind OO = FD->getDeclName().getCXXOverloadedOperator();
+  if (OO == OO_Equal || isCompoundAssignmentOperator(OO)) {
+QualType RetT = FD->getReturnType();
+if (RetT->isLValueReferenceType()) {
+  ASTContext &Ctx = FD->getASTContext();
+  QualType LHST;
+  auto *MD = dyn_cast(FD);
+  if (MD && MD->isCXXInstanceMember())
+LHST = Ctx.getLValueReferenceType(MD->getThisObjectType());
+  else
+LHST = MD->getParamDecl(0)->getType();
+  if (Ctx.hasSameType(RetT, LHST))
+return true;
+}
+  }
+
   return false;
 }
 
@@ -7257,15 +7284,37 @@ static void 
visitLocalsRetainedByInitializer(IndirectLocalPath &Path,
   // The lifetime of an init-capture is that of the closure object constructed
   // by a lambda-expression.
   if (auto *LE = dyn_cast(Init)) {
+LambdaExpr::capture_iterator CapI = LE->capture_begin();
 for (Expr *E : LE->capture_inits()) {
+  assert(CapI != LE->capture_end());
+  const LambdaCapture &Cap = *CapI++;
   if (!E)
 continue;
+  if (Cap.capturesVariable())
+Path.push_back({IndirectLocalPathEntry::LambdaCaptureInit, E, &Cap});
   if (E->isGLValue())
 visitLocalsRetainedByReferenceBinding(Path, E, RK_ReferenceBinding,
   Visit, EnableLifetimeWarnings);
   else
 visitLocalsRetainedByIni

[clang] 84e8257 - FileManager: Improve the FileEntryRef API and customize its OptionalStorage

2020-10-30 Thread Duncan P . N . Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-10-30T13:25:46-04:00
New Revision: 84e8257937ec6a332aa0b688f4dce57016516ffd

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

LOG: FileManager: Improve the FileEntryRef API and customize its OptionalStorage

Make a few changes to the `FileEntryRef` API in preparation for
propagating it enough to remove `FileEntry::getName()`.

- Allow `FileEntryRef` to degrade implicitly to `const FileEntry*`. This
  allows functions currently returning `const FileEntry *` to be updated
  to return `FileEntryRef` without requiring all callers to be updated
  in the same patch. This helps avoid both (a) massive patches where
  many fields and locals are updated simultaneously and (b) noisy
  incremental patches where the first patch adds `getFileEntry()` at
  call sites and the second patch removes it. (Once `FileEntryRef` is
  everywhere, we should remove this API.)
- Change `operator==` to compare the underlying `FileEntry*`, ignoring
  any difference in the spelling of the filename. There were 0 users of
  the existing function because it's not useful.  In case comparing the
  exact named reference becomes important, add/test `isSameRef`.
- Add `==` comparisons between `FileEntryRef` and `const FileEntry *`
  (compares the `FileEntry*`).
- Customize `OptionalStorage` to be pointer-sized. Add
  a private constructor that initializes with `nullptr` and specialize
  `OptionalStorage` to use it. This unblocks updating fields in
  size-sensitive data structures that currently use `const FileEntry *`.
- Add `OptionalFileEntryRefDegradesToFileEntryPtr`, a wrapper around
  `Optional` that degrades to `const FileEntry*`. This
  facilitates future incremental patches, like the same operator on
  `FileEntryRef`. (Once `FileEntryRef` is everywhere, we should remove
  this class.)
- Remove the unncessary `const` from the by-value return of
  `FileEntryRef::getName`.
- Delete the unused function `FileEntry::isOpenForTests`.

Note that there are still `FileEntry` APIs that aren't wrapped and I
plan to deal with these separately / incrementally, as they are needed.

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

Added: 
clang/unittests/Basic/FileEntryTest.cpp

Modified: 
clang/include/clang/Basic/FileEntry.h
clang/unittests/Basic/CMakeLists.txt
clang/unittests/Basic/FileManagerTest.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/FileEntry.h 
b/clang/include/clang/Basic/FileEntry.h
index 65149569bb59..318aa2cdbb47 100644
--- a/clang/include/clang/Basic/FileEntry.h
+++ b/clang/include/clang/Basic/FileEntry.h
@@ -31,6 +31,22 @@ class File;
 
 namespace clang {
 
+class FileEntryRef;
+
+} // namespace clang
+
+namespace llvm {
+namespace optional_detail {
+
+/// Forward declare a template specialization for OptionalStorage.
+template <>
+class OptionalStorage;
+
+} // namespace optional_detail
+} // namespace llvm
+
+namespace clang {
+
 class DirectoryEntry;
 class FileEntry;
 
@@ -38,9 +54,9 @@ class FileEntry;
 /// accessed by the FileManager's client.
 class FileEntryRef {
 public:
-  const StringRef getName() const { return Entry->first(); }
+  StringRef getName() const { return ME->first(); }
   const FileEntry &getFileEntry() const {
-return *Entry->second->V.get();
+return *ME->second->V.get();
   }
 
   inline bool isValid() const;
@@ -49,12 +65,26 @@ class FileEntryRef {
   inline const llvm::sys::fs::UniqueID &getUniqueID() const;
   inline time_t getModificationTime() const;
 
+  /// Check if the underlying FileEntry is the same, intentially ignoring
+  /// whether the file was referenced with the same spelling of the filename.
   friend bool operator==(const FileEntryRef &LHS, const FileEntryRef &RHS) {
-return LHS.Entry == RHS.Entry;
+return &LHS.getFileEntry() == &RHS.getFileEntry();
+  }
+  friend bool operator==(const FileEntry *LHS, const FileEntryRef &RHS) {
+return LHS == &RHS.getFileEntry();
+  }
+  friend bool operator==(const FileEntryRef &LHS, const FileEntry *RHS) {
+return &LHS.getFileEntry() == RHS;
   }
   friend bool operator!=(const FileEntryRef &LHS, const FileEntryRef &RHS) {
 return !(LHS == RHS);
   }
+  friend bool operator!=(const FileEntry *LHS, const FileEntryRef &RHS) {
+return !(LHS == RHS);
+  }
+  friend bool operator!=(const FileEntryRef &LHS, const FileEntry *RHS) {
+return !(LHS == RHS);
+  }
 
   struct MapValue;
 
@@ -78,20 +108,190 @@ class FileEntryRef {
 MapValue(MapEntry &ME) : V(&ME) {}
   };
 
-private:
-  friend class FileManager;
+  /// Check if RHS referenced the file in exactly the same way.
+  bool isSameRef(const FileEntryRef &RHS) const { return ME == RHS.ME; }
+
+  /// Allow FileEntryRef to degrade into 'const FileEntry*' to facilitate
+  /// 

[PATCH] D89834: FileManager: Improve the FileEntryRef API and customize its OptionalStorage

2020-10-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG84e8257937ec: FileManager: Improve the FileEntryRef API and 
customize its OptionalStorage (authored by dexonsmith).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89834

Files:
  clang/include/clang/Basic/FileEntry.h
  clang/unittests/Basic/CMakeLists.txt
  clang/unittests/Basic/FileEntryTest.cpp
  clang/unittests/Basic/FileManagerTest.cpp

Index: clang/unittests/Basic/FileManagerTest.cpp
===
--- clang/unittests/Basic/FileManagerTest.cpp
+++ clang/unittests/Basic/FileManagerTest.cpp
@@ -350,6 +350,58 @@
 f2 ? *f2 : nullptr);
 }
 
+TEST_F(FileManagerTest, getFileRefEquality) {
+  auto StatCache = std::make_unique();
+  StatCache->InjectDirectory("dir", 40);
+  StatCache->InjectFile("dir/f1.cpp", 41);
+  StatCache->InjectFile("dir/f1-also.cpp", 41);
+  StatCache->InjectFile("dir/f1-redirect.cpp", 41, "dir/f1.cpp");
+  StatCache->InjectFile("dir/f2.cpp", 42);
+  manager.setStatCache(std::move(StatCache));
+
+  auto F1 = manager.getFileRef("dir/f1.cpp");
+  auto F1Again = manager.getFileRef("dir/f1.cpp");
+  auto F1Also = manager.getFileRef("dir/f1-also.cpp");
+  auto F1Redirect = manager.getFileRef("dir/f1-redirect.cpp");
+  auto F2 = manager.getFileRef("dir/f2.cpp");
+
+  // Check Expected for error.
+  ASSERT_FALSE(!F1);
+  ASSERT_FALSE(!F1Also);
+  ASSERT_FALSE(!F1Again);
+  ASSERT_FALSE(!F1Redirect);
+  ASSERT_FALSE(!F2);
+
+  // Check names.
+  EXPECT_EQ("dir/f1.cpp", F1->getName());
+  EXPECT_EQ("dir/f1.cpp", F1Again->getName());
+  EXPECT_EQ("dir/f1-also.cpp", F1Also->getName());
+  EXPECT_EQ("dir/f1.cpp", F1Redirect->getName());
+  EXPECT_EQ("dir/f2.cpp", F2->getName());
+
+  // Compare against FileEntry*.
+  EXPECT_EQ(&F1->getFileEntry(), *F1);
+  EXPECT_EQ(*F1, &F1->getFileEntry());
+  EXPECT_NE(&F2->getFileEntry(), *F1);
+  EXPECT_NE(*F1, &F2->getFileEntry());
+
+  // Compare using ==.
+  EXPECT_EQ(*F1, *F1Also);
+  EXPECT_EQ(*F1, *F1Again);
+  EXPECT_EQ(*F1, *F1Redirect);
+  EXPECT_EQ(*F1Also, *F1Redirect);
+  EXPECT_NE(*F2, *F1);
+  EXPECT_NE(*F2, *F1Also);
+  EXPECT_NE(*F2, *F1Again);
+  EXPECT_NE(*F2, *F1Redirect);
+
+  // Compare using isSameRef.
+  EXPECT_TRUE(F1->isSameRef(*F1Again));
+  EXPECT_TRUE(F1->isSameRef(*F1Redirect));
+  EXPECT_FALSE(F1->isSameRef(*F1Also));
+  EXPECT_FALSE(F1->isSameRef(*F2));
+}
+
 // getFile() Should return the same entry as getVirtualFile if the file actually
 // is a virtual file, even if the name is not exactly the same (but is after
 // normalisation done by the file system, like on Windows). This can be checked
Index: clang/unittests/Basic/FileEntryTest.cpp
===
--- /dev/null
+++ clang/unittests/Basic/FileEntryTest.cpp
@@ -0,0 +1,104 @@
+//===- unittests/Basic/FileEntryTest.cpp - Test FileEntry/FileEntryRef ===//
+//
+// 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/Basic/FileEntry.h"
+#include "llvm/ADT/StringMap.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace clang;
+
+namespace {
+
+using MapEntry = FileEntryRef::MapEntry;
+using MapValue = FileEntryRef::MapValue;
+using MapType = StringMap>;
+
+FileEntryRef addRef(MapType &M, StringRef Name, FileEntry &E) {
+  return FileEntryRef(*M.insert({Name, MapValue(E)}).first);
+}
+
+TEST(FileEntryTest, FileEntryRef) {
+  MapType Refs;
+  FileEntry E1, E2;
+  FileEntryRef R1 = addRef(Refs, "1", E1);
+  FileEntryRef R2 = addRef(Refs, "2", E2);
+  FileEntryRef R1Also = addRef(Refs, "1-also", E1);
+
+  EXPECT_EQ("1", R1.getName());
+  EXPECT_EQ("2", R2.getName());
+  EXPECT_EQ("1-also", R1Also.getName());
+
+  EXPECT_EQ(&E1, &R1.getFileEntry());
+  EXPECT_EQ(&E2, &R2.getFileEntry());
+  EXPECT_EQ(&E1, &R1Also.getFileEntry());
+
+  const FileEntry *CE1 = R1;
+  EXPECT_EQ(CE1, &E1);
+}
+
+TEST(FileEntryTest, OptionalFileEntryRefDegradesToFileEntryPtr) {
+  MapType Refs;
+  FileEntry E1, E2;
+  OptionalFileEntryRefDegradesToFileEntryPtr M0;
+  OptionalFileEntryRefDegradesToFileEntryPtr M1 = addRef(Refs, "1", E1);
+  OptionalFileEntryRefDegradesToFileEntryPtr M2 = addRef(Refs, "2", E2);
+  OptionalFileEntryRefDegradesToFileEntryPtr M0Also = None;
+  OptionalFileEntryRefDegradesToFileEntryPtr M1Also =
+  addRef(Refs, "1-also", E1);
+
+  EXPECT_EQ(M0, M0Also);
+  EXPECT_EQ(StringRef("1"), M1->getName());
+  EXPECT_EQ(StringRef("2"), M2->getName());
+  EXPECT_EQ(StringRef("1-also"), M1Also->getName());
+
+  EXPECT_EQ(&E1, &M1->getFileEntry());
+  EXPECT_EQ(&E2, &M2->getFileEntry());
+  EXPECT_EQ(

[PATCH] D90478: Basic: Split out DirectoryEntry.h, NFC

2020-10-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: arphaman, JDevlieghere.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.

Move `DirectoryEntry` and `DirectoryEntryRef` into their own header,
similar to the creation of FileEntry.h. No functionality change here,
just preparing to include it in more places to allow wider adoption of
`DirectoryEntryRef` without requiring all of `FileManager.h`.


https://reviews.llvm.org/D90478

Files:
  clang/include/clang/Basic/DirectoryEntry.h
  clang/include/clang/Basic/FileManager.h

Index: clang/include/clang/Basic/FileManager.h
===
--- clang/include/clang/Basic/FileManager.h
+++ clang/include/clang/Basic/FileManager.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_BASIC_FILEMANAGER_H
 #define LLVM_CLANG_BASIC_FILEMANAGER_H
 
+#include "clang/Basic/DirectoryEntry.h"
 #include "clang/Basic/FileEntry.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/LLVM.h"
@@ -42,36 +43,6 @@
 
 class FileSystemStatCache;
 
-/// Cached information about one directory (either on disk or in
-/// the virtual file system).
-class DirectoryEntry {
-  friend class FileManager;
-
-  // FIXME: We should not be storing a directory entry name here.
-  StringRef Name; // Name of the directory.
-
-public:
-  StringRef getName() const { return Name; }
-};
-
-/// A reference to a \c DirectoryEntry  that includes the name of the directory
-/// as it was accessed by the FileManager's client.
-class DirectoryEntryRef {
-public:
-  const DirectoryEntry &getDirEntry() const { return *Entry->getValue(); }
-
-  StringRef getName() const { return Entry->getKey(); }
-
-private:
-  friend class FileManager;
-
-  DirectoryEntryRef(
-  llvm::StringMapEntry> *Entry)
-  : Entry(Entry) {}
-
-  const llvm::StringMapEntry> *Entry;
-};
-
 /// Implements support for file system lookup, file system caching,
 /// and directory search management.
 ///
Index: clang/include/clang/Basic/DirectoryEntry.h
===
--- /dev/null
+++ clang/include/clang/Basic/DirectoryEntry.h
@@ -0,0 +1,56 @@
+//===- clang/Basic/DirectoryEntry.h - Directory references --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// Defines interfaces for clang::DirectoryEntry and clang::DirectoryEntryRef.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_DIRECTORYENTRY_H
+#define LLVM_CLANG_BASIC_DIRECTORYENTRY_H
+
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/ErrorOr.h"
+
+namespace clang {
+
+/// Cached information about one directory (either on disk or in
+/// the virtual file system).
+class DirectoryEntry {
+  friend class FileManager;
+
+  // FIXME: We should not be storing a directory entry name here.
+  StringRef Name; // Name of the directory.
+
+public:
+  StringRef getName() const { return Name; }
+};
+
+/// A reference to a \c DirectoryEntry  that includes the name of the directory
+/// as it was accessed by the FileManager's client.
+class DirectoryEntryRef {
+public:
+  const DirectoryEntry &getDirEntry() const { return *Entry->getValue(); }
+
+  StringRef getName() const { return Entry->getKey(); }
+
+private:
+  friend class FileManager;
+
+  DirectoryEntryRef(
+  llvm::StringMapEntry> *Entry)
+  : Entry(Entry) {}
+
+  const llvm::StringMapEntry> *Entry;
+};
+
+} // end namespace clang
+
+#endif // LLVM_CLANG_BASIC_DIRECTORYENTRY_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90481: Basic: Change Module::Umbrella to a PointerUnion, NFC

2020-10-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: arphaman, JDevlieghere.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.

Change `Module::Umbrella` from a `const void *` to a `PointerUnion` of
`FileEntry` and `DirectoryEntry`. We can drop the `HasUmbrellaDir` bit
(since `PointerUnion` includes that).

This change makes it safer to update to `FileEntryRef` and
`DirectoryEntryRef` in a future patch.


https://reviews.llvm.org/D90481

Files:
  clang/include/clang/Basic/Module.h
  clang/lib/Basic/Module.cpp
  clang/lib/Lex/ModuleMap.cpp

Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -1125,7 +1125,6 @@
   Twine NameAsWritten) {
   Headers[UmbrellaHeader].push_back(KnownHeader(Mod, NormalHeader));
   Mod->Umbrella = UmbrellaHeader;
-  Mod->HasUmbrellaDir = false;
   Mod->UmbrellaAsWritten = NameAsWritten.str();
   UmbrellaDirs[UmbrellaHeader->getDir()] = Mod;
 
@@ -1137,7 +1136,6 @@
 void ModuleMap::setUmbrellaDir(Module *Mod, const DirectoryEntry *UmbrellaDir,
Twine NameAsWritten) {
   Mod->Umbrella = UmbrellaDir;
-  Mod->HasUmbrellaDir = true;
   Mod->UmbrellaAsWritten = NameAsWritten.str();
   UmbrellaDirs[UmbrellaDir] = Mod;
 }
Index: clang/lib/Basic/Module.cpp
===
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -44,7 +44,7 @@
   InferSubmodules(false), InferExplicitSubmodules(false),
   InferExportWildcard(false), ConfigMacrosExhaustive(false),
   NoUndeclaredIncludes(false), ModuleMapIsPrivate(false),
-  HasUmbrellaDir(false), NameVisibility(Hidden) {
+  NameVisibility(Hidden) {
   if (Parent) {
 IsAvailable = Parent->isAvailable();
 IsUnimportable = Parent->isUnimportable();
@@ -247,7 +247,7 @@
   if (Header U = getUmbrellaHeader())
 return {"", U.Entry->getDir()};
 
-  return {UmbrellaAsWritten, static_cast(Umbrella)};
+  return {UmbrellaAsWritten, Umbrella.dyn_cast()};
 }
 
 void Module::addTopHeader(const FileEntry *File) {
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_BASIC_MODULE_H
 #define LLVM_CLANG_BASIC_MODULE_H
 
+#include "clang/Basic/DirectoryEntry.h"
 #include "clang/Basic/FileEntry.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -44,8 +45,6 @@
 
 namespace clang {
 
-class DirectoryEntry;
-class FileEntry;
 class FileManager;
 class LangOptions;
 class TargetInfo;
@@ -134,7 +133,7 @@
   std::string PresumedModuleMapFile;
 
   /// The umbrella header or directory.
-  const void *Umbrella = nullptr;
+  llvm::PointerUnion Umbrella;
 
   /// The module signature.
   ASTFileSignature Signature;
@@ -303,9 +302,6 @@
   /// to a regular (public) module map.
   unsigned ModuleMapIsPrivate : 1;
 
-  /// Whether Umbrella is a directory or header.
-  unsigned HasUmbrellaDir : 1;
-
   /// Describes the visibility of the various names within a
   /// particular module.
   enum NameVisibilityKind {
@@ -548,15 +544,16 @@
   /// Retrieve the header that serves as the umbrella header for this
   /// module.
   Header getUmbrellaHeader() const {
-if (!HasUmbrellaDir)
-  return Header{UmbrellaAsWritten,
-static_cast(Umbrella)};
+if (auto *FE = Umbrella.dyn_cast())
+  return Header{UmbrellaAsWritten, FE};
 return Header{};
   }
 
   /// Determine whether this module has an umbrella directory that is
   /// not based on an umbrella header.
-  bool hasUmbrellaDir() const { return Umbrella && HasUmbrellaDir; }
+  bool hasUmbrellaDir() const {
+return Umbrella && Umbrella.is();
+  }
 
   /// Add a top-level header associated with this module.
   void addTopHeader(const FileEntry *File);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90447: [AMDGPU] Add gfx1033 target

2020-10-30 Thread Tim Renouf via Phabricator via cfe-commits
tpr updated this revision to Diff 301953.
tpr added a comment.
Herald added subscribers: emaste, jholewinski.
Herald added a reviewer: espindola.

V3: Add missing bits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90447

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/CodeGenOpenCL/amdgpu-features.cl
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/amdgpu-mcpu.cl
  llvm/docs/AMDGPUUsage.rst
  llvm/include/llvm/BinaryFormat/ELF.h
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Object/ELFObjectFile.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/lib/Support/TargetParser.cpp
  llvm/lib/Target/AMDGPU/GCNProcessors.td
  llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
  llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll
  llvm/test/CodeGen/AMDGPU/hsa-note-no-func.ll
  llvm/test/MC/AMDGPU/gfx1011_dlops.s
  llvm/test/MC/AMDGPU/gfx1030_err.s
  llvm/test/MC/AMDGPU/gfx1030_new.s
  llvm/test/MC/Disassembler/AMDGPU/gfx1011_dasm_dlops.txt
  llvm/test/MC/Disassembler/AMDGPU/gfx1030_dasm_new.txt
  llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
  llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
  llvm/tools/llvm-readobj/ELFDumper.cpp

Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1786,6 +1786,7 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1030),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1031),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1032),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1033),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_XNACK),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_SRAM_ECC)
 };
Index: llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
===
--- llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
+++ llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
@@ -58,6 +58,9 @@
 # RUN: yaml2obj %s -o %t -DCPU=GFX909
 # RUN: llvm-readobj -h %t | FileCheck %s --match-full-lines -DFILE=%t -DCPU=GFX909 -DFLAGS=0x31
 
+# RUN: yaml2obj %s -o %t -DCPU=GFX90C
+# RUN: llvm-readobj -h %t | FileCheck %s --match-full-lines -DFILE=%t -DCPU=GFX90C -DFLAGS=0x32
+
 # RUN: yaml2obj %s -o %t -DCPU=GFX1010
 # RUN: llvm-readobj -h %t | FileCheck %s --match-full-lines -DFILE=%t -DCPU=GFX1010 -DFLAGS=0x33
 
@@ -76,6 +79,9 @@
 # RUN: yaml2obj %s -o %t -DCPU=GFX1032
 # RUN: llvm-readobj -h %t | FileCheck %s --match-full-lines -DFILE=%t -DCPU=GFX1032 -DFLAGS=0x38
 
+# RUN: yaml2obj %s -o %t -DCPU=GFX1033
+# RUN: llvm-readobj -h %t | FileCheck %s --match-full-lines -DFILE=%t -DCPU=GFX1033 -DFLAGS=0x39
+
 --- !ELF
 FileHeader:
   Class:   ELFCLASS64
Index: llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
===
--- llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
+++ llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
@@ -170,6 +170,10 @@
 # RUN: llvm-readobj -s -file-headers %t.o.43 | FileCheck --check-prefixes=ELF-ALL,ELF-GFX90C %s
 # RUN: obj2yaml %t.o.43 | FileCheck --check-prefixes=YAML-GFX90C %s
 
+# RUN: yaml2obj --docnum=44 %s > %t.o.44
+# RUN: llvm-readobj -s -file-headers %t.o.44 | FileCheck --check-prefixes=ELF-ALL,ELF-GFX1033 %s
+# RUN: obj2yaml %t.o.44 | FileCheck --check-prefixes=YAML-GFX1033 %s
+
 # ELF-ALL: Flags [
 # ELF-R600:  EF_AMDGPU_MACH_R600_R600 (0x1)
 # ELF-R630:  EF_AMDGPU_MACH_R600_R630 (0x2)
@@ -214,6 +218,7 @@
 # ELF-GFX1030:   EF_AMDGPU_MACH_AMDGCN_GFX1030 (0x36)
 # ELF-GFX1031:   EF_AMDGPU_MACH_AMDGCN_GFX1031 (0x37)
 # ELF-GFX1032:   EF_AMDGPU_MACH_AMDGCN_GFX1032 (0x38)
+# ELF-GFX1033:   EF_AMDGPU_MACH_AMDGCN_GFX1033 (0x39)
 # ELF-ALL: ]
 
 # YAML-R600:Flags: [ EF_AMDGPU_MACH_R600_R600 ]
@@ -259,6 +264,7 @@
 # YAML-GFX1030: Flags: [ EF_AMDGPU_MACH_AMDGCN_GFX1030 ]
 # YAML-GFX1031: Flags: [ EF_AMDGPU_MACH_AMDGCN_GFX1031 ]
 # YAML-GFX1032: Flags: [ EF_AMDGPU_MACH_AMDGCN_GFX1032 ]
+# YAML-GFX1033: Flags: [ EF_AMDGPU_MACH_AMDGCN_GFX1033 ]
 
 # Doc1
 --- !ELF
@@ -732,3 +738,14 @@
   Machine: EM_AMDGPU
   Flags:   [ EF_AMDGPU_MACH_AMDGCN_GFX90C ]
 ...
+
+# Doc44
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  OSABI:   ELFOSABI_NONE
+  Type:ET_REL
+  Machine: EM_AMDGPU
+  Flags:   [ EF_AMDGPU_MACH_AMDGCN_GFX1033 ]
+...
Index: llvm/test/MC/Disassembler/AMDGPU/gfx1030_dasm_new.txt
===
--- llvm/test/MC/Disassembler/AMDGPU/gfx1030_dasm_new.txt
+++ llvm/test/MC/Disassembler/AMDGPU/gfx1030_dasm_new.txt
@@ -1,6 +1,7 @@
 # RUN: llvm-mc -arch=amdgcn -mcpu=gfx1030 -disassemble -show-encoding < %s 

[PATCH] D90484: FileManager: Add FileEntryRef::getDir, returning DirectoryEntryRef

2020-10-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: arphaman, JDevlieghere.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.

Add `FileEntryRef::getDir`, which returns a `DirectoryEntryRef`. This
includes a few changes:

- Customize `OptionalStorage` so that `Optional` is 
pointer-sized (like the change made to `Optional`). Factored out 
a common class, `FileMgr::MapEntryOptionalStorage`, to reduce the code 
duplication.
- Store an `Optional` in `FileEntryRef::MapValue`. This is 
set if and only if `MapValue` has a real `FileEntry`.
- Change `FileManager::getFileRef` and `getVirtualFileRef` to use 
`getDirectoryRef` and store it in the `StringMap` for `FileEntryRef`.


https://reviews.llvm.org/D90484

Files:
  clang/include/clang/Basic/DirectoryEntry.h
  clang/include/clang/Basic/FileEntry.h
  clang/lib/Basic/FileManager.cpp
  clang/unittests/Basic/FileEntryTest.cpp

Index: clang/unittests/Basic/FileEntryTest.cpp
===
--- clang/unittests/Basic/FileEntryTest.cpp
+++ clang/unittests/Basic/FileEntryTest.cpp
@@ -15,85 +15,97 @@
 
 namespace {
 
-using MapEntry = FileEntryRef::MapEntry;
-using MapValue = FileEntryRef::MapValue;
-using MapType = StringMap>;
-
-FileEntryRef addRef(MapType &M, StringRef Name, FileEntry &E) {
-  return FileEntryRef(*M.insert({Name, MapValue(E)}).first);
-}
+using FileMap = StringMap>;
+using DirMap = StringMap>;
+
+struct RefMaps {
+  FileMap Files;
+  DirMap Dirs;
+
+  DirectoryEntry D;
+  DirectoryEntryRef DR;
+  SmallVector, 5> FEs;
+
+  RefMaps() : DR(*Dirs.insert({"dir", D}).first) {}
+
+  FileEntryRef addFile(StringRef Name) {
+FEs.push_back(std::make_unique());
+return FileEntryRef(
+*Files.insert({Name, FileEntryRef::MapValue(*FEs.back().get(), DR)})
+ .first);
+  }
+  FileEntryRef addFileAlias(StringRef Name, FileEntryRef Base) {
+return FileEntryRef(
+*Files
+ .insert(
+ {Name, FileEntryRef::MapValue(
+const_cast(Base.getFileEntry()), DR)})
+ .first);
+  }
+};
 
 TEST(FileEntryTest, FileEntryRef) {
-  MapType Refs;
-  FileEntry E1, E2;
-  FileEntryRef R1 = addRef(Refs, "1", E1);
-  FileEntryRef R2 = addRef(Refs, "2", E2);
-  FileEntryRef R1Also = addRef(Refs, "1-also", E1);
+  RefMaps Refs;
+  FileEntryRef R1 = Refs.addFile("1");
+  FileEntryRef R2 = Refs.addFile("2");
+  FileEntryRef R1Also = Refs.addFileAlias("1-also", R1);
 
   EXPECT_EQ("1", R1.getName());
   EXPECT_EQ("2", R2.getName());
   EXPECT_EQ("1-also", R1Also.getName());
 
-  EXPECT_EQ(&E1, &R1.getFileEntry());
-  EXPECT_EQ(&E2, &R2.getFileEntry());
-  EXPECT_EQ(&E1, &R1Also.getFileEntry());
+  EXPECT_NE(&R1.getFileEntry(), &R2.getFileEntry());
+  EXPECT_EQ(&R1.getFileEntry(), &R1Also.getFileEntry());
 
   const FileEntry *CE1 = R1;
-  EXPECT_EQ(CE1, &E1);
+  EXPECT_EQ(CE1, &R1.getFileEntry());
 }
 
 TEST(FileEntryTest, OptionalFileEntryRefDegradesToFileEntryPtr) {
-  MapType Refs;
-  FileEntry E1, E2;
+  RefMaps Refs;
   OptionalFileEntryRefDegradesToFileEntryPtr M0;
-  OptionalFileEntryRefDegradesToFileEntryPtr M1 = addRef(Refs, "1", E1);
-  OptionalFileEntryRefDegradesToFileEntryPtr M2 = addRef(Refs, "2", E2);
+  OptionalFileEntryRefDegradesToFileEntryPtr M1 = Refs.addFile("1");
+  OptionalFileEntryRefDegradesToFileEntryPtr M2 = Refs.addFile("2");
   OptionalFileEntryRefDegradesToFileEntryPtr M0Also = None;
   OptionalFileEntryRefDegradesToFileEntryPtr M1Also =
-  addRef(Refs, "1-also", E1);
+  Refs.addFileAlias("1-also", *M1);
 
   EXPECT_EQ(M0, M0Also);
   EXPECT_EQ(StringRef("1"), M1->getName());
   EXPECT_EQ(StringRef("2"), M2->getName());
   EXPECT_EQ(StringRef("1-also"), M1Also->getName());
 
-  EXPECT_EQ(&E1, &M1->getFileEntry());
-  EXPECT_EQ(&E2, &M2->getFileEntry());
-  EXPECT_EQ(&E1, &M1Also->getFileEntry());
-
   const FileEntry *CE1 = M1;
-  EXPECT_EQ(CE1, &E1);
+  EXPECT_EQ(CE1, &M1->getFileEntry());
 }
 
 TEST(FileEntryTest, equals) {
-  MapType Refs;
-  FileEntry E1, E2;
-  FileEntryRef R1 = addRef(Refs, "1", E1);
-  FileEntryRef R2 = addRef(Refs, "2", E2);
-  FileEntryRef R1Also = addRef(Refs, "1-also", E1);
-
-  EXPECT_EQ(R1, &E1);
-  EXPECT_EQ(&E1, R1);
+  RefMaps Refs;
+  FileEntryRef R1 = Refs.addFile("1");
+  FileEntryRef R2 = Refs.addFile("2");
+  FileEntryRef R1Also = Refs.addFileAlias("1-also", R1);
+
+  EXPECT_EQ(R1, &R1.getFileEntry());
+  EXPECT_EQ(&R1.getFileEntry(), R1);
   EXPECT_EQ(R1, R1Also);
-  EXPECT_NE(R1, &E2);
-  EXPECT_NE(&E2, R1);
+  EXPECT_NE(R1, &R2.getFileEntry());
+  EXPECT_NE(&R2.getFileEntry(), R1);
   EXPECT_NE(R1, R2);
 
   OptionalFileEntryRefDegradesToFileEntryPtr M0;
   OptionalFileEntryRefDegradesToFileEntryPtr M1 = R1;
 
-  EXPECT_EQ(M1, &E1);
-  EXPECT_EQ(&E1, M1);
-  EXPECT_NE(M1, &E2);
-  EXPECT_NE(&E2, M1);
+  EXPECT_EQ(M1, &R1.getFileEntry());
+  EXPECT_EQ(&R1.getFileEntry(), M1);
+  EXPECT_NE(M1, &R2.getFileEntry());
+  EXPECT_N

[PATCH] D90485: Lex: Update Module::findHeader to return FileEntryRef, NFC

2020-10-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: arphaman, JDevlieghere.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.

Update `Module::findHeader` to return `Optional` and
fix its one caller.


https://reviews.llvm.org/D90485

Files:
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Lex/ModuleMap.cpp

Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -171,23 +171,23 @@
 llvm::sys::path::append(Path, "Frameworks", Paths[I-1] + ".framework");
 }
 
-const FileEntry *ModuleMap::findHeader(
+Optional ModuleMap::findHeader(
 Module *M, const Module::UnresolvedHeaderDirective &Header,
 SmallVectorImpl &RelativePathName, bool &NeedsFramework) {
   // Search for the header file within the module's home directory.
   auto *Directory = M->Directory;
   SmallString<128> FullPathName(Directory->getName());
 
-  auto GetFile = [&](StringRef Filename) -> const FileEntry * {
-auto File = SourceMgr.getFileManager().getFile(Filename);
-if (!File ||
-(Header.Size && (*File)->getSize() != *Header.Size) ||
-(Header.ModTime && (*File)->getModificationTime() != *Header.ModTime))
-  return nullptr;
+  auto GetFile = [&](StringRef Filename) -> Optional {
+auto File =
+expectedToOptional(SourceMgr.getFileManager().getFileRef(Filename));
+if (!File || (Header.Size && File->getSize() != *Header.Size) ||
+(Header.ModTime && File->getModificationTime() != *Header.ModTime))
+  return None;
 return *File;
   };
 
-  auto GetFrameworkFile = [&]() -> const FileEntry * {
+  auto GetFrameworkFile = [&]() -> Optional {
 unsigned FullPathLength = FullPathName.size();
 appendSubframeworkPaths(M, RelativePathName);
 unsigned RelativePathLength = RelativePathName.size();
@@ -195,7 +195,7 @@
 // Check whether this file is in the public headers.
 llvm::sys::path::append(RelativePathName, "Headers", Header.FileName);
 llvm::sys::path::append(FullPathName, RelativePathName);
-if (auto *File = GetFile(FullPathName))
+if (auto File = GetFile(FullPathName))
   return File;
 
 // Check whether this file is in the private headers.
@@ -227,7 +227,7 @@
   // Lookup for normal headers.
   llvm::sys::path::append(RelativePathName, Header.FileName);
   llvm::sys::path::append(FullPathName, RelativePathName);
-  auto *NormalHdrFile = GetFile(FullPathName);
+  auto NormalHdrFile = GetFile(FullPathName);
 
   if (!NormalHdrFile && Directory->getName().endswith(".framework")) {
 // The lack of 'framework' keyword in a module declaration it's a simple
@@ -241,7 +241,7 @@
   << Header.FileName << M->getFullModuleName();
   NeedsFramework = true;
 }
-return nullptr;
+return None;
   }
 
   return NormalHdrFile;
@@ -251,18 +251,18 @@
   const Module::UnresolvedHeaderDirective &Header,
   bool &NeedsFramework) {
   SmallString<128> RelativePathName;
-  if (const FileEntry *File =
+  if (Optional File =
   findHeader(Mod, Header, RelativePathName, NeedsFramework)) {
 if (Header.IsUmbrella) {
-  const DirectoryEntry *UmbrellaDir = File->getDir();
+  const DirectoryEntry *UmbrellaDir = &File->getDir().getDirEntry();
   if (Module *UmbrellaMod = UmbrellaDirs[UmbrellaDir])
 Diags.Report(Header.FileNameLoc, diag::err_mmap_umbrella_clash)
   << UmbrellaMod->getFullModuleName();
   else
 // Record this umbrella header.
-setUmbrellaHeader(Mod, File, RelativePathName.str());
+setUmbrellaHeader(Mod, *File, RelativePathName.str());
 } else {
-  Module::Header H = {std::string(RelativePathName.str()), File};
+  Module::Header H = {std::string(RelativePathName.str()), *File};
   if (Header.Kind == Module::HK_Excluded)
 excludeHeader(Mod, H);
   else
Index: clang/include/clang/Lex/ModuleMap.h
===
--- clang/include/clang/Lex/ModuleMap.h
+++ clang/include/clang/Lex/ModuleMap.h
@@ -328,10 +328,9 @@
   /// \param NeedsFramework If M is not a framework but a missing header would
   ///be found in case M was, set it to true. False otherwise.
   /// \return The resolved file, if any.
-  const FileEntry *findHeader(Module *M,
-  const Module::UnresolvedHeaderDirective &Header,
-  SmallVectorImpl &RelativePathName,
-  bool &NeedsFramework);
+  Optional
+  findHeader(Module *M, const Module::UnresolvedHeaderDirective &Header,
+ SmallVectorImpl &RelativePathName, bool &NeedsFramework);
 
   /// Resolve the given header directive.
   ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/li

[PATCH] D90486: [NewPM] Add OptimizationLevel param to TargetMachine::registerPassBuilderCallbacks()

2020-10-30 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
Herald added subscribers: llvm-commits, cfe-commits, steven_wu, hiraditya, tpr, 
mgorny.
Herald added a reviewer: bollu.
Herald added projects: clang, LLVM.
aeubanks requested review of this revision.

To prevent targets from adding optional passes for -O0,
TargetMachine::registerPassBuilderCallbacks() needs an OptimizationLevel
parameter to see if it's O0.

Currently no existing users require this, but some targets that haven't
implemented TargetMachine::registerPassBuilderCallbacks() yet will
require it, e.g. AMDGPU.

This requires moving OptimizationLevel out of PassBuilder, or else
TargetMachine.h will have to #include all of PassBuilder.h.

Since registerPassBuilderCallbacks() now requires an OptimizationLevel,
we can't call it in PassBuilder's constructor. Rather, it's called when
we create a full pipeline, whether default or LTO or O0. This makes
sense since there's no need to run registerPassBuilderCallbacks() when
adding individual passes via PassBuilder, only when creating full
pipelines.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90486

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/examples/Bye/Bye.cpp
  llvm/include/llvm/Passes/OptimizationLevel.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/CMakeLists.txt
  llvm/lib/Passes/OptimizationLevel.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Target/BPF/BPFTargetMachine.cpp
  llvm/lib/Target/BPF/BPFTargetMachine.h
  llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
  llvm/lib/Target/Hexagon/HexagonTargetMachine.h
  llvm/tools/opt/NewPMDriver.cpp
  llvm/utils/gn/secondary/llvm/lib/Passes/BUILD.gn
  polly/lib/Support/RegisterPasses.cpp

Index: polly/lib/Support/RegisterPasses.cpp
===
--- polly/lib/Support/RegisterPasses.cpp
+++ polly/lib/Support/RegisterPasses.cpp
@@ -470,7 +470,7 @@
 }
 
 static void buildDefaultPollyPipeline(FunctionPassManager &PM,
-  PassBuilder::OptimizationLevel Level) {
+  OptimizationLevel Level) {
   if (!polly::shouldEnablePolly())
 return;
   PassBuilder PB;
Index: llvm/utils/gn/secondary/llvm/lib/Passes/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/Passes/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/Passes/BUILD.gn
@@ -18,6 +18,7 @@
 "//llvm/lib/Transforms/Vectorize",
   ]
   sources = [
+"OptimizationLevel.cpp",
 "PassBuilder.cpp",
 "PassPlugin.cpp",
 "StandardInstrumentations.cpp",
Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -143,39 +143,39 @@
 static void registerEPCallbacks(PassBuilder &PB) {
   if (tryParsePipelineText(PB, PeepholeEPPipeline))
 PB.registerPeepholeEPCallback(
-[&PB](FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
+[&PB](FunctionPassManager &PM, OptimizationLevel Level) {
   ExitOnError Err("Unable to parse PeepholeEP pipeline: ");
   Err(PB.parsePassPipeline(PM, PeepholeEPPipeline));
 });
   if (tryParsePipelineText(PB,
 LateLoopOptimizationsEPPipeline))
 PB.registerLateLoopOptimizationsEPCallback(
-[&PB](LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
+[&PB](LoopPassManager &PM, OptimizationLevel Level) {
   ExitOnError Err("Unable to parse LateLoopOptimizationsEP pipeline: ");
   Err(PB.parsePassPipeline(PM, LateLoopOptimizationsEPPipeline));
 });
   if (tryParsePipelineText(PB, LoopOptimizerEndEPPipeline))
 PB.registerLoopOptimizerEndEPCallback(
-[&PB](LoopPassManager &PM, PassBuilder::OptimizationLevel Level) {
+[&PB](LoopPassManager &PM, OptimizationLevel Level) {
   ExitOnError Err("Unable to parse LoopOptimizerEndEP pipeline: ");
   Err(PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline));
 });
   if (tryParsePipelineText(PB,
 ScalarOptimizerLateEPPipeline))
 PB.registerScalarOptimizerLateEPCallback(
-[&PB](FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) {
+[&PB](FunctionPassManager &PM, OptimizationLevel Level) {
   ExitOnError Err("Unable to parse ScalarOptimizerLateEP pipeline: ");
   Err(PB.parsePassPipeline(PM, ScalarOptimizerLateEPPipeline));
 });
   if (tryParsePipelineText(PB, CGSCCOptimizerLateEPPipeline))
 PB.registerCGSCCOptimizerLateEPCallback(
-[&PB](CGSCCPassManager &PM, PassBuilder::OptimizationLevel Level) {
+[&PB](CGSCCPassManager &PM, OptimizationLevel Level) {
   ExitOnError Err("Unable to parse CGSCCOptimizerLateEP pipeline: ");
 

[PATCH] D84362: [NFC] Refactor DiagnosticBuilder and PartialDiagnostic

2020-10-30 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I may not have been clear.  I'm not saying SourceLocation is a meaningful 
concept in the driver.  I'm saying that if you generalize the concept of 
"source location" to "location in the input", there is a clear analogue in the 
driver (namely, a position in the argument list), and the only reason this 
isn't passed down to the driver and used in diagnostics is that we don't have 
the ability to express that today to the diagnostic engine.  So instead of 
trying to extract out a part of the diagnostics engine that will work without 
any concept of source locations, you should be trying to parameterize the 
diagnostics engine so that it can work with an arbitrary external concept of 
source locations, and then the driver can use a different kind of source 
location than the main compiler and everything is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84362

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


[PATCH] D89158: [NewPM] Provide method to run all pipeline callbacks, used for -O0

2020-10-30 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

https://reviews.llvm.org/D90486 for adding OptimizationLevel to 
registerPassBuilderCallbacks(), although this one should land first since that 
one needs to update PassBuilder::runRegisteredEPCallbacks() to call 
TargetMachine::registerPassBuilderCallbacks()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89158

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


[clang] 010238a - Speculative fix for bots after 84e8257937ec6a332aa0b688f4dce57016516ffd

2020-10-30 Thread Duncan P . N . Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-10-30T14:01:01-04:00
New Revision: 010238a296e61cbf6f4d7f4383e26cf00c4e4992

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

LOG: Speculative fix for bots after 84e8257937ec6a332aa0b688f4dce57016516ffd

I'm not seeing an error locally, but many bots are having a problem with
the call to `hasOptionalValue`. Try to fix it.

Added: 


Modified: 
clang/include/clang/Basic/FileEntry.h

Removed: 




diff  --git a/clang/include/clang/Basic/FileEntry.h 
b/clang/include/clang/Basic/FileEntry.h
index 318aa2cdbb47..03697c584b0b 100644
--- a/clang/include/clang/Basic/FileEntry.h
+++ b/clang/include/clang/Basic/FileEntry.h
@@ -148,7 +148,7 @@ class FileEntryRef {
 
   // Private constructor for use by OptionalStorage.
   FileEntryRef(optional_none_tag) : ME(nullptr) {}
-  bool hasOptionalValue() const { return ME; }
+  constexpr bool hasOptionalValue() const { return ME; }
 
   const MapEntry *ME;
 };



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


[PATCH] D83717: [clang-tidy] Add check fo SEI CERT item ENV32-C

2020-10-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D83717#2364187 , @gamesh411 wrote:

> In D83717#2279263 , @aaron.ballman 
> wrote:
>
>> One of the concerns I have with this not being a cfg-only check is that most 
>> of the bad situations are not going to be caught by the clang-tidy version 
>> of the check.
>
> ...
>
>> Have you run this check over any large code bases to see if it currently 
>> catches any true positive diagnostics?
>
> I have tried llvm, tmux, curl and tried codesearch.com to look for other 
> sources containing `atexit`, but no clang-tidy results were found for this 
> check (this is partly because it is hard to manually make the project results 
> buildable). So it is hard to see whether this flow-sensitive approach would 
> result in many false positives.

Just to make sure we're on the same page -- the current approach is not 
flow-sensitive and so my concern is that it won't report any true positives 
(not that it will be prone to false positives).

Btw, one trick I've used to make random projects easier to work with in 
clang-tidy is to either find ones that support CMake already or if they use 
make, then run the command through `bear` (https://github.com/rizsotto/Bear) -- 
this way I can get a compile_commands.json file that I can use to try to get 
clang-tidy diagnostics out of the project.

In any of the projects that you found which are using `atexit()`, did you try 
to inspect the exit handler code paths to see if you could manually identify 
any problem code (like `assert()` calls)? I realize that's a lot of effort to 
go through (especially if you have to consider C++ constructs like constructors 
or overloaded operators which may be hard to spot by code inspection), but if 
you find the check doesn't trigger on code bases but there are issues when 
manually inspecting the code, that strongly suggests this should be a 
flow-sensitive check that probably lives in the static analyzer rather than 
clang-tidy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83717

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


[clang] 5530fb5 - Speculative fix for bots after 84e8257937ec6a332aa0b688f4dce57016516ffd, v2

2020-10-30 Thread Duncan P . N . Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-10-30T14:04:48-04:00
New Revision: 5530fb586f30da9dcb434f6be39198dbf016b866

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

LOG: Speculative fix for bots after 84e8257937ec6a332aa0b688f4dce57016516ffd, v2

Looks like some bots don't like the defaulted default constructor, try
being explicit.

Added: 


Modified: 
clang/include/clang/Basic/FileEntry.h

Removed: 




diff  --git a/clang/include/clang/Basic/FileEntry.h 
b/clang/include/clang/Basic/FileEntry.h
index 03697c584b0b..89788b1e68f9 100644
--- a/clang/include/clang/Basic/FileEntry.h
+++ b/clang/include/clang/Basic/FileEntry.h
@@ -167,11 +167,12 @@ namespace optional_detail {
 /// Customize OptionalStorage to use FileEntryRef and its
 /// optional_none_tag to keep it the size of a single pointer.
 template <> class OptionalStorage {
-  clang::FileEntryRef MaybeRef = clang::FileEntryRef::optional_none_tag{};
+  clang::FileEntryRef MaybeRef;
 
 public:
   ~OptionalStorage() = default;
-  constexpr OptionalStorage() noexcept = default;
+  constexpr OptionalStorage() noexcept
+  : MaybeRef(clang::FileEntryRef::optional_none_tag) {}
   constexpr OptionalStorage(OptionalStorage const &Other) = default;
   constexpr OptionalStorage(OptionalStorage &&Other) = default;
   OptionalStorage &operator=(OptionalStorage const &Other) = default;



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


[clang] 940d0a3 - Revert "FileManager: Improve the FileEntryRef API and customize its OptionalStorage" and follow-ups

2020-10-30 Thread Duncan P . N . Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2020-10-30T14:06:55-04:00
New Revision: 940d0a310dca31ae97080b068cef92eadfee6367

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

LOG: Revert "FileManager: Improve the FileEntryRef API and customize its 
OptionalStorage" and follow-ups

This reverts commit 5530fb586f30da9dcb434f6be39198dbf016b866.
This reverts commit 010238a296e61cbf6f4d7f4383e26cf00c4e4992.
This reverts commit 84e8257937ec6a332aa0b688f4dce57016516ffd.

Having trouble getting the bots compiling. Will try again later.

Added: 


Modified: 
clang/include/clang/Basic/FileEntry.h
clang/unittests/Basic/CMakeLists.txt
clang/unittests/Basic/FileManagerTest.cpp

Removed: 
clang/unittests/Basic/FileEntryTest.cpp



diff  --git a/clang/include/clang/Basic/FileEntry.h 
b/clang/include/clang/Basic/FileEntry.h
index 89788b1e68f9..65149569bb59 100644
--- a/clang/include/clang/Basic/FileEntry.h
+++ b/clang/include/clang/Basic/FileEntry.h
@@ -31,22 +31,6 @@ class File;
 
 namespace clang {
 
-class FileEntryRef;
-
-} // namespace clang
-
-namespace llvm {
-namespace optional_detail {
-
-/// Forward declare a template specialization for OptionalStorage.
-template <>
-class OptionalStorage;
-
-} // namespace optional_detail
-} // namespace llvm
-
-namespace clang {
-
 class DirectoryEntry;
 class FileEntry;
 
@@ -54,9 +38,9 @@ class FileEntry;
 /// accessed by the FileManager's client.
 class FileEntryRef {
 public:
-  StringRef getName() const { return ME->first(); }
+  const StringRef getName() const { return Entry->first(); }
   const FileEntry &getFileEntry() const {
-return *ME->second->V.get();
+return *Entry->second->V.get();
   }
 
   inline bool isValid() const;
@@ -65,26 +49,12 @@ class FileEntryRef {
   inline const llvm::sys::fs::UniqueID &getUniqueID() const;
   inline time_t getModificationTime() const;
 
-  /// Check if the underlying FileEntry is the same, intentially ignoring
-  /// whether the file was referenced with the same spelling of the filename.
   friend bool operator==(const FileEntryRef &LHS, const FileEntryRef &RHS) {
-return &LHS.getFileEntry() == &RHS.getFileEntry();
-  }
-  friend bool operator==(const FileEntry *LHS, const FileEntryRef &RHS) {
-return LHS == &RHS.getFileEntry();
-  }
-  friend bool operator==(const FileEntryRef &LHS, const FileEntry *RHS) {
-return &LHS.getFileEntry() == RHS;
+return LHS.Entry == RHS.Entry;
   }
   friend bool operator!=(const FileEntryRef &LHS, const FileEntryRef &RHS) {
 return !(LHS == RHS);
   }
-  friend bool operator!=(const FileEntry *LHS, const FileEntryRef &RHS) {
-return !(LHS == RHS);
-  }
-  friend bool operator!=(const FileEntryRef &LHS, const FileEntry *RHS) {
-return !(LHS == RHS);
-  }
 
   struct MapValue;
 
@@ -108,191 +78,20 @@ class FileEntryRef {
 MapValue(MapEntry &ME) : V(&ME) {}
   };
 
-  /// Check if RHS referenced the file in exactly the same way.
-  bool isSameRef(const FileEntryRef &RHS) const { return ME == RHS.ME; }
-
-  /// Allow FileEntryRef to degrade into 'const FileEntry*' to facilitate
-  /// incremental adoption.
-  ///
-  /// The goal is to avoid code churn due to dances like the following:
-  /// \code
-  /// // Old code.
-  /// lvalue = rvalue;
-  ///
-  /// // Temporary code from an incremental patch.
-  /// lvalue = &rvalue.getFileEntry();
-  ///
-  /// // Final code.
-  /// lvalue = rvalue;
-  /// \endcode
-  ///
-  /// FIXME: Once FileEntryRef is "everywhere" and FileEntry::LastRef and
-  /// FileEntry::getName have been deleted, delete this implicit conversion.
-  operator const FileEntry *() const { return &getFileEntry(); }
-
-  FileEntryRef() = delete;
-  explicit FileEntryRef(const MapEntry &ME) : ME(&ME) {
-assert(ME.second && "Expected payload");
-assert(ME.second->V && "Expected non-null");
-assert(ME.second->V.is() && "Expected FileEntry");
-  }
-
-  /// Expose the underlying MapEntry to simplify packing in a PointerIntPair or
-  /// PointerUnion and allow construction in Optional.
-  const clang::FileEntryRef::MapEntry &getMapEntry() const { return *ME; }
-
 private:
-  friend class llvm::optional_detail::OptionalStorage<
-  FileEntryRef, /*is_trivially_copyable*/ true>;
-  struct optional_none_tag {};
-
-  // Private constructor for use by OptionalStorage.
-  FileEntryRef(optional_none_tag) : ME(nullptr) {}
-  constexpr bool hasOptionalValue() const { return ME; }
-
-  const MapEntry *ME;
-};
-
-static_assert(sizeof(FileEntryRef) == sizeof(const FileEntry *),
-  "FileEntryRef must avoid size overhead");
-
-static_assert(std::is_trivially_copyable::value,
-  "FileEntryRef must be trivially copyable");
-
-} // end namespace clang
-
-namespace llvm {
-namespace optional_detail {
-
-/// 

[PATCH] D90336: [Sema] Diagnose annotating `if constexpr` with a likelihood attribute

2020-10-30 Thread Mark de Wever via Phabricator via cfe-commits
Mordante marked an inline comment as done.
Mordante added a comment.

Thanks for the review!




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3163
 def note_attribute_has_no_effect_here : Note<
-  "annotating the %select{infinite loop}0 here">;
+  "annotating the %select{infinite loop|'if constexpr' statement}0 here">;
 def err_decl_attribute_invalid_on_stmt : Error<

rjmccall wrote:
> This isn't a useful form of re-use.  The problem is that the original note is 
> pretending to be generic when it really isn't; please rename it to something 
> like `note_annotating_infinite_loop_here` (maybe in a different patch).  This 
> patch should just add a new note.
I'll fix it. I'll also change the warn at line 3158, since that uses the same 
select.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90336

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


[PATCH] D89899: [CodeGen] Implement [[likely]] and [[unlikely]] for the iteration statements

2020-10-30 Thread Mark de Wever via Phabricator via cfe-commits
Mordante marked an inline comment as done.
Mordante added a comment.

Thanks for the review.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3161
+   InGroup;
+def note_attribute_has_no_effect_here : Note<
+  "annotating the %select{infinite loop}0 here">;

aaron.ballman wrote:
> As @rjmccall pointed out in the other review, this isn't really a generic 
> note. I'd mildly recommend renaming the note and removing the select.
I'll do that and the same for the warn.


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

https://reviews.llvm.org/D89899

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


  1   2   >