[PATCH] D142985: [LinkerWrapper] Fix memory issues due to unguarded accesses to global state

2023-01-31 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

In D142985#4093783 , @jhuber6 wrote:

> If this fixes the issues on your side, please open a bug so it can be 
> backported.

I wrote
 https://github.com/llvm/llvm-project/issues/60437


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142985

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


[PATCH] D142985: [LinkerWrapper] Fix memory issues due to unguarded accesses to global state

2023-01-31 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

@jhuber6 
I really have no idea about the fix, but I've run the linker-wrapper.c testcase 
with asan built binaries with this fix 500 times now without seeing any 
failures.
Without the fix it fails in like 1 out of 10 runs so it surely looks like the 
fix does something good!

Nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142985

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


[PATCH] D141738: Add initial support for cross compile Windows runtimes under Linux when building Fuchsia clang toolchain

2023-01-31 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:95
+# and remove these libpath flags.
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/lib/x64"
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/atlmfc/lib/x64"

phosek wrote:
> haowei wrote:
> > thakis wrote:
> > > You can tell cmake to invoke lld-link, which has a /winsysroot: flag.
> > What would be a good way to make CMake invoke lld-link (or through 
> > clang-cl) instead of using `cmake vs_link` in this situation?
> > We thought about using
> > 
> > ```
> > set(CMAKE_${LANG}_SIMULATE_ID "MSVC")
> > set(CMAKE_${LANG}_COMPILER_FRONTEND_VARIANT "GNU")
> > ```
> > 
> > but I don't feel great about changing variables that are not suppose to 
> > change. 
> Wouldn't CMake use `lld-link` if you set `CMAKE_LINKER=lld-link`. We already 
> do this in 
> https://github.com/llvm/llvm-project/blob/0e09bb8b143c80426c497a924ee4fa57a26af6b5/llvm/cmake/modules/LLVMExternalProjectUtils.cmake#L179
>  which is used by the bootstrapping build so you should be able to use 
> `/winsysroot:` here.
@haowei have tried this suggestion?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141738

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


[PATCH] D141672: [RISCV] Support vector crypto extension ISA string and assembly

2023-01-31 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 493826.
4vtomat added a comment.

NFC, some indentation fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141672

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rvv/zvkb.s
  llvm/test/MC/RISCV/rvv/zvkg.s
  llvm/test/MC/RISCV/rvv/zvknh.s
  llvm/test/MC/RISCV/rvv/zvkns-invalid.s
  llvm/test/MC/RISCV/rvv/zvkns.s
  llvm/test/MC/RISCV/rvv/zvksed-invalid.s
  llvm/test/MC/RISCV/rvv/zvksed.s
  llvm/test/MC/RISCV/rvv/zvksh.s

Index: llvm/test/MC/RISCV/rvv/zvksh.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksh.s
@@ -0,0 +1,21 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksh  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm3c.vi v10, v9, 7
+# CHECK-INST: vsm3c.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0xae]
+# CHECK-ERROR: instruction requires the following: 'Zvksh'
+# CHECK-UNKNOWN: 77 a5 93 ae   
+
+vsm3me.vv v10, v9, v8
+# CHECK-INST: vsm3me.vv v10, v9, v8
+# CHECK-ENCODING: [0x77,0x25,0x94,0x82]
+# CHECK-ERROR: instruction requires the following: 'Zvksh'
+# CHECK-UNKNOWN: 77 25 94 82   
Index: llvm/test/MC/RISCV/rvv/zvksed.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksed.s
@@ -0,0 +1,27 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksed  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm4k.vi v10, v9, 7
+# CHECK-INST: vsm4k.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0x86]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 a5 93 86   
+
+vsm4r.vv v10, v9
+# CHECK-INST: vsm4r.vv v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa2]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 25 98 a2   
+
+vsm4r.vs v10, v9
+# CHECK-INST: vsm4r.vs v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa6]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 25 98 a6   
Index: llvm/test/MC/RISCV/rvv/zvksed-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvksed-invalid.s
@@ -0,0 +1,5 @@
+# RUN: not llvm-mc -triple=riscv32 --mattr=+zve32x --mattr=+experimental-zvksed -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+
+vsm4k.vi v10, v9, 8
+# CHECK-ERROR: immediate must be an integer in the range [0, 7]
Index: llvm/test/MC/RISCV/rvv/zvkns.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvkns.s
@@ -0,0 +1,75 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvkns %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvkns %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvkns  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvkns %s \

[PATCH] D139774: [libclang] Add API to set temporary directory location

2023-01-31 Thread Igor Kushnir via Phabricator via cfe-commits
vedgy added a comment.

In D139774#4094619 , @aaron.ballman 
wrote:

> Is there a middle ground where, instead of #2 for general temporary storage, 
> we went with #2 but with compiler-specific directories instead of system 
> directories. e.g., don't let the caller set the temp directory, but do let 
> the caller set the preamble directory (which defaults to the temp directory) 
> so long as it's set before invoking the compiler? This still won't let you 
> change options mid-run, but it also seems like it should have less risk of 
> affecting other components while still solving the thread safety issues. I'm 
> not certain if it's any easier to implement, but I think it does save you 
> from modifying `FileSystemOptions`. As a separate item, we could then 
> consider adding a new C API to let you toggle the in-memory vs on-disk 
> functionality after exploring that it won't cause other problems because 
> nobody considered the possibility that it's not a stable value for the 
> compiler invocation.

OK, so I'm going to implement overriding the preamble directory in 
`clang_createIndexWithPreambleStoragePath` (or `clang_createIndex2` or 
`clang_createIndexExt` or?); try to keep it simple and not modify 
`FileSystemOptions`; deal with the in-memory option separately later. Abandon 
this revision now and create another one once ready?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139774

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


[PATCH] D142872: Honor the fwrapv option when generating the inbounds GEP .

2023-01-31 Thread Umesh Kalappa via Phabricator via cfe-commits
umesh.kalappa0 added a comment.

@nikic ,is that changes are ok ?


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

https://reviews.llvm.org/D142872

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


[PATCH] D142688: [Clang][Driver] Handle LoongArch multiarch tuples

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



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:41
 /// so we provide a rough mapping here.
 std::string Linux::getMultiarchTriple(const Driver ,
   const llvm::Triple ,

SixWeining wrote:
> Missing test. Perhaps add some in `clang/test/Driver/linux-ld.c` and 
> `clang/test/Driver/linux-header-search.cpp`? Or postpone this change until 
> loongarch is upstreamed to Debian?
Thanks, I'll try adding the tests in the next revision.

But given [[ https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1028654 | the 
recent reversal of upstream dpkg support ]] (apparently due to 
miscommunication) it may be prudent to wait until a consensus is reached 
Debian-side.



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:93
+
+if (TargetTriple.isGNUEnvironment()) {
+  Libc = "gnu";

SixWeining wrote:
> Should only check `{GNU|GNUF32|GNUF64}`?
While technically only `gnu{,sf,f32,f64}` are permitted by the LoongArch 
Toolchain Conventions (with the bare `-gnu` being somewhat de-facto standard 
but not officially so), I believe the user's intent to specify a GNU 
environment still holds even in cases of "errors" like applying "gnuabi64" or 
"gnueabi" to LoongArch. Same applies for the musl case.



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:95
+  Libc = "gnu";
+} else if (TargetTriple.isMusl()) {
+  Libc = "musl";

SixWeining wrote:
> Should only check `Triple::Musl`?
Explained above in the GNU case.



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:116
+
+return std::string("loongarch64-linux-") + Libc + FPFlavor;
+  }

MaskRay wrote:
> `return (... + ...).str();` if an operand of `+` is a `Twine`
Thanks, will change in next revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142688

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


[PATCH] D142826: [Clang] Add -Wtype-limits to -Wextra for GCC compatibility

2023-01-31 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 493810.
xgupta added a comment.

address comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142826

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/test/Sema/tautological-constant-compare.c


Index: clang/test/Sema/tautological-constant-compare.c
===
--- clang/test/Sema/tautological-constant-compare.c
+++ clang/test/Sema/tautological-constant-compare.c
@@ -4,8 +4,8 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only 
-Wtautological-type-limit-compare -DTEST -verify -x c++ %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtype-limits -DTEST 
-verify %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtype-limits -DTEST 
-verify -x c++ %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -verify=silent %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -verify=silent -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -DTEST -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -DTEST -verify -x c++ %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify=silent 
%s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify=silent 
-x c++ %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify=silent %s
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -992,6 +992,7 @@
 EmptyInitStatement,
 StringConcatation,
 FUseLdPath,
+TypeLimits,
   ]>;
 
 def Most : DiagGroup<"most", [
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -58,6 +58,9 @@
   inside a namespace. This fixes
   `Issue 59446 `_.
 
+- ``-Wtype-limits`` was added to ``-Wextra`` for GCC compatibility. This fixes
+  `Issue 58375 `_.
+
 Improvements to Clang's diagnostics
 ^^^
 


Index: clang/test/Sema/tautological-constant-compare.c
===
--- clang/test/Sema/tautological-constant-compare.c
+++ clang/test/Sema/tautological-constant-compare.c
@@ -4,8 +4,8 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtautological-type-limit-compare -DTEST -verify -x c++ %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtype-limits -DTEST -verify %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtype-limits -DTEST -verify -x c++ %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -verify=silent %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -verify=silent -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -DTEST -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -DTEST -verify -x c++ %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify=silent %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify=silent -x c++ %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify=silent %s
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -992,6 +992,7 @@
 EmptyInitStatement,
 StringConcatation,
 FUseLdPath,
+TypeLimits,
   ]>;
 
 def Most : DiagGroup<"most", [
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -58,6 +58,9 @@
   inside a namespace. This fixes
   `Issue 59446 `_.
 
+- ``-Wtype-limits`` was added to ``-Wextra`` for GCC compatibility. This fixes
+  `Issue 58375 `_.
+
 Improvements to Clang's diagnostics
 ^^^
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a7fbca4 - [NFC] Extract `CodeGenInstAlias` into its own *.h/*.cpp

2023-01-31 Thread Sergei Barannikov via cfe-commits

Author: Sergei Barannikov
Date: 2023-02-01T05:23:43+03:00
New Revision: a7fbca40805ca414a9dc37b91075e89e6a3b75d5

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

LOG: [NFC] Extract `CodeGenInstAlias` into its own *.h/*.cpp

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

Added: 
llvm/utils/TableGen/CodeGenInstAlias.cpp
llvm/utils/TableGen/CodeGenInstAlias.h

Modified: 
clang/docs/tools/clang-formatted-files.txt
llvm/utils/TableGen/AsmMatcherEmitter.cpp
llvm/utils/TableGen/AsmWriterEmitter.cpp
llvm/utils/TableGen/CMakeLists.txt
llvm/utils/TableGen/CodeGenInstruction.cpp
llvm/utils/TableGen/CodeGenInstruction.h
llvm/utils/gn/secondary/llvm/utils/TableGen/BUILD.gn

Removed: 




diff  --git a/clang/docs/tools/clang-formatted-files.txt 
b/clang/docs/tools/clang-formatted-files.txt
index cbac961982e6a..aa9b871ea58cb 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -7418,6 +7418,8 @@ llvm/unittests/XRay/FDRRecordsTest.cpp
 llvm/unittests/XRay/FDRTraceWriterTest.cpp
 llvm/unittests/XRay/ProfileTest.cpp
 llvm/utils/not/not.cpp
+llvm/Utils/TableGen/CodeGenInstAlias.cpp
+llvm/Utils/TableGen/CodeGenInstAlias.h
 llvm/utils/TableGen/CodeBeadsGen.cpp
 llvm/utils/TableGen/CompressInstEmitter.cpp
 llvm/utils/TableGen/DFAEmitter.h

diff  --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp 
b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
index c13e5b5deff6f..4b37347bbae62 100644
--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
@@ -95,6 +95,7 @@
 //
 
//===--===//
 
+#include "CodeGenInstAlias.h"
 #include "CodeGenInstruction.h"
 #include "CodeGenTarget.h"
 #include "SubtargetFeatureInfo.h"

diff  --git a/llvm/utils/TableGen/AsmWriterEmitter.cpp 
b/llvm/utils/TableGen/AsmWriterEmitter.cpp
index f2e4d15a2c755..e7c0604b8ec75 100644
--- a/llvm/utils/TableGen/AsmWriterEmitter.cpp
+++ b/llvm/utils/TableGen/AsmWriterEmitter.cpp
@@ -12,6 +12,7 @@
 
//===--===//
 
 #include "AsmWriterInst.h"
+#include "CodeGenInstAlias.h"
 #include "CodeGenInstruction.h"
 #include "CodeGenRegisters.h"
 #include "CodeGenTarget.h"

diff  --git a/llvm/utils/TableGen/CMakeLists.txt 
b/llvm/utils/TableGen/CMakeLists.txt
index aa16e7e894aca..44ed5549c8ea3 100644
--- a/llvm/utils/TableGen/CMakeLists.txt
+++ b/llvm/utils/TableGen/CMakeLists.txt
@@ -13,6 +13,7 @@ add_tablegen(llvm-tblgen LLVM
   CodeEmitterGen.cpp
   CodeGenDAGPatterns.cpp
   CodeGenHwModes.cpp
+  CodeGenInstAlias.cpp
   CodeGenInstruction.cpp
   CodeGenMapTable.cpp
   CodeGenRegisters.cpp

diff  --git a/llvm/utils/TableGen/CodeGenInstAlias.cpp 
b/llvm/utils/TableGen/CodeGenInstAlias.cpp
new file mode 100644
index 0..f3e722d17866a
--- /dev/null
+++ b/llvm/utils/TableGen/CodeGenInstAlias.cpp
@@ -0,0 +1,282 @@
+//===- CodeGenInstAlias.cpp - CodeGen InstAlias Class Wrapper 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements the CodeGenInstAlias class.
+//
+//===--===//
+
+#include "CodeGenInstAlias.h"
+#include "CodeGenInstruction.h"
+#include "CodeGenTarget.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/TableGen/Error.h"
+#include "llvm/TableGen/Record.h"
+
+using namespace llvm;
+
+/// tryAliasOpMatch - This is a helper function for the CodeGenInstAlias
+/// constructor.  It checks if an argument in an InstAlias pattern matches
+/// the corresponding operand of the instruction.  It returns true on a
+/// successful match, with ResOp set to the result operand to be used.
+bool CodeGenInstAlias::tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo,
+   Record *InstOpRec, bool hasSubOps,
+   ArrayRef Loc, CodeGenTarget ,
+   ResultOperand ) {
+  Init *Arg = Result->getArg(AliasOpNo);
+  DefInit *ADI = dyn_cast(Arg);
+  Record *ResultRecord = ADI ? ADI->getDef() : nullptr;
+
+  if (ADI && ADI->getDef() == InstOpRec) {
+// If the operand is a record, it must have a name, and the record type
+// must match up with the instruction's argument type.
+if (!Result->getArgName(AliasOpNo))
+  PrintFatalError(Loc, "result argument #" + Twine(AliasOpNo) +
+   " must have a name!");
+

[PATCH] D142968: [NFC] Extract `CodeGenInstAlias` into its own *.h/*.cpp

2023-01-31 Thread Sergei Barannikov 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 rGa7fbca40805c: [NFC] Extract `CodeGenInstAlias` into its own 
*.h/*.cpp (authored by barannikov88).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142968

Files:
  clang/docs/tools/clang-formatted-files.txt
  llvm/utils/TableGen/AsmMatcherEmitter.cpp
  llvm/utils/TableGen/AsmWriterEmitter.cpp
  llvm/utils/TableGen/CMakeLists.txt
  llvm/utils/TableGen/CodeGenInstAlias.cpp
  llvm/utils/TableGen/CodeGenInstAlias.h
  llvm/utils/TableGen/CodeGenInstruction.cpp
  llvm/utils/TableGen/CodeGenInstruction.h
  llvm/utils/gn/secondary/llvm/utils/TableGen/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/utils/TableGen/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/utils/TableGen/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/utils/TableGen/BUILD.gn
@@ -15,6 +15,7 @@
 "CodeEmitterGen.cpp",
 "CodeGenDAGPatterns.cpp",
 "CodeGenHwModes.cpp",
+"CodeGenInstAlias.cpp",
 "CodeGenInstruction.cpp",
 "CodeGenMapTable.cpp",
 "CodeGenRegisters.cpp",
Index: llvm/utils/TableGen/CodeGenInstruction.h
===
--- llvm/utils/TableGen/CodeGenInstruction.h
+++ llvm/utils/TableGen/CodeGenInstruction.h
@@ -23,8 +23,6 @@
 #include 
 
 namespace llvm {
-class SMLoc;
-template  class ArrayRef;
   class Record;
   class DagInit;
   class CodeGenTarget;
@@ -340,71 +338,6 @@
 bool isOperandImpl(StringRef OpListName, unsigned i,
StringRef PropertyName) const;
   };
-
-
-  /// CodeGenInstAlias - This represents an InstAlias definition.
-  class CodeGenInstAlias {
-  public:
-Record *TheDef;// The actual record defining this InstAlias.
-
-/// AsmString - The format string used to emit a .s file for the
-/// instruction.
-std::string AsmString;
-
-/// Result - The result instruction.
-DagInit *Result;
-
-/// ResultInst - The instruction generated by the alias (decoded from
-/// Result).
-CodeGenInstruction *ResultInst;
-
-
-struct ResultOperand {
-private:
-  std::string Name;
-  Record *R = nullptr;
-  int64_t Imm = 0;
-
-public:
-  enum {
-K_Record,
-K_Imm,
-K_Reg
-  } Kind;
-
-  ResultOperand(std::string N, Record *r)
-  : Name(std::move(N)), R(r), Kind(K_Record) {}
-  ResultOperand(int64_t I) : Imm(I), Kind(K_Imm) {}
-  ResultOperand(Record *r) : R(r), Kind(K_Reg) {}
-
-  bool isRecord() const { return Kind == K_Record; }
-  bool isImm() const { return Kind == K_Imm; }
-  bool isReg() const { return Kind == K_Reg; }
-
-  StringRef getName() const { assert(isRecord()); return Name; }
-  Record *getRecord() const { assert(isRecord()); return R; }
-  int64_t getImm() const { assert(isImm()); return Imm; }
-  Record *getRegister() const { assert(isReg()); return R; }
-
-  unsigned getMINumOperands() const;
-};
-
-/// ResultOperands - The decoded operands for the result instruction.
-std::vector ResultOperands;
-
-/// ResultInstOperandIndex - For each operand, this vector holds a pair of
-/// indices to identify the corresponding operand in the result
-/// instruction.  The first index specifies the operand and the second
-/// index specifies the suboperand.  If there are no suboperands or if all
-/// of them are matched by the operand, the second value should be -1.
-std::vector > ResultInstOperandIndex;
-
-CodeGenInstAlias(Record *R, CodeGenTarget );
-
-bool tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo,
- Record *InstOpRec, bool hasSubOps, ArrayRef Loc,
- CodeGenTarget , ResultOperand );
-  };
-}
+} // namespace llvm
 
 #endif
Index: llvm/utils/TableGen/CodeGenInstruction.cpp
===
--- llvm/utils/TableGen/CodeGenInstruction.cpp
+++ llvm/utils/TableGen/CodeGenInstruction.cpp
@@ -13,7 +13,6 @@
 #include "CodeGenInstruction.h"
 #include "CodeGenTarget.h"
 #include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/StringMap.h"
 #include "llvm/TableGen/Error.h"
 #include "llvm/TableGen/Record.h"
 #include 
@@ -592,266 +591,3 @@
   return Constraint->getDef()->isSubClassOf("TypedOperand") &&
  Constraint->getDef()->getValueAsBit(PropertyName);
 }
-
-//===--===//
-/// CodeGenInstAlias Implementation
-//===--===//
-
-/// tryAliasOpMatch - This is a helper function for the CodeGenInstAlias
-/// constructor.  It checks if an argument in an InstAlias pattern matches
-/// the corresponding operand of the 

[PATCH] D142704: [C++20][Modules] Handle template declarations in header units.

2023-01-31 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu 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/D142704/new/

https://reviews.llvm.org/D142704

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


[PATCH] D143040: [Clang][DependencyScanner] Remove secondary actions from -cc1

2023-01-31 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese created this revision.
Bigcheese added a reviewer: jansvoboda11.
Bigcheese added a project: clang.
Herald added a subscriber: ributzka.
Herald added a project: All.
Bigcheese requested review of this revision.

The -arcmt-action= and -objcmt-migrate* actions were being passed to
module builds. This caused these builds to fail, as they are secondary
actions that suppress emitting modules.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143040

Files:
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/strip-input-args.m


Index: clang/test/ClangScanDeps/strip-input-args.m
===
--- /dev/null
+++ clang/test/ClangScanDeps/strip-input-args.m
@@ -0,0 +1,52 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb1.json.template > %t/cdb1.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb1.json -format 
experimental-full -mode preprocess-dependency-directives > %t/result1.txt
+
+// RUN: FileCheck %s -input-file %t/result1.txt
+
+// Verify that secondary actions get stripped, and that there's a single 
version
+// of module A.
+
+// CHECK:"modules": [
+// CHECK-NEXT: {
+// CHECK:"command-line": [
+// CHECK-NOT:  "-arcmt-action=check"
+// CHECK-NOT:  "-objcmt-migrate-literals"
+// CHECK-NOT:  "-mt-migrate-directory"
+// CHECK:]
+// CHECK:"name": "A"
+// CHECK:  }
+// CHECK-NOT:  "name"
+// CHECK:"translation-units"
+
+//--- cdb1.json.template
+[
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-ccc-arcmt-check -fsyntax-only DIR/t1.m",
+"file": "DIR/t1.m"
+  },
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps 
-ccc-objcmt-migrate bob -fsyntax-only DIR/t2.m",
+"file": "DIR/t2.m"
+  }
+]
+
+//--- modules/A/module.modulemap
+
+module A {
+  umbrella header "A.h"
+}
+
+//--- modules/A/A.h
+
+typedef int A_t;
+
+//--- t1.m
+@import A;
+
+//--- t2.m
+@import A;
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -111,6 +111,9 @@
   CI.getDependencyOutputOpts().Targets.clear();
 
   CI.getFrontendOpts().ProgramAction = frontend::GenerateModule;
+  CI.getFrontendOpts().ARCMTAction = FrontendOptions::ARCMT_None;
+  CI.getFrontendOpts().ObjCMTAction = FrontendOptions::ObjCMT_None;
+  CI.getFrontendOpts().MTMigrateDir.clear();
   CI.getLangOpts()->ModuleName = Deps.ID.ModuleName;
   CI.getFrontendOpts().IsSystemModule = Deps.IsSystem;
 


Index: clang/test/ClangScanDeps/strip-input-args.m
===
--- /dev/null
+++ clang/test/ClangScanDeps/strip-input-args.m
@@ -0,0 +1,52 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb1.json.template > %t/cdb1.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb1.json -format experimental-full -mode preprocess-dependency-directives > %t/result1.txt
+
+// RUN: FileCheck %s -input-file %t/result1.txt
+
+// Verify that secondary actions get stripped, and that there's a single version
+// of module A.
+
+// CHECK:"modules": [
+// CHECK-NEXT: {
+// CHECK:"command-line": [
+// CHECK-NOT:  "-arcmt-action=check"
+// CHECK-NOT:  "-objcmt-migrate-literals"
+// CHECK-NOT:  "-mt-migrate-directory"
+// CHECK:]
+// CHECK:"name": "A"
+// CHECK:  }
+// CHECK-NOT:  "name"
+// CHECK:"translation-units"
+
+//--- cdb1.json.template
+[
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -ccc-arcmt-check -fsyntax-only DIR/t1.m",
+"file": "DIR/t1.m"
+  },
+  {
+"directory": "DIR",
+"command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -ccc-objcmt-migrate bob -fsyntax-only DIR/t2.m",
+"file": "DIR/t2.m"
+  }
+]
+
+//--- modules/A/module.modulemap
+
+module A {
+  umbrella header "A.h"
+}
+
+//--- modules/A/A.h
+
+typedef int A_t;
+
+//--- t1.m
+@import A;
+
+//--- t2.m
+@import A;
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -111,6 +111,9 @@
   CI.getDependencyOutputOpts().Targets.clear();
 
   CI.getFrontendOpts().ProgramAction = 

[PATCH] D142688: [Clang][Driver] Handle LoongArch multiarch tuples

2023-01-31 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n updated this revision to Diff 493796.
xen0n added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142688

Files:
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/loongarch-abi.c


Index: clang/test/Driver/loongarch-abi.c
===
--- clang/test/Driver/loongarch-abi.c
+++ clang/test/Driver/loongarch-abi.c
@@ -16,6 +16,26 @@
 // RUN: %clang --target=loongarch64-unknown-elf %s -fsyntax-only -### 
-mabi=lp64d 2>&1 \
 // RUN:   | FileCheck --check-prefix=LP64D %s
 
+// RUN: %clang --target=loongarch32-linux-gnusf %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=ILP32S %s
+// RUN: %clang --target=loongarch32-linux-gnuf32 %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=ILP32F %s
+// RUN: %clang --target=loongarch32-linux-gnuf64 %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=ILP32D %s
+
+// RUN: %clang --target=loongarch64-linux-gnusf %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=LP64S %s
+// RUN: %clang --target=loongarch64-linux-gnuf32 %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=LP64F %s
+// RUN: %clang --target=loongarch64-linux-gnuf64 %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=LP64D %s
+
+// Check that -mabi prevails in case of conflicts with the triple-implied ABI.
+// RUN: %clang --target=loongarch32-linux-gnuf64 %s -fsyntax-only -### 
-mabi=ilp32s 2>&1 \
+// RUN:   | FileCheck --check-prefix=ILP32S %s
+// RUN: %clang --target=loongarch64-linux-gnuf64 %s -fsyntax-only -### 
-mabi=lp64s 2>&1 \
+// RUN:   | FileCheck --check-prefix=LP64S %s
+
 // ILP32S: "-target-abi" "ilp32s"
 // ILP32F: "-target-abi" "ilp32f"
 // ILP32D: "-target-abi" "ilp32d"
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -86,6 +86,36 @@
   case llvm::Triple::aarch64_be:
 return "aarch64_be-linux-gnu";
 
+  case llvm::Triple::loongarch64: {
+const char *Libc;
+const char *FPFlavor;
+
+if (TargetTriple.isGNUEnvironment()) {
+  Libc = "gnu";
+} else if (TargetTriple.isMusl()) {
+  Libc = "musl";
+} else {
+  return TargetTriple.str();
+}
+
+switch (TargetEnvironment) {
+default:
+  return TargetTriple.str();
+case llvm::Triple::GNUSF:
+  FPFlavor = "sf";
+  break;
+case llvm::Triple::GNUF32:
+  FPFlavor = "f32";
+  break;
+case llvm::Triple::GNU:
+case llvm::Triple::GNUF64:
+  FPFlavor = "f64";
+  break;
+}
+
+return std::string("loongarch64-linux-") + Libc + FPFlavor;
+  }
+
   case llvm::Triple::m68k:
 return "m68k-linux-gnu";
 
Index: clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
===
--- clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -54,7 +54,17 @@
   }
 
   // Choose a default based on the triple.
-  return IsLA32 ? "ilp32d" : "lp64d";
+  // Honor the explicit ABI modifier suffix in triple's environment part if
+  // present, falling back to {ILP32,LP64}D otherwise.
+  switch (Triple.getEnvironment()) {
+  case llvm::Triple::GNUSF:
+return IsLA32 ? "ilp32s" : "lp64s";
+  case llvm::Triple::GNUF32:
+return IsLA32 ? "ilp32f" : "lp64f";
+  case llvm::Triple::GNUF64:
+  default:
+return IsLA32 ? "ilp32d" : "lp64d";
+  }
 }
 
 void loongarch::getLoongArchTargetFeatures(const Driver ,


Index: clang/test/Driver/loongarch-abi.c
===
--- clang/test/Driver/loongarch-abi.c
+++ clang/test/Driver/loongarch-abi.c
@@ -16,6 +16,26 @@
 // RUN: %clang --target=loongarch64-unknown-elf %s -fsyntax-only -### -mabi=lp64d 2>&1 \
 // RUN:   | FileCheck --check-prefix=LP64D %s
 
+// RUN: %clang --target=loongarch32-linux-gnusf %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=ILP32S %s
+// RUN: %clang --target=loongarch32-linux-gnuf32 %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=ILP32F %s
+// RUN: %clang --target=loongarch32-linux-gnuf64 %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=ILP32D %s
+
+// RUN: %clang --target=loongarch64-linux-gnusf %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=LP64S %s
+// RUN: %clang --target=loongarch64-linux-gnuf32 %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=LP64F %s
+// RUN: %clang --target=loongarch64-linux-gnuf64 %s -fsyntax-only -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=LP64D %s
+
+// Check that -mabi prevails in case of conflicts with the triple-implied ABI.
+// RUN: %clang --target=loongarch32-linux-gnuf64 %s -fsyntax-only 

[PATCH] D141451: [clang] report inlining decisions with -Wattribute-{warning|error}

2023-01-31 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D141451#4064298 , @dblaikie wrote:

> Right - I was thinking more, as above, about directly using the existing 
> metadata generation (if it's too expensive to enable by default, then 
> possibly under an off-by-default warning or other flag) that the inliner 
> already knows how to read and write, rather than creating new/different 
> metadata handling.
> Again, might be worth knowing what the cost of the debug info metadata loc 
> tracking mode is.

For a first order approximation, I have this diff applied:

  diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
  index 436226c6f178..6d5049803188 100644
  --- a/clang/include/clang/Basic/CodeGenOptions.def
  +++ b/clang/include/clang/Basic/CodeGenOptions.def
  @@ -386,7 +386,7 @@ VALUE_CODEGENOPT(SmallDataLimit, 32, 0)
   VALUE_CODEGENOPT(SSPBufferSize, 32, 0)
   
   /// The kind of generated debug info.
  -ENUM_CODEGENOPT(DebugInfo, codegenoptions::DebugInfoKind, 4, 
codegenoptions::NoDebugInfo)
  +ENUM_CODEGENOPT(DebugInfo, codegenoptions::DebugInfoKind, 4, 
codegenoptions::LocTrackingOnly)
   
   /// Whether to generate macro debug info.
   CODEGENOPT(MacroDebugInfo, 1, 0)

This changes the default value of `codegenopts.DebugInfo` from 
`codegenoptions::NoDebugInfo` to `codegenoptions::LocTrackingOnly`, which is 
what the optimization remark emitter infra uses.  This emits more debug info 
than we need (metadata for every statement in IR rather than JUST `call` 
instructions).  But it would give me analogous metadata I could use to solve 
this problem addressed by this patch, and it would guarantee that I had precise 
col/line info.

Comparing 30 Linux kernel x86_64 defconfig (i.e. no debug info) builds with vs 
without that change:

Without (baseline):

  $ hyperfine --prepare 'make LLVM=1 -j128 -s clean' --runs 30 'make LLVM=1 
-j128 -s'
  Benchmark 1: make LLVM=1 -j128 -s
Time (mean ± σ): 61.592 s ±  0.156 s[User: 4378.360 s, System: 
312.040 s]
Range (min … max):   61.283 s … 62.026 s30 runs

With diff from above:

  $ hyperfine --prepare 'make LLVM=1 -j128 -s clean' --runs 30 'make LLVM=1 
-j128 -s'  
  Benchmark 1: make LLVM=1 -j128 -s
Time (mean ± σ): 62.228 s ±  0.523 s[User: 4433.828 s, System: 
312.908 s]
Range (min … max):   61.825 s … 64.912 s30 runs

So that's a slowdown from the mean of ~1.02% ((1 - 61.592/62.228)*100). We 
probably could claw some of that back if we had another level of 
`codegenoptions` between `NoDebugInfo` and `LocTrackingOnly` that only emitted 
LocTracking info for call insts (stated another way, omit `DILocation` for all 
instructions other than `call`). I'm guessing that would take significant work 
to add to clang; I wasn't able how to figure out how to do so quickly.  I 
imagine updating the non-debug-info clang tests to also be a treat.  Is a 1% 
compile time performance hit worth more precise backend diagnostics? Probably 
(IMO). Perhaps worth an RFC?

---

FWIW, here are measurements of D141451  @ 
Diff 488371 at the same base as the baseline:

  $ hyperfine --prepare 'make LLVM=1 -j128 -s clean' --runs 30 'make LLVM=1 
-j128 -s'
  Benchmark 1: make LLVM=1 -j128 -s
Time (mean ± σ): 61.702 s ±  0.456 s[User: 4395.106 s, System: 
313.120 s]
Range (min … max):   61.409 s … 64.000 s30 runs

That's ~0.17% slower (and my machine is running hot from benchmarking for the 
past 1.5hrs). Note this patch/approach doesn't have precise line info.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141451

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


[PATCH] D142861: [Clang] avoid relying on StringMap iteration order when roundtripping -analyzer-config

2023-01-31 Thread Erik Desjardins via Phabricator via cfe-commits
erikdesjardins added a comment.

I don't have commit access, please commit this on my behalf: `Erik Desjardins 
`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142861

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


[PATCH] D139737: [-Wunsafe-buffer-usage] Initiate Fix-it generation for local variable declarations

2023-01-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:694
+// Return text representation of an `Expr`.  In case unable to get the text
+// representatiion of `E`, return `Default`.
+static StringRef getExprTextOr(const Expr *E, const SourceManager ,




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

https://reviews.llvm.org/D139737

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


[PATCH] D136497: [Clang] support for outputs along indirect edges of asm goto

2023-01-31 Thread Bill Wendling via Phabricator via cfe-commits
void accepted this revision.
void added a comment.
This revision is now accepted and ready to land.

One small comment about the documentation but L:GTM.




Comment at: clang/docs/LanguageExtensions.rst:1584
+Outputs may be used along any branches from the ``asm goto`` whether the
+branches are taken or not.
 

efriedma wrote:
> Maybe put a note about earlier releases, so people don't get confused if they 
> use newer documentation than their version of clang.
> 
> Is there any chance we want a dedicated __has_extension flag?
> Is there any chance we want a dedicated __has_extension flag?

Might not be a bad idea just in case they have more than one compiler version 
they're using. Then again, if they add code to use this feature, they're fairly 
committed to the assumption that it'll "just work" even with a __has_extension 
flag...(Remember that we currently don't actually warn if they're using the 
outputs on the indirect branch. We just specify that such behavior is 
undefined.)

I think a strongly worded note here that it's available with Clang 16+ (or 
whatever) is going to be slightly better. It'll force them to use macros to 
support multiple compiler versions, making their code wicked ugly, and them 
possibly coming up with better ways to ensure that the correct compiler is used 
for this feature.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136497

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


[PATCH] D141625: [DeclContext] Sort the Decls before adding into DeclContext

2023-01-31 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

> Sorry, I'm still not really following - OK, sounds like you're saying this 
> test does fail at HEAD/without this patch in reverse iteration mode, and is a 
> bit larger than would be minimally necessary to achieve that, but also might 
> fail at HEAD without reverse iteration, providing somewhat more testing than 
> if it were fully minimized/only caught in reverse.
>
> Fair enough -I don't think it's the right tradeoff, but I'm glad it's 
> stable/provides that coverage.

The main motivations are:

- Reverse iteration coverage from bots are really low.
- The FileCheck that supposed to fail on reverse iteration is not fully 
checking the order of decls in the serialized bitcode in a semantic way. It is 
only checking an index, which also assigned based on an iteration order. If 
both iterations are iterating none deterministic container, both will be 
reversed and the test will pass :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141625

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


[PATCH] D141324: [clang] extend external_source_symbol attribute with the USR clause

2023-01-31 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

@erichkeane ping.


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

https://reviews.llvm.org/D141324

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


[clang] cd97675 - [hexagon] add a -mcabac flag

2023-01-31 Thread Brian Cain via cfe-commits

Author: Brian Cain
Date: 2023-01-31T16:30:35-08:00
New Revision: cd97675e02368f31d56bd8f143c5987649d162d8

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

LOG: [hexagon] add a -mcabac flag

For v73 and later, clang users who wish to use the cabac instructions need
a way to add the 'cabac' target feature.

Reviewed By: kparzysz

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/hexagon-toolchain-elf.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9aef70321d525..3dead3fcebb0b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4559,6 +4559,8 @@ def mnvs : Flag<["-"], "mnvs">, 
Group,
   Flags<[CC1Option]>, HelpText<"Enable generation of new-value stores">;
 def mno_nvs : Flag<["-"], "mno-nvs">, Group,
   Flags<[CC1Option]>, HelpText<"Disable generation of new-value stores">;
+def mcabac: Flag<["-"], "mcabac">, Group,
+  HelpText<"Enable CABAC instructions">;
 
 // SPARC feature flags
 def mfpu : Flag<["-"], "mfpu">, Group;

diff  --git a/clang/test/Driver/hexagon-toolchain-elf.c 
b/clang/test/Driver/hexagon-toolchain-elf.c
index 477bc8a969b92..9454c33747630 100644
--- a/clang/test/Driver/hexagon-toolchain-elf.c
+++ b/clang/test/Driver/hexagon-toolchain-elf.c
@@ -581,6 +581,16 @@
 // RUN:| FileCheck --check-prefix=CHECK371 %s
 // CHECK371-NOT: "+reserved-r19"
 
+// 
-
+// mcabac
+// 
-
+// RUN: %clang -### -target hexagon-unknown-elf -mcabac %s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK372 %s
+// CHECK372: "-target-feature" "+cabac"
+// RUN: %clang -### -target hexagon-unknown-elf %s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK373 %s
+// CHECK373-NOT: "+cabac"
+
 // 
-
 // Misc Defaults
 // 
-



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


[PATCH] D142947: [hexagon] add a -mcabac flag

2023-01-31 Thread Brian Cain 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 rGcd97675e0236: [hexagon] add a -mcabac flag (authored by 
androm3da).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142947

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/hexagon-toolchain-elf.c


Index: clang/test/Driver/hexagon-toolchain-elf.c
===
--- clang/test/Driver/hexagon-toolchain-elf.c
+++ clang/test/Driver/hexagon-toolchain-elf.c
@@ -581,6 +581,16 @@
 // RUN:| FileCheck --check-prefix=CHECK371 %s
 // CHECK371-NOT: "+reserved-r19"
 
+// 
-
+// mcabac
+// 
-
+// RUN: %clang -### -target hexagon-unknown-elf -mcabac %s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK372 %s
+// CHECK372: "-target-feature" "+cabac"
+// RUN: %clang -### -target hexagon-unknown-elf %s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK373 %s
+// CHECK373-NOT: "+cabac"
+
 // 
-
 // Misc Defaults
 // 
-
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4559,6 +4559,8 @@
   Flags<[CC1Option]>, HelpText<"Enable generation of new-value stores">;
 def mno_nvs : Flag<["-"], "mno-nvs">, Group,
   Flags<[CC1Option]>, HelpText<"Disable generation of new-value stores">;
+def mcabac: Flag<["-"], "mcabac">, Group,
+  HelpText<"Enable CABAC instructions">;
 
 // SPARC feature flags
 def mfpu : Flag<["-"], "mfpu">, Group;


Index: clang/test/Driver/hexagon-toolchain-elf.c
===
--- clang/test/Driver/hexagon-toolchain-elf.c
+++ clang/test/Driver/hexagon-toolchain-elf.c
@@ -581,6 +581,16 @@
 // RUN:| FileCheck --check-prefix=CHECK371 %s
 // CHECK371-NOT: "+reserved-r19"
 
+// -
+// mcabac
+// -
+// RUN: %clang -### -target hexagon-unknown-elf -mcabac %s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK372 %s
+// CHECK372: "-target-feature" "+cabac"
+// RUN: %clang -### -target hexagon-unknown-elf %s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK373 %s
+// CHECK373-NOT: "+cabac"
+
 // -
 // Misc Defaults
 // -
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4559,6 +4559,8 @@
   Flags<[CC1Option]>, HelpText<"Enable generation of new-value stores">;
 def mno_nvs : Flag<["-"], "mno-nvs">, Group,
   Flags<[CC1Option]>, HelpText<"Disable generation of new-value stores">;
+def mcabac: Flag<["-"], "mcabac">, Group,
+  HelpText<"Enable CABAC instructions">;
 
 // SPARC feature flags
 def mfpu : Flag<["-"], "mfpu">, Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143027: [clang][deps] Fix module context hash for constant strings

2023-01-31 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.

Thanks for fixing this. LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143027

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


[PATCH] D139052: [NFC][Profile] Access profile through VirtualFileSystem

2023-01-31 Thread Steven Wu via Phabricator via cfe-commits
steven_wu updated this revision to Diff 493768.
steven_wu added a comment.

Try fix pre-merge build failure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139052

Files:
  clang/include/clang/CodeGen/BackendUtil.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/CodeGen/MIRSampleProfile.h
  llvm/include/llvm/CodeGen/Passes.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
  llvm/include/llvm/ProfileData/InstrProfReader.h
  llvm/include/llvm/ProfileData/SampleProfReader.h
  llvm/include/llvm/Support/PGOOptions.h
  llvm/include/llvm/Transforms/IPO/SampleProfile.h
  llvm/include/llvm/Transforms/Instrumentation/PGOInstrumentation.h
  llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
  llvm/lib/CodeGen/MIRSampleProfile.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/PassBuilderPipelines.cpp
  llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/ProfileData/InstrProfReader.cpp
  llvm/lib/ProfileData/SampleProfReader.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/PGOOptions.cpp
  llvm/lib/Target/X86/X86InsertPrefetch.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/tools/llvm-cov/CodeCoverage.cpp
  llvm/tools/llvm-profdata/llvm-profdata.cpp
  llvm/tools/llvm-profgen/llvm-profgen.cpp
  llvm/tools/opt/NewPMDriver.cpp
  llvm/unittests/ProfileData/SampleProfTest.cpp

Index: llvm/unittests/ProfileData/SampleProfTest.cpp
===
--- llvm/unittests/ProfileData/SampleProfTest.cpp
+++ llvm/unittests/ProfileData/SampleProfTest.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Testing/Support/SupportHelpers.h"
 #include "gtest/gtest.h"
@@ -57,8 +58,9 @@
 
   void readProfile(const Module , StringRef Profile,
StringRef RemapFile = "") {
+auto FS = vfs::getRealFileSystem();
 auto ReaderOrErr = SampleProfileReader::create(
-std::string(Profile), Context, FSDiscriminatorPass::Base,
+std::string(Profile), Context, *FS, FSDiscriminatorPass::Base,
 std::string(RemapFile));
 ASSERT_TRUE(NoError(ReaderOrErr.getError()));
 Reader = std::move(ReaderOrErr.get());
Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -31,6 +31,7 @@
 #include "llvm/Passes/StandardInstrumentations.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ToolOutputFile.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
@@ -333,22 +334,25 @@
bool EnableDebugify, bool VerifyDIPreserve) {
   bool VerifyEachPass = VK == VK_VerifyEachPass;
 
+  auto FS = vfs::getRealFileSystem();
   std::optional P;
   switch (PGOKindFlag) {
   case InstrGen:
-P = PGOOptions(ProfileFile, "", "", PGOOptions::IRInstr);
+P = PGOOptions(ProfileFile, "", "", FS, PGOOptions::IRInstr);
 break;
   case InstrUse:
-P = PGOOptions(ProfileFile, "", ProfileRemappingFile, PGOOptions::IRUse);
+P = PGOOptions(ProfileFile, "", ProfileRemappingFile, FS,
+   PGOOptions::IRUse);
 break;
   case SampleUse:
-P = PGOOptions(ProfileFile, "", ProfileRemappingFile,
+P = PGOOptions(ProfileFile, "", ProfileRemappingFile, FS,
PGOOptions::SampleUse);
 break;
   case NoPGO:
 if (DebugInfoForProfiling || PseudoProbeForProfiling)
-  P = PGOOptions("", "", "", PGOOptions::NoAction, PGOOptions::NoCSAction,
- DebugInfoForProfiling, PseudoProbeForProfiling);
+  P = PGOOptions("", "", "", nullptr, PGOOptions::NoAction,
+ PGOOptions::NoCSAction, DebugInfoForProfiling,
+ PseudoProbeForProfiling);
 else
   P = std::nullopt;
   }
@@ -367,7 +371,7 @@
 P->CSAction = PGOOptions::CSIRInstr;
 P->CSProfileGenFile = CSProfileGenFile;
   } else
-P = PGOOptions("", CSProfileGenFile, ProfileRemappingFile,
+P = PGOOptions("", CSProfileGenFile, ProfileRemappingFile, FS,
PGOOptions::NoAction, PGOOptions::CSIRInstr);
 } else /* CSPGOKindFlag == CSInstrUse */ {
   if (!P) {
Index: llvm/tools/llvm-profgen/llvm-profgen.cpp

[PATCH] D141738: Add initial support for cross compile Windows runtimes under Linux when building Fuchsia clang toolchain

2023-01-31 Thread Haowei Wu via Phabricator via cfe-commits
haowei updated this revision to Diff 493766.
haowei added a comment.

Correct dependency issues on llvm-mt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141738

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/cmake/caches/Fuchsia.cmake
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/LLVMExternalProjectUtils.cmake

Index: llvm/cmake/modules/LLVMExternalProjectUtils.cmake
===
--- llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -93,7 +93,10 @@
   if(_cmake_system_name STREQUAL Darwin)
 list(APPEND ARG_TOOLCHAIN_TOOLS llvm-libtool-darwin llvm-lipo)
   elseif(is_msvc_target)
-list(APPEND ARG_TOOLCHAIN_TOOLS llvm-lib)
+list(APPEND ARG_TOOLCHAIN_TOOLS llvm-lib llvm-rc)
+if (LLVM_ENABLE_LIBXML2)
+  list(APPEND ARG_TOOLCHAIN_TOOLS llvm-mt)
+endif()
   else()
 # TODO: These tools don't fully support Mach-O format yet.
 list(APPEND ARG_TOOLCHAIN_TOOLS llvm-objcopy llvm-strip llvm-readelf)
@@ -212,6 +215,12 @@
 if(llvm-readelf IN_LIST TOOLCHAIN_TOOLS)
   list(APPEND compiler_args -DCMAKE_READELF=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-readelf${CMAKE_EXECUTABLE_SUFFIX})
 endif()
+if(llvm-mt IN_LIST TOOLCHAIN_TOOLS AND is_msvc_target)
+  list(APPEND compiler_args -DCMAKE_MT=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-mt${CMAKE_EXECUTABLE_SUFFIX})
+endif()
+if(llvm-rc IN_LIST TOOLCHAIN_TOOLS AND is_msvc_target)
+  list(APPEND compiler_args -DCMAKE_RC_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-rc${CMAKE_EXECUTABLE_SUFFIX})
+endif()
 list(APPEND ARG_DEPENDS ${TOOLCHAIN_TOOLS})
   endif()
 
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1315,6 +1315,10 @@
 strings
 strip
 )
+  # Build llvm-mt if libxml2 is enabled. Can be used by runtimes.
+  if (LLVM_ENABLE_LIBXML2)
+list(APPEND LLVM_TOOLCHAIN_TOOLS llvm-mt)
+  endif()
 endif()
 
 macro(llvm_add_tool project name)
Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -29,6 +29,8 @@
   CMAKE_MODULE_LINKER_FLAGS
   CMAKE_SHARED_LINKER_FLAGS
   CMAKE_EXE_LINKER_FLAGS
+  LLVM_WINSYSROOT
+  LLVM_VFSOVERLAY
 )
 
 set(_FUCHSIA_BOOTSTRAP_PASSTHROUGH_BOOL
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -69,12 +69,44 @@
   set(RUNTIMES_CMAKE_ARGS "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13;-DCMAKE_OSX_ARCHITECTURES=arm64|x86_64" CACHE STRING "")
 endif()
 
-if(WIN32)
+if(WIN32 OR LLVM_WINSYSROOT)
+  if((NOT WIN32) AND (NOT LLVM_VFSOVERLAY))
+message(FATAL_ERROR "LLVM_VFSOVERLAY should be defined.")
+  endif()
   set(target "x86_64-pc-windows-msvc")
 
+  if (LLVM_WINSYSROOT)
+set(WINDOWS_COMPILER_FLAGS
+  -Xclang
+  -ivfsoverlay
+  -Xclang
+  ${LLVM_VFSOVERLAY}
+  # TODO: /winsysroot should be set by HandleLLVMOptions.cmake automatically
+  # but it current has a bug that prevents it from working under cross
+  # compilation. Set this flag manually for now.
+  /winsysroot
+  ${LLVM_WINSYSROOT})
+string(REPLACE ";" " " WINDOWS_COMPILER_FLAGS "${WINDOWS_COMPILER_FLAGS}")
+set(WINDOWS_LINK_FLAGS
+/vfsoverlay:${LLVM_VFSOVERLAY}
+# TODO: On Windows, linker is invoked by cmake instead of the clang-cl driver,
+# so we have to manually set the libpath. We use clang-cl driver if we can
+# and remove these libpath flags.
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/lib/x64"
+-libpath:"${LLVM_WINSYSROOT}/VC/Tools/MSVC/14.34.31933/atlmfc/lib/x64"
+-libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/ucrt/x64"
+-libpath:"${LLVM_WINSYSROOT}/Windows Kits/10/Lib/10.0.19041.0/um/x64")
+string(REPLACE ";" " " WINDOWS_LINK_FLAGS "${WINDOWS_LINK_FLAGS}")
+  endif()
+
   list(APPEND BUILTIN_TARGETS "${target}")
   set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
   set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_C_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_CXX_FLAGS ${WINDOWS_COMPILER_FLAGS} CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_EXE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE STRING "")
+  set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE STRING "")
 
   list(APPEND 

[PATCH] D143027: [clang][deps] Fix module context hash for constant strings

2023-01-31 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 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/D143027/new/

https://reviews.llvm.org/D143027

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


[PATCH] D143027: [clang][deps] Fix module context hash for constant strings

2023-01-31 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added reviewers: jansvoboda11, Bigcheese.
Herald added a project: All.
benlangmuir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We were not hashing constant strings in the command-line, only ones that
required allocations. This was causing us to get the same hash across
different flag options.

rdar://101053855


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143027

Files:
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/Inputs/modules-context-hash/cdb_b2.json.template
  clang/test/ClangScanDeps/modules-context-hash.c


Index: clang/test/ClangScanDeps/modules-context-hash.c
===
--- clang/test/ClangScanDeps/modules-context-hash.c
+++ clang/test/ClangScanDeps/modules-context-hash.c
@@ -7,15 +7,18 @@
 
 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-context-hash/cdb_a.json.template > 
%t/cdb_a.json
 // RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-context-hash/cdb_b.json.template > 
%t/cdb_b.json
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-context-hash/cdb_b2.json.template 
> %t/cdb_b2.json
 
-// We run two separate scans. The context hash for "a" and "b" can differ 
between
+// We run separate scans. The context hash for "a" and "b" can differ between
 // systems. If we'd scan both Clang invocations in a single run, the order of 
JSON
 // entities would be non-deterministic. To prevent this, run the scans 
separately
 // and verify that the context hashes differ with a single FileCheck 
invocation.
 //
-// RUN: clang-scan-deps -compilation-database %t/cdb_a.json -format 
experimental-full -j 1 >  %t/result.json
-// RUN: clang-scan-deps -compilation-database %t/cdb_b.json -format 
experimental-full -j 1 >> %t/result.json
-// RUN: cat %t/result.json | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t 
-check-prefix=CHECK
+// RUN: clang-scan-deps -compilation-database %t/cdb_a.json -format 
experimental-full -j 1 >  %t/result_a.json
+// RUN: clang-scan-deps -compilation-database %t/cdb_b.json -format 
experimental-full -j 1 > %t/result_b.json
+// RUN: clang-scan-deps -compilation-database %t/cdb_b2.json -format 
experimental-full -j 1 > %t/result_b2.json
+// RUN: cat %t/result_a.json %t/result_b.json | sed 's:\?:/:g' | FileCheck 
%s -DPREFIX=%/t -check-prefix=CHECK
+// RUN: cat %t/result_b.json %t/result_b2.json | sed 's:\?:/:g' | 
FileCheck %s -DPREFIX=%/t -check-prefix=FLAG_ONLY
 
 // CHECK:  {
 // CHECK-NEXT:   "modules": [
@@ -91,3 +94,17 @@
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "input-file": "[[PREFIX]]/tu.c"
 // CHECK-NEXT: }
+
+// B and B2 only differ by -fapplication-extension
+
+// FLAG_ONLY:   "modules": [
+// FLAG_ONLY-NEXT: {
+// FLAG_ONLY:"context-hash": "[[HASH_MOD_B1:.*]]"
+// FLAG_ONLY-NOT:"-fapplication-extension"
+
+// FLAG_ONLY:   "modules": [
+// FLAG_ONLY-NEXT: {
+// FLAG_ONLY-NOT:"context-hash": "[[HASH_MOD_B1]]"
+// FLAG_ONLY:"-fapplication-extension"
+// FLAG_ONLY:   "translation-units": [
+// FLAG_ONLY-NOT:"context-hash": "[[HASH_MOD_B1]]"
Index: clang/test/ClangScanDeps/Inputs/modules-context-hash/cdb_b2.json.template
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/modules-context-hash/cdb_b2.json.template
@@ -0,0 +1,7 @@
+[
+  {
+"directory": "DIR",
+"command": "clang -c DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache 
-IDIR/b -o DIR/tu_b.o -fapplication-extension",
+"file": "DIR/tu.c"
+  }
+]
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -264,13 +264,13 @@
   HashBuilder.add(serialization::VERSION_MAJOR, serialization::VERSION_MINOR);
 
   // Hash the BuildInvocation without any input files.
-  SmallVector DummyArgs;
-  CI.generateCC1CommandLine(DummyArgs, [&](const Twine ) {
-Scratch.clear();
-StringRef Str = Arg.toStringRef(Scratch);
-HashBuilder.add(Str);
-return "";
+  SmallVector Args;
+  llvm::BumpPtrAllocator Alloc;
+  llvm::StringSaver Saver(Alloc);
+  CI.generateCC1CommandLine(Args, [&](const Twine ) {
+return Saver.save(Arg).data();
   });
+  HashBuilder.addRange(Args);
 
   // Hash the module dependencies. These paths may differ even if the 
invocation
   // is identical if they depend on the contents of the files in the TU -- for


Index: clang/test/ClangScanDeps/modules-context-hash.c
===
--- clang/test/ClangScanDeps/modules-context-hash.c
+++ clang/test/ClangScanDeps/modules-context-hash.c
@@ -7,15 +7,18 @@
 
 // RUN: sed "s|DIR|%/t|g" 

[PATCH] D142939: Fix handling of -> calls for modernize-use-emplace

2023-01-31 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a comment.

Nevermind, this was fixed as I was looking at it. LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142939

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


[PATCH] D142939: Fix handling of -> calls for modernize-use-emplace

2023-01-31 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp:100
+auto cxxMemberCallExprOnContainer(StringRef MethodName,
+  const std::vector ContainerNames) 
{
+  return cxxMemberCallExpr(

```
const std::vector 
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142939

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


[PATCH] D142939: Fix handling of -> calls for modernize-use-emplace

2023-01-31 Thread Peter Wolf via Phabricator via cfe-commits
BigPeet updated this revision to Diff 493756.
BigPeet added a comment.

- fix passing vector by value instead of by ref-to-const


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142939

Files:
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp
@@ -1334,3 +1334,90 @@
   v3.push_back({{0}});
   v3.push_back({{}});
 }
+
+void testWithPointerTypes() {
+  std::list l;
+  std::list* lp = 
+  std::stack s;
+  std::stack* sp;
+
+  lp->push_back(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_back(1, 2);
+  lp->push_front(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_front instead of push_front [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_front(1, 2);
+  sp->push(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace instead of push [modernize-use-emplace]
+  // CHECK-FIXES: sp->emplace(1, 2);
+
+  lp->push_back(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_back(1, 2);
+  lp->push_front(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_front instead of push_front [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_front(1, 2);
+  sp->push(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace instead of push [modernize-use-emplace]
+  // CHECK-FIXES: sp->emplace(1, 2);
+
+  lp->push_back(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_back();
+  lp->push_front(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_front instead of push_front [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_front();
+  sp->push(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace instead of push [modernize-use-emplace]
+  // CHECK-FIXES: sp->emplace();
+
+  lp->push_back(Something{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_back();
+  lp->push_front(Something{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_front instead of push_front [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_front();
+  sp->push(Something{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace instead of push [modernize-use-emplace]
+  // CHECK-FIXES: sp->emplace();
+
+  lp->emplace_back(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: unnecessary temporary object created while calling emplace_back
+  // CHECK-FIXES: lp->emplace_back(1, 2);
+  lp->emplace_front(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: unnecessary temporary object created while calling emplace_front
+  // CHECK-FIXES: lp->emplace_front(1, 2);
+  sp->emplace(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: unnecessary temporary object created while calling emplace
+  // CHECK-FIXES: sp->emplace(1, 2);
+
+  lp->emplace_back(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: unnecessary temporary object created while calling emplace_back
+  // CHECK-FIXES: lp->emplace_back(1, 2);
+  lp->emplace_front(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: unnecessary temporary object created while calling emplace_front
+  // CHECK-FIXES: lp->emplace_front(1, 2);
+  sp->emplace(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: unnecessary temporary object created while calling emplace
+  // CHECK-FIXES: sp->emplace(1, 2);
+
+  lp->emplace_back(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: unnecessary temporary object created while calling emplace_back
+  // CHECK-FIXES: lp->emplace_back();
+  lp->emplace_front(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: unnecessary temporary object created while calling emplace_front
+  // CHECK-FIXES: lp->emplace_front();
+  sp->emplace(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: unnecessary temporary object created while calling emplace
+  // CHECK-FIXES: sp->emplace();
+
+  lp->emplace_back(Something{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: unnecessary temporary object created while calling emplace_back
+  // CHECK-FIXES: lp->emplace_back();
+  lp->emplace_front(Something{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: unnecessary temporary 

[PATCH] D143025: [Fuchsia] Add llvm-mt and llvm-rc to clang bootstrap dependency

2023-01-31 Thread Haowei Wu via Phabricator via cfe-commits
haowei created this revision.
haowei added a reviewer: phosek.
Herald added a subscriber: abrachet.
Herald added a project: All.
haowei requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

llvm-mt and llvm-rc tools are capable of building clang for Windows and 
compiler runtimes. We should use them in clang bootstrap build instead of 
relying on mt and rc provided by the host toolchain.
This patch also simplified the BOOTSTRAP_ flags, allowing them to be pass 
through from regular flags.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143025

Files:
  clang/cmake/caches/Fuchsia.cmake


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -17,6 +17,40 @@
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 
+# Passthrough stage1 flags to stage1.
+set(_FUCHSIA_BOOTSTRAP_PASSTHROUGH_STRINGS
+  ZLIB_INCLUDE_DIR
+  ZLIB_LIBRARY
+  zstd_DIR
+  LibXml2_ROOT
+  CURL_ROOT
+  OpenSSL_ROOT
+  CMAKE_SYSROOT
+  CMAKE_MODULE_LINKER_FLAGS
+  CMAKE_SHARED_LINKER_FLAGS
+  CMAKE_EXE_LINKER_FLAGS
+)
+
+set(_FUCHSIA_BOOTSTRAP_PASSTHROUGH_BOOL
+  LLVM_ENABLE_ZLIB
+  LLVM_ENABLE_ZSTD
+  LLVM_ENABLE_LIBXML2
+  LLVM_ENABLE_CURL
+  CMAKE_FIND_PACKAGE_PREFER_CONFIG
+)
+
+foreach(variableName ${_FUCHSIA_BOOTSTRAP_PASSTHROUGH_STRINGS})
+  if(DEFINED ${variableName})
+set(BOOTSTRAP_${variableName} "${${variableName}}" CACHE STRING "")
+  endif()
+endforeach()
+
+foreach(variableName ${_FUCHSIA_BOOTSTRAP_PASSTHROUGH_BOOL})
+  if(DEFINED ${variableName})
+set(BOOTSTRAP_${variableName} "${${variableName}}" CACHE BOOL "")
+  endif()
+endforeach()
+
 if(WIN32)
   set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
 endif()
@@ -105,12 +139,6 @@
   endif()
 endif()
 
-if(UNIX)
-  set(BOOTSTRAP_CMAKE_SHARED_LINKER_FLAGS "-ldl -lpthread" CACHE STRING "")
-  set(BOOTSTRAP_CMAKE_MODULE_LINKER_FLAGS "-ldl -lpthread" CACHE STRING "")
-  set(BOOTSTRAP_CMAKE_EXE_LINKER_FLAGS "-ldl -lpthread" CACHE STRING "")
-endif()
-
 set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
 
@@ -145,6 +173,8 @@
 set(CLANG_BOOTSTRAP_EXTRA_DEPS
   builtins
   runtimes
+  llvm-rc
+  llvm-mt
   CACHE STRING "")
 set(CLANG_BOOTSTRAP_CMAKE_ARGS
   ${EXTRA_ARGS}


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -17,6 +17,40 @@
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 
+# Passthrough stage1 flags to stage1.
+set(_FUCHSIA_BOOTSTRAP_PASSTHROUGH_STRINGS
+  ZLIB_INCLUDE_DIR
+  ZLIB_LIBRARY
+  zstd_DIR
+  LibXml2_ROOT
+  CURL_ROOT
+  OpenSSL_ROOT
+  CMAKE_SYSROOT
+  CMAKE_MODULE_LINKER_FLAGS
+  CMAKE_SHARED_LINKER_FLAGS
+  CMAKE_EXE_LINKER_FLAGS
+)
+
+set(_FUCHSIA_BOOTSTRAP_PASSTHROUGH_BOOL
+  LLVM_ENABLE_ZLIB
+  LLVM_ENABLE_ZSTD
+  LLVM_ENABLE_LIBXML2
+  LLVM_ENABLE_CURL
+  CMAKE_FIND_PACKAGE_PREFER_CONFIG
+)
+
+foreach(variableName ${_FUCHSIA_BOOTSTRAP_PASSTHROUGH_STRINGS})
+  if(DEFINED ${variableName})
+set(BOOTSTRAP_${variableName} "${${variableName}}" CACHE STRING "")
+  endif()
+endforeach()
+
+foreach(variableName ${_FUCHSIA_BOOTSTRAP_PASSTHROUGH_BOOL})
+  if(DEFINED ${variableName})
+set(BOOTSTRAP_${variableName} "${${variableName}}" CACHE BOOL "")
+  endif()
+endforeach()
+
 if(WIN32)
   set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
 endif()
@@ -105,12 +139,6 @@
   endif()
 endif()
 
-if(UNIX)
-  set(BOOTSTRAP_CMAKE_SHARED_LINKER_FLAGS "-ldl -lpthread" CACHE STRING "")
-  set(BOOTSTRAP_CMAKE_MODULE_LINKER_FLAGS "-ldl -lpthread" CACHE STRING "")
-  set(BOOTSTRAP_CMAKE_EXE_LINKER_FLAGS "-ldl -lpthread" CACHE STRING "")
-endif()
-
 set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
 
@@ -145,6 +173,8 @@
 set(CLANG_BOOTSTRAP_EXTRA_DEPS
   builtins
   runtimes
+  llvm-rc
+  llvm-mt
   CACHE STRING "")
 set(CLANG_BOOTSTRAP_CMAKE_ARGS
   ${EXTRA_ARGS}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141625: [DeclContext] Sort the Decls before adding into DeclContext

2023-01-31 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D141625#4094942 , @steven_wu wrote:

> In D141625#4094837 , @dblaikie 
> wrote:
>
>> In D141625#4094742 , @steven_wu 
>> wrote:
>>
>>> In D141625#4067225 , @dblaikie 
>>> wrote:
>>>
 In D141625#4066961 , @steven_wu 
 wrote:

> No, reverse iteration will not break diff test for a small number of 
> decls. Everything will be in reverse order so it is the same.

 Hmm, I'm not sure I'm following why that is - could you explain this in 
 more detail? The usual problem is that, say, we're outputting based on an 
 unstable order - even two items would be enough to cause a test of that to 
 fail in either forward or reverse iteration mode until the order is 
 stabilized.

 Is that not the case here? Is there some interaction between iteration 
 order that's part of the nondeterminism here?
>>>
>>> In order to make a test that will break before the change with reverse 
>>> iteration, the test needs to check that the decls/records are serialized 
>>> into the module in a pre deterministic order. It can't be just diff the 
>>> output of two runs with a small input because small input will not overflow 
>>> the smallptrset, thus the reverse iteration outputs from two runs will very 
>>> likely to be identical, just in a different order from forward iteration.
>>
>> Sure, I think I'm with you there - but the current test checks that the 
>> decls/records are serialized into the module in a pre-deterministic order, 
>> right? So it doesn't seem like a reverse iteration-failing test would be 
>> more involved/brittle/less robust than the test being added here?
>
> Yes, exactly, I added file check so that this test is going to fail for 
> reverse iteration. What I also want is keep the size of the test case since 
> it not really enormous so this test also has a good chance of failing without 
> reverse iteration.

Sorry, I'm still not really following - OK, sounds like you're saying this test 
does fail at HEAD/without this patch in reverse iteration mode, and is a bit 
larger than would be minimally necessary to achieve that, but also might fail 
at HEAD without reverse iteration, providing somewhat more testing than if it 
were fully minimized/only caught in reverse.

Fair enough -I don't think it's the right tradeoff, but I'm glad it's 
stable/provides that coverage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141625

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


[PATCH] D142939: Fix handling of -> calls for modernize-use-emplace

2023-01-31 Thread Peter Wolf via Phabricator via cfe-commits
BigPeet added a comment.

Refactored the code a little bit to get rid of some repetitions. Should 
effectively match the same code as the accepted revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142939

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


[PATCH] D142939: Fix handling of -> calls for modernize-use-emplace

2023-01-31 Thread Peter Wolf via Phabricator via cfe-commits
BigPeet updated this revision to Diff 493753.
BigPeet added a comment.

- additional deduplication of code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142939

Files:
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp
@@ -1334,3 +1334,90 @@
   v3.push_back({{0}});
   v3.push_back({{}});
 }
+
+void testWithPointerTypes() {
+  std::list l;
+  std::list* lp = 
+  std::stack s;
+  std::stack* sp;
+
+  lp->push_back(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_back(1, 2);
+  lp->push_front(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_front instead of push_front [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_front(1, 2);
+  sp->push(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace instead of push [modernize-use-emplace]
+  // CHECK-FIXES: sp->emplace(1, 2);
+
+  lp->push_back(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_back(1, 2);
+  lp->push_front(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_front instead of push_front [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_front(1, 2);
+  sp->push(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace instead of push [modernize-use-emplace]
+  // CHECK-FIXES: sp->emplace(1, 2);
+
+  lp->push_back(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_back();
+  lp->push_front(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_front instead of push_front [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_front();
+  sp->push(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace instead of push [modernize-use-emplace]
+  // CHECK-FIXES: sp->emplace();
+
+  lp->push_back(Something{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_back();
+  lp->push_front(Something{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_front instead of push_front [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_front();
+  sp->push(Something{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace instead of push [modernize-use-emplace]
+  // CHECK-FIXES: sp->emplace();
+
+  lp->emplace_back(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: unnecessary temporary object created while calling emplace_back
+  // CHECK-FIXES: lp->emplace_back(1, 2);
+  lp->emplace_front(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: unnecessary temporary object created while calling emplace_front
+  // CHECK-FIXES: lp->emplace_front(1, 2);
+  sp->emplace(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: unnecessary temporary object created while calling emplace
+  // CHECK-FIXES: sp->emplace(1, 2);
+
+  lp->emplace_back(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: unnecessary temporary object created while calling emplace_back
+  // CHECK-FIXES: lp->emplace_back(1, 2);
+  lp->emplace_front(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: unnecessary temporary object created while calling emplace_front
+  // CHECK-FIXES: lp->emplace_front(1, 2);
+  sp->emplace(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: unnecessary temporary object created while calling emplace
+  // CHECK-FIXES: sp->emplace(1, 2);
+
+  lp->emplace_back(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: unnecessary temporary object created while calling emplace_back
+  // CHECK-FIXES: lp->emplace_back();
+  lp->emplace_front(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: unnecessary temporary object created while calling emplace_front
+  // CHECK-FIXES: lp->emplace_front();
+  sp->emplace(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: unnecessary temporary object created while calling emplace
+  // CHECK-FIXES: sp->emplace();
+
+  lp->emplace_back(Something{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: unnecessary temporary object created while calling emplace_back
+  // CHECK-FIXES: lp->emplace_back();
+  lp->emplace_front(Something{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: unnecessary temporary object created while 

[PATCH] D140897: [clang][dataflow] Fix handling of `DeclRefExpr`s to `BindingDecl`s.

2023-01-31 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

I hope we will be able to get rid of this `SkipPast` thing at some point by 
looking at the value categories of the AST instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140897

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


[PATCH] D141625: [DeclContext] Sort the Decls before adding into DeclContext

2023-01-31 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

In D141625#4094837 , @dblaikie wrote:

> In D141625#4094742 , @steven_wu 
> wrote:
>
>> In D141625#4067225 , @dblaikie 
>> wrote:
>>
>>> In D141625#4066961 , @steven_wu 
>>> wrote:
>>>
 No, reverse iteration will not break diff test for a small number of 
 decls. Everything will be in reverse order so it is the same.
>>>
>>> Hmm, I'm not sure I'm following why that is - could you explain this in 
>>> more detail? The usual problem is that, say, we're outputting based on an 
>>> unstable order - even two items would be enough to cause a test of that to 
>>> fail in either forward or reverse iteration mode until the order is 
>>> stabilized.
>>>
>>> Is that not the case here? Is there some interaction between iteration 
>>> order that's part of the nondeterminism here?
>>
>> In order to make a test that will break before the change with reverse 
>> iteration, the test needs to check that the decls/records are serialized 
>> into the module in a pre deterministic order. It can't be just diff the 
>> output of two runs with a small input because small input will not overflow 
>> the smallptrset, thus the reverse iteration outputs from two runs will very 
>> likely to be identical, just in a different order from forward iteration.
>
> Sure, I think I'm with you there - but the current test checks that the 
> decls/records are serialized into the module in a pre-deterministic order, 
> right? So it doesn't seem like a reverse iteration-failing test would be more 
> involved/brittle/less robust than the test being added here?

Yes, exactly, I added file check so that this test is going to fail for reverse 
iteration. What I also want is keep the size of the test case since it not 
really enormous so this test also has a good chance of failing without reverse 
iteration.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141625

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


[PATCH] D142939: Fix handling of -> calls for modernize-use-emplace

2023-01-31 Thread Peter Wolf via Phabricator via cfe-commits
BigPeet updated this revision to Diff 493745.
BigPeet added a comment.

- reducing code repitition + further tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142939

Files:
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp
@@ -1334,3 +1334,90 @@
   v3.push_back({{0}});
   v3.push_back({{}});
 }
+
+void testWithPointerTypes() {
+  std::list l;
+  std::list* lp = 
+  std::stack s;
+  std::stack* sp;
+
+  lp->push_back(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_back(1, 2);
+  lp->push_front(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_front instead of push_front [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_front(1, 2);
+  sp->push(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace instead of push [modernize-use-emplace]
+  // CHECK-FIXES: sp->emplace(1, 2);
+
+  lp->push_back(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_back(1, 2);
+  lp->push_front(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_front instead of push_front [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_front(1, 2);
+  sp->push(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace instead of push [modernize-use-emplace]
+  // CHECK-FIXES: sp->emplace(1, 2);
+
+  lp->push_back(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_back();
+  lp->push_front(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_front instead of push_front [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_front();
+  sp->push(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace instead of push [modernize-use-emplace]
+  // CHECK-FIXES: sp->emplace();
+
+  lp->push_back(Something{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_back instead of push_back [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_back();
+  lp->push_front(Something{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_front instead of push_front [modernize-use-emplace]
+  // CHECK-FIXES: lp->emplace_front();
+  sp->push(Something{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace instead of push [modernize-use-emplace]
+  // CHECK-FIXES: sp->emplace();
+
+  lp->emplace_back(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: unnecessary temporary object created while calling emplace_back
+  // CHECK-FIXES: lp->emplace_back(1, 2);
+  lp->emplace_front(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: unnecessary temporary object created while calling emplace_front
+  // CHECK-FIXES: lp->emplace_front(1, 2);
+  sp->emplace(Something(1, 2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: unnecessary temporary object created while calling emplace
+  // CHECK-FIXES: sp->emplace(1, 2);
+
+  lp->emplace_back(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: unnecessary temporary object created while calling emplace_back
+  // CHECK-FIXES: lp->emplace_back(1, 2);
+  lp->emplace_front(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: unnecessary temporary object created while calling emplace_front
+  // CHECK-FIXES: lp->emplace_front(1, 2);
+  sp->emplace(Something{1, 2});
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: unnecessary temporary object created while calling emplace
+  // CHECK-FIXES: sp->emplace(1, 2);
+
+  lp->emplace_back(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: unnecessary temporary object created while calling emplace_back
+  // CHECK-FIXES: lp->emplace_back();
+  lp->emplace_front(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: unnecessary temporary object created while calling emplace_front
+  // CHECK-FIXES: lp->emplace_front();
+  sp->emplace(Something());
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: unnecessary temporary object created while calling emplace
+  // CHECK-FIXES: sp->emplace();
+
+  lp->emplace_back(Something{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: unnecessary temporary object created while calling emplace_back
+  // CHECK-FIXES: lp->emplace_back();
+  lp->emplace_front(Something{});
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: unnecessary temporary object created 

[PATCH] D142710: [clang][dataflow] Relax validity assumptions in `UncheckedOptionalAccessModel`.

2023-01-31 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

This change looks good to me. I wonder, however, whether the behavior should be 
parameterized in the future. E.g., whether the user of the analysis should be 
able to make a decision whether the analysis should be pessimistic or 
optimistic about unmodeled values.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142710

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


[PATCH] D143021: [OpenMP 5.2] Deprecate 'destroy' clause without argument for 'depobj' construct

2023-01-31 Thread Fazlay Rabbi via Phabricator via cfe-commits
mdfazlay created this revision.
mdfazlay added reviewers: ABataev, mikerice, jdoerfert.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
mdfazlay requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Deprecate and diagnose uses of the 'destroy' clauses without an argument in 
'omp depobj' directives.

Note that an error is given for deprecated features (rather than a warning).

Reference: 
(1) OpenMP 5.2 Sepec: Section 3.5, Page 73
(2) OpenMP 5.2 spec: Sec B.2 line 13, Page 626


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143021

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/depobj_messages.cpp


Index: clang/test/OpenMP/depobj_messages.cpp
===
--- clang/test/OpenMP/depobj_messages.cpp
+++ clang/test/OpenMP/depobj_messages.cpp
@@ -2,11 +2,15 @@
 // RUN: -ferror-limit 100 %s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,omp51 -fopenmp -fopenmp-version=51 \
 // RUN: -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 \
+// RUN: -ferror-limit 100 %s -Wuninitialized
 
 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -fopenmp-version=50 \
 // RUN: -ferror-limit 100 %s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,omp51 -fopenmp-simd -fopenmp-version=51 \
 // RUN: -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 \
+// RUN: -ferror-limit 100 %s -Wuninitialized
 
 struct S1 { // expected-note 2 {{declared here}}
   int a;
@@ -27,7 +31,7 @@
 #pragma omp depobj(x) untied  // expected-error {{unexpected OpenMP clause 
'untied' in directive '#pragma omp depobj'}}
 #pragma omp depobj(x) unknown // expected-warning {{extra tokens at the end of 
'#pragma omp depobj' are ignored}}
   if (argc)
-#pragma omp depobj(x) destroy // expected-error {{'#pragma omp depobj' cannot 
be an immediate substatement}}
+#pragma omp depobj(x) destroy // omp52-error {{'destroy' clause without 
argument on '#pragma omp depobj' construct is deprecated since OpenMP 5.2}} 
expected-error {{'#pragma omp depobj' cannot be an immediate substatement}}
 if (argc) {
 #pragma omp depobj(x) depend(in:s)
 }
@@ -148,16 +152,16 @@
 #pragma omp parallel depobj(argc) // expected-warning {{extra tokens at the 
end of '#pragma omp parallel' are ignored}}
   ;
 #pragma omp depobj(x) seq_cst // expected-error {{unexpected OpenMP clause 
'seq_cst' in directive '#pragma omp depobj'}}
-#pragma omp depobj(x) depend(source: x) // omp51-error {{expected depend 
modifier(iterator) or 'in', 'out', 'inout', 'mutexinoutset' or 'inoutset' in 
OpenMP clause 'depend'}} omp50-error {{expected depend modifier(iterator) or 
'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}}
+#pragma omp depobj(x) depend(source: x) // omp52-error {{expected depend 
modifier(iterator) or 'in', 'out', 'inout', 'mutexinoutset' or 'inoutset' in 
OpenMP clause 'depend'}} omp51-error {{expected depend modifier(iterator) or 
'in', 'out', 'inout', 'mutexinoutset' or 'inoutset' in OpenMP clause 'depend'}} 
omp50-error {{expected depend modifier(iterator) or 'in', 'out', 'inout' or 
'mutexinoutset' in OpenMP clause 'depend'}}
 #pragma omp depobj(x) update // expected-error {{expected '(' after 'update'}}
-#pragma omp depobj(x) update( // expected-error {{expected ')'}} expected-note 
{{to match this '('}} omp51-error {{expected 'in', 'out', 'inout', 
'mutexinoutset' or 'inoutset' in OpenMP clause 'update'}} omp50-error 
{{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'update'}}
-#pragma omp depobj(x) update(sink // expected-error {{expected ')'}} 
expected-note {{to match this '('}} omp51-error {{expected 'in', 'out', 
'inout', 'mutexinoutset' or 'inoutset' in OpenMP clause 'update'}} omp50-error 
{{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'update'}}
-#pragma omp depobj(x) destroy destroy // expected-error {{directive '#pragma 
omp depobj' cannot contain more than one 'destroy' clause}}
+#pragma omp depobj(x) update( // expected-error {{expected ')'}} expected-note 
{{to match this '('}} omp52-error {{expected 'in', 'out', 'inout', 
'mutexinoutset' or 'inoutset' in OpenMP clause 'update'}} omp51-error 
{{expected 'in', 'out', 'inout', 'mutexinoutset' or 'inoutset' in OpenMP clause 
'update'}} omp50-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in 
OpenMP clause 'update'}}
+#pragma omp depobj(x) update(sink // expected-error {{expected ')'}} 
expected-note {{to match this '('}} omp52-error {{expected 'in', 'out', 
'inout', 'mutexinoutset' or 'inoutset' in OpenMP clause 'update'}} omp51-error 
{{expected 'in', 'out', 'inout', 'mutexinoutset' or 'inoutset' in OpenMP clause 
'update'}} omp50-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in 

[PATCH] D139395: Add CFI integer types normalization

2023-01-31 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139395

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


[PATCH] D139395: Add CFI integer types normalization

2023-01-31 Thread Ramon de C Valle via Phabricator via cfe-commits
rcvalle marked 4 inline comments as done.
rcvalle added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1694
+  getCXXABI().getMangleContext().mangleTypeName(
+  T, Out, !!getCodeGenOpts().SanitizeCfiICallNormalizeIntegers);
+

pcc wrote:
> Is the !! necessary here?
Fixed. Thank you!



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:6881
+getCXXABI().getMangleContext().mangleTypeName(
+T, Out, !!getCodeGenOpts().SanitizeCfiICallNormalizeIntegers);
+

pcc wrote:
> Likewise
Fixed. Thank you!



Comment at: clang/test/CodeGen/cfi-icall-normalize.c:55-75
+// CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFv{{u2i8|u2u8}}E.normalized"}
+// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFv{{u2i8S_|u2u8u2i8}}E.normalized"}
+// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFv{{u2i8S_S_|u2u8u2i8S0_}}E.normalized"}
+// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}E.normalized"}
+// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}S_E.normalized"}
+// CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}S_S_E.normalized"}
+// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFv{{u3i32|u3i64}}E.normalized"}

pcc wrote:
> Shouldn't these all be checking for specific types? Since you're specifying a 
> triple, the width and signedness of the integer types are fixed.
Fixed. Thank you!



Comment at: clang/test/CodeGen/cfi-icall-normalize2.c:9
+// CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}}
+// CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata 
!"_ZTSFv{{u3i16|u3i32|u3i64}}E.normalized")
+fn(arg);

pcc wrote:
> Likewise; also below
Fixed. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139395

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


[PATCH] D141625: [DeclContext] Sort the Decls before adding into DeclContext

2023-01-31 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D141625#4094742 , @steven_wu wrote:

> In D141625#4067225 , @dblaikie 
> wrote:
>
>> In D141625#4066961 , @steven_wu 
>> wrote:
>>
>>> No, reverse iteration will not break diff test for a small number of decls. 
>>> Everything will be in reverse order so it is the same.
>>
>> Hmm, I'm not sure I'm following why that is - could you explain this in more 
>> detail? The usual problem is that, say, we're outputting based on an 
>> unstable order - even two items would be enough to cause a test of that to 
>> fail in either forward or reverse iteration mode until the order is 
>> stabilized.
>>
>> Is that not the case here? Is there some interaction between iteration order 
>> that's part of the nondeterminism here?
>
> In order to make a test that will break before the change with reverse 
> iteration, the test needs to check that the decls/records are serialized into 
> the module in a pre deterministic order. It can't be just diff the output of 
> two runs with a small input because small input will not overflow the 
> smallptrset, thus the reverse iteration outputs from two runs will very 
> likely to be identical, just in a different order from forward iteration.

Sure, I think I'm with you there - but the current test checks that the 
decls/records are serialized into the module in a pre-deterministic order, 
right? So it doesn't seem like a reverse iteration-failing test would be more 
involved/brittle/less robust than the test being added here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141625

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


[PATCH] D139395: Add CFI integer types normalization

2023-01-31 Thread Ramon de C Valle via Phabricator via cfe-commits
rcvalle updated this revision to Diff 493732.
rcvalle marked an inline comment as done.
rcvalle added a comment.

Changed as per review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139395

Files:
  clang/docs/ControlFlowIntegrity.rst
  clang/docs/UsersManual.rst
  clang/include/clang/AST/Mangle.h
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/cfi-icall-normalize.c
  clang/test/CodeGen/cfi-icall-normalize2.c
  clang/test/CodeGen/kcfi-normalize.c

Index: clang/test/CodeGen/kcfi-normalize.c
===
--- /dev/null
+++ clang/test/CodeGen/kcfi-normalize.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=kcfi -fsanitize-cfi-icall-experimental-normalize-integers -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=kcfi -fsanitize-cfi-icall-experimental-normalize-integers -x c++ -o - %s | FileCheck %s
+#if !__has_feature(kcfi)
+#error Missing kcfi?
+#endif
+
+// Test that normalized type metadata for functions are emitted for cross-language KCFI support with
+// other languages that can't represent and encode C/C++ integer types.
+
+void foo(void (*fn)(int), int arg) {
+// CHECK-LABEL: define{{.*}}foo
+// CHECK-SAME: {{.*}}!kcfi_type ![[TYPE1:[0-9]+]]
+// CHECK: call void %0(i32 noundef %1){{.*}}[ "kcfi"(i32 1162514891) ]
+fn(arg);
+}
+
+void bar(void (*fn)(int, int), int arg1, int arg2) {
+// CHECK-LABEL: define{{.*}}bar
+// CHECK-SAME: {{.*}}!kcfi_type ![[TYPE2:[0-9]+]]
+// CHECK: call void %0(i32 noundef %1, i32 noundef %2){{.*}}[ "kcfi"(i32 448046469) ]
+fn(arg1, arg2);
+}
+
+void baz(void (*fn)(int, int, int), int arg1, int arg2, int arg3) {
+// CHECK-LABEL: define{{.*}}baz
+// CHECK-SAME: {{.*}}!kcfi_type ![[TYPE3:[0-9]+]]
+// CHECK: call void %0(i32 noundef %1, i32 noundef %2, i32 noundef %3){{.*}}[ "kcfi"(i32 -2049681433) ]
+fn(arg1, arg2, arg3);
+}
+
+// CHECK: ![[TYPE1]] = !{i32 -1143117868}
+// CHECK: ![[TYPE2]] = !{i32 -460921415}
+// CHECK: ![[TYPE3]] = !{i32 -333839615}
Index: clang/test/CodeGen/cfi-icall-normalize2.c
===
--- /dev/null
+++ clang/test/CodeGen/cfi-icall-normalize2.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-icall -fsanitize-trap=cfi-icall -fsanitize-cfi-icall-experimental-normalize-integers -emit-llvm -o - %s | FileCheck %s
+
+// Test that normalized type metadata for functions are emitted for cross-language CFI support with
+// other languages that can't represent and encode C/C++ integer types.
+
+void foo(void (*fn)(int), int arg) {
+// CHECK-LABEL: define{{.*}}foo
+// CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}}
+// CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFvu3i32E.normalized")
+fn(arg);
+}
+
+void bar(void (*fn)(int, int), int arg1, int arg2) {
+// CHECK-LABEL: define{{.*}}bar
+// CHECK-SAME: {{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}}
+// CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFvu3i32S_E.normalized")
+fn(arg1, arg2);
+}
+
+void baz(void (*fn)(int, int, int), int arg1, int arg2, int arg3) {
+// CHECK-LABEL: define{{.*}}baz
+// CHECK-SAME: {{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}}
+// CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata !"_ZTSFvu3i32S_S_E.normalized")
+fn(arg1, arg2, arg3);
+}
+
+// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvPFvu3i32ES_E.normalized"}
+// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvPFvu3i32S_ES_S_E.normalized"}
+// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFvPFvu3i32S_S_ES_S_S_E.normalized"}
Index: clang/test/CodeGen/cfi-icall-normalize.c
===
--- /dev/null
+++ clang/test/CodeGen/cfi-icall-normalize.c
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-icall -fsanitize-trap=cfi-icall -fsanitize-cfi-icall-experimental-normalize-integers -emit-llvm -o - %s | FileCheck %s
+
+// Test that integer types are normalized for cross-language CFI support with
+// other languages that can't represent and encode C/C++ integer types.
+
+void foo0(char arg) { }
+// CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] !type !{{[0-9]+}}
+void foo1(char arg1, signed char arg2) { }
+// CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}}
+void foo2(char arg1, signed char arg2, signed char arg3) { }
+// CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}}
+void foo3(int arg) { }
+// CHECK: 

[PATCH] D137107: Allow MS extension: support of constexpr with __declspec(dllimport).

2023-01-31 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 493726.

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

https://reviews.llvm.org/D137107

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGenCXX/PR19955.cpp
  clang/test/CodeGenCXX/aix-static-init.cpp
  clang/test/CodeGenCXX/call-conv-thru-alias.cpp
  clang/test/CodeGenCXX/const-init-cxx11.cpp
  clang/test/CodeGenCXX/constant-init.cpp
  clang/test/CodeGenCXX/ctor-dtor-alias.cpp
  clang/test/CodeGenCXX/cxx11-thread-local.cpp
  clang/test/CodeGenCXX/cxx1z-initializer-aggregate.cpp
  clang/test/CodeGenCXX/cxx2a-thread-local-constinit.cpp
  clang/test/CodeGenCXX/dllimport.cpp
  clang/test/CodeGenCXX/dso-handle-custom.cpp
  clang/test/CodeGenCXX/funcattrs-global-ctor-dtor.cpp
  clang/test/CodeGenCXX/no_destroy.cpp
  clang/test/CodeGenCXX/non-const-init-cxx2a.cpp
  clang/test/CodeGenCXX/static-destructor.cpp
  clang/test/CodeGenOpenCLCXX/atexit.clcpp
  clang/test/SemaCXX/PR19955.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/dllimport-constexpr.cpp

Index: clang/test/SemaCXX/dllimport-constexpr.cpp
===
--- clang/test/SemaCXX/dllimport-constexpr.cpp
+++ clang/test/SemaCXX/dllimport-constexpr.cpp
@@ -40,7 +40,6 @@
 // constexpr initialization doesn't work for dllimport things.
 // expected-error@+1{{must be initialized by a constant expression}}
 constexpr void (*constexpr_import_func)() = _func;
-// expected-error@+1{{must be initialized by a constant expression}}
 constexpr int *constexpr_import_int = _int;
 // expected-error@+1{{must be initialized by a constant expression}}
 constexpr void (Foo::*constexpr_memptr)() = ::imported_method;
@@ -60,3 +59,11 @@
   // expected-note@+1 {{requested here}}
   StaticConstexpr::g_fp();
 }
+
+extern int __declspec(dllimport) val;
+constexpr int& val_ref = val;
+
+void assigndllimporttoconst () {
+  extern int _declspec(dllimport) val;
+  constexpr int& val_ref = val;
+}
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -1596,7 +1596,7 @@
   void f(int k) { // expected-note {{here}}
 int arr[k]; // expected-warning {{C99}} expected-note {{function parameter 'k'}}
 constexpr int n = 1 +
-sizeof(arr) // expected-error {{constant expression}}
+sizeof(arr) // expected-error{{constexpr variable 'n' must be initialized by a constant expression}}
 * 3;
   }
 }
Index: clang/test/SemaCXX/PR19955.cpp
===
--- clang/test/SemaCXX/PR19955.cpp
+++ clang/test/SemaCXX/PR19955.cpp
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -triple i686-mingw32 -verify -std=c++11 %s
 
 extern int __attribute__((dllimport)) var;
-constexpr int *varp =  // expected-error {{must be initialized by a constant expression}}
+constexpr int *varp = 
 
 extern __attribute__((dllimport)) void fun();
 constexpr void (*funp)(void) =  // expected-error {{must be initialized by a constant expression}}
Index: clang/test/CodeGenOpenCLCXX/atexit.clcpp
===
--- clang/test/CodeGenOpenCLCXX/atexit.clcpp
+++ clang/test/CodeGenOpenCLCXX/atexit.clcpp
@@ -5,7 +5,7 @@
 };
 S s;
 
-//CHECK-LABEL: define internal spir_func void @__cxx_global_var_init()
+//CHECK-LABEL: define internal spir_func void @__ctor()
 //CHECK: call spir_func i32 @__cxa_atexit(ptr @_ZNU3AS41SD1Ev, ptr null, ptr addrspace(1) @__dso_handle)
 
 //CHECK: declare spir_func i32 @__cxa_atexit(ptr, ptr, ptr addrspace(1))
Index: clang/test/CodeGenCXX/static-destructor.cpp
===
--- clang/test/CodeGenCXX/static-destructor.cpp
+++ clang/test/CodeGenCXX/static-destructor.cpp
@@ -16,17 +16,17 @@
 Foo global;
 
 // X86 destructors have void return, and are registered directly with __cxa_atexit.
-// X86: define internal void @__cxx_global_var_init()
+// X86: define internal void @__dtor()
 // X86:   call i32 @__cxa_atexit(ptr @_ZN3FooD1Ev, ptr @global, ptr @__dso_handle)
 
 // ARM destructors return this, but can be registered directly with __cxa_atexit
 // because the calling conventions tolerate the mismatch.
-// ARM: define internal void @__cxx_global_var_init()
+// ARM: define internal void @__dtor()
 // ARM:   call i32 @__cxa_atexit(ptr @_ZN3FooD1Ev, ptr @global, ptr @__dso_handle)
 
 // Wasm destructors return this, and use a wrapper function, which is registered
 // with __cxa_atexit.
-// WASM: define internal void @__cxx_global_var_init()
+// WASM: define internal void @__dtor()
 // WASM: 

[PATCH] D139052: [NFC][Profile] Access profile through VirtualFileSystem

2023-01-31 Thread Steven Wu via Phabricator via cfe-commits
steven_wu updated this revision to Diff 493724.
steven_wu added a comment.

Rebase to main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139052

Files:
  clang/include/clang/CodeGen/BackendUtil.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/CodeGen/MIRSampleProfile.h
  llvm/include/llvm/CodeGen/Passes.h
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
  llvm/include/llvm/ProfileData/InstrProfReader.h
  llvm/include/llvm/ProfileData/SampleProfReader.h
  llvm/include/llvm/Support/PGOOptions.h
  llvm/include/llvm/Transforms/IPO/SampleProfile.h
  llvm/include/llvm/Transforms/Instrumentation/PGOInstrumentation.h
  llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
  llvm/lib/CodeGen/MIRSampleProfile.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Passes/PassBuilderPipelines.cpp
  llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/ProfileData/InstrProfReader.cpp
  llvm/lib/ProfileData/SampleProfReader.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/PGOOptions.cpp
  llvm/lib/Target/X86/X86InsertPrefetch.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/tools/llvm-cov/CodeCoverage.cpp
  llvm/tools/llvm-profdata/llvm-profdata.cpp
  llvm/tools/llvm-profgen/llvm-profgen.cpp
  llvm/tools/opt/NewPMDriver.cpp
  llvm/unittests/ProfileData/SampleProfTest.cpp

Index: llvm/unittests/ProfileData/SampleProfTest.cpp
===
--- llvm/unittests/ProfileData/SampleProfTest.cpp
+++ llvm/unittests/ProfileData/SampleProfTest.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Testing/Support/SupportHelpers.h"
 #include "gtest/gtest.h"
@@ -57,8 +58,9 @@
 
   void readProfile(const Module , StringRef Profile,
StringRef RemapFile = "") {
+auto FS = vfs::getRealFileSystem();
 auto ReaderOrErr = SampleProfileReader::create(
-std::string(Profile), Context, FSDiscriminatorPass::Base,
+std::string(Profile), Context, *FS, FSDiscriminatorPass::Base,
 std::string(RemapFile));
 ASSERT_TRUE(NoError(ReaderOrErr.getError()));
 Reader = std::move(ReaderOrErr.get());
Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -31,6 +31,7 @@
 #include "llvm/Passes/StandardInstrumentations.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ToolOutputFile.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
@@ -333,22 +334,25 @@
bool EnableDebugify, bool VerifyDIPreserve) {
   bool VerifyEachPass = VK == VK_VerifyEachPass;
 
+  auto FS = vfs::getRealFileSystem();
   std::optional P;
   switch (PGOKindFlag) {
   case InstrGen:
-P = PGOOptions(ProfileFile, "", "", PGOOptions::IRInstr);
+P = PGOOptions(ProfileFile, "", "", FS, PGOOptions::IRInstr);
 break;
   case InstrUse:
-P = PGOOptions(ProfileFile, "", ProfileRemappingFile, PGOOptions::IRUse);
+P = PGOOptions(ProfileFile, "", ProfileRemappingFile, FS,
+   PGOOptions::IRUse);
 break;
   case SampleUse:
-P = PGOOptions(ProfileFile, "", ProfileRemappingFile,
+P = PGOOptions(ProfileFile, "", ProfileRemappingFile, FS,
PGOOptions::SampleUse);
 break;
   case NoPGO:
 if (DebugInfoForProfiling || PseudoProbeForProfiling)
-  P = PGOOptions("", "", "", PGOOptions::NoAction, PGOOptions::NoCSAction,
- DebugInfoForProfiling, PseudoProbeForProfiling);
+  P = PGOOptions("", "", "", nullptr, PGOOptions::NoAction,
+ PGOOptions::NoCSAction, DebugInfoForProfiling,
+ PseudoProbeForProfiling);
 else
   P = std::nullopt;
   }
@@ -367,7 +371,7 @@
 P->CSAction = PGOOptions::CSIRInstr;
 P->CSProfileGenFile = CSProfileGenFile;
   } else
-P = PGOOptions("", CSProfileGenFile, ProfileRemappingFile,
+P = PGOOptions("", CSProfileGenFile, ProfileRemappingFile, FS,
PGOOptions::NoAction, PGOOptions::CSIRInstr);
 } else /* CSPGOKindFlag == CSInstrUse */ {
   if (!P) {
Index: llvm/tools/llvm-profgen/llvm-profgen.cpp

[PATCH] D141907: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected

2023-01-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

edeaf16f2c2f02d6e43312d48d26d354d87913f3 (2011) added the CMake variable 
`CLANG_RESOURCE_DIR` but did not explain why. 
The patch introduced conditions in C++ code like

  std::string path_to_clang_dir = std::string(CLANG_RESOURCE_DIR).empty()
  ? "/foo/bar/" LLDB_INSTALL_LIBDIR_BASENAME
"/clang/" CLANG_VERSION_MAJOR_STRING
  : "/foo/bar/bin/" CLANG_RESOURCE_DIR;

which makes me uncomfortable.

I wish that we can just replace all places that construct 
`CLANG_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_MAJOR_STRING` manually 
with a simple `CLANG_RESOURCE_DIR` which is guaranteed to be non-empty.

In the long term, the CMake variable `CLANG_RESOURCE_DIR` probably should be 
removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141907

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


[PATCH] D141625: [DeclContext] Sort the Decls before adding into DeclContext

2023-01-31 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

In D141625#4067225 , @dblaikie wrote:

> In D141625#4066961 , @steven_wu 
> wrote:
>
>> No, reverse iteration will not break diff test for a small number of decls. 
>> Everything will be in reverse order so it is the same.
>
> Hmm, I'm not sure I'm following why that is - could you explain this in more 
> detail? The usual problem is that, say, we're outputting based on an unstable 
> order - even two items would be enough to cause a test of that to fail in 
> either forward or reverse iteration mode until the order is stabilized.
>
> Is that not the case here? Is there some interaction between iteration order 
> that's part of the nondeterminism here?

In order to make a test that will break before the change with reverse 
iteration, the test needs to check that the decls/records are serialized into 
the module in a pre deterministic order. It can't be just diff the output of 
two runs with a small input because small input will not overflow the 
smallptrset, thus the reverse iteration outputs from two runs will very likely 
to be identical, just in a different order from forward iteration.

It is also in the same time not easy to write a test that can check the pre 
deterministic order of the serialization because it is hard to identify which 
entry is which decl from the output of bcanalyzer. For example, an entry like 
`` means nothing 
just looking at itself. Even worse, the opcode I check `op13` in the test is 
assigned via iteration order and decls are serialized via iteration order. So 
all the entries will always kind of appear in ascending order.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141625

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


[PATCH] D141861: [nvptx-arch] Dynamically load the CUDA runtime if not found during the build

2023-01-31 Thread Steven Johnson via Phabricator via cfe-commits
srj added a comment.

In D141861#4094238 , @srj wrote:

> In D141861#4094084 , @srj wrote:
>
>> In D141861#4094079 , @jhuber6 
>> wrote:
>>
>>> In D141861#4094063 , @srj wrote:
>>>
 Yes please!
>>>
>>> Let me know if this fixes anything rG9f64fbb882dc 
>>> .
>>
>> Testing now
>
> So far, so good, let me just verify a few more things

Looks good! Thanks for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141861

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


[PATCH] D142384: [C++20] Fix a crash with modules.

2023-01-31 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/include/clang/AST/DeclCXX.h:557-560
+  RecordDecl::field_iterator field_begin() const {
+assert(hasDefinition() && "Definition not available to get fields.");
+return static_cast(getDefinition())->field_begin();
+  }

This change makes me nervous: calling `field_begin` / `fields` on a 
`CXXRecordDecl*` will now work, but calling those same functions on the same 
object that has been cast to `RecordDecl*` will still be broken. Can we change 
the accessors in the base class instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142384

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


[clang] eb469c2 - Fix Clang sphinx build

2023-01-31 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-01-31T15:42:07-05:00
New Revision: eb469c2751227f789db40c75fae2143d313c91be

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

LOG: Fix Clang sphinx build

This addresses the issue found by:
https://lab.llvm.org/buildbot/#/builders/92/builds/39458

and it also fixes a follow-on error with building the RST.

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index b0b11e85ab6a..eebbf6863dd4 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -6275,6 +6275,7 @@ attribute requires a string literal argument to identify 
the handle being releas
 }
 
 def UnsafeBufferUsageDocs : Documentation {
+  let Category = DocCatFunction;
   let Content = [{
 The attribute ``[[clang::unsafe_buffer_usage]]`` should be placed on functions
 that need to be avoided as they are prone to buffer overflows. It is designed 
to
@@ -6295,6 +6296,7 @@ would make sense to put the attribute on function 
``foo()`` below because
 passing an incorrect size parameter would cause a buffer overflow:
 
 .. code-block:: c++
+
   [[clang::unsafe_buffer_usage]]
   void foo(int *buf, size_t size) {
 for (size_t i = 0; i < size; ++i) {



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


[PATCH] D140489: Add builtin_elementwise_log

2023-01-31 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM. This looks pretty straightforward and similar to other changes you've 
been making.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140489

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


[PATCH] D142939: Fix handling of -> calls for modernize-use-emplace

2023-01-31 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank accepted this revision.
nicovank added a comment.
This revision is now accepted and ready to land.

This is becoming repetitive, but I guess that's the nature of those things. 
Maybe something like this would help clean it up, not sure if any better for 
right now.

  template  // Lambda templates would have been nice.
  auto onTypeOrPointerType(const T ) { // onUnderlyingType ?
return on(anyOf(hasType(Type), hasType(pointerType(pointee(Type);
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142939

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


[PATCH] D139774: [libclang] Add API to set temporary directory location

2023-01-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D139774#4092553 , @vedgy wrote:

> In D139774#4091631 , @aaron.ballman 
> wrote:
>
>> My preference is still for specific API names. If we want to do something 
>> general to all temp files, I think `FileSystemOptions` is the way to go.
>>
>> My concern with not using a constructor is that, because this is the C API, 
>> we will be supporting the functionality for a long time even if we do switch 
>> to using a global override in `FileSystemOptions` where you would need to 
>> set the information up before executing the compiler. To me, these paths are 
>> something that should not be possible to change once the compiler has 
>> started executing. (That also solves the multithreading problem where 
>> multiple threads are fighting over what the temp directory should be and 
>> stepping on each other's toes.)
>
> As I understand, this leaves two choices:
>
> 1. Specific preamble API names, two separate non-constructor setters; the 
> option values are stored in a separate struct (or even as two separate data 
> members), not inside `FileSystemOptions`.
> 2. General temporary-storage arguments (possibly combined in a struct) to a 
> new overloaded constructor function; the option values are stored inside the 
> `FileSystemOptions` struct.
>
> The second alternative is likely more difficult to implement, more risky and 
> less convenient to use (the store-in-memory bool option cannot be modified at 
> any time). Perhaps it should be delayed until (and if) we learn of other 
> temporary files libclang creates? A downside of implementing the first option 
> now is that the specific API would have to be supported for a long time, even 
> after the general temporary-file API is implemented.

I still think the general solution is where we ultimately want to get to and 
that makes me hesitant to go with specific preamble API names despite that 
being the direction you prefer. If this wasn't the C APIs, I'd be less 
concerned because we make no stability guarantees about our C++ interfaces. But 
we try really hard not to break the C APIs, so adding the specific names is 
basically committing to not only the APIs but their semantics. I think that 
makes implementing the general solution slightly more awkward because these are 
weird special cases that barely get tested in-tree, so they'd be very easy to 
overlook and accidentally break.

Is there a middle ground where, instead of #2 for general temporary storage, we 
went with #2 but with compiler-specific directories instead of system 
directories. e.g., don't let the caller set the temp directory, but do let the 
caller set the preamble directory (which defaults to the temp directory) so 
long as it's set before invoking the compiler? This still won't let you change 
options mid-run, but it also seems like it should have less risk of affecting 
other components while still solving the thread safety issues. I'm not certain 
if it's any easier to implement, but I think it does save you from modifying 
`FileSystemOptions`. As a separate item, we could then consider adding a new C 
API to let you toggle the in-memory vs on-disk functionality after exploring 
that it won't cause other problems because nobody considered the possibility 
that it's not a stable value for the compiler invocation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139774

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


[PATCH] D142822: [clang] ASTImporter: Fix importing of va_list types and declarations

2023-01-31 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 493709.
vabridgers added a comment.

rebase, bump review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142822

Files:
  clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
  clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/cert/dcl58-cpp.cpp
  clang/docs/ReleaseNotes.rst
  clang/lib/Frontend/ASTMerge.cpp
  clang/lib/Sema/Sema.cpp
  clang/test/AST/ast-dump-file-line-json.c
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/AST/ast-dump-record-definition-data-json.cpp
  clang/test/AST/ast-dump-records-json.cpp
  clang/test/AST/ast-dump-records.cpp
  clang/test/AST/ast-dump-template-decls-json.cpp
  clang/test/AST/ast-dump-traits.cpp
  clang/test/AST/fixed_point.c
  clang/test/AST/float16.cpp
  clang/test/PCH/stmt-openmp_structured_block-bit.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1248,8 +1248,8 @@
 }
 )";
   Decl *FromTU = getTuDecl(Code, Lang_CXX03);
-  auto FromNs =
-  FirstDeclMatcher().match(FromTU, namespaceDecl());
+  auto FromNs = FirstDeclMatcher().match(
+  FromTU, namespaceDecl(hasName("x")));
   auto ToNs = cast(Import(FromNs, Lang_CXX03));
   ASSERT_TRUE(ToNs);
   auto From =
@@ -7561,7 +7561,14 @@
   }
   )",
   Lang_CXX14);
-  auto *FromFD = FirstDeclMatcher().match(FromTU, fieldDecl());
+
+  auto *FromF = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("declToImport")));
+  CXXRecordDecl *FromLambda =
+  cast((cast(FromF->getBody())->body_back()))
+  ->getLambdaClass();
+
+  auto *FromFD = *FromLambda->field_begin();
   ASSERT_TRUE(FromFD);
   ASSERT_TRUE(FromFD->hasCapturedVLAType());
 
@@ -8137,6 +8144,24 @@
   EXPECT_FALSE(SharedStatePtr->isNewDecl(ToBar));
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, VaList) {
+  Decl *FromTU = getTuDecl(R"(typedef __builtin_va_list va_list;)", Lang_C99);
+
+  auto *FromVaList = FirstDeclMatcher().match(
+  FromTU, typedefDecl(hasName("va_list")));
+  ASSERT_TRUE(FromVaList);
+
+  auto *ToVaList = Import(FromVaList, Lang_C99);
+  ASSERT_TRUE(ToVaList);
+
+  auto *ToBuiltinVaList = FirstDeclMatcher().match(
+  ToAST->getASTContext().getTranslationUnitDecl(),
+  typedefDecl(hasName("__builtin_va_list")));
+
+  ASSERT_TRUE(ToAST->getASTContext().hasSameType(
+  ToVaList->getUnderlyingType(), ToBuiltinVaList->getUnderlyingType()));
+}
+
 INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ASTImporterLookupTableTest,
  DefaultTestValuesForRunOptions);
 
Index: clang/test/PCH/stmt-openmp_structured_block-bit.cpp
===
--- clang/test/PCH/stmt-openmp_structured_block-bit.cpp
+++ clang/test/PCH/stmt-openmp_structured_block-bit.cpp
@@ -13,7 +13,7 @@
 // expected-no-diagnostics
 
 // CHECK: TranslationUnitDecl 0x{{.*}} <> 
-// CHECK: `-FunctionDecl 0x{{.*}} <{{.*}}stmt-openmp_structured_block-bit.cpp:8:1, line:11:1> line:8:6 {{(test|imported test)}} 'void ()'
+// CHECK:  -FunctionDecl 0x{{.*}} <{{.*}}stmt-openmp_structured_block-bit.cpp:8:1, line:11:1> line:8:6 {{(test|imported test)}} 'void ()'
 // CHECK-NEXT:   `-CompoundStmt 0x{{.*}} 
 // CHECK-NEXT: `-OMPParallelDirective 0x{{.*}} 
 // CHECK-NEXT:   `-CapturedStmt 0x{{.*}} 
Index: clang/test/AST/float16.cpp
===
--- clang/test/AST/float16.cpp
+++ clang/test/AST/float16.cpp
@@ -29,7 +29,7 @@
   }
 }
 
-//CHECK:  |-NamespaceDecl
+//CHECK:  |-NamespaceDecl {{.*}} <{{.*}}:22:1,
 //CHECK-NEXT: | |-VarDecl {{.*}} f1n '_Float16'
 //CHECK-NEXT: | |-VarDecl {{.*}} f2n '_Float16' cinit
 //CHECK-NEXT: | | `-FloatingLiteral {{.*}} '_Float16' 3.30e+01
Index: clang/test/AST/fixed_point.c
===
--- clang/test/AST/fixed_point.c
+++ clang/test/AST/fixed_point.c
@@ -402,5 +402,5 @@
 
 _Accum literallast = 1.0k;// One
 
-//CHECK-NEXT: `-VarDecl {{.*}} literallast '_Accum' cinit
+//CHECK-NEXT:  -VarDecl {{.*}} literallast '_Accum' cinit
 //CHECK-NEXT:   `-FixedPointLiteral {{.*}} '_Accum' 1.0
Index: clang/test/AST/ast-dump-traits.cpp
===
--- clang/test/AST/ast-dump-traits.cpp
+++ clang/test/AST/ast-dump-traits.cpp
@@ -52,7 +52,7 @@
 // CHECK-NEXT: | `-CompoundStmt {{.*}} 
 // CHECK-NEXT: |   `-CStyleCastExpr {{.*}}  'void' 
 // CHECK-NEXT: | `-ExpressionTraitExpr {{.*}}  'bool' __is_lvalue_expr
-// CHECK-NEXT: `-FunctionDecl {{.*}}  line:30:6{{( imported)?}} 

[PATCH] D142999: [Clang] Adjust PIC handling for the AMDGPU ToolChain

2023-01-31 Thread Joseph Huber 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 rG9271c5da434b: [Clang] Adjust PIC handling for the AMDGPU 
ToolChain (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142999

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/test/Driver/amdgcn-toolchain-pic.cl

Index: clang/test/Driver/amdgcn-toolchain-pic.cl
===
--- clang/test/Driver/amdgcn-toolchain-pic.cl
+++ clang/test/Driver/amdgcn-toolchain-pic.cl
@@ -1,7 +1,5 @@
-// RUN: %clang -### --target=amdgcn-- -mcpu=gfx803 %s 2>&1 | FileCheck %s
-// RUN: %clang -### --target=amdgcn-amd- -mcpu=gfx803 %s 2>&1 | FileCheck %s
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx803 %s 2>&1 | FileCheck %s
 // RUN: %clang -### --target=amdgcn-amd-amdpal -mcpu=gfx803 %s 2>&1 | FileCheck %s
 // RUN: %clang -### --target=amdgcn-amd-mesa3d -mcpu=gfx803 %s 2>&1 | FileCheck %s
 
-// CHECK: "-cc1"{{.*}} "-mrelocation-model" "pic" "-pic-level" "1"
+// CHECK: "-cc1"{{.*}} "-mrelocation-model" "pic" "-pic-level" "2"
Index: clang/lib/Driver/ToolChains/HIPAMD.cpp
===
--- clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -270,8 +270,7 @@
   const OptTable  = getDriver().getOpts();
 
   for (Arg *A : Args) {
-if (!shouldSkipArgument(A) &&
-!shouldSkipSanitizeOption(*this, Args, BoundArch, A))
+if (!shouldSkipSanitizeOption(*this, Args, BoundArch, A))
   DAL->append(A);
   }
 
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1418,10 +1418,6 @@
 }
   }
 
-  // AMDGPU-specific defaults for PIC.
-  if (Triple.getArch() == llvm::Triple::amdgcn)
-PIC = true;
-
   // The last argument relating to either PIC or PIE wins, and no
   // other argument is used. If the last argument is any flavor of the
   // '-fno-...' arguments, both PIC and PIE are disabled. Any PIE
Index: clang/lib/Driver/ToolChains/AMDGPU.h
===
--- clang/lib/Driver/ToolChains/AMDGPU.h
+++ clang/lib/Driver/ToolChains/AMDGPU.h
@@ -64,11 +64,11 @@
 
   bool IsMathErrnoDefault() const override { return false; }
   bool isCrossCompiling() const override { return true; }
-  bool isPICDefault() const override { return false; }
+  bool isPICDefault() const override { return true; }
   bool isPIEDefault(const llvm::opt::ArgList ) const override {
 return false;
   }
-  bool isPICDefaultForced() const override { return false; }
+  bool isPICDefaultForced() const override { return true; }
   bool SupportsProfiling() const override { return false; }
 
   llvm::opt::DerivedArgList *
@@ -97,9 +97,6 @@
   /// Needed for translating LTO options.
   const char *getDefaultLinker() const override { return "ld.lld"; }
 
-  /// Should skip argument.
-  bool shouldSkipArgument(const llvm::opt::Arg *Arg) const;
-
   /// Uses amdgpu-arch tool to get arch of the system GPU. Will return error
   /// if unable to find one.
   virtual Expected>
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -611,10 +611,8 @@
   if (!DAL)
 DAL = new DerivedArgList(Args.getBaseArgs());
 
-  for (Arg *A : Args) {
-if (!shouldSkipArgument(A))
-  DAL->append(A);
-  }
+  for (Arg *A : Args)
+DAL->append(A);
 
   checkTargetID(*DAL);
 
@@ -870,13 +868,6 @@
   return BCLibs;
 }
 
-bool AMDGPUToolChain::shouldSkipArgument(const llvm::opt::Arg *A) const {
-  Option O = A->getOption();
-  if (O.matches(options::OPT_fPIE) || O.matches(options::OPT_fpie))
-return true;
-  return false;
-}
-
 llvm::SmallVector
 ROCMToolChain::getCommonDeviceLibNames(const llvm::opt::ArgList ,
const std::string ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9271c5d - [Clang] Adjust PIC handling for the AMDGPU ToolChain

2023-01-31 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-01-31T14:31:10-06:00
New Revision: 9271c5da434b0827ad21f43013be287f3637a9b4

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

LOG: [Clang] Adjust PIC handling for the AMDGPU ToolChain

The AMDGPU target only emits shared libraries currently. This patch
changes the handling of the PIC level to be managed in the
AMDGPUToolChain rather than having a special case for it. This causes
`--target=amdgcn--` to no longer set the PIC. This should be an
acceptable change since that doesn't use a correct toolchain anyway.

Reviewed By: arsenm

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/AMDGPU.h
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/HIPAMD.cpp
clang/test/Driver/amdgcn-toolchain-pic.cl

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 5849e9cfdb9b5..52021901b9bf8 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -611,10 +611,8 @@ AMDGPUToolChain::TranslateArgs(const DerivedArgList , 
StringRef BoundArch,
   if (!DAL)
 DAL = new DerivedArgList(Args.getBaseArgs());
 
-  for (Arg *A : Args) {
-if (!shouldSkipArgument(A))
-  DAL->append(A);
-  }
+  for (Arg *A : Args)
+DAL->append(A);
 
   checkTargetID(*DAL);
 
@@ -870,13 +868,6 @@ RocmInstallationDetector::getCommonBitcodeLibs(
   return BCLibs;
 }
 
-bool AMDGPUToolChain::shouldSkipArgument(const llvm::opt::Arg *A) const {
-  Option O = A->getOption();
-  if (O.matches(options::OPT_fPIE) || O.matches(options::OPT_fpie))
-return true;
-  return false;
-}
-
 llvm::SmallVector
 ROCMToolChain::getCommonDeviceLibNames(const llvm::opt::ArgList ,
const std::string ,

diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.h 
b/clang/lib/Driver/ToolChains/AMDGPU.h
index cce70da6612ba..124a34e852e61 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.h
+++ b/clang/lib/Driver/ToolChains/AMDGPU.h
@@ -64,11 +64,11 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public 
Generic_ELF {
 
   bool IsMathErrnoDefault() const override { return false; }
   bool isCrossCompiling() const override { return true; }
-  bool isPICDefault() const override { return false; }
+  bool isPICDefault() const override { return true; }
   bool isPIEDefault(const llvm::opt::ArgList ) const override {
 return false;
   }
-  bool isPICDefaultForced() const override { return false; }
+  bool isPICDefaultForced() const override { return true; }
   bool SupportsProfiling() const override { return false; }
 
   llvm::opt::DerivedArgList *
@@ -97,9 +97,6 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public 
Generic_ELF {
   /// Needed for translating LTO options.
   const char *getDefaultLinker() const override { return "ld.lld"; }
 
-  /// Should skip argument.
-  bool shouldSkipArgument(const llvm::opt::Arg *Arg) const;
-
   /// Uses amdgpu-arch tool to get arch of the system GPU. Will return error
   /// if unable to find one.
   virtual Expected>

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 0883631dfe98f..24e95102f4f3d 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1418,10 +1418,6 @@ tools::ParsePICArgs(const ToolChain , const 
ArgList ) {
 }
   }
 
-  // AMDGPU-specific defaults for PIC.
-  if (Triple.getArch() == llvm::Triple::amdgcn)
-PIC = true;
-
   // The last argument relating to either PIC or PIE wins, and no
   // other argument is used. If the last argument is any flavor of the
   // '-fno-...' arguments, both PIC and PIE are disabled. Any PIE

diff  --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp 
b/clang/lib/Driver/ToolChains/HIPAMD.cpp
index a555fe5830e04..8c504d8439d67 100644
--- a/clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -270,8 +270,7 @@ HIPAMDToolChain::TranslateArgs(const 
llvm::opt::DerivedArgList ,
   const OptTable  = getDriver().getOpts();
 
   for (Arg *A : Args) {
-if (!shouldSkipArgument(A) &&
-!shouldSkipSanitizeOption(*this, Args, BoundArch, A))
+if (!shouldSkipSanitizeOption(*this, Args, BoundArch, A))
   DAL->append(A);
   }
 

diff  --git a/clang/test/Driver/amdgcn-toolchain-pic.cl 
b/clang/test/Driver/amdgcn-toolchain-pic.cl
index 47adb8815d317..acd5fe413ff71 100644
--- a/clang/test/Driver/amdgcn-toolchain-pic.cl
+++ b/clang/test/Driver/amdgcn-toolchain-pic.cl
@@ -1,7 +1,5 @@
-// RUN: %clang -### --target=amdgcn-- -mcpu=gfx803 %s 2>&1 | FileCheck %s
-// RUN: %clang -### --target=amdgcn-amd- -mcpu=gfx803 

[PATCH] D133392: [MTE] Add AArch64GlobalsTagging Pass

2023-01-31 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added a comment.

In D133392#4094524 , @dyung wrote:

> Hi @hctim, the test you added is failing on buildbots where AArch64 is not 
> built, can you either update the test to not require that backend, or mark 
> the test as requiring it?
>
> https://lab.llvm.org/buildbot/#/builders/139/builds/35253
>
>   error: unable to create target: 'No available targets are compatible with 
> triple "aarch64-unknown-linux-android31"'
>   1 error generated.

Thanks for the heads up. I've reverted and will test on my end before relanding.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133392

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


[clang] 15e33c6 - Revert "[MTE] Add AArch64GlobalsTagging Pass"

2023-01-31 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2023-01-31T12:25:58-08:00
New Revision: 15e33c699cefe0e8528ec661a2b6477f21b6cb10

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

LOG: Revert "[MTE] Add AArch64GlobalsTagging Pass"

This reverts commit 4edfcff71e150770675a19576f698c7bbe788ee2.

Broke the non-aarch64-containing target builds.
https://reviews.llvm.org/D133392 has more context.

Added: 


Modified: 
llvm/lib/CodeGen/GlobalMerge.cpp
llvm/lib/Target/AArch64/AArch64.h
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/AArch64/CMakeLists.txt
llvm/test/CodeGen/AArch64/O0-pipeline.ll
llvm/test/CodeGen/AArch64/O3-pipeline.ll

Removed: 
clang/test/CodeGen/memtag-globals-asm.cpp
llvm/lib/Target/AArch64/AArch64GlobalsTagging.cpp



diff  --git a/clang/test/CodeGen/memtag-globals-asm.cpp 
b/clang/test/CodeGen/memtag-globals-asm.cpp
deleted file mode 100644
index 0e9ab316cc185..0
--- a/clang/test/CodeGen/memtag-globals-asm.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-// RUN: %clang_cc1 -S -x c++ -std=c++11 -triple aarch64-linux-android31 \
-// RUN:   -fsanitize=memtag-globals -o %t.out %s
-// RUN: FileCheck %s --input-file=%t.out
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-A
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-B
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-C
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-D
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-E
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-F
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-G
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-H
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-I
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-J
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-K
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-L
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-M
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-N
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-O
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-P
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-Q
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-R
-
-// RUN: %clang_cc1 -O3 -S -x c++ -std=c++11 -triple aarch64-linux-android31 \
-// RUN:   -fsanitize=memtag-globals -o %t.out %s
-// RUN: FileCheck %s --input-file=%t.out
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-A
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-B
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-C
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-D
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-E
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-F
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-G
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-H
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-I
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-J
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-K
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-L
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-M
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-N
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-O
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-P
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-Q
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-R
-
-/// Ensure that emulated TLS also doesn't get sanitized.
-// RUN: %clang_cc1 -S -x c++ -std=c++11 -triple aarch64-linux-android31 \
-// RUN:   -fsanitize=memtag-globals -o - %s | FileCheck %s
-
-// CHECK-A: .memtag global_int
-// CHECK-A: .globl global_int
-// CHECK-A: .p2align 4, 0x0
-// CHECK-A: .size global_int, 16
-int global_int;
-// CHECK-B: .memtag _ZL9local_int
-// CHECK-B: .local _ZL9local_int
-// CHECK-B: .comm _ZL9local_int,16,16
-static int local_int;
-
-// CHECK-C: .memtag _ZL12local_buffer
-// CHECK-C: .local _ZL12local_buffer
-// CHECK-C: .comm _ZL12local_buffer,16,16
-static char local_buffer[16];
-// CHECK-D: .memtag _ZL22local_buffer_local_end
-// CHECK-D: .p2align 4, 0x0
-// CHECK-D: _ZL22local_buffer_local_end:
-// CHECK-D: .xword _ZL12local_buffer+16
-// CHECK-D: .size _ZL22local_buffer_local_end, 16
-static char* local_buffer_local_end = _buffer[16];
-// CHECK-E: .memtag local_buffer_global_end
-// CHECK-E: .globl local_buffer_global_end
-// CHECK-E  .p2align 4, 0x0
-// CHECK-E: 

[PATCH] D142822: [clang] ASTImporter: Fix importing of va_list types and declarations

2023-01-31 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers added subscribers: DavidSpickett, jrtc27.
vabridgers added a comment.

@DavidSpickett and/or @jrtc27 , I started with @mizvekov 's patch ( D136886 
) and attempted to address the problems with 
that patch on arm and aarch64. Is it possible for you to try testing this patch 
and/or commenting? Thank you. - Vince


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142822

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


[PATCH] D141910: [OpenMP][OMPIRBuilder]Move SIMD alignment calculation to LLVM Frontend

2023-01-31 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added a comment.

I've reverted this change from `main` branch, let me know if there's anything I 
can do to help with addressing the build issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141910

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


[PATCH] D142891: [clang-format] Recognize Verilog non-blocking assignment

2023-01-31 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/WhitespaceManager.cpp:839-846
 return Style.AlignConsecutiveAssignments.AlignCompound
? C.Tok->getPrecedence() == prec::Assignment
-   : C.Tok->is(tok::equal);
+   : C.Tok->is(tok::equal) ||
+ // In Verilog the '<=' is not a compound assignment,
+ // thus it is aligned even when the AlignCompound
+ // option is not set.
+ (Style.isVerilog() && C.Tok->is(tok::lessequal) &&

Do you need the extra case, or could you just activate `AlignCompound`?

If you do, can you please add parens, the precedence of `?` and `:` in 
combination with `||` is at least for me not 100% clear.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142891

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


[PATCH] D140803: [clang][Interp] Implement C++ Range-for loops

2023-01-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/AST/Interp/loops.cpp:278
+
+namespace RangeForLoop {
+  constexpr int localArray() {

tbaeder wrote:
> aaron.ballman wrote:
> > You should also add failure tests where the range-based for loop is not 
> > valid in a constant expression. Especially interesting cases would be ones 
> > involving lifetime problems, such as: https://godbolt.org/z/3EE7f8rdE
> Oof, that reproducer doesn't work right now for several reasons :/ Can you 
> come up with something simpler?
Not trivially, no. Also, that case is now fixed by https://wg21.link/p2644r0 
for C++23 due to lifetime extension that we probably don't model yet.


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

https://reviews.llvm.org/D140803

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


[PATCH] D133392: [MTE] Add AArch64GlobalsTagging Pass

2023-01-31 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

Hi @hctim, the test you added is failing on buildbots where AArch64 is not 
built, can you either update the test to not require that backend, or mark the 
test as requiring it?

https://lab.llvm.org/buildbot/#/builders/139/builds/35253

  error: unable to create target: 'No available targets are compatible with 
triple "aarch64-unknown-linux-android31"'
  1 error generated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133392

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


[PATCH] D142947: [hexagon] add a -mcabac flag

2023-01-31 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz accepted this revision.
kparzysz added a comment.
This revision is now accepted and ready to land.

The cxx tests passed for me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142947

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


[PATCH] D142277: [clang][Interp] Clear metadata when destroying locals

2023-01-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/Interp/EvalEmitter.cpp:260-261
+// local variable is used after being destroyed.
+InlineDescriptor  = *reinterpret_cast(B->rawData());
+std::memset(, 0, sizeof(InlineDescriptor));
   }

I'm not certain this is a good idea -- we've just deallocated `B` and then 
we're saying "cool, now get me your raw data so I can muck about with it".

The comments in `InterpState::deallocate()` say `// Free storage, if 
necessary.`, so this looks a lot like a use-after-free. Am I missing something?



Comment at: clang/lib/AST/Interp/InterpFrame.cpp:80-81
+// local variable is used after being destroyed.
+InlineDescriptor *ID = localInlineDesc(Local.Offset);
+std::memset(ID, 0, sizeof(InlineDescriptor));
   }

Same here as above.


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

https://reviews.llvm.org/D142277

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


[PATCH] D138940: [-Wunsafe-buffer-usage] Introduce the `unsafe_buffer_usage` attribute

2023-01-31 Thread Rashmi Mudduluru 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 rGacc3cc69e4d1: [-Wunsafe-buffer-usage] Introduce the 
unsafe_buffer_usage attribute (authored by t-rasmud).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138940

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaCXX/attr-unsafe-buffer-usage.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-function-attr.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-function-attr.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-function-attr.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -verify %s
+
+[[clang::unsafe_buffer_usage]]
+void deprecatedFunction3();
+
+void deprecatedFunction4(int z);
+
+void someFunction();
+
+[[clang::unsafe_buffer_usage]]
+void overloading(int* x);
+
+void overloading(char c[]);
+
+void overloading(int* x, int size);
+
+[[clang::unsafe_buffer_usage]]
+void deprecatedFunction4(int z);
+
+void caller(int z, int* x, int size, char c[]) {
+deprecatedFunction3(); // expected-warning{{function introduces unsafe buffer manipulation}}
+deprecatedFunction4(z); // expected-warning{{function introduces unsafe buffer manipulation}}
+someFunction();
+
+overloading(x); // expected-warning{{function introduces unsafe buffer manipulation}}
+overloading(x, size);
+overloading(c);
+}
+
+[[clang::unsafe_buffer_usage]]
+void overloading(char c[]);
+
+// Test variadics
+[[clang::unsafe_buffer_usage]]
+void testVariadics(int *ptr, ...);
+
+template
+[[clang::unsafe_buffer_usage]]
+T adder(T first, Args... args);
+
+template 
+void foo(T t) {}
+
+template<>
+[[clang::unsafe_buffer_usage]]
+void foo(int *t) {}
+
+void caller1(int *p, int *q) {
+testVariadics(p, q);  // expected-warning{{function introduces unsafe buffer manipulation}}
+adder(p, q);  // expected-warning{{function introduces unsafe buffer manipulation}}
+
+int x;
+foo(x);
+foo();  // expected-warning{{function introduces unsafe buffer manipulation}}
+}
+
+// Test virtual functions
+class BaseClass {
+public:
+[[clang::unsafe_buffer_usage]]
+virtual void func() {}
+
+virtual void func1() {}
+};
+
+class DerivedClass : public BaseClass {
+public:
+void func() {}
+
+[[clang::unsafe_buffer_usage]]
+void func1() {}
+};
+
+void testInheritance() {
+DerivedClass DC;
+DC.func();
+DC.func1();  // expected-warning{{function introduces unsafe buffer manipulation}}
+
+BaseClass *BC;
+BC->func();  // expected-warning{{function introduces unsafe buffer manipulation}}
+BC->func1();
+
+BC = 
+BC->func();  // expected-warning{{function introduces unsafe buffer manipulation}}
+BC->func1();
+}
Index: clang/test/SemaCXX/attr-unsafe-buffer-usage.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-unsafe-buffer-usage.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1  -fsyntax-only -verify %s
+
+// Function annotations.
+[[clang::unsafe_buffer_usage]]
+void f(int *buf, int size);
+void g(int *buffer [[clang::unsafe_buffer_usage("buffer")]], int size); // expected-warning {{'unsafe_buffer_usage' attribute only applies to functions}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -187,6 +187,7 @@
 // CHECK-NEXT: TestTypestate (SubjectMatchRule_function_is_member)
 // CHECK-NEXT: TrivialABI (SubjectMatchRule_record)
 // CHECK-NEXT: Uninitialized (SubjectMatchRule_variable_is_local)
+// CHECK-NEXT: UnsafeBufferUsage (SubjectMatchRule_function)
 // CHECK-NEXT: UseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: VecReturn (SubjectMatchRule_record)
 // CHECK-NEXT: VecTypeHint (SubjectMatchRule_function)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -8446,6 +8446,11 @@
   D->addAttr(Attr::Create(S.Context, Argument, AL));
 }
 
+template
+static void handleUnsafeBufferUsage(Sema , Decl *D, const ParsedAttr ) {
+  

[clang] acc3cc6 - [-Wunsafe-buffer-usage] Introduce the unsafe_buffer_usage attribute

2023-01-31 Thread Rashmi Mudduluru via cfe-commits

Author: Rashmi Mudduluru
Date: 2023-01-31T11:43:34-08:00
New Revision: acc3cc69e4d1c8e199fde51798a5a2a6edb35796

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

LOG: [-Wunsafe-buffer-usage] Introduce the unsafe_buffer_usage attribute

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

Added: 
clang/test/SemaCXX/attr-unsafe-buffer-usage.cpp
clang/test/SemaCXX/warn-unsafe-buffer-usage-function-attr.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Analysis/UnsafeBufferUsage.cpp
clang/lib/Sema/AnalysisBasedWarnings.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0a1197044a71a..c6139252e0c34 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -89,6 +89,11 @@ New Pragmas in Clang
 Attribute Changes in Clang
 --
 
+Introduced a new function attribute ``__attribute__((unsafe_buffer_usage))``
+to be worn by functions containing buffer operations that could cause out of
+bounds memory accesses. It emits warnings at call sites to such functions when
+the flag ``-Wunsafe-buffer-usage`` is enabled.
+
 Windows Support
 ---
 

diff  --git 
a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def 
b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
index d10d95e5b1ba7..78889da32b3b4 100644
--- a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
+++ b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
@@ -29,6 +29,7 @@ WARNING_GADGET(Increment)
 WARNING_GADGET(Decrement)
 WARNING_GADGET(ArraySubscript)
 WARNING_GADGET(PointerArithmetic)
+WARNING_GADGET(UnsafeBufferUsageAttr)
 
 #undef FIXABLE_GADGET
 #undef WARNING_GADGET

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index d449a2fe7f8f7..fc2c7f7e37f45 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3966,6 +3966,12 @@ def ReleaseHandle : InheritableParamAttr {
   let Documentation = [ReleaseHandleDocs];
 }
 
+def UnsafeBufferUsage : InheritableAttr {
+  let Spellings = [Clang<"unsafe_buffer_usage">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [UnsafeBufferUsageDocs];
+}
+
 def DiagnoseAsBuiltin : InheritableAttr {
   let Spellings = [Clang<"diagnose_as_builtin">];
   let Args = [DeclArgument,

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 6d7a3ffd2d52c..b0b11e85ab6ad 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -6274,6 +6274,82 @@ attribute requires a string literal argument to identify 
the handle being releas
   }];
 }
 
+def UnsafeBufferUsageDocs : Documentation {
+  let Content = [{
+The attribute ``[[clang::unsafe_buffer_usage]]`` should be placed on functions
+that need to be avoided as they are prone to buffer overflows. It is designed 
to
+work together with the off-by-default compiler warning 
``-Wunsafe-buffer-usage``
+to help codebases transition away from raw pointer based buffer management,
+in favor of safer abstractions such as C++20 ``std::span``. The attribute 
causes
+``-Wunsafe-buffer-usage`` to warn on every use of the function, and it may
+enable ``-Wunsafe-buffer-usage`` to emit automatic fix-it hints
+which would help the user replace such unsafe functions with safe
+alternatives, though the attribute can be used even when the fix can't be 
automated.
+
+The attribute does not suppress ``-Wunsafe-buffer-usage`` inside the function
+to which it is attached. These warnings still need to be addressed.
+
+The attribute is warranted even if the only way a function can overflow
+the buffer is by violating the function's preconditions. For example, it
+would make sense to put the attribute on function ``foo()`` below because
+passing an incorrect size parameter would cause a buffer overflow:
+
+.. code-block:: c++
+  [[clang::unsafe_buffer_usage]]
+  void foo(int *buf, size_t size) {
+for (size_t i = 0; i < size; ++i) {
+  buf[i] = i;
+}
+  }
+
+The attribute is NOT warranted when the function uses safe abstractions,
+assuming that these abstractions weren't misused outside the function.
+For example, function ``bar()`` below doesn't need the attribute,
+because assuming that the container ``buf`` is well-formed (has size that
+fits the original buffer it refers to), overflow cannot occur:
+
+.. code-block:: c++
+

[PATCH] D128440: [WebAssembly] Initial support for reference type funcref in clang

2023-01-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Some more comments, but there are unaddressed comments from earlier reviews as 
well.




Comment at: clang/include/clang/Basic/Attr.td:4129
+  let Documentation = [WebAssemblyExportNameDocs];
+  let Subjects = SubjectList<[TypedefName], ErrorDiag>;
+}

erichkeane wrote:
> pmatos wrote:
> > erichkeane wrote:
> > > pmatos wrote:
> > > > erichkeane wrote:
> > > > > Note that it seems this is likely not going to work correctly on 
> > > > > template type aliases!  You probably want to make sure that is 
> > > > > acceptable to you.
> > > > Documentation says about Subject:
> > > > 
> > > > ```
> > > >   // The things to which an attribute can appertain
> > > >   SubjectList Subjects;
> > > > ```
> > > > 
> > > > Given this can be attached to function pointer types, is the subject 
> > > > then just Type ?
> > > IIRC, the list of subjects are the Decls and Stmt types that are possibly 
> > > allowed.  I don't thnk it would be just 'Type' there.
> > > 
> > > As you have it, it is only allowed on TypedefNameDecl.
> > > 
> > > See the SubsetSubject's at the top of this file for some examples on how 
> > > you could constrain a special matcher to only work on function pointer 
> > > decls.
> > Good point @erichkeane . What do you think of FunctionPointer 
> > implementation here?
> That seems acceptable to me.
That makes sense to me as well, but FWIW, type attributes don't currently have 
much of any tablegen automation (unlike decl and stmt attributes), so the 
subject list isn't strictly necessary here. But it's still appreciated because 
1) it's documentation, and 2) we want to tablegen more and this helps us with 
that goal.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11804
+def err_wasm_funcref_not_wasm : Error<
+  "invalid use of __funcref keyword outside the WebAssembly triple">;
 } // end of sema component.





Comment at: clang/lib/AST/DeclBase.cpp:1060-1063
+  if (Ty->isFunctionPointerType())
+return true;
+
+  return false;





Comment at: clang/lib/Parse/ParseDecl.cpp:854-855
+  SourceLocation AttrNameLoc = ConsumeToken();
+  attrs.addNew(AttrName, AttrNameLoc, /*ScopeName=*/nullptr, 
/*ScopeLoc=*/SourceLocation{}, /*Args=*/nullptr, /*numArgs=*/0,
+   ParsedAttr::AS_Keyword);
+}

Be sure to run clang-format over the patch to fix this sort of thing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128440

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


[PATCH] D142675: [clang][CGDebugInfo] emit DW_LANG_C_plus_plus_{20|17} DW_LANG_C17

2023-01-31 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Also noting that GCC 12.2.0 does not produce these newer `DW_AT_language` 
values when using -std={c17|c++17|c++20}`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142675

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


[PATCH] D140415: [flang] stack arrays pass

2023-01-31 Thread Tom Eccles via Phabricator via cfe-commits
tblah added inline comments.



Comment at: flang/lib/Optimizer/Transforms/StackArrays.cpp:433
+  llvm::DenseSet freedValues;
+  func->walk([&](mlir::func::ReturnOp child) {
+const LatticePoint *lattice = solver.lookupState(child);

kiranchandramohan wrote:
> Do we have a test with multiple returns?
Thanks for this. It turned out I needed to join across all of the lattices at 
the return statements to ensure that values were returned at *all* return 
statements, not at *any* return statement.



Comment at: flang/lib/Optimizer/Transforms/StackArrays.cpp:696-697
+
+void StackArraysPass::runOnOperation() {
+  mlir::ModuleOp mod = getOperation();
+

kiranchandramohan wrote:
> From the following code, it seems the functions are processed independently. 
> Can this be a `Function` pass?
It can't. `fir::factory::getLlvm::getStackSave` and 
`fir::factory::getLlvmSatckRestore` add function declarations to the 
module-level. If functions are processed in different threads, there is a race 
condition when the `fir::builder` first checks to see if the function already 
exists in the module and if not, adds it.



Comment at: flang/test/Transforms/stack-arrays.fir:203
+
+// check that stack save/restore are not used when the memalloc and freemem are
+// in different blocks

kiranchandramohan wrote:
> Is this a case for future improvement?
Yes. This is an open TODO. I'll add a comment.

It should be possible to still do stack save/restore if the block containing 
the free is *always* executed after the memalloc. This might already be 
guaranteed by the data-flow analysis - I haven't thought enough about it. I 
haven't seen this happen in the allocations automatically generated by flang, 
so I don't think it is important to solve now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140415

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


[PATCH] D140415: [flang] stack arrays pass

2023-01-31 Thread Tom Eccles via Phabricator via cfe-commits
tblah updated this revision to Diff 493692.
tblah marked 10 inline comments as done.
tblah added a comment.

Thanks for review.

Changes:

- Join the lattices at each return operation to ensure that values are freed at 
*all* returns, not only *some* return
- Add tests with multiple return operations
- Fix nits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140415

Files:
  clang/docs/tools/clang-formatted-files.txt
  flang/include/flang/Optimizer/Builder/MutableBox.h
  flang/include/flang/Optimizer/Dialect/FIRAttr.h
  flang/include/flang/Optimizer/Transforms/Passes.h
  flang/include/flang/Optimizer/Transforms/Passes.td
  flang/lib/Lower/Allocatable.cpp
  flang/lib/Optimizer/Builder/MutableBox.cpp
  flang/lib/Optimizer/Transforms/CMakeLists.txt
  flang/lib/Optimizer/Transforms/StackArrays.cpp
  flang/test/Lower/HLFIR/allocatable-and-pointer-status-change.f90
  flang/test/Lower/Intrinsics/c_loc.f90
  flang/test/Lower/Intrinsics/system_clock.f90
  flang/test/Transforms/stack-arrays.f90
  flang/test/Transforms/stack-arrays.fir

Index: flang/test/Transforms/stack-arrays.fir
===
--- /dev/null
+++ flang/test/Transforms/stack-arrays.fir
@@ -0,0 +1,282 @@
+// RUN: fir-opt --stack-arrays %s | FileCheck %s
+
+// Simplest transformation
+func.func @simple() {
+  %0 = fir.allocmem !fir.array<42xi32>
+  fir.freemem %0 : !fir.heap>
+  return
+}
+// CHECK: func.func @simple() {
+// CHECK-NEXT: fir.alloca !fir.array<42xi32>
+// CHECK-NEXT: return
+// CHECK-NEXT: }
+
+// Check fir.must_be_heap allocations are not moved
+func.func @must_be_heap() {
+  %0 = fir.allocmem !fir.array<42xi32> {fir.must_be_heap = true}
+  fir.freemem %0 : !fir.heap>
+  return
+}
+// CHECK:  func.func @must_be_heap() {
+// CHECK-NEXT:   %[[ALLOC:.*]] = fir.allocmem !fir.array<42xi32> {fir.must_be_heap = true}
+// CHECK-NEXT:   fir.freemem %[[ALLOC]] : !fir.heap>
+// CHECK-NEXT:   return
+// CHECK-NEXT: }
+
+// Check the data-flow-analysis can detect cases where we aren't sure if memory
+// is freed by the end of the function
+func.func @dfa1(%arg0: !fir.ref> {fir.bindc_name = "cond"}) {
+  %7 = arith.constant 42 : index
+  %8 = fir.allocmem !fir.array, %7 {uniq_name = "_QFdfa1Earr.alloc"}
+  %9 = fir.load %arg0 : !fir.ref>
+  %10 = fir.convert %9 : (!fir.logical<4>) -> i1
+  fir.if %10 {
+fir.freemem %8 : !fir.heap>
+  } else {
+  }
+  return
+}
+// CHECK:  func.func @dfa1(%arg0: !fir.ref> {fir.bindc_name = "cond"}) {
+// CHECK-NEXT:   %[[C42:.*]] = arith.constant 42 : index
+// CHECK-NEXT:   %[[MEM:.*]] = fir.allocmem !fir.array, %[[C42]] {uniq_name = "_QFdfa1Earr.alloc"}
+// CHECK-NEXT:   %[[LOGICAL:.*]] = fir.load %arg0 : !fir.ref>
+// CHECK-NEXT:   %[[BOOL:.*]] = fir.convert %[[LOGICAL]] : (!fir.logical<4>) -> i1
+// CHECK-NEXT:   fir.if %[[BOOL]] {
+// CHECK-NEXT: fir.freemem %[[MEM]] : !fir.heap>
+// CHECK-NEXT:   } else {
+// CHECK-NEXT:   }
+// CHECK-NEXT:   return
+// CHECK-NEXT: }
+
+// Check scf.if (fir.if is not considered a branch operation)
+func.func @dfa2(%arg0: i1) {
+  %a = fir.allocmem !fir.array<1xi8>
+  scf.if %arg0 {
+fir.freemem %a : !fir.heap>
+  } else {
+  }
+  return
+}
+// CHECK: func.func @dfa2(%arg0: i1) {
+// CHECK-NEXT:  %[[MEM:.*]] = fir.allocmem !fir.array<1xi8>
+// CHECK-NEXT:  scf.if %arg0 {
+// CHECK-NEXT:fir.freemem %[[MEM]] : !fir.heap>
+// CHECK-NEXT:  } else {
+// CHECK-NEXT:  }
+// CHECK-NEXT:  return
+// CHECK-NEXT:  }
+
+// check the alloca is placed after all operands become available
+func.func @placement1() {
+  // do some stuff with other ssa values
+  %1 = arith.constant 1 : index
+  %2 = arith.constant 2 : index
+  %3 = arith.addi %1, %2 : index
+  // operand is now available
+  %4 = fir.allocmem !fir.array, %3
+  // ...
+  fir.freemem %4 : !fir.heap>
+  return
+}
+// CHECK:  func.func @placement1() {
+// CHECK-NEXT:   %[[ONE:.*]] = arith.constant 1 : index
+// CHECK-NEXT:   %[[TWO:.*]] = arith.constant 2 : index
+// CHECK-NEXT:   %[[ARG:.*]] = arith.addi %[[ONE]], %[[TWO]] : index
+// CHECK-NEXT:   %[[MEM:.*]] = fir.alloca !fir.array, %[[ARG]]
+// CHECK-NEXT:   return
+// CHECK-NEXT: }
+
+// check that if there are no operands, then the alloca is placed early
+func.func @placement2() {
+  // do some stuff with other ssa values
+  %1 = arith.constant 1 : index
+  %2 = arith.constant 2 : index
+  %3 = arith.addi %1, %2 : index
+  %4 = fir.allocmem !fir.array<42xi32>
+  // ...
+  fir.freemem %4 : !fir.heap>
+  return
+}
+// CHECK:  func.func @placement2() {
+// CHECK-NEXT:   %[[MEM:.*]] = fir.alloca !fir.array<42xi32>
+// CHECK-NEXT:   %[[ONE:.*]] = arith.constant 1 : index
+// CHECK-NEXT:   %[[TWO:.*]] = arith.constant 2 : index
+// CHECK-NEXT:   %[[SUM:.*]] = arith.addi %[[ONE]], %[[TWO]] : index
+// CHECK-NEXT:   return
+// CHECK-NEXT: }
+
+// check that stack allocations which must be placed in loops use 

[PATCH] D142914: [MLIR][OpenMP] Added OMPIRBuilder support for Target Data directives.

2023-01-31 Thread Valentin Clement via Phabricator via cfe-commits
clementval added inline comments.



Comment at: 
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp:1342-1382
+/// Create a constant string location from the MLIR Location information.
+static llvm::Constant *
+createSourceLocStrFromLocation(Location loc, llvm::OpenMPIRBuilder ,
+   StringRef name, uint32_t ) {
+  if (auto fileLoc = loc.dyn_cast()) {
+StringRef fileName = fileLoc.getFilename();
+unsigned lineNo = fileLoc.getLine();

TIFitis wrote:
> clementval wrote:
> > TIFitis wrote:
> > > clementval wrote:
> > > > TIFitis wrote:
> > > > > clementval wrote:
> > > > > > kiranchandramohan wrote:
> > > > > > > clementval wrote:
> > > > > > > > Instead of copy pasting this from 
> > > > > > > > `mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp`
> > > > > > > >  can you extract it and put it in a common shared file so bith 
> > > > > > > > translation can use the same code without duplication?
> > > > > > > @raghavendhra put up a patch some time back and he faced some 
> > > > > > > issues. It might be good to check with him or may be he can 
> > > > > > > comment here.
> > > > > > > https://reviews.llvm.org/D127037
> > > > > > > https://discourse.llvm.org/t/rfc-for-refactoring-common-code-for-openacc-and-openmp/63833
> > > > > > Just moving the three functions should be trivial. I'm not talking 
> > > > > > about the processMapOperand.
> > > > > I've moved `getSizeInBytes`.
> > > > > 
> > > > > The other two functions make use of `mlir::Location` and thus can't 
> > > > > be moved trivially.
> > > > > 
> > > > > I can still try to move them by individually passing the elements of 
> > > > > `mlir::Location` but that might not be ideal. Is that what you'd like?
> > > > What about a new header file in 
> > > > `mlir/include/mlir/Target/LLVMIR/Dialect/**` shared by 
> > > > `mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp` 
> > > > and 
> > > > `mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp`. 
> > > > That should be doable. 
> > > `mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp` 
> > > and `mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp` 
> > > already have access to the common `mlir::Location` type.
> > > 
> > > Problem is that `OMPIRBuilder.cpp` is the only common file between them  
> > > where I can move the two functions to. Currently there are no `mlir/**` 
> > > include files in `OMPIRBuilder.cpp` and it seems to me like a strict 
> > > design choice to have it that way.
> > The functions can be header only. Why do you need to put them in the 
> > OMPIRBuilder.cpp? I think it is better than duplicate the exact same code 
> > over. 
> Sorry, I misunderstood you earlier.
> I've added a new header file 
> `mlir/include/mlir/Target/LLVMIR/Dialect/Utils.h`, this is my first attempt 
> at adding a new header file, please let me know if you find any issues.
Thanks! That's what I had in mind. We might want to check with MLIR folks if 
`mlir::utils` is suited for that. I don't mind if it is `mlir::omp::builder` or 
smth similar since it is related to the OMPIRBuilder.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142914

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


[PATCH] D142999: [Clang] Adjust PIC handling for the AMDGPU ToolChain

2023-01-31 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPU.h:71
   }
-  bool isPICDefaultForced() const override { return false; }
+  bool isPICDefaultForced() const override { return true; }
   bool SupportsProfiling() const override { return false; }

arsenm wrote:
> What's the difference between isPICDefault and isPICDefaultForced?
`isPICDefaultForced` more or less just overrides `-fpie` or similar AFAIK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142999

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


[PATCH] D142988: [AArch64] Make nosimd imply nocrypto

2023-01-31 Thread Dave Green 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 rG00ce96b02e87: [AArch64] Make nosimd imply nocrypto (authored 
by dmgreen).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142988

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


Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -455,7 +455,7 @@
 // RUN: %clang -target aarch64 -mcpu=cortex-a53+noSIMD -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-MCPU-3 %s
 // CHECK-MCPU-1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "-crypto" "-target-feature" "+zcm" "-target-feature" "+zcz" 
"-target-feature" "-sha2" "-target-feature" "-aes"
 // CHECK-MCPU-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc"
-// CHECK-MCPU-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+aes" "-target-feature" "+crc" "-target-feature" 
"+fp-armv8" "-target-feature" "+sha2" "-target-feature" "-neon"
+// CHECK-MCPU-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+crc" "-target-feature" "+fp-armv8" "-target-feature" 
"-neon" "-target-feature" "-sha2" "-target-feature" "-aes"
 
 // RUN: %clang -target aarch64 -mcpu=cyclone+nocrc+nocrypto -march=armv8-a 
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MARCH %s
 // RUN: %clang -target aarch64 -march=armv8-a -mcpu=cyclone+nocrc+nocrypto  
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MARCH %s
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -407,7 +407,7 @@
 else if (*I == "+crypto") {
   HasCrypto = true;
   HasNoCrypto = false;
-} else if (*I == "-crypto") {
+} else if (*I == "-crypto" || *I == "-neon") {
   HasCrypto = false;
   HasNoCrypto = true;
   HasSM4 = HasSHA2 = HasSHA3 = HasAES = false;


Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -455,7 +455,7 @@
 // RUN: %clang -target aarch64 -mcpu=cortex-a53+noSIMD -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-3 %s
 // CHECK-MCPU-1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "-crypto" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "-sha2" "-target-feature" "-aes"
 // CHECK-MCPU-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc"
-// CHECK-MCPU-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8a" "-target-feature" "+aes" "-target-feature" "+crc" "-target-feature" "+fp-armv8" "-target-feature" "+sha2" "-target-feature" "-neon"
+// CHECK-MCPU-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8a" "-target-feature" "+crc" "-target-feature" "+fp-armv8" "-target-feature" "-neon" "-target-feature" "-sha2" "-target-feature" "-aes"
 
 // RUN: %clang -target aarch64 -mcpu=cyclone+nocrc+nocrypto -march=armv8-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MARCH %s
 // RUN: %clang -target aarch64 -march=armv8-a -mcpu=cyclone+nocrc+nocrypto  -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MARCH %s
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -407,7 +407,7 @@
 else if (*I == "+crypto") {
   HasCrypto = true;
   HasNoCrypto = false;
-} else if (*I == "-crypto") {
+} else if (*I == "-crypto" || *I == "-neon") {
   HasCrypto = false;
   HasNoCrypto = true;
   HasSM4 = HasSHA2 = HasSHA3 = HasAES = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 00ce96b - [AArch64] Make nosimd imply nocrypto

2023-01-31 Thread David Green via cfe-commits

Author: David Green
Date: 2023-01-31T19:17:22Z
New Revision: 00ce96b02e87c1ceba1857590f56c647ad91db91

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

LOG: [AArch64] Make nosimd imply nocrypto

This adds a quick check for -neon, making it imply the same as -crypto,
which helps get some features correct in more cases.

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index de306daaa7478..4b641bbb73d41 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -407,7 +407,7 @@ void aarch64::getAArch64TargetFeatures(const Driver ,
 else if (*I == "+crypto") {
   HasCrypto = true;
   HasNoCrypto = false;
-} else if (*I == "-crypto") {
+} else if (*I == "-crypto" || *I == "-neon") {
   HasCrypto = false;
   HasNoCrypto = true;
   HasSM4 = HasSHA2 = HasSHA3 = HasAES = false;

diff  --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index b0ef8a6355845..5834bc11f40c8 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -455,7 +455,7 @@
 // RUN: %clang -target aarch64 -mcpu=cortex-a53+noSIMD -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-MCPU-3 %s
 // CHECK-MCPU-1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "-crypto" "-target-feature" "+zcm" "-target-feature" "+zcz" 
"-target-feature" "-sha2" "-target-feature" "-aes"
 // CHECK-MCPU-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc"
-// CHECK-MCPU-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+aes" "-target-feature" "+crc" "-target-feature" 
"+fp-armv8" "-target-feature" "+sha2" "-target-feature" "-neon"
+// CHECK-MCPU-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+crc" "-target-feature" "+fp-armv8" "-target-feature" 
"-neon" "-target-feature" "-sha2" "-target-feature" "-aes"
 
 // RUN: %clang -target aarch64 -mcpu=cyclone+nocrc+nocrypto -march=armv8-a 
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MARCH %s
 // RUN: %clang -target aarch64 -march=armv8-a -mcpu=cyclone+nocrc+nocrypto  
-### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-MARCH %s



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


[PATCH] D142826: [Clang] Add -Wtype-limits to -Wextra for GCC compatibility

2023-01-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Sema/tautological-constant-compare.c:7-8
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtype-limits -DTEST 
-verify -x c++ %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -verify=silent %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -verify=silent -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -verify -x c++ %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify=silent 
%s

Ooops, I'm sorry, I forgot about this edit. :-( Once you make that change on 
the RUN lines, you'll remove all the additional warnings you added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142826

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


[PATCH] D141858: [clang][Interp] Fix Pointer::toAPValue() for expressions

2023-01-31 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.

LG given that other test coverage exists for this.


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

https://reviews.llvm.org/D141858

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


[PATCH] D142999: [Clang] Adjust PIC handling for the AMDGPU ToolChain

2023-01-31 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.

I don't understand how the PIC options are supposed to propagate given that 
codegen seems to still use magic flags but removing a special case seems good




Comment at: clang/lib/Driver/ToolChains/AMDGPU.h:71
   }
-  bool isPICDefaultForced() const override { return false; }
+  bool isPICDefaultForced() const override { return true; }
   bool SupportsProfiling() const override { return false; }

What's the difference between isPICDefault and isPICDefaultForced?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142999

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


[PATCH] D142991: [clang-tidy] Add --fix-mode and --nolint-prefix options

2023-01-31 Thread Kyle Edwards via Phabricator via cfe-commits
KyleFromKitware updated this revision to Diff 493681.
KyleFromKitware added a comment.

Fixed crash when warning doesn't have associated location.


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

https://reviews.llvm.org/D142991

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidy.h
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang/include/clang/Basic/DiagnosticFrontendKinds.td

Index: clang/include/clang/Basic/DiagnosticFrontendKinds.td
===
--- clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -180,6 +180,7 @@
   "qualifier 'const' is needed for variables in address space '%0'">;
 
 def note_fixit_applied : Note<"FIX-IT applied suggested code changes">;
+def note_fixit_added_nolint : Note<"FIX-IT added NOLINT to suppress warning">;
 def note_fixit_in_macro : Note<
 "FIX-IT unable to apply suggested code changes in a macro">;
 def note_fixit_failed : Note<
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -138,6 +138,25 @@
 )"),
   cl::init(false), cl::cat(ClangTidyCategory));
 
+static cl::opt FixMode("fix-mode", cl::desc(R"(
+How to fix warnings:
+  - 'fixit' (default) applies fix-it if available
+  - 'nolint' adds a NOLINT comment to suppress the
+warning, prefixed with the value of the
+--nolint-prefix argument
+  - 'fixit-or-nolint' applies fix-it if available,
+otherwise adds a NOLINT comment like the 'nolint'
+option
+)"),
+cl::init("fixit"),
+cl::cat(ClangTidyCategory));
+
+static cl::opt NoLintPrefix("nolint-prefix", cl::desc(R"(
+Prefix to be added to NOLINT comments.
+)"),
+ cl::init(""),
+ cl::cat(ClangTidyCategory));
+
 static cl::opt FormatStyle("format-style", cl::desc(R"(
 Style for formatting code around applied fixes:
   - 'none' (default) turns off formatting
@@ -473,6 +492,19 @@
 return 1;
   }
 
+  FixType Type = FT_FixIt;
+  if (FixMode.getValue() == "fixit")
+Type = FT_FixIt;
+  else if (FixMode.getValue() == "nolint")
+Type = FT_NoLint;
+  else if (FixMode.getValue() == "fixit-or-nolint")
+Type = FT_FixItOrNoLint;
+  else {
+llvm::WithColor::error()
+<< "invalid value for --fix-type: '" << FixMode.getValue() << "'\n";
+return 1;
+  }
+
   llvm::IntrusiveRefCntPtr BaseFS(
   new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
 
@@ -597,9 +629,9 @@
 
   ClangTidyContext Context(std::move(OwningOptionsProvider),
AllowEnablingAnalyzerAlphaCheckers);
-  std::vector Errors =
-  runClangTidy(Context, OptionsParser->getCompilations(), PathList, BaseFS,
-   FixNotes, EnableCheckProfile, ProfilePrefix);
+  std::vector Errors = runClangTidy(
+  Context, OptionsParser->getCompilations(), PathList, BaseFS, FixNotes,
+  Type, NoLintPrefix.getValue(), EnableCheckProfile, ProfilePrefix);
   bool FoundErrors = llvm::any_of(Errors, [](const ClangTidyError ) {
 return E.DiagLevel == ClangTidyError::Error;
   });
@@ -613,7 +645,7 @@
 
   unsigned WErrorCount = 0;
 
-  handleErrors(Errors, Context, DisableFixes ? FB_NoFix : Behaviour,
+  handleErrors(Errors, Context, DisableFixes ? FB_NoFix : Behaviour, Type,
WErrorCount, BaseFS);
 
   if (!ExportFixes.empty() && !Errors.empty()) {
@@ -623,7 +655,7 @@
   llvm::errs() << "Error opening output file: " << EC.message() << '\n';
   return 1;
 }
-exportReplacements(FilePath.str(), Errors, OS);
+exportReplacements(FilePath.str(), Errors, OS, Type);
   }
 
   if (!Quiet) {
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -40,6 +40,7 @@
 
   bool IsWarningAsError;
   std::vector EnabledDiagnosticAliases;
+  llvm::StringMap NoLintReplacements;
 };
 
 /// Contains displayed and ignored diagnostic counters for a ClangTidy run.
@@ -240,12 +241,22 @@
   llvm::StringSet<> *OptionsCollector = nullptr;
 };
 
-/// Gets the Fix attached to \p Diagnostic.
+/// Controls how clang-tidy applies fixes.
+enum FixType {
+  /// Only apply fix-its.
+  FT_FixIt,
+  /// Only add NOLINT lines.
+  FT_NoLint,
+  /// Add NOLINT if fix-it is not available.
+  FT_FixItOrNoLint
+};
+
+/// Gets the Fix attached to \p ClangTidyError.
 /// If 

[PATCH] D142999: [Clang] Adjust PIC handling for the AMDGPU ToolChain

2023-01-31 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: arsenm, JonChesterfield, yaxunl, t-tye, msearles.
Herald added subscribers: kosarev, kerbowa, tpr, dstuttard, jvesely, kzhuravl.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, wdng.
Herald added a project: clang.

The AMDGPU target only emits shared libraries currently. This patch
changes the handling of the PIC level to be managed in the
AMDGPUToolChain rather than having a special case for it. This causes
`--target=amdgcn--` to no longer set the PIC. This should be an
acceptable change since that doesn't use a correct toolchain anyway.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142999

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/test/Driver/amdgcn-toolchain-pic.cl

Index: clang/test/Driver/amdgcn-toolchain-pic.cl
===
--- clang/test/Driver/amdgcn-toolchain-pic.cl
+++ clang/test/Driver/amdgcn-toolchain-pic.cl
@@ -1,7 +1,5 @@
-// RUN: %clang -### --target=amdgcn-- -mcpu=gfx803 %s 2>&1 | FileCheck %s
-// RUN: %clang -### --target=amdgcn-amd- -mcpu=gfx803 %s 2>&1 | FileCheck %s
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx803 %s 2>&1 | FileCheck %s
 // RUN: %clang -### --target=amdgcn-amd-amdpal -mcpu=gfx803 %s 2>&1 | FileCheck %s
 // RUN: %clang -### --target=amdgcn-amd-mesa3d -mcpu=gfx803 %s 2>&1 | FileCheck %s
 
-// CHECK: "-cc1"{{.*}} "-mrelocation-model" "pic" "-pic-level" "1"
+// CHECK: "-cc1"{{.*}} "-mrelocation-model" "pic" "-pic-level" "2"
Index: clang/lib/Driver/ToolChains/HIPAMD.cpp
===
--- clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -270,8 +270,7 @@
   const OptTable  = getDriver().getOpts();
 
   for (Arg *A : Args) {
-if (!shouldSkipArgument(A) &&
-!shouldSkipSanitizeOption(*this, Args, BoundArch, A))
+if (!shouldSkipSanitizeOption(*this, Args, BoundArch, A))
   DAL->append(A);
   }
 
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1418,10 +1418,6 @@
 }
   }
 
-  // AMDGPU-specific defaults for PIC.
-  if (Triple.getArch() == llvm::Triple::amdgcn)
-PIC = true;
-
   // The last argument relating to either PIC or PIE wins, and no
   // other argument is used. If the last argument is any flavor of the
   // '-fno-...' arguments, both PIC and PIE are disabled. Any PIE
Index: clang/lib/Driver/ToolChains/AMDGPU.h
===
--- clang/lib/Driver/ToolChains/AMDGPU.h
+++ clang/lib/Driver/ToolChains/AMDGPU.h
@@ -64,11 +64,11 @@
 
   bool IsMathErrnoDefault() const override { return false; }
   bool isCrossCompiling() const override { return true; }
-  bool isPICDefault() const override { return false; }
+  bool isPICDefault() const override { return true; }
   bool isPIEDefault(const llvm::opt::ArgList ) const override {
 return false;
   }
-  bool isPICDefaultForced() const override { return false; }
+  bool isPICDefaultForced() const override { return true; }
   bool SupportsProfiling() const override { return false; }
 
   llvm::opt::DerivedArgList *
@@ -97,9 +97,6 @@
   /// Needed for translating LTO options.
   const char *getDefaultLinker() const override { return "ld.lld"; }
 
-  /// Should skip argument.
-  bool shouldSkipArgument(const llvm::opt::Arg *Arg) const;
-
   /// Uses amdgpu-arch tool to get arch of the system GPU. Will return error
   /// if unable to find one.
   virtual Expected>
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -611,10 +611,8 @@
   if (!DAL)
 DAL = new DerivedArgList(Args.getBaseArgs());
 
-  for (Arg *A : Args) {
-if (!shouldSkipArgument(A))
-  DAL->append(A);
-  }
+  for (Arg *A : Args)
+DAL->append(A);
 
   checkTargetID(*DAL);
 
@@ -870,13 +868,6 @@
   return BCLibs;
 }
 
-bool AMDGPUToolChain::shouldSkipArgument(const llvm::opt::Arg *A) const {
-  Option O = A->getOption();
-  if (O.matches(options::OPT_fPIE) || O.matches(options::OPT_fpie))
-return true;
-  return false;
-}
-
 llvm::SmallVector
 ROCMToolChain::getCommonDeviceLibNames(const llvm::opt::ArgList ,
const std::string ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141861: [nvptx-arch] Dynamically load the CUDA runtime if not found during the build

2023-01-31 Thread Steven Johnson via Phabricator via cfe-commits
srj added a comment.

In D141861#4094084 , @srj wrote:

> In D141861#4094079 , @jhuber6 wrote:
>
>> In D141861#4094063 , @srj wrote:
>>
>>> Yes please!
>>
>> Let me know if this fixes anything rG9f64fbb882dc 
>> .
>
> Testing now

So far, so good, let me just verify a few more things


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141861

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


[PATCH] D142800: [Clang][Diagnostic] Add `-Wcomparison-op-parentheses` to warn on chained comparisons

2023-01-31 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

> I'd be interested to see the fixit-hints for the first bit, also to see how 
> others feel about it here.

My 2c is that `-Wparentheses` is already a very stylistic warning (even correct 
code, without knowing about this esoteric/specific suppression style of adding 
parens, is likely to be caught by this general class of diagnostic) so I'm 
pretty apprehensive about opening it up further - but data would be the 
decider. Running the proposed slices (different operators in different orders, 
etc) of warning over some broad codebases to get a sense of the false positive 
rate would be really helpful/necessary to decide which things to include and 
exclude.


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

https://reviews.llvm.org/D142800

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


[PATCH] D142907: LangRef: Add "dynamic" option to "denormal-fp-math"

2023-01-31 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

LGTM for the parts I've commented on.




Comment at: clang/test/CodeGenCUDA/link-builtin-bitcode-denormal-fp-mode.cu:77
+
+// CHECK: kernel_f32({{.*}}) #[[$KERNELATTR:[0-9]+]]
+__global__ void kernel_f32(float* out, float* a, float* b, float* c) {

arsenm wrote:
> tra wrote:
> > Nit: CHECK-LABEL ?
>  error: found 'CHECK-LABEL:' with variable definition or use
> 
Interesting. 
In that case label and attribute checks could be separated into something like 
this:
```
CHECK-LABEL: name
CHECK-SAME: [[attribute]]
```

Up to you.



Comment at: llvm/test/CodeGen/Generic/denormal-fp-math-cl-opt.ll:3
+
+; Check that we annotated the command line flag annotates the IR with the 
appropriate attributes
+

tra wrote:
> Edit: `Check that the command line flag annotates the IR with the appropriate 
> attributes.`
^^ The comment still needs to be edited.


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

https://reviews.llvm.org/D142907

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


[PATCH] D141907: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected

2023-01-31 Thread Michał Górny via Phabricator via cfe-commits
mgorny added reviewers: MaskRay, thesamesam, tstellar.
mgorny added a comment.

Ok, this turned out to be surprisingly painless, at least within our packaging.

However, I'd prefer if someone more experienced looked at the CMake changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141907

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


[PATCH] D142994: [UsersManual] Add llvm-progen as an alternative tool for AutoFDO profile generation.

2023-01-31 Thread Wenlei He via Phabricator via cfe-commits
wenlei added a subscriber: davidxl.
wenlei added a comment.

Given llvm-profgen is in llvm tree, I'm wondering if it makes sense to treat it 
first option instead of alternative to out of tree create_llvm_prof. wdyt 
@davidxl


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142994

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


[PATCH] D139395: Add CFI integer types normalization

2023-01-31 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc added a comment.

LGTM with nits




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1694
+  getCXXABI().getMangleContext().mangleTypeName(
+  T, Out, !!getCodeGenOpts().SanitizeCfiICallNormalizeIntegers);
+

Is the !! necessary here?



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:6881
+getCXXABI().getMangleContext().mangleTypeName(
+T, Out, !!getCodeGenOpts().SanitizeCfiICallNormalizeIntegers);
+

Likewise



Comment at: clang/test/CodeGen/cfi-icall-normalize.c:55-75
+// CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFv{{u2i8|u2u8}}E.normalized"}
+// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFv{{u2i8S_|u2u8u2i8}}E.normalized"}
+// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFv{{u2i8S_S_|u2u8u2i8S0_}}E.normalized"}
+// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}E.normalized"}
+// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}S_E.normalized"}
+// CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64}}S_S_E.normalized"}
+// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFv{{u3i32|u3i64}}E.normalized"}

Shouldn't these all be checking for specific types? Since you're specifying a 
triple, the width and signedness of the integer types are fixed.



Comment at: clang/test/CodeGen/cfi-icall-normalize2.c:9
+// CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}}
+// CHECK: call i1 @llvm.type.test({{i8\*|ptr}} {{%f|%0}}, metadata 
!"_ZTSFv{{u3i16|u3i32|u3i64}}E.normalized")
+fn(arg);

Likewise; also below


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139395

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


[PATCH] D142757: [clang][driver] Emit an error for `/clang:-x`

2023-01-31 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added inline comments.



Comment at: clang/test/Driver/x-args.c:12
+// RUN: not %clang_cl /TC /WX /clang:-xc /clang:-E /clang:-dM %s 2>&1 | 
FileCheck -check-prefix=CL %s
+// CL-NOT: '-x c' after last input file has no effect
+// CL: error: unsupported option '-x c'; did you mean '/TC' or '/TP'?

MaskRay wrote:
> You can remove this `CL-NOT` negative pattern. Instead, use 
> `--check-prefix=CL --implicit-check-not=error:` to check that there is no 
> other error.
I probably don't fully understand the suggestion, but there is a `error:` that 
is being checked in this test. The one that this revision adds. It is checked 
on the next line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142757

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


[PATCH] D142690: [libc++] Fixes the Clang modular build.

2023-01-31 Thread Mark de Wever 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 rGa7f8ddc4e2e3: [libc++] Fixes the Clang modular build. 
(authored by Mordante).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142690

Files:
  libcxx/include/module.modulemap.in


Index: libcxx/include/module.modulemap.in
===
--- libcxx/include/module.modulemap.in
+++ libcxx/include/module.modulemap.in
@@ -758,13 +758,19 @@
   module derived_from   { private header 
"__concepts/derived_from.h" }
   module destructible   { private header 
"__concepts/destructible.h" }
   module different_from { private header 
"__concepts/different_from.h" }
-  module equality_comparable{ private header 
"__concepts/equality_comparable.h" }
+  module equality_comparable {
+private header "__concepts/equality_comparable.h"
+export type_traits.common_reference
+  }
   module invocable  { private header 
"__concepts/invocable.h" }
   module movable{ private header 
"__concepts/movable.h" }
   module predicate  { private header 
"__concepts/predicate.h" }
   module regular{ private header 
"__concepts/regular.h" }
   module relation   { private header 
"__concepts/relation.h" }
-  module same_as{ private header 
"__concepts/same_as.h" }
+  module same_as {
+private header "__concepts/same_as.h"
+export type_traits.is_same
+  }
   module semiregular{ private header 
"__concepts/semiregular.h" }
   module swappable  { private header 
"__concepts/swappable.h" }
   module totally_ordered{ private header 
"__concepts/totally_ordered.h" }
@@ -981,7 +987,11 @@
   module back_insert_iterator  { private header 
"__iterator/back_insert_iterator.h" }
   module bounded_iter  { private header 
"__iterator/bounded_iter.h" }
   module common_iterator   { private header 
"__iterator/common_iterator.h" }
-  module concepts  { private header "__iterator/concepts.h" }
+  module concepts {
+private header "__iterator/concepts.h"
+export concepts.equality_comparable
+export type_traits.common_reference
+  }
   module counted_iterator  { private header 
"__iterator/counted_iterator.h" }
   module data  { private header "__iterator/data.h" }
   module default_sentinel  { private header 
"__iterator/default_sentinel.h" }


Index: libcxx/include/module.modulemap.in
===
--- libcxx/include/module.modulemap.in
+++ libcxx/include/module.modulemap.in
@@ -758,13 +758,19 @@
   module derived_from   { private header "__concepts/derived_from.h" }
   module destructible   { private header "__concepts/destructible.h" }
   module different_from { private header "__concepts/different_from.h" }
-  module equality_comparable{ private header "__concepts/equality_comparable.h" }
+  module equality_comparable {
+private header "__concepts/equality_comparable.h"
+export type_traits.common_reference
+  }
   module invocable  { private header "__concepts/invocable.h" }
   module movable{ private header "__concepts/movable.h" }
   module predicate  { private header "__concepts/predicate.h" }
   module regular{ private header "__concepts/regular.h" }
   module relation   { private header "__concepts/relation.h" }
-  module same_as{ private header "__concepts/same_as.h" }
+  module same_as {
+private header "__concepts/same_as.h"
+export type_traits.is_same
+  }
   module semiregular{ private header "__concepts/semiregular.h" }
   module swappable  { private header "__concepts/swappable.h" }
   module totally_ordered{ private header "__concepts/totally_ordered.h" }
@@ -981,7 +987,11 @@
   module back_insert_iterator  { private header "__iterator/back_insert_iterator.h" }
   module bounded_iter  { private header "__iterator/bounded_iter.h" }
   module common_iterator   { private header "__iterator/common_iterator.h" }
-  module concepts  { private header "__iterator/concepts.h" }
+  module concepts {
+private header "__iterator/concepts.h"
+export concepts.equality_comparable
+export type_traits.common_reference
+  }
   module counted_iterator  { private 

[PATCH] D142994: [UsersManual] Add llvm-progen as an alternative tool for AutoFDO profile generation.

2023-01-31 Thread Hongtao Yu via Phabricator via cfe-commits
hoy created this revision.
Herald added subscribers: modimo, wenlei.
Herald added a project: All.
hoy requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Test Plan:


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142994

Files:
  clang/docs/UsersManual.rst


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -2294,6 +2294,14 @@
without the ``-b`` flag, you need to use ``--use_lbr=false`` when
calling ``create_llvm_prof``.
 
+   Alternatively, the LLVM tool ``llvm-profgen`` can also be used to generate
+   the LLVM sample profile:
+
+   .. code-block:: console
+
+ $ llvm-profgen --binary=./code --output=code.prof--perfdata=perf.data
+
+
 4. Build the code again using the collected profile. This step feeds
the profile back to the optimizers. This should result in a binary
that executes faster than the original one. Note that you are not


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -2294,6 +2294,14 @@
without the ``-b`` flag, you need to use ``--use_lbr=false`` when
calling ``create_llvm_prof``.
 
+   Alternatively, the LLVM tool ``llvm-profgen`` can also be used to generate
+   the LLVM sample profile:
+
+   .. code-block:: console
+
+ $ llvm-profgen --binary=./code --output=code.prof--perfdata=perf.data
+
+
 4. Build the code again using the collected profile. This step feeds
the profile back to the optimizers. This should result in a binary
that executes faster than the original one. Note that you are not
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141861: [nvptx-arch] Dynamically load the CUDA runtime if not found during the build

2023-01-31 Thread Steven Johnson via Phabricator via cfe-commits
srj added a comment.

In D141861#4094079 , @jhuber6 wrote:

> In D141861#4094063 , @srj wrote:
>
>> Yes please!
>
> Let me know if this fixes anything rG9f64fbb882dc 
> .

Testing now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141861

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


[clang] d8982f7 - [AST] assert(false) -> llvm_unreachable

2023-01-31 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2023-01-31T18:57:01+01:00
New Revision: d8982f72282bb88da6a3793f9d55fccd5621c825

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

LOG: [AST] assert(false) -> llvm_unreachable

Has the advantage of not triggering missing return warnings even in
NDEBUG builds.

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 438c224f0a2c..a6dfbd48d0d4 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -4093,7 +4093,8 @@ QualType ASTContext::getWebAssemblyExternrefType() const {
 return SingletonId;
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
   }
-  assert(false && "shouldn't try to generate type externref outside 
WebAssembly target");
+  llvm_unreachable(
+  "shouldn't try to generate type externref outside WebAssembly target");
 }
 
 /// getScalableVectorType - Return the unique reference to a scalable vector



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


[PATCH] D141861: [nvptx-arch] Dynamically load the CUDA runtime if not found during the build

2023-01-31 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D141861#4094063 , @srj wrote:

> Yes please!

Let me know if this fixes anything rG9f64fbb882dc 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141861

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


[clang] 9f64fbb - [Clang] Do not attempt to directly link arch tools in 32-bit mode

2023-01-31 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-01-31T11:56:24-06:00
New Revision: 9f64fbb882dc3c76712ec70316253ca396baa824

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

LOG: [Clang] Do not attempt to directly link arch tools in 32-bit mode

Summary:
We offer almost no support for offloading on 32-bit systems. This causes
some problems when cross-compiling for 32-bit machines as it will find
the CUDA from the host that is incompatible. Instead we force these to
always use the dynamically loaded version, which should always compile.

Added: 


Modified: 
clang/tools/amdgpu-arch/CMakeLists.txt
clang/tools/nvptx-arch/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/amdgpu-arch/CMakeLists.txt 
b/clang/tools/amdgpu-arch/CMakeLists.txt
index d687d1691b7a6..f50a5c5365a6f 100644
--- a/clang/tools/amdgpu-arch/CMakeLists.txt
+++ b/clang/tools/amdgpu-arch/CMakeLists.txt
@@ -12,7 +12,7 @@ add_clang_tool(amdgpu-arch AMDGPUArch.cpp)
 
 # If we find the HSA runtime we link with it directly.
 find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS 
/opt/rocm)
-if (${hsa-runtime64_FOUND})
+if (hsa-runtime64_FOUND AND NOT  LLVM_BUILD_32_BITS)
   set_target_properties(amdgpu-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
   clang_target_link_libraries(amdgpu-arch PRIVATE hsa-runtime64::hsa-runtime64)
 else()

diff  --git a/clang/tools/nvptx-arch/CMakeLists.txt 
b/clang/tools/nvptx-arch/CMakeLists.txt
index 95c25dc75847e..d40510f3da835 100644
--- a/clang/tools/nvptx-arch/CMakeLists.txt
+++ b/clang/tools/nvptx-arch/CMakeLists.txt
@@ -12,7 +12,7 @@ add_clang_tool(nvptx-arch NVPTXArch.cpp)
 find_package(CUDAToolkit QUIET)
 
 # If we found the CUDA library directly we just dynamically link against it.
-if (CUDAToolkit_FOUND)
+if (CUDAToolkit_FOUND AND NOT LLVM_BUILD_32_BITS)
   target_link_libraries(nvptx-arch PRIVATE CUDA::cuda_driver)
 else()
   target_compile_definitions(nvptx-arch PRIVATE "DYNAMIC_CUDA")



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


[PATCH] D142907: LangRef: Add "dynamic" option to "denormal-fp-math"

2023-01-31 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 493653.
arsenm added a comment.

Fix dropping target-cpu. Also skip interposable functions if we aren't 
internalizing (this seems to be a theoretical concern, since PropagateAttrs and 
Internalize are set as a pair)


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

https://reviews.llvm.org/D142907

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGen/denormalfpmode-f32.c
  clang/test/CodeGen/denormalfpmode.c
  clang/test/CodeGenCUDA/Inputs/ocml-sample.cl
  clang/test/CodeGenCUDA/link-builtin-bitcode-denormal-fp-mode.cu
  clang/test/Driver/denormal-fp-math.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/ADT/FloatingPointMode.h
  llvm/include/llvm/IR/Attributes.td
  llvm/include/llvm/IR/Function.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
  llvm/test/CodeGen/Generic/denormal-fp-math-cl-opt.ll
  llvm/test/CodeGen/X86/sqrt-fastmath.ll
  llvm/test/Transforms/Inline/AMDGPU/inline-denormal-fp-math.ll
  llvm/test/Transforms/InstSimplify/canonicalize.ll
  llvm/test/Transforms/InstSimplify/constant-fold-fp-denormal.ll
  llvm/unittests/ADT/FloatingPointMode.cpp
  llvm/utils/TableGen/Attributes.cpp

Index: llvm/utils/TableGen/Attributes.cpp
===
--- llvm/utils/TableGen/Attributes.cpp
+++ llvm/utils/TableGen/Attributes.cpp
@@ -54,6 +54,7 @@
   // Emit attribute enums in the same order llvm::Attribute::operator< expects.
   Emit({"EnumAttr", "TypeAttr", "IntAttr"}, "ATTRIBUTE_ENUM");
   Emit({"StrBoolAttr"}, "ATTRIBUTE_STRBOOL");
+  Emit({"ComplexStrAttr"}, "ATTRIBUTE_COMPLEXSTR");
 
   OS << "#undef ATTRIBUTE_ALL\n";
   OS << "#endif\n\n";
Index: llvm/unittests/ADT/FloatingPointMode.cpp
===
--- llvm/unittests/ADT/FloatingPointMode.cpp
+++ llvm/unittests/ADT/FloatingPointMode.cpp
@@ -20,6 +20,8 @@
 parseDenormalFPAttributeComponent("preserve-sign"));
   EXPECT_EQ(DenormalMode::PositiveZero,
 parseDenormalFPAttributeComponent("positive-zero"));
+  EXPECT_EQ(DenormalMode::Dynamic,
+parseDenormalFPAttributeComponent("dynamic"));
   EXPECT_EQ(DenormalMode::Invalid, parseDenormalFPAttributeComponent("foo"));
 }
 
@@ -27,6 +29,7 @@
   EXPECT_EQ("ieee", denormalModeKindName(DenormalMode::IEEE));
   EXPECT_EQ("preserve-sign", denormalModeKindName(DenormalMode::PreserveSign));
   EXPECT_EQ("positive-zero", denormalModeKindName(DenormalMode::PositiveZero));
+  EXPECT_EQ("dynamic", denormalModeKindName(DenormalMode::Dynamic));
   EXPECT_EQ("", denormalModeKindName(DenormalMode::Invalid));
 }
 
@@ -54,6 +57,10 @@
   EXPECT_EQ(DenormalMode(DenormalMode::PositiveZero, DenormalMode::PositiveZero),
 parseDenormalFPAttribute("positive-zero,positive-zero"));
 
+  EXPECT_EQ(DenormalMode(DenormalMode::Dynamic, DenormalMode::Dynamic),
+parseDenormalFPAttribute("dynamic"));
+  EXPECT_EQ(DenormalMode(DenormalMode::Dynamic, DenormalMode::Dynamic),
+parseDenormalFPAttribute("dynamic,dynamic"));
 
   EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::PositiveZero),
 parseDenormalFPAttribute("ieee,positive-zero"));
@@ -65,6 +72,10 @@
   EXPECT_EQ(DenormalMode(DenormalMode::IEEE, DenormalMode::PreserveSign),
 parseDenormalFPAttribute("ieee,preserve-sign"));
 
+  EXPECT_EQ(DenormalMode(DenormalMode::Dynamic, DenormalMode::PreserveSign),
+parseDenormalFPAttribute("dynamic,preserve-sign"));
+  EXPECT_EQ(DenormalMode(DenormalMode::PreserveSign, DenormalMode::Dynamic),
+parseDenormalFPAttribute("preserve-sign,dynamic"));
 
   EXPECT_EQ(DenormalMode(DenormalMode::Invalid, DenormalMode::Invalid),
 parseDenormalFPAttribute("foo"));
@@ -102,6 +113,13 @@
   EXPECT_EQ(
 "preserve-sign,positive-zero",
 DenormalMode(DenormalMode::PreserveSign, DenormalMode::PositiveZero).str());
+
+  EXPECT_EQ("dynamic,dynamic",
+DenormalMode(DenormalMode::Dynamic, DenormalMode::Dynamic).str());
+  EXPECT_EQ("ieee,dynamic",
+DenormalMode(DenormalMode::IEEE, DenormalMode::Dynamic).str());
+  EXPECT_EQ("dynamic,ieee",
+DenormalMode(DenormalMode::Dynamic, DenormalMode::IEEE).str());
 }
 
 TEST(FloatingPointModeTest, DenormalModeIsSimple) {
@@ -110,6 +128,10 @@
 DenormalMode::Invalid).isSimple());
   EXPECT_FALSE(DenormalMode(DenormalMode::PreserveSign,
 DenormalMode::PositiveZero).isSimple());
+  EXPECT_FALSE(DenormalMode(DenormalMode::PreserveSign, DenormalMode::Dynamic)
+   .isSimple());
+  EXPECT_FALSE(DenormalMode(DenormalMode::Dynamic, DenormalMode::PreserveSign)
+   

[PATCH] D141861: [nvptx-arch] Dynamically load the CUDA runtime if not found during the build

2023-01-31 Thread Steven Johnson via Phabricator via cfe-commits
srj added a comment.

In D141861#4094059 , @jhuber6 wrote:

> In D141861#4094058 , @srj wrote:
>
>> In D141861#4094043 , @jhuber6 
>> wrote:
>>
>>> Would this just require checking `LLVM_BUILD_32_BITS`? Should be an easy 
>>> change.
>>
>> I think so. (It might be tempting to check `if (CMAKE_SIZEOF_VOID_P EQUAL 
>> 8)` but LLVM_BUILD_32_BITS is likely to be a more explicit signal.)
>
> SG, want me to push that real quick?

Yes please!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141861

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


[PATCH] D142384: [C++20] Fix a crash with modules.

2023-01-31 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 493652.
usaxena95 added a comment.

Use definition based field access only for CXXRecordDecl.
Avoid dynamic dispatch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142384

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


Index: clang/include/clang/AST/DeclCXX.h
===
--- clang/include/clang/AST/DeclCXX.h
+++ clang/include/clang/AST/DeclCXX.h
@@ -554,6 +554,21 @@
 
   bool hasDefinition() const { return DefinitionData || dataPtr(); }
 
+  RecordDecl::field_iterator field_begin() const {
+assert(hasDefinition() && "Definition not available to get fields.");
+return static_cast(getDefinition())->field_begin();
+  }
+
+  RecordDecl::field_iterator field_end() const {
+return field_iterator(decl_iterator());
+  }
+
+  RecordDecl::field_range fields() const {
+return field_range(field_begin(), field_end());
+  }
+
+  bool field_empty() const { return field_begin() == field_end(); }
+
   static CXXRecordDecl *Create(const ASTContext , TagKind TK, DeclContext 
*DC,
SourceLocation StartLoc, SourceLocation IdLoc,
IdentifierInfo *Id,


Index: clang/include/clang/AST/DeclCXX.h
===
--- clang/include/clang/AST/DeclCXX.h
+++ clang/include/clang/AST/DeclCXX.h
@@ -554,6 +554,21 @@
 
   bool hasDefinition() const { return DefinitionData || dataPtr(); }
 
+  RecordDecl::field_iterator field_begin() const {
+assert(hasDefinition() && "Definition not available to get fields.");
+return static_cast(getDefinition())->field_begin();
+  }
+
+  RecordDecl::field_iterator field_end() const {
+return field_iterator(decl_iterator());
+  }
+
+  RecordDecl::field_range fields() const {
+return field_range(field_begin(), field_end());
+  }
+
+  bool field_empty() const { return field_begin() == field_end(); }
+
   static CXXRecordDecl *Create(const ASTContext , TagKind TK, DeclContext *DC,
SourceLocation StartLoc, SourceLocation IdLoc,
IdentifierInfo *Id,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141861: [nvptx-arch] Dynamically load the CUDA runtime if not found during the build

2023-01-31 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D141861#4094058 , @srj wrote:

> In D141861#4094043 , @jhuber6 wrote:
>
>> Would this just require checking `LLVM_BUILD_32_BITS`? Should be an easy 
>> change.
>
> I think so. (It might be tempting to check `if (CMAKE_SIZEOF_VOID_P EQUAL 8)` 
> but LLVM_BUILD_32_BITS is likely to be a more explicit signal.)

SG, want me to push that real quick?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141861

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


[PATCH] D141861: [nvptx-arch] Dynamically load the CUDA runtime if not found during the build

2023-01-31 Thread Steven Johnson via Phabricator via cfe-commits
srj added a comment.

In D141861#4094043 , @jhuber6 wrote:

> Would this just require checking `LLVM_BUILD_32_BITS`? Should be an easy 
> change.

I think so. (It might be tempting to check `if (CMAKE_SIZEOF_VOID_P EQUAL 8)` 
but LLVM_BUILD_32_BITS is likely to be a more explicit signal.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141861

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


[PATCH] D142992: [include-mapping] Implement language separation in stdlib recognizer library

2023-01-31 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 493651.
VitaNuo added a comment.

Remove comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142992

Files:
  clang/include/clang/Tooling/Inclusions/StandardLibrary.h
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp

Index: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
===
--- clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -8,6 +8,8 @@
 
 #include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "clang/AST/Decl.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/LangStandard.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 
@@ -15,35 +17,54 @@
 namespace tooling {
 namespace stdlib {
 
-static llvm::StringRef *HeaderNames;
-static std::pair *SymbolNames;
-static unsigned *SymbolHeaderIDs;
-static llvm::DenseMap *HeaderIDs;
 // Maps symbol name -> Symbol::ID, within a namespace.
 using NSSymbolMap = llvm::DenseMap;
-static llvm::DenseMap *NamespaceSymbols;
 
-static int initialize() {
+struct SymbolHeaderMapping {
+  llvm::StringRef *HeaderNames;
+  std::pair *SymbolNames;
+  unsigned *SymbolHeaderIDs;
+  llvm::DenseMap HeaderIDs;
+  llvm::DenseMap NamespaceSymbols;
+};
+
+static llvm::DenseMap LanguageMappings;
+
+static int countSymbols(Lang Language) {
   unsigned SymCount = 0;
 #define SYMBOL(Name, NS, Header) ++SymCount;
+  switch (Language) {
+  case Lang::C:
 #include "clang/Tooling/Inclusions/CSymbolMap.inc"
+break;
+  case Lang::Cpp:
 #include "clang/Tooling/Inclusions/StdSymbolMap.inc"
+break;
+  }
 #undef SYMBOL
-  SymbolNames = new std::remove_reference_t[SymCount];
-  SymbolHeaderIDs =
-  new std::remove_reference_t[SymCount];
-  NamespaceSymbols = new std::remove_reference_t;
-  HeaderIDs = new std::remove_reference_t;
+  return SymCount;
+}
+
+static void initialize(Lang Language) {
+  SymbolHeaderMapping *Mapping = new SymbolHeaderMapping();
+  LanguageMappings.try_emplace(Language, Mapping);
+
+  unsigned SymCount = countSymbols(Language);
+  Mapping->SymbolNames =
+  new std::remove_reference_tSymbolNames)>[SymCount];
+  Mapping->SymbolHeaderIDs = new std::remove_reference_t<
+  decltype(*Mapping->SymbolHeaderIDs)>[SymCount];
 
   auto AddNS = [&](llvm::StringRef NS) -> NSSymbolMap & {
-auto R = NamespaceSymbols->try_emplace(NS, nullptr);
+auto R = Mapping->NamespaceSymbols.try_emplace(NS, nullptr);
 if (R.second)
   R.first->second = new NSSymbolMap();
 return *R.first->second;
   };
 
   auto AddHeader = [&](llvm::StringRef Header) -> unsigned {
-return HeaderIDs->try_emplace(Header, HeaderIDs->size()).first->second;
+return Mapping->HeaderIDs.try_emplace(Header, Mapping->HeaderIDs.size())
+.first->second;
   };
 
   auto Add = [&, SymIndex(0)](llvm::StringRef Name, llvm::StringRef NS,
@@ -51,8 +72,8 @@
 if (NS == "None")
   NS = "";
 
-SymbolNames[SymIndex] = {NS, Name};
-SymbolHeaderIDs[SymIndex] = AddHeader(HeaderName);
+Mapping->SymbolNames[SymIndex] = {NS, Name};
+Mapping->SymbolHeaderIDs[SymIndex] = AddHeader(HeaderName);
 
 NSSymbolMap  = AddNS(NS);
 NSSymbols.try_emplace(Name, SymIndex);
@@ -60,14 +81,24 @@
 ++SymIndex;
   };
 #define SYMBOL(Name, NS, Header) Add(#Name, #NS, #Header);
+  switch (Language) {
+  case Lang::C:
 #include "clang/Tooling/Inclusions/CSymbolMap.inc"
+break;
+  case Lang::Cpp:
 #include "clang/Tooling/Inclusions/StdSymbolMap.inc"
+break;
+  }
 #undef SYMBOL
 
-  HeaderNames = new llvm::StringRef[HeaderIDs->size()];
-  for (const auto  : *HeaderIDs)
-HeaderNames[E.second] = E.first;
+  Mapping->HeaderNames = new llvm::StringRef[Mapping->HeaderIDs.size()];
+  for (const auto  : Mapping->HeaderIDs)
+Mapping->HeaderNames[E.second] = E.first;
+}
 
+static int initialize() {
+  for (Lang Language : AllLangs)
+initialize(Language);
   return 0;
 }
 
@@ -76,38 +107,67 @@
   (void)Dummy;
 }
 
-std::optional Header::named(llvm::StringRef Name) {
+static SymbolHeaderMapping *GetMapping(Lang Language) {
+  auto MapIt = LanguageMappings.find(Language);
+  SymbolHeaderMapping *Mapping = MapIt->getSecond();
+  return Mapping;
+}
+
+std::optional Header::named(llvm::StringRef Name, Lang Language) {
   ensureInitialized();
-  auto It = HeaderIDs->find(Name);
-  if (It == HeaderIDs->end())
+  SymbolHeaderMapping *Mapping = GetMapping(Language);
+  auto It = Mapping->HeaderIDs.find(Name);
+  if (It == Mapping->HeaderIDs.end())
 return std::nullopt;
-  return Header(It->second);
+  return Header(It->second, Language);
 }
-llvm::StringRef Header::name() const { return HeaderNames[ID]; }
-llvm::StringRef Symbol::scope() const { return SymbolNames[ID].first; }
-llvm::StringRef Symbol::name() const { return SymbolNames[ID].second; }

[PATCH] D142992: [include-mapping] Implement language separation in stdlib recognizer library

2023-01-31 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo created this revision.
Herald added a project: All.
VitaNuo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142992

Files:
  clang/include/clang/Tooling/Inclusions/StandardLibrary.h
  clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp

Index: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
===
--- clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -8,6 +8,8 @@
 
 #include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "clang/AST/Decl.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/LangStandard.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 
@@ -15,35 +17,58 @@
 namespace tooling {
 namespace stdlib {
 
-static llvm::StringRef *HeaderNames;
-static std::pair *SymbolNames;
-static unsigned *SymbolHeaderIDs;
-static llvm::DenseMap *HeaderIDs;
 // Maps symbol name -> Symbol::ID, within a namespace.
 using NSSymbolMap = llvm::DenseMap;
-static llvm::DenseMap *NamespaceSymbols;
 
-static int initialize() {
+struct SymbolHeaderMapping {
+  llvm::StringRef *HeaderNames;
+  std::pair *SymbolNames;
+  unsigned *SymbolHeaderIDs;
+  llvm::DenseMap HeaderIDs;
+  llvm::DenseMap NamespaceSymbols;
+};
+
+static llvm::DenseMap LanguageMappings;
+
+static int countSymbols(Lang Language) {
   unsigned SymCount = 0;
 #define SYMBOL(Name, NS, Header) ++SymCount;
+  switch (Language) {
+  case Lang::C:
 #include "clang/Tooling/Inclusions/CSymbolMap.inc"
+break;
+  case Lang::Cpp:
 #include "clang/Tooling/Inclusions/StdSymbolMap.inc"
+break;
+  }
 #undef SYMBOL
-  SymbolNames = new std::remove_reference_t[SymCount];
-  SymbolHeaderIDs =
-  new std::remove_reference_t[SymCount];
-  NamespaceSymbols = new std::remove_reference_t;
-  HeaderIDs = new std::remove_reference_t;
+  return SymCount;
+}
+
+static void initialize(Lang Language) {
+  SymbolHeaderMapping *Mapping = new SymbolHeaderMapping();
+  LanguageMappings.try_emplace(Language, Mapping);
+
+  unsigned SymCount = countSymbols(Language);
+  Mapping->SymbolNames =
+  new std::remove_reference_tSymbolNames)>[SymCount];
+  Mapping->SymbolHeaderIDs = new std::remove_reference_t<
+  decltype(*Mapping->SymbolHeaderIDs)>[SymCount];
+  // Mapping->NamespaceSymbols =
+  // new std::remove_reference_tNamespaceSymbols)>;
+  // Mapping->HeaderIDs =
+  // new std::remove_reference_tHeaderIDs)>;
 
   auto AddNS = [&](llvm::StringRef NS) -> NSSymbolMap & {
-auto R = NamespaceSymbols->try_emplace(NS, nullptr);
+auto R = Mapping->NamespaceSymbols.try_emplace(NS, nullptr);
 if (R.second)
   R.first->second = new NSSymbolMap();
 return *R.first->second;
   };
 
   auto AddHeader = [&](llvm::StringRef Header) -> unsigned {
-return HeaderIDs->try_emplace(Header, HeaderIDs->size()).first->second;
+return Mapping->HeaderIDs.try_emplace(Header, Mapping->HeaderIDs.size())
+.first->second;
   };
 
   auto Add = [&, SymIndex(0)](llvm::StringRef Name, llvm::StringRef NS,
@@ -51,8 +76,8 @@
 if (NS == "None")
   NS = "";
 
-SymbolNames[SymIndex] = {NS, Name};
-SymbolHeaderIDs[SymIndex] = AddHeader(HeaderName);
+Mapping->SymbolNames[SymIndex] = {NS, Name};
+Mapping->SymbolHeaderIDs[SymIndex] = AddHeader(HeaderName);
 
 NSSymbolMap  = AddNS(NS);
 NSSymbols.try_emplace(Name, SymIndex);
@@ -60,14 +85,24 @@
 ++SymIndex;
   };
 #define SYMBOL(Name, NS, Header) Add(#Name, #NS, #Header);
+  switch (Language) {
+  case Lang::C:
 #include "clang/Tooling/Inclusions/CSymbolMap.inc"
+break;
+  case Lang::Cpp:
 #include "clang/Tooling/Inclusions/StdSymbolMap.inc"
+break;
+  }
 #undef SYMBOL
 
-  HeaderNames = new llvm::StringRef[HeaderIDs->size()];
-  for (const auto  : *HeaderIDs)
-HeaderNames[E.second] = E.first;
+  Mapping->HeaderNames = new llvm::StringRef[Mapping->HeaderIDs.size()];
+  for (const auto  : Mapping->HeaderIDs)
+Mapping->HeaderNames[E.second] = E.first;
+}
 
+static int initialize() {
+  for (Lang Language : AllLangs)
+initialize(Language);
   return 0;
 }
 
@@ -76,38 +111,67 @@
   (void)Dummy;
 }
 
-std::optional Header::named(llvm::StringRef Name) {
+static SymbolHeaderMapping *GetMapping(Lang Language) {
+  auto MapIt = LanguageMappings.find(Language);
+  SymbolHeaderMapping *Mapping = MapIt->getSecond();
+  return Mapping;
+}
+
+std::optional Header::named(llvm::StringRef Name, Lang Language) {
   ensureInitialized();
-  auto It = HeaderIDs->find(Name);
-  if (It == HeaderIDs->end())
+  SymbolHeaderMapping *Mapping = GetMapping(Language);
+  auto It = Mapping->HeaderIDs.find(Name);
+  if (It == Mapping->HeaderIDs.end())
 return std::nullopt;
-  return Header(It->second);
+  return Header(It->second, Language);
 }
-llvm::StringRef Header::name() const 

[PATCH] D142757: [clang][driver] Emit an error for `/clang:-x`

2023-01-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.



Comment at: clang/test/Driver/x-args.c:12
+// RUN: not %clang_cl /TC /WX /clang:-xc /clang:-E /clang:-dM %s 2>&1 | 
FileCheck -check-prefix=CL %s
+// CL-NOT: '-x c' after last input file has no effect
+// CL: error: unsupported option '-x c'; did you mean '/TC' or '/TP'?

You can remove this `CL-NOT` negative pattern. Instead, use `--check-prefix=CL 
--implicit-check-not=error:` to check that there is no other error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142757

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


  1   2   3   >