[clang] [llvm] [clang backend] In AArch64's DataLayout, specify a minimum function alignment of 4. (PR #90702)

2024-05-02 Thread Tim Northover via cfe-commits


@@ -1480,11 +1480,11 @@ AArch64leTargetInfo::AArch64leTargetInfo(const 
llvm::Triple ,
 void AArch64leTargetInfo::setDataLayout() {
   if (getTriple().isOSBinFormatMachO()) {
 if(getTriple().isArch32Bit())
-  resetDataLayout("e-m:o-p:32:32-i64:64-i128:128-n32:64-S128", "_");
+  resetDataLayout("e-m:o-p:32:32-i64:64-i128:128-n32:64-S128-Fn32", "_");

TNorthover wrote:

Yep. CPU would hard-fault if that was violated. All instructions are 4 bytes 
and must be aligned.

https://github.com/llvm/llvm-project/pull/90702
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7a8cf95 - AArch64-Darwin: allow -mcmodel=large with (default) PIC

2024-04-04 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2024-04-04T10:25:30+01:00
New Revision: 7a8cf951b3bdc60feac412200ab9661e009d44ae

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

LOG: AArch64-Darwin: allow -mcmodel=large with (default) PIC

Darwin targets implement -mcmodel=large by forcing all global accesses to use
the GOT, instead of the ELF movz/movk sequence. That means it's compatible with
PIC so the Clang driver shouldn't reject the option.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/mcmodel.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index b7ec7e0a60977b..766a9b91e3c0ad 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5882,7 +5882,8 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   CM = "large";
 if (Triple.isAArch64(64)) {
   Ok = CM == "tiny" || CM == "small" || CM == "large";
-  if (CM == "large" && RelocationModel != llvm::Reloc::Static)
+  if (CM == "large" && !Triple.isOSBinFormatMachO() &&
+  RelocationModel != llvm::Reloc::Static)
 D.Diag(diag::err_drv_argument_only_allowed_with)
 << A->getAsString(Args) << "-fno-pic";
 } else if (Triple.isLoongArch()) {

diff  --git a/clang/test/Driver/mcmodel.c b/clang/test/Driver/mcmodel.c
index 1eb6ae16ff472d..9681c32579d71e 100644
--- a/clang/test/Driver/mcmodel.c
+++ b/clang/test/Driver/mcmodel.c
@@ -11,6 +11,7 @@
 // RUN: FileCheck --check-prefix=AIX-MCMEDIUM-OVERRIDE %s < %t.log
 // RUN: not %clang -### -c -mcmodel=lager %s 2>&1 | FileCheck 
--check-prefix=INVALID %s
 // RUN: %clang --target=aarch64 -### -S -mcmodel=large -fno-pic %s 2>&1 | 
FileCheck --check-prefix=LARGE %s
+// RUN: %clang --target=aarch64-apple-macosx -### -S -mcmodel=large %s 2>&1 | 
FileCheck --check-prefix=LARGE %s
 // RUN: not %clang --target=aarch64 -### -S -mcmodel=large -fpic %s 2>&1 | 
FileCheck --check-prefix=AARCH64-PIC-LARGE %s
 // RUN: not %clang -### -c --target=aarch64 -mcmodel=medium %s 2>&1 | 
FileCheck --check-prefix=ERR-MEDIUM %s
 // RUN: not %clang -### -c --target=aarch64 -mcmodel=kernel %s 2>&1 | 
FileCheck --check-prefix=ERR-KERNEL %s



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


[clang] AArch64: add __builtin_arm_trap (PR #85054)

2024-03-14 Thread Tim Northover via cfe-commits

TNorthover wrote:

Thanks. Good idea on the docs, I've added some wording and pushed the change 
(4299c727e480)

https://github.com/llvm/llvm-project/pull/85054
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] AArch64: add __builtin_arm_trap (PR #85054)

2024-03-14 Thread Tim Northover via cfe-commits

https://github.com/TNorthover closed 
https://github.com/llvm/llvm-project/pull/85054
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4299c72 - AArch64: add __builtin_arm_trap

2024-03-14 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2024-03-14T11:32:44Z
New Revision: 4299c727e4806aa55398ad23da48a401554cd432

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

LOG: AArch64: add __builtin_arm_trap

It's useful to provide an indicator code with the trap, which the generic
__builtin_trap can't do. asm("brk #N") is an option, but following that with a
__builtin_unreachable() leads to two traps when the compiler doesn't know the
block can't return. So compiler support like this is useful.

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/include/clang/Basic/BuiltinsAArch64.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-arm64.c
clang/test/Sema/builtins-arm64.c

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 06af93fd3c15ca..9347703e96e21a 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3443,6 +3443,21 @@ Query for this feature with 
``__has_builtin(__builtin_debugtrap)``.
 
 Query for this feature with ``__has_builtin(__builtin_trap)``.
 
+``__builtin_arm_trap``
+--
+
+``__builtin_arm_trap`` is an AArch64 extension to ``__builtin_trap`` which 
also accepts a compile-time constant value, encoded directly into the trap 
instruction for later inspection.
+
+**Syntax**:
+
+.. code-block:: c++
+
+__builtin_arm_trap(const unsigned short payload)
+
+**Description**
+
+``__builtin_arm_trap`` is lowered to the ``llvm.aarch64.break`` builtin, and 
then to ``brk #payload``.
+
 ``__builtin_nondeterministic_value``
 
 

diff  --git a/clang/include/clang/Basic/BuiltinsAArch64.def 
b/clang/include/clang/Basic/BuiltinsAArch64.def
index b5cbe90c8fd6a3..cf8711c6eaee37 100644
--- a/clang/include/clang/Basic/BuiltinsAArch64.def
+++ b/clang/include/clang/Basic/BuiltinsAArch64.def
@@ -50,6 +50,9 @@ BUILTIN(__builtin_arm_wfi, "v", "")
 BUILTIN(__builtin_arm_sev, "v", "")
 BUILTIN(__builtin_arm_sevl, "v", "")
 
+// Like __builtin_trap but provide an 16-bit immediate reason code (which goes 
into `brk #N`).
+BUILTIN(__builtin_arm_trap, "vUIs", "nr")
+
 // CRC32
 TARGET_BUILTIN(__builtin_arm_crc32b, "UiUiUc", "nc", "crc")
 TARGET_BUILTIN(__builtin_arm_crc32cb, "UiUiUc", "nc", "crc")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 93ab465079777b..528a13fb275124 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -10686,6 +10686,12 @@ Value 
*CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
 return Builder.CreateCall(F, llvm::ConstantInt::get(Int32Ty, HintID));
   }
 
+  if (BuiltinID == clang::AArch64::BI__builtin_arm_trap) {
+Function *F = CGM.getIntrinsic(Intrinsic::aarch64_break);
+llvm::Value *Arg = EmitScalarExpr(E->getArg(0));
+return Builder.CreateCall(F, Builder.CreateZExt(Arg, CGM.Int32Ty));
+  }
+
   if (BuiltinID == clang::AArch64::BI__builtin_arm_get_sme_state) {
 // Create call to __arm_sme_state and store the results to the two 
pointers.
 CallInst *CI = EmitRuntimeCall(CGM.CreateRuntimeFunction(

diff  --git a/clang/test/CodeGen/builtins-arm64.c 
b/clang/test/CodeGen/builtins-arm64.c
index 05ea1c719edff3..8bd68d9ceb48ec 100644
--- a/clang/test/CodeGen/builtins-arm64.c
+++ b/clang/test/CodeGen/builtins-arm64.c
@@ -156,4 +156,10 @@ int rndrrs(uint64_t *__addr) {
   return __builtin_arm_rndrrs(__addr);
 }
 
+// CHECK-LABEL: @trap(
+// CHECK: call void @llvm.aarch64.break(i32 42)
+void trap() {
+  __builtin_arm_trap(42);
+}
+
 // CHECK: ![[M0]] = !{!"1:2:3:4:5"}

diff  --git a/clang/test/Sema/builtins-arm64.c 
b/clang/test/Sema/builtins-arm64.c
index e711121f7260ff..f094162b3aadc9 100644
--- a/clang/test/Sema/builtins-arm64.c
+++ b/clang/test/Sema/builtins-arm64.c
@@ -29,3 +29,12 @@ void test_prefetch(void) {
   __builtin_arm_prefetch(0, 0, 0, 2, 0); // expected-error-re {{argument value 
{{.*}} is outside the valid range}}
   __builtin_arm_prefetch(0, 0, 0, 0, 2); // expected-error-re {{argument value 
{{.*}} is outside the valid range}}
 }
+
+void test_trap(short s, unsigned short us) {
+  __builtin_arm_trap(42);
+  __builtin_arm_trap(65535);
+  __builtin_arm_trap(-1);
+  __builtin_arm_trap(65536); // expected-warning {{implicit conversion from 
'int' to 'unsigned short' changes value from 65536 to 0}}
+  __builtin_arm_trap(s); // expected-error {{argument to '__builtin_arm_trap' 
must be a constant integer}}
+  __builtin_arm_trap(us); // expected-error {{argument to '__builtin_arm_trap' 
must be a constant integer}}
+}
\ No newline at end of file



___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[clang] AArch64: add __builtin_arm_trap (PR #85054)

2024-03-13 Thread Tim Northover via cfe-commits

https://github.com/TNorthover created 
https://github.com/llvm/llvm-project/pull/85054

It's useful to provide an indicator code with the trap, which the generic 
__builtin_trap can't do. asm("brk #N") is an option, but following that with a 
__builtin_unreachable() leads to two traps when the compiler doesn't know the 
block can't return. So compiler support like this is useful.

>From 73d396865037ebad977d8158f6c66e2c8361dfec Mon Sep 17 00:00:00 2001
From: Tim Northover 
Date: Fri, 8 Mar 2024 12:15:53 +
Subject: [PATCH] AArch64: add __builtin_arm_trap

It's useful to provide an indicator code with the trap, which the generic
__builtin_trap can't do. asm("brk #N") is an option, but following that with a
__builtin_unreachable() leads to two traps when the compiler doesn't know the
block can't return. So compiler support like this is useful.
---
 clang/include/clang/Basic/BuiltinsAArch64.def | 3 +++
 clang/lib/CodeGen/CGBuiltin.cpp   | 6 ++
 clang/test/CodeGen/builtins-arm64.c   | 6 ++
 clang/test/Sema/builtins-arm64.c  | 9 +
 4 files changed, 24 insertions(+)

diff --git a/clang/include/clang/Basic/BuiltinsAArch64.def 
b/clang/include/clang/Basic/BuiltinsAArch64.def
index b5cbe90c8fd6a3..cf8711c6eaee37 100644
--- a/clang/include/clang/Basic/BuiltinsAArch64.def
+++ b/clang/include/clang/Basic/BuiltinsAArch64.def
@@ -50,6 +50,9 @@ BUILTIN(__builtin_arm_wfi, "v", "")
 BUILTIN(__builtin_arm_sev, "v", "")
 BUILTIN(__builtin_arm_sevl, "v", "")
 
+// Like __builtin_trap but provide an 16-bit immediate reason code (which goes 
into `brk #N`).
+BUILTIN(__builtin_arm_trap, "vUIs", "nr")
+
 // CRC32
 TARGET_BUILTIN(__builtin_arm_crc32b, "UiUiUc", "nc", "crc")
 TARGET_BUILTIN(__builtin_arm_crc32cb, "UiUiUc", "nc", "crc")
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 93ab465079777b..528a13fb275124 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -10686,6 +10686,12 @@ Value 
*CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
 return Builder.CreateCall(F, llvm::ConstantInt::get(Int32Ty, HintID));
   }
 
+  if (BuiltinID == clang::AArch64::BI__builtin_arm_trap) {
+Function *F = CGM.getIntrinsic(Intrinsic::aarch64_break);
+llvm::Value *Arg = EmitScalarExpr(E->getArg(0));
+return Builder.CreateCall(F, Builder.CreateZExt(Arg, CGM.Int32Ty));
+  }
+
   if (BuiltinID == clang::AArch64::BI__builtin_arm_get_sme_state) {
 // Create call to __arm_sme_state and store the results to the two 
pointers.
 CallInst *CI = EmitRuntimeCall(CGM.CreateRuntimeFunction(
diff --git a/clang/test/CodeGen/builtins-arm64.c 
b/clang/test/CodeGen/builtins-arm64.c
index 05ea1c719edff3..8bd68d9ceb48ec 100644
--- a/clang/test/CodeGen/builtins-arm64.c
+++ b/clang/test/CodeGen/builtins-arm64.c
@@ -156,4 +156,10 @@ int rndrrs(uint64_t *__addr) {
   return __builtin_arm_rndrrs(__addr);
 }
 
+// CHECK-LABEL: @trap(
+// CHECK: call void @llvm.aarch64.break(i32 42)
+void trap() {
+  __builtin_arm_trap(42);
+}
+
 // CHECK: ![[M0]] = !{!"1:2:3:4:5"}
diff --git a/clang/test/Sema/builtins-arm64.c b/clang/test/Sema/builtins-arm64.c
index e711121f7260ff..f094162b3aadc9 100644
--- a/clang/test/Sema/builtins-arm64.c
+++ b/clang/test/Sema/builtins-arm64.c
@@ -29,3 +29,12 @@ void test_prefetch(void) {
   __builtin_arm_prefetch(0, 0, 0, 2, 0); // expected-error-re {{argument value 
{{.*}} is outside the valid range}}
   __builtin_arm_prefetch(0, 0, 0, 0, 2); // expected-error-re {{argument value 
{{.*}} is outside the valid range}}
 }
+
+void test_trap(short s, unsigned short us) {
+  __builtin_arm_trap(42);
+  __builtin_arm_trap(65535);
+  __builtin_arm_trap(-1);
+  __builtin_arm_trap(65536); // expected-warning {{implicit conversion from 
'int' to 'unsigned short' changes value from 65536 to 0}}
+  __builtin_arm_trap(s); // expected-error {{argument to '__builtin_arm_trap' 
must be a constant integer}}
+  __builtin_arm_trap(us); // expected-error {{argument to '__builtin_arm_trap' 
must be a constant integer}}
+}
\ No newline at end of file

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


[llvm] [libcxxabi] [clang-tools-extra] [compiler-rt] [clang] [mlir] [libc] [openmp] [libcxx] [flang] [AArch64] Add custom lowering for load <3 x i8>. (PR #78632)

2024-01-30 Thread Tim Northover via cfe-commits

https://github.com/TNorthover approved this pull request.


https://github.com/llvm/llvm-project/pull/78632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libc] [compiler-rt] [libcxxabi] [llvm] [clang-tools-extra] [flang] [libcxx] [mlir] [clang] [openmp] [AArch64] Add custom lowering for load <3 x i8>. (PR #78632)

2024-01-30 Thread Tim Northover via cfe-commits

https://github.com/TNorthover edited 
https://github.com/llvm/llvm-project/pull/78632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[mlir] [libcxxabi] [openmp] [clang-tools-extra] [libc] [clang] [llvm] [libcxx] [compiler-rt] [flang] [AArch64] Add custom lowering for load <3 x i8>. (PR #78632)

2024-01-30 Thread Tim Northover via cfe-commits


@@ -21248,6 +21248,61 @@ static SDValue foldTruncStoreOfExt(SelectionDAG , 
SDNode *N) {
   return SDValue();
 }
 
+// A custom combine to lower load <3 x i8> as the more efficient sequence
+// below:
+//ldrb wX, [x0, #2]
+//ldrh wY, [x0]
+//orr wX, wY, wX, lsl #16
+//fmov s0, wX
+//
+// Note that an alternative sequence with even fewer (although usually more
+// complex/expensive) instructions would be:
+//   ld1r.4h { v0 }, [x0], #2
+//   ld1.b { v0 }[2], [x0]
+//
+// Generating this sequence unfortunately results in noticeably worse codegen
+// for code that extends the loaded v3i8, due to legalization breaking vector
+// shuffle detection in a way that is very difficult to work around.
+// TODO: Revisit once v3i8 legalization has been improved in general.
+static SDValue combineV3I8LoadExt(LoadSDNode *LD, SelectionDAG ) {
+  EVT MemVT = LD->getMemoryVT();
+  if (MemVT != EVT::getVectorVT(*DAG.getContext(), MVT::i8, 3) ||
+  LD->getOriginalAlign() >= 4)
+return SDValue();
+
+  SDLoc DL(LD);
+  MachineFunction  = DAG.getMachineFunction();
+  SDValue Chain = LD->getChain();
+  SDValue BasePtr = LD->getBasePtr();
+  MachineMemOperand *MMO = LD->getMemOperand();
+  assert(LD->getOffset().isUndef() && "undef offset expected");
+
+  // Load 2 x i8, then 1 x i8.
+  SDValue L16 = DAG.getLoad(MVT::i16, DL, Chain, BasePtr, MMO);
+  TypeSize Offset2 = TypeSize::getFixed(2);
+  SDValue L8 = DAG.getLoad(MVT::i8, DL, Chain,
+   DAG.getMemBasePlusOffset(BasePtr, Offset2, DL),
+   MF.getMachineMemOperand(MMO, 2, 1));
+
+  // Extend to i32.
+  SDValue Ext16 = DAG.getNode(ISD::ZERO_EXTEND, DL, MVT::i32, L16);
+  SDValue Ext8 = DAG.getNode(ISD::ZERO_EXTEND, DL, MVT::i32, L8);
+
+  // Pack 2 x i8 and 1 x i8 in an i32 and convert to v4i8.
+  SDValue Shr = DAG.getNode(ISD::SHL, DL, MVT::i32, Ext8,

TNorthover wrote:

Mismatch between name and operation.

https://github.com/llvm/llvm-project/pull/78632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [libcxxabi] [clang-tools-extra] [compiler-rt] [clang] [mlir] [libc] [openmp] [libcxx] [flang] [AArch64] Add custom lowering for load <3 x i8>. (PR #78632)

2024-01-30 Thread Tim Northover via cfe-commits

TNorthover wrote:

I'm happier with that, I think. Just one typo I spotted in the new version but 
no need to reupload.

https://github.com/llvm/llvm-project/pull/78632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] [llvm] [compiler-rt] [openmp] [mlir] [libcxx] [clang-tools-extra] [flang] [clang] [libc] [AArch64] Add custom lowering for load <3 x i8>. (PR #78632)

2024-01-29 Thread Tim Northover via cfe-commits


@@ -11012,6 +11012,50 @@ SDValue ReconstructShuffleWithRuntimeMask(SDValue Op, 
SelectionDAG ) {
   MaskSourceVec);
 }
 
+// Check if Op is a BUILD_VECTOR with 2 extracts and a load that is cheaper to
+// insert into a vector and use a shuffle. This improves lowering for loads of
+// <3 x i8>.
+static SDValue shuffleWithSingleLoad(SDValue Op, SelectionDAG ) {
+  if (Op.getNumOperands() != 4 || Op.getValueType() != MVT::v4i16)
+return SDValue();
+
+  SDValue V0 = Op.getOperand(0);
+  SDValue V1 = Op.getOperand(1);
+  SDValue V2 = Op.getOperand(2);
+  SDValue V3 = Op.getOperand(3);
+  if (V0.getOpcode() != ISD::EXTRACT_VECTOR_ELT ||
+  V1.getOpcode() != ISD::EXTRACT_VECTOR_ELT ||
+  V2.getOpcode() != ISD::LOAD ||
+  !(V3.isUndef() || V3.getOpcode() == ISD::EXTRACT_VECTOR_ELT))
+return SDValue();
+
+  if (V0.getOperand(0) != V1.getOperand(0) ||
+  V0.getConstantOperandVal(1) != 0 || V1.getConstantOperandVal(1) != 1 ||
+  !(V3.isUndef() || V3.getConstantOperandVal(1) == 3))
+return SDValue();
+
+  SDLoc dl(Op);
+  auto *L = cast(Op.getOperand(2));
+  auto Vec = V0.getOperand(0);
+
+  Vec = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, Vec.getValueType(), Vec,
+SDValue(L, 0), DAG.getConstant(2, dl, MVT::i64));
+  Vec = DAG.getNode(ISD::BITCAST, dl, MVT::v4i16, Vec);

TNorthover wrote:

I think `Vec` could have quite a variety of unexpected types here (though 
running at a specific phase of DAG might limit that). There's no reason to 
expect it to have either 4 elements or for each element to be `i16` just from 
what you've checked so far.

https://github.com/llvm/llvm-project/pull/78632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] [compiler-rt] [llvm] [flang] [libc] [openmp] [libcxx] [clang] [mlir] [clang-tools-extra] [AArch64] Add custom lowering for load <3 x i8>. (PR #78632)

2024-01-29 Thread Tim Northover via cfe-commits

https://github.com/TNorthover edited 
https://github.com/llvm/llvm-project/pull/78632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [libcxx] [flang] [compiler-rt] [mlir] [llvm] [libcxxabi] [clang-tools-extra] [libc] [AArch64] Add custom lowering for load <3 x i8>. (PR #78632)

2024-01-29 Thread Tim Northover via cfe-commits

https://github.com/TNorthover commented:

Not a fan, but if we must then I think there might still be some gaps...

https://github.com/llvm/llvm-project/pull/78632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libc] [clang] [compiler-rt] [libcxxabi] [clang-tools-extra] [flang] [libcxx] [openmp] [llvm] [mlir] [AArch64] Add custom lowering for load <3 x i8>. (PR #78632)

2024-01-29 Thread Tim Northover via cfe-commits


@@ -21248,6 +21297,51 @@ static SDValue foldTruncStoreOfExt(SelectionDAG , 
SDNode *N) {
   return SDValue();
 }
 
+// A custom combine to lower load <3 x i8> as the more efficient sequence
+// below:
+//ldrb wX, [x0, #2]
+//ldrh wY, [x0]
+//orr wX, wY, wX, lsl #16
+//fmov s0, wX
+//
+static SDValue combineV3I8LoadExt(LoadSDNode *LD, SelectionDAG ) {
+  EVT MemVT = LD->getMemoryVT();
+  if (MemVT != EVT::getVectorVT(*DAG.getContext(), MVT::i8, 3) ||
+  LD->getOriginalAlign() >= 4)
+return SDValue();
+
+  SDLoc DL(LD);
+  MachineFunction  = DAG.getMachineFunction();
+  SDValue Chain = LD->getChain();
+  SDValue BasePtr = LD->getBasePtr();
+  MachineMemOperand *MMO = LD->getMemOperand();
+  assert(LD->getOffset().isUndef() && "undef offset expected");
+
+  // Load 2 x i8, then 1 x i8.
+  SDValue L16 = DAG.getLoad(MVT::i16, DL, Chain, BasePtr,
+MF.getMachineMemOperand(MMO, 0, 2));
+  TypeSize Offset2 = TypeSize::getFixed(2);
+  SDValue L8 = DAG.getLoad(MVT::i8, DL, Chain,
+   DAG.getMemBasePlusOffset(BasePtr, Offset2, DL),
+   MF.getMachineMemOperand(MMO, 2, 1));
+
+  SDValue Ins16 = DAG.getNode(ISD::SPLAT_VECTOR, DL, MVT::v4i16, L16);
+
+  SDValue Cast = DAG.getNode(ISD::BITCAST, DL, MVT::v8i8, Ins16);
+
+  SDValue Ext8 = DAG.getNode(ISD::ZERO_EXTEND, DL, MVT::i32, L8);
+  SDValue Trunc8 = DAG.getNode(ISD::TRUNCATE, DL, MVT::i8, Ext8);

TNorthover wrote:

What are these two doing? They ought to amount to a nop.

https://github.com/llvm/llvm-project/pull/78632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [mlir] [libc] [libcxxabi] [flang] [openmp] [compiler-rt] [clang-tools-extra] [libcxx] [clang] [AArch64] Add custom lowering for load <3 x i8>. (PR #78632)

2024-01-29 Thread Tim Northover via cfe-commits


@@ -11012,6 +11012,50 @@ SDValue ReconstructShuffleWithRuntimeMask(SDValue Op, 
SelectionDAG ) {
   MaskSourceVec);
 }
 
+// Check if Op is a BUILD_VECTOR with 2 extracts and a load that is cheaper to
+// insert into a vector and use a shuffle. This improves lowering for loads of
+// <3 x i8>.
+static SDValue shuffleWithSingleLoad(SDValue Op, SelectionDAG ) {
+  if (Op.getNumOperands() != 4 || Op.getValueType() != MVT::v4i16)
+return SDValue();
+
+  SDValue V0 = Op.getOperand(0);
+  SDValue V1 = Op.getOperand(1);
+  SDValue V2 = Op.getOperand(2);
+  SDValue V3 = Op.getOperand(3);
+  if (V0.getOpcode() != ISD::EXTRACT_VECTOR_ELT ||
+  V1.getOpcode() != ISD::EXTRACT_VECTOR_ELT ||
+  V2.getOpcode() != ISD::LOAD ||
+  !(V3.isUndef() || V3.getOpcode() == ISD::EXTRACT_VECTOR_ELT))
+return SDValue();
+
+  if (V0.getOperand(0) != V1.getOperand(0) ||
+  V0.getConstantOperandVal(1) != 0 || V1.getConstantOperandVal(1) != 1 ||
+  !(V3.isUndef() || V3.getConstantOperandVal(1) == 3))

TNorthover wrote:

We're not checking `V3.getOperand(0)` anywhere.

https://github.com/llvm/llvm-project/pull/78632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libc] [openmp] [llvm] [clang] [flang] [clang-tools-extra] [compiler-rt] [libcxx] [libcxxabi] [mlir] [AArch64] Add custom lowering for load <3 x i8>. (PR #78632)

2024-01-29 Thread Tim Northover via cfe-commits


@@ -11012,6 +11012,50 @@ SDValue ReconstructShuffleWithRuntimeMask(SDValue Op, 
SelectionDAG ) {
   MaskSourceVec);
 }
 
+// Check if Op is a BUILD_VECTOR with 2 extracts and a load that is cheaper to
+// insert into a vector and use a shuffle. This improves lowering for loads of
+// <3 x i8>.
+static SDValue shuffleWithSingleLoad(SDValue Op, SelectionDAG ) {
+  if (Op.getNumOperands() != 4 || Op.getValueType() != MVT::v4i16)
+return SDValue();
+
+  SDValue V0 = Op.getOperand(0);
+  SDValue V1 = Op.getOperand(1);
+  SDValue V2 = Op.getOperand(2);
+  SDValue V3 = Op.getOperand(3);
+  if (V0.getOpcode() != ISD::EXTRACT_VECTOR_ELT ||

TNorthover wrote:

This is a hyper-specific pattern. I assume it's because we are specifically 
looking for and only care about a single `<3 x i8>` instruction (a load?) and 
this is what it's been mangled to by the time we get to see it. If so we might 
have to tolerate the horror, but should at least call it out in comments.

https://github.com/llvm/llvm-project/pull/78632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] AArch64: add support for currently released Apple CPUs. (PR #73499)

2023-11-29 Thread Tim Northover via cfe-commits

https://github.com/TNorthover closed 
https://github.com/llvm/llvm-project/pull/73499
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] AArch64: add support for currently released Apple CPUs. (PR #73499)

2023-11-29 Thread Tim Northover via cfe-commits

TNorthover wrote:

Push was to resolve merge conflicts.

https://github.com/llvm/llvm-project/pull/73499
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] AArch64: add support for currently released Apple CPUs. (PR #73499)

2023-11-29 Thread Tim Northover via cfe-commits

https://github.com/TNorthover updated 
https://github.com/llvm/llvm-project/pull/73499

>From 61e58d0eb96f9443e13879c3055d3d32b33dc2d4 Mon Sep 17 00:00:00 2001
From: Tim Northover 
Date: Wed, 22 Nov 2023 14:10:31 +
Subject: [PATCH] AArch64: add support for currently released Apple CPUs.

These are still v8.6a so mostly just a copy/paste job.
---
 clang/test/Misc/target-invalid-cpu-note.c |  4 +--
 .../llvm/TargetParser/AArch64TargetParser.h   | 10 
 llvm/lib/Target/AArch64/AArch64.td| 25 ++-
 llvm/lib/Target/AArch64/AArch64Subtarget.cpp  |  2 ++
 llvm/lib/Target/AArch64/AArch64Subtarget.h|  1 +
 .../TargetParser/TargetParserTest.cpp | 22 +++-
 6 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 693f47a78b7fa57..c7146e63add5f20 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-a520, 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-a715, cortex-a720, 
cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, 
neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-m1, apple-m2, 
apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, 
thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, 
tsv110, a64fx, carmel, ampere1, ampere1a, grace{{$}}
+// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a520, 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-a715, cortex-a720, 
cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, 
neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, 
apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, 
falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, 
thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, grace{{$}}
 
 // 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-a520, 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-a715, 
cortex-a720, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, 
cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-a15, apple-a16,  apple-m1, apple-m2, 
apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, 
thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, 
tsv110, a64fx, carmel, ampere1, ampere1a, grace{{$}}
+// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, 
cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, 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-a715, 
cortex-a720, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, 
cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, 
apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, 
falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, 
thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, grace{{$}}
 
 // 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/TargetParser/AArch64TargetParser.h 
b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index 

[clang] [llvm] AArch64: add support for currently released Apple CPUs. (PR #73499)

2023-11-27 Thread Tim Northover via cfe-commits

https://github.com/TNorthover created 
https://github.com/llvm/llvm-project/pull/73499

These are still v8.6a and have no real changes as far as LLVM cares, so it's 
mostly just a copy/paste job (actually from 
https://github.com/llvm/llvm-project/pull/73497 rather than `main` as I write 
this).

>From c415ffd79582e6a24e4da7152935c93cbe17210e Mon Sep 17 00:00:00 2001
From: Tim Northover 
Date: Wed, 22 Nov 2023 14:10:31 +
Subject: [PATCH] AArch64: add support for currently released Apple CPUs.

These are still v8.6a so mostly just a copy/paste job.
---
 clang/test/Misc/target-invalid-cpu-note.c |  4 +--
 .../llvm/TargetParser/AArch64TargetParser.h   |  9 +++
 llvm/lib/Target/AArch64/AArch64.td| 25 ++-
 llvm/lib/Target/AArch64/AArch64Subtarget.cpp  |  2 ++
 llvm/lib/Target/AArch64/AArch64Subtarget.h|  1 +
 .../TargetParser/TargetParserTest.cpp | 22 +++-
 6 files changed, 59 insertions(+), 4 deletions(-)

diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 693f47a78b7fa57..c7146e63add5f20 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-a520, 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-a715, cortex-a720, 
cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, 
neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-m1, apple-m2, 
apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, 
thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, 
tsv110, a64fx, carmel, ampere1, ampere1a, grace{{$}}
+// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a520, 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-a715, cortex-a720, 
cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, 
neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, 
apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, 
falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, 
thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, grace{{$}}
 
 // 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-a520, 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-a715, 
cortex-a720, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, 
cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-a15, apple-a16,  apple-m1, apple-m2, 
apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, 
thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, 
tsv110, a64fx, carmel, ampere1, ampere1a, grace{{$}}
+// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, 
cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, 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-a715, 
cortex-a720, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, 
cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, 
apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, 
falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, 
thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, grace{{$}}
 
 // RUN: not %clang_cc1 -triple i386--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix 

[clang] 211055c - AArch64: emit synchronous unwind for Darwin arm64_32 platforms too.

2023-05-23 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2023-05-23T13:15:32+01:00
New Revision: 211055c7443e5594863ec95754e22f66e66aecc5

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

LOG: AArch64: emit synchronous unwind for Darwin arm64_32 platforms too.

Since we're checking the triple directly, arm64_32 shows up differently and was
still getting an attempt at asynchronous unwind that added lots more
`__eh_frame` entries instead of the compact format.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/clang-translation.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index e66606293821..3ab8bc8c8ec9 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2941,8 +2941,10 @@ ToolChain::UnwindTableLevel 
MachO::getDefaultUnwindTableLevel(const ArgList 
   (GetExceptionModel(Args) != llvm::ExceptionHandling::SjLj &&
Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions,
 true)))
-return getArch() == llvm::Triple::aarch64 ? UnwindTableLevel::Synchronous
-  : UnwindTableLevel::Asynchronous;
+return (getArch() == llvm::Triple::aarch64 ||
+getArch() == llvm::Triple::aarch64_32)
+   ? UnwindTableLevel::Synchronous
+   : UnwindTableLevel::Asynchronous;
 
   return UnwindTableLevel::None;
 }

diff  --git a/clang/test/Driver/clang-translation.c 
b/clang/test/Driver/clang-translation.c
index d950d9a4de9b..4e42ab3a9e2e 100644
--- a/clang/test/Driver/clang-translation.c
+++ b/clang/test/Driver/clang-translation.c
@@ -81,6 +81,8 @@
 
 // RUN: %clang -target arm64-apple-ios10 -funwind-tables -### -S %s -arch 
arm64 2>&1 | \
 // RUN: FileCheck -check-prefix=ARM64-APPLE-UNWIND %s
+// RUN: %clang -target arm64_32-apple-watchos8 -funwind-tables -### -S %s 
-arch arm64 2>&1 | \
+// RUN: FileCheck -check-prefix=ARM64-APPLE-UNWIND %s
 // ARM64-APPLE-UNWIND: -funwind-tables=1
 
 // RUN: %clang -target arm64-apple-ios10 -### -ffreestanding -S %s -arch arm64 
2>&1 | \



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


[clang] d3aed4f - MachO use generic code to detect atomic support.

2023-04-04 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2023-04-04T13:44:45+01:00
New Revision: d3aed4f401fa35ea986d3967c529f4d2b24e2bb6

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

LOG: MachO use generic code to detect atomic support.

The default code can detect what width of atomic instructions are supported
based on the targeted architecture profile, version etc so there's no need to
hard-code 64 on Darwin targets (especially as it's wrong in most M-class
cases).

Added: 
clang/test/CodeGen/atomic-arm.c

Modified: 
clang/lib/Basic/Targets/ARM.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 5e0e8f5c476af..a0ffbcf78001e 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -1406,11 +1406,6 @@ DarwinARMTargetInfo::DarwinARMTargetInfo(const 
llvm::Triple ,
  const TargetOptions )
 : DarwinTargetInfo(Triple, Opts) {
   HasAlignMac68kSupport = true;
-  // iOS always has 64-bit atomic instructions.
-  // FIXME: This should be based off of the target features in
-  // ARMleTargetInfo.
-  MaxAtomicInlineWidth = 64;
-
   if (Triple.isWatchABI()) {
 // Darwin on iOS uses a variant of the ARM C++ ABI.
 TheCXXABI.set(TargetCXXABI::WatchOS);

diff  --git a/clang/test/CodeGen/atomic-arm.c b/clang/test/CodeGen/atomic-arm.c
new file mode 100644
index 0..6952b4d0099b5
--- /dev/null
+++ b/clang/test/CodeGen/atomic-arm.c
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -triple thumbv6m-apple-unknown-macho %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-V6M
+// RUN: %clang_cc1 -triple thumbv7m-apple-unknown-macho %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-V7M
+// RUN: %clang_cc1 -triple thumbv7-apple-ios13.0 %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-HOSTED
+// RUN: %clang_cc1 -triple thumbv7k-apple-watchos5.0 %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-HOSTED
+
+
+// CHECK-V6M: @always1 = global i32 0
+// CHECK-V6M: @always4 = global i32 0
+// CHECK-V6M: @always8 = global i32 0
+
+// CHECK-V7M: @always1 = global i32 1
+// CHECK-V7M: @always4 = global i32 1
+// CHECK-V7M: @always8 = global i32 0
+
+// CHECK-HOSTED: @always1 = global i32 1
+// CHECK-HOSTED: @always4 = global i32 1
+// CHECK-HOSTED: @always8 = global i32 1
+
+int always1 = __atomic_always_lock_free(1, 0);
+int always4 = __atomic_always_lock_free(4, 0);
+int always8 = __atomic_always_lock_free(8, 0);
+
+int lock_free_1() {
+  // CHECK-LABEL: @lock_free_1
+  // CHECK-V6M:   [[RES:%.*]] = call arm_aapcscc zeroext i1 
@__atomic_is_lock_free(i32 noundef 1, ptr noundef null)
+  // CHECK-V6M:   [[RES32:%.*]] = zext i1 [[RES]] to i32
+  // CHECK-V6M:   ret i32 [[RES32]]
+
+  // CHECK-V7M: ret i32 1
+  // CHECK-HOSTED: ret i32 1
+  return __c11_atomic_is_lock_free(1);
+}
+
+int lock_free_4() {
+  // CHECK-LABEL: @lock_free_4
+  // CHECK-V6M:   [[RES:%.*]] = call arm_aapcscc zeroext i1 
@__atomic_is_lock_free(i32 noundef 4, ptr noundef null)
+  // CHECK-V6M:   [[RES32:%.*]] = zext i1 [[RES]] to i32
+  // CHECK-V6M:   ret i32 [[RES32]]
+
+  // CHECK-V7M: ret i32 1
+  // CHECK-HOSTED: ret i32 1
+  return __c11_atomic_is_lock_free(4);
+}
+
+int lock_free_8() {
+  // CHECK-LABEL: @lock_free_8
+  // CHECK-V6M:   [[RES:%.*]] = call arm_aapcscc zeroext i1 
@__atomic_is_lock_free(i32 noundef 8, ptr noundef null)
+  // CHECK-V6M:   [[RES32:%.*]] = zext i1 [[RES]] to i32
+  // CHECK-V6M:   ret i32 [[RES32]]
+
+  // CHECK-V7M:   [[RES:%.*]] = call arm_aapcscc zeroext i1 
@__atomic_is_lock_free(i32 noundef 8, ptr noundef null)
+  // CHECK-V7M:   [[RES32:%.*]] = zext i1 [[RES]] to i32
+  // CHECK-V7M:   ret i32 [[RES32]]
+
+  // CHECK-HOSTED: ret i32 1
+  return __c11_atomic_is_lock_free(8);
+}



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


[clang] ecec44f - AArch64: remove SM4 support from Apple CPUs.

2023-01-26 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2023-01-26T13:00:36Z
New Revision: ecec44f2ae733b3848d4dd71324f5fdc33adc62e

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

LOG: AArch64: remove SM4 support from Apple CPUs.

The CPUs never supported SM4 instructions, but until recently I think crypto
was folded into the baseline architecture as a monolithic feature so it was
difficult to represent that. Now it's split we can, and the CPUs that support
v8.4 onwards only handle AES, SHA2, SHA3 by way of crypto instructions.

Added: 


Modified: 
clang/test/Preprocessor/aarch64-target-features.c
llvm/include/llvm/TargetParser/AArch64TargetParser.h
llvm/unittests/TargetParser/TargetParserTest.cpp

Removed: 




diff  --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index ba1b56c492067..9c03ae09cb79c 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -312,7 +312,7 @@
 // CHECK-MCPU-APPLE-A11: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8.2a" "-target-feature" "+crc" "-target-feature" "+crypto" 
"-target-feature" "+fp-armv8" "-target-feature" "+fullfp16" "-target-feature" 
"+lse" "-target-feature" "+ras" "-target-feature" "+rdm" "-target-feature" 
"+neon" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" 
"+sha2" "-target-feature" "+aes"
 // CHECK-MCPU-APPLE-A12: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8.3a" "-target-feature" "+crc" "-target-feature" "+crypto" 
"-target-feature" "+fp-armv8" "-target-feature" "+fullfp16" "-target-feature" 
"+lse" "-target-feature" "+ras" "-target-feature" "+rcpc" "-target-feature" 
"+rdm" "-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" 
"+zcz" "-target-feature" "+sha2" "-target-feature" "+aes"
 // CHECK-MCPU-A34: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+fp-armv8" 
"-target-feature" "+neon"
-// CHECK-MCPU-APPLE-A13: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8.4a" "-target-feature" "+crc" "-target-feature" "+crypto" 
"-target-feature" "+dotprod" "-target-feature" "+fp-armv8" "-target-feature" 
"+fp16fml" "-target-feature" "+lse" "-target-feature" "+ras" "-target-feature" 
"+rcpc" "-target-feature" "+rdm" "-target-feature" "+neon" "-target-feature" 
"+zcm" "-target-feature" "+zcz" "-target-feature" "+fullfp16" "-target-feature" 
"+sm4" "-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" 
"+aes"
+// CHECK-MCPU-APPLE-A13: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8.4a"  "-target-feature" "+aes" "-target-feature" "+crc" 
"-target-feature" "+dotprod" "-target-feature" "+fp-armv8" "-target-feature" 
"+fp16fml" "-target-feature" "+lse" "-target-feature" "+ras" "-target-feature" 
"+rcpc" "-target-feature" "+rdm" "-target-feature" "+sha2" "-target-feature" 
"+sha3" "-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" 
"+zcz" "-target-feature" "+fullfp16"
 // CHECK-MCPU-A35: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+fp-armv8" "-target-feature" "+neon"
 // CHECK-MCPU-A53: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+fp-armv8" "-target-feature" "+neon"
 // CHECK-MCPU-A57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+fp-armv8" "-target-feature" "+neon"
@@ -327,7 +327,7 @@
 // CHECK-MCPU-CARMEL: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8.2a" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+fp-armv8" "-target-feature" "+fullfp16" "-target-feature" "+lse" 
"-target-feature" "+ras" "-target-feature" "+rdm" "-target-feature" "+neon" 
"-target-feature" "+sha2" "-target-feature" "+aes"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-ARCH-ARM64 %s
-// CHECK-ARCH-ARM64: "-target-cpu" "apple-m1" "-target-feature" "+v8.5a" 
"-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+dotprod" "-target-feature" "+fp-armv8" "-target-feature" "+fp16fml" 
"-target-feature" "+lse" "-target-feature" "+ras" "-target-feature" "+rcpc" 
"-target-feature" "+rdm" "-target-feature" "+neon" "-target-feature" "+zcm" 
"-target-feature" "+zcz" "-target-feature" "+fullfp16" "-target-feature" "+sm4" 
"-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" "+aes"
+// CHECK-ARCH-ARM64: "-target-cpu" "apple-m1" "-target-feature" "+v8.5a" 

[clang] e62b3a9 - Unwind-tables: move back to original logic outline for kind.

2022-09-29 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2022-09-29T13:39:06+01:00
New Revision: e62b3a9375d8694efe5bf3d1409bec9be0d288e9

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

LOG: Unwind-tables: move back to original logic outline for kind.

There are lots of options interacting in complex ways here, and when moving to
`getDefaultUnwindTableLevel` I had refactored this and changed behaviour in
some cases. So this reverts the basic structure of the logic back to the
original, while leaving the hook in the new style.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/clang-translation.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c93a7276f1a9..5ea9e8085302 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5470,27 +5470,24 @@ void Clang::ConstructJob(Compilation , const 
JobAction ,
   // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more
   // complicated ways.
   auto SanitizeArgs = TC.getSanitizerArgs(Args);
-  auto UnwindTables = TC.getDefaultUnwindTableLevel(Args);
-
-  const bool HasSyncUnwindTables = Args.hasFlag(
-  options::OPT_funwind_tables, options::OPT_fno_unwind_tables, false);
-  if (Args.hasFlag(options::OPT_fasynchronous_unwind_tables,
-   options::OPT_fno_asynchronous_unwind_tables,
-   SanitizeArgs.needsUnwindTables()) &&
-  !Freestanding)
-UnwindTables = ToolChain::UnwindTableLevel::Asynchronous;
-  else if (HasSyncUnwindTables)
-UnwindTables = ToolChain::UnwindTableLevel::Synchronous;
-  else if (Args.hasFlag(options::OPT_fno_unwind_tables,
-   options::OPT_fno_asynchronous_unwind_tables,
-   options::OPT_funwind_tables, false) || Freestanding)
-UnwindTables = ToolChain::UnwindTableLevel::None;
-
-
-  if (UnwindTables == ToolChain::UnwindTableLevel::Synchronous)
-CmdArgs.push_back("-funwind-tables=1");
-  else if (UnwindTables == ToolChain::UnwindTableLevel::Asynchronous)
+
+  bool IsAsyncUnwindTablesDefault =
+  TC.getDefaultUnwindTableLevel(Args) == 
ToolChain::UnwindTableLevel::Asynchronous;
+  bool IsSyncUnwindTablesDefault =
+  TC.getDefaultUnwindTableLevel(Args) == 
ToolChain::UnwindTableLevel::Synchronous;
+
+  bool AsyncUnwindTables = Args.hasFlag(
+  options::OPT_fasynchronous_unwind_tables,
+  options::OPT_fno_asynchronous_unwind_tables,
+  (IsAsyncUnwindTablesDefault || SanitizeArgs.needsUnwindTables()) &&
+  !Freestanding);
+  bool UnwindTables =
+  Args.hasFlag(options::OPT_funwind_tables, options::OPT_fno_unwind_tables,
+   IsSyncUnwindTablesDefault && !Freestanding);
+  if (AsyncUnwindTables)
 CmdArgs.push_back("-funwind-tables=2");
+  else if (UnwindTables)
+ CmdArgs.push_back("-funwind-tables=1");
 
   // Prepare `-aux-target-cpu` and `-aux-target-feature` unless
   // `--gpu-use-aux-triple-only` is specified.
@@ -7316,7 +7313,7 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
 CmdArgs.push_back("-faddrsig");
 
   if ((Triple.isOSBinFormatELF() || Triple.isOSBinFormatMachO()) &&
-  (EH || UnwindTables != ToolChain::UnwindTableLevel::None ||
+  (EH || UnwindTables || AsyncUnwindTables ||
DebugInfoKind != codegenoptions::NoDebugInfo))
 CmdArgs.push_back("-D__GCC_HAVE_DWARF2_CFI_ASM=1");
 

diff  --git a/clang/test/Driver/clang-translation.c 
b/clang/test/Driver/clang-translation.c
index 715b0b3150bd..ca98ca5e8228 100644
--- a/clang/test/Driver/clang-translation.c
+++ b/clang/test/Driver/clang-translation.c
@@ -99,6 +99,17 @@
 //
 // ARM64-EXPLICIT-UWTABLE-APPLE: -funwind-tables
 
+// RUN: %clang -target arm64-apple-macosx -### -ffreestanding 
-fasynchronous-unwind-tables %s 2>&1 | \
+// RUN: FileCheck --check-prefix=ASYNC-UNWIND-FREESTANDING %s
+//
+// ASYNC-UNWIND-FREESTANDING: -funwind-tables=2
+
+// Quite weird behaviour, but it's a long-standing default.
+// RUN: %clang -target x86_64-apple-macosx -### -fno-unwind-tables %s 2>&1 |\
+// RUN: FileCheck --check-prefix=NOUNWIND-IGNORED %s
+//
+// NOUNWIND-IGNORED: -funwind-tables=2
+
 // RUN: %clang -target arm64-apple-ios10 -fno-exceptions -### -S %s -arch 
arm64 2>&1 | \
 // RUN: FileCheck -check-prefix=ARM64-APPLE-EXCEP %s
 // ARM64-APPLE-EXCEP-NOT: -funwind-tables



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


[clang] 677da09 - AArch64: add support for newer Apple CPUs

2022-09-22 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2022-09-22T11:58:51+01:00
New Revision: 677da09d0259d7530d32e85cb561bee15f0066e2

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

LOG: AArch64: add support for newer Apple CPUs

They're roughly ARMv8.6. This works in the .td file, but in
AArch64TargetParser.def, marking them v8.6 brings in support for the SM4
cryptographic hash and we don't actually have that. So TargetParser side
they're marked as v8.5, with the extra features (BF16 and I8MM added manually).

Finally, A16 supports the HCX extension in addition to v8.6. This has no
TargetParser implications.

Added: 


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/AArch64Subtarget.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.h
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 08e54b9a74889..1f5899fa2649f 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, ampere1{{$}}
+// 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-a15, apple-a16, apple-m1, apple-m2, 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, 
ampere1{{$}}
+// 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-a15, apple-a16,  apple-m1, apple-m2, 
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/include/llvm/Support/AArch64TargetParser.def
index e2f949856d9f7..72286439e0f84 100644
--- a/llvm/include/llvm/Support/AArch64TargetParser.def
+++ 

[clang] 4388b56 - Refactor unwind table driver interface to expose default level. NFC.

2022-09-20 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2022-09-20T10:47:18+01:00
New Revision: 4388b56d525c08ce3cf941cfbad2428b0e1695b0

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

LOG: Refactor unwind table driver interface to expose default level. NFC.

Added: 


Modified: 
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CrossWindows.cpp
clang/lib/Driver/ToolChains/CrossWindows.h
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Darwin.h
clang/lib/Driver/ToolChains/FreeBSD.cpp
clang/lib/Driver/ToolChains/FreeBSD.h
clang/lib/Driver/ToolChains/Fuchsia.h
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Gnu.h
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Driver/ToolChains/MSVC.h
clang/lib/Driver/ToolChains/MinGW.cpp
clang/lib/Driver/ToolChains/MinGW.h
clang/lib/Driver/ToolChains/NetBSD.h
clang/lib/Driver/ToolChains/OpenBSD.cpp
clang/lib/Driver/ToolChains/OpenBSD.h

Removed: 




diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index 28137e36e2af..a0d5127007cf 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -108,6 +108,12 @@ class ToolChain {
 UNW_Libgcc
   };
 
+  enum class UnwindTableLevel {
+None,
+Synchronous,
+Asynchronous,
+  };
+
   enum RTTIMode {
 RM_Enabled,
 RM_Disabled,
@@ -495,9 +501,9 @@ class ToolChain {
   /// Returns true if gcov instrumentation (-fprofile-arcs or --coverage) is 
on.
   static bool needsGCovInstrumentation(const llvm::opt::ArgList );
 
-  /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables
-  /// by default.
-  virtual bool IsUnwindTablesDefault(const llvm::opt::ArgList ) const;
+  /// How detailed should the unwind tables be by default.
+  virtual UnwindTableLevel
+  getDefaultUnwindTableLevel(const llvm::opt::ArgList ) const;
 
   /// Test whether this toolchain supports outline atomics by default.
   virtual bool

diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 26c5087b4ac2..5547f28d6351 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -287,8 +287,9 @@ std::string ToolChain::getInputFilename(const InputInfo 
) const {
   return Input.getFilename();
 }
 
-bool ToolChain::IsUnwindTablesDefault(const ArgList ) const {
-  return false;
+ToolChain::UnwindTableLevel
+ToolChain::getDefaultUnwindTableLevel(const ArgList ) const {
+  return UnwindTableLevel::None;
 }
 
 Tool *ToolChain::getClang() const {

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 9cc08306471c..34caeaf0f6af 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5461,17 +5461,26 @@ void Clang::ConstructJob(Compilation , const 
JobAction ,
   // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more
   // complicated ways.
   auto SanitizeArgs = TC.getSanitizerArgs(Args);
-  bool AsyncUnwindTables = Args.hasFlag(
-  options::OPT_fasynchronous_unwind_tables,
-  options::OPT_fno_asynchronous_unwind_tables,
-  (TC.IsUnwindTablesDefault(Args) || SanitizeArgs.needsUnwindTables()) &&
-  !Freestanding);
-  bool UnwindTables = Args.hasFlag(options::OPT_funwind_tables,
-   options::OPT_fno_unwind_tables, false);
-  if (AsyncUnwindTables)
-CmdArgs.push_back("-funwind-tables=2");
-  else if (UnwindTables)
+  auto UnwindTables = TC.getDefaultUnwindTableLevel(Args);
+
+  if (Args.hasFlag(options::OPT_fasynchronous_unwind_tables,
+   options::OPT_fno_asynchronous_unwind_tables,
+   SanitizeArgs.needsUnwindTables()) &&
+  !Freestanding)
+UnwindTables = ToolChain::UnwindTableLevel::Asynchronous;
+  else if (Args.hasFlag(options::OPT_funwind_tables,
+options::OPT_fno_unwind_tables, false))
+UnwindTables = ToolChain::UnwindTableLevel::Synchronous;
+  else if (Args.hasFlag(options::OPT_fno_unwind_tables,
+   options::OPT_fno_asynchronous_unwind_tables,
+   options::OPT_funwind_tables, false) || Freestanding)
+UnwindTables = ToolChain::UnwindTableLevel::None;
+
+
+  if (UnwindTables == ToolChain::UnwindTableLevel::Synchronous)
 CmdArgs.push_back("-funwind-tables=1");
+  else if (UnwindTables == ToolChain::UnwindTableLevel::Asynchronous)
+CmdArgs.push_back("-funwind-tables=2");
 
   // Prepare `-aux-target-cpu` and `-aux-target-feature` unless
   // `--gpu-use-aux-triple-only` is specified.
@@ -7293,7 +7302,7 @@ void Clang::ConstructJob(Compilation , 

[clang] 58f9aba - AAArch64: disable asynchronous unwind by default for MachO.

2022-09-20 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2022-09-20T10:47:18+01:00
New Revision: 58f9abaed4aa148566d5f14afdf473e57b20d687

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

LOG: AAArch64: disable asynchronous unwind by default for MachO.

AArch64 MachO has a compact unwind format where most functions' unwind info can
be represented in just 4 bytes. But this cannot represent any asynchronous CFI
function, so it's essentially disabled when that's used. This is a large
code-size hit that we'd rather not take unless explicitly requested.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/clang-translation.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index e466ce935a68..50572ff04ff8 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2932,7 +2932,8 @@ ToolChain::UnwindTableLevel 
MachO::getDefaultUnwindTableLevel(const ArgList 
   (GetExceptionModel(Args) != llvm::ExceptionHandling::SjLj &&
Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions,
 true)))
-return UnwindTableLevel::Asynchronous;
+return getArch() == llvm::Triple::aarch64 ? UnwindTableLevel::Synchronous
+  : UnwindTableLevel::Asynchronous;
 
   return UnwindTableLevel::None;
 }

diff  --git a/clang/test/Driver/clang-translation.c 
b/clang/test/Driver/clang-translation.c
index c471c6a8f73d..ffa732c8f656 100644
--- a/clang/test/Driver/clang-translation.c
+++ b/clang/test/Driver/clang-translation.c
@@ -77,7 +77,11 @@
 
 // RUN: %clang -target arm64-apple-ios10 -### -S %s -arch arm64 2>&1 | \
 // RUN: FileCheck -check-prefix=ARM64-APPLE %s
-// ARM64-APPLE: -funwind-tables=2
+// ARM64-APPLE: -funwind-tables=1
+
+// RUN: %clang -target arm64-apple-ios10 -funwind-tables -### -S %s -arch 
arm64 2>&1 | \
+// RUN: FileCheck -check-prefix=ARM64-APPLE-UNWIND %s
+// ARM64-APPLE-UNWIND: -funwind-tables=1
 
 // RUN: %clang -target arm64-apple-ios10 -### -ffreestanding -S %s -arch arm64 
2>&1 | \
 // RUN: FileCheck -check-prefix=ARM64-FREESTANDING-APPLE %s



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


[clang] 4f637c3 - [tests][Driver] Pass an empty sysroot for `DEFAULT_SYSROOT` builds

2022-03-04 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2022-03-04T09:01:50Z
New Revision: 4f637c30e1cd2d1d85f4f3b2ab042bfd75ae2865

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

LOG: [tests][Driver] Pass an empty sysroot for `DEFAULT_SYSROOT` builds

The baremetal-sysroot test fails when the toolchain is configured with
DEFAULT_SYSROOT. So, to emulate not having passed one at all, let's
pass an empty sysroot instead.

https://reviews.llvm.org/D119144

Patch by Carlo Cabrera 

Added: 


Modified: 
clang/test/Driver/baremetal-sysroot.cpp

Removed: 




diff  --git a/clang/test/Driver/baremetal-sysroot.cpp 
b/clang/test/Driver/baremetal-sysroot.cpp
index ae174e01417e7..fc66020772a77 100644
--- a/clang/test/Driver/baremetal-sysroot.cpp
+++ b/clang/test/Driver/baremetal-sysroot.cpp
@@ -10,7 +10,7 @@
 // RUN: ln -s %clang %T/baremetal_default_sysroot/bin/clang
 
 // RUN: %T/baremetal_default_sysroot/bin/clang -no-canonical-prefixes %s -### 
-o %t.o 2>&1 \
-// RUN: -target armv6m-none-eabi \
+// RUN: -target armv6m-none-eabi --sysroot= \
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-C %s
 // CHECK-V6M-C: "{{.*}}clang{{.*}}" "-cc1" "-triple" 
"thumbv6m-none-unknown-eabi"
 // CHECK-V6M-C-SAME: "-internal-isystem" 
"{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"



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


[clang] f24335c - MachO: fix Clang test broken by dropping private labels in LLVM.

2021-07-15 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2021-07-15T15:05:08+01:00
New Revision: f24335c69ea363082d922797363e98f1dcb3b14f

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

LOG: MachO: fix Clang test broken by dropping private labels in LLVM.

LLVM changed to not emit L... labels for things marked "do_not_dead_strip"
because the linker can sometimes drop the flag if there's no proper symbol.
This Clang test checked for the old behaviour, but doesn't actually care about
that bit.

Added: 


Modified: 
clang/test/CodeGenObjC/protocol-in-extended-class.m

Removed: 




diff  --git a/clang/test/CodeGenObjC/protocol-in-extended-class.m 
b/clang/test/CodeGenObjC/protocol-in-extended-class.m
index 26c858e53e803..74f1be9e53b5a 100644
--- a/clang/test/CodeGenObjC/protocol-in-extended-class.m
+++ b/clang/test/CodeGenObjC/protocol-in-extended-class.m
@@ -26,4 +26,4 @@ -(void) Meth {
 
 // CHECK-LP64: __OBJC_PROTOCOL_$_ExtendedProtocol:
 
-// CHECK-LP32: L_OBJC_PROTOCOL_ExtendedProtocol:
+// CHECK-LP32: _OBJC_PROTOCOL_ExtendedProtocol:



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


[clang-tools-extra] 48c68a6 - Recommit: Support: add llvm::thread class that supports specifying stack size.

2021-07-08 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2021-07-08T16:22:26+01:00
New Revision: 48c68a630e0101c16aa371f9202a4a53438b

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

LOG: Recommit: Support: add llvm::thread class that supports specifying stack 
size.

This adds a new llvm::thread class with the same interface as std::thread
except there is an extra constructor that allows us to set the new thread's
stack size. On Darwin even the default size is boosted to 8MB to match the main
thread.

It also switches all users of the older C-style `llvm_execute_on_thread` API
family over to `llvm::thread` followed by either a `detach` or `join` call and
removes the old API.

Moved definition of DefaultStackSize into the .cpp file to hopefully
fix the build on some (GCC-6?) machines.

Added: 


Modified: 
clang-tools-extra/clangd/support/Threading.cpp
clang/tools/libclang/CIndex.cpp
llvm/include/llvm/Support/CrashRecoveryContext.h
llvm/include/llvm/Support/Threading.h
llvm/include/llvm/Support/thread.h
llvm/lib/Support/CrashRecoveryContext.cpp
llvm/lib/Support/ThreadPool.cpp
llvm/lib/Support/Threading.cpp
llvm/lib/Support/Unix/Threading.inc
llvm/lib/Support/Windows/Threading.inc
llvm/unittests/Support/Threading.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/support/Threading.cpp 
b/clang-tools-extra/clangd/support/Threading.cpp
index 7f3bd62be306c..4d50776b941d2 100644
--- a/clang-tools-extra/clangd/support/Threading.cpp
+++ b/clang-tools-extra/clangd/support/Threading.cpp
@@ -3,6 +3,7 @@
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Threading.h"
+#include "llvm/Support/thread.h"
 #include 
 #include 
 #ifdef __USE_POSIX
@@ -95,8 +96,10 @@ void AsyncTaskRunner::runAsync(const llvm::Twine ,
   };
 
   // Ensure our worker threads have big enough stacks to run clang.
-  llvm::llvm_execute_on_thread_async(std::move(Task),
- /*clang::DesiredStackSize*/ 8 << 20);
+  llvm::thread Thread(
+  /*clang::DesiredStackSize*/ llvm::Optional(8 << 20),
+  std::move(Task));
+  Thread.detach();
 }
 
 Deadline timeoutSeconds(llvm::Optional Seconds) {

diff  --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index e3d34e1cf59bb..72eae1e2cd9ca 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -55,6 +55,7 @@
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/thread.h"
 #include 
 
 #if LLVM_ENABLE_THREADS != 0 && defined(__APPLE__)
@@ -6785,10 +6786,10 @@ void clang_enableStackTraces(void) {
 
 void clang_executeOnThread(void (*fn)(void *), void *user_data,
unsigned stack_size) {
-  llvm::llvm_execute_on_thread(fn, user_data,
-   stack_size == 0
-   ? clang::DesiredStackSize
-   : llvm::Optional(stack_size));
+  llvm::thread Thread(stack_size == 0 ? clang::DesiredStackSize
+  : llvm::Optional(stack_size),
+  fn, user_data);
+  Thread.join();
 }
 
 
//===--===//

diff  --git a/llvm/include/llvm/Support/CrashRecoveryContext.h 
b/llvm/include/llvm/Support/CrashRecoveryContext.h
index f756635ee1f90..498690655fd18 100644
--- a/llvm/include/llvm/Support/CrashRecoveryContext.h
+++ b/llvm/include/llvm/Support/CrashRecoveryContext.h
@@ -87,7 +87,7 @@ class CrashRecoveryContext {
   /// a protected context which is run in another thread (optionally with a
   /// requested stack size).
   ///
-  /// See RunSafely() and llvm_execute_on_thread().
+  /// See RunSafely().
   ///
   /// On Darwin, if PRIO_DARWIN_BG is set on the calling thread, it will be
   /// propagated to the new thread as well.

diff  --git a/llvm/include/llvm/Support/Threading.h 
b/llvm/include/llvm/Support/Threading.h
index e489caf47e9b1..94de950d44702 100644
--- a/llvm/include/llvm/Support/Threading.h
+++ b/llvm/include/llvm/Support/Threading.h
@@ -55,36 +55,6 @@ class Twine;
 /// false otherwise.
 bool llvm_is_multithreaded();
 
-/// Execute the given \p UserFn on a separate thread, passing it the provided 
\p
-/// UserData and waits for thread completion.
-///
-/// This function does not guarantee that the code will actually be executed
-/// on a separate thread or honoring the requested stack size, but tries to do
-/// so where system support is available.
-///
-/// \param UserFn - The callback to execute.
-/// \param UserData - An argument to pass to the callback function.
-/// \param StackSizeInBytes - A requested size (in bytes) for 

[clang] 48c68a6 - Recommit: Support: add llvm::thread class that supports specifying stack size.

2021-07-08 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2021-07-08T16:22:26+01:00
New Revision: 48c68a630e0101c16aa371f9202a4a53438b

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

LOG: Recommit: Support: add llvm::thread class that supports specifying stack 
size.

This adds a new llvm::thread class with the same interface as std::thread
except there is an extra constructor that allows us to set the new thread's
stack size. On Darwin even the default size is boosted to 8MB to match the main
thread.

It also switches all users of the older C-style `llvm_execute_on_thread` API
family over to `llvm::thread` followed by either a `detach` or `join` call and
removes the old API.

Moved definition of DefaultStackSize into the .cpp file to hopefully
fix the build on some (GCC-6?) machines.

Added: 


Modified: 
clang-tools-extra/clangd/support/Threading.cpp
clang/tools/libclang/CIndex.cpp
llvm/include/llvm/Support/CrashRecoveryContext.h
llvm/include/llvm/Support/Threading.h
llvm/include/llvm/Support/thread.h
llvm/lib/Support/CrashRecoveryContext.cpp
llvm/lib/Support/ThreadPool.cpp
llvm/lib/Support/Threading.cpp
llvm/lib/Support/Unix/Threading.inc
llvm/lib/Support/Windows/Threading.inc
llvm/unittests/Support/Threading.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/support/Threading.cpp 
b/clang-tools-extra/clangd/support/Threading.cpp
index 7f3bd62be306c..4d50776b941d2 100644
--- a/clang-tools-extra/clangd/support/Threading.cpp
+++ b/clang-tools-extra/clangd/support/Threading.cpp
@@ -3,6 +3,7 @@
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Threading.h"
+#include "llvm/Support/thread.h"
 #include 
 #include 
 #ifdef __USE_POSIX
@@ -95,8 +96,10 @@ void AsyncTaskRunner::runAsync(const llvm::Twine ,
   };
 
   // Ensure our worker threads have big enough stacks to run clang.
-  llvm::llvm_execute_on_thread_async(std::move(Task),
- /*clang::DesiredStackSize*/ 8 << 20);
+  llvm::thread Thread(
+  /*clang::DesiredStackSize*/ llvm::Optional(8 << 20),
+  std::move(Task));
+  Thread.detach();
 }
 
 Deadline timeoutSeconds(llvm::Optional Seconds) {

diff  --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index e3d34e1cf59bb..72eae1e2cd9ca 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -55,6 +55,7 @@
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/thread.h"
 #include 
 
 #if LLVM_ENABLE_THREADS != 0 && defined(__APPLE__)
@@ -6785,10 +6786,10 @@ void clang_enableStackTraces(void) {
 
 void clang_executeOnThread(void (*fn)(void *), void *user_data,
unsigned stack_size) {
-  llvm::llvm_execute_on_thread(fn, user_data,
-   stack_size == 0
-   ? clang::DesiredStackSize
-   : llvm::Optional(stack_size));
+  llvm::thread Thread(stack_size == 0 ? clang::DesiredStackSize
+  : llvm::Optional(stack_size),
+  fn, user_data);
+  Thread.join();
 }
 
 
//===--===//

diff  --git a/llvm/include/llvm/Support/CrashRecoveryContext.h 
b/llvm/include/llvm/Support/CrashRecoveryContext.h
index f756635ee1f90..498690655fd18 100644
--- a/llvm/include/llvm/Support/CrashRecoveryContext.h
+++ b/llvm/include/llvm/Support/CrashRecoveryContext.h
@@ -87,7 +87,7 @@ class CrashRecoveryContext {
   /// a protected context which is run in another thread (optionally with a
   /// requested stack size).
   ///
-  /// See RunSafely() and llvm_execute_on_thread().
+  /// See RunSafely().
   ///
   /// On Darwin, if PRIO_DARWIN_BG is set on the calling thread, it will be
   /// propagated to the new thread as well.

diff  --git a/llvm/include/llvm/Support/Threading.h 
b/llvm/include/llvm/Support/Threading.h
index e489caf47e9b1..94de950d44702 100644
--- a/llvm/include/llvm/Support/Threading.h
+++ b/llvm/include/llvm/Support/Threading.h
@@ -55,36 +55,6 @@ class Twine;
 /// false otherwise.
 bool llvm_is_multithreaded();
 
-/// Execute the given \p UserFn on a separate thread, passing it the provided 
\p
-/// UserData and waits for thread completion.
-///
-/// This function does not guarantee that the code will actually be executed
-/// on a separate thread or honoring the requested stack size, but tries to do
-/// so where system support is available.
-///
-/// \param UserFn - The callback to execute.
-/// \param UserData - An argument to pass to the callback function.
-/// \param StackSizeInBytes - A requested size (in bytes) for 

[clang] 2bf5e8d - Revert "Support: add llvm::thread class that supports specifying stack size."

2021-07-08 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2021-07-08T14:59:47+01:00
New Revision: 2bf5e8d953ededbc208bd4c116c9d6331d73f0f0

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

LOG: Revert "Support: add llvm::thread class that supports specifying stack 
size."

It's causing build failures because DefaultStackSize isn't defined everywhere
it should be and I need time to investigate.

Added: 


Modified: 
clang-tools-extra/clangd/support/Threading.cpp
clang/tools/libclang/CIndex.cpp
llvm/include/llvm/Support/CrashRecoveryContext.h
llvm/include/llvm/Support/Threading.h
llvm/include/llvm/Support/thread.h
llvm/lib/Support/CrashRecoveryContext.cpp
llvm/lib/Support/ThreadPool.cpp
llvm/lib/Support/Threading.cpp
llvm/lib/Support/Unix/Threading.inc
llvm/lib/Support/Windows/Threading.inc
llvm/unittests/Support/Threading.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/support/Threading.cpp 
b/clang-tools-extra/clangd/support/Threading.cpp
index 4d50776b941d2..7f3bd62be306c 100644
--- a/clang-tools-extra/clangd/support/Threading.cpp
+++ b/clang-tools-extra/clangd/support/Threading.cpp
@@ -3,7 +3,6 @@
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Threading.h"
-#include "llvm/Support/thread.h"
 #include 
 #include 
 #ifdef __USE_POSIX
@@ -96,10 +95,8 @@ void AsyncTaskRunner::runAsync(const llvm::Twine ,
   };
 
   // Ensure our worker threads have big enough stacks to run clang.
-  llvm::thread Thread(
-  /*clang::DesiredStackSize*/ llvm::Optional(8 << 20),
-  std::move(Task));
-  Thread.detach();
+  llvm::llvm_execute_on_thread_async(std::move(Task),
+ /*clang::DesiredStackSize*/ 8 << 20);
 }
 
 Deadline timeoutSeconds(llvm::Optional Seconds) {

diff  --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 72eae1e2cd9ca..e3d34e1cf59bb 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -55,7 +55,6 @@
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/thread.h"
 #include 
 
 #if LLVM_ENABLE_THREADS != 0 && defined(__APPLE__)
@@ -6786,10 +6785,10 @@ void clang_enableStackTraces(void) {
 
 void clang_executeOnThread(void (*fn)(void *), void *user_data,
unsigned stack_size) {
-  llvm::thread Thread(stack_size == 0 ? clang::DesiredStackSize
-  : llvm::Optional(stack_size),
-  fn, user_data);
-  Thread.join();
+  llvm::llvm_execute_on_thread(fn, user_data,
+   stack_size == 0
+   ? clang::DesiredStackSize
+   : llvm::Optional(stack_size));
 }
 
 
//===--===//

diff  --git a/llvm/include/llvm/Support/CrashRecoveryContext.h 
b/llvm/include/llvm/Support/CrashRecoveryContext.h
index 498690655fd18..f756635ee1f90 100644
--- a/llvm/include/llvm/Support/CrashRecoveryContext.h
+++ b/llvm/include/llvm/Support/CrashRecoveryContext.h
@@ -87,7 +87,7 @@ class CrashRecoveryContext {
   /// a protected context which is run in another thread (optionally with a
   /// requested stack size).
   ///
-  /// See RunSafely().
+  /// See RunSafely() and llvm_execute_on_thread().
   ///
   /// On Darwin, if PRIO_DARWIN_BG is set on the calling thread, it will be
   /// propagated to the new thread as well.

diff  --git a/llvm/include/llvm/Support/Threading.h 
b/llvm/include/llvm/Support/Threading.h
index 94de950d44702..e489caf47e9b1 100644
--- a/llvm/include/llvm/Support/Threading.h
+++ b/llvm/include/llvm/Support/Threading.h
@@ -55,6 +55,36 @@ class Twine;
 /// false otherwise.
 bool llvm_is_multithreaded();
 
+/// Execute the given \p UserFn on a separate thread, passing it the provided 
\p
+/// UserData and waits for thread completion.
+///
+/// This function does not guarantee that the code will actually be executed
+/// on a separate thread or honoring the requested stack size, but tries to do
+/// so where system support is available.
+///
+/// \param UserFn - The callback to execute.
+/// \param UserData - An argument to pass to the callback function.
+/// \param StackSizeInBytes - A requested size (in bytes) for the thread stack
+/// (or None for default)
+void llvm_execute_on_thread(
+void (*UserFn)(void *), void *UserData,
+llvm::Optional StackSizeInBytes = llvm::None);
+
+/// Schedule the given \p Func for execution on a separate thread, then return
+/// to the caller immediately. Roughly equivalent to
+/// `std::thread(Func).detach()`, except it allows requesting a specific stack
+/// size, if 

[clang] 727e1c9 - Support: add llvm::thread class that supports specifying stack size.

2021-07-08 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2021-07-08T14:51:53+01:00
New Revision: 727e1c9be3a5b20c6b502f056d74a681689049d7

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

LOG: Support: add llvm::thread class that supports specifying stack size.

This adds a new llvm::thread class with the same interface as std::thread
except there is an extra constructor that allows us to set the new thread's
stack size. On Darwin even the default size is boosted to 8MB to match the main
thread.

It also switches all users of the older C-style `llvm_execute_on_thread` API
family over to `llvm::thread` followed by either a `detach` or `join` call and
removes the old API.

Added: 


Modified: 
clang-tools-extra/clangd/support/Threading.cpp
clang/tools/libclang/CIndex.cpp
llvm/include/llvm/Support/CrashRecoveryContext.h
llvm/include/llvm/Support/Threading.h
llvm/include/llvm/Support/thread.h
llvm/lib/Support/CrashRecoveryContext.cpp
llvm/lib/Support/ThreadPool.cpp
llvm/lib/Support/Threading.cpp
llvm/lib/Support/Unix/Threading.inc
llvm/lib/Support/Windows/Threading.inc
llvm/unittests/Support/Threading.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/support/Threading.cpp 
b/clang-tools-extra/clangd/support/Threading.cpp
index 7f3bd62be306c..4d50776b941d2 100644
--- a/clang-tools-extra/clangd/support/Threading.cpp
+++ b/clang-tools-extra/clangd/support/Threading.cpp
@@ -3,6 +3,7 @@
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Threading.h"
+#include "llvm/Support/thread.h"
 #include 
 #include 
 #ifdef __USE_POSIX
@@ -95,8 +96,10 @@ void AsyncTaskRunner::runAsync(const llvm::Twine ,
   };
 
   // Ensure our worker threads have big enough stacks to run clang.
-  llvm::llvm_execute_on_thread_async(std::move(Task),
- /*clang::DesiredStackSize*/ 8 << 20);
+  llvm::thread Thread(
+  /*clang::DesiredStackSize*/ llvm::Optional(8 << 20),
+  std::move(Task));
+  Thread.detach();
 }
 
 Deadline timeoutSeconds(llvm::Optional Seconds) {

diff  --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index e3d34e1cf59bb..72eae1e2cd9ca 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -55,6 +55,7 @@
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/thread.h"
 #include 
 
 #if LLVM_ENABLE_THREADS != 0 && defined(__APPLE__)
@@ -6785,10 +6786,10 @@ void clang_enableStackTraces(void) {
 
 void clang_executeOnThread(void (*fn)(void *), void *user_data,
unsigned stack_size) {
-  llvm::llvm_execute_on_thread(fn, user_data,
-   stack_size == 0
-   ? clang::DesiredStackSize
-   : llvm::Optional(stack_size));
+  llvm::thread Thread(stack_size == 0 ? clang::DesiredStackSize
+  : llvm::Optional(stack_size),
+  fn, user_data);
+  Thread.join();
 }
 
 
//===--===//

diff  --git a/llvm/include/llvm/Support/CrashRecoveryContext.h 
b/llvm/include/llvm/Support/CrashRecoveryContext.h
index f756635ee1f90..498690655fd18 100644
--- a/llvm/include/llvm/Support/CrashRecoveryContext.h
+++ b/llvm/include/llvm/Support/CrashRecoveryContext.h
@@ -87,7 +87,7 @@ class CrashRecoveryContext {
   /// a protected context which is run in another thread (optionally with a
   /// requested stack size).
   ///
-  /// See RunSafely() and llvm_execute_on_thread().
+  /// See RunSafely().
   ///
   /// On Darwin, if PRIO_DARWIN_BG is set on the calling thread, it will be
   /// propagated to the new thread as well.

diff  --git a/llvm/include/llvm/Support/Threading.h 
b/llvm/include/llvm/Support/Threading.h
index e489caf47e9b1..94de950d44702 100644
--- a/llvm/include/llvm/Support/Threading.h
+++ b/llvm/include/llvm/Support/Threading.h
@@ -55,36 +55,6 @@ class Twine;
 /// false otherwise.
 bool llvm_is_multithreaded();
 
-/// Execute the given \p UserFn on a separate thread, passing it the provided 
\p
-/// UserData and waits for thread completion.
-///
-/// This function does not guarantee that the code will actually be executed
-/// on a separate thread or honoring the requested stack size, but tries to do
-/// so where system support is available.
-///
-/// \param UserFn - The callback to execute.
-/// \param UserData - An argument to pass to the callback function.
-/// \param StackSizeInBytes - A requested size (in bytes) for the thread stack
-/// (or None for default)
-void llvm_execute_on_thread(
-void (*UserFn)(void *), void *UserData,
-   

[clang] e94fada - SwiftAsync: add Clang attribute to apply the LLVM `swiftasync` one.

2021-05-28 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2021-05-28T12:31:12+01:00
New Revision: e94fada045fe88787a414e3307412c1cc3a1b259

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

LOG: SwiftAsync: add Clang attribute to apply the LLVM `swiftasync` one.

Expected to be used by Swift runtime developers.

Added: 


Modified: 
clang/include/clang/AST/Attr.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/Specifiers.h
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaType.cpp
clang/test/CodeGen/arm-swiftcall.c
clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/Sema/attr-swiftcall.c

Removed: 




diff  --git a/clang/include/clang/AST/Attr.h b/clang/include/clang/AST/Attr.h
index e453733ab92c..dbfecc125049 100644
--- a/clang/include/clang/AST/Attr.h
+++ b/clang/include/clang/AST/Attr.h
@@ -208,6 +208,8 @@ class ParameterABIAttr : public InheritableParamAttr {
 switch (getKind()) {
 case attr::SwiftContext:
   return ParameterABI::SwiftContext;
+case attr::SwiftAsyncContext:
+  return ParameterABI::SwiftAsyncContext;
 case attr::SwiftErrorResult:
   return ParameterABI::SwiftErrorResult;
 case attr::SwiftIndirectResult:

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 6a3945315393..5bfcec732907 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2457,6 +2457,11 @@ def SwiftContext : ParameterABIAttr {
   let Documentation = [SwiftContextDocs];
 }
 
+def SwiftAsyncContext : ParameterABIAttr {
+  let Spellings = [Clang<"swift_async_context">];
+  let Documentation = [SwiftAsyncContextDocs];
+}
+
 def SwiftErrorResult : ParameterABIAttr {
   let Spellings = [Clang<"swift_error_result">];
   let Documentation = [SwiftErrorResultDocs];

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index e9ee45d91dc5..cdbbb38573da 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4529,6 +4529,19 @@ A context parameter must have pointer or reference type.
   }];
 }
 
+def SwiftAsyncContextDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{
+The ``swift_async_context`` attribute marks a parameter as having the
+special asynchronous context-parameter ABI treatment.
+
+This treatment generally passes the context value in a special register
+which is normally callee-preserved.
+
+A context parameter must have pointer or reference type.
+  }];
+}
+
 def SwiftErrorResultDocs : Documentation {
   let Category = DocCatVariable;
   let Content = [{

diff  --git a/clang/include/clang/Basic/Specifiers.h 
b/clang/include/clang/Basic/Specifiers.h
index 07d8177b8ab2..148421ea1124 100644
--- a/clang/include/clang/Basic/Specifiers.h
+++ b/clang/include/clang/Basic/Specifiers.h
@@ -344,7 +344,12 @@ namespace clang {
 /// This parameter (which must have pointer type) uses the special
 /// Swift context-pointer ABI treatment.  There can be at
 /// most one parameter on a given function that uses this treatment.
-SwiftContext
+SwiftContext,
+
+/// This parameter (which must have pointer type) uses the special
+/// Swift asynchronous context-pointer ABI treatment.  There can be at
+/// most one parameter on a given function that uses this treatment.
+SwiftAsyncContext,
   };
 
   /// Assigned inheritance model for a class in the MS C++ ABI. Must match 
order

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 94e404a5f38a..b5b9cd753519 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -3140,6 +3140,7 @@ 
CXXNameMangler::mangleExtParameterInfo(FunctionProtoType::ExtParameterInfo PI) {
 
   // All of these start with "swift", so they come before "ns_consumed".
   case ParameterABI::SwiftContext:
+  case ParameterABI::SwiftAsyncContext:
   case ParameterABI::SwiftErrorResult:
   case ParameterABI::SwiftIndirectResult:
 mangleVendorQualifier(getParameterABISpelling(PI.getABI()));

diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index b2ce28e0ae1e..720cab917a22 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -846,6 +846,8 @@ StringRef clang::getParameterABISpelling(ParameterABI ABI) {
 llvm_unreachable("asking for spelling of ordinary parameter ABI");
   case ParameterABI::SwiftContext:
 return "swift_context";
+  case ParameterABI::SwiftAsyncContext:
+return "swift_async_context";
   case ParameterABI::SwiftErrorResult:
 return 

[clang] c454200 - AArch64/MacOS: switch default CPU to apple-a13.

2021-03-08 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2021-03-08T15:47:05Z
New Revision: c4542005dae203dc4cb4e4be22628d4e24b4d5b6

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

LOG: AArch64/MacOS: switch default CPU to apple-a13.

The DevKits had A12 processors, but they're all gone now and real hardware has
an A13.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Driver/aarch64-mac-cpus.c
clang/test/Preprocessor/aarch64-target-features.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index a5e632fd8cdb..0789bb222a26 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -50,8 +50,8 @@ std::string aarch64::getAArch64TargetCPU(const ArgList ,
 
   if (Triple.isTargetMachineMac() &&
   Triple.getArch() == llvm::Triple::aarch64) {
-// Apple Silicon macs default to A12 CPUs.
-return "apple-a12";
+// Apple Silicon macs default to A13 CPUs.
+return "apple-a13";
   }
 
   // Make sure we pick the appropriate Apple CPU if -arch is used or when

diff  --git a/clang/test/Driver/aarch64-mac-cpus.c 
b/clang/test/Driver/aarch64-mac-cpus.c
index 437c38376545..8d7b51ec96cf 100644
--- a/clang/test/Driver/aarch64-mac-cpus.c
+++ b/clang/test/Driver/aarch64-mac-cpus.c
@@ -1,4 +1,4 @@
-// arm64 Mac-based targets default to Apple A12.
+// arm64 Mac-based targets default to Apple A13.
 
 // RUN: %clang -target arm64-apple-macos -### -c %s 2>&1 | 
FileCheck %s
 // RUN: %clang -target arm64-apple-ios-macabi-### -c %s 2>&1 | 
FileCheck %s
@@ -12,8 +12,8 @@
 // RUN: %clang -target arm64-apple-macos -mcpu=apple-a7  -### -c %s 2>&1 | 
FileCheck --check-prefix=EXPLICIT-A7 %s
 // RUN: %clang -target arm64-apple-macos -mcpu=apple-a13 -### -c %s 2>&1 | 
FileCheck --check-prefix=EXPLICIT-A13 %s
 
-// CHECK: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "apple-a12"
-// CHECK-SAME: "-target-feature" "+v8.3a"
+// CHECK: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "apple-a13"
+// CHECK-SAME: "-target-feature" "+v8.4a"
 
 // EXPLICIT-A11: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "apple-a11"
 // EXPLICIT-A7: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "apple-a7"

diff  --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index 430508cf4233..3c7b56d75553 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -255,7 +255,7 @@
 // CHECK-MCPU-CARMEL: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8.2a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+fullfp16" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+sha2" "-target-feature" "+aes"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-ARCH-ARM64 %s
-// CHECK-ARCH-ARM64: "-target-cpu" "apple-a12" "-target-feature" "+v8.3a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+fullfp16" 
"-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" 
"-target-feature" "+rcpc" "-target-feature" "+zcm" "-target-feature" "+zcz"
+// CHECK-ARCH-ARM64: "-target-cpu" "apple-a13" "-target-feature" "+v8.4a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+dotprod" 
"-target-feature" "+fullfp16" "-target-feature" "+ras" "-target-feature" "+lse" 
"-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" 
"-target-feature" "+zcz" "-target-feature" "+fp16fml"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64_32 -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-ARCH-ARM64_32 %s
 // CHECK-ARCH-ARM64_32: "-target-cpu" "apple-s4" "-target-feature" "+v8.3a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+fullfp16" 
"-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" 
"-target-feature" "+rcpc" "-target-feature" "+zcm" "-target-feature" "+zcz" 
"-target-feature" "+sha2" "-target-feature" "+aes"



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


[clang] 888c5c2 - AArch64: report fp16 arithmetic is present for apple-a11 CPU.

2021-03-02 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2021-03-02T15:07:18Z
New Revision: 888c5c24cab63091774b7065e6925177bb43787d

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

LOG: AArch64: report fp16 arithmetic is present for apple-a11 CPU.

AArch64.td got it right, but the target-parser dropped it, leading to missing
feature flags in Clang.

Added: 


Modified: 
clang/test/Preprocessor/aarch64-target-features.c
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index 7ac5eac24f6c..ceda05d7294b 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -231,7 +231,7 @@
 // RUN: %clang -target aarch64 -mcpu=carmel -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-CARMEL %s
 // CHECK-MCPU-APPLE-A7: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" 
"+sha2" "-target-feature" "+aes"
 // CHECK-MCPU-APPLE-A10: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+rdm" "-target-feature" 
"+zcm" "-target-feature" "+zcz" "-target-feature" "+sha2" "-target-feature" 
"+aes"
-// CHECK-MCPU-APPLE-A11: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8.2a" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+ras" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" 
"+zcm" "-target-feature" "+zcz" "-target-feature" "+sha2" "-target-feature" 
"+aes"
+// CHECK-MCPU-APPLE-A11: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8.2a" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+fullfp16" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" 
"+sha2" "-target-feature" "+aes"
 // CHECK-MCPU-APPLE-A12: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8.3a" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+fullfp16" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" "-target-feature" 
"+zcz" "-target-feature" "+sha2" "-target-feature" "+aes"
 // CHECK-MCPU-A34: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc"
 // CHECK-MCPU-APPLE-A13: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8.4a" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+dotprod" "-target-feature" "+fullfp16" "-target-feature" "+ras" 
"-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" "+rcpc" 
"-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "+fp16fml" 
"-target-feature" "+sm4" "-target-feature" "+sha3" "-target-feature" "+sha2" 
"-target-feature" "+aes"

diff  --git a/llvm/include/llvm/Support/AArch64TargetParser.def 
b/llvm/include/llvm/Support/AArch64TargetParser.def
index 332fb555e824..5d146f88fa60 100644
--- a/llvm/include/llvm/Support/AArch64TargetParser.def
+++ b/llvm/include/llvm/Support/AArch64TargetParser.def
@@ -184,7 +184,7 @@ AARCH64_CPU_NAME("apple-a9", ARMV8A, 
FK_CRYPTO_NEON_FP_ARMV8, false,
 AARCH64_CPU_NAME("apple-a10", ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false,
  (AArch64::AEK_CRC | AArch64::AEK_RDM))
 AARCH64_CPU_NAME("apple-a11", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false,
- (AArch64::AEK_NONE))
+ (AArch64::AEK_FP16))
 AARCH64_CPU_NAME("apple-a12", ARMV8_3A, FK_CRYPTO_NEON_FP_ARMV8, false,
  (AArch64::AEK_FP16))
 AARCH64_CPU_NAME("apple-a13", ARMV8_4A, FK_CRYPTO_NEON_FP_ARMV8, false,

diff  --git a/llvm/unittests/Support/TargetParserTest.cpp 
b/llvm/unittests/Support/TargetParserTest.cpp
index 7be133cf2c7a..648ef14a07ef 100644
--- a/llvm/unittests/Support/TargetParserTest.cpp
+++ b/llvm/unittests/Support/TargetParserTest.cpp
@@ -1023,10 +1023,10 @@ INSTANTIATE_TEST_CASE_P(
  AArch64::AEK_SIMD,
  "8-A"),
 ARMCPUTestParams("apple-a11", "armv8.2-a", "crypto-neon-fp-armv8",
- AArch64::AEK_NONE | AArch64::AEK_CRC |
- AArch64::AEK_CRYPTO | 

[clang] 152df3a - arm64: count Triple::aarch64_32 as an aarch64 target and enable leaf frame pointers

2020-12-03 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2020-12-03T11:09:44Z
New Revision: 152df3add156b68aca7bfb06b62ea85fa127f3b1

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

LOG: arm64: count Triple::aarch64_32 as an aarch64 target and enable leaf frame 
pointers

Added: 


Modified: 
clang/lib/Driver/ToolChain.cpp
clang/test/Driver/frame-pointer-elim.c
llvm/include/llvm/ADT/Triple.h
llvm/lib/BinaryFormat/MachO.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 0330afdcec48..85ab05cb7021 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -1075,9 +1075,9 @@ SanitizerMask ToolChain::getSupportedSanitizers() const {
   getTriple().isAArch64())
 Res |= SanitizerKind::CFIICall;
   if (getTriple().getArch() == llvm::Triple::x86_64 ||
-  getTriple().isAArch64() || getTriple().isRISCV())
+  getTriple().isAArch64(64) || getTriple().isRISCV())
 Res |= SanitizerKind::ShadowCallStack;
-  if (getTriple().isAArch64())
+  if (getTriple().isAArch64(64))
 Res |= SanitizerKind::MemTag;
   return Res;
 }

diff  --git a/clang/test/Driver/frame-pointer-elim.c 
b/clang/test/Driver/frame-pointer-elim.c
index fd74da7768eb..83dbf3816b68 100644
--- a/clang/test/Driver/frame-pointer-elim.c
+++ b/clang/test/Driver/frame-pointer-elim.c
@@ -97,6 +97,8 @@
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 // RUN: %clang -### -target x86_64-scei-ps4 -S -O2 %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
+// RUN: %clang -### -target aarch64-apple-darwin -arch arm64_32 -S %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 
 // RUN: %clang -### -target powerpc64 -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-ALL %s

diff  --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index 6bfdfe691c2e..4e1a9499bf81 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/include/llvm/ADT/Triple.h
@@ -714,7 +714,17 @@ class Triple {
 
   /// Tests whether the target is AArch64 (little and big endian).
   bool isAArch64() const {
-return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be;
+return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be ||
+   getArch() == Triple::aarch64_32;
+  }
+
+  /// Tests whether the target is AArch64 and pointers are the size specified 
by
+  /// \p PointerWidth.
+  bool isAArch64(int PointerWidth) const {
+assert(PointerWidth == 64 || PointerWidth == 32);
+if (!isAArch64())
+  return false;
+return isArch64Bit() ? PointerWidth == 64 : PointerWidth == 32;
   }
 
   /// Tests whether the target is MIPS 32-bit (little and big endian).

diff  --git a/llvm/lib/BinaryFormat/MachO.cpp b/llvm/lib/BinaryFormat/MachO.cpp
index 2b9eb8025521..0901022a6141 100644
--- a/llvm/lib/BinaryFormat/MachO.cpp
+++ b/llvm/lib/BinaryFormat/MachO.cpp
@@ -55,7 +55,7 @@ static MachO::CPUSubTypeARM getARMSubType(const Triple ) {
 }
 
 static MachO::CPUSubTypeARM64 getARM64SubType(const Triple ) {
-  assert(T.isAArch64() || T.getArch() == Triple::aarch64_32);
+  assert(T.isAArch64());
   if (T.isArch32Bit())
 return (MachO::CPUSubTypeARM64)MachO::CPU_SUBTYPE_ARM64_32_V8;
   if (T.getArchName() == "arm64e")
@@ -84,9 +84,7 @@ Expected MachO::getCPUType(const Triple ) {
   if (T.isARM() || T.isThumb())
 return MachO::CPU_TYPE_ARM;
   if (T.isAArch64())
-return MachO::CPU_TYPE_ARM64;
-  if (T.getArch() == Triple::aarch64_32)
-return MachO::CPU_TYPE_ARM64_32;
+return T.isArch32Bit() ? MachO::CPU_TYPE_ARM64_32 : MachO::CPU_TYPE_ARM64;
   if (T.getArch() == Triple::ppc)
 return MachO::CPU_TYPE_POWERPC;
   if (T.getArch() == Triple::ppc64)



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


[clang] 9697a9e - Fix typo in identifier in assert.

2020-07-15 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2020-07-15T09:57:53+01:00
New Revision: 9697a9e2d316f0d9d588f4de536b0a6bbef2810f

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

LOG: Fix typo in identifier in assert.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 34f4f21746f7..8994b939093e 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -6400,7 +6400,7 @@ static Value *EmitSpecialRegisterBuiltin(CodeGenFunction 
,
 && "Can't fit 64-bit value in 32-bit register");
 
   if (AccessKind != Write) {
-assert(AccesKind == NormalRead || AccessKind == VolatileRead);
+assert(AccessKind == NormalRead || AccessKind == VolatileRead);
 llvm::Function *F = CGM.getIntrinsic(
 AccessKind == VolatileRead ? llvm::Intrinsic::read_volatile_register
: llvm::Intrinsic::read_register,



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


[clang] 5165b2b - AArch64+ARM: make LLVM consider system registers volatile.

2020-07-15 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2020-07-15T09:47:36+01:00
New Revision: 5165b2b5fd5fd62c5a34970be81c79231844804c

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

LOG: AArch64+ARM: make LLVM consider system registers volatile.

Some of the system registers readable on AArch64 and ARM platforms
return different values with each read (for example a timer counter),
these shouldn't be hoisted outside loops or otherwise interfered with,
but the normal @llvm.read_register intrinsic is only considered to read
memory.

This introduces a separate @llvm.read_volatile_register intrinsic and
maps all system-registers on ARM platforms to use it for the
__builtin_arm_rsr calls. Registers declared with asm("r9") or similar
are unaffected.

Added: 
llvm/test/Transforms/LICM/read-volatile-register.ll

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-arm.c
clang/test/CodeGen/builtins-arm64.c
llvm/docs/LangRef.rst
llvm/include/llvm/IR/Intrinsics.td
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 35a93a7889f4..34f4f21746f7 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -6361,6 +6361,12 @@ Value *CodeGenFunction::GetValueForARMHint(unsigned 
BuiltinID) {
 llvm::ConstantInt::get(Int32Ty, Value));
 }
 
+enum SpecialRegisterAccessKind {
+  NormalRead,
+  VolatileRead,
+  Write,
+};
+
 // Generates the IR for the read/write special register builtin,
 // ValueType is the type of the value that is to be written or read,
 // RegisterType is the type of the register being written to or read from.
@@ -6368,7 +6374,7 @@ static Value *EmitSpecialRegisterBuiltin(CodeGenFunction 
,
  const CallExpr *E,
  llvm::Type *RegisterType,
  llvm::Type *ValueType,
- bool IsRead,
+ SpecialRegisterAccessKind AccessKind,
  StringRef SysReg = "") {
   // write and register intrinsics only support 32 and 64 bit operations.
   assert((RegisterType->isIntegerTy(32) || RegisterType->isIntegerTy(64))
@@ -6393,8 +6399,12 @@ static Value *EmitSpecialRegisterBuiltin(CodeGenFunction 
,
   assert(!(RegisterType->isIntegerTy(32) && ValueType->isIntegerTy(64))
 && "Can't fit 64-bit value in 32-bit register");
 
-  if (IsRead) {
-llvm::Function *F = CGM.getIntrinsic(llvm::Intrinsic::read_register, 
Types);
+  if (AccessKind != Write) {
+assert(AccesKind == NormalRead || AccessKind == VolatileRead);
+llvm::Function *F = CGM.getIntrinsic(
+AccessKind == VolatileRead ? llvm::Intrinsic::read_volatile_register
+   : llvm::Intrinsic::read_register,
+Types);
 llvm::Value *Call = Builder.CreateCall(F, Metadata);
 
 if (MixedTypes)
@@ -6773,9 +6783,11 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned 
BuiltinID,
   BuiltinID == ARM::BI__builtin_arm_wsr64 ||
   BuiltinID == ARM::BI__builtin_arm_wsrp) {
 
-bool IsRead = BuiltinID == ARM::BI__builtin_arm_rsr ||
-  BuiltinID == ARM::BI__builtin_arm_rsr64 ||
-  BuiltinID == ARM::BI__builtin_arm_rsrp;
+SpecialRegisterAccessKind AccessKind = Write;
+if (BuiltinID == ARM::BI__builtin_arm_rsr ||
+BuiltinID == ARM::BI__builtin_arm_rsr64 ||
+BuiltinID == ARM::BI__builtin_arm_rsrp)
+  AccessKind = VolatileRead;
 
 bool IsPointerBuiltin = BuiltinID == ARM::BI__builtin_arm_rsrp ||
 BuiltinID == ARM::BI__builtin_arm_wsrp;
@@ -6794,7 +6806,8 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned 
BuiltinID,
   ValueType = RegisterType = Int32Ty;
 }
 
-return EmitSpecialRegisterBuiltin(*this, E, RegisterType, ValueType, 
IsRead);
+return EmitSpecialRegisterBuiltin(*this, E, RegisterType, ValueType,
+  AccessKind);
   }
 
   // Deal with MVE builtins
@@ -8834,9 +8847,11 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned 
BuiltinID,
   BuiltinID == AArch64::BI__builtin_arm_wsr64 ||
   BuiltinID == AArch64::BI__builtin_arm_wsrp) {
 
-bool IsRead = BuiltinID == AArch64::BI__builtin_arm_rsr ||
-  BuiltinID == AArch64::BI__builtin_arm_rsr64 ||
-  BuiltinID == AArch64::BI__builtin_arm_rsrp;
+SpecialRegisterAccessKind AccessKind = Write;
+if (BuiltinID == AArch64::BI__builtin_arm_rsr ||
+BuiltinID == 

[clang] 903e5c3 - AArch64: add missing Apple CPU names and use them by default.

2020-01-08 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2020-01-08T09:24:06Z
New Revision: 903e5c3028d61481c570c09eeb5e7a920c2d7d38

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

LOG: AArch64: add missing Apple CPU names and use them by default.

Apple's CPUs are called A7-A13 in official communication, occasionally with
weird suffixes which we probably don't need to care about. This adds each one
and describes its features. It also switches the default CPU to the canonical
name for Cyclone, but leaves legacy support in so that existing bitcode still
compiles.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Driver/aarch64-cpus.c
clang/test/Driver/arm64-as.s
clang/test/Preprocessor/aarch64-target-features.c
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.h
llvm/lib/Target/AArch64/AArch64SystemOperands.td
llvm/test/CodeGen/AArch64/arm64-zero-cycle-zeroing.ll
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 3a5fe6ddeaed..9c27504dccf5 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -43,10 +43,11 @@ std::string aarch64::getAArch64TargetCPU(const ArgList 
,
   else if (CPU.size())
 return CPU;
 
-  // Make sure we pick "cyclone" if -arch is used or when targetting a Darwin
-  // OS.
+  // Make sure we pick the appropriate Apple CPU if -arch is used or when
+  // targetting a Darwin OS.
   if (Args.getLastArg(options::OPT_arch) || Triple.isOSDarwin())
-return "cyclone";
+return Triple.getArch() == llvm::Triple::aarch64_32 ? "apple-s4"
+: "apple-a7";
 
   return "generic";
 }
@@ -139,7 +140,7 @@ getAArch64MicroArchFeaturesFromMtune(const Driver , 
StringRef Mtune,
   // Handle CPU name is 'native'.
   if (MtuneLowerCase == "native")
 MtuneLowerCase = llvm::sys::getHostCPUName();
-  if (MtuneLowerCase == "cyclone") {
+  if (MtuneLowerCase == "cyclone" || MtuneLowerCase.find("apple") == 0) {
 Features.push_back("+zcm");
 Features.push_back("+zcz");
   }

diff  --git a/clang/test/Driver/aarch64-cpus.c 
b/clang/test/Driver/aarch64-cpus.c
index 66b439fd2cad..c7dc5f63d678 100644
--- a/clang/test/Driver/aarch64-cpus.c
+++ b/clang/test/Driver/aarch64-cpus.c
@@ -23,11 +23,11 @@
 // RUN: %clang -target arm64-apple-darwin -arch arm64 -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-DARWIN %s
 // RUN: %clang -target arm64-apple-darwin -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-DARWIN %s
 // RUN: %clang -target arm64-apple-ios12.0 -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-DARWIN %s
-// ARM64-DARWIN: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "cyclone"
+// ARM64-DARWIN: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "apple-a7"
 // ARM64-DARWIN-SAME: "-target-feature" "+aes"
 
 // RUN: %clang -target arm64-apple-darwin -arch arm64_32 -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64_32-DARWIN %s
-// ARM64_32-DARWIN: "-cc1"{{.*}} "-triple" "aarch64_32{{.*}}" "-target-cpu" 
"cyclone"
+// ARM64_32-DARWIN: "-cc1"{{.*}} "-triple" "aarch64_32{{.*}}" "-target-cpu" 
"apple-s4"
 
 // RUN: %clang -target aarch64 -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck 
-check-prefix=CA35 %s
 // RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a35 -### -c %s 
2>&1 | FileCheck -check-prefix=CA35 %s

diff  --git a/clang/test/Driver/arm64-as.s b/clang/test/Driver/arm64-as.s
index 061e5b2eff87..956ea938ee03 100644
--- a/clang/test/Driver/arm64-as.s
+++ b/clang/test/Driver/arm64-as.s
@@ -2,4 +2,4 @@
 // RUN: %clang -target arm64-apple-ios -arch arm64 -### -c %s 2>&1 | FileCheck 
-check-prefix=TARGET %s
 //
 // TARGET: "-cc1as"
-// TARGET: "-target-cpu" "cyclone"
+// TARGET: "-target-cpu" "apple-a7"

diff  --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index 723cbb486576..6d2225d1bdda 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -142,7 +142,16 @@
 // RUN: %clang -target aarch64 -mtune=CYCLONE -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MTUNE-CYCLONE %s
 // CHECK-MTUNE-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+neon" "-target-feature" "+zcm" "-target-feature" "+zcz"
 
-// RUN: %clang -target aarch64 -mcpu=cyclone -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-CYCLONE %s
+// RUN: %clang -target aarch64 -mcpu=apple-a7 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-APPLE-A7 %s
+// RUN: 

[clang] 85cb560 - ConstrainedFP: use API compatible with opaque pointers.

2019-12-19 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2019-12-19T21:50:47Z
New Revision: 85cb560b8a421d950ccea593b4ee0569249dc136

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

LOG: ConstrainedFP: use API compatible with opaque pointers.

This just updates an IRBuilder interface to take Functions instead of
Values so the type can be derived, and fixes some callsites in Clang to
call the updated API.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
llvm/include/llvm/IR/IRBuilder.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 37aca09bff5b..3b35fc23a1b9 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -368,10 +368,10 @@ static Value 
*emitUnaryMaybeConstrainedFPBuiltin(CodeGenFunction ,
   llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
 
   if (CGF.Builder.getIsFPConstrained()) {
-Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, 
Src0->getType());
 return CGF.Builder.CreateConstrainedFPCall(F, { Src0 });
   } else {
-Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
 return CGF.Builder.CreateCall(F, Src0);
   }
 }
@@ -385,10 +385,10 @@ static Value 
*emitBinaryMaybeConstrainedFPBuiltin(CodeGenFunction ,
   llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
 
   if (CGF.Builder.getIsFPConstrained()) {
-Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, 
Src0->getType());
 return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1 });
   } else {
-Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
 return CGF.Builder.CreateCall(F, { Src0, Src1 });
   }
 }
@@ -403,10 +403,10 @@ static Value 
*emitTernaryMaybeConstrainedFPBuiltin(CodeGenFunction ,
   llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2));
 
   if (CGF.Builder.getIsFPConstrained()) {
-Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, 
Src0->getType());
 return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1, Src2 });
   } else {
-Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
 return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 });
   }
 }

diff  --git a/llvm/include/llvm/IR/IRBuilder.h 
b/llvm/include/llvm/IR/IRBuilder.h
index 5d5f12d2c7c6..1abdf2242b58 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -2421,18 +2421,16 @@ class IRBuilder : public IRBuilderBase, public Inserter 
{
 Args, OpBundles, Name, FPMathTag);
   }
 
-  // Deprecated [opaque pointer types]
   CallInst *CreateConstrainedFPCall(
-  Value *Callee, ArrayRef Args, const Twine  = "",
+  Function *Callee, ArrayRef Args, const Twine  = "",
   Optional Rounding = None,
   Optional Except = None) {
 llvm::SmallVector UseArgs;
 
 for (auto *OneArg : Args)
   UseArgs.push_back(OneArg);
-Function *F = cast(Callee);
 bool HasRoundingMD = false;
-switch (F->getIntrinsicID()) {
+switch (Callee->getIntrinsicID()) {
 default:
   break;
 #define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN)  \
@@ -2445,9 +2443,7 @@ class IRBuilder : public IRBuilderBase, public Inserter {
   UseArgs.push_back(getConstrainedFPRounding(Rounding));
 UseArgs.push_back(getConstrainedFPExcept(Except));
 
-CallInst *C = CreateCall(
-cast(Callee->getType()->getPointerElementType()), Callee,
-UseArgs, Name);
+CallInst *C = CreateCall(Callee, UseArgs, Name);
 setConstrainedFPCallAttr(C);
 return C;
   }



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


[clang] 5cf5876 - Atomics: support min/max orthogonally

2019-11-21 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2019-11-21T10:37:56Z
New Revision: 5cf58768cb3ba31ee37facaf23f7a74f78781590

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

LOG: Atomics: support min/max orthogonally

We seem to have been gradually growing support for atomic min/max operations
(exposing longstanding IR atomicrmw instructions). But until now there have
been gaps in the expected intrinsics. This adds support for the C11-style
intrinsics (i.e. taking _Atomic, rather than individually blessed by C11
standard), and the variants that return the new value instead of the original
one.

That way, people won't be misled by trying one form and it not working, and the
front-end is more friendly to people using _Atomic types, as we recommend.

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/Expr.cpp
clang/lib/CodeGen/CGAtomic.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/atomic-ops.c
clang/test/Sema/atomic-ops.c
clang/test/SemaOpenCL/atomic-ops.cl

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index a9fb85fa0d8d..d9a4862dbe80 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -2586,6 +2586,8 @@ the corresponding C11 operations, are:
 * ``__c11_atomic_fetch_and``
 * ``__c11_atomic_fetch_or``
 * ``__c11_atomic_fetch_xor``
+* ``__c11_atomic_fetch_max``
+* ``__c11_atomic_fetch_min``
 
 The macros ``__ATOMIC_RELAXED``, ``__ATOMIC_CONSUME``, ``__ATOMIC_ACQUIRE``,
 ``__ATOMIC_RELEASE``, ``__ATOMIC_ACQ_REL``, and ``__ATOMIC_SEQ_CST`` are

diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 4ed00a13b004..8a102744700f 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -718,6 +718,8 @@ ATOMIC_BUILTIN(__c11_atomic_fetch_sub, "v.", "t")
 ATOMIC_BUILTIN(__c11_atomic_fetch_and, "v.", "t")
 ATOMIC_BUILTIN(__c11_atomic_fetch_or, "v.", "t")
 ATOMIC_BUILTIN(__c11_atomic_fetch_xor, "v.", "t")
+ATOMIC_BUILTIN(__c11_atomic_fetch_max, "v.", "t")
+ATOMIC_BUILTIN(__c11_atomic_fetch_min, "v.", "t")
 BUILTIN(__c11_atomic_thread_fence, "vi", "n")
 BUILTIN(__c11_atomic_signal_fence, "vi", "n")
 BUILTIN(__c11_atomic_is_lock_free, "iz", "n")
@@ -742,6 +744,8 @@ ATOMIC_BUILTIN(__atomic_sub_fetch, "v.", "t")
 ATOMIC_BUILTIN(__atomic_and_fetch, "v.", "t")
 ATOMIC_BUILTIN(__atomic_or_fetch, "v.", "t")
 ATOMIC_BUILTIN(__atomic_xor_fetch, "v.", "t")
+ATOMIC_BUILTIN(__atomic_max_fetch, "v.", "t")
+ATOMIC_BUILTIN(__atomic_min_fetch, "v.", "t")
 ATOMIC_BUILTIN(__atomic_nand_fetch, "v.", "t")
 BUILTIN(__atomic_test_and_set, "bvD*i", "n")
 BUILTIN(__atomic_clear, "vvD*i", "n")

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 78ff18b8798e..eb05a7e910c9 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7430,10 +7430,8 @@ def err_atomic_op_needs_trivial_copy : Error<
 def err_atomic_op_needs_atomic_int_or_ptr : Error<
   "address argument to atomic operation must be a pointer to %select{|atomic 
}0"
   "integer or pointer (%1 invalid)">;
-def err_atomic_op_needs_int32_or_ptr : Error<
-  "address argument to atomic operation must be a pointer to signed or 
unsigned 32-bit integer">;
-def err_atomic_op_bitwise_needs_atomic_int : Error<
-  "address argument to bitwise atomic operation must be a pointer to "
+def err_atomic_op_needs_atomic_int : Error<
+  "address argument to atomic operation must be a pointer to "
   "%select{|atomic }0integer (%1 invalid)">;
 def warn_atomic_op_has_invalid_memory_order : Warning<
   "memory order argument to atomic operation is invalid">,

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index e5bb8a778c18..3f722f8fd541 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -4603,6 +4603,8 @@ unsigned AtomicExpr::getNumSubExprs(AtomicOp Op) {
   case AO__c11_atomic_fetch_and:
   case AO__c11_atomic_fetch_or:
   case AO__c11_atomic_fetch_xor:
+  case AO__c11_atomic_fetch_max:
+  case AO__c11_atomic_fetch_min:
   case AO__atomic_fetch_add:
   case AO__atomic_fetch_sub:
   case AO__atomic_fetch_and:
@@ -4615,6 +4617,8 @@ unsigned AtomicExpr::getNumSubExprs(AtomicOp Op) {
   case AO__atomic_or_fetch:
   case AO__atomic_xor_fetch:
   case AO__atomic_nand_fetch:
+  case AO__atomic_min_fetch:
+  case AO__atomic_max_fetch:
   case AO__atomic_fetch_min:
   case AO__atomic_fetch_max:
 return 3;

diff  --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp
index 505916350750..039fe6da8420 100644

[clang] db73bcd - ARM-NEON: separate soon-to-be conflicting f16 patterns. NFC.

2019-11-20 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2019-11-20T13:20:02Z
New Revision: db73bcd98ef4ffbe91405a5adfcfdcd83bc007f4

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

LOG: ARM-NEON: separate soon-to-be conflicting f16 patterns. NFC.

This separates some intrinsic definitions into multiple instantiations because
they use a modifier that forces the float size to a given value. That modifier
won't work in the new NeonEmitter modifier scheme and committing this
separately allows the Python script to be run on the .td files to perform the
conversion automatically.

Added: 


Modified: 
clang/include/clang/Basic/arm_fp16.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_fp16.td 
b/clang/include/clang/Basic/arm_fp16.td
index ca33a8d2ec0b..bb9873efac85 100644
--- a/clang/include/clang/Basic/arm_fp16.td
+++ b/clang/include/clang/Basic/arm_fp16.td
@@ -43,7 +43,9 @@ let ArchGuard = 
"defined(__ARM_FEATURE_FP16_SCALAR_ARITHMETIC) && defined(__aarc
   def FRINTX_S64H : SInst<"vrndx", "ss", "Sh">;
 
   // Conversion
-  def SCALAR_SCVTFSH  : SInst<"vcvth_f16", "Ys", "silUsUiUl">;
+  def SCALAR_SCVTFSH  : SInst<"vcvth_f16", "Ys", "sUs">;
+  def SCALAR_SCVTFSH1 : SInst<"vcvth_f16", "Ys", "iUi">;
+  def SCALAR_SCVTFSH2 : SInst<"vcvth_f16", "Ys", "lUl">;
   def SCALAR_FCVTZSH  : SInst<"vcvt_s16", "$s", "Sh">;
   def SCALAR_FCVTZSH1 : SInst<"vcvt_s32", "Is", "Sh">;
   def SCALAR_FCVTZSH2 : SInst<"vcvt_s64", "Ls", "Sh">;
@@ -75,7 +77,9 @@ let ArchGuard = 
"defined(__ARM_FEATURE_FP16_SCALAR_ARITHMETIC) && defined(__aarc
   def SCALAR_FCVTPUH1 : SInst<"vcvtp_u32", "Us", "Sh">;
   def SCALAR_FCVTPUH2 : SInst<"vcvtp_u64", "Os", "Sh">;
   let isVCVT_N = 1 in {
-def SCALAR_SCVTFSHO : SInst<"vcvth_n_f16", "Ysi", "silUsUiUl">;
+def SCALAR_SCVTFSHO : SInst<"vcvth_n_f16", "Ysi", "sUs">;
+def SCALAR_SCVTFSH1O: SInst<"vcvth_n_f16", "Ysi", "iUi">;
+def SCALAR_SCVTFSH2O: SInst<"vcvth_n_f16", "Ysi", "lUl">;
 def SCALAR_FCVTZSHO : SInst<"vcvt_n_s16", "$si", "Sh">;
 def SCALAR_FCVTZSH1O: SInst<"vcvt_n_s32", "Isi", "Sh">;
 def SCALAR_FCVTZSH2O: SInst<"vcvt_n_s64", "Lsi", "Sh">;



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


[clang] e23d6f3 - NeonEmitter: remove special case on casting polymorphic builtins.

2019-11-20 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2019-11-20T13:20:02Z
New Revision: e23d6f3184d365a9e72a67870d98e80f998d

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

LOG: NeonEmitter: remove special case on casting polymorphic builtins.

For some reason we were not casting a fairly obscure class of builtin calls we
expected to be polymorphic to vectors of char. It worked because the only
affected intrinsics weren't actually polymorphic after all, but is
unnecessarily complicated.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/utils/TableGen/NeonEmitter.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index d9d0538b9138..ecac9aee5c7c 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -5456,6 +5456,11 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
 llvm::Type *Tys[2] = { Ty, GetFloatNeonType(this, Type) };
 return EmitNeonCall(CGM.getIntrinsic(LLVMIntrinsic, Tys), Ops, NameHint);
   }
+  case NEON::BI__builtin_neon_vcvtx_f32_v: {
+llvm::Type *Tys[2] = { VTy->getTruncatedElementVectorType(VTy), Ty};
+return EmitNeonCall(CGM.getIntrinsic(LLVMIntrinsic, Tys), Ops, NameHint);
+
+  }
   case NEON::BI__builtin_neon_vext_v:
   case NEON::BI__builtin_neon_vextq_v: {
 int CV = cast(Ops[2])->getSExtValue();

diff  --git a/clang/utils/TableGen/NeonEmitter.cpp 
b/clang/utils/TableGen/NeonEmitter.cpp
index bb893bc49f63..cdf761b00c61 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -1078,9 +1078,7 @@ std::string Intrinsic::getBuiltinTypeStr() {
 if (!RetT.isScalar() && RetT.isInteger() && !RetT.isSigned())
   RetT.makeSigned();
 
-bool ForcedVectorFloatingType = isFloatingPointProtoModifier(Proto[0]);
-if (LocalCK == ClassB && !RetT.isVoid() && !RetT.isScalar() &&
-!ForcedVectorFloatingType)
+if (LocalCK == ClassB && !RetT.isVoid() && !RetT.isScalar())
   // Cast to vector of 8-bit elements.
   RetT.makeInteger(8, true);
 
@@ -1092,8 +1090,7 @@ std::string Intrinsic::getBuiltinTypeStr() {
 if (T.isPoly())
   T.makeInteger(T.getElementSizeInBits(), false);
 
-bool ForcedFloatingType = isFloatingPointProtoModifier(Proto[I + 1]);
-if (LocalCK == ClassB && !T.isScalar() && !ForcedFloatingType)
+if (LocalCK == ClassB && !T.isScalar())
   T.makeInteger(8, true);
 // Halves always get converted to 8-bit elements.
 if (T.isHalf() && T.isVector() && !T.isScalarForMangling())



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


[clang] b80e483 - Update tests after change to llvm-cxxfilt's underscore stripping behaviour.

2019-11-20 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2019-11-20T13:10:55Z
New Revision: b80e483c4205d216f6648d7e217183694fe9a55e

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

LOG: Update tests after change to llvm-cxxfilt's underscore stripping behaviour.

Added: 


Modified: 
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-mmintrin.c
clang/test/CodeGen/ppc-pmmintrin.c
clang/test/CodeGen/ppc-smmintrin.c
clang/test/CodeGen/ppc-tmmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c

Removed: 




diff  --git a/clang/test/CodeGen/ppc-emmintrin.c 
b/clang/test/CodeGen/ppc-emmintrin.c
index 5e0ff67e4dd1..631b6c9d2614 100644
--- a/clang/test/CodeGen/ppc-emmintrin.c
+++ b/clang/test/CodeGen/ppc-emmintrin.c
@@ -2,9 +2,9 @@
 // REQUIRES: powerpc-registered-target
 
 // RUN: %clang -S -emit-llvm -target powerpc64-unknown-linux-gnu -mcpu=pwr8 
-ffreestanding -DNO_WARN_X86_INTRINSICS %s \
-// RUN:  -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN:  -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 // RUN: %clang -S -emit-llvm -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 
-ffreestanding -DNO_WARN_X86_INTRINSICS %s \
-// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-LE
 
 // CHECK-BE-DAG: @_mm_movemask_pd.perm_mask = internal constant <4 x i32> , align 16
 // CHECK-BE-DAG: @_mm_shuffle_epi32.permute_selectors = internal constant [4 x 
i32] [i32 66051, i32 67438087, i32 134810123, i32 202182159], align 4

diff  --git a/clang/test/CodeGen/ppc-mmintrin.c 
b/clang/test/CodeGen/ppc-mmintrin.c
index 019672863331..0a43f32fb0b0 100644
--- a/clang/test/CodeGen/ppc-mmintrin.c
+++ b/clang/test/CodeGen/ppc-mmintrin.c
@@ -2,13 +2,13 @@
 // REQUIRES: powerpc-registered-target
 
 // RUN: %clang -S -emit-llvm -target powerpc64-unknown-linux-gnu -mcpu=pwr8 
-DNO_WARN_X86_INTRINSICS %s \
-// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK-P8,CHECK,CHECK-BE
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK-P8,CHECK,CHECK-BE
 // RUN: %clang -S -emit-llvm -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 
-DNO_WARN_X86_INTRINSICS %s \
-// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK-P8,CHECK,CHECK-LE
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK-P8,CHECK,CHECK-LE
 // RUN: %clang -S -emit-llvm -target powerpc64-unknown-linux-gnu -mcpu=pwr9 
-DNO_WARN_X86_INTRINSICS %s \
-// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK-P9,CHECK,CHECK-BE
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK-P9,CHECK,CHECK-BE
 // RUN: %clang -S -emit-llvm -target powerpc64le-unknown-linux-gnu -mcpu=pwr9 
-DNO_WARN_X86_INTRINSICS %s \
-// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt | FileCheck %s --check-prefixes=CHECK-P9,CHECK,CHECK-LE
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n| FileCheck %s --check-prefixes=CHECK-P9,CHECK,CHECK-LE
 
 #include 
 

diff  --git a/clang/test/CodeGen/ppc-pmmintrin.c 
b/clang/test/CodeGen/ppc-pmmintrin.c
index ee4e89837444..f56a6a9993df 100644
--- a/clang/test/CodeGen/ppc-pmmintrin.c
+++ b/clang/test/CodeGen/ppc-pmmintrin.c
@@ -2,9 +2,9 @@
 // REQUIRES: powerpc-registered-target
 
 // RUN: %clang -S -emit-llvm -target powerpc64-gnu-linux -mcpu=pwr8 
-DNO_MM_MALLOC -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
-// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt | FileCheck %s
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s
 // RUN: %clang -S -emit-llvm -target powerpc64le-gnu-linux -mcpu=pwr8 
-DNO_MM_MALLOC -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
-// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt | FileCheck %s
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s
 
 #include 
 

diff  --git a/clang/test/CodeGen/ppc-smmintrin.c 
b/clang/test/CodeGen/ppc-smmintrin.c
index 666bc0fc440c..c3245ab19d1f 100644
--- a/clang/test/CodeGen/ppc-smmintrin.c

[clang] 44e5879 - AArch64: add arm64_32 support to Clang.

2019-11-12 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2019-11-12T12:45:18Z
New Revision: 44e5879f0fb7c28b90e8042fde81bba30b4090a3

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

LOG: AArch64: add arm64_32 support to Clang.

Added: 
clang/test/CodeGen/arm64_32-vaarg.c
clang/test/CodeGen/arm64_32.c
clang/test/Driver/arm64_32-link.c
clang/test/Preprocessor/arm64_32.c

Modified: 
clang/lib/Basic/Targets.cpp
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AArch64.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaType.cpp
clang/test/CodeGen/builtins-arm64.c
clang/test/CodeGen/target-data.c
clang/test/CodeGenCXX/armv7k.cpp
clang/test/Driver/aarch64-cpus.c
clang/test/Preprocessor/aarch64-target-features.c
clang/test/Preprocessor/init-v7k-compat.c
clang/test/Preprocessor/stdint.c
clang/test/Sema/aarch64-neon-vector-types.c
clang/test/Sema/types.c

Removed: 




diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 63a64ed2931a..664260d184fc 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -122,6 +122,11 @@ TargetInfo *AllocateTarget(const llvm::Triple ,
   case llvm::Triple::lanai:
 return new LanaiTargetInfo(Triple, Opts);
 
+  case llvm::Triple::aarch64_32:
+if (Triple.isOSDarwin())
+  return new DarwinAArch64TargetInfo(Triple, Opts);
+
+return nullptr;
   case llvm::Triple::aarch64:
 if (Triple.isOSDarwin())
   return new DarwinAArch64TargetInfo(Triple, Opts);

diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index c86cc63e3d84..bdfb5700b46a 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -51,7 +51,11 @@ AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple 
,
   HasLegalHalfType = true;
   HasFloat16 = true;
 
-  LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
+  if (Triple.isArch64Bit())
+LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
+  else
+LongWidth = LongAlign = PointerWidth = PointerAlign = 32;
+
   MaxVectorAlign = 128;
   MaxAtomicInlineWidth = 128;
   MaxAtomicPromoteWidth = 128;
@@ -160,7 +164,7 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
,
 Builder.defineMacro("__ELF__");
 
   // Target properties.
-  if (!getTriple().isOSWindows()) {
+  if (!getTriple().isOSWindows() && getTriple().isArch64Bit()) {
 Builder.defineMacro("_LP64");
 Builder.defineMacro("__LP64__");
   }
@@ -506,14 +510,19 @@ int AArch64TargetInfo::getEHDataRegisterNumber(unsigned 
RegNo) const {
   return -1;
 }
 
+bool AArch64TargetInfo::hasInt128Type() const { return true; }
+
 AArch64leTargetInfo::AArch64leTargetInfo(const llvm::Triple ,
  const TargetOptions )
 : AArch64TargetInfo(Triple, Opts) {}
 
 void AArch64leTargetInfo::setDataLayout() {
-  if (getTriple().isOSBinFormatMachO())
-resetDataLayout("e-m:o-i64:64-i128:128-n32:64-S128");
-  else
+  if (getTriple().isOSBinFormatMachO()) {
+if(getTriple().isArch32Bit())
+  resetDataLayout("e-m:o-p:32:32-i64:64-i128:128-n32:64-S128");
+else
+  resetDataLayout("e-m:o-i64:64-i128:128-n32:64-S128");
+  } else
 resetDataLayout("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128");
 }
 
@@ -631,19 +640,34 @@ DarwinAArch64TargetInfo::DarwinAArch64TargetInfo(const 
llvm::Triple ,
  const TargetOptions )
 : DarwinTargetInfo(Triple, Opts) {
   Int64Type = SignedLongLong;
+  if (getTriple().isArch32Bit())
+IntMaxType = SignedLongLong;
+
+  WCharType = SignedInt;
   UseSignedCharForObjCBool = false;
 
   LongDoubleWidth = LongDoubleAlign = SuitableAlign = 64;
   LongDoubleFormat = ::APFloat::IEEEdouble();
 
-  TheCXXABI.set(TargetCXXABI::iOS64);
+  UseZeroLengthBitfieldAlignment = false;
+
+  if (getTriple().isArch32Bit()) {
+UseBitFieldTypeAlignment = false;
+ZeroLengthBitfieldBoundary = 32;
+UseZeroLengthBitfieldAlignment = true;
+TheCXXABI.set(TargetCXXABI::WatchOS);
+  } else
+TheCXXABI.set(TargetCXXABI::iOS64);
 }
 
 void DarwinAArch64TargetInfo::getOSDefines(const LangOptions ,
const llvm::Triple ,
MacroBuilder ) const {
   Builder.defineMacro("__AARCH64_SIMD__");
-  Builder.defineMacro("__ARM64_ARCH_8__");
+  if (Triple.isArch32Bit())
+Builder.defineMacro("__ARM64_ARCH_8_32__");
+  else
+

[clang] 10e0d64 - CodeGen: set correct result for atomic compound expressions

2019-11-07 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2019-11-07T13:36:44Z
New Revision: 10e0d64337d64ebdb658bf9108bd9bb48fb5390c

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

LOG: CodeGen: set correct result for atomic compound expressions

Atomic compound expressions try to use atomicrmw if possible, but this
path doesn't set the Result variable, leaving it to crash in later code
if anything ever tries to use the result of the expression. This fixes
that issue by recalculating the new value based on the old one
atomically loaded.

Added: 


Modified: 
clang/lib/CodeGen/CGExprScalar.cpp
clang/test/CodeGen/atomic_ops.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index c1391d46f60c..822976640643 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2849,7 +2849,8 @@ LValue ScalarExprEmitter::EmitCompoundAssignLValue(
   CGF.SanOpts.has(SanitizerKind::UnsignedIntegerOverflow)) &&
 CGF.getLangOpts().getSignedOverflowBehavior() !=
 LangOptions::SOB_Trapping) {
-  llvm::AtomicRMWInst::BinOp aop = llvm::AtomicRMWInst::BAD_BINOP;
+  llvm::AtomicRMWInst::BinOp AtomicOp = llvm::AtomicRMWInst::BAD_BINOP;
+  llvm::Instruction::BinaryOps Op;
   switch (OpInfo.Opcode) {
 // We don't have atomicrmw operands for *, %, /, <<, >>
 case BO_MulAssign: case BO_DivAssign:
@@ -2858,30 +2859,40 @@ LValue ScalarExprEmitter::EmitCompoundAssignLValue(
 case BO_ShrAssign:
   break;
 case BO_AddAssign:
-  aop = llvm::AtomicRMWInst::Add;
+  AtomicOp = llvm::AtomicRMWInst::Add;
+  Op = llvm::Instruction::Add;
   break;
 case BO_SubAssign:
-  aop = llvm::AtomicRMWInst::Sub;
+  AtomicOp = llvm::AtomicRMWInst::Sub;
+  Op = llvm::Instruction::Sub;
   break;
 case BO_AndAssign:
-  aop = llvm::AtomicRMWInst::And;
+  AtomicOp = llvm::AtomicRMWInst::And;
+  Op = llvm::Instruction::And;
   break;
 case BO_XorAssign:
-  aop = llvm::AtomicRMWInst::Xor;
+  AtomicOp = llvm::AtomicRMWInst::Xor;
+  Op = llvm::Instruction::Xor;
   break;
 case BO_OrAssign:
-  aop = llvm::AtomicRMWInst::Or;
+  AtomicOp = llvm::AtomicRMWInst::Or;
+  Op = llvm::Instruction::Or;
   break;
 default:
   llvm_unreachable("Invalid compound assignment type");
   }
-  if (aop != llvm::AtomicRMWInst::BAD_BINOP) {
-llvm::Value *amt = CGF.EmitToMemory(
+  if (AtomicOp != llvm::AtomicRMWInst::BAD_BINOP) {
+llvm::Value *Amt = CGF.EmitToMemory(
 EmitScalarConversion(OpInfo.RHS, E->getRHS()->getType(), LHSTy,
  E->getExprLoc()),
 LHSTy);
-Builder.CreateAtomicRMW(aop, LHSLV.getPointer(), amt,
+Value *OldVal = Builder.CreateAtomicRMW(
+AtomicOp, LHSLV.getPointer(), Amt,
 llvm::AtomicOrdering::SequentiallyConsistent);
+
+// Since operation is atomic, the result type is guaranteed to be the
+// same as the input in LLVM terms.
+Result = Builder.CreateBinOp(Op, OldVal, Amt);
 return LHSLV;
   }
 }

diff  --git a/clang/test/CodeGen/atomic_ops.c b/clang/test/CodeGen/atomic_ops.c
index 0af1d387192d..a853ba9f739c 100644
--- a/clang/test/CodeGen/atomic_ops.c
+++ b/clang/test/CodeGen/atomic_ops.c
@@ -37,3 +37,56 @@ void baz(int y) {
 // CHECK: {{store atomic|call void @__atomic_store}}
   x += y;
 }
+
+_Atomic(int) compound_add(_Atomic(int) in) {
+// CHECK-LABEL: @compound_add
+// CHECK: [[OLD:%.*]] = atomicrmw add i32* {{.*}}, i32 5 seq_cst
+// CHECK: [[NEW:%.*]] = add i32 [[OLD]], 5
+// CHECK: ret i32 [[NEW]]
+
+  return (in += 5);
+}
+
+_Atomic(int) compound_sub(_Atomic(int) in) {
+// CHECK-LABEL: @compound_sub
+// CHECK: [[OLD:%.*]] = atomicrmw sub i32* {{.*}}, i32 5 seq_cst
+// CHECK: [[NEW:%.*]] = sub i32 [[OLD]], 5
+// CHECK: ret i32 [[NEW]]
+
+  return (in -= 5);
+}
+
+_Atomic(int) compound_xor(_Atomic(int) in) {
+// CHECK-LABEL: @compound_xor
+// CHECK: [[OLD:%.*]] = atomicrmw xor i32* {{.*}}, i32 5 seq_cst
+// CHECK: [[NEW:%.*]] = xor i32 [[OLD]], 5
+// CHECK: ret i32 [[NEW]]
+
+  return (in ^= 5);
+}
+
+_Atomic(int) compound_or(_Atomic(int) in) {
+// CHECK-LABEL: @compound_or
+// CHECK: [[OLD:%.*]] = atomicrmw or i32* {{.*}}, i32 5 seq_cst
+// CHECK: [[NEW:%.*]] = or i32 [[OLD]], 5
+// CHECK: ret i32 [[NEW]]
+
+  return (in |= 5);
+}
+
+_Atomic(int) compound_and(_Atomic(int) in) {
+// CHECK-LABEL: @compound_and
+// CHECK: [[OLD:%.*]] = atomicrmw and i32* {{.*}}, i32 5 seq_cst
+// CHECK: [[NEW:%.*]] = and i32 [[OLD]], 5
+// CHECK: 

[clang] 59f063b - NeonEmitter: remove special 'a' type modifier.

2019-11-06 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2019-11-06T10:23:36Z
New Revision: 59f063b89c518ae81467f6015d1c428c61583f71

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

LOG: NeonEmitter: remove special 'a' type modifier.

'a' used to implement a splat in C++ code in NeonEmitter.cpp, but this
can be done directly from .td expansions now (and most ops already did).
So removing it simplifies the overall code.

https://reviews.llvm.org/D69716

Added: 


Modified: 
clang/include/clang/Basic/arm_neon.td
clang/include/clang/Basic/arm_neon_incl.td
clang/test/CodeGen/aarch64-neon-2velem.c
clang/test/CodeGen/arm_neon_intrinsics.c
clang/utils/TableGen/NeonEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index a52ed496580d..127c5af97ce6 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -53,6 +53,7 @@ def OP_MLAL_N   : Op<(op "+", $p0, (call "vmull", $p1, (dup 
$p2)))>;
 def OP_MLSL_N   : Op<(op "-", $p0, (call "vmull", $p1, (dup $p2)))>;
 def OP_MUL_LN   : Op<(op "*", $p0, (splat $p1, $p2))>;
 def OP_MULX_LN  : Op<(call "vmulx", $p0, (splat $p1, $p2))>;
+def OP_MULL_N  : Op<(call "vmull", $p0, (dup $p1))>;
 def OP_MULL_LN  : Op<(call "vmull", $p0, (splat $p1, $p2))>;
 def OP_MULLHi_LN: Op<(call "vmull", (call "vget_high", $p0), (splat $p1, 
$p2))>;
 def OP_MLA_LN   : Op<(op "+", $p0, (op "*", $p1, (splat $p2, $p3)))>;
@@ -63,17 +64,22 @@ def OP_MLALHi_LN: Op<(op "+", $p0, (call "vmull", (call 
"vget_high", $p1),
 def OP_MLSL_LN  : Op<(op "-", $p0, (call "vmull", $p1, (splat $p2, $p3)))>;
 def OP_MLSLHi_LN : Op<(op "-", $p0, (call "vmull", (call "vget_high", $p1),
(splat $p2, $p3)))>;
+def OP_QDMULL_N : Op<(call "vqdmull", $p0, (dup $p1))>;
 def OP_QDMULL_LN : Op<(call "vqdmull", $p0, (splat $p1, $p2))>;
 def OP_QDMULLHi_LN : Op<(call "vqdmull", (call "vget_high", $p0),
  (splat $p1, $p2))>;
+def OP_QDMLAL_N : Op<(call "vqdmlal", $p0, $p1, (dup $p2))>;
 def OP_QDMLAL_LN : Op<(call "vqdmlal", $p0, $p1, (splat $p2, $p3))>;
 def OP_QDMLALHi_LN : Op<(call "vqdmlal", $p0, (call "vget_high", $p1),
   (splat $p2, $p3))>;
+def OP_QDMLSL_N : Op<(call "vqdmlsl", $p0, $p1, (dup $p2))>;
 def OP_QDMLSL_LN : Op<(call "vqdmlsl", $p0, $p1, (splat $p2, $p3))>;
 def OP_QDMLSLHi_LN : Op<(call "vqdmlsl", $p0, (call "vget_high", $p1),
   (splat $p2, $p3))>;
+def OP_QDMULH_N : Op<(call "vqdmulh", $p0, (dup $p1))>;
 def OP_QDMULH_LN : Op<(call "vqdmulh", $p0, (splat $p1, $p2))>;
 def OP_QRDMULH_LN : Op<(call "vqrdmulh", $p0, (splat $p1, $p2))>;
+def OP_QRDMULH_N : Op<(call "vqrdmulh", $p0, (dup $p1))>;
 def OP_QRDMLAH : Op<(call "vqadd", $p0, (call "vqrdmulh", $p1, $p2))>;
 def OP_QRDMLSH : Op<(call "vqsub", $p0, (call "vqrdmulh", $p1, $p2))>;
 def OP_QRDMLAH_LN : Op<(call "vqadd", $p0, (call "vqrdmulh", $p1, (splat $p2, 
$p3)))>;
@@ -516,13 +522,13 @@ def VQDMLSL_LANE  : SOpInst<"vqdmlsl_lane", "wwddi", 
"si", OP_QDMLSL_LN>;
 def VMUL_N: IOpInst<"vmul_n", "dds", "sifUsUiQsQiQfQUsQUi", OP_MUL_N>;
 def VMUL_LANE : IOpInst<"vmul_lane", "ddgi",
 "sifUsUiQsQiQfQUsQUi", OP_MUL_LN>;
-def VMULL_N   : SInst<"vmull_n", "wda", "siUsUi">;
+def VMULL_N   : SOpInst<"vmull_n", "wds", "siUsUi", OP_MULL_N>;
 def VMULL_LANE: SOpInst<"vmull_lane", "wddi", "siUsUi", OP_MULL_LN>;
-def VQDMULL_N : SInst<"vqdmull_n", "wda", "si">;
+def VQDMULL_N : SOpInst<"vqdmull_n", "wds", "si", OP_QDMULL_N>;
 def VQDMULL_LANE  : SOpInst<"vqdmull_lane", "wddi", "si", OP_QDMULL_LN>;
-def VQDMULH_N : SInst<"vqdmulh_n", "dda", "siQsQi">;
+def VQDMULH_N : SOpInst<"vqdmulh_n", "dds", "siQsQi", OP_QDMULH_N>;
 def VQDMULH_LANE  : SOpInst<"vqdmulh_lane", "ddgi", "siQsQi", OP_QDMULH_LN>;
-def VQRDMULH_N: SInst<"vqrdmulh_n", "dda", "siQsQi">;
+def VQRDMULH_N: SOpInst<"vqrdmulh_n", "dds", "siQsQi", OP_QRDMULH_N>;
 def VQRDMULH_LANE : SOpInst<"vqrdmulh_lane", "ddgi", "siQsQi", OP_QRDMULH_LN>;
 
 let ArchGuard = "defined(__ARM_FEATURE_QRDMX)" in {
@@ -530,12 +536,12 @@ def VQRDMLAH_LANE : SOpInst<"vqrdmlah_lane", "dddgi", 
"siQsQi", OP_QRDMLAH_LN>;
 def VQRDMLSH_LANE : SOpInst<"vqrdmlsh_lane", "dddgi", "siQsQi", OP_QRDMLSH_LN>;
 }
 
-def VMLA_N: IOpInst<"vmla_n", "ddda", "siUsUifQsQiQUsQUiQf", OP_MLA_N>;
-def VMLAL_N   : SOpInst<"vmlal_n", "wwda", "siUsUi", OP_MLAL_N>;
-def VQDMLAL_N : SInst<"vqdmlal_n", "wwda", "si">;
+def VMLA_N: IOpInst<"vmla_n", "ddds", "siUsUifQsQiQUsQUiQf", OP_MLA_N>;
+def VMLAL_N   : SOpInst<"vmlal_n", "wwds", "siUsUi", OP_MLAL_N>;
+def 

[clang] 9577ee8 - NeonEmitter: switch to enum for internal Type representation.

2019-11-06 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2019-11-06T10:02:15Z
New Revision: 9577ee84e638530be7a310c9d50526a36e3c212e

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

LOG: NeonEmitter: switch to enum for internal Type representation.

Previously we had a handful of bools (Signed, Floating, ...) that could
easily end up in an inconsistent state. This adds an enum Kind which
holds the mutually exclusive states a type might be in, retaining some
of the bools that modified an underlying type.

https://reviews.llvm.org/D69715

Added: 


Modified: 
clang/utils/TableGen/NeonEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/NeonEmitter.cpp 
b/clang/utils/TableGen/NeonEmitter.cpp
index 9d668a281534..ecd932475cb1 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -140,7 +140,15 @@ class Type {
 private:
   TypeSpec TS;
 
-  bool Float, Signed, Immediate, Void, Poly, Constant, Pointer;
+  enum TypeKind {
+Void,
+Float,
+SInt,
+UInt,
+Poly,
+  };
+  TypeKind Kind;
+  bool Immediate, Constant, Pointer;
   // ScalarForMangling and NoManglingQ are really not suited to live here as
   // they are not related to the type. But they live in the TypeSpec (not the
   // prototype), so this is really the only place to store them.
@@ -149,15 +157,14 @@ class Type {
 
 public:
   Type()
-  : Float(false), Signed(false), Immediate(false), Void(true), Poly(false),
-Constant(false), Pointer(false), ScalarForMangling(false),
-NoManglingQ(false), Bitwidth(0), ElementBitwidth(0), NumVectors(0) {}
+  : Kind(Void), Immediate(false), Constant(false),
+Pointer(false), ScalarForMangling(false), NoManglingQ(false),
+Bitwidth(0), ElementBitwidth(0), NumVectors(0) {}
 
   Type(TypeSpec TS, char CharMod)
-  : TS(std::move(TS)), Float(false), Signed(false), Immediate(false),
-Void(false), Poly(false), Constant(false), Pointer(false),
-ScalarForMangling(false), NoManglingQ(false), Bitwidth(0),
-ElementBitwidth(0), NumVectors(0) {
+  : TS(std::move(TS)), Kind(Void), Immediate(false),
+Constant(false), Pointer(false), ScalarForMangling(false),
+NoManglingQ(false), Bitwidth(0), ElementBitwidth(0), NumVectors(0) {
 applyModifier(CharMod);
   }
 
@@ -174,21 +181,21 @@ class Type {
   bool noManglingQ() const { return NoManglingQ; }
 
   bool isPointer() const { return Pointer; }
-  bool isFloating() const { return Float; }
-  bool isInteger() const { return !Float && !Poly; }
-  bool isSigned() const { return Signed; }
+  bool isFloating() const { return Kind == Float; }
+  bool isInteger() const { return Kind == SInt || Kind == UInt; }
+  bool isPoly() const { return Kind == Poly; }
+  bool isSigned() const { return Kind == SInt; }
   bool isImmediate() const { return Immediate; }
   bool isScalar() const { return NumVectors == 0; }
   bool isVector() const { return NumVectors > 0; }
-  bool isFloat() const { return Float && ElementBitwidth == 32; }
-  bool isDouble() const { return Float && ElementBitwidth == 64; }
-  bool isHalf() const { return Float && ElementBitwidth == 16; }
-  bool isPoly() const { return Poly; }
+  bool isFloat() const { return isFloating() && ElementBitwidth == 32; }
+  bool isDouble() const { return isFloating() && ElementBitwidth == 64; }
+  bool isHalf() const { return isFloating() && ElementBitwidth == 16; }
   bool isChar() const { return ElementBitwidth == 8; }
-  bool isShort() const { return !Float && ElementBitwidth == 16; }
-  bool isInt() const { return !Float && ElementBitwidth == 32; }
-  bool isLong() const { return !Float && ElementBitwidth == 64; }
-  bool isVoid() const { return Void; }
+  bool isShort() const { return isInteger() && ElementBitwidth == 16; }
+  bool isInt() const { return isInteger() && ElementBitwidth == 32; }
+  bool isLong() const { return isInteger() && ElementBitwidth == 64; }
+  bool isVoid() const { return Kind == Void; }
   unsigned getNumElements() const { return Bitwidth / ElementBitwidth; }
   unsigned getSizeInBits() const { return Bitwidth; }
   unsigned getElementSizeInBits() const { return ElementBitwidth; }
@@ -197,21 +204,24 @@ class Type {
   //
   // Mutator functions
   //
-  void makeUnsigned() { Signed = false; }
-  void makeSigned() { Signed = true; }
+  void makeUnsigned() {
+assert(isInteger() && "not a potentially signed type");
+Kind = UInt;
+  }
+  void makeSigned() {
+assert(isInteger() && "not a potentially signed type");
+Kind = SInt;
+  }
 
   void makeInteger(unsigned ElemWidth, bool Sign) {
-Float = false;
-Poly = false;
-Signed = Sign;
+assert(!isVoid() && "converting void to int probably not useful");
+Kind = Sign ? SInt : UInt;
 

r362129 - Reapply: LLVM IR: update Clang tests for byval being a typed attribute.

2019-05-30 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Thu May 30 11:49:19 2019
New Revision: 362129

URL: http://llvm.org/viewvc/llvm-project?rev=362129=rev
Log:
Reapply: LLVM IR: update Clang tests for byval being a typed attribute.

Since byval is now a typed attribute it gets sorted slightly differently by
LLVM when the order of attributes is being canonicalized. This updates the few
Clang tests that depend on the old order.

Clang patch is unchanged.

Modified:
cfe/trunk/test/CodeGen/aapcs-align.cpp
cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp
cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp
cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp
cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
cfe/trunk/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl

Modified: cfe/trunk/test/CodeGen/aapcs-align.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aapcs-align.cpp?rev=362129=362128=362129=diff
==
--- cfe/trunk/test/CodeGen/aapcs-align.cpp (original)
+++ cfe/trunk/test/CodeGen/aapcs-align.cpp Thu May 30 11:49:19 2019
@@ -95,8 +95,8 @@ void g4() {
   f4m(1, 2, 3, 4, 5, s);
 }
 // CHECK: define void @g4
-// CHECK: call void @f4(i32 1, %struct.SF16* byval nonnull align 8
-// CHECK: call void @f4m(i32 1, i32 2, i32 3, i32 4, i32 5, %struct.SF16* 
byval nonnull align 8
+// CHECK: call void @f4(i32 1, %struct.SF16* nonnull byval align 8
+// CHECK: call void @f4m(i32 1, i32 2, i32 3, i32 4, i32 5, %struct.SF16* 
nonnull byval align 8
 // CHECK: declare void @f4(i32, %struct.SF16* byval align 8)
 // CHECK: declare void @f4m(i32, i32, i32, i32, i32, %struct.SF16* byval align 
8)
 

Modified: cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp?rev=362129=362128=362129=diff
==
--- cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp Thu May 30 11:49:19 
2019
@@ -104,7 +104,7 @@ struct TestInit {
 //
 // CHECK-CTOR-GLOBAL: call void 
@_ZN15source_location7currentEjjPKcS1_(%struct.source_location* sret 
%[[TMP_ONE:[^,]*]],
 // CHECK-CTOR-GLOBAL-SAME: i32 3400, i32 {{[0-9]+}}, {{[^@]*}}@[[FILE]], 
{{[^@]*}}@[[FUNC]],
-// CHECK-CTOR-GLOBAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* @GlobalInitVal, 
%struct.source_location* {{[^%]*}}%[[TMP_ONE]])
+// CHECK-CTOR-GLOBAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* @GlobalInitVal, 
%struct.source_location* {{.*}}%[[TMP_ONE]])
 #line 3400 "GlobalInitVal.cpp"
 TestInit GlobalInitVal;
 
@@ -119,7 +119,7 @@ extern "C" void test_init_function() {
 //
 // CHECK-CTOR-LOCAL: call void 
@_ZN15source_location7currentEjjPKcS1_(%struct.source_location* sret 
%[[TMP:[^,]*]],
 // CHECK-CTOR-LOCAL-SAME: i32 3500, i32 {{[0-9]+}}, {{[^@]*}}@[[FILE]], 
{{[^@]*}}@[[FUNC]],
-// CHECK-CTOR-LOCAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* %init_local, 
%struct.source_location* {{[^%]*}}%[[TMP]])
+// CHECK-CTOR-LOCAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* %init_local, 
%struct.source_location* {{.*}}%[[TMP]])
 #line 3500 "LocalInitVal.cpp"
   TestInit init_local;
   sink(init_local);

Modified: cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp?rev=362129=362128=362129=diff
==
--- cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp Thu May 30 11:49:19 2019
@@ -30,12 +30,12 @@ struct two_fields {
   double d, e;
 };
 test(two_fields);
-// CHECK: define void @_Z7forward10two_fields(%struct.two_fields* noalias 
nocapture sret %{{.*}}, %struct.two_fields* byval nocapture readonly align 8 
%{{.*}})
+// CHECK: define void @_Z7forward10two_fields(%struct.two_fields* noalias 
nocapture sret %{{.*}}, %struct.two_fields* nocapture readonly byval align 8 
%{{.*}})
 //
 // CHECK: define void @_Z15test_two_fieldsv()
 // CHECK: %[[tmp:.*]] = alloca %struct.two_fields, align 8
 // CHECK: call void @_Z14def_two_fieldsv(%struct.two_fields* nonnull sret 
%[[tmp]])
-// CHECK: call void @_Z3use10two_fields(%struct.two_fields* byval nonnull 
align 8 %[[tmp]])
+// CHECK: call void @_Z3use10two_fields(%struct.two_fields* nonnull byval 
align 8 %[[tmp]])
 // CHECK: ret void
 //
 // CHECK: declare void @_Z3use10two_fields(%struct.two_fields* byval align 8)

Modified: cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp?rev=362129=362128=362129=diff
==
--- 

r362028 - Revert "LLVM IR: update Clang tests for byval being a typed attribute."

2019-05-29 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed May 29 13:45:32 2019
New Revision: 362028

URL: http://llvm.org/viewvc/llvm-project?rev=362028=rev
Log:
Revert "LLVM IR: update Clang tests for byval being a typed attribute."

The underlying LLVM change couldn't cope with llvm-link and broke LTO builds.

Modified:
cfe/trunk/test/CodeGen/aapcs-align.cpp
cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp
cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp
cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp
cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
cfe/trunk/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl

Modified: cfe/trunk/test/CodeGen/aapcs-align.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aapcs-align.cpp?rev=362028=362027=362028=diff
==
--- cfe/trunk/test/CodeGen/aapcs-align.cpp (original)
+++ cfe/trunk/test/CodeGen/aapcs-align.cpp Wed May 29 13:45:32 2019
@@ -95,8 +95,8 @@ void g4() {
   f4m(1, 2, 3, 4, 5, s);
 }
 // CHECK: define void @g4
-// CHECK: call void @f4(i32 1, %struct.SF16* nonnull byval align 8
-// CHECK: call void @f4m(i32 1, i32 2, i32 3, i32 4, i32 5, %struct.SF16* 
nonnull byval align 8
+// CHECK: call void @f4(i32 1, %struct.SF16* byval nonnull align 8
+// CHECK: call void @f4m(i32 1, i32 2, i32 3, i32 4, i32 5, %struct.SF16* 
byval nonnull align 8
 // CHECK: declare void @f4(i32, %struct.SF16* byval align 8)
 // CHECK: declare void @f4m(i32, i32, i32, i32, i32, %struct.SF16* byval align 
8)
 

Modified: cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp?rev=362028=362027=362028=diff
==
--- cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp Wed May 29 13:45:32 
2019
@@ -104,7 +104,7 @@ struct TestInit {
 //
 // CHECK-CTOR-GLOBAL: call void 
@_ZN15source_location7currentEjjPKcS1_(%struct.source_location* sret 
%[[TMP_ONE:[^,]*]],
 // CHECK-CTOR-GLOBAL-SAME: i32 3400, i32 {{[0-9]+}}, {{[^@]*}}@[[FILE]], 
{{[^@]*}}@[[FUNC]],
-// CHECK-CTOR-GLOBAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* @GlobalInitVal, 
%struct.source_location* {{.*}}%[[TMP_ONE]])
+// CHECK-CTOR-GLOBAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* @GlobalInitVal, 
%struct.source_location* {{[^%]*}}%[[TMP_ONE]])
 #line 3400 "GlobalInitVal.cpp"
 TestInit GlobalInitVal;
 
@@ -119,7 +119,7 @@ extern "C" void test_init_function() {
 //
 // CHECK-CTOR-LOCAL: call void 
@_ZN15source_location7currentEjjPKcS1_(%struct.source_location* sret 
%[[TMP:[^,]*]],
 // CHECK-CTOR-LOCAL-SAME: i32 3500, i32 {{[0-9]+}}, {{[^@]*}}@[[FILE]], 
{{[^@]*}}@[[FUNC]],
-// CHECK-CTOR-LOCAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* %init_local, 
%struct.source_location* {{.*}}%[[TMP]])
+// CHECK-CTOR-LOCAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* %init_local, 
%struct.source_location* {{[^%]*}}%[[TMP]])
 #line 3500 "LocalInitVal.cpp"
   TestInit init_local;
   sink(init_local);

Modified: cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp?rev=362028=362027=362028=diff
==
--- cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp Wed May 29 13:45:32 2019
@@ -30,12 +30,12 @@ struct two_fields {
   double d, e;
 };
 test(two_fields);
-// CHECK: define void @_Z7forward10two_fields(%struct.two_fields* noalias 
nocapture sret %{{.*}}, %struct.two_fields* nocapture readonly byval align 8 
%{{.*}})
+// CHECK: define void @_Z7forward10two_fields(%struct.two_fields* noalias 
nocapture sret %{{.*}}, %struct.two_fields* byval nocapture readonly align 8 
%{{.*}})
 //
 // CHECK: define void @_Z15test_two_fieldsv()
 // CHECK: %[[tmp:.*]] = alloca %struct.two_fields, align 8
 // CHECK: call void @_Z14def_two_fieldsv(%struct.two_fields* nonnull sret 
%[[tmp]])
-// CHECK: call void @_Z3use10two_fields(%struct.two_fields* nonnull byval 
align 8 %[[tmp]])
+// CHECK: call void @_Z3use10two_fields(%struct.two_fields* byval nonnull 
align 8 %[[tmp]])
 // CHECK: ret void
 //
 // CHECK: declare void @_Z3use10two_fields(%struct.two_fields* byval align 8)

Modified: cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp?rev=362028=362027=362028=diff
==
--- cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp Wed May 29 13:45:32 
2019
@@ -20,7 +20,7 

r362013 - LLVM IR: update Clang tests for byval being a typed attribute.

2019-05-29 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed May 29 12:13:29 2019
New Revision: 362013

URL: http://llvm.org/viewvc/llvm-project?rev=362013=rev
Log:
LLVM IR: update Clang tests for byval being a typed attribute.

Since byval is now a typed attribute it gets sorted slightly differently by
LLVM when the order of attributes is being canonicalized. This updates the few
Clang tests that depend on the old order.

Modified:
cfe/trunk/test/CodeGen/aapcs-align.cpp
cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp
cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp
cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp
cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
cfe/trunk/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl

Modified: cfe/trunk/test/CodeGen/aapcs-align.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aapcs-align.cpp?rev=362013=362012=362013=diff
==
--- cfe/trunk/test/CodeGen/aapcs-align.cpp (original)
+++ cfe/trunk/test/CodeGen/aapcs-align.cpp Wed May 29 12:13:29 2019
@@ -95,8 +95,8 @@ void g4() {
   f4m(1, 2, 3, 4, 5, s);
 }
 // CHECK: define void @g4
-// CHECK: call void @f4(i32 1, %struct.SF16* byval nonnull align 8
-// CHECK: call void @f4m(i32 1, i32 2, i32 3, i32 4, i32 5, %struct.SF16* 
byval nonnull align 8
+// CHECK: call void @f4(i32 1, %struct.SF16* nonnull byval align 8
+// CHECK: call void @f4m(i32 1, i32 2, i32 3, i32 4, i32 5, %struct.SF16* 
nonnull byval align 8
 // CHECK: declare void @f4(i32, %struct.SF16* byval align 8)
 // CHECK: declare void @f4m(i32, i32, i32, i32, i32, %struct.SF16* byval align 
8)
 

Modified: cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp?rev=362013=362012=362013=diff
==
--- cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/builtin-source-location.cpp Wed May 29 12:13:29 
2019
@@ -104,7 +104,7 @@ struct TestInit {
 //
 // CHECK-CTOR-GLOBAL: call void 
@_ZN15source_location7currentEjjPKcS1_(%struct.source_location* sret 
%[[TMP_ONE:[^,]*]],
 // CHECK-CTOR-GLOBAL-SAME: i32 3400, i32 {{[0-9]+}}, {{[^@]*}}@[[FILE]], 
{{[^@]*}}@[[FUNC]],
-// CHECK-CTOR-GLOBAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* @GlobalInitVal, 
%struct.source_location* {{[^%]*}}%[[TMP_ONE]])
+// CHECK-CTOR-GLOBAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* @GlobalInitVal, 
%struct.source_location* {{.*}}%[[TMP_ONE]])
 #line 3400 "GlobalInitVal.cpp"
 TestInit GlobalInitVal;
 
@@ -119,7 +119,7 @@ extern "C" void test_init_function() {
 //
 // CHECK-CTOR-LOCAL: call void 
@_ZN15source_location7currentEjjPKcS1_(%struct.source_location* sret 
%[[TMP:[^,]*]],
 // CHECK-CTOR-LOCAL-SAME: i32 3500, i32 {{[0-9]+}}, {{[^@]*}}@[[FILE]], 
{{[^@]*}}@[[FUNC]],
-// CHECK-CTOR-LOCAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* %init_local, 
%struct.source_location* {{[^%]*}}%[[TMP]])
+// CHECK-CTOR-LOCAL-NEXT: call void 
@_ZN8TestInitC1E15source_location(%struct.TestInit* %init_local, 
%struct.source_location* {{.*}}%[[TMP]])
 #line 3500 "LocalInitVal.cpp"
   TestInit init_local;
   sink(init_local);

Modified: cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp?rev=362013=362012=362013=diff
==
--- cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp Wed May 29 12:13:29 2019
@@ -30,12 +30,12 @@ struct two_fields {
   double d, e;
 };
 test(two_fields);
-// CHECK: define void @_Z7forward10two_fields(%struct.two_fields* noalias 
nocapture sret %{{.*}}, %struct.two_fields* byval nocapture readonly align 8 
%{{.*}})
+// CHECK: define void @_Z7forward10two_fields(%struct.two_fields* noalias 
nocapture sret %{{.*}}, %struct.two_fields* nocapture readonly byval align 8 
%{{.*}})
 //
 // CHECK: define void @_Z15test_two_fieldsv()
 // CHECK: %[[tmp:.*]] = alloca %struct.two_fields, align 8
 // CHECK: call void @_Z14def_two_fieldsv(%struct.two_fields* nonnull sret 
%[[tmp]])
-// CHECK: call void @_Z3use10two_fields(%struct.two_fields* byval nonnull 
align 8 %[[tmp]])
+// CHECK: call void @_Z3use10two_fields(%struct.two_fields* nonnull byval 
align 8 %[[tmp]])
 // CHECK: ret void
 //
 // CHECK: declare void @_Z3use10two_fields(%struct.two_fields* byval align 8)

Modified: cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp?rev=362013=362012=362013=diff
==
--- cfe/trunk/test/CodeGenCXX/x86_64-arguments-nacl-x32.cpp 

Re: r345971 - Reapply Logging: make os_log buffer size an integer constant expression.

2018-11-02 Thread Tim Northover via cfe-commits
On 2 Nov 2018, at 15:28, Sam McCall  wrote:
> In that case, I don't think it makes sense to think of the format string 
> parser as part of the analyzer - as the build deps suggest, it's now part of 
> AST and gets reused by analyzer. (Similar to how the analyzer uses other bits 
> of AST/clang). If there are parts only relevant to analyzer, it'd be nice to 
> move them out of the AST library, but I don't know to what extent that's 
> feasible.

The Scanf one could have been left there, but that seems even worse from a 
consistency point of view.

> So it does seem to me like all the uses of analyzer namespaces are suspect - 
> moving code from Analyzer to AST is a semantic difference (the layers aren't 
> *just* about making the linker happy, after all!)

But what it’s doing is still analysis. It seems like we’d just be making up 
another term for the sake of it if we changed it.

Cheers.

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


Re: r345971 - Reapply Logging: make os_log buffer size an integer constant expression.

2018-11-02 Thread Tim Northover via cfe-commits


> On 2 Nov 2018, at 15:03, Tim Northover  wrote:
>> (If the do belong here: the namespaces and comments don't seem to have been 
>> updated)
> 
> Good point, I’ll get onto fixing that.

Actually, do you have any particular ones in mind? After going in to make 
changes, they still look pretty good to me; I don’t think libclangAnalysis 
should have the monopoly on the term.

Cheers.

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


Re: r345971 - Reapply Logging: make os_log buffer size an integer constant expression.

2018-11-02 Thread Tim Northover via cfe-commits
Hi Sam,

On 2 Nov 2018, at 13:31, Sam McCall  wrote:
> The move of OSLog.h and FormatString.h to AST doesn't look obviously correct.
> Do these really belong in this layer? I think this patch needs review from 
> someone who knows AST/ better than myself... was there a review?

Eli reviewed the change for OSLog.h in https://reviews.llvm.org/D53514 
 so that it could be used for the main part of 
the change. After that it was discovered OSLog depends on the other format 
helpers so there was still a circular dependency; I decided adding the others 
was a minor enough change to just go ahead.

The only alternative I see would be an entirely new library (“MiniAnalysis”?), 
which seems quite excessive.

> (If the do belong here: the namespaces and comments don't seem to have been 
> updated)

Good point, I’ll get onto fixing that.

Cheers.

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


[clang-tools-extra] r345971 - Reapply Logging: make os_log buffer size an integer constant expression.

2018-11-02 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Fri Nov  2 06:14:11 2018
New Revision: 345971

URL: http://llvm.org/viewvc/llvm-project?rev=345971=rev
Log:
Reapply Logging: make os_log buffer size an integer constant expression.

The size of an os_log buffer is known at any stage of compilation, so making it
a constant expression means that the common idiom of declaring a buffer for it
won't result in a VLA. That allows the compiler to skip saving and restoring
the stack pointer around such buffers.

This also moves the OSLog and other FormatString helpers from
libclangAnalysis to libclangAST to avoid a circular dependency.

Modified:
clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt?rev=345971=345970=345971=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt Fri Nov  2 06:14:11 
2018
@@ -15,7 +15,6 @@ add_clang_library(clangTidyCERTModule
   VariadicFunctionDefCheck.cpp
 
   LINK_LIBS
-  clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic

Modified: clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp?rev=345971=345970=345971=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp Fri Nov  2 
06:14:11 2018
@@ -10,7 +10,7 @@
 #include "StrToNumCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Analysis/Analyses/FormatString.h"
+#include "clang/AST/FormatString.h"
 #include "llvm/ADT/StringSwitch.h"
 #include 
 


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


Re: r345866 - Reapply Logging: make os_log buffer size an integer constant expression.

2018-11-01 Thread Tim Northover via cfe-commits
On 1 Nov 2018, at 18:36, Jan Vesely  wrote:
> this patch seems to cause a build failure:

Ugh. Reverted as r345871. 

Do you know what linker and other options you’re using? The only failure I’ve 
been able to reproduce locally is when I introduced a circular dependency.

Cheers.

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


r345871 - Revert "Reapply Logging: make os_log buffer size an integer constant expression."

2018-11-01 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Thu Nov  1 11:37:42 2018
New Revision: 345871

URL: http://llvm.org/viewvc/llvm-project?rev=345871=rev
Log:
Revert "Reapply Logging: make os_log buffer size an integer constant 
expression."

Still more dependency hell.

Added:
cfe/trunk/include/clang/Analysis/Analyses/OSLog.h
cfe/trunk/lib/Analysis/OSLog.cpp
Removed:
cfe/trunk/include/clang/AST/OSLog.h
cfe/trunk/lib/AST/OSLog.cpp
Modified:
cfe/trunk/lib/AST/CMakeLists.txt
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Analysis/CMakeLists.txt
cfe/trunk/lib/Analysis/PrintfFormatString.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins.c

Removed: cfe/trunk/include/clang/AST/OSLog.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OSLog.h?rev=345870=auto
==
--- cfe/trunk/include/clang/AST/OSLog.h (original)
+++ cfe/trunk/include/clang/AST/OSLog.h (removed)
@@ -1,155 +0,0 @@
-//= OSLog.h - Analysis of calls to os_log builtins --*- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-//
-// This file defines APIs for determining the layout of the data buffer for
-// os_log() and os_trace().
-//
-//===--===//
-
-#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_OSLOG_H
-#define LLVM_CLANG_ANALYSIS_ANALYSES_OSLOG_H
-
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/Expr.h"
-
-namespace clang {
-namespace analyze_os_log {
-
-/// An OSLogBufferItem represents a single item in the data written by a call
-/// to os_log() or os_trace().
-class OSLogBufferItem {
-public:
-  enum Kind {
-// The item is a scalar (int, float, raw pointer, etc.). No further copying
-// is required. This is the only kind allowed by os_trace().
-ScalarKind = 0,
-
-// The item is a count, which describes the length of the following item to
-// be copied. A count may only be followed by an item of kind StringKind,
-// WideStringKind, or PointerKind.
-CountKind,
-
-// The item is a pointer to a C string. If preceded by a count 'n',
-// os_log() will copy at most 'n' bytes from the pointer.
-StringKind,
-
-// The item is a pointer to a block of raw data. This item must be preceded
-// by a count 'n'. os_log() will copy exactly 'n' bytes from the pointer.
-PointerKind,
-
-// The item is a pointer to an Objective-C object. os_log() may retain the
-// object for later processing.
-ObjCObjKind,
-
-// The item is a pointer to wide-char string.
-WideStringKind,
-
-// The item is corresponding to the '%m' format specifier, no value is
-// populated in the buffer and the runtime is loading the errno value.
-ErrnoKind
-  };
-
-  enum {
-// The item is marked "private" in the format string.
-IsPrivate = 0x1,
-
-// The item is marked "public" in the format string.
-IsPublic = 0x2
-  };
-
-private:
-  Kind TheKind = ScalarKind;
-  const Expr *TheExpr = nullptr;
-  CharUnits ConstValue;
-  CharUnits Size; // size of the data, not including the header bytes
-  unsigned Flags = 0;
-
-public:
-  OSLogBufferItem(Kind kind, const Expr *expr, CharUnits size, unsigned flags)
-  : TheKind(kind), TheExpr(expr), Size(size), Flags(flags) {}
-
-  OSLogBufferItem(ASTContext , CharUnits value, unsigned flags)
-  : TheKind(CountKind), ConstValue(value),
-Size(Ctx.getTypeSizeInChars(Ctx.IntTy)), Flags(flags) {}
-
-  unsigned char getDescriptorByte() const {
-unsigned char result = 0;
-if (getIsPrivate())
-  result |= IsPrivate;
-if (getIsPublic())
-  result |= IsPublic;
-result |= ((unsigned)getKind()) << 4;
-return result;
-  }
-
-  unsigned char getSizeByte() const { return size().getQuantity(); }
-
-  Kind getKind() const { return TheKind; }
-  bool getIsPrivate() const { return (Flags & IsPrivate) != 0; }
-  bool getIsPublic() const { return (Flags & IsPublic) != 0; }
-
-  const Expr *getExpr() const { return TheExpr; }
-  CharUnits getConstValue() const { return ConstValue; }
-  CharUnits size() const { return Size; }
-};
-
-class OSLogBufferLayout {
-public:
-  SmallVector Items;
-
-  enum Flags { HasPrivateItems = 1, HasNonScalarItems = 1 << 1 };
-
-  CharUnits size() const {
-CharUnits result;
-result += CharUnits::fromQuantity(2); // summary byte, num-args byte
-for (auto  : Items) {
-  // descriptor byte, size byte
-  result += item.size() + CharUnits::fromQuantity(2);
-}
-return result;
-  }
-
-  bool hasPrivateItems() const {
-return llvm::any_of(
-Items, [](const OSLogBufferItem ) { return Item.getIsPrivate(); 
});
-  }
-
-  bool hasPublicItems() 

r345866 - Reapply Logging: make os_log buffer size an integer constant expression.

2018-11-01 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Thu Nov  1 11:04:49 2018
New Revision: 345866

URL: http://llvm.org/viewvc/llvm-project?rev=345866=rev
Log:
Reapply Logging: make os_log buffer size an integer constant expression.

The size of an os_log buffer is known at any stage of compilation, so making it
a constant expression means that the common idiom of declaring a buffer for it
won't result in a VLA. That allows the compiler to skip saving and restoring
the stack pointer around such buffers.

This also moves the OSLog helpers from libclangAnalysis to libclangAST
to avoid a circular dependency.

Added:
cfe/trunk/include/clang/AST/OSLog.h
cfe/trunk/lib/AST/OSLog.cpp
Removed:
cfe/trunk/include/clang/Analysis/Analyses/OSLog.h
cfe/trunk/lib/Analysis/OSLog.cpp
Modified:
cfe/trunk/lib/AST/CMakeLists.txt
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Analysis/CMakeLists.txt
cfe/trunk/lib/Analysis/PrintfFormatString.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins.c

Added: cfe/trunk/include/clang/AST/OSLog.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OSLog.h?rev=345866=auto
==
--- cfe/trunk/include/clang/AST/OSLog.h (added)
+++ cfe/trunk/include/clang/AST/OSLog.h Thu Nov  1 11:04:49 2018
@@ -0,0 +1,155 @@
+//= OSLog.h - Analysis of calls to os_log builtins --*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file defines APIs for determining the layout of the data buffer for
+// os_log() and os_trace().
+//
+//===--===//
+
+#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_OSLOG_H
+#define LLVM_CLANG_ANALYSIS_ANALYSES_OSLOG_H
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Expr.h"
+
+namespace clang {
+namespace analyze_os_log {
+
+/// An OSLogBufferItem represents a single item in the data written by a call
+/// to os_log() or os_trace().
+class OSLogBufferItem {
+public:
+  enum Kind {
+// The item is a scalar (int, float, raw pointer, etc.). No further copying
+// is required. This is the only kind allowed by os_trace().
+ScalarKind = 0,
+
+// The item is a count, which describes the length of the following item to
+// be copied. A count may only be followed by an item of kind StringKind,
+// WideStringKind, or PointerKind.
+CountKind,
+
+// The item is a pointer to a C string. If preceded by a count 'n',
+// os_log() will copy at most 'n' bytes from the pointer.
+StringKind,
+
+// The item is a pointer to a block of raw data. This item must be preceded
+// by a count 'n'. os_log() will copy exactly 'n' bytes from the pointer.
+PointerKind,
+
+// The item is a pointer to an Objective-C object. os_log() may retain the
+// object for later processing.
+ObjCObjKind,
+
+// The item is a pointer to wide-char string.
+WideStringKind,
+
+// The item is corresponding to the '%m' format specifier, no value is
+// populated in the buffer and the runtime is loading the errno value.
+ErrnoKind
+  };
+
+  enum {
+// The item is marked "private" in the format string.
+IsPrivate = 0x1,
+
+// The item is marked "public" in the format string.
+IsPublic = 0x2
+  };
+
+private:
+  Kind TheKind = ScalarKind;
+  const Expr *TheExpr = nullptr;
+  CharUnits ConstValue;
+  CharUnits Size; // size of the data, not including the header bytes
+  unsigned Flags = 0;
+
+public:
+  OSLogBufferItem(Kind kind, const Expr *expr, CharUnits size, unsigned flags)
+  : TheKind(kind), TheExpr(expr), Size(size), Flags(flags) {}
+
+  OSLogBufferItem(ASTContext , CharUnits value, unsigned flags)
+  : TheKind(CountKind), ConstValue(value),
+Size(Ctx.getTypeSizeInChars(Ctx.IntTy)), Flags(flags) {}
+
+  unsigned char getDescriptorByte() const {
+unsigned char result = 0;
+if (getIsPrivate())
+  result |= IsPrivate;
+if (getIsPublic())
+  result |= IsPublic;
+result |= ((unsigned)getKind()) << 4;
+return result;
+  }
+
+  unsigned char getSizeByte() const { return size().getQuantity(); }
+
+  Kind getKind() const { return TheKind; }
+  bool getIsPrivate() const { return (Flags & IsPrivate) != 0; }
+  bool getIsPublic() const { return (Flags & IsPublic) != 0; }
+
+  const Expr *getExpr() const { return TheExpr; }
+  CharUnits getConstValue() const { return ConstValue; }
+  CharUnits size() const { return Size; }
+};
+
+class OSLogBufferLayout {
+public:
+  SmallVector Items;
+
+  enum Flags { HasPrivateItems = 1, HasNonScalarItems = 1 << 1 };
+
+  CharUnits size() const {
+CharUnits result;
+result += CharUnits::fromQuantity(2); // summary 

Re: r345833 - Logging: add CMake dependency so libAST can use OSLog analysis.

2018-11-01 Thread Tim Northover via cfe-commits
Oh bother, I vaguely remember that means I’ll have broken .so builds now?

Either way, I’ve reverted the sequence in r345846. I’ll work on putting the 
os_log machinery into AST and update the review.

Thanks for looking out!

Tim.

> On 1 Nov 2018, at 16:05, Benjamin Kramer  wrote:
> 
> This doesn't work. AST cannot depend on Analysis because Analysis already 
> depends on AST.
> 
> On Thu, Nov 1, 2018 at 3:24 PM Tim Northover via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: tnorthover
> Date: Thu Nov  1 07:22:20 2018
> New Revision: 345833
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=345833=rev 
> <http://llvm.org/viewvc/llvm-project?rev=345833=rev>
> Log:
> Logging: add CMake dependency so libAST can use OSLog analysis.
> 
> Should fix bots on platforms with slightly different symbol resolution
> semantics.
> 
> Modified:
> cfe/trunk/lib/AST/CMakeLists.txt
> 
> Modified: cfe/trunk/lib/AST/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CMakeLists.txt?rev=345833=345832=345833=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CMakeLists.txt?rev=345833=345832=345833=diff>
> ==
> --- cfe/trunk/lib/AST/CMakeLists.txt (original)
> +++ cfe/trunk/lib/AST/CMakeLists.txt Thu Nov  1 07:22:20 2018
> @@ -1,4 +1,5 @@
>  set(LLVM_LINK_COMPONENTS
> +  Analysis
>BinaryFormat
>Support
>)
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org <mailto:cfe-commits@lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits>

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


r345846 - Revert "Logging: make os_log buffer size an integer constant expression.

2018-11-01 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Thu Nov  1 09:15:24 2018
New Revision: 345846

URL: http://llvm.org/viewvc/llvm-project?rev=345846=rev
Log:
Revert "Logging: make os_log buffer size an integer constant expression.

This also reverts a couple of follow-up commits trying to fix the
dependency issues. Latest revision added a cyclic dependency that can't
just be patched up in 5 minutes.

Modified:
cfe/trunk/lib/AST/CMakeLists.txt
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins.c

Modified: cfe/trunk/lib/AST/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CMakeLists.txt?rev=345846=345845=345846=diff
==
--- cfe/trunk/lib/AST/CMakeLists.txt (original)
+++ cfe/trunk/lib/AST/CMakeLists.txt Thu Nov  1 09:15:24 2018
@@ -72,7 +72,6 @@ add_clang_library(clangAST
   VTTBuilder.cpp
 
   LINK_LIBS
-  clangAnalysis
   clangBasic
   clangLex
   )

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=345846=345845=345846=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Nov  1 09:15:24 2018
@@ -33,7 +33,6 @@
 //
 
//===--===//
 
-#include "clang/Analysis/Analyses/OSLog.h"
 #include "clang/AST/APValue.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTDiagnostic.h"
@@ -8127,12 +8126,6 @@ bool IntExprEvaluator::VisitBuiltinCallE
 llvm_unreachable("unexpected EvalMode");
   }
 
-  case Builtin::BI__builtin_os_log_format_buffer_size: {
-analyze_os_log::OSLogBufferLayout Layout;
-analyze_os_log::computeOSLogBufferLayout(Info.Ctx, E, Layout);
-return Success(Layout.size().getQuantity(), E);
-  }
-
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
   case Builtin::BI__builtin_bswap64: {

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=345846=345845=345846=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Nov  1 09:15:24 2018
@@ -3609,6 +3609,13 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   case Builtin::BI__builtin_os_log_format:
 return emitBuiltinOSLogFormat(*E);
 
+  case Builtin::BI__builtin_os_log_format_buffer_size: {
+analyze_os_log::OSLogBufferLayout Layout;
+analyze_os_log::computeOSLogBufferLayout(CGM.getContext(), E, Layout);
+return RValue::get(ConstantInt::get(ConvertType(E->getType()),
+Layout.size().getQuantity()));
+  }
+
   case Builtin::BI__xray_customevent: {
 if (!ShouldXRayInstrumentFunction())
   return RValue::getIgnored();

Modified: cfe/trunk/test/CodeGen/builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=345846=345845=345846=diff
==
--- cfe/trunk/test/CodeGen/builtins.c (original)
+++ cfe/trunk/test/CodeGen/builtins.c Thu Nov  1 09:15:24 2018
@@ -729,28 +729,25 @@ void test_builtin_os_log_merge_helper1(v
 
 // CHECK-LABEL: define void @test_builtin_os_log_errno
 void test_builtin_os_log_errno() {
-  // CHECK-NOT: @stacksave
-  // CHECK: %[[BUF:.*]] = alloca [4 x i8], align 1
-  // CHECK: %[[DECAY:.*]] = getelementptr inbounds [4 x i8], [4 x i8]* 
%[[BUF]], i32 0, i32 0
-  // CHECK: call void @__os_log_helper_1_2_1_0_96(i8* %[[DECAY]])
-  // CHECK-NOT: @stackrestore
+  // CHECK: %[[VLA:.*]] = alloca i8, i64 4, align 16
+  // CHECK: call void @__os_log_helper_16_2_1_0_96(i8* %[[VLA]])
 
   char buf[__builtin_os_log_format_buffer_size("%m")];
   __builtin_os_log_format(buf, "%m");
 }
 
-// CHECK-LABEL: define linkonce_odr hidden void @__os_log_helper_1_2_1_0_96
+// CHECK-LABEL: define linkonce_odr hidden void @__os_log_helper_16_2_1_0_96
 // CHECK: (i8* %[[BUFFER:.*]])
 
 // CHECK: %[[BUFFER_ADDR:.*]] = alloca i8*, align 8
 // CHECK: store i8* %[[BUFFER]], i8** %[[BUFFER_ADDR]], align 8
 // CHECK: %[[BUF:.*]] = load i8*, i8** %[[BUFFER_ADDR]], align 8
 // CHECK: %[[SUMMARY:.*]] = getelementptr i8, i8* %[[BUF]], i64 0
-// CHECK: store i8 2, i8* %[[SUMMARY]], align 1
+// CHECK: store i8 2, i8* %[[SUMMARY]], align 16
 // CHECK: %[[NUMARGS:.*]] = getelementptr i8, i8* %[[BUF]], i64 1
 // CHECK: store i8 1, i8* %[[NUMARGS]], align 1
 // CHECK: %[[ARGDESCRIPTOR:.*]] = getelementptr i8, i8* %[[BUF]], i64 2
-// CHECK: store i8 96, i8* %[[ARGDESCRIPTOR]], align 1
+// CHECK: store i8 96, i8* %[[ARGDESCRIPTOR]], align 2
 // CHECK: %[[ARGSIZE:.*]] = getelementptr i8, i8* %[[BUF]], i64 3
 // CHECK: store i8 0, i8* %[[ARGSIZE]], align 1
 // CHECK-NEXT: ret void


r345835 - Logging: put link against libclangAnalysis rather than libLLVMAnalysis for os_log

2018-11-01 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Thu Nov  1 07:43:35 2018
New Revision: 345835

URL: http://llvm.org/viewvc/llvm-project?rev=345835=rev
Log:
Logging: put link against libclangAnalysis rather than libLLVMAnalysis for 
os_log

Modified:
cfe/trunk/lib/AST/CMakeLists.txt

Modified: cfe/trunk/lib/AST/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CMakeLists.txt?rev=345835=345834=345835=diff
==
--- cfe/trunk/lib/AST/CMakeLists.txt (original)
+++ cfe/trunk/lib/AST/CMakeLists.txt Thu Nov  1 07:43:35 2018
@@ -1,5 +1,4 @@
 set(LLVM_LINK_COMPONENTS
-  Analysis
   BinaryFormat
   Support
   )
@@ -73,6 +72,7 @@ add_clang_library(clangAST
   VTTBuilder.cpp
 
   LINK_LIBS
+  clangAnalysis
   clangBasic
   clangLex
   )


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


r345833 - Logging: add CMake dependency so libAST can use OSLog analysis.

2018-11-01 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Thu Nov  1 07:22:20 2018
New Revision: 345833

URL: http://llvm.org/viewvc/llvm-project?rev=345833=rev
Log:
Logging: add CMake dependency so libAST can use OSLog analysis.

Should fix bots on platforms with slightly different symbol resolution
semantics.

Modified:
cfe/trunk/lib/AST/CMakeLists.txt

Modified: cfe/trunk/lib/AST/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CMakeLists.txt?rev=345833=345832=345833=diff
==
--- cfe/trunk/lib/AST/CMakeLists.txt (original)
+++ cfe/trunk/lib/AST/CMakeLists.txt Thu Nov  1 07:22:20 2018
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  Analysis
   BinaryFormat
   Support
   )


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


r345828 - Logging: make os_log buffer size an integer constant expression.

2018-11-01 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Thu Nov  1 06:49:54 2018
New Revision: 345828

URL: http://llvm.org/viewvc/llvm-project?rev=345828=rev
Log:
Logging: make os_log buffer size an integer constant expression.

The size of an os_log buffer is known at any stage of compilation, so making it
a constant expression means that the common idiom of declaring a buffer for it
won't result in a VLA. That allows the compiler to skip saving and restoring
the stack pointer around such buffers.

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins.c

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=345828=345827=345828=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Nov  1 06:49:54 2018
@@ -33,6 +33,7 @@
 //
 
//===--===//
 
+#include "clang/Analysis/Analyses/OSLog.h"
 #include "clang/AST/APValue.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTDiagnostic.h"
@@ -8126,6 +8127,12 @@ bool IntExprEvaluator::VisitBuiltinCallE
 llvm_unreachable("unexpected EvalMode");
   }
 
+  case Builtin::BI__builtin_os_log_format_buffer_size: {
+analyze_os_log::OSLogBufferLayout Layout;
+analyze_os_log::computeOSLogBufferLayout(Info.Ctx, E, Layout);
+return Success(Layout.size().getQuantity(), E);
+  }
+
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
   case Builtin::BI__builtin_bswap64: {

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=345828=345827=345828=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Nov  1 06:49:54 2018
@@ -3609,13 +3609,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   case Builtin::BI__builtin_os_log_format:
 return emitBuiltinOSLogFormat(*E);
 
-  case Builtin::BI__builtin_os_log_format_buffer_size: {
-analyze_os_log::OSLogBufferLayout Layout;
-analyze_os_log::computeOSLogBufferLayout(CGM.getContext(), E, Layout);
-return RValue::get(ConstantInt::get(ConvertType(E->getType()),
-Layout.size().getQuantity()));
-  }
-
   case Builtin::BI__xray_customevent: {
 if (!ShouldXRayInstrumentFunction())
   return RValue::getIgnored();

Modified: cfe/trunk/test/CodeGen/builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=345828=345827=345828=diff
==
--- cfe/trunk/test/CodeGen/builtins.c (original)
+++ cfe/trunk/test/CodeGen/builtins.c Thu Nov  1 06:49:54 2018
@@ -729,25 +729,28 @@ void test_builtin_os_log_merge_helper1(v
 
 // CHECK-LABEL: define void @test_builtin_os_log_errno
 void test_builtin_os_log_errno() {
-  // CHECK: %[[VLA:.*]] = alloca i8, i64 4, align 16
-  // CHECK: call void @__os_log_helper_16_2_1_0_96(i8* %[[VLA]])
+  // CHECK-NOT: @stacksave
+  // CHECK: %[[BUF:.*]] = alloca [4 x i8], align 1
+  // CHECK: %[[DECAY:.*]] = getelementptr inbounds [4 x i8], [4 x i8]* 
%[[BUF]], i32 0, i32 0
+  // CHECK: call void @__os_log_helper_1_2_1_0_96(i8* %[[DECAY]])
+  // CHECK-NOT: @stackrestore
 
   char buf[__builtin_os_log_format_buffer_size("%m")];
   __builtin_os_log_format(buf, "%m");
 }
 
-// CHECK-LABEL: define linkonce_odr hidden void @__os_log_helper_16_2_1_0_96
+// CHECK-LABEL: define linkonce_odr hidden void @__os_log_helper_1_2_1_0_96
 // CHECK: (i8* %[[BUFFER:.*]])
 
 // CHECK: %[[BUFFER_ADDR:.*]] = alloca i8*, align 8
 // CHECK: store i8* %[[BUFFER]], i8** %[[BUFFER_ADDR]], align 8
 // CHECK: %[[BUF:.*]] = load i8*, i8** %[[BUFFER_ADDR]], align 8
 // CHECK: %[[SUMMARY:.*]] = getelementptr i8, i8* %[[BUF]], i64 0
-// CHECK: store i8 2, i8* %[[SUMMARY]], align 16
+// CHECK: store i8 2, i8* %[[SUMMARY]], align 1
 // CHECK: %[[NUMARGS:.*]] = getelementptr i8, i8* %[[BUF]], i64 1
 // CHECK: store i8 1, i8* %[[NUMARGS]], align 1
 // CHECK: %[[ARGDESCRIPTOR:.*]] = getelementptr i8, i8* %[[BUF]], i64 2
-// CHECK: store i8 96, i8* %[[ARGDESCRIPTOR]], align 2
+// CHECK: store i8 96, i8* %[[ARGDESCRIPTOR]], align 1
 // CHECK: %[[ARGSIZE:.*]] = getelementptr i8, i8* %[[BUF]], i64 3
 // CHECK: store i8 0, i8* %[[ARGSIZE]], align 1
 // CHECK-NEXT: ret void


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


r341240 - Tests: fix tests encoding specific hash values for 32-bit systems.

2018-08-31 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Fri Aug 31 12:24:37 2018
New Revision: 341240

URL: http://llvm.org/viewvc/llvm-project?rev=341240=rev
Log:
Tests: fix tests encoding specific hash values for 32-bit systems.

I changed the seed slightly, but forgot to run the tests on a 32-bit system, so
tests which hard-code a specific hash value started breaking.

Modified:
cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp

Modified: cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp?rev=341240=341239=341240=diff
==
--- cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp Fri Aug 31 12:24:37 2018
@@ -72,7 +72,7 @@ void member_access(S *p) {
   // The two hash values are for 64- and 32-bit Clang binaries, respectively.
   // FIXME: We should produce a 64-bit value either way.
   //
-  // CHECK-NEXT: xor i64 {{-4030275160588942838|2562089159}}, %[[VPTR]]
+  // CHECK-NEXT: xor i64 {{-4030275160588942838|1107558922}}, %[[VPTR]]
   // CHECK-NEXT: mul i64 {{.*}}, -7070675565921424023
   // CHECK-NEXT: lshr i64 {{.*}}, 47
   // CHECK-NEXT: xor i64
@@ -121,7 +121,7 @@ void member_access(S *p) {
   // (3b) Check that 'p' actually points to an 'S'
 
   // CHECK: load i64, i64*
-  // CHECK-NEXT: xor i64 {{-4030275160588942838|2562089159}},
+  // CHECK-NEXT: xor i64 {{-4030275160588942838|1107558922}},
   // [...]
   // CHECK: getelementptr inbounds [128 x i64], [128 x i64]* 
@__ubsan_vptr_type_cache, i32 0, i64 %
   // CHECK: br i1


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


r338879 - Revert "clang-format: [JS] don't break comments before any '{'"

2018-08-03 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Fri Aug  3 05:19:22 2018
New Revision: 338879

URL: http://llvm.org/viewvc/llvm-project?rev=338879=rev
Log:
Revert "clang-format: [JS] don't break comments before any '{'"

This reverts commit r338837, it introduced an infinite loop on all bots.

Modified:
cfe/trunk/lib/Format/BreakableToken.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/BreakableToken.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=338879=338878=338879=diff
==
--- cfe/trunk/lib/Format/BreakableToken.cpp (original)
+++ cfe/trunk/lib/Format/BreakableToken.cpp Fri Aug  3 05:19:22 2018
@@ -90,19 +90,19 @@ static BreakableToken::Split getCommentS
 
   StringRef::size_type SpaceOffset = Text.find_last_of(Blanks, MaxSplitBytes);
 
+  // Do not split before a number followed by a dot: this would be interpreted
+  // as a numbered list, which would prevent re-flowing in subsequent passes.
   static auto *const kNumberedListRegexp = new llvm::Regex("^[1-9][0-9]?\\.");
-  while (SpaceOffset != StringRef::npos) {
-// Do not split before a number followed by a dot: this would be 
interpreted
-// as a numbered list, which would prevent re-flowing in subsequent passes.
-if (kNumberedListRegexp->match(Text.substr(SpaceOffset).ltrim(Blanks)))
-  SpaceOffset = Text.find_last_of(Blanks, SpaceOffset);
-// In JavaScript, some @tags can be followed by {, and machinery that 
parses
-// these comments will fail to understand the comment if followed by a line
-// break. So avoid ever breaking before a {.
-else if (Style.Language == FormatStyle::LK_JavaScript &&
- SpaceOffset + 1 < Text.size() && Text[SpaceOffset + 1] == '{')
-  SpaceOffset = Text.find_last_of(Blanks, SpaceOffset);
-  }
+  if (SpaceOffset != StringRef::npos &&
+  kNumberedListRegexp->match(Text.substr(SpaceOffset).ltrim(Blanks)))
+SpaceOffset = Text.find_last_of(Blanks, SpaceOffset);
+  // In JavaScript, some @tags can be followed by {, and machinery that parses
+  // these comments will fail to understand the comment if followed by a line
+  // break. So avoid ever breaking before a {.
+  if (Style.Language == FormatStyle::LK_JavaScript &&
+  SpaceOffset != StringRef::npos && SpaceOffset + 1 < Text.size() &&
+  Text[SpaceOffset + 1] == '{')
+SpaceOffset = Text.find_last_of(Blanks, SpaceOffset);
 
   if (SpaceOffset == StringRef::npos ||
   // Don't break at leading whitespace.

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=338879=338878=338879=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Aug  3 05:19:22 2018
@@ -2067,14 +2067,6 @@ TEST_F(FormatTestJS, JSDocAnnotations) {
" * @param {canWrap onSpace}\n"
" */",
getGoogleJSStyleWithColumns(20));
-  // make sure clang-format doesn't break before *any* '{'
-  verifyFormat("/**\n"
-   " * @lala {lala {lalala\n"
-   " */\n",
-   "/**\n"
-   " * @lala {lala {lalala\n"
-   " */\n",
-   getGoogleJSStyleWithColumns(20));
   verifyFormat("/**\n"
" * @see http://very/very/long/url/is/long\n;
" */",


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


Re: r338837 - clang-format: [JS] don't break comments before any '{'

2018-08-03 Thread Tim Northover via cfe-commits
On Fri, 3 Aug 2018 at 11:47, Tim Northover  wrote:
> On Fri, 3 Aug 2018 at 10:34, Martin Probst via cfe-commits
>  wrote:
> > clang-format: [JS] don't break comments before any '{'
>
> This looks like it's triggered a bunch of infinite loops in Clang's
> unittests.

I've just taken a look at the normal lab.llvm.org bots and it looks
like *everything* is broken so I've reverted it for now.

Cheers.

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


Re: r338837 - clang-format: [JS] don't break comments before any '{'

2018-08-03 Thread Tim Northover via cfe-commits
Hi Martin,

On Fri, 3 Aug 2018 at 10:34, Martin Probst via cfe-commits
 wrote:
> clang-format: [JS] don't break comments before any '{'

This looks like it's triggered a bunch of infinite loops in Clang's
unittests. For example:
http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/51705/.

Could you take a look?

Cheers.

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


[clang-tools-extra] r334093 - Add semicolon to recent MSVC fix.

2018-06-06 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed Jun  6 06:28:49 2018
New Revision: 334093

URL: http://llvm.org/viewvc/llvm-project?rev=334093=rev
Log:
Add semicolon to recent MSVC fix.

Modified:
clang-tools-extra/trunk/clangd/Quality.cpp

Modified: clang-tools-extra/trunk/clangd/Quality.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Quality.cpp?rev=334093=334092=334093=diff
==
--- clang-tools-extra/trunk/clangd/Quality.cpp (original)
+++ clang-tools-extra/trunk/clangd/Quality.cpp Wed Jun  6 06:28:49 2018
@@ -90,7 +90,7 @@ categorize(const index::SymbolInfo ) {
 case index::SymbolKind::Unknown:
   return SymbolQualitySignals::Unknown;
   }
-  llvm_unreachable("Unknown index::SymbolKind")
+  llvm_unreachable("Unknown index::SymbolKind");
 }
 
 void SymbolQualitySignals::merge(const CodeCompletionResult ) {


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


r330566 - [Atomics] warn about atomic accesses using libcalls

2018-04-23 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Mon Apr 23 01:16:24 2018
New Revision: 330566

URL: http://llvm.org/viewvc/llvm-project?rev=330566=rev
Log:
[Atomics] warn about atomic accesses using libcalls

If an atomic variable is misaligned (and that suspicion is why Clang emits
libcalls at all) the runtime support library will have to use a lock to safely
access it, with potentially very bad performance consequences. There's a very
good chance this is unintentional so it makes sense to issue a warning.

Also give it a named group so people can promote it to an error, or disable it
if they really don't care.

Added:
cfe/trunk/test/CodeGen/atomics-sema-alignment.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CGAtomic.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=330566=330565=330566=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Apr 23 01:16:24 
2018
@@ -7111,6 +7111,9 @@ def warn_atomic_op_has_invalid_memory_or
   InGroup>;
 def err_atomic_op_has_invalid_synch_scope : Error<
   "synchronization scope argument to atomic operation is invalid">;
+def warn_atomic_op_misaligned : Warning<
+  "misaligned or large atomic operation may incur significant performance 
penalty">,
+  InGroup>;
 
 def err_overflow_builtin_must_be_int : Error<
   "operand argument to overflow builtin must be an integer (%0 invalid)">;

Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=330566=330565=330566=diff
==
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Mon Apr 23 01:16:24 2018
@@ -18,6 +18,7 @@
 #include "TargetInfo.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
+#include "clang/Sema/SemaDiagnostic.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Intrinsics.h"
@@ -751,6 +752,13 @@ RValue CodeGenFunction::EmitAtomicExpr(A
   Address Dest = Address::invalid();
   Address Ptr = EmitPointerWithAlignment(E->getPtr());
 
+  if (E->getOp() == AtomicExpr::AO__c11_atomic_init ||
+  E->getOp() == AtomicExpr::AO__opencl_atomic_init) {
+LValue lvalue = MakeAddrLValue(Ptr, AtomicTy);
+EmitAtomicInit(E->getVal1(), lvalue);
+return RValue::get(nullptr);
+  }
+
   CharUnits sizeChars, alignChars;
   std::tie(sizeChars, alignChars) = getContext().getTypeInfoInChars(AtomicTy);
   uint64_t Size = sizeChars.getQuantity();
@@ -758,12 +766,8 @@ RValue CodeGenFunction::EmitAtomicExpr(A
   bool UseLibcall = ((Ptr.getAlignment() % sizeChars) != 0 ||
  getContext().toBits(sizeChars) > MaxInlineWidthInBits);
 
-  if (E->getOp() == AtomicExpr::AO__c11_atomic_init ||
-  E->getOp() == AtomicExpr::AO__opencl_atomic_init) {
-LValue lvalue = MakeAddrLValue(Ptr, AtomicTy);
-EmitAtomicInit(E->getVal1(), lvalue);
-return RValue::get(nullptr);
-  }
+  if (UseLibcall)
+CGM.getDiags().Report(E->getLocStart(), diag::warn_atomic_op_misaligned);
 
   llvm::Value *Order = EmitScalarExpr(E->getOrder());
   llvm::Value *Scope =

Added: cfe/trunk/test/CodeGen/atomics-sema-alignment.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/atomics-sema-alignment.c?rev=330566=auto
==
--- cfe/trunk/test/CodeGen/atomics-sema-alignment.c (added)
+++ cfe/trunk/test/CodeGen/atomics-sema-alignment.c Mon Apr 23 01:16:24 2018
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu %s -emit-llvm -o /dev/null -verify
+
+typedef struct {
+  int a, b;
+} IntPair;
+
+typedef struct {
+  long long a;
+} LongStruct;
+
+typedef int __attribute__((aligned(1))) unaligned_int;
+
+void func(IntPair *p) {
+  IntPair res;
+  __atomic_load(p, , 0); // expected-warning {{misaligned or large atomic 
operation may incur significant performance penalty}}
+  __atomic_store(p, , 0); // expected-warning {{misaligned or large atomic 
operation may incur significant performance penalty}}
+  __atomic_fetch_add((unaligned_int *)p, 1, 2); // expected-warning 
{{misaligned or large atomic operation may incur significant performance 
penalty}}
+  __atomic_fetch_sub((unaligned_int *)p, 1, 3); // expected-warning 
{{misaligned or large atomic operation may incur significant performance 
penalty}}
+}
+
+void func1(LongStruct *p) {
+  LongStruct res;
+  __atomic_load(p, , 0);
+  __atomic_store(p, , 0);
+  __atomic_fetch_add((int *)p, 1, 2);
+  __atomic_fetch_sub((int *)p, 1, 3);
+}


___

r320250 - Switch to gnu++14 as the default dialect.

2017-12-09 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Sat Dec  9 04:09:54 2017
New Revision: 320250

URL: http://llvm.org/viewvc/llvm-project?rev=320250=rev
Log:
Switch to gnu++14 as the default dialect.

This is C++14 with conforming GNU extensions.

Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGenCXX/new-overflow.cpp
cfe/trunk/test/CodeGenCXX/new.cpp
cfe/trunk/test/CodeGenCXX/vtable-available-externally.cpp
cfe/trunk/test/Lexer/cxx-features.cpp
cfe/trunk/test/Lexer/half-literal.cpp
cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp
cfe/trunk/test/Parser/cxx1z-nested-namespace-definition.cpp
cfe/trunk/test/SemaCXX/new-array-size-conv.cpp
cfe/trunk/test/SemaCXX/new-delete.cpp
cfe/trunk/test/SemaCXX/unknown-type-name.cpp
cfe/trunk/test/SemaTemplate/class-template-decl.cpp
cfe/trunk/test/SemaTemplate/explicit-instantiation.cpp

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=320250=320249=320250=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Sat Dec  9 04:09:54 2017
@@ -176,7 +176,10 @@ C11 Feature Support
 C++ Language Changes in Clang
 -
 
-...
+- Clang's default C++ dialect is now ``gnu++14`` instead of ``gnu++98``. This
+  means Clang will by default accept code using features from C++14 and
+  conforming GNU extensions. Projects incompatible with C++14 can add
+  ``-std=gnu++98`` to their build settings to restore the previous behaviour.
 
 C++1z Feature Support
 ^

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=320250=320249=320250=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Sat Dec  9 04:09:54 2017
@@ -1729,11 +1729,7 @@ void CompilerInvocation::setLangDefaults
   break;
 case InputKind::CXX:
 case InputKind::ObjCXX:
-  // The PS4 uses C++11 as the default C++ standard.
-  if (T.isPS4())
-LangStd = LangStandard::lang_gnucxx11;
-  else
-LangStd = LangStandard::lang_gnucxx98;
+  LangStd = LangStandard::lang_gnucxx14;
   break;
 case InputKind::RenderScript:
   LangStd = LangStandard::lang_c99;

Modified: cfe/trunk/test/CodeGenCXX/new-overflow.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/new-overflow.cpp?rev=320250=320249=320250=diff
==
--- cfe/trunk/test/CodeGenCXX/new-overflow.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/new-overflow.cpp Sat Dec  9 04:09:54 2017
@@ -85,9 +85,7 @@ namespace test4 {
 
   // CHECK:define [[A:%.*]]* @_ZN5test44testEs(i16 signext
   // CHECK:  [[N:%.*]] = sext i16 {{%.*}} to i32
-  // CHECK-NEXT: [[T0:%.*]] = icmp slt i32 [[N]], 0
-  // CHECK-NEXT: [[T1:%.*]] = select i1 [[T0]], i32 -1, i32 [[N]]
-  // CHECK-NEXT: call i8* @_Znaj(i32 [[T1]])
+  // CHECK-NEXT: call i8* @_Znaj(i32 [[N]])
   // CHECK:  getelementptr inbounds {{.*}}, i32 [[N]]
   elt *test(short s) {
 return new elt[s];
@@ -104,9 +102,7 @@ namespace test5 {
 
   // CHECK:define [[A:%.*]]* @_ZN5test54testEi(i32
   // CHECK:  [[N:%.*]] = load i32, i32*
-  // CHECK-NEXT: [[T0:%.*]] = icmp slt i32 [[N]], 0
-  // CHECK-NEXT: [[T1:%.*]] = select i1 [[T0]], i32 -1, i32 [[N]]
-  // CHECK-NEXT: call i8* @_Znaj(i32 [[T1]])
+  // CHECK-NEXT: call i8* @_Znaj(i32 [[N]])
   // CHECK:  getelementptr inbounds {{.*}}, i32 [[N]]
   elt *test(int s) {
 return new elt[s];
@@ -169,13 +165,11 @@ namespace test8 {
 
   // CHECK:define [[A:%.*]]* @_ZN5test84testEx(i64
   // CHECK:  [[N:%.*]] = load i64, i64*
-  // CHECK-NEXT: [[T0:%.*]] = icmp uge i64 [[N]], 4294967296
   // CHECK-NEXT: [[T1:%.*]] = trunc i64 [[N]] to i32
   // CHECK-NEXT: [[T2:%.*]] = call { i32, i1 } 
@llvm.umul.with.overflow.i32(i32 [[T1]], i32 4)
   // CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 1
-  // CHECK-NEXT: [[T4:%.*]] = or i1 [[T0]], [[T3]]
   // CHECK-NEXT: [[T5:%.*]] = extractvalue { i32, i1 } [[T2]], 0
-  // CHECK-NEXT: [[T6:%.*]] = select i1 [[T4]], i32 -1, i32 [[T5]]
+  // CHECK-NEXT: [[T6:%.*]] = select i1 [[T3]], i32 -1, i32 [[T5]]
   // CHECK-NEXT: call i8* @_Znaj(i32 [[T6]])
   // CHECK:  getelementptr inbounds {{.*}}, i32 [[T1]]
   elt *test(long long s) {
@@ -194,13 +188,11 @@ namespace test9 {
 
   // CHECK:define [[A:%.*]]* @_ZN5test94testEy(i64
   // CHECK:  [[N:%.*]] = load i64, i64*
-  // CHECK-NEXT: [[T0:%.*]] = icmp uge i64 [[N]], 4294967296
   // CHECK-NEXT: [[T1:%.*]] = trunc i64 

Re: [PATCH] D40948: Switch Clang's default C++ language target to C++14

2017-12-07 Thread Tim Northover via cfe-commits
> +  LangStd = LangStandard::lang_gnucxx14;
> 
> This comment should be removed.

Opps, yep. Fixed on my local branch. I won't upload a new diff just yet though.

Thanks.

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


Re: [PATCH] D40948: Switch Clang's default C++ language target to C++14

2017-12-07 Thread Tim Northover via cfe-commits
Here's the test-suite diff. It's really just a few ancient code-bases
that don't compile with C++14, no runtime issues I noticed.

Tim.
commit a52b065052bfefaac17e7096fd2c911aac62e9da
Author: Tim Northover 
Date:   Thu Dec 7 09:16:34 2017 +

Support C++14 as a default in Clang

diff --git a/External/SPEC/CFP2006/447.dealII/CMakeLists.txt 
b/External/SPEC/CFP2006/447.dealII/CMakeLists.txt
index 4c3388f4..00bd711b 100644
--- a/External/SPEC/CFP2006/447.dealII/CMakeLists.txt
+++ b/External/SPEC/CFP2006/447.dealII/CMakeLists.txt
@@ -1,6 +1,7 @@
 include_directories(${BENCHMARK_DIR}/src/include)
 add_definitions(-DBOOST_DISABLE_THREADS -Ddeal_II_dimension=3)
 list(APPEND LDFLAGS -lm)
+list(APPEND CXXFLAGS -std=gnu++98)
 
 macro(verify_n run_type dir n)
   # Note that the official SPEC fp tolarence is only "-a .001", however 
this
diff --git a/External/SPEC/CFP2006/447.dealII/Makefile 
b/External/SPEC/CFP2006/447.dealII/Makefile
index 32d6d55d..ac433b55 100644
--- a/External/SPEC/CFP2006/447.dealII/Makefile
+++ b/External/SPEC/CFP2006/447.dealII/Makefile
@@ -16,7 +16,7 @@ CPPFLAGS += \
 -Ddeal_II_dimension=3 \
 -DBOOST_DISABLE_THREADS   \
 -I$(SPEC_BENCH_DIR)/src/include
-CXXFLAGS += -stdlib=libstdc++
+CXXFLAGS += -stdlib=libstdc++ -std=gnu++98
 
 STDOUT_FILENAME := log
 
diff --git a/External/SPEC/CFP2006/450.soplex/CMakeLists.txt 
b/External/SPEC/CFP2006/450.soplex/CMakeLists.txt
index f572c6bf..ffd415a5 100644
--- a/External/SPEC/CFP2006/450.soplex/CMakeLists.txt
+++ b/External/SPEC/CFP2006/450.soplex/CMakeLists.txt
@@ -1,4 +1,5 @@
 list(APPEND LDFLAGS -lm)
+list(APPEND CXXFLAGS -std=gnu++98)
 
 macro(test_input run_type input outname stdout_reltol info_reltol)
   llvm_test_run(RUN_TYPE ${run_type}
diff --git a/External/SPEC/CFP2006/450.soplex/Makefile 
b/External/SPEC/CFP2006/450.soplex/Makefile
index dcb457d4..b7de08ec 100644
--- a/External/SPEC/CFP2006/450.soplex/Makefile
+++ b/External/SPEC/CFP2006/450.soplex/Makefile
@@ -9,6 +9,7 @@ LEVEL = ../../../..
 FP_ABSTOLERANCE = 1.0e-5
 
 CPPFLAGS += -DNDEBUG
+CXXFLAGS += -std=gnu++98
 
 LDFLAGS = -lstdc++ -lm
 LIBS= -lstdc++ -lm
diff --git a/External/SPEC/CINT2006/483.xalancbmk/CMakeLists.txt 
b/External/SPEC/CINT2006/483.xalancbmk/CMakeLists.txt
index caf5ab8c..712cefbd 100644
--- a/External/SPEC/CINT2006/483.xalancbmk/CMakeLists.txt
+++ b/External/SPEC/CINT2006/483.xalancbmk/CMakeLists.txt
@@ -11,6 +11,9 @@ add_definitions(
   -DXML_USE_NATIVE_TRANSCODER
   -DXML_USE_INMEM_MESSAGELOADER
 )
+
+list(APPEND CXXFLAGS -std=gnu++98)
+
 include_directories(
   ${CMAKE_CURRENT_SOURCE_DIR}
   ${BENCHMARK_DIR}/src
diff --git a/External/SPEC/CINT2006/483.xalancbmk/Makefile 
b/External/SPEC/CINT2006/483.xalancbmk/Makefile
index 780ea3cf..2e366415 100644
--- a/External/SPEC/CINT2006/483.xalancbmk/Makefile
+++ b/External/SPEC/CINT2006/483.xalancbmk/Makefile
@@ -20,6 +20,8 @@ CPPFLAGS += -DNDEBUG -DAPP_NO_THREADS 
-DXALAN_INMEM_MSG_LOADER\
 -I$(SPEC_BENCH_DIR)/src/xercesc/util/Transcoders/Iconv\
 -I$(SPEC_BENCH_DIR)/src/xalanc/include
 
+CXXFLAGS += -std=gnu++98
+
 ifeq ($(TARGET_OS),Darwin)
   CPPFLAGS += -DSPEC_CPU_MACOSX
 endif
diff --git a/MultiSource/Benchmarks/7zip/CMakeLists.txt 
b/MultiSource/Benchmarks/7zip/CMakeLists.txt
index ee0a9ff9..9cba36f9 100644
--- a/MultiSource/Benchmarks/7zip/CMakeLists.txt
+++ b/MultiSource/Benchmarks/7zip/CMakeLists.txt
@@ -1,7 +1,7 @@
 set(PROG 7zip-benchmark)
 set(RUN_OPTIONS b)
 list(APPEND CFLAGS -DBREAK_HANDLER -DUNICODE -D_UNICODE 
-I${CMAKE_CURRENT_SOURCE_DIR}/C -I${CMAKE_CURRENT_SOURCE_DIR}/CPP/myWindows 
-I${CMAKE_CURRENT_SOURCE_DIR}/CPP/include_windows 
-I${CMAKE_CURRENT_SOURCE_DIR}/CPP -I. -D_FILE_OFFSET_BITS=64 
-D_LARGEFILE_SOURCE -DNDEBUG -D_REENTRANT -DENV_UNIX -D_7ZIP_LARGE_PAGES 
-pthread)
-list(APPEND CXXFLAGS -DBREAK_HANDLER -DUNICODE -D_UNICODE 
-I${CMAKE_CURRENT_SOURCE_DIR}/C -I${CMAKE_CURRENT_SOURCE_DIR}/CPP/myWindows 
-I${CMAKE_CURRENT_SOURCE_DIR}/CPP/include_windows 
-I${CMAKE_CURRENT_SOURCE_DIR}/CPP -I. -D_FILE_OFFSET_BITS=64 
-D_LARGEFILE_SOURCE -DNDEBUG -D_REENTRANT -DENV_UNIX -D_7ZIP_LARGE_PAGES 
-pthread)
+list(APPEND CXXFLAGS -Wno-error=c++11-narrowing -DBREAK_HANDLER -DUNICODE 
-D_UNICODE -I${CMAKE_CURRENT_SOURCE_DIR}/C 
-I${CMAKE_CURRENT_SOURCE_DIR}/CPP/myWindows 
-I${CMAKE_CURRENT_SOURCE_DIR}/CPP/include_windows 
-I${CMAKE_CURRENT_SOURCE_DIR}/CPP -I. -D_FILE_OFFSET_BITS=64 
-D_LARGEFILE_SOURCE -DNDEBUG -D_REENTRANT -DENV_UNIX -D_7ZIP_LARGE_PAGES 
-pthread)
 list(APPEND LDFLAGS -lstdc++ -pthread)
 set(Source CPP/myWindows/myGetTickCount.cpp 
CPP/myWindows/wine_date_and_time.cpp CPP/myWindows/myAddExeFlag.cpp 
CPP/myWindows/mySplitCommandLine.cpp CPP/7zip/UI/Console/BenchCon.cpp 
CPP/7zip/UI/Console/ConsoleClose.cpp 
CPP/7zip/UI/Console/ExtractCallbackConsole.cpp CPP/7zip/UI/Console/List.cpp 
CPP/7zip/UI/Console/Main.cpp CPP/7zip/UI/Console/MainAr.cpp 
CPP/7zip/UI/Console/OpenCallbackConsole.cpp 

Re: r311137 - GlobalISel (AArch64): fix ABI at border between GPRs and SP.

2017-08-17 Thread Tim Northover via cfe-commits
On 17 August 2017 at 16:14, Tim Northover via cfe-commits
<cfe-commits@lists.llvm.org> wrote:
> Author: tnorthover
> Date: Thu Aug 17 16:14:01 2017
> New Revision: 311137
>
> URL: http://llvm.org/viewvc/llvm-project?rev=311137=rev
> Log:
> GlobalISel (AArch64): fix ABI at border between GPRs and SP.

Oops. Reverted in r311140. It went along with my GlobalISel fix accidentally.

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


r311140 - Revert r311137 (GlobalISel ABI commit).

2017-08-17 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Thu Aug 17 17:33:24 2017
New Revision: 311140

URL: http://llvm.org/viewvc/llvm-project?rev=311140=rev
Log:
Revert r311137 (GlobalISel ABI commit).

It was committed by mistake since it was in the same monorepo as the
LLVM change I was working on.

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=311140=311139=311140=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Thu Aug 17 17:33:24 2017
@@ -438,7 +438,7 @@ void arm::getARMTargetFeatures(const Too
 //
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
-if (Triple.isOSBinFormatMachO() || Triple.isOSNetBSD()) {
+if (Triple.isOSDarwin() || Triple.isOSNetBSD()) {
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");


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


r311137 - GlobalISel (AArch64): fix ABI at border between GPRs and SP.

2017-08-17 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Thu Aug 17 16:14:01 2017
New Revision: 311137

URL: http://llvm.org/viewvc/llvm-project?rev=311137=rev
Log:
GlobalISel (AArch64): fix ABI at border between GPRs and SP.

If a struct would end up half in GPRs and half on SP the ABI says it should
actually go entirely on the stack. We were getting this wrong in GlobalISel
before, causing compatibility issues.

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=311137=311136=311137=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Thu Aug 17 16:14:01 2017
@@ -438,7 +438,7 @@ void arm::getARMTargetFeatures(const Too
 //
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
-if (Triple.isOSDarwin() || Triple.isOSNetBSD()) {
+if (Triple.isOSBinFormatMachO() || Triple.isOSNetBSD()) {
   if (VersionNum < 6 ||
   Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");


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


r310478 - Reapply Sema: allow imaginary constants via GNU extension if UDL overloads not present.

2017-08-09 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed Aug  9 07:56:48 2017
New Revision: 310478

URL: http://llvm.org/viewvc/llvm-project?rev=310478=rev
Log:
Reapply Sema: allow imaginary constants via GNU extension if UDL overloads not 
present.

C++14 added user-defined literal support for complex numbers so that you
can write something like "complex val = 2i". However, there is
an existing GNU extension supporting this syntax and interpreting the
result as a _Complex type.

This changes parsing so that such literals are interpreted in terms of
C++14's operators if an overload is present but otherwise falls back to
the original GNU extension.

(We now have more robust diagnostics for implicit conversions so the
libc++ test that caused the original revert still passes).

Added:
cfe/trunk/test/SemaCXX/imaginary-constants.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=310478=310477=310478=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Wed Aug  9 07:56:48 2017
@@ -173,8 +173,6 @@ def warn_char_constant_too_large : Warni
 def err_multichar_utf_character_literal : Error<
   "Unicode character literals may not contain multiple characters">;
 def err_exponent_has_no_digits : Error<"exponent has no digits">;
-def ext_imaginary_constant : Extension<
-  "imaginary constants are a GNU extension">, InGroup;
 def err_hex_constant_requires : Error<
   "hexadecimal floating %select{constant|literal}0 requires "
   "%select{an exponent|a significand}1">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=310478=310477=310478=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Aug  9 07:56:48 
2017
@@ -194,6 +194,8 @@ def warn_duplicate_declspec : Warning<"d
   InGroup;
 def ext_plain_complex : ExtWarn<
   "plain '_Complex' requires a type specifier; assuming '_Complex double'">;
+def ext_imaginary_constant : Extension<
+  "imaginary constants are a GNU extension">, InGroup;
 def ext_integer_complex : Extension<
   "complex integer types are a GNU extension">, InGroup;
 

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=310478=310477=310478=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Aug  9 07:56:48 2017
@@ -3020,6 +3020,8 @@ public:
   enum LiteralOperatorLookupResult {
 /// \brief The lookup resulted in an error.
 LOLR_Error,
+/// \brief The lookup found no match but no diagnostic was issued.
+LOLR_ErrorNoDiagnostic,
 /// \brief The lookup found a single 'cooked' literal operator, which
 /// expects a normal literal to be built and passed to it.
 LOLR_Cooked,
@@ -3144,7 +3146,8 @@ public:
 ArrayRef ArgTys,
 bool AllowRaw,
 bool AllowTemplate,
-bool AllowStringTemplate);
+bool AllowStringTemplate,
+bool DiagnoseMissing);
   bool isKnownName(StringRef name);
 
   void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc,

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=310478=310477=310478=diff
==
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Wed Aug  9 07:56:48 2017
@@ -658,9 +658,6 @@ NumericLiteralParser::NumericLiteralPars
   break;
 }
   }
-  // "i", "if", and "il" are user-defined suffixes in C++1y.
-  if (*s == 'i' && PP.getLangOpts().CPlusPlus14)
-break;
   // fall through.
 case 'j':
 case 'J':
@@ -672,35 +669,34 @@ NumericLiteralParser::NumericLiteralPars
 break;
   }
 
-  if (s != ThisTokEnd) {
+  // "i", "if", and "il" are user-defined suffixes in C++1y.
+  if (s != ThisTokEnd || isImaginary) {
 // FIXME: 

r310426 - Revert "Lexer: always allow imaginary constants in GNU mode."

2017-08-08 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Tue Aug  8 16:17:51 2017
New Revision: 310426

URL: http://llvm.org/viewvc/llvm-project?rev=310426=rev
Log:
Revert "Lexer: always allow imaginary constants in GNU mode."

This reverts r310423. It was committed by mistake, I intended to commit the
improved diagnostics for implicit conversions instead.

Removed:
cfe/trunk/test/Lexer/imaginary-constants.cpp
Modified:
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/test/SemaCXX/constexpr-printing.cpp
cfe/trunk/unittests/AST/DeclTest.cpp

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=310426=310425=310426=diff
==
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Tue Aug  8 16:17:51 2017
@@ -659,7 +659,7 @@ NumericLiteralParser::NumericLiteralPars
 }
   }
   // "i", "if", and "il" are user-defined suffixes in C++1y.
-  if (*s == 'i' && !PP.getLangOpts().GNUMode)
+  if (*s == 'i' && PP.getLangOpts().CPlusPlus14)
 break;
   // fall through.
 case 'j':

Removed: cfe/trunk/test/Lexer/imaginary-constants.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/imaginary-constants.cpp?rev=310425=auto
==
--- cfe/trunk/test/Lexer/imaginary-constants.cpp (original)
+++ cfe/trunk/test/Lexer/imaginary-constants.cpp (removed)
@@ -1,25 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=gnu++98 -DHAVE_IMAGINARY=1
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=gnu++11 -DHAVE_IMAGINARY=1
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=gnu++14 -DHAVE_IMAGINARY=1
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -DHAVE_IMAGINARY=0
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -DHAVE_IMAGINARY=0
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 -DHAVE_IMAGINARY=0 
-DCXX14=1
-
-// Imaginary constants are a GNU extension that became problematic when C++14
-// defined its own versions. Until then they're supported even in
-// standards-compliant mode.
-#if HAVE_IMAGINARY
-// expected-no-diagnostics
-#elif CXX14
-// expected-error@+9 {{no matching literal operator for call to 'operator""i' 
with argument of type 'unsigned long long' or 'const char *', and no matching 
literal operator template}}
-// expected-error@+9 {{no matching literal operator for call to 'operator""il' 
with argument of type 'unsigned long long' or 'const char *', and no matching 
literal operator template}}
-// expected-error@+9 {{invalid suffix 'ill' on integer constant}}
-#else
-// expected-error@+5 {{invalid suffix 'i' on integer constant}}
-// expected-error@+5 {{invalid suffix 'il' on integer constant}}
-// expected-error@+7 {{invalid suffix 'ill' on integer constant}}
-#endif
-
-_Complex int val1 = 2i;
-_Complex long val2 = 2il;
-_Complex long long val3 = 2ill;

Modified: cfe/trunk/test/SemaCXX/constexpr-printing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constexpr-printing.cpp?rev=310426=310425=310426=diff
==
--- cfe/trunk/test/SemaCXX/constexpr-printing.cpp (original)
+++ cfe/trunk/test/SemaCXX/constexpr-printing.cpp Tue Aug  8 16:17:51 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -std=gnu++11 -fsyntax-only -verify -triple 
x86_64-linux-gnu
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -triple x86_64-linux-gnu
 
 struct S;
 constexpr int extract(const S );

Modified: cfe/trunk/unittests/AST/DeclTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/DeclTest.cpp?rev=310426=310425=310426=diff
==
--- cfe/trunk/unittests/AST/DeclTest.cpp (original)
+++ cfe/trunk/unittests/AST/DeclTest.cpp Tue Aug  8 16:17:51 2017
@@ -26,7 +26,7 @@ TEST(Decl, CleansUpAPValues) {
   // This is a regression test for a memory leak in APValues for structs that
   // allocate memory. This test only fails if run under valgrind with full leak
   // checking enabled.
-  std::vector Args(1, "-std=gnu++11");
+  std::vector Args(1, "-std=c++11");
   Args.push_back("-fno-ms-extensions");
   ASSERT_TRUE(runToolOnCodeWithArgs(
   Factory->create(),


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


r310427 - Sema: disable implicit conversion from _Complex to real types in C++.

2017-08-08 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Tue Aug  8 16:18:05 2017
New Revision: 310427

URL: http://llvm.org/viewvc/llvm-project?rev=310427=rev
Log:
Sema: disable implicit conversion from _Complex to real types in C++.

Converting a _Complex type to a real one simply discards the imaginary part.
This can easily lead to loss of information so for safety (and GCC
compatibility) this patch disallows that when the conversion would be implicit.

The one exception is bool, which actually compares both real and imaginary
parts and so is safe.

Added:
cfe/trunk/test/SemaCXX/complex-conversion.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGenCXX/stmtexpr.cpp
cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp
cfe/trunk/test/OpenMP/atomic_update_codegen.cpp
cfe/trunk/test/SemaCXX/complex-overload.cpp
cfe/trunk/test/SemaCXX/integer-overflow.cpp
cfe/trunk/test/SemaCXX/warn-absolute-value.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=310427=310426=310427=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Aug  8 16:18:05 
2017
@@ -3087,6 +3087,8 @@ def warn_impcast_vector_scalar : Warning
 def warn_impcast_complex_scalar : Warning<
   "implicit conversion discards imaginary component: %0 to %1">,
   InGroup, DefaultIgnore;
+def err_impcast_complex_scalar : Error<
+  "implicit conversion from %0 to %1 is not permitted in C++">;
 def warn_impcast_float_precision : Warning<
   "implicit conversion loses floating-point precision: %0 to %1">,
   InGroup, DefaultIgnore;

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=310427=310426=310427=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Aug  8 16:18:05 2017
@@ -9431,10 +9431,13 @@ void CheckImplicitConversion(Sema , Ex
   // Strip complex types.
   if (isa(Source)) {
 if (!isa(Target)) {
-  if (S.SourceMgr.isInSystemMacro(CC))
+  if (S.SourceMgr.isInSystemMacro(CC) || Target->isBooleanType())
 return;
 
-  return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_complex_scalar);
+  return DiagnoseImpCast(S, E, T, CC,
+ S.getLangOpts().CPlusPlus
+ ? diag::err_impcast_complex_scalar
+ : diag::warn_impcast_complex_scalar);
 }
 
 Source = cast(Source)->getElementType().getTypePtr();

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=310427=310426=310427=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug  8 16:18:05 2017
@@ -7530,6 +7530,12 @@ Sema::CheckAssignmentConstraints(QualTyp
   if (unsupportedTypeConversion(*this, LHSType, RHSType))
 return Incompatible;
 
+  // Disallow assigning a _Complex to a real type in C++ mode since it simply
+  // discards the imaginary part.
+  if (getLangOpts().CPlusPlus && RHSType->getAs() &&
+  !LHSType->getAs())
+return Incompatible;
+
   // Arithmetic conversions.
   if (LHSType->isArithmeticType() && RHSType->isArithmeticType() &&
   !(getLangOpts().CPlusPlus && LHSType->isEnumeralType())) {

Modified: cfe/trunk/test/CodeGenCXX/stmtexpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/stmtexpr.cpp?rev=310427=310426=310427=diff
==
--- cfe/trunk/test/CodeGenCXX/stmtexpr.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/stmtexpr.cpp Tue Aug  8 16:18:05 2017
@@ -173,7 +173,7 @@ extern "C" int cleanup_exit_lvalue_local
 _Complex float bar_complex(A, int);
 extern "C" int cleanup_exit_complex(bool b) {
   _Complex float v = bar_complex(A(1), ({ if (b) return 42; 13; }));
-  return v;
+  return (float)v;
 }
 
 // CHECK-LABEL: define{{.*}} i32 @cleanup_exit_complex({{.*}})

Modified: cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp?rev=310427=310426=310427=diff
==
--- cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp Tue Aug  8 16:18:05 2017
@@ -611,50 +611,6 @@ int main() {
 // CHECK: store i8 [[DESIRED_I8]], i8* @{{.+}},
 #pragma omp atomic capture
   {bx = civ - bx; bv = bx;}
-// CHECK: 

r310423 - Lexer: always allow imaginary constants in GNU mode.

2017-08-08 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Tue Aug  8 15:03:54 2017
New Revision: 310423

URL: http://llvm.org/viewvc/llvm-project?rev=310423=rev
Log:
Lexer: always allow imaginary constants in GNU mode.

Added:
cfe/trunk/test/Lexer/imaginary-constants.cpp
Modified:
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/test/SemaCXX/constexpr-printing.cpp
cfe/trunk/unittests/AST/DeclTest.cpp

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=310423=310422=310423=diff
==
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Tue Aug  8 15:03:54 2017
@@ -659,7 +659,7 @@ NumericLiteralParser::NumericLiteralPars
 }
   }
   // "i", "if", and "il" are user-defined suffixes in C++1y.
-  if (*s == 'i' && PP.getLangOpts().CPlusPlus14)
+  if (*s == 'i' && !PP.getLangOpts().GNUMode)
 break;
   // fall through.
 case 'j':

Added: cfe/trunk/test/Lexer/imaginary-constants.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/imaginary-constants.cpp?rev=310423=auto
==
--- cfe/trunk/test/Lexer/imaginary-constants.cpp (added)
+++ cfe/trunk/test/Lexer/imaginary-constants.cpp Tue Aug  8 15:03:54 2017
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=gnu++98 -DHAVE_IMAGINARY=1
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=gnu++11 -DHAVE_IMAGINARY=1
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=gnu++14 -DHAVE_IMAGINARY=1
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -DHAVE_IMAGINARY=0
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -DHAVE_IMAGINARY=0
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 -DHAVE_IMAGINARY=0 
-DCXX14=1
+
+// Imaginary constants are a GNU extension that became problematic when C++14
+// defined its own versions. Until then they're supported even in
+// standards-compliant mode.
+#if HAVE_IMAGINARY
+// expected-no-diagnostics
+#elif CXX14
+// expected-error@+9 {{no matching literal operator for call to 'operator""i' 
with argument of type 'unsigned long long' or 'const char *', and no matching 
literal operator template}}
+// expected-error@+9 {{no matching literal operator for call to 'operator""il' 
with argument of type 'unsigned long long' or 'const char *', and no matching 
literal operator template}}
+// expected-error@+9 {{invalid suffix 'ill' on integer constant}}
+#else
+// expected-error@+5 {{invalid suffix 'i' on integer constant}}
+// expected-error@+5 {{invalid suffix 'il' on integer constant}}
+// expected-error@+7 {{invalid suffix 'ill' on integer constant}}
+#endif
+
+_Complex int val1 = 2i;
+_Complex long val2 = 2il;
+_Complex long long val3 = 2ill;

Modified: cfe/trunk/test/SemaCXX/constexpr-printing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constexpr-printing.cpp?rev=310423=310422=310423=diff
==
--- cfe/trunk/test/SemaCXX/constexpr-printing.cpp (original)
+++ cfe/trunk/test/SemaCXX/constexpr-printing.cpp Tue Aug  8 15:03:54 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -triple x86_64-linux-gnu
+// RUN: %clang_cc1 %s -std=gnu++11 -fsyntax-only -verify -triple 
x86_64-linux-gnu
 
 struct S;
 constexpr int extract(const S );

Modified: cfe/trunk/unittests/AST/DeclTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/DeclTest.cpp?rev=310423=310422=310423=diff
==
--- cfe/trunk/unittests/AST/DeclTest.cpp (original)
+++ cfe/trunk/unittests/AST/DeclTest.cpp Tue Aug  8 15:03:54 2017
@@ -26,7 +26,7 @@ TEST(Decl, CleansUpAPValues) {
   // This is a regression test for a memory leak in APValues for structs that
   // allocate memory. This test only fails if run under valgrind with full leak
   // checking enabled.
-  std::vector Args(1, "-std=c++11");
+  std::vector Args(1, "-std=gnu++11");
   Args.push_back("-fno-ms-extensions");
   ASSERT_TRUE(runToolOnCodeWithArgs(
   Factory->create(),


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


r308898 - AArch64 & ARM: move TargetInfo functions from .h to .cpp file. NFC.

2017-07-24 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Mon Jul 24 10:06:23 2017
New Revision: 308898

URL: http://llvm.org/viewvc/llvm-project?rev=308898=rev
Log:
AArch64 & ARM: move TargetInfo functions from .h to .cpp file. NFC.

Most of them are virtual anyway, and the few remaining ones can move to the
.cpp for consistency.

Modified:
cfe/trunk/lib/Basic/Targets/AArch64.cpp
cfe/trunk/lib/Basic/Targets/AArch64.h
cfe/trunk/lib/Basic/Targets/ARM.cpp
cfe/trunk/lib/Basic/Targets/ARM.h

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=308898=308897=308898=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Mon Jul 24 10:06:23 2017
@@ -19,6 +19,245 @@
 using namespace clang;
 using namespace clang::targets;
 
+const Builtin::Info AArch64TargetInfo::BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS)   
\
+   {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#include "clang/Basic/BuiltinsNEON.def"
+
+#define BUILTIN(ID, TYPE, ATTRS)   
\
+   {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#include "clang/Basic/BuiltinsAArch64.def"
+};
+
+AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple ,
+ const TargetOptions )
+: TargetInfo(Triple), ABI("aapcs") {
+  if (getTriple().getOS() == llvm::Triple::NetBSD ||
+  getTriple().getOS() == llvm::Triple::OpenBSD) {
+WCharType = SignedInt;
+
+// NetBSD apparently prefers consistency across ARM targets to
+// consistency across 64-bit targets.
+Int64Type = SignedLongLong;
+IntMaxType = SignedLongLong;
+  } else {
+WCharType = UnsignedInt;
+Int64Type = SignedLong;
+IntMaxType = SignedLong;
+  }
+
+  LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
+  MaxVectorAlign = 128;
+  MaxAtomicInlineWidth = 128;
+  MaxAtomicPromoteWidth = 128;
+
+  LongDoubleWidth = LongDoubleAlign = SuitableAlign = 128;
+  LongDoubleFormat = ::APFloat::IEEEquad();
+
+  // Make __builtin_ms_va_list available.
+  HasBuiltinMSVaList = true;
+
+  // {} in inline assembly are neon specifiers, not assembly variant
+  // specifiers.
+  NoAsmVariants = true;
+
+  // AAPCS gives rules for bitfields. 7.1.7 says: "The container type
+  // contributes to the alignment of the containing aggregate in the same way
+  // a plain (non bit-field) member of that type would, without exception for
+  // zero-sized or anonymous bit-fields."
+  assert(UseBitFieldTypeAlignment && "bitfields affect type alignment");
+  UseZeroLengthBitfieldAlignment = true;
+
+  // AArch64 targets default to using the ARM C++ ABI.
+  TheCXXABI.set(TargetCXXABI::GenericAArch64);
+
+  if (Triple.getOS() == llvm::Triple::Linux)
+this->MCountName = "\01_mcount";
+  else if (Triple.getOS() == llvm::Triple::UnknownOS)
+this->MCountName =
+Opts.EABIVersion == llvm::EABI::GNU ? "\01_mcount" : "mcount";
+}
+
+StringRef AArch64TargetInfo::getABI() const { return ABI; }
+
+bool AArch64TargetInfo::setABI(const std::string ) {
+  if (Name != "aapcs" && Name != "darwinpcs")
+return false;
+
+  ABI = Name;
+  return true;
+}
+
+bool AArch64TargetInfo::isValidCPUName(StringRef Name) const {
+  return Name == "generic" ||
+ llvm::AArch64::parseCPUArch(Name) !=
+ static_cast(llvm::AArch64::ArchKind::AK_INVALID);
+}
+
+bool AArch64TargetInfo::setCPU(const std::string ) {
+  return isValidCPUName(Name);
+}
+
+void AArch64TargetInfo::getTargetDefinesARMV81A(const LangOptions ,
+MacroBuilder ) const {
+  Builder.defineMacro("__ARM_FEATURE_QRDMX", "1");
+}
+
+void AArch64TargetInfo::getTargetDefinesARMV82A(const LangOptions ,
+MacroBuilder ) const {
+  // Also include the ARMv8.1 defines
+  getTargetDefinesARMV81A(Opts, Builder);
+}
+
+void AArch64TargetInfo::getTargetDefines(const LangOptions ,
+ MacroBuilder ) const {
+  // Target identification.
+  Builder.defineMacro("__aarch64__");
+  // For bare-metal none-eabi.
+  if (getTriple().getOS() == llvm::Triple::UnknownOS &&
+  (getTriple().getEnvironment() == llvm::Triple::EABI ||
+   getTriple().getEnvironment() == llvm::Triple::EABIHF))
+Builder.defineMacro("__ELF__");
+
+  // Target properties.
+  Builder.defineMacro("_LP64");
+  Builder.defineMacro("__LP64__");
+
+  // ACLE predefines. Many can only have one possible value on v8 AArch64.
+  Builder.defineMacro("__ARM_ACLE", "200");
+  Builder.defineMacro("__ARM_ARCH", "8");
+  Builder.defineMacro("__ARM_ARCH_PROFILE", "'A'");
+
+  Builder.defineMacro("__ARM_64BIT_STATE", "1");
+  Builder.defineMacro("__ARM_PCS_AAPCS64", "1");
+  Builder.defineMacro("__ARM_ARCH_ISA_A64", "1");
+
+  

Re: [PATCH] D33424: Lexer: allow imaginary constants in GNU mode (only).

2017-06-01 Thread Tim Northover via cfe-commits
On 26 May 2017 at 11:29, Richard Smith  wrote:
> If we generally think that distinction is a good thing, then (because this
> is a conforming extension) consistency weakly suggests that it should not be
> controlled by GNU mode. But I don't find that argument decisive; the
> important thing is that we don't enable non-conforming extensions by default
> in non-GNU (and non-MS-compat) modes, not that GNU mode consists of /only/
> non-conforming extensions.

I'm pretty convinced by the conforming/non-conforming distinction and
consistency argument. And think that the Microsoft way seems even
better for the future.

Making the libc++ test pass is pretty ugly, but I've managed to get it
working by building with "-Werror=gnu-imaginary-constant".

Marshall, I know this really isn't your preferred solution but can you
stomach it if I also make sure we do the extra diagnostics so it's
difficult to misuse?

> Looking at the
>
>   std::complex x = 1.0if;
>
> case again, I think there's another problem here: we support an implicit
> conversion from _Complex float to float in C++ (without even a warning).
> This conversion is valid in C, but at least GCC disallows it in its C++
> mode. We should probably at least warn on that.

Definitely. I think the error from G++ is probably the right choice.
I'll get cracking on that, it's a good idea regardless of what happens
here.

Cheers.

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


Re: [PATCH] D33424: Lexer: allow imaginary constants in GNU mode (only).

2017-05-26 Thread Tim Northover via cfe-commits
On 24 May 2017 at 17:54, Richard Smith  wrote:
> Yikes :-( Maybe libc++ *should* have that extension then. It sounds like
> we'll silently get the wrong value for any attempt at std::complex /
> _Complex interop right now:

That sounds like a pretty good idea whatever we decide to do about the literals.

But we do need to sort out what we're going to do here. I quite like
the approach you suggested, and think it's an improvement worth
putting in for gnu++ modes regardless.

So the remaining question is what we should do for the
standards-compliant C++ modes. We seem to have 3 plausible options:

1. Bar it everywhere. It's an extension.
2. Bar it for C++14 onwards, where the standard provides literals.
3. Allow it everywhere.

Although 2 would be the most conservative option (it maintains all
existing behaviour), it's my least favourite for the added complexity
and quirkiness.

My original inclination is to go with Marshall and pick 1, but it's a
very weak preference and I know I tend to be a bit user-hostile in
these situations.

So, how do we resolve this. Does anyone else have opinions?

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


r303957 - Create valid LValue to represent null pointers in constant exprs

2017-05-25 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Thu May 25 21:16:00 2017
New Revision: 303957

URL: http://llvm.org/viewvc/llvm-project?rev=303957=rev
Log:
Create valid LValue to represent null pointers in constant exprs

We were leaving the SubobjectDesignator in a surprising situation, where
it was allegedly valid but didn't actually refer to a type. This caused
a crash later on.

This patch fills out the SubobjectDesignator with the pointee type (as
happens in other evaluations of constant pointers) so that we don't
crash later.

Added:
cfe/trunk/test/SemaCXX/null-cast.cpp
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=303957=303956=303957=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu May 25 21:16:00 2017
@@ -1230,8 +1230,7 @@ namespace {
   IsNullPtr = V.isNullPointer();
 }
 
-void set(APValue::LValueBase B, unsigned I = 0, bool BInvalid = false,
- bool IsNullPtr_ = false, uint64_t Offset_ = 0) {
+void set(APValue::LValueBase B, unsigned I = 0, bool BInvalid = false) {
 #ifndef NDEBUG
   // We only allow a few types of invalid bases. Enforce that here.
   if (BInvalid) {
@@ -1242,11 +1241,20 @@ namespace {
 #endif
 
   Base = B;
-  Offset = CharUnits::fromQuantity(Offset_);
+  Offset = CharUnits::fromQuantity(0);
   InvalidBase = BInvalid;
   CallIndex = I;
   Designator = SubobjectDesignator(getType(B));
-  IsNullPtr = IsNullPtr_;
+  IsNullPtr = false;
+}
+
+void setNull(QualType PointerTy, uint64_t TargetVal) {
+  Base = (Expr *)nullptr;
+  Offset = CharUnits::fromQuantity(TargetVal);
+  InvalidBase = false;
+  CallIndex = 0;
+  Designator = SubobjectDesignator(PointerTy->getPointeeType());
+  IsNullPtr = true;
 }
 
 void setInvalid(APValue::LValueBase B, unsigned I = 0) {
@@ -5494,8 +5502,8 @@ public:
 return true;
   }
   bool ZeroInitialization(const Expr *E) {
-auto Offset = Info.Ctx.getTargetNullPointerValue(E->getType());
-Result.set((Expr*)nullptr, 0, false, true, Offset);
+auto TargetVal = Info.Ctx.getTargetNullPointerValue(E->getType());
+Result.setNull(E->getType(), TargetVal);
 return true;
   }
 

Added: cfe/trunk/test/SemaCXX/null-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/null-cast.cpp?rev=303957=auto
==
--- cfe/trunk/test/SemaCXX/null-cast.cpp (added)
+++ cfe/trunk/test/SemaCXX/null-cast.cpp Thu May 25 21:16:00 2017
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {};
+struct B : virtual A {};
+
+void foo() {
+  (void)static_cast(*(B *)0); // expected-warning {{binding dereferenced 
null pointer to reference has undefined behavior}}
+}


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


Re: [PATCH] D33424: Lexer: allow imaginary constants in GNU mode (only).

2017-05-24 Thread Tim Northover via cfe-commits
On 24 May 2017 at 15:32, Marshall Clow via Phabricator
 wrote:
> More. Trying the above code on godbolt.org, gcc 6.1/6.2/6.3/7.1 all reject it 
> (with `-std=c++14` and `-std=c++1z`) with the error message:

This was a pretty explicit intent in Richard's proposal: treat
incoming code as charitably as possible, maybe dial it back if it
turns out we need more GCC compatibility for some reason.

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


Re: [PATCH] D33424: Lexer: allow imaginary constants in GNU mode (only).

2017-05-24 Thread Tim Northover via cfe-commits
On 24 May 2017 at 15:06, Richard Smith  wrote:
> I think this is expected. Clang has an extension where it treats 1.0if as a
> _Complex float if no operator""if is available;

Since it's breaking some bots, I've reverted my commit while we hash
this out. r303813.

> libc++ has an extension
> where std::complex can be initialized from _Complex float. For the
> same reason, that code has historically worked in C++11 and C++98 modes.

Are you sure? It looks like it does an implicit cast to float
(discarding the imaginary part) and then calls the "complex(float,
float = 0.0)" constructor to me.

Cheers.

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


r303813 - Revert "Sema: allow imaginary constants via GNU extension if UDL overloads not present."

2017-05-24 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed May 24 17:18:35 2017
New Revision: 303813

URL: http://llvm.org/viewvc/llvm-project?rev=303813=rev
Log:
Revert "Sema: allow imaginary constants via GNU extension if UDL overloads not 
present."

This reverts commit r303697. It broke libc++ tests that were specifically
checking incompatibility in C++14 mode.

Removed:
cfe/trunk/test/SemaCXX/imaginary-constants.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=303813=303812=303813=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Wed May 24 17:18:35 2017
@@ -173,6 +173,8 @@ def warn_char_constant_too_large : Warni
 def err_multichar_utf_character_literal : Error<
   "Unicode character literals may not contain multiple characters">;
 def err_exponent_has_no_digits : Error<"exponent has no digits">;
+def ext_imaginary_constant : Extension<
+  "imaginary constants are a GNU extension">, InGroup;
 def err_hex_constant_requires : Error<
   "hexadecimal floating %select{constant|literal}0 requires "
   "%select{an exponent|a significand}1">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=303813=303812=303813=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed May 24 17:18:35 
2017
@@ -194,8 +194,6 @@ def warn_duplicate_declspec : Warning<"d
   InGroup;
 def ext_plain_complex : ExtWarn<
   "plain '_Complex' requires a type specifier; assuming '_Complex double'">;
-def ext_imaginary_constant : Extension<
-  "imaginary constants are a GNU extension">, InGroup;
 def ext_integer_complex : Extension<
   "complex integer types are a GNU extension">, InGroup;
 

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=303813=303812=303813=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed May 24 17:18:35 2017
@@ -2946,8 +2946,6 @@ public:
   enum LiteralOperatorLookupResult {
 /// \brief The lookup resulted in an error.
 LOLR_Error,
-/// \brief The lookup found no match but no diagnostic was issued.
-LOLR_ErrorNoDiagnostic,
 /// \brief The lookup found a single 'cooked' literal operator, which
 /// expects a normal literal to be built and passed to it.
 LOLR_Cooked,
@@ -3072,8 +3070,7 @@ public:
 ArrayRef ArgTys,
 bool AllowRaw,
 bool AllowTemplate,
-bool AllowStringTemplate,
-bool DiagnoseMissing);
+bool AllowStringTemplate);
   bool isKnownName(StringRef name);
 
   void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc,

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=303813=303812=303813=diff
==
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Wed May 24 17:18:35 2017
@@ -651,6 +651,9 @@ NumericLiteralParser::NumericLiteralPars
   break;
 }
   }
+  // "i", "if", and "il" are user-defined suffixes in C++1y.
+  if (*s == 'i' && PP.getLangOpts().CPlusPlus14)
+break;
   // fall through.
 case 'j':
 case 'J':
@@ -662,34 +665,35 @@ NumericLiteralParser::NumericLiteralPars
 break;
   }
 
-  // "i", "if", and "il" are user-defined suffixes in C++1y.
-  if (s != ThisTokEnd || isImaginary) {
+  if (s != ThisTokEnd) {
 // FIXME: Don't bother expanding UCNs if !tok.hasUCN().
 expandUCNs(UDSuffixBuf, StringRef(SuffixBegin, ThisTokEnd - SuffixBegin));
 if (isValidUDSuffix(PP.getLangOpts(), UDSuffixBuf)) {
-  if (!isImaginary) {
-// Any suffix pieces we might have parsed are actually part of the
-// ud-suffix.
-isLong = false;
-isUnsigned = false;
-isLongLong = false;
-isFloat = 

r303694 - Sema: allow imaginary constants via GNU extension if UDL overloads not present.

2017-05-23 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Tue May 23 16:41:49 2017
New Revision: 303694

URL: http://llvm.org/viewvc/llvm-project?rev=303694=rev
Log:
Sema: allow imaginary constants via GNU extension if UDL overloads not present.

C++14 added user-defined literal support for complex numbers so that you can
write something like "complex val = 2i". However, there is an existing
GNU extension supporting this syntax and interpreting the result as a _Complex
type.

This changes parsing so that such literals are interpreted in terms of C++14's
operators if an overload is present but otherwise falls back to the original
GNU extension.

Added:
cfe/trunk/test/SemaCXX/imaginary-constants.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=303694=303693=303694=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue May 23 16:41:49 2017
@@ -173,8 +173,6 @@ def warn_char_constant_too_large : Warni
 def err_multichar_utf_character_literal : Error<
   "Unicode character literals may not contain multiple characters">;
 def err_exponent_has_no_digits : Error<"exponent has no digits">;
-def ext_imaginary_constant : Extension<
-  "imaginary constants are a GNU extension">, InGroup;
 def err_hex_constant_requires : Error<
   "hexadecimal floating %select{constant|literal}0 requires "
   "%select{an exponent|a significand}1">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=303694=303693=303694=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 23 16:41:49 
2017
@@ -194,6 +194,8 @@ def warn_duplicate_declspec : Warning<"d
   InGroup;
 def ext_plain_complex : ExtWarn<
   "plain '_Complex' requires a type specifier; assuming '_Complex double'">;
+def ext_imaginary_constant : Extension<
+  "imaginary constants are a GNU extension">, InGroup;
 def ext_integer_complex : Extension<
   "complex integer types are a GNU extension">, InGroup;
 

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=303694=303693=303694=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue May 23 16:41:49 2017
@@ -2946,6 +2946,8 @@ public:
   enum LiteralOperatorLookupResult {
 /// \brief The lookup resulted in an error.
 LOLR_Error,
+/// \brief The lookup found no match but no diagnostic was issued.
+LOLR_ErrorNoDiagnostic,
 /// \brief The lookup found a single 'cooked' literal operator, which
 /// expects a normal literal to be built and passed to it.
 LOLR_Cooked,
@@ -3070,7 +3072,8 @@ public:
 ArrayRef ArgTys,
 bool AllowRaw,
 bool AllowTemplate,
-bool AllowStringTemplate);
+bool AllowStringTemplate,
+bool DiagnoseMissing);
   bool isKnownName(StringRef name);
 
   void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc,

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=303694=303693=303694=diff
==
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Tue May 23 16:41:49 2017
@@ -652,9 +652,6 @@ NumericLiteralParser::NumericLiteralPars
   break;
 }
   }
-  // "i", "if", and "il" are user-defined suffixes in C++1y.
-  if (*s == 'i' && PP.getLangOpts().CPlusPlus14)
-break;
   // fall through.
 case 'j':
 case 'J':
@@ -667,36 +664,34 @@ NumericLiteralParser::NumericLiteralPars
 break;
   }
 
-  if (s != ThisTokEnd) {
+  // "i", "if", and "il" are user-defined suffixes in C++1y.
+  if (s != ThisTokEnd || isImaginary) {
 // FIXME: Don't bother expanding UCNs if !tok.hasUCN().
 expandUCNs(UDSuffixBuf, StringRef(SuffixBegin, ThisTokEnd - SuffixBegin));
 if 

r302313 - AArch64: fix weird edge case in ABI.

2017-05-05 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Fri May  5 17:36:06 2017
New Revision: 302313

URL: http://llvm.org/viewvc/llvm-project?rev=302313=rev
Log:
AArch64: fix weird edge case in ABI.

It turns out there are some sort-of-but-not-quite empty structs that break all
the rules. For example:

struct SuperEmpty { int arr[0]; };
struct SortOfEmpty { struct SuperEmpty e; };

Both of these have sizeof == 0, even in C++ mode, for GCC compatibility. The
first one also doesn't occupy a register when passed by value in GNU C++ mode,
unlike everything else.

On Darwin, we want to ignore the lot (and especially don't want to try to use
an i0 as we were).

Added:
cfe/trunk/test/CodeGen/aarch64-args.cpp
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=302313=302312=302313=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri May  5 17:36:06 2017
@@ -4890,10 +4890,16 @@ ABIArgInfo AArch64ABIInfo::classifyArgum
 
   // Empty records are always ignored on Darwin, but actually passed in C++ 
mode
   // elsewhere for GNU compatibility.
-  if (isEmptyRecord(getContext(), Ty, true)) {
+  uint64_t Size = getContext().getTypeSize(Ty);
+  bool IsEmpty = isEmptyRecord(getContext(), Ty, true);
+  if (IsEmpty || Size == 0) {
 if (!getContext().getLangOpts().CPlusPlus || isDarwinPCS())
   return ABIArgInfo::getIgnore();
 
+// GNU C mode. The only argument that gets ignored is an empty one with 
size
+// 0.
+if (IsEmpty && Size == 0)
+  return ABIArgInfo::getIgnore();
 return ABIArgInfo::getDirect(llvm::Type::getInt8Ty(getVMContext()));
   }
 
@@ -4906,7 +4912,6 @@ ABIArgInfo AArch64ABIInfo::classifyArgum
   }
 
   // Aggregates <= 16 bytes are passed directly in registers or on the stack.
-  uint64_t Size = getContext().getTypeSize(Ty);
   if (Size <= 128) {
 // On RenderScript, coerce Aggregates <= 16 bytes to an integer array of
 // same size and alignment.
@@ -4946,7 +4951,8 @@ ABIArgInfo AArch64ABIInfo::classifyRetur
 : ABIArgInfo::getDirect());
   }
 
-  if (isEmptyRecord(getContext(), RetTy, true))
+  uint64_t Size = getContext().getTypeSize(RetTy);
+  if (isEmptyRecord(getContext(), RetTy, true) || Size == 0)
 return ABIArgInfo::getIgnore();
 
   const Type *Base = nullptr;
@@ -4956,7 +4962,6 @@ ABIArgInfo AArch64ABIInfo::classifyRetur
 return ABIArgInfo::getDirect();
 
   // Aggregates <= 16 bytes are returned directly in registers or on the stack.
-  uint64_t Size = getContext().getTypeSize(RetTy);
   if (Size <= 128) {
 // On RenderScript, coerce Aggregates <= 16 bytes to an integer array of
 // same size and alignment.

Added: cfe/trunk/test/CodeGen/aarch64-args.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-args.cpp?rev=302313=auto
==
--- cfe/trunk/test/CodeGen/aarch64-args.cpp (added)
+++ cfe/trunk/test/CodeGen/aarch64-args.cpp Fri May  5 17:36:06 2017
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios7.0 -target-abi darwinpcs -emit-llvm 
-o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - -x c %s | 
FileCheck %s --check-prefix=CHECK-GNU-C
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck %s 
--check-prefix=CHECK-GNU-CXX
+
+// Empty structs are ignored for PCS purposes on Darwin and in C mode 
elsewhere.
+// In C++ mode on ELF they consume a register slot though. Functions are
+// slightly bigger than minimal to make confirmation against actual GCC
+// behaviour easier.
+
+#if __cplusplus
+#define EXTERNC extern "C"
+#else
+#define EXTERNC
+#endif
+
+struct Empty {};
+
+// CHECK: define i32 @empty_arg(i32 %a)
+// CHECK-GNU-C: define i32 @empty_arg(i32 %a)
+// CHECK-GNU-CXX: define i32 @empty_arg(i8 %e.coerce, i32 %a)
+EXTERNC int empty_arg(struct Empty e, int a) {
+  return a;
+}
+
+// CHECK: define void @empty_ret()
+// CHECK-GNU-C: define void @empty_ret()
+// CHECK-GNU-CXX: define void @empty_ret()
+EXTERNC struct Empty empty_ret() {
+  struct Empty e;
+  return e;
+}
+
+// However, what counts as "empty" is a baroque mess. This is super-empty, it's
+// ignored even in C++ mode. It also has sizeof == 0, violating C++, but that's
+// legacy for you:
+
+struct SuperEmpty {
+  int arr[0];
+};
+
+// CHECK: define i32 @super_empty_arg(i32 %a)
+// CHECK-GNU-C: define i32 @super_empty_arg(i32 %a)
+// CHECK-GNU-CXX: define i32 @super_empty_arg(i32 %a)
+EXTERNC int super_empty_arg(struct SuperEmpty e, int a) {
+  return a;
+}
+
+// This is not empty. It has 0 size but consumes a register slot for GCC.
+
+struct SortOfEmpty {
+  struct SuperEmpty e;
+};
+
+// CHECK: define i32 @sort_of_empty_arg(i32 %a)
+// CHECK-GNU-C: define i32 

r302066 - Tests: strengthen CHECK line to avoid picking up stray path.

2017-05-03 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed May  3 14:20:45 2017
New Revision: 302066

URL: http://llvm.org/viewvc/llvm-project?rev=302066=rev
Log:
Tests: strengthen CHECK line to avoid picking up stray path.

A bot had "-LTO" in its working directory, which matched the regex used in this
test. Since the arg is quoted, we can exploit that instead. Still broken if
there's a path with a quote in, but I think that's pretty niche.

Modified:
cfe/trunk/test/Driver/arch-specific-libdir-rpath.c

Modified: cfe/trunk/test/Driver/arch-specific-libdir-rpath.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arch-specific-libdir-rpath.c?rev=302066=302065=302066=diff
==
--- cfe/trunk/test/Driver/arch-specific-libdir-rpath.c (original)
+++ cfe/trunk/test/Driver/arch-specific-libdir-rpath.c Wed May  3 14:20:45 2017
@@ -81,5 +81,5 @@
 // RPATH-X86_64:"-rpath" 
"[[RESDIR]]{{(/|)lib(/|)linux(/|)x86_64}}"
 // LIBPATH-AArch64: -L[[RESDIR]]{{(/|)lib(/|)linux(/|)aarch64}}
 // RPATH-AArch64:   "-rpath" 
"[[RESDIR]]{{(/|)lib(/|)linux(/|)aarch64}}"
-// NO-LIBPATH-NOT:  -L{{.*Inputs(/|)resource_dir}}
+// NO-LIBPATH-NOT:  "-L{{[^"]*Inputs(/|)resource_dir}}"
 // NO-RPATH-NOT:"-rpath" {{.*(/|)Inputs(/|)resource_dir}}


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


r301585 - libclang: remove unused variable.

2017-04-27 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Thu Apr 27 15:22:40 2017
New Revision: 301585

URL: http://llvm.org/viewvc/llvm-project?rev=301585=rev
Log:
libclang: remove unused variable.

Modified:
cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=301585=301584=301585=diff
==
--- cfe/trunk/tools/libclang/CXCursor.cpp (original)
+++ cfe/trunk/tools/libclang/CXCursor.cpp Thu Apr 27 15:22:40 2017
@@ -1565,8 +1565,7 @@ CXType clang_Cursor_getReceiverType(CXCu
 ME = dyn_cast_or_null(CE->getCallee());
 
   if (ME) {
-if (const CXXMethodDecl *
-  MD = dyn_cast_or_null(ME->getMemberDecl())) {
+if (dyn_cast_or_null(ME->getMemberDecl())) {
   auto receiverTy = ME->getBase()->IgnoreImpCasts()->getType();
   return cxtype::MakeCXType(receiverTy, TU);
 }


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


Re: LLVM Lab SVN mirror is behind

2017-03-15 Thread Tim Northover via cfe-commits
On 15 March 2017 at 10:19, Galina Kistanova via llvm-commits
 wrote:
> I'm looking at that. Hope we will get a solution by the next release time.

Moving to git at last would be ideal, but I wouldn't bet on it either.

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


r293311 - ARM-Darwin: re-enable -momit-leaf-frame-pointer.

2017-01-27 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Fri Jan 27 11:53:42 2017
New Revision: 293311

URL: http://llvm.org/viewvc/llvm-project?rev=293311=rev
Log:
ARM-Darwin: re-enable -momit-leaf-frame-pointer.

In r279546 I disabled all frame pointer elimination at the front-end on
ARM-Darwin (and warned about it) because before that the backend had been
silently ignoring these options. It turns out we didn't ignore
-momit-leaf-frame-pointer though, just the more general -fomit-frame-pointer.

So this re-enables passing that down to CodeGen so that everything really does
continue working as before (with better diagnostics).

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/frame-pointer-elim.c

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=293311=293310=293311=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Jan 27 11:53:42 2017
@@ -1109,10 +1109,6 @@ Darwin::TranslateArgs(const DerivedArgLi
  options::OPT_fno_omit_frame_pointer, false))
   getDriver().Diag(clang::diag::warn_drv_unsupported_opt_for_target)
   << "-fomit-frame-pointer" << BoundArch;
-if (Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
- options::OPT_mno_omit_leaf_frame_pointer, false))
-  getDriver().Diag(clang::diag::warn_drv_unsupported_opt_for_target)
-  << "-momit-leaf-frame-pointer" << BoundArch;
   }
 
   return DAL;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=293311=293310=293311=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jan 27 11:53:42 2017
@@ -3455,7 +3455,7 @@ static bool areOptimizationsEnabled(cons
   return false;
 }
 
-static bool mustUseFramePointerForTarget(const llvm::Triple ) {
+static bool mustUseNonLeafFramePointerForTarget(const llvm::Triple ) {
   switch (Triple.getArch()){
   default:
 return false;
@@ -3521,7 +3521,7 @@ static bool shouldUseFramePointer(const
   if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
options::OPT_fomit_frame_pointer))
 return A->getOption().matches(options::OPT_fno_omit_frame_pointer) ||
-   mustUseFramePointerForTarget(Triple);
+   mustUseNonLeafFramePointerForTarget(Triple);
 
   if (Args.hasArg(options::OPT_pg))
 return true;
@@ -3533,8 +3533,7 @@ static bool shouldUseLeafFramePointer(co
   const llvm::Triple ) {
   if (Arg *A = Args.getLastArg(options::OPT_mno_omit_leaf_frame_pointer,
options::OPT_momit_leaf_frame_pointer))
-return A->getOption().matches(options::OPT_mno_omit_leaf_frame_pointer) ||
-   mustUseFramePointerForTarget(Triple);
+return A->getOption().matches(options::OPT_mno_omit_leaf_frame_pointer);
 
   if (Args.hasArg(options::OPT_pg))
 return true;

Modified: cfe/trunk/test/Driver/frame-pointer-elim.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/frame-pointer-elim.c?rev=293311=293310=293311=diff
==
--- cfe/trunk/test/Driver/frame-pointer-elim.c (original)
+++ cfe/trunk/test/Driver/frame-pointer-elim.c Fri Jan 27 11:53:42 2017
@@ -49,9 +49,9 @@
 
 // RUN: %clang -### -target armv7s-apple-ios8.0 -momit-leaf-frame-pointer %s 
2>&1 | \
 // RUN:   FileCheck --check-prefix=WARN-OMIT-LEAF-7S %s
-// WARN-OMIT-LEAF-7S: warning: optimization flag '-momit-leaf-frame-pointer' 
is not supported for target 'armv7s'
+// WARN-OMIT-LEAF-7S-NOT: warning: optimization flag 
'-momit-leaf-frame-pointer' is not supported for target 'armv7s'
 // WARN-OMIT-LEAF-7S: "-mdisable-fp-elim"
-// WARN-OMIT-LEAF-7S-NOT: "-momit-leaf-frame-pointer"
+// WARN-OMIT-LEAF-7S: "-momit-leaf-frame-pointer"
 
 // On the PS4, we default to omitting the frame pointer on leaf functions
 // (OMIT_LEAF check line is above)


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


r290268 - ARM: define a macro for the FPv5 FPU in ARM mode.

2016-12-21 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed Dec 21 14:49:43 2016
New Revision: 290268

URL: http://llvm.org/viewvc/llvm-project?rev=290268=rev
Log:
ARM: define a macro for the FPv5 FPU in ARM mode.

FPv5 is in Cortex-M7 and the 64-bit CPUs when running in 32-bit mode. The name
is from the Cortex-M7 TRM.

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/arm-target-features.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=290268=290267=290268=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Dec 21 14:49:43 2016
@@ -5391,6 +5391,8 @@ public:
 Builder.defineMacro("__ARM_VFPV3__");
   if (FPU & VFP4FPU)
 Builder.defineMacro("__ARM_VFPV4__");
+  if (FPU & FPARMV8)
+Builder.defineMacro("__ARM_FPV5__");
 }
 
 // This only gets set when Neon instructions are actually available, unlike

Modified: cfe/trunk/test/Preprocessor/arm-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/arm-target-features.c?rev=290268=290267=290268=diff
==
--- cfe/trunk/test/Preprocessor/arm-target-features.c (original)
+++ cfe/trunk/test/Preprocessor/arm-target-features.c Wed Dec 21 14:49:43 2016
@@ -389,6 +389,7 @@
 // M7-THUMB:#define __ARM_ARCH_EXT_IDIV__ 1
 // M7-THUMB:#define __ARM_FEATURE_DSP 1
 // M7-THUMB:#define __ARM_FP 0xE
+// M7-THUMB:#define __ARM_FPV5__ 1
 
 // Test whether predefines are as expected when targeting krait.
 // RUN: %clang -target armv7 -mcpu=krait -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=KRAIT %s


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


r289692 - AArch64: add architecture version feature to Clang invocation.

2016-12-14 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed Dec 14 13:21:30 2016
New Revision: 289692

URL: http://llvm.org/viewvc/llvm-project?rev=289692=rev
Log:
AArch64: add architecture version feature to Clang invocation.

Otherwise we don't get the correct predefines and so on in the front-end (or
the right features in the backend).

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/aarch64-cpus.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=289692=289691=289692=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Dec 14 13:21:30 2016
@@ -2527,9 +2527,11 @@ static bool DecodeAArch64Mcpu(const Driv
 Features.push_back("+neon");
   } else {
 unsigned ArchKind = llvm::AArch64::parseCPUArch(CPU);
-unsigned Extersion = llvm::AArch64::getDefaultExtensions(CPU, ArchKind);
+if (!llvm::AArch64::getArchFeatures(ArchKind, Features))
+  return false;
 
-if (!llvm::AArch64::getExtensionFeatures(Extersion, Features))
+unsigned Extension = llvm::AArch64::getDefaultExtensions(CPU, ArchKind);
+if (!llvm::AArch64::getExtensionFeatures(Extension, Features))
   return false;
}
 

Modified: cfe/trunk/test/Driver/aarch64-cpus.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-cpus.c?rev=289692=289691=289692=diff
==
--- cfe/trunk/test/Driver/aarch64-cpus.c (original)
+++ cfe/trunk/test/Driver/aarch64-cpus.c Wed Dec 14 13:21:30 2016
@@ -157,16 +157,20 @@
 // RUN: %clang -target aarch64 -mcpu=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=VULCAN %s
 // RUN: %clang -target aarch64 -mlittle-endian -mcpu=vulcan -### -c %s 2>&1 | 
FileCheck -check-prefix=VULCAN %s
 // RUN: %clang -target aarch64_be -mlittle-endian -mcpu=vulcan -### -c %s 2>&1 
| FileCheck -check-prefix=VULCAN %s
-// RUN: %clang -target aarch64 -mtune=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=VULCAN %s
-// RUN: %clang -target aarch64 -mlittle-endian -mtune=vulcan -### -c %s 2>&1 | 
FileCheck -check-prefix=VULCAN %s
-// RUN: %clang -target aarch64_be -mlittle-endian -mtune=vulcan -### -c %s 
2>&1 | FileCheck -check-prefix=VULCAN %s
-// VULCAN: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "vulcan"
+// RUN: %clang -target aarch64 -mtune=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=VULCAN-TUNE %s
+// RUN: %clang -target aarch64 -mlittle-endian -mtune=vulcan -### -c %s 2>&1 | 
FileCheck -check-prefix=VULCAN-TUNE %s
+// RUN: %clang -target aarch64_be -mlittle-endian -mtune=vulcan -### -c %s 
2>&1 | FileCheck -check-prefix=VULCAN-TUNE %s
+// VULCAN: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "vulcan" 
"-target-feature" "+v8.1a"
+// VULCAN-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "vulcan"
+// VULCAN-TUNE-NOT: +v8.1a
 
 // RUN: %clang -target arm64 -mcpu=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-VULCAN %s
 // RUN: %clang -target arm64 -mlittle-endian -mcpu=vulcan -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-VULCAN %s
-// RUN: %clang -target arm64 -mtune=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-VULCAN %s
-// RUN: %clang -target arm64 -mlittle-endian -mtune=vulcan -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-VULCAN %s
-// ARM64-VULCAN: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "vulcan"
+// RUN: %clang -target arm64 -mtune=vulcan -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-VULCAN-TUNE %s
+// RUN: %clang -target arm64 -mlittle-endian -mtune=vulcan -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-VULCAN-TUNE %s
+// ARM64-VULCAN: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "vulcan" 
"-target-feature" "+v8.1a"
+// ARM64-VULCAN-TUNE: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" 
"vulcan"
+// ARM64-VULCAN-TUNE-NOT: +v8.1a
 
 // RUN: %clang -target aarch64_be -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERIC-BE %s
 // RUN: %clang -target aarch64 -mbig-endian -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERIC-BE %s


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


Re: [libcxx] r284214 - XFAIL aligned allocation tests for older Clang versions

2016-10-18 Thread Tim Northover via cfe-commits
On 15 October 2016 at 13:08, Eric Fiselier via cfe-commits
 wrote:
> Are these tests still broken for you?

They're still breaking multiple Green Dragon bots (e.g. the basic
"make check" at
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA/)[1].
What do you need to help fix the issue?

Cheers.

Tim.

[1] Becoming more important now that we think we've fixed the hardware
problem in their lab and want to re-enable notifications.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r284392 - Reapply r284383. The test failures were due to a missing dir in test/

2016-10-17 Thread Tim Northover via cfe-commits
On 17 October 2016 at 10:34, Tim Northover  wrote:
> I think this might be something to do with git not actually recording
> empty directories. Could you have another look?

Never mind, I've confirmed and committed a fix in r284401.

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


Re: r284392 - Reapply r284383. The test failures were due to a missing dir in test/

2016-10-17 Thread Tim Northover via cfe-commits
On 17 October 2016 at 11:13, Krzysztof Parzyszek
 wrote:
> That is crazy! You are right---git does not store empty directories. "SVN
> co" worked fine for me, but "git clone" didn't.  D:

Oops, a bit of overlap. Thanks for fixing it more thoroughly than me!

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


r284401 - Hexagon: add dummy files to test dir so git keeps them.

2016-10-17 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Mon Oct 17 13:00:27 2016
New Revision: 284401

URL: http://llvm.org/viewvc/llvm-project?rev=284401=rev
Log:
Hexagon: add dummy files to test dir so git keeps them.

Should fix hexagon-elf-toolchain.c tests on Git.

Added:
cfe/trunk/test/Driver/Inputs/hexagon_tree/Tools/bin/.keep
cfe/trunk/test/Driver/Inputs/hexagon_tree/Tools/target/.keep

Added: cfe/trunk/test/Driver/Inputs/hexagon_tree/Tools/bin/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/hexagon_tree/Tools/bin/.keep?rev=284401=auto
==
(empty)

Added: cfe/trunk/test/Driver/Inputs/hexagon_tree/Tools/target/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/hexagon_tree/Tools/target/.keep?rev=284401=auto
==
(empty)


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


Re: [libcxx] r284214 - XFAIL aligned allocation tests for older Clang versions

2016-10-17 Thread Tim Northover via cfe-commits
On 14 October 2016 at 14:21, Eric Fiselier via cfe-commits
 wrote:
> Could you give me more information about the compiler your using?

Do you mostly build libcxx outside of a Clang source tree? I suspect
the problem is that if Clang is built at the same time then that's the
Clang which gets used to test libcxx, so it's effectively always 4.0.

This is consistent with local tests I've run of both in-tree builds
and out (using Xcode 8).

Cheers.

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


  1   2   >