[clang] [Documentation] Replace recommonmark by myst-parser (PR #65664)

2023-09-11 Thread Andrei Lebedev via cfe-commits

andreil99 wrote:

I can update the publishing bots. For the bots running on 
https://lab.llvm.org/buildbot/#/workers/92 we would need @gribozavr or somebody 
with access to gribozavr3 worker.

@cor3ntin, is there any dependency on a particular version of myst-parser?

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


[clang] [RISCV] Add MC layer support for Zicfiss. (PR #66043)

2023-09-11 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-backend-risc-v


Changes

The patch adds the instructions in Zicfiss extension. Zicfiss extension is to 
support shadow stack for control flow integrity. This patch is based on version 
[0.3.1].

[0.3.1]: https://github.com/riscv/riscv-cfi/releases/tag/v0.3.1
--

Patch is 23.44 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/66043.diff

14 Files Affected:

- (modified) clang/test/Preprocessor/riscv-target-features.c (+9) 
- (modified) llvm/docs/RISCVUsage.rst (+3) 
- (modified) llvm/lib/Support/RISCVISAInfo.cpp (+2) 
- (modified) llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp (+29) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+7) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfo.td (+5-4) 
- (added) llvm/lib/Target/RISCV/RISCVInstrInfoZicfiss.td (+86) 
- (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp (+3) 
- (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.td (+9) 
- (modified) llvm/test/MC/RISCV/attribute-arch.s (+3) 
- (added) llvm/test/MC/RISCV/rv32zicfiss-invalid.s (+20) 
- (added) llvm/test/MC/RISCV/rv32zicfiss-valid.s (+103) 
- (added) llvm/test/MC/RISCV/rv64zicfiss-invalid.s (+20) 
- (added) llvm/test/MC/RISCV/rv64zicfiss-valid.s (+103) 



diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 02b67dc7944ba88..163eba81543ee5b 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -113,6 +113,7 @@
 // CHECK-NOT: __riscv_zfa {{.*$}}
 // CHECK-NOT: __riscv_zfbfmin {{.*$}}
 // CHECK-NOT: __riscv_zicfilp {{.*$}}
+// CHECK-NOT: __riscv_zicfiss {{.*$}}
 // CHECK-NOT: __riscv_zicond {{.*$}}
 // CHECK-NOT: __riscv_ztso {{.*$}}
 // CHECK-NOT: __riscv_zvbb {{.*$}}
@@ -1220,3 +1221,11 @@
 // RUN: -march=rv64i_zve32x_zvkt1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKT-EXT %s
 // CHECK-ZVKT-EXT: __riscv_zvkt 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32izicfiss0p3 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZICFISS-EXT %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64izicfiss0p3 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZICFISS-EXT %s
+// CHECK-ZICFISS-EXT: __riscv_zicfiss 3000{{$}}
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 8d12d58738c609a..31c55def0a7694a 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -205,6 +205,9 @@ The primary goal of experimental support is to assist in 
the process of ratifica
 ``experimental-zicfilp``
   LLVM implements the `0.2 draft specification 
`__.
 
+``experimental-zicfiss``
+  LLVM implements the `0.3.1 draft specification 
`__.
+
 ``experimental-zicond``
   LLVM implements the `1.0-rc1 draft specification 
`__.
 
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp 
b/llvm/lib/Support/RISCVISAInfo.cpp
index a02c9842e85839a..c414b62c5f31092 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -170,6 +170,8 @@ static const RISCVSupportedExtension 
SupportedExperimentalExtensions[] = {
 {"zfbfmin", RISCVExtensionVersion{0, 8}},
 
 {"zicfilp", RISCVExtensionVersion{0, 2}},
+{"zicfiss", RISCVExtensionVersion{0, 3}},
+
 {"zicond", RISCVExtensionVersion{1, 0}},
 
 {"ztso", RISCVExtensionVersion{0, 1}},
diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp 
b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
index d561d90d3088c1a..14b3122f0fecbdb 100644
--- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
+++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
@@ -74,6 +74,17 @@ static DecodeStatus DecodeGPRRegisterClass(MCInst , 
uint32_t RegNo,
   return MCDisassembler::Success;
 }
 
+static DecodeStatus DecodeGPRRARegisterClass(MCInst , uint32_t RegNo,
+ uint64_t Address,
+ const MCDisassembler *Decoder) {
+  MCRegister Reg = RISCV::X0 + RegNo;
+  if (Reg != RISCV::X1 && Reg != RISCV::X5)
+return MCDisassembler::Fail;
+
+  Inst.addOperand(MCOperand::createReg(Reg));
+  return MCDisassembler::Success;
+}
+
 static DecodeStatus DecodeFPR16RegisterClass(MCInst , uint32_t RegNo,
  uint64_t Address,
  const MCDisassembler *Decoder) {
@@ -370,6 +381,10 @@ static DecodeStatus decodeZcmpRlist(MCInst , unsigned 
Imm,
 static DecodeStatus decodeZcmpSpimm(MCInst , unsigned Imm,
 uint64_t Address, const void *Decoder);
 
+static DecodeStatus decodeCSSPushPopchk(MCInst , 

[clang] [RISCV] Add MC layer support for Zicfiss. (PR #66043)

2023-09-11 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-mc


Changes

The patch adds the instructions in Zicfiss extension. Zicfiss extension is to 
support shadow stack for control flow integrity. This patch is based on version 
[0.3.1].

[0.3.1]: https://github.com/riscv/riscv-cfi/releases/tag/v0.3.1
--

Patch is 23.44 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/66043.diff

14 Files Affected:

- (modified) clang/test/Preprocessor/riscv-target-features.c (+9) 
- (modified) llvm/docs/RISCVUsage.rst (+3) 
- (modified) llvm/lib/Support/RISCVISAInfo.cpp (+2) 
- (modified) llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp (+29) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+7) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfo.td (+5-4) 
- (added) llvm/lib/Target/RISCV/RISCVInstrInfoZicfiss.td (+86) 
- (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp (+3) 
- (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.td (+9) 
- (modified) llvm/test/MC/RISCV/attribute-arch.s (+3) 
- (added) llvm/test/MC/RISCV/rv32zicfiss-invalid.s (+20) 
- (added) llvm/test/MC/RISCV/rv32zicfiss-valid.s (+103) 
- (added) llvm/test/MC/RISCV/rv64zicfiss-invalid.s (+20) 
- (added) llvm/test/MC/RISCV/rv64zicfiss-valid.s (+103) 



diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 02b67dc7944ba88..163eba81543ee5b 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -113,6 +113,7 @@
 // CHECK-NOT: __riscv_zfa {{.*$}}
 // CHECK-NOT: __riscv_zfbfmin {{.*$}}
 // CHECK-NOT: __riscv_zicfilp {{.*$}}
+// CHECK-NOT: __riscv_zicfiss {{.*$}}
 // CHECK-NOT: __riscv_zicond {{.*$}}
 // CHECK-NOT: __riscv_ztso {{.*$}}
 // CHECK-NOT: __riscv_zvbb {{.*$}}
@@ -1220,3 +1221,11 @@
 // RUN: -march=rv64i_zve32x_zvkt1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKT-EXT %s
 // CHECK-ZVKT-EXT: __riscv_zvkt 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32izicfiss0p3 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZICFISS-EXT %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64izicfiss0p3 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZICFISS-EXT %s
+// CHECK-ZICFISS-EXT: __riscv_zicfiss 3000{{$}}
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 8d12d58738c609a..31c55def0a7694a 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -205,6 +205,9 @@ The primary goal of experimental support is to assist in 
the process of ratifica
 ``experimental-zicfilp``
   LLVM implements the `0.2 draft specification 
`__.
 
+``experimental-zicfiss``
+  LLVM implements the `0.3.1 draft specification 
`__.
+
 ``experimental-zicond``
   LLVM implements the `1.0-rc1 draft specification 
`__.
 
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp 
b/llvm/lib/Support/RISCVISAInfo.cpp
index a02c9842e85839a..c414b62c5f31092 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -170,6 +170,8 @@ static const RISCVSupportedExtension 
SupportedExperimentalExtensions[] = {
 {"zfbfmin", RISCVExtensionVersion{0, 8}},
 
 {"zicfilp", RISCVExtensionVersion{0, 2}},
+{"zicfiss", RISCVExtensionVersion{0, 3}},
+
 {"zicond", RISCVExtensionVersion{1, 0}},
 
 {"ztso", RISCVExtensionVersion{0, 1}},
diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp 
b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
index d561d90d3088c1a..14b3122f0fecbdb 100644
--- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
+++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
@@ -74,6 +74,17 @@ static DecodeStatus DecodeGPRRegisterClass(MCInst , 
uint32_t RegNo,
   return MCDisassembler::Success;
 }
 
+static DecodeStatus DecodeGPRRARegisterClass(MCInst , uint32_t RegNo,
+ uint64_t Address,
+ const MCDisassembler *Decoder) {
+  MCRegister Reg = RISCV::X0 + RegNo;
+  if (Reg != RISCV::X1 && Reg != RISCV::X5)
+return MCDisassembler::Fail;
+
+  Inst.addOperand(MCOperand::createReg(Reg));
+  return MCDisassembler::Success;
+}
+
 static DecodeStatus DecodeFPR16RegisterClass(MCInst , uint32_t RegNo,
  uint64_t Address,
  const MCDisassembler *Decoder) {
@@ -370,6 +381,10 @@ static DecodeStatus decodeZcmpRlist(MCInst , unsigned 
Imm,
 static DecodeStatus decodeZcmpSpimm(MCInst , unsigned Imm,
 uint64_t Address, const void *Decoder);
 
+static DecodeStatus decodeCSSPushPopchk(MCInst , uint32_t Insn,
+   

[clang] [RISCV] Add MC layer support for Zicfiss. (PR #66043)

2023-09-11 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-clang


Changes

The patch adds the instructions in Zicfiss extension. Zicfiss extension is to 
support shadow stack for control flow integrity. This patch is based on version 
[0.3.1].

[0.3.1]: https://github.com/riscv/riscv-cfi/releases/tag/v0.3.1
--

Patch is 23.44 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/66043.diff

14 Files Affected:

- (modified) clang/test/Preprocessor/riscv-target-features.c (+9) 
- (modified) llvm/docs/RISCVUsage.rst (+3) 
- (modified) llvm/lib/Support/RISCVISAInfo.cpp (+2) 
- (modified) llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp (+29) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+7) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfo.td (+5-4) 
- (added) llvm/lib/Target/RISCV/RISCVInstrInfoZicfiss.td (+86) 
- (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp (+3) 
- (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.td (+9) 
- (modified) llvm/test/MC/RISCV/attribute-arch.s (+3) 
- (added) llvm/test/MC/RISCV/rv32zicfiss-invalid.s (+20) 
- (added) llvm/test/MC/RISCV/rv32zicfiss-valid.s (+103) 
- (added) llvm/test/MC/RISCV/rv64zicfiss-invalid.s (+20) 
- (added) llvm/test/MC/RISCV/rv64zicfiss-valid.s (+103) 



diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 02b67dc7944ba88..163eba81543ee5b 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -113,6 +113,7 @@
 // CHECK-NOT: __riscv_zfa {{.*$}}
 // CHECK-NOT: __riscv_zfbfmin {{.*$}}
 // CHECK-NOT: __riscv_zicfilp {{.*$}}
+// CHECK-NOT: __riscv_zicfiss {{.*$}}
 // CHECK-NOT: __riscv_zicond {{.*$}}
 // CHECK-NOT: __riscv_ztso {{.*$}}
 // CHECK-NOT: __riscv_zvbb {{.*$}}
@@ -1220,3 +1221,11 @@
 // RUN: -march=rv64i_zve32x_zvkt1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKT-EXT %s
 // CHECK-ZVKT-EXT: __riscv_zvkt 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32izicfiss0p3 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZICFISS-EXT %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64izicfiss0p3 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZICFISS-EXT %s
+// CHECK-ZICFISS-EXT: __riscv_zicfiss 3000{{$}}
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 8d12d58738c609a..31c55def0a7694a 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -205,6 +205,9 @@ The primary goal of experimental support is to assist in 
the process of ratifica
 ``experimental-zicfilp``
   LLVM implements the `0.2 draft specification 
`__.
 
+``experimental-zicfiss``
+  LLVM implements the `0.3.1 draft specification 
`__.
+
 ``experimental-zicond``
   LLVM implements the `1.0-rc1 draft specification 
`__.
 
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp 
b/llvm/lib/Support/RISCVISAInfo.cpp
index a02c9842e85839a..c414b62c5f31092 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -170,6 +170,8 @@ static const RISCVSupportedExtension 
SupportedExperimentalExtensions[] = {
 {"zfbfmin", RISCVExtensionVersion{0, 8}},
 
 {"zicfilp", RISCVExtensionVersion{0, 2}},
+{"zicfiss", RISCVExtensionVersion{0, 3}},
+
 {"zicond", RISCVExtensionVersion{1, 0}},
 
 {"ztso", RISCVExtensionVersion{0, 1}},
diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp 
b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
index d561d90d3088c1a..14b3122f0fecbdb 100644
--- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
+++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
@@ -74,6 +74,17 @@ static DecodeStatus DecodeGPRRegisterClass(MCInst , 
uint32_t RegNo,
   return MCDisassembler::Success;
 }
 
+static DecodeStatus DecodeGPRRARegisterClass(MCInst , uint32_t RegNo,
+ uint64_t Address,
+ const MCDisassembler *Decoder) {
+  MCRegister Reg = RISCV::X0 + RegNo;
+  if (Reg != RISCV::X1 && Reg != RISCV::X5)
+return MCDisassembler::Fail;
+
+  Inst.addOperand(MCOperand::createReg(Reg));
+  return MCDisassembler::Success;
+}
+
 static DecodeStatus DecodeFPR16RegisterClass(MCInst , uint32_t RegNo,
  uint64_t Address,
  const MCDisassembler *Decoder) {
@@ -370,6 +381,10 @@ static DecodeStatus decodeZcmpRlist(MCInst , unsigned 
Imm,
 static DecodeStatus decodeZcmpSpimm(MCInst , unsigned Imm,
 uint64_t Address, const void *Decoder);
 
+static DecodeStatus decodeCSSPushPopchk(MCInst , uint32_t Insn,

[clang] [RISCV] Add MC layer support for Zicfiss. (PR #66043)

2023-09-11 Thread via cfe-commits

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


[clang] [RISCV] Add MC layer support for Zicfiss. (PR #66043)

2023-09-11 Thread via cfe-commits

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


[clang] [RISCV] Add MC layer support for Zicfiss. (PR #66043)

2023-09-11 Thread via cfe-commits

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


[clang] [RISCV] Add MC layer support for Zicfiss. (PR #66043)

2023-09-11 Thread Yeting Kuo via cfe-commits

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


[clang] [RISCV] Add MC layer support for Zicfiss. (PR #66043)

2023-09-11 Thread Yeting Kuo via cfe-commits

https://github.com/yetingk created 
https://github.com/llvm/llvm-project/pull/66043:

The patch adds the instructions in Zicfiss extension. Zicfiss extension is to 
support shadow stack for control flow integrity. This patch is based on version 
[0.3.1].

[0.3.1]: https://github.com/riscv/riscv-cfi/releases/tag/v0.3.1

>From 91bb1d9884276a37f93515a648aa6ece353fdc70 Mon Sep 17 00:00:00 2001
From: Yeting Kuo 
Date: Tue, 12 Sep 2023 12:28:00 +0800
Subject: [PATCH] [RISCV] Add MC layer support for Zicfiss.

The patch adds the instructions in Zicfiss extension. Zicfiss extension is
to support shadow stack for control flow integrity.

Differential Revision: https://reviews.llvm.org/D152793
---
 .../test/Preprocessor/riscv-target-features.c |   9 ++
 llvm/docs/RISCVUsage.rst  |   3 +
 llvm/lib/Support/RISCVISAInfo.cpp |   2 +
 .../RISCV/Disassembler/RISCVDisassembler.cpp  |  29 +
 llvm/lib/Target/RISCV/RISCVFeatures.td|   7 ++
 llvm/lib/Target/RISCV/RISCVInstrInfo.td   |   9 +-
 .../lib/Target/RISCV/RISCVInstrInfoZicfiss.td |  86 +++
 llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp   |   3 +
 llvm/lib/Target/RISCV/RISCVRegisterInfo.td|   9 ++
 llvm/test/MC/RISCV/attribute-arch.s   |   3 +
 llvm/test/MC/RISCV/rv32zicfiss-invalid.s  |  20 
 llvm/test/MC/RISCV/rv32zicfiss-valid.s| 103 ++
 llvm/test/MC/RISCV/rv64zicfiss-invalid.s  |  20 
 llvm/test/MC/RISCV/rv64zicfiss-valid.s| 103 ++
 14 files changed, 402 insertions(+), 4 deletions(-)
 create mode 100644 llvm/lib/Target/RISCV/RISCVInstrInfoZicfiss.td
 create mode 100644 llvm/test/MC/RISCV/rv32zicfiss-invalid.s
 create mode 100644 llvm/test/MC/RISCV/rv32zicfiss-valid.s
 create mode 100644 llvm/test/MC/RISCV/rv64zicfiss-invalid.s
 create mode 100644 llvm/test/MC/RISCV/rv64zicfiss-valid.s

diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 02b67dc7944ba88..163eba81543ee5b 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -113,6 +113,7 @@
 // CHECK-NOT: __riscv_zfa {{.*$}}
 // CHECK-NOT: __riscv_zfbfmin {{.*$}}
 // CHECK-NOT: __riscv_zicfilp {{.*$}}
+// CHECK-NOT: __riscv_zicfiss {{.*$}}
 // CHECK-NOT: __riscv_zicond {{.*$}}
 // CHECK-NOT: __riscv_ztso {{.*$}}
 // CHECK-NOT: __riscv_zvbb {{.*$}}
@@ -1220,3 +1221,11 @@
 // RUN: -march=rv64i_zve32x_zvkt1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKT-EXT %s
 // CHECK-ZVKT-EXT: __riscv_zvkt 100{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32izicfiss0p3 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZICFISS-EXT %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64izicfiss0p3 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZICFISS-EXT %s
+// CHECK-ZICFISS-EXT: __riscv_zicfiss 3000{{$}}
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 8d12d58738c609a..31c55def0a7694a 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -205,6 +205,9 @@ The primary goal of experimental support is to assist in 
the process of ratifica
 ``experimental-zicfilp``
   LLVM implements the `0.2 draft specification 
`__.
 
+``experimental-zicfiss``
+  LLVM implements the `0.3.1 draft specification 
`__.
+
 ``experimental-zicond``
   LLVM implements the `1.0-rc1 draft specification 
`__.
 
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp 
b/llvm/lib/Support/RISCVISAInfo.cpp
index a02c9842e85839a..c414b62c5f31092 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -170,6 +170,8 @@ static const RISCVSupportedExtension 
SupportedExperimentalExtensions[] = {
 {"zfbfmin", RISCVExtensionVersion{0, 8}},
 
 {"zicfilp", RISCVExtensionVersion{0, 2}},
+{"zicfiss", RISCVExtensionVersion{0, 3}},
+
 {"zicond", RISCVExtensionVersion{1, 0}},
 
 {"ztso", RISCVExtensionVersion{0, 1}},
diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp 
b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
index d561d90d3088c1a..14b3122f0fecbdb 100644
--- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
+++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
@@ -74,6 +74,17 @@ static DecodeStatus DecodeGPRRegisterClass(MCInst , 
uint32_t RegNo,
   return MCDisassembler::Success;
 }
 
+static DecodeStatus DecodeGPRRARegisterClass(MCInst , uint32_t RegNo,
+ uint64_t Address,
+ const MCDisassembler *Decoder) {
+  MCRegister Reg = RISCV::X0 + RegNo;
+  if (Reg != RISCV::X1 && Reg != RISCV::X5)

[clang-tools-extra] [flang][openacc] Enable lowering support for OpenACC atomic operations (PR #65776)

2023-09-11 Thread via cfe-commits

https://github.com/NimishMishra commented:

Apologies for the late review. I mainly worked on the OpenMP side of atomic 
construct.

Thank you for the sharing of code between OpenACC and OpenMP. Overall, the 
sharing between OpenMP and OpenACC looks good to me. Minor comments have 
already been pointed out by others and fixed.

Thanks!

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


[clang] [Documentation] Replace recommonmark by myst-parser (PR #65664)

2023-09-11 Thread Tom Stellard via cfe-commits

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

LGTM.  @andreil99 Are you maintaining the documentation bots?

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


[clang] [Driver] Implement ToolChain on Haiku (PR #66038)

2023-09-11 Thread Brad Smith via cfe-commits

https://github.com/brad0 updated 
https://github.com/llvm/llvm-project/pull/66038:

>From 659b362ae637be0500ed50a88d9cf5648a081827 Mon Sep 17 00:00:00 2001
From: X512 
Date: Mon, 11 Sep 2023 20:56:02 -0400
Subject: [PATCH] [Driver] Implement ToolChain on Haiku

Co-authored-by: David Karoly 
Co-authored-by: Brad Smith 
---
 clang/lib/Driver/ToolChains/Gnu.cpp   |  31 
 clang/lib/Driver/ToolChains/Haiku.cpp | 137 ++
 clang/lib/Driver/ToolChains/Haiku.h   |  31 
 .../boot/system/develop/lib/crti.o|   0
 .../boot/system/develop/lib/crtn.o|   0
 .../boot/system/develop/lib/init_term_dyn.o   |   0
 .../boot/system/develop/lib/start_dyn.o   |   0
 .../x86_64-unknown-haiku/13.2.0/crtbegin.o|   0
 .../x86_64-unknown-haiku/13.2.0/crtbeginS.o   |   0
 .../gcc/x86_64-unknown-haiku/13.2.0/crtend.o  |   0
 .../gcc/x86_64-unknown-haiku/13.2.0/crtendS.o |   0
 clang/test/Driver/haiku.c |  44 ++
 12 files changed, 243 insertions(+)
 create mode 100644 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/lib/crti.o
 create mode 100644 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/lib/crtn.o
 create mode 100644 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/lib/init_term_dyn.o
 create mode 100644 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/lib/start_dyn.o
 create mode 100644 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/13.2.0/crtbegin.o
 create mode 100644 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/13.2.0/crtbeginS.o
 create mode 100644 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/13.2.0/crtend.o
 create mode 100644 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/13.2.0/crtendS.o

diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 7aeb8e29ebc5574..cd6713ab52d926d 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2224,6 +2224,12 @@ bool 
Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib ) const {
 void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
 const llvm::Triple , SmallVectorImpl ,
 StringRef SysRoot) {
+
+  if (TargetTriple.isOSHaiku()) {
+Prefixes.push_back(concat(SysRoot, "/boot/system/develop/tools"));
+return;
+  }
+
   if (TargetTriple.isOSSolaris()) {
 // Solaris is a special case.
 // The GCC installation is under
@@ -2426,6 +2432,31 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   using std::begin;
   using std::end;
 
+  if (TargetTriple.isOSHaiku()) {
+static const char *const HaikuLibDirs[] = {"/lib"};
+static const char *const HaikuAArch64Triples[] = {"aarch64-unknown-haiku"};
+static const char *const HaikuRISCV64Triples[] = {"riscv64-unknown-haiku"};
+static const char *const HaikuX86Triples[] = {"i586-unknown-haiku"};
+static const char *const HaikuX86_64Triples[] = {"x86_64-unknown-haiku"};
+LibDirs.append(begin(HaikuLibDirs), end(HaikuLibDirs));
+switch (TargetTriple.getArch()) {
+case llvm::Triple::aarch64:
+  TripleAliases.append(begin(HaikuAArch64Triples), 
end(HaikuAArch64Triples));
+  break;
+case llvm::Triple::riscv64:
+  TripleAliases.append(begin(HaikuRISCV64Triples), 
end(HaikuRISCV64Triples));
+  break;
+case llvm::Triple::x86:
+  TripleAliases.append(begin(HaikuX86Triples), end(HaikuX86Triples));
+  break;
+case llvm::Triple::x86_64:
+  TripleAliases.append(begin(HaikuX86_64Triples), end(HaikuX86_64Triples));
+  break;
+default:
+  break;
+}
+  }
+
   if (TargetTriple.isOSSolaris()) {
 static const char *const SolarisLibDirs[] = {"/lib"};
 static const char *const SolarisSparcV8Triples[] = {
diff --git a/clang/lib/Driver/ToolChains/Haiku.cpp 
b/clang/lib/Driver/ToolChains/Haiku.cpp
index 55fc0533f699fab..3def1c7b67a30a9 100644
--- a/clang/lib/Driver/ToolChains/Haiku.cpp
+++ b/clang/lib/Driver/ToolChains/Haiku.cpp
@@ -9,20 +9,145 @@
 #include "Haiku.h"
 #include "CommonArgs.h"
 #include "clang/Config/config.h"
+#include "clang/Driver/Compilation.h"
 #include "llvm/Support/Path.h"
 
 using namespace clang::driver;
+using namespace clang::driver::tools;
 using namespace clang::driver::toolchains;
 using namespace clang;
 using namespace llvm::opt;
 
+void haiku::Linker::ConstructJob(Compilation , const JobAction ,
+   const InputInfo ,
+   const InputInfoList ,
+   const ArgList ,
+   const char *LinkingOutput) const {
+  const toolchains::Haiku  =
+  static_cast(getToolChain());
+  const Driver  = ToolChain.getDriver();
+  const 

[PATCH] D159138: [clang][Sema] Fix format size estimator's handling of %o, %x, %X with alternative form

2023-09-11 Thread Takuya Shimizu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
hazohelet marked an inline comment as done.
Closed by commit rG72f6abb9bca6: [clang][Sema] Fix format size estimators 
handling of %o, %x, %X with… (authored by hazohelet).

Changed prior to commit:
  https://reviews.llvm.org/D159138?vs=555043=556516#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159138

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/warn-fortify-source.c

Index: clang/test/Sema/warn-fortify-source.c
===
--- clang/test/Sema/warn-fortify-source.c
+++ clang/test/Sema/warn-fortify-source.c
@@ -85,7 +85,7 @@
   __builtin_memset(buf, 0xff, 11); // expected-warning {{'memset' will always overflow; destination buffer has size 10, but size argument is 11}}
 }
 
-void call_snprintf(double d) {
+void call_snprintf(double d, int n) {
   char buf[10];
   __builtin_snprintf(buf, 10, "merp");
   __builtin_snprintf(buf, 11, "merp"); // expected-warning {{'snprintf' size argument is too large; destination buffer has size 10, but size argument is 11}}
@@ -96,6 +96,13 @@
   __builtin_snprintf(buf, 1, "%.1000g", d); // expected-warning {{'snprintf' will always be truncated; specified size is 1, but format string expands to at least 2}}
   __builtin_snprintf(buf, 5, "%.1000g", d);
   __builtin_snprintf(buf, 5, "%.1000G", d);
+  __builtin_snprintf(buf, 10, " %#08x", n);
+  __builtin_snprintf(buf, 2, "%#x", n);
+  __builtin_snprintf(buf, 2, "%#X", n);
+  __builtin_snprintf(buf, 2, "%#o", n);
+  __builtin_snprintf(buf, 1, "%#x", n); // expected-warning {{'snprintf' will always be truncated; specified size is 1, but format string expands to at least 2}}
+  __builtin_snprintf(buf, 1, "%#X", n); // expected-warning {{'snprintf' will always be truncated; specified size is 1, but format string expands to at least 2}}
+  __builtin_snprintf(buf, 1, "%#o", n); // expected-warning {{'snprintf' will always be truncated; specified size is 1, but format string expands to at least 2}}
 }
 
 void call_vsnprintf(void) {
@@ -110,6 +117,13 @@
   __builtin_vsnprintf(buf, 1, "%.1000g", list); // expected-warning {{'vsnprintf' will always be truncated; specified size is 1, but format string expands to at least 2}}
   __builtin_vsnprintf(buf, 5, "%.1000g", list);
   __builtin_vsnprintf(buf, 5, "%.1000G", list);
+  __builtin_vsnprintf(buf, 10, " %#08x", list);
+  __builtin_vsnprintf(buf, 2, "%#x", list);
+  __builtin_vsnprintf(buf, 2, "%#X", list);
+  __builtin_vsnprintf(buf, 2, "%#o", list);
+  __builtin_vsnprintf(buf, 1, "%#x", list); // expected-warning {{'vsnprintf' will always be truncated; specified size is 1, but format string expands to at least 2}}
+  __builtin_vsnprintf(buf, 1, "%#X", list); // expected-warning {{'vsnprintf' will always be truncated; specified size is 1, but format string expands to at least 2}}
+  __builtin_vsnprintf(buf, 1, "%#o", list); // expected-warning {{'vsnprintf' will always be truncated; specified size is 1, but format string expands to at least 2}}
 }
 
 void call_sprintf_chk(char *buf) {
@@ -147,7 +161,7 @@
   __builtin___sprintf_chk(buf, 1, 2, "%%");
   __builtin___sprintf_chk(buf, 1, 1, "%%"); // expected-warning {{'sprintf' will always overflow; destination buffer has size 1, but format string expands to at least 2}}
   __builtin___sprintf_chk(buf, 1, 4, "%#x", 9);
-  __builtin___sprintf_chk(buf, 1, 3, "%#x", 9); // expected-warning {{'sprintf' will always overflow; destination buffer has size 3, but format string expands to at least 4}}
+  __builtin___sprintf_chk(buf, 1, 3, "%#x", 9);
   __builtin___sprintf_chk(buf, 1, 4, "%p", (void *)9);
   __builtin___sprintf_chk(buf, 1, 3, "%p", (void *)9); // expected-warning {{'sprintf' will always overflow; destination buffer has size 3, but format string expands to at least 4}}
   __builtin___sprintf_chk(buf, 1, 3, "%+d", 9);
@@ -184,7 +198,7 @@
   sprintf(buf, "1234%lld", 9ll);
   sprintf(buf, "12345%lld", 9ll); // expected-warning {{'sprintf' will always overflow; destination buffer has size 6, but format string expands to at least 7}}
   sprintf(buf, "12%#x", 9);
-  sprintf(buf, "123%#x", 9); // expected-warning {{'sprintf' will always overflow; destination buffer has size 6, but format string expands to at least 7}}
+  sprintf(buf, "123%#x", 9);
   sprintf(buf, "12%p", (void *)9);
   sprintf(buf, "123%p", (void *)9); // expected-warning {{'sprintf' will always overflow; destination buffer has size 6, but format string expands to at least 7}}
   sprintf(buf, "123%+d", 9);
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -890,6 +890,8 @@
 // %g style conversion switches between %f or %e style 

[clang] 72f6abb - [clang][Sema] Fix format size estimator's handling of %o, %x, %X with alternative form

2023-09-11 Thread Takuya Shimizu via cfe-commits

Author: Takuya Shimizu
Date: 2023-09-12T12:22:26+09:00
New Revision: 72f6abb9bca68bf1398b321a73ebe3158bca67e5

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

LOG: [clang][Sema] Fix format size estimator's handling of %o, %x, %X with 
alternative form

The wrong handling of %x specifier with alternative form causes a false 
positive in linux kernel 
(https://github.com/ClangBuiltLinux/linux/issues/1923#issuecomment-1696075886)

The kernel code: 
https://github.com/torvalds/linux/blob/651a00bc56403161351090a9d7ddbd7095975324/drivers/media/pci/cx18/cx18-mailbox.c#L99

This patch fixes this handling, and also adds some standard wordings as 
comments to clarify the reason.

Reviewed By: nickdesaulniers
Differential Revision: https://reviews.llvm.org/D159138

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/warn-fortify-source.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fc0972c20476d09..c7b4432380120cb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -164,7 +164,7 @@ Improvements to Clang's diagnostics
   result in string truncation.
   (`#64871: `_).
   Also clang no longer emits false positive warnings about the output length of
-  ``%g`` format specifier.
+  ``%g`` format specifier and about ``%o, %x, %X`` with ``#`` flag.
 - Clang now emits ``-Wcast-qual`` for functional-style cast expressions.
 
 Bug Fixes in This Version

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 3b4ac613da76aa8..fad70223362eddd 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -890,6 +890,8 @@ class EstimateSizeFormatHandler
 // %g style conversion switches between %f or %e style dynamically.
 // %g removes trailing zeros, and does not print decimal point if there are
 // no digits that follow it. Thus %g can print a single digit.
+// FIXME: If it is alternative form:
+// For g and G conversions, trailing zeros are not removed from the result.
 case analyze_format_string::ConversionSpecifier::gArg:
 case analyze_format_string::ConversionSpecifier::GArg:
   Size += 1;
@@ -947,18 +949,26 @@ class EstimateSizeFormatHandler
 
 if (FS.hasAlternativeForm()) {
   switch (FS.getConversionSpecifier().getKind()) {
-  default:
-break;
-  // Force a leading '0'.
+  // For o conversion, it increases the precision, if and only if 
necessary,
+  // to force the first digit of the result to be a zero
+  // (if the value and precision are both 0, a single 0 is printed)
   case analyze_format_string::ConversionSpecifier::oArg:
-Size += 1;
-break;
-  // Force a leading '0x'.
+  // For b conversion, a nonzero result has 0b prefixed to it.
+  case analyze_format_string::ConversionSpecifier::bArg:
+  // For x (or X) conversion, a nonzero result has 0x (or 0X) prefixed to
+  // it.
   case analyze_format_string::ConversionSpecifier::xArg:
   case analyze_format_string::ConversionSpecifier::XArg:
-Size += 2;
+// Note: even when the prefix is added, if
+// (prefix_width <= FieldWidth - formatted_length) holds,
+// the prefix does not increase the format
+// size. e.g.(("%#3x", 0xf) is "0xf")
+
+// If the result is zero, o, b, x, X adds nothing.
 break;
-  // Force a period '.' before decimal, even if precision is 0.
+  // For a, A, e, E, f, F, g, and G conversions,
+  // the result of converting a floating-point number always contains a
+  // decimal-point
   case analyze_format_string::ConversionSpecifier::aArg:
   case analyze_format_string::ConversionSpecifier::AArg:
   case analyze_format_string::ConversionSpecifier::eArg:
@@ -969,6 +979,9 @@ class EstimateSizeFormatHandler
   case analyze_format_string::ConversionSpecifier::GArg:
 Size += (Precision ? 0 : 1);
 break;
+  // For other conversions, the behavior is undefined.
+  default:
+break;
   }
 }
 assert(SpecifierLen <= Size && "no underflow");

diff  --git a/clang/test/Sema/warn-fortify-source.c 
b/clang/test/Sema/warn-fortify-source.c
index 5ed9782b26fb788..de6171af8c14524 100644
--- a/clang/test/Sema/warn-fortify-source.c
+++ b/clang/test/Sema/warn-fortify-source.c
@@ -85,7 +85,7 @@ void call_memset(void) {
   __builtin_memset(buf, 0xff, 11); // expected-warning {{'memset' will always 
overflow; destination buffer has size 10, but size argument is 11}}
 }
 
-void call_snprintf(double d) {
+void call_snprintf(double d, int n) {
   char buf[10];
   

[clang] [Fuchsia] Support building runtimes for RISC-V on Linux (PR #66025)

2023-09-11 Thread Petr Hosek via cfe-commits

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


[clang] 10e1c4a - [Fuchsia] Support building runtimes for RISC-V on Linux (#66025)

2023-09-11 Thread via cfe-commits

Author: Petr Hosek
Date: 2023-09-11T20:20:24-07:00
New Revision: 10e1c4a02be824c5394da4f2c79bc351eda19dc9

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

LOG: [Fuchsia] Support building runtimes for RISC-V on Linux (#66025)

We support RISC-V on Linux as the host platform for Fuchsia.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 4890040b1b6a2b4..bc4d9f1462b1814 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -132,7 +132,7 @@ if(WIN32 OR LLVM_WINSYSROOT)
   set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
 endif()
 
-foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;x86_64-unknown-linux-gnu)
+foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;riscv64-unknown-linux-gnu;x86_64-unknown-linux-gnu)
   if(LINUX_${target}_SYSROOT)
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}")



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


[clang] [clang] fix lack comparison of declRefExpr in ASTStructuralEquivalence (PR #66041)

2023-09-11 Thread via cfe-commits

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


[clang] [clang] fix lack comparison of declRefExpr in ASTStructuralEquivalence (PR #66041)

2023-09-11 Thread via cfe-commits

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


[clang] [clang] fix lack comparison of declRefExpr in ASTStructuralEquivalence (PR #66041)

2023-09-11 Thread via cfe-commits

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


[clang] [clang] fix lack comparison of declRefExpr in ASTStructuralEquivalence (PR #66041)

2023-09-11 Thread via cfe-commits

https://github.com/mzyKi created 
https://github.com/llvm/llvm-project/pull/66041:

Before fix,the following testcase expected true. While I think only comparison 
of declName is not sufficient.Thanks for giving suggestions.

>From 1efbe57a8acd2219228014dd7dce6f179ee777c7 Mon Sep 17 00:00:00 2001
From: miaozhiyuan 
Date: Tue, 12 Sep 2023 10:51:35 +0800
Subject: [PATCH] [clang] fix lack comparison of declRefExpr in
 ASTStructuralEquivalence

---
 clang/lib/AST/ASTStructuralEquivalence.cpp| 8 
 clang/unittests/AST/StructuralEquivalenceTest.cpp | 9 +
 2 files changed, 17 insertions(+)

diff --git a/clang/lib/AST/ASTStructuralEquivalence.cpp 
b/clang/lib/AST/ASTStructuralEquivalence.cpp
index 544420234ef0eb0..f43706998dc471a 100644
--- a/clang/lib/AST/ASTStructuralEquivalence.cpp
+++ b/clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -214,6 +214,14 @@ class StmtComparer {
 return E1->size() == E2->size();
   }
 
+  bool IsStmtEquivalent(const DeclRefExpr *DRE1, const DeclRefExpr *DRE2) {
+if (nullptr == DRE1->getDecl() || nullptr == DRE2->getDecl()) {
+  return false;
+}
+return IsStructurallyEquivalent(Context, DRE1->getDecl()->getDeclName(),
+DRE2->getDecl()->getDeclName());
+  }
+
   bool IsStmtEquivalent(const DependentScopeDeclRefExpr *DE1,
 const DependentScopeDeclRefExpr *DE2) {
 if (!IsStructurallyEquivalent(Context, DE1->getDeclName(),
diff --git a/clang/unittests/AST/StructuralEquivalenceTest.cpp 
b/clang/unittests/AST/StructuralEquivalenceTest.cpp
index 4e9f476659b9ee6..5787fc5a6566617 100644
--- a/clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ b/clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -2320,5 +2320,14 @@ TEST_F(StructuralEquivalenceStmtTest, UnresolvedLookup) {
   EXPECT_TRUE(testStructuralMatch(t));
 }
 
+TEST_F(StructuralEquivalenceStmtTest, DeclRefENoEq) {
+  std::string Prefix = "enum Test { AAA, BBB };";
+  auto t = makeStmts(
+  Prefix + "void foo(int i) {if (i > 0) {i = AAA;} else {i = BBB;}}",
+  Prefix + "void foo(int i) {if (i > 0) {i = BBB;} else {i = AAA;}}",
+  Lang_CXX03, ifStmt());
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang

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


[clang] [clang] fix lack comparison of declRefExpr in ASTStructuralEquivalence (PR #66041)

2023-09-11 Thread via cfe-commits

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


[PATCH] D86310: [X86] Align i128 to 16 bytes in x86 datalayouts

2023-09-11 Thread Trevor Gross via Phabricator via cfe-commits
tmgross added a comment.

> See the source code comment I quoted in 
> https://bugs.llvm.org/show_bug.cgi?id=50198#c3: "If the target does not have 
> native f128 support, expand it to i128 and we will be generating soft float 
> library calls." This applies to x86. `f128` is expanded to `i128`, so any 
> changes to the alignment for `i128` automatically apply to `f128` as well.

Thank you for the explanation, that makes sense.

> In D86310#4516911 , @hvdijk wrote:
>
>> In D86310#4516876 , @pengfei wrote:
>>
>>> There's also concern about the alignment difference between `_BitInt(128)` 
>>> and `__int128`, see #60925 
>>> 
>>
>> That references https://gitlab.com/x86-psABIs/x86-64-ABI/-/issues/11, where 
>> the answer four months ago was basically "it's probably already too late for 
>> that" with a suggestion to try and post on the mailing list to try and 
>> convince others that this was important enough to do. Nothing was posted to 
>> the mailing list, and by now GCC has started implementing what the ABI 
>> specifies (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102989). I think we 
>> would need an extraordinary rationale if we want to convince others that the 
>> ABI should be changed.
>
> The discussion has since moved to the list 
> (https://groups.google.com/g/x86-64-abi/c/-JeR9HgUU20) and it seems as if the 
> alignment of `__int128` is fixed, no changes are planned there; if anything 
> changes, it will be the alignment of `_BitInt(128)`, and that will be 
> independent of this patch.

Agreed; LLVM is doing the wrong thing with `i128` and the correct thing for 
`_BitInt(128)`, so `_BitInt` has no bearing on this change.

> Based on this, I now do think again the right course of action is to just 
> commit this. It still applies to current LLVM without changes, and passes 
> tests.
>
> The point that is still contentious is the handling of IR generated from 
> older versions of LLVM that do not have this patch. Personally, I feel that 
> D158169  being accepted already answered 
> how to handle this. D158169  clearly broke 
> the ABI in LLVM: code generated with the current version of LLVM is not 
> binary compatible with code generated with older versions of LLVM. But that 
> is considered acceptable when the code generated by these older versions of 
> LLVM was buggy and we have no reason to expect that there is code out there 
> that relies on that bug remaining unfixed. The same logic applies here.

Also agreed with this, I think concensus on this thread seems to be in 
agreement with the current patch too. Looking forward to the land :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86310

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


[clang] [Driver] Implement ToolChain on Haiku (PR #66038)

2023-09-11 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-clang-driver


Changes

Instead of passing everything off to GCC, add a ToolChain for Haiku to allow 
Clang to properly link things on its own.
--
Full diff: https://github.com/llvm/llvm-project/pull/66038.diff

12 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+31) 
- (modified) clang/lib/Driver/ToolChains/Haiku.cpp (+137) 
- (modified) clang/lib/Driver/ToolChains/Haiku.h (+31) 
- (added) 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/lib/crti.o () 
- (added) 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/lib/crtn.o () 
- (added) 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/lib/init_term_dyn.o
 () 
- (added) 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/lib/start_dyn.o 
() 
- (added) 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/13.2.0/crtbegin.o
 () 
- (added) 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/13.2.0/crtbeginS.o
 () 
- (added) 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/13.2.0/crtend.o
 () 
- (added) 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/13.2.0/crtendS.o
 () 
- (modified) clang/test/Driver/haiku.c (+44) 



diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 7aeb8e29ebc5574..cd6713ab52d926d 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2224,6 +2224,12 @@ bool 
Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib ) const {
 void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
 const llvm::Triple , SmallVectorImpl ,
 StringRef SysRoot) {
+
+  if (TargetTriple.isOSHaiku()) {
+Prefixes.push_back(concat(SysRoot, "/boot/system/develop/tools"));
+return;
+  }
+
   if (TargetTriple.isOSSolaris()) {
 // Solaris is a special case.
 // The GCC installation is under
@@ -2426,6 +2432,31 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   using std::begin;
   using std::end;
 
+  if (TargetTriple.isOSHaiku()) {
+static const char *const HaikuLibDirs[] = {"/lib"};
+static const char *const HaikuAArch64Triples[] = {"aarch64-unknown-haiku"};
+static const char *const HaikuRISCV64Triples[] = {"riscv64-unknown-haiku"};
+static const char *const HaikuX86Triples[] = {"i586-unknown-haiku"};
+static const char *const HaikuX86_64Triples[] = {"x86_64-unknown-haiku"};
+LibDirs.append(begin(HaikuLibDirs), end(HaikuLibDirs));
+switch (TargetTriple.getArch()) {
+case llvm::Triple::aarch64:
+  TripleAliases.append(begin(HaikuAArch64Triples), 
end(HaikuAArch64Triples));
+  break;
+case llvm::Triple::riscv64:
+  TripleAliases.append(begin(HaikuRISCV64Triples), 
end(HaikuRISCV64Triples));
+  break;
+case llvm::Triple::x86:
+  TripleAliases.append(begin(HaikuX86Triples), end(HaikuX86Triples));
+  break;
+case llvm::Triple::x86_64:
+  TripleAliases.append(begin(HaikuX86_64Triples), end(HaikuX86_64Triples));
+  break;
+default:
+  break;
+}
+  }
+
   if (TargetTriple.isOSSolaris()) {
 static const char *const SolarisLibDirs[] = {"/lib"};
 static const char *const SolarisSparcV8Triples[] = {
diff --git a/clang/lib/Driver/ToolChains/Haiku.cpp 
b/clang/lib/Driver/ToolChains/Haiku.cpp
index 55fc0533f699fab..3def1c7b67a30a9 100644
--- a/clang/lib/Driver/ToolChains/Haiku.cpp
+++ b/clang/lib/Driver/ToolChains/Haiku.cpp
@@ -9,20 +9,145 @@
 #include "Haiku.h"
 #include "CommonArgs.h"
 #include "clang/Config/config.h"
+#include "clang/Driver/Compilation.h"
 #include "llvm/Support/Path.h"
 
 using namespace clang::driver;
+using namespace clang::driver::tools;
 using namespace clang::driver::toolchains;
 using namespace clang;
 using namespace llvm::opt;
 
+void haiku::Linker::ConstructJob(Compilation , const JobAction ,
+   const InputInfo ,
+   const InputInfoList ,
+   const ArgList ,
+   const char *LinkingOutput) const {
+  const toolchains::Haiku  =
+  static_cast(getToolChain());
+  const Driver  = ToolChain.getDriver();
+  const llvm::Triple::ArchType Arch = ToolChain.getArch();
+  const bool Static = Args.hasArg(options::OPT_static);
+  const bool Shared = Args.hasArg(options::OPT_shared);
+  ArgStringList CmdArgs;
+
+  // Silence warning for "clang -g foo.o -o foo"
+  Args.ClaimAllArgs(options::OPT_g_Group);
+  // and "clang -emit-llvm foo.o -o foo"
+  Args.ClaimAllArgs(options::OPT_emit_llvm);
+  // and for "clang -w foo.o -o foo". Other warning options are already
+  // handled somewhere else.
+  Args.ClaimAllArgs(options::OPT_w);
+
+  // Silence warning for "clang -pie foo.o -o foo"
+  

[clang] [Driver] Implement ToolChain on Haiku (PR #66038)

2023-09-11 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-clang


Changes

Instead of passing everything off to GCC, add a ToolChain for Haiku to allow 
Clang to properly link things on its own.
--
Full diff: https://github.com/llvm/llvm-project/pull/66038.diff

12 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+31) 
- (modified) clang/lib/Driver/ToolChains/Haiku.cpp (+137) 
- (modified) clang/lib/Driver/ToolChains/Haiku.h (+31) 
- (added) 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/lib/crti.o () 
- (added) 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/lib/crtn.o () 
- (added) 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/lib/init_term_dyn.o
 () 
- (added) 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/lib/start_dyn.o 
() 
- (added) 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/13.2.0/crtbegin.o
 () 
- (added) 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/13.2.0/crtbeginS.o
 () 
- (added) 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/13.2.0/crtend.o
 () 
- (added) 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/13.2.0/crtendS.o
 () 
- (modified) clang/test/Driver/haiku.c (+44) 



diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 7aeb8e29ebc5574..cd6713ab52d926d 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2224,6 +2224,12 @@ bool 
Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib ) const {
 void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
 const llvm::Triple , SmallVectorImpl ,
 StringRef SysRoot) {
+
+  if (TargetTriple.isOSHaiku()) {
+Prefixes.push_back(concat(SysRoot, "/boot/system/develop/tools"));
+return;
+  }
+
   if (TargetTriple.isOSSolaris()) {
 // Solaris is a special case.
 // The GCC installation is under
@@ -2426,6 +2432,31 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   using std::begin;
   using std::end;
 
+  if (TargetTriple.isOSHaiku()) {
+static const char *const HaikuLibDirs[] = {"/lib"};
+static const char *const HaikuAArch64Triples[] = {"aarch64-unknown-haiku"};
+static const char *const HaikuRISCV64Triples[] = {"riscv64-unknown-haiku"};
+static const char *const HaikuX86Triples[] = {"i586-unknown-haiku"};
+static const char *const HaikuX86_64Triples[] = {"x86_64-unknown-haiku"};
+LibDirs.append(begin(HaikuLibDirs), end(HaikuLibDirs));
+switch (TargetTriple.getArch()) {
+case llvm::Triple::aarch64:
+  TripleAliases.append(begin(HaikuAArch64Triples), 
end(HaikuAArch64Triples));
+  break;
+case llvm::Triple::riscv64:
+  TripleAliases.append(begin(HaikuRISCV64Triples), 
end(HaikuRISCV64Triples));
+  break;
+case llvm::Triple::x86:
+  TripleAliases.append(begin(HaikuX86Triples), end(HaikuX86Triples));
+  break;
+case llvm::Triple::x86_64:
+  TripleAliases.append(begin(HaikuX86_64Triples), end(HaikuX86_64Triples));
+  break;
+default:
+  break;
+}
+  }
+
   if (TargetTriple.isOSSolaris()) {
 static const char *const SolarisLibDirs[] = {"/lib"};
 static const char *const SolarisSparcV8Triples[] = {
diff --git a/clang/lib/Driver/ToolChains/Haiku.cpp 
b/clang/lib/Driver/ToolChains/Haiku.cpp
index 55fc0533f699fab..3def1c7b67a30a9 100644
--- a/clang/lib/Driver/ToolChains/Haiku.cpp
+++ b/clang/lib/Driver/ToolChains/Haiku.cpp
@@ -9,20 +9,145 @@
 #include "Haiku.h"
 #include "CommonArgs.h"
 #include "clang/Config/config.h"
+#include "clang/Driver/Compilation.h"
 #include "llvm/Support/Path.h"
 
 using namespace clang::driver;
+using namespace clang::driver::tools;
 using namespace clang::driver::toolchains;
 using namespace clang;
 using namespace llvm::opt;
 
+void haiku::Linker::ConstructJob(Compilation , const JobAction ,
+   const InputInfo ,
+   const InputInfoList ,
+   const ArgList ,
+   const char *LinkingOutput) const {
+  const toolchains::Haiku  =
+  static_cast(getToolChain());
+  const Driver  = ToolChain.getDriver();
+  const llvm::Triple::ArchType Arch = ToolChain.getArch();
+  const bool Static = Args.hasArg(options::OPT_static);
+  const bool Shared = Args.hasArg(options::OPT_shared);
+  ArgStringList CmdArgs;
+
+  // Silence warning for "clang -g foo.o -o foo"
+  Args.ClaimAllArgs(options::OPT_g_Group);
+  // and "clang -emit-llvm foo.o -o foo"
+  Args.ClaimAllArgs(options::OPT_emit_llvm);
+  // and for "clang -w foo.o -o foo". Other warning options are already
+  // handled somewhere else.
+  Args.ClaimAllArgs(options::OPT_w);
+
+  // Silence warning for "clang -pie foo.o -o foo"
+  

[clang] [Driver] Implement ToolChain on Haiku (PR #66038)

2023-09-11 Thread via cfe-commits

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


[clang] [Driver] Implement ToolChain on Haiku (PR #66038)

2023-09-11 Thread via cfe-commits

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


[clang] [Driver] Implement ToolChain on Haiku (PR #66038)

2023-09-11 Thread Brad Smith via cfe-commits

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


[clang] [Driver] Implement ToolChain on Haiku (PR #66038)

2023-09-11 Thread Brad Smith via cfe-commits

https://github.com/brad0 created 
https://github.com/llvm/llvm-project/pull/66038:

Instead of passing everything off to GCC, add a ToolChain for Haiku to allow 
Clang to properly link things on its own.

>From 789c663c84322e509e8e6e270159878e86cfdefa Mon Sep 17 00:00:00 2001
From: X512 
Date: Mon, 11 Sep 2023 20:56:02 -0400
Subject: [PATCH] [Driver] Implement ToolChain on Haiku

Co-authored-by: David Karoly 
Co-authored-by: Brad Smith 
---
 clang/lib/Driver/ToolChains/Gnu.cpp   |  31 
 clang/lib/Driver/ToolChains/Haiku.cpp | 137 ++
 clang/lib/Driver/ToolChains/Haiku.h   |  31 
 .../boot/system/develop/lib/crti.o|   0
 .../boot/system/develop/lib/crtn.o|   0
 .../boot/system/develop/lib/init_term_dyn.o   |   0
 .../boot/system/develop/lib/start_dyn.o   |   0
 .../x86_64-unknown-haiku/13.2.0/crtbegin.o|   0
 .../x86_64-unknown-haiku/13.2.0/crtbeginS.o   |   0
 .../gcc/x86_64-unknown-haiku/13.2.0/crtend.o  |   0
 .../gcc/x86_64-unknown-haiku/13.2.0/crtendS.o |   0
 clang/test/Driver/haiku.c |  44 ++
 12 files changed, 243 insertions(+)
 create mode 100644 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/lib/crti.o
 create mode 100644 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/lib/crtn.o
 create mode 100644 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/lib/init_term_dyn.o
 create mode 100644 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/lib/start_dyn.o
 create mode 100644 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/13.2.0/crtbegin.o
 create mode 100644 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/13.2.0/crtbeginS.o
 create mode 100644 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/13.2.0/crtend.o
 create mode 100644 
clang/test/Driver/Inputs/haiku_x86_64_tree/boot/system/develop/tools/lib/gcc/x86_64-unknown-haiku/13.2.0/crtendS.o

diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 7aeb8e29ebc5574..cd6713ab52d926d 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2224,6 +2224,12 @@ bool 
Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib ) const {
 void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
 const llvm::Triple , SmallVectorImpl ,
 StringRef SysRoot) {
+
+  if (TargetTriple.isOSHaiku()) {
+Prefixes.push_back(concat(SysRoot, "/boot/system/develop/tools"));
+return;
+  }
+
   if (TargetTriple.isOSSolaris()) {
 // Solaris is a special case.
 // The GCC installation is under
@@ -2426,6 +2432,31 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   using std::begin;
   using std::end;
 
+  if (TargetTriple.isOSHaiku()) {
+static const char *const HaikuLibDirs[] = {"/lib"};
+static const char *const HaikuAArch64Triples[] = {"aarch64-unknown-haiku"};
+static const char *const HaikuRISCV64Triples[] = {"riscv64-unknown-haiku"};
+static const char *const HaikuX86Triples[] = {"i586-unknown-haiku"};
+static const char *const HaikuX86_64Triples[] = {"x86_64-unknown-haiku"};
+LibDirs.append(begin(HaikuLibDirs), end(HaikuLibDirs));
+switch (TargetTriple.getArch()) {
+case llvm::Triple::aarch64:
+  TripleAliases.append(begin(HaikuAArch64Triples), 
end(HaikuAArch64Triples));
+  break;
+case llvm::Triple::riscv64:
+  TripleAliases.append(begin(HaikuRISCV64Triples), 
end(HaikuRISCV64Triples));
+  break;
+case llvm::Triple::x86:
+  TripleAliases.append(begin(HaikuX86Triples), end(HaikuX86Triples));
+  break;
+case llvm::Triple::x86_64:
+  TripleAliases.append(begin(HaikuX86_64Triples), end(HaikuX86_64Triples));
+  break;
+default:
+  break;
+}
+  }
+
   if (TargetTriple.isOSSolaris()) {
 static const char *const SolarisLibDirs[] = {"/lib"};
 static const char *const SolarisSparcV8Triples[] = {
diff --git a/clang/lib/Driver/ToolChains/Haiku.cpp 
b/clang/lib/Driver/ToolChains/Haiku.cpp
index 55fc0533f699fab..3def1c7b67a30a9 100644
--- a/clang/lib/Driver/ToolChains/Haiku.cpp
+++ b/clang/lib/Driver/ToolChains/Haiku.cpp
@@ -9,20 +9,145 @@
 #include "Haiku.h"
 #include "CommonArgs.h"
 #include "clang/Config/config.h"
+#include "clang/Driver/Compilation.h"
 #include "llvm/Support/Path.h"
 
 using namespace clang::driver;
+using namespace clang::driver::tools;
 using namespace clang::driver::toolchains;
 using namespace clang;
 using namespace llvm::opt;
 
+void haiku::Linker::ConstructJob(Compilation , const JobAction ,
+   const InputInfo ,
+   const InputInfoList ,
+   const ArgList ,
+   const char *LinkingOutput) 

[clang] 2bdf5aa - [Driver] Properly report error for unsupported powerpc darwin/macos triples

2023-09-11 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-09-11T18:53:51-07:00
New Revision: 2bdf5aa5debf6e3b1afe588db990ca58e55c

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

LOG: [Driver] Properly report error for unsupported powerpc darwin/macos triples

The removal started at https://reviews.llvm.org/D50989 and
https://reviews.llvm.org/D75494 removed the Triple support. Without recognizing
Darwin triples as Mach-O, we will get assertion error in ToolChains/Darwin.h due
to the universal binary mechanism.

Fix #47698

---

This requires fixing many misuses of llc -march= and llvm-mc -arch= (
commits 806761a7629df268c8aed49657aeccffa6bca449 and 
252c42354eca54274ed7b10c32c73c6937478e8b).

Added: 


Modified: 
clang/test/Driver/unsupported-target-arch.c
llvm/lib/TargetParser/Triple.cpp
llvm/unittests/TargetParser/TripleTest.cpp

Removed: 




diff  --git a/clang/test/Driver/unsupported-target-arch.c 
b/clang/test/Driver/unsupported-target-arch.c
index 24174650151f1ce..8df0ee9fe7d06f1 100644
--- a/clang/test/Driver/unsupported-target-arch.c
+++ b/clang/test/Driver/unsupported-target-arch.c
@@ -59,3 +59,7 @@
 // RUN: not %clang --target=thumbeb-none-elf -o %t.o %s 2> %t.err
 // RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-THUMBEB-INVALID-ENV 
%s
 // CHECK-THUMBEB-INVALID-ENV: warning: mismatch between architecture and 
environment in target triple 'thumbeb-none-elf'; did you mean 
'thumbeb-none-eabi'? [-Winvalid-command-line-argument]{{$}}
+
+// RUN: not %clang --target=powerpc-apple-darwin -o /dev/null %s 2> %t.err
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-PPCMAC %s
+// CHECK-PPCMAC: error: unknown target triple 'unknown-apple-macosx{{.*}}'

diff  --git a/llvm/lib/TargetParser/Triple.cpp 
b/llvm/lib/TargetParser/Triple.cpp
index 260819d4a83d5a2..3da145f3b0b8927 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -787,6 +787,8 @@ static Triple::SubArchType parseSubArch(StringRef 
SubArchName) {
 }
 
 static Triple::ObjectFormatType getDefaultFormat(const Triple ) {
+  if (T.isOSDarwin())
+return Triple::MachO;
   switch (T.getArch()) {
   case Triple::UnknownArch:
   case Triple::aarch64:
@@ -795,9 +797,7 @@ static Triple::ObjectFormatType getDefaultFormat(const 
Triple ) {
   case Triple::thumb:
   case Triple::x86:
   case Triple::x86_64:
-if (T.isOSDarwin())
-  return Triple::MachO;
-else if (T.isOSWindows())
+if (T.isOSWindows())
   return Triple::COFF;
 return Triple::ELF;
 

diff  --git a/llvm/unittests/TargetParser/TripleTest.cpp 
b/llvm/unittests/TargetParser/TripleTest.cpp
index dae5a82ff491860..2b2ec73fcb8a926 100644
--- a/llvm/unittests/TargetParser/TripleTest.cpp
+++ b/llvm/unittests/TargetParser/TripleTest.cpp
@@ -1937,6 +1937,7 @@ TEST(TripleTest, FileFormat) {
   EXPECT_EQ(Triple::MachO, Triple("i686-apple-macosx").getObjectFormat());
   EXPECT_EQ(Triple::MachO, Triple("i686-apple-ios").getObjectFormat());
   EXPECT_EQ(Triple::MachO, Triple("i686---macho").getObjectFormat());
+  EXPECT_EQ(Triple::MachO, Triple("powerpc-apple-macosx").getObjectFormat());
 
   EXPECT_EQ(Triple::COFF, Triple("i686--win32").getObjectFormat());
 



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


[clang] [AArch64][PAC] Support ptrauth builtins and -fptrauth-intrinsics. (PR #65996)

2023-09-11 Thread Chuanqi Xu via cfe-commits


@@ -303,6 +303,10 @@ bool Module::directlyUses(const Module *Requested) {
   if (!Requested->Parent && Requested->Name == "_Builtin_stddef_max_align_t")
 return true;
 
+  // Anyone is allowed to use our builtin ptrauth.h and its accompanying 
module.
+  if (!Requested->Parent && Requested->Name == "ptrauth")

ChuanqiXu9 wrote:

While I haven't understood the patch fully, I believe hardcoding the module 
name in such a style is not good.

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


[clang] [AArch64][PAC] Support ptrauth builtins and -fptrauth-intrinsics. (PR #65996)

2023-09-11 Thread Chuanqi Xu via cfe-commits

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


[clang] [AArch64][PAC] Support ptrauth builtins and -fptrauth-intrinsics. (PR #65996)

2023-09-11 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 requested changes to this pull request.


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


[clang] [libc++] Implement ranges::contains (PR #65148)

2023-09-11 Thread via cfe-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/65148:

>From 02e9afd761228f401df4d9f8dfaaca44ffae0c6e Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 31 Aug 2023 20:08:32 +
Subject: [PATCH 1/8] [libc++] Implement ranges::contains

Differential Revision: https://reviews.llvm.org/D159232
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__algorithm/ranges_contains.h  |  60 ++
 libcxx/include/algorithm  |   9 +
 ...obust_against_copying_projections.pass.cpp |   4 +
 .../alg.contains/ranges.contains.pass.cpp | 190 ++
 .../niebloid.compile.pass.cpp |   1 +
 6 files changed, 265 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 77a7269121ec142..024aa8959fb7200 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -104,6 +104,7 @@ set(files
   __algorithm/ranges_any_of.h
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
+  __algorithm/ranges_contains.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains.h 
b/libcxx/include/__algorithm/ranges_contains.h
new file mode 100644
index 000..647b7ea34be3421
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains.h
@@ -0,0 +1,60 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+
+#include <__algorithm/in_in_result.h>
+#include <__algorithm/ranges_find.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains {
+struct __fn {
+  template  _Sent, class _Type, 
class _Proj = identity>
+requires indirect_binary_predicate, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = 
{}) const {
+return ranges::find(std::move(__first), std::move(__last), __value, 
std::ref(__proj)) != __last;
+  }
+
+  template 
+requires indirect_binary_predicate, _Proj>, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
+return ranges::find(ranges::begin(__range), ranges::end(__range), __value, 
std::ref(__proj)) != ranges::end(__range);
+  }
+};
+} // namespace __contains
+inline namespace __cpo {
+inline constexpr auto contains = __contains::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 76e0d22bf73ef85..003bf132b38b4d8 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -226,6 +226,14 @@ namespace ranges {
   template
 using copy_backward_result = in_out_result;
 // since C++20
 
+  template S, class T, class Proj = identity>
+requires indirect_binary_predicate, 
const T*>
+constexpr bool ranges::contains(I first, S last, const T& value, Proj proj 
= {});   // since C++23
+
+  template
+requires indirect_binary_predicate, Proj>, const T*>
+constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {});
 // since C++23
+
   template S, weakly_incrementable O>
 requires indirectly_copyable
 constexpr ranges::copy_result ranges::copy(I first, S last, O 
result);// since C++20
@@ -1827,6 +1835,7 @@ template 
 #include <__algorithm/ranges_any_of.h>
 #include <__algorithm/ranges_binary_search.h>
 #include <__algorithm/ranges_clamp.h>
+#include <__algorithm/ranges_contains.h>
 #include <__algorithm/ranges_copy.h>
 #include <__algorithm/ranges_copy_backward.h>
 #include <__algorithm/ranges_copy_if.h>
diff --git 

[clang-tools-extra] [libc++] Implement ranges::contains (PR #65148)

2023-09-11 Thread via cfe-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/65148:

>From 02e9afd761228f401df4d9f8dfaaca44ffae0c6e Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 31 Aug 2023 20:08:32 +
Subject: [PATCH 1/8] [libc++] Implement ranges::contains

Differential Revision: https://reviews.llvm.org/D159232
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__algorithm/ranges_contains.h  |  60 ++
 libcxx/include/algorithm  |   9 +
 ...obust_against_copying_projections.pass.cpp |   4 +
 .../alg.contains/ranges.contains.pass.cpp | 190 ++
 .../niebloid.compile.pass.cpp |   1 +
 6 files changed, 265 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 77a7269121ec142..024aa8959fb7200 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -104,6 +104,7 @@ set(files
   __algorithm/ranges_any_of.h
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
+  __algorithm/ranges_contains.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains.h 
b/libcxx/include/__algorithm/ranges_contains.h
new file mode 100644
index 000..647b7ea34be3421
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains.h
@@ -0,0 +1,60 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+
+#include <__algorithm/in_in_result.h>
+#include <__algorithm/ranges_find.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains {
+struct __fn {
+  template  _Sent, class _Type, 
class _Proj = identity>
+requires indirect_binary_predicate, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = 
{}) const {
+return ranges::find(std::move(__first), std::move(__last), __value, 
std::ref(__proj)) != __last;
+  }
+
+  template 
+requires indirect_binary_predicate, _Proj>, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
+return ranges::find(ranges::begin(__range), ranges::end(__range), __value, 
std::ref(__proj)) != ranges::end(__range);
+  }
+};
+} // namespace __contains
+inline namespace __cpo {
+inline constexpr auto contains = __contains::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 76e0d22bf73ef85..003bf132b38b4d8 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -226,6 +226,14 @@ namespace ranges {
   template
 using copy_backward_result = in_out_result;
 // since C++20
 
+  template S, class T, class Proj = identity>
+requires indirect_binary_predicate, 
const T*>
+constexpr bool ranges::contains(I first, S last, const T& value, Proj proj 
= {});   // since C++23
+
+  template
+requires indirect_binary_predicate, Proj>, const T*>
+constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {});
 // since C++23
+
   template S, weakly_incrementable O>
 requires indirectly_copyable
 constexpr ranges::copy_result ranges::copy(I first, S last, O 
result);// since C++20
@@ -1827,6 +1835,7 @@ template 
 #include <__algorithm/ranges_any_of.h>
 #include <__algorithm/ranges_binary_search.h>
 #include <__algorithm/ranges_clamp.h>
+#include <__algorithm/ranges_contains.h>
 #include <__algorithm/ranges_copy.h>
 #include <__algorithm/ranges_copy_backward.h>
 #include <__algorithm/ranges_copy_if.h>
diff --git 

[PATCH] D86310: [X86] Align i128 to 16 bytes in x86 datalayouts

2023-09-11 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk added a comment.

In D86310#4605475 , @tmgross wrote:

> In D86310#4597359 , @hvdijk wrote:
>
>> In D86310#4596841 , @tmgross wrote:
>>
>>> I think that D158169  seems to have fixed 
>>> clang as well; after applying both patches, clang gcc and rustc all seem to 
>>> agree.
>>
>> Interesting. I cannot see how it would, I may be missing something; I will 
>> check when I am able.
>
> D158169  landed today, I confirmed that the 
> current main (with D158169 ) makes Clang 
> <-> GCC works but LLVM still fails without this patch.

I had hoped to avoid the piecewise ABI breakage, but with that already having 
landed, we already have that anyway, so I no longer see a reason to delay this 
until we can also fix `va_arg`.

> Doesn't clang just wind up going through the same tablegen as LLVM, so it 
> makes sense that both would be fixed?

Actually able to look into this now again, and yes, it does. I was sure I'd 
seen clang expand `__int128` so that at the LLVM level, there was no longer any 
`i128`, but it does not happen here, and because it does not happen here, this 
patch does fix it.

>>> Was your failure in https://bugs.llvm.org/show_bug.cgi?id=50198 fixed with 
>>> these patches?
>>
>> Yes, it was (at least it was at the time that I initially commented).
>
> You mean this patch only right - how does that work? Looking closer at your 
> comments there, it doesn't seem like `i128` changes would affect anything if 
> the `f128` return alignment is the source of the problem.

See the source code comment I quoted in 
https://bugs.llvm.org/show_bug.cgi?id=50198#c3: "If the target does not have 
native f128 support, expand it to i128 and we will be generating soft float 
library calls." This applies to x86. `f128` is expanded to `i128`, so any 
changes to the alignment for `i128` automatically apply to `f128` as well.

In D86310#4516911 , @hvdijk wrote:

> In D86310#4516876 , @pengfei wrote:
>
>> There's also concern about the alignment difference between `_BitInt(128)` 
>> and `__int128`, see #60925 
>> 
>
> That references https://gitlab.com/x86-psABIs/x86-64-ABI/-/issues/11, where 
> the answer four months ago was basically "it's probably already too late for 
> that" with a suggestion to try and post on the mailing list to try and 
> convince others that this was important enough to do. Nothing was posted to 
> the mailing list, and by now GCC has started implementing what the ABI 
> specifies (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102989). I think we 
> would need an extraordinary rationale if we want to convince others that the 
> ABI should be changed.

The discussion has since moved to the list 
(https://groups.google.com/g/x86-64-abi/c/-JeR9HgUU20) and it seems as if the 
alignment of `__int128` is fixed, no changes are planned there; if anything 
changes, it will be the alignment of `_BitInt(128)`, and that will be 
independent of this patch.

Based on this, I now do think again the right course of action is to just 
commit this. It still applies to current LLVM without changes, and passes tests.

The point that is still contentious is the handling of IR generated from older 
versions of LLVM that do not have this patch. Personally, I feel that D158169 
 being accepted already answered how to 
handle this. D158169  clearly broke the ABI 
in LLVM: code generated with the current version of LLVM is not binary 
compatible with code generated with older versions of LLVM. But that is 
considered acceptable when the code generated by these older versions of LLVM 
was buggy and we have no reason to expect that there is code out there that 
relies on that bug remaining unfixed. The same logic applies here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86310

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


[clang] [libc++] Implement ranges::contains (PR #65148)

2023-09-11 Thread via cfe-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/65148:

>From 02e9afd761228f401df4d9f8dfaaca44ffae0c6e Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 31 Aug 2023 20:08:32 +
Subject: [PATCH 1/7] [libc++] Implement ranges::contains

Differential Revision: https://reviews.llvm.org/D159232
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__algorithm/ranges_contains.h  |  60 ++
 libcxx/include/algorithm  |   9 +
 ...obust_against_copying_projections.pass.cpp |   4 +
 .../alg.contains/ranges.contains.pass.cpp | 190 ++
 .../niebloid.compile.pass.cpp |   1 +
 6 files changed, 265 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 77a7269121ec142..024aa8959fb7200 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -104,6 +104,7 @@ set(files
   __algorithm/ranges_any_of.h
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
+  __algorithm/ranges_contains.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains.h 
b/libcxx/include/__algorithm/ranges_contains.h
new file mode 100644
index 000..647b7ea34be3421
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains.h
@@ -0,0 +1,60 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+
+#include <__algorithm/in_in_result.h>
+#include <__algorithm/ranges_find.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains {
+struct __fn {
+  template  _Sent, class _Type, 
class _Proj = identity>
+requires indirect_binary_predicate, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = 
{}) const {
+return ranges::find(std::move(__first), std::move(__last), __value, 
std::ref(__proj)) != __last;
+  }
+
+  template 
+requires indirect_binary_predicate, _Proj>, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
+return ranges::find(ranges::begin(__range), ranges::end(__range), __value, 
std::ref(__proj)) != ranges::end(__range);
+  }
+};
+} // namespace __contains
+inline namespace __cpo {
+inline constexpr auto contains = __contains::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 76e0d22bf73ef85..003bf132b38b4d8 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -226,6 +226,14 @@ namespace ranges {
   template
 using copy_backward_result = in_out_result;
 // since C++20
 
+  template S, class T, class Proj = identity>
+requires indirect_binary_predicate, 
const T*>
+constexpr bool ranges::contains(I first, S last, const T& value, Proj proj 
= {});   // since C++23
+
+  template
+requires indirect_binary_predicate, Proj>, const T*>
+constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {});
 // since C++23
+
   template S, weakly_incrementable O>
 requires indirectly_copyable
 constexpr ranges::copy_result ranges::copy(I first, S last, O 
result);// since C++20
@@ -1827,6 +1835,7 @@ template 
 #include <__algorithm/ranges_any_of.h>
 #include <__algorithm/ranges_binary_search.h>
 #include <__algorithm/ranges_clamp.h>
+#include <__algorithm/ranges_contains.h>
 #include <__algorithm/ranges_copy.h>
 #include <__algorithm/ranges_copy_backward.h>
 #include <__algorithm/ranges_copy_if.h>
diff --git 

[clang-tools-extra] [libc++] Implement ranges::contains (PR #65148)

2023-09-11 Thread via cfe-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/65148:

>From 02e9afd761228f401df4d9f8dfaaca44ffae0c6e Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 31 Aug 2023 20:08:32 +
Subject: [PATCH 1/7] [libc++] Implement ranges::contains

Differential Revision: https://reviews.llvm.org/D159232
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__algorithm/ranges_contains.h  |  60 ++
 libcxx/include/algorithm  |   9 +
 ...obust_against_copying_projections.pass.cpp |   4 +
 .../alg.contains/ranges.contains.pass.cpp | 190 ++
 .../niebloid.compile.pass.cpp |   1 +
 6 files changed, 265 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 77a7269121ec142..024aa8959fb7200 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -104,6 +104,7 @@ set(files
   __algorithm/ranges_any_of.h
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
+  __algorithm/ranges_contains.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains.h 
b/libcxx/include/__algorithm/ranges_contains.h
new file mode 100644
index 000..647b7ea34be3421
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains.h
@@ -0,0 +1,60 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+
+#include <__algorithm/in_in_result.h>
+#include <__algorithm/ranges_find.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains {
+struct __fn {
+  template  _Sent, class _Type, 
class _Proj = identity>
+requires indirect_binary_predicate, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = 
{}) const {
+return ranges::find(std::move(__first), std::move(__last), __value, 
std::ref(__proj)) != __last;
+  }
+
+  template 
+requires indirect_binary_predicate, _Proj>, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
+return ranges::find(ranges::begin(__range), ranges::end(__range), __value, 
std::ref(__proj)) != ranges::end(__range);
+  }
+};
+} // namespace __contains
+inline namespace __cpo {
+inline constexpr auto contains = __contains::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 76e0d22bf73ef85..003bf132b38b4d8 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -226,6 +226,14 @@ namespace ranges {
   template
 using copy_backward_result = in_out_result;
 // since C++20
 
+  template S, class T, class Proj = identity>
+requires indirect_binary_predicate, 
const T*>
+constexpr bool ranges::contains(I first, S last, const T& value, Proj proj 
= {});   // since C++23
+
+  template
+requires indirect_binary_predicate, Proj>, const T*>
+constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {});
 // since C++23
+
   template S, weakly_incrementable O>
 requires indirectly_copyable
 constexpr ranges::copy_result ranges::copy(I first, S last, O 
result);// since C++20
@@ -1827,6 +1835,7 @@ template 
 #include <__algorithm/ranges_any_of.h>
 #include <__algorithm/ranges_binary_search.h>
 #include <__algorithm/ranges_clamp.h>
+#include <__algorithm/ranges_contains.h>
 #include <__algorithm/ranges_copy.h>
 #include <__algorithm/ranges_copy_backward.h>
 #include <__algorithm/ranges_copy_if.h>
diff --git 

[PATCH] D159103: [Driver][HLSL] Improve diagnostics for invalid shader model and stage

2023-09-11 Thread Justin Bogner via Phabricator via cfe-commits
bogner added a subscriber: Keenuts.
bogner added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:4146
   if (Opts.HLSL) {
-bool SupportedTarget = (T.getArch() == llvm::Triple::dxil ||
-T.getArch() == llvm::Triple::spirv) &&
-   T.getOS() == llvm::Triple::ShaderModel;
-if (!SupportedTarget)
+if (T.isDXIL() || T.isSPIRV) {
+  enum { ShaderModel, ShaderStage };

@Keenuts Does this look right, or do we want something like `T.isSPIRVLogical` 
here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159103

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


[PATCH] D159103: [Driver][HLSL] Improve diagnostics for invalid shader model and stage

2023-09-11 Thread Justin Bogner via Phabricator via cfe-commits
bogner updated this revision to Diff 556512.
bogner added a comment.

Rebased to fix conflicts


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159103

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Driver/hlsl-lang-targets.hlsl
  llvm/include/llvm/TargetParser/Triple.h

Index: llvm/include/llvm/TargetParser/Triple.h
===
--- llvm/include/llvm/TargetParser/Triple.h
+++ llvm/include/llvm/TargetParser/Triple.h
@@ -271,7 +271,9 @@
 Callable,
 Mesh,
 Amplification,
+
 OpenHOS,
+
 LastEnvironmentType = OpenHOS
   };
   enum ObjectFormatType {
@@ -756,6 +758,22 @@
 return getArch() == Triple::dxil;
   }
 
+  bool isShaderModelOS() const {
+return getOS() == Triple::ShaderModel;
+  }
+
+  bool isShaderStageEnvironment() const {
+EnvironmentType Env = getEnvironment();
+return Env == Triple::Pixel || Env == Triple::Vertex ||
+   Env == Triple::Geometry || Env == Triple::Hull ||
+   Env == Triple::Domain || Env == Triple::Compute ||
+   Env == Triple::Library || Env == Triple::RayGeneration ||
+   Env == Triple::Intersection || Env == Triple::AnyHit ||
+   Env == Triple::ClosestHit || Env == Triple::Miss ||
+   Env == Triple::Callable || Env == Triple::Mesh ||
+   Env == Triple::Amplification;
+  }
+
   /// Tests whether the target is SPIR (32- or 64-bit).
   bool isSPIR() const {
 return getArch() == Triple::spir || getArch() == Triple::spir64;
Index: clang/test/Driver/hlsl-lang-targets.hlsl
===
--- clang/test/Driver/hlsl-lang-targets.hlsl
+++ clang/test/Driver/hlsl-lang-targets.hlsl
@@ -1,14 +1,52 @@
-// RUN: not %clang -target x86_64-unknown-unknown %s 2>&1 | FileCheck %s --check-prefix=X86
-// RUN: not %clang -target dxil-unknown-unknown %s 2>&1 | FileCheck %s --check-prefix=DXIL
-// RUN: not %clang -target x86_64-unknown-shadermodel %s 2>&1 | FileCheck %s --check-prefix=SM
-// RUN: not %clang -target spirv64-unknown-unknown %s 2>&1 | FileCheck %s --check-prefix=SPIRV
+// Supported targets
+//
+// RUN: %clang -target dxil--shadermodel6.2-pixel %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-VALID %s
+// RUN: %clang -target dxil-unknown-shadermodel6.2-pixel %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-VALID %s
+// RUN: %clang -target dxil--shadermodel6.2-library %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-VALID %s
+// RUN: %clang -target dxil-unknown-shadermodel6.2-library %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-VALID %s
 
+// Empty shader model
+//
+// RUN: not %clang -target dxil %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-NO-OS %s
 
-// A completely unsupported target...
-// X86: error: HLSL code generation is unsupported for target 'x86_64-unknown-unknown'
+// Invalid shader models
+//
+// RUN: not %clang -target dxil--linux %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-BAD-OS %s
+// RUN: not %clang -target dxil--win32 %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-BAD-OS %s
+// RUN: not %clang -target dxil--unknown %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-BAD-OS %s
+// RUN: not %clang -target dxil--invalidos %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-BAD-OS %s
 
-// Poorly specified targets
-// DXIL: error: HLSL code generation is unsupported for target 'dxil-unknown-unknown'
-// SM: error: HLSL code generation is unsupported for target 'x86_64-unknown-shadermodel'
+// Bad shader model versions. Currently we just check for any version at all.
+//
+// RUN: not %clang -target dxil--shadermodel %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-BAD-OS %s
+// RUN: not %clang -target dxil--shadermodel0.0 %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-BAD-OS %s
 
-// FIXME// SPIRV: error: HLSL code generation is unsupported for target 'spirv64-unknown-unknown'
+// Empty shader stage
+//
+// RUN: not %clang -target dxil-shadermodel6.2 %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-NO-ENV %s
+// RUN: not %clang -target dxil--shadermodel6.2 %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-NO-ENV %s
+// RUN: not %clang -target dxil--shadermodel6.2 %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-NO-ENV %s
+
+// Invalid shader stages
+//
+// RUN: not %clang -target dxil--shadermodel6.2-unknown %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-BAD-ENV %s
+// RUN: not %clang -target dxil--shadermodel6.2-invalidenvironment %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-BAD-ENV %s
+// RUN: not %clang -target dxil--shadermodel6.2-eabi %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-BAD-ENV %s
+// RUN: not %clang -target 

[clang] [dataflow] Add global condition to DataflowAnalysisContext (PR #65949)

2023-09-11 Thread Gábor Horváth via cfe-commits


@@ -108,6 +108,16 @@ class DataflowAnalysisContext {
   /// A null `PointeeType` can be used for the pointee of `std::nullptr_t`.
   PointerValue (QualType PointeeType);
 
+  /// Adds `Constraint` to current and future flow conditions in this context.
+  ///
+  /// The global condition must contain only flow-insensitive information, i.e.

Xazax-hun wrote:

I wonder if `GlobalConstraint` is a bit vague. How about something like 
`addFlowInsensitiveInvariant`. This makes part of the comment unnecessary. 

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


[clang] [dataflow] Add global condition to DataflowAnalysisContext (PR #65949)

2023-09-11 Thread Gábor Horváth via cfe-commits


@@ -150,7 +157,7 @@ bool DataflowAnalysisContext::flowConditionImplies(Atom 
Token,
   Constraints.insert(().makeAtomRef(Token));
   Constraints.insert(().makeNot(Val));
   llvm::DenseSet VisitedTokens;

Xazax-hun wrote:

Aren't these `VisitedTokens` locals now unused?

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


[clang] [clang][dataflow] Change `diagnoseFunction` to take type of diagnostic list instead of diagnostic itself. (PR #66014)

2023-09-11 Thread Gábor Horváth via cfe-commits

https://github.com/Xazax-hun approved this pull request.

LGTM!

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


[clang-tools-extra] [libc++] Implement ranges::contains (PR #65148)

2023-09-11 Thread via cfe-commits

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


[clang] [libc++] Implement ranges::contains (PR #65148)

2023-09-11 Thread via cfe-commits

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


[clang] [Inliner] Improve attribute propagation to callsites when inlining. (PR #66036)

2023-09-11 Thread via cfe-commits

goldsteinn wrote:

Compile time impact: 
https://llvm-compile-time-tracker.com/compare.php?from=825df6cfeae3b3aeaa3e8a1882c564bc50d99be5=4ccda9426371d37d57042058992931e3bd1ea9e3=instructions:u

Some regression for ThinLTO/FullLTO, minimal for normal O3 build.

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


[clang-tools-extra] [libc++] Implement ranges::contains (PR #65148)

2023-09-11 Thread via cfe-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/65148:

>From 02e9afd761228f401df4d9f8dfaaca44ffae0c6e Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 31 Aug 2023 20:08:32 +
Subject: [PATCH 1/7] [libc++] Implement ranges::contains

Differential Revision: https://reviews.llvm.org/D159232
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__algorithm/ranges_contains.h  |  60 ++
 libcxx/include/algorithm  |   9 +
 ...obust_against_copying_projections.pass.cpp |   4 +
 .../alg.contains/ranges.contains.pass.cpp | 190 ++
 .../niebloid.compile.pass.cpp |   1 +
 6 files changed, 265 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 77a7269121ec142..024aa8959fb7200 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -104,6 +104,7 @@ set(files
   __algorithm/ranges_any_of.h
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
+  __algorithm/ranges_contains.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains.h 
b/libcxx/include/__algorithm/ranges_contains.h
new file mode 100644
index 000..647b7ea34be3421
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains.h
@@ -0,0 +1,60 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+
+#include <__algorithm/in_in_result.h>
+#include <__algorithm/ranges_find.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains {
+struct __fn {
+  template  _Sent, class _Type, 
class _Proj = identity>
+requires indirect_binary_predicate, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = 
{}) const {
+return ranges::find(std::move(__first), std::move(__last), __value, 
std::ref(__proj)) != __last;
+  }
+
+  template 
+requires indirect_binary_predicate, _Proj>, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
+return ranges::find(ranges::begin(__range), ranges::end(__range), __value, 
std::ref(__proj)) != ranges::end(__range);
+  }
+};
+} // namespace __contains
+inline namespace __cpo {
+inline constexpr auto contains = __contains::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 76e0d22bf73ef85..003bf132b38b4d8 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -226,6 +226,14 @@ namespace ranges {
   template
 using copy_backward_result = in_out_result;
 // since C++20
 
+  template S, class T, class Proj = identity>
+requires indirect_binary_predicate, 
const T*>
+constexpr bool ranges::contains(I first, S last, const T& value, Proj proj 
= {});   // since C++23
+
+  template
+requires indirect_binary_predicate, Proj>, const T*>
+constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {});
 // since C++23
+
   template S, weakly_incrementable O>
 requires indirectly_copyable
 constexpr ranges::copy_result ranges::copy(I first, S last, O 
result);// since C++20
@@ -1827,6 +1835,7 @@ template 
 #include <__algorithm/ranges_any_of.h>
 #include <__algorithm/ranges_binary_search.h>
 #include <__algorithm/ranges_clamp.h>
+#include <__algorithm/ranges_contains.h>
 #include <__algorithm/ranges_copy.h>
 #include <__algorithm/ranges_copy_backward.h>
 #include <__algorithm/ranges_copy_if.h>
diff --git 

[clang] [libc++] Implement ranges::contains (PR #65148)

2023-09-11 Thread via cfe-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/65148:

>From 02e9afd761228f401df4d9f8dfaaca44ffae0c6e Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 31 Aug 2023 20:08:32 +
Subject: [PATCH 1/7] [libc++] Implement ranges::contains

Differential Revision: https://reviews.llvm.org/D159232
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__algorithm/ranges_contains.h  |  60 ++
 libcxx/include/algorithm  |   9 +
 ...obust_against_copying_projections.pass.cpp |   4 +
 .../alg.contains/ranges.contains.pass.cpp | 190 ++
 .../niebloid.compile.pass.cpp |   1 +
 6 files changed, 265 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 77a7269121ec142..024aa8959fb7200 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -104,6 +104,7 @@ set(files
   __algorithm/ranges_any_of.h
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
+  __algorithm/ranges_contains.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains.h 
b/libcxx/include/__algorithm/ranges_contains.h
new file mode 100644
index 000..647b7ea34be3421
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains.h
@@ -0,0 +1,60 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+
+#include <__algorithm/in_in_result.h>
+#include <__algorithm/ranges_find.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains {
+struct __fn {
+  template  _Sent, class _Type, 
class _Proj = identity>
+requires indirect_binary_predicate, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = 
{}) const {
+return ranges::find(std::move(__first), std::move(__last), __value, 
std::ref(__proj)) != __last;
+  }
+
+  template 
+requires indirect_binary_predicate, _Proj>, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
+return ranges::find(ranges::begin(__range), ranges::end(__range), __value, 
std::ref(__proj)) != ranges::end(__range);
+  }
+};
+} // namespace __contains
+inline namespace __cpo {
+inline constexpr auto contains = __contains::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 76e0d22bf73ef85..003bf132b38b4d8 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -226,6 +226,14 @@ namespace ranges {
   template
 using copy_backward_result = in_out_result;
 // since C++20
 
+  template S, class T, class Proj = identity>
+requires indirect_binary_predicate, 
const T*>
+constexpr bool ranges::contains(I first, S last, const T& value, Proj proj 
= {});   // since C++23
+
+  template
+requires indirect_binary_predicate, Proj>, const T*>
+constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {});
 // since C++23
+
   template S, weakly_incrementable O>
 requires indirectly_copyable
 constexpr ranges::copy_result ranges::copy(I first, S last, O 
result);// since C++20
@@ -1827,6 +1835,7 @@ template 
 #include <__algorithm/ranges_any_of.h>
 #include <__algorithm/ranges_binary_search.h>
 #include <__algorithm/ranges_clamp.h>
+#include <__algorithm/ranges_contains.h>
 #include <__algorithm/ranges_copy.h>
 #include <__algorithm/ranges_copy_backward.h>
 #include <__algorithm/ranges_copy_if.h>
diff --git 

[clang] [Parse] Split incremental-extensions (PR #65683)

2023-09-11 Thread Ben Barham via cfe-commits

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


[clang] 4c264c2 - [Parse] Split incremental-extensions (#65683)

2023-09-11 Thread via cfe-commits

Author: Ben Barham
Date: 2023-09-11T17:40:43-07:00
New Revision: 4c264c26d726f594c4618e4bfeac93d403de893f

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

LOG: [Parse] Split incremental-extensions (#65683)

The preprocessor `IncrementalProcessing` option was being used to
control whether or not to teardown the lexer or run the end of
translation unit action. In D127284 this was merged with
`-fincremental-extensions`, which also changes top level parsing.

Split these again so that the former behavior can be achieved without
the latter (ie. to allow managing lifetime without also changing
parsing).

Resolves rdar://113406310.

Added: 


Modified: 
clang/include/clang/Lex/Preprocessor.h
clang/lib/Lex/PPLexerChange.cpp
clang/lib/Lex/Preprocessor.cpp
clang/lib/Parse/Parser.cpp

Removed: 




diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index bc1d94a61508d8d..575d08b83fd3a02 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -277,6 +277,9 @@ class Preprocessor {
   /// Empty line handler.
   EmptylineHandler *Emptyline = nullptr;
 
+  /// True to avoid tearing down the lexer etc on EOF
+  bool IncrementalProcessing = false;
+
 public:
   /// The kind of translation unit we are processing.
   const TranslationUnitKind TUKind;
@@ -1910,14 +1913,11 @@ class Preprocessor {
   void recomputeCurLexerKind();
 
   /// Returns true if incremental processing is enabled
-  bool isIncrementalProcessingEnabled() const {
-return getLangOpts().IncrementalExtensions;
-  }
+  bool isIncrementalProcessingEnabled() const { return IncrementalProcessing; }
 
   /// Enables the incremental processing
   void enableIncrementalProcessing(bool value = true) {
-// FIXME: Drop this interface.
-const_cast(getLangOpts()).IncrementalExtensions = value;
+IncrementalProcessing = value;
   }
 
   /// Specify the point at which code-completion will be performed.

diff  --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp
index ab005381adfaf2c..811a760420e0a2d 100644
--- a/clang/lib/Lex/PPLexerChange.cpp
+++ b/clang/lib/Lex/PPLexerChange.cpp
@@ -541,7 +541,7 @@ bool Preprocessor::HandleEndOfFile(Token , bool 
isEndOfMacro) {
   Result.startToken();
   CurLexer->BufferPtr = EndPos;
 
-  if (isIncrementalProcessingEnabled()) {
+  if (getLangOpts().IncrementalExtensions) {
 CurLexer->FormTokenWithChars(Result, EndPos, tok::annot_repl_input_end);
 Result.setAnnotationEndLoc(Result.getLocation());
 Result.setAnnotationValue(nullptr);

diff  --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index 8de78a13930ed62..f0381c18a8b6f77 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -146,6 +146,10 @@ 
Preprocessor::Preprocessor(std::shared_ptr PPOpts,
 Ident_AbnormalTermination = nullptr;
   }
 
+  // Default incremental processing to -fincremental-extensions, clients can
+  // override with `enableIncrementalProcessing` if desired.
+  IncrementalProcessing = LangOpts.IncrementalExtensions;
+
   // If using a PCH where a #pragma hdrstop is expected, start skipping tokens.
   if (usingPCHWithPragmaHdrStop())
 SkippingUntilPragmaHdrStop = true;

diff  --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 09215b8303ecf9c..858b6439df5122a 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -615,6 +615,11 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy ,
Sema::ModuleImportState ) {
   DestroyTemplateIdAnnotationsRAIIObj CleanupRAII(*this);
 
+  // Skip over the EOF token, flagging end of previous input for incremental
+  // processing
+  if (PP.isIncrementalProcessingEnabled() && Tok.is(tok::eof))
+ConsumeToken();
+
   Result = nullptr;
   switch (Tok.getKind()) {
   case tok::annot_pragma_unused:
@@ -706,7 +711,8 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy ,
 
 // Late template parsing can begin.
 Actions.SetLateTemplateParser(LateTemplateParserCallback, nullptr, this);
-Actions.ActOnEndOfTranslationUnit();
+if (!PP.isIncrementalProcessingEnabled())
+  Actions.ActOnEndOfTranslationUnit();
 //else don't tell Sema that we ended parsing: more input might come.
 return true;
 
@@ -1038,7 +1044,7 @@ Parser::ParseExternalDeclaration(ParsedAttributes ,
   ConsumeToken();
   return nullptr;
 }
-if (PP.isIncrementalProcessingEnabled() &&
+if (getLangOpts().IncrementalExtensions &&
 !isDeclarationStatement(/*DisambiguatingWithExpression=*/true))
   return ParseTopLevelStmtDecl();
 



___
cfe-commits mailing list

[clang-tools-extra] [libc++] Implement ranges::contains (PR #65148)

2023-09-11 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/65148:

>From 02e9afd761228f401df4d9f8dfaaca44ffae0c6e Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 31 Aug 2023 20:08:32 +
Subject: [PATCH 1/7] [libc++] Implement ranges::contains

Differential Revision: https://reviews.llvm.org/D159232
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__algorithm/ranges_contains.h  |  60 ++
 libcxx/include/algorithm  |   9 +
 ...obust_against_copying_projections.pass.cpp |   4 +
 .../alg.contains/ranges.contains.pass.cpp | 190 ++
 .../niebloid.compile.pass.cpp |   1 +
 6 files changed, 265 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 77a7269121ec142..024aa8959fb7200 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -104,6 +104,7 @@ set(files
   __algorithm/ranges_any_of.h
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
+  __algorithm/ranges_contains.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains.h 
b/libcxx/include/__algorithm/ranges_contains.h
new file mode 100644
index 000..647b7ea34be3421
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains.h
@@ -0,0 +1,60 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+
+#include <__algorithm/in_in_result.h>
+#include <__algorithm/ranges_find.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains {
+struct __fn {
+  template  _Sent, class _Type, 
class _Proj = identity>
+requires indirect_binary_predicate, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = 
{}) const {
+return ranges::find(std::move(__first), std::move(__last), __value, 
std::ref(__proj)) != __last;
+  }
+
+  template 
+requires indirect_binary_predicate, _Proj>, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
+return ranges::find(ranges::begin(__range), ranges::end(__range), __value, 
std::ref(__proj)) != ranges::end(__range);
+  }
+};
+} // namespace __contains
+inline namespace __cpo {
+inline constexpr auto contains = __contains::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 76e0d22bf73ef85..003bf132b38b4d8 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -226,6 +226,14 @@ namespace ranges {
   template
 using copy_backward_result = in_out_result;
 // since C++20
 
+  template S, class T, class Proj = identity>
+requires indirect_binary_predicate, 
const T*>
+constexpr bool ranges::contains(I first, S last, const T& value, Proj proj 
= {});   // since C++23
+
+  template
+requires indirect_binary_predicate, Proj>, const T*>
+constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {});
 // since C++23
+
   template S, weakly_incrementable O>
 requires indirectly_copyable
 constexpr ranges::copy_result ranges::copy(I first, S last, O 
result);// since C++20
@@ -1827,6 +1835,7 @@ template 
 #include <__algorithm/ranges_any_of.h>
 #include <__algorithm/ranges_binary_search.h>
 #include <__algorithm/ranges_clamp.h>
+#include <__algorithm/ranges_contains.h>
 #include <__algorithm/ranges_copy.h>
 #include <__algorithm/ranges_copy_backward.h>
 #include <__algorithm/ranges_copy_if.h>
diff --git 

[clang] [libc++] Implement ranges::contains (PR #65148)

2023-09-11 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/65148:

>From 02e9afd761228f401df4d9f8dfaaca44ffae0c6e Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 31 Aug 2023 20:08:32 +
Subject: [PATCH 1/7] [libc++] Implement ranges::contains

Differential Revision: https://reviews.llvm.org/D159232
---
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__algorithm/ranges_contains.h  |  60 ++
 libcxx/include/algorithm  |   9 +
 ...obust_against_copying_projections.pass.cpp |   4 +
 .../alg.contains/ranges.contains.pass.cpp | 190 ++
 .../niebloid.compile.pass.cpp |   1 +
 6 files changed, 265 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 77a7269121ec142..024aa8959fb7200 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -104,6 +104,7 @@ set(files
   __algorithm/ranges_any_of.h
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
+  __algorithm/ranges_contains.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains.h 
b/libcxx/include/__algorithm/ranges_contains.h
new file mode 100644
index 000..647b7ea34be3421
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains.h
@@ -0,0 +1,60 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
+
+#include <__algorithm/in_in_result.h>
+#include <__algorithm/ranges_find.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains {
+struct __fn {
+  template  _Sent, class _Type, 
class _Proj = identity>
+requires indirect_binary_predicate, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = 
{}) const {
+return ranges::find(std::move(__first), std::move(__last), __value, 
std::ref(__proj)) != __last;
+  }
+
+  template 
+requires indirect_binary_predicate, _Proj>, const _Type*>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
+  operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
+return ranges::find(ranges::begin(__range), ranges::end(__range), __value, 
std::ref(__proj)) != ranges::end(__range);
+  }
+};
+} // namespace __contains
+inline namespace __cpo {
+inline constexpr auto contains = __contains::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___ALGORITHM_RANGES_CONTAINS_H
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 76e0d22bf73ef85..003bf132b38b4d8 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -226,6 +226,14 @@ namespace ranges {
   template
 using copy_backward_result = in_out_result;
 // since C++20
 
+  template S, class T, class Proj = identity>
+requires indirect_binary_predicate, 
const T*>
+constexpr bool ranges::contains(I first, S last, const T& value, Proj proj 
= {});   // since C++23
+
+  template
+requires indirect_binary_predicate, Proj>, const T*>
+constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {});
 // since C++23
+
   template S, weakly_incrementable O>
 requires indirectly_copyable
 constexpr ranges::copy_result ranges::copy(I first, S last, O 
result);// since C++20
@@ -1827,6 +1835,7 @@ template 
 #include <__algorithm/ranges_any_of.h>
 #include <__algorithm/ranges_binary_search.h>
 #include <__algorithm/ranges_clamp.h>
+#include <__algorithm/ranges_contains.h>
 #include <__algorithm/ranges_copy.h>
 #include <__algorithm/ranges_copy_backward.h>
 #include <__algorithm/ranges_copy_if.h>
diff --git 

[clang] [Inliner] Improve attribute propagation to callsites when inlining. (PR #66036)

2023-09-11 Thread via cfe-commits

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


[clang] inliner attrs (PR #66036)

2023-09-11 Thread via cfe-commits

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


[clang] inliner attrs (PR #66036)

2023-09-11 Thread via cfe-commits

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


[PATCH] D154603: [analyzer][clangsa] Add new option to alpha.security.cert.InvalidPtrChecker

2023-09-11 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 marked 2 inline comments as done.
gamesh411 added a comment.

@steakhal gentle ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154603

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


[clang] inliner attrs (PR #66036)

2023-09-11 Thread via cfe-commits

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


[PATCH] D154603: [analyzer][clangsa] Add new option to alpha.security.cert.InvalidPtrChecker

2023-09-11 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 556510.
gamesh411 added a comment.

- use std::string
- simplify tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154603

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/cert/env34-c-cert-examples.c
  clang/test/Analysis/cert/env34-c.c
  clang/test/Analysis/invalid-ptr-checker.c

Index: clang/test/Analysis/invalid-ptr-checker.c
===
--- /dev/null
+++ clang/test/Analysis/invalid-ptr-checker.c
@@ -0,0 +1,50 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=alpha.security.cert.env.InvalidPtr \
+// RUN:  -analyzer-config alpha.security.cert.env.InvalidPtr:InvalidatingGetEnv=false \
+// RUN:  -analyzer-output=text -verify -Wno-unused %s
+//
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=alpha.security.cert.env.InvalidPtr \
+// RUN:  -analyzer-config \
+// RUN: alpha.security.cert.env.InvalidPtr:InvalidatingGetEnv=true \
+// RUN: -analyzer-output=text -verify=expected,pedantic -Wno-unused %s
+
+#include "Inputs/system-header-simulator.h"
+
+char *getenv(const char *name);
+int setenv(const char *name, const char *value, int overwrite);
+int strcmp(const char *, const char *);
+
+int custom_env_handler(const char **envp);
+
+void getenv_after_getenv(void) {
+  char *v1 = getenv("V1");
+  // pedantic-note@-1{{previous function call was here}}
+
+  char *v2 = getenv("V2");
+  // pedantic-note@-1{{'getenv' call may invalidate the result of the previous 'getenv'}}
+
+  strcmp(v1, v2);
+  // pedantic-warning@-1{{use of invalidated pointer 'v1' in a function call}}
+  // pedantic-note@-2{{use of invalidated pointer 'v1' in a function call}}
+}
+
+void setenv_after_getenv(void) {
+  char *v1 = getenv("VAR1");
+
+  setenv("VAR2", "...", 1);
+  // expected-note@-1{{'setenv' call may invalidate the environment returned by getenv}}
+
+  strcmp(v1, "");
+  // expected-warning@-1{{use of invalidated pointer 'v1' in a function call}}
+  // expected-note@-2{{use of invalidated pointer 'v1' in a function call}}
+}
+
+int main(int argc, const char *argv[], const char *envp[]) {
+  setenv("VAR", "...", 0);
+  // expected-note@-1 2 {{'setenv' call may invalidate the environment parameter of 'main'}}
+
+  *envp;
+  // expected-warning@-1 2 {{dereferencing an invalid pointer}}
+  // expected-note@-2 2 {{dereferencing an invalid pointer}}
+}
Index: clang/test/Analysis/cert/env34-c.c
===
--- clang/test/Analysis/cert/env34-c.c
+++ clang/test/Analysis/cert/env34-c.c
@@ -1,5 +1,6 @@
 // RUN: %clang_analyze_cc1 \
 // RUN:  -analyzer-checker=alpha.security.cert.env.InvalidPtr\
+// RUN:  -analyzer-config alpha.security.cert.env.InvalidPtr:InvalidatingGetEnv=true \
 // RUN:  -analyzer-output=text -verify -Wno-unused %s
 
 #include "../Inputs/system-header-simulator.h"
Index: clang/test/Analysis/cert/env34-c-cert-examples.c
===
--- clang/test/Analysis/cert/env34-c-cert-examples.c
+++ clang/test/Analysis/cert/env34-c-cert-examples.c
@@ -1,15 +1,49 @@
+// Default options.
 // RUN: %clang_analyze_cc1 \
 // RUN:  -analyzer-checker=core,alpha.security.cert.env.InvalidPtr \
 // RUN:  -verify -Wno-unused %s
+//
+// Test the laxer handling of getenv function (this is the default).
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,alpha.security.cert.env.InvalidPtr \
+// RUN:  -analyzer-config alpha.security.cert.env.InvalidPtr:InvalidatingGetEnv=false \
+// RUN:  -verify -Wno-unused %s
+//
+// Test the stricter handling of getenv function.
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,alpha.security.cert.env.InvalidPtr \
+// RUN:  -analyzer-config alpha.security.cert.env.InvalidPtr:InvalidatingGetEnv=true \
+// RUN:  -verify=pedantic -Wno-unused %s
 
 #include "../Inputs/system-header-simulator.h"
 char *getenv(const char *name);
+int setenv(const char *name, const char *value, int overwrite);
 int strcmp(const char*, const char*);
 char *strdup(const char*);
 void free(void *memblock);
 void *malloc(size_t size);
 
-void incorrect_usage(void) {
+void incorrect_usage_setenv_getenv_invalidation(void) {
+  char *tmpvar;
+  char *tempvar;
+
+  tmpvar = getenv("TMP");
+
+  if (!tmpvar)
+return;
+
+  setenv("TEMP", "", 1); //setenv can invalidate env
+
+  if (!tmpvar)
+return;
+
+  if (strcmp(tmpvar, "") == 0) { // body of strcmp is unknown
+// expected-warning@-1{{use of invalidated pointer 'tmpvar' in a function call}}
+// pedantic-warning@-2{{use of invalidated pointer 'tmpvar' in a function call}}
+  }
+}
+

[clang-tools-extra] [libc++] Implement ranges::contains (PR #65148)

2023-09-11 Thread via cfe-commits

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


[clang] [libc++] Implement ranges::contains (PR #65148)

2023-09-11 Thread via cfe-commits

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


[clang] inliner attrs (PR #66036)

2023-09-11 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-clang


Changes

- Add some additional tests for progagating attributes before inlining; NFC
- Regen checks for old test; NFC
- Split some tests for c/cpp; NFC
- Use "best" ret attribute when propagating attributes during inlining
- Also propagate `noundef` and `align` ret attributes during inlining
- Propagate callee function memory access attributes before inlining
- Propagate callee argument memory access attributes before inlining
- Propagate some additional callee argument attributes before inlining
- Propagate some callee function attributes to callsites before inlining

--

Patch is 373.25 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/66036.diff

45 Files Affected:

- (modified) clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c (+9-9) 
- (modified) clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c (+4-4) 
- (modified) clang/test/CodeGen/X86/bitscan-builtins.c (-3) 
- (added) clang/test/CodeGen/X86/bitscan-builtins.cpp (+71) 
- (modified) clang/test/CodeGen/X86/popcnt-builtins.c (-2) 
- (added) clang/test/CodeGen/X86/popcnt-builtins.cpp (+67) 
- (modified) clang/test/CodeGen/X86/rot-intrinsics.c (-7) 
- (added) clang/test/CodeGen/X86/rot-intrinsics.cpp (+165) 
- (modified) clang/test/CodeGen/X86/x86-bswap.c (-1) 
- (added) clang/test/CodeGen/X86/x86-bswap.cpp (+44) 
- (modified) clang/test/CodeGen/aarch64-ls64.c (+3-3) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp 
(+5-5) 
- (modified) clang/test/CodeGen/fp-contract-fast-pragma.cpp (+1-1) 
- (modified) clang/test/CodeGen/fp-contract-on-pragma.cpp (+1-1) 
- (modified) clang/test/CodeGen/fp-contract-pragma.cpp (+1-1) 
- (modified) clang/test/CodeGenCUDA/cuda-builtin-vars.cu (+12-12) 
- (modified) clang/test/Headers/__clang_hip_cmath.hip (+10-10) 
- (modified) clang/test/Headers/__clang_hip_math.hip (+524-524) 
- (modified) clang/test/Headers/__clang_hip_math_ocml_rounded_ops.hip (+44-44) 
- (modified) clang/test/Headers/amdgcn_openmp_device_math.c (+12-12) 
- (modified) clang/test/Headers/amdgcn_openmp_device_math_constexpr.cpp 
(+12-12) 
- (modified) clang/test/Headers/hip-header.hip (+5-5) 
- (modified) clang/test/Headers/nvptx_device_cmath_functions.cpp (+5-5) 
- (modified) clang/test/Headers/nvptx_device_cmath_functions_cxx17.cpp (+5-5) 
- (modified) clang/test/Headers/nvptx_device_math_functions.c (+12-7) 
- (modified) clang/test/Headers/nvptx_device_math_functions.cpp (+5-5) 
- (modified) clang/test/Headers/nvptx_device_math_functions_cxx17.cpp (+5-5) 
- (modified) clang/test/Headers/nvptx_device_math_modf.cpp (+4-4) 
- (modified) clang/test/Headers/nvptx_device_math_sin.cpp (+4-4) 
- (modified) clang/test/Headers/nvptx_device_math_sin_cos.cpp (+6-6) 
- (modified) clang/test/Headers/openmp_device_math_isnan.cpp (+4-4) 
- (modified) clang/test/OpenMP/bug57757.cpp (+1-1) 
- (modified) llvm/include/llvm/Support/ModRef.h (+7) 
- (modified) llvm/lib/Transforms/Utils/InlineFunction.cpp (+187) 
- (added) llvm/test/Transforms/Inline/access-attributes-prop.ll (+498) 
- (modified) llvm/test/Transforms/Inline/assumptions-from-callsite-attrs.ll 
(+1-1) 
- (modified) llvm/test/Transforms/Inline/byval.ll (+122-73) 
- (modified) llvm/test/Transforms/Inline/memprof_inline.ll (+2-2) 
- (modified) llvm/test/Transforms/Inline/noalias-calls-always.ll (+6-6) 
- (modified) llvm/test/Transforms/Inline/noalias-calls.ll (+10-10) 
- (added) llvm/test/Transforms/Inline/ret_attr_align_and_noundef.ll (+171) 
- (modified) llvm/test/Transforms/Inline/ret_attr_update.ll (+1-1) 
- (modified) llvm/test/Transforms/SampleProfile/norepeated-icp-3.ll (+1-1) 
- (modified) llvm/test/Transforms/SampleProfile/norepeated-icp-4.ll (+1-1) 
- (modified) llvm/test/Transforms/SampleProfile/uniqname.ll (+3-3) 



diff --git a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c 
b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
index 44f8cbe2cc01739..642b08ac68ef122 100644
--- a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
+++ b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
@@ -636,31 +636,31 @@ void test_core(void) {
   // CHECK-ASM: vlbb
 
   vsc = vec_load_len(cptrsc, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vuc = vec_load_len(cptruc, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vss = vec_load_len(cptrss, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vus = vec_load_len(cptrus, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   

[clang] inliner attrs (PR #66036)

2023-09-11 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-llvm-transforms


Changes

- Add some additional tests for progagating attributes before inlining; NFC
- Regen checks for old test; NFC
- Split some tests for c/cpp; NFC
- Use "best" ret attribute when propagating attributes during inlining
- Also propagate `noundef` and `align` ret attributes during inlining
- Propagate callee function memory access attributes before inlining
- Propagate callee argument memory access attributes before inlining
- Propagate some additional callee argument attributes before inlining
- Propagate some callee function attributes to callsites before inlining

--

Patch is 373.25 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/66036.diff

45 Files Affected:

- (modified) clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c (+9-9) 
- (modified) clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c (+4-4) 
- (modified) clang/test/CodeGen/X86/bitscan-builtins.c (-3) 
- (added) clang/test/CodeGen/X86/bitscan-builtins.cpp (+71) 
- (modified) clang/test/CodeGen/X86/popcnt-builtins.c (-2) 
- (added) clang/test/CodeGen/X86/popcnt-builtins.cpp (+67) 
- (modified) clang/test/CodeGen/X86/rot-intrinsics.c (-7) 
- (added) clang/test/CodeGen/X86/rot-intrinsics.cpp (+165) 
- (modified) clang/test/CodeGen/X86/x86-bswap.c (-1) 
- (added) clang/test/CodeGen/X86/x86-bswap.cpp (+44) 
- (modified) clang/test/CodeGen/aarch64-ls64.c (+3-3) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp 
(+5-5) 
- (modified) clang/test/CodeGen/fp-contract-fast-pragma.cpp (+1-1) 
- (modified) clang/test/CodeGen/fp-contract-on-pragma.cpp (+1-1) 
- (modified) clang/test/CodeGen/fp-contract-pragma.cpp (+1-1) 
- (modified) clang/test/CodeGenCUDA/cuda-builtin-vars.cu (+12-12) 
- (modified) clang/test/Headers/__clang_hip_cmath.hip (+10-10) 
- (modified) clang/test/Headers/__clang_hip_math.hip (+524-524) 
- (modified) clang/test/Headers/__clang_hip_math_ocml_rounded_ops.hip (+44-44) 
- (modified) clang/test/Headers/amdgcn_openmp_device_math.c (+12-12) 
- (modified) clang/test/Headers/amdgcn_openmp_device_math_constexpr.cpp 
(+12-12) 
- (modified) clang/test/Headers/hip-header.hip (+5-5) 
- (modified) clang/test/Headers/nvptx_device_cmath_functions.cpp (+5-5) 
- (modified) clang/test/Headers/nvptx_device_cmath_functions_cxx17.cpp (+5-5) 
- (modified) clang/test/Headers/nvptx_device_math_functions.c (+12-7) 
- (modified) clang/test/Headers/nvptx_device_math_functions.cpp (+5-5) 
- (modified) clang/test/Headers/nvptx_device_math_functions_cxx17.cpp (+5-5) 
- (modified) clang/test/Headers/nvptx_device_math_modf.cpp (+4-4) 
- (modified) clang/test/Headers/nvptx_device_math_sin.cpp (+4-4) 
- (modified) clang/test/Headers/nvptx_device_math_sin_cos.cpp (+6-6) 
- (modified) clang/test/Headers/openmp_device_math_isnan.cpp (+4-4) 
- (modified) clang/test/OpenMP/bug57757.cpp (+1-1) 
- (modified) llvm/include/llvm/Support/ModRef.h (+7) 
- (modified) llvm/lib/Transforms/Utils/InlineFunction.cpp (+187) 
- (added) llvm/test/Transforms/Inline/access-attributes-prop.ll (+498) 
- (modified) llvm/test/Transforms/Inline/assumptions-from-callsite-attrs.ll 
(+1-1) 
- (modified) llvm/test/Transforms/Inline/byval.ll (+122-73) 
- (modified) llvm/test/Transforms/Inline/memprof_inline.ll (+2-2) 
- (modified) llvm/test/Transforms/Inline/noalias-calls-always.ll (+6-6) 
- (modified) llvm/test/Transforms/Inline/noalias-calls.ll (+10-10) 
- (added) llvm/test/Transforms/Inline/ret_attr_align_and_noundef.ll (+171) 
- (modified) llvm/test/Transforms/Inline/ret_attr_update.ll (+1-1) 
- (modified) llvm/test/Transforms/SampleProfile/norepeated-icp-3.ll (+1-1) 
- (modified) llvm/test/Transforms/SampleProfile/norepeated-icp-4.ll (+1-1) 
- (modified) llvm/test/Transforms/SampleProfile/uniqname.ll (+3-3) 



diff --git a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c 
b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
index 44f8cbe2cc01739..642b08ac68ef122 100644
--- a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
+++ b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
@@ -636,31 +636,31 @@ void test_core(void) {
   // CHECK-ASM: vlbb
 
   vsc = vec_load_len(cptrsc, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vuc = vec_load_len(cptruc, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vss = vec_load_len(cptrss, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vus = vec_load_len(cptrus, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: 

[clang] inliner attrs (PR #66036)

2023-09-11 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-backend-x86


Changes

- Add some additional tests for progagating attributes before inlining; NFC
- Regen checks for old test; NFC
- Split some tests for c/cpp; NFC
- Use "best" ret attribute when propagating attributes during inlining
- Also propagate `noundef` and `align` ret attributes during inlining
- Propagate callee function memory access attributes before inlining
- Propagate callee argument memory access attributes before inlining
- Propagate some additional callee argument attributes before inlining
- Propagate some callee function attributes to callsites before inlining

--

Patch is 373.25 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/66036.diff

45 Files Affected:

- (modified) clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c (+9-9) 
- (modified) clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c (+4-4) 
- (modified) clang/test/CodeGen/X86/bitscan-builtins.c (-3) 
- (added) clang/test/CodeGen/X86/bitscan-builtins.cpp (+71) 
- (modified) clang/test/CodeGen/X86/popcnt-builtins.c (-2) 
- (added) clang/test/CodeGen/X86/popcnt-builtins.cpp (+67) 
- (modified) clang/test/CodeGen/X86/rot-intrinsics.c (-7) 
- (added) clang/test/CodeGen/X86/rot-intrinsics.cpp (+165) 
- (modified) clang/test/CodeGen/X86/x86-bswap.c (-1) 
- (added) clang/test/CodeGen/X86/x86-bswap.cpp (+44) 
- (modified) clang/test/CodeGen/aarch64-ls64.c (+3-3) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp 
(+5-5) 
- (modified) clang/test/CodeGen/fp-contract-fast-pragma.cpp (+1-1) 
- (modified) clang/test/CodeGen/fp-contract-on-pragma.cpp (+1-1) 
- (modified) clang/test/CodeGen/fp-contract-pragma.cpp (+1-1) 
- (modified) clang/test/CodeGenCUDA/cuda-builtin-vars.cu (+12-12) 
- (modified) clang/test/Headers/__clang_hip_cmath.hip (+10-10) 
- (modified) clang/test/Headers/__clang_hip_math.hip (+524-524) 
- (modified) clang/test/Headers/__clang_hip_math_ocml_rounded_ops.hip (+44-44) 
- (modified) clang/test/Headers/amdgcn_openmp_device_math.c (+12-12) 
- (modified) clang/test/Headers/amdgcn_openmp_device_math_constexpr.cpp 
(+12-12) 
- (modified) clang/test/Headers/hip-header.hip (+5-5) 
- (modified) clang/test/Headers/nvptx_device_cmath_functions.cpp (+5-5) 
- (modified) clang/test/Headers/nvptx_device_cmath_functions_cxx17.cpp (+5-5) 
- (modified) clang/test/Headers/nvptx_device_math_functions.c (+12-7) 
- (modified) clang/test/Headers/nvptx_device_math_functions.cpp (+5-5) 
- (modified) clang/test/Headers/nvptx_device_math_functions_cxx17.cpp (+5-5) 
- (modified) clang/test/Headers/nvptx_device_math_modf.cpp (+4-4) 
- (modified) clang/test/Headers/nvptx_device_math_sin.cpp (+4-4) 
- (modified) clang/test/Headers/nvptx_device_math_sin_cos.cpp (+6-6) 
- (modified) clang/test/Headers/openmp_device_math_isnan.cpp (+4-4) 
- (modified) clang/test/OpenMP/bug57757.cpp (+1-1) 
- (modified) llvm/include/llvm/Support/ModRef.h (+7) 
- (modified) llvm/lib/Transforms/Utils/InlineFunction.cpp (+187) 
- (added) llvm/test/Transforms/Inline/access-attributes-prop.ll (+498) 
- (modified) llvm/test/Transforms/Inline/assumptions-from-callsite-attrs.ll 
(+1-1) 
- (modified) llvm/test/Transforms/Inline/byval.ll (+122-73) 
- (modified) llvm/test/Transforms/Inline/memprof_inline.ll (+2-2) 
- (modified) llvm/test/Transforms/Inline/noalias-calls-always.ll (+6-6) 
- (modified) llvm/test/Transforms/Inline/noalias-calls.ll (+10-10) 
- (added) llvm/test/Transforms/Inline/ret_attr_align_and_noundef.ll (+171) 
- (modified) llvm/test/Transforms/Inline/ret_attr_update.ll (+1-1) 
- (modified) llvm/test/Transforms/SampleProfile/norepeated-icp-3.ll (+1-1) 
- (modified) llvm/test/Transforms/SampleProfile/norepeated-icp-4.ll (+1-1) 
- (modified) llvm/test/Transforms/SampleProfile/uniqname.ll (+3-3) 



diff --git a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c 
b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
index 44f8cbe2cc01739..642b08ac68ef122 100644
--- a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
+++ b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
@@ -636,31 +636,31 @@ void test_core(void) {
   // CHECK-ASM: vlbb
 
   vsc = vec_load_len(cptrsc, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vuc = vec_load_len(cptruc, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vss = vec_load_len(cptrss, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vus = vec_load_len(cptrus, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll

[clang] inliner attrs (PR #66036)

2023-09-11 Thread via cfe-commits

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


[clang] inliner attrs (PR #66036)

2023-09-11 Thread via cfe-commits

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


[clang] inliner attrs (PR #66036)

2023-09-11 Thread via cfe-commits

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


[clang] inliner attrs (PR #66036)

2023-09-11 Thread via cfe-commits

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


[clang] inliner attrs (PR #66036)

2023-09-11 Thread via cfe-commits

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


[clang] inliner attrs (PR #66036)

2023-09-11 Thread via cfe-commits

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


[clang] Update GoogleTest to v1.14.0 (PR #65823)

2023-09-11 Thread Zero Omega via cfe-commits

zeroomega wrote:

I have locally tested this PR using gcc 12.2.0 on Linux x64 and MSVC from 
VS2019, both passed without issues. @pogo59 Do you have any concerns or 
suggestions before we merge this?

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


[clang] [libc][libm][GPU] Added missing vendor entry points to `libm` for GPUs (PR #66031)

2023-09-11 Thread Anton Rydahl via cfe-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,MaheshRavishankar
 <1663364+maheshravishan...@users.noreply.github.com>,Fangrui Song
 ,Razvan Lupusoru ,Walter Erquinigo
 ,"Yaxun (Sam) Liu" ,Nico Weber
 ,Stella Laurenzo ,Lang Hames
 ,Matthias Braun ,Arthur Eubanks
 ,Nico Weber ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Vitaly Buka
 ,Vitaly Buka ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,erichkeane ,Amir Ayupov
 ,Amir Ayupov ,yinying-lisa-li
 <107574043+yinying-lisa...@users.noreply.github.com>,Christopher Di Bella
 ,Konstantin Varlamov ,Alexey Bader
 ,Vitaly Buka 


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


[clang] Propagate the DWARF version from the main compiler invocation to PCHC… (PR #66032)

2023-09-11 Thread Adrian Prantl via cfe-commits

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


[clang] Propagate the DWARF version from the main compiler invocation to PCHC… (PR #66032)

2023-09-11 Thread Adrian Prantl via cfe-commits

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


[clang] Propagate the DWARF version from the main compiler invocation to PCHC… (PR #66032)

2023-09-11 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-clang-modules


Changes

…ontainerGenerator

Currently it remains uninitialized and thus always uses the LLVM default of 4.
--
Full diff: https://github.com/llvm/llvm-project/pull/66032.diff

2 Files Affected:

- (modified) clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (+1) 
- (modified) clang/test/Modules/ModuleDebugInfo.cpp (+4-1) 



diff --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp 
b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index 114a9c1e2eac12..9ffeef026bd1b7 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -160,6 +160,7 @@ class PCHContainerGenerator : public ASTConsumer {
 LangOpts.CurrentModule.empty() ? MainFileName : LangOpts.CurrentModule;
 CodeGenOpts.setDebugInfo(llvm::codegenoptions::FullDebugInfo);
 CodeGenOpts.setDebuggerTuning(CI.getCodeGenOpts().getDebuggerTuning());
+CodeGenOpts.DwarfVersion = CI.getCodeGenOpts().DwarfVersion;
 CodeGenOpts.DebugPrefixMap =
 CI.getInvocation().getCodeGenOpts().DebugPrefixMap;
 CodeGenOpts.DebugStrictDwarf = CI.getCodeGenOpts().DebugStrictDwarf;
diff --git a/clang/test/Modules/ModuleDebugInfo.cpp 
b/clang/test/Modules/ModuleDebugInfo.cpp
index 8f7fa22bcb0b00..4d78324867bcb8 100644
--- a/clang/test/Modules/ModuleDebugInfo.cpp
+++ b/clang/test/Modules/ModuleDebugInfo.cpp
@@ -6,10 +6,11 @@
 
 // Modules:
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
-debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj 
-fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t 
-emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll
+// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
-debugger-tuning=lldb -debug-info-kind=limited -dwarf-version=5 -fmodules 
-fmodule-format=obj -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s 
-I %S/Inputs -I %t -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer 
&>%t-mod.ll
 // RUN: cat %t-mod.ll | FileCheck %s
 // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
 // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-MOD %s
+// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-MOD-DWARF %s
 
 // PCH:
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11  
-debugger-tuning=lldb -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch 
%S/Inputs/DebugCXX.h -mllvm -debug-only=pchcontainer &>%t-pch.ll
@@ -20,6 +21,8 @@
 @import DebugCXX;
 #endif
 
+// CHECK-MOD-DWARF: !"Dwarf Version", i32 5
+
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 




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


[clang] Propagate the DWARF version from the main compiler invocation to PCHC… (PR #66032)

2023-09-11 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-clang


Changes

…ontainerGenerator

Currently it remains uninitialized and thus always uses the LLVM default of 4.
--
Full diff: https://github.com/llvm/llvm-project/pull/66032.diff

2 Files Affected:

- (modified) clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (+1) 
- (modified) clang/test/Modules/ModuleDebugInfo.cpp (+4-1) 



diff --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp 
b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index 114a9c1e2eac121..9ffeef026bd1b76 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -160,6 +160,7 @@ class PCHContainerGenerator : public ASTConsumer {
 LangOpts.CurrentModule.empty() ? MainFileName : LangOpts.CurrentModule;
 CodeGenOpts.setDebugInfo(llvm::codegenoptions::FullDebugInfo);
 CodeGenOpts.setDebuggerTuning(CI.getCodeGenOpts().getDebuggerTuning());
+CodeGenOpts.DwarfVersion = CI.getCodeGenOpts().DwarfVersion;
 CodeGenOpts.DebugPrefixMap =
 CI.getInvocation().getCodeGenOpts().DebugPrefixMap;
 CodeGenOpts.DebugStrictDwarf = CI.getCodeGenOpts().DebugStrictDwarf;
diff --git a/clang/test/Modules/ModuleDebugInfo.cpp 
b/clang/test/Modules/ModuleDebugInfo.cpp
index 8f7fa22bcb0b001..4d78324867bcb81 100644
--- a/clang/test/Modules/ModuleDebugInfo.cpp
+++ b/clang/test/Modules/ModuleDebugInfo.cpp
@@ -6,10 +6,11 @@
 
 // Modules:
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
-debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj 
-fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t 
-emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll
+// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
-debugger-tuning=lldb -debug-info-kind=limited -dwarf-version=5 -fmodules 
-fmodule-format=obj -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s 
-I %S/Inputs -I %t -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer 
&>%t-mod.ll
 // RUN: cat %t-mod.ll | FileCheck %s
 // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
 // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-MOD %s
+// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-MOD-DWARF %s
 
 // PCH:
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11  
-debugger-tuning=lldb -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch 
%S/Inputs/DebugCXX.h -mllvm -debug-only=pchcontainer &>%t-pch.ll
@@ -20,6 +21,8 @@
 @import DebugCXX;
 #endif
 
+// CHECK-MOD-DWARF: !"Dwarf Version", i32 5
+
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 




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


[clang] Propagate the DWARF version from the main compiler invocation to PCHC… (PR #66032)

2023-09-11 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-clang-codegen


Changes

…ontainerGenerator

Currently it remains uninitialized and thus always uses the LLVM default of 4.
--
Full diff: https://github.com/llvm/llvm-project/pull/66032.diff

2 Files Affected:

- (modified) clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (+1) 
- (modified) clang/test/Modules/ModuleDebugInfo.cpp (+4-1) 



diff --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp 
b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index 114a9c1e2eac121..9ffeef026bd1b76 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -160,6 +160,7 @@ class PCHContainerGenerator : public ASTConsumer {
 LangOpts.CurrentModule.empty() ? MainFileName : LangOpts.CurrentModule;
 CodeGenOpts.setDebugInfo(llvm::codegenoptions::FullDebugInfo);
 CodeGenOpts.setDebuggerTuning(CI.getCodeGenOpts().getDebuggerTuning());
+CodeGenOpts.DwarfVersion = CI.getCodeGenOpts().DwarfVersion;
 CodeGenOpts.DebugPrefixMap =
 CI.getInvocation().getCodeGenOpts().DebugPrefixMap;
 CodeGenOpts.DebugStrictDwarf = CI.getCodeGenOpts().DebugStrictDwarf;
diff --git a/clang/test/Modules/ModuleDebugInfo.cpp 
b/clang/test/Modules/ModuleDebugInfo.cpp
index 8f7fa22bcb0b001..4d78324867bcb81 100644
--- a/clang/test/Modules/ModuleDebugInfo.cpp
+++ b/clang/test/Modules/ModuleDebugInfo.cpp
@@ -6,10 +6,11 @@
 
 // Modules:
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
-debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj 
-fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t 
-emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll
+// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
-debugger-tuning=lldb -debug-info-kind=limited -dwarf-version=5 -fmodules 
-fmodule-format=obj -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s 
-I %S/Inputs -I %t -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer 
&>%t-mod.ll
 // RUN: cat %t-mod.ll | FileCheck %s
 // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
 // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-MOD %s
+// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-MOD-DWARF %s
 
 // PCH:
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11  
-debugger-tuning=lldb -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch 
%S/Inputs/DebugCXX.h -mllvm -debug-only=pchcontainer &>%t-pch.ll
@@ -20,6 +21,8 @@
 @import DebugCXX;
 #endif
 
+// CHECK-MOD-DWARF: !"Dwarf Version", i32 5
+
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 




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


[clang] Propagate the DWARF version from the main compiler invocation to PCHC… (PR #66032)

2023-09-11 Thread via cfe-commits

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


[clang] Propagate the DWARF version from the main compiler invocation to PCHC… (PR #66032)

2023-09-11 Thread via cfe-commits

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


[clang] Propagate the DWARF version from the main compiler invocation to PCHC… (PR #66032)

2023-09-11 Thread via cfe-commits

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


[clang] Propagate the DWARF version from the main compiler invocation to PCHC… (PR #66032)

2023-09-11 Thread Adrian Prantl via cfe-commits

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


[clang] Propagate the DWARF version from the main compiler invocation to PCHC… (PR #66032)

2023-09-11 Thread Adrian Prantl via cfe-commits

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


[clang] Propagate the DWARF version from the main compiler invocation to PCHC… (PR #66032)

2023-09-11 Thread Adrian Prantl via cfe-commits

https://github.com/adrian-prantl created 
https://github.com/llvm/llvm-project/pull/66032:

…ontainerGenerator

Currently it remains uninitialized and thus always uses the LLVM default of 4.

>From 6bdd0f5468ae1bf04912a9559c685b335fbe94c9 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Mon, 11 Sep 2023 16:54:23 -0700
Subject: [PATCH] Propagate the DWARF version from the main compiler invocation
 to PCHContainerGenerator

Currently it remains uninitialized and thus always uses the LLVM default of 4.
---
 clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp | 1 +
 clang/test/Modules/ModuleDebugInfo.cpp | 5 -
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp 
b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index 114a9c1e2eac121..9ffeef026bd1b76 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -160,6 +160,7 @@ class PCHContainerGenerator : public ASTConsumer {
 LangOpts.CurrentModule.empty() ? MainFileName : LangOpts.CurrentModule;
 CodeGenOpts.setDebugInfo(llvm::codegenoptions::FullDebugInfo);
 CodeGenOpts.setDebuggerTuning(CI.getCodeGenOpts().getDebuggerTuning());
+CodeGenOpts.DwarfVersion = CI.getCodeGenOpts().DwarfVersion;
 CodeGenOpts.DebugPrefixMap =
 CI.getInvocation().getCodeGenOpts().DebugPrefixMap;
 CodeGenOpts.DebugStrictDwarf = CI.getCodeGenOpts().DebugStrictDwarf;
diff --git a/clang/test/Modules/ModuleDebugInfo.cpp 
b/clang/test/Modules/ModuleDebugInfo.cpp
index 8f7fa22bcb0b001..4d78324867bcb81 100644
--- a/clang/test/Modules/ModuleDebugInfo.cpp
+++ b/clang/test/Modules/ModuleDebugInfo.cpp
@@ -6,10 +6,11 @@
 
 // Modules:
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
-debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj 
-fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t 
-emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll
+// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
-debugger-tuning=lldb -debug-info-kind=limited -dwarf-version=5 -fmodules 
-fmodule-format=obj -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s 
-I %S/Inputs -I %t -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer 
&>%t-mod.ll
 // RUN: cat %t-mod.ll | FileCheck %s
 // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
 // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-MOD %s
+// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-MOD-DWARF %s
 
 // PCH:
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11  
-debugger-tuning=lldb -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch 
%S/Inputs/DebugCXX.h -mllvm -debug-only=pchcontainer &>%t-pch.ll
@@ -20,6 +21,8 @@
 @import DebugCXX;
 #endif
 
+// CHECK-MOD-DWARF: !"Dwarf Version", i32 5
+
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 

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


[clang] [libc][libm][GPU] Added missing vendor entry points to `libm` for GPUs (PR #66031)

2023-09-11 Thread via cfe-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,MaheshRavishankar
 <1663364+maheshravishan...@users.noreply.github.com>,Fangrui Song
 ,Razvan Lupusoru ,Walter Erquinigo
 ,"Yaxun (Sam) Liu" ,Nico Weber
 ,Stella Laurenzo ,Lang Hames
 ,Matthias Braun ,Arthur Eubanks
 ,Nico Weber ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Vitaly Buka
 ,Vitaly Buka ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,erichkeane ,Amir Ayupov
 ,Amir Ayupov ,yinying-lisa-li
 <107574043+yinying-lisa...@users.noreply.github.com>,Christopher Di Bella
 ,Konstantin Varlamov ,Alexey Bader
 ,Vitaly Buka 


llvmbot wrote:

@llvm/pr-subscribers-backend-amdgpu


Changes

There are a number of mathematical functions where no target-agnostic 
implementations exist, and the compiler built-ins are not correctly lowered on 
all GPU targets. This patch adds inlined wrappers for those functions to the 
GPU version of `libm` for AMDGPU and NVPTX targets.
--

Patch is 52.08 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/66031.diff

50 Files Affected:

- (modified) libc/config/gpu/entrypoints.txt (+34-3) 
- (modified) libc/src/math/CMakeLists.txt (+15) 
- (added) libc/src/math/acos.h (+18) 
- (added) libc/src/math/acosh.h (+18) 
- (added) libc/src/math/asin.h (+18) 
- (added) libc/src/math/asinh.h (+18) 
- (added) libc/src/math/atan.h (+18) 
- (added) libc/src/math/atan2.h (+18) 
- (added) libc/src/math/atan2f.h (+18) 
- (added) libc/src/math/atanh.h (+18) 
- (added) libc/src/math/erf.h (+18) 
- (added) libc/src/math/expm1.h (+18) 
- (modified) libc/src/math/gpu/vendor/CMakeLists.txt (+143) 
- (added) libc/src/math/gpu/vendor/acos.cpp (+18) 
- (added) libc/src/math/gpu/vendor/acosh.cpp (+18) 
- (modified) libc/src/math/gpu/vendor/amdgpu/amdgpu.h (+25) 
- (modified) libc/src/math/gpu/vendor/amdgpu/declarations.h (+31-3) 
- (added) libc/src/math/gpu/vendor/asin.cpp (+18) 
- (added) libc/src/math/gpu/vendor/asinh.cpp (+18) 
- (added) libc/src/math/gpu/vendor/atan.cpp (+18) 
- (added) libc/src/math/gpu/vendor/atan2.cpp (+20) 
- (added) libc/src/math/gpu/vendor/atan2f.cpp (+21) 
- (added) libc/src/math/gpu/vendor/atanh.cpp (+18) 
- (added) libc/src/math/gpu/vendor/erf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/erff.cpp (+18) 
- (added) libc/src/math/gpu/vendor/exp.cpp (+18) 
- (added) libc/src/math/gpu/vendor/exp10.cpp (+18) 
- (added) libc/src/math/gpu/vendor/exp2.cpp (+18) 
- (added) libc/src/math/gpu/vendor/expm1.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log10.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log10f.cpp (+19) 
- (added) libc/src/math/gpu/vendor/log1p.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log1pf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log2.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log2f.cpp (+18) 
- (added) libc/src/math/gpu/vendor/logb.cpp (+18) 
- (added) libc/src/math/gpu/vendor/logbf.cpp (+19) 
- (added) libc/src/math/gpu/vendor/logf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lrint.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lrintf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lround.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lroundf.cpp (+20) 
- (modified) libc/src/math/gpu/vendor/nvptx/declarations.h (+25) 
- (modified) libc/src/math/gpu/vendor/nvptx/nvptx.h (+25) 
- (added) libc/src/math/gpu/vendor/tgamma.cpp (+18) 
- (added) libc/src/math/gpu/vendor/tgammaf.cpp (+18) 
- (added) libc/src/math/sincos.h (+18) 
- (added) libc/src/math/tgamma.h (+18) 
- (added) libc/src/math/tgammaf.h (+18) 



diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index 0e314c60870c6ae..730f76cbd6fbb9c 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -113,11 +113,19 @@ set(TARGET_LIBC_ENTRYPOINTS
 
 set(TARGET_LIBM_ENTRYPOINTS
 # math.h entrypoints
+libc.src.math.acos
 libc.src.math.acosf
+libc.src.math.acosh
 libc.src.math.acoshf
+libc.src.math.asin
 libc.src.math.asinf
+libc.src.math.asinh
 libc.src.math.asinhf
+libc.src.math.atan
 libc.src.math.atanf
+libc.src.math.atan2
+libc.src.math.atan2f
+libc.src.math.atanh
 libc.src.math.atanhf
 libc.src.math.ceil
 libc.src.math.ceilf
@@ -127,9 +135,15 @@ set(TARGET_LIBM_ENTRYPOINTS
 libc.src.math.cosf
 libc.src.math.cosh
 libc.src.math.coshf
+libc.src.math.erf
+libc.src.math.erff
+libc.src.math.exp10
 libc.src.math.exp10f
+libc.src.math.exp2
 libc.src.math.exp2f
+libc.src.math.exp
 libc.src.math.expf
+libc.src.math.expm1
 libc.src.math.expm1f
 libc.src.math.fabs
 libc.src.math.fabsf
@@ -157,15 +171,26 @@ set(TARGET_LIBM_ENTRYPOINTS
 libc.src.math.llrintf
 libc.src.math.llround
 libc.src.math.llroundf
-libc.src.math.pow
-libc.src.math.powf
-libc.src.math.sin
+libc.src.math.log10
+libc.src.math.log10f
+

[clang] dfd1d8d - Revert "adds `__reference_constructs_from_temporary`"

2023-09-11 Thread Christopher Di Bella via cfe-commits

Author: Christopher Di Bella
Date: 2023-09-11T23:44:50Z
New Revision: dfd1d8d505d61c9b401a3cdd6a687848f1c37cc5

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

LOG: Revert "adds `__reference_constructs_from_temporary`"

I'm reverting this on principle, since it didn't get the Phabricator
approval I thought it had (only an informal LGTM). Will re-apply once
it has been properly approved.

This reverts commit e1bfeb6bcc627a94c5ab3a5417d290c7dc516d54.

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/include/clang/Basic/TokenKinds.def
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/type-traits.cpp
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index b9466b5a0bc2087..11cbdca7a268fc3 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1621,10 +1621,6 @@ The following type trait primitives are supported by 
Clang. Those traits marked
   materialized temporary object. If ``T`` is not a reference type the result
   is false. Note this trait will also return false when the initialization of
   ``T`` from ``U`` is ill-formed.
-  Deprecated, use ``__reference_constructs_from_temporary``.
-* ``__reference_constructs_from_temporary(T, U)`` (C++)
-  Returns true if a reference ``T`` can be constructed from a temporary of type
-  a non-cv-qualified ``U``.
 * ``__underlying_type`` (C++, GNU, Microsoft)
 
 In addition, the following expression traits are supported:

diff  --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 72e8df8c793a7b6..45ebc200b168986 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -531,7 +531,6 @@ TYPE_TRAIT_1(__is_scoped_enum, IsScopedEnum, KEYCXX)
 TYPE_TRAIT_1(__is_referenceable, IsReferenceable, KEYCXX)
 TYPE_TRAIT_1(__can_pass_in_regs, CanPassInRegs, KEYCXX)
 TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX)
-TYPE_TRAIT_2(__reference_constructs_from_temporary, 
ReferenceConstructsFromTemporary, KEYCXX)
 
 // Embarcadero Expression Traits
 EXPRESSION_TRAIT(__is_lvalue_expr, IsLValueExpr, KEYCXX)

diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp 
b/clang/lib/Lex/PPMacroExpansion.cpp
index ec6a084f228f32d..775cbfafa999602 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -1695,7 +1695,6 @@ void Preprocessor::ExpandBuiltinMacro(Token ) {
   .Case("__array_rank", true)
   .Case("__array_extent", true)
   .Case("__reference_binds_to_temporary", true)
-  .Case("__reference_constructs_from_temporary", true)
 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) .Case("__" #Trait, true)
 #include "clang/Basic/TransformTypeTraits.def"
   .Default(false);

diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
b/clang/lib/Parse/ParseDeclCXX.cpp
index 5fe9abb1fdcab30..730b6e55246d6b7 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1655,9 +1655,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind 
TagTokKind,
   tok::kw___is_union,
   tok::kw___is_unsigned,
   tok::kw___is_void,
-  tok::kw___is_volatile,
-  tok::kw___reference_binds_to_temporary,
-  tok::kw___reference_constructs_from_temporary))
+  tok::kw___is_volatile))
 // GNU libstdc++ 4.2 and libc++ use certain intrinsic names as the
 // name of struct templates, but some are keywords in GCC >= 4.3
 // and Clang. Therefore, when we see the token sequence "struct

diff  --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 74664c34abdbd89..f8bf785da2896a3 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1128,8 +1128,6 @@ ExprResult Parser::ParseCastExpression(CastParseKind 
ParseKind,
   REVERTIBLE_TYPE_TRAIT(__is_unsigned);
   REVERTIBLE_TYPE_TRAIT(__is_void);
   REVERTIBLE_TYPE_TRAIT(__is_volatile);
-  REVERTIBLE_TYPE_TRAIT(__reference_binds_to_temporary);
-  REVERTIBLE_TYPE_TRAIT(__reference_constructs_from_temporary);
 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) 
\
   REVERTIBLE_TYPE_TRAIT(RTT_JOIN(__, Trait));
 #include "clang/Basic/TransformTypeTraits.def"

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 65e8edc7806ecd8..a7be01319a72393 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -30,7 +30,6 @@
 #include "clang/Basic/TargetInfo.h"
 #include 

[clang] [libc][libm][GPU] Added missing vendor entry points to `libm` for GPUs (PR #66031)

2023-09-11 Thread via cfe-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,MaheshRavishankar
 <1663364+maheshravishan...@users.noreply.github.com>,Fangrui Song
 ,Razvan Lupusoru ,Walter Erquinigo
 ,"Yaxun (Sam) Liu" ,Nico Weber
 ,Stella Laurenzo ,Lang Hames
 ,Matthias Braun ,Arthur Eubanks
 ,Nico Weber ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Vitaly Buka
 ,Vitaly Buka ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,erichkeane ,Amir Ayupov
 ,Amir Ayupov ,yinying-lisa-li
 <107574043+yinying-lisa...@users.noreply.github.com>,Christopher Di Bella
 ,Konstantin Varlamov ,Alexey Bader
 ,Vitaly Buka 


llvmbot wrote:

@llvm/pr-subscribers-libc


Changes

There are a number of mathematical functions where no target-agnostic 
implementations exist, and the compiler built-ins are not correctly lowered on 
all GPU targets. This patch adds inlined wrappers for those functions to the 
GPU version of `libm` for AMDGPU and NVPTX targets.
--

Patch is 51.98 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/66031.diff

50 Files Affected:

- (modified) libc/config/gpu/entrypoints.txt (+34-3) 
- (modified) libc/src/math/CMakeLists.txt (+15) 
- (added) libc/src/math/acos.h (+18) 
- (added) libc/src/math/acosh.h (+18) 
- (added) libc/src/math/asin.h (+18) 
- (added) libc/src/math/asinh.h (+18) 
- (added) libc/src/math/atan.h (+18) 
- (added) libc/src/math/atan2.h (+18) 
- (added) libc/src/math/atan2f.h (+18) 
- (added) libc/src/math/atanh.h (+18) 
- (added) libc/src/math/erf.h (+18) 
- (added) libc/src/math/expm1.h (+18) 
- (modified) libc/src/math/gpu/vendor/CMakeLists.txt (+143) 
- (added) libc/src/math/gpu/vendor/acos.cpp (+18) 
- (added) libc/src/math/gpu/vendor/acosh.cpp (+18) 
- (modified) libc/src/math/gpu/vendor/amdgpu/amdgpu.h (+25) 
- (modified) libc/src/math/gpu/vendor/amdgpu/declarations.h (+31-3) 
- (added) libc/src/math/gpu/vendor/asin.cpp (+18) 
- (added) libc/src/math/gpu/vendor/asinh.cpp (+18) 
- (added) libc/src/math/gpu/vendor/atan.cpp (+18) 
- (added) libc/src/math/gpu/vendor/atan2.cpp (+20) 
- (added) libc/src/math/gpu/vendor/atan2f.cpp (+21) 
- (added) libc/src/math/gpu/vendor/atanh.cpp (+18) 
- (added) libc/src/math/gpu/vendor/erf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/erff.cpp (+18) 
- (added) libc/src/math/gpu/vendor/exp.cpp (+18) 
- (added) libc/src/math/gpu/vendor/exp10.cpp (+18) 
- (added) libc/src/math/gpu/vendor/exp2.cpp (+18) 
- (added) libc/src/math/gpu/vendor/expm1.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log10.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log10f.cpp (+19) 
- (added) libc/src/math/gpu/vendor/log1p.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log1pf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log2.cpp (+18) 
- (added) libc/src/math/gpu/vendor/log2f.cpp (+18) 
- (added) libc/src/math/gpu/vendor/logb.cpp (+18) 
- (added) libc/src/math/gpu/vendor/logbf.cpp (+19) 
- (added) libc/src/math/gpu/vendor/logf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lrint.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lrintf.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lround.cpp (+18) 
- (added) libc/src/math/gpu/vendor/lroundf.cpp (+20) 
- (modified) libc/src/math/gpu/vendor/nvptx/declarations.h (+25) 
- (modified) libc/src/math/gpu/vendor/nvptx/nvptx.h (+25) 
- (added) libc/src/math/gpu/vendor/tgamma.cpp (+18) 
- (added) libc/src/math/gpu/vendor/tgammaf.cpp (+18) 
- (added) libc/src/math/sincos.h (+18) 
- (added) libc/src/math/tgamma.h (+18) 
- (added) libc/src/math/tgammaf.h (+18) 



diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index 0e314c60870c6a..730f76cbd6fbb9 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -113,11 +113,19 @@ set(TARGET_LIBC_ENTRYPOINTS
 
 set(TARGET_LIBM_ENTRYPOINTS
 # math.h entrypoints
+libc.src.math.acos
 libc.src.math.acosf
+libc.src.math.acosh
 libc.src.math.acoshf
+libc.src.math.asin
 libc.src.math.asinf
+libc.src.math.asinh
 libc.src.math.asinhf
+libc.src.math.atan
 libc.src.math.atanf
+libc.src.math.atan2
+libc.src.math.atan2f
+libc.src.math.atanh
 libc.src.math.atanhf
 libc.src.math.ceil
 libc.src.math.ceilf
@@ -127,9 +135,15 @@ set(TARGET_LIBM_ENTRYPOINTS
 libc.src.math.cosf
 libc.src.math.cosh
 libc.src.math.coshf
+libc.src.math.erf
+libc.src.math.erff
+libc.src.math.exp10
 libc.src.math.exp10f
+libc.src.math.exp2
 libc.src.math.exp2f
+libc.src.math.exp
 libc.src.math.expf
+libc.src.math.expm1
 libc.src.math.expm1f
 libc.src.math.fabs
 libc.src.math.fabsf
@@ -157,15 +171,26 @@ set(TARGET_LIBM_ENTRYPOINTS
 libc.src.math.llrintf
 libc.src.math.llround
 libc.src.math.llroundf
-libc.src.math.pow
-libc.src.math.powf
-libc.src.math.sin
+libc.src.math.log10
+libc.src.math.log10f
+libc.src.math.log1p

[clang] [libc][libm][GPU] Added missing vendor entry points to `libm` for GPUs (PR #66031)

2023-09-11 Thread Anton Rydahl via cfe-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,MaheshRavishankar
 <1663364+maheshravishan...@users.noreply.github.com>,Fangrui Song
 ,Razvan Lupusoru ,Walter Erquinigo
 ,"Yaxun (Sam) Liu" ,Nico Weber
 ,Stella Laurenzo ,Lang Hames
 ,Matthias Braun ,Arthur Eubanks
 ,Nico Weber ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Vitaly Buka
 ,Vitaly Buka ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,erichkeane ,Amir Ayupov
 ,Amir Ayupov ,yinying-lisa-li
 <107574043+yinying-lisa...@users.noreply.github.com>,Christopher Di Bella
 ,Konstantin Varlamov ,Alexey Bader
 ,Vitaly Buka 


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


[clang] [libc][libm][GPU] Added missing vendor entry points to `libm` for GPUs (PR #66031)

2023-09-11 Thread Anton Rydahl via cfe-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,MaheshRavishankar
 <1663364+maheshravishan...@users.noreply.github.com>,Fangrui Song
 ,Razvan Lupusoru ,Walter Erquinigo
 ,"Yaxun (Sam) Liu" ,Nico Weber
 ,Stella Laurenzo ,Lang Hames
 ,Matthias Braun ,Arthur Eubanks
 ,Nico Weber ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Vitaly Buka
 ,Vitaly Buka ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,erichkeane ,Amir Ayupov
 ,Amir Ayupov ,yinying-lisa-li
 <107574043+yinying-lisa...@users.noreply.github.com>,Christopher Di Bella
 ,Konstantin Varlamov ,Alexey Bader
 ,Vitaly Buka 


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


[clang] [libc][libm][GPU] Added missing vendor entry points to `libm` for GPUs (PR #66031)

2023-09-11 Thread Anton Rydahl via cfe-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,MaheshRavishankar
 <1663364+maheshravishan...@users.noreply.github.com>,Fangrui Song
 ,Razvan Lupusoru ,Walter Erquinigo
 ,"Yaxun (Sam) Liu" ,Nico Weber
 ,Stella Laurenzo ,Lang Hames
 ,Matthias Braun ,Arthur Eubanks
 ,Nico Weber ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Vitaly Buka
 ,Vitaly Buka ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,erichkeane ,Amir Ayupov
 ,Amir Ayupov ,yinying-lisa-li
 <107574043+yinying-lisa...@users.noreply.github.com>,Christopher Di Bella
 ,Konstantin Varlamov ,Alexey Bader
 ,Vitaly Buka 


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


[clang] [libc][libm][GPU] Added missing vendor entry points to `libm` for GPUs (PR #66031)

2023-09-11 Thread Anton Rydahl via cfe-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,MaheshRavishankar
 <1663364+maheshravishan...@users.noreply.github.com>,Fangrui Song
 ,Razvan Lupusoru ,Walter Erquinigo
 ,"Yaxun (Sam) Liu" ,Nico Weber
 ,Stella Laurenzo ,Lang Hames
 ,Matthias Braun ,Arthur Eubanks
 ,Nico Weber ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Vitaly Buka
 ,Vitaly Buka ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,erichkeane ,Amir Ayupov
 ,Amir Ayupov ,yinying-lisa-li
 <107574043+yinying-lisa...@users.noreply.github.com>,Christopher Di Bella
 ,Konstantin Varlamov ,Alexey Bader
 ,Vitaly Buka 


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


[clang] [libc][libm][GPU] Added missing vendor entry points to `libm` for GPUs (PR #66031)

2023-09-11 Thread Anton Rydahl via cfe-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,MaheshRavishankar
 <1663364+maheshravishan...@users.noreply.github.com>,Fangrui Song
 ,Razvan Lupusoru ,Walter Erquinigo
 ,"Yaxun (Sam) Liu" ,Nico Weber
 ,Stella Laurenzo ,Lang Hames
 ,Matthias Braun ,Arthur Eubanks
 ,Nico Weber ,
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Vitaly Buka
 ,Vitaly Buka ,Fangrui Song
 ,Fangrui Song ,Fangrui Song 
,Fangrui
 Song ,erichkeane ,Amir Ayupov
 ,Amir Ayupov ,yinying-lisa-li
 <107574043+yinying-lisa...@users.noreply.github.com>,Christopher Di Bella
 ,Konstantin Varlamov ,Alexey Bader
 ,Vitaly Buka 


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


[PATCH] D152504: [clang][ThreadSafety] Analyze cleanup functions

2023-09-11 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: clang/lib/Analysis/ThreadSafetyCommon.cpp:320
 // Substitute call arguments for references to function parameters
-assert(I < Ctx->NumArgs);
-return translate(Ctx->FunArgs[I], Ctx->Prev);
+if (const auto *const *FunArgs =
+Ctx->FunArgs.dyn_cast()) {

I'd suggest to go either with `const auto *` or `const Expr *const *`.



Comment at: clang/test/Sema/warn-thread-safety-analysis.c:82-86
+void broken_cleanup_int(int *unused) __attribute__((release_capability(mu1))) {
+  (void)unused;
+  mutex_exclusive_unlock();
+  Bar_fun1(6); // expected-warning {{calling function 'Bar_fun1' requires 
holding mutex 'mu1' exclusively}}
+}

FWIW, this might not be so interesting. In the function we don't know that this 
is being used as a cleanup function, so we just look at it like any function. 
So we warn. This should already by covered by other tests and has nothing to do 
with the cleanup attribute.

In fact, we probably don't need the definition of any cleanup function, since 
the function we're interested in is one where it's being used.



Comment at: clang/test/Sema/warn-thread-safety-analysis.c:159
   return 0;
 }
 

Would you mind adding a test case that uses substitution? Something like this:

```lang=c
void unlock_scope(struct Mutex *const *mu) 
__attribute__((release_capability(**mu)));

void test() {
  struct Mutex* const __attribute__((cleanup(unlock_scope))) scope = 
  mutex_exclusive_lock(scope);  // Note that we have to lock through scope, 
because no alias analysis!
  // Cleanup happens automatically -> no warning.
}
```

This looks like something that might be used in actual C code, maybe hidden 
behind a macro.

In fact, the existing test case doesn't look terribly interesting to me.


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

https://reviews.llvm.org/D152504

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


[clang] a2e2f47 - [Clang][Docs] Fix typo in clang-offload-packager documentation

2023-09-11 Thread Alexey Bader via cfe-commits

Author: Alexey Bader
Date: 2023-09-11T16:24:37-07:00
New Revision: a2e2f471c51f0aea836a4929dfdf50523dcff1eb

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

LOG: [Clang][Docs] Fix typo in clang-offload-packager documentation

Fixed formatting of the section violating 80-char line limit.

Added: 


Modified: 
clang/docs/ClangOffloadPackager.rst

Removed: 




diff  --git a/clang/docs/ClangOffloadPackager.rst 
b/clang/docs/ClangOffloadPackager.rst
index 1d6ded952e8adfe..2b985e260e302de 100644
--- a/clang/docs/ClangOffloadPackager.rst
+++ b/clang/docs/ClangOffloadPackager.rst
@@ -124,7 +124,7 @@ array of the :ref:`string entry` 
format.
 
+--+--+---+
 |   Type   |   Identifier | Description
   |
 
+==+==+===+
-| uint64_t |  key offset  | Absolute byte offset of the key in th string 
table|
+| uint64_t |  key offset  | Absolute byte offset of the key in the string 
table   |
 
+--+--+---+
 | uint64_t | value offset | Absolute byte offset of the value in the 
string table |
 
+--+--+---+
@@ -145,9 +145,9 @@ Usage
 =
 
 This tool can be used with the following arguments. Generally information is
-passed as a key-value pair to the ``image=`` argument. The ``file`` and 
``triple``,
-arguments are considered mandatory to make a valid image. The ``arch`` argument
-is suggested.
+passed as a key-value pair to the ``image=`` argument. The ``file`` and
+``triple``, arguments are considered mandatory to make a valid image.
+The ``arch`` argument is suggested.
 
 .. code-block:: console
 



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


[clang] [Fuchsia] Support building runtimes for RISC-V on Linux (PR #66025)

2023-09-11 Thread Alex Brachet via cfe-commits

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


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


[PATCH] D157331: [clang] Implement C23

2023-09-11 Thread Zijun Zhao via Phabricator via cfe-commits
ZijunZhao updated this revision to Diff 556504.
ZijunZhao added a comment.

Remove c++ related conditions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157331

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/stdckdint.h
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/C/C2x/n2359.c
  clang/test/C/C2x/n2683.c
  clang/test/C/C2x/n2683_2.c
  clang/test/Headers/stdckdint.c
  clang/test/Modules/Inputs/System/usr/include/module.map
  clang/test/Sema/builtins-overflow.c
  clang/www/c_status.html

Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -887,6 +887,11 @@
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2672.pdf;>N2672
   Yes
 
+
+  Towards Integer Safety
+  https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2683.pdf;>N2683
+  Clang 18
+
 
   Adding Fundamental Type for N-bit Integers
 
Index: clang/test/Sema/builtins-overflow.c
===
--- clang/test/Sema/builtins-overflow.c
+++ clang/test/Sema/builtins-overflow.c
@@ -14,11 +14,11 @@
   __builtin_add_overflow();  // expected-error {{too few arguments to function call, expected 3, have 0}}
   __builtin_add_overflow(1, 1, 1, 1);  // expected-error {{too many arguments to function call, expected 3, have 4}}
 
-  __builtin_add_overflow(c, 1, );  // expected-error {{operand argument to overflow builtin must be an integer ('const char *' invalid)}}
-  __builtin_add_overflow(1, c, );  // expected-error {{operand argument to overflow builtin must be an integer ('const char *' invalid)}}
-  __builtin_add_overflow(1, 1, 3);  // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer ('int' invalid)}}
-  __builtin_add_overflow(1, 1, );  // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer ('float *' invalid)}}
-  __builtin_add_overflow(1, 1, );  // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer ('const unsigned int *' invalid)}}
+  __builtin_add_overflow(c, 1, );  // expected-error {{operand argument to overflow builtin must be an integer type ('const char *' invalid)}}
+  __builtin_add_overflow(1, c, );  // expected-error {{operand argument to overflow builtin must be an integer type ('const char *' invalid)}}
+  __builtin_add_overflow(1, 1, 3);  // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer type ('int' invalid)}}
+  __builtin_add_overflow(1, 1, );  // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer type ('float *' invalid)}}
+  __builtin_add_overflow(1, 1, );  // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer type ('const unsigned int *' invalid)}}
 
   {
 _BitInt(128) x = 1;
Index: clang/test/Modules/Inputs/System/usr/include/module.map
===
--- clang/test/Modules/Inputs/System/usr/include/module.map
+++ clang/test/Modules/Inputs/System/usr/include/module.map
@@ -14,6 +14,11 @@
 header "stdbool.h"
   }
 
+  // In both directories (compiler support version wins, does not forward)
+  module stdckdint {
+header "stdckdint.h"
+  }
+
   // In both directories (compiler support version wins, forwards)
   module stdint {
 header "stdint.h"
Index: clang/test/Headers/stdckdint.c
===
--- /dev/null
+++ clang/test/Headers/stdckdint.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -emit-llvm -verify -std=c23 %s -o - | FileCheck %s
+// expected-no-diagnostics
+#include 
+
+_Static_assert(__STDC_VERSION_STDCKDINT_H__ == 202311L, "");
+
+// CHECK-LABEL: define dso_local zeroext i1 @test_ckd_add() #0 {
+// CHECK:  entry:
+// CHECK:%result = alloca i32, align 4
+// CHECK:%0 = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 -1073741826, i32 -1073741826)
+// CHECK:%1 = extractvalue { i32, i1 } %0, 1
+// CHECK:%2 = extractvalue { i32, i1 } %0, 0
+// CHECK:store i32 %2, ptr %result, align 4
+// CHECK:ret i1 %1
+// CHECK:}
+// CHECK:; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
+// CHECK:declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) #1
+bool test_ckd_add() {
+  int result;
+  return ckd_add(, -1073741826, -1073741826);
+}
+
+// CHECK-LABEL: define dso_local zeroext i1 @test_ckd_sub() #0 {
+// CHECK:  entry:
+// CHECK:%result = alloca i32, align 4
+// CHECK:%0 = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 -1073741826, i32 

[PATCH] D135341: adds `__reference_constructs_from_temporary`

2023-09-11 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

Sorry, I had read @erichkeane's LGTM and taken that as actually approved. Would 
you like me to revert?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135341

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


[PATCH] D135341: adds `__reference_constructs_from_temporary`

2023-09-11 Thread Christopher Di Bella via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe1bfeb6bcc62: adds `__reference_constructs_from_temporary` 
(authored by cjdb).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135341

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/type-traits.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -292,10 +292,9 @@
   https://wg21.link/P2255R2;>P2255R2
   
 Partial
-  Clang provides a __reference_binds_to_temporary type trait
-  builtin, with which the library facility can be partially implemented.
-  Both __reference_constructs_from_temporary and
-  __reference_converts_from_temporary builtins should be
+  Clang provides __reference_constructs_from_temporary type
+  trait builtin, with which std::reference_constructs_from_temporary
+  implemented. __reference_converts_from_temporary needs to be
   provided, following the normal cross-vendor convention to implement
   traits requiring compiler support directly.
 
Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -2542,6 +2542,51 @@
   { int arr[T((__reference_binds_to_temporary(const int &, long)))]; }
 }
 
+void reference_constructs_from_temporary_checks() {
+  static_assert(!__reference_constructs_from_temporary(int &, int &), "");
+  static_assert(!__reference_constructs_from_temporary(int &, int &&), "");
+
+  static_assert(!__reference_constructs_from_temporary(int const &, int &), "");
+  static_assert(!__reference_constructs_from_temporary(int const &, int const &), "");
+  static_assert(!__reference_constructs_from_temporary(int const &, int &&), "");
+
+  static_assert(!__reference_constructs_from_temporary(int &, long &), ""); // doesn't construct
+
+  static_assert(__reference_constructs_from_temporary(int const &, long &), "");
+  static_assert(__reference_constructs_from_temporary(int const &, long &&), "");
+  static_assert(__reference_constructs_from_temporary(int &&, long &), "");
+
+  using LRef = ConvertsToRef;
+  using RRef = ConvertsToRef;
+  using CLRef = ConvertsToRef;
+  using LongRef = ConvertsToRef;
+  static_assert(__is_constructible(int &, LRef), "");
+  static_assert(!__reference_constructs_from_temporary(int &, LRef), "");
+
+  static_assert(__is_constructible(int &&, RRef), "");
+  static_assert(!__reference_constructs_from_temporary(int &&, RRef), "");
+
+  static_assert(__is_constructible(int const &, CLRef), "");
+  static_assert(!__reference_constructs_from_temporary(int &&, CLRef), "");
+
+  static_assert(__is_constructible(int const &, LongRef), "");
+  static_assert(__reference_constructs_from_temporary(int const &, LongRef), "");
+
+  // Test that it doesn't accept non-reference types as input.
+  static_assert(!__reference_constructs_from_temporary(int, long), "");
+
+  static_assert(__reference_constructs_from_temporary(const int &, long), "");
+
+  // Additional checks
+  static_assert(__reference_constructs_from_temporary(POD const&, Derives), "");
+  static_assert(__reference_constructs_from_temporary(int&&, int), "");
+  static_assert(__reference_constructs_from_temporary(const int&, int), "");
+  static_assert(!__reference_constructs_from_temporary(int&&, int&&), "");
+  static_assert(!__reference_constructs_from_temporary(const int&, int&&), "");
+  static_assert(__reference_constructs_from_temporary(int&&, long&&), "");
+  static_assert(__reference_constructs_from_temporary(int&&, long), "");
+}
+
 void array_rank() {
   int t01[T(__array_rank(IntAr) == 1)];
   int t02[T(__array_rank(ConstIntArAr) == 2)];
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -30,6 +30,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Basic/TypeTraits.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/EnterExpressionEvaluationContext.h"
@@ -5410,14 +5411,15 @@
   if (Kind <= UTT_Last)
 return EvaluateUnaryTypeTrait(S, Kind, KWLoc, Args[0]->getType());
 
-  // Evaluate BTT_ReferenceBindsToTemporary alongside the IsConstructible
-  // traits to 

[clang] e1bfeb6 - adds `__reference_constructs_from_temporary`

2023-09-11 Thread Christopher Di Bella via cfe-commits

Author: Christopher Di Bella
Date: 2023-09-11T23:14:08Z
New Revision: e1bfeb6bcc627a94c5ab3a5417d290c7dc516d54

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

LOG: adds `__reference_constructs_from_temporary`

This is information that the compiler already has, and should be exposed
so that the library doesn't need to reimplement the exact same
functionality.

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

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/include/clang/Basic/TokenKinds.def
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/type-traits.cpp
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 11cbdca7a268fc3..b9466b5a0bc2087 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1621,6 +1621,10 @@ The following type trait primitives are supported by 
Clang. Those traits marked
   materialized temporary object. If ``T`` is not a reference type the result
   is false. Note this trait will also return false when the initialization of
   ``T`` from ``U`` is ill-formed.
+  Deprecated, use ``__reference_constructs_from_temporary``.
+* ``__reference_constructs_from_temporary(T, U)`` (C++)
+  Returns true if a reference ``T`` can be constructed from a temporary of type
+  a non-cv-qualified ``U``.
 * ``__underlying_type`` (C++, GNU, Microsoft)
 
 In addition, the following expression traits are supported:

diff  --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 45ebc200b168986..72e8df8c793a7b6 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -531,6 +531,7 @@ TYPE_TRAIT_1(__is_scoped_enum, IsScopedEnum, KEYCXX)
 TYPE_TRAIT_1(__is_referenceable, IsReferenceable, KEYCXX)
 TYPE_TRAIT_1(__can_pass_in_regs, CanPassInRegs, KEYCXX)
 TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX)
+TYPE_TRAIT_2(__reference_constructs_from_temporary, 
ReferenceConstructsFromTemporary, KEYCXX)
 
 // Embarcadero Expression Traits
 EXPRESSION_TRAIT(__is_lvalue_expr, IsLValueExpr, KEYCXX)

diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp 
b/clang/lib/Lex/PPMacroExpansion.cpp
index 775cbfafa999602..ec6a084f228f32d 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -1695,6 +1695,7 @@ void Preprocessor::ExpandBuiltinMacro(Token ) {
   .Case("__array_rank", true)
   .Case("__array_extent", true)
   .Case("__reference_binds_to_temporary", true)
+  .Case("__reference_constructs_from_temporary", true)
 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) .Case("__" #Trait, true)
 #include "clang/Basic/TransformTypeTraits.def"
   .Default(false);

diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
b/clang/lib/Parse/ParseDeclCXX.cpp
index 730b6e55246d6b7..5fe9abb1fdcab30 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1655,7 +1655,9 @@ void Parser::ParseClassSpecifier(tok::TokenKind 
TagTokKind,
   tok::kw___is_union,
   tok::kw___is_unsigned,
   tok::kw___is_void,
-  tok::kw___is_volatile))
+  tok::kw___is_volatile,
+  tok::kw___reference_binds_to_temporary,
+  tok::kw___reference_constructs_from_temporary))
 // GNU libstdc++ 4.2 and libc++ use certain intrinsic names as the
 // name of struct templates, but some are keywords in GCC >= 4.3
 // and Clang. Therefore, when we see the token sequence "struct

diff  --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index f8bf785da2896a3..74664c34abdbd89 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1128,6 +1128,8 @@ ExprResult Parser::ParseCastExpression(CastParseKind 
ParseKind,
   REVERTIBLE_TYPE_TRAIT(__is_unsigned);
   REVERTIBLE_TYPE_TRAIT(__is_void);
   REVERTIBLE_TYPE_TRAIT(__is_volatile);
+  REVERTIBLE_TYPE_TRAIT(__reference_binds_to_temporary);
+  REVERTIBLE_TYPE_TRAIT(__reference_constructs_from_temporary);
 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) 
\
   REVERTIBLE_TYPE_TRAIT(RTT_JOIN(__, Trait));
 #include "clang/Basic/TransformTypeTraits.def"

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index a7be01319a72393..65e8edc7806ecd8 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -30,6 +30,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TokenKinds.h"
 

[clang] [clang-format] Fix a bug in annotating `&&` followed by `*` or `&` (PR #65933)

2023-09-11 Thread Owen Pan via cfe-commits

https://github.com/owenca updated 
https://github.com/llvm/llvm-project/pull/65933:

>From 70aafbc4717264205796fa2ea67d78482f9f2a0d Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Mon, 11 Sep 2023 01:00:24 -0700
Subject: [PATCH] [clang-format] Fix a bug in annotating `&&` followed by `*`
 or `&`

Fixes #65877.
---
 clang/lib/Format/TokenAnnotator.cpp   | 7 +--
 clang/unittests/Format/TokenAnnotatorTest.cpp | 6 ++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index e925bee44cd0c6a..142168e074bbc27 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2598,9 +2598,12 @@ class AnnotatingParser {
 if (InTemplateArgument && NextToken->Tok.isAnyIdentifier())
   return TT_BinaryOperator;
 
-// "&&(" is quite unlikely to be two successive unary "&".
-if (Tok.is(tok::ampamp) && NextToken->is(tok::l_paren))
+// "&&" followed by "(", "*", or "&" is quite unlikely to be two successive
+// unary "&".
+if (Tok.is(tok::ampamp) &&
+NextToken->isOneOf(tok::l_paren, tok::star, tok::amp)) {
   return TT_BinaryOperator;
+}
 
 // This catches some cases where evaluation order is used as control flow:
 //   aaa && aaa->f();
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 434852983712940..be025dab86fafa5 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -280,6 +280,12 @@ TEST_F(TokenAnnotatorTest, UnderstandsUsesOfStarAndAmp) {
   EXPECT_TOKEN(Tokens[12], tok::ampamp, TT_BinaryOperator);
   EXPECT_TOKEN(Tokens[27], tok::ampamp, TT_BinaryOperator);
 
+  Tokens = annotate("foo = *i < *j && *j > *k;");
+  EXPECT_EQ(Tokens.size(), 15u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::less, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[7], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[10], tok::greater, TT_BinaryOperator);
+
   FormatStyle Style = getLLVMStyle();
   Style.TypeNames.push_back("MYI");
   Tokens = annotate("if (MYI *p{nullptr})", Style);

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


[PATCH] D135238: [clang] adds copy-constructible type-trait builtins

2023-09-11 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb updated this revision to Diff 556500.
cjdb added a comment.

runs 'arc diff `git merge-base HEAD origin` --update D135238 
' to try and get CI happy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135238

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/type-traits.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -292,10 +292,9 @@
   https://wg21.link/P2255R2;>P2255R2
   
 Partial
-  Clang provides a __reference_binds_to_temporary type trait
-  builtin, with which the library facility can be partially implemented.
-  Both __reference_constructs_from_temporary and
-  __reference_converts_from_temporary builtins should be
+  Clang provides __reference_constructs_from_temporary type
+  trait builtin, with which std::reference_constructs_from_temporary
+  implemented. __reference_converts_from_temporary needs to be
   provided, following the normal cross-vendor convention to implement
   traits requiring compiler support directly.
 
Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -2542,6 +2542,51 @@
   { int arr[T((__reference_binds_to_temporary(const int &, long)))]; }
 }
 
+void reference_constructs_from_temporary_checks() {
+  static_assert(!__reference_constructs_from_temporary(int &, int &), "");
+  static_assert(!__reference_constructs_from_temporary(int &, int &&), "");
+
+  static_assert(!__reference_constructs_from_temporary(int const &, int &), "");
+  static_assert(!__reference_constructs_from_temporary(int const &, int const &), "");
+  static_assert(!__reference_constructs_from_temporary(int const &, int &&), "");
+
+  static_assert(!__reference_constructs_from_temporary(int &, long &), ""); // doesn't construct
+
+  static_assert(__reference_constructs_from_temporary(int const &, long &), "");
+  static_assert(__reference_constructs_from_temporary(int const &, long &&), "");
+  static_assert(__reference_constructs_from_temporary(int &&, long &), "");
+
+  using LRef = ConvertsToRef;
+  using RRef = ConvertsToRef;
+  using CLRef = ConvertsToRef;
+  using LongRef = ConvertsToRef;
+  static_assert(__is_constructible(int &, LRef), "");
+  static_assert(!__reference_constructs_from_temporary(int &, LRef), "");
+
+  static_assert(__is_constructible(int &&, RRef), "");
+  static_assert(!__reference_constructs_from_temporary(int &&, RRef), "");
+
+  static_assert(__is_constructible(int const &, CLRef), "");
+  static_assert(!__reference_constructs_from_temporary(int &&, CLRef), "");
+
+  static_assert(__is_constructible(int const &, LongRef), "");
+  static_assert(__reference_constructs_from_temporary(int const &, LongRef), "");
+
+  // Test that it doesn't accept non-reference types as input.
+  static_assert(!__reference_constructs_from_temporary(int, long), "");
+
+  static_assert(__reference_constructs_from_temporary(const int &, long), "");
+
+  // Additional checks
+  static_assert(__reference_constructs_from_temporary(POD const&, Derives), "");
+  static_assert(__reference_constructs_from_temporary(int&&, int), "");
+  static_assert(__reference_constructs_from_temporary(const int&, int), "");
+  static_assert(!__reference_constructs_from_temporary(int&&, int&&), "");
+  static_assert(!__reference_constructs_from_temporary(const int&, int&&), "");
+  static_assert(__reference_constructs_from_temporary(int&&, long&&), "");
+  static_assert(__reference_constructs_from_temporary(int&&, long), "");
+}
+
 void array_rank() {
   int t01[T(__array_rank(IntAr) == 1)];
   int t02[T(__array_rank(ConstIntArAr) == 2)];
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -30,6 +30,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Basic/TypeTraits.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/EnterExpressionEvaluationContext.h"
@@ -5410,14 +5411,15 @@
   if (Kind <= UTT_Last)
 return EvaluateUnaryTypeTrait(S, Kind, KWLoc, Args[0]->getType());
 
-  // Evaluate BTT_ReferenceBindsToTemporary alongside the IsConstructible
-  // traits to avoid duplication.
-  if (Kind <= BTT_Last && Kind != BTT_ReferenceBindsToTemporary)
+  // Evaluate ReferenceBindsToTemporary 

[PATCH] D135341: adds `__reference_constructs_from_temporary`

2023-09-11 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb updated this revision to Diff 556499.
cjdb added a comment.

I somehow made cxx_status.html worse in the previous commit, not better


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135341

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/type-traits.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -292,10 +292,9 @@
   https://wg21.link/P2255R2;>P2255R2
   
 Partial
-  Clang provides a __reference_binds_to_temporary type trait
-  builtin, with which the library facility can be partially implemented.
-  Both __reference_constructs_from_temporary and
-  __reference_converts_from_temporary builtins should be
+  Clang provides __reference_constructs_from_temporary type
+  trait builtin, with which std::reference_constructs_from_temporary
+  implemented. __reference_converts_from_temporary needs to be
   provided, following the normal cross-vendor convention to implement
   traits requiring compiler support directly.
 
Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -2542,6 +2542,51 @@
   { int arr[T((__reference_binds_to_temporary(const int &, long)))]; }
 }
 
+void reference_constructs_from_temporary_checks() {
+  static_assert(!__reference_constructs_from_temporary(int &, int &), "");
+  static_assert(!__reference_constructs_from_temporary(int &, int &&), "");
+
+  static_assert(!__reference_constructs_from_temporary(int const &, int &), "");
+  static_assert(!__reference_constructs_from_temporary(int const &, int const &), "");
+  static_assert(!__reference_constructs_from_temporary(int const &, int &&), "");
+
+  static_assert(!__reference_constructs_from_temporary(int &, long &), ""); // doesn't construct
+
+  static_assert(__reference_constructs_from_temporary(int const &, long &), "");
+  static_assert(__reference_constructs_from_temporary(int const &, long &&), "");
+  static_assert(__reference_constructs_from_temporary(int &&, long &), "");
+
+  using LRef = ConvertsToRef;
+  using RRef = ConvertsToRef;
+  using CLRef = ConvertsToRef;
+  using LongRef = ConvertsToRef;
+  static_assert(__is_constructible(int &, LRef), "");
+  static_assert(!__reference_constructs_from_temporary(int &, LRef), "");
+
+  static_assert(__is_constructible(int &&, RRef), "");
+  static_assert(!__reference_constructs_from_temporary(int &&, RRef), "");
+
+  static_assert(__is_constructible(int const &, CLRef), "");
+  static_assert(!__reference_constructs_from_temporary(int &&, CLRef), "");
+
+  static_assert(__is_constructible(int const &, LongRef), "");
+  static_assert(__reference_constructs_from_temporary(int const &, LongRef), "");
+
+  // Test that it doesn't accept non-reference types as input.
+  static_assert(!__reference_constructs_from_temporary(int, long), "");
+
+  static_assert(__reference_constructs_from_temporary(const int &, long), "");
+
+  // Additional checks
+  static_assert(__reference_constructs_from_temporary(POD const&, Derives), "");
+  static_assert(__reference_constructs_from_temporary(int&&, int), "");
+  static_assert(__reference_constructs_from_temporary(const int&, int), "");
+  static_assert(!__reference_constructs_from_temporary(int&&, int&&), "");
+  static_assert(!__reference_constructs_from_temporary(const int&, int&&), "");
+  static_assert(__reference_constructs_from_temporary(int&&, long&&), "");
+  static_assert(__reference_constructs_from_temporary(int&&, long), "");
+}
+
 void array_rank() {
   int t01[T(__array_rank(IntAr) == 1)];
   int t02[T(__array_rank(ConstIntArAr) == 2)];
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -30,6 +30,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Basic/TypeTraits.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/EnterExpressionEvaluationContext.h"
@@ -5410,14 +5411,15 @@
   if (Kind <= UTT_Last)
 return EvaluateUnaryTypeTrait(S, Kind, KWLoc, Args[0]->getType());
 
-  // Evaluate BTT_ReferenceBindsToTemporary alongside the IsConstructible
-  // traits to avoid duplication.
-  if (Kind <= BTT_Last && Kind != BTT_ReferenceBindsToTemporary)
+  // Evaluate ReferenceBindsToTemporary and ReferenceConstructsFromTemporary
+  // 

[clang] [Fuchsia] Support building runtimes for RISC-V on Linux (PR #66025)

2023-09-11 Thread via cfe-commits

llvmbot wrote:

@llvm/pr-subscribers-clang


Changes

We support RISC-V on Linux as the host platform for Fuchsia.
--
Full diff: https://github.com/llvm/llvm-project/pull/66025.diff

1 Files Affected:

- (modified) clang/cmake/caches/Fuchsia-stage2.cmake (+1-1) 



diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 4890040b1b6a2b4..bc4d9f1462b1814 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -132,7 +132,7 @@ if(WIN32 OR LLVM_WINSYSROOT)
   set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
 endif()
 
-foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;x86_64-unknown-linux-gnu)
+foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;riscv64-unknown-linux-gnu;x86_64-unknown-linux-gnu)
   if(LINUX_${target}_SYSROOT)
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}")




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


  1   2   3   4   5   6   >