Re: [clang] c411c1b - Fix missing qualifier in template type diffing

2021-08-16 Thread David Blaikie via cfe-commits
Perhaps the test case could be stripped down a bit?

template 
class Array {};

template 
class S {};

template 
Array Make();

void Call() {
Array> v = Make>();
}

Seems to exhibit the same issue, by the looks of it.

On Mon, Aug 16, 2021 at 6:38 PM via cfe-commits 
wrote:

>
> Author: Weverything
> Date: 2021-08-16T18:34:18-07:00
> New Revision: c411c1bd7f7d3550d24333f80980c0be6481d34a
>
> URL:
> https://github.com/llvm/llvm-project/commit/c411c1bd7f7d3550d24333f80980c0be6481d34a
> DIFF:
> https://github.com/llvm/llvm-project/commit/c411c1bd7f7d3550d24333f80980c0be6481d34a.diff
>
> LOG: Fix missing qualifier in template type diffing
>
> Handle SubstTemplateTypeParmType so qualifiers do not get dropped from
> the diagnostic message.
>
> Added:
>
>
> Modified:
> clang/lib/AST/ASTDiagnostic.cpp
> clang/test/Misc/diag-template-diffing.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/AST/ASTDiagnostic.cpp
> b/clang/lib/AST/ASTDiagnostic.cpp
> index dc22481d0a84c..7e435e8b35b80 100644
> --- a/clang/lib/AST/ASTDiagnostic.cpp
> +++ b/clang/lib/AST/ASTDiagnostic.cpp
> @@ -1088,6 +1088,9 @@ class TemplateDiff {
>  Ty->getAs())
>return TST;
>
> +if (const auto* SubstType = Ty->getAs())
> +  Ty = SubstType->getReplacementType();
> +
>  const RecordType *RT = Ty->getAs();
>
>  if (!RT)
>
> diff  --git a/clang/test/Misc/diag-template-
> diff ing.cpp b/clang/test/Misc/diag-template-
> diff ing.cpp
> index cc1cc9ca70679..6bf6e2de4277c 100644
> --- a/clang/test/Misc/diag-template-
> diff ing.cpp
> +++ b/clang/test/Misc/diag-template-
> diff ing.cpp
> @@ -1488,6 +1488,43 @@ void run(A_reg reg, A_ptr ptr,
> A_ref ref) {
>  }
>  }
>
> +namespace SubstTemplateTypeParmType {
> +template 
> +class Array {
> +};
> +
> +template 
> +class S{};
> +
> +template 
> +Array Make(T ()[num]);
> +
> +void Run(int, Array>) {}
> +
> +Array> Make();
> +void Call() {
> +  const S s1[5];
> +  S s2[5];
> +
> +  Run(0, Make(s1));   // Error
> +  Run(0, Make(s2));   // Okay
> +}
> +
> +// CHECK-ELIDE-NOTREE: no matching function for call to 'Run'
> +// CHECK-ELIDE-NOTREE: no known conversion from 'Array>' to
> 'Array>' for 2nd argument
> +// CHECK-NOELIDE-NOTREE: no matching function for call to 'Run'
> +// CHECK-NOELIDE-NOTREE: no known conversion from 'Array>'
> to 'Array>' for 2nd argument
> +// CHECK-ELIDE-TREE: no matching function for call to 'Run'
> +// CHECK-ELIDE-TREE: no known conversion from argument type to parameter
> type for 2nd argument
> +// CHECK-ELIDE-TREE:   Array<
> +// CHECK-ELIDE-TREE: [const != (no qualifiers)] S<...>>
> +// CHECK-NOELIDE-TREE: no matching function for call to 'Run'
> +// CHECK-NOELIDE-TREE: no known conversion from argument type to
> parameter type for 2nd argument
> +// CHECK-NOELIDE-TREE:   Array<
> +// CHECK-NOELIDE-TREE: [const != (no qualifiers)] S<
> +// CHECK-NOELIDE-TREE:   int>>
> +}
> +
>  // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated.
>  // CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated.
>  // CHECK-ELIDE-TREE: {{[0-9]*}} errors generated.
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-08-16 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added subscribers: samitolvanen, pcc.
v.g.vassilev added a comment.

In D96033#2948243 , @leonardchan wrote:

>> @leonardchan, @phosek, I am not aware of such flag. Do you know how much 
>> memory does LTO + clang-repl consume and would it make sense to ping some of 
>> the LTO folks for their advice?
>
> I played around a bit with adding a flag and it turned out to be not as 
> difficult as I thought it would: D108173 . 
> I think making this more of an "opt-in/out" tool like clang-staticanalyzer 
> might be a good idea in general since not all downstream users may want to 
> built all clang tools.

I would rather fix the underlying issue. @samitolvanen, @pcc do you know who 
can help us with debugging excessive memory use when linking clang-repl using 
LTO?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96033

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


[PATCH] D106739: [analyzer] Add option to SATest.py for extra checkers

2021-08-16 Thread Deep Majumder via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG198e6771e24f: [analyzer] Add option to SATest.py for extra 
checkers (authored by RedDocMD).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106739

Files:
  clang/utils/analyzer/SATest.py
  clang/utils/analyzer/SATestBuild.py


Index: clang/utils/analyzer/SATestBuild.py
===
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -213,6 +213,7 @@
 project: ProjectInfo
 override_compiler: bool = False
 extra_analyzer_config: str = ""
+extra_checkers: str = ""
 is_reference_build: bool = False
 strictness: int = 0
 
@@ -233,13 +234,16 @@
 """
 A component aggregating all of the project testing.
 """
+
 def __init__(self, jobs: int, projects: List[ProjectInfo],
  override_compiler: bool, extra_analyzer_config: str,
+ extra_checkers: str,
  regenerate: bool, strictness: bool):
 self.jobs = jobs
 self.projects = projects
 self.override_compiler = override_compiler
 self.extra_analyzer_config = extra_analyzer_config
+self.extra_checkers = extra_checkers
 self.regenerate = regenerate
 self.strictness = strictness
 
@@ -252,6 +256,7 @@
 TestInfo(project,
  self.override_compiler,
  self.extra_analyzer_config,
+ self.extra_checkers,
  self.regenerate, self.strictness))
 if self.jobs <= 1:
 return self._single_threaded_test_all(projects_to_test)
@@ -305,10 +310,12 @@
 """
 A component aggregating testing for one project.
 """
+
 def __init__(self, test_info: TestInfo, silent: bool = False):
 self.project = test_info.project
 self.override_compiler = test_info.override_compiler
 self.extra_analyzer_config = test_info.extra_analyzer_config
+self.extra_checkers = test_info.extra_checkers
 self.is_reference_build = test_info.is_reference_build
 self.strictness = test_info.strictness
 self.silent = silent
@@ -414,6 +421,8 @@
 if 'SA_ADDITIONAL_CHECKERS' in os.environ:
 all_checkers = (all_checkers + ',' +
 os.environ['SA_ADDITIONAL_CHECKERS'])
+if self.extra_checkers != "":
+all_checkers += "," + self.extra_checkers
 
 # Run scan-build from within the patched source directory.
 cwd = os.path.join(directory, PATCHED_SOURCE_DIR_NAME)
Index: clang/utils/analyzer/SATest.py
===
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -42,6 +42,7 @@
   projects,
   args.override_compiler,
   args.extra_analyzer_config,
+  args.extra_checkers,
   args.regenerate,
   args.strictness)
 tests_passed = tester.test_all()
@@ -250,6 +251,10 @@
   dest="extra_analyzer_config", type=str,
   default="",
   help="Arguments passed to to -analyzer-config")
+build_parser.add_argument("--extra-checkers",
+  dest="extra_checkers", type=str,
+  default="",
+  help="Extra checkers to enable")
 build_parser.add_argument("--projects", action="store", default="",
   help="Comma-separated list of projects to test")
 build_parser.add_argument("--max-size", action="store", default=None,


Index: clang/utils/analyzer/SATestBuild.py
===
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -213,6 +213,7 @@
 project: ProjectInfo
 override_compiler: bool = False
 extra_analyzer_config: str = ""
+extra_checkers: str = ""
 is_reference_build: bool = False
 strictness: int = 0
 
@@ -233,13 +234,16 @@
 """
 A component aggregating all of the project testing.
 """
+
 def __init__(self, jobs: int, projects: List[ProjectInfo],
  override_compiler: bool, extra_analyzer_config: str,
+ extra_checkers: str,
  regenerate: bool, strictness: bool):
 self.jobs = jobs
 self.projects = projects
 self.override_compiler = override_compiler
 self.extra_analyzer_config = extra_analyzer_config
+

[clang] 198e677 - [analyzer] Add option to SATest.py for extra checkers

2021-08-16 Thread Deep Majumder via cfe-commits

Author: Deep Majumder
Date: 2021-08-17T10:42:57+05:30
New Revision: 198e6771e24fb5d8d9f3b155445ecc2a4f211004

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

LOG: [analyzer] Add option to SATest.py for extra checkers

This patch adds the flag `extra-checkers` to the sub-command `build` for
passing a comma separated list of additional checkers to include.

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

Added: 


Modified: 
clang/utils/analyzer/SATest.py
clang/utils/analyzer/SATestBuild.py

Removed: 




diff  --git a/clang/utils/analyzer/SATest.py b/clang/utils/analyzer/SATest.py
index 176fe40a2b171..9931870b3b0dd 100755
--- a/clang/utils/analyzer/SATest.py
+++ b/clang/utils/analyzer/SATest.py
@@ -42,6 +42,7 @@ def build(parser, args):
   projects,
   args.override_compiler,
   args.extra_analyzer_config,
+  args.extra_checkers,
   args.regenerate,
   args.strictness)
 tests_passed = tester.test_all()
@@ -250,6 +251,10 @@ def main():
   dest="extra_analyzer_config", type=str,
   default="",
   help="Arguments passed to to -analyzer-config")
+build_parser.add_argument("--extra-checkers",
+  dest="extra_checkers", type=str,
+  default="",
+  help="Extra checkers to enable")
 build_parser.add_argument("--projects", action="store", default="",
   help="Comma-separated list of projects to test")
 build_parser.add_argument("--max-size", action="store", default=None,

diff  --git a/clang/utils/analyzer/SATestBuild.py 
b/clang/utils/analyzer/SATestBuild.py
index ed5c7379bb5b4..1977a8fc2aeff 100644
--- a/clang/utils/analyzer/SATestBuild.py
+++ b/clang/utils/analyzer/SATestBuild.py
@@ -213,6 +213,7 @@ class TestInfo(NamedTuple):
 project: ProjectInfo
 override_compiler: bool = False
 extra_analyzer_config: str = ""
+extra_checkers: str = ""
 is_reference_build: bool = False
 strictness: int = 0
 
@@ -233,13 +234,16 @@ class RegressionTester:
 """
 A component aggregating all of the project testing.
 """
+
 def __init__(self, jobs: int, projects: List[ProjectInfo],
  override_compiler: bool, extra_analyzer_config: str,
+ extra_checkers: str,
  regenerate: bool, strictness: bool):
 self.jobs = jobs
 self.projects = projects
 self.override_compiler = override_compiler
 self.extra_analyzer_config = extra_analyzer_config
+self.extra_checkers = extra_checkers
 self.regenerate = regenerate
 self.strictness = strictness
 
@@ -252,6 +256,7 @@ def test_all(self) -> bool:
 TestInfo(project,
  self.override_compiler,
  self.extra_analyzer_config,
+ self.extra_checkers,
  self.regenerate, self.strictness))
 if self.jobs <= 1:
 return self._single_threaded_test_all(projects_to_test)
@@ -305,10 +310,12 @@ class ProjectTester:
 """
 A component aggregating testing for one project.
 """
+
 def __init__(self, test_info: TestInfo, silent: bool = False):
 self.project = test_info.project
 self.override_compiler = test_info.override_compiler
 self.extra_analyzer_config = test_info.extra_analyzer_config
+self.extra_checkers = test_info.extra_checkers
 self.is_reference_build = test_info.is_reference_build
 self.strictness = test_info.strictness
 self.silent = silent
@@ -414,6 +421,8 @@ def scan_build(self, directory: str, output_dir: str,
 if 'SA_ADDITIONAL_CHECKERS' in os.environ:
 all_checkers = (all_checkers + ',' +
 os.environ['SA_ADDITIONAL_CHECKERS'])
+if self.extra_checkers != "":
+all_checkers += "," + self.extra_checkers
 
 # Run scan-build from within the patched source directory.
 cwd = os.path.join(directory, PATCHED_SOURCE_DIR_NAME)



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


[PATCH] D107684: [NFC][AVR][clang] Add test for D107672

2021-08-16 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

It seems we need not adding this test, since a similiar test is added in 
https://reviews.llvm.org/rGb31199bab4865deef4e778d7a028c8ec64285654


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107684

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


[PATCH] D107682: [AVR][clang] Improve search for avr-libc installation path

2021-08-16 Thread Ben Shi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb31199bab486: [AVR][clang] Improve search for avr-libc 
installation path (authored by benshi001).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107682

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/avr/include/.keep
  clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/avr/lib/libavr.a
  
clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/lib/gcc/avr/10.3.0/libgcc.a
  clang/test/Driver/Inputs/basic_avr_tree_2/usr/avr/include/.keep
  clang/test/Driver/Inputs/basic_avr_tree_2/usr/avr/lib/libavr.a
  clang/test/Driver/avr-toolchain.c


Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -6,12 +6,24 @@
 // CHECK1-SAME: "-resource-dir" "[[RESOURCE:[^"]+]]"
 // CHECK1-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree]]"
 // CHECK1-SAME: "-internal-isystem"
-// CHECK1-SAME: {{^}} "[[SYSROOT]]/usr/lib/avr/include"
+// CHECK1-SAME: {{^}} "[[SYSROOT]]/usr/lib/gcc/avr/5.4.0/../../../avr/include"
 // CHECK1-NOT:  "-L
 // CHECK1:  avr-ld"
 // CHECK1-SAME: "-o" "a.out"
 // CHECK1-SAME: {{^}} "--gc-sections"
 
+// RUN: %clang %s -### -target avr --sysroot 
%S/Inputs/basic_avr_tree_2/opt/local -S 2>&1 | FileCheck --check-prefix=CHECK2 
%s
+// CHECK2: clang{{.*}} "-cc1" "-triple" "avr"
+// CHECK2-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree_2/opt/local]]"
+// CHECK2-SAME: "-internal-isystem"
+// CHECK2-SAME: {{^}} "[[SYSROOT]]/lib/gcc/avr/10.3.0/../../../../avr/include"
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree_2 -S 
2>&1 | FileCheck --check-prefix=CHECK3 %s
+// CHECK3: clang{{.*}} "-cc1" "-triple" "avr"
+// CHECK3-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree_2]]"
+// CHECK3-SAME: "-internal-isystem"
+// CHECK3-SAME: {{^}} "[[SYSROOT]]/usr/avr/include"
+
 // RUN: %clang %s -### -target avr 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-fno-use-init-array"
 
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -453,11 +453,21 @@
 }
 
 llvm::Optional AVRToolChain::findAVRLibcInstallation() const {
+  // Search avr-libc installation according to avr-gcc installation.
+  std::string GCCParent(GCCInstallation.getParentLibPath());
+  std::string Path(GCCParent + "/avr");
+  if (llvm::sys::fs::is_directory(Path))
+return Path;
+  Path = GCCParent + "/../avr";
+  if (llvm::sys::fs::is_directory(Path))
+return Path;
+
+  // Search avr-libc installation from possible locations, and return the first
+  // one that exists, if there is no avr-gcc installed.
   for (StringRef PossiblePath : PossibleAVRLibcLocations) {
 std::string Path = getDriver().SysRoot + PossiblePath.str();
-// Return the first avr-libc installation that exists.
 if (llvm::sys::fs::is_directory(Path))
-  return Optional(Path);
+  return Path;
   }
 
   return llvm::None;


Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -6,12 +6,24 @@
 // CHECK1-SAME: "-resource-dir" "[[RESOURCE:[^"]+]]"
 // CHECK1-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree]]"
 // CHECK1-SAME: "-internal-isystem"
-// CHECK1-SAME: {{^}} "[[SYSROOT]]/usr/lib/avr/include"
+// CHECK1-SAME: {{^}} "[[SYSROOT]]/usr/lib/gcc/avr/5.4.0/../../../avr/include"
 // CHECK1-NOT:  "-L
 // CHECK1:  avr-ld"
 // CHECK1-SAME: "-o" "a.out"
 // CHECK1-SAME: {{^}} "--gc-sections"
 
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree_2/opt/local -S 2>&1 | FileCheck --check-prefix=CHECK2 %s
+// CHECK2: clang{{.*}} "-cc1" "-triple" "avr"
+// CHECK2-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree_2/opt/local]]"
+// CHECK2-SAME: "-internal-isystem"
+// CHECK2-SAME: {{^}} "[[SYSROOT]]/lib/gcc/avr/10.3.0/../../../../avr/include"
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree_2 -S 2>&1 | FileCheck --check-prefix=CHECK3 %s
+// CHECK3: clang{{.*}} "-cc1" "-triple" "avr"
+// CHECK3-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree_2]]"
+// CHECK3-SAME: "-internal-isystem"
+// CHECK3-SAME: {{^}} "[[SYSROOT]]/usr/avr/include"
+
 // RUN: %clang %s -### -target avr 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-fno-use-init-array"
 
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -453,11 +453,21 @@
 }
 
 llvm::Optional 

[clang] b31199b - [AVR][clang] Improve search for avr-libc installation path

2021-08-16 Thread Ben Shi via cfe-commits

Author: Ben Shi
Date: 2021-08-17T11:51:35+08:00
New Revision: b31199bab4865deef4e778d7a028c8ec64285654

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

LOG: [AVR][clang] Improve search for avr-libc installation path

Search avr-libc path according to avr-gcc installation at first,
then other possible installed pathes.

Reviewed By: MaskRay

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

Added: 
clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/avr/include/.keep
clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/avr/lib/libavr.a

clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/lib/gcc/avr/10.3.0/libgcc.a
clang/test/Driver/Inputs/basic_avr_tree_2/usr/avr/include/.keep
clang/test/Driver/Inputs/basic_avr_tree_2/usr/avr/lib/libavr.a

Modified: 
clang/lib/Driver/ToolChains/AVR.cpp
clang/test/Driver/avr-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AVR.cpp 
b/clang/lib/Driver/ToolChains/AVR.cpp
index cebf9d13a4ce0..5a12406a51cc6 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -453,11 +453,21 @@ void AVR::Linker::ConstructJob(Compilation , const 
JobAction ,
 }
 
 llvm::Optional AVRToolChain::findAVRLibcInstallation() const {
+  // Search avr-libc installation according to avr-gcc installation.
+  std::string GCCParent(GCCInstallation.getParentLibPath());
+  std::string Path(GCCParent + "/avr");
+  if (llvm::sys::fs::is_directory(Path))
+return Path;
+  Path = GCCParent + "/../avr";
+  if (llvm::sys::fs::is_directory(Path))
+return Path;
+
+  // Search avr-libc installation from possible locations, and return the first
+  // one that exists, if there is no avr-gcc installed.
   for (StringRef PossiblePath : PossibleAVRLibcLocations) {
 std::string Path = getDriver().SysRoot + PossiblePath.str();
-// Return the first avr-libc installation that exists.
 if (llvm::sys::fs::is_directory(Path))
-  return Optional(Path);
+  return Path;
   }
 
   return llvm::None;

diff  --git 
a/clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/avr/include/.keep 
b/clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/avr/include/.keep
new file mode 100644
index 0..e69de29bb2d1d

diff  --git 
a/clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/avr/lib/libavr.a 
b/clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/avr/lib/libavr.a
new file mode 100644
index 0..e69de29bb2d1d

diff  --git 
a/clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/lib/gcc/avr/10.3.0/libgcc.a
 
b/clang/test/Driver/Inputs/basic_avr_tree_2/opt/local/lib/gcc/avr/10.3.0/libgcc.a
new file mode 100644
index 0..e69de29bb2d1d

diff  --git a/clang/test/Driver/Inputs/basic_avr_tree_2/usr/avr/include/.keep 
b/clang/test/Driver/Inputs/basic_avr_tree_2/usr/avr/include/.keep
new file mode 100644
index 0..e69de29bb2d1d

diff  --git a/clang/test/Driver/Inputs/basic_avr_tree_2/usr/avr/lib/libavr.a 
b/clang/test/Driver/Inputs/basic_avr_tree_2/usr/avr/lib/libavr.a
new file mode 100644
index 0..e69de29bb2d1d

diff  --git a/clang/test/Driver/avr-toolchain.c 
b/clang/test/Driver/avr-toolchain.c
index 74eb6ff37aed1..6bb7a00b6a3b5 100644
--- a/clang/test/Driver/avr-toolchain.c
+++ b/clang/test/Driver/avr-toolchain.c
@@ -6,12 +6,24 @@
 // CHECK1-SAME: "-resource-dir" "[[RESOURCE:[^"]+]]"
 // CHECK1-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree]]"
 // CHECK1-SAME: "-internal-isystem"
-// CHECK1-SAME: {{^}} "[[SYSROOT]]/usr/lib/avr/include"
+// CHECK1-SAME: {{^}} "[[SYSROOT]]/usr/lib/gcc/avr/5.4.0/../../../avr/include"
 // CHECK1-NOT:  "-L
 // CHECK1:  avr-ld"
 // CHECK1-SAME: "-o" "a.out"
 // CHECK1-SAME: {{^}} "--gc-sections"
 
+// RUN: %clang %s -### -target avr --sysroot 
%S/Inputs/basic_avr_tree_2/opt/local -S 2>&1 | FileCheck --check-prefix=CHECK2 
%s
+// CHECK2: clang{{.*}} "-cc1" "-triple" "avr"
+// CHECK2-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree_2/opt/local]]"
+// CHECK2-SAME: "-internal-isystem"
+// CHECK2-SAME: {{^}} "[[SYSROOT]]/lib/gcc/avr/10.3.0/../../../../avr/include"
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree_2 -S 
2>&1 | FileCheck --check-prefix=CHECK3 %s
+// CHECK3: clang{{.*}} "-cc1" "-triple" "avr"
+// CHECK3-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree_2]]"
+// CHECK3-SAME: "-internal-isystem"
+// CHECK3-SAME: {{^}} "[[SYSROOT]]/usr/avr/include"
+
 // RUN: %clang %s -### -target avr 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-fno-use-init-array"
 



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


[PATCH] D108173: [WIP][clang] Add a cmake flag for choosing to build clang-repl

2021-08-16 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

> Not all downstream users may want to build all tools shipped with clang. 
> clang-repl for us in particular can sometimes lead to flaky builds when 
> testing a toolchain built with LTO.

Can we just fix clang-repl instead?  I think there needs to be a more 
compelling case to add a new cmake options for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108173

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


[PATCH] D58514: Avoid needlessly copying blocks that initialize or are assigned to local auto variables to the heap

2021-08-16 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

It appears as though this commit was reverted in Apple's XCode Clang fork -- 
the behavior currently in XCode matches the behavior of upstream Clang prior to 
this patch. Presuming that's correct, I think we should revert this upstream as 
well. There doesn't seem to be a good reason to have the semantics of blocks 
differ between Apple's clang and upstream clang.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58514

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


[PATCH] D105265: [X86] AVX512FP16 instructions enabling 3/6

2021-08-16 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke accepted this revision.
LuoYuanke added a comment.
This revision is now accepted and ready to land.

LGTM, but wait 1 or 2 days for the comments from others.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105265

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


[clang] c411c1b - Fix missing qualifier in template type diffing

2021-08-16 Thread via cfe-commits

Author: Weverything
Date: 2021-08-16T18:34:18-07:00
New Revision: c411c1bd7f7d3550d24333f80980c0be6481d34a

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

LOG: Fix missing qualifier in template type diffing

Handle SubstTemplateTypeParmType so qualifiers do not get dropped from
the diagnostic message.

Added: 


Modified: 
clang/lib/AST/ASTDiagnostic.cpp
clang/test/Misc/diag-template-diffing.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index dc22481d0a84c..7e435e8b35b80 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -1088,6 +1088,9 @@ class TemplateDiff {
 Ty->getAs())
   return TST;
 
+if (const auto* SubstType = Ty->getAs())
+  Ty = SubstType->getReplacementType();
+
 const RecordType *RT = Ty->getAs();
 
 if (!RT)

diff  --git a/clang/test/Misc/diag-template-
diff ing.cpp b/clang/test/Misc/diag-template-
diff ing.cpp
index cc1cc9ca70679..6bf6e2de4277c 100644
--- a/clang/test/Misc/diag-template-
diff ing.cpp
+++ b/clang/test/Misc/diag-template-
diff ing.cpp
@@ -1488,6 +1488,43 @@ void run(A_reg reg, A_ptr ptr, 
A_ref ref) {
 }
 }
 
+namespace SubstTemplateTypeParmType {
+template 
+class Array {
+};
+
+template 
+class S{};
+
+template 
+Array Make(T ()[num]);
+
+void Run(int, Array>) {}
+
+Array> Make();
+void Call() {
+  const S s1[5];
+  S s2[5];
+
+  Run(0, Make(s1));   // Error
+  Run(0, Make(s2));   // Okay
+}
+
+// CHECK-ELIDE-NOTREE: no matching function for call to 'Run'
+// CHECK-ELIDE-NOTREE: no known conversion from 'Array>' to 
'Array>' for 2nd argument
+// CHECK-NOELIDE-NOTREE: no matching function for call to 'Run'
+// CHECK-NOELIDE-NOTREE: no known conversion from 'Array>' to 
'Array>' for 2nd argument
+// CHECK-ELIDE-TREE: no matching function for call to 'Run'
+// CHECK-ELIDE-TREE: no known conversion from argument type to parameter type 
for 2nd argument
+// CHECK-ELIDE-TREE:   Array<
+// CHECK-ELIDE-TREE: [const != (no qualifiers)] S<...>>
+// CHECK-NOELIDE-TREE: no matching function for call to 'Run'
+// CHECK-NOELIDE-TREE: no known conversion from argument type to parameter 
type for 2nd argument
+// CHECK-NOELIDE-TREE:   Array<
+// CHECK-NOELIDE-TREE: [const != (no qualifiers)] S<
+// CHECK-NOELIDE-TREE:   int>>
+}
+
 // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated.
 // CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated.
 // CHECK-ELIDE-TREE: {{[0-9]*}} errors generated.



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


[PATCH] D67149: Fix argument order for BugType instation for

2021-08-16 Thread liushuai wang via Phabricator via cfe-commits
MTC added a comment.
Herald added a subscriber: martong.

Hi @NoQ, sorry to bother you. This patch has been on hold for a very long time. 
It should not have been fixed yet. What's next? Abandon the patch, or improve 
it yourself?


Repository:
  rC Clang

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

https://reviews.llvm.org/D67149

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


[PATCH] D108178: [PATCH 8/8] [clang] enable sanitizers for hexagon

2021-08-16 Thread Brian Cain via Phabricator via cfe-commits
bcain created this revision.
bcain added reviewers: sidneym, kparzysz.
bcain added a project: clang.
Herald added subscribers: s.egerton, simoncook.
bcain requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108178

Files:
  clang/lib/Driver/ToolChains/Hexagon.cpp
  clang/lib/Driver/ToolChains/Hexagon.h
  clang/lib/Driver/ToolChains/Linux.cpp


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -694,6 +694,7 @@
  getTriple().getArch() == llvm::Triple::thumbeb;
   const bool IsRISCV64 = getTriple().getArch() == llvm::Triple::riscv64;
   const bool IsSystemZ = getTriple().getArch() == llvm::Triple::systemz;
+  const bool IsHexagon = getTriple().getArch() == llvm::Triple::hexagon;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::PointerCompare;
@@ -707,7 +708,7 @@
   if (IsX86_64 || IsMIPS64 || IsAArch64)
 Res |= SanitizerKind::DataFlow;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch || IsPowerPC64 ||
-  IsRISCV64 || IsSystemZ)
+  IsRISCV64 || IsSystemZ || IsHexagon)
 Res |= SanitizerKind::Leak;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64 || IsSystemZ)
 Res |= SanitizerKind::Thread;
@@ -716,7 +717,7 @@
   if (IsX86 || IsX86_64)
 Res |= SanitizerKind::Function;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch ||
-  IsPowerPC64)
+  IsPowerPC64 || IsHexagon)
 Res |= SanitizerKind::Scudo;
   if (IsX86_64 || IsAArch64) {
 Res |= SanitizerKind::HWAddress;
Index: clang/lib/Driver/ToolChains/Hexagon.h
===
--- clang/lib/Driver/ToolChains/Hexagon.h
+++ clang/lib/Driver/ToolChains/Hexagon.h
@@ -104,6 +104,8 @@
   void getHexagonLibraryPaths(const llvm::opt::ArgList ,
   ToolChain::path_list ) const;
 
+  std::string getCompilerRTPath() const override;
+
   static bool isAutoHVXEnabled(const llvm::opt::ArgList );
   static const StringRef GetDefaultCPU();
   static const StringRef GetTargetCPUVersion(const llvm::opt::ArgList );
Index: clang/lib/Driver/ToolChains/Hexagon.cpp
===
--- clang/lib/Driver/ToolChains/Hexagon.cpp
+++ clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -146,6 +146,8 @@
   "-mcpu=hexagon" +
   toolchains::HexagonToolChain::GetTargetCPUVersion(Args)));
 
+  addSanitizerRuntimes(HTC, Args, CmdArgs);
+
   if (Output.isFilename()) {
 CmdArgs.push_back("-o");
 CmdArgs.push_back(Output.getFilename());
@@ -223,6 +225,8 @@
   bool UseShared = IsShared && !IsStatic;
   StringRef CpuVer = toolchains::HexagonToolChain::GetTargetCPUVersion(Args);
 
+  bool NeedsSanitizerDeps = addSanitizerRuntimes(HTC, Args, CmdArgs);
+
   
//
   // Silence warnings for various options
   
//
@@ -288,6 +292,12 @@
 AddLinkerInputs(HTC, Inputs, Args, CmdArgs, JA);
 
 if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  if (NeedsSanitizerDeps) {
+linkSanitizerRuntimeDeps(HTC, CmdArgs);
+// FIXME: sanitizer_common or only some require unwind?
+CmdArgs.push_back("-lunwind");
+  }
+
   CmdArgs.push_back("-lclang_rt.builtins-hexagon");
   CmdArgs.push_back("-lc");
 }
@@ -450,6 +460,13 @@
   return None;
 }
 
+std::string HexagonToolChain::getCompilerRTPath() const {
+  SmallString<128> Dir(getDriver().SysRoot);
+  llvm::sys::path::append(Dir, "usr", "lib");
+  Dir += SelectedMultilib.gccSuffix();
+  return std::string(Dir.str());
+}
+
 void HexagonToolChain::getHexagonLibraryPaths(const ArgList ,
   ToolChain::path_list ) const {
   const Driver  = getDriver();


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -694,6 +694,7 @@
  getTriple().getArch() == llvm::Triple::thumbeb;
   const bool IsRISCV64 = getTriple().getArch() == llvm::Triple::riscv64;
   const bool IsSystemZ = getTriple().getArch() == llvm::Triple::systemz;
+  const bool IsHexagon = getTriple().getArch() == llvm::Triple::hexagon;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::PointerCompare;
@@ -707,7 +708,7 @@
   if (IsX86_64 || IsMIPS64 || IsAArch64)
 Res |= SanitizerKind::DataFlow;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch || IsPowerPC64 ||
-  IsRISCV64 || IsSystemZ)
+  IsRISCV64 || IsSystemZ || IsHexagon)
 Res |= SanitizerKind::Leak;
   if (IsX86_64 

[PATCH] D105265: [X86] AVX512FP16 instructions enabling 3/6

2021-08-16 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:1996
   setOperationAction(ISD::SCALAR_TO_VECTOR,   MVT::v16f16, Custom);
+  setOperationAction(ISD::SINT_TO_FP, MVT::v16i16, Legal);
+  setOperationAction(ISD::STRICT_SINT_TO_FP,  MVT::v16i16, Legal);

pengfei wrote:
> LuoYuanke wrote:
> > How do we know it covert to v16f16? Is it possible convert to v16f32?
> No. Because `v16f32` is not a legal type on X86.
Sorry, I mistook it with `v32f32`.
The answer is still no. But because we extend `v16i16` to `v16i32` in 
`combineS(U)IntToFP` at the begining. So we don't need to worry about there's 
no a legal `v16i16` to `v16f32`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105265

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


[PATCH] D107296: Treat inttypes.h as a built-in header

2021-08-16 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In general it is correct but there is no test case. I have a test case but it 
fails for other reasons. And I wasn't able to find time to address these "other 
reasons". I'll post my version of the test case soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107296

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-08-16 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

> @leonardchan, @phosek, I am not aware of such flag. Do you know how much 
> memory does LTO + clang-repl consume and would it make sense to ping some of 
> the LTO folks for their advice?

I played around a bit with adding a flag and it turned out to be not as 
difficult as I thought it would: D108173 . I 
think making this more of an "opt-in/out" tool like clang-staticanalyzer might 
be a good idea in general since not all downstream users may want to built all 
clang tools.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96033

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


[PATCH] D107933: [clang] Expose unreachable fallthrough annotation warning

2021-08-16 Thread Nathan Chancellor via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9ed4a94d6451: [clang] Expose unreachable fallthrough 
annotation warning (authored by nathanchance).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107933

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaCXX/P30636.cpp
  clang/test/SemaCXX/switch-implicit-fallthrough.cpp


Index: clang/test/SemaCXX/switch-implicit-fallthrough.cpp
===
--- clang/test/SemaCXX/switch-implicit-fallthrough.cpp
+++ clang/test/SemaCXX/switch-implicit-fallthrough.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough 
-Wunreachable-code-fallthrough %s
 
 
 int fallthrough(int n) {
@@ -193,6 +193,26 @@
 ;
   }
 
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunreachable-code-fallthrough"
+  switch (n) {
+  n += 300;
+  [[clang::fallthrough]];  // no warning here
+case 221:
+  return 1;
+  [[clang::fallthrough]];  // no warning here
+case 222:
+  return 2;
+  __attribute__((fallthrough)); // no warning here
+case 223:
+  if (1)
+return 3;
+  __attribute__((fallthrough)); // no warning here
+case 224:
+  n += 400;
+  }
+#pragma clang diagnostic pop
+
   long p = static_cast(n) * n;
   switch (sizeof(p)) {
 case 9:
Index: clang/test/SemaCXX/P30636.cpp
===
--- clang/test/SemaCXX/P30636.cpp
+++ clang/test/SemaCXX/P30636.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough 
-Wunreachable-code-fallthrough %s
 // expected-no-diagnostics
 
 template
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -1125,7 +1125,7 @@
 // unreachable in all instantiations of the template.
 if (!IsTemplateInstantiation)
   S.Diag(AS->getBeginLoc(),
- diag::warn_fallthrough_attr_unreachable);
+ diag::warn_unreachable_fallthrough_attr);
 markFallthroughVisited(AS);
 ++AnnotatedCnt;
 break;
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -682,6 +682,9 @@
 def warn_unreachable_loop_increment : Warning<
   "loop will run at most once (loop increment never executed)">,
   InGroup, DefaultIgnore;
+def warn_unreachable_fallthrough_attr : Warning<
+  "fallthrough annotation in unreachable code">,
+  InGroup, DefaultIgnore;
 def note_unreachable_silence : Note<
   "silence by adding parentheses to mark code as explicitly dead">;
 
@@ -9578,9 +9581,6 @@
   "fallthrough annotation is outside switch statement">;
 def err_fallthrough_attr_invalid_placement : Error<
   "fallthrough annotation does not directly precede switch label">;
-def warn_fallthrough_attr_unreachable : Warning<
-  "fallthrough annotation in unreachable code">,
-  InGroup, DefaultIgnore;
 
 def warn_unreachable_default : Warning<
   "default label in switch which covers all enumeration values">,
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -821,8 +821,10 @@
 //  under separate flags.
 //
 def UnreachableCodeLoopIncrement : 
DiagGroup<"unreachable-code-loop-increment">;
+def UnreachableCodeFallthrough : DiagGroup<"unreachable-code-fallthrough">;
 def UnreachableCode : DiagGroup<"unreachable-code",
-[UnreachableCodeLoopIncrement]>;
+[UnreachableCodeLoopIncrement,
+ UnreachableCodeFallthrough]>;
 def UnreachableCodeBreak : DiagGroup<"unreachable-code-break">;
 def UnreachableCodeReturn : DiagGroup<"unreachable-code-return">;
 def UnreachableCodeAggressive : DiagGroup<"unreachable-code-aggressive",


Index: clang/test/SemaCXX/switch-implicit-fallthrough.cpp
===
--- clang/test/SemaCXX/switch-implicit-fallthrough.cpp
+++ clang/test/SemaCXX/switch-implicit-fallthrough.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 

[PATCH] D108173: [WIP][clang] Add a cmake flag for choosing to build clang-repl

2021-08-16 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan planned changes to this revision.
leonardchan added inline comments.



Comment at: clang/CMakeLists.txt:468
 
+option(CLANG_BUILD_CLANG_REPL_DEFAULT "Build clang-repl by default." OFF)
+

Apart from name bikeshedding, it's more likely we'll want this `ON` by default 
to match current upstream behavior, then downstream users like us can just set 
this to `OFF` in our configs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108173

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


[clang] 9ed4a94 - [clang] Expose unreachable fallthrough annotation warning

2021-08-16 Thread Nathan Chancellor via cfe-commits

Author: Nathan Chancellor
Date: 2021-08-16T17:14:55-07:00
New Revision: 9ed4a94d6451046a51ef393cd62f00710820a7e8

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

LOG: [clang] Expose unreachable fallthrough annotation warning

The Linux kernel has a macro called IS_ENABLED(), which evaluates to a
constant 1 or 0 based on Kconfig selections, allowing C code to be
unconditionally enabled or disabled at build time. For example:

int foo(struct *a, int b) {
switch (b) {
case 1:
if (a->flag || !IS_ENABLED(CONFIG_64BIT))
return 1;
__attribute__((fallthrough));
case 2:
return 2;
default:
return 3;
}
}

There is an unreachable warning about the fallthrough annotation in the
first case because !IS_ENABLED(CONFIG_64BIT) can be evaluated to 1,
which looks like

return 1;
__attribute__((fallthrough));

to clang.

This type of warning is pointless for the Linux kernel because it does
this trick all over the place due to the sheer number of configuration
options that it has.

Add -Wunreachable-code-fallthrough, enabled under -Wunreachable-code, so
that projects that want to warn on unreachable code get this warning but
projects that do not care about unreachable code can still use
-Wimplicit-fallthrough without having to make changes to their code
base.

Fixes PR51094.

Reviewed By: aaron.ballman, nickdesaulniers

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/AnalysisBasedWarnings.cpp
clang/test/SemaCXX/P30636.cpp
clang/test/SemaCXX/switch-implicit-fallthrough.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 30dadd9731c15..17b5f419ef58c 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -821,8 +821,10 @@ def ReservedIdentifier : DiagGroup<"reserved-identifier",
 //  under separate flags.
 //
 def UnreachableCodeLoopIncrement : 
DiagGroup<"unreachable-code-loop-increment">;
+def UnreachableCodeFallthrough : DiagGroup<"unreachable-code-fallthrough">;
 def UnreachableCode : DiagGroup<"unreachable-code",
-[UnreachableCodeLoopIncrement]>;
+[UnreachableCodeLoopIncrement,
+ UnreachableCodeFallthrough]>;
 def UnreachableCodeBreak : DiagGroup<"unreachable-code-break">;
 def UnreachableCodeReturn : DiagGroup<"unreachable-code-return">;
 def UnreachableCodeAggressive : DiagGroup<"unreachable-code-aggressive",

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 9eaa696d99913..41152212c0d12 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -682,6 +682,9 @@ def warn_unreachable_return : Warning<
 def warn_unreachable_loop_increment : Warning<
   "loop will run at most once (loop increment never executed)">,
   InGroup, DefaultIgnore;
+def warn_unreachable_fallthrough_attr : Warning<
+  "fallthrough annotation in unreachable code">,
+  InGroup, DefaultIgnore;
 def note_unreachable_silence : Note<
   "silence by adding parentheses to mark code as explicitly dead">;
 
@@ -9578,9 +9581,6 @@ def err_fallthrough_attr_outside_switch : Error<
   "fallthrough annotation is outside switch statement">;
 def err_fallthrough_attr_invalid_placement : Error<
   "fallthrough annotation does not directly precede switch label">;
-def warn_fallthrough_attr_unreachable : Warning<
-  "fallthrough annotation in unreachable code">,
-  InGroup, DefaultIgnore;
 
 def warn_unreachable_default : Warning<
   "default label in switch which covers all enumeration values">,

diff  --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp 
b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index aa2602c8d9256..99ce143d3559d 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -1125,7 +1125,7 @@ namespace {
 // unreachable in all instantiations of the template.
 if (!IsTemplateInstantiation)
   S.Diag(AS->getBeginLoc(),
- diag::warn_fallthrough_attr_unreachable);
+ diag::warn_unreachable_fallthrough_attr);
 markFallthroughVisited(AS);
 ++AnnotatedCnt;
 break;

diff  --git a/clang/test/SemaCXX/P30636.cpp b/clang/test/SemaCXX/P30636.cpp
index 2e2affb0cfdea..1d5400d3ba0ed 100644
--- a/clang/test/SemaCXX/P30636.cpp
+++ b/clang/test/SemaCXX/P30636.cpp
@@ 

[PATCH] D108173: [WIP][clang] Add a cmake flag for choosing to build clang-repl

2021-08-16 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added a project: clang.
Herald added a subscriber: mgorny.
leonardchan requested review of this revision.

Not all downstream users may want to build all tools shipped with clang. 
`clang-repl` for us in particular can sometimes lead to flaky builds when 
testing a toolchain built with LTO.

This is a WIP patch that demonstrates:

- Allowing `clang-repl` to be built (by default) as part of `check-all`. Note 
that this doesn't remove it as a build target. It just makes it so that it's 
not built by default.
- Only running tests that require `clang-repl` via a `REQUIRES` line.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108173

Files:
  clang/CMakeLists.txt
  clang/test/CMakeLists.txt
  clang/test/Interpreter/execute.cpp
  clang/test/Interpreter/sanity.c
  clang/test/lit.cfg.py
  clang/test/lit.site.cfg.py.in

Index: clang/test/lit.site.cfg.py.in
===
--- clang/test/lit.site.cfg.py.in
+++ clang/test/lit.site.cfg.py.in
@@ -26,6 +26,7 @@
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
 config.clang_staticanalyzer_z3 = "@LLVM_WITH_Z3@"
 config.clang_examples = @CLANG_BUILD_EXAMPLES@
+config.clang_repl = @CLANG_BUILD_CLANG_REPL_DEFAULT@
 config.enable_shared = @ENABLE_SHARED@
 config.enable_backtrace = @ENABLE_BACKTRACES@
 config.enable_experimental_new_pass_manager = @LLVM_ENABLE_NEW_PASS_MANAGER@
Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -63,7 +63,7 @@
 tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir]
 
 tools = [
-'apinotes-test', 'c-index-test', 'clang-diff', 'clang-format', 'clang-repl',
+'apinotes-test', 'c-index-test', 'clang-diff', 'clang-format',
 'clang-tblgen', 'clang-scan-deps', 'opt', 'llvm-ifs', 'yaml2obj',
 ToolSubst('%clang_extdef_map', command=FindTool(
 'clang-extdef-mapping'), unresolved='ignore'),
@@ -73,9 +73,20 @@
 config.available_features.add('examples')
 tools.append('clang-interpreter')
 
-def have_host_jit_support():
+def get_clang_repl():
 clang_repl_exe = lit.util.which('clang-repl', config.clang_tools_dir)
 
+if not clang_repl_exe:
+return None
+
+return clang_repl_exe
+
+clang_repl_exe = get_clang_repl()
+if clang_repl_exe is not None:
+tools.append('clang-repl')
+config.available_features.add('clang-repl')
+
+def have_host_jit_support():
 if not clang_repl_exe:
 print('clang-repl not found')
 return False
Index: clang/test/Interpreter/sanity.c
===
--- clang/test/Interpreter/sanity.c
+++ clang/test/Interpreter/sanity.c
@@ -1,3 +1,5 @@
+// REQUIRES: clang-repl
+
 // RUN: cat %s | \
 // RUN:   clang-repl -Xcc -fno-color-diagnostics -Xcc -Xclang -Xcc -ast-dump \
 // RUN:-Xcc -Xclang -Xcc -ast-dump-filter -Xcc -Xclang -Xcc Test 2>&1| \
Index: clang/test/Interpreter/execute.cpp
===
--- clang/test/Interpreter/execute.cpp
+++ clang/test/Interpreter/execute.cpp
@@ -1,3 +1,5 @@
+// REQUIRES: clang-repl
+
 // RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
 // RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
 // REQUIRES: host-supports-jit
Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -13,6 +13,7 @@
   CLANG_BUILD_EXAMPLES
   CLANG_ENABLE_ARCMT
   CLANG_ENABLE_STATIC_ANALYZER
+  CLANG_BUILD_CLANG_REPL_DEFAULT
   CLANG_SPAWN_CC1
   ENABLE_BACKTRACES
   LLVM_ENABLE_NEW_PASS_MANAGER
@@ -70,13 +71,16 @@
   clang-import-test
   clang-rename
   clang-refactor
-  clang-repl
   clang-diff
   clang-scan-deps
   diagtool
   hmaptool
   )
-  
+
+if(CLANG_BUILD_CLANG_REPL_DEFAULT)
+  list(APPEND CLANG_TEST_DEPS clang-repl)
+endif()
+
 if(CLANG_ENABLE_STATIC_ANALYZER)
   list(APPEND CLANG_TEST_DEPS
 clang-check
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -465,6 +465,8 @@
 option(CLANG_ENABLE_STATIC_ANALYZER
   "Include static analyzer in clang binary." ON)
 
+option(CLANG_BUILD_CLANG_REPL_DEFAULT "Build clang-repl by default." OFF)
+
 option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)
 
 option(CLANG_ROUND_TRIP_CC1_ARGS
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108083: [sanitizer] Add hexagon support to sanitizer-common (1/8)

2021-08-16 Thread Brian Cain via Phabricator via cfe-commits
bcain updated this revision to Diff 366766.
bcain retitled this revision from "add sanitizer support to hexagon" to 
"[sanitizer] Add hexagon support to sanitizer-common (1/8)".
bcain edited the summary of this revision.
bcain added a comment.

Decomposed to just the sanitizer-common portion.  Now it's an 8 patch series, 
this is number 1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108083

Files:
  compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
  compiler-rt/lib/sanitizer_common/sanitizer_common.h
  compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
  compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_platform.h
  compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
  compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_hexagon.inc

Index: compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_hexagon.inc
===
--- /dev/null
+++ compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_hexagon.inc
@@ -0,0 +1,131 @@
+//===-- sanitizer_syscall_linux_hexagon.inc -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Implementations of internal_syscall and internal_iserror for Linux/hexagon.
+//
+//===--===//
+
+#define SYSCALL(name) __NR_ ## name
+
+#define __internal_syscall_LL_E(x) \
+((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
+((union { long long ll; long l[2]; }){ .ll = x }).l[1]
+#define __internal_syscall_LL_O(x) 0, __SYSCALL_LL_E((x))
+
+#define __asm_syscall(...) do { \
+__asm__ __volatile__ ( "trap0(#1)" \
+: "=r"(r0) : __VA_ARGS__ : "memory"); \
+return r0; \
+} while (0)
+
+#define __internal_syscall0(n) \
+  (__internal_syscall)(n)
+
+static uptr __internal_syscall(long n)
+{
+  register long r6 __asm__("r6") = n;
+  register long r0 __asm__("r0");
+  __asm_syscall("r"(r6));
+}
+
+#define __internal_syscall1(n, a1) \
+  (__internal_syscall)(n, (long)(a1))
+
+static uptr __internal_syscall(long n, long a)
+{
+  register long r6 __asm__("r6") = n;
+  register long r0 __asm__("r0") = a;
+  __asm_syscall("r"(r6), "0"(r0));
+}
+
+#define __internal_syscall2(n, a1, a2) \
+  (__internal_syscall)(n, (long)(a1), (long)(a2))
+
+static uptr __internal_syscall(long n, long a, long b)
+{
+  register long r6 __asm__("r6") = n;
+  register long r0 __asm__("r0") = a;
+  register long r1 __asm__("r1") = b;
+  __asm_syscall("r"(r6), "0"(r0), "r"(r1));
+}
+
+#define __internal_syscall3(n, a1, a2, a3) \
+  (__internal_syscall)(n, (long)(a1), (long)(a2), (long)(a3))
+
+static uptr __internal_syscall(long n, long a, long b, long c)
+{
+  register long r6 __asm__("r6") = n;
+  register long r0 __asm__("r0") = a;
+  register long r1 __asm__("r1") = b;
+  register long r2 __asm__("r2") = c;
+  __asm_syscall("r"(r6), "0"(r0), "r"(r1), "r"(r2));
+}
+
+#define __internal_syscall4(n, a1, a2, a3, a4) \
+  (__internal_syscall)(n, (long)(a1), (long)(a2), (long)(a3), (long)(a4))
+
+static uptr __internal_syscall(long n, long a, long b, long c, long d)
+{
+  register long r6 __asm__("r6") = n;
+  register long r0 __asm__("r0") = a;
+  register long r1 __asm__("r1") = b;
+  register long r2 __asm__("r2") = c;
+  register long r3 __asm__("r3") = d;
+  __asm_syscall("r"(r6), "0"(r0), "r"(r1), "r"(r2), "r"(r3));
+}
+
+#define __internal_syscall5(n, a1, a2, a3, a4, a5) \
+  (__internal_syscall)(n, (long)(a1), (long)(a2), (long)(a3), (long)(a4), \
+   (long)(a5))
+
+static uptr __internal_syscall(long n, long a, long b, long c, long d, long e)
+{
+  register long r6 __asm__("r6") = n;
+  register long r0 __asm__("r0") = a;
+  register long r1 __asm__("r1") = b;
+  register long r2 __asm__("r2") = c;
+  register long r3 __asm__("r3") = d;
+  register long r4 __asm__("r4") = e;
+  __asm_syscall("r"(r6), "0"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r4));
+}
+
+#define __internal_syscall6(n, a1, a2, a3, a4, a5, a6) \
+  (__internal_syscall)(n, (long)(a1), (long)(a2), (long)(a3), (long)(a4), \
+   (long)(a5), (long)(a6))
+
+static uptr __internal_syscall(long n, long a, long b, long c, long d, long e,
+  long f)
+{
+  register long r6 __asm__("r6") = n;
+  register long r0 __asm__("r0") = a;
+  register long r1 __asm__("r1") = b;
+  register long r2 __asm__("r2") = c;
+  

[PATCH] D108003: [Clang] Extend -Wbool-operation to warn about bitwise and of bools with side effects

2021-08-16 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

> Can we either emit that [`a &= foo()`] as a suggestion if the code looks like 
> `a = a & foo()`? Or simply not emit a warning?

The problem is that if `a` is boolean, then `a = a & something` is 99% for sure 
a typo — 99% of the time, the programmer meant `a = a && something`. So any 
compiler suggestion or fixit that blindly "doubles down" on the 
non-short-circuiting behavior is a bad idea. 
https://quuxplusone.github.io/blog/2020/09/02/wparentheses/ is relevant.

One proper way to silence the warning //without// short-circuiting would be `a 
= int(a) & something` — this indicates that you really do want integer 
bitwise-ANDing, not boolean. Alternatively, and probably best, just declare `a` 
as an integer variable to begin with. Of course the compiler cannot recommend 
this if `something` isn't strictly zero or one. But in that case you might 
already have a bug:

  int error_returning_func() { return 2; }
  int main() {
  bool t = true;
  t = t && error_returning_func();
  assert(t);  // still true
  t = t & error_returning_func();
  assert(!t);  // now it's false
  }

So typo'ing `&` for `&&` doesn't just turn off short-circuiting — it can also 
mess up the runtime value stored in the bool.


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

https://reviews.llvm.org/D108003

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


[PATCH] D95583: Frontend: Add -f{, no-}implicit-modules-uses-lock and -Rmodule-lock

2021-08-16 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/test/Modules/implicit-modules-use-lock.m:21
+
+// CHECK-NO-LOCKS-NOT: remark:
+// CHECK-LOCKS: remark: locking '{{.*}}.pcm' to build module 'X' 
[-Rmodule-lock]

arichardson wrote:
> jansvoboda11 wrote:
> > dexonsmith wrote:
> > > jansvoboda11 wrote:
> > > > Where is the empty remark coming from? Is it useful to us in any way?
> > > This is a `CHECK-NOT: ` line (with a custom `-check-prefix`). It 
> > > confirms that `` does not occur at least until the next positive 
> > > check matches. The `FileCheck` invocation that uses `CHECK-NO-LOCKS` has 
> > > no other check lines, so this really means: "`remark:` does not match on 
> > > any line". Note I also needed to add `-allow-empty` since with no 
> > > diagnostics at all, `FileCheck`'s stdin will be empty.
> > > 
> > > FYI, if you want to read more:
> > > - `-check-prefix` is documented at 
> > > https://www.llvm.org/docs/CommandGuide/FileCheck.html#the-filecheck-check-prefix-option
> > > - `CHECK-NOT` is documented at 
> > > https://www.llvm.org/docs/CommandGuide/FileCheck.html#the-check-not-directive
> > > 
> > > Often in clang tests it's easier to use `-cc1 -verify` for diagnostics 
> > > instead of manual `FileCheck`s (`expected-no-diagnostics` comment being 
> > > the equivalent of `-allow-empty`). In the modules testcases, there's 
> > > often a complicated setup that we want to run a lot of `RUN:` lines 
> > > against where each one expects different diagnostics. Maybe we should add 
> > > prefix support to `-verify` (or maybe it's there and no one told me...).
> > Ah, that makes sense, thanks!
> This could use e.g. `-verify=lock` and `-verify=lock` to avoid the Filecheck 
> usage.
Thanks! Fixed in d8a08fae0af9aa09c108b3e7c60f192249dd2098.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95583

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


[clang] d8a08fa - Clean up test for -f{, no-}implicit-modules-uses-lock

2021-08-16 Thread Duncan P. N. Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2021-08-16T16:23:04-07:00
New Revision: d8a08fae0af9aa09c108b3e7c60f192249dd2098

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

LOG: Clean up test for -f{,no-}implicit-modules-uses-lock

@arichardson pointed out in post-commit review for
https://reviews.llvm.org/D95583 (b714f73defc8e075) that `-verify` has an
optional argument that works a lot like `FileCheck`'s `-check-prefix`.
Use it to simplify the test for `-fno-implicit-modules-use-lock`!

Added: 


Modified: 
clang/test/Modules/implicit-modules-use-lock.m

Removed: 




diff  --git a/clang/test/Modules/implicit-modules-use-lock.m 
b/clang/test/Modules/implicit-modules-use-lock.m
index 811b83a7e4c76..6c9582df4de52 100644
--- a/clang/test/Modules/implicit-modules-use-lock.m
+++ b/clang/test/Modules/implicit-modules-use-lock.m
@@ -4,20 +4,20 @@
 //
 // RUN: rm -rf %t.cache
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
-// RUN:   -fimplicit-modules-use-lock -Rmodule-lock \
+// RUN:   -fimplicit-modules-use-lock -Rmodule-lock -Rmodule-build \
 // RUN:   -fmodules-cache-path=%t.cache -I%S/Inputs/system-out-of-date \
 // RUN:   -fsyntax-only %s -Wnon-modular-include-in-framework-module \
-// RUN:   -Werror=non-modular-include-in-framework-module 2>&1 \
-// RUN: | FileCheck %s -check-prefix=CHECK-LOCKS
+// RUN:   -Werror=non-modular-include-in-framework-module \
+// RUN:   -verify=locks,build
 //
 // RUN: rm -rf %t.cache
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
-// RUN:   -fno-implicit-modules-use-lock -Rmodule-lock \
+// RUN:   -fno-implicit-modules-use-lock -Rmodule-lock -Rmodule-build \
 // RUN:   -fmodules-cache-path=%t.cache -I%S/Inputs/system-out-of-date \
 // RUN:   -fsyntax-only %s -Wnon-modular-include-in-framework-module \
-// RUN:   -Werror=non-modular-include-in-framework-module 2>&1 \
-// RUN: | FileCheck %s -check-prefix=CHECK-NO-LOCKS -allow-empty
+// RUN:   -Werror=non-modular-include-in-framework-module \
+// RUN:   -verify=build
 
-// CHECK-NO-LOCKS-NOT: remark:
-// CHECK-LOCKS: remark: locking '{{.*}}.pcm' to build module 'X' 
[-Rmodule-lock]
-@import X;
+@import X; // locks-remark-re {{locking '{{.*}}.pcm' to build module 'X'}} \
+   // build-remark {{building module 'X'}} \
+   // build-remark {{finished building module 'X'}}



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


[PATCH] D108151: [NFC][clang] Use X86 Features declaration from X86TargetParser

2021-08-16 Thread Andrei Elovikov via Phabricator via cfe-commits
a.elovikov updated this revision to Diff 366760.
a.elovikov added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Another version. My main goal here is to gradually move more stuff from clang/
to llvm/ so I'm open to other suggestions in doing so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108151

Files:
  clang/include/clang/Basic/X86Target.def
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  llvm/include/llvm/Support/X86TargetParser.def

Index: llvm/include/llvm/Support/X86TargetParser.def
===
--- llvm/include/llvm/Support/X86TargetParser.def
+++ llvm/include/llvm/Support/X86TargetParser.def
@@ -91,54 +91,59 @@
 X86_CPU_SUBTYPE(INTEL_COREI7_ROCKETLAKE, "rocketlake")
 #undef X86_CPU_SUBTYPE
 
-
-// This macro is used for cpu types present in compiler-rt/libgcc.
+// This macro is used for cpu types present in compiler-rt/libgcc. The third
+// parameter PRIORITY is as required by the attribute 'target' checking. Note
+// that not all are supported/prioritized by GCC, so synchronization with GCC's
+// implementation may require changing some existing values.
+//
+// We cannot just re-sort the list though because its order is dictated by the
+// order of bits in CodeGenFunction::GetX86CpuSupportsMask.
 #ifndef X86_FEATURE_COMPAT
-#define X86_FEATURE_COMPAT(ENUM, STR) X86_FEATURE(ENUM, STR)
+#define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY) X86_FEATURE(ENUM, STR)
 #endif
 
 #ifndef X86_FEATURE
 #define X86_FEATURE(ENUM, STR)
 #endif
 
-X86_FEATURE_COMPAT(CMOV,"cmov")
-X86_FEATURE_COMPAT(MMX, "mmx")
-X86_FEATURE_COMPAT(POPCNT,  "popcnt")
-X86_FEATURE_COMPAT(SSE, "sse")
-X86_FEATURE_COMPAT(SSE2,"sse2")
-X86_FEATURE_COMPAT(SSE3,"sse3")
-X86_FEATURE_COMPAT(SSSE3,   "ssse3")
-X86_FEATURE_COMPAT(SSE4_1,  "sse4.1")
-X86_FEATURE_COMPAT(SSE4_2,  "sse4.2")
-X86_FEATURE_COMPAT(AVX, "avx")
-X86_FEATURE_COMPAT(AVX2,"avx2")
-X86_FEATURE_COMPAT(SSE4_A,  "sse4a")
-X86_FEATURE_COMPAT(FMA4,"fma4")
-X86_FEATURE_COMPAT(XOP, "xop")
-X86_FEATURE_COMPAT(FMA, "fma")
-X86_FEATURE_COMPAT(AVX512F, "avx512f")
-X86_FEATURE_COMPAT(BMI, "bmi")
-X86_FEATURE_COMPAT(BMI2,"bmi2")
-X86_FEATURE_COMPAT(AES, "aes")
-X86_FEATURE_COMPAT(PCLMUL,  "pclmul")
-X86_FEATURE_COMPAT(AVX512VL,"avx512vl")
-X86_FEATURE_COMPAT(AVX512BW,"avx512bw")
-X86_FEATURE_COMPAT(AVX512DQ,"avx512dq")
-X86_FEATURE_COMPAT(AVX512CD,"avx512cd")
-X86_FEATURE_COMPAT(AVX512ER,"avx512er")
-X86_FEATURE_COMPAT(AVX512PF,"avx512pf")
-X86_FEATURE_COMPAT(AVX512VBMI,  "avx512vbmi")
-X86_FEATURE_COMPAT(AVX512IFMA,  "avx512ifma")
-X86_FEATURE_COMPAT(AVX5124VNNIW,"avx5124vnniw")
-X86_FEATURE_COMPAT(AVX5124FMAPS,"avx5124fmaps")
-X86_FEATURE_COMPAT(AVX512VPOPCNTDQ, "avx512vpopcntdq")
-X86_FEATURE_COMPAT(AVX512VBMI2, "avx512vbmi2")
-X86_FEATURE_COMPAT(GFNI,"gfni")
-X86_FEATURE_COMPAT(VPCLMULQDQ,  "vpclmulqdq")
-X86_FEATURE_COMPAT(AVX512VNNI,  "avx512vnni")
-X86_FEATURE_COMPAT(AVX512BITALG,"avx512bitalg")
-X86_FEATURE_COMPAT(AVX512BF16,  "avx512bf16")
-X86_FEATURE_COMPAT(AVX512VP2INTERSECT, "avx512vp2intersect")
+X86_FEATURE_COMPAT(CMOV,"cmov",  0)
+X86_FEATURE_COMPAT(MMX, "mmx",   1)
+X86_FEATURE_COMPAT(POPCNT,  "popcnt",9)
+X86_FEATURE_COMPAT(SSE, "sse",   2)
+X86_FEATURE_COMPAT(SSE2,"sse2",  3)
+X86_FEATURE_COMPAT(SSE3,"sse3",  4)
+X86_FEATURE_COMPAT(SSSE3,   "ssse3", 5)
+X86_FEATURE_COMPAT(SSE4_1,  "sse4.1",7)
+X86_FEATURE_COMPAT(SSE4_2,  "sse4.2",8)
+X86_FEATURE_COMPAT(AVX, "avx",   12)
+X86_FEATURE_COMPAT(AVX2,"avx2",  18)
+X86_FEATURE_COMPAT(SSE4_A,  "sse4a", 6)
+X86_FEATURE_COMPAT(FMA4,"fma4",  14)
+X86_FEATURE_COMPAT(XOP, "xop",   15)
+X86_FEATURE_COMPAT(FMA, "fma",   16)
+X86_FEATURE_COMPAT(AVX512F, "avx512f",   19)
+X86_FEATURE_COMPAT(BMI, "bmi",   13)
+X86_FEATURE_COMPAT(BMI2,"bmi2",  17)
+X86_FEATURE_COMPAT(AES, "aes",   10)
+X86_FEATURE_COMPAT(PCLMUL,  "pclmul",11)
+X86_FEATURE_COMPAT(AVX512VL,"avx512vl",  20)
+X86_FEATURE_COMPAT(AVX512BW,"avx512bw",  21)
+X86_FEATURE_COMPAT(AVX512DQ,"avx512dq",

[PATCH] D107296: Treat inttypes.h as a built-in header

2021-08-16 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith resigned from this revision.
dexonsmith added reviewers: bruno, vsapsai.
dexonsmith added subscribers: bruno, vsapsai.
dexonsmith added a comment.

@bruno or @vsapsai, any chance one of you knows whether this is correct?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107296

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


[PATCH] D108083: add sanitizer support to hexagon

2021-08-16 Thread Brian Cain via Phabricator via cfe-commits
bcain added a comment.

In D108083#2947914 , @vitalybuka 
wrote:

> Do we have public bot for hexagon?

I think we have one intended to for checking hexagon-unknown-elf and perhaps 
not one for hexagon-unknown-linux-musl. I believe that only the Linux target 
uses the compiler-rt libraries, though.

We can help create a bot for hexagon-unknown-linux-musl. What's the process?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108083

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


[PATCH] D108083: add sanitizer support to hexagon

2021-08-16 Thread Brian Cain via Phabricator via cfe-commits
bcain added a comment.

In D108083#2947907 , @vitalybuka 
wrote:

> Can you cut this into separate peaces, at least patch per sanitizer for "asan 
> lsan ubsan scudo scudo_standalone cfi safestack"?

Sure, that's no problem. While I'm breaking it up, us there a 
guideline/preference to whether the clang changes can be combined in one of 
these patches, or should those be on their own as well?

> Some common peaces could be probably extracted as well.






Comment at: compiler-rt/test/asan/CMakeLists.txt:19
 set(${bits} 64)
-  elseif (${arch} MATCHES "i386|arm|mips|mipsel|sparc")
+  elseif (${arch} MATCHES "i386|arm|mips|mipsel|sparc|hexagon")
 set(${bits} 32)

vitalybuka wrote:
> why only this test changes?
> 
Sorry, I shouldnt have included this, I'll omit it. I'd like to land the build 
changes before test ones. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108083

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


[PATCH] D98061: [InstrProfiling] Generate runtime hook for Fuchsia

2021-08-16 Thread Kirsten Lee via Phabricator via cfe-commits
kile added a comment.

Apologies, reporting on the incorrect revision :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98061

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


[PATCH] D106030: [Clang] add support for error+warning fn attrs

2021-08-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/test/Sema/attr-error.c:31-32
+
+__attribute__((error("foo"))) int bad5(void);   // expected-error {{'error' 
and 'warning' attributes are not compatible}}
+__attribute__((warning("foo"))) int bad5(void); // expected-note {{conflicting 
attribute is here}}
+

aaron.ballman wrote:
> nickdesaulniers wrote:
> > aaron.ballman wrote:
> > > I think the diagnostic order is backwards here. The first declaration is 
> > > where I'd expect the note and the second declaration is where I'd expect 
> > > the error. (The idea is: the first declaration adds an attribute to the 
> > > decl, so the redeclaration is what introduces the conflict and so that's 
> > > where the error should live.) As an example: 
> > > https://godbolt.org/z/bjGTWxYvh
> > I'm not sure how to reconcile this. Looking at `bad4` above (different case 
> > than `bad5`), the diagnostic we get is:
> > ```
> > /tmp/y.c:1:30: error: 'warning' and 'error' attributes are not compatible
> > __attribute__((error("foo"), warning("foo")))
> >  ^
> > /tmp/y.c:1:16: note: conflicting attribute is here
> > __attribute__((error("foo"), warning("foo")))
> >^
> > 1 error generated.
> > ```
> > which looks correct to me. If I flip the order these are diagnosed in, that 
> > fixes `bad5` but if I flip around the ordering:
> > ```
> > --- a/clang/lib/Sema/SemaDeclAttr.cpp
> > +++ b/clang/lib/Sema/SemaDeclAttr.cpp
> > -  Diag(CI.getLoc(), diag::err_attributes_are_not_compatible) << CI << 
> > EA;
> > -  Diag(EA->getLocation(), diag::note_conflicting_attribute);
> > +  Diag(EA->getLocation(), diag::err_attributes_are_not_compatible)
> > +  << CI << EA;
> > +  Diag(CI.getLoc(), diag::note_conflicting_attribute);
> > ```
> > Then `bad4` doesn't look quite correct.
> > ```
> > /tmp/y.c:1:16: error: 'warning' and 'error' attributes are not compatible
> > __attribute__((error("foo"), warning("foo")))
> >^
> > /tmp/y.c:1:30: note: conflicting attribute is here
> > __attribute__((error("foo"), warning("foo")))
> >  ^
> > ```
> > Perhaps in the callers of `handleErrorAttr` I'm confusing which `Decl` is 
> > the "new" vs the "old?"
> > which looks correct to me.
> 
> That also looks correct to me; the second attribute is the diagnostic and the 
> first attribute is the note.
> 
> > Perhaps in the callers of handleErrorAttr I'm confusing which Decl is the 
> > "new" vs the "old?"
> 
> Huh, this is rather strange. The logic you're using is basically the same as 
> `checkAttrMutualExclusion()`, just with extra work to figure out which kind 
> of attribute you're dealing with. I'm not seeing what's causing the order to 
> be different when I reason my way through the code. Perhaps in the `bad4()` 
> case, are we somehow processing the attributes in reverse order?
> 
> FWIW, at the end of the day, we can live with the diagnostic in either 
> situation, even if they're a bit strange. I think the merge behavior (two 
> different decls) is more important to get right because that's going to be 
> the far more common scenario to see the diagnostic in. If it turns out that 
> it's a systemic issue (or just gnarly to figure out), it won't block this 
> review. We can always improve the behavior in a follow-up.
I suspect that `DiagnoseMutualExclusions` (via tablegen) would be able to catch 
this, had we distinct `Attr`s for warning and error; example tablegen rule: 
`def : MutualExclusions<[Hot, Cold]>;`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106030

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


[PATCH] D108083: add sanitizer support to hexagon

2021-08-16 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Do we have public bot for hexagon?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108083

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


[PATCH] D108083: add sanitizer support to hexagon

2021-08-16 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Can you cut this into separate peaces, at least patch per sanitizer for "asan 
lsan ubsan scudo scudo_standalone cfi safestack"?
Some common peaces could be probably extracted as well.




Comment at: 
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:106
+#elif defined(__hexagon__)
+const unsigned struct_kernel_stat_sz = 128;
+const unsigned struct_kernel_stat64_sz = 0;

please clang-format entire patch



Comment at: 
compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_hexagon.inc:130
+  } else {
+return false;
+  }

Please fix clang-tidy which can be fixed.



Comment at: compiler-rt/test/asan/CMakeLists.txt:19
 set(${bits} 64)
-  elseif (${arch} MATCHES "i386|arm|mips|mipsel|sparc")
+  elseif (${arch} MATCHES "i386|arm|mips|mipsel|sparc|hexagon")
 set(${bits} 32)

why only this test changes?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108083

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


[PATCH] D54943: [clang-tidy] implement const-transformation for cppcoreguidelines-const-correctness

2021-08-16 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

@JonasToth, @aaron.ballman suspects that there's enough overlap between this 
patch and D107873  to consider merging the 
two efforts. I'm happy to collaborate, but we should probably check that our 
goals are aligned. Are you active on the LLVM Discord? We could probably 
discuss a fair bit of this offline and then ping Aaron after we work out 
whether or not to do this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54943

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


[clang] f22ba51 - [Remarks] Emit optimization remarks for atomics generating CAS loop

2021-08-16 Thread Anshil Gandhi via cfe-commits

Author: Anshil Gandhi
Date: 2021-08-16T14:56:01-06:00
New Revision: f22ba51873509b93732015176b778465f40c6db5

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

LOG: [Remarks] Emit optimization remarks for atomics generating CAS loop

Implements ORE in AtomicExpand pass to report atomics generating a
compare and swap loop.

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

Added: 
clang/test/CodeGenCUDA/atomics-remarks-gfx90a.cu
clang/test/CodeGenOpenCL/atomics-remarks-gfx90a.cl
llvm/test/CodeGen/AMDGPU/atomics-remarks-gfx90a.ll

Modified: 
llvm/lib/CodeGen/AtomicExpandPass.cpp

Removed: 




diff  --git a/clang/test/CodeGenCUDA/atomics-remarks-gfx90a.cu 
b/clang/test/CodeGenCUDA/atomics-remarks-gfx90a.cu
new file mode 100644
index 0..96892286fd75e
--- /dev/null
+++ b/clang/test/CodeGenCUDA/atomics-remarks-gfx90a.cu
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   -target-cpu gfx90a -Rpass=atomic-expand -S -o - 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=GFX90A-CAS
+
+// REQUIRES: amdgpu-registered-target
+
+#include "Inputs/cuda.h"
+#include 
+
+// GFX90A-CAS: A compare and swap loop was generated for an atomic fadd 
operation at system memory scope
+// GFX90A-CAS-LABEL: _Z14atomic_add_casPf
+// GFX90A-CAS:  flat_atomic_cmpswap v0, v[2:3], v[4:5] glc
+// GFX90A-CAS:  s_cbranch_execnz
+__device__ float atomic_add_cas(float *p) {
+  return __atomic_fetch_add(p, 1.0f, memory_order_relaxed);
+}

diff  --git a/clang/test/CodeGenOpenCL/atomics-remarks-gfx90a.cl 
b/clang/test/CodeGenOpenCL/atomics-remarks-gfx90a.cl
new file mode 100644
index 0..127866e84e051
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/atomics-remarks-gfx90a.cl
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -O0 -triple=amdgcn-amd-amdhsa -target-cpu 
gfx90a \
+// RUN: -Rpass=atomic-expand -S -o - 2>&1 | \
+// RUN: FileCheck %s --check-prefix=REMARK
+
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -O0 -triple=amdgcn-amd-amdhsa -target-cpu 
gfx90a \
+// RUN: -Rpass=atomic-expand -S -emit-llvm -o - 2>&1 | \
+// RUN: FileCheck %s --check-prefix=GFX90A-CAS
+
+// REQUIRES: amdgpu-registered-target
+
+typedef enum memory_order {
+  memory_order_relaxed = __ATOMIC_RELAXED,
+  memory_order_acquire = __ATOMIC_ACQUIRE,
+  memory_order_release = __ATOMIC_RELEASE,
+  memory_order_acq_rel = __ATOMIC_ACQ_REL,
+  memory_order_seq_cst = __ATOMIC_SEQ_CST
+} memory_order;
+
+typedef enum memory_scope {
+  memory_scope_work_item = __OPENCL_MEMORY_SCOPE_WORK_ITEM,
+  memory_scope_work_group = __OPENCL_MEMORY_SCOPE_WORK_GROUP,
+  memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE,
+  memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES,
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
+  memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP
+#endif
+} memory_scope;
+
+// REMARK: remark: A compare and swap loop was generated for an atomic fadd 
operation at workgroup-one-as memory scope [-Rpass=atomic-expand]
+// REMARK: remark: A compare and swap loop was generated for an atomic fadd 
operation at agent-one-as memory scope [-Rpass=atomic-expand]
+// REMARK: remark: A compare and swap loop was generated for an atomic fadd 
operation at one-as memory scope [-Rpass=atomic-expand]
+// REMARK: remark: A compare and swap loop was generated for an atomic fadd 
operation at wavefront-one-as memory scope [-Rpass=atomic-expand]
+// GFX90A-CAS-LABEL: @atomic_cas
+// GFX90A-CAS: atomicrmw fadd float addrspace(1)* {{.*}} 
syncscope("workgroup-one-as") monotonic
+// GFX90A-CAS: atomicrmw fadd float addrspace(1)* {{.*}} 
syncscope("agent-one-as") monotonic
+// GFX90A-CAS: atomicrmw fadd float addrspace(1)* {{.*}} syncscope("one-as") 
monotonic
+// GFX90A-CAS: atomicrmw fadd float addrspace(1)* {{.*}} 
syncscope("wavefront-one-as") monotonic
+float atomic_cas(__global atomic_float *d, float a) {
+  float ret1 = __opencl_atomic_fetch_add(d, a, memory_order_relaxed, 
memory_scope_work_group);
+  float ret2 = __opencl_atomic_fetch_add(d, a, memory_order_relaxed, 
memory_scope_device);
+  float ret3 = __opencl_atomic_fetch_add(d, a, memory_order_relaxed, 
memory_scope_all_svm_devices);
+  float ret4 = __opencl_atomic_fetch_add(d, a, memory_order_relaxed, 
memory_scope_sub_group);
+}

diff  --git a/llvm/lib/CodeGen/AtomicExpandPass.cpp 
b/llvm/lib/CodeGen/AtomicExpandPass.cpp
index 125a3be585cb5..a27d43e43a855 100644
--- a/llvm/lib/CodeGen/AtomicExpandPass.cpp
+++ b/llvm/lib/CodeGen/AtomicExpandPass.cpp
@@ -17,6 +17,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/CodeGen/AtomicExpandUtils.h"
 #include 

[PATCH] D107933: [clang] Expose unreachable fallthrough annotation warning

2021-08-16 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance updated this revision to Diff 366733.
nathanchance marked an inline comment as not done.
nathanchance edited the summary of this revision.
nathanchance added a comment.

- Update commit message (forgot to use `arc diff --edit --verbatim`) [David]


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107933

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaCXX/P30636.cpp
  clang/test/SemaCXX/switch-implicit-fallthrough.cpp


Index: clang/test/SemaCXX/switch-implicit-fallthrough.cpp
===
--- clang/test/SemaCXX/switch-implicit-fallthrough.cpp
+++ clang/test/SemaCXX/switch-implicit-fallthrough.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough 
-Wunreachable-code-fallthrough %s
 
 
 int fallthrough(int n) {
@@ -193,6 +193,26 @@
 ;
   }
 
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunreachable-code-fallthrough"
+  switch (n) {
+  n += 300;
+  [[clang::fallthrough]];  // no warning here
+case 221:
+  return 1;
+  [[clang::fallthrough]];  // no warning here
+case 222:
+  return 2;
+  __attribute__((fallthrough)); // no warning here
+case 223:
+  if (1)
+return 3;
+  __attribute__((fallthrough)); // no warning here
+case 224:
+  n += 400;
+  }
+#pragma clang diagnostic pop
+
   long p = static_cast(n) * n;
   switch (sizeof(p)) {
 case 9:
Index: clang/test/SemaCXX/P30636.cpp
===
--- clang/test/SemaCXX/P30636.cpp
+++ clang/test/SemaCXX/P30636.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough 
-Wunreachable-code-fallthrough %s
 // expected-no-diagnostics
 
 template
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -1125,7 +1125,7 @@
 // unreachable in all instantiations of the template.
 if (!IsTemplateInstantiation)
   S.Diag(AS->getBeginLoc(),
- diag::warn_fallthrough_attr_unreachable);
+ diag::warn_unreachable_fallthrough_attr);
 markFallthroughVisited(AS);
 ++AnnotatedCnt;
 break;
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -682,6 +682,9 @@
 def warn_unreachable_loop_increment : Warning<
   "loop will run at most once (loop increment never executed)">,
   InGroup, DefaultIgnore;
+def warn_unreachable_fallthrough_attr : Warning<
+  "fallthrough annotation in unreachable code">,
+  InGroup, DefaultIgnore;
 def note_unreachable_silence : Note<
   "silence by adding parentheses to mark code as explicitly dead">;
 
@@ -9578,9 +9581,6 @@
   "fallthrough annotation is outside switch statement">;
 def err_fallthrough_attr_invalid_placement : Error<
   "fallthrough annotation does not directly precede switch label">;
-def warn_fallthrough_attr_unreachable : Warning<
-  "fallthrough annotation in unreachable code">,
-  InGroup, DefaultIgnore;
 
 def warn_unreachable_default : Warning<
   "default label in switch which covers all enumeration values">,
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -821,8 +821,10 @@
 //  under separate flags.
 //
 def UnreachableCodeLoopIncrement : 
DiagGroup<"unreachable-code-loop-increment">;
+def UnreachableCodeFallthrough : DiagGroup<"unreachable-code-fallthrough">;
 def UnreachableCode : DiagGroup<"unreachable-code",
-[UnreachableCodeLoopIncrement]>;
+[UnreachableCodeLoopIncrement,
+ UnreachableCodeFallthrough]>;
 def UnreachableCodeBreak : DiagGroup<"unreachable-code-break">;
 def UnreachableCodeReturn : DiagGroup<"unreachable-code-return">;
 def UnreachableCodeAggressive : DiagGroup<"unreachable-code-aggressive",


Index: clang/test/SemaCXX/switch-implicit-fallthrough.cpp
===
--- clang/test/SemaCXX/switch-implicit-fallthrough.cpp
+++ clang/test/SemaCXX/switch-implicit-fallthrough.cpp
@@ -1,4 +1,4 @@

[PATCH] D108151: [NFC][clang] Use X86 Features declaration from X86TargetParser

2021-08-16 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

The order in X86Parser.def is determined by how bits are allocated in to 
feature vector in libgcc. They're not in any priority order that I know of.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108151

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


Re: [clang] 80ed75e - Revert "[NFC] Fix typos"

2021-08-16 Thread David Blaikie via cfe-commits
Ah, thanks for the details!

On Mon, Aug 16, 2021 at 1:26 PM Kostya Kortchinsky 
wrote:

> Apologies.
> As explained in another thread, this was a mistake of mine as I reverted 2
> CLs instead of 1 (mine).
> This was resolved with the original author.
> My own CL ended up breaking some 32-bit builders.
>
> On Mon, Aug 16, 2021 at 1:22 PM David Blaikie  wrote:
>
>> Please include in the commit message a reason for a revert.
>>
>> On Mon, Aug 16, 2021 at 11:14 AM Kostya Kortchinsky via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>>
>>> Author: Kostya Kortchinsky
>>> Date: 2021-08-16T11:13:05-07:00
>>> New Revision: 80ed75e7fb45f9f5fc84ca7cbe258be036015384
>>>
>>> URL:
>>> https://github.com/llvm/llvm-project/commit/80ed75e7fb45f9f5fc84ca7cbe258be036015384
>>> DIFF:
>>> https://github.com/llvm/llvm-project/commit/80ed75e7fb45f9f5fc84ca7cbe258be036015384.diff
>>>
>>> LOG: Revert "[NFC] Fix typos"
>>>
>>> This reverts commit b7425e956be60a73004d7ae5bb37da85872c29fb.
>>>
>>> Added:
>>>
>>>
>>> Modified:
>>> clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
>>> clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
>>> compiler-rt/test/profile/Linux/instrprof-cs.c
>>> llvm/include/llvm/Transforms/Instrumentation.h
>>> llvm/lib/ProfileData/SampleProfReader.cpp
>>>
>>> Removed:
>>>
>>>
>>>
>>>
>>> 
>>> diff  --git
>>> a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
>>> b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
>>> index a13de306eac84..175dfcef0df45 100644
>>> --- a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
>>> +++ b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
>>> @@ -6,7 +6,7 @@
>>>  //
>>>
>>>  
>>> //===--===//
>>>  //
>>> -//  This file defines a CheckObjCInstMethSignature, a flow-insensitive
>>> check
>>> +//  This file defines a CheckObjCInstMethSignature, a flow-insenstive
>>> check
>>>  //  that determines if an Objective-C class interface incorrectly
>>> redefines
>>>  //  the method signature in a subclass.
>>>  //
>>>
>>> diff  --git a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
>>> b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
>>> index dcca8be55e337..90c5583d89691 100644
>>> --- a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
>>> +++ b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
>>> @@ -6,7 +6,7 @@
>>>  //
>>>
>>>  
>>> //===--===//
>>>  //
>>> -//  This file defines a CheckNSError, a flow-insensitive check
>>> +//  This file defines a CheckNSError, a flow-insenstive check
>>>  //  that determines if an Objective-C class interface correctly returns
>>>  //  a non-void return type.
>>>  //
>>>
>>> diff  --git a/compiler-rt/test/profile/Linux/instrprof-cs.c
>>> b/compiler-rt/test/profile/Linux/instrprof-cs.c
>>> index 0ad6f0350c560..d825525a532db 100644
>>> --- a/compiler-rt/test/profile/Linux/instrprof-cs.c
>>> +++ b/compiler-rt/test/profile/Linux/instrprof-cs.c
>>> @@ -8,7 +8,7 @@
>>>  // RUN: %clang_profgen=%t.profraw -o %t.gen.cis -O2 %s
>>>  // RUN: %run %t.gen.cis
>>>  // RUN: llvm-profdata merge -o %t.cis.profdata %t.profraw
>>> -// Check context insensitive profile
>>> +// Check context insenstive profile
>>>  // RUN: %clang_profuse=%t.cis.profdata  -O2 -emit-llvm -S %s -o - |
>>> FileCheck %s --check-prefix=CIS
>>>  int g1 = 1;
>>>  int volatile g2 = 2;
>>>
>>> diff  --git a/llvm/include/llvm/Transforms/Instrumentation.h
>>> b/llvm/include/llvm/Transforms/Instrumentation.h
>>> index 0c822999aecf3..03108bacb0da5 100644
>>> --- a/llvm/include/llvm/Transforms/Instrumentation.h
>>> +++ b/llvm/include/llvm/Transforms/Instrumentation.h
>>> @@ -78,7 +78,7 @@ struct GCOVOptions {
>>>  ModulePass *createGCOVProfilerPass(const GCOVOptions  =
>>> GCOVOptions::getDefault());
>>>
>>> -// PGO Instrumention. Parameter IsCS indicates if this is the context
>>> sensitive
>>> +// PGO Instrumention. Parameter IsCS indicates if this is the context
>>> senstive
>>>  // instrumentation.
>>>  ModulePass *createPGOInstrumentationGenLegacyPass(bool IsCS = false);
>>>  ModulePass *
>>> @@ -138,7 +138,7 @@ struct InstrProfOptions {
>>>  };
>>>
>>>  /// Insert frontend instrumentation based profiling. Parameter IsCS
>>> indicates if
>>> -// this is the context sensitive instrumentation.
>>> +// this is the context senstive instrumentation.
>>>  ModulePass *createInstrProfilingLegacyPass(
>>>  const InstrProfOptions  = InstrProfOptions(), bool IsCS =
>>> false);
>>>
>>>
>>> diff  --git a/llvm/lib/ProfileData/SampleProfReader.cpp
>>> b/llvm/lib/ProfileData/SampleProfReader.cpp
>>> index a801ca1ef36d7..6058eddb13dc7 100644
>>> --- a/llvm/lib/ProfileData/SampleProfReader.cpp
>>> +++ 

Re: [clang] 80ed75e - Revert "[NFC] Fix typos"

2021-08-16 Thread Kostya Kortchinsky via cfe-commits
Apologies.
As explained in another thread, this was a mistake of mine as I reverted 2
CLs instead of 1 (mine).
This was resolved with the original author.
My own CL ended up breaking some 32-bit builders.

On Mon, Aug 16, 2021 at 1:22 PM David Blaikie  wrote:

> Please include in the commit message a reason for a revert.
>
> On Mon, Aug 16, 2021 at 11:14 AM Kostya Kortchinsky via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> Author: Kostya Kortchinsky
>> Date: 2021-08-16T11:13:05-07:00
>> New Revision: 80ed75e7fb45f9f5fc84ca7cbe258be036015384
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/80ed75e7fb45f9f5fc84ca7cbe258be036015384
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/80ed75e7fb45f9f5fc84ca7cbe258be036015384.diff
>>
>> LOG: Revert "[NFC] Fix typos"
>>
>> This reverts commit b7425e956be60a73004d7ae5bb37da85872c29fb.
>>
>> Added:
>>
>>
>> Modified:
>> clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
>> clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
>> compiler-rt/test/profile/Linux/instrprof-cs.c
>> llvm/include/llvm/Transforms/Instrumentation.h
>> llvm/lib/ProfileData/SampleProfReader.cpp
>>
>> Removed:
>>
>>
>>
>>
>> 
>> diff  --git
>> a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
>> b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
>> index a13de306eac84..175dfcef0df45 100644
>> --- a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
>> +++ b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
>> @@ -6,7 +6,7 @@
>>  //
>>
>>  
>> //===--===//
>>  //
>> -//  This file defines a CheckObjCInstMethSignature, a flow-insensitive
>> check
>> +//  This file defines a CheckObjCInstMethSignature, a flow-insenstive
>> check
>>  //  that determines if an Objective-C class interface incorrectly
>> redefines
>>  //  the method signature in a subclass.
>>  //
>>
>> diff  --git a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
>> b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
>> index dcca8be55e337..90c5583d89691 100644
>> --- a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
>> +++ b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
>> @@ -6,7 +6,7 @@
>>  //
>>
>>  
>> //===--===//
>>  //
>> -//  This file defines a CheckNSError, a flow-insensitive check
>> +//  This file defines a CheckNSError, a flow-insenstive check
>>  //  that determines if an Objective-C class interface correctly returns
>>  //  a non-void return type.
>>  //
>>
>> diff  --git a/compiler-rt/test/profile/Linux/instrprof-cs.c
>> b/compiler-rt/test/profile/Linux/instrprof-cs.c
>> index 0ad6f0350c560..d825525a532db 100644
>> --- a/compiler-rt/test/profile/Linux/instrprof-cs.c
>> +++ b/compiler-rt/test/profile/Linux/instrprof-cs.c
>> @@ -8,7 +8,7 @@
>>  // RUN: %clang_profgen=%t.profraw -o %t.gen.cis -O2 %s
>>  // RUN: %run %t.gen.cis
>>  // RUN: llvm-profdata merge -o %t.cis.profdata %t.profraw
>> -// Check context insensitive profile
>> +// Check context insenstive profile
>>  // RUN: %clang_profuse=%t.cis.profdata  -O2 -emit-llvm -S %s -o - |
>> FileCheck %s --check-prefix=CIS
>>  int g1 = 1;
>>  int volatile g2 = 2;
>>
>> diff  --git a/llvm/include/llvm/Transforms/Instrumentation.h
>> b/llvm/include/llvm/Transforms/Instrumentation.h
>> index 0c822999aecf3..03108bacb0da5 100644
>> --- a/llvm/include/llvm/Transforms/Instrumentation.h
>> +++ b/llvm/include/llvm/Transforms/Instrumentation.h
>> @@ -78,7 +78,7 @@ struct GCOVOptions {
>>  ModulePass *createGCOVProfilerPass(const GCOVOptions  =
>> GCOVOptions::getDefault());
>>
>> -// PGO Instrumention. Parameter IsCS indicates if this is the context
>> sensitive
>> +// PGO Instrumention. Parameter IsCS indicates if this is the context
>> senstive
>>  // instrumentation.
>>  ModulePass *createPGOInstrumentationGenLegacyPass(bool IsCS = false);
>>  ModulePass *
>> @@ -138,7 +138,7 @@ struct InstrProfOptions {
>>  };
>>
>>  /// Insert frontend instrumentation based profiling. Parameter IsCS
>> indicates if
>> -// this is the context sensitive instrumentation.
>> +// this is the context senstive instrumentation.
>>  ModulePass *createInstrProfilingLegacyPass(
>>  const InstrProfOptions  = InstrProfOptions(), bool IsCS =
>> false);
>>
>>
>> diff  --git a/llvm/lib/ProfileData/SampleProfReader.cpp
>> b/llvm/lib/ProfileData/SampleProfReader.cpp
>> index a801ca1ef36d7..6058eddb13dc7 100644
>> --- a/llvm/lib/ProfileData/SampleProfReader.cpp
>> +++ b/llvm/lib/ProfileData/SampleProfReader.cpp
>> @@ -53,7 +53,7 @@ using namespace sampleprof;
>>  // For ext-binary format profiles, the flag is set in the summary.
>>  static cl::opt ProfileIsFSDisciminator(
>>  "profile-isfs", cl::Hidden, 

Re: [clang] 80ed75e - Revert "[NFC] Fix typos"

2021-08-16 Thread David Blaikie via cfe-commits
Please include in the commit message a reason for a revert.

On Mon, Aug 16, 2021 at 11:14 AM Kostya Kortchinsky via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Kostya Kortchinsky
> Date: 2021-08-16T11:13:05-07:00
> New Revision: 80ed75e7fb45f9f5fc84ca7cbe258be036015384
>
> URL:
> https://github.com/llvm/llvm-project/commit/80ed75e7fb45f9f5fc84ca7cbe258be036015384
> DIFF:
> https://github.com/llvm/llvm-project/commit/80ed75e7fb45f9f5fc84ca7cbe258be036015384.diff
>
> LOG: Revert "[NFC] Fix typos"
>
> This reverts commit b7425e956be60a73004d7ae5bb37da85872c29fb.
>
> Added:
>
>
> Modified:
> clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
> clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
> compiler-rt/test/profile/Linux/instrprof-cs.c
> llvm/include/llvm/Transforms/Instrumentation.h
> llvm/lib/ProfileData/SampleProfReader.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git
> a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
> b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
> index a13de306eac84..175dfcef0df45 100644
> --- a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
> +++ b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
> @@ -6,7 +6,7 @@
>  //
>
>  
> //===--===//
>  //
> -//  This file defines a CheckObjCInstMethSignature, a flow-insensitive
> check
> +//  This file defines a CheckObjCInstMethSignature, a flow-insenstive
> check
>  //  that determines if an Objective-C class interface incorrectly
> redefines
>  //  the method signature in a subclass.
>  //
>
> diff  --git a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
> b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
> index dcca8be55e337..90c5583d89691 100644
> --- a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
> +++ b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
> @@ -6,7 +6,7 @@
>  //
>
>  
> //===--===//
>  //
> -//  This file defines a CheckNSError, a flow-insensitive check
> +//  This file defines a CheckNSError, a flow-insenstive check
>  //  that determines if an Objective-C class interface correctly returns
>  //  a non-void return type.
>  //
>
> diff  --git a/compiler-rt/test/profile/Linux/instrprof-cs.c
> b/compiler-rt/test/profile/Linux/instrprof-cs.c
> index 0ad6f0350c560..d825525a532db 100644
> --- a/compiler-rt/test/profile/Linux/instrprof-cs.c
> +++ b/compiler-rt/test/profile/Linux/instrprof-cs.c
> @@ -8,7 +8,7 @@
>  // RUN: %clang_profgen=%t.profraw -o %t.gen.cis -O2 %s
>  // RUN: %run %t.gen.cis
>  // RUN: llvm-profdata merge -o %t.cis.profdata %t.profraw
> -// Check context insensitive profile
> +// Check context insenstive profile
>  // RUN: %clang_profuse=%t.cis.profdata  -O2 -emit-llvm -S %s -o - |
> FileCheck %s --check-prefix=CIS
>  int g1 = 1;
>  int volatile g2 = 2;
>
> diff  --git a/llvm/include/llvm/Transforms/Instrumentation.h
> b/llvm/include/llvm/Transforms/Instrumentation.h
> index 0c822999aecf3..03108bacb0da5 100644
> --- a/llvm/include/llvm/Transforms/Instrumentation.h
> +++ b/llvm/include/llvm/Transforms/Instrumentation.h
> @@ -78,7 +78,7 @@ struct GCOVOptions {
>  ModulePass *createGCOVProfilerPass(const GCOVOptions  =
> GCOVOptions::getDefault());
>
> -// PGO Instrumention. Parameter IsCS indicates if this is the context
> sensitive
> +// PGO Instrumention. Parameter IsCS indicates if this is the context
> senstive
>  // instrumentation.
>  ModulePass *createPGOInstrumentationGenLegacyPass(bool IsCS = false);
>  ModulePass *
> @@ -138,7 +138,7 @@ struct InstrProfOptions {
>  };
>
>  /// Insert frontend instrumentation based profiling. Parameter IsCS
> indicates if
> -// this is the context sensitive instrumentation.
> +// this is the context senstive instrumentation.
>  ModulePass *createInstrProfilingLegacyPass(
>  const InstrProfOptions  = InstrProfOptions(), bool IsCS =
> false);
>
>
> diff  --git a/llvm/lib/ProfileData/SampleProfReader.cpp
> b/llvm/lib/ProfileData/SampleProfReader.cpp
> index a801ca1ef36d7..6058eddb13dc7 100644
> --- a/llvm/lib/ProfileData/SampleProfReader.cpp
> +++ b/llvm/lib/ProfileData/SampleProfReader.cpp
> @@ -53,7 +53,7 @@ using namespace sampleprof;
>  // For ext-binary format profiles, the flag is set in the summary.
>  static cl::opt ProfileIsFSDisciminator(
>  "profile-isfs", cl::Hidden, cl::init(false),
> -cl::desc("Profile uses flow sensitive discriminators"));
> +cl::desc("Profile uses flow senstive discriminators"));
>
>  /// Dump the function profile for \p FName.
>  ///
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>

[PATCH] D99551: [clang-offload-wrapper] Add standard notes for ELF offload images

2021-08-16 Thread Vyacheslav Zakharin via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG93d08acaacec: [clang-offload-wrapper] Add standard notes for 
ELF offload images (authored by vzakhari).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99551

Files:
  clang/test/Driver/Inputs/empty-elf-template.yaml
  clang/test/Driver/clang-offload-wrapper.c
  clang/tools/clang-offload-wrapper/CMakeLists.txt
  clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp

Index: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
===
--- clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
+++ clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
@@ -17,27 +17,37 @@
 #include "clang/Basic/Version.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/BinaryFormat/ELF.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/EndianStream.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/ToolOutputFile.h"
+#include "llvm/Support/VCSRevision.h"
 #include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Transforms/Utils/ModuleUtils.h"
 #include 
 #include 
 
+#define OPENMP_OFFLOAD_IMAGE_VERSION "1.0"
+
 using namespace llvm;
+using namespace llvm::object;
 
 static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
 
@@ -60,6 +70,12 @@
cl::desc("Target triple for the output module"),
cl::value_desc("triple"), cl::cat(ClangOffloadWrapperCategory));
 
+static cl::opt SaveTemps(
+"save-temps",
+cl::desc("Save temporary files that may be produced by the tool. "
+ "This option forces print-out of the temporary files' names."),
+cl::Hidden);
+
 namespace {
 
 class BinaryWrapper {
@@ -70,6 +86,15 @@
   StructType *ImageTy = nullptr;
   StructType *DescTy = nullptr;
 
+  std::string ToolName;
+  std::string ObjcopyPath;
+  // Temporary file names that may be created during adding notes
+  // to ELF offload images. Use -save-temps to keep them and also
+  // see their names. A temporary file's name includes the name
+  // of the original input ELF image, so you can easily match
+  // them, if you have multiple inputs.
+  std::vector TempFiles;
+
 private:
   IntegerType *getSizeTTy() {
 switch (M.getDataLayout().getPointerTypeSize(Type::getInt8PtrTy(C))) {
@@ -294,8 +319,61 @@
   }
 
 public:
-  BinaryWrapper(StringRef Target) : M("offload.wrapper.object", C) {
+  BinaryWrapper(StringRef Target, StringRef ToolName)
+  : M("offload.wrapper.object", C), ToolName(ToolName) {
 M.setTargetTriple(Target);
+// Look for llvm-objcopy in the same directory, from which
+// clang-offload-wrapper is invoked. This helps OpenMP offload
+// LIT tests.
+
+// This just needs to be some symbol in the binary; C++ doesn't
+// allow taking the address of ::main however.
+void *P = (void *)(intptr_t)
+std::string COWPath = sys::fs::getMainExecutable(ToolName.str().c_str(), P);
+if (!COWPath.empty()) {
+  auto COWDir = sys::path::parent_path(COWPath);
+  ErrorOr ObjcopyPathOrErr =
+  sys::findProgramByName("llvm-objcopy", {COWDir});
+  if (ObjcopyPathOrErr) {
+ObjcopyPath = *ObjcopyPathOrErr;
+return;
+  }
+
+  // Otherwise, look through PATH environment.
+}
+
+ErrorOr ObjcopyPathOrErr =
+sys::findProgramByName("llvm-objcopy");
+if (!ObjcopyPathOrErr) {
+  WithColor::warning(errs(), ToolName)
+  << "cannot find llvm-objcopy[.exe] in PATH; ELF notes cannot be "
+ "added.\n";
+  return;
+}
+
+ObjcopyPath = *ObjcopyPathOrErr;
+  }
+
+  ~BinaryWrapper() {
+if (TempFiles.empty())
+  return;
+
+StringRef ToolNameRef(ToolName);
+auto warningOS = [ToolNameRef]() -> raw_ostream & {
+  return WithColor::warning(errs(), ToolNameRef);
+};
+
+for (auto  : TempFiles) {
+  if (SaveTemps) {
+warningOS() << "keeping temporary file " << F << "\n";
+continue;
+  }
+
+  auto EC = sys::fs::remove(F, false);
+  if (EC)
+warningOS() << "cannot remove temporary file " << F << ": "
+<< EC.message().c_str() << "\n";
+}
   }
 
   const Module (ArrayRef> Binaries) {
@@ -305,6 

[clang] 93d08ac - [clang-offload-wrapper] Add standard notes for ELF offload images

2021-08-16 Thread Vyacheslav Zakharin via cfe-commits

Author: Vyacheslav Zakharin
Date: 2021-08-16T13:09:01-07:00
New Revision: 93d08acaacec951dbb302f77eeae51974985b6b2

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

LOG: [clang-offload-wrapper] Add standard notes for ELF offload images

The patch adds ELF notes into SHT_NOTE sections of ELF offload images
passed to clang-offload-wrapper.

The new notes use a null-terminated "LLVMOMPOFFLOAD" note name.
There are currently three types of notes:

VERSION: a string (not null-terminated) representing the ELF offload
image structure. The current version '1.0' does not put any restrictions
on the structure of the image. If we ever need to come up with a common
structure for ELF offload images (e.g. to be able to analyze the images
in libomptarget in some standard way), then we will introduce new versions.

PRODUCER: a vendor specific name of the producing toolchain.
Upstream LLVM uses "LLVM" (not null-terminated).

PRODUCER_VERSION: a vendor specific version of the producing toolchain.
Upstream LLVM uses LLVM_VERSION_STRING with optional  LLVM_REVISION.

All three notes are not mandatory currently.

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

Added: 
clang/test/Driver/Inputs/empty-elf-template.yaml

Modified: 
clang/test/Driver/clang-offload-wrapper.c
clang/tools/clang-offload-wrapper/CMakeLists.txt
clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp

Removed: 




diff  --git a/clang/test/Driver/Inputs/empty-elf-template.yaml 
b/clang/test/Driver/Inputs/empty-elf-template.yaml
new file mode 100644
index 0..f77de07a430f6
--- /dev/null
+++ b/clang/test/Driver/Inputs/empty-elf-template.yaml
@@ -0,0 +1,5 @@
+--- !ELF
+FileHeader:
+  Class: ELFCLASS[[BITS]]
+  Data:  ELFDATA2[[ENCODING]]
+  Type:  ET_REL

diff  --git a/clang/test/Driver/clang-offload-wrapper.c 
b/clang/test/Driver/clang-offload-wrapper.c
index 9a36559e34dd7..c671d88209744 100644
--- a/clang/test/Driver/clang-offload-wrapper.c
+++ b/clang/test/Driver/clang-offload-wrapper.c
@@ -19,9 +19,10 @@
 //
 // Check bitcode produced by the wrapper tool.
 //
-// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.bc 
%t.tgt
+// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o %t.wrapper.bc 
%t.tgt 2>&1 | FileCheck %s --check-prefix ELF-WARNING
 // RUN: llvm-dis %t.wrapper.bc -o - | FileCheck %s --check-prefix CHECK-IR
 
+// ELF-WARNING: is not an ELF image, so notes cannot be added to it.
 // CHECK-IR: target triple = "x86_64-pc-linux-gnu"
 
 // CHECK-IR-DAG: [[ENTTY:%.+]] = type { i8*, i8*, i{{32|64}}, i32, i32 }
@@ -53,3 +54,24 @@
 // CHECK-IR:   ret void
 
 // CHECK-IR: declare void @__tgt_unregister_lib([[DESCTY]]*)
+
+// Check that clang-offload-wrapper adds LLVMOMPOFFLOAD notes
+// into the ELF offload images:
+// RUN: yaml2obj %S/Inputs/empty-elf-template.yaml -o %t.64le -DBITS=64 
-DENCODING=LSB
+// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o 
%t.wrapper.elf64le.bc %t.64le
+// RUN: llvm-dis %t.wrapper.elf64le.bc -o - | FileCheck %s --check-prefix 
OMPNOTES
+// RUN: yaml2obj %S/Inputs/empty-elf-template.yaml -o %t.64be -DBITS=64 
-DENCODING=MSB
+// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o 
%t.wrapper.elf64be.bc %t.64be
+// RUN: llvm-dis %t.wrapper.elf64be.bc -o - | FileCheck %s --check-prefix 
OMPNOTES
+// RUN: yaml2obj %S/Inputs/empty-elf-template.yaml -o %t.32le -DBITS=32 
-DENCODING=LSB
+// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o 
%t.wrapper.elf32le.bc %t.32le
+// RUN: llvm-dis %t.wrapper.elf32le.bc -o - | FileCheck %s --check-prefix 
OMPNOTES
+// RUN: yaml2obj %S/Inputs/empty-elf-template.yaml -o %t.32be -DBITS=32 
-DENCODING=MSB
+// RUN: clang-offload-wrapper -target=x86_64-pc-linux-gnu -o 
%t.wrapper.elf32be.bc %t.32be
+// RUN: llvm-dis %t.wrapper.elf32be.bc -o - | FileCheck %s --check-prefix 
OMPNOTES
+
+// There is no clean way for extracting the offload image
+// from the object file currently, so try to find
+// the inserted ELF notes in the device image variable's
+// initializer:
+// OMPNOTES: @{{.+}} = internal unnamed_addr constant [{{[0-9]+}} x i8] 
c"{{.*}}LLVMOMPOFFLOAD{{.*}}LLVMOMPOFFLOAD{{.*}}LLVMOMPOFFLOAD{{.*}}"

diff  --git a/clang/tools/clang-offload-wrapper/CMakeLists.txt 
b/clang/tools/clang-offload-wrapper/CMakeLists.txt
index 8bcb46267a37c..144edf5ab60c0 100644
--- a/clang/tools/clang-offload-wrapper/CMakeLists.txt
+++ b/clang/tools/clang-offload-wrapper/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(LLVM_LINK_COMPONENTS BitWriter Core Support TransformUtils)
+set(LLVM_LINK_COMPONENTS BitWriter Core Object Support TransformUtils)
 
 add_clang_tool(clang-offload-wrapper
   ClangOffloadWrapper.cpp

diff  --git a/clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp 

[PATCH] D106891: [Remarks] Emit optimization remarks for atomics generating CAS loop

2021-08-16 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

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


[PATCH] D107933: [clang] Expose unreachable fallthrough annotation warning

2021-08-16 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Patch description probably needs an update - looks like it's out of date ("Add 
-Wimplicit-fallthrough-unreachable, which is default enabled with 
-Wimplicit-fallthrough" should read, I guess "Add 
-Wunreachable-code-fallthrough, which is default enabled with 
-Wunreachable-code" - also, I might avoid using the "default enabled" as it may 
lead to some confusion/sound like it's suggesting that "this subwarning is on 
by default as it's grouped under this other on-by-default warning", which isn't 
the case - maybe "which is enabled with -Wunreachable-code" would suffice? or 
"which is part of the -Wunreachable-code group")


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107933

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


[PATCH] D106030: [Clang] add support for error+warning fn attrs

2021-08-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 366717.
nickdesaulniers added a comment.

- reorder diag vs note


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106030

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-error.c
  clang/test/CodeGen/attr-warning.c
  clang/test/Frontend/backend-attribute-error-warning-optimize.c
  clang/test/Frontend/backend-attribute-error-warning.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Misc/serialized-diags-driver.c
  clang/test/Sema/attr-error.c
  clang/test/Sema/attr-warning.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/test/CodeGen/X86/attr-dontcall.ll
  llvm/test/ThinLTO/X86/dontcall.ll

Index: llvm/test/ThinLTO/X86/dontcall.ll
===
--- /dev/null
+++ llvm/test/ThinLTO/X86/dontcall.ll
@@ -0,0 +1,33 @@
+; RUN: split-file %s %t
+; RUN: opt -module-summary %t/a.s -o %t/a.bc
+; RUN: opt -module-summary %t/b.s -o %t/b.bc
+; RUN: not llvm-lto2 run %t/a.bc %t/b.bc -o %t/out -save-temps 2>&1 \
+; RUN:   -r=%t/a.bc,callee,px \
+; RUN:   -r=%t/b.bc,callee,x  \
+; RUN:   -r=%t/b.bc,caller,px
+
+; TODO: As part of LTO, we check that types match, but *we don't yet check that
+; attributes match!!! What should happen if we remove "dontcall" from the
+; definition or declaration of @callee?
+
+; CHECK: call to callee marked "dontcall"
+
+;--- a.s
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @callee() "dontcall" noinline {
+  ret i32 42
+}
+
+;--- b.s
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare i32 @callee() "dontcall"
+
+define i32 @caller() {
+entry:
+  %0 = call i32 @callee()
+  ret i32 %0
+}
Index: llvm/test/CodeGen/X86/attr-dontcall.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/attr-dontcall.ll
@@ -0,0 +1,11 @@
+; RUN: not llc -global-isel=0 -fast-isel=0 -stop-after=finalize-isel %s 2>&1 | FileCheck %s
+; RUN: not llc -global-isel=0 -fast-isel=1 -stop-after=finalize-isel %s 2>&1 | FileCheck %s
+; RUN: not llc -global-isel=1 -fast-isel=0 -stop-after=irtranslator %s 2>&1 | FileCheck %s
+
+declare void @foo() "dontcall"
+define void @bar() {
+  call void @foo()
+  ret void
+}
+
+; CHECK: error: call to foo marked "dontcall"
Index: llvm/lib/IR/DiagnosticInfo.cpp
===
--- llvm/lib/IR/DiagnosticInfo.cpp
+++ llvm/lib/IR/DiagnosticInfo.cpp
@@ -401,3 +401,7 @@
 
 void OptimizationRemarkAnalysisFPCommute::anchor() {}
 void OptimizationRemarkAnalysisAliasing::anchor() {}
+
+void DiagnosticInfoDontCall::print(DiagnosticPrinter ) const {
+  DP << "call to " << getFunctionName() << " marked \"dontcall\"";
+}
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -69,6 +69,7 @@
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GetElementPtrTypeIterator.h"
 #include "llvm/IR/InlineAsm.h"
@@ -7945,6 +7946,15 @@
   }
 
   if (Function *F = I.getCalledFunction()) {
+if (F->hasFnAttribute("dontcall")) {
+  unsigned LocCookie = 0;
+  if (MDNode *MD = I.getMetadata("srcloc"))
+LocCookie =
+mdconst::extract(MD->getOperand(0))->getZExtValue();
+  DiagnosticInfoDontCall D(F->getName(), LocCookie);
+  DAG.getContext()->diagnose(D);
+}
+
 if (F->isDeclaration()) {
   // Is this an LLVM intrinsic or a target-specific intrinsic?
   unsigned IID = F->getIntrinsicID();
Index: llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -75,6 +75,7 @@
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/IR/DebugLoc.h"
 #include "llvm/IR/DerivedTypes.h"
+#include 

[PATCH] D108150: [Remarks] Emit optimization remarks for atomics generating hardware instructions

2021-08-16 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec added a comment.

- Add [AMDGPU] to the title.
- Rebase on top of D106891 .
- Add tests to atomics-remarks-gfx90a.ll as well, including LDS with matching 
and non-matching rounding mode.




Comment at: llvm/lib/Target/AMDGPU/SIISelLowering.cpp:12194
   if (!Ty->isDoubleTy())
-return AtomicExpansionKind::None;
+return reportUnsafeHWInst(RMW, AtomicExpansionKind::None);
 

This is safe.



Comment at: llvm/lib/Target/AMDGPU/SIISelLowering.cpp:12200
   .getValueAsString() == "true")
- ? AtomicExpansionKind::None
+ ? reportUnsafeHWInst(RMW, AtomicExpansionKind::None)
  : AtomicExpansionKind::CmpXChg;

This is safe if `fpModeMatchesGlobalFPAtomicMode(RMW)` returned true and unsafe 
if not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108150

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


[PATCH] D104285: [analyzer][AST] Retrieve value by direct index from list initialization of constant array declaration.

2021-08-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D104285#2947255 , @ASDenysPetrov 
wrote:

> In D104285#2943449 , @aaron.ballman 
> wrote:
>
>> One thing I think is worth asking in this thread is whether what you're 
>> analyzing is undefined behavior?
>
> Technically you are right. Every exit out of an array extent is UB according 
> to the Standard.

At least in C++; I'd have to double-check for C.

> But in practice we can rely on the fact that multidimensional arrays have a 
> continuous layout in memory on stack.

"But in practice we can rely on " is a very dangerous 
assumption for users to make, and I think we shouldn't codify that in the 
design of the static analyzer. We might be able to make that guarantee for 
*clang*, but we can't make that guarantee for all implementations. One of the 
big uses of a static analyzer is with pointing out UB due to portability 
concerns.

> Also every compiler treats `int[2][2]` and `int**` differently. E.g.:
>
>   int arr[6][7];
>   arr[2][3]; // *(arr + (2*7 + 3)) = *(arr + 17)
>   
>   int *ptr = arr;
>   ptr[17]; //  *(arr + 17)
>   
>   int **ptr;
>   ptr[2][3] // *(*(ptr + 2) + 3)
>
> Many engineers expoit this fact and treat multidimensional arrays on stack 
> through a raw pointer (`(int*)arr`). We can foresee their intentions and 
> treat a multidimensional array as a single one instead of a warning about UB.

We can do that only if we're convinced that's a sound static analysis (and I'm 
not convinced). Optimizers can optimize based on the inference that code must 
be UB free, so I worry that there are optimization situations where the 
analyzer will fail to warn the user because we're assuming this is safe based 
purely on memory layout. However, things like TBAA, vectorization, etc may have 
a different analysis than strictly the memory layout.

>> And when you turn some of these examples into constant expressions, we 
>> reject them based on the bounds. e.g., https://godbolt.org/z/nYPcY14a8
>
> Yes, when we use expicit constants there we can catch such a warning, because 
> AST parser can timely recognize the issue. The parser is not smart enough to 
> treat variables. Static Analyzer is in charge of this and executes after the 
> parser.

I'm aware.

> I think AST parser shall also ignore the Standard in this particular case 
> with an eye on a real use cases and developers' intentions.

It would be a bug in Clang to do so; the standard requires a diagnostic if a 
constant evaluation cannot be performed due to UB: 
http://eel.is/c++draft/expr.const#5.7

> As you can see there is a bit modified version which doesn't emit the warning 
> https://godbolt.org/z/Mdhhe6Eo9.

Correct; I would not expect Clang to diagnose that because it doesn't require 
constant evaluation. I was pointing out the `constexpr` diagnostics because it 
demonstrates that this code has undefined behavior and you're modelling it as 
though the behavior were concretely defined.


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

https://reviews.llvm.org/D104285

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-08-16 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

In D96033#2944625 , @phosek wrote:

> In D96033#298 , @leonardchan 
> wrote:
>
>> We're still hitting the OOMs when building clang-repl with LTO even with 
>> `-DLLVM_PARALLEL_LINK_JOBS=32`. While we don't build this target explicitly 
>> in our toolchain, it is built when running tests via `stage2-check-clang`. 
>> Is there perhaps a simple cmake flag that allows us to not run clang-repl 
>> tests so we don't build it?
>
> To clarify, this is on a machine with 512GB RAM.

@leonardchan, @phosek, I am not aware of such flag. Do you know how much memory 
does LTO + clang-repl consume and would it make sense to ping some of the LTO 
folks for their advice?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96033

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


[PATCH] D106030: [Clang] add support for error+warning fn attrs

2021-08-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Sema/attr-error.c:31-32
+
+__attribute__((error("foo"))) int bad5(void);   // expected-error {{'error' 
and 'warning' attributes are not compatible}}
+__attribute__((warning("foo"))) int bad5(void); // expected-note {{conflicting 
attribute is here}}
+

nickdesaulniers wrote:
> aaron.ballman wrote:
> > I think the diagnostic order is backwards here. The first declaration is 
> > where I'd expect the note and the second declaration is where I'd expect 
> > the error. (The idea is: the first declaration adds an attribute to the 
> > decl, so the redeclaration is what introduces the conflict and so that's 
> > where the error should live.) As an example: https://godbolt.org/z/bjGTWxYvh
> I'm not sure how to reconcile this. Looking at `bad4` above (different case 
> than `bad5`), the diagnostic we get is:
> ```
> /tmp/y.c:1:30: error: 'warning' and 'error' attributes are not compatible
> __attribute__((error("foo"), warning("foo")))
>  ^
> /tmp/y.c:1:16: note: conflicting attribute is here
> __attribute__((error("foo"), warning("foo")))
>^
> 1 error generated.
> ```
> which looks correct to me. If I flip the order these are diagnosed in, that 
> fixes `bad5` but if I flip around the ordering:
> ```
> --- a/clang/lib/Sema/SemaDeclAttr.cpp
> +++ b/clang/lib/Sema/SemaDeclAttr.cpp
> -  Diag(CI.getLoc(), diag::err_attributes_are_not_compatible) << CI << EA;
> -  Diag(EA->getLocation(), diag::note_conflicting_attribute);
> +  Diag(EA->getLocation(), diag::err_attributes_are_not_compatible)
> +  << CI << EA;
> +  Diag(CI.getLoc(), diag::note_conflicting_attribute);
> ```
> Then `bad4` doesn't look quite correct.
> ```
> /tmp/y.c:1:16: error: 'warning' and 'error' attributes are not compatible
> __attribute__((error("foo"), warning("foo")))
>^
> /tmp/y.c:1:30: note: conflicting attribute is here
> __attribute__((error("foo"), warning("foo")))
>  ^
> ```
> Perhaps in the callers of `handleErrorAttr` I'm confusing which `Decl` is the 
> "new" vs the "old?"
> which looks correct to me.

That also looks correct to me; the second attribute is the diagnostic and the 
first attribute is the note.

> Perhaps in the callers of handleErrorAttr I'm confusing which Decl is the 
> "new" vs the "old?"

Huh, this is rather strange. The logic you're using is basically the same as 
`checkAttrMutualExclusion()`, just with extra work to figure out which kind of 
attribute you're dealing with. I'm not seeing what's causing the order to be 
different when I reason my way through the code. Perhaps in the `bad4()` case, 
are we somehow processing the attributes in reverse order?

FWIW, at the end of the day, we can live with the diagnostic in either 
situation, even if they're a bit strange. I think the merge behavior (two 
different decls) is more important to get right because that's going to be the 
far more common scenario to see the diagnostic in. If it turns out that it's a 
systemic issue (or just gnarly to figure out), it won't block this review. We 
can always improve the behavior in a follow-up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106030

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


[PATCH] D108151: [NFC][clang] Use X86 Features declaration from X86TargetParser

2021-08-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Are these in the same order in X86TargetParser.Def?  Can we make some comment 
in that file to make sure that we keep them in the order (see comment in 
original x86Target.def)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108151

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


[PATCH] D108151: [NFC][clang] Use X86 Features declaration from X86TargetParser

2021-08-16 Thread Andrei Elovikov via Phabricator via cfe-commits
a.elovikov created this revision.
a.elovikov added reviewers: erichkeane, craig.topper.
Herald added a subscriber: pengfei.
a.elovikov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

...instead of redeclaring them in clang's own X86Target.def. They were already
required to be in sync (IIUC), so no reason to maintain two identical lists.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108151

Files:
  clang/include/clang/Basic/X86Target.def
  clang/lib/Basic/Targets/X86.cpp


Index: clang/lib/Basic/Targets/X86.cpp
===
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -1057,17 +1057,13 @@
 
 static unsigned getFeaturePriority(llvm::X86::ProcessorFeatures Feat) {
   enum class FeatPriority {
-#define FEATURE(FEAT) FEAT,
-#include "clang/Basic/X86Target.def"
+#define X86_FEATURE_COMPAT(ENUM, STR) ENUM,
+#include "llvm/Support/X86TargetParser.def"
+MAX
   };
-  switch (Feat) {
-#define FEATURE(FEAT)  
\
-  case llvm::X86::FEAT:
\
-return static_cast(FeatPriority::FEAT);
-#include "clang/Basic/X86Target.def"
-  default:
-llvm_unreachable("No Feature Priority for non-CPUSupports Features");
-  }
+  assert(Feat < static_cast(FeatPriority::MAX) &&
+ "No Feature Priority for non-CPUSupports Features");
+  return static_cast(Feat);
 }
 
 unsigned X86TargetInfo::multiVersionSortPriority(StringRef Name) const {
Index: clang/include/clang/Basic/X86Target.def
===
--- clang/include/clang/Basic/X86Target.def
+++ clang/include/clang/Basic/X86Target.def
@@ -11,10 +11,6 @@
 //
 
//===--===//
 
-#ifndef FEATURE
-#define FEATURE(ENUM)
-#endif
-
 #ifndef CPU_SPECIFIC
 #define CPU_SPECIFIC(NAME, MANGLING, FEATURES)
 #endif
@@ -23,50 +19,6 @@
 #define CPU_SPECIFIC_ALIAS(NEW_NAME, NAME)
 #endif
 
-// List of CPU Supports features in order.  These need to remain in the order
-// required by attribute 'target' checking.  Note that not all are supported/
-// prioritized by GCC, so synchronization with GCC's implementation may require
-// changing some existing values.
-FEATURE(FEATURE_CMOV)
-FEATURE(FEATURE_MMX)
-FEATURE(FEATURE_SSE)
-FEATURE(FEATURE_SSE2)
-FEATURE(FEATURE_SSE3)
-FEATURE(FEATURE_SSSE3)
-FEATURE(FEATURE_SSE4_A)
-FEATURE(FEATURE_SSE4_1)
-FEATURE(FEATURE_SSE4_2)
-FEATURE(FEATURE_POPCNT)
-FEATURE(FEATURE_AES)
-FEATURE(FEATURE_PCLMUL)
-FEATURE(FEATURE_AVX)
-FEATURE(FEATURE_BMI)
-FEATURE(FEATURE_FMA4)
-FEATURE(FEATURE_XOP)
-FEATURE(FEATURE_FMA)
-FEATURE(FEATURE_BMI2)
-FEATURE(FEATURE_AVX2)
-FEATURE(FEATURE_AVX512F)
-FEATURE(FEATURE_AVX512VL)
-FEATURE(FEATURE_AVX512BW)
-FEATURE(FEATURE_AVX512DQ)
-FEATURE(FEATURE_AVX512CD)
-FEATURE(FEATURE_AVX512ER)
-FEATURE(FEATURE_AVX512PF)
-FEATURE(FEATURE_AVX512VBMI)
-FEATURE(FEATURE_AVX512IFMA)
-FEATURE(FEATURE_AVX5124VNNIW)
-FEATURE(FEATURE_AVX5124FMAPS)
-FEATURE(FEATURE_AVX512VPOPCNTDQ)
-FEATURE(FEATURE_AVX512VBMI2)
-FEATURE(FEATURE_GFNI)
-FEATURE(FEATURE_VPCLMULQDQ)
-FEATURE(FEATURE_AVX512VNNI)
-FEATURE(FEATURE_AVX512BITALG)
-FEATURE(FEATURE_AVX512BF16)
-FEATURE(FEATURE_AVX512VP2INTERSECT)
-
-
 // FIXME: When commented out features are supported in LLVM, enable them here.
 CPU_SPECIFIC("generic", 'A', "")
 CPU_SPECIFIC("pentium", 'B', "")
@@ -107,4 +59,3 @@
 #undef CPU_SPECIFIC
 #undef PROC_64_BIT
 #undef PROC_32_BIT
-#undef FEATURE


Index: clang/lib/Basic/Targets/X86.cpp
===
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -1057,17 +1057,13 @@
 
 static unsigned getFeaturePriority(llvm::X86::ProcessorFeatures Feat) {
   enum class FeatPriority {
-#define FEATURE(FEAT) FEAT,
-#include "clang/Basic/X86Target.def"
+#define X86_FEATURE_COMPAT(ENUM, STR) ENUM,
+#include "llvm/Support/X86TargetParser.def"
+MAX
   };
-  switch (Feat) {
-#define FEATURE(FEAT)  \
-  case llvm::X86::FEAT:\
-return static_cast(FeatPriority::FEAT);
-#include "clang/Basic/X86Target.def"
-  default:
-llvm_unreachable("No Feature Priority for non-CPUSupports Features");
-  }
+  assert(Feat < static_cast(FeatPriority::MAX) &&
+ "No Feature Priority for non-CPUSupports Features");
+  return static_cast(Feat);
 }
 
 unsigned X86TargetInfo::multiVersionSortPriority(StringRef Name) const {
Index: clang/include/clang/Basic/X86Target.def
===
--- clang/include/clang/Basic/X86Target.def
+++ clang/include/clang/Basic/X86Target.def
@@ -11,10 +11,6 @@
 //
 

[PATCH] D108150: [Remarks] Emit optimization remarks for atomics generating hardware instructions

2021-08-16 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 created this revision.
gandhi21299 added reviewers: rampitec, arsenm, b-sumner.
Herald added subscribers: foad, kerbowa, jfb, hiraditya, Anastasia, nhaehnle, 
jvesely.
gandhi21299 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, wdng.
Herald added projects: clang, LLVM.

- produce remarks when atomic instructions are expanded into hardware 
instructions in SIISelLowering.cpp
- an OpenCL test containing both IR-level and ISA level checks
- currently only support for atomic fadd


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108150

Files:
  clang/test/CodeGenOpenCL/atomics-remarks-gfx90a.cl
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Index: llvm/lib/Target/AMDGPU/SIISelLowering.cpp
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -19,6 +19,7 @@
 #include "SIRegisterInfo.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/LegacyDivergenceAnalysis.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/CodeGen/Analysis.h"
 #include "llvm/CodeGen/FunctionLoweringInfo.h"
@@ -12118,6 +12119,26 @@
   return DenormMode == DenormalMode::getIEEE();
 }
 
+static TargetLowering::AtomicExpansionKind
+reportUnsafeHWInst(AtomicRMWInst *RMW,
+   TargetLowering::AtomicExpansionKind Kind) {
+  OptimizationRemarkEmitter ORE(RMW->getFunction());
+  LLVMContext  = RMW->getFunction()->getContext();
+  SmallVector SSNs;
+  Ctx.getSyncScopeNames(SSNs);
+  auto MemScope = SSNs[RMW->getSyncScopeID()].empty()
+  ? "system"
+  : SSNs[RMW->getSyncScopeID()];
+  ORE.emit([&]() {
+return OptimizationRemark(DEBUG_TYPE, "Passed", RMW->getFunction())
+   << "Hardware instruction generated for atomic "
+   << RMW->getOperationName(RMW->getOperation())
+   << " operation at memory scope " << MemScope
+   << " due to an unsafe request.";
+  });
+  return Kind;
+}
+
 TargetLowering::AtomicExpansionKind
 SITargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *RMW) const {
   switch (RMW->getOperation()) {
@@ -12154,14 +12175,15 @@
 SSID == RMW->getContext().getOrInsertSyncScopeID("one-as"))
   return AtomicExpansionKind::CmpXChg;
 
-return AtomicExpansionKind::None;
+return reportUnsafeHWInst(RMW, AtomicExpansionKind::None);
   }
 
   if (AS == AMDGPUAS::FLAT_ADDRESS)
 return AtomicExpansionKind::CmpXChg;
 
-  return RMW->use_empty() ? AtomicExpansionKind::None
-  : AtomicExpansionKind::CmpXChg;
+  return RMW->use_empty()
+ ? reportUnsafeHWInst(RMW, AtomicExpansionKind::None)
+ : AtomicExpansionKind::CmpXChg;
 }
 
 // DS FP atomics do repect the denormal mode, but the rounding mode is fixed
@@ -12169,13 +12191,13 @@
 // The only exception is DS_ADD_F64 which never flushes regardless of mode.
 if (AS == AMDGPUAS::LOCAL_ADDRESS && Subtarget->hasLDSFPAtomics()) {
   if (!Ty->isDoubleTy())
-return AtomicExpansionKind::None;
+return reportUnsafeHWInst(RMW, AtomicExpansionKind::None);
 
   return (fpModeMatchesGlobalFPAtomicMode(RMW) ||
   RMW->getFunction()
   ->getFnAttribute("amdgpu-unsafe-fp-atomics")
   .getValueAsString() == "true")
- ? AtomicExpansionKind::None
+ ? reportUnsafeHWInst(RMW, AtomicExpansionKind::None)
  : AtomicExpansionKind::CmpXChg;
 }
 
Index: clang/test/CodeGenOpenCL/atomics-remarks-gfx90a.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/atomics-remarks-gfx90a.cl
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -cl-std=CL2.0 -O0 -triple=amdgcn-amd-amdhsa -target-cpu gfx90a \
+// RUN: -Rpass=si-lower -munsafe-fp-atomics %s -S -o - 2>&1 | \
+// RUN: FileCheck %s --check-prefix=GFX90A-HW-REMARK
+
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -O0 -triple=amdgcn-amd-amdhsa -target-cpu gfx90a \
+// RUN: -Rpass=si-lower -S -emit-llvm -o - 2>&1 | \
+// RUN: FileCheck %s --check-prefix=GFX90A-HW
+
+// REQUIRES: amdgpu-registered-target
+
+typedef enum memory_order {
+  memory_order_relaxed = __ATOMIC_RELAXED,
+  memory_order_acquire = __ATOMIC_ACQUIRE,
+  memory_order_release = __ATOMIC_RELEASE,
+  memory_order_acq_rel = __ATOMIC_ACQ_REL,
+  memory_order_seq_cst = __ATOMIC_SEQ_CST
+} memory_order;
+
+typedef enum memory_scope {
+  memory_scope_work_item = __OPENCL_MEMORY_SCOPE_WORK_ITEM,
+  memory_scope_work_group = __OPENCL_MEMORY_SCOPE_WORK_GROUP,
+  memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE,
+  memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES,
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
+  memory_scope_sub_group = 

[PATCH] D106891: [Remarks] Emit optimization remarks for atomics generating CAS loop

2021-08-16 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added a comment.

Will do, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

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


[PATCH] D106891: [Remarks] Emit optimization remarks for atomics generating CAS loop

2021-08-16 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec accepted this revision.
rampitec added a comment.

LGTM, but please wait for others too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

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


[PATCH] D106891: [Remarks] Emit optimization remarks for atomics generating CAS loop

2021-08-16 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 366683.
gandhi21299 added a comment.

- ORE does not need to be a pointer anymore, it is constructed as local 
variable with this patch as requested by reviewer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

Files:
  clang/test/CodeGenCUDA/atomics-remarks-gfx90a.cu
  clang/test/CodeGenOpenCL/atomics-remarks-gfx90a.cl
  llvm/lib/CodeGen/AtomicExpandPass.cpp
  llvm/test/CodeGen/AMDGPU/atomics-remarks-gfx90a.ll

Index: llvm/test/CodeGen/AMDGPU/atomics-remarks-gfx90a.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/atomics-remarks-gfx90a.ll
@@ -0,0 +1,103 @@
+; RUN: llc -march=amdgcn -mcpu=gfx90a -verify-machineinstrs --pass-remarks=atomic-expand \
+; RUN:  %s -o - 2>&1 | FileCheck %s --check-prefix=GFX90A-CAS
+
+; GFX90A-CAS: A compare and swap loop was generated for an atomic fadd operation at system memory scope
+; GFX90A-CAS: A compare and swap loop was generated for an atomic fadd operation at agent memory scope
+; GFX90A-CAS: A compare and swap loop was generated for an atomic fadd operation at workgroup memory scope
+; GFX90A-CAS: A compare and swap loop was generated for an atomic fadd operation at wavefront memory scope
+; GFX90A-CAS: A compare and swap loop was generated for an atomic fadd operation at singlethread memory scope
+; GFX90A-CAS: A compare and swap loop was generated for an atomic fadd operation at one-as memory scope
+; GFX90A-CAS: A compare and swap loop was generated for an atomic fadd operation at agent-one-as memory scope
+; GFX90A-CAS: A compare and swap loop was generated for an atomic fadd operation at workgroup-one-as memory scope
+; GFX90A-CAS: A compare and swap loop was generated for an atomic fadd operation at wavefront-one-as memory scope
+; GFX90A-CAS: A compare and swap loop was generated for an atomic fadd operation at singlethread-one-as memory scope
+
+; GFX90A-CAS-LABEL: atomic_add_cas:
+; GFX90A-CAS: flat_atomic_cmpswap v3, v[0:1], v[4:5] glc
+; GFX90A-CAS: s_cbranch_execnz
+define dso_local void @atomic_add_cas(float* %p, float %q) {
+entry:
+  %ret = atomicrmw fadd float* %p, float %q monotonic, align 4
+  ret void
+}
+
+; GFX90A-CAS-LABEL: atomic_add_cas_agent:
+; GFX90A-CAS: flat_atomic_cmpswap v3, v[0:1], v[4:5] glc
+; GFX90A-CAS: s_cbranch_execnz
+define dso_local void @atomic_add_cas_agent(float* %p, float %q) {
+entry:
+  %ret = atomicrmw fadd float* %p, float %q syncscope("agent") monotonic, align 4
+  ret void
+}
+
+; GFX90A-CAS-LABEL: atomic_add_cas_workgroup:
+; GFX90A-CAS: flat_atomic_cmpswap v3, v[0:1], v[4:5] glc
+; GFX90A-CAS: s_cbranch_execnz
+define dso_local void @atomic_add_cas_workgroup(float* %p, float %q) {
+entry:
+  %ret = atomicrmw fadd float* %p, float %q syncscope("workgroup") monotonic, align 4
+  ret void
+}
+
+; GFX90A-CAS-LABEL: atomic_add_cas_wavefront:
+; GFX90A-CAS: flat_atomic_cmpswap v3, v[0:1], v[4:5] glc
+; GFX90A-CAS: s_cbranch_execnz
+define dso_local void @atomic_add_cas_wavefront(float* %p, float %q) {
+entry:
+  %ret = atomicrmw fadd float* %p, float %q syncscope("wavefront") monotonic, align 4
+  ret void
+}
+
+; GFX90A-CAS-LABEL: atomic_add_cas_singlethread:
+; GFX90A-CAS: flat_atomic_cmpswap v3, v[0:1], v[4:5] glc
+; GFX90A-CAS: s_cbranch_execnz
+define dso_local void @atomic_add_cas_singlethread(float* %p, float %q) {
+entry:
+  %ret = atomicrmw fadd float* %p, float %q syncscope("singlethread") monotonic, align 4
+  ret void
+}
+
+; GFX90A-CAS-LABEL: atomic_add_cas_one_as:
+; GFX90A-CAS: flat_atomic_cmpswap v3, v[0:1], v[4:5] glc
+; GFX90A-CAS: s_cbranch_execnz
+define dso_local void @atomic_add_cas_one_as(float* %p, float %q) {
+entry:
+  %ret = atomicrmw fadd float* %p, float %q syncscope("one-as") monotonic, align 4
+  ret void
+}
+
+; GFX90A-CAS-LABEL: atomic_add_cas_agent_one_as:
+; GFX90A-CAS: flat_atomic_cmpswap v3, v[0:1], v[4:5] glc
+; GFX90A-CAS: s_cbranch_execnz
+define dso_local void @atomic_add_cas_agent_one_as(float* %p, float %q) {
+entry:
+  %ret = atomicrmw fadd float* %p, float %q syncscope("agent-one-as") monotonic, align 4
+  ret void
+}
+
+; GFX90A-CAS-LABEL: atomic_add_cas_workgroup_one_as:
+; GFX90A-CAS: flat_atomic_cmpswap v3, v[0:1], v[4:5] glc
+; GFX90A-CAS: s_cbranch_execnz
+define dso_local void @atomic_add_cas_workgroup_one_as(float* %p, float %q) {
+entry:
+  %ret = atomicrmw fadd float* %p, float %q syncscope("workgroup-one-as") monotonic, align 4
+  ret void
+}
+
+; GFX90A-CAS-LABEL: atomic_add_cas_wavefront_one_as:
+; GFX90A-CAS: flat_atomic_cmpswap v3, v[0:1], v[4:5] glc
+; GFX90A-CAS: s_cbranch_execnz
+define dso_local void @atomic_add_cas_wavefront_one_as(float* %p, float %q) {
+entry:
+  %ret = atomicrmw fadd float* %p, float %q syncscope("wavefront-one-as") monotonic, align 4
+  ret void
+}
+
+; GFX90A-CAS-LABEL: atomic_add_cas_singlethread_one_as:
+; GFX90A-CAS: 

[PATCH] D108074: [MemorySSA] Remove unnecessary MSSA dependencies

2021-08-16 Thread Nikita Popov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG570c9beb8ebb: [MemorySSA] Remove unnecessary MSSA 
dependencies (authored by nikic).
Herald added subscribers: cfe-commits, ormris, steven_wu.
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D108074?vs=366439=366689#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108074

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Utils/LoopVersioning.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/novect-lcssa-cfg-invalidation.ll

Index: llvm/test/Transforms/LoopVectorize/novect-lcssa-cfg-invalidation.ll
===
--- llvm/test/Transforms/LoopVectorize/novect-lcssa-cfg-invalidation.ll
+++ llvm/test/Transforms/LoopVectorize/novect-lcssa-cfg-invalidation.ll
@@ -13,7 +13,6 @@
 ; CHECK-NOT:   Invalidating analysis: BranchProbabilityAnalysis on novect
 ; CHECK-NOT:   Invalidating analysis: BlockFrequencyAnalysis on novect
 ; CHECK:   Invalidating analysis: DemandedBitsAnalysis on novect
-; CHECK:   Invalidating analysis: MemorySSAAnalysis on novect
 ; CHECK:   Running pass: JumpThreadingPass on novect
 
 ; CHECK:   entry:
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -87,7 +87,6 @@
 #include "llvm/Analysis/LoopAnalysisManager.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/LoopIterator.h"
-#include "llvm/Analysis/MemorySSA.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/Analysis/ProfileSummaryInfo.h"
 #include "llvm/Analysis/ScalarEvolution.h"
@@ -10539,15 +10538,12 @@
 auto  = AM.getResult(F);
 auto  = AM.getResult(F);
 auto  = AM.getResult(F);
-MemorySSA *MSSA = EnableMSSALoopDependency
-  ? (F).getMSSA()
-  : nullptr;
 
 auto  = AM.getResult(F).getManager();
 std::function GetLAA =
 [&](Loop ) -> const LoopAccessInfo & {
   LoopStandardAnalysisResults AR = {AA,  AC,  DT,  LI,  SE,
-TLI, TTI, nullptr, MSSA};
+TLI, TTI, nullptr, nullptr};
   return LAM.getResult(L, AR);
 };
 auto  = AM.getResult(F);
Index: llvm/lib/Transforms/Utils/LoopVersioning.cpp
===
--- llvm/lib/Transforms/Utils/LoopVersioning.cpp
+++ llvm/lib/Transforms/Utils/LoopVersioning.cpp
@@ -14,9 +14,9 @@
 
 #include "llvm/Transforms/Utils/LoopVersioning.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/LoopAccessAnalysis.h"
 #include "llvm/Analysis/LoopInfo.h"
-#include "llvm/Analysis/MemorySSA.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/IR/Dominators.h"
@@ -354,14 +354,11 @@
   auto  = AM.getResult(F);
   auto  = AM.getResult(F);
   auto  = AM.getResult(F);
-  MemorySSA *MSSA = EnableMSSALoopDependency
-? (F).getMSSA()
-: nullptr;
 
   auto  = AM.getResult(F).getManager();
   auto GetLAA = [&](Loop ) -> const LoopAccessInfo & {
 LoopStandardAnalysisResults AR = {AA,  AC,  DT,  LI,  SE,
-  TLI, TTI, nullptr, MSSA};
+  TLI, TTI, nullptr, nullptr};
 return LAM.getResult(L, AR);
   };
 
Index: llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
===
--- llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
+++ llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
@@ -34,7 +34,6 @@
 #include "llvm/Analysis/LoopAccessAnalysis.h"
 #include "llvm/Analysis/LoopAnalysisManager.h"
 #include "llvm/Analysis/LoopInfo.h"
-#include "llvm/Analysis/MemorySSA.h"
 #include "llvm/Analysis/ProfileSummaryInfo.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
@@ -718,15 +717,12 @@
   auto *PSI = MAMProxy.getCachedResult(*F.getParent());
   auto *BFI = (PSI && PSI->hasProfileSummary()) ?
   (F) : nullptr;
-  MemorySSA *MSSA = EnableMSSALoopDependency
-? (F).getMSSA()
-: nullptr;
 
   auto  = AM.getResult(F).getManager();
   bool Changed = eliminateLoadsAcrossLoops(
   F, LI, DT, BFI, PSI, , , [&](Loop ) -> const LoopAccessInfo & {
 LoopStandardAnalysisResults AR = {AA,  AC,  DT,  LI,  SE,
- 

[clang] 570c9be - [MemorySSA] Remove unnecessary MSSA dependencies

2021-08-16 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-08-16T20:40:55+02:00
New Revision: 570c9beb8ebb4bdcc807101518cc36ad5e20797c

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

LOG: [MemorySSA] Remove unnecessary MSSA dependencies

LoopLoadElimination, LoopVersioning and LoopVectorize currently
fetch MemorySSA when construction LoopAccessAnalysis. However,
LoopAccessAnalysis does not actually use MemorySSA and we can pass
nullptr instead.

This saves one MemorySSA calculation in the default pipeline, and
thus improves compile-time.

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

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
llvm/lib/Transforms/Utils/LoopVersioning.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/novect-lcssa-cfg-invalidation.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
index 4651a5d282faf..8f7fc5e9b8411 100644
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -146,7 +146,6 @@
 ; CHECK-O: Running analysis: BranchProbabilityAnalysis on main
 ; CHECK-O: Running analysis: PostDominatorTreeAnalysis on main
 ; CHECK-O: Running analysis: DemandedBitsAnalysis on main
-; CHECK-O: Running analysis: MemorySSAAnalysis on main
 ; CHECK-O: Running pass: LoopLoadEliminationPass on main
 ; CHECK-O: Running pass: InstCombinePass on main
 ; CHECK-O: Running pass: SimplifyCFGPass on main

diff  --git a/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp 
b/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
index aaf586173e442..9c4f18f8e2213 100644
--- a/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
@@ -34,7 +34,6 @@
 #include "llvm/Analysis/LoopAccessAnalysis.h"
 #include "llvm/Analysis/LoopAnalysisManager.h"
 #include "llvm/Analysis/LoopInfo.h"
-#include "llvm/Analysis/MemorySSA.h"
 #include "llvm/Analysis/ProfileSummaryInfo.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
@@ -718,15 +717,12 @@ PreservedAnalyses LoopLoadEliminationPass::run(Function 
,
   auto *PSI = MAMProxy.getCachedResult(*F.getParent());
   auto *BFI = (PSI && PSI->hasProfileSummary()) ?
   (F) : nullptr;
-  MemorySSA *MSSA = EnableMSSALoopDependency
-? (F).getMSSA()
-: nullptr;
 
   auto  = AM.getResult(F).getManager();
   bool Changed = eliminateLoadsAcrossLoops(
   F, LI, DT, BFI, PSI, , , [&](Loop ) -> const LoopAccessInfo & {
 LoopStandardAnalysisResults AR = {AA,  AC,  DT,  LI,  SE,
-  TLI, TTI, nullptr, MSSA};
+  TLI, TTI, nullptr, nullptr};
 return LAM.getResult(L, AR);
   });
 

diff  --git a/llvm/lib/Transforms/Utils/LoopVersioning.cpp 
b/llvm/lib/Transforms/Utils/LoopVersioning.cpp
index 8a89158788cf8..14439796fb4ae 100644
--- a/llvm/lib/Transforms/Utils/LoopVersioning.cpp
+++ b/llvm/lib/Transforms/Utils/LoopVersioning.cpp
@@ -14,9 +14,9 @@
 
 #include "llvm/Transforms/Utils/LoopVersioning.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/LoopAccessAnalysis.h"
 #include "llvm/Analysis/LoopInfo.h"
-#include "llvm/Analysis/MemorySSA.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/IR/Dominators.h"
@@ -354,14 +354,11 @@ PreservedAnalyses LoopVersioningPass::run(Function ,
   auto  = AM.getResult(F);
   auto  = AM.getResult(F);
   auto  = AM.getResult(F);
-  MemorySSA *MSSA = EnableMSSALoopDependency
-? (F).getMSSA()
-: nullptr;
 
   auto  = AM.getResult(F).getManager();
   auto GetLAA = [&](Loop ) -> const LoopAccessInfo & {
 LoopStandardAnalysisResults AR = {AA,  AC,  DT,  LI,  SE,
-  TLI, TTI, nullptr, MSSA};
+  TLI, TTI, nullptr, nullptr};
 return LAM.getResult(L, AR);
   };
 

diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index aac382af50c2b..b842d15fe1874 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -87,7 +87,6 @@
 #include "llvm/Analysis/LoopAnalysisManager.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/LoopIterator.h"
-#include "llvm/Analysis/MemorySSA.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/Analysis/ProfileSummaryInfo.h"
 #include 

[PATCH] D108003: [Clang] Extend -Wbool-operation to warn about bitwise and of bools with side effects

2021-08-16 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D108003#2944714 , @xbolva00 wrote:

> In D108003#2944178 , @aeubanks 
> wrote:
>
>> I ran this over Chrome and ran into a use case that looks legitimate. It 
>> seems like the pattern in LLVM where we want to run a bunch of 
>> transformations and get if any of them changed anything.
>>
>> https://source.chromium.org/chromium/chromium/src/+/main:third_party/webrtc/api/audio/echo_canceller3_config.cc;drc=cbdbb8c1666fd08a094422905e73391706a05b03;l=111
>
> Maybe “res &= foo ();” would be better? “Changed |= foo();” is very typical 
> for LLVM.

Can we either emit that as a suggestion if the code looks like `a = a & foo()`? 
Or simply not emit a warning?


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

https://reviews.llvm.org/D108003

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


[PATCH] D108073: [PassBuilder] Don't use MemorySSA for standalone LoopRotate passes

2021-08-16 Thread Nikita Popov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0a031449b2c7: [PassBuilder] Dont use MemorySSA for 
standalone LoopRotate passes (authored by nikic).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108073

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/lib/Passes/PassBuilder.cpp


Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -923,7 +923,7 @@
   FunctionPassManager FPM;
   // Disable header duplication in loop rotation at -Oz.
   FPM.addPass(createFunctionToLoopPassAdaptor(
-  LoopRotatePass(Level != OptimizationLevel::Oz), EnableMSSALoopDependency,
+  LoopRotatePass(Level != OptimizationLevel::Oz), /*UseMemorySSA=*/false,
   /*UseBlockFrequencyInfo=*/false));
   MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
 
@@ -1399,8 +1399,7 @@
   // Disable header duplication at -Oz.
   OptimizePM.addPass(createFunctionToLoopPassAdaptor(
   LoopRotatePass(Level != OptimizationLevel::Oz, LTOPreLink),
-  EnableMSSALoopDependency,
-  /*UseBlockFrequencyInfo=*/false));
+  /*UseMemorySSA=*/false, /*UseBlockFrequencyInfo=*/false));
 
   // Distribute loops to allow partial vectorization.  I.e. isolate dependences
   // into separate loop that would otherwise inhibit vectorization.  This is
Index: clang/test/CodeGen/thinlto-distributed-newpm.ll
===
--- clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -134,7 +134,6 @@
 ; CHECK-O: Running pass: LoopSimplifyPass on main
 ; CHECK-O: Running analysis: LoopAnalysis on main
 ; CHECK-O: Running pass: LCSSAPass on main
-; CHECK-O: Running analysis: MemorySSAAnalysis on main
 ; CHECK-O: Running analysis: AAManager on main
 ; CHECK-O: Running analysis: BasicAA on main
 ; CHECK-O: Running analysis: ScalarEvolutionAnalysis on main
@@ -147,6 +146,7 @@
 ; CHECK-O: Running analysis: BranchProbabilityAnalysis on main
 ; CHECK-O: Running analysis: PostDominatorTreeAnalysis on main
 ; CHECK-O: Running analysis: DemandedBitsAnalysis on main
+; CHECK-O: Running analysis: MemorySSAAnalysis on main
 ; CHECK-O: Running pass: LoopLoadEliminationPass on main
 ; CHECK-O: Running pass: InstCombinePass on main
 ; CHECK-O: Running pass: SimplifyCFGPass on main


Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -923,7 +923,7 @@
   FunctionPassManager FPM;
   // Disable header duplication in loop rotation at -Oz.
   FPM.addPass(createFunctionToLoopPassAdaptor(
-  LoopRotatePass(Level != OptimizationLevel::Oz), EnableMSSALoopDependency,
+  LoopRotatePass(Level != OptimizationLevel::Oz), /*UseMemorySSA=*/false,
   /*UseBlockFrequencyInfo=*/false));
   MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
 
@@ -1399,8 +1399,7 @@
   // Disable header duplication at -Oz.
   OptimizePM.addPass(createFunctionToLoopPassAdaptor(
   LoopRotatePass(Level != OptimizationLevel::Oz, LTOPreLink),
-  EnableMSSALoopDependency,
-  /*UseBlockFrequencyInfo=*/false));
+  /*UseMemorySSA=*/false, /*UseBlockFrequencyInfo=*/false));
 
   // Distribute loops to allow partial vectorization.  I.e. isolate dependences
   // into separate loop that would otherwise inhibit vectorization.  This is
Index: clang/test/CodeGen/thinlto-distributed-newpm.ll
===
--- clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -134,7 +134,6 @@
 ; CHECK-O: Running pass: LoopSimplifyPass on main
 ; CHECK-O: Running analysis: LoopAnalysis on main
 ; CHECK-O: Running pass: LCSSAPass on main
-; CHECK-O: Running analysis: MemorySSAAnalysis on main
 ; CHECK-O: Running analysis: AAManager on main
 ; CHECK-O: Running analysis: BasicAA on main
 ; CHECK-O: Running analysis: ScalarEvolutionAnalysis on main
@@ -147,6 +146,7 @@
 ; CHECK-O: Running analysis: BranchProbabilityAnalysis on main
 ; CHECK-O: Running analysis: PostDominatorTreeAnalysis on main
 ; CHECK-O: Running analysis: DemandedBitsAnalysis on main
+; CHECK-O: Running analysis: MemorySSAAnalysis on main
 ; CHECK-O: Running pass: LoopLoadEliminationPass on main
 ; CHECK-O: Running pass: InstCombinePass on main
 ; CHECK-O: Running pass: SimplifyCFGPass on main
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0a03144 - [PassBuilder] Don't use MemorySSA for standalone LoopRotate passes

2021-08-16 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-08-16T20:34:18+02:00
New Revision: 0a031449b2c757400090b23bd6ddf4d896d32643

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

LOG: [PassBuilder] Don't use MemorySSA for standalone LoopRotate passes

Two standalone LoopRotate passes scheduled using
createFunctionToLoopPassAdaptor() currently enable MemorySSA.
However, while LoopRotate can preserve MemorySSA, it does not use
it, so requiring MemorySSA is unnecessary.

This change doesn't have a practical compile-time impact by itself,
because subsequent passes still request MemorySSA.

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

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
llvm/lib/Passes/PassBuilder.cpp

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
index c61a6ff7fbeb5..4651a5d282faf 100644
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -134,7 +134,6 @@
 ; CHECK-O: Running pass: LoopSimplifyPass on main
 ; CHECK-O: Running analysis: LoopAnalysis on main
 ; CHECK-O: Running pass: LCSSAPass on main
-; CHECK-O: Running analysis: MemorySSAAnalysis on main
 ; CHECK-O: Running analysis: AAManager on main
 ; CHECK-O: Running analysis: BasicAA on main
 ; CHECK-O: Running analysis: ScalarEvolutionAnalysis on main
@@ -147,6 +146,7 @@
 ; CHECK-O: Running analysis: BranchProbabilityAnalysis on main
 ; CHECK-O: Running analysis: PostDominatorTreeAnalysis on main
 ; CHECK-O: Running analysis: DemandedBitsAnalysis on main
+; CHECK-O: Running analysis: MemorySSAAnalysis on main
 ; CHECK-O: Running pass: LoopLoadEliminationPass on main
 ; CHECK-O: Running pass: InstCombinePass on main
 ; CHECK-O: Running pass: SimplifyCFGPass on main

diff  --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 2972687274f52..cdf0a732e6708 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -923,7 +923,7 @@ void PassBuilder::addPGOInstrPasses(ModulePassManager ,
   FunctionPassManager FPM;
   // Disable header duplication in loop rotation at -Oz.
   FPM.addPass(createFunctionToLoopPassAdaptor(
-  LoopRotatePass(Level != OptimizationLevel::Oz), EnableMSSALoopDependency,
+  LoopRotatePass(Level != OptimizationLevel::Oz), /*UseMemorySSA=*/false,
   /*UseBlockFrequencyInfo=*/false));
   MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
 
@@ -1399,8 +1399,7 @@ 
PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
   // Disable header duplication at -Oz.
   OptimizePM.addPass(createFunctionToLoopPassAdaptor(
   LoopRotatePass(Level != OptimizationLevel::Oz, LTOPreLink),
-  EnableMSSALoopDependency,
-  /*UseBlockFrequencyInfo=*/false));
+  /*UseMemorySSA=*/false, /*UseBlockFrequencyInfo=*/false));
 
   // Distribute loops to allow partial vectorization.  I.e. isolate dependences
   // into separate loop that would otherwise inhibit vectorization.  This is



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


[PATCH] D108083: add sanitizer support to hexagon

2021-08-16 Thread Sid Manning via Phabricator via cfe-commits
sidneym added inline comments.



Comment at: 
compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_hexagon.inc:124
+
+bool internal_iserror(uptr retval, int *rverrno) {
+  if (retval == (uptr)-1) {

bcain wrote:
> @sidneym Can you confirm that this implementation looks correct?  I thought 
> the convention was -1 for failed syscalls.
Maybe it should be <0 instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108083

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


[PATCH] D98061: [InstrProfiling] Generate runtime hook for Fuchsia

2021-08-16 Thread Kirsten Lee via Phabricator via cfe-commits
kile added a comment.

Hi Petr,

This looks to be the change that most likely broke a test on Windows Debug - 
would you mind taking a look? Here's the relevant test and stack trace:

FAIL: LLVM :: Instrumentation/InstrProfiling/linkage.ll (56524 of 77140)

- TEST 'LLVM :: Instrumentation/InstrProfiling/linkage.ll' FAILED 


Script:
---

: 'RUN: at line 3';   d:\a\_work\1\b\llvm\debug\bin\opt.exe < 
D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll 
-mtriple=x86_64-apple-macosx10.10.0 -instrprof -S | 
d:\a\_work\1\b\llvm\debug\bin\filecheck.exe 
D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll 
--check-prefixes=MACHO
: 'RUN: at line 4';   d:\a\_work\1\b\llvm\debug\bin\opt.exe < 
D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll 
-mtriple=x86_64-unknown-linux -instrprof -S | 
d:\a\_work\1\b\llvm\debug\bin\filecheck.exe 
D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll 
--check-prefixes=ELF
: 'RUN: at line 5';   d:\a\_work\1\b\llvm\debug\bin\opt.exe < 
D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll 
-mtriple=x86_64-unknown-fuchsia -instrprof -S | 
d:\a\_work\1\b\llvm\debug\bin\filecheck.exe 
D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll 
--check-prefixes=ELF
: 'RUN: at line 6';   d:\a\_work\1\b\llvm\debug\bin\opt.exe < 
D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll 
 -mtriple=x86_64-pc-win32-coff -instrprof -S | 
d:\a\_work\1\b\llvm\debug\bin\filecheck.exe 
D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll 
--check-prefixes=COFF
: 'RUN: at line 7';   d:\a\_work\1\b\llvm\debug\bin\opt.exe < 
D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll 
-mtriple=x86_64-apple-macosx10.10.0 -passes=instrprof -S | 
d:\a\_work\1\b\llvm\debug\bin\filecheck.exe 
D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll 
--check-prefixes=MACHO
: 'RUN: at line 8';   d:\a\_work\1\b\llvm\debug\bin\opt.exe < 
D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll 
-mtriple=x86_64-unknown-linux -passes=instrprof -S | 
d:\a\_work\1\b\llvm\debug\bin\filecheck.exe 
D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll 
--check-prefixes=ELF
: 'RUN: at line 9';   d:\a\_work\1\b\llvm\debug\bin\opt.exe < 
D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll 
-mtriple=x86_64-unknown-fuchsia -passes=instrprof -S | 
d:\a\_work\1\b\llvm\debug\bin\filecheck.exe 
D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll 
--check-prefixes=ELF
: 'RUN: at line 10';   d:\a\_work\1\b\llvm\debug\bin\opt.exe < 
D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll 
 -mtriple=x86_64-pc-win32-coff -passes=instrprof -S | 
d:\a\_work\1\b\llvm\debug\bin\filecheck.exe 
D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll 
--check-prefixes=COFF

-

Exit Code: 2

Command Output (stdout):


$ ":" "RUN: at line 3"
$ "d:\a\_work\1\b\llvm\debug\bin\opt.exe" "-mtriple=x86_64-apple-macosx10.10.0" 
"-instrprof" "-S"
$ "d:\a\_work\1\b\llvm\debug\bin\filecheck.exe" 
"D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll"
 "--check-prefixes=MACHO"
$ ":" "RUN: at line 4"
$ "d:\a\_work\1\b\llvm\debug\bin\opt.exe" "-mtriple=x86_64-unknown-linux" 
"-instrprof" "-S"
$ "d:\a\_work\1\b\llvm\debug\bin\filecheck.exe" 
"D:\a\_work\1\s\llvm-project\llvm\test\Instrumentation\InstrProfiling\linkage.ll"
 "--check-prefixes=ELF"
$ ":" "RUN: at line 5"
$ "d:\a\_work\1\b\llvm\debug\bin\opt.exe" "-mtriple=x86_64-unknown-fuchsia" 
"-instrprof" "-S"

command stderr:
===

PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace.

Stack dump:

0.  Program arguments: d:\\a\\_work\\1\\b\\llvm\\debug\\bin\\opt.exe 
-mtriple=x86_64-unknown-fuchsia -instrprof -S

#0 0x7ff6c05a6844 failwithmessage 
d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\rtc\error.cpp:213:0

#1 0x7ff6c05a69e4 _RTC_UninitUse 
d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\rtc\error.cpp:362:0

#2 0x7ff6be864982 llvm::InstrProfiling::run(class llvm::Module &, class 
std::function<(class llvm::Function &)>) 
D:\a\_work\1\s\llvm-project\llvm\lib\Transforms\Instrumentation\InstrProfiling.cpp:590:0

#3 0x7ff6be8644ad llvm::InstrProfiling::run(class llvm::Module &, class 
llvm::AnalysisManager &) 
D:\a\_work\1\s\llvm-project\llvm\lib\Transforms\Instrumentation\InstrProfiling.cpp:417:0

#4 0x7ff6bf82d229 llvm::detail::PassModel>::run(class llvm::Module &, class 
llvm::AnalysisManager &) 
D:\a\_work\1\s\llvm-project\llvm\include\llvm\IR\PassManagerInternal.h:85:0

#5 0x7ff6bc402b9e llvm::PassManager>::run(class llvm::Module &, class 

[PATCH] D106030: [Clang] add support for error+warning fn attrs

2021-08-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/test/Sema/attr-error.c:31-32
+
+__attribute__((error("foo"))) int bad5(void);   // expected-error {{'error' 
and 'warning' attributes are not compatible}}
+__attribute__((warning("foo"))) int bad5(void); // expected-note {{conflicting 
attribute is here}}
+

aaron.ballman wrote:
> I think the diagnostic order is backwards here. The first declaration is 
> where I'd expect the note and the second declaration is where I'd expect the 
> error. (The idea is: the first declaration adds an attribute to the decl, so 
> the redeclaration is what introduces the conflict and so that's where the 
> error should live.) As an example: https://godbolt.org/z/bjGTWxYvh
I'm not sure how to reconcile this. Looking at `bad4` above (different case 
than `bad5`), the diagnostic we get is:
```
/tmp/y.c:1:30: error: 'warning' and 'error' attributes are not compatible
__attribute__((error("foo"), warning("foo")))
 ^
/tmp/y.c:1:16: note: conflicting attribute is here
__attribute__((error("foo"), warning("foo")))
   ^
1 error generated.
```
which looks correct to me. If I flip the order these are diagnosed in, that 
fixes `bad5` but if I flip around the ordering:
```
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
-  Diag(CI.getLoc(), diag::err_attributes_are_not_compatible) << CI << EA;
-  Diag(EA->getLocation(), diag::note_conflicting_attribute);
+  Diag(EA->getLocation(), diag::err_attributes_are_not_compatible)
+  << CI << EA;
+  Diag(CI.getLoc(), diag::note_conflicting_attribute);
```
Then `bad4` doesn't look quite correct.
```
/tmp/y.c:1:16: error: 'warning' and 'error' attributes are not compatible
__attribute__((error("foo"), warning("foo")))
   ^
/tmp/y.c:1:30: note: conflicting attribute is here
__attribute__((error("foo"), warning("foo")))
 ^
```
Perhaps in the callers of `handleErrorAttr` I'm confusing which `Decl` is the 
"new" vs the "old?"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106030

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


[PATCH] D106891: [Remarks] Emit optimization remarks for atomics generating CAS loop

2021-08-16 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added inline comments.



Comment at: llvm/lib/CodeGen/AtomicExpandPass.cpp:175
 
+  ORE = std::make_unique();
   auto  = TPC->getTM();

rampitec wrote:
> gandhi21299 wrote:
> > rampitec wrote:
> > > Is there a reason to construct it upfront and not just use a local 
> > > variable only when needed? Like in StackProtector.cpp for example.
> > We can certainly implement it as a local variable as long as we have access 
> > to the function this pass is operating on. I was thinking of its potential 
> > use throughout this pass in the future.
> You have access to the function, AI->getParent()->getParent().
> You also will not need to pass ORE everywhere in the subsequent patch, just 
> construct it in target in place.
Sounds like a plan!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

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


[PATCH] D106891: [Remarks] Emit optimization remarks for atomics generating CAS loop

2021-08-16 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec added inline comments.



Comment at: llvm/lib/CodeGen/AtomicExpandPass.cpp:175
 
+  ORE = std::make_unique();
   auto  = TPC->getTM();

gandhi21299 wrote:
> rampitec wrote:
> > Is there a reason to construct it upfront and not just use a local variable 
> > only when needed? Like in StackProtector.cpp for example.
> We can certainly implement it as a local variable as long as we have access 
> to the function this pass is operating on. I was thinking of its potential 
> use throughout this pass in the future.
You have access to the function, AI->getParent()->getParent().
You also will not need to pass ORE everywhere in the subsequent patch, just 
construct it in target in place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

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


[PATCH] D107717: [LLVM][CMake][NFC] Resolve FIXME: Rename LLVM_CMAKE_PATH to LLVM_CMAKE_DIR throughout the project

2021-08-16 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit updated this revision to Diff 366671.

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

https://reviews.llvm.org/D107717

Files:
  clang/CMakeLists.txt
  clang/lib/Basic/CMakeLists.txt
  compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  flang/CMakeLists.txt
  libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake
  libunwind/CMakeLists.txt
  lld/CMakeLists.txt
  lld/Common/CMakeLists.txt
  lldb/cmake/modules/LLDBStandalone.cmake
  lldb/source/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/include/llvm/Support/CMakeLists.txt
  runtimes/CMakeLists.txt

Index: runtimes/CMakeLists.txt
===
--- runtimes/CMakeLists.txt
+++ runtimes/CMakeLists.txt
@@ -65,7 +65,7 @@
 
 # This variable makes sure that e.g. llvm-lit is found.
 set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR})
-set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
+set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_DIR}/cmake/modules)
 
 # This variable is used by individual runtimes to locate LLVM files.
 set(LLVM_PATH ${LLVM_BUILD_MAIN_SRC_DIR})
Index: llvm/include/llvm/Support/CMakeLists.txt
===
--- llvm/include/llvm/Support/CMakeLists.txt
+++ llvm/include/llvm/Support/CMakeLists.txt
@@ -3,7 +3,7 @@
 # The VC revision include that we want to generate.
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSRevision.h")
 
-set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
 
 if(LLVM_APPEND_VC_REV)
   set(llvm_source_dir ${LLVM_MAIN_SRC_DIR})
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -295,8 +295,8 @@
 set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include ) # --includedir
 set(LLVM_BINARY_DIR   ${CMAKE_CURRENT_BINARY_DIR}  ) # --prefix
 
-# Note: LLVM_CMAKE_PATH does not include generated files
-set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
+# Note: LLVM_CMAKE_DIR does not include generated files
+set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_DIR}/cmake/modules)
 set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples)
 set(LLVM_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
 
Index: lldb/source/CMakeLists.txt
===
--- lldb/source/CMakeLists.txt
+++ lldb/source/CMakeLists.txt
@@ -8,7 +8,7 @@
 find_first_existing_vc_file("${LLDB_SOURCE_DIR}" lldb_vc)
 
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
-set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
 
 if(lldb_vc AND LLVM_APPEND_VC_REV)
   set(lldb_source_dir ${LLDB_SOURCE_DIR})
Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -3,8 +3,8 @@
 find_package(LLVM REQUIRED CONFIG HINTS ${LLVM_DIR} NO_CMAKE_FIND_ROOT_PATH)
 find_package(Clang REQUIRED CONFIG HINTS ${Clang_DIR} ${LLVM_DIR}/../clang NO_CMAKE_FIND_ROOT_PATH)
 
-# We set LLVM_CMAKE_PATH so that GetSVN.cmake is found correctly when building SVNVersion.inc
-set(LLVM_CMAKE_PATH ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake modules")
+# We set LLVM_CMAKE_DIR so that GetSVN.cmake is found correctly when building SVNVersion.inc
+set(LLVM_CMAKE_DIR ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake modules")
 
 set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
 set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include")
Index: lld/Common/CMakeLists.txt
===
--- lld/Common/CMakeLists.txt
+++ lld/Common/CMakeLists.txt
@@ -8,7 +8,7 @@
 find_first_existing_vc_file("${LLD_SOURCE_DIR}" lld_vc)
 
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
-set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
 
 if(lld_vc AND LLVM_APPEND_VC_REV)
   set(lld_source_dir ${LLD_SOURCE_DIR})
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -27,7 +27,7 @@
 
   list(GET LLVM_CONFIG_OUTPUT 0 OBJ_ROOT)
   list(GET LLVM_CONFIG_OUTPUT 1 MAIN_INCLUDE_DIR)
-  list(GET LLVM_CONFIG_OUTPUT 2 LLVM_CMAKE_PATH)
+  list(GET LLVM_CONFIG_OUTPUT 2 LLVM_CMAKE_DIR)
   list(GET LLVM_CONFIG_OUTPUT 3 MAIN_SRC_DIR)
 
   set(LLVM_OBJ_ROOT ${OBJ_ROOT} CACHE PATH "path to LLVM build tree")
@@ -35,14 +35,14 @@
   set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
 
   

[PATCH] D106891: [Remarks] Emit optimization remarks for atomics generating CAS loop

2021-08-16 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added inline comments.



Comment at: llvm/lib/CodeGen/AtomicExpandPass.cpp:175
 
+  ORE = std::make_unique();
   auto  = TPC->getTM();

rampitec wrote:
> Is there a reason to construct it upfront and not just use a local variable 
> only when needed? Like in StackProtector.cpp for example.
We can certainly implement it as a local variable as long as we have access to 
the function this pass is operating on. I was thinking of its potential use 
throughout this pass in the future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

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


[PATCH] D106891: [Remarks] Emit optimization remarks for atomics generating CAS loop

2021-08-16 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec added inline comments.



Comment at: llvm/lib/CodeGen/AtomicExpandPass.cpp:175
 
+  ORE = std::make_unique();
   auto  = TPC->getTM();

Is there a reason to construct it upfront and not just use a local variable 
only when needed? Like in StackProtector.cpp for example.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

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


[clang] 80ed75e - Revert "[NFC] Fix typos"

2021-08-16 Thread Kostya Kortchinsky via cfe-commits

Author: Kostya Kortchinsky
Date: 2021-08-16T11:13:05-07:00
New Revision: 80ed75e7fb45f9f5fc84ca7cbe258be036015384

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

LOG: Revert "[NFC] Fix typos"

This reverts commit b7425e956be60a73004d7ae5bb37da85872c29fb.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
compiler-rt/test/profile/Linux/instrprof-cs.c
llvm/include/llvm/Transforms/Instrumentation.h
llvm/lib/ProfileData/SampleProfReader.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
index a13de306eac84..175dfcef0df45 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
@@ -6,7 +6,7 @@
 //
 
//===--===//
 //
-//  This file defines a CheckObjCInstMethSignature, a flow-insensitive check
+//  This file defines a CheckObjCInstMethSignature, a flow-insenstive check
 //  that determines if an Objective-C class interface incorrectly redefines
 //  the method signature in a subclass.
 //

diff  --git a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
index dcca8be55e337..90c5583d89691 100644
--- a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
@@ -6,7 +6,7 @@
 //
 
//===--===//
 //
-//  This file defines a CheckNSError, a flow-insensitive check
+//  This file defines a CheckNSError, a flow-insenstive check
 //  that determines if an Objective-C class interface correctly returns
 //  a non-void return type.
 //

diff  --git a/compiler-rt/test/profile/Linux/instrprof-cs.c 
b/compiler-rt/test/profile/Linux/instrprof-cs.c
index 0ad6f0350c560..d825525a532db 100644
--- a/compiler-rt/test/profile/Linux/instrprof-cs.c
+++ b/compiler-rt/test/profile/Linux/instrprof-cs.c
@@ -8,7 +8,7 @@
 // RUN: %clang_profgen=%t.profraw -o %t.gen.cis -O2 %s
 // RUN: %run %t.gen.cis
 // RUN: llvm-profdata merge -o %t.cis.profdata %t.profraw
-// Check context insensitive profile
+// Check context insenstive profile
 // RUN: %clang_profuse=%t.cis.profdata  -O2 -emit-llvm -S %s -o - | FileCheck 
%s --check-prefix=CIS
 int g1 = 1;
 int volatile g2 = 2;

diff  --git a/llvm/include/llvm/Transforms/Instrumentation.h 
b/llvm/include/llvm/Transforms/Instrumentation.h
index 0c822999aecf3..03108bacb0da5 100644
--- a/llvm/include/llvm/Transforms/Instrumentation.h
+++ b/llvm/include/llvm/Transforms/Instrumentation.h
@@ -78,7 +78,7 @@ struct GCOVOptions {
 ModulePass *createGCOVProfilerPass(const GCOVOptions  =
GCOVOptions::getDefault());
 
-// PGO Instrumention. Parameter IsCS indicates if this is the context sensitive
+// PGO Instrumention. Parameter IsCS indicates if this is the context senstive
 // instrumentation.
 ModulePass *createPGOInstrumentationGenLegacyPass(bool IsCS = false);
 ModulePass *
@@ -138,7 +138,7 @@ struct InstrProfOptions {
 };
 
 /// Insert frontend instrumentation based profiling. Parameter IsCS indicates 
if
-// this is the context sensitive instrumentation.
+// this is the context senstive instrumentation.
 ModulePass *createInstrProfilingLegacyPass(
 const InstrProfOptions  = InstrProfOptions(), bool IsCS = false);
 

diff  --git a/llvm/lib/ProfileData/SampleProfReader.cpp 
b/llvm/lib/ProfileData/SampleProfReader.cpp
index a801ca1ef36d7..6058eddb13dc7 100644
--- a/llvm/lib/ProfileData/SampleProfReader.cpp
+++ b/llvm/lib/ProfileData/SampleProfReader.cpp
@@ -53,7 +53,7 @@ using namespace sampleprof;
 // For ext-binary format profiles, the flag is set in the summary.
 static cl::opt ProfileIsFSDisciminator(
 "profile-isfs", cl::Hidden, cl::init(false),
-cl::desc("Profile uses flow sensitive discriminators"));
+cl::desc("Profile uses flow senstive discriminators"));
 
 /// Dump the function profile for \p FName.
 ///



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


[PATCH] D107719: [Clang][AST][NFC] Resolve FIXME: Remove unused QualType ElementType member from the ASTContext class.

2021-08-16 Thread Simon Pilgrim via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8bc72dede68c: [Clang][AST][NFC] Resolve FIXME: Remove unused 
QualType ElementType member from… (authored by gAlfonso-bit, committed by 
RKSimon).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107719

Files:
  clang/include/clang/AST/Type.h


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -3455,10 +3455,6 @@
 protected:
   friend class ASTContext;
 
-  /// The element type of the matrix.
-  // FIXME: Appears to be unused? There is also MatrixType::ElementType...
-  QualType ElementType;
-
   /// Number of rows and columns.
   unsigned NumRows;
   unsigned NumColumns;


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -3455,10 +3455,6 @@
 protected:
   friend class ASTContext;
 
-  /// The element type of the matrix.
-  // FIXME: Appears to be unused? There is also MatrixType::ElementType...
-  QualType ElementType;
-
   /// Number of rows and columns.
   unsigned NumRows;
   unsigned NumColumns;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8bc72de - [Clang][AST][NFC] Resolve FIXME: Remove unused QualType ElementType member from the ASTContext class.

2021-08-16 Thread Simon Pilgrim via cfe-commits

Author: Alfsonso Gregory
Date: 2021-08-16T19:07:50+01:00
New Revision: 8bc72dede68ccbbf828c0421276d962d369ba70f

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

LOG: [Clang][AST][NFC] Resolve FIXME: Remove unused QualType ElementType member 
from the ASTContext class.

It is completely unused and not needed to be kept, so let us remove it.

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

Added: 


Modified: 
clang/include/clang/AST/Type.h

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 4238667b8b076..fc83c895afa2e 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -3455,10 +3455,6 @@ class ConstantMatrixType final : public MatrixType {
 protected:
   friend class ASTContext;
 
-  /// The element type of the matrix.
-  // FIXME: Appears to be unused? There is also MatrixType::ElementType...
-  QualType ElementType;
-
   /// Number of rows and columns.
   unsigned NumRows;
   unsigned NumColumns;



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


[clang] b7425e9 - [NFC] Fix typos

2021-08-16 Thread Rong Xu via cfe-commits

Author: Rong Xu
Date: 2021-08-16T10:15:30-07:00
New Revision: b7425e956be60a73004d7ae5bb37da85872c29fb

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

LOG: [NFC] Fix typos

s/senstive/senstive/g

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
compiler-rt/test/profile/Linux/instrprof-cs.c
llvm/include/llvm/Transforms/Instrumentation.h
llvm/lib/ProfileData/SampleProfReader.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
index 175dfcef0df45..a13de306eac84 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
@@ -6,7 +6,7 @@
 //
 
//===--===//
 //
-//  This file defines a CheckObjCInstMethSignature, a flow-insenstive check
+//  This file defines a CheckObjCInstMethSignature, a flow-insensitive check
 //  that determines if an Objective-C class interface incorrectly redefines
 //  the method signature in a subclass.
 //

diff  --git a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
index 90c5583d89691..dcca8be55e337 100644
--- a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
@@ -6,7 +6,7 @@
 //
 
//===--===//
 //
-//  This file defines a CheckNSError, a flow-insenstive check
+//  This file defines a CheckNSError, a flow-insensitive check
 //  that determines if an Objective-C class interface correctly returns
 //  a non-void return type.
 //

diff  --git a/compiler-rt/test/profile/Linux/instrprof-cs.c 
b/compiler-rt/test/profile/Linux/instrprof-cs.c
index d825525a532db..0ad6f0350c560 100644
--- a/compiler-rt/test/profile/Linux/instrprof-cs.c
+++ b/compiler-rt/test/profile/Linux/instrprof-cs.c
@@ -8,7 +8,7 @@
 // RUN: %clang_profgen=%t.profraw -o %t.gen.cis -O2 %s
 // RUN: %run %t.gen.cis
 // RUN: llvm-profdata merge -o %t.cis.profdata %t.profraw
-// Check context insenstive profile
+// Check context insensitive profile
 // RUN: %clang_profuse=%t.cis.profdata  -O2 -emit-llvm -S %s -o - | FileCheck 
%s --check-prefix=CIS
 int g1 = 1;
 int volatile g2 = 2;

diff  --git a/llvm/include/llvm/Transforms/Instrumentation.h 
b/llvm/include/llvm/Transforms/Instrumentation.h
index 03108bacb0da5..0c822999aecf3 100644
--- a/llvm/include/llvm/Transforms/Instrumentation.h
+++ b/llvm/include/llvm/Transforms/Instrumentation.h
@@ -78,7 +78,7 @@ struct GCOVOptions {
 ModulePass *createGCOVProfilerPass(const GCOVOptions  =
GCOVOptions::getDefault());
 
-// PGO Instrumention. Parameter IsCS indicates if this is the context senstive
+// PGO Instrumention. Parameter IsCS indicates if this is the context sensitive
 // instrumentation.
 ModulePass *createPGOInstrumentationGenLegacyPass(bool IsCS = false);
 ModulePass *
@@ -138,7 +138,7 @@ struct InstrProfOptions {
 };
 
 /// Insert frontend instrumentation based profiling. Parameter IsCS indicates 
if
-// this is the context senstive instrumentation.
+// this is the context sensitive instrumentation.
 ModulePass *createInstrProfilingLegacyPass(
 const InstrProfOptions  = InstrProfOptions(), bool IsCS = false);
 

diff  --git a/llvm/lib/ProfileData/SampleProfReader.cpp 
b/llvm/lib/ProfileData/SampleProfReader.cpp
index 6058eddb13dc7..a801ca1ef36d7 100644
--- a/llvm/lib/ProfileData/SampleProfReader.cpp
+++ b/llvm/lib/ProfileData/SampleProfReader.cpp
@@ -53,7 +53,7 @@ using namespace sampleprof;
 // For ext-binary format profiles, the flag is set in the summary.
 static cl::opt ProfileIsFSDisciminator(
 "profile-isfs", cl::Hidden, cl::init(false),
-cl::desc("Profile uses flow senstive discriminators"));
+cl::desc("Profile uses flow sensitive discriminators"));
 
 /// Dump the function profile for \p FName.
 ///



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


[PATCH] D107775: [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from isSpecifierType

2021-08-16 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit updated this revision to Diff 39.
gAlfonso-bit added a comment.

Rearranged if statements


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

https://reviews.llvm.org/D107775

Files:
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp


Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -303,7 +303,6 @@
   SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder);
 
   // Print qualifiers as appropriate.
-
   bool CanPrefixQualifiers = false;
   bool NeedARCStrongQualifier = false;
   CanPrefixQualifiers = canPrefixQualifiers(T, NeedARCStrongQualifier);
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2785,7 +2785,6 @@
   case DependentTemplateSpecialization:
   case ObjCInterface:
   case ObjCObject:
-  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
 return true;
   default:
 return false;
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -155,9 +155,12 @@
   BaseType = PTy->getPointeeType();
 else if (const BlockPointerType *BPy = BaseType->getAs())
   BaseType = BPy->getPointeeType();
-else if (const ArrayType* ATy = dyn_cast(BaseType))
+else if (const ObjCObjectPointerType *OPT =
+ BaseType->getAs())
+  BaseType = OPT->getPointeeType();
+else if (const ArrayType *ATy = dyn_cast(BaseType))
   BaseType = ATy->getElementType();
-else if (const FunctionType* FTy = BaseType->getAs())
+else if (const FunctionType *FTy = BaseType->getAs())
   BaseType = FTy->getReturnType();
 else if (const VectorType *VTy = BaseType->getAs())
   BaseType = VTy->getElementType();


Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -303,7 +303,6 @@
   SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder);
 
   // Print qualifiers as appropriate.
-
   bool CanPrefixQualifiers = false;
   bool NeedARCStrongQualifier = false;
   CanPrefixQualifiers = canPrefixQualifiers(T, NeedARCStrongQualifier);
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2785,7 +2785,6 @@
   case DependentTemplateSpecialization:
   case ObjCInterface:
   case ObjCObject:
-  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
 return true;
   default:
 return false;
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -155,9 +155,12 @@
   BaseType = PTy->getPointeeType();
 else if (const BlockPointerType *BPy = BaseType->getAs())
   BaseType = BPy->getPointeeType();
-else if (const ArrayType* ATy = dyn_cast(BaseType))
+else if (const ObjCObjectPointerType *OPT =
+ BaseType->getAs())
+  BaseType = OPT->getPointeeType();
+else if (const ArrayType *ATy = dyn_cast(BaseType))
   BaseType = ATy->getElementType();
-else if (const FunctionType* FTy = BaseType->getAs())
+else if (const FunctionType *FTy = BaseType->getAs())
   BaseType = FTy->getReturnType();
 else if (const VectorType *VTy = BaseType->getAs())
   BaseType = VTy->getElementType();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107296: Treat inttypes.h as a built-in header

2021-08-16 Thread Mark Rowe via Phabricator via cfe-commits
markrowe added a comment.

@dexonsmith Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107296

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


[PATCH] D104285: [analyzer][AST] Retrieve value by direct index from list initialization of constant array declaration.

2021-08-16 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

In D104285#2943449 , @aaron.ballman 
wrote:

> One thing I think is worth asking in this thread is whether what you're 
> analyzing is undefined behavior?

Technically you are right. Every exit out of an array extent is UB according to 
the Standard.
But in practice we can rely on the fact that multidimensional arrays have a 
continuous layout in memory on stack.
Also every compiler treats `int[2][2]` and `int**` differently. E.g.:

  int arr[6][7];
  arr[2][3]; // *(arr + (2*7 + 3)) = *(arr + 17)
  
  int *ptr = arr;
  ptr[17]; //  *(arr + 17)
  
  int **ptr;
  ptr[2][3] // *(*(ptr + 2) + 3)

Many engineers expoit this fact and treat multidimensional arrays on stack 
through a raw pointer (`(int*)arr`). We can foresee their intentions and treat 
a multidimensional array as a single one instead of a warning about UB.

> And when you turn some of these examples into constant expressions, we reject 
> them based on the bounds. e.g., https://godbolt.org/z/nYPcY14a8

Yes, when we use expicit constants there we can catch such a warning, because 
AST parser can timely recognize the issue. The parser is not smart enough to 
treat variables. Static Analyzer is in charge of this and executes after the 
parser. I think AST parser shall also ignore the Standard in this particular 
case with an eye on a real use cases and developers' intentions. As you can see 
there is a bit modified version which doesn't emit the warning 
https://godbolt.org/z/Mdhhe6Eo9.


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

https://reviews.llvm.org/D104285

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


[PATCH] D108138: [SimplifyCFG] Remove switch statements before vectorization

2021-08-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

I'm not sure i'm sold on this, even though i'm aware that selects hurt 
vectorization.
How does this Simplify the CFG? I think it would be best to teach LV selects,
or at worst do this in LV itself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108138

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


[PATCH] D106030: [Clang] add support for error+warning fn attrs

2021-08-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Sema/attr-error.c:31-32
+
+__attribute__((error("foo"))) int bad5(void);   // expected-error {{'error' 
and 'warning' attributes are not compatible}}
+__attribute__((warning("foo"))) int bad5(void); // expected-note {{conflicting 
attribute is here}}
+

I think the diagnostic order is backwards here. The first declaration is where 
I'd expect the note and the second declaration is where I'd expect the error. 
(The idea is: the first declaration adds an attribute to the decl, so the 
redeclaration is what introduces the conflict and so that's where the error 
should live.) As an example: https://godbolt.org/z/bjGTWxYvh


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106030

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


[PATCH] D107717: [LLVM][CMake][NFC] Resolve FIXME: Rename LLVM_CMAKE_PATH to LLVM_CMAKE_DIR throughout the project

2021-08-16 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

@ldionne can we land this please?


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

https://reviews.llvm.org/D107717

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


[PATCH] D107719: [Clang][AST][NFC] Resolve FIXME: Remove unused QualType ElementType member from the ASTContext class.

2021-08-16 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

In D107719#2946159 , @c-rhodes wrote:

> In D107719#2945656 , @gAlfonso-bit 
> wrote:
>
>> Not sure about the timing of base patch, but maybe this patch is also 
>> candidate for llvm 13 (backport)?
>
> What's the value in backporting it to 13? It's NFC

The less FIXME's, the better


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

https://reviews.llvm.org/D107719

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


[PATCH] D108132: Add implicit map for a list item appears in a reduction clause.

2021-08-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D108132#2947080 , @jyu2 wrote:

>>> I am not sure I can do that. Do you mean when generate map adding coding 
>>> code to look though reduction clause and generate map for it?
>
>
>
>> Yes, exactly.
>
> We are missing mappable checking for example:
>
> #pragma omp target parallel for reduction(task, +: b[0:2][2:4][1])
>
> In this, we should not add map clause, since the section is not contiguous 
> storage.

.
OK, and what's the problem to check for this in codegen? Also, we can map 
non-contiguous storage, at least in some cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108132

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


[PATCH] D108132: Add implicit map for a list item appears in a reduction clause.

2021-08-16 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

>> I am not sure I can do that. Do you mean when generate map adding coding 
>> code to look though reduction clause and generate map for it?



> Yes, exactly.

We are missing mappable checking for example:

#pragma omp target parallel for reduction(task, +: b[0:2][2:4][1])

In this, we should not add map clause, since the section is not contiguous 
storage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108132

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


[PATCH] D108132: Add implicit map for a list item appears in a reduction clause.

2021-08-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D108132#2947053 , @jyu2 wrote:

> Hi ABataev,
> Thanks for  reviedw.
>
> In D108132#2946927 , @ABataev wrote:
>
>> Why it can not be performed in codegen?
>
> I am not sure I can do that.  Do you mean when generate map adding coding 
> code to look though reduction clause and generate map for it?

Yes, exactly.

> Here is the runtime test, I am trying to find way on how to add runtime test 
> in clang.  But in my added test reduction_implicit_map.cpp, I did checked IR 
> for this.

Add it to libomptarget.

> The command line: without may change:
> cmplrllvm-25845>clang -fopenmp -fopenmp-targets=x86_64-pc-linux-gnu o.cpp -g
> cmplrllvm-25845>./a.out
> Segmentation fault (core dumped)
> with may change:
> cmplrllvm-25845> ./a.out
> Result=5050
>
> test
> 
>
> extern "C" int printf(const char *,...);
> void sum(int* input, int size, int* output)
> {
>
>   #pragma omp target teams distribute parallel for reduction(+:output[0]) 
> map(to:input[0:size]) //map(output[0])
>   for(int i=0; i   output[0] += input[i];
>
> }
> int main()
> {
>
>   const int size = 100;
>   int *array = new int[size];
>   int result = 0;
>   for (int i = 0; i < size; i++)
>   array[i] = i + 1;
>   sum(array, size, );
>   printf("Result=%d\n", result);
>   delete[] array;
>   return 0;
>
> }




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108132

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


[PATCH] D108132: Add implicit map for a list item appears in a reduction clause.

2021-08-16 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

Hi ABataev,
Thanks for  reviedw.

In D108132#2946927 , @ABataev wrote:

> Why it can not be performed in codegen?

I am not sure I can do that.  Do you mean when generate map adding coding code 
to look though reduction clause and generate map for it?

Here is the runtime test, I am trying to find way on how to add runtime test in 
clang.  But in my added test reduction_implicit_map.cpp, I did checked IR for 
this.

The command line: without may change:
cmplrllvm-25845>clang -fopenmp -fopenmp-targets=x86_64-pc-linux-gnu o.cpp -g
cmplrllvm-25845>./a.out
Segmentation fault (core dumped)
with may change:
cmplrllvm-25845> ./a.out
Result=5050

test


extern "C" int printf(const char *,...);
void sum(int* input, int size, int* output)
{

  #pragma omp target teams distribute parallel for reduction(+:output[0]) 
map(to:input[0:size]) //map(output[0])
  for(int i=0; ihttps://reviews.llvm.org/D108132/new/

https://reviews.llvm.org/D108132

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


[PATCH] D107933: [clang] Expose unreachable fallthrough annotation warning

2021-08-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, I think this is incremental progress.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107933

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


[PATCH] D108138: [SimplifyCFG] Remove switch statements before vectorization

2021-08-16 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: david-arm, fhahn, dmgreen, craig.topper, 
lebedev.ri.
Herald added subscribers: ctetreau, ormris, wenlei, steven_wu, hiraditya, 
kristof.beyls.
kmclaughlin requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch adds a new function, TurnSmallSwitchIntoICmps, to SimplifyCFG
which attempts to replace small switch statements with a series of conditional
branches and compares. The purpose of this is to allow vectorization of loops
which is not possible at the moment due to the presence of switch statements.
We now run SimplifyCFG to unswitch just before the vectorizer; if we didn't
vectorize the loop then the switch is added back afterwards.

Two new options have been added, the first is `-remove-switch-blocks` which
enables/disables this feature and is on by default. The second is
`-switch-removal-threshold`, which sets the threshold number of switch cases
which we will convert to branches & compares, above which we will not attempt
to convert the switch. If unspecified, the default value used here initially is 
4.

The following tests have been added:

- SimplifyCFG/remove-switches.ll: Tests the changes to SimplifyCFG to replace 
switch statments & ensures branch weights are updated correctly if provided.
- LoopVectorize/AArch64/sve-remove-switches.ll: Tests that we can vectorize 
loops with switch statements with scalable vectors. Also tests that where 
vectorization is not possible, that the switch statement is created again.
- LoopVectorize/remove-switches.ll: Ensures that we do not vectorize the loop 
if the target doesn't support masked loads & stores, where the cost would be 
too high.

Patch originally by David Sherwood


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108138

Files:
  clang/test/Frontend/optimization-remark-analysis.c
  llvm/include/llvm/Transforms/Utils/SimplifyCFGOptions.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-remove-switches.ll
  llvm/test/Transforms/LoopVectorize/remove-switches.ll
  llvm/test/Transforms/SimplifyCFG/nomerge.ll
  llvm/test/Transforms/SimplifyCFG/remove-switches.ll

Index: llvm/test/Transforms/SimplifyCFG/remove-switches.ll
===
--- /dev/null
+++ llvm/test/Transforms/SimplifyCFG/remove-switches.ll
@@ -0,0 +1,142 @@
+; RUN: opt < %s -simplifycfg -switch-removal-threshold=4 -S | FileCheck %s
+
+define void @unswitch(i32* nocapture %a, i32* nocapture readonly %b, i32* nocapture readonly %c, i64 %N){
+; CHECK-LABEL: @unswitch(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[FOR_BODY:%.*]]
+; CHECK:   for.body:
+; CHECK-NEXT:[[I:%.*]] = phi i64 [ [[INC:%.*]], [[L4:%.*]] ], [ 0, [[ENTRY:%.*]] ]
+; CHECK-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[A:%.*]], i64 [[I]]
+; CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
+; CHECK-NEXT:[[SWITCH:%.*]] = icmp eq i32 [[TMP0]], 4
+; CHECK-NEXT:br i1 [[SWITCH]], label [[L4]], label [[FOR_BODY_SWITCH:%.*]], !prof !0
+; CHECK:   for.body.switch:
+; CHECK-NEXT:[[SWITCH1:%.*]] = icmp eq i32 [[TMP0]], 2
+; CHECK-NEXT:br i1 [[SWITCH1]], label [[L2:%.*]], label [[FOR_BODY_SWITCH2:%.*]], !prof !1
+; CHECK:   for.body.switch2:
+; CHECK-NEXT:[[SWITCH3:%.*]] = icmp eq i32 [[TMP0]], 3
+; CHECK-NEXT:br i1 [[SWITCH3]], label [[L3:%.*]], label [[FOR_BODY_SWITCH4:%.*]], !prof !2
+; CHECK:   for.body.switch4:
+; CHECK-NEXT:[[ARRAYIDX5:%.*]] = getelementptr inbounds i32, i32* [[B:%.*]], i64 [[I]]
+; CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* [[ARRAYIDX5]], align 4
+; CHECK-NEXT:[[MUL:%.*]] = mul nsw i32 [[TMP1]], [[TMP0]]
+; CHECK-NEXT:[[ADD:%.*]] = add nsw i32 [[MUL]], [[TMP0]]
+; CHECK-NEXT:store i32 [[ADD]], i32* [[ARRAYIDX]], align 4
+; CHECK-NEXT:br label [[L2]]
+entry:
+  br label %for.body
+
+for.body:
+  %i = phi i64 [ %inc, %L4 ], [ 0, %entry ]
+  %arrayidx = getelementptr inbounds i32, i32* %a, i64 %i
+  %0 = load i32, i32* %arrayidx
+  switch i32 %0, label %L1 [
+  i32 4, label %L4
+  i32 2, label %L2
+  i32 3, label %L3
+  ], !prof !0
+
+L1:
+  %arrayidx5 = getelementptr inbounds i32, i32* %b, i64 %i
+  %1 = load i32, i32* %arrayidx5
+  %mul = mul nsw i32 %1, %0
+  %add = add nsw i32 %mul, %0
+  store i32 %add, i32* %arrayidx
+  br label %L2
+
+L2:
+  %2 = phi i32 [ %0, %for.body ], [ %add, %L1 ]
+  %arrayidx7 = getelementptr inbounds i32, i32* %b, i64 %i
+  %3 = load i32, i32* %arrayidx7, align 4
+  %mul9 = mul nsw i32 %3, %3
+  %add11 

[PATCH] D107719: [Clang][AST][NFC] Resolve FIXME: Remove unused QualType ElementType member from the ASTContext class.

2021-08-16 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

@RKSimon could you commit for me please?


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

https://reviews.llvm.org/D107719

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


[PATCH] D107873: [clang-tidy] Add 'performance-const-parameter-value-or-ref' for checking const-qualified parameters

2021-08-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

It seems like there may be some considerable overlap between this check and the 
one proposed in https://reviews.llvm.org/D54943. I know the other check is more 
about C++ Core Guidelines so it's not perfect overlap. But I do wonder if it'd 
make sense to combine the efforts given that the goal of both checks is to find 
const correctness issues. Do you think there's a chance for sharing 
implementation efforts here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107873

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


[PATCH] D105821: [analyzer] [WIP] Model destructor for std::unique_ptr

2021-08-16 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

The code looks great, I don't see any major problems.

We still need tests, I can't stress this enough. All the real-world cornercases 
you've covered here as you updated the patch deserve a test case.

Some of these changes should probably be separated into other patches, eg. 
invalidation and pointer escape for non-destructor operations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105821

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


[PATCH] D107719: [Clang][AST][NFC] Resolve FIXME: Remove unused QualType ElementType member from the ASTContext class.

2021-08-16 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

OK then we can just merge this in main only then


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

https://reviews.llvm.org/D107719

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


[PATCH] D107719: [Clang][AST][NFC] Resolve FIXME: Remove unused QualType ElementType member from the ASTContext class.

2021-08-16 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

I do not have commit access.


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

https://reviews.llvm.org/D107719

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


[PATCH] D108132: Add implicit map for a list item appears in a reduction clause.

2021-08-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Also, would be good to see a runtime test, which reveals the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108132

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


[PATCH] D108132: Add implicit map for a list item appears in a reduction clause.

2021-08-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Why it can not be performed in codegen?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108132

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


[PATCH] D105265: [X86] AVX512FP16 instructions enabling 3/6

2021-08-16 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:1996
   setOperationAction(ISD::SCALAR_TO_VECTOR,   MVT::v16f16, Custom);
+  setOperationAction(ISD::SINT_TO_FP, MVT::v16i16, Legal);
+  setOperationAction(ISD::STRICT_SINT_TO_FP,  MVT::v16i16, Legal);

LuoYuanke wrote:
> How do we know it covert to v16f16? Is it possible convert to v16f32?
No. Because `v16f32` is not a legal type on X86.



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:2054
+  // vcvttph2[u]dq v4f16 -> v4i32/64, v2f16 -> v2i32/64
+  setOperationAction(ISD::FP_TO_SINT,MVT::v2f16, Custom);
+  setOperationAction(ISD::STRICT_FP_TO_SINT, MVT::v2f16, Custom);

LuoYuanke wrote:
> Why it is not v2i16?
This is used to customize vector widen, which always check the action of result 
type.



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:19998
+  SDLoc dl(Op);
+  SDValue InVec = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, MVT::v2i64, Src);
+  if (IsStrict) {

LuoYuanke wrote:
> Should this node be chained to Op.getOperand(0) for strict FP and convert 
> operation be chained to this node?
Not, we just chain FP nodes together.



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:22003
+  MakeLibCallOptions CallOptions;
+  return makeLibCall(DAG, LC, VT, In, CallOptions, SDLoc(Op)).first;
+}

LuoYuanke wrote:
> InChain for strict FP?
Good catch.



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:22014
+SDValue Res = DAG.getNode(ISD::CONCAT_VECTORS, DL, MVT::v8f16, In,
+  DAG.getUNDEF(MVT::v4f16));
+if (IsStrict)

LuoYuanke wrote:
> Is there any case for v3f16?
No, v3f16 will be widen to v4f16 first.



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:31265
+  if (Src.getValueType().getVectorElementType() == MVT::i16)
+return;
+

LuoYuanke wrote:
> Where is vXi16 handle? Is it promoted to vXi32 finally?
No. i16 and f16 has the same element size. So we don't need to replace them 
with custom nodes.



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:31280
+unsigned Opc = IsSigned ? X86ISD::CVTSI2P : X86ISD::CVTUI2P;
+Results.push_back(DAG.getNode(Opc, dl, MVT::v8f16, Src));
+  }

LuoYuanke wrote:
> Isn't the result type changed to v8f16? Why we don't extract sub-vector here?
Yes. The common widen code widen both src and dst elements as the same size. We 
are customizing to different size here so than we can always select the 128 bit 
instructions. Result type larger than 128 bits doesn't have this problem.



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:49327
+  // UINT_TO_FP(vXi33~63) -> UINT_TO_FP(ZEXT(vXi33~63 to vXi64))
+  if (InVT.isVector() && VT.getVectorElementType() == MVT::f16) {
+unsigned ScalarSize = InVT.getScalarSizeInBits();

LuoYuanke wrote:
> Need to check Subtarget.hasFP16() ?
No. We can't go to here without feature FP16 enabled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105265

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


[PATCH] D105265: [X86] AVX512FP16 instructions enabling 3/6

2021-08-16 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 366630.
pengfei added a comment.

1. Address Yuanke's comments.
2. Add missed strict FP handling.
3. Refactor the repeated declarations for strict FP.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105265

Files:
  clang/include/clang/Basic/BuiltinsX86.def
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/avx512fp16intrin.h
  clang/lib/Headers/avx512vlfp16intrin.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/X86/avx512fp16-builtins.c
  clang/test/CodeGen/X86/avx512vlfp16-builtins.c
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/include/llvm/IR/RuntimeLibcalls.def
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86InstrAVX512.td
  llvm/lib/Target/X86/X86InstrFoldTables.cpp
  llvm/lib/Target/X86/X86InstrFragmentsSIMD.td
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/lib/Target/X86/X86InstrSSE.td
  llvm/lib/Target/X86/X86IntrinsicsInfo.h
  llvm/test/CodeGen/X86/avx512fp16-arith-intrinsics.ll
  llvm/test/CodeGen/X86/avx512fp16-arith-vl-intrinsics.ll
  llvm/test/CodeGen/X86/avx512fp16-arith.ll
  llvm/test/CodeGen/X86/avx512fp16-cvt-ph-w-intrinsics.ll
  llvm/test/CodeGen/X86/avx512fp16-cvt-ph-w-vl-intrinsics.ll
  llvm/test/CodeGen/X86/avx512fp16-cvt.ll
  llvm/test/CodeGen/X86/avx512fp16-intrinsics.ll
  llvm/test/CodeGen/X86/avx512fp16vl-intrinsics.ll
  llvm/test/CodeGen/X86/cvt16-2.ll
  llvm/test/CodeGen/X86/fp-strict-scalar-fp16.ll
  llvm/test/CodeGen/X86/fp-strict-scalar-fptoint-fp16.ll
  llvm/test/CodeGen/X86/fp-strict-scalar-inttofp-fp16.ll
  llvm/test/CodeGen/X86/stack-folding-fp-avx512fp16vl.ll
  llvm/test/CodeGen/X86/vec-strict-128-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-256-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-512-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-fptoint-128-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-fptoint-256-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-fptoint-512-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-inttofp-128-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-inttofp-256-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-inttofp-512-fp16.ll
  llvm/test/MC/Disassembler/X86/avx512fp16.txt
  llvm/test/MC/Disassembler/X86/avx512fp16vl.txt
  llvm/test/MC/X86/avx512fp16.s
  llvm/test/MC/X86/avx512fp16vl.s
  llvm/test/MC/X86/intel-syntax-avx512fp16.s
  llvm/test/MC/X86/intel-syntax-avx512fp16vl.s

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


[PATCH] D108132: Add implicit map for a list item appears in a reduction clause.

2021-08-16 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 created this revision.
jyu2 added reviewers: ABataev, mikerice, jdoerfert.
jyu2 requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

A new rule is added in 5.0:
If a list item appears in a reduction, lastprivate or linear clause
on a combined target construct then it is treated as if it also appears
in a map clause with a map-type of tofrom.

Currently map clauses for all capture variables are added implicitly.
But missing for list item of expression for array elements or array
sections.

The change is to add implicit map clause for array of elements used in
reduction clause. Skip adding map clause if the expression is not
mappable.
Noted: For linear and lastprivate, since only variable name is
accepted, the map has been added though capture variables.

To do so:
During the mappable checking, if error, ignore diagnose and skip
adding implicit map clause.

The changes:
1> Add code to generate implicit map in ActOnOpenMPExecutableDirective,

  for omp 5.0 and up.

2> Add extra default parameter NoDiagnose in ActOnOpenMPMapClause:
Use that to skip error as well as skip adding implicit map during the
mappable checking.

Note: there are only three places need to be check for NoDiagnose. Rest
of them either the check is for < omp 5.0 or the error already generated for
reduction clause.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108132

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/OpenMP/reduction_implicit_map.cpp

Index: clang/test/OpenMP/reduction_implicit_map.cpp
===
--- /dev/null
+++ clang/test/OpenMP/reduction_implicit_map.cpp
@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ \
+// RUN:  -triple powerpc64le-unknown-unknown -DCUDA \
+// RUN:  -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o \
+// RUN:  %t-ppc-host.bc
+
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-cuda-mode -x c++ \
+// RUN:  -triple nvptx64-unknown-unknown -DCUA \
+// RUN:  -fopenmp-targets=nvptx64-nvidia-cuda -DCUDA -emit-llvm %s \
+// RUN:  -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc \
+// RUN:  -o - | FileCheck %s --check-prefix CHECK
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ \
+// RUN:   -triple powerpc64le-unknown-unknown -DDIAG\
+// RUN:   -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm \
+// RUN:   %s -o - | FileCheck  %s \
+// RUN:   --check-prefix=CHECK1
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ \
+// RUN:   -triple i386-unknown-unknown \
+// RUN:   -fopenmp-targets=i386-pc-linux-gnu -emit-llvm \
+// RUN:   %s -o - | FileCheck  %s \
+// RUN:   --check-prefix=CHECK2
+
+// expected-no-diagnostics
+
+#if defined(CUDA)
+int foo(int n) {
+  double *e;
+  //no error and no implicit map generated for e[:1]
+  #pragma omp target parallel reduction(+: e[:1])
+*e=10;
+  ;
+  return 0;
+}
+// CHECK-NOT @.offload_maptypes
+// CHECK: call void @__kmpc_nvptx_end_reduce_nowait(
+#elif defined(DIAG)
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+  S2(S2 ):a(s2.a) { }
+  S2  +(S2 );
+};
+int bar() {
+ S2 o[5];
+  //no warnig "copyable and not guaranteed to be mapped correctly" and
+  //implicit map generated.
+#pragma omp target reduction(+:o[0])
+  for (int i = 0; i < 10; i++);
+  double b[10][10][10];
+  //no error no implicit map generated, the map for b is generated but not
+  //for b[0:2][2:4][1].
+#pragma omp target parallel for reduction(task, +: b[0:2][2:4][1])
+  for (long long i = 0; i < 10; ++i);
+  return 0;
+}
+// map for variable o
+// CHECK1: offload_sizes = private unnamed_addr constant [1 x i64] [i64 20]
+// CHECK1: offload_maptypes = private unnamed_addr constant [1 x i64] [i64 547]
+// map for b:
+// CHECK1: @.offload_sizes.1 = private unnamed_addr constant [1 x i64] [i64 8000]
+// CHECK1: @.offload_maptypes.2 = private unnamed_addr constant [1 x i64] [i64 547]
+#else
+// generate implicit map for array elements or array sections in reduction
+// clause. In following case: the implicit map is generate for output[0]
+// with map size 4 and output[:3] with map size 12.
+void sum(int* input, int size, int* output)
+{
+#pragma omp target teams distribute parallel for reduction(+:output[0]) map(to:input[0:size])
+for(int i=0; i VarList,
   const OMPVarListLocTy , ArrayRef UnresolvedMappers) {
-return getSema().ActOnOpenMPMapClause(MapTypeModifiers, MapTypeModifiersLoc,
-  MapperIdScopeSpec, MapperId, MapType,
-  IsMapTypeImplicit, MapLoc, ColonLoc,
-  VarList, Locs, UnresolvedMappers);
+return getSema().ActOnOpenMPMapClause(
+MapTypeModifiers, MapTypeModifiersLoc, MapperIdScopeSpec, MapperId,
+MapType, IsMapTypeImplicit, MapLoc, ColonLoc, VarList, Locs,
+/*NoDiagnose=*/false, 

[PATCH] D99732: [AST] Pick last tentative definition as the acting definition

2021-08-16 Thread Benson Chu via Phabricator via cfe-commits
pestctrl added a comment.

@mizvekov Thanks for the help! I recently got commit access, so I think I can 
commit this myself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99732

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


[clang] 2d3668c - [analyzer] MallocChecker: Add a visitor to leave a note on functions that could have, but did not change ownership on leaked memory

2021-08-16 Thread Kristóf Umann via cfe-commits

Author: Kristóf Umann
Date: 2021-08-16T16:19:00+02:00
New Revision: 2d3668c997faac1f64cd3b8eb336af989069d135

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

LOG: [analyzer] MallocChecker: Add a visitor to leave a note on functions that 
could have, but did not change ownership on leaked memory

This is a rather common feedback we get from out leak checkers: bug reports are
really short, and are contain barely any usable information on what the analyzer
did to conclude that a leak actually happened.

This happens because of our bug report minimizing effort. We construct bug
reports by inspecting the ExplodedNodes that lead to the error from the bottom
up (from the error node all the way to the root of the exploded graph), and mark
entities that were the cause of a bug, or have interacted with it as
interesting. In order to make the bug report a bit less verbose, whenever we
find an entire function call (from CallEnter to CallExitEnd) that didn't talk
about any interesting entity, we prune it (click here for more info on bug
report generation). Even if the event to highlight is exactly this lack of
interaction with interesting entities.

D105553 generalized the visitor that creates notes for these cases. This patch
adds a new kind of NoStateChangeVisitor that leaves notes in functions that
took a piece of dynamically allocated memory that later leaked as parameter,
and didn't change its ownership status.

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

Added: 
clang/test/Analysis/NewDeleteLeaks.cpp

Modified: 
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/test/Analysis/analyzer-config.c

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 444b00d73f0b7..125ef859d1ebb 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -485,7 +485,17 @@ def DynamicMemoryModeling: 
Checker<"DynamicMemoryModeling">,
   "allocating and deallocating functions are annotated with "
   "ownership_holds, ownership_takes and ownership_returns.",
   "false",
-  InAlpha>
+  InAlpha>,
+CmdLineOption
   ]>,
   Dependencies<[CStringModeling]>,
   Documentation,

diff  --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index a6470da09c458..7db4066653cbd 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -48,6 +48,7 @@
 #include "InterCheckerAPI.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ParentMap.h"
@@ -64,12 +65,15 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicExtent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/StoreRef.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SetOperations.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Compiler.h"
@@ -298,6 +302,8 @@ class MallocChecker
   /// which might free a pointer are annotated.
   DefaultBool ShouldIncludeOwnershipAnnotatedFunctions;
 
+  DefaultBool ShouldRegisterNoOwnershipChangeVisitor;
+
   /// Many checkers are essentially built into this one, so enabling them will
   /// make MallocChecker perform additional modeling and reporting.
   enum CheckKind {
@@ -722,11 +728,146 @@ class MallocChecker
   bool isArgZERO_SIZE_PTR(ProgramStateRef State, CheckerContext ,
   SVal ArgVal) const;
 };
+} // end anonymous namespace
+
+//===--===//
+// Definition of NoOwnershipChangeVisitor.
+//===--===//
+
+namespace {
+class NoOwnershipChangeVisitor final : public NoStateChangeFuncVisitor {
+  SymbolRef Sym;
+  using OwnerSet = llvm::SmallPtrSet;
+
+  // Collect which entities point 

[PATCH] D104975: Implement P1949

2021-08-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Lex/Lexer.cpp:1622-1623
+
+  const bool isIDStart = isAllowedInitiallyIDChar(CodePoint, LangOpts);
+  const bool isIDContinue = isIDStart || isAllowedIDChar(CodePoint, LangOpts);
+





Comment at: clang/lib/Lex/Lexer.cpp:1628
+
+  const bool InvalidOnlyAtStart = IsFirst && !isIDStart && isIDContinue;
+





Comment at: clang/lib/Lex/Lexer.cpp:1687-1689
+  if (Result != llvm::conversionOK) {
 return false;
+  }





Comment at: clang/lib/Lex/Lexer.cpp:1698-1700
+// We got a unicode codepoint that is neither a space nor a
+// a valid identifier part
+// Carry on as if the codepoint was valid for recovery purposes





Comment at: clang/www/make_cxx_dr_status:139
+if dup.startswith('P'):
+  avail = 'Superseded by %s' % (dup, dup)
+  avail_style = ' class="na"'




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104975

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


[PATCH] D108110: Fix LLVM_ENABLE_THREADS check from 26a92d5852b2c6bf77efd26f6c0194c913f40285

2021-08-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!

> Since the other branch has never been used I wonder if we should just remove 
> it instead?

I don't think removing the other branch entirely is a good approach because 
then the call will silently be a noop when threads are disabled. I'd rather we 
keep the support, or turn the other branch into a loud breakage so that callers 
of it find out at compile time that it's not supported when threads are 
disabled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108110

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


[clang] c019142 - [analyzer][NFC] Split the main logic of NoStoreFuncVisitor to an abstract NoStateChangeVisitor class

2021-08-16 Thread Kristóf Umann via cfe-commits

Author: Kristóf Umann
Date: 2021-08-16T15:03:22+02:00
New Revision: c019142a89b477cd247434c1d8f571662d26e19d

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

LOG: [analyzer][NFC] Split the main logic of NoStoreFuncVisitor to an abstract 
NoStateChangeVisitor class

Preceding discussion on cfe-dev: 
https://lists.llvm.org/pipermail/cfe-dev/2021-June/068450.html

NoStoreFuncVisitor is a rather unique visitor. As VisitNode is invoked on most
other visitors, they are looking for the point where something changed -- change
on a value, some checker-specific GDM trait, a new constraint.
NoStoreFuncVisitor, however, looks specifically for functions that *didn't*
write to a MemRegion of interesting. Quoting from its comments:

/// Put a diagnostic on return statement of all inlined functions
/// for which  the region of interest \p RegionOfInterest was passed into,
/// but not written inside, and it has caused an undefined read or a null
/// pointer dereference outside.

It so happens that there are a number of other similar properties that are
worth checking. For instance, if some memory leaks, it might be interesting why
a function didn't take ownership of said memory:

void sink(int *P) {} // no notes

void f() {
  sink(new int(5)); // note: Memory is allocated
// Well hold on, sink() was supposed to deal with
// that, this must be a false positive...
} // warning: Potential memory leak [cplusplus.NewDeleteLeaks]

In here, the entity of interest isn't a MemRegion, but a symbol. The property
that changed here isn't a change of value, but rather liveness and GDM traits
managed by MalloChecker.

This patch moves some of the logic of NoStoreFuncVisitor to a new abstract
class, NoStateChangeFuncVisitor. This is mostly calculating and caching the
stack frames in which the entity of interest wasn't changed.

Descendants of this interface have to define 3 things:

* What constitutes as a change to an entity (this is done by overriding
wasModifiedBeforeCallExit)
* What the diagnostic message should be (this is done by overriding
maybeEmitNoteFor.*)
* What constitutes as the entity of interest being passed into the function 
(this
is also done by overriding maybeEmitNoteFor.*)

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
index 24cae12af24a1..139b0dcd51704 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -21,6 +21,7 @@
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/StringRef.h"
 #include 
 #include 
@@ -622,6 +623,84 @@ class TagVisitor : public BugReporterVisitor {
PathSensitiveBugReport ) override;
 };
 
+class ObjCMethodCall;
+class CXXConstructorCall;
+
+/// Put a diagnostic on return statement (or on } in its absence) of all 
inlined
+/// functions for which some property remained unchanged.
+/// Resulting diagnostics may read such as "Returning without writing to X".
+///
+/// Descendants can define what a "state change is", like a change of value
+/// to a memory region, liveness, etc. For function calls where the state did
+/// not change as defined, a custom note may be constructed.
+class NoStateChangeFuncVisitor : public BugReporterVisitor {
+private:
+  /// Frames modifying the state as defined in \c wasModifiedBeforeCallExit.
+  /// This visitor generates a note only if a function does *not* change the
+  /// state that way. This information is not immediately available
+  /// by looking at the node associated with the exit from the function
+  /// (usually the return statement). To avoid recomputing the same information
+  /// many times (going up the path for each node and checking whether the
+  /// region was written into) we instead lazily compute the stack frames
+  /// along the path.
+  llvm::SmallPtrSet FramesModifying;
+  llvm::SmallPtrSet FramesModifyingCalculated;
+
+  /// Check and lazily calculate whether the state is modified in the stack
+  /// frame to which \p CallExitBeginN belongs.
+  /// The calculation is cached in FramesModifying.
+  bool isModifiedInFrame(const ExplodedNode *CallExitBeginN);
+
+  /// Write to \c FramesModifying all stack frames along the path in the 
current
+  /// stack frame which modifies 

[PATCH] D105553: [analyzer][NFC] Split the main logic of NoStoreFuncVisitor to an abstract NoStateChangeVisitor class

2021-08-16 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc019142a89b4: [analyzer][NFC] Split the main logic of 
NoStoreFuncVisitor to an abstract… (authored by Szelethus).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105553

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -343,46 +343,140 @@
   return P;
 }
 
+//===--===//
+// Implementation of NoStateChangeFuncVisitor.
+//===--===//
+
+bool NoStateChangeFuncVisitor::isModifiedInFrame(const ExplodedNode *N) {
+  const LocationContext *Ctx = N->getLocationContext();
+  const StackFrameContext *SCtx = Ctx->getStackFrame();
+  if (!FramesModifyingCalculated.count(SCtx))
+findModifyingFrames(N);
+  return FramesModifying.count(SCtx);
+}
+
+void NoStateChangeFuncVisitor::findModifyingFrames(
+const ExplodedNode *const CallExitBeginN) {
+
+  assert(CallExitBeginN->getLocationAs());
+  const ExplodedNode *LastReturnN = CallExitBeginN;
+  const StackFrameContext *const OriginalSCtx =
+  CallExitBeginN->getLocationContext()->getStackFrame();
+
+  const ExplodedNode *CurrN = CallExitBeginN;
+
+  do {
+ProgramStateRef State = CurrN->getState();
+auto CallExitLoc = CurrN->getLocationAs();
+if (CallExitLoc) {
+  LastReturnN = CurrN;
+}
+
+FramesModifyingCalculated.insert(
+CurrN->getLocationContext()->getStackFrame());
+
+if (wasModifiedBeforeCallExit(CurrN, LastReturnN)) {
+  const StackFrameContext *SCtx = CurrN->getStackFrame();
+  while (!SCtx->inTopFrame()) {
+auto p = FramesModifying.insert(SCtx);
+if (!p.second)
+  break; // Frame and all its parents already inserted.
+SCtx = SCtx->getParent()->getStackFrame();
+  }
+}
+
+// Stop calculation at the call to the current function.
+if (auto CE = CurrN->getLocationAs())
+  if (CE->getCalleeContext() == OriginalSCtx)
+break;
+
+CurrN = CurrN->getFirstPred();
+  } while (CurrN);
+}
+
+PathDiagnosticPieceRef NoStateChangeFuncVisitor::VisitNode(
+const ExplodedNode *N, BugReporterContext , PathSensitiveBugReport ) {
+
+  const LocationContext *Ctx = N->getLocationContext();
+  const StackFrameContext *SCtx = Ctx->getStackFrame();
+  ProgramStateRef State = N->getState();
+  auto CallExitLoc = N->getLocationAs();
+
+  // No diagnostic if region was modified inside the frame.
+  if (!CallExitLoc || isModifiedInFrame(N))
+return nullptr;
+
+  CallEventRef<> Call =
+  BR.getStateManager().getCallEventManager().getCaller(SCtx, State);
+
+  // Optimistically suppress uninitialized value bugs that result
+  // from system headers having a chance to initialize the value
+  // but failing to do so. It's too unlikely a system header's fault.
+  // It's much more likely a situation in which the function has a failure
+  // mode that the user decided not to check. If we want to hunt such
+  // omitted checks, we should provide an explicit function-specific note
+  // describing the precondition under which the function isn't supposed to
+  // initialize its out-parameter, and additionally check that such
+  // precondition can actually be fulfilled on the current path.
+  if (Call->isInSystemHeader()) {
+// We make an exception for system header functions that have no branches.
+// Such functions unconditionally fail to initialize the variable.
+// If they call other functions that have more paths within them,
+// this suppression would still apply when we visit these inner functions.
+// One common example of a standard function that doesn't ever initialize
+// its out parameter is operator placement new; it's up to the follow-up
+// constructor (if any) to initialize the memory.
+if (!N->getStackFrame()->getCFG()->isLinear()) {
+  static int i = 0;
+  R.markInvalid(, nullptr);
+}
+return nullptr;
+  }
+
+  if (const auto *MC = dyn_cast(Call)) {
+// If we failed to construct a piece for self, we still want to check
+// whether the entity of interest is in a parameter.
+if (PathDiagnosticPieceRef Piece = maybeEmitNoteForObjCSelf(R, *MC, N))
+  return Piece;
+  }
+
+  if (const auto *CCall = dyn_cast(Call)) {
+// Do not generate diagnostics for not modified parameters in
+// constructors.
+return maybeEmitNoteForCXXThis(R, *CCall, N);
+  }
+
+  return maybeEmitNoteForParameters(R, 

  1   2   >