[llvm-branch-commits] [clang] 08dbbaf - [RISCV][NFC] Refactor RISC-V vector intrinsic utils.

2022-05-11 Thread Kito Cheng via llvm-branch-commits

Author: Kito Cheng
Date: 2022-05-11T17:56:59+08:00
New Revision: 08dbbaf68d88a57e977d0674bddd0142e5d1e0b9

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

LOG: [RISCV][NFC] Refactor RISC-V vector intrinsic utils.

This patch is preparation for D111617, use class/struct/enum rather than
char/StringRef to present internal information as possible, that provide
more compact way to store those info and also easier to
serialize/deserialize.

And also that improve readability of the code, e.g. "v" vs
TypeProfile::Vector.

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

Added: 


Modified: 
clang/include/clang/Support/RISCVVIntrinsicUtils.h
clang/lib/Support/RISCVVIntrinsicUtils.cpp
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h 
b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
index 1a4947d0c3df3..ddd46fe1727c9 100644
--- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -9,7 +9,10 @@
 #ifndef CLANG_SUPPORT_RISCVVINTRINSICUTILS_H
 #define CLANG_SUPPORT_RISCVVINTRINSICUTILS_H
 
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/BitmaskEnum.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include 
 #include 
@@ -18,9 +21,128 @@
 namespace clang {
 namespace RISCV {
 
-using BasicType = char;
 using VScaleVal = llvm::Optional;
 
+// Modifier for vector type.
+enum class VectorTypeModifier : uint8_t {
+  NoModifier,
+  Log2EEW3,
+  Log2EEW4,
+  Log2EEW5,
+  Log2EEW6,
+  FixedSEW8,
+  FixedSEW16,
+  FixedSEW32,
+  FixedSEW64,
+  LFixedLog2LMULN3,
+  LFixedLog2LMULN2,
+  LFixedLog2LMULN1,
+  LFixedLog2LMUL0,
+  LFixedLog2LMUL1,
+  LFixedLog2LMUL2,
+  LFixedLog2LMUL3,
+  SFixedLog2LMULN3,
+  SFixedLog2LMULN2,
+  SFixedLog2LMULN1,
+  SFixedLog2LMUL0,
+  SFixedLog2LMUL1,
+  SFixedLog2LMUL2,
+  SFixedLog2LMUL3,
+};
+
+// Similar to basic type but used to describe what's kind of type related to
+// basic vector type, used to compute type info of arguments.
+enum class PrimitiveType : uint8_t {
+  Invalid,
+  Scalar,
+  Vector,
+  Widening2XVector,
+  Widening4XVector,
+  Widening8XVector,
+  MaskVector,
+  Void,
+  SizeT,
+  Ptr
diff ,
+  UnsignedLong,
+  SignedLong,
+};
+
+// Modifier for type, used for both scalar and vector types.
+enum class TypeModifier : uint8_t {
+  NoModifier = 0,
+  Pointer = 1 << 0,
+  Const = 1 << 1,
+  Immediate = 1 << 2,
+  UnsignedInteger = 1 << 3,
+  SignedInteger = 1 << 4,
+  Float = 1 << 5,
+  LMUL1 = 1 << 6,
+  MaxOffset = 6,
+  LLVM_MARK_AS_BITMASK_ENUM(LMUL1),
+};
+
+// TypeProfile is used to compute type info of arguments or return value.
+struct TypeProfile {
+  constexpr TypeProfile() = default;
+  constexpr TypeProfile(PrimitiveType PT) : PT(static_cast(PT)) {}
+  constexpr TypeProfile(PrimitiveType PT, TypeModifier TM)
+  : PT(static_cast(PT)), TM(static_cast(TM)) {}
+  constexpr TypeProfile(uint8_t PT, uint8_t VTM, uint8_t TM)
+  : PT(PT), VTM(VTM), TM(TM) {}
+
+  uint8_t PT = static_cast(PrimitiveType::Invalid);
+  uint8_t VTM = static_cast(VectorTypeModifier::NoModifier);
+  uint8_t TM = static_cast(TypeModifier::NoModifier);
+
+  std::string IndexStr() const {
+return std::to_string(PT) + "_" + std::to_string(VTM) + "_" +
+   std::to_string(TM);
+  };
+
+  bool operator!=(const TypeProfile &TP) const {
+return TP.PT != PT || TP.VTM != VTM || TP.TM != TM;
+  }
+  bool operator>(const TypeProfile &TP) const {
+return !(TP.PT <= PT && TP.VTM <= VTM && TP.TM <= TM);
+  }
+
+  static const TypeProfile Mask;
+  static const TypeProfile Vector;
+  static const TypeProfile VL;
+  static llvm::Optional
+  parseTypeProfile(llvm::StringRef PrototypeStr);
+};
+
+llvm::SmallVector parsePrototypes(llvm::StringRef Prototypes);
+
+// Basic type of vector type.
+enum class BasicType : uint8_t {
+  Unknown = 0,
+  Int8 = 1 << 0,
+  Int16 = 1 << 1,
+  Int32 = 1 << 2,
+  Int64 = 1 << 3,
+  Float16 = 1 << 4,
+  Float32 = 1 << 5,
+  Float64 = 1 << 6,
+  MaxOffset = 6,
+  LLVM_MARK_AS_BITMASK_ENUM(Float64),
+};
+
+// Type of vector type.
+enum ScalarTypeKind : uint8_t {
+  Void,
+  Size_t,
+  Ptr
diff _t,
+  UnsignedLong,
+  SignedLong,
+  Boolean,
+  SignedInteger,
+  UnsignedInteger,
+  Float,
+  Invalid,
+};
+
 // Exponential LMUL
 struct LMULType {
   int Log2LMUL;
@@ -32,20 +154,12 @@ struct LMULType {
   LMULType &operator*=(uint32_t RHS);
 };
 
+class RVVType;
+using RVVTypePtr = RVVType *;
+using RVVTypes = std::vector;
+
 // This class is compact representation of a valid and invalid RVVType.
 class RVVType {
-  enum ScalarTypeKind : uint32_t {
-Void,
-Size_t,
-Ptr
diff _t,
-UnsignedLong,
-SignedLong,
-

[llvm-branch-commits] [clang] 5b6216d - [RISCV] Lazily add RVV C intrinsics.

2022-05-11 Thread Kito Cheng via llvm-branch-commits

Author: Kito Cheng
Date: 2022-05-11T17:56:59+08:00
New Revision: 5b6216d6aa45c91bd348393eba8952f34735b736

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

LOG: [RISCV] Lazily add RVV C intrinsics.

Leverage the method OpenCL uses that adds C intrinsics when the lookup
failed. There is no need to define C intrinsics in the header file any
more. It could help to avoid the large header file to speed up the
compilation of RVV source code. Besides that, only the C intrinsics used
by the users will be added into the declaration table.

This patch is based on https://reviews.llvm.org/D103228 and inspired by
OpenCL implementation.

### Experimental Results

 TL;DR:

- Binary size of clang increase ~200k, which is +0.07%  for debug build and 
+0.13% for release build.
- Single file compilation speed up ~33x for debug build and ~8.5x for release 
build
- Regression time reduce ~10% (`ninja check-all`, enable all targets)

 Header size change
```
   |  size | LoC |
--
Before | 4,434,725 |  69,749 |
After  | 6,140 | 162 |
```

 Single File Compilation Time
Testcase:
```
#include 

vint32m1_t test_vadd_vv_vfloat32m1_t(vint32m1_t op1, vint32m1_t op2, size_t vl) 
{
  return vadd(op1, op2, vl);
}
```
# Debug build:
Before:
```
real0m19.352s
user0m19.252s
sys 0m0.092s
```

After:
```
real0m0.576s
user0m0.552s
sys 0m0.024s
```

~33x speed up for debug build

# Release build:
Before:
```
real0m0.773s
user0m0.741s
sys 0m0.032s
```

After:
```
real0m0.092s
user0m0.080s
sys 0m0.012s
```

~8.5x speed up for release build

 Regression time
Note: the failed case is `tools/llvm-debuginfod-find/debuginfod.test` which is 
unrelated to this patch.

# Debug build
Before:
```
Testing Time: 1358.38s
  Skipped  :11
  Unsupported  :   446
  Passed   : 75767
  Expectedly Failed:   190
  Failed   : 1
```
After
```
Testing Time: 1220.29s
  Skipped  :11
  Unsupported  :   446
  Passed   : 75767
  Expectedly Failed:   190
  Failed   : 1
```
# Release build
Before:
```
Testing Time: 381.98s
  Skipped  :12
  Unsupported  :  1407
  Passed   : 74765
  Expectedly Failed:   176
  Failed   : 1
```
After:
```
Testing Time: 346.25s
  Skipped  :12
  Unsupported  :  1407
  Passed   : 74765
  Expectedly Failed:   176
  Failed   : 1
```

 Binary size of clang

# Debug build
Before
```
   textdata bss dec hex filename
335261851   12726004 552812 348540667   14c64efb
bin/clang
```
After
```
   textdata bss dec hex filename
335442803   12798708 552940 348794451   14ca2e53
bin/clang
```
+253K, +0.07% code size

# Release build
Before
```
   textdata bss dec hex filename
144123975   8374648  483140 152981763   91e5103 bin/clang
```
After
```
   textdata bss dec hex filename
144255762   8447296  483268 153186326   9217016 bin/clang
```
+204K, +0.13%

Authored-by: Kito Cheng 
Co-Authored-by: Hsiangkai Wang 

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

Added: 
clang/lib/Sema/SemaRVVLookup.cpp

Modified: 
clang/include/clang/Basic/CMakeLists.txt
clang/include/clang/Basic/TokenKinds.def
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Support/RISCVVIntrinsicUtils.h
clang/lib/Parse/ParsePragma.cpp
clang/lib/Sema/CMakeLists.txt
clang/lib/Sema/SemaLookup.cpp
clang/lib/Support/RISCVVIntrinsicUtils.cpp
clang/utils/TableGen/RISCVVEmitter.cpp
clang/utils/TableGen/TableGen.cpp
clang/utils/TableGen/TableGenBackends.h

Removed: 




diff  --git a/clang/include/clang/Basic/CMakeLists.txt 
b/clang/include/clang/Basic/CMakeLists.txt
index 8cd891385a483..b930842ae8cfd 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -90,3 +90,6 @@ clang_tablegen(riscv_vector_builtins.inc 
-gen-riscv-vector-builtins
 clang_tablegen(riscv_vector_builtin_cg.inc -gen-riscv-vector-builtin-codegen
   SOURCE riscv_vector.td
   TARGET ClangRISCVVectorBuiltinCG)
+clang_tablegen(riscv_vector_builtin_sema.inc -gen-riscv-vector-builtin-sema
+  SOURCE riscv_vector.td
+  TARGET ClangRISCVVectorBuiltinSema)

diff  --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 7b65a15378050..fc159ab3114d0 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -908,6 +908,9 @@ PRAGMA_ANNOTATION(pragma_fp)
 // Annotation for the attribute pragma direc

[llvm-branch-commits] [libcxx] 5eb2262 - Bump version to 14.0.4

2022-05-11 Thread Tom Stellard via llvm-branch-commits

Author: Tom Stellard
Date: 2022-05-11T14:33:54-07:00
New Revision: 5eb22621bcd2c00514e2138ca0d541c229f08a92

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

LOG: Bump version to 14.0.4

Added: 


Modified: 
libcxx/CMakeLists.txt
libcxxabi/CMakeLists.txt
libunwind/CMakeLists.txt
llvm/CMakeLists.txt
llvm/utils/gn/secondary/llvm/version.gni
llvm/utils/lit/lit/__init__.py
llvm/utils/release/build_llvm_package.bat
utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h

Removed: 




diff  --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index caadccde26485..98baa73d61e5b 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -32,7 +32,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR 
LIBCXX_STANDALONE_BUIL
   project(libcxx CXX C)
 
   set(PACKAGE_NAME libcxx)
-  set(PACKAGE_VERSION 14.0.3)
+  set(PACKAGE_VERSION 14.0.4)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 

diff  --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 57f3f7f5712f1..aa49944ab1a2b 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -34,7 +34,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR 
LIBCXXABI_STANDALONE_B
   project(libcxxabi CXX C)
 
   set(PACKAGE_NAME libcxxabi)
-  set(PACKAGE_VERSION 14.0.3)
+  set(PACKAGE_VERSION 14.0.4)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 

diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 5e094050bf838..924752a358baa 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -33,7 +33,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR 
LIBUNWIND_STANDALONE_B
   project(libunwind LANGUAGES NONE)
 
   set(PACKAGE_NAME libunwind)
-  set(PACKAGE_VERSION 14.0.3)
+  set(PACKAGE_VERSION 14.0.4)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index c0c8f05514d89..d2982f1c7d36f 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -17,7 +17,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR)
   set(LLVM_VERSION_MINOR 0)
 endif()
 if(NOT DEFINED LLVM_VERSION_PATCH)
-  set(LLVM_VERSION_PATCH 3)
+  set(LLVM_VERSION_PATCH 4)
 endif()
 if(NOT DEFINED LLVM_VERSION_SUFFIX)
   set(LLVM_VERSION_SUFFIX)

diff  --git a/llvm/utils/gn/secondary/llvm/version.gni 
b/llvm/utils/gn/secondary/llvm/version.gni
index 8923e9be72a2e..4b94fbb6e293e 100644
--- a/llvm/utils/gn/secondary/llvm/version.gni
+++ b/llvm/utils/gn/secondary/llvm/version.gni
@@ -1,4 +1,4 @@
 llvm_version_major = 14
 llvm_version_minor = 0
-llvm_version_patch = 3
+llvm_version_patch = 4
 llvm_version = "$llvm_version_major.$llvm_version_minor.$llvm_version_patch"

diff  --git a/llvm/utils/lit/lit/__init__.py b/llvm/utils/lit/lit/__init__.py
index 8f4d5f0a29273..eb3d73e780300 100644
--- a/llvm/utils/lit/lit/__init__.py
+++ b/llvm/utils/lit/lit/__init__.py
@@ -2,7 +2,7 @@
 
 __author__ = 'Daniel Dunbar'
 __email__ = 'dan...@minormatter.com'
-__versioninfo__ = (14, 0, 3)
+__versioninfo__ = (14, 0, 4)
 __version__ = '.'.join(str(v) for v in __versioninfo__) + 'dev'
 
 __all__ = []

diff  --git a/llvm/utils/release/build_llvm_package.bat 
b/llvm/utils/release/build_llvm_package.bat
index 0ef58f7502841..1c55bcf120658 100755
--- a/llvm/utils/release/build_llvm_package.bat
+++ b/llvm/utils/release/build_llvm_package.bat
@@ -27,8 +27,8 @@ set 
python64_dir=C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python36
 for /f "usebackq" %%i in (`PowerShell ^(Get-Date^).ToString^('MMdd'^)`) do 
set datestamp=%%i
 
 set revision=%1
-set package_version=14.0.3-%revision:~0,8%
-set clang_format_vs_version=14.0.3.%datestamp%
+set package_version=14.0.4-%revision:~0,8%
+set clang_format_vs_version=14.0.4.%datestamp%
 set build_dir=llvm_package_%revision:~0,8%
 
 echo Revision: %revision%

diff  --git 
a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h 
b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h
index 1ec4e1f131fc4..437c6f4257c70 100644
--- a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h
+++ b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h
@@ -83,7 +83,7 @@
 #define LLVM_VERSION_PATCH 0
 
 /* LLVM version string */
-#define LLVM_VERSION_STRING "14.0.3"
+#define LLVM_VERSION_STRING "14.0.4"
 
 /* Whether LLVM records statistics for use with GetStatistics(),
  * PrintStatistics() or PrintStatisticsJSON()



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm

[llvm-branch-commits] [llvm] 9ed930e - [MC][test] Improve offset.s

2022-05-11 Thread Tom Stellard via llvm-branch-commits

Author: Fangrui Song
Date: 2022-05-11T14:45:04-07:00
New Revision: 9ed930e5cd74011f6d236d6a653138d076a5320f

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

LOG: [MC][test] Improve offset.s

(cherry picked from commit 67acc34e2ad89f18a6d66d72ddc30e77c5aff7d9)

Added: 


Modified: 
llvm/test/MC/ELF/offset.s

Removed: 




diff  --git a/llvm/test/MC/ELF/offset.s b/llvm/test/MC/ELF/offset.s
index d98405eda9901..8d7fd3cd1459c 100644
--- a/llvm/test/MC/ELF/offset.s
+++ b/llvm/test/MC/ELF/offset.s
@@ -1,77 +1,54 @@
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | 
llvm-readobj --symbols - | FileCheck %s
+# RUN: llvm-mc -filetype=obj -triple x86_64 %s -o %t
+# RUN: llvm-readelf -s %t | FileCheck %s
+
+## Test that a variable declared with "var = other_var + cst" is in the same
+## section as other_var and its value is the value of other_var + cst.
+## In addition, its st_size inherits from other_var.
+
+# CHECK:  0: {{.*}}
+# CHECK-NEXT:000142 OBJECT  GLOBAL DEFAULT [[#A:]] a
+# CHECK-NEXT:0005 0 NOTYPE  GLOBAL DEFAULT [[#A]]  b
+# CHECK-NEXT:000142 OBJECT  GLOBAL DEFAULT [[#A]]  a1
+# CHECK-NEXT:000242 OBJECT  GLOBAL DEFAULT [[#A]]  c
+# CHECK-NEXT:000d42 OBJECT  GLOBAL DEFAULT [[#A]]  d
+# CHECK-NEXT:000d42 OBJECT  GLOBAL DEFAULT [[#A]]  d1
+# CHECK-NEXT:000d42 OBJECT  GLOBAL DEFAULT [[#A]]  d2
+# CHECK-NEXT:000141 OBJECT  GLOBAL DEFAULT [[#A]]  e
+# CHECK-NEXT:000142 OBJECT  GLOBAL DEFAULT [[#A]]  e1
+# CHECK-NEXT:000142 OBJECT  GLOBAL DEFAULT [[#A]]  e2
+# CHECK-NEXT:000242 OBJECT  GLOBAL DEFAULT [[#A]]  e3
+# CHECK-NEXT:0005 0 NOTYPE  GLOBAL DEFAULT [[#A]]  test2_a
+# CHECK-NEXT:0005 0 NOTYPE  GLOBAL DEFAULT [[#A]]  test2_b
+# CHECK-NEXT:0009 0 NOTYPE  GLOBAL DEFAULT [[#A]]  test2_c
+# CHECK-NEXT:0009 0 NOTYPE  GLOBAL DEFAULT [[#A]]  test2_d
+# CHECK-NEXT:0004 0 NOTYPE  GLOBAL DEFAULT  ABStest2_e
+# CHECK-NEXT:000142 OBJECT  GLOBAL DEFAULT [[#A]]  e@v1
 
-// Test that a variable declared with "var = other_var + cst" is in the same
-// section as other_var and its value is the value of other_var + cst.
 
 .data
-.globl sym_a
-.size sym_a, 42
+.globl a
+.size a, 42
 .byte 42
-.type sym_a, @object
-sym_a:
-
-// CHECK:   Symbol {
-// CHECK: Name: sym_a
-// CHECK-NEXT:Value: 0x1
-// CHECK-NEXT:Size: 42
-// CHECK-NEXT:Binding: Global
-// CHECK-NEXT:Type: Object
-// CHECK-NEXT:Other: 0
-// CHECK-NEXT:Section: .data
-// CHECK-NEXT:  }
+.type a, @object
+a:
 
 .long 42
-.globl sym_b
-sym_b:
-.globl sym_c
-sym_c = sym_a
-// CHECK:   Symbol {
-// CHECK: Name: sym_c
-// CHECK-NEXT:Value: 0x1
-// CHECK-NEXT:Size: 42
-// CHECK-NEXT:Binding: Global
-// CHECK-NEXT:Type: Object
-// CHECK-NEXT:Other: 0
-// CHECK-NEXT:Section: .data
-// CHECK-NEXT:  }
-
-.globl sym_d
-sym_d = sym_a + 1
-// CHECK:   Symbol {
-// CHECK: Name: sym_d
-// CHECK-NEXT:Value: 0x2
-// CHECK-NEXT:Size: 42
-// CHECK-NEXT:Binding: Global
-// CHECK-NEXT:Type: Object
-// CHECK-NEXT:Other: 0
-// CHECK-NEXT:Section: .data
-// CHECK-NEXT:  }
+.globl b, a1, c, d, d1, d2, e, e1, e2, e3
+b:
+a1 = a
+c = a + 1
 
-.globl sym_e
-sym_e = sym_a + (sym_b - sym_a) * 3
-// CHECK:   Symbol {
-// CHECK: Name: sym_e
-// CHECK-NEXT:Value: 0xD
-// CHECK-NEXT:Size: 42
-// CHECK-NEXT:Binding: Global
-// CHECK-NEXT:Type: Object
-// CHECK-NEXT:Other: 0
-// CHECK-NEXT:Section: .data
-// CHECK-NEXT:  }
-
-
-.globl sym_f
-sym_f = sym_a + (1 - 1)
-// CHECK:   Symbol {
-// CHECK: Name: sym_f
-// CHECK-NEXT:Value: 0x1
-// CHECK-NEXT:Size: 42
-// CHECK-NEXT:Binding: Global
-// CHECK-NEXT:Type: Object
-// CHECK-NEXT:Other: 0
-// CHECK-NEXT:Section: .data
-// CHECK-NEXT:  }
+## These st_size fields inherit from a.
+d = a + (b - a) * 3
+.set d1, d
+d2 = d1
 
+e = a + (1 - 1)
+.size e, 41
+## FIXME These st_size fields inherit from e instead of a.
+.set e1, e
+.set e2, e1
+e3 = e1 + 1
 
 .globl test2_a
 .globl test2_b
@@ -85,48 +62,6 @@ test2_c:
 .long 0
 test2_d = test2_c
 test2_e = test2_d - test2_b
-// CHECK:  Symbol {
-// CHECK:Name: test2_a
-// CHECK-NEXT:   Value: 0x5
-// CHECK-NEXT:   Size: 0
-// CHECK-NEXT:   Binding: Global
-// CHECK-NEXT:   Type: None
-// CHECK-NEX

[llvm-branch-commits] [llvm] f3f90ec - [MC][ELF] Improve st_size propagation rule

2022-05-11 Thread Tom Stellard via llvm-branch-commits

Author: Fangrui Song
Date: 2022-05-11T14:45:04-07:00
New Revision: f3f90ec42ae674afe1858b4f7d9f270731872b80

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

LOG: [MC][ELF] Improve st_size propagation rule

`.symver foo, foo@ver` creates the MCSymbolELF `foo@ver` whose almost all
attributes (including st_size) should inherit from `foo` (GNU as behavior).

a041ef1bd8905f0d58e301c6830b183002ff1847 added st_size propagation which works
for many cases but fails for the following one:

```
.set __GLIBC_2_12_sys_errlist, _sys_errlist_internal
.type   __GLIBC_2_12_sys_errlist,@object
.size   __GLIBC_2_12_sys_errlist, 1080
.symver __GLIBC_2_12_sys_errlist, sys_errlist@GLIBC_2.12
...
_sys_errlist_internal:
.size   _sys_errlist_internal, 1072
```

`sys_errlist@GLIBC_2.12`'s st_size is 1072 (incorrect), which does not match
`__GLIBC_2_12_sys_errlist`'s st_size: 1080.

The problem is that `Base` is (the final) `_sys_errlist_internal` while we want
to respect (the intermediate) `__GLIBC_2_12_sys_errlist`'s st_size.
Fix this by following the MCSymbolRefExpr assignment chain and finding
the closest non-null `getSize()`, which covers most needs. Notably MCBinaryExpr
is not handled, but it is rare enough to matter.

Reviewed By: peter.smith

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

(cherry picked from commit e07dfa5328b0ca1465ae7b749e1ac2d994741e27)

Added: 


Modified: 
llvm/lib/MC/ELFObjectWriter.cpp
llvm/test/MC/ELF/offset.s

Removed: 




diff  --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 6fd2f7e7a7185..e6d28141dd06b 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -549,9 +549,27 @@ void ELFWriter::writeSymbol(SymbolTableWriter &Writer, 
uint32_t StringIndex,
   uint64_t Size = 0;
 
   const MCExpr *ESize = MSD.Symbol->getSize();
-  if (!ESize && Base)
+  if (!ESize && Base) {
+// For expressions like .set y, x+1, if y's size is unset, inherit from x.
 ESize = Base->getSize();
 
+// For `.size x, 2; y = x; .size y, 1; z = y; z1 = z; .symver y, y@v1`, z,
+// z1, and y@v1's st_size equals y's. However, `Base` is `x` which will 
give
+// us 2. Follow the MCSymbolRefExpr assignment chain, which covers most
+// needs. MCBinaryExpr is not handled.
+const MCSymbolELF *Sym = &Symbol;
+while (Sym->isVariable()) {
+  if (auto *Expr =
+  dyn_cast(Sym->getVariableValue(false))) {
+Sym = cast(&Expr->getSymbol());
+if (!Sym->getSize())
+  continue;
+ESize = Sym->getSize();
+  }
+  break;
+}
+  }
+
   if (ESize) {
 int64_t Res;
 if (!ESize->evaluateKnownAbsolute(Res, Layout))

diff  --git a/llvm/test/MC/ELF/offset.s b/llvm/test/MC/ELF/offset.s
index 8d7fd3cd1459c..199675dd2b738 100644
--- a/llvm/test/MC/ELF/offset.s
+++ b/llvm/test/MC/ELF/offset.s
@@ -14,15 +14,15 @@
 # CHECK-NEXT:000d42 OBJECT  GLOBAL DEFAULT [[#A]]  d1
 # CHECK-NEXT:000d42 OBJECT  GLOBAL DEFAULT [[#A]]  d2
 # CHECK-NEXT:000141 OBJECT  GLOBAL DEFAULT [[#A]]  e
-# CHECK-NEXT:000142 OBJECT  GLOBAL DEFAULT [[#A]]  e1
-# CHECK-NEXT:000142 OBJECT  GLOBAL DEFAULT [[#A]]  e2
+# CHECK-NEXT:000141 OBJECT  GLOBAL DEFAULT [[#A]]  e1
+# CHECK-NEXT:000141 OBJECT  GLOBAL DEFAULT [[#A]]  e2
 # CHECK-NEXT:000242 OBJECT  GLOBAL DEFAULT [[#A]]  e3
 # CHECK-NEXT:0005 0 NOTYPE  GLOBAL DEFAULT [[#A]]  test2_a
 # CHECK-NEXT:0005 0 NOTYPE  GLOBAL DEFAULT [[#A]]  test2_b
 # CHECK-NEXT:0009 0 NOTYPE  GLOBAL DEFAULT [[#A]]  test2_c
 # CHECK-NEXT:0009 0 NOTYPE  GLOBAL DEFAULT [[#A]]  test2_d
 # CHECK-NEXT:0004 0 NOTYPE  GLOBAL DEFAULT  ABStest2_e
-# CHECK-NEXT:000142 OBJECT  GLOBAL DEFAULT [[#A]]  e@v1
+# CHECK-NEXT:000141 OBJECT  GLOBAL DEFAULT [[#A]]  e@v1
 
 
 .data
@@ -45,7 +45,8 @@ d2 = d1
 
 e = a + (1 - 1)
 .size e, 41
-## FIXME These st_size fields inherit from e instead of a.
+## These st_size fields inherit from e instead of a.
+## TODO e3's st_size should inherit from e.
 .set e1, e
 .set e2, e1
 e3 = e1 + 1



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


[llvm-branch-commits] [clang] 869c1d7 - [Clang] Fix the guaranteed alignment of memory returned by malloc/new on OpenBSD

2022-05-11 Thread Tom Stellard via llvm-branch-commits

Author: Mark Kettenis
Date: 2022-05-11T14:45:05-07:00
New Revision: 869c1d7d09025ae6a30acd9423eb3febd96a143c

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

LOG: [Clang] Fix the guaranteed alignment of memory returned by malloc/new on 
OpenBSD

The guaranteed alignment is 16 bytes on OpenBSD.

(cherry picked from commit c7ee0b8bda8b32a800bc01e9151b364446a6e1b1)

Added: 


Modified: 
clang/lib/Basic/TargetInfo.cpp
clang/test/Preprocessor/init-arm.c
clang/test/Preprocessor/init-ppc.c
clang/test/Preprocessor/init-x86.c

Removed: 




diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index e3a2f30febe75..188ffb5f2f78c 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -69,11 +69,11 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) {
   // From the glibc documentation, on GNU systems, malloc guarantees 16-byte
   // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
   // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html.
-  // This alignment guarantee also applies to Windows and Android. On Darwin,
-  // the alignment is 16 bytes on both 64-bit and 32-bit systems.
+  // This alignment guarantee also applies to Windows and Android. On Darwin
+  // and OpenBSD, the alignment is 16 bytes on both 64-bit and 32-bit systems.
   if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
 NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
-  else if (T.isOSDarwin())
+  else if (T.isOSDarwin() || T.isOSOpenBSD())
 NewAlign = 128;
   else
 NewAlign = 0; // Infer from basic type alignment.

diff  --git a/clang/test/Preprocessor/init-arm.c 
b/clang/test/Preprocessor/init-arm.c
index 32eb2c513f8b0..8038c24d30732 100644
--- a/clang/test/Preprocessor/init-arm.c
+++ b/clang/test/Preprocessor/init-arm.c
@@ -199,6 +199,9 @@
 // RUN: %clang_cc1 -E -dM -triple=armv7-apple-ios7.0 -x c++ < /dev/null | 
FileCheck -match-full-lines -check-prefix ARM-DARWIN-CXX %s
 // ARM-DARWIN-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
 
+// RUN: %clang_cc1 -E -dM -triple=arm-unknown-openbsd -x c++ < /dev/null | 
FileCheck -match-full-lines -check-prefix ARM-OPENBSD-CXX %s
+// ARM-OPENBSD-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
+
 // RUN: %clang_cc1 -dM -ffreestanding -triple arm-none-none -target-abi 
apcs-gnu -E /dev/null -o - | FileCheck -match-full-lines -check-prefix 
ARM-APCS-GNU %s
 // ARM-APCS-GNU: #define __INTPTR_TYPE__ int
 // ARM-APCS-GNU: #define __PTRDIFF_TYPE__ int

diff  --git a/clang/test/Preprocessor/init-ppc.c 
b/clang/test/Preprocessor/init-ppc.c
index 611b16dfb8f7e..f82a81961d401 100644
--- a/clang/test/Preprocessor/init-ppc.c
+++ b/clang/test/Preprocessor/init-ppc.c
@@ -1176,3 +1176,6 @@
 // PPC-DARWIN:#define __WINT_WIDTH__ 32
 // PPC-DARWIN:#define __powerpc__ 1
 // PPC-DARWIN:#define __ppc__ 1
+
+// RUN: %clang_cc1 -E -dM -triple=powerpc-unknown-openbsd -x c++ < /dev/null | 
FileCheck -match-full-lines -check-prefix PPC-OPENBSD-CXX %s
+// PPC-OPENBSD-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL

diff  --git a/clang/test/Preprocessor/init-x86.c 
b/clang/test/Preprocessor/init-x86.c
index 527cd39508889..5cf4ed71b4015 100644
--- a/clang/test/Preprocessor/init-x86.c
+++ b/clang/test/Preprocessor/init-x86.c
@@ -1732,3 +1732,6 @@
 // X86_64-NETBSD:#define __amd64__ 1
 // X86_64-NETBSD:#define __x86_64 1
 // X86_64-NETBSD:#define __x86_64__ 1
+
+// RUN: %clang_cc1 -E -dM -triple=i386-unknown-openbsd -x c++ < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-OPENBSD-CXX %s
+// I386-OPENBSD-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL



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


[llvm-branch-commits] [clang] 50d4a84 - Fix test for c7ee0b8bda8b32a800bc01e9151b364446a6e1b1

2022-05-11 Thread Tom Stellard via llvm-branch-commits

Author: Brad Smith
Date: 2022-05-11T14:45:05-07:00
New Revision: 50d4a84152c67ee16b2e54ddca4f6cca32890bb5

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

LOG: Fix test for c7ee0b8bda8b32a800bc01e9151b364446a6e1b1

OpenBSD/sparc is dead and support was removed awhile ago.

(cherry picked from commit 7898c79b742f0dda6ec47b572f727fcd6d8ff54a)

Added: 


Modified: 
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index dd645bf6003ce..46cfcd6dbb0aa 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -878,9 +878,7 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=sparc-none-none < /dev/null | FileCheck -match-full-lines -check-prefix 
SPARC -check-prefix SPARC-DEFAULT %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=sparc-rtems-elf < /dev/null | FileCheck -match-full-lines -check-prefix 
SPARC -check-prefix SPARC-DEFAULT %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=sparc-none-netbsd < /dev/null | FileCheck -match-full-lines 
-check-prefix SPARC -check-prefix SPARC-NETOPENBSD %s
-// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=sparc-none-openbsd < /dev/null | FileCheck -match-full-lines 
-check-prefix SPARC -check-prefix SPARC-NETOPENBSD %s
 // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=sparc-none-none < /dev/null | FileCheck -match-full-lines -check-prefix 
SPARC -check-prefix SPARC-DEFAULT -check-prefix SPARC-DEFAULT-CXX %s
-// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=sparc-none-openbsd < /dev/null | FileCheck -match-full-lines 
-check-prefix SPARC -check-prefix SPARC-NETOPENBSD -check-prefix 
SPARC-NETOPENBSD-CXX %s
 //
 // SPARC-NOT:#define _LP64
 // SPARC:#define __BIGGEST_ALIGNMENT__ 8
@@ -1030,7 +1028,6 @@
 // SPARC-NETOPENBSD:#define __SIZE_TYPE__ long unsigned int
 // SPARC:#define __SIZE_WIDTH__ 32
 // SPARC-DEFAULT-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
-// SPARC-NETOPENBSD-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8UL
 // SPARC:#define __UINT16_C_SUFFIX__
 // SPARC:#define __UINT16_MAX__ 65535
 // SPARC:#define __UINT16_TYPE__ unsigned short



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


[llvm-branch-commits] [clang] 5c4cf01 - [Driver][Linux] Remove D.Dir+"/../lib" from default search paths for LLVM_ENABLE_RUNTIMES builds

2022-05-11 Thread Tom Stellard via llvm-branch-commits

Author: Fangrui Song
Date: 2022-05-11T14:45:04-07:00
New Revision: 5c4cf01f47da35816a252c4656b36404b4b8615c

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

LOG: [Driver][Linux] Remove D.Dir+"/../lib" from default search paths for 
LLVM_ENABLE_RUNTIMES builds

The rule was added in 2014 to support -stdlib=libc++ and -lc++ without
specifying -L, when D.Dir is not a well-known system library directory like
/usr/lib /usr/lib64. This rule turns out to get in the way with (-m32 for
64-bit clang) or (-m64 for 32-bit clang) for Gentoo :
https://github.com/llvm/llvm-project/issues/54515

Nowadays LLVM_ENABLE_RUNTIMES is the only recommended way building libc++ and
LLVM_ENABLE_PROJECTS=libc++ is deprecated. LLVM_ENABLE_RUNTIMES builds libc++
in D.Dir+"/../lib/${triple}/". The rule is unneeded. Also reverts D108286.

Gentoo uses a modified LLVM_ENABLE_RUNTIMES that installs libc++.so in
well-known paths like /usr/lib64 and /usr/lib which are already covered by
nearby search paths.

Implication: if a downstream package needs something like -lLLVM-15git and uses
libLLVM-15git.so not in a well-known path, it needs to supply -L
D.Dir+"/../lib" explicitly (e.g. via LLVMConfig.cmake), instead of relying on
the previous default search path.

Reviewed By: mgorny

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

(cherry picked from commit afaefb671fe12e7788d3e8de6b6193b935fbf16c)

Added: 


Modified: 
clang/lib/Driver/ToolChains/Linux.cpp
clang/test/Driver/linux-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index f85c04df4f6c9..83cb41159de7e 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -301,18 +301,12 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, 
const ArgList &Args)
 
   Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths);
 
-  // Similar to the logic for GCC above, if we are currently running Clang
-  // inside of the requested system root, add its parent library path to those
-  // searched.
-  // FIXME: It's not clear whether we should use the driver's installed
-  // directory ('Dir' below) or the ResourceDir.
-  if (StringRef(D.Dir).startswith(SysRoot)) {
-// Even if OSLibDir != "lib", this is needed for Clang in the build
-// directory (not installed) to find libc++.
+  // The deprecated -DLLVM_ENABLE_PROJECTS=libcxx configuration installs
+  // libc++.so in D.Dir+"/../lib/". Detect this path.
+  // TODO Remove once LLVM_ENABLE_PROJECTS=libcxx is unsupported.
+  if (StringRef(D.Dir).startswith(SysRoot) &&
+  D.getVFS().exists(D.Dir + "/../lib/libc++.so"))
 addPathIfExists(D, D.Dir + "/../lib", Paths);
-if (OSLibDir != "lib")
-  addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths);
-  }
 
   addPathIfExists(D, SysRoot + "/lib", Paths);
   addPathIfExists(D, SysRoot + "/usr/lib", Paths);

diff  --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
index b70b712c2eb77..08910d95843fa 100644
--- a/clang/test/Driver/linux-ld.c
+++ b/clang/test/Driver/linux-ld.c
@@ -530,7 +530,6 @@
 // CHECK-BASIC-LIBCXX-INSTALL: "-internal-isystem" 
"[[SYSROOT]]/usr/bin/../include/c++/v1"
 // CHECK-BASIC-LIBCXX-INSTALL: "-internal-isystem" 
"[[SYSROOT]]/usr/local/include"
 // CHECK-BASIC-LIBCXX-INSTALL: "--sysroot=[[SYSROOT]]"
-// CHECK-BASIC-LIBCXX-INSTALL: "-L[[SYSROOT]]/usr/bin/../lib"
 //
 // Test that we can use -stdlib=libc++ in a build system even when it
 // occasionally links C code instead of C++ code.
@@ -547,7 +546,6 @@
 // CHECK-BASIC-LIBCXX-C-LINK-NOT: "-internal-isystem" 
"[[SYSROOT]]/usr/bin/../include/c++/v1"
 // CHECK-BASIC-LIBCXX-C-LINK: "-internal-isystem" 
"[[SYSROOT]]/usr/local/include"
 // CHECK-BASIC-LIBCXX-C-LINK: "--sysroot=[[SYSROOT]]"
-// CHECK-BASIC-LIBCXX-C-LINK: "-L[[SYSROOT]]/usr/bin/../lib"
 //
 // Check multi arch support on Ubuntu 12.04 LTS.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \



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


[llvm-branch-commits] [clang] cd59758 - [HIP] Fix HIP include path

2022-05-11 Thread Tom Stellard via llvm-branch-commits

Author: Yaxun (Sam) Liu
Date: 2022-05-11T14:45:05-07:00
New Revision: cd597588217a69b413ad44ba11d650b576045e2b

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

LOG: [HIP] Fix HIP include path

The clang compiler prepends the HIP header include paths to the search
list using -internal-isystem when building for the HIP language. This
prevents warnings related to things like reserved identifiers when
including the HIP headers even when ROCm is installed in a non-system
directory, such as /opt/rocm.

However, when HIP is installed in /usr, then the prepended include
path would be /usr/include. That is a problem, because the C standard
library headers are stored in /usr/include and the C++ standard
library headers must come before the C library headers in the search
path list (because the C++ standard library headers use #include_next
to include the C standard library headers).

While the HIP wrapper headers _do_ need to be earlier in the search
than the C++ headers, those headers get their own subdirectory and
their own explicit -internal-isystem argument. This include path is for
 and , which do not require a
particular search ordering with respect to the C or C++ headers. Thus,
HIP include path is added after other system include paths.

With contribution from Cordell Bloor.

Reviewed by: Artem Belevich

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

(cherry picked from commit 6730b44480fcce18bfbbae0c46719250e9eae425)

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/test/Driver/hip-include-path.hip
clang/test/Driver/rocm-detect.hip

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 43ce33750ebac..9638fa2ecfcab 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -510,7 +510,7 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const 
ArgList &DriverArgs,
 return;
   }
 
-  CC1Args.push_back("-internal-isystem");
+  CC1Args.push_back("-idirafter");
   CC1Args.push_back(DriverArgs.MakeArgString(getIncludePath()));
   if (UsesRuntimeWrapper)
 CC1Args.append({"-include", "__clang_hip_runtime_wrapper.h"});

diff  --git a/clang/test/Driver/hip-include-path.hip 
b/clang/test/Driver/hip-include-path.hip
index dce42f58fdf5e..92f2fab6c24cf 100644
--- a/clang/test/Driver/hip-include-path.hip
+++ b/clang/test/Driver/hip-include-path.hip
@@ -19,24 +19,24 @@
 // COMMON-LABEL: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
 // CLANG-SAME: "-internal-isystem" 
"{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include/cuda_wrappers"
 // NOCLANG-NOT: "{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include/cuda_wrappers"
-// HIP-SAME: "-internal-isystem" "{{[^"]*}}Inputs/rocm/include"
-// NOHIP-NOT: "{{.*}}Inputs/rocm/include"
+// HIP-SAME: "-idirafter" "{{[^"]*}}Inputs/rocm/include"
 // HIP-SAME: "-include" "__clang_hip_runtime_wrapper.h"
 // NOHIP-NOT: "-include" "__clang_hip_runtime_wrapper.h"
 // skip check of standard C++ include path
 // CLANG-SAME: "-internal-isystem" 
"{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include"
 // NOCLANG-NOT: "{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include"
+// NOHIP-NOT: "{{.*}}Inputs/rocm/include"
 
 // COMMON-LABEL: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
 // CLANG-SAME: "-internal-isystem" 
"{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include/cuda_wrappers"
 // NOCLANG-NOT: "{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include/cuda_wrappers"
-// HIP-SAME: "-internal-isystem" "{{[^"]*}}Inputs/rocm/include"
-// NOHIP-NOT: "{{.*}}Inputs/rocm/include"
+// HIP-SAME: "-idirafter" "{{[^"]*}}Inputs/rocm/include"
 // HIP-SAME: "-include" "__clang_hip_runtime_wrapper.h"
 // NOHIP-NOT: "-include" "__clang_hip_runtime_wrapper.h"
 // skip check of standard C++ include path
 // CLANG-SAME: "-internal-isystem" 
"{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include"
 // NOCLANG-NOT: "{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include"
+// NOHIP-NOT: "{{.*}}Inputs/rocm/include"
 
 // RUN: %clang -c -### -target x86_64-unknown-linux-gnu --cuda-gpu-arch=gfx900 
\
 // RUN:   -std=c++11 --rocm-path=%S/Inputs/rocm -nogpulib %s 2>&1 \
@@ -45,7 +45,7 @@
 // ROCM35-LABEL: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
 // ROCM35-NOT: "{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include/cuda_wrappers"
 // ROCM35-SAME: "-internal-isystem" "{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}"
-// ROCM35-SAME: "-internal-isystem" "{{[^"]*}}Inputs/rocm/include"
+// ROCM35-SAME: "-idirafter" "{{[^"]*}}Inputs/rocm/include"
 // ROCM35-NOT: "-include" "__clang_hip_runtime_wrapper.h"
 // skip check of standard C++ include path
 // ROCM35-SAME: "-internal-isystem" 
"{{[^"]*}}/lib{{[^"]*}}/clang/{{[^"]*}}/include"

diff  --git a/clang/test/Driver/rocm-detect.hip 
b/clang/test/Driver/rocm-detect.hip
index 3ab0175cf1f15..7166c42e9691e 10

[llvm-branch-commits] [llvm] 39e9097 - [InstCombine] add scalable vector test for logical select; NFC

2022-05-11 Thread Tom Stellard via llvm-branch-commits

Author: Sanjay Patel
Date: 2022-05-11T14:45:05-07:00
New Revision: 39e909731a11f14006b347a1510ab3b9a93c2c70

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

LOG: [InstCombine] add scalable vector test for logical select; NFC

D124997 shows that the code is not ready to handle scalable vectors,
so add some more coverage for a potential crashing case.

(cherry picked from commit 7bad1d281c798929ae1be44b8c8a1e0713151ea9)

Added: 


Modified: 
llvm/test/Transforms/InstCombine/logical-select.ll

Removed: 




diff  --git a/llvm/test/Transforms/InstCombine/logical-select.ll 
b/llvm/test/Transforms/InstCombine/logical-select.ll
index b847d92c8c095..f6375616d8995 100644
--- a/llvm/test/Transforms/InstCombine/logical-select.ll
+++ b/llvm/test/Transforms/InstCombine/logical-select.ll
@@ -708,6 +708,25 @@ define <2 x i64> @bitcast_vec_cond(<16 x i1> %cond, <2 x 
i64> %c, <2 x i64> %d)
   ret <2 x i64> %r
 }
 
+define  @bitcast_vec_condi_scalable( 
%cond,  %c,  %d) {
+; CHECK-LABEL: @bitcast_vec_condi_scalable(
+; CHECK-NEXT:[[S:%.*]] = sext  [[COND:%.*]] to 
+; CHECK-NEXT:[[T9:%.*]] = bitcast  [[S]] to 
+; CHECK-NEXT:[[NOTT9:%.*]] = xor  [[T9]], shufflevector 
( insertelement ( poison, i64 -1, i32 0), 
 poison,  zeroinitializer)
+; CHECK-NEXT:[[T11:%.*]] = and  [[NOTT9]], [[C:%.*]]
+; CHECK-NEXT:[[T12:%.*]] = and  [[T9]], [[D:%.*]]
+; CHECK-NEXT:[[R:%.*]] = or  [[T11]], [[T12]]
+; CHECK-NEXT:ret  [[R]]
+;
+  %s = sext  %cond to 
+  %t9 = bitcast  %s to 
+  %nott9 = xor  %t9, shufflevector ( 
insertelement ( poison, i64 -1, i32 0),  
poison,  zeroinitializer)
+  %t11 = and  %nott9, %c
+  %t12 = and  %t9, %d
+  %r = or  %t11, %t12
+  ret  %r
+}
+
 ; Negative test - bitcast of condition from wide source element type cannot be 
converted to select.
 
 define <8 x i3> @bitcast_vec_cond_commute1(<3 x i1> %cond, <8 x i3> %pc, <8 x 
i3> %d) {



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


[llvm-branch-commits] [llvm] 0108630 - [InstCombine] Fix scalable-vector bitwise select matching

2022-05-11 Thread Tom Stellard via llvm-branch-commits

Author: Fraser Cormack
Date: 2022-05-11T14:45:05-07:00
New Revision: 0108630f8bc5d520400247d7834a11de4e2b62fa

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

LOG: [InstCombine] Fix scalable-vector bitwise select matching

D113035 enhanced the matching of bitwise selects from vector types. This
change unfortunately introduced crashes as it tries to cast scalable
vector types to integers.

Reviewed By: spatel

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

(cherry picked from commit bafab9c09f68190d1928a341255d50a7732443ab)

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/test/Transforms/InstCombine/logical-select.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 2aab79e890786..7eaa28bd13206 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -2488,8 +2488,12 @@ Value *InstCombinerImpl::matchSelectFromAndOr(Value *A, 
Value *C, Value *B,
 // not create unnecessary casts if the types already match.
 Type *SelTy = A->getType();
 if (auto *VecTy = dyn_cast(Cond->getType())) {
+  // For a fixed or scalable vector get N from <{vscale x} N x iM>
   unsigned Elts = VecTy->getElementCount().getKnownMinValue();
-  Type *EltTy = Builder.getIntNTy(SelTy->getPrimitiveSizeInBits() / Elts);
+  // For a fixed or scalable vector, get the size in bits of N x iM; for a
+  // scalar this is just M.
+  unsigned SelEltSize = SelTy->getPrimitiveSizeInBits().getKnownMinSize();
+  Type *EltTy = Builder.getIntNTy(SelEltSize / Elts);
   SelTy = VectorType::get(EltTy, VecTy->getElementCount());
 }
 Value *BitcastC = Builder.CreateBitCast(C, SelTy);

diff  --git a/llvm/test/Transforms/InstCombine/logical-select.ll 
b/llvm/test/Transforms/InstCombine/logical-select.ll
index f6375616d8995..565da1776b5c8 100644
--- a/llvm/test/Transforms/InstCombine/logical-select.ll
+++ b/llvm/test/Transforms/InstCombine/logical-select.ll
@@ -471,6 +471,18 @@ define <4 x i1> @vec_of_bools(<4 x i1> %a, <4 x i1> %b, <4 
x i1> %c) {
   ret <4 x i1> %or
 }
 
+define  @vec_of_bools_scalable( %a,  %c,  %d) {
+; CHECK-LABEL: @vec_of_bools_scalable(
+; CHECK-NEXT:[[TMP1:%.*]] = select  [[A:%.*]],  [[C:%.*]],  [[D:%.*]]
+; CHECK-NEXT:ret  [[TMP1]]
+;
+  %b = xor  %a, shufflevector ( 
insertelement ( poison, i1 true, i32 0),  
poison,  zeroinitializer)
+  %t11 = and  %a, %c
+  %t12 = and  %b, %d
+  %r = or  %t11, %t12
+  ret  %r
+}
+
 define i4 @vec_of_casted_bools(i4 %a, i4 %b, <4 x i1> %c) {
 ; CHECK-LABEL: @vec_of_casted_bools(
 ; CHECK-NEXT:[[TMP1:%.*]] = bitcast i4 [[B:%.*]] to <4 x i1>
@@ -488,6 +500,25 @@ define i4 @vec_of_casted_bools(i4 %a, i4 %b, <4 x i1> %c) {
   ret i4 %or
 }
 
+define  @vec_of_casted_bools_scalable( %a, 
 %b,  %cond) {
+; CHECK-LABEL: @vec_of_casted_bools_scalable(
+; CHECK-NEXT:[[TMP1:%.*]] = bitcast  [[A:%.*]] to 

+; CHECK-NEXT:[[TMP2:%.*]] = bitcast  [[B:%.*]] to 

+; CHECK-NEXT:[[TMP3:%.*]] = select  [[COND:%.*]],  [[TMP1]],  [[TMP2]]
+; CHECK-NEXT:[[TMP4:%.*]] = bitcast  [[TMP3]] to 
+; CHECK-NEXT:ret  [[TMP4]]
+;
+  %scond = sext  %cond to 
+  %notcond = xor  %cond, shufflevector ( 
insertelement ( poison, i1 true, i32 0),  
poison,  zeroinitializer)
+  %snotcond = sext  %notcond to 
+  %bc1 = bitcast  %scond to 
+  %bc2 = bitcast  %snotcond to 
+  %and1 = and  %a, %bc1
+  %and2 = and  %bc2, %b
+  %or = or  %and1, %and2
+  ret  %or
+}
+
 ; Inverted 'and' constants mean this is a select which is canonicalized to a 
shuffle.
 
 define <4 x i32> @vec_sel_consts(<4 x i32> %a, <4 x i32> %b) {



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


[llvm-branch-commits] [llvm] 60c8e02 - [IPSCCP] Support unfeasible default dests for switch.

2022-05-11 Thread Tom Stellard via llvm-branch-commits

Author: Florian Hahn
Date: 2022-05-11T14:45:05-07:00
New Revision: 60c8e02c9d12b38c00e5f870d883c5ac293a5371

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

LOG: [IPSCCP] Support unfeasible default dests for switch.

At the moment, unfeasible default destinations are not handled properly
in removeNonFeasibleEdges. So far, only unfeasible cases are removed,
but later code expects unreachable blocks to have no predecessors.

This is causing the crash reported in PR49573.

If the default destination is unfeasible it won't be executed. Create
a new unreachable block on demand and use that as default
destination.

Note that at the moment this only is relevant for cases where
resolvedUndefsIn marks the first case as executable. Regular switch
handling has a FIXME/TODO to support determining whether the default
case is feasible or not.

Fixes #48917.

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

(cherry picked from commit 857c612d899f271402470d4026d2e3be1dce53a4)

Added: 


Modified: 
llvm/lib/Transforms/Scalar/SCCP.cpp
llvm/test/Transforms/SCCP/switch-constantfold-crash.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/SCCP.cpp 
b/llvm/lib/Transforms/Scalar/SCCP.cpp
index c34da51e6dc17..fa1cfc84e4fda 100644
--- a/llvm/lib/Transforms/Scalar/SCCP.cpp
+++ b/llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -342,7 +342,8 @@ static void findReturnsToZap(Function &F,
 }
 
 static bool removeNonFeasibleEdges(const SCCPSolver &Solver, BasicBlock *BB,
-   DomTreeUpdater &DTU) {
+   DomTreeUpdater &DTU,
+   BasicBlock *&NewUnreachableBB) {
   SmallPtrSet FeasibleSuccessors;
   bool HasNonFeasibleEdges = false;
   for (BasicBlock *Succ : successors(BB)) {
@@ -385,6 +386,23 @@ static bool removeNonFeasibleEdges(const SCCPSolver 
&Solver, BasicBlock *BB,
   } else if (FeasibleSuccessors.size() > 1) {
 SwitchInstProfUpdateWrapper SI(*cast(TI));
 SmallVector Updates;
+
+// If the default destination is unfeasible it will never be taken. Replace
+// it with a new block with a single Unreachable instruction.
+BasicBlock *DefaultDest = SI->getDefaultDest();
+if (!FeasibleSuccessors.contains(DefaultDest)) {
+  if (!NewUnreachableBB) {
+NewUnreachableBB =
+BasicBlock::Create(DefaultDest->getContext(), 
"default.unreachable",
+   DefaultDest->getParent(), DefaultDest);
+new UnreachableInst(DefaultDest->getContext(), NewUnreachableBB);
+  }
+
+  SI->setDefaultDest(NewUnreachableBB);
+  Updates.push_back({DominatorTree::Delete, BB, DefaultDest});
+  Updates.push_back({DominatorTree::Insert, BB, NewUnreachableBB});
+}
+
 for (auto CI = SI->case_begin(); CI != SI->case_end();) {
   if (FeasibleSuccessors.contains(CI->getCaseSuccessor())) {
 ++CI;
@@ -532,8 +550,9 @@ bool llvm::runIPSCCP(
   NumInstRemoved += changeToUnreachable(F.front().getFirstNonPHI(),
 /*PreserveLCSSA=*/false, &DTU);
 
+BasicBlock *NewUnreachableBB = nullptr;
 for (BasicBlock &BB : F)
-  MadeChanges |= removeNonFeasibleEdges(Solver, &BB, DTU);
+  MadeChanges |= removeNonFeasibleEdges(Solver, &BB, DTU, 
NewUnreachableBB);
 
 for (BasicBlock *DeadBB : BlocksToErase)
   DTU.deleteBB(DeadBB);

diff  --git a/llvm/test/Transforms/SCCP/switch-constantfold-crash.ll 
b/llvm/test/Transforms/SCCP/switch-constantfold-crash.ll
index eb727fc54c03d..4aa1679310542 100644
--- a/llvm/test/Transforms/SCCP/switch-constantfold-crash.ll
+++ b/llvm/test/Transforms/SCCP/switch-constantfold-crash.ll
@@ -1,8 +1,9 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -passes=ipsccp < %s -S | FileCheck %s
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --function-signature
+; RUN: opt -passes=ipsccp < %s -S | FileCheck --check-prefixes=CHECK,ONCE %s
+; RUN: opt -passes='ipsccp,ipsccp' < %s -S | FileCheck 
--check-prefixes=CHECK,TWICE %s
 
 define void @barney() {
-; CHECK-LABEL: @barney(
+; CHECK-LABEL: define {{[^@]+}}@barney() {
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:br label [[BB9:%.*]]
 ; CHECK:   bb6:
@@ -26,7 +27,7 @@ bb9:  ; preds = 
%bb
 }
 
 define void @blam() {
-; CHECK-LABEL: @blam(
+; CHECK-LABEL: define {{[^@]+}}@blam() {
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:br label [[BB16:%.*]]
 ; CHECK:   bb16:
@@ -59,7 +60,7 @@ bb38: ; preds = 
%bb16
 
 
 define void @hoge() {
-; CHECK-LABEL: @hoge(
+; CHECK-LABEL: define {{[^@]+}}@hoge() {
 ; CHECK-NEXT:  bb:
 ; CHECK-NEXT:br label [[BB2:%.*]]
 

[llvm-branch-commits] [llvm] 5252880 - [AArch64] Ampere1 does not support MTE

2022-05-11 Thread Tom Stellard via llvm-branch-commits

Author: Philipp Tomsich
Date: 2022-05-11T16:16:13-07:00
New Revision: 52528806579b445f627cd93ff8201a59265795e8

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

LOG: [AArch64] Ampere1 does not support MTE

The initial support for the Ampere1 mistakenly signalled support for
the MTE feature.  However, the core does not include the optional MTE
functionality.

Update the target parser to not include MTE for Ampere1.

Reviewed By: dmgreen

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

(cherry picked from commit 91b24b018062c8650abfbd10f7da80a0c92266a7)

Added: 


Modified: 
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/Support/AArch64TargetParser.def 
b/llvm/include/llvm/Support/AArch64TargetParser.def
index 199dba08e4656..c45c149c60847 100644
--- a/llvm/include/llvm/Support/AArch64TargetParser.def
+++ b/llvm/include/llvm/Support/AArch64TargetParser.def
@@ -291,8 +291,7 @@ AARCH64_CPU_NAME("a64fx", ARMV8_2A, 
FK_CRYPTO_NEON_FP_ARMV8, false,
 AARCH64_CPU_NAME("carmel", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false,
  AArch64::AEK_FP16)
 AARCH64_CPU_NAME("ampere1", ARMV8_6A, FK_CRYPTO_NEON_FP_ARMV8, false,
- (AArch64::AEK_FP16 | AArch64::AEK_MTE | AArch64::AEK_SB |
-  AArch64::AEK_SSBS))
+ (AArch64::AEK_FP16 | AArch64::AEK_SB | AArch64::AEK_SSBS))
 // Invalid CPU
 AARCH64_CPU_NAME("invalid", INVALID, FK_INVALID, true, AArch64::AEK_INVALID)
 #undef AARCH64_CPU_NAME

diff  --git a/llvm/unittests/Support/TargetParserTest.cpp 
b/llvm/unittests/Support/TargetParserTest.cpp
index bba51e8c43e65..0a3aba78a1923 100644
--- a/llvm/unittests/Support/TargetParserTest.cpp
+++ b/llvm/unittests/Support/TargetParserTest.cpp
@@ -1192,7 +1192,7 @@ INSTANTIATE_TEST_SUITE_P(
  AArch64::AEK_RDM  | AArch64::AEK_RCPC | 
AArch64::AEK_DOTPROD |
  AArch64::AEK_SM4  | AArch64::AEK_SHA3 | 
AArch64::AEK_BF16|
  AArch64::AEK_SHA2 | AArch64::AEK_AES  | 
AArch64::AEK_I8MM|
- AArch64::AEK_MTE  | AArch64::AEK_SSBS | 
AArch64::AEK_SB,
+ AArch64::AEK_SSBS | AArch64::AEK_SB,
  "8.6-A"),
 ARMCPUTestParams(
 "neoverse-512tvb", "armv8.4-a", "crypto-neon-fp-armv8",



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


[llvm-branch-commits] [llvm] 53433dd - [AArch64] Support for Ampere1 core

2022-05-11 Thread Tom Stellard via llvm-branch-commits

Author: Philipp Tomsich
Date: 2022-05-11T16:16:13-07:00
New Revision: 53433dd0b5034681e1866e74651e8527a29e9364

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

LOG: [AArch64] Support for Ampere1 core

Add support for the Ampere Computing Ampere1 core.
Ampere1 implements the AArch64 state and is compatible with ARMv8.6-A.

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

(cherry picked from commit 64816e68f4419a9e14c23be8aa96fa412bed7e12)

Added: 
llvm/lib/Target/AArch64/AArch64SchedAmpere1.td
llvm/lib/Target/AArch64/AArch64SchedPredAmpere.td

Modified: 
clang/test/Misc/target-invalid-cpu-note.c
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64SchedPredicates.td
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.h
llvm/test/CodeGen/AArch64/cpus.ll
llvm/test/CodeGen/AArch64/neon-dot-product.ll
llvm/test/CodeGen/AArch64/remat.ll
llvm/test/MC/AArch64/armv8.2a-dotprod.s
llvm/test/MC/AArch64/armv8.3a-rcpc.s
llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 9b3cb45f8e23c..15d7aebe35cbc 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -5,11 +5,11 @@
 
 // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix AARCH64
 // AARCH64: error: unknown target CPU 'not-a-cpu'
-// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, cortex-a65ae, 
cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, 
cortex-a78, cortex-a78c, cortex-a710, cortex-r82, cortex-x1, cortex-x1c, 
cortex-x2, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, 
apple-a13, apple-a14, apple-m1, apple-s4, apple-s5, exynos-m3, exynos-m4, 
exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, 
thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel{{$}}
+// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, cortex-a65ae, 
cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, 
cortex-a78, cortex-a78c, cortex-a710, cortex-r82, cortex-x1, cortex-x1c, 
cortex-x2, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, 
apple-a13, apple-a14, apple-m1, apple-s4, apple-s5, exynos-m3, exynos-m4, 
exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, 
thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1{{$}}
 
 // RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE_AARCH64
 // TUNE_AARCH64: error: unknown target CPU 'not-a-cpu'
-// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, 
cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, 
cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, 
cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-r82, cortex-x1, 
cortex-x1c, cortex-x2, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, 
neoverse-v1, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-m1, apple-s4, apple-s5, exynos-m3, 
exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, 
thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel{{$}}
+// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, 
cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, 
cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, 
cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-r82, cortex-x1, 
cortex-x1c, cortex-x2, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, 
neoverse-v1, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-m1, apple-s4, apple-s5, exynos-m3, 
exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, 
thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, 
ampere1{{$}}
 
 // RUN: not %clang_cc1 -triple i386--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix X86
 // X86: error: unknown target CPU 'not-a-cpu'

diff  --git a/llvm/include/llvm/Support/AArch64TargetParser.def 
b/llvm/

[llvm-branch-commits] [llvm] c6d56a3 - [AArch64] Add native CPU detection for Ampere1

2022-05-11 Thread Tom Stellard via llvm-branch-commits

Author: Philipp Tomsich
Date: 2022-05-11T16:16:13-07:00
New Revision: c6d56a324ef87668f109f738e3f51f8eb528c9dd

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

LOG: [AArch64] Add native CPU detection for Ampere1

Map the IMPLEMENTOR ID 0xc0 (Ampere Computing) and CPU ID 0xac3
(Ampere1) to ampere1.

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

(cherry picked from commit 7e02bc5237751118efe36c41b0caf004aeed022f)

Added: 


Modified: 
llvm/lib/Support/Host.cpp
llvm/unittests/Support/Host.cpp

Removed: 




diff  --git a/llvm/lib/Support/Host.cpp b/llvm/lib/Support/Host.cpp
index f6003b783245e..a82a4d451c8a3 100644
--- a/llvm/lib/Support/Host.cpp
+++ b/llvm/lib/Support/Host.cpp
@@ -296,6 +296,12 @@ StringRef sys::detail::getHostCPUNameForARM(StringRef 
ProcCpuinfoContent) {
 }
   }
 
+  if (Implementer == "0xc0") { // Ampere Computing
+return StringSwitch(Part)
+.Case("0xac3", "ampere1")
+.Default("generic");
+  }
+
   return "generic";
 }
 

diff  --git a/llvm/unittests/Support/Host.cpp b/llvm/unittests/Support/Host.cpp
index 888cfb2658e42..6c1bbbc8ee58e 100644
--- a/llvm/unittests/Support/Host.cpp
+++ b/llvm/unittests/Support/Host.cpp
@@ -128,6 +128,10 @@ TEST(getLinuxHostCPUName, AArch64) {
   "CPU part: 0xc01"),
 "saphira");
 
+  EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0xc0\n"
+  "CPU part: 0xac3"),
+"ampere1");
+
   // MSM8992/4 weirdness
   StringRef MSM8992ProcCpuInfo = R"(
 Processor   : AArch64 Processor rev 3 (aarch64)



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