[PATCH] D106757: [PowerPC] Implement partial vector ld/st builtins for XL compatibility

2021-07-24 Thread Albion Fung via Phabricator via cfe-commits
Conanap added a comment.

do we need an IR -> ASM test case as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106757

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


[PATCH] D106757: [PowerPC] Implement partial vector ld/st builtins for XL compatibility

2021-07-24 Thread Albion Fung via Phabricator via cfe-commits
Conanap added inline comments.



Comment at: clang/lib/Headers/altivec.h:3151
+#else
+#define __vec_ldrmb __builtin_vsx_ldrmb
+#define __vec_strmb __builtin_vsx_strmb

I believe the preference is to have this defined in 
`clang/lib/Basic/Targets/PPC.cpp` under `defineXLCompatMacros`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106757

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


[PATCH] D106753: ConvertUTF: Created wrapper convertUTF32ToUTF8String

2021-07-24 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 updated this revision to Diff 361487.
MarcusJohnson91 edited the summary of this revision.
MarcusJohnson91 added a comment.

Added tests


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

https://reviews.llvm.org/D106753

Files:
  llvm/include/llvm/Support/ConvertUTF.h
  llvm/lib/Support/ConvertUTFWrapper.cpp
  llvm/unittests/Support/ConvertUTFTest.cpp

Index: llvm/unittests/Support/ConvertUTFTest.cpp
===
--- llvm/unittests/Support/ConvertUTFTest.cpp
+++ llvm/unittests/Support/ConvertUTFTest.cpp
@@ -36,6 +36,28 @@
   EXPECT_EQ(Expected, Result);
 }
 
+TEST(ConvertUTFTest, ConvertUTF32LittleEndianToUTF8String) {
+  // Src is the look of disapproval.
+  alignas(UTF32) static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
+  ArrayRef Ref(Src, sizeof(Src) - 1);
+  std::string Result;
+  bool Success = convertUTF32ToUTF8String(Ref, Result);
+  EXPECT_TRUE(Success);
+  std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0");
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST(ConvertUTFTest, ConvertUTF32BigEndianToUTF8String) {
+  // Src is the look of disapproval.
+  alignas(UTF32) static const char Src[] = "\xfe\xff\x0c\xa0\x00_\x0c\xa0";
+  ArrayRef Ref(Src, sizeof(Src) - 1);
+  std::string Result;
+  bool Success = convertUTF32ToUTF8String(Ref, Result);
+  EXPECT_TRUE(Success);
+  std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0");
+  EXPECT_EQ(Expected, Result);
+}
+
 TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) {
   // Src is the look of disapproval.
   static const char Src[] = "\xe0\xb2\xa0_\xe0\xb2\xa0";
@@ -78,6 +100,33 @@
   EXPECT_FALSE(HasBOM);
 }
 
+TEST(ConvertUTFTest, HasUTF32BOM) {
+  bool HasBOM = hasUTF32ByteOrderMark(makeArrayRef("\x00\x00\xfe\xff", 4));
+  EXPECT_TRUE(HasBOM);
+  HasBOM = hasUTF32ByteOrderMark(makeArrayRef("\xff\xfe\x00\x00", 4));
+  EXPECT_TRUE(HasBOM);
+  HasBOM = hasUTF32ByteOrderMark(makeArrayRef("\x00\x00\xfe\xff ", 5));
+  EXPECT_TRUE(HasBOM); // Don't care about odd lengths.
+  HasBOM = hasUTF32ByteOrderMark(makeArrayRef("\x00\x00\xfe\xff\x00asdf", 9));
+  EXPECT_TRUE(HasBOM);
+
+  HasBOM = hasUTF32ByteOrderMark(None);
+  EXPECT_FALSE(HasBOM);
+  HasBOM = hasUTF32ByteOrderMark(makeArrayRef("\xfe", 1));
+  EXPECT_FALSE(HasBOM);
+}
+
+TEST(ConvertUTFTest, UTF32WrappersForConvertUTF32ToUTF8String) {
+  // Src is the look of disapproval.
+  alignas(UTF32) static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
+  ArrayRef SrcRef = makeArrayRef((const UTF32 *)Src, 4);
+  std::string Result;
+  bool Success = convertUTF32ToUTF8String(SrcRef, Result);
+  EXPECT_TRUE(Success);
+  std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0");
+  EXPECT_EQ(Expected, Result);
+}
+
 TEST(ConvertUTFTest, UTF16WrappersForConvertUTF16ToUTF8String) {
   // Src is the look of disapproval.
   alignas(UTF16) static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
Index: llvm/lib/Support/ConvertUTFWrapper.cpp
===
--- llvm/lib/Support/ConvertUTFWrapper.cpp
+++ llvm/lib/Support/ConvertUTFWrapper.cpp
@@ -82,6 +82,12 @@
   ((S[0] == '\xff' && S[1] == '\xfe') ||
(S[0] == '\xfe' && S[1] == '\xff')));
 }
+  
+bool hasUTF32ByteOrderMark(ArrayRef S) {
+  return (S.size() >= 4 &&
+  ((S[0] == '\x00' && S[1] == '\x00' && S[2] == '\xfe' && S[3] == '\xff') ||
+   (S[0] == '\xff' && S[1] == '\xfe' && S[2] == '\x00' && S[3] == '\x00')));
+}
 
 bool convertUTF16ToUTF8String(ArrayRef SrcBytes, std::string ) {
   assert(Out.empty());
@@ -140,6 +146,64 @@
   llvm::ArrayRef(reinterpret_cast(Src.data()),
   Src.size() * sizeof(UTF16)), Out);
 }
+  
+bool convertUTF32ToUTF8String(ArrayRef SrcBytes, std::string ) {
+  assert(Out.empty());
+
+  // Error out on an uneven byte count.
+  if (SrcBytes.size() % 2)
+return false;
+
+  // Avoid OOB by returning early on empty input.
+  if (SrcBytes.empty())
+return true;
+
+  const UTF32 *Src = reinterpret_cast(SrcBytes.begin());
+  const UTF32 *SrcEnd = reinterpret_cast(SrcBytes.end());
+
+  assert((uintptr_t)Src % sizeof(UTF32) == 0);
+
+  // Byteswap if necessary.
+  std::vector ByteSwapped;
+  if (Src[0] == UNI_UTF16_BYTE_ORDER_MARK_SWAPPED) {
+ByteSwapped.insert(ByteSwapped.end(), Src, SrcEnd);
+for (unsigned I = 0, E = ByteSwapped.size(); I != E; ++I)
+  ByteSwapped[I] = llvm::ByteSwap_32(ByteSwapped[I]);
+Src = [0];
+SrcEnd = [ByteSwapped.size() - 1] + 1;
+  }
+
+  // Skip the BOM for conversion.
+  if (Src[0] == UNI_UTF32_BYTE_ORDER_MARK_NATIVE)
+Src++;
+
+  // Just allocate enough space up front.  We'll shrink it later.  Allocate
+  // enough that we can fit a null terminator without reallocating.
+  Out.resize(SrcBytes.size() * UNI_MAX_UTF8_BYTES_PER_CODE_POINT + 1);
+  UTF8 *Dst = reinterpret_cast([0]);
+  UTF8 *DstEnd = Dst + Out.size();
+
+  ConversionResult CR =
+  ConvertUTF32toUTF8(, SrcEnd, , DstEnd, strictConversion);
+  

[PATCH] D106753: ConvertUTF: Created wrapper convertUTF32ToUTF8String

2021-07-24 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 updated this revision to Diff 361485.
MarcusJohnson91 added a comment.

Added tests


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

https://reviews.llvm.org/D106753

Files:
  llvm/include/llvm/Support/ConvertUTF.h
  llvm/lib/Support/ConvertUTFWrapper.cpp
  llvm/unittests/Support/ConvertUTFTest.cpp

Index: llvm/unittests/Support/ConvertUTFTest.cpp
===
--- llvm/unittests/Support/ConvertUTFTest.cpp
+++ llvm/unittests/Support/ConvertUTFTest.cpp
@@ -36,6 +36,28 @@
   EXPECT_EQ(Expected, Result);
 }
 
+TEST(ConvertUTFTest, ConvertUTF32LittleEndianToUTF8String) {
+  // Src is the look of disapproval.
+  alignas(UTF32) static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
+  ArrayRef Ref(Src, sizeof(Src) - 1);
+  std::string Result;
+  bool Success = convertUTF32ToUTF8String(Ref, Result);
+  EXPECT_TRUE(Success);
+  std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0");
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST(ConvertUTFTest, ConvertUTF32BigEndianToUTF8String) {
+  // Src is the look of disapproval.
+  alignas(UTF32) static const char Src[] = "\xfe\xff\x0c\xa0\x00_\x0c\xa0";
+  ArrayRef Ref(Src, sizeof(Src) - 1);
+  std::string Result;
+  bool Success = convertUTF32ToUTF8String(Ref, Result);
+  EXPECT_TRUE(Success);
+  std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0");
+  EXPECT_EQ(Expected, Result);
+}
+
 TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) {
   // Src is the look of disapproval.
   static const char Src[] = "\xe0\xb2\xa0_\xe0\xb2\xa0";
Index: llvm/lib/Support/ConvertUTFWrapper.cpp
===
--- llvm/lib/Support/ConvertUTFWrapper.cpp
+++ llvm/lib/Support/ConvertUTFWrapper.cpp
@@ -140,6 +140,64 @@
   llvm::ArrayRef(reinterpret_cast(Src.data()),
   Src.size() * sizeof(UTF16)), Out);
 }
