[PATCH] D150670: [WebAssembly] Disable generation of fshl/fshr for rotates

2023-05-18 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added a comment.

In D150670#4351147 , @nikic wrote:

> Lowering to a rotate intrinsic only "solves" this for wasm and will at the 
> same time make these rotates completely opaque to optimization -- heck, it 
> looks like we don't even support constant folding for these intrinsics 
> (https://llvm.godbolt.org/z/hMWG16b9W).

Another thing wrt this optimization regard is that Wasm is slightly different 
from other targets in that it's not natively executed but instead executed 
through a VM or passed through binaryen for further optimization. I just tested 
this and emcc which passes the resulting file through binaryen performs this 
optimization. I imagine V8 won't have problems with this code either, therefore 
the missing optimization in llvm is not problematic for the target.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150670

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


[PATCH] D150670: [WebAssembly] Disable generation of fshl/fshr for rotates

2023-05-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

> Preventing the simplification means adding target specific code in 
> instcombine which seems even worse than adding it here given as @dschuff 
> pointed out, there's precedent with x86.

How harmful is it to avoid breaking rotate patterns even if the target doesn't 
support rotate?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150670

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


[clang] f0303bd - [gcov] Make .gcno/.gcda paths absolute

2023-05-18 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-05-18T00:27:10-07:00
New Revision: f0303bd67d32b41d6502d2ff5fa825a9d21acf96

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

LOG: [gcov] Make .gcno/.gcda paths absolute

This restores 737a452173a67f88d111f27b688bf3696c260db9 (2013) which was removed
by my a07b135ce0c0111bd83450b5dc29ef0381cdbc39.
This behavior turns out to be depended on by `bazel coverage`.

Add a `PWD=/proc/self/cwd %clang -### -c --coverage %s -o foo/bar.o` test.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/coverage.c
clang/test/Driver/working-directory.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index f9b0f8df913d..2a44e8d6158b 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -929,6 +929,8 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, 
Compilation &C,
 } else {
   CoverageFilename = llvm::sys::path::filename(Output.getBaseInput());
 }
+if (llvm::sys::path::is_relative(CoverageFilename))
+  (void)D.getVFS().makeAbsolute(CoverageFilename);
 llvm::sys::path::replace_extension(CoverageFilename, "gcno");
 if (EmitCovNotes) {
   CmdArgs.push_back("-coverage-notes-file");

diff  --git a/clang/test/Driver/coverage.c b/clang/test/Driver/coverage.c
index b3118f0ceb19..d77a720f8ade 100644
--- a/clang/test/Driver/coverage.c
+++ b/clang/test/Driver/coverage.c
@@ -1,21 +1,25 @@
 // RUN: %clang -### -S -ftest-coverage %s 2>&1 | FileCheck 
--check-prefix=TEST-COVERAGE %s
 // RUN: %clang -### -S -ftest-coverage -fno-test-coverage %s 2>&1 | FileCheck 
--check-prefix=NO-TEST-COVERAGE %s
 
-// TEST-COVERAGE: "-coverage-notes-file" "coverage.gcno"
+// TEST-COVERAGE: "-coverage-notes-file" "{{.*}}{{/|}}coverage.gcno"
 // NO-TEST-COVERAGE-NOT: "-coverage-notes-file"
 
 // RUN: %clang -### -S -fprofile-arcs %s 2>&1 | FileCheck 
--check-prefix=PROFILE-ARCS %s
 // RUN: %clang -### -S -fprofile-arcs -fno-profile-arcs %s 2>&1 | FileCheck 
--check-prefix=NO-PROFILE-ARCS %s
 
 // NO-PROFILE-ARCS-NOT: "-coverage-notes-file"
-// PROFILE-ARCS: "-coverage-data-file" "coverage.gcda"
+// PROFILE-ARCS: "-coverage-data-file" "{{.*}}{{/|}}coverage.gcda"
 
 // RUN: %clang -### -S -ftest-coverage %s -o /foo/bar.o 2>&1 | FileCheck 
--check-prefix=GCNO-LOCATION %s
 // RUN: %clang_cl -### /c --coverage /Fo/foo/bar.obj -- %s 2>&1 | FileCheck 
--check-prefix=GCNO-LOCATION %s
 // RUN: %clang -### -c -ftest-coverage %s -o foo/bar.o 2>&1 | FileCheck 
--check-prefix=GCNO-LOCATION-REL %s
 
 // GCNO-LOCATION: "-coverage-notes-file" "{{.*}}/foo/bar.gcno"
-// GCNO-LOCATION-REL: "-coverage-notes-file" "foo/bar.gcno"
+// GCNO-LOCATION-REL: "-coverage-notes-file" "{{.*}}{{/|}}foo/bar.gcno"
+
+/// GCC allows PWD to change the paths.
+// RUN: %if system-linux %{ PWD=/proc/self/cwd %clang -### -c --coverage %s -o 
foo/bar.o 2>&1 | FileCheck --check-prefix=PWD %s %}
+// PWD: "-coverage-notes-file" "/proc/self/cwd/foo/bar.gcno" 
"-coverage-data-file" "/proc/self/cwd/foo/bar.gcda"
 
 /// Don't warn -Wunused-command-line-argument.
 // RUN: %clang -E -Werror --coverage -ftest-coverage -fprofile-arcs %s
@@ -38,13 +42,14 @@
 // RUN: mkdir d e f && cp %s d/a.c && touch d/b.c
 
 // RUN: %clang -### --coverage d/a.c d/b.c -o e/x 2>&1 | FileCheck %s 
--check-prefix=LINK1
-// LINK1: -cc1{{.*}} "-coverage-notes-file" "e/x-a.gcno" "-coverage-data-file" 
"e/x-a.gcda"
-// LINK1: -cc1{{.*}} "-coverage-notes-file" "e/x-b.gcno" "-coverage-data-file" 
"e/x-b.gcda"
+// LINK1: -cc1{{.*}} "-coverage-notes-file" "{{.*}}{{/|}}e/x-a.gcno" 
"-coverage-data-file" "{{.*}}{{/|}}e/x-a.gcda"
+// LINK1: -cc1{{.*}} "-coverage-notes-file" "{{.*}}{{/|}}e/x-b.gcno" 
"-coverage-data-file" "{{.*}}{{/|}}e/x-b.gcda"
 
 // RUN: %clang -### --coverage d/a.c d/b.c -o e/x -dumpdir f/g 2>&1 | 
FileCheck %s --check-prefix=LINK2
-// LINK2: -cc1{{.*}} "-coverage-notes-file" "f/ga.gcno" "-coverage-data-file" 
"f/ga.gcda"
-// LINK2: -cc1{{.*}} "-coverage-notes-file" "f/gb.gcno" "-coverage-data-file" 
"f/gb.gcda"
+// LINK2: -cc1{{.*}} "-coverage-notes-file" "{{.*}}{{/|}}f/ga.gcno" 
"-coverage-data-file" "{{.*}}{{/|}}f/ga.gcda"
+// LINK2: -cc1{{.*}} "-coverage-notes-file" "{{.*}}{{/|}}f/gb.gcno" 
"-coverage-data-file" "{{.*}}{{/|}}f/gb.gcda"
 
-// RUN: %clang -### --coverage d/a.c d/b.c -o e/x -fprofile-dir=f 2>&1 | 
FileCheck %s --check-prefix=LINK3
-// LINK3: -cc1{{.*}} "-coverage-notes-file" "e/x-a.gcno" "-coverage-data-file" 
"f{{/|}}e/x-a.gcda"
-// LINK3: -cc1{{.*}} "-coverage-notes-file" "e/x-b.gcno" "-coverage-data-file" 
"f{{/|}}e/x-b.gcda"
+/// GCC allows PWD to change the paths.
+// RUN: %if system-linux %{ PWD=/proc/self/cwd %

[PATCH] D150848: [clang-format] Respect ColumnLimit 0 lines breaks in inline asm

2023-05-18 Thread Emilia Kond via Phabricator via cfe-commits
rymiel created this revision.
rymiel added a project: clang-format.
rymiel added reviewers: HazardyKnusperkeks, owenpan, MyDeveloperDay.
Herald added projects: All, clang.
Herald added a subscriber: cfe-commits.
rymiel requested review of this revision.

Previously, using ColumnLimit: 0 with extended inline asm with the
BreakBeforeInlineASMColon: OnlyMultiline option (the default style),
the formatter would act as if in Always mode, meaning a line break was
added before every colon in an extended inline assembly block.

This patch respects the already existing line breaks, and doesn't add
any new ones, if in ColumnLimit 0 mode.

Behaviour with Always stays as expected, with a break before every colon
regardless of any existing line breaks.

Behaviour with Never was broken before, and remains broken with this patch,
it is just never respected in ColumnLimit 0 mode.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150848

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -4617,6 +4617,42 @@
 format("__asm   {\n"
"}\n"
"int   i;"));
+
+  auto Style = getLLVMStyleWithColumns(0);
+  Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_OnlyMultiline;
+  verifyFormat("asm(\"xyz\" : \"=a\"(a), \"=d\"(b) : \"a\"(data));", Style);
+  EXPECT_EQ("asm(\"xyz\"\n"
+": \"=a\"(a), \"=d\"(b)\n"
+": \"a\"(data));",
+format("asm(\"xyz\"\n"
+   ": \"=a\"(a), \"=d\"(b)\n"
+   ": \"a\"(data));",
+   Style));
+  EXPECT_EQ("asm(\"xyz\" : \"=a\"(a), \"=d\"(b)\n"
+": \"a\"(data));",
+format("asm(\"xyz\" : \"=a\"(a), \"=d\"(b)\n"
+   ": \"a\"(data));",
+   Style));
+
+  Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_Always;
+  EXPECT_EQ(
+  "asm(\"xyz\"\n"
+  ": \"=a\"(a), \"=d\"(b)\n"
+  ": \"a\"(data));",
+  format("asm(\"xyz\" : \"=a\"(a), \"=d\"(b) : \"a\"(data));", Style));
+  EXPECT_EQ("asm(\"xyz\"\n"
+": \"=a\"(a), \"=d\"(b)\n"
+": \"a\"(data));",
+format("asm(\"xyz\"\n"
+   ": \"=a\"(a), \"=d\"(b)\n"
+   ": \"a\"(data));",
+   Style));
+  EXPECT_EQ("asm(\"xyz\"\n"
+": \"=a\"(a), \"=d\"(b)\n"
+": \"a\"(data));",
+format("asm(\"xyz\" : \"=a\"(a), \"=d\"(b)\n"
+   ": \"a\"(data));",
+   Style));
 }
 
 TEST_F(FormatTest, FormatTryCatch) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -357,7 +357,8 @@
   if (Current.MustBreakBefore ||
   (Current.is(TT_InlineASMColon) &&
(Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_Always ||
-Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_OnlyMultiline))) 
{
+(Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_OnlyMultiline &&
+ Style.ColumnLimit != 0 {
 return true;
   }
   if (CurrentState.BreakBeforeClosingBrace &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -4617,6 +4617,42 @@
 format("__asm   {\n"
"}\n"
"int   i;"));
+
+  auto Style = getLLVMStyleWithColumns(0);
+  Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_OnlyMultiline;
+  verifyFormat("asm(\"xyz\" : \"=a\"(a), \"=d\"(b) : \"a\"(data));", Style);
+  EXPECT_EQ("asm(\"xyz\"\n"
+": \"=a\"(a), \"=d\"(b)\n"
+": \"a\"(data));",
+format("asm(\"xyz\"\n"
+   ": \"=a\"(a), \"=d\"(b)\n"
+   ": \"a\"(data));",
+   Style));
+  EXPECT_EQ("asm(\"xyz\" : \"=a\"(a), \"=d\"(b)\n"
+": \"a\"(data));",
+format("asm(\"xyz\" : \"=a\"(a), \"=d\"(b)\n"
+   ": \"a\"(data));",
+   Style));
+
+  Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_Always;
+  EXPECT_EQ(
+  "asm(\"xyz\"\n"
+  ": \"=a\"(a), \"=d\"(b)\n"
+  ": \"a\"(data));",
+  format("asm(\"xyz\" : \"=a\"(a), \"=d\"(b) : \"a\"(data));", Style));
+  EXPECT_EQ("asm(\"xyz\"\n"
+": \"=a\"(a), \"=d\"(b)\n"
+": \"a\"(data));",
+format("asm(\"xyz\"\n"
+   ": \"=a\"(a), \"=d\"(b)\n"
+ 

[PATCH] D149447: [clang][analyzer] Improve documentation of StdCLibraryFunctionArgs checker (NFC)

2023-05-18 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/docs/analyzer/checkers.rst:2490-2523
+**List of checked functions**
+
+``fgetc``, ``fread``, ``fwrite``, ``getc``, ``getchar``, ``getdelim``,
+``getenv``, ``getline``, ``isalnum``, ``isalpha``, ``isascii``, ``isblank``,
+``isdigit``, ``isgraph``, ``islower``, ``isprint``, ``ispunct``, ``isspace``,
+``isupper``, ``isxdigit``, ``read``, ``toascii``, ``tolower``, ``toupper``,
+``write``

Szelethus wrote:
> balazske wrote:
> > Szelethus wrote:
> > > We should create an option or something the //actual// list of functions 
> > > we model. This is the prime example of unsustainable documenting.
> > Such function lists are used at documentation of other checkers, but I am 
> > not sure if it is good to add such a long list here. Probably the 
> > "DisplayLoadedSummaries" option of `apiModeling.StdCLibraryFunctions` 
> > checker can be used, this lists only the actually found functions (that 
> > have available declaration and are enabled), and the console output needs 
> > to be observed to see the list. And this option is currently not documented.
> > Such function lists are used at documentation of other checkers
> 
> Is it possible that those lists are not really expected to change? We do 
> expect the list for this checker to grow, do we not?
At first look not all other checkers check every possible function, only the 
most common ones, it looks possible to extend these. Some have an incomplete 
list in the documentation. My concern was if an user want to know if a specific 
function is checked or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149447

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


[clang] fc89e90 - [C++20] [Modules] Emit an warning for experimental header units

2023-05-18 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-05-18T16:12:41+08:00
New Revision: fc89e9044d0b37dcd4e3f085f21bef1b21d2ab8d

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

LOG: [C++20] [Modules] Emit an warning for experimental header units

Currently, the header units are rarely used and it is not well tested.
To avoid further misunderstandings, let's mark it as experimental and
emit a warning when users wants to import it.

This is discussed in modules developers meeting.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaModule.cpp
clang/test/CXX/module/module.interface/p2.cpp
clang/test/Modules/cxx20-10-2-ex2.cpp
clang/test/Modules/cxx20-hu-04.cpp
clang/test/Modules/cxx20-include-translation.cpp
clang/test/Modules/merge-concepts.cppm

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 0d93727ccc7b3..54671bfe4e943 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11279,6 +11279,10 @@ def err_invalid_module_name : Error<"%0 is an invalid 
name for a module">;
 def err_extern_def_in_header_unit : Error<
   "non-inline external definitions are not permitted in C++ header units">;
 
+def warn_experimental_header_unit : Warning<
+  "the implementation of header units is in an experimental phase">,
+  InGroup>;
+
 def ext_equivalent_internal_linkage_decl_in_modules : ExtWarn<
   "ambiguous use of internal linkage declaration %0 defined in multiple 
modules">,
   InGroup>;

diff  --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index e1d7c290effe4..a1ab013fcf5e8 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -544,6 +544,9 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
SourceLocation ExportLoc,
SourceLocation ImportLoc, Module *Mod,
ModuleIdPath Path) {
+  if (Mod->isHeaderUnit())
+Diag(ImportLoc, diag::warn_experimental_header_unit);
+
   VisibleModules.setVisible(Mod, ImportLoc);
 
   checkModuleImportContext(*this, Mod, ImportLoc, CurContext);

diff  --git a/clang/test/CXX/module/module.interface/p2.cpp 
b/clang/test/CXX/module/module.interface/p2.cpp
index 0cb6514cd3345..bf4e3f9650fd4 100644
--- a/clang/test/CXX/module/module.interface/p2.cpp
+++ b/clang/test/CXX/module/module.interface/p2.cpp
@@ -5,9 +5,10 @@
 // RUN: %clang_cc1 -std=c++20 %s -DY_INTERFACE -emit-module-interface -o 
%t/y.pcm
 // RUN: %clang_cc1 -std=c++20 %s -DINTERFACE -fmodule-file=X=%t/x.pcm 
-fmodule-file=Y=%t/y.pcm -emit-module-interface -o %t/m.pcm
 // RUN: %clang_cc1 -std=c++20 %s -DIMPLEMENTATION -I%S/Inputs 
-fmodule-file=%t/h.pcm \
-// RUN:   -fmodule-file=X=%t/x.pcm -fmodule-file=Y=%t/y.pcm 
-fmodule-file=p2=%t/m.pcm -verify
+// RUN:   -fmodule-file=X=%t/x.pcm -fmodule-file=Y=%t/y.pcm 
-fmodule-file=p2=%t/m.pcm -verify \
+// RUN:   -Wno-experimental-header-units
 // RUN: %clang_cc1 -std=c++20 %s -DUSER -I%S/Inputs -fmodule-file=%t/h.pcm 
-fmodule-file=p2=%t/m.pcm \
-// RUN:   -fmodule-file=X=%t/x.pcm -fmodule-file=Y=%t/y.pcm -verify
+// RUN:   -fmodule-file=X=%t/x.pcm -fmodule-file=Y=%t/y.pcm 
-Wno-experimental-header-units -verify
 
 #if defined(X_INTERFACE)
 export module X;

diff  --git a/clang/test/Modules/cxx20-10-2-ex2.cpp 
b/clang/test/Modules/cxx20-10-2-ex2.cpp
index 659e4fe937e17..bc66d6a2ec1a9 100644
--- a/clang/test/Modules/cxx20-10-2-ex2.cpp
+++ b/clang/test/Modules/cxx20-10-2-ex2.cpp
@@ -29,7 +29,7 @@ module;
 #include "std-10-2-ex2-b.h"
 
 export module M;
-import "std-10-2-ex2-c.h";
+import "std-10-2-ex2-c.h";  // expected-warning {{the implementation of header 
units is in an experimental phase}}
 import X;
 export using ::f, ::g, ::h; // OK
 struct S;   // expected-note {{target of using declaration}}

diff  --git a/clang/test/Modules/cxx20-hu-04.cpp 
b/clang/test/Modules/cxx20-hu-04.cpp
index da6056d4d47ed..aed1bdb875ec9 100644
--- a/clang/test/Modules/cxx20-hu-04.cpp
+++ b/clang/test/Modules/cxx20-hu-04.cpp
@@ -42,7 +42,7 @@ int baz(int);
 // CHECK-HU-NEXT:  Header Unit './hu-01.h' is the Primary Module at index #1
 
 //--- hu-02.h
-export import "hu-01.h";
+export import "hu-01.h"; // expected-warning {{the implementation of header 
units is in an experimental phase}}
 #if !defined(FORTYTWO) || FORTYTWO != 42
 #error FORTYTWO missing in hu-02
 #endif
