[PATCH] D137309: [clang] Added Swift support for RISCV

2022-11-14 Thread Alsey Coleman Miller via Phabricator via cfe-commits
colemancda added a comment.

In D137309#3914550 , @asb wrote:

> In D137309#3914494 , @colemancda 
> wrote:
>
>> RV32 is enabled as well. I'll add unit tests.
>
> Great, thanks. Is it really the case that shouldPassIndirectlyForSwift has 
> the same result regardless of native word size?

Yes, if you check other implementations like Arm and AArch64, the 
implementation is the same.
Where is a good place to start for the unit test development for this ABI?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137309

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


[PATCH] D136354: [Driver] Enable nested configuration files

2022-11-14 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 475349.
sepavloff added a comment.

Removed support of `--config file`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136354

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/Inputs/config-6.cfg
  clang/test/Driver/config-file-errs.c
  clang/test/Driver/config-file.c
  clang/unittests/Driver/ToolChainTest.cpp
  llvm/lib/Support/CommandLine.cpp

Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -1191,27 +1191,44 @@
 return Error::success();
 
   StringRef BasePath = llvm::sys::path::parent_path(FName);
-  for (auto I = NewArgv.begin(), E = NewArgv.end(); I != E; ++I) {
-const char *&Arg = *I;
-if (Arg == nullptr)
+  for (const char *&Arg : NewArgv) {
+if (!Arg)
   continue;
 
 // Substitute  with the file's base path.
 if (InConfigFile)
   ExpandBasePaths(BasePath, Saver, Arg);
 
-// Get expanded file name.
-StringRef FileName(Arg);
-if (!FileName.consume_front("@"))
-  continue;
-if (!llvm::sys::path::is_relative(FileName))
+// Discover the case, when argument should be transformed into '@file' and
+// evaluate 'file' for it.
+StringRef ArgStr(Arg);
+StringRef FileName;
+bool ConfigInclusion = false;
+if (ArgStr.consume_front("@")) {
+  FileName = ArgStr;
+  if (!llvm::sys::path::is_relative(FileName))
+continue;
+} else if (ArgStr.consume_front("--config=")) {
+  FileName = ArgStr;
+  ConfigInclusion = true;
+} else {
   continue;
+}
 
 // Update expansion construct.
 SmallString<128> ResponseFile;
 ResponseFile.push_back('@');
-ResponseFile.append(BasePath);
-llvm::sys::path::append(ResponseFile, FileName);
+if (ConfigInclusion && !llvm::sys::path::has_parent_path(FileName)) {
+  SmallString<128> FilePath;
+  if (!findConfigFile(FileName, FilePath))
+return createStringError(
+std::make_error_code(std::errc::no_such_file_or_directory),
+"cannot not find configuration file: " + FileName);
+  ResponseFile.append(FilePath);
+} else {
+  ResponseFile.append(BasePath);
+  llvm::sys::path::append(ResponseFile, FileName);
+}
 Arg = Saver.save(ResponseFile.str()).data();
   }
   return Error::success();
Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -652,4 +652,58 @@
 #undef INCLUDED1
 }
 
+TEST(ToolChainTest, NestedConfigFile) {
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+  struct TestDiagnosticConsumer : public DiagnosticConsumer {};
+  DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
+  IntrusiveRefCntPtr FS(
+  new llvm::vfs::InMemoryFileSystem);
+
+#ifdef _WIN32
+  const char *TestRoot = "C:\\";
+#else
+  const char *TestRoot = "/";
+#endif
+  FS->setCurrentWorkingDirectory(TestRoot);
+
+  FS->addFile("/opt/sdk/root.cfg", 0,
+  llvm::MemoryBuffer::getMemBuffer("--config platform.cfg\n"));
+  FS->addFile("/opt/sdk/root2.cfg", 0,
+  llvm::MemoryBuffer::getMemBuffer("--config=platform.cfg\n"));
+  FS->addFile("/opt/sdk/platform.cfg", 0,
+  llvm::MemoryBuffer::getMemBuffer("--sysroot=/platform-sys\n"));
+  FS->addFile("/home/test/bin/platform.cfg", 0,
+  llvm::MemoryBuffer::getMemBuffer("--sysroot=/platform-bin\n"));
+
+  SmallString<128> ClangExecutable("/home/test/bin/clang");
+  FS->makeAbsolute(ClangExecutable);
+
+  // User file is absent - use system definitions.
+  {
+Driver TheDriver(ClangExecutable, "arm-linux-gnueabi", Diags,
+ "clang LLVM compiler", FS);
+std::unique_ptr C(TheDriver.BuildCompilation(
+{"/home/test/bin/clang", "--config", "root.cfg",
+ "--config-system-dir=/opt/sdk", "--config-user-dir=/home/test/sdk"}));
+ASSERT_TRUE(C);
+ASSERT_FALSE(C->containsError());
+EXPECT_EQ("/platform-sys", TheDriver.SysRoot);
+  }
+
+  // User file overrides system definitions.
+  FS->addFile("/home/test/sdk/platform.cfg", 0,
+  llvm::MemoryBuffer::getMemBuffer("--sysroot=/platform-user\n"));
+  {
+Driver TheDriver(ClangExecutable, "arm-linux-gnueabi", Diags,
+ "clang LLVM compiler", FS);
+std::unique_ptr C(TheDriver.BuildCompilation(
+{"/home/test/bin/clang", "--config", "root2.cfg",
+ "--config-system-dir=/opt/sdk", "--config-user-dir=/home/test/sdk"}));
+ASSERT_TRUE(C);
+ASSERT_FALSE(C->containsError());
+EXPECT_EQ("/platform-user", TheDr

[PATCH] D137473: [vfs] Allow root paths relative to the directory of the vfsoverlay YAML file

2022-11-14 Thread Haowei Wu via Phabricator via cfe-commits
haowei updated this revision to Diff 475347.
haowei added a comment.

Unit test failures under Windows should be fixed now.

Root->name will also use base FS's current directory instead of process current 
directory now. Please take a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137473

Files:
  clang/test/VFS/Inputs/root-relative-overlay.yaml
  clang/test/VFS/relative-path.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1452,18 +1452,20 @@
 
   std::unique_ptr
   getFromYAMLRawString(StringRef Content,
-   IntrusiveRefCntPtr ExternalFS) {
+   IntrusiveRefCntPtr ExternalFS,
+   StringRef YAMLFilePath = "") {
 std::unique_ptr Buffer = MemoryBuffer::getMemBuffer(Content);
-return getVFSFromYAML(std::move(Buffer), CountingDiagHandler, "", this,
-  ExternalFS);
+return getVFSFromYAML(std::move(Buffer), CountingDiagHandler, YAMLFilePath,
+  this, ExternalFS);
   }
 
   std::unique_ptr getFromYAMLString(
   StringRef Content,
-  IntrusiveRefCntPtr ExternalFS = new DummyFileSystem()) {
+  IntrusiveRefCntPtr ExternalFS = new DummyFileSystem(),
+  StringRef YAMLFilePath = "") {
 std::string VersionPlusContent("{\n  'version':0,\n");
 VersionPlusContent += Content.slice(Content.find('{') + 1, StringRef::npos);
-return getFromYAMLRawString(VersionPlusContent, ExternalFS);
+return getFromYAMLRawString(VersionPlusContent, ExternalFS, YAMLFilePath);
   }
 
   // This is intended as a "XFAIL" for windows hosts.
@@ -1849,6 +1851,45 @@
   EXPECT_EQ(0, NumDiagnostics);
 }
 
+TEST_F(VFSFromYAMLTest, RootRelativeTest) {
+  IntrusiveRefCntPtr Lower(new DummyFileSystem());
+  Lower->addDirectory("//root/foo/bar");
+  Lower->addRegularFile("//root/foo/bar/a");
+  IntrusiveRefCntPtr FS =
+  getFromYAMLString("{\n"
+"  'case-sensitive': false,\n"
+"  'root-relative': 'overlay-dir',\n"
+"  'roots': [\n"
+"{ 'name': 'b', 'type': 'file',\n"
+"  'external-contents': '//root/foo/bar/a'\n"
+"}\n"
+"  ]\n"
+"}",
+Lower, "//root/foo/bar/overlay");
+
+  ASSERT_NE(FS.get(), nullptr);
+  ErrorOr S = FS->status("//root/foo/bar/b");
+  ASSERT_FALSE(S.getError());
+  EXPECT_EQ("//root/foo/bar/a", S->getName());
+
+  IntrusiveRefCntPtr FSOverlayRelative =
+  getFromYAMLString("{\n"
+"  'case-sensitive': false,\n"
+"  'overlay-relative': true,\n"
+"  'root-relative': 'overlay-dir',\n"
+"  'roots': [\n"
+"{ 'name': 'b', 'type': 'file',\n"
+"  'external-contents': 'a'\n"
+"}\n"
+"  ]\n"
+"}",
+Lower, "//root/foo/bar/overlay");
+  ASSERT_NE(FSOverlayRelative.get(), nullptr);
+  ErrorOr SOverlayRelative = FS->status("//root/foo/bar/b");
+  ASSERT_FALSE(SOverlayRelative.getError());
+  EXPECT_EQ("//root/foo/bar/a", SOverlayRelative->getName());
+}
+
 TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
   IntrusiveRefCntPtr BaseFS(
   new vfs::InMemoryFileSystem);
Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -1356,22 +1356,32 @@
   if (!WorkingDir)
 return WorkingDir.getError();
 
+  return makeAbsolute(WorkingDir.get(), Path);
+}
+
+std::error_code
+RedirectingFileSystem::makeAbsolute(StringRef WorkingDir,
+SmallVectorImpl &Path) const {
   // We can't use sys::fs::make_absolute because that assumes the path style
   // is native and there is no way to override that.  Since we know WorkingDir
   // is absolute, we can use it to determine which style we actually have and
   // append Path ourselves.
+  if (!sys::path::is_absolute(WorkingDir, sys::path::Style::posix) &&
+  !sys::path::is_absolute(WorkingDir,
+  sys::path::Style::windows_backslash)) {
+return std::error_code();
+  }
   sys::path::Style style = sys::path::Style::windows_backslash;
-  if (sys::path::is_absolute(WorkingDir.get(), sys::path::Style::posix)) {
+  if (sys::path::is_absolute(WorkingDir, sys::path::Sty

[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2022-11-14 Thread Dhruva Chakrabarti via Phabricator via cfe-commits
dhruvachak added a comment.

@jhuber6

Turns out a rebase on top of trunk had ~200 test conflicts. During my last 
update in Sep, I had resolved all of the clang test conflicts and failures, 
there were only llvm test failures.

At this point, I checked out commit 92bc3fb5 
 for all 
the failed tests (both clang and llvm tests) and then ran 
update_cc_test_checks.py on all of the auto-generated clang tests with the 
updated compiler. After this update, the test results look like the following:

make check-clang: Some of these may be new since the last iteration. But I 
believe most of them need some manual updates. I did not check all of the 7 
tests below but I believe most of them are not autogenerated. I suggest looking 
at them after the llvm tests are regenerated properly.



Failed Tests (7):

  Clang :: CodeGen/PowerPC/ppc64le-varargs-f128.c
  Clang :: OpenMP/nvptx_target_printf_codegen.c
  Clang :: OpenMP/parallel_copyin_combined_codegen.c
  Clang :: OpenMP/target_globals_codegen.cpp
  Clang :: OpenMP/target_map_codegen_hold.cpp
  Clang :: OpenMP/task_target_device_codegen.c
  Clang :: OpenMP/unroll_codegen_parallel_for_factor.cpp

Testing Time: 47.70s

  Skipped  : 4
  Unsupported  :  1490
  Passed   : 30113
  Expectedly Failed:28
  Failed   : 7

make check-llvm: Other than spmdization_constant_prop, I think the rest of them 
have a C code snippet. These are the ones to look at first. These tests are not 
updated in the current rebased version. You may see the updates I made to them 
from the previous commit.



Failed Tests (9):

  LLVM :: Transforms/OpenMP/custom_state_machines.ll
  LLVM :: Transforms/OpenMP/custom_state_machines_remarks.ll
  LLVM :: Transforms/OpenMP/gpu_state_machine_function_ptr_replacement.ll
  LLVM :: Transforms/OpenMP/spmdization.ll
  LLVM :: Transforms/OpenMP/spmdization_assumes.ll
  LLVM :: Transforms/OpenMP/spmdization_constant_prop.ll
  LLVM :: Transforms/OpenMP/spmdization_guarding.ll
  LLVM :: Transforms/OpenMP/spmdization_guarding_two_reaching_kernels.ll
  LLVM :: Transforms/OpenMP/spmdization_remarks.ll

Testing Time: 58.80s

  Skipped  :59
  Unsupported  : 19062
  Passed   : 31988
  Expectedly Failed:69
  Failed   : 9

make check-openmp: On amdgpu, this looks good.



Expectedly Failed Tests (12):

  libomptarget :: amdgcn-amd-amdhsa :: mapping/data_member_ref.cpp
  libomptarget :: amdgcn-amd-amdhsa :: 
mapping/declare_mapper_nested_default_mappers.cpp
  libomptarget :: amdgcn-amd-amdhsa :: mapping/declare_mapper_nested_mappers.cpp
  libomptarget :: amdgcn-amd-amdhsa :: mapping/lambda_by_value.cpp
  libomptarget :: amdgcn-amd-amdhsa :: mapping/ompx_hold/struct.c
  libomptarget :: amdgcn-amd-amdhsa :: offloading/host_as_target.c
  libomptarget :: amdgcn-amd-amdhsa-LTO :: mapping/data_member_ref.cpp
  libomptarget :: amdgcn-amd-amdhsa-LTO :: 
mapping/declare_mapper_nested_default_mappers.cpp
  libomptarget :: amdgcn-amd-amdhsa-LTO :: 
mapping/declare_mapper_nested_mappers.cpp
  libomptarget :: amdgcn-amd-amdhsa-LTO :: mapping/lambda_by_value.cpp
  libomptarget :: amdgcn-amd-amdhsa-LTO :: mapping/ompx_hold/struct.c
  libomptarget :: amdgcn-amd-amdhsa-LTO :: offloading/host_as_target.c

Testing Time: 145.83s

  Unsupported  : 139
  Passed   : 613
  Expectedly Failed:  12

[100%] Built target check-openmp
[100%] Built target check-openmp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[libunwind] c507269 - [libunwind][LoongArch] Add 64-bit LoongArch support

2022-11-14 Thread Weining Lu via cfe-commits

Author: zhanglimin
Date: 2022-11-15T14:37:00+08:00
New Revision: c5072695127e767a76973cdbed683215df31fa40

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

LOG: [libunwind][LoongArch] Add 64-bit LoongArch support

Defines enums for the LoongArch registers.
Adds the register class implementation for LoongArch.
Adds save and restore context functionality.

This only supports 64 bits integer and float-point register
implementation.

Fix https://github.com/llvm/llvm-project/issues/55398

Reviewed By: SixWeining

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

Added: 


Modified: 
libunwind/include/__libunwind_config.h
libunwind/include/libunwind.h
libunwind/src/Registers.hpp
libunwind/src/UnwindCursor.hpp
libunwind/src/UnwindRegistersRestore.S
libunwind/src/UnwindRegistersSave.S
libunwind/src/config.h
libunwind/src/libunwind.cpp

Removed: 




diff  --git a/libunwind/include/__libunwind_config.h 
b/libunwind/include/__libunwind_config.h
index 5e9de90f649f..f69fe89e9a26 100644
--- a/libunwind/include/__libunwind_config.h
+++ b/libunwind/include/__libunwind_config.h
@@ -30,6 +30,7 @@
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_RISCV 64
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_VE143
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_S390X 83
+#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_LOONGARCH 64
 
 #if defined(_LIBUNWIND_IS_NATIVE_ONLY)
 # if defined(__linux__)
@@ -166,6 +167,16 @@
 #  define _LIBUNWIND_CONTEXT_SIZE 34
 #  define _LIBUNWIND_CURSOR_SIZE 46
 #  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_S390X
+#elif defined(__loongarch__)
+#define _LIBUNWIND_TARGET_LOONGARCH 1
+#if __loongarch_grlen == 64
+#define _LIBUNWIND_CONTEXT_SIZE 65
+#define _LIBUNWIND_CURSOR_SIZE 77
+#else
+#error "Unsupported LoongArch ABI"
+#endif
+#define _LIBUNWIND_HIGHEST_DWARF_REGISTER  
\
+  _LIBUNWIND_HIGHEST_DWARF_REGISTER_LOONGARCH
 # else
 #  error "Unsupported architecture."
 # endif
@@ -185,6 +196,7 @@
 # define _LIBUNWIND_TARGET_RISCV 1
 # define _LIBUNWIND_TARGET_VE 1
 # define _LIBUNWIND_TARGET_S390X 1
+#define _LIBUNWIND_TARGET_LOONGARCH 1
 # define _LIBUNWIND_CONTEXT_SIZE 167
 # define _LIBUNWIND_CURSOR_SIZE 179
 # define _LIBUNWIND_HIGHEST_DWARF_REGISTER 287

diff  --git a/libunwind/include/libunwind.h b/libunwind/include/libunwind.h
index f878b46f0348..8c8cf8f53338 100644
--- a/libunwind/include/libunwind.h
+++ b/libunwind/include/libunwind.h
@@ -1219,4 +1219,72 @@ enum {
   // 68-83 Vector Registers %v16-%v31
 };
 
+// LoongArch registers.
+enum {
+  UNW_LOONGARCH_R0 = 0,
+  UNW_LOONGARCH_R1 = 1,
+  UNW_LOONGARCH_R2 = 2,
+  UNW_LOONGARCH_R3 = 3,
+  UNW_LOONGARCH_R4 = 4,
+  UNW_LOONGARCH_R5 = 5,
+  UNW_LOONGARCH_R6 = 6,
+  UNW_LOONGARCH_R7 = 7,
+  UNW_LOONGARCH_R8 = 8,
+  UNW_LOONGARCH_R9 = 9,
+  UNW_LOONGARCH_R10 = 10,
+  UNW_LOONGARCH_R11 = 11,
+  UNW_LOONGARCH_R12 = 12,
+  UNW_LOONGARCH_R13 = 13,
+  UNW_LOONGARCH_R14 = 14,
+  UNW_LOONGARCH_R15 = 15,
+  UNW_LOONGARCH_R16 = 16,
+  UNW_LOONGARCH_R17 = 17,
+  UNW_LOONGARCH_R18 = 18,
+  UNW_LOONGARCH_R19 = 19,
+  UNW_LOONGARCH_R20 = 20,
+  UNW_LOONGARCH_R21 = 21,
+  UNW_LOONGARCH_R22 = 22,
+  UNW_LOONGARCH_R23 = 23,
+  UNW_LOONGARCH_R24 = 24,
+  UNW_LOONGARCH_R25 = 25,
+  UNW_LOONGARCH_R26 = 26,
+  UNW_LOONGARCH_R27 = 27,
+  UNW_LOONGARCH_R28 = 28,
+  UNW_LOONGARCH_R29 = 29,
+  UNW_LOONGARCH_R30 = 30,
+  UNW_LOONGARCH_R31 = 31,
+  UNW_LOONGARCH_F0 = 32,
+  UNW_LOONGARCH_F1 = 33,
+  UNW_LOONGARCH_F2 = 34,
+  UNW_LOONGARCH_F3 = 35,
+  UNW_LOONGARCH_F4 = 36,
+  UNW_LOONGARCH_F5 = 37,
+  UNW_LOONGARCH_F6 = 38,
+  UNW_LOONGARCH_F7 = 39,
+  UNW_LOONGARCH_F8 = 40,
+  UNW_LOONGARCH_F9 = 41,
+  UNW_LOONGARCH_F10 = 42,
+  UNW_LOONGARCH_F11 = 43,
+  UNW_LOONGARCH_F12 = 44,
+  UNW_LOONGARCH_F13 = 45,
+  UNW_LOONGARCH_F14 = 46,
+  UNW_LOONGARCH_F15 = 47,
+  UNW_LOONGARCH_F16 = 48,
+  UNW_LOONGARCH_F17 = 49,
+  UNW_LOONGARCH_F18 = 50,
+  UNW_LOONGARCH_F19 = 51,
+  UNW_LOONGARCH_F20 = 52,
+  UNW_LOONGARCH_F21 = 53,
+  UNW_LOONGARCH_F22 = 54,
+  UNW_LOONGARCH_F23 = 55,
+  UNW_LOONGARCH_F24 = 56,
+  UNW_LOONGARCH_F25 = 57,
+  UNW_LOONGARCH_F26 = 58,
+  UNW_LOONGARCH_F27 = 59,
+  UNW_LOONGARCH_F28 = 60,
+  UNW_LOONGARCH_F29 = 61,
+  UNW_LOONGARCH_F30 = 62,
+  UNW_LOONGARCH_F31 = 63,
+};
+
 #endif

diff  --git a/libunwind/src/Registers.hpp b/libunwind/src/Registers.hpp
index e5fde6888fe6..ff736ca9e8b3 100644
--- a/libunwind/src/Registers.hpp
+++ b/libunwind/src/Registers.hpp
@@ -40,6 +40,7 @@ enum {
   REGISTERS_RISCV,
   REGISTERS_VE,
   REGISTERS_S390X,
+  REGISTERS_LOONGARCH,
 };
 
 #if defined(_LIBUNWIND_TARGET_I386)
@@ -5031,6 +5032,271 @@ inline const char *Registers_s390x::getRegisterName(int 
regNum) {
 }
 #endif // _LIBUNWIND_TARGET_S390X

[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2022-11-14 Thread Dhruva Chakrabarti via Phabricator via cfe-commits
dhruvachak updated this revision to Diff 475341.
dhruvachak edited the summary of this revision.
dhruvachak added a comment.
Herald added subscribers: kosarev, jvesely.

Rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/AST/ast-dump-openmp-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for.c
  clang/test/OpenMP/align_clause_codegen.cpp
  clang/test/OpenMP/amdgcn_target_global_constructor.cpp
  clang/test/OpenMP/atomic_compare_codegen.cpp
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/cancellation_point_codegen.cpp
  clang/test/OpenMP/debug-info-complex-byval.cpp
  clang/test/OpenMP/debug-info-openmp-array.cpp
  clang/test/OpenMP/debug_threadprivate_copyin.c
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_variant_construct_codegen_1.c
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/for_lastprivate_codegen.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen_UDR.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/interop_irbuilder.cpp
  clang/test/OpenMP/irbuilder_for_unsigned_auto.c
  clang/test/OpenMP/irbuilder_for_unsigned_down.c
  clang/test/OpenMP/irbuilder_for_unsigned_dynamic.c
  clang/test/OpenMP/irbuilder_for_unsigned_dynamic_chunked.c
  clang/test/OpenMP/irbuilder_for_unsigned_runtime.c
  clang/test/OpenMP/irbuilder_for_unsigned_static_chunked.c
  clang/test/OpenMP/irbuilder_nested_parallel_for.c
  clang/test/OpenMP/irbuilder_safelen.cpp
  clang/test/OpenMP/irbuilder_safelen_order_concurrent.cpp
  clang/test/OpenMP/irbuilder_simd_aligned.cpp
  clang/test/OpenMP/irbuilder_simdlen.cpp
  clang/test/OpenMP/irbuilder_simdlen_safelen.cpp
  clang/test/OpenMP/irbuilder_unroll_full.c
  clang/test/OpenMP/irbuilder_unroll_heuristic.c
  clang/test/OpenMP/irbuilder_unroll_partial_factor.c
  clang/test/OpenMP/irbuilder_unroll_partial_factor_for.c
  clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c
  clang/test/OpenMP/irbuilder_unroll_partial_heuristic.c
  clang/test/OpenMP/irbuilder_unroll_partial_heuristic_constant_for.c
  clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c
  clang/test/OpenMP/irbuilder_unroll_partial_heuristic_runtime_for.c
  clang/test/OpenMP/irbuilder_unroll_unroll_partial_factor.c
  clang/test/OpenMP/irbuilder_unroll_unroll_partial_heuristic.c
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_in_reduction_codegen.cpp
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codeg

[PATCH] D136354: [Driver] Enable nested configuration files

2022-11-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/lib/Support/CommandLine.cpp:1215-1222
+} else if (ArgStr == "--config") {
+  if (I + 1 == E)
+return createStringError(std::errc::invalid_argument,
+ "Option '--config' requires an argument");
+  I = NewArgv.erase(I);
+  E = NewArgv.end();
+  FileName = *I;

mgorny wrote:
> Not sure if we want to add extra complexity for the legacy spelling here. 
> @MaskRay, what do you think?
I agree. Supporting just `--config=` suffices.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136354

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


[PATCH] D136354: [Driver] Enable nested configuration files

2022-11-14 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: llvm/lib/Support/CommandLine.cpp:1215-1222
+} else if (ArgStr == "--config") {
+  if (I + 1 == E)
+return createStringError(std::errc::invalid_argument,
+ "Option '--config' requires an argument");
+  I = NewArgv.erase(I);
+  E = NewArgv.end();
+  FileName = *I;

Not sure if we want to add extra complexity for the legacy spelling here. 
@MaskRay, what do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136354

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


[PATCH] D137512: [clang] Add Swift support for MIPS

2022-11-14 Thread Alsey Coleman Miller via Phabricator via cfe-commits
colemancda updated this revision to Diff 475337.
colemancda added a comment.

Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137512

Files:
  clang/lib/Basic/Targets/Mips.h
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -7864,7 +7864,7 @@
 
//===--===//
 
 namespace {
-class MipsABIInfo : public ABIInfo {
+class MipsABIInfo : public SwiftABIInfo {
   bool IsO32;
   const unsigned MinABIStackAlignInBytes, StackAlignInBytes;
   void CoerceToIntArgs(uint64_t TySize,
@@ -7873,9 +7873,10 @@
   llvm::Type* returnAggregateInRegs(QualType RetTy, uint64_t Size) const;
   llvm::Type* getPaddingType(uint64_t Align, uint64_t Offset) const;
 public:
-  MipsABIInfo(CodeGenTypes &CGT, bool _IsO32) :
-ABIInfo(CGT), IsO32(_IsO32), MinABIStackAlignInBytes(IsO32 ? 4 : 8),
-StackAlignInBytes(IsO32 ? 8 : 16) {}
+  MipsABIInfo(CodeGenTypes &CGT, bool _IsO32)
+  : SwiftABIInfo(CGT), IsO32(_IsO32),
+MinABIStackAlignInBytes(IsO32 ? 4 : 8),
+StackAlignInBytes(IsO32 ? 8 : 16) {}
 
   ABIArgInfo classifyReturnType(QualType RetTy) const;
   ABIArgInfo classifyArgumentType(QualType RetTy, uint64_t &Offset) const;
@@ -7883,6 +7884,14 @@
   Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType Ty) const override;
   ABIArgInfo extendType(QualType Ty) const;
+
+private:
+  bool shouldPassIndirectlyForSwift(ArrayRef scalars,
+bool asReturnValue) const override {
+return occupiesMoreThan(CGT, scalars, /*total*/ 4);
+  }
+
+  bool isSwiftErrorInRegister() const override { return false; }
 };
 
 class MIPSTargetCodeGenInfo : public TargetCodeGenInfo {
Index: clang/lib/Basic/Targets/Mips.h
===
--- clang/lib/Basic/Targets/Mips.h
+++ clang/lib/Basic/Targets/Mips.h
@@ -407,6 +407,17 @@
 
   bool validateTarget(DiagnosticsEngine &Diags) const override;
   bool hasBitIntType() const override { return true; }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+switch (CC) {
+case CC_Swift:
+  return CCCR_OK;
+case CC_SwiftAsync:
+  return CCCR_Error;
+default:
+  return CCCR_Warning;
+}
+  }
 };
 } // namespace targets
 } // namespace clang


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -7864,7 +7864,7 @@
 //===--===//
 
 namespace {
-class MipsABIInfo : public ABIInfo {
+class MipsABIInfo : public SwiftABIInfo {
   bool IsO32;
   const unsigned MinABIStackAlignInBytes, StackAlignInBytes;
   void CoerceToIntArgs(uint64_t TySize,
@@ -7873,9 +7873,10 @@
   llvm::Type* returnAggregateInRegs(QualType RetTy, uint64_t Size) const;
   llvm::Type* getPaddingType(uint64_t Align, uint64_t Offset) const;
 public:
-  MipsABIInfo(CodeGenTypes &CGT, bool _IsO32) :
-ABIInfo(CGT), IsO32(_IsO32), MinABIStackAlignInBytes(IsO32 ? 4 : 8),
-StackAlignInBytes(IsO32 ? 8 : 16) {}
+  MipsABIInfo(CodeGenTypes &CGT, bool _IsO32)
+  : SwiftABIInfo(CGT), IsO32(_IsO32),
+MinABIStackAlignInBytes(IsO32 ? 4 : 8),
+StackAlignInBytes(IsO32 ? 8 : 16) {}
 
   ABIArgInfo classifyReturnType(QualType RetTy) const;
   ABIArgInfo classifyArgumentType(QualType RetTy, uint64_t &Offset) const;
@@ -7883,6 +7884,14 @@
   Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType Ty) const override;
   ABIArgInfo extendType(QualType Ty) const;
+
+private:
+  bool shouldPassIndirectlyForSwift(ArrayRef scalars,
+bool asReturnValue) const override {
+return occupiesMoreThan(CGT, scalars, /*total*/ 4);
+  }
+
+  bool isSwiftErrorInRegister() const override { return false; }
 };
 
 class MIPSTargetCodeGenInfo : public TargetCodeGenInfo {
Index: clang/lib/Basic/Targets/Mips.h
===
--- clang/lib/Basic/Targets/Mips.h
+++ clang/lib/Basic/Targets/Mips.h
@@ -407,6 +407,17 @@
 
   bool validateTarget(DiagnosticsEngine &Diags) const override;
   bool hasBitIntType() const override { return true; }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
+switch (CC) {
+case CC_Swift:
+  return CCCR_OK;
+case CC_SwiftAsync:
+  return CCCR_Error;
+default:
+  return CCCR_Warning;
+}
+  }
 };
 } // namespace targets
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llv

[PATCH] D136786: Fix `unsafe-fp-math` attribute emission.

2022-11-14 Thread Michele Scandale via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb7d7c448df9a: Fix `unsafe-fp-math` attribute emission. 
(authored by michele.scandale).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136786

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/fp-function-attrs.cpp
  clang/test/CodeGen/func-attr.c

Index: clang/test/CodeGen/func-attr.c
===
--- clang/test/CodeGen/func-attr.c
+++ clang/test/CodeGen/func-attr.c
@@ -1,12 +1,28 @@
-// RUN: %clang -c -target x86_64 -ffast-math \
-// RUN: -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -ffast-math \
+// RUN: -ffp-contract=fast -emit-llvm -o - %s | \
+// RUN: FileCheck %s --check-prefixes=CHECK,CHECK-UNSAFE
 
-// RUN: %clang -c -target x86_64 -funsafe-math-optimizations \
-// RUN: -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -funsafe-math-optimizations \
+// RUN: -ffp-contract=fast -emit-llvm -o - %s | \
+// RUN: FileCheck %s --check-prefixes=CHECK,CHECK-UNSAFE
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -funsafe-math-optimizations \
+// RUN: -ffp-contract=on -emit-llvm -o - %s | \
+// RUN: FileCheck %s --check-prefixes=CHECK,CHECK-NOUNSAFE
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -funsafe-math-optimizations \
+// RUN: -ffp-contract=off -emit-llvm -o - %s | \
+// RUN: FileCheck %s --check-prefixes=CHECK,CHECK-NOUNSAFE
 
 float foo(float a, float b) {
   return a+b;
 }
 
-// CHECK: define{{.*}} float @foo(float noundef %{{.*}}, float noundef %{{.*}}){{.*}} [[FAST_ATTRS:#[0-9]+]]
-// CHECK: attributes [[FAST_ATTRS]] = { {{.*}} "approx-func-fp-math"="true" {{.*}} "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" {{.*}} "unsafe-fp-math"="true"
+// CHECK:  define{{.*}} float @foo(float noundef %{{.*}}, float noundef %{{.*}}){{.*}} [[ATTRS:#[0-9]+]]
+// CHECK:  attributes [[ATTRS]] = {
+// CHECK-SAME:   "approx-func-fp-math"="true"
+// CHECK-SAME:   "no-signed-zeros-fp-math"="true"
+// CHECK-SAME:   "no-trapping-math"="true"
+// CHECK-UNSAFE-SAME:"unsafe-fp-math"="true"
+// CHECK-NOUNSAFE-NOT:   "unsafe-fp-math"="true"
+// CHECK-SAME: }
Index: clang/test/CodeGen/fp-function-attrs.cpp
===
--- clang/test/CodeGen/fp-function-attrs.cpp
+++ clang/test/CodeGen/fp-function-attrs.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -ffast-math -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -ffast-math -ffp-contract=fast-honor-pragmas -emit-llvm -o - %s | FileCheck %s
 
 float test_default(float a, float b, float c) {
   float tmp = a;
@@ -35,10 +36,23 @@
   return tmp;
 }
 
-// CHECK: define{{.*}} float @_Z27test_reassociate_off_pragmafff(float noundef %a, float noundef %b, float noundef %c) [[NOREASSOC_ATTRS:#[0-9]+]]
+// CHECK: define{{.*}} float @_Z27test_reassociate_off_pragmafff(float noundef %a, float noundef %b, float noundef %c) [[NO_UNSAFE_ATTRS:#[0-9]+]]
 // CHECK: fadd nnan ninf nsz arcp contract afn float {{%.+}}, {{%.+}}
 // CHECK: fadd fast float {{%.+}}, {{%.+}}
 
+float test_contract_on_pragma(float a, float b, float c) {
+  float tmp = a * b;
+  {
+#pragma clang fp contract(on)
+tmp += c;
+  }
+  return tmp;
+}
+
+// CHECK: define{{.*}} float @_Z23test_contract_on_pragmafff(float noundef %a, float noundef %b, float noundef %c) [[NO_UNSAFE_ATTRS:#[0-9]+]]
+// CHECK: fmul fast float {{%.+}}, {{%.+}}
+// CHECK: fadd reassoc nnan ninf nsz arcp afn float {{%.+}}, {{%.+}}
+
 // CHECK: attributes [[FAST_ATTRS]] = { {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" {{.*}}"unsafe-fp-math"="true"{{.*}} }
 // CHECK: attributes [[PRECISE_ATTRS]] = { {{.*}}"no-infs-fp-math"="false" {{.*}}"no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" {{.*}}"unsafe-fp-math"="false"{{.*}} }
-// CHECK: attributes [[NOREASSOC_ATTRS]] = { {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" {{.*}}"unsafe-fp-math"="false"{{.*}} }
+// CHECK: attributes [[NO_UNSAFE_ATTRS]] = { {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" {{.*}}"unsafe-fp-math"="false"{{.*}} }
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -173,10 +173,11 @@
   mergeFnAttrValue("no-infs-fp-math", FPFeatures.getNoHonorInfs());
   mergeFnAttrValue("no-nans-fp-math", FPFeatures.getNoHonorNaNs());
   mergeFnAttrValue("no-signed-zeros-fp-math", FPFeatures.getNoSignedZero());
-  mergeFnAttrV

[clang] b7d7c44 - Fix `unsafe-fp-math` attribute emission.

2022-11-14 Thread Michele Scandale via cfe-commits

Author: Michele Scandale
Date: 2022-11-14T20:40:57-08:00
New Revision: b7d7c448df9a4679c1dfa079911f863e32d8e41f

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

LOG: Fix `unsafe-fp-math` attribute emission.

The conditions for which Clang emits the `unsafe-fp-math` function
attribute has been modified as part of
`84a9ec2ff1ee97fd7e8ed988f5e7b197aab84a7`.
In the backend code generators `"unsafe-fp-math"="true"` enable floating
point contraction for the whole function.
The intent of the change in `84a9ec2ff1ee97fd7e8ed988f5e7b197aab84a7`
was to prevent backend code generators performing contractions when that
is not expected.
However the change is inaccurate and incomplete because it allows
`unsafe-fp-math` to be set also when only in-statement contraction is
allowed.

Consider the following example
```
float foo(float a, float b, float c) {
  float tmp = a * b;
  return tmp + c;
}
```
and compile it with the command line
```
clang -fno-math-errno -funsafe-math-optimizations -ffp-contract=on \
  -O2 -mavx512f -S -o -
```
The resulting assembly has a `vfmadd213ss` instruction which corresponds
to a fused multiply-add. From the user perspective there shouldn't be
any contraction because the multiplication and the addition are not in
the same statement.

The optimized IR is:
```
define float @test(float noundef %a, float noundef %b, float noundef %c) #0 {
  %mul = fmul reassoc nsz arcp afn float %b, %a
  %add = fadd reassoc nsz arcp afn float %mul, %c
  ret float %add
}

attributes #0 = {
  [...]
  "no-signed-zeros-fp-math"="true"
  "no-trapping-math"="true"
  [...]
  "unsafe-fp-math"="true"
}
```
The `"unsafe-fp-math"="true"` function attribute allows the backend code
generator to perform `(fadd (fmul a, b), c) -> (fmadd a, b, c)`.

In the current IR representation there is no way to determine the
statement boundaries from the original source code.
Because of this for in-statement only contraction the generated IR
doesn't have instructions with the `contract` fast-math flag and
`llvm.fmuladd` is being used to represent contractions opportunities
that occur within a single statement.
Therefore `"unsafe-fp-math"="true"` can only be emitted when contraction
across statements is allowed.

Moreover the change in `84a9ec2ff1ee97fd7e8ed988f5e7b197aab84a7` doesn't
take into account that the floating point math function attributes can
be refined during IR code generation of a function to handle the cases
where the floating point math options are modified within a compound
statement via pragmas (see `CGFPOptionsRAII`).
For consistency `unsafe-fp-math` needs to be disabled if the contraction
mode for any scope/operation is not `fast`.
Similarly for consistency reason the initialization of `UnsafeFPMath` of
in `TargetOptions` for the backend code generation should take into
account the contraction mode as well.

Reviewed By: zahiraam

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/test/CodeGen/fp-function-attrs.cpp
clang/test/CodeGen/func-attr.c

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 41f9ce3a009d..8498ca2e6338 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -409,7 +409,12 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
   Options.NoInfsFPMath = LangOpts.NoHonorInfs;
   Options.NoNaNsFPMath = LangOpts.NoHonorNaNs;
   Options.NoZerosInBSS = CodeGenOpts.NoZeroInitializedInBSS;
-  Options.UnsafeFPMath = LangOpts.UnsafeFPMath;
+  Options.UnsafeFPMath = LangOpts.AllowFPReassoc && LangOpts.AllowRecip &&
+ LangOpts.NoSignedZero && LangOpts.ApproxFunc &&
+ (LangOpts.getDefaultFPContractMode() ==
+  LangOptions::FPModeKind::FPM_Fast ||
+  LangOpts.getDefaultFPContractMode() ==
+  LangOptions::FPModeKind::FPM_FastHonorPragmas);
   Options.ApproxFuncFPMath = LangOpts.ApproxFunc;
 
   Options.BBSections =

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index b7d6ea2d3cc6..4b9c29c68181 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1862,11 +1862,12 @@ void 
CodeGenModule::getDefaultFunctionAttributes(StringRef Name,
   FuncAttrs.addAttribute("no-nans-fp-math", "true");
 if (LangOpts.ApproxFunc)
   FuncAttrs.addAttribute("approx-func-fp-math", "true");
-if ((LangOpts.FastMath ||
- (!LangOpts.FastMath && LangOpts.AllowFPReassoc &&
-  LangOpts.AllowRecip && !LangOpts.FiniteMathOnly &&
-  LangOpts.NoSignedZero && Lan

[PATCH] D136354: [Driver] Enable nested configuration files

2022-11-14 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136354

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


[PATCH] D137719: [clang] Missed rounding mode use in constant evaluation

2022-11-14 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137719

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


[PATCH] D137809: [LoongArch] Add immediate operand validity check for __builtin_loongarch_dbar

2022-11-14 Thread Gong LingQin via Phabricator via cfe-commits
gonglingqin updated this revision to Diff 475333.
gonglingqin added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Add test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137809

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/LoongArch/intrinsic-error.c
  llvm/test/CodeGen/LoongArch/intrinsic-error.ll


Index: llvm/test/CodeGen/LoongArch/intrinsic-error.ll
===
--- llvm/test/CodeGen/LoongArch/intrinsic-error.ll
+++ llvm/test/CodeGen/LoongArch/intrinsic-error.ll
@@ -8,11 +8,18 @@
   ret void
 }
 
-define void @dbar_imm_out_of_range() nounwind {
+define void @dbar_imm_out_of_hi_range() nounwind {
 ; CHECK: argument to '__builtin_loongarch_dbar' out of range
 entry:
   call void @llvm.loongarch.dbar(i32 32769)
   ret void
 }
 
+define void @dbar_imm_out_of_lo_range() nounwind {
+; CHECK: argument to '__builtin_loongarch_dbar' out of range
+entry:
+  call void @llvm.loongarch.dbar(i32 -1)
+  ret void
+}
+
 declare void @llvm.loongarch.dbar(i32)
Index: clang/test/CodeGen/LoongArch/intrinsic-error.c
===
--- clang/test/CodeGen/LoongArch/intrinsic-error.c
+++ clang/test/CodeGen/LoongArch/intrinsic-error.c
@@ -6,3 +6,11 @@
 int crc_w_d_w(long int a, int b) {
   return __builtin_loongarch_crc_w_d_w(a, b); // expected-error {{this builtin 
requires target: loongarch64}}
 }
+
+void dbar_out_of_hi_range() {
+  return __builtin_loongarch_dbar(32768); // expected-error {{argument value 
32768 is outside the valid range [0, 32767]}}
+}
+
+void dbar_out_of_lo_range() {
+  return __builtin_loongarch_dbar(-1); // expected-error {{argument value 
4294967295 is outside the valid range [0, 32767]}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3683,6 +3683,9 @@
   diag::err_loongarch_builtin_requires_la64)
  << TheCall->getSourceRange();
 break;
+  case LoongArch::BI__builtin_loongarch_dbar:
+// Check if immediate is in [0, 32767]
+return SemaBuiltinConstantArgRange(TheCall, 0, 0, 32767);
   }
 
   return false;


Index: llvm/test/CodeGen/LoongArch/intrinsic-error.ll
===
--- llvm/test/CodeGen/LoongArch/intrinsic-error.ll
+++ llvm/test/CodeGen/LoongArch/intrinsic-error.ll
@@ -8,11 +8,18 @@
   ret void
 }
 
-define void @dbar_imm_out_of_range() nounwind {
+define void @dbar_imm_out_of_hi_range() nounwind {
 ; CHECK: argument to '__builtin_loongarch_dbar' out of range
 entry:
   call void @llvm.loongarch.dbar(i32 32769)
   ret void
 }
 
+define void @dbar_imm_out_of_lo_range() nounwind {
+; CHECK: argument to '__builtin_loongarch_dbar' out of range
+entry:
+  call void @llvm.loongarch.dbar(i32 -1)
+  ret void
+}
+
 declare void @llvm.loongarch.dbar(i32)
Index: clang/test/CodeGen/LoongArch/intrinsic-error.c
===
--- clang/test/CodeGen/LoongArch/intrinsic-error.c
+++ clang/test/CodeGen/LoongArch/intrinsic-error.c
@@ -6,3 +6,11 @@
 int crc_w_d_w(long int a, int b) {
   return __builtin_loongarch_crc_w_d_w(a, b); // expected-error {{this builtin requires target: loongarch64}}
 }
+
+void dbar_out_of_hi_range() {
+  return __builtin_loongarch_dbar(32768); // expected-error {{argument value 32768 is outside the valid range [0, 32767]}}
+}
+
+void dbar_out_of_lo_range() {
+  return __builtin_loongarch_dbar(-1); // expected-error {{argument value 4294967295 is outside the valid range [0, 32767]}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3683,6 +3683,9 @@
   diag::err_loongarch_builtin_requires_la64)
  << TheCall->getSourceRange();
 break;
+  case LoongArch::BI__builtin_loongarch_dbar:
+// Check if immediate is in [0, 32767]
+return SemaBuiltinConstantArgRange(TheCall, 0, 0, 32767);
   }
 
   return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137809: [LoongArch] Add immediate operand validity check for __builtin_loongarch_dbar

2022-11-14 Thread Gong LingQin via Phabricator via cfe-commits
gonglingqin added inline comments.



Comment at: clang/test/CodeGen/LoongArch/intrinsic-error.c:11
+void dbar() {
+  return __builtin_loongarch_dbar(32768); // expected-error {{argument value 
32768 is outside the valid range [0, 32767]}}
+}

SixWeining wrote:
> Also check lower bound.
Thanks, I will add test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137809

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


[clang] 9044226 - [NFC] [C++20] [Modules] Remove unused Global Module Fragment variables/arguments

2022-11-14 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-11-15T11:51:13+08:00
New Revision: 9044226ba2dab1c8c4e7fb352c4c5b4d399052b4

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

LOG: [NFC] [C++20] [Modules] Remove unused Global Module Fragment 
variables/arguments

Added: 


Modified: 
clang/include/clang/Lex/ModuleMap.h
clang/lib/Lex/ModuleMap.cpp
clang/lib/Sema/SemaModule.cpp

Removed: 




diff  --git a/clang/include/clang/Lex/ModuleMap.h 
b/clang/include/clang/Lex/ModuleMap.h
index ca04ce623616e..35c5c2297a042 100644
--- a/clang/include/clang/Lex/ModuleMap.h
+++ b/clang/include/clang/Lex/ModuleMap.h
@@ -564,8 +564,7 @@ class ModuleMap {
   /// Note that this also sets the current module to the newly-created module.
   ///
   /// \returns The newly-created module.
-  Module *createModuleForInterfaceUnit(SourceLocation Loc, StringRef Name,
-   Module *GlobalModule);
+  Module *createModuleForInterfaceUnit(SourceLocation Loc, StringRef Name);
 
   /// Create a header module from the specified list of headers.
   Module *createHeaderModule(StringRef Name, ArrayRef Headers);

diff  --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 2d8970516a5d2..210fab72fc81e 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -873,8 +873,7 @@ 
ModuleMap::createPrivateModuleFragmentForInterfaceUnit(Module *Parent,
 }
 
 Module *ModuleMap::createModuleForInterfaceUnit(SourceLocation Loc,
-StringRef Name,
-Module *GlobalModule) {
+StringRef Name) {
   assert(LangOpts.CurrentModule == Name && "module name mismatch");
   assert(!Modules[Name] && "redefining existing module");
 

diff  --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 1db716e77e7d5..3d4fef1d141d1 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -244,14 +244,8 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, 
SourceLocation ModuleLoc,
 return nullptr;
   }
 
-  // Find the global module fragment we're adopting into this module, if any.
-  Module *GlobalModuleFragment = nullptr;
-  if (!ModuleScopes.empty() &&
-  ModuleScopes.back().Module->Kind == Module::GlobalModuleFragment)
-GlobalModuleFragment = ModuleScopes.back().Module;
-
   assert((!getLangOpts().CPlusPlusModules || getLangOpts().ModulesTS ||
-  SeenGMF == (bool)GlobalModuleFragment) &&
+  SeenGMF == (bool)this->GlobalModuleFragment) &&
  "mismatched global module state");
 
   // In C++20, the module-declaration must be the first declaration if there
@@ -335,8 +329,7 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, 
SourceLocation ModuleLoc,
 }
 
 // Create a Module for the module that we're defining.
-Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName,
-   GlobalModuleFragment);
+Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName);
 if (MDK == ModuleDeclKind::PartitionInterface)
   Mod->Kind = Module::ModulePartitionInterface;
 assert(Mod && "module creation should not fail");
@@ -356,21 +349,19 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, 
SourceLocation ModuleLoc,
 if (!Mod) {
   Diag(ModuleLoc, diag::err_module_not_defined) << ModuleName;
   // Create an empty module interface unit for error recovery.
-  Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName,
- GlobalModuleFragment);
+  Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName);
 }
   } break;
 
   case ModuleDeclKind::PartitionImplementation:
 // Create an interface, but note that it is an implementation
 // unit.
-Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName,
-   GlobalModuleFragment);
+Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName);
 Mod->Kind = Module::ModulePartitionImplementation;
 break;
   }
 
-  if (!GlobalModuleFragment) {
+  if (!this->GlobalModuleFragment) {
 ModuleScopes.push_back({});
 if (getLangOpts().ModulesLocalVisibility)
   ModuleScopes.back().OuterVisibleModules = std::move(VisibleModules);



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


[PATCH] D137809: [LoongArch] Add immediate operand validity check for __builtin_loongarch_dbar

2022-11-14 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added inline comments.



Comment at: clang/test/CodeGen/LoongArch/intrinsic-error.c:11
+void dbar() {
+  return __builtin_loongarch_dbar(32768); // expected-error {{argument value 
32768 is outside the valid range [0, 32767]}}
+}

Also check lower bound.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137809

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


[PATCH] D137609: [C++20] [Modules] Remove unmaintained header modules

2022-11-14 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

@bruno ping~


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

https://reviews.llvm.org/D137609

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


[PATCH] D131938: [C++20] [Coroutines] Disable to take the address of labels in coroutines

2022-11-14 Thread Adrian Vogelsgesang via Phabricator via cfe-commits
avogelsgesang added a comment.

Personally, I am fine with this change as in review right now.

@ychen are you still planning to look further into this issue as part of your 
alternative patch https://reviews.llvm.org/D132084 ? Otherwise, I would propose 
that we merge @ChuanqiXu 's change for the time being. Later on, we can still 
re-enable this functionality, as soon as we figured out the LLVM coroutine 
semantics of this


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

https://reviews.llvm.org/D131938

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


[PATCH] D137217: [LTO][COFF] Use bitcode file names in lto native object file names.

2022-11-14 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

@MaskRay wondering if this is a good change to make for ELF as well, wdyt?




Comment at: clang/lib/CodeGen/BackendUtil.cpp:1104
 
-  auto AddStream = [&](size_t Task) {
+  auto AddStream = [&](size_t Task, Twine File) {
 return std::make_unique(std::move(OS),

zequanwu wrote:
> tejohnson wrote:
> > I think you might need to mark the new parameter as unused here and in 
> > other cases where it isn't used via LLVM_ATTRIBUTE_UNUSED, to avoid build 
> > warnings - I can't recall how strictly that is enforced.
> LLVM_ATTRIBUTE_UNUSED is used to suppress unused functions. For unused 
> parameter, I don't see any build warnings when compiling with this patch. I 
> feel like it's very common to have unused parameter. 
LLVM_ATTRIBUTE_UNUSED maps to __attribute__((__unused__)) which works for 
either functions or parameters. However, I see where the macro is defined in 
llvm/include/llvm/Support/Compiler.h that using "(void)unused;" is preferred. 
Either one works (see below). However, it must be the case that there are no 
bots building with -Wunused-parameter, since I see Task is also unused here. So 
nevermind this suggestion, since what you have currently is consistent with 
what is already done here.

```
$ cat unused.cc
int foo(int x1, int x2 __attribute__((__unused__)), int x3) {
  (void)x3;
  return 1;
}
$ clang++ -c unused.cc -Wunused-parameter
unused.cc:1:13: warning: unused parameter 'x1' [-Wunused-parameter]
int foo(int x1, int x2 __attribute__((__unused__)), int x3) {
^
1 warning generated.
```



Comment at: lld/COFF/LTO.cpp:229
+StringRef ltoObjName;
+if (bitcodeFilePath == "ld-temp.o") {
+  ltoObjName =

zequanwu wrote:
> tejohnson wrote:
> > This case should always be i==0 I think?
> IIUC, "ld-temp.o" is the name of combined module. Do you mean there will be 
> only 1 combined module and it will always be the first task?
Yes. So you don't need the handling for i==0 in the name in this case (you 
could probably assert that i==0).



Comment at: llvm/include/llvm/Support/Caching.h:53
 ///
 /// if (AddStreamFn AddStream = Cache(Task, Key))
 ///   ProduceContent(AddStream);

tejohnson wrote:
> This and possibly other header file descriptions need updates.
Can you add a note that ModuleName is the unique module identifier for the 
bitcode module the cache is being checked for.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137217

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


[PATCH] D137768: [opt][clang] Enable using -module-summary /-flto=thin with -S / -emit-llvm

2022-11-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:996
+MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists,
+true /* EmitLTOSummary */));
+  }

Nitpick, but we should be consistent with the documented format for clang-tidy 
bugprone-argument-comment: 
https://clang.llvm.org/extra/clang-tidy/checks/bugprone/argument-comment.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137768

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


