[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-08-03 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

From yesterday's C++ clang WG meeting

- We can land this now
- We need to track the debugger issue
- We should mention the lack of debugging support in the release notes
- We should strive to improve the situation in the 18 time frame but it would 
not be blocker as few people may be impacted.
- We should remember to modify the release notes when debugger support is 
improved if that happens before clang 18


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

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


[clang] ab5ebe4 - [NFC][Clang][Test] Fix warning-as-error

2023-08-03 Thread Michael Platings via cfe-commits

Author: Michael Platings
Date: 2023-08-03T08:26:25+01:00
New Revision: ab5ebe4b2088ba3a22a7922cd8bd827a7cedc3a4

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

LOG: [NFC][Clang][Test] Fix warning-as-error

Since D156363 this test has been failing with -Wmissing-multilib if
multilib is configured for the BareMetal toolchain.
By setting sysroot the test is more hermetic and the failure is avoided.

Added: 


Modified: 
clang/test/Driver/fsemantic-interposition.c

Removed: 




diff  --git a/clang/test/Driver/fsemantic-interposition.c 
b/clang/test/Driver/fsemantic-interposition.c
index e2713de80f690a..0ee0dbb3be3471 100644
--- a/clang/test/Driver/fsemantic-interposition.c
+++ b/clang/test/Driver/fsemantic-interposition.c
@@ -1,20 +1,20 @@
-// RUN: %clang -target x86_64 %s -Werror -fpic -fsemantic-interposition -c 
-### 2>&1 | FileCheck %s
-// RUN: %clang -target x86_64 %s -Werror -fPIC -fsemantic-interposition -c 
-### 2>&1 | FileCheck %s
+// RUN: %clang --sysroot=%S/Inputs -target x86_64 %s -Werror -fpic 
-fsemantic-interposition -c -### 2>&1 | FileCheck %s
+// RUN: %clang --sysroot=%S/Inputs -target x86_64 %s -Werror -fPIC 
-fsemantic-interposition -c -### 2>&1 | FileCheck %s
 // CHECK: "-fsemantic-interposition"
 
 /// No-op for -fno-pic/-fpie.
-// RUN: %clang -target x86_64 %s -Werror -fsemantic-interposition -c -### 2>&1 
| FileCheck --check-prefix=NOOP %s
-// RUN: %clang -target x86_64 %s -Werror -fPIE -fsemantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NOOP %s
+// RUN: %clang --sysroot=%S/Inputs -target x86_64 %s -Werror 
-fsemantic-interposition -c -### 2>&1 | FileCheck --check-prefix=NOOP %s
+// RUN: %clang --sysroot=%S/Inputs -target x86_64 %s -Werror -fPIE 
-fsemantic-interposition -c -### 2>&1 | FileCheck --check-prefix=NOOP %s
 // NOOP-NOT: "-fsemantic-interposition"
 // NOOP-NOT: "-fno-semantic-interposition"
 
 /// If -fno-semantic-interposition is specified and the target supports local
 /// aliases, neither CC1 option is set.
-// RUN: %clang -target aarch64 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
-// RUN: %clang -target riscv32 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
-// RUN: %clang -target riscv64 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
-// RUN: %clang -target i386 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
-// RUN: %clang -target x86_64 %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=NO %s
+// RUN: %clang --sysroot=%S/Inputs -target aarch64 %s -Werror -fPIC 
-fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=NO %s
+// RUN: %clang --sysroot=%S/Inputs -target riscv32 %s -Werror -fPIC 
-fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=NO %s
+// RUN: %clang --sysroot=%S/Inputs -target riscv64 %s -Werror -fPIC 
-fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=NO %s
+// RUN: %clang --sysroot=%S/Inputs -target i386 %s -Werror -fPIC 
-fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=NO %s
+// RUN: %clang --sysroot=%S/Inputs -target x86_64 %s -Werror -fPIC 
-fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=NO %s
 // NO-NOT: "-fsemantic-interposition"
 // NO-NOT: "-fhalf-no-semantic-interposition"
 
@@ -23,8 +23,8 @@
 /// local aliases, use the traditional half-baked behavor: interprocedural
 /// optimizations are allowed but local aliases are not used. If references are
 /// not optimized out, semantic interposition at runtime is possible.
-// RUN: %clang -target ppc64le %s -Werror -fPIC -fno-semantic-interposition -c 
-### 2>&1 | FileCheck --check-prefix=HALF %s
+// RUN: %clang --sysroot=%S/Inputs -target ppc64le %s -Werror -fPIC 
-fno-semantic-interposition -c -### 2>&1 | FileCheck --check-prefix=HALF %s
 
-// RUN: %clang -target x86_64 %s -Werror -fPIC -c -### 2>&1 | FileCheck 
--check-prefix=HALF %s
+// RUN: %clang --sysroot=%S/Inputs -target x86_64 %s -Werror -fPIC -c -### 
2>&1 | FileCheck --check-prefix=HALF %s
 //
 // HALF: "-fhalf-no-semantic-interposition"



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


[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-08-03 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 546730.
SixWeining edited the summary of this revision.
SixWeining added a comment.

- work with `-fno-integrated-cc1`
- add mingsing `"`s in macros


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

Files:
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/lib/Basic/Targets/LoongArch.h
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/lib/Driver/ToolChains/Arch/LoongArch.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/loongarch-march-error.c
  clang/test/Driver/loongarch-march.c
  clang/test/Driver/loongarch-mtune-error.c
  clang/test/Driver/loongarch-mtune.c
  clang/test/Preprocessor/init-loongarch.c
  llvm/include/llvm/TargetParser/LoongArchTargetParser.h
  llvm/lib/Target/LoongArch/LoongArch.td
  llvm/lib/TargetParser/LoongArchTargetParser.cpp
  llvm/test/CodeGen/LoongArch/cpus-invalid.ll
  llvm/test/CodeGen/LoongArch/cpus.ll

Index: llvm/test/CodeGen/LoongArch/cpus.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/cpus.ll
@@ -0,0 +1,20 @@
+;; This tests that llc accepts all valid LoongArch CPUs.
+;; Note the 'generic' names have been tested in cpu-name-generic.ll.
+
+; RUN: llc < %s --mtriple=loongarch64 --mcpu=loongarch64 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 --mcpu=la464 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 2>&1 | FileCheck %s
+
+; CHECK-NOT: {{.*}} is not a recognized processor for this target
+
+define void @f() {
+  ret void
+}
+
+define void @tune_cpu_loongarch64() "tune-cpu"="loongarch64" {
+  ret void
+}
+
+define void @tune_cpu_la464() "tune-cpu"="la464" {
+  ret void
+}
Index: llvm/test/CodeGen/LoongArch/cpus-invalid.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/cpus-invalid.ll
@@ -0,0 +1,7 @@
+; RUN: llc < %s --mtriple=loongarch64 --mattr=+64bit --mcpu=invalidcpu 2>&1 | FileCheck %s
+
+; CHECK: {{.*}} is not a recognized processor for this target
+
+define void @f() {
+  ret void
+}
Index: llvm/lib/TargetParser/LoongArchTargetParser.cpp
===
--- llvm/lib/TargetParser/LoongArchTargetParser.cpp
+++ llvm/lib/TargetParser/LoongArchTargetParser.cpp
@@ -46,3 +46,15 @@
   }
   return false;
 }
+
+bool LoongArch::isValidCPUName(StringRef Name) { return isValidArchName(Name); }
+
+void LoongArch::fillValidCPUList(SmallVectorImpl &Values) {
+  for (const auto A : AllArchs)
+Values.emplace_back(A.Name);
+}
+
+StringRef LoongArch::getDefaultArch(bool Is64Bit) {
+  // TODO: use a real 32-bit arch name.
+  return Is64Bit ? "loongarch64" : "";
+}
Index: llvm/lib/Target/LoongArch/LoongArch.td
===
--- llvm/lib/Target/LoongArch/LoongArch.td
+++ llvm/lib/Target/LoongArch/LoongArch.td
@@ -117,6 +117,11 @@
 def : ProcessorModel<"generic-la32", NoSchedModel, [Feature32Bit]>;
 def : ProcessorModel<"generic-la64", NoSchedModel, [Feature64Bit, FeatureUAL]>;
 
+// Generic 64-bit processor with double-precision floating-point support.
+def : ProcessorModel<"loongarch64", NoSchedModel, [Feature64Bit,
+   FeatureUAL,
+   FeatureBasicD]>;
+
 // Support generic for compatibility with other targets. The triple will be used
 // to change to the appropriate la32/la64 version.
 def : ProcessorModel<"generic", NoSchedModel, []>;
Index: llvm/include/llvm/TargetParser/LoongArchTargetParser.h
===
--- llvm/include/llvm/TargetParser/LoongArchTargetParser.h
+++ llvm/include/llvm/TargetParser/LoongArchTargetParser.h
@@ -66,9 +66,12 @@
 
 bool isValidArchName(StringRef Arch);
 bool getArchFeatures(StringRef Arch, std::vector &Features);
+bool isValidCPUName(StringRef TuneCPU);
+void fillValidCPUList(SmallVectorImpl &Values);
+StringRef getDefaultArch(bool Is64Bit);
 
 } // namespace LoongArch
 
 } // namespace llvm
 
-#endif // LLVM_SUPPORT_LOONGARCHTARGETPARSER_H
+#endif // LLVM_TARGETPARSER_LOONGARCHTARGETPARSER_H
Index: clang/test/Preprocessor/init-loongarch.c
===
--- clang/test/Preprocessor/init-loongarch.c
+++ clang/test/Preprocessor/init-loongarch.c
@@ -787,3 +787,23 @@
 // LA64-FPU0-LP64S: #define __loongarch_lp64 1
 // LA64-FPU0-LP64S-NOT: #define __loongarch_single_float
 // LA64-FPU0-LP64S: #define __loongarch_soft_float 1
+
+/// Check __loongarch_arch and __loongarch_tune.
+
+// RUN: %clang --target=loongarch64 -x c -E -dM %s -o - | \
+// RUN:   FileCheck --match-full-lines --check-prefix=ARCH-TUNE -DARCH=loongarch64 -DTUNE=loongarch64 %s
+// RUN: %clang --target=loongarch64 -x c -E -dM %s -o - -march=loon

[PATCH] D155456: [RISCV] Support -m[no-]strict-align options

2023-08-03 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/test/Driver/riscv-features.c:41
+// DEFAULT: "-target-feature" "-unaligned-scalar-mem"
+// DEFAULT-NOT: "-target-feature" "+unaligned-scalar-mem"
+

wangpc wrote:
> arichardson wrote:
> > This looks a bit fragile, can we just check all -target-feature flags 
> > instead and add --implicit-check-not='-target-feature" to Filecheck?
> I'm so sorry that I may not get what you mean, can you tell me what kind of 
> change I need to make?
I would suggest keep this check simple as it, because the `-target-feature` 
list for RISC-V is very loong, the list will increase when we add new 
extension, and add new extension is kind of relative frequently happened for 
RISC-V, check the full feature list will increase the maintenance burden for 
adding new extensions IMO.

e.g.

```
$ clang --target=riscv32-unknown-elf -### %s -march=rv32gv -mstrict-align ~/x.c
 "/scratch1/kitoc/llvm-workspace/build/bin/clang-18" "-cc1" "-triple" 
"riscv32-unknown-unknown-elf" "-emit-obj" "-mrelax-all" "-dumpdir" "a-" 
"-disable-free" "-clear-ast-before-backend" "-main-file-name" "x.c" 
"-mrelocation-model" "static" "-mframe-pointer=all" "-fmath-errno" 
"-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" 
"-nostdsysteminc" "-target-cpu" "generic-rv32" "-target-feature" "+m" 
"-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d" 
"-target-feature" "+v" "-target-feature" "+zicsr" "-target-feature" "+zifencei" 
"-target-feature" "+zve32f" "-target-feature" "+zve32x" "-target-feature" 
"+zve64d" "-target-feature" "+zve64f" "-target-feature" "+zve64x" 
"-target-feature" "+zvl128b" "-target-feature" "+zvl32b" "-target-feature" 
"+zvl64b" "-target-feature" "-c" "-target-feature" "-e" "-target-feature" "-h" 
"-target-feature" "-svinval" "-target-feature" "-svnapot" "-target-feature" 
"-svpbmt" "-target-feature" "-xcvalu" "-target-feature" "-xcvbi" 
"-target-feature" "-xcvbitmanip" "-target-feature" "-xcvmac" "-target-feature" 
"-xcvsimd" "-target-feature" "-xsfcie" "-target-feature" "-xsfvcp" 
"-target-feature" "-xtheadba" "-target-feature" "-xtheadbb" "-target-feature" 
"-xtheadbs" "-target-feature" "-xtheadcmo" "-target-feature" "-xtheadcondmov" 
"-target-feature" "-xtheadfmemidx" "-target-feature" "-xtheadmac" 
"-target-feature" "-xtheadmemidx" "-target-feature" "-xtheadmempair" 
"-target-feature" "-xtheadsync" "-target-feature" "-xtheadvdot" 
"-target-feature" "-xventanacondops" "-target-feature" "-zawrs" 
"-target-feature" "-zba" "-target-feature" "-zbb" "-target-feature" "-zbc" 
"-target-feature" "-zbkb" "-target-feature" "-zbkc" "-target-feature" "-zbkx" 
"-target-feature" "-zbs" "-target-feature" "-zca" "-target-feature" "-zcb" 
"-target-feature" "-zcd" "-target-feature" "-zce" "-target-feature" "-zcf" 
"-target-feature" "-zcmp" "-target-feature" "-zcmt" "-target-feature" "-zdinx" 
"-target-feature" "-zfh" "-target-feature" "-zfhmin" "-target-feature" "-zfinx" 
"-target-feature" "-zhinx" "-target-feature" "-zhinxmin" "-target-feature" 
"-zicbom" "-target-feature" "-zicbop" "-target-feature" "-zicboz" 
"-target-feature" "-zicntr" "-target-feature" "-zihintpause" "-target-feature" 
"-zihpm" "-target-feature" "-zk" "-target-feature" "-zkn" "-target-feature" 
"-zknd" "-target-feature" "-zkne" "-target-feature" "-zknh" "-target-feature" 
"-zkr" "-target-feature" "-zks" "-target-feature" "-zksed" "-target-feature" 
"-zksh" "-target-feature" "-zkt" "-target-feature" "-zmmul" "-target-feature" 
"-zvfh" "-target-feature" "-zvl1024b" "-target-feature" "-zvl16384b" 
"-target-feature" "-zvl2048b" "-target-feature" "-zvl256b" "-target-feature" 
"-zvl32768b" "-target-feature" "-zvl4096b" "-target-feature" "-zvl512b" 
"-target-feature" "-zvl65536b" "-target-feature" "-zvl8192b" "-target-feature" 
"-experimental-smaia" "-target-feature" "-experimental-ssaia" "-target-feature" 
"-experimental-zacas" "-target-feature" "-experimental-zfa" "-target-feature" 
"-experimental-zfbfmin" "-target-feature" "-experimental-zicond" 
"-target-feature" "-experimental-zihintntl" "-target-feature" 
"-experimental-ztso" "-target-feature" "-experimental-zvbb" "-target-feature" 
"-experimental-zvbc" "-target-feature" "-experimental-zvfbfmin" 
"-target-feature" "-experimental-zvfbfwma" "-target-feature" 
"-experimental-zvkg" "-target-feature" "-experimental-zvkn" "-target-feature" 
"-experimental-zvknc" "-target-feature" "-experimental-zvkned" 
"-target-feature" "-experimental-zvkng" "-target-feature" 
"-experimental-zvknha" "-target-feature" "-experimental-zvknhb" 
"-target-feature" "-experimental-zvks" "-target-feature" "-experimental-zvksc" 
"-target-feature" "-experimental-zvksed" "-target-feature" 
"-experimental-zvksg" "-target-feature" "-experimental-zvksh" "-target-feature" 
"-experimental-zvkt" "-target-feature" "+relax" "-target-feature" 
"-save-restore" "-target-abi

[PATCH] D155370: [CodeComplete] Improve FunctionCanBeCall

2023-08-03 Thread Younan Zhang via Phabricator via cfe-commits
zyounan planned changes to this revision.
zyounan added a comment.

In D155370#4552967 , @nridge wrote:

> I was thinking of functions with different names (with a common prefix) and 
> different signatures, where the signature could be a useful piece of 
> information in addition to the name to help you choose the right one.

Ah, that makes sense! Honestly, I've never thought the signature could assist 
such a scenario.

> Note, we have a flag that affects this, `--completion-style=detailed`.

Thanks. Just learned this flag.

Apart from the `Signature`, I still have two improvements for `CanBeCall`. I 
think it's better to close this review and merge these two changes into one 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155370

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


[PATCH] D156223: [RISCV] Resolve a few bugs in RISCVVIntrinsicUtils.cpp

2023-08-03 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:136
   case Invalid:
+  case Undefined:
 llvm_unreachable("Unhandled type.");

4vtomat wrote:
> eopXD wrote:
> > Could we just reuse `Invalid`?
> We can't reuse Invalid, since `ScalarType` in `RVVType` class is default to 
> `Invalid`, we are not able to determine whether it's really invalid or not 
> during `applyModifier` function, so that's the reason why I added `Undefined` 
> to differentiate between `default` and `really invalid`.
I has some question before too :P thanks for explanation!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156223

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


[PATCH] D156221: [RISCV] Support overloaded version ntlh intrinsic function

2023-08-03 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.
This revision is now accepted and ready to land.

LGTM, and the change seems like is fewer than my exception :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156221

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


[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-08-03 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/LoongArch.cpp:199-204
+  // Handle CPU name is 'native'.
+  if (CPU == "native") {
+CPU = llvm::sys::getHostCPUName();
+if (CPU == "generic")
+  CPU = llvm::LoongArch::getDefaultArch(Triple.isLoongArch64());
+  }

This part is identical between `-march=` and `-mtune=` handling. I'd suggest 
extracting out a common helper for this, or making this function generic over 
`options::OPT_m*_EQ` (whichever more suitable for you and the Clang 
maintainers; I don't have a particular preference).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

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


[PATCH] D125788: [flang][driver] Rename `flang-new` as `flang`

2023-08-03 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a subscriber: everythingfunctional.
awarzynski added a comment.

In D125788#4556324 , @MaskRay wrote:

> If you continue this work, consider landing this rename in multiple phases, 
> e.g.
>
> - Use lit substitutions instead of `flang-new` and other preparatory stuff so 
> that the next step has very little change
> - change flang-new to flang and add flang-new as a symlink for compatibility
> - remove the symlink `flang-new`, when it is no longer used.
>
> Many build bots can fail in weird ways and ensuring that we will not revert a 
> large change prevents causing churn to the tests.

Thank you, these are great pointers! CC @everythingfunctional


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125788

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


[PATCH] D156861: [Driver] Remove references to Solaris 12

2023-08-03 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D156861#4555280 , @MaskRay wrote:

> While you are modifying the lines `static const char ...[]` should look 
> better than `static const char *const SolarisX86Triples[]`

While this would certainly avoid the ugly formatting, it doesn't compile.  
Besides, I'd rather avoid using different styles just a few lines apart.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156861

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


[PATCH] D156971: [clang-format] Handle "// clang-format on" for SeparateDefinitionBlocks

2023-08-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, MyDeveloperDay.
owenpan requested review of this revision.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156971

Files:
  clang/lib/Format/DefinitionBlockSeparator.cpp
  clang/unittests/Format/DefinitionBlockSeparatorTest.cpp


Index: clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
===
--- clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
+++ clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
@@ -283,6 +283,15 @@
 TEST_F(DefinitionBlockSeparatorTest, Always) {
   FormatStyle Style = getLLVMStyle();
   Style.SeparateDefinitionBlocks = FormatStyle::SDS_Always;
+
+  verifyFormat("// clang-format off\n"
+   "template\n"
+   "concept C = not A>;\n"
+   "// clang-format on\n"
+   "\n"
+   "struct E {};",
+   Style);
+
   std::string Prefix = "namespace {\n";
   std::string Infix = "\n"
   "// Enum test1\n"
Index: clang/lib/Format/DefinitionBlockSeparator.cpp
===
--- clang/lib/Format/DefinitionBlockSeparator.cpp
+++ clang/lib/Format/DefinitionBlockSeparator.cpp
@@ -143,8 +143,10 @@
   if (LikelyDefinition(OperateLine))
 return false;
 
-  if (OperateLine->First->is(tok::comment))
+  if (const auto *Tok = OperateLine->First;
+  Tok->is(tok::comment) && !isClangFormatOn(Tok->TokenText)) {
 return true;
+  }
 
   // A single line identifier that is not in the last line.
   if (OperateLine->First->is(tok::identifier) &&


Index: clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
===
--- clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
+++ clang/unittests/Format/DefinitionBlockSeparatorTest.cpp
@@ -283,6 +283,15 @@
 TEST_F(DefinitionBlockSeparatorTest, Always) {
   FormatStyle Style = getLLVMStyle();
   Style.SeparateDefinitionBlocks = FormatStyle::SDS_Always;
+
+  verifyFormat("// clang-format off\n"
+   "template\n"
+   "concept C = not A>;\n"
+   "// clang-format on\n"
+   "\n"
+   "struct E {};",
+   Style);
+
   std::string Prefix = "namespace {\n";
   std::string Infix = "\n"
   "// Enum test1\n"
Index: clang/lib/Format/DefinitionBlockSeparator.cpp
===
--- clang/lib/Format/DefinitionBlockSeparator.cpp
+++ clang/lib/Format/DefinitionBlockSeparator.cpp
@@ -143,8 +143,10 @@
   if (LikelyDefinition(OperateLine))
 return false;
 
-  if (OperateLine->First->is(tok::comment))
+  if (const auto *Tok = OperateLine->First;
+  Tok->is(tok::comment) && !isClangFormatOn(Tok->TokenText)) {
 return true;
+  }
 
   // A single line identifier that is not in the last line.
   if (OperateLine->First->is(tok::identifier) &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127762: [Clang][AArch64] Add/implement ACLE keywords for SME.

2023-08-03 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm added a comment.

Thanks for dropping the attribute requirements down to TargetAArch64.  But the 
offsetting requirement was that something somewhere (CodeGen?) must raise an 
error if code requires SME and SME isn't present.  I think that means:

1. SME is not enabled for an `__arm_streaming` or `__arm_locally_streaming` 
function definition.
2. SME is not enabled for a call to an `__arm_streaming` function.
3. SME is not enabled for an `__arm_shared_za` or `__arm_new_za` function 
definition.

(Calls to `__arm_shared_za` functions don't need to be listed explicitly, since 
only `__arm_shared_za` and `__arm_new_za` functions can make such calls.)

In all cases, the check would apply after `__attribute__((target_version))` is 
taken into account.

Perhaps that's a separate patch though.




Comment at: clang/include/clang/Basic/AttrDocs.td:6645
+responsibility to do this.  Clang will ensure that the generated code in
+streaming-compatible functions is valid in either mode (PSTATE.SM=0 or
+PSTATE.SM=1). For example, if an ``__arm_streaming_compatible`` function calls 
a





Comment at: clang/test/Sema/aarch64-sme-func-attrs.c:186
+struct S2_2 : public S {
+// expected-cpp-error@+2 {{virtual function 'shared_za_memberfn' has different 
attributes ('void () __arm_shared_za __arm_preserves_za') than the function it 
overrides (which has 'void () __arm_shared_za')}}
+// expected-cpp-note@-11 {{overridden virtual function is here}}

Thanks, this is indeed the case I was suggesting to test.  But my point was 
that it shouldn't be an error.  It's OK for an override to be 
`__arm_preserves_za` even if the function it overrides isn't.  Something that 
calls `shared_za_member` directly from an `S2_2` object can take advantage of 
the extra guarantee.

It's the other way that's wrong.  If a virtual function is `__arm_preserves_za` 
then any override must be too.

The principle is similar to covariant return types. E.g.:
```
struct S1 { virtual S1 *f(); };
struct S2 : S1 { S2 *f() override; }; // OK
struct S3 : S2 { S2 *f() override; }; // OK
struct S4 : S3 { S1 *f() override; }; // Error
```
An `__arm_preserves_za` function acts like functions that return `S2 *` in this 
example, and a non-`__arm_preserves_za` function acts like functions that 
return `S1 *`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127762

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


[clang] d0dc887 - [Driver] Remove references to Solaris 12

2023-08-03 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2023-08-03T09:54:25+02:00
New Revision: d0dc887d7ed285688004c75de3784cfe94febd34

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

LOG: [Driver] Remove references to Solaris 12

Solaris 12 was re-christened as Solaris 11.4 while still in beta, so all
references are long obsolete and can be removed.

Tested on `amd64-pc-solaris2.11`.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index b64fff8b14be8a..7aa6984ab8f353 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2407,13 +2407,11 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   if (TargetTriple.getOS() == llvm::Triple::Solaris) {
 static const char *const SolarisLibDirs[] = {"/lib"};
 static const char *const SolarisSparcV8Triples[] = {
-"sparc-sun-solaris2.11", "sparc-sun-solaris2.12"};
+"sparc-sun-solaris2.11"};
 static const char *const SolarisSparcV9Triples[] = {
-"sparcv9-sun-solaris2.11", "sparcv9-sun-solaris2.12"};
-static const char *const SolarisX86Triples[] = {"i386-pc-solaris2.11",
-"i386-pc-solaris2.12"};
-static const char *const SolarisX86_64Triples[] = {"x86_64-pc-solaris2.11",
-   
"x86_64-pc-solaris2.12"};
+"sparcv9-sun-solaris2.11"};
+static const char *const SolarisX86Triples[] = {"i386-pc-solaris2.11"};
+static const char *const SolarisX86_64Triples[] = 
{"x86_64-pc-solaris2.11"};
 LibDirs.append(begin(SolarisLibDirs), end(SolarisLibDirs));
 BiarchLibDirs.append(begin(SolarisLibDirs), end(SolarisLibDirs));
 switch (TargetTriple.getArch()) {



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


[PATCH] D156861: [Driver] Remove references to Solaris 12

2023-08-03 Thread Rainer Orth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd0dc887d7ed2: [Driver] Remove references to Solaris 12 
(authored by ro).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156861

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2407,13 +2407,11 @@
   if (TargetTriple.getOS() == llvm::Triple::Solaris) {
 static const char *const SolarisLibDirs[] = {"/lib"};
 static const char *const SolarisSparcV8Triples[] = {
-"sparc-sun-solaris2.11", "sparc-sun-solaris2.12"};
+"sparc-sun-solaris2.11"};
 static const char *const SolarisSparcV9Triples[] = {
-"sparcv9-sun-solaris2.11", "sparcv9-sun-solaris2.12"};
-static const char *const SolarisX86Triples[] = {"i386-pc-solaris2.11",
-"i386-pc-solaris2.12"};
-static const char *const SolarisX86_64Triples[] = {"x86_64-pc-solaris2.11",
-   
"x86_64-pc-solaris2.12"};
+"sparcv9-sun-solaris2.11"};
+static const char *const SolarisX86Triples[] = {"i386-pc-solaris2.11"};
+static const char *const SolarisX86_64Triples[] = 
{"x86_64-pc-solaris2.11"};
 LibDirs.append(begin(SolarisLibDirs), end(SolarisLibDirs));
 BiarchLibDirs.append(begin(SolarisLibDirs), end(SolarisLibDirs));
 switch (TargetTriple.getArch()) {


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2407,13 +2407,11 @@
   if (TargetTriple.getOS() == llvm::Triple::Solaris) {
 static const char *const SolarisLibDirs[] = {"/lib"};
 static const char *const SolarisSparcV8Triples[] = {
-"sparc-sun-solaris2.11", "sparc-sun-solaris2.12"};
+"sparc-sun-solaris2.11"};
 static const char *const SolarisSparcV9Triples[] = {
-"sparcv9-sun-solaris2.11", "sparcv9-sun-solaris2.12"};
-static const char *const SolarisX86Triples[] = {"i386-pc-solaris2.11",
-"i386-pc-solaris2.12"};
-static const char *const SolarisX86_64Triples[] = {"x86_64-pc-solaris2.11",
-   "x86_64-pc-solaris2.12"};
+"sparcv9-sun-solaris2.11"};
+static const char *const SolarisX86Triples[] = {"i386-pc-solaris2.11"};
+static const char *const SolarisX86_64Triples[] = {"x86_64-pc-solaris2.11"};
 LibDirs.append(begin(SolarisLibDirs), end(SolarisLibDirs));
 BiarchLibDirs.append(begin(SolarisLibDirs), end(SolarisLibDirs));
 switch (TargetTriple.getArch()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156787: [analyzer][attr] Add docs to ownership_* attributes

2023-08-03 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/test/Analysis/malloc-annotations.c:151-155
+void af6(void) {
+  int *p = my_malloc(12);
+  my_hold(p);
+  *p = 4;
+}

Please, consider elaborating on this test with some comments, as it's not clear 
to me at first glance - without reading anything about the attributes - what's 
going on here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156787

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


[clang] e68ffa3 - [Driver] Make test work on targets that have no OpenMP library configured

2023-08-03 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2023-08-03T09:59:49+02:00
New Revision: e68ffa373f7f3e61de4e030d126f9968679cdfdc

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

LOG: [Driver] Make test work on targets that have no OpenMP library configured

Added: 


Modified: 
clang/test/Driver/openmp-offload-infer.c

Removed: 




diff  --git a/clang/test/Driver/openmp-offload-infer.c 
b/clang/test/Driver/openmp-offload-infer.c
index d7c37716cd3029..9a949f52e2e97d 100644
--- a/clang/test/Driver/openmp-offload-infer.c
+++ b/clang/test/Driver/openmp-offload-infer.c
@@ -39,7 +39,7 @@
 // CHECK-ARCH-BINDINGS: "x86_64-unknown-linux-gnu" - "clang", inputs: 
["[[HOST_BC]]", "[[BINARY]]"], output: "[[HOST_OBJ:.*]]"
 // CHECK-ARCH-BINDINGS: "x86_64-unknown-linux-gnu" - "Offload::Linker", 
inputs: ["[[HOST_OBJ]]"], output: "a.out"
 
-// RUN:   not %clang -### --target=x86_64-unknown-linux-gnu 
-ccc-print-bindings -fopenmp \
+// RUN:   not %clang -### --target=x86_64-unknown-linux-gnu 
-ccc-print-bindings -fopenmp=libomp \
 // RUN: --offload-arch=sm_70 --offload-arch=gfx908 --offload-arch=skylake \
 // RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-FAILED
 



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


[PATCH] D156221: [RISCV] Support overloaded version ntlh intrinsic function

2023-08-03 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added inline comments.



Comment at: clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c:218
 // CHECK: !8 = !{i32 5}
\ No newline at end of file


Nit: new line here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156221

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


[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-08-03 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 546742.
SixWeining marked an inline comment as done.
SixWeining added a comment.

Add a common helper for `-m{arch,tune}=native` handling.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

Files:
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/lib/Basic/Targets/LoongArch.h
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/lib/Driver/ToolChains/Arch/LoongArch.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/loongarch-march-error.c
  clang/test/Driver/loongarch-march.c
  clang/test/Driver/loongarch-mtune-error.c
  clang/test/Driver/loongarch-mtune.c
  clang/test/Preprocessor/init-loongarch.c
  llvm/include/llvm/TargetParser/LoongArchTargetParser.h
  llvm/lib/Target/LoongArch/LoongArch.td
  llvm/lib/TargetParser/LoongArchTargetParser.cpp
  llvm/test/CodeGen/LoongArch/cpus-invalid.ll
  llvm/test/CodeGen/LoongArch/cpus.ll

Index: llvm/test/CodeGen/LoongArch/cpus.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/cpus.ll
@@ -0,0 +1,20 @@
+;; This tests that llc accepts all valid LoongArch CPUs.
+;; Note the 'generic' names have been tested in cpu-name-generic.ll.
+
+; RUN: llc < %s --mtriple=loongarch64 --mcpu=loongarch64 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 --mcpu=la464 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 2>&1 | FileCheck %s
+
+; CHECK-NOT: {{.*}} is not a recognized processor for this target
+
+define void @f() {
+  ret void
+}
+
+define void @tune_cpu_loongarch64() "tune-cpu"="loongarch64" {
+  ret void
+}
+
+define void @tune_cpu_la464() "tune-cpu"="la464" {
+  ret void
+}
Index: llvm/test/CodeGen/LoongArch/cpus-invalid.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/cpus-invalid.ll
@@ -0,0 +1,7 @@
+; RUN: llc < %s --mtriple=loongarch64 --mattr=+64bit --mcpu=invalidcpu 2>&1 | FileCheck %s
+
+; CHECK: {{.*}} is not a recognized processor for this target
+
+define void @f() {
+  ret void
+}
Index: llvm/lib/TargetParser/LoongArchTargetParser.cpp
===
--- llvm/lib/TargetParser/LoongArchTargetParser.cpp
+++ llvm/lib/TargetParser/LoongArchTargetParser.cpp
@@ -46,3 +46,15 @@
   }
   return false;
 }
+
+bool LoongArch::isValidCPUName(StringRef Name) { return isValidArchName(Name); }
+
+void LoongArch::fillValidCPUList(SmallVectorImpl &Values) {
+  for (const auto A : AllArchs)
+Values.emplace_back(A.Name);
+}
+
+StringRef LoongArch::getDefaultArch(bool Is64Bit) {
+  // TODO: use a real 32-bit arch name.
+  return Is64Bit ? "loongarch64" : "";
+}
Index: llvm/lib/Target/LoongArch/LoongArch.td
===
--- llvm/lib/Target/LoongArch/LoongArch.td
+++ llvm/lib/Target/LoongArch/LoongArch.td
@@ -117,6 +117,11 @@
 def : ProcessorModel<"generic-la32", NoSchedModel, [Feature32Bit]>;
 def : ProcessorModel<"generic-la64", NoSchedModel, [Feature64Bit, FeatureUAL]>;
 
+// Generic 64-bit processor with double-precision floating-point support.
+def : ProcessorModel<"loongarch64", NoSchedModel, [Feature64Bit,
+   FeatureUAL,
+   FeatureBasicD]>;
+
 // Support generic for compatibility with other targets. The triple will be used
 // to change to the appropriate la32/la64 version.
 def : ProcessorModel<"generic", NoSchedModel, []>;
Index: llvm/include/llvm/TargetParser/LoongArchTargetParser.h
===
--- llvm/include/llvm/TargetParser/LoongArchTargetParser.h
+++ llvm/include/llvm/TargetParser/LoongArchTargetParser.h
@@ -66,9 +66,12 @@
 
 bool isValidArchName(StringRef Arch);
 bool getArchFeatures(StringRef Arch, std::vector &Features);
+bool isValidCPUName(StringRef TuneCPU);
+void fillValidCPUList(SmallVectorImpl &Values);
+StringRef getDefaultArch(bool Is64Bit);
 
 } // namespace LoongArch
 
 } // namespace llvm
 
-#endif // LLVM_SUPPORT_LOONGARCHTARGETPARSER_H
+#endif // LLVM_TARGETPARSER_LOONGARCHTARGETPARSER_H
Index: clang/test/Preprocessor/init-loongarch.c
===
--- clang/test/Preprocessor/init-loongarch.c
+++ clang/test/Preprocessor/init-loongarch.c
@@ -787,3 +787,23 @@
 // LA64-FPU0-LP64S: #define __loongarch_lp64 1
 // LA64-FPU0-LP64S-NOT: #define __loongarch_single_float
 // LA64-FPU0-LP64S: #define __loongarch_soft_float 1
+
+/// Check __loongarch_arch and __loongarch_tune.
+
+// RUN: %clang --target=loongarch64 -x c -E -dM %s -o - | \
+// RUN:   FileCheck --match-full-lines --check-prefix=ARCH-TUNE -DARCH=loongarch64 -DTUNE=loongarch64 %s
+// RUN: %clang --target=loongarch64 -x c -E -dM %s -o - -march=loongarch64 | 

[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-08-03 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/LoongArch.cpp:199-204
+  // Handle CPU name is 'native'.
+  if (CPU == "native") {
+CPU = llvm::sys::getHostCPUName();
+if (CPU == "generic")
+  CPU = llvm::LoongArch::getDefaultArch(Triple.isLoongArch64());
+  }

xen0n wrote:
> This part is identical between `-march=` and `-mtune=` handling. I'd suggest 
> extracting out a common helper for this, or making this function generic over 
> `options::OPT_m*_EQ` (whichever more suitable for you and the Clang 
> maintainers; I don't have a particular preference).
Thanks. Just added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

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


[PATCH] D156724: [StaticAnalyzer] Fix incorrect link to "note" diagnostics in HTML output

2023-08-03 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

Looks correct.
Please merge it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156724

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


[PATCH] D138810: [RISCV] Support vector crypto extension C intrinsics

2023-08-03 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 546746.
4vtomat added a comment.

This update does a few things:

1. Update test cases based on rvv-intrinsic-doc.
2. Add checks for "zvknh[a|b]" instructions.
3. Rename and restructure the function from CheckInvalidEGW to 
CheckInvalidVLENandLMUL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138810

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Basic/riscv_vector_common.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesef.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesem.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaeskf1.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaeskf2.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vandn.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vbrev.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vbrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclmulh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vcpopv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vctz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vghsh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vgmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vrol.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vror.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2ch.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2cl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2ms.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm3c.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm3me.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4k.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4r.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwsll.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdf.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdm.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesef.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesem.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaeskf1.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaeskf2.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vandn.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vbrev.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vbrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vclmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vclmulh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vclz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcpopv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vctz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vghsh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vgmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vrol.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vror.c
  
clang/test/CodeGen/R

[clang] f3ce925 - [RISCV] Resolve a few bugs in RISCVVIntrinsicUtils.cpp

2023-08-03 Thread via cfe-commits

Author: 4vtomat
Date: 2023-08-03T01:48:23-07:00
New Revision: f3ce925083d2214289c73b8f21590ac32beef03d

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

LOG: [RISCV] Resolve a few bugs in RISCVVIntrinsicUtils.cpp

This patch does a few things:
  1. Add a new type called Undefined to ScalarTypeKind.
  2. Make RVVType::applyModifier early return when encounter invalid
 ScalarType, otherwise it could be modified to "non-invalid" type in the 
following code.
  3. When FixedLMULType::SmallerThan is applied, the lmul should be "<" than
 specified one, so lmuls which are ">=" should be marked as invalid.

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

Added: 

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlmul_trunc_v_invalid.c

Modified: 
clang/include/clang/Support/RISCVVIntrinsicUtils.h
clang/lib/Sema/SemaRISCVVectorLookup.cpp
clang/lib/Support/RISCVVIntrinsicUtils.cpp

Removed: 




diff  --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h 
b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
index 804b1518c06b51..e69df9ed720607 100644
--- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -218,6 +218,7 @@ enum ScalarTypeKind : uint8_t {
   UnsignedInteger,
   Float,
   Invalid,
+  Undefined,
 };
 
 // Exponential LMUL
@@ -240,7 +241,7 @@ class RVVType {
   friend class RVVTypeCache;
 
   BasicType BT;
-  ScalarTypeKind ScalarType = Invalid;
+  ScalarTypeKind ScalarType = Undefined;
   LMULType LMUL;
   bool IsPointer = false;
   // IsConstant indices are "int", but have the constant expression.

diff  --git a/clang/lib/Sema/SemaRISCVVectorLookup.cpp 
b/clang/lib/Sema/SemaRISCVVectorLookup.cpp
index db2059e68b3d17..eec2bc11e35d9e 100644
--- a/clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ b/clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -133,6 +133,7 @@ static QualType RVVType2Qual(ASTContext &Context, const 
RVVType *Type) {
 }
 break;
   case Invalid:
+  case Undefined:
 llvm_unreachable("Unhandled type.");
   }
   if (Type->isVector()) {

diff  --git a/clang/lib/Support/RISCVVIntrinsicUtils.cpp 
b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
index 4b9736b6009ca9..abb4009ef2bce9 100644
--- a/clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -742,6 +742,10 @@ void RVVType::applyModifier(const PrototypeDescriptor 
&Transformer) {
 break;
   }
 
+  // Early return if the current type modifier is already invalid.
+  if (ScalarType == Invalid)
+return;
+
   for (unsigned TypeModifierMaskShift = 0;
TypeModifierMaskShift <= static_cast(TypeModifier::MaxOffset);
++TypeModifierMaskShift) {
@@ -803,13 +807,13 @@ void RVVType::applyFixedSEW(unsigned NewSEW) {
 void RVVType::applyFixedLog2LMUL(int Log2LMUL, enum FixedLMULType Type) {
   switch (Type) {
   case FixedLMULType::LargerThan:
-if (Log2LMUL < LMUL.Log2LMUL) {
+if (Log2LMUL <= LMUL.Log2LMUL) {
   ScalarType = ScalarTypeKind::Invalid;
   return;
 }
 break;
   case FixedLMULType::SmallerThan:
-if (Log2LMUL > LMUL.Log2LMUL) {
+if (Log2LMUL >= LMUL.Log2LMUL) {
   ScalarType = ScalarTypeKind::Invalid;
   return;
 }

diff  --git 
a/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlmul_trunc_v_invalid.c
 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlmul_trunc_v_invalid.c
new file mode 100644
index 00..d00db214a69dcc
--- /dev/null
+++ 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlmul_trunc_v_invalid.c
@@ -0,0 +1,21 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +zvfh -disable-O0-optnone %s -fsyntax-only -verify
+
+#include 
+
+vuint64m2_t test_vlmul_trunc_v_u64m2_u64m2(vuint64m2_t op1) { // expected-note 
{{'test_vlmul_trunc_v_u64m2_u64m2' declared here}}
+  return __riscv_vlmul_trunc_v_u64m2_u64m2(op1); // expected-error {{call to 
undeclared function '__riscv_vlmul_trunc_v_u64m2_u64m2'; ISO C99 and later do 
not support implicit function declarations}} expected-error {{returning 'int' 
from a function with incompatible result type 'vuint64m2_t' (aka 
'__rvv_uint64m2_t')}} expected-note {{did you mean 
'test_vlmul_trunc_v_u64m2_u64m2'?}}
+}
+
+vuint64m4_t test_vlmul_trunc_v_u64m4_u64m4(vuint64m4_t op1) { // expected-note 
{{'test_vlmul_trunc_v_u64m4_u64m4' declared here}}
+  return __riscv_vlmul_trunc_v_u64m4_u64m4(op1); // expected-error {{call to 
undeclared function '__riscv_vlmul_trunc_v_u64m4_u64m4'; ISO C99 and later do 
not support implicit function declarations}} expecte

[PATCH] D156223: [RISCV] Resolve a few bugs in RISCVVIntrinsicUtils.cpp

2023-08-03 Thread Brandon Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf3ce925083d2: [RISCV] Resolve a few bugs in 
RISCVVIntrinsicUtils.cpp (authored by 4vtomat).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156223

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlmul_trunc_v_invalid.c


Index: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlmul_trunc_v_invalid.c
===
--- /dev/null
+++ 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlmul_trunc_v_invalid.c
@@ -0,0 +1,21 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +zvfh -disable-O0-optnone %s -fsyntax-only -verify
+
+#include 
+
+vuint64m2_t test_vlmul_trunc_v_u64m2_u64m2(vuint64m2_t op1) { // expected-note 
{{'test_vlmul_trunc_v_u64m2_u64m2' declared here}}
+  return __riscv_vlmul_trunc_v_u64m2_u64m2(op1); // expected-error {{call to 
undeclared function '__riscv_vlmul_trunc_v_u64m2_u64m2'; ISO C99 and later do 
not support implicit function declarations}} expected-error {{returning 'int' 
from a function with incompatible result type 'vuint64m2_t' (aka 
'__rvv_uint64m2_t')}} expected-note {{did you mean 
'test_vlmul_trunc_v_u64m2_u64m2'?}}
+}
+
+vuint64m4_t test_vlmul_trunc_v_u64m4_u64m4(vuint64m4_t op1) { // expected-note 
{{'test_vlmul_trunc_v_u64m4_u64m4' declared here}}
+  return __riscv_vlmul_trunc_v_u64m4_u64m4(op1); // expected-error {{call to 
undeclared function '__riscv_vlmul_trunc_v_u64m4_u64m4'; ISO C99 and later do 
not support implicit function declarations}} expected-error {{returning 'int' 
from a function with incompatible result type 'vuint64m4_t' (aka 
'__rvv_uint64m4_t')}} expected-note {{did you mean 
'test_vlmul_trunc_v_u64m4_u64m4'?}}
+}
+
+vuint64m1_t test_vlmul_trunc_v_u64m1_u64m1(vuint64m1_t op1) { // expected-note 
{{'test_vlmul_trunc_v_u64m1_u64m1' declared here}}
+  return __riscv_vlmul_trunc_v_u64m1_u64m1(op1); // expected-error {{call to 
undeclared function '__riscv_vlmul_trunc_v_u64m1_u64m1'; ISO C99 and later do 
not support implicit function declarations}} expected-error {{returning 'int' 
from a function with incompatible result type 'vuint64m1_t' (aka 
'__rvv_uint64m1_t')}} expected-note {{did you mean 
'test_vlmul_trunc_v_u64m1_u64m1'?}}
+}
+
+vuint64m8_t test_vlmul_trunc_v_u64m8_u64m8(vuint64m8_t op1) { // expected-note 
{{'test_vlmul_trunc_v_u64m8_u64m8' declared here}}
+  return __riscv_vlmul_trunc_v_u64m8_u64m8(op1); // expected-error {{call to 
undeclared function '__riscv_vlmul_trunc_v_u64m8_u64m8'; ISO C99 and later do 
not support implicit function declarations}} expected-error {{returning 'int' 
from a function with incompatible result type 'vuint64m8_t' (aka 
'__rvv_uint64m8_t')}} expected-note {{did you mean 
'test_vlmul_trunc_v_u64m8_u64m8'?}}
+}
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -742,6 +742,10 @@
 break;
   }
 
+  // Early return if the current type modifier is already invalid.
+  if (ScalarType == Invalid)
+return;
+
   for (unsigned TypeModifierMaskShift = 0;
TypeModifierMaskShift <= static_cast(TypeModifier::MaxOffset);
++TypeModifierMaskShift) {
@@ -803,13 +807,13 @@
 void RVVType::applyFixedLog2LMUL(int Log2LMUL, enum FixedLMULType Type) {
   switch (Type) {
   case FixedLMULType::LargerThan:
-if (Log2LMUL < LMUL.Log2LMUL) {
+if (Log2LMUL <= LMUL.Log2LMUL) {
   ScalarType = ScalarTypeKind::Invalid;
   return;
 }
 break;
   case FixedLMULType::SmallerThan:
-if (Log2LMUL > LMUL.Log2LMUL) {
+if (Log2LMUL >= LMUL.Log2LMUL) {
   ScalarType = ScalarTypeKind::Invalid;
   return;
 }
Index: clang/lib/Sema/SemaRISCVVectorLookup.cpp
===
--- clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -133,6 +133,7 @@
 }
 break;
   case Invalid:
+  case Undefined:
 llvm_unreachable("Unhandled type.");
   }
   if (Type->isVector()) {
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -218,6 +218,7 @@
   UnsignedInteger,
   Float,
   Invalid,
+  Undefined,
 };
 
 // Exponential LMUL
@@ -240,7 +241,7 @@
   frien

[clang] 962dede - [NFC][clang] Fix static analyzer concerns

2023-08-03 Thread via cfe-commits

Author: Podchishchaeva, Mariya
Date: 2023-08-03T01:52:26-07:00
New Revision: 962deded6c30193175b4d96d6397e29bf6c238e9

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

LOG: [NFC][clang] Fix static analyzer concerns

IdDeclInfoMap frees resources in the destructor but doesn't
have user-written copy c'tor or assignment operator, so copying it using
default ones can cause double free.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/lib/Sema/IdentifierResolver.cpp

Removed: 




diff  --git a/clang/lib/Sema/IdentifierResolver.cpp 
b/clang/lib/Sema/IdentifierResolver.cpp
index 773cef65dcbdf0..98a6f3b45089b3 100644
--- a/clang/lib/Sema/IdentifierResolver.cpp
+++ b/clang/lib/Sema/IdentifierResolver.cpp
@@ -60,6 +60,9 @@ class IdentifierResolver::IdDeclInfoMap {
 }
   }
 
+  IdDeclInfoMap(const IdDeclInfoMap &) = delete;
+  IdDeclInfoMap &operator=(const IdDeclInfoMap &) = delete;
+
   /// Returns the IdDeclInfo associated to the DeclarationName.
   /// It creates a new IdDeclInfo if one was not created before for this id.
   IdDeclInfo &operator[](DeclarationName Name);



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


[PATCH] D156904: [NFC][clang] Fix static analyzer concerns

2023-08-03 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG962deded6c30: [NFC][clang] Fix static analyzer concerns 
(authored by Fznamznon).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156904

Files:
  clang/lib/Sema/IdentifierResolver.cpp


Index: clang/lib/Sema/IdentifierResolver.cpp
===
--- clang/lib/Sema/IdentifierResolver.cpp
+++ clang/lib/Sema/IdentifierResolver.cpp
@@ -60,6 +60,9 @@
 }
   }
 
+  IdDeclInfoMap(const IdDeclInfoMap &) = delete;
+  IdDeclInfoMap &operator=(const IdDeclInfoMap &) = delete;
+
   /// Returns the IdDeclInfo associated to the DeclarationName.
   /// It creates a new IdDeclInfo if one was not created before for this id.
   IdDeclInfo &operator[](DeclarationName Name);


Index: clang/lib/Sema/IdentifierResolver.cpp
===
--- clang/lib/Sema/IdentifierResolver.cpp
+++ clang/lib/Sema/IdentifierResolver.cpp
@@ -60,6 +60,9 @@
 }
   }
 
+  IdDeclInfoMap(const IdDeclInfoMap &) = delete;
+  IdDeclInfoMap &operator=(const IdDeclInfoMap &) = delete;
+
   /// Returns the IdDeclInfo associated to the DeclarationName.
   /// It creates a new IdDeclInfo if one was not created before for this id.
   IdDeclInfo &operator[](DeclarationName Name);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156221: [RISCV] Support overloaded version ntlh intrinsic function

2023-08-03 Thread Piyou Chen via Phabricator via cfe-commits
BeMg updated this revision to Diff 546753.
BeMg added a comment.

Add new line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156221

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/riscv_ntlh.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c

Index: clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c
===
--- clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c
+++ clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c
@@ -100,6 +100,24 @@
   *scvs1 = __riscv_ntl_load(scvs2, __RISCV_NTLH_ALL);   // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
   *scvc1 = __riscv_ntl_load(scvc2, __RISCV_NTLH_ALL);   // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
 
+  uc = __riscv_ntl_load(&sc);   // CHECK: load i8{{.*}}align 1, !nontemporal !4, !riscv-nontemporal-domain !8
+  sc = __riscv_ntl_load(&uc);   // CHECK: load i8{{.*}}align 1, !nontemporal !4, !riscv-nontemporal-domain !8
+  us = __riscv_ntl_load(&ss);   // CHECK: load i16{{.*}}align 2, !nontemporal !4, !riscv-nontemporal-domain !8
+  ss = __riscv_ntl_load(&us);   // CHECK: load i16{{.*}}align 2, !nontemporal !4, !riscv-nontemporal-domain !8
+  ui = __riscv_ntl_load(&si);   // CHECK: load i32{{.*}}align 4, !nontemporal !4, !riscv-nontemporal-domain !8
+  si = __riscv_ntl_load(&ui);   // CHECK: load i32{{.*}}align 4, !nontemporal !4, !riscv-nontemporal-domain !8
+  ull = __riscv_ntl_load(&sll); // CHECK: load i64{{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
+  sll = __riscv_ntl_load(&ull); // CHECK: load i64{{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
+  h1 = __riscv_ntl_load(&h2);   // CHECK: load half{{.*}}align 2, !nontemporal !4, !riscv-nontemporal-domain !8
+  f1 = __riscv_ntl_load(&f2);   // CHECK: load float{{.*}}align 4, !nontemporal !4, !riscv-nontemporal-domain !8
+  d1 = __riscv_ntl_load(&d2);   // CHECK: load double{{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
+  v4si1 = __riscv_ntl_load(&v4si2);   // CHECK: load <4 x i32>{{.*}}align 16, !nontemporal !4, !riscv-nontemporal-domain !8
+  v8ss1 = __riscv_ntl_load(&v8ss2);   // CHECK: load <8 x i16>{{.*}}align 16, !nontemporal !4, !riscv-nontemporal-domain !8
+  v16sc1 = __riscv_ntl_load(&v16sc2);   // CHECK: load <16 x i8>{{.*}}align 16, !nontemporal !4, !riscv-nontemporal-domain !8
+  *scvi1 = __riscv_ntl_load(scvi2);   // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
+  *scvs1 = __riscv_ntl_load(scvs2);   // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
+  *scvc1 = __riscv_ntl_load(scvc2);   // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
+
   __riscv_ntl_store(&uc, 1, __RISCV_NTLH_INNERMOST_PRIVATE);// CHECK: store i8{{.*}}align 1, !nontemporal !4, !riscv-nontemporal-domain !5
   __riscv_ntl_store(&sc, 1, __RISCV_NTLH_INNERMOST_PRIVATE);// CHECK: store i8{{.*}}align 1, !nontemporal !4, !riscv-nontemporal-domain !5
   __riscv_ntl_store(&us, 1, __RISCV_NTLH_INNERMOST_PRIVATE);// CHECK: store i16{{.*}}align 2, !nontemporal !4, !riscv-nontemporal-domain !5
@@ -172,6 +190,23 @@
   __riscv_ntl_store(scvs2, *scvs1, __RISCV_NTLH_ALL);  // CHECK: store {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
   __riscv_ntl_store(scvc2, *scvc1, __RISCV_NTLH_ALL);  // CHECK: store {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
 
+  __riscv_ntl_store(&uc, 1);// CHECK: store i8{{.*}}align 1, !nontemporal !4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&sc, 1);// CHECK: store i8{{.*}}align 1, !nontemporal !4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&us, 1);// CHECK: store i16{{.*}}align 2, !nontemporal !4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&ss, 1);// CHECK: store i16{{.*}}align 2, !nontemporal !4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&ui, 1);// CHECK: store i32{{.*}}align 4, !nontemporal !4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&si, 1);// CHECK: store i32{{.*}}align 4, !nontemporal !4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&ull, 1);   // CHECK: store i64{{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&sll, 1);   // CHECK: store i64{{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&h1, 1.0);  // CHECK: store half{{.*}}align 2, !nontemporal !4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&f1, 1.0);  // CHECK: store float{{.*}}align 4, !nontemporal !4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&d1, 1.0);  // CHECK: store double{{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&v4si1, v4si2);  // CHECK: store <4 x i32>{{.*}}align 16, !nontemporal !4, !riscv-nontemporal-domain 

[clang] c4bb3e0 - [NFC][clang] Fix static analyzer concerns

2023-08-03 Thread via cfe-commits

Author: Podchishchaeva, Mariya
Date: 2023-08-03T02:00:17-07:00
New Revision: c4bb3e073548cf436d5fa0406e3ae75e94684dec

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

LOG: [NFC][clang] Fix static analyzer concerns

InterpState frees resources in the destructor but doesn't
have user-written copy c'tor or assignment operator, so copying it using
default ones can cause double free.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/lib/AST/Interp/InterpState.h

Removed: 




diff  --git a/clang/lib/AST/Interp/InterpState.h 
b/clang/lib/AST/Interp/InterpState.h
index fc28c74002d9dd..8f84bf6ed2eaff 100644
--- a/clang/lib/AST/Interp/InterpState.h
+++ b/clang/lib/AST/Interp/InterpState.h
@@ -39,6 +39,9 @@ class InterpState final : public State, public SourceMapper {
 
   ~InterpState();
 
+  InterpState(const InterpState &) = delete;
+  InterpState &operator=(const InterpState &) = delete;
+
   // Stack frame accessors.
   Frame *getSplitFrame() { return Parent.getCurrentFrame(); }
   Frame *getCurrentFrame() override;



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


[PATCH] D156900: [NFC][clang] Fix static analyzer concerns

2023-08-03 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc4bb3e073548: [NFC][clang] Fix static analyzer concerns 
(authored by Fznamznon).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156900

Files:
  clang/lib/AST/Interp/InterpState.h


Index: clang/lib/AST/Interp/InterpState.h
===
--- clang/lib/AST/Interp/InterpState.h
+++ clang/lib/AST/Interp/InterpState.h
@@ -39,6 +39,9 @@
 
   ~InterpState();
 
+  InterpState(const InterpState &) = delete;
+  InterpState &operator=(const InterpState &) = delete;
+
   // Stack frame accessors.
   Frame *getSplitFrame() { return Parent.getCurrentFrame(); }
   Frame *getCurrentFrame() override;


Index: clang/lib/AST/Interp/InterpState.h
===
--- clang/lib/AST/Interp/InterpState.h
+++ clang/lib/AST/Interp/InterpState.h
@@ -39,6 +39,9 @@
 
   ~InterpState();
 
+  InterpState(const InterpState &) = delete;
+  InterpState &operator=(const InterpState &) = delete;
+
   // Stack frame accessors.
   Frame *getSplitFrame() { return Parent.getCurrentFrame(); }
   Frame *getCurrentFrame() override;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156724: [StaticAnalyzer] Fix incorrect link to "note" diagnostics in HTML output

2023-08-03 Thread Guruprasad Hegde via Phabricator via cfe-commits
gruuprasad added a comment.

@steakhal, ok, this is my first contribution, I don't have the commit access 
yet. 
Can you please merge this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156724

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


[PATCH] D156724: [StaticAnalyzer] Fix incorrect link to "note" diagnostics in HTML output

2023-08-03 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D156724#4556774 , @gruuprasad 
wrote:

> @steakhal, ok, this is my first contribution, I don't have the commit access 
> yet. 
> Can you please merge this?

What should be the commit author?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156724

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


[PATCH] D112921: [clang] Enable sized deallocation by default in C++14 onwards

2023-08-03 Thread Wang Pengcheng via Phabricator via cfe-commits
wangpc updated this revision to Diff 546760.
wangpc added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112921

Files:
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/SizedDeallocation.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/Analysis/cxxnewexpr-callback.cpp
  
clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p2.cpp
  clang/test/CXX/expr/expr.unary/expr.new/p14.cpp
  clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp
  clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
  clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp
  clang/test/CodeGenCXX/delete-two-arg.cpp
  clang/test/CodeGenCXX/delete.cpp
  clang/test/CodeGenCXX/dllimport.cpp
  clang/test/CodeGenCXX/new.cpp
  clang/test/CodeGenCoroutines/coro-aligned-alloc-2.cpp
  clang/test/CodeGenCoroutines/coro-aligned-alloc.cpp
  clang/test/CodeGenCoroutines/coro-alloc.cpp
  clang/test/CodeGenCoroutines/coro-cleanup.cpp
  clang/test/CodeGenCoroutines/coro-dealloc.cpp
  clang/test/CodeGenCoroutines/coro-gro.cpp
  clang/test/CodeGenCoroutines/pr56919.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/PCH/cxx1z-aligned-alloc.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp
  clang/test/SemaCXX/builtin-operator-new-delete.cpp
  clang/test/SemaCXX/cxx1y-sized-deallocation.cpp
  clang/test/SemaCXX/unavailable_aligned_allocation.cpp
  clang/unittests/StaticAnalyzer/CallEventTest.cpp
  clang/www/cxx_status.html
  libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp

Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
===
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
@@ -8,11 +8,14 @@
 
 // test sized operator delete replacement.
 
+// TODO(mordante) fix this test after updating clang in Docker
+// UNSUPPORTED: clang-17, clang-18
 // UNSUPPORTED: sanitizer-new-delete, c++03, c++11
+// XFAIL: clang-15, clang-16
+// XFAIL: apple-clang
 
-// NOTE: Clang does not enable sized-deallocation in C++14 and beyond by
-// default. It is only enabled when -fsized-deallocation is given.
-// XFAIL: clang, apple-clang
+// Sized deallocation was added in macOS 10.12 and aligned OSes.
+// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11}}
 
 #include 
 #include 
Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
===
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
@@ -8,11 +8,14 @@
 
 // test sized operator delete[] replacement.
 
+// TODO(mordante) fix this test after updating clang in Docker
+// UNSUPPORTED: clang-17, clang-18
 // UNSUPPORTED: sanitizer-new-delete, c++03, c++11
+// XFAIL: clang-15, clang-16
+// XFAIL: apple-clang
 
-// NOTE: Clang does not enable sized-deallocation in C++14 and beyond by
-// default. It is only enabled when -fsized-deallocation is given.
-// XFAIL: clang, apple-clang
+// Sized deallocation was added in macOS 10.12 and aligned OSes.
+// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11}}
 
 #include 
 #include 
Index: libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
===
--- libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
+++ libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
@@ -25,6 +25,9 @@
 // GCC doesn't support the aligned-allocation flags.
 // XFAIL: gcc
 
+// TODO(mordante) fix this test after updating clang in Docker
+// UNSUPPORTED: clang-17, clang-18
+
 // RUN: %{build} -faligned-allocation -fsized-deallocation
 // RUN: %{run}
 // RUN: %{build} -faligned-allocation -fno-sized-deallocation -DNO_SIZE
Index: clang/www/cxx_status.html
===

[PATCH] D155456: [RISCV] Support -m[no-]strict-align options

2023-08-03 Thread Wang Pengcheng via Phabricator via cfe-commits
wangpc added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155456

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


[PATCH] D156724: [StaticAnalyzer] Fix incorrect link to "note" diagnostics in HTML output

2023-08-03 Thread Guruprasad Hegde via Phabricator via cfe-commits
gruuprasad added a comment.

Email:gruupras...@gmail.com
GitHub username: gruuprasad
Either of these fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156724

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


[PATCH] D156975: [NFC][clang] Fix static analyzer concerns

2023-08-03 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon created this revision.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a project: All.
Fznamznon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A bunch of classes in APValue free resources in the destructor but don't
have user-written copy c'tor or assignment operator, so copying them using
default ones can cause double free.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156975

Files:
  clang/include/clang/AST/APValue.h


Index: clang/include/clang/AST/APValue.h
===
--- clang/include/clang/AST/APValue.h
+++ clang/include/clang/AST/APValue.h
@@ -270,12 +270,16 @@
 APValue *Elts = nullptr;
 unsigned NumElts = 0;
 Vec() = default;
+Vec(const Vec &) = delete;
+Vec &operator=(const Vec &) = delete;
 ~Vec() { delete[] Elts; }
   };
   struct Arr {
 APValue *Elts;
 unsigned NumElts, ArrSize;
 Arr(unsigned NumElts, unsigned ArrSize);
+Arr(const Arr &) = delete;
+Arr &operator=(const Arr &) = delete;
 ~Arr();
   };
   struct StructData {
@@ -283,12 +287,16 @@
 unsigned NumBases;
 unsigned NumFields;
 StructData(unsigned NumBases, unsigned NumFields);
+StructData(const StructData &) = delete;
+StructData &operator=(const StructData &) = delete;
 ~StructData();
   };
   struct UnionData {
 const FieldDecl *Field;
 APValue *Value;
 UnionData();
+UnionData(const UnionData &) = delete;
+UnionData &operator=(const UnionData &) = delete;
 ~UnionData();
   };
   struct AddrLabelDiffData {


Index: clang/include/clang/AST/APValue.h
===
--- clang/include/clang/AST/APValue.h
+++ clang/include/clang/AST/APValue.h
@@ -270,12 +270,16 @@
 APValue *Elts = nullptr;
 unsigned NumElts = 0;
 Vec() = default;
+Vec(const Vec &) = delete;
+Vec &operator=(const Vec &) = delete;
 ~Vec() { delete[] Elts; }
   };
   struct Arr {
 APValue *Elts;
 unsigned NumElts, ArrSize;
 Arr(unsigned NumElts, unsigned ArrSize);
+Arr(const Arr &) = delete;
+Arr &operator=(const Arr &) = delete;
 ~Arr();
   };
   struct StructData {
@@ -283,12 +287,16 @@
 unsigned NumBases;
 unsigned NumFields;
 StructData(unsigned NumBases, unsigned NumFields);
+StructData(const StructData &) = delete;
+StructData &operator=(const StructData &) = delete;
 ~StructData();
   };
   struct UnionData {
 const FieldDecl *Field;
 APValue *Value;
 UnionData();
+UnionData(const UnionData &) = delete;
+UnionData &operator=(const UnionData &) = delete;
 ~UnionData();
   };
   struct AddrLabelDiffData {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-08-03 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 546766.
SixWeining added a comment.

rename the common helper to `postProcessTargetCPUString`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

Files:
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/lib/Basic/Targets/LoongArch.h
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/lib/Driver/ToolChains/Arch/LoongArch.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/loongarch-march-error.c
  clang/test/Driver/loongarch-march.c
  clang/test/Driver/loongarch-mtune-error.c
  clang/test/Driver/loongarch-mtune.c
  clang/test/Preprocessor/init-loongarch.c
  llvm/include/llvm/TargetParser/LoongArchTargetParser.h
  llvm/lib/Target/LoongArch/LoongArch.td
  llvm/lib/TargetParser/LoongArchTargetParser.cpp
  llvm/test/CodeGen/LoongArch/cpus-invalid.ll
  llvm/test/CodeGen/LoongArch/cpus.ll

Index: llvm/test/CodeGen/LoongArch/cpus.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/cpus.ll
@@ -0,0 +1,20 @@
+;; This tests that llc accepts all valid LoongArch CPUs.
+;; Note the 'generic' names have been tested in cpu-name-generic.ll.
+
+; RUN: llc < %s --mtriple=loongarch64 --mcpu=loongarch64 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 --mcpu=la464 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 2>&1 | FileCheck %s
+
+; CHECK-NOT: {{.*}} is not a recognized processor for this target
+
+define void @f() {
+  ret void
+}
+
+define void @tune_cpu_loongarch64() "tune-cpu"="loongarch64" {
+  ret void
+}
+
+define void @tune_cpu_la464() "tune-cpu"="la464" {
+  ret void
+}
Index: llvm/test/CodeGen/LoongArch/cpus-invalid.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/cpus-invalid.ll
@@ -0,0 +1,7 @@
+; RUN: llc < %s --mtriple=loongarch64 --mattr=+64bit --mcpu=invalidcpu 2>&1 | FileCheck %s
+
+; CHECK: {{.*}} is not a recognized processor for this target
+
+define void @f() {
+  ret void
+}
Index: llvm/lib/TargetParser/LoongArchTargetParser.cpp
===
--- llvm/lib/TargetParser/LoongArchTargetParser.cpp
+++ llvm/lib/TargetParser/LoongArchTargetParser.cpp
@@ -46,3 +46,15 @@
   }
   return false;
 }
+
+bool LoongArch::isValidCPUName(StringRef Name) { return isValidArchName(Name); }
+
+void LoongArch::fillValidCPUList(SmallVectorImpl &Values) {
+  for (const auto A : AllArchs)
+Values.emplace_back(A.Name);
+}
+
+StringRef LoongArch::getDefaultArch(bool Is64Bit) {
+  // TODO: use a real 32-bit arch name.
+  return Is64Bit ? "loongarch64" : "";
+}
Index: llvm/lib/Target/LoongArch/LoongArch.td
===
--- llvm/lib/Target/LoongArch/LoongArch.td
+++ llvm/lib/Target/LoongArch/LoongArch.td
@@ -117,6 +117,11 @@
 def : ProcessorModel<"generic-la32", NoSchedModel, [Feature32Bit]>;
 def : ProcessorModel<"generic-la64", NoSchedModel, [Feature64Bit, FeatureUAL]>;
 
+// Generic 64-bit processor with double-precision floating-point support.
+def : ProcessorModel<"loongarch64", NoSchedModel, [Feature64Bit,
+   FeatureUAL,
+   FeatureBasicD]>;
+
 // Support generic for compatibility with other targets. The triple will be used
 // to change to the appropriate la32/la64 version.
 def : ProcessorModel<"generic", NoSchedModel, []>;
Index: llvm/include/llvm/TargetParser/LoongArchTargetParser.h
===
--- llvm/include/llvm/TargetParser/LoongArchTargetParser.h
+++ llvm/include/llvm/TargetParser/LoongArchTargetParser.h
@@ -66,9 +66,12 @@
 
 bool isValidArchName(StringRef Arch);
 bool getArchFeatures(StringRef Arch, std::vector &Features);
+bool isValidCPUName(StringRef TuneCPU);
+void fillValidCPUList(SmallVectorImpl &Values);
+StringRef getDefaultArch(bool Is64Bit);
 
 } // namespace LoongArch
 
 } // namespace llvm
 
-#endif // LLVM_SUPPORT_LOONGARCHTARGETPARSER_H
+#endif // LLVM_TARGETPARSER_LOONGARCHTARGETPARSER_H
Index: clang/test/Preprocessor/init-loongarch.c
===
--- clang/test/Preprocessor/init-loongarch.c
+++ clang/test/Preprocessor/init-loongarch.c
@@ -787,3 +787,23 @@
 // LA64-FPU0-LP64S: #define __loongarch_lp64 1
 // LA64-FPU0-LP64S-NOT: #define __loongarch_single_float
 // LA64-FPU0-LP64S: #define __loongarch_soft_float 1
+
+/// Check __loongarch_arch and __loongarch_tune.
+
+// RUN: %clang --target=loongarch64 -x c -E -dM %s -o - | \
+// RUN:   FileCheck --match-full-lines --check-prefix=ARCH-TUNE -DARCH=loongarch64 -DTUNE=loongarch64 %s
+// RUN: %clang --target=loongarch64 -x c -E -dM %s -o - -march=loongarch64 | \
+// RUN:   FileCheck --match-full-lines --c

[PATCH] D155456: [RISCV] Support -m[no-]strict-align options

2023-08-03 Thread Wang Pengcheng via Phabricator via cfe-commits
wangpc updated this revision to Diff 546772.
wangpc added a comment.

Rebase since `ReleaseNotes.rst` is changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155456

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-default-features.c
  clang/test/Driver/riscv-features.c


Index: clang/test/Driver/riscv-features.c
===
--- clang/test/Driver/riscv-features.c
+++ clang/test/Driver/riscv-features.c
@@ -26,6 +26,22 @@
 // DEFAULT: "-target-feature" "-save-restore"
 // DEFAULT-NOT: "-target-feature" "+save-restore"
 
+// RUN: %clang --target=riscv32-unknown-elf -### %s -munaligned-access 2>&1 | 
FileCheck %s -check-prefix=UNALIGNED-SCALAR-MEM
+// RUN: %clang --target=riscv32-unknown-elf -### %s -mno-unaligned-access 2>&1 
| FileCheck %s -check-prefix=NO-UNALIGNED-SCALAR-MEM
+// RUN: %clang --target=riscv32-unknown-elf -### %s -mno-strict-align 2>&1 | 
FileCheck %s -check-prefix=UNALIGNED-SCALAR-MEM
+// RUN: %clang --target=riscv32-unknown-elf -### %s -mstrict-align 2>&1 | 
FileCheck %s -check-prefix=NO-UNALIGNED-SCALAR-MEM
+// RUN: %clang --target=riscv32-unknown-elf -### %s -march=rv32gv 
-munaligned-access 2>&1 | FileCheck %s -check-prefix=UNALIGNED-VECTOR-MEM
+// RUN: %clang --target=riscv32-unknown-elf -### %s -march=rv32gv 
-mno-unaligned-access 2>&1 | FileCheck %s -check-prefix=NO-UNALIGNED-VECTOR-MEM
+// RUN: %clang --target=riscv32-unknown-elf -### %s -march=rv32gv 
-mno-strict-align 2>&1 | FileCheck %s -check-prefix=UNALIGNED-VECTOR-MEM
+// RUN: %clang --target=riscv32-unknown-elf -### %s -march=rv32gv 
-mstrict-align 2>&1 | FileCheck %s -check-prefix=NO-UNALIGNED-VECTOR-MEM
+
+// UNALIGNED-SCALAR-MEM: "-target-feature" "+unaligned-scalar-mem"
+// NO-UNALIGNED-SCALAR-MEM: "-target-feature" "-unaligned-scalar-mem"
+// UNALIGNED-VECTOR-MEM: "-target-feature" "+unaligned-vector-mem"
+// NO-UNALIGNED-VECTOR-MEM: "-target-feature" "-unaligned-vector-mem"
+// DEFAULT: "-target-feature" "-unaligned-scalar-mem"
+// DEFAULT-NOT: "-target-feature" "+unaligned-scalar-mem"
+
 // RUN: %clang --target=riscv32-linux -### %s -fsyntax-only 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=DEFAULT-LINUX
 // RUN: %clang --target=riscv64-linux -### %s -fsyntax-only 2>&1 \
Index: clang/test/Driver/riscv-default-features.c
===
--- clang/test/Driver/riscv-default-features.c
+++ clang/test/Driver/riscv-default-features.c
@@ -3,8 +3,10 @@
 
 // RV32: "target-features"="+32bit,+a,+c,+m,+relax,
 // RV32-SAME: -save-restore
+// RV32-SAME: -unaligned-scalar-mem
 // RV64: "target-features"="+64bit,+a,+c,+m,+relax,
 // RV64-SAME: -save-restore
+// RV64-SAME: -unaligned-scalar-mem
 
 // Dummy function
 int foo(void){
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -167,6 +167,19 @@
   else
 Features.push_back("-save-restore");
 
+  // -mno-unaligned-access is default, unless -munaligned-access is specified.
+  bool HasV = llvm::is_contained(Features, "+zve32x");
+  if (Args.hasFlag(options::OPT_munaligned_access,
+   options::OPT_mno_unaligned_access, false)) {
+Features.push_back("+unaligned-scalar-mem");
+if (HasV)
+  Features.push_back("+unaligned-vector-mem");
+  } else {
+Features.push_back("-unaligned-scalar-mem");
+if (HasV)
+  Features.push_back("-unaligned-vector-mem");
+  }
+
   // Now add any that the user explicitly requested on the command line,
   // which may override the defaults.
   handleTargetFeaturesGroup(D, Triple, Args, Features,
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3834,9 +3834,9 @@
"in __riscv_v_fixed_vlen preprocessor define (RISC-V only)">;
 
 def munaligned_access : Flag<["-"], "munaligned-access">, Group,
-  HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64/LoongArch 
only)">;
+  HelpText<"Allow memory accesses to be unaligned 
(AArch32/AArch64/LoongArch/RISC-V only)">;
 def mno_unaligned_access : Flag<["-"], "mno-unaligned-access">, Group,
-  HelpText<"Force all memory accesses to be aligned (AArch32/AArch64/LoongArch 
only)">;
+  HelpText<"Force all memory accesses to be aligned 
(AArch32/AArch64/LoongArch/RISC-V only)">;
 } // let Flags = [TargetSpecific]
 def mstrict_align : Flag<["-"], "mstrict-align">, Alias, 
Flags<[CC1Option,HelpHidden]>,
   HelpText<"Force all memory accesses to be aligned (same as 
mno-unaligned-access)">;
Index: clang/docs/ReleaseNotes.rst
===

[clang] e73ae74 - [analyzer] Fix incorrect link to "note" diagnostics in HTML output

2023-08-03 Thread Balazs Benics via cfe-commits

Author: Guruprasad Hegde
Date: 2023-08-03T11:44:05+02:00
New Revision: e73ae745b0d660d3974c04b2281575f325971338

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

LOG: [analyzer] Fix incorrect link to "note" diagnostics in HTML output

IDs of the note list start from 1. Link generated for each note started
with index 0 i.e #Note0, #Note1 and so on.
As a result, first link ("#Note0") was invalid, subsequent links pointed
at wrong note.
Now, generated links to the notes start with index 1 i.e (#Note1, #Note2
and so on.

Patch by Guruprasad Hegde (gruuprasad)!

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

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

Added: 
clang/test/Analysis/html_diagnostics/notes-links.cpp

Modified: 
clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp 
b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
index 0fe0c93dc01653..f91a51cc5f8f6a 100644
--- a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -592,11 +592,11 @@ void HTMLDiagnostics::FinalizeHTML(const PathDiagnostic& 
D, Rewriter &R,
 P->getLocation().asLocation().getExpansionLineNumber();
 int ColumnNumber =
 P->getLocation().asLocation().getExpansionColumnNumber();
+++NumExtraPieces;
 os << "Note:"
<< "line "
<< LineNumber << ", column " << ColumnNumber << ""
<< P->getString() << "";
-++NumExtraPieces;
   }
 }
 

diff  --git a/clang/test/Analysis/html_diagnostics/notes-links.cpp 
b/clang/test/Analysis/html_diagnostics/notes-links.cpp
new file mode 100644
index 00..856cc5f41ef6ed
--- /dev/null
+++ b/clang/test/Analysis/html_diagnostics/notes-links.cpp
@@ -0,0 +1,22 @@
+// RUN: rm -fR %t
+// RUN: mkdir %t
+// RUN: %clang_analyze_cc1 
-analyzer-checker=optin.cplusplus.UninitializedObject \
+// RUN:-analyzer-output=html -o %t -verify %s
+// RUN: cat %t/report-*.html | FileCheck %s
+
+struct A {
+  int *iptr;
+  int a;  // expected-note{{uninitialized field 'this->a'}}
+  int b;  // expected-note{{uninitialized field 'this->b'}}
+
+  A (int *iptr) : iptr(iptr) {} // expected-warning{{2 uninitialized fields at 
the end of the constructor call [optin.cplusplus.UninitializedObject]}}
+};
+
+void f() {
+  A a(0);
+}
+
+//CHECK:  Note:
+//CHECK-NOT:  
+//CHECK-SAME: line 9, column 7
+//CHECK-SAME: line 10, column 7



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


[PATCH] D156724: [StaticAnalyzer] Fix incorrect link to "note" diagnostics in HTML output

2023-08-03 Thread Balázs Benics via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe73ae745b0d6: [analyzer] Fix incorrect link to 
"note" diagnostics in HTML output (authored by gruuprasad, committed 
by steakhal).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156724

Files:
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/test/Analysis/html_diagnostics/notes-links.cpp


Index: clang/test/Analysis/html_diagnostics/notes-links.cpp
===
--- /dev/null
+++ clang/test/Analysis/html_diagnostics/notes-links.cpp
@@ -0,0 +1,22 @@
+// RUN: rm -fR %t
+// RUN: mkdir %t
+// RUN: %clang_analyze_cc1 
-analyzer-checker=optin.cplusplus.UninitializedObject \
+// RUN:-analyzer-output=html -o %t -verify %s
+// RUN: cat %t/report-*.html | FileCheck %s
+
+struct A {
+  int *iptr;
+  int a;  // expected-note{{uninitialized field 'this->a'}}
+  int b;  // expected-note{{uninitialized field 'this->b'}}
+
+  A (int *iptr) : iptr(iptr) {} // expected-warning{{2 uninitialized fields at 
the end of the constructor call [optin.cplusplus.UninitializedObject]}}
+};
+
+void f() {
+  A a(0);
+}
+
+//CHECK:  Note:
+//CHECK-NOT:  
+//CHECK-SAME: line 9, column 7
+//CHECK-SAME: line 10, column 7
Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -592,11 +592,11 @@
 P->getLocation().asLocation().getExpansionLineNumber();
 int ColumnNumber =
 P->getLocation().asLocation().getExpansionColumnNumber();
+++NumExtraPieces;
 os << "Note:"
<< "line "
<< LineNumber << ", column " << ColumnNumber << ""
<< P->getString() << "";
-++NumExtraPieces;
   }
 }
 


Index: clang/test/Analysis/html_diagnostics/notes-links.cpp
===
--- /dev/null
+++ clang/test/Analysis/html_diagnostics/notes-links.cpp
@@ -0,0 +1,22 @@
+// RUN: rm -fR %t
+// RUN: mkdir %t
+// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.UninitializedObject \
+// RUN:-analyzer-output=html -o %t -verify %s
+// RUN: cat %t/report-*.html | FileCheck %s
+
+struct A {
+  int *iptr;
+  int a;  // expected-note{{uninitialized field 'this->a'}}
+  int b;  // expected-note{{uninitialized field 'this->b'}}
+
+  A (int *iptr) : iptr(iptr) {} // expected-warning{{2 uninitialized fields at the end of the constructor call [optin.cplusplus.UninitializedObject]}}
+};
+
+void f() {
+  A a(0);
+}
+
+//CHECK:  Note:
+//CHECK-NOT:  
+//CHECK-SAME: line 9, column 7
+//CHECK-SAME: line 10, column 7
Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -592,11 +592,11 @@
 P->getLocation().asLocation().getExpansionLineNumber();
 int ColumnNumber =
 P->getLocation().asLocation().getExpansionColumnNumber();
+++NumExtraPieces;
 os << "Note:"
<< "line "
<< LineNumber << ", column " << ColumnNumber << ""
<< P->getString() << "";
-++NumExtraPieces;
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155610: [Clang][ExprConstant] Print integer instead of character on static assertion failure

2023-08-03 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 546782.
hazohelet added a comment.

Address comments from Corentin

- Use default `pushEscapedString` escaping (``) instead of UCN 
representation `\u0001`
- Convert multi-byte characters (`wchar_t`, `char16_t`, `char32_t`) to UTF-8 
and prints them.
- Added `CharToString` utility function


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

https://reviews.llvm.org/D155610

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/Lexer/cxx1z-trigraphs.cpp
  clang/test/SemaCXX/static-assert-cxx26.cpp
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -262,7 +262,29 @@
 return 'c';
   }
   static_assert(getChar() == 'a', ""); // expected-error {{failed}} \
-   // expected-note {{evaluates to ''c' == 'a''}}
+   // expected-note {{evaluates to ''c' (99) == 'a' (97)'}}
+  static_assert((char)9 == '\x61', ""); // expected-error {{failed}} \
+// expected-note {{evaluates to ''\t' (9) == 'a' (97)'}}
+  static_assert((char)10 == '\0', ""); // expected-error {{failed}} \
+   // expected-note {{n' (10) == '' (0)'}}
+  // The note above is intended to match "evaluates to '\n' (10) == '' (0)'", but if we write it as it is,
+  // the "\n" cannot be consumed by the diagnostic consumer.
+  static_assert((signed char)10 == (char)-123, ""); // expected-error {{failed}} \
+// expected-note {{evaluates to '10 == '<85>' (-123)'}}
+  static_assert((char)-4 == (unsigned char)-8, ""); // expected-error {{failed}} \
+// expected-note {{evaluates to ''' (-4) == 248'}}
+  static_assert((char)-128 == (char)-123, ""); // expected-error {{failed}} \
+   // expected-note {{evaluates to ''<80>' (-128) == '<85>' (-123)'}}
+  static_assert('\xA0' == (char)'\x20', ""); // expected-error {{failed}} \
+ // expected-note {{evaluates to ''' (-96) == ' ' (32)'}}
+static_assert((char16_t)L'ゆ' == L"C̵̭̯̠̎͌ͅť̺"[1], ""); // expected-error {{failed}} \
+// expected-note {{evaluates to 'u'ゆ' (12422) == L'̵' (821)'}}
+static_assert(L"\/"[1] == u'\xFFFD', ""); // expected-error {{failed}} \
+   // expected-note {{evaluates to 'L'/' (65295) == u'�' (65533)'}}
+static_assert(L"⚾"[0] == U'🌍', ""); // expected-error {{failed}} \
+   // expected-note {{evaluates to 'L'⚾' (9918) == U'🌍' (127757)'}}
+static_assert(U"\a"[0] == (wchar_t)9, ""); // expected-error {{failed}} \
+   // expected-note {{evaluates to 'U'\a' (7) == L'\t' (9)'}}
 
   /// Bools are printed as bools.
   constexpr bool invert(bool b) {
Index: clang/test/SemaCXX/static-assert-cxx26.cpp
===
--- clang/test/SemaCXX/static-assert-cxx26.cpp
+++ clang/test/SemaCXX/static-assert-cxx26.cpp
@@ -298,3 +298,12 @@
 Bad b; // expected-note {{in instantiation}}
 
 }
+
+namespace EscapeInDiagnostic {
+static_assert('\u{9}' == (char)1, ""); // expected-error {{failed}} \
+   // expected-note {{evaluates to ''\t' (9) == '' (1)'}}
+static_assert((char8_t)-128 == (char8_t)-123, ""); // expected-error {{failed}} \
+   // expected-note {{evaluates to 'u8'<80>' (128) == u8'<85>' (133)'}}
+static_assert((char16_t)0xFEFF == (char16_t)0xDB93, ""); // expected-error {{failed}} \
+ // expected-note {{evaluates to 'u'' (65279) == u'\xDB93' (56211)'}}
+}
Index: clang/test/Lexer/cxx1z-trigraphs.cpp
===
--- clang/test/Lexer/cxx1z-trigraphs.cpp
+++ clang/test/Lexer/cxx1z-trigraphs.cpp
@@ -21,7 +21,7 @@
 
 #if !ENABLED_TRIGRAPHS
 // expected-error@11 {{}} expected-warning@11 {{trigraph ignored}}
-// expected-error@13 {{failed}} expected-warning@13 {{trigraph ignored}} expected-note@13 {{evaluates to ''?' == '#''}}
+// expected-error@13 {{failed}} expected-warning@13 {{trigraph ignored}} expected-note@13 {{evaluates to ''?' (63) == '#' (35)'}}
 // expected-error@16 {{}}
 // expected-error@20 {{}}
 #else
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -46,6 +46,7 @@
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
 #inc

[clang] 23ce536 - [RISCV] Support -m[no-]strict-align options

2023-08-03 Thread via cfe-commits

Author: wangpc
Date: 2023-08-03T18:11:41+08:00
New Revision: 23ce5368409c760f3dd49d0f17f34772b0b869d8

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

LOG: [RISCV] Support -m[no-]strict-align options

To match GCC.

Options `-m[no-]strict-align` are aliases of `-m[no-]unaligned-access`
in clang, but there is no corresponding option in GCC.

Support of `-m[no-]unaligned-access` in GCC may be needed to align
Clang/GCC.

Reviewed By: kito-cheng

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/test/Driver/riscv-default-features.c
clang/test/Driver/riscv-features.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 627a1541cfddb9..da3cb85dce8e76 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -171,6 +171,8 @@ LoongArch Support
 
 RISC-V Support
 ^^
+- Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or 
the
+  aliases ``-m[no-]strict-align``.
 
 CUDA/HIP Language Changes
 ^

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 296fa1fcc38a02..ebf7e0c9f39979 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3834,9 +3834,9 @@ def mrvv_vector_bits_EQ : Joined<["-"], 
"mrvv-vector-bits=">, Group,
"in __riscv_v_fixed_vlen preprocessor define (RISC-V only)">;
 
 def munaligned_access : Flag<["-"], "munaligned-access">, Group,
-  HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64/LoongArch 
only)">;
+  HelpText<"Allow memory accesses to be unaligned 
(AArch32/AArch64/LoongArch/RISC-V only)">;
 def mno_unaligned_access : Flag<["-"], "mno-unaligned-access">, Group,
-  HelpText<"Force all memory accesses to be aligned (AArch32/AArch64/LoongArch 
only)">;
+  HelpText<"Force all memory accesses to be aligned 
(AArch32/AArch64/LoongArch/RISC-V only)">;
 } // let Flags = [TargetSpecific]
 def mstrict_align : Flag<["-"], "mstrict-align">, Alias, 
Flags<[CC1Option,HelpHidden]>,
   HelpText<"Force all memory accesses to be aligned (same as 
mno-unaligned-access)">;

diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 17e1aab961e5a8..91a5589c363c49 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -167,6 +167,19 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   else
 Features.push_back("-save-restore");
 
+  // -mno-unaligned-access is default, unless -munaligned-access is specified.
+  bool HasV = llvm::is_contained(Features, "+zve32x");
+  if (Args.hasFlag(options::OPT_munaligned_access,
+   options::OPT_mno_unaligned_access, false)) {
+Features.push_back("+unaligned-scalar-mem");
+if (HasV)
+  Features.push_back("+unaligned-vector-mem");
+  } else {
+Features.push_back("-unaligned-scalar-mem");
+if (HasV)
+  Features.push_back("-unaligned-vector-mem");
+  }
+
   // Now add any that the user explicitly requested on the command line,
   // which may override the defaults.
   handleTargetFeaturesGroup(D, Triple, Args, Features,

diff  --git a/clang/test/Driver/riscv-default-features.c 
b/clang/test/Driver/riscv-default-features.c
index 6e48f7cc37dcb0..9e7d119d0e2690 100644
--- a/clang/test/Driver/riscv-default-features.c
+++ b/clang/test/Driver/riscv-default-features.c
@@ -3,8 +3,10 @@
 
 // RV32: "target-features"="+32bit,+a,+c,+m,+relax,
 // RV32-SAME: -save-restore
+// RV32-SAME: -unaligned-scalar-mem
 // RV64: "target-features"="+64bit,+a,+c,+m,+relax,
 // RV64-SAME: -save-restore
+// RV64-SAME: -unaligned-scalar-mem
 
 // Dummy function
 int foo(void){

diff  --git a/clang/test/Driver/riscv-features.c 
b/clang/test/Driver/riscv-features.c
index f67dd3d46402ba..bb9b4f37e222a1 100644
--- a/clang/test/Driver/riscv-features.c
+++ b/clang/test/Driver/riscv-features.c
@@ -26,6 +26,22 @@
 // DEFAULT: "-target-feature" "-save-restore"
 // DEFAULT-NOT: "-target-feature" "+save-restore"
 
+// RUN: %clang --target=riscv32-unknown-elf -### %s -munaligned-access 2>&1 | 
FileCheck %s -check-prefix=UNALIGNED-SCALAR-MEM
+// RUN: %clang --target=riscv32-unknown-elf -### %s -mno-unaligned-access 2>&1 
| FileCheck %s -check-prefix=NO-UNALIGNED-SCALAR-MEM
+// RUN: %clang --target=riscv32-unknown-elf -### %s -mno-strict-align 2>&1 | 
FileCheck %s -check-prefix=UNALIGNED-SCALAR-MEM
+// RUN: %clang --target=riscv32-unknown-elf -### %s -mstrict-align 2>&1 | 
FileCheck %s -check-prefix=NO-UNALIGNED-SCALAR-MEM
+// RUN: %cl

[PATCH] D155456: [RISCV] Support -m[no-]strict-align options

2023-08-03 Thread Wang Pengcheng via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG23ce5368409c: [RISCV] Support -m[no-]strict-align options 
(authored by wangpc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155456

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-default-features.c
  clang/test/Driver/riscv-features.c


Index: clang/test/Driver/riscv-features.c
===
--- clang/test/Driver/riscv-features.c
+++ clang/test/Driver/riscv-features.c
@@ -26,6 +26,22 @@
 // DEFAULT: "-target-feature" "-save-restore"
 // DEFAULT-NOT: "-target-feature" "+save-restore"
 
+// RUN: %clang --target=riscv32-unknown-elf -### %s -munaligned-access 2>&1 | 
FileCheck %s -check-prefix=UNALIGNED-SCALAR-MEM
+// RUN: %clang --target=riscv32-unknown-elf -### %s -mno-unaligned-access 2>&1 
| FileCheck %s -check-prefix=NO-UNALIGNED-SCALAR-MEM
+// RUN: %clang --target=riscv32-unknown-elf -### %s -mno-strict-align 2>&1 | 
FileCheck %s -check-prefix=UNALIGNED-SCALAR-MEM
+// RUN: %clang --target=riscv32-unknown-elf -### %s -mstrict-align 2>&1 | 
FileCheck %s -check-prefix=NO-UNALIGNED-SCALAR-MEM
+// RUN: %clang --target=riscv32-unknown-elf -### %s -march=rv32gv 
-munaligned-access 2>&1 | FileCheck %s -check-prefix=UNALIGNED-VECTOR-MEM
+// RUN: %clang --target=riscv32-unknown-elf -### %s -march=rv32gv 
-mno-unaligned-access 2>&1 | FileCheck %s -check-prefix=NO-UNALIGNED-VECTOR-MEM
+// RUN: %clang --target=riscv32-unknown-elf -### %s -march=rv32gv 
-mno-strict-align 2>&1 | FileCheck %s -check-prefix=UNALIGNED-VECTOR-MEM
+// RUN: %clang --target=riscv32-unknown-elf -### %s -march=rv32gv 
-mstrict-align 2>&1 | FileCheck %s -check-prefix=NO-UNALIGNED-VECTOR-MEM
+
+// UNALIGNED-SCALAR-MEM: "-target-feature" "+unaligned-scalar-mem"
+// NO-UNALIGNED-SCALAR-MEM: "-target-feature" "-unaligned-scalar-mem"
+// UNALIGNED-VECTOR-MEM: "-target-feature" "+unaligned-vector-mem"
+// NO-UNALIGNED-VECTOR-MEM: "-target-feature" "-unaligned-vector-mem"
+// DEFAULT: "-target-feature" "-unaligned-scalar-mem"
+// DEFAULT-NOT: "-target-feature" "+unaligned-scalar-mem"
+
 // RUN: %clang --target=riscv32-linux -### %s -fsyntax-only 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=DEFAULT-LINUX
 // RUN: %clang --target=riscv64-linux -### %s -fsyntax-only 2>&1 \
Index: clang/test/Driver/riscv-default-features.c
===
--- clang/test/Driver/riscv-default-features.c
+++ clang/test/Driver/riscv-default-features.c
@@ -3,8 +3,10 @@
 
 // RV32: "target-features"="+32bit,+a,+c,+m,+relax,
 // RV32-SAME: -save-restore
+// RV32-SAME: -unaligned-scalar-mem
 // RV64: "target-features"="+64bit,+a,+c,+m,+relax,
 // RV64-SAME: -save-restore
+// RV64-SAME: -unaligned-scalar-mem
 
 // Dummy function
 int foo(void){
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -167,6 +167,19 @@
   else
 Features.push_back("-save-restore");
 
+  // -mno-unaligned-access is default, unless -munaligned-access is specified.
+  bool HasV = llvm::is_contained(Features, "+zve32x");
+  if (Args.hasFlag(options::OPT_munaligned_access,
+   options::OPT_mno_unaligned_access, false)) {
+Features.push_back("+unaligned-scalar-mem");
+if (HasV)
+  Features.push_back("+unaligned-vector-mem");
+  } else {
+Features.push_back("-unaligned-scalar-mem");
+if (HasV)
+  Features.push_back("-unaligned-vector-mem");
+  }
+
   // Now add any that the user explicitly requested on the command line,
   // which may override the defaults.
   handleTargetFeaturesGroup(D, Triple, Args, Features,
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3834,9 +3834,9 @@
"in __riscv_v_fixed_vlen preprocessor define (RISC-V only)">;
 
 def munaligned_access : Flag<["-"], "munaligned-access">, Group,
-  HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64/LoongArch 
only)">;
+  HelpText<"Allow memory accesses to be unaligned 
(AArch32/AArch64/LoongArch/RISC-V only)">;
 def mno_unaligned_access : Flag<["-"], "mno-unaligned-access">, Group,
-  HelpText<"Force all memory accesses to be aligned (AArch32/AArch64/LoongArch 
only)">;
+  HelpText<"Force all memory accesses to be aligned 
(AArch32/AArch64/LoongArch/RISC-V only)">;
 } // let Flags = [TargetSpecific]
 def mstrict_align : Flag<["-"], "mstrict-align">, Alias, 
Flags<[CC1Option,HelpHidden]>,
   HelpText<"Force all memory accesses to be al

[clang] c7cacb2 - Fix __cfi_check not aligned to 4k on relocatable files with no executable code

2023-08-03 Thread Yi Kong via cfe-commits

Author: Yi Kong
Date: 2023-08-03T19:53:54+09:00
New Revision: c7cacb2f6efe07fa4a1129bb7e2389312670b84a

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

LOG: Fix __cfi_check not aligned to 4k on relocatable files with no executable 
code

CrossDSOCFIPass is supposed to replace this stub function to a properly
aligned function. However the pass is not ran if the file has no
executable code, thus producing incorrectly aligned __cfi_check.

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

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

Added: 
clang/test/CodeGen/cfi-cross-dso-align.c

Modified: 
clang/lib/CodeGen/CGExpr.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index ed6095f7cfeb0d..15aa1b730d268b 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3445,14 +3445,12 @@ void CodeGenFunction::EmitCfiCheckStub() {
   llvm::Function *F = llvm::Function::Create(
   llvm::FunctionType::get(VoidTy, {Int64Ty, Int8PtrTy, Int8PtrTy}, false),
   llvm::GlobalValue::WeakAnyLinkage, "__cfi_check", M);
+  F->setAlignment(llvm::Align(4096));
   CGM.setDSOLocal(F);
   llvm::BasicBlock *BB = llvm::BasicBlock::Create(Ctx, "entry", F);
-  // FIXME: consider emitting an intrinsic call like
-  // call void @llvm.cfi_check(i64 %0, i8* %1, i8* %2)
-  // which can be lowered in CrossDSOCFI pass to the actual contents of
-  // __cfi_check. This would allow inlining of __cfi_check calls.
-  llvm::CallInst::Create(
-  llvm::Intrinsic::getDeclaration(M, llvm::Intrinsic::trap), "", BB);
+  // CrossDSOCFI pass is not executed if there is no executable code.
+  SmallVector Args{F->getArg(2), F->getArg(1)};
+  llvm::CallInst::Create(M->getFunction("__cfi_check_fail"), Args, "", BB);
   llvm::ReturnInst::Create(Ctx, nullptr, BB);
 }
 
@@ -3546,9 +3544,6 @@ void CodeGenFunction::EmitCfiCheckFail() {
   }
 
   FinishFunction();
-  // The only reference to this function will be created during LTO link.
-  // Make sure it survives until then.
-  CGM.addUsedGlobal(F);
 }
 
 void CodeGenFunction::EmitUnreachable(SourceLocation Loc) {

diff  --git a/clang/test/CodeGen/cfi-cross-dso-align.c 
b/clang/test/CodeGen/cfi-cross-dso-align.c
new file mode 100644
index 00..e023601184fe99
--- /dev/null
+++ b/clang/test/CodeGen/cfi-cross-dso-align.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \
+// RUN: -emit-llvm -o - %s | FileCheck %s
+
+int a;
+
+// CHECK: define weak void @__cfi_check(i64 %[[TYPE:.*]], ptr %[[ADDR:.*]], 
ptr %[[DATA:.*]]) align 4096
+// CHECK-NEXT: entry:
+// CHECK-NEXT: call void @__cfi_check_fail(ptr %[[DATA]], ptr %[[ADDR]])



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


[PATCH] D155736: Fix __cfi_check not aligned to 4k on relocatable files with no executable code

2023-08-03 Thread Yi Kong via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc7cacb2f6efe: Fix __cfi_check not aligned to 4k on 
relocatable files with no executable code (authored by kongyi).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155736

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/cfi-cross-dso-align.c


Index: clang/test/CodeGen/cfi-cross-dso-align.c
===
--- /dev/null
+++ clang/test/CodeGen/cfi-cross-dso-align.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \
+// RUN: -emit-llvm -o - %s | FileCheck %s
+
+int a;
+
+// CHECK: define weak void @__cfi_check(i64 %[[TYPE:.*]], ptr %[[ADDR:.*]], 
ptr %[[DATA:.*]]) align 4096
+// CHECK-NEXT: entry:
+// CHECK-NEXT: call void @__cfi_check_fail(ptr %[[DATA]], ptr %[[ADDR]])
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3445,14 +3445,12 @@
   llvm::Function *F = llvm::Function::Create(
   llvm::FunctionType::get(VoidTy, {Int64Ty, Int8PtrTy, Int8PtrTy}, false),
   llvm::GlobalValue::WeakAnyLinkage, "__cfi_check", M);
+  F->setAlignment(llvm::Align(4096));
   CGM.setDSOLocal(F);
   llvm::BasicBlock *BB = llvm::BasicBlock::Create(Ctx, "entry", F);
-  // FIXME: consider emitting an intrinsic call like
-  // call void @llvm.cfi_check(i64 %0, i8* %1, i8* %2)
-  // which can be lowered in CrossDSOCFI pass to the actual contents of
-  // __cfi_check. This would allow inlining of __cfi_check calls.
-  llvm::CallInst::Create(
-  llvm::Intrinsic::getDeclaration(M, llvm::Intrinsic::trap), "", BB);
+  // CrossDSOCFI pass is not executed if there is no executable code.
+  SmallVector Args{F->getArg(2), F->getArg(1)};
+  llvm::CallInst::Create(M->getFunction("__cfi_check_fail"), Args, "", BB);
   llvm::ReturnInst::Create(Ctx, nullptr, BB);
 }
 
@@ -3546,9 +3544,6 @@
   }
 
   FinishFunction();
-  // The only reference to this function will be created during LTO link.
-  // Make sure it survives until then.
-  CGM.addUsedGlobal(F);
 }
 
 void CodeGenFunction::EmitUnreachable(SourceLocation Loc) {


Index: clang/test/CodeGen/cfi-cross-dso-align.c
===
--- /dev/null
+++ clang/test/CodeGen/cfi-cross-dso-align.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \
+// RUN: -emit-llvm -o - %s | FileCheck %s
+
+int a;
+
+// CHECK: define weak void @__cfi_check(i64 %[[TYPE:.*]], ptr %[[ADDR:.*]], ptr %[[DATA:.*]]) align 4096
+// CHECK-NEXT: entry:
+// CHECK-NEXT: call void @__cfi_check_fail(ptr %[[DATA]], ptr %[[ADDR]])
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3445,14 +3445,12 @@
   llvm::Function *F = llvm::Function::Create(
   llvm::FunctionType::get(VoidTy, {Int64Ty, Int8PtrTy, Int8PtrTy}, false),
   llvm::GlobalValue::WeakAnyLinkage, "__cfi_check", M);
+  F->setAlignment(llvm::Align(4096));
   CGM.setDSOLocal(F);
   llvm::BasicBlock *BB = llvm::BasicBlock::Create(Ctx, "entry", F);
-  // FIXME: consider emitting an intrinsic call like
-  // call void @llvm.cfi_check(i64 %0, i8* %1, i8* %2)
-  // which can be lowered in CrossDSOCFI pass to the actual contents of
-  // __cfi_check. This would allow inlining of __cfi_check calls.
-  llvm::CallInst::Create(
-  llvm::Intrinsic::getDeclaration(M, llvm::Intrinsic::trap), "", BB);
+  // CrossDSOCFI pass is not executed if there is no executable code.
+  SmallVector Args{F->getArg(2), F->getArg(1)};
+  llvm::CallInst::Create(M->getFunction("__cfi_check_fail"), Args, "", BB);
   llvm::ReturnInst::Create(Ctx, nullptr, BB);
 }
 
@@ -3546,9 +3544,6 @@
   }
 
   FinishFunction();
-  // The only reference to this function will be created during LTO link.
-  // Make sure it survives until then.
-  CGM.addUsedGlobal(F);
 }
 
 void CodeGenFunction::EmitUnreachable(SourceLocation Loc) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155610: [Clang][ExprConstant] Print integer instead of character on static assertion failure

2023-08-03 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

This is starting to look pretty good!
I'm happy with the general direction, my only concern is that printing a prefix 
does not seem useful - we are trying to display the value, not how it was 
produced.




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16839
+
+static void PrintCharLiteralPrefix(BuiltinType::Kind BTK,
+   llvm::raw_ostream &OS) {

We have similar switches in
* `StringLiteral::outputString` 
* `TryPrintAsStringLiteral` (APValue.cpp)
* `CharacterLiteral::print`

Sadly they all look at different things so I don't know if we could refactor 
all of that.
But looking further done, I don;t think we should print a prefix here, so we 
could remove that bit entirely. 



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16899
+  uint32_t CodePoint = 
static_cast(V.getInt().getZExtValue());
+  PrintCharLiteralPrefix(BTy->getKind(), OS);
+  OS << '\'';

Looking at the diagnostics, I don't think it makes sense to print a prefix 
here. You could just leave that part out.


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

https://reviews.llvm.org/D155610

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


[PATCH] D156320: [FLang] Add support for Rpass flag

2023-08-03 Thread victorkingi via Phabricator via cfe-commits
victorkingi updated this revision to Diff 546798.
victorkingi added a comment.

rpass flag now prints remarks when requested but does not display
the passName used, i.e [-Rpass=inline]


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156320

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/DiagnosticIDs.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/tools/flang-driver/driver.cpp

Index: flang/tools/flang-driver/driver.cpp
===
--- flang/tools/flang-driver/driver.cpp
+++ flang/tools/flang-driver/driver.cpp
@@ -30,6 +30,7 @@
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Host.h"
+#include 
 #include 
 
 using llvm::StringRef;
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -87,6 +87,10 @@
 ! HELP-NEXT: -print-effective-triple Print the effective target triple
 ! HELP-NEXT: -print-target-triplePrint the normalized target triple
 ! HELP-NEXT: -P Disable linemarker output in -E mode
+! HELP-NEXT: -Rpass-analysis= Report transformation analysis from optimization passes whose name matches the given POSIX regular expression
+! HELP-NEXT: -Rpass-missed=   Report missed transformations by optimization passes whose name matches the given POSIX regular expression
+! HELP-NEXT: -Rpass=  Report transformations performed by optimization passes whose name matches the given POSIX regular expression
+! HELP-NEXT: -R  Enable the specified remark
 ! HELP-NEXT: -save-temps=Save intermediate compilation results.
 ! HELP-NEXT: -save-tempsSave intermediate compilation results
 ! HELP-NEXT: -std=   Language standard to compile for
@@ -206,6 +210,10 @@
 ! HELP-FC1-NEXT: -pic-level   Value for __PIC__
 ! HELP-FC1-NEXT: -plugin  Use the named plugin action instead of the default action (use "help" to list available options)
 ! HELP-FC1-NEXT: -P Disable linemarker output in -E mode
+! HELP-FC1-NEXT: -Rpass-analysis= Report transformation analysis from optimization passes whose name matches the given POSIX regular expression
+! HELP-FC1-NEXT: -Rpass-missed=   Report missed transformations by optimization passes whose name matches the given POSIX regular expression
+! HELP-FC1-NEXT: -Rpass=  Report transformations performed by optimization passes whose name matches the given POSIX regular expression
+! HELP-FC1-NEXT: -R  Enable the specified remark
 ! HELP-FC1-NEXT: -save-temps=Save intermediate compilation results.
 ! HELP-FC1-NEXT: -save-tempsSave intermediate compilation results
 ! HELP-FC1-NEXT: -std=   Language standard to compile for
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -91,6 +91,10 @@
 ! CHECK-NEXT: -print-effective-triple Print the effective target triple
 ! CHECK-NEXT: -print-target-triplePrint the normalized target triple
 ! CHECK-NEXT: -P Disable linemarker output in -E mode
+! CHECK-NEXT: -Rpass-analysis= Report transformation analysis from optimization passes whose name matches the given POSIX regular expression
+! CHECK-NEXT: -Rpass-missed=   Report missed transformations by optimization passes whose name matches the given POSIX regular expression
+! CHECK-NEXT: -Rpass=  Report transformations performed by optimization passes whose name matches the given POSIX regular expression
+! CHECK-NEXT: -R  Enable the specified remark
 ! CHECK-NEXT: -save-temps=Save intermediate compilation results.
 ! CHECK-NEXT: -save-tempsSave intermediate compilation results
 ! CHECK-NEXT: -std=   Language standard to compile for
Index: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -27,6 +27,7 @@
 #include "llvm/Option/Option.h"
 #include "llvm/Support/BuryPointer.h"
 #include "llvm/Support/CommandLine.h"
+#include 
 
 namespace Fortran::frontend {
 
@@ -100,6 +101,72 @@
   llvm_unreachable("Invalid program action!");
 }
 
+static void EmitUnknownDiagWarning(clang::DiagnosticsEngine &Diags,
+  

[PATCH] D156989: FloatingPointMode: Use -1 for "Dynamic"

2023-08-03 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: sepavloff, rjmccall, kpn, cameron.mcinally, uweigand, 
scanon, jcranmer-intel, foad.
Herald added subscribers: StephenFan, tpr.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

FLT_ROUNDS says -1 is used for "the default rounding direction is not
known". The previous 7 was taking away options in the
"implementation-defined behavior" range if you just wanted to extend
the enum.

  

AMDGPU has 2 separately controllable rounding modes that change
different fp types. I want to stick to the standard values in the case
the modes are the same, and use the extended range for cases where the
two are different. Dodging this gap in the enum value required
defining the AMDGPU target specific values in a weird way with strange
conversion code to handle it (see https://reviews.llvm.org/D153257).


https://reviews.llvm.org/D156989

Files:
  clang/include/clang/Basic/FPOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Basic/LangOptions.cpp
  llvm/include/llvm/ADT/FloatingPointMode.h

Index: llvm/include/llvm/ADT/FloatingPointMode.h
===
--- llvm/include/llvm/ADT/FloatingPointMode.h
+++ llvm/include/llvm/ADT/FloatingPointMode.h
@@ -35,18 +35,30 @@
 /// rounding mode value, so it does not need to fit the bit fields.
 ///
 enum class RoundingMode : int8_t {
+  // Special values.
+  Invalid = -2,
+
+  ///< Denotes mode unknown at compile time.
+  Dynamic = -1,
+
   // Rounding mode defined in IEEE-754.
   TowardZero= 0,///< roundTowardZero.
   NearestTiesToEven = 1,///< roundTiesToEven.
   TowardPositive= 2,///< roundTowardPositive.
   TowardNegative= 3,///< roundTowardNegative.
-  NearestTiesToAway = 4,///< roundTiesToAway.
-
-  // Special values.
-  Dynamic = 7,///< Denotes mode unknown at compile time.
-  Invalid = -1///< Denotes invalid value.
+  NearestTiesToAway = 4 ///< roundTiesToAway.
 };
 
+/// Encode a RoundingMode value into a form suitable for a bitfield.
+constexpr int8_t encodeRoundingMode(RoundingMode RM) {
+  return static_cast(RM) + 1;
+}
+
+/// Decode a RoundingMode value from a form suitable for a bitfield.
+constexpr RoundingMode decodeRoundingMode(int8_t Val) {
+  return static_cast(Val - 1);
+}
+
 /// Returns text representation of the given rounding mode.
 inline StringRef spell(RoundingMode RM) {
   switch (RM) {
Index: clang/lib/Basic/LangOptions.cpp
===
--- clang/lib/Basic/LangOptions.cpp
+++ clang/lib/Basic/LangOptions.cpp
@@ -215,7 +215,7 @@
 
 FPOptionsOverride FPOptions::getChangesSlow(const FPOptions &Base) const {
   FPOptions::storage_type OverrideMask = 0;
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS)\
+#define OPTION(NAME, TYPE, ENCODE, DECODE, WIDTH, PREVIOUS)\
   if (get##NAME() != Base.get##NAME()) \
 OverrideMask |= NAME##Mask;
 #include "clang/Basic/FPOptions.def"
@@ -223,14 +223,14 @@
 }
 
 LLVM_DUMP_METHOD void FPOptions::dump() {
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS)\
+#define OPTION(NAME, TYPE, ENCODE, DECODE, WIDTH, PREVIOUS)\
   llvm::errs() << "\n " #NAME " " << get##NAME();
 #include "clang/Basic/FPOptions.def"
   llvm::errs() << "\n";
 }
 
 LLVM_DUMP_METHOD void FPOptionsOverride::dump() {
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS)\
+#define OPTION(NAME, TYPE, ENCODE, DECODE, WIDTH, PREVIOUS)\
   if (has##NAME##Override())   \
 llvm::errs() << "\n " #NAME " Override is " << get##NAME##Override();
 #include "clang/Basic/FPOptions.def"
Index: clang/lib/AST/TextNodeDumper.cpp
===
--- clang/lib/AST/TextNodeDumper.cpp
+++ clang/lib/AST/TextNodeDumper.cpp
@@ -756,7 +756,7 @@
 }
 
 void TextNodeDumper::printFPOptions(FPOptionsOverride FPO) {
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS)\
+#define OPTION(NAME, TYPE, ENCODE, DECODE, WIDTH, PREVIOUS)\
   if (FPO.has##NAME##Override())   \
 OS << " " #NAME "=" << FPO.get##NAME##Override();
 #include "clang/Basic/FPOptions.def"
Index: clang/lib/AST/JSONNodeDumper.cpp
===
--- clang/lib/AST/JSONNodeDumper.cpp
+++ clang/lib/AST/JSONNodeDumper.cpp
@@ -1740,7 +1740,7 @@
 
 llvm::json::Object JSONNodeDumper::createFPOptions(FPOptionsOverride FPO) {
   llvm::json::Object Ret;
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS)   

[PATCH] D155736: Fix __cfi_check not aligned to 4k on relocatable files with no executable code

2023-08-03 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

It seems this patch broke the Solaris/amd64 buildbot 
:

  FAIL: Clang::cfi-check-fail.c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155736

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


[PATCH] D156400: [clang][Interp] Implement __builtin_offsetof

2023-08-03 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/AST/Interp/Interp.h:1901
+inline bool OffsetOf(InterpState &S, CodePtr OpPC, const OffsetOfExpr *E) {
+  std::vector ArrayIndices;
+  for (unsigned I = 0; I != E->getNumExpressions(); ++I)

Might be useful to use a small vector here



Comment at: clang/lib/AST/Interp/InterpBuiltin.cpp:590
 
+bool InterpretOffsetOf(InterpState &S, CodePtr OpPC, const OffsetOfExpr *E,
+   const std::vector &ArrayIndices,

This function is the same as `IntExprEvaluator::VisitOffsetOfExpr` - except for 
the array case. It's frustrating me but I don't have a good solution 


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

https://reviews.llvm.org/D156400

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


[PATCH] D156400: [clang][Interp] Implement __builtin_offsetof

2023-08-03 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:1536-1537
+  // Cast to Sint64.
+  if (IndexT != PT_Sint64) {
+if (!this->emitCast(IndexT, PT_Sint64, E))
+  return false;

Shouldn't that be size_t?


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

https://reviews.llvm.org/D156400

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


[PATCH] D156989: FloatingPointMode: Use -1 for "Dynamic"

2023-08-03 Thread Jay Foad via Phabricator via cfe-commits
foad added inline comments.



Comment at: llvm/include/llvm/ADT/FloatingPointMode.h:39
+  // Special values.
+  Invalid = -2,
+

Lost the `///<` comment here.



Comment at: llvm/include/llvm/ADT/FloatingPointMode.h:41
+
+  ///< Denotes mode unknown at compile time.
+  Dynamic = -1,

Does `///<` work //before// the field name?


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

https://reviews.llvm.org/D156989

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


[PATCH] D155736: Fix __cfi_check not aligned to 4k on relocatable files with no executable code

2023-08-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks check-clang: http://45.33.8.238/linux/114361/step_7.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155736

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


[clang] 9f72df7 - Fixing a formatting mistake; NFC

2023-08-03 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-08-03T08:07:59-04:00
New Revision: 9f72df7e30f074b46b18d3de267450236e4e37ea

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

LOG: Fixing a formatting mistake; NFC

There was a brace that was hanging out in the middle of nowhere, this
fixes that issue.

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 2716b667710596..678553a4898c30 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -13890,44 +13890,44 @@ void Sema::diagnoseLogicalInsteadOfBitwise(Expr *Op1, 
Expr *Op2,
   Op2->getType()->isIntegerType() && !Op2->isValueDependent() &&
   // Don't warn in macros or template instantiations.
   !Loc.isMacroID() && !inTemplateInstantiation() &&
-  !Op2->getExprLoc().isMacroID() &&
-  !Op1->getExprLoc().isMacroID()) {
+  !Op2->getExprLoc().isMacroID() && !Op1->getExprLoc().isMacroID()) {
 bool IsOp1InMacro = Op1->getExprLoc().isMacroID();
 bool IsOp2InMacro = Op2->getExprLoc().isMacroID();
 
 // Exclude the specific expression from triggering the warning.
-if (!(IsOp1InMacro && IsOp2InMacro && Op1->getSourceRange() == 
Op2->getSourceRange())) {
-// If the RHS can be constant folded, and if it constant folds to something
-// that isn't 0 or 1 (which indicate a potential logical operation that
-// happened to fold to true/false) then warn.
-// Parens on the RHS are ignored.
-// If the RHS can be constant folded, and if it constant folds to something
-// that isn't 0 or 1 (which indicate a potential logical operation that
-// happened to fold to true/false) then warn.
-// Parens on the RHS are ignored.
-Expr::EvalResult EVResult;
-if (Op2->EvaluateAsInt(EVResult, Context)) {
-  llvm::APSInt Result = EVResult.Val.getInt();
-  if ((getLangOpts().Bool && !Op2->getType()->isBooleanType() &&
-   !Op2->getExprLoc().isMacroID()) ||
-  (Result != 0 && Result != 1)) {
-Diag(Loc, diag::warn_logical_instead_of_bitwise)
-<< Op2->getSourceRange() << (Opc == BO_LAnd ? "&&" : "||");
-// Suggest replacing the logical operator with the bitwise version
-Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
-<< (Opc == BO_LAnd ? "&" : "|")
-<< FixItHint::CreateReplacement(
-   SourceRange(Loc, getLocForEndOfToken(Loc)),
-   Opc == BO_LAnd ? "&" : "|");
-if (Opc == BO_LAnd)
-  // Suggest replacing "Foo() && kNonZero" with "Foo()"
-  Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
-  << FixItHint::CreateRemoval(SourceRange(
- getLocForEndOfToken(Op1->getEndLoc()), Op2->getEndLoc()));
+if (!(IsOp1InMacro && IsOp2InMacro &&
+  Op1->getSourceRange() == Op2->getSourceRange())) {
+  // If the RHS can be constant folded, and if it constant folds to
+  // something that isn't 0 or 1 (which indicate a potential logical
+  // operation that happened to fold to true/false) then warn. Parens on 
the
+  // RHS are ignored. If the RHS can be constant folded, and if it constant
+  // folds to something that isn't 0 or 1 (which indicate a potential
+  // logical operation that happened to fold to true/false) then warn.
+  // Parens on the RHS are ignored.
+  Expr::EvalResult EVResult;
+  if (Op2->EvaluateAsInt(EVResult, Context)) {
+llvm::APSInt Result = EVResult.Val.getInt();
+if ((getLangOpts().Bool && !Op2->getType()->isBooleanType() &&
+ !Op2->getExprLoc().isMacroID()) ||
+(Result != 0 && Result != 1)) {
+  Diag(Loc, diag::warn_logical_instead_of_bitwise)
+  << Op2->getSourceRange() << (Opc == BO_LAnd ? "&&" : "||");
+  // Suggest replacing the logical operator with the bitwise version
+  Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
+  << (Opc == BO_LAnd ? "&" : "|")
+  << FixItHint::CreateReplacement(
+ SourceRange(Loc, getLocForEndOfToken(Loc)),
+ Opc == BO_LAnd ? "&" : "|");
+  if (Opc == BO_LAnd)
+// Suggest replacing "Foo() && kNonZero" with "Foo()"
+Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
+<< FixItHint::CreateRemoval(
+   SourceRange(getLocForEndOfToken(Op1->getEndLoc()),
+   Op2->getEndLoc()));
+}
   }
 }
   }
-  }
 }
 
 // C99 6.5.[13,14]



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

[PATCH] D156704: [clang][HeaderSearch] Treat framework headers as System for suggestPath

2023-08-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang/lib/Lex/HeaderSearch.cpp:1939
 
 std::string HeaderSearch::suggestPathToFileForDiagnostics(
 llvm::StringRef File, llvm::StringRef WorkingDir, llvm::StringRef MainFile,

sorry I guess my suggestion get distorted a little bit on the way :D

I was actually suggesting to rename `IsSystem` to `IsAngled`, and change the 
logic in the rest of the code here to look for angled-ness of include search 
path, rather than system-ness.
As all of the current callers make use of this information to figure out if 
they should spell the includes with `angles` or `quotes` and set it if the 
include search dir is either part of angled or system includes.

That way we make sure we're not giving mixed signals out of this function. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156704

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


[PATCH] D153954: [clang][analyzer] Fix empty enum handling in EnumCastOutOfRange checker

2023-08-03 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy accepted this revision.
donat.nagy added a comment.
This revision is now accepted and ready to land.

LGTM, with a little bikeshedding ;-)




Comment at: clang/test/Analysis/enum-cast-out-of-range.cpp:203
+
+enum class empty_unfixed {};
+

Consider using "specified" and "unspecified" instead of "fixed" and "unfixed", 
because the rest of the test file uses them and in my opinion "unfixed" looks 
strange in this context.  (I know that e.g. 
https://en.cppreference.com/w/cpp/language/enum speaks about "fixed" underlying 
context, but it doesn't use "unfixed".) 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153954

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


[PATCH] D156400: [clang][Interp] Implement __builtin_offsetof

2023-08-03 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/AST/Interp/Interp.h:1902
+  std::vector ArrayIndices;
+  for (unsigned I = 0; I != E->getNumExpressions(); ++I)
+ArrayIndices.emplace_back(S.Stk.pop());

can you use size_t here?
It's already a bug nest but it can't hurt to use better types, even if 
`getNumExpressions` returns unsigned 
 https://godbolt.org/z/vhYxose4o 


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

https://reviews.llvm.org/D156400

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


[PATCH] D156743: clang/OpenCL: Add inline implementations of sqrt in builtin header

2023-08-03 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 546814.
arsenm marked an inline comment as done.

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

https://reviews.llvm.org/D156743

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Headers/opencl-c.h
  clang/lib/Sema/OpenCLBuiltins.td
  clang/test/CodeGenOpenCL/sqrt-fpmath.cl

Index: clang/test/CodeGenOpenCL/sqrt-fpmath.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/sqrt-fpmath.cl
@@ -0,0 +1,201 @@
+// Test that float variants of sqrt are emitted as available_externally inline
+// definitions that call the sqrt intrinsic with appropriate !fpmath metadata
+// depending on -cl-fp32-correctly-rounded-divide-sqrt
+
+// Test with -fdeclare-opencl-builtins
+// RUN: %clang_cc1 -disable-llvm-passes -triple amdgcn-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header -S -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,DEFAULT %s
+// RUN: %clang_cc1 -disable-llvm-passes -triple amdgcn-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header -cl-fp32-correctly-rounded-divide-sqrt -S -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,CORRECTLYROUNDED %s
+
+// RUN: %clang_cc1 -disable-llvm-passes -triple amdgcn-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header -cl-unsafe-math-optimizations -S -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,DEFAULT-UNSAFE %s
+// RUN: %clang_cc1 -disable-llvm-passes -triple amdgcn-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header -cl-fp32-correctly-rounded-divide-sqrt -cl-unsafe-math-optimizations -S -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,CORRECTLYROUNDED-UNSAFE %s
+
+// Test without -fdeclare-opencl-builtins
+// RUN: %clang_cc1 -disable-llvm-passes -triple amdgcn-unknown-unknown -finclude-default-header -S -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,DEFAULT %s
+// RUN: %clang_cc1 -disable-llvm-passes -triple amdgcn-unknown-unknown -finclude-default-header -cl-fp32-correctly-rounded-divide-sqrt -S -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,CORRECTLYROUNDED %s
+
+// RUN: %clang_cc1 -disable-llvm-passes -triple amdgcn-unknown-unknown -finclude-default-header -cl-unsafe-math-optimizations -S -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,DEFAULT-UNSAFE %s
+// RUN: %clang_cc1 -disable-llvm-passes -triple amdgcn-unknown-unknown -finclude-default-header -cl-fp32-correctly-rounded-divide-sqrt -cl-unsafe-math-optimizations -S -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,CORRECTLYROUNDED-UNSAFE %s
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+// CHECK-LABEL: define {{.*}} float @call_sqrt_f32(
+// CHECK: call {{.*}} float @_Z4sqrtf(float noundef %{{.+}}) #{{[0-9]+$}}
+float call_sqrt_f32(float x) {
+  return sqrt(x);
+}
+
+// CHECK-LABEL: define available_externally float @_Z4sqrtf(float noundef %__x)
+// DEFAULT: call float @llvm.sqrt.f32(float %{{.+}}), !fpmath [[$FPMATH:![0-9]+]]{{$}}
+// CORRECTLYROUNDED: call float @llvm.sqrt.f32(float %{{.+}}){{$}}
+
+// DEFAULT-UNSAFE: call reassoc nsz arcp contract afn float @llvm.sqrt.f32(float %{{.+}}), !fpmath [[$FPMATH:![0-9]+]]{{$}}
+// CORRECTLYROUNDED-UNSAFE: call reassoc nsz arcp contract afn float @llvm.sqrt.f32(float %{{.+}}){{$}}
+
+// CHECK-LABEL: define {{.*}} <2 x float> @call_sqrt_v2f32(
+// CHECK: call {{.*}} <2 x float> @_Z4sqrtDv2_f(<2 x float> noundef %{{.*}}) #{{[0-9]+$}}
+float2 call_sqrt_v2f32(float2 x) {
+  return sqrt(x);
+}
+
+// CHECK-LABEL: define available_externally <2 x float> @_Z4sqrtDv2_f(<2 x float> noundef %__x)
+// DEFAULT: call <2 x float> @llvm.sqrt.v2f32(<2 x float> %{{.+}}), !fpmath [[$FPMATH:![0-9]+]]{{$}}
+// CORRECTLYROUNDED: call <2 x float> @llvm.sqrt.v2f32(<2 x float> %{{.+}}){{$}}
+
+// DEFAULT-UNSAFE: call reassoc nsz arcp contract afn <2 x float> @llvm.sqrt.v2f32(<2 x float> %{{.+}}), !fpmath [[$FPMATH:![0-9]+]]{{$}}
+// CORRECTLYROUNDED-UNSAFE: call reassoc nsz arcp contract afn <2 x float> @llvm.sqrt.v2f32(<2 x float> %{{.+}}){{$}}
+
+// CHECK-LABEL: define {{.*}} <3 x float> @call_sqrt_v3f32(
+// CHECK: call {{.*}} <3 x float> @_Z4sqrtDv3_f(<3 x float> noundef %{{.*}}) #{{[0-9]+$}}
+float3 call_sqrt_v3f32(float3 x) {
+  return sqrt(x);
+}
+
+// CHECK-LABEL: define available_externally <3 x float> @_Z4sqrtDv3_f(<3 x float> noundef %__x)
+// DEFAULT: call <3 x float> @llvm.sqrt.v3f32(<3 x float> %{{.+}}), !fpmath [[$FPMATH:![0-9]+]]{{$}}
+// CORRECTLYROUNDED: call <3 x float> @llvm.sqrt.v3f32(<3 x float> %{{.+}}){{$}}
+
+// DEFAULT-UNSAFE: call reassoc nsz arcp contract afn <3 x float> @llvm.sqrt.v3f32(<3 x float> %{{.+}}), !fpmath [[$FPMATH:![0-9]+]]{{$}}
+// CORRECTLYROUNDED-UNSAFE: call reassoc nsz arcp contract afn <3 x float> @llvm.sqrt.v3f32(<3 x float> %{{.+}}){{$}}
+
+
+// CHECK-LABEL: define {{.*}} <4 x float> @call_sqrt_v4f32(
+// CHECK: call {{.*}} <4 x float> @_Z4sqrtDv4_f(<4 x float> noundef %{{.*}}) #{{[0-9]+$}}
+float4 call_sqrt_v4f32(float4 x) {

[PATCH] D156743: clang/OpenCL: Add inline implementations of sqrt in builtin header

2023-08-03 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/Headers/opencl-c-base.h:832
+
+inline float __ovld __cnfn sqrt(float __x) {
+  return __builtin_elementwise_sqrt(__x);

svenvh wrote:
> Anastasia wrote:
> > Is this a generic implementation enough? Would some targets not need to do 
> > something different for this built-in?
> > 
> > Ideally this header is to be kept light so I am a bit worried about adding 
> > definitions of the functions here. Otherwise we will end up in the same 
> > situation as we one day were with opencl-c.h. So could these be left there 
> > instead? It might be good to check with @svenvh if TableGen header has 
> > already a way to do this function forwarding or can be extended to do such 
> > a thing. Then it would be implementable in the both header mechanisms. I 
> > don't know if Sven has some other ideas or opinions...
> We did already discuss this a bit on the GitHub issue: 
> https://github.com/llvm/llvm-project/issues/64264
As I mentioned on the ticket, it's only this one case so I'm not worried about 
adding a lot more to the base header. I think we can start by assuming 
llvm.sqrt always works correctly, I don't want to add more complexity to handle 
this case without a specific reason


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

https://reviews.llvm.org/D156743

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


[PATCH] D156989: FloatingPointMode: Use -1 for "Dynamic"

2023-08-03 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 546815.

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

https://reviews.llvm.org/D156989

Files:
  clang/include/clang/Basic/FPOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Basic/LangOptions.cpp
  llvm/include/llvm/ADT/FloatingPointMode.h

Index: llvm/include/llvm/ADT/FloatingPointMode.h
===
--- llvm/include/llvm/ADT/FloatingPointMode.h
+++ llvm/include/llvm/ADT/FloatingPointMode.h
@@ -35,18 +35,28 @@
 /// rounding mode value, so it does not need to fit the bit fields.
 ///
 enum class RoundingMode : int8_t {
+  // Special values.
+  Invalid = -2, ///< Denotes invalid value.
+  Dynamic = -1, ///< Denotes mode unknown at compile time.
+
   // Rounding mode defined in IEEE-754.
   TowardZero= 0,///< roundTowardZero.
   NearestTiesToEven = 1,///< roundTiesToEven.
   TowardPositive= 2,///< roundTowardPositive.
   TowardNegative= 3,///< roundTowardNegative.
-  NearestTiesToAway = 4,///< roundTiesToAway.
-
-  // Special values.
-  Dynamic = 7,///< Denotes mode unknown at compile time.
-  Invalid = -1///< Denotes invalid value.
+  NearestTiesToAway = 4 ///< roundTiesToAway.
 };
 
+/// Encode a RoundingMode value into a form suitable for a bitfield.
+constexpr int8_t encodeRoundingMode(RoundingMode RM) {
+  return static_cast(RM) + 1;
+}
+
+/// Decode a RoundingMode value from a form suitable for a bitfield.
+constexpr RoundingMode decodeRoundingMode(int8_t Val) {
+  return static_cast(Val - 1);
+}
+
 /// Returns text representation of the given rounding mode.
 inline StringRef spell(RoundingMode RM) {
   switch (RM) {
Index: clang/lib/Basic/LangOptions.cpp
===
--- clang/lib/Basic/LangOptions.cpp
+++ clang/lib/Basic/LangOptions.cpp
@@ -215,7 +215,7 @@
 
 FPOptionsOverride FPOptions::getChangesSlow(const FPOptions &Base) const {
   FPOptions::storage_type OverrideMask = 0;
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS)\
+#define OPTION(NAME, TYPE, ENCODE, DECODE, WIDTH, PREVIOUS)\
   if (get##NAME() != Base.get##NAME()) \
 OverrideMask |= NAME##Mask;
 #include "clang/Basic/FPOptions.def"
@@ -223,14 +223,14 @@
 }
 
 LLVM_DUMP_METHOD void FPOptions::dump() {
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS)\
+#define OPTION(NAME, TYPE, ENCODE, DECODE, WIDTH, PREVIOUS)\
   llvm::errs() << "\n " #NAME " " << get##NAME();
 #include "clang/Basic/FPOptions.def"
   llvm::errs() << "\n";
 }
 
 LLVM_DUMP_METHOD void FPOptionsOverride::dump() {
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS)\
+#define OPTION(NAME, TYPE, ENCODE, DECODE, WIDTH, PREVIOUS)\
   if (has##NAME##Override())   \
 llvm::errs() << "\n " #NAME " Override is " << get##NAME##Override();
 #include "clang/Basic/FPOptions.def"
Index: clang/lib/AST/TextNodeDumper.cpp
===
--- clang/lib/AST/TextNodeDumper.cpp
+++ clang/lib/AST/TextNodeDumper.cpp
@@ -756,7 +756,7 @@
 }
 
 void TextNodeDumper::printFPOptions(FPOptionsOverride FPO) {
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS)\
+#define OPTION(NAME, TYPE, ENCODE, DECODE, WIDTH, PREVIOUS)\
   if (FPO.has##NAME##Override())   \
 OS << " " #NAME "=" << FPO.get##NAME##Override();
 #include "clang/Basic/FPOptions.def"
Index: clang/lib/AST/JSONNodeDumper.cpp
===
--- clang/lib/AST/JSONNodeDumper.cpp
+++ clang/lib/AST/JSONNodeDumper.cpp
@@ -1740,7 +1740,7 @@
 
 llvm::json::Object JSONNodeDumper::createFPOptions(FPOptionsOverride FPO) {
   llvm::json::Object Ret;
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS)\
+#define OPTION(NAME, TYPE, ENCODE, DECODE, WIDTH, PREVIOUS)\
   if (FPO.has##NAME##Override())   \
 Ret.try_emplace(#NAME, static_cast(FPO.get##NAME##Override()));
 #include "clang/Basic/FPOptions.def"
Index: clang/include/clang/Basic/LangOptions.h
===
--- clang/include/clang/Basic/LangOptions.h
+++ clang/include/clang/Basic/LangOptions.h
@@ -670,7 +670,7 @@
   // Define a fake option named "First" so that we have a PREVIOUS even for the
   // real first option.
   static constexpr storage_type FirstShift = 0, FirstWidth = 0;
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS)\
+#define OPTION(NAME, ENCODE, DECODE, TYPE, WIDTH, PRE

[PATCH] D156993: [clang] Error on substitution failure within lambda body inside a requires-expression

2023-08-03 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon created this revision.
Herald added a project: All.
Fznamznon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Per CWG 2672 substitution failure within the body of a lambda inside a
requires-expression should be a hard error.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156993

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/SemaCXX/lambda-unevaluated.cpp


Index: clang/test/SemaCXX/lambda-unevaluated.cpp
===
--- clang/test/SemaCXX/lambda-unevaluated.cpp
+++ clang/test/SemaCXX/lambda-unevaluated.cpp
@@ -155,17 +155,24 @@
 
 template 
 concept lambda_works = requires {
-[]() { T::foo(); };
+[]() { T::foo(); }; // expected-error{{type 'int' cannot be used prior to 
'::'}}
+// expected-note@-1{{while substituting into a lambda 
expression here}}
+// expected-note@-2{{in instantiation of requirement 
here}}
+// expected-note@-4{{while substituting template 
arguments into constraint expression here}}
 };
 
-static_assert(!lambda_works);
+static_assert(!lambda_works); // expected-note {{while checking the 
satisfaction of concept 'lambda_works' requested here}}
 static_assert(lambda_works);
 
 template 
-int* func(T) requires requires { []() { T::foo(); }; };
+int* func(T) requires requires { []() { T::foo(); }; }; // 
expected-error{{type 'int' cannot be used prior to '::'}}
+// 
expected-note@-1{{while substituting into a lambda expression here}}
+// 
expected-note@-2{{in instantiation of requirement here}}
+// 
expected-note@-3{{while substituting template arguments into constraint 
expression here}}
 double* func(...);
 
-static_assert(__is_same(decltype(func(0)), double*));
+static_assert(__is_same(decltype(func(0)), double*)); // expected-note {{while 
checking constraint satisfaction for template 'func' required here}}
+  // expected-note@-1 {{in 
instantiation of function template specialization 
'lambda_in_constraints::func'}}
 static_assert(__is_same(decltype(func(WithFoo())), int*));
 
 template 
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1074,7 +1074,6 @@
   if (InNonInstantiationSFINAEContext)
 return std::optional(nullptr);
 
-  bool SawLambdaSubstitution = false;
   for (SmallVectorImpl::const_reverse_iterator
  Active = CodeSynthesisContexts.rbegin(),
  ActiveEnd = CodeSynthesisContexts.rend();
@@ -1101,10 +1100,7 @@
   // A lambda-expression appearing in a function type or a template
   // parameter is not considered part of the immediate context for the
   // purposes of template argument deduction.
-
-  // We need to check parents.
-  SawLambdaSubstitution = true;
-  break;
+  return std::nullopt;
 
 case CodeSynthesisContext::DefaultTemplateArgumentInstantiation:
 case CodeSynthesisContext::PriorTemplateArgumentSubstitution:
@@ -1120,8 +1116,6 @@
   // We're either substituting explicitly-specified template arguments,
   // deduced template arguments. SFINAE applies unless we are in a lambda
   // expression, see [temp.deduct]p9.
-  if (SawLambdaSubstitution)
-return std::nullopt;
   [[fallthrough]];
 case CodeSynthesisContext::ConstraintSubstitution:
 case CodeSynthesisContext::RequirementInstantiation:
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -132,6 +132,10 @@
   (`#35574 _`) and
   (`#27224 _`).
 
+- Clang emits an error on substitution failure within lambda body inside a
+  requires-expression. This fixes:
+  (`#64138 _`).
+
 Bug Fixes to AST Handling
 ^
 - Fixed an import failure of recursive friend class template.


Index: clang/test/SemaCXX/lambda-unevaluated.cpp
===
--- clang/test/SemaCXX/lambda-unevaluated.cpp
+++ clang/test/SemaCXX/lambda-unevaluated.cpp
@@ -155,17 +155,24 @@
 
 template 
 concept lambda_works = requires {
-[]() { T::foo(); };
+[]() { T::foo(); }; // expected-error{{type 'int' cannot be used prior to '::'}}
+// expected-note@-1{{while substituting into a lambda ex

[PATCH] D156320: [FLang] Add support for Rpass flag

2023-08-03 Thread victorkingi via Phabricator via cfe-commits
victorkingi updated this revision to Diff 546819.
victorkingi added a comment.

added test file optimization-remark.f90


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156320

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/DiagnosticIDs.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/optimization-remark.f90
  flang/tools/flang-driver/driver.cpp

Index: flang/tools/flang-driver/driver.cpp
===
--- flang/tools/flang-driver/driver.cpp
+++ flang/tools/flang-driver/driver.cpp
@@ -30,6 +30,7 @@
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Host.h"
+#include 
 #include 
 
 using llvm::StringRef;
Index: flang/test/Driver/optimization-remark.f90
===
--- /dev/null
+++ flang/test/Driver/optimization-remark.f90
@@ -0,0 +1,35 @@
+! This file tests the -Rpass family of flags (-Rpass, -Rpass-missed
+! and -Rpass-analysis)
+! loop-delete isn't enabled at O0 so we use at least O1
+
+! Check that we can override -Rpass= with -Rno-pass.
+! RUN: %flang_fc1 %s -O1 -Rpass=loop-delete -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+! RUN: %flang_fc1 %s -O1 -Rpass=loop-delete -Rno-pass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS
+! RUN: %flang_fc1 %s -O1 -Rpass=loop-delete -Rno-everything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS
+! RUN: %flang_fc1 %s -O1 -Rpass=loop-delete -Rno-everything -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+
+! -Reverything implies -Rpass=.*.
+! RUN: %flang_fc1 %s -O1 -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+
+! -Rpass implies -Rpass=.*
+! RUN: %flang_fc1 %s -O1 -Rpass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+
+! Check full -Rpass message is emitted
+! RUN: %flang %s -O1 -Rpass=loop-delete 2>&1 | FileCheck %s
+
+
+! CHECK: remark: Loop deleted because it is invariant
+! CHECK-REMARKS: remark:
+! CHECK-NO-REMARKS-NOT: remark:
+
+
+program forttest
+implicit none
+real, dimension(1:50) :: aR1
+integer :: n
+
+do n = 1,50
+aR1(n) = n * 1
+end do
+
+end program forttest
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -87,6 +87,10 @@
 ! HELP-NEXT: -print-effective-triple Print the effective target triple
 ! HELP-NEXT: -print-target-triplePrint the normalized target triple
 ! HELP-NEXT: -P Disable linemarker output in -E mode
+! HELP-NEXT: -Rpass-analysis= Report transformation analysis from optimization passes whose name matches the given POSIX regular expression
+! HELP-NEXT: -Rpass-missed=   Report missed transformations by optimization passes whose name matches the given POSIX regular expression
+! HELP-NEXT: -Rpass=  Report transformations performed by optimization passes whose name matches the given POSIX regular expression
+! HELP-NEXT: -R  Enable the specified remark
 ! HELP-NEXT: -save-temps=Save intermediate compilation results.
 ! HELP-NEXT: -save-tempsSave intermediate compilation results
 ! HELP-NEXT: -std=   Language standard to compile for
@@ -206,6 +210,10 @@
 ! HELP-FC1-NEXT: -pic-level   Value for __PIC__
 ! HELP-FC1-NEXT: -plugin  Use the named plugin action instead of the default action (use "help" to list available options)
 ! HELP-FC1-NEXT: -P Disable linemarker output in -E mode
+! HELP-FC1-NEXT: -Rpass-analysis= Report transformation analysis from optimization passes whose name matches the given POSIX regular expression
+! HELP-FC1-NEXT: -Rpass-missed=   Report missed transformations by optimization passes whose name matches the given POSIX regular expression
+! HELP-FC1-NEXT: -Rpass=  Report transformations performed by optimization passes whose name matches the given POSIX regular expression
+! HELP-FC1-NEXT: -R  Enable the specified remark
 ! HELP-FC1-NEXT: -save-temps=Save intermediate compilation results.
 ! HELP-FC1-NEXT: -save-tempsSave intermediate compilation results
 ! HELP-FC1-NEXT: -std=   Language standard to compile for
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driv

[PATCH] D156794: [clang][Interp] Lazily visit unknown global declarations

2023-08-03 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:2172-2173
 
+  // Lazily visit global declarations we haven't seen yet.
+  // This happens in C.
+  if (const auto *VD = dyn_cast(D);

aaron.ballman wrote:
> Do we want to assert/limit this functionality to C instead of doing it in 
> both C and C++?
I never know how to do something for just C. I know there's stuff in `LangOpts` 
for C++, but no `LangOpts::C`?


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

https://reviews.llvm.org/D156794

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


[PATCH] D156993: [clang] Error on substitution failure within lambda body inside a requires-expression

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

Thanks for the PR!

Can you add a test in `dr26xx` ?

Also, i think the intent is that only the body is in the immediate context.

maybe we need a test like

  cpp 
  requires {   
 decltype([] -> T {})::foo();
  }

Because I think the intent is for that to work (@rsmith?)




Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:1100-1102
   // A lambda-expression appearing in a function type or a template
   // parameter is not considered part of the immediate context for the
   // purposes of template argument deduction.

Can you also add
// CWG2672: A lambda-expression body is never in the immediate context ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156993

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


[PATCH] D156993: [clang] Error on substitution failure within lambda body inside a requires-expression

2023-08-03 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin requested changes to this revision.
cor3ntin added a comment.
This revision now requires changes to proceed.

Oups, I did not meant to accept that, sorry!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156993

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


[PATCH] D153954: [clang][analyzer] Fix empty enum handling in EnumCastOutOfRange checker

2023-08-03 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.

LGTM




Comment at: clang/test/Analysis/enum-cast-out-of-range.cpp:203
+
+enum class empty_unfixed {};
+

donat.nagy wrote:
> Consider using "specified" and "unspecified" instead of "fixed" and 
> "unfixed", because the rest of the test file uses them and in my opinion 
> "unfixed" looks strange in this context.  (I know that e.g. 
> https://en.cppreference.com/w/cpp/language/enum speaks about "fixed" 
> underlying context, but it doesn't use "unfixed".) 
How about calling it "plain" or "common"?



Comment at: clang/test/Analysis/enum-cast-out-of-range.cpp:212-214
+  empty_unfixed eu = static_cast(0); //should always be OK to 
zero initialize any enum
+  empty_fixed ef = static_cast(0);
+  empty_fixed_unsigned efu = static_cast(0);




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153954

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


[PATCH] D156312: [analyzer] Upstream BitwiseShiftChecker

2023-08-03 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/docs/analyzer/checkers.rst:35
+core.BitwiseShift (C, C++)
+"""
+





Comment at: clang/docs/analyzer/checkers.rst:44-50
+Moreover, if the pedantic mode is activated by
+``-analyzer-config core.BitwiseShift:Pedantic=true``, then this checker also
+reports situations where the _left_ operand of a shift operator is negative or
+overflow occurs during the right shift of a signed value. (Most compilers
+handle these predictably, but the C standard and the C++ standards before C++20
+say that they're undefined behavior. In the C++20 standard these constructs are
+well-defined, so activating pedantic mode in C++20 has no effect.)

I believe shifting out the "sign bit" is UB because the representation of the 
signed integer type was not defined.
Prior C++20 (?), it was allowed to represent signed integer types as 
`two's-complement` (virtually every platform uses this), `one's complement`, 
`sign-magnitude`. [[ 
https://en.wikipedia.org/wiki/Signed_number_representations | Wiki ]].
And it turns out, all these three representations behave differently with 
negative values.
Check out [[ https://youtu.be/JhUxIVf1qok?t=2089 | JF's talk ]] from 2018 about 
this.

I'd need to think about the relevance of C++20 in this context, but here is 
what I think of now:
My idea is that the observed behavior is not influenced by the "standard", 
rather by the time we released C++20, they realized that no actual platform 
uses weird signed integer representations.
Given this observation, I'd argue that we shouldn't have this flag at all.



Comment at: clang/docs/analyzer/checkers.rst:81
+
+Ensure the shift operands are in proper range before shifting.
+

We should exactly elaborate on what "proper" means here.



Comment at: clang/lib/StaticAnalyzer/Checkers/BitwiseShiftChecker.cpp:142
+  BinaryOperator::Opcode 
Comparison,
+  long long Limit) {
+  SValBuilder &SVB = Ctx.getSValBuilder();

One does not frequently see the `long long` type.
Do you have a specific reason why `int` or `unsigned` wouldn't be good?



Comment at: clang/lib/StaticAnalyzer/Checkers/BitwiseShiftChecker.cpp:150
+  SVB.evalBinOp(State, Comparison, Val, LimitVal, SVB.getConditionType());
+  if (auto DURes = ResultVal.getAs()) {
+auto [StTrue, StFalse] = State->assume(DURes.value());

How about swapping these branches on the `ResultVal.isUndef()` predicate?



Comment at: clang/lib/StaticAnalyzer/Checkers/BitwiseShiftChecker.cpp:152-156
+if (!StTrue) {
+  // We detected undefined behavior (the caller will report it).
+  State = StFalse;
+  return false;
+}

Generally, I don't favor mutating member functions.
It makes it harder to track how we ended up with a given State.




Comment at: clang/lib/StaticAnalyzer/Checkers/BitwiseShiftChecker.cpp:157-158
+}
+// The code may be valid, so let's assume that it's valid:
+State = StTrue;
+if (StFalse) {

I wonder if we should add a message here that we introduced a new constraint: 
"X assumed to be non-negative".
To add such a message, you should do something similar to what is done in the 
`StdLibraryFunctionsChecker`.
Take the `C.getPredecessor()` and chain all your NoteTags by calling the `Pred 
= C.addTransition(NewState, Pred, Tag)` like this. This way. This is how one 
"sequence of ExplodedNodes" can be made.



Comment at: clang/test/Analysis/analyzer-config.c:36
 // CHECK-NEXT: cfg-temporary-dtors = true
+// CHECK-NEXT: consider-single-element-arrays-as-flexible-array-members = true
+// CHECK-NEXT: core.BitwiseShift:Pedantic = false

I'm pretty sure I got rid of this one :D
Consider rebasing on top of `llvm/main`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156312

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


[PATCH] D153954: [clang][analyzer] Fix empty enum handling in EnumCastOutOfRange checker

2023-08-03 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy added inline comments.



Comment at: clang/test/Analysis/enum-cast-out-of-range.cpp:203
+
+enum class empty_unfixed {};
+

steakhal wrote:
> donat.nagy wrote:
> > Consider using "specified" and "unspecified" instead of "fixed" and 
> > "unfixed", because the rest of the test file uses them and in my opinion 
> > "unfixed" looks strange in this context.  (I know that e.g. 
> > https://en.cppreference.com/w/cpp/language/enum speaks about "fixed" 
> > underlying context, but it doesn't use "unfixed".) 
> How about calling it "plain" or "common"?
"plain" is also a good alternative for "unfixed" (although it would still be 
inconsistent with the earlier cases); but "common" is confusing, because in 
addition to the "plain, regular, normal" meaning it can also mean "mutual; 
shared by more than one ".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153954

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


[PATCH] D156794: [clang][Interp] Lazily visit unknown global declarations

2023-08-03 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:2172-2173
 
+  // Lazily visit global declarations we haven't seen yet.
+  // This happens in C.
+  if (const auto *VD = dyn_cast(D);

tbaeder wrote:
> aaron.ballman wrote:
> > Do we want to assert/limit this functionality to C instead of doing it in 
> > both C and C++?
> I never know how to do something for just C. I know there's stuff in 
> `LangOpts` for C++, but no `LangOpts::C`?
`!LangOpts.CPlusPlus` afaik


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

https://reviews.llvm.org/D156794

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


[clang] a093598 - Revert "Fix __cfi_check not aligned to 4k on relocatable files with no executable code"

2023-08-03 Thread Yi Kong via cfe-commits

Author: Yi Kong
Date: 2023-08-03T22:03:43+09:00
New Revision: a093598e50e7b252205f1164751ac9c74874e254

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

LOG: Revert "Fix __cfi_check not aligned to 4k on relocatable files with no 
executable code"

This reverts commit c7cacb2f6efe07fa4a1129bb7e2389312670b84a.

Broken tests.

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp

Removed: 
clang/test/CodeGen/cfi-cross-dso-align.c



diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 15aa1b730d268b..ed6095f7cfeb0d 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3445,12 +3445,14 @@ void CodeGenFunction::EmitCfiCheckStub() {
   llvm::Function *F = llvm::Function::Create(
   llvm::FunctionType::get(VoidTy, {Int64Ty, Int8PtrTy, Int8PtrTy}, false),
   llvm::GlobalValue::WeakAnyLinkage, "__cfi_check", M);
-  F->setAlignment(llvm::Align(4096));
   CGM.setDSOLocal(F);
   llvm::BasicBlock *BB = llvm::BasicBlock::Create(Ctx, "entry", F);
-  // CrossDSOCFI pass is not executed if there is no executable code.
-  SmallVector Args{F->getArg(2), F->getArg(1)};
-  llvm::CallInst::Create(M->getFunction("__cfi_check_fail"), Args, "", BB);
+  // FIXME: consider emitting an intrinsic call like
+  // call void @llvm.cfi_check(i64 %0, i8* %1, i8* %2)
+  // which can be lowered in CrossDSOCFI pass to the actual contents of
+  // __cfi_check. This would allow inlining of __cfi_check calls.
+  llvm::CallInst::Create(
+  llvm::Intrinsic::getDeclaration(M, llvm::Intrinsic::trap), "", BB);
   llvm::ReturnInst::Create(Ctx, nullptr, BB);
 }
 
@@ -3544,6 +3546,9 @@ void CodeGenFunction::EmitCfiCheckFail() {
   }
 
   FinishFunction();
+  // The only reference to this function will be created during LTO link.
+  // Make sure it survives until then.
+  CGM.addUsedGlobal(F);
 }
 
 void CodeGenFunction::EmitUnreachable(SourceLocation Loc) {

diff  --git a/clang/test/CodeGen/cfi-cross-dso-align.c 
b/clang/test/CodeGen/cfi-cross-dso-align.c
deleted file mode 100644
index e023601184fe99..00
--- a/clang/test/CodeGen/cfi-cross-dso-align.c
+++ /dev/null
@@ -1,8 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \
-// RUN: -emit-llvm -o - %s | FileCheck %s
-
-int a;
-
-// CHECK: define weak void @__cfi_check(i64 %[[TYPE:.*]], ptr %[[ADDR:.*]], 
ptr %[[DATA:.*]]) align 4096
-// CHECK-NEXT: entry:
-// CHECK-NEXT: call void @__cfi_check_fail(ptr %[[DATA]], ptr %[[ADDR]])



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


[PATCH] D156312: [analyzer] Upstream BitwiseShiftChecker

2023-08-03 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy marked an inline comment as done.
donat.nagy added a comment.

@steakhal  Thanks for the review!

I answered some of your questions; and I'll handle the rest soon.




Comment at: clang/lib/StaticAnalyzer/Checkers/BitwiseShiftChecker.cpp:150
+  SVB.evalBinOp(State, Comparison, Val, LimitVal, SVB.getConditionType());
+  if (auto DURes = ResultVal.getAs()) {
+auto [StTrue, StFalse] = State->assume(DURes.value());

steakhal wrote:
> How about swapping these branches on the `ResultVal.isUndef()` predicate?
The argument of `ProgramState::assume()` must be a `DefinedOrUnknownSVal`, so I 
need to cast the return value of `evalBinOp` (which may be Undefined) to this 
type.



Comment at: clang/lib/StaticAnalyzer/Checkers/BitwiseShiftChecker.cpp:157-158
+}
+// The code may be valid, so let's assume that it's valid:
+State = StTrue;
+if (StFalse) {

steakhal wrote:
> I wonder if we should add a message here that we introduced a new constraint: 
> "X assumed to be non-negative".
> To add such a message, you should do something similar to what is done in the 
> `StdLibraryFunctionsChecker`.
> Take the `C.getPredecessor()` and chain all your NoteTags by calling the 
> `Pred = C.addTransition(NewState, Pred, Tag)` like this. This way. This is 
> how one "sequence of ExplodedNodes" can be made.
This is already done by `BitwiseShiftValidator::createNoteTag()`. It's a bit 
complex because the checker merges all its assumptions into a single note tag 
(because I didn't want to emit two or three notes directly after each other.



Comment at: clang/test/Analysis/analyzer-config.c:36
 // CHECK-NEXT: cfg-temporary-dtors = true
+// CHECK-NEXT: consider-single-element-arrays-as-flexible-array-members = true
+// CHECK-NEXT: core.BitwiseShift:Pedantic = false

steakhal wrote:
> I'm pretty sure I got rid of this one :D
> Consider rebasing on top of `llvm/main`.
Oops, this might be an error introduced during a rebase... Thanks for catching 
it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156312

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


[PATCH] D156896: [NFC][clang] Fix static analyzer concerns

2023-08-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, though I find the whole `OwnsAction` business to be a code smell. I think 
it'd be somewhat involved trying to address that though, so these changes are 
reasonable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156896

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


[PATCH] D156975: [NFC][clang] Fix static analyzer concerns

2023-08-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156975

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


[PATCH] D156320: [FLang] Add support for Rpass flag

2023-08-03 Thread victorkingi via Phabricator via cfe-commits
victorkingi updated this revision to Diff 546826.
victorkingi added a comment.

added frontend forwarding test for Rpass flags


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156320

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/DiagnosticIDs.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/frontend-forwarding.f90
  flang/test/Driver/optimization-remark.f90
  flang/tools/flang-driver/driver.cpp

Index: flang/tools/flang-driver/driver.cpp
===
--- flang/tools/flang-driver/driver.cpp
+++ flang/tools/flang-driver/driver.cpp
@@ -30,6 +30,7 @@
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Host.h"
+#include 
 #include 
 
 using llvm::StringRef;
Index: flang/test/Driver/optimization-remark.f90
===
--- /dev/null
+++ flang/test/Driver/optimization-remark.f90
@@ -0,0 +1,35 @@
+! This file tests the -Rpass family of flags (-Rpass, -Rpass-missed
+! and -Rpass-analysis)
+! loop-delete isn't enabled at O0 so we use at least O1
+
+! Check that we can override -Rpass= with -Rno-pass.
+! RUN: %flang_fc1 %s -O1 -Rpass=loop-delete -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+! RUN: %flang_fc1 %s -O1 -Rpass=loop-delete -Rno-pass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS
+! RUN: %flang_fc1 %s -O1 -Rpass=loop-delete -Rno-everything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS
+! RUN: %flang_fc1 %s -O1 -Rpass=loop-delete -Rno-everything -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+
+! -Reverything implies -Rpass=.*.
+! RUN: %flang_fc1 %s -O1 -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+
+! -Rpass implies -Rpass=.*
+! RUN: %flang_fc1 %s -O1 -Rpass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+
+! Check full -Rpass message is emitted
+! RUN: %flang %s -O1 -Rpass=loop-delete 2>&1 | FileCheck %s
+
+
+! CHECK: remark: Loop deleted because it is invariant
+! CHECK-REMARKS: remark:
+! CHECK-NO-REMARKS-NOT: remark:
+
+
+program forttest
+implicit none
+real, dimension(1:50) :: aR1
+integer :: n
+
+do n = 1,50
+aR1(n) = n * 1
+end do
+
+end program forttest
Index: flang/test/Driver/frontend-forwarding.f90
===
--- flang/test/Driver/frontend-forwarding.f90
+++ flang/test/Driver/frontend-forwarding.f90
@@ -20,6 +20,13 @@
 ! RUN: -flang-experimental-hlfir \
 ! RUN: -mllvm -print-before-all \
 ! RUN: -save-temps=obj \
+! RUN: -Rpass \
+! RUN: -Rpass-missed \
+! RUN: -Rpass-analysis \
+! RUN: -Rno-pass \
+! RUN: -Reverything \
+! RUN: -Rno-everything \
+! RUN: -Rpass=inline \
 ! RUN: -P \
 ! RUN:   | FileCheck %s
 
@@ -40,5 +47,12 @@
 ! CHECK: "-fversion-loops-for-stride"
 ! CHECK: "-flang-experimental-polymorphism"
 ! CHECK: "-flang-experimental-hlfir"
+! CHECK: "-Rpass"
+! CHECK: "-Rpass-missed"
+! CHECK: "-Rpass-analysis"
+! CHECK: "-Rno-pass"
+! CHECK: "-Reverything"
+! CHECK: "-Rno-everything"
+! CHECK: "-Rpass=inline"
 ! CHECK: "-mllvm" "-print-before-all"
 ! CHECK: "-save-temps=obj"
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -87,6 +87,10 @@
 ! HELP-NEXT: -print-effective-triple Print the effective target triple
 ! HELP-NEXT: -print-target-triplePrint the normalized target triple
 ! HELP-NEXT: -P Disable linemarker output in -E mode
+! HELP-NEXT: -Rpass-analysis= Report transformation analysis from optimization passes whose name matches the given POSIX regular expression
+! HELP-NEXT: -Rpass-missed=   Report missed transformations by optimization passes whose name matches the given POSIX regular expression
+! HELP-NEXT: -Rpass=  Report transformations performed by optimization passes whose name matches the given POSIX regular expression
+! HELP-NEXT: -R  Enable the specified remark
 ! HELP-NEXT: -save-temps=Save intermediate compilation results.
 ! HELP-NEXT: -save-tempsSave intermediate compilation results
 ! HELP-NEXT: -std=   Language standard to compile for
@@ -206,6 +210,10 @@
 ! HELP-FC1-NEXT: -pic-level   Value for __PIC__
 ! HELP-FC1-NEXT: -plugin  Use the named plugin action instead of the default action (use "he

[PATCH] D156320: [FLang] Add support for Rpass flag

2023-08-03 Thread victorkingi via Phabricator via cfe-commits
victorkingi updated this revision to Diff 546831.
victorkingi added a comment.

removed unused header includes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156320

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/DiagnosticIDs.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/frontend-forwarding.f90
  flang/test/Driver/optimization-remark.f90

Index: flang/test/Driver/optimization-remark.f90
===
--- /dev/null
+++ flang/test/Driver/optimization-remark.f90
@@ -0,0 +1,35 @@
+! This file tests the -Rpass family of flags (-Rpass, -Rpass-missed
+! and -Rpass-analysis)
+! loop-delete isn't enabled at O0 so we use at least O1
+
+! Check that we can override -Rpass= with -Rno-pass.
+! RUN: %flang_fc1 %s -O1 -Rpass=loop-delete -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+! RUN: %flang_fc1 %s -O1 -Rpass=loop-delete -Rno-pass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS
+! RUN: %flang_fc1 %s -O1 -Rpass=loop-delete -Rno-everything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS
+! RUN: %flang_fc1 %s -O1 -Rpass=loop-delete -Rno-everything -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+
+! -Reverything implies -Rpass=.*.
+! RUN: %flang_fc1 %s -O1 -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+
+! -Rpass implies -Rpass=.*
+! RUN: %flang_fc1 %s -O1 -Rpass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+
+! Check full -Rpass message is emitted
+! RUN: %flang %s -O1 -Rpass=loop-delete 2>&1 | FileCheck %s
+
+
+! CHECK: remark: Loop deleted because it is invariant
+! CHECK-REMARKS: remark:
+! CHECK-NO-REMARKS-NOT: remark:
+
+
+program forttest
+implicit none
+real, dimension(1:50) :: aR1
+integer :: n
+
+do n = 1,50
+aR1(n) = n * 1
+end do
+
+end program forttest
Index: flang/test/Driver/frontend-forwarding.f90
===
--- flang/test/Driver/frontend-forwarding.f90
+++ flang/test/Driver/frontend-forwarding.f90
@@ -20,6 +20,13 @@
 ! RUN: -flang-experimental-hlfir \
 ! RUN: -mllvm -print-before-all \
 ! RUN: -save-temps=obj \
+! RUN: -Rpass \
+! RUN: -Rpass-missed \
+! RUN: -Rpass-analysis \
+! RUN: -Rno-pass \
+! RUN: -Reverything \
+! RUN: -Rno-everything \
+! RUN: -Rpass=inline \
 ! RUN: -P \
 ! RUN:   | FileCheck %s
 
@@ -40,5 +47,12 @@
 ! CHECK: "-fversion-loops-for-stride"
 ! CHECK: "-flang-experimental-polymorphism"
 ! CHECK: "-flang-experimental-hlfir"
+! CHECK: "-Rpass"
+! CHECK: "-Rpass-missed"
+! CHECK: "-Rpass-analysis"
+! CHECK: "-Rno-pass"
+! CHECK: "-Reverything"
+! CHECK: "-Rno-everything"
+! CHECK: "-Rpass=inline"
 ! CHECK: "-mllvm" "-print-before-all"
 ! CHECK: "-save-temps=obj"
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -87,6 +87,10 @@
 ! HELP-NEXT: -print-effective-triple Print the effective target triple
 ! HELP-NEXT: -print-target-triplePrint the normalized target triple
 ! HELP-NEXT: -P Disable linemarker output in -E mode
+! HELP-NEXT: -Rpass-analysis= Report transformation analysis from optimization passes whose name matches the given POSIX regular expression
+! HELP-NEXT: -Rpass-missed=   Report missed transformations by optimization passes whose name matches the given POSIX regular expression
+! HELP-NEXT: -Rpass=  Report transformations performed by optimization passes whose name matches the given POSIX regular expression
+! HELP-NEXT: -R  Enable the specified remark
 ! HELP-NEXT: -save-temps=Save intermediate compilation results.
 ! HELP-NEXT: -save-tempsSave intermediate compilation results
 ! HELP-NEXT: -std=   Language standard to compile for
@@ -206,6 +210,10 @@
 ! HELP-FC1-NEXT: -pic-level   Value for __PIC__
 ! HELP-FC1-NEXT: -plugin  Use the named plugin action instead of the default action (use "help" to list available options)
 ! HELP-FC1-NEXT: -P Disable linemarker output in -E mode
+! HELP-FC1-NEXT: -Rpass-analysis= Report transformation analysis from optimization passes whose name matches the given POSIX regular expression
+! HELP-FC1-NEXT: -Rpass-missed=   Report missed transformations by optimization passes whose name matches the given POSIX regular expression
+! HELP-FC1-NEXT: -Rpass=  R

[PATCH] D156993: [clang] Error on substitution failure within lambda body inside a requires-expression

2023-08-03 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 546837.
Fznamznon added a comment.

Rebase, apply feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156993

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/CXX/drs/dr26xx.cpp
  clang/test/SemaCXX/lambda-unevaluated.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -15839,7 +15839,7 @@
 https://cplusplus.github.io/CWG/issues/2672.html";>2672
 open
 Lambda body SFINAE is still required, contrary to intent and note
-Not resolved
+Clang 18
   
   
 https://cplusplus.github.io/CWG/issues/2673.html";>2673
Index: clang/test/SemaCXX/lambda-unevaluated.cpp
===
--- clang/test/SemaCXX/lambda-unevaluated.cpp
+++ clang/test/SemaCXX/lambda-unevaluated.cpp
@@ -155,17 +155,24 @@
 
 template 
 concept lambda_works = requires {
-[]() { T::foo(); };
+[]() { T::foo(); }; // expected-error{{type 'int' cannot be used prior to '::'}}
+// expected-note@-1{{while substituting into a lambda expression here}}
+// expected-note@-2{{in instantiation of requirement here}}
+// expected-note@-4{{while substituting template arguments into constraint expression here}}
 };
 
-static_assert(!lambda_works);
+static_assert(!lambda_works); // expected-note {{while checking the satisfaction of concept 'lambda_works' requested here}}
 static_assert(lambda_works);
 
 template 
-int* func(T) requires requires { []() { T::foo(); }; };
+int* func(T) requires requires { []() { T::foo(); }; }; // expected-error{{type 'int' cannot be used prior to '::'}}
+// expected-note@-1{{while substituting into a lambda expression here}}
+// expected-note@-2{{in instantiation of requirement here}}
+// expected-note@-3{{while substituting template arguments into constraint expression here}}
 double* func(...);
 
-static_assert(__is_same(decltype(func(0)), double*));
+static_assert(__is_same(decltype(func(0)), double*)); // expected-note {{while checking constraint satisfaction for template 'func' required here}}
+  // expected-note@-1 {{in instantiation of function template specialization 'lambda_in_constraints::func'}}
 static_assert(__is_same(decltype(func(WithFoo())), int*));
 
 template 
Index: clang/test/CXX/drs/dr26xx.cpp
===
--- clang/test/CXX/drs/dr26xx.cpp
+++ clang/test/CXX/drs/dr26xx.cpp
@@ -150,3 +150,24 @@
 
 J j = { "ghi" };  // expected-error {{no viable constructor or deduction guide}}
 }
+
+namespace dr2672 { // dr2672: 18 open
+template 
+void f(T) requires requires { []() { T::invalid; } (); }; // expected-error{{type 'int' cannot be used prior to '::'}}
+  // expected-note@-1{{while substituting into a lambda expression here}}
+  // expected-note@-2{{in instantiation of requirement here}}
+  // expected-note@-3{{while substituting template arguments into constraint expression here}}
+void f(...);
+
+template 
+void bar(T) requires requires {
+   decltype([]() -> T {})::foo();
+};
+void bar(...);
+
+void m() {
+  f(0); // expected-note {{while checking constraint satisfaction for template 'f' required here}}
+// expected-note@-1 {{in instantiation of function template specialization}}
+  bar(0);
+}
+}
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1074,7 +1074,6 @@
   if (InNonInstantiationSFINAEContext)
 return std::optional(nullptr);
 
-  bool SawLambdaSubstitution = false;
   for (SmallVectorImpl::const_reverse_iterator
  Active = CodeSynthesisContexts.rbegin(),
  ActiveEnd = CodeSynthesisContexts.rend();
@@ -1101,10 +1100,8 @@
   // A lambda-expression appearing in a function type or a template
   // parameter is not considered part of the immediate context for the
   // purposes of template argument deduction.
-
-  // We need to check parents.
-  SawLambdaSubstitution = true;
-  break;
+  // CWG2672: A lambda-expression body is never in the immediate context.
+  return std::nullopt;
 
 case CodeSynthesisContext::DefaultTemplateArgumentInstantiation:
 case CodeSynthesisC

[PATCH] D156993: [clang] Error on substitution failure within lambda body inside a requires-expression

2023-08-03 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added a comment.

> Can you add a test in dr26xx ?

Sure, done. Hope I updated cxx_dr_status in the right way. The script wasn't 
happy until I added "open" to the test comment.

> maybe we need a test like Because I think the intent is for that to work

Seems to be working if I got it right.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156993

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


[PATCH] D155610: [Clang][Sema] Fix display of characters on static assertion failure

2023-08-03 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 546832.
hazohelet marked 2 inline comments as done.
hazohelet retitled this revision from "[Clang][ExprConstant] Print integer 
instead of character on static assertion failure" to "[Clang][Sema] Fix display 
of characters on static assertion failure".
hazohelet edited the summary of this revision.
hazohelet added a comment.

Address comments from Corentin

- Remove printing of character type prefix
- Added code example in release note
- Removed unnecessary static_cast


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

https://reviews.llvm.org/D155610

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/Lexer/cxx1z-trigraphs.cpp
  clang/test/SemaCXX/static-assert-cxx26.cpp
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -262,7 +262,29 @@
 return 'c';
   }
   static_assert(getChar() == 'a', ""); // expected-error {{failed}} \
-   // expected-note {{evaluates to ''c' == 'a''}}
+   // expected-note {{evaluates to ''c' (99) == 'a' (97)'}}
+  static_assert((char)9 == '\x61', ""); // expected-error {{failed}} \
+// expected-note {{evaluates to ''\t' (9) == 'a' (97)'}}
+  static_assert((char)10 == '\0', ""); // expected-error {{failed}} \
+   // expected-note {{n' (10) == '' (0)'}}
+  // The note above is intended to match "evaluates to '\n' (10) == '' (0)'", but if we write it as it is,
+  // the "\n" cannot be consumed by the diagnostic consumer.
+  static_assert((signed char)10 == (char)-123, ""); // expected-error {{failed}} \
+// expected-note {{evaluates to '10 == '<85>' (-123)'}}
+  static_assert((char)-4 == (unsigned char)-8, ""); // expected-error {{failed}} \
+// expected-note {{evaluates to ''' (-4) == 248'}}
+  static_assert((char)-128 == (char)-123, ""); // expected-error {{failed}} \
+   // expected-note {{evaluates to ''<80>' (-128) == '<85>' (-123)'}}
+  static_assert('\xA0' == (char)'\x20', ""); // expected-error {{failed}} \
+ // expected-note {{evaluates to ''' (-96) == ' ' (32)'}}
+static_assert((char16_t)L'ゆ' == L"C̵̭̯̠̎͌ͅť̺"[1], ""); // expected-error {{failed}} \
+// expected-note {{evaluates to ''ゆ' (12422) == '̵' (821)'}}
+static_assert(L"\/"[1] == u'\xFFFD', ""); // expected-error {{failed}} \
+   // expected-note {{evaluates to ''/' (65295) == '�' (65533)'}}
+static_assert(L"⚾"[0] == U'🌍', ""); // expected-error {{failed}} \
+   // expected-note {{evaluates to ''⚾' (9918) == '🌍' (127757)'}}
+static_assert(U"\a"[0] == (wchar_t)9, ""); // expected-error {{failed}} \
+   // expected-note {{evaluates to ''\a' (7) == '\t' (9)'}}
 
   /// Bools are printed as bools.
   constexpr bool invert(bool b) {
Index: clang/test/SemaCXX/static-assert-cxx26.cpp
===
--- clang/test/SemaCXX/static-assert-cxx26.cpp
+++ clang/test/SemaCXX/static-assert-cxx26.cpp
@@ -298,3 +298,12 @@
 Bad b; // expected-note {{in instantiation}}
 
 }
+
+namespace EscapeInDiagnostic {
+static_assert('\u{9}' == (char)1, ""); // expected-error {{failed}} \
+   // expected-note {{evaluates to ''\t' (9) == '' (1)'}}
+static_assert((char8_t)-128 == (char8_t)-123, ""); // expected-error {{failed}} \
+   // expected-note {{evaluates to ''<80>' (128) == '<85>' (133)'}}
+static_assert((char16_t)0xFEFF == (char16_t)0xDB93, ""); // expected-error {{failed}} \
+ // expected-note {{evaluates to ''' (65279) == '\xDB93' (56211)'}}
+}
Index: clang/test/Lexer/cxx1z-trigraphs.cpp
===
--- clang/test/Lexer/cxx1z-trigraphs.cpp
+++ clang/test/Lexer/cxx1z-trigraphs.cpp
@@ -21,7 +21,7 @@
 
 #if !ENABLED_TRIGRAPHS
 // expected-error@11 {{}} expected-warning@11 {{trigraph ignored}}
-// expected-error@13 {{failed}} expected-warning@13 {{trigraph ignored}} expected-note@13 {{evaluates to ''?' == '#''}}
+// expected-error@13 {{failed}} expected-warning@13 {{trigraph ignored}} expected-note@13 {{evaluates to ''?' (63) == '#' (35)'}}
 // expected-error@16 {{}}
 // expected-error@20 {{}}
 #else
Index: clang/lib/Sema/SemaDeclCXX.cpp

[PATCH] D156866: [Clang][LoongArch] Use the ClangBuiltin class to automatically generate support for CBE and CFE

2023-08-03 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added a comment.

LGTM except a nit.




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:20447
-
-Value *CodeGenFunction::EmitLoongArchBuiltinExpr(unsigned BuiltinID,
- const CallExpr *E) {

The declaration in `clang/lib/CodeGen/CodeGenFunction.h` should also be deleted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156866

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


[PATCH] D156234: [clang][deps] add support for dependency scanning with cc1 command line

2023-08-03 Thread Connor Sughrue via Phabricator via cfe-commits
cpsughrue updated this revision to Diff 546861.
cpsughrue added a comment.

Fixing failed test on Windows CI


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

https://reviews.llvm.org/D156234

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/modules-cc1.cpp

Index: clang/test/ClangScanDeps/modules-cc1.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-cc1.cpp
@@ -0,0 +1,29 @@
+// Check that clang-scan-deps works with cc1 command lines
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+
+//--- modules_cc1.cpp
+#include "header.h"
+
+//--- header.h
+
+//--- module.modulemap
+module header1 { header "header.h" }
+
+//--- cdb.json.template
+[{
+  "file": "DIR/modules_cc1.cpp",
+  "directory": "DIR",
+  "command": "clang -cc1 DIR/modules_cc1.cpp -fimplicit-module-maps -o modules_cc1.o"
+}]
+
+// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -j 1 -mode preprocess-dependency-directives > %t/result
+// RUN: cat %t/result | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t
+
+// CHECK: modules_cc1.o:
+// CHECK-NEXT: [[PREFIX]]/modules_cc1.cpp
+// CHECK-NEXT: [[PREFIX]]/module.modulemap
+// CHECK-NEXT: [[PREFIX]]/header.h
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -385,6 +385,9 @@
   if (!Compilation)
 return false;
 
+  if (Compilation->containsError())
+return false;
+
   for (const driver::Command &Job : Compilation->getJobs()) {
 if (!Callback(Job))
   return false;
@@ -392,6 +395,26 @@
   return true;
 }
 
+static bool createAndRunToolInvocation(
+std::vector CommandLine, DependencyScanningAction &Action,
+FileManager &FM,
+std::shared_ptr &PCHContainerOps,
+DiagnosticsEngine &Diags, DependencyConsumer &Consumer) {
+
+  // Save executable path before providing CommandLine to ToolInvocation
+  std::string Executable = CommandLine[0];
+  ToolInvocation Invocation(std::move(CommandLine), &Action, &FM,
+PCHContainerOps);
+  Invocation.setDiagnosticConsumer(Diags.getClient());
+  Invocation.setDiagnosticOptions(&Diags.getDiagnosticOptions());
+  if (!Invocation.run())
+return false;
+
+  std::vector Args = Action.takeLastCC1Arguments();
+  Consumer.handleBuildCommand({std::move(Executable), std::move(Args)});
+  return true;
+}
+
 bool DependencyScanningWorker::computeDependencies(
 StringRef WorkingDirectory, const std::vector &CommandLine,
 DependencyConsumer &Consumer, DependencyActionController &Controller,
@@ -454,37 +477,37 @@
   DependencyScanningAction Action(WorkingDirectory, Consumer, Controller, DepFS,
   Format, OptimizeArgs, EagerLoadModules,
   DisableFree, ModuleName);
-  bool Success = forEachDriverJob(
-  FinalCommandLine, *Diags, *FileMgr, [&](const driver::Command &Cmd) {
-if (StringRef(Cmd.getCreator().getName()) != "clang") {
-  // Non-clang command. Just pass through to the dependency
-  // consumer.
-  Consumer.handleBuildCommand(
-  {Cmd.getExecutable(),
-   {Cmd.getArguments().begin(), Cmd.getArguments().end()}});
-  return true;
-}
-
-std::vector Argv;
-Argv.push_back(Cmd.getExecutable());
-Argv.insert(Argv.end(), Cmd.getArguments().begin(),
-Cmd.getArguments().end());
-
-// Create an invocation that uses the underlying file
-// system to ensure that any file system requests that
-// are made by the driver do not go through the
-// dependency scanning filesystem.
-ToolInvocation Invocation(std::move(Argv), &Action, &*FileMgr,
-  PCHContainerOps);
-Invocation.setDiagnosticConsumer(Diags->getClient());
-Invocation.setDiagnosticOptions(&Diags->getDiagnosticOptions());
-if (!Invocation.run())
-  return false;
-
-std::vector Args = Action.takeLastCC1Arguments();
-Consumer.handleBuildCommand({Cmd.getExecutable(), std::move(Args)});
-return true;
-  });
+
+  bool Success = false;
+  if (FinalCommandLine[1] == "-cc1") {
+Success = createAndRunToolInvocation(FinalCommandLine, Action, *FileMgr,
+ PCHContainerOps, *Diags, Consumer);
+  } else {
+Success = forEachDriverJob(
+FinalCommandLine, *Diags, *FileMgr, [&](const driver::Command &Cmd) {
+  if (StringRef(Cmd.getCreator().getName()) != "clang") {
+// Non-clang command. Just pass through to the dependency
+// consumer.
+Consum

[PATCH] D142660: [AIX] supporting -X options for llvm-ranlib in AIX OS

2023-08-03 Thread Digger Lin via Phabricator via cfe-commits
DiggerLin updated this revision to Diff 546867.
DiggerLin marked 2 inline comments as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142660

Files:
  clang/lib/Driver/OffloadBundler.cpp
  clang/test/lit.cfg.py
  clang/tools/clang-offload-packager/ClangOffloadPackager.cpp
  llvm/include/llvm/Object/Archive.h
  llvm/include/llvm/Object/ArchiveWriter.h
  llvm/lib/ObjCopy/Archive.cpp
  llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
  llvm/lib/Object/Archive.cpp
  llvm/lib/Object/ArchiveWriter.cpp
  llvm/lib/Object/COFFImportFile.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/test/tools/llvm-ranlib/AIX-X-option-non-AIX.test
  llvm/test/tools/llvm-ranlib/aix-X-option.test
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp

Index: llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
===
--- llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
+++ llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
@@ -600,18 +600,17 @@
 
   if (NewMembers.size() == 1)
 return writeArchive(OutputFile, NewMembers.begin()->second.getMembers(),
-/*WriteSymtab=*/true,
+SymtabWritingMode::NormalSymtab,
 /*Kind=*/object::Archive::K_DARWIN, C.Deterministic,
 /*Thin=*/false);
 
   SmallVector, 2> OutputBinaries;
   for (const std::pair &M : NewMembers) {
 Expected> OutputBufferOrErr =
-writeArchiveToBuffer(M.second.getMembers(),
- /*WriteSymtab=*/true,
- /*Kind=*/object::Archive::K_DARWIN,
- C.Deterministic,
- /*Thin=*/false);
+writeArchiveToBuffer(
+M.second.getMembers(), SymtabWritingMode::NormalSymtab,
+/*Kind=*/object::Archive::K_DARWIN, C.Deterministic,
+/*Thin=*/false);
 if (!OutputBufferOrErr)
   return OutputBufferOrErr.takeError();
 std::unique_ptr &OutputBuffer = OutputBufferOrErr.get();
Index: llvm/tools/llvm-ar/llvm-ar.cpp
===
--- llvm/tools/llvm-ar/llvm-ar.cpp
+++ llvm/tools/llvm-ar/llvm-ar.cpp
@@ -69,7 +69,9 @@
  << "  -v --version  - Display the version of this program\n"
  << "  -D- Use zero for timestamps and uids/gids "
 "(default)\n"
- << "  -U- Use actual timestamps and uids/gids\n";
+ << "  -U- Use actual timestamps and uids/gids\n"
+ << "  -X{32|64|32_64|any}   - Specify which archive symbol tables "
+"should be generated if they do not already exist (AIX OS only)\n";
 }
 
 static void printArHelp(StringRef ToolName) {
@@ -225,7 +227,8 @@
 static bool CompareFullPath = false;  ///< 'P' modifier
 static bool OnlyUpdate = false;   ///< 'u' modifier
 static bool Verbose = false;  ///< 'v' modifier
-static bool Symtab = true;///< 's' modifier
+static SymtabWritingMode Symtab =
+SymtabWritingMode::NormalSymtab;  ///< 's' modifier
 static bool Deterministic = true; ///< 'D' and 'U' modifiers
 static bool Thin = false; ///< 'T' modifier
 static bool AddLibrary = false;   ///< 'L' modifier
@@ -371,11 +374,11 @@
   CompareFullPath = true;
   break;
 case 's':
-  Symtab = true;
+  Symtab = SymtabWritingMode::NormalSymtab;
   MaybeJustCreateSymTab = true;
   break;
 case 'S':
-  Symtab = false;
+  Symtab = SymtabWritingMode::NoSymtab;
   break;
 case 'u':
   OnlyUpdate = true;
@@ -1074,9 +1077,31 @@
   // In summary, we only need to update the symbol table if we have none.
   // This is actually very common because of broken build systems that think
   // they have to run ranlib.
-  if (OldArchive->hasSymbolTable())
-return;
+  if (OldArchive->hasSymbolTable()) {
+if (OldArchive->kind() != object::Archive::K_AIXBIG)
+  return;
 
+// For archives in the Big Archive format, the bit mode option specifies
+// which symbol table to generate. The presence of a symbol table that does
+// not match the specified bit mode does not prevent creation of the symbol
+// table that has been requested.
+if (OldArchive->kind() == object::Archive::K_AIXBIG) {
+  BigArchive *BigArc = dyn_cast(OldArchive);
+  if (BigArc->has32BitGlobalSymtab() &&
+  Symtab == SymtabWritingMode::BigArchive32)
+return;
+
+  if (BigArc->has64BitGlobalSymtab() &&
+  Symtab == SymtabWritingMode::BigArchive64)
+return;
+
+  if (BigArc->has32BitGlobalSymtab() && BigArc->has64BitGlobalSymtab() &&
+  Symtab == SymtabWritingMode::NormalSymtab)
+return;
+
+  Symtab = SymtabWritin

[PATCH] D154581: [clang][Interp] Track existing InitMaps in InterpState

2023-08-03 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 546872.
tbaeder added a comment.

1. Use  a `shared_ptr` for the initmaps.
2. However, we allocate them into the `Block`, therefore can't forget to call 
the Block's dtor.
3. To distinguish between Blocks we've already deallocated (via a `destroy` 
op), add an `IsInitialized` flag that we set in `invokeCtor` and unset in 
`invokeDtor`.


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

https://reviews.llvm.org/D154581

Files:
  clang/lib/AST/Interp/Descriptor.cpp
  clang/lib/AST/Interp/Descriptor.h
  clang/lib/AST/Interp/EvalEmitter.cpp
  clang/lib/AST/Interp/EvalEmitter.h
  clang/lib/AST/Interp/InterpBlock.h
  clang/lib/AST/Interp/InterpFrame.cpp
  clang/lib/AST/Interp/InterpState.cpp
  clang/lib/AST/Interp/Pointer.cpp
  clang/lib/AST/Interp/Pointer.h
  clang/test/AST/Interp/arrays.cpp
  clang/test/AST/Interp/literals.cpp

Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -1011,37 +1011,3 @@
   static_assert(heh(2) == 'h', "");
 #endif
 }
-
-namespace NE {
-  constexpr int foo() noexcept {
-return 1;
-  }
-  static_assert(noexcept(foo()), "");
-  constexpr int foo2() {
-return 1;
-  }
-  static_assert(!noexcept(foo2()), "");
-
-#if __cplusplus > 201402L
-  constexpr int a() {
-int b = 0;
-(void)noexcept(++b); // expected-warning {{expression with side effects has no effect in an unevaluated context}} \
- // ref-warning {{expression with side effects has no effect in an unevaluated context}}
-
-return b;
-  }
-  static_assert(a() == 0, "");
-#endif
-}
-
-namespace PointerCasts {
-  constexpr int M = 10;
-  constexpr const int *P = &M;
-  constexpr intptr_t A = (intptr_t)P; // ref-error {{must be initialized by a constant expression}} \
-  // ref-note {{cast that performs the conversions of a reinterpret_cast}} \
-  // expected-error {{must be initialized by a constant expression}} \
-  // expected-note {{cast that performs the conversions of a reinterpret_cast}}
-
-  int array[(intptr_t)(char*)0]; // ref-warning {{variable length array folded to constant array}} \
- // expected-warning {{variable length array folded to constant array}}
-}
Index: clang/test/AST/Interp/arrays.cpp
===
--- clang/test/AST/Interp/arrays.cpp
+++ clang/test/AST/Interp/arrays.cpp
@@ -350,3 +350,53 @@
   static_assert(b.f[0] == 0.0, "");
   static_assert(b.f[1] == 0.0, "");
 }
+
+namespace NoInitMapLeak {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdivision-by-zero"
+#pragma clang diagnostic ignored "-Wc++20-extensions"
+  constexpr int testLeak() { // expected-error {{never produces a constant expression}} \
+ // ref-error {{never produces a constant expression}}
+int a[2];
+a[0] = 1;
+// interrupts interpretation.
+(void)(1 / 0); // expected-note 2{{division by zero}} \
+   // ref-note 2{{division by zero}}
+
+
+return 1;
+  }
+#pragma clang diagnostic pop
+  static_assert(testLeak() == 1, ""); // expected-error {{not an integral constant expression}} \
+  // expected-note {{in call to 'testLeak()'}} \
+  // ref-error {{not an integral constant expression}} \
+  // ref-note {{in call to 'testLeak()'}}
+
+
+  constexpr int a[] = {1,2,3,4/0,5}; // expected-error {{must be initialized by a constant expression}} \
+ // expected-note {{division by zero}} \
+ // ref-error {{must be initialized by a constant expression}} \
+ // ref-note {{division by zero}} \
+ // ref-note {{declared here}}
+
+  /// FIXME: This should fail in the new interpreter as well.
+  constexpr int b = a[0]; // ref-error {{must be initialized by a constant expression}} \
+  // ref-note {{is not a constant expression}} \
+  // ref-note {{declared here}}
+  static_assert(b == 1, ""); // ref-error {{not an integral constant expression}} \
+ // ref-note {{not a constant expression}}
+
+  constexpr int f() { // expected-error {{never produces a constant expression}} \
+  // ref-error {{never produces a constant expression}}
+int a[] = {19,2,3/0,4}; // expected-note 2{{division by zero}} \
+// expected-warning {{is undefined}} \
+// ref-note 2{{division by zero}} \
+// ref-warning {{is undefined}}
+return 1;
+  }
+  

[PATCH] D154262: [clang][Interp] LambdaThisCaptures

2023-08-03 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154262

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


[PATCH] D156453: [clang][Interp] Create only globals when initializing a global variable

2023-08-03 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156453

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


[PATCH] D144457: [clang][Interp] Handle global composite temporaries

2023-08-03 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144457

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


[PATCH] D155387: [Clang] Fix member lookup so that we don't ignore ambiguous lookups in some cases

2023-08-03 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added a comment.

Hi folks,

I found an issue with building Android using this patch. I've reduced it down 
to the following problem where the evaluation of the `std::visit` is believed 
to be non-exhaustive, but it seems like it is? Would you mind taking a look? 
Admittedly, my knowledge in this area of the cxx stdlib is not so great.

Thanks.

  $ cat /tmp/variant.cpp
  #include 
  #include 
  
  struct A {};
  struct B {};
  
  using MyVariant = std::variant;
  
  // Helper to std::visit with lambdas.
  template 
  struct Visitor : V... {};
  // explicit deduction guide (not needed as of C++20)
  template 
  Visitor(V...) -> Visitor;
  
  const char* toString(const MyVariant& args) {
  Visitor toStringVisitor{
  [&](const A&) { return "A"; },
  [&](const B&) { return "B"; },
  };
  return std::visit(toStringVisitor, args);
  }



  $ ~/llvm-build/opt/bin/clang++ /tmp/variant.cpp -c -o /tmp/variant.o 
-std=c++17 -stdlib=libc++
  In file included from /tmp/variant.cpp:2:
  
/usr/local/google/home/mitchp/llvm-build/opt/bin/../include/c++/v1/variant:680:19:
 error: static assertion failed due to requirement 
'is_invocable_v &, const A &>': `std::visit` requires the visitor to 
be exhaustive.
680 | static_assert(is_invocable_v<_Visitor, _Values...>,
|   ^~~~
  
/usr/local/google/home/mitchp/llvm-build/opt/bin/../include/c++/v1/variant:689:7:
 note: in instantiation of function template specialization 
'std::__variant_detail::__visitation::__variant::__std_visit_exhaustive_visitor_check &, const A &>' 
requested here
689 |   __std_visit_exhaustive_visitor_check<
|   ^
  
/usr/local/google/home/mitchp/llvm-build/opt/bin/../include/c++/v1/__type_traits/invoke.h:337:10:
 note: in instantiation of function template specialization 
'std::__variant_detail::__visitation::__variant::__value_visitor 
&>::operator() &>' requested here
337 | decltype(std::declval<_Fp>()(std::declval<_Args>()...))
|  ^
  
/usr/local/google/home/mitchp/llvm-build/opt/bin/../include/c++/v1/variant:572:16:
 note: while substituting deduced template arguments into function template 
'__invoke' [with _Fp = 
std::__variant_detail::__visitation::__variant::__value_visitor &>, _Args = 
 &>]
572 | return _VSTD::__invoke(
|^
  
/usr/local/google/home/mitchp/llvm-build/opt/bin/../include/c++/v1/__config:805:17:
 note: expanded from macro '_VSTD'
805 | #  define _VSTD std
| ^
  
/usr/local/google/home/mitchp/llvm-build/opt/bin/../include/c++/v1/variant:581:43:
 note: in instantiation of function template specialization 
'std::__variant_detail::__visitation::__base::__dispatcher<0>::__dispatch &> &&, const 
std::__variant_detail::__base &>' requested here
581 | return __dispatcher<_Is...>::template __dispatch<_Fp, _Vs...>;
|   ^
  
/usr/local/google/home/mitchp/llvm-build/opt/bin/../include/c++/v1/variant:608:12:
 note: in instantiation of function template specialization 
'std::__variant_detail::__visitation::__base::__make_dispatch &> &&, const 
std::__variant_detail::__base &, 0UL>' requested here
608 | return __make_dispatch<_Fp, _Vs...>(__is);
|^
  
/usr/local/google/home/mitchp/llvm-build/opt/bin/../include/c++/v1/variant:616:34:
 note: (skipping 2 contexts in backtrace; use -ftemplate-backtrace-limit=0 to 
see all)
616 | return __base::__make_farray(__make_fmatrix_impl<_Fp, _Vs...>(
|  ^
  
/usr/local/google/home/mitchp/llvm-build/opt/bin/../include/c++/v1/variant:533:9:
 note: in instantiation of function template specialization 
'std::__variant_detail::__visitation::__base::__make_fmatrix &> &&, const 
std::__variant_detail::__base &>' requested here
533 | __make_fmatrix<_Visitor&&,
| ^
  
/usr/local/google/home/mitchp/llvm-build/opt/bin/../include/c++/v1/variant:642:20:
 note: in instantiation of function template specialization 
'std::__variant_detail::__visitation::__base::__visit_alt &>, const 
std::__variant_detail::__impl &>' requested here
642 | return __base::__visit_alt(
|^
  
/usr/local/google/home/mitchp/llvm-build/opt/bin/../include/c++/v1/variant:661:12:
 note: in instantiation of function template specialization 
'std::__variant_detail::__visitation::__variant::__visit_alt &>, const 
std::variant &>' requested here
661 | return __visit_alt(
|^
  
/usr/local/google/home/mitchp/llvm-build/opt/bin/../include/c++/v1/variant:1759:21:
 note: in instantiation of function template specialization 
'std::__variant_detail::__visitation::__variant::__visit_value &, const 
std::variant &>' requested here
   1759 |   return __variant::__visit_value(_VSTD::forward<_Visitor>(__visitor),
| ^

[PATCH] D157007: [clang][ExtractAPI] Add support for C++ classes with fix

2023-08-03 Thread Erick Velez via Phabricator via cfe-commits
evelez7 created this revision.
evelez7 added a reviewer: dang.
Herald added a reviewer: ributzka.
Herald added a subscriber: ChuanqiXu.
Herald added a project: All.
evelez7 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Reintroduce D153557  with fix for 
use-after-free from f4de606ef271 
 and minor 
changes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157007

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/DeclarationFragments.h
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/class.cpp
  clang/test/ExtractAPI/constructor_destructor.cpp
  clang/test/ExtractAPI/conversions.cpp
  clang/test/ExtractAPI/function_noexcepts.cpp
  clang/test/ExtractAPI/methods.cpp
  clang/test/ExtractAPI/multiple_inheritance.cpp
  clang/test/ExtractAPI/operator_overload.cpp
  clang/test/ExtractAPI/simple_inheritance.cpp

Index: clang/test/ExtractAPI/simple_inheritance.cpp
===
--- /dev/null
+++ clang/test/ExtractAPI/simple_inheritance.cpp
@@ -0,0 +1,162 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 -extract-api -triple arm64-apple-macosx \
+// RUN:   -x c++-header %t/input.h -o %t/output.json -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+//--- input.h
+class Foo {};
+
+class Bar : public Foo {};
+/// expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationships": [
+{
+  "kind": "inheritsFrom",
+  "source": "c:@S@Bar",
+  "target": "c:@S@Foo",
+  "targetFallback": "Foo"
+}
+  ],
+  "symbols": [
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "class"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Foo"
+},
+{
+  "kind": "text",
+  "spelling": ";"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c++",
+"precise": "c:@S@Foo"
+  },
+  "kind": {
+"displayName": "Class",
+"identifier": "c++.class"
+  },
+  "location": {
+"position": {
+  "character": 7,
+  "line": 1
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"title": "Foo"
+  },
+  "pathComponents": [
+"Foo"
+  ]
+},
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "class"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Bar"
+},
+{
+  "kind": "text",
+  "spelling": ";"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c++",
+"precise": "c:@S@Bar"
+  },
+  "kind": {
+"displayName": "Class",
+"identifier": "c++.class"
+  },
+  "location": {
+"position": {
+  "character": 7,
+  "line": 3
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "Bar"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Bar"
+  }
+],
+"title": "Bar"
+

[PATCH] D156172: [clang][CodeGen] Emit annotations for function declarations.

2023-08-03 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I'm happy with this approach.




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:4327
+if (D && D->hasAttr() && isa(Entry))
+  DeferredAnnotations[cast(Entry)] = cast(D);
+

This doesn't quite seem sufficient... I'd expect you'd want to update the map 
when you see a new declaration.  Otherwise we miss annotations on something 
like:

```
void foo(void);
void *xxx = (void*)foo;
void __attribute__((annotate("bar"))) foo();
```

Granted, I wouldn't expect this sort of construct to show up normally, and I'm 
not sure how hard this is to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156172

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


[PATCH] D157007: [clang][ExtractAPI] Add support for C++ classes with fix

2023-08-03 Thread Erick Velez via Phabricator via cfe-commits
evelez7 added inline comments.



Comment at: clang/lib/ExtractAPI/DeclarationFragments.cpp:612
+  if (isa(Method)) {
+Name = Method->getNameAsString();
+if (dyn_cast(Method)->isExplicit())

Minor change is here. Since `Name` is now an `std::string`, a cast to 
`Method`'s DeclContext is no longer needed to bypass the simple identifier 
assertion from `getName` for StringRefs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157007

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


[PATCH] D156794: [clang][Interp] Lazily visit unknown global declarations

2023-08-03 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 546882.

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

https://reviews.llvm.org/D156794

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/c.c


Index: clang/test/AST/Interp/c.c
===
--- clang/test/AST/Interp/c.c
+++ clang/test/AST/Interp/c.c
@@ -1,12 +1,23 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -pedantic 
-verify=pedantic-expected %s
 // RUN: %clang_cc1 -verify=ref %s
+// RUN: %clang_cc1 -pedantic -verify=pedantic-ref %s
 
 /// expected-no-diagnostics
-/// ref-no-diagnostics
 
 _Static_assert(1, "");
 _Static_assert(0 != 1, "");
-_Static_assert(1.0 == 1.0, "");
+_Static_assert(1.0 == 1.0, ""); // pedantic-ref-warning {{not an integer 
constant expression}} \
+// pedantic-expected-warning {{not an integer 
constant expression}}
 _Static_assert( (5 > 4) + (3 > 2) == 2, "");
 
+/// FIXME: Should also be rejected in the new interpreter
 int a = (1 == 1 ? 5 : 3);
+_Static_assert(a == 5, ""); // ref-error {{not an integral constant 
expression}} \
+// pedantic-ref-error {{not an integral constant 
expression}} \
+// pedantic-expected-warning {{not an integer 
constant expression}}
+
+const int b = 3;
+_Static_assert(b == 3, ""); // pedantic-ref-warning {{not an integer constant 
expression}} \
+// pedantic-expected-warning {{not an integer 
constant expression}}
+
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -2169,6 +2169,17 @@
 return this->emitGetPtrThisField(Offset, E);
   }
 
+  // Lazily visit global declarations we haven't seen yet.
+  // This happens in C.
+  if (!Ctx.getLangOpts().CPlusPlus) {
+if (const auto *VD = dyn_cast(D);
+VD && VD->hasGlobalStorage() && VD->getAnyInitializer()) {
+  if (!this->visitVarDecl(VD))
+return false;
+  // Retry.
+  return this->VisitDeclRefExpr(E);
+}
+  }
   return false;
 }
 


Index: clang/test/AST/Interp/c.c
===
--- clang/test/AST/Interp/c.c
+++ clang/test/AST/Interp/c.c
@@ -1,12 +1,23 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -pedantic -verify=pedantic-expected %s
 // RUN: %clang_cc1 -verify=ref %s
+// RUN: %clang_cc1 -pedantic -verify=pedantic-ref %s
 
 /// expected-no-diagnostics
-/// ref-no-diagnostics
 
 _Static_assert(1, "");
 _Static_assert(0 != 1, "");
-_Static_assert(1.0 == 1.0, "");
+_Static_assert(1.0 == 1.0, ""); // pedantic-ref-warning {{not an integer constant expression}} \
+// pedantic-expected-warning {{not an integer constant expression}}
 _Static_assert( (5 > 4) + (3 > 2) == 2, "");
 
+/// FIXME: Should also be rejected in the new interpreter
 int a = (1 == 1 ? 5 : 3);
+_Static_assert(a == 5, ""); // ref-error {{not an integral constant expression}} \
+// pedantic-ref-error {{not an integral constant expression}} \
+// pedantic-expected-warning {{not an integer constant expression}}
+
+const int b = 3;
+_Static_assert(b == 3, ""); // pedantic-ref-warning {{not an integer constant expression}} \
+// pedantic-expected-warning {{not an integer constant expression}}
+
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -2169,6 +2169,17 @@
 return this->emitGetPtrThisField(Offset, E);
   }
 
+  // Lazily visit global declarations we haven't seen yet.
+  // This happens in C.
+  if (!Ctx.getLangOpts().CPlusPlus) {
+if (const auto *VD = dyn_cast(D);
+VD && VD->hasGlobalStorage() && VD->getAnyInitializer()) {
+  if (!this->visitVarDecl(VD))
+return false;
+  // Retry.
+  return this->VisitDeclRefExpr(E);
+}
+  }
   return false;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156799: Update generic scheduling to use A510 scheduling model

2023-08-03 Thread harvin iriawan via Phabricator via cfe-commits
harviniriawan updated this revision to Diff 546884.
harviniriawan marked 23 inline comments as done.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156799

Files:
  clang/test/CodeGen/aarch64-ABI-align-packed-assembly.c
  llvm/lib/Target/AArch64/AArch64.td
  llvm/test/Analysis/CostModel/AArch64/vector-select.ll
  llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-lse2.ll
  llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-lse2_lse128.ll
  llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-outline_atomics.ll
  llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-rcpc.ll
  llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-rcpc3.ll
  llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-v8_1a.ll
  llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-v8a.ll
  llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomicrmw-lse2.ll
  llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomicrmw-lse2_lse128.ll
  llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomicrmw-outline_atomics.ll
  llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomicrmw-rcpc.ll
  llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomicrmw-rcpc3.ll
  llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomicrmw-v8_1a.ll
  llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomicrmw-v8a.ll
  llvm/test/CodeGen/AArch64/GlobalISel/aapcs_vararg_frame.ll
  llvm/test/CodeGen/AArch64/GlobalISel/arm64-atomic.ll
  llvm/test/CodeGen/AArch64/GlobalISel/arm64-pcsections.ll
  llvm/test/CodeGen/AArch64/GlobalISel/call-translator-variadic-musttail.ll
  llvm/test/CodeGen/AArch64/GlobalISel/combine-udiv.ll
  llvm/test/CodeGen/AArch64/GlobalISel/select-bitfield-insert.ll
  llvm/test/CodeGen/AArch64/GlobalISel/store-merging.ll
  llvm/test/CodeGen/AArch64/GlobalISel/swifterror.ll
  llvm/test/CodeGen/AArch64/a57-csel.ll
  llvm/test/CodeGen/AArch64/aarch64-addv.ll
  llvm/test/CodeGen/AArch64/aarch64-be-bv.ll
  llvm/test/CodeGen/AArch64/aarch64-bit-gen.ll
  llvm/test/CodeGen/AArch64/aarch64-combine-add-sub-mul.ll
  llvm/test/CodeGen/AArch64/aarch64-dup-ext-scalable.ll
  llvm/test/CodeGen/AArch64/aarch64-dup-ext.ll
  llvm/test/CodeGen/AArch64/aarch64-dynamic-stack-layout.ll
  llvm/test/CodeGen/AArch64/aarch64-fixup-statepoint-regs-crash.ll
  llvm/test/CodeGen/AArch64/aarch64-fold-lslfast.ll
  llvm/test/CodeGen/AArch64/aarch64-interleaved-access-w-undef.ll
  llvm/test/CodeGen/AArch64/aarch64-isel-csinc.ll
  llvm/test/CodeGen/AArch64/aarch64-load-ext.ll
  llvm/test/CodeGen/AArch64/aarch64-matrix-umull-smull.ll
  llvm/test/CodeGen/AArch64/aarch64-mops-consecutive.ll
  llvm/test/CodeGen/AArch64/aarch64-mops.ll
  llvm/test/CodeGen/AArch64/aarch64-mull-masks.ll
  llvm/test/CodeGen/AArch64/aarch64-neon-vector-insert-uaddlv.ll
  llvm/test/CodeGen/AArch64/aarch64-pmull2.ll
  llvm/test/CodeGen/AArch64/aarch64-smull.ll
  llvm/test/CodeGen/AArch64/aarch64-uzp1-combine.ll
  llvm/test/CodeGen/AArch64/aarch64-wide-mul.ll
  llvm/test/CodeGen/AArch64/aarch64_fnmadd.ll
  llvm/test/CodeGen/AArch64/aarch64_win64cc_vararg.ll
  llvm/test/CodeGen/AArch64/abd-combine.ll
  llvm/test/CodeGen/AArch64/active_lane_mask.ll
  llvm/test/CodeGen/AArch64/add-extract.ll
  llvm/test/CodeGen/AArch64/addcarry-crash.ll
  llvm/test/CodeGen/AArch64/addsub-constant-folding.ll
  llvm/test/CodeGen/AArch64/addsub.ll
  llvm/test/CodeGen/AArch64/align-down.ll
  llvm/test/CodeGen/AArch64/and-mask-removal.ll
  llvm/test/CodeGen/AArch64/andorbrcompare.ll
  llvm/test/CodeGen/AArch64/argument-blocks-array-of-struct.ll
  llvm/test/CodeGen/AArch64/arm64-AdvSIMD-Scalar.ll
  llvm/test/CodeGen/AArch64/arm64-addr-type-promotion.ll
  llvm/test/CodeGen/AArch64/arm64-addrmode.ll
  llvm/test/CodeGen/AArch64/arm64-bitfield-extract.ll
  llvm/test/CodeGen/AArch64/arm64-convert-v4f64.ll
  llvm/test/CodeGen/AArch64/arm64-cse.ll
  llvm/test/CodeGen/AArch64/arm64-csel.ll
  llvm/test/CodeGen/AArch64/arm64-fcopysign.ll
  llvm/test/CodeGen/AArch64/arm64-fmadd.ll
  llvm/test/CodeGen/AArch64/arm64-homogeneous-prolog-epilog-no-helper.ll
  llvm/test/CodeGen/AArch64/arm64-indexed-vector-ldst.ll
  llvm/test/CodeGen/AArch64/arm64-inline-asm.ll
  llvm/test/CodeGen/AArch64/arm64-instruction-mix-remarks.ll
  llvm/test/CodeGen/AArch64/arm64-ld1.ll
  llvm/test/CodeGen/AArch64/arm64-ldp.ll
  llvm/test/CodeGen/AArch64/arm64-misaligned-memcpy-inline.ll
  llvm/test/CodeGen/AArch64/arm64-mul.ll
  llvm/test/CodeGen/AArch64/arm64-neon-3vdiff.ll
  llvm/test/CodeGen/AArch64/arm64-neon-mul-div.ll
  llvm/test/CodeGen/AArch64/arm64-neon-v8.1a.ll
  llvm/test/CodeGen/AArch64/arm64-non-pow2-ldst.ll
  llvm/test/CodeGen/AArch64/arm64-nvcast.ll
  llvm/test/CodeGen/AArch64/arm64-promote-const-complex-initializers.ll
  llvm/test/CodeGen/AArch64/arm64-register-pairing.ll
  llvm/test/CodeGen/AArch64/arm64-rev.ll
  llvm/test/CodeGen/AArch64/arm64-setcc-int-to-fp-combine.ll
  llvm/test/CodeGen/AArch64/arm64-setcc-swap-infloop.ll
  llvm/test/CodeGen/AA

[PATCH] D156799: Update generic scheduling to use A510 scheduling model

2023-08-03 Thread harvin iriawan via Phabricator via cfe-commits
harviniriawan added inline comments.



Comment at: llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll:1
-; RUN: split-file %s %t
 ; RUN: cat %t/main.ll %t/a.ll > %t/a2.ll
 ; RUN: cat %t/main.ll %t/b.ll > %t/b2.ll

dmgreen wrote:
> Can you explain this one? Are the two versions now too different to keep the 
> same?
Yes indeed. the ones with CHECK-ADD annoyingly is scheduled slightly 
differently due to it being ADD instead of LDR


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156799

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


[PATCH] D140828: [C++] Implement "Deducing this" (P0847R7)

2023-08-03 Thread Hristo Hristov via Phabricator via cfe-commits
Zingam added a comment.

In D140828#4544438 , @cor3ntin wrote:

> In D140828#4544433 , @Zingam wrote:
>
>> Is this going to land soon? There is a libc++ paper I'm interested in that 
>> relies on "deducing this" and I wonder if I should wait for "this" first 
>> before I start working on it?
>
> Hard to tell. Maybe in the next few weeks depending on reviewers 
> availability. I'm curious, what paper is that?

Sounds great. Thank you. I've been eyeing at this paper - 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2637r3.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140828

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


[clang] f887cb1 - [NFC][clang] Fix static analyzer concerns

2023-08-03 Thread via cfe-commits

Author: Podchishchaeva, Mariya
Date: 2023-08-03T08:36:49-07:00
New Revision: f887cb10acc9fb21e389703062398adf1331232f

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

LOG: [NFC][clang] Fix static analyzer concerns

ToolInvocation frees resources in the destructor but doesn't
have user-written copy c'tor or assignment operator, so copying it using
default ones can cause double free.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/include/clang/Tooling/Tooling.h

Removed: 




diff  --git a/clang/include/clang/Tooling/Tooling.h 
b/clang/include/clang/Tooling/Tooling.h
index 13c1b51bf85fbb..070706e8fa6d11 100644
--- a/clang/include/clang/Tooling/Tooling.h
+++ b/clang/include/clang/Tooling/Tooling.h
@@ -267,6 +267,9 @@ class ToolInvocation {
 
   ~ToolInvocation();
 
+  ToolInvocation(const ToolInvocation &) = delete;
+  ToolInvocation &operator=(const ToolInvocation &) = delete;
+
   /// Set a \c DiagnosticConsumer to use during driver command-line parsing and
   /// the action invocation itself.
   void setDiagnosticConsumer(DiagnosticConsumer *DiagConsumer) {



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


[PATCH] D156896: [NFC][clang] Fix static analyzer concerns

2023-08-03 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf887cb10acc9: [NFC][clang] Fix static analyzer concerns 
(authored by Fznamznon).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156896

Files:
  clang/include/clang/Tooling/Tooling.h


Index: clang/include/clang/Tooling/Tooling.h
===
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -267,6 +267,9 @@
 
   ~ToolInvocation();
 
+  ToolInvocation(const ToolInvocation &) = delete;
+  ToolInvocation &operator=(const ToolInvocation &) = delete;
+
   /// Set a \c DiagnosticConsumer to use during driver command-line parsing and
   /// the action invocation itself.
   void setDiagnosticConsumer(DiagnosticConsumer *DiagConsumer) {


Index: clang/include/clang/Tooling/Tooling.h
===
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -267,6 +267,9 @@
 
   ~ToolInvocation();
 
+  ToolInvocation(const ToolInvocation &) = delete;
+  ToolInvocation &operator=(const ToolInvocation &) = delete;
+
   /// Set a \c DiagnosticConsumer to use during driver command-line parsing and
   /// the action invocation itself.
   void setDiagnosticConsumer(DiagnosticConsumer *DiagConsumer) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 25d6f9d - [NFC][clang] Fix static analyzer concerns

2023-08-03 Thread via cfe-commits

Author: Podchishchaeva, Mariya
Date: 2023-08-03T08:37:58-07:00
New Revision: 25d6f9ddc1913de1094fa610ce77288f337771a2

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

LOG: [NFC][clang] Fix static analyzer concerns

A bunch of classes in APValue free resources in the destructor but don't
have user-written copy c'tor or assignment operator, so copying them using
default ones can cause double free.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/include/clang/AST/APValue.h

Removed: 




diff  --git a/clang/include/clang/AST/APValue.h 
b/clang/include/clang/AST/APValue.h
index 286c1a1b0941ae..c4206b73b11562 100644
--- a/clang/include/clang/AST/APValue.h
+++ b/clang/include/clang/AST/APValue.h
@@ -270,12 +270,16 @@ class APValue {
 APValue *Elts = nullptr;
 unsigned NumElts = 0;
 Vec() = default;
+Vec(const Vec &) = delete;
+Vec &operator=(const Vec &) = delete;
 ~Vec() { delete[] Elts; }
   };
   struct Arr {
 APValue *Elts;
 unsigned NumElts, ArrSize;
 Arr(unsigned NumElts, unsigned ArrSize);
+Arr(const Arr &) = delete;
+Arr &operator=(const Arr &) = delete;
 ~Arr();
   };
   struct StructData {
@@ -283,12 +287,16 @@ class APValue {
 unsigned NumBases;
 unsigned NumFields;
 StructData(unsigned NumBases, unsigned NumFields);
+StructData(const StructData &) = delete;
+StructData &operator=(const StructData &) = delete;
 ~StructData();
   };
   struct UnionData {
 const FieldDecl *Field;
 APValue *Value;
 UnionData();
+UnionData(const UnionData &) = delete;
+UnionData &operator=(const UnionData &) = delete;
 ~UnionData();
   };
   struct AddrLabelDiffData {



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


[PATCH] D155610: [Clang][Sema] Fix display of characters on static assertion failure

2023-08-03 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment.

One concern from my side is that some unicode characters like `U+FEFF` (I added 
in test) are invisible, but it may not be a big concern because we also display 
integer representation in parens.


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

https://reviews.llvm.org/D155610

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


[PATCH] D156975: [NFC][clang] Fix static analyzer concerns

2023-08-03 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG25d6f9ddc191: [NFC][clang] Fix static analyzer concerns 
(authored by Fznamznon).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156975

Files:
  clang/include/clang/AST/APValue.h


Index: clang/include/clang/AST/APValue.h
===
--- clang/include/clang/AST/APValue.h
+++ clang/include/clang/AST/APValue.h
@@ -270,12 +270,16 @@
 APValue *Elts = nullptr;
 unsigned NumElts = 0;
 Vec() = default;
+Vec(const Vec &) = delete;
+Vec &operator=(const Vec &) = delete;
 ~Vec() { delete[] Elts; }
   };
   struct Arr {
 APValue *Elts;
 unsigned NumElts, ArrSize;
 Arr(unsigned NumElts, unsigned ArrSize);
+Arr(const Arr &) = delete;
+Arr &operator=(const Arr &) = delete;
 ~Arr();
   };
   struct StructData {
@@ -283,12 +287,16 @@
 unsigned NumBases;
 unsigned NumFields;
 StructData(unsigned NumBases, unsigned NumFields);
+StructData(const StructData &) = delete;
+StructData &operator=(const StructData &) = delete;
 ~StructData();
   };
   struct UnionData {
 const FieldDecl *Field;
 APValue *Value;
 UnionData();
+UnionData(const UnionData &) = delete;
+UnionData &operator=(const UnionData &) = delete;
 ~UnionData();
   };
   struct AddrLabelDiffData {


Index: clang/include/clang/AST/APValue.h
===
--- clang/include/clang/AST/APValue.h
+++ clang/include/clang/AST/APValue.h
@@ -270,12 +270,16 @@
 APValue *Elts = nullptr;
 unsigned NumElts = 0;
 Vec() = default;
+Vec(const Vec &) = delete;
+Vec &operator=(const Vec &) = delete;
 ~Vec() { delete[] Elts; }
   };
   struct Arr {
 APValue *Elts;
 unsigned NumElts, ArrSize;
 Arr(unsigned NumElts, unsigned ArrSize);
+Arr(const Arr &) = delete;
+Arr &operator=(const Arr &) = delete;
 ~Arr();
   };
   struct StructData {
@@ -283,12 +287,16 @@
 unsigned NumBases;
 unsigned NumFields;
 StructData(unsigned NumBases, unsigned NumFields);
+StructData(const StructData &) = delete;
+StructData &operator=(const StructData &) = delete;
 ~StructData();
   };
   struct UnionData {
 const FieldDecl *Field;
 APValue *Value;
 UnionData();
+UnionData(const UnionData &) = delete;
+UnionData &operator=(const UnionData &) = delete;
 ~UnionData();
   };
   struct AddrLabelDiffData {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-08-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D153536#4556485 , @cor3ntin wrote:

> From yesterday's C++ clang WG meeting
>
> - We can land this now
> - We need to track the debugger issue
> - We should mention the lack of debugging support in the release notes
> - We should strive to improve the situation in the 18 time frame but it would 
> not be blocker as few people may be impacted.
> - We should remember to modify the release notes when debugger support is 
> improved if that happens before clang 18

Agreed; there are some minor things that need to be tweaked before landing this 
now, but I think the patch is pretty close to finished.




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:4332
+  llvm::find_if(Result, [this](const NamedDecl *Elem) {
+return (isa(Elem) || isa(Elem)) &&
+   Elem->isPlaceholderVar(getLangOpts());





Comment at: clang/lib/Sema/SemaDeclCXX.cpp:4343
+  break;
+if ((isa(ND) || isa(ND)) &&
+ND->isPlaceholderVar(getLangOpts()))





Comment at: clang/lib/Sema/SemaDeclCXX.cpp:4355
+  for (auto *D : ClassDecl->lookup(MemberOrBase)) {
+if (isa(D) || isa(D)) {
+  bool IsPlaceholder = D->isPlaceholderVar(getLangOpts());





Comment at: clang/www/cxx_status.html:148
   https://wg21.link/P2169R4";>P2169R4
-  No
+  Clang 17
  




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

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


[PATCH] D155610: [Clang][Sema] Fix display of characters on static assertion failure

2023-08-03 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D155610#4557930 , @hazohelet wrote:

> One concern from my side is that some unicode characters like `U+FEFF` (I 
> added in test) are invisible, but it may not be a big concern because we also 
> display integer representation in parens.

This is not an easy problem to solve. `pushEscapedString` does not escape 
formatting code points, such as `U+FEFF` because doing so break a bunch of 
scripts/emojis.
There are cases where it should probably be escaped but that fully depend on 
context, and it would require grapheme clusterization, which is a lot of work 
for limited value.


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

https://reviews.llvm.org/D155610

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


[PATCH] D154576: [RISCV] RISCV vector calling convention (1/2)

2023-08-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

The clang bits LGTM, but I'll leave final sign-off to the LLVM reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154576

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


[PATCH] D155610: [Clang][Sema] Fix display of characters on static assertion failure

2023-08-03 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:103-137
+- When describing the failure of static assertion of `==` expression, clang 
prints the integer
+  representation of the value as well as its character representation when
+  the user-provided expression is of character type. If the character is
+  non-printable, clang now shows the escpaed character.
+  Clang also prints multi-byte characters if the user-provided expression
+  is of multi-byte character type.
+

@aaron.ballman One one hand this is nice, on the other hand maybe too detailed. 
What do you think?


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

https://reviews.llvm.org/D155610

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


  1   2   3   >