[PATCH] D138753: [AArch64TargetParser] getArchFeatures -> getArchFeature

2022-11-27 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson created this revision.
tmatheson added reviewers: lenary, pratlucas, dmgreen, tschuett, DavidSpickett.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: All.
tmatheson requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138753

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  llvm/include/llvm/Support/AArch64TargetParser.h
  llvm/lib/Support/AArch64TargetParser.cpp
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -1683,17 +1683,6 @@
   EXPECT_THAT(Features, ::testing::ContainerEq(AllFeatures));
 }
 
-TEST(TargetParserTest, AArch64ArchFeatures) {
-  std::vector Features;
-
-  for (auto AK : AArch64::ArchKinds) {
-if (AK == AArch64::ArchKind::INVALID)
-  EXPECT_FALSE(AArch64::getArchFeatures(AK, Features));
-else
-  EXPECT_TRUE(AArch64::getArchFeatures(AK, Features));
-  }
-}
-
 TEST(TargetParserTest, AArch64ArchV9toV8Conversion) {
   for (auto AK : AArch64::ArchKinds) {
 if (AK == AArch64::ArchKind::INVALID)
Index: llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
===
--- llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -6764,7 +6764,7 @@
 
   // Get the architecture and extension features.
   std::vector AArch64Features;
-  AArch64::getArchFeatures(ID, AArch64Features);
+  AArch64Features.push_back(AArch64::getArchFeature(ID));
   AArch64::getExtensionFeatures(AArch64::getDefaultExtensions("generic", ID),
 AArch64Features);
 
Index: llvm/lib/Support/AArch64TargetParser.cpp
===
--- llvm/lib/Support/AArch64TargetParser.cpp
+++ llvm/lib/Support/AArch64TargetParser.cpp
@@ -81,12 +81,8 @@
   .Default(CPU);
 }
 
-bool AArch64::getArchFeatures(AArch64::ArchKind AK,
-  std::vector &Features) {
-  if (AK == ArchKind::INVALID)
-return false;
-  Features.push_back(AArch64ARCHNames[static_cast(AK)].ArchFeature);
-  return true;
+StringRef AArch64::getArchFeature(AArch64::ArchKind AK) {
+  return AArch64ARCHNames[static_cast(AK)].ArchFeature;
 }
 
 StringRef AArch64::getArchName(AArch64::ArchKind AK) {
Index: llvm/include/llvm/Support/AArch64TargetParser.h
===
--- llvm/include/llvm/Support/AArch64TargetParser.h
+++ llvm/include/llvm/Support/AArch64TargetParser.h
@@ -158,7 +158,7 @@
 
 bool getExtensionFeatures(uint64_t Extensions,
   std::vector &Features);
-bool getArchFeatures(ArchKind AK, std::vector &Features);
+StringRef getArchFeature(ArchKind AK);
 
 StringRef getArchName(ArchKind AK);
 StringRef getSubArch(ArchKind AK);
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -135,8 +135,9 @@
 Features.push_back("+neon");
   } else {
 ArchKind = llvm::AArch64::parseCPUArch(CPU);
-if (!llvm::AArch64::getArchFeatures(ArchKind, Features))
+if (ArchKind == llvm::AArch64::ArchKind::INVALID)
   return false;
+Features.push_back(llvm::AArch64::getArchFeature(ArchKind));
 
 uint64_t Extension = llvm::AArch64::getDefaultExtensions(CPU, ArchKind);
 if (!llvm::AArch64::getExtensionFeatures(Extension, Features))
@@ -160,9 +161,9 @@
   llvm::AArch64::ArchKind ArchKind = llvm::AArch64::parseArch(Split.first);
   if (Split.first == "native")
 ArchKind = llvm::AArch64::getCPUArchKind(llvm::sys::getHostCPUName().str());
-  if (ArchKind == llvm::AArch64::ArchKind::INVALID ||
-  !llvm::AArch64::getArchFeatures(ArchKind, Features))
+  if (ArchKind == llvm::AArch64::ArchKind::INVALID)
 return false;
+  Features.push_back(llvm::AArch64::getArchFeature(ArchKind));
 
   // Enable SVE2 by default on Armv9-A.
   // It can still be disabled if +nosve2 is present.
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -796,12 +796,9 @@
 
   // Parse the architecture version, adding the required features to
   // Ret.Features.
-  std::vector FeatureStrs;
-  if (ArchKind == llvm::AArch64::ArchKind::INVALID ||
-  !llvm::AArch64::getArchFeatures(ArchKind, FeatureStrs))
+  if (ArchKind == llvm::AArch64::ArchKind::INVAL

[PATCH] D138755: [Clang][CodeGen] Use poison instead of undef for extra argument in __builtin_amdgcn_mov_dpp [NFC]

2022-11-27 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito created this revision.
ManuelJBrito added a project: AMDGPU.
Herald added subscribers: kosarev, jvesely.
Herald added a project: All.
ManuelJBrito requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Use poison instead of undef when emitting llvm.amdgcn.update.dpp for 
__builtin_amdgcn_mov_dpp.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138755

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl


Index: clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
===
--- clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
+++ clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
@@ -101,7 +101,7 @@
 }
 
 // CHECK-LABEL: @test_mov_dpp
-// CHECK: call i32 @llvm.amdgcn.update.dpp.i32(i32 undef, i32 %src, i32 0, i32 
0, i32 0, i1 false)
+// CHECK: call i32 @llvm.amdgcn.update.dpp.i32(i32 poison, i32 %src, i32 0, 
i32 0, i32 0, i1 false)
 void test_mov_dpp(global int* out, int src)
 {
   *out = __builtin_amdgcn_mov_dpp(src, 0, 0, 0, false);
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -16893,7 +16893,7 @@
   Args.push_back(EmitScalarExpr(E->getArg(I)));
 assert(Args.size() == 5 || Args.size() == 6);
 if (Args.size() == 5)
-  Args.insert(Args.begin(), llvm::UndefValue::get(Args[0]->getType()));
+  Args.insert(Args.begin(), llvm::PoisonValue::get(Args[0]->getType()));
 Function *F =
 CGM.getIntrinsic(Intrinsic::amdgcn_update_dpp, Args[0]->getType());
 return Builder.CreateCall(F, Args);


Index: clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
===
--- clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
+++ clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
@@ -101,7 +101,7 @@
 }
 
 // CHECK-LABEL: @test_mov_dpp
-// CHECK: call i32 @llvm.amdgcn.update.dpp.i32(i32 undef, i32 %src, i32 0, i32 0, i32 0, i1 false)
+// CHECK: call i32 @llvm.amdgcn.update.dpp.i32(i32 poison, i32 %src, i32 0, i32 0, i32 0, i1 false)
 void test_mov_dpp(global int* out, int src)
 {
   *out = __builtin_amdgcn_mov_dpp(src, 0, 0, 0, false);
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -16893,7 +16893,7 @@
   Args.push_back(EmitScalarExpr(E->getArg(I)));
 assert(Args.size() == 5 || Args.size() == 6);
 if (Args.size() == 5)
-  Args.insert(Args.begin(), llvm::UndefValue::get(Args[0]->getType()));
+  Args.insert(Args.begin(), llvm::PoisonValue::get(Args[0]->getType()));
 Function *F =
 CGM.getIntrinsic(Intrinsic::amdgcn_update_dpp, Args[0]->getType());
 return Builder.CreateCall(F, Args);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138755: [Clang][CodeGen] Use poison instead of undef for extra argument in __builtin_amdgcn_mov_dpp [NFC]

2022-11-27 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito added a reviewer: yaxunl.
ManuelJBrito added a comment.

Couldn't find documentation for this intrinsic, can you shed a light on whether 
or not this change is OK?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138755

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


[PATCH] D138749: [clang] Compare constraints before diagnosing mismatched ref qualifiers (GH58962)

2022-11-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Sema/SemaOverload.cpp:1324
+if ((NewRC != nullptr) != (OldRC != nullptr))
+  // RC are most certainly different - these are overloads.
+  return true;

I know it's preexisting but, I'm not sure that comment adds anything.
If we want to keep it, "requires clauses are different, - these are overloads."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138749

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


[clang] 131cddc - [AVR] Fix broken bitcast for aliases in non-zero address space

2022-11-27 Thread Ayke van Laethem via cfe-commits

Author: Ayke van Laethem
Date: 2022-11-27T15:27:42+01:00
New Revision: 131cddcba2c4c953a8a49d7adbf656cab9e9f1c7

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

LOG: [AVR] Fix broken bitcast for aliases in non-zero address space

This was triggered by some code in picolibc. The minimal version looks
like this:

double infinity(void) {
   return 5;
}

extern long double infinityl() __attribute__((__alias__("infinity")));

These two declarations have a different type (not because of the 'long
double', which is also 'double' in IR, but because infinityl has
variadic parameters). This led to a crash in the bitcast which assumed
address space 0.

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/avr/alias-avr.c

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index ae25767bc753a..133c603622f8e 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4002,7 +4002,8 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
 // (If function is requested for a definition, we always need to create a 
new
 // function, not just return a bitcast.)
 if (!IsForDefinition)
-  return llvm::ConstantExpr::getBitCast(Entry, Ty->getPointerTo());
+  return llvm::ConstantExpr::getBitCast(
+  Entry, Ty->getPointerTo(Entry->getAddressSpace()));
   }
 
   // This function doesn't have a complete type (for example, the return

diff  --git a/clang/test/CodeGen/avr/alias-avr.c 
b/clang/test/CodeGen/avr/alias-avr.c
index 88ba3a99eedb2..bcef98a9f5429 100644
--- a/clang/test/CodeGen/avr/alias-avr.c
+++ b/clang/test/CodeGen/avr/alias-avr.c
@@ -6,3 +6,8 @@ int mul(int a, int b) {
 
 // CHECK: @multiply ={{.*}} alias i16 (i16, i16), ptr addrspace(1) @mul
 int multiply(int x, int y) __attribute__((alias("mul")));
+
+// Make sure the correct address space is used when creating an alias that 
needs
+// a pointer cast.
+// CHECK: @smallmul = alias i8 (i16, i16), ptr addrspace(1) @mul
+char smallmul(int a, int b) __attribute__((alias("mul")));



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


[PATCH] D138681: [AVR] Fix broken bitcast for aliases in non-zero address space

2022-11-27 Thread Ayke via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG131cddcba2c4: [AVR] Fix broken bitcast for aliases in 
non-zero address space (authored by aykevl).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138681

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/avr/alias-avr.c


Index: clang/test/CodeGen/avr/alias-avr.c
===
--- clang/test/CodeGen/avr/alias-avr.c
+++ clang/test/CodeGen/avr/alias-avr.c
@@ -6,3 +6,8 @@
 
 // CHECK: @multiply ={{.*}} alias i16 (i16, i16), ptr addrspace(1) @mul
 int multiply(int x, int y) __attribute__((alias("mul")));
+
+// Make sure the correct address space is used when creating an alias that 
needs
+// a pointer cast.
+// CHECK: @smallmul = alias i8 (i16, i16), ptr addrspace(1) @mul
+char smallmul(int a, int b) __attribute__((alias("mul")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4002,7 +4002,8 @@
 // (If function is requested for a definition, we always need to create a 
new
 // function, not just return a bitcast.)
 if (!IsForDefinition)
-  return llvm::ConstantExpr::getBitCast(Entry, Ty->getPointerTo());
+  return llvm::ConstantExpr::getBitCast(
+  Entry, Ty->getPointerTo(Entry->getAddressSpace()));
   }
 
   // This function doesn't have a complete type (for example, the return


Index: clang/test/CodeGen/avr/alias-avr.c
===
--- clang/test/CodeGen/avr/alias-avr.c
+++ clang/test/CodeGen/avr/alias-avr.c
@@ -6,3 +6,8 @@
 
 // CHECK: @multiply ={{.*}} alias i16 (i16, i16), ptr addrspace(1) @mul
 int multiply(int x, int y) __attribute__((alias("mul")));
+
+// Make sure the correct address space is used when creating an alias that needs
+// a pointer cast.
+// CHECK: @smallmul = alias i8 (i16, i16), ptr addrspace(1) @mul
+char smallmul(int a, int b) __attribute__((alias("mul")));
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4002,7 +4002,8 @@
 // (If function is requested for a definition, we always need to create a new
 // function, not just return a bitcast.)
 if (!IsForDefinition)
-  return llvm::ConstantExpr::getBitCast(Entry, Ty->getPointerTo());
+  return llvm::ConstantExpr::getBitCast(
+  Entry, Ty->getPointerTo(Entry->getAddressSpace()));
   }
 
   // This function doesn't have a complete type (for example, the return
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91195: Add Annotation2MD pass to add !annotate metadata from llvm.global.annotations

2022-11-27 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.
Herald added subscribers: kosarev, ormris.
Herald added a project: All.



Comment at: llvm/lib/Transforms/IPO/Annotation2Metadata.cpp:51
+auto *StrGEP = dyn_cast(OpC->getOperand(1));
+if (!StrGEP || StrGEP->getNumOperands() < 2)
+  continue;

This needs to handle pure Constants / direct GlobalValue references. The test 
added here fails when converted to opaque pointers when all of the no-op 
bitcasts and getelementptrs are removed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91195

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


[PATCH] D133289: [C2X] N3007 Type inference for object definitions

2022-11-27 Thread Guillot Tony via Phabricator via cfe-commits
to268 updated this revision to Diff 478113.
to268 marked 5 inline comments as done.
to268 added a comment.

Added test cases and added an explicit `auto*` diagnostic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133289

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/C/C2x/n3007.c
  clang/test/CodeGen/auto.c
  clang/test/Parser/c2x-auto.c
  clang/test/Sema/c2x-auto.c
  clang/www/c_status.html

Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -1192,7 +1192,7 @@
 
   Type inference for object declarations
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3007.htm";>N3007
-  No
+  Clang 16
 
 
   constexpr for object definitions
Index: clang/test/Sema/c2x-auto.c
===
--- /dev/null
+++ clang/test/Sema/c2x-auto.c
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c2x %s
+
+void test_basic_types(void) {
+  auto undefined; // expected-error {{declaration of variable 'undefined' with deduced type 'auto' requires an initializer}}
+  auto auto_int = 4;
+  auto auto_long = 4UL;
+}
+
+void test_sizeof_typeof(void) {
+  auto auto_size = sizeof(auto);  // expected-error {{expected expression}}
+  typeof(auto) tpof = 4;  // expected-error {{expected expression}}
+}
+
+void test_casts(void) {
+  auto int_cast = (int)(4 + 3);
+  auto double_cast = (double)(1 / 3);
+  auto long_cast = (long)(4UL + 3UL);
+  auto auto_cast = (auto)(4 + 3); // expected-error {{expected expression}}
+}
+
+void test_compound_literral(void) {
+  auto int_cl = (int){13};
+  auto double_cl = (double){2.5};
+  auto array[] = { 1, 2, 3 }; // expected-error {{'array' declared as array of 'auto'}}
+
+  // FIXME: This should be accepted per C2x 6.5.2.5p4
+  auto auto_cl = (auto){13};  // expected-error {{'auto' is not allowed in a compound literal}}
+}
+
+void test_array_pointers(void) {
+  double array[3] = { 0 };
+  auto a = array;
+  auto b = &array;
+}
+
+void test_qualifiers(const int y) {
+  const auto a = 12;
+  auto b = y;
+  static auto c = 1UL;
+  int* pa = &a; // expected-warning {{initializing 'int *' with an expression of type 'const int *' discards qualifiers}}
+  const int* pb = &b;
+  int* pc = &c; // expected-warning {{incompatible pointer types initializing 'int *' with an expression of type 'unsigned long *'}}
+
+}
+
+void test_strings(void) {
+  auto str = "this is a string";
+  // FIXME: This should work for char*
+  auto str2[] = "this is a string"; // expected-error {{str2' declared as array of 'auto'}}
+  auto (str3) = "this is a string";
+  auto (((str4))) = "this is a string";
+}
+
+// FIXME: All these statements should fails (cannot declare a variable as a auto*)
+void test_pointers(void) {
+  auto a = 12;
+  auto *ptr = &a; // expected-error {{cannot declare 'ptr' as an explcit 'auto*' in C2x}}
+  auto *str = "this is a string"; // expected-error {{cannot declare 'str' as an explcit 'auto*' in C2x}}
+  const auto *str2 = "this is a string";  // expected-error {{cannot declare 'str2' as an explcit 'auto*' in C2x}}
+  auto *b = &a;   // expected-error {{cannot declare 'b' as an explcit 'auto*' in C2x}}
+  *b = &a;
+}
+
+void test_scopes(void) {
+  double a = 7;
+  double b = 9;
+  {
+auto a = a * a; // expected-error {{variable 'a' declared with deduced type 'auto' cannot appear in its own initializer}} \
+   expected-error {{variable 'a' declared with deduced type 'auto' cannot appear in its own initializer}}
+  }
+  {
+auto b = a * a;
+auto a = b;
+  }
+}
Index: clang/test/Parser/c2x-auto.c
===
--- /dev/null
+++ clang/test/Parser/c2x-auto.c
@@ -0,0 +1,123 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c2x -std=c2x %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c17 -std=c17 %s
+
+#define AUTO_MACRO(_NAME, ARG, ARG2, ARG3) \
+  auto _NAME = ARG + (ARG2 / ARG3);
+
+struct S {
+int a;
+auto b;   // c2x-error {{'auto' not allowed in struct member}} \
+ c17-error {{type name does not allow storage class to be specified}} \
+ c17-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int}}
+union {
+  char c;
+  auto smth;  // c2x-error {{'auto' not allowed in union member}} \
+ c17-error {{type name does not allow storage class to be specified}} \
+ c17-error {{type specifier missing, defaults to 'int'; ISO C99 and later do not support impl

[PATCH] D138489: [tsan] Add tsan support for loongarch64

2022-11-27 Thread Youling Tang via Phabricator via cfe-commits
tangyouling updated this revision to Diff 478124.
tangyouling added a comment.

Add the missing $t0-$t8 in internal_clone().


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138489

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
  compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_linux.h
  compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
  compiler-rt/lib/tsan/rtl/CMakeLists.txt
  compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
  compiler-rt/lib/tsan/rtl/tsan_platform.h
  compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
  compiler-rt/lib/tsan/rtl/tsan_rtl.h
  compiler-rt/lib/tsan/rtl/tsan_rtl_loongarch64.S
  compiler-rt/test/sanitizer_common/print_address.h
  compiler-rt/test/tsan/map32bit.cpp
  compiler-rt/test/tsan/mmap_large.cpp

Index: compiler-rt/test/tsan/mmap_large.cpp
===
--- compiler-rt/test/tsan/mmap_large.cpp
+++ compiler-rt/test/tsan/mmap_large.cpp
@@ -17,7 +17,7 @@
 int main() {
 #ifdef __x86_64__
   const size_t kLog2Size = 39;
-#elif defined(__mips64) || defined(__aarch64__)
+#elif defined(__mips64) || defined(__aarch64__) || defined(__loongarch_lp64)
   const size_t kLog2Size = 32;
 #elif defined(__powerpc64__)
   const size_t kLog2Size = 39;
Index: compiler-rt/test/tsan/map32bit.cpp
===
--- compiler-rt/test/tsan/map32bit.cpp
+++ compiler-rt/test/tsan/map32bit.cpp
@@ -12,6 +12,7 @@
 // XFAIL: aarch64
 // XFAIL: powerpc64
 // XFAIL: s390x
+// XFAIL: loongarch64
 
 // MAP_32BIT doesn't exist on OS X and NetBSD.
 // UNSUPPORTED: darwin,netbsd
Index: compiler-rt/test/sanitizer_common/print_address.h
===
--- compiler-rt/test/sanitizer_common/print_address.h
+++ compiler-rt/test/sanitizer_common/print_address.h
@@ -7,8 +7,9 @@
   va_start(ap, n);
   while (n--) {
 void *p = va_arg(ap, void *);
-#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \
-defined(__s390x__) || (defined(__riscv) && __riscv_xlen == 64)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) ||   \
+defined(__s390x__) || (defined(__riscv) && __riscv_xlen == 64) ||  \
+defined(__loongarch_lp64)
 // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not
 // match to the format used in the diagnotic message.
 fprintf(stderr, "0x%012lx ", (unsigned long) p);
Index: compiler-rt/lib/tsan/rtl/tsan_rtl_loongarch64.S
===
--- /dev/null
+++ compiler-rt/lib/tsan/rtl/tsan_rtl_loongarch64.S
@@ -0,0 +1,196 @@
+#include "sanitizer_common/sanitizer_asm.h"
+
+.section .text
+
+ASM_HIDDEN(__tsan_setjmp)
+.comm _ZN14__interception11real_setjmpE,8,8
+.globl ASM_SYMBOL_INTERCEPTOR(setjmp)
+ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(setjmp))
+ASM_SYMBOL_INTERCEPTOR(setjmp):
+  CFI_STARTPROC
+
+  // Save frame pointer and return address register
+  addi.d $sp, $sp, -32
+  st.d $ra, $sp, 24
+  st.d $fp, $sp, 16
+  CFI_DEF_CFA_OFFSET (32)
+  CFI_OFFSET (1, -8)
+  CFI_OFFSET (22, -16)
+
+  // Adjust the SP for previous frame
+  addi.d $fp, $sp, 32
+  CFI_DEF_CFA_REGISTER (22)
+
+  // Save env parameter
+  st.d $a0, $sp, 8
+  CFI_OFFSET (4, -24)
+
+  // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
+  addi.d  $a0, $fp, 0
+
+  // call tsan interceptor
+  bl  ASM_SYMBOL(__tsan_setjmp)
+
+  // Restore env parameter
+  ld.d $a0, $sp, 8
+  CFI_RESTORE (4)
+
+  // Restore frame/link register
+  ld.d $fp, $sp, 16
+  ld.d $ra, $sp, 24
+  addi.d $sp, $sp, 32
+  CFI_RESTORE (22)
+  CFI_RESTORE (1)
+  CFI_DEF_CFA (3, 0)
+
+  // tail jump to libc setjmp
+  la.local $a1, _ZN14__interception11real_setjmpE
+  ld.d $a1, $a1, 0
+  jr $a1
+
+  CFI_ENDPROC
+ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(setjmp))
+
+.comm _ZN14__interception12real__setjmpE,8,8
+.globl ASM_SYMBOL_INTERCEPTOR(_setjmp)
+ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(_setjmp))
+ASM_SYMBOL_INTERCEPTOR(_setjmp):
+  CFI_STARTPROC
+
+  // Save frame pointer and return address register
+  addi.d $sp, $sp, -32
+  st.d $ra, $sp, 24
+  st.d $fp, $sp, 16
+  CFI_DEF_CFA_OFFSET (32)
+  CFI_OFFSET (1, -8)
+  CFI_OFFSET (22, -16)
+
+  // Adjust the SP for previous frame
+  addi.d $fp, $sp, 32
+  CFI_DEF_CFA_REGISTER (22)
+
+  // Save env parameter
+  st.d $a0, $sp, 8
+  CFI_OFFSET (4, -24)
+
+  // Obtain SP, first argument to `void __tsan_setjmp(uptr sp)`
+  addi.d  $a0, $fp, 0
+
+  // call tsan interceptor
+  bl  ASM_SYMBOL(__tsan_setjmp)
+
+  // Restore env parameter
+  ld.d $a0, $sp, 8
+  CFI_RESTORE (4)
+
+  // Restore frame/link register
+  ld.d $fp, $sp, 16
+  ld.d $ra, $sp, 24

[PATCH] D138418: [LoongArch] Add remaining intrinsics for CRC check instructions

2022-11-27 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added inline comments.



Comment at: llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp:925
   llvm_unreachable("Unexpected Intrinsic.");
-case Intrinsic::loongarch_crc_w_d_w: {
-  Results.push_back(DAG.getNode(
-  ISD::TRUNCATE, DL, N->getValueType(0),
-  DAG.getNode(
-  LoongArchISD::CRC_W_D_W, DL, MVT::i64, N->getOperand(2),
-  DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, N->getOperand(3);
-  Results.push_back(N->getOperand(0));
-  break;
-}
+#define CRC_CASE_EXT_TWOOP(NAME, NODE) 
\
+  case Intrinsic::loongarch_##NAME: {  
\

SixWeining wrote:
> gonglingqin wrote:
> > xen0n wrote:
> > > What's a "two op", are you meaning "binary op" instead?
> > Yes, thank you for your correction!
> Seems the difference is not `binary op` or `unar op`. They are both `binary 
> op`s. The difference is that the former uses 2 `ISD::ANY_EXTEND` while the 
> latter only use one.
@xen0n What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138418

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


[PATCH] D138552: [docs] Document that the modules can improve the linking time

2022-11-27 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu abandoned this revision.
ChuanqiXu added a comment.

In D138552#3951462 , @dblaikie wrote:

>> And another problem here is, without LTO, the function definitions in other 
>> TU can't be inlined. But now, the function definitions in the module 
>> interface can be imported to the importee as AvaialableExternally linkage 
>> with optimization. The AvaialableExternally linkage is a special linkage 
>> which aims for the IPO. And the AvaialableExternally entities would be 
>> removed in the middle end after inlining. (I know there are arguments to 
>> remove the function definition in the module file.) So if we move not 
>> directly used things in .cpp files, the performance will be hurt. But it is 
>> not the case for modules (at least for now).
>
> Yeah, I think if we're planning to minimize pcms to the point where they 
> can't do code generation I guess we'll probably remove the indirect function 
> definitions/not use available externally, and rely on (Thin)LTO to provide 
> whole program optimization - so the guidance that modules reduces link time 
> wouldn't be true in that case.
>
> I think it's probably best to abandon this patch/not document/suggest that 
> this is a benefit people should expect from modules if it's one that'd go 
> away in the future anyway.

Got it. You're correct : )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138552

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


[PATCH] D137534: [C++20] [Modules] [ClangScanDeps] Allow clang-scan-deps to without specified compilation database in P1689 (3/3)

2022-11-27 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu marked an inline comment as done.
ChuanqiXu added inline comments.



Comment at: clang/tools/clang-scan-deps/ClangScanDeps.cpp:197
+llvm::cl::opt P1689TargetedCommand(
+"p1689-targeted-command", llvm::cl::Optional,
+llvm::cl::desc("Only supported for P1689, the targeted command of which "

ben.boeckel wrote:
> ChuanqiXu wrote:
> > ben.boeckel wrote:
> > > Can this be something like `--` so that I don't have to figure out how to 
> > > quote the thing (for the shell and whatever parsing Clang does 
> > > internally)?
> > Yeah, it can. Both `-` and `--` are accepted. I've updated the test to 
> > disambiguate.
> I don't mean the flag using `--` as a prefix. I don't care about that. What I 
> *do* care about is having to quote everything I'd give to `clang` here. I'd 
> vastly prefer something like:
> 
> ```
> clang-scan-deps -p1689-targeted-file-name=… -p1689-use-command -- -flags 
> --for ---clang --go --here
> ```
I got your point. But I prefer the current style if it won't be a problem for 
you to quote the options. In my imagination, it would be easier for the build 
systems to quote the flags than we synthesis things here. I guess there should 
already be one existing command line in the build system. And I feel like the 
current style may be more convenient and friendly for other tools to use. Could 
you try to use the current style?


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

https://reviews.llvm.org/D137534

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