+  
+bool convertUTF32ToUTF8String(ArrayRef SrcBytes, std::string ) {
+  assert(Out.empty());
+
+  // Error out on an uneven byte count.
+  if (SrcBytes.size() % 2)
+return false;
+
+  // Avoid OOB by returning early on empty input.
+  if (SrcBytes.empty())
+return true;
+
+  const UTF32 *Src = reinterpret_cast(SrcBytes.begin());
+  const UTF32 *SrcEnd = reinterpret_cast(SrcBytes.end());
+
+  assert((uintptr_t)Src % sizeof(UTF32) == 0);
+
+  // Byteswap if necessary.
+  std::vector ByteSwapped;
+  if (Src[0] == UNI_UTF16_BYTE_ORDER_MARK_SWAPPED) {
+ByteSwapped.insert(ByteSwapped.end(), Src, SrcEnd);
+for (unsigned I = 0, E = ByteSwapped.size(); I != E; ++I)
+  ByteSwapped[I] = llvm::ByteSwap_32(ByteSwapped[I]);
+Src = [0];
+SrcEnd = [ByteSwapped.size() - 1] + 1;
+  }
+
+  // Skip the BOM for conversion.
+  if (Src[0] == UNI_UTF32_BYTE_ORDER_MARK_NATIVE)
+Src++;
+
+  // Just allocate enough space up front.  We'll shrink it later.  Allocate
+  // enough that we can fit a null terminator without reallocating.
+  Out.resize(SrcBytes.size() * UNI_MAX_UTF8_BYTES_PER_CODE_POINT + 1);
+  UTF8 *Dst = reinterpret_cast([0]);
+  UTF8 *DstEnd = Dst + Out.size();
+
+  ConversionResult CR =
+  ConvertUTF32toUTF8(, SrcEnd, , DstEnd, strictConversion);
+  assert(CR != targetExhausted);
+
+  if (CR != conversionOK) {
+Out.clear();
+return false;
+  }
+
+  Out.resize(reinterpret_cast(Dst) - [0]);
+  Out.push_back(0);
+  Out.pop_back();
+  return true;
+}
+  
+bool convertUTF32ToUTF8String(ArrayRef Src, std::string )
+{
+  return convertUTF16ToUTF8String(
+  llvm::ArrayRef(reinterpret_cast(Src.data()),
+  Src.size() * sizeof(UTF32)), Out);
+}
 
 bool convertUTF8ToUTF16String(StringRef SrcUTF8,
   SmallVectorImpl ) {
Index: llvm/include/llvm/Support/ConvertUTF.h
===
--- llvm/include/llvm/Support/ConvertUTF.h
+++ llvm/include/llvm/Support/ConvertUTF.h
@@ -122,6 +122,9 @@
 
 #define UNI_UTF16_BYTE_ORDER_MARK_NATIVE  0xFEFF
 #define UNI_UTF16_BYTE_ORDER_MARK_SWAPPED 0xFFFE
+  
+#define UNI_UTF32_BYTE_ORDER_MARK_NATIVE  0xFEFF
+#define UNI_UTF32_BYTE_ORDER_MARK_SWAPPED 0xFFFE
 
 typedef enum {
   conversionOK,   /* conversion successful */
@@ -277,6 +280,24 @@
 * \returns true on success
 */
 bool convertUTF16ToUTF8String(ArrayRef Src, std::string );
+  
+/**
+ * Converts a stream of raw bytes assumed to be UTF32 into a UTF8 std::string.
+ *
+ * \param [in] SrcBytes A buffer of what is assumed to be UTF-32 encoded text.
+ * \param [out] Out Converted UTF-8 is stored here on success.
+ * \returns true on success
+ */
+bool convertUTF32ToUTF8String(ArrayRef SrcBytes, std::string );
+
+/**
+* Converts a UTF32 string into a UTF8 std::string.
+*
+* \param [in] Src A buffer of UTF-32 encoded text.
+* \param [out] Out Converted UTF-8 is stored here on success.
+* \returns true on success
+*/
+bool convertUTF32ToUTF8String(ArrayRef Src, std::string );
 
 /**
  * Converts a UTF-8 string into a UTF-16 string with native endianness.

[PATCH] D106701: [clang] Add -falign-loops=N where N is a power of 2

2021-07-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/test/CodeGen/RISCV/loop-alignment.ll:3-4
+; RUN: llc < %s -mtriple=riscv64 | FileCheck %s
+; RUN: llc < %s -mtriple=riscv64 -align-loops=16 | FileCheck %s 
-check-prefix=ALIGN_16
+; RUN: llc < %s -mtriple=riscv64 -align-loops=32 | FileCheck %s 
-check-prefix=ALIGN_32
+

luismarques wrote:
> MaskRay wrote:
> > jrtc27 wrote:
> > > MaskRay wrote:
> > > > jrtc27 wrote:
> > > > > MaskRay wrote:
> > > > > > luismarques wrote:
> > > > > > > Nit: it's a convention of the RISC-V backend codegen tests to 
> > > > > > > wrap the RUN lines.
> > > > > > only 86 columns. compiler-rt is even transiting to 100 column.
> > > > > compiler-rt is not the RISC-V backend :)
> > > > Wrapping lines here just makes the code less readable.
> > > That's your personal opinion, which I disagree with, and it's not true if 
> > > your terminal isn't wide enough. Going against existing convention in the 
> > > backend tests should only be done with very good reason, and personal 
> > > opinion is not that.
> > Lines longer than 80-column (in this case just 86) are pretty common among 
> > tests. I really hope test/CodeGen/RISCV/ can be more tolerant on this 
> > matter.
> > 
> > Even the Linux scripts/checkpatch.pl has increased the limit to 100 because 
> > in many cases wrapping lines for strict 80-conformance just harms 
> > readability.
> > 
> > Of course I don't want to waste time arguing on this matter. So if this 
> > turns out to be an issue for RISC-V folks, I'll update it to save my time.
> > Of course I don't want to waste time arguing on this matter. So if this 
> > turns out to be an issue for RISC-V folks, I'll update it to save my time.
> 
> Personally, I don't particularly care. I don't know if @asb has strong 
> feelings about this. If you think it would be beneficial to relax this 
> convention please raise the issue on llvm-dev. Let's not keep discussing this 
> in every patch touching RISC-V :-)
Personally I don't even think the generic case needs to be raised on llvm-dev:) 
There are just so many column>80 cases in llvm/test and clang/test. Actually, 
If someone wants to enforce the 80-column rule more rigidly, that probably 
needs a discussion.

That said, the argument here is about a subdirectory: llvm/test/CodeGen/RISCV/ 
...




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106701

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


[PATCH] D106701: [clang] Add -falign-loops=N where N is a power of 2

2021-07-24 Thread Luís Marques via Phabricator via cfe-commits
luismarques added inline comments.



Comment at: llvm/test/CodeGen/RISCV/loop-alignment.ll:3-4
+; RUN: llc < %s -mtriple=riscv64 | FileCheck %s
+; RUN: llc < %s -mtriple=riscv64 -align-loops=16 | FileCheck %s 
-check-prefix=ALIGN_16
+; RUN: llc < %s -mtriple=riscv64 -align-loops=32 | FileCheck %s 
-check-prefix=ALIGN_32
+

MaskRay wrote:
> jrtc27 wrote:
> > MaskRay wrote:
> > > jrtc27 wrote:
> > > > MaskRay wrote:
> > > > > luismarques wrote:
> > > > > > Nit: it's a convention of the RISC-V backend codegen tests to wrap 
> > > > > > the RUN lines.
> > > > > only 86 columns. compiler-rt is even transiting to 100 column.
> > > > compiler-rt is not the RISC-V backend :)
> > > Wrapping lines here just makes the code less readable.
> > That's your personal opinion, which I disagree with, and it's not true if 
> > your terminal isn't wide enough. Going against existing convention in the 
> > backend tests should only be done with very good reason, and personal 
> > opinion is not that.
> Lines longer than 80-column (in this case just 86) are pretty common among 
> tests. I really hope test/CodeGen/RISCV/ can be more tolerant on this matter.
> 
> Even the Linux scripts/checkpatch.pl has increased the limit to 100 because 
> in many cases wrapping lines for strict 80-conformance just harms readability.
> 
> Of course I don't want to waste time arguing on this matter. So if this turns 
> out to be an issue for RISC-V folks, I'll update it to save my time.
> Of course I don't want to waste time arguing on this matter. So if this turns 
> out to be an issue for RISC-V folks, I'll update it to save my time.

Personally, I don't particularly care. I don't know if @asb has strong feelings 
about this. If you think it would be beneficial to relax this convention please 
raise the issue on llvm-dev. Let's not keep discussing this in every patch 
touching RISC-V :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106701

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


[PATCH] D106733: [clang/darwin] Pass libclang_rt.profile last on linker command

2021-07-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

LG


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

https://reviews.llvm.org/D106733

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


[PATCH] D105527: libclang.so: Make SONAME independent from LLVM version

2021-07-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/LibClang/lit.local.cfg:1
+
+config.substitutions.append(('%libclang', os.path.join(config.clang_lib_dir, 
'libclang.so')))

delete blank line



Comment at: clang/test/LibClang/symbols.test:2
+# Check that there are no unversioned clang symbols in libclang.so
+RUN: llvm-nm -Dj --defined-only %libclang | grep -v -e '@@LLVM_[0-9]\+$' | not 
grep '^clang'

Also a test that no local symbol is called `clang_*`

A `local: *` can easily localize unintented `clang_*` symbols



Comment at: clang/tools/libclang/libclang.map:405
+clang_visitChildrenWithBlock;
+local: *;
+};

MaskRay wrote:
> Make its indentation match `global:`
You may consider

```
LLVM_13 {
  /* no global: here */
  clang_foobar;
}

local {
  local: *;
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105527

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


[PATCH] D106732: Support macro deprecation #pragma clang deprecated

2021-07-24 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 361480.
beanz added a comment.

Updating comment about remaining bits.

Rather than subtracting one, I re-added up the bits. The bitfield is now at
40 bits, so it only has 24 bits remaining (someone please check my math).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106732

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Pragma.cpp
  clang/test/Lexer/deprecate-macro.c

Index: clang/test/Lexer/deprecate-macro.c
===
--- /dev/null
+++ clang/test/Lexer/deprecate-macro.c
@@ -0,0 +1,42 @@
+// RUN: not %clang_cc1 -Wdeprecated %s -fsyntax-only
+
+// expected-error@+1{{expected '(' in #pragma clang deprecated}}
+#pragma clang deprecated
+
+// expected-error@+1{{expected string literal in #pragma clang deprecated}}
+#pragma clang deprecated(4
+
+// expected-error@+1{{expected string literal in #pragma clang deprecated}}
+#pragma clang deprecated(foo)
+
+// expected-warning@+1{{'foo' is not a defined macro for #pragma clang deprecated}}
+#pragma clang deprecated("foo")
+
+#define bar 1
+#pragma clang deprecated("bar", "bar is deprecated use 1")
+
+// expected-warning@+1{{macro 'bar' has been marked as deprecated: Bar is deprecated use 1}}
+#if bar
+#endif
+
+#define foo 1
+#pragma clang deprecated("foo")
+
+// expected-error@+1{{expected ')' in #pragma clang deprecated}}
+#pragma clang deprecated("foo"
+
+// expected-warning@+1{{macro 'foo' has been marked as deprecated}}
+#if foo
+#endif
+
+// expected-warning@+1{{macro 'foo' has been marked as deprecated}}
+#if defined(foo)
+#endif
+
+int main(int argc, char** argv) {
+  // expected-warning@+1{{#pragma clang deprecate 'main' is not a defined macro}}
+#pragma clang deprecated("main")
+
+  // expected-warning@+1{{macro 'foo' has been marked as deprecated}}
+  return foo;
+}
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -1911,6 +1911,54 @@
   }
 };
 
+/// "\#pragma deprecate()"
+///
+/// The syntax is
+/// \code
+///   #pragma clang deprecate(MACRO_NAME)
+/// \endcode
+struct PragmaDeprecatedHandler : public PragmaHandler {
+  PragmaDeprecatedHandler() : PragmaHandler("deprecated") {}
+
+  void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
+Token ) override {
+std::string Macro, MessageString;
+
+PP.Lex(Tok);
+if (Tok.isNot(tok::l_paren)) {
+  PP.Diag(Tok, diag::err_pragma_deprecated_expected) << "(";
+  return;
+}
+
+PP.Lex(Tok);
+if (!PP.FinishLexStringLiteral(Tok, Macro, "#pragma clang deprecated",
+   /*AllowMacroExpansion=*/true))
+  return;
+IdentifierInfo *II = PP.getIdentifierInfo(Macro);
+
+if (!II->hasMacroDefinition() || !II->hadMacroDefinition()) {
+  PP.Diag(Tok, diag::warn_pragma_deprecated_not_a_macro) << II->getName();
+  return;
+}
+
+if (Tok.is(tok::comma)) {
+  PP.Lex(Tok);
+  if (!PP.FinishLexStringLiteral(Tok, MessageString,
+ "#pragma clang deprecated",
+ /*AllowMacroExpansion=*/true))
+return;
+}
+
+if (Tok.isNot(tok::r_paren)) {
+  PP.Diag(Tok, diag::err_pragma_deprecated_expected) << ")";
+  return;
+}
+
+II->setIsDeprecatedMacro(true);
+PP.addMacroDeprecationMsg(II, std::move(MessageString));
+  }
+};
+
 } // namespace
 
 /// RegisterBuiltinPragmas - Install the standard preprocessor pragmas:
@@ -1939,6 +1987,7 @@
   AddPragmaHandler("clang", new PragmaDiagnosticHandler("clang"));
   AddPragmaHandler("clang", new PragmaARCCFCodeAuditedHandler());
   AddPragmaHandler("clang", new PragmaAssumeNonNullHandler());
+  AddPragmaHandler("clang", new PragmaDeprecatedHandler());
 
   // #pragma clang module ...
   auto *ModuleHandler = new PragmaNamespace("module");
Index: clang/lib/Lex/PPMacroExpansion.cpp
===
--- clang/lib/Lex/PPMacroExpansion.cpp
+++ clang/lib/Lex/PPMacroExpansion.cpp
@@ -471,6 +471,16 @@
 /// expanded as a macro, handle it and return the next token as 'Identifier'.
 bool Preprocessor::HandleMacroExpandedIdentifier(Token ,
  const MacroDefinition ) {
+  if (Identifier.getIdentifierInfo()->isDeprecatedMacro()) {
+auto MsgEntry = MacroDeprecationMsgs.find(Identifier.getIdentifierInfo());
+if (MsgEntry == MacroDeprecationMsgs.end())
+  Diag(Identifier, diag::warn_pragma_deprecated_macro_use)
+  << Identifier.getIdentifierInfo()->getName();
+

[PATCH] D106701: [clang] Add -falign-loops=N where N is a power of 2

2021-07-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked an inline comment as done.
MaskRay added inline comments.



Comment at: llvm/test/CodeGen/RISCV/loop-alignment.ll:3-4
+; RUN: llc < %s -mtriple=riscv64 | FileCheck %s
+; RUN: llc < %s -mtriple=riscv64 -align-loops=16 | FileCheck %s 
-check-prefix=ALIGN_16
+; RUN: llc < %s -mtriple=riscv64 -align-loops=32 | FileCheck %s 
-check-prefix=ALIGN_32
+

jrtc27 wrote:
> MaskRay wrote:
> > jrtc27 wrote:
> > > MaskRay wrote:
> > > > luismarques wrote:
> > > > > Nit: it's a convention of the RISC-V backend codegen tests to wrap 
> > > > > the RUN lines.
> > > > only 86 columns. compiler-rt is even transiting to 100 column.
> > > compiler-rt is not the RISC-V backend :)
> > Wrapping lines here just makes the code less readable.
> That's your personal opinion, which I disagree with, and it's not true if 
> your terminal isn't wide enough. Going against existing convention in the 
> backend tests should only be done with very good reason, and personal opinion 
> is not that.
Lines longer than 80-column (in this case just 86) are pretty common among 
tests. I really hope test/CodeGen/RISCV/ can be more tolerant on this matter.

Even the Linux scripts/checkpatch.pl has increased the limit to 100 because in 
many cases wrapping lines for strict 80-conformance just harms readability.

Of course I don't want to waste time arguing on this matter. So if this turns 
out to be an issue for RISC-V folks, I'll update it to save my time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106701

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


[PATCH] D106737: DRAFT - [clang] [hexagon] Add resource include dir

2021-07-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added a comment.
This revision now requires changes to proceed.

Thanks for the patch. This makes the behavior closer to Linux.cpp . Request 
changes to clear my queue before a test is added...




Comment at: clang/lib/Driver/ToolChains/Hexagon.cpp:604
+  const bool HasSysRoot = !D.SysRoot.empty();
+  if (HasSysRoot) {
 SmallString<128> P(D.SysRoot);

To match Linux.cpp, this code block should be unconditional.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106737

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


[PATCH] D106701: [clang] Add -falign-loops=N where N is a power of 2

2021-07-24 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: llvm/test/CodeGen/RISCV/loop-alignment.ll:3-4
+; RUN: llc < %s -mtriple=riscv64 | FileCheck %s
+; RUN: llc < %s -mtriple=riscv64 -align-loops=16 | FileCheck %s 
-check-prefix=ALIGN_16
+; RUN: llc < %s -mtriple=riscv64 -align-loops=32 | FileCheck %s 
-check-prefix=ALIGN_32
+

MaskRay wrote:
> jrtc27 wrote:
> > MaskRay wrote:
> > > luismarques wrote:
> > > > Nit: it's a convention of the RISC-V backend codegen tests to wrap the 
> > > > RUN lines.
> > > only 86 columns. compiler-rt is even transiting to 100 column.
> > compiler-rt is not the RISC-V backend :)
> Wrapping lines here just makes the code less readable.
That's your personal opinion, which I disagree with, and it's not true if your 
terminal isn't wide enough. Going against existing convention in the backend 
tests should only be done with very good reason, and personal opinion is not 
that.



Comment at: llvm/test/CodeGen/RISCV/loop-alignment.ll:13
+
+; ALIGN_16-LABEL: test:
+; ALIGN_16: .p2align 4

MaskRay wrote:
> jrtc27 wrote:
> > - not _ in check prefixes
> I find that `_` in check prefixes is also popular.
> 
> It has the benefit that `_` cannot conflict with `-NOT` -LABEL` etc.
I have never seen it before and there are zero uses of it in RISC-V CodeGen 
tests. Please conform to the existing style by using -.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106701

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


[PATCH] D106756: Added l16/l32 length modifiers for char16_t/char32_t

2021-07-24 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 created this revision.
MarcusJohnson91 added reviewers: aaron.ballman, efriedma.
MarcusJohnson91 added a project: clang.
MarcusJohnson91 requested review of this revision.

Split from D103426 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106756

Files:
  clang/include/clang/AST/FormatString.h
  clang/lib/AST/FormatString.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/ScanfFormatString.cpp
  clang/test/Sema/format-strings-int-typedefs.c

Index: clang/test/Sema/format-strings-int-typedefs.c
===
--- clang/test/Sema/format-strings-int-typedefs.c
+++ clang/test/Sema/format-strings-int-typedefs.c
@@ -12,6 +12,10 @@
   printf("%td", 42.0); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'int')}}
   printf("%lc", 42.0); // expected-warning {{format specifies type 'wint_t' (aka 'int')}}
   printf("%ls", 42.0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+  printf("%l16c", 42.0); // expected-warning {{format specifies type 'char16_t' (aka 'int')}}
+  printf("%l16s", 42.0); // expected-warning {{format specifies type 'char16_t *' (aka 'int *')}}
+  printf("%l32c", 42.0); // expected-warning {{format specifies type 'char32_t' (aka 'int')}}
+  printf("%l32s", 42.0); // expected-warning {{format specifies type 'char32_t *' (aka 'int *')}}
   printf("%S", 42.0);  // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
   printf("%C", 42.0);  // expected-warning {{format specifies type 'wchar_t' (aka 'int')}}
   
@@ -21,6 +25,10 @@
   wprintf(L"%td", 42.0); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'int')}}
   wprintf(L"%lc", 42.0); // expected-warning {{format specifies type 'wint_t' (aka 'int')}}
   wprintf(L"%ls", 42.0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+  wprintf(L"%l16c", 42.0); // expected-warning {{format specifies type 'char16_t' (aka 'int')}}
+  wprintf(L"%l16s", 42.0); // expected-warning {{format specifies type 'char16_t *' (aka 'int *')}}
+  wprintf(L"%l32c", 42.0); // expected-warning {{format specifies type 'char32_t' (aka 'int')}}
+  wprintf(L"%l32s", 42.0); // expected-warning {{format specifies type 'char32_t *' (aka 'int *')}}
   wprintf(L"%S", 42.0);  // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
   wprintf(L"%C", 42.0);  // expected-warning {{format specifies type 'wchar_t' (aka 'int')}}
 
@@ -30,6 +38,10 @@
   scanf("%td", 0); // expected-warning {{format specifies type 'ptrdiff_t *' (aka 'int *')}}
   scanf("%lc", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
   scanf("%ls", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+  scanf("%l16c", 0); // expected-warning {{format specifies type 'char16_t *' (aka 'int *')}}
+  scanf("%l16s", 0); // expected-warning {{format specifies type 'char16_t *' (aka 'int *')}}
+  scanf("%l32c", 0); // expected-warning {{format specifies type 'char32_t *' (aka 'int *')}}
+  scanf("%l32s", 0); // expected-warning {{format specifies type 'char32_t *' (aka 'int *')}}
   scanf("%S",  0);  // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
   scanf("%C",  0);  // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
   
@@ -39,6 +51,10 @@
   wscanf("%td", 0); // expected-warning {{format specifies type 'ptrdiff_t *' (aka 'int *')}}
   wscanf("%lc", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
   wscanf("%ls", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+  wscanf("%l16c", 0); // expected-warning {{format specifies type 'char16_t *' (aka 'int *')}}
+  wscanf("%l16s", 0); // expected-warning {{format specifies type 'char16_t *' (aka 'int *')}}
+  wscanf("%l32c", 0); // expected-warning {{format specifies type 'char32_t *' (aka 'int *')}}
+  wscanf("%l32s", 0); // expected-warning {{format specifies type 'char32_t *' (aka 'int *')}}
   wscanf("%S",  0);  // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
   wscanf("%C",  0);  // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
 
Index: clang/lib/AST/ScanfFormatString.cpp
===
--- clang/lib/AST/ScanfFormatString.cpp
+++ clang/lib/AST/ScanfFormatString.cpp
@@ -261,6 +261,8 @@
 case LengthModifier::AsInt32:
 case LengthModifier::AsInt3264:
 case LengthModifier::AsWide:
+case LengthModifier::AsUTF16:
+case LengthModifier::AsUTF32:
 case LengthModifier::AsShortLong:
   return ArgType::Invalid();
   }
@@ -302,6 +304,8 @@
 case LengthModifier::AsInt32:
 case LengthModifier::AsInt3264:
 case LengthModifier::AsWide:
+case LengthModifier::AsUTF16:
+case LengthModifier::AsUTF32:
 case 

[PATCH] D106755: Extended format string checking to wprintf/wscanf

2021-07-24 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 created this revision.
Herald added a subscriber: martong.
Herald added a reviewer: aaron.ballman.
MarcusJohnson91 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Split from D103426 


https://reviews.llvm.org/D106755

Files:
  clang-tools-extra/clang-tidy/boost/UseToStringCheck.cpp
  clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/FormatString.h
  clang/include/clang/AST/Type.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/OSLog.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaFixItUtils.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
  clang/test/Sema/format-strings-c90.c
  clang/test/Sema/format-strings-darwin.c
  clang/test/Sema/format-strings-int-typedefs.c
  clang/test/Sema/format-strings-ms.c
  clang/test/Sema/format-strings-non-iso.c
  clang/test/Sema/format-strings-pedantic.c
  clang/test/Sema/format-strings-scanf.c
  clang/test/Sema/string-plus-char.c
  clang/test/SemaCXX/format-strings-0x.cpp
  clang/test/SemaCXX/format-strings.cpp

Index: clang/test/SemaCXX/format-strings.cpp
===
--- clang/test/SemaCXX/format-strings.cpp
+++ clang/test/SemaCXX/format-strings.cpp
@@ -7,7 +7,10 @@
 extern "C" {
 extern int scanf(const char *restrict, ...);
 extern int printf(const char *restrict, ...);
+extern int wscanf(const char *restrict, ...);
+extern int wprintf(const char *restrict, ...);
 extern int vprintf(const char *restrict, va_list);
+extern int vwprintf(const char *restrict, va_list);
 }
 
 void f(char **sp, float *fp) {
@@ -17,13 +20,24 @@
 #else
   // expected-warning@-4 {{format specifies type 'float *' but the argument has type 'char **'}}
 #endif
+  
+  scanf("%as", sp);
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{'a' length modifier is not supported by ISO C}}
+#else
+  // expected-warning@-4 {{format specifies type 'float *' but the argument has type 'wchar_t **'}}
+#endif
 
   printf("%a", 1.0);
   scanf("%afoobar", fp);
+  
+  wprintf("%a", 1.0);
+  wscanf("%afoobar", fp);
 }
 
 void g() {
   printf("%ls", "foo"); // expected-warning{{format specifies type 'wchar_t *' but the argument has type 'const char *'}}
+  wprintf("%ls", "foo"); // expected-warning{{format specifies type 'wchar_t *' but the argument has type 'const char *'}}
 }
 
 // Test that we properly handle format_idx on C++ members.
@@ -76,7 +90,7 @@
   va_start(ap,fmt);
   const char * const format = fmt;
   vprintf(format, ap); // no-warning
-
+  
   const char *format2 = fmt;
   vprintf(format2, ap); // expected-warning{{format string is not a string literal}}
 
Index: clang/test/SemaCXX/format-strings-0x.cpp
===
--- clang/test/SemaCXX/format-strings-0x.cpp
+++ clang/test/SemaCXX/format-strings-0x.cpp
@@ -3,33 +3,53 @@
 extern "C" {
 extern int scanf(const char *restrict, ...);
 extern int printf(const char *restrict, ...);
+extern int wscanf(const wchar_t *restrict, ...);
 }
 
 void f(char **sp, float *fp) {
   scanf("%as", sp); // expected-warning{{format specifies type 'float *' but the argument has type 'char **'}}
+  wscanf("%as", sp); // expected-warning{{format specifies type 'float *' but the argument has type 'wchar_t **'}}
 
   printf("%p", sp); // expected-warning{{format specifies type 'void *' but the argument has type 'char **'}}
+  wprintf("%p", sp); // expected-warning{{format specifies type 'void *' but the argument has type 'wchar_t **'}}
   scanf("%p", sp);  // expected-warning{{format specifies type 'void **' but the argument has type 'char **'}}
+  wscanf("%p", sp);  // expected-warning{{format specifies type 'void **' but the argument has type 'wchar_t **'}}
 
   printf("%a", 1.0);
   scanf("%afoobar", fp);
+  wprintf("%a", 1.0);
+  wscanf("%afoobar", fp);
   printf(nullptr);
   printf(*sp); // expected-warning {{not a string literal}}
   // expected-note@-1{{treat the string as an argument to avoid this}}
+  wprintf(*sp); // expected-warning {{not a string literal}}
+  // expected-note@-1{{treat the string as an argument to avoid this}}
 
   // PR13099
   printf(
 R"foobar(%)foobar"
 R"bazquux(d)bazquux" // expected-warning {{more '%' conversions than data arguments}}
 R"xyzzy()xyzzy");
+  wprintf(
+R"foobar(%)foobar"
+

[PATCH] D106701: [clang] Add -falign-loops=N where N is a power of 2

2021-07-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked 2 inline comments as done.
MaskRay added inline comments.



Comment at: llvm/test/CodeGen/RISCV/loop-alignment.ll:3-4
+; RUN: llc < %s -mtriple=riscv64 | FileCheck %s
+; RUN: llc < %s -mtriple=riscv64 -align-loops=16 | FileCheck %s 
-check-prefix=ALIGN_16
+; RUN: llc < %s -mtriple=riscv64 -align-loops=32 | FileCheck %s 
-check-prefix=ALIGN_32
+

jrtc27 wrote:
> MaskRay wrote:
> > luismarques wrote:
> > > Nit: it's a convention of the RISC-V backend codegen tests to wrap the 
> > > RUN lines.
> > only 86 columns. compiler-rt is even transiting to 100 column.
> compiler-rt is not the RISC-V backend :)
Wrapping lines here just makes the code less readable.



Comment at: llvm/test/CodeGen/RISCV/loop-alignment.ll:13
+
+; ALIGN_16-LABEL: test:
+; ALIGN_16: .p2align 4

jrtc27 wrote:
> - not _ in check prefixes
I find that `_` in check prefixes is also popular.

It has the benefit that `_` cannot conflict with `-NOT` -LABEL` etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106701

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


[PATCH] D106753: ConvertUTF: Created wrapper convertUTF32ToUTF8String

2021-07-24 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 created this revision.
MarcusJohnson91 added a project: clang.
Herald added subscribers: dexonsmith, hiraditya.
MarcusJohnson91 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Split from D103426 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106753

Files:
  llvm/include/llvm/Support/ConvertUTF.h
  llvm/lib/Support/ConvertUTFWrapper.cpp

Index: llvm/lib/Support/ConvertUTFWrapper.cpp
===
--- llvm/lib/Support/ConvertUTFWrapper.cpp
+++ llvm/lib/Support/ConvertUTFWrapper.cpp
@@ -140,6 +140,64 @@
   llvm::ArrayRef(reinterpret_cast(Src.data()),
   Src.size() * sizeof(UTF16)), Out);
 }
+  
+bool convertUTF32ToUTF8String(ArrayRef SrcBytes, std::string ) {
+  assert(Out.empty());
+
+  // Error out on an uneven byte count.
+  if (SrcBytes.size() % 2)
+return false;
+
+  // Avoid OOB by returning early on empty input.
+  if (SrcBytes.empty())
+return true;
+
+  const UTF32 *Src = reinterpret_cast(SrcBytes.begin());
+  const UTF32 *SrcEnd = reinterpret_cast(SrcBytes.end());
+
+  assert((uintptr_t)Src % sizeof(UTF32) == 0);
+
+  // Byteswap if necessary.
+  std::vector ByteSwapped;
+  if (Src[0] == UNI_UTF16_BYTE_ORDER_MARK_SWAPPED) {
+ByteSwapped.insert(ByteSwapped.end(), Src, SrcEnd);
+for (unsigned I = 0, E = ByteSwapped.size(); I != E; ++I)
+  ByteSwapped[I] = llvm::ByteSwap_32(ByteSwapped[I]);
+Src = [0];
+SrcEnd = [ByteSwapped.size() - 1] + 1;
+  }
+
+  // Skip the BOM for conversion.
+  if (Src[0] == UNI_UTF32_BYTE_ORDER_MARK_NATIVE)
+Src++;
+
+  // Just allocate enough space up front.  We'll shrink it later.  Allocate
+  // enough that we can fit a null terminator without reallocating.
+  Out.resize(SrcBytes.size() * UNI_MAX_UTF8_BYTES_PER_CODE_POINT + 1);
+  UTF8 *Dst = reinterpret_cast([0]);
+  UTF8 *DstEnd = Dst + Out.size();
+
+  ConversionResult CR =
+  ConvertUTF32toUTF8(, SrcEnd, , DstEnd, strictConversion);
+  assert(CR != targetExhausted);
+
+  if (CR != conversionOK) {
+Out.clear();
+return false;
+  }
+
+  Out.resize(reinterpret_cast(Dst) - [0]);
+  Out.push_back(0);
+  Out.pop_back();
+  return true;
+}
+  
+bool convertUTF32ToUTF8String(ArrayRef Src, std::string )
+{
+  return convertUTF16ToUTF8String(
+  llvm::ArrayRef(reinterpret_cast(Src.data()),
+  Src.size() * sizeof(UTF32)), Out);
+}
 
 bool convertUTF8ToUTF16String(StringRef SrcUTF8,
   SmallVectorImpl ) {
Index: llvm/include/llvm/Support/ConvertUTF.h
===
--- llvm/include/llvm/Support/ConvertUTF.h
+++ llvm/include/llvm/Support/ConvertUTF.h
@@ -122,6 +122,9 @@
 
 #define UNI_UTF16_BYTE_ORDER_MARK_NATIVE  0xFEFF
 #define UNI_UTF16_BYTE_ORDER_MARK_SWAPPED 0xFFFE
+  
+#define UNI_UTF32_BYTE_ORDER_MARK_NATIVE  0xFEFF
+#define UNI_UTF32_BYTE_ORDER_MARK_SWAPPED 0xFFFE
 
 typedef enum {
   conversionOK,   /* conversion successful */
@@ -277,6 +280,24 @@
 * \returns true on success
 */
 bool convertUTF16ToUTF8String(ArrayRef Src, std::string );
+  
+/**
+ * Converts a stream of raw bytes assumed to be UTF32 into a UTF8 std::string.
+ *
+ * \param [in] SrcBytes A buffer of what is assumed to be UTF-32 encoded text.
+ * \param [out] Out Converted UTF-8 is stored here on success.
+ * \returns true on success
+ */
+bool convertUTF32ToUTF8String(ArrayRef SrcBytes, std::string );
+
+/**
+* Converts a UTF32 string into a UTF8 std::string.
+*
+* \param [in] Src A buffer of UTF-32 encoded text.
+* \param [out] Out Converted UTF-8 is stored here on success.
+* \returns true on success
+*/
+bool convertUTF32ToUTF8String(ArrayRef Src, std::string );
 
 /**
  * Converts a UTF-8 string into a UTF-16 string with native endianness.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106585: Fix clang debug info irgen of i128 enums

2021-07-24 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.

Preserving existing behavior sounds OK - maybe some comment about that it might 
be good to remove so the next person who looks at it knows there's something 
not-quite-fully-reasoned here (& the comment about GCC's representation choice 
still seems off - GCC does use the signedness of the enumerators, not only the 
enumeration).




Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3117
+llvm::APSInt Value = Enum->getInitVal();
+Value.setIsSigned(IsSigned);
+Enumerators.push_back(DBuilder.createEnumerator(Enum->getName(), Value));

rnk wrote:
> MaskRay wrote:
> > dblaikie wrote:
> > > rnk wrote:
> > > > rnk wrote:
> > > > > dblaikie wrote:
> > > > > > rnk wrote:
> > > > > > > dblaikie wrote:
> > > > > > > > Is the value already signed appropriately?
> > > > > > > > 
> > > > > > > > Removing this line of code (and the `bool IsSigned` variable, 
> > > > > > > > so it doesn't break `-Werror=unused-variable`) doesn't cause 
> > > > > > > > any tests to fail, that I can see.
> > > > > > > I'm afraid it might not be NFC. I took the cautious approach of 
> > > > > > > trying to leave things exactly as they were. Enums in C can have 
> > > > > > > surprisingly different behavior, IIRC.
> > > > > > I'd rather not leave in haunted-graveyard-y code like that.
> > > > > > 
> > > > > > Could we assert that Value.getIsSigned == IsSigned? Then if there's 
> > > > > > a case where it isn't we'll have a test case/justification for the 
> > > > > > code?
> > > > > I convinced myself that the signed-ness of the APSInt in the 
> > > > > EnumConstantDecl always matches by looking at this code here:
> > > > > https://github.com/llvm/llvm-project/blob/aee8457b8d4123d087c45aef95d14f24934fed53/clang/lib/Sema/SemaDecl.cpp#L18379
> > > > > 
> > > > > So far as I can tell, we always run that code, no matter whether 
> > > > > LangOpts.CPlusPlus is set or not. That's enough for me.
> > > > Oh, I was wrong, your suggested change *does* break 
> > > > clang/test/CodeGen/enum2.c. My caution was warranted. :)
> > > Hrm, still not quite clear on what's going on. Seems like GCC actually 
> > > does things differently - it does produce DWARF using the signedness of 
> > > the literal to dictate the signedness of the enumerator, which seems 
> > > inconsistent with the comment ("This matches the DWARF produced by GCC 
> > > for C enums with positive enumerators" - well it's consistent with that 
> > > statement (for positive enumerators) but inconsistent with what happens 
> > > if you mix sign of enumerators - then GCC uses different encodings, but 
> > > Clang doesn't (regardless of the representational difference - with 
> > > isSigned true or false))
> > > 
> > > Looks like LLVM, for DWARF at least, uses the signedness of the 
> > > enumeration's type ( 
> > > https://github.com/llvm-mirror/llvm/blob/2c4ca6832fa6b306ee6a7010bfb80a3f2596f824/lib/CodeGen/AsmPrinter/DwarfUnit.cpp#L1406-L1427
> > >  ). (the BTF backend seems to respect the individual signedness)
> > > 
> > > So... mixed feelings? For DWARF it looks like the signed-ness 
> > > representation doesn't matter/is ignored and only the signedness of the 
> > > enumeration is used. GCC respects the signedness of different expressions 
> > > - but I don't know that that's a good choice either, seems like it should 
> > > represent the value of the enumerator proper, not of the expression used 
> > > to initialize the enumerator.
> > > 
> > > And also - what's the deal with the APInt encoding? It looks like 
> > > something in the IR printing correctly encodes the signedness of the 
> > > APInt value:
> > > ```
> > > $ clang-tot enum.c -g -c -emit-llvm -S -o - | grep Enumerator
> > > !6 = !DIEnumerator(name: "A", value: 0)
> > > !7 = !DIEnumerator(name: "B", value: -1)
> > > ```
> > > (this is the output without the per-enumerator signedness initialization)
> > > So how's that working & why do we carry the extra signedness in a boolean 
> > > as well? 
> > > 
> > > Sorry, feel free to ignore all this if it's not worth the rabbit-hole. 
> > > I'm generally OK with this preserving the existing behavior - but it does 
> > > raise a bunch of questions for me.
> > > 
> > > 
> > > Seems like GCC actually does things differently
> > 
> > Can you elaborate a bit with an example?
> > 
> > I played with this a bit and GCC does appear to behave similar to clang 
> > with this patch.
> > 
> > Because of disallowed C++11 narrowing, I cannot place an signed enumerator 
> > in a enumeration type with an unsigned underlying type:
> > 
> > GCC
> > error: enumerator value ‘-3’ is outside the range of underlying type ‘long 
> > unsigned int’
> > (clang can suppress this with -Wno-c++11-narrowing/-Wno-narrowing)
> > 
> > And also - what's the deal with the APInt encoding? It looks like something 
> > in the IR printing correctly encodes the signedness of the APInt value:
> 
> I believe LLVM IR integers 

[PATCH] D106721: [AArch64] Implemnt MSVC __mulh and __umulh builtins and corresponding IR level intrinsics

2021-07-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

We won't call compiler-rt for i128 multiply on aarch64.  It's not worthwhile 
under any circumstances.

Pattern-matching 64/64->128 multiply in SelectionDAG legalization has been 
reliable in practice, as far as I know.  And even it misses due to weird 
behavior in instcombine or something like that, we only end up with one or two 
extra mla instructions, so not a big deal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106721

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


[PATCH] D103426: Clang: Extend format string checking to wprintf/wscanf

2021-07-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

This should split into three patches:

1. The ConvertUTFWrapper patch.
2. The patch to add format warnings for wprintf/wscanf/etc.
3. The patch to add the %l16/%l32 format modifiers.




Comment at: clang/lib/AST/Expr.cpp:1091
+  if (llvm::convertUTF32ToUTF8String(AR, Output)) {
+CString = new char[Output.size() + 1];
+memcpy(CString, Output.c_str(), Output.size());

This leaks memory.

This function should return either a StringRef to memory that's part of AST 
object, or an std::string.



Comment at: clang/lib/AST/OSLog.cpp:206
   const StringLiteral *Lit = 
cast(StringArg->IgnoreParenCasts());
-  assert(Lit && (Lit->isAscii() || Lit->isUTF8()));
-  StringRef Data = Lit->getString();
+  assert(Lit);
+  std::string String(Lit->getStrDataAsChar());

Why are you changing this code?



Comment at: clang/lib/AST/Type.cpp:1962
 
+bool Type::isType(const std::string TypeName) const {
+  QualType Desugar = this->getLocallyUnqualifiedSingleStepDesugaredType();

MarcusJohnson91 wrote:
> aaron.ballman wrote:
> > Oh, I see now that this is doing a name comparison against the type -- 
> > that's not a good API in general because it's *really* hard to guess at 
> > what the type will come out as textually. e.g., `class` and `struct` 
> > keywords are interchangeable in C++, C sometimes gets confused with `bool` 
> > vs `_Bool`, template arguments sometimes matter, nested name specifiers, 
> > etc. Callers of this API will have to guess at these details and the 
> > printing of the type may change over time (e.g., C may switch from `_Bool` 
> > to `bool` and then code calling `isType("_Bool")` may react poorly to the 
> > change).
> > 
> > I think we need to avoid this sort of API on `Type`.
> I see your point, I reverted the behavior back to doing the desugaring in 
> just isChar16Type and isChar32Type
I'm not convinced we should be looking at sugar even in 
isChar16Type/isChar32Type/isAnyCharacterType.  That seems like a great way to 
end up with subtle bugs that only manifest when someone uses the wrong typedef.

Where is the distinction between the value `(uint32_t)1` vs. `(char32_t)1` 
relevant for C, anyway?



Comment at: clang/lib/Sema/SemaChecking.cpp:103
+#include 
+#include 
 

Stray includes?



Comment at: clang/test/Sema/format-strings-non-iso.c:6
+
+int wprintf(const char *restrict, ...);
+int wscanf(const char  *restrict, ...);

This declaration is wrong?  Does that not cause a warning somewhere?



Comment at: llvm/lib/Support/ConvertUTFWrapper.cpp:148
+  // Error out on an uneven byte count.
+  if (SrcBytes.size() % 2)
+return false;

sizeof(UTF32)?


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

https://reviews.llvm.org/D103426

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


[PATCH] D106701: [clang] Add -falign-loops=N where N is a power of 2

2021-07-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D106701#2902544 , @dblaikie wrote:

> In D106701#2901656 , @MaskRay wrote:
>
>> In D106701#2901639 , @efriedma 
>> wrote:
>>
>>> Can we hook this up to a LLVM IR function attribute, instead of making it a 
>>> codegen flag?
>>
>> The current TargetLoweringBase::PrefLoopAlignment is global. I have 
>> considered a function attribute, but it seems overkill for now.
>> (Inlining behavior is a bit unclear.)
>> The current use cases just need a global value instead of a refined 
>> per-function value.
>
> global module metadata is also an option

Using a global module metadata needs to think of the merging behavior.
The behavior isn't clear.

> (what's the motivation for adding this feature - do you have a use-case in 
> mind?)

Use case: x86 has a `cl::opt`. RISC-V is exploring D106570 
.

> (the usual: This should probably be committed as separate patches - at least 
> LLVM, then Clang pieces)

(Can commit the llvm/ part first.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106701

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


[PATCH] D106701: [clang] Add -falign-loops=N where N is a power of 2

2021-07-24 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: llvm/test/CodeGen/RISCV/loop-alignment.ll:3-4
+; RUN: llc < %s -mtriple=riscv64 | FileCheck %s
+; RUN: llc < %s -mtriple=riscv64 -align-loops=16 | FileCheck %s 
-check-prefix=ALIGN_16
+; RUN: llc < %s -mtriple=riscv64 -align-loops=32 | FileCheck %s 
-check-prefix=ALIGN_32
+

MaskRay wrote:
> luismarques wrote:
> > Nit: it's a convention of the RISC-V backend codegen tests to wrap the RUN 
> > lines.
> only 86 columns. compiler-rt is even transiting to 100 column.
compiler-rt is not the RISC-V backend :)



Comment at: llvm/test/CodeGen/RISCV/loop-alignment.ll:10
+; CHECK-LABEL:test:
+; CHECK-NOT:.p2align
+; CHECK:ret

This isn't autogenerated? Also NOT on .p2align isn't great in general, .balign 
and .align don't match that yet could have been emitted.



Comment at: llvm/test/CodeGen/RISCV/loop-alignment.ll:13
+
+; ALIGN_16-LABEL: test:
+; ALIGN_16: .p2align 4

- not _ in check prefixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106701

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


[PATCH] D106701: [clang] Add -falign-loops=N where N is a power of 2

2021-07-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D106701#2902544 , @dblaikie wrote:

> In D106701#2901656 , @MaskRay wrote:
>
>> In D106701#2901639 , @efriedma 
>> wrote:
>>
>>> Can we hook this up to a LLVM IR function attribute, instead of making it a 
>>> codegen flag?
>>
>> The current TargetLoweringBase::PrefLoopAlignment is global. I have 
>> considered a function attribute, but it seems overkill for now.
>> (Inlining behavior is a bit unclear.)
>> The current use cases just need a global value instead of a refined 
>> per-function value.
>
> global module metadata is also an option
>
> (what's the motivation for adding this feature - do you have a use-case in 
> mind?)
>
> (the usual: This should probably be committed as separate patches - at least 
> LLVM, then Clang pieces)

I would like to have this for experimenting on RISCV. I was proposing to add 
similar hidden options like X86 in D106570 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106701

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


[PATCH] D106701: [clang] Add -falign-loops=N where N is a power of 2

2021-07-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/test/CodeGen/RISCV/loop-alignment.ll:3-4
+; RUN: llc < %s -mtriple=riscv64 | FileCheck %s
+; RUN: llc < %s -mtriple=riscv64 -align-loops=16 | FileCheck %s 
-check-prefix=ALIGN_16
+; RUN: llc < %s -mtriple=riscv64 -align-loops=32 | FileCheck %s 
-check-prefix=ALIGN_32
+

luismarques wrote:
> Nit: it's a convention of the RISC-V backend codegen tests to wrap the RUN 
> lines.
only 86 columns. compiler-rt is even transiting to 100 column.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106701

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


[PATCH] D106701: [clang] Add -falign-loops=N where N is a power of 2

2021-07-24 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D106701#2901656 , @MaskRay wrote:

> In D106701#2901639 , @efriedma 
> wrote:
>
>> Can we hook this up to a LLVM IR function attribute, instead of making it a 
>> codegen flag?
>
> The current TargetLoweringBase::PrefLoopAlignment is global. I have 
> considered a function attribute, but it seems overkill for now.
> (Inlining behavior is a bit unclear.)
> The current use cases just need a global value instead of a refined 
> per-function value.

global module metadata is also an option

(what's the motivation for adding this feature - do you have a use-case in 
mind?)

(the usual: This should probably be committed as separate patches - at least 
LLVM, then Clang pieces)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106701

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


[PATCH] D106746: [OpenMPOpt] Expand SPMDization with guarding

2021-07-24 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis updated this revision to Diff 361468.
ggeorgakoudis added a comment.

Code cleanup


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106746

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  openmp/libomptarget/deviceRTLs/common/include/target.h
  openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
  openmp/libomptarget/deviceRTLs/common/src/parallel.cu
  openmp/libomptarget/deviceRTLs/common/support.h
  openmp/libomptarget/deviceRTLs/interface.h

Index: openmp/libomptarget/deviceRTLs/interface.h
===
--- openmp/libomptarget/deviceRTLs/interface.h
+++ openmp/libomptarget/deviceRTLs/interface.h
@@ -417,8 +417,9 @@
 
 // non standard
 EXTERN int32_t __kmpc_target_init(ident_t *Ident, bool IsSPMD,
- bool UseGenericStateMachine,
-   bool RequiresFullRuntime);
+  bool IsSPMDGuarded,
+  bool UseGenericStateMachine,
+  bool RequiresFullRuntime);
 EXTERN void __kmpc_target_deinit(ident_t *Ident, bool IsSPMD,
bool RequiresFullRuntime);
 EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn);
@@ -449,6 +450,8 @@
 // SPMD execution mode interrogation function.
 EXTERN int8_t __kmpc_is_spmd_exec_mode();
 
+EXTERN int8_t __kmpc_is_spmd_guarded_exec_mode();
+
 /// Return true if the hardware thread id \p Tid represents the OpenMP main
 /// thread in generic mode outside of a parallel region.
 EXTERN int8_t __kmpc_is_generic_main_thread(kmp_int32 Tid);
Index: openmp/libomptarget/deviceRTLs/common/support.h
===
--- openmp/libomptarget/deviceRTLs/common/support.h
+++ openmp/libomptarget/deviceRTLs/common/support.h
@@ -22,13 +22,14 @@
 enum ExecutionMode {
   Spmd = 0x00u,
   Generic = 0x01u,
-  ModeMask = 0x01u,
+  SpmdGuarded = 0x02u,
+  ModeMask = 0x03u,
 };
 
 enum RuntimeMode {
   RuntimeInitialized = 0x00u,
-  RuntimeUninitialized = 0x02u,
-  RuntimeMask = 0x02u,
+  RuntimeUninitialized = 0x04u,
+  RuntimeMask = 0x04u,
 };
 
 void setExecutionParameters(ExecutionMode EMode, RuntimeMode RMode);
Index: openmp/libomptarget/deviceRTLs/common/src/parallel.cu
===
--- openmp/libomptarget/deviceRTLs/common/src/parallel.cu
+++ openmp/libomptarget/deviceRTLs/common/src/parallel.cu
@@ -300,7 +300,36 @@
   }
 
   if (__kmpc_is_spmd_exec_mode()) {
+// Store spmd_guarded status to check after the parallel region executes.
+int is_spmd_guarded = __kmpc_is_spmd_guarded_exec_mode();
+if (is_spmd_guarded) {
+  // No barrier is need on entry since this will be called only from non-guarded
+  // SPMD execution.
+
+  // Disable SPMD guarding for the parallel region. Runtime suport is not needed
+  // by construction of SPMD guarded regions, so simple assignment to Spmd is
+  // enough. Also, a preceding barrier is unnecessary since all threads must be
+  // in non-guarded context when reaching this point.
+  if (__kmpc_get_hardware_thread_id_in_block() == 0)
+execution_param = Spmd;
+
+  // Barrier to ensure all threads are updated to Spmd.
+  __kmpc_barrier_simple_spmd(ident, 0);
+}
+
 __kmp_invoke_microtask(global_tid, 0, fn, args, nargs);
+
+if (is_spmd_guarded) {
+  // Re-enable SPMD guarding. Runtime support is not needed by construction.
+  // Barrier to ensure all threads have finished Spmd execution before
+  // re-enabling guarding.
+  __kmpc_barrier_simple_spmd(ident, 0);
+  if (__kmpc_get_hardware_thread_id_in_block() == 0)
+execution_param = SpmdGuarded;
+
+  // Barrier to ensure all threads are updated to SpmdGuarded.
+  __kmpc_barrier_simple_spmd(ident, 0);
+}
 return;
   }
 
Index: openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
===
--- openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
+++ openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
@@ -82,11 +82,12 @@
   omptarget_nvptx_workFn = 0;
 }
 
-static void __kmpc_spmd_kernel_init(bool RequiresFullRuntime) {
+static void __kmpc_spmd_kernel_init(bool IsSPMDGuarded, bool RequiresFullRuntime) {
   PRINT0(LD_IO, "call to __kmpc_spmd_kernel_init\n");
 
-  setExecutionParameters(Spmd, RequiresFullRuntime ? RuntimeInitialized
- : RuntimeUninitialized);
+  setExecutionParameters(IsSPMDGuarded ? SpmdGuarded : Spmd,
+ RequiresFullRuntime ? RuntimeInitialized
+  

[PATCH] D106701: [clang] Add -falign-loops=N where N is a power of 2

2021-07-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 361467.
MaskRay marked 2 inline comments as done.
MaskRay added a comment.

comments. add a test/CodeGen test. add HelpText.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106701

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/align-loops.c
  clang/test/Driver/falign-loops.c
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/test/CodeGen/RISCV/align-loops.ll
  llvm/test/CodeGen/X86/innermost-loop-alignment.ll

Index: llvm/test/CodeGen/X86/innermost-loop-alignment.ll
===
--- llvm/test/CodeGen/X86/innermost-loop-alignment.ll
+++ llvm/test/CodeGen/X86/innermost-loop-alignment.ll
@@ -1,7 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc < %s -mtriple=i686-pc-linux-gnu | FileCheck %s -check-prefix=DEFAULT
 ; RUN: llc < %s -mtriple=i686-pc-linux-gnu -x86-experimental-pref-innermost-loop-alignment=5 | FileCheck %s -check-prefix=ALIGN32
-; RUN: llc < %s -mtriple=i686-pc-linux-gnu -x86-experimental-pref-loop-alignment=5 -x86-experimental-pref-innermost-loop-alignment=6 | FileCheck %s -check-prefix=ALIGN64
+; RUN: llc < %s -mtriple=i686-pc-linux-gnu -align-loops=32 -x86-experimental-pref-innermost-loop-alignment=6 | FileCheck %s -check-prefix=ALIGN64
 
 declare void @foo()
 
Index: llvm/test/CodeGen/RISCV/align-loops.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/align-loops.ll
@@ -0,0 +1,44 @@
+; RUN: llc < %s -mtriple=riscv64 | FileCheck %s
+; RUN: llc < %s -mtriple=riscv64 -align-loops=16 | FileCheck %s -check-prefix=ALIGN_16
+; RUN: llc < %s -mtriple=riscv64 -align-loops=32 | FileCheck %s -check-prefix=ALIGN_32
+
+declare void @foo()
+
+define void @test(i32 %n, i32 %m) nounwind {
+; CHECK-LABEL:test:
+; CHECK-NOT:.p2align
+; CHECK:ret
+
+; ALIGN_16-LABEL: test:
+; ALIGN_16: .p2align 4{{$}}
+; ALIGN_16-NEXT:  .LBB0_1: # %outer
+; ALIGN_16: .p2align 4{{$}}
+; ALIGN_16-NEXT:  .LBB0_2: # %inner
+
+; ALIGN_32-LABEL: test:
+; ALIGN_32: .p2align 5{{$}}
+; ALIGN_32-NEXT:  .LBB0_1: # %outer
+; ALIGN_32: .p2align 5{{$}}
+; ALIGN_32-NEXT:  .LBB0_2: # %inner
+entry:
+  br label %outer
+
+outer:
+  %outer.iv = phi i32 [0, %entry], [%outer.iv.next, %outer_bb]
+  br label %inner
+
+inner:
+  %inner.iv = phi i32 [0, %outer], [%inner.iv.next, %inner]
+  call void @foo()
+  %inner.iv.next = add i32 %inner.iv, 1
+  %inner.cond = icmp ne i32 %inner.iv.next, %m
+  br i1 %inner.cond, label %inner, label %outer_bb
+
+outer_bb:
+  %outer.iv.next = add i32 %outer.iv, 1
+  %outer.cond = icmp ne i32 %outer.iv.next, %n
+  br i1 %outer.cond, label %outer, label %exit
+
+exit:
+  ret void
+}
Index: llvm/lib/CodeGen/TargetLoweringBase.cpp
===
--- llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -52,6 +52,7 @@
 #include "llvm/Support/MachineValueType.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Target/TargetMachine.h"
+#include "llvm/Target/TargetOptions.h"
 #include "llvm/Transforms/Utils/SizeOpts.h"
 #include 
 #include 
@@ -2020,6 +2021,12 @@
   return getTargetMachine().isPositionIndependent();
 }
 
+Align TargetLoweringBase::getPrefLoopAlignment(MachineLoop *ML) const {
+  if (TM.Options.LoopAlignment)
+return Align(TM.Options.LoopAlignment);
+  return PrefLoopAlignment;
+}
+
 //===--===//
 //  Reciprocal Estimates
 //===--===//
Index: llvm/lib/CodeGen/CommandFlags.cpp
===
--- llvm/lib/CodeGen/CommandFlags.cpp
+++ llvm/lib/CodeGen/CommandFlags.cpp
@@ -94,6 +94,7 @@
 CGOPT(bool, ForceDwarfFrameSection)
 CGOPT(bool, XRayOmitFunctionIndex)
 CGOPT(bool, DebugStrictDwarf)
+CGOPT(unsigned, AlignLoops)
 
 codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() {
 #define CGBINDOPT(NAME)\
@@ -452,6 +453,10 @@
   "strict-dwarf", cl::desc("use strict dwarf"), cl::init(false));
   CGBINDOPT(DebugStrictDwarf);
 
+  static cl::opt AlignLoops("align-loops",
+  cl::desc("Default alignment for loops"));
+  CGBINDOPT(AlignLoops);
+
 #undef CGBINDOPT
 
   mc::RegisterMCTargetOptionsFlags();
@@ 

[PATCH] D103426: Clang: Extend format string checking to wprintf/wscanf

2021-07-24 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 updated this revision to Diff 361466.
MarcusJohnson91 added a comment.

Full context diff after squashing all the commits together


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

https://reviews.llvm.org/D103426

Files:
  clang-tools-extra/clang-tidy/boost/UseToStringCheck.cpp
  clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/FormatString.h
  clang/include/clang/AST/Type.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/FormatString.cpp
  clang/lib/AST/OSLog.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/ScanfFormatString.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaFixItUtils.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
  clang/test/Sema/format-strings-c90.c
  clang/test/Sema/format-strings-darwin.c
  clang/test/Sema/format-strings-int-typedefs.c
  clang/test/Sema/format-strings-ms.c
  clang/test/Sema/format-strings-non-iso.c
  clang/test/Sema/format-strings-pedantic.c
  clang/test/Sema/format-strings-scanf.c
  clang/test/Sema/string-plus-char.c
  clang/test/SemaCXX/format-strings-0x.cpp
  clang/test/SemaCXX/format-strings.cpp
  llvm/include/llvm/Support/ConvertUTF.h
  llvm/lib/Support/ConvertUTFWrapper.cpp

Index: llvm/lib/Support/ConvertUTFWrapper.cpp
===
--- llvm/lib/Support/ConvertUTFWrapper.cpp
+++ llvm/lib/Support/ConvertUTFWrapper.cpp
@@ -140,6 +140,64 @@
   llvm::ArrayRef(reinterpret_cast(Src.data()),
   Src.size() * sizeof(UTF16)), Out);
 }
+  
+bool convertUTF32ToUTF8String(ArrayRef SrcBytes, std::string ) {
+  assert(Out.empty());
+
+  // Error out on an uneven byte count.
+  if (SrcBytes.size() % 2)
+return false;
+
+  // Avoid OOB by returning early on empty input.
+  if (SrcBytes.empty())
+return true;
+
+  const UTF32 *Src = reinterpret_cast(SrcBytes.begin());
+  const UTF32 *SrcEnd = reinterpret_cast(SrcBytes.end());
+
+  assert((uintptr_t)Src % sizeof(UTF32) == 0);
+
+  // Byteswap if necessary.
+  std::vector ByteSwapped;
+  if (Src[0] == UNI_UTF16_BYTE_ORDER_MARK_SWAPPED) {
+ByteSwapped.insert(ByteSwapped.end(), Src, SrcEnd);
+for (unsigned I = 0, E = ByteSwapped.size(); I != E; ++I)
+  ByteSwapped[I] = llvm::ByteSwap_32(ByteSwapped[I]);
+Src = [0];
+SrcEnd = [ByteSwapped.size() - 1] + 1;
+  }
+
+  // Skip the BOM for conversion.
+  if (Src[0] == UNI_UTF32_BYTE_ORDER_MARK_NATIVE)
+Src++;
+
+  // Just allocate enough space up front.  We'll shrink it later.  Allocate
+  // enough that we can fit a null terminator without reallocating.
+  Out.resize(SrcBytes.size() * UNI_MAX_UTF8_BYTES_PER_CODE_POINT + 1);
+  UTF8 *Dst = reinterpret_cast([0]);
+  UTF8 *DstEnd = Dst + Out.size();
+
+  ConversionResult CR =
+  ConvertUTF32toUTF8(, SrcEnd, , DstEnd, strictConversion);
+  assert(CR != targetExhausted);
+
+  if (CR != conversionOK) {
+Out.clear();
+return false;
+  }
+
+  Out.resize(reinterpret_cast(Dst) - [0]);
+  Out.push_back(0);
+  Out.pop_back();
+  return true;
+}
+  
+bool convertUTF32ToUTF8String(ArrayRef Src, std::string )
+{
+  return convertUTF16ToUTF8String(
+  llvm::ArrayRef(reinterpret_cast(Src.data()),
+  Src.size() * sizeof(UTF32)), Out);
+}
 
 bool convertUTF8ToUTF16String(StringRef SrcUTF8,
   SmallVectorImpl ) {
Index: llvm/include/llvm/Support/ConvertUTF.h
===
--- llvm/include/llvm/Support/ConvertUTF.h
+++ llvm/include/llvm/Support/ConvertUTF.h
@@ -122,6 +122,9 @@
 
 #define UNI_UTF16_BYTE_ORDER_MARK_NATIVE  0xFEFF
 #define UNI_UTF16_BYTE_ORDER_MARK_SWAPPED 0xFFFE
+  
+#define UNI_UTF32_BYTE_ORDER_MARK_NATIVE  0xFEFF
+#define UNI_UTF32_BYTE_ORDER_MARK_SWAPPED 0xFFFE
 
 typedef enum {
   conversionOK,   /* conversion successful */
@@ -277,6 +280,24 @@
 * \returns true on success
 */
 bool convertUTF16ToUTF8String(ArrayRef Src, std::string );
+  
+/**
+ * Converts a stream of raw bytes assumed to be UTF32 into a UTF8 std::string.
+ *
+ * \param [in] SrcBytes A buffer of what is assumed to be UTF-32 encoded text.
+ * \param [out] Out Converted UTF-8 is stored here on success.
+ * \returns true on success
+ */
+bool convertUTF32ToUTF8String(ArrayRef SrcBytes, std::string );
+
+/**
+* Converts a UTF32 string into a UTF8 std::string.
+*
+* \param [in] Src A buffer of UTF-32 encoded text.
+* \param [out] Out 

[PATCH] D106748: [OpenCL] Add support of __opencl_c_pipes feature macro.

2021-07-24 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov created this revision.
azabaznov added reviewers: Anastasia, svenvh.
Herald added subscribers: ldrumm, yaxunl.
azabaznov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

'pipe' keyword is introduced in OpenCL C 2.0: so do checks for OpenCL C version 
while
parsing and then later on check for language options to construct actual pipe. 
This feature
requires support of __opencl_c_generic_address_space, so diagnostics for that 
is provided as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106748

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/lib/Basic/OpenCLOptions.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/Sema.cpp
  clang/test/CodeGenOpenCL/address-spaces-mangling.cl
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/pipe_builtin.cl
  clang/test/CodeGenOpenCL/pipe_types.cl
  clang/test/CodeGenOpenCL/pipe_types_mangling.cl
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/Parser/opencl-cl20.cl
  clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
  clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
  clang/test/SemaOpenCL/storageclass.cl

Index: clang/test/SemaOpenCL/storageclass.cl
===
--- clang/test/SemaOpenCL/storageclass.cl
+++ clang/test/SemaOpenCL/storageclass.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
 static constant int G1 = 0;
@@ -44,11 +44,11 @@
 
 static generic float g_generic_static_var = 0;
 #if (__OPENCL_C_VERSION__ < 300)
-// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}}
+// expected-error@-2 {{type qualifier 'generic' requires OpenCL C 2.0 or later and a feature support}}
 // expected-error@-3 {{program scope variable must reside in constant address space}}
 #elif (__OPENCL_C_VERSION__ == 300)
  #if !defined(__opencl_c_generic_address_space)
-// expected-error@-6 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
+// expected-error@-6 {{type qualifier 'generic' requires OpenCL C 2.0 or later and a feature support}}
  #endif
  #if !defined(__opencl_c_program_scope_global_variables)
 // expected-error@-9 {{program scope variable must reside in constant address space}}
@@ -86,11 +86,11 @@
 
 extern generic float g_generic_extern_var;
 #if (__OPENCL_C_VERSION__ < 300)
-// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}}
+// expected-error@-2 {{type qualifier 'generic' requires OpenCL C 2.0 or later and a feature support}}
 // expected-error@-3 {{extern variable must reside in constant address space}}
 #elif (__OPENCL_C_VERSION__ == 300)
  #if !defined(__opencl_c_generic_address_space)
-// expected-error@-6 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
+// expected-error@-6 {{type qualifier 'generic' requires OpenCL C 2.0 or later and a feature support}}
  #endif
  #if !defined(__opencl_c_program_scope_global_variables)
 // expected-error@-9 {{extern variable must reside in constant address space}}
@@ -189,11 +189,11 @@
 
   static generic float l_generic_static_var = 0;
 #if (__OPENCL_C_VERSION__ < 300)
-// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}}
+// expected-error@-2 {{type qualifier 'generic' requires OpenCL C 2.0 or later and a feature support}}
 // expected-error@-3 {{variables in function scope cannot be declared static}}
 #elif (__OPENCL_C_VERSION__ == 300)
  #if !defined(__opencl_c_generic_address_space)
-// expected-error@-6 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
+// expected-error@-6 {{type qualifier 'generic' requires OpenCL C 2.0 or later and a feature support}}
  #endif
  #if !defined(__opencl_c_program_scope_global_variables)
 // expected-error@-9 {{static local variable must reside in constant address space}}
@@ -239,11 +239,11 @@
 
   extern 

[PATCH] D106746: [OpenMPOpt][WIP] Expand SPMDization with guarding

2021-07-24 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis updated this revision to Diff 361456.
ggeorgakoudis added a comment.

Update for sensible access to __kmpc_is_spmd_guarded_exec_mode


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106746

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  openmp/libomptarget/deviceRTLs/common/include/target.h
  openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
  openmp/libomptarget/deviceRTLs/common/src/parallel.cu
  openmp/libomptarget/deviceRTLs/common/support.h
  openmp/libomptarget/deviceRTLs/interface.h

Index: openmp/libomptarget/deviceRTLs/interface.h
===
--- openmp/libomptarget/deviceRTLs/interface.h
+++ openmp/libomptarget/deviceRTLs/interface.h
@@ -417,8 +417,9 @@
 
 // non standard
 EXTERN int32_t __kmpc_target_init(ident_t *Ident, bool IsSPMD,
- bool UseGenericStateMachine,
-   bool RequiresFullRuntime);
+  bool IsSPMDGuarded,
+  bool UseGenericStateMachine,
+  bool RequiresFullRuntime);
 EXTERN void __kmpc_target_deinit(ident_t *Ident, bool IsSPMD,
bool RequiresFullRuntime);
 EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn);
@@ -449,6 +450,8 @@
 // SPMD execution mode interrogation function.
 EXTERN int8_t __kmpc_is_spmd_exec_mode();
 
+EXTERN int8_t __kmpc_is_spmd_guarded_exec_mode();
+
 /// Return true if the hardware thread id \p Tid represents the OpenMP main
 /// thread in generic mode outside of a parallel region.
 EXTERN int8_t __kmpc_is_generic_main_thread(kmp_int32 Tid);
Index: openmp/libomptarget/deviceRTLs/common/support.h
===
--- openmp/libomptarget/deviceRTLs/common/support.h
+++ openmp/libomptarget/deviceRTLs/common/support.h
@@ -22,13 +22,14 @@
 enum ExecutionMode {
   Spmd = 0x00u,
   Generic = 0x01u,
-  ModeMask = 0x01u,
+  SpmdGuarded = 0x02u,
+  ModeMask = 0x03u,
 };
 
 enum RuntimeMode {
   RuntimeInitialized = 0x00u,
-  RuntimeUninitialized = 0x02u,
-  RuntimeMask = 0x02u,
+  RuntimeUninitialized = 0x04u,
+  RuntimeMask = 0x04u,
 };
 
 void setExecutionParameters(ExecutionMode EMode, RuntimeMode RMode);
Index: openmp/libomptarget/deviceRTLs/common/src/parallel.cu
===
--- openmp/libomptarget/deviceRTLs/common/src/parallel.cu
+++ openmp/libomptarget/deviceRTLs/common/src/parallel.cu
@@ -300,7 +300,36 @@
   }
 
   if (__kmpc_is_spmd_exec_mode()) {
+// Store spmd_guarded status to check after the parallel region executes.
+int is_spmd_guarded = __kmpc_is_spmd_guarded_exec_mode();
+if (is_spmd_guarded) {
+  // No barrier is need on entry since this will be called only from non-guarded
+  // SPMD execution.
+
+  // Disable SPMD guarding for the parallel region. Runtime suport is not needed
+  // by construction of SPMD guarded regions, so simple assignment to Spmd is
+  // enough. Also, a preceding barrier is unnecessary since all threads must be
+  // in non-guarded context when reaching this point.
+  if (__kmpc_get_hardware_thread_id_in_block() == 0)
+execution_param = Spmd;
+
+  // Barrier to ensure all threads are updated to Spmd.
+  __kmpc_barrier_simple_spmd(ident, 0);
+}
+
 __kmp_invoke_microtask(global_tid, 0, fn, args, nargs);
+
+if (is_spmd_guarded) {
+  // Re-enable SPMD guarding. Runtime support is not needed by construction.
+  // Barrier to ensure all threads have finished Spmd execution before
+  // re-enabling guarding.
+  __kmpc_barrier_simple_spmd(ident, 0);
+  if (__kmpc_get_hardware_thread_id_in_block() == 0)
+execution_param = SpmdGuarded;
+
+  // Barrier to ensure all threads are updated to SpmdGuarded.
+  __kmpc_barrier_simple_spmd(ident, 0);
+}
 return;
   }
 
Index: openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
===
--- openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
+++ openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
@@ -82,11 +82,12 @@
   omptarget_nvptx_workFn = 0;
 }
 
-static void __kmpc_spmd_kernel_init(bool RequiresFullRuntime) {
+static void __kmpc_spmd_kernel_init(bool IsSPMDGuarded, bool RequiresFullRuntime) {
   PRINT0(LD_IO, "call to __kmpc_spmd_kernel_init\n");
 
-  setExecutionParameters(Spmd, RequiresFullRuntime ? RuntimeInitialized
- : RuntimeUninitialized);
+  setExecutionParameters(IsSPMDGuarded ? SpmdGuarded : Spmd,
+ RequiresFullRuntime ? 

[PATCH] D106701: [clang] Add -falign-loops=N where N is a power of 2

2021-07-24 Thread Luís Marques via Phabricator via cfe-commits
luismarques added a comment.

LGTM. I'll let someone familiar with the old option explicitly approve it.




Comment at: clang/test/Driver/falign-loops.c:6-7
+// RUN: %clang -### -falign-loops=5 %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-5
+// RUN: %clang -### -falign-loops=8 %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-8
+// RUN: %clang -### -falign-loops=65537 %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-65537
+// RUN: %clang -### -falign-loops=a %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-ERR-A

I would generally expect to see the `<= x` bound tested with `x` and `x+1`, not 
just `x+1`.



Comment at: llvm/test/CodeGen/RISCV/loop-alignment.ll:3-4
+; RUN: llc < %s -mtriple=riscv64 | FileCheck %s
+; RUN: llc < %s -mtriple=riscv64 -align-loops=16 | FileCheck %s 
-check-prefix=ALIGN_16
+; RUN: llc < %s -mtriple=riscv64 -align-loops=32 | FileCheck %s 
-check-prefix=ALIGN_32
+

Nit: it's a convention of the RISC-V backend codegen tests to wrap the RUN 
lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106701

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


[PATCH] D106746: [OpenMPOpt][WIP] Expand SPMDIzation with guarding

2021-07-24 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis created this revision.
Herald added subscribers: ormris, guansong, hiraditya, yaxunl.
ggeorgakoudis requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added subscribers: llvm-commits, openmp-commits, cfe-commits, bbn, 
sstefan1.
Herald added a reviewer: baziotis.
Herald added projects: clang, OpenMP, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106746

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  openmp/libomptarget/deviceRTLs/common/include/target.h
  openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
  openmp/libomptarget/deviceRTLs/common/src/parallel.cu
  openmp/libomptarget/deviceRTLs/common/support.h
  openmp/libomptarget/deviceRTLs/interface.h

Index: openmp/libomptarget/deviceRTLs/interface.h
===
--- openmp/libomptarget/deviceRTLs/interface.h
+++ openmp/libomptarget/deviceRTLs/interface.h
@@ -417,8 +417,9 @@
 
 // non standard
 EXTERN int32_t __kmpc_target_init(ident_t *Ident, bool IsSPMD,
- bool UseGenericStateMachine,
-   bool RequiresFullRuntime);
+  bool IsSPMDGuarded,
+  bool UseGenericStateMachine,
+  bool RequiresFullRuntime);
 EXTERN void __kmpc_target_deinit(ident_t *Ident, bool IsSPMD,
bool RequiresFullRuntime);
 EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn);
@@ -449,6 +450,8 @@
 // SPMD execution mode interrogation function.
 EXTERN int8_t __kmpc_is_spmd_exec_mode();
 
+EXTERN int8_t __kmpc_is_spmd_guarded_exec_mode();
+
 /// Return true if the hardware thread id \p Tid represents the OpenMP main
 /// thread in generic mode outside of a parallel region.
 EXTERN int8_t __kmpc_is_generic_main_thread(kmp_int32 Tid);
Index: openmp/libomptarget/deviceRTLs/common/support.h
===
--- openmp/libomptarget/deviceRTLs/common/support.h
+++ openmp/libomptarget/deviceRTLs/common/support.h
@@ -22,13 +22,14 @@
 enum ExecutionMode {
   Spmd = 0x00u,
   Generic = 0x01u,
-  ModeMask = 0x01u,
+  SpmdGuarded = 0x02u,
+  ModeMask = 0x03u,
 };
 
 enum RuntimeMode {
   RuntimeInitialized = 0x00u,
-  RuntimeUninitialized = 0x02u,
-  RuntimeMask = 0x02u,
+  RuntimeUninitialized = 0x04u,
+  RuntimeMask = 0x04u,
 };
 
 void setExecutionParameters(ExecutionMode EMode, RuntimeMode RMode);
Index: openmp/libomptarget/deviceRTLs/common/src/parallel.cu
===
--- openmp/libomptarget/deviceRTLs/common/src/parallel.cu
+++ openmp/libomptarget/deviceRTLs/common/src/parallel.cu
@@ -300,7 +300,36 @@
   }
 
   if (__kmpc_is_spmd_exec_mode()) {
+// Store spmd_guarded status to check after the parallel region executes.
+int is_spmd_guarded = __kmpc_is_spmd_guarded_exec_mode();
+if (is_spmd_guarded) {
+  // No barrier is need on entry since this will be called only from non-guarded
+  // SPMD execution.
+
+  // Disable SPMD guarding for the parallel region. Runtime suport is not needed
+  // by construction of SPMD guarded regions, so simple assignment to Spmd is
+  // enough. Also, a preceding barrier is unnecessary since all threads must be
+  // in non-guarded context when reaching this point.
+  if (__kmpc_get_hardware_thread_id_in_block() == 0)
+execution_param = Spmd;
+
+  // Barrier to ensure all threads are updated to Spmd.
+  __kmpc_barrier_simple_spmd(ident, 0);
+}
+
 __kmp_invoke_microtask(global_tid, 0, fn, args, nargs);
+
+if (is_spmd_guarded) {
+  // Re-enable SPMD guarding. Runtime support is not needed by construction.
+  // Barrier to ensure all threads have finished Spmd execution before
+  // re-enabling guarding.
+  __kmpc_barrier_simple_spmd(ident, 0);
+  if (__kmpc_get_hardware_thread_id_in_block() == 0)
+execution_param = SpmdGuarded;
+
+  // Barrier to ensure all threads are updated to SpmdGuarded.
+  __kmpc_barrier_simple_spmd(ident, 0);
+}
 return;
   }
 
Index: openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
===
--- openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
+++ openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
@@ -82,11 +82,12 @@
   omptarget_nvptx_workFn = 0;
 }
 
-static void __kmpc_spmd_kernel_init(bool RequiresFullRuntime) {
+static void __kmpc_spmd_kernel_init(bool IsSPMDGuarded, bool RequiresFullRuntime) {
   PRINT0(LD_IO, "call to __kmpc_spmd_kernel_init\n");
 
-  setExecutionParameters(Spmd, 

[clang] 05ae303 - [clang][patch] Remove test artifact before running test for consistent results

2021-07-24 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-07-24T07:55:10-04:00
New Revision: 05ae3035554aab083ea1ba721284c950cf25d158

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

LOG: [clang][patch] Remove test artifact before running test for consistent 
results

Fix non-deterministic test behavior by removing previously-created
test directory, see comments in D95159

Added: 


Modified: 
clang/test/Index/preamble-reparse-changed-module.m

Removed: 




diff  --git a/clang/test/Index/preamble-reparse-changed-module.m 
b/clang/test/Index/preamble-reparse-changed-module.m
index 1c63e802ce0c0..349ed0db27d01 100644
--- a/clang/test/Index/preamble-reparse-changed-module.m
+++ b/clang/test/Index/preamble-reparse-changed-module.m
@@ -1,5 +1,6 @@
 // REQUIRES: shell
 
+// RUN: rm -rf %t
 // RUN: mkdir -p %t/mod
 // RUN: touch %t/empty.h
 // RUN: cp %S/Inputs/preamble-reparse-changed-module/module.modulemap %t/mod



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


[PATCH] D106339: Add support to generate Sphinx DOCX documentation

2021-07-24 Thread Tony Tye via Phabricator via cfe-commits
t-tye added a comment.

In D106339#2890258 , @ldionne wrote:

> What's the benefit of having docx documentation? We generate HTML 
> documentation, which ends up in the website, and that seems strictly superior 
> to generating docx. What do you need it for?
>
> The libc++ changes are almost trivial so I would not object to the change on 
> that basis, however in general I think it's better to avoid adding support 
> for things we won't be using on a regular basis.

We do have a project that requires docx documentation that includes parts of 
the LLVM documentation, so being able to generate it from the build is helpful. 
However, if adding docx support is not useful to anyone else then the changes 
can be kept out of tree.

A few observations are that the makefile.bat and Makefile.sphinx files already 
appear to support many of the build targets supported by Sphinx, so adding docx 
did not seem out of place. Building docx as part of the LLVM build is disabled 
by default so has no impact unless explicitly enabled. The changes to support 
it appeared fairly minor.

The changes not directly related to adding docx support have been split out to 
D106338 , D106734 
 and D106736 
 which may be worth considering independent 
of whether this review is useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106339

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


[PATCH] D106339: Add support to generate Sphinx DOCX documentation

2021-07-24 Thread Tony Tye via Phabricator via cfe-commits
t-tye updated this revision to Diff 361407.
t-tye added a comment.

Factor out documentation and CMake file changes unrelated to adding DOCX 
support to D106736 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106339

Files:
  clang-tools-extra/docs/CMakeLists.txt
  clang-tools-extra/docs/conf.py
  clang-tools-extra/docs/make.bat
  clang/docs/CMakeLists.txt
  clang/docs/Makefile.sphinx
  clang/docs/analyzer/conf.py
  clang/docs/analyzer/make.bat
  clang/docs/conf.py
  clang/docs/make.bat
  flang/docs/CMakeLists.txt
  flang/docs/conf.py
  libcxx/docs/CMakeLists.txt
  libcxx/docs/Makefile.sphinx
  libcxx/docs/conf.py
  libunwind/docs/CMakeLists.txt
  libunwind/docs/conf.py
  lld/docs/CMakeLists.txt
  lld/docs/conf.py
  lld/docs/make.bat
  lld/docs/sphinx_intro.rst
  lldb/docs/CMakeLists.txt
  lldb/docs/conf.py
  lldb/docs/resources/build.rst
  llvm/cmake/modules/AddSphinxTarget.cmake
  llvm/cmake/modules/FindSphinx.cmake
  llvm/docs/CMake.rst
  llvm/docs/CMakeLists.txt
  llvm/docs/Makefile.sphinx
  llvm/docs/README.txt
  llvm/docs/conf.py
  llvm/docs/make.bat
  openmp/docs/CMakeLists.txt
  openmp/docs/README.txt
  openmp/docs/conf.py
  polly/docs/CMakeLists.txt
  polly/docs/conf.py

Index: polly/docs/conf.py
===
--- polly/docs/conf.py
+++ polly/docs/conf.py
@@ -28,6 +28,9 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax']
 
+if tags.has('builder-docx'):
+extensions.append('docxbuilder')
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
 
Index: polly/docs/CMakeLists.txt
===
--- polly/docs/CMakeLists.txt
+++ polly/docs/CMakeLists.txt
@@ -98,6 +98,9 @@
 if (${SPHINX_OUTPUT_MAN})
   add_sphinx_target(man polly)
 endif()
+if (${SPHINX_OUTPUT_DOCX})
+  add_sphinx_target(docx polly)
+endif()
   endif()
 endif()
 
Index: openmp/docs/conf.py
===
--- openmp/docs/conf.py
+++ openmp/docs/conf.py
@@ -28,6 +28,9 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax', 'sphinx.ext.intersphinx']
 
+if tags.has('builder-docx'):
+extensions.append('docxbuilder')
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
 
Index: openmp/docs/README.txt
===
--- openmp/docs/README.txt
+++ openmp/docs/README.txt
@@ -58,3 +58,23 @@
 
 Other projects (such as openmp)
 `https://.llvm.org/docs/CommandGuide/Foo.html`
+
+DOCX Output
+===
+
+Building the DOCX files is similar to building the HTML documentation. The
+primary difference is to use the `docx` makefile target, instead of the
+default (which is `html`). Sphinx then produces the DOCX files in the
+directory `/docs/docx/`.
+
+cd 
+cmake -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_DOCX=true 
+make
+
+The correspondence between reStructuredText files and generated DOCX files is:
+
+LLVM project
+`llvm/docs/index.rst` <-> `/docs/docx/LLVM.docx` <-> `/share/doc/llvm/LLVM.docx`
+
+Other projects
+`/docs/index.rst` <-> `/tools//docs/docx/.docx` <-> `/share/doc//.docx`
Index: openmp/docs/CMakeLists.txt
===
--- openmp/docs/CMakeLists.txt
+++ openmp/docs/CMakeLists.txt
@@ -99,5 +99,8 @@
 if (${SPHINX_OUTPUT_MAN})
   add_sphinx_target(man openmp)
 endif()
+if (${SPHINX_OUTPUT_DOCX})
+  add_sphinx_target(docx openmp)
+endif()
   endif()
 endif()
Index: llvm/docs/make.bat
===
--- llvm/docs/make.bat
+++ llvm/docs/make.bat
@@ -31,6 +31,7 @@
 	echo.  text   to make text files
 	echo.  manto make manual pages
 	echo.  texinfoto make Texinfo files
+	echo.  docx   to make DOCX files
 	echo.  gettextto make PO message catalogs
 	echo.  changesto make an overview over all changed/added/deprecated items
 	echo.  linkcheck  to check all external links for integrity
@@ -153,6 +154,14 @@
 	goto end
 )
 
+if "%1" == "docx" (
+	%SPHINXBUILD% -b docx %ALLSPHINXOPTS% %BUILDDIR%/docx
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The DOCX files are in %BUILDDIR%/docx.
+	goto end
+)
+
 if "%1" == "gettext" (
 	%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
 	if errorlevel 1 exit /b 1
Index: llvm/docs/conf.py
===
--- llvm/docs/conf.py
+++ llvm/docs/conf.py
@@ -28,6 +28,9 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = 

[PATCH] D106339: Add support to generate Sphinx DOCX documentation

2021-07-24 Thread Tony Tye via Phabricator via cfe-commits
t-tye updated this revision to Diff 361402.
t-tye added a comment.

Split change for clang makefile to elimnate Sphinx warnings of missing .rst 
fies when building man pages into D106734 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106339

Files:
  clang-tools-extra/docs/CMakeLists.txt
  clang-tools-extra/docs/conf.py
  clang-tools-extra/docs/make.bat
  clang/docs/CMakeLists.txt
  clang/docs/Makefile.sphinx
  clang/docs/analyzer/conf.py
  clang/docs/analyzer/make.bat
  clang/docs/conf.py
  clang/docs/make.bat
  flang/docs/CMakeLists.txt
  flang/docs/conf.py
  libcxx/docs/CMakeLists.txt
  libcxx/docs/Makefile.sphinx
  libcxx/docs/conf.py
  libunwind/docs/CMakeLists.txt
  libunwind/docs/conf.py
  lld/docs/CMakeLists.txt
  lld/docs/conf.py
  lld/docs/make.bat
  lld/docs/sphinx_intro.rst
  lldb/docs/CMakeLists.txt
  lldb/docs/conf.py
  lldb/docs/resources/build.rst
  llvm/cmake/modules/AddSphinxTarget.cmake
  llvm/cmake/modules/FindSphinx.cmake
  llvm/docs/CMake.rst
  llvm/docs/CMakeLists.txt
  llvm/docs/Makefile.sphinx
  llvm/docs/README.txt
  llvm/docs/conf.py
  llvm/docs/make.bat
  openmp/docs/CMakeLists.txt
  openmp/docs/README.txt
  openmp/docs/conf.py
  polly/docs/CMakeLists.txt
  polly/docs/conf.py

Index: polly/docs/conf.py
===
--- polly/docs/conf.py
+++ polly/docs/conf.py
@@ -28,6 +28,9 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax']
 
+if tags.has('builder-docx'):
+extensions.append('docxbuilder')
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
 
Index: polly/docs/CMakeLists.txt
===
--- polly/docs/CMakeLists.txt
+++ polly/docs/CMakeLists.txt
@@ -98,6 +98,9 @@
 if (${SPHINX_OUTPUT_MAN})
   add_sphinx_target(man polly)
 endif()
+if (${SPHINX_OUTPUT_DOCX})
+  add_sphinx_target(docx polly)
+endif()
   endif()
 endif()
 
Index: openmp/docs/conf.py
===
--- openmp/docs/conf.py
+++ openmp/docs/conf.py
@@ -28,6 +28,9 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax', 'sphinx.ext.intersphinx']
 
+if tags.has('builder-docx'):
+extensions.append('docxbuilder')
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
 
Index: openmp/docs/README.txt
===
--- openmp/docs/README.txt
+++ openmp/docs/README.txt
@@ -1,5 +1,5 @@
 OpenMP LLVM Documentation
-==
+=
 
 OpenMP LLVM's documentation is written in reStructuredText, a lightweight
 plaintext markup language (file extension `.rst`). While the
@@ -14,11 +14,15 @@
 cd 
 cmake -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_HTML=true 
 make
-$BROWSER /projects/openmp/docs//html/index.html
+$BROWSER /projects/openmp/docs/html/index.html
 
-The mapping between reStructuredText files and generated documentation is
-`docs/Foo.rst` <-> `/projects/openmp/docs//html/Foo.html` <->
-`https://openmp.llvm.org/docs/Foo.html`.
+The correspondence between reStructuredText files and generated HTML pages is:
+
+LLVM project
+`llvm/docs/Foo.rst` <-> `/docs/html/Foo.html` <-> `/share/doc/llvm/html/Foo.html` <-> `https://llvm.org/docs/Foo.html`
+
+Other projects
+`/docs/Foo.rst` <-> `/tools//docs/html/Foo.html` <-> `/share/doc//html/Foo.html`<-> `https://.llvm.org/docs/Foo.html`
 
 If you are interested in writing new documentation, you will want to read
 `llvm/docs/SphinxQuickstartTemplate.rst` which will get you writing
@@ -26,7 +30,7 @@
 reStructuredText markup syntax.
 
 Manpage Output
-===
+==
 
 Building the manpages is similar to building the HTML documentation. The
 primary difference is to use the `man` makefile target, instead of the
@@ -36,10 +40,41 @@
 cd 
 cmake -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_MAN=true 
 make
-man -l >build-dir>/docs/man/FileCheck.1
+man -l /docs/man/FileCheck.1
+
+The correspondence between reStructuredText files and generated man pages is:
+
+LLVM project
+`llvm/docs/CommandGuide/Foo.rst` <-> `/docs/man/Foo.1` <-> `/share/man/man1/Foo.1`
+
+Other projects
+`/docs/CommandGuide/Foo.rst` <-> `/tools//docs/man/Foo.1` <-> `/share/man/man1/Foo.1`
 
-The correspondence between .rst files and man pages is
-`docs/CommandGuide/Foo.rst` <-> `/projects/openmp/docs//man/Foo.1`.
 These .rst files are also included during HTML generation so they are also
-viewable online (as noted above) at e.g.
-`https://openmp.llvm.org/docs/CommandGuide/Foo.html`.
+viewable online:
+
+LLVM project

[PATCH] D106252: Make simple requirements starting with requires ill-formed in in requirement body

2021-07-24 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/test/Parser/cxx2a-concepts-requires-expr.cpp:152-153
+};
+bool r42 = requires(typename S::type i) {
+  requires requires(typename S::type i) { requires true; };
+};

Quuxplusone wrote:
> `s/int/T/` otherwise you miss the point of p2092's "Down with `typename`!" 
> changes.
Haha, you are right, thanks.
No wonder it passed...
I've elected to remove these tests for now, until P2092 is implemented 
(https://reviews.llvm.org/D53847)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106252

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


[PATCH] D106252: Make simple requirements starting with requires ill-formed in in requirement body

2021-07-24 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 361416.
cor3ntin added a comment.

- Fix typos
- remove the tests about typenames (don't pass yet)
- Mark as partial until P2092  is implemented


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106252

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/Parser/cxx2a-concepts-requires-expr.cpp
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -934,7 +934,7 @@
   

 https://wg21.link/p1972r0;>P1972R0
-No
+No
   
   
 https://wg21.link/p1980r0;>P1980R0
@@ -944,9 +944,11 @@
   
   
 https://wg21.link/p2092r0;>P2092R0
+Clang 13
   
   
 https://wg21.link/p2113r0;>P2113R0
+No
   
 
 
Index: clang/test/Parser/cxx2a-concepts-requires-expr.cpp
===
--- clang/test/Parser/cxx2a-concepts-requires-expr.cpp
+++ clang/test/Parser/cxx2a-concepts-requires-expr.cpp
@@ -134,13 +134,13 @@
 // expected-error@-1 {{expected ';' at end of requirement}}
 
 bool r38 = requires { requires { 1; }; };
-// expected-warning@-1 {{this requires expression will only be checked for 
syntactic validity; did you intend to place it in a nested requirement? (add 
another 'requires' before the expression)}}
+// expected-error@-1 {{requires expression in requirement body; did you intend 
to place it in a nested requirement? (add another 'requires' before the 
expression)}}
 
 bool r39 = requires { requires () { 1; }; };
-// expected-warning@-1 {{this requires expression will only be checked for 
syntactic validity; did you intend to place it in a nested requirement? (add 
another 'requires' before the expression)}}
+// expected-error@-1 {{requires expression in requirement body; did you intend 
to place it in a nested requirement? (add another 'requires' before the 
expression)}}
 
 bool r40 = requires { requires (int i) { i; }; };
-// expected-warning@-1 {{this requires expression will only be checked for 
syntactic validity; did you intend to place it in a nested requirement? (add 
another 'requires' before the expression)}}
+// expected-error@-1 {{requires expression in requirement body; did you intend 
to place it in a nested requirement? (add another 'requires' before the 
expression)}}
 
 bool r41 = requires { requires (); };
 // expected-error@-1 {{expected expression}}
Index: clang/lib/Parse/ParseExprCXX.cpp
===
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -3602,7 +3602,7 @@
   break;
 }
 if (!Expression.isInvalid() && PossibleRequiresExprInSimpleRequirement)
-  Diag(StartLoc, diag::warn_requires_expr_in_simple_requirement)
+  Diag(StartLoc, diag::err_requires_expr_in_simple_requirement)
   << FixItHint::CreateInsertion(StartLoc, "requires");
 if (auto *Req = Actions.ActOnSimpleRequirement(Expression.get()))
   Requirements.push_back(Req);
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -806,10 +806,10 @@
 def err_requires_expr_simple_requirement_noexcept : Error<
   "'noexcept' can only be used in a compound requirement (with '{' '}' around "
   "the expression)">;
-def warn_requires_expr_in_simple_requirement : Warning<
-  "this requires expression will only be checked for syntactic validity; did "
+def err_requires_expr_in_simple_requirement : Error<
+  "requires expression in requirement body; did "
   "you intend to place it in a nested requirement? (add another 'requires' "
-  "before the expression)">, InGroup>;
+  "before the expression)">;
 
 def err_missing_dependent_template_keyword : Error<
   "use 'template' keyword to treat '%0' as a dependent template name">;


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -934,7 +934,7 @@
   

 https://wg21.link/p1972r0;>P1972R0
-No
+No
   
   
 https://wg21.link/p1980r0;>P1980R0
@@ -944,9 +944,11 @@
   
   
 https://wg21.link/p2092r0;>P2092R0
+Clang 13
   
   
 https://wg21.link/p2113r0;>P2113R0
+No
   
 
 
Index: clang/test/Parser/cxx2a-concepts-requires-expr.cpp
===
--- clang/test/Parser/cxx2a-concepts-requires-expr.cpp
+++ 

[PATCH] D98214: [clang-format] Fix aligning with linebreaks

2021-07-24 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D98214#2901304 , @baramin wrote:

> This is true.
>  .clang-format:
>
>   Language:Cpp
>   AlignConsecutiveAssignments: Consecutive
>   BinPackArguments: false
>   BinPackParameters: false
>   ColumnLimit: 120
>   ConstructorInitializerIndentWidth: 4
>   ContinuationIndentWidth: 4
>   IndentWidth: 4
>   TabWidth:4
>   UseCRLF: false
>   UseTab:  Never
>
> Format, that looks like a regression for me:
> Now:
>
>   void SomeFunc() {
>   newWatcher.maxAgeUsec = ToLegacyTimestamp(GetMaxAge(
>   FromLegacyTimestamp(monitorFrequencyUsec), 
> seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));
>   newWatcher.maxAge = ToLegacyTimestamp(GetMaxAge(
>   FromLegacyTimestamp(monitorFrequencyUsec), 
> seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));
>   newWatcher.max= ToLegacyTimestamp(GetMaxAge(
>  FromLegacyTimestamp(monitorFrequencyUsec), 
> seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));
>   }
>
> Before:
>
>   void SomeFunc() {
>   newWatcher.maxAgeUsec = ToLegacyTimestamp(GetMaxAge(
>   FromLegacyTimestamp(monitorFrequencyUsec), 
> seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));
>   newWatcher.maxAge = ToLegacyTimestamp(GetMaxAge(
>   FromLegacyTimestamp(monitorFrequencyUsec), 
> seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));
>   newWatcher.max= ToLegacyTimestamp(GetMaxAge(
>   FromLegacyTimestamp(monitorFrequencyUsec), 
> seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));
>   }

Yeah okay, that looks wrong. I will take a look at it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98214

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