[PATCH] D137762: [clang-format] avoid breaking )( with BlockIndent

2022-11-14 Thread Gedare Bloom via Phabricator via cfe-commits
gedare added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:7215
   Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  EXPECT_EQ(StringRef("functionCall(paramA, paramB,\n"
-  "paramC);\n"
-  "void functionDecl(int A, int B,\n"
-  "int C);"),
-format(Input, Style));
+  verifyFormat("functionCall(paramA, paramB,\n"
+   "paramC);\n"

HazardyKnusperkeks wrote:
> Sorry for the confusion, you can (and should?) keep the `Input` variable. 
> There is a verifyFormat with 4 arguments. So that the input in the formatting 
> doesn't have to be the expected.
Ok, I restored it in this function. I didn't add it to the other functions 
since they weren't using it already.  The vast majority of the calls to 
verifyFormat are using the 3-argument version. It's unclear what is preferred.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137762

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


[PATCH] D137762: [clang-format] avoid breaking )( with BlockIndent

2022-11-14 Thread Gedare Bloom via Phabricator via cfe-commits
gedare updated this revision to Diff 475313.
gedare added a comment.

- FormatTest: restore Input variable to one test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137762

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7214,49 +7214,57 @@
 "void functionDecl(int A, int B, int C);";
   Style.AllowAllArgumentsOnNextLine = false;
   Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  EXPECT_EQ(StringRef("functionCall(paramA, paramB,\n"
-  "paramC);\n"
-  "void functionDecl(int A, int B,\n"
-  "int C);"),
-format(Input, Style));
+  verifyFormat("functionCall(paramA, paramB,\n"
+   "paramC);\n"
+   "void functionDecl(int A, int B,\n"
+   "int C);",
+   Input, Style);
   Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
-  EXPECT_EQ(StringRef("functionCall(paramA, paramB,\n"
-  " paramC);\n"
-  "void functionDecl(int A, int B,\n"
-  "  int C);"),
-format(Input, Style));
-  // However, BAS_AlwaysBreak should take precedence over
+  verifyFormat("functionCall(paramA, paramB,\n"
+   " paramC);\n"
+   "void functionDecl(int A, int B,\n"
+   "  int C);",
+   Input, Style);
+  // However, BAS_AlwaysBreak and BAS_BlockIndent should take precedence over
   // AllowAllArgumentsOnNextLine.
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
-  EXPECT_EQ(StringRef("functionCall(\n"
-  "paramA, paramB, paramC);\n"
-  "void functionDecl(\n"
-  "int A, int B, int C);"),
-format(Input, Style));
+  verifyFormat("functionCall(\n"
+   "paramA, paramB, paramC);\n"
+   "void functionDecl(\n"
+   "int A, int B, int C);",
+   Input, Style);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  verifyFormat("functionCall(\n"
+   "paramA, paramB, paramC\n"
+   ");\n"
+   "void functionDecl(\n"
+   "int A, int B, int C\n"
+   ");",
+   Input, Style);
 
   // When AllowAllArgumentsOnNextLine is set, we prefer breaking before the
   // first argument.
   Style.AllowAllArgumentsOnNextLine = true;
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
-  EXPECT_EQ(StringRef("functionCall(\n"
-  "paramA, paramB, paramC);\n"
-  "void functionDecl(\n"
-  "int A, int B, int C);"),
-format(Input, Style));
+  verifyFormat("functionCall(\n"
+   "paramA, paramB, paramC);\n"
+   "void functionDecl(\n"
+   "int A, int B, int C);",
+   Input, Style);
   // It wouldn't fit on one line with aligned parameters so this setting
   // doesn't change anything for BAS_Align.
   Style.AlignAfterOpenBracket = FormatStyle::BAS_Align;
-  EXPECT_EQ(StringRef("functionCall(paramA, paramB,\n"
-  " paramC);\n"
-  "void functionDecl(int A, int B,\n"
-  "  int C);"),
-format(Input, Style));
+  verifyFormat("functionCall(paramA, paramB,\n"
+   " paramC);\n"
+   "void functionDecl(int A, int B,\n"
+   "  int C);",
+   Input, Style);
   Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  EXPECT_EQ(StringRef("functionCall(\n"
-  "paramA, paramB, paramC);\n"
-  "void functionDecl(\n"
-  "int A, int B, int C);"),
-format(Input, Style));
+  verifyFormat("functionCall(\n"
+   "paramA, paramB, paramC);\n"
+   "void functionDecl(\n"
+   "int A, int B, int C);",
+   Input, Style);
 }
 
 TEST_F(FormatTest, BreakBeforeInlineASMColon) {
@@ -8435,6 +8443,52 @@
   "(a, )) &&\n"
   ");",
   Style);
+
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  Style.BinPackArguments = false;
+  Style.BinPackParameters = false;
+  verifyFormat("void aa(\n"
+   "aaa ,\n"
+   "a aaa,\n"
+ 

[PATCH] D137996: Add support for a backdoor driver option that enables emitting header usage information in JSON to a file

2022-11-14 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: jansvoboda11, akyrtzi.
ahatanak added a project: clang.
Herald added a project: All.
ahatanak requested review of this revision.
Herald added a subscriber: MaskRay.

Each line in the file is a JSON object that has the name of the main source 
file followed by the list of system header files included directly or 
indirectly from that file.

For example:

  {"source":"/tmp/foo.c", "includes":["/usr/include/stdio.h", 
"/usr/include/stdlib.h"]}

To reduce the amount of data written to the file, only the system headers that 
are directly included from a file that isn't in the system directory are 
recorded.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137996

Files:
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/DependencyOutputOptions.h
  clang/include/clang/Frontend/Utils.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/test/Preprocessor/Inputs/print-header-json/header0.h
  clang/test/Preprocessor/Inputs/print-header-json/header1.h
  clang/test/Preprocessor/Inputs/print-header-json/header2.h
  clang/test/Preprocessor/Inputs/print-header-json/system/system0.h
  clang/test/Preprocessor/Inputs/print-header-json/system/system1.h
  clang/test/Preprocessor/Inputs/print-header-json/system/system2.h
  clang/test/Preprocessor/Inputs/print-header-json/system/system3.h
  clang/test/Preprocessor/print-header-json.c
  clang/tools/driver/driver.cpp

Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -260,6 +260,9 @@
   TheDriver.CCPrintHeaders =
   CheckEnvVar("CC_PRINT_HEADERS", "CC_PRINT_HEADERS_FILE",
   TheDriver.CCPrintHeadersFilename);
+  TheDriver.CCPrintHeadersJson =
+  CheckEnvVar("CC_PRINT_HEADERS_JSON", "CC_PRINT_HEADERS_FILE",
+  TheDriver.CCPrintHeadersFilename);
   TheDriver.CCLogDiagnostics =
   CheckEnvVar("CC_LOG_DIAGNOSTICS", "CC_LOG_DIAGNOSTICS_FILE",
   TheDriver.CCLogDiagnosticsFilename);
Index: clang/test/Preprocessor/print-header-json.c
===
--- /dev/null
+++ clang/test/Preprocessor/print-header-json.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -E -header-include-json -header-include-file %t.txt -I %S/Inputs/print-header-json -isystem %S/Inputs/print-header-json/system %s -o /dev/null
+// RUN: cat %t.txt | FileCheck %s
+
+#include "system0.h"
+#include "header0.h"
+#include "system2.h"
+
+// CHECK: {"source":"{{[^,]*}}/print-header-json.c","includes":["{{[^,]*}}/Inputs/print-header-json/system/system0.h","{{[^,]*}}/Inputs/print-header-json/system/system2.h","{{[^,]*}}/Inputs/print-header-json/system/system3.h"]}
Index: clang/test/Preprocessor/Inputs/print-header-json/system/system0.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/print-header-json/system/system0.h
@@ -0,0 +1,2 @@
+#include "system1.h"
+#include "system2.h"
Index: clang/test/Preprocessor/Inputs/print-header-json/header0.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/print-header-json/header0.h
@@ -0,0 +1,3 @@
+#include "system3.h"
+#include "header1.h"
+#include "header2.h"
Index: clang/lib/Frontend/HeaderIncludeGen.cpp
===
--- clang/lib/Frontend/HeaderIncludeGen.cpp
+++ clang/lib/Frontend/HeaderIncludeGen.cpp
@@ -12,7 +12,10 @@
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/Support/JSON.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
+
 using namespace clang;
 
 namespace {
@@ -49,6 +52,43 @@
   void FileSkipped(const FileEntryRef &SkippedFile, const Token &FilenameTok,
SrcMgr::CharacteristicKind FileType) override;
 };
+
+/// A callback for emitting header usage information to a file in JSON. Each
+/// line in the file is a JSON object that includes the source file name and
+/// the list of headers directly or indirectly included from it. For example:
+///
+/// {"source":"/tmp/foo.c",
+///  "includes":["/usr/include/stdio.h", "/usr/include/stdlib.h"]}
+///
+/// To reduce the amount of data written to the file, we only record system
+/// headers that are directly included from a file that isn't in the system
+/// directory.
+class HeaderIncludesJSONCallback : public PPCallbacks {
+  SourceManager &SM;
+  raw_ostream *OutputFile;
+  bool OwnsOutputFile;
+  std::set IncludedHeaders;
+
+public:
+  HeaderIncludesJSONCallback(const Preprocessor *PP, raw_ostream *OutputFile_,
+ bool OwnsOutputFile_)
+  : S

[PATCH] D137995: [Flang][Driver] Handle target CPU and features

2022-11-14 Thread Usman Nadeem via Phabricator via cfe-commits
mnadeem created this revision.
mnadeem added reviewers: vzakhari, awarzynski, kiranchandramohan.
mnadeem added a project: Flang.
Herald added subscribers: ctetreau, jdoerfert, s.egerton, simoncook, 
fedor.sergeev, kristof.beyls, dschuff.
Herald added a reviewer: sscalpone.
Herald added a project: All.
mnadeem requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay, aheejin.
Herald added a project: clang.

This patch:

- Adds `target-feature` and `target-cpu` to FC1Options.
- Moves `getTargetFeatures()` from Clang.cpp to CommonArgs.cpp.
- Processes target cpu and features in the flang driver. Right now features are 
only added for AArch64 because I only did basic testing on AArch64 but it 
should generally work for others as well.
- Adds appropriate structures in TargetOptions and passes them to the target 
machine.

What's missing:

- Adding the CPU info and the features as attributes in the LLVM IR module.
- Processing target specific flags, e.g. SVE vector bits for AArch64, ABI etc.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137995

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/ToolChains/Flang.h
  flang/include/flang/Frontend/TargetOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help.f90
  flang/test/Driver/target-cpu-features.f90

Index: flang/test/Driver/target-cpu-features.f90
===
--- /dev/null
+++ flang/test/Driver/target-cpu-features.f90
@@ -0,0 +1,22 @@
+! REQUIRES: aarch64-registered-target, x86-registered-target
+
+! Test that -mcpu is forwarded to -target-cpu and that the target features are
+! also added.
+
+! RUN: %flang --target=aarch64-linux-gnu -mcpu=cortex-a57 -emit-llvm -c %s \
+! RUN:   -o %t.o -### 2>&1 | FileCheck %s -check-prefix=CHECK-A57
+
+! RUN: %flang --target=aarch64-linux-gnu -mcpu=cortex-a76 -emit-llvm -c %s \
+! RUN:   -o %t.o -### 2>&1 | FileCheck %s -check-prefix=CHECK-A76
+
+! RUN: %flang --target=x86_64-linux-gnu -mcpu=cortex-a57 -emit-llvm -c %s \
+! RUN:   -o %t.o -### 2>&1 | FileCheck %s -check-prefix=CHECK-NO-A57
+
+! CHECK-A57: "-triple" "aarch64-unknown-linux-gnu"
+! CHECK-A57: "-target-cpu" "cortex-a57" "-target-feature" "+v8a" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+sha2" "-target-feature" "+aes"
+
+! CHECK-A76: "-triple" "aarch64-unknown-linux-gnu"
+! CHECK-A76: "-target-cpu" "cortex-a76" "-target-feature" "+v8.2a" "-target-feature" "+crc" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" "+crypto" "-target-feature" "+dotprod" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+fullfp16" "-target-feature" "+ras" "-target-feature" "+rcpc" "-target-feature" "+ssbs" "-target-feature" "+sha2" "-target-feature" "+aes"
+
+! CHECK-NO-A57: "-fc1"
+! CHECK-NO-A57-NOT: cortex-a57
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -156,6 +156,8 @@
 ! HELP-FC1-NEXT: -P Disable linemarker output in -E mode
 ! HELP-FC1-NEXT: -std=   Language standard to compile for
 ! HELP-FC1-NEXT: -S Only run preprocess and compilation steps
+! HELP-FC1-NEXT: -target-cpu Target a specific cpu type
+! HELP-FC1-NEXT: -target-feature  Target specific attributes
 ! HELP-FC1-NEXT: -test-io   Run the InputOuputTest action. Use for development and testing only.
 ! HELP-FC1-NEXT: -triple Specify target triple (e.g. i686-apple-darwin9)
 ! HELP-FC1-NEXT: -U  Undefine macro 
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -591,7 +591,8 @@
 void CodeGenAction::setUpTargetMachine() {
   CompilerInstance &ci = this->getInstance();
 
-  const std::string &theTriple = ci.getInvocation().getTargetOpts().triple;
+  const auto &targetOpts = ci.getInvocation().getTargetOpts();
+  const std::string &theTriple = targetOpts.triple;
 
   // Create `Target`
   std::string error;
@@ -602,9 +603,11 @@
   // Create `TargetMachine`
   const auto &CGOpts = ci.getInvocation().getCodeGenOpts();
   llvm::CodeGenOpt::Level OptLevel = getCGOptLevel(CGOpts);
+  std::string featuresStr = llvm::join(targetOpts.featuresAsWritten.begin(),
+   targetOpts.featuresAsWritten.end(), ",");
   tm.reset(theTarget->createTargetMachine(
-  theTriple, /*CPU=*/"",
-  /*Features=*/"", llvm::TargetOptions(),
+  theTr

[PATCH] D137244: [Clang] Correctly capture bindings in dependent lambdas.

2022-11-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

This looks reasonable to me but not confident enough to approve it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137244

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


[PATCH] D137960: [Lexer] Speedup LexTokenInternal

2022-11-14 Thread Chris Lattner via Phabricator via cfe-commits
lattner accepted this revision.
lattner added a comment.
This revision is now accepted and ready to land.

Nice!  I'd love someone else's eyes on this, but that's a great speedup!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137960

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


[PATCH] D135128: [clang][cli] Simplify repetitive macro invocations

2022-11-14 Thread Stella Stamenova via Phabricator via cfe-commits
stella.stamenova added a comment.

In D135128#3921902 , @jansvoboda11 
wrote:

> @stella.stamenova Any updates?

We haven't had time to come up with a proper solution yet. One short-term 
solution (assuming there's urgency in making the change) would be to 
temporarily disable treating warnings as errors on the mlir buildbot. This will 
remove the issue there and I don't know of other buildbots that enforce warning 
as error on Windows, so it will likely unblock the commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135128

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


[PATCH] D136806: [Pipelines] Introduce SROA after (final, full) loop unrolling

2022-11-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D136806#3926319 , @arsenm wrote:

> I think SROA after unroll is important. It's practically the main reason to 
> unroll






Comment at: llvm/lib/Passes/PassBuilderPipelines.cpp:1200-1201
 FPM.addPass(WarnMissedTransformationsPass());
+FPM.addPass(SROAPass());
 FPM.addPass(InstCombinePass());
 FPM.addPass(

As the cross-revision diff shows, running sroa before instcombine, 
non-unexpectedly, makes more sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136806

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


[PATCH] D136806: [Pipelines] Introduce SROA after (final, full) loop unrolling

2022-11-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 475311.
lebedev.ri retitled this revision from "[Pipelines] Introduce SROA after (full) 
loop unrolling" to "[Pipelines] Introduce SROA after (final, full) loop 
unrolling".
lebedev.ri added a reviewer: arsenm.
lebedev.ri added a comment.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

In D136806#3926319 , @arsenm wrote:

> I think SROA after unroll is important. It's practically the main reason to 
> unroll

Yay, finally some recognition.
Would you like to stamp? :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136806

Files:
  clang/test/CodeGen/cleanup-destslot-simple.c
  llvm/lib/Passes/PassBuilderPipelines.cpp
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
  llvm/test/Transforms/PhaseOrdering/X86/SROA-after-final-loop-unrolling-2.ll
  llvm/test/Transforms/PhaseOrdering/X86/SROA-after-final-loop-unrolling.ll
  llvm/test/Transforms/PhaseOrdering/single-iteration-loop-sroa.ll

Index: llvm/test/Transforms/PhaseOrdering/single-iteration-loop-sroa.ll
===
--- llvm/test/Transforms/PhaseOrdering/single-iteration-loop-sroa.ll
+++ llvm/test/Transforms/PhaseOrdering/single-iteration-loop-sroa.ll
@@ -13,17 +13,17 @@
 ; CHECK-NEXT:store i16 [[TMP0:%.*]], ptr [[DATA]], align 2
 ; CHECK-NEXT:br label [[BB6_I_I:%.*]]
 ; CHECK:   bb6.i.i:
-; CHECK-NEXT:[[ITER_SROA_0_07_I_I:%.*]] = phi i64 [ [[TMP2:%.*]], [[BB6_I_I]] ], [ 0, [[START:%.*]] ]
+; CHECK-NEXT:[[ITER_SROA_0_07_I_I:%.*]] = phi i64 [ [[TMP1:%.*]], [[BB6_I_I]] ], [ 0, [[START:%.*]] ]
 ; CHECK-NEXT:[[_40_I_I:%.*]] = sub nsw i64 0, [[ITER_SROA_0_07_I_I]]
-; CHECK-NEXT:[[TMP2]] = add nuw nsw i64 [[ITER_SROA_0_07_I_I]], 1
+; CHECK-NEXT:[[TMP1]] = add nuw nsw i64 [[ITER_SROA_0_07_I_I]], 1
 ; CHECK-NEXT:[[_34_I_I:%.*]] = getelementptr inbounds [0 x i8], ptr [[DATA]], i64 0, i64 [[ITER_SROA_0_07_I_I]]
-; CHECK-NEXT:[[TMP1:%.*]] = getelementptr [0 x i8], ptr [[DATA]], i64 0, i64 [[_40_I_I]]
-; CHECK-NEXT:[[_39_I_I:%.*]] = getelementptr i8, ptr [[TMP1:%.*]], i64 1
+; CHECK-NEXT:[[TMP2:%.*]] = getelementptr [0 x i8], ptr [[DATA]], i64 0, i64 [[_40_I_I]]
+; CHECK-NEXT:[[_39_I_I:%.*]] = getelementptr i8, ptr [[TMP2]], i64 1
 ; CHECK-NEXT:[[TMP_0_COPYLOAD_I_I_I_I:%.*]] = load i8, ptr [[_34_I_I]], align 1
 ; CHECK-NEXT:[[TMP2_0_COPYLOAD_I_I_I_I:%.*]] = load i8, ptr [[_39_I_I]], align 1
 ; CHECK-NEXT:store i8 [[TMP2_0_COPYLOAD_I_I_I_I]], ptr [[_34_I_I]], align 1
 ; CHECK-NEXT:store i8 [[TMP_0_COPYLOAD_I_I_I_I]], ptr [[_39_I_I]], align 1
-; CHECK-NEXT:[[EXITCOND_NOT_I_I:%.*]] = icmp eq i64 [[TMP2]], [[X:%.*]]
+; CHECK-NEXT:[[EXITCOND_NOT_I_I:%.*]] = icmp eq i64 [[TMP1]], [[X:%.*]]
 ; CHECK-NEXT:br i1 [[EXITCOND_NOT_I_I]], label [[EXIT:%.*]], label [[BB6_I_I]]
 ; CHECK:   exit:
 ; CHECK-NEXT:[[DOTSROA_0_0_COPYLOAD:%.*]] = load i16, ptr [[DATA]], align 2
Index: llvm/test/Transforms/PhaseOrdering/X86/SROA-after-final-loop-unrolling.ll
===
--- llvm/test/Transforms/PhaseOrdering/X86/SROA-after-final-loop-unrolling.ll
+++ llvm/test/Transforms/PhaseOrdering/X86/SROA-after-final-loop-unrolling.ll
@@ -13,38 +13,10 @@
 define void @wibble(ptr %arg) personality ptr null {
 ; CHECK-LABEL: @wibble(
 ; CHECK-NEXT:  bb:
-; CHECK-NEXT:[[I1:%.*]] = alloca [[T1:%.*]], align 16
 ; CHECK-NEXT:[[I10_3_I_PRE:%.*]] = load i8, ptr [[ARG:%.*]], align 1
-; CHECK-NEXT:[[VECTOR_RECUR_INIT:%.*]] = insertelement <4 x i8> poison, i8 [[I10_3_I_PRE]], i64 3
-; CHECK-NEXT:[[TMP0:%.*]] = getelementptr [64 x i8], ptr [[ARG]], i64 0, i64 1
-; CHECK-NEXT:[[WIDE_LOAD:%.*]] = load <4 x i8>, ptr [[TMP0]], align 1
-; CHECK-NEXT:[[TMP1:%.*]] = shufflevector <4 x i8> [[VECTOR_RECUR_INIT]], <4 x i8> [[WIDE_LOAD]], <4 x i32> 
-; CHECK-NEXT:[[TMP2:%.*]] = or <4 x i8> [[TMP1]], 
-; CHECK-NEXT:[[TMP3:%.*]] = zext <4 x i8> [[TMP2]] to <4 x i32>
-; CHECK-NEXT:store <4 x i32> [[TMP3]], ptr [[I1]], align 16
-; CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds [16 x i32], ptr [[I1]], i64 0, i64 4
-; CHECK-NEXT:[[TMP5:%.*]] = getelementptr [64 x i8], ptr [[ARG]], i64 0, i64 5
-; CHECK-NEXT:[[WIDE_LOAD_1:%.*]] = load <4 x i8>, ptr [[TMP5]], align 1
-; CHECK-NEXT:[[TMP6:%.*]] = shufflevector <4 x i8> [[WIDE_LOAD]], <4 x i8> [[WIDE_LOAD_1]], <4 x i32> 
-; CHECK-NEXT:[[TMP7:%.*]] = or <4 x i8> [[TMP6]], 
-; CHECK-NEXT:[[TMP8:%.*]] = zext <4 x i8> [[TMP7]] to <4 x i32>
-; CHECK-NEXT:store <4 x i32> [[TMP8]], pt

[clang] b2fbafc - [NFC][Clang] Autogenerate checklines in a test being affected by a patch

2022-11-14 Thread Roman Lebedev via cfe-commits

Author: Roman Lebedev
Date: 2022-11-15T03:51:24+03:00
New Revision: b2fbafc911062ba74761d69d035ee8686125f2fc

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

LOG: [NFC][Clang] Autogenerate checklines in a test being affected by a patch

Added: 


Modified: 
clang/test/CodeGen/cleanup-destslot-simple.c

Removed: 




diff  --git a/clang/test/CodeGen/cleanup-destslot-simple.c 
b/clang/test/CodeGen/cleanup-destslot-simple.c
index 36cea26408eb7..18d4c2138090e 100644
--- a/clang/test/CodeGen/cleanup-destslot-simple.c
+++ b/clang/test/CodeGen/cleanup-destslot-simple.c
@@ -1,22 +1,117 @@
-// RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm 
-debug-info-kind=line-tables-only %s -o - | FileCheck %s --check-prefix=CHECK 
--check-prefix=LIFETIME
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm 
-debug-info-kind=line-tables-only %s -o - | FileCheck %s 
--check-prefix=CHECK-LIFETIME
 
 // We shouldn't have markers at -O0 or with msan.
-// RUN: %clang_cc1 -O0 -triple x86_64-none-linux-gnu -emit-llvm 
-debug-info-kind=line-tables-only %s -o - | FileCheck %s
-// RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm 
-debug-info-kind=line-tables-only %s -o - -fsanitize=memory | FileCheck %s
-// RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm 
-debug-info-kind=line-tables-only %s -o - -fsanitize=kernel-memory | FileCheck 
%s
+// RUN: %clang_cc1 -O0 -triple x86_64-none-linux-gnu -emit-llvm 
-debug-info-kind=line-tables-only %s -o - | FileCheck %s 
--check-prefix=CHECK-OPTNONE
+// RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm 
-debug-info-kind=line-tables-only %s -o - -fsanitize=memory | FileCheck %s 
--check-prefix=CHECK-MSAN
+// RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm 
-debug-info-kind=line-tables-only %s -o - -fsanitize=kernel-memory | FileCheck 
%s --check-prefix=CHECK-KMSAN
 
 // There is no exception to handle here, lifetime.end is not a destructor,
 // so there is no need have cleanup dest slot related code
-// CHECK-LABEL: define{{.*}} i32 @test
+
+// CHECK-LIFETIME-LABEL: @test(
+// CHECK-LIFETIME-NEXT:  entry:
+// CHECK-LIFETIME-NEXT:[[X:%.*]] = alloca i32, align 4
+// CHECK-LIFETIME-NEXT:[[P:%.*]] = alloca ptr, align 8
+// CHECK-LIFETIME-NEXT:call void @llvm.lifetime.start.p0(i64 4, ptr 
nonnull [[X]]) #[[ATTR2:[0-9]+]], !dbg [[DBG9:![0-9]+]]
+// CHECK-LIFETIME-NEXT:store i32 3, ptr [[X]], align 4, !dbg 
[[DBG10:![0-9]+]], !tbaa [[TBAA11:![0-9]+]]
+// CHECK-LIFETIME-NEXT:call void @llvm.lifetime.start.p0(i64 8, ptr 
nonnull [[P]]), !dbg [[DBG15:![0-9]+]]
+// CHECK-LIFETIME-NEXT:store volatile ptr [[X]], ptr [[P]], align 8, !dbg 
[[DBG16:![0-9]+]], !tbaa [[TBAA17:![0-9]+]]
+// CHECK-LIFETIME-NEXT:[[P_0_P_0_P_0_:%.*]] = load volatile ptr, ptr 
[[P]], align 8, !dbg [[DBG19:![0-9]+]], !tbaa [[TBAA17]]
+// CHECK-LIFETIME-NEXT:[[TMP0:%.*]] = load i32, ptr [[P_0_P_0_P_0_]], 
align 4, !dbg [[DBG20:![0-9]+]], !tbaa [[TBAA11]]
+// CHECK-LIFETIME-NEXT:call void @llvm.lifetime.end.p0(i64 8, ptr nonnull 
[[P]]), !dbg [[DBG21:![0-9]+]]
+// CHECK-LIFETIME-NEXT:call void @llvm.lifetime.end.p0(i64 4, ptr nonnull 
[[X]]) #[[ATTR2]], !dbg [[DBG21]]
+// CHECK-LIFETIME-NEXT:ret i32 [[TMP0]], !dbg [[DBG22:![0-9]+]]
+//
+// CHECK-OPTNONE-LABEL: @test(
+// CHECK-OPTNONE-NEXT:  entry:
+// CHECK-OPTNONE-NEXT:[[X:%.*]] = alloca i32, align 4
+// CHECK-OPTNONE-NEXT:[[P:%.*]] = alloca ptr, align 8
+// CHECK-OPTNONE-NEXT:store i32 3, ptr [[X]], align 4, !dbg 
[[DBG9:![0-9]+]]
+// CHECK-OPTNONE-NEXT:store volatile ptr [[X]], ptr [[P]], align 8, !dbg 
[[DBG10:![0-9]+]]
+// CHECK-OPTNONE-NEXT:[[TMP0:%.*]] = load volatile ptr, ptr [[P]], align 
8, !dbg [[DBG11:![0-9]+]]
+// CHECK-OPTNONE-NEXT:[[TMP1:%.*]] = load i32, ptr [[TMP0]], align 4, !dbg 
[[DBG12:![0-9]+]]
+// CHECK-OPTNONE-NEXT:ret i32 [[TMP1]], !dbg [[DBG13:![0-9]+]]
+//
+// CHECK-MSAN-LABEL: @test(
+// CHECK-MSAN-NEXT:  entry:
+// CHECK-MSAN-NEXT:[[X:%.*]] = alloca i32, align 4
+// CHECK-MSAN-NEXT:[[P:%.*]] = alloca ptr, align 8
+// CHECK-MSAN-NEXT:call void @llvm.lifetime.start.p0(i64 4, ptr nonnull 
[[X]]) #[[ATTR2:[0-9]+]], !dbg [[DBG9:![0-9]+]]
+// CHECK-MSAN-NEXT:[[TMP0:%.*]] = ptrtoint ptr [[X]] to i64, !dbg [[DBG9]]
+// CHECK-MSAN-NEXT:[[TMP1:%.*]] = xor i64 [[TMP0]], 87960930222080, !dbg 
[[DBG9]]
+// CHECK-MSAN-NEXT:[[TMP2:%.*]] = inttoptr i64 [[TMP1]] to ptr, !dbg 
[[DBG9]]
+// CHECK-MSAN-NEXT:store i32 0, ptr [[TMP2]], align 4, !dbg 
[[DBG10:![0-9]+]]
+// CHECK-MSAN-NEXT:store i32 3, ptr [[X]], align 4, !dbg [[DBG10]], !tbaa 
[[TBAA11:![0-9]+]]
+// CHECK-MSAN-NEXT:call void @llvm.lif

[PATCH] D136998: Try to implement lambdas with inalloca parameters by inlining the call operator function.

2022-11-14 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a comment.

In D136998#3926368 , @efriedma wrote:

> In D136998#3926321 , @rnk wrote:
>
>> In D136998#3906874 , @efriedma 
>> wrote:
>>
>>> Should we try to use this codepath for variadic lambdas as well?
>>
>> Yes!
>>
>>> Do we want to try to unify our cloning code?  
>>> CodeGenFunction::GenerateVarArgsThunk has code doing something similar.  
>>> (It's at least worth comparing to see if you're doing something 
>>> significantly different...)
>>
>> Good idea
>>
>> In D136998#3906881 , @efriedma 
>> wrote:
>>
>>> Might also be worth considering if we can avoid cloning here.  It should be 
>>> possible to emit the lambda body into a separate function with a calling 
>>> convention of your choice, and make both the call operator and the static 
>>> invoker call it.
>>
>> This would be nice. I wasn't able to provide guidance on how to do that, and 
>> I think Amy was struggling to synthesize a new method (`__invoke`, `__impl`) 
>> at the AST layer.
>
> I think you wouldn't actually synthesize it at all in the AST.
>
> Basically, the follow code changes:
>
> 1. Change the mangling of the function that contains the actual lambda body.
> 2. Make that function use an alternate calling convention that doesn't 
> involve inalloca etc.
> 3. Synthesize thunks to represent the actual call operator and static invoker.
>
> This is similar to the way virtual overriding works: there's an actual 
> function, but there are also alternate entry points that end up in the 
> vtables.

Thanks, that makes sense. I'm not very familiar with thunks but I'll look into 
it. Would we make a thunk that contains the call to the new lambda body 
function, and then the invoker and call op functions return that thunk?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136998

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


[PATCH] D133633: [CMake] Add ClangBootstrap configuration

2022-11-14 Thread Amir Ayupov via Phabricator via cfe-commits
Amir updated this revision to Diff 475309.
Amir added a comment.

Move out toolchain tools back into CMAKE_ARGS


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133633

Files:
  clang/CMakeLists.txt
  clang/cmake/modules/ClangBootstrap.cmake

Index: clang/cmake/modules/ClangBootstrap.cmake
===
--- /dev/null
+++ clang/cmake/modules/ClangBootstrap.cmake
@@ -0,0 +1,41 @@
+include(ExternalProject)
+
+# clang_Bootstrap_Add(name ...
+#   DEPENDS targets...
+# Targets that this project depends on
+#   CMAKE_ARGS arguments...
+# Optional cmake arguments to pass when configuring the project
+#   BUILD_TOOL_ARGS arguments...
+# Optional arguments to pass to the build tool
+macro(clang_Bootstrap_Add name)
+  cmake_parse_arguments(ARG "" "LINKER;AR;RANLIB;OBJCOPY;STRIP"
+"DEPENDS;TABLEGEN;CMAKE_ARGS;BUILD_TOOL_ARGS"
+${ARGN})
+  set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${name}-stamps/)
+  set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${name}-bins/)
+  # Build arguments for native tool used in CMake.
+  set(build_configuration "$")
+
+  ExternalProject_Add(${name}
+DEPENDS ${ARG_DEPENDS}
+PREFIX ${name}
+SOURCE_DIR ${CMAKE_SOURCE_DIR}
+STAMP_DIR ${STAMP_DIR}
+BINARY_DIR ${BINARY_DIR}
+EXCLUDE_FROM_ALL 1
+CMAKE_ARGS
+# We shouldn't need to set this here, but INSTALL_DIR doesn't
+# seem to work, so instead I'm passing this through
+-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
+${ARG_CMAKE_ARGS}
+BUILD_COMMAND ${CMAKE_COMMAND} --build ${BINARY_DIR}
+   --config ${build_configuration}
+   ${ARG_BUILD_TOOL_ARGS}
+INSTALL_COMMAND ""
+STEP_TARGETS configure build
+USES_TERMINAL_CONFIGURE 1
+USES_TERMINAL_BUILD 1
+USES_TERMINAL_INSTALL 1
+LIST_SEPARATOR |
+  )
+endmacro()
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -785,24 +785,16 @@
   endforeach()
 
   # Build arguments for native tool used in CMake.
-  set(build_configuration "$")
   set(build_tool_args "${LLVM_EXTERNAL_PROJECT_BUILD_TOOL_ARGS}")
   if(NOT build_tool_args STREQUAL "")
 string(PREPEND build_tool_args "-- ")
 separate_arguments(build_tool_args UNIX_COMMAND "${build_tool_args}")
   endif()
 
-  ExternalProject_Add(${NEXT_CLANG_STAGE}
+  include(ClangBootstrap)
+  clang_Bootstrap_Add(${NEXT_CLANG_STAGE}
 DEPENDS clang-bootstrap-deps
-PREFIX ${NEXT_CLANG_STAGE}
-SOURCE_DIR ${CMAKE_SOURCE_DIR}
-STAMP_DIR ${STAMP_DIR}
-BINARY_DIR ${BINARY_DIR}
-EXCLUDE_FROM_ALL 1
 CMAKE_ARGS
-# We shouldn't need to set this here, but INSTALL_DIR doesn't
-# seem to work, so instead I'm passing this through
--DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
 ${PASSTHROUGH_VARIABLES}
 ${CLANG_BOOTSTRAP_CMAKE_ARGS}
  -DCLANG_STAGE=${NEXT_CLANG_STAGE}
@@ -814,16 +806,8 @@
 ${${CLANG_STAGE}_RANLIB}
 ${${CLANG_STAGE}_OBJCOPY}
 ${${CLANG_STAGE}_STRIP}
-BUILD_COMMAND ${CMAKE_COMMAND} --build ${BINARY_DIR}
-   --config ${build_configuration}
-   ${build_tool_args}
-INSTALL_COMMAND ""
-STEP_TARGETS configure build
-USES_TERMINAL_CONFIGURE 1
-USES_TERMINAL_BUILD 1
-USES_TERMINAL_INSTALL 1
-LIST_SEPARATOR |
-)
+BUILD_TOOL_ARGS ${build_tool_args}
+  )
 
   # exclude really-install from main target
   set_target_properties(${NEXT_CLANG_STAGE} PROPERTIES _EP_really-install_EXCLUDE_FROM_MAIN On)
@@ -904,37 +888,23 @@
   )
 
   # Build specified targets with instrumented Clang to collect the profile
-  set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/bolt-instrumented-clang-stamps/)
-  set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/bolt-instrumented-clang-bins/)
-  set(build_configuration "$")
-  include(ExternalProject)
-  ExternalProject_Add(bolt-instrumentation-profile
+  include(ClangBootstrap)
+  set(COMPILER_OPTIONS
+-DCMAKE_C_COMPILER=${CLANG_INSTRUMENTED}
+-DCMAKE_CXX_COMPILER=${CLANGXX_INSTRUMENTED}
+-DCMAKE_ASM_COMPILER=${CLANG_INSTRUMENTED}
+-DCMAKE_ASM_COMPILER_ID=Clang
+  )
+  clang_Bootstrap_Add(bolt-instrumentation-profile
 DEPENDS clang++-instrumented
-PREFIX bolt-instrumentation-profile
-SOURCE_DIR ${CMAKE_SOURCE_DIR}
-STAMP_DIR ${STAMP_DIR}
-BINARY_DIR ${BINARY_DIR}
-EXCLUDE_FROM_ALL 1
 CMAKE_ARGS
 ${CLANG_BOLT_INSTRUMENT_EXTRA_CMAKE_FLAGS}
-# We shouldn't need to set this here, but INSTALL_DIR doesn't
-# seem to work, so instead I'm passing this through
--DCMAKE_I

[PATCH] D137205: [clang-tidy] Add performance-unnecessary-copy-on-last-use check

2022-11-14 Thread Fabian Keßler via Phabricator via cfe-commits
Febbe added a comment.

I have a problem with lambdas capturing by copy implicitly (`[=]()...`). It 
seems like, that child nodes are not reachable via a MatchFinder unless they 
are spelled in source. I actually don't know how to prevent a fix elegantly: My 
proposed idea is, to check the source location of the capture list for each 
lambda and check, if the declRefExpr is part of it... . This is bug prone, and 
possibly slow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137205

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


[PATCH] D136998: Try to implement lambdas with inalloca parameters by inlining the call operator function.

2022-11-14 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

In D136998#3926321 , @rnk wrote:

> In D136998#3906874 , @efriedma 
> wrote:
>
>> Should we try to use this codepath for variadic lambdas as well?
>
> Yes!
>
>> Do we want to try to unify our cloning code?  
>> CodeGenFunction::GenerateVarArgsThunk has code doing something similar.  
>> (It's at least worth comparing to see if you're doing something 
>> significantly different...)
>
> Good idea
>
> In D136998#3906881 , @efriedma 
> wrote:
>
>> Might also be worth considering if we can avoid cloning here.  It should be 
>> possible to emit the lambda body into a separate function with a calling 
>> convention of your choice, and make both the call operator and the static 
>> invoker call it.
>
> This would be nice. I wasn't able to provide guidance on how to do that, and 
> I think Amy was struggling to synthesize a new method (`__invoke`, `__impl`) 
> at the AST layer.

I think you wouldn't actually synthesize it at all in the AST.

Basically, the follow code changes:

1. Change the mangling of the function that contains the actual lambda body.
2. Make that function use an alternate calling convention that doesn't involve 
inalloca etc.
3. Synthesize thunks to represent the actual call operator and static invoker.

This is similar to the way virtual overriding works: there's an actual 
function, but there are also alternate entry points that end up in the vtables.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136998

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


[PATCH] D137823: [clang-format][NFC] Moved configuration parsing tests in own file

2022-11-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/unittests/Format/ConfigParseTest.cpp:1006
+
+TEST(FormatStyle, GetStyleWithEmptyFileName) {
+  llvm::vfs::InMemoryFileSystem FS;

HazardyKnusperkeks wrote:
> owenpan wrote:
> > Otherwise, the test will be skipped.
> That is not true.
> It will be executed, and that was the name in the beginning.
> 
> I only changed the old `FormatTest` to `ParseTest` and didn't change these 3, 
> because I thought someone made this on purpose.
> 
> ```
> [ RUN  ] ParseTest.ConfigurationRoundTripTest
> [   OK ] ParseTest.ConfigurationRoundTripTest (4 ms)
> [--] 7 tests from ParseTest (201 ms total)
> 
> [--] 3 tests from FormatStyle
> [ RUN  ] FormatStyle.GetStyleWithEmptyFileName
> [   OK ] FormatStyle.GetStyleWithEmptyFileName (3 ms)
> ```
You are right. However, IMO we should still rename `FormatTest`. In fact, we 
should rename both `ParseTest` and `FormatTest` to `ConfigParseTest` to match 
the filename like other test files.


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

https://reviews.llvm.org/D137823

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


[PATCH] D137806: [AST] Fix class layout when using external layout under MS ABI.

2022-11-14 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk 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/D137806/new/

https://reviews.llvm.org/D137806

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


[PATCH] D136998: Try to implement lambdas with inalloca parameters by inlining the call operator function.

2022-11-14 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D136998#3906874 , @efriedma wrote:

> Should we try to use this codepath for variadic lambdas as well?

Yes!

> Do we want to try to unify our cloning code?  
> CodeGenFunction::GenerateVarArgsThunk has code doing something similar.  
> (It's at least worth comparing to see if you're doing something significantly 
> different...)

Good idea

In D136998#3906881 , @efriedma wrote:

> Might also be worth considering if we can avoid cloning here.  It should be 
> possible to emit the lambda body into a separate function with a calling 
> convention of your choice, and make both the call operator and the static 
> invoker call it.

This would be nice. I wasn't able to provide guidance on how to do that, and I 
think Amy was struggling to synthesize a new method (`__invoke`, `__impl`) at 
the AST layer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136998

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


[clang] 77bf0df - Revert "[opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvm"

2022-11-14 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-11-14T15:51:03-08:00
New Revision: 77bf0df376d7fcd305d9576511e7d0806b96971a

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

LOG: Revert "[opt][clang] Enable using -module-summary/-flto=thin with 
-S/-emit-llvm"

This reverts commit bf8381a8bce28fc69857645cc7e84a72317e693e.

There is a layering violation: LLVMAnalysis depends on LLVMCore, so
LLVMCore should not include LLVMAnalysis header
llvm/Analysis/ModuleSummaryAnalysis.h

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
clang/test/CodeGen/split-lto-unit.c
llvm/include/llvm/IR/IRPrintingPasses.h
llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
llvm/lib/IR/IRPrintingPasses.cpp
llvm/test/Bitcode/thinlto-function-summary.ll
llvm/tools/opt/NewPMDriver.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 26633f8007037..41f9ce3a009da 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -978,24 +978,19 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
   if (!actionRequiresCodeGen(Action) && CodeGenOpts.VerifyModule)
 MPM.addPass(VerifierPass());
 
-  if (Action == Backend_EmitBC || Action == Backend_EmitLL) {
+  switch (Action) {
+  case Backend_EmitBC:
 if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
+  if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
+ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
+if (!ThinLinkOS)
+  return;
+  }
   if (!TheModule->getModuleFlag("EnableSplitLTOUnit"))
 TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
  CodeGenOpts.EnableSplitLTOUnit);
-  if (Action == Backend_EmitBC) {
-if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
-  ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
-  if (!ThinLinkOS)
-return;
-}
-MPM.addPass(ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? 
&ThinLinkOS->os()
- : nullptr));
-  } else {
-MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists,
-true /* EmitLTOSummary */));
-  }
-
+  MPM.addPass(ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &ThinLinkOS->os()
+   : nullptr));
 } else {
   // Emit a module summary by default for Regular LTO except for ld64
   // targets
@@ -1007,13 +1002,17 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
   TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
uint32_t(1));
   }
-  if (Action == Backend_EmitBC)
-MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
-  EmitLTOSummary));
-  else
-MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists,
-EmitLTOSummary));
+  MPM.addPass(
+  BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists, 
EmitLTOSummary));
 }
+break;
+
+  case Backend_EmitLL:
+MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists));
+break;
+
+  default:
+break;
   }
 
   // Now that we have all of the passes ready, run them.

diff  --git a/clang/test/CodeGen/split-lto-unit.c 
b/clang/test/CodeGen/split-lto-unit.c
index b1560b61f3e30..941aebafd01b3 100644
--- a/clang/test/CodeGen/split-lto-unit.c
+++ b/clang/test/CodeGen/split-lto-unit.c
@@ -1,15 +1,12 @@
 // ; Check that -flto=thin without -fsplit-lto-unit has EnableSplitLTOUnit = 0
 // RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s
-// RUN: %clang_cc1 -flto=thin -emit-llvm < %s | FileCheck %s
 // CHECK: !{i32 1, !"EnableSplitLTOUnit", i32 0}
 //
 // ; Check that -flto=thin with -fsplit-lto-unit has EnableSplitLTOUnit = 1
 // RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm-bc < %s | llvm-dis 
-o - | FileCheck %s --check-prefix=SPLIT
-// RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm < %s | FileCheck %s 
--check-prefix=SPLIT
 // SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1}
 //
 // ; Check that regular LTO has EnableSplitLTOUnit = 1
 // RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | 
llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" 
--check-prefix=SPLIT
-// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm < %s | 
FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
 
 int main(void) {}

diff  --git a/llvm/include/llvm/IR/IRPrintingPasses.h 
b/llvm/include/llvm/IR/IRPrintingPasses.h
index 5f4880643c52d.

[PATCH] D137962: [clang][Tooling] Make the filename behaviour consistent

2022-11-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Code change LGTM, i think the doc change should be dropped or reshaped though.




Comment at: clang/docs/JSONCompilationDatabase.rst:89
same file, for example if the same source file is compiled with
-   different configurations.
+   different configurations. ``dot`` (./) ``dotdot`` (../) in the path is
+   stripped lexically.

This doesn't fit with the rest of the spec text: the new text describing tool 
behavior, while everything else describes the data.

I'm not totally sure about documenting this (it's of pretty limited interest, 
doesn't cover symlink handling exhaustively, and seems more a limitation of the 
tools than a feature of the format). If you do want to I'd suggest separating 
it from the format description into a separate paragraph below (e.g. "Because 
compilation databases can be large, tools match filenames are matched against 
entries textually without IO. This means they generally don't understand 
symlinks.")


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137962

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


[PATCH] D137989: [clang][deps] Avoid leaking modulemap paths across unrelated imports

2022-11-14 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added inline comments.



Comment at: clang/lib/Serialization/ASTWriter.cpp:1561
   else
 // FIXME: The path should be taken from the FileEntryRef.
 PP->Diag(SourceLocation(), diag::err_module_unable_to_hash_content)

jansvoboda11 wrote:
> Do you think resolving this fixme warrants separate patch?
Good catch, I'll remove this FIXME. Usually diagnostics use the on-disk path, 
so I think FileEntryRef::getName is correct here and we don't need to change it 
to getNameAsRequested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137989

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


[PATCH] D137217: [LTO][COFF] Use bitcode file names in lto native object file names.

2022-11-14 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1104
 
-  auto AddStream = [&](size_t Task) {
+  auto AddStream = [&](size_t Task, Twine File) {
 return std::make_unique(std::move(OS),

tejohnson wrote:
> I think you might need to mark the new parameter as unused here and in other 
> cases where it isn't used via LLVM_ATTRIBUTE_UNUSED, to avoid build warnings 
> - I can't recall how strictly that is enforced.
LLVM_ATTRIBUTE_UNUSED is used to suppress unused functions. For unused 
parameter, I don't see any build warnings when compiling with this patch. I 
feel like it's very common to have unused parameter. 



Comment at: lld/COFF/LTO.cpp:229
+StringRef ltoObjName;
+if (bitcodeFilePath == "ld-temp.o") {
+  ltoObjName =

tejohnson wrote:
> This case should always be i==0 I think?
IIUC, "ld-temp.o" is the name of combined module. Do you mean there will be 
only 1 combined module and it will always be the first task?



Comment at: lld/COFF/LTO.cpp:245
+  saveBuffer(buf[i].second, ltoObjName);
 ret.push_back(make(ctx, MemoryBufferRef(objBuf, ltoObjName)));
   }

tejohnson wrote:
> The above changes affect both the MemoryBufferRef name as well as the 
> saveTemps output file name. I assume the change to the former is what is 
> required for PDB, is that correct?
Yes, it changes both the MemoryBufferRef and the saveTemps output file name 
otherwise the saveTemps output file name won't match with the the names in pdb. 
The former is what's written into PDB.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137217

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


[PATCH] D137217: [LTO][COFF] Use bitcode file names in lto native object file names.

2022-11-14 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 475296.
zequanwu marked 2 inline comments as done.
zequanwu added a comment.

Update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137217

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
  lld/COFF/LTO.cpp
  lld/COFF/LTO.h
  lld/ELF/LTO.cpp
  lld/MachO/LTO.cpp
  lld/test/COFF/lto-obj-path.ll
  lld/test/COFF/pdb-thinlto.ll
  lld/test/COFF/thinlto.ll
  lld/wasm/LTO.cpp
  lldb/source/Core/DataFileCache.cpp
  llvm/include/llvm/Support/Caching.h
  llvm/lib/Debuginfod/Debuginfod.cpp
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Support/Caching.cpp
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp

Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -411,7 +411,8 @@
   if (HasErrors)
 return 1;
 
-  auto AddStream = [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task,
+   Twine ModuleName) -> std::unique_ptr {
 std::string Path = OutputFilename + "." + utostr(Task);
 
 std::error_code EC;
@@ -420,8 +421,9 @@
 return std::make_unique(std::move(S), Path);
   };
 
-  auto AddBuffer = [&](size_t Task, std::unique_ptr MB) {
-*AddStream(Task)->OS << MB->getBuffer();
+  auto AddBuffer = [&](size_t Task, Twine ModuleName,
+   std::unique_ptr MB) {
+*AddStream(Task, ModuleName)->OS << MB->getBuffer();
   };
 
   FileCache Cache;
Index: llvm/tools/llvm-lto/llvm-lto.cpp
===
--- llvm/tools/llvm-lto/llvm-lto.cpp
+++ llvm/tools/llvm-lto/llvm-lto.cpp
@@ -317,11 +317,11 @@
   if (!CurrentActivity.empty())
 OS << ' ' << CurrentActivity;
   OS << ": ";
-  
+
   DiagnosticPrinterRawOStream DP(OS);
   DI.print(DP);
   OS << '\n';
-  
+
   if (DI.getSeverity() == DS_Error)
 exit(1);
   return true;
@@ -1099,7 +1099,9 @@
 error("writing merged module failed.");
 }
 
-auto AddStream = [&](size_t Task) -> std::unique_ptr {
+auto AddStream =
+[&](size_t Task,
+Twine ModuleName) -> std::unique_ptr {
   std::string PartFilename = OutputFilename;
   if (Parallelism != 1)
 PartFilename += "." + utostr(Task);
Index: llvm/lib/Support/Caching.cpp
===
--- llvm/lib/Support/Caching.cpp
+++ llvm/lib/Support/Caching.cpp
@@ -37,7 +37,8 @@
   TempFilePrefixRef.toVector(TempFilePrefix);
   CacheDirectoryPathRef.toVector(CacheDirectoryPath);
 
-  return [=](unsigned Task, StringRef Key) -> Expected {
+  return [=](unsigned Task, StringRef Key,
+ Twine ModuleName) -> Expected {
 // This choice of file name allows the cache to be pruned (see pruneCache()
 // in include/llvm/Support/CachePruning.h).
 SmallString<64> EntryPath;
@@ -54,7 +55,7 @@
 /*RequiresNullTerminator=*/false);
   sys::fs::closeFile(*FDOrErr);
   if (MBOrErr) {
-AddBuffer(Task, std::move(*MBOrErr));
+AddBuffer(Task, ModuleName, std::move(*MBOrErr));
 return AddStreamFn();
   }
   EC = MBOrErr.getError();
@@ -77,14 +78,15 @@
 struct CacheStream : CachedFileStream {
   AddBufferFn AddBuffer;
   sys::fs::TempFile TempFile;
+  std::string ModuleName;
   unsigned Task;
 
   CacheStream(std::unique_ptr OS, AddBufferFn AddBuffer,
   sys::fs::TempFile TempFile, std::string EntryPath,
-  unsigned Task)
+  std::string ModuleName, unsigned Task)
   : CachedFileStream(std::move(OS), std::move(EntryPath)),
 AddBuffer(std::move(AddBuffer)), TempFile(std::move(TempFile)),
-Task(Task) {}
+ModuleName(ModuleName), Task(Task) {}
 
   ~CacheStream() {
 // TODO: Manually commit rather than using non-trivial destructor,
@@ -133,11 +135,12 @@
  TempFile.TmpName + " to " + ObjectPathName + ": " +
  toString(std::move(E)) + "\n");
 
-AddBuffer(Task, std::move(*MBOrErr));
+AddBuffer(Task, ModuleName, std::move(*MBOrErr));
   }
 };
 
-return [=](size_t Task) -> Expected> {
+return [=](size_t Task, Twine ModuleName)
+   -> Expected> {
   // Create the cache directory if not already done. Doing this lazily
   // ensures the filesystem isn't mutated until the cache is.
   if (std::error_code EC = sys::fs::create_directories(
@@ -158,7 +161,8 @@
   // This CacheStream will move the temporary file into the cache when done.
   return std::make_unique(
   std::make_unique(Tem

[clang] bf8381a - [opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvm

2022-11-14 Thread Alexander Shaposhnikov via cfe-commits

Author: Alexander Shaposhnikov
Date: 2022-11-14T23:24:08Z
New Revision: bf8381a8bce28fc69857645cc7e84a72317e693e

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

LOG: [opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvm

Enable using -module-summary with -S
(similarly to what currently can be achieved with opt  -o - | llvm-dis).
This is a recommit of ef9e62469.

Test plan: ninja check-all

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
clang/test/CodeGen/split-lto-unit.c
llvm/include/llvm/IR/IRPrintingPasses.h
llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
llvm/lib/IR/IRPrintingPasses.cpp
llvm/test/Bitcode/thinlto-function-summary.ll
llvm/tools/opt/NewPMDriver.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 41f9ce3a009da..26633f8007037 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -978,19 +978,24 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
   if (!actionRequiresCodeGen(Action) && CodeGenOpts.VerifyModule)
 MPM.addPass(VerifierPass());
 
-  switch (Action) {
-  case Backend_EmitBC:
+  if (Action == Backend_EmitBC || Action == Backend_EmitLL) {
 if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
-  if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
-ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
-if (!ThinLinkOS)
-  return;
-  }
   if (!TheModule->getModuleFlag("EnableSplitLTOUnit"))
 TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
  CodeGenOpts.EnableSplitLTOUnit);
-  MPM.addPass(ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &ThinLinkOS->os()
-   : nullptr));
+  if (Action == Backend_EmitBC) {
+if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
+  ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
+  if (!ThinLinkOS)
+return;
+}
+MPM.addPass(ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? 
&ThinLinkOS->os()
+ : nullptr));
+  } else {
+MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists,
+true /* EmitLTOSummary */));
+  }
+
 } else {
   // Emit a module summary by default for Regular LTO except for ld64
   // targets
@@ -1002,17 +1007,13 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
   TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
uint32_t(1));
   }
-  MPM.addPass(
-  BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists, 
EmitLTOSummary));
+  if (Action == Backend_EmitBC)
+MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
+  EmitLTOSummary));
+  else
+MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists,
+EmitLTOSummary));
 }
-break;
-
-  case Backend_EmitLL:
-MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists));
-break;
-
-  default:
-break;
   }
 
   // Now that we have all of the passes ready, run them.

diff  --git a/clang/test/CodeGen/split-lto-unit.c 
b/clang/test/CodeGen/split-lto-unit.c
index 941aebafd01b3..b1560b61f3e30 100644
--- a/clang/test/CodeGen/split-lto-unit.c
+++ b/clang/test/CodeGen/split-lto-unit.c
@@ -1,12 +1,15 @@
 // ; Check that -flto=thin without -fsplit-lto-unit has EnableSplitLTOUnit = 0
 // RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s
+// RUN: %clang_cc1 -flto=thin -emit-llvm < %s | FileCheck %s
 // CHECK: !{i32 1, !"EnableSplitLTOUnit", i32 0}
 //
 // ; Check that -flto=thin with -fsplit-lto-unit has EnableSplitLTOUnit = 1
 // RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm-bc < %s | llvm-dis 
-o - | FileCheck %s --check-prefix=SPLIT
+// RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm < %s | FileCheck %s 
--check-prefix=SPLIT
 // SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1}
 //
 // ; Check that regular LTO has EnableSplitLTOUnit = 1
 // RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | 
llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" 
--check-prefix=SPLIT
+// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm < %s | 
FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
 
 int main(void) {}

diff  --git a/llvm/include/llvm/IR/IRPrintingPasses.h 
b/llvm/include/llvm/IR/IRPrintingPasses.h
index 3fba5b81

[PATCH] D137992: [asan] -fsanitize-address-outline-instrumentation -> -asan-max-inline-poisoning-size=0

2022-11-14 Thread Roy Sundahl via Phabricator via cfe-commits
rsundahl created this revision.
Herald added a project: All.
rsundahl requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

The clang flag -fsanitize-address-outline-instrumentation should not only pass
-asan-instrumentation-with-call-threshold=0 to the sanitizer, but should also
pass -asan-max-inline-poisoning-size=0. Both flags' cutoff values need to be set
to zero to suppress inlining in favor of making calls into compiler-rt.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137992

Files:
  clang/lib/Driver/SanitizerArgs.cpp


Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -1256,6 +1256,9 @@
   if (AsanOutlineInstrumentation) {
 CmdArgs.push_back("-mllvm");
 CmdArgs.push_back("-asan-instrumentation-with-call-threshold=0");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-asan-max-inline-poisoning-size=0");
+
   }
 
   // Only pass the option to the frontend if the user requested,


Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -1256,6 +1256,9 @@
   if (AsanOutlineInstrumentation) {
 CmdArgs.push_back("-mllvm");
 CmdArgs.push_back("-asan-instrumentation-with-call-threshold=0");
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-asan-max-inline-poisoning-size=0");
+
   }
 
   // Only pass the option to the frontend if the user requested,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137989: [clang][deps] Avoid leaking modulemap paths across unrelated imports

2022-11-14 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!




Comment at: clang/lib/Serialization/ASTWriter.cpp:1561
   else
 // FIXME: The path should be taken from the FileEntryRef.
 PP->Diag(SourceLocation(), diag::err_module_unable_to_hash_content)

Do you think resolving this fixme warrants separate patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137989

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


[PATCH] D137989: [clang][deps] Avoid leaking modulemap paths across unrelated imports

2022-11-14 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added reviewers: jansvoboda11, Bigcheese.
Herald added a project: All.
benlangmuir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Use a FileEntryRef when retrieving modulemap paths in the scanner so that we 
use a path compatible with the original module import, rather than a FileEntry 
which can allow unrelated modules to leak paths into how we build a module due 
to FileManager mutating the path.

Note: the current change prevents an "unrelated" path, but does not change how 
VFS mapped paths are handled (which would be calling getNameAsRequested) nor 
canonicalize the path.  In that sense, this is a narrower version of  
https://reviews.llvm.org/D135636 that should not be blocked by the VFS concerns.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137989

Files:
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/modules-symlink-dir-from-module.c

