[clang] 9652eba - [clang] Modernize SourceLocation (NFC)

2023-05-25 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-05-25T22:56:08-07:00
New Revision: 9652eba3cfe004cce533445b7e8aedf96451cc6c

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

LOG: [clang] Modernize SourceLocation (NFC)

Added: 


Modified: 
clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h

Removed: 




diff  --git a/clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h 
b/clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h
index 3f6f364d65052..960d59a747fc4 100644
--- a/clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h
+++ b/clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h
@@ -28,9 +28,9 @@ namespace ast_matchers {
 namespace dynamic {
 
 struct SourceLocation {
-  SourceLocation() : Line(), Column() {}
-  unsigned Line;
-  unsigned Column;
+  SourceLocation() = default;
+  unsigned Line = 0;
+  unsigned Column = 0;
 };
 
 struct SourceRange {



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


[clang-tools-extra] 8683b2f - [clang-tody] Fix typos in documentation

2023-05-25 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-05-25T22:56:06-07:00
New Revision: 8683b2f1a9a1cb899345452dba097dd1d37efd17

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

LOG: [clang-tody] Fix typos in documentation

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/signal-handler.rst

clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/prefer-member-initializer.rst

Removed: 




diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/signal-handler.rst 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/signal-handler.rst
index 8a11924c465dd..658b6555f1a1c 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/signal-handler.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/signal-handler.rst
@@ -20,7 +20,7 @@ Checked signal handler rules for up to and including C++14:
 
 The check is disabled on C++17 and later.
 
-Asnychronous-safety is determined by comparing the function's name against a 
set
+Asynchronous-safety is determined by comparing the function's name against a 
set
 of known functions. In addition, the function must come from a system header
 include and in a global namespace. The (possible) arguments passed to the
 function are not checked. Any function that cannot be determined to be

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/prefer-member-initializer.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/prefer-member-initializer.rst
index 803cdbd64edb8..738b6736e 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/prefer-member-initializer.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/prefer-member-initializer.rst
@@ -28,7 +28,7 @@ see check `modernize-use-default-member-init 
<../modernize/use-default-member-in
   Enforcement of rule C.48 in this check is deprecated, to be removed in
   :program:`clang-tidy` version 19 (only C.49 will be enforced by this check 
then).
   Please use `cppcoreguidelines-use-default-member-init 
<../cppcoreguidelines/use-default-member-init.html>`_
-  to enfoce rule C.48.
+  to enforce rule C.48.
 
 Example 1
 -



___
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-25 Thread Vikram Hegde via Phabricator via cfe-commits
vikramRH updated this revision to Diff 525946.
vikramRH added a comment.

rebase and ping, apologies for the short frequency.


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,9 @@
 #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"
+#include "llvm/Support/MathExtras.h"
 
 using namespace llvm;
 
@@ -179,11 +182,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> , Value *Fmt) {
-  StringRef Str;
-  if (!getConstantStringInfo(Fmt, Str) || Str.empty())
-return;
-
+static void locateCStrings(SparseBitVector<8> , StringRef Str) {
   static const char ConvSpecifiers[] = "diouxXfFeEgGaAcspn";
   size_t SpecPos = 0;
   // Skip the first argument, the format string.
@@ -207,14 +206,298 @@
   }
 }
 
-Value *llvm::emitAMDGPUPrintfCall(IRBuilder<> ,
-  ArrayRef Args) {
+// helper struct to package the string related data
+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) {}
+};
+
+// 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<> , ArrayRef , Value *Fmt,
+bool isConstFmtStr, SparseBitVector<8> ,
+SmallVectorImpl , Value *) {
+  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 = alignTo(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 printf_alloc function
+  AttributeList Attr = AttributeList::get(
+  Builder.getContext(), AttributeList::FunctionIndex, Attribute::NoUnwind);
+
+  Type *Tys_alloc[1] = 

[PATCH] D151509: [Driver][X86] Reject unsupported value for -mabi=

2023-05-25 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: clang/test/Driver/x86-mabi.c:6
+
+// CHECK-NOT: {{error|warning}}:
+// ERR: error: unsupported option '-mabi=' for target '{{.*}}'

MaskRay wrote:
> pengfei wrote:
> > What's the expected result for e.g. `x86_64-pc-windows-gnu/mingw/cygnus` ?
> They use `-mabi=ms`, but I feel it's excessive to test all combinations.
> (I think `*windows-cygnus` triples are likely dead.)
Agreed, just want to double confirm it. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151509

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


[PATCH] D151325: [analyzer] Differentiate lifetime extended temporaries

2023-05-25 Thread Tomasz Kamiński via Phabricator via cfe-commits
tomasz-kaminski-sonarsource added a comment.

In D151325#4374326 , @NoQ wrote:

> I totally support this! There's no reason why the region wouldn't carry such 
> information.
>
> This patch is surprisingly tiny, but this matches my grep observations: 
> almost nothing in the static analyzer treats `CXXTempObjectRegion` specially. 
> Even in case of live symbols/regions analysis, it simply relies on how 
> temporary region is bound in the Store to the lifetime-extending reference, 
> so it doesn't need to be handled explicitly.

Indeed. However, I think that this could be a side product of 
`CXXTempObjectRegion` not representing actual short lived temporaries.

> I see that there's no change in `MoveChecker` which treats 
> `CXXTempObjectRegion` specially, and I suspect it may start emitting more 
> warnings after this patch, but I'm not sure if it's a good thing or a bad 
> thing. Could be worth experimenting (eg. by analyzing LLVM itself, it has 
> enough move semantics to demonstrate potential problems).

I have performed our internal test, which includes LLVM, and it has no changes 
in the results due to this patch. 
For the `MoveChecker`, after inspecting the code I believe that we should 
exclude only `CXXTempObjectsRegions` from that checker, as it is certainly 
possible to perform operations on moved from lifetime extended object.

> Do you have any preferences on creating a common base class for 
> `CXXTempObjectRegion` and `CXXLifetimeExtendedObjectRegion`? Or, as an 
> opposite extreme, simply add a nullable `ExD` field to `CXXTempObjectRegion` 
> instead of making a new class? Both could save us some code when these 
> regions do need to be treated uniformly, but it doesn't look like a popular 
> situation to worry about.

Despite them, both being referred to as temporary, they are very different in 
nature. Thus I believe they should be considered separately by each checker, 
thus I prefer them to not be related. This is why I skipped `Temp` word in the 
name of the region.
If any, I would group them with `VarRegion`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151325

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


[PATCH] D151344: Reland "[CMake] Bumps minimum version to 3.20.0.

2023-05-25 Thread H. Vetinari via Phabricator via cfe-commits
h-vetinari added inline comments.



Comment at: libunwind/src/CMakeLists.txt:28-35
 
 # See add_asm_sources() in compiler-rt for explanation of this workaround.
 # CMake doesn't work correctly with assembly on AIX. Workaround by compiling
 # as C files as well.
 if((APPLE AND CMAKE_VERSION VERSION_LESS 3.19) OR
-   (MINGW AND CMAKE_VERSION VERSION_LESS 3.17) OR
-   (${CMAKE_SYSTEM_NAME} MATCHES "AIX"))
+   (MINGW AND CMAKE_VERSION VERSION_LESS 3.17))
   set_source_files_properties(${LIBUNWIND_ASM_SOURCES} PROPERTIES LANGUAGE C)

mstorsjo wrote:
> h-vetinari wrote:
> > Shouldn't it be possible to remove that entire block (as it only fires for 
> > CMake <3.20)?
> The intention was to do such cleanups in a later patch, as mentioned in the 
> original commit message in https://reviews.llvm.org/D144509. (I guess it 
> would be good to bring the original commit message along with the reland 
> attempts too.)
Well sure, but "workarounds" is a broad term. It makes sense to not try to 
clean up everything that newer CMake enables, but this PR does remove a lot of 
(all?) other lines with `CMAKE_VERSION VERSION_LESS ` where x<3.20. On top 
of that, since this line is already being changed (which is why I noticed in 
the first place), I'd suggest to just remove it. But I don't feel strongly 
about this, just thought I'd point it out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151344

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


[PATCH] D151509: [Driver][X86] Reject unsupported value for -mabi=

2023-05-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/x86-mabi.c:6
+
+// CHECK-NOT: {{error|warning}}:
+// ERR: error: unsupported option '-mabi=' for target '{{.*}}'

pengfei wrote:
> What's the expected result for e.g. `x86_64-pc-windows-gnu/mingw/cygnus` ?
They use `-mabi=ms`, but I feel it's excessive to test all combinations.
(I think `*windows-cygnus` triples are likely dead.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151509

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


[PATCH] D151060: [Clang][Sema] Generate vector vs scalar builtin overloads

2023-05-25 Thread Cassie Jones via Phabricator via cfe-commits
porglezomp added a comment.

Confirming your sense that those loops look a bit suspicious, I've found that 
this makes some implicit conversions ambiguous.
Put a test case up for that at D151532 , I 
think I understand what those loops should be changed to instead, so I'll 
update when I have something passing this new test as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151060

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


[PATCH] D151383: [clang-tidy] Check for specific return types on all functions

2023-05-25 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:398
 
+
 Removed checks

Excessive newline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151383

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


[PATCH] D151532: [test] Test ext_vector_type operators with implicit conversions

2023-05-25 Thread Cassie Jones via Phabricator via cfe-commits
porglezomp created this revision.
porglezomp added reviewers: aaron.ballman, fhahn.
Herald added a subscriber: StephenFan.
Herald added a project: All.
porglezomp requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

An extra test for implicit conversion issues discovered while testing D151060 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151532

Files:
  clang/test/SemaCXX/vector.cpp


Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -772,3 +772,27 @@
 }
 #endif
 }
+
+namespace {
+// Test ext_vector_type builtin operators in the presence of implicit 
conversions
+
+typedef int __attribute__((ext_vector_type(4))) vec4i;
+
+struct simd4i {
+vec4i x;
+
+simd4i(const vec4i& val): x(val) {}
+operator vec4i() const { return x; }
+};
+
+simd4i operator| (const simd4i& lhs, const simd4i& rhs) { return vec4i(lhs) | 
vec4i(rhs); }
+simd4i& operator|= (simd4i& lhs, const simd4i& rhs) { return lhs = lhs | rhs; }
+
+simd4i test1(simd4i a, vec4i b) {
+return a |= b;
+}
+
+simd4i test2(simd4i a, vec4i b) {
+return a | b;
+}
+}


Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -772,3 +772,27 @@
 }
 #endif
 }
+
+namespace {
+// Test ext_vector_type builtin operators in the presence of implicit conversions
+
+typedef int __attribute__((ext_vector_type(4))) vec4i;
+
+struct simd4i {
+vec4i x;
+
+simd4i(const vec4i& val): x(val) {}
+operator vec4i() const { return x; }
+};
+
+simd4i operator| (const simd4i& lhs, const simd4i& rhs) { return vec4i(lhs) | vec4i(rhs); }
+simd4i& operator|= (simd4i& lhs, const simd4i& rhs) { return lhs = lhs | rhs; }
+
+simd4i test1(simd4i a, vec4i b) {
+return a |= b;
+}
+
+simd4i test2(simd4i a, vec4i b) {
+return a | b;
+}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151344: Reland "[CMake] Bumps minimum version to 3.20.0.

2023-05-25 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: libunwind/src/CMakeLists.txt:28-35
 
 # See add_asm_sources() in compiler-rt for explanation of this workaround.
 # CMake doesn't work correctly with assembly on AIX. Workaround by compiling
 # as C files as well.
 if((APPLE AND CMAKE_VERSION VERSION_LESS 3.19) OR
-   (MINGW AND CMAKE_VERSION VERSION_LESS 3.17) OR
-   (${CMAKE_SYSTEM_NAME} MATCHES "AIX"))
+   (MINGW AND CMAKE_VERSION VERSION_LESS 3.17))
   set_source_files_properties(${LIBUNWIND_ASM_SOURCES} PROPERTIES LANGUAGE C)

h-vetinari wrote:
> Shouldn't it be possible to remove that entire block (as it only fires for 
> CMake <3.20)?
The intention was to do such cleanups in a later patch, as mentioned in the 
original commit message in https://reviews.llvm.org/D144509. (I guess it would 
be good to bring the original commit message along with the reland attempts 
too.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151344

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


[PATCH] D151509: [Driver][X86] Reject unsupported value for -mabi=

2023-05-25 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/test/Driver/x86-mabi.c:6
+
+// CHECK-NOT: {{error|warning}}:
+// ERR: error: unsupported option '-mabi=' for target '{{.*}}'

What's the expected result for e.g. `x86_64-pc-windows-gnu/mingw/cygnus` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151509

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


[PATCH] D151190: [clangd] Do not end inactiveRegions range at position 0 of line

2023-05-25 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz added inline comments.



Comment at: clang-tools-extra/clangd/unittests/ClangdTests.cpp:1343
 #undef CMDMACRO
 $inactive3[[#ifdef CMDMACRO
   int inactiveInt2;

hokein wrote:
> While this patch is an improvement, I wonder we should move it further.
> 
> Has been thinking about it more, we seem to have some inconsistent behavior 
> on highlighting the `#if`, `#else`, `#endif` lines:
> 
> - in `$inactive1` case, the `#endif` is marked as inactive (IMO, the 
> highlighting in the editor is confusing, it looks like we're missing a match 
> `endif`, thus I prefer to mark it as active to correspond to the active `#if` 
> branch);
> - in `$inactive3` case, the line `#elif PREAMBLEMACRO > 0` is marked as 
> inactive, this is inconsistent with `$inactive1` case;
> 
> I think it would be nice to have a consistent model. One approach is to 
> always consider `#if`, `#elif`, `#endif`, `#endif` lines active (in the 
> implementation side, this would mean we always use the line range 
> [skipp_range.start.line+1, skipp_range.end.line - 1]).
> 
> What do you think about this?
> 
> 
+1. My perspective is that C++ source code is actually a meta-language 
(preprocessor) that describes generation of C++ language code. That is, `#if`, 
`#else`, `#endif` and .etc are always in a sense "executed" to generate the 
actual code. So they shouldn't be marked as inactive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151190

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


[PATCH] D151429: print user provide value in tabstop diagnostic

2023-05-25 Thread csmoe via Phabricator via cfe-commits
csmoe added a comment.

thanks for your review :)
user: csmoe
email: cs...@msn.com


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151429

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


[PATCH] D151280: [NFC][CLANG] Fix static code analyzer concerns

2023-05-25 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc3e7c6e9e080: [NFC][CLANG] Fix static code analyzer concerns 
(authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151280

Files:
  clang/lib/CodeGen/CGExprConstant.cpp


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1340,6 +1340,7 @@
 std::string Str;
 CGM.getContext().getObjCEncodingForType(E->getEncodedType(), Str);
 const ConstantArrayType *CAT = CGM.getContext().getAsConstantArrayType(T);
+assert(CAT && "String data not of constant array type!");
 
 // Resize the string to the right size, adding zeros at the end, or
 // truncating as needed.


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1340,6 +1340,7 @@
 std::string Str;
 CGM.getContext().getObjCEncodingForType(E->getEncodedType(), Str);
 const ConstantArrayType *CAT = CGM.getContext().getAsConstantArrayType(T);
+assert(CAT && "String data not of constant array type!");
 
 // Resize the string to the right size, adding zeros at the end, or
 // truncating as needed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151383: [clang-tidy] Check for specific return types on all functions

2023-05-25 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav updated this revision to Diff 525926.
chaitanyav marked an inline comment as done.
chaitanyav added a comment.

Use single backticks for options


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151383

Files:
  clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-return-value.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-return-value.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-return-value.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-return-value.cpp
@@ -52,6 +52,9 @@
   bool empty() const noexcept;
 };
 
+class error_code {
+};
+
 // the check should be able to match std lib calls even if the functions are
 // declared inside inline namespaces
 inline namespace v1 {
@@ -72,6 +75,10 @@
 
 void useFuture(const std::future );
 
+std::error_code errorFunc() {
+return std::error_code();
+}
+
 void warning() {
   std::async(increment, 42);
   // CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used
@@ -185,6 +192,10 @@
 // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
 // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
   }
+
+  errorFunc();
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
+  // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
 }
 
 void noWarning() {
@@ -209,6 +220,8 @@
   std::vector VecNoWarning;
   auto VecEmptyRetval = VecNoWarning.empty();
 
+  (void) errorFunc();
+
   // test using the return value in different kinds of expressions
   useFuture(std::async(increment, 42));
   std::launder()->f();
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
@@ -46,5 +46,11 @@
  return value often indicates that the programmer confused the function with
  ``clear()``.
 
+.. option:: CheckedReturnTypes
+
+   Semicolon-separated list of function return types to check.
+   By default the following function return types are checked:
+   `std::error_code, std::expected, boost::system::error_code, abseil::Status`
+
 `cert-err33-c <../cert/err33-c.html>`_ is an alias of this check that checks a
 fixed and large set of standard library functions.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -248,6 +248,10 @@
   constructor initializers. Correctly handle constructor arguments as being
   sequenced when constructor call is written as list-initialization.
 
+- Extend :doc:`bugprone-unused-return-value
+  ` check to check for all functions
+  with specified return types using the ``CheckedReturnTypes`` option.
+
 - Deprecated :doc:`cert-dcl21-cpp
   ` check.
 
@@ -391,6 +395,7 @@
   `: warn on ``const &&``
   constructors.
 
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.h
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.h
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.h
@@ -27,6 +27,7 @@
 
 private:
   std::string CheckedFunctions;
+  std::string CheckedReturnTypes;
 };
 
 } // namespace clang::tidy::bugprone
Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -28,6 +28,17 @@
   Finder, Builder);
 }
 
+// Checks if the function return type is in CheckedReturnedTypes
+AST_MATCHER_P(FunctionDecl, hasAnyReturnType, std::vector,
+  RetTypes) {
+  auto FuncRetType = Node.getReturnType().getAsString();
+  for (const auto RetType : RetTypes) {
+if (RetType == FuncRetType) {
+  return true;
+}
+  }
+  return false;
+}
 } // namespace
 
 UnusedReturnValueCheck::UnusedReturnValueCheck(llvm::StringRef Name,
@@ -124,19 +135,28 @@
"::sigismember;"
"::strcasecmp;"
"::strsignal;"
-   "::ttyname")) {}
+   

[clang] c3e7c6e - [NFC][CLANG] Fix static code analyzer concerns

2023-05-25 Thread via cfe-commits

Author: Manna, Soumi
Date: 2023-05-25T20:00:24-07:00
New Revision: c3e7c6e9e0809e2626253af584c7d7acfc4ce60b

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

LOG: [NFC][CLANG] Fix static code analyzer concerns

Reported by Static Code Analyzer Tool:

Inside "CGExprConstant.cpp" file, VisitObjCEncodeExpr() returns null value 
which is dereferenced without checking.

This patch adds an assert.

Reviewed By: erichkeane

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

Added: 


Modified: 
clang/lib/CodeGen/CGExprConstant.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprConstant.cpp 
b/clang/lib/CodeGen/CGExprConstant.cpp
index 2fb9722ecc7e..b0dd59871584 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1340,6 +1340,7 @@ class ConstExprEmitter :
 std::string Str;
 CGM.getContext().getObjCEncodingForType(E->getEncodedType(), Str);
 const ConstantArrayType *CAT = CGM.getContext().getAsConstantArrayType(T);
+assert(CAT && "String data not of constant array type!");
 
 // Resize the string to the right size, adding zeros at the end, or
 // truncating as needed.



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


[PATCH] D150635: [clangd] Implement end-definition-comment inlay hints

2023-05-25 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz marked an inline comment as done.
daiyousei-qz added a comment.

Addressed the remaining comments. Thanks everyone for helping review and 
improve this patch!




Comment at: clang-tools-extra/clangd/InlayHints.cpp:802
+Position HintStart = sourceLocToPosition(SM, RBraceLoc);
+Position HintEnd = {HintStart.line,
+HintStart.character +

sammccall wrote:
> I'd prefer `sourceLocToPosition(SM, 
> RBraceLoc.getLocationWithOffset(HintRangeText.size()))` which would avoids 
> such low-level conversion between coordinate systems, and seems to perform 
> just fine (we're going to hit SourceManager's caches).
> 
> Will leave this up to you though.
Yeah, this is definitely clearer. Updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150635

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


[PATCH] D150635: [clangd] Implement end-definition-comment inlay hints

2023-05-25 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz updated this revision to Diff 525922.
daiyousei-qz marked 8 inline comments as done.
daiyousei-qz added a comment.

- Address remaining comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150635

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -77,6 +77,7 @@
   C.InlayHints.Parameters = false;
   C.InlayHints.DeducedTypes = false;
   C.InlayHints.Designators = false;
+  C.InlayHints.BlockEnd = false;
   return C;
 }
 
@@ -122,6 +123,15 @@
   assertHints(InlayHintKind::Designator, AnnotatedSource, Expected...);
 }
 
+template 
+void assertBlockEndHints(llvm::StringRef AnnotatedSource,
+ ExpectedHints... Expected) {
+  Config Cfg;
+  Cfg.InlayHints.BlockEnd = true;
+  WithContextValue WithCfg(Config::Key, std::move(Cfg));
+  assertHints(InlayHintKind::BlockEnd, AnnotatedSource, Expected...);
+}
+
 TEST(ParameterHints, Smoke) {
   assertParameterHints(R"cpp(
 void foo(int param);
@@ -1550,6 +1560,194 @@
   ExpectedHint{"a: ", "param1"}, ExpectedHint{"b: ", "param2"},
   ExpectedHint{"c: ", "param3"});
 }
+
+TEST(BlockEndHints, Functions) {
+  assertBlockEndHints(R"cpp(
+int foo() {
+  return 41;
+$foo[[}]]
+
+template 
+int bar() { 
+  // No hint for lambda for now
+  auto f = []() { 
+return X; 
+  };
+  return f(); 
+$bar[[}]]
+
+// No hint because this isn't a definition
+int buz();
+
+struct S{};
+bool operator==(S, S) {
+  return true;
+$opEqual[[}]]
+  )cpp",
+  ExpectedHint{" // foo", "foo"},
+  ExpectedHint{" // bar", "bar"},
+  ExpectedHint{" // operator==", "opEqual"});
+}
+
+TEST(BlockEndHints, Methods) {
+  assertBlockEndHints(R"cpp(
+struct Test {
+  // No hint because there's no function body
+  Test() = default;
+  
+  ~Test() {
+  $dtor[[}]]
+
+  void method1() {
+  $method1[[}]]
+
+  // No hint because this isn't a definition
+  void method2();
+
+  template 
+  void method3() {
+  $method3[[}]]
+
+  // No hint because this isn't a definition
+  template 
+  void method4();
+
+  Test operator+(int) const {
+return *this;
+  $opIdentity[[}]]
+
+  operator bool() const {
+return true;
+  $opBool[[}]]
+
+  // No hint because there's no function body
+  operator int() const = delete;
+} x;
+
+void Test::method2() {
+$method2[[}]]
+
+template 
+void Test::method4() {
+$method4[[}]]
+  )cpp",
+  ExpectedHint{" // ~Test", "dtor"},
+  ExpectedHint{" // method1", "method1"},
+  ExpectedHint{" // method3", "method3"},
+  ExpectedHint{" // operator+", "opIdentity"},
+  ExpectedHint{" // operator bool", "opBool"},
+  ExpectedHint{" // Test::method2", "method2"},
+  ExpectedHint{" // Test::method4", "method4"});
+}
+
+TEST(BlockEndHints, Namespaces) {
+  assertBlockEndHints(
+  R"cpp(
+namespace {
+  void foo();
+$anon[[}]]
+
+namespace ns {
+  void bar();
+$ns[[}]]
+  )cpp",
+  ExpectedHint{" // namespace", "anon"},
+  ExpectedHint{" // namespace ns", "ns"});
+}
+
+TEST(BlockEndHints, Types) {
+  assertBlockEndHints(
+  R"cpp(
+struct S {
+$S[[};]]
+
+class C {
+$C[[};]]
+
+union U {
+$U[[};]]
+
+enum E1 {
+$E1[[};]]
+
+enum class E2 {
+$E2[[};]]
+  )cpp",
+  ExpectedHint{" // struct S", "S"}, ExpectedHint{" // class C", "C"},
+  ExpectedHint{" // union U", "U"}, ExpectedHint{" // enum E1", "E1"},
+  ExpectedHint{" // enum class E2", "E2"});
+}
+
+TEST(BlockEndHints, TrailingSemicolon) {
+  assertBlockEndHints(R"cpp(
+// The hint is placed after the trailing ';'
+struct S1 {
+$S1[[}  ;]]   
+
+// The hint is always placed in the same line with the closing '}'.
+// So in this case where ';' is missing, it is attached to '}'.
+struct S2 {
+$S2[[}]]
+
+;
+
+// No hint because only one trailing ';' is allowed
+struct S3 {
+};;
+
+// No hint because trailing ';' is only allowed for class/struct/union/enum
+void foo() {
+};
+
+// Rare case, but yes we'll have a hint here.
+struct {
+

[PATCH] D150913: [Clang][BFloat16] Upgrade __bf16 to arithmetic type, change mangling, and extend excess precision support.

2023-05-25 Thread M. Zeeshan Siddiqui via Phabricator via cfe-commits
codemzs updated this revision to Diff 525920.
codemzs marked 3 inline comments as done.
codemzs added a comment.

Addresses feedback on extended floating type documentation from @rjmccall and 
@pengfei


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

https://reviews.llvm.org/D150913

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/FPOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/Type.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CodeGen/X86/avx512bf16-error.c
  clang/test/CodeGen/X86/bfloat-mangle.cpp
  clang/test/CodeGen/X86/bfloat16.cpp
  clang/test/CodeGen/X86/fexcess-precision-bfloat16.c
  clang/test/CodeGenCUDA/amdgpu-bf16.cu
  clang/test/CodeGenCUDA/bf16.cu
  clang/test/Driver/fexcess-precision.c
  clang/test/Sema/arm-bf16-forbidden-ops.c
  clang/test/Sema/arm-bf16-forbidden-ops.cpp
  clang/test/Sema/arm-bfloat.cpp
  clang/test/SemaCUDA/amdgpu-bf16.cu
  clang/test/SemaCUDA/bf16.cu

Index: clang/test/SemaCUDA/bf16.cu
===
--- clang/test/SemaCUDA/bf16.cu
+++ clang/test/SemaCUDA/bf16.cu
@@ -2,32 +2,32 @@
 // REQUIRES: x86-registered-target
 
 // RUN: %clang_cc1 "-triple" "x86_64-unknown-linux-gnu" "-aux-triple" "nvptx64-nvidia-cuda" \
-// RUN:"-target-cpu" "x86-64" -fsyntax-only -verify=scalar %s
+// RUN:"-target-cpu" "x86-64" -fsyntax-only -verify=scalar -Wno-unused %s
 // RUN: %clang_cc1 "-aux-triple" "x86_64-unknown-linux-gnu" "-triple" "nvptx64-nvidia-cuda" \
-// RUN:-fcuda-is-device "-aux-target-cpu" "x86-64" -fsyntax-only -verify=scalar %s
+// RUN:-fcuda-is-device "-aux-target-cpu" "x86-64" -fsyntax-only -verify=scalar -Wno-unused %s
 
 #include "Inputs/cuda.h"
 
 __device__ void test(bool b, __bf16 *out, __bf16 in) {
   __bf16 bf16 = in; // No error on using the type itself.
 
-  bf16 + bf16; // scalar-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
-  bf16 - bf16; // scalar-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
-  bf16 * bf16; // scalar-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
-  bf16 / bf16; // scalar-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 + bf16;
+  bf16 - bf16;
+  bf16 * bf16;
+  bf16 / bf16;
 
   __fp16 fp16;
 
-  bf16 + fp16; // scalar-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
-  fp16 + bf16; // scalar-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
-  bf16 - fp16; // scalar-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
-  fp16 - bf16; // scalar-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
-  bf16 * fp16; // scalar-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
-  fp16 * bf16; // scalar-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
-  bf16 / fp16; // scalar-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
-  fp16 / bf16; // scalar-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 + fp16;
+  fp16 + bf16;
+  bf16 - fp16;
+  fp16 - bf16;
+  bf16 * fp16;
+  fp16 * bf16;
+  bf16 / fp16;
+  fp16 / bf16;
   bf16 = fp16; // scalar-error {{assigning to '__bf16' from incompatible type '__fp16'}}
   fp16 = bf16; // scalar-error {{assigning to '__fp16' from incompatible type '__bf16'}}
-  bf16 + (b ? fp16 : bf16); // scalar-error {{incompatible operand types ('__fp16' and '__bf16')}}
+  bf16 + (b ? fp16 : bf16);
   *out = bf16;
 }
Index: clang/test/SemaCUDA/amdgpu-bf16.cu
===
--- clang/test/SemaCUDA/amdgpu-bf16.cu
+++ clang/test/SemaCUDA/amdgpu-bf16.cu
@@ -1,13 +1,8 @@
 // REQUIRES: amdgpu-registered-target
 // REQUIRES: x86-registered-target
 
-// RUN: %clang_cc1 "-triple" "x86_64-unknown-linux-gnu" "-aux-triple" "amdgcn-amd-amdhsa"\
-// RUN:"-target-cpu" "x86-64" -fsyntax-only -verify=amdgcn %s
-// RUN: %clang_cc1 "-aux-triple" "x86_64-unknown-linux-gnu" "-triple" "amdgcn-amd-amdhsa"\
-// RUN:-fcuda-is-device "-aux-target-cpu" "x86-64" -fsyntax-only -verify=amdgcn %s
-
 // RUN: %clang_cc1 "-aux-triple" "x86_64-unknown-linux-gnu" "-triple" "r600-unknown-unknown"\
-// RUN:-fcuda-is-device "-aux-target-cpu" "x86-64" -fsyntax-only -verify=amdgcn,r600 %s
+// RUN:-fcuda-is-device "-aux-target-cpu" "x86-64" -fsyntax-only -verify=r600 %s
 
 // AMDGCN has storage-only support for 

[PATCH] D151529: [NFC][CLANG] Fix nullptr dereference issue in DeduceTemplateArgumentsByTypeMatch()

2023-05-25 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added a reviewer: erichkeane.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

DeduceTemplateArgumentsByTypeMatch() returns null value which is dereferenced 
without checking since  
getAsIncompleteArrayType() returns nullptr and we are dereferencing null 
pointer value for S.Context->getAsIncompleteArrayType(P) when calling 
getElementType().

This patch adds an assert.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151529

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp


Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1703,10 +1703,12 @@
   if (!IAA)
 return Sema::TDK_NonDeducedMismatch;
 
+  const auto *IAP = S.Context.getAsIncompleteArrayType(P);
+  assert(IAP && "Template arguments not of incomplete array type!");
+
   return DeduceTemplateArgumentsByTypeMatch(
-  S, TemplateParams,
-  S.Context.getAsIncompleteArrayType(P)->getElementType(),
-  IAA->getElementType(), Info, Deduced, TDF & TDF_IgnoreQualifiers);
+  S, TemplateParams, IAP->getElementType(), IAA->getElementType(), 
Info,
+  Deduced, TDF & TDF_IgnoreQualifiers);
 }
 
 // T [integer-constant]


Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1703,10 +1703,12 @@
   if (!IAA)
 return Sema::TDK_NonDeducedMismatch;
 
+  const auto *IAP = S.Context.getAsIncompleteArrayType(P);
+  assert(IAP && "Template arguments not of incomplete array type!");
+
   return DeduceTemplateArgumentsByTypeMatch(
-  S, TemplateParams,
-  S.Context.getAsIncompleteArrayType(P)->getElementType(),
-  IAA->getElementType(), Info, Deduced, TDF & TDF_IgnoreQualifiers);
+  S, TemplateParams, IAP->getElementType(), IAA->getElementType(), Info,
+  Deduced, TDF & TDF_IgnoreQualifiers);
 }
 
 // T [integer-constant]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150930: [Driver] Accept and ignore -fno-lifetime-dse argument

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

In D150930#4356732 , @jhuber6 wrote:

> In D150930#4355240 , @MaskRay wrote:
>
>> Note: for options controlling individual optimization behaviors, there is a 
>> large probability that they may not make sense for Clang since the two 
>> compilers' internals are so different. 
>> Users and projects should learn to not add GCC optimization options for 
>> Clang uses.
>
> If this is the case, can we at least add a CMake option to disable LLVM from 
> enabling this option against the user's will? As it stands 
> https://reviews.llvm.org/rG47f5c54f997a59bb2c65abe6b8b811f6e7553456 
> represents a significant regression in usability. As I understand, the 
> previous patch only had an issue with LTO builds, so it should be perfectly 
> reasonable for users to at least disable this at the LLVM level if they do 
> not with the LLVM build to insert an incompatible flag into their compilation 
> database.

I am fine with the CMake work if someone wants to do it..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150930

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


[PATCH] D150253: [RISCV] Add Zvfhmin extension for clang.

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



Comment at: llvm/lib/Target/RISCV/RISCVSubtarget.h:162
+  bool hasVInstructionsF16Mininal() const {
+return HasStdExtZvfhmin || HasStdExtZvfh;
+  }

jacquesguan wrote:
> craig.topper wrote:
> > michaelmaitland wrote:
> > > michaelmaitland wrote:
> > > > jacquesguan wrote:
> > > > > craig.topper wrote:
> > > > > > Doesn't HasStdExtZvfh already imply HasStdExtZvfhmin?
> > > > > The v spec doesn't metion this.
> > > > I think the spec conveys this when it says `The Zvfhmin extension 
> > > > depends on the Zve32f extension.`
> > > My mistake, that says `Zve32f`, not `Zvfh`. However, the spec does say:
> > > 
> > > `When the Zvfhmin extension is implemented, the vfwcvt.f.f.v and 
> > > vfncvt.f.f.w instructions become defined when SEW=16` and also says `When 
> > > the Zvfh extension is implemented, all instructions in Sections Vector 
> > > Floating-Point Instructions.` Since `vfwcvt.f.f.v and vfncvt.f.f.w` are 
> > > part of `Vector Floating-Point Instructions` section, this is how it is 
> > > implied.
> > It's implemented in LLVM by this patch https://reviews.llvm.org/D150016
> This patch make Zvfh imply **Zfhmin ** not **Zvfhmin**. I think the relation 
> between Zvfh and Zvfhmin is just like the relation between Zfh and Zfhmin. 
> Now Zfh doesn't imply Zfhmin, so I keep Zvfh not imply Zvfhmin.
Oops. Too many extensions with similar names. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150253

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


[PATCH] D150913: [Clang][BFloat16] Upgrade __bf16 to arithmetic type, change mangling, and extend excess precision support.

2023-05-25 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:852
 ``double`` when passed to ``printf``, so the programmer must explicitly cast 
it to
 ``double`` before using it with an ``%f`` or similar specifier.
 

rjmccall wrote:
> codemzs wrote:
> > pengfei wrote:
> > > rjmccall wrote:
> > > > pengfei wrote:
> > > > > rjmccall wrote:
> > > > > > Suggested rework:
> > > > > > 
> > > > > > ```
> > > > > > Clang supports three half-precision (16-bit) floating point types: 
> > > > > > ``__fp16``,
> > > > > > ``_Float16`` and ``__bf16``.  These types are supported in all 
> > > > > > language
> > > > > > modes, but not on all targets:
> > > > > > 
> > > > > > - ``__fp16`` is supported on every target.
> > > > > > 
> > > > > > - ``_Float16`` is currently supported on the following targets:
> > > > > >   * 32-bit ARM (natively on some architecture versions)
> > > > > >   * 64-bit ARM (AArch64) (natively on ARMv8.2a and above)
> > > > > >   * AMDGPU (natively)
> > > > > >   * SPIR (natively)
> > > > > >   * X86 (if SSE2 is available; natively if AVX512-FP16 is also 
> > > > > > available)
> > > > > > 
> > > > > > - ``__bf16`` is currently supported on the following targets:
> > > > > >   * 32-bit ARM
> > > > > >   * 64-bit ARM (AArch64)
> > > > > >   * X86 (when SSE2 is available)
> > > > > > 
> > > > > > (For X86, SSE2 is available on 64-bit and all recent 32-bit 
> > > > > > processors.)
> > > > > > 
> > > > > > ``__fp16`` and ``_Float16`` both use the binary16 format from IEEE
> > > > > > 754-2008, which provides a 5-bit exponent and an 11-bit significand
> > > > > > (counting the implicit leading 1).  ``__bf16`` uses the `bfloat16
> > > > > > `_ 
> > > > > > format,
> > > > > > which provides an 8-bit exponent and an 8-bit significand; this is 
> > > > > > the same
> > > > > > exponent range as `float`, just with greatly reduced precision.
> > > > > > 
> > > > > > ``_Float16`` and ``__bf16`` follow the usual rules for arithmetic
> > > > > > floating-point types.  Most importantly, this means that arithmetic 
> > > > > > operations
> > > > > > on operands of these types are formally performed in the type and 
> > > > > > produce
> > > > > > values of the type.  ``__fp16`` does not follow those rules: most 
> > > > > > operations
> > > > > > immediately promote operands of type ``__fp16`` to ``float``, and so
> > > > > > arithmetic operations are defined to be performed in ``float`` and 
> > > > > > so result in
> > > > > > a value of type ``float`` (unless further promoted because of other 
> > > > > > operands).
> > > > > > See below for more information on the exact specifications of these 
> > > > > > types.
> > > > > > 
> > > > > > Only some of the supported processors for ``__fp16`` and ``__bf16`` 
> > > > > > offer
> > > > > > native hardware support for arithmetic in their corresponding 
> > > > > > formats.
> > > > > > The exact conditions are described in the lists above.  When 
> > > > > > compiling for a
> > > > > > processor without native support, Clang will perform the arithmetic 
> > > > > > in
> > > > > > ``float``, inserting extensions and truncations as necessary.  This 
> > > > > > can be
> > > > > > done in a way that exactly emulates the behavior of hardware 
> > > > > > support for
> > > > > > arithmetic, but it can require many extra operations.  By default, 
> > > > > > Clang takes
> > > > > > advantage of the C standard's allowances for excess precision in 
> > > > > > intermediate
> > > > > > operands in order to eliminate intermediate truncations within 
> > > > > > statements.
> > > > > > This is generally much faster but can generate different results 
> > > > > > from strict
> > > > > > operation-by-operation emulation.
> > > > > > 
> > > > > > The use of excess precision can be independently controlled for 
> > > > > > these two
> > > > > > types with the ``-ffloat16-excess-precision=`` and
> > > > > > ``-fbfloat16-excess-precision=`` options.  Valid values include:
> > > > > > - ``none`` (meaning to perform strict operation-by-operation 
> > > > > > emulation)
> > > > > > - ``standard`` (meaning that excess precision is permitted under 
> > > > > > the rules
> > > > > >   described in the standard, i.e. never across explicit casts or 
> > > > > > statements)
> > > > > > - ``fast`` (meaning that excess precision is permitted whenever the
> > > > > >   optimizer sees an opportunity to avoid truncations; currently 
> > > > > > this has no
> > > > > >   effect beyond ``standard``)
> > > > > > 
> > > > > > The ``_Float16`` type is an interchange floating type specified in
> > > > > >  ISO/IEC TS 18661-3:2015 ("Floating-point extensions for C").  It 
> > > > > > will
> > > > > > be supported on more targets as they define ABIs for it.
> > > > > > 
> > > > > > The ``__bf16`` type is a non-standard extension, but it generally 
> > > > > > follows
> > > > > > the rules 

[PATCH] D141627: [Clang][OpenMP] Fix the issue that list items in `has_device_addr` are still mapped to the target device

2023-05-25 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

`12d840375d5a81e9ce1050354371c550669de2d7` should fix the case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141627

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


[clang] 12d8403 - [Clang] Simplify test `clang/test/OpenMP/bug59160.c`

2023-05-25 Thread Shilei Tian via cfe-commits

Author: Shilei Tian
Date: 2023-05-25T22:12:16-04:00
New Revision: 12d840375d5a81e9ce1050354371c550669de2d7

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

LOG: [Clang] Simplify test `clang/test/OpenMP/bug59160.c`

Added: 


Modified: 
clang/test/OpenMP/bug59160.c

Removed: 




diff  --git a/clang/test/OpenMP/bug59160.c b/clang/test/OpenMP/bug59160.c
index 9a997780cf7a..7790b4bfb285 100644
--- a/clang/test/OpenMP/bug59160.c
+++ b/clang/test/OpenMP/bug59160.c
@@ -1,4 +1,3 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-globals --include-generated-funcs 
--replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" 
--prefix-filecheck-ir-name _
 // RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-version=51 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-version=51 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix 
SIMD-ONLY0 %s
 // expected-no-diagnostics
@@ -15,144 +14,7 @@ void zoo(void) {
 xpp[1][1] = 222;
   }
 }
-//.
-// CHECK: @.offload_sizes = private unnamed_addr constant [2 x i64] [i64 8, 
i64 2]
-// CHECK: @.offload_maptypes = private unnamed_addr constant [2 x i64] [i64 
67, i64 19]
-// CHECK: @0 = private unnamed_addr constant [23 x i8] c"
-// CHECK: @1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, 
i32 0, i32 22, ptr @0 }, align 8
-// CHECK: @.{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_zoo_l13.region_id = weak 
constant i8 0
-// CHECK: @.offload_sizes.1 = private unnamed_addr constant [1 x i64] [i64 8]
-// CHECK: @.offload_maptypes.2 = private unnamed_addr constant [1 x i64] [i64 
288]
-// CHECK: @.omp_offloading.entry_name = internal unnamed_addr constant [37 x 
i8] c"{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_zoo_l13\00"
-// CHECK: 
@.omp_offloading.entry.{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_zoo_l13 = weak 
constant %struct.__tgt_offload_entry { ptr 
@.{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_zoo_l13.region_id, ptr 
@.omp_offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"omp_offloading_entries", align 1
-// CHECK: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ 
i32, ptr, ptr } { i32 0, ptr @.omp_offloading.requires_reg, ptr null }]
-//.
-// CHECK-LABEL: define {{[^@]+}}@zoo
-// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[X:%.*]] = alloca [10 x i16], align 2
-// CHECK-NEXT:[[XP:%.*]] = alloca [10 x ptr], align 8
-// CHECK-NEXT:[[XPP:%.*]] = alloca ptr, align 8
-// CHECK-NEXT:[[DOTOFFLOAD_BASEPTRS:%.*]] = alloca [2 x ptr], align 8
-// CHECK-NEXT:[[DOTOFFLOAD_PTRS:%.*]] = alloca [2 x ptr], align 8
-// CHECK-NEXT:[[DOTOFFLOAD_MAPPERS:%.*]] = alloca [2 x ptr], align 8
-// CHECK-NEXT:[[DOTOFFLOAD_BASEPTRS7:%.*]] = alloca [1 x ptr], align 8
-// CHECK-NEXT:[[DOTOFFLOAD_PTRS8:%.*]] = alloca [1 x ptr], align 8
-// CHECK-NEXT:[[DOTOFFLOAD_MAPPERS9:%.*]] = alloca [1 x ptr], align 8
-// CHECK-NEXT:[[KERNEL_ARGS:%.*]] = alloca 
[[STRUCT___TGT_KERNEL_ARGUMENTS:%.*]], align 8
-// CHECK-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds [10 x i16], ptr 
[[X]], i64 0, i64 0
-// CHECK-NEXT:[[ARRAYIDX1:%.*]] = getelementptr inbounds [10 x ptr], ptr 
[[XP]], i64 0, i64 1
-// CHECK-NEXT:store ptr [[ARRAYIDX]], ptr [[ARRAYIDX1]], align 8
-// CHECK-NEXT:[[ARRAYIDX2:%.*]] = getelementptr inbounds [10 x ptr], ptr 
[[XP]], i64 0, i64 0
-// CHECK-NEXT:store ptr [[ARRAYIDX2]], ptr [[XPP]], align 8
-// CHECK-NEXT:[[ARRAYIDX3:%.*]] = getelementptr inbounds [10 x i16], ptr 
[[X]], i64 0, i64 1
-// CHECK-NEXT:store i16 111, ptr [[ARRAYIDX3]], align 2
-// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[XPP]], align 8
-// CHECK-NEXT:[[TMP1:%.*]] = load ptr, ptr [[XPP]], align 8
-// CHECK-NEXT:[[ARRAYIDX4:%.*]] = getelementptr inbounds ptr, ptr 
[[TMP1]], i64 1
-// CHECK-NEXT:[[TMP2:%.*]] = load ptr, ptr [[XPP]], align 8
-// CHECK-NEXT:[[ARRAYIDX5:%.*]] = getelementptr inbounds ptr, ptr 
[[TMP2]], i64 1
-// CHECK-NEXT:[[TMP3:%.*]] = load ptr, ptr [[ARRAYIDX5]], align 8
-// CHECK-NEXT:[[ARRAYIDX6:%.*]] = getelementptr inbounds i16, ptr 
[[TMP3]], i64 1
-// CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds [2 x ptr], ptr 
[[DOTOFFLOAD_BASEPTRS]], i32 0, i32 0
-// CHECK-NEXT:store ptr [[TMP0]], ptr [[TMP4]], align 8
-// CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds [2 x ptr], ptr 
[[DOTOFFLOAD_PTRS]], i32 0, i32 0
-// CHECK-NEXT:store ptr [[ARRAYIDX4]], ptr [[TMP5]], align 8
-// CHECK-NEXT:[[TMP6:%.*]] = getelementptr inbounds [2 x ptr], 

[PATCH] D150253: [RISCV] Add Zvfhmin extension for clang.

2023-05-25 Thread Jianjian Guan via Phabricator via cfe-commits
jacquesguan marked 5 inline comments as done.
jacquesguan added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVSubtarget.h:162
+  bool hasVInstructionsF16Mininal() const {
+return HasStdExtZvfhmin || HasStdExtZvfh;
+  }

craig.topper wrote:
> michaelmaitland wrote:
> > michaelmaitland wrote:
> > > jacquesguan wrote:
> > > > craig.topper wrote:
> > > > > Doesn't HasStdExtZvfh already imply HasStdExtZvfhmin?
> > > > The v spec doesn't metion this.
> > > I think the spec conveys this when it says `The Zvfhmin extension depends 
> > > on the Zve32f extension.`
> > My mistake, that says `Zve32f`, not `Zvfh`. However, the spec does say:
> > 
> > `When the Zvfhmin extension is implemented, the vfwcvt.f.f.v and 
> > vfncvt.f.f.w instructions become defined when SEW=16` and also says `When 
> > the Zvfh extension is implemented, all instructions in Sections Vector 
> > Floating-Point Instructions.` Since `vfwcvt.f.f.v and vfncvt.f.f.w` are 
> > part of `Vector Floating-Point Instructions` section, this is how it is 
> > implied.
> It's implemented in LLVM by this patch https://reviews.llvm.org/D150016
This patch make Zvfh imply **Zfhmin ** not **Zvfhmin**. I think the relation 
between Zvfh and Zvfhmin is just like the relation between Zfh and Zfhmin. Now 
Zfh doesn't imply Zfhmin, so I keep Zvfh not imply Zvfhmin.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150253

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


[PATCH] D150114: [Headers][doc] Add "add/sub/mul" intrinsic descriptions to avx2intrin.h

2023-05-25 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

LGTM except for a possible typo.




Comment at: clang/lib/Headers/avx2intrin.h:412
+///vectors of [16 x i16] and returns the lower 16 bits of each difference
+///in an element of the [16 x i16] result (overflow is ignored).
+///Differences from \a __a are returned in the lower 64 bits of each

underflow?



Comment at: clang/lib/Headers/avx2intrin.h:448
+///vectors of [8 x i32] and returns the lower 32 bits of each difference in
+///an element of the [8 x i31] result (overflow is ignored). Differences
+///from \a __a are returned in the lower 64 bits of each 128-bit half of

typo or intended?



Comment at: clang/lib/Headers/avx2intrin.h:448
+///vectors of [8 x i32] and returns the lower 32 bits of each difference in
+///an element of the [8 x i31] result (overflow is ignored). Differences
+///from \a __a are returned in the lower 64 bits of each 128-bit half of

pengfei wrote:
> typo or intended?
underflow.


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

https://reviews.llvm.org/D150114

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


[PATCH] D141627: [Clang][OpenMP] Fix the issue that list items in `has_device_addr` are still mapped to the target device

2023-05-25 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

In D141627#4374782 , @dyung wrote:

> In D141627#4374757 , 
> @tianshilei1992 wrote:
>
>> In D141627#4374753 , @Northbadge 
>> wrote:
>>
>>> FYI this is failing- 
>>> https://lab.llvm.org/buildbot/#/builders/109/builds/64971/steps/6/logs/FAIL__Clang__bug59160_c
>>
>> Thanks. I pushed a fix in eaf3de6970fc 
>> .
>
> In case you are not already aware, the test is still failing after your fix:
> https://lab.llvm.org/buildbot/#/builders/139/builds/41495

thanks. I’ll fix it soon or I’ll revert it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141627

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


[PATCH] D151525: [NFC][CLANG] Fix nullptr dereference issue in Type::getSveEltType()

2023-05-25 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added a reviewer: erichkeane.
Herald added subscribers: ctetreau, tschuett.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

This patch uses castAs instead of getAs which will assert if the type doesn't 
match in clang::​Type::​getSveEltType(clang::​ASTContext const &)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151525

Files:
  clang/lib/AST/Type.cpp


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2421,7 +2421,7 @@
 QualType Type::getSveEltType(const ASTContext ) const {
   assert(isVLSTBuiltinType() && "unsupported type!");
 
-  const BuiltinType *BTy = getAs();
+  const BuiltinType *BTy = castAs();
   if (BTy->getKind() == BuiltinType::SveBool)
 // Represent predicates as i8 rather than i1 to avoid any layout issues.
 // The type is bitcasted to a scalable predicate type when casting between


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2421,7 +2421,7 @@
 QualType Type::getSveEltType(const ASTContext ) const {
   assert(isVLSTBuiltinType() && "unsupported type!");
 
-  const BuiltinType *BTy = getAs();
+  const BuiltinType *BTy = castAs();
   if (BTy->getKind() == BuiltinType::SveBool)
 // Represent predicates as i8 rather than i1 to avoid any layout issues.
 // The type is bitcasted to a scalable predicate type when casting between
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150446: [analyzer] Check ArraySubscriptExprs in ArrayBoundCheckerV2

2023-05-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> By the way, I'm fed up with the hack that ElementRegion is used for three 
> separate things ("real" array indexing, casts and pointer arithmetic). To fix 
> this I'm thinking about introducing a subclass hierarchy where a base class 
> `ElementLikeRegion` has three subclasses:
>
> - `ElementRegion` represents the smaller memory area of one element in an 
> array,
> - `CastRegion` represents the same memory area, but with a different type, and
> - `OffsetRegion` represents the same memory area, but with a different 
> starting point.
>
> Most old references to ElementRegion could be replaced by references to 
> ElementLikeRegion, but functions like `stripCasts()` would be able to 
> distinguish between the subclasses and do the intuitive thing.
>
> What do you think about this idea? Do you see any problem with it?
>
> (By the way I'm not satisfied with these quickly picked class names -- feel 
> free to suggest better ones!)

My usual response to this is, "region types were a mistake". Every single time 
when the program relies on region type, it is actually supposed to rely on 
either AST type behind the program point, or on the dynamic type map if runtime 
types are of interest. I believe the ideal solution is to remove all non-base 
regions (`ElementRegion`, `FieldRegion`, `CXXBaseObjectRegion`, 
`CXXDerivedObjectRegion`) entirely, and instead represent all single-location 
values as (//base region//, //offset//) pairs (where //offset// can be an 
arbitrary `SVal` of appropriate numeric type), and represent regions as (//base 
region//, //begin offset//, //end offset//) triples.

So for example the `SymbolRegionValue{FieldRegion{VarRegion}}` object 
`reg_$0field>` would be turned into a `SymbolRegionValue{VarRegion, 
Offset}` object `reg_$0` where `32` is the bit offset of field 
`field` in the struct. We could preserve the end offset here as well, but the 
`int` part already tells us that it's `64` or something like that. Funny type 
punning should probably be handled by the surrounding expression instead; here 
we just need to capture what the memory read looked like when it produced that 
symbol.

Basically do whatever `RegionStore` already does right, everywhere else.

I have more thoughts/examples at 
https://github.com/llvm/llvm-project/issues/42709

I don't know whether my solution is easier to implement than your solution. My 
solution yields a much simpler system at the end (whereas your solution 
increases complexity), but in my case the changes can be pretty dramatic. Both 
solutions will be pretty hard because you'll have to untangle a lot of code 
built specifically to deal with the existing artificial ambiguities. One good 
thing about my solution is, you'd at least be able to consult runtime behavior 
as the ultimate source of truth; region types aren't part of the runtime 
behavior so there's no right or wrong way to handle them so they'll always be a 
source of confusion. But if I was to guess, I'd say your solution is probably 
more realistic to implement on a short time frame, and you might be able to 
make your work somewhat incremental as well, by introducing the new regions in 
more and more cases.

> I'm replacing it with an implementation based on 
> `check::PreStmt`

I think this is a great call; there's no fundamental reason why this would be 
more precise, but this tightly ties the problem to source code (as opposed to 
low-level memory layout), which allows us to shape the entire analysis 
differently and communicate with the user more efficiently.

One straightforward implication is that this way we avoid dealing with 
multiplication/division when calculating offsets. This is particularly valuable 
when the offset is symbolic, so existing decomposition into `RegionOffset` 
basically gives up. Of course we could fix `RegionOffset` to correctly compute 
a symbolic offset value instead, with all the multiplications and divisions 
over symbolic expressions. Then the constraint solver will need to solve these 
multiplications/divisions. Of course we could improve the constraint solver to 
handle them better, but if we can avoid this entirely, why not? Then, after the 
solver gives us the answer, we have to explain the answer to the user. And 
then, again, this isn't unsolvable, but that explanation would be much more 
convoluted in terms of symbolic byte offsets, than in terms of the actual 
source-level array index.

Now, symbolic offsets are actually extremely important because I believe this 
is pretty much the only case where we can reach good false positive rate. A 
typical loop over an array will be modeled by assigning the loop counter to 
concrete values `0`, `1`, `2`, `3` and simulating the loop. This is the root 
cause of many false positives because the assumption that the loop can 
definitely be executed exactly `0` (or exactly `1` or exactly `2` or exactly 
`3`) times is deeply incorrect. However when the index is symbolic, it 
indicates that 

[PATCH] D146777: [clang] Preliminary fat-lto-object support

2023-05-25 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth updated this revision to Diff 525902.
paulkirth added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146777

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/embed-lto-fatlto.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fatlto-objects.c

Index: clang/test/Driver/fatlto-objects.c
===
--- /dev/null
+++ clang/test/Driver/fatlto-objects.c
@@ -0,0 +1,10 @@
+// REQUIRES: x86_64-linux
+// RUN: %clang -target x86_64-unknown-linux-gnu -flto -ffat-lto-objects -fintegrated-as -### %s -c 2>&1 | FileCheck %s -check-prefix=CHECK-CC
+// CHECK-CC: -cc1
+// CHECK-CC: -emit-obj
+// CHECK-CC: -ffat-lto-objects
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -ffat-lto-objects -fintegrated-as -### %s -c 2>&1 | FileCheck %s -check-prefix=CHECK-CC-NOLTO
+// CHECK-CC-NOLTO: -cc1
+// CHECK-CC-NOLTO: -emit-obj
+// CHECK-CC-NOLTO-NOT: -ffat-lto-objects
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -425,7 +425,6 @@
 // CHECK-WARNING-DAG: optimization flag '-fwhole-program' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fcaller-saves' is not supported
 // CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ffat-lto-objects' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fmerge-constants' is not supported
 // CHECK-WARNING-DAG: optimization flag '-finline-small-functions' is not supported
 // CHECK-WARNING-DAG: optimization flag '-ftree-dce' is not supported
Index: clang/test/CodeGen/embed-lto-fatlto.c
===
--- /dev/null
+++ clang/test/CodeGen/embed-lto-fatlto.c
@@ -0,0 +1,9 @@
+// RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -S -flto=full -ffat-lto-objects -emit-llvm < %s  | FileCheck %s
+// RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -S -flto=full -ffat-lto-objects -emit-llvm < %s  | FileCheck %s
+//
+// CHECK: !{{[0-9]+}} = !{i32 1, !"ThinLTO", i32 0}
+// CHECK: !{{[0-9]+}} = !{i32 1, !"EnableSplitLTOUnit", i32 1}
+
+int test(void) {
+  return 0xabcd;
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7272,6 +7272,14 @@
 }
   }
 
+  if (IsUsingLTO && Args.getLastArg(options::OPT_ffat_lto_objects)) {
+assert(LTOMode == LTOK_Full || LTOMode == LTOK_Thin);
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-flto=") + (LTOMode == LTOK_Thin ? "thin" : "full")));
+CmdArgs.push_back("-flto-unit");
+CmdArgs.push_back("-ffat-lto-objects");
+  }
+
   if (Args.hasArg(options::OPT_forder_file_instrumentation)) {
  CmdArgs.push_back("-forder-file-instrumentation");
  // Enable order file instrumentation when ThinLTO is not on. When ThinLTO is
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4639,8 +4639,13 @@
   }
   case phases::Backend: {
 if (isUsingLTO() && TargetDeviceOffloadKind == Action::OFK_None) {
-  types::ID Output =
-  Args.hasArg(options::OPT_S) ? types::TY_LTO_IR : types::TY_LTO_BC;
+  types::ID Output;
+  if (Args.hasArg(options::OPT_S))
+Output = types::TY_LTO_IR;
+  else if (Args.hasArg(options::OPT_ffat_lto_objects))
+Output = types::TY_PP_Asm;
+  else
+Output = types::TY_LTO_BC;
   return C.MakeAction(Input, Output);
 }
 if (isUsingLTO(/* IsOffload */ true) &&
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -24,6 +24,7 @@
 #include "llvm/Bitcode/BitcodeReader.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
 #include "llvm/Bitcode/BitcodeWriterPass.h"
+#include "llvm/Bitcode/EmbedBitcodePass.h"
 #include "llvm/CodeGen/RegAllocRegistry.h"
 #include "llvm/CodeGen/SchedulerRegistry.h"
 #include "llvm/CodeGen/TargetSubtargetInfo.h"
@@ -990,7 +991,10 @@
 MPM.addPass(InstrProfiling(*Options, false));
   });
 
-if (IsThinLTO) {
+if (CodeGenOpts.FatLTO) {
+  MPM = PB.buildFatLTODefaultPipeline(
+  Level, IsThinLTO, IsThinLTO || shouldEmitRegularLTOSummary());
+} else if (IsThinLTO) {
   MPM = PB.buildThinLTOPreLinkDefaultPipeline(Level);
 } else if (IsLTO) {
   MPM = 

[PATCH] D151523: [ASTStructuralEquivalence] Fix crash when ObjCCategoryDecl doesn't have corresponding ObjCInterfaceDecl.

2023-05-25 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Kinda a follow-up to D121176 .

One big alternative that I've considered is to store interface name in 
`ObjCCategoryDecl` because when we parse `@interface 
InterfaceName(CategoryName)` we know the interface name. The intention was to 
allow

  @interface A(X) @end

and

  @interface A @end
  @interface A(X) @end

as equivalent. But I'm not convinced it is the right call and that's why it 
doesn't justify the extra effort.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151523

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


[PATCH] D151523: [ASTStructuralEquivalence] Fix crash when ObjCCategoryDecl doesn't have corresponding ObjCInterfaceDecl.

2023-05-25 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: martong, shafik, ahatanak.
Herald added subscribers: ributzka, rnkovacs.
Herald added a project: All.
vsapsai requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When this happens, it is invalid code and there is diagnostic

  error: cannot find interface declaration for '...'

But clang shouldn't crash even if code is invalid. Though subsequent
diagnostic can be imperfect because without ObjCInterfaceDecl we don't have
a type for error messages.

rdar://108818430


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151523

Files:
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/unittests/AST/StructuralEquivalenceTest.cpp


Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -1143,6 +1143,18 @@
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+TEST_F(StructuralEquivalenceObjCCategoryTest, CategoriesWithoutInterfaces) {
+  auto t = makeDecls("  @interface A(X) 
@end",
+   "@interface A @end @interface A(X) 
@end",
+   Lang_OBJC, objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+
+  auto t2 = makeDecls("@interface A(X) @end",
+"@interface A(X) @end",
+Lang_OBJC, objcCategoryDecl());
+  EXPECT_TRUE(testStructuralMatch(t2));
+}
+
 TEST_F(StructuralEquivalenceObjCCategoryTest, CategoryAndExtension) {
   auto t = makeDecls("@interface A @end @interface A(X) 
@end",
"@interface A @end @interface A() @end",
Index: clang/lib/AST/ASTStructuralEquivalence.cpp
===
--- clang/lib/AST/ASTStructuralEquivalence.cpp
+++ clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -2057,8 +2057,13 @@
   if (!IsStructurallyEquivalent(D1->getIdentifier(), D2->getIdentifier()))
 return false;
 
-  if (!IsStructurallyEquivalent(D1->getClassInterface()->getIdentifier(),
-D2->getClassInterface()->getIdentifier()))
+  const ObjCInterfaceDecl *Intf1 = D1->getClassInterface(),
+  *Intf2 = D2->getClassInterface();
+  if ((Intf1 != nullptr) != (Intf2 != nullptr))
+return false;
+
+  if (Intf1 &&
+  !IsStructurallyEquivalent(Intf1->getIdentifier(), 
Intf2->getIdentifier()))
 return false;
 
   // Compare protocols.
@@ -2077,7 +2082,8 @@
 return false;
 
   // Compare ivars.
-  QualType D2Type = 
Context.ToCtx.getObjCInterfaceType(D2->getClassInterface());
+  QualType D2Type =
+  Intf2 ? Context.ToCtx.getObjCInterfaceType(Intf2) : QualType();
   ObjCCategoryDecl::ivar_iterator Ivar2 = D2->ivar_begin(),
   Ivar2End = D2->ivar_end();
   for (ObjCCategoryDecl::ivar_iterator Ivar1 = D1->ivar_begin(),


Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -1143,6 +1143,18 @@
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+TEST_F(StructuralEquivalenceObjCCategoryTest, CategoriesWithoutInterfaces) {
+  auto t = makeDecls("  @interface A(X) @end",
+   "@interface A @end @interface A(X) @end",
+   Lang_OBJC, objcCategoryDecl());
+  EXPECT_FALSE(testStructuralMatch(t));
+
+  auto t2 = makeDecls("@interface A(X) @end",
+"@interface A(X) @end",
+Lang_OBJC, objcCategoryDecl());
+  EXPECT_TRUE(testStructuralMatch(t2));
+}
+
 TEST_F(StructuralEquivalenceObjCCategoryTest, CategoryAndExtension) {
   auto t = makeDecls("@interface A @end @interface A(X) @end",
"@interface A @end @interface A() @end",
Index: clang/lib/AST/ASTStructuralEquivalence.cpp
===
--- clang/lib/AST/ASTStructuralEquivalence.cpp
+++ clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -2057,8 +2057,13 @@
   if (!IsStructurallyEquivalent(D1->getIdentifier(), D2->getIdentifier()))
 return false;
 
-  if (!IsStructurallyEquivalent(D1->getClassInterface()->getIdentifier(),
-D2->getClassInterface()->getIdentifier()))
+  const ObjCInterfaceDecl *Intf1 = D1->getClassInterface(),
+  *Intf2 = D2->getClassInterface();
+  if ((Intf1 != nullptr) != (Intf2 != nullptr))
+return false;
+
+  if (Intf1 &&
+  !IsStructurallyEquivalent(Intf1->getIdentifier(), Intf2->getIdentifier()))
 return false;
 
   // Compare 

[PATCH] D141627: [Clang][OpenMP] Fix the issue that list items in `has_device_addr` are still mapped to the target device

2023-05-25 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

In D141627#4374757 , @tianshilei1992 
wrote:

> In D141627#4374753 , @Northbadge 
> wrote:
>
>> FYI this is failing- 
>> https://lab.llvm.org/buildbot/#/builders/109/builds/64971/steps/6/logs/FAIL__Clang__bug59160_c
>
> Thanks. I pushed a fix in eaf3de6970fc 
> .

In case you are not already aware, the test is still failing after your fix:
https://lab.llvm.org/buildbot/#/builders/139/builds/41495


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141627

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


[PATCH] D144911: adding bf16 support to NVPTX

2023-05-25 Thread Kushan Ahmadian via Phabricator via cfe-commits
kushanam updated this revision to Diff 525896.
kushanam added a comment.

removing commented td entry


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144911

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp
  llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/lib/Target/NVPTX/NVPTXMCExpr.cpp
  llvm/lib/Target/NVPTX/NVPTXMCExpr.h
  llvm/lib/Target/NVPTX/NVPTXRegisterInfo.td
  llvm/lib/Target/NVPTX/NVPTXSubtarget.cpp
  llvm/lib/Target/NVPTX/NVPTXSubtarget.h
  llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
  llvm/test/CodeGen/NVPTX/bf16-instructions.ll

Index: llvm/test/CodeGen/NVPTX/bf16-instructions.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/bf16-instructions.ll
@@ -0,0 +1,88 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | FileCheck %s
+; RUN: %if ptxas-11.0 %{ llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | %ptxas-verify -arch=sm_80 %}
+
+
+; CHECK-LABEL: test_fadd(
+; CHECK-DAG:  ld.param.b16[[A:%h[0-9]+]], [test_fadd_param_0];
+; CHECK-DAG:  ld.param.b16[[B:%h[0-9]+]], [test_fadd_param_1];
+; CHECK-NEXT: add.rn.bf16 [[R:%f[0-9]+]], [[A]], [[B]];
+; CHECK-NEXT: st.param.b16[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define bfloat @test_fadd(bfloat %0, bfloat %1) {
+  %3 = fadd bfloat %0, %1 
+  ret bfloat %3
+}
+
+; CHECK-LABEL: test_fsub(
+; CHECK-DAG:  ld.param.b16[[A:%h[0-9]+]], [test_fsub_param_0];
+; CHECK-DAG:  ld.param.b16[[B:%h[0-9]+]], [test_fsub_param_1];
+; CHECK-NEXT: sub.rn.bf16 [[R:%f[0-9]+]], [[A]], [[B]];
+; CHECK-NEXT: st.param.b16[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define bfloat @test_fsub(bfloat %0, bfloat %1) {
+  %3 = fsub bfloat %0, %1 
+  ret bfloat %3
+}
+
+; CHECK-LABEL: test_faddx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_faddx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_faddx2_param_1];
+; CHECK-NEXT: add.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_faddx2(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fadd <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fsubx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fsubx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fsubx2_param_1];
+; CHECK-NEXT: sub.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_fsubx2(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fsub <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fmulx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fmulx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fmulx2_param_1];
+; CHECK-NEXT: mul.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_fmul(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fmul <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fdiv(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fdiv_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fdiv_param_1];
+; CHECK-DAG:  mov.b32 {[[A0:%h[0-9]+]], [[A1:%h[0-9]+]]}, [[A]]
+; CHECK-DAG:  mov.b32 {[[B0:%h[0-9]+]], [[B1:%h[0-9]+]]}, [[B]]
+; CHECK-DAG:  cvt.f32.bf16 [[FA0:%f[0-9]+]], [[A0]];
+; CHECK-DAG:  cvt.f32.bf16 [[FA1:%f[0-9]+]], [[A1]];
+; CHECK-DAG:  cvt.f32.bf16 [[FB0:%f[0-9]+]], [[B0]];
+; CHECK-DAG:  cvt.f32.bf16 [[FB1:%f[0-9]+]], [[B1]];
+; CHECK-DAG:  div.rn.f32  [[FR0:%f[0-9]+]], [[FA0]], [[FB0]];
+; CHECK-DAG:  div.rn.f32  [[FR1:%f[0-9]+]], [[FA1]], [[FB1]];
+; CHECK-DAG:  cvt.rn.bf16.f32  [[R0:%h[0-9]+]], [[FR0]];
+; CHECK-DAG:  cvt.rn.bf16.f32  [[R1:%h[0-9]+]], [[FR1]];
+; CHECK-NEXT: mov.b32 [[R:%hh[0-9]+]], {[[R0]], [[R1]]}
+; CHECK-NEXT: st.param.b32[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define <2 x bfloat> @test_fdiv(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fdiv <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
Index: llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
===
--- llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
+++ llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
@@ -204,6 +204,14 @@
   return {Intrinsic::fma, FTZ_MustBeOff, true};
 case Intrinsic::nvvm_fma_rn_ftz_f16x2:
  

[PATCH] D151517: Fix wrong error message when compiling C souce code

2023-05-25 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 525894.
jyu2 retitled this revision from "Fix couple of problems in uses_allocators 
clause." to "Fix wrong error message when compiling C souce code".
jyu2 edited the summary of this revision.
jyu2 added a comment.

Thanks Alexey,  sure I am separate the patch.  This is first oen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151517

Files:
  clang/lib/Parse/ParseOpenMP.cpp
  clang/test/OpenMP/target_uses_allocators.c


Index: clang/test/OpenMP/target_uses_allocators.c
===
--- clang/test/OpenMP/target_uses_allocators.c
+++ clang/test/OpenMP/target_uses_allocators.c
@@ -2,6 +2,8 @@
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50  -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -verify 
-emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-include-pch %t %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -verify 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-include-pch %t %s -emit-llvm -o - | FileCheck %s
 
 #ifndef HEADER
 #define HEADER
@@ -19,9 +21,27 @@
   KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
 } omp_allocator_handle_t;
 
+typedef enum omp_alloctrait_key_t { omp_atk_sync_hint = 1,
+omp_atk_alignment = 2,
+omp_atk_access = 3,
+omp_atk_pool_size = 4,
+omp_atk_fallback = 5,
+omp_atk_fb_data = 6,
+omp_atk_pinned = 7,
+omp_atk_partition = 8
+} omp_alloctrait_key_t;
+
+typedef struct omp_alloctrait_t {
+  omp_alloctrait_key_t key;
+  __UINTPTR_TYPE__ value;
+} omp_alloctrait_t;
+
+
 // CHECK: define {{.*}}[[FIE:@.+]]()
 void fie(void) {
   int x;
+  omp_allocator_handle_t my_allocator;
+  omp_alloctrait_t traits[10];
   #pragma omp target uses_allocators(omp_null_allocator) 
allocate(omp_null_allocator: x) firstprivate(x)
   {}
   #pragma omp target uses_allocators(omp_default_mem_alloc) 
allocate(omp_default_mem_alloc: x) firstprivate(x)
@@ -40,6 +60,8 @@
   {}
   #pragma omp target uses_allocators(omp_thread_mem_alloc) 
allocate(omp_thread_mem_alloc: x) firstprivate(x) // expected-warning 
{{allocator with the 'thread' trait access has unspecified behavior on 'target' 
directive}}
   {}
+#pragma omp target uses_allocators(omp_null_allocator, omp_thread_mem_alloc, 
my_allocator(traits))
+  {}
 }
 
 #endif
@@ -106,3 +128,16 @@
 // CHECK-NEXT: %[[#R1:]] = load i32, ptr %x.addr, align 4
 // CHECK-NEXT: store i32 %[[#R1]], ptr %.x..void.addr, align 4
 // CHECK-NEXT: call void @__kmpc_free(i32 %[[#R0]], ptr %.x..void.addr, ptr 
inttoptr (i64 8 to ptr))
+
+// CHECK: [[TRAITS_ADDR_REF:%.+]] = alloca ptr,
+// CHECK: [[MY_ALLOCATOR_ADDR:%.+]] = alloca i64,
+// CHECK: [[TRAITS_ADDR:%.+]] = load ptr, ptr [[TRAITS_ADDR_REF]],
+// CHECK: [[TRAITS:%.+]] = load ptr, ptr [[TRAITS_ADDR]],
+// CHECK: [[ALLOCATOR:%.+]] = call ptr @__kmpc_init_allocator(i32 %{{.+}}, ptr 
null, i32 10, ptr [[TRAITS]])
+// CHECK: [[CONV:%.+]] = ptrtoint ptr [[ALLOCATOR]] to i64
+// CHECK: store i64 [[CONV]], ptr [[MY_ALLOCATOR_ADDR]],
+
+// Destroy allocator upon exit from the region.
+// CHECK: [[ALLOCATOR:%.+]] = load i64, ptr [[MY_ALLOCATOR_ADDR]],
+// CHECK: [[CONV:%.+]] = inttoptr i64 [[ALLOCATOR]] to ptr
+// CHECK: call void @__kmpc_destroy_allocator(i32 %{{.+}}, ptr [[CONV]])
Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -3103,8 +3103,13 @@
 return nullptr;
   SmallVector Data;
   do {
+CXXScopeSpec SS;
+Token Replacement;
 ExprResult Allocator =
-getLangOpts().CPlusPlus ? ParseCXXIdExpression() : ParseExpression();
+getLangOpts().CPlusPlus
+? ParseCXXIdExpression()
+: tryParseCXXIdExpression(SS, /*isAddressOfOperand=*/false,
+  Replacement);
 if (Allocator.isInvalid()) {
   SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
 StopBeforeMatch);


Index: clang/test/OpenMP/target_uses_allocators.c
===
--- clang/test/OpenMP/target_uses_allocators.c
+++ 

[PATCH] D141627: [Clang][OpenMP] Fix the issue that list items in `has_device_addr` are still mapped to the target device

2023-05-25 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

In D141627#4374753 , @Northbadge 
wrote:

> FYI this is failing- 
> https://lab.llvm.org/buildbot/#/builders/109/builds/64971/steps/6/logs/FAIL__Clang__bug59160_c

Thanks. I pushed a fix in eaf3de6970fc 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141627

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


[clang] eaf3de6 - [Clang] Fix test case issue introduced by D141627

2023-05-25 Thread Shilei Tian via cfe-commits

Author: Shilei Tian
Date: 2023-05-25T20:40:57-04:00
New Revision: eaf3de6970fc6e779310a59fbf8f8452f6b34c55

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

LOG: [Clang] Fix test case issue introduced by D141627

Added: 


Modified: 
clang/test/OpenMP/bug59160.c

Removed: 




diff  --git a/clang/test/OpenMP/bug59160.c b/clang/test/OpenMP/bug59160.c
index 49522fe9ef859..9a997780cf7af 100644
--- a/clang/test/OpenMP/bug59160.c
+++ b/clang/test/OpenMP/bug59160.c
@@ -20,11 +20,11 @@ void zoo(void) {
 // CHECK: @.offload_maptypes = private unnamed_addr constant [2 x i64] [i64 
67, i64 19]
 // CHECK: @0 = private unnamed_addr constant [23 x i8] c"
 // CHECK: @1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, 
i32 0, i32 22, ptr @0 }, align 8
-// CHECK: @.__omp_offloading_34_735f4a3a_zoo_l13.region_id = weak constant i8 0
+// CHECK: @.{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_zoo_l13.region_id = weak 
constant i8 0
 // CHECK: @.offload_sizes.1 = private unnamed_addr constant [1 x i64] [i64 8]
 // CHECK: @.offload_maptypes.2 = private unnamed_addr constant [1 x i64] [i64 
288]
-// CHECK: @.omp_offloading.entry_name = internal unnamed_addr constant [37 x 
i8] c"__omp_offloading_34_735f4a3a_zoo_l13\00"
-// CHECK: @.omp_offloading.entry.__omp_offloading_34_735f4a3a_zoo_l13 = weak 
constant %struct.__tgt_offload_entry { ptr 
@.__omp_offloading_34_735f4a3a_zoo_l13.region_id, ptr 
@.omp_offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"omp_offloading_entries", align 1
+// CHECK: @.omp_offloading.entry_name = internal unnamed_addr constant [37 x 
i8] c"{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_zoo_l13\00"
+// CHECK: 
@.omp_offloading.entry.{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_zoo_l13 = weak 
constant %struct.__tgt_offload_entry { ptr 
@.{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}_zoo_l13.region_id, ptr 
@.omp_offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"omp_offloading_entries", align 1
 // CHECK: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ 
i32, ptr, ptr } { i32 0, ptr @.omp_offloading.requires_reg, ptr null }]
 //.
 // CHECK-LABEL: define {{[^@]+}}@zoo
@@ -156,20 +156,3 @@ void zoo(void) {
 // SIMD-ONLY0-NEXT:[[ARRAYIDX5:%.*]] = getelementptr inbounds i16, ptr 
[[TMP1]], i64 1
 // SIMD-ONLY0-NEXT:store i16 222, ptr [[ARRAYIDX5]], align 2
 // SIMD-ONLY0-NEXT:ret void
-//
-//.
-// CHECK: attributes #0 = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="-altivec,-bpermd,-crbits,-crypto,-direct-move,-extdiv,-htm,-isa-v206-instructions,-isa-v207-instructions,-isa-v30-instructions,-power8-vector,-power9-vector,-privileged,-quadword-atomics,-rop-protect,-spe,-vsx"
 }
-// CHECK: attributes #1 = { nounwind }
-// CHECK: attributes #2 = { noinline norecurse nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="-altivec,-bpermd,-crbits,-crypto,-direct-move,-extdiv,-htm,-isa-v206-instructions,-isa-v207-instructions,-isa-v30-instructions,-power8-vector,-power9-vector,-privileged,-quadword-atomics,-rop-protect,-spe,-vsx"
 }
-// CHECK: attributes #3 = { noinline nounwind "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" 
"target-features"="-altivec,-bpermd,-crbits,-crypto,-direct-move,-extdiv,-htm,-isa-v206-instructions,-isa-v207-instructions,-isa-v30-instructions,-power8-vector,-power9-vector,-privileged,-quadword-atomics,-rop-protect,-spe,-vsx"
 }
-//.
-// SIMD-ONLY0: attributes #0 = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="-altivec,-bpermd,-crbits,-crypto,-direct-move,-extdiv,-htm,-isa-v206-instructions,-isa-v207-instructions,-isa-v30-instructions,-power8-vector,-power9-vector,-privileged,-quadword-atomics,-rop-protect,-spe,-vsx"
 }
-//.
-// CHECK: !0 = !{i32 0, i32 52, i32 1935624762, !"zoo", i32 13, i32 0, i32 0}
-// CHECK: !1 = !{i32 1, !"wchar_size", i32 4}
-// CHECK: !2 = !{i32 7, !"openmp", i32 51}
-// CHECK: !3 = !{!"clang version 17.0.0"}
-//.
-// SIMD-ONLY0: !0 = !{i32 1, !"wchar_size", i32 4}
-// SIMD-ONLY0: !1 = !{!"clang version 17.0.0"}
-//.



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


[PATCH] D141627: [Clang][OpenMP] Fix the issue that list items in `has_device_addr` are still mapped to the target device

2023-05-25 Thread Jin Xin Ng via Phabricator via cfe-commits
Northbadge added a comment.

FYI this is failing- 
https://lab.llvm.org/buildbot/#/builders/109/builds/64971/steps/6/logs/FAIL__Clang__bug59160_c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141627

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


[PATCH] D141627: [Clang][OpenMP] Fix the issue that list items in `has_device_addr` are still mapped to the target device

2023-05-25 Thread Shilei Tian 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 rGb8e3077d60de: [Clang][OpenMP] Fix the issue that list items 
in `has_device_addr` are still… (authored by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141627

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/bug59160.c

Index: clang/test/OpenMP/bug59160.c
===
--- /dev/null
+++ clang/test/OpenMP/bug59160.c
@@ -0,0 +1,175 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --check-globals --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" --prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-version=51 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-version=51 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// expected-no-diagnostics
+
+void zoo(void) {
+  short x[10];
+  short *(xp[10]);
+  xp[1] = [0];
+  short **xpp = [0];
+  x[1] = 111;
+#pragma omp target data map(tofrom: xpp[1][1]) use_device_addr(xpp[1][1])
+#pragma omp target has_device_addr(xpp[1][1])
+  {
+xpp[1][1] = 222;
+  }
+}
+//.
+// CHECK: @.offload_sizes = private unnamed_addr constant [2 x i64] [i64 8, i64 2]
+// CHECK: @.offload_maptypes = private unnamed_addr constant [2 x i64] [i64 67, i64 19]
+// CHECK: @0 = private unnamed_addr constant [23 x i8] c"
+// CHECK: @1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 22, ptr @0 }, align 8
+// CHECK: @.__omp_offloading_34_735f4a3a_zoo_l13.region_id = weak constant i8 0
+// CHECK: @.offload_sizes.1 = private unnamed_addr constant [1 x i64] [i64 8]
+// CHECK: @.offload_maptypes.2 = private unnamed_addr constant [1 x i64] [i64 288]
+// CHECK: @.omp_offloading.entry_name = internal unnamed_addr constant [37 x i8] c"__omp_offloading_34_735f4a3a_zoo_l13\00"
+// CHECK: @.omp_offloading.entry.__omp_offloading_34_735f4a3a_zoo_l13 = weak constant %struct.__tgt_offload_entry { ptr @.__omp_offloading_34_735f4a3a_zoo_l13.region_id, ptr @.omp_offloading.entry_name, i64 0, i32 0, i32 0 }, section "omp_offloading_entries", align 1
+// CHECK: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 0, ptr @.omp_offloading.requires_reg, ptr null }]
+//.
+// CHECK-LABEL: define {{[^@]+}}@zoo
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[X:%.*]] = alloca [10 x i16], align 2
+// CHECK-NEXT:[[XP:%.*]] = alloca [10 x ptr], align 8
+// CHECK-NEXT:[[XPP:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[DOTOFFLOAD_BASEPTRS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_PTRS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_MAPPERS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_BASEPTRS7:%.*]] = alloca [1 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_PTRS8:%.*]] = alloca [1 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_MAPPERS9:%.*]] = alloca [1 x ptr], align 8
+// CHECK-NEXT:[[KERNEL_ARGS:%.*]] = alloca [[STRUCT___TGT_KERNEL_ARGUMENTS:%.*]], align 8
+// CHECK-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds [10 x i16], ptr [[X]], i64 0, i64 0
+// CHECK-NEXT:[[ARRAYIDX1:%.*]] = getelementptr inbounds [10 x ptr], ptr [[XP]], i64 0, i64 1
+// CHECK-NEXT:store ptr [[ARRAYIDX]], ptr [[ARRAYIDX1]], align 8
+// CHECK-NEXT:[[ARRAYIDX2:%.*]] = getelementptr inbounds [10 x ptr], ptr [[XP]], i64 0, i64 0
+// CHECK-NEXT:store ptr [[ARRAYIDX2]], ptr [[XPP]], align 8
+// CHECK-NEXT:[[ARRAYIDX3:%.*]] = getelementptr inbounds [10 x i16], ptr [[X]], i64 0, i64 1
+// CHECK-NEXT:store i16 111, ptr [[ARRAYIDX3]], align 2
+// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[XPP]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load ptr, ptr [[XPP]], align 8
+// CHECK-NEXT:[[ARRAYIDX4:%.*]] = getelementptr inbounds ptr, ptr [[TMP1]], i64 1
+// CHECK-NEXT:[[TMP2:%.*]] = load ptr, ptr [[XPP]], align 8
+// CHECK-NEXT:[[ARRAYIDX5:%.*]] = getelementptr inbounds ptr, ptr [[TMP2]], i64 1
+// CHECK-NEXT:[[TMP3:%.*]] = load ptr, ptr [[ARRAYIDX5]], align 8
+// CHECK-NEXT:[[ARRAYIDX6:%.*]] = getelementptr inbounds i16, ptr [[TMP3]], i64 1
+// CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds [2 x ptr], ptr [[DOTOFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK-NEXT:store ptr [[TMP0]], ptr [[TMP4]], align 8
+// CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds [2 x ptr], ptr [[DOTOFFLOAD_PTRS]], i32 0, i32 0
+// CHECK-NEXT:store ptr [[ARRAYIDX4]], ptr [[TMP5]], align 8

[clang] b8e3077 - [Clang][OpenMP] Fix the issue that list items in `has_device_addr` are still mapped to the target device

2023-05-25 Thread Shilei Tian via cfe-commits

Author: Shilei Tian
Date: 2023-05-25T20:19:07-04:00
New Revision: b8e3077d60de73ddcb1511a68af3fdd37fe81cf7

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

LOG: [Clang][OpenMP] Fix the issue that list items in `has_device_addr` are 
still mapped to the target device

This patch fixes the issue that list items in `has_device_addr` are still mapped
to the target device because front end emits map type `OMP_MAP_TO`.

Fix #59160.

Reviewed By: jyu2

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

Added: 
clang/test/OpenMP/bug59160.c

Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 8900f33383e21..ff6d1d4ed869f 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8640,9 +8640,7 @@ class MappableExprsHandler {
   CGF.getTypeSize(CGF.getContext().VoidPtrTy), CGF.Int64Ty,
   /*isSigned=*/true));
   CombinedInfo.Types.push_back(
-  (Cap->capturesVariable()
-   ? OpenMPOffloadMappingFlags::OMP_MAP_TO
-   : OpenMPOffloadMappingFlags::OMP_MAP_LITERAL) |
+  OpenMPOffloadMappingFlags::OMP_MAP_LITERAL |
   OpenMPOffloadMappingFlags::OMP_MAP_TARGET_PARAM);
   CombinedInfo.Mappers.push_back(nullptr);
   return;

diff  --git a/clang/test/OpenMP/bug59160.c b/clang/test/OpenMP/bug59160.c
new file mode 100644
index 0..49522fe9ef859
--- /dev/null
+++ b/clang/test/OpenMP/bug59160.c
@@ -0,0 +1,175 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-globals --include-generated-funcs 
--replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" 
--prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-version=51 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-version=51 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix 
SIMD-ONLY0 %s
+// expected-no-diagnostics
+
+void zoo(void) {
+  short x[10];
+  short *(xp[10]);
+  xp[1] = [0];
+  short **xpp = [0];
+  x[1] = 111;
+#pragma omp target data map(tofrom: xpp[1][1]) use_device_addr(xpp[1][1])
+#pragma omp target has_device_addr(xpp[1][1])
+  {
+xpp[1][1] = 222;
+  }
+}
+//.
+// CHECK: @.offload_sizes = private unnamed_addr constant [2 x i64] [i64 8, 
i64 2]
+// CHECK: @.offload_maptypes = private unnamed_addr constant [2 x i64] [i64 
67, i64 19]
+// CHECK: @0 = private unnamed_addr constant [23 x i8] c"
+// CHECK: @1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, 
i32 0, i32 22, ptr @0 }, align 8
+// CHECK: @.__omp_offloading_34_735f4a3a_zoo_l13.region_id = weak constant i8 0
+// CHECK: @.offload_sizes.1 = private unnamed_addr constant [1 x i64] [i64 8]
+// CHECK: @.offload_maptypes.2 = private unnamed_addr constant [1 x i64] [i64 
288]
+// CHECK: @.omp_offloading.entry_name = internal unnamed_addr constant [37 x 
i8] c"__omp_offloading_34_735f4a3a_zoo_l13\00"
+// CHECK: @.omp_offloading.entry.__omp_offloading_34_735f4a3a_zoo_l13 = weak 
constant %struct.__tgt_offload_entry { ptr 
@.__omp_offloading_34_735f4a3a_zoo_l13.region_id, ptr 
@.omp_offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"omp_offloading_entries", align 1
+// CHECK: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ 
i32, ptr, ptr } { i32 0, ptr @.omp_offloading.requires_reg, ptr null }]
+//.
+// CHECK-LABEL: define {{[^@]+}}@zoo
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[X:%.*]] = alloca [10 x i16], align 2
+// CHECK-NEXT:[[XP:%.*]] = alloca [10 x ptr], align 8
+// CHECK-NEXT:[[XPP:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[DOTOFFLOAD_BASEPTRS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_PTRS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_MAPPERS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_BASEPTRS7:%.*]] = alloca [1 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_PTRS8:%.*]] = alloca [1 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_MAPPERS9:%.*]] = alloca [1 x ptr], align 8
+// CHECK-NEXT:[[KERNEL_ARGS:%.*]] = alloca 
[[STRUCT___TGT_KERNEL_ARGUMENTS:%.*]], align 8
+// CHECK-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds [10 x i16], ptr 
[[X]], i64 0, i64 0
+// CHECK-NEXT:[[ARRAYIDX1:%.*]] = getelementptr inbounds [10 x ptr], ptr 
[[XP]], i64 0, i64 1
+// CHECK-NEXT:store ptr [[ARRAYIDX]], ptr [[ARRAYIDX1]], align 8
+// CHECK-NEXT:[[ARRAYIDX2:%.*]] = 

[PATCH] D151344: Reland "[CMake] Bumps minimum version to 3.20.0.

2023-05-25 Thread H. Vetinari via Phabricator via cfe-commits
h-vetinari added inline comments.



Comment at: libunwind/src/CMakeLists.txt:28-35
 
 # See add_asm_sources() in compiler-rt for explanation of this workaround.
 # CMake doesn't work correctly with assembly on AIX. Workaround by compiling
 # as C files as well.
 if((APPLE AND CMAKE_VERSION VERSION_LESS 3.19) OR
-   (MINGW AND CMAKE_VERSION VERSION_LESS 3.17) OR
-   (${CMAKE_SYSTEM_NAME} MATCHES "AIX"))
+   (MINGW AND CMAKE_VERSION VERSION_LESS 3.17))
   set_source_files_properties(${LIBUNWIND_ASM_SOURCES} PROPERTIES LANGUAGE C)

Shouldn't it be possible to remove that entire block (as it only fires for 
CMake <3.20)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151344

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


[PATCH] D144911: adding bf16 support to NVPTX

2023-05-25 Thread Kushan Ahmadian via Phabricator via cfe-commits
kushanam updated this revision to Diff 525883.
kushanam added a comment.

rebasing the diff based on the branch HEAD


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144911

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp
  llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/lib/Target/NVPTX/NVPTXMCExpr.cpp
  llvm/lib/Target/NVPTX/NVPTXMCExpr.h
  llvm/lib/Target/NVPTX/NVPTXRegisterInfo.td
  llvm/lib/Target/NVPTX/NVPTXSubtarget.cpp
  llvm/lib/Target/NVPTX/NVPTXSubtarget.h
  llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
  llvm/test/CodeGen/NVPTX/bf16-instructions.ll

Index: llvm/test/CodeGen/NVPTX/bf16-instructions.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/bf16-instructions.ll
@@ -0,0 +1,88 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | FileCheck %s
+; RUN: %if ptxas-11.0 %{ llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | %ptxas-verify -arch=sm_80 %}
+
+
+; CHECK-LABEL: test_fadd(
+; CHECK-DAG:  ld.param.b16[[A:%h[0-9]+]], [test_fadd_param_0];
+; CHECK-DAG:  ld.param.b16[[B:%h[0-9]+]], [test_fadd_param_1];
+; CHECK-NEXT: add.rn.bf16 [[R:%f[0-9]+]], [[A]], [[B]];
+; CHECK-NEXT: st.param.b16[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define bfloat @test_fadd(bfloat %0, bfloat %1) {
+  %3 = fadd bfloat %0, %1 
+  ret bfloat %3
+}
+
+; CHECK-LABEL: test_fsub(
+; CHECK-DAG:  ld.param.b16[[A:%h[0-9]+]], [test_fsub_param_0];
+; CHECK-DAG:  ld.param.b16[[B:%h[0-9]+]], [test_fsub_param_1];
+; CHECK-NEXT: sub.rn.bf16 [[R:%f[0-9]+]], [[A]], [[B]];
+; CHECK-NEXT: st.param.b16[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define bfloat @test_fsub(bfloat %0, bfloat %1) {
+  %3 = fsub bfloat %0, %1 
+  ret bfloat %3
+}
+
+; CHECK-LABEL: test_faddx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_faddx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_faddx2_param_1];
+; CHECK-NEXT: add.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_faddx2(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fadd <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fsubx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fsubx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fsubx2_param_1];
+; CHECK-NEXT: sub.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_fsubx2(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fsub <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fmulx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fmulx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fmulx2_param_1];
+; CHECK-NEXT: mul.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_fmul(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fmul <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fdiv(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fdiv_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fdiv_param_1];
+; CHECK-DAG:  mov.b32 {[[A0:%h[0-9]+]], [[A1:%h[0-9]+]]}, [[A]]
+; CHECK-DAG:  mov.b32 {[[B0:%h[0-9]+]], [[B1:%h[0-9]+]]}, [[B]]
+; CHECK-DAG:  cvt.f32.bf16 [[FA0:%f[0-9]+]], [[A0]];
+; CHECK-DAG:  cvt.f32.bf16 [[FA1:%f[0-9]+]], [[A1]];
+; CHECK-DAG:  cvt.f32.bf16 [[FB0:%f[0-9]+]], [[B0]];
+; CHECK-DAG:  cvt.f32.bf16 [[FB1:%f[0-9]+]], [[B1]];
+; CHECK-DAG:  div.rn.f32  [[FR0:%f[0-9]+]], [[FA0]], [[FB0]];
+; CHECK-DAG:  div.rn.f32  [[FR1:%f[0-9]+]], [[FA1]], [[FB1]];
+; CHECK-DAG:  cvt.rn.bf16.f32  [[R0:%h[0-9]+]], [[FR0]];
+; CHECK-DAG:  cvt.rn.bf16.f32  [[R1:%h[0-9]+]], [[FR1]];
+; CHECK-NEXT: mov.b32 [[R:%hh[0-9]+]], {[[R0]], [[R1]]}
+; CHECK-NEXT: st.param.b32[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define <2 x bfloat> @test_fdiv(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fdiv <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
Index: llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
===
--- llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
+++ llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
@@ -204,6 +204,14 @@
   return {Intrinsic::fma, FTZ_MustBeOff, true};
 case 

[PATCH] D150528: [Clang][Attribute] Improve the AST/diagnoses fidelity of alignas and _Alignas

2023-05-25 Thread Yurong 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 rGf75b73549d4a: [Clang][Attribute] Improve the AST/diagnoses 
fidelity of alignas and _Alignas (authored by yronglin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150528

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/AttrImpl.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/AST/ast-dump-attr.cpp
  clang/test/Sema/aix-attr-aligned-vector-warn.c
  clang/test/Sema/aix-attr-aligned-vector-warn.cpp
  clang/test/Sema/sizeless-1.c
  clang/test/SemaCXX/attr-cxx0x.cpp
  clang/test/SemaCXX/builtin-align-cxx.cpp
  clang/test/SemaCXX/cxx11-attr-print.cpp
  clang/test/SemaCXX/sizeless-1.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -508,6 +508,16 @@
   OS << "assert(!is" << getLowerName() << "Expr);\n";
   OS << "return " << getLowerName() << "Type;\n";
   OS << "  }";
+
+  OS << "  std::optional getCached" << getUpperName()
+ << "Value() const {\n";
+  OS << "return " << getLowerName() << "Cache;\n";
+  OS << "  }";
+
+  OS << "  void setCached" << getUpperName()
+ << "Value(unsigned AlignVal) {\n";
+  OS << "" << getLowerName() << "Cache = AlignVal;\n";
+  OS << "  }";
 }
 
 void writeAccessorDefinitions(raw_ostream ) const override {
@@ -530,21 +540,6 @@
   OS << "  return " << getLowerName()
  << "Type->getType()->containsErrors();\n";
   OS << "}\n";
-
-  // FIXME: Do not do the calculation here
-  // FIXME: Handle types correctly
-  // A null pointer means maximum alignment
-  OS << "unsigned " << getAttrName() << "Attr::get" << getUpperName()
- << "(ASTContext ) const {\n";
-  OS << "  assert(!is" << getUpperName() << "Dependent());\n";
-  OS << "  if (is" << getLowerName() << "Expr)\n";
-  OS << "return " << getLowerName() << "Expr ? " << getLowerName()
- << "Expr->EvaluateKnownConstInt(Ctx).getZExtValue()"
- << " * Ctx.getCharWidth() : "
- << "Ctx.getTargetDefaultAlignForAttributeAligned();\n";
-  OS << "  else\n";
-  OS << "return 0; // FIXME\n";
-  OS << "}\n";
 }
 
 void writeASTVisitorTraversal(raw_ostream ) const override {
@@ -601,7 +596,8 @@
   OS << "union {\n";
   OS << "Expr *" << getLowerName() << "Expr;\n";
   OS << "TypeSourceInfo *" << getLowerName() << "Type;\n";
-  OS << "};";
+  OS << "};\n";
+  OS << "std::optional " << getLowerName() << "Cache;\n";
 }
 
 void writePCHReadArgs(raw_ostream ) const override {
@@ -628,14 +624,21 @@
 }
 
 std::string getIsOmitted() const override {
-  return "!is" + getLowerName().str() + "Expr || !" + getLowerName().str()
- + "Expr";
+  return "!((is" + getLowerName().str() + "Expr && " +
+ getLowerName().str() + "Expr) || (!is" + getLowerName().str() +
+ "Expr && " + getLowerName().str() + "Type))";
 }
 
 void writeValue(raw_ostream ) const override {
   OS << "\";\n";
-  OS << "" << getLowerName()
+  OS << "if (is" << getLowerName() << "Expr && " << getLowerName()
+ << "Expr)";
+  OS << "  " << getLowerName()
  << "Expr->printPretty(OS, nullptr, Policy);\n";
+  OS << "if (!is" << getLowerName() << "Expr && " << getLowerName()
+ << "Type)";
+  OS << "  " << getLowerName()
+ << "Type->getType().print(OS, Policy);\n";
   OS << "OS << \"";
 }
 
Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -73,7 +73,7 @@
   svint8_t __attribute__((aligned(4))) aligned_int8_2; // expected-error {{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
   svint8_t _Alignas(int) aligned_int8_3;   // expected-error {{'_Alignas' attribute cannot be applied to sizeless type 'svint8_t'}}
 
-  int _Alignas(svint8_t) aligned_int; // expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
+  int _Alignas(svint8_t) aligned_int; // expected-error {{invalid application of '_Alignas' to sizeless type 'svint8_t'}}
 
   // Using pointers to sizeless data isn't wrong here, but because the
   // type is incomplete, it doesn't provide any alignment 

[clang] f75b735 - [Clang][Attribute] Improve the AST/diagnoses fidelity of alignas and _Alignas

2023-05-25 Thread via cfe-commits

Author: yronglin
Date: 2023-05-26T07:41:26+08:00
New Revision: f75b73549d4adb7e111444f4144af7bffb532f91

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

LOG: [Clang][Attribute] Improve the AST/diagnoses fidelity of alignas and 
_Alignas

- Fix diagnoses when the argument to `alignas` or `_Alignas` is an incomplete 
type.

Before:
```
./alignas.cpp:1:15: error: invalid application of 'alignof' to an incomplete 
type 'void'
class alignas(void) Foo {};
 ~^
1 error generated.
```
Now:
```
./alignas.cpp:1:15: error: invalid application of 'alignas' to an incomplete 
type 'void'
class alignas(void) Foo {};
 ~^
1 error generated.
```

- Improve the AST fidelity of `alignas` and `_Alignas` attribute.

Before:
```
AlignedAttr 0x13f07f278  alignas
`-ConstantExpr 0x13f07f258  'unsigned long'
  |-value: Int 8
  `-UnaryExprOrTypeTraitExpr 0x13f07f118  'unsigned long' 
alignof 'void *'
```

Now:
```
AlignedAttr 0x14288c608  alignas 'void *'
```

Reviewed By: erichkeane

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

Added: 
clang/test/Sema/aix-attr-aligned-vector-warn.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/ParsedAttr.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/AttrImpl.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/AST/ast-dump-attr.cpp
clang/test/Sema/aix-attr-aligned-vector-warn.c
clang/test/Sema/sizeless-1.c
clang/test/SemaCXX/attr-cxx0x.cpp
clang/test/SemaCXX/builtin-align-cxx.cpp
clang/test/SemaCXX/cxx11-attr-print.cpp
clang/test/SemaCXX/sizeless-1.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7a936051fe051..f1cc205c4a430 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -256,6 +256,9 @@ Attribute Changes in Clang
   the compilation of the foreign language sources (e.g. Swift).
 - The ``__has_attribute``, ``__has_c_attribute`` and ``__has_cpp_attribute``
   preprocessor operators now return 1 also for attributes defined by plugins.
+- Improve the AST fidelity of ``alignas`` and ``_Alignas`` attribute. Before, 
we 
+  model ``alignas(type-id)`` as though the user wrote 
``alignas(alignof(type-id))``,
+  now we directly use ``alignas(type-id)``.
 
 Improvements to Clang's diagnostics
 ---
@@ -307,6 +310,10 @@ Improvements to Clang's diagnostics
   (`#62850: `_).
 - Clang now warns when any predefined macro is undefined or redefined, instead
   of only some of them.
+- Clang now correctly diagnoses when the argument to ``alignas`` or 
``_Alignas`` 
+  is an incomplete type.
+  (`#55175: `_, and fixes an
+  incorrect mention of ``alignof`` in a diagnostic about ``alignas``).
 
 Bug Fixes in This Version
 -

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 1f4ccd0a3f3a0..43ea50a71f744 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -3004,8 +3004,9 @@ class Parser : public CodeCompletionHandler {
  SourceLocation EndLoc);
   void ParseAtomicSpecifier(DeclSpec );
 
-  ExprResult ParseAlignArgument(SourceLocation Start,
-SourceLocation );
+  ExprResult ParseAlignArgument(StringRef KWName, SourceLocation Start,
+SourceLocation , bool ,
+ParsedType );
   void ParseAlignmentSpecifier(ParsedAttributes ,
SourceLocation *endLoc = nullptr);
   ExprResult ParseExtIntegerArgument();

diff  --git a/clang/include/clang/Sema/ParsedAttr.h 
b/clang/include/clang/Sema/ParsedAttr.h
index 3612e9244f328..592580bccd234 100644
--- a/clang/include/clang/Sema/ParsedAttr.h
+++ b/clang/include/clang/Sema/ParsedAttr.h
@@ -273,12 +273,13 @@ class ParsedAttr final
   /// Constructor for attributes with a single type argument.
   ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange,
  IdentifierInfo *scopeName, SourceLocation scopeLoc,
- ParsedType typeArg, Form formUsed)
+ ParsedType typeArg, Form formUsed, SourceLocation ellipsisLoc)
   : AttributeCommonInfo(attrName, scopeName, attrRange, scopeLoc, 
formUsed),
-NumArgs(0), Invalid(false), UsedAsTypeAttr(false),
-IsAvailability(false), 

[PATCH] D150528: [Clang][Attribute] Improve the AST/diagnoses fidelity of alignas and _Alignas

2023-05-25 Thread Yurong via Phabricator via cfe-commits
yronglin marked 2 inline comments as done.
yronglin added a comment.

The libcxx CI failure seems not caused bye this patch, I have found that there 
have a patch to fix this issue. https://reviews.llvm.org/D151508


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150528

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


[PATCH] D151517: Fix couple of problems in uses_allocators clause.

2023-05-25 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Could you split it into 3 separate patches?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151517

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


[PATCH] D151517: Fix couple of problems in uses_allocators clause.

2023-05-25 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 created this revision.
jyu2 added reviewers: ABataev, jdoerfert.
jyu2 added projects: OpenMP, clang.
Herald added a project: All.
jyu2 requested review of this revision.
Herald added subscribers: openmp-commits, cfe-commits, jplehr, sstefan1.

1> Fix wrong error message when compiling C souce code:
Currently emit error as following for uses_allocators(alloc(traits)):

called object type 'omp_allocator_handle_t' (aka
'enum omp_allocator_handle_t') is not a function or function pointer

To fix this, since "alloc" is Id expresison(spce 5.2), during the parser
(in ParseOpenMP.cpp), using tryParseCXXIdExpression instead of
ParseExpression for C.

2> Fix runtime problem when call to __kmpc_init_allocator
It seem load of traits.addr should be passed in rumtime call.  Curently
the load of load traits.addr gets passed cause runtime to fail.

3> change to use CGF.EmitAutoVarAlloca(allocator) instead
CGF.EmitVarDecl(allocator).
If I understant correct, it is not necessary to emit variable init,
since "allocator" is private to target region.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151517

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/test/OpenMP/target_parallel_for_simd_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_parallel_for_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_parallel_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_simd_uses_allocators_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_uses_allocators_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_teams_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_uses_allocators.c
  clang/test/OpenMP/target_uses_allocators_codegen.cpp
  openmp/libomptarget/test/mapping/target_uses_allocator.c

Index: openmp/libomptarget/test/mapping/target_uses_allocator.c
===
--- /dev/null
+++ openmp/libomptarget/test/mapping/target_uses_allocator.c
@@ -0,0 +1,56 @@
+// RUN: %libomptarget-compile-run-and-check-generic
+
+#include 
+#include 
+
+#define N 1024
+
+int test_omp_aligned_alloc_on_device() {
+  int errors = 0;
+
+  omp_memspace_handle_t memspace = omp_default_mem_space;
+  omp_alloctrait_t traits[2] = {{omp_atk_alignment, 64}, {omp_atk_access, 64}};
+  omp_allocator_handle_t alloc =
+  omp_init_allocator(omp_default_mem_space, 1, traits);
+
+#pragma omp target map(tofrom : errors) uses_allocators(alloc(traits))
+  {
+int *x;
+int not_correct_array_values = 0;
+
+x = (int *)omp_aligned_alloc(64, N * sizeof(int), alloc);
+if (x == NULL) {
+  errors++;
+} else {
+#pragma omp parallel for simd simdlen(16) aligned(x : 64)
+  for (int i = 0; i < N; i++) {
+x[i] = i;
+  }
+
+#pragma omp parallel for simd simdlen(16) aligned(x : 64)
+  for (int i = 0; i < N; i++) {
+if (x[i] != i) {
+#pragma omp atomic write
+  not_correct_array_values = 1;
+}
+  }
+  if (not_correct_array_values) {
+errors++;
+  }
+  omp_free(x, alloc);
+}
+  }
+
+  omp_destroy_allocator(alloc);
+
+  return errors;
+}
+
+int main() {
+  int errors = 0;
+  if (test_omp_aligned_alloc_on_device())
+printf("FAILE\n");
+  else
+// CHECK: PASSED
+printf("PASSED\n");
+}
Index: clang/test/OpenMP/target_uses_allocators_codegen.cpp
===
--- clang/test/OpenMP/target_uses_allocators_codegen.cpp
+++ clang/test/OpenMP/target_uses_allocators_codegen.cpp
@@ -78,8 +78,7 @@
 // CHECK: [[TRAITS_ADDR_REF:%.+]] = alloca ptr,
 // CHECK: [[MY_ALLOCATOR_ADDR:%.+]] = alloca i64,
 // CHECK: [[TRAITS_ADDR:%.+]] = load ptr, ptr [[TRAITS_ADDR_REF]],
-// CHECK: [[TRAITS:%.+]] = load ptr, ptr [[TRAITS_ADDR]],
-// CHECK: [[ALLOCATOR:%.+]] = call ptr @__kmpc_init_allocator(i32 %{{.+}}, ptr null, i32 10, ptr [[TRAITS]])
+// CHECK: [[ALLOCATOR:%.+]] = call ptr @__kmpc_init_allocator(i32 %{{.+}}, ptr null, i32 10, ptr [[TRAITS_ADDR]])
 // CHECK: [[CONV:%.+]] = ptrtoint ptr [[ALLOCATOR]] to i64
 // CHECK: store i64 [[CONV]], ptr [[MY_ALLOCATOR_ADDR]],
 
Index: clang/test/OpenMP/target_uses_allocators.c
===
--- clang/test/OpenMP/target_uses_allocators.c
+++ clang/test/OpenMP/target_uses_allocators.c
@@ -2,6 +2,8 @@
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50  -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -verify -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ 

[PATCH] D151383: [clang-tidy] Check for specific return types on all functions

2023-05-25 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:394
 
+- Extend ``bugprone-unused-return-value`` check to check for all functions
+  with specified return types using the ``CheckedReturnTypes`` option.

Please keep alphabetical order in section (by check name).



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst:53
+   By default the following function return types are checked:
+   ``std::error_code std::expected boost::system::error_code abseil::Status``
+

Please use single back-tick for option values.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151383

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


[PATCH] D151383: [clang-tidy] Check for specific return types on all functions

2023-05-25 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav added a comment.

please let me know if there is better way to do the matching 
`hasAnyReturnType`.  We could also sort then do binarysearch instead of looping 
through the list of ret types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151383

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


[PATCH] D151383: [clang-tidy] Check for specific return types on all functions

2023-05-25 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav updated this revision to Diff 525855.
chaitanyav added a comment.

Add tests, update docs and extend matchcallexpr


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151383

Files:
  clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-return-value.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-return-value.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-return-value.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-return-value.cpp
@@ -52,6 +52,9 @@
   bool empty() const noexcept;
 };
 
+class error_code {
+};
+
 // the check should be able to match std lib calls even if the functions are
 // declared inside inline namespaces
 inline namespace v1 {
@@ -72,6 +75,10 @@
 
 void useFuture(const std::future );
 
+std::error_code errorFunc() {
+return std::error_code();
+}
+
 void warning() {
   std::async(increment, 42);
   // CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used
@@ -185,6 +192,10 @@
 // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
 // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
   }
+
+  errorFunc();
+  // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
+  // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
 }
 
 void noWarning() {
@@ -209,6 +220,8 @@
   std::vector VecNoWarning;
   auto VecEmptyRetval = VecNoWarning.empty();
 
+  (void) errorFunc();
+
   // test using the return value in different kinds of expressions
   useFuture(std::async(increment, 42));
   std::launder()->f();
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
@@ -46,5 +46,11 @@
  return value often indicates that the programmer confused the function with
  ``clear()``.
 
+.. option:: CheckedReturnTypes
+
+   Semicolon-separated list of function return types to check.
+   By default the following function return types are checked:
+   ``std::error_code std::expected boost::system::error_code abseil::Status``
+
 `cert-err33-c <../cert/err33-c.html>`_ is an alias of this check that checks a
 fixed and large set of standard library functions.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -391,6 +391,9 @@
   `: warn on ``const &&``
   constructors.
 
+- Extend ``bugprone-unused-return-value`` check to check for all functions
+  with specified return types using the ``CheckedReturnTypes`` option.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.h
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.h
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.h
@@ -27,6 +27,7 @@
 
 private:
   std::string CheckedFunctions;
+  std::string CheckedReturnTypes;
 };
 
 } // namespace clang::tidy::bugprone
Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -28,6 +28,17 @@
   Finder, Builder);
 }
 
+// Checks if the function return type is in CheckedReturnedTypes
+AST_MATCHER_P(FunctionDecl, hasAnyReturnType, std::vector,
+  RetTypes) {
+  auto FuncRetType = Node.getReturnType().getAsString();
+  for (const auto RetType : RetTypes) {
+if (RetType == FuncRetType) {
+  return true;
+}
+  }
+  return false;
+}
 } // namespace
 
 UnusedReturnValueCheck::UnusedReturnValueCheck(llvm::StringRef Name,
@@ -124,19 +135,28 @@
"::sigismember;"
"::strcasecmp;"
"::strsignal;"
-   "::ttyname")) {}
+   "::ttyname")),
+  CheckedReturnTypes(Options.get("CheckedReturnTypes",
+ "std::error_code;"
+ "std::expected;"
+ "boost::system::error_code;"
+

[PATCH] D151515: [CodeGen] add additional cast when checking call arguments

2023-05-25 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 created this revision.
HerrCai0907 added reviewers: shafik, erichkeane, aaron.ballman.
Herald added a project: All.
HerrCai0907 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixed: https://github.com/llvm/llvm-project/issues/62945
c++20 supports "Permit conversions to arrays of unknown bound".
This make it possible that ConstantArrayType is function parameter
but IncompleteArrayType is argument (initializer list).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151515

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp


Index: clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp
===
--- clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp
+++ clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp
@@ -23,4 +23,13 @@
 
   return r2;
 }
+
+// CHECK-LABEL: @_ZN3One3fooEi
+// CHECK-NEXT: entry:
+// CHECK-NEXT: ret void
+void foo(int a) {
+  auto f = [](int(&&)[]) {};
+  f({a});
+}
+
 } // namespace One
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -4369,14 +4369,19 @@
 CallExpr::const_arg_iterator Arg = ArgRange.begin();
 for (QualType Ty : ArgTypes) {
   assert(Arg != ArgRange.end() && "Running over edge of argument list!");
-  assert(
-  (isGenericMethod || Ty->isVariablyModifiedType() ||
-   Ty.getNonReferenceType()->isObjCRetainableType() ||
-   getContext()
-   .getCanonicalType(Ty.getNonReferenceType())
-   .getTypePtr() ==
-   getContext().getCanonicalType((*Arg)->getType()).getTypePtr()) 
&&
-  "type mismatch in call argument!");
+  // argument can be ConstantArrayType and parameter can be 
IncompleteArrayType
+  const Type *CanonicalTy = getContext()
+.getCanonicalType(Ty.getNonReferenceType())
+.getTypePtr()
+->getPointeeOrArrayElementType();
+  const Type *CanonicalArgTy = getContext()
+   .getCanonicalType((*Arg)->getType())
+   .getTypePtr()
+   ->getPointeeOrArrayElementType();
+  assert((isGenericMethod || Ty->isVariablyModifiedType() ||
+  Ty.getNonReferenceType()->isObjCRetainableType() ||
+  CanonicalTy == CanonicalArgTy) &&
+ "type mismatch in call argument!");
   ++Arg;
 }
 


Index: clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp
===
--- clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp
+++ clang/test/CodeGenCXX/cxx20-p0388-unbound-ary.cpp
@@ -23,4 +23,13 @@
 
   return r2;
 }
+
+// CHECK-LABEL: @_ZN3One3fooEi
+// CHECK-NEXT: entry:
+// CHECK-NEXT: ret void
+void foo(int a) {
+  auto f = [](int(&&)[]) {};
+  f({a});
+}
+
 } // namespace One
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -4369,14 +4369,19 @@
 CallExpr::const_arg_iterator Arg = ArgRange.begin();
 for (QualType Ty : ArgTypes) {
   assert(Arg != ArgRange.end() && "Running over edge of argument list!");
-  assert(
-  (isGenericMethod || Ty->isVariablyModifiedType() ||
-   Ty.getNonReferenceType()->isObjCRetainableType() ||
-   getContext()
-   .getCanonicalType(Ty.getNonReferenceType())
-   .getTypePtr() ==
-   getContext().getCanonicalType((*Arg)->getType()).getTypePtr()) &&
-  "type mismatch in call argument!");
+  // argument can be ConstantArrayType and parameter can be IncompleteArrayType
+  const Type *CanonicalTy = getContext()
+.getCanonicalType(Ty.getNonReferenceType())
+.getTypePtr()
+->getPointeeOrArrayElementType();
+  const Type *CanonicalArgTy = getContext()
+   .getCanonicalType((*Arg)->getType())
+   .getTypePtr()
+   ->getPointeeOrArrayElementType();
+  assert((isGenericMethod || Ty->isVariablyModifiedType() ||
+  Ty.getNonReferenceType()->isObjCRetainableType() ||
+  CanonicalTy == CanonicalArgTy) &&
+ "type mismatch in call argument!");
   ++Arg;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151509: [Driver][X86] Reject unsupported value for -mabi=

2023-05-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: aaron.ballman, arichardson, craig.topper, erichkeane, 
pengfei.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

-mabi= was incorrectly claimed before D134671 
. -mabi=sysv appears to be
somewhat common in open-source packages, even if it was not intended to
be supported by Clang.
(For common options supported by multiple architectures, it's easy to
forget to report an error on unsupported targets. Unfortunately
the driver infrastructure doesn't make this less error-prone.)

On x86, support -mabi=sysv for non-Windows targets and -mabi=ms for Windows,
and remove the spurious -Wunused-command-line-argument warning.

With this change, all popular architectures claim -mabi=, so we don't
have to worry much about -Wunused-command-line-argument for other
architectures.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151509

Files:
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/mabi.c
  clang/test/Driver/x86-mabi.c


Index: clang/test/Driver/x86-mabi.c
===
--- /dev/null
+++ clang/test/Driver/x86-mabi.c
@@ -0,0 +1,11 @@
+// RUN: %clang -### --target=x86_64-windows-msvc -mabi=ms -S %s 2>&1 | 
FileCheck %s
+// RUN: %clang -### --target=i386-unknown-linux -mabi=ms -S %s 2>&1 | 
FileCheck --check-prefix=ERR %s
+// RUN: %clang -### --target=x86_64-windows-msvc -mabi=sysv -S %s 2>&1 | 
FileCheck --check-prefix=ERR %s
+// RUN: %clang -### --target=i386-unknown-linux -mabi=sysv -S %s 2>&1 | 
FileCheck %s
+
+// CHECK-NOT: {{error|warning}}:
+// ERR: error: unsupported option '-mabi=' for target '{{.*}}'
+
+int f() {
+  return 0;
+}
Index: clang/test/Driver/mabi.c
===
--- clang/test/Driver/mabi.c
+++ /dev/null
@@ -1,6 +0,0 @@
-// RUN: %clang --target=i386-unknown-linux -mabi=ms -S %s -### 2>&1 | 
FileCheck --check-prefix=CHECK %s
-
-int f() {
-  // CHECK: warning: argument unused during compilation: '-mabi=ms'
-  return 0;
-}
Index: clang/lib/Driver/ToolChains/Arch/X86.cpp
===
--- clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -119,6 +119,15 @@
 void x86::getX86TargetFeatures(const Driver , const llvm::Triple ,
const ArgList ,
std::vector ) {
+  // Claim and report unsupported -mabi=. Note: we don't support "sysv_abi" or
+  // "ms_abi" as default function attributes.
+  if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mabi_EQ)) {
+StringRef DefaultAbi = Triple.isOSWindows() ? "ms" : "sysv";
+if (A->getValue() != DefaultAbi)
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getSpelling() << Triple.getTriple();
+  }
+
   // If -march=native, autodetect the feature list.
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
 if (StringRef(A->getValue()) == "native") {


Index: clang/test/Driver/x86-mabi.c
===
--- /dev/null
+++ clang/test/Driver/x86-mabi.c
@@ -0,0 +1,11 @@
+// RUN: %clang -### --target=x86_64-windows-msvc -mabi=ms -S %s 2>&1 | FileCheck %s
+// RUN: %clang -### --target=i386-unknown-linux -mabi=ms -S %s 2>&1 | FileCheck --check-prefix=ERR %s
+// RUN: %clang -### --target=x86_64-windows-msvc -mabi=sysv -S %s 2>&1 | FileCheck --check-prefix=ERR %s
+// RUN: %clang -### --target=i386-unknown-linux -mabi=sysv -S %s 2>&1 | FileCheck %s
+
+// CHECK-NOT: {{error|warning}}:
+// ERR: error: unsupported option '-mabi=' for target '{{.*}}'
+
+int f() {
+  return 0;
+}
Index: clang/test/Driver/mabi.c
===
--- clang/test/Driver/mabi.c
+++ /dev/null
@@ -1,6 +0,0 @@
-// RUN: %clang --target=i386-unknown-linux -mabi=ms -S %s -### 2>&1 | FileCheck --check-prefix=CHECK %s
-
-int f() {
-  // CHECK: warning: argument unused during compilation: '-mabi=ms'
-  return 0;
-}
Index: clang/lib/Driver/ToolChains/Arch/X86.cpp
===
--- clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -119,6 +119,15 @@
 void x86::getX86TargetFeatures(const Driver , const llvm::Triple ,
const ArgList ,
std::vector ) {
+  // Claim and report unsupported -mabi=. Note: we don't support "sysv_abi" or
+  // "ms_abi" as default function attributes.
+  if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mabi_EQ)) {
+StringRef DefaultAbi = Triple.isOSWindows() ? "ms" : "sysv";
+if (A->getValue() != DefaultAbi)
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << 

[PATCH] D151325: [analyzer] Differentiate lifetime extended temporaries

2023-05-25 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I totally support this! There's no reason why the region wouldn't carry such 
information.

This patch is surprisingly tiny, but this matches my grep observations: almost 
nothing in the static analyzer treats `CXXTempObjectRegion` specially. Even in 
case of live symbols/regions analysis, it simply relies on how temporary region 
is bound in the Store to the lifetime-extending reference, so it doesn't need 
to be handled explicitly.

I see that there's no change in `MoveChecker` which treats 
`CXXTempObjectRegion` specially, and I suspect it may start emitting more 
warnings after this patch, but I'm not sure if it's a good thing or a bad 
thing. Could be worth experimenting (eg. by analyzing LLVM itself, it has 
enough move semantics to demonstrate potential problems).

Do you have any preferences on creating a common base class for 
`CXXTempObjectRegion` and `CXXLifetimeExtendedObjectRegion`? Or, as an opposite 
extreme, simply add a nullable `ExD` field to `CXXTempObjectRegion` instead of 
making a new class? Both could save us some code when these regions do need to 
be treated uniformly, but it doesn't look like a popular situation to worry 
about.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151325

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


[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Lily Orth-Smith via Phabricator via cfe-commits
electriclilies updated this revision to Diff 525831.
electriclilies added a comment.

format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

Files:
  mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
  mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
  mlir/test/Dialect/LLVMIR/call-intrin.mlir


Index: mlir/test/Dialect/LLVMIR/call-intrin.mlir
===
--- mlir/test/Dialect/LLVMIR/call-intrin.mlir
+++ mlir/test/Dialect/LLVMIR/call-intrin.mlir
@@ -11,7 +11,7 @@
 llvm.func @round_sse41() -> vector<4xf32> {
 %0 = llvm.mlir.constant(1 : i32) : i32
 %1 = llvm.mlir.constant(dense<0.2> : vector<4xf32>) : vector<4xf32>
-%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : 
(vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {}
+%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : 
(vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {fastmathFlags = 
#llvm.fastmath}
 llvm.return %res: vector<4xf32>
 }
 
Index: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
@@ -95,7 +95,7 @@
 
 /// Builder for LLVM_CallIntrinsicOp
 static LogicalResult
-convertCallLLVMIntrinsicOp(CallIntrinsicOp , llvm::IRBuilderBase ,
+convertCallLLVMIntrinsicOp(CallIntrinsicOp op, llvm::IRBuilderBase ,
LLVM::ModuleTranslation ) {
   llvm::Module *module = builder.GetInsertBlock()->getModule();
   llvm::Intrinsic::ID id =
@@ -114,6 +114,8 @@
   } else {
 fn = llvm::Intrinsic::getDeclaration(module, id, {});
   }
+  FastmathFlagsInterface itf = op;
+  builder.setFastMathFlags(getFastmathFlags(itf));
 
   auto *inst =
   builder.CreateCall(fn, moduleTranslation.lookupValues(op.getOperands()));
Index: mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
===
--- mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
+++ mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
@@ -867,19 +867,24 @@
 // CallIntrinsicOp
 //======//
 
-def LLVM_CallIntrinsicOp : LLVM_Op<"call_intrinsic"> {
+def LLVM_CallIntrinsicOp
+: LLVM_Op<"call_intrinsic",
+  [DeclareOpInterfaceMethods]> {
   let summary = "Call to an LLVM intrinsic function.";
   let description = [{
 Call the specified llvm intrinsic. If the intrinsic is overloaded, use
 the MLIR function type of this op to determine which intrinsic to call.
 }];
-  let arguments = (ins StrAttr:$intrin, Variadic:$args);
+  let arguments = (ins StrAttr:$intrin, Variadic:$args,
+   DefaultValuedAttr:$fastmathFlags);
   let results = (outs Variadic:$results);
   let llvmBuilder = [{
 return convertCallLLVMIntrinsicOp(op, builder, moduleTranslation);
   }];
   let assemblyFormat = [{
-$intrin `(` $args `)` `:` functional-type($args, $results) attr-dict
+$intrin `(` $args `)` `:` functional-type($args, $results)
+  custom(attr-dict)
   }];
 }
 


Index: mlir/test/Dialect/LLVMIR/call-intrin.mlir
===
--- mlir/test/Dialect/LLVMIR/call-intrin.mlir
+++ mlir/test/Dialect/LLVMIR/call-intrin.mlir
@@ -11,7 +11,7 @@
 llvm.func @round_sse41() -> vector<4xf32> {
 %0 = llvm.mlir.constant(1 : i32) : i32
 %1 = llvm.mlir.constant(dense<0.2> : vector<4xf32>) : vector<4xf32>
-%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : (vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {}
+%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : (vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {fastmathFlags = #llvm.fastmath}
 llvm.return %res: vector<4xf32>
 }
 
Index: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
@@ -95,7 +95,7 @@
 
 /// Builder for LLVM_CallIntrinsicOp
 static LogicalResult
-convertCallLLVMIntrinsicOp(CallIntrinsicOp , llvm::IRBuilderBase ,
+convertCallLLVMIntrinsicOp(CallIntrinsicOp op, llvm::IRBuilderBase ,
LLVM::ModuleTranslation ) {
   llvm::Module *module = builder.GetInsertBlock()->getModule();
   llvm::Intrinsic::ID id =
@@ -114,6 +114,8 @@
   } else {
 fn = llvm::Intrinsic::getDeclaration(module, id, {});
   }
+  FastmathFlagsInterface itf = op;
+  builder.setFastMathFlags(getFastmathFlags(itf));
 
   auto *inst =
   builder.CreateCall(fn, 

[PATCH] D127660: [clang][lex] NFCI: Use DirectoryEntryRef in Preprocessor::MainFileDir

2023-05-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 marked an inline comment as done.
jansvoboda11 added inline comments.
Herald added a subscriber: ributzka.



Comment at: clang/lib/Frontend/FrontendAction.cpp:507
   // be resolved relative to the build directory of the module map file.
-  CI.getPreprocessor().setMainFileDir(M->Directory);
+  CI.getPreprocessor().setMainFileDir(*M->Directory);
 

bnbarham wrote:
> Same as in previous review, is this guaranteed to be set? Might be worth a 
> comment on the field itself if so (in https://reviews.llvm.org/D127654)
It is. Couple lines above we call `HeaderSearch::lookupModule()`, which parses 
the defining module map and sets the `Directory`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127660

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


[PATCH] D127654: [clang] NFCI: Use DirectoryEntryRef in Module::Directory

2023-05-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 marked 2 inline comments as done.
jansvoboda11 added inline comments.
Herald added a subscriber: ributzka.



Comment at: clang/include/clang/Basic/Module.h:138
   /// are found.
-  const DirectoryEntry *Directory = nullptr;
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr Directory;
 

bnbarham wrote:
> Too many places to update I assume?
Yes.



Comment at: clang/lib/Lex/ModuleMap.cpp:178
   // Search for the header file within the module's home directory.
-  auto *Directory = M->Directory;
+  auto Directory = M->Directory;
   SmallString<128> FullPathName(Directory->getName());

bnbarham wrote:
> Does a module always have a directory?
No. Only a module we have read module map for. Module we only read from the PCM 
(and perhaps a standard C++ module) will not have a directory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127654

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


[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Lily Orth-Smith via Phabricator via cfe-commits
electriclilies added inline comments.



Comment at: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp:98
 static LogicalResult
 convertCallLLVMIntrinsicOp(CallIntrinsicOp , llvm::IRBuilderBase ,
LLVM::ModuleTranslation ) {

electriclilies wrote:
> Mogball wrote:
> > Mogball wrote:
> > > electriclilies wrote:
> > > > Mogball wrote:
> > > > > Mogball wrote:
> > > > > > electriclilies wrote:
> > > > > > > Mogball wrote:
> > > > > > > > I think the problem with the cast below is that this is passed 
> > > > > > > > by reference. You should not pass operation handles by 
> > > > > > > > reference.
> > > > > > > I think I can't pass it by value because it's const though.. 
> > > > > > where is it const?
> > > > > if it were const, it wouldn't bind to a non-const reference anyways
> > > > If I just try to pass the op into the dyn_cast, it gives this error, 
> > > > which says that the op is a const
> > > > ```
> > > > /home/lily/modular/third-party/llvm-project/llvm/include/llvm/Support/Casting.h:64:65:
> > > >  error: cannot initialize a parameter of type 'mlir::Operation *' with 
> > > > an rvalue of type 'const mlir::LLVM::CallIntrinsicOp *
> > > > ```
> > > did you drop the reference?
> > ```
> > CallIntrinsicOp 
> > ```
> > 
> > delete the `&`. You should never do this for ops anyways
> OK, I think I can upcast it to an Operation& to avoid this, and get rid of 
> the copy
Dropped the reference, it works now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

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


[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Jeff Niu via Phabricator via cfe-commits
Mogball accepted this revision.
Mogball added inline comments.
This revision is now accepted and ready to land.



Comment at: mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td:878
 }];
-  let arguments = (ins StrAttr:$intrin, Variadic:$args);
+  let arguments = (ins StrAttr:$intrin, Variadic:$args, 
DefaultValuedAttr:$fastmathFlags);
   let results = (outs Variadic:$results);

here as well please



Comment at: mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td:883
   }];
   let assemblyFormat = [{
+$intrin `(` $args `)` `:` functional-type($args, $results) 
custom(attr-dict)

and this one


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

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


[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Lily Orth-Smith via Phabricator via cfe-commits
electriclilies updated this revision to Diff 525815.
electriclilies added a comment.

fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

Files:
  mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
  mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
  mlir/test/Dialect/LLVMIR/call-intrin.mlir


Index: mlir/test/Dialect/LLVMIR/call-intrin.mlir
===
--- mlir/test/Dialect/LLVMIR/call-intrin.mlir
+++ mlir/test/Dialect/LLVMIR/call-intrin.mlir
@@ -11,7 +11,7 @@
 llvm.func @round_sse41() -> vector<4xf32> {
 %0 = llvm.mlir.constant(1 : i32) : i32
 %1 = llvm.mlir.constant(dense<0.2> : vector<4xf32>) : vector<4xf32>
-%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : 
(vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {}
+%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : 
(vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {fastmathFlags = 
#llvm.fastmath}
 llvm.return %res: vector<4xf32>
 }
 
Index: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
@@ -95,7 +95,7 @@
 
 /// Builder for LLVM_CallIntrinsicOp
 static LogicalResult
-convertCallLLVMIntrinsicOp(CallIntrinsicOp , llvm::IRBuilderBase ,
+convertCallLLVMIntrinsicOp(CallIntrinsicOp op, llvm::IRBuilderBase ,
LLVM::ModuleTranslation ) {
   llvm::Module *module = builder.GetInsertBlock()->getModule();
   llvm::Intrinsic::ID id =
@@ -114,6 +114,8 @@
   } else {
 fn = llvm::Intrinsic::getDeclaration(module, id, {});
   }
+  FastmathFlagsInterface itf = op;
+  builder.setFastMathFlags(getFastmathFlags(itf));
 
   auto *inst =
   builder.CreateCall(fn, moduleTranslation.lookupValues(op.getOperands()));
Index: mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
===
--- mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
+++ mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
@@ -867,19 +867,21 @@
 // CallIntrinsicOp
 //======//
 
-def LLVM_CallIntrinsicOp : LLVM_Op<"call_intrinsic"> {
+def LLVM_CallIntrinsicOp
+: LLVM_Op<"call_intrinsic",
+  [DeclareOpInterfaceMethods]> {
   let summary = "Call to an LLVM intrinsic function.";
   let description = [{
 Call the specified llvm intrinsic. If the intrinsic is overloaded, use
 the MLIR function type of this op to determine which intrinsic to call.
 }];
-  let arguments = (ins StrAttr:$intrin, Variadic:$args);
+  let arguments = (ins StrAttr:$intrin, Variadic:$args, 
DefaultValuedAttr:$fastmathFlags);
   let results = (outs Variadic:$results);
   let llvmBuilder = [{
 return convertCallLLVMIntrinsicOp(op, builder, moduleTranslation);
   }];
   let assemblyFormat = [{
-$intrin `(` $args `)` `:` functional-type($args, $results) attr-dict
+$intrin `(` $args `)` `:` functional-type($args, $results) 
custom(attr-dict)
   }];
 }
 


Index: mlir/test/Dialect/LLVMIR/call-intrin.mlir
===
--- mlir/test/Dialect/LLVMIR/call-intrin.mlir
+++ mlir/test/Dialect/LLVMIR/call-intrin.mlir
@@ -11,7 +11,7 @@
 llvm.func @round_sse41() -> vector<4xf32> {
 %0 = llvm.mlir.constant(1 : i32) : i32
 %1 = llvm.mlir.constant(dense<0.2> : vector<4xf32>) : vector<4xf32>
-%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : (vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {}
+%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : (vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {fastmathFlags = #llvm.fastmath}
 llvm.return %res: vector<4xf32>
 }
 
Index: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
@@ -95,7 +95,7 @@
 
 /// Builder for LLVM_CallIntrinsicOp
 static LogicalResult
-convertCallLLVMIntrinsicOp(CallIntrinsicOp , llvm::IRBuilderBase ,
+convertCallLLVMIntrinsicOp(CallIntrinsicOp op, llvm::IRBuilderBase ,
LLVM::ModuleTranslation ) {
   llvm::Module *module = builder.GetInsertBlock()->getModule();
   llvm::Intrinsic::ID id =
@@ -114,6 +114,8 @@
   } else {
 fn = llvm::Intrinsic::getDeclaration(module, id, {});
   }
+  FastmathFlagsInterface itf = op;
+  builder.setFastMathFlags(getFastmathFlags(itf));
 
   auto *inst =
   builder.CreateCall(fn, moduleTranslation.lookupValues(op.getOperands()));
Index: 

[PATCH] D151503: [CUDA] correctly install cuda_wrappers/bits/shared_ptr_base.h

2023-05-25 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
Herald added subscribers: mattd, carlosgalvezp, bixia, yaxunl.
Herald added a project: All.
tra edited the summary of this revision.
tra edited the summary of this revision.
tra published this revision for review.
tra added reviewers: qiongsiwu1, jlebar.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, jplehr, sstefan1.
Herald added a project: clang.

The file must go under cuda_wrappers/bits/, but was copied
directly into cuda_wrappers/ during installation.

https://github.com/llvm/llvm-project/issues/62939


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151503

Files:
  clang/lib/Headers/CMakeLists.txt


Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -267,6 +267,9 @@
   cuda_wrappers/cmath
   cuda_wrappers/complex
   cuda_wrappers/new
+)
+
+set(cuda_wrapper_bits_files
   cuda_wrappers/bits/shared_ptr_base.h
 )
 
@@ -328,7 +331,8 @@
 
 
 # Copy header files from the source directory to the build directory
-foreach( f ${files} ${cuda_wrapper_files} ${ppc_wrapper_files} 
${openmp_wrapper_files} ${hlsl_files})
+foreach( f ${files} ${cuda_wrapper_files} ${cuda_wrapper_bits_files}
+   ${ppc_wrapper_files} ${openmp_wrapper_files} ${hlsl_files})
   copy_header_to_output_dir(${CMAKE_CURRENT_SOURCE_DIR} ${f})
 endforeach( f )
 
@@ -429,7 +433,7 @@
 # Architecture/platform specific targets
 add_header_target("arm-resource-headers" 
"${arm_only_files};${arm_only_generated_files}")
 add_header_target("aarch64-resource-headers" 
"${aarch64_only_files};${aarch64_only_generated_files}")
-add_header_target("cuda-resource-headers" 
"${cuda_files};${cuda_wrapper_files}")
+add_header_target("cuda-resource-headers" 
"${cuda_files};${cuda_wrapper_files};${cuda_wrapper_bits_files}")
 add_header_target("hexagon-resource-headers" "${hexagon_files}")
 add_header_target("hip-resource-headers" "${hip_files}")
 add_header_target("loongarch-resource-headers" "${loongarch_files}")
@@ -463,6 +467,11 @@
   DESTINATION ${header_install_dir}/cuda_wrappers
   COMPONENT clang-resource-headers)
 
+install(
+  FILES ${cuda_wrapper_bits_files}
+  DESTINATION ${header_install_dir}/cuda_wrappers/bits
+  COMPONENT clang-resource-headers)
+
 install(
   FILES ${ppc_wrapper_files}
   DESTINATION ${header_install_dir}/ppc_wrappers


Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -267,6 +267,9 @@
   cuda_wrappers/cmath
   cuda_wrappers/complex
   cuda_wrappers/new
+)
+
+set(cuda_wrapper_bits_files
   cuda_wrappers/bits/shared_ptr_base.h
 )
 
@@ -328,7 +331,8 @@
 
 
 # Copy header files from the source directory to the build directory
-foreach( f ${files} ${cuda_wrapper_files} ${ppc_wrapper_files} ${openmp_wrapper_files} ${hlsl_files})
+foreach( f ${files} ${cuda_wrapper_files} ${cuda_wrapper_bits_files}
+   ${ppc_wrapper_files} ${openmp_wrapper_files} ${hlsl_files})
   copy_header_to_output_dir(${CMAKE_CURRENT_SOURCE_DIR} ${f})
 endforeach( f )
 
@@ -429,7 +433,7 @@
 # Architecture/platform specific targets
 add_header_target("arm-resource-headers" "${arm_only_files};${arm_only_generated_files}")
 add_header_target("aarch64-resource-headers" "${aarch64_only_files};${aarch64_only_generated_files}")
-add_header_target("cuda-resource-headers" "${cuda_files};${cuda_wrapper_files}")
+add_header_target("cuda-resource-headers" "${cuda_files};${cuda_wrapper_files};${cuda_wrapper_bits_files}")
 add_header_target("hexagon-resource-headers" "${hexagon_files}")
 add_header_target("hip-resource-headers" "${hip_files}")
 add_header_target("loongarch-resource-headers" "${loongarch_files}")
@@ -463,6 +467,11 @@
   DESTINATION ${header_install_dir}/cuda_wrappers
   COMPONENT clang-resource-headers)
 
+install(
+  FILES ${cuda_wrapper_bits_files}
+  DESTINATION ${header_install_dir}/cuda_wrappers/bits
+  COMPONENT clang-resource-headers)
+
 install(
   FILES ${ppc_wrapper_files}
   DESTINATION ${header_install_dir}/ppc_wrappers
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151502: [clang-tidy][docs] Fix link to libc style guide

2023-05-25 Thread Alex Brachet via Phabricator via cfe-commits
abrachet updated this revision to Diff 525814.

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

https://reviews.llvm.org/D151502

Files:
  clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h
  clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst


Index: 
clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst
+++ clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst
@@ -5,4 +5,4 @@
 
 Checks that all implicit and explicit inline functions in header files are
 tagged with the ``LIBC_INLINE`` macro. See the `libc style guide
-`_ for more information about this 
macro.
+`_ for more information about this 
macro.
Index: clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h
===
--- clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h
+++ clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h
@@ -18,7 +18,7 @@
 /// are tagged with the LIBC_INLINE macro.
 ///
 /// For more information about the LIBC_INLINE macro, see
-/// https://libc.llvm.org/code_style.html.
+/// https://libc.llvm.org/dev/code_style.html.
 ///
 /// For the user-facing documentation see:
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/llvmlibc/inline-function-decl-check.html


Index: clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst
+++ clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst
@@ -5,4 +5,4 @@
 
 Checks that all implicit and explicit inline functions in header files are
 tagged with the ``LIBC_INLINE`` macro. See the `libc style guide
-`_ for more information about this macro.
+`_ for more information about this macro.
Index: clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h
===
--- clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h
+++ clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h
@@ -18,7 +18,7 @@
 /// are tagged with the LIBC_INLINE macro.
 ///
 /// For more information about the LIBC_INLINE macro, see
-/// https://libc.llvm.org/code_style.html.
+/// https://libc.llvm.org/dev/code_style.html.
 ///
 /// For the user-facing documentation see:
 /// http://clang.llvm.org/extra/clang-tidy/checks/llvmlibc/inline-function-decl-check.html
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Lily Orth-Smith via Phabricator via cfe-commits
electriclilies added inline comments.



Comment at: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp:98
 static LogicalResult
 convertCallLLVMIntrinsicOp(CallIntrinsicOp , llvm::IRBuilderBase ,
LLVM::ModuleTranslation ) {

Mogball wrote:
> Mogball wrote:
> > electriclilies wrote:
> > > Mogball wrote:
> > > > Mogball wrote:
> > > > > electriclilies wrote:
> > > > > > Mogball wrote:
> > > > > > > I think the problem with the cast below is that this is passed by 
> > > > > > > reference. You should not pass operation handles by reference.
> > > > > > I think I can't pass it by value because it's const though.. 
> > > > > where is it const?
> > > > if it were const, it wouldn't bind to a non-const reference anyways
> > > If I just try to pass the op into the dyn_cast, it gives this error, 
> > > which says that the op is a const
> > > ```
> > > /home/lily/modular/third-party/llvm-project/llvm/include/llvm/Support/Casting.h:64:65:
> > >  error: cannot initialize a parameter of type 'mlir::Operation *' with an 
> > > rvalue of type 'const mlir::LLVM::CallIntrinsicOp *
> > > ```
> > did you drop the reference?
> ```
> CallIntrinsicOp 
> ```
> 
> delete the `&`. You should never do this for ops anyways
OK, I think I can upcast it to an Operation& to avoid this, and get rid of the 
copy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

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


[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Jeff Niu via Phabricator via cfe-commits
Mogball added inline comments.



Comment at: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp:98
 static LogicalResult
 convertCallLLVMIntrinsicOp(CallIntrinsicOp , llvm::IRBuilderBase ,
LLVM::ModuleTranslation ) {

Mogball wrote:
> electriclilies wrote:
> > Mogball wrote:
> > > Mogball wrote:
> > > > electriclilies wrote:
> > > > > Mogball wrote:
> > > > > > I think the problem with the cast below is that this is passed by 
> > > > > > reference. You should not pass operation handles by reference.
> > > > > I think I can't pass it by value because it's const though.. 
> > > > where is it const?
> > > if it were const, it wouldn't bind to a non-const reference anyways
> > If I just try to pass the op into the dyn_cast, it gives this error, which 
> > says that the op is a const
> > ```
> > /home/lily/modular/third-party/llvm-project/llvm/include/llvm/Support/Casting.h:64:65:
> >  error: cannot initialize a parameter of type 'mlir::Operation *' with an 
> > rvalue of type 'const mlir::LLVM::CallIntrinsicOp *
> > ```
> did you drop the reference?
```
CallIntrinsicOp 
```

delete the `&`. You should never do this for ops anyways


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

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


[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Jeff Niu via Phabricator via cfe-commits
Mogball added inline comments.



Comment at: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp:98
 static LogicalResult
 convertCallLLVMIntrinsicOp(CallIntrinsicOp , llvm::IRBuilderBase ,
LLVM::ModuleTranslation ) {

electriclilies wrote:
> Mogball wrote:
> > Mogball wrote:
> > > electriclilies wrote:
> > > > Mogball wrote:
> > > > > I think the problem with the cast below is that this is passed by 
> > > > > reference. You should not pass operation handles by reference.
> > > > I think I can't pass it by value because it's const though.. 
> > > where is it const?
> > if it were const, it wouldn't bind to a non-const reference anyways
> If I just try to pass the op into the dyn_cast, it gives this error, which 
> says that the op is a const
> ```
> /home/lily/modular/third-party/llvm-project/llvm/include/llvm/Support/Casting.h:64:65:
>  error: cannot initialize a parameter of type 'mlir::Operation *' with an 
> rvalue of type 'const mlir::LLVM::CallIntrinsicOp *
> ```
did you drop the reference?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

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


[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Lily Orth-Smith via Phabricator via cfe-commits
electriclilies added inline comments.



Comment at: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp:98
 static LogicalResult
 convertCallLLVMIntrinsicOp(CallIntrinsicOp , llvm::IRBuilderBase ,
LLVM::ModuleTranslation ) {

Mogball wrote:
> Mogball wrote:
> > electriclilies wrote:
> > > Mogball wrote:
> > > > I think the problem with the cast below is that this is passed by 
> > > > reference. You should not pass operation handles by reference.
> > > I think I can't pass it by value because it's const though.. 
> > where is it const?
> if it were const, it wouldn't bind to a non-const reference anyways
If I just try to pass the op into the dyn_cast, it gives this error, which says 
that the op is a const
```
/home/lily/modular/third-party/llvm-project/llvm/include/llvm/Support/Casting.h:64:65:
 error: cannot initialize a parameter of type 'mlir::Operation *' with an 
rvalue of type 'const mlir::LLVM::CallIntrinsicOp *
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

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


[PATCH] D151502: [clang-tidy][docs] Fix link to libc style guide

2023-05-25 Thread Alex Brachet via Phabricator via cfe-commits
abrachet created this revision.
abrachet added reviewers: mcgrathr, sivachandra.
Herald added subscribers: PiotrZSL, carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
abrachet requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

https://reviews.llvm.org/D151502

Files:
  clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst


Index: 
clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst
+++ clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst
@@ -5,4 +5,4 @@
 
 Checks that all implicit and explicit inline functions in header files are
 tagged with the ``LIBC_INLINE`` macro. See the `libc style guide
-`_ for more information about this 
macro.
+`_ for more information about this 
macro.


Index: clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst
+++ clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst
@@ -5,4 +5,4 @@
 
 Checks that all implicit and explicit inline functions in header files are
 tagged with the ``LIBC_INLINE`` macro. See the `libc style guide
-`_ for more information about this macro.
+`_ for more information about this macro.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150988: [clang][Darwin] Error out when missing requested libarclite library

2023-05-25 Thread Fahad Nayyar via Phabricator via cfe-commits
fahadnayyar updated this revision to Diff 525791.
fahadnayyar added a comment.

Adding 1 more test chage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150988

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/arclite-link-external-toolchain.c
  clang/test/Driver/arclite-link.c


Index: clang/test/Driver/arclite-link.c
===
--- clang/test/Driver/arclite-link.c
+++ clang/test/Driver/arclite-link.c
@@ -1,9 +1,13 @@
 // RUN: touch %t.o
-// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo 
-mmacosx-version-min=10.10 %t.o 2>&1 | FileCheck 
-check-prefix=CHECK-ARCLITE-OSX %s
+// RUN: mkdir -p 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
+// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo 
-mmacosx-version-min=10.10 %t.o \
+// RUN: -isysroot 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime 
-mmacosx-version-min=10.11 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE 
%s
 // RUN: %clang -### -target i386-apple-darwin10 -fobjc-link-runtime 
-mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime 
-nostdlib %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOSTDLIB %s
 
+// CHECK-ARCLITE-OSX: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a'.
+// CHECK-ARCLITE-OSX: This likely means you need to increase your minimum 
deployment target
 // CHECK-ARCLITE-OSX: -lfoo
 // CHECK-ARCLITE-OSX: libarclite_macosx.a
 // CHECK-ARCLITE-OSX: -framework
Index: clang/test/Driver/arclite-link-external-toolchain.c
===
--- clang/test/Driver/arclite-link-external-toolchain.c
+++ clang/test/Driver/arclite-link-external-toolchain.c
@@ -4,5 +4,8 @@
 // RUN:   -isysroot 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
 \
 // RUN:   %s 2>&1 | FileCheck %s
 
+// CHECK: error: SDK does not contain 'libarclite' at the path '
+// CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a'.
+// CHECK: This likely means you need to increase your minimum deployment target
 // CHECK: -lfoo
 // CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1204,6 +1204,9 @@
 P += "macosx";
   P += ".a";
 
+  if (!getVFS().exists(P))
+getDriver().Diag(clang::diag::err_drv_darwin_sdk_missing_arclite) << P;
+
   CmdArgs.push_back(Args.MakeArgString(P));
 }
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -619,6 +619,9 @@
   "SDK settings were ignored as 'SDKSettings.json' could not be parsed">,
   InGroup>;
 
+def err_drv_darwin_sdk_missing_arclite : Error<
+  "SDK does not contain 'libarclite' at the path '%0'. This likely means you 
need to increase your minimum deployment target">;
+
 def err_drv_trivial_auto_var_init_stop_after_missing_dependency : Error<
   "'-ftrivial-auto-var-init-stop-after=*' is used without "
   "'-ftrivial-auto-var-init=zero' or '-ftrivial-auto-var-init=pattern'">;


Index: clang/test/Driver/arclite-link.c
===
--- clang/test/Driver/arclite-link.c
+++ clang/test/Driver/arclite-link.c
@@ -1,9 +1,13 @@
 // RUN: touch %t.o
-// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo -mmacosx-version-min=10.10 %t.o 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
+// RUN: mkdir -p %t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
+// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo -mmacosx-version-min=10.10 %t.o \
+// RUN: -isysroot %t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.11 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
 // RUN: %clang -### -target i386-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -nostdlib %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOSTDLIB %s
 
+// 

[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Jeff Niu via Phabricator via cfe-commits
Mogball added inline comments.



Comment at: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp:98
 static LogicalResult
 convertCallLLVMIntrinsicOp(CallIntrinsicOp , llvm::IRBuilderBase ,
LLVM::ModuleTranslation ) {

Mogball wrote:
> electriclilies wrote:
> > Mogball wrote:
> > > I think the problem with the cast below is that this is passed by 
> > > reference. You should not pass operation handles by reference.
> > I think I can't pass it by value because it's const though.. 
> where is it const?
if it were const, it wouldn't bind to a non-const reference anyways


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

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


[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Jeff Niu via Phabricator via cfe-commits
Mogball added inline comments.



Comment at: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp:98
 static LogicalResult
 convertCallLLVMIntrinsicOp(CallIntrinsicOp , llvm::IRBuilderBase ,
LLVM::ModuleTranslation ) {

electriclilies wrote:
> Mogball wrote:
> > I think the problem with the cast below is that this is passed by 
> > reference. You should not pass operation handles by reference.
> I think I can't pass it by value because it's const though.. 
where is it const?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

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


[PATCH] D151495: [clang-tidy] Improve build-in type handling in bugprone-swapped-arguments

2023-05-25 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL created this revision.
PiotrZSL added reviewers: bkramer, njames93, carlosgalvezp.
Herald added a subscriber: xazax.hun.
Herald added a project: All.
PiotrZSL requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Improved detection of argument swaps involving integral and floating-point
types by enhancing handling of implicit conversions. Now implicit casts
from float to double are also considered, same for integers.
Improved documentation.

Fixes: #62926


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151495

Files:
  clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone/swapped-arguments.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/swapped-arguments.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/swapped-arguments.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/swapped-arguments.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/swapped-arguments.cpp
@@ -8,26 +8,31 @@
 void G(T a, U b) {
   F(a, b); // no-warning
   F(2.0, 4);
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'int' to 'double' followed by argument converted from 'double' to 'int', potentially swapped arguments.
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'double' to 'int' followed by argument converted from 'int' to 'double', potentially swapped arguments.
 // CHECK-FIXES: F(4, 2.0)
 }
 
+void funShortFloat(short, float);
+void funFloatFloat(float, float);
+void funBoolShort(bool, short);
+void funBoolFloat(bool, float);
+
 void foo() {
   F(1.0, 3);
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'int' to 'double' followed by argument converted from 'double' to 'int', potentially swapped arguments.
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'double' to 'int' followed by argument converted from 'int' to 'double', potentially swapped arguments.
 // CHECK-FIXES: F(3, 1.0)
 
 #define M(x, y) x##y()
 
   double b = 1.0;
   F(b, M(Some, Function));
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'int' to 'double' followed by argument converted from 'double' to 'int', potentially swapped arguments.
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'double' to 'int' followed by argument converted from 'int' to 'double', potentially swapped arguments.
 // CHECK-FIXES: F(M(Some, Function), b);
 
 #define N F(b, SomeFunction())
 
   N;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'int' to 'double' followed by argument converted from 'double' to 'int', potentially swapped arguments.
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'double' to 'int' followed by argument converted from 'int' to 'double', potentially swapped arguments.
 // In macro, don't emit fixits.
 // CHECK-FIXES: #define N F(b, SomeFunction())
 
@@ -42,12 +47,32 @@
 
 #define APPLY(f, x, y) f(x, y)
   APPLY(F, 1.0, 3);
-// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: argument with implicit conversion from 'int' to 'double' followed by argument converted from 'double' to 'int', potentially swapped arguments.
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: argument with implicit conversion from 'double' to 'int' followed by argument converted from 'int' to 'double', potentially swapped arguments.
 // CHECK-FIXES: APPLY(F, 3, 1.0);
 
 #define PARAMS 1.0, 3
 #define CALL(P) F(P)
   CALL(PARAMS);
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'int' to 'double' followed by argument converted from 'double' to 'int', potentially swapped arguments.
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'double' to 'int' followed by argument converted from 'int' to 'double', potentially swapped arguments.
 // In macro, don't emit fixits.
+
+  funShortFloat(5.0, 1U);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'double' to 'short' followed by argument converted from 'unsigned int' to 'float', potentially swapped arguments.
+  // CHECK-FIXES: funShortFloat(1U, 5.0);
+  funShortFloat(5.0, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'double' to 'short' followed by argument converted from 'int' to 'float', potentially swapped arguments.
+  // CHECK-FIXES: funShortFloat(1, 5.0);
+  funShortFloat(5.0f, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'float' to 'short' followed by argument converted from 'int' to 'float', potentially swapped arguments.
+  // CHECK-FIXES: funShortFloat(1, 5.0f);
+
+  

[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Lily Orth-Smith via Phabricator via cfe-commits
electriclilies added inline comments.



Comment at: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp:98
 static LogicalResult
 convertCallLLVMIntrinsicOp(CallIntrinsicOp , llvm::IRBuilderBase ,
LLVM::ModuleTranslation ) {

Mogball wrote:
> I think the problem with the cast below is that this is passed by reference. 
> You should not pass operation handles by reference.
I think I can't pass it by value because it's const though.. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

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


[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Jeff Niu via Phabricator via cfe-commits
Mogball added inline comments.



Comment at: mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td:870
 
-def LLVM_CallIntrinsicOp : LLVM_Op<"call_intrinsic"> {
+def LLVM_CallIntrinsicOp : LLVM_Op<"call_intrinsic", 
[DeclareOpInterfaceMethods]> {
   let summary = "Call to an LLVM intrinsic function.";

please fit this definition into 80 characters wide



Comment at: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp:98
 static LogicalResult
 convertCallLLVMIntrinsicOp(CallIntrinsicOp , llvm::IRBuilderBase ,
LLVM::ModuleTranslation ) {

I think the problem with the cast below is that this is passed by reference. 
You should not pass operation handles by reference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

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


[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Lily Orth-Smith via Phabricator via cfe-commits
electriclilies added inline comments.



Comment at: 
mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp:130
 
-  llvm::CallInst *inst =
   builder.CreateCall(fn, moduleTranslation.lookupValues(op.getOperands()));

ftynse wrote:
> Don't use `auto` unless the type is obvious from context (e.g., the RHS is a 
> cast) or difficult to spell.
This auto was already here, I changed it in previous commit. It showed up in 
the diff because I hadn't squashed my changes yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

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


[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Lily Orth-Smith via Phabricator via cfe-commits
electriclilies updated this revision to Diff 525779.
electriclilies added a comment.

Remove whitespace


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

Files:
  mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
  mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
  mlir/test/Dialect/LLVMIR/call-intrin.mlir


Index: mlir/test/Dialect/LLVMIR/call-intrin.mlir
===
--- mlir/test/Dialect/LLVMIR/call-intrin.mlir
+++ mlir/test/Dialect/LLVMIR/call-intrin.mlir
@@ -11,7 +11,7 @@
 llvm.func @round_sse41() -> vector<4xf32> {
 %0 = llvm.mlir.constant(1 : i32) : i32
 %1 = llvm.mlir.constant(dense<0.2> : vector<4xf32>) : vector<4xf32>
-%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : 
(vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {}
+%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : 
(vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {fastmathFlags = 
#llvm.fastmath}
 llvm.return %res: vector<4xf32>
 }
 
Index: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
@@ -114,6 +114,9 @@
   } else {
 fn = llvm::Intrinsic::getDeclaration(module, id, {});
   }
+  Operation* op2 = op;
+  if (auto fmf = dyn_cast(op2))
+builder.setFastMathFlags(getFastmathFlags(fmf));
 
   auto *inst =
   builder.CreateCall(fn, moduleTranslation.lookupValues(op.getOperands()));
Index: mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
===
--- mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
+++ mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
@@ -867,19 +867,19 @@
 // CallIntrinsicOp
 //======//
 
-def LLVM_CallIntrinsicOp : LLVM_Op<"call_intrinsic"> {
+def LLVM_CallIntrinsicOp : LLVM_Op<"call_intrinsic", 
[DeclareOpInterfaceMethods]> {
   let summary = "Call to an LLVM intrinsic function.";
   let description = [{
 Call the specified llvm intrinsic. If the intrinsic is overloaded, use
 the MLIR function type of this op to determine which intrinsic to call.
 }];
-  let arguments = (ins StrAttr:$intrin, Variadic:$args);
+  let arguments = (ins StrAttr:$intrin, Variadic:$args, 
DefaultValuedAttr:$fastmathFlags);
   let results = (outs Variadic:$results);
   let llvmBuilder = [{
 return convertCallLLVMIntrinsicOp(op, builder, moduleTranslation);
   }];
   let assemblyFormat = [{
-$intrin `(` $args `)` `:` functional-type($args, $results) attr-dict
+$intrin `(` $args `)` `:` functional-type($args, $results) 
custom(attr-dict)
   }];
 }
 


Index: mlir/test/Dialect/LLVMIR/call-intrin.mlir
===
--- mlir/test/Dialect/LLVMIR/call-intrin.mlir
+++ mlir/test/Dialect/LLVMIR/call-intrin.mlir
@@ -11,7 +11,7 @@
 llvm.func @round_sse41() -> vector<4xf32> {
 %0 = llvm.mlir.constant(1 : i32) : i32
 %1 = llvm.mlir.constant(dense<0.2> : vector<4xf32>) : vector<4xf32>
-%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : (vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {}
+%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : (vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {fastmathFlags = #llvm.fastmath}
 llvm.return %res: vector<4xf32>
 }
 
Index: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
@@ -114,6 +114,9 @@
   } else {
 fn = llvm::Intrinsic::getDeclaration(module, id, {});
   }
+  Operation* op2 = op;
+  if (auto fmf = dyn_cast(op2))
+builder.setFastMathFlags(getFastmathFlags(fmf));
 
   auto *inst =
   builder.CreateCall(fn, moduleTranslation.lookupValues(op.getOperands()));
Index: mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
===
--- mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
+++ mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
@@ -867,19 +867,19 @@
 // CallIntrinsicOp
 //======//
 
-def LLVM_CallIntrinsicOp : LLVM_Op<"call_intrinsic"> {
+def LLVM_CallIntrinsicOp : LLVM_Op<"call_intrinsic", [DeclareOpInterfaceMethods]> {
   let summary = "Call to an LLVM intrinsic function.";
   let description = [{
 Call the specified llvm intrinsic. If the intrinsic is overloaded, use
 the MLIR function type of this op to determine which 

[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Alex Zinenko via Phabricator via cfe-commits
ftynse added inline comments.



Comment at: clang/lib/CodeGen/CGHLSLRuntime.cpp:367
   // that can be valid on the real entry.
-  // This is what I want to do
   AttributeList NewAttrs = AttributeList::get(Ctx, 
AttributeList::FunctionIndex,

electriclilies wrote:
> ftynse wrote:
> > This cleanup should go in a separate commit.
> For some reason arcanist is showing the diff between my 2 latest commits, not 
> between main and my branch, I added this in a previous commit then removed it 
> in my final clean up commit.. 
If you create it with `arc`, the command indicates with respect to which other 
commit the diff is taken, e.g. `arc diff HEAD^` is the diff between the 
currently checked out commit and the previous one (`HEAD^`). You can do several 
steps (`HEAD^^^` for three) or specify the commit hash explicitly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

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


[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Lily Orth-Smith via Phabricator via cfe-commits
electriclilies updated this revision to Diff 525778.
electriclilies added a comment.

Squish commits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

Files:
  mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
  mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
  mlir/test/Dialect/LLVMIR/call-intrin.mlir


Index: mlir/test/Dialect/LLVMIR/call-intrin.mlir
===
--- mlir/test/Dialect/LLVMIR/call-intrin.mlir
+++ mlir/test/Dialect/LLVMIR/call-intrin.mlir
@@ -11,7 +11,7 @@
 llvm.func @round_sse41() -> vector<4xf32> {
 %0 = llvm.mlir.constant(1 : i32) : i32
 %1 = llvm.mlir.constant(dense<0.2> : vector<4xf32>) : vector<4xf32>
-%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : 
(vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {}
+%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : 
(vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {fastmathFlags = 
#llvm.fastmath}
 llvm.return %res: vector<4xf32>
 }
 
Index: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
@@ -93,6 +93,7 @@
   return llvm::Intrinsic::getDeclaration(module, id, overloadedArgTysRef);
 }
 
+
 /// Builder for LLVM_CallIntrinsicOp
 static LogicalResult
 convertCallLLVMIntrinsicOp(CallIntrinsicOp , llvm::IRBuilderBase ,
@@ -114,9 +115,13 @@
   } else {
 fn = llvm::Intrinsic::getDeclaration(module, id, {});
   }
+  Operation* op2 = op;
+  if (auto fmf = dyn_cast(op2))
+builder.setFastMathFlags(getFastmathFlags(fmf));
 
   auto *inst =
   builder.CreateCall(fn, moduleTranslation.lookupValues(op.getOperands()));
+
   if (op.getNumResults() == 1)
 moduleTranslation.mapValue(op->getResults().front()) = inst;
   return success();
Index: mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
===
--- mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
+++ mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
@@ -867,19 +867,19 @@
 // CallIntrinsicOp
 //======//
 
-def LLVM_CallIntrinsicOp : LLVM_Op<"call_intrinsic"> {
+def LLVM_CallIntrinsicOp : LLVM_Op<"call_intrinsic", 
[DeclareOpInterfaceMethods]> {
   let summary = "Call to an LLVM intrinsic function.";
   let description = [{
 Call the specified llvm intrinsic. If the intrinsic is overloaded, use
 the MLIR function type of this op to determine which intrinsic to call.
 }];
-  let arguments = (ins StrAttr:$intrin, Variadic:$args);
+  let arguments = (ins StrAttr:$intrin, Variadic:$args, 
DefaultValuedAttr:$fastmathFlags);
   let results = (outs Variadic:$results);
   let llvmBuilder = [{
 return convertCallLLVMIntrinsicOp(op, builder, moduleTranslation);
   }];
   let assemblyFormat = [{
-$intrin `(` $args `)` `:` functional-type($args, $results) attr-dict
+$intrin `(` $args `)` `:` functional-type($args, $results) 
custom(attr-dict)
   }];
 }
 


Index: mlir/test/Dialect/LLVMIR/call-intrin.mlir
===
--- mlir/test/Dialect/LLVMIR/call-intrin.mlir
+++ mlir/test/Dialect/LLVMIR/call-intrin.mlir
@@ -11,7 +11,7 @@
 llvm.func @round_sse41() -> vector<4xf32> {
 %0 = llvm.mlir.constant(1 : i32) : i32
 %1 = llvm.mlir.constant(dense<0.2> : vector<4xf32>) : vector<4xf32>
-%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : (vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {}
+%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : (vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {fastmathFlags = #llvm.fastmath}
 llvm.return %res: vector<4xf32>
 }
 
Index: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
@@ -93,6 +93,7 @@
   return llvm::Intrinsic::getDeclaration(module, id, overloadedArgTysRef);
 }
 
+
 /// Builder for LLVM_CallIntrinsicOp
 static LogicalResult
 convertCallLLVMIntrinsicOp(CallIntrinsicOp , llvm::IRBuilderBase ,
@@ -114,9 +115,13 @@
   } else {
 fn = llvm::Intrinsic::getDeclaration(module, id, {});
   }
+  Operation* op2 = op;
+  if (auto fmf = dyn_cast(op2))
+builder.setFastMathFlags(getFastmathFlags(fmf));
 
   auto *inst =
   builder.CreateCall(fn, moduleTranslation.lookupValues(op.getOperands()));
+
   if (op.getNumResults() == 1)
 moduleTranslation.mapValue(op->getResults().front()) = inst;
   return success();
Index: 

[PATCH] D149495: [RISCV] Add support for V extension in SiFive7

2023-05-25 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

In D149495#4373796 , @michaelmaitland 
wrote:

> In D149495#4373768 , @reames wrote:
>
>> Let's go ahead and land this as is, we can rework the stylistic pieces once 
>> the linked patches land.
>
> This has landed in 
> https://reviews.llvm.org/rG1a855819a87f426bdbd83c815fa47ca01fdf928f. I raised 
> my question regarding examples in my previous comment on this post because I 
> am starting to rework the stylistic concerns raised by @pcwang-thead. 
> However, I will wait until Wang's patches land before making any 
> modifications to style.

My apologies, I read right past the commit in the history.  Oops.  Sorry for 
the noise!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149495

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


[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Lily Orth-Smith via Phabricator via cfe-commits
electriclilies added inline comments.



Comment at: clang/lib/CodeGen/CGHLSLRuntime.cpp:367
   // that can be valid on the real entry.
-  // This is what I want to do
   AttributeList NewAttrs = AttributeList::get(Ctx, 
AttributeList::FunctionIndex,

ftynse wrote:
> This cleanup should go in a separate commit.
For some reason arcanist is showing the diff between my 2 latest commits, not 
between main and my branch, I added this in a previous commit then removed it 
in my final clean up commit.. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

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


[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Lily Orth-Smith via Phabricator via cfe-commits
electriclilies added a comment.

For some reason the diff is showing the difference between 2 commits on my 
branch, anyone know how to fix this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

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


[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Alex Zinenko via Phabricator via cfe-commits
ftynse added inline comments.



Comment at: clang/lib/CodeGen/CGHLSLRuntime.cpp:367
   // that can be valid on the real entry.
-  // This is what I want to do
   AttributeList NewAttrs = AttributeList::get(Ctx, 
AttributeList::FunctionIndex,

This cleanup should go in a separate commit.



Comment at: 
mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp:130
 
-  llvm::CallInst *inst =
   builder.CreateCall(fn, moduleTranslation.lookupValues(op.getOperands()));

Don't use `auto` unless the type is obvious from context (e.g., the RHS is a 
cast) or difficult to spell.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151492

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


[PATCH] D149495: [RISCV] Add support for V extension in SiFive7

2023-05-25 Thread Michael Maitland via Phabricator via cfe-commits
michaelmaitland added a comment.

In D149495#4373768 , @reames wrote:

> Let's go ahead and land this as is, we can rework the stylistic pieces once 
> the linked patches land.

This has landed in 
https://reviews.llvm.org/rG1a855819a87f426bdbd83c815fa47ca01fdf928f. I raised 
my question regarding examples in my previous comment on this post because I am 
starting to rework the stylistic concerns raised by @pcwang-thead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149495

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


[PATCH] D148266: [clang][driver] Linking to just-built libc++.dylib when bootstrapping libc++ with clang

2023-05-25 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: clang/lib/Driver/ToolChains/Darwin.cpp:431
+  // libc++.dylib in the toolchain.
+  if ((!Args.hasArg(options::OPT_nostdinc, options::OPT_nostdlibinc,
+options::OPT_nostdincxx)) &&

arphaman wrote:
> ldionne wrote:
> > The more I look at this, the more I think it seems kind of weird to me that 
> > a linker argument would be impacted by `-nostdinc` & friends, which control 
> > header search paths. IMO we should use the simplest behavior and only check 
> > for `libc++.dylib` here, and not check for `libc++.dylib` when we determine 
> > the header search paths.
> > 
> > @arphaman Do you have an opinion?
> That makes sense to me. I'm not sure why specifically do we need to check if 
> the dylib exists when determining the header search path. Is there a specific 
> reason we couldn't mix the local headers and the system's dylib in that case?
> 
We definitely don't want to mix the local headers and the system dylib. They 
can be configured differently (e.g. different ABI flags amongst other things). 
However it shouldn't really matter since when we build libc++, we build both 
the dylib and the headers so either both should be picked up or neither should 
be. I wouldn't bother checking. If we really wanted to check, we could actually 
error-out if one (but not both) are there, since that would point out to a 
mismatch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148266

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


[PATCH] D151492: Add fastmath attributes to llvm.call_intrinsic

2023-05-25 Thread Lily Orth-Smith via Phabricator via cfe-commits
electriclilies created this revision.
Herald added subscribers: bviyer, Moerafaat, zero9178, bzcheeseman, awarzynski, 
sdasgup3, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, 
jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, 
antiagainst, shauheen, rriddle, mehdi_amini.
Herald added a reviewer: ftynse.
Herald added a reviewer: dcaballe.
Herald added a project: All.
electriclilies requested review of this revision.
Herald added a reviewer: nicolasvasilache.
Herald added subscribers: cfe-commits, stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, MLIR.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151492

Files:
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
  mlir/test/Dialect/LLVMIR/call-intrin.mlir


Index: mlir/test/Dialect/LLVMIR/call-intrin.mlir
===
--- mlir/test/Dialect/LLVMIR/call-intrin.mlir
+++ mlir/test/Dialect/LLVMIR/call-intrin.mlir
@@ -11,7 +11,7 @@
 llvm.func @round_sse41() -> vector<4xf32> {
 %0 = llvm.mlir.constant(1 : i32) : i32
 %1 = llvm.mlir.constant(dense<0.2> : vector<4xf32>) : vector<4xf32>
-%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : 
(vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {}
+%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : 
(vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {fastmathFlags = 
#llvm.fastmath}
 llvm.return %res: vector<4xf32>
 }
 
Index: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
@@ -16,15 +16,12 @@
 #include "mlir/Support/LLVM.h"
 #include "mlir/Target/LLVMIR/ModuleTranslation.h"
 
-//#include "llvm/IR/Attributes.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/MatrixBuilder.h"
 #include "llvm/IR/Operator.h"
 
-#include "mlir/Conversion/ArithCommon/AttrToLLVMConverter.h"
-
 using namespace mlir;
 using namespace mlir::LLVM;
 using mlir::LLVM::detail::createIntrinsicCall;
@@ -118,16 +115,11 @@
   } else {
 fn = llvm::Intrinsic::getDeclaration(module, id, {});
   }
-  llvm::errs() << "hi\n";
   Operation* op2 = op;
-  llvm::errs() << "hi2\n";
-  if (auto fmf = dyn_cast(op2)) {
-llvm::errs() << "setting fastmath flags\n";
+  if (auto fmf = dyn_cast(op2))
 builder.setFastMathFlags(getFastmathFlags(fmf));
-llvm::errs() << "done\n";
-  }
 
-  llvm::CallInst *inst =
+  auto *inst =
   builder.CreateCall(fn, moduleTranslation.lookupValues(op.getOperands()));
 
   if (op.getNumResults() == 1)
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -364,7 +364,6 @@
 
   // Copy function attributes over, we have no argument or return attributes
   // that can be valid on the real entry.
-  // This is what I want to do
   AttributeList NewAttrs = AttributeList::get(Ctx, 
AttributeList::FunctionIndex,
   
Fn->getAttributes().getFnAttrs());
   EntryFn->setAttributes(NewAttrs);


Index: mlir/test/Dialect/LLVMIR/call-intrin.mlir
===
--- mlir/test/Dialect/LLVMIR/call-intrin.mlir
+++ mlir/test/Dialect/LLVMIR/call-intrin.mlir
@@ -11,7 +11,7 @@
 llvm.func @round_sse41() -> vector<4xf32> {
 %0 = llvm.mlir.constant(1 : i32) : i32
 %1 = llvm.mlir.constant(dense<0.2> : vector<4xf32>) : vector<4xf32>
-%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : (vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {}
+%res = llvm.call_intrinsic "llvm.x86.sse41.round.ss"(%1, %1, %0) : (vector<4xf32>, vector<4xf32>, i32) -> vector<4xf32> {fastmathFlags = #llvm.fastmath}
 llvm.return %res: vector<4xf32>
 }
 
Index: mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
@@ -16,15 +16,12 @@
 #include "mlir/Support/LLVM.h"
 #include "mlir/Target/LLVMIR/ModuleTranslation.h"
 
-//#include "llvm/IR/Attributes.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/MatrixBuilder.h"
 #include "llvm/IR/Operator.h"
 
-#include "mlir/Conversion/ArithCommon/AttrToLLVMConverter.h"
-
 using namespace mlir;
 using namespace mlir::LLVM;
 using mlir::LLVM::detail::createIntrinsicCall;
@@ -118,16 +115,11 @@
   } else {
 fn = llvm::Intrinsic::getDeclaration(module, 

[PATCH] D151393: [CodeGen] Make __clang_call_terminate have an unwind table entry

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

In D151393#4373764 , @smeenai wrote:

> I searched for `__clang_call_terminate` in the Clang test directory when I 
> was working on this diff. Most tests were testing calls to it, not 
> definitions. There were a couple of tests checking the definition, but they 
> seemed pretty targeted (e.g. 
> https://github.com/llvm/llvm-project/blob/main/clang/test/CodeGenCXX/noexcept.cpp)
>  or auto-generated, so I figured having a separate test case for the specific 
> thing I cared about was best.

Thank you for the research!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151393

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


[PATCH] D149495: [RISCV] Add support for V extension in SiFive7

2023-05-25 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

Let's go ahead and land this as is, we can rework the stylistic pieces once the 
linked patches land.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149495

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


[PATCH] D151393: [CodeGen] Make __clang_call_terminate have an unwind table entry

2023-05-25 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

I searched for `__clang_call_terminate` in the Clang test directory when I was 
working on this diff. Most tests were testing calls to it, not definitions. 
There were a couple of tests checking the definition, but they seemed pretty 
targeted (e.g. 
https://github.com/llvm/llvm-project/blob/main/clang/test/CodeGenCXX/noexcept.cpp)
 or auto-generated, so I figured having a separate test case for the specific 
thing I cared about was best.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151393

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


[PATCH] D151445: [Flang] Add main-file-name flag to flang -fc1

2023-05-25 Thread Dominik Adamski via Phabricator via cfe-commits
domada added a comment.

In D151445#4372892 , @clementval 
wrote:

> You should be able to get this information from the source location in MLIR.

Hi, thank you for your quick feedback.

You are right, the source location is provided in MLIR. Unfortunately, when we 
compile the source code with -save-temps file, then we use preprocessed file as 
the input for MLIR and we have no information about original source file.

Please look at the output of the command:
`flang-new -save-temps -v **test.f90**`

Output:
`flang-new -fc1 /*some fc1 options */ **-o test.i test.f90**`
`flang-new -fc1 /*some fc1 options */ **-o test.bc test.i**`

If we generate the code for OpenMP, then we generate two different preprocessed 
files (one for host code, the second one for the device). Then we use these 
preprocessed files as the input for MLIR. Originally we use the name of 
preprocessed file as the input for generation of unique name of OpenMP kernel 
function (please look at the original code inside 
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp  ). In 
consequence we generate two different kernel names for host and the device 
module (host and the device code should operate on the same name of the kernel 
function). To fix that isssue I provide an information about the original 
source file (not the name of the input preprocessed file).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151445

___
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-25 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

In D150887#4373695 , @nikic wrote:

> I wanted to check whether you plan to do more opaque pointer test conversions 
> in clang. Just to make sure we don't duplicate work...

I'm done for now


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] D151145: Add disabled unittest reproducing TextProto formatting issue.

2023-05-25 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

> In D151145#4365580 , 
> @HazardyKnusperkeks wrote:
>
>> As stated on Github I don't think we have a bug.
>
> Are you sure, I'm pretty sure this is a bug? Can you elaborate on the 
> discussion on github. I wouldn't want to fix something that isn't broken. If 
> this is indeed expected maybe I can update the docs.

Everything good, seems to be a bug.




Comment at: clang/unittests/Format/FormatTestRawStrings.cpp:177
+format(R"test(
+t = R"pb(item:1)pb";)test",
+   getRawStringPbStyleSeparateSection()));

Icantjuddle wrote:
> HazardyKnusperkeks wrote:
> > EXPECT_EQ
> I used the function instead of the macro to conform to the convention of 
> every other test in the file. 
> 
> The function provides its own justification.
> ```
>   // Gcc 4.8 doesn't support raw string literals in macros, which breaks some
>   // build bots. We use this function instead.
>   void expect_eq(const std::string Expected, const std::string Actual) {
> ```
And every other clang-format test file (at least I worked on) uses the macro.

Also I don't think gcc 4.8 will be able to compile LLVM anymore, but I may be 
wrong on that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151145

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


[PATCH] D151365: [Sema] cast to CXXRecordDecl correctly when diag a default comparison method

2023-05-25 Thread Congcong Cai 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 rG5df593a35471: [Sema] cast to CXXRecordDecl correctly when 
diag a default comparison method (authored by HerrCai0907).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151365

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
  clang/test/SemaCXX/cxx20-default-compare.cpp


Index: clang/test/SemaCXX/cxx20-default-compare.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx20-default-compare.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -std=c++23 -verify -Wfloat-equal
+
+struct Foo {
+  float val;
+  bool operator==(const Foo &) const;
+  friend bool operator==(const Foo &, const Foo &);
+  friend bool operator==(Foo, Foo );
+};
+
+// Declare the defaulted comparison function as a member function.
+bool Foo::operator==(const Foo &) const = default; // expected-warning 
{{comparing floating point with == or != is unsafe}} expected-note {{in 
defaulted equality comparison operator for 'Foo' first required here}}
+
+// Declare the defaulted comparison function as a non-member function.
+bool operator==(const Foo &, const Foo &) = default;  // expected-warning 
{{comparing floating point with == or != is unsafe}} expected-note {{in 
defaulted equality comparison operator for 'Foo' first required here}}
+
+// Declare the defaulted comparison function as a non-member function. 
Arguments are passed by value.
+bool operator==(Foo, Foo) = default;  // expected-warning {{comparing floating 
point with == or != is unsafe}} expected-note {{in defaulted equality 
comparison operator for 'Foo' first required here}}
Index: clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
===
--- clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
+++ clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
@@ -227,5 +227,5 @@
 A a;
 std::strong_ordering operator<=>(const B&) const = default; // 
expected-error {{call to deleted constructor of 'A'}}
   };
-  bool x = B() < B(); // expected-note {{in defaulted three-way comparison 
operator for 'Preference::B' first required here}}
+  bool x = B() < B(); // expected-note {{in defaulted three-way comparison 
operator for 'B' first required here}}
 }
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -961,11 +961,13 @@
 << MD->isExplicitlyDefaulted() << DFK.asSpecialMember()
 << Context.getTagDeclType(MD->getParent());
   } else if (DFK.isComparison()) {
+QualType RecordType = FD->getParamDecl(0)
+  ->getType()
+  .getNonReferenceType()
+  .getUnqualifiedType();
 Diags.Report(Active->PointOfInstantiation,
  diag::note_comparison_synthesized_at)
-<< (int)DFK.asComparison()
-<< Context.getTagDeclType(
-   cast(FD->getLexicalDeclContext()));
+<< (int)DFK.asComparison() << RecordType;
   }
   break;
 }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -445,6 +445,9 @@
   (`#62789 `_).
 - Fix a crash when instantiating a non-type template argument in a dependent 
scope.
   (`#62533 `_).
+- Fix crash when diagnosing default comparison method.
+  (`#62791 `_) and
+  (`#62102 `_).
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/cxx20-default-compare.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx20-default-compare.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -std=c++23 -verify -Wfloat-equal
+
+struct Foo {
+  float val;
+  bool operator==(const Foo &) const;
+  friend bool operator==(const Foo &, const Foo &);
+  friend bool operator==(Foo, Foo );
+};
+
+// Declare the defaulted comparison function as a member function.
+bool Foo::operator==(const Foo &) const = default; // expected-warning {{comparing floating point with == or != is unsafe}} expected-note {{in defaulted equality comparison operator for 'Foo' first required here}}
+
+// Declare the defaulted comparison function as a non-member function.
+bool operator==(const Foo 

[clang] 5df593a - [Sema] cast to CXXRecordDecl correctly when diag a default comparison method

2023-05-25 Thread Congcong Cai via cfe-commits

Author: Congcong Cai
Date: 2023-05-25T22:07:50+02:00
New Revision: 5df593a354714e081ac441a74f89ad2a56334e28

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

LOG: [Sema] cast to CXXRecordDecl correctly when diag a default comparison 
method

Fixed: https://github.com/llvm/llvm-project/issues/62791
Fixed: https://github.com/llvm/llvm-project/issues/62102
in c++20, default comparison is supported. `getLexicalDeclContext` maybe cannot
get the `CXXRecord` if default comparison defined out of `CXXRecord`.
This patch want to get these information from the first function argument.

Reviewed By: #clang-language-wg, erichkeane

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

Added: 
clang/test/SemaCXX/cxx20-default-compare.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/CXX/class/class.compare/class.spaceship/p1.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 07137e75c9f88..7a936051fe051 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -445,6 +445,9 @@ Bug Fixes in This Version
   (`#62789 `_).
 - Fix a crash when instantiating a non-type template argument in a dependent 
scope.
   (`#62533 `_).
+- Fix crash when diagnosing default comparison method.
+  (`#62791 `_) and
+  (`#62102 `_).
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 32a8ba1a5c46d..b58d58ea1b052 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -961,11 +961,13 @@ void Sema::PrintInstantiationStack() {
 << MD->isExplicitlyDefaulted() << DFK.asSpecialMember()
 << Context.getTagDeclType(MD->getParent());
   } else if (DFK.isComparison()) {
+QualType RecordType = FD->getParamDecl(0)
+  ->getType()
+  .getNonReferenceType()
+  .getUnqualifiedType();
 Diags.Report(Active->PointOfInstantiation,
  diag::note_comparison_synthesized_at)
-<< (int)DFK.asComparison()
-<< Context.getTagDeclType(
-   cast(FD->getLexicalDeclContext()));
+<< (int)DFK.asComparison() << RecordType;
   }
   break;
 }

diff  --git a/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp 
b/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
index c5e7226364660..cd5c8b155a9fa 100644
--- a/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
+++ b/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
@@ -227,5 +227,5 @@ namespace Preference {
 A a;
 std::strong_ordering operator<=>(const B&) const = default; // 
expected-error {{call to deleted constructor of 'A'}}
   };
-  bool x = B() < B(); // expected-note {{in defaulted three-way comparison 
operator for 'Preference::B' first required here}}
+  bool x = B() < B(); // expected-note {{in defaulted three-way comparison 
operator for 'B' first required here}}
 }

diff  --git a/clang/test/SemaCXX/cxx20-default-compare.cpp 
b/clang/test/SemaCXX/cxx20-default-compare.cpp
new file mode 100644
index 0..7074ee885ac4a
--- /dev/null
+++ b/clang/test/SemaCXX/cxx20-default-compare.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -std=c++23 -verify -Wfloat-equal
+
+struct Foo {
+  float val;
+  bool operator==(const Foo &) const;
+  friend bool operator==(const Foo &, const Foo &);
+  friend bool operator==(Foo, Foo );
+};
+
+// Declare the defaulted comparison function as a member function.
+bool Foo::operator==(const Foo &) const = default; // expected-warning 
{{comparing floating point with == or != is unsafe}} expected-note {{in 
defaulted equality comparison operator for 'Foo' first required here}}
+
+// Declare the defaulted comparison function as a non-member function.
+bool operator==(const Foo &, const Foo &) = default;  // expected-warning 
{{comparing floating point with == or != is unsafe}} expected-note {{in 
defaulted equality comparison operator for 'Foo' first required here}}
+
+// Declare the defaulted comparison function as a non-member function. 
Arguments are passed by value.
+bool operator==(Foo, Foo) = default;  // expected-warning {{comparing floating 
point with == or != is unsafe}} expected-note {{in defaulted equality 
comparison operator for 'Foo' first required here}}




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

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

I wanted to check whether you plan to do more opaque pointer test conversions 
in clang. Just to make sure we don't duplicate work...


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] D151162: Add -Wpacked-non-pod to -Wall

2023-05-25 Thread Erich Keane 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 rG916897444778: Reapply: [clang][diagnostics] Adding 
-Wpacked-non-pod to -Wall (authored by SlaterLatiao, committed by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D151162?vs=525744=525764#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151162

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp
  clang/test/CodeGenCXX/warn-padded-packed.cpp
  clang/test/Misc/warning-wall.c


Index: clang/test/Misc/warning-wall.c
===
--- clang/test/Misc/warning-wall.c
+++ clang/test/Misc/warning-wall.c
@@ -99,6 +99,7 @@
 CHECK-NEXT:  -Wswitch
 CHECK-NEXT:  -Wswitch-bool
 CHECK-NEXT:  -Wmisleading-indentation
+CHECK-NEXT:  -Wpacked-non-pod
 
 
 CHECK-NOT:-W
Index: clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp
===
--- clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp
+++ clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp
@@ -1,5 +1,10 @@
 // RUN: %clang_cc1 -triple=x86_64-none-none -Wpadded -Wpacked 
-verify=expected,top %s -emit-llvm-only
 // RUN: %clang_cc1 -triple=x86_64-none-none -Wpadded -Wpacked 
-verify=expected,abi15 -fclang-abi-compat=15 %s -emit-llvm-only
+// -Wpacked-non-pod itself should not emit the "packed attribute is 
unnecessary" warnings.
+// RUN: %clang_cc1 -triple=x86_64-none-none -Wpacked-non-pod -verify=top %s 
-emit-llvm-only
+// -Wall should not emit the "packed attribute is unnecessary" warnings 
without -Wpacked.
+// RUN: %clang_cc1 -triple=x86_64-none-none -Wall -verify=top %s 
-emit-llvm-only
+
 
 struct S1 {
   char c;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1060,7 +1060,7 @@
 // warning should be active _only_ when -Wall is passed in, mark it as
 // DefaultIgnore in addition to putting it here.
 def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool,
-MisleadingIndentation]>;
+MisleadingIndentation, PackedNonPod]>;
 
 // Warnings that should be in clang-cl /w4.
 def : DiagGroup<"CL4", [All, Extra]>;


Index: clang/test/Misc/warning-wall.c
===
--- clang/test/Misc/warning-wall.c
+++ clang/test/Misc/warning-wall.c
@@ -99,6 +99,7 @@
 CHECK-NEXT:  -Wswitch
 CHECK-NEXT:  -Wswitch-bool
 CHECK-NEXT:  -Wmisleading-indentation
+CHECK-NEXT:  -Wpacked-non-pod
 
 
 CHECK-NOT:-W
Index: clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp
===
--- clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp
+++ clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp
@@ -1,5 +1,10 @@
 // RUN: %clang_cc1 -triple=x86_64-none-none -Wpadded -Wpacked -verify=expected,top %s -emit-llvm-only
 // RUN: %clang_cc1 -triple=x86_64-none-none -Wpadded -Wpacked -verify=expected,abi15 -fclang-abi-compat=15 %s -emit-llvm-only
+// -Wpacked-non-pod itself should not emit the "packed attribute is unnecessary" warnings.
+// RUN: %clang_cc1 -triple=x86_64-none-none -Wpacked-non-pod -verify=top %s -emit-llvm-only
+// -Wall should not emit the "packed attribute is unnecessary" warnings without -Wpacked.
+// RUN: %clang_cc1 -triple=x86_64-none-none -Wall -verify=top %s -emit-llvm-only
+
 
 struct S1 {
   char c;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1060,7 +1060,7 @@
 // warning should be active _only_ when -Wall is passed in, mark it as
 // DefaultIgnore in addition to putting it here.
 def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool,
-MisleadingIndentation]>;
+MisleadingIndentation, PackedNonPod]>;
 
 // Warnings that should be in clang-cl /w4.
 def : DiagGroup<"CL4", [All, Extra]>;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9168974 - Reapply: [clang][diagnostics] Adding -Wpacked-non-pod to -Wall

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

Author: Zenong Zhang
Date: 2023-05-25T13:02:00-07:00
New Revision: 91689744477843a588f701fdc598ccff3cbbc8fb

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

LOG: Reapply: [clang][diagnostics] Adding -Wpacked-non-pod to -Wall

Users will be informed when non-POD is not packed using -Wall. This
is also consistent with GCC.

Fixes PR#60832.

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

Added: 
clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp

Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/test/Misc/warning-wall.c

Removed: 
clang/test/CodeGenCXX/warn-padded-packed.cpp



diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 08b8f02460c16..9944fa87aba23 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1060,7 +1060,7 @@ def Consumed   : DiagGroup<"consumed">;
 // warning should be active _only_ when -Wall is passed in, mark it as
 // DefaultIgnore in addition to putting it here.
 def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool,
-MisleadingIndentation]>;
+MisleadingIndentation, PackedNonPod]>;
 
 // Warnings that should be in clang-cl /w4.
 def : DiagGroup<"CL4", [All, Extra]>;

diff  --git a/clang/test/CodeGenCXX/warn-padded-packed.cpp 
b/clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp
similarity index 93%
rename from clang/test/CodeGenCXX/warn-padded-packed.cpp
rename to clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp
index c51a6c9443f6e..5402e21e3a5b8 100644
--- a/clang/test/CodeGenCXX/warn-padded-packed.cpp
+++ b/clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp
@@ -1,5 +1,10 @@
 // RUN: %clang_cc1 -triple=x86_64-none-none -Wpadded -Wpacked 
-verify=expected,top %s -emit-llvm-only
 // RUN: %clang_cc1 -triple=x86_64-none-none -Wpadded -Wpacked 
-verify=expected,abi15 -fclang-abi-compat=15 %s -emit-llvm-only
+// -Wpacked-non-pod itself should not emit the "packed attribute is 
unnecessary" warnings.
+// RUN: %clang_cc1 -triple=x86_64-none-none -Wpacked-non-pod -verify=top %s 
-emit-llvm-only
+// -Wall should not emit the "packed attribute is unnecessary" warnings 
without -Wpacked.
+// RUN: %clang_cc1 -triple=x86_64-none-none -Wall -verify=top %s 
-emit-llvm-only
+
 
 struct S1 {
   char c;

diff  --git a/clang/test/Misc/warning-wall.c b/clang/test/Misc/warning-wall.c
index e57c5d6d501da..1c74759ce6161 100644
--- a/clang/test/Misc/warning-wall.c
+++ b/clang/test/Misc/warning-wall.c
@@ -99,6 +99,7 @@ CHECK-NEXT:-Wdangling-else
 CHECK-NEXT:  -Wswitch
 CHECK-NEXT:  -Wswitch-bool
 CHECK-NEXT:  -Wmisleading-indentation
+CHECK-NEXT:  -Wpacked-non-pod
 
 
 CHECK-NOT:-W



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


[PATCH] D151429: print user provide value in tabstop diagnostic

2023-05-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!

I see this is your first contribution. I'm happy to commit this patch for you 
if you don't have commit access 
 yet. Just 
let me know the name and email you'd like me to put in the commit author field.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151429

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


[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-05-25 Thread Nikita Popov via Phabricator via cfe-commits
nikic added inline comments.



Comment at: 
clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected:12
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[X]], align 4
+// CHECK-NEXT:ret i32 [[TMP1]]
+//

hnrklssn wrote:
> nikic wrote:
> > hnrklssn wrote:
> > > nikic wrote:
> > > > nikic wrote:
> > > > > hnrklssn wrote:
> > > > > > hnrklssn wrote:
> > > > > > > nikic wrote:
> > > > > > > > hnrklssn wrote:
> > > > > > > > > delcypher wrote:
> > > > > > > > > > @hnrklssn I just noticed we don't have a `CHECK` for what 
> > > > > > > > > > `META2` actually refers to. Should we?
> > > > > > > > > > 
> > > > > > > > > > Not something that has to be fixed in this patch, more just 
> > > > > > > > > > an observation.
> > > > > > > > > Indeed this is true for metadata in general, presumably 
> > > > > > > > > because the RHS often refer to things like other metadata 
> > > > > > > > > identifiers. In the case of annotations they seem to always 
> > > > > > > > > refer to simple strings however, so it would be feasible to 
> > > > > > > > > do a straight match without having to do recursive matching 
> > > > > > > > > or complex regexes to determine which part of the metadata to 
> > > > > > > > > match against.
> > > > > > > > > 
> > > > > > > > > In many cases with metadata attached to IR nodes, multiple 
> > > > > > > > > nodes refer to the same metadata node, so at least you verify 
> > > > > > > > > that they still are consistent. But I agree that verifying 
> > > > > > > > > the content would be a great future addition.
> > > > > > > > You need to pass `--check-globals` to check the actual metadata.
> > > > > > > When I add that to this test case it adds
> > > > > > > 
> > > > > > > ```
> > > > > > > //.
> > > > > > > // CHECK: attributes #0 = { noinline nounwind optnone 
> > > > > > > "min-legal-vector-width"="0" "no-trapping-math"="true" 
> > > > > > > "stack-protector-buffer-size"="8" 
> > > > > > > "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
> > > > > > > //.
> > > > > > > // CHECK: !0 = !{i32 1, !"wchar_size", i32 4}
> > > > > > > // CHECK: !1 = !{!"clang version 17.0.0 
> > > > > > > (g...@github.com:llvm/llvm-project.git 
> > > > > > > 684914f47cf59e9ab6d8b0f73c58ca6272ea28d4)"}
> > > > > > > // CHECK: !2 = !{!"auto-init"}
> > > > > > > //.
> > > > > > > ```
> > > > > > > 
> > > > > > > So it seems to just be doing a simple literal matching on all 
> > > > > > > metadata, regardless of whether we captured that metadata in any 
> > > > > > > filecheck variable. And it still doesn't use the META2 variable 
> > > > > > > to match the definition. Am I missing something? If we use the 
> > > > > > > literal metadata names instead of variable matching for the 
> > > > > > > definitions, there isn't much point in doing variable matching 
> > > > > > > for the metadata uses either, since the test still very much 
> > > > > > > relies on the metadata numbering being stable.
> > > > > > @nikic Do you have more information to add about how metadata 
> > > > > > definition matchers can be generated without hardcoding everything 
> > > > > > (which is kind of the opposite of what this patch is trying to do), 
> > > > > > or in general if you're happy with the state of the PR?
> > > > > This works fine with update_test_checks, so it must be some bug in 
> > > > > update_cc_test_checks in particular. From a quick look, I suspect 
> > > > > it's because 
> > > > > https://github.com/llvm/llvm-project/blob/3d05ab6d3e24e76ff53b8d7d623c436b4be5b809/llvm/utils/update_cc_test_checks.py#L447
> > > > >  hardcodes a True value, while update_test_checks makes this 
> > > > > dependent on `--preserve-names`, which is disabled by default there.
> > > > Or maybe just test this with update_test_checks? This change is 
> > > > valuable for that script as well, and it doesn't have this extra issue.
> > > I couldn't find any uses of 
> > > `--preserve-names` in the entire repo (not even in tests for 
> > > update_test_checks), so I went ahead and changed update_cc_test_checks to 
> > > pass True instead.
> > > 
> > > While at it I added 2 new options to match some, but not necessarily all, 
> > > globals. I set the least verbose one (other than "none") as the default, 
> > > emitting checks for the definitions of all globals that we emit matches 
> > > for in the IR. Do you agree that this is reasonable?
> > That sounds like a nice approach. My main question would be whether 
> > `--check-globals seen` is the right default: My gut feeling here is that 
> > this will introduce additional checks for attributes/metadata in tests that 
> > don't actually care about it, but I'm not particularly sure about that.
> > 
> > You might want to do some mass test regeneration and take a look over the 
> > diff to see how useful the changes would be.
> > 
> > If we do change the default, the default change likely need to be part of 
> > `--version 3` to avoid substantial test churn.
> I've 

[PATCH] D127647: [clang][lex] NFCI: Use FileEntryRef in ModuleMap::{load,lookup}ModuleMap()

2023-05-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 525760.
jansvoboda11 added a comment.

Rebase on top of D151398 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127647

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/ModuleMap.cpp

Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -1017,9 +1017,9 @@
   // We haven't looked here before. Load a module map, if there is
   // one.
   bool IsFrameworkDir = Parent.endswith(".framework");
-  if (const FileEntry *ModMapFile =
-HeaderInfo.lookupModuleMapFile(*ParentDir, IsFrameworkDir)) {
-parseModuleMapFile(ModMapFile, Attrs.IsSystem, *ParentDir);
+  if (OptionalFileEntryRef ModMapFile =
+  HeaderInfo.lookupModuleMapFile(*ParentDir, IsFrameworkDir)) {
+parseModuleMapFile(*ModMapFile, Attrs.IsSystem, *ParentDir);
 inferred = InferredDirectories.find(*ParentDir);
   }
 
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1648,10 +1648,10 @@
   return true;
 }
 
-static const FileEntry *getPrivateModuleMap(const FileEntry *File,
+static const FileEntry *getPrivateModuleMap(FileEntryRef File,
 FileManager ) {
-  StringRef Filename = llvm::sys::path::filename(File->getName());
-  SmallString<128>  PrivateFilename(File->getDir()->getName());
+  StringRef Filename = llvm::sys::path::filename(File.getName());
+  SmallString<128>  PrivateFilename(File.getDir().getName());
   if (Filename == "module.map")
 llvm::sys::path::append(PrivateFilename, "module_private.map");
   else if (Filename == "module.modulemap")
@@ -1663,7 +1663,7 @@
   return nullptr;
 }
 
-bool HeaderSearch::loadModuleMapFile(const FileEntry *File, bool IsSystem,
+bool HeaderSearch::loadModuleMapFile(FileEntryRef File, bool IsSystem,
  FileID ID, unsigned *Offset,
  StringRef OriginalModuleMapFile) {
   // Find the directory for the module. For frameworks, that may require going
@@ -1682,9 +1682,7 @@
 Dir = FakeFile.getDir();
   }
 } else {
-  // TODO: Replace with `Dir = File.getDir()` when `File` is switched to
-  // `FileEntryRef`.
-  Dir = FileMgr.getOptionalDirectoryRef(File->getDir()->getName());
+  Dir = File.getDir();
 }
 
 assert(Dir && "parent must exist");
@@ -1713,11 +1711,9 @@
 }
 
 HeaderSearch::LoadModuleMapResult
-HeaderSearch::loadModuleMapFileImpl(const FileEntry *File, bool IsSystem,
+HeaderSearch::loadModuleMapFileImpl(FileEntryRef File, bool IsSystem,
 DirectoryEntryRef Dir, FileID ID,
 unsigned *Offset) {
-  assert(File && "expected FileEntry");
-
   // Check whether we've already loaded this module map, and mark it as being
   // loaded in case we recursively try to load it from itself.
   auto AddResult = LoadedModuleMaps.insert(std::make_pair(File, true));
@@ -1741,23 +1737,23 @@
   return LMM_NewlyLoaded;
 }
 
-const FileEntry *
+OptionalFileEntryRef
 HeaderSearch::lookupModuleMapFile(const DirectoryEntry *Dir, bool IsFramework) {
   if (!HSOpts->ImplicitModuleMaps)
-return nullptr;
+return std::nullopt;
   // For frameworks, the preferred spelling is Modules/module.modulemap, but
   // module.map at the framework root is also accepted.
   SmallString<128> ModuleMapFileName(Dir->getName());
   if (IsFramework)
 llvm::sys::path::append(ModuleMapFileName, "Modules");
   llvm::sys::path::append(ModuleMapFileName, "module.modulemap");
-  if (auto F = FileMgr.getFile(ModuleMapFileName))
+  if (auto F = FileMgr.getOptionalFileRef(ModuleMapFileName))
 return *F;
 
   // Continue to allow module.map
   ModuleMapFileName = Dir->getName();
   llvm::sys::path::append(ModuleMapFileName, "module.map");
-  if (auto F = FileMgr.getFile(ModuleMapFileName))
+  if (auto F = FileMgr.getOptionalFileRef(ModuleMapFileName))
 return *F;
 
   // For frameworks, allow to have a private module map with a preferred
@@ -1766,10 +1762,10 @@
 ModuleMapFileName = Dir->getName();
 llvm::sys::path::append(ModuleMapFileName, "Modules",
 "module.private.modulemap");
-if (auto F = FileMgr.getFile(ModuleMapFileName))
+if (auto F = FileMgr.getOptionalFileRef(ModuleMapFileName))
   return *F;
   }
-  return nullptr;
+  return std::nullopt;
 }
 
 Module *HeaderSearch::loadFrameworkModule(StringRef Name, DirectoryEntryRef Dir,
@@ -1812,9 +1808,10 @@
   if (KnownDir != 

[PATCH] D151293: [clang][ExtractAPI] Refactor serializer to the CRTP

2023-05-25 Thread Erick Velez via Phabricator via cfe-commits
evelez7 abandoned this revision.
evelez7 added inline comments.



Comment at: clang/include/clang/ExtractAPI/Serialization/SerializerBase.h:28-31
+struct APISetVisitorOption {
   /// Do not include unnecessary whitespaces to save space.
   bool Compact;
 };

dang wrote:
> This is very specific to SymbolGraphSerializer or at last to JSON.
If there aren't any base visitor options, I'll just move this to 
`SymbolGraphSerializer` without any inheritance.



Comment at: clang/include/clang/ExtractAPI/Serialization/SerializerBase.h:84
+for (const auto  : API.getObjCProtocols())
+  getDerived()->visitObjCContainerRecord(*Protocol.second);
+  }

dang wrote:
> This should visit some sort Protocol Records specifically. Likewise for 
> interfaces.
Not sure I understand, these functions essentially replace the loops in the old 
`SymbolGraphSerializer::serialize` loops, which are now grouped as function 
calls in `APISetVisitor::traverseAPISet`. Should I add functions that take 
Protocols, Interfaces as parameters to visit them specifically?



Comment at: 
clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:129
   template 
-  void serializeMembers(const APIRecord ,
-const SmallVector> );
+  void visitMembers(const APIRecord ,
+const SmallVector> );

dang wrote:
> I think we shouldn't need to have this method. APISetVisitor should handle 
> calling the relevant visitMethods for the members.
I've been considering how to move it to `APISetVisitor`. Its current 
implementation doesn't seem like it would fit well with a generic base 
implementation. It would be overridden to call `visitRelationship` which relies 
on a `RelationshipKind` parameter. Since that's SymbolKit specific, I don't 
think we'd raise that to the base class.

If there was a base relationship struct that `RelationshipKind` inherited from, 
it might solve that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151293

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


  1   2   3   >