@@ -82,7 +82,7 @@ inline int bar(int x) {
 
 //--- importer-01.cpp
 export module B;
-import "hu-02.h";
+import "hu-02.h"; // expected-warning {{the implementation of header units is 
in an experimental phase}}
 
 int success(int x) {
   re

[PATCH] D150670: [WebAssembly] Disable generation of fshl/fshr for rotates

2023-05-18 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

In D150670#4352055 , @pmatos wrote:

> In D150670#4351147 , @nikic wrote:
>
>> This doesn't looks like a wasm specific problem. You get essentially the 
>> same issue on any target that has a rotate instruction but no funnel shift 
>> instruction. Here are just a couple examples: https://godbolt.org/z/8v6nfaax9
>
> Yes, I am indeed aware this is not specific to wasm. What's specific to wasm 
> afaiu is that the code generated is much worse when expanding fshl. That's 
> what I mentioned in the bug discussion here: 
> https://github.com/llvm/llvm-project/issues/62703#issuecomment-1548474310
>
>> I believe this needs to be either solved by preventing demanded bits 
>> simplifications that break a rotate pattern (though I'm not sure if that 
>> would break any other optimizations we care about) or by adding a special 
>> case for this in the backend when lowering FSH to ROT.
>
> Preventing the simplification means adding target specific code in 
> instcombine which seems even worse than adding it here given as @dschuff 
> pointed out, there's precedent with x86.

I'm not suggesting to add any target specific code to instcombine. I think 
there are actually quite a few different ways this could be solved. See 
https://llvm.godbolt.org/z/f55K7K17W for three possible representations of the 
same rotate pattern.

1. Say that we prefer preserving rotates over "simplifying" funnel shifts 
(ending up with the rot2 pattern). Basically by skipping the optimization at 
https://github.com/llvm/llvm-project/blob/7f54b38e28b3b66195de672848f2b5366d0d51e3/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp#L927-L931
 if both fsh operands are the same. Assuming this doesn't cause test 
regressions, I think this would be acceptable to do. From a backend 
perspective, even for targets that have a native funnel shift (aarch64, x86), 
the difference between the rot1/rot2 patterns looks pretty neutral.

2. Undo the transform in the backend. It is bidrectional 
(https://alive2.llvm.org/ce/z/Chb85F), so this is possible.  This would need an 
extra legalization/combiner pattern (depending on where we form ROTs). 
Advantage of undoing the pattern is the usual one: Works if it was in the 
undesirable form in the first place. (E.g. this could happen if the rotate did 
not use a builtin but was implemented as `x << 8 | x >> 24`, which is probably 
much more widespread than the builtin. Though I checked, and we don't form a 
funnel shift for it in this case right now.)

3. Move the and from the fsh arguments to the result. This is the rot3 pattern. 
This seems to produce the best codegen on average, because it can use uxtb16 on 
ARM. Moving the and from args to return is a bit unusual for unary ops, but if 
we see this as moving two ands on both fsh arguments (which happen to be the 
same) to one on the result, that would be a pretty standard transform.

I think all of those options are viable, and couldn't say for certain which one 
is best. I think any of them would be better than making clang emit a special 
intrinsic just for wasm though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150670

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


[clang] e8cd046 - [AST] Initialize local counter

2023-05-18 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2023-05-18T01:19:11-07:00
New Revision: e8cd04624e503ae063e925eb5609281a88716d83

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

LOG: [AST] Initialize local counter

I assume it's optional and ReadAST does not have to set the
counter on success.

Without the patch msan complains that we pass
uninitialized value into noundef parameters of setCounterValue.

Reviewed By: bnbarham, barannikov88

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

Added: 


Modified: 
clang/lib/Frontend/ASTUnit.cpp

Removed: 




diff  --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index b1e7db1f6b39..14971da4da0b 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -822,7 +822,6 @@ std::unique_ptr ASTUnit::LoadFromASTFile(
   // Gather Info for preprocessor construction later on.
 
   HeaderSearch &HeaderInfo = *AST->HeaderInfo;
-  unsigned Counter;
 
   AST->PP = std::make_shared(
   AST->PPOpts, AST->getDiagnostics(), *AST->LangOpts,
@@ -846,6 +845,7 @@ std::unique_ptr ASTUnit::LoadFromASTFile(
   /*isysroot=*/"",
   /*DisableValidationKind=*/disableValid, AllowASTWithCompilerErrors);
 
+  unsigned Counter = 0;
   AST->Reader->setListener(std::make_unique(
   *AST->PP, AST->Ctx.get(), *AST->HSOpts, *AST->PPOpts, *AST->LangOpts,
   AST->TargetOpts, AST->Target, Counter));



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


[PATCH] D150492: [AST] Initialize local counter

2023-05-18 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe8cd04624e50: [AST] Initialize local counter (authored by 
vitalybuka).

Changed prior to commit:
  https://reviews.llvm.org/D150492?vs=521819&id=523292#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150492

Files:
  clang/lib/Frontend/ASTUnit.cpp


Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -822,7 +822,6 @@
   // Gather Info for preprocessor construction later on.
 
   HeaderSearch &HeaderInfo = *AST->HeaderInfo;
-  unsigned Counter;
 
   AST->PP = std::make_shared(
   AST->PPOpts, AST->getDiagnostics(), *AST->LangOpts,
@@ -846,6 +845,7 @@
   /*isysroot=*/"",
   /*DisableValidationKind=*/disableValid, AllowASTWithCompilerErrors);
 
+  unsigned Counter = 0;
   AST->Reader->setListener(std::make_unique(
   *AST->PP, AST->Ctx.get(), *AST->HSOpts, *AST->PPOpts, *AST->LangOpts,
   AST->TargetOpts, AST->Target, Counter));


Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -822,7 +822,6 @@
   // Gather Info for preprocessor construction later on.
 
   HeaderSearch &HeaderInfo = *AST->HeaderInfo;
-  unsigned Counter;
 
   AST->PP = std::make_shared(
   AST->PPOpts, AST->getDiagnostics(), *AST->LangOpts,
@@ -846,6 +845,7 @@
   /*isysroot=*/"",
   /*DisableValidationKind=*/disableValid, AllowASTWithCompilerErrors);
 
+  unsigned Counter = 0;
   AST->Reader->setListener(std::make_unique(
   *AST->PP, AST->Ctx.get(), *AST->HSOpts, *AST->PPOpts, *AST->LangOpts,
   AST->TargetOpts, AST->Target, Counter));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b96d063 - [NFC][AST] Align one line

2023-05-18 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2023-05-18T01:19:48-07:00
New Revision: b96d0635f0c65de2fbbcf67fac7e70f9cce35171

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

LOG: [NFC][AST] Align one line

Added: 


Modified: 
clang/lib/Frontend/ASTUnit.cpp

Removed: 




diff  --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 14971da4da0b..d23a40f6ffd1 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -859,7 +859,7 @@ std::unique_ptr ASTUnit::LoadFromASTFile(
 AST->Ctx->setExternalSource(AST->Reader);
 
   switch (AST->Reader->ReadAST(Filename, serialization::MK_MainFile,
-  SourceLocation(), ASTReader::ARR_None)) {
+   SourceLocation(), ASTReader::ARR_None)) {
   case ASTReader::Success:
 break;
 



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


[clang] 11fe931 - [AST] Initialized AutoTypeLocInfo::FoundDecl

2023-05-18 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2023-05-18T01:21:29-07:00
New Revision: 11fe9310b9146ee7dfd7cf01662e8fc0a7cd508c

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

LOG: [AST] Initialized AutoTypeLocInfo::FoundDecl

Msan complains if getFoundDecl called before it's set.
This looks like data class, so I see no reason to keep
the single field uninitialized.

Added: 


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

Removed: 




diff  --git a/clang/include/clang/AST/TypeLoc.h 
b/clang/include/clang/AST/TypeLoc.h
index 72ed3cb752e0f..8bf64dc6158c3 100644
--- a/clang/include/clang/AST/TypeLoc.h
+++ b/clang/include/clang/AST/TypeLoc.h
@@ -2102,7 +2102,7 @@ struct AutoTypeLocInfo : TypeSpecLocInfo {
   NestedNameSpecifierLoc NestedNameSpec;
   SourceLocation TemplateKWLoc;
   SourceLocation ConceptNameLoc;
-  NamedDecl *FoundDecl;
+  NamedDecl *FoundDecl = nullptr;
   SourceLocation LAngleLoc;
   SourceLocation RAngleLoc;
 



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


[clang] 9e270c6 - [test][clang-repl] Disable test incompatible with msan

2023-05-18 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2023-05-18T01:24:03-07:00
New Revision: 9e270c64a7319929da2b92920a91136fd9e2df43

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

LOG: [test][clang-repl] Disable test incompatible with msan

Added: 


Modified: 
clang/test/Interpreter/simple-exception.cpp

Removed: 




diff  --git a/clang/test/Interpreter/simple-exception.cpp 
b/clang/test/Interpreter/simple-exception.cpp
index 886b8ffd2d701..8741886a0a621 100644
--- a/clang/test/Interpreter/simple-exception.cpp
+++ b/clang/test/Interpreter/simple-exception.cpp
@@ -3,6 +3,11 @@
 // XFAIL for arm, arm64, riscv, or running on Windows.
 // XFAIL: target={{(arm|riscv).*}}, system-windows
 // RUN: cat %s | clang-repl | FileCheck %s
+
+// Incompatible with msan. It passes with -O3 but fail -Oz. Interpreter
+// generates non-instrumented code, which may call back to instrumented.
+// UNSUPPORTED: msan
+
 extern "C" int printf(const char *, ...);
 
 int f() { throw "Simple exception"; return 0; }



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


[PATCH] D150549: Move SubtargetFeature.h from MC to TargetParser

2023-05-18 Thread Job Noorman via Phabricator via cfe-commits
jobnoorman added a comment.

In D150549#4351614 , @MaskRay wrote:

> In D150549#4349531 , @jobnoorman 
> wrote:
>
>> In D150549#4347056 , @MaskRay 
>> wrote:
>>
>>> This seems fine, but please consider making `MC/SubtargetFeature.h` a 
>>> forwarding header temporarily.
>>
>> To be clear: do you want me to check-in this forwarding header or should I 
>> just do it locally for the tests below? If the former, what exactly is the 
>> purpose of adding this header?
>
> The motivation is similar to https://reviews.llvm.org/D137838#3921828
>
>> That way, you don't have to update oodles of include lines in this patch, 
>> and it makes it a bit easier to see what's going on. (You can then update 
>> all the include lines in a trivial follow-up if this change goes through, 
>> and then remove the forwarding headers in Support, to cut the dependency you 
>> want to remove.)
>
> (There is a non-zero probability that the patch may miss something and get 
> reverted. By creating a forwarding header we don't risk causing too much 
> churn to the many files.)
> For a large-scaling refactoring

Thanks for the link! If I understand the discussion there correctly, the 
motivation for adding the forwarding header was to not have to update any 
`#include` sites directly in order to reduce the size of the patch. So what you 
are asking me to do is

1. Update this patch to have a forwarding header and //not// change `#include` 
sites;
2. Create a second patch that updates `#include`s and removes the forward. This 
patch would be committed at some point in the future once we're sure the move 
is fine.

Is this correct?

I do wonder if this is necessary in this case as the patch is much smaller than 
the one in the link you shared.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150549

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


[PATCH] D150752: [bolt] Use correct output paths and passthrough necessary options

2023-05-18 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings added inline comments.



Comment at: bolt/CMakeLists.txt:88
+  if(CMAKE_SYSROOT)
+list(APPEND extra_args -DCMAKE_SYSROOT=${CMAKE_SYSROOT})
+  endif()

The [[ https://cmake.org/cmake/help/latest/variable/CMAKE_TOOLCHAIN_FILE.html | 
documentation for CMAKE_SYSROOT  ]] says "This variable may only be set in a 
toolchain file specified by the CMAKE_TOOLCHAIN_FILE variable."

Maybe pass CMAKE_TOOLCHAIN_FILE through instead?



Comment at: bolt/CMakeLists.txt:88
+  if(CMAKE_SYSROOT)
+list(APPEND extra_args -DCMAKE_SYSROOT=${CMAKE_SYSROOT})
+  endif()

michaelplatings wrote:
> The [[ https://cmake.org/cmake/help/latest/variable/CMAKE_TOOLCHAIN_FILE.html 
> | documentation for CMAKE_SYSROOT  ]] says "This variable may only be set in 
> a toolchain file specified by the CMAKE_TOOLCHAIN_FILE variable."
> 
> Maybe pass CMAKE_TOOLCHAIN_FILE through instead?
`list(APPEND variable_that_may_or_may_not_exist ...` is quite fragile. Should 
someone have `-Dextra_args=X` on their cmake command line then that will be 
included here, which I don't think is the intent. I suggest adding 
`set(extra_args "")` above the `if`. This also improves readability because 
otherwise you have to scan the whole file to figure out that `extra_args` 
wasn't previously defined.



Comment at: bolt/CMakeLists.txt:98
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-   -DCMAKE_INSTALL_PREFIX=${LLVM_BINARY_DIR}
+   -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}

Given that the install step now does nothing, and the `install` statement below 
passes `-DCMAKE_INSTALL_PREFIX` explicitly, could this line be deleted? 
Alternatively perhaps `-DCMAKE_INSTALL_PREFIX` could be removed from the 
`install` statement.



Comment at: bolt/CMakeLists.txt:103
+INSTALL_COMMAND ""
+STEP_TARGETS configure build
 BUILD_ALWAYS True

These targets don't appear to be used. I suggest either deleting this line, or 
if they're needed/useful somehow then adding a comment either here or in the 
commit message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150752

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


[PATCH] D148785: -fsanitize=function: use type hashes instead of RTTI objects

2023-05-18 Thread Peter Smith via Phabricator via cfe-commits
peter.smith added inline comments.



Comment at: clang/test/CodeGenCXX/catch-undef-behavior.cpp:408
 
   // RTTI pointer check
+  // CHECK: [[CalleeTypeHashPtr:%.+]] = getelementptr <{ i32, i32 }>, <{ i32, 
i32 }>* [[PTR]], i32 -1, i32 1

MaskRay wrote:
> peter.smith wrote:
> > CalleeTypeHash check?
> `CalleeTypeHashPtr` seems clear. Do you mean to change `HashCmp` below to 
> `CalleeTypeHashMatch`?
> 
> 
Apologies; I meant the comment is stale, it still says RTTI pointer check



Comment at: llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll:92
 ; CHECK-NEXT: .Ltmp{{.*}}:
 ; CHECK-NEXT:   nop
 ; CHECK-NEXT:   .word   3238382334  // 0xc105cafe

MaskRay wrote:
> MaskRay wrote:
> > peter.smith wrote:
> > > samitolvanen wrote:
> > > > peter.smith wrote:
> > > > > Assuming the test is the equivalent of 
> > > > > `-fpatchable-function-entry=1,1` I think this is the wrong place for 
> > > > > the nop, I think it needs to be after the signature and the loads 
> > > > > adjusted. For example with -fsanitize=kcfi 
> > > > > -fpatchable-function-entries=1,1
> > > > > ```
> > > > > typedef int Fptr(void);
> > > > > 
> > > > > int function(void) {
> > > > >   return 0;
> > > > > }
> > > > > 
> > > > > int call(Fptr* fp) {
> > > > >   return fp();
> > > > > }
> > > > > ```
> > > > > Results in code like:
> > > > > ```
> > > > > .word   1670944012  // @call
> > > > > // 0x6398950c
> > > > > .Ltmp1:
> > > > > nop
> > > > > call:
> > > > > .Lfunc_begin1:
> > > > > .cfi_startproc
> > > > > // %bb.0:   // %entry
> > > > > ldurw16, [x0, #-8]
> > > > > movkw17, #50598
> > > > > movkw17, #14001, lsl #16
> > > > > cmp w16, w17
> > > > > b.eq.Ltmp2
> > > > > brk #0x8220
> > > > > .Ltmp2:
> > > > > br  x0
> > > > > .Lfunc_end1:
> > > > > ```
> > > > > Note the NOP is after the signature, with the `ldur` having an offset 
> > > > > of -8 and not the usual -4. I think you would need to make sure the 
> > > > > signature is a branch instruction for each target for this scheme to 
> > > > > work.
> > > > No, this looks correct to me. Note that in AsmPrinter the type hash is 
> > > > emitted after the patchable-function-prefix nops, while the KCFI type 
> > > > hash is emitted before them.
> > > My concern is more along the lines of how would this function be patched 
> > > if the code doing the patching were unaware of the signature. I'm not 
> > > familiar with how the kernel uses the nops so it could be that this is 
> > > won't be a problem in practice.
> > > 
> > > With -fsanitize=kcfi it looks like there is no difference to the code 
> > > doing the patching as the nops are in the same place with respect to the 
> > > function entry point and there is no fall through into the signature.
> > > 
> > > With -fsanitize=function anything patching the first nop as an 
> > > instruction would need to branch over the signature (unless the first 
> > > entry of the signature was a branch instruction, but that would mean a 
> > > target specific signature), obviously if the nop is patched with data and 
> > > isn't the entry point then this doesn't matter. The code doing the 
> > > patching would also need to know how to locate the nop ahead of the 
> > > signature.
> > The responsibility is on the user side to ensure that when M>0, they code 
> > patches one of the M NOPs to a branch over the signature (0xc105cafe). 
> > 
> > ```
> > // -fsanitize=function -fpatchable-function-entry=3,3
> > .Ltmp0:
> > nop
> > nop
> > nop# ensure there is a branch over the signature
> > .long   3238382334  # 0xc105cafe
> > .long   2772461324  # 0xa540670c
> > foo:
> > ```
> > 
> > In addition, `-fpatchable-function-entry=N,M` where M>0 is uncommon. 
> > `-fpatchable-function-entry=` didn't work with `-fsanitize=function` before 
> > my changes.
> > 
> > My concern is more along the lines of how would this function be patched if 
> > the code doing the patching were unaware of the signature. I'm not familiar 
> > with how the kernel uses the nops so it could be that this is won't be a 
> > problem in practice.
> 
> I think the patching code must be aware if the user decides to use 
> `-fpatchable-function-entry=N,M` where `M>0`, otherwise it's the pilot error 
> to use the option with `-fsanitize=function`.
> 
> `-fsanitize=function` is designed to be compatible with uninstrumented 
> functions (used as indirect call callees) and compatible with object files,  
> `-fpatchable-function-entry=N,M` functions, and regular functions. The call 
> site must use the fixed offset unaffected by `-fpatchable-function-entry=N,M`.
I don't have any objections here. Just wanted to make sure that we weren't 
breaking any exp

[PATCH] D149447: [clang][analyzer] Improve documentation of StdCLibraryFunctionArgs checker (NFC)

2023-05-18 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4400ff587be2: [clang][analyzer] Improve documentation of 
StdCLibraryFunctionArgs checker (NFC) (authored by balazske).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149447

Files:
  clang/docs/analyzer/checkers.rst

Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -2432,17 +2432,57 @@
 
 .. code-block:: c
 
+  #define EOF -1
   void test_alnum_concrete(int v) {
 int ret = isalnum(256); // \
-// warning: Function argument constraint is not satisfied
+// warning: Function argument outside of allowed range
 (void)ret;
   }
 
-If the argument's value is unknown then the value is assumed to hold the proper value range.
+  void buffer_size_violation(FILE *file) {
+enum { BUFFER_SIZE = 1024 };
+wchar_t wbuf[BUFFER_SIZE];
+
+const size_t size = sizeof(*wbuf);   // 4
+const size_t nitems = sizeof(wbuf);  // 4096
+
+// Below we receive a warning because the 3rd parameter should be the
+// number of elements to read, not the size in bytes. This case is a known
+// vulnerability described by the ARR38-C SEI-CERT rule.
+fread(wbuf, size, nitems, file);
+  }
+
+You can think of this checker as defining restrictions (pre- and postconditions)
+on standard library functions. Preconditions are checked, and when they are
+violated, a warning is emitted. Post conditions are added to the analysis, e.g.
+that the return value must be no greater than 255.
+
+These are the possible checks on the values passed as function arguments:
+ - The argument has an allowed range (or multiple ranges) of values. The checker
+   can detect if a passed value is outside of the allowed range and show the
+   actual and allowed values.
+ - The argument has pointer type and is not allowed to be null pointer. Many
+   (but not all) standard functions can produce undefined behavior if a null
+   pointer is passed, these cases can be detected by the checker.
+ - The argument is a pointer to a memory block and the minimal size of this
+   buffer is determined by another argument to the function, or by
+   multiplication of two arguments (like at function ``fread``), or is a fixed
+   value (for example ``asctime_r`` requires at least a buffer of size 26). The
+   checker can detect if the buffer size is too small and in optimal case show
+   the size of the buffer and the values of the corresponding arguments.
+
+If the user disables the checker then the argument violation warning is
+suppressed. However, the assumption about the argument is still modeled.
+For instance, if the argument to a function must be in between 0 and 255,
+but the value of the argument is unknown, the analyzer will conservatively
+assume that it is in this interval, even if warnings for this checker are
+disabled. Similarly, if a function mustn't be called with a null pointer but it
+is, analysis will stop on that execution path (similarly to a division by zero),
+with or without a warning. If the null value of the argument can not be proven,
+the analyzer will assume that it is non-null.
 
 .. code-block:: c
 
-  #define EOF -1
   int test_alnum_symbolic(int x) {
 int ret = isalnum(x);
 // after the call, ret is assumed to be in the range [-1, 255]
@@ -2453,55 +2493,27 @@
 return ret;
   }
 
-If the user disables the checker then the argument violation warning is
-suppressed. However, the assumption about the argument is still modeled. This
-is because exploring an execution path that already contains undefined behavior
-is not valuable.
-
-There are different kind of constraints modeled: range constraint, not null
-constraint, buffer size constraint. A **range constraint** requires the
-argument's value to be in a specific range, see ``isalnum`` as an example above.
-A **not null constraint** requires the pointer argument to be non-null.
-
-A **buffer size** constraint specifies the minimum size of the buffer
-argument. The size might be a known constant. For example, ``asctime_r`` requires
-that the buffer argument's size must be greater than or equal to ``26`` bytes. In
-other cases, the size is denoted by another argument or as a multiplication of
-two arguments.
-For instance, ``size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)``.
-Here, ``ptr`` is the buffer, and its minimum size is ``size * nmemb``
-
-.. code-block:: c
-
-  void buffer_size_constraint_violation(FILE *file) {
-enum { BUFFER_SIZE = 1024 };
-wchar_t wbuf[BUFFER_SIZE];
-
-const size_t size = sizeof(*wbuf);   // 4
-const size_t nitems = sizeof(wbuf);  // 4096
-
-// Below we receive a warning because the 3rd parameter should be the
-// number of elements to read, not the size in bytes. This case is a

[clang] 4400ff5 - [clang][analyzer] Improve documentation of StdCLibraryFunctionArgs checker (NFC)

2023-05-18 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2023-05-18T11:25:09+02:00
New Revision: 4400ff587be2d0baff5067f3fa210f9c34af2737

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

LOG: [clang][analyzer] Improve documentation of StdCLibraryFunctionArgs checker 
(NFC)

Documentation is made more exact, term "constraint" is removed entirely,
description of checker option is corrected.

Reviewed By: Szelethus, gamesh411

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

Added: 


Modified: 
clang/docs/analyzer/checkers.rst

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index ae2da6d2d96f0..e32f9c799240e 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2432,17 +2432,57 @@ not representable as unsigned char and is not equal to 
``EOF``.
 
 .. code-block:: c
 
+  #define EOF -1
   void test_alnum_concrete(int v) {
 int ret = isalnum(256); // \
-// warning: Function argument constraint is not satisfied
+// warning: Function argument outside of allowed range
 (void)ret;
   }
 
-If the argument's value is unknown then the value is assumed to hold the 
proper value range.
+  void buffer_size_violation(FILE *file) {
+enum { BUFFER_SIZE = 1024 };
+wchar_t wbuf[BUFFER_SIZE];
+
+const size_t size = sizeof(*wbuf);   // 4
+const size_t nitems = sizeof(wbuf);  // 4096
+
+// Below we receive a warning because the 3rd parameter should be the
+// number of elements to read, not the size in bytes. This case is a known
+// vulnerability described by the ARR38-C SEI-CERT rule.
+fread(wbuf, size, nitems, file);
+  }
+
+You can think of this checker as defining restrictions (pre- and 
postconditions)
+on standard library functions. Preconditions are checked, and when they are
+violated, a warning is emitted. Post conditions are added to the analysis, e.g.
+that the return value must be no greater than 255.
+
+These are the possible checks on the values passed as function arguments:
+ - The argument has an allowed range (or multiple ranges) of values. The 
checker
+   can detect if a passed value is outside of the allowed range and show the
+   actual and allowed values.
+ - The argument has pointer type and is not allowed to be null pointer. Many
+   (but not all) standard functions can produce undefined behavior if a null
+   pointer is passed, these cases can be detected by the checker.
+ - The argument is a pointer to a memory block and the minimal size of this
+   buffer is determined by another argument to the function, or by
+   multiplication of two arguments (like at function ``fread``), or is a fixed
+   value (for example ``asctime_r`` requires at least a buffer of size 26). The
+   checker can detect if the buffer size is too small and in optimal case show
+   the size of the buffer and the values of the corresponding arguments.
+
+If the user disables the checker then the argument violation warning is
+suppressed. However, the assumption about the argument is still modeled.
+For instance, if the argument to a function must be in between 0 and 255,
+but the value of the argument is unknown, the analyzer will conservatively
+assume that it is in this interval, even if warnings for this checker are
+disabled. Similarly, if a function mustn't be called with a null pointer but it
+is, analysis will stop on that execution path (similarly to a division by 
zero),
+with or without a warning. If the null value of the argument can not be proven,
+the analyzer will assume that it is non-null.
 
 .. code-block:: c
 
-  #define EOF -1
   int test_alnum_symbolic(int x) {
 int ret = isalnum(x);
 // after the call, ret is assumed to be in the range [-1, 255]
@@ -2453,55 +2493,27 @@ If the argument's value is unknown then the value is 
assumed to hold the proper
 return ret;
   }
 
-If the user disables the checker then the argument violation warning is
-suppressed. However, the assumption about the argument is still modeled. This
-is because exploring an execution path that already contains undefined behavior
-is not valuable.
-
-There are 
diff erent kind of constraints modeled: range constraint, not null
-constraint, buffer size constraint. A **range constraint** requires the
-argument's value to be in a specific range, see ``isalnum`` as an example 
above.
-A **not null constraint** requires the pointer argument to be non-null.
-
-A **buffer size** constraint specifies the minimum size of the buffer
-argument. The size might be a known constant. For example, ``asctime_r`` 
requires
-that the buffer argument's size must be greater than or equal to ``26`` bytes. 
In
-other cases, the size is denoted by another argument or as a multiplication of
-two arguments.
-For instance

[PATCH] D146557: [MLIR][OpenMP] Refactoring how map clause is processed

2023-05-18 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 523303.
TIFitis added a comment.

Done migrating from Clang. This makes use of the clang functions now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146557

Files:
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
  mlir/test/Target/LLVMIR/omptarget-llvm.mlir

Index: mlir/test/Target/LLVMIR/omptarget-llvm.mlir
===
--- mlir/test/Target/LLVMIR/omptarget-llvm.mlir
+++ mlir/test/Target/LLVMIR/omptarget-llvm.mlir
@@ -11,29 +11,28 @@
   llvm.return
 }
 
+// CHECK: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4]
 // CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 3]
 // CHECK-LABEL: define void @_QPopenmp_target_data() {
 // CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
-// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_3:.*]] = alloca i32, i64 1, align 4
 // CHECK: br label %[[VAL_4:.*]]
-// CHECK:   [[VAL_4]]:
-// CHECK: %[[VAL_5:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_5]], align 8
-// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK:   entry:; preds = %[[VAL_5:.*]]
+// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
 // CHECK: store ptr %[[VAL_3]], ptr %[[VAL_6]], align 8
-// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: store i64 ptrtoint (ptr getelementptr (ptr, ptr null, i32 1) to i64), ptr %[[VAL_7]], align 4
-// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_8]], ptr %[[VAL_9]], ptr %[[VAL_10]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_7]], align 8
+// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_2]], i64 0, i64 0
+// CHECK: store ptr null, ptr %[[VAL_8]], align 8
+// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_9]], ptr %[[VAL_10]], ptr @.offload_sizes, ptr @.offload_maptypes, ptr null, ptr null)
 // CHECK: store i32 99, ptr %[[VAL_3]], align 4
 // CHECK: %[[VAL_11:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
 // CHECK: %[[VAL_12:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: %[[VAL_13:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_11]], ptr %[[VAL_12]], ptr %[[VAL_13]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_11]], ptr %[[VAL_12]], ptr @.offload_sizes, ptr @.offload_maptypes, ptr null, ptr null)
 // CHECK: ret void
 
 // -
@@ -51,35 +50,34 @@
   llvm.return
 }
 
+// CHECK: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4096]
 // CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 2]
 // CHECK-LABEL: define void @_QPopenmp_target_data_region
 // CHECK: (ptr %[[ARG_0:.*]]) {
 // CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
-// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
 // CHECK: br label %[[VAL_3:.*]]
-// CHECK:   [[VAL_3]]:
-// CHECK: %[[VAL_4:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_5:.*]], ptr %[[VAL_4]], align 8
-// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: 

[PATCH] D146557: [MLIR][OpenMP] Refactoring createTargetData in OMPIRBuilder

2023-05-18 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 523304.
TIFitis edited the summary of this revision.
TIFitis added a comment.

Small fix to code comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146557

Files:
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
  mlir/test/Target/LLVMIR/omptarget-llvm.mlir

Index: mlir/test/Target/LLVMIR/omptarget-llvm.mlir
===
--- mlir/test/Target/LLVMIR/omptarget-llvm.mlir
+++ mlir/test/Target/LLVMIR/omptarget-llvm.mlir
@@ -11,29 +11,28 @@
   llvm.return
 }
 
+// CHECK: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4]
 // CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 3]
 // CHECK-LABEL: define void @_QPopenmp_target_data() {
 // CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
-// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_3:.*]] = alloca i32, i64 1, align 4
 // CHECK: br label %[[VAL_4:.*]]
-// CHECK:   [[VAL_4]]:
-// CHECK: %[[VAL_5:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_5]], align 8
-// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK:   entry:; preds = %[[VAL_5:.*]]
+// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
 // CHECK: store ptr %[[VAL_3]], ptr %[[VAL_6]], align 8
-// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: store i64 ptrtoint (ptr getelementptr (ptr, ptr null, i32 1) to i64), ptr %[[VAL_7]], align 4
-// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_8]], ptr %[[VAL_9]], ptr %[[VAL_10]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_7]], align 8
+// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_2]], i64 0, i64 0
+// CHECK: store ptr null, ptr %[[VAL_8]], align 8
+// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_9]], ptr %[[VAL_10]], ptr @.offload_sizes, ptr @.offload_maptypes, ptr null, ptr null)
 // CHECK: store i32 99, ptr %[[VAL_3]], align 4
 // CHECK: %[[VAL_11:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
 // CHECK: %[[VAL_12:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: %[[VAL_13:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_11]], ptr %[[VAL_12]], ptr %[[VAL_13]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_11]], ptr %[[VAL_12]], ptr @.offload_sizes, ptr @.offload_maptypes, ptr null, ptr null)
 // CHECK: ret void
 
 // -
@@ -51,35 +50,34 @@
   llvm.return
 }
 
+// CHECK: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4096]
 // CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 2]
 // CHECK-LABEL: define void @_QPopenmp_target_data_region
 // CHECK: (ptr %[[ARG_0:.*]]) {
 // CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
-// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
 // CHECK: br label %[[VAL_3:.*]]
-// CHECK:   [[VAL_3]]:
-// CHECK: %[[VAL_4:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_5:.*]], ptr %[[VAL_4]], align 8
-// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK:  

[PATCH] D150087: [Clang] Support more stdio builtins

2023-05-18 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf updated this revision to Diff 523305.
qiucf marked an inline comment as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150087

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/PowerPC/ppc64-f128-builtins.c

Index: clang/test/CodeGen/PowerPC/ppc64-f128-builtins.c
===
--- clang/test/CodeGen/PowerPC/ppc64-f128-builtins.c
+++ clang/test/CodeGen/PowerPC/ppc64-f128-builtins.c
@@ -52,6 +52,63 @@
   __builtin_snprintf(buf, 20, "%.Lf", x);
 }
 
+// IEEE128-LABEL: define dso_local void @test_scanf
+// IEEE128: call signext i32 (ptr, ...) @__scanfieee128
+// PPC128-LABEL: define dso_local void @test_scanf
+// PPC128: call signext i32 (ptr, ...) @scanf
+void test_scanf(int *x) {
+  __builtin_scanf("%d", x);
+}
+
+// IEEE128-LABEL: define dso_local void @test_sscanf
+// IEEE128: call signext i32 (ptr, ptr, ...) @__sscanfieee128
+// PPC128-LABEL: define dso_local void @test_sscanf
+// PPC128: call signext i32 (ptr, ptr, ...) @sscanf
+void test_sscanf(int *x) {
+  __builtin_sscanf(buf, "%d", x);
+}
+
+// IEEE128-LABEL: define dso_local void @test_vprintf
+// IEEE128: call signext i32 @__vprintfieee128
+// PPC128-LABEL: define dso_local void @test_vprintf
+// PPC128: call signext i32 @vprintf
+void test_vprintf(const char *fmt, ...) {
+  __builtin_va_list args;
+  __builtin_va_start(args, fmt);
+  __builtin_vprintf(fmt, args);
+  __builtin_va_end(args);
+}
+
+// IEEE128-LABEL: define dso_local void @test_vscanf
+// IEEE128: call signext i32 @__vscanfieee128
+// PPC128-LABEL: define dso_local void @test_vscanf
+// PPC128: call signext i32 @vscanf
+void test_vscanf(const char *fmt, ...) {
+  __builtin_va_list args;
+  __builtin_va_start(args, fmt);
+  __builtin_vscanf(fmt, args);
+  __builtin_va_end(args);
+}
+
+// IEEE128-LABEL: define dso_local void @test_vsscanf
+// IEEE128: call signext i32 @__vsscanfieee128
+// PPC128-LABEL: define dso_local void @test_vsscanf
+// PPC128: call signext i32 @vsscanf
+void test_vsscanf(const char *fmt, ...) {
+  __builtin_va_list args;
+  __builtin_va_start(args, fmt);
+  __builtin_vsscanf(buf, fmt, args);
+  __builtin_va_end(args);
+}
+
+// IEEE128-LABEL: define dso_local void @test_snprintf_chk
+// IEEE128: call signext i32 (ptr, i64, i32, i64, ptr, ...) @__snprintf_chkieee128
+// PPC128-LABEL: define dso_local void @test_snprintf_chk
+// PPC128: call signext i32 (ptr, i64, i32, i64, ptr, ...) @__snprintf_chk
+void test_snprintf_chk(long double x) {
+  __builtin___snprintf_chk(buf, 20, 1, 20, "%.Lf", x);
+}
+
 // GLIBC has special handling of 'nexttoward'
 
 // IEEE128-LABEL: define dso_local fp128 @test_nexttoward
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -99,13 +99,29 @@
 
   // TODO: This list should be expanded or refactored after all GCC-compatible
   // std libcall builtins are implemented.
-  static SmallDenseMap F128Builtins{
+  static SmallDenseMap F128Builtins{
+  {Builtin::BI__builtin___fprintf_chk, "__fprintf_chkieee128"},
+  {Builtin::BI__builtin___printf_chk, "__printf_chkieee128"},
+  {Builtin::BI__builtin___snprintf_chk, "__snprintf_chkieee128"},
+  {Builtin::BI__builtin___sprintf_chk, "__sprintf_chkieee128"},
+  {Builtin::BI__builtin___vfprintf_chk, "__vfprintf_chkieee128"},
+  {Builtin::BI__builtin___vprintf_chk, "__vprintf_chkieee128"},
+  {Builtin::BI__builtin___vsnprintf_chk, "__vsnprintf_chkieee128"},
+  {Builtin::BI__builtin___vsprintf_chk, "__vsprintf_chkieee128"},
+  {Builtin::BI__builtin_fprintf, "__fprintfieee128"},
   {Builtin::BI__builtin_printf, "__printfieee128"},
+  {Builtin::BI__builtin_snprintf, "__snprintfieee128"},
+  {Builtin::BI__builtin_sprintf, "__sprintfieee128"},
+  {Builtin::BI__builtin_vfprintf, "__vfprintfieee128"},
+  {Builtin::BI__builtin_vprintf, "__vprintfieee128"},
   {Builtin::BI__builtin_vsnprintf, "__vsnprintfieee128"},
   {Builtin::BI__builtin_vsprintf, "__vsprintfieee128"},
-  {Builtin::BI__builtin_sprintf, "__sprintfieee128"},
-  {Builtin::BI__builtin_snprintf, "__snprintfieee128"},
-  {Builtin::BI__builtin_fprintf, "__fprintfieee128"},
+  {Builtin::BI__builtin_fscanf, "__fscanfieee128"},
+  {Builtin::BI__builtin_scanf, "__scanfieee128"},
+  {Builtin::BI__builtin_sscanf, "__sscanfieee128"},
+  {Builtin::BI__builtin_vfscanf, "__vfscanfieee128"},
+  {Builtin::BI__builtin_vscanf, "__vscanfieee128"},
+  {Builtin::BI__builtin_vsscanf, "__vsscanfieee128"},
   {Builtin::BI__builtin_nexttowardf128, "__nexttowardieee128"},
   };
 
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ 

[PATCH] D150087: [Clang] Support more stdio builtins

2023-05-18 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf marked an inline comment as done.
qiucf added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:109
+  {Builtin::BI__builtin___vsnprintf_chk, "__vsnprintfieee128"},
+  {Builtin::BI__builtin___vsprintf_chk, "__vsprintfieee128"},
+  {Builtin::BI__builtin_fprintf, "__fprintfieee128"},

tuliom wrote:
> Any reasons to not map these built-ins to their respective `_chkieee128` 
> counterparts? e.g. `__fprintf_chkieee128`.
Updated.

I just saw GCC in some cases emits no-chk version when calling 
`__builtin_*printf_chk`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150087

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


[PATCH] D146557: [MLIR][OpenMP] Refactoring createTargetData in OMPIRBuilder

2023-05-18 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 523316.
TIFitis added a comment.

Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146557

Files:
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
  mlir/test/Target/LLVMIR/omptarget-llvm.mlir

Index: mlir/test/Target/LLVMIR/omptarget-llvm.mlir
===
--- mlir/test/Target/LLVMIR/omptarget-llvm.mlir
+++ mlir/test/Target/LLVMIR/omptarget-llvm.mlir
@@ -11,29 +11,28 @@
   llvm.return
 }
 
+// CHECK: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4]
 // CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 3]
 // CHECK-LABEL: define void @_QPopenmp_target_data() {
 // CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
-// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_3:.*]] = alloca i32, i64 1, align 4
 // CHECK: br label %[[VAL_4:.*]]
-// CHECK:   [[VAL_4]]:
-// CHECK: %[[VAL_5:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_5]], align 8
-// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK:   entry:; preds = %[[VAL_5:.*]]
+// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
 // CHECK: store ptr %[[VAL_3]], ptr %[[VAL_6]], align 8
-// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: store i64 ptrtoint (ptr getelementptr (ptr, ptr null, i32 1) to i64), ptr %[[VAL_7]], align 4
-// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_8]], ptr %[[VAL_9]], ptr %[[VAL_10]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_7]], align 8
+// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_2]], i64 0, i64 0
+// CHECK: store ptr null, ptr %[[VAL_8]], align 8
+// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_9]], ptr %[[VAL_10]], ptr @.offload_sizes, ptr @.offload_maptypes, ptr null, ptr null)
 // CHECK: store i32 99, ptr %[[VAL_3]], align 4
 // CHECK: %[[VAL_11:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
 // CHECK: %[[VAL_12:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: %[[VAL_13:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_11]], ptr %[[VAL_12]], ptr %[[VAL_13]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_11]], ptr %[[VAL_12]], ptr @.offload_sizes, ptr @.offload_maptypes, ptr null, ptr null)
 // CHECK: ret void
 
 // -
@@ -51,35 +50,34 @@
   llvm.return
 }
 
+// CHECK: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4096]
 // CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 2]
 // CHECK-LABEL: define void @_QPopenmp_target_data_region
 // CHECK: (ptr %[[ARG_0:.*]]) {
 // CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
-// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
 // CHECK: br label %[[VAL_3:.*]]
-// CHECK:   [[VAL_3]]:
-// CHECK: %[[VAL_4:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_5:.*]], ptr %[[VAL_4]], align 8
-// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_5]], ptr %[[VAL_6]], align 8
-// CHECK:  

[PATCH] D146557: [MLIR][OpenMP] Refactoring createTargetData in OMPIRBuilder

2023-05-18 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 523318.
TIFitis added a comment.

Fix lint messages


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146557

Files:
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
  mlir/test/Target/LLVMIR/omptarget-llvm.mlir

Index: mlir/test/Target/LLVMIR/omptarget-llvm.mlir
===
--- mlir/test/Target/LLVMIR/omptarget-llvm.mlir
+++ mlir/test/Target/LLVMIR/omptarget-llvm.mlir
@@ -11,29 +11,28 @@
   llvm.return
 }
 
+// CHECK: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4]
 // CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 3]
 // CHECK-LABEL: define void @_QPopenmp_target_data() {
 // CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
-// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_3:.*]] = alloca i32, i64 1, align 4
 // CHECK: br label %[[VAL_4:.*]]
-// CHECK:   [[VAL_4]]:
-// CHECK: %[[VAL_5:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_5]], align 8
-// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK:   entry:; preds = %[[VAL_5:.*]]
+// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
 // CHECK: store ptr %[[VAL_3]], ptr %[[VAL_6]], align 8
-// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: store i64 ptrtoint (ptr getelementptr (ptr, ptr null, i32 1) to i64), ptr %[[VAL_7]], align 4
-// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_8]], ptr %[[VAL_9]], ptr %[[VAL_10]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_7]], align 8
+// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_2]], i64 0, i64 0
+// CHECK: store ptr null, ptr %[[VAL_8]], align 8
+// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_9]], ptr %[[VAL_10]], ptr @.offload_sizes, ptr @.offload_maptypes, ptr null, ptr null)
 // CHECK: store i32 99, ptr %[[VAL_3]], align 4
 // CHECK: %[[VAL_11:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
 // CHECK: %[[VAL_12:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: %[[VAL_13:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_11]], ptr %[[VAL_12]], ptr %[[VAL_13]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_11]], ptr %[[VAL_12]], ptr @.offload_sizes, ptr @.offload_maptypes, ptr null, ptr null)
 // CHECK: ret void
 
 // -
@@ -51,35 +50,34 @@
   llvm.return
 }
 
+// CHECK: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4096]
 // CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 2]
 // CHECK-LABEL: define void @_QPopenmp_target_data_region
 // CHECK: (ptr %[[ARG_0:.*]]) {
 // CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
-// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
 // CHECK: br label %[[VAL_3:.*]]
-// CHECK:   [[VAL_3]]:
-// CHECK: %[[VAL_4:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_5:.*]], ptr %[[VAL_4]], align 8
-// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_5]], ptr %[[VAL_6]], align 8
-/

[PATCH] D149548: [IR] Update to use new shufflevector semantics

2023-05-18 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito added reviewers: qiucf, lkail, shchenz.
ManuelJBrito added a comment.

Adding some PowerPC folks to review the change in codegen for vec_promote.
AFAICT its OK to have the undefined values be poison.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149548

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


[PATCH] D146873: [2/11][POC][Clang][RISCV] Define RVV tuple types

2023-05-18 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 523323.
eopXD marked an inline comment as done.
eopXD added a comment.

Bump CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146873

Files:
  clang/include/clang/Basic/RISCVVTypes.def
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type-0.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type-1.c
  clang/test/Sema/riscv-types.c

Index: clang/test/Sema/riscv-types.c
===
--- clang/test/Sema/riscv-types.c
+++ clang/test/Sema/riscv-types.c
@@ -133,6 +133,9 @@
 
   // CHECK: __rvv_int8mf2_t x43;
   __rvv_int8mf2_t x43;
+
+  // CHECK: __rvv_int32m1x2_t x44;
+  __rvv_int32m1x2_t x44;
 }
 
 typedef __rvv_bool4_t vbool4_t;
Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type-1.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type-1.c
@@ -0,0 +1,49 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zve32x -disable-O0-optnone \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | FileCheck %s
+
+#include 
+
+// Declare local variable
+// CHECK-LABEL: define dso_local void @foo
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret void
+//
+void foo() {
+  __rvv_int32m1x2_t v_tuple;
+}
+
+// Declare local variable and return
+// CHECK-LABEL: define dso_local { ,  } @bar
+// CHECK-SAME: () #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret { ,  } undef
+//
+__rvv_int32m1x2_t bar() {
+  __rvv_int32m1x2_t v_tuple;
+  return v_tuple;
+}
+
+// Pass as function parameter
+// CHECK-LABEL: define dso_local void @baz
+// CHECK-SAME: ( [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-NEXT:ret void
+//
+void baz(__rvv_int32m1x2_t v_tuple) {
+}
+
+// Pass as function parameter and return
+// CHECK-LABEL: define dso_local { ,  } @qux
+// CHECK-SAME: ( [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-NEXT:ret { ,  } [[TMP1]]
+//
+__rvv_int32m1x2_t qux(__rvv_int32m1x2_t v_tuple) {
+  return v_tuple;
+}
Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type-0.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type-0.c
@@ -0,0 +1,63 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zve32x -O0 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+
+#include 
+
+// Declare local variable
+// CHECK-LABEL: define dso_local void @foo
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[V_TUPLE:%.*]] = alloca { ,  }, align 4
+// CHECK-NEXT:ret void
+//
+void foo() {
+  __rvv_int32m1x2_t v_tuple;
+}
+
+// Declare local variable and return
+// CHECK-LABEL: define dso_local { ,  } @bar
+// CHECK-SAME: () #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[V_TUPLE:%.*]] = alloca { ,  }, align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load { ,  }, ptr [[V_TUPLE]], align 4
+// CHECK-NEXT:ret { ,  } [[TMP0]]
+//
+__rvv_int32m1x2_t bar() {
+  __rvv_int32m1x2_t v_tuple;
+  return v_tuple;
+}
+
+// Pass as function parameter
+// CHECK-LABEL: define dso_local void @baz
+// CHECK-SAME: ( [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[V_TUPLE:%.*]] = alloca { ,  }, align 4
+// CHECK-NEXT:[[V_TUPLE_ADDR:%.*]] = alloca { ,  }, align 4
+// CHECK-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-NEXT:store { ,  } [[TMP1]], ptr [[V_TUPLE]], align 4
+// CHECK-NEXT:[[V_TUPLE1:%.*]] = load { ,  }, ptr [[V_TUPLE]], align 4
+// CHECK-NEXT:store { ,  } [[V_TUPLE1]], ptr [[V_TUPLE_ADDR]], align 4
+// CHECK-NEXT:ret void
+//
+void baz(__rvv_int32m1x2_t v_tuple) {
+}
+
+// Pass as function parameter and return
+// CHECK-LABEL: define dso_local { ,  } @qux
+// CHECK-SAME: ( [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[V_TUPLE:%.*]] = alloca { ,  }, align 4
+/

[PATCH] D146557: [MLIR][OpenMP] Refactoring createTargetData in OMPIRBuilder

2023-05-18 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 523331.
TIFitis added a comment.

Try to fix patch application.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146557

Files:
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
  mlir/test/Target/LLVMIR/omptarget-llvm.mlir

Index: mlir/test/Target/LLVMIR/omptarget-llvm.mlir
===
--- mlir/test/Target/LLVMIR/omptarget-llvm.mlir
+++ mlir/test/Target/LLVMIR/omptarget-llvm.mlir
@@ -11,29 +11,28 @@
   llvm.return
 }
 
+// CHECK: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4]
 // CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 3]
 // CHECK-LABEL: define void @_QPopenmp_target_data() {
 // CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
-// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_3:.*]] = alloca i32, i64 1, align 4
 // CHECK: br label %[[VAL_4:.*]]
-// CHECK:   [[VAL_4]]:
-// CHECK: %[[VAL_5:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_5]], align 8
-// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK:   entry:; preds = %[[VAL_5:.*]]
+// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
 // CHECK: store ptr %[[VAL_3]], ptr %[[VAL_6]], align 8
-// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: store i64 ptrtoint (ptr getelementptr (ptr, ptr null, i32 1) to i64), ptr %[[VAL_7]], align 4
-// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_8]], ptr %[[VAL_9]], ptr %[[VAL_10]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_7]], align 8
+// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_2]], i64 0, i64 0
+// CHECK: store ptr null, ptr %[[VAL_8]], align 8
+// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_9]], ptr %[[VAL_10]], ptr @.offload_sizes, ptr @.offload_maptypes, ptr null, ptr null)
 // CHECK: store i32 99, ptr %[[VAL_3]], align 4
 // CHECK: %[[VAL_11:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
 // CHECK: %[[VAL_12:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: %[[VAL_13:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
-// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_11]], ptr %[[VAL_12]], ptr %[[VAL_13]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_11]], ptr %[[VAL_12]], ptr @.offload_sizes, ptr @.offload_maptypes, ptr null, ptr null)
 // CHECK: ret void
 
 // -
@@ -51,35 +50,34 @@
   llvm.return
 }
 
+// CHECK: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 4096]
 // CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 2]
 // CHECK-LABEL: define void @_QPopenmp_target_data_region
 // CHECK: (ptr %[[ARG_0:.*]]) {
 // CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
 // CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
-// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x ptr], align 8
 // CHECK: br label %[[VAL_3:.*]]
-// CHECK:   [[VAL_3]]:
-// CHECK: %[[VAL_4:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_5:.*]], ptr %[[VAL_4]], align 8
-// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
-// CHECK: store ptr %[[VAL_5]], ptr %[[VAL_6]]

[PATCH] D150860: [OpenMP] Change clang emitTargetDataCalls to use OMPIRBuilder

2023-05-18 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis created this revision.
TIFitis added reviewers: jsjodin, dpalermo, kiranktp, jdoerfert.
Herald added subscribers: sunshaoce, guansong, hiraditya, yaxunl.
Herald added a project: All.
TIFitis requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, jplehr, sstefan1.
Herald added projects: clang, LLVM.

This patch changes the emitTargetDataCalls function in clang to make use of the 
OpenMPIRBuilder::createTargetData function for Target Data directive code gen.

Depends on D146557 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150860

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4082,7 +4082,9 @@
 TargetDataInfo &Info,
 function_ref GenMapInfoCB,
 function_ref
-BodyGenCB) {
+BodyGenCB,
+function_ref DeviceAddrCB,
+function_ref CustomMapperCB) {
   if (!updateToLocation(Loc))
 return InsertPointTy();
 
@@ -4093,9 +4095,9 @@
   // arguments of the runtime call by reference because they are used in the
   // closing of the region.
   auto BeginThenGen = [&](InsertPointTy UnusedIP, InsertPointTy CodeGenIP) {
-emitOffloadingArrays(AllocaIP, Builder.saveIP(),
- GenMapInfoCB(Builder.saveIP()), Info,
- /*IsNonContiguous=*/true);
+emitOffloadingArrays(
+AllocaIP, Builder.saveIP(), GenMapInfoCB(Builder.saveIP()), Info,
+/*IsNonContiguous=*/true, DeviceAddrCB, CustomMapperCB);
 
 TargetDataRTArgs RTArgs;
 emitOffloadingArraysArgument(Builder, RTArgs, Info);
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -1888,13 +1888,19 @@
   /// \param Info Stores all information realted to the Target Data directive.
   /// \param GenMapInfoCB Callback that populates the MapInfos and returns.
   /// \param BodyGenCB Optional Callback to generate the region code.
+  /// \param DeviceAddrCB Optional callback to generate code related to
+  /// use_device_ptr and use_device_addr.
+  /// \param CustomMapperCB Optional callback to generate code related to
+  /// custom mappers.
   OpenMPIRBuilder::InsertPointTy createTargetData(
   const LocationDescription &Loc, InsertPointTy AllocaIP,
   InsertPointTy CodeGenIP, bool IsBegin, Value *DeviceID, Value *IfCond,
   TargetDataInfo &Info,
   function_ref GenMapInfoCB,
   function_ref
-  BodyGenCB = nullptr);
+  BodyGenCB = nullptr,
+  function_ref DeviceAddrCB = nullptr,
+  function_ref CustomMapperCB = nullptr);
 
   using TargetBodyGenCallbackTy = function_ref;
Index: clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
===
--- clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
+++ clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
@@ -131,7 +131,6 @@
 ++l;
   }
   // CK1: [[BEND]]:
-  // CK1: [[CMP:%.+]] = icmp ne ptr %{{.+}}, null
   // CK1: br i1 [[CMP]], label %[[BTHEN:.+]], label %[[BELSE:.+]]
 
   // CK1: [[BTHEN]]:
Index: clang/test/OpenMP/target_data_codegen.cpp
===
--- clang/test/OpenMP/target_data_codegen.cpp
+++ clang/test/OpenMP/target_data_codegen.cpp
@@ -63,9 +63,7 @@
 
   // CK1: %{{.+}} = add nsw i32 %{{[^,]+}}, 1
 
-  // CK1-DAG: call void @__tgt_target_data_end_mapper(ptr @{{.+}}, i64 [[DEV:%[^,]+]], i32 1, ptr [[GEPBP:%.+]], ptr [[GEPP:%.+]], ptr [[SIZE00]], ptr [[MTYPE00]], ptr null, ptr null)
-  // CK1-DAG: [[DEV]] = sext i32 [[DEVi32:%[^,]+]] to i64
-  // CK1-DAG: [[DEVi32]] = load i32, ptr %{{[^,]+}},
+  // CK1-DAG: call void @__tgt_target_data_end_mapper(ptr @{{.+}}, i64 [[DEV]], i32 1, ptr [[GEPBP:%.+]], ptr [[GEPP:%.+]], ptr [[SIZE00]], ptr [[MTYPE00]], ptr null, ptr null)
   // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP]]
 // CK1-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P]]
   #pragma omp target data if(1+3-5) device(arg) map(from: gc)
@@ -354,11 +352,11 @@
 }
 
 // Region 00
+// CK2-DAG: [[DEV:%[^,]+]] = sext i32 [[DEVi32:%[^,]+]] to i64
+// CK2-DAG: [[DEVi32]] = load i32, ptr %{{[^,]+}},
 // CK2: br i1 %{{[^,]+}}, label %[[IFTHEN:[^,]+]], label %[[IFELSE:[^,]+]]
 // CK2: [[IFTHEN]]
-// CK2-DAG: call void @__tgt_target_data_begin_mapper(ptr @{{.+}}, i64 [[DEV:%[^,]+]], i32 2, ptr [[GEPBP:%.+]], ptr [[GEPP:%.+]], ptr [[GEPS:%[^,]+]], ptr [[MTYPE00

[PATCH] D149872: [OpenMP][OMPIRBuilder] Migrate emitOffloadingArrays and EmitNonContiguousDescriptor from Clang

2023-05-18 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 523340.
TIFitis added a comment.

Rebasing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149872

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4406,6 +4406,260 @@
 Builder.CreatePointerCast(Info.RTArgs.MappersArray, VoidPtrPtrTy);
 }
 
+void OpenMPIRBuilder::emitNonContiguousDescriptor(InsertPointTy AllocaIP,
+  InsertPointTy CodeGenIP,
+  MapInfosTy &CombinedInfo,
+  TargetDataInfo &Info) {
+  MapInfosTy::StructNonContiguousInfo &NonContigInfo =
+  CombinedInfo.NonContigInfo;
+
+  // Build an array of struct descriptor_dim and then assign it to
+  // offload_args.
+  //
+  // struct descriptor_dim {
+  //  uint64_t offset;
+  //  uint64_t count;
+  //  uint64_t stride
+  // };
+  Type *Int64Ty = Builder.getInt64Ty();
+  StructType *DimTy = StructType::create(
+  M.getContext(), ArrayRef({Int64Ty, Int64Ty, Int64Ty}),
+  "struct.descriptor_dim");
+
+  enum { OffsetFD = 0, CountFD, StrideFD };
+  // We need two index variable here since the size of "Dims" is the same as
+  // the size of Components, however, the size of offset, count, and stride is
+  // equal to the size of base declaration that is non-contiguous.
+  for (unsigned I = 0, L = 0, E = NonContigInfo.Dims.size(); I < E; ++I) {
+// Skip emitting ir if dimension size is 1 since it cannot be
+// non-contiguous.
+if (NonContigInfo.Dims[I] == 1)
+  continue;
+Builder.restoreIP(AllocaIP);
+ArrayType *ArrayTy = ArrayType::get(DimTy, NonContigInfo.Dims[I]);
+AllocaInst *DimsAddr =
+Builder.CreateAlloca(ArrayTy, /* ArraySize = */ nullptr, "dims");
+Builder.restoreIP(CodeGenIP);
+for (unsigned II = 0, EE = NonContigInfo.Dims[I]; II < EE; ++II) {
+  unsigned RevIdx = EE - II - 1;
+  Value *DimsLVal = Builder.CreateInBoundsGEP(
+  DimsAddr->getAllocatedType(), DimsAddr,
+  {Builder.getInt64(0), Builder.getInt64(II)});
+  // Offset
+  Value *OffsetLVal = Builder.CreateStructGEP(DimTy, DimsLVal, OffsetFD);
+  Builder.CreateAlignedStore(
+  NonContigInfo.Offsets[L][RevIdx], OffsetLVal,
+  M.getDataLayout().getPrefTypeAlign(OffsetLVal->getType()));
+  // Count
+  Value *CountLVal = Builder.CreateStructGEP(DimTy, DimsLVal, CountFD);
+  Builder.CreateAlignedStore(
+  NonContigInfo.Counts[L][RevIdx], CountLVal,
+  M.getDataLayout().getPrefTypeAlign(CountLVal->getType()));
+  // Stride
+  Value *StrideLVal = Builder.CreateStructGEP(DimTy, DimsLVal, StrideFD);
+  Builder.CreateAlignedStore(
+  NonContigInfo.Strides[L][RevIdx], StrideLVal,
+  M.getDataLayout().getPrefTypeAlign(CountLVal->getType()));
+}
+// args[I] = &dims
+Builder.restoreIP(CodeGenIP);
+Value *DAddr = Builder.CreatePointerBitCastOrAddrSpaceCast(
+DimsAddr, Builder.getInt8PtrTy());
+Value *P = Builder.CreateConstInBoundsGEP2_32(
+ArrayType::get(Builder.getInt8PtrTy(), Info.NumberOfPtrs),
+Info.RTArgs.PointersArray, 0, I);
+Builder.CreateAlignedStore(
+DAddr, P, M.getDataLayout().getPrefTypeAlign(Builder.getInt8PtrTy()));
+++L;
+  }
+}
+
+void OpenMPIRBuilder::emitOffloadingArrays(
+InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
+TargetDataInfo &Info, bool IsNonContiguous,
+function_ref DeviceAddrCB,
+function_ref CustomMapperCB) {
+
+  // Reset the array information.
+  Info.clearArrayInfo();
+  Info.NumberOfPtrs = CombinedInfo.BasePointers.size();
+
+  if (Info.NumberOfPtrs) {
+Builder.restoreIP(AllocaIP);
+// Detect if we have any capture size requiring runtime evaluation of the
+// size so that a constant array could be eventually used.
+ArrayType *PointerArrayType =
+ArrayType::get(Builder.getInt8PtrTy(), Info.NumberOfPtrs);
+
+Info.RTArgs.BasePointersArray = Builder.CreateAlloca(
+PointerArrayType, /* ArraySize = */ nullptr, ".offload_baseptrs");
+
+Info.RTArgs.PointersArray = Builder.CreateAlloca(
+PointerArrayType, /* ArraySize = */ nullptr, ".offload_ptrs");
+AllocaInst *MappersArray = Builder.CreateAlloca(
+PointerArrayType, /* ArraySize = */ nullptr, ".offload_mappers");
+Info.RTArgs.MappersArray = MappersArray;
+
+// If we don't have any VLA types or other types that require runtime
+// evaluation, we can use a constant array for the map sizes, otherwise we
+// need to fill u

[PATCH] D150863: [CLANG][AArch64][SVE2.1] Add UCLAMP/SCLAMP/FCLAMP function prototypes

2023-05-18 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto created this revision.
Herald added subscribers: kristof.beyls, tschuett.
Herald added a project: All.
CarolineConcatto requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Submitting this patch in the name of: David Sherwood 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150863

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c
  clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_sclamp.c
  clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_uclamp.c
  llvm/include/llvm/TargetParser/AArch64TargetParser.h

Index: llvm/include/llvm/TargetParser/AArch64TargetParser.h
===
--- llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -253,7 +253,7 @@
 {"sve2-sha3", AArch64::AEK_SVE2SHA3, "+sve2-sha3", "-sve2-sha3", FEAT_SVE_SHA3, "+sve2,+sve,+sve2-sha3,+fullfp16,+fp-armv8,+neon", 410},
 {"sve2-sm4", AArch64::AEK_SVE2SM4, "+sve2-sm4", "-sve2-sm4", FEAT_SVE_SM4, "+sve2,+sve,+sve2-sm4,+fullfp16,+fp-armv8,+neon", 420},
 {"sve2", AArch64::AEK_SVE2, "+sve2", "-sve2", FEAT_SVE2, "+sve2,+sve,+fullfp16,+fp-armv8,+neon", 370},
-{"sve2p1", AArch64::AEK_SVE2p1, "+sve2p1", "-sve2p1", FEAT_MAX, "", 0},
+{"sve2p1", AArch64::AEK_SVE2p1, "+sve2p1", "-sve2p1", FEAT_MAX, "+sve2p1,+sve2,+sve,+fullfp16,+fp-armv8,+neon", 0},
 {"the", AArch64::AEK_THE, "+the", "-the", FEAT_MAX, "", 0},
 {"tme", AArch64::AEK_TME, "+tme", "-tme", FEAT_MAX, "", 0},
 {"wfxt", AArch64::AEK_NONE, {}, {}, FEAT_WFXT, "+wfxt", 550},
Index: clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_uclamp.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_uclamp.c
@@ -0,0 +1,78 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 \
+// RUN:   -S -Werror -emit-llvm -disable-O0-optnone -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2p1 \
+// RUN:   -S -Werror -emit-llvm -disable-O0-optnone -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 \
+// RUN:   -S -Werror -emit-llvm -disable-O0-optnone -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2p1 \
+// RUN:   -S -Werror -emit-llvm -disable-O0-optnone -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 \
+// RUN:   -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1, A2_UNUSED, A3, A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1, A2, A3, A4) A1##A2##A3##A4
+#endif
+
+// CHECK-LABEL: @test_svclamp_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.uclamp.nxv16i8( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z15test_svclamp_u8u11__SVUint8_tu11__SVUint8_tu11__SVUint8_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.uclamp.nxv16i8( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CPP-CHECK-NEXT:ret  [[TMP0]]
+//
+svuint8_t test_svclamp_u8(svuint8_t op1, svuint8_t op2, svuint8_t op3) {
+  return SVE_ACLE_FUNC(svclamp, _u8, , )(op1, op2, op3);
+}
+
+// CHECK-LABEL: @test_svclamp_u16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.uclamp.nxv8i16( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z16test_svclamp_u16u12__SVUint16_tu12__SVUint16_tu12__SVUint16_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.uclamp.nxv8i16( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CPP-CHECK-NEXT:ret  [[TMP0]]
+//
+svuint16_t test_svclamp_u16(svuint16_t op1, svuint16_t op2, svuint16_t op3) {
+  return SVE_ACLE_FUNC(svclamp, _u16, , )(op1, op2, op3);
+}
+
+// CHECK-LABEL: @test_svclamp_u32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.uclamp.nxv4i32( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z16test_svclamp_u32u12__SVUint32_tu12__SVUint32_tu12__SVUint32_t(
+// CPP-CHECK-NEXT:  entry

[PATCH] D150860: [OpenMP] Change clang emitTargetDataCalls to use OMPIRBuilder

2023-05-18 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis added inline comments.



Comment at: clang/test/OpenMP/target_data_codegen.cpp:67-68
-  // CK1-DAG: call void @__tgt_target_data_end_mapper(ptr @{{.+}}, i64 
[[DEV:%[^,]+]], i32 1, ptr [[GEPBP:%.+]], ptr [[GEPP:%.+]], ptr [[SIZE00]], ptr 
[[MTYPE00]], ptr null, ptr null)
-  // CK1-DAG: [[DEV]] = sext i32 [[DEVi32:%[^,]+]] to i64
-  // CK1-DAG: [[DEVi32]] = load i32, ptr %{{[^,]+}},
   // CK1-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP]]

Similar to what I discussed for the if clause, the device clause argument need 
not be recomputed.
We can reuse the device argument from the begin mapper for the end mapper as 
well.



Comment at: clang/test/OpenMP/target_data_codegen.cpp:355-356
 // Region 00
+// CK2-DAG: [[DEV:%[^,]+]] = sext i32 [[DEVi32:%[^,]+]] to i64
+// CK2-DAG: [[DEVi32]] = load i32, ptr %{{[^,]+}},
 // CK2: br i1 %{{[^,]+}}, label %[[IFTHEN:[^,]+]], label %[[IFELSE:[^,]+]]

When both if clause and device clause are present, the device clause argument 
is inadvertently brought outside the `IfThen` region as we emit the 
`llvm:Value` from the `Clang::Expr` for it before making call to 
createTargetData.

I don't think this change would affect any use cases.



Comment at: clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp:133-134
   }
   // CK1: [[BEND]]:
-  // CK1: [[CMP:%.+]] = icmp ne ptr %{{.+}}, null
   // CK1: br i1 [[CMP]], label %[[BTHEN:.+]], label %[[BELSE:.+]]

I think it is incorrect to recompute the branch condition here.

Consider the following C code:
```
int a = 1;
#pragma omp target data map(tofrom : a) if(a > 10) {a = 100;}
```
In this case the if condition is false before executing the region, but becomes 
true after.
If the branch condition is recomputed then it would take the `IfThen` branch 
here for executing the end_mapper call. This is incorrect and the end_mapper 
call should not be made partially without a begin _mapper call here.

Using the OMPIRBuilder fixes this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150860

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


[PATCH] D150427: [AMDGPU] Non hostcall printf support for HIP

2023-05-18 Thread Vikram Hegde via Phabricator via cfe-commits
vikramRH updated this revision to Diff 523344.
vikramRH added a comment.

Hanldles Review comments from @sameerds


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150427

Files:
  clang/include/clang/Basic/TargetOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGGPUBuiltin.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenHIP/printf_nonhostcall.cpp
  clang/test/Driver/hip-options.hip
  llvm/include/llvm/Transforms/Utils/AMDGPUEmitPrintf.h
  llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp

Index: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
===
--- llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
+++ llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
@@ -17,6 +17,8 @@
 #include "llvm/Transforms/Utils/AMDGPUEmitPrintf.h"
 #include "llvm/ADT/SparseBitVector.h"
 #include "llvm/Analysis/ValueTracking.h"
+#include "llvm/Support/DataExtractor.h"
+#include "llvm/Support/MD5.h"
 
 using namespace llvm;
 
@@ -179,10 +181,7 @@
 
 // Scan the format string to locate all specifiers, and mark the ones that
 // specify a string, i.e, the "%s" specifier with optional '*' characters.
-static void locateCStrings(SparseBitVector<8> &BV, Value *Fmt) {
-  StringRef Str;
-  if (!getConstantStringInfo(Fmt, Str) || Str.empty())
-return;
+static void locateCStrings(SparseBitVector<8> &BV, Value *Fmt, StringRef &Str) {
 
   static const char ConvSpecifiers[] = "diouxXfFeEgGaAcspn";
   size_t SpecPos = 0;
@@ -207,14 +206,308 @@
   }
 }
 
+// helper struct to package the string related data
+typedef struct StringData {
+  std::string Str = "";
+  bool isConst = true;
+  Value *RealSize = nullptr;
+  Value *AlignedSize = nullptr;
+
+  StringData(std::string str, bool IC, Value *RS,
+Value *AS)
+  : Str(str), isConst(IC), RealSize(RS), AlignedSize(AS) {}
+} StringData;
+
+static inline size_t alignUp(size_t Value, uint Alignment) {
+  return (Value + Alignment - 1) & ~(Alignment - 1);
+}
+
+// Calculates frame size required for current printf expansion and allocates
+// space on printf buffer. Printf frame includes following contents
+// [ ControlDWord , format string/Hash , Arguments (each aligned to 8 byte) ]
+static Value *callBufferedPrintfStart(IRBuilder<> &Builder,
+ ArrayRef &Args, Value *Fmt,
+ bool isConstFmtStr,
+ SparseBitVector<8> &SpecIsCString,
+ SmallVectorImpl &StringContents,
+ Value *&ArgSize) {
+  Value *NonConstStrLen = nullptr;
+
+  // First 4 bytes to be reserved for control dword
+  size_t BufSize = 4;
+  if (isConstFmtStr)
+// First 8 bytes of MD5 hash
+BufSize += 8;
+  else {
+auto LenWithNull = getStrlenWithNull(Builder, Fmt);
+
+// Align the computed length to next 8 byte boundary
+auto TempAdd = Builder.CreateAdd(
+LenWithNull, ConstantInt::get(LenWithNull->getType(), 7U));
+NonConstStrLen = Builder.CreateAnd(
+TempAdd, ConstantInt::get(LenWithNull->getType(), ~7U));
+
+StringContents.push_back(
+StringData("", false, LenWithNull, NonConstStrLen));
+  }
+
+  for (size_t i = 1; i < Args.size(); i++) {
+if (SpecIsCString.test(i)) {
+  StringRef ArgStr;
+  if (getConstantStringInfo(Args[i], ArgStr)) {
+auto alignedLen = alignUp(ArgStr.size() + 1, 8);
+StringContents.push_back(StringData((ArgStr.str() + '\0'), /*isConst*/true,
+/*RealSize*/nullptr, /*AlignedSize*/nullptr));
+BufSize += alignedLen;
+  } else {
+auto LenWithNull = getStrlenWithNull(Builder, Args[i]);
+
+// Align the computed length to next 8 byte boundary
+auto TempAdd = Builder.CreateAdd(
+LenWithNull, ConstantInt::get(LenWithNull->getType(), 7U));
+auto LenWithNullAligned = Builder.CreateAnd(
+TempAdd, ConstantInt::get(LenWithNull->getType(), ~7U));
+
+if (NonConstStrLen) {
+  auto Val = Builder.CreateAdd(LenWithNullAligned, NonConstStrLen,
+   "cumulativeAdd");
+  NonConstStrLen = Val;
+} else
+  NonConstStrLen = LenWithNullAligned;
+
+StringContents.push_back(
+StringData("", false, LenWithNull, LenWithNullAligned));
+  }
+} else
+  // We end up expanding non string arguments to 8 bytes
+  BufSize += 8;
+  }
+
+  // calculate final size value to be passed to printf_alloc
+  Value *SizeToReserve = ConstantInt::get(Builder.getInt64Ty(), BufSize, false);
+  SmallVector Alloc_args;
+  if (NonConstStrLen)
+SizeToReserve = Builder.CreateAdd(NonConstStrLen, SizeToReserve);
+
+  ArgSize = Builder.CreateTrunc(SizeToReserve, Builder.getInt32Ty());
+  Alloc_args.push_back(ArgSize);
+
+  // call the p

[PATCH] D150427: [AMDGPU] Non hostcall printf support for HIP

2023-05-18 Thread Vikram Hegde via Phabricator via cfe-commits
vikramRH added inline comments.



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:426-427
+
+// The buffered version still follows OpenCL printf standards for
+// printf return value, i.e 0 on success, 1 on failure.
+ConstantPointerNull *zeroIntPtr =

sameerds wrote:
> So we cannot use a buffered printf in HIP?
I guess hostcall version returns number of bytes printed as the printf return 
value, This is not done in Buffered case since we do not print stuff in "real 
time", instead I have decided to stick with OpenCL standard (return 0 on 
success and -1 on failure)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150427

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


[PATCH] D150427: [AMDGPU] Non hostcall printf support for HIP

2023-05-18 Thread Vikram Hegde via Phabricator via cfe-commits
vikramRH added inline comments.



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:458
+auto CreateControlDWord = M->getOrInsertFunction(
+StringRef("__ockl_create_control_dword"), Builder.getInt32Ty(),
+Builder.getInt32Ty(), Int1Ty, Int1Ty);

arsenm wrote:
> vikramRH wrote:
> > arsenm wrote:
> > > Do we really need another ockl control variable for this? Why isn't it a 
> > > parameter? printf=stdout always 
> > There are certain HIP API's such as "hip_assert" that output to stderr. 
> > currently such API's are supported via hostcalls. Although this 
> > implementation does not currently support the API's ,its kept as an option. 
> Right but the way to handle that would be a parameter for where to output, 
> not an externally set global 
I am not clear here, you expect additional inputs to device lib function ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150427

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


[PATCH] D146664: Apply the same fallbacks as runtimes search for stdlib search

2023-05-18 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Is it possible to test this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146664

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


[PATCH] D150867: [AArch64][FMV] Prevent target attribute using for multiversioning.

2023-05-18 Thread Pavel Iliin via Phabricator via cfe-commits
ilinpv created this revision.
ilinpv added a reviewer: danielkiss.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
ilinpv requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

On AArch64 for function multiversioning target_version/target_clones attributes 
should be used. The patch fixes the defect allowing target attribute to cause 
multiversioning.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150867

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/attr-target-version.c


Index: clang/test/Sema/attr-target-version.c
===
--- clang/test/Sema/attr-target-version.c
+++ clang/test/Sema/attr-target-version.c
@@ -15,15 +15,22 @@
 //expected-note@+1 {{previous definition is here}}
 int __attribute__((target_version("default"))) foo(void) { return 2; }
 
-//expected-note@+1 {{previous declaration is here}}
+//expected-note@+1 {{previous definition is here}}
 int __attribute__((target_version("sha3 + pmull "))) foo(void) { return 1; }
+//expected-note@-1 {{previous definition is here}}
 
-//expected-error@+1 {{multiversioning attributes cannot be combined}}
+//expected-error@+1 {{redefinition of 'foo'}}
 int __attribute__((target("dotprod"))) foo(void) { return -1; }
+//expected-warning@-1 {{attribute declaration must precede definition}}
 
 //expected-error@+1 {{redefinition of 'foo'}}
 int foo(void) { return 2; }
 
+//expected-note@+1 {{previous definition is here}}
+__attribute__ ((target("bf16,sve,sve2,dotprod"))) int func(void) { return 1; }
+//expected-error@+1 {{redefinition of 'func'}}
+__attribute__ ((target("default"))) int func(void) { return 0; }
+
 //expected-note@+1 {{previous declaration is here}}
 void __attribute__((target_version("bti+flagm2"))) one(void) {}
 //expected-error@+1 {{multiversioned function redeclarations require identical 
target attributes}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -11540,6 +11540,10 @@
 return false;
   }
 
+  // Target attribute on AArch64 is not used for multiversioning
+  if (NewTA && S.getASTContext().getTargetInfo().getTriple().isAArch64())
+return false;
+
   if (!OldDecl || !OldDecl->getAsFunction() ||
   OldDecl->getDeclContext()->getRedeclContext() !=
   NewFD->getDeclContext()->getRedeclContext()) {


Index: clang/test/Sema/attr-target-version.c
===
--- clang/test/Sema/attr-target-version.c
+++ clang/test/Sema/attr-target-version.c
@@ -15,15 +15,22 @@
 //expected-note@+1 {{previous definition is here}}
 int __attribute__((target_version("default"))) foo(void) { return 2; }
 
-//expected-note@+1 {{previous declaration is here}}
+//expected-note@+1 {{previous definition is here}}
 int __attribute__((target_version("sha3 + pmull "))) foo(void) { return 1; }
+//expected-note@-1 {{previous definition is here}}
 
-//expected-error@+1 {{multiversioning attributes cannot be combined}}
+//expected-error@+1 {{redefinition of 'foo'}}
 int __attribute__((target("dotprod"))) foo(void) { return -1; }
+//expected-warning@-1 {{attribute declaration must precede definition}}
 
 //expected-error@+1 {{redefinition of 'foo'}}
 int foo(void) { return 2; }
 
+//expected-note@+1 {{previous definition is here}}
+__attribute__ ((target("bf16,sve,sve2,dotprod"))) int func(void) { return 1; }
+//expected-error@+1 {{redefinition of 'func'}}
+__attribute__ ((target("default"))) int func(void) { return 0; }
+
 //expected-note@+1 {{previous declaration is here}}
 void __attribute__((target_version("bti+flagm2"))) one(void) {}
 //expected-error@+1 {{multiversioned function redeclarations require identical target attributes}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -11540,6 +11540,10 @@
 return false;
   }
 
+  // Target attribute on AArch64 is not used for multiversioning
+  if (NewTA && S.getASTContext().getTargetInfo().getTriple().isAArch64())
+return false;
+
   if (!OldDecl || !OldDecl->getAsFunction() ||
   OldDecl->getDeclContext()->getRedeclContext() !=
   NewFD->getDeclContext()->getRedeclContext()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144999: [Clang][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs.

2023-05-18 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 523354.
oontvoo added a comment.

rebase again (windows failures in flang tests looked unrelated)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/femit-dwarf-unwind.c
  clang/test/Driver/femit-dwarf-unwind.s
  clang/tools/driver/cc1as_main.cpp
  lld/MachO/UnwindInfoSection.cpp
  lld/test/MachO/Inputs/eh-frame-x86_64-r.o
  lld/test/MachO/compact-unwind-both-local-and-dylib-personality.s
  lld/test/MachO/compact-unwind-generated.test
  lld/test/MachO/compact-unwind-lsda-folding.s
  lld/test/MachO/compact-unwind-stack-ind.s
  lld/test/MachO/compact-unwind.s
  lld/test/MachO/eh-frame-personality-dedup.s
  lld/test/MachO/eh-frame.s
  lld/test/MachO/icf-only-lsda-folded.s
  lld/test/MachO/icf.s
  lld/test/MachO/invalid/compact-unwind-bad-reloc.s
  lld/test/MachO/invalid/compact-unwind-personalities.s
  llvm/include/llvm/MC/MCAsmBackend.h
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCTargetOptions.h
  llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/test/CodeGen/X86/2014-08-29-CompactUnwind.ll
  llvm/test/CodeGen/X86/compact-unwind.ll
  llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
  llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
  llvm/test/MC/MachO/ARM/compact-unwind-armv7k.s
  llvm/test/MC/X86/compact-unwind.s

Index: llvm/test/MC/X86/compact-unwind.s
===
--- llvm/test/MC/X86/compact-unwind.s
+++ llvm/test/MC/X86/compact-unwind.s
@@ -1,4 +1,4 @@
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin10.0 %s | llvm-objdump --unwind-info - | FileCheck %s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin10.0 %s -emit-compact-unwind-non-canonical=true | llvm-objdump --unwind-info - | FileCheck %s
 
 	.section	__TEXT,__text,regular,pure_instructions
 	.macosx_version_min 10, 10
Index: llvm/test/MC/MachO/ARM/compact-unwind-armv7k.s
===
--- llvm/test/MC/MachO/ARM/compact-unwind-armv7k.s
+++ llvm/test/MC/MachO/ARM/compact-unwind-armv7k.s
@@ -1,4 +1,4 @@
-@ RUN: llvm-mc -triple=thumbv7k-apple-watchos2.0.0 -filetype=obj -o %t < %s && llvm-objdump --unwind-info %t | FileCheck %s
+@ RUN: llvm-mc -triple=thumbv7k-apple-watchos2.0.0 -emit-compact-unwind-non-canonical=true -filetype=obj -o %t < %s && llvm-objdump --unwind-info %t | FileCheck %s
 
 @ CHECK: Contents of __compact_unwind section:
 
Index: llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
===
--- llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
+++ llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
@@ -1,11 +1,11 @@
 // RUN: rm -rf %t; mkdir %t
-// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj -o %t/x86_64.o
+// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj -o %t/x86_64.o -emit-compact-unwind-non-canonical=true
 // RUN: llvm-objdump --macho --dwarf=frames %t/x86_64.o | FileCheck %s --check-prefix TWO-FDES
-// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj -o %t/arm64.o
+// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj -o %t/arm64.o -emit-compact-unwind-non-canonical=true
 // RUN: llvm-objdump --macho --dwarf=frames %t/arm64.o | FileCheck %s --check-prefix ONE-FDE
-// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind no-compact-unwind -o %t/x86_64-no-dwarf.o
+// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind no-compact-unwind -o %t/x86_64-no-dwarf.o -emit-compact-unwind-non-canonical=true
 // RUN: llvm-objdump --macho --dwarf=frames %t/x86_64-no-dwarf.o | FileCheck %s --check-prefix ONE-FDE
-// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind always -o %t/arm64-dwarf.o
+// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind always -o %t/arm64-dwarf.o -emit-compact-unwind-non-canonical=true
 // RUN: llvm-objdump --macho --dwarf=frames %t/arm64-dwarf.o | FileCheck %s --check-prefix TWO-FDES
 
 // TWO-FDES: FDE
Index: llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
===
--- llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
+++ llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
@@ -1,4 +1,4 @@
-// RUN: llvm-mc -triple=arm64-apple-ios -filetype=obj 

[PATCH] D150829: [clang] Convert several tests to opaque pointers

2023-05-18 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp:22
+// CHECK: store i32 0, ptr @arr
+// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr @arr, i32 0, i32 1), ptr noundef @.str)
+// CHECK: store i32 1, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 1)

barannikov88 wrote:
> This looks suspicious to me. The first gep index has i32 type (used to be 
> i64). The two other geps have it i64.
> 
This is okay -- it's an artifact of using a DL-unaware constant folder in Clang 
CodeGen. Index types will get canonicalized once a DL-aware folder sees them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150829

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


[clang] 34e49d3 - Revert "[clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables"

2023-05-18 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2023-05-18T06:44:39-07:00
New Revision: 34e49d3e85a6dd03856af0fb4b7f8d8ae1f4f06a

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

LOG: Revert "[clang][AST] Print name instead of type when diagnosing 
uninitialized subobject in constexpr variables"

This reverts commit 0e167fc0a2147c9b673b8afd5fea001b0d127781.

This patch causes its assertion to fire when doing AST-dump, so
reverting so that the author has time to fix this.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticASTKinds.td
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/Interp/Interp.cpp
clang/test/AST/Interp/cxx20.cpp
clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
clang/test/SemaCXX/constant-expression-cxx2a.cpp
clang/test/SemaCXX/cxx2a-consteval.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0b7433b0fcb55..9420a9e687ca7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -282,9 +282,7 @@ Improvements to Clang's diagnostics
   Clang ABI >= 15.
   (`#62353: `_,
   fallout from the non-POD packing ABI fix in LLVM 15).
-- Clang constexpr evaluator now prints subobject's name instead of its type in 
notes
-  when a constexpr variable has uninitialized subobjects after its constructor 
call.
-  (`#58601 `_)
+
 
 Bug Fixes in This Version
 -

diff  --git a/clang/include/clang/Basic/DiagnosticASTKinds.td 
b/clang/include/clang/Basic/DiagnosticASTKinds.td
index eb13467317963..c283ee842e730 100644
--- a/clang/include/clang/Basic/DiagnosticASTKinds.td
+++ b/clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -65,7 +65,7 @@ def note_consteval_address_accessible : Note<
   "%select{pointer|reference}0 to a consteval declaration "
   "is not a constant expression">;
 def note_constexpr_uninitialized : Note<
-  "subobject %0 is not initialized">;
+  "%select{|sub}0object of type %1 is not initialized">;
 def note_constexpr_static_local : Note<
   "control flows through the definition of a %select{static|thread_local}0 
variable">;
 def note_constexpr_subobject_declared_here : Note<

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 84c8623a0b8ae..ce3c5257e7114 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2119,7 +2119,7 @@ static bool 
CheckEvaluationResult(CheckEvaluationResultKind CERK,
   EvalInfo &Info, SourceLocation DiagLoc,
   QualType Type, const APValue &Value,
   ConstantExprKind Kind,
-  const FieldDecl *SubobjectDecl,
+  SourceLocation SubobjectLoc,
   CheckedTemporaries &CheckedTemps);
 
 /// Check that this reference or pointer core constant expression is a valid
@@ -2266,8 +2266,8 @@ static bool CheckLValueConstantExpression(EvalInfo &Info, 
SourceLocation Loc,
   APValue *V = MTE->getOrCreateValue(false);
   assert(V && "evasluation result refers to uninitialised temporary");
   if (!CheckEvaluationResult(CheckEvaluationResultKind::ConstantExpression,
- Info, MTE->getExprLoc(), TempType, *V, Kind,
- /*SubobjectDecl=*/nullptr, CheckedTemps))
+ Info, MTE->getExprLoc(), TempType, *V,
+ Kind, SourceLocation(), CheckedTemps))
 return false;
 }
   }
@@ -2350,13 +2350,13 @@ static bool 
CheckEvaluationResult(CheckEvaluationResultKind CERK,
   EvalInfo &Info, SourceLocation DiagLoc,
   QualType Type, const APValue &Value,
   ConstantExprKind Kind,
-  const FieldDecl *SubobjectDecl,
+  SourceLocation SubobjectLoc,
   CheckedTemporaries &CheckedTemps) {
   if (!Value.hasValue()) {
-assert(SubobjectDecl && "SubobjectDecl shall be non-null");
-Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized) << SubobjectDecl;
-Info.Note(SubobjectDecl->getLocation(),
-  diag::note_constexpr_subobject_declared_here);
+Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized)
+  << true << Type;
+if (SubobjectLoc.isValid())
+  Info.Note(SubobjectLoc, diag::note_constexpr_subobject_declared_here);
 return false;
   }
 
@@ -2373,19 +2373,20 @@ static bool 
CheckEvaluationResult(CheckEvaluationResultKind CERK,
 

[PATCH] D146358: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables

2023-05-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D146358#4351787 , @hazohelet wrote:

> In D146358#4350810 , @erichkeane 
> wrote:
>
>> Our downstream discovered that this causes a regression when compiling 
>> `utility` with `ast-dump`.  I've put up a minimal reproducer: 
>> https://godbolt.org/z/oaezas7Ws
>>
>> @hazohelet : Will you be able to look into this soon?
>
> Thanks for the report and the reproducer.
> I cannot take sufficient time for about 36 hours, but I'll be able to 
> investigate it after that.

That is long enough away that I unfortunately have to revert (see 
34e49d3e85a6dd03856af0fb4b7f8d8ae1f4f06a 
). Please 
note that in the LLVM project reverts are common/frequent (we have a policy of 
'revert often'), and should not be taken negatively!  Please feel free to 
re-submit this patch with a fix/the test provided, and we'll re-review promptly!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146358

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


[PATCH] D150183: [Clang][clang-cl] Implement `__builtin_FUNCSIG`

2023-05-18 Thread Jakub Mazurkiewicz via Phabricator via cfe-commits
JMazurkiewicz updated this revision to Diff 523360.
JMazurkiewicz marked 2 inline comments as done.
JMazurkiewicz added a comment.

- Address comments (thanks for the review @aaron.ballman!),
- Remove `clang-format` changes (CI might fail),
- Add extra tests in `clang/test/Preprocessor/feature_tests.cpp`.


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

https://reviews.llvm.org/D150183

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Preprocessor/feature_tests.c
  clang/test/Preprocessor/feature_tests.cpp
  clang/test/Sema/source_location.c
  clang/test/SemaCXX/source_location.cpp

Index: clang/test/SemaCXX/source_location.cpp
===
--- clang/test/SemaCXX/source_location.cpp
+++ clang/test/SemaCXX/source_location.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify %s
 // RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -DUSE_CONSTEVAL -fexceptions -verify %s
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fms-extensions -DMS -fexceptions -verify %s
+// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -fms-extensions -DMS -DUSE_CONSTEVAL -fexceptions -verify %s
 // expected-no-diagnostics
 
 #define assert(...) ((__VA_ARGS__) ? ((void)0) : throw 42)
@@ -86,6 +88,9 @@
 static_assert(is_same);
 static_assert(is_same);
 static_assert(is_same);
+#ifdef MS
+static_assert(is_same);
+#endif
 static_assert(is_same);
 
 // test noexcept
@@ -94,6 +99,9 @@
 static_assert(noexcept(__builtin_FILE()));
 static_assert(noexcept(__builtin_FILE_NAME()));
 static_assert(noexcept(__builtin_FUNCTION()));
+#ifdef MS
+static_assert(noexcept(__builtin_FUNCSIG()));
+#endif
 static_assert(noexcept(__builtin_source_location()));
 
 //===--===//
@@ -450,6 +458,57 @@
 
 } // namespace test_func
 
+//===--===//
+//__builtin_FUNCSIG()
+//===--===//
+
+#ifdef MS
+namespace test_funcsig {
+
+constexpr const char *test_funcsig_simple(const char *f = __builtin_FUNCSIG()) {
+  return f;
+}
+constexpr const char *get_funcsig() {
+  return __FUNCSIG__;
+}
+constexpr bool test_funcsig() {
+  return is_equal(__FUNCSIG__, test_funcsig_simple()) &&
+ !is_equal(get_funcsig(), test_funcsig_simple());
+}
+static_assert(test_funcsig());
+
+template 
+constexpr Pair test_funcsig_template(T, const char* f = __builtin_FUNCSIG()) {
+  return {f, __builtin_FUNCSIG()};
+}
+template 
+void func_template_tests() {
+  constexpr auto P = test_funcsig_template(42);
+  static_assert(is_equal(P.first, __FUNCSIG__), "");
+  static_assert(!is_equal(P.second, __FUNCSIG__), "");
+}
+template void func_template_tests();
+
+template 
+struct TestCtor {
+  T funcsig = __builtin_FUNCSIG();
+  T ctor_funcsig;
+  TestCtor() = default;
+  template 
+  constexpr TestCtor(int, F f = __builtin_FUNCSIG()) : ctor_funcsig(f) {}
+};
+void ctor_tests() {
+  constexpr TestCtor<> Template{42};
+  static_assert(is_equal(Template.funcsig, "__cdecl test_funcsig::TestCtor<>::TestCtor(int, F) [T = const char *, F = const char *]"));
+  static_assert(is_equal(Template.ctor_funcsig, __FUNCSIG__));
+}
+
+constexpr const char* global_funcsig = __builtin_FUNCSIG();
+static_assert(is_equal(global_funcsig, ""));
+
+} // namespace test_funcsig
+#endif
+
 //===--===//
 //__builtin_COLUMN()
 //===--===//
Index: clang/test/Sema/source_location.c
===
--- clang/test/Sema/source_location.c
+++ clang/test/Sema/source_location.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c90 -fconst-strings -DCONST_STRINGS -verify %s
 // RUN: %clang_cc1 -std=c90 -verify %s
+// RUN: %clang_cc1 -std=c90 -fms-extensions -DMS -fconst-strings -DCONST_STRINGS -verify %s
+// RUN: %clang_cc1 -std=c90 -fms-extensions -DMS -verify %s
 
 // expected-no-diagnostics
 
@@ -13,6 +15,9 @@
 #ifndef CONST_STRINGS
 char *const NCFILE = __builtin_FILE();
 char *const NCFUNC = __builtin_FUNCTION();
+#ifdef MS
+char *const NCFNSG = __builtin_FUNCSIG();
+#endif
 #endif
 
 #ifdef CONST_STRINGS
@@ -20,6 +25,9 @@
 _Static_assert(IsEqual(__builtin_FILE_NAME(), __FILE_NAME__), "");
 _Static_assert(__builtin_LINE() == __LINE__, "");
 _Static_assert(IsEqual("", __builtin_FUNCTION()), "");
+#ifdef MS
+_Static_assert(IsEqual("", __builtin_FUNCSIG()), "");
+#endif
 
 #line 42 "my_file.c"
 _Static_assert(__builtin_LINE() == 42, "");
@@ -30,5 +38,8 @@
 
 void fo

[clang] 0bf5f63 - [clang] Convert several tests to opaque pointers

2023-05-18 Thread Sergei Barannikov via cfe-commits

Author: Sergei Barannikov
Date: 2023-05-18T17:01:11+03:00
New Revision: 0bf5f632ed53cb8c986d69168589228014522e1b

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

LOG: [clang] Convert several tests to opaque pointers

Reviewed By: nikic

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

Added: 


Modified: 
clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
clang/test/CodeGenCXX/address-space-cast-coerce.cpp
clang/test/CodeGenCXX/address-space-cast.cpp
clang/test/CodeGenCXX/aix-alignment.cpp
clang/test/CodeGenCXX/alignment.cpp
clang/test/CodeGenCXX/anonymous-union-member-initializer.cpp
clang/test/CodeGenCXX/arm-swiftcall.cpp
clang/test/CodeGenCXX/arm.cpp
clang/test/CodeGenCXX/arm64.cpp
clang/test/CodeGenCXX/armv7k.cpp
clang/test/CodeGenCXX/assign-operator.cpp
clang/test/CodeGenCXX/attr-musttail.cpp
clang/test/CodeGenCXX/attr-target-clones.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp 
b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
index 653c3d04972db..4033adc8f0390 100644
--- a/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
+++ b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -no-opaque-pointers %s -emit-llvm -o - -triple 
x86_64-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s
 
 struct A {
   A(const char *);
@@ -18,9 +18,9 @@ struct S {
   { 2, "goodbye" }
 };
 
-// CHECK: store i32 0, i32* getelementptr inbounds ([3 x %struct.S], [3 x 
%struct.S]* @arr, i64 0, i64 0, i32 0)
-// CHECK: call void @_ZN1AC1EPKc(%struct.A* {{[^,]*}} getelementptr inbounds 
([3 x %struct.S], [3 x %struct.S]* @arr, i64 0, i64 0, i32 1), i8* noundef 
getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
-// CHECK: store i32 1, i32* getelementptr inbounds ([3 x %struct.S], [3 x 
%struct.S]* @arr, i64 0, i64 1, i32 0)
-// CHECK: call void @_ZN1AC1EPKc(%struct.A* {{[^,]*}} getelementptr inbounds 
([3 x %struct.S], [3 x %struct.S]* @arr, i64 0, i64 1, i32 1), i8* noundef 
getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
-// CHECK: store i32 2, i32* getelementptr inbounds ([3 x %struct.S], [3 x 
%struct.S]* @arr, i64 0, i64 2, i32 0)
-// CHECK: call void @_ZN1AC1EPKc(%struct.A* {{[^,]*}} getelementptr inbounds 
([3 x %struct.S], [3 x %struct.S]* @arr, i64 0, i64 2, i32 1), i8* noundef 
getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
+// CHECK: store i32 0, ptr @arr
+// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr @arr, i32 0, i32 1), ptr noundef @.str)
+// CHECK: store i32 1, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 1)
+// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr @arr, i64 1, i32 1), ptr noundef @.str.1)
+// CHECK: store i32 2, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 2)
+// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr @arr, i64 2, i32 1), ptr noundef @.str.2)

diff  --git a/clang/test/CodeGenCXX/address-space-cast-coerce.cpp 
b/clang/test/CodeGenCXX/address-space-cast-coerce.cpp
index f131168f1c78a..7279b6c7f23a0 100644
--- a/clang/test/CodeGenCXX/address-space-cast-coerce.cpp
+++ b/clang/test/CodeGenCXX/address-space-cast-coerce.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -no-opaque-pointers %s -triple=amdgcn-amd-amdhsa -emit-llvm 
-o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s
 
 template struct my_vector_base;
 
@@ -46,8 +46,9 @@ int mane() {
 char1 f1{1};
 char1 f2{1};
 
-// CHECK: %[[a:[^ ]+]] = addrspacecast i16 addrspace(5)* %{{[^ ]+}} to i16*
-// CHECK: %[[a:[^ ]+]] = addrspacecast %{{[^ ]+}} addrspace(5)* %{{[^ ]+}} to 
%{{[^ ]+}} 
+// CHECK: [[TMP:%.+]] = alloca i16
+// CHECK: [[COERCE:%.+]] = addrspacecast ptr addrspace(5) [[TMP]] to ptr
+// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %{{.+}}, ptr align 2 
[[COERCE]], i64 1, i1 false)
 
 char1 f3 = f1 + f2;
 }

diff  --git a/clang/test/CodeGenCXX/address-space-cast.cpp 
b/clang/test/CodeGenCXX/address-space-cast.cpp
index 36a7904d6bfe8..0e3d179ee2d42 100644
--- a/clang/test/CodeGenCXX/address-space-cast.cpp
+++ b/clang/test/CodeGenCXX/address-space-cast.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -no-opaque-pointers %s -triple=amdgcn-amd-amdhsa -emit-llvm 
-o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s
 
 #define __private__ __attribute__((address_space(5)))
 
@@ -16,60 +16,61 @@ void fn(Derived *p) {
   __private__ Base *b = (__private__ Base *)p;
 }
 
+// CHECK-LABEL: test_cast
 void test_cast(char *gen_char_ptr, void *gen_void_ptr

[PATCH] D150829: [clang] Convert several tests to opaque pointers

2023-05-18 Thread Sergei Barannikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0bf5f632ed53: [clang] Convert several tests to opaque 
pointers (authored by barannikov88).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150829

Files:
  clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
  clang/test/CodeGenCXX/address-space-cast-coerce.cpp
  clang/test/CodeGenCXX/address-space-cast.cpp
  clang/test/CodeGenCXX/aix-alignment.cpp
  clang/test/CodeGenCXX/alignment.cpp
  clang/test/CodeGenCXX/anonymous-union-member-initializer.cpp
  clang/test/CodeGenCXX/arm-swiftcall.cpp
  clang/test/CodeGenCXX/arm.cpp
  clang/test/CodeGenCXX/arm64.cpp
  clang/test/CodeGenCXX/armv7k.cpp
  clang/test/CodeGenCXX/assign-operator.cpp
  clang/test/CodeGenCXX/attr-musttail.cpp
  clang/test/CodeGenCXX/attr-target-clones.cpp

Index: clang/test/CodeGenCXX/attr-target-clones.cpp
===
--- clang/test/CodeGenCXX/attr-target-clones.cpp
+++ clang/test/CodeGenCXX/attr-target-clones.cpp
@@ -1,20 +1,20 @@
-// RUN: %clang_cc1 -no-opaque-pointers -std=c++11 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=LINUX
-// RUN: %clang_cc1 -no-opaque-pointers -std=c++11 -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefix=WINDOWS
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=LINUX
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefix=WINDOWS
 
 // Overloaded ifuncs
-// LINUX: @_Z10overloadedi.ifunc = weak_odr ifunc i32 (i32), i32 (i32)* ()* @_Z10overloadedi.resolver
-// LINUX: @_Z10overloadedPKc.ifunc = weak_odr ifunc i32 (i8*), i32 (i8*)* ()* @_Z10overloadedPKc.resolver
+// LINUX: @_Z10overloadedi.ifunc = weak_odr ifunc i32 (i32), ptr @_Z10overloadedi.resolver
+// LINUX: @_Z10overloadedPKc.ifunc = weak_odr ifunc i32 (ptr), ptr @_Z10overloadedPKc.resolver
 // struct 'C' ifuncs, note the 'float, U' one doesn't get one.
-// LINUX: @_ZN1CIssE3fooEv.ifunc = weak_odr ifunc i32 (%struct.C*), i32 (%struct.C*)* ()* @_ZN1CIssE3fooEv.resolver
-// LINUX: @_ZN1CIisE3fooEv.ifunc = weak_odr ifunc i32 (%struct.C.0*), i32 (%struct.C.0*)* ()* @_ZN1CIisE3fooEv.resolver
-// LINUX: @_ZN1CIdfE3fooEv.ifunc = weak_odr ifunc i32 (%struct.C.2*), i32 (%struct.C.2*)* ()* @_ZN1CIdfE3fooEv.resolver
+// LINUX: @_ZN1CIssE3fooEv.ifunc = weak_odr ifunc i32 (ptr), ptr @_ZN1CIssE3fooEv.resolver
+// LINUX: @_ZN1CIisE3fooEv.ifunc = weak_odr ifunc i32 (ptr), ptr @_ZN1CIisE3fooEv.resolver
+// LINUX: @_ZN1CIdfE3fooEv.ifunc = weak_odr ifunc i32 (ptr), ptr @_ZN1CIdfE3fooEv.resolver
 
 int __attribute__((target_clones("sse4.2", "default"))) overloaded(int) { return 1; }
 // LINUX: define {{.*}}i32 @_Z10overloadedi.sse4.2.0(i32{{.+}})
 // LINUX: define {{.*}}i32 @_Z10overloadedi.default.1(i32{{.+}})
-// LINUX: define weak_odr i32 (i32)* @_Z10overloadedi.resolver() comdat
-// LINUX: ret i32 (i32)* @_Z10overloadedi.sse4.2.0
-// LINUX: ret i32 (i32)* @_Z10overloadedi.default.1
+// LINUX: define weak_odr ptr @_Z10overloadedi.resolver() comdat
+// LINUX: ret ptr @_Z10overloadedi.sse4.2.0
+// LINUX: ret ptr @_Z10overloadedi.default.1
 
 // WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHH@Z.sse4.2.0"(i32{{.+}})
 // WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHH@Z.default.1"(i32{{.+}})
@@ -23,15 +23,15 @@
 // WINDOWS: call i32 @"?overloaded@@YAHH@Z.default.1"
 
 int __attribute__((target_clones("arch=ivybridge", "default"))) overloaded(const char *) { return 2; }
-// LINUX: define {{.*}}i32 @_Z10overloadedPKc.arch_ivybridge.0(i8*{{.+}})
-// LINUX: define {{.*}}i32 @_Z10overloadedPKc.default.1(i8*{{.+}})
-// LINUX: define weak_odr i32 (i8*)* @_Z10overloadedPKc.resolver() comdat
-// LINUX: ret i32 (i8*)* @_Z10overloadedPKc.arch_ivybridge.0
-// LINUX: ret i32 (i8*)* @_Z10overloadedPKc.default.1
-
-// WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHPEBD@Z.arch_ivybridge.0"(i8*{{.+}})
-// WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHPEBD@Z.default.1"(i8*{{.+}})
-// WINDOWS: define weak_odr dso_local i32 @"?overloaded@@YAHPEBD@Z"(i8*{{.+}}) comdat
+// LINUX: define {{.*}}i32 @_Z10overloadedPKc.arch_ivybridge.0(ptr{{.+}})
+// LINUX: define {{.*}}i32 @_Z10overloadedPKc.default.1(ptr{{.+}})
+// LINUX: define weak_odr ptr @_Z10overloadedPKc.resolver() comdat
+// LINUX: ret ptr @_Z10overloadedPKc.arch_ivybridge.0
+// LINUX: ret ptr @_Z10overloadedPKc.default.1
+
+// WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHPEBD@Z.arch_ivybridge.0"(ptr{{.+}})
+// WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHPEBD@Z.default.1"(ptr{{.+}})
+// WINDOWS: define weak_odr dso_local i32 @"?overloaded@@YAHPEBD@Z"(ptr{{.+}}) comdat
 // WINDOWS: call i32 @"?overloaded@@YAHPEBD@Z.arch_ivybridge.0"
 // WINDOWS: call i32 @"?overloaded@@YAHPEBD@Z.default.1"
 
@@ -64,57 +64

[clang] 8e82376 - [clang][RISCV] Set HasLegalHalfType to true if zhinx is enabled

2023-05-18 Thread Alex Bradbury via cfe-commits

Author: Alex Bradbury
Date: 2023-05-18T15:01:48+01:00
New Revision: 8e82376863460f6dc2dbb7fe6754af3ba69cc9c4

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

LOG: [clang][RISCV] Set HasLegalHalfType to true if zhinx is enabled

Now that codegen support for zhinx in landed (D149811), we should set
HasLegalHalfType=true for zhinx (see D145071 for the patch doing this
for zfh).

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

Added: 


Modified: 
clang/lib/Basic/Targets/RISCV.cpp
clang/test/CodeGen/RISCV/Float16-arith.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index bb61d75372667..5318cf52d0cdd 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -320,7 +320,7 @@ bool 
RISCVTargetInfo::handleTargetFeatures(std::vector &Features,
   if (ABI.empty())
 ABI = ISAInfo->computeDefaultABI().str();
 
-  if (ISAInfo->hasExtension("zfh"))
+  if (ISAInfo->hasExtension("zfh") || ISAInfo->hasExtension("zhinx"))
 HasLegalHalfType = true;
 
   return true;

diff  --git a/clang/test/CodeGen/RISCV/Float16-arith.c 
b/clang/test/CodeGen/RISCV/Float16-arith.c
index baedc0788dedc..97faa48f87795 100644
--- a/clang/test/CodeGen/RISCV/Float16-arith.c
+++ b/clang/test/CodeGen/RISCV/Float16-arith.c
@@ -42,12 +42,9 @@ _Float16 x, y, z;
 // ZHINX-SAME: () #[[ATTR0:[0-9]+]] {
 // ZHINX-NEXT:  entry:
 // ZHINX-NEXT:[[TMP0:%.*]] = load half, ptr @y, align 2
-// ZHINX-NEXT:[[EXT:%.*]] = fpext half [[TMP0]] to float
 // ZHINX-NEXT:[[TMP1:%.*]] = load half, ptr @z, align 2
-// ZHINX-NEXT:[[EXT1:%.*]] = fpext half [[TMP1]] to float
-// ZHINX-NEXT:[[ADD:%.*]] = fadd float [[EXT]], [[EXT1]]
-// ZHINX-NEXT:[[UNPROMOTION:%.*]] = fptrunc float [[ADD]] to half
-// ZHINX-NEXT:store half [[UNPROMOTION]], ptr @x, align 2
+// ZHINX-NEXT:[[ADD:%.*]] = fadd half [[TMP0]], [[TMP1]]
+// ZHINX-NEXT:store half [[ADD]], ptr @x, align 2
 // ZHINX-NEXT:ret void
 //
 void f16_add() {



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


[PATCH] D150777: [clang][RISCV] Set HasLegalHalfType to true if zhinx is enabled

2023-05-18 Thread Alex Bradbury 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 rG8e8237686346: [clang][RISCV] Set HasLegalHalfType to true if 
zhinx is enabled (authored by asb).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150777

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/test/CodeGen/RISCV/Float16-arith.c


Index: clang/test/CodeGen/RISCV/Float16-arith.c
===
--- clang/test/CodeGen/RISCV/Float16-arith.c
+++ clang/test/CodeGen/RISCV/Float16-arith.c
@@ -42,12 +42,9 @@
 // ZHINX-SAME: () #[[ATTR0:[0-9]+]] {
 // ZHINX-NEXT:  entry:
 // ZHINX-NEXT:[[TMP0:%.*]] = load half, ptr @y, align 2
-// ZHINX-NEXT:[[EXT:%.*]] = fpext half [[TMP0]] to float
 // ZHINX-NEXT:[[TMP1:%.*]] = load half, ptr @z, align 2
-// ZHINX-NEXT:[[EXT1:%.*]] = fpext half [[TMP1]] to float
-// ZHINX-NEXT:[[ADD:%.*]] = fadd float [[EXT]], [[EXT1]]
-// ZHINX-NEXT:[[UNPROMOTION:%.*]] = fptrunc float [[ADD]] to half
-// ZHINX-NEXT:store half [[UNPROMOTION]], ptr @x, align 2
+// ZHINX-NEXT:[[ADD:%.*]] = fadd half [[TMP0]], [[TMP1]]
+// ZHINX-NEXT:store half [[ADD]], ptr @x, align 2
 // ZHINX-NEXT:ret void
 //
 void f16_add() {
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -320,7 +320,7 @@
   if (ABI.empty())
 ABI = ISAInfo->computeDefaultABI().str();
 
-  if (ISAInfo->hasExtension("zfh"))
+  if (ISAInfo->hasExtension("zfh") || ISAInfo->hasExtension("zhinx"))
 HasLegalHalfType = true;
 
   return true;


Index: clang/test/CodeGen/RISCV/Float16-arith.c
===
--- clang/test/CodeGen/RISCV/Float16-arith.c
+++ clang/test/CodeGen/RISCV/Float16-arith.c
@@ -42,12 +42,9 @@
 // ZHINX-SAME: () #[[ATTR0:[0-9]+]] {
 // ZHINX-NEXT:  entry:
 // ZHINX-NEXT:[[TMP0:%.*]] = load half, ptr @y, align 2
-// ZHINX-NEXT:[[EXT:%.*]] = fpext half [[TMP0]] to float
 // ZHINX-NEXT:[[TMP1:%.*]] = load half, ptr @z, align 2
-// ZHINX-NEXT:[[EXT1:%.*]] = fpext half [[TMP1]] to float
-// ZHINX-NEXT:[[ADD:%.*]] = fadd float [[EXT]], [[EXT1]]
-// ZHINX-NEXT:[[UNPROMOTION:%.*]] = fptrunc float [[ADD]] to half
-// ZHINX-NEXT:store half [[UNPROMOTION]], ptr @x, align 2
+// ZHINX-NEXT:[[ADD:%.*]] = fadd half [[TMP0]], [[TMP1]]
+// ZHINX-NEXT:store half [[ADD]], ptr @x, align 2
 // ZHINX-NEXT:ret void
 //
 void f16_add() {
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -320,7 +320,7 @@
   if (ABI.empty())
 ABI = ISAInfo->computeDefaultABI().str();
 
-  if (ISAInfo->hasExtension("zfh"))
+  if (ISAInfo->hasExtension("zfh") || ISAInfo->hasExtension("zhinx"))
 HasLegalHalfType = true;
 
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150411: [NFC][Clang][Coverity] Fix Static Code Analysis Concerns with copy without assign

2023-05-18 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 523376.

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

https://reviews.llvm.org/D150411

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Analysis/Analyses/Consumed.h
  clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
  clang/include/clang/Analysis/Analyses/ThreadSafetyUtil.h
  clang/include/clang/Analysis/Support/BumpVector.h
  clang/include/clang/Rewrite/Core/RewriteRope.h
  clang/include/clang/Sema/Lookup.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/EHScopeStack.h
  clang/lib/Sema/SemaAccess.cpp
  clang/utils/TableGen/ClangDiagnosticsEmitter.cpp

Index: clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
===
--- clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -653,6 +653,14 @@
   Root(O.Root) {
   O.Root = nullptr;
 }
+// The move assignment operator is defined as deleted pending further
+// motivation.
+DiagText &operator=(DiagText &&) = delete;
+
+// The copy constrcutor and copy assignment operator is defined as deleted
+// pending further motivation.
+DiagText(const DiagText &) = delete;
+DiagText &operator=(const DiagText &) = delete;
 
 ~DiagText() {
   for (Piece *P : AllocatedPieces)
Index: clang/lib/Sema/SemaAccess.cpp
===
--- clang/lib/Sema/SemaAccess.cpp
+++ clang/lib/Sema/SemaAccess.cpp
@@ -199,6 +199,16 @@
 : Target(S.Target), Has(S.Has) {
   S.Target = nullptr;
 }
+
+// The move assignment operator is defined as deleted pending further
+// motivation.
+SavedInstanceContext &operator=(SavedInstanceContext &&) = delete;
+
+// The copy constrcutor and copy assignment operator is defined as deleted
+// pending further motivation.
+SavedInstanceContext (const SavedInstanceContext &) = delete;
+SavedInstanceContext &operator=(const SavedInstanceContext &) = delete;
+
 ~SavedInstanceContext() {
   if (Target)
 Target->HasInstanceContext = Has;
Index: clang/lib/CodeGen/EHScopeStack.h
===
--- clang/lib/CodeGen/EHScopeStack.h
+++ clang/lib/CodeGen/EHScopeStack.h
@@ -148,6 +148,12 @@
   public:
 Cleanup(const Cleanup &) = default;
 Cleanup(Cleanup &&) {}
+
+// The copy and move assignment operator is defined as deleted pending
+// further motivation.
+Cleanup &operator=(const Cleanup &) = delete;
+Cleanup &operator=(Cleanup &&) = delete;
+
 Cleanup() = default;
 
 virtual bool isRedundantBeforeReturn() { return false; }
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -829,7 +829,13 @@
   ApplyDebugLocation(ApplyDebugLocation &&Other) : CGF(Other.CGF) {
 Other.CGF = nullptr;
   }
-  ApplyDebugLocation &operator=(ApplyDebugLocation &&) = default;
+
+  // Define copy assignment operator.
+  ApplyDebugLocation &operator=(ApplyDebugLocation &&Other) {
+CGF = Other.CGF;
+Other.CGF = nullptr;
+return *this;
+  }
 
   ~ApplyDebugLocation();
 
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
@@ -672,6 +672,11 @@
   SymbolVisitor(const SymbolVisitor &) = default;
   SymbolVisitor(SymbolVisitor &&) {}
 
+  // The copy and move assignment operator is defined as deleted pending further
+  // motivation.
+  SymbolVisitor &operator=(const SymbolVisitor &) = delete;
+  SymbolVisitor &operator=(SymbolVisitor &&) = delete;
+
   /// A visitor method invoked by ProgramStateManager::scanReachableSymbols.
   ///
   /// The method returns \c true if symbols should continue be scanned and \c
Index: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
===
--- clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -51,6 +51,12 @@
   BugReporterVisitor() = default;
   BugReporterVisitor(const BugReporterVisitor &) = default;
   BugReporterVisitor(BugReporterVisitor &&) {}
+
+  // The copy and move assignment operator is defined as deleted pending further
+  // motivation.
+  BugReporterVisitor &operator=(const BugReporterVisitor &) = delete;
+  BugReporterVisitor &op

[PATCH] D150183: [Clang][clang-cl] Implement `__builtin_FUNCSIG`

2023-05-18 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 assuming precommit CI doesn't come back with surprises, though there are 
some minor typos in the release notes to be fixed. Do you need someone to 
commit on your behalf? If so, what name and email address would you like used 
for patch attribution? (If you need me to land it for you, I can fix up the 
release notes when I land, so you don't have to upload a new patch. If you land 
the changes yourself, feel free to fix the release notes while landing as well.)




Comment at: clang/docs/ReleaseNotes.rst:195
   whether a file can be enabled for the multiple-include optimization.
+- Clang now support ``__builtin_FUNCSIG()`` which retruns the same information
+  as the ``__FUNCSIG__`` macro (available only with ``-fms-extensions`` flag).




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

https://reviews.llvm.org/D150183

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


[PATCH] D150872: [clang-tidy] Add support for new TODO style to google-readability-todo

2023-05-18 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: sammccall.
Herald added subscribers: PiotrZSL, carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
ymandel requested review of this revision.
Herald added a project: clang-tools-extra.

Google style is changing to encourage a different (and more common) form of
TODO, specifically: `TODO: link - description`.  This patch adds support for the
new style, while maintaining backwards compatability with the old style. The
patch adds a configuration option to the check to control which style (V1 or V2)
is checked.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150872

Files:
  clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp
  clang-tools-extra/clang-tidy/google/TodoCommentCheck.h
  clang-tools-extra/docs/clang-tidy/checks/google/readability-todo.rst
  clang-tools-extra/test/clang-tidy/checkers/google/readability-todo-v2.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/google/readability-todo-v2.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/google/readability-todo-v2.cpp
@@ -0,0 +1,33 @@
+// RUN: %check_clang_tidy %s google-readability-todo %t -- \
+// RUN: -config="{User: 'some user', CheckOptions: \
+// RUN:   [{key: google-readability-todo.UseV2Style, \
+// RUN: value: 'true'}]}" \
+// RUN: --
+
+//   TODOfix this1
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: TODO requires link and description
+
+//   TODO fix this2
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: TODO requires link and description
+
+// TODO fix this3
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: TODO requires link and description
+
+// TODO: fix this4
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: TODO requires link and description
+
+// V2-style TODO comments:
+
+// TODO: https://github.com/llvm/llvm-project/issues/12345 - Some description
+// TODO: link - description
+
+// V1-style TODO comments, supported for backwards compatability:
+
+//   TODO(clang)fix this5
+
+// TODO(foo):shave yaks
+// TODO(bar):
+// TODO(foo): paint bikeshed
+// TODO(b/12345): find the holy grail
+// TODO (b/12345): allow spaces before parentheses
+// TODO(asdf) allow missing semicolon
Index: clang-tools-extra/docs/clang-tidy/checks/google/readability-todo.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/google/readability-todo.rst
+++ clang-tools-extra/docs/clang-tidy/checks/google/readability-todo.rst
@@ -9,3 +9,17 @@
 https://google.github.io/styleguide/cppguide.html#TODO_Comments.
 
 Corresponding cpplint.py check: `readability/todo`
+
+Options
+---
+
+.. option:: User
+
+   The username to use when suggesting an edit to a TODO comment. Only relevant to V1 style.
+
+.. option:: UseV2Style
+
+   Whether to check TODO comments against the new TODO style, specifically:
+   ```
+   // TODO: link - description
+   ```
Index: clang-tools-extra/clang-tidy/google/TodoCommentCheck.h
===
--- clang-tools-extra/clang-tidy/google/TodoCommentCheck.h
+++ clang-tools-extra/clang-tidy/google/TodoCommentCheck.h
@@ -27,8 +27,13 @@
   void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
Preprocessor *ModuleExpanderPP) override;
 
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override {
+Options.store(Opts, "UseV2Style", UseV2Style);
+  }
+
 private:
   class TodoCommentHandler;
+  bool UseV2Style;
   std::unique_ptr Handler;
 };
 
Index: clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp
===
--- clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp
+++ clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp
@@ -7,51 +7,97 @@
 //===--===//
 
 #include "TodoCommentCheck.h"
+#include "clang/Basic/Diagnostic.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/Preprocessor.h"
+#include "llvm/Support/ErrorHandling.h"
 #include 
 
 namespace clang::tidy::google::readability {
 
+enum class TodoStyleVersion {
+  V1,
+  V2,
+};
+
+std::string_view getVersionRegex(TodoStyleVersion V) {
+  switch (V) {
+  case TodoStyleVersion::V1:
+return "^// *TODO *(\\(.*\\))?:?( )?(.*)$";
+  case TodoStyleVersion::V2:
+return "^// *TODO *((: *[^ ]+( - .)?)|([(][^)]*[)])?).*$";
+  }
+  llvm_unreachable("bad enum value");
+}
+
 class TodoCommentCheck::TodoCommentHandler : public CommentHandler {
 public:
-  TodoCommentHandler(TodoCommentCheck &Check, std::optional User)
-  : Check(Check), User(User ? *User : "unknown"),
-TodoMatch("^// *TODO *(\\(.*\\))?:?( )?(.*)$") {}
+  TodoCommentHandler(TodoCommentCheck &Check, std::optional User,
+ TodoStyleVersion V)
+  : Check(Check), User(User ? *User : "unknown"), Ver

[PATCH] D150411: [NFC][Clang][Coverity] Fix Static Code Analysis Concerns with copy without assign

2023-05-18 Thread Soumi Manna via Phabricator via cfe-commits
Manna added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:1790
 SemaDiagnosticBuilder(const SemaDiagnosticBuilder &) = default;
+SemaDiagnosticBuilder &operator=(const SemaDiagnosticBuilder &) = delete;
 ~SemaDiagnosticBuilder();

tahonermann wrote:
> aaronpuchert wrote:
> > tahonermann wrote:
> > > 
> > Being explicit is certainly a good thing, but the C++ committee wants to go 
> > into the direction of "copy/move operations are implicitly deleted if any 
> > of them or the destructor is user-declared." See 
> > [depr.impldec](https://eel.is/c++draft/depr.impldec). It is already 
> > partially the case, for example here. So why do need to spell something out 
> > explicitly when the language goes into the direction of being even more 
> > implicit?
> I have low expectations of that deprecation ever being acted on. In fact, 
> there have been discussions about un-deprecating it because of the lack of 
> such intent.
> 
> The motivation for deprecation is not based on a judgement of whether 
> implicit or explicit is better, but rather based on a safety argument; if a 
> copy constructor or destructor is user-declared, that is probably because 
> some form of resource management is needed that won't be performed by the 
> defaulted copy assignment operator. Thus, defining the implicit copy 
> assignment operator as deleted would avoid the possibility of the compiler 
> injecting bugs in the program.
> 
> The rules for when the copy vs assignment operators are implicitly defined as 
> deleted can be hard to remember. I think being explicit is useful if only to 
> indicate that the author thought about whether such operations should be 
> provided. Since we don't have a principled reason for defining these 
> operations as deleted, it might not be a bad idea to add a comment that 
> states something like "The copy/move assignment operator is defined as 
> deleted pending further motivation".
Thank you @tahonermann for the comments and the updates about the deprecations 
discussion.

>>t might not be a bad idea to add a comment that states something like "The 
>>copy/move assignment operator is defined as deleted pending further 
>>motivation".

I like the idea of adding a comment since pending standard decision. I have 
updated my patch with the comments 


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

https://reviews.llvm.org/D150411

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


[PATCH] D150833: [WebAssembly] Add wasm_simd128.h intrinsics for relaxed SIMD

2023-05-18 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc672c3fe05ad: [WebAssembly] Add wasm_simd128.h intrinsics 
for relaxed SIMD (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150833

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/Headers/wasm_simd128.h
  cross-project-tests/intrinsic-header-tests/wasm_simd128.c

Index: cross-project-tests/intrinsic-header-tests/wasm_simd128.c
===
--- cross-project-tests/intrinsic-header-tests/wasm_simd128.c
+++ cross-project-tests/intrinsic-header-tests/wasm_simd128.c
@@ -1,7 +1,8 @@
 // REQUIRES: webassembly-registered-target
 // expected-no-diagnostics
 
-// RUN: %clang %s -O2 -S -o - -target wasm32-unknown-unknown -msimd128 -Wcast-qual -Werror | FileCheck %s
+// RUN: %clang %s -O2 -S -o - -target wasm32-unknown-unknown \
+// RUN: -msimd128 -mrelaxed-simd -Wcast-qual -Werror | FileCheck %s
 
 #include 
 
@@ -1264,3 +1265,123 @@
 v128_t test_i16x8_q15mulr_sat(v128_t a, v128_t b) {
   return wasm_i16x8_q15mulr_sat(a, b);
 }
+
+// CHECK-LABEL: test_f32x4_relaxed_madd:
+// CHECK: f32x4.relaxed_madd{{$}}
+v128_t test_f32x4_relaxed_madd(v128_t a, v128_t b, v128_t c) {
+  return wasm_f32x4_relaxed_madd(a, b, c);
+}
+
+// CHECK-LABEL: test_f32x4_relaxed_nmadd:
+// CHECK: f32x4.relaxed_nmadd{{$}}
+v128_t test_f32x4_relaxed_nmadd(v128_t a, v128_t b, v128_t c) {
+  return wasm_f32x4_relaxed_nmadd(a, b, c);
+}
+
+// CHECK-LABEL: test_f64x2_relaxed_madd:
+// CHECK: f64x2.relaxed_madd{{$}}
+v128_t test_f64x2_relaxed_madd(v128_t a, v128_t b, v128_t c) {
+  return wasm_f64x2_relaxed_madd(a, b, c);
+}
+
+// CHECK-LABEL: test_f64x2_relaxed_nmadd:
+// CHECK: f64x2.relaxed_nmadd{{$}}
+v128_t test_f64x2_relaxed_nmadd(v128_t a, v128_t b, v128_t c) {
+  return wasm_f64x2_relaxed_nmadd(a, b, c);
+}
+
+// CHECK-LABEL: test_i8x16_relaxed_laneselect:
+// CHECK: i8x16.relaxed_laneselect{{$}}
+v128_t test_i8x16_relaxed_laneselect(v128_t a, v128_t b, v128_t m) {
+  return wasm_i8x16_relaxed_laneselect(a, b, m);
+}
+
+// CHECK-LABEL: test_i16x8_relaxed_laneselect:
+// CHECK: i16x8.relaxed_laneselect{{$}}
+v128_t test_i16x8_relaxed_laneselect(v128_t a, v128_t b, v128_t m) {
+  return wasm_i16x8_relaxed_laneselect(a, b, m);
+}
+
+// CHECK-LABEL: test_i32x4_relaxed_laneselect:
+// CHECK: i32x4.relaxed_laneselect{{$}}
+v128_t test_i32x4_relaxed_laneselect(v128_t a, v128_t b, v128_t m) {
+  return wasm_i32x4_relaxed_laneselect(a, b, m);
+}
+
+// CHECK-LABEL: test_i64x2_relaxed_laneselect:
+// CHECK: i64x2.relaxed_laneselect{{$}}
+v128_t test_i64x2_relaxed_laneselect(v128_t a, v128_t b, v128_t m) {
+  return wasm_i64x2_relaxed_laneselect(a, b, m);
+}
+
+// CHECK-LABEL: test_i8x16_relaxed_swizzle:
+// CHECK: i8x16.relaxed_swizzle{{$}}
+v128_t test_i8x16_relaxed_swizzle(v128_t a, v128_t s) {
+  return wasm_i8x16_relaxed_swizzle(a, s);
+}
+
+// CHECK-LABEL: test_f32x4_relaxed_min:
+// CHECK: f32x4.relaxed_min{{$}}
+v128_t test_f32x4_relaxed_min(v128_t a, v128_t b) {
+  return wasm_f32x4_relaxed_min(a, b);
+}
+
+// CHECK-LABEL: test_f32x4_relaxed_max:
+// CHECK: f32x4.relaxed_max{{$}}
+v128_t test_f32x4_relaxed_max(v128_t a, v128_t b) {
+  return wasm_f32x4_relaxed_max(a, b);
+}
+
+// CHECK-LABEL: test_f64x2_relaxed_min:
+// CHECK: f64x2.relaxed_min{{$}}
+v128_t test_f64x2_relaxed_min(v128_t a, v128_t b) {
+  return wasm_f64x2_relaxed_min(a, b);
+}
+
+// CHECK-LABEL: test_f64x2_relaxed_max:
+// CHECK: f64x2.relaxed_max
+v128_t test_f64x2_relaxed_max(v128_t a, v128_t b) {
+  return wasm_f64x2_relaxed_max(a, b);
+}
+
+// CHECK-LABEL: test_i32x4_relaxed_trunc_f32x4:
+// CHECK: i32x4.relaxed_trunc_f32x4_s{{$}}
+v128_t test_i32x4_relaxed_trunc_f32x4(v128_t a) {
+  return wasm_i32x4_relaxed_trunc_f32x4(a);
+}
+
+// CHECK-LABEL: test_u32x4_relaxed_trunc_f32x4:
+// CHECK: i32x4.relaxed_trunc_f32x4_u{{$}}
+v128_t test_u32x4_relaxed_trunc_f32x4(v128_t a) {
+  return wasm_u32x4_relaxed_trunc_f32x4(a);
+}
+
+// CHECK-LABEL: test_i32x4_relaxed_trunc_f64x2_zero:
+// CHECK: i32x4.relaxed_trunc_f64x2_s_zero{{$}}
+v128_t test_i32x4_relaxed_trunc_f64x2_zero(v128_t a) {
+  return wasm_i32x4_relaxed_trunc_f64x2_zero(a);
+}
+
+// CHECK-LABEL: test_u32x4_relaxed_trunc_f64x2_zero:
+// CHECK: i32x4.relaxed_trunc_f64x2_u_zero{{$}}
+v128_t test_u32x4_relaxed_trunc_f64x2_zero(v128_t a) {
+  return wasm_u32x4_relaxed_trunc_f64x2_zero(a);
+}
+
+// CHECK-LABEL: test_i16x8_relaxed_q15mulr:
+// CHECK: i16x8.relaxed_q15mulr_s{{$}}
+v128_t test_i16x8_relaxed_q15mulr(v128_t a, v128_t b) {
+  return wasm_i16x8_relaxed_q15mulr(a, b);
+}
+
+// CHECK-LABEL: test_i16x8_relaxed_dot_i8x16_i7x16:
+// CHECK: i16x8.relaxed_dot_i8x16_i7x16_s{{$}}
+v128_t test_i16x8_relaxed_dot_i8x16_i7x16(v128_t a, v128_t b) {
+  return wasm_i16x8_relaxed_dot_i8x16_i7x16(a, b);
+}
+
+// CHECK-LABEL: test_i32x4_relaxed_dot_i8x16_i7x16_add:

[PATCH] D150183: [Clang][clang-cl] Implement `__builtin_FUNCSIG`

2023-05-18 Thread Jakub Mazurkiewicz via Phabricator via cfe-commits
JMazurkiewicz added a comment.

> Do you need someone to commit on your behalf? If so, what name and email 
> address would you like used for patch attribution?

Yes, my name and email: "Jakub Mazurkiewicz ".

> I can fix up the release notes when I land, so you don't have to upload a new 
> patch.

Thank you in advance.


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

https://reviews.llvm.org/D150183

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


[PATCH] D150875: Make dereferencing a void* a hard-error instead of warn-as-error

2023-05-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: clang-vendors, clang-language-wg.
Herald added a project: All.
erichkeane requested review of this revision.

Clang 16 changed to consider dereferencing a void* to be a
warning-as-error, plus made this an error in SFINAE contexts, since this
resulted in incorrect template instantiation.  When doing so, the Clang
16 documentation was updated to reflect that this was likely to change
again to a non-disablable error in the next version.

As there has been no response to changing from a warning to an error, I
believe this is a non-controversial change.

This patch changes this to be an Error, consistent with the standard and
other compilers.


https://reviews.llvm.org/D150875

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/disallow_void_deref.cpp


Index: clang/test/SemaCXX/disallow_void_deref.cpp
===
--- clang/test/SemaCXX/disallow_void_deref.cpp
+++ clang/test/SemaCXX/disallow_void_deref.cpp
@@ -1,8 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify=enabled,sfinae -std=c++20 %s
-// RUN: %clang_cc1 -fsyntax-only -verify=sfinae -std=c++20 
-Wno-void-ptr-dereference %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 
 void f(void* p) {
-  (void)*p; // enabled-error{{ISO C++ does not allow indirection on operand of 
type 'void *'}}
+  (void)*p; // expected-error{{ISO C++ does not allow indirection on operand 
of type 'void *'}}
 }
 
 template
@@ -11,6 +10,6 @@
 };
 
 static_assert(deref);
-// sfinae-error@-1{{static assertion failed}}
-// sfinae-note@-2{{because 'void *' does not satisfy 'deref'}}
-// sfinae-note@#FAILED_REQ{{because '*t' would be invalid: ISO C++ does not 
allow indirection on operand of type 'void *'}}
+// expected-error@-1{{static assertion failed}}
+// expected-note@-2{{because 'void *' does not satisfy 'deref'}}
+// expected-note@#FAILED_REQ{{because '*t' would be invalid: ISO C++ does not 
allow indirection on operand of type 'void *'}}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -14957,7 +14957,7 @@
 //   be a pointer to an object type, or a pointer to a function type
 LangOptions LO = S.getLangOpts();
 if (LO.CPlusPlus)
-  S.Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer_cpp)
+  S.Diag(OpLoc, diag::err_typecheck_indirection_through_void_pointer_cpp)
   << OpTy << Op->getSourceRange();
 else if (!(LO.C99 && IsAfterAmp) && !S.isUnevaluatedContext())
   S.Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6981,9 +6981,8 @@
 def ext_typecheck_indirection_through_void_pointer : ExtWarn<
   "ISO C does not allow indirection on operand of type %0">,
   InGroup;
-def ext_typecheck_indirection_through_void_pointer_cpp
-: ExtWarn<"ISO C++ does not allow indirection on operand of type %0">,
-  InGroup, DefaultError, SFINAEFailure;
+def err_typecheck_indirection_through_void_pointer_cpp
+: Error<"ISO C++ does not allow indirection on operand of type %0">;
 def warn_indirection_through_null : Warning<
   "indirection of non-volatile null pointer will be deleted, not trap">,
   InGroup;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -55,6 +55,8 @@
 -
 - Clang won't search for coroutine_traits in std::experimental namespace any 
more.
   Clang will only search for std::coroutine_traits for coroutines then.
+- Clang no longer allows dereferencing of a ``void*`` as an extension. Clang 16
+  converted this to a warning-as-default-error as well as a SFINAE error.
 
 ABI Changes in This Version
 ---


Index: clang/test/SemaCXX/disallow_void_deref.cpp
===
--- clang/test/SemaCXX/disallow_void_deref.cpp
+++ clang/test/SemaCXX/disallow_void_deref.cpp
@@ -1,8 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify=enabled,sfinae -std=c++20 %s
-// RUN: %clang_cc1 -fsyntax-only -verify=sfinae -std=c++20 -Wno-void-ptr-dereference %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 
 void f(void* p) {
-  (void)*p; // enabled-error{{ISO C++ does not allow indirection on operand of type 'void *'}}
+  (void)*p; // expected-error{{ISO C++ does not allow indirection on operand of type 'void *'}}
 }
 
 template
@@ -11,6 +10,6 @@
 };
 
 static_assert(deref);
-// sfinae-error@-1{{static assertion failed}}
-// sfinae-note@

[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-05-18 Thread Roy Sundahl via Phabricator via cfe-commits
rsundahl marked an inline comment as done.
rsundahl added inline comments.



Comment at: compiler-rt/docs/ASanABI.rst:29
+
+  Following are some examples of reasonable responses to such changes:
+

MaskRay wrote:
> How does the 2-space indentation render in the built HTML? It may look good, 
> I ask just in case.
> How does the 2-space indentation render in the built HTML? It may look good, 
> I ask just in case.

IDK so I played around with it. Global search/replace 2 spaces with 4 does not 
affect rendering of the block above at all. In the block below there was an 
effect which was to indent the code blocks one more stop. The reason for this 
seems to be that the "current indent level" is advanced by 2 in a bulleted 
list, so below, the code block statement is actually aligned with the bulleted 
paragraph above it. After the GSR, the code block is indented and rendered 
further indented. Since bullets advance the "current indent level" by 2, maybe 
a more natural indent for the source code (.rst) is to use 2 as well. Seems to 
read a little easier in the source and avoids having to think about all the 
multiple of 4's after a bullet being "off by 2".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143675

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


[PATCH] D150411: [NFC][Clang][Coverity] Fix Static Code Analysis Concerns with copy without assign

2023-05-18 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 523396.
Manna added a comment.

Fix clang-format issues


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

https://reviews.llvm.org/D150411

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Analysis/Analyses/Consumed.h
  clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
  clang/include/clang/Analysis/Analyses/ThreadSafetyUtil.h
  clang/include/clang/Analysis/Support/BumpVector.h
  clang/include/clang/Rewrite/Core/RewriteRope.h
  clang/include/clang/Sema/Lookup.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/EHScopeStack.h
  clang/lib/Sema/SemaAccess.cpp
  clang/utils/TableGen/ClangDiagnosticsEmitter.cpp

Index: clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
===
--- clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -653,6 +653,14 @@
   Root(O.Root) {
   O.Root = nullptr;
 }
+// The move assignment operator is defined as deleted pending further
+// motivation.
+DiagText &operator=(DiagText &&) = delete;
+
+// The copy constrcutor and copy assignment operator is defined as deleted
+// pending further motivation.
+DiagText(const DiagText &) = delete;
+DiagText &operator=(const DiagText &) = delete;
 
 ~DiagText() {
   for (Piece *P : AllocatedPieces)
Index: clang/lib/Sema/SemaAccess.cpp
===
--- clang/lib/Sema/SemaAccess.cpp
+++ clang/lib/Sema/SemaAccess.cpp
@@ -199,6 +199,16 @@
 : Target(S.Target), Has(S.Has) {
   S.Target = nullptr;
 }
+
+// The move assignment operator is defined as deleted pending further
+// motivation.
+SavedInstanceContext &operator=(SavedInstanceContext &&) = delete;
+
+// The copy constrcutor and copy assignment operator is defined as deleted
+// pending further motivation.
+SavedInstanceContext(const SavedInstanceContext &) = delete;
+SavedInstanceContext &operator=(const SavedInstanceContext &) = delete;
+
 ~SavedInstanceContext() {
   if (Target)
 Target->HasInstanceContext = Has;
Index: clang/lib/CodeGen/EHScopeStack.h
===
--- clang/lib/CodeGen/EHScopeStack.h
+++ clang/lib/CodeGen/EHScopeStack.h
@@ -148,6 +148,12 @@
   public:
 Cleanup(const Cleanup &) = default;
 Cleanup(Cleanup &&) {}
+
+// The copy and move assignment operator is defined as deleted pending
+// further motivation.
+Cleanup &operator=(const Cleanup &) = delete;
+Cleanup &operator=(Cleanup &&) = delete;
+
 Cleanup() = default;
 
 virtual bool isRedundantBeforeReturn() { return false; }
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -829,7 +829,13 @@
   ApplyDebugLocation(ApplyDebugLocation &&Other) : CGF(Other.CGF) {
 Other.CGF = nullptr;
   }
-  ApplyDebugLocation &operator=(ApplyDebugLocation &&) = default;
+
+  // Define copy assignment operator.
+  ApplyDebugLocation &operator=(ApplyDebugLocation &&Other) {
+CGF = Other.CGF;
+Other.CGF = nullptr;
+return *this;
+  }
 
   ~ApplyDebugLocation();
 
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
@@ -672,6 +672,11 @@
   SymbolVisitor(const SymbolVisitor &) = default;
   SymbolVisitor(SymbolVisitor &&) {}
 
+  // The copy and move assignment operator is defined as deleted pending further
+  // motivation.
+  SymbolVisitor &operator=(const SymbolVisitor &) = delete;
+  SymbolVisitor &operator=(SymbolVisitor &&) = delete;
+
   /// A visitor method invoked by ProgramStateManager::scanReachableSymbols.
   ///
   /// The method returns \c true if symbols should continue be scanned and \c
Index: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
===
--- clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -51,6 +51,12 @@
   BugReporterVisitor() = default;
   BugReporterVisitor(const BugReporterVisitor &) = default;
   BugReporterVisitor(BugReporterVisitor &&) {}
+
+  // The copy and move assignment operator is defined as deleted pending further
+  // motivation.
+  BugReporterVisitor &operator=(const BugReport

[clang] 153d9b9 - Remove unreferenced files from Clang's website

2023-05-18 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-05-18T11:53:27-04:00
New Revision: 153d9b9371c3adf719cad4307e395692caa752ac

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

LOG: Remove unreferenced files from Clang's website

None of these files are referenced by anything else on the website, and
the content for these files is quite dated or experiments that did not
pan out. I used a few search engines to see if others were linking to
this content (esp the libstdc++ patches) and did not find significant
evidence that they were.

Added: 


Modified: 


Removed: 
clang/www/carbon-compile.png
clang/www/clang_video-05-25-2007.html
clang/www/clang_video-07-25-2007.html
clang/www/cxx_compatibility.html
clang/www/demo/DemoInfo.html
clang/www/demo/cathead.png
clang/www/demo/index.cgi
clang/www/demo/syntax.css
clang/www/demo/what is this directory.txt
clang/www/feature-compile1.png
clang/www/feature-compile2.png
clang/www/feature-memory1.png
clang/www/libstdc++4.4-clang0x.patch
clang/www/libstdc++4.6-clang11.patch
clang/www/libstdc++4.7-clang11.patch



diff  --git a/clang/www/carbon-compile.png b/clang/www/carbon-compile.png
deleted file mode 100644
index e8516c7055bb2..0
Binary files a/clang/www/carbon-compile.png and /dev/null 
diff er

diff  --git a/clang/www/clang_video-05-25-2007.html 
b/clang/www/clang_video-05-25-2007.html
deleted file mode 100755
index 4f669f4dbecf1..0
--- a/clang/www/clang_video-05-25-2007.html
+++ /dev/null
@@ -1,15 +0,0 @@
-http://www.w3.org/TR/html4/strict.dtd";>
-
-
-
-   
-   2007 LLVM Developer's Meeting
-   
-   
-https://llvm.org/devmtg/2007-05/";>
-
-
-   
-Redirecting to the new page
-
-

diff  --git a/clang/www/clang_video-07-25-2007.html 
b/clang/www/clang_video-07-25-2007.html
deleted file mode 100755
index 38661c58b2fc4..0
--- a/clang/www/clang_video-07-25-2007.html
+++ /dev/null
@@ -1,15 +0,0 @@
-http://www.w3.org/TR/html4/strict.dtd";>
-
-
-
-   
-   LLVM 2.0 and Beyond!
-   
-   
-https://llvm.org/devmtg/2007-05/";>
-
-
-   
-Redirecting to the new page
-
-

diff  --git a/clang/www/cxx_compatibility.html 
b/clang/www/cxx_compatibility.html
deleted file mode 100755
index 1dfb492587013..0
--- a/clang/www/cxx_compatibility.html
+++ /dev/null
@@ -1,27 +0,0 @@
-http://www.w3.org/TR/html4/strict.dtd";>
-
-
-
-  
-  Clang - C++ Compatibility
-  
-  
-  
-
-
-
-
-
-
-
-
-
-Clang's C++ Compatibility
-
-
-  The Clang C++ compatibility page has moved. You will be directed to its new home in 5 seconds.
-
-
-
-

diff  --git a/clang/www/demo/DemoInfo.html b/clang/www/demo/DemoInfo.html
deleted file mode 100644
index 9656ba7afc094..0
--- a/clang/www/demo/DemoInfo.html
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
-
-
-Demo page information
-
-
-
-
-
-Demo page information
-
-Press "back" or click here to return to the demo
-page.
-
-Hints and Advice
-
-
-The generated LLVM code will be easier to read if
-you use stdio (e.g., printf) than iostreams (e.g., std::cout).
-
-Unused inline functions and methods are not generated.  Instead
-of 'class foo { void bar() {}};',
-try writing 'class foo { void bar(); }; void foo::bar() {}'.
-
-If you want to try out a file that uses non-standard header files,  you 
should
-  preprocess it (e.g., with the -save-temps or -E options to
-  gcc) then upload the result.
-
-
-
-
-Demangle C++ names with C++ filt
-
-
-Select this option if you want to run the output LLVM IR through "c++filt",
-which converts 'mangled' C++ names to their unmangled version.
-Note that LLVM code produced will not be lexically valid, but it will
-be easier to understand.
-
-
-Run link-time optimizer
-
-
-Select this option to run the LLVM link-time optimizer, which is designed to
-optimize across files in your application.  Since the demo page doesn't allow
-you to upload multiple files at once, and does not link in any libraries, we
-configured the demo page optimizer to assume there are no calls
-coming in from outside the source file, allowing it to optimize more
-aggressively.
-
-Note that you have to define 'main' in your program for this
-to make much of a 
diff erence.
-
-
-Show detailed pass statistics
-
-
-Select this option to enable compilation timings and statistics from various
-optimizers.
-
-
-Analyze generated bytecode
-
-
-Select this option to run the https://llvm.org/docs/CommandGuide/llvm-bcanalyzer.html";>llvm-bcanalyzer
 tool
-on the generated bytecode, which introspects into the format of the .bc file
-itself.  
-
-
-Show C++ API code
-
-
-Select this option to run the https://llvm.org/cmds/llvm2cpp.html";>llvm2cpp tool
-on the generated bytecode, which auto generates the C++ API cal

[PATCH] D150746: [CodeGen]Translating pointer arguments can require an address space cast

2023-05-18 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx updated this revision to Diff 523400.
AlexVlx added a comment.

Reworked in accordance with review comments, correcting the embedded assumption 
about VTT being always in the generic AS. This ended up being slightly noisier 
than anticipated since functionality is spread out.


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

https://reviews.llvm.org/D150746

Files:
  clang/lib/CodeGen/ItaniumCXXABI.cpp


Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -1587,12 +1587,14 @@
   // All parameters are already in place except VTT, which goes after 'this'.
   // These are Clang types, so we don't need to worry about sret yet.
 
-  // Check if we need to add a VTT parameter (which has type void **).
+  // Check if we need to add a VTT parameter (which has type global void **).
   if ((isa(GD.getDecl()) ? GD.getCtorType() == Ctor_Base
  : GD.getDtorType() == Dtor_Base) 
&&
   cast(GD.getDecl())->getParent()->getNumVBases() != 0) {
+LangAS AS = CGM.GetGlobalVarAddressSpace(nullptr);
+QualType Q = Context.getAddrSpaceQualType(Context.VoidPtrTy, AS);
 ArgTys.insert(ArgTys.begin() + 1,
-  Context.getPointerType(Context.VoidPtrTy));
+  Context.getPointerType(CanQualType::CreateUnsafe(Q)));
 return AddedStructorArgCounts::prefix(1);
   }
   return AddedStructorArgCounts{};
@@ -1625,7 +1627,9 @@
 ASTContext &Context = getContext();
 
 // FIXME: avoid the fake decl
-QualType T = Context.getPointerType(Context.VoidPtrTy);
+LangAS AS = CGM.GetGlobalVarAddressSpace(nullptr);
+QualType Q = Context.getAddrSpaceQualType(Context.VoidPtrTy, AS);
+QualType T = Context.getPointerType(Q);
 auto *VTTDecl = ImplicitParamDecl::Create(
 Context, /*DC=*/nullptr, MD->getLocation(), &Context.Idents.get("vtt"),
 T, ImplicitParamDecl::CXXVTT);
@@ -1667,10 +1671,14 @@
   if (!NeedsVTTParameter(GlobalDecl(D, Type)))
 return AddedStructorArgs{};
 
-  // Insert the implicit 'vtt' argument as the second argument.
+  // Insert the implicit 'vtt' argument as the second argument. Make sure to
+  // correctly reflect its address space, which can differ from generic on
+  // some targets.
   llvm::Value *VTT =
   CGF.GetVTTParameter(GlobalDecl(D, Type), ForVirtualBase, Delegating);
-  QualType VTTTy = getContext().getPointerType(getContext().VoidPtrTy);
+  LangAS AS = getLangASFromTargetAS(VTT->getType()->getPointerAddressSpace());
+  QualType Q = getContext().getAddrSpaceQualType(getContext().VoidPtrTy, AS);
+  QualType VTTTy = getContext().getPointerType(Q);
   return AddedStructorArgs::prefix({{VTT, VTTTy}});
 }
 


Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -1587,12 +1587,14 @@
   // All parameters are already in place except VTT, which goes after 'this'.
   // These are Clang types, so we don't need to worry about sret yet.
 
-  // Check if we need to add a VTT parameter (which has type void **).
+  // Check if we need to add a VTT parameter (which has type global void **).
   if ((isa(GD.getDecl()) ? GD.getCtorType() == Ctor_Base
  : GD.getDtorType() == Dtor_Base) &&
   cast(GD.getDecl())->getParent()->getNumVBases() != 0) {
+LangAS AS = CGM.GetGlobalVarAddressSpace(nullptr);
+QualType Q = Context.getAddrSpaceQualType(Context.VoidPtrTy, AS);
 ArgTys.insert(ArgTys.begin() + 1,
-  Context.getPointerType(Context.VoidPtrTy));
+  Context.getPointerType(CanQualType::CreateUnsafe(Q)));
 return AddedStructorArgCounts::prefix(1);
   }
   return AddedStructorArgCounts{};
@@ -1625,7 +1627,9 @@
 ASTContext &Context = getContext();
 
 // FIXME: avoid the fake decl
-QualType T = Context.getPointerType(Context.VoidPtrTy);
+LangAS AS = CGM.GetGlobalVarAddressSpace(nullptr);
+QualType Q = Context.getAddrSpaceQualType(Context.VoidPtrTy, AS);
+QualType T = Context.getPointerType(Q);
 auto *VTTDecl = ImplicitParamDecl::Create(
 Context, /*DC=*/nullptr, MD->getLocation(), &Context.Idents.get("vtt"),
 T, ImplicitParamDecl::CXXVTT);
@@ -1667,10 +1671,14 @@
   if (!NeedsVTTParameter(GlobalDecl(D, Type)))
 return AddedStructorArgs{};
 
-  // Insert the implicit 'vtt' argument as the second argument.
+  // Insert the implicit 'vtt' argument as the second argument. Make sure to
+  // correctly reflect its address space, which can differ from generic on
+  // some targets.
   llvm::Value *VTT =
   CGF.GetVTTParameter(GlobalDecl(D, Type), ForVirtualBase, Delegating);
-  QualType VTTTy = getContext().getPointerType(getContext().VoidPtrTy);
+  LangAS AS = getLangASFrom

[clang] fbd8f89 - Ensure comparison of constraints creates a code synth context

2023-05-18 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2023-05-18T09:07:42-07:00
New Revision: fbd8f8985e36581487371e9ff4ac7d99655b51e7

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

LOG: Ensure comparison of constraints creates a code synth context

This is a regression from 6db007a0 that was reported in:
https://github.com/llvm/llvm-project/issues/62697

The assertion was because we require a code synthesis context for the
instantiation of templates, and this reproducer causes a comparison that
doesn't have a parent-template causing one to exists.

This patch fixes it by creating a ConstraintNormalization context.

Added: 


Modified: 
clang/lib/Sema/SemaConcept.cpp
clang/test/SemaTemplate/concepts-out-of-line-def.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 2f5fb8f8d029e..25884838d632c 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -764,6 +764,15 @@ static const Expr *SubstituteConstraintExpression(Sema &S, 
const NamedDecl *ND,
 return ConstrExpr;
 
   Sema::SFINAETrap SFINAE(S, /*AccessCheckingSFINAE=*/false);
+
+  Sema::InstantiatingTemplate Inst(
+  S, ND->getLocation(),
+  Sema::InstantiatingTemplate::ConstraintNormalization{},
+  const_cast(ND), SourceRange{});
+
+  if (Inst.isInvalid())
+return nullptr;
+
   std::optional ThisScope;
   if (auto *RD = dyn_cast(ND->getDeclContext()))
 ThisScope.emplace(S, const_cast(RD), Qualifiers());

diff  --git a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp 
b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
index b7c91712f8713..25b34f0644a17 100644
--- a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
+++ b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
@@ -399,3 +399,16 @@ inline void W0::W1::f(const T9 &) {}
 } // namespace three_level
 
 } // namespace MultilevelTemplateWithPartialSpecialization
+
+namespace PR62697 {
+template
+concept c = true;
+
+template
+struct s {
+void f() requires c;
+};
+
+template
+void s::f() requires c { }
+}



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


[PATCH] D150843: [clang][Diagnostics] Refactor printableTextForNextCharacter

2023-05-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

This generally looks good to me but i have a couple remarks




Comment at: clang/lib/Frontend/TextDiagnostic.cpp:124-128
+  if (CharSize == 1 && llvm::isLegalUTF8Sequence(Begin, End) &&
+  llvm::sys::locale::isPrint(*Begin)) {
+++(*I);
+return std::make_pair(SmallString<16>(Begin, End), true);
+  }

this could be simplified : the common case for ascii could be just looking at 
`isPrint(*Begin);` (which implies  CharSize == 1 and  
llvm::isLegalUTF8Sequence(Begin, End))
So you could do it before computing CharSize



Comment at: clang/lib/Frontend/TextDiagnostic.cpp:132
+  // Convert it to UTF32 and check if it's printable.
+  if (llvm::isLegalUTF8Sequence(Begin, End)) {
+llvm::UTF32 C;

I think we should check that `CharSize` is not greater than `Begin + 
SourceLine.size() - *i`  or something along those lines otherwise we may 
overflow SourceLine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150843

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


[PATCH] D150744: [NFC][CLANG] Fix uninitialized scalar field issues found by Coverity

2023-05-18 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/include/clang/Parse/Parser.h:1190
   class ParseScopeFlags {
 Scope *CurScope;
+unsigned OldFlags = 0;

@tahonermann I feel like we should have a default member initializer for any 
member that by default is not initialized. I realize in this case there 
currently should be no way for this to be bot initialized but that may not stay 
true and I don't believe there will be a penalty for doing this since it is 
initialized in the `mem-initializer-list` and therefore the default init should 
be omitted when calling the constructor. 


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

https://reviews.llvm.org/D150744

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


[clang] fa0a391 - [RISCV] Fix assertion when casting LMUL!=1 RVV types to GNU types with -mrvv-vector-bits.

2023-05-18 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2023-05-18T09:21:38-07:00
New Revision: fa0a39113a28448529f62d3ea30a7b7a8066f231

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

LOG: [RISCV] Fix assertion when casting LMUL!=1 RVV types to GNU types with 
-mrvv-vector-bits.

We need to call isRVVVLSBuiltinType() before calling getRVVTypeSize().

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/test/Sema/attr-riscv-rvv-vector-bits.c

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index d5611f8f953f6..d5b08649cbca3 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -9599,7 +9599,8 @@ bool ASTContext::areCompatibleRVVTypes(QualType FirstType,
  VT->getElementType().getCanonicalType() ==
  FirstType->getRVVEltType(*this);
 if (VT->getVectorKind() == VectorType::GenericVector)
-  return getTypeSize(SecondType) == getRVVTypeSize(*this, BT) &&
+  return FirstType->isRVVVLSBuiltinType() &&
+ getTypeSize(SecondType) == getRVVTypeSize(*this, BT) &&
  hasSameType(VT->getElementType(),
  getBuiltinVectorTypeInfo(BT).ElementType);
   }
@@ -9623,6 +9624,9 @@ bool ASTContext::areLaxCompatibleRVVTypes(QualType 
FirstType,
 if (!BT)
   return false;
 
+if (!BT->isRVVVLSBuiltinType())
+  return false;
+
 const auto *VecTy = SecondType->getAs();
 if (VecTy &&
 (VecTy->getVectorKind() == VectorType::RVVFixedLengthDataVector ||

diff  --git a/clang/test/Sema/attr-riscv-rvv-vector-bits.c 
b/clang/test/Sema/attr-riscv-rvv-vector-bits.c
index bc1a70830eafc..e23f490427dec 100644
--- a/clang/test/Sema/attr-riscv-rvv-vector-bits.c
+++ b/clang/test/Sema/attr-riscv-rvv-vector-bits.c
@@ -17,6 +17,8 @@ typedef __rvv_uint64m1_t vuint64m1_t;
 typedef __rvv_float32m1_t vfloat32m1_t;
 typedef __rvv_float64m1_t vfloat64m1_t;
 
+typedef __rvv_int32m2_t vint32m2_t;
+
 // Define valid fixed-width RVV types
 typedef vint8m1_t fixed_int8m1_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
 typedef vint16m1_t fixed_int16m1_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
@@ -45,6 +47,8 @@ typedef uint64_t gnu_uint64m1_t 
__attribute__((vector_size(__riscv_v_fixed_vlen
 typedef float gnu_float32m1_t __attribute__((vector_size(__riscv_v_fixed_vlen 
/ 8)));
 typedef double gnu_float64m1_t __attribute__((vector_size(__riscv_v_fixed_vlen 
/ 8)));
 
+typedef int32_t gnu_int32m2_t __attribute__((vector_size((__riscv_v_fixed_vlen 
* 2) / 8)));
+
 // Attribute must have a single argument
 typedef vint8m1_t no_argument __attribute__((riscv_rvv_vector_bits)); 
// expected-error {{'riscv_rvv_vector_bits' attribute takes one argument}}
 typedef vint8m1_t two_arguments __attribute__((riscv_rvv_vector_bits(2, 4))); 
// expected-error {{'riscv_rvv_vector_bits' attribute takes one argument}}
@@ -217,6 +221,11 @@ TEST_CAST_VECTOR(uint64m1)
 TEST_CAST_VECTOR(float32m1)
 TEST_CAST_VECTOR(float64m1)
 
+// Test that casts only work for LMUL=1 types and don't crash.
+vint32m2_t to_vint32m2_t_from_gnut(gnu_int32m2_t x) { return x; } // 
expected-error-re {{returning 'gnu_int32m2_t' (vector of {{[0-9]+}} 'int32_t' 
values) from a function with incompatible result type 'vint32m2_t' (aka 
'__rvv_int32m2_t')}}
+
+gnu_int32m2_t to_gnut_from_svint32_t(vint32m2_t x) { return x; } // 
expected-error-re {{returning 'vint32m2_t' (aka '__rvv_int32m2_t') from a 
function with incompatible result type 'gnu_int32m2_t' (vector of {{[0-9]+}} 
'int32_t' values)}}
+
 // --//
 // Test the scalable and fixed-length types can be used interchangeably
 



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


[clang] 0e85260 - Removed outdated information from Clang's webpage menu

2023-05-18 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-05-18T12:23:29-04:00
New Revision: 0e85260db1cfd4e8688d917a09a212c2d9a343f3

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

LOG: Removed outdated information from Clang's webpage menu

This removes the link to Planet Clang as well as the LLVM coverage
reports, as neither has been actively worked on for several years.

Added: 


Modified: 
clang/www/menu.html.incl

Removed: 




diff  --git a/clang/www/menu.html.incl b/clang/www/menu.html.incl
index 372e1492f827..9d886c7dae96 100755
--- a/clang/www/menu.html.incl
+++ b/clang/www/menu.html.incl
@@ -36,7 +36,6 @@
 https://discourse.llvm.org/c/clang";>Clang Forum
 http://lists.llvm.org/mailman/listinfo/cfe-commits";>cfe-commits 
List
 https://github.com/llvm/llvm-project/issues";>Bug Reports
-http://planet.clang.org/";>Planet Clang
 IRC: irc.oftc.net#llvm
   
 
@@ -47,11 +46,6 @@
 http://clang.llvm.org/doxygen/";>doxygen
   
 
-  
-Quick Links
-http://llvm.org/reports/coverage/";>Testing Coverage
-  
-
   
 Clang Events
 http://llvm.org/devmtg/";>LLVM Meeting



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


[PATCH] D150875: Make dereferencing a void* a hard-error instead of warn-as-error

2023-05-18 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added a comment.

I found one use here: 
https://github.com/ericniebler/range-v3/blob/48dc2eb666c07e6afc8ec5edf7db9a5c6cde7a56/include/range/v3/functional/invoke.hpp#L51


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

https://reviews.llvm.org/D150875

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


[PATCH] D150875: Make dereferencing a void* a hard-error instead of warn-as-error

2023-05-18 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

LGTM


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

https://reviews.llvm.org/D150875

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


[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-05-18 Thread Roy Sundahl via Phabricator via cfe-commits
rsundahl updated this revision to Diff 523409.
rsundahl added a comment.

Implement suggestions from latest review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143675

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/Driver/fsanitize-stable-abi.c
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/docs/ASanABI.rst
  compiler-rt/lib/asan_abi/CMakeLists.txt
  compiler-rt/lib/asan_abi/asan_abi.cpp
  compiler-rt/lib/asan_abi/asan_abi.h
  compiler-rt/lib/asan_abi/asan_abi_shim.cpp
  compiler-rt/lib/asan_abi/asan_abi_tbd.txt
  compiler-rt/test/asan_abi/CMakeLists.txt
  compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
  compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
  compiler-rt/test/asan_abi/lit.cfg.py
  compiler-rt/test/asan_abi/lit.site.cfg.py.in

Index: compiler-rt/test/asan_abi/lit.site.cfg.py.in
===
--- /dev/null
+++ compiler-rt/test/asan_abi/lit.site.cfg.py.in
@@ -0,0 +1,18 @@
+@LIT_SITE_CFG_IN_HEADER@
+
+# Tool-specific config options.
+config.name_suffix = "@ASAN_ABI_TEST_CONFIG_SUFFIX@"
+config.target_cflags = "@ASAN_ABI_TEST_TARGET_CFLAGS@"
+config.clang = "@ASAN_ABI_TEST_TARGET_CC@"
+config.bits = "@ASAN_ABI_TEST_BITS@"
+config.arm_thumb = "@COMPILER_RT_ARM_THUMB@"
+config.apple_platform = "@ASAN_ABI_TEST_APPLE_PLATFORM@"
+config.apple_platform_min_deployment_target_flag = "@ASAN_ABI_TEST_MIN_DEPLOYMENT_TARGET_FLAG@"
+config.asan_abi_dynamic = @ASAN_ABI_TEST_DYNAMIC@
+config.target_arch = "@ASAN_ABI_TEST_TARGET_ARCH@"
+
+# Load common config for all compiler-rt lit tests.
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
+
+# Load tool-specific config that would do the real work.
+lit_config.load_config(config, "@ASAN_ABI_LIT_SOURCE_DIR@/lit.cfg.py")
Index: compiler-rt/test/asan_abi/lit.cfg.py
===
--- /dev/null
+++ compiler-rt/test/asan_abi/lit.cfg.py
@@ -0,0 +1,74 @@
+# -*- Python -*-
+
+import os
+import platform
+import re
+
+import lit.formats
+
+def get_required_attr(config, attr_name):
+  attr_value = getattr(config, attr_name, None)
+  if attr_value is None:
+lit_config.fatal(
+  'No attribute %r in test configuration! You may need to run '
+  'tests from your build directory or add this attribute '
+  'to lit.site.cfg.py ' % attr_name)
+  return attr_value
+
+# Setup config name.
+config.name = 'AddressSanitizerABI' + config.name_suffix
+
+# Platform-specific default ASAN_ABI_OPTIONS for lit tests.
+default_asan_abi_opts = list(config.default_sanitizer_opts)
+
+default_asan_abi_opts_str = ':'.join(default_asan_abi_opts)
+if default_asan_abi_opts_str:
+  config.environment['ASAN_ABI_OPTIONS'] = default_asan_abi_opts_str
+  default_asan_abi_opts_str += ':'
+config.substitutions.append(('%env_asan_abi_opts=',
+ 'env ASAN_ABI_OPTIONS=' + default_asan_abi_opts_str))
+
+# Setup source root.
+config.test_source_root = os.path.dirname(__file__)
+
+# GCC-ASan doesn't link in all the necessary libraries automatically, so
+# we have to do it ourselves.
+extra_link_flags = []
+
+# Setup default compiler flags used with -fsanitize=address option.
+# FIXME: Review the set of required flags and check if it can be reduced.
+target_cflags = [get_required_attr(config, 'target_cflags')] + extra_link_flags
+target_cxxflags = config.cxx_mode_flags + target_cflags
+clang_asan_abi_static_cflags = (['-fsanitize=address',
+'-fsanitize-stable-abi',
+'-mno-omit-leaf-frame-pointer',
+'-fno-omit-frame-pointer',
+'-fno-optimize-sibling-calls'] +
+config.debug_info_flags + target_cflags)
+clang_asan_abi_static_cxxflags = config.cxx_mode_flags + clang_asan_abi_static_cflags
+
+config.available_features.add('asan_abi-static-runtime')
+clang_asan_abi_cflags = clang_asan_abi_static_cflags
+clang_asan_abi_cxxflags = clang_asan_abi_static_cxxflags
+
+def build_invocation(compile_flags):
+  return ' ' + ' '.join([config.clang] + compile_flags) + ' '
+
+config.substitutions.append( ('%clang ', build_invocation(target_cflags)) )
+config.substitutions.append( ('%clangxx ', build_invocation(target_cxxflags)) )
+config.substitutions.append( ('%clang_asan_abi ', build_invocation(clang_asan_abi_cflags)) )
+config.substitutions.append( ('%clangxx_asan_abi ', build_invocation(clang_asan_abi_cxxflags)) )
+
+libasan_abi_path = os.path.join(config.compiler_rt_libdir, 'libclang_rt.asan_abi_osx.a'.format(config.apple_platform))
+
+if libasan_abi_path is not None:
+  config.substitutions.append( ('%libasan_abi', libasan_abi_path) )
+  config.substitutions.append( ('%clang_asan_abi_static ', bu

[clang] d02d054 - Clean up Clang's index page slightly

2023-05-18 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-05-18T12:37:53-04:00
New Revision: d02d054473834091ce662073654c947b0551d61d

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

LOG: Clean up Clang's index page slightly

Set the charset to UTF-8, link to the actual liscense we used,
claim support for targets LLVM supports instead of listing them
manually, and stop listing individual language standards we support.

Added: 


Modified: 
clang/www/index.html

Removed: 




diff  --git a/clang/www/index.html b/clang/www/index.html
index d568a7b8d414..95bbfa86172b 100755
--- a/clang/www/index.html
+++ b/clang/www/index.html
@@ -3,7 +3,7 @@
 
 
 
-  
+  
   Clang C Language Family Frontend for LLVM
   
   
@@ -33,7 +33,7 @@ Features and Goals
   
   Fast compiles and low memory use
   Expressive diagnostics (examples)
-  GCC compatibility
+  GCC & MSVC compatibility
   
 
   Utility and
@@ -44,7 +44,9 @@ Features and Goals
   Support diverse clients (refactoring, static analysis, code generation,
etc.)
   Allow tight integration with IDEs
-  Use the LLVM 'Apache 2' License
+  Use the LLVM 'Apache 2'
+https://github.com/llvm/llvm-project/blob/main/LICENSE.TXT";>License
+  
   
 
   Internal Design and
@@ -80,12 +82,13 @@ Current Status
 
   Clang is considered to
be a production quality C, Objective-C, C++ and Objective-C++ compiler when
-   targeting X86-32, X86-64, and ARM (other targets may have caveats, but are
-   usually easy to fix). As example, Clang is used in production to build
-   performance-critical software like Chrome or Firefox.  If you are 
looking
-   for source analysis or source-to-source transformation tools, Clang is 
probably
-   a great solution for you.  Clang supports C++11, C++14 and C++17, please see
-   the C++ status page for more information.
+   targeting any target supported by LLVM. As example, Clang is used in
+   production to build performance-critical software like Chrome or Firefox.
+ If you are looking for source analysis or source-to-source
+   transformation tools, Clang is probably a great solution for you. Please see
+   the C++ status page or the
+   C status page for more information about what
+   standard modes and features are supported.
 
   
   Get it and get involved!



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


[PATCH] D150872: [clang-tidy] Add support for new TODO style to google-readability-todo

2023-05-18 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp:97
 : ClangTidyCheck(Name, Context),
+  UseV2Style(Options.getLocalOrGlobal("UseV2Style", false)),
   Handler(std::make_unique(

Given this check is part of the google module, doesn't it make sense to have 
the default as what google now recommends.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/google/readability-todo.rst:6
 
 Finds TODO comments without a username or bug number.
 

Maybe update this line to something along with lines of
`Finds TODO comments not conforming to googles style guidelines`



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/google/readability-todo.rst:16-18
+.. option:: User
+
+   The username to use when suggesting an edit to a TODO comment. Only 
relevant to V1 style.

This shouldn't appear in the options, as it isn't read from the `CheckOptions`



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/google/readability-todo.rst:22
+
+   Whether to check TODO comments against the new TODO style, specifically:
+   ```

It would be good to specify the default value of this option(or just the 
default behaviour of the check)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150872

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


[PATCH] D150875: Make dereferencing a void* a hard-error instead of warn-as-error

2023-05-18 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Can you expand on the motivation for removing this extension? This doesn't seem 
to save a lot of code complexity, and it increases migration costs for our 
users. I'd like to have some motivation for putting them through the trouble of 
migrating.


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

https://reviews.llvm.org/D150875

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


[PATCH] D150875: Make dereferencing a void* a hard-error instead of warn-as-error

2023-05-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D150875#4353209 , @rupprecht wrote:

> I found one use here: 
> https://github.com/ericniebler/range-v3/blob/48dc2eb666c07e6afc8ec5edf7db9a5c6cde7a56/include/range/v3/functional/invoke.hpp#L51

Huh, that is an interesting use!  I notice that he enables that for both GCC 
AND Clang, but probably doesn't notice because he disables Wpragma as well.  So 
this change would change the legality of his program (potentially) for Clang 
(though, we ALREADY would have broken any SFINAE/concepts uses because of the 
SFINAE change in 16), but only to be what GCC gives him?  I think we can be ok 
with that?


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

https://reviews.llvm.org/D150875

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


[PATCH] D150875: Make dereferencing a void* a hard-error instead of warn-as-error

2023-05-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D150875#4353358 , @rnk wrote:

> Can you expand on the motivation for removing this extension? This doesn't 
> seem to save a lot of code complexity, and it increases migration costs for 
> our users. I'd like to have some motivation for putting them through the 
> trouble of migrating.

The motivation is essentially the same motivation for making this a SFINAE 
error: We are the only of the major compilers with this "extension" (I hesitate 
to call it that, as I'm not sure this FITS in the 'extension's permitted by 
standard), and we gave warning last release in the release notes that we'd be 
doing this.  You're right there is no additional code complexity, but there IS 
standards compliance issues, as well as "do what everyone else does".

I WILL say the SFINAE change last release was more significant as a motivation, 
since it had the ability to change the overload set.


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

https://reviews.llvm.org/D150875

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


[PATCH] D150875: Make dereferencing a void* a hard-error instead of warn-as-error

2023-05-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D150875#4353358 , @rnk wrote:

> Can you expand on the motivation for removing this extension? This doesn't 
> seem to save a lot of code complexity, and it increases migration costs for 
> our users. I'd like to have some motivation for putting them through the 
> trouble of migrating.

Note, there was an RFC: 
https://discourse.llvm.org/t/rfc-can-we-stop-the-extension-to-allow-dereferencing-void-in-c/65708


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

https://reviews.llvm.org/D150875

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


[PATCH] D144457: [clang][Interp] Handle global composite temporaries

2023-05-18 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

I think it mostly makes sense but I want Aaron to also look at it.




Comment at: clang/lib/AST/Interp/Pointer.cpp:10
 #include "Pointer.h"
+#include "Boolean.h"
+#include "Context.h"

Are all these headers really needed for the change below?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144457

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


[PATCH] D150645: [Driver] Support multi /guard: options

2023-05-18 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

if you add a test for the repro, relanding lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150645

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


[PATCH] D150820: [NVPTX, CUDA] added optional src_size argument to __nvvm_cp_async*

2023-05-18 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 523426.
tra added a comment.

Actually connected the Sema check for the optional argument, and added a test 
to cover it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150820

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-nvptx.c
  clang/test/SemaCUDA/builtins.cu
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/async-copy.ll

Index: llvm/test/CodeGen/NVPTX/async-copy.ll
===
--- llvm/test/CodeGen/NVPTX/async-copy.ll
+++ llvm/test/CodeGen/NVPTX/async-copy.ll
@@ -1,35 +1,35 @@
-; RUN: llc < %s -march=nvptx -mcpu=sm_80 -mattr=+ptx70 | FileCheck -check-prefixes=ALL,CHECK_PTX32 %s
-; RUN: llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | FileCheck -check-prefixes=ALL,CHECK_PTX64 %s
+; RUN: llc < %s -march=nvptx -mcpu=sm_80 -mattr=+ptx70 | FileCheck -check-prefixes=CHECK,CHECK_PTX32 %s
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | FileCheck -check-prefixes=CHECK,CHECK_PTX64 %s
 ; RUN: %if ptxas-11.0 %{ llc < %s -march=nvptx -mcpu=sm_80 -mattr=+ptx70 | %ptxas-verify -arch=sm_80 %}
 ; RUN: %if ptxas-11.0 %{ llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | %ptxas-verify -arch=sm_80 %}
 
 declare void @llvm.nvvm.cp.async.wait.group(i32)
 
-; ALL-LABEL: asyncwaitgroup
+; CHECK-LABEL: asyncwaitgroup
 define void @asyncwaitgroup() {
-  ; ALL: cp.async.wait_group 8;
+  ; CHECK: cp.async.wait_group 8;
   tail call void @llvm.nvvm.cp.async.wait.group(i32 8)
-  ; ALL: cp.async.wait_group 0;
+  ; CHECK: cp.async.wait_group 0;
   tail call void @llvm.nvvm.cp.async.wait.group(i32 0)
-  ; ALL: cp.async.wait_group 16;
+  ; CHECK: cp.async.wait_group 16;
   tail call void @llvm.nvvm.cp.async.wait.group(i32 16)
   ret void
 }
 
 declare void @llvm.nvvm.cp.async.wait.all()
 
-; ALL-LABEL: asyncwaitall
+; CHECK-LABEL: asyncwaitall
 define void @asyncwaitall() {
-; ALL: cp.async.wait_all
+; CHECK: cp.async.wait_all
   tail call void @llvm.nvvm.cp.async.wait.all()
   ret void
 }
 
 declare void @llvm.nvvm.cp.async.commit.group()
 
-; ALL-LABEL: asynccommitgroup
+; CHECK-LABEL: asynccommitgroup
 define void @asynccommitgroup() {
-; ALL: cp.async.commit_group
+; CHECK: cp.async.commit_group
   tail call void @llvm.nvvm.cp.async.commit.group()
   ret void
 }
@@ -41,72 +41,75 @@
 
 ; CHECK-LABEL: asyncmbarrier
 define void @asyncmbarrier(ptr %a) {
-; CHECK_PTX32: cp.async.mbarrier.arrive.b64 [%r{{[0-9]+}}];
-; CHECK_PTX64: cp.async.mbarrier.arrive.b64 [%rd{{[0-9]+}}];
+; The distinction between PTX32/PTX64 here is only to capture pointer register type
+; in R to be used in subsequent tests.
+; CHECK_PTX32: cp.async.mbarrier.arrive.b64 [%[[R:r]]{{[0-9]+}}];
+; CHECK_PTX64: cp.async.mbarrier.arrive.b64 [%[[R:rd]]{{[0-9]+}}];
   tail call void @llvm.nvvm.cp.async.mbarrier.arrive(ptr %a)
   ret void
 }
 
 ; CHECK-LABEL: asyncmbarriershared
 define void @asyncmbarriershared(ptr addrspace(3) %a) {
-; CHECK_PTX32: cp.async.mbarrier.arrive.shared.b64 [%r{{[0-9]+}}];
-; CHECK_PTX64: cp.async.mbarrier.arrive.shared.b64 [%rd{{[0-9]+}}];
+; CHECK: cp.async.mbarrier.arrive.shared.b64 [%[[R]]{{[0-9]+}}];
   tail call void @llvm.nvvm.cp.async.mbarrier.arrive.shared(ptr addrspace(3) %a)
   ret void
 }
 
 ; CHECK-LABEL: asyncmbarriernoinc
 define void @asyncmbarriernoinc(ptr %a) {
-; CHECK_PTX32: cp.async.mbarrier.arrive.noinc.b64 [%r{{[0-9]+}}];
-; CHECK_PTX64: cp.async.mbarrier.arrive.noinc.b64 [%rd{{[0-9]+}}];
+; CHECK_PTX64: cp.async.mbarrier.arrive.noinc.b64 [%[[R]]{{[0-9]+}}];
   tail call void @llvm.nvvm.cp.async.mbarrier.arrive.noinc(ptr %a)
   ret void
 }
 
 ; CHECK-LABEL: asyncmbarriernoincshared
 define void @asyncmbarriernoincshared(ptr addrspace(3) %a) {
-; CHECK_PTX32: cp.async.mbarrier.arrive.noinc.shared.b64 [%r{{[0-9]+}}];
-; CHECK_PTX64: cp.async.mbarrier.arrive.noinc.shared.b64 [%rd{{[0-9]+}}];
+; CHECK: cp.async.mbarrier.arrive.noinc.shared.b64 [%[[R]]{{[0-9]+}}];
   tail call void @llvm.nvvm.cp.async.mbarrier.arrive.noinc.shared(ptr addrspace(3) %a)
   ret void
 }
 
-declare void @llvm.nvvm.cp.async.ca.shared.global.4(ptr addrspace(3) %a, ptr addrspace(1) %b)
+declare void @llvm.nvvm.cp.async.ca.shared.global.4(ptr addrspace(3) %a, ptr addrspace(1) %b, i32 %c)
 
 ; CHECK-LABEL: asynccasharedglobal4i8
-define void @asynccasharedglobal4i8(ptr addrspace(3) %a, ptr addrspace(1) %b) {
-; CHECK_PTX32: cp.async.ca.shared.global [%r{{[0-9]+}}], [%r{{[0-9]+}}], 4;
-; CHECK_PTX64: cp.async.ca.shared.global [%rd{{[0-9]+}}], [%rd{{[0-9]+}}], 4;
-  tail call void @llvm.nvvm.cp.async.ca.shared.global.4(ptr addrspace(3) %a, ptr addrspace(1) %b)
+define void @asynccasharedglobal4i8(ptr addrspace(3) %a, ptr addrspace(1) %b, i32 %c) {
+; CHECK: cp.async.c

[PATCH] D150820: [NVPTX, CUDA] added optional src_size argument to __nvvm_cp_async*

2023-05-18 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 523428.
tra added a comment.

Cosmetic test cleanup.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150820

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-nvptx.c
  clang/test/SemaCUDA/builtins.cu
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/async-copy.ll

Index: llvm/test/CodeGen/NVPTX/async-copy.ll
===
--- llvm/test/CodeGen/NVPTX/async-copy.ll
+++ llvm/test/CodeGen/NVPTX/async-copy.ll
@@ -1,35 +1,35 @@
-; RUN: llc < %s -march=nvptx -mcpu=sm_80 -mattr=+ptx70 | FileCheck -check-prefixes=ALL,CHECK_PTX32 %s
-; RUN: llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | FileCheck -check-prefixes=ALL,CHECK_PTX64 %s
+; RUN: llc < %s -march=nvptx -mcpu=sm_80 -mattr=+ptx70 | FileCheck -check-prefixes=CHECK,CHECK_PTX32 %s
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | FileCheck -check-prefixes=CHECK,CHECK_PTX64 %s
 ; RUN: %if ptxas-11.0 %{ llc < %s -march=nvptx -mcpu=sm_80 -mattr=+ptx70 | %ptxas-verify -arch=sm_80 %}
 ; RUN: %if ptxas-11.0 %{ llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | %ptxas-verify -arch=sm_80 %}
 
 declare void @llvm.nvvm.cp.async.wait.group(i32)
 
-; ALL-LABEL: asyncwaitgroup
+; CHECK-LABEL: asyncwaitgroup
 define void @asyncwaitgroup() {
-  ; ALL: cp.async.wait_group 8;
+  ; CHECK: cp.async.wait_group 8;
   tail call void @llvm.nvvm.cp.async.wait.group(i32 8)
-  ; ALL: cp.async.wait_group 0;
+  ; CHECK: cp.async.wait_group 0;
   tail call void @llvm.nvvm.cp.async.wait.group(i32 0)
-  ; ALL: cp.async.wait_group 16;
+  ; CHECK: cp.async.wait_group 16;
   tail call void @llvm.nvvm.cp.async.wait.group(i32 16)
   ret void
 }
 
 declare void @llvm.nvvm.cp.async.wait.all()
 
-; ALL-LABEL: asyncwaitall
+; CHECK-LABEL: asyncwaitall
 define void @asyncwaitall() {
-; ALL: cp.async.wait_all
+; CHECK: cp.async.wait_all
   tail call void @llvm.nvvm.cp.async.wait.all()
   ret void
 }
 
 declare void @llvm.nvvm.cp.async.commit.group()
 
-; ALL-LABEL: asynccommitgroup
+; CHECK-LABEL: asynccommitgroup
 define void @asynccommitgroup() {
-; ALL: cp.async.commit_group
+; CHECK: cp.async.commit_group
   tail call void @llvm.nvvm.cp.async.commit.group()
   ret void
 }
@@ -41,72 +41,75 @@
 
 ; CHECK-LABEL: asyncmbarrier
 define void @asyncmbarrier(ptr %a) {
-; CHECK_PTX32: cp.async.mbarrier.arrive.b64 [%r{{[0-9]+}}];
-; CHECK_PTX64: cp.async.mbarrier.arrive.b64 [%rd{{[0-9]+}}];
+; The distinction between PTX32/PTX64 here is only to capture pointer register type
+; in R to be used in subsequent tests.
+; CHECK_PTX32: cp.async.mbarrier.arrive.b64 [%[[R:r]]{{[0-9]+}}];
+; CHECK_PTX64: cp.async.mbarrier.arrive.b64 [%[[R:rd]]{{[0-9]+}}];
   tail call void @llvm.nvvm.cp.async.mbarrier.arrive(ptr %a)
   ret void
 }
 
 ; CHECK-LABEL: asyncmbarriershared
 define void @asyncmbarriershared(ptr addrspace(3) %a) {
-; CHECK_PTX32: cp.async.mbarrier.arrive.shared.b64 [%r{{[0-9]+}}];
-; CHECK_PTX64: cp.async.mbarrier.arrive.shared.b64 [%rd{{[0-9]+}}];
+; CHECK: cp.async.mbarrier.arrive.shared.b64 [%[[R]]{{[0-9]+}}];
   tail call void @llvm.nvvm.cp.async.mbarrier.arrive.shared(ptr addrspace(3) %a)
   ret void
 }
 
 ; CHECK-LABEL: asyncmbarriernoinc
 define void @asyncmbarriernoinc(ptr %a) {
-; CHECK_PTX32: cp.async.mbarrier.arrive.noinc.b64 [%r{{[0-9]+}}];
-; CHECK_PTX64: cp.async.mbarrier.arrive.noinc.b64 [%rd{{[0-9]+}}];
+; CHECK_PTX64: cp.async.mbarrier.arrive.noinc.b64 [%[[R]]{{[0-9]+}}];
   tail call void @llvm.nvvm.cp.async.mbarrier.arrive.noinc(ptr %a)
   ret void
 }
 
 ; CHECK-LABEL: asyncmbarriernoincshared
 define void @asyncmbarriernoincshared(ptr addrspace(3) %a) {
-; CHECK_PTX32: cp.async.mbarrier.arrive.noinc.shared.b64 [%r{{[0-9]+}}];
-; CHECK_PTX64: cp.async.mbarrier.arrive.noinc.shared.b64 [%rd{{[0-9]+}}];
+; CHECK: cp.async.mbarrier.arrive.noinc.shared.b64 [%[[R]]{{[0-9]+}}];
   tail call void @llvm.nvvm.cp.async.mbarrier.arrive.noinc.shared(ptr addrspace(3) %a)
   ret void
 }
 
-declare void @llvm.nvvm.cp.async.ca.shared.global.4(ptr addrspace(3) %a, ptr addrspace(1) %b)
+declare void @llvm.nvvm.cp.async.ca.shared.global.4(ptr addrspace(3) %a, ptr addrspace(1) %b, i32 %c)
 
 ; CHECK-LABEL: asynccasharedglobal4i8
-define void @asynccasharedglobal4i8(ptr addrspace(3) %a, ptr addrspace(1) %b) {
-; CHECK_PTX32: cp.async.ca.shared.global [%r{{[0-9]+}}], [%r{{[0-9]+}}], 4;
-; CHECK_PTX64: cp.async.ca.shared.global [%rd{{[0-9]+}}], [%rd{{[0-9]+}}], 4;
-  tail call void @llvm.nvvm.cp.async.ca.shared.global.4(ptr addrspace(3) %a, ptr addrspace(1) %b)
+define void @asynccasharedglobal4i8(ptr addrspace(3) %a, ptr addrspace(1) %b, i32 %c) {
+; CHECK: cp.async.ca.shared.global [%[[R]]{{[0-9]+}}], [%[[R]]{{[0-9]+}}], 4, %r{{[0-9]+

[PATCH] D150875: Make dereferencing a void* a hard-error instead of warn-as-error

2023-05-18 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D150875#4353398 , @aaron.ballman 
wrote:

> Note, there was an RFC: 
> https://discourse.llvm.org/t/rfc-can-we-stop-the-extension-to-allow-dereferencing-void-in-c/65708

Thanks, that addresses my concern. Please link to it from the commit message, 
it will help anyone bisecting the behavior change have context.


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

https://reviews.llvm.org/D150875

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


[PATCH] D149716: clang: Use new frexp intrinsic for builtins and add f16 version

2023-05-18 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

ping


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

https://reviews.llvm.org/D149716

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


[clang] 3f43abc - [RISCV] Reduce dependency on RISCV::RVVBitsPerBlock for calculating vector size for -mrvv-vector-bits.

2023-05-18 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2023-05-18T10:09:50-07:00
New Revision: 3f43abc9e78cce99741f7c8cf54552c95cc98d9f

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

LOG: [RISCV] Reduce dependency on RISCV::RVVBitsPerBlock for calculating vector 
size for -mrvv-vector-bits.

We can use the minimum value of the BuiltinType's ElementCount and
the element size.

This needs to be done to support LMUL!=1 types anyway.

I did have to make an ordering change in the error checks in
HandleRISCVRVVVectorBitsTypeAttr to check if the type is an RVV
VLS type before checking the size.

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/lib/Sema/SemaType.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index d5b08649cbca..9c247b3c439a 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -85,7 +85,6 @@
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/TargetParser/RISCVTargetParser.h"
 #include "llvm/TargetParser/Triple.h"
 #include 
 #include 
@@ -9581,7 +9580,14 @@ bool ASTContext::areLaxCompatibleSveTypes(QualType 
FirstType,
 static uint64_t getRVVTypeSize(ASTContext &Context, const BuiltinType *Ty) {
   assert(Ty->isRVVVLSBuiltinType() && "Invalid RVV Type");
   auto VScale = Context.getTargetInfo().getVScaleRange(Context.getLangOpts());
-  return VScale ? VScale->first * llvm::RISCV::RVVBitsPerBlock : 0;
+  if (!VScale)
+return 0;
+
+  ASTContext::BuiltinVectorTypeInfo Info = 
Context.getBuiltinVectorTypeInfo(Ty);
+
+  unsigned EltSize = Context.getTypeSize(Info.ElementType);
+  unsigned MinElts = Info.EC.getKnownMinValue();
+  return VScale->first * MinElts * EltSize;
 }
 
 bool ASTContext::areCompatibleRVVTypes(QualType FirstType,

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index da105e3d6ad2..06efb3dfef8e 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8320,31 +8320,32 @@ static void HandleRISCVRVVVectorBitsTypeAttr(QualType 
&CurType,
   if (!verifyValidIntegerConstantExpr(S, Attr, RVVVectorSizeInBits))
 return;
 
+  // Attribute can only be attached to a single RVV vector type.
+  if (!CurType->isRVVVLSBuiltinType()) {
+S.Diag(Attr.getLoc(), diag::err_attribute_invalid_rvv_type)
+<< Attr << CurType;
+Attr.setInvalid();
+return;
+  }
+
   unsigned VecSize = static_cast(RVVVectorSizeInBits.getZExtValue());
 
+  ASTContext::BuiltinVectorTypeInfo Info =
+  S.Context.getBuiltinVectorTypeInfo(CurType->getAs());
+  unsigned EltSize = S.Context.getTypeSize(Info.ElementType);
+  unsigned MinElts = Info.EC.getKnownMinValue();
+
   // The attribute vector size must match -mrvv-vector-bits.
-  // FIXME: Add support for types with LMUL!=1. Need to make sure size passed
-  // to attribute is equal to LMUL*VScaleMin*RVVBitsPerBlock.
-  if (VecSize != VScale->first * llvm::RISCV::RVVBitsPerBlock) {
+  if (VecSize != VScale->first * MinElts * EltSize) {
 S.Diag(Attr.getLoc(), diag::err_attribute_bad_rvv_vector_size)
 << VecSize << VScale->first * llvm::RISCV::RVVBitsPerBlock;
 Attr.setInvalid();
 return;
   }
 
-  // Attribute can only be attached to a single RVV vector type.
-  if (!CurType->isRVVVLSBuiltinType()) {
-S.Diag(Attr.getLoc(), diag::err_attribute_invalid_rvv_type)
-<< Attr << CurType;
-Attr.setInvalid();
-return;
-  }
-
-  QualType EltType = CurType->getRVVEltType(S.Context);
-  unsigned TypeSize = S.Context.getTypeSize(EltType);
   VectorType::VectorKind VecKind = VectorType::RVVFixedLengthDataVector;
-  VecSize /= TypeSize;
-  CurType = S.Context.getVectorType(EltType, VecSize, VecKind);
+  VecSize /= EltSize;
+  CurType = S.Context.getVectorType(Info.ElementType, VecSize, VecKind);
 }
 
 /// Handle OpenCL Access Qualifier Attribute.



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


[PATCH] D150875: Make dereferencing a void* a hard-error instead of warn-as-error

2023-05-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D150875#4353435 , @rnk wrote:

> In D150875#4353398 , @aaron.ballman 
> wrote:
>
>> Note, there was an RFC: 
>> https://discourse.llvm.org/t/rfc-can-we-stop-the-extension-to-allow-dereferencing-void-in-c/65708
>
> Thanks, that addresses my concern. Please link to it from the commit message, 
> it will help anyone bisecting the behavior change have context.

Will do!  I've put it in my local git, and will put it in phab as well.


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

https://reviews.llvm.org/D150875

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


[PATCH] D150875: Make dereferencing a void* a hard-error instead of warn-as-error

2023-05-18 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

We heavily rely on this extension in CheriBSD via `__typeof__((*(p))) * 
__capability` as we want to be able to take any pointer, including to an array 
or function that needs to undergo decay to be an actual pointer, and turn it 
into a `__capability`-qualified one. Presumably you're saying we should instead 
use `__typeof((0, (p)))__ __capability` as an uglier alternative way to force 
decay?


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

https://reviews.llvm.org/D150875

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


[PATCH] D150875: Make dereferencing a void* a hard-error instead of warn-as-error

2023-05-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D150875#4353467 , @jrtc27 wrote:

> We heavily rely on this extension in CheriBSD via `__typeof__((*(p))) * 
> __capability` as we want to be able to take any pointer, including to an 
> array or function that needs to undergo decay to be an actual pointer, and 
> turn it into a `__capability`-qualified one. Presumably you're saying we 
> should instead use `__typeof__((0, (p))) __capability` as an uglier 
> alternative way to force decay?

Do you do that in C++, or just C?  Note that this does NOT change the behavior 
in C.  In C++ I'd probably just suggest using `std::decay`.


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

https://reviews.llvm.org/D150875

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


[PATCH] D150875: Make dereferencing a void* a hard-error instead of warn-as-error

2023-05-18 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D150875#4353484 , @erichkeane 
wrote:

> In D150875#4353467 , @jrtc27 wrote:
>
>> We heavily rely on this extension in CheriBSD via `__typeof__((*(p))) * 
>> __capability` as we want to be able to take any pointer, including to an 
>> array or function that needs to undergo decay to be an actual pointer, and 
>> turn it into a `__capability`-qualified one. Presumably you're saying we 
>> should instead use `__typeof__((0, (p))) __capability` as an uglier 
>> alternative way to force decay?
>
> Do you do that in C++, or just C?  Note that this does NOT change the 
> behavior in C.  In C++ I'd probably just suggest using `std::decay`.

In practice just C (kernel-only macro), though ideally the macro would still 
work in C++ (at least on CheriBSD; C++-based OSes will differ, but can of 
course do their own thing).


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

https://reviews.llvm.org/D150875

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


[PATCH] D146873: [2/11][POC][Clang][RISCV] Define RVV tuple types

2023-05-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/CodeGen/CGCall.cpp:3135
   STy->getNumElements() > 1) {
-uint64_t SrcSize = CGM.getDataLayout().getTypeAllocSize(STy);
-llvm::Type *DstTy = Ptr.getElementType();
-uint64_t DstSize = CGM.getDataLayout().getTypeAllocSize(DstTy);
+if (STy->containsScalableVectorType()) {
+  assert(STy->containsHomogeneousScalableVectorTypes() &&

Can we call `CGM.getDataLayout().getTypeAllocSize(STy)` and check if the 
TypeSize returned isScalable instead of calling containsScalableVectorType?



Comment at: 
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type-1.c:1
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zve32x -disable-O0-optnone 
\

Do these two tests have the same content but different RUN lines? Can we merge 
them with 2 different RUN lines?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146873

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


[clang] 09aaf53 - [RFC][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs.

2023-05-18 Thread Vy Nguyen via cfe-commits

Author: Vy Nguyen
Date: 2023-05-18T13:27:47-04:00
New Revision: 09aaf53a05e3786eea374f3ce57574225036412d

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

LOG: [RFC][MC][MachO]Only emits compact-unwind format for "canonical" 
personality symbols. For the rest, use DWARFs.

Details: https://github.com/rust-lang/rust/issues/102754

The MachO format uses 2 bits to encode these personality funtions, with 0 
reserved for "no-personality".
This means we can only have up to 3 personality. There are already three 
popular personalities:  __gxx_personality_v0, __gcc_personality_v0, and 
__objc_personality_v0.
As a result, any system that needs custom-personality will run into a problem.

This patch implemented jyknight's proposal to simply force DWARFs for all 
non-canonical personality functions.

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

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/femit-dwarf-unwind.c
clang/test/Driver/femit-dwarf-unwind.s
clang/tools/driver/cc1as_main.cpp
lld/MachO/UnwindInfoSection.cpp
lld/test/MachO/Inputs/eh-frame-x86_64-r.o
lld/test/MachO/compact-unwind-both-local-and-dylib-personality.s
lld/test/MachO/compact-unwind-generated.test
lld/test/MachO/compact-unwind-lsda-folding.s
lld/test/MachO/compact-unwind-stack-ind.s
lld/test/MachO/compact-unwind.s
lld/test/MachO/eh-frame-personality-dedup.s
lld/test/MachO/eh-frame.s
lld/test/MachO/icf-only-lsda-folded.s
lld/test/MachO/icf.s
lld/test/MachO/invalid/compact-unwind-bad-reloc.s
lld/test/MachO/invalid/compact-unwind-personalities.s
llvm/include/llvm/MC/MCAsmBackend.h
llvm/include/llvm/MC/MCContext.h
llvm/include/llvm/MC/MCTargetOptions.h
llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
llvm/lib/MC/MCAsmBackend.cpp
llvm/lib/MC/MCContext.cpp
llvm/lib/MC/MCStreamer.cpp
llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h
llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
llvm/test/CodeGen/X86/2014-08-29-CompactUnwind.ll
llvm/test/CodeGen/X86/compact-unwind.ll
llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
llvm/test/MC/MachO/ARM/compact-unwind-armv7k.s
llvm/test/MC/X86/compact-unwind.s

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 5752c6e285b98..53d92c4c76673 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -114,6 +114,9 @@ CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when 
-fstack-size-section is enabl
 CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
   ///< enabled.
 
+///< Set when -femit-compact-unwind-non-canonical is enabled.
+CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0)
+
 ///< Set when -femit-dwarf-unwind is passed.
 ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
 llvm::EmitDwarfUnwindType::Default)

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f3026693e6d53..9f6922cbe5678 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3244,6 +3244,9 @@ def femit_dwarf_unwind_EQ : Joined<["-"], 
"femit-dwarf-unwind=">,
   NormalizedValues<["Always", "NoCompactUnwind", "Default"]>,
   NormalizedValuesScope<"llvm::EmitDwarfUnwindType">,
   MarshallingInfoEnum, "Default">;
+defm emit_compact_unwind_non_canonical : 
BoolFOption<"emit-compact-unwind-non-canonical",
+  CodeGenOpts<"EmitCompactUnwindNonCanonical">, DefaultFalse,
+  PosFlag, 
NegFlag>;
 def g_Flag : Flag<["-"], "g">, Group,
 Flags<[CoreOption,FlangOption]>, HelpText<"Generate source-level debug 
information">;
 def gline_tables_only : Flag<["-"], "gline-tables-only">, Group,

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index d62d00a156f1c..934e41c75f4d1 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -454,6 +454,8 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
 
   Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
   Options.MCOptions.EmitDwarfUnwind = CodeGenOpts.getEmitDwarfUnwind();
+  Options.MCOptions.EmitCompactUnwindNonCanonical =
+  CodeGenOpts.EmitCompactUnwindNonCanonical;
   Options.MCO

[PATCH] D144999: [Clang][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs.

2023-05-18 Thread Vy Nguyen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG09aaf53a05e3: [RFC][MC][MachO]Only emits compact-unwind 
format for "canonical" personality… (authored by oontvoo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/femit-dwarf-unwind.c
  clang/test/Driver/femit-dwarf-unwind.s
  clang/tools/driver/cc1as_main.cpp
  lld/MachO/UnwindInfoSection.cpp
  lld/test/MachO/Inputs/eh-frame-x86_64-r.o
  lld/test/MachO/compact-unwind-both-local-and-dylib-personality.s
  lld/test/MachO/compact-unwind-generated.test
  lld/test/MachO/compact-unwind-lsda-folding.s
  lld/test/MachO/compact-unwind-stack-ind.s
  lld/test/MachO/compact-unwind.s
  lld/test/MachO/eh-frame-personality-dedup.s
  lld/test/MachO/eh-frame.s
  lld/test/MachO/icf-only-lsda-folded.s
  lld/test/MachO/icf.s
  lld/test/MachO/invalid/compact-unwind-bad-reloc.s
  lld/test/MachO/invalid/compact-unwind-personalities.s
  llvm/include/llvm/MC/MCAsmBackend.h
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCTargetOptions.h
  llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/test/CodeGen/X86/2014-08-29-CompactUnwind.ll
  llvm/test/CodeGen/X86/compact-unwind.ll
  llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
  llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
  llvm/test/MC/MachO/ARM/compact-unwind-armv7k.s
  llvm/test/MC/X86/compact-unwind.s

Index: llvm/test/MC/X86/compact-unwind.s
===
--- llvm/test/MC/X86/compact-unwind.s
+++ llvm/test/MC/X86/compact-unwind.s
@@ -1,4 +1,4 @@
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin10.0 %s | llvm-objdump --unwind-info - | FileCheck %s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin10.0 %s -emit-compact-unwind-non-canonical=true | llvm-objdump --unwind-info - | FileCheck %s
 
 	.section	__TEXT,__text,regular,pure_instructions
 	.macosx_version_min 10, 10
Index: llvm/test/MC/MachO/ARM/compact-unwind-armv7k.s
===
--- llvm/test/MC/MachO/ARM/compact-unwind-armv7k.s
+++ llvm/test/MC/MachO/ARM/compact-unwind-armv7k.s
@@ -1,4 +1,4 @@
-@ RUN: llvm-mc -triple=thumbv7k-apple-watchos2.0.0 -filetype=obj -o %t < %s && llvm-objdump --unwind-info %t | FileCheck %s
+@ RUN: llvm-mc -triple=thumbv7k-apple-watchos2.0.0 -emit-compact-unwind-non-canonical=true -filetype=obj -o %t < %s && llvm-objdump --unwind-info %t | FileCheck %s
 
 @ CHECK: Contents of __compact_unwind section:
 
Index: llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
===
--- llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
+++ llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
@@ -1,11 +1,11 @@
 // RUN: rm -rf %t; mkdir %t
-// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj -o %t/x86_64.o
+// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj -o %t/x86_64.o -emit-compact-unwind-non-canonical=true
 // RUN: llvm-objdump --macho --dwarf=frames %t/x86_64.o | FileCheck %s --check-prefix TWO-FDES
-// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj -o %t/arm64.o
+// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj -o %t/arm64.o -emit-compact-unwind-non-canonical=true
 // RUN: llvm-objdump --macho --dwarf=frames %t/arm64.o | FileCheck %s --check-prefix ONE-FDE
-// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind no-compact-unwind -o %t/x86_64-no-dwarf.o
+// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind no-compact-unwind -o %t/x86_64-no-dwarf.o -emit-compact-unwind-non-canonical=true
 // RUN: llvm-objdump --macho --dwarf=frames %t/x86_64-no-dwarf.o | FileCheck %s --check-prefix ONE-FDE
-// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind always -o %t/arm64-dwarf.o
+// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind always -o %t/arm64-dwarf.o -emit-compact-unwind-non-canonical=true
 // RUN: llvm-objdump --macho --dwarf=frames %t/arm64-dwarf.o | FileCheck %s --check-prefix TWO-FDES
 
 // TWO-FDES: FDE
Index: llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
===
--- llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
+++ llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s

[PATCH] D150875: Make dereferencing a void* a hard-error instead of warn-as-error

2023-05-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D150875#4353384 , @erichkeane 
wrote:

> We are the only of the major compilers with this "extension" (I hesitate to 
> call it that, as I'm not sure this FITS in the 'extension's permitted by 
> standard)

I'm not objecting to removing this extension, but... do you have reason to 
doubt that it's conforming, or just a lack of confidence that it is? (If the 
`SFINAEFailure` change wasn't enough, then it's not clear to me why this change 
would be. We use a `SFINAEFailure` diagnostic for other extensions, and if 
that's not sufficient for conformance then we probably have a lot of 
conformance gaps of this kind.)




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6985
+def err_typecheck_indirection_through_void_pointer_cpp
+: Error<"ISO C++ does not allow indirection on operand of type %0">;
 def warn_indirection_through_null : Warning<

We normally only use this "ISO C++ does not allow" phrasing for extensions 
(with the implication being that ISO C++ doesn't allow it, but Clang does). Can 
you rephrase the diagnostic too, to remove those unnecessary words?


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

https://reviews.llvm.org/D150875

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


[PATCH] D150473: [clang/Driver] Also consider `gnu++` standard when checking for modules support

2023-05-18 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added a comment.

Ping 🙏


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150473

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


[PATCH] D150872: [clang-tidy] Add support for new TODO style to google-readability-todo

2023-05-18 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 523440.
ymandel added a comment.

Address reviewer comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150872

Files:
  clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp
  clang-tools-extra/clang-tidy/google/TodoCommentCheck.h
  clang-tools-extra/docs/clang-tidy/checks/google/readability-todo.rst
  clang-tools-extra/test/clang-tidy/checkers/google/readability-todo-v2.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/google/readability-todo-v2.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/google/readability-todo-v2.cpp
@@ -0,0 +1,33 @@
+// RUN: %check_clang_tidy %s google-readability-todo %t -- \
+// RUN: -config="{User: 'some user', CheckOptions: \
+// RUN:   [{key: google-readability-todo.UseV2Style, \
+// RUN: value: 'true'}]}" \
+// RUN: --
+
+//   TODOfix this1
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: TODO requires link and description
+
+//   TODO fix this2
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: TODO requires link and description
+
+// TODO fix this3
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: TODO requires link and description
+
+// TODO: fix this4
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: TODO requires link and description
+
+// V2-style TODO comments:
+
+// TODO: https://github.com/llvm/llvm-project/issues/12345 - Some description
+// TODO: link - description
+
+// V1-style TODO comments, supported for backwards compatability:
+
+//   TODO(clang)fix this5
+
+// TODO(foo):shave yaks
+// TODO(bar):
+// TODO(foo): paint bikeshed
+// TODO(b/12345): find the holy grail
+// TODO (b/12345): allow spaces before parentheses
+// TODO(asdf) allow missing semicolon
Index: clang-tools-extra/docs/clang-tidy/checks/google/readability-todo.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/google/readability-todo.rst
+++ clang-tools-extra/docs/clang-tidy/checks/google/readability-todo.rst
@@ -3,9 +3,32 @@
 google-readability-todo
 ===
 
-Finds TODO comments without a username or bug number.
+Finds TODO comments not conforming to Google's style guidelines.
 
 The relevant style guide section is
 https://google.github.io/styleguide/cppguide.html#TODO_Comments.
 
 Corresponding cpplint.py check: `readability/todo`
+
+Options
+---
+
+.. option:: UseV2Style
+
+   Disabled by default.
+
+   When disabled, the check enforces the style
+   ```
+   // TODO(username/bug): description
+   ```
+   and will suggest fixes in this style, where possible (for example, a TODO
+   missing the username).
+   
+   When enabled, the check also accepts TODO comments in the following style:
+   ```
+   // TODO: link - description
+   ```   
+   It will still admit the previous style, for backwards compatability. But, it
+   won't suggest fixes, since mistakes are now ambiguous: given `TODO: text`, "text"
+   could be the description or it could be a link of some form.
+
Index: clang-tools-extra/clang-tidy/google/TodoCommentCheck.h
===
--- clang-tools-extra/clang-tidy/google/TodoCommentCheck.h
+++ clang-tools-extra/clang-tidy/google/TodoCommentCheck.h
@@ -27,8 +27,13 @@
   void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
Preprocessor *ModuleExpanderPP) override;
 
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override {
+Options.store(Opts, "UseV2Style", UseV2Style);
+  }
+
 private:
   class TodoCommentHandler;
+  bool UseV2Style;
   std::unique_ptr Handler;
 };
 
Index: clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp
===
--- clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp
+++ clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp
@@ -7,51 +7,97 @@
 //===--===//
 
 #include "TodoCommentCheck.h"
+#include "clang/Basic/Diagnostic.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/Preprocessor.h"
+#include "llvm/Support/ErrorHandling.h"
 #include 
 
 namespace clang::tidy::google::readability {
 
+enum class TodoStyleVersion {
+  V1,
+  V2,
+};
+
+std::string_view getVersionRegex(TodoStyleVersion V) {
+  switch (V) {
+  case TodoStyleVersion::V1:
+return "^// *TODO *(\\(.*\\))?:?( )?(.*)$";
+  case TodoStyleVersion::V2:
+return "^// *TODO *((: *[^ ]+( - .)?)|([(][^)]*[)])?).*$";
+  }
+  llvm_unreachable("bad enum value");
+}
+
 class TodoCommentCheck::TodoCommentHandler : public CommentHandler {
 public:
-  TodoCommentHandler(TodoCommentCheck &Check, std::optional User)
-  : Check(Check), User(User ? *User : "unknown"),
-TodoMatch("^// *TODO *(\\(.*\\))?:?( )?(.*)$") {}
+  TodoCommentHandler(TodoCommentC

[PATCH] D150872: [clang-tidy] Add support for new TODO style to google-readability-todo

2023-05-18 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 3 inline comments as done.
ymandel added a comment.

Thank you for the very fast review!




Comment at: clang-tools-extra/clang-tidy/google/TodoCommentCheck.cpp:97
 : ClangTidyCheck(Name, Context),
+  UseV2Style(Options.getLocalOrGlobal("UseV2Style", false)),
   Handler(std::make_unique(

njames93 wrote:
> Given this check is part of the google module, doesn't it make sense to have 
> the default as what google now recommends.
The style guide hasn't been updated yet. Once that happens, I think we should 
switch the default. I can add a FIXME -- what do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150872

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


[PATCH] D150875: Make dereferencing a void* a hard-error instead of warn-as-error

2023-05-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.



In D150875#4353535 , @rsmith wrote:

> In D150875#4353384 , @erichkeane 
> wrote:
>
>> We are the only of the major compilers with this "extension" (I hesitate to 
>> call it that, as I'm not sure this FITS in the 'extension's permitted by 
>> standard)
>
> I'm not objecting to removing this extension, but... do you have reason to 
> doubt that it's conforming, or just a lack of confidence that it is? (If the 
> `SFINAEFailure` change wasn't enough, then it's not clear to me why this 
> change would be. We use a `SFINAEFailure` diagnostic for other extensions, 
> and if that's not sufficient for conformance then we probably have a lot of 
> conformance gaps of this kind.)

No, just lack of confidence.  I guess if it is supposed to be ill-formed, we 
can permit it (except in SFINAE?), right?  The intent here is mostly just for 
'cleanup' as we see it.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6985
+def err_typecheck_indirection_through_void_pointer_cpp
+: Error<"ISO C++ does not allow indirection on operand of type %0">;
 def warn_indirection_through_null : Warning<

rsmith wrote:
> We normally only use this "ISO C++ does not allow" phrasing for extensions 
> (with the implication being that ISO C++ doesn't allow it, but Clang does). 
> Can you rephrase the diagnostic too, to remove those unnecessary words?
I definitely can.  Though, I wonder if we can just use the 
err_typecheck_indirection_requires_pointer above instead and remove this 
diagnostic?  We might need to change that to `indirection requires non-void 
pointer operand (%0 invalid)`.  WDYT?


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

https://reviews.llvm.org/D150875

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


[PATCH] D147731: [3/11][POC][Clang][RISCV] Add typedef of the tuple type and define tuple type variant of vlseg2e32

2023-05-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:1528
+
+  unsigned Offset = IsMasked ? 1 : 0;
+  llvm::Value *MaskOperand = IsMasked ? Ops[0] : nullptr;

I don't think we need the `Value *` variables here. They're only benefit is 
naming, but I think we can do that with comments.

Something like this

```
unsigned Offset = IsMasked ? 1 : 0;
Operands.push_back(Ops[Offset]); // Pointer
if (IsMasked)
  Operands.push_back(Ops[0]); // Mask
Operands.push_back(Ops[Offset + 1]); // VL
```



Comment at: clang/lib/AST/ASTContext.cpp:4090
+unsigned NumElts,
+unsigned NumFields) const {
+  if (Target->hasRISCVVTypes()) {

Would it be possible to add NumFields to getScalableVectorType maybe with a 
default value of 1 instead of introducing a new function?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147731

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


[PATCH] D146873: [2/11][POC][Clang][RISCV] Define RVV tuple types

2023-05-18 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:3135
   STy->getNumElements() > 1) {
-uint64_t SrcSize = CGM.getDataLayout().getTypeAllocSize(STy);
-llvm::Type *DstTy = Ptr.getElementType();
-uint64_t DstSize = CGM.getDataLayout().getTypeAllocSize(DstTy);
+if (STy->containsScalableVectorType()) {
+  assert(STy->containsHomogeneousScalableVectorTypes() &&

craig.topper wrote:
> Can we call `CGM.getDataLayout().getTypeAllocSize(STy)` and check if the 
> TypeSize returned isScalable instead of calling containsScalableVectorType?
Switched to using `CGM.getDataLayout().getTypeAllocSize(STy)`, though calling 
`containsScalableVectorType` won't cost too much because the function has 
memoization.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146873

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


[PATCH] D146873: [2/11][POC][Clang][RISCV] Define RVV tuple types

2023-05-18 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 523446.
eopXD marked 2 inline comments as done.
eopXD added a comment.

Address comments from Craig.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146873

Files:
  clang/include/clang/Basic/RISCVVTypes.def
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type.c
  clang/test/Sema/riscv-types.c

Index: clang/test/Sema/riscv-types.c
===
--- clang/test/Sema/riscv-types.c
+++ clang/test/Sema/riscv-types.c
@@ -133,6 +133,9 @@
 
   // CHECK: __rvv_int8mf2_t x43;
   __rvv_int8mf2_t x43;
+
+  // CHECK: __rvv_int32m1x2_t x44;
+  __rvv_int32m1x2_t x44;
 }
 
 typedef __rvv_bool4_t vbool4_t;
Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type.c
@@ -0,0 +1,90 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zve32x -O0 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=O0
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zve32x -disable-O0-optnone \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | FileCheck %s --check-prefix=AFTER_MEM2REG
+
+
+#include 
+
+// Declare local variable
+// O0-LABEL: define dso_local void @foo
+// O0-SAME: () #[[ATTR0:[0-9]+]] {
+// O0-NEXT:  entry:
+// O0-NEXT:[[V_TUPLE:%.*]] = alloca { ,  }, align 4
+// O0-NEXT:ret void
+//
+// AFTER_MEM2REG-LABEL: define dso_local void @foo
+// AFTER_MEM2REG-SAME: () #[[ATTR0:[0-9]+]] {
+// AFTER_MEM2REG-NEXT:  entry:
+// AFTER_MEM2REG-NEXT:ret void
+//
+void foo() {
+  __rvv_int32m1x2_t v_tuple;
+}
+
+// Declare local variable and return
+// O0-LABEL: define dso_local { ,  } @bar
+// O0-SAME: () #[[ATTR0]] {
+// O0-NEXT:  entry:
+// O0-NEXT:[[V_TUPLE:%.*]] = alloca { ,  }, align 4
+// O0-NEXT:[[TMP0:%.*]] = load { ,  }, ptr [[V_TUPLE]], align 4
+// O0-NEXT:ret { ,  } [[TMP0]]
+//
+// AFTER_MEM2REG-LABEL: define dso_local { ,  } @bar
+// AFTER_MEM2REG-SAME: () #[[ATTR0]] {
+// AFTER_MEM2REG-NEXT:  entry:
+// AFTER_MEM2REG-NEXT:ret { ,  } undef
+//
+__rvv_int32m1x2_t bar() {
+  __rvv_int32m1x2_t v_tuple;
+  return v_tuple;
+}
+
+// Pass as function parameter
+// O0-LABEL: define dso_local void @baz
+// O0-SAME: ( [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] {
+// O0-NEXT:  entry:
+// O0-NEXT:[[V_TUPLE:%.*]] = alloca { ,  }, align 4
+// O0-NEXT:[[V_TUPLE_ADDR:%.*]] = alloca { ,  }, align 4
+// O0-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// O0-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// O0-NEXT:store { ,  } [[TMP1]], ptr [[V_TUPLE]], align 4
+// O0-NEXT:[[V_TUPLE1:%.*]] = load { ,  }, ptr [[V_TUPLE]], align 4
+// O0-NEXT:store { ,  } [[V_TUPLE1]], ptr [[V_TUPLE_ADDR]], align 4
+// O0-NEXT:ret void
+//
+// AFTER_MEM2REG-LABEL: define dso_local void @baz
+// AFTER_MEM2REG-SAME: ( [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] {
+// AFTER_MEM2REG-NEXT:  entry:
+// AFTER_MEM2REG-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// AFTER_MEM2REG-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// AFTER_MEM2REG-NEXT:ret void
+//
+void baz(__rvv_int32m1x2_t v_tuple) {
+}
+
+// Pass as function parameter and return
+// O0-LABEL: define dso_local { ,  } @qux
+// O0-SAME: ( [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] {
+// O0-NEXT:  entry:
+// O0-NEXT:[[V_TUPLE:%.*]] = alloca { ,  }, align 4
+// O0-NEXT:[[V_TUPLE_ADDR:%.*]] = alloca { ,  }, align 4
+// O0-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// O0-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// O0-NEXT:store { ,  } [[TMP1]], ptr [[V_TUPLE]], align 4
+// O0-NEXT:[[V_TUPLE1:%.*]] = load { ,  }, ptr [[V_TUPLE]], align 4
+// O0-NEXT:store { ,  } [[V_TUPLE1]], ptr [[V_TUPLE_ADDR]], align 4
+// O0-NEXT:[[TMP2:%.*]] = load { ,  }, ptr [[V_TUPLE_ADDR]], align 4
+// O0-NEXT:ret { ,  } [[TMP2]]
+//
+// AFTER_MEM2REG-LABEL: define dso_local { ,  } @qux
+// AFTER_MEM2REG-SAME: ( [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] {
+// AFTER_MEM2REG-NEXT:  entry:
+// AFTER_MEM2REG-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// AFTER_MEM2REG-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// AFTER_MEM2REG-NEXT:ret { ,  } [[TMP1]]
+//
+__rvv_int32m1x2_t qux(__rvv_int32m1x2_t v_tuple) {
+  return v_tuple;
+}
Index: clang/lib/CodeGen/CodeGenTypes.cpp

[PATCH] D147774: [4/11][POC][Clang][RISCV] Define tuple type variant of vsseg2e32

2023-05-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:1575
+  unsigned Offset = IsMasked ? 1 : 0;
+  llvm::Value *MaskOperand = IsMasked ? Ops[0] : nullptr;
+  llvm::Value *PtrOperand = Ops[Offset];

Similar comment to patch 3. We can index the Ops array directly in the 
push_back calls instead of having temporary variables.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147774

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


[PATCH] D147911: [5/11][POC][Clang][RISCV] Define tuple type variant of vlseg2e32ff

2023-05-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:1635
+  Operands.push_back(PtrOperand);
+  if (MaskOperand)
+Operands.push_back(MaskOperand);

Same comment as previous patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147911

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


[PATCH] D147912: [6/11][POC][Clang][RISCV] Define tuple type variant of vlsseg2e32

2023-05-18 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:1693
+  unsigned Offset = IsMasked ? 1 : 0;
+  llvm::Value *MaskOperand = IsMasked ? Ops[0] : nullptr;
+  llvm::Value *PtrOperand = IsMasked ? Ops[1] : Ops[0];

Same comment as previous patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147912

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


[PATCH] D149276: [Clang] Fix parsing of `(auto(x))`.

2023-05-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseTentative.cpp:2178-2182
+// When parsing an identifier after an arrow
+// it may be a member expression, in which case we
+// should not annotate it as an independant expression
+// so we just lookup that name, if it's not a type
+// the construct is not a function declaration

This comment looks like it can be re-flowed to 80 columns instead of shortened 
like this.



Comment at: clang/lib/Parse/ParseTentative.cpp:2185-2187
+  Token Next = NextToken();
+  if (NextToken().is(tok::coloncolon))
+return false;

Something smells off here -- `NextToken()` is a peek; were you trying to 
advance the tokens stream? If not, then `Next.is(...)` would be more clear.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149276

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


[PATCH] D148665: Change -fsanitize=function to place two words before the function entry

2023-05-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Ping:)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148665

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


[PATCH] D150817: Use windows baskslash on anonymous tag locations if using MSVCFormatting and it's not absolute path.

2023-05-18 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150817

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


[PATCH] D150875: Make dereferencing a void* a hard-error instead of warn-as-error

2023-05-18 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Ok, so I was curious why this was an extension.  This is the original patch: 
https://github.com/llvm/llvm-project/commit/80877c228d019e9cdca6295f3197867cc86e1720
 where @rsmith mentions there is no good reason for this limitation, then 
mentions a core issue having been filed.  I found CWG1923 
(https://open-std.org/JTC1/SC22/WG21/docs/cwg_closed.html#1923), which is said 
issue.  The resolution is "Needs an EWG Paper", which seems to be the end of 
the line, as I see no such paper?


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

https://reviews.llvm.org/D150875

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


[PATCH] D150887: [clang] Convert a few tests to opaque pointers

2023-05-18 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: clang/test/CodeGenCXX/const-init-cxx11.cpp:353
   };
-  // CHECK: @_ZN14VirtualMembersL13sGlobalMemoryE = internal global { i8** } { 
i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* 
@_ZTVN14VirtualMembers12nsMemoryImplE, i32 0, inrange i32 0, i32 2) }
+  // CHECK: @_ZN14VirtualMembersL13sGlobalMemoryE = internal global 
%"struct.VirtualMembers::nsMemoryImpl" { ptr getelementptr inbounds ({ [3 x 
ptr] }, ptr @_ZTVN14VirtualMembers12nsMemoryImplE, i32 0, inrange i32 0, i32 2) 
}
   __attribute__((used))

This was one suspicious change. An anonymous struct became named.




Comment at: clang/test/CodeGenCXX/constructor-destructor-return-this.cpp:156
+// CHECKMS-LABEL: define dso_local x86_thiscallcc noundef ptr 
@"??0D@@QAE@XZ"(ptr {{[^,]*}} returned{{[^,]*}} %this, i32 noundef 
%is_most_derived)
+// CHECKMS-LABEL: define dso_local x86_thiscallcc void 
@"??1D@@UAE@XZ"(ptr{{[^,]*}} %this)
 

The parameter has changed its name for some reason.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150887

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


[PATCH] D146054: [RISCV] Add --print-supported-extensions support

2023-05-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Please also mark resolved comments as done, otherwise reviewers can presume 
that some comments are unresolved and don't necessarily give another round of 
reviews.




Comment at: clang/test/Driver/print-supported-extensions.c:6
+// RUN: %clang --target=riscv64 --print-supported-extensions 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK-RISCV
+

Use `--implicit-check-not=warning:` instead of `// CHECK-NOT: warning: argument 
unused during compilation`.

We additionally check that there is no warning and the warning doesn't come 
after the output from `--print-supported-extensions`.



Comment at: clang/test/Driver/print-supported-extensions.c:6
+// RUN: %clang --target=riscv64 --print-supported-extensions 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK-RISCV
+

MaskRay wrote:
> Use `--implicit-check-not=warning:` instead of `// CHECK-NOT: warning: 
> argument unused during compilation`.
> 
> We additionally check that there is no warning and the warning doesn't come 
> after the output from `--print-supported-extensions`.
For a file with just one prefix, conventionally we just use the default `CHECK` 
and omit `--check-prefix`.

Have you ever checked that the test detects issues? `CHECK` below are ignored 
with `--check-prefix=CHECK-RISCV`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146054

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


  1   2   3   >