Index: clang/test/ClangScanDeps/modules-symlink-dir-from-module.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-symlink-dir-from-module.c
@@ -0,0 +1,94 @@
+// Check that the path of an imported modulemap file is not influenced by
+// modules outside that module's dependency graph. Specifically, the "Foo"
+// module below does not transitively import Mod via a symlink, so it should not
+// see the symlinked path.
+
+// REQUIRES: shell
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json
+// RUN: ln -s module %t/include/symlink-to-module
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -j 1 \
+// RUN:   -format experimental-full  -mode=preprocess-dependency-directives \
+// RUN:   -optimize-args -module-files-dir %t/build > %t/deps.json
+
+// RUN: cat %t/deps.json | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t
+
+// CHECK: "modules": [
+// CHECK:   {
+// CHECK: "command-line": [
+// CHECK:   "-fmodule-map-file=[[PREFIX]]/include/module/module.modulemap"
+// CHECK: ]
+// CHECK: "name": "Foo"
+// CHECK:   }
+// CHECK:   {
+// CHECK: "command-line": [
+// FIXME: canonicalize this path
+// CHECK:   "-fmodule-map-file=[[PREFIX]]/include/symlink-to-module/module.modulemap"
+// CHECK: ]
+// CHECK: "name": "Foo_Private"
+// CHECK:   }
+// CHECK:   {
+// CHECK: "command-line": [
+// CHECK:   "[[PREFIX]]/include/module/module.modulemap"
+// CHECK: ]
+// CHECK: "name": "Mod"
+// CHECK:   }
+// CHECK:   {
+// CHECK: "command-line": [
+// FIXME: canonicalize this path
+// CHECK:   "-fmodule-map-file=[[PREFIX]]/include/symlink-to-module/module.modulemap"
+// CHECK: ]
+// CHECK: "name": "Other"
+// CHECK:   }
+// CHECK:   {
+// CHECK: "command-line": [
+// FIXME: canonicalize this path
+// CHECK:   "-fmodule-map-file=[[PREFIX]]/include/symlink-to-module/module.modulemap"
+// CHECK: ]
+// CHECK: "name": "Test"
+// CHECK:   }
+// CHECK: ]
+
+//--- cdb.json.in
+[{
+  "directory": "DIR",
+  "command": "clang -fsyntax-only DIR/test.c -F DIR/Frameworks -I DIR/include -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/module-cache",
+  "file": "DIR/test.c"
+}]
+
+//--- include/module/module.modulemap
+module Mod { header "mod.h" export * }
+
+//--- include/module/mod.h
+
+//--- include/module.modulemap
+module Other { header "other.h" export * }
+
+//--- include/other.h
+#include "symlink-to-module/mod.h"
+#include "module/mod.h"
+
+//--- Frameworks/Foo.framework/Modules/module.modulemap
+framework module Foo { header "Foo.h" export * }
+//--- Frameworks/Foo.framework/Modules/module.private.modulemap
+framework module Foo_Private { header "Priv.h" export * }
+
+//--- Frameworks/Foo.framework/Headers/Foo.h
+#include "module/mod.h"
+
+//--- Frameworks/Foo.framework/PrivateHeaders/Priv.h
+#include 
+#include "other.h"
+
+//--- module.modulemap
+module Test { header "test.h" export * }
+
+//--- test.h
+#include 
+#include 
+
+//--- test.c
+#include "test.h"
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -447,10 +447,10 @@
   addAllAffectingClangModules(M, MD, SeenDeps);
 
   MDC.ScanInstance.getASTReader()->visitTopLevelModuleMaps(
-  *MF, [&](const FileEntry *FE) {
-if (FE->getName().endswith("__inferred_module.map"))
+  *MF, [&](FileEntryRef FE) {
+if (FE.getName().endswith("__inferred_module.map"))
   return;
-MD.ModuleMapFileDeps.emplace_back(FE->getName());
+MD.ModuleMapFil

[PATCH] D137381: [clang][compiler-rt] Exception escape out of an non-unwinding function is an undefined behaviour

2022-11-14 Thread John McCall via Phabricator via cfe-commits
rjmccall added a subscriber: jyknight.
rjmccall added a comment.

I don't have a problem with adding a sanitizer like this.  IIRC, though, 
there's a review process for adding new sanitizers; I don't remember if this is 
the normal RFC process or something more streamlined.  Also, I know @jyknight 
is interested in a mode that checks `-fno-exceptions` more efficiently, which 
is of direct relevance to what you're trying here; that was discussed in a 
forums thread 
(https://discourse.llvm.org/t/rfc-add-call-unwindabort-to-llvm-ir/62543).

The implementation and tests here don't seem to match the stated problem, 
though.  Trying to throw out of a `noexcept` function is actually well-defined 
— the function has to catch the exception and call `std::terminate`, and we do 
actually generate code that way.  Your patch is just adding a check at the 
start of the handler we emit, which means it's not catching anything we're not 
already catching; also, again, this is a well-defined execution path, so it 
doesn't seem appropriate to trigger UBSan on it.

IIRC, there are really only two potential sources of UB with `noexcept`.  The 
first is that you can declare a function `noexcept(true)` but implement it as 
`noexcept(false)`, which is in a class of problems (ODR violations) that I 
think UBSan doesn't normally try to diagnose.  The second is that I think it's 
possible to get a `noexcept(true)` function pointer for a `noexcept(false)` 
function, maybe via some chain of casts; that would be a little closer to what 
UBSan normally diagnoses.

Meanwhile, your original test case has nothing to do with `noexcept`. 
`__attribute__((pure))` (like `nothrow` and `-fno-exceptions`) really does 
introduce a novel UB rule which it would be reasonable to ask the compiler to 
check under UBSan.

I think the right way to handle what you're trying to handle would be to 
introduce some different kind of scope, a "it's UB to unwind out of this" 
scope, and then push that scope around calls and implementations of functions 
that use one of the UB-to-throw attributes.  You could also potentially push 
that scope around calls to `nounwind` functions if you want to catch those ODR 
/ function-pointer cases.




Comment at: clang/lib/CodeGen/CodeGenFunction.h:2021
 
-  llvm::BasicBlock *getInvokeDest() {
+  llvm::BasicBlock *getInvokeDest(SourceLocation Loc = SourceLocation()) {
 if (!EHStack.requiresLandingPad()) return nullptr;

I'm not sure why this has a default argument.



Comment at: clang/lib/CodeGen/CodeGenFunction.h:2028
+// FIXME: what about FuncletPads?
+if (llvm::BasicBlock *InvokeBB = Builder.GetInsertBlock();
+SanOpts.has(SanitizerKind::ExceptionEscape) &&

The purpose of `getInvokeDestImpl` is to outline the slow path, and this 
definitely belongs in the slow path.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137381

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


[PATCH] D137986: [Clang][CodeGen][AIX] Map __builtin_frexpl, __builtin_ldexpl, and __builtin_modfl to 'double' version lib calls in 64-bit 'long double' mode

2022-11-14 Thread Xing Xue via Phabricator via cfe-commits
xingxue created this revision.
xingxue added reviewers: rjmccall, hubert.reinterpretcast, daltenty, 
cebowleratibm.
xingxue added a project: LLVM.
Herald added a project: All.
xingxue requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

AIX library functions `frexpl()`, `ldexpl()`, and `modfl()` are for 128-bit 
`long double`. Other `*l()` functions, e.g., `acosl()`, are for 64-bit `long 
double`. The AIX Clang compiler currently maps builtin functions 
`__builtin_frexpl()`, `__builtin_ldexpl()`, and `__builtin_modfl()` to 
`frexpl()`, `ldexpl()`, and `modfl()` in 64-bit `long double` mode which 
results in seg-faults or incorrect return values. This patch changes to map 
`__builtin_frexpl()`, `__builtin_ldexpl()`, and `__builtin_modfl()` to `double` 
version lib functions `frexp()`, `ldexp()` and `modf()` in 64-bit `long double` 
mode. The following is from AIX .

  /*
   * frexpl(), ldexpl(), and modfl() have preexisting shared versions which are
   * 128-bit only.  64-bit versions must be made available for C99 for the
   * default 64-bit long double.  These cannot simply be macros because the
   * actual routines will be the incorrect form in 64-bit mode if the user
   * forces the actual routines to be used through undef or macro suppression
   * per the standard.
   */
  #if defined(_ISOC99_SOURCE) && !defined(__LONGDOUBLE128)
  static long double _NOTHROW(frexpl, (long double __x, int *__i))
  {
   return (long double) frexp((double) __x, __i);
  }
  
  static long double _NOTHROW(ldexpl, (long double __x, int __i))
  {
   return (long double) ldexp((double) __x, __i);
  }
  
  #ifndef __MODFL
  static long double _NOTHROW(modfl, (long double __x, long double *__y))
  {
   return (long double) modf((double) __x, (double *) __y);
  }
  #endif
  #endif


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137986

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aix-builtin-mapping.c


Index: clang/test/CodeGen/aix-builtin-mapping.c
===
--- /dev/null
+++ clang/test/CodeGen/aix-builtin-mapping.c
@@ -0,0 +1,22 @@
+// AIX library functions frexpl, ldexpl, and modfl are for 128-bit
+// 'long double'. Check that the compiler generates calls to the 'double'
+// versions for correspoding builtin functions in 64-bit 'long double' mode.
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix -mlong-double-64 -S -o - %s | 
FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -mlong-double-64 -S -o - %s | 
FileCheck %s -check-prefix=CHECK
+
+int main()
+{
+  int DummyInt;
+  long double DummyLongDouble;
+  long double returnValue;
+
+  returnValue = __builtin_modfl(1.0L, &DummyLongDouble);
+  returnValue = __builtin_frexpl(0.0L, &DummyInt);
+  returnValue = __builtin_ldexpl(1.0L, 1);
+}
+
+// CHECK:  bl .modf[PR]
+// CHECK:  bl .frexp[PR]
+// CHECK:  bl .ldexp[PR]
+
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -106,6 +106,15 @@
   {Builtin::BI__builtin_nexttowardf128, "__nexttowardieee128"},
   };
 
+  // The AIX library functions frexpl, ldexpl, and modfl are for 128-bit
+  // 'long double'. Map to the 'double' versions if it is 64-bit 'long
+  // double' mode.
+  static SmallDenseMap AIXLongDoubleBuiltins{
+  {Builtin::BI__builtin_frexpl, "frexp"},
+  {Builtin::BI__builtin_ldexpl, "ldexp"},
+  {Builtin::BI__builtin_modfl, "modf"},
+  };
+
   // If the builtin has been declared explicitly with an assembler label,
   // use the mangled name. This differs from the plain label on platforms
   // that prefix labels.
@@ -118,6 +127,12 @@
 &getTarget().getLongDoubleFormat() == &llvm::APFloat::IEEEquad() &&
 F128Builtins.find(BuiltinID) != F128Builtins.end())
   Name = F128Builtins[BuiltinID];
+else if (getTriple().isOSAIX() &&
+ &getTarget().getLongDoubleFormat() ==
+ &llvm::APFloat::IEEEdouble() &&
+ AIXLongDoubleBuiltins.find(BuiltinID) !=
+ AIXLongDoubleBuiltins.end())
+  Name = AIXLongDoubleBuiltins[BuiltinID];
 else
   Name = Context.BuiltinInfo.getName(BuiltinID) + 10;
   }


Index: clang/test/CodeGen/aix-builtin-mapping.c
===
--- /dev/null
+++ clang/test/CodeGen/aix-builtin-mapping.c
@@ -0,0 +1,22 @@
+// AIX library functions frexpl, ldexpl, and modfl are for 128-bit
+// 'long double'. Check that the compiler generates calls to the 'double'
+// versions for correspoding builtin functions in 64-bit 'long double' mode.
+
+// RUN: %clang_cc1 -triple powerpc-ibm-aix -mlong-double-64 -S -o - %s | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix -mlong-double-64 -S -o - %s | FileCheck %s -check-prefix=CHECK
+
+int m

[PATCH] D137381: [clang][compiler-rt] Exception escape out of an non-unwinding function is an undefined behaviour

2022-11-14 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D137381#3924698 , @lebedev.ri 
wrote:

> Can someone from @Sanitizers please comment? :) @vitalybuka ? @glider ? 
> @rsmith  ?
>
> In D137381#3923911 , @MaskRay wrote:
>
>> I think improving diagnostic is useful but `-fsanitize=` is probably not a 
>> good place.

@MaskRay Seems find to me. Why do you think so?

>> Instrumenting call sites with `callq   __ubsan_handle_exception_escape@PLT` 
>> wastes code size.
>
> Can you please explain why replacing one call with another somehow makes 
> things worse?

Would be nice to see some measuraments? E.g. CTMark.

>> The functionality is better handled somewhere in libc++abi personality 
>> related code
>
> That would not be helpful, i'm not using libc++.
> It seems obviously wrong to me to require every used C++ ABI library
> to implement "some improvements", instead, you know,
> the clang irgen + clang ubsan lib.
>
> If we do this, we have native source location info for the location of the 
> call site
> out of which the exception has escaped, that causes the "abort".
> I do not know if that will be possible with less native approach.
>
> The reason i'm doing this, is because recently i had to deal with a few of 
> these bugs,
> and i never got any kind of backtrace, so the situation can't not be made 
> better.
>
>> with possible improvement to exception handling related LLVM IR.
>
>
>
>>   void bar(); void foo() { bar(); }
>>
>> `clang++ -fno-exceptions -fsanitize=exception-escape -c b.cc` does not 
>> instrument the potentially-throwing-and-propagating `bar()` so an error 
>> cannot be caught.
>
> i'm only looking at `-fexceptions` side of things, i'm not sure how
> mixing `-fno-exceptions` and `-fexceptions` code is supposed to work.

Handling this case would be usefull.

> It is not oblivious to me why not dealing with some other situation
> means we can't deal with the situation we can deal with.
>
>> However, for `-fno-exceptions` code, instrumenting every call site is going 
>> to greatly increase code size and suppress optimizations.
>
> Citation needed/define "greatly"?
> We have a single "termination" landing pad per function,
> and we seem to end up with just a single extra `jmp` per call.
> https://godbolt.org/z/Td3jWM1oh
>
> But yes, that's the known and expected nature of sanitization.
>
>> I wish that I capture the compiler and runtime behavior well in 
>> https://maskray.me/blog/2020-12-12-c++-exception-handling-abi#compiler-behavior.
>>  
>> https://discourse.llvm.org/t/catching-exceptions-while-unwinding-through-fno-exceptions-code/57151
>>  is a proposal to improve the diagnostics.
>
> Thanks. That explains current behavior, but does not tell why it must be 
> enshrined and never changed.






Comment at: clang/docs/ReleaseNotes.rst:806
+- A new Undefined Behavior Sanitizer check has been implemented:
+  ``-fsanitize-exception-escape`` (part of ``-fsanitize=undefined``),
+  which catches cases of C++ exceptions trying to unwind




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137381

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


[PATCH] D137948: [clang][dataflow] Add widening API and implement it for built-in boolean model.

2022-11-14 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h:68
+/// `LatticeT` can optionally provide the following members:
+///  * `bool widen(const LatticeT &Previous)` - chooses a lattice element that
+/// approximates the join of this element with the argument. Widen is 
called

We should document what is the return value for. Also I see `LatticeJoinEffect` 
instead of bool in the code, but I might be confused.



Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h:108
 
+  LatticeJoinEffect widenTypeErased(TypeErasedLattice &Current,
+const TypeErasedLattice &Previous) final {

I wonder if `LatticeJoinEffect` is the right name if we also use this for 
widening. (Also, are we in the process of removing these?)



Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h:140
+///
+///  `Prev` must precede `Current` in the value ordering.
+///

First, I was confused, because I thought they could be equivalent as well. But 
I guess this code is only called for values that are not considered equivalent. 
Documenting this is really useful.



Comment at: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:374-378
+  Environment WidenedEnv(*DACtx);
+
+  WidenedEnv.CallStack = CallStack;
+  WidenedEnv.ReturnLoc = ReturnLoc;
+  WidenedEnv.ThisPointeeLoc = ThisPointeeLoc;

Shouldn't we have a simple copy ctor from PrefEnv that could populate all these 
fields?

Also, this makes me wonder if we actually want to move some of these out from 
environment, since these presumably would not change between basic blocks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137948

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


[PATCH] D136998: Try to implement lambdas with inalloca parameters by inlining the call operator function.

2022-11-14 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 475269.
akhuang added a comment.

Fix calling convention of cloned function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136998

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/inalloca-lambda.cpp

Index: clang/test/CodeGenCXX/inalloca-lambda.cpp
===
--- clang/test/CodeGenCXX/inalloca-lambda.cpp
+++ clang/test/CodeGenCXX/inalloca-lambda.cpp
@@ -1,7 +1,4 @@
-// RUN: not %clang_cc1 -triple i686-windows-msvc -emit-llvm -o /dev/null %s  2>&1 | FileCheck %s
-
-// PR28299
-// CHECK: error: cannot compile this forwarded non-trivially copyable parameter yet
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -o - %s  2>&1 | FileCheck %s
 
 class A {
   A(const A &);
@@ -9,3 +6,7 @@
 typedef void (*fptr_t)(A);
 fptr_t fn1() { return [](A) {}; }
 
+// CHECK: define internal void @"?__invoke@@?0??fn1@@YAP6AXVA@@@ZXZ@CA?A?@@0@Z"
+// CHECK-SAME: (ptr inalloca(<{ %class.A, [3 x i8] }>) %0)
+// CHECK: %1 = getelementptr inbounds <{ %class.A, [3 x i8] }>, ptr %0, i32 0, i32 0
+// CHECK: ret void
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -3554,6 +3554,18 @@
 EmitGlobalFunctionDefinition(GD, GV);
 }
 
+static bool isInAllocaArg(CGCXXABI &ABI, QualType T) {
+  const CXXRecordDecl *RD = T->getAsCXXRecordDecl();
+  return RD && ABI.getRecordArgABI(RD) == CGCXXABI::RAA_DirectInMemory;
+}
+
+static bool hasInAllocaArg(const TargetInfo &TI, CGCXXABI &CGABI, const CXXMethodDecl *MD) {
+  return TI.getCXXABI().isMicrosoft() && 
+llvm::any_of(MD->parameters(), [&](ParmVarDecl *P) {
+return isInAllocaArg(CGABI, P->getType());
+  });
+}
+
 void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD, llvm::GlobalValue *GV) {
   const auto *D = cast(GD.getDecl());
 
@@ -3580,6 +3592,14 @@
   // This is necessary for the generation of certain thunks.
   if (isa(Method) || isa(Method))
 ABI->emitCXXStructor(GD);
+  // Special path for emitting lambda static invokers with inalloca parameters.
+  else if (Method->isLambdaStaticInvoker() && 
+   hasInAllocaArg(getTarget(), getCXXABI(), Method)) {
+// Emit the call operator definition before emitting a static invoker.
+const CXXMethodDecl *CallOp = Method->getParent()->getLambdaCallOperator();
+EmitGlobalFunctionDefinition(GlobalDecl(CallOp), nullptr);
+CodeGenFunction(*this).EmitClonedLambdaStaticInvoke(Method);
+  }
   else if (FD->isMultiVersion())
 EmitMultiVersionFunctionDefinition(GD, GV);
   else
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -2223,6 +2223,8 @@
   void EmitLambdaBlockInvokeBody();
   void EmitLambdaDelegatingInvokeBody(const CXXMethodDecl *MD);
   void EmitLambdaStaticInvokeBody(const CXXMethodDecl *MD);
+  void EmitClonedLambdaStaticInvoke(const CXXMethodDecl *MD);
+
   void EmitLambdaVLACapture(const VariableArrayType *VAT, LValue LV) {
 EmitStoreThroughLValue(RValue::get(VLASizeMap[VAT->getSizeExpr()]), LV);
   }
@@ -2255,6 +2257,8 @@
  GlobalDecl GD, const ThunkInfo &Thunk,
  bool IsUnprototyped);
 
+  void CreateClonedFunction(llvm::Function *Fn, llvm::Function *BaseFn,
+llvm::ValueToValueMapTy &VMap);
   llvm::Function *GenerateVarArgsThunk(llvm::Function *Fn,
const CGFunctionInfo &FnInfo,
GlobalDecl GD, const ThunkInfo &Thunk);
Index: clang/lib/CodeGen/CGVTables.cpp
===
--- clang/lib/CodeGen/CGVTables.cpp
+++ clang/lib/CodeGen/CGVTables.cpp
@@ -139,6 +139,21 @@
   }
 }
 
+void CodeGenFunction::CreateClonedFunction(
+llvm::Function *Fn, llvm::Function *BaseFn, llvm::ValueToValueMapTy &VMap) {
+  // We are cloning a function while some Metadata nodes are still unresolved.
+  // Ensure that the value mapper does not encounter any of them.
+  resolveTopLevelMetadata(BaseFn, VMap);
+  llvm::Function *NewFn = llvm::CloneFunction(BaseFn, VMap);
+  Fn->replaceAllUsesWith(NewFn);
+  NewFn->takeName(Fn);
+  Fn->eraseFromParent();
+  Fn = NewFn;
+
+  // "Initialize" CGF (minimally).
+  CurFn = Fn;
+}
+
 // This function does roughly the same thing as GenerateThunk, but in a
 // very different way, so that va_start and va_end work correctly.
 // FIXME: This function assumes "this" is the first non-sret LLVM argument of
@@ -181,17 +196,7 @@
   // Cl

[PATCH] D137980: [ARM] Pretend atomics are always lock-free for small widths.

2022-11-14 Thread Eli Friedman via Phabricator via cfe-commits
efriedma created this revision.
efriedma added reviewers: nikic, t.p.northover, john.brawn, joerg, tomhughes, 
alanphipps, aykevl.
Herald added subscribers: s.egerton, simoncook, hiraditya, kristof.beyls.
Herald added a project: All.
efriedma requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead.
Herald added projects: clang, LLVM.

Trying to accurately model what the hardware actually supports seems to lead to 
a lot of people complaining, and nobody saying it's actually helpful. So just 
pretend everything is lock-free, and let users deal with ensuring that the 
__sync_* routines are actually lock-free. If anyone complains, we can just say 
"gcc does the same thing".

Partially reverts D120026 .  Makes D130480 
 unnecessary.

Fixes https://github.com/llvm/llvm-project/issues/58603


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137980

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/CodeGen/arm-atomics-m0.c
  clang/test/CodeGen/atomic-ops-libcall.c
  clang/test/CodeGen/atomics-inlining.c
  clang/test/CodeGen/c11atomics.c
  clang/test/CodeGen/pr45476.cpp
  clang/test/CodeGenCXX/threadsafe-statics-no-atomic.cpp
  clang/test/CodeGenOpenCL/atomic-ops-libcall.cl
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/test/CodeGen/ARM/atomic-64bit.ll
  llvm/test/CodeGen/ARM/atomic-load-store.ll
  llvm/test/CodeGen/ARM/atomic-op.ll
  llvm/test/CodeGen/ARM/thumbv6m-atomic32.ll

Index: llvm/test/CodeGen/ARM/thumbv6m-atomic32.ll
===
--- llvm/test/CodeGen/ARM/thumbv6m-atomic32.ll
+++ llvm/test/CodeGen/ARM/thumbv6m-atomic32.ll
@@ -3,285 +3,156 @@
 ; RUN: llc -mtriple=thumbv6m-none-eabi -mattr=+atomics-32 < %s | FileCheck %s --check-prefixes=CHECK,ATOMIC32
 
 define i8 @load8(ptr %p) {
-; NO-ATOMIC32-LABEL: load8:
-; NO-ATOMIC32:   @ %bb.0:
-; NO-ATOMIC32-NEXT:.save {r7, lr}
-; NO-ATOMIC32-NEXT:push {r7, lr}
-; NO-ATOMIC32-NEXT:movs r1, #5
-; NO-ATOMIC32-NEXT:bl __atomic_load_1
-; NO-ATOMIC32-NEXT:pop {r7, pc}
-;
-; ATOMIC32-LABEL: load8:
-; ATOMIC32:   @ %bb.0:
-; ATOMIC32-NEXT:ldrb r0, [r0]
-; ATOMIC32-NEXT:dmb sy
-; ATOMIC32-NEXT:bx lr
+; CHECK-LABEL: load8:
+; CHECK:   @ %bb.0:
+; CHECK-NEXT:ldrb r0, [r0]
+; CHECK-NEXT:dmb sy
+; CHECK-NEXT:bx lr
   %v = load atomic i8, ptr %p seq_cst, align 1
   ret i8 %v
 }
 
 define void @store8(ptr %p) {
-; NO-ATOMIC32-LABEL: store8:
-; NO-ATOMIC32:   @ %bb.0:
-; NO-ATOMIC32-NEXT:.save {r7, lr}
-; NO-ATOMIC32-NEXT:push {r7, lr}
-; NO-ATOMIC32-NEXT:movs r1, #0
-; NO-ATOMIC32-NEXT:movs r2, #5
-; NO-ATOMIC32-NEXT:bl __atomic_store_1
-; NO-ATOMIC32-NEXT:pop {r7, pc}
-;
-; ATOMIC32-LABEL: store8:
-; ATOMIC32:   @ %bb.0:
-; ATOMIC32-NEXT:dmb sy
-; ATOMIC32-NEXT:movs r1, #0
-; ATOMIC32-NEXT:strb r1, [r0]
-; ATOMIC32-NEXT:dmb sy
-; ATOMIC32-NEXT:bx lr
+; CHECK-LABEL: store8:
+; CHECK:   @ %bb.0:
+; CHECK-NEXT:dmb sy
+; CHECK-NEXT:movs r1, #0
+; CHECK-NEXT:strb r1, [r0]
+; CHECK-NEXT:dmb sy
+; CHECK-NEXT:bx lr
   store atomic i8 0, ptr %p seq_cst, align 1
   ret void
 }
 
 define i8 @rmw8(ptr %p) {
-; NO-ATOMIC32-LABEL: rmw8:
-; NO-ATOMIC32:   @ %bb.0:
-; NO-ATOMIC32-NEXT:.save {r7, lr}
-; NO-ATOMIC32-NEXT:push {r7, lr}
-; NO-ATOMIC32-NEXT:movs r1, #1
-; NO-ATOMIC32-NEXT:movs r2, #5
-; NO-ATOMIC32-NEXT:bl __atomic_fetch_add_1
-; NO-ATOMIC32-NEXT:pop {r7, pc}
-;
-; ATOMIC32-LABEL: rmw8:
-; ATOMIC32:   @ %bb.0:
-; ATOMIC32-NEXT:.save {r7, lr}
-; ATOMIC32-NEXT:push {r7, lr}
-; ATOMIC32-NEXT:dmb sy
-; ATOMIC32-NEXT:movs r1, #1
-; ATOMIC32-NEXT:bl __sync_fetch_and_add_1
-; ATOMIC32-NEXT:dmb sy
-; ATOMIC32-NEXT:pop {r7, pc}
+; CHECK-LABEL: rmw8:
+; CHECK:   @ %bb.0:
+; CHECK-NEXT:.save {r7, lr}
+; CHECK-NEXT:push {r7, lr}
+; CHECK-NEXT:dmb sy
+; CHECK-NEXT:movs r1, #1
+; CHECK-NEXT:bl __sync_fetch_and_add_1
+; CHECK-NEXT:dmb sy
+; CHECK-NEXT:pop {r7, pc}
   %v = atomicrmw add ptr %p, i8 1 seq_cst, align 1
   ret i8 %v
 }
 
 define i8 @cmpxchg8(ptr %p) {
-; NO-ATOMIC32-LABEL: cmpxchg8:
-; NO-ATOMIC32:   @ %bb.0:
-; NO-ATOMIC32-NEXT:.save {r7, lr}
-; NO-ATOMIC32-NEXT:push {r7, lr}
-; NO-ATOMIC32-NEXT:.pad #8
-; NO-ATOMIC32-NEXT:sub sp, #8
-; NO-ATOMIC32-NEXT:add r1, sp, #4
-; NO-ATOMIC32-NEXT:movs r2, #0
-; NO-ATOMIC32-NEXT:strb r2, [r1]
-; NO-ATOMIC32-NEXT:movs r3, #5
-; NO-ATOMIC32-NEXT:str r3, [sp]
-; NO-ATOMIC32-NEXT:movs r2, #1
-; NO-ATOMIC32-NEXT:bl __atomic_compare_exchange_1
-; NO-ATOMIC32-NEXT:ldr r0, [sp, #4]
-; NO-ATOMIC32-NEXT:add sp, #8
-; NO-ATOMIC32-NEXT:pop {r7, pc}
-;
-; ATOMIC32-LABEL: cmpxchg8:
-; ATOMIC32:   @ %bb.0:
-; ATOMIC32-NEXT:.save {r7, lr}
-; ATOMIC32-NEXT:push {r7, lr}
-; ATOMIC32-NEXT:dmb 

[clang] 8c15c17 - Revert "[opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvm"

2022-11-14 Thread Alexander Shaposhnikov via cfe-commits

Author: Alexander Shaposhnikov
Date: 2022-11-14T21:31:30Z
New Revision: 8c15c17e3ba7916b2efb2a100495c710bae04fb6

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

LOG: Revert "[opt][clang] Enable using -module-summary/-flto=thin with 
-S/-emit-llvm"

This reverts commit ef9e624694c0f125c53f7d0d3472fd486bada57d
for further investigation offline.
It appears to break the buildbot
llvm-clang-x86_64-sie-ubuntu-fast.

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
clang/test/CodeGen/split-lto-unit.c
llvm/include/llvm/IR/IRPrintingPasses.h
llvm/lib/IR/CMakeLists.txt
llvm/lib/IR/IRPrintingPasses.cpp
llvm/test/Bitcode/thinlto-function-summary.ll
llvm/tools/opt/NewPMDriver.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 26633f8007037..41f9ce3a009da 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -978,24 +978,19 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
   if (!actionRequiresCodeGen(Action) && CodeGenOpts.VerifyModule)
 MPM.addPass(VerifierPass());
 
-  if (Action == Backend_EmitBC || Action == Backend_EmitLL) {
+  switch (Action) {
+  case Backend_EmitBC:
 if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
+  if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
+ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
+if (!ThinLinkOS)
+  return;
+  }
   if (!TheModule->getModuleFlag("EnableSplitLTOUnit"))
 TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
  CodeGenOpts.EnableSplitLTOUnit);
-  if (Action == Backend_EmitBC) {
-if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
-  ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
-  if (!ThinLinkOS)
-return;
-}
-MPM.addPass(ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? 
&ThinLinkOS->os()
- : nullptr));
-  } else {
-MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists,
-true /* EmitLTOSummary */));
-  }
-
+  MPM.addPass(ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &ThinLinkOS->os()
+   : nullptr));
 } else {
   // Emit a module summary by default for Regular LTO except for ld64
   // targets
@@ -1007,13 +1002,17 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
   TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
uint32_t(1));
   }
-  if (Action == Backend_EmitBC)
-MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
-  EmitLTOSummary));
-  else
-MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists,
-EmitLTOSummary));
+  MPM.addPass(
+  BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists, 
EmitLTOSummary));
 }
+break;
+
+  case Backend_EmitLL:
+MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists));
+break;
+
+  default:
+break;
   }
 
   // Now that we have all of the passes ready, run them.

diff  --git a/clang/test/CodeGen/split-lto-unit.c 
b/clang/test/CodeGen/split-lto-unit.c
index b1560b61f3e30..941aebafd01b3 100644
--- a/clang/test/CodeGen/split-lto-unit.c
+++ b/clang/test/CodeGen/split-lto-unit.c
@@ -1,15 +1,12 @@
 // ; Check that -flto=thin without -fsplit-lto-unit has EnableSplitLTOUnit = 0
 // RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s
-// RUN: %clang_cc1 -flto=thin -emit-llvm < %s | FileCheck %s
 // CHECK: !{i32 1, !"EnableSplitLTOUnit", i32 0}
 //
 // ; Check that -flto=thin with -fsplit-lto-unit has EnableSplitLTOUnit = 1
 // RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm-bc < %s | llvm-dis 
-o - | FileCheck %s --check-prefix=SPLIT
-// RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm < %s | FileCheck %s 
--check-prefix=SPLIT
 // SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1}
 //
 // ; Check that regular LTO has EnableSplitLTOUnit = 1
 // RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | 
llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" 
--check-prefix=SPLIT
-// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm < %s | 
FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
 
 int main(void) {}

diff  --git a/llvm/include/llvm/IR/IRPrintingPasses.h 
b/llvm/include/llvm/IR/IRPrintingPasses.h
index 5f4880643c52d..3fba5b81e37a9 100644
--- a/llvm/include/llvm/IR/IRPrintingPasses

[PATCH] D137979: parse: process GNU and standard attributes on top-level decls

2022-11-14 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added reviewers: aaron.ballman, sammccall.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
compnerd requested review of this revision.
Herald added a project: clang.

We would previously reject valid input where GNU attributes preceded the 
standard attributes on top-level declarations.  A previous attribute handling 
change had begun rejecting this whilst GCC does honour this layout.  In 
practice, this breaks use of `extern "C"` attributed functions which use both 
standard and GNU attributes as experienced by the Swift runtime.

The majority of the changes here are plumbing the parsed attributes down to the 
use sites.  This incidentally improves source location tracking and token 
handling in the source manager.  The downside of this is that it exposes a 
latent issue in the indexing path where we would try to backtrack to annotate 
attributes post-expansion.  However the proper parsing now introduced results 
in the token stream now retrieving the pre-expanded token whilst still 
associating the attribute to the declaration.  This percolates throughout the 
other various tests.

The one remaining failure with this test is Index/annotate-tokens.c where the 
leading attribute is not associated with the declaration due to the 
`FinalizeDeclarationGroup` not re-associating the attributes with the 
declarations in the declaration group.  However, the declaration still does 
receive the attribute.

Special thanks to Aaron Ballman for the many hints and extensive rubber ducking 
that was involved in identifying the various places where we accidentally 
dropped attributes.

Fixes: #58229


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137979

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseHLSL.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant-varying-return.c
  clang/test/AST/ast-dump-openmp-begin-declare-variant_10.c
  clang/test/AST/ast-dump-openmp-begin-declare-variant_11.c
  clang/test/AST/ast-dump-openmp-begin-declare-variant_12.c
  clang/test/Analysis/Inputs/expected-plists/retain-release.m.objc.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release.m.objcpp.plist
  clang/test/Parser/attr-order.cpp
  clang/test/Parser/cxx-attributes.cpp
  clang/test/SemaCXX/attr-unavailable.cpp
  clang/test/SemaObjC/objc-asm-attribute-neg-test.m
  clang/unittests/Tooling/SourceCodeTest.cpp

Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -247,14 +247,12 @@
 
   // Includes attributes.
   Visitor.runOverAnnotated(R"cpp(
-  #define ATTR __attribute__((deprecated("message")))
-  $r[[ATTR
+  $r[[__attribute__((deprecated("message")))
   int x;]])cpp");
 
   // Includes attributes and comments together.
   Visitor.runOverAnnotated(R"cpp(
-  #define ATTR __attribute__((deprecated("message")))
-  $r[[ATTR
+  $r[[__attribute__((deprecated("message")))
   // Comment.
   int x;]])cpp");
 }
@@ -402,14 +400,12 @@
 
   // Includes attributes.
   Visit(R"cpp(
-  #define ATTR __attribute__((deprecated("message")))
-  $r[[ATTR
+  $r[[__attribute__((deprecated("message")))
   int x;]])cpp");
 
   // Includes attributes and comments together.
   Visit(R"cpp(
-  #define ATTR __attribute__((deprecated("message")))
-  $r[[ATTR
+  $r[[__attribute__((deprecated("message")))
   // Comment.
   int x;]])cpp");
 }
Index: clang/test/SemaObjC/objc-asm-attribute-neg-test.m
===
--- clang/test/SemaObjC/objc-asm-attribute-neg-test.m
+++ clang/test/SemaObjC/objc-asm-attribute-neg-test.m
@@ -28,7 +28,7 @@
 @end
 
 __attribute__((objc_runtime_name("MySecretNamespace.ForwardClass")))
-@class ForwardClass; // expected-error {{prefix attribute must be followed by an interface, protocol, or implementation}}
+@class ForwardClass; // expected-error@-1 {{prefix attribute must be followed by an interface, protocol, or implementation}}
 
 __attribute__((objc_runtime_name("MySecretNamespace.ForwardProtocol")))
 @protocol ForwardProtocol;
Index: clang/test/SemaCXX/attr-unavailable.cpp
===
--- clang/test/SemaCXX/attr-unavailable.cpp
+++ clang/test/SemaCXX/attr-unavailable.cpp
@@ -42,18 +42,18 @@
 // delayed process for 'deprecated'.
 //  and 
 enum DeprecatedEnum { DE_A, DE_B } __attribute__((deprecated)); // expected-note {{'DeprecatedEnum' has been explicitly marked deprecated here}}
-__attribute__((deprecated)) typedef enum DeprecatedEnum DeprecatedEnum;
 typedef enum DeprecatedEnum AnotherDeprecatedEnum; // expected-warning {{'DeprecatedEnum' is deprecated}}

[clang] ef9e624 - [opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvm

2022-11-14 Thread Alexander Shaposhnikov via cfe-commits

Author: Alexander Shaposhnikov
Date: 2022-11-14T21:11:07Z
New Revision: ef9e624694c0f125c53f7d0d3472fd486bada57d

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

LOG: [opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvm

Enable using -module-summary with -S
(similarly to what currently can be achieved with opt  -o - | llvm-dis).

Test plan: ninja check-all

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
clang/test/CodeGen/split-lto-unit.c
llvm/include/llvm/IR/IRPrintingPasses.h
llvm/lib/IR/CMakeLists.txt
llvm/lib/IR/IRPrintingPasses.cpp
llvm/test/Bitcode/thinlto-function-summary.ll
llvm/tools/opt/NewPMDriver.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 41f9ce3a009da..26633f8007037 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -978,19 +978,24 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
   if (!actionRequiresCodeGen(Action) && CodeGenOpts.VerifyModule)
 MPM.addPass(VerifierPass());
 
-  switch (Action) {
-  case Backend_EmitBC:
+  if (Action == Backend_EmitBC || Action == Backend_EmitLL) {
 if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
-  if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
-ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
-if (!ThinLinkOS)
-  return;
-  }
   if (!TheModule->getModuleFlag("EnableSplitLTOUnit"))
 TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
  CodeGenOpts.EnableSplitLTOUnit);
-  MPM.addPass(ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &ThinLinkOS->os()
-   : nullptr));
+  if (Action == Backend_EmitBC) {
+if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
+  ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
+  if (!ThinLinkOS)
+return;
+}
+MPM.addPass(ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? 
&ThinLinkOS->os()
+ : nullptr));
+  } else {
+MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists,
+true /* EmitLTOSummary */));
+  }
+
 } else {
   // Emit a module summary by default for Regular LTO except for ld64
   // targets
@@ -1002,17 +1007,13 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
   TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
uint32_t(1));
   }
-  MPM.addPass(
-  BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists, 
EmitLTOSummary));
+  if (Action == Backend_EmitBC)
+MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
+  EmitLTOSummary));
+  else
+MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists,
+EmitLTOSummary));
 }
-break;
-
-  case Backend_EmitLL:
-MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists));
-break;
-
-  default:
-break;
   }
 
   // Now that we have all of the passes ready, run them.

diff  --git a/clang/test/CodeGen/split-lto-unit.c 
b/clang/test/CodeGen/split-lto-unit.c
index 941aebafd01b3..b1560b61f3e30 100644
--- a/clang/test/CodeGen/split-lto-unit.c
+++ b/clang/test/CodeGen/split-lto-unit.c
@@ -1,12 +1,15 @@
 // ; Check that -flto=thin without -fsplit-lto-unit has EnableSplitLTOUnit = 0
 // RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s
+// RUN: %clang_cc1 -flto=thin -emit-llvm < %s | FileCheck %s
 // CHECK: !{i32 1, !"EnableSplitLTOUnit", i32 0}
 //
 // ; Check that -flto=thin with -fsplit-lto-unit has EnableSplitLTOUnit = 1
 // RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm-bc < %s | llvm-dis 
-o - | FileCheck %s --check-prefix=SPLIT
+// RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm < %s | FileCheck %s 
--check-prefix=SPLIT
 // SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1}
 //
 // ; Check that regular LTO has EnableSplitLTOUnit = 1
 // RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | 
llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" 
--check-prefix=SPLIT
+// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm < %s | 
FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
 
 int main(void) {}

diff  --git a/llvm/include/llvm/IR/IRPrintingPasses.h 
b/llvm/include/llvm/IR/IRPrintingPasses.h
index 3fba5b81e37a9..5f4880643c52d 100644
--- a/llvm/include/llv

[PATCH] D137768: [opt][clang] Enable using -module-summary /-flto=thin with -S / -emit-llvm

2022-11-14 Thread Alexander Shaposhnikov 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 rGef9e624694c0: [opt][clang] Enable using 
-module-summary/-flto=thin with -S/-emit-llvm (authored by 
alexander-shaposhnikov).

Changed prior to commit:
  https://reviews.llvm.org/D137768?vs=475082&id=475259#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137768

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/split-lto-unit.c
  llvm/include/llvm/IR/IRPrintingPasses.h
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/IRPrintingPasses.cpp
  llvm/test/Bitcode/thinlto-function-summary.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -443,16 +443,16 @@
 MPM.addPass(NewPMCheckDebugifyPass(false, "", &DIStatsMap));
   if (VerifyDIPreserve)
 MPM.addPass(NewPMCheckDebugifyPass(
-false, "", nullptr, DebugifyMode::OriginalDebugInfo, &DebugInfoBeforePass,
-VerifyDIPreserveExport));
+false, "", nullptr, DebugifyMode::OriginalDebugInfo,
+&DebugInfoBeforePass, VerifyDIPreserveExport));
 
   // Add any relevant output pass at the end of the pipeline.
   switch (OK) {
   case OK_NoOutput:
 break; // No output pass needed.
   case OK_OutputAssembly:
-MPM.addPass(
-PrintModulePass(Out->os(), "", ShouldPreserveAssemblyUseListOrder));
+MPM.addPass(PrintModulePass(
+Out->os(), "", ShouldPreserveAssemblyUseListOrder, EmitSummaryIndex));
 break;
   case OK_OutputBitcode:
 MPM.addPass(BitcodeWriterPass(Out->os(), ShouldPreserveBitcodeUseListOrder,
Index: llvm/test/Bitcode/thinlto-function-summary.ll
===
--- llvm/test/Bitcode/thinlto-function-summary.ll
+++ llvm/test/Bitcode/thinlto-function-summary.ll
@@ -31,6 +31,8 @@
 
 
 ; RUN: opt -passes=name-anon-globals -module-summary < %s | llvm-dis | FileCheck %s
+; RUN: opt -passes=name-anon-globals -module-summary -S < %s | FileCheck %s
+; RUN: opt -passes=name-anon-globals -module-summary -S < %s | llvm-as | llvm-dis | FileCheck %s
 ; Check that this round-trips correctly.
 
 ; ModuleID = ''
Index: llvm/lib/IR/IRPrintingPasses.cpp
===
--- llvm/lib/IR/IRPrintingPasses.cpp
+++ llvm/lib/IR/IRPrintingPasses.cpp
@@ -12,6 +12,7 @@
 
 #include "llvm/IR/IRPrintingPasses.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Analysis/ModuleSummaryAnalysis.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PrintPasses.h"
@@ -24,19 +25,20 @@
 
 PrintModulePass::PrintModulePass() : OS(dbgs()) {}
 PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner,
- bool ShouldPreserveUseListOrder)
+ bool ShouldPreserveUseListOrder,
+ bool EmitSummaryIndex)
 : OS(OS), Banner(Banner),
-  ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
+  ShouldPreserveUseListOrder(ShouldPreserveUseListOrder),
+  EmitSummaryIndex(EmitSummaryIndex) {}
 
-PreservedAnalyses PrintModulePass::run(Module &M, ModuleAnalysisManager &) {
+PreservedAnalyses PrintModulePass::run(Module &M, ModuleAnalysisManager &AM) {
   if (llvm::isFunctionInPrintList("*")) {
 if (!Banner.empty())
   OS << Banner << "\n";
 M.print(OS, nullptr, ShouldPreserveUseListOrder);
-  }
-  else {
+  } else {
 bool BannerPrinted = false;
-for(const auto &F : M.functions()) {
+for (const auto &F : M.functions()) {
   if (llvm::isFunctionInPrintList(F.getName())) {
 if (!BannerPrinted && !Banner.empty()) {
   OS << Banner << "\n";
@@ -46,6 +48,16 @@
   }
 }
   }
+
+  ModuleSummaryIndex *Index =
+  EmitSummaryIndex ? &(AM.getResult(M))
+   : nullptr;
+  if (Index) {
+if (Index->modulePaths().empty())
+  Index->addModule("", 0);
+Index->print(OS);
+  }
+
   return PreservedAnalyses::all();
 }
 
Index: llvm/lib/IR/CMakeLists.txt
===
--- llvm/lib/IR/CMakeLists.txt
+++ llvm/lib/IR/CMakeLists.txt
@@ -76,6 +76,7 @@
   intrinsics_gen
 
   LINK_COMPONENTS
+  Analysis
   BinaryFormat
   Remarks
   Support
Index: llvm/include/llvm/IR/IRPrintingPasses.h
===
--- llvm/include/llvm/IR/IRPrintingPasses.h
+++ llvm/include/llvm/IR/IRPrintingPasses.h
@@ -58,11 +58,13 @@
   raw_ostream &OS;
   std::string Banner;
   bool ShouldPreserveUseListOrder;
+  bool EmitSummaryIndex;
 
 public:
   PrintModulePass();
   PrintModulePass(raw_ostream &OS, const std::string &Banner = "",
-  bool Shou

[PATCH] D137883: [clang-format][NFC] Improve documentation of FixNamespaceComments

2022-11-14 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 475257.
HazardyKnusperkeks marked 2 inline comments as done.

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

https://reviews.llvm.org/D137883

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2121,14 +2121,17 @@
   bool ExperimentalAutoDetectBinPacking;
 
   /// If ``true``, clang-format adds missing namespace end comments for
-  /// short namespaces and fixes invalid existing ones. Short ones are
-  /// controlled by "ShortNamespaceLines".
+  /// namespaces and fixes invalid existing ones. This doesn't affect short
+  /// namespaces, which are controlled by ``ShortNamespaceLines``.
   /// \code
   ///true:  false:
-  ///namespace a {  vs. namespace a {
-  ///foo(); foo();
-  ///bar(); bar();
+  ///namespace longNamespace {  vs. namespace longNamespace {
+  ///void foo();void foo();
+  ///void bar();void bar();
   ///} // namespace a   }
+  ///namespace shortNamespace { namespace shortNamespace {
+  ///void baz();void baz();
+  ///}  }
   /// \endcode
   /// \version 5
   bool FixNamespaceComments;
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2696,16 +2696,19 @@
 
 **FixNamespaceComments** (``Boolean``) :versionbadge:`clang-format 5`
   If ``true``, clang-format adds missing namespace end comments for
-  short namespaces and fixes invalid existing ones. Short ones are
-  controlled by "ShortNamespaceLines".
+  namespaces and fixes invalid existing ones. This doesn't affect short
+  namespaces, which are controlled by ``ShortNamespaceLines``.
 
   .. code-block:: c++
 
  true:  false:
- namespace a {  vs. namespace a {
- foo(); foo();
- bar(); bar();
+ namespace longNamespace {  vs. namespace longNamespace {
+ void foo();void foo();
+ void bar();void bar();
  } // namespace a   }
+ namespace shortNamespace { namespace shortNamespace {
+ void baz();void baz();
+ }  }
 
 **ForEachMacros** (``List of Strings``) :versionbadge:`clang-format 3.7`
   A vector of macros that should be interpreted as foreach loops


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2121,14 +2121,17 @@
   bool ExperimentalAutoDetectBinPacking;
 
   /// If ``true``, clang-format adds missing namespace end comments for
-  /// short namespaces and fixes invalid existing ones. Short ones are
-  /// controlled by "ShortNamespaceLines".
+  /// namespaces and fixes invalid existing ones. This doesn't affect short
+  /// namespaces, which are controlled by ``ShortNamespaceLines``.
   /// \code
   ///true:  false:
-  ///namespace a {  vs. namespace a {
-  ///foo(); foo();
-  ///bar(); bar();
+  ///namespace longNamespace {  vs. namespace longNamespace {
+  ///void foo();void foo();
+  ///void bar();void bar();
   ///} // namespace a   }
+  ///namespace shortNamespace { namespace shortNamespace {
+  ///void baz();void baz();
+  ///}  }
   /// \endcode
   /// \version 5
   bool FixNamespaceComments;
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2696,16 +2696,19 @@
 
 **FixNamespaceComments** (``Boolean``) :versionbadge:`clang-format 5`
   If ``true``, clang-format adds missing namespace end comments for
-  short namespaces and fixes invalid existing ones. Short ones are
-  controlled by "ShortNamespaceLines".
+  namespaces and fixes invalid existing ones. This doesn't affect short
+  namespaces, which are controlled by ``ShortNamespaceLines``.
 
   .. c

[PATCH] D137865: [clang-format][NFC] Improve documentation on ReflowComments

2022-11-14 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/include/clang/Format/Format.h:3073-3076
+  /// If ``true``, clang-format will attempt to re-flow comments. That is it
+  /// will touch a comment and *reflow* long comments into new lines, trying to
+  /// obey the ``ColumnLimit``. ``/*`` comments will get a leading ``*`` on the
+  /// new lines.

owenpan wrote:
> Let's leave it as is because the new lines don't always get a leading `*`:
> ```
> $ cat foo.cpp
> /* The LLVM Project is a collection of modular and reusable compiler and 
> toolchain
>technologies. */
> $ clang-format -style='{ReflowComments: true}' foo.cpp
> /* The LLVM Project is a collection of modular and reusable compiler and
>toolchain technologies. */
> ```
That was from a short glimpse on the code.
Adapted the text.


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

https://reviews.llvm.org/D137865

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


[PATCH] D137865: [clang-format][NFC] Improve documentation on ReflowComments

2022-11-14 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 475253.
HazardyKnusperkeks marked 3 inline comments as done.

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

https://reviews.llvm.org/D137865

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -3070,7 +3070,9 @@
   ReferenceAlignmentStyle ReferenceAlignment;
 
   // clang-format off
-  /// If ``true``, clang-format will attempt to re-flow comments.
+  /// If ``true``, clang-format will attempt to re-flow comments. That is it
+  /// will touch a comment and *reflow* long comments into new lines, trying to
+  /// obey the ``ColumnLimit``.
   /// \code
   ///false:
   ///// veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with 
plenty of information
@@ -3821,7 +3823,7 @@
   /// \version 3.7
   bool SpacesInCStyleCastParentheses;
 
-  /// Control of spaces within a single line comment
+  /// Control of spaces within a single line comment.
   struct SpacesInLineComment {
 /// The minimum number of spaces at the start of the comment.
 unsigned Minimum;
@@ -3858,6 +3860,8 @@
   ///   ///  - Foo/// - Foo
   ///   ///- Bar  ///   - Bar
   /// \endcode
+  ///
+  /// This option has only effect if ``ReflowComments`` is set to ``true``.
   /// \version 13
   SpacesInLineComment SpacesInLineCommentPrefix;
 
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -3795,7 +3795,9 @@
 
 
 **ReflowComments** (``Boolean``) :versionbadge:`clang-format 3.8`
-  If ``true``, clang-format will attempt to re-flow comments.
+  If ``true``, clang-format will attempt to re-flow comments. That is it
+  will touch a comment and *reflow* long comments into new lines, trying to
+  obey the ``ColumnLimit``.
 
   .. code-block:: c++
 
@@ -4610,9 +4612,11 @@
 ///  - Foo/// - Foo
 ///- Bar  ///   - Bar
 
+  This option has only effect if ``ReflowComments`` is set to ``true``.
+
   Nested configuration flags:
 
-  Control of spaces within a single line comment
+  Control of spaces within a single line comment.
 
   * ``unsigned Minimum`` The minimum number of spaces at the start of the 
comment.
 


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -3070,7 +3070,9 @@
   ReferenceAlignmentStyle ReferenceAlignment;
 
   // clang-format off
-  /// If ``true``, clang-format will attempt to re-flow comments.
+  /// If ``true``, clang-format will attempt to re-flow comments. That is it
+  /// will touch a comment and *reflow* long comments into new lines, trying to
+  /// obey the ``ColumnLimit``.
   /// \code
   ///false:
   ///// veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
@@ -3821,7 +3823,7 @@
   /// \version 3.7
   bool SpacesInCStyleCastParentheses;
 
-  /// Control of spaces within a single line comment
+  /// Control of spaces within a single line comment.
   struct SpacesInLineComment {
 /// The minimum number of spaces at the start of the comment.
 unsigned Minimum;
@@ -3858,6 +3860,8 @@
   ///   ///  - Foo/// - Foo
   ///   ///- Bar  ///   - Bar
   /// \endcode
+  ///
+  /// This option has only effect if ``ReflowComments`` is set to ``true``.
   /// \version 13
   SpacesInLineComment SpacesInLineCommentPrefix;
 
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -3795,7 +3795,9 @@
 
 
 **ReflowComments** (``Boolean``) :versionbadge:`clang-format 3.8`
-  If ``true``, clang-format will attempt to re-flow comments.
+  If ``true``, clang-format will attempt to re-flow comments. That is it
+  will touch a comment and *reflow* long comments into new lines, trying to
+  obey the ``ColumnLimit``.
 
   .. code-block:: c++
 
@@ -4610,9 +4612,11 @@
 ///  - Foo/// - Foo
 ///- Bar  ///   - Bar
 
+  This option has only effect if ``ReflowComments`` is set to ``true``.
+
   Nested configuration flags:
 
-  Control of spaces within a single line comment
+  Control of spaces within a single line comment.
 
   * ``unsigned Minimum`` The minimum number of spaces at the start of the comment.
 
___
cfe-commits mailing list
cfe-commits@lists.

[PATCH] D137563: [clang][Interp] Check declarations for constexpr-ness in Load() instructions

2022-11-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/Interp/Interp.cpp:101
 
+static bool CheckConstexpr(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
+  if (!S.inConstantContext())

Is `CheckConstexpr` descriptive enough? Would something like `CheckLoadIsValid` 
be better?



Comment at: clang/lib/AST/Interp/Interp.cpp:110
+  if (auto *VarD = dyn_cast(VD)) {
+if (VarD->hasLocalStorage() || VarD->isConstexpr())
+  return true;

Is this sufficient? How about something like this:

```
int *p;

int constexpr f(int &x) {
*p=1;
return 10;
}
```

Maybe I am not understanding. I think more test case would be useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137563

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


[PATCH] D137768: [opt][clang] Enable using -module-summary /-flto=thin with -S / -emit-llvm

2022-11-14 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:988
 if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
   if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
 ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);

tejohnson wrote:
> I'd go ahead and move this extra file emission under the EmitBC case, since 
> it is also a BC file.
sure, will do


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137768

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


[PATCH] D137762: [clang-format] avoid breaking )( with BlockIndent

2022-11-14 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:7215
   Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  EXPECT_EQ(StringRef("functionCall(paramA, paramB,\n"
-  "paramC);\n"
-  "void functionDecl(int A, int B,\n"
-  "int C);"),
-format(Input, Style));
+  verifyFormat("functionCall(paramA, paramB,\n"
+   "paramC);\n"

Sorry for the confusion, you can (and should?) keep the `Input` variable. There 
is a verifyFormat with 4 arguments. So that the input in the formatting doesn't 
have to be the expected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137762

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


[PATCH] D137823: [clang-format][NFC] Moved configuration parsing tests in own file

2022-11-14 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks marked 3 inline comments as done.
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/ConfigParseTest.cpp:1006
+
+TEST(FormatStyle, GetStyleWithEmptyFileName) {
+  llvm::vfs::InMemoryFileSystem FS;

owenpan wrote:
> Otherwise, the test will be skipped.
That is not true.
It will be executed, and that was the name in the beginning.

I only changed the old `FormatTest` to `ParseTest` and didn't change these 3, 
because I thought someone made this on purpose.

```
[ RUN  ] ParseTest.ConfigurationRoundTripTest
[   OK ] ParseTest.ConfigurationRoundTripTest (4 ms)
[--] 7 tests from ParseTest (201 ms total)

[--] 3 tests from FormatStyle
[ RUN  ] FormatStyle.GetStyleWithEmptyFileName
[   OK ] FormatStyle.GetStyleWithEmptyFileName (3 ms)
```



Comment at: clang/unittests/Format/ConfigParseTest.cpp:1013
+
+TEST(FormatStyle, GetStyleOfFile) {
+  llvm::vfs::InMemoryFileSystem FS;

owenpan wrote:
> Change `FormatStyle` to `ParseTest` here and on line 1220 below.
Discussion above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137823

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


[PATCH] D137217: [LTO][COFF] Use bitcode file names in lto native object file names.

2022-11-14 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

The naming convention used here for COFF is actually very similar to what is 
done for other ThinLTO save-temps output files, which are placed at the input 
module locations. We may want to just do this across the board. @MaskRay wdyt? 
A few other questions/comments below.




Comment at: clang/lib/CodeGen/BackendUtil.cpp:1104
 
-  auto AddStream = [&](size_t Task) {
+  auto AddStream = [&](size_t Task, Twine File) {
 return std::make_unique(std::move(OS),

I think you might need to mark the new parameter as unused here and in other 
cases where it isn't used via LLVM_ATTRIBUTE_UNUSED, to avoid build warnings - 
I can't recall how strictly that is enforced.



Comment at: lld/COFF/LTO.cpp:229
+StringRef ltoObjName;
+if (bitcodeFilePath == "ld-temp.o") {
+  ltoObjName =

This case should always be i==0 I think?



Comment at: lld/COFF/LTO.cpp:245
+  saveBuffer(buf[i].second, ltoObjName);
 ret.push_back(make(ctx, MemoryBufferRef(objBuf, ltoObjName)));
   }

The above changes affect both the MemoryBufferRef name as well as the saveTemps 
output file name. I assume the change to the former is what is required for 
PDB, is that correct?



Comment at: lld/MachO/LTO.cpp:132
+"ThinLTO", "Thin", config->thinLTOCacheDir,
+[&](size_t task, Twine originFile, std::unique_ptr mb) {
+  files[task] = std::move(mb);

In some files this parameter is called "filed" and in others "originFile". 
Better to be consistent, and perhaps to use a more descriptive name, something 
like moduleName ?



Comment at: llvm/include/llvm/Support/Caching.h:53
 ///
 /// if (AddStreamFn AddStream = Cache(Task, Key))
 ///   ProduceContent(AddStream);

This and possibly other header file descriptions need updates.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137217

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


[PATCH] D137562: [clang][Interp] Start supporting virtual base classes

2022-11-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/Interp/Descriptor.cpp:126
+  auto CtorSub = [=](unsigned SubOff, Descriptor *F, bool IsBase,
+ bool Recurse = true) {
 auto *Desc = reinterpret_cast(Ptr + SubOff) - 1;

To recurse or not seems to be a property of whether the base is virtual or not.

Maybe a enum w/ `Base` and `Virtual` base would be better and then the logic of 
whether to recurse can be kept local to the lambda,



Comment at: clang/lib/AST/Interp/Descriptor.cpp:147
   for (const auto &V : D->ElemRecord->virtual_bases())
-CtorSub(V.Offset, V.Desc, /*isBase=*/true);
+CtorSub(V.Offset, V.Desc, /*isBase=*/true, false);
 }




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137562

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


[PATCH] D137917: [cmake] Fix _GNU_SOURCE being added unconditionally

2022-11-14 Thread Tom Stellard via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8da41fe69622: [cmake] Fix _GNU_SOURCE being added 
unconditionally (authored by Trass3r, committed by tstellar).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137917

Files:
  clang/CMakeLists.txt
  llvm/cmake/config-ix.cmake


Index: llvm/cmake/config-ix.cmake
===
--- llvm/cmake/config-ix.cmake
+++ llvm/cmake/config-ix.cmake
@@ -348,7 +348,7 @@
 
 check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
 if( LLVM_USING_GLIBC )
-  add_definitions( -D_GNU_SOURCE )
+  add_compile_definitions(_GNU_SOURCE)
   list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
 endif()
 # This check requires _GNU_SOURCE
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -414,8 +414,6 @@
   endif()
 endif()
 
-add_definitions( -D_GNU_SOURCE )
-
 option(CLANG_BUILD_TOOLS
   "Build the Clang tools. If OFF, just generate build targets." ON)
 


Index: llvm/cmake/config-ix.cmake
===
--- llvm/cmake/config-ix.cmake
+++ llvm/cmake/config-ix.cmake
@@ -348,7 +348,7 @@
 
 check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
 if( LLVM_USING_GLIBC )
-  add_definitions( -D_GNU_SOURCE )
+  add_compile_definitions(_GNU_SOURCE)
   list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
 endif()
 # This check requires _GNU_SOURCE
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -414,8 +414,6 @@
   endif()
 endif()
 
-add_definitions( -D_GNU_SOURCE )
-
 option(CLANG_BUILD_TOOLS
   "Build the Clang tools. If OFF, just generate build targets." ON)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8da41fe - [cmake] Fix _GNU_SOURCE being added unconditionally

2022-11-14 Thread Tom Stellard via cfe-commits

Author: Andreas Hollandt
Date: 2022-11-14T12:28:21-08:00
New Revision: 8da41fe69622f35e0a15b5a1754cd670e6057938

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

LOG: [cmake] Fix _GNU_SOURCE being added unconditionally

Reviewed By: tstellar

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

Added: 


Modified: 
clang/CMakeLists.txt
llvm/cmake/config-ix.cmake

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index c9f86d4c9889c..e6cc6e4705428 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -414,8 +414,6 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   endif()
 endif()
 
-add_definitions( -D_GNU_SOURCE )
-
 option(CLANG_BUILD_TOOLS
   "Build the Clang tools. If OFF, just generate build targets." ON)
 

diff  --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 15a7d78b3ac43..28ca8223ce934 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -348,7 +348,7 @@ endif()
 
 check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
 if( LLVM_USING_GLIBC )
-  add_definitions( -D_GNU_SOURCE )
+  add_compile_definitions(_GNU_SOURCE)
   list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
 endif()
 # This check requires _GNU_SOURCE



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


[PATCH] D137753: [Clang][GNU][AIX][p]Enable -p Functionality

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475242.
francii added a comment.

Add sysroot check to aix-ld.c test cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/aix-ld.c
  clang/test/Driver/linux-ld.c

Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1572,6 +1572,13 @@
 // CHECK-CRTFASTMATH: usr/lib/gcc/x86_64-unknown-linux/10.2.0{{/|}}crtfastmath.o
 // CHECK-NOCRTFASTMATH-NOT: crtfastmath.o
 
+// Check that we link in gcrt1.o when compiling with -p
+// RUN: %clang -p --target=x86_64-unknown-linux -no-pie -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/basic_linux_tree 2>& 1 \
+// RUN:   | FileCheck --check-prefix=CHECK-P %s
+// CHECK-P: gcrt1.o
+
 // Check that we link in gcrt1.o when compiling with -pg
 // RUN: %clang -pg --target=x86_64-unknown-linux -no-pie -### %s \
 // RUN:--gcc-toolchain="" \
Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -498,7 +498,7 @@
 if (!isAndroid && !IsIAMCU) {
   const char *crt1 = nullptr;
   if (!Args.hasArg(options::OPT_shared)) {
-if (Args.hasArg(options::OPT_pg))
+if (Args.hasArg(options::OPT_p, options::OPT_pg))
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -521,7 +521,8 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList &Args,
   const llvm::Triple &Triple) {
-  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
+  if (Args.hasArg(options::OPT_p, options::OPT_pg) &&
+  !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6268,6 +6269,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fms_hotpatch);
 
   if (TC.SupportsProfiling()) {
+Args.AddLastArg(CmdArgs, options::OPT_p);
 Args.AddLastArg(CmdArgs, options::OPT_pg);
 
 llvm::Triple::ArchType Arch = TC.getArch();
@@ -7388,7 +7390,7 @@
 C.getJobs().getJobs().back()->PrintInputFilenames = true;
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_pg))
+  if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg))
 if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
 !Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1043,7 +1043,8 @@
   // inlining, we just add an attribute to insert a mcount call in backend.
   // The attribute "countin

[PATCH] D137851: [OPENMP]Initial support for at clause

2022-11-14 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

In D137851#3925661 , @jdoerfert wrote:

> Drive by: Please add commit messages to non trivial changes to explaining 
> what's going on.

Thanks.  Added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137851

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


[PATCH] D137968: [clang-tidy] Ignore overriden methods in `readability-const-return-type`.

2022-11-14 Thread Nathan James via Phabricator via cfe-commits
njames93 accepted this revision.
njames93 added a comment.

Lg, but can you address that one nit before landing




Comment at: clang-tools-extra/docs/ReleaseNotes.rst:169
 
+- Change the behavior of :doc:`readability-const-return-type
+  ` to not

Can this be moved to below the braces around statements check as we like to 
keep things in alphabetical order.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137968

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


[PATCH] D137872: Try to implement lambdas with inalloca parameters by forwarding without use of inallocas.

2022-11-14 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I'm not quite sure I understand what's happening here.  Does this actually 
avoid generating two copies of the function body if both the call operator and 
the conversion are used?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137872

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


[PATCH] D137851: [OPENMP]Initial support for at clause

2022-11-14 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Drive by: Please add commit messages to non trivial changes to explaining 
what's going on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137851

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


[PATCH] D137217: [LTO][COFF] Use bitcode file names in lto native object file names.

2022-11-14 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137217

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


[PATCH] D137972: [clang-tidy] Optionally ignore findings in macros in `readability-const-return-type`.

2022-11-14 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: njames93, thomasetter.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a project: All.
ymandel requested review of this revision.
Herald added a project: clang-tools-extra.

Adds support for options-controlled configuration of the check to ignore 
results in macros.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137972

Files:
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability/const-return-type.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type-macros.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -196,13 +196,22 @@
 // Test cases where the `const` token lexically is hidden behind some form of
 // indirection.
 
+// Regression tests involving macros, which are ignored by default because
+// IgnoreMacros defaults to true.
+#define CONCAT(a, b) a##b
+CONCAT(cons, t) int n22(){}
+
 #define CONSTINT const int
-CONSTINT p18() {}
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu
+CONSTINT n23() {}
 
 #define CONST const
-CONST int p19() {}
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu
+CONST int n24() {}
+
+#define CREATE_FUNCTION()\
+const int n_inside_macro() { \
+  return 1; \
+}
+CREATE_FUNCTION();
 
 using ty = const int;
 ty p21() {}
Index: clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type-macros.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type-macros.cpp
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy -std=c++14 %s readability-const-return-type %t -- \
+// RUN:   -config="{CheckOptions: [{key: readability-const-return-type.IgnoreMacros, value: false}]}"
+
+//  p# = positive test
+//  n# = negative test
+
+// Regression tests involving macros
+#define CONCAT(a, b) a##b
+CONCAT(cons, t) int p22(){}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu
+// We warn, but we can't give a fix
+
+#define CONSTINT const int
+CONSTINT p23() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu
+
+#define CONST const
+CONST int p24() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu
+
+#define CREATE_FUNCTION()\
+const int p_inside_macro() { \
+  return 1; \
+}
+CREATE_FUNCTION();
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu
+// We warn, but we can't give a fix
Index: clang-tools-extra/docs/clang-tidy/checks/readability/const-return-type.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability/const-return-type.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability/const-return-type.rst
@@ -24,3 +24,12 @@
const int* foo();
const int& foo();
const Clazz* foo();
+
+
+Options
+---
+
+.. option:: IgnoreMacros
+
+   If set to `true`, the check will not give warnings inside macros. Default
+   is `true`.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -166,6 +166,10 @@
   ` to not
   warn about `const` value parameters of declarations inside macros.
 
+- Change the default behavior of :doc:`readability-const-return-type
+  ` to not
+  warn about `const` value parameters of declarations inside macros.
+
 - Change the behavior of :doc:`readability-const-return-type
   ` to not
   warn about `const` return types in overridden functions since the derived
Index: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.h
===
--- clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.h
+++ clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.h
@@ -22,9 +22,15 @@
 /// http://clang.llvm.org/extra/clang-tidy/checks/readability/const-return-type.html
 class ConstReturnTypeCheck : public ClangTidyCheck {
  public:
-  using ClangTidyCheck::ClangTidyCheck;
-  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
-  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+   ConstReturnTypeCheck(StringRef Name, ClangTidyContext *Context)
+   : ClangTidyCheck(Name

[PATCH] D137851: [OPENMP]Initial support for at clause

2022-11-14 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:11293
+   SourceLocation EndLoc,
+   bool InExContext = true);
   /// Called on well-formed '\#pragma omp barrier'.

ABataev wrote:
> Why do you need this flag?
The error pragma is not allowed in declared context when "at" clause with 
execution modifier. 
It is allowed with compilation modifier.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:11035-11037
+  for (auto *AC :
+   OMPExecutableDirective::getClausesOfKind(Clauses))
+AtC = AC;

ABataev wrote:
> Why do you need a loop here?
Only one "at" clause is allowed.  So I think Loop does not matters.  Changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137851

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


[PATCH] D137851: [OPENMP]Initial support for at clause

2022-11-14 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 475225.
jyu2 added a comment.

Thanks Alexey!  Address Alexey comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137851

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/OpenMPKinds.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/error_ast_print.cpp
  clang/test/OpenMP/error_message.cpp
  clang/tools/libclang/CIndex.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -301,6 +301,9 @@
   let clangClass = "OMPAtomicDefaultMemOrderClause";
   let flangClass = "OmpAtomicDefaultMemOrderClause";
 }
+def OMPC_At : Clause<"at"> {
+  let clangClass = "OMPAtClause";
+}
 def OMPC_Allocate : Clause<"allocate"> {
   let clangClass = "OMPAllocateClause";
   let flangClass = "OmpAllocateClause";
@@ -527,7 +530,11 @@
 }
 def OMP_TaskYield : Directive<"taskyield"> {}
 def OMP_Barrier : Directive<"barrier"> {}
-def OMP_Error : Directive<"error"> {}
+def OMP_Error : Directive<"error"> {
+  let allowedClauses = [
+VersionedClause
+  ];
+}
 def OMP_TaskWait : Directive<"taskwait"> {
   let allowedClauses = [
 VersionedClause
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1868,6 +1868,7 @@
 CHECK_SIMPLE_CLAUSE(Use, OMPC_use)
 CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
 CHECK_SIMPLE_CLAUSE(Nocontext, OMPC_nocontext)
+CHECK_SIMPLE_CLAUSE(At, OMPC_at)
 CHECK_SIMPLE_CLAUSE(Filter, OMPC_filter)
 CHECK_SIMPLE_CLAUSE(When, OMPC_when)
 CHECK_SIMPLE_CLAUSE(AdjustArgs, OMPC_adjust_args)
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2443,6 +2443,8 @@
 void OMPClauseEnqueue::VisitOMPAtomicDefaultMemOrderClause(
 const OMPAtomicDefaultMemOrderClause *) {}
 
+void OMPClauseEnqueue::VisitOMPAtClause(const OMPAtClause *) {}
+
 void OMPClauseEnqueue::VisitOMPDeviceClause(const OMPDeviceClause *C) {
   Visitor->AddStmt(C->getDevice());
 }
Index: clang/test/OpenMP/error_message.cpp
===
--- clang/test/OpenMP/error_message.cpp
+++ clang/test/OpenMP/error_message.cpp
@@ -7,19 +7,19 @@
   if (argc)
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 if (argc) {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 }
   while (argc)
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 while (argc) {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 }
   do
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 while (argc)
   ;
   do {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
   } while (argc);
   switch (argc)
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
@@ -28,47 +28,75 @@
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
   switch (argc)
   case 1: {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
   }
   switch (argc) {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
   case 1:
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 break;
   default: {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
   } break;
   }
   for (;;)
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 for (;;) {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 }
 label:
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 label1 : {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 }
 if (1)
   label2:
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 
+// expected-error@+1 {{ERROR}}
+#pragma omp error at() // expected-error {{expected 'compilation' or 'execution' in Open

[PATCH] D137968: [clang-tidy] Ignore overriden methods in `readability-const-return-type`.

2022-11-14 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 475224.
ymandel added a comment.

Add test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137968

Files:
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -279,13 +279,22 @@
   // CHECK-NOT-FIXES: virtual int getC() = 0;
 };
 
-class PVDerive : public PVBase {
+class NVDerive : public PVBase {
 public:
-  const int getC() { return 1; }
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 
'const'-qualified at the top level, which may reduce code readability without 
improving const correctness
-  // CHECK-NOT-FIXES: int getC() { return 1; }
+  // Don't warn about overridden methods, because it may be impossible to make
+  // them non-const as the user may not be able to change the base class.
+  const int getC() override { return 1; }
 };
 
+class NVDeriveOutOfLine : public PVBase {
+public:
+  // Don't warn about overridden methods, because it may be impossible to make
+  // them non-const as one may not be able to change the base class
+  const int getC();
+};
+
+const int NVDeriveOutOfLine::getC() { return 1; }
+
 // Don't warn about const auto types, because it may be impossible to make 
them non-const
 // without a significant semantics change. Since `auto` drops cv-qualifiers,
 // tests check `decltype(auto)`.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -166,6 +166,11 @@
   ` to not
   warn about `const` value parameters of declarations inside macros.
 
+- Change the behavior of :doc:`readability-const-return-type
+  ` to not
+  warn about `const` return types in overridden functions since the derived
+  class cannot always choose to change the function signature.
+
 - Fixed crashes in :doc:`readability-braces-around-statements
   ` and
   :doc:`readability-simplify-boolean-expr 
`
Index: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -114,7 +114,9 @@
   Finder->addMatcher(
   functionDecl(
   returns(allOf(isConstQualified(), unless(NonLocalConstType))),
-  anyOf(isDefinition(), cxxMethodDecl(isPure(
+  anyOf(isDefinition(), cxxMethodDecl(isPure())),
+  // Overridden functions are not actionable.
+  unless(cxxMethodDecl(isOverride(
   .bind("func"),
   this);
 }


Index: clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -279,13 +279,22 @@
   // CHECK-NOT-FIXES: virtual int getC() = 0;
 };
 
-class PVDerive : public PVBase {
+class NVDerive : public PVBase {
 public:
-  const int getC() { return 1; }
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 'const'-qualified at the top level, which may reduce code readability without improving const correctness
-  // CHECK-NOT-FIXES: int getC() { return 1; }
+  // Don't warn about overridden methods, because it may be impossible to make
+  // them non-const as the user may not be able to change the base class.
+  const int getC() override { return 1; }
 };
 
+class NVDeriveOutOfLine : public PVBase {
+public:
+  // Don't warn about overridden methods, because it may be impossible to make
+  // them non-const as one may not be able to change the base class
+  const int getC();
+};
+
+const int NVDeriveOutOfLine::getC() { return 1; }
+
 // Don't warn about const auto types, because it may be impossible to make them non-const
 // without a significant semantics change. Since `auto` drops cv-qualifiers,
 // tests check `decltype(auto)`.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -166,6 +166,11 @@
   ` to not
   warn about `const` value parameters of declarations inside macros.
 
+- Change the behavior of :doc:`readability-const-return-type
+  ` to not
+  warn about `const` return 

[PATCH] D137738: [clang-tidy] Suppress google-objc-avoid-throwing-exception in system macros 🫢

2022-11-14 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 475222.
stephanemoore added a subscriber: Eugene.Zelenko.
stephanemoore added a comment.

Included namespace comment linter fixes from D137740 
 as advised by @Eugene.Zelenko,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137738

Files:
  clang-tools-extra/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/google/Inputs/system-header-throw.h
  
clang-tools-extra/test/clang-tidy/checkers/google/objc-avoid-throwing-exception.m

Index: clang-tools-extra/test/clang-tidy/checkers/google/objc-avoid-throwing-exception.m
===
--- clang-tools-extra/test/clang-tidy/checkers/google/objc-avoid-throwing-exception.m
+++ clang-tools-extra/test/clang-tidy/checkers/google/objc-avoid-throwing-exception.m
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s google-objc-avoid-throwing-exception %t
+// RUN: %check_clang_tidy %s google-objc-avoid-throwing-exception %t -- -- -I %S/Inputs/
+
 @class NSString;
 
 @interface NSException
@@ -21,12 +22,29 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
 }
 
+#include "system-header-throw.h"
+
+#define THROW(e) @throw e
+
+#define RAISE [NSException raise:@"example" format:@"fmt"]
+
 - (void)f2 {
 [NSException raise:@"TestException" format:@"Test"];
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
 [NSException raise:@"TestException" format:@"Test %@" arguments:@"bar"];
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
 [NotException raise:@"NotException" format:@"Test"];
+
+NSException *e;
+SYS_THROW(e);
+
+SYS_RAISE;
+
+THROW(e);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
+
+RAISE;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass in NSError ** instead of throwing exception to indicate Objective-C errors [google-objc-avoid-throwing-exception]
 }
 @end
 
Index: clang-tools-extra/test/clang-tidy/checkers/google/Inputs/system-header-throw.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/google/Inputs/system-header-throw.h
@@ -0,0 +1,6 @@
+#pragma clang system_header
+
+#define SYS_THROW(e) @throw e
+
+#define SYS_RAISE [NSException raise:@"example" format:@"fmt"]
+
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -141,6 +141,10 @@
   would be emitted for uninitialized members of an anonymous union despite
   there being an initializer for one of the other members.
 
+- Fixed false positives in :doc:`google-objc-avoid-throwing-exception
+  ` check for exceptions
+  thrown by code emitted from macros in system headers.
+
 - Improved :doc:`modernize-use-emplace `
   check.
 
Index: clang-tools-extra/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
===
--- clang-tools-extra/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
+++ clang-tools-extra/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
@@ -36,12 +36,28 @@
   Result.Nodes.getNodeAs("raiseException");
   auto SourceLoc = MatchedStmt == nullptr ? MatchedExpr->getSelectorStartLoc()
   : MatchedStmt->getThrowLoc();
+
+  // Early return on invalid locations.
+  if (SourceLoc.isInvalid())
+return;
+
+  // If the match location was in a macro, check if the macro was in a system
+  // header.
+  if (SourceLoc.isMacroID()) {
+SourceManager &SM = *Result.SourceManager;
+auto MacroLoc = SM.getImmediateMacroCallerLoc(SourceLoc);
+
+// Matches in system header macros should be ignored.
+if (SM.isInSystemHeader(MacroLoc))
+  return;
+  }
+
   diag(SourceLoc,
"pass in NSError ** instead of throwing exception to indicate "
"Objective-C errors");
 }
 
-}  // namespace objc
-}  // namespace google
-}  // namespace tidy
-}  // namespace clang
+} // namespace objc
+} // namespace google
+} // namespace tidy
+} // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137874: clang/AMDGPU: Use Support's wrapper around getenv

2022-11-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

840a793375fec763c2b2781b82b764325635cc7a 



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

https://reviews.llvm.org/D137874

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


[clang] 840a793 - clang/AMDGPU: Use Support's wrapper around getenv

2022-11-14 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2022-11-14T11:07:31-08:00
New Revision: 840a793375fec763c2b2781b82b764325635cc7a

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

LOG: clang/AMDGPU: Use Support's wrapper around getenv

This does some extra stuff for Windows, so might as well
use it just in case.

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 261594171564e..153537c45d2d6 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -20,6 +20,7 @@
 #include "llvm/Support/Host.h"
 #include "llvm/Support/LineIterator.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include 
 
@@ -199,9 +200,10 @@ RocmInstallationDetector::getInstallationPathCandidates() {
 ROCmSearchDirs.emplace_back(RocmPathArg.str());
 DoPrintROCmSearchDirs();
 return ROCmSearchDirs;
-  } else if (const char *RocmPathEnv = ::getenv("ROCM_PATH")) {
-if (!StringRef(RocmPathEnv).empty()) {
-  ROCmSearchDirs.emplace_back(RocmPathEnv);
+  } else if (Optional RocmPathEnv =
+ llvm::sys::Process::GetEnv("ROCM_PATH")) {
+if (!RocmPathEnv->empty()) {
+  ROCmSearchDirs.emplace_back(std::move(*RocmPathEnv));
   DoPrintROCmSearchDirs();
   return ROCmSearchDirs;
 }
@@ -374,8 +376,9 @@ void RocmInstallationDetector::detectDeviceLibrary() {
 
   if (!RocmDeviceLibPathArg.empty())
 LibDevicePath = RocmDeviceLibPathArg[RocmDeviceLibPathArg.size() - 1];
-  else if (const char *LibPathEnv = ::getenv("HIP_DEVICE_LIB_PATH"))
-LibDevicePath = LibPathEnv;
+  else if (Optional LibPathEnv =
+   llvm::sys::Process::GetEnv("HIP_DEVICE_LIB_PATH"))
+LibDevicePath = std::move(*LibPathEnv);
 
   auto &FS = D.getVFS();
   if (!LibDevicePath.empty()) {



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


[PATCH] D137968: [clang-tidy] Ignore overriden methods in `readability-const-return-type`.

2022-11-14 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: njames93, thomasetter.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a project: All.
ymandel requested review of this revision.
Herald added a project: clang-tools-extra.

Overrides are constrained by the signature of the overridden method, so a
warning on an override is frequently unactionable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137968

Files:
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -279,11 +279,11 @@
   // CHECK-NOT-FIXES: virtual int getC() = 0;
 };
 
-class PVDerive : public PVBase {
+class NVDerive : public PVBase {
 public:
-  const int getC() { return 1; }
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 
'const'-qualified at the top level, which may reduce code readability without 
improving const correctness
-  // CHECK-NOT-FIXES: int getC() { return 1; }
+  // Don't warn about overridden methods, because it may be impossible to make
+  // them non-const as the user may not be able to change the base class.
+  const int getC() override { return 1; }
 };
 
 // Don't warn about const auto types, because it may be impossible to make 
them non-const
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -166,6 +166,11 @@
   ` to not
   warn about `const` value parameters of declarations inside macros.
 
+- Change the behavior of :doc:`readability-const-return-type
+  ` to not
+  warn about `const` return types in overridden functions since the derived
+  class cannot always choose to change the function signature.
+
 - Fixed crashes in :doc:`readability-braces-around-statements
   ` and
   :doc:`readability-simplify-boolean-expr 
`
Index: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -114,7 +114,9 @@
   Finder->addMatcher(
   functionDecl(
   returns(allOf(isConstQualified(), unless(NonLocalConstType))),
-  anyOf(isDefinition(), cxxMethodDecl(isPure(
+  anyOf(isDefinition(), cxxMethodDecl(isPure())),
+  // Overridden functions are not actionable.
+  unless(cxxMethodDecl(isOverride(
   .bind("func"),
   this);
 }


Index: clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -279,11 +279,11 @@
   // CHECK-NOT-FIXES: virtual int getC() = 0;
 };
 
-class PVDerive : public PVBase {
+class NVDerive : public PVBase {
 public:
-  const int getC() { return 1; }
-  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 'const'-qualified at the top level, which may reduce code readability without improving const correctness
-  // CHECK-NOT-FIXES: int getC() { return 1; }
+  // Don't warn about overridden methods, because it may be impossible to make
+  // them non-const as the user may not be able to change the base class.
+  const int getC() override { return 1; }
 };
 
 // Don't warn about const auto types, because it may be impossible to make them non-const
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -166,6 +166,11 @@
   ` to not
   warn about `const` value parameters of declarations inside macros.
 
+- Change the behavior of :doc:`readability-const-return-type
+  ` to not
+  warn about `const` return types in overridden functions since the derived
+  class cannot always choose to change the function signature.
+
 - Fixed crashes in :doc:`readability-braces-around-statements
   ` and
   :doc:`readability-simplify-boolean-expr `
Index: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -114,7 +114,9 @@
   Finder->addMatcher(
   funct

[PATCH] D133036: [InstCombine] Treat passing undef to noundef params as UB

2022-11-14 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

I'll hold off on submitting this until that bug is figured out


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133036

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


Re: How can Autoconf help with the transition to stricter compilation defaults?

2022-11-14 Thread Aaron Ballman via cfe-commits
On Mon, Nov 14, 2022 at 1:14 PM Paul Eggert  wrote:
>
> On 2022-11-14 04:41, Aaron Ballman wrote:
> > it's generally a problem when autoconf relies on invalid
> > language constructs
>
> Autoconf *must* rely on invalid language constructs, if only to test
> whether the language constructs work. And Clang therefore must be
> careful about how it diagnoses invalid constructs. Clang shouldn't
> willy-nilly change the way it reports invalid constructs, as that can
> break Autoconf.
>
> > issues of security
> > like statically known instances of UB
>
> It's fine to report those; I'm not saying don't report them. All I'm
> saying is that Clang should be careful about *how* it reports them.
>
> At the very least if there are going to be changes in this area, the
> Clang developers should notify Autoconf (and presumably other)
> downstream users of the changes, and provide a supported way to get the
> old behavior for reporting, and give downstream time to adapt.

Definitely agreed about the communication aspects! I mentioned this upthread:

FWIW, we're working on improving communication
about potentially disruptive changes to Clang, so you might want to
consider either subscribing to the clang-vendors code review group at
https://reviews.llvm.org/project/members/113/ (if you want to be
involved in code review before things land) or the Announcements
discourse channel at https://discourse.llvm.org/c/announce/ (if you
want to be notified after something lands but before Clang ships).

One other thing we've done recently is starting to call out
potentially disruptive changes in the release notes as well:
https://clang.llvm.org/docs/ReleaseNotes.html#potentially-breaking-changes
-- but this is more for notifying folks after a release goes out, so
one of the other approaches is more proactive if the goal is to alert
Clang developers to serious deployment problems before we ship.

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


Re: How can Autoconf help with the transition to stricter compilation defaults?

2022-11-14 Thread Florian Weimer via cfe-commits
* Paul Eggert:

> On 2022-11-14 04:41, Aaron Ballman wrote:
>> it's generally a problem when autoconf relies on invalid
>> language constructs
>
> Autoconf *must* rely on invalid language constructs, if only to test
> whether the language constructs work. And Clang therefore must be 
> careful about how it diagnoses invalid constructs. Clang shouldn't
> willy-nilly change the way it reports invalid constructs, as that can 
> break Autoconf.

This is only true for the status quo.  We could finally band together
and define an interface between autoconf and the toolchain that avoids
feature probing through source code fragments for common cases.  It
might make configure scripts to run quite a bit faster, too.

That being said, system compilers need to be careful when turning
warnings into errors by default, but that doesn't mean we should never
do such changes, particularly when we know based on interactions with
programmers that the warnings are not sufficient for avoiding wasted
time.

Thanks,
Florian

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


[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475203.
francii added a comment.

Add sysroot to test cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137375

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-GPROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-GPROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: How can Autoconf help with the transition to stricter compilation defaults?

2022-11-14 Thread Paul Eggert via cfe-commits

On 2022-11-14 04:41, Aaron Ballman wrote:

it's generally a problem when autoconf relies on invalid
language constructs


Autoconf *must* rely on invalid language constructs, if only to test 
whether the language constructs work. And Clang therefore must be 
careful about how it diagnoses invalid constructs. Clang shouldn't 
willy-nilly change the way it reports invalid constructs, as that can 
break Autoconf.



issues of security
like statically known instances of UB


It's fine to report those; I'm not saying don't report them. All I'm 
saying is that Clang should be careful about *how* it reports them.


At the very least if there are going to be changes in this area, the 
Clang developers should notify Autoconf (and presumably other) 
downstream users of the changes, and provide a supported way to get the 
old behavior for reporting, and give downstream time to adapt.

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


[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475197.
francii added a comment.

Remove check for -p


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137375

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L/lib/profiled"
+// CHECK-LD32-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L/lib/profiled"
+// CHECK-LD64-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L/lib/profiled"
+// CHECK-LD32-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L/lib/profiled"
+// CHECK-LD64-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137753: [Clang][GNU][AIX][p]Enable -p Functionality

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475196.
francii added a comment.

Add profiled libraries check AIX


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/aix-ld.c
  clang/test/Driver/linux-ld.c

Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1572,6 +1572,13 @@
 // CHECK-CRTFASTMATH: usr/lib/gcc/x86_64-unknown-linux/10.2.0{{/|}}crtfastmath.o
 // CHECK-NOCRTFASTMATH-NOT: crtfastmath.o
 
+// Check that we link in gcrt1.o when compiling with -p
+// RUN: %clang -p --target=x86_64-unknown-linux -no-pie -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/basic_linux_tree 2>& 1 \
+// RUN:   | FileCheck --check-prefix=CHECK-P %s
+// CHECK-P: gcrt1.o
+
 // Check that we link in gcrt1.o when compiling with -pg
 // RUN: %clang -pg --target=x86_64-unknown-linux -no-pie -### %s \
 // RUN:--gcc-toolchain="" \
Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L/lib/profiled"
+// CHECK-LD32-PROF: "-L/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L/lib/profiled"
+// CHECK-LD64-PROF: "-L/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -498,7 +498,7 @@
 if (!isAndroid && !IsIAMCU) {
   const char *crt1 = nullptr;
   if (!Args.hasArg(options::OPT_shared)) {
-if (Args.hasArg(options::OPT_pg))
+if (Args.hasArg(options::OPT_p, options::OPT_pg))
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -521,7 +521,8 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList &Args,
   const llvm::Triple &Triple) {
-  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
+  if (Args.hasArg(options::OPT_p, options::OPT_pg) &&
+  !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6268,6 +6269,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fms_hotpatch);
 
   if (TC.SupportsProfiling()) {
+Args.AddLastArg(CmdArgs, options::OPT_p);
 Args.AddLastArg(CmdArgs, options::OPT_pg);
 
 llvm::Triple::ArchType Arch = TC.getArch();
@@ -7388,7 +7390,7 @@
 C.getJobs().getJobs().back()->PrintInputFilenames = true;
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_pg))
+  if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg))
 if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
 !Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1043,7 +1043,8 @@
   // inlining, we just add an attribute to insert a mcount call in backend.
   // The attribute "counting-function" is set to mcount function name which is

[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475194.
francii added a comment.

Fix mixup


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137375

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L/lib/profiled"
+// CHECK-LD32-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L/lib/profiled"
+// CHECK-LD64-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L/lib/profiled"
+// CHECK-LD32-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L/lib/profiled"
+// CHECK-LD64-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137962: [clang][Tooling] Make the filename behaviour consistent

2022-11-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added a project: All.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added a project: clang.

Dotdots were removed only when converting a relative path to absolute
one. This patch makes the behaviour consistent for absolute file paths by
removing them in that case as well. Also updates the documentation to mention
the behaviour.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137962

Files:
  clang/docs/JSONCompilationDatabase.rst
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -92,16 +92,32 @@
   expected_files.push_back(std::string(PathStorage.str()));
   llvm::sys::path::native("//net/file1", PathStorage);
   expected_files.push_back(std::string(PathStorage.str()));
+  llvm::sys::path::native("//net/dir/file3", PathStorage);
+  expected_files.push_back(std::string(PathStorage.str()));
   EXPECT_EQ(expected_files,
-getAllFiles("[{\"directory\":\"//net/dir\","
-"\"command\":\"command\","
-"\"file\":\"file1\"},"
-" {\"directory\":\"//net/dir\","
-"\"command\":\"command\","
-"\"file\":\"../file1\"},"
-" {\"directory\":\"//net/dir\","
-"\"command\":\"command\","
-"\"file\":\"file2\"}]",
+getAllFiles(R"json(
+[
+  {
+"directory": "//net/dir",
+"command": "command",
+"file": "file1"
+  },
+  {
+"directory": "//net/dir",
+"command": "command",
+"file": "../file1"
+  },
+  {
+"directory": "//net/dir",
+"command": "command",
+"file": "file2"
+  },
+  {
+"directory": "//net/dir",
+"command": "command",
+"file": "//net/dir/foo/../file3"
+  }
+])json",
 ErrorMessage, JSONCommandLineSyntax::Gnu))
   << ErrorMessage;
 }
Index: clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -426,6 +426,7 @@
   llvm::sys::path::native(AbsolutePath, NativeFilePath);
 } else {
   llvm::sys::path::native(FileName, NativeFilePath);
+  llvm::sys::path::remove_dots(NativeFilePath, /*remove_dot_dot=*/ true);
 }
 auto Cmd = CompileCommandRef(Directory, File, *Command, Output);
 IndexByFile[NativeFilePath].push_back(Cmd);
Index: clang/docs/JSONCompilationDatabase.rst
===
--- clang/docs/JSONCompilationDatabase.rst
+++ clang/docs/JSONCompilationDatabase.rst
@@ -86,7 +86,8 @@
compilation step. This is used by tools as the key into the
compilation database. There can be multiple command objects for the
same file, for example if the same source file is compiled with
-   different configurations.
+   different configurations. ``dot`` (./) ``dotdot`` (../) in the path is
+   stripped lexically.
 -  **arguments:** The compile command argv as list of strings.
This should run the compilation step for the translation unit ``file``.
``arguments[0]`` should be the executable name, such as ``clang++``.


Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -92,16 +92,32 @@
   expected_files.push_back(std::string(PathStorage.str()));
   llvm::sys::path::native("//net/file1", PathStorage);
   expected_files.push_back(std::string(PathStorage.str()));
+  llvm::sys::path::native("//net/dir/file3", PathStorage);
+  expected_files.push_back(std::string(PathStorage.str()));
   EXPECT_EQ(expected_files,
-getAllFiles("[{\"directory\":\"//net/dir\","
-"\"command\":\"command\","
-"\"file\":\"file1\"},"
-" {\"directory\":\"//net/dir\","
-"\"command\":\"command\","
-"\"file\":\"../file1\"},"
-" {\"directory\":\"//net/dir\","
-"\"command\":\"command\","
-"\"file\":\"file2\

[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475187.
francii added a comment.
Herald added a subscriber: ormris.

Removed check for sysroot, it is not needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137375

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/linux-ld.c

Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1572,6 +1572,13 @@
 // CHECK-CRTFASTMATH: usr/lib/gcc/x86_64-unknown-linux/10.2.0{{/|}}crtfastmath.o
 // CHECK-NOCRTFASTMATH-NOT: crtfastmath.o
 
+// Check that we link in gcrt1.o when compiling with -p
+// RUN: %clang -p --target=x86_64-unknown-linux -no-pie -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/basic_linux_tree 2>& 1 \
+// RUN:   | FileCheck --check-prefix=CHECK-P %s
+// CHECK-P: gcrt1.o
+
 // Check that we link in gcrt1.o when compiling with -pg
 // RUN: %clang -pg --target=x86_64-unknown-linux -no-pie -### %s \
 // RUN:--gcc-toolchain="" \
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -498,7 +498,7 @@
 if (!isAndroid && !IsIAMCU) {
   const char *crt1 = nullptr;
   if (!Args.hasArg(options::OPT_shared)) {
-if (Args.hasArg(options::OPT_pg))
+if (Args.hasArg(options::OPT_p, options::OPT_pg))
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -521,7 +521,8 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList &Args,
   const llvm::Triple &Triple) {
-  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
+  if (Args.hasArg(options::OPT_p, options::OPT_pg) &&
+  !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6268,6 +6269,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fms_hotpatch);
 
   if (TC.SupportsProfiling()) {
+Args.AddLastArg(CmdArgs, options::OPT_p);
 Args.AddLastArg(CmdArgs, options::OPT_pg);
 
 llvm::Triple::ArchType Arch = TC.getArch();
@@ -7388,7 +7390,7 @@
 C.getJobs().getJobs().back()->PrintInputFilenames = true;
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_pg))
+  if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg))
 if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
 !Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/lib/profiled"));
+  CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1043,7 +1043,8 @@
   // inlining, we just add an attribute to insert a mcount call in backend.
   // The attribute "counting-function" is set to mcount function name which is
   // architecture dependent.
-  if (CGM.getCodeGenOpts().InstrumentForProfiling) {
+  if (CGM.getCodeGenOpts().InstrumentForProfiling ||
+  CGM.getCodeGenOpts().InstrumentForProfilingGraph) {
 // Calls to fentry/mcount should not be generated if function has
 // the no_instrument_function attribute.
 if (!CurFuncDecl || !CurFuncDecl->hasAttr()) {
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -923,7 +923,8 @@
 if (CodeGenOpts.InstrumentFunctions ||
 CodeGenOpts.InstrumentFunctionEntryBare ||
 CodeGenOpts.InstrumentFunctionsAfterInlining ||
-CodeGenOpts.InstrumentForProfil

[PATCH] D137885: [modules] Support zstd in .pcm file

2022-11-14 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/Serialization/ASTReader.cpp:1456
+  const llvm::compression::Format F =
+  Blob.size() >= 2 && memcmp(Blob.data(), "\x1f\x8b", 2) == 0
+  ? llvm::compression::Format::Zlib

Worth a comment about this magic number?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137885

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


[PATCH] D137960: [Lexer] Speedup LexTokenInternal

2022-11-14 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

Compile time tracker record : 
https://llvm-compile-time-tracker.com/compare.php?from=f71d32a0eea47b3d2bb43d6be15cf09d47ef6971&to=b4df7d2a01aacd29ae539b04e72b3667e2362aa1&stat=instructions:u
The cost of preprocessing is hidden by the optimization time, but -O0 gives an 
hint of the expected speedup.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137960

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


[PATCH] D137960: [Lexer] Speedup LexTokenInternal

2022-11-14 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added reviewers: lattner, nikic.
Herald added a project: All.
serge-sans-paille requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Only reset "NeedsCleaning" flag in case of re-entrant call.
Do not needlessly blank IdentifierInfo. This information will be set
once the token type is picked.

This yields a nice 1% speedup when pre-processing sqlite amalgamation
through:

valgrind --tool=callgrind ./bin/clang -E sqlite3.c -o/dev/null


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137960

Files:
  clang/lib/Lex/Lexer.cpp


Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -3516,10 +3516,8 @@
 /// token, not a normal token, as such, it is an internal interface.  It 
assumes
 /// that the Flags of result have been cleared before calling this.
 bool Lexer::LexTokenInternal(Token &Result, bool TokAtPhysicalStartOfLine) {
-LexNextToken:
-  // New token, can't need cleaning yet.
-  Result.clearFlag(Token::NeedsCleaning);
-  Result.setIdentifierInfo(nullptr);
+LexStart:
+  assert(!Result.needsCleaning() && "Result doesn't need cleaning");
 
   // CurPtr - Cache BufferPtr in an automatic variable.
   const char *CurPtr = BufferPtr;
@@ -4141,8 +4139,9 @@
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
 } else if (Char == '|') {
   // If this is '|||' and we're in a conflict marker, ignore it.
-  if (CurPtr[1] == '|' && HandleEndOfConflictMarker(CurPtr-1))
+  if (CurPtr[1] == '|' && HandleEndOfConflictMarker(CurPtr - 1)) {
 goto LexNextToken;
+  }
   Kind = tok::pipepipe;
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
 } else {
@@ -4170,8 +4169,9 @@
 Char = getCharAndSize(CurPtr, SizeTmp);
 if (Char == '=') {
   // If this is '' and we're in a conflict marker, ignore it.
-  if (CurPtr[1] == '=' && HandleEndOfConflictMarker(CurPtr-1))
+  if (CurPtr[1] == '=' && HandleEndOfConflictMarker(CurPtr - 1)) {
 goto LexNextToken;
+  }
 
   Kind = tok::equalequal;
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
@@ -4301,6 +4301,10 @@
 
   // We parsed the directive; lex a token with the new state.
   return false;
+
+LexNextToken:
+  Result.clearFlag(Token::NeedsCleaning);
+  goto LexStart;
 }
 
 const char *Lexer::convertDependencyDirectiveToken(


Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -3516,10 +3516,8 @@
 /// token, not a normal token, as such, it is an internal interface.  It assumes
 /// that the Flags of result have been cleared before calling this.
 bool Lexer::LexTokenInternal(Token &Result, bool TokAtPhysicalStartOfLine) {
-LexNextToken:
-  // New token, can't need cleaning yet.
-  Result.clearFlag(Token::NeedsCleaning);
-  Result.setIdentifierInfo(nullptr);
+LexStart:
+  assert(!Result.needsCleaning() && "Result doesn't need cleaning");
 
   // CurPtr - Cache BufferPtr in an automatic variable.
   const char *CurPtr = BufferPtr;
@@ -4141,8 +4139,9 @@
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
 } else if (Char == '|') {
   // If this is '|||' and we're in a conflict marker, ignore it.
-  if (CurPtr[1] == '|' && HandleEndOfConflictMarker(CurPtr-1))
+  if (CurPtr[1] == '|' && HandleEndOfConflictMarker(CurPtr - 1)) {
 goto LexNextToken;
+  }
   Kind = tok::pipepipe;
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
 } else {
@@ -4170,8 +4169,9 @@
 Char = getCharAndSize(CurPtr, SizeTmp);
 if (Char == '=') {
   // If this is '' and we're in a conflict marker, ignore it.
-  if (CurPtr[1] == '=' && HandleEndOfConflictMarker(CurPtr-1))
+  if (CurPtr[1] == '=' && HandleEndOfConflictMarker(CurPtr - 1)) {
 goto LexNextToken;
+  }
 
   Kind = tok::equalequal;
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
@@ -4301,6 +4301,10 @@
 
   // We parsed the directive; lex a token with the new state.
   return false;
+
+LexNextToken:
+  Result.clearFlag(Token::NeedsCleaning);
+  goto LexStart;
 }
 
 const char *Lexer::convertDependencyDirectiveToken(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137269: [Clang][AArch64][Darwin] Enable GlobalISel by default for Darwin ARM64 platforms.

2022-11-14 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

> One thing that we did notice is that adding `-fno-global-isel` to cflags and 
> ldflags only had an effect when manually blowing away the thinlto cache. 
> Maybe whatever decides when to invalidate the thinlto cache needs to learn to 
> invalidate it when the `-global-isel` flag changes?

Looks like we'll have to do D134013  for the 
Mach-O and COFF lld ports as well. I'll make a CL for that. Thanks to @hans for 
pointing that out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137269

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


[PATCH] D128457: [clangd] Add new IncludeType to IncludeHeaderWithReferences

2022-11-14 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 475180.
dgoldman added a comment.

Run clang format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128457

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/Symbol.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/index/YAMLSerialization.cpp
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/IndexTests.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp

Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -53,8 +53,16 @@
 IncludeHeaders:
   - Header:'include1'
 References:7
+Directives:  [ Include ]
   - Header:'include2'
 References:3
+Directives:  [ Import ]
+  - Header:'include3'
+References:2
+Directives:  [ Include, Import ]
+  - Header:'include4'
+References:1
+Directives:  [ ]
 ...
 ---
 !Symbol
@@ -114,8 +122,11 @@
 
 MATCHER_P(id, I, "") { return arg.ID == cantFail(SymbolID::fromStr(I)); }
 MATCHER_P(qName, Name, "") { return (arg.Scope + arg.Name).str() == Name; }
-MATCHER_P2(IncludeHeaderWithRef, IncludeHeader, References, "") {
-  return (arg.IncludeHeader == IncludeHeader) && (arg.References == References);
+MATCHER_P3(IncludeHeaderWithRefAndDirectives, IncludeHeader, References,
+   SupportedDirectives, "") {
+  return (arg.IncludeHeader == IncludeHeader) &&
+ (arg.References == References) &&
+ (arg.SupportedDirectives == SupportedDirectives);
 }
 
 auto readIndexFile(llvm::StringRef Text) {
@@ -148,9 +159,14 @@
   EXPECT_EQ(static_cast(Sym1.Flags), 129);
   EXPECT_TRUE(Sym1.Flags & Symbol::IndexedForCodeCompletion);
   EXPECT_FALSE(Sym1.Flags & Symbol::Deprecated);
-  EXPECT_THAT(Sym1.IncludeHeaders,
-  UnorderedElementsAre(IncludeHeaderWithRef("include1", 7u),
-   IncludeHeaderWithRef("include2", 3u)));
+  EXPECT_THAT(
+  Sym1.IncludeHeaders,
+  UnorderedElementsAre(
+  IncludeHeaderWithRefAndDirectives("include1", 7u, Symbol::Include),
+  IncludeHeaderWithRefAndDirectives("include2", 3u, Symbol::Import),
+  IncludeHeaderWithRefAndDirectives("include3", 2u,
+Symbol::Include | Symbol::Import),
+  IncludeHeaderWithRefAndDirectives("include4", 1u, Symbol::Invalid)));
 
   EXPECT_THAT(Sym2, qName("clang::Foo2"));
   EXPECT_EQ(Sym2.Signature, "-sig");
Index: clang-tools-extra/clangd/unittests/IndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -567,9 +567,9 @@
   L.Name = "left";
   R.Name = "right";
   L.ID = R.ID = SymbolID("hello");
-  L.IncludeHeaders.emplace_back("common", 1);
-  R.IncludeHeaders.emplace_back("common", 1);
-  R.IncludeHeaders.emplace_back("new", 1);
+  L.IncludeHeaders.emplace_back("common", 1, Symbol::Include);
+  R.IncludeHeaders.emplace_back("common", 1, Symbol::Include);
+  R.IncludeHeaders.emplace_back("new", 1, Symbol::Include);
 
   // Both have no definition.
   Symbol M = mergeSymbol(L, R);
@@ -615,7 +615,7 @@
 std::move(DynData), DynSize);
 
   SymbolSlab::Builder StaticB;
-  S.IncludeHeaders.push_back({"", 0});
+  S.IncludeHeaders.push_back({"", 0, Symbol::Include});
   StaticB.insert(S);
   auto StaticIndex =
   MemIndex::build(std::move(StaticB).build(), RefSlab(), RelationSlab());
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1071,7 +1071,7 @@
 Sym.Flags |= Symbol::IndexedForCodeCompletion;
 Sym.CanonicalDeclaration.FileURI = S.DeclaringFile.c_str();
 Sym.Definition.FileURI = S.DeclaringFile.c_str();
-Sym.IncludeHeaders.emplace_back(S.IncludeHeader, 1);
+Sym.IncludeHeaders.emplace_back(S.IncludeHeader, 1, Symbol::Include);
 Slab.insert(Sym);
   }
   return MemIndex::build(std::move(Slab).build(), RefSlab(), RelationSlab());
@@ -1129,7 +1129,7 @@
   Symbol Sym = enm("X")

[PATCH] D137851: [OPENMP]Initial support for at clause

2022-11-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:11293
+   SourceLocation EndLoc,
+   bool InExContext = true);
   /// Called on well-formed '\#pragma omp barrier'.

Why do you need this flag?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:11035-11037
+  for (auto *AC :
+   OMPExecutableDirective::getClausesOfKind(Clauses))
+AtC = AC;

Why do you need a loop here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137851

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


[PATCH] D137917: [cmake] Fix _GNU_SOURCE being added unconditionally

2022-11-14 Thread Trass3r via Phabricator via cfe-commits
Trass3r added a comment.

`Andreas Hollandt `


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137917

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


[clang] cbcf123 - [LegacyPM] Remove cl::opts controlling optimization pass manager passes

2022-11-14 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2022-11-14T09:38:17-08:00
New Revision: cbcf123af293ee56876cce16dac83c3008478dae

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

LOG: [LegacyPM] Remove cl::opts controlling optimization pass manager passes

Move these to the new PM if they're used there.

Part of removing the legacy pass manager for optimization pipeline.

Reland with UseNewGVN usage in clang removed.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/lib/Passes/PassBuilderPipelines.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index eb444c829381f..41f9ce3a009da 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -83,7 +83,6 @@
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Scalar/JumpThreading.h"
 #include "llvm/Transforms/Scalar/LowerMatrixIntrinsics.h"
-#include "llvm/Transforms/Scalar/NewGVN.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
 #include "llvm/Transforms/Utils/Debugify.h"
@@ -101,7 +100,6 @@ using namespace llvm;
 
 namespace llvm {
 extern cl::opt DebugInfoCorrelate;
-extern cl::opt RunNewGVN;
 
 // Experiment to move sanitizers earlier.
 static cl::opt ClSanitizeOnOptimizerEarlyEP(
@@ -676,10 +674,7 @@ static void addSanitizers(const Triple &TargetTriple,
   FPM.addPass(EarlyCSEPass(true /* Enable mem-ssa. */));
   FPM.addPass(InstCombinePass());
   FPM.addPass(JumpThreadingPass());
-  if (RunNewGVN)
-FPM.addPass(NewGVNPass());
-  else
-FPM.addPass(GVNPass());
+  FPM.addPass(GVNPass());
   FPM.addPass(InstCombinePass());
   MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
 }

diff  --git a/llvm/lib/Passes/PassBuilderPipelines.cpp 
b/llvm/lib/Passes/PassBuilderPipelines.cpp
index b32d53d8dfaf8..f978b2cefe9e3 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -134,11 +134,11 @@ static cl::opt UseInlineAdvisor(
 "enable-ml-inliner", cl::init(InliningAdvisorMode::Default), cl::Hidden,
 cl::desc("Enable ML policy for inliner. Currently trained for -Oz only"),
 cl::values(clEnumValN(InliningAdvisorMode::Default, "default",
-  "Heuristics-based inliner version."),
+  "Heuristics-based inliner version"),
clEnumValN(InliningAdvisorMode::Development, "development",
-  "Use development mode (runtime-loadable model)."),
+  "Use development mode (runtime-loadable model)"),
clEnumValN(InliningAdvisorMode::Release, "release",
-  "Use release mode (AOT-compiled model).")));
+  "Use release mode (AOT-compiled model)")));
 
 static cl::opt EnableSyntheticCounts(
 "enable-npm-synthetic-counts", cl::Hidden,
@@ -161,7 +161,7 @@ static cl::opt 
EnableModuleInliner("enable-module-inliner",
 static cl::opt PerformMandatoryInliningsFirst(
 "mandatory-inlining-first", cl::init(true), cl::Hidden,
 cl::desc("Perform mandatory inlinings module-wide, before performing "
- "inlining."));
+ "inlining"));
 
 static cl::opt EnableO3NonTrivialUnswitching(
 "enable-npm-O3-nontrivial-unswitch", cl::init(true), cl::Hidden,
@@ -190,6 +190,99 @@ static cl::opt EnableGlobalAnalyses(
 "enable-global-analyses", cl::init(true), cl::Hidden,
 cl::desc("Enable inter-procedural analyses"));
 
+static cl::opt
+RunPartialInlining("enable-partial-inlining", cl::init(false), cl::Hidden,
+   cl::desc("Run Partial inlinining pass"));
+
+static cl::opt ExtraVectorizerPasses(
+"extra-vectorizer-passes", cl::init(false), cl::Hidden,
+cl::desc("Run cleanup optimization passes after vectorization"));
+
+static cl::opt RunNewGVN("enable-newgvn", cl::init(false), cl::Hidden,
+   cl::desc("Run the NewGVN pass"));
+
+static cl::opt EnableLoopInterchange(
+"enable-loopinterchange", cl::init(false), cl::Hidden,
+cl::desc("Enable the experimental LoopInterchange Pass"));
+
+static cl::opt EnableUnrollAndJam("enable-unroll-and-jam",
+cl::init(false), cl::Hidden,
+cl::desc("Enable Unroll And Jam 
Pass"));
+
+static cl::opt EnableLoopFlatten("enable-loop-flatten", cl::init(false),
+   cl::Hidden,
+   cl::desc("Enable the 

  1   2   >