[PATCH] D143522: [AMDGPU] Set a data layout entry for buffer descriptors (addrspace 7)

2023-02-16 Thread Nicolai Hähnle via Phabricator via cfe-commits
nhaehnle added a comment.

This really needs to be a 160-bit type, not a 128-bit type.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143522

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


[PATCH] D144100: [clang] Fix a bug that allowed some overflowing octal escape sequences

2023-02-16 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 497915.
barannikov88 added a comment.

Update the comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144100

Files:
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/Lexer/char-escapes-delimited.c


Index: clang/test/Lexer/char-escapes-delimited.c
===
--- clang/test/Lexer/char-escapes-delimited.c
+++ clang/test/Lexer/char-escapes-delimited.c
@@ -58,6 +58,8 @@
 #if __WCHAR_MAX__ > 0x
   unsigned d = L'\o{377}'; // ext-warning {{extension}} cxx2b-warning 
{{C++2b}}
   unsigned e = L'\o{400}'; // expected-error {{octal escape sequence 
out of range}}
+  unsigned f = L'\o{1000}'; // expected-error {{octal escape sequence 
out of range}}
+  unsigned g = L'\o{2000}'; // expected-error {{octal escape sequence 
out of range}}
 #else
   unsigned d = L'\o{17}'; // ext-warning {{extension}} cxx2b-warning 
{{C++2b}}
   unsigned e = L'\o{20}'; // expected-error {{octal escape sequence out of 
range}}
Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -263,7 +263,8 @@
 ThisTokBuf++;
 continue;
   }
-  if (ResultChar & 0x02000)
+  // Check if one of the top three bits is set before shifting them out.
+  if (ResultChar & 0xE000)
 Overflow = true;
 
   ResultChar <<= 3;


Index: clang/test/Lexer/char-escapes-delimited.c
===
--- clang/test/Lexer/char-escapes-delimited.c
+++ clang/test/Lexer/char-escapes-delimited.c
@@ -58,6 +58,8 @@
 #if __WCHAR_MAX__ > 0x
   unsigned d = L'\o{377}'; // ext-warning {{extension}} cxx2b-warning {{C++2b}}
   unsigned e = L'\o{400}'; // expected-error {{octal escape sequence out of range}}
+  unsigned f = L'\o{1000}'; // expected-error {{octal escape sequence out of range}}
+  unsigned g = L'\o{2000}'; // expected-error {{octal escape sequence out of range}}
 #else
   unsigned d = L'\o{17}'; // ext-warning {{extension}} cxx2b-warning {{C++2b}}
   unsigned e = L'\o{20}'; // expected-error {{octal escape sequence out of range}}
Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -263,7 +263,8 @@
 ThisTokBuf++;
 continue;
   }
-  if (ResultChar & 0x02000)
+  // Check if one of the top three bits is set before shifting them out.
+  if (ResultChar & 0xE000)
 Overflow = true;
 
   ResultChar <<= 3;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f8d5f0e - [NFC] Add two tests for C++ modules

2023-02-16 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-02-16T17:02:04+08:00
New Revision: f8d5f0e53b04040cebbba639530133b261a4432f

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

LOG: [NFC] Add two tests for C++ modules

One test for checking the decls in language linkage shouldn't be
discarded and can be mangled correctly.

Another one for checking we can't export again in an export decl.

Added: 
clang/test/Modules/export-in-another-export.cppm
clang/test/Modules/language-linkage.cppm

Modified: 


Removed: 




diff  --git a/clang/test/Modules/export-in-another-export.cppm 
b/clang/test/Modules/export-in-another-export.cppm
new file mode 100644
index ..38cb4d6c4a8c
--- /dev/null
+++ b/clang/test/Modules/export-in-another-export.cppm
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -std=c++20 %s -fsyntax-only -verify
+export module M;
+export { // expected-note {{export block begins here}}
+export int foo() { return 43; } // expected-error {{export declaration 
appears within another export declaration}}
+}

diff  --git a/clang/test/Modules/language-linkage.cppm 
b/clang/test/Modules/language-linkage.cppm
new file mode 100644
index ..bf7982cd9207
--- /dev/null
+++ b/clang/test/Modules/language-linkage.cppm
@@ -0,0 +1,18 @@
+// Make sure that the declarations inside the language linkage can
+// be generated correctly.
+//
+// RUN: rm -fr %t
+// RUN: mkdir %t
+//
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %s 
-emit-module-interface -o %t/M.pcm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/M.pcm -S 
-emit-llvm -disable-llvm-passes -o - | FileCheck %s
+export module M;
+
+extern "C++" {
+void foo() {} 
+}
+
+extern "C" void bar() {}
+
+// CHECK: define {{.*}}@bar(
+// CHECK: define {{.*}}@_Z3foov(



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


[clang] 37b7a60 - [NFC] Add a test for C++20 Modules

2023-02-16 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-02-16T17:14:16+08:00
New Revision: 37b7a60cd74b7a1754583b7eb63a6339158fd398

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

LOG: [NFC] Add a test for C++20 Modules

Add a test to check that the template instantiation during the template
specialization wouldn't be emitted again in the importer.

Added: 


Modified: 
clang/test/Modules/pr60693.cppm

Removed: 




diff  --git a/clang/test/Modules/pr60693.cppm b/clang/test/Modules/pr60693.cppm
index 117a0f2753d0..c50791083a5b 100644
--- a/clang/test/Modules/pr60693.cppm
+++ b/clang/test/Modules/pr60693.cppm
@@ -16,7 +16,14 @@ constexpr bool f() {
return true;
 }
 
-export template
+template 
+struct u {
+T unit() {
+return T();
+}
+};
+
+export template
 struct s {
static constexpr auto a = f();
static constexpr auto b = f();
@@ -28,6 +35,9 @@ struct s {
 int bar() {
 return 44;
 }
+T zoo() {
+return u().unit();
+}
 };
 
 template struct s;
@@ -46,9 +56,15 @@ extern "C" long use2() {
 return _.foo();
 }
 
+extern "C" long use3() {
+s _;
+return _.zoo();
+}
+
 // CHECK: define{{.*}}@use(
 // CHECK-NOT: }
 // CHECK: ret{{.*}} 4
 
 // CHECK: declare{{.*}}@_ZNW1a1sIlE3fooEv
 // CHECK-NOT: _ZNW1a1sIlE3barEv
+// CHECK: declare{{.*}}_ZNW1a1sIlE3zooEv



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


[PATCH] D144169: [WebAssembly] Fix simd bit shift intrinsics codegen

2023-02-16 Thread JunMa via Phabricator via cfe-commits
junparser created this revision.
Herald added subscribers: pmatos, asb, ecnelises, sunfish, jgravelle-google, 
sbc100, dschuff.
Herald added a project: All.
junparser requested review of this revision.
Herald added subscribers: cfe-commits, aheejin.
Herald added a project: clang.

According to github.com/WebAssembly/simd/blob/main/proposals/simd/SIMD.md,
the shift count of bit shift instructions is taken modulo lane width.
This patch adds such operation.

Fixes PR#60655


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144169

Files:
  clang/lib/Headers/wasm_simd128.h
  clang/test/Headers/wasm.c

Index: clang/test/Headers/wasm.c
===
--- clang/test/Headers/wasm.c
+++ clang/test/Headers/wasm.c
@@ -1584,11 +1584,12 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
 // CHECK-NEXT:[[TMP1:%.*]] = trunc i32 [[B:%.*]] to i8
-// CHECK-NEXT:[[TMP2:%.*]] = insertelement <16 x i8> undef, i8 [[TMP1]], i64 0
-// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <16 x i8> [[TMP2]], <16 x i8> poison, <16 x i32> zeroinitializer
+// CHECK-NEXT:[[TMP2:%.*]] = and i8 [[TMP1]], 7
+// CHECK-NEXT:[[TMP3:%.*]] = insertelement <16 x i8> undef, i8 [[TMP2]], i64 0
+// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <16 x i8> [[TMP3]], <16 x i8> poison, <16 x i32> zeroinitializer
 // CHECK-NEXT:[[SHL_I:%.*]] = shl <16 x i8> [[TMP0]], [[SH_PROM_I]]
-// CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[SHL_I]] to <4 x i32>
-// CHECK-NEXT:ret <4 x i32> [[TMP3]]
+// CHECK-NEXT:[[TMP4:%.*]] = bitcast <16 x i8> [[SHL_I]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP4]]
 //
 v128_t test_i8x16_shl(v128_t a, uint32_t b) {
   return wasm_i8x16_shl(a, b);
@@ -1598,11 +1599,12 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
 // CHECK-NEXT:[[TMP1:%.*]] = trunc i32 [[B:%.*]] to i8
-// CHECK-NEXT:[[TMP2:%.*]] = insertelement <16 x i8> undef, i8 [[TMP1]], i64 0
-// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <16 x i8> [[TMP2]], <16 x i8> poison, <16 x i32> zeroinitializer
+// CHECK-NEXT:[[TMP2:%.*]] = and i8 [[TMP1]], 7
+// CHECK-NEXT:[[TMP3:%.*]] = insertelement <16 x i8> undef, i8 [[TMP2]], i64 0
+// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <16 x i8> [[TMP3]], <16 x i8> poison, <16 x i32> zeroinitializer
 // CHECK-NEXT:[[SHR_I:%.*]] = ashr <16 x i8> [[TMP0]], [[SH_PROM_I]]
-// CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[SHR_I]] to <4 x i32>
-// CHECK-NEXT:ret <4 x i32> [[TMP3]]
+// CHECK-NEXT:[[TMP4:%.*]] = bitcast <16 x i8> [[SHR_I]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP4]]
 //
 v128_t test_i8x16_shr(v128_t a, uint32_t b) {
   return wasm_i8x16_shr(a, b);
@@ -1612,11 +1614,12 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
 // CHECK-NEXT:[[TMP1:%.*]] = trunc i32 [[B:%.*]] to i8
-// CHECK-NEXT:[[TMP2:%.*]] = insertelement <16 x i8> undef, i8 [[TMP1]], i64 0
-// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <16 x i8> [[TMP2]], <16 x i8> poison, <16 x i32> zeroinitializer
+// CHECK-NEXT:[[TMP2:%.*]] = and i8 [[TMP1]], 7
+// CHECK-NEXT:[[TMP3:%.*]] = insertelement <16 x i8> undef, i8 [[TMP2]], i64 0
+// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <16 x i8> [[TMP3]], <16 x i8> poison, <16 x i32> zeroinitializer
 // CHECK-NEXT:[[SHR_I:%.*]] = lshr <16 x i8> [[TMP0]], [[SH_PROM_I]]
-// CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[SHR_I]] to <4 x i32>
-// CHECK-NEXT:ret <4 x i32> [[TMP3]]
+// CHECK-NEXT:[[TMP4:%.*]] = bitcast <16 x i8> [[SHR_I]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP4]]
 //
 v128_t test_u8x16_shr(v128_t a, uint32_t b) {
   return wasm_u8x16_shr(a, b);
@@ -1801,11 +1804,12 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <8 x i16>
 // CHECK-NEXT:[[TMP1:%.*]] = trunc i32 [[B:%.*]] to i16
-// CHECK-NEXT:[[TMP2:%.*]] = insertelement <8 x i16> undef, i16 [[TMP1]], i64 0
-// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <8 x i16> [[TMP2]], <8 x i16> poison, <8 x i32> zeroinitializer
+// CHECK-NEXT:[[TMP2:%.*]] = and i16 [[TMP1]], 15
+// CHECK-NEXT:[[TMP3:%.*]] = insertelement <8 x i16> undef, i16 [[TMP2]], i64 0
+// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <8 x i16> [[TMP3]], <8 x i16> poison, <8 x i32> zeroinitializer
 // CHECK-NEXT:[[SHL_I:%.*]] = shl <8 x i16> [[TMP0]], [[SH_PROM_I]]
-// CHECK-NEXT:[[TMP3:%.*]] = bitcast <8 x i16> [[SHL_I]] to <4 x i32>
-// CHECK-NEXT:ret <4 x i32> [[TMP3]]
+// CHECK-NEXT:[[TMP4:%.*]] = bitcast <8 x i16> [[SHL_I]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP4]]
 //
 v128_t test_i16x8_shl(v128_t a, uint32_t b) {
   return wasm_i16x8_shl(a, b);
@@ -1815,11 +1819,12 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4

[PATCH] D144170: [clang-format] Add simple macro replacements in formatting.

2023-02-16 Thread Manuel Klimek via Phabricator via cfe-commits
klimek created this revision.
klimek added a reviewer: sammccall.
Herald added a project: All.
klimek requested review of this revision.
Herald added a project: clang.

Add configuration to specify macros.
Macros will be expanded, and the code will be parsed and annotated
in the expanded state. In a second step, the formatting decisions
in the annotated expanded code will be reconstructed onto the
original unexpanded macro call.

Eventually, this will allow to remove special-case code for
various macro options we accumulated over the years in favor of
one principled mechanism.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144170

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/Macros.h
  clang/lib/Format/TokenAnalyzer.cpp
  clang/lib/Format/TokenAnalyzer.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/TokenAnnotator.h
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TestLexer.h

Index: clang/unittests/Format/TestLexer.h
===
--- clang/unittests/Format/TestLexer.h
+++ clang/unittests/Format/TestLexer.h
@@ -72,7 +72,8 @@
   TokenList annotate(llvm::StringRef Code) {
 FormatTokenLexer Lex = getNewLexer(Code);
 auto Tokens = Lex.lex();
-UnwrappedLineParser Parser(Style, Lex.getKeywords(), 0, Tokens, *this);
+UnwrappedLineParser Parser(SourceMgr.get(), Style, Lex.getKeywords(), 0,
+   Tokens, *this, Allocator, IdentTable);
 Parser.parse();
 TokenAnnotator Annotator(Style, Lex.getKeywords());
 for (auto &Line : UnwrappedLines) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -66,7 +66,8 @@
 
   void _verifyFormat(const char *File, int Line, llvm::StringRef Expected,
  llvm::StringRef Code,
- const FormatStyle &Style = getLLVMStyle()) {
+ const FormatStyle &Style = getLLVMStyle(),
+ bool MessUp = true) {
 ScopedTrace t(File, Line, ::testing::Message() << Code.str());
 EXPECT_EQ(Expected.str(), format(Expected, Style))
 << "Expected code is not stable";
@@ -76,20 +77,24 @@
   // needs to be checked for Objective-C++ as well.
   FormatStyle ObjCStyle = Style;
   ObjCStyle.Language = FormatStyle::LK_ObjC;
-  EXPECT_EQ(Expected.str(), format(test::messUp(Code), ObjCStyle));
+  EXPECT_EQ(Expected.str(),
+format(MessUp ? test::messUp(Code) : Code, ObjCStyle));
 }
   }
 
   void _verifyFormat(const char *File, int Line, llvm::StringRef Code,
- const FormatStyle &Style = getLLVMStyle()) {
-_verifyFormat(File, Line, Code, test::messUp(Code), Style);
+ const FormatStyle &Style = getLLVMStyle(),
+ bool MessUp = true) {
+_verifyFormat(File, Line, Code, MessUp ? test::messUp(Code) : Code, Style,
+  MessUp);
   }
 
   void _verifyIncompleteFormat(const char *File, int Line, llvm::StringRef Code,
-   const FormatStyle &Style = getLLVMStyle()) {
+   const FormatStyle &Style = getLLVMStyle(),
+   bool MessUp = true) {
 ScopedTrace t(File, Line, ::testing::Message() << Code.str());
-EXPECT_EQ(Code.str(),
-  format(test::messUp(Code), Style, SC_ExpectIncomplete));
+EXPECT_EQ(Code.str(), format(MessUp ? test::messUp(Code) : Code, Style,
+ SC_ExpectIncomplete));
   }
 
   void _verifyIndependentOfContext(const char *File, int Line,
@@ -22568,6 +22573,189 @@
"llvm::outs()\n<<");
 }
 
+TEST_F(FormatTest, UnexpandConfiguredMacros) {
+  FormatStyle Style = getLLVMStyle();
+  Style.Macros.push_back("CLASS=class C {");
+  Style.Macros.push_back("SEMI=;");
+  Style.Macros.push_back("STMT=f();");
+  Style.Macros.push_back("ID(x)=x");
+  Style.Macros.push_back("ID3(x, y, z)=x y z");
+  Style.Macros.push_back("CALL(x)=f([] { x })");
+  Style.Macros.push_back("ASSIGN_OR_RETURN(a, b, c)=a = (b) || (c)");
+
+  verifyFormat("ID(nested(a(b, c), d))", Style);
+  verifyFormat("CLASS\n"
+   "  a *b;\n"
+   "};",
+   Style);
+  verifyFormat("SEMI\n"
+   "SEMI\n"
+   "SEMI",
+   Style);
+  verifyFormat("STMT\n"
+   "STMT\n"
+   "STMT",
+   Style);
+  verifyFormat("void f() { ID(a *b); }", Style);
+  verifyFormat(R"(ID(
+{ ID(a *b); });
+)",
+   Style);

[PATCH] D140795: [Flang] Add user option -funderscoring/-fnounderscoring to control trailing underscore added to external names

2023-02-16 Thread Mark Danial via Phabricator via cfe-commits
madanial updated this revision to Diff 497928.
madanial added a comment.

Bug Fix for failing test cases


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

https://reviews.llvm.org/D140795

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/include/flang/Optimizer/Transforms/Passes.h
  flang/include/flang/Optimizer/Transforms/Passes.td
  flang/include/flang/Tools/CLOptions.inc
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/underscoring.f90
  flang/test/Fir/external-mangling.fir

Index: flang/test/Fir/external-mangling.fir
===
--- flang/test/Fir/external-mangling.fir
+++ flang/test/Fir/external-mangling.fir
@@ -1,6 +1,9 @@
-// RUN: fir-opt --external-name-interop %s | FileCheck %s
-// RUN: tco --external-name-interop %s | FileCheck %s
-// RUN: tco --external-name-interop %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR
+// RUN: fir-opt --external-name-interop="append-underscore=true" %s | FileCheck %s --check-prefix=CHECK-UNDER
+// RUN: fir-opt --external-name-interop="append-underscore=false" %s | FileCheck %s --check-prefix=CHECK-NOUNDER
+// RUN: tco --external-name-interop="append-underscore=true" %s | FileCheck %s --check-prefix=CHECK-UNDER
+// RUN: tco --external-name-interop="append-underscore=false" %s | FileCheck %s --check-prefix=CHECK-NOUNDER
+// RUN: tco --external-name-interop="append-underscore=true" %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR-UNDER
+// RUN: tco --external-name-interop="append-underscore=false" %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR-NOUNDER
 
 func.func @_QPfoo() {
   %c0 = arith.constant 0 : index
@@ -21,24 +24,43 @@
 func.func private @_QPbar(!fir.ref)
 func.func private @_QPbar2(!fir.ref)
 
-// CHECK: func @foo_
-// CHECK: %{{.*}} = fir.address_of(@a_) : !fir.ref>
-// CHECK: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
-// CHECK: fir.call @bar_
-// CHECK: fir.call @bar2_
-// CHECK: fir.global common @a_(dense<0> : vector<4xi8>) : !fir.array<4xi8>
-// CHECK: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
-// CHECK: func private @bar_(!fir.ref)
-
-// LLVMIR: %{{.*}} = llvm.mlir.addressof @a_ : !llvm.ptr>
-// LLVMIR: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
-// LLVMIR: llvm.call @bar_(%{{.*}}) : (!llvm.ptr) -> ()
-// LLVMIR: llvm.call @bar2_(%{{.*}}) : (!llvm.ptr) -> ()
-
-// LLVMIR: llvm.mlir.global common @a_(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
-// LLVMIR: llvm.mlir.global common @__BLNK__(dense<0> : vector<4xi8>) {{.*}}  : !llvm.array<4 x i8>
-// LLVMIR: llvm.func @bar_(!llvm.ptr) attributes {sym_visibility = "private"}
-// LLVMIR: llvm.func @bar2_(!llvm.ptr) attributes {sym_visibility = "private"}
+// CHECK-UNDER: func @foo_
+// CHECK-UNDER: %{{.*}} = fir.address_of(@a_) : !fir.ref>
+// CHECK-UNDER: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
+// CHECK-UNDER: fir.call @bar_
+// CHECK-UNDER: fir.call @bar2_
+// CHECK-UNDER: fir.global common @a_(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-UNDER: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-UNDER: func private @bar_(!fir.ref)
+
+// CHECK-NOUNDER: func @foo(
+// CHECK-NOUNDER: %{{.*}} = fir.address_of(@a) : !fir.ref>
+// CHECK-NOUNDER: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
+// CHECK-NOUNDER: fir.call @bar(
+// CHECK-NOUNDER: fir.call @bar2(
+// CHECK-NOUNDER: fir.global common @a(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-NOUNDER: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-NOUNDER: func private @bar(!fir.ref)
+
+// LLVMIR-UNDER: %{{.*}} = llvm.mlir.addressof @a_ : !llvm.ptr>
+// LLVMIR-UNDER: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
+// LLVMIR-UNDER: llvm.call @bar_(%{{.*}}) : (!llvm.ptr) -> ()
+// LLVMIR-UNDER: llvm.call @bar2_(%{{.*}}) : (!llvm.ptr) -> ()
+
+// LLVMIR-UNDER: llvm.mlir.global common @a_(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
+// LLVMIR-UNDER: llvm.mlir.global common @__BLNK__(dense<0> : vector<4xi8>) {{.*}}  : !llvm.array<4 x i8>
+// LLVMIR-UNDER: llvm.func @bar_(!llvm.ptr) attributes {sym_visibility = "private"}
+// LLVMIR-UNDER: llvm.func @bar2_(!llvm.ptr) attributes {sym_visibility = "private"}
+
+// LLVMIR-NOUNDER: %{{.*}} = llvm.mlir.addressof @a : !llvm.ptr>
+// LLVMIR-NOUNDER: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
+// LLVMIR-NOUNDER: llvm.call @bar(%{{.*}}) : (!llvm.ptr) -> ()
+// LLVMIR-NOUNDER: llvm.call @bar2(%{{.*}}) : (!llvm.ptr) -> ()
+
+// LLVMIR-NOUNDER: llvm.mlir.global common @a(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
+// LLVMIR-NOUNDER: llvm.mlir.gl

[PATCH] D140795: [Flang] Add user option -funderscoring/-fnounderscoring to control trailing underscore added to external names

2023-02-16 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

You still have style mismatch in `flang/include/flang/Tools/CLOptions.inc`. 
This file is likely not run through clang-format so that's why.




Comment at: flang/include/flang/Tools/CLOptions.inc:214
+llvm::OptimizationLevel optLevel = defaultOptLevel,
+bool Underscoring = true) {
   fir::addBoxedProcedurePass(pm);





Comment at: flang/include/flang/Tools/CLOptions.inc:233
 llvm::OptimizationLevel optLevel = defaultOptLevel,
-bool stackArrays = false) {
+bool stackArrays = false, bool Underscoring = true) {
   // Add default optimizer pass pipeline.





Comment at: flang/include/flang/Tools/CLOptions.inc:238
   // Add codegen pass pipeline.
-  fir::createDefaultFIRCodeGenPassPipeline(pm, optLevel);
+  fir::createDefaultFIRCodeGenPassPipeline(pm, optLevel, Underscoring);
 }




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

https://reviews.llvm.org/D140795

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


[PATCH] D140795: [Flang] Add user option -funderscoring/-fnounderscoring to control trailing underscore added to external names

2023-02-16 Thread Mark Danial via Phabricator via cfe-commits
madanial updated this revision to Diff 497931.
madanial added a comment.

addressing style mismatch in > flang/include/flang/Tools/CLOptions.inc


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

https://reviews.llvm.org/D140795

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/include/flang/Optimizer/Transforms/Passes.h
  flang/include/flang/Optimizer/Transforms/Passes.td
  flang/include/flang/Tools/CLOptions.inc
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/underscoring.f90
  flang/test/Fir/external-mangling.fir

Index: flang/test/Fir/external-mangling.fir
===
--- flang/test/Fir/external-mangling.fir
+++ flang/test/Fir/external-mangling.fir
@@ -1,6 +1,9 @@
-// RUN: fir-opt --external-name-interop %s | FileCheck %s
-// RUN: tco --external-name-interop %s | FileCheck %s
-// RUN: tco --external-name-interop %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR
+// RUN: fir-opt --external-name-interop="append-underscore=true" %s | FileCheck %s --check-prefix=CHECK-UNDER
+// RUN: fir-opt --external-name-interop="append-underscore=false" %s | FileCheck %s --check-prefix=CHECK-NOUNDER
+// RUN: tco --external-name-interop="append-underscore=true" %s | FileCheck %s --check-prefix=CHECK-UNDER
+// RUN: tco --external-name-interop="append-underscore=false" %s | FileCheck %s --check-prefix=CHECK-NOUNDER
+// RUN: tco --external-name-interop="append-underscore=true" %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR-UNDER
+// RUN: tco --external-name-interop="append-underscore=false" %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR-NOUNDER
 
 func.func @_QPfoo() {
   %c0 = arith.constant 0 : index
@@ -21,24 +24,43 @@
 func.func private @_QPbar(!fir.ref)
 func.func private @_QPbar2(!fir.ref)
 
-// CHECK: func @foo_
-// CHECK: %{{.*}} = fir.address_of(@a_) : !fir.ref>
-// CHECK: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
-// CHECK: fir.call @bar_
-// CHECK: fir.call @bar2_
-// CHECK: fir.global common @a_(dense<0> : vector<4xi8>) : !fir.array<4xi8>
-// CHECK: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
-// CHECK: func private @bar_(!fir.ref)
-
-// LLVMIR: %{{.*}} = llvm.mlir.addressof @a_ : !llvm.ptr>
-// LLVMIR: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
-// LLVMIR: llvm.call @bar_(%{{.*}}) : (!llvm.ptr) -> ()
-// LLVMIR: llvm.call @bar2_(%{{.*}}) : (!llvm.ptr) -> ()
-
-// LLVMIR: llvm.mlir.global common @a_(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
-// LLVMIR: llvm.mlir.global common @__BLNK__(dense<0> : vector<4xi8>) {{.*}}  : !llvm.array<4 x i8>
-// LLVMIR: llvm.func @bar_(!llvm.ptr) attributes {sym_visibility = "private"}
-// LLVMIR: llvm.func @bar2_(!llvm.ptr) attributes {sym_visibility = "private"}
+// CHECK-UNDER: func @foo_
+// CHECK-UNDER: %{{.*}} = fir.address_of(@a_) : !fir.ref>
+// CHECK-UNDER: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
+// CHECK-UNDER: fir.call @bar_
+// CHECK-UNDER: fir.call @bar2_
+// CHECK-UNDER: fir.global common @a_(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-UNDER: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-UNDER: func private @bar_(!fir.ref)
+
+// CHECK-NOUNDER: func @foo(
+// CHECK-NOUNDER: %{{.*}} = fir.address_of(@a) : !fir.ref>
+// CHECK-NOUNDER: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref>
+// CHECK-NOUNDER: fir.call @bar(
+// CHECK-NOUNDER: fir.call @bar2(
+// CHECK-NOUNDER: fir.global common @a(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-NOUNDER: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+// CHECK-NOUNDER: func private @bar(!fir.ref)
+
+// LLVMIR-UNDER: %{{.*}} = llvm.mlir.addressof @a_ : !llvm.ptr>
+// LLVMIR-UNDER: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
+// LLVMIR-UNDER: llvm.call @bar_(%{{.*}}) : (!llvm.ptr) -> ()
+// LLVMIR-UNDER: llvm.call @bar2_(%{{.*}}) : (!llvm.ptr) -> ()
+
+// LLVMIR-UNDER: llvm.mlir.global common @a_(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
+// LLVMIR-UNDER: llvm.mlir.global common @__BLNK__(dense<0> : vector<4xi8>) {{.*}}  : !llvm.array<4 x i8>
+// LLVMIR-UNDER: llvm.func @bar_(!llvm.ptr) attributes {sym_visibility = "private"}
+// LLVMIR-UNDER: llvm.func @bar2_(!llvm.ptr) attributes {sym_visibility = "private"}
+
+// LLVMIR-NOUNDER: %{{.*}} = llvm.mlir.addressof @a : !llvm.ptr>
+// LLVMIR-NOUNDER: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr>
+// LLVMIR-NOUNDER: llvm.call @bar(%{{.*}}) : (!llvm.ptr) -> ()
+// LLVMIR-NOUNDER: llvm.call @bar2(%{{.*}}) : (!llvm.ptr) -> ()
+
+// LLVMIR-NOUNDER: llvm.mlir.global common @a(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<

[PATCH] D144169: [WebAssembly] Fix simd bit shift intrinsics codegen

2023-02-16 Thread JunMa via Phabricator via cfe-commits
junparser updated this revision to Diff 497935.
junparser added a comment.

Replace rem with bitmask operation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144169

Files:
  clang/lib/Headers/wasm_simd128.h
  clang/test/Headers/wasm.c

Index: clang/test/Headers/wasm.c
===
--- clang/test/Headers/wasm.c
+++ clang/test/Headers/wasm.c
@@ -1584,11 +1584,12 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
 // CHECK-NEXT:[[TMP1:%.*]] = trunc i32 [[B:%.*]] to i8
-// CHECK-NEXT:[[TMP2:%.*]] = insertelement <16 x i8> undef, i8 [[TMP1]], i64 0
-// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <16 x i8> [[TMP2]], <16 x i8> poison, <16 x i32> zeroinitializer
+// CHECK-NEXT:[[TMP2:%.*]] = and i8 [[TMP1]], 7
+// CHECK-NEXT:[[TMP3:%.*]] = insertelement <16 x i8> undef, i8 [[TMP2]], i64 0
+// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <16 x i8> [[TMP3]], <16 x i8> poison, <16 x i32> zeroinitializer
 // CHECK-NEXT:[[SHL_I:%.*]] = shl <16 x i8> [[TMP0]], [[SH_PROM_I]]
-// CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[SHL_I]] to <4 x i32>
-// CHECK-NEXT:ret <4 x i32> [[TMP3]]
+// CHECK-NEXT:[[TMP4:%.*]] = bitcast <16 x i8> [[SHL_I]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP4]]
 //
 v128_t test_i8x16_shl(v128_t a, uint32_t b) {
   return wasm_i8x16_shl(a, b);
@@ -1598,11 +1599,12 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
 // CHECK-NEXT:[[TMP1:%.*]] = trunc i32 [[B:%.*]] to i8
-// CHECK-NEXT:[[TMP2:%.*]] = insertelement <16 x i8> undef, i8 [[TMP1]], i64 0
-// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <16 x i8> [[TMP2]], <16 x i8> poison, <16 x i32> zeroinitializer
+// CHECK-NEXT:[[TMP2:%.*]] = and i8 [[TMP1]], 7
+// CHECK-NEXT:[[TMP3:%.*]] = insertelement <16 x i8> undef, i8 [[TMP2]], i64 0
+// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <16 x i8> [[TMP3]], <16 x i8> poison, <16 x i32> zeroinitializer
 // CHECK-NEXT:[[SHR_I:%.*]] = ashr <16 x i8> [[TMP0]], [[SH_PROM_I]]
-// CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[SHR_I]] to <4 x i32>
-// CHECK-NEXT:ret <4 x i32> [[TMP3]]
+// CHECK-NEXT:[[TMP4:%.*]] = bitcast <16 x i8> [[SHR_I]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP4]]
 //
 v128_t test_i8x16_shr(v128_t a, uint32_t b) {
   return wasm_i8x16_shr(a, b);
@@ -1612,11 +1614,12 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <16 x i8>
 // CHECK-NEXT:[[TMP1:%.*]] = trunc i32 [[B:%.*]] to i8
-// CHECK-NEXT:[[TMP2:%.*]] = insertelement <16 x i8> undef, i8 [[TMP1]], i64 0
-// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <16 x i8> [[TMP2]], <16 x i8> poison, <16 x i32> zeroinitializer
+// CHECK-NEXT:[[TMP2:%.*]] = and i8 [[TMP1]], 7
+// CHECK-NEXT:[[TMP3:%.*]] = insertelement <16 x i8> undef, i8 [[TMP2]], i64 0
+// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <16 x i8> [[TMP3]], <16 x i8> poison, <16 x i32> zeroinitializer
 // CHECK-NEXT:[[SHR_I:%.*]] = lshr <16 x i8> [[TMP0]], [[SH_PROM_I]]
-// CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[SHR_I]] to <4 x i32>
-// CHECK-NEXT:ret <4 x i32> [[TMP3]]
+// CHECK-NEXT:[[TMP4:%.*]] = bitcast <16 x i8> [[SHR_I]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP4]]
 //
 v128_t test_u8x16_shr(v128_t a, uint32_t b) {
   return wasm_u8x16_shr(a, b);
@@ -1801,11 +1804,12 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <8 x i16>
 // CHECK-NEXT:[[TMP1:%.*]] = trunc i32 [[B:%.*]] to i16
-// CHECK-NEXT:[[TMP2:%.*]] = insertelement <8 x i16> undef, i16 [[TMP1]], i64 0
-// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <8 x i16> [[TMP2]], <8 x i16> poison, <8 x i32> zeroinitializer
+// CHECK-NEXT:[[TMP2:%.*]] = and i16 [[TMP1]], 15
+// CHECK-NEXT:[[TMP3:%.*]] = insertelement <8 x i16> undef, i16 [[TMP2]], i64 0
+// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <8 x i16> [[TMP3]], <8 x i16> poison, <8 x i32> zeroinitializer
 // CHECK-NEXT:[[SHL_I:%.*]] = shl <8 x i16> [[TMP0]], [[SH_PROM_I]]
-// CHECK-NEXT:[[TMP3:%.*]] = bitcast <8 x i16> [[SHL_I]] to <4 x i32>
-// CHECK-NEXT:ret <4 x i32> [[TMP3]]
+// CHECK-NEXT:[[TMP4:%.*]] = bitcast <8 x i16> [[SHL_I]] to <4 x i32>
+// CHECK-NEXT:ret <4 x i32> [[TMP4]]
 //
 v128_t test_i16x8_shl(v128_t a, uint32_t b) {
   return wasm_i16x8_shl(a, b);
@@ -1815,11 +1819,12 @@
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i32> [[A:%.*]] to <8 x i16>
 // CHECK-NEXT:[[TMP1:%.*]] = trunc i32 [[B:%.*]] to i16
-// CHECK-NEXT:[[TMP2:%.*]] = insertelement <8 x i16> undef, i16 [[TMP1]], i64 0
-// CHECK-NEXT:[[SH_PROM_I:%.*]] = shufflevector <8 x i16> [[TMP2]], <8 x i16> poison, <8 x i32> zeroinitializer
+//

[PATCH] D124351: [Clang] Implement Change scope of lambda trailing-return-type

2023-02-16 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 497937.
cor3ntin added a comment.

Reopen/Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124351

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Scope.h
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/Scope.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp
  clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1366,7 +1366,7 @@
 
   Change scope of lambda trailing-return-type
   https://wg21.link/P2036R3";>P2036R3
-  No
+  Clang 17
 
 
   https://wg21.link/P2579R0";>P2579R0
Index: clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -95,7 +95,7 @@
 #ifdef AVOID
   auto l4 = [var = param] (int param) { ; }; // no warning
 #else
-  auto l4 = [var = param] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  auto l4 = [var = param](int param) { ; }; // expected-warning 2{{declaration shadows a local variable}}
 #endif
 
   // Make sure that inner lambdas work as well.
Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -0,0 +1,243 @@
+// RUN: %clang_cc1 -std=c++2b -verify -fsyntax-only %s
+
+template 
+constexpr bool is_same = false;
+
+template 
+constexpr bool is_same = true;
+
+void f() {
+
+  int y;
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  auto ref = [&x = y](
+ decltype([&](decltype(x)) { return 0; }) y) {
+return x;
+  };
+}
+
+void test_noexcept() {
+
+  int y;
+
+  static_assert(noexcept([x = 1] noexcept(is_same) {}()));
+  static_assert(noexcept([x = 1] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([y] noexcept(is_same) {}()));
+  static_assert(noexcept([y] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([=] noexcept(is_same) {}()));
+  static_assert(noexcept([=] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([&] noexcept(is_same) {}()));
+  static_assert(noexcept([&] mutable noexcept(is_same) {}()));
+}
+
+void test_requires() {
+
+  int x;
+
+  [x = 1]() requires is_same {}
+  ();
+  [x = 1]() mutable requires is_same {}
+  ();
+  [x]() requires is_same {}
+  ();
+  [x]() mutable requires is_same {}
+  ();
+  [=]() requires is_same {}
+  ();
+  [=]() mutable requires is_same {}
+  ();
+  [&]() requires is_same {}
+  ();
+  [&]() mutable requires is_same {}
+  ();
+  [&x]() requires is_same {}
+  ();
+  [&x]() mutable requires is_same {}
+  ();
+
+  [x = 1]() requires is_same {} ();
+  [x = 1]() mutable requires is_same {} ();
+}
+
+void err() {
+  int y, z;
+  (void)[x = 1]
+  requires(is_same) {};
+
+  (void)[x = 1]{};
+
+  (void)[=]{};
+
+  (void)[z]{};
+}
+
+void gnu_attributes() {
+  int y;
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))) mutable {}();
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))) mutable {}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+
+
+  (void)[x=1]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+  // expected-warning@-1 {{wrong type}} expected-note@-1{{'diagnose_if' attribute on 'operator()'}}
+  (void)[x=1]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+
+  (void)[x=1]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))) mutable {}();
+  (void)[x=

[PATCH] D144100: [clang] Fix a bug that allowed some overflowing octal escape sequences

2023-02-16 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin added a comment.
This revision is now accepted and ready to land.

I wonder if a better fix would be change ResultChar to be a 64 bits integer, 
although I think it might be over killed (ie, i'm not aware of a good use case 
for wanting to store values that large in a 32 bits wide char, so this looks 
fine.
Thanks for the fix :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144100

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


[PATCH] D144179: [Clang] Added functionality to provide config file name via env variable

2023-02-16 Thread Jolanta Jensen via Phabricator via cfe-commits
jolanta.jensen created this revision.
jolanta.jensen added reviewers: mgabka, huntergr, david-arm.
Herald added a project: All.
jolanta.jensen requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Also added functionality to set the name of the config file env variable
via CMake.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144179

Files:
  clang/include/clang/Config/config.h.cmake
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/config-file-from-env.c

Index: clang/test/Driver/config-file-from-env.c
===
--- /dev/null
+++ clang/test/Driver/config-file-from-env.c
@@ -0,0 +1,51 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: mkdir %t/empty_dir
+// RUN: echo "-Wall" > %t/c.cfg
+// RUN: echo "-ffast-math" > %t/cxx.cfg
+// RUN: touch %t/unreadable.cfg
+// RUN: chmod 000 %t/unreadable.cfg
+// RUN: touch %t/test.c
+// RUN: touch %t/test.cpp
+
+// RUN: CONFIG_FILE=%t/c.cfg %clang -S %t/test.c -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-C1
+// CHECK-C1: Configuration file: {{.*}}/c.cfg
+// CHECK-C1: -Wall
+
+// RUN: CONFIG_FILE=%t/unreadable.cfg not %clang -S %t/test.c -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-C2
+// CHECK-C2: error: cannot read configuration file '{{.*}}/unreadable.cfg'
+
+// RUN: CONFIG_FILE=%t/c.cfg %clang -S %t/test.c --config %S/Inputs/config-1.cfg -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-C3
+// CHECK-C3: Configuration file: {{.*}}/config-1.cfg
+// CHECK-C3: -Werror
+// CHECK-C3-NOT: -Wall
+
+// RUN: CONFIG_FILE= not %clang -S %t/test.c -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-C4
+// CHECK-C4: error: cannot read configuration file ''
+
+// RUN: CONFIG_FILE=%t/empty_dir not %clang -S %t/test.c -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-C5
+// CHECK-C5: error: configuration file '{{.*}}/empty_dir' cannot be opened: not a regular file
+
+// RUN: CONFIG_FILE=%t/cxx.cfg %clang++ -S %t/test.cpp -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-CXX1
+// CHECK-CXX1: Configuration file: {{.*}}/cxx.cfg
+// CHECK-CXX1: -ffast-math
+
+// RUN: CONFIG_FILE=%t/unreadable.cfg not %clang++ -S %t/test.cpp -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-CXX2
+// CHECK-CXX2: error: cannot read configuration file '{{.*}}/unreadable.cfg'
+
+// RUN: CONFIG_FILE=%t/cxx.cfg %clang++ -S %t/test.cpp --config %S/Inputs/config-1.cfg -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-CXX3
+// CHECK-CXX3: Configuration file: {{.*}}/config-1.cfg
+// CHECK-CXX3: -Werror
+// CHECK-CXX3-NOT: -ffast-math
+
+// RUN: CONFIG_FILE= not %clang++ -S %t/test.cpp -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-CXX4
+// CHECK-CXX4: error: cannot read configuration file ''
+
+// RUN: CONFIG_FILE=%t/empty_dir not %clang++ -S %t/test.cpp -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-CXX5
+// CHECK-CXX5: error: configuration file '{{.*}}/empty_dir' cannot be opened: not a regular file
+
+// RUN: CONFIG_FILE=%t/c.cfg %clang++ --config=%t/cxx.cfg -S %t/test.cpp -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-CXX6
+// CHECK-CXX6-NOT: Configuration file: {{.*}}/c.cfg
+// CHECK-CXX6-NOT: -Wall
+
+// RUN: rm -rf %t
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1034,6 +1034,35 @@
   return false;
 }
 
+bool Driver::readConfigFileFromEnv() {
+  llvm::cl::ExpansionContext ExpCtx(Saver.getAllocator(),
+llvm::cl::tokenizeConfigFile);
+  ExpCtx.setVFS(&getVFS());
+  std::string EnvCfgName = "CONFIG_FILE";
+
+#if defined(ENV_CONFIG_FILE_NAME)
+  EnvCfgName = ENV_CONFIG_FILE_NAME;
+#endif
+  const char *EnvCfgFileName = getenv(EnvCfgName.c_str());
+
+  if (!EnvCfgFileName)
+return false;
+
+  std::string CfgFileName = EnvCfgFileName;
+  if (CfgFileName.empty()) {
+Diag(diag::err_drv_cannot_read_config_file) << CfgFileName << "";
+return true;
+  }
+
+  // If argument contains directory separator, treat it as a path to
+  // configuration file.
+  SmallString<128> CfgFilePath;
+  if (llvm::sys::path::is_relative(CfgFileName))
+llvm::sys::fs::current_path(CfgFilePath);
+  llvm::sys::path::append(CfgFilePath, CfgFileName);
+  return readConfigFile(CfgFilePath, ExpCtx);
+}
+
 bool Driver::loadConfigFiles() {
   llvm::cl::ExpansionContext ExpCtx(Saver.getAllocator(),
 llvm::cl::tokenizeConfigFile);
@@ -1099,6 +1128,9 @@
 }
   }
 
+  if (ConfigFiles.empty())
+return readConfigFileFromEnv();
+
   // No error occurred.
   return false;
 }
Index: clang/include/clang/Driver/Driver.h
===
--- clang/include/clang/Driver/Driver.h
+++ clang/include/clang/Driver/Driver.h
@@ 

[clang] 574e417 - [clang] Fix a bug that allowed some overflowing octal escape sequences

2023-02-16 Thread Sergei Barannikov via cfe-commits

Author: Sergei Barannikov
Date: 2023-02-16T15:19:24+03:00
New Revision: 574e417460cdfebb8157fbe61b6a015e44856f64

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

LOG: [clang] Fix a bug that allowed some overflowing octal escape sequences

Reviewed By: cor3ntin

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

Added: 


Modified: 
clang/lib/Lex/LiteralSupport.cpp
clang/test/Lexer/char-escapes-delimited.c

Removed: 




diff  --git a/clang/lib/Lex/LiteralSupport.cpp 
b/clang/lib/Lex/LiteralSupport.cpp
index 421a853360430..38b68bde4b516 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -263,7 +263,8 @@ static unsigned ProcessCharEscape(const char *ThisTokBegin,
 ThisTokBuf++;
 continue;
   }
-  if (ResultChar & 0x02000)
+  // Check if one of the top three bits is set before shifting them out.
+  if (ResultChar & 0xE000)
 Overflow = true;
 
   ResultChar <<= 3;

diff  --git a/clang/test/Lexer/char-escapes-delimited.c 
b/clang/test/Lexer/char-escapes-delimited.c
index 8e7094bc2ca5d..3b1deffe936db 100644
--- a/clang/test/Lexer/char-escapes-delimited.c
+++ b/clang/test/Lexer/char-escapes-delimited.c
@@ -58,6 +58,8 @@ void octal(void) {
 #if __WCHAR_MAX__ > 0x
   unsigned d = L'\o{377}'; // ext-warning {{extension}} cxx2b-warning 
{{C++2b}}
   unsigned e = L'\o{400}'; // expected-error {{octal escape sequence 
out of range}}
+  unsigned f = L'\o{1000}'; // expected-error {{octal escape sequence 
out of range}}
+  unsigned g = L'\o{2000}'; // expected-error {{octal escape sequence 
out of range}}
 #else
   unsigned d = L'\o{17}'; // ext-warning {{extension}} cxx2b-warning 
{{C++2b}}
   unsigned e = L'\o{20}'; // expected-error {{octal escape sequence out of 
