[clang] [Documentation] Replace recommonmark by myst-parser (PR #65664)

2023-09-08 Thread via cfe-commits

cor3ntin wrote:

Agreed. I have found that the full set of needed pip modules is
`sphinx myst-parser sphinx-markdown-tables sphinx-automodapi furo` - I think 
most of theses are only used by LLDB but might as well document them as 
requirements for everything.

https://github.com/llvm/llvm-project/pull/65664
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Parse] Split incremental-extensions (PR #65683)

2023-09-08 Thread via cfe-commits

https://github.com/cor3ntin approved this pull request.


https://github.com/llvm/llvm-project/pull/65683
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-08 Thread Andrzej Warzyński via cfe-commits


@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU

banach-space wrote:

Solaris is not GNU ;-) Please use a dedicated prefix.

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] fix failed ompt tests on M1 device (PR #65696)

2023-09-08 Thread Lixi Zhou via cfe-commits

https://github.com/lixi-zhou updated 
https://github.com/llvm/llvm-project/pull/65696:

>From eacec22651766c6c6961d14964ddb6a180fbfec0 Mon Sep 17 00:00:00 2001
From: Lixi Zhou 
Date: Thu, 7 Sep 2023 16:15:25 -0700
Subject: [PATCH 1/2] fix failed ompt test on M1 device

---
 openmp/runtime/test/ompt/callback.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/openmp/runtime/test/ompt/callback.h 
b/openmp/runtime/test/ompt/callback.h
index 8180b3d2663f769..d8218113d4b197b 100644
--- a/openmp/runtime/test/ompt/callback.h
+++ b/openmp/runtime/test/ompt/callback.h
@@ -190,8 +190,8 @@ ompt_label_##id:
 // On AArch64 the NOP instruction is 4 bytes long, can be followed by inserted
 // store instruction (another 4 bytes long).
 #define print_possible_return_addresses(addr) \
-  printf("%" PRIu64 ": current_address=%p or %p\n", 
ompt_get_thread_data()->value, \
- ((char *)addr) - 4, ((char *)addr) - 8)
+  printf("%" PRIu64 ": current_address=%p or %p or %p\n", 
ompt_get_thread_data()->value, \
+ ((char *)addr) - 4, ((char *)addr) - 8, ((char *)addr) - 12)
 #elif KMP_ARCH_RISCV64
 #if __riscv_compressed
 // On RV64GC the C.NOP instruction is 2 byte long. In addition, the compiler

>From e6e727648acbd8c1a3cb4f2bb1047b7903153f29 Mon Sep 17 00:00:00 2001
From: lixizhou 
Date: Fri, 8 Sep 2023 00:25:05 -0700
Subject: [PATCH 2/2] refactor code based on feedback, fix #63149

---
 openmp/runtime/test/ompt/callback.h | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/openmp/runtime/test/ompt/callback.h 
b/openmp/runtime/test/ompt/callback.h
index d8218113d4b197b..ecce5357b6ecb59 100644
--- a/openmp/runtime/test/ompt/callback.h
+++ b/openmp/runtime/test/ompt/callback.h
@@ -189,9 +189,17 @@ ompt_label_##id:
 #elif KMP_ARCH_AARCH64
 // On AArch64 the NOP instruction is 4 bytes long, can be followed by inserted
 // store instruction (another 4 bytes long).
-#define print_possible_return_addresses(addr) \
-  printf("%" PRIu64 ": current_address=%p or %p or %p\n", 
ompt_get_thread_data()->value, \
- ((char *)addr) - 4, ((char *)addr) - 8, ((char *)addr) - 12)
+#if KMP_OS_DARWIN
+#define print_possible_return_addresses(addr)  
\
+  printf("%" PRIu64 ": current_address=%p or %p or %p\n",  
\
+ ompt_get_thread_data()->value, ((char *)addr) - 4,
\
+ ((char *)addr) - 8, ((char *)addr) - 12)
+#else
+#define print_possible_return_addresses(addr)  
\
+  printf("%" PRIu64 ": current_address=%p or %p\n",
\
+ ompt_get_thread_data()->value, ((char *)addr) - 4,
\
+ ((char *)addr) - 8)
+#endif
 #elif KMP_ARCH_RISCV64
 #if __riscv_compressed
 // On RV64GC the C.NOP instruction is 2 byte long. In addition, the compiler

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


[clang] [sema] Improve -Wsign-compare (PR #65684)

2023-09-08 Thread via cfe-commits

cor3ntin wrote:

Thanks for working on this.

I wonder if it's maybe too clever? Comparing to 0 is only one of the possible 
fix, I usually try to make sure my types are consistent instead - which is not 
something a fixit could do.

The more annoying thing is that this does not interact well with 
`-Wold-style-cast` and most C++ guidelines. In C++ we would want to use a 
`static_cast` instead.

Either way, the diagnostic changes are a nice improvement


https://github.com/llvm/llvm-project/pull/65684
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-08 Thread Rainer Orth via cfe-commits


@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU

rorth wrote:

True, but how many more copies of the same patterns do we want?  Add FreeBSD, 
OpenBSD, ... whenever they arrive?  Isn't the common patternwith or without `-lm`?  How about putting the first under 
one label and the `-lm` part under another, used where appropriate?

https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format][NFC] Skip additional tests of the same case upon failure (PR #65540)

2023-09-08 Thread via cfe-commits

https://github.com/owenca updated 
https://github.com/llvm/llvm-project/pull/65540:

>From dbcdf774da71129572e4844a0998b4e810f7aae4 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Wed, 6 Sep 2023 14:53:39 -0700
Subject: [PATCH] [clang-format][NFC] Skip remaining tests of the same case
 upon failure

A typical test case goes through the format, stability, ObjC, and messUp
tests. If any of theses tests fails, we should skip the remaining tests for
the same test case.
---
 clang/unittests/Format/FormatTestBase.h | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/clang/unittests/Format/FormatTestBase.h 
b/clang/unittests/Format/FormatTestBase.h
index 22eea23b869a212..eaadb1c9f83e5a5 100644
--- a/clang/unittests/Format/FormatTestBase.h
+++ b/clang/unittests/Format/FormatTestBase.h
@@ -80,17 +80,22 @@ class FormatTestBase : public ::testing::Test {
 return Style;
   }
 
-  void _verifyFormat(const char *File, int Line, llvm::StringRef Expected,
+  bool _verifyFormat(const char *File, int Line, llvm::StringRef Expected,
  llvm::StringRef Code,
  const std::optional &Style = {},
  const std::vector &Ranges = {}) {
 testing::ScopedTrace t(File, Line, ::testing::Message() << Code.str());
+const auto ExpectedCode{Expected.str()};
+auto FormattedCode{format(Code, Style, SC_ExpectComplete, Ranges)};
+EXPECT_EQ(ExpectedCode, FormattedCode);
+if (ExpectedCode != FormattedCode)
+  return false;
 if (Expected != Code) {
-  EXPECT_EQ(Expected.str(),
-format(Expected, Style, SC_ExpectComplete, Ranges))
-  << "Expected code is not stable";
+  FormattedCode = format(Expected, Style, SC_ExpectComplete, Ranges);
+  EXPECT_EQ(ExpectedCode, FormattedCode) << "Expected code is not stable";
+  if (ExpectedCode != FormattedCode)
+return false;
 }
-EXPECT_EQ(Expected.str(), format(Code, Style, SC_ExpectComplete, Ranges));
 auto UsedStyle = Style ? Style.value() : getDefaultStyle();
 if (UsedStyle.Language == FormatStyle::LK_Cpp) {
   // Objective-C++ is a superset of C++, so everything checked for C++
@@ -98,14 +103,18 @@ class FormatTestBase : public ::testing::Test {
   FormatStyle ObjCStyle = UsedStyle;
   ObjCStyle.Language = FormatStyle::LK_ObjC;
   // FIXME: Additional messUp is superfluous.
-  EXPECT_EQ(Expected.str(),
-format(Code, ObjCStyle, SC_ExpectComplete, Ranges));
+  FormattedCode = format(Code, ObjCStyle, SC_ExpectComplete, Ranges);
+  EXPECT_EQ(ExpectedCode, FormattedCode);
+  if (ExpectedCode != FormattedCode)
+return false;
 }
+return true;
   }
 
   void _verifyFormat(const char *File, int Line, llvm::StringRef Code,
  const std::optional &Style = {}) {
-_verifyFormat(File, Line, Code, Code, Style);
+if (!_verifyFormat(File, Line, Code, Code, Style))
+  return;
 if (const auto MessedUpCode{messUp(Code)}; MessedUpCode != Code)
   _verifyFormat(File, Line, Code, MessedUpCode, Style);
   }

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


[clang] [clang] Improve `_Alignas` on a `struct` declaration diagnostic (PR #65638)

2023-09-08 Thread via cfe-commits

cor3ntin wrote:

Generally looks good, thanks for working on this

I'd like to see more tests in `clang/test/Sema/alignas.c` - we don't have a 
test for `struct _Alignas(int)  T` either apparently.
Given this fixes a bug, it could benefit from a release note in 
`clang/docs/ReleaseNotes.rst`

https://github.com/llvm/llvm-project/pull/65638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D159480: [Clang][AArch64] Fine-grained ldp and stp policies.

2023-09-08 Thread Manos Anagnostakis via Phabricator via cfe-commits
manosanag added a comment.

Hello Dave,

thanks for replying.

Yes, this is an optimization.

On some AArch64 cores, including Ampere's ampere1 architecture that this is 
targeted for, load/store pair instructions are faster compared to simple 
loads/stores only when the alignment of the pair is at least twice that of the 
individual element being loaded. Based on the performance of various 
benchmarks, emitting ldp/stp instructions was disabled on GCC at some point 
(discussion is 
https://gcc.gnu.org/pipermail/gcc-patches/2023-April/615672.html). This patch 
improves on that and offers control over when the instructions are used.

Similar patch with the same flags has been recently submitted for review in the 
GCC mailing lists 
(https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628590.html).

I have a fix ready for the fortran regressions shown by autotesting. I can 
include some of this information to the commit message of the diff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159480

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


[clang] [clang-format][NFC] Skip remaining tests of the same case upon failure (PR #65540)

2023-09-08 Thread via cfe-commits

https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/65540
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format][NFC] Skip remaining tests of the same case upon failure (PR #65540)

2023-09-08 Thread via cfe-commits

https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/65540
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7ecbf6c - [clang-format][NFC] Skip remaining tests of the same case upon failure (#65540)

2023-09-08 Thread via cfe-commits

Author: Owen
Date: 2023-09-08T01:06:54-07:00
New Revision: 7ecbf6c30605ecbee4fdbcdec8f0866328c5217f

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

LOG: [clang-format][NFC] Skip remaining tests of the same case upon failure 
(#65540)

A typical test case goes through the format, stability, ObjC, and messUp
tests. If any of theses tests fails, we should skip the remaining tests
for the same test case.

Added: 


Modified: 
clang/unittests/Format/FormatTestBase.h

Removed: 




diff  --git a/clang/unittests/Format/FormatTestBase.h 
b/clang/unittests/Format/FormatTestBase.h
index 22eea23b869a212..eaadb1c9f83e5a5 100644
--- a/clang/unittests/Format/FormatTestBase.h
+++ b/clang/unittests/Format/FormatTestBase.h
@@ -80,17 +80,22 @@ class FormatTestBase : public ::testing::Test {
 return Style;
   }
 
-  void _verifyFormat(const char *File, int Line, llvm::StringRef Expected,
+  bool _verifyFormat(const char *File, int Line, llvm::StringRef Expected,
  llvm::StringRef Code,
  const std::optional &Style = {},
  const std::vector &Ranges = {}) {
 testing::ScopedTrace t(File, Line, ::testing::Message() << Code.str());
+const auto ExpectedCode{Expected.str()};
+auto FormattedCode{format(Code, Style, SC_ExpectComplete, Ranges)};
+EXPECT_EQ(ExpectedCode, FormattedCode);
+if (ExpectedCode != FormattedCode)
+  return false;
 if (Expected != Code) {
-  EXPECT_EQ(Expected.str(),
-format(Expected, Style, SC_ExpectComplete, Ranges))
-  << "Expected code is not stable";
+  FormattedCode = format(Expected, Style, SC_ExpectComplete, Ranges);
+  EXPECT_EQ(ExpectedCode, FormattedCode) << "Expected code is not stable";
+  if (ExpectedCode != FormattedCode)
+return false;
 }
-EXPECT_EQ(Expected.str(), format(Code, Style, SC_ExpectComplete, Ranges));
 auto UsedStyle = Style ? Style.value() : getDefaultStyle();
 if (UsedStyle.Language == FormatStyle::LK_Cpp) {
   // Objective-C++ is a superset of C++, so everything checked for C++
@@ -98,14 +103,18 @@ class FormatTestBase : public ::testing::Test {
   FormatStyle ObjCStyle = UsedStyle;
   ObjCStyle.Language = FormatStyle::LK_ObjC;
   // FIXME: Additional messUp is superfluous.
-  EXPECT_EQ(Expected.str(),
-format(Code, ObjCStyle, SC_ExpectComplete, Ranges));
+  FormattedCode = format(Code, ObjCStyle, SC_ExpectComplete, Ranges);
+  EXPECT_EQ(ExpectedCode, FormattedCode);
+  if (ExpectedCode != FormattedCode)
+return false;
 }
+return true;
   }
 
   void _verifyFormat(const char *File, int Line, llvm::StringRef Code,
  const std::optional &Style = {}) {
-_verifyFormat(File, Line, Code, Code, Style);
+if (!_verifyFormat(File, Line, Code, Code, Style))
+  return;
 if (const auto MessedUpCode{messUp(Code)}; MessedUpCode != Code)
   _verifyFormat(File, Line, Code, MessedUpCode, Style);
   }



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


[clang] [clang-format][NFC] Skip remaining tests of the same case upon failure (PR #65540)

2023-09-08 Thread via cfe-commits

https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/65540
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AMDGPU] Remove Code Object V2 (PR #65715)

2023-09-08 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm commented:

The test updates to update the target can be done in a precommit.

Is this dropping read support?

https://github.com/llvm/llvm-project/pull/65715
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Reduce constraint on modulo with small concrete range (PR #65448)

2023-09-08 Thread Ding Fei via cfe-commits

https://github.com/danix800 converted_to_draft 
https://github.com/llvm/llvm-project/pull/65448
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a serious bug in git-clang-format (PR #65723)

2023-09-08 Thread via cfe-commits

https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/65723:

When applying format changes to staged files, git-clang-format erroneously 
checks out all files in the index and thus may overwrite unstaged changes.

Fixes #65643.

>From eb3fc8f7c9f61650d458ffbd2952fa97e7c2e28d Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Fri, 8 Sep 2023 01:16:33 -0700
Subject: [PATCH] [clang-format] Fix a serious bug in git-clang-format

When applying format changes to staged files, git-clang-format erroneously
checks out all files in the index and thus may overwrite unstaged changes.

Fixes #65643.
---
 clang/tools/clang-format/git-clang-format | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index c0b99b82203234c..0f33b5339ec14cb 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -606,7 +606,7 @@ def apply_changes(old_tree, new_tree, force=False, 
patch_mode=False):
 index_tree = old_tree
   else:
 with temporary_index_file(new_tree):
-  run('git', 'checkout-index', '-a', '-f')
+  run('git', 'checkout-index', '-f', '--', *changed_files)
   return changed_files
 
 

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


[clang] [clang-format] Fix a serious bug in git-clang-format (PR #65723)

2023-09-08 Thread via cfe-commits

https://github.com/owenca review_requested 
https://github.com/llvm/llvm-project/pull/65723
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a serious bug in git-clang-format (PR #65723)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65723
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-08 Thread Rainer Orth via cfe-commits

https://github.com/rorth edited https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 96122b5 - [C++20] [Modules] Introduce ForceCheckCXX20ModulesInputFiles options for

2023-09-08 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-09-08T16:53:12+08:00
New Revision: 96122b5b717c2b1a291d7298ac50b1daf02bd97c

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

LOG: [C++20] [Modules] Introduce ForceCheckCXX20ModulesInputFiles options for
C++20 modules

Previously, we banned the check for input files from C++20 modules since
we thought the BMI from C++20 modules should be a standalone artifact.

However, during the recent experiment with clangd for modules, I find
it is necessary to tell whether or not a BMI is out-of-date by checking the
input files especially for language servers.

So this patch brings a header search option
ForceCheckCXX20ModulesInputFiles to allow the tools (concretly, clangd)
to check the input files from BMI.

Added: 
clang/test/Modules/cxx20-force-check-input.cppm

Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Lex/HeaderSearchOptions.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index b29e2e53f938544..4bc292c1fa1620c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2906,6 +2906,11 @@ def fvalidate_ast_input_files_content:
" Files with mismatching mtime's are considered valid"
" if both contents is identical">,
   MarshallingInfoFlag>;
+def fforce_check_cxx20_modules_input_files:
+  Flag <["-"], "fforce-check-cxx20-modules-input-files">,
+  Group, Visibility<[ClangOption, CC1Option]>,
+  HelpText<"Check the input source files from C++20 modules explicitly">,
+  MarshallingInfoFlag>;
 def fmodules_validate_input_files_content:
   Flag <["-"], "fmodules-validate-input-files-content">,
   Group, Flags<[NoXarchOption]>,

diff  --git a/clang/include/clang/Lex/HeaderSearchOptions.h 
b/clang/include/clang/Lex/HeaderSearchOptions.h
index 6436a9b3bde20a2..126659f3ac00223 100644
--- a/clang/include/clang/Lex/HeaderSearchOptions.h
+++ b/clang/include/clang/Lex/HeaderSearchOptions.h
@@ -211,6 +211,9 @@ class HeaderSearchOptions {
   // validate consistency.
   unsigned ValidateASTInputFilesContent : 1;
 
+  // Whether the input files from C++20 Modules should be checked.
+  unsigned ForceCheckCXX20ModulesInputFiles : 1;
+
   /// Whether the module includes debug information (-gmodules).
   unsigned UseDebugInfo : 1;
 
@@ -233,7 +236,8 @@ class HeaderSearchOptions {
 UseStandardCXXIncludes(true), UseLibcxx(false), Verbose(false),
 ModulesValidateOncePerBuildSession(false),
 ModulesValidateSystemHeaders(false),
-ValidateASTInputFilesContent(false), UseDebugInfo(false),
+ValidateASTInputFilesContent(false),
+ForceCheckCXX20ModulesInputFiles(false), UseDebugInfo(false),
 ModulesValidateDiagnosticOptions(true), ModulesHashContent(false),
 ModulesStrictContextHash(false) {}
 

diff  --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index a4753f525d9de2d..167db521a890cd9 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -550,12 +550,16 @@ class ASTInfoCollector : public ASTReaderListener {
   bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
StringRef SpecificModuleCachePath,
bool Complain) override {
-// Preserve previously set header search paths.
+// llvm::SaveAndRestore doesn't support bit field.
+auto ForceCheckCXX20ModulesInputFiles =
+this->HSOpts.ForceCheckCXX20ModulesInputFiles;
 llvm::SaveAndRestore X(this->HSOpts.UserEntries);
 llvm::SaveAndRestore Y(this->HSOpts.SystemHeaderPrefixes);
 llvm::SaveAndRestore Z(this->HSOpts.VFSOverlayFiles);
 
 this->HSOpts = HSOpts;
+this->HSOpts.ForceCheckCXX20ModulesInputFiles =
+ForceCheckCXX20ModulesInputFiles;
 
 return false;
   }

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 8ece979f2408e4d..576da09095002b0 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -2428,6 +2428,16 @@ InputFile ASTReader::getInputFile(ModuleFile &F, 
unsigned ID, bool Complain) {
   // For standard C++ modules, we don't need to check the inputs.
   bool SkipChecks = F.StandardCXXModule;
 
+  const HeaderSearchOptions &HSOpts =
+  PP.getHeaderSearchInfo().getHeaderSearchOpts();
+
+  // The option ForceCheckCXX20ModulesInputFiles is only meaningful for C++20
+  // modules.
+  if (F.StandardCXXModule && HSOpts.ForceCheckCXX20ModulesInputFiles) {
+SkipChecks = false;
+Overridden = false;
+  }
+
   OptionalFileEntryRefDegradesToFileEntryPtr File = OptionalFileEntry

[PATCH] D157526: [clang][Sema] Remove irrelevant diagnostics from constraint satisfaction failure

2023-09-08 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

LGTM, but please wait a few days for @erichkeane


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

https://reviews.llvm.org/D157526

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


[clang] [analyzer] Reduce constraint on modulo with small concrete range (PR #65448)

2023-09-08 Thread Ding Fei via cfe-commits

https://github.com/danix800 updated 
https://github.com/llvm/llvm-project/pull/65448:

>From 235f39a6a5137e53239105727798d4540e5dd563 Mon Sep 17 00:00:00 2001
From: dingfei 
Date: Wed, 6 Sep 2023 10:03:21 +0800
Subject: [PATCH 1/3] [analyzer] Reduce constraint on modulo with small
 concrete range

---
 .../Core/RangeConstraintManager.cpp   | 48 +++
 clang/test/Analysis/constraint-assignor.c | 60 +++
 2 files changed, 108 insertions(+)

diff --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index 5de99384449a4c8..9bda29c87f3c0f1 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -2073,6 +2073,14 @@ class ConstraintAssignor : public 
ConstraintAssignorBase {
 if (Sym->getOpcode() != BO_Rem)
   return true;
 // a % b != 0 implies that a != 0.
+// Z3 verification:
+//   (declare-const a Int)
+//   (declare-const m Int)
+//   (assert (not (= m 0)))
+//   (assert (not (= (mod a m) 0)))
+//   (assert (= a 0))
+//   (check-sat)
+//   ; unsat
 if (!Constraint.containsZero()) {
   SVal SymSVal = Builder.makeSymbolVal(Sym->getLHS());
   if (auto NonLocSymSVal = SymSVal.getAs()) {
@@ -2080,6 +2088,46 @@ class ConstraintAssignor : public 
ConstraintAssignorBase {
 if (!State)
   return false;
   }
+} else if (auto *SIE = dyn_cast(Sym);
+   SIE && Constraint.encodesFalseRange()) {
+  // a % m == 0 && a in [x, y] && y - x < m implies that
+  // a = (y < 0 ? x : y) / m * m which is a 'ConcreteInt'
+  // where x and m are 'ConcreteInt'.
+  //
+  // Z3 verification:
+  //   (declare-const a Int)
+  //   (declare-const m Int)
+  //   (declare-const x Int)
+  //   (declare-const y Int)
+  //   (assert (= (mod a m) 0))
+  //   (assert (< (- y x) m))
+  //   (assert (and (>= a x) (<= a y)))
+  //   (assert (not (= a (* (div y m) m
+  //   (check-sat)
+  //   ; unsat
+  llvm::APSInt Modulo = SIE->getRHS();
+  Modulo = llvm::APSInt(Modulo.abs(), Modulo.isUnsigned());
+  RangeSet RS =
+  SymbolicRangeInferrer::inferRange(RangeFactory, State, 
SIE->getLHS());
+  if (RS.size() == 1) {
+auto R = RS.begin();
+if ((R->To() - R->From()).getExtValue() < Modulo.getExtValue()) {
+  SVal SymSVal = Builder.makeSymbolVal(SIE->getLHS());
+  if (auto NonLocSymSVal = SymSVal.getAs()) {
+auto NewConstConstraint = Builder.makeIntVal(
+(R->To() > 0 ? R->To() : R->From()) / Modulo * Modulo);
+if (auto Cond = Builder
+.evalBinOp(State, BO_EQ, *NonLocSymSVal,
+   NewConstConstraint,
+   Builder.getConditionType())
+.template getAs()) {
+  State = State->assume(*Cond, true);
+  if (!State)
+return false;
+}
+  }
+}
+  }
 }
 return true;
   }
diff --git a/clang/test/Analysis/constraint-assignor.c 
b/clang/test/Analysis/constraint-assignor.c
index 8210e576c98bd21..150fe20c9f37a0a 100644
--- a/clang/test/Analysis/constraint-assignor.c
+++ b/clang/test/Analysis/constraint-assignor.c
@@ -5,6 +5,7 @@
 
 void clang_analyzer_warnIfReached(void);
 void clang_analyzer_eval(int);
+void clang_analyzer_dump(int);
 
 void rem_constant_rhs_ne_zero(int x, int y) {
   if (x % 3 == 0) // x % 3 != 0 -> x != 0
@@ -82,3 +83,62 @@ void remainder_with_adjustment_of_composit_lhs(int x, int y) 
{
   clang_analyzer_eval(x + y != -1);// expected-warning{{TRUE}}
   (void)(x * y); // keep the constraints alive.
 }
+
+void remainder_infeasible(int x, int y) {
+  if (x <= 2 || x >= 5)
+return;
+  if (x % 5 != 0)
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)x; // keep the constraints alive.
+}
+
+void remainder_within_modulo_positive_range_unsigned(unsigned x) {
+  if (x <= 2 || x > 6)
+return;
+  clang_analyzer_dump(x); // expected-warning{{reg_$0}}
+  if (x % 5 != 0)
+return;
+  clang_analyzer_dump(x);  // expected-warning{{5 S32b}}
+  (void)x; // keep the constraints alive.
+}
+
+void remainder_within_modulo_positive_range(int x) {
+  if (x <= 2 || x > 6)
+return;
+  clang_analyzer_dump(x); // expected-warning{{reg_$0}}
+  if (x % 5 != 0)
+return;
+  clang_analyzer_dump(x);  // expected-warning{{5 S32b}}
+  (void)x; // keep the constraints alive.
+}
+
+void remainder_within_modulo_range_spans_zero(int x) {
+  if (x <= -2 || x > 2)
+return;
+  clang_analyzer_dump(x); // expected-warning{{reg_$0}}
+  if (x % 5 != 0)
+return;
+  clang_analyzer_dump(x);  // expected-warning{{0 S32b}}
+  (void)x; // keep the constraints alive.
+}
+
+void rem

[clang] [analyzer] Reduce constraint on modulo with small concrete range (PR #65448)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65448
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Reduce constraint on modulo with small concrete range (PR #65448)

2023-09-08 Thread Ding Fei via cfe-commits

https://github.com/danix800 unlabeled 
https://github.com/llvm/llvm-project/pull/65448
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Reduce constraint on modulo with small concrete range (PR #65448)

2023-09-08 Thread Ding Fei via cfe-commits

https://github.com/danix800 updated 
https://github.com/llvm/llvm-project/pull/65448:

>From 501595caf608aaeb8253235c32de5dd3ef4d3439 Mon Sep 17 00:00:00 2001
From: dingfei 
Date: Wed, 6 Sep 2023 10:03:21 +0800
Subject: [PATCH 1/3] [analyzer] Reduce constraint on modulo with small
 concrete range

---
 .../Core/RangeConstraintManager.cpp   | 48 +++
 clang/test/Analysis/constraint-assignor.c | 60 +++
 2 files changed, 108 insertions(+)

diff --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index 5de99384449a4c8..9bda29c87f3c0f1 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -2073,6 +2073,14 @@ class ConstraintAssignor : public 
ConstraintAssignorBase {
 if (Sym->getOpcode() != BO_Rem)
   return true;
 // a % b != 0 implies that a != 0.
+// Z3 verification:
+//   (declare-const a Int)
+//   (declare-const m Int)
+//   (assert (not (= m 0)))
+//   (assert (not (= (mod a m) 0)))
+//   (assert (= a 0))
+//   (check-sat)
+//   ; unsat
 if (!Constraint.containsZero()) {
   SVal SymSVal = Builder.makeSymbolVal(Sym->getLHS());
   if (auto NonLocSymSVal = SymSVal.getAs()) {
@@ -2080,6 +2088,46 @@ class ConstraintAssignor : public 
ConstraintAssignorBase {
 if (!State)
   return false;
   }
+} else if (auto *SIE = dyn_cast(Sym);
+   SIE && Constraint.encodesFalseRange()) {
+  // a % m == 0 && a in [x, y] && y - x < m implies that
+  // a = (y < 0 ? x : y) / m * m which is a 'ConcreteInt'
+  // where x and m are 'ConcreteInt'.
+  //
+  // Z3 verification:
+  //   (declare-const a Int)
+  //   (declare-const m Int)
+  //   (declare-const x Int)
+  //   (declare-const y Int)
+  //   (assert (= (mod a m) 0))
+  //   (assert (< (- y x) m))
+  //   (assert (and (>= a x) (<= a y)))
+  //   (assert (not (= a (* (div y m) m
+  //   (check-sat)
+  //   ; unsat
+  llvm::APSInt Modulo = SIE->getRHS();
+  Modulo = llvm::APSInt(Modulo.abs(), Modulo.isUnsigned());
+  RangeSet RS =
+  SymbolicRangeInferrer::inferRange(RangeFactory, State, 
SIE->getLHS());
+  if (RS.size() == 1) {
+auto R = RS.begin();
+if ((R->To() - R->From()).getExtValue() < Modulo.getExtValue()) {
+  SVal SymSVal = Builder.makeSymbolVal(SIE->getLHS());
+  if (auto NonLocSymSVal = SymSVal.getAs()) {
+auto NewConstConstraint = Builder.makeIntVal(
+(R->To() > 0 ? R->To() : R->From()) / Modulo * Modulo);
+if (auto Cond = Builder
+.evalBinOp(State, BO_EQ, *NonLocSymSVal,
+   NewConstConstraint,
+   Builder.getConditionType())
+.template getAs()) {
+  State = State->assume(*Cond, true);
+  if (!State)
+return false;
+}
+  }
+}
+  }
 }
 return true;
   }
diff --git a/clang/test/Analysis/constraint-assignor.c 
b/clang/test/Analysis/constraint-assignor.c
index 8210e576c98bd21..150fe20c9f37a0a 100644
--- a/clang/test/Analysis/constraint-assignor.c
+++ b/clang/test/Analysis/constraint-assignor.c
@@ -5,6 +5,7 @@
 
 void clang_analyzer_warnIfReached(void);
 void clang_analyzer_eval(int);
+void clang_analyzer_dump(int);
 
 void rem_constant_rhs_ne_zero(int x, int y) {
   if (x % 3 == 0) // x % 3 != 0 -> x != 0
@@ -82,3 +83,62 @@ void remainder_with_adjustment_of_composit_lhs(int x, int y) 
{
   clang_analyzer_eval(x + y != -1);// expected-warning{{TRUE}}
   (void)(x * y); // keep the constraints alive.
 }
+
+void remainder_infeasible(int x, int y) {
+  if (x <= 2 || x >= 5)
+return;
+  if (x % 5 != 0)
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)x; // keep the constraints alive.
+}
+
+void remainder_within_modulo_positive_range_unsigned(unsigned x) {
+  if (x <= 2 || x > 6)
+return;
+  clang_analyzer_dump(x); // expected-warning{{reg_$0}}
+  if (x % 5 != 0)
+return;
+  clang_analyzer_dump(x);  // expected-warning{{5 S32b}}
+  (void)x; // keep the constraints alive.
+}
+
+void remainder_within_modulo_positive_range(int x) {
+  if (x <= 2 || x > 6)
+return;
+  clang_analyzer_dump(x); // expected-warning{{reg_$0}}
+  if (x % 5 != 0)
+return;
+  clang_analyzer_dump(x);  // expected-warning{{5 S32b}}
+  (void)x; // keep the constraints alive.
+}
+
+void remainder_within_modulo_range_spans_zero(int x) {
+  if (x <= -2 || x > 2)
+return;
+  clang_analyzer_dump(x); // expected-warning{{reg_$0}}
+  if (x % 5 != 0)
+return;
+  clang_analyzer_dump(x);  // expected-warning{{0 S32b}}
+  (void)x; // keep the constraints alive.
+}
+
+void rem

[clang] [analyzer] Reduce constraint on modulo with small concrete range (PR #65448)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65448
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d60c474 - [Clang] Propagate target-features if compatible when using mlink-builtin-bitcode

2023-09-08 Thread Juan Manuel MARTINEZ CAAMAÑO via cfe-commits

Author: Juan Manuel MARTINEZ CAAMAÑO
Date: 2023-09-08T11:20:16+02:00
New Revision: d60c47476dde601f1e48d44717ef23b7f1006fe6

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

LOG: [Clang] Propagate target-features if compatible when using 
mlink-builtin-bitcode

Buitlins from AMD's device-libs are compiled without specifying a
target-cpu, which results in builtins without the target-features
attribute set.

Before this patch, when linking this builtins with -mlink-builtin-bitcode
the target-features were not propagated in the incoming builtins.

With this patch, the default target features are propagated
if they are compatible with the target-features in the incoming builtin.

Reviewed By: arsenm

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

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGen/link-builtin-bitcode.c
clang/test/CodeGenCUDA/link-builtin-bitcode-gpu-attrs-preserved.cu

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 177059191bf4948..37de2800fd69c02 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2001,6 +2001,54 @@ static void getTrivialDefaultFunctionAttributes(
   }
 }
 
+static void
+overrideFunctionFeaturesWithTargetFeatures(llvm::AttrBuilder &FuncAttr,
+   const llvm::Function &F,
+   const TargetOptions &TargetOpts) {
+  auto FFeatures = F.getFnAttribute("target-features");
+
+  llvm::StringSet<> IncompatibleFeatureNames;
+  SmallVector MergedFeatures;
+  MergedFeatures.reserve(TargetOpts.Features.size());
+
+  if (FFeatures.isValid()) {
+const auto &TFeatures = TargetOpts.FeatureMap;
+for (StringRef Feature : llvm::split(FFeatures.getValueAsString(), ',')) {
+  if (Feature.empty())
+continue;
+
+  bool EnabledForFunc = Feature.starts_with("+");
+  assert(EnabledForFunc || Feature.starts_with("-"));
+
+  StringRef Name = Feature.drop_front(1);
+  auto TEntry = TFeatures.find(Name);
+
+  // Preserves features that are incompatible (either set to something
+  // 
diff erent or missing) from the target features
+  bool MissingFromTarget = TEntry == TFeatures.end();
+  bool EnabledForTarget = !MissingFromTarget && TEntry->second;
+  bool Incompatible = EnabledForTarget != EnabledForFunc;
+  if (MissingFromTarget || Incompatible) {
+MergedFeatures.push_back(Feature);
+if (Incompatible)
+  IncompatibleFeatureNames.insert(Name);
+  }
+}
+  }
+
+  for (StringRef Feature : TargetOpts.Features) {
+if (Feature.empty())
+  continue;
+StringRef Name = Feature.drop_front(1);
+if (IncompatibleFeatureNames.contains(Name))
+  continue;
+MergedFeatures.push_back(Feature);
+  }
+
+  if (!MergedFeatures.empty())
+FuncAttr.addAttribute("target-features", llvm::join(MergedFeatures, ","));
+}
+
 void CodeGen::mergeDefaultFunctionDefinitionAttributes(
 llvm::Function &F, const CodeGenOptions &CodeGenOpts,
 const LangOptions &LangOpts, const TargetOptions &TargetOpts,
@@ -2058,6 +2106,9 @@ void CodeGen::mergeDefaultFunctionDefinitionAttributes(
 
   F.removeFnAttrs(AttrsToRemove);
   addDenormalModeAttrs(Merged, MergedF32, FuncAttrs);
+
+  overrideFunctionFeaturesWithTargetFeatures(FuncAttrs, F, TargetOpts);
+
   F.addFnAttrs(FuncAttrs);
 }
 

diff  --git a/clang/test/CodeGen/link-builtin-bitcode.c 
b/clang/test/CodeGen/link-builtin-bitcode.c
index b3b54badf3f827e..fe60a9746f1c85f 100644
--- a/clang/test/CodeGen/link-builtin-bitcode.c
+++ b/clang/test/CodeGen/link-builtin-bitcode.c
@@ -1,42 +1,49 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-attributes --check-globals --include-generated-funcs 
--version 2
+// Build two version of the bitcode library, one with a target-cpu set and one 
without
 // RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx803 -DBITCODE -emit-llvm-bc 
-o %t-lib.bc %s
+// RUN: %clang_cc1 -triple amdgcn-- -DBITCODE -emit-llvm-bc -o 
%t-lib.no-cpu.bc %s
+
 // RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx90a -emit-llvm-bc -o %t.bc 
%s
 // RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx90a -emit-llvm \
 // RUN:   -mlink-builtin-bitcode %t-lib.bc -o - %t.bc | FileCheck %s
 
+// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx90a -emit-llvm-bc -o %t.bc 
%s
+// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx90a -emit-llvm \
+// RUN:   -mlink-builtin-bitcode %t-lib.no-cpu.bc -o - %t.bc | FileCheck %s
+
 #ifdef BITCODE
-int foo(void) { return 42; }
+int no_attr(void) { return 42; }
+int __attribute__((target("gfx8-insts"))) attr_in_target(void) { return 42; }
+int __attribute__((target("extended-i

[PATCH] D159206: [Clang] Propagate target-features if compatible when using mlink-builtin-bitcode

2023-09-08 Thread Juan Manuel Martinez Caamaño via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd60c47476dde: [Clang] Propagate target-features if 
compatible when using mlink-builtin-bitcode (authored by jmmartinez).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159206

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/link-builtin-bitcode.c
  clang/test/CodeGenCUDA/link-builtin-bitcode-gpu-attrs-preserved.cu

Index: clang/test/CodeGenCUDA/link-builtin-bitcode-gpu-attrs-preserved.cu
===
--- clang/test/CodeGenCUDA/link-builtin-bitcode-gpu-attrs-preserved.cu
+++ clang/test/CodeGenCUDA/link-builtin-bitcode-gpu-attrs-preserved.cu
@@ -31,7 +31,7 @@
 
 
 // CHECK: define {{.*}} i64 @do_intrin_stuff() #[[ATTR:[0-9]+]]
-// INTERNALIZE: attributes #[[ATTR]] = {{.*}} "target-cpu"="gfx{{.*}}" "target-features"="+gfx11-insts"
+// INTERNALIZE: attributes #[[ATTR]] = {{.*}} "target-cpu"="gfx{{.*}}" "target-features"="{{.*}}+gfx11-insts{{.*}}"
 // NOINTERNALIZE: attributes #[[ATTR]] = {{.*}} "target-features"="+gfx11-insts"
 
 #define __device__ __attribute__((device))
Index: clang/test/CodeGen/link-builtin-bitcode.c
===
--- clang/test/CodeGen/link-builtin-bitcode.c
+++ clang/test/CodeGen/link-builtin-bitcode.c
@@ -1,42 +1,49 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-attributes --check-globals --include-generated-funcs --version 2
+// Build two version of the bitcode library, one with a target-cpu set and one without
 // RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx803 -DBITCODE -emit-llvm-bc -o %t-lib.bc %s
+// RUN: %clang_cc1 -triple amdgcn-- -DBITCODE -emit-llvm-bc -o %t-lib.no-cpu.bc %s
+
 // RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx90a -emit-llvm-bc -o %t.bc %s
 // RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx90a -emit-llvm \
 // RUN:   -mlink-builtin-bitcode %t-lib.bc -o - %t.bc | FileCheck %s
 
+// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx90a -emit-llvm-bc -o %t.bc %s
+// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx90a -emit-llvm \
+// RUN:   -mlink-builtin-bitcode %t-lib.no-cpu.bc -o - %t.bc | FileCheck %s
+
 #ifdef BITCODE
-int foo(void) { return 42; }
+int no_attr(void) { return 42; }
+int __attribute__((target("gfx8-insts"))) attr_in_target(void) { return 42; }
+int __attribute__((target("extended-image-insts"))) attr_not_in_target(void) { return 42; }
+int __attribute__((target("no-gfx9-insts"))) attr_incompatible(void) { return 42; }
 int x = 12;
 #endif
 
-extern int foo(void);
+extern int no_attr(void);
+extern int attr_in_target(void);
+extern int attr_not_in_target(void);
+extern int attr_incompatible(void);
 extern int x;
 
-int bar() { return foo() + x; }
-//.
+int bar() { return no_attr() + attr_in_target() + attr_not_in_target() + attr_incompatible() + x; }
+
 // CHECK: @x = internal addrspace(1) global i32 12, align 4
-//.
-// CHECK: Function Attrs: noinline nounwind optnone
+
 // CHECK-LABEL: define dso_local i32 @bar
-// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[RETVAL:%.*]] = alloca i32, align 4, addrspace(5)
-// CHECK-NEXT:[[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
-// CHECK-NEXT:[[CALL:%.*]] = call i32 @foo()
-// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr addrspacecast (ptr addrspace(1) @x to ptr), align 4
-// CHECK-NEXT:[[ADD:%.*]] = add nsw i32 [[CALL]], [[TMP0]]
-// CHECK-NEXT:ret i32 [[ADD]]
+// CHECK-SAME: () #[[ATTR_BAR:[0-9]+]] {
 //
-//
-// CHECK: Function Attrs: convergent noinline nounwind optnone
-// CHECK-LABEL: define internal i32 @foo
-// CHECK-SAME: () #[[ATTR1:[0-9]+]] {
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[RETVAL:%.*]] = alloca i32, align 4, addrspace(5)
-// CHECK-NEXT:[[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
-// CHECK-NEXT:ret i32 42
-//
-//.
-// CHECK: attributes #0 = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx90a" "target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" }
-// CHECK: attributes #1 = { convergent noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx90a" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" }
-//.
+// CHECK-LABEL: define internal i32 @no_attr
+// CHECK-SAME: () #[[ATTR_COMPATIBLE:[0-9]+]] {
+
+// CHECK-LABEL: define internal i32 @attr_in_target
+// CHECK-SAME: () #[[ATTR_COMPATIBLE:[0-9]+]] {
+
+// 

[clang] [analyzer] Reduce constraint on modulo with small concrete range (PR #65448)

2023-09-08 Thread Ding Fei via cfe-commits

https://github.com/danix800 unlabeled 
https://github.com/llvm/llvm-project/pull/65448
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Don't crash when BlockToState is called from unreachable path (PR #65732)

2023-09-08 Thread Kinuko Yasuda via cfe-commits

https://github.com/kinu created https://github.com/llvm/llvm-project/pull/65732:

When we call `getEnvironment`, `BlockToState[BlockId]` for the block can return 
null even if CFCtx.isBlockReachable(B) returns true if it is called from a 
particular block that is marked unreachable to the block.

>From 1f805ef6a1c5697299eab149a9c0552e9195c259 Mon Sep 17 00:00:00 2001
From: Kinuko Yasuda 
Date: Fri, 8 Sep 2023 09:03:35 +
Subject: [PATCH] [clang][dataflow] Don't crash when BlockToState doesn't have
 unreached block

When we call `getEnvironment`, `BlockToState[BlockId]` for the block can return
null even if CFCtx.isBlockReachable(B) returns true if it is called from a
particular block that is marked unreachable to the block.
(An example is in `EvaluateBlockWithUnreachablePreds` in TransferTest.cpp)
---
 clang/lib/Analysis/FlowSensitive/Transfer.cpp | 15 +-
 .../Analysis/FlowSensitive/TransferTest.cpp   | 20 +++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp 
b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index 67d8be392ae6053..b46c947c691b9b9 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -43,7 +43,20 @@ const Environment *StmtToEnvMap::getEnvironment(const Stmt 
&S) const {
   if (!CFCtx.isBlockReachable(*BlockIt->getSecond()))
 return nullptr;
   const auto &State = BlockToState[BlockIt->getSecond()->getBlockID()];
-  assert(State);
+  if (!(State)) {
+LLVM_DEBUG({
+  // State can be null when this block is unreachable from the block that
+  // called this method.
+  bool hasUnreachableEdgeFromPred = false;
+  for (auto B : BlockIt->getSecond()->preds())
+if (!B) {
+  hasUnreachableEdgeFromPred = true;
+  break;
+}
+  assert(hasUnreachableEdgeFromPred);
+});
+return nullptr;
+  }
   return &State->Env;
 }
 
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 177970ac52a67eb..1fa800044c288d4 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -5853,4 +5853,24 @@ TEST(TransferTest, AnonymousStructWithReferenceField) {
   });
 }
 
+TEST(TransferTest, EvaluateBlockWithUnreachablePreds) {
+  // This is a crash repro.
+  // `false` block may not have been processed when we try to evalute the `||`
+  // after visiting `true`, because it is not necessary (and therefore the edge
+  // is marked unreachable). Trying to get the analysis state via
+  // `getEnvironment` for the subexpression should still not crash.
+  std::string Code = R"(
+int cast(int i) {
+  if ((i < 0 && true) || false) {
+return 0;
+  }
+  return 0;
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {});
+}
+
 } // namespace

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


[clang] [clang][dataflow] Don't crash when BlockToState is called from unreachable path (PR #65732)

2023-09-08 Thread Kinuko Yasuda via cfe-commits

https://github.com/kinu review_requested 
https://github.com/llvm/llvm-project/pull/65732
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Don't crash when BlockToState is called from unreachable path (PR #65732)

2023-09-08 Thread Kinuko Yasuda via cfe-commits

https://github.com/kinu review_requested 
https://github.com/llvm/llvm-project/pull/65732
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Don't crash when BlockToState is called from unreachable path (PR #65732)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65732
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Parse] Split incremental-extensions (PR #65683)

2023-09-08 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev approved this pull request.

LGTM! Maybe we can cherry pick it for the patch release 17.0.1. If that’s a 
critical patch for swift we can try for the 17.0.0 release. 

https://github.com/llvm/llvm-project/pull/65683
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Don't crash when BlockToState is called from unreachable path (PR #65732)

2023-09-08 Thread Kinuko Yasuda via cfe-commits


@@ -43,7 +43,20 @@ const Environment *StmtToEnvMap::getEnvironment(const Stmt 
&S) const {
   if (!CFCtx.isBlockReachable(*BlockIt->getSecond()))
 return nullptr;
   const auto &State = BlockToState[BlockIt->getSecond()->getBlockID()];
-  assert(State);
+  if (!(State)) {
+LLVM_DEBUG({
+  // State can be null when this block is unreachable from the block that
+  // called this method.
+  bool hasUnreachableEdgeFromPred = false;
+  for (auto B : BlockIt->getSecond()->preds())
+if (!B) {
+  hasUnreachableEdgeFromPred = true;
+  break;
+}
+  assert(hasUnreachableEdgeFromPred);

kinu wrote:

This check can be done more thoroughly (maybe with some pre-processing) if we 
want, but can be a bit costly. We won't hit this very often though

https://github.com/llvm/llvm-project/pull/65732
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Don't crash when BlockToState is called from unreachable path (PR #65732)

2023-09-08 Thread Kinuko Yasuda via cfe-commits

kinu wrote:

CC @martinboehme @Xazax-hun @ymand

https://github.com/llvm/llvm-project/pull/65732
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a serious bug in git-clang-format (PR #65723)

2023-09-08 Thread via cfe-commits

https://github.com/cor3ntin approved this pull request.

Oh wow. Thanks for fixing that so quickly!

https://github.com/llvm/llvm-project/pull/65723
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Drop functions with incompatible target-features when using mlink-builtin-bitcode (PR #65737)

2023-09-08 Thread Juan Manuel Martinez Caamaño via cfe-commits

https://github.com/jmmartinez created 
https://github.com/llvm/llvm-project/pull/65737:

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

From 1c2c8c7045d7298644f08833d3b2cdec694ea91d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20MARTINEZ=20CAAMA=C3=91O?= 
Date: Fri, 8 Sep 2023 11:25:44 +0200
Subject: [PATCH] [Clang] Drop functions with incompatible target-features when
 using mlink-builtin-bitcode

Differential Revision: https://reviews.llvm.org/D159257
---
 clang/lib/CodeGen/CGCall.cpp  | 20 
 clang/lib/CodeGen/CGCall.h|  5 +
 clang/lib/CodeGen/CodeGenAction.cpp   |  4 +++-
 clang/test/CodeGen/link-builtin-bitcode.c |  4 +---
 4 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 37de2800fd69c02..ace20b0b3745641 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2112,6 +2112,26 @@ void CodeGen::mergeDefaultFunctionDefinitionAttributes(
   F.addFnAttrs(FuncAttrs);
 }
 
+bool CodeGen::dropFunctionWithIncompatibleAttributes(
+llvm::Function &F, const TargetOptions &TargetOpts) {
+  auto FFeatures = F.getFnAttribute("target-features");
+  if (!FFeatures.isValid())
+return false;
+
+  const auto &TFeatures = TargetOpts.FeatureMap;
+  for (StringRef Feature : llvm::split(FFeatures.getValueAsString(), ',')) {
+bool EnabledForFunc = Feature[0] == '+';
+StringRef Name = Feature.substr(1);
+auto TEntry = TFeatures.find(Name);
+if (TEntry != TFeatures.end() && TEntry->second != EnabledForFunc) {
+  F.replaceAllUsesWith(llvm::ConstantPointerNull::get(F.getType()));
+  F.eraseFromParent();
+  return true;
+}
+  }
+  return false;
+}
+
 void CodeGenModule::getTrivialDefaultFunctionAttributes(
 StringRef Name, bool HasOptnone, bool AttrOnCallSite,
 llvm::AttrBuilder &FuncAttrs) {
diff --git a/clang/lib/CodeGen/CGCall.h b/clang/lib/CodeGen/CGCall.h
index aee86a3242fd3f4..bca664479fff13d 100644
--- a/clang/lib/CodeGen/CGCall.h
+++ b/clang/lib/CodeGen/CGCall.h
@@ -375,6 +375,11 @@ class ReturnValueSlot {
   bool isExternallyDestructed() const { return IsExternallyDestructed; }
 };
 
+/// If \p F "target-features" are incompatible with the \p TargetOpts features,
+/// it is correct to drop the function. \return true if \p F is dropped
+bool dropFunctionWithIncompatibleAttributes(llvm::Function &F,
+const TargetOptions &TargetOpts);
+
 /// Adds attributes to \p F according to our \p CodeGenOpts and \p LangOpts, as
 /// though we had emitted it ourselves. We remove any attributes on F that
 /// conflict with the attributes we add here.
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index a3b72381d73fc54..6f8e545a3a50816 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -267,11 +267,13 @@ namespace clang {
   for (auto &LM : LinkModules) {
 assert(LM.Module && "LinkModule does not actually have a module");
 if (LM.PropagateAttrs)
-  for (Function &F : *LM.Module) {
+  for (Function &F : llvm::make_early_inc_range(*LM.Module)) {
 // Skip intrinsics. Keep consistent with how intrinsics are created
 // in LLVM IR.
 if (F.isIntrinsic())
   continue;
+if (CodeGen::dropFunctionWithIncompatibleAttributes(F, TargetOpts))
+  continue;
 CodeGen::mergeDefaultFunctionDefinitionAttributes(
 F, CodeGenOpts, LangOpts, TargetOpts, LM.Internalize);
   }
diff --git a/clang/test/CodeGen/link-builtin-bitcode.c 
b/clang/test/CodeGen/link-builtin-bitcode.c
index fe60a9746f1c85f..2fcf8c6c4a64dfb 100644
--- a/clang/test/CodeGen/link-builtin-bitcode.c
+++ b/clang/test/CodeGen/link-builtin-bitcode.c
@@ -40,10 +40,8 @@ int bar() { return no_attr() + attr_in_target() + 
attr_not_in_target() + attr_in
 // CHECK-LABEL: define internal i32 @attr_not_in_target
 // CHECK-SAME: () #[[ATTR_EXTEND:[0-9]+]] {
 
-// CHECK-LABEL: @attr_incompatible
-// CHECK-SAME: () #[[ATTR_INCOMPATIBLE:[0-9]+]] {
+// CHECK-NOT: @attr_incompatible
 
 // CHECK: attributes #[[ATTR_BAR]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 }
 // CHECK: attributes #[[ATTR_COMPATIBLE]] = { convergent noinline nounwind 
optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-inst

[clang] [Clang] Drop functions with incompatible target-features when using mlink-builtin-bitcode (PR #65737)

2023-09-08 Thread Juan Manuel Martinez Caamaño via cfe-commits

https://github.com/jmmartinez review_requested 
https://github.com/llvm/llvm-project/pull/65737
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Drop functions with incompatible target-features when using mlink-builtin-bitcode (PR #65737)

2023-09-08 Thread Juan Manuel Martinez Caamaño via cfe-commits

https://github.com/jmmartinez labeled 
https://github.com/llvm/llvm-project/pull/65737
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Drop functions with incompatible target-features when using mlink-builtin-bitcode (PR #65737)

2023-09-08 Thread Juan Manuel Martinez Caamaño via cfe-commits

https://github.com/jmmartinez review_requested 
https://github.com/llvm/llvm-project/pull/65737
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Drop functions with incompatible target-features when using mlink-builtin-bitcode (PR #65737)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65737
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D159257: [Clang] Drop functions with incompatible target-features when using mlink-builtin-bitcode

2023-09-08 Thread Juan Manuel Martinez Caamaño via Phabricator via cfe-commits
jmmartinez abandoned this revision.
jmmartinez added a comment.

Moved into https://github.com/llvm/llvm-project/pull/65737


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159257

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


[clang] [analyzer] Reduce constraint on modulo with small concrete range (PR #65448)

2023-09-08 Thread Ding Fei via cfe-commits

https://github.com/danix800 review_requested 
https://github.com/llvm/llvm-project/pull/65448
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Reduce constraint on modulo with small concrete range (PR #65448)

2023-09-08 Thread Ding Fei via cfe-commits

https://github.com/danix800 ready_for_review 
https://github.com/llvm/llvm-project/pull/65448
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Improve `_Alignas` on a `struct` declaration diagnostic (PR #65638)

2023-09-08 Thread via cfe-commits

cor3ntin wrote:

There is similar effort on Phab, we should pick one of them 
https://reviews.llvm.org/D141177

https://github.com/llvm/llvm-project/pull/65638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Reduce constraint on modulo with small concrete range (PR #65448)

2023-09-08 Thread Balazs Benics via cfe-commits

https://github.com/steakhal commented:

In 1 minute it makes sense.
Will need a thorough evaluation.
I'll review this properly once I'm back from vacation.

https://github.com/llvm/llvm-project/pull/65448
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D159138: [clang][Sema] Fix format size estimator's handling of %o, %x, %X with alternative form

2023-09-08 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment.

Ping


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

https://reviews.llvm.org/D159138

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


[clang] [mlir][LLVM] Model side effects of volatile and atomic load-store (PR #65730)

2023-09-08 Thread Markus Böck via cfe-commits

https://github.com/zero9178 updated 
https://github.com/llvm/llvm-project/pull/65730:

From d32d6c5faca4141120482b7346c75f6656a29299 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Markus=20B=C3=B6ck?= 
Date: Fri, 8 Sep 2023 11:16:22 +0200
Subject: [PATCH 1/2] [mlir][LLVM] Model side effects of volatile and atomic
 load-store

According to the LLVM language reference, both volatile memory operations and 
atomic operations (except unordered) do not simply read memory but also perform 
write operations on arbitrary memory[0][1].

In the case of volatile memory operations, this is the case due to the read 
possibly having target specific properties. A common real-world situation where 
this happens is reading memory mapped registers on an MCU for example. Atomic 
operations are more special. They form a kind of memory barrier which from the 
perspective of the optimizer/lang-ref makes writes from other threads visible 
in the current thread. Any kind of synchronization can therefore conservatively 
be modeled as a write-effect.

This PR therefore adjusts the side effects of `llvm.load` and `llvm.store` to 
add unknown global read and write effects if they are either atomic or volatile.

Regarding testing: I am not sure how to best test this change for `llvm.store` 
and the "globalness" of the effect that isn't just a unit test checking that 
the output matches exactly. For the time being, I added a test making sure that 
`llvm.load` does not get DCEd in aforementioned cases.

Related logic in LLVM proper:
https://github.com/llvm/llvm-project/blob/3398744a6106c83993611bd3c5e79ec6b94417dc/llvm/lib/IR/Instruction.cpp#L638-L676

https://github.com/llvm/llvm-project/blob/3398744a6106c83993611bd3c5e79ec6b94417dc/llvm/include/llvm/IR/Instructions.h#L258-L262

[0] https://llvm.org/docs/LangRef.html#volatile-memory-accesses
[1] https://llvm.org/docs/Atomics.html#monotonic
---
 mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td | 10 ++
 mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp  | 22 +
 mlir/test/Dialect/LLVMIR/canonicalize.mlir  | 17 
 3 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td 
b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index 7ceec72144eb52c..e9ed7f1186ee58a 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -326,9 +326,10 @@ def LLVM_GEPOp : LLVM_Op<"getelementptr", [Pure,
 }
 
 def LLVM_LoadOp : LLVM_MemAccessOpBase<"load",
-[DeclareOpInterfaceMethods,
+[DeclareOpInterfaceMethods,
+ DeclareOpInterfaceMethods,
  DeclareOpInterfaceMethods]> {
-  dag args = (ins Arg, "", [MemRead]>:$addr,
+  dag args = (ins LLVM_PointerTo:$addr,
   OptionalAttr:$alignment,
   UnitAttr:$volatile_,
   UnitAttr:$nontemporal,
@@ -399,10 +400,11 @@ def LLVM_LoadOp : LLVM_MemAccessOpBase<"load",
 }
 
 def LLVM_StoreOp : LLVM_MemAccessOpBase<"store",
-[DeclareOpInterfaceMethods,
+[DeclareOpInterfaceMethods,
+ DeclareOpInterfaceMethods,
  DeclareOpInterfaceMethods]> {
   dag args = (ins LLVM_LoadableType:$value,
-  Arg,"",[MemWrite]>:$addr,
+  LLVM_PointerTo:$addr,
   OptionalAttr:$alignment,
   UnitAttr:$volatile_,
   UnitAttr:$nontemporal,
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp 
b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index ae01f7c4621522b..a4e5c25f3394e67 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -812,6 +812,17 @@ Type GEPOp::getResultPtrElementType() {
 // LoadOp
 
//===--===//
 
+void LoadOp::getEffects(
+SmallVectorImpl>
+&effects) {
+  effects.emplace_back(MemoryEffects::Read::get(), getAddr());
+  if (getVolatile_() || (getOrdering() != AtomicOrdering::not_atomic &&
+ getOrdering() != AtomicOrdering::unordered)) {
+effects.emplace_back(MemoryEffects::Write::get());
+effects.emplace_back(MemoryEffects::Read::get());
+  }
+}
+
 /// Returns true if the given type is supported by atomic operations. All
 /// integer and float types with limited bit width are supported. Additionally,
 /// depending on the operation pointers may be supported as well.
@@ -932,6 +943,17 @@ static void printLoadType(OpAsmPrinter &printer, Operation 
*op, Type type,
 // StoreOp
 
//===--===//
 
+void StoreOp::getEffects(
+SmallVectorImpl>
+&effects) {
+  effects.emplace_back(MemoryEffects::Write::get(), getAddr());
+  if (getVolatile_() || (getOrdering() != AtomicOrdering::not_atomic &&
+ getOrdering() != AtomicOrdering::unordered)) {
+effects.emplace_back(MemoryEffects::Write::get());
+effects.emplace_back(MemoryEffects::Read::get());
+  }
+}
+
 LogicalResult StoreOp::verif

[clang] [mlir][LLVM] Model side effects of volatile and atomic load-store (PR #65730)

2023-09-08 Thread Markus Böck via cfe-commits

https://github.com/zero9178 resolved 
https://github.com/llvm/llvm-project/pull/65730
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [mlir][LLVM] Model side effects of volatile and atomic load-store (PR #65730)

2023-09-08 Thread Markus Böck via cfe-commits

https://github.com/zero9178 resolved 
https://github.com/llvm/llvm-project/pull/65730
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D159115: [clang-repl] Adapt to the recent dylib-related changes in ORC.

2023-09-08 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In D159115#4640154 , @tuliom wrote:

> This new test does not work on ppc64le.

I've tested right now (as of 3398744a6106c83993611bd3c5e79ec6b94417dc 
) and all 
clang tests passed for me on Gentoo/ppc64le.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159115

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


[clang] [clang][dataflow] Don't crash when BlockToState is called from unreachable path (PR #65732)

2023-09-08 Thread Yitzhak Mandelbaum via cfe-commits

https://github.com/ymand edited https://github.com/llvm/llvm-project/pull/65732
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Don't crash when BlockToState is called from unreachable path (PR #65732)

2023-09-08 Thread Yitzhak Mandelbaum via cfe-commits

https://github.com/ymand approved this pull request.


https://github.com/llvm/llvm-project/pull/65732
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Don't crash when BlockToState is called from unreachable path (PR #65732)

2023-09-08 Thread Yitzhak Mandelbaum via cfe-commits


@@ -43,7 +43,20 @@ const Environment *StmtToEnvMap::getEnvironment(const Stmt 
&S) const {
   if (!CFCtx.isBlockReachable(*BlockIt->getSecond()))
 return nullptr;
   const auto &State = BlockToState[BlockIt->getSecond()->getBlockID()];
-  assert(State);
+  if (!(State)) {
+LLVM_DEBUG({
+  // State can be null when this block is unreachable from the block that
+  // called this method.
+  bool hasUnreachableEdgeFromPred = false;
+  for (auto B : BlockIt->getSecond()->preds())
+if (!B) {
+  hasUnreachableEdgeFromPred = true;
+  break;
+}
+  assert(hasUnreachableEdgeFromPred);

ymand wrote:

I agree on leaving it debug only (or removing it entirely).

https://github.com/llvm/llvm-project/pull/65732
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Better bitfield access units (PR #65742)

2023-09-08 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan review_requested 
https://github.com/llvm/llvm-project/pull/65742
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Better bitfield access units (PR #65742)

2023-09-08 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan review_requested 
https://github.com/llvm/llvm-project/pull/65742
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Better bitfield access units (PR #65742)

2023-09-08 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan review_requested 
https://github.com/llvm/llvm-project/pull/65742
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Better bitfield access units (PR #65742)

2023-09-08 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan review_requested 
https://github.com/llvm/llvm-project/pull/65742
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Better bitfield access units (PR #65742)

2023-09-08 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan review_requested 
https://github.com/llvm/llvm-project/pull/65742
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Better bitfield access units (PR #65742)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65742
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Better bitfield access units (PR #65742)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65742
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Better bitfield access units (PR #65742)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65742
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Better bitfield access units (PR #65742)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65742
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Better bitfield access units (PR #65742)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65742
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AST] Only dump desugared type when visibly different (PR #65214)

2023-09-08 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

Yep, I definitely I agree this is a good change, thanks for working on it!
I thought about doing the same at the time, but I just didn't have the 
bandwidth for yet another patch with a lot of test churn :)

https://github.com/llvm/llvm-project/pull/65214
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [mlir][LLVM] Model side effects of volatile and atomic load-store (PR #65730)

2023-09-08 Thread Markus Böck via cfe-commits

https://github.com/zero9178 closed 
https://github.com/llvm/llvm-project/pull/65730
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152752: [MS] Fix passing aligned records by value in some cases

2023-09-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D152752#4641396 , @rnk wrote:

> Following up, the vararg fix is here: 
> https://github.com/llvm/llvm-project/pull/65692

Thank you for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152752

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


[clang] [MS] Follow up fix to pass aligned args to variadic x86_32 functions (PR #65692)

2023-09-08 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman review_requested 
https://github.com/llvm/llvm-project/pull/65692
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [MS] Follow up fix to pass aligned args to variadic x86_32 functions (PR #65692)

2023-09-08 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman review_requested 
https://github.com/llvm/llvm-project/pull/65692
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [MS] Follow up fix to pass aligned args to variadic x86_32 functions (PR #65692)

2023-09-08 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman commented:

I believe these changes are correct and they look to be reasonable, but adding 
the codegen code owners for final approval.

https://github.com/llvm/llvm-project/pull/65692
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Merge `RecordValue`s with different locations correctly. (PR #65319)

2023-09-08 Thread Kinuko Yasuda via cfe-commits


@@ -121,18 +121,18 @@ static Value *mergeDistinctValues(QualType Type, Value 
&Val1,
 
   Value *MergedVal = nullptr;
   if (auto *RecordVal1 = dyn_cast(&Val1)) {
-[[maybe_unused]] auto *RecordVal2 = cast(&Val2);
-
-// Values to be merged are always associated with the same location in
-// `LocToVal`. The location stored in `RecordVal` should therefore also
-// be the same.
-assert(&RecordVal1->getLoc() == &RecordVal2->getLoc());
-
-// `RecordVal1` and `RecordVal2` may have different properties associated
-// with them. Create a new `RecordValue` without any properties so that we
-// soundly approximate both values. If a particular analysis needs to merge
-// properties, it should do so in `DataflowAnalysis::merge()`.
-MergedVal = &MergedEnv.create(RecordVal1->getLoc());
+auto *RecordVal2 = cast(&Val2);
+
+if (&RecordVal1->getLoc() == &RecordVal2->getLoc())
+  // `RecordVal1` and `RecordVal2` may have different properties associated
+  // with them. Create a new `RecordValue` without any properties so that 
we
+  // soundly approximate both values. If a particular analysis needs to
+  // merge properties, it should do so in `DataflowAnalysis::merge()`.
+  MergedVal = &MergedEnv.create(RecordVal1->getLoc());
+else
+  // If the locations for the two records are different, need to create a
+  // completely new value.

kinu wrote:

I think you're right, I wanted to see if some comment may help but it's a bit 
irrelevant here. Also given that it's going away I'm good with it, thanks!

https://github.com/llvm/llvm-project/pull/65319
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Merge `RecordValue`s with different locations correctly. (PR #65319)

2023-09-08 Thread Kinuko Yasuda via cfe-commits


@@ -121,18 +121,18 @@ static Value *mergeDistinctValues(QualType Type, Value 
&Val1,
 
   Value *MergedVal = nullptr;
   if (auto *RecordVal1 = dyn_cast(&Val1)) {
-[[maybe_unused]] auto *RecordVal2 = cast(&Val2);
-
-// Values to be merged are always associated with the same location in
-// `LocToVal`. The location stored in `RecordVal` should therefore also
-// be the same.
-assert(&RecordVal1->getLoc() == &RecordVal2->getLoc());
-
-// `RecordVal1` and `RecordVal2` may have different properties associated
-// with them. Create a new `RecordValue` without any properties so that we
-// soundly approximate both values. If a particular analysis needs to merge
-// properties, it should do so in `DataflowAnalysis::merge()`.
-MergedVal = &MergedEnv.create(RecordVal1->getLoc());
+auto *RecordVal2 = cast(&Val2);
+
+if (&RecordVal1->getLoc() == &RecordVal2->getLoc())
+  // `RecordVal1` and `RecordVal2` may have different properties associated
+  // with them. Create a new `RecordValue` without any properties so that 
we
+  // soundly approximate both values. If a particular analysis needs to
+  // merge properties, it should do so in `DataflowAnalysis::merge()`.

kinu wrote:

SGTM. Yeah adding 'with the same location, ...' may clarify the situation bit, 
either works for me.

https://github.com/llvm/llvm-project/pull/65319
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [MS] Follow up fix to pass aligned args to variadic x86_32 functions (PR #65692)

2023-09-08 Thread Simon Pilgrim via cfe-commits

https://github.com/RKSimon approved this pull request.

LGTM if the clang team are happy with us not raising the alignment error

https://github.com/llvm/llvm-project/pull/65692
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Better bitfield access units (PR #65742)

2023-09-08 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan converted_to_draft 
https://github.com/llvm/llvm-project/pull/65742
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [MS] Follow up fix to pass aligned args to variadic x86_32 functions (PR #65692)

2023-09-08 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> LGTM if the clang team are happy with us not raising the alignment error

Yup, that's what got us on this path in the first place. Our downstream at 
Intel started getting errors on code that was previously working, this restores 
the previous behavior in that case.

https://github.com/llvm/llvm-project/pull/65692
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [MS] Follow up fix to pass aligned args to variadic x86_32 functions (PR #65692)

2023-09-08 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman approved this pull request.

Approving, but do wait a bit before landing in case a codegen code owner has 
comments.

https://github.com/llvm/llvm-project/pull/65692
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147844: [clang][Sema]Print diagnostic warning about precedence when integer expression is used without parentheses in an conditional operator expression

2023-09-08 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Ping. What's missing to land this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

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


[clang] [sema] Improve -Wsign-compare (PR #65684)

2023-09-08 Thread via cfe-commits

apple-fcloutier wrote:

IMO, the `< 0` check is fundamentally the right in-place fix to offer, although 
I went back and forth on attaching it to the warning or the note. It's a little 
disappointing that we still need the explicit cast to silence the warning, 
however.

https://github.com/llvm/llvm-project/pull/65684
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [sema] Improve -Wsign-compare (PR #65684)

2023-09-08 Thread via cfe-commits

cor3ntin wrote:

Not emitting a warning at all when there is an explicit comparison to `0` is an 
interesting idea, maybe that would be worth exploring? I wonder how complicated 
that would be

https://github.com/llvm/llvm-project/pull/65684
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-08 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [sema] Improve -Wsign-compare (PR #65684)

2023-09-08 Thread via cfe-commits

apple-fcloutier wrote:

There's two main reasons I didn't go that route. First, we don't have great 
ways to check that two expressions refer to the same object (that I'm aware 
of). We can keep track of DeclRefExprs or maybe MemberExprs alone, but that 
creates a weird cliff of fixit availability. Second, 
`AnalyzeImplicitConversions` doesn't do recursive descent, so keeping a stack 
of known facts about inspected values is a good deal more complicated.

If somebody tells me how to do 1, I can probably manage 2 on my own.

https://github.com/llvm/llvm-project/pull/65684
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143524: Make the -Wunused-template default.

2023-09-08 Thread Louis Dionne via Phabricator via cfe-commits
ldionne removed reviewers: ldionne, libc++.
ldionne added a comment.
Herald added a subscriber: wangpc.

[Github PR transition cleanup]

Dropping libc++ since this shouldn't affect libc++ since D144667 
.


Repository:
  rC Clang

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

https://reviews.llvm.org/D143524

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


[PATCH] D154869: [Flang] [FlangRT] Introduce FlangRT project as solution to Flang's runtime LLVM integration

2023-09-08 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: runtimes/CMakeLists.txt:20
 
+set(RUNTIMES_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+

This shouldn't be necessary, CMake already creates a `Project_SOURCE_DIR` 
variable for each declared `project()` IIRC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154869

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


[clang-tools-extra] [AArch64][CodeGen] Fix wrong operand order when creating vcmla intrinsic (PR #65278)

2023-09-08 Thread via cfe-commits

https://github.com/daisy202309 updated 
https://github.com/llvm/llvm-project/pull/65278:

>From 9b68bfc6078a400247a55d181a6bc8ff73819cd4 Mon Sep 17 00:00:00 2001
From: lizhijin 
Date: Tue, 5 Sep 2023 00:56:23 +0800
Subject: [PATCH] [AArch64][CodeGen] Fix wrong operand order when creating
 vcmla intrinsic

---
 .../Target/AArch64/AArch64ISelLowering.cpp|  2 +-
 ...-deinterleaving-add-mull-fixed-contract.ll | 48 
 ...plex-deinterleaving-add-mull-fixed-fast.ll | 56 +--
 .../AArch64/complex-deinterleaving-f16-mul.ll | 32 +--
 .../AArch64/complex-deinterleaving-f32-mul.ll | 32 +--
 .../AArch64/complex-deinterleaving-f64-mul.ll | 28 +-
 .../complex-deinterleaving-mixed-cases.ll | 56 +--
 .../complex-deinterleaving-multiuses.ll   | 46 +++
 .../complex-deinterleaving-reductions.ll  | 32 +--
 .../AArch64/complex-deinterleaving-splat.ll   | 32 +--
 .../complex-deinterleaving-uniform-cases.ll   | 16 +++---
 11 files changed, 190 insertions(+), 190 deletions(-)

diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 16fe5bc2786318c..e37e64c4ca16925 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -26123,7 +26123,7 @@ Value 
*AArch64TargetLowering::createComplexDeinterleavingIR(
 
 
 return B.CreateIntrinsic(IdMap[(int)Rotation], Ty,
- {Accumulator, InputB, InputA});
+ {Accumulator, InputA, InputB});
   }
 
   if (OperationType == ComplexDeinterleavingOperation::CAdd) {
diff --git 
a/llvm/test/CodeGen/AArch64/complex-deinterleaving-add-mull-fixed-contract.ll 
b/llvm/test/CodeGen/AArch64/complex-deinterleaving-add-mull-fixed-contract.ll
index c684a18a7e0773c..09672d1be216136 100644
--- 
a/llvm/test/CodeGen/AArch64/complex-deinterleaving-add-mull-fixed-contract.ll
+++ 
b/llvm/test/CodeGen/AArch64/complex-deinterleaving-add-mull-fixed-contract.ll
@@ -48,14 +48,14 @@ define <4 x double> @mul_add_mull(<4 x double> %a, <4 x 
double> %b, <4 x double>
 ; CHECK-NEXT:movi v17.2d, #
 ; CHECK-NEXT:movi v18.2d, #
 ; CHECK-NEXT:movi v19.2d, #
-; CHECK-NEXT:fcmla v16.2d, v0.2d, v2.2d, #0
-; CHECK-NEXT:fcmla v18.2d, v1.2d, v3.2d, #0
-; CHECK-NEXT:fcmla v17.2d, v5.2d, v7.2d, #0
-; CHECK-NEXT:fcmla v19.2d, v4.2d, v6.2d, #0
-; CHECK-NEXT:fcmla v16.2d, v0.2d, v2.2d, #90
-; CHECK-NEXT:fcmla v18.2d, v1.2d, v3.2d, #90
-; CHECK-NEXT:fcmla v17.2d, v5.2d, v7.2d, #90
-; CHECK-NEXT:fcmla v19.2d, v4.2d, v6.2d, #90
+; CHECK-NEXT:fcmla v16.2d, v2.2d, v0.2d, #0
+; CHECK-NEXT:fcmla v18.2d, v3.2d, v1.2d, #0
+; CHECK-NEXT:fcmla v17.2d, v7.2d, v5.2d, #0
+; CHECK-NEXT:fcmla v19.2d, v6.2d, v4.2d, #0
+; CHECK-NEXT:fcmla v16.2d, v2.2d, v0.2d, #90
+; CHECK-NEXT:fcmla v18.2d, v3.2d, v1.2d, #90
+; CHECK-NEXT:fcmla v17.2d, v7.2d, v5.2d, #90
+; CHECK-NEXT:fcmla v19.2d, v6.2d, v4.2d, #90
 ; CHECK-NEXT:fadd v1.2d, v18.2d, v17.2d
 ; CHECK-NEXT:fadd v0.2d, v16.2d, v19.2d
 ; CHECK-NEXT:ret
@@ -94,14 +94,14 @@ define <4 x double> @mul_sub_mull(<4 x double> %a, <4 x 
double> %b, <4 x double>
 ; CHECK-NEXT:movi v17.2d, #
 ; CHECK-NEXT:movi v18.2d, #
 ; CHECK-NEXT:movi v19.2d, #
-; CHECK-NEXT:fcmla v16.2d, v0.2d, v2.2d, #0
-; CHECK-NEXT:fcmla v18.2d, v1.2d, v3.2d, #0
-; CHECK-NEXT:fcmla v17.2d, v5.2d, v7.2d, #0
-; CHECK-NEXT:fcmla v19.2d, v4.2d, v6.2d, #0
-; CHECK-NEXT:fcmla v16.2d, v0.2d, v2.2d, #90
-; CHECK-NEXT:fcmla v18.2d, v1.2d, v3.2d, #90
-; CHECK-NEXT:fcmla v17.2d, v5.2d, v7.2d, #90
-; CHECK-NEXT:fcmla v19.2d, v4.2d, v6.2d, #90
+; CHECK-NEXT:fcmla v16.2d, v2.2d, v0.2d, #0
+; CHECK-NEXT:fcmla v18.2d, v3.2d, v1.2d, #0
+; CHECK-NEXT:fcmla v17.2d, v7.2d, v5.2d, #0
+; CHECK-NEXT:fcmla v19.2d, v6.2d, v4.2d, #0
+; CHECK-NEXT:fcmla v16.2d, v2.2d, v0.2d, #90
+; CHECK-NEXT:fcmla v18.2d, v3.2d, v1.2d, #90
+; CHECK-NEXT:fcmla v17.2d, v7.2d, v5.2d, #90
+; CHECK-NEXT:fcmla v19.2d, v6.2d, v4.2d, #90
 ; CHECK-NEXT:fsub v1.2d, v18.2d, v17.2d
 ; CHECK-NEXT:fsub v0.2d, v16.2d, v19.2d
 ; CHECK-NEXT:ret
@@ -140,14 +140,14 @@ define <4 x double> @mul_conj_mull(<4 x double> %a, <4 x 
double> %b, <4 x double
 ; CHECK-NEXT:movi v17.2d, #
 ; CHECK-NEXT:movi v18.2d, #
 ; CHECK-NEXT:movi v19.2d, #
-; CHECK-NEXT:fcmla v16.2d, v0.2d, v2.2d, #0
-; CHECK-NEXT:fcmla v18.2d, v1.2d, v3.2d, #0
-; CHECK-NEXT:fcmla v17.2d, v7.2d, v5.2d, #0
-; CHECK-NEXT:fcmla v19.2d, v6.2d, v4.2d, #0
-; CHECK-NEXT:fcmla v16.2d, v0.2d, v2.2d, #90
-; CHECK-NEXT:fcmla v18.2d, v1.2d, v3.2d, #90
-; CHECK-NEXT:fcmla v17.2d, v7.2d, v5.2d, #270
-; CHECK-NEXT:fcmla v

[clang] [clang][dataflow] Don't crash when BlockToState is called from unreachable path (PR #65732)

2023-09-08 Thread Kinuko Yasuda via cfe-commits

https://github.com/kinu updated https://github.com/llvm/llvm-project/pull/65732:

>From bc119f4bb478431bf85cda47dbc2a25faa59e85f Mon Sep 17 00:00:00 2001
From: Kinuko Yasuda 
Date: Fri, 8 Sep 2023 09:03:35 +
Subject: [PATCH 1/2] [clang][dataflow] Don't crash when BlockToState doesn't
 have unreached block

When we call `getEnvironment`, `BlockToState[BlockId]` for the block can return
null even if CFCtx.isBlockReachable(B) returns true if it is called from a
particular block that is marked unreachable to the block.
(An example is in `EvaluateBlockWithUnreachablePreds` in TransferTest.cpp)
---
 clang/lib/Analysis/FlowSensitive/Transfer.cpp | 15 +-
 .../Analysis/FlowSensitive/TransferTest.cpp   | 20 +++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp 
b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index 67d8be392ae6053..b46c947c691b9b9 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -43,7 +43,20 @@ const Environment *StmtToEnvMap::getEnvironment(const Stmt 
&S) const {
   if (!CFCtx.isBlockReachable(*BlockIt->getSecond()))
 return nullptr;
   const auto &State = BlockToState[BlockIt->getSecond()->getBlockID()];
-  assert(State);
+  if (!(State)) {
+LLVM_DEBUG({
+  // State can be null when this block is unreachable from the block that
+  // called this method.
+  bool hasUnreachableEdgeFromPred = false;
+  for (auto B : BlockIt->getSecond()->preds())
+if (!B) {
+  hasUnreachableEdgeFromPred = true;
+  break;
+}
+  assert(hasUnreachableEdgeFromPred);
+});
+return nullptr;
+  }
   return &State->Env;
 }
 
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 177970ac52a67eb..1fa800044c288d4 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -5853,4 +5853,24 @@ TEST(TransferTest, AnonymousStructWithReferenceField) {
   });
 }
 
+TEST(TransferTest, EvaluateBlockWithUnreachablePreds) {
+  // This is a crash repro.
+  // `false` block may not have been processed when we try to evalute the `||`
+  // after visiting `true`, because it is not necessary (and therefore the edge
+  // is marked unreachable). Trying to get the analysis state via
+  // `getEnvironment` for the subexpression should still not crash.
+  std::string Code = R"(
+int cast(int i) {
+  if ((i < 0 && true) || false) {
+return 0;
+  }
+  return 0;
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {});
+}
+
 } // namespace

>From 144cdf860b19f867e8c61c9478713adbe719967b Mon Sep 17 00:00:00 2001
From: Kinuko Yasuda 
Date: Fri, 8 Sep 2023 13:11:49 +
Subject: [PATCH 2/2] comment change to see if it triggers build

---
 clang/unittests/Analysis/FlowSensitive/TransferTest.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 1fa800044c288d4..ec07555d7f33b3b 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -5858,7 +5858,7 @@ TEST(TransferTest, EvaluateBlockWithUnreachablePreds) {
   // `false` block may not have been processed when we try to evalute the `||`
   // after visiting `true`, because it is not necessary (and therefore the edge
   // is marked unreachable). Trying to get the analysis state via
-  // `getEnvironment` for the subexpression should still not crash.
+  // `getEnvironment` for the subexpression still should not crash.
   std::string Code = R"(
 int cast(int i) {
   if ((i < 0 && true) || false) {

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


[PATCH] D159115: [clang-repl] Adapt to the recent dylib-related changes in ORC.

2023-09-08 Thread Tulio Magno Quites Machado Filho via Phabricator via cfe-commits
tuliom added a comment.

In D159115#4640388 , @mgorny wrote:

> I'm sorry, by "new" you mean the version with `uintptr_t` or the original as 
> well?

Both with `uintptr_t` as well as `unsigned long long`.

In D159115#4641721 , @mgorny wrote:

> I've tested right now (as of 3398744a6106c83993611bd3c5e79ec6b94417dc 
> ) and 
> all clang tests passed for me on Gentoo/ppc64le.

Did Gentoo switch the default long double to IEEE 128-bit floating point?
If not, that could explain why this new code is broken on ppc64le.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159115

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


[PATCH] D159206: [Clang] Propagate target-features if compatible when using mlink-builtin-bitcode

2023-09-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2005
+static void
+overrideFunctionFeaturesWithTargetFeatures(llvm::AttrBuilder &FuncAttr,
+   const llvm::Function &F,

can you add a comment about how the original target feature attributes of the 
function that is incompatible or missing in the target feature are handled.



Comment at: clang/test/CodeGen/link-builtin-bitcode.c:46
+
+// CHECK: attributes #[[ATTR_BAR]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 }
+// CHECK: attributes #[[ATTR_COMPATIBLE]] = { convergent noinline nounwind 
optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-cpu"="gfx90a" 
"target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gws,+image-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
 }

The irrelevant function attributes should not be checked


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159206

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


[clang] [RISCV] Support predefined marcro __riscv_misaligned_{fast,avoid}. (PR #65756)

2023-09-08 Thread Yeting Kuo via cfe-commits

https://github.com/yetingk review_requested 
https://github.com/llvm/llvm-project/pull/65756
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   >