range}}



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


[PATCH] D144100: [clang] Fix a bug that allowed some overflowing octal escape sequences

2023-02-16 Thread Sergei Barannikov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG574e417460cd: [clang] Fix a bug that allowed some 
overflowing octal escape sequences (authored by barannikov88).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144100

Files:
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/Lexer/char-escapes-delimited.c


Index: clang/test/Lexer/char-escapes-delimited.c
===
--- clang/test/Lexer/char-escapes-delimited.c
+++ clang/test/Lexer/char-escapes-delimited.c
@@ -58,6 +58,8 @@
 #if __WCHAR_MAX__ > 0x
   unsigned d = L'\o{377}'; // ext-warning {{extension}} cxx2b-warning 
{{C++2b}}
   unsigned e = L'\o{400}'; // expected-error {{octal escape sequence 
out of range}}
+  unsigned f = L'\o{1000}'; // expected-error {{octal escape sequence 
out of range}}
+  unsigned g = L'\o{2000}'; // expected-error {{octal escape sequence 
out of range}}
 #else
   unsigned d = L'\o{17}'; // ext-warning {{extension}} cxx2b-warning 
{{C++2b}}
   unsigned e = L'\o{20}'; // expected-error {{octal escape sequence out of 
range}}
Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -263,7 +263,8 @@
 ThisTokBuf++;
 continue;
   }
-  if (ResultChar & 0x02000)
+  // Check if one of the top three bits is set before shifting them out.
+  if (ResultChar & 0xE000)
 Overflow = true;
 
   ResultChar <<= 3;


Index: clang/test/Lexer/char-escapes-delimited.c
===
--- clang/test/Lexer/char-escapes-delimited.c
+++ clang/test/Lexer/char-escapes-delimited.c
@@ -58,6 +58,8 @@
 #if __WCHAR_MAX__ > 0x
   unsigned d = L'\o{377}'; // ext-warning {{extension}} cxx2b-warning {{C++2b}}
   unsigned e = L'\o{400}'; // expected-error {{octal escape sequence out of range}}
+  unsigned f = L'\o{1000}'; // expected-error {{octal escape sequence out of range}}
+  unsigned g = L'\o{2000}'; // expected-error {{octal escape sequence out of range}}
 #else
   unsigned d = L'\o{17}'; // ext-warning {{extension}} cxx2b-warning {{C++2b}}
   unsigned e = L'\o{20}'; // expected-error {{octal escape sequence out of range}}
Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -263,7 +263,8 @@
 ThisTokBuf++;
 continue;
   }
-  if (ResultChar & 0x02000)
+  // Check if one of the top three bits is set before shifting them out.
+  if (ResultChar & 0xE000)
 Overflow = true;
 
   ResultChar <<= 3;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140795: [Flang] Add user option -funderscoring/-fnounderscoring to control trailing underscore added to external names

2023-02-16 Thread Valentin Clement via Phabricator via cfe-commits
clementval accepted this revision.
clementval added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for working on this.


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

https://reviews.llvm.org/D140795

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


[PATCH] D144181: [clang][DebugInfo] Add abi-tags on constructors/destructors as LLVM annotations

2023-02-16 Thread Michael Buch via Phabricator via cfe-commits
Michael137 created this revision.
Michael137 added reviewers: dblaikie, aprantl.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

**Summary**

After this patch, any `AbiTagAttr` attribute on a constructor/destructor
(like the ones for numerous types in libcxx) will be attached to the
declaration `DW_TAG_subprogram` as a `DW_TAG_LLVM_annotation`. E.g.,

  DW_TAG_subprogram
DW_AT_name("shared_ptr")
DW_AT_decl_file   ("./bin/../include/c++/v1/__memory/shared_ptr.h")
DW_AT_decl_line   (475)
DW_AT_declaration (true)
DW_AT_external(true)
DW_AT_accessibility   (DW_ACCESS_public)
  
DW_TAG_LLVM_annotation
  DW_AT_name  ("abi_tag")
  DW_AT_const_value   ("v17")

We only emit these annotations for constructors/destructors declarations
because those don't carry linkage names, which is where this information
is usually encoded.

**Motivation**

ABI tags affect a function's linkage name, which LLDB uses to resolve
function calls during expression evaluation. However,
constructors/destructors are emitted as declarations and can have
multiple definitions with different linkage names for a single
declaration DIE. LLDB relies on Clang to mangle the function AST node
into the correct linkage name. However, LLDB doesn't know about the
`AbiTagAttr` that was attached to a constructor/destructor in the
source, so there's no way to cleanly reconstruct the AST and resolve
the function symbol.

With this patch, LLDB can attach the ABI tag to the ctor/dtor decl
and let clang determine which linkage name to pick.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144181

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/attr-abi_tag-ctors-dtors.cpp

Index: clang/test/CodeGen/attr-abi_tag-ctors-dtors.cpp
===
--- /dev/null
+++ clang/test/CodeGen/attr-abi_tag-ctors-dtors.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang -g -S -emit-llvm -o - %s | FileCheck %s
+
+struct Foo {
+  [[gnu::abi_tag("Ctor")]] Foo() {}
+  [[gnu::abi_tag("Dtor")]] ~Foo() {}
+};
+
+Foo f;
+
+// CHECK:  ![[#]] = !DISubprogram(name: "Foo",
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: [[#]], annotations: ![[CTOR_ANNOTS:[0-9]+]])
+// CHECK:  ![[CTOR_ANNOTS]] = !{![[CTOR:[0-9]+]]}
+// CHECK:  ![[CTOR]] = !{!"abi_tag", !"Ctor"}
+// CHECK:  ![[#]] = !DISubprogram(name: "~Foo",
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: [[#]], annotations: ![[DTOR_ANNOTS:[0-9]+]])
+// CHECK:  ![[DTOR_ANNOTS]] = !{![[DTOR:[0-9]+]]}
+// CHECK:  ![[DTOR]] = !{!"abi_tag", !"Dtor"}
+// CHECK:  ![[#]] = distinct !DISubprogram(name: "Foo",
+// FCHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], declaration: ![[#]], retainedNodes: ![[#]], annotations: ![[CTOR_ANNOTS]])
+// FCHECK:  ![[#]] = distinct !DISubprogram(name: "~Foo",
+// FCHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], declaration: ![[#]], retainedNodes: ![[#]], annotations: ![[DTOR_ANNOTS]])
+// FCHECK:  ![[#]] = distinct !DISubprogram(name: "Foo",
+// FCHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], declaration: ![[#]], retainedNodes: ![[#]], annotations: ![[CTOR_ANNOTS]])
+// FCHECK:  ![[#]] = distinct !DISubprogram(name: "~Foo",
+// FCHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], declaration: ![[#]], retainedNodes: ![[#]], annotations: ![[DTOR_ANNOTS]])
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -303,6 +303,10 @@
   /// A helper function to collect debug info for btf_decl_tag annotations.
   llvm::DINodeArray CollectBTFDeclTagAnnotations(const Decl *D);
 
+  /// A helper function to collect debug info for abi_tag annotations.
+  /// Returns a null DINodeArray if 'D' doesn't have any 'clang::AbiTagAttr's.
+  llvm::DINodeArray CollectAbiTagAnnotations(const Decl *D);
+
   llvm::DIType *createFieldType(StringRef name, QualType type,
 SourceLocation loc, AccessSpecifier AS,
 uint64_t offsetInBits, uint32_t AlignInBits,
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1350,6 +1350,8 @@
   SourceLocation Loc = Ty->getDecl()->getLocation();
 
   uint32_t Align = getDeclAlignIfRequired(Ty->getDecl(), CGM.getContext());
+  // TODO: need to account for tags on typedefs? Or would LLDB correctly
+  // call through typedefs of abi-tagged decls?
   // Typedefs are derived from some other type.
   llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(Ty->g

[PATCH] D144181: [clang][DebugInfo] Add abi-tags on constructors/destructors as LLVM annotations

2023-02-16 Thread Michael Buch via Phabricator via cfe-commits
Michael137 updated this revision to Diff 497983.
Michael137 added a comment.

- Remove leftover comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144181

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/attr-abi_tag-ctors-dtors.cpp

Index: clang/test/CodeGen/attr-abi_tag-ctors-dtors.cpp
===
--- /dev/null
+++ clang/test/CodeGen/attr-abi_tag-ctors-dtors.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang -g -S -emit-llvm -o - %s | FileCheck %s
+
+struct Foo {
+  [[gnu::abi_tag("Ctor")]] Foo() {}
+  [[gnu::abi_tag("Dtor")]] ~Foo() {}
+};
+
+Foo f;
+
+// CHECK:  ![[#]] = !DISubprogram(name: "Foo",
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: [[#]], annotations: ![[CTOR_ANNOTS:[0-9]+]])
+// CHECK:  ![[CTOR_ANNOTS]] = !{![[CTOR:[0-9]+]]}
+// CHECK:  ![[CTOR]] = !{!"abi_tag", !"Ctor"}
+// CHECK:  ![[#]] = !DISubprogram(name: "~Foo",
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: [[#]], annotations: ![[DTOR_ANNOTS:[0-9]+]])
+// CHECK:  ![[DTOR_ANNOTS]] = !{![[DTOR:[0-9]+]]}
+// CHECK:  ![[DTOR]] = !{!"abi_tag", !"Dtor"}
+// CHECK:  ![[#]] = distinct !DISubprogram(name: "Foo",
+// FCHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], declaration: ![[#]], retainedNodes: ![[#]], annotations: ![[CTOR_ANNOTS]])
+// FCHECK:  ![[#]] = distinct !DISubprogram(name: "~Foo",
+// FCHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], declaration: ![[#]], retainedNodes: ![[#]], annotations: ![[DTOR_ANNOTS]])
+// FCHECK:  ![[#]] = distinct !DISubprogram(name: "Foo",
+// FCHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], declaration: ![[#]], retainedNodes: ![[#]], annotations: ![[CTOR_ANNOTS]])
+// FCHECK:  ![[#]] = distinct !DISubprogram(name: "~Foo",
+// FCHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], declaration: ![[#]], retainedNodes: ![[#]], annotations: ![[DTOR_ANNOTS]])
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -303,6 +303,10 @@
   /// A helper function to collect debug info for btf_decl_tag annotations.
   llvm::DINodeArray CollectBTFDeclTagAnnotations(const Decl *D);
 
+  /// A helper function to collect debug info for abi_tag annotations.
+  /// Returns a null DINodeArray if 'D' doesn't have any 'clang::AbiTagAttr's.
+  llvm::DINodeArray CollectAbiTagAnnotations(const Decl *D);
+
   llvm::DIType *createFieldType(StringRef name, QualType type,
 SourceLocation loc, AccessSpecifier AS,
 uint64_t offsetInBits, uint32_t AlignInBits,
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1350,6 +1350,8 @@
   SourceLocation Loc = Ty->getDecl()->getLocation();
 
   uint32_t Align = getDeclAlignIfRequired(Ty->getDecl(), CGM.getContext());
+  // TODO: need to account for tags on typedefs? Or would LLDB correctly
+  // call through typedefs of abi-tagged decls?
   // Typedefs are derived from some other type.
   llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(Ty->getDecl());
 
@@ -1842,11 +1844,19 @@
   SPFlags |= llvm::DISubprogram::SPFlagDeleted;
   };
 
+  llvm::DINodeArray AbiTagAnnotations = nullptr;
+
   switch (Method->getKind()) {
 
   case Decl::CXXConstructor:
   case Decl::CXXDestructor:
 checkAttrDeleted(Method);
+
+// Add annotations for abi_tag's for constructors/destructors
+// because their declarations don't carry linkage names (which
+// encodes the existance of abi-tags). LLDB uses these annotations
+// to resolve calls to abi-tagged constructors/destructors.
+AbiTagAnnotations = CollectAbiTagAnnotations(Method);
 break;
   case Decl::CXXMethod:
 if (Method->isCopyAssignmentOperator() ||
@@ -1893,7 +1903,7 @@
   llvm::DISubprogram *SP = DBuilder.createMethod(
   RecordTy, MethodName, MethodLinkageName, MethodDefUnit, MethodLine,
   MethodTy, VIndex, ThisAdjustment, ContainingType, Flags, SPFlags,
-  TParamsArray.get());
+  TParamsArray.get(), nullptr, AbiTagAnnotations);
 
   SPCache[Method->getCanonicalDecl()].reset(SP);
 
@@ -2195,6 +2205,21 @@
   return DBuilder.getOrCreateArray(Annotations);
 }
 
+llvm::DINodeArray CGDebugInfo::CollectAbiTagAnnotations(const Decl *D) {
+  if (!D->hasAttr())
+return nullptr;
+
+  SmallVector Annotations;
+  auto const *Attr = D->getAttr();
+  for (const auto Tag : Attr->tags()) {
+llvm::Metadata *Ops[2] = {
+llvm::MDString::get(CGM.getLLVMContext(), StringRef("abi_tag")),
+llvm::MDString::get(CGM.getLLVMCont

[PATCH] D144136: Add a "remark" to report on array accesses

2023-02-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I'd like to understand what the overhead is for this. How much overhead does 
this add when the remark is disabled? How much overhead does this add when the 
remark is enabled?

> This will report a ton of information. It's basically only good for piping to 
> a file and using Perl to gather any useful information.

This is why I'm worried about overhead -- there can be *a lot* of array 
accesses in a complex TU and spitting data out to (potentially) stdout/stderr 
is *slow*.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144136

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


[PATCH] D144181: [clang][DebugInfo] Add abi-tags on constructors/destructors as LLVM annotations

2023-02-16 Thread Michael Buch via Phabricator via cfe-commits
Michael137 updated this revision to Diff 497986.
Michael137 added a comment.

- Remove leftover comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144181

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/attr-abi_tag-ctors-dtors.cpp


Index: clang/test/CodeGen/attr-abi_tag-ctors-dtors.cpp
===
--- /dev/null
+++ clang/test/CodeGen/attr-abi_tag-ctors-dtors.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang -g -S -emit-llvm -o - %s | FileCheck %s
+
+struct Foo {
+  [[gnu::abi_tag("Ctor")]] Foo() {}
+  [[gnu::abi_tag("Dtor")]] ~Foo() {}
+};
+
+Foo f;
+
+// CHECK:  ![[#]] = !DISubprogram(name: "Foo",
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: [[#]], annotations: 
![[CTOR_ANNOTS:[0-9]+]])
+// CHECK:  ![[CTOR_ANNOTS]] = !{![[CTOR:[0-9]+]]}
+// CHECK:  ![[CTOR]] = !{!"abi_tag", !"Ctor"}
+// CHECK:  ![[#]] = !DISubprogram(name: "~Foo",
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: [[#]], annotations: 
![[DTOR_ANNOTS:[0-9]+]])
+// CHECK:  ![[DTOR_ANNOTS]] = !{![[DTOR:[0-9]+]]}
+// CHECK:  ![[DTOR]] = !{!"abi_tag", !"Dtor"}
+// CHECK:  ![[#]] = distinct !DISubprogram(name: "Foo",
+// FCHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: 
![[#]], declaration: ![[#]], retainedNodes: ![[#]], annotations: 
![[CTOR_ANNOTS]])
+// FCHECK:  ![[#]] = distinct !DISubprogram(name: "~Foo",
+// FCHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: 
![[#]], declaration: ![[#]], retainedNodes: ![[#]], annotations: 
![[DTOR_ANNOTS]])
+// FCHECK:  ![[#]] = distinct !DISubprogram(name: "Foo",
+// FCHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: 
![[#]], declaration: ![[#]], retainedNodes: ![[#]], annotations: 
![[CTOR_ANNOTS]])
+// FCHECK:  ![[#]] = distinct !DISubprogram(name: "~Foo",
+// FCHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: 
![[#]], declaration: ![[#]], retainedNodes: ![[#]], annotations: 
![[DTOR_ANNOTS]])
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -303,6 +303,10 @@
   /// A helper function to collect debug info for btf_decl_tag annotations.
   llvm::DINodeArray CollectBTFDeclTagAnnotations(const Decl *D);
 
+  /// A helper function to collect debug info for abi_tag annotations.
+  /// Returns a null DINodeArray if 'D' doesn't have any 'clang::AbiTagAttr's.
+  llvm::DINodeArray CollectAbiTagAnnotations(const Decl *D);
+
   llvm::DIType *createFieldType(StringRef name, QualType type,
 SourceLocation loc, AccessSpecifier AS,
 uint64_t offsetInBits, uint32_t AlignInBits,
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1842,11 +1842,19 @@
   SPFlags |= llvm::DISubprogram::SPFlagDeleted;
   };
 
+  llvm::DINodeArray AbiTagAnnotations = nullptr;
+
   switch (Method->getKind()) {
 
   case Decl::CXXConstructor:
   case Decl::CXXDestructor:
 checkAttrDeleted(Method);
+
+// Add annotations for abi_tag's for constructors/destructors
+// because their declarations don't carry linkage names (which
+// encodes the existance of abi-tags). LLDB uses these annotations
+// to resolve calls to abi-tagged constructors/destructors.
+AbiTagAnnotations = CollectAbiTagAnnotations(Method);
 break;
   case Decl::CXXMethod:
 if (Method->isCopyAssignmentOperator() ||
@@ -1893,7 +1901,7 @@
   llvm::DISubprogram *SP = DBuilder.createMethod(
   RecordTy, MethodName, MethodLinkageName, MethodDefUnit, MethodLine,
   MethodTy, VIndex, ThisAdjustment, ContainingType, Flags, SPFlags,
-  TParamsArray.get());
+  TParamsArray.get(), nullptr, AbiTagAnnotations);
 
   SPCache[Method->getCanonicalDecl()].reset(SP);
 
@@ -2195,6 +2203,21 @@
   return DBuilder.getOrCreateArray(Annotations);
 }
 
+llvm::DINodeArray CGDebugInfo::CollectAbiTagAnnotations(const Decl *D) {
+  if (!D->hasAttr())
+return nullptr;
+
+  SmallVector Annotations;
+  auto const *Attr = D->getAttr();
+  for (const auto Tag : Attr->tags()) {
+llvm::Metadata *Ops[2] = {
+llvm::MDString::get(CGM.getLLVMContext(), StringRef("abi_tag")),
+llvm::MDString::get(CGM.getLLVMContext(), Tag)};
+Annotations.push_back(llvm::MDNode::get(CGM.getLLVMContext(), Ops));
+  }
+  return DBuilder.getOrCreateArray(Annotations);
+}
+
 llvm::DIType *CGDebugInfo::getOrCreateVTablePtrType(llvm::DIFile *Unit) {
   if (VTablePtrType)
 return VTablePtrType;


Index: clang/test/CodeGen/attr-abi_tag-ctors-dtors.cpp
===
-

[PATCH] D144181: [clang][DebugInfo] Add abi-tags on constructors/destructors as LLVM annotations

2023-02-16 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added a comment.

Left is without patch. Right is with patch.

    
 
  file: bin/lldb.dSYM/Contents/Resources/DWARF/lldb file: 
bin/lldb.dSYM/Contents/Resources/DWARF/lldb
    
 
  SECTION   SIZE (b)SECTION 
  SIZE (b)   
    
     
  __debug_line   1168840 (6.21%)
__debug_line   1168840 (6.18%)   
  __debug_info   6102802 (32.40%)   
__debug_info   6196012 (32.73%)  
  __debug_ranges   11760 (0.06%)
__debug_ranges   11760 (0.06%)   
  __debug_aranges   3360 (0.02%)
__debug_aranges   3360 (0.02%)   
  __debug_loc412 (0.00%)
__debug_loc412 (0.00%)   
  __debug_abbrev8419 (0.04%)
__debug_abbrev8431 (0.04%)   
  __debug_str7762681 (41.21%)   
__debug_str7762697 (41.01%)  
  __apple_names   654916 (3.48%)
__apple_names   654916 (3.46%)   
  __apple_namespac 22936 (0.12%)
__apple_namespac 22936 (0.12%)   
  __apple_types  1185783 (6.30%)
__apple_types  1185783 (6.26%)   
  __apple_objc36 (0.00%)
__apple_objc36 (0.00%)   

 
   Total Size: 16921945  (89.84%)Total 
Size: 17015183  (89.89%)  
   Total File Size: 18834777 Total 
File Size: 18928015   
    
 

 
    
 
  file: lib/libc++.1.dylib.dSYM/Contents/Resources/DWARF/libc++.1.dylib file: 
lib/libc++.1.dylib.dSYM/Contents/Resources/DWARF/libc++.1.dylib
    
 
  SECTION   SIZE (b)SECTION 
  SIZE (b)   
    
     
  __debug_line497612 (12.53%)   
__debug_line497612 (12.49%)  
  __debug_aranges   2032 (0.05%)
__debug_aranges   2032 (0.05%)   
  __debug_info   1353725 (34.09%)   
__debug_info   1366516 (34.30%)  
  __debug_ranges   10544 (0.27%)
__debug_ranges   10544 (0.26%)   
  __debug_loc515 (0.01%)
__debug_loc515 (0.01%)   
  __debug_abbrev5177 (0.13%)
__debug_abbrev5189 (0.13%)   
  __debug_str1084612 (27.31%)   
__debug_str1084628 (27.22%)  
  __apple_names   250484 (6.31%)
__apple_names   250484 (6.29%)   
  __apple_namespac  1476 (0.04%)   

[PATCH] D142609: [Clang] Fix -Wconstant-logical-operand when LHS is a constant

2023-02-16 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

gentle ping for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609

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


[PATCH] D144170: [clang-format] Add simple macro replacements in formatting.

2023-02-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

It's happening!




Comment at: clang/lib/Format/ContinuationIndenter.cpp:743
 
+  // Align following lines within parenthesis / brackets if configured.
+  // For a line of macro parents, the commas that follow the opening 
parenthesis

nit: parentheses



Comment at: clang/lib/Format/ContinuationIndenter.cpp:744
+  // Align following lines within parenthesis / brackets if configured.
+  // For a line of macro parents, the commas that follow the opening 
parenthesis
+  // in the line come after the opening parenthesis' children - we want to 
align

This is a bit hard to follow without context, I had to look up 
MacroCallReconstructor::takeResult() to recall the structure it's referring to, 
and there's no obvious breadcrumb to point you there. And if you don't follow 
the details, it's hard to understand what the relevance is.

Maybe something like: this doesn't apply to macro expansion lines, which are 
`MACRO( , , )` with args as children of `(` and `,`. It does not make sense to 
align the commas with the opening paren.

(I think describing here how the alignment ends up working in that case might 
just add confusion: it's not handled by this code, right?)



Comment at: clang/lib/Format/TokenAnnotator.h:68
 FormatToken *Current = First;
+addChildren(Line.Tokens.front(), Current);
 for (const UnwrappedLineNode &Node : llvm::drop_begin(Line.Tokens)) {

this seems like a separate bugfix: previously if the first node in Line.Tokens 
had children, we wouldn't be adding them.

Is this true? Was there some reason the first node could never have children 
before?



Comment at: clang/lib/Format/TokenAnnotator.h:76
+  addChildren(Node, Current);
+  // FIXME: if we add children, previous will point to the token before
+  // the children; changing this requires significant changes across

does "add children" here refer to the procedure in addChildren(), or to the 
token insertion idea introduced in the previous patch?

(i.e. is this just describing that previous/next skip over trees of children 
rather than including them in the chain, or is there something new going on?)



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:924
+  Tok->MacroCtx->Role = MR_UnexpandedArg;
+  Tok->SpacesRequiredBefore = 0;
+} else {

comment as to why?



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:926
+} else {
+  Tok->Finalized = true;
+}

why do we no longer finalize the child tree?



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:225
+  }
+  Callback.finishRun();
+}

I'm sure you got this right, but it's hard for me to evaluate this code because 
I don't know what `UnwrappedLineConsumer::finishRun()` is for - it's not 
documented and the implementation is mysterious.

You might consider adding a comment to that interface/method, it's not really 
related to this change though.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:4198
   LLVM_DEBUG({
-if (CurrentLines == &Lines)
+if (CurrentLines == &Lines) {
+  llvm::dbgs() << "Adding unwrapped line:\n";

nit: you check this condition a bunch of times, and this patch adds more.

giving it a name like `!parsingPPDirective()` would be less cryptic



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:4235
+// FIXME: We format the expanded lines in an extra step that does not give
+// the formatter all unwrapped lines, thus the indexes are invalid; to 
allow
+// all features during expanded line formatting, recalcuate the indexes

This is a bit vague as to what the "indexes" refer to and what the implications 
are (between comment & code "indexes" is mentioned 3 times but it's not clear 
without digging what they are).

AFAICS in practice this only affects indentation of braces in whitesmiths 
style, which may be worth mentioning. (It'll get stale, but at the moment the 
comment sounds like arbitrary things are likely to be broken)



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:4564
+  // We parse the macro call into a new line.
+  auto Args = parseMacroCall();
+  InExpansion = OldInExpansion;

it looks like you go into parsing the macro call including parens and arguments 
regardless of whether the macro is object-like or function-like.

So given
```
#define DEBUG puts
DEBUG("foo");
```
you're going to expand to `puts;` instead of `puts("foo");`



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:4573
+  Line = std::move(PreCall);
+  SmallVector New = Macros.expand(ID, Args);
+  if (!New.empty())

Calling a macro with the wrong arity might be worth flagging in 

[PATCH] D124351: [Clang] Implement Change scope of lambda trailing-return-type

2023-02-16 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 497994.
cor3ntin added a comment.

Fix GH60518 by not trying to capture parameters declared in the current 
context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124351

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Scope.h
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/Scope.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp
  clang/test/SemaCXX/lambda-expressions.cpp
  clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1366,7 +1366,7 @@
 
   Change scope of lambda trailing-return-type
   https://wg21.link/P2036R3";>P2036R3
-  No
+  Clang 17
 
 
   https://wg21.link/P2579R0";>P2579R0
Index: clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -95,7 +95,7 @@
 #ifdef AVOID
   auto l4 = [var = param] (int param) { ; }; // no warning
 #else
-  auto l4 = [var = param] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  auto l4 = [var = param](int param) { ; }; // expected-warning 2{{declaration shadows a local variable}}
 #endif
 
   // Make sure that inner lambdas work as well.
Index: clang/test/SemaCXX/lambda-expressions.cpp
===
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -665,3 +665,19 @@
 // expected-note@-2 2 {{default capture by}}
 }
 };
+
+namespace GH60518 {
+// Lambdas should not try to capture
+// function parameters that are used in enable_if
+struct StringLiteral {
+template 
+StringLiteral(const char (&array)[N])
+__attribute__((enable_if(__builtin_strlen(array) == 2,
+  "invalid string literal")));
+};
+
+void Func1() {
+  [[maybe_unused]] auto y = [&](decltype(StringLiteral("xx"))) {};
+}
+
+}
Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -0,0 +1,243 @@
+// RUN: %clang_cc1 -std=c++2b -verify -fsyntax-only %s
+
+template 
+constexpr bool is_same = false;
+
+template 
+constexpr bool is_same = true;
+
+void f() {
+
+  int y;
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  auto ref = [&x = y](
+ decltype([&](decltype(x)) { return 0; }) y) {
+return x;
+  };
+}
+
+void test_noexcept() {
+
+  int y;
+
+  static_assert(noexcept([x = 1] noexcept(is_same) {}()));
+  static_assert(noexcept([x = 1] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([y] noexcept(is_same) {}()));
+  static_assert(noexcept([y] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([=] noexcept(is_same) {}()));
+  static_assert(noexcept([=] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([&] noexcept(is_same) {}()));
+  static_assert(noexcept([&] mutable noexcept(is_same) {}()));
+}
+
+void test_requires() {
+
+  int x;
+
+  [x = 1]() requires is_same {}
+  ();
+  [x = 1]() mutable requires is_same {}
+  ();
+  [x]() requires is_same {}
+  ();
+  [x]() mutable requires is_same {}
+  ();
+  [=]() requires is_same {}
+  ();
+  [=]() mutable requires is_same {}
+  ();
+  [&]() requires is_same {}
+  ();
+  [&]() mutable requires is_same {}
+  ();
+  [&x]() requires is_same {}
+  ();
+  [&x]() mutable requires is_same {}
+  ();
+
+  [x = 1]() requires is_same {} ();
+  [x = 1]() mutable requires is_same {} ();
+}
+
+void err() {
+  int y, z;
+  (void)[x = 1]
+  requires(is_same) {};
+
+  (void)[x = 1]{};
+
+  (void)[=]{};
+
+  (void)[z]{};
+}
+
+void gnu_attributes() {
+  int y;
+  (void)[=]() __attribute__((diagnose_if(!is_same, "wrong type", "warning"))){}();
+  // expected-warning@-1 {{wrong type}} 

[PATCH] D143704: [Flang] Part one of Feature List action

2023-02-16 Thread Eric Schweitz via Phabricator via cfe-commits
schweitz added a comment.

In D143704#4130124 , @jdoerfert wrote:

> In D143704#4130062 , @clementval 
> wrote:
>
>> Where is this coming from? Did I miss where this was discussed.
>
> It's discussed here, for now. :)
>
>> You will not be able to find all not implemented features by going on 
>> through the AST. Most of the not implemented message are triggered by 
>> lowering.
>
> Right. Let's take a step back.
> First, this allows us to identify (and count) features used by an app 
> programmatically. This is in itself useful and we should not intertwine it 
> with the (non-)implemented parts (see my comment from before).
> Next, we want to identify if a "feature" is implemented or not. This is 
> arguably not a straight forward task and also not 100% tied to AST nodes, 
> however, it would be a useful capability for the time being.
> One idea was to extend the `TODO` function to include some tie to a AST 
> entity. That will work sometimes, and sometimes it won't. In either case it 
> is unclear how we can continue lowering (or whatever stage the TODO is in).
> Thus, we might want to manually associate the existing `TODO`s with AST 
> features in a map we maintain. So we run this counting scheme, then lookup 
> each entity in the map, and provide feedback if it is supported, not 
> supported, or partially supported (or unknown).
> All that said, let's separate the concerns into 1) listing of features, and 
> 2) assigning implementation status. This patch does only the former and 
> should be reviewed as such.

For some background context:

TODO is a macro. It had 2 purposes. 1. Developers: easy to grep for and find. 
2. Developers and users: imposing a practice where flang would halt 
(semi-)meaningfully rather than generate garbage output for the user to wade 
through.

It has no association with the parse tree. (Flang doesn't have an AST to my 
knowledge.) The flang parser has its own diagnostics reporting system.

TODO is flexible enough to allow different diagnostic systems to be used, 
different sorts of fatal exits to report different information, etc.

However, it should be considered harmful to make the TODO macro always 
associate with some syntactic source artifact. It would also be unwise to 
redefine TODO from a halt semantics to a "just keep going and see what happens" 
semantics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143704

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


[PATCH] D143691: Fix clang-formats IncludeCategory to match the documentation

2023-02-16 Thread Fabian Keßler via Phabricator via cfe-commits
Febbe added inline comments.



Comment at: clang/unittests/Format/SortIncludesTest.cpp:548
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"llvm/a.h\"\n"
+"#include \"b.h\"\n"

HazardyKnusperkeks wrote:
> While I may accept there are more than one //main// header, this should not 
> happen in my opinion.
Yes, that is a conflict of interests. There is no perfect way of implementing 
this, without the help of clang-tidy / the clang language server:

To arguably define a file as a main include, all declarations must be analyzed, 
whether they are predeclared in the include or not.
But we don't have the help of the clang AST.

My expectation is, that when I randomly shuffle the includes, that they are 
always sorted to the same result.
Currently, this is not the case, and depending on the rules it can furthermore 
happen, that a main include "a.h" is exchanged with the "llvm/a.h". 
This should also not happen, but it does, and it is not covered by the tests.

I consider the false negative of a correct main include worse than a false 
positive.
Therefore, I changed it. 
In addition, my approach has the advantage that all includes are sorted in the 
same way, regardless of the order.

But if you want, we could introduce a new Option like: `enum 
FindMainIncludes{FMI_First, FMI_All, FMI_Off = 0};`
With `First` to match the current behavior, `All` for the new behavior.
But then matched includes with a negative priority would be swapped with the 
other possible main_include at each run.
I don't know how to prevent this.
The best solution I can imagine, is still a comment of the programmer, that the 
respective include is or is not a main include.
E.g. `// clang-format pragma: no_main_include`

Another idea would be, to insert all main includes into a list with the 
matchers' priority, and then take the last negative or the first positive, but 
only if it is not partially sortable with the neighbors.
This might be a good heuristic, whether the include was previously detected as 
main include.
But I don't know if this is implementable with the current algorithm.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143691

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


[PATCH] D143704: [Flang] Part one of Feature List action

2023-02-16 Thread Eric Schweitz via Phabricator via cfe-commits
schweitz added a comment.

I should've mentioned in my comment that the TODO macros are meant to be 
deleted. Some day, there will be no more TODOs and there should be a huge 
celebration.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143704

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


[PATCH] D144188: Tighten up a modules test

2023-02-16 Thread Paul Robinson via Phabricator via cfe-commits
probinson created this revision.
probinson added a reviewer: ChuanqiXu.
Herald added a project: All.
probinson requested review of this revision.

https://reviews.llvm.org/D144188

Files:
  clang/test/CXX/module/basic/basic.def.odr/p4.cppm


Index: clang/test/CXX/module/basic/basic.def.odr/p4.cppm
===
--- clang/test/CXX/module/basic/basic.def.odr/p4.cppm
+++ clang/test/CXX/module/basic/basic.def.odr/p4.cppm
@@ -2,7 +2,7 @@
 // RUN: mkdir %t
 // RUN: split-file %s %t
 //
-// RUN: %clang_cc1 -std=c++20 %t/Module.cppm -triple %itanium_abi_triple 
-emit-llvm -o - | FileCheck %t/Module.cppm --implicit-check-not unused_inline 
--implicit-check-not unused_stastic_global_module
+// RUN: %clang_cc1 -std=c++20 %t/Module.cppm -triple %itanium_abi_triple 
-emit-llvm -o - | FileCheck %t/Module.cppm --implicit-check-not unused
 //
 // RUN: %clang_cc1 -std=c++20 %t/Module.cppm -triple %itanium_abi_triple 
-emit-module-interface -o %t/Module.pcm
 // RUN: %clang_cc1 -std=c++20 %t/module.cpp -triple %itanium_abi_triple 
-fmodule-file=%t/Module.pcm -emit-llvm -o - | FileCheck %t/module.cpp 
--implicit-check-not=unused --implicit-check-not=global_module
@@ -33,8 +33,6 @@
 // CHECK-DAG: @_ZL24const_var_module_linkage = internal
 //
 // CHECK-DAG: @_ZW6Module25unused_var_module_linkage = {{(dso_local )?}}global 
i32 4
-// CHECK-NOT: @_ZW6Module32unused_static_var_module_linkage =
-// CHECK-NOT: @_ZW6Module31unused_const_var_module_linkage =
 
 module;
 
@@ -85,7 +83,6 @@
   }
 }
 
-// CHECK-NOT: define {{(dso_local )?}}void 
{{.*}}@_ZW6Module28unused_static_module_linkagev
 static void unused_static_module_linkage() {}
 
 static void used_static_module_linkage() {}


Index: clang/test/CXX/module/basic/basic.def.odr/p4.cppm
===
--- clang/test/CXX/module/basic/basic.def.odr/p4.cppm
+++ clang/test/CXX/module/basic/basic.def.odr/p4.cppm
@@ -2,7 +2,7 @@
 // RUN: mkdir %t
 // RUN: split-file %s %t
 //
-// RUN: %clang_cc1 -std=c++20 %t/Module.cppm -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %t/Module.cppm --implicit-check-not unused_inline --implicit-check-not unused_stastic_global_module
+// RUN: %clang_cc1 -std=c++20 %t/Module.cppm -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %t/Module.cppm --implicit-check-not unused
 //
 // RUN: %clang_cc1 -std=c++20 %t/Module.cppm -triple %itanium_abi_triple -emit-module-interface -o %t/Module.pcm
 // RUN: %clang_cc1 -std=c++20 %t/module.cpp -triple %itanium_abi_triple -fmodule-file=%t/Module.pcm -emit-llvm -o - | FileCheck %t/module.cpp --implicit-check-not=unused --implicit-check-not=global_module
@@ -33,8 +33,6 @@
 // CHECK-DAG: @_ZL24const_var_module_linkage = internal
 //
 // CHECK-DAG: @_ZW6Module25unused_var_module_linkage = {{(dso_local )?}}global i32 4
-// CHECK-NOT: @_ZW6Module32unused_static_var_module_linkage =
-// CHECK-NOT: @_ZW6Module31unused_const_var_module_linkage =
 
 module;
 
@@ -85,7 +83,6 @@
   }
 }
 
-// CHECK-NOT: define {{(dso_local )?}}void {{.*}}@_ZW6Module28unused_static_module_linkagev
 static void unused_static_module_linkage() {}
 
 static void used_static_module_linkage() {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144188: Tighten up a modules test

2023-02-16 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

I looked at this test only because it caused a merge conflict downstream. While 
it does work, it will not catch some kinds of mistakes; by being less specific 
in the "not" checks, it will catch more potential problems.




Comment at: clang/test/CXX/module/basic/basic.def.odr/p4.cppm:5
 //
-// RUN: %clang_cc1 -std=c++20 %t/Module.cppm -triple %itanium_abi_triple 
-emit-llvm -o - | FileCheck %t/Module.cppm --implicit-check-not unused_inline 
--implicit-check-not unused_stastic_global_module
 //

Note the typo "unused_sta*s*tic_global_module"
Simpler to reject all "unused" strings.



Comment at: clang/test/CXX/module/basic/basic.def.odr/p4.cppm:88
 
-// CHECK-NOT: define {{(dso_local )?}}void 
{{.*}}@_ZW6Module28unused_static_module_linkagev
 static void unused_static_module_linkage() {}

This CHECK-NOT is overly specific. For example,
`define dso_local hidden void ...`
would not match, and therefore pass, when it should not.


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

https://reviews.llvm.org/D144188

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


[PATCH] D144190: [AIX][clang] Storage Locations for Constant Pointers

2023-02-16 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 created this revision.
qiongsiwu1 added a project: clang.
Herald added subscribers: ormris, kbarton, nemanjai.
Herald added a project: All.
qiongsiwu1 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.

This patch adds clang options `-mroptr` and `-mno-roptr` to specify storage 
locations for constant pointers on AIX.

When the `-mroptr` option is in effect, constant pointers, virtual function 
tables, and virtual type tables are placed in read-only storage. When the 
`-mno-roptr` option is in effect, pointers, virtual function tables, and 
virtual type tables are placed are placed in read/write storage.

This patch depends on https://reviews.llvm.org/D144189.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144190

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/PowerPC/aix-roptr.c
  clang/test/Driver/ppc-roptr.c

Index: clang/test/Driver/ppc-roptr.c
===
--- /dev/null
+++ clang/test/Driver/ppc-roptr.c
@@ -0,0 +1,18 @@
+// RUN: %clang -### -target powerpc-ibm-aix-xcoff -mroptr %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target powerpc-ibm-aix-xcoff -mroptr -mno-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=ROPTR
+// RUN: %clang -### -target powerpc64-ibm-aix-xcoff -mroptr %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target powerpc64-ibm-aix-xcoff -mroptr -mno-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=ROPTR
+// CHECK: "-mroptr"
+// CHECK: "-bforceimprw"
+// ROPTR-NOT: "-mroptr"
+// ROPTR-NOT: "-bforceimprw"
+
+char c1 = 10;
+char c2 = 20;
+char* const c1_ptr = &c1;
+
+int main() {
+*(char**)&c1_ptr = &c2;
+}
Index: clang/test/CodeGen/PowerPC/aix-roptr.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/aix-roptr.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix-xcoff -mroptr -fdata-sections \
+// RUN: -S <%s | FileCheck %s --check-prefix=CHECK32
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -mroptr -fdata-sections \
+// RUN: -S <%s | FileCheck %s --check-prefix=CHECK64
+// RUN: not %clang_cc1 -triple=powerpc-ibm-aix-xcoff -mroptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: not %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -mroptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: not %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -mroptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=TARGET_ERR
+// RUN: not %clang -Xclang -triple=powerpc-ibm-aix-xcoff -mroptr -shared \
+// RUN: -S %s 2>&1 | FileCheck %s --check-prefix=SHARED_ERR
+// RUN: not %clang -Xclang -triple=powerpc64-ibm-aix-xcoff -mroptr -shared \
+// RUN: -S %s 2>&1 | FileCheck %s --check-prefix=SHARED_ERR
+
+char c1 = 10;
+char c2 = 20;
+char* const c1_ptr = &c1;
+// CHECK32: .csect c1_ptr[RO],2
+// CHECK32-NEXT:	.globl	c1_ptr[RO]
+// CHECK32-NEXT:	.align	2
+// CHECK32-NEXT:	.vbyte	4, c1[RW]
+
+// CHECK64: .csect c1_ptr[RO],3
+// CHECK64-NEXT:	.globl	c1_ptr[RO]
+// CHECK64-NEXT:	.align	3
+// CHECK64-NEXT:	.vbyte	8, c1[RW]
+
+// DATA_SECTION_ERR: error: -mroptr is supported only with -fdata-sections
+// TARGET_ERR: error: unsupported option '-mroptr' for target 'powerpc64le-unknown-linux-gnu'
+// SHARED_ERR: error: -mroptr is not suppored with -shared
+
+int main() {
+*(char**)&c1_ptr = &c2;
+}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1560,6 +1560,9 @@
   if (Opts.EnableAIXExtendedAltivecABI)
 GenerateArg(Args, OPT_mabi_EQ_vec_extabi, SA);
 
+  if (Opts.ReadOnlyPointers)
+GenerateArg(Args, OPT_mroptr, SA);
+
   if (!Opts.OptRecordPasses.empty())
 GenerateArg(Args, OPT_opt_record_passes, Opts.OptRecordPasses, SA);
 
@@ -1949,6 +1952,17 @@
 Opts.EnableAIXExtendedAltivecABI = O.matches(OPT_mabi_EQ_vec_extabi);
   }
 
+  if (Arg *A = Args.getLastArg(OPT_mroptr)) {
+if (!T.isOSAIX())
+  Diags.Report(diag::err_drv_unsupported_opt_for_target)
+  << A->getSpelling() << T.str();
+
+if (!Args.hasFlag(OPT_fdata_sections, OPT_fno_data_sections, false))
+  Diags.Report(diag::err_roptr_requires_data_sections);
+
+Opts.ReadOnlyPointers = true;
+  }
+
   if (Arg *A = Args.getLastArg(OPT_mabi_EQ_quadword_atomics)) {
 if (!T.isOSAIX() || T.isPPC32())
   Diags.Report(diag::err_drv_unsupported_opt_for_target)
Index: clang/lib/Driver/ToolChains/Clang.cpp
==

[PATCH] D144181: [clang][DebugInfo] Add abi-tags on constructors/destructors as LLVM annotations

2023-02-16 Thread Michael Buch via Phabricator via cfe-commits
Michael137 updated this revision to Diff 498019.
Michael137 added a comment.

- Update test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144181

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/attr-abi_tag-ctors-dtors.cpp

Index: clang/test/CodeGen/attr-abi_tag-ctors-dtors.cpp
===
--- /dev/null
+++ clang/test/CodeGen/attr-abi_tag-ctors-dtors.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang -g -S -emit-llvm -o - %s | FileCheck %s
+
+struct Foo {
+  [[gnu::abi_tag("Ctor")]] Foo() {}
+  [[gnu::abi_tag("Dtor")]] ~Foo() {}
+};
+
+struct Bar {
+  [[gnu::abi_tag("v1", ".1")]] [[gnu::abi_tag("Ignored1")]] Bar() {}
+  [[gnu::abi_tag("v2", ".0")]] [[gnu::abi_tag("Ignored2")]] ~Bar() {}
+};
+
+Bar b;
+Foo f;
+
+// CHECK:  ![[#]] = !DISubprogram(name: "Foo",
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: [[#]], annotations: ![[FOO_CTOR_ANNOTS:[0-9]+]])
+// CHECK:  ![[FOO_CTOR_ANNOTS]] = !{![[CTOR:[0-9]+]]}
+// CHECK:  ![[CTOR]] = !{!"abi_tag", !"Ctor"}
+// CHECK:  ![[#]] = !DISubprogram(name: "~Foo",
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: [[#]], annotations: ![[FOO_DTOR_ANNOTS:[0-9]+]])
+// CHECK:  ![[FOO_DTOR_ANNOTS]] = !{![[DTOR:[0-9]+]]}
+// CHECK:  ![[DTOR]] = !{!"abi_tag", !"Dtor"}
+
+// CHECK:  ![[#]] = !DISubprogram(name: "Bar",
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: [[#]], annotations: ![[BAR_CTOR_ANNOTS:[0-9]+]])
+// CHECK:  ![[BAR_CTOR_ANNOTS]] = !{![[CTOR:[0-9]+]], ![[TAG:[0-9]+]]}
+// CHECK:  ![[CTOR]] = !{!"abi_tag", !".1"}
+// CHECK:  ![[TAG]] = !{!"abi_tag", !"v1"}
+// CHECK:  ![[#]] = !DISubprogram(name: "~Bar",
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: [[#]], annotations: ![[BAR_DTOR_ANNOTS:[0-9]+]])
+// CHECK:  ![[BAR_DTOR_ANNOTS]] = !{![[DTOR:[0-9]+]], ![[TAG:[0-9]+]]}
+// CHECK:  ![[DTOR]] = !{!"abi_tag", !".0"}
+// CHECK:  ![[TAG]] = !{!"abi_tag", !"v2"}
+// CHECK:  ![[#]] = distinct !DISubprogram(name: "Bar", linkageName:
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], declaration: ![[#]], retainedNodes: ![[#]])
+// CHECK:  ![[#]] = distinct !DISubprogram(name: "~Bar", linkageName:
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], declaration: ![[#]], retainedNodes: ![[#]])
+// CHECK:  ![[#]] = distinct !DISubprogram(name: "Foo", linkageName:
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], declaration: ![[#]], retainedNodes: ![[#]])
+// CHECK:  ![[#]] = distinct !DISubprogram(name: "~Foo", linkageName:
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], declaration: ![[#]], retainedNodes: ![[#]])
+// CHECK:  ![[#]] = distinct !DISubprogram(name: "Bar", linkageName:
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], declaration: ![[#]], retainedNodes: ![[#]])
+// CHECK:  ![[#]] = distinct !DISubprogram(name: "~Bar", linkageName:
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], declaration: ![[#]], retainedNodes: ![[#]])
+// CHECK:  ![[#]] = distinct !DISubprogram(name: "Foo", linkageName:
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], declaration: ![[#]], retainedNodes: ![[#]])
+// CHECK:  ![[#]] = distinct !DISubprogram(name: "~Foo", linkageName:
+// CHECK-SAME: flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: ![[#]], declaration: ![[#]], retainedNodes: ![[#]])
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -303,6 +303,10 @@
   /// A helper function to collect debug info for btf_decl_tag annotations.
   llvm::DINodeArray CollectBTFDeclTagAnnotations(const Decl *D);
 
+  /// A helper function to collect debug info for abi_tag annotations.
+  /// Returns a null DINodeArray if 'D' doesn't have any 'clang::AbiTagAttr's.
+  llvm::DINodeArray CollectAbiTagAnnotations(const Decl *D);
+
   llvm::DIType *createFieldType(StringRef name, QualType type,
 SourceLocation loc, AccessSpecifier AS,
 uint64_t offsetInBits, uint32_t AlignInBits,
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1842,11 +1842,19 @@
   SPFlags |= llvm::DISubprogram::SPFlagDeleted;
   };
 
+  llvm::DINodeArray AbiTagAnnotations = nullptr;
+
   switch (Method->getKind()) {
 
   case Decl::CXXConstructor:
   case Decl::CXXDestructor:
 checkAttrDeleted(Method);
+
+// Add annotations for abi_tag's for constructors/destructors
+// becaus

[PATCH] D143704: [Flang] Part one of Feature List action

2023-02-16 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan added a comment.

FWIW, We have a plugin 
(https://github.com/llvm/llvm-project/tree/main/flang/examples/FlangOmpReport) 
that goes over the parse-tree and reports all the OpenMP constructs and clauses 
seen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143704

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


[PATCH] D141230: [clang-format-diff.py] give clang-format-diff a job pool (10x speed)

2023-02-16 Thread Sean Maher via Phabricator via cfe-commits
seanptmaher added a comment.

Hey, bump on this. Still waiting on the commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141230

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


[PATCH] D144169: [WebAssembly] Fix simd bit shift intrinsics codegen

2023-02-16 Thread Thomas Lively via Phabricator via cfe-commits
tlively accepted this revision.
tlively added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144169

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


[PATCH] D144192: GH60642: Fix ICE when checking a lambda defined in a concept definition

2023-02-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added a reviewer: clang-language-wg.
Herald added a project: All.
erichkeane requested review of this revision.

As reported in GH60642, we asserted when there was a lambda defined in a
template arguments inside of a concept, which caused us to not properly
set up the list of instantiation args.  This patch ensures that the
'lambda context decl' correctly falls-through the template argument
instantiation, so that it is available when instantiating the lambda,
and thus, when setting up the lambda instantiation args list.


https://reviews.llvm.org/D144192

Files:
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaTemplate/concepts-lambda.cpp


Index: clang/test/SemaTemplate/concepts-lambda.cpp
===
--- clang/test/SemaTemplate/concepts-lambda.cpp
+++ clang/test/SemaTemplate/concepts-lambda.cpp
@@ -1,6 +1,5 @@
 // RUN: %clang_cc1 -std=c++20 -verify %s
 // RUN: %clang_cc1 -std=c++20 -verify %s -triple powerpc64-ibm-aix
-// expected-no-diagnostics
 
 namespace GH57945 {
   template
@@ -92,3 +91,28 @@
 static_assert(ConstructibleWithN);
 
 }
+
+// GH60642 reported an assert being hit, make sure we don't assert.
+namespace GH60642 {
+template concept C = requires { Q.template operator()(); };
+template concept D = true;
+static_assert(C<[]{}>);  // ok
+template concept E = C<[]{}>;
+static_assert(E);  // previously Asserted.
+
+// ensure we properly diagnose when "D" is false.
+namespace DIsFalse {
+template concept C = requires { Q.template operator()(); };
+template concept D = false;
+static_assert(C<[]{}>);
+// expected-error@-1{{static assertion failed}}
+// expected-note@-2{{does not satisfy 'C'}}
+// expected-note@-5{{because 'Q.template operator()()' would be 
invalid: no matching member function for call to 'operator()'}}
+template concept E = C<[]{}>;
+static_assert(E);
+// expected-error@-1{{static assertion failed}}
+// expected-note@-2{{because 'int' does not satisfy 'E'}}
+// expected-note@-4{{does not satisfy 'C'}}
+// expected-note@-11{{because 'Q.template operator()()' would be 
invalid: no matching member function for call to 'operator()'}}
+}
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -4569,7 +4569,7 @@
 getSema(),
 Uneval ? Sema::ExpressionEvaluationContext::Unevaluated
: Sema::ExpressionEvaluationContext::ConstantEvaluated,
-/*LambdaContextDecl=*/nullptr, /*ExprContext=*/
+Sema::ReuseLambdaContextDecl, /*ExprContext=*/
 Sema::ExpressionEvaluationContextRecord::EK_TemplateArgument);
 
 Expr *InputExpr = Input.getSourceExpression();


Index: clang/test/SemaTemplate/concepts-lambda.cpp
===
--- clang/test/SemaTemplate/concepts-lambda.cpp
+++ clang/test/SemaTemplate/concepts-lambda.cpp
@@ -1,6 +1,5 @@
 // RUN: %clang_cc1 -std=c++20 -verify %s
 // RUN: %clang_cc1 -std=c++20 -verify %s -triple powerpc64-ibm-aix
-// expected-no-diagnostics
 
 namespace GH57945 {
   template
@@ -92,3 +91,28 @@
 static_assert(ConstructibleWithN);
 
 }
+
+// GH60642 reported an assert being hit, make sure we don't assert.
+namespace GH60642 {
+template concept C = requires { Q.template operator()(); };
+template concept D = true;
+static_assert(C<[]{}>);  // ok
+template concept E = C<[]{}>;
+static_assert(E);  // previously Asserted.
+
+// ensure we properly diagnose when "D" is false.
+namespace DIsFalse {
+template concept C = requires { Q.template operator()(); };
+template concept D = false;
+static_assert(C<[]{}>);
+// expected-error@-1{{static assertion failed}}
+// expected-note@-2{{does not satisfy 'C'}}
+// expected-note@-5{{because 'Q.template operator()()' would be invalid: no matching member function for call to 'operator()'}}
+template concept E = C<[]{}>;
+static_assert(E);
+// expected-error@-1{{static assertion failed}}
+// expected-note@-2{{because 'int' does not satisfy 'E'}}
+// expected-note@-4{{does not satisfy 'C'}}
+// expected-note@-11{{because 'Q.template operator()()' would be invalid: no matching member function for call to 'operator()'}}
+}
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -4569,7 +4569,7 @@
 getSema(),
 Uneval ? Sema::ExpressionEvaluationContext::Unevaluated
: Sema::ExpressionEvaluationContext::ConstantEvaluated,
-/*LambdaContextDecl=*/nullptr, /*ExprContext=*/
+Sema::ReuseLambdaContextDecl, /*ExprContext=*/
 Sema::ExpressionEvaluationContextRecord::EK_TemplateArgument);
 
 Expr *InputExpr = Input.getSourceExpression();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http

[PATCH] D144192: GH60642: Fix ICE when checking a lambda defined in a concept definition

2023-02-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I don't really need reviewers here, I'm more putting this on phab to get the 
libcxx testing, once that succeeds, i intend to do this as Review-after-commit 
if there are no concerns (and also ask for this to go to 16.0, as it is a 
regression).


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

https://reviews.llvm.org/D144192

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


[clang] 081815b - [Clang] Regenerate check lines (NFC)

2023-02-16 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2023-02-16T17:05:25+01:00
New Revision: 081815b4e32cc57debe974ff89d61436f3bcec83

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

LOG: [Clang] Regenerate check lines (NFC)

Convert test to use update_cc_test_checks.

Added: 


Modified: 
clang/test/CodeGen/WebAssembly/wasm-varargs.c

Removed: 




diff  --git a/clang/test/CodeGen/WebAssembly/wasm-varargs.c 
b/clang/test/CodeGen/WebAssembly/wasm-varargs.c
index 91840c296096..869ff4afe5c1 100644
--- a/clang/test/CodeGen/WebAssembly/wasm-varargs.c
+++ b/clang/test/CodeGen/WebAssembly/wasm-varargs.c
@@ -1,7 +1,28 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature
 // RUN: %clang_cc1 -no-opaque-pointers -triple wasm32-unknown-unknown -o - 
-emit-llvm %s | FileCheck %s
 
 #include 
 
+// CHECK-LABEL: define {{[^@]+}}@test_i32
+// CHECK-SAME: (i8* noundef [[FMT:%.*]], ...) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[FMT_ADDR:%.*]] = alloca i8*, align 4
+// CHECK-NEXT:[[VA:%.*]] = alloca i8*, align 4
+// CHECK-NEXT:[[V:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i8* [[FMT]], i8** [[FMT_ADDR]], align 4
+// CHECK-NEXT:[[VA1:%.*]] = bitcast i8** [[VA]] to i8*
+// CHECK-NEXT:call void @llvm.va_start(i8* [[VA1]])
+// CHECK-NEXT:[[ARGP_CUR:%.*]] = load i8*, i8** [[VA]], align 4
+// CHECK-NEXT:[[ARGP_NEXT:%.*]] = getelementptr inbounds i8, i8* 
[[ARGP_CUR]], i32 4
+// CHECK-NEXT:store i8* [[ARGP_NEXT]], i8** [[VA]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast i8* [[ARGP_CUR]] to i32*
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* [[TMP0]], align 4
+// CHECK-NEXT:store i32 [[TMP1]], i32* [[V]], align 4
+// CHECK-NEXT:[[VA2:%.*]] = bitcast i8** [[VA]] to i8*
+// CHECK-NEXT:call void @llvm.va_end(i8* [[VA2]])
+// CHECK-NEXT:[[TMP2:%.*]] = load i32, i32* [[V]], align 4
+// CHECK-NEXT:ret i32 [[TMP2]]
+//
 int test_i32(char *fmt, ...) {
   va_list va;
 
@@ -12,25 +33,31 @@ int test_i32(char *fmt, ...) {
   return v;
 }
 
-// CHECK-LABEL: define i32 @test_i32(i8*{{.*}} %fmt, ...) {{.*}} {
-// CHECK:   [[FMT_ADDR:%[^,=]+]] = alloca i8*, align 4
-// CHECK:   [[VA:%[^,=]+]] = alloca i8*, align 4
-// CHECK:   [[V:%[^,=]+]] = alloca i32, align 4
-// CHECK:   store i8* %fmt, i8** [[FMT_ADDR]], align 4
-// CHECK:   [[VA1:%[^,=]+]] = bitcast i8** [[VA]] to i8*
-// CHECK:   call void @llvm.va_start(i8* [[VA1]])
-// CHECK:   [[ARGP_CUR:%[^,=]+]] = load i8*, i8** [[VA]], align 4
-// CHECK:   [[ARGP_NEXT:%[^,=]+]] = getelementptr inbounds i8, i8* 
[[ARGP_CUR]], i32 4
-// CHECK:   store i8* [[ARGP_NEXT]], i8** [[VA]], align 4
-// CHECK:   [[R3:%[^,=]+]] = bitcast i8* [[ARGP_CUR]] to i32*
-// CHECK:   [[R4:%[^,=]+]] = load i32, i32* [[R3]], align 4
-// CHECK:   store i32 [[R4]], i32* [[V]], align 4
-// CHECK:   [[VA2:%[^,=]+]] = bitcast i8** [[VA]] to i8*
-// CHECK:   call void @llvm.va_end(i8* [[VA2]])
-// CHECK:   [[R5:%[^,=]+]] = load i32, i32* [[V]], align 4
-// CHECK:   ret i32 [[R5]]
-// CHECK: }
 
+// CHECK-LABEL: define {{[^@]+}}@test_i64
+// CHECK-SAME: (i8* noundef [[FMT:%.*]], ...) #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[FMT_ADDR:%.*]] = alloca i8*, align 4
+// CHECK-NEXT:[[VA:%.*]] = alloca i8*, align 4
+// CHECK-NEXT:[[V:%.*]] = alloca i64, align 8
+// CHECK-NEXT:store i8* [[FMT]], i8** [[FMT_ADDR]], align 4
+// CHECK-NEXT:[[VA1:%.*]] = bitcast i8** [[VA]] to i8*
+// CHECK-NEXT:call void @llvm.va_start(i8* [[VA1]])
+// CHECK-NEXT:[[ARGP_CUR:%.*]] = load i8*, i8** [[VA]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = ptrtoint i8* [[ARGP_CUR]] to i32
+// CHECK-NEXT:[[TMP1:%.*]] = add i32 [[TMP0]], 7
+// CHECK-NEXT:[[TMP2:%.*]] = and i32 [[TMP1]], -8
+// CHECK-NEXT:[[ARGP_CUR_ALIGNED:%.*]] = inttoptr i32 [[TMP2]] to i8*
+// CHECK-NEXT:[[ARGP_NEXT:%.*]] = getelementptr inbounds i8, i8* 
[[ARGP_CUR_ALIGNED]], i32 8
+// CHECK-NEXT:store i8* [[ARGP_NEXT]], i8** [[VA]], align 4
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast i8* [[ARGP_CUR_ALIGNED]] to i64*
+// CHECK-NEXT:[[TMP4:%.*]] = load i64, i64* [[TMP3]], align 8
+// CHECK-NEXT:store i64 [[TMP4]], i64* [[V]], align 8
+// CHECK-NEXT:[[VA2:%.*]] = bitcast i8** [[VA]] to i8*
+// CHECK-NEXT:call void @llvm.va_end(i8* [[VA2]])
+// CHECK-NEXT:[[TMP5:%.*]] = load i64, i64* [[V]], align 8
+// CHECK-NEXT:ret i64 [[TMP5]]
+//
 long long test_i64(char *fmt, ...) {
   va_list va;
 
@@ -41,28 +68,6 @@ long long test_i64(char *fmt, ...) {
   return v;
 }
 
-// CHECK-LABEL: define i64 @test_i64(i8*{{.*}} %fmt, ...) {{.*}} {
-// CHECK:   [[FMT_ADDR:%[^,=]+]] = alloca i8*, align 4
-// CHECK:   [[VA:%[^,=]+]] = alloca i8*, align 4
-// CHECK:   [[V:%[^,=]+]] = alloca i64,

[clang] eb3dfa0 - [Clang] Convert some tests to opaque pointers (NFC)

2023-02-16 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2023-02-16T17:05:26+01:00
New Revision: eb3dfa0a248794cc51912705540f1ab1f4dde619

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

LOG: [Clang] Convert some tests to opaque pointers (NFC)

Added: 


Modified: 
clang/test/CodeGen/WebAssembly/wasm-varargs.c
clang/test/CodeGen/X86/avx512fp16-builtins.c
clang/test/CodeGen/X86/ms-x86-intrinsics.c
clang/test/CodeGen/ms-intrinsics-other.c

Removed: 




diff  --git a/clang/test/CodeGen/WebAssembly/wasm-varargs.c 
b/clang/test/CodeGen/WebAssembly/wasm-varargs.c
index 869ff4afe5c1..3c743692e094 100644
--- a/clang/test/CodeGen/WebAssembly/wasm-varargs.c
+++ b/clang/test/CodeGen/WebAssembly/wasm-varargs.c
@@ -1,26 +1,23 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature
-// RUN: %clang_cc1 -no-opaque-pointers -triple wasm32-unknown-unknown -o - 
-emit-llvm %s | FileCheck %s
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -o - -emit-llvm %s | 
FileCheck %s
 
 #include 
 
 // CHECK-LABEL: define {{[^@]+}}@test_i32
-// CHECK-SAME: (i8* noundef [[FMT:%.*]], ...) #[[ATTR0:[0-9]+]] {
+// CHECK-SAME: (ptr noundef [[FMT:%.*]], ...) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[FMT_ADDR:%.*]] = alloca i8*, align 4
-// CHECK-NEXT:[[VA:%.*]] = alloca i8*, align 4
+// CHECK-NEXT:[[FMT_ADDR:%.*]] = alloca ptr, align 4
+// CHECK-NEXT:[[VA:%.*]] = alloca ptr, align 4
 // CHECK-NEXT:[[V:%.*]] = alloca i32, align 4
-// CHECK-NEXT:store i8* [[FMT]], i8** [[FMT_ADDR]], align 4
-// CHECK-NEXT:[[VA1:%.*]] = bitcast i8** [[VA]] to i8*
-// CHECK-NEXT:call void @llvm.va_start(i8* [[VA1]])
-// CHECK-NEXT:[[ARGP_CUR:%.*]] = load i8*, i8** [[VA]], align 4
-// CHECK-NEXT:[[ARGP_NEXT:%.*]] = getelementptr inbounds i8, i8* 
[[ARGP_CUR]], i32 4
-// CHECK-NEXT:store i8* [[ARGP_NEXT]], i8** [[VA]], align 4
-// CHECK-NEXT:[[TMP0:%.*]] = bitcast i8* [[ARGP_CUR]] to i32*
-// CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* [[TMP0]], align 4
-// CHECK-NEXT:store i32 [[TMP1]], i32* [[V]], align 4
-// CHECK-NEXT:[[VA2:%.*]] = bitcast i8** [[VA]] to i8*
-// CHECK-NEXT:call void @llvm.va_end(i8* [[VA2]])
-// CHECK-NEXT:[[TMP2:%.*]] = load i32, i32* [[V]], align 4
+// CHECK-NEXT:store ptr [[FMT]], ptr [[FMT_ADDR]], align 4
+// CHECK-NEXT:call void @llvm.va_start(ptr [[VA]])
+// CHECK-NEXT:[[ARGP_CUR:%.*]] = load ptr, ptr [[VA]], align 4
+// CHECK-NEXT:[[ARGP_NEXT:%.*]] = getelementptr inbounds i8, ptr 
[[ARGP_CUR]], i32 4
+// CHECK-NEXT:store ptr [[ARGP_NEXT]], ptr [[VA]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[ARGP_CUR]], align 4
+// CHECK-NEXT:store i32 [[TMP1]], ptr [[V]], align 4
+// CHECK-NEXT:call void @llvm.va_end(ptr [[VA]])
+// CHECK-NEXT:[[TMP2:%.*]] = load i32, ptr [[V]], align 4
 // CHECK-NEXT:ret i32 [[TMP2]]
 //
 int test_i32(char *fmt, ...) {
@@ -35,27 +32,24 @@ int test_i32(char *fmt, ...) {
 
 
 // CHECK-LABEL: define {{[^@]+}}@test_i64
-// CHECK-SAME: (i8* noundef [[FMT:%.*]], ...) #[[ATTR0]] {
+// CHECK-SAME: (ptr noundef [[FMT:%.*]], ...) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[FMT_ADDR:%.*]] = alloca i8*, align 4
-// CHECK-NEXT:[[VA:%.*]] = alloca i8*, align 4
+// CHECK-NEXT:[[FMT_ADDR:%.*]] = alloca ptr, align 4
+// CHECK-NEXT:[[VA:%.*]] = alloca ptr, align 4
 // CHECK-NEXT:[[V:%.*]] = alloca i64, align 8
-// CHECK-NEXT:store i8* [[FMT]], i8** [[FMT_ADDR]], align 4
-// CHECK-NEXT:[[VA1:%.*]] = bitcast i8** [[VA]] to i8*
-// CHECK-NEXT:call void @llvm.va_start(i8* [[VA1]])
-// CHECK-NEXT:[[ARGP_CUR:%.*]] = load i8*, i8** [[VA]], align 4
-// CHECK-NEXT:[[TMP0:%.*]] = ptrtoint i8* [[ARGP_CUR]] to i32
+// CHECK-NEXT:store ptr [[FMT]], ptr [[FMT_ADDR]], align 4
+// CHECK-NEXT:call void @llvm.va_start(ptr [[VA]])
+// CHECK-NEXT:[[ARGP_CUR:%.*]] = load ptr, ptr [[VA]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = ptrtoint ptr [[ARGP_CUR]] to i32
 // CHECK-NEXT:[[TMP1:%.*]] = add i32 [[TMP0]], 7
 // CHECK-NEXT:[[TMP2:%.*]] = and i32 [[TMP1]], -8
-// CHECK-NEXT:[[ARGP_CUR_ALIGNED:%.*]] = inttoptr i32 [[TMP2]] to i8*
-// CHECK-NEXT:[[ARGP_NEXT:%.*]] = getelementptr inbounds i8, i8* 
[[ARGP_CUR_ALIGNED]], i32 8
-// CHECK-NEXT:store i8* [[ARGP_NEXT]], i8** [[VA]], align 4
-// CHECK-NEXT:[[TMP3:%.*]] = bitcast i8* [[ARGP_CUR_ALIGNED]] to i64*
-// CHECK-NEXT:[[TMP4:%.*]] = load i64, i64* [[TMP3]], align 8
-// CHECK-NEXT:store i64 [[TMP4]], i64* [[V]], align 8
-// CHECK-NEXT:[[VA2:%.*]] = bitcast i8** [[VA]] to i8*
-// CHECK-NEXT:call void @llvm.va_end(i8* [[VA2]])
-// CHECK-NEXT:[[TMP5:%.*]] = load i64, i64* [[V]], align 8
+// CHECK-NEX

[PATCH] D143704: [Flang] Part one of Feature List action

2023-02-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

> However, it should be considered harmful to make the TODO macro always 
> associate with some syntactic source artifact. It would also be unwise to 
> redefine TODO from a halt semantics to a "just keep going and see what 
> happens" semantics.

@schweitz Why? What's the inherent harm to do that under a flag in an 
experimental compiler that is called `...-new`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143704

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


[PATCH] D143692: [clang][driver] Emit error when enabling emulated tls on unsupported architectures

2023-02-16 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth abandoned this revision.
paulkirth added a comment.

Based on discussion at the LLVM RISC-V community call, we're going to support 
emulated TLS in RISC-V, so we can abandon this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143692

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


[PATCH] D144195: [XCore] Adapt Clang tests to opaque pointers.

2023-02-16 Thread Nigel Perks via Phabricator via cfe-commits
nigelp-xmos created this revision.
Herald added a project: All.
nigelp-xmos requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144195

Files:
  clang/test/CodeGen/xcore-abi.c
  clang/test/CodeGen/xcore-stringtype.c

Index: clang/test/CodeGen/xcore-stringtype.c
===
--- clang/test/CodeGen/xcore-stringtype.c
+++ clang/test/CodeGen/xcore-stringtype.c
@@ -1,5 +1,5 @@
 // REQUIRES: xcore-registered-target
-// RUN: %clang_cc1 -no-opaque-pointers -triple xcore-unknown-unknown -fno-signed-char -fno-common -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple xcore-unknown-unknown -fno-signed-char -fno-common -emit-llvm -o - %s | FileCheck %s
 
 // CHECK: target triple = "xcore-unknown-unknown"
 
@@ -23,8 +23,7 @@
 
 
 // test BuiltinType
-// CHECK: !{{[0-9]+}} = !{void (i1, i8, i8, i8, i16, i16, i16, i32, i32, i32,
-// CHECK:  i32, i32, i32, i64, i64, i64, float, double, double)*
+// CHECK: !{{[0-9]+}} = !{ptr
 // CHECK:  @builtinType, !"f{0}(b,uc,uc,sc,ss,us,ss,si,ui,si,sl,
 // CHECK:  ul,sl,sll,ull,sll,ft,d,ld)"}
 void builtinType(_Bool B, char C, unsigned char UC, signed char SC, short S,
@@ -36,14 +35,14 @@
 
 
 // test FunctionType & Qualifiers
-// CHECK: !{{[0-9]+}} = !{void ()* @gI, !"f{0}()"}
-// CHECK: !{{[0-9]+}} = !{void (...)* @eI, !"f{0}()"}
-// CHECK: !{{[0-9]+}} = !{void ()* @gV, !"f{0}(0)"}
-// CHECK: !{{[0-9]+}} = !{void ()* @eV, !"f{0}(0)"}
-// CHECK: !{{[0-9]+}} = !{void (i32, ...)* @gVA, !"f{0}(si,va)"}
-// CHECK: !{{[0-9]+}} = !{void (i32, ...)* @eVA, !"f{0}(si,va)"}
-// CHECK: !{{[0-9]+}} = !{i32* (i32*)* @gQ, !"f{crv:p(cv:si)}(p(cv:si))"}
-// CHECK: !{{[0-9]+}} = !{i32* (i32*)* @eQ, !"f{crv:p(cv:si)}(p(cv:si))"}
+// CHECK: !{{[0-9]+}} = !{ptr @gI, !"f{0}()"}
+// CHECK: !{{[0-9]+}} = !{ptr @eI, !"f{0}()"}
+// CHECK: !{{[0-9]+}} = !{ptr @gV, !"f{0}(0)"}
+// CHECK: !{{[0-9]+}} = !{ptr @eV, !"f{0}(0)"}
+// CHECK: !{{[0-9]+}} = !{ptr @gVA, !"f{0}(si,va)"}
+// CHECK: !{{[0-9]+}} = !{ptr @eVA, !"f{0}(si,va)"}
+// CHECK: !{{[0-9]+}} = !{ptr @gQ, !"f{crv:p(cv:si)}(p(cv:si))"}
+// CHECK: !{{[0-9]+}} = !{ptr @eQ, !"f{crv:p(cv:si)}(p(cv:si))"}
 extern void eI();
 void gI() {eI();};
 extern void eV(void);
@@ -57,10 +56,10 @@
 
 
 // test PointerType
-// CHECK: !{{[0-9]+}} = !{i32* (i32*, i32* (i32*)*)*
+// CHECK: !{{[0-9]+}} = !{ptr
 // CHECK:   @pointerType, !"f{p(si)}(p(si),p(f{p(si)}(p(si"}
-// CHECK: !{{[0-9]+}} = !{i32** @EP, !"p(si)"}
-// CHECK: !{{[0-9]+}} = !{i32** @GP, !"p(si)"}
+// CHECK: !{{[0-9]+}} = !{ptr @EP, !"p(si)"}
+// CHECK: !{{[0-9]+}} = !{ptr @GP, !"p(si)"}
 extern int* EP;
 int* GP;
 int* pointerType(int *I, int * (*FP)(int *)) {
@@ -68,19 +67,19 @@
 }
 
 // test ArrayType
-// CHECK: !{{[0-9]+}} = !{[2 x i32]* (i32*, i32*, [2 x i32]*, [2 x i32]*, i32*)*
+// CHECK: !{{[0-9]+}} = !{ptr
 // CHECK:   @arrayType, !"f{p(a(2:si))}(p(si),p(cv:si),p(a(2:si)),
 // CHECK:   p(a(2:si)),p(si))"}
-// CHECK: !{{[0-9]+}} = !{[0 x i32]* @EA1, !"a(*:cv:si)"}
-// CHECK: !{{[0-9]+}} = !{[2 x i32]* @EA2, !"a(2:si)"}
-// CHECK: !{{[0-9]+}} = !{[0 x [2 x i32]]* @EA3, !"a(*:a(2:si))"}
-// CHECK: !{{[0-9]+}} = !{[3 x [2 x i32]]* @EA4, !"a(3:a(2:si))"}
-// CHECK: !{{[0-9]+}} = !{[2 x i32]* @GA1, !"a(2:cv:si)"}
-// CHECK: !{{[0-9]+}} = !{void ([2 x i32]*)* @arrayTypeVariable1,
+// CHECK: !{{[0-9]+}} = !{ptr @EA1, !"a(*:cv:si)"}
+// CHECK: !{{[0-9]+}} = !{ptr @EA2, !"a(2:si)"}
+// CHECK: !{{[0-9]+}} = !{ptr @EA3, !"a(*:a(2:si))"}
+// CHECK: !{{[0-9]+}} = !{ptr @EA4, !"a(3:a(2:si))"}
+// CHECK: !{{[0-9]+}} = !{ptr @GA1, !"a(2:cv:si)"}
+// CHECK: !{{[0-9]+}} = !{ptr @arrayTypeVariable1,
 // CHECK:   !"f{0}(p(a(2:si)))"}
-// CHECK: !{{[0-9]+}} = !{void (void ([2 x i32]*)*)* @arrayTypeVariable2,
+// CHECK: !{{[0-9]+}} = !{ptr @arrayTypeVariable2,
 // CHECK:   !"f{0}(p(f{0}(p(a(2:si)"}
-// CHECK: !{{[0-9]+}} = !{[3 x [2 x i32]]* @GA2, !"a(3:a(2:si))"}
+// CHECK: !{{[0-9]+}} = !{ptr @GA2, !"a(3:a(2:si))"}
 extern int GA2[3][2];
 extern const volatile int EA1[];
 extern int EA2[2];
@@ -108,16 +107,16 @@
 
 
 // test StructureType
-// CHECK: !{{[0-9]+}} = !{void (%struct.S1*)* @structureType1,
+// CHECK: !{{[0-9]+}} = !{ptr @structureType1,
 // CHECK:   !"f{0}(s(S1){m(ps2){p(s(S2){m(ps3){p(s(S3){m(s1){s(S1){}}})}})}})"}
-// CHECK: !{{[0-9]+}} = !{void (%struct.S2*)* @structureType2,
+// CHECK: !{{[0-9]+}} = !{ptr @structureType2,
 // CHECK:   !"f{0}(s(S2){m(ps3){p(s(S3){m(s1){s(S1){m(ps2){p(s(S2){}))}})"}
-// CHECK: !{{[0-9]+}} = !{void (%struct.S3*)* @structureType3,
+// CHECK: !{{[0-9]+}} = !{ptr @structureType3,
 // CHECK:   !"f{0}(s(S3){m(s1){s(S1){m(ps2){p(s(S2){m(ps3){p(s(S3){})}}))"}
-// CHECK: !{{[0-9]+}} = !{void (%struct.S4*)* @structureType4,
+// CHECK: !{{[0-9]+}} = !{ptr @structureType4,
 // CHECK:   !"f{0}(s(S4){m(s1){s(S1){m(ps2){p(s(S2){m(ps3){p(s(S3)

[PATCH] D144195: [XCore] Adapt Clang tests to opaque pointers.

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144195

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


[PATCH] D144196: [C2x] Remove the ATOMIC_VAR_INIT macro from stdatomic.h

2023-02-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: clang-language-wg, jyknight, libc++.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This implements WG14 N2886 
(https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2886.htm) which removed the 
macro entirely. (NB the macro was deprecated in C17.) As the paper is not 
particularly clear on what alternative was picked, here are my notes from the 
May 2022 meeting:

Does WG14 wish to adopt variant 1, change 3.2, 3.3, and 3.4 from N2886 into 
C23? 14/2/2 (consensus).
Does WG14 want to exchange Variant 1 with Variant 2 in N2886 in C23? 9/3/6 
(consensus).
(There was no sentiment in the room for either Variant 3 or Variant 4 so those 
were not voted on.)
Does WG14 want to integrate change 3.5 in N2886 into C23? 8/1/9 (consensus).
Does WG14 want to integrate change 3.6 in N2886 into C23? 2/5/9 (no consensus).

I've added the libc++ reviewers to ensure this doesn't negatively impact 
 and the clang-vendors group for early awareness about a potentially 
breaking change. Any code that is broken by the removal can remove the use of 
`ATOMIC_VAR_INIT` and use regular initialization instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144196

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Headers/stdatomic.h
  clang/test/C/C2x/n2886.c
  clang/www/c_status.html


Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -1131,7 +1131,7 @@
 
   Remove ATOMIC_VAR_INIT v2
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2886.htm";>N2886
-  No
+  Clang 17
 
 
   Require exact-width integer type interfaces v2
Index: clang/test/C/C2x/n2886.c
===
--- /dev/null
+++ clang/test/C/C2x/n2886.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify=okay -std=c11 -ffreestanding %s
+// RUN: %clang_cc1 -verify -std=c17 -ffreestanding %s
+// RUN: %clang_cc1 -verify -std=c2x -ffreestanding %s
+
+/* WG14 N2886: yes
+ * Remove ATOMIC_VAR_INIT v2
+ */
+
+/* okay-no-diagnostics */
+#include 
+
+_Atomic int a = ATOMIC_VAR_INIT(0); /* #diag */
+#if __STDC_VERSION__ <= 201710L
+/* expected-warning@#diag {{macro 'ATOMIC_VAR_INIT' has been marked as 
deprecated}}
+   expected-note@stdatomic.h:* {{macro marked 'deprecated' here}}
+*/
+#else
+/* expected-error@#diag {{use of undeclared identifier 'ATOMIC_VAR_INIT'}} */
+#endif
+
Index: clang/lib/Headers/stdatomic.h
===
--- clang/lib/Headers/stdatomic.h
+++ clang/lib/Headers/stdatomic.h
@@ -45,9 +45,16 @@
 #define ATOMIC_POINTER_LOCK_FREE__CLANG_ATOMIC_POINTER_LOCK_FREE
 
 /* 7.17.2 Initialization */
-
+/* FIXME: This is using the placeholder dates Clang produces for these macros
+   in C2x mode; switch to the correct values once they've been published. */
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ < 202000L) ||   
\
+defined(__cplusplus)
+/* ATOMIC_VAR_INIT was removed in C2x, but still remains in C++2b. */
 #define ATOMIC_VAR_INIT(value) (value)
-#if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201710L) || 
\
+#endif
+
+#if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201710L &&  
\
+  __STDC_VERSION__ < 202000L) ||   
\
  (defined(__cplusplus) && __cplusplus >= 202002L)) &&  
\
 !defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS)
 /* ATOMIC_VAR_INIT was deprecated in C17 and C++20. */
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -77,6 +77,9 @@
 - Implemented the ``unreachable`` macro in freestanding  for
   `WG14 N2826 `_
 
+- Removed the ``ATOMIC_VAR_INIT`` macro in C2x and later standards modes, which
+  implements `WG14 N2886 
`_
+
 Non-comprehensive list of changes in this release
 -
 - Clang now saves the address of ABI-indirect function parameters on the stack,


Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -1131,7 +1131,7 @@
 
   Remove ATOMIC_VAR_INIT v2
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2886.htm";>N2886
-  No
+  Clang 17
 
 
   Require exact-width integer type interfaces v2
Index: clang/test/C/C2x/n2886.c
===
--- /dev/null
+++ clang/test/C/C2x/n2886.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify=okay

[clang] 0871337 - [XCore] Adapt Clang tests to opaque pointers.

2023-02-16 Thread Nigel Perks via cfe-commits

Author: Nigel Perks
Date: 2023-02-16T16:32:29Z
New Revision: 0871337d97f71cac2dbc9cce33c0ecca3c5e5f9c

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

LOG: [XCore] Adapt Clang tests to opaque pointers.

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

Added: 


Modified: 
clang/test/CodeGen/xcore-abi.c
clang/test/CodeGen/xcore-stringtype.c

Removed: 




diff  --git a/clang/test/CodeGen/xcore-abi.c b/clang/test/CodeGen/xcore-abi.c
index 28fdae57de72..4dd0f221533b 100644
--- a/clang/test/CodeGen/xcore-abi.c
+++ b/clang/test/CodeGen/xcore-abi.c
@@ -1,12 +1,12 @@
 // REQUIRES: xcore-registered-target
-// RUN: %clang_cc1 -no-opaque-pointers -triple xcore -verify %s
+// RUN: %clang_cc1 -triple xcore -verify %s
 _Static_assert(sizeof(long long) == 8, "sizeof long long is wrong");
 _Static_assert(_Alignof(long long) == 4, "alignof long long is wrong");
 
 _Static_assert(sizeof(double) == 8, "sizeof double is wrong");
 _Static_assert(_Alignof(double) == 4, "alignof double is wrong");
 
-// RUN: %clang_cc1 -no-opaque-pointers -triple xcore-unknown-unknown 
-fno-signed-char -fno-common -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple xcore-unknown-unknown -fno-signed-char -fno-common 
-emit-llvm -o - %s | FileCheck %s
 
 // CHECK: target triple = "xcore-unknown-unknown"
 
@@ -25,91 +25,77 @@ void testva (int n, ...) {
   // CHECK-LABEL: testva
   va_list ap;
   va_start(ap,n);
-  // CHECK: [[AP:%[a-z0-9]+]] = alloca i8*, align 4
-  // CHECK: [[AP1:%[a-z0-9]+]] = bitcast i8** [[AP]] to i8*
-  // CHECK: call void @llvm.va_start(i8* [[AP1]])
+  // CHECK: [[AP:%[a-z0-9]+]] = alloca ptr, align 4
+  // CHECK: [[V5:%[a-z0-9]+]] = alloca %struct.x, align 4
+  // CHECK: [[TMP:%[a-z0-9]+]] = alloca [4 x i32], align 4
+  // CHECK: call void @llvm.va_start(ptr [[AP]])
 
   char* v1 = va_arg (ap, char*);
   f(v1);
-  // CHECK: [[I:%[a-z0-9]+]] = load i8*, i8** [[AP]]
-  // CHECK: [[P:%[a-z0-9]+]] = bitcast i8* [[I]] to i8**
-  // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, i8* [[I]], i32 4
-  // CHECK: store i8* [[IN]], i8** [[AP]]
-  // CHECK: [[V1:%[a-z0-9]+]] = load i8*, i8** [[P]]
-  // CHECK: store i8* [[V1]], i8** [[V:%[a-z0-9]+]], align 4
-  // CHECK: [[V2:%[a-z0-9]+]] = load i8*, i8** [[V]], align 4
-  // CHECK: call void @f(i8* noundef [[V2]])
+  // CHECK: [[I:%[a-z0-9]+]] = load ptr, ptr [[AP]]
+  // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, ptr [[I]], i32 4
+  // CHECK: store ptr [[IN]], ptr [[AP]]
+  // CHECK: [[V1:%[a-z0-9]+]] = load ptr, ptr [[I]]
+  // CHECK: store ptr [[V1]], ptr [[V:%[a-z0-9]+]], align 4
+  // CHECK: [[V2:%[a-z0-9]+]] = load ptr, ptr [[V]], align 4
+  // CHECK: call void @f(ptr noundef [[V2]])
 
   char v2 = va_arg (ap, char); // expected-warning{{second argument to 
'va_arg' is of promotable type 'char'}}
   f(&v2);
-  // CHECK: [[I:%[a-z0-9]+]] = load i8*, i8** [[AP]]
-  // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, i8* [[I]], i32 4
-  // CHECK: store i8* [[IN]], i8** [[AP]]
-  // CHECK: [[V1:%[a-z0-9]+]] = load i8, i8* [[I]]
-  // CHECK: store i8 [[V1]], i8* [[V:%[a-z0-9]+]], align 1
-  // CHECK: call void @f(i8* noundef [[V]])
+  // CHECK: [[I:%[a-z0-9]+]] = load ptr, ptr [[AP]]
+  // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, ptr [[I]], i32 4
+  // CHECK: store ptr [[IN]], ptr [[AP]]
+  // CHECK: [[V1:%[a-z0-9]+]] = load i8, ptr [[I]]
+  // CHECK: store i8 [[V1]], ptr [[V:%[a-z0-9]+]], align 1
+  // CHECK: call void @f(ptr noundef [[V]])
 
   int v3 = va_arg (ap, int);
   f(&v3);
-  // CHECK: [[I:%[a-z0-9]+]] = load i8*, i8** [[AP]]
-  // CHECK: [[P:%[a-z0-9]+]] = bitcast i8* [[I]] to i32*
-  // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, i8* [[I]], i32 4
-  // CHECK: store i8* [[IN]], i8** [[AP]]
-  // CHECK: [[V1:%[a-z0-9]+]] = load i32, i32* [[P]]
-  // CHECK: store i32 [[V1]], i32* [[V:%[a-z0-9]+]], align 4
-  // CHECK: [[V2:%[a-z0-9]+]] = bitcast i32* [[V]] to i8*
-  // CHECK: call void @f(i8* noundef [[V2]])
+  // CHECK: [[I:%[a-z0-9]+]] = load ptr, ptr [[AP]]
+  // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, ptr [[I]], i32 4
+  // CHECK: store ptr [[IN]], ptr [[AP]]
+  // CHECK: [[V1:%[a-z0-9]+]] = load i32, ptr [[I]]
+  // CHECK: store i32 [[V1]], ptr [[V:%[a-z0-9]+]], align 4
+  // CHECK: call void @f(ptr noundef [[V]])
 
   long long int v4 = va_arg (ap, long long int);
   f(&v4);
-  // CHECK: [[I:%[a-z0-9]+]] = load i8*, i8** [[AP]]
-  // CHECK: [[P:%[a-z0-9]+]] = bitcast i8* [[I]] to i64*
-  // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, i8* [[I]], i32 8
-  // CHECK: store i8* [[IN]], i8** [[AP]]
-  // CHECK: [[V1:%[a-z0-9]+]] = load i64, i64* [[P]]
-  // CHECK: store i64 [[V1]], i64* [[V:%[a-z0-9]+]], align 4
-  // CHECK:[[V2:%[a-z0-9]+]] = bitcast i6

[PATCH] D144195: [XCore] Adapt Clang tests to opaque pointers.

2023-02-16 Thread Nigel Perks via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0871337d97f7: [XCore] Adapt Clang tests to opaque pointers. 
(authored by nigelp-xmos).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144195

Files:
  clang/test/CodeGen/xcore-abi.c
  clang/test/CodeGen/xcore-stringtype.c

Index: clang/test/CodeGen/xcore-stringtype.c
===
--- clang/test/CodeGen/xcore-stringtype.c
+++ clang/test/CodeGen/xcore-stringtype.c
@@ -1,5 +1,5 @@
 // REQUIRES: xcore-registered-target
-// RUN: %clang_cc1 -no-opaque-pointers -triple xcore-unknown-unknown -fno-signed-char -fno-common -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple xcore-unknown-unknown -fno-signed-char -fno-common -emit-llvm -o - %s | FileCheck %s
 
 // CHECK: target triple = "xcore-unknown-unknown"
 
@@ -23,8 +23,7 @@
 
 
 // test BuiltinType
-// CHECK: !{{[0-9]+}} = !{void (i1, i8, i8, i8, i16, i16, i16, i32, i32, i32,
-// CHECK:  i32, i32, i32, i64, i64, i64, float, double, double)*
+// CHECK: !{{[0-9]+}} = !{ptr
 // CHECK:  @builtinType, !"f{0}(b,uc,uc,sc,ss,us,ss,si,ui,si,sl,
 // CHECK:  ul,sl,sll,ull,sll,ft,d,ld)"}
 void builtinType(_Bool B, char C, unsigned char UC, signed char SC, short S,
@@ -36,14 +35,14 @@
 
 
 // test FunctionType & Qualifiers
-// CHECK: !{{[0-9]+}} = !{void ()* @gI, !"f{0}()"}
-// CHECK: !{{[0-9]+}} = !{void (...)* @eI, !"f{0}()"}
-// CHECK: !{{[0-9]+}} = !{void ()* @gV, !"f{0}(0)"}
-// CHECK: !{{[0-9]+}} = !{void ()* @eV, !"f{0}(0)"}
-// CHECK: !{{[0-9]+}} = !{void (i32, ...)* @gVA, !"f{0}(si,va)"}
-// CHECK: !{{[0-9]+}} = !{void (i32, ...)* @eVA, !"f{0}(si,va)"}
-// CHECK: !{{[0-9]+}} = !{i32* (i32*)* @gQ, !"f{crv:p(cv:si)}(p(cv:si))"}
-// CHECK: !{{[0-9]+}} = !{i32* (i32*)* @eQ, !"f{crv:p(cv:si)}(p(cv:si))"}
+// CHECK: !{{[0-9]+}} = !{ptr @gI, !"f{0}()"}
+// CHECK: !{{[0-9]+}} = !{ptr @eI, !"f{0}()"}
+// CHECK: !{{[0-9]+}} = !{ptr @gV, !"f{0}(0)"}
+// CHECK: !{{[0-9]+}} = !{ptr @eV, !"f{0}(0)"}
+// CHECK: !{{[0-9]+}} = !{ptr @gVA, !"f{0}(si,va)"}
+// CHECK: !{{[0-9]+}} = !{ptr @eVA, !"f{0}(si,va)"}
+// CHECK: !{{[0-9]+}} = !{ptr @gQ, !"f{crv:p(cv:si)}(p(cv:si))"}
+// CHECK: !{{[0-9]+}} = !{ptr @eQ, !"f{crv:p(cv:si)}(p(cv:si))"}
 extern void eI();
 void gI() {eI();};
 extern void eV(void);
@@ -57,10 +56,10 @@
 
 
 // test PointerType
-// CHECK: !{{[0-9]+}} = !{i32* (i32*, i32* (i32*)*)*
+// CHECK: !{{[0-9]+}} = !{ptr
 // CHECK:   @pointerType, !"f{p(si)}(p(si),p(f{p(si)}(p(si"}
-// CHECK: !{{[0-9]+}} = !{i32** @EP, !"p(si)"}
-// CHECK: !{{[0-9]+}} = !{i32** @GP, !"p(si)"}
+// CHECK: !{{[0-9]+}} = !{ptr @EP, !"p(si)"}
+// CHECK: !{{[0-9]+}} = !{ptr @GP, !"p(si)"}
 extern int* EP;
 int* GP;
 int* pointerType(int *I, int * (*FP)(int *)) {
@@ -68,19 +67,19 @@
 }
 
 // test ArrayType
-// CHECK: !{{[0-9]+}} = !{[2 x i32]* (i32*, i32*, [2 x i32]*, [2 x i32]*, i32*)*
+// CHECK: !{{[0-9]+}} = !{ptr
 // CHECK:   @arrayType, !"f{p(a(2:si))}(p(si),p(cv:si),p(a(2:si)),
 // CHECK:   p(a(2:si)),p(si))"}
-// CHECK: !{{[0-9]+}} = !{[0 x i32]* @EA1, !"a(*:cv:si)"}
-// CHECK: !{{[0-9]+}} = !{[2 x i32]* @EA2, !"a(2:si)"}
-// CHECK: !{{[0-9]+}} = !{[0 x [2 x i32]]* @EA3, !"a(*:a(2:si))"}
-// CHECK: !{{[0-9]+}} = !{[3 x [2 x i32]]* @EA4, !"a(3:a(2:si))"}
-// CHECK: !{{[0-9]+}} = !{[2 x i32]* @GA1, !"a(2:cv:si)"}
-// CHECK: !{{[0-9]+}} = !{void ([2 x i32]*)* @arrayTypeVariable1,
+// CHECK: !{{[0-9]+}} = !{ptr @EA1, !"a(*:cv:si)"}
+// CHECK: !{{[0-9]+}} = !{ptr @EA2, !"a(2:si)"}
+// CHECK: !{{[0-9]+}} = !{ptr @EA3, !"a(*:a(2:si))"}
+// CHECK: !{{[0-9]+}} = !{ptr @EA4, !"a(3:a(2:si))"}
+// CHECK: !{{[0-9]+}} = !{ptr @GA1, !"a(2:cv:si)"}
+// CHECK: !{{[0-9]+}} = !{ptr @arrayTypeVariable1,
 // CHECK:   !"f{0}(p(a(2:si)))"}
-// CHECK: !{{[0-9]+}} = !{void (void ([2 x i32]*)*)* @arrayTypeVariable2,
+// CHECK: !{{[0-9]+}} = !{ptr @arrayTypeVariable2,
 // CHECK:   !"f{0}(p(f{0}(p(a(2:si)"}
-// CHECK: !{{[0-9]+}} = !{[3 x [2 x i32]]* @GA2, !"a(3:a(2:si))"}
+// CHECK: !{{[0-9]+}} = !{ptr @GA2, !"a(3:a(2:si))"}
 extern int GA2[3][2];
 extern const volatile int EA1[];
 extern int EA2[2];
@@ -108,16 +107,16 @@
 
 
 // test StructureType
-// CHECK: !{{[0-9]+}} = !{void (%struct.S1*)* @structureType1,
+// CHECK: !{{[0-9]+}} = !{ptr @structureType1,
 // CHECK:   !"f{0}(s(S1){m(ps2){p(s(S2){m(ps3){p(s(S3){m(s1){s(S1){}}})}})}})"}
-// CHECK: !{{[0-9]+}} = !{void (%struct.S2*)* @structureType2,
+// CHECK: !{{[0-9]+}} = !{ptr @structureType2,
 // CHECK:   !"f{0}(s(S2){m(ps3){p(s(S3){m(s1){s(S1){m(ps2){p(s(S2){}))}})"}
-// CHECK: !{{[0-9]+}} = !{void (%struct.S3*)* @structureType3,
+// CHECK: !{{[0-9]+}} = !{ptr @structureType3,
 // CHECK:   !"f{0}(s(S3){m(s1){s(S1){m(ps2){p(s(S2){m(ps3){p(s(S3){})}}))"}
-// CHECK: !{{[0-9]+}} = !{void (%struct.S4*)* @structureType

[PATCH] D143436: [clangd] Apply standard adaptors to CDBs pushed from LSP

2023-02-16 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 498038.
DmitryPolukhin added a comment.

Move standard adaptors to CommandMangler


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143436

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/CompileCommands.h
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/test/did-change-configuration-params.test
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
  clang/include/clang/Tooling/Tooling.h
  clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
  clang/lib/Tooling/Tooling.cpp

Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -43,6 +43,7 @@
 #include "llvm/Option/OptTable.h"
 #include "llvm/Option/Option.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
@@ -299,6 +300,31 @@
   }
 }
 
+void addExpandedResponseFiles(std::vector &CommandLine,
+  llvm::StringRef WorkingDir,
+  llvm::cl::TokenizerCallback Tokenizer,
+  llvm::vfs::FileSystem &FS) {
+  bool SeenRSPFile = false;
+  llvm::SmallVector Argv;
+  Argv.reserve(CommandLine.size());
+  for (auto &Arg : CommandLine) {
+Argv.push_back(Arg.c_str());
+if (!Arg.empty())
+  SeenRSPFile |= Arg.front() == '@';
+  }
+  if (!SeenRSPFile)
+return;
+  llvm::BumpPtrAllocator Alloc;
+  llvm::cl::ExpansionContext ECtx(Alloc, Tokenizer);
+  llvm::Error Err =
+  ECtx.setVFS(&FS).setCurrentDir(WorkingDir).expandResponseFiles(Argv);
+  if (Err)
+llvm::errs() << Err;
+  // Don't assign directly, Argv aliases CommandLine.
+  std::vector ExpandedArgv(Argv.begin(), Argv.end());
+  CommandLine = std::move(ExpandedArgv);
+}
+
 } // namespace tooling
 } // namespace clang
 
@@ -684,7 +710,7 @@
 
   if (!Invocation.run())
 return nullptr;
- 
+
   assert(ASTs.size() == 1);
   return std::move(ASTs[0]);
 }
Index: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
===
--- clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
+++ clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang/Tooling/CompilationDatabase.h"
+#include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ConvertUTF.h"
@@ -48,28 +49,9 @@
 
 private:
   std::vector expand(std::vector Cmds) const {
-for (auto &Cmd : Cmds) {
-  bool SeenRSPFile = false;
-  llvm::SmallVector Argv;
-  Argv.reserve(Cmd.CommandLine.size());
-  for (auto &Arg : Cmd.CommandLine) {
-Argv.push_back(Arg.c_str());
-if (!Arg.empty())
-  SeenRSPFile |= Arg.front() == '@';
-  }
-  if (!SeenRSPFile)
-continue;
-  llvm::BumpPtrAllocator Alloc;
-  llvm::cl::ExpansionContext ECtx(Alloc, Tokenizer);
-  llvm::Error Err = ECtx.setVFS(FS.get())
-.setCurrentDir(Cmd.Directory)
-.expandResponseFiles(Argv);
-  if (Err)
-llvm::errs() << Err;
-  // Don't assign directly, Argv aliases CommandLine.
-  std::vector ExpandedArgv(Argv.begin(), Argv.end());
-  Cmd.CommandLine = std::move(ExpandedArgv);
-}
+for (auto &Cmd : Cmds)
+  tooling::addExpandedResponseFiles(Cmd.CommandLine, Cmd.Directory,
+Tokenizer, *FS);
 return Cmds;
   }
 
Index: clang/include/clang/Tooling/Tooling.h
===
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -506,6 +506,12 @@
 void addTargetAndModeForProgramName(std::vector &CommandLine,
 StringRef InvokedAs);
 
+/// Helper function that expands response files in command line.
+void addExpandedResponseFiles(std::vector &CommandLine,
+  llvm::StringRef WorkingDir,
+  llvm::cl::TokenizerCallback Tokenizer,
+  llvm::vfs::FileSystem &FS);
+
 /// Creates a \c CompilerInvocation.
 CompilerInvocation *newInvocation(DiagnosticsEngine *Diagnostics,
   ArrayRef CC1Args,
Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -49,7 +49,7 @@
   Cmd.Comman

[PATCH] D143509: Move the BySpelling map to IncludeStructure.

2023-02-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Headers.h:167
+  // Spelling should include brackets or quotes, e.g. .
+  llvm::SmallVector
+  mainFileIncludesWithSpelling(llvm::StringRef Spelling) const {

we're still returning just the `HeaderID`, the suggestion was to return 
`llvm::SmallVector` so that applications can work with other 
information available in the `Inclusion`. we also won't have any requirements 
around include being resolved that way. the application should figure out what 
to do if `HeaderID` is missing.

also can you move this function body to source file instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143509

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


[PATCH] D142907: LangRef: Add "dynamic" option to "denormal-fp-math"

2023-02-16 Thread Joshua Cranmer via Phabricator via cfe-commits
jcranmer-intel added a comment.

Not entirely sure where the best place to effect this (I think somewhere in the 
clang driver code?), but on further reflection, it feels like strict fp-model 
in clang should set the denormal mode to dynamic.


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

https://reviews.llvm.org/D142907

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


[PATCH] D143436: [clangd] Apply standard adaptors to CDBs pushed from LSP

2023-02-16 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/CompileCommands.cpp:222
+  tooling::addExpandedResponseFiles(Cmd, Command.Directory, Tokenizer, *FS);
+  tooling::addTargetAndModeForProgramName(Cmd, Cmd.front());
   auto &OptTable = clang::driver::getDriverOptTable();

The target needs to be added **after** the call to `SystemIncludeExtractor` 
later in this function (this is what D138546 is trying to fix). The reason is 
that `SystemIncludeExtractor` includes any `--target` flag in the compiler 
driver being queried for system includes, which may be gcc, which does not 
support `--target`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143436

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


[PATCH] D143436: [clangd] Apply standard adaptors to CDBs pushed from LSP

2023-02-16 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/CompileCommands.cpp:222
+  tooling::addExpandedResponseFiles(Cmd, Command.Directory, Tokenizer, *FS);
+  tooling::addTargetAndModeForProgramName(Cmd, Cmd.front());
   auto &OptTable = clang::driver::getDriverOptTable();

nridge wrote:
> The target needs to be added **after** the call to `SystemIncludeExtractor` 
> later in this function (this is what D138546 is trying to fix). The reason is 
> that `SystemIncludeExtractor` includes any `--target` flag in the compiler 
> driver being queried for system includes, which may be gcc, which does not 
> support `--target`.
(I guess we could make that change separately in D138546, but if we're changing 
the place where the `--target` is added in this patch, I figure we might as 
well move it directly to the desired place.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143436

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


[PATCH] D142822: [clang] ASTImporter: Fix importing of va_list types and declarations

2023-02-16 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

With this fix the `std::__va_list` is created at initialization of Sema, 
previously it was not there. Function `CreateAArch64ABIBuiltinVaListDecl` 
(ASTContext.cpp) makes the namespace `std` and `__va_list` record. This change 
fixes the problem with `ASTImporter` probably because the __va_list record 
exists before start of AST import, this way it is found and added to 
`ASTImporterLookupTable` at initialization (the original problem was caused 
because `std::__va_list` is missing from `ASTImporterLookupTable`). But I was 
thinking of other ways to fix the problem. My old fix for the problem may still 
work without any test failures:

In D136886#3892261 , @balazske wrote:

> `ASTImporterLookupTable` do not contain an entry for `__va_list_tag`, I do 
> not know why it is missing. If it is added "manually" the crash disappears 
> (without fix in `VisitTypedefType`). Following code was used to add 
> VaListTagDecl:
>
>   ASTImporterLookupTable::ASTImporterLookupTable(TranslationUnitDecl &TU) {
> Builder B(*this);
> B.TraverseDecl(&TU);
> // Add __va_list_tag to the table, it is not visited by the builder.
> if (NamedDecl *D = 
> dyn_cast_or_null(TU.getASTContext().getVaListTagDecl()))
>   add(&TU, D);
>   }
>
> The problem probably existed before but did not have visible effect until the 
> new assertion was added.

It can happen (without any of the new fixes) that `std::__va_list` is created 
during the AST import process, it is created at first access. This can be the 
reason why it is missing from the lookup table: It is created implicitly by 
`ASTContext` code in the "to" context during import. To fix this problem, I 
think the above quoted code is a good solution: The va_list declaration is 
created at start of AST import (if it did not exist yet) (by the get function) 
and added to the lookup table. Probably it can be a problem that the va_list 
declaration and std namespace appears in a TU by just importing any code into 
it, but probably no tests will fail for this case. Another way to fix the 
problem is to add special handling of `std::__va_list` at least on the affected 
platforms to `ASTImporterLookupTable` but I did not check of this can be done. 
I do not like to change function `ASTImporter::VisitTypedefType` like in the 
very first fix of @vabridgers because it affects how every typedef is imported, 
and that can be incorrect. Probably some special handling of a record called 
`__va_list` at AST import can be a good fix too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142822

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


[PATCH] D142907: LangRef: Add "dynamic" option to "denormal-fp-math"

2023-02-16 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D142907#4132318 , @jcranmer-intel 
wrote:

> Not entirely sure where the best place to effect this (I think somewhere in 
> the clang driver code?), but on further reflection, it feels like strict 
> fp-model in clang should set the denormal mode to dynamic.

I was thinking of changing the default in general to dynamic. I was going to at 
least change the strictfp default in a follow up


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

https://reviews.llvm.org/D142907

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


[PATCH] D144120: [HLSL] add log library functions

2023-02-16 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 updated this revision to Diff 498051.
bob80905 added a comment.

- add newline


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144120

Files:
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/test/CodeGenHLSL/builtins/log.hlsl
  clang/test/CodeGenHLSL/builtins/log10.hlsl
  clang/test/CodeGenHLSL/builtins/log2.hlsl

Index: clang/test/CodeGenHLSL/builtins/log2.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/log2.hlsl
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
+
+// CHECK: define noundef half @
+// CHECK: call half @llvm.log2.f16(
+// NO_HALF: define noundef float @"?test_log2_half@@YA$halff@$halff@@Z"(
+// NO_HALF: call float @llvm.log2.f32(
+half test_log2_half ( half p0 ) {
+  return log2 ( p0 );
+}
+// CHECK: define noundef <2 x half> @
+// CHECK: call <2 x half> @llvm.log2.v2f16
+// NO_HALF: define noundef <2 x float> @"?test_log2_float2@@YAT?$__vector@M$01@__clang@@T12@@Z"(
+// NO_HALF: call <2 x float> @llvm.log2.v2f32(
+half2 test_log2_half2 ( half2 p0 ) {
+  return log2 ( p0 );
+}
+// CHECK: define noundef <3 x half> @
+// CHECK: call <3 x half> @llvm.log2.v3f16
+// NO_HALF: define noundef <3 x float> @"?test_log2_float3@@YAT?$__vector@M$02@__clang@@T12@@Z"(
+// NO_HALF: call <3 x float> @llvm.log2.v3f32(
+half3 test_log2_half3 ( half3 p0 ) {
+  return log2 ( p0 );
+}
+// CHECK: define noundef <4 x half> @
+// CHECK: call <4 x half> @llvm.log2.v4f16
+// NO_HALF: define noundef <4 x float> @"?test_log2_float4@@YAT?$__vector@M$03@__clang@@T12@@Z"(
+// NO_HALF: call <4 x float> @llvm.log2.v4f32(
+half4 test_log2_half4 ( half4 p0 ) {
+  return log2 ( p0 );
+}
+
+// CHECK: define noundef float @
+// CHECK: call float @llvm.log2.f32(
+float test_log2_float ( float p0 ) {
+  return log2 ( p0 );
+}
+// CHECK: define noundef <2 x float> @
+// CHECK: call <2 x float> @llvm.log2.v2f32
+float2 test_log2_float2 ( float2 p0 ) {
+  return log2 ( p0 );
+}
+// CHECK: define noundef <3 x float> @
+// CHECK: call <3 x float> @llvm.log2.v3f32
+float3 test_log2_float3 ( float3 p0 ) {
+  return log2 ( p0 );
+}
+// CHECK: define noundef <4 x float> @
+// CHECK: call <4 x float> @llvm.log2.v4f32
+float4 test_log2_float4 ( float4 p0 ) {
+  return log2 ( p0 );
+}
Index: clang/test/CodeGenHLSL/builtins/log10.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/log10.hlsl
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
+
+// CHECK: define noundef half @
+// CHECK: call half @llvm.log10.f16(
+// NO_HALF: define noundef float @"?test_log10_half@@YA$halff@$halff@@Z"(
+// NO_HALF: call float @llvm.log10.f32(
+half test_log10_half ( half p0 ) {
+  return log10 ( p0 );
+}
+// CHECK: define noundef <2 x half> @
+// CHECK: call <2 x half> @llvm.log10.v2f16
+// NO_HALF: define noundef <2 x float> @"?test_log10_float2@@YAT?$__vector@M$01@__clang@@T12@@Z"(
+// NO_HALF: call <2 x float> @llvm.log10.v2f32(
+half2 test_log10_half2 ( half2 p0 ) {
+  return log10 ( p0 );
+}
+// CHECK: define noundef <3 x half> @
+// CHECK: call <3 x half> @llvm.log10.v3f16
+// NO_HALF: define noundef <3 x float> @"?test_log10_float3@@YAT?$__vector@M$02@__clang@@T12@@Z"(
+// NO_HALF: call <3 x float> @llvm.log10.v3f32(
+half3 test_log10_half3 ( half3 p0 ) {
+  return log10 ( p0 );
+}
+// CHECK: define noundef <4 x half> @
+// CHECK: call <4 x half> @llvm.log10.v4f16
+// NO_HALF: define noundef <4 x float> @"?test_log10_float4@@YAT?$__vector@M$03@__clang@@T12@@Z"(
+// NO_HALF: call <4 x float> @llvm.log10.v4f32(
+half4 test_log10_half4 ( half4 p0 ) {
+  return log10 ( p0 );
+}
+
+// CHECK: define noundef float @
+// CHECK: call float @llvm.log10.f32(
+float test_log10_float ( float p0 ) {
+  return log10 ( p0 );
+}
+// CHECK: define noundef <2 x float> @
+// CHECK: call <2 x float> @llvm.log10.v2f32
+float2 test_log10_float2 ( float2 p0 ) {
+  return log10 ( p0 );
+}
+// CHECK: define noundef <3 x float> @
+// CHECK: call <3 x float> @llvm.log10.v3f32
+float3 test_log10_float3 ( float3 p0 ) {
+  return log10 ( p0

[PATCH] D144181: [clang][DebugInfo] Add abi-tags on constructors/destructors as LLVM annotations

2023-02-16 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Size-wise this looks like an acceptable increase. If we created a new 
DW_AT_LLVM_abi_tag, we could save an extra 4 bytes (assuming DW_FORM_strp) per 
DIE. That might be worth it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144181

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


[clang] f842b7a - [HLSL] add log library functions

2023-02-16 Thread Joshua Batista via cfe-commits

Author: Joshua Batista
Date: 2023-02-16T09:50:12-08:00
New Revision: f842b7a6b8f40d817d6d43143e09521bd586a756

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

LOG: [HLSL] add log library functions

This change exposes the log library functions for HLSL,excluding long, int, and 
long long doubles. The log functions are supported for all scalar, vector, and 
matrix types.
Long and long long double support is missing in this patch because those types
don't exist in HLSL. Int is missing because the log functions only work on 
floating type arguments.

The full documentation of the HLSL log functions are available here:
https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-log
https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-log2
https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-log10

Reviewed By: python3kgae

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

Added: 
clang/test/CodeGenHLSL/builtins/log.hlsl
clang/test/CodeGenHLSL/builtins/log10.hlsl
clang/test/CodeGenHLSL/builtins/log2.hlsl

Modified: 
clang/lib/Headers/hlsl/hlsl_intrinsics.h

Removed: 




diff  --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index d811a28a43350..570552367215b 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -219,5 +219,94 @@ double3 trunc(double3);
 __attribute__((clang_builtin_alias(__builtin_elementwise_trunc)))
 double4 trunc(double4);
 
+// log builtins
+#ifdef __HLSL_ENABLE_16_BIT
+__attribute__((clang_builtin_alias(__builtin_elementwise_log))) half log(half);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log)))
+half2 log(half2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log)))
+half3 log(half3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log)))
+half4 log(half4);
+#endif
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_log))) float
+log(float);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log)))
+float2 log(float2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log)))
+float3 log(float3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log)))
+float4 log(float4);
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_log))) double
+log(double);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log)))
+double2 log(double2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log)))
+double3 log(double3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log)))
+double4 log(double4);
+
+// log2 builtins
+#ifdef __HLSL_ENABLE_16_BIT
+__attribute__((clang_builtin_alias(__builtin_elementwise_log2)))
+half log2(half);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log2)))
+half2 log2(half2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log2)))
+half3 log2(half3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log2)))
+half4 log2(half4);
+#endif
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_log2))) float
+log2(float);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log2)))
+float2 log2(float2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log2)))
+float3 log2(float3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log2)))
+float4 log2(float4);
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_log2))) double
+log2(double);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log2)))
+double2 log2(double2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log2)))
+double3 log2(double3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log2)))
+double4 log2(double4);
+
+// log10 builtins
+#ifdef __HLSL_ENABLE_16_BIT
+__attribute__((clang_builtin_alias(__builtin_elementwise_log10)))
+half log10(half);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log10)))
+half2 log10(half2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log10)))
+half3 log10(half3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log10)))
+half4 log10(half4);
+#endif
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_log10))) float
+log10(float);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log10)))
+float2 log10(float2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log10)))
+float3 log10(float3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log10)))
+float4 log10(float4);
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_log10))) double
+log10(double);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log10)))
+double2 log10(double2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_log10)))
+double3 log10(

[PATCH] D144120: [HLSL] add log library functions

2023-02-16 Thread Joshua Batista via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf842b7a6b8f4: [HLSL] add log library functions (authored by 
bob80905).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144120

Files:
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/test/CodeGenHLSL/builtins/log.hlsl
  clang/test/CodeGenHLSL/builtins/log10.hlsl
  clang/test/CodeGenHLSL/builtins/log2.hlsl

Index: clang/test/CodeGenHLSL/builtins/log2.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/log2.hlsl
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
+
+// CHECK: define noundef half @
+// CHECK: call half @llvm.log2.f16(
+// NO_HALF: define noundef float @"?test_log2_half@@YA$halff@$halff@@Z"(
+// NO_HALF: call float @llvm.log2.f32(
+half test_log2_half ( half p0 ) {
+  return log2 ( p0 );
+}
+// CHECK: define noundef <2 x half> @
+// CHECK: call <2 x half> @llvm.log2.v2f16
+// NO_HALF: define noundef <2 x float> @"?test_log2_float2@@YAT?$__vector@M$01@__clang@@T12@@Z"(
+// NO_HALF: call <2 x float> @llvm.log2.v2f32(
+half2 test_log2_half2 ( half2 p0 ) {
+  return log2 ( p0 );
+}
+// CHECK: define noundef <3 x half> @
+// CHECK: call <3 x half> @llvm.log2.v3f16
+// NO_HALF: define noundef <3 x float> @"?test_log2_float3@@YAT?$__vector@M$02@__clang@@T12@@Z"(
+// NO_HALF: call <3 x float> @llvm.log2.v3f32(
+half3 test_log2_half3 ( half3 p0 ) {
+  return log2 ( p0 );
+}
+// CHECK: define noundef <4 x half> @
+// CHECK: call <4 x half> @llvm.log2.v4f16
+// NO_HALF: define noundef <4 x float> @"?test_log2_float4@@YAT?$__vector@M$03@__clang@@T12@@Z"(
+// NO_HALF: call <4 x float> @llvm.log2.v4f32(
+half4 test_log2_half4 ( half4 p0 ) {
+  return log2 ( p0 );
+}
+
+// CHECK: define noundef float @
+// CHECK: call float @llvm.log2.f32(
+float test_log2_float ( float p0 ) {
+  return log2 ( p0 );
+}
+// CHECK: define noundef <2 x float> @
+// CHECK: call <2 x float> @llvm.log2.v2f32
+float2 test_log2_float2 ( float2 p0 ) {
+  return log2 ( p0 );
+}
+// CHECK: define noundef <3 x float> @
+// CHECK: call <3 x float> @llvm.log2.v3f32
+float3 test_log2_float3 ( float3 p0 ) {
+  return log2 ( p0 );
+}
+// CHECK: define noundef <4 x float> @
+// CHECK: call <4 x float> @llvm.log2.v4f32
+float4 test_log2_float4 ( float4 p0 ) {
+  return log2 ( p0 );
+}
Index: clang/test/CodeGenHLSL/builtins/log10.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/log10.hlsl
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
+
+// CHECK: define noundef half @
+// CHECK: call half @llvm.log10.f16(
+// NO_HALF: define noundef float @"?test_log10_half@@YA$halff@$halff@@Z"(
+// NO_HALF: call float @llvm.log10.f32(
+half test_log10_half ( half p0 ) {
+  return log10 ( p0 );
+}
+// CHECK: define noundef <2 x half> @
+// CHECK: call <2 x half> @llvm.log10.v2f16
+// NO_HALF: define noundef <2 x float> @"?test_log10_float2@@YAT?$__vector@M$01@__clang@@T12@@Z"(
+// NO_HALF: call <2 x float> @llvm.log10.v2f32(
+half2 test_log10_half2 ( half2 p0 ) {
+  return log10 ( p0 );
+}
+// CHECK: define noundef <3 x half> @
+// CHECK: call <3 x half> @llvm.log10.v3f16
+// NO_HALF: define noundef <3 x float> @"?test_log10_float3@@YAT?$__vector@M$02@__clang@@T12@@Z"(
+// NO_HALF: call <3 x float> @llvm.log10.v3f32(
+half3 test_log10_half3 ( half3 p0 ) {
+  return log10 ( p0 );
+}
+// CHECK: define noundef <4 x half> @
+// CHECK: call <4 x half> @llvm.log10.v4f16
+// NO_HALF: define noundef <4 x float> @"?test_log10_float4@@YAT?$__vector@M$03@__clang@@T12@@Z"(
+// NO_HALF: call <4 x float> @llvm.log10.v4f32(
+half4 test_log10_half4 ( half4 p0 ) {
+  return log10 ( p0 );
+}
+
+// CHECK: define noundef float @
+// CHECK: call float @llvm.log10.f32(
+float test_log10_float ( float p0 ) {
+  return log10 ( p0 );
+}
+// CHECK: define noundef <2 x float> @
+// CHECK: call <2 x float> @llvm.log10.v2f32
+float2 test_log10_float2 ( float2 p0 ) {
+  return log10 ( p0 );
+}
+// CHECK: defin

[PATCH] D142914: [MLIR][OpenMP] Added OMPIRBuilder support for Target Data directives.

2023-02-16 Thread Raghu via Phabricator via cfe-commits
raghavendhra accepted this revision.
raghavendhra added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142914

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


[PATCH] D141307: [WIP] Add -f[no-]loop-versioning option

2023-02-16 Thread Mats Petersson via Phabricator via cfe-commits
Leporacanthicus updated this revision to Diff 498065.
Leporacanthicus added a comment.

Rebased and updated help-message

Also using different type of template for the option


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141307

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/include/flang/Tools/CLOptions.inc
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90

Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -41,9 +41,11 @@
 ! HELP-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-NEXT: -flogical-abbreviations Enable logical abbreviations
+! HELP-NEXT: -floop-versioning  Create unit-strided versions of loops
 ! HELP-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
 ! HELP-NEXT: -fno-color-diagnostics  Disable colors in diagnostics
 ! HELP-NEXT: -fno-integrated-as  Disable the integrated assembler
+! HELP-NEXT: -fno-loop-versioning   Do not create unit-strided loops (default)
 ! HELP-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-NEXT: -fno-stack-arrays  Allocate array temporaries on the heap (default)
 ! HELP-NEXT: -fopenacc  Enable OpenACC
@@ -129,10 +131,12 @@
 ! HELP-FC1-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-FC1-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
+! HELP-FC1-NEXT: -floop-versioning  Create unit-strided versions of loops
 ! HELP-FC1-NEXT: -fno-analyzed-objects-for-unparse
 ! HELP-FC1-NEXT:Do not use the analyzed objects when unparsing
 ! HELP-FC1-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
 ! HELP-FC1-NEXT: -fno-debug-pass-manager Disables debug printing for the new pass manager
+! HELP-FC1-NEXT: -fno-loop-versioning   Do not create unit-strided loops (default)
 ! HELP-FC1-NEXT: -fno-reformat  Dump the cooked character stream in -E mode
 ! HELP-FC1-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-FC1-NEXT: -fno-stack-arrays  Allocate array temporaries on the heap (default)
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -43,9 +43,11 @@
 ! CHECK-NEXT:Enable support for generating executables (experimental)
 ! CHECK-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
+! CHECK-NEXT: -floop-versioning  Create unit-strided versions of loops
 ! CHECK-NEXT: -fno-automatic Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE
 ! CHECK-NEXT: -fno-color-diagnostics  Disable colors in diagnostics
 ! CHECK-NEXT: -fno-integrated-as Disable the integrated assembler
+! CHECK-NEXT: -fno-loop-versioning   Do not create unit-strided loops (default)
 ! CHECK-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! CHECK-NEXT: -fno-stack-arrays  Allocate array temporaries on the heap (default)
 ! CHECK-NEXT: -fopenacc  Enable OpenACC
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -545,7 +545,8 @@
   pm.enableVerifier(/*verifyPasses=*/true);
 
   // Create the pass pipeline
-  fir::createMLIRToLLVMPassPipeline(pm, level, opts.StackArrays);
+  fir::createMLIRToLLVMPassPipeline(pm, level, opts.StackArrays,
+opts.LoopVersioning);
   mlir::applyPassManagerCLOptions(pm);
 
   // run the pass manager
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -130,6 +130,10 @@
clang::driver::options::OPT_fno_stack_arrays, false)) {
 opts.StackArrays = 1;
   }
+  if (args.hasFlag(clang::driver::options::OPT_fl

[PATCH] D142907: LangRef: Add "dynamic" option to "denormal-fp-math"

2023-02-16 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

What's the plan for tying this to strictfp? Because I don't it should be tied 
to cases where we use the constrained intrinsics but the exceptions are ignored 
and the default rounding is in stated. Those instructions are supposed to 
behave the same as the non-constrained instructions. So keying off the presence 
of the strictfp attribute on the function definition, or the (equivalent) 
presence of constrained intrinsics, would be too simple.

I don't see an obvious connection between denormals and exception behavior, and 
the rounding mode has the same problem. It would be surprising if changing the 
rounding mode changed denormal handling or optimization even when the new 
rounding mode would have identical results. It would also be surprising if 
changing the rounding mode back to the default round-to-nearest changed how 
denormals are handled.

Would we get different denormal behavior with a clang flag vs using a #pragma 
at the top of a source file? That seems surprising as well.

In the abstract I can see lumping in denormal handing with the rest of the FP 
environment handling. But in the LLVM context I don't see how we can tie use of 
the constrained intrinsics to denormals.


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

https://reviews.llvm.org/D142907

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


[PATCH] D143670: Stop claiming we support [[carries_dependency]]

2023-02-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

In D143670#4116858 , @erichkeane 
wrote:

> The guidance from EWG this week and in the past was that we are always 
> required to 'parse and diagnose appertainment' of standard attributes, but 
> not to enable __has_cpp_attribute unless we actually 'do' something with it.  
> I intend/suggest we add a condition to the CXX tag of 'is supported' with 
> some sort of conditional for checking diagnostic and O level (or just 
> straight 'false' in this case).

I'm aware of EWG's guidance, and EWG (and WG21) are aware of Clang's position 
regarding conformance in this area. It's unfortunate that EWG didn't consider 
implementer feedback or sibling committee feedback to be sufficiently 
compelling, but at the end of the day, we are the implementers not EWG, and we 
need to do what's best for us. This implementation is conforming to what the 
standard says. We're obligated to issue a diagnostic for the situations you 
identified and we do -- "attribute ignored" is a diagnostic that conveys 
exactly what we intend it to convey. Maybe someday we will improve conformance 
in this area but it is explicitly not a priority given that we're still trying 
to work on C++20 features three years after that standard was released. I 
suspect we'll get around to this particular "issue" roughly never (given the 
work, risks, and benefits) which is why WG21 was told this was a burden for us 
and that we would be conforming in this manner.

To be clear about this change specifically -- this is a consistency change. Our 
existing policy has always been that we do not silently ignore attributes 
unless they're actively harmful to diagnose as being ignored. 
`[[carries_dependency]]` isn't even used in practice, so it does not fall into 
the "harmful to diagnose" category. To date, we've silently accepted it without 
any intention of implementing the performance improvements it suggests are 
possible, and that's against our usual policy. What's more, this makes our 
behavior more self-consistent -- we already do syntactic ignorability of other 
standard attributes, like `[[no_unique_address]]` on some targets.

As we saw when we switched our default mode to C++17, compile time overhead is 
only getting worse with every release of C++. We do not need to keep the 
(admittedly small) compile time overhead on every C++ compilation to check for 
requirements of an attribute we will then ignore entirely. "You're using this 
wrong but we do nothing with it" is user-hostile behavior for attributes which 
are inherently non-portable (even the standard ones). I don't expect this to 
have a measurable impact on compile time overhead in practice, but it's hard to 
argue that there's value in testing every function parameter of every function 
declaration to see if it perhaps is using `[[carries_dependency]]` wrong. 
However, for future attributes like `[[assume]]`, the expense of syntactic 
checking the argument expression is significant and nontrivial, and we should 
be self-consistent. (I expect we'll be one of the later C++ implementations to 
adopt that attribute given it cannot be *semantically* ignored due to potential 
for template instantiations, changing ABI, etc. We were bitten by WG21 adopting 
`[[no_unique_address]]` for C++20 and `[[assume]]` has already had at least one 
implementer push back on implementing it, so there's a very real chance we'll 
be in the same boat again.)

There's ample evidence that total ignorability is not unexpected behavior in 
practice, either -- the idiomatic way of using attributes is to use feature 
testing macros to provide various levels of fallback behavior. Note how the 
fallback clauses do not provide any syntactic checking for the attribute 
arguments and are defined in a way that semantic appertainment issues are 
silently ignored as well:

https://github.com/mozilla/gecko-dev/blob/master/third_party/highway/hwy/base.h#L159
https://github.com/pytorch/pytorch/blob/master/c10/util/Deprecated.h#L22
https://github.com/boostorg/config/blob/master/include/boost/config/detail/suffix.hpp#L701

Mozilla, pytorch, and boost are not doing anything unusual here and they are 
all examples of quite popular C++ projects; it seems to be rare that fallback 
code ever checks that the syntax of the argument is valid or that it’s being 
applied to the correct thing.

Given that these changes are conforming, make us more self-consistent with 
other C++ standard attributes we don't implement, and makes it less likely to 
introduce header incompatibilities with C (which has reaffirmed the need for 
syntactic ignorability of attribute for more than one of their implementations 
as well), I think we should move forward with these changes to 
`[[carries_dependency]]` regardless of EWG's guidance. We're following what 
we're obligated to follow for the standard requirements and WG21 is aware of 
this. Ef

[PATCH] D143953: [RISCV] Accept zicsr and zifencei command line options

2023-02-16 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

This was discussed at today's RISCV sync-up call.  We have a large conversion 
pending on the topic of isa compatibility checking, but there was a consensus 
that this was reasonable and could move forward.  I'm going to be landing this 
change in the near future.


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

https://reviews.llvm.org/D143953

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


[PATCH] D142609: [Clang] Fix -Wconstant-logical-operand when LHS is a constant

2023-02-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

I did kernel builds of x86_64 and aarch64 defconfigs. This found new instance:
https://github.com/ClangBuiltLinux/linux/issues/1806
which looks like something we can fix in the kernel sources.  Our CI will 
probably find more instances once this lands, but I'm happy with it.




Comment at: clang/lib/Sema/SemaExpr.cpp:13584
+// the other is a constant.
+void Sema::diagnoseLogicalInsteadOfBitwise(ExprResult &Op1, ExprResult &Op2,
SourceLocation Loc,

Every reference to Op1 and Op2 immediately calls `.get()` on it. That's 
annoying. How about `Sema::diagnoseLogicalInsteadOfBitwise` accepts `Expr*` (or 
whatever ExprResult::get returns), and we call `.get()` in the caller?



Comment at: clang/lib/Sema/SemaExpr.cpp:13588
+   bool EnumConstantInBoolContext) {
+  if (!EnumConstantInBoolContext && Op1.get()->getType()->isIntegerType() &&
+  !Op1.get()->getType()->isBooleanType() &&

This is the only use of `EnumConstantInBoolContext` in 
`Sema::diagnoseLogicalInsteadOfBitwise`. It's being used to elide the entirety 
of the method.  In that case, it seems wasteful to bother to pass it as a 
parameter.  Instead, I don't think `Sema::diagnoseLogicalInsteadOfBitwise` 
should be called if `EnumConstantInBoolContext` is `true`.

If you remove the parameter `EnumConstantInBoolContext` then...



Comment at: clang/lib/Sema/SemaExpr.cpp:13588
+   bool EnumConstantInBoolContext) {
+  if (!EnumConstantInBoolContext && Op1.get()->getType()->isIntegerType() &&
+  !Op1.get()->getType()->isBooleanType() &&

nickdesaulniers wrote:
> This is the only use of `EnumConstantInBoolContext` in 
> `Sema::diagnoseLogicalInsteadOfBitwise`. It's being used to elide the 
> entirety of the method.  In that case, it seems wasteful to bother to pass it 
> as a parameter.  Instead, I don't think 
> `Sema::diagnoseLogicalInsteadOfBitwise` should be called if 
> `EnumConstantInBoolContext` is `true`.
> 
> If you remove the parameter `EnumConstantInBoolContext` then...
Do you mind pulling the types into dedicated variables, then reusing them? I 
kind of hate seeing verbose OpX.get()->getType() so much in this method.

Type T1 = Op1.get()->getType();
Type T2 = Op2.get()->getType();

if (T1->isIntegerType() && !T1->isBooleanType() ...
  ...



Comment at: clang/lib/Sema/SemaExpr.cpp:13640-13648
+  if (EnumConstantInBoolContext)
+Diag(Loc, diag::warn_enum_constant_in_bool_context);
+
+  // Diagnose cases where the user write a logical and/or but probably meant a
+  // bitwise one.
+  diagnoseLogicalInsteadOfBitwise(LHS, RHS, Loc, Opc,
+  EnumConstantInBoolContext);

...this can become:

```
if (EnumConstantInBoolContext) {
  Diag(...
} else {
  diagnoseLogicalInsteadOfBitwise(...
  diagnoseLogicalInsteadOfBitwise(...
}
```
```
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index e61b9252901d..47cfd0884911 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -12569,8 +12569,7 @@ public:
   BinaryOperatorKind Opc);
   void diagnoseLogicalInsteadOfBitwise(ExprResult &Op1, ExprResult &Op2,
SourceLocation Loc,
-   BinaryOperatorKind Opc,
-   bool EnumConstantInBoolContext);
+   BinaryOperatorKind Opc);
   QualType CheckLogicalOperands( // C99 6.5.[13,14]
 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc,
 BinaryOperatorKind Opc);
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 7acf6f41625e..fa64b0cdbe94 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -13583,9 +13583,8 @@ inline QualType Sema::CheckBitwiseOperands(ExprResult 
&LHS, ExprResult &RHS,
 // the other is a constant.
 void Sema::diagnoseLogicalInsteadOfBitwise(ExprResult &Op1, ExprResult &Op2,
SourceLocation Loc,
-   BinaryOperatorKind Opc,
-   bool EnumConstantInBoolContext) {
-  if (!EnumConstantInBoolContext && Op1.get()->getType()->isIntegerType() &&
+   BinaryOperatorKind Opc) {
+  if (Op1.get()->getType()->isIntegerType() &&
   !Op1.get()->getType()->isBooleanType() &&
   Op2.get()->getType()->isIntegerType() && !Op2.get()->isValueDependent() 
&&
   // Don't warn in macros or template instantiations.
@@ -13639,13 +13638,12 @@ inline QualType Sema::CheckLogicalOperands(ExprResult 
&LHS, ExprResult &RHS,
 
   if (EnumConstantInBoolContext)
 Diag(Loc, diag::warn_enum_constant_in_bool_context);
-
-  // Diagnose

[PATCH] D142890: [clangd] Add config option for fast diagnostics mode

2023-02-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/unittests/PreambleTests.cpp:235
   MockFS FS;
-  auto TU = TestTU::withCode(Modified);
+  auto &TU = PreambleTU;
+  TU.Code = Modified.str();

now there's only one variable used for both - just rename it instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142890

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


[PATCH] D142584: [CodeGen] Add a boolean flag to `Address::getPointer` and `Lvalue::getPointer` that indicates whether the pointer is known not to be null

2023-02-16 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/Address.h:67
   return;
-// Currently the max supported alignment is much less than 1 << 63 and is
+// Currently the max supported alignment is much less than 1 << 32 and is
 // guaranteed to be a power of 2, so we can store the log of the alignment

ahatanak wrote:
> efriedma wrote:
> > ahatanak wrote:
> > > efriedma wrote:
> > > > This comment isn't right.  The max alignment is, as far as I can tell, 
> > > > 1<<32 exactly.  (But there's something weird going on with very large 
> > > > values... somehow `int a[1LL<<32] __attribute((aligned(1ULL<<32))) = 
> > > > {};` ignores the alignment.)
> > > The following function generated by tablegen (and a few others directly 
> > > or indirectly calling the function) returns a 32-bit int, but it should 
> > > be returning a 64-bit int.
> > > 
> > > https://github.com/llvm/llvm-project/blob/main/clang/utils/TableGen/ClangAttrEmitter.cpp#L532
> > Filed https://github.com/llvm/llvm-project/issues/60752 so we don't lose 
> > track of this.
> I just realized we can't reduce the number of bits used for alignment here as 
> we need 6 bits for alignment of `1 << 32`.
> 
> Should we allocate additional memory when `AlignLog` is either 31 or 32? If 
> the 5-bit alignment is equal to `0b1`, it would mean that there is an 
> out-of-line storage large enough to hold the alignment and any other extra 
> information that is needed. I think https://reviews.llvm.org/D117262#3267899 
> proposes a similar idea.
How much does `sizeof(Address)` actually matter, anyway?  If it's going to get 
that nasty to implement the packing, I'm not sure it's worth the effort to 
optimize.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142584

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


[PATCH] D144179: [Clang] Added functionality to provide config file name via env variable

2023-02-16 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Behaviors due to a new environment variable should be very careful. Why is this 
useful? If you want this, you can add a wrapper around `clang` to specify 
`--config=` by yourself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144179

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


[PATCH] D142907: LangRef: Add "dynamic" option to "denormal-fp-math"

2023-02-16 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D142907#4132543 , @kpn wrote:

> What's the plan for tying this to strictfp? Because I don't it should be tied 
> to cases where we use the constrained intrinsics but the exceptions are 
> ignored and the default rounding is in stated. Those instructions are 
> supposed to behave the same as the non-constrained instructions. So keying 
> off the presence of the strictfp attribute on the function definition, or the 
> (equivalent) presence of constrained intrinsics, would be too simple.

The denormal mode is exactly parallel to the rounding mode, we just don't have 
a mirrored field in the constrained intrinsic metadata operands. If we 
defaulted to using the dynamic mode if you were to use strictfp, everything 
would be OK. You just couldn't optimize based on knowledge of the denormal 
mode. I don't really think it's worth putting in the same optimization effort 
as the rounding mode.


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

https://reviews.llvm.org/D142907

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


[libunwind] 372820b - [libunwind][PowerPC] Fix saving/restoring VSX registers on LE systems

2023-02-16 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2023-02-16T13:37:58-05:00
New Revision: 372820bf571c8d32c8165cfc74b0439c7bb397f9

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

LOG: [libunwind][PowerPC] Fix saving/restoring VSX registers on LE systems

Currently, libunwind just uses stxvd2x/lxvd2x to save/restore
VSX registers respectively. This puts the registers in
doubleword-reversed order into memory on little endian systems.
If both the save and restore are done the same way, this
isn't a problem. However if the unwinder is just restoring
a callee-saved register, it will restore it in the wrong
order (since function prologues save them in the correct order).
This patch adds the necessary swaps before the saves and after
the restores.

Differential revision: https://reviews.llvm.org/D137599

Added: 
libcxxabi/test/vendor/ibm/vec_reg_restore-le.pass.cpp

Modified: 
libunwind/src/UnwindRegistersRestore.S
libunwind/src/UnwindRegistersSave.S

Removed: 




diff  --git a/libcxxabi/test/vendor/ibm/vec_reg_restore-le.pass.cpp 
b/libcxxabi/test/vendor/ibm/vec_reg_restore-le.pass.cpp
new file mode 100644
index 0..413d248a9886b
--- /dev/null
+++ b/libcxxabi/test/vendor/ibm/vec_reg_restore-le.pass.cpp
@@ -0,0 +1,90 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// Check that the PowerPC vector registers are restored properly during
+// unwinding.
+
+// REQUIRES: target=powerpc{{(64)?}}le-unknown-linux-gnu
+// UNSUPPORTED: no-exceptions
+
+// Callee-saved VSR's 62 and 63 (vr30, vr31 respectively) are set to 16 bytes
+// with values 1, 2 respectively in main. In order to ensure the two 
doublewords
+// in each register are 
diff erent, they are merged. Then they are reset to 16
+// bytes with values 9 and 12 respectively in a callee and an exception is
+// thrown. When catching an exception in main, the values in the two registers
+// need to be the original ones (including the correct doubleword order).
+
+#include 
+#include 
+
+int __attribute__((noinline)) test2(int i) {
+  if (i > 3)
+throw i;
+  srand(i);
+  return rand();
+}
+
+int __attribute__((noinline)) test(int i) {
+  // Clobber VS63 and VS62 in the function body.
+  // Set VS63 to 16 bytes each with value 9
+  asm volatile("vspltisb 31, 9" : : : "v31");
+
+  // Set VS62 to 16 bytes each with value 12
+  asm volatile("vspltisb 30, 12" : : : "v30");
+  return test2(i);
+}
+
+#define cmpVS63(vec, result)   
\
+  {
\
+vector unsigned char gbg;  
\
+asm volatile("vcmpequb. %[gbg], 31, %[veca];"  
\
+ "mfocrf %[res], 2;"   
\
+ "rlwinm %[res], %[res], 25, 31, 31"   
\
+ : [res] "=r"(result), [gbg] "=v"(gbg) 
\
+ : [veca] "v"(vec) 
\
+ : "cr6"); 
\
+  }
+
+#define cmpVS62(vec, result)   
\
+  {
\
+vector unsigned char gbg;  
\
+asm volatile("vcmpequb. %[gbg], 30, %[veca];"  
\
+ "mfocrf %[res], 2;"   
\
+ "rlwinm %[res], %[res], 25, 31, 31"   
\
+ : [res] "=r"(result), [gbg] "=v"(gbg) 
\
+ : [veca] "v"(vec) 
\
+ : "cr6"); 
\
+  }
+
+int main(int, char **) {
+  // Set VS63 to 16 bytes each with value 1.
+  asm volatile("vspltisb 31, 1" : : : "v31");
+
+  // Set VS62 to 16 bytes each with value 2.
+  asm volatile("vspltisb 30, 2" : : : "v30");
+
+  // Mix doublewords for both VS62 and VS63.
+  asm volatile("xxmrghd 63, 63, 62");
+  asm volatile("xxmrghd 62, 63, 62");
+
+  vector unsigned long long expectedVS63Value = {0x202020202020202,
+ 0x101010101010101};
+  vector unsigned long long expectedVS62Value = {0x202020202020202

[PATCH] D143953: [RISCV] Accept zicsr and zifencei command line options

2023-02-16 Thread Philip Reames via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG22e199e6afb1: [RISCV] Accept zicsr and zifencei command line 
options (authored by reames).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143953

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s

Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -193,3 +193,9 @@
 
 .attribute arch, "rv32iztso0p1"
 # CHECK: attribute  5, "rv32i2p0_ztso0p1"
+
+.attribute arch, "rv32izicsr2p0"
+# CHECK: attribute  5, "rv32i2p0_zicsr2p0"
+
+.attribute arch, "rv32izifencei2p0"
+# CHECK: attribute  5, "rv32i2p0_zifencei2p0"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -46,6 +46,8 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcb %s -o - | FileCheck --check-prefixes=CHECK,RV32ZCB %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcd %s -o - | FileCheck --check-prefixes=CHECK,RV32ZCD %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcf %s -o - | FileCheck --check-prefixes=CHECK,RV32ZCF %s
+; RUN: llc -mtriple=riscv32 -mattr=+zicsr %s -o - | FileCheck --check-prefixes=CHECK,RV32ZICSR %s
+; RUN: llc -mtriple=riscv32 -mattr=+zifencei %s -o - | FileCheck --check-prefixes=CHECK,RV32ZIFENCEI %s
 
 ; RUN: llc -mtriple=riscv64 %s -o - | FileCheck %s
 ; RUN: llc -mtriple=riscv64 -mattr=+m %s -o - | FileCheck --check-prefixes=CHECK,RV64M %s
@@ -99,6 +101,8 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zca %s -o - | FileCheck --check-prefixes=CHECK,RV64ZCA %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zcb %s -o - | FileCheck --check-prefixes=CHECK,RV64ZCB %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zcd %s -o - | FileCheck --check-prefixes=CHECK,RV64ZCD %s
+; RUN: llc -mtriple=riscv64 -mattr=+zicsr %s -o - | FileCheck --check-prefixes=CHECK,RV64ZICSR %s
+; RUN: llc -mtriple=riscv64 -mattr=+zifencei %s -o - | FileCheck --check-prefixes=CHECK,RV64ZIFENCEI %s
 
 ; CHECK: .attribute 4, 16
 
@@ -147,6 +151,8 @@
 ; RV32ZCB: .attribute 5, "rv32i2p0_zca1p0_zcb1p0"
 ; RV32ZCD: .attribute 5, "rv32i2p0_zcd1p0"
 ; RV32ZCF: .attribute 5, "rv32i2p0_zcf1p0"
+; RV32ZICSR: .attribute 5, "rv32i2p0_zicsr2p0"
+; RV32ZIFENCEI: .attribute 5, "rv32i2p0_zifencei2p0"
 
 ; RV64M: .attribute 5, "rv64i2p0_m2p0"
 ; RV64ZMMUL: .attribute 5, "rv64i2p0_zmmul1p0"
@@ -199,6 +205,8 @@
 ; RV64ZCA: .attribute 5, "rv64i2p0_zca1p0"
 ; RV64ZCB: .attribute 5, "rv64i2p0_zca1p0_zcb1p0"
 ; RV64ZCD: .attribute 5, "rv64i2p0_zcd1p0"
+; RV64ZICSR: .attribute 5, "rv64i2p0_zicsr2p0"
+; RV64ZIFENCEI: .attribute 5, "rv64i2p0_zifencei2p0"
 
 define i32 @addi(i32 %a) {
   %1 = add i32 %a, 1
Index: llvm/lib/Target/RISCV/RISCVFeatures.td
===
--- llvm/lib/Target/RISCV/RISCVFeatures.td
+++ llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -71,6 +71,20 @@
 AssemblerPredicate<(all_of FeatureStdExtZihintntl),
 "'Zihintntl' (Non-Temporal Locality Hints)">;
 
+def FeatureStdExtZicsr
+: SubtargetFeature<"zicsr", "HasStdExtZicsr", "true",
+   "'zicsr' (CSRs)">;
+def HasStdExtZicsr : Predicate<"Subtarget->hasStdExtZicsr()">,
+AssemblerPredicate<(all_of FeatureStdExtZicsr),
+"'Zicsr' (CSRs)">;
+
+def FeatureStdExtZifencei
+: SubtargetFeature<"zifencei", "HasStdExtZifencei", "true",
+   "'zifencei' (fence.i)">;
+def HasStdExtZifencei : Predicate<"Subtarget->hasStdExtZifencei()">,
+   AssemblerPredicate<(all_of FeatureStdExtZifencei),
+   "'Zifencei' (fence.i)">;
+
 def FeatureStdExtZfhmin
 : SubtargetFeature<"zfhmin", "HasStdExtZfhmin", "true",
"'Zfhmin' (Half-Precision Floating-Point Minimal)",
Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -103,6 +103,8 @@
 {"zicbom", RISCVExtensionVersion{1, 0}},
 {"zicboz", RISCVExtensionVersion{1, 0}},
 {"zicbop", RISCVExtensionVersion{1, 0}},
+{"zicsr", RISCVExtensionVersion{2, 0}},
+{"zifencei", RISCVExtensionVersion{2, 0}},
 
 {"svnapot", RISCVExtensionVersion{1, 0}},
 {"svpbmt", RISCVExtensionVersion{1, 0}},
Index: l

[clang] 22e199e - [RISCV] Accept zicsr and zifencei command line options

2023-02-16 Thread Philip Reames via cfe-commits

Author: Philip Reames
Date: 2023-02-16T10:41:41-08:00
New Revision: 22e199e6afb1263c943c0c0d4498694e15bf8a16

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

LOG: [RISCV] Accept zicsr and zifencei command line options

This change adds the definition of the two extensions, but does not either a) 
make any instruction conditional on them or b) enabled the extensions by 
default. (The *instructions* do remain enabled by default per ISA version 2.0 
which is our current default.)

This is meant to be a building block towards something like 
https://reviews.llvm.org/D141666, and in the meantime, address one of the most 
surprising of the current user experience warts. The current behavior of 
rejecting the extensions at the command line despite emitting code which 
appears to use them is surprising to anyone not deeply versed in the details of 
this situation.

Between versions 2.0 and 2.1 of the base I specification, a backwards 
incompatible change was made to remove selected instructions and CSRs from the 
base ISA. These instructions were grouped into a set of new extensions (these), 
but were no longer required by the base ISA. This change is described in 
“Preface to Document Version 20190608-Base-Ratified” from the specification 
document.

As LLVM currently implements only version 2.0 of the base specification, 
accepting these extensions at the command line introduces a configuration which 
doesn't actually match any spec version. It's a pretty harmless variant since 
the 2.0 extension definitions, to my knowledge, exactly match the text from the 
2.0 I text before they were moved into standalone extensions in 2.1 of I. (The 
version numbering in that sentence is a tad confusing to say the least. 
Hopefully I got it right.)

It is worth noting that we already have numerous examples of accepting 
extensions in the march string which didn't exist in version of the spec 
document corresponding to our current base I version, so this doesn't set any 
new precedent.

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

Added: 


Modified: 
clang/test/Preprocessor/riscv-target-features.c
llvm/docs/RISCVUsage.rst
llvm/lib/Support/RISCVISAInfo.cpp
llvm/lib/Target/RISCV/RISCVFeatures.td
llvm/test/CodeGen/RISCV/attributes.ll
llvm/test/MC/RISCV/attribute-arch.s

Removed: 




diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 31bddb97d7fbf..da87e6b112a6e 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -494,3 +494,15 @@
 // RUN: %clang -target riscv32 -march=rv32izcf1p0 
-menable-experimental-extensions \
 // RUN: -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-ZCF-EXT %s
 // CHECK-ZCF-EXT: __riscv_zcf 100{{$}}
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32izicsr2p0 -x c -E 
-dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZICSR-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64izicsr2p0 -x c -E 
-dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZICSR-EXT %s
+// CHECK-ZICSR-EXT: __riscv_zicsr 200{{$}}
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32izifencei2p0 -x c 
-E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZIFENCEI-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64izifencei2p0 -x c 
-E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZIFENCEI-EXT %s
+// CHECK-ZIFENCEI-EXT: __riscv_zifencei 200{{$}}

diff  --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 8242707348385..5932523df391e 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -130,7 +130,7 @@ Supported
 .. _riscv-i2p1-note:
 
 ``zicsr``, ``zifencei``
-  Between versions 2.0 and 2.1 of the base I specification, a backwards 
incompatible change was made to remove selected instructions and CSRs from the 
base ISA.  These instructions were grouped into a set of new extensions, but 
were no longer required by the base ISA.  This change is described in "Preface 
to Document Version 20190608-Base-Ratified" from the specification document.  
LLVM currently implements version 2.0 of the base specification.  Thus, 
instructions from these extensions are accepted as part of the base ISA, but 
attempts to explicitly enable the extensions will error.
+  Between versions 2.0 and 2.1 of the base I specification, a backwards 
incompatible change was made to remove selected instructions and CSRs from the 
base ISA.  These instructions were grouped into a set of new extensions, but 
were no longer required by the base ISA.  This change is described in "Preface 
to Document Version 20190608-Base-Ratified" from the specification d

[PATCH] D143953: [RISCV] Accept zicsr and zifencei command line options

2023-02-16 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

LGTM, and the summary of the discussion in the sync-up call matches my 
understanding.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143953

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


[PATCH] D142609: [Clang] Fix -Wconstant-logical-operand when LHS is a constant

2023-02-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Hmm...looking at some of the commits to the related code, it might be very 
intentional that we don't warn symmetrically:

938533db602b32ab435078e723b656ac6e779a1b
e54ff6cc3e479523b71e4c7eb4bd13707d84de0f




Comment at: clang/test/SemaCXX/expressions.cpp:146-148
   #define Y2 2
   bool r2 = X || Y2; // expected-warning {{use of logical '||' with constant 
operand}} \
  // expected-note {{use '|' for a bitwise operation}}

So I think we'll want to change this test.

See commit d6eb2b9f4d4fc236376e3a5a7b8faa31e8dd427d that introduced it.

If we have a constant that was defined via macro, we DONT want to warn for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609

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


[PATCH] D142609: [Clang] Fix -Wconstant-logical-operand when LHS is a constant

2023-02-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/test/SemaCXX/expressions.cpp:146-148
   #define Y2 2
   bool r2 = X || Y2; // expected-warning {{use of logical '||' with constant 
operand}} \
  // expected-note {{use '|' for a bitwise operation}}

nickdesaulniers wrote:
> So I think we'll want to change this test.
> 
> See commit d6eb2b9f4d4fc236376e3a5a7b8faa31e8dd427d that introduced it.
> 
> If we have a constant that was defined via macro, we DONT want to warn for it.
Another related issue is that sometimes we set these constants via `-D` flags. 
I wonder if that's a clang bug that those aren't considered as having a valid 
macro id?

See also https://github.com/ClangBuiltLinux/linux/issues/1806


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609

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


[PATCH] D143096: [clangd] Provide patched diagnostics with preamble patch

2023-02-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/Preamble.cpp:625
+// same spelling.
+static std::vector patchDiags(llvm::ArrayRef BaselineDiags,
+const ScannedPreamble &BaselineScan,

I think this function is too long with too many local lambdas, consider 
converting it to a class instead (call me old-fashioned!)



Comment at: clang-tools-extra/clangd/Preamble.cpp:645
+auto ModifiedStartIt =
+ModifiedContentsToLine.find(BaselineScan.Lines[BaselineStart]);
+if (ModifiedStartIt == ModifiedContentsToLine.end())

we're assuming that the ranges are within the preamble and everyone agrees 
about the bounds. If not, BaselineStart may not be a valid index into 
BaselineScan.Lines

This assumption seems broadly reasonable, but is *very much* not locally 
enforced. I'd suggest a defensive check or at least an assert.



Comment at: clang-tools-extra/clangd/Preamble.cpp:648
+  return std::nullopt;
+int Closest = ModifiedStartIt->second.front();
+for (auto AlternateLine : ModifiedStartIt->second) {

this doesn't look right: you're first deciding which possible starting point is 
closest, and then deciding whether it matches. So a range that matches can be 
masked by a range where only the first line matches, if the latter is closer.



Comment at: clang-tools-extra/clangd/Preamble.cpp:683
+  NewFix.Edits.emplace_back(E);
+  NewFix.Edits.back().range = *NewRange;
+}

probably doesn't matter, but you're inconsistent about moving vs copying range



Comment at: clang-tools-extra/clangd/Preamble.cpp:706
+Diag NewDiag;
+// Copy all fields but Notes, Fixes, Name and Tags.
+static_cast(NewDiag) = static_cast(D);

reasoning about the fields you're *not* rewriting feels fragile. (Here and in 
TranslateFix).

Consider copying the whole object and mutating in place (`bool 
TranslateDiag(Diag&)` together with `erase_if`)



Comment at: clang-tools-extra/clangd/Preamble.h:162
+  /// Returns diag locations for Modified contents.
+  llvm::ArrayRef patchedDiags() const { return PatchedDiags; }
   static constexpr llvm::StringLiteral HeaderName = "__preamble_patch__.h";

nit: blank line after



Comment at: clang-tools-extra/clangd/unittests/PreambleTests.cpp:820
+  {
+// Note is also dropped if diag is gone.
+Annotations Code(R"(

i'm confused about what this comment is getting at - a note without a diag is 
not even representable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143096

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


[PATCH] D143691: Fix clang-formats IncludeCategory to match the documentation

2023-02-16 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/SortIncludesTest.cpp:548
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"llvm/a.h\"\n"
+"#include \"b.h\"\n"

Febbe wrote:
> HazardyKnusperkeks wrote:
> > While I may accept there are more than one //main// header, this should not 
> > happen in my opinion.
> Yes, that is a conflict of interests. There is no perfect way of implementing 
> this, without the help of clang-tidy / the clang language server:
> 
> To arguably define a file as a main include, all declarations must be 
> analyzed, whether they are predeclared in the include or not.
> But we don't have the help of the clang AST.
> 
> My expectation is, that when I randomly shuffle the includes, that they are 
> always sorted to the same result.
> Currently, this is not the case, and depending on the rules it can 
> furthermore happen, that a main include "a.h" is exchanged with the 
> "llvm/a.h". 
> This should also not happen, but it does, and it is not covered by the tests.
> 
> I consider the false negative of a correct main include worse than a false 
> positive.
> Therefore, I changed it. 
> In addition, my approach has the advantage that all includes are sorted in 
> the same way, regardless of the order.
> 
> But if you want, we could introduce a new Option like: `enum 
> FindMainIncludes{FMI_First, FMI_All, FMI_Off = 0};`
> With `First` to match the current behavior, `All` for the new behavior.
> But then matched includes with a negative priority would be swapped with the 
> other possible main_include at each run.
> I don't know how to prevent this.
> The best solution I can imagine, is still a comment of the programmer, that 
> the respective include is or is not a main include.
> E.g. `// clang-format pragma: no_main_include`
> 
> Another idea would be, to insert all main includes into a list with the 
> matchers' priority, and then take the last negative or the first positive, 
> but only if it is not partially sortable with the neighbors.
> This might be a good heuristic, whether the include was previously detected 
> as main include.
> But I don't know if this is implementable with the current algorithm.
> 
> 
It is very unfortunate that `llvm/a.h` would be detected as a main header, but 
would currently the relative order be kept and thus `a.h` always be //the// 
main header?

I don't think you will find someone (of the usual reviewers) to be in favor of 
the pragma, and I certainly don't want such a thing in my code.

A heuristic seems to be a good way. I'd say from all the candidates we take the 
one without any directories in it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143691

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


[PATCH] D142907: LangRef: Add "dynamic" option to "denormal-fp-math"

2023-02-16 Thread Joshua Cranmer via Phabricator via cfe-commits
jcranmer-intel added a comment.

In D142907#4132430 , @arsenm wrote:

> I was thinking of changing the default in general to dynamic. I was going to 
> at least change the strictfp default in a follow up

I had the same thought too, but I reflected a little further that the default 
fp model implying that the environment being in the default state means we can 
assume the FTZ/DAZ are also in a default (IEEE) state.

In D142907#4132543 , @kpn wrote:

> What's the plan for tying this to strictfp? Because I don't it should be tied 
> to cases where we use the constrained intrinsics but the exceptions are 
> ignored and the default rounding is in stated. Those instructions are 
> supposed to behave the same as the non-constrained instructions. So keying 
> off the presence of the strictfp attribute on the function definition, or the 
> (equivalent) presence of constrained intrinsics, would be too simple.

The way I see it, `strictfp` is an assertion that every FP instruction has a 
dependency on the FP environment, which is largely orthogonal to the 
`denormal-mode` attribute asserting that the FTZ/DAZ bits in the FP environment 
have a particular value. The constrained intrinsics also have the ability to 
assert some properties of the FP environment (specifically, rounding mode and 
exception behavior) on individual instructions. By not adding any metadata to 
constrained intrinsics at the same time, we don't get the ability to set the 
denormal-mode on a per-instruction basis-but I don't think there's much value 
to be gained by doing so (giving that we already have it at a per-function 
level).

> Would we get different denormal behavior with a clang flag vs using a #pragma 
> at the top of a source file? That seems surprising as well.

One of the consequences of having so many different ways of controlling 
compiler FP environment assumptions is that there's a crazy amount of 
interactions to consider. But I think there is ultimately a workable solution 
for the clang frontend to generate interactions that make sense.


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

https://reviews.llvm.org/D142907

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


[PATCH] D144190: [AIX][clang] Storage Locations for Constant Pointers

2023-02-16 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 updated this revision to Diff 498118.
qiongsiwu1 added a comment.

Rebase to resolve clang release note conflict.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144190

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/PowerPC/aix-roptr.c
  clang/test/Driver/ppc-roptr.c

Index: clang/test/Driver/ppc-roptr.c
===
--- /dev/null
+++ clang/test/Driver/ppc-roptr.c
@@ -0,0 +1,18 @@
+// RUN: %clang -### -target powerpc-ibm-aix-xcoff -mroptr %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target powerpc-ibm-aix-xcoff -mroptr -mno-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=ROPTR
+// RUN: %clang -### -target powerpc64-ibm-aix-xcoff -mroptr %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target powerpc64-ibm-aix-xcoff -mroptr -mno-roptr %s 2>&1 | \
+// RUN: FileCheck %s --check-prefix=ROPTR
+// CHECK: "-mroptr"
+// CHECK: "-bforceimprw"
+// ROPTR-NOT: "-mroptr"
+// ROPTR-NOT: "-bforceimprw"
+
+char c1 = 10;
+char c2 = 20;
+char* const c1_ptr = &c1;
+
+int main() {
+*(char**)&c1_ptr = &c2;
+}
Index: clang/test/CodeGen/PowerPC/aix-roptr.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/aix-roptr.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix-xcoff -mroptr -fdata-sections \
+// RUN: -S <%s | FileCheck %s --check-prefix=CHECK32
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -mroptr -fdata-sections \
+// RUN: -S <%s | FileCheck %s --check-prefix=CHECK64
+// RUN: not %clang_cc1 -triple=powerpc-ibm-aix-xcoff -mroptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: not %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -mroptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: not %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -mroptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=TARGET_ERR
+// RUN: not %clang -Xclang -triple=powerpc-ibm-aix-xcoff -mroptr -shared \
+// RUN: -S %s 2>&1 | FileCheck %s --check-prefix=SHARED_ERR
+// RUN: not %clang -Xclang -triple=powerpc64-ibm-aix-xcoff -mroptr -shared \
+// RUN: -S %s 2>&1 | FileCheck %s --check-prefix=SHARED_ERR
+
+char c1 = 10;
+char c2 = 20;
+char* const c1_ptr = &c1;
+// CHECK32: .csect c1_ptr[RO],2
+// CHECK32-NEXT:	.globl	c1_ptr[RO]
+// CHECK32-NEXT:	.align	2
+// CHECK32-NEXT:	.vbyte	4, c1[RW]
+
+// CHECK64: .csect c1_ptr[RO],3
+// CHECK64-NEXT:	.globl	c1_ptr[RO]
+// CHECK64-NEXT:	.align	3
+// CHECK64-NEXT:	.vbyte	8, c1[RW]
+
+// DATA_SECTION_ERR: error: -mroptr is supported only with -fdata-sections
+// TARGET_ERR: error: unsupported option '-mroptr' for target 'powerpc64le-unknown-linux-gnu'
+// SHARED_ERR: error: -mroptr is not suppored with -shared
+
+int main() {
+*(char**)&c1_ptr = &c2;
+}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1560,6 +1560,9 @@
   if (Opts.EnableAIXExtendedAltivecABI)
 GenerateArg(Args, OPT_mabi_EQ_vec_extabi, SA);
 
+  if (Opts.ReadOnlyPointers)
+GenerateArg(Args, OPT_mroptr, SA);
+
   if (!Opts.OptRecordPasses.empty())
 GenerateArg(Args, OPT_opt_record_passes, Opts.OptRecordPasses, SA);
 
@@ -1949,6 +1952,17 @@
 Opts.EnableAIXExtendedAltivecABI = O.matches(OPT_mabi_EQ_vec_extabi);
   }
 
+  if (Arg *A = Args.getLastArg(OPT_mroptr)) {
+if (!T.isOSAIX())
+  Diags.Report(diag::err_drv_unsupported_opt_for_target)
+  << A->getSpelling() << T.str();
+
+if (!Args.hasFlag(OPT_fdata_sections, OPT_fno_data_sections, false))
+  Diags.Report(diag::err_roptr_requires_data_sections);
+
+Opts.ReadOnlyPointers = true;
+  }
+
   if (Arg *A = Args.getLastArg(OPT_mabi_EQ_quadword_atomics)) {
 if (!T.isOSAIX() || T.isPPC32())
   Diags.Report(diag::err_drv_unsupported_opt_for_target)
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5248,6 +5248,17 @@
   << A->getSpelling() << RawTriple.str();
   }
 
+  if (Args.hasFlag(options::OPT_mroptr, options::OPT_mno_roptr, false)) {
+if (!Triple.isOSAIX())
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << "-mroptr" << RawTriple.str();
+
+if (Args.hasArg(options::OPT_shared))
+  D.Diag(diag::err_roptr_cannot_build_shared);
+
+CmdArgs.push_back("-mroptr");

[PATCH] D144136: Add a "remark" to report on array accesses

2023-02-16 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

In D144136#4131825 , @aaron.ballman 
wrote:

> I'd like to understand what the overhead is for this. How much overhead does 
> this add when the remark is disabled? How much overhead does this add when 
> the remark is enabled?
>
>> This will report a ton of information. It's basically only good for piping 
>> to a file and using Perl to gather any useful information.
>
> This is why I'm worried about overhead -- there can be *a lot* of array 
> accesses in a complex TU and spitting data out to (potentially) stdout/stderr 
> is *slow*.

I should have indicated that I'm not expecting this to go into mainline Clang. 
As you mentioned, this would be a lot of overhead and is really only useful in 
the way @kees mentioned. I created this "arc" patch to make it easier for him 
to import it. :-) Sorry for the confusion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144136

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


[PATCH] D144206: [clang-tidy] Fix false-positive in cppcoreguidelines-slicing

2023-02-16 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL created this revision.
Herald added subscribers: carlosgalvezp, shchenz, kbarton, xazax.hun, nemanjai.
Herald added a reviewer: njames93.
Herald added a project: All.
PiotrZSL published this revision for review.
PiotrZSL added a comment.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Ready for review.


When warning would be emitted in constructor for virtual base class
initialization.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144206

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
@@ -98,3 +98,20 @@
   a = h;
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 
'DerivedThatOverridesH' to 'Base' discards override 'h'
 }
+
+struct BaseA {
+virtual ~BaseA() {}
+virtual void foo() {}
+
+int i;
+};
+
+struct BaseB : virtual BaseA {
+virtual void foo() {}
+};
+
+struct ClassWithVirtualBases : BaseB {
+  ClassWithVirtualBases(const BaseB& other) : BaseA(other), BaseB(other) {}
+  ClassWithVirtualBases(const ClassWithVirtualBases& other) : BaseA(other), 
BaseB(other) {}
+};
+
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -130,6 +130,10 @@
 Changes in existing checks
 ^^
 
+- Fixed a false positive in :doc:`cppcoreguidelines-slicing
+  ` check when warning would be
+  emitted in constructor for virtual base class initialization.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp
@@ -40,12 +40,15 @@
   const auto HasTypeDerivedFromBaseDecl =
   anyOf(hasType(IsDerivedFromBaseDecl),
 hasType(references(IsDerivedFromBaseDecl)));
-  const auto IsWithinDerivedCtor =
-  hasParent(cxxConstructorDecl(ofClass(equalsBoundNode("DerivedDecl";
+  const auto IsCallToBaseClass = hasParent(cxxConstructorDecl(
+  ofClass(isSameOrDerivedFrom(equalsBoundNode("DerivedDecl"))),
+  hasAnyConstructorInitializer(allOf(
+  isBaseInitializer(), withInitializer(equalsBoundNode("Call"));
 
   // Assignment slicing: "a = b;" and "a = std::move(b);" variants.
   const auto SlicesObjectInAssignment =
-  callExpr(callee(cxxMethodDecl(anyOf(isCopyAssignmentOperator(),
+  callExpr(expr().bind("Call"),
+   callee(cxxMethodDecl(anyOf(isCopyAssignmentOperator(),
   isMoveAssignmentOperator()),
 OfBaseClass)),
hasArgument(1, HasTypeDerivedFromBaseDecl));
@@ -53,17 +56,17 @@
   // Construction slicing: "A a{b};" and "f(b);" variants. Note that in case of
   // slicing the letter will create a temporary and therefore call a ctor.
   const auto SlicesObjectInCtor = cxxConstructExpr(
+  expr().bind("Call"),
   hasDeclaration(cxxConstructorDecl(
   anyOf(isCopyConstructor(), isMoveConstructor()), OfBaseClass)),
   hasArgument(0, HasTypeDerivedFromBaseDecl),
   // We need to disable matching on the call to the base copy/move
   // constructor in DerivedDecl's constructors.
-  unless(IsWithinDerivedCtor));
+  unless(IsCallToBaseClass));
 
-  Finder->addMatcher(traverse(TK_AsIs, expr(anyOf(SlicesObjectInAssignment,
-  SlicesObjectInCtor))
-   .bind("Call")),
- this);
+  Finder->addMatcher(
+  traverse(TK_AsIs, expr(SlicesObjectInAssignment).bind("Call")), this);
+  Finder->addMatcher(traverse(TK_AsIs, SlicesObjectInCtor), this);
 }
 
 /// Warns on methods overridden in DerivedDecl with respect to BaseDecl.


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/slicing.cpp
@@ -98,3 +98,20 @@
   a = h;
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: slicing object from type 'DerivedThatOverridesH' to 'Base' discards override 'h'
 }
+
+struct BaseA {
+virtual ~BaseA() {}
+virtual void foo() {}
+
+int i;
+};
+
+str

[PATCH] D144181: [clang][DebugInfo] Add abi-tags on constructors/destructors as LLVM annotations

2023-02-16 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Ah, accidentally posted to the lldb part of this stack... instead:

Any chance we can make these work more like member functions (could the ctors 
include their mangled names, for instance)? Or is it the innate nature of ctors 
having the various C1 /C2/etc versions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144181

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


[PATCH] D144181: [clang][DebugInfo] Add abi-tags on constructors/destructors as LLVM annotations

2023-02-16 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added a comment.

In D144181#4133025 , @dblaikie wrote:

> Ah, accidentally posted to the lldb part of this stack... instead:
>
> Any chance we can make these work more like member functions (could the ctors 
> include their mangled names, for instance)? Or is it the innate nature of 
> ctors having the various C1 /C2/etc versions?

Initially we tried that in https://reviews.llvm.org/D143652. The existence of 
multiple constructor definitions which aren't linked to the `DISubprogram` 
declaration makes it tough. We need to start with a pretty expensive search 
through the index for all the possible definitions. But then we need to somehow 
choose the right one to take the linkage name from. And that context isn't 
available at the point where LLDB parses DWARF.

I'll post some numbers of how much space this would take with Adrian's 
suggestion and go from there


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144181

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


[PATCH] D144216: [clang-tidy] Extract string header from redundant-string-cstr checker

2023-02-16 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe created this revision.
mikecrowe added a reviewer: njames93.
Herald added a subscriber: xazax.hun.
Herald added a project: All.
mikecrowe requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

In preparation for using the implementation of basic_string and
basic_string_view from redundant-string-cstr.cpp in other checks, let's
extract it to a header.


https://reviews.llvm.org/D144216

Files:
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
  
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr.cpp
@@ -1,71 +1,5 @@
-// RUN: %check_clang_tidy %s readability-redundant-string-cstr %t
-
-typedef unsigned __INT16_TYPE__ char16;
-typedef unsigned __INT32_TYPE__ char32;
-typedef __SIZE_TYPE__ size;
-
-namespace std {
-template 
-class allocator {};
-template 
-class char_traits {};
-template 
-struct basic_string {
-  typedef basic_string _Type;
-  basic_string();
-  basic_string(const C *p, const A &a = A());
-
-  ~basic_string();
-
-  const C *c_str() const;
-  const C *data() const;
-
-  _Type& append(const C *s);
-  _Type& append(const C *s, size n);
-  _Type& assign(const C *s);
-  _Type& assign(const C *s, size n);
-
-  int compare(const _Type&) const;
-  int compare(const C* s) const;
-  int compare(size pos, size len, const _Type&) const;
-  int compare(size pos, size len, const C* s) const;
-
-  size find(const _Type& str, size pos = 0) const;
-  size find(const C* s, size pos = 0) const;
-  size find(const C* s, size pos, size n) const;
-
-  _Type& insert(size pos, const _Type& str);
-  _Type& insert(size pos, const C* s);
-  _Type& insert(size pos, const C* s, size n);
-
-  _Type& operator+=(const _Type& str);
-  _Type& operator+=(const C* s);
-  _Type& operator=(const _Type& str);
-  _Type& operator=(const C* s);
-};
-
-typedef basic_string, std::allocator> string;
-typedef basic_string, std::allocator> wstring;
-typedef basic_string, std::allocator> u16string;
-typedef basic_string, std::allocator> u32string;
-
-template 
-struct basic_string_view {
-  basic_string_view(const C* s);
-};
-typedef basic_string_view> string_view;
-typedef basic_string_view> wstring_view;
-typedef basic_string_view> u16string_view;
-typedef basic_string_view> u32string_view;
-}
-
-std::string operator+(const std::string&, const std::string&);
-std::string operator+(const std::string&, const char*);
-std::string operator+(const char*, const std::string&);
-
-bool operator==(const std::string&, const std::string&);
-bool operator==(const std::string&, const char*);
-bool operator==(const char*, const std::string&);
+// RUN: %check_clang_tidy %s readability-redundant-string-cstr %t -- -- -isystem %clang_tidy_headers
+#include 
 
 namespace llvm {
 struct StringRef {
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
@@ -0,0 +1,71 @@
+#ifndef _STRING_
+#define _STRING_
+
+typedef unsigned __INT16_TYPE__ char16;
+typedef unsigned __INT32_TYPE__ char32;
+typedef __SIZE_TYPE__ size;
+
+namespace std {
+template 
+class allocator {};
+template 
+class char_traits {};
+template 
+struct basic_string {
+  typedef basic_string _Type;
+  basic_string();
+  basic_string(const C *p, const A &a = A());
+
+  ~basic_string();
+
+  const C *c_str() const;
+  const C *data() const;
+
+  _Type& append(const C *s);
+  _Type& append(const C *s, size n);
+  _Type& assign(const C *s);
+  _Type& assign(const C *s, size n);
+
+  int compare(const _Type&) const;
+  int compare(const C* s) const;
+  int compare(size pos, size len, const _Type&) const;
+  int compare(size pos, size len, const C* s) const;
+
+  size find(const _Type& str, size pos = 0) const;
+  size find(const C* s, size pos = 0) const;
+  size find(const C* s, size pos, size n) const;
+
+  _Type& insert(size pos, const _Type& str);
+  _Type& insert(size pos, const C* s);
+  _Type& insert(size pos, const C* s, size n);
+
+  _Type& operator+=(const _Type& str);
+  _Type& operator+=(const C* s);
+  _Type& operator=(const _Type& str);
+  _Type& operator=(const C* s);
+};
+
+typedef basic_string, std::allocator> string;
+typedef basic_string, std::allocator> wstring;
+typedef basic_string, std::allocator> u16string;
+typedef basic_string, std::allocator> u32string;
+
+template 
+struct basic_string_view {
+  basic_string_view(const C* s);
+};
+typedef basic_string_view> string_view;
+typedef basic_string_view> wstring_view;
+typedef basic_string_view> u16string_view;
+typedef basic_

[PATCH] D143342: [clang-tidy] Support std::format and std::print in readability-redundant-string-cstr

2023-02-16 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe updated this revision to Diff 498136.
mikecrowe edited the summary of this revision.

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

https://reviews.llvm.org/D143342

Files:
  clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
  
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr-format.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr-format.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr-format.cpp
@@ -0,0 +1,214 @@
+// RUN: %check_clang_tidy -check-suffix=STDFORMAT -std=c++20 %s readability-redundant-string-cstr %t -- --  -isystem %clang_tidy_headers -DTEST_STDFORMAT
+// RUN: %check_clang_tidy -check-suffixes=STDFORMAT,STDPRINT -std=c++2b %s readability-redundant-string-cstr %t -- --  -isystem %clang_tidy_headers -DTEST_STDFORMAT -DTEST_STDPRINT
+#include 
+
+namespace std {
+  template
+struct type_identity { using type = T; };
+  template
+using type_identity_t = typename type_identity::type;
+
+  template 
+  struct basic_format_string {
+consteval basic_format_string(const CharT *format) : str(format) {}
+basic_string_view> str;
+  };
+
+  template
+using format_string = basic_format_string...>;
+
+  template
+using wformat_string = basic_format_string...>;
+
+#if defined(TEST_STDFORMAT)
+  template
+  std::string format(format_string, Args &&...);
+  template
+  std::string format(wformat_string, Args &&...);
+#endif // TEST_STDFORMAT
+
+#if defined(TEST_STDPRINT)
+  template
+  void print(format_string, Args &&...);
+  template
+  void print(wformat_string, Args &&...);
+#endif // TEST_STDPRINT
+}
+
+namespace notstd {
+#if defined(TEST_STDFORMAT)
+  template
+  std::string format(const char *, Args &&...);
+  template
+  std::string format(const wchar_t *, Args &&...);
+#endif // TEST_STDFORMAT
+#if defined(TEST_STDPRINT)
+  template
+  void print(const char *, Args &&...);
+  template
+  void print(const wchar_t *, Args &&...);
+#endif // TEST_STDPRINT
+}
+
+std::string return_temporary();
+std::wstring return_wtemporary();
+
+#if defined(TEST_STDFORMAT)
+void std_format(const std::string &s1, const std::string &s2, const std::string &s3) {
+  auto r1 = std::format("One:{}\n", s1.c_str());
+  // CHECK-MESSAGES-STDFORMAT: :[[@LINE-1]]:37: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-FIXES-STDFORMAT: {{^  }}auto r1 = std::format("One:{}\n", s1);
+
+  auto r2 = std::format("One:{} Two:{} Three:{} Four:{}\n", s1.c_str(), s2, s3.c_str(), return_temporary().c_str());
+  // CHECK-MESSAGES-STDFORMAT: :[[@LINE-1]]:61: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-MESSAGES-STDFORMAT: :[[@LINE-2]]:77: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-MESSAGES-STDFORMAT: :[[@LINE-3]]:89: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-FIXES-STDFORMAT: {{^  }}auto r2 = std::format("One:{} Two:{} Three:{} Four:{}\n", s1, s2, s3, return_temporary());
+
+  using namespace std;
+  auto r3 = format("Four:{}\n", s1.c_str());
+  // CHECK-MESSAGES-STDFORMAT: :[[@LINE-1]]:33: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-FIXES-STDFORMAT: {{^  }}auto r3 = format("Four:{}\n", s1);
+}
+
+void std_format_wide(const std::wstring &s1, const std::wstring &s2, const std::wstring &s3) {
+  auto r1 = std::format(L"One:{}\n", s1.c_str());
+  // CHECK-MESSAGES-STDFORMAT: :[[@LINE-1]]:38: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-FIXES-STDFORMAT: {{^  }}auto r1 = std::format(L"One:{}\n", s1);
+
+  auto r2 = std::format(L"One:{} Two:{} Three:{} Four:{}\n", s1.c_str(), s2, s3.c_str(), return_wtemporary().c_str());
+  // CHECK-MESSAGES-STDFORMAT: :[[@LINE-1]]:62: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-MESSAGES-STDFORMAT: :[[@LINE-2]]:78: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-MESSAGES-STDFORMAT: :[[@LINE-3]]:90: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-FIXES-STDFORMAT: {{^  }}auto r2 = std::format(L"One:{} Two:{} Three:{} Four:{}\n", s1, s2, s3, return_wtemporary());
+
+  using namespace std;
+  auto r3 = format(L"Four:{}\n", s1.c_str());
+  // CHECK-MESSAGES-STDFORMAT: :[[@LINE-1]]:34: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-FIXES-STDFORMAT: {{^  }}auto r3 = format(L"Four:{}\n", s1);
+}
+
+// There's are c_str() calls here, so it shouldn't be touched.
+std::string std_format_no_cstr(const std::string &s1, const std::string &s2) {
+  return std::format("One: {}, Two: {}\n", s1, s2);
+}
+

[PATCH] D143342: [clang-tidy] Support std::format and std::print in readability-redundant-string-cstr

2023-02-16 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe marked 2 inline comments as done.
mikecrowe added a comment.

I ended up splitting out the std::format and std::print tests to their own file 
which meant that I didn't need to modify the existing 
`redundant-string-cstr.cpp` file in this commit. (Though of course I had to 
extract the  header in D144216  
first.) Let me know if you don't like the split.

I also slightly re-ordered the tests and removed a few incorrect comments that 
incorrectly survived the switch to using `forEachArgumentWithParam`.


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

https://reviews.llvm.org/D143342

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


[PATCH] D143436: [clangd] Apply standard adaptors to CDBs pushed from LSP

2023-02-16 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 498138.
DmitryPolukhin added a comment.

Add test for expanded response files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143436

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/CompileCommands.h
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/test/Inputs/did-change-configuration-params.args
  clang-tools-extra/clangd/test/did-change-configuration-params.test
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
  clang/include/clang/Tooling/Tooling.h
  clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
  clang/lib/Tooling/Tooling.cpp

Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -43,6 +43,7 @@
 #include "llvm/Option/OptTable.h"
 #include "llvm/Option/Option.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
@@ -299,6 +300,31 @@
   }
 }
 
+void addExpandedResponseFiles(std::vector &CommandLine,
+  llvm::StringRef WorkingDir,
+  llvm::cl::TokenizerCallback Tokenizer,
+  llvm::vfs::FileSystem &FS) {
+  bool SeenRSPFile = false;
+  llvm::SmallVector Argv;
+  Argv.reserve(CommandLine.size());
+  for (auto &Arg : CommandLine) {
+Argv.push_back(Arg.c_str());
+if (!Arg.empty())
+  SeenRSPFile |= Arg.front() == '@';
+  }
+  if (!SeenRSPFile)
+return;
+  llvm::BumpPtrAllocator Alloc;
+  llvm::cl::ExpansionContext ECtx(Alloc, Tokenizer);
+  llvm::Error Err =
+  ECtx.setVFS(&FS).setCurrentDir(WorkingDir).expandResponseFiles(Argv);
+  if (Err)
+llvm::errs() << Err;
+  // Don't assign directly, Argv aliases CommandLine.
+  std::vector ExpandedArgv(Argv.begin(), Argv.end());
+  CommandLine = std::move(ExpandedArgv);
+}
+
 } // namespace tooling
 } // namespace clang
 
@@ -684,7 +710,7 @@
 
   if (!Invocation.run())
 return nullptr;
- 
+
   assert(ASTs.size() == 1);
   return std::move(ASTs[0]);
 }
Index: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
===
--- clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
+++ clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang/Tooling/CompilationDatabase.h"
+#include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ConvertUTF.h"
@@ -48,28 +49,9 @@
 
 private:
   std::vector expand(std::vector Cmds) const {
-for (auto &Cmd : Cmds) {
-  bool SeenRSPFile = false;
-  llvm::SmallVector Argv;
-  Argv.reserve(Cmd.CommandLine.size());
-  for (auto &Arg : Cmd.CommandLine) {
-Argv.push_back(Arg.c_str());
-if (!Arg.empty())
-  SeenRSPFile |= Arg.front() == '@';
-  }
-  if (!SeenRSPFile)
-continue;
-  llvm::BumpPtrAllocator Alloc;
-  llvm::cl::ExpansionContext ECtx(Alloc, Tokenizer);
-  llvm::Error Err = ECtx.setVFS(FS.get())
-.setCurrentDir(Cmd.Directory)
-.expandResponseFiles(Argv);
-  if (Err)
-llvm::errs() << Err;
-  // Don't assign directly, Argv aliases CommandLine.
-  std::vector ExpandedArgv(Argv.begin(), Argv.end());
-  Cmd.CommandLine = std::move(ExpandedArgv);
-}
+for (auto &Cmd : Cmds)
+  tooling::addExpandedResponseFiles(Cmd.CommandLine, Cmd.Directory,
+Tokenizer, *FS);
 return Cmds;
   }
 
Index: clang/include/clang/Tooling/Tooling.h
===
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -506,6 +506,12 @@
 void addTargetAndModeForProgramName(std::vector &CommandLine,
 StringRef InvokedAs);
 
+/// Helper function that expands response files in command line.
+void addExpandedResponseFiles(std::vector &CommandLine,
+  llvm::StringRef WorkingDir,
+  llvm::cl::TokenizerCallback Tokenizer,
+  llvm::vfs::FileSystem &FS);
+
 /// Creates a \c CompilerInvocation.
 CompilerInvocation *newInvocation(DiagnosticsEngine *Diagnostics,
   ArrayRef CC1Args,
Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/c

[PATCH] D143436: [clangd] Apply standard adaptors to CDBs pushed from LSP

2023-02-16 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

@nridge I'm sorry, I pushed version without all tests. Now I added test case 
for response files, it seems that clangd hasn't had it before this patch.




Comment at: clang-tools-extra/clangd/CompileCommands.cpp:222
+  tooling::addExpandedResponseFiles(Cmd, Command.Directory, Tokenizer, *FS);
+  tooling::addTargetAndModeForProgramName(Cmd, Cmd.front());
   auto &OptTable = clang::driver::getDriverOptTable();

nridge wrote:
> nridge wrote:
> > The target needs to be added **after** the call to `SystemIncludeExtractor` 
> > later in this function (this is what D138546 is trying to fix). The reason 
> > is that `SystemIncludeExtractor` includes any `--target` flag in the 
> > compiler driver being queried for system includes, which may be gcc, which 
> > does not support `--target`.
> (I guess we could make that change separately in D138546, but if we're 
> changing the place where the `--target` is added in this patch, I figure we 
> might as well move it directly to the desired place.)
I think there are order problems here:
- we need `--driver-mode=cl` injected here to make check on line #229 work as 
expected
- if we don't inject it driver mode here, command line edits won't see the 
change; see how I modified test clangd/unittests/CompileCommandsTests.cpp line 
#203, with D138546 edits were not applied properly to driver mode

I'll double check how it works on Windows but I expect that moving it after 
SystemIncludeExtractor will break proper driver mode detection.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143436

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


[PATCH] D144218: [Clang] [AVR] Fix USHRT_MAX for 16-bit int.

2023-02-16 Thread Daniel Thornburgh via Phabricator via cfe-commits
mysterymath created this revision.
mysterymath added reviewers: aaron.ballman, aykevl, dylanmckay.
Herald added a subscriber: Jim.
Herald added a project: All.
mysterymath requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

For AVR, the definition of USHRT_MAX overflows.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144218

Files:
  clang/lib/Headers/limits.h


Index: clang/lib/Headers/limits.h
===
--- clang/lib/Headers/limits.h
+++ clang/lib/Headers/limits.h
@@ -52,7 +52,7 @@
 #define LONG_MIN  (-__LONG_MAX__ -1L)
 
 #define UCHAR_MAX (__SCHAR_MAX__*2  +1)
-#define USHRT_MAX (__SHRT_MAX__ *2  +1)
+#define USHRT_MAX (__SHRT_MAX__ * 2U + 1U)
 #define UINT_MAX  (__INT_MAX__  *2U +1U)
 #define ULONG_MAX (__LONG_MAX__ *2UL+1UL)
 


Index: clang/lib/Headers/limits.h
===
--- clang/lib/Headers/limits.h
+++ clang/lib/Headers/limits.h
@@ -52,7 +52,7 @@
 #define LONG_MIN  (-__LONG_MAX__ -1L)
 
 #define UCHAR_MAX (__SCHAR_MAX__*2  +1)
-#define USHRT_MAX (__SHRT_MAX__ *2  +1)
+#define USHRT_MAX (__SHRT_MAX__ * 2U + 1U)
 #define UINT_MAX  (__INT_MAX__  *2U +1U)
 #define ULONG_MAX (__LONG_MAX__ *2UL+1UL)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144192: GH60642: Fix ICE when checking a lambda defined in a concept definition

2023-02-16 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/Sema/TreeTransform.h:4572
: Sema::ExpressionEvaluationContext::ConstantEvaluated,
-/*LambdaContextDecl=*/nullptr, /*ExprContext=*/
+Sema::ReuseLambdaContextDecl, /*ExprContext=*/
 Sema::ExpressionEvaluationContextRecord::EK_TemplateArgument);

Not for this PR but I am looking at other place we use 
`EnterExpressionEvaluationContext` and it is not obvious to me when we should 
be using `Sema::ReuseLambdaContextDecl` or not. So might be worth looking at 
other uses as well.


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

https://reviews.llvm.org/D144192

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


[PATCH] D143691: Fix clang-formats IncludeCategory to match the documentation

2023-02-16 Thread Fabian Keßler via Phabricator via cfe-commits
Febbe added inline comments.



Comment at: clang/unittests/Format/SortIncludesTest.cpp:548
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"llvm/a.h\"\n"
+"#include \"b.h\"\n"

HazardyKnusperkeks wrote:
> Febbe wrote:
> > HazardyKnusperkeks wrote:
> > > While I may accept there are more than one //main// header, this should 
> > > not happen in my opinion.
> > Yes, that is a conflict of interests. There is no perfect way of 
> > implementing this, without the help of clang-tidy / the clang language 
> > server:
> > 
> > To arguably define a file as a main include, all declarations must be 
> > analyzed, whether they are predeclared in the include or not.
> > But we don't have the help of the clang AST.
> > 
> > My expectation is, that when I randomly shuffle the includes, that they are 
> > always sorted to the same result.
> > Currently, this is not the case, and depending on the rules it can 
> > furthermore happen, that a main include "a.h" is exchanged with the 
> > "llvm/a.h". 
> > This should also not happen, but it does, and it is not covered by the 
> > tests.
> > 
> > I consider the false negative of a correct main include worse than a false 
> > positive.
> > Therefore, I changed it. 
> > In addition, my approach has the advantage that all includes are sorted in 
> > the same way, regardless of the order.
> > 
> > But if you want, we could introduce a new Option like: `enum 
> > FindMainIncludes{FMI_First, FMI_All, FMI_Off = 0};`
> > With `First` to match the current behavior, `All` for the new behavior.
> > But then matched includes with a negative priority would be swapped with 
> > the other possible main_include at each run.
> > I don't know how to prevent this.
> > The best solution I can imagine, is still a comment of the programmer, that 
> > the respective include is or is not a main include.
> > E.g. `// clang-format pragma: no_main_include`
> > 
> > Another idea would be, to insert all main includes into a list with the 
> > matchers' priority, and then take the last negative or the first positive, 
> > but only if it is not partially sortable with the neighbors.
> > This might be a good heuristic, whether the include was previously detected 
> > as main include.
> > But I don't know if this is implementable with the current algorithm.
> > 
> > 
> It is very unfortunate that `llvm/a.h` would be detected as a main header, 
> but would currently the relative order be kept and thus `a.h` always be 
> //the// main header?
> 
> I don't think you will find someone (of the usual reviewers) to be in favor 
> of the pragma, and I certainly don't want such a thing in my code.
> 
> A heuristic seems to be a good way. I'd say from all the candidates we take 
> the one without any directories in it.
> but would currently the relative order be kept and thus a.h always be the 
> main header?

No, unfortunately, clang-format never sorted the path after its dept, 
std::filesystem::path would do that, but clang-format uses the std::less 
operator of StringRef which is a lexicographical comparison.
Therefore, `m.h` will always be ordered after `llvm/m.h`. Changing that would 
reorder nearly all headers in all projects using clang-format. But I could do 
this only for the main-include candidates.

Nevertheless, I don't think this would be a good heuristic either, because me, 
and many others are using an extra `include` folder for public headers (API) 
and the `src` directory for private headers:

```
my-lib/
├─ include/
│  ├─ public_headers.md
│  ├─ a.h
├─ src/
│  ├─ private_headers_and_source.md
│  ├─ a_priv.h
│  ├─ a.cpp
```

With your proposed solution, the primary main header is ordered after the main 
include.
Let me implement my heuristic first, maybe it will work well enough to prevent 
the reordering, when the main header is sorted by hand (just like before, but 
now it also should work for negative priorities).

Otherwise, we must reconsider which tradeoff we choose (maybe a completely new 
one).



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143691

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


[PATCH] D143436: [clangd] Apply standard adaptors to CDBs pushed from LSP

2023-02-16 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 498140.
DmitryPolukhin added a comment.

Update test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143436

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/CompileCommands.h
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/test/Inputs/did-change-configuration-params.args
  clang-tools-extra/clangd/test/did-change-configuration-params.test
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
  clang/include/clang/Tooling/Tooling.h
  clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
  clang/lib/Tooling/Tooling.cpp

Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -43,6 +43,7 @@
 #include "llvm/Option/OptTable.h"
 #include "llvm/Option/Option.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
@@ -299,6 +300,31 @@
   }
 }
 
+void addExpandedResponseFiles(std::vector &CommandLine,
+  llvm::StringRef WorkingDir,
+  llvm::cl::TokenizerCallback Tokenizer,
+  llvm::vfs::FileSystem &FS) {
+  bool SeenRSPFile = false;
+  llvm::SmallVector Argv;
+  Argv.reserve(CommandLine.size());
+  for (auto &Arg : CommandLine) {
+Argv.push_back(Arg.c_str());
+if (!Arg.empty())
+  SeenRSPFile |= Arg.front() == '@';
+  }
+  if (!SeenRSPFile)
+return;
+  llvm::BumpPtrAllocator Alloc;
+  llvm::cl::ExpansionContext ECtx(Alloc, Tokenizer);
+  llvm::Error Err =
+  ECtx.setVFS(&FS).setCurrentDir(WorkingDir).expandResponseFiles(Argv);
+  if (Err)
+llvm::errs() << Err;
+  // Don't assign directly, Argv aliases CommandLine.
+  std::vector ExpandedArgv(Argv.begin(), Argv.end());
+  CommandLine = std::move(ExpandedArgv);
+}
+
 } // namespace tooling
 } // namespace clang
 
@@ -684,7 +710,7 @@
 
   if (!Invocation.run())
 return nullptr;
- 
+
   assert(ASTs.size() == 1);
   return std::move(ASTs[0]);
 }
Index: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
===
--- clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
+++ clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang/Tooling/CompilationDatabase.h"
+#include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ConvertUTF.h"
@@ -48,28 +49,9 @@
 
 private:
   std::vector expand(std::vector Cmds) const {
-for (auto &Cmd : Cmds) {
-  bool SeenRSPFile = false;
-  llvm::SmallVector Argv;
-  Argv.reserve(Cmd.CommandLine.size());
-  for (auto &Arg : Cmd.CommandLine) {
-Argv.push_back(Arg.c_str());
-if (!Arg.empty())
-  SeenRSPFile |= Arg.front() == '@';
-  }
-  if (!SeenRSPFile)
-continue;
-  llvm::BumpPtrAllocator Alloc;
-  llvm::cl::ExpansionContext ECtx(Alloc, Tokenizer);
-  llvm::Error Err = ECtx.setVFS(FS.get())
-.setCurrentDir(Cmd.Directory)
-.expandResponseFiles(Argv);
-  if (Err)
-llvm::errs() << Err;
-  // Don't assign directly, Argv aliases CommandLine.
-  std::vector ExpandedArgv(Argv.begin(), Argv.end());
-  Cmd.CommandLine = std::move(ExpandedArgv);
-}
+for (auto &Cmd : Cmds)
+  tooling::addExpandedResponseFiles(Cmd.CommandLine, Cmd.Directory,
+Tokenizer, *FS);
 return Cmds;
   }
 
Index: clang/include/clang/Tooling/Tooling.h
===
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -506,6 +506,12 @@
 void addTargetAndModeForProgramName(std::vector &CommandLine,
 StringRef InvokedAs);
 
+/// Helper function that expands response files in command line.
+void addExpandedResponseFiles(std::vector &CommandLine,
+  llvm::StringRef WorkingDir,
+  llvm::cl::TokenizerCallback Tokenizer,
+  llvm::vfs::FileSystem &FS);
+
 /// Creates a \c CompilerInvocation.
 CompilerInvocation *newInvocation(DiagnosticsEngine *Diagnostics,
   ArrayRef CC1Args,
Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCo

[PATCH] D144192: GH60642: Fix ICE when checking a lambda defined in a concept definition

2023-02-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/TreeTransform.h:4572
: Sema::ExpressionEvaluationContext::ConstantEvaluated,
-/*LambdaContextDecl=*/nullptr, /*ExprContext=*/
+Sema::ReuseLambdaContextDecl, /*ExprContext=*/
 Sema::ExpressionEvaluationContextRecord::EK_TemplateArgument);

shafik wrote:
> Not for this PR but I am looking at other place we use 
> `EnterExpressionEvaluationContext` and it is not obvious to me when we should 
> be using `Sema::ReuseLambdaContextDecl` or not. So might be worth looking at 
> other uses as well.
Yeah, its unfortunately not particularly clear to me either. We should be 
re-using that context any time we're going "down" in code (that is, if we are 
potentially in a context where a lambda is defined inside of something its 
actual declcontext doesn't match), but should NOT reuse the context in a case 
where we are 'swapping' contexts to do something like instantiate a function 
required by the current context/etc.


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

https://reviews.llvm.org/D144192

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


[PATCH] D140723: [clang][Interp] Only check constructors for global variables

2023-02-16 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

So we are only checking global constructors b/c it is valid in a constant 
expression context to initialize a record and not initialize all their fields 
as long as we don't use any of those fields.

Note, cases that stem from this has been discussed as part of 
https://github.com/cplusplus/papers/issues/1380 but the issue is not resolved 
yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140723

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


[PATCH] D140723: [clang][Interp] Only check constructors for global variables

2023-02-16 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140723

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


[PATCH] D144047: [CUDA][SPIRV] Match builtin types and __GCC_ATOMIC_XXX_LOCK_FREE macros on host/device

2023-02-16 Thread Shangwu Yao via Phabricator via cfe-commits
shangwuyao updated this revision to Diff 498145.
shangwuyao added a comment.

Run clang-format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144047

Files:
  clang/lib/Basic/Targets/SPIR.h
  clang/test/CodeGenCUDASPIRV/cuda-types.cu

Index: clang/test/CodeGenCUDASPIRV/cuda-types.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDASPIRV/cuda-types.cu
@@ -0,0 +1,56 @@
+// Check that types, widths, __CLANG_ATOMIC* macros, etc. match on the host and
+// device sides of CUDA compilations. Note that we filter out long double and
+// maxwidth of _BitInt(), as this is intentionally different on host and device.
+//
+// Also ignore __CLANG_ATOMIC_LLONG_LOCK_FREE on i386. The default host CPU for
+// an i386 triple is typically at least an i586, which has cmpxchg8b (Clang
+// feature, "cx8"). Therefore, __CLANG_ATOMIC_LLONG_LOCK_FREE is 2 on the host,
+// but the value should be 1 for the device.
+//
+// Unlike CUDA, the width of SPIR-V POINTER type could differ between host and
+// device, because SPIR-V explicitly sets POINTER type width. So it is the
+// user's responsibility to choose the offload with the right POINTER size,
+// otherwise the values for __CLANG_ATOMIC_POINTER_LOCK_FREE could be different.
+
+// RUN: mkdir -p %t
+
+// RUN: %clang --cuda-host-only -nocudainc -nocudalib --offload=spirv32 -target i386-unknown-linux-gnu -x cuda -emit-llvm -E -dM -o - /dev/null \
+// RUN:   | grep -E '__CLANG_ATOMIC' \
+// RUN:   | grep -Ev '_ATOMIC_LLONG_LOCK_FREE' > %t/i386-host-defines-filtered
+// RUN: %clang --cuda-device-only -nocudainc -nocudalib --offload=spirv32 -target i386-unknown-linux-gnu -x cuda -emit-llvm -E -dM -o - /dev/null \
+// RUN:   | grep -E '__CLANG_ATOMIC' \
+// RUN:   | grep -Ev '_ATOMIC_LLONG_LOCK_FREE' > %t/i386-device-defines-filtered
+// RUN: diff %t/i386-host-defines-filtered %t/i386-device-defines-filtered
+
+// RUN: %clang --cuda-host-only -nocudainc -nocudalib --offload=spirv32 -target i386-windows-msvc -x cuda -emit-llvm -E -dM -o - /dev/null \
+// RUN:   | grep -E '__CLANG_ATOMIC' \
+// RUN:   | grep -Ev '_ATOMIC_LLONG_LOCK_FREE' > %t/i386-msvc-host-defines-filtered
+// RUN: %clang --cuda-device-only -nocudainc -nocudalib --offload=spirv32 -target i386-windows-msvc -x cuda -emit-llvm -E -dM -o - /dev/null \
+// RUN:   | grep -E '__CLANG_ATOMIC' \
+// RUN:   | grep -Ev '_ATOMIC_LLONG_LOCK_FREE' > %t/i386-msvc-device-defines-filtered
+// RUN: diff %t/i386-msvc-host-defines-filtered %t/i386-msvc-device-defines-filtered
+
+// RUN: %clang --cuda-host-only -nocudainc -nocudalib --offload=spirv64 -target x86_64-unknown-linux-gnu -x cuda -emit-llvm -E -dM -o - /dev/null \
+// RUN:   | grep -E '__CLANG_ATOMIC' \
+// RUN:   | grep -Ev '_ATOMIC_LLONG_LOCK_FREE' > %t/x86_64-host-defines-filtered
+// RUN: %clang --cuda-device-only -nocudainc -nocudalib --offload=spirv64 -target x86_64-unknown-linux-gnu -x cuda -emit-llvm -E -dM -o - /dev/null \
+// RUN:   | grep -E '__CLANG_ATOMIC' \
+// RUN:   | grep -Ev '_ATOMIC_LLONG_LOCK_FREE' > %t/x86_64-device-defines-filtered
+// RUN: diff %t/x86_64-host-defines-filtered %t/x86_64-device-defines-filtered
+
+// RUN: %clang --cuda-host-only -nocudainc -nocudalib --offload=spirv64 -target powerpc64-unknown-linux-gnu -x cuda -emit-llvm -E -dM -o - /dev/null \
+// RUN:   | grep -E '__CLANG_ATOMIC' \
+// RUN:   | grep -Ev '_ATOMIC_LLONG_LOCK_FREE' > %t/powerpc64-host-defines-filtered
+// RUN: %clang --cuda-device-only -nocudainc -nocudalib --offload=spirv64 -target powerpc64-unknown-linux-gnu -x cuda -emit-llvm -E -dM -o - /dev/null \
+// RUN:   | grep -E '__CLANG_ATOMIC' \
+// RUN:   | grep -Ev '_ATOMIC_LLONG_LOCK_FREE' > %t/powerpc64-device-defines-filtered
+// RUN: diff %t/powerpc64-host-defines-filtered %t/powerpc64-device-defines-filtered
+
+// RUN: %clang --cuda-host-only -nocudainc -nocudalib --offload=spirv64 -target x86_64-windows-msvc -x cuda -emit-llvm -E -dM -o - /dev/null \
+// RUN:   | grep -E '__CLANG_ATOMIC' \
+// RUN:   | grep -Ev '_ATOMIC_LLONG_LOCK_FREE' > %t/x86_64-msvc-host-defines-filtered
+// RUN: %clang --cuda-device-only -nocudainc -nocudalib --offload=spirv64 -target x86_64-windows-msvc -x cuda -emit-llvm -E -dM -o - /dev/null \
+// RUN:   | grep -E '__CLANG_ATOMIC' \
+// RUN:   | grep -Ev '_ATOMIC_LLONG_LOCK_FREE' > %t/x86_64-msvc-device-defines-filtered
+// RUN: diff %t/x86_64-msvc-host-defines-filtered %t/x86_64-msvc-device-defines-filtered
+
Index: clang/lib/Basic/Targets/SPIR.h
===
--- clang/lib/Basic/Targets/SPIR.h
+++ clang/lib/Basic/Targets/SPIR.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
 #define LLVM_CLANG_LIB_BASIC_TARGETS_SPIR_H
 
+#include "Targets.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "llvm/Support/Compiler.h"
@@ -79,8 +80,10 @@
 
 // Base cl

[PATCH] D137113: [Clang] refactor CodeGenFunction::EmitAsmStmt NFC

2023-02-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 498156.
nickdesaulniers added a comment.

- final rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137113

Files:
  clang/lib/CodeGen/CGStmt.cpp

Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -24,6 +24,7 @@
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/Assumptions.h"
@@ -2327,6 +2328,93 @@
   }
 }
 
+static void
+EmitAsmStores(CodeGenFunction &CGF, const AsmStmt &S,
+  const llvm::ArrayRef RegResults,
+  const llvm::ArrayRef ResultRegTypes,
+  const llvm::ArrayRef ResultTruncRegTypes,
+  const llvm::ArrayRef ResultRegDests,
+  const llvm::ArrayRef ResultRegQualTys,
+  const llvm::BitVector &ResultTypeRequiresCast,
+  const llvm::BitVector &ResultRegIsFlagReg) {
+  CGBuilderTy &Builder = CGF.Builder;
+  CodeGenModule &CGM = CGF.CGM;
+  llvm::LLVMContext &CTX = CGF.getLLVMContext();
+
+  assert(RegResults.size() == ResultRegTypes.size());
+  assert(RegResults.size() == ResultTruncRegTypes.size());
+  assert(RegResults.size() == ResultRegDests.size());
+  // ResultRegDests can be also populated by addReturnRegisterOutputs() above,
+  // in which case its size may grow.
+  assert(ResultTypeRequiresCast.size() <= ResultRegDests.size());
+  assert(ResultRegIsFlagReg.size() <= ResultRegDests.size());
+
+  for (unsigned i = 0, e = RegResults.size(); i != e; ++i) {
+llvm::Value *Tmp = RegResults[i];
+llvm::Type *TruncTy = ResultTruncRegTypes[i];
+
+if ((i < ResultRegIsFlagReg.size()) && ResultRegIsFlagReg[i]) {
+  // Target must guarantee the Value `Tmp` here is lowered to a boolean
+  // value.
+  llvm::Constant *Two = llvm::ConstantInt::get(Tmp->getType(), 2);
+  llvm::Value *IsBooleanValue =
+  Builder.CreateCmp(llvm::CmpInst::ICMP_ULT, Tmp, Two);
+  llvm::Function *FnAssume = CGM.getIntrinsic(llvm::Intrinsic::assume);
+  Builder.CreateCall(FnAssume, IsBooleanValue);
+}
+
+// If the result type of the LLVM IR asm doesn't match the result type of
+// the expression, do the conversion.
+if (ResultRegTypes[i] != TruncTy) {
+
+  // Truncate the integer result to the right size, note that TruncTy can be
+  // a pointer.
+  if (TruncTy->isFloatingPointTy())
+Tmp = Builder.CreateFPTrunc(Tmp, TruncTy);
+  else if (TruncTy->isPointerTy() && Tmp->getType()->isIntegerTy()) {
+uint64_t ResSize = CGM.getDataLayout().getTypeSizeInBits(TruncTy);
+Tmp = Builder.CreateTrunc(
+Tmp, llvm::IntegerType::get(CTX, (unsigned)ResSize));
+Tmp = Builder.CreateIntToPtr(Tmp, TruncTy);
+  } else if (Tmp->getType()->isPointerTy() && TruncTy->isIntegerTy()) {
+uint64_t TmpSize =
+CGM.getDataLayout().getTypeSizeInBits(Tmp->getType());
+Tmp = Builder.CreatePtrToInt(
+Tmp, llvm::IntegerType::get(CTX, (unsigned)TmpSize));
+Tmp = Builder.CreateTrunc(Tmp, TruncTy);
+  } else if (TruncTy->isIntegerTy()) {
+Tmp = Builder.CreateZExtOrTrunc(Tmp, TruncTy);
+  } else if (TruncTy->isVectorTy()) {
+Tmp = Builder.CreateBitCast(Tmp, TruncTy);
+  }
+}
+
+LValue Dest = ResultRegDests[i];
+// ResultTypeRequiresCast elements correspond to the first
+// ResultTypeRequiresCast.size() elements of RegResults.
+if ((i < ResultTypeRequiresCast.size()) && ResultTypeRequiresCast[i]) {
+  unsigned Size = CGF.getContext().getTypeSize(ResultRegQualTys[i]);
+  Address A =
+  Builder.CreateElementBitCast(Dest.getAddress(CGF), ResultRegTypes[i]);
+  if (CGF.getTargetHooks().isScalarizableAsmOperand(CGF, TruncTy)) {
+Builder.CreateStore(Tmp, A);
+continue;
+  }
+
+  QualType Ty =
+  CGF.getContext().getIntTypeForBitwidth(Size, /*Signed*/ false);
+  if (Ty.isNull()) {
+const Expr *OutExpr = S.getOutputExpr(i);
+CGM.getDiags().Report(OutExpr->getExprLoc(),
+  diag::err_store_value_to_reg);
+return;
+  }
+  Dest = CGF.MakeAddrLValue(A, Ty);
+}
+CGF.EmitStoreThroughLValue(RValue::get(Tmp), Dest);
+  }
+}
+
 void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
   // Pop all cleanup blocks at the end of the asm statement.
   CodeGenFunction::RunCleanupsScope Cleanups(*this);
@@ -2627,7 +2715,7 @@
   SmallVector Transfer;
   llvm::BasicBlock *Fallthrough = nullptr;
   bool IsGCCAsmGoto = false;
-  if (const auto *GS =  dyn_cast(&S)) {
+  if (const auto *GS = dyn_cast(&S)) {
 IsGCCAsmGoto = GS->isAsmGoto();

[PATCH] D136497: [Clang] support for outputs along indirect edges of asm goto

2023-02-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 498157.
nickdesaulniers added a comment.

- final rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136497

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/asm-goto.c
  clang/test/CodeGen/asm-goto2.c
  clang/test/Modules/asm-goto.c

Index: clang/test/Modules/asm-goto.c
===
--- clang/test/Modules/asm-goto.c
+++ clang/test/Modules/asm-goto.c
@@ -5,7 +5,7 @@
 
 // CHECK-LABEL: define {{.*}} @foo(
 // CHECK: callbr {{.*}} "=r,!i{{.*}}()
-// CHECK-NEXT: to label %asm.fallthrough [label %indirect]
+// CHECK-NEXT: to label %asm.fallthrough [label %indirect.split]
 
 int bar(void) {
   return foo();
Index: clang/test/CodeGen/asm-goto2.c
===
--- /dev/null
+++ clang/test/CodeGen/asm-goto2.c
@@ -0,0 +1,156 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O0 -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: @test0(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[RET:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[TMP0:%.*]] = callbr i32 asm "", "=r,!i,~{dirflag},~{fpsr},~{flags}"() #[[ATTR1:[0-9]+]]
+// CHECK-NEXT:to label [[ASM_FALLTHROUGH:%.*]] [label %z.split], !srcloc !2
+// CHECK:   asm.fallthrough:
+// CHECK-NEXT:store i32 [[TMP0]], ptr [[RET]], align 4
+// CHECK-NEXT:store i32 42, ptr [[RET]], align 4
+// CHECK-NEXT:br label [[Z:%.*]]
+// CHECK:   z:
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[RET]], align 4
+// CHECK-NEXT:ret i32 [[TMP1]]
+// CHECK:   z.split:
+// CHECK-NEXT:store i32 [[TMP0]], ptr [[RET]], align 4
+// CHECK-NEXT:br label [[Z]]
+//
+int test0 (void) {
+  int ret;
+  asm goto ("" : "=r"(ret):::z);
+  ret = 42;
+z:
+  return ret;
+}
+
+// CHECK-LABEL: @test1(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[RET:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[B:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[TMP0:%.*]] = callbr { i32, i32 } asm "", "=r,=r,!i,~{dirflag},~{fpsr},~{flags}"() #[[ATTR1]]
+// CHECK-NEXT:to label [[ASM_FALLTHROUGH:%.*]] [label %z.split], !srcloc !3
+// CHECK:   asm.fallthrough:
+// CHECK-NEXT:[[ASMRESULT:%.*]] = extractvalue { i32, i32 } [[TMP0]], 0
+// CHECK-NEXT:[[ASMRESULT1:%.*]] = extractvalue { i32, i32 } [[TMP0]], 1
+// CHECK-NEXT:store i32 [[ASMRESULT]], ptr [[RET]], align 4
+// CHECK-NEXT:store i32 [[ASMRESULT1]], ptr [[B]], align 4
+// CHECK-NEXT:store i32 42, ptr [[RET]], align 4
+// CHECK-NEXT:br label [[Z:%.*]]
+// CHECK:   z:
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[RET]], align 4
+// CHECK-NEXT:ret i32 [[TMP1]]
+// CHECK:   z.split:
+// CHECK-NEXT:[[ASMRESULT2:%.*]] = extractvalue { i32, i32 } [[TMP0]], 0
+// CHECK-NEXT:[[ASMRESULT3:%.*]] = extractvalue { i32, i32 } [[TMP0]], 1
+// CHECK-NEXT:store i32 [[ASMRESULT2]], ptr [[RET]], align 4
+// CHECK-NEXT:store i32 [[ASMRESULT3]], ptr [[B]], align 4
+// CHECK-NEXT:br label [[Z]]
+//
+int test1 (void) {
+  int ret, b;
+  asm goto ("" : "=r"(ret), "=r"(b):::z);
+  ret = 42;
+z:
+  return ret;
+}
+
+// CHECK-LABEL: @test2(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[RET:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[B:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[TMP0:%.*]] = callbr { i32, i32 } asm "", "=r,=r,!i,~{dirflag},~{fpsr},~{flags}"() #[[ATTR1]]
+// CHECK-NEXT:to label [[ASM_FALLTHROUGH:%.*]] [label %z.split], !srcloc !4
+// CHECK:   asm.fallthrough:
+// CHECK-NEXT:[[ASMRESULT:%.*]] = extractvalue { i32, i32 } [[TMP0]], 0
+// CHECK-NEXT:[[ASMRESULT1:%.*]] = extractvalue { i32, i32 } [[TMP0]], 1
+// CHECK-NEXT:store i32 [[ASMRESULT]], ptr [[RET]], align 4
+// CHECK-NEXT:store i32 [[ASMRESULT1]], ptr [[B]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = callbr { i32, i32 } asm "", "=r,=r,!i,~{dirflag},~{fpsr},~{flags}"() #[[ATTR1]]
+// CHECK-NEXT:to label [[ASM_FALLTHROUGH4:%.*]] [label %z.split9], !srcloc !5
+// CHECK:   asm.fallthrough4:
+// CHECK-NEXT:[[ASMRESULT5:%.*]] = extractvalue { i32, i32 } [[TMP1]], 0
+// CHECK-NEXT:[[ASMRESULT6:%.*]] = extractvalue { i32, i32 } [[TMP1]], 1
+// CHECK-NEXT:store i32 [[ASMRESULT5]], ptr [[RET]], align 4
+// CHECK-NEXT:store i32 [[ASMRESULT6]], ptr [[B]], align 4
+// CHECK-NEXT:br label [[Z:%.*]]
+// CHECK:   z:
+// CHECK-NEXT:[[TMP2:%.*]] = load i32, ptr [[RET]], align 4
+// CHECK-NEXT:ret i32 [[TMP2]]
+// CHECK:   z.split:
+// CHECK-NEXT:[[ASMRESULT2:%.*]] = extractvalue { i32, i32 } [[TMP0]], 0
+// CHECK-NEXT:[[ASMRESULT3:%.*]] = extractvalue { i32, i32 } [[TMP0]], 1
+// CHECK-NEXT:store i32 [[ASMRESULT2]], ptr [[

[PATCH] D140508: [clang] fix -Wuninitialized for asm goto outputs on indirect edges.

2023-02-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 498158.
nickdesaulniers added a comment.

- final rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140508

Files:
  clang/lib/Analysis/UninitializedValues.cpp
  clang/test/Analysis/uninit-asm-goto.cpp

Index: clang/test/Analysis/uninit-asm-goto.cpp
===
--- clang/test/Analysis/uninit-asm-goto.cpp
+++ clang/test/Analysis/uninit-asm-goto.cpp
@@ -9,9 +9,9 @@
 return -1;
 }
 
+// test2: Expect no diagnostics
 int test2(int x) {
-  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}}
- // expected-note@-1 {{initialize the variable}}
+  int y;
   if (x < 42)
 asm goto("" : "+S"(x), "+D"(y) : "r"(x) :: indirect_1, indirect_2);
   else
@@ -20,29 +20,29 @@
 indirect_1:
   return -42;
 indirect_2:
-  return y; // expected-note {{uninitialized use occurs here}}
+  return y;
 }
 
+// test3: Expect no diagnostics
 int test3(int x) {
-  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}}
- // expected-note@-1 {{initialize the variable}}
+  int y;
   asm goto("" : "=&r"(y) : "r"(x) : : fail);
 normal:
   y += x;
   return y;
   if (x) {
 fail:
-return y; // expected-note {{uninitialized use occurs here}}
+return y;
   }
   return 0;
 }
 
+// test4: Expect no diagnostics
 int test4(int x) {
-  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}}
- // expected-note@-1 {{initialize the variable}}
+  int y;
   goto forward;
 backward:
-  return y; // expected-note {{uninitialized use occurs here}}
+  return y;
 forward:
   asm goto("" : "=r"(y) : "r"(x) : : backward);
   return y;
@@ -70,23 +70,40 @@
   return -1;
 }
 
+// test7: Expect no diagnostics.
 int test7(int z) {
-int x; // expected-warning {{variable 'x' is used uninitialized whenever its declaration is reached}}
-   // expected-note@-1 {{initialize the variable 'x' to silence this warning}}
+int x;
 if (z)
   asm goto ("":"=r"(x):::A1,A2);
 return 0;
 A1:
 A2:
-return x; // expected-note {{uninitialized use occurs here}}
+return x;
 }
 
+// test8: Expect no diagnostics
 int test8() {
-int x = 0; // expected-warning {{variable 'x' is used uninitialized whenever its declaration is reached}}
-   // expected-note@-1 {{variable 'x' is declared here}}
+int x = 0;
 asm goto ("":"=r"(x):::A1,A2);
 return 0;
 A1:
 A2:
-return x; // expected-note {{uninitialized use occurs here}}
+return x;
+}
+
+// test9: Expect no diagnostics
+int test9 (int x) {
+int y;
+asm goto("": "=r"(y) :::out);
+return 42;
+out:
+return y;
+}
+
+int test10() {
+  int y; // expected-note {{initialize the variable 'y' to silence this warning}}
+  asm goto(""out);
+  return 42;
+out:
+  return y; // expected-warning {{variable 'y' is uninitialized when used here}}
 }
Index: clang/lib/Analysis/UninitializedValues.cpp
===
--- clang/lib/Analysis/UninitializedValues.cpp
+++ clang/lib/Analysis/UninitializedValues.cpp
@@ -586,28 +586,6 @@
   continue;
 }
 
-if (AtPredExit == MayUninitialized) {
-  // If the predecessor's terminator is an "asm goto" that initializes
-  // the variable, then don't count it as "initialized" on the indirect
-  // paths.
-  CFGTerminator term = Pred->getTerminator();
-  if (const auto *as = dyn_cast_or_null(term.getStmt())) {
-const CFGBlock *fallthrough = *Pred->succ_begin();
-if (as->isAsmGoto() &&
-llvm::any_of(as->outputs(), [&](const Expr *output) {
-return vd == findVar(output).getDecl() &&
-llvm::any_of(as->labels(),
- [&](const AddrLabelExpr *label) {
-  return label->getLabel()->getStmt() == B->Label &&
-  B != fallthrough;
-});
-})) {
-  Use.setUninitAfterDecl();
-  continue;
-}
-  }
-}
-
 unsigned &SV = SuccsVisited[Pred->getBlockID()];
 if (!SV) {
   // When visiting the first successor of a block, mark all NULL
@@ -820,7 +798,8 @@
 // it's used on an indirect path, where it's not guaranteed to be
 // defined.
 if (const VarDecl *VD = findVar(Ex).getDecl())
-  vals[VD] = MayUninitialized;
+  if (vals[VD] != Initialized)
+vals[VD] = MayUninitialized;
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143205: [clang] add __has_extension(gnu_asm_goto_with_outputs_full)

2023-02-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 498159.
nickdesaulniers added a comment.

- final rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143205

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Features.def
  clang/test/Parser/asm-goto.c


Index: clang/test/Parser/asm-goto.c
===
--- clang/test/Parser/asm-goto.c
+++ clang/test/Parser/asm-goto.c
@@ -7,6 +7,9 @@
 #if !__has_extension(gnu_asm_goto_with_outputs)
 #error Extension 'gnu_asm_goto_with_outputs' should be available by default
 #endif
+#if !__has_extension(gnu_asm_goto_with_outputs_full)
+#error Extension 'gnu_asm_goto_with_outputs_full' should be available by 
default
+#endif
 
 int a, b, c, d, e, f, g, h, i, j, k, l;
 
Index: clang/include/clang/Basic/Features.def
===
--- clang/include/clang/Basic/Features.def
+++ clang/include/clang/Basic/Features.def
@@ -268,6 +268,7 @@
 EXTENSION(statement_attributes_with_gnu_syntax, true)
 EXTENSION(gnu_asm, LangOpts.GNUAsm)
 EXTENSION(gnu_asm_goto_with_outputs, LangOpts.GNUAsm)
+EXTENSION(gnu_asm_goto_with_outputs_full, LangOpts.GNUAsm)
 EXTENSION(matrix_types, LangOpts.MatrixTypes)
 EXTENSION(matrix_types_scalar_division, true)
 EXTENSION(cxx_attributes_on_using_declarations, LangOpts.CPlusPlus11)
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1591,6 +1591,12 @@
 Outputs may be used along any branches from the ``asm goto`` whether the
 branches are taken or not.
 
+Query for this feature with ``__has_extension(gnu_asm_goto_with_outputs)``.
+
+Prior to clang-16, the output may only be used safely when the indirect
+branches are not taken.  Query for this difference with
+``__has_extension(gnu_asm_goto_with_outputs_full)``.
+
 When using tied-outputs (i.e. outputs that are inputs and outputs, not just
 outputs) with the `+r` constraint, there is a hidden input that's created
 before the label, so numeric references to operands must account for that.
@@ -1618,8 +1624,6 @@
   return -1;
   }
 
-Query for this feature with ``__has_extension(gnu_asm_goto_with_outputs)``.
-
 Objective-C Features
 
 


Index: clang/test/Parser/asm-goto.c
===
--- clang/test/Parser/asm-goto.c
+++ clang/test/Parser/asm-goto.c
@@ -7,6 +7,9 @@
 #if !__has_extension(gnu_asm_goto_with_outputs)
 #error Extension 'gnu_asm_goto_with_outputs' should be available by default
 #endif
+#if !__has_extension(gnu_asm_goto_with_outputs_full)
+#error Extension 'gnu_asm_goto_with_outputs_full' should be available by default
+#endif
 
 int a, b, c, d, e, f, g, h, i, j, k, l;
 
Index: clang/include/clang/Basic/Features.def
===
--- clang/include/clang/Basic/Features.def
+++ clang/include/clang/Basic/Features.def
@@ -268,6 +268,7 @@
 EXTENSION(statement_attributes_with_gnu_syntax, true)
 EXTENSION(gnu_asm, LangOpts.GNUAsm)
 EXTENSION(gnu_asm_goto_with_outputs, LangOpts.GNUAsm)
+EXTENSION(gnu_asm_goto_with_outputs_full, LangOpts.GNUAsm)
 EXTENSION(matrix_types, LangOpts.MatrixTypes)
 EXTENSION(matrix_types_scalar_division, true)
 EXTENSION(cxx_attributes_on_using_declarations, LangOpts.CPlusPlus11)
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1591,6 +1591,12 @@
 Outputs may be used along any branches from the ``asm goto`` whether the
 branches are taken or not.
 
+Query for this feature with ``__has_extension(gnu_asm_goto_with_outputs)``.
+
+Prior to clang-16, the output may only be used safely when the indirect
+branches are not taken.  Query for this difference with
+``__has_extension(gnu_asm_goto_with_outputs_full)``.
+
 When using tied-outputs (i.e. outputs that are inputs and outputs, not just
 outputs) with the `+r` constraint, there is a hidden input that's created
 before the label, so numeric references to operands must account for that.
@@ -1618,8 +1624,6 @@
   return -1;
   }
 
-Query for this feature with ``__has_extension(gnu_asm_goto_with_outputs)``.
-
 Objective-C Features
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143670: Stop claiming we support [[carries_dependency]]

2023-02-16 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/Preprocessor/has_attribute.cpp:51
 // FIXME(201806L) CHECK: assert: 0
-// CHECK: carries_dependency: 200809L
+// CHECK: carries_dependency: 0
 // CHECK: deprecated: 201309L

aaron.ballman wrote:
> hubert.reinterpretcast wrote:
> > I'd trust this when I see the change to [cpp.cond]/6 arrive in CWG.
> This is consistent with how we handle `[[no_unique_address]]` (see line 59).
Is that driven by compatibility concerns on the platform though? For example, 
we might be doing something on line 59 to match MSVC.

Do we know if GCC intends to make a similar change for `carries_dependency`? It 
may help to be more explicit about why our situation is different from GCC's.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143670

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


[PATCH] D143301: [flang] Handle unsupported warning flags

2023-02-16 Thread Ethan Luis McDonough via Phabricator via cfe-commits
elmcdonough updated this revision to Diff 498164.
elmcdonough added a comment.

Change multiclass name for the sake of clarity.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143301

Files:
  clang/include/clang/Driver/Options.td
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/werror-all.f90
  flang/test/Driver/wextra-ok.f90

Index: flang/test/Driver/wextra-ok.f90
===
--- /dev/null
+++ flang/test/Driver/wextra-ok.f90
@@ -0,0 +1,11 @@
+! Ensure that supplying -Wextra into flang-new does not raise error
+! The first check should be changed if -Wextra is implemented
+
+! RUN: %flang -std=f2018 -Wextra %s 2>&1 | FileCheck %s --check-prefix=CHECK-OK
+! RUN: not %flang -std=f2018 -Wblah -Wextra %s 2>&1 | FileCheck %s --check-prefix=WRONG
+
+! CHECK-OK: argument unused during compilation: '-Wextra'
+! WRONG: Only `-Werror` is supported currently.
+
+program wextra_ok
+end program wextra_ok
Index: flang/test/Driver/werror-all.f90
===
--- /dev/null
+++ flang/test/Driver/werror-all.f90
@@ -0,0 +1,13 @@
+! Ensures that -Werror is read regardless of whether or not other -W
+! flags are present in the CLI args
+
+! RUN: not %flang -std=f2018 -Werror -Wextra %s 2>&1 | FileCheck %s --check-prefix=WRONG 
+! RUN: %flang -std=f2018 -Wextra -Wall %s 2>&1 | FileCheck %s --check-prefix=CHECK-OK
+
+! WRONG: Semantic errors in
+! CHECK-OK: FORALL index variable
+
+program werror_check_all
+  integer :: a(3)
+  forall (j=1:n) a(i) = 1
+end program werror_check_all
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -604,14 +604,17 @@
   // TODO: Currently throws a Diagnostic for anything other than -W,
   // this has to change when other -W's are supported.
   if (args.hasArg(clang::driver::options::OPT_W_Joined)) {
-if (args.getLastArgValue(clang::driver::options::OPT_W_Joined)
-.equals("error")) {
-  res.setWarnAsErr(true);
-} else {
-  const unsigned diagID =
-  diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
-"Only `-Werror` is supported currently.");
-  diags.Report(diagID);
+const auto &wArgs =
+args.getAllArgValues(clang::driver::options::OPT_W_Joined);
+for (const auto &wArg : wArgs) {
+  if (wArg == "error") {
+res.setWarnAsErr(true);
+  } else {
+const unsigned diagID =
+diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
+  "Only `-Werror` is supported currently.");
+diags.Report(diagID);
+  }
 }
   }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -235,6 +235,10 @@
 def clang_ignored_m_Group : OptionGroup<"">,
   Group, Flags<[Ignored]>;
 
+// Unsupported flang groups
+def flang_ignored_w_Group : OptionGroup<"">,
+  Group, Flags<[FlangOnlyOption, Ignored]>;
+
 // Group for clang options in the process of deprecation.
 // Please include the version that deprecated the flag as comment to allow
 // easier garbage collection.
@@ -4874,6 +4878,10 @@
   def fno_#NAME : Flag<["-"], "fno-"#name>;
 }
 
+multiclass FlangIgnoredDiagOpt {
+  def unsupported_warning_w#NAME : Flag<["-", "--"], "W"#name>, Group;
+}
+
 defm : BooleanFFlag<"keep-inline-functions">, Group;
 
 def fprofile_dir : Joined<["-"], "fprofile-dir=">, Group;
@@ -5034,6 +5042,34 @@
 defm underscoring : BooleanFFlag<"underscoring">, Group;
 defm whole_file : BooleanFFlag<"whole-file">, Group;
 
+// Unsupported flang W options
+defm : FlangIgnoredDiagOpt<"extra">;
+defm : FlangIgnoredDiagOpt<"aliasing">;
+defm : FlangIgnoredDiagOpt<"ampersand">;
+defm : FlangIgnoredDiagOpt<"array-bounds">;
+defm : FlangIgnoredDiagOpt<"c-binding-type">;
+defm : FlangIgnoredDiagOpt<"character-truncation">;
+defm : FlangIgnoredDiagOpt<"conversion">;
+defm : FlangIgnoredDiagOpt<"do-subscript">;
+defm : FlangIgnoredDiagOpt<"function-elimination">;
+defm : FlangIgnoredDiagOpt<"implicit-interface">;
+defm : FlangIgnoredDiagOpt<"implicit-procedure">;
+defm : FlangIgnoredDiagOpt<"intrinsic-shadow">;
+defm : FlangIgnoredDiagOpt<"use-without-only">;
+defm : FlangIgnoredDiagOpt<"intrinsics-std">;
+defm : FlangIgnoredDiagOpt<"line-truncation">;
+defm : FlangIgnoredDiagOpt<"no-align-commons">;
+defm : FlangIgnoredDiagOpt<"no-overwrite-recursive">;
+defm : FlangIgnoredDiagOpt<"no-tabs">;
+defm : FlangIgnoredDiagOpt<"real-q-constant">;
+defm : FlangIgnoredDiagOpt<"surprising">;
+defm : FlangIgnoredDiagOpt<"underflow">;
+defm : FlangIgnoredDiagOpt<"unused-parameter">;
+defm : FlangIgn

[PATCH] D144232: [PowerPC] Correctly use ELFv2 ABI on FreeBSD/powerpc64

2023-02-16 Thread Piotr Kubaj via Phabricator via cfe-commits
pkubaj created this revision.
pkubaj added reviewers: dim, nemanjai, adalava.
Herald added subscribers: shchenz, kbarton, hiraditya.
Herald added a project: All.
pkubaj requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Currently ELFv2 is mostly set, but some places still default to ELFv1.
While this mostly works, it breaks in particular when lld is used with LTO,
as reported in https://github.com/llvm/llvm-project/issues/46697.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144232

Files:
  clang/lib/Basic/Targets/PPC.h
  llvm/lib/Target/PowerPC/PPCTargetMachine.cpp


Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
===
--- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -233,6 +233,10 @@
   assert(Options.MCOptions.getABIName().empty() &&
  "Unknown target-abi option!");
 
+  if (TT.isOSFreeBSD() && TT.getArch() == Triple::ppc64 && 
(TT.getOSMajorVersion() == 0 || TT.getOSMajorVersion() >= 13)) {
+return PPCTargetMachine::PPC_ABI_ELFv2;
+  }
+
   switch (TT.getArch()) {
   case Triple::ppc64le:
 return PPCTargetMachine::PPC_ABI_ELFv2;
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -425,6 +425,9 @@
 } else if ((Triple.getArch() == llvm::Triple::ppc64le)) {
   DataLayout = "e-m:e-i64:64-n32:64";
   ABI = "elfv2";
+} else if (Triple.isOSFreeBSD() && (Triple.getOSMajorVersion() == 0 || 
Triple.getOSMajorVersion() >= 13)) {
+  DataLayout = "E-m:e-i64:64-n32:64";
+  ABI = "elfv2";
 } else {
   DataLayout = "E-m:e-i64:64-n32:64";
   ABI = "elfv1";


Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
===
--- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -233,6 +233,10 @@
   assert(Options.MCOptions.getABIName().empty() &&
  "Unknown target-abi option!");
 
+  if (TT.isOSFreeBSD() && TT.getArch() == Triple::ppc64 && (TT.getOSMajorVersion() == 0 || TT.getOSMajorVersion() >= 13)) {
+return PPCTargetMachine::PPC_ABI_ELFv2;
+  }
+
   switch (TT.getArch()) {
   case Triple::ppc64le:
 return PPCTargetMachine::PPC_ABI_ELFv2;
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -425,6 +425,9 @@
 } else if ((Triple.getArch() == llvm::Triple::ppc64le)) {
   DataLayout = "e-m:e-i64:64-n32:64";
   ABI = "elfv2";
+} else if (Triple.isOSFreeBSD() && (Triple.getOSMajorVersion() == 0 || Triple.getOSMajorVersion() >= 13)) {
+  DataLayout = "E-m:e-i64:64-n32:64";
+  ABI = "elfv2";
 } else {
   DataLayout = "E-m:e-i64:64-n32:64";
   ABI = "elfv1";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >