[PATCH] D118439: [scan-build] Fix deadlock at failures in libears/ear.c

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

We missed the release, let's backport it to 14.0.0.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118439

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


[PATCH] D119256: [OpenMP][Clang] Move partial support of reverse offload to a future version

2022-02-08 Thread Saiyedul Islam 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 rG4db88a54b6d4: [OpenMP][Clang] Move partial support of 
reverse offload to a future version (authored by saiislam).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119256

Files:
  clang/test/OpenMP/requires_ast_print.cpp
  clang/test/OpenMP/requires_messages.cpp
  clang/test/OpenMP/requires_target_messages.cpp
  clang/test/OpenMP/target_ast_print.cpp
  clang/test/OpenMP/target_device_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -590,7 +590,15 @@
   let allowedClauses = [
 VersionedClause,
 VersionedClause,
-VersionedClause,
+// OpenMP 5.2 Spec: If an implementation is not supporting a requirement
+// (reverse offload in this case) then it should give compile-time error
+// termination.
+// Seeting supported version for reverse_offload to a distant future version
+// 9.9 so that its partial support can be tested in the meantime.
+//
+// TODO: Correct this supprted version number whenever complete
+// implementation of reverse_offload is available.
+VersionedClause,
 VersionedClause,
 VersionedClause
   ];
Index: clang/test/OpenMP/target_device_codegen.cpp
===
--- clang/test/OpenMP/target_device_codegen.cpp
+++ clang/test/OpenMP/target_device_codegen.cpp
@@ -6,12 +6,25 @@
 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=99 -DOMP99 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,REV
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=99 -DOMP99 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=99 -DOMP99 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,REV
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=99 -DOMP99 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefixes=SIMD-ONLY0
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=99 -DOMP99 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=99 -DOMP99 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=SIMD-ONLY0
+
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER
+
+#ifdef OMP99
 #pragma omp requires reverse_offload
+#endif
+
 void foo(int n) {
 
   // CHECK:   [[N:%.+]] = load i32, i32* [[N_ADDR:%.+]],
@@ -40,11 +53,14 @@
   // CHECK:   [[END]]
   #pragma omp target device(device_num: n)
   ;
-  // CHECK-NOT:   call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}},
-  // CHECK:   call void @__omp_offloading_{{.+}}_l46()
-  // CHECK-NOT:   call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}},
+
+#ifdef OMP99
+  // REV-NOT:   call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}},
+  // REV:   call void @__omp_offloading_{{.+}}_l61()
+  // REV-NOT:   call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}},
   #pragma omp target device(ancestor: n)
   ;
+#endif
 }
 
 #endif
Index: clang/test/OpenMP/target_ast_print.cpp
===
--- clang/test/OpenMP/target_ast_print.cpp
+++ clang/test/OpenMP/target_ast_print.cpp
@@ -342,7 +342,18 @@
 // RUN: %clang_cc1 -DOMP5 -verify -fopenmp-simd -fopenmp-version=50 -ast-print %s | FileCheck %s --check-prefix OMP5
 // RUN: %clang_cc1 -DOMP5 -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s
 // RUN: %clang_cc1 -DOMP5 -fopenmp-simd -fopenmp-version=50 -std=c++11 

[clang] 4db88a5 - [OpenMP][Clang] Move partial support of reverse offload to a future version

2022-02-08 Thread Saiyedul Islam via cfe-commits

Author: Saiyedul Islam
Date: 2022-02-09T07:11:41Z
New Revision: 4db88a54b6d4bd38fe38dbe57ec2a156ff3c144e

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

LOG: [OpenMP][Clang] Move partial support of reverse offload to a future version

OpenMP Spec 5.2 requires unimplemented requires clauses to produce
compile time error termination. Moving current partial support of
reverse_offload to a distant future version 9.9 so that existing
code can be tested and maintained until a complete implementation
is available.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/test/OpenMP/requires_ast_print.cpp
clang/test/OpenMP/requires_messages.cpp
clang/test/OpenMP/requires_target_messages.cpp
clang/test/OpenMP/target_ast_print.cpp
clang/test/OpenMP/target_device_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/clang/test/OpenMP/requires_ast_print.cpp 
b/clang/test/OpenMP/requires_ast_print.cpp
index e884c71c86635..8343608070c18 100644
--- a/clang/test/OpenMP/requires_ast_print.cpp
+++ b/clang/test/OpenMP/requires_ast_print.cpp
@@ -5,6 +5,14 @@
 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only 
-verify %s -ast-print | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=99 -DOMP99 -ast-print %s 
| FileCheck --check-prefixes=CHECK,REV %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=99 -DOMP99 -x c++ -std=c++11 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=99 -DOMP99 -std=c++11 
-include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck 
--check-prefixes=CHECK,REV %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=99 -DOMP99 
-ast-print %s | FileCheck --check-prefixes=CHECK,REV %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=99 -DOMP99 -x c++ -std=c++11 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=99 -DOMP99 -std=c++11 
-include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck 
--check-prefixes=CHECK,REV %s
 // expected-no-diagnostics
 
 #ifndef HEADER
@@ -16,8 +24,10 @@
 #pragma omp requires unified_shared_memory
 // CHECK:#pragma omp requires unified_shared_memory
 
+#ifdef OMP99
 #pragma omp requires reverse_offload
-// CHECK:#pragma omp requires reverse_offload
+// REV:#pragma omp requires reverse_offload
+#endif
 
 #pragma omp requires dynamic_allocators
 // CHECK:#pragma omp requires dynamic_allocators

diff  --git a/clang/test/OpenMP/requires_messages.cpp 
b/clang/test/OpenMP/requires_messages.cpp
index 72a6c5022975e..10d311631b100 100644
--- a/clang/test/OpenMP/requires_messages.cpp
+++ b/clang/test/OpenMP/requires_messages.cpp
@@ -1,9 +1,10 @@
 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100  %s -Wuninitialized
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=99 -DOMP99 
-verify=expected,rev -ferror-limit 100  %s -Wuninitialized
 
 int a;
-#pragma omp requires unified_address allocate(a) // expected-note 
{{unified_address clause previously used here}} expected-note {{unified_address 
clause previously used here}} expected-note {{unified_address clause previously 
used here}} expected-note {{unified_address clause previously used here}} 
expected-note {{unified_address clause previously used here}} 
expected-note{{unified_address clause previously used here}} expected-error 
{{unexpected OpenMP clause 'allocate' in directive '#pragma omp requires'}}
+#pragma omp requires unified_address allocate(a) // rev-note {{unified_address 
clause previously used here}} expected-note {{unified_address clause previously 
used here}} expected-note {{unified_address clause previously used here}} 
expected-note {{unified_address clause previously used here}} expected-note 
{{unified_address clause previously used here}} expected-note{{unified_address 
clause previously used here}} expected-error {{unexpected OpenMP clause 
'allocate' in directive '#pragma omp requires'}}
 
-#pragma omp requires unified_shared_memory // expected-note 
{{unified_shared_memory clause previously used here}} 
expected-note{{unified_shared_memory clause previously used here}}
+#pragma omp requires unified_shared_memory // rev-note {{unified_shared_memory 
clause previously used here}} expected-note{{unified_shared_memory clause 
previously used here}}
 
 #pragma omp requires unified_shared_memory, unified_shared_memory // 
expected-error {{Only one unified_shared_memory clause can appear on a requires 
directive in a single translation unit}} expected-error {{directive '#pragma 
omp requires' cannot contain more than one 'unified_shared_memory' 

[PATCH] D84225: [CFE] Add nomerge function attribute to inline assembly.

2022-02-08 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D84225#3305140 , @rnk wrote:

> In D84225#3304189 , @pengfei wrote:
>
>> It's not a workaround. We do need to avoid the merging sometime. For 
>> example, given we have 2 branches begin with inline asm of `endbr`. We have 
>> to use `nomerge` to stop them been merged out of the branches. `sideeffect` 
>> doesn't help with that.
>
> That doesn't sound sufficient to ensure that `endbr` will be the first 
> instruction in that basic block, which I'm guessing is a requirement. PHI 
> nodes might cause register copies / spills to appear before `endbr`, and 
> instrumentation passes typically insert code at the top of basic blocks. It 
> sounds like we might need a more complete solution for tracking indirect 
> branch target blocks. Maybe `indirectbr` and basic block addresses already 
> feed into this, but I'm out of my depth here.
>
> Anyway, I don't want to make a value judgment here. I'm in favor of this 
> change. We should allow users to apply `nomerge` to inline asm, whether it is 
> a workaround or not.

Thanks @rnk . Yes, so we emit `endbr` in a backend pass rather than this way. I 
just want to demonstrate why we can't merge inline asm sometime. I don't have a 
better example at a short time :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84225

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


[PATCH] D118948: [MTE] Add -fsanitize=memtag* and friends.

2022-02-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: lld/ELF/Driver.cpp:690
+if (config->memtagStack || config->memtagHeap)
+  error("When using --memtag-stack or --memtag-heap, a --memtag-mode value 
"
+"is required.");

lld uses the diagnostic format specified by 
https://llvm.org/docs/CodingStandards.html#error-and-warning-messages

Please see other `error` and `warn` messages. No capitalization. No trailing 
perioid.



Comment at: lld/ELF/Options.td:728
+// remap the stack as PROT_MTE.
+defm memtag_stack: B<"memtag-stack",
+"Instruct the dynamic loader to prepare for MTE stack instrumentation", 
"">;

`B`/`Eq` is for legacy options which accept single-dash forms. Newer options 
should use `BB` and `EEq`.



Comment at: lld/ELF/SyntheticSections.h:1195
+  : SyntheticSection(llvm::ELF::SHF_ALLOC, llvm::ELF::SHT_NOTE,
+ /* alignment */ 4, ".note.android.memtag") {}
+  void writeTo(uint8_t *buf) override;

MaskRay wrote:
> `/*alignment=*/4`
no space after `/*`



Comment at: lld/test/ELF/aarch64-memtag-android-abi.s:3
+
+# Old versions of Android (Android 11 & 12) have very strict parsing logic on
+# the layout of the ELF note. This test serves as a "hey, you're going to break

In lld and llvm binary utilities, we use `##` for non-RUN-non-CHECK comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118948

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


[PATCH] D118948: [MTE] Add -fsanitize=memtag* and friends.

2022-02-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D118948#3295589 , @hctim wrote:

> In D118948#3295321 , @MaskRay wrote:
>
>> I haven't investigated the use case yet, just commented a few things. Please 
>> split the patch into 3:
>>
>> - BinaryFormat/ELF.h (see an inline comment)
>> - lld/ELF
>> - clang
>
> Can you clarify what you'd like (from D107949 
> ) in patch #1?

For patch #1, make yaml2obj support the `NT_*` tags (`grep NT_ 
llvm-readobj/ELF/note-*.test`) and obj2yaml able to dump the tag. Add 
llvm-readobj support.

llvm-objdump support may be unneeded.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118948

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


[PATCH] D116261: [Clang][OpenMP] Add support for compare capture in parser

2022-02-08 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 marked 2 inline comments as done.
tianshilei1992 added inline comments.



Comment at: clang/lib/AST/OpenMPClause.cpp:1804
+void OMPClausePrinter::VisitOMPCompareCaptureClause(OMPCompareCaptureClause *) 
{
+  // Do nothing as it is dummy.
+}

ABataev wrote:
> Output?
I did it on purpose because `OMPCompareCaptureClause` is a dummy node. When it 
is visited (I really doubt if it can be visited because we don't create it 
explicitly), it should not output any thing. `compare` and `capture` are 
printed when visiting the two clauses.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:11363-11364
   break;
+case OMPC_compare_capture:
+  llvm_unreachable("OMPC_compare_capture should never be created");
 default:

ABataev wrote:
> Why?
For the same reason for the output in AST.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116261

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


[PATCH] D119296: KCFI sanitizer

2022-02-08 Thread Joao Moreira via Phabricator via cfe-commits
joaomoreira added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:696
+def KCFIUnchecked : Attr {
+  let Spellings = [Clang<"kcfi_unchecked">];
+  let Subjects = SubjectList<[Var, TypedefName]>;

Are you considering that perhaps one could use KCFI and X86 CET/IBT at the same 
time? If not, is there a reason for not just reusing the existing "nocf_check" 
attribute?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119296

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


[clang] a163cdf - [docs] Re-generate ClangCommandLineReference.rst

2022-02-08 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-02-08T20:54:52-08:00
New Revision: a163cdf6b50c0b7706fcf7805fd29736ad4eb9c2

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

LOG: [docs] Re-generate ClangCommandLineReference.rst

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index e4b5c1a78044..c03a4c2bbc1e 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -20,7 +20,7 @@ GCC-compatible ``clang`` and ``clang++`` drivers.
 .. program:: clang
 .. option:: -B, --prefix , --prefix=
 
-Search $prefix/$triple-$file and $prefix$file for executables, libraries, 
includes, and data files used by the compiler. $prefix may or may not be a 
directory
+Search $prefix$file for executables, libraries, and data files. If $prefix is 
a directory, search $prefix/$file
 
 .. option:: -F
 
@@ -513,7 +513,7 @@ CUDA offloading device architecture (e.g. sm\_35), or HIP 
offloading target ID i
 
 .. option:: --offload=,...
 
-Specify comma-separated list of offloading target triples (HIP only)
+Specify comma-separated list of offloading target triples (CUDA and HIP only)
 
 .. option:: -p, --profile
 
@@ -797,6 +797,14 @@ Use the LLVM representation for assembler and object files
 
 Generate Interface Stub Files, emit merged text not binary.
 
+.. option:: -extract-api
+
+Extract API information
+
+.. option:: -fopenmp-new-driver
+
+Use the new driver for OpenMP offloading.
+
 .. option:: -fsyntax-only
 
 .. option:: -module-file-info
@@ -899,7 +907,7 @@ Inline suitable functions
 
 Inline functions which are (explicitly or implicitly) marked inline
 
-.. option:: -flegacy-pass-manager, -fno-experimental-new-pass-manager, 
-fno-legacy-pass-manager
+.. option:: -flegacy-pass-manager, -fno-legacy-pass-manager
 
 Use the legacy pass manager in LLVM (deprecated, to be removed in a future 
release)
 
@@ -1232,9 +1240,9 @@ Set directory to include search path with prefix
 
 Add directory to SYSTEM include search path, absolute paths are relative to 
-isysroot
 
-.. option:: --libomptarget-amdgpu-bc-path=
+.. option:: --libomptarget-amdgpu-bc-path=, 
--libomptarget-amdgcn-bc-path=
 
-Path to libomptarget-amdgpu bitcode library
+Path to libomptarget-amdgcn bitcode library
 
 .. option:: --libomptarget-nvptx-bc-path=
 
@@ -1673,6 +1681,10 @@ Do not emit  debug info for defined but unused types
 
 Embed LLVM bitcode (option: off, all, bitcode, marker)
 
+.. option:: -fembed-offload-object=
+
+Embed Offloading device-side binary into host object file as a section.
+
 .. option:: -femit-all-decls
 
 Emit all declarations, even if unused
@@ -1725,8 +1737,6 @@ Assume all loops are finite.
 
 .. option:: -ffinite-math-only, -fno-finite-math-only
 
-Allow floating-point optimizations that assume arguments and results are not 
NaNs or +-inf. This defines the \_\_FINITE\_MATH\_ONLY\_\_ preprocessor macro.
-
 .. option:: -ffixed-point, -fno-fixed-point
 
 Enable fixed point types
@@ -1807,14 +1817,10 @@ Specify that single precision floating-point divide and 
sqrt used in the program
 
 Use new kernel launching API for HIP
 
-.. option:: -fhonor-infinities, -fhonor-infinites, -fno-honor-infinities, 
-fno-honor-infinites
-
-Specify that floating-point optimizations are not allowed that assume 
arguments and results are not +-inf.
+.. option:: -fhonor-infinities, -fhonor-infinites, -fno-honor-infinities
 
 .. option:: -fhonor-nans, -fno-honor-nans
 
-Specify that floating-point optimizations are not allowed that assume 
arguments and results are not NANs.
-
 .. option:: -fhosted
 
 .. option:: -fignore-exceptions
@@ -1963,6 +1969,10 @@ Dot-separated value representing the Microsoft compiler 
version number to report
 
 Accept some non-standard constructs supported by the Microsoft compiler
 
+.. option:: -fms-hotpatch
+
+Ensure that all functions can be hotpatched at runtime
+
 .. option:: -fms-memptr-rep=
 
 .. option:: -fms-volatile
@@ -2071,6 +2081,10 @@ Parse OpenMP pragmas and generate parallel code.
 
 Enable all Clang extensions for OpenMP directives and clauses
 
+.. option:: -fopenmp-implicit-rpath, -fno-openmp-implicit-rpath
+
+Set rpath on OpenMP executables
+
 .. option:: -fopenmp-simd, -fno-openmp-simd
 
 Emit OpenMP code only for SIMD-based constructs.
@@ -2083,10 +2097,6 @@ Enable debugging in the OpenMP offloading device RTL
 
 Use the new bitcode library for OpenMP offloading
 
-.. option:: -fopenmp-new-driver
-
-Use the new scheme for creating and linking OpenMP offloading code
-
 .. option:: -fopenmp-version=
 
 Set OpenMP version (e.g. 45 for OpenMP 4.5, 50 for OpenMP 5.0). Default value 
is 50.
@@ -2306,6 +2316,10 @@ Generate read-only 

[PATCH] D117809: [clang] Add an extract-api driver option

2022-02-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Thanks for working on such tools but the patch order is not right.
You should implement the functionality first, and in the last, add the driver 
option.
The driver option is user-facing and the availability makes users think the 
functionality is ready when it actually isn't.

I am also a bit unsure whether the option name should use the single-dash `-e*` 
since `-e` is a short option taking a value, so a typo in `-extract-api` cannot 
be detected.
By convention a two-dash option should be used.
(Yes, I know `-emit-llvm` is a violation.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117809

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


[PATCH] D119309: [Driver][test] Clean up some AIX tests

2022-02-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 407038.
MaskRay edited the summary of this revision.
MaskRay added a comment.

update more


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119309

Files:
  clang/test/Driver/aix-as.c
  clang/test/Driver/aix-err-options.c
  clang/test/Driver/aix-ld.c
  clang/test/Driver/aix-mcpu-default.c
  clang/test/Driver/aix-rtlib.c
  clang/test/Driver/aix-toolchain-include.cpp

Index: clang/test/Driver/aix-toolchain-include.cpp
===
--- clang/test/Driver/aix-toolchain-include.cpp
+++ clang/test/Driver/aix-toolchain-include.cpp
@@ -1,31 +1,31 @@
 // Tests that the AIX toolchain adds system includes to its search path.
 
 // Check powerpc-ibm-aix, 32-bit/64-bit.
-// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
-// RUN:		-target powerpc-ibm-aix \
+// RUN: %clangxx -### %s 2>&1 \
+// RUN:		--target=powerpc-ibm-aix \
 // RUN:		-resource-dir=%S/Inputs/resource_dir \
 // RUN:		--sysroot=%S/Inputs/basic_aix_tree \
 // RUN:   | FileCheck -check-prefixes=CHECK-INTERNAL-INCLUDE,CHECK-INTERNAL-INCLUDE-CXX %s
 
-// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
-// RUN:		-target powerpc64-ibm-aix \
+// RUN: %clangxx -### %s 2>&1 \
+// RUN:		--target=powerpc64-ibm-aix \
 // RUN:		-resource-dir=%S/Inputs/resource_dir \
 // RUN:		--sysroot=%S/Inputs/basic_aix_tree \
 // RUN:   | FileCheck -check-prefixes=CHECK-INTERNAL-INCLUDE,CHECK-INTERNAL-INCLUDE-CXX %s
 
-// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
-// RUN:		-target powerpc-ibm-aix \
+// RUN: %clang -### -xc %s 2>&1 \
+// RUN:		--target=powerpc-ibm-aix \
 // RUN:		-resource-dir=%S/Inputs/resource_dir \
 // RUN:		--sysroot=%S/Inputs/basic_aix_tree \
 // RUN:   | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
 
-// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
-// RUN:		-target powerpc64-ibm-aix \
+// RUN: %clang -### -xc %s 2>&1 \
+// RUN:		--target=powerpc64-ibm-aix \
 // RUN:		-resource-dir=%S/Inputs/resource_dir \
 // RUN:		--sysroot=%S/Inputs/basic_aix_tree \
 // RUN:   | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
 
-// CHECK-INTERNAL-INCLUDE:  {{.*}}clang{{.*}}" "-cc1"
+// CHECK-INTERNAL-INCLUDE:  "-cc1"
 // CHECK-INTERNAL-INCLUDE:  "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-INTERNAL-INCLUDE:  "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-INTERNAL-INCLUDE-CXX:  "-internal-isystem" "[[SYSROOT]]{{(/|)}}opt{{(/|)}}IBM{{(/|)}}openxlCSDK{{(/|)}}include{{(/|)}}c++{{(/|)}}v1"
@@ -34,69 +34,69 @@
 // CHECK-INTERNAL-INCLUDE:  "-internal-isystem" "[[SYSROOT]]/usr/include"
 
 // Check powerpc-ibm-aix, 32-bit/64-bit. -nostdinc option.
-// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
-// RUN:		-target powerpc-ibm-aix \
+// RUN: %clangxx -### %s 2>&1 \
+// RUN:		--target=powerpc-ibm-aix \
 // RUN:		-resource-dir=%S/Inputs/resource_dir \
 // RUN:		--sysroot=%S/Inputs/basic_aix_tree \
 // RUN:		-nostdinc \
 // RUN:   | FileCheck -check-prefix=CHECK-NOSTDINC-INCLUDE %s
 
-// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
-// RUN:		-target powerpc64-ibm-aix \
+// RUN: %clangxx -### %s 2>&1 \
+// RUN:		--target=powerpc64-ibm-aix \
 // RUN:		-resource-dir=%S/Inputs/resource_dir \
 // RUN:		--sysroot=%S/Inputs/basic_aix_tree \
 // RUN:		-nostdinc \
 // RUN:   | FileCheck -check-prefix=CHECK-NOSTDINC-INCLUDE %s
 
-// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
-// RUN:		-target powerpc-ibm-aix \
+// RUN: %clang -### -xc %s 2>&1 \
+// RUN:		--target=powerpc-ibm-aix \
 // RUN:		-resource-dir=%S/Inputs/resource_dir \
 // RUN:		--sysroot=%S/Inputs/basic_aix_tree \
 // RUN:		-nostdinc \
 // RUN:   | FileCheck -check-prefix=CHECK-NOSTDINC-INCLUDE %s
 
-// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
-// RUN:		-target powerpc64-ibm-aix \
+// RUN: %clang -### -xc %s 2>&1 \
+// RUN:		--target=powerpc64-ibm-aix \
 // RUN:		-resource-dir=%S/Inputs/resource_dir \
 // RUN:		--sysroot=%S/Inputs/basic_aix_tree \
 // RUN:		-nostdinc \
 // RUN:   | FileCheck -check-prefix=CHECK-NOSTDINC-INCLUDE %s
 
-// CHECK-NOSTDINC-INCLUDE:	{{.*}}clang{{.*}}" "-cc1"
+// CHECK-NOSTDINC-INCLUDE:	"-cc1"
 // CHECK-NOSTDINC-INCLUDE:	"-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-NOSTDINC-INCLUDE:	"-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-NOSTDINC-INCLUDE-NOT:	"-internal-isystem"
 
 // Check powerpc-ibm-aix, 32-bit/64-bit. -nostdlibinc option.
-// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
-// RUN:		-target powerpc-ibm-aix \
+// RUN: %clangxx -### %s 2>&1 \
+// RUN:		--target=powerpc-ibm-aix \
 // RUN:		-resource-dir=%S/Inputs/resource_dir \
 // RUN:		--sysroot=%S/Inputs/basic_aix_tree \
 // RUN:		-nostdlibinc \
 // RUN:   | FileCheck -check-prefix=CHECK-NOSTDLIBINC-INCLUDE %s
 
-// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
-// RUN:		-target powerpc64-ibm-aix \
+// RUN: %clangxx -### %s 2>&1 \
+// RUN:		

[PATCH] D119309: [Driver][test] Clean up some AIX tests

2022-02-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: DiggerLin, hubert.reinterpretcast, jasonliu, stevewan, 
Xiangling_L.
Herald added a reviewer: ctetreau.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- For `-###`, `-o %t.o` is unnecessary if we don't specifically test the output 
filename.
- --target= is the canonical spelling. -target is a legacy spelling which 
unfortunately cannot be removed because there are too many uses.
- -no-canonical-prefixes uses the dereferenced absolute path for the cc1 
command. For most tests "-cc1" is sufficient to identify the command line, no 
need to specifically test the "clang" command, and -no-canonical-prefixes can 
removed.
- --unwindlib= is the preferred spelling. -u is a short option taking a value, 
which means a -uwindlib= typo cannot be detected.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119309

Files:
  clang/test/Driver/aix-as.c
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -2,14 +2,14 @@
 // sysroot to make these tests independent of the host system.
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit.
-// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN: %clang %s -### 2>&1 \
 // RUN:-resource-dir=%S/Inputs/resource_dir \
-// RUN:-target powerpc-ibm-aix7.1.0.0 \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
 // RUN:--sysroot %S/Inputs/aix_ppc_tree \
-// RUN:-unwindlib=libunwind \
+// RUN:--unwindlib=libunwind \
 // RUN:   | FileCheck --check-prefix=CHECK-LD32 %s
 // CHECK-LD32-NOT: warning:
-// CHECK-LD32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
 // CHECK-LD32: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-LD32: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD32: "{{.*}}ld{{(.exe)?}}"
@@ -28,14 +28,14 @@
 // CHECK-LD32: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit.
-// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN: %clang %s -### 2>&1 \
 // RUN:-resource-dir=%S/Inputs/resource_dir \
-// RUN:-target powerpc64-ibm-aix7.1.0.0 \
+// RUN:--target=powerpc64-ibm-aix7.1.0.0 \
 // RUN:--sysroot %S/Inputs/aix_ppc_tree \
-// RUN:-unwindlib=libunwind \
+// RUN:--unwindlib=libunwind \
 // RUN:   | FileCheck --check-prefix=CHECK-LD64 %s
 // CHECK-LD64-NOT: warning:
-// CHECK-LD64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-LD64: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
 // CHECK-LD64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-LD64: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD64: "{{.*}}ld{{(.exe)?}}"
@@ -54,15 +54,15 @@
 // CHECK-LD64: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable POSIX thread support.
-// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN: %clang %s -### 2>&1 \
 // RUN:-resource-dir=%S/Inputs/resource_dir \
 // RUN:-pthread \
-// RUN:-target powerpc-ibm-aix7.1.0.0 \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
 // RUN:--sysroot %S/Inputs/aix_ppc_tree \
-// RUN:-unwindlib=libunwind \
+// RUN:--unwindlib=libunwind \
 // RUN:   | FileCheck --check-prefix=CHECK-LD32-PTHREAD %s
 // CHECK-LD32-PTHREAD-NOT: warning:
-// CHECK-LD32-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-PTHREAD: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
 // CHECK-LD32-PTHREAD: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-LD32-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD32-PTHREAD: "{{.*}}ld{{(.exe)?}}"
@@ -82,15 +82,15 @@
 // CHECK-LD32-PTHREAD: "-lc"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. POSIX thread alias.
-// RUN: %clang -no-canonical-prefixes %s -### 2>&1 \
+// RUN: %clang %s -### 2>&1 \
 // RUN:-resource-dir=%S/Inputs/resource_dir \
 // RUN:-pthreads \
-// RUN:-target powerpc64-ibm-aix7.1.0.0 \
+// RUN:--target=powerpc64-ibm-aix7.1.0.0 \
 // RUN:--sysroot %S/Inputs/aix_ppc_tree \
-// RUN:-unwindlib=libunwind \
+// RUN:--unwindlib=libunwind \
 // RUN:   | FileCheck --check-prefix=CHECK-LD64-PTHREAD %s
 // CHECK-LD64-PTHREAD-NOT: warning:
-// CHECK-LD64-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-LD64-PTHREAD: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
 // CHECK-LD64-PTHREAD: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-LD64-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD64-PTHREAD: "{{.*}}ld{{(.exe)?}}"
@@ -110,15 +110,15 @@
 // CHECK-LD64-PTHREAD: "-lc"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable profiling.
-// RUN: %clang -no-canonical-prefixes %s -### 

[PATCH] D119147: [AIX][clang][driver] Check the command string to the linker for exportlist opts

2022-02-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/Job.cpp:304
 
+void Command::setRedirectFiles(std::vector> Redirects) {
+  RedirectFiles = Redirects;





Comment at: clang/lib/Driver/Job.cpp:370
+ makeArrayRef(RedirectFilesOptional),
+ /*secondsToWait*/ 0, /*memoryLimit*/ 0,
+ ErrMsg, ExecutionFailed, );





Comment at: clang/lib/Driver/ToolChains/AIX.cpp:80
+static bool hasExportListLinkerOpts(const ArgStringList ) {
+  for (size_t i = 0; i < CmdArgs.size(); ++i) {
+llvm::StringRef ArgString(CmdArgs[i]);

https://llvm.org/docs/CodingStandards.html#don-t-evaluate-end-every-time-through-a-loop

Prefer `!=`



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:219
+
+std::unique_ptr ExpCommand = std::make_unique(
+JA, *this, ResponseFileSupport::None(), CreateExportListExec,





Comment at: clang/test/Driver/aix-ld.c:609
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. -shared (with exp option strings in 
other opt).
+// RUN: %clangxx -x c++ -no-canonical-prefixes %s 2>&1 -### \
+// RUN:-resource-dir=%S/Inputs/resource_dir \

If you don't test `clang` in CHECK lines, you can omit `-no-canonical-prefixes`

Consider switching to `.cpp` if you always use `-x c++`.



Comment at: clang/test/Driver/aix-ld.c:615
+// RUN:-ccc-install-dir 
%T/open_xl_aix_install/opt/IBM/openxlC/%open_xl_vrm/bin \
+// RUN:-unwindlib=libunwind \
+// RUN:-Wl,-Z/expall/expfull/a-bE:/a-bexport:/ \

`-u` prefixed long option form is not recommended. `-u` is a short option 
taking a value, therefore an option name typo cannot be detected.



Comment at: clang/test/Driver/aix-ld.c:624
+// CHECK-LD32-SHARED: "--export-symbols"
+// CHECK-LD32-SHARED: "-X"
+// CHECK-LD32-SHARED: "32"




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119147

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


[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2022-02-08 Thread Jim Lin via Phabricator via cfe-commits
Jim added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVRegisterInfo.td:555
+def GPRF64  : RegisterClass<"RISCV", [f64], 64, (add GPR)>;
+def GPRPF64 : RegisterClass<"RISCV", [f64], 64, (add
+X10_PD, X12_PD, X14_PD, X16_PD,

Is XLenRI correct for GPRPF64? RV32 has size 32.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

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


[PATCH] D119299: [NFC] clang-format one function.

2022-02-08 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added a comment.
This revision is now accepted and ready to land.

I don't think you need approval for that


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119299

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


[PATCH] D119026: [HIP] Emit amdgpu_code_object_version module flag

2022-02-08 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1d97cb1f6e44: [HIP] Emit amdgpu_code_object_version module 
flag (authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119026

Files:
  clang/include/clang/Basic/TargetOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenCUDA/amdgpu-asan-printf.cu
  clang/test/CodeGenCUDA/amdgpu-asan.cu
  clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
  clang/test/Driver/hip-code-object-version.hip

Index: clang/test/Driver/hip-code-object-version.hip
===
--- clang/test/Driver/hip-code-object-version.hip
+++ clang/test/Driver/hip-code-object-version.hip
@@ -34,6 +34,7 @@
 // RUN:   %s 2>&1 | FileCheck -check-prefix=V3 %s
 
 // V3-WARN: warning: argument '-mcode-object-v3' is deprecated, use '-mcode-object-version=3' instead [-Wdeprecated]
+// V3: "-mcode-object-version=3"
 // V3: "-mllvm" "--amdhsa-code-object-version=3"
 // V3: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
 
@@ -44,6 +45,7 @@
 // RUN:   --offload-arch=gfx906 -nogpulib \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=V4 %s
 
+// V4: "-mcode-object-version=4"
 // V4: "-mllvm" "--amdhsa-code-object-version=4"
 // V4: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx906"
 
@@ -54,6 +56,7 @@
 // RUN:   --offload-arch=gfx906 -nogpulib \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=V5 %s
 
+// V5: "-mcode-object-version=5"
 // V5: "-mllvm" "--amdhsa-code-object-version=5"
 // V5: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx906"
 
@@ -74,6 +77,25 @@
 // INVALID: error: invalid integral value '1' in '-mcode-object-version=1'
 // INVALID-NOT: error: invalid integral value
 
+// Check LLVM code object version option --amdhsa-code-object-version
+// is passed to -cc1 and -cc1as, and -mcode-object-version is passed
+// to -cc1 but not -cc1as.
+
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   -mcode-object-version=5 \
+// RUN:   --offload-arch=gfx906 -nogpulib -save-temps \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=CC1 %s
+
+// CC1: "-cc1" {{.*}}"-mcode-object-version=5" {{.*}}"-mllvm" "--amdhsa-code-object-version=5"
+// CC1: "-cc1as" {{.*}}"-mllvm" "--amdhsa-code-object-version=5"
+
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   -mcode-object-version=5 \
+// RUN:   --offload-arch=gfx906 -nogpulib -save-temps \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=CC1NEG %s
+
+// CC1NEG-NOT: "-cc1as" {{.*}}"-mcode-object-version=5"
+
 // Check warnings are emitted for legacy options before -mcode-object-version options.
 // Check warnings are emitted only once.
 
Index: clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
@@ -0,0 +1,26 @@
+// Create module flag for code object version.
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -o - %s | FileCheck %s -check-prefix=NONE
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -mcode-object-version=2 -o - %s | FileCheck -check-prefix=NONE %s
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -mcode-object-version=3 -o - %s | FileCheck -check-prefix=NONE %s
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -mcode-object-version=4 -o - %s | FileCheck -check-prefix=NONE %s
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -mcode-object-version=5 -o - %s | FileCheck -check-prefix=V5 %s
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -mcode-object-version=none -o - %s | FileCheck %s -check-prefix=NONE
+
+// RUN: not %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -mcode-object-version=4.1 -o - %s 2>&1| FileCheck %s -check-prefix=INV
+
+// V5: !{{.*}} = !{i32 1, !"amdgpu_code_object_version", i32 500}
+// NONE-NOT: !{{.*}} = !{i32 1, !"amdgpu_code_object_version",
+// INV: error: invalid value '4.1' in '-mcode-object-version=4.1'
Index: clang/test/CodeGenCUDA/amdgpu-asan.cu
===
--- clang/test/CodeGenCUDA/amdgpu-asan.cu
+++ clang/test/CodeGenCUDA/amdgpu-asan.cu
@@ -27,8 +27,7 @@
 // ASAN-DAG: @llvm.compiler.used = {{.*}}@__amdgpu_device_library_preserve_asan_functions_ptr
 // ASAN-DAG: define weak void @__asan_report_load1(i64 %{{.*}})
 
-// MFCHECK: !llvm.module.flags = !{![[FLAG1:[0-9]+]], ![[FLAG2:[0-9]+]]}
-// MFCHECK: ![[FLAG1]] = !{i32 4, !"amdgpu_hostcall", i32 1}
+// MFCHECK: !{{.*}} = !{i32 4, 

[clang] 1d97cb1 - [HIP] Emit amdgpu_code_object_version module flag

2022-02-08 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2022-02-08T21:58:40-05:00
New Revision: 1d97cb1f6e44a77cfc6911b916656e3c5de9bec8

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

LOG: [HIP] Emit amdgpu_code_object_version module flag

code object version determines ABI, therefore should not be mixed.

This patch emits amdgpu_code_object_version module flag in LLVM IR
based on code object version (default 4).

The amdgpu_code_object_version value is code object version times 100.

LLVM IR with different amdgpu_code_object_version module flag cannot
be linked.

The -cc1 option -mcode-object-version=none is for ROCm device library use
only, which supports multiple ABI.

Reviewed by: Artem Belevich

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

Added: 
clang/test/CodeGenCUDA/amdgpu-code-object-version.cu

Modified: 
clang/include/clang/Basic/TargetOptions.h
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGenCUDA/amdgpu-asan-printf.cu
clang/test/CodeGenCUDA/amdgpu-asan.cu
clang/test/Driver/hip-code-object-version.hip

Removed: 




diff  --git a/clang/include/clang/Basic/TargetOptions.h 
b/clang/include/clang/Basic/TargetOptions.h
index 696abf4ca4733..009f25981ca93 100644
--- a/clang/include/clang/Basic/TargetOptions.h
+++ b/clang/include/clang/Basic/TargetOptions.h
@@ -78,6 +78,18 @@ class TargetOptions {
   /// \brief If enabled, allow AMDGPU unsafe floating point atomics.
   bool AllowAMDGPUUnsafeFPAtomics = false;
 
+  /// \brief Enumeration value for AMDGPU code object version, which is the
+  /// code object version times 100.
+  enum CodeObjectVersionKind {
+COV_None,
+COV_2 = 200,
+COV_3 = 300,
+COV_4 = 400,
+COV_5 = 500,
+  };
+  /// \brief Code object version for AMDGPU.
+  CodeObjectVersionKind CodeObjectVersion;
+
   // The code model to be used as specified by the user. Corresponds to
   // CodeModel::Model enum defined in include/llvm/Support/CodeGen.h, plus
   // "default" for the case when the user has not explicitly specified a

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 313ff79e26459..1900d0f782de6 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3450,8 +3450,12 @@ defm amdgpu_ieee : BoolOption<"m", "amdgpu-ieee",
   NegFlag>, Group;
 
 def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, 
Group,
-  HelpText<"Specify code object ABI version. Defaults to 4. (AMDGPU only)">,
-  MetaVarName<"">, Values<"2,3,4,5">;
+  HelpText<"Specify code object ABI version. Allowed values are 2, 3, 4, and 
5. Defaults to 4. (AMDGPU only)">,
+  Flags<[CC1Option]>,
+  Values<"none,2,3,4,5">,
+  NormalizedValuesScope<"TargetOptions">,
+  NormalizedValues<["COV_None", "COV_2", "COV_3", "COV_4", "COV_5"]>,
+  MarshallingInfoEnum, "COV_4">;
 
 defm code_object_v3_legacy : SimpleMFlag<"code-object-v3",
   "Legacy option to specify code object ABI V3",

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index a8f0892f0e8f4..8a7345a9f494a 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -552,21 +552,32 @@ void CodeGenModule::Release() {
 EmitMainVoidAlias();
   }
 
-  // Emit reference of __amdgpu_device_library_preserve_asan_functions to
-  // preserve ASAN functions in bitcode libraries.
-  if (LangOpts.Sanitize.has(SanitizerKind::Address) && getTriple().isAMDGPU()) 
{
-auto *FT = llvm::FunctionType::get(VoidTy, {});
-auto *F = llvm::Function::Create(
-FT, llvm::GlobalValue::ExternalLinkage,
-"__amdgpu_device_library_preserve_asan_functions", ());
-auto *Var = new llvm::GlobalVariable(
-getModule(), FT->getPointerTo(),
-/*isConstant=*/true, llvm::GlobalValue::WeakAnyLinkage, F,
-"__amdgpu_device_library_preserve_asan_functions_ptr", nullptr,
-llvm::GlobalVariable::NotThreadLocal);
-addCompilerUsedGlobal(Var);
-if (!getModule().getModuleFlag("amdgpu_hostcall")) {
-  getModule().addModuleFlag(llvm::Module::Override, "amdgpu_hostcall", 1);
+  if (getTriple().isAMDGPU()) {
+// Emit reference of __amdgpu_device_library_preserve_asan_functions to
+// preserve ASAN functions in bitcode libraries.
+if (LangOpts.Sanitize.has(SanitizerKind::Address)) {
+  auto *FT = llvm::FunctionType::get(VoidTy, {});
+  auto *F = llvm::Function::Create(
+  FT, llvm::GlobalValue::ExternalLinkage,
+  "__amdgpu_device_library_preserve_asan_functions", ());
+  auto *Var = new llvm::GlobalVariable(
+  getModule(), FT->getPointerTo(),
+  /*isConstant=*/true, 

[PATCH] D119250: [RISCV][NFC] Refactor RISCVISAInfo.

2022-02-08 Thread Zakk Chen 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 rGcfe7f690367b: [RISCV][NFC] Refactor RISCVISAInfo. (authored 
by khchen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119250

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Support/TargetParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp

Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
===
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
@@ -45,11 +45,8 @@
   else
 emitAttribute(RISCVAttrs::STACK_ALIGN, RISCVAttrs::ALIGN_16);
 
-  unsigned XLen = STI.hasFeature(RISCV::Feature64Bit) ? 64 : 32;
-  std::vector FeatureVector;
-  RISCVFeatures::toFeatureVector(FeatureVector, STI.getFeatureBits());
-
-  auto ParseResult = llvm::RISCVISAInfo::parseFeatures(XLen, FeatureVector);
+  auto ParseResult = RISCVFeatures::parseFeatureBits(
+  STI.hasFeature(RISCV::Feature64Bit), STI.getFeatureBits());
   if (!ParseResult) {
 /* Assume any error about features should handled earlier.  */
 consumeError(ParseResult.takeError());
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
===
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
@@ -18,6 +18,7 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/MC/MCInstrDesc.h"
 #include "llvm/MC/SubtargetFeature.h"
+#include "llvm/Support/RISCVISAInfo.h"
 
 namespace llvm {
 
@@ -344,9 +345,8 @@
 // triple. Exits with report_fatal_error if not.
 void validate(const Triple , const FeatureBitset );
 
-// Convert FeatureBitset to FeatureVector.
-void toFeatureVector(std::vector ,
- const FeatureBitset );
+llvm::Expected>
+parseFeatureBits(bool IsRV64, const FeatureBitset );
 
 } // namespace RISCVFeatures
 
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
===
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
@@ -16,6 +16,7 @@
 #include "llvm/ADT/Triple.h"
 #include "llvm/MC/MCSubtargetInfo.h"
 #include "llvm/Support/RISCVISAInfo.h"
+#include "llvm/Support/TargetParser.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace llvm {
@@ -106,13 +107,17 @@
 report_fatal_error("RV32E can't be enabled for an RV64 target");
 }
 
-void toFeatureVector(std::vector ,
- const FeatureBitset ) {
+llvm::Expected>
+parseFeatureBits(bool IsRV64, const FeatureBitset ) {
+  unsigned XLen = IsRV64 ? 64 : 32;
+  std::vector FeatureVector;
+  // Convert FeatureBitset to FeatureVector.
   for (auto Feature : RISCVFeatureKV) {
 if (FeatureBits[Feature.Value] &&
 llvm::RISCVISAInfo::isSupportedExtensionFeature(Feature.Key))
   FeatureVector.push_back(std::string("+") + Feature.Key);
   }
+  return llvm::RISCVISAInfo::parseFeatures(XLen, FeatureVector);
 }
 
 } // namespace RISCVFeatures
Index: llvm/lib/Support/TargetParser.cpp
===
--- llvm/lib/Support/TargetParser.cpp
+++ llvm/lib/Support/TargetParser.cpp
@@ -329,21 +329,6 @@
   return true;
 }
 
-StringRef computeDefaultABIFromArch(const llvm::RISCVISAInfo ) {
-  if (ISAInfo.getXLen() == 32) {
-if (ISAInfo.hasExtension("d"))
-  return "ilp32d";
-if (ISAInfo.hasExtension("e"))
-  return "ilp32e";
-return "ilp32";
-  } else if (ISAInfo.getXLen() == 64) {
-if (ISAInfo.hasExtension("d"))
-  return "lp64d";
-return "lp64";
-  }
-  llvm_unreachable("Invalid XLEN");
-}
-
 } // namespace RISCV
 } // namespace llvm
 
Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -914,3 +914,18 @@
 return std::move(Result);
   return std::move(ISAInfo);
 }
+
+StringRef RISCVISAInfo::computeDefaultABI() const {
+  if (XLen == 32) {
+if (hasExtension("d"))
+  return "ilp32d";
+if (hasExtension("e"))
+  return "ilp32e";
+return "ilp32";
+  } else if (XLen == 64) {
+if (hasExtension("d"))
+  return "lp64d";
+return "lp64";
+  }
+  llvm_unreachable("Invalid XLEN");
+}
Index: llvm/include/llvm/Support/TargetParser.h
===
--- 

[clang] cfe7f69 - [RISCV][NFC] Refactor RISCVISAInfo.

2022-02-08 Thread Zakk Chen via cfe-commits

Author: Zakk Chen
Date: 2022-02-08T18:37:43-08:00
New Revision: cfe7f690367b9d2903f099162f0bcbbfd18c7610

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

LOG: [RISCV][NFC] Refactor RISCVISAInfo.

1. Remove computeDefaultABIFromArch and add computeDefaultABI in
RISCVISAInfo.
2. Add parseFeatureBits which may used in D118333.

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

Added: 


Modified: 
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
llvm/include/llvm/Support/RISCVISAInfo.h
llvm/include/llvm/Support/TargetParser.h
llvm/lib/Support/RISCVISAInfo.cpp
llvm/lib/Support/TargetParser.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 0680cad5b07c5..ca72cf200d466 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -272,7 +272,7 @@ bool 
RISCVTargetInfo::handleTargetFeatures(std::vector ,
   }
 
   if (ABI.empty())
-ABI = llvm::RISCV::computeDefaultABIFromArch(*ISAInfo).str();
+ABI = ISAInfo->computeDefaultABI().str();
 
   return true;
 }

diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 7ad8ca69bed5d..8a8ed20986c57 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -198,7 +198,7 @@ StringRef riscv::getRISCVABI(const ArgList , const 
llvm::Triple ) {
 // Ignore parsing error, just go 3rd step.
 consumeError(ParseResult.takeError());
   else
-return llvm::RISCV::computeDefaultABIFromArch(**ParseResult);
+return (*ParseResult)->computeDefaultABI();
 
   // 3. Choose a default based on the triple
   //

diff  --git a/llvm/include/llvm/Support/RISCVISAInfo.h 
b/llvm/include/llvm/Support/RISCVISAInfo.h
index 7fa0e6ee3acfe..6e34779545c16 100644
--- a/llvm/include/llvm/Support/RISCVISAInfo.h
+++ b/llvm/include/llvm/Support/RISCVISAInfo.h
@@ -66,6 +66,7 @@ class RISCVISAInfo {
   bool hasExtension(StringRef Ext) const;
   std::string toString() const;
   std::vector toFeatureVector() const;
+  StringRef computeDefaultABI() const;
 
   static bool isSupportedExtensionFeature(StringRef Ext);
   static bool isSupportedExtension(StringRef Ext);

diff  --git a/llvm/include/llvm/Support/TargetParser.h 
b/llvm/include/llvm/Support/TargetParser.h
index 02a8d72483db6..d4880d638cf72 100644
--- a/llvm/include/llvm/Support/TargetParser.h
+++ b/llvm/include/llvm/Support/TargetParser.h
@@ -170,7 +170,6 @@ void fillValidCPUArchList(SmallVectorImpl 
, bool IsRV64);
 void fillValidTuneCPUArchList(SmallVectorImpl , bool IsRV64);
 bool getCPUFeaturesExceptStdExt(CPUKind Kind, std::vector 
);
 StringRef resolveTuneCPUAlias(StringRef TuneCPU, bool IsRV64);
-StringRef computeDefaultABIFromArch(const llvm::RISCVISAInfo );
 
 } // namespace RISCV
 

diff  --git a/llvm/lib/Support/RISCVISAInfo.cpp 
b/llvm/lib/Support/RISCVISAInfo.cpp
index a6d4e0b2feba6..598eceaa6c274 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -914,3 +914,18 @@ 
RISCVISAInfo::postProcessAndChecking(std::unique_ptr &) {
 return std::move(Result);
   return std::move(ISAInfo);
 }
+
+StringRef RISCVISAInfo::computeDefaultABI() const {
+  if (XLen == 32) {
+if (hasExtension("d"))
+  return "ilp32d";
+if (hasExtension("e"))
+  return "ilp32e";
+return "ilp32";
+  } else if (XLen == 64) {
+if (hasExtension("d"))
+  return "lp64d";
+return "lp64";
+  }
+  llvm_unreachable("Invalid XLEN");
+}

diff  --git a/llvm/lib/Support/TargetParser.cpp 
b/llvm/lib/Support/TargetParser.cpp
index 0105cd2e81532..b3eb43e2038bf 100644
--- a/llvm/lib/Support/TargetParser.cpp
+++ b/llvm/lib/Support/TargetParser.cpp
@@ -329,21 +329,6 @@ bool getCPUFeaturesExceptStdExt(CPUKind Kind,
   return true;
 }
 
-StringRef computeDefaultABIFromArch(const llvm::RISCVISAInfo ) {
-  if (ISAInfo.getXLen() == 32) {
-if (ISAInfo.hasExtension("d"))
-  return "ilp32d";
-if (ISAInfo.hasExtension("e"))
-  return "ilp32e";
-return "ilp32";
-  } else if (ISAInfo.getXLen() == 64) {
-if (ISAInfo.hasExtension("d"))
-  return "lp64d";
-return "lp64";
-  }
-  llvm_unreachable("Invalid XLEN");
-}
-
 } // namespace RISCV
 } // namespace llvm
 

diff  --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp 
b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
index 144e761f002dc..bd99596e54c13 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
@@ 

[clang] 8440ec6 - [docs] Document -ffinite-math-only, -fhonor-{infinities,infinites,nans}

2022-02-08 Thread Jon Roelofs via cfe-commits

Author: Jon Roelofs
Date: 2022-02-08T18:10:17-08:00
New Revision: 8440ec66f4f0f2e4f49061262648809345952bf7

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

LOG: [docs] Document -ffinite-math-only, -fhonor-{infinities,infinites,nans}

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 12ea688edc1a8..e4b5c1a780446 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -1725,6 +1725,8 @@ Assume all loops are finite.
 
 .. option:: -ffinite-math-only, -fno-finite-math-only
 
+Allow floating-point optimizations that assume arguments and results are not 
NaNs or +-inf. This defines the \_\_FINITE\_MATH\_ONLY\_\_ preprocessor macro.
+
 .. option:: -ffixed-point, -fno-fixed-point
 
 Enable fixed point types
@@ -1805,10 +1807,14 @@ Specify that single precision floating-point divide and 
sqrt used in the program
 
 Use new kernel launching API for HIP
 
-.. option:: -fhonor-infinities, -fhonor-infinites, -fno-honor-infinities
+.. option:: -fhonor-infinities, -fhonor-infinites, -fno-honor-infinities, 
-fno-honor-infinites
+
+Specify that floating-point optimizations are not allowed that assume 
arguments and results are not +-inf.
 
 .. option:: -fhonor-nans, -fno-honor-nans
 
+Specify that floating-point optimizations are not allowed that assume 
arguments and results are not NANs.
+
 .. option:: -fhosted
 
 .. option:: -fignore-exceptions



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


[PATCH] D116861: [UBSan] Fix incorrect alignment reported when global new returns an offset pointer

2022-02-08 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGExprCXX.cpp:1658-1659
   Target.getNewAlign(), getContext().getTypeSize(allocType)));
   allocationAlign = std::max(
   allocationAlign, getContext().toCharUnitsFromBits(AllocatorAlign));
 }

rnk wrote:
> I believe John's proposal is to remove this `max` here.
Or to at least use something more conservative, like the alignment of a 
pointer.  Or even potentially to fix `getNewAlign()` so that we're only 
aggressive about it on targets (like Darwin) that have more explicitly 
authorized us to be so.  But in any case, we should make the change up here 
instead of only in the UBSan check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116861

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


[PATCH] D115610: [C++20] [Modules] Don't create multiple global module fragment

2022-02-08 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D115610#3304289 , @urnathan wrote:

> the landed version is good, with Richard's suggested member name change.  
> Can't see a way of post-commit accepting?

Yeah, maybe we can't do post-commit accept formally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115610

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


[PATCH] D119216: [AMDGPU] replace hostcall module flag with function attribute

2022-02-08 Thread Sameer Sahasrabuddhe via Phabricator via cfe-commits
sameerds added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp:566
+  return false;
+};
+

jdoerfert wrote:
> sameerds wrote:
> > jdoerfert wrote:
> > > jdoerfert wrote:
> > > > sameerds wrote:
> > > > > jdoerfert wrote:
> > > > > > You can use AAPointerInfo for the call site return IRPosition. It 
> > > > > > will (through the iterations) gather all accesses and put them into 
> > > > > > "bins" based on offset and size. It deals with uses in calls, etc. 
> > > > > > and if there is stuff missing it is better to add it in one place 
> > > > > > so we benefit throughout. 
> > > > > I am not following what you have in mind. "implicitarg_ptr" is a 
> > > > > pointer returned by an intrinsic that reads an ABI-defined register. 
> > > > > I need to check that for a given call-graph, a particular range of 
> > > > > bytes relative to that base pointer are never accessed. The above DFS 
> > > > > on the uses conservatively assumes that such a load exists unless it 
> > > > > can conclusively trace every use of the base pointer. This may 
> > > > > include the pointer being passed to an extern function or being 
> > > > > stored into a different memory location (although we don't expect ABI 
> > > > > registers being capture this way). I am not seeing how to construct 
> > > > > this around AAPointerInfo. As far as I can see, the public interface 
> > > > > only talks about uses that are recognized as loads and stores.
> > > > Not actually tested, replaces the function body. Depends on D119249.
> > > > ```
> > > > const auto PointerInfoAA = A.getAAFor(*this, 
> > > > IRPosition::callback_returned(cast(Ptr)), 
> > > > DepClassTy::Required);
> > > > if (!PointerInfoAA.getState().isValidState())
> > > >   return true; // Abort (which is weird as false is abort in the other 
> > > > CB).
> > > > AAPointerInfo::OffsetAndSize OAS(*Position, /* probably look pointer 
> > > > width up in DL */ 8);
> > > > return !forallInterferingAccesses(OAS, [](const AAPointerInfo::Access 
> > > > , bool IsExact) {
> > > >return Acc.getRemoteInst()->isDroppable(); });
> > > > ```
> > > You don't actually need the state check.
> > > And as I said, this will take care of following pointers passed into 
> > > callees or through memory to other places, all while ignoring dead code, 
> > > etc.
> > I see now. forallInterferingAccesses() does check for valid state on entry, 
> > which is sufficient to take care of all the opaque uses like a call to an 
> > extern function or a complicated phi or a capturing store. Thanks a ton ... 
> > this has been very educational!
> Yes, all "forAll" functions will return `false` if we cannot visit "all". 
> Though, these methods will utilize the smarts, e.g., ignore what is dead, 
> look at loads if the value is stored in a way we can track it through memory, 
> transfer accesses in a callee to the caller "space" if a pointer is passed to 
> the callee,... etc.
> Yes, all "forAll" functions will return `false` if we cannot visit "all". 
> Though, these methods will utilize the smarts, e.g., ignore what is dead, 
> look at loads if the value is stored in a way we can track it through memory, 
> transfer accesses in a callee to the caller "space" if a pointer is passed to 
> the callee,... etc.

@jdoerfert, do you see  D119249 landing soon? We are kinda on a short runway 
here (less than a handful of days) and hoping to land this review quickly 
because it solves an important issue. I would prefer to have the check that you 
outlined, but the alternative is to let my version through now, and then update 
it when the new interface becomes available.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119216

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


[PATCH] D119207: [CUDA][SPIRV] Assign global address space to CUDA kernel arguments

2022-02-08 Thread Shangwu Yao via Phabricator via cfe-commits
shangwuyao added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:10322
 ABIArgInfo SPIRVABIInfo::classifyKernelArgumentType(QualType Ty) const {
-  if (getContext().getLangOpts().HIP) {
+  if (getContext().getLangOpts().CUDAIsDevice) {
 // Coerce pointer arguments with default address space to CrossWorkGroup

jlebar wrote:
> I am surprised by this change.  Is the language mode HIP only when compiling 
> for device?  Or are you intentionally changing the behavior in HIP mode?
> 
> Same in SPIR.h
We are targeting SPIRV so //I think// "compiling for device" is implied, I will 
let others comment on this to see if the assumption is correct. So this 
function can only be called when compiling for device, and won't be called when 
compiling for host. 

Also tried compiling for device and host separately to see where exactly does 
the code diverge (to make sure those two functions are not called when 
compiling for host):
1. This `classifyKernelArgumentType()` function is called from [[ 
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGCall.cpp#L774-L777
 | here ]], which is only enabled when the calling convention is `SPIR_KERNEL`. 
And when compiling for host, the calling convention is `C`.

2. For the SPIR.h file, the `TargetInfo::adjust` function is called both when 
compiling for host and for device, see [[ 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Basic/Targets/SPIR.h#L142-L157
 | here ]], while the `setAddressSpaceMap` function is only called when 
compiling for device (SPIRV).

In conclusion, those two functions won't be reached when compiling for host.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119207

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


[PATCH] D110869: [X86] Implement -fzero-call-used-regs option

2022-02-08 Thread Bill Wendling 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 rGdeaf22bc0e30: [X86] Implement -fzero-call-used-regs option 
(authored by void).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110869

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/zero-call-used-regs.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/zero_call_used_regs.c
  llvm/include/llvm/CodeGen/MachineRegisterInfo.h
  llvm/include/llvm/CodeGen/TargetFrameLowering.h
  llvm/include/llvm/CodeGen/TargetRegisterInfo.h
  llvm/include/llvm/Support/CodeGen.h
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/MachineRegisterInfo.cpp
  llvm/lib/CodeGen/PrologEpilogInserter.cpp
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86FrameLowering.h
  llvm/lib/Target/X86/X86RegisterInfo.cpp
  llvm/lib/Target/X86/X86RegisterInfo.h
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/test/CodeGen/X86/zero-call-used-regs-fmod.ll
  llvm/test/CodeGen/X86/zero-call-used-regs.ll
  llvm/utils/TableGen/CodeGenRegisters.cpp
  llvm/utils/TableGen/CodeGenRegisters.h
  llvm/utils/TableGen/RegisterInfoEmitter.cpp

Index: llvm/utils/TableGen/RegisterInfoEmitter.cpp
===
--- llvm/utils/TableGen/RegisterInfoEmitter.cpp
+++ llvm/utils/TableGen/RegisterInfoEmitter.cpp
@@ -1176,6 +1176,10 @@
  << "unsigned RegUnit) const override;\n"
  << "  ArrayRef getRegMaskNames() const override;\n"
  << "  ArrayRef getRegMasks() const override;\n"
+ << "  bool isGeneralPurposeRegister(const MachineFunction &, "
+ << "MCRegister) const override;\n"
+ << "  bool isFixedRegister(const MachineFunction &, "
+ << "MCRegister) const override;\n"
  << "  /// Devirtualized TargetFrameLowering.\n"
  << "  static const " << TargetName << "FrameLowering *getFrameLowering(\n"
  << "  const MachineFunction );\n"
@@ -1620,6 +1624,36 @@
   }
   OS << "}\n\n";
 
+  const std::list  =
+  RegBank.getRegCategories();
+  OS << "bool " << ClassName << "::\n"
+ << "isGeneralPurposeRegister(const MachineFunction , "
+ << "MCRegister PhysReg) const {\n"
+ << "  return\n";
+  for (const CodeGenRegisterCategory  : RegCategories)
+if (Category.getName() == "GeneralPurposeRegisters") {
+  for (const CodeGenRegisterClass *RC : Category.getClasses())
+OS << "  " << RC->getQualifiedName()
+   << "RegClass.contains(PhysReg) ||\n";
+  break;
+}
+  OS << "  false;\n";
+  OS << "}\n\n";
+
+  OS << "bool " << ClassName << "::\n"
+ << "isFixedRegister(const MachineFunction , "
+ << "MCRegister PhysReg) const {\n"
+ << "  return\n";
+  for (const CodeGenRegisterCategory  : RegCategories)
+if (Category.getName() == "FixedRegisters") {
+  for (const CodeGenRegisterClass *RC : Category.getClasses())
+OS << "  " << RC->getQualifiedName()
+   << "RegClass.contains(PhysReg) ||\n";
+  break;
+}
+  OS << "  false;\n";
+  OS << "}\n\n";
+
   OS << "ArrayRef " << ClassName
  << "::getRegMaskNames() const {\n";
   if (!CSRSets.empty()) {
Index: llvm/utils/TableGen/CodeGenRegisters.h
===
--- llvm/utils/TableGen/CodeGenRegisters.h
+++ llvm/utils/TableGen/CodeGenRegisters.h
@@ -476,6 +476,26 @@
 static void computeSubClasses(CodeGenRegBank&);
   };
 
+  // Register categories are used when we need to deterine the category a
+  // register falls into (GPR, vector, fixed, etc.) without having to know
+  // specific information about the target architecture.
+  class CodeGenRegisterCategory {
+Record *TheDef;
+std::string Name;
+std::list Classes;
+
+  public:
+CodeGenRegisterCategory(CodeGenRegBank &, Record *R);
+CodeGenRegisterCategory(CodeGenRegisterCategory &) = delete;
+
+// Return the Record that defined this class, or NULL if the class was
+// created by TableGen.
+Record *getDef() const { return TheDef; }
+
+std::string getName() const { return Name; }
+std::list getClasses() const { return Classes; }
+  };
+
   // Register units are used to model interference and register pressure.
   // Every register is assigned one or more register units such that two
   // registers overlap if and only if they have a register unit in common.
@@ -559,6 +579,13 @@
 typedef std::map RCKeyMap;
 RCKeyMap Key2RC;
 
+// Register categories.
+std::list RegCategories;
+DenseMap Def2RCat;
+using 

[clang] deaf22b - [X86] Implement -fzero-call-used-regs option

2022-02-08 Thread Bill Wendling via cfe-commits

Author: Bill Wendling
Date: 2022-02-08T17:42:54-08:00
New Revision: deaf22bc0e306bc44c70d2503e9364b5ed312c49

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

LOG: [X86] Implement -fzero-call-used-regs option

The "-fzero-call-used-regs" option tells the compiler to zero out
certain registers before the function returns. It's also available as a
function attribute: zero_call_used_regs.

The two upper categories are:

  - "used": Zero out used registers.
  - "all": Zero out all registers, whether used or not.

The individual options are:

  - "skip": Don't zero out any registers. This is the default.
  - "used": Zero out all used registers.
  - "used-arg": Zero out used registers that are used for arguments.
  - "used-gpr": Zero out used registers that are GPRs.
  - "used-gpr-arg": Zero out used GPRs that are used as arguments.
  - "all": Zero out all registers.
  - "all-arg": Zero out all registers used for arguments.
  - "all-gpr": Zero out all GPRs.
  - "all-gpr-arg": Zero out all GPRs used for arguments.

This is used to help mitigate Return-Oriented Programming exploits.

Reviewed By: nickdesaulniers

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

Added: 
clang/test/CodeGen/zero-call-used-regs.c
clang/test/Sema/zero_call_used_regs.c
llvm/test/CodeGen/X86/zero-call-used-regs-fmod.ll
llvm/test/CodeGen/X86/zero-call-used-regs.ll

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test
llvm/include/llvm/CodeGen/MachineRegisterInfo.h
llvm/include/llvm/CodeGen/TargetFrameLowering.h
llvm/include/llvm/CodeGen/TargetRegisterInfo.h
llvm/include/llvm/Support/CodeGen.h
llvm/include/llvm/Target/Target.td
llvm/lib/CodeGen/MachineRegisterInfo.cpp
llvm/lib/CodeGen/PrologEpilogInserter.cpp
llvm/lib/Target/X86/X86FrameLowering.cpp
llvm/lib/Target/X86/X86FrameLowering.h
llvm/lib/Target/X86/X86RegisterInfo.cpp
llvm/lib/Target/X86/X86RegisterInfo.h
llvm/lib/Target/X86/X86RegisterInfo.td
llvm/utils/TableGen/CodeGenRegisters.cpp
llvm/utils/TableGen/CodeGenRegisters.h
llvm/utils/TableGen/RegisterInfoEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index dfc609e8ca28c..5156b6b5615b1 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2564,6 +2564,19 @@ def VectorCall : DeclOrTypeAttr {
   let Documentation = [VectorCallDocs];
 }
 
+def ZeroCallUsedRegs : InheritableAttr {
+  let Spellings = [GCC<"zero_call_used_regs">];
+  let Subjects = SubjectList<[Function], ErrorDiag>;
+  let Args = [
+EnumArgument<"ZeroCallUsedRegs", "ZeroCallUsedRegsKind",
+ ["skip", "used-gpr-arg", "used-gpr", "used-arg", "used",
+  "all-gpr-arg", "all-gpr", "all-arg", "all"],
+ ["Skip", "UsedGPRArg", "UsedGPR", "UsedArg", "Used",
+  "AllGPRArg", "AllGPR", "AllArg", "All"]>
+  ];
+  let Documentation = [ZeroCallUsedRegsDocs];
+}
+
 def Pascal : DeclOrTypeAttr {
   let Spellings = [Clang<"pascal">, Keyword<"__pascal">, Keyword<"_pascal">];
 //  let Subjects = [Function, ObjCMethod];

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 74ee5f84dfa85..9ce3d59bc5d97 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -6270,3 +6270,41 @@ pointing to precise locations of the call site in the 
source.
   }
   }];
 }
+
+def ZeroCallUsedRegsDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+This attribute, when attached to a function, causes the compiler to zero a
+subset of all call-used registers before the function returns. It's used to
+increase program security by either mitigating `Return-Oriented Programming`_
+(ROP) attacks or preventing information leakage through registers.
+
+The term "`call-used" means registers which are not guaranteed to be preserved
+unchanged for the caller by the current calling convention. This could also be
+described as "caller-saved" or "not callee-saved".
+
+The `choice` parameters gives the programmer flexibility to choose the subset
+of the call-used registers to be zeroed:
+
+- ``skip`` doesn't zero any call-used registers. This choice overrides any
+  command-line arguments.
+- ``used`` only zeros call-used registers used in the function. By ``used``, we
+  mean a register whose contents 

[clang] dc8f4e1 - [cxx_status] Add a couple of Feb 2022 library papers that need compiler support.

2022-02-08 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2022-02-08T17:25:52-08:00
New Revision: dc8f4e118d92982ff5f6316fe7d541d120ebabd1

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

LOG: [cxx_status] Add a couple of Feb 2022 library papers that need compiler 
support.

Added: 


Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 7a6cdba840e23..c1f65401df17c 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -946,7 +946,7 @@ C++20 implementation status

 https://wg21.link/p2103r0;>P2103R0
   
-   
+   
 https://wg21.link/p2493r0;>P2493R0
   
   
@@ -1205,7 +1205,7 @@ C++20 implementation status
   
 Partial
   The optimizer does not yet handle TLS with
-  `__attribute__((const))` attribute correctly. There can be issues where the
+  __attribute__((const)) attribute correctly. There can be issues 
where the
   coroutine may resume on a 
diff erent thread. This feature requires further
   analysis of the C++ Standard to determine what work is necessary for 
conformance.
 
@@ -1388,11 +1388,31 @@ C++2b implementation status
   https://wg21.link/P2360R0;>P2360R0
   Clang 14
 
+
 
   Attributes on Lambda-Expressions
   https://wg21.link/P2173R1;>P2173R1
   Clang 13
 
+
+  constexpr for  and cstdlib
+  https://wg21.link/P0533R9;>P0533R9
+  No
+
+
+  Type trait to determine if a reference binds to a temporary
+  https://wg21.link/P2255R2;>P2255R2
+  
+Partial
+  Clang provides a __reference_binds_to_temporary type trait
+  builtin, with which the library facility can be partially 
implemented.
+  Both __reference_constructs_from_temporary and
+  __reference_converts_from_temporary builtins should be
+  provided, following the normal cross-vendor convention to implement
+  traits requiring compiler support directly.
+
+  
+
 
 
 



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


[PATCH] D119178: Add support for generating debug-info for structured bindings of structs and arrays

2022-02-08 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4667
+
+  SmallVector Expr;
+  AppendAddressSpaceXDeref(AddressSpace, Expr);

aprantl wrote:
> 13 seems to be unnecessarily high. Shouldn't 1 be enough for the expected 
> single DW_OP_deref?
Good catch, I used the `VarDecl` version of `EmitDeclare` as an example and I 
copied it from there.

I will also be pushing the `DW_OP_plus_uconst` and the value later on as well. 
So maybe 3 is a the right value.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4713
+   .toCharUnitsFromBits(value * typeSize)
+   .getQuantity());
+  }

aprantl wrote:
> Can C++ arrays ever have a non-zero stride? (perhaps due to element 
> alignment?)
Elements must be contiguous and start at `0` see 
[dcl.array/p6](http://eel.is/c++draft/dcl.array#6):

>An object of type “array of N U” consists of a contiguously allocated 
>non-empty set of N subobjects of type U, known as the elements of the array, 
>and numbered 0 to N-1.

The size of the type should include any padding. 



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4716
+}
+  }
+

aprantl wrote:
> Should there be an else { assert("unhandled binding expressions"); } here or 
> are there other expressions that just don't need special handling?
We should only have three cases:

- struct
- array
- tuple-like 

We exit early for the tuple-like case at the top b/c we handle that elsewhere. 

So maybe asserting we never end up with a not handled case may make sense.


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

https://reviews.llvm.org/D119178

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


[PATCH] D119178: Add support for generating debug-info for structured bindings of structs and arrays

2022-02-08 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4647
+const bool UsePointerValue) {
+  assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
+  assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");

do you need a 
```
 if (DebugKind > codegenoptions::LimitedDebugInfo)
  return
```

here?


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

https://reviews.llvm.org/D119178

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


[PATCH] D119301: [AArch64][ARM] add -Wunaligned-access only for clang

2022-02-08 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: mubashar_, lenary, pbarrio.
Herald added a subscriber: kristof.beyls.
ychen 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/D119301

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.h
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Clang.cpp

Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -347,8 +347,7 @@
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_32:
   case llvm::Triple::aarch64_be:
-aarch64::getAArch64TargetFeatures(D, Triple, Args, CmdArgs, Features,
-  ForAS);
+aarch64::getAArch64TargetFeatures(D, Triple, Args, Features, ForAS);
 break;
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
@@ -1893,6 +1892,14 @@
   CmdArgs.push_back(Args.MakeArgString(TuneCPU));
 }
   }
+
+  auto StrictAlignIter =
+  std::find_if(CmdArgs.rbegin(), CmdArgs.rend(), [](StringRef Arg) {
+return Arg == "+strict-align" || Arg == "-strict-align";
+  });
+  if (StrictAlignIter != CmdArgs.rend() &&
+  StringRef(*StrictAlignIter) == "+strict-align")
+CmdArgs.push_back("-Wunaligned-access");
 }
 
 void Clang::AddMIPSTargetArgs(const ArgList ,
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -772,8 +772,6 @@
   // Kernel code has more strict alignment requirements.
   if (KernelOrKext) {
 Features.push_back("+strict-align");
-if (!ForAS)
-  CmdArgs.push_back("-Wunaligned-access");
   } else if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
   options::OPT_munaligned_access)) {
 if (A->getOption().matches(options::OPT_munaligned_access)) {
@@ -784,11 +782,8 @@
   // access either.
   else if (Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v8m_baseline)
 D.Diag(diag::err_target_unsupported_unaligned) << "v8m.base";
-} else {
+} else
   Features.push_back("+strict-align");
-  if (!ForAS)
-CmdArgs.push_back("-Wunaligned-access");
-}
   } else {
 // Assume pre-ARMv6 doesn't support unaligned accesses.
 //
@@ -807,23 +802,14 @@
 int VersionNum = getARMSubArchVersionNumber(Triple);
 if (Triple.isOSDarwin() || Triple.isOSNetBSD()) {
   if (VersionNum < 6 ||
-  Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m) {
+  Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
-if (!ForAS)
-  CmdArgs.push_back("-Wunaligned-access");
-  }
 } else if (Triple.isOSLinux() || Triple.isOSNaCl() ||
Triple.isOSWindows()) {
-  if (VersionNum < 7) {
+  if (VersionNum < 7)
 Features.push_back("+strict-align");
-if (!ForAS)
-  CmdArgs.push_back("-Wunaligned-access");
-  }
-} else {
+} else
   Features.push_back("+strict-align");
-  if (!ForAS)
-CmdArgs.push_back("-Wunaligned-access");
-}
   }
 
   // llvm does not support reserving registers in general. There is support
Index: clang/lib/Driver/ToolChains/Arch/AArch64.h
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.h
+++ clang/lib/Driver/ToolChains/Arch/AArch64.h
@@ -22,7 +22,6 @@
 
 void getAArch64TargetFeatures(const Driver , const llvm::Triple ,
   const llvm::opt::ArgList ,
-  llvm::opt::ArgStringList ,
   std::vector ,
   bool ForAS);
 
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -222,7 +222,6 @@
 void aarch64::getAArch64TargetFeatures(const Driver ,
const llvm::Triple ,
const ArgList ,
-   llvm::opt::ArgStringList ,
std::vector ,
bool ForAS) {
   Arg *A;
@@ -466,16 +465,10 @@
 
   if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
options::OPT_munaligned_access)) {
-if (A->getOption().matches(options::OPT_mno_unaligned_access)) {
+if (A->getOption().matches(options::OPT_mno_unaligned_access))
   

[PATCH] D116861: [UBSan] Fix incorrect alignment reported when global new returns an offset pointer

2022-02-08 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/CodeGen/CGExprCXX.cpp:1658-1659
   Target.getNewAlign(), getContext().getTypeSize(allocType)));
   allocationAlign = std::max(
   allocationAlign, getContext().toCharUnitsFromBits(AllocatorAlign));
 }

I believe John's proposal is to remove this `max` here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116861

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


[PATCH] D118199: [AArch64] ACLE feature macro for Armv8.8-A MOPS

2022-02-08 Thread Son Tuan Vu via Phabricator via cfe-commits
tyb0807 reopened this revision.
tyb0807 added a comment.
This revision is now accepted and ready to land.

Reverted due to buildbots failures


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118199

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


[clang] 9b81d2f - Revert "[AArch64] ACLE feature macro for Armv8.8-A MOPS"

2022-02-08 Thread via cfe-commits

Author: tyb0807
Date: 2022-02-09T00:10:09Z
New Revision: 9b81d2fae8c05ea611578137101e46a7b61fbaed

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

LOG: Revert "[AArch64] ACLE feature macro for Armv8.8-A MOPS"

This reverts commit d379ec99085e33ace51740f2b93bda5e5c72326f.

Added: 


Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/test/CodeGen/aarch64-mops.c
clang/test/Preprocessor/aarch64-target-features.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index b04508570ad75..34bdb58dffc1c 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -226,8 +226,6 @@ void AArch64TargetInfo::getTargetDefinesARMV87A(const 
LangOptions ,
 
 void AArch64TargetInfo::getTargetDefinesARMV88A(const LangOptions ,
 MacroBuilder ) const {
-  // FIXME: this does not handle the case where MOPS is disabled using +nomops
-  Builder.defineMacro("__ARM_FEATURE_MOPS", "1");
   // Also include the Armv8.7 defines
   getTargetDefinesARMV87A(Opts, Builder);
 }
@@ -437,9 +435,6 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
,
   if (HasRandGen)
 Builder.defineMacro("__ARM_FEATURE_RNG", "1");
 
-  if (HasMOPS)
-Builder.defineMacro("__ARM_FEATURE_MOPS", "1");
-
   switch (ArchKind) {
   default:
 break;
@@ -667,8 +662,6 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector ,
   HasFlagM = true;
 if (Feature == "+hbc")
   HasHBC = true;
-if (Feature == "+mops")
-  HasMOPS = true;
   }
 
   setDataLayout();

diff  --git a/clang/test/CodeGen/aarch64-mops.c 
b/clang/test/CodeGen/aarch64-mops.c
index 9a19d4202bcc2..0b6a2c26c1e82 100644
--- a/clang/test/CodeGen/aarch64-mops.c
+++ b/clang/test/CodeGen/aarch64-mops.c
@@ -1,18 +1,8 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 
 // RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops 
-target-feature +mte -S -emit-llvm -o - %s  | FileCheck %s
-// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -verify %s
-// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a+mops+memtag  
-S -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+memtag   
-S -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a+mops+memtag  
-S -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a+memtag   
-S -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a  -Xclang 
-verify -S -emit-llvm %s -o -
-// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a+mops -Xclang 
-verify -S -emit-llvm %s -o -
-// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a  -Xclang 
-verify -S -emit-llvm %s -o -
-// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a  -Xclang 
-verify -S -emit-llvm %s -o -
-// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a+mops -Xclang 
-verify -S -emit-llvm %s -o -
-// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a  -Xclang 
-verify -S -emit-llvm %s -o -
 
+#define __ARM_FEATURE_MOPS 1
 #include 
 #include 
 
@@ -23,9 +13,9 @@
 // CHECK-NEXT:[[TMP0:%.*]] = load i8*, i8** [[DST_ADDR]], align 8
 // CHECK-NEXT:[[TMP1:%.*]] = call i8* @llvm.aarch64.mops.memset.tag(i8* 
[[TMP0]], i8 0, i64 0)
 // CHECK-NEXT:ret i8* [[TMP1]]
+//
 void *bzero_0(void *dst) {
-  // expected-warning@+1 {{incompatible integer to pointer conversion 
returning 'int' from a function with result type 'void *'}}
-  return __arm_mops_memset_tag(dst, 0, 0); // expected-warning{{implicit 
declaration of function '__arm_mops_memset_tag' is invalid in C99}}
+  return __arm_mops_memset_tag(dst, 0, 0);
 }
 
 // CHECK-LABEL: @bzero_1(
@@ -35,9 +25,9 @@ void *bzero_0(void *dst) {
 // CHECK-NEXT:[[TMP0:%.*]] = load i8*, i8** [[DST_ADDR]], align 8
 // CHECK-NEXT:[[TMP1:%.*]] = call i8* @llvm.aarch64.mops.memset.tag(i8* 
[[TMP0]], i8 0, i64 1)
 // CHECK-NEXT:ret i8* [[TMP1]]
+//
 void *bzero_1(void *dst) {
-  // expected-warning@+1 {{incompatible integer to pointer conversion 
returning 'int' from a function with result type 'void *'}}
-  return __arm_mops_memset_tag(dst, 0, 1); // expected-warning{{implicit 
declaration of function '__arm_mops_memset_tag' is invalid in C99}}
+  return __arm_mops_memset_tag(dst, 0, 1);
 }
 
 // CHECK-LABEL: @bzero_10(
@@ -47,9 +37,9 @@ void *bzero_1(void *dst) {
 // CHECK-NEXT:[[TMP0:%.*]] = load i8*, i8** [[DST_ADDR]], align 8
 // CHECK-NEXT:[[TMP1:%.*]] = call i8* @llvm.aarch64.mops.memset.tag(i8* 
[[TMP0]], i8 0, i64 10)
 // 

[PATCH] D119296: KCFI sanitizer

2022-02-08 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:3168
+  -1);
+  llvm::Value *Test = Builder.CreateICmpEQ(Builder.CreateLoad(HashPtr), Hash);
+  llvm::BasicBlock *ContBB = createBasicBlock("kcfi.cont");

We considered a scheme like this before and one problem that we discovered with 
comparing the hash in this way is that it can produce gadgets, e.g.
```
movabs $0x0123456789abcdef, %rax
cmp %rax, ...
```
the `cmp`instruction ends up being a valid target address because the `movabs` 
instruction ends in the hash. The way we thought about solving this was to 
introduce a new intrinsic that would materialize the constant without these 
gadgets (e.g. invert the `movabs` operand and follow it by a `not`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119296

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


[PATCH] D119296: KCFI sanitizer

2022-02-08 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:5419
+  typedef typeof(f1) * __attribute__((kcfi_unchecked) unchecked_t;
+  ((unchecked_t)p2)();  // unchecked
+

`p2` is already unchecked. Would it be more demonstrative to cast `p1` (which 
is checked) to `unchecked_t` and show that that indirect call remains unchecked?



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1590-1597
+  llvm::MDString *MDS = dyn_cast(CreateMetadataIdentifierImpl(
+  T, MetadataIdMap, "", /*OnlyExternal=*/false));
+  if (!MDS)
+return nullptr;
+
+  return llvm::ConstantInt::get(
+  Int64Ty,

```
if (auto *MDS =
  return llvm::ConstantInt ...
return nullptr;
```



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4706
+  else if (auto *VD = dyn_cast(D))
+if (auto *TSI = VD->getTypeSourceInfo())
+  Type = TSI->getType();

remove auto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119296

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


[PATCH] D119300: Use-after-dtor detection for trivial base classes.

2022-02-08 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis created this revision.
eugenis added reviewers: kda, vitalybuka.
eugenis requested review of this revision.
Herald added projects: clang, Sanitizers.
Herald added a subscriber: Sanitizers.

-fsanitize-memory-use-after-dtor detects memory access after a
subobject is destroyed but its memory is not yet deallocated.
This is done by poisoning each object memory near the end of its destructor.

Subobjects (members and base classes) do this in their respective
destructors, and the parent class does the same for its members with
trivial destructors.

Inexplicably, base classes with trivial destructors are not handled at
all. This change fixes this oversight by adding the base class poisoning logic
to the parent class destructor.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119300

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
  compiler-rt/test/msan/dtor-base-access.cpp

Index: compiler-rt/test/msan/dtor-base-access.cpp
===
--- compiler-rt/test/msan/dtor-base-access.cpp
+++ compiler-rt/test/msan/dtor-base-access.cpp
@@ -9,41 +9,62 @@
 
 class Base {
  public:
-  int *x_ptr;
-  Base(int *y_ptr) {
-// store value of subclass member
-x_ptr = y_ptr;
-  }
-  virtual ~Base();
+   int b;
+   Base() { b = 1; }
+   ~Base();
 };
 
-class Derived : public Base {
- public:
-  int y;
-  Derived():Base() {
-y = 10;
-  }
+class TrivialBaseBefore {
+public:
+  int tb0;
+  TrivialBaseBefore() { tb0 = 1; }
+};
+
+class TrivialBaseAfter {
+public:
+  int tb1;
+  TrivialBaseAfter() { tb1 = 1; }
+};
+
+class Derived : public TrivialBaseBefore, public Base, public TrivialBaseAfter {
+public:
+  int d;
+  Derived() { d = 1; }
   ~Derived();
 };
 
+Derived *g;
+
 Base::~Base() {
-  // ok access its own member
-  assert(__msan_test_shadow(>x_ptr, sizeof(this->x_ptr)) == -1);
-  // bad access subclass member
-  assert(__msan_test_shadow(this->x_ptr, sizeof(*this->x_ptr)) != -1);
+  // ok to access its own members and earlier bases
+  assert(__msan_test_shadow(>tb0, sizeof(g->tb0)) == -1);
+  assert(__msan_test_shadow(>b, sizeof(g->b)) == -1);
+  // not ok to access others
+  assert(__msan_test_shadow(>tb1, sizeof(g->tb1)) == 0);
+  assert(__msan_test_shadow(>d, sizeof(g->d)) == 0);
 }
 
 Derived::~Derived() {
-  // ok to access its own members
-  assert(__msan_test_shadow(>y, sizeof(this->y)) == -1);
-  // ok access base class members
-  assert(__msan_test_shadow(>x_ptr, sizeof(this->x_ptr)) == -1);
+  // ok to access everything
+  assert(__msan_test_shadow(>tb0, sizeof(g->tb0)) == -1);
+  assert(__msan_test_shadow(>b, sizeof(g->b)) == -1);
+  assert(__msan_test_shadow(>tb1, sizeof(g->tb1)) == -1);
+  assert(__msan_test_shadow(>d, sizeof(g->d)) == -1);
 }
 
 int main() {
-  Derived *d = new Derived();
-  assert(__msan_test_shadow(>x_ptr, sizeof(d->x_ptr)) == -1);
-  d->~Derived();
-  assert(__msan_test_shadow(>x_ptr, sizeof(d->x_ptr)) != -1);
+  g = new Derived();
+  // ok to access everything
+  assert(__msan_test_shadow(>tb0, sizeof(g->tb0)) == -1);
+  assert(__msan_test_shadow(>b, sizeof(g->b)) == -1);
+  assert(__msan_test_shadow(>tb1, sizeof(g->tb1)) == -1);
+  assert(__msan_test_shadow(>d, sizeof(g->d)) == -1);
+
+  g->~Derived();
+  // not ok to access everything
+  assert(__msan_test_shadow(>tb0, sizeof(g->tb0)) == 0);
+  assert(__msan_test_shadow(>b, sizeof(g->b)) == 0);
+  assert(__msan_test_shadow(>tb1, sizeof(g->tb1)) == 0);
+  assert(__msan_test_shadow(>d, sizeof(g->d)) == 0);
   return 0;
 }
Index: clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+// Base class has trivial dtor => complete dtor poisons base class memory directly.
+
+class Base {
+ public:
+  int x[4];
+};
+
+class Derived : public Base {
+ public:
+  int y;
+  ~Derived() {
+  }
+};
+
+Derived d;
+
+// Poison members, then poison the trivial base class.
+// CHECK-LABEL: define {{.*}}DerivedD2Ev
+// CHECK: %[[GEP:[0-9a-z]+]] = getelementptr i8, i8* {{.*}}, i64 16
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}%[[GEP]], i64 4
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}, i64 16
+// CHECK: ret void
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -1666,6 +1666,31 @@
 CGF.EmitNounwindRuntimeCall(Fn, Args);
   }
 
+  /// Poison base class with a trivial destructor.
+  struct 

[PATCH] D119299: [NFC] clang-format one function.

2022-02-08 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis created this revision.
eugenis added reviewers: kda, vitalybuka.
eugenis requested review of this revision.
Herald added a project: clang.

fix code formatting


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119299

Files:
  clang/lib/CodeGen/CGClass.cpp


Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -1649,22 +1649,22 @@
 }
   };
 
- static void EmitSanitizerDtorCallback(CodeGenFunction , llvm::Value *Ptr,
- CharUnits::QuantityType PoisonSize) {
-   CodeGenFunction::SanitizerScope SanScope();
-   // Pass in void pointer and size of region as arguments to runtime
-   // function
-   llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),
-  llvm::ConstantInt::get(CGF.SizeTy, PoisonSize)};
-
-   llvm::Type *ArgTypes[] = {CGF.VoidPtrTy, CGF.SizeTy};
-
-   llvm::FunctionType *FnType =
-   llvm::FunctionType::get(CGF.VoidTy, ArgTypes, false);
-   llvm::FunctionCallee Fn =
-   CGF.CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_callback");
-   CGF.EmitNounwindRuntimeCall(Fn, Args);
- }
+  static void EmitSanitizerDtorCallback(CodeGenFunction , llvm::Value *Ptr,
+CharUnits::QuantityType PoisonSize) {
+CodeGenFunction::SanitizerScope SanScope();
+// Pass in void pointer and size of region as arguments to runtime
+// function
+llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),
+   llvm::ConstantInt::get(CGF.SizeTy, PoisonSize)};
+
+llvm::Type *ArgTypes[] = {CGF.VoidPtrTy, CGF.SizeTy};
+
+llvm::FunctionType *FnType =
+llvm::FunctionType::get(CGF.VoidTy, ArgTypes, false);
+llvm::FunctionCallee Fn =
+CGF.CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_callback");
+CGF.EmitNounwindRuntimeCall(Fn, Args);
+  }
 
   class SanitizeDtorMembers final : public EHScopeStack::Cleanup {
 const CXXDestructorDecl *Dtor;


Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -1649,22 +1649,22 @@
 }
   };
 
- static void EmitSanitizerDtorCallback(CodeGenFunction , llvm::Value *Ptr,
- CharUnits::QuantityType PoisonSize) {
-   CodeGenFunction::SanitizerScope SanScope();
-   // Pass in void pointer and size of region as arguments to runtime
-   // function
-   llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),
-  llvm::ConstantInt::get(CGF.SizeTy, PoisonSize)};
-
-   llvm::Type *ArgTypes[] = {CGF.VoidPtrTy, CGF.SizeTy};
-
-   llvm::FunctionType *FnType =
-   llvm::FunctionType::get(CGF.VoidTy, ArgTypes, false);
-   llvm::FunctionCallee Fn =
-   CGF.CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_callback");
-   CGF.EmitNounwindRuntimeCall(Fn, Args);
- }
+  static void EmitSanitizerDtorCallback(CodeGenFunction , llvm::Value *Ptr,
+CharUnits::QuantityType PoisonSize) {
+CodeGenFunction::SanitizerScope SanScope();
+// Pass in void pointer and size of region as arguments to runtime
+// function
+llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),
+   llvm::ConstantInt::get(CGF.SizeTy, PoisonSize)};
+
+llvm::Type *ArgTypes[] = {CGF.VoidPtrTy, CGF.SizeTy};
+
+llvm::FunctionType *FnType =
+llvm::FunctionType::get(CGF.VoidTy, ArgTypes, false);
+llvm::FunctionCallee Fn =
+CGF.CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_callback");
+CGF.EmitNounwindRuntimeCall(Fn, Args);
+  }
 
   class SanitizeDtorMembers final : public EHScopeStack::Cleanup {
 const CXXDestructorDecl *Dtor;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119296: KCFI sanitizer

2022-02-08 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen created this revision.
Herald added subscribers: dexonsmith, dang, jdoerfert, cryptoad.
Herald added a reviewer: aaron.ballman.
samitolvanen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The KCFI sanitizer, enabled with -fsanitize=kcfi, implements a
forward-edge control flow integrity scheme in Clang for indirect
calls. It uses LLVM prefix data to store a type identifier for each
function and injects verification code before indirect calls.

Unlike the current CFI schemes implemented in LLVM, KCFI does not
require LTO, does not alter function references to point to a jump
table, and never breaks function address equality. KCFI is intended
to be used in low-level code, such as operating system kernels,
where the existing schemes can cause undue complications because
of the aforementioned properties. However, unlike the existing
schemes, KCFI is limited to validating only indirect calls and is
not compatible with executable-only memory.

KCFI does not provide runtime support. Users of the scheme are
expected to implement an error handling function with the following
signature:

  void __kcfi_check_fail(uint64_t id, void *ptr);

The first argument is the expected type identifier, and the second
argument is the address of the indirect call. This function must not
return unless -fsanitize-recover=kcfi is passed to Clang, in which
case code execution may continue after the error handler.

A KCFI type identifier is the xxHash64 of a C++ mangled typename,
with the first two bytes replaced with 0x10CF to make it easier for
binary tooling to detect the identifiers in programs where not all
functions have one. If a program contains indirect calls to assembly
functions, they must be manually annotated with the expected type
identifiers to prevent errors. To make this easier, Clang generates
a __kcfi_typeid_ symbol for each address-taken function declaration,
which can be used to annotate functions in assembly:

  .c:
int f(void);
int (*p)(void) = f;
p();
  
  .s:
.quad __kcfi_typeid_f
.global f
f:
  ...

Note that if additional data has been injected between the KCFI
type identifier and the start of the function, e.g. by using
-fpatchable-function-entry, the offset in bytes must be specified
using -fsanitize-kcfi-offset= to avoid errors. The offset
must be the same for all indirectly called functions in every
translation unit.

Similarly to other sanitizers, KCFI checking can be disabled for
a function with a no_sanitize("kcfi") function attribute, or by
using the sanitizer special case list. However, as this may not
be fine-grained enough in cases where want to disable checking
only for specific calls, we also add the kcfi_unchecked attribute
for function pointers and function pointer types, which disables
checking for indirect calls made using an annotated pointer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119296

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Features.def
  clang/include/clang/Basic/Sanitizers.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/kcfi.c
  clang/test/CodeGen/kcfi_unchecked.c
  clang/test/Driver/fsanitize.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-kcfi_unchecked.c

Index: clang/test/Sema/attr-kcfi_unchecked.c
===
--- /dev/null
+++ clang/test/Sema/attr-kcfi_unchecked.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+int a __attribute__((kcfi_unchecked));   // expected-error {{'kcfi_unchecked' attribute argument only applies to a function pointer or a function pointer type}}
+void *p __attribute__((kcfi_unchecked)); // expected-error {{'kcfi_unchecked' attribute argument only applies to a function pointer or a function pointer type}}
+void (*f)(void) __attribute__((kcfi_unchecked));
+
+typedef unsigned long l_unchecked_t __attribute__((kcfi_unchecked)); // expected-error {{'kcfi_unchecked' attribute argument only applies to a function pointer or a function pointer type}}
+typedef int (*f_unchecked_t)(void) __attribute__((kcfi_unchecked));
+
+void f1(unsigned long p __attribute__((kcfi_unchecked))) {} // expected-error {{'kcfi_unchecked' attribute argument only applies to a function pointer or a function pointer type}}
+void f2(void *p __attribute__((kcfi_unchecked))) {} // expected-error 

[PATCH] D118199: [AArch64] ACLE feature macro for Armv8.8-A MOPS

2022-02-08 Thread Andrew via Phabricator via cfe-commits
browneee added a comment.

Hi,

This change appears to break on of the buildbots (clang-ppc64le-linux-lnt 
):
https://lab.llvm.org/buildbot/#/builders/105/builds/21233/steps/7/logs/FAIL__Clang__aarch64-mops_c

   TEST 'Clang :: CodeGen/aarch64-mops.c' FAILED 

  Script:
  --
  : 'RUN: at line 3';   
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/clang -cc1 
-internal-isystem 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/lib/clang/15.0.0/include
 -nostdsysteminc -triple aarch64-arm-unknown-eabi -target-feature +mops 
-target-feature +mte -S -emit-llvm -o - 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/clang/test/CodeGen/aarch64-mops.c
  | 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/FileCheck 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/clang/test/CodeGen/aarch64-mops.c
  : 'RUN: at line 4';   
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/clang -cc1 
-internal-isystem 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/lib/clang/15.0.0/include
 -nostdsysteminc -triple aarch64-arm-unknown-eabi -verify 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/clang/test/CodeGen/aarch64-mops.c
  : 'RUN: at line 5';   
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/clang 
-target aarch64-arm-none-eabi -march=armv8.7-a+mops+memtag  -S 
-emit-llvm 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/clang/test/CodeGen/aarch64-mops.c
 -o - | 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/FileCheck 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/clang/test/CodeGen/aarch64-mops.c
  : 'RUN: at line 6';   
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/clang 
-target aarch64-arm-none-eabi -march=armv8.8-a+memtag   -S 
-emit-llvm 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/clang/test/CodeGen/aarch64-mops.c
 -o - | 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/FileCheck 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/clang/test/CodeGen/aarch64-mops.c
  : 'RUN: at line 7';   
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/clang 
-target aarch64-arm-none-eabi -march=armv9.2-a+mops+memtag  -S 
-emit-llvm 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/clang/test/CodeGen/aarch64-mops.c
 -o - | 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/FileCheck 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/clang/test/CodeGen/aarch64-mops.c
  : 'RUN: at line 8';   
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/clang 
-target aarch64-arm-none-eabi -march=armv9.3-a+memtag   -S 
-emit-llvm 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/clang/test/CodeGen/aarch64-mops.c
 -o - | 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/FileCheck 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/clang/test/CodeGen/aarch64-mops.c
  : 'RUN: at line 9';   
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/clang 
-target aarch64-arm-none-eabi -march=armv8.7-a  -Xclang -verify -S 
-emit-llvm 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/clang/test/CodeGen/aarch64-mops.c
 -o -
  : 'RUN: at line 10';   
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/clang 
-target aarch64-arm-none-eabi -march=armv8.7-a+mops -Xclang -verify -S 
-emit-llvm 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/clang/test/CodeGen/aarch64-mops.c
 -o -
  : 'RUN: at line 11';   
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/clang 
-target aarch64-arm-none-eabi -march=armv8.8-a  -Xclang -verify -S 
-emit-llvm 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/clang/test/CodeGen/aarch64-mops.c
 -o -
  : 'RUN: at line 12';   
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/clang 
-target aarch64-arm-none-eabi -march=armv9.2-a  -Xclang -verify -S 
-emit-llvm 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/clang/test/CodeGen/aarch64-mops.c
 -o -
  : 'RUN: at line 13';   
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/clang 
-target aarch64-arm-none-eabi -march=armv9.2-a+mops -Xclang -verify -S 
-emit-llvm 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/clang/test/CodeGen/aarch64-mops.c
 -o -
  : 'RUN: at line 14';   
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/clang 
-target aarch64-arm-none-eabi -march=armv9.3-a  -Xclang -verify -S 
-emit-llvm 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/clang/test/CodeGen/aarch64-mops.c
 -o -
  --
  Exit Code: 2
  Command Output (stderr):
  --
  In file included from 

[PATCH] D116861: [UBSan] Fix incorrect alignment reported when global new returns an offset pointer

2022-02-08 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

If we want to assume a weaker alignment, we should change the calculation of 
`allocationAlign` rather than just changing this point downstream of that 
computation.  But replacements of the standard `operator new` are restricted 
and cannot simply choose to return less-aligned memory; at the very least, the 
test program is not portable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116861

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


[PATCH] D119257: Revert "Re-land [LLD] Remove global state in lldCommon"

2022-02-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D119257#3306151 , @krzysz00 wrote:

> Having checked with other folks more familiar with the context of our 
> project, it looks like we might actually be fine using lld as a subprocess, 
> since we'll always be sitting on top of a ROCm installation, which includes 
> lld, and since "take this object file and wrap it into a shared library" is 
> extremely unlikely to be broken by version changes.

Thanks for the flexibility :)

> That being said, I've also heard that when this code was initially landing 
> (as part of mlir-rocm-runner, and before my time), the feedback was to use 
> lld as a library and not a subprocess.

I guess they did not realize how tricky to make lld/ELF library usage more 
reliable ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119257

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


[PATCH] D118525: [modules] Merge ObjC interface ivars with anonymous types.

2022-02-08 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 406977.
vsapsai added a comment.
Herald added a project: clang.

Rebase and address clang-format comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118525

Files:
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/AST/ast-dump-decl.mm
  clang/test/Modules/merge-anon-record-definition-in-objc.m
  clang/test/SemaObjC/check-dup-decls-inside-objc.m

Index: clang/test/SemaObjC/check-dup-decls-inside-objc.m
===
--- /dev/null
+++ clang/test/SemaObjC/check-dup-decls-inside-objc.m
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class -x objective-c++ %s
+
+// Test decls inside Objective-C entities are considered to be duplicates of same-name decls outside of these entities.
+
+@protocol SomeProtocol
+struct InProtocol {}; // expected-note {{previous definition is here}}
+- (union MethodReturnType { int x; float y; })returningMethod; // expected-note {{previous definition is here}}
+#ifdef __cplusplus
+// expected-error@-2 {{'MethodReturnType' cannot be defined in a parameter type}}
+#endif
+@end
+
+@interface Container {
+  struct InInterfaceCurliesWithField {} field; // expected-note {{previous definition is here}}
+  union InInterfaceCurlies { int x; float y; }; // expected-note {{previous definition is here}}
+}
+enum InInterface { kX = 0, }; // expected-note {{previous definition is here}}
+@end
+
+@interface Container(Category)
+union InCategory { int x; float y; }; // expected-note {{previous definition is here}}
+@end
+
+@interface Container() {
+  enum InExtensionCurliesWithField: int { kY = 1, } extensionField; // expected-note {{previous definition is here}}
+  struct InExtensionCurlies {}; // expected-note {{previous definition is here}}
+}
+union InExtension { int x; float y; }; // expected-note {{previous definition is here}}
+@end
+
+@implementation Container {
+  union InImplementationCurliesWithField { int x; float y; } implField; // expected-note {{previous definition is here}}
+  enum InImplementationCurlies { kZ = 2, }; // expected-note {{previous definition is here}}
+}
+struct InImplementation {}; // expected-note {{previous definition is here}}
+@end
+
+@implementation Container(Category)
+enum InCategoryImplementation { kW = 3, }; // expected-note {{previous definition is here}}
+@end
+
+
+struct InProtocol { int a; }; // expected-error {{redefinition of 'InProtocol'}}
+union MethodReturnType { int a; long b; }; // expected-error {{redefinition of 'MethodReturnType'}}
+
+struct InInterfaceCurliesWithField { int a; }; // expected-error {{redefinition of 'InInterfaceCurliesWithField'}}
+union InInterfaceCurlies { int a; long b; }; // expected-error {{redefinition of 'InInterfaceCurlies'}}
+enum InInterface { kA = 10, }; // expected-error {{redefinition of 'InInterface'}}
+
+union InCategory { int a; long b; }; // expected-error {{redefinition of 'InCategory'}}
+
+enum InExtensionCurliesWithField: int { kB = 11, }; // expected-error {{redefinition of 'InExtensionCurliesWithField'}}
+struct InExtensionCurlies { int a; }; // expected-error {{redefinition of 'InExtensionCurlies'}}
+union InExtension { int a; long b; }; // expected-error {{redefinition of 'InExtension'}}
+
+union InImplementationCurliesWithField { int a; long b; }; // expected-error {{redefinition of 'InImplementationCurliesWithField'}}
+enum InImplementationCurlies { kC = 12, }; // expected-error {{redefinition of 'InImplementationCurlies'}}
+struct InImplementation { int a; }; // expected-error {{redefinition of 'InImplementation'}}
+
+enum InCategoryImplementation { kD = 13, }; // expected-error {{redefinition of 'InCategoryImplementation'}}
Index: clang/test/Modules/merge-anon-record-definition-in-objc.m
===
--- /dev/null
+++ clang/test/Modules/merge-anon-record-definition-in-objc.m
@@ -0,0 +1,77 @@
+// UNSUPPORTED: -zos, -aix
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -fsyntax-only -F%t/Frameworks %t/test.m -Wno-objc-property-implementation -Wno-incomplete-implementation \
+// RUN:-fmodules -fmodule-name=Target -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
+
+// Test anonymous TagDecl inside Objective-C interfaces are merged and ivars with these anonymous types are merged too.
+
+//--- Frameworks/Foundation.framework/Headers/Foundation.h
+@interface NSObject
+@end
+
+//--- Frameworks/Foundation.framework/Modules/module.modulemap
+framework module Foundation {
+  header "Foundation.h"
+  export *
+}
+
+//--- Frameworks/Target.framework/Headers/Target.h
+#import 
+@interface TestClass : NSObject {
+@public
+  struct {
+struct { 

[clang] ca9f0ec - [clang] Document objc_unsafeClaimAutoreleasedReturnValue.

2022-02-08 Thread Ahmed Bougacha via cfe-commits

Author: Ahmed Bougacha
Date: 2022-02-08T14:30:39-08:00
New Revision: ca9f0ec1a30b899ce9df3d2173aa9a295b510509

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

LOG: [clang] Document objc_unsafeClaimAutoreleasedReturnValue.

This has been added a few years ago but wasn't listed here.

Added: 


Modified: 
clang/docs/AutomaticReferenceCounting.rst

Removed: 




diff  --git a/clang/docs/AutomaticReferenceCounting.rst 
b/clang/docs/AutomaticReferenceCounting.rst
index 9b0b6b86eb11e..5e40fa837b1aa 100644
--- a/clang/docs/AutomaticReferenceCounting.rst
+++ b/clang/docs/AutomaticReferenceCounting.rst
@@ -2380,8 +2380,10 @@ the current pool, and returns an opaque "handle" to it.
 If ``value`` is null, this call has no effect.  Otherwise, it makes a best
 effort to hand off ownership of a retain count on the object to a call to
 :ref:`objc_retainAutoreleasedReturnValue
-` for the same object in an
-enclosing call frame.  If this is not possible, the object is autoreleased as
+` (or
+:ref:`objc_unsafeClaimAutoreleasedReturnValue
+`) for the same object in
+an enclosing call frame.  If this is not possible, the object is autoreleased 
as
 above.
 
 Always returns ``value``.
@@ -2579,8 +2581,8 @@ Always returns ``value``.
 If ``value`` is null, this call has no effect.  Otherwise, it attempts to
 accept a hand off of a retain count from a call to
 :ref:`objc_autoreleaseReturnValue ` on
-``value`` in a recently-called function or something it calls.  If that fails,
-it performs a retain operation exactly like :ref:`objc_retain
+``value`` in a recently-called function or something it tail-calls.  If that
+fails, it performs a retain operation exactly like :ref:`objc_retain
 `.
 
 Always returns ``value``.
@@ -2639,3 +2641,21 @@ registration updated to point to ``value``.
 
 Returns the value of ``object`` after the call.
 
+.. _arc.runtime.objc_unsafeClaimAutoreleasedReturnValue:
+
+``id objc_unsafeClaimAutoreleasedReturnValue(id value);``
+-
+
+*Precondition:* ``value`` is null or a pointer to a valid object.
+
+If ``value`` is null, this call has no effect.  Otherwise, it attempts to
+accept a hand off of a retain count from a call to
+:ref:`objc_autoreleaseReturnValue ` on
+``value`` in a recently-called function or something it tail-calls (in a manner
+similar to :ref:`objc_retainAutoreleasedReturnValue
+`).  If that succeeds,
+it performs a release operation exactly like :ref:`objc_release
+`.  If the handoff fails, this call has no effect.
+
+Always returns ``value``.
+



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


[clang] 6ba68a5 - [clang][Driver] Use a VersionTuple for darwin linker version checks.

2022-02-08 Thread Ahmed Bougacha via cfe-commits

Author: Ahmed Bougacha
Date: 2022-02-08T14:30:39-08:00
New Revision: 6ba68a5fc34271c85f438217f50e165cb0158c04

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

LOG: [clang][Driver] Use a VersionTuple for darwin linker version checks.

This unifies a couple spots that did it manually by checking the
flag directly.

It does mean that we're now dropping the 5th component, but that's
not used in any of these checks, and to my knowledge it's never been
used in ld64.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Darwin.h
clang/test/Driver/darwin-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index e71511747e44d..df860ccc6be4f 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -209,19 +209,19 @@ static bool shouldLinkerNotDedup(bool IsLinkerOnlyAction, 
const ArgList ) {
 void darwin::Linker::AddLinkArgs(Compilation , const ArgList ,
  ArgStringList ,
  const InputInfoList ,
- unsigned Version[5], bool LinkerIsLLD) const {
+ VersionTuple Version, bool LinkerIsLLD) const 
{
   const Driver  = getToolChain().getDriver();
   const toolchains::MachO  = getMachOToolChain();
 
   // Newer linkers support -demangle. Pass it if supported and not disabled by
   // the user.
-  if ((Version[0] >= 100 || LinkerIsLLD) &&
+  if ((Version >= VersionTuple(100) || LinkerIsLLD) &&
   !Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
 CmdArgs.push_back("-demangle");
 
   // FIXME: Pass most of the flags below that check Version if LinkerIsLLD too.
 
-  if (Args.hasArg(options::OPT_rdynamic) && Version[0] >= 137)
+  if (Args.hasArg(options::OPT_rdynamic) && Version >= VersionTuple(137))
 CmdArgs.push_back("-export_dynamic");
 
   // If we are using App Extension restrictions, pass a flag to the linker
@@ -230,7 +230,7 @@ void darwin::Linker::AddLinkArgs(Compilation , const 
ArgList ,
options::OPT_fno_application_extension, false))
 CmdArgs.push_back("-application_extension");
 
-  if (D.isUsingLTO() && Version[0] >= 116 && NeedsTempPath(Inputs)) {
+  if (D.isUsingLTO() && Version >= VersionTuple(116) && NeedsTempPath(Inputs)) 
{
 std::string TmpPathName;
 if (D.getLTOMode() == LTOK_Full) {
   // If we are using full LTO, then automatically create a temporary file
@@ -259,7 +259,7 @@ void darwin::Linker::AddLinkArgs(Compilation , const 
ArgList ,
   // clang version won't work anyways.
   // lld is built at the same revision as clang and statically links in
   // LLVM libraries, so it doesn't need libLTO.dylib.
-  if (Version[0] >= 133 && !LinkerIsLLD) {
+  if (Version >= VersionTuple(133) && !LinkerIsLLD) {
 // Search for libLTO in /../lib/libLTO.dylib
 StringRef P = llvm::sys::path::parent_path(D.Dir);
 SmallString<128> LibLTOPath(P);
@@ -270,7 +270,7 @@ void darwin::Linker::AddLinkArgs(Compilation , const 
ArgList ,
   }
 
   // ld64 version 262 and above run the deduplicate pass by default.
-  if (Version[0] >= 262 && shouldLinkerNotDedup(C.getJobs().empty(), Args))
+  if (Version >= VersionTuple(262) && 
shouldLinkerNotDedup(C.getJobs().empty(), Args))
 CmdArgs.push_back("-no_deduplicate");
 
   // Derived from the "link" spec.
@@ -342,7 +342,7 @@ void darwin::Linker::AddLinkArgs(Compilation , const 
ArgList ,
   Args.AddAllArgs(CmdArgs, options::OPT_init);
 
   // Add the deployment target.
-  if (Version[0] >= 520 || LinkerIsLLD)
+  if (Version >= VersionTuple(520) || LinkerIsLLD)
 MachOTC.addPlatformVersionArgs(Args, CmdArgs);
   else
 MachOTC.addMinVersionArgs(Args, CmdArgs);
@@ -368,7 +368,8 @@ void darwin::Linker::AddLinkArgs(Compilation , const 
ArgList ,
 // Check if the toolchain supports bitcode build flow.
 if (MachOTC.SupportsEmbeddedBitcode()) {
   CmdArgs.push_back("-bitcode_bundle");
-  if (C.getDriver().embedBitcodeMarkerOnly() && Version[0] >= 278) {
+  if (C.getDriver().embedBitcodeMarkerOnly() &&
+  Version >= VersionTuple(278)) {
 CmdArgs.push_back("-bitcode_process_mode");
 CmdArgs.push_back("marker");
   }
@@ -548,12 +549,7 @@ void darwin::Linker::ConstructJob(Compilation , const 
JobAction ,
 return;
   }
 
-  unsigned Version[5] = {0, 0, 0, 0, 0};
-  if (Arg *A = Args.getLastArg(options::OPT_mlinker_version_EQ)) {
-if (!Driver::GetReleaseVersion(A->getValue(), Version))
-  getToolChain().getDriver().Diag(diag::err_drv_invalid_version_number)
-  << A->getAsString(Args);
-  }
+  VersionTuple Version = getMachOToolChain().getLinkerVersion(Args);
 
  

[PATCH] D119257: Revert "Re-land [LLD] Remove global state in lldCommon"

2022-02-08 Thread Krzysztof Drewniak via Phabricator via cfe-commits
krzysz00 added a comment.

Having checked with other folks more familiar with the context of our project, 
it looks like we might actually be fine using lld as a subprocess, since we'll 
always be sitting on top of a ROCm installation, which includes lld, and since 
"take this object file and wrap it into a shared library" is extremely unlikely 
to be broken by version changes.

That being said, I've also heard that when this code was initially landing (as 
part of mlir-rocm-runner, and before my time), the feedback was to use lld as a 
library and not a subprocess.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119257

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


[PATCH] D119291: [Clang] Add support for STDC CX_LIMITED_RANGE pragma.

2022-02-08 Thread Joshua Cranmer via Phabricator via cfe-commits
jcranmer-intel created this revision.
Herald added a subscriber: dexonsmith.
jcranmer-intel requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This pragma is defined in the C specification. Notably, the C specification
makes the "DEFAULT" value identical to "OFF" for this pragma, unlike other
floating-point pragmas which are undefined behavior. This may be surprising to
some users.

This patch builds on, and requires, the complex intrinsics to make the pragmas
work properly.

Depends on D119290 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119291

Files:
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Lex/Pragma.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/test/CodeGen/cx-limited-range-pragma.c

Index: clang/test/CodeGen/cx-limited-range-pragma.c
===
--- /dev/null
+++ clang/test/CodeGen/cx-limited-range-pragma.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -fuse-complex-intrinsics -fcx-range=limited -o - | FileCheck %s --check-prefixes=CHECK-COMMON,CHECK-LIMITED
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -fuse-complex-intrinsics -fcx-range=nonan -o - | FileCheck %s --check-prefixes=CHECK-COMMON,CHECK-NO-NAN
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -fuse-complex-intrinsics -fcx-range=full -o - | FileCheck %s --check-prefixes=CHECK-COMMON,CHECK-FULL
+
+_Complex float range_limited(_Complex float a, _Complex float b) {
+// CHECK-COMMON: @range_limited
+// CHECK-COMMON: call{{.*}}complex.fmul{{.*}} #[[LIMITED:[0-9]+]]
+// CHECK-COMMON: call{{.*}}complex.fdiv{{.*}} #[[LIMITED]]
+#pragma STDC CX_LIMITED_RANGE ON
+  return a * b + a / b;
+}
+
+_Complex float range_full(_Complex float a, _Complex float b) {
+// CHECK-COMMON: @range_full
+// CHECK-COMMON: call{{.*}}complex.fmul{{.*}} #[[FULL:[0-9]+]]
+// CHECK-COMMON: call{{.*}}complex.fdiv{{.*}} #[[FULL]]
+#pragma STDC CX_LIMITED_RANGE OFF
+  return a * b + a / b;
+}
+
+_Complex float range_default(_Complex float a, _Complex float b) {
+// CHECK-LIMITED: @range_default
+// CHECK-LIMITED: call{{.*}}complex.fmul{{.*}} #[[LIMITED]]
+// CHECK-LIMITED: call{{.*}}complex.fdiv{{.*}} #[[LIMITED]]
+// CHECK-NO-NAN: @range_default
+// CHECK-NO-NAN: call{{.*}}complex.fmul{{.*}} #[[LIMITED]]
+// CHECK-NO-NAN: call{{.*}}complex.fdiv{{.*}} #[[NONAN:[0-9]+]]
+// CHECK-FULL: @range_default
+// CHECK-FULL: call{{.*}}complex.fmul{{.*}} #[[FULL]]
+// CHECK-FULL: call{{.*}}complex.fdiv{{.*}} #[[FULL]]
+  return a * b + a / b;
+}
+
+_Complex float range_scoped(_Complex float a, _Complex float b) {
+// CHECK-COMMON: @range_scoped
+// CHECK-COMMON: call{{.*}}complex.fmul{{.*}} #[[FULL]]
+// CHECK-COMMON: call{{.*}}complex.fdiv{{.*}} #[[FULL]]
+#pragma STDC CX_LIMITED_RANGE OFF
+  _Complex float res = a * b;
+  {
+#pragma STDC CX_LIMITED_RANGE DEFAULT
+res += a / b;
+  }
+  return res;
+}
+
+// CHECK-COMMON: attributes #[[LIMITED]] = { "complex-range"="limited" }
+// CHECK-COMMON: attributes #[[FULL]] = { "complex-range"="full" }
+// CHECK-NO-NAN: attributes #[[NONAN]] = { "complex-range"="no-nan" }
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -1165,6 +1165,14 @@
   CurFPFeatures = NewFPFeatures.applyOverrides(LO);
 }
 
+void Sema::ActOnPragmaComplexLimitedRange(SourceLocation Loc,
+  LangOptions::ComplexRangeKind Range) {
+  FPOptionsOverride NewFPFeatures = CurFPFeatureOverrides();
+  NewFPFeatures.setComplexRangeOverride(Range);
+  FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);
+  CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
+}
+
 void Sema::ActOnPragmaFPExceptions(SourceLocation Loc,
LangOptions::FPExceptionModeKind FPE) {
   setExceptionMode(Loc, FPE);
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -791,6 +791,9 @@
   case tok::annot_pragma_fenv_round:
 HandlePragmaFEnvRound();
 return nullptr;
+  case tok::annot_pragma_cx_limited_range:
+HandlePragmaComplexLimitedRange();
+return nullptr;
   case tok::annot_pragma_float_control:
 HandlePragmaFloatControl();
 return nullptr;
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -388,6 +388,12 @@
 ConsumeAnnotationToken();
 return StmtError();
 
+  case tok::annot_pragma_cx_limited_range:
+

[PATCH] D119290: [Clang] Add support for -fcx-limited-range, -fcx-fortran-rules options.

2022-02-08 Thread Joshua Cranmer via Phabricator via cfe-commits
jcranmer-intel created this revision.
Herald added a subscriber: dang.
jcranmer-intel requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

These are built on top of, and require, the complex intrinsics definitions to
work with. They are intended to be similar in operation to the gcc command line
options.

Depends on D119289 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119290

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/complex-range-flags.c

Index: clang/test/Driver/complex-range-flags.c
===
--- /dev/null
+++ clang/test/Driver/complex-range-flags.c
@@ -0,0 +1,21 @@
+// Test that the tri-valued complex range argument gets set appropriately.
+
+// REQUIRES: clang-driver
+
+// CHECK-FULL-RANGE: "-cc1"
+// CHECK-FULL-RANGE: "-fcx-range=full"
+
+// CHECK-LIMITED-RANGE: "-cc1"
+// CHECK-LIMITED-RANGE: "-fcx-range=limited"
+
+// CHECK-NONAN-RANGE: "-cc1"
+// CHECK-NONAN-RANGE: "-fcx-range=nonan"
+
+// RUN: %clang -### -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FULL-RANGE %s
+
+// RUN: %clang -### -c -fcx-limited-range %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LIMITED-RANGE %s
+
+// RUN: %clang -### -c -fcx-fortran-rules %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NONAN-RANGE %s
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2696,6 +2696,19 @@
 // overriden by ffp-exception-behavior?
   bool RoundingFPMath = false;
   bool RoundingMathPresent = false; // Is rounding-math in args?
+  LangOptions::ComplexRangeKind CxRangeArg =
+LangOptions::CX_Full;
+  StringRef RulingRangeArg = "";
+  auto setCxRangeArg = [, , , ](
+  LangOptions::ComplexRangeKind Kind, StringRef ArgName) {
+if (!RulingRangeArg.empty() && Kind != CxRangeArg) {
+D.Diag(clang::diag::warn_drv_overriding_flag_option)
+   << Args.MakeArgString(RulingRangeArg)
+   << Args.MakeArgString(ArgName);
+}
+RulingRangeArg = ArgName;
+CxRangeArg = Kind;
+  };
   // -ffp-model values: strict, fast, precise
   StringRef FPModel = "";
   // -ffp-exception-behavior options: strict, maytrap, ignore
@@ -2942,6 +2955,7 @@
   RoundingFPMath = false;
   // If fast-math is set then set the fp-contract mode to fast.
   FPContract = "fast";
+  CxRangeArg = LangOptions::CX_NoNan;
   break;
 case options::OPT_fno_fast_math:
   HonorINFs = true;
@@ -2966,6 +2980,19 @@
   << "-ffp-contract=on";
 }
   break;
+
+case options::OPT_fcx_limited_range:
+  setCxRangeArg(LangOptions::CX_Limited, "fcx-limited-range");
+  break;
+case options::OPT_fnocx_limited_range:
+  setCxRangeArg(LangOptions::CX_Full, "fcx-limited-range");
+  break;
+case options::OPT_fcx_fortran_rules:
+  setCxRangeArg(LangOptions::CX_NoNan, "fcx-fortran-rules");
+  break;
+case options::OPT_fnocx_fortran_rules:
+  setCxRangeArg(LangOptions::CX_Full, "fcx-fortran-rules");
+  break;
 }
 if (StrictFPModel) {
   // If -ffp-model=strict has been specified on command line but
@@ -3103,6 +3130,18 @@
DefaultUseComplexIntrinsics)) {
 CmdArgs.push_back("-fuse-complex-intrinsics");
   }
+
+  switch (CxRangeArg) {
+  case LangOptions::CX_Limited:
+CmdArgs.push_back("-fcx-range=limited");
+break;
+  case LangOptions::CX_NoNan:
+CmdArgs.push_back("-fcx-range=nonan");
+break;
+  case LangOptions::CX_Full:
+CmdArgs.push_back("-fcx-range=full");
+break;
+  }
 }
 
 static void RenderAnalyzerOptions(const ArgList , ArgStringList ,
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1847,6 +1847,16 @@
   "Determines whether to lower _Complex operations to LLVM complex "
   "intrinsics">,
   NegFlag>;
+def fcx_limited_range : Flag<["-"], "fcx-limited-range">, Group;
+def fnocx_limited_range : Flag<["-"], "fnocx-limited-range">, Group;
+def fcx_fortran_rules : Flag<["-"], "fcx-fortran-rules">, Group;
+def fnocx_fortran_rules : Flag<["-"], "fnocx-fortran-rules">, Group;
+def cx_rangeEQ : Joined<["-"], "fcx-range=">, Group, Flags<[CC1Option]>,
+  HelpText<"Specifies the behavior of complex multiplication and division">,
+  Values<"limited,nonan,full">,
+  NormalizedValuesScope<"LangOptions">,
+  NormalizedValues<["CX_Limited", "CX_NoNan", "CX_Full"]>,
+  MarshallingInfoEnum, "CX_Full">;
 
 def ffor_scope : Flag<["-"], "ffor-scope">, Group;
 def fno_for_scope : Flag<["-"], "fno-for-scope">, Group;

[PATCH] D119289: [Clang] Add lowering for _C complex arithmetic to complex intrinsics.

2022-02-08 Thread Joshua Cranmer via Phabricator via cfe-commits
jcranmer-intel created this revision.
Herald added subscribers: dexonsmith, dang, pengfei.
jcranmer-intel requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This adds a new guard flag, -fuse-complex-intrinsics, that is defaulted to on
for the x86/x86-64 platforms, as they can be lowered to complex intrinsics
through the entire pipeline correctly. Other platforms could be added, but it
requires auditing their support correctly in the backend, and I don't have as
much familiarity with their ABIs as I do for x86/x86-64. Help would be
appreciated.

Future patches will build on top of this support to enable more complex limited
range support, but only when lowering to intrinsics.

Depends on D119288 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119289

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/FPOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/complex-intrinsics.c

Index: clang/test/CodeGen/complex-intrinsics.c
===
--- /dev/null
+++ clang/test/CodeGen/complex-intrinsics.c
@@ -0,0 +1,188 @@
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -o - | FileCheck %s --check-prefix=NOINTRIN
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck %s --check-prefix=NOINTRIN
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple i686-unknown-unknown -o - | FileCheck %s --check-prefix=NOINTRIN
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple spir -o - | FileCheck %s --check-prefix=NOINTRIN
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -fuse-complex-intrinsics -o - | FileCheck %s --check-prefix=INTRIN
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-pc-win64 -fuse-complex-intrinsics -o - | FileCheck %s --check-prefix=INTRIN
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -fuse-complex-intrinsics -DT=int -o - | FileCheck %s --check-prefix=INT
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -DT=int -o - | FileCheck %s --check-prefix=INT
+
+// Check defaults for intrinsics:
+// RUN: %clang %s -O0 -S -emit-llvm -target x86_64-unknown-unknown -o - | FileCheck %s --check-prefix=INTRIN
+// RUN: %clang %s -O0 -S -emit-llvm -target x86_64-unknown-unknown -fuse-complex-intrinsics -o - | FileCheck %s --check-prefix=INTRIN
+// RUN: %clang %s -O0 -S -emit-llvm -target x86_64-unknown-unknown -fno-use-complex-intrinsics -o - | FileCheck %s --check-prefix=NOINTRIN
+// RUN: %clang %s -O0 -S -emit-llvm -target aarch64-unknown-unknown -o - | FileCheck %s --check-prefix=NOINTRIN
+// RUN: %clang %s -O0 -S -emit-llvm -target aarch64-unknown-unknown -fuse-complex-intrinsics -o - | FileCheck %s --check-prefix=INTRIN
+// RUN: %clang %s -O0 -S -emit-llvm -target aarch64-unknown-unknown -fno-use-complex-intrinsics -o - | FileCheck %s --check-prefix=NOINTRIN
+
+#ifndef T
+#  define T float
+#endif
+
+T check_var;
+// INTRIN: @check_var = {{.*}}global [[T:[a-z0-9]+]]
+// NOINTRIN: @check_var = {{.*}}global [[T:[a-z0-9]+]]
+// INT: @check_var = {{.*}}global [[T:i[0-9]+]]
+
+T _Complex add_rc(T a, T _Complex b) {
+  // INTRIN-LABEL: @add_rc(
+  // INTRIN-COUNT-1: fadd [[T]]
+  // INTRIN: ret
+  // NOINTRIN-LABEL: @add_rc(
+  // NOINTRIN-COUNT-1: fadd [[T]]
+  // NOINTRIN: ret
+  // INT-LABEL: @add_rc(
+  // INT-COUNT-1: add [[T]]
+  // INT: ret
+  return a + b;
+}
+
+T _Complex add_cr(T _Complex a, T b) {
+  // INTRIN-LABEL: @add_cr(
+  // INTRIN-COUNT-1: fadd [[T]]
+  // INTRIN: ret
+  // NOINTRIN-LABEL: @add_cr(
+  // NOINTRIN-COUNT-1: fadd [[T]]
+  // NOINTRIN: ret
+  // INT-LABEL: @add_cr(
+  // INT-COUNT-1: add [[T]]
+  // INT: ret
+  return a + b;
+}
+
+T _Complex add_cc(T _Complex a, T _Complex b) {
+  // INTRIN-LABEL: @add_cc(
+  // INTRIN-COUNT-2: fadd [[T]]
+  // INTRIN: ret
+  // NOINTRIN-LABEL: @add_cc(
+  // NOINTRIN-COUNT-2: fadd [[T]]
+  // NOINTRIN: ret
+  // INT-LABEL: @add_cc(
+  // INT-COUNT-2: add [[T]]
+  // INT: ret
+  return a + b;
+}
+
+T _Complex sub_rc(T a, T _Complex b) {
+  // INTRIN-LABEL: @sub_rc(
+  // INTRIN: fsub [[T]]
+  // INTRIN: fneg [[T]]
+  // INTRIN: ret
+  // NOINTRIN-LABEL: @sub_rc(
+  // NOINTRIN: fsub [[T]]
+  // NOINTRIN: fneg [[T]]
+  // NOINTRIN: ret
+  // INT-LABEL: @sub_rc(
+  // INT-COUNT-2: sub [[T]]
+  // INT: ret
+  return a - b;
+}
+
+T _Complex sub_cr(T _Complex a, T b) {
+  // INTRIN-LABEL: @sub_cr(
+  // INTRIN: fsub [[T]]
+  // INTRIN-NOT: fsub [[T]]
+  // INTRIN: ret
+  // NOINTRIN-LABEL: @sub_cr(
+  // NOINTRIN: fsub [[T]]
+  // NOINTRIN-NOT: fsub [[T]]
+  // NOINTRIN: ret
+  // INT-LABEL: @sub_cr(
+  // INT-COUNT-2: sub [[T]]
+  // INT: ret
+  return a - b;
+}
+
+T _Complex sub_cc(T _Complex a, T 

[PATCH] D118977: [NVPTX] Add more FMA intriniscs/builtins

2022-02-08 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: llvm/lib/Target/NVPTX/NVPTXIntrinsics.td:937
+class FMA_TUPLE Preds = [hasPTX70, hasSM80]> {
+  string Variant = V;

 I think the default should be the most useful/common and the least surprising 
value.
I'd argue that in this case it would be `[]`.  This would give reader a 
reasonable idea about what's going on even without looking at FMA_TUPLE 
implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118977

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


[PATCH] D119257: Revert "Re-land [LLD] Remove global state in lldCommon"

2022-02-08 Thread Krzysztof Drewniak via Phabricator via cfe-commits
krzysz00 added a comment.

(Since it looks like the discussion moved here) @MaskRay We can't spawn lld as 
a subprocess due to customer requirements around having the kernel 
generator/compiler delivered as a static library in some cases. (And there's 
LLVM version compatibility concerns, but those might be less of an issue in 
this case)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119257

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


[PATCH] D119257: Revert "Re-land [LLD] Remove global state in lldCommon"

2022-02-08 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

Yes, I saw these, thanks a lot @aganea !!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119257

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


[PATCH] D119257: Revert "Re-land [LLD] Remove global state in lldCommon"

2022-02-08 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

@mehdi_amini  Just to unblock users, I've posted 
https://reviews.llvm.org/D119277 which fixes the issue originally raised by 
@krzysz00 
I'm also working on a more long term solution in 
https://reviews.llvm.org/D119049


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119257

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


[PATCH] D119257: Revert "Re-land [LLD] Remove global state in lldCommon"

2022-02-08 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

(The discussion seems to be happening in two places: 
https://github.com/llvm/llvm-project/issues/53475 )

You can break downstream users, the relationship inside the monorepo is 
different as far as I know: I believe we will have to live with revert like the 
one above until you collaborate actively to find a supported way and move there 
though. 
Just asking "please move away from the library usage" alone won't be enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119257

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


[PATCH] D118936: [test] Remove -fno-experimental-new-pass-manager -O1 from sanitize-address-field-padding.cpp

2022-02-08 Thread Arthur Eubanks 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 rGf16cc5df2288: [test] Remove 
-fno-experimental-new-pass-manager -O1 from sanitize-address… (authored by 
aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118936

Files:
  clang/test/CodeGen/sanitize-address-field-padding.cpp


Index: clang/test/CodeGen/sanitize-address-field-padding.cpp
===
--- clang/test/CodeGen/sanitize-address-field-padding.cpp
+++ clang/test/CodeGen/sanitize-address-field-padding.cpp
@@ -2,7 +2,7 @@
 // RUN: echo 'type:SomeNamespace::IgnorelistedByName=field-padding' > 
%t.type.ignorelist
 // RUN: echo 'src:*sanitize-address-field-padding.cpp=field-padding' > 
%t.file.ignorelist
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address 
-fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.type.ignorelist 
-Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address 
-fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.type.ignorelist 
-Rsanitize-address -emit-llvm -o - %s -O1 -fno-experimental-new-pass-manager 
-mconstructor-aliases 2>&1 | FileCheck %s --check-prefix=WITH_CTOR_ALIASES
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address 
-fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.type.ignorelist 
-Rsanitize-address -emit-llvm -o - %s -mconstructor-aliases 2>&1 | FileCheck %s 
--check-prefix=WITH_CTOR_ALIASES
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address 
-fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.file.ignorelist 
-Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s 
--check-prefix=FILE_IGNORELIST
 // RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - %s 2>&1 | FileCheck %s 
--check-prefix=NO_PADDING
 // Try to emulate -save-temps option and make sure -disable-llvm-passes will 
not run sanitize instrumentation.


Index: clang/test/CodeGen/sanitize-address-field-padding.cpp
===
--- clang/test/CodeGen/sanitize-address-field-padding.cpp
+++ clang/test/CodeGen/sanitize-address-field-padding.cpp
@@ -2,7 +2,7 @@
 // RUN: echo 'type:SomeNamespace::IgnorelistedByName=field-padding' > %t.type.ignorelist
 // RUN: echo 'src:*sanitize-address-field-padding.cpp=field-padding' > %t.file.ignorelist
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.type.ignorelist -Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.type.ignorelist -Rsanitize-address -emit-llvm -o - %s -O1 -fno-experimental-new-pass-manager -mconstructor-aliases 2>&1 | FileCheck %s --check-prefix=WITH_CTOR_ALIASES
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.type.ignorelist -Rsanitize-address -emit-llvm -o - %s -mconstructor-aliases 2>&1 | FileCheck %s --check-prefix=WITH_CTOR_ALIASES
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.file.ignorelist -Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=FILE_IGNORELIST
 // RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=NO_PADDING
 // Try to emulate -save-temps option and make sure -disable-llvm-passes will not run sanitize instrumentation.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f16cc5d - [test] Remove -fno-experimental-new-pass-manager -O1 from sanitize-address-field-padding.cpp

2022-02-08 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2022-02-08T13:22:43-08:00
New Revision: f16cc5df2288ef4637de29cd878627967b0fee3b

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

LOG: [test] Remove -fno-experimental-new-pass-manager -O1 from 
sanitize-address-field-padding.cpp

-O1 doesn't seem necessary here.

Reviewed By: vitalybuka

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

Added: 


Modified: 
clang/test/CodeGen/sanitize-address-field-padding.cpp

Removed: 




diff  --git a/clang/test/CodeGen/sanitize-address-field-padding.cpp 
b/clang/test/CodeGen/sanitize-address-field-padding.cpp
index 67316bd97412..71d6540d3fe9 100644
--- a/clang/test/CodeGen/sanitize-address-field-padding.cpp
+++ b/clang/test/CodeGen/sanitize-address-field-padding.cpp
@@ -2,7 +2,7 @@
 // RUN: echo 'type:SomeNamespace::IgnorelistedByName=field-padding' > 
%t.type.ignorelist
 // RUN: echo 'src:*sanitize-address-field-padding.cpp=field-padding' > 
%t.file.ignorelist
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address 
-fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.type.ignorelist 
-Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address 
-fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.type.ignorelist 
-Rsanitize-address -emit-llvm -o - %s -O1 -fno-experimental-new-pass-manager 
-mconstructor-aliases 2>&1 | FileCheck %s --check-prefix=WITH_CTOR_ALIASES
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address 
-fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.type.ignorelist 
-Rsanitize-address -emit-llvm -o - %s -mconstructor-aliases 2>&1 | FileCheck %s 
--check-prefix=WITH_CTOR_ALIASES
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address 
-fsanitize-address-field-padding=1 -fsanitize-ignorelist=%t.file.ignorelist 
-Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s 
--check-prefix=FILE_IGNORELIST
 // RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - %s 2>&1 | FileCheck %s 
--check-prefix=NO_PADDING
 // Try to emulate -save-temps option and make sure -disable-llvm-passes will 
not run sanitize instrumentation.



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


[PATCH] D119257: Revert "Re-land [LLD] Remove global state in lldCommon"

2022-02-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added a comment.
This revision now requires changes to proceed.

Thanks to @aganea for working on this. I agree that lld/ELF is not ready for 
library usage. So far the arguments have always been "the library usage is easy 
since lld headers happen to be exposed", but do not justify that it should be 
done this way. Most use cases can be replaced with spawning a new process.

For lld/ELF, the library usage is unsupported and may happen to work for some 
use cases. But please move away from the library usage, or expect that it may 
break at any time, and don't use "it worked for some time for us" as an 
argument for reverts like https://reviews.llvm.org/D119257

If anything needs to be reverted, the original change adding lld::elf::link 
should be reverted instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119257

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


[PATCH] D119215: [clang] Properly cache member pointer LLVM types

2022-02-08 Thread Arthur Eubanks 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 rGf05a63f9a09b: [clang] Properly cache member pointer LLVM 
types (authored by aeubanks).

Changed prior to commit:
  https://reviews.llvm.org/D119215?vs=406908=406950#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119215

Files:
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/CodeGenTypes.h
  clang/test/CodeGenCXX/type-cache-2.cpp
  clang/test/CodeGenCXX/type-cache-3.cpp
  clang/test/CodeGenCXX/type-cache.cpp

Index: clang/test/CodeGenCXX/type-cache.cpp
===
--- clang/test/CodeGenCXX/type-cache.cpp
+++ clang/test/CodeGenCXX/type-cache.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -mllvm -verify-type-cache -emit-llvm %s -o - -triple i386-pc-windows-msvc19.16.0 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple i386-pc-windows-msvc19.16.0 | FileCheck %s
 // REQUIRES: asserts, x86-registered-target
 
 // CHECK: call {}* @"?f@@YA?AUz@@XZ"()
Index: clang/test/CodeGenCXX/type-cache-3.cpp
===
--- clang/test/CodeGenCXX/type-cache-3.cpp
+++ clang/test/CodeGenCXX/type-cache-3.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -mllvm -verify-type-cache -emit-llvm %s -o - -triple i386-pc-windows-msvc19.16.0 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple i386-pc-windows-msvc19.16.0 | FileCheck %s
 // REQUIRES: asserts, x86-registered-target
 
 // CHECK-LABEL: define {{.*}}@"?f@@YAXXZ"(
Index: clang/test/CodeGenCXX/type-cache-2.cpp
===
--- clang/test/CodeGenCXX/type-cache-2.cpp
+++ clang/test/CodeGenCXX/type-cache-2.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -mllvm -verify-type-cache -emit-llvm %s -o - -triple i386-pc-windows-msvc19.16.0 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple i386-pc-windows-msvc19.16.0 | FileCheck %s
 // REQUIRES: asserts, x86-registered-target
 
 // CHECK: call void @"?dc@z@@SAXU1@@Z"
Index: clang/lib/CodeGen/CodeGenTypes.h
===
--- clang/lib/CodeGen/CodeGenTypes.h
+++ clang/lib/CodeGen/CodeGenTypes.h
@@ -96,7 +96,7 @@
   /// corresponding llvm::Type.
   llvm::DenseMap TypeCache;
 
-  llvm::SmallSet RecordsWithOpaqueMemberPointers;
+  llvm::DenseMap RecordsWithOpaqueMemberPointers;
 
   static constexpr unsigned FunctionInfosLog2InitSize = 9;
   /// Helper for ConvertType.
Index: clang/lib/CodeGen/CodeGenTypes.cpp
===
--- clang/lib/CodeGen/CodeGenTypes.cpp
+++ clang/lib/CodeGen/CodeGenTypes.cpp
@@ -29,16 +29,6 @@
 using namespace clang;
 using namespace CodeGen;
 
-#ifndef NDEBUG
-#include "llvm/Support/CommandLine.h"
-// TODO: turn on by default when defined(EXPENSIVE_CHECKS) once check-clang is
-// -verify-type-cache clean.
-static llvm::cl::opt VerifyTypeCache(
-"verify-type-cache",
-llvm::cl::desc("Verify that the type cache matches the computed type"),
-llvm::cl::init(false), llvm::cl::Hidden);
-#endif
-
 CodeGenTypes::CodeGenTypes(CodeGenModule )
   : CGM(cgm), Context(cgm.getContext()), TheModule(cgm.getModule()),
 Target(cgm.getTarget()), TheCXXABI(cgm.getCXXABI()),
@@ -437,14 +427,12 @@
 TypeCache.find(Ty);
 if (TCI != TypeCache.end())
   CachedType = TCI->second;
-if (CachedType) {
-#ifndef NDEBUG
-  if (!VerifyTypeCache)
-return CachedType;
-#else
+  // With expensive checks, check that the type we compute matches the
+  // cached type.
+#ifndef EXPENSIVE_CHECKS
+if (CachedType)
   return CachedType;
 #endif
-}
   }
 
   // If we don't have it in the cache, convert it now.
@@ -784,8 +772,11 @@
   case Type::MemberPointer: {
 auto *MPTy = cast(Ty);
 if (!getCXXABI().isMemberPointerConvertible(MPTy)) {
-  RecordsWithOpaqueMemberPointers.insert(MPTy->getClass());
-  ResultType = llvm::StructType::create(getLLVMContext());
+  auto *C = MPTy->getClass();
+  auto Insertion = RecordsWithOpaqueMemberPointers.insert({C, nullptr});
+  if (Insertion.second)
+Insertion.first->second = llvm::StructType::create(getLLVMContext());
+  ResultType = Insertion.first->second;
 } else {
   ResultType = getCXXABI().ConvertMemberPointerType(MPTy);
 }
@@ -822,13 +813,8 @@
   }
 
   assert(ResultType && "Didn't convert a type?");
-
-#ifndef NDEBUG
-  if (CachedType) {
-assert(CachedType == ResultType &&
-   "Cached type doesn't match computed type");
-  }
-#endif
+  assert((!CachedType || CachedType == ResultType) &&
+ "Cached type doesn't match computed type");
 
   if (ShouldUseCache)
 TypeCache[Ty] = ResultType;
___
cfe-commits mailing list

[clang] f05a63f - [clang] Properly cache member pointer LLVM types

2022-02-08 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2022-02-08T13:22:24-08:00
New Revision: f05a63f9a09bdacab6a98683c5a4fc3f1f2a9149

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

LOG: [clang] Properly cache member pointer LLVM types

When not going through the main Clang->LLVM type cache, we'd
accidentally create multiple different opaque types for a member pointer
type.

This allows us to remove the -verify-type-cache flag now that
check-clang passes with it on. We can do the verification in expensive
builds. Previously microsoft-abi-member-pointers.cpp was failing with
-verify-type-cache.

I suspect that there may be more issues when we have multiple member
pointer types and we clear the cache, but we can leave that for later.

Followup to D118744.

Reviewed By: rnk

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenTypes.cpp
clang/lib/CodeGen/CodeGenTypes.h
clang/test/CodeGenCXX/type-cache-2.cpp
clang/test/CodeGenCXX/type-cache-3.cpp
clang/test/CodeGenCXX/type-cache.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenTypes.cpp 
b/clang/lib/CodeGen/CodeGenTypes.cpp
index 7a8a7c916473..33bdb6911cd1 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -29,16 +29,6 @@
 using namespace clang;
 using namespace CodeGen;
 
-#ifndef NDEBUG
-#include "llvm/Support/CommandLine.h"
-// TODO: turn on by default when defined(EXPENSIVE_CHECKS) once check-clang is
-// -verify-type-cache clean.
-static llvm::cl::opt VerifyTypeCache(
-"verify-type-cache",
-llvm::cl::desc("Verify that the type cache matches the computed type"),
-llvm::cl::init(false), llvm::cl::Hidden);
-#endif
-
 CodeGenTypes::CodeGenTypes(CodeGenModule )
   : CGM(cgm), Context(cgm.getContext()), TheModule(cgm.getModule()),
 Target(cgm.getTarget()), TheCXXABI(cgm.getCXXABI()),
@@ -437,14 +427,12 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
 TypeCache.find(Ty);
 if (TCI != TypeCache.end())
   CachedType = TCI->second;
-if (CachedType) {
-#ifndef NDEBUG
-  if (!VerifyTypeCache)
-return CachedType;
-#else
+  // With expensive checks, check that the type we compute matches the
+  // cached type.
+#ifndef EXPENSIVE_CHECKS
+if (CachedType)
   return CachedType;
 #endif
-}
   }
 
   // If we don't have it in the cache, convert it now.
@@ -784,8 +772,11 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
   case Type::MemberPointer: {
 auto *MPTy = cast(Ty);
 if (!getCXXABI().isMemberPointerConvertible(MPTy)) {
-  RecordsWithOpaqueMemberPointers.insert(MPTy->getClass());
-  ResultType = llvm::StructType::create(getLLVMContext());
+  auto *C = MPTy->getClass();
+  auto Insertion = RecordsWithOpaqueMemberPointers.insert({C, nullptr});
+  if (Insertion.second)
+Insertion.first->second = llvm::StructType::create(getLLVMContext());
+  ResultType = Insertion.first->second;
 } else {
   ResultType = getCXXABI().ConvertMemberPointerType(MPTy);
 }
@@ -822,13 +813,8 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
   }
 
   assert(ResultType && "Didn't convert a type?");
-
-#ifndef NDEBUG
-  if (CachedType) {
-assert(CachedType == ResultType &&
-   "Cached type doesn't match computed type");
-  }
-#endif
+  assert((!CachedType || CachedType == ResultType) &&
+ "Cached type doesn't match computed type");
 
   if (ShouldUseCache)
 TypeCache[Ty] = ResultType;

diff  --git a/clang/lib/CodeGen/CodeGenTypes.h 
b/clang/lib/CodeGen/CodeGenTypes.h
index 05aae88ba59e..cd20563cbf75 100644
--- a/clang/lib/CodeGen/CodeGenTypes.h
+++ b/clang/lib/CodeGen/CodeGenTypes.h
@@ -96,7 +96,7 @@ class CodeGenTypes {
   /// corresponding llvm::Type.
   llvm::DenseMap TypeCache;
 
-  llvm::SmallSet RecordsWithOpaqueMemberPointers;
+  llvm::DenseMap RecordsWithOpaqueMemberPointers;
 
   static constexpr unsigned FunctionInfosLog2InitSize = 9;
   /// Helper for ConvertType.

diff  --git a/clang/test/CodeGenCXX/type-cache-2.cpp 
b/clang/test/CodeGenCXX/type-cache-2.cpp
index bc672f795166..1f1472a0ebac 100644
--- a/clang/test/CodeGenCXX/type-cache-2.cpp
+++ b/clang/test/CodeGenCXX/type-cache-2.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -mllvm -verify-type-cache -emit-llvm %s -o - -triple 
i386-pc-windows-msvc19.16.0 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple i386-pc-windows-msvc19.16.0 | 
FileCheck %s
 // REQUIRES: asserts, x86-registered-target
 
 // CHECK: call void @"?dc@z@@SAXU1@@Z"

diff  --git a/clang/test/CodeGenCXX/type-cache-3.cpp 
b/clang/test/CodeGenCXX/type-cache-3.cpp
index 2cbb63b143de..8a9af353f58e 100644
--- a/clang/test/CodeGenCXX/type-cache-3.cpp
+++ 

[PATCH] D110869: [X86] Implement -fzero-call-used-regs option

2022-02-08 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 406948.
void added a comment.

Remove obsolete change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110869

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/zero-call-used-regs.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/zero_call_used_regs.c
  llvm/include/llvm/CodeGen/MachineRegisterInfo.h
  llvm/include/llvm/CodeGen/TargetFrameLowering.h
  llvm/include/llvm/CodeGen/TargetRegisterInfo.h
  llvm/include/llvm/Support/CodeGen.h
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/MachineRegisterInfo.cpp
  llvm/lib/CodeGen/PrologEpilogInserter.cpp
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86FrameLowering.h
  llvm/lib/Target/X86/X86RegisterInfo.cpp
  llvm/lib/Target/X86/X86RegisterInfo.h
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/test/CodeGen/X86/zero-call-used-regs-fmod.ll
  llvm/test/CodeGen/X86/zero-call-used-regs.ll
  llvm/utils/TableGen/CodeGenRegisters.cpp
  llvm/utils/TableGen/CodeGenRegisters.h
  llvm/utils/TableGen/RegisterInfoEmitter.cpp

Index: llvm/utils/TableGen/RegisterInfoEmitter.cpp
===
--- llvm/utils/TableGen/RegisterInfoEmitter.cpp
+++ llvm/utils/TableGen/RegisterInfoEmitter.cpp
@@ -1176,6 +1176,10 @@
  << "unsigned RegUnit) const override;\n"
  << "  ArrayRef getRegMaskNames() const override;\n"
  << "  ArrayRef getRegMasks() const override;\n"
+ << "  bool isGeneralPurposeRegister(const MachineFunction &, "
+ << "MCRegister) const override;\n"
+ << "  bool isFixedRegister(const MachineFunction &, "
+ << "MCRegister) const override;\n"
  << "  /// Devirtualized TargetFrameLowering.\n"
  << "  static const " << TargetName << "FrameLowering *getFrameLowering(\n"
  << "  const MachineFunction );\n"
@@ -1620,6 +1624,36 @@
   }
   OS << "}\n\n";
 
+  const std::list  =
+  RegBank.getRegCategories();
+  OS << "bool " << ClassName << "::\n"
+ << "isGeneralPurposeRegister(const MachineFunction , "
+ << "MCRegister PhysReg) const {\n"
+ << "  return\n";
+  for (const CodeGenRegisterCategory  : RegCategories)
+if (Category.getName() == "GeneralPurposeRegisters") {
+  for (const CodeGenRegisterClass *RC : Category.getClasses())
+OS << "  " << RC->getQualifiedName()
+   << "RegClass.contains(PhysReg) ||\n";
+  break;
+}
+  OS << "  false;\n";
+  OS << "}\n\n";
+
+  OS << "bool " << ClassName << "::\n"
+ << "isFixedRegister(const MachineFunction , "
+ << "MCRegister PhysReg) const {\n"
+ << "  return\n";
+  for (const CodeGenRegisterCategory  : RegCategories)
+if (Category.getName() == "FixedRegisters") {
+  for (const CodeGenRegisterClass *RC : Category.getClasses())
+OS << "  " << RC->getQualifiedName()
+   << "RegClass.contains(PhysReg) ||\n";
+  break;
+}
+  OS << "  false;\n";
+  OS << "}\n\n";
+
   OS << "ArrayRef " << ClassName
  << "::getRegMaskNames() const {\n";
   if (!CSRSets.empty()) {
Index: llvm/utils/TableGen/CodeGenRegisters.h
===
--- llvm/utils/TableGen/CodeGenRegisters.h
+++ llvm/utils/TableGen/CodeGenRegisters.h
@@ -476,6 +476,26 @@
 static void computeSubClasses(CodeGenRegBank&);
   };
 
+  // Register categories are used when we need to deterine the category a
+  // register falls into (GPR, vector, fixed, etc.) without having to know
+  // specific information about the target architecture.
+  class CodeGenRegisterCategory {
+Record *TheDef;
+std::string Name;
+std::list Classes;
+
+  public:
+CodeGenRegisterCategory(CodeGenRegBank &, Record *R);
+CodeGenRegisterCategory(CodeGenRegisterCategory &) = delete;
+
+// Return the Record that defined this class, or NULL if the class was
+// created by TableGen.
+Record *getDef() const { return TheDef; }
+
+std::string getName() const { return Name; }
+std::list getClasses() const { return Classes; }
+  };
+
   // Register units are used to model interference and register pressure.
   // Every register is assigned one or more register units such that two
   // registers overlap if and only if they have a register unit in common.
@@ -559,6 +579,13 @@
 typedef std::map RCKeyMap;
 RCKeyMap Key2RC;
 
+// Register categories.
+std::list RegCategories;
+DenseMap Def2RCat;
+using RCatKeyMap =
+std::map;
+RCatKeyMap Key2RCat;
+
 // Remember each unique set of register units. Initially, this contains a
 // 

[PATCH] D118199: [AArch64] ACLE feature macro for Armv8.8-A MOPS

2022-02-08 Thread Son Tuan Vu 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 rGd379ec99085e: [AArch64] ACLE feature macro for Armv8.8-A 
MOPS (authored by tyb0807).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118199

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/test/CodeGen/aarch64-mops.c
  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
@@ -510,9 +510,21 @@
 // CHECK-NO-SVE-VECTOR-BITS-NOT: __ARM_FEATURE_SVE_BITS
 // CHECK-NO-SVE-VECTOR-BITS-NOT: __ARM_FEATURE_SVE_VECTOR_OPERATORS
 
-// == Check Largse System Extensions (LSE)
+// == Check Large System Extensions (LSE)
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+lse -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+lse -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // CHECK-LSE: __ARM_FEATURE_ATOMICS 1
+
+// == Check Armv8.8-A/Armv9.3-A memcpy and memset acceleration instructions (MOPS)
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// CHECK-MOPS: __ARM_FEATURE_MOPS 1
+// CHECK-NOMOPS-NOT: __ARM_FEATURE_MOPS 1
Index: clang/test/CodeGen/aarch64-mops.c
===
--- clang/test/CodeGen/aarch64-mops.c
+++ clang/test/CodeGen/aarch64-mops.c
@@ -1,8 +1,18 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 
 // RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops -target-feature +mte -S -emit-llvm -o - %s  | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -verify %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a+mops+memtag  -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+memtag   -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a+mops+memtag  -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a+memtag   -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a  -Xclang -verify -S -emit-llvm %s -o -
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a+mops -Xclang -verify -S -emit-llvm %s -o -
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a  -Xclang -verify -S -emit-llvm %s -o -
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a  -Xclang -verify -S -emit-llvm %s -o -
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a+mops -Xclang -verify -S -emit-llvm %s -o -
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a  -Xclang -verify -S -emit-llvm %s -o -
 
-#define __ARM_FEATURE_MOPS 1
 #include 
 #include 
 
@@ -13,9 +23,9 @@
 // CHECK-NEXT:[[TMP0:%.*]] = load i8*, i8** [[DST_ADDR]], align 8
 // CHECK-NEXT:[[TMP1:%.*]] = call i8* @llvm.aarch64.mops.memset.tag(i8* [[TMP0]], i8 0, i64 0)
 // CHECK-NEXT:ret i8* [[TMP1]]
-//
 void *bzero_0(void *dst) {
-  return __arm_mops_memset_tag(dst, 0, 0);
+  // expected-warning@+1 {{incompatible integer to pointer conversion returning 'int' from a function with result type 'void *'}}
+  return __arm_mops_memset_tag(dst, 0, 0); // expected-warning{{implicit declaration of function '__arm_mops_memset_tag' is invalid in C99}}
 }
 
 // CHECK-LABEL: 

[clang] d379ec9 - [AArch64] ACLE feature macro for Armv8.8-A MOPS

2022-02-08 Thread via cfe-commits

Author: tyb0807
Date: 2022-02-08T21:07:49Z
New Revision: d379ec99085e33ace51740f2b93bda5e5c72326f

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

LOG: [AArch64] ACLE feature macro for Armv8.8-A MOPS

This introduces the new __ARM_FEATURE_MOPS ACLE feature test macro,
which signals the availability of the new Armv8.8-A/Armv9.3-A
instructions for standardising memcpy, memset and memmove operations.

This patch supersedes the one from https://reviews.llvm.org/D116160.

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

Added: 


Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/test/CodeGen/aarch64-mops.c
clang/test/Preprocessor/aarch64-target-features.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 34bdb58dffc1c..b04508570ad75 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -226,6 +226,8 @@ void AArch64TargetInfo::getTargetDefinesARMV87A(const 
LangOptions ,
 
 void AArch64TargetInfo::getTargetDefinesARMV88A(const LangOptions ,
 MacroBuilder ) const {
+  // FIXME: this does not handle the case where MOPS is disabled using +nomops
+  Builder.defineMacro("__ARM_FEATURE_MOPS", "1");
   // Also include the Armv8.7 defines
   getTargetDefinesARMV87A(Opts, Builder);
 }
@@ -435,6 +437,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
,
   if (HasRandGen)
 Builder.defineMacro("__ARM_FEATURE_RNG", "1");
 
+  if (HasMOPS)
+Builder.defineMacro("__ARM_FEATURE_MOPS", "1");
+
   switch (ArchKind) {
   default:
 break;
@@ -662,6 +667,8 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector ,
   HasFlagM = true;
 if (Feature == "+hbc")
   HasHBC = true;
+if (Feature == "+mops")
+  HasMOPS = true;
   }
 
   setDataLayout();

diff  --git a/clang/test/CodeGen/aarch64-mops.c 
b/clang/test/CodeGen/aarch64-mops.c
index 0b6a2c26c1e82..9a19d4202bcc2 100644
--- a/clang/test/CodeGen/aarch64-mops.c
+++ b/clang/test/CodeGen/aarch64-mops.c
@@ -1,8 +1,18 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 
 // RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops 
-target-feature +mte -S -emit-llvm -o - %s  | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -verify %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a+mops+memtag  
-S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+memtag   
-S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a+mops+memtag  
-S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a+memtag   
-S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a  -Xclang 
-verify -S -emit-llvm %s -o -
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a+mops -Xclang 
-verify -S -emit-llvm %s -o -
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a  -Xclang 
-verify -S -emit-llvm %s -o -
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a  -Xclang 
-verify -S -emit-llvm %s -o -
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a+mops -Xclang 
-verify -S -emit-llvm %s -o -
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a  -Xclang 
-verify -S -emit-llvm %s -o -
 
-#define __ARM_FEATURE_MOPS 1
 #include 
 #include 
 
@@ -13,9 +23,9 @@
 // CHECK-NEXT:[[TMP0:%.*]] = load i8*, i8** [[DST_ADDR]], align 8
 // CHECK-NEXT:[[TMP1:%.*]] = call i8* @llvm.aarch64.mops.memset.tag(i8* 
[[TMP0]], i8 0, i64 0)
 // CHECK-NEXT:ret i8* [[TMP1]]
-//
 void *bzero_0(void *dst) {
-  return __arm_mops_memset_tag(dst, 0, 0);
+  // expected-warning@+1 {{incompatible integer to pointer conversion 
returning 'int' from a function with result type 'void *'}}
+  return __arm_mops_memset_tag(dst, 0, 0); // expected-warning{{implicit 
declaration of function '__arm_mops_memset_tag' is invalid in C99}}
 }
 
 // CHECK-LABEL: @bzero_1(
@@ -25,9 +35,9 @@ void *bzero_0(void *dst) {
 // CHECK-NEXT:[[TMP0:%.*]] = load i8*, i8** [[DST_ADDR]], align 8
 // CHECK-NEXT:[[TMP1:%.*]] = call i8* @llvm.aarch64.mops.memset.tag(i8* 
[[TMP0]], i8 0, i64 1)
 // CHECK-NEXT:ret i8* [[TMP1]]
-//
 void *bzero_1(void *dst) {
-  return __arm_mops_memset_tag(dst, 0, 1);
+  // expected-warning@+1 {{incompatible integer to pointer conversion 
returning 'int' from a function with result type 'void *'}}
+  return __arm_mops_memset_tag(dst, 0, 1); // expected-warning{{implicit 
declaration of function '__arm_mops_memset_tag' is invalid in 

[PATCH] D119257: Revert "Re-land [LLD] Remove global state in lldCommon"

2022-02-08 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

All things considered I think in the short term it is better to aim for small 
patches/fixes that can be transplanted to `release/14.x` if need be. I've 
posted D119277  for the issue you were seeing 
@krzysz00, but I am still planning on proper fix over the next week or so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119257

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


[clang] f2c2e92 - Fix a typo (occured => occurred)

2022-02-08 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2022-02-08T21:35:26+01:00
New Revision: f2c2e924e73a76562b7cc6d8fd96df5b177eaf18

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

LOG: Fix a typo (occured => occurred)

Reported:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1005195

Added: 


Modified: 
clang/include/clang-c/Index.h
clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/Specifiers.h
clang/include/clang/CrossTU/CrossTranslationUnit.h
clang/include/clang/Format/Format.h
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/StaticAnalyzer/Core/RegionStore.cpp
clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
llvm/include/llvm/CodeGen/ISDOpcodes.h
llvm/include/llvm/Support/MathExtras.h
llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
llvm/lib/TableGen/TGLexer.h
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/test/Transforms/LowerConstantIntrinsics/stale-worklist-phi.ll
llvm/utils/reduce_pipeline_test/fake_opt.py

Removed: 




diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index b0d7ef509c26f..ea44673a3f1ea 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -3900,7 +3900,7 @@ enum CXTypeNullabilityKind {
   /**
* Generally behaves like Nullable, except when used in a block parameter 
that
* was imported into a swift async method. There, swift will assume that the
-   * parameter can get null even if no error occured. _Nullable parameters are
+   * parameter can get null even if no error occurred. _Nullable parameters are
* assumed to only get null on error.
*/
   CXTypeNullability_NullableResult = 4

diff  --git a/clang/include/clang/Analysis/Analyses/CalledOnceCheck.h 
b/clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
index 6d78fa4a897ad..b65a3967cd50d 100644
--- a/clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
+++ b/clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
@@ -79,7 +79,7 @@ class CalledOnceCheckHandler {
   /// the path containing the call and not containing the call.  This helps us
   /// to pinpoint a bad path for the user.
   /// \param Parameter -- parameter that should be called once.
-  /// \param Function -- function declaration where the problem occured.
+  /// \param Function -- function declaration where the problem occurred.
   /// \param Where -- the least common ancestor statement.
   /// \param Reason -- a reason describing the path without a call.
   /// \param IsCalledDirectly -- true, if parameter actually gets called on

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 1682a71eb992e..74ee5f84dfa85 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -3816,10 +3816,10 @@ completion handler in a Swift async method. For 
instance, here:
 This method asynchronously calls ``completionHandler`` when the data is
 available, or calls it with an error. ``_Nullable_result`` indicates to the
 Swift importer that this is the uncommon case where ``result`` can get ``nil``
-even if no error has occured, and will therefore import it as a Swift optional
+even if no error has occurred, and will therefore import it as a Swift optional
 type. Otherwise, if ``result`` was annotated with ``_Nullable``, the Swift
 importer will assume that ``result`` will always be non-nil unless an error
-occured.
+occurred.
 }];
 }
 

diff  --git a/clang/include/clang/Basic/Specifiers.h 
b/clang/include/clang/Basic/Specifiers.h
index 82b3c1f3c2740..52ca7cce9d961 100644
--- a/clang/include/clang/Basic/Specifiers.h
+++ b/clang/include/clang/Basic/Specifiers.h
@@ -324,7 +324,7 @@ namespace clang {
 Unspecified,
 // Generally behaves like Nullable, except when used in a block parameter
 // that was imported into a swift async method. There, swift will assume
-// that the parameter can get null even if no error occured. _Nullable
+// that the parameter can get null even if no error occurred. _Nullable
 // parameters are assumed to only get null on error.
 NullableResult,
   };

diff  --git a/clang/include/clang/CrossTU/CrossTranslationUnit.h 
b/clang/include/clang/CrossTU/CrossTranslationUnit.h
index d9f9c51fccd9c..a09826f93afc0 100644
--- a/clang/include/clang/CrossTU/CrossTranslationUnit.h
+++ b/clang/include/clang/CrossTU/CrossTranslationUnit.h
@@ -291,7 +291,7 @@ class CrossTranslationUnitContext {
 /// \param DisplayCTUProgress Display a message about loading new ASTs.
 ///
 /// \return An Expected instance which 

[PATCH] D118428: [clang-cl] Support the /JMC flag

2022-02-08 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 406927.
ychen marked an inline comment as done.
ychen added a comment.

- address feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118428

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-options.c
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/CodeGen/Passes.h
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/LinkAllPasses.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/CodeGen.cpp
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/CodeGen/JMCInstrumenter.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/test/CodeGen/X86/jmc-instrument.ll
  llvm/test/Instrumentation/JustMyCode/jmc-instrument-x86.ll
  llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -498,7 +498,8 @@
   "generic-to-nvvm",  "expandmemcmp",
   "loop-reduce",  "lower-amx-type",
   "pre-amx-config",   "lower-amx-intrinsics",
-  "polyhedral-info",  "replace-with-veclib"};
+  "polyhedral-info",  "replace-with-veclib",
+  "jmc-instrument"};
   for (const auto  : PassNamePrefix)
 if (Pass.startswith(P))
   return true;
@@ -572,6 +573,7 @@
   initializeHardwareLoopsPass(Registry);
   initializeTypePromotionPass(Registry);
   initializeReplaceWithVeclibLegacyPass(Registry);
+  initializeJMCInstrumenterPass(Registry);
 
 #ifdef BUILD_EXAMPLES
   initializeExampleIRTransforms(Registry);
Index: llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll
@@ -0,0 +1,120 @@
+; RUN: opt -jmc-instrument -mtriple=x86_64-pc-windows-msvc  -S < %s | FileCheck %s
+; RUN: opt -jmc-instrument -mtriple=aarch64-pc-windows-msvc -S < %s | FileCheck %s
+; RUN: opt -jmc-instrument -mtriple=arm-pc-windows-msvc -S < %s | FileCheck %s
+
+; CHECK: $__JustMyCode_Default = comdat any
+
+; CHECK: @"__7DF23CF5_x@c" = internal unnamed_addr global i8 1, section ".msvcjmc", align 1, !dbg !0
+; CHECK: @"__A85D9D03_x@c" = internal unnamed_addr global i8 1, section ".msvcjmc", align 1, !dbg !5
+; CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (void (i8*)* @__JustMyCode_Default to i8*)], section "llvm.metadata"
+
+; CHECK: define void @l1() !dbg !13 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__7DF23CF5_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @l2() !dbg !17 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__7DF23CF5_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @w1() !dbg !19 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @w2() !dbg !20 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @w3() !dbg !22 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @w4() !dbg !24 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: declare void @__CheckForDebuggerJustMyCode(i8* noundef) unnamed_addr
+
+; CHECK: define void @__JustMyCode_Default(i8* noundef %0) unnamed_addr comdat {
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: !llvm.linker.options = !{!12}
+
+; CHECK: !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+; CHECK: !1 = distinct !DIGlobalVariable(name: "__7DF23CF5_x@c", scope: !2, file: !3, type: !8, isLocal: true, isDefinition: true)
+; CHECK: !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
+; CHECK: !3 = !DIFile(filename: "a/x.c", directory: "/tmp")
+; CHECK: !4 = !{!0, !5}
+; CHECK: !5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
+; CHECK: !6 = distinct !DIGlobalVariable(name: "__A85D9D03_x@c", scope: !2, file: !7, type: !8, isLocal: true, isDefinition: true)
+; CHECK: !7 = !DIFile(filename: "./x.c", directory: "C:ab")
+; CHECK: !8 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char, flags: DIFlagArtificial)
+; CHECK: !9 = !{i32 2, !"CodeView", i32 1}
+; CHECK: !10 = !{i32 2, 

[PATCH] D110869: [X86] Implement -fzero-call-used-regs option

2022-02-08 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 406924.
void added a comment.

Move register clearning to after the "pop"s.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110869

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/zero-call-used-regs.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/zero_call_used_regs.c
  llvm/include/llvm/CodeGen/MachineRegisterInfo.h
  llvm/include/llvm/CodeGen/TargetFrameLowering.h
  llvm/include/llvm/CodeGen/TargetRegisterInfo.h
  llvm/include/llvm/Support/CodeGen.h
  llvm/include/llvm/Target/Target.td
  llvm/lib/CodeGen/MachineRegisterInfo.cpp
  llvm/lib/CodeGen/PrologEpilogInserter.cpp
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86FrameLowering.h
  llvm/lib/Target/X86/X86RegisterInfo.cpp
  llvm/lib/Target/X86/X86RegisterInfo.h
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/test/CodeGen/X86/zero-call-used-regs-fmod.ll
  llvm/test/CodeGen/X86/zero-call-used-regs.ll
  llvm/utils/TableGen/CodeGenRegisters.cpp
  llvm/utils/TableGen/CodeGenRegisters.h
  llvm/utils/TableGen/RegisterInfoEmitter.cpp

Index: llvm/utils/TableGen/RegisterInfoEmitter.cpp
===
--- llvm/utils/TableGen/RegisterInfoEmitter.cpp
+++ llvm/utils/TableGen/RegisterInfoEmitter.cpp
@@ -1176,6 +1176,10 @@
  << "unsigned RegUnit) const override;\n"
  << "  ArrayRef getRegMaskNames() const override;\n"
  << "  ArrayRef getRegMasks() const override;\n"
+ << "  bool isGeneralPurposeRegister(const MachineFunction &, "
+ << "MCRegister) const override;\n"
+ << "  bool isFixedRegister(const MachineFunction &, "
+ << "MCRegister) const override;\n"
  << "  /// Devirtualized TargetFrameLowering.\n"
  << "  static const " << TargetName << "FrameLowering *getFrameLowering(\n"
  << "  const MachineFunction );\n"
@@ -1620,6 +1624,36 @@
   }
   OS << "}\n\n";
 
+  const std::list  =
+  RegBank.getRegCategories();
+  OS << "bool " << ClassName << "::\n"
+ << "isGeneralPurposeRegister(const MachineFunction , "
+ << "MCRegister PhysReg) const {\n"
+ << "  return\n";
+  for (const CodeGenRegisterCategory  : RegCategories)
+if (Category.getName() == "GeneralPurposeRegisters") {
+  for (const CodeGenRegisterClass *RC : Category.getClasses())
+OS << "  " << RC->getQualifiedName()
+   << "RegClass.contains(PhysReg) ||\n";
+  break;
+}
+  OS << "  false;\n";
+  OS << "}\n\n";
+
+  OS << "bool " << ClassName << "::\n"
+ << "isFixedRegister(const MachineFunction , "
+ << "MCRegister PhysReg) const {\n"
+ << "  return\n";
+  for (const CodeGenRegisterCategory  : RegCategories)
+if (Category.getName() == "FixedRegisters") {
+  for (const CodeGenRegisterClass *RC : Category.getClasses())
+OS << "  " << RC->getQualifiedName()
+   << "RegClass.contains(PhysReg) ||\n";
+  break;
+}
+  OS << "  false;\n";
+  OS << "}\n\n";
+
   OS << "ArrayRef " << ClassName
  << "::getRegMaskNames() const {\n";
   if (!CSRSets.empty()) {
Index: llvm/utils/TableGen/CodeGenRegisters.h
===
--- llvm/utils/TableGen/CodeGenRegisters.h
+++ llvm/utils/TableGen/CodeGenRegisters.h
@@ -476,6 +476,26 @@
 static void computeSubClasses(CodeGenRegBank&);
   };
 
+  // Register categories are used when we need to deterine the category a
+  // register falls into (GPR, vector, fixed, etc.) without having to know
+  // specific information about the target architecture.
+  class CodeGenRegisterCategory {
+Record *TheDef;
+std::string Name;
+std::list Classes;
+
+  public:
+CodeGenRegisterCategory(CodeGenRegBank &, Record *R);
+CodeGenRegisterCategory(CodeGenRegisterCategory &) = delete;
+
+// Return the Record that defined this class, or NULL if the class was
+// created by TableGen.
+Record *getDef() const { return TheDef; }
+
+std::string getName() const { return Name; }
+std::list getClasses() const { return Classes; }
+  };
+
   // Register units are used to model interference and register pressure.
   // Every register is assigned one or more register units such that two
   // registers overlap if and only if they have a register unit in common.
@@ -559,6 +579,13 @@
 typedef std::map RCKeyMap;
 RCKeyMap Key2RC;
 
+// Register categories.
+std::list RegCategories;
+DenseMap Def2RCat;
+using RCatKeyMap =
+std::map;
+RCatKeyMap Key2RCat;
+
 // Remember each unique set of register units. Initially, 

[PATCH] D110869: [X86] Implement -fzero-call-used-regs option

2022-02-08 Thread Bill Wendling via Phabricator via cfe-commits
void added inline comments.



Comment at: llvm/lib/Target/X86/X86FrameLowering.cpp:595
+continue;
+  XorOp = X86::PXORrr;
+} else if (X86::VR256RegClass.contains(Reg)) {

nickdesaulniers wrote:
> void wrote:
> > nickdesaulniers wrote:
> > > Is there any way to figure the `XorOp` outside of this loop? Seems 
> > > unfortunate to repeatedly scan almost every register class for every used 
> > > register.
> > > 
> > > Like instead of querying each register set whether a given register is in 
> > > it, is it possible to ask a register what register class it's in? Or can 
> > > a register belong to more than one register class?
> > There's a function in TRI that you can call to grab the RegClass of a 
> > register, but it calls a "`contains`" on each register class to see if it 
> > belongs in it, so it would be worse than this code.
> > 
> > In practice, the register classes won't have many members in it. It sucks, 
> > but it's probably something like `16*16` in a worst case scenario.
> > 
> > (I think registers can belong to multiple register classes (e.g. sub- and 
> > super-classes), but I don't quote me on that.)
> Right, I just get a sinking feeling that we're going to repeatedly scan these 
> RegClass lists for every MachineFunction, when the answer doesn't change; we 
> should eventually be able to map these O(1).
That could be a separate change, since it's incidental to this feature. We 
could create a map of this information, which should help performance a lot.



Comment at: llvm/lib/Target/X86/X86RegisterInfo.cpp:629-633
+  if (!ST.is64Bit())
+return llvm::any_of(
+   SmallVector{X86::EAX, X86::ECX, X86::EDX},
+   [&](MCRegister ) { return IsSubReg(RegA, Reg); }) ||
+   (ST.hasMMX() && X86::VR64RegClass.contains(Reg));

nickdesaulniers wrote:
> Do we need to clear stack slots for i386?
> 
> The Linux kernel uses `-mreg-param=3` to use a faster, though custom calling 
> convention. This corresponds to the `inreg` parameter attribute in LLVM IR.
> 
> Otherwise, perhaps a todo and diagnose `-m32` in the front end?
Clearing stack slots for i386 isn't done by GCC 
(https://godbolt.org/z/af8e61d3q). I think we can omit doing that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110869

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


[PATCH] D118428: [clang-cl] Support the /JMC flag

2022-02-08 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen marked an inline comment as done.
ychen added inline comments.



Comment at: llvm/lib/CodeGen/JMCInstrumenter.cpp:180
+ "JMC instrument more than once?");
+  FunctionCallee Fn =
+  M.getOrInsertFunction(CheckFunctionName, getCheckFunctionType(Ctx));

hans wrote:
> might as well get the Function* already here?
> 
> ```
> CheckFunction = cast(M.getOrInsertFunction(...).getCallee());
> ```
sounds good.



Comment at: llvm/lib/CodeGen/TargetPassConfig.cpp:1096
+  if (TM->Options.JMCInstrument)
+addPass(createJMCInstrumenterPass());
   addCodeGenPrepare();

hans wrote:
> could this be moved into addIRPasses()?
Yes, it could. `CFGuardCheckPass` is there for targets with COFF. I didn't put 
it there because I plan to make it work with ELF in the next step, putting it 
here is convenient. I don't feel strongly though.



Comment at: llvm/test/CodeGen/X86/jmc-instrument.ll:2
+; Check that the flag symbol is not full-qualified.
+; RUN: llc < %s -enable-jmc-instrument | FileCheck %s
+

hans wrote:
> hans wrote:
> > Since it's an IR pass, I think we don't need to have an llc test at all.
> I still think it's unusual to have an llc test for an IR pass. Are there any 
> other examples where we do something similar?
yes, it is pretty rare. I wanted to test the `CodeViewDebug.cpp` change, 
however, the code path only triggers when the JMC pass is run. Using `llc` came 
to mind. I'm open to any alternative.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118428

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


[PATCH] D119231: [clang][lex][minimizer] Ensure whitespace between squashed lines

2022-02-08 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LG, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119231

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


[PATCH] D119271: CGCall: also emit LLVM `allocalign` attribute when handling AllocAlign

2022-02-08 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang/test/CodeGen/alloc-align-attr.c:14
 // CHECK-NEXT:[[CASTED_ALIGN:%.*]] = zext i32 [[TMP0]] to i64
 // CHECK-NEXT:call void @llvm.assume(i1 true) [ "align"(i32* [[CALL]], i64 
[[CASTED_ALIGN]]) ]
 // CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* [[CALL]], align 4

now this llvm.assume is redudant and should be removed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119271

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


[PATCH] D119234: [clang] [MinGW] Recognize -lcrtdll as a library replacing -lmsvcrt

2022-02-08 Thread Martin Storsjö 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 rG079b6d02d1f5: [clang] [MinGW] Recognize -lcrtdll as a 
library replacing -lmsvcrt (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119234

Files:
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/test/Driver/mingw-msvcrt.c


Index: clang/test/Driver/mingw-msvcrt.c
===
--- clang/test/Driver/mingw-msvcrt.c
+++ clang/test/Driver/mingw-msvcrt.c
@@ -2,6 +2,7 @@
 // RUN: %clang -v -target i686-pc-windows-gnu -lmsvcr120 -### %s 2>&1 | 
FileCheck -check-prefix=CHECK_MSVCR120 %s
 // RUN: %clang -v -target i686-pc-windows-gnu -lucrtbase -### %s 2>&1 | 
FileCheck -check-prefix=CHECK_UCRTBASE %s
 // RUN: %clang -v -target i686-pc-windows-gnu -lucrt -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_UCRT %s
+// RUN: %clang -v -target i686-pc-windows-gnu -lcrtdll -### %s 2>&1 | 
FileCheck -check-prefix=CHECK_CRTDLL %s
 
 // CHECK_DEFAULT: "-lmingwex" "-lmsvcrt" "-ladvapi32"
 // CHECK_DEFAULT-SAME: "-lmsvcrt" "-lkernel32" "{{.*}}crtend.o"
@@ -11,3 +12,5 @@
 // CHECK_UCRTBASE-SAME: "-lmingwex" "-ladvapi32"
 // CHECK_UCRT: "-lucrt"
 // CHECK_UCRT-SAME: "-lmingwex" "-ladvapi32"
+// CHECK_CRTDLL: "-lcrtdll"
+// CHECK_CRTDLL-SAME: "-lmingwex" "-ladvapi32"
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -86,7 +86,9 @@
   CmdArgs.push_back("-lmoldname");
   CmdArgs.push_back("-lmingwex");
   for (auto Lib : Args.getAllArgValues(options::OPT_l))
-if (StringRef(Lib).startswith("msvcr") || 
StringRef(Lib).startswith("ucrt"))
+if (StringRef(Lib).startswith("msvcr") ||
+StringRef(Lib).startswith("ucrt") ||
+StringRef(Lib).startswith("crtdll"))
   return;
   CmdArgs.push_back("-lmsvcrt");
 }


Index: clang/test/Driver/mingw-msvcrt.c
===
--- clang/test/Driver/mingw-msvcrt.c
+++ clang/test/Driver/mingw-msvcrt.c
@@ -2,6 +2,7 @@
 // RUN: %clang -v -target i686-pc-windows-gnu -lmsvcr120 -### %s 2>&1 | FileCheck -check-prefix=CHECK_MSVCR120 %s
 // RUN: %clang -v -target i686-pc-windows-gnu -lucrtbase -### %s 2>&1 | FileCheck -check-prefix=CHECK_UCRTBASE %s
 // RUN: %clang -v -target i686-pc-windows-gnu -lucrt -### %s 2>&1 | FileCheck -check-prefix=CHECK_UCRT %s
+// RUN: %clang -v -target i686-pc-windows-gnu -lcrtdll -### %s 2>&1 | FileCheck -check-prefix=CHECK_CRTDLL %s
 
 // CHECK_DEFAULT: "-lmingwex" "-lmsvcrt" "-ladvapi32"
 // CHECK_DEFAULT-SAME: "-lmsvcrt" "-lkernel32" "{{.*}}crtend.o"
@@ -11,3 +12,5 @@
 // CHECK_UCRTBASE-SAME: "-lmingwex" "-ladvapi32"
 // CHECK_UCRT: "-lucrt"
 // CHECK_UCRT-SAME: "-lmingwex" "-ladvapi32"
+// CHECK_CRTDLL: "-lcrtdll"
+// CHECK_CRTDLL-SAME: "-lmingwex" "-ladvapi32"
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -86,7 +86,9 @@
   CmdArgs.push_back("-lmoldname");
   CmdArgs.push_back("-lmingwex");
   for (auto Lib : Args.getAllArgValues(options::OPT_l))
-if (StringRef(Lib).startswith("msvcr") || StringRef(Lib).startswith("ucrt"))
+if (StringRef(Lib).startswith("msvcr") ||
+StringRef(Lib).startswith("ucrt") ||
+StringRef(Lib).startswith("crtdll"))
   return;
   CmdArgs.push_back("-lmsvcrt");
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 079b6d0 - [clang] [MinGW] Recognize -lcrtdll as a library replacing -lmsvcrt

2022-02-08 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2022-02-08T21:57:07+02:00
New Revision: 079b6d02d1f52301e2d3276fadba822bf87b75b2

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

LOG: [clang] [MinGW] Recognize -lcrtdll as a library replacing -lmsvcrt

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/MinGW.cpp
clang/test/Driver/mingw-msvcrt.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MinGW.cpp 
b/clang/lib/Driver/ToolChains/MinGW.cpp
index 0501f9737404..ceeaa79bc202 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -86,7 +86,9 @@ void tools::MinGW::Linker::AddLibGCC(const ArgList ,
   CmdArgs.push_back("-lmoldname");
   CmdArgs.push_back("-lmingwex");
   for (auto Lib : Args.getAllArgValues(options::OPT_l))
-if (StringRef(Lib).startswith("msvcr") || 
StringRef(Lib).startswith("ucrt"))
+if (StringRef(Lib).startswith("msvcr") ||
+StringRef(Lib).startswith("ucrt") ||
+StringRef(Lib).startswith("crtdll"))
   return;
   CmdArgs.push_back("-lmsvcrt");
 }

diff  --git a/clang/test/Driver/mingw-msvcrt.c 
b/clang/test/Driver/mingw-msvcrt.c
index bb4813ca33a5..48a30d8469cb 100644
--- a/clang/test/Driver/mingw-msvcrt.c
+++ b/clang/test/Driver/mingw-msvcrt.c
@@ -2,6 +2,7 @@
 // RUN: %clang -v -target i686-pc-windows-gnu -lmsvcr120 -### %s 2>&1 | 
FileCheck -check-prefix=CHECK_MSVCR120 %s
 // RUN: %clang -v -target i686-pc-windows-gnu -lucrtbase -### %s 2>&1 | 
FileCheck -check-prefix=CHECK_UCRTBASE %s
 // RUN: %clang -v -target i686-pc-windows-gnu -lucrt -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_UCRT %s
+// RUN: %clang -v -target i686-pc-windows-gnu -lcrtdll -### %s 2>&1 | 
FileCheck -check-prefix=CHECK_CRTDLL %s
 
 // CHECK_DEFAULT: "-lmingwex" "-lmsvcrt" "-ladvapi32"
 // CHECK_DEFAULT-SAME: "-lmsvcrt" "-lkernel32" "{{.*}}crtend.o"
@@ -11,3 +12,5 @@
 // CHECK_UCRTBASE-SAME: "-lmingwex" "-ladvapi32"
 // CHECK_UCRT: "-lucrt"
 // CHECK_UCRT-SAME: "-lmingwex" "-ladvapi32"
+// CHECK_CRTDLL: "-lcrtdll"
+// CHECK_CRTDLL-SAME: "-lmingwex" "-ladvapi32"



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


[PATCH] D119271: CGCall: also emit LLVM `allocalign` attribute when handling AllocAlign

2022-02-08 Thread Augie Fackler via Phabricator via cfe-commits
durin42 created this revision.
Herald added a subscriber: jdoerfert.
durin42 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

LLVM is growing knowledge of this, so we should inform it when we have
the information available.

Depends on D118263 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119271

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/alloc-align-attr.c
  clang/test/CodeGen/alloc-fns-alignment.c
  clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
  clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
  clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
  clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp

Index: clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
===
--- clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
+++ clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
@@ -27,10 +27,10 @@
 struct OVERALIGNED A { A(); int n[128]; };
 
 // CHECK-LABEL: define {{.*}} @_Z2a0v()
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 i8* @_ZnwmSt11align_val_t(i64 noundef 512, i64 noundef 32)
+// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 i8* @_ZnwmSt11align_val_t(i64 noundef 512, i64 allocalign noundef 32)
 // CHECK: call void @_ZdlPvSt11align_val_t(i8* noundef %[[ALLOC]], i64 noundef 32)
 // CHECK-MS-LABEL: define {{.*}} @"?a0@@YAPEAXXZ"()
-// CHECK-MS: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 i8* @"??2@YAPEAX_KW4align_val_t@std@@@Z"(i64 noundef 512, i64 noundef 32)
+// CHECK-MS: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 i8* @"??2@YAPEAX_KW4align_val_t@std@@@Z"(i64 noundef 512, i64 allocalign noundef 32)
 // CHECK-MS: cleanuppad
 // CHECK-MS: call void @"??3@YAXPEAXW4align_val_t@std@@@Z"(i8* noundef %[[ALLOC]], i64 noundef 32)
 void *a0() { return new A; }
@@ -39,13 +39,13 @@
 // The size is known.
 //
 // CHECK-LABEL: define {{.*}} @_Z2a1l(
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 i8* @_ZnamSt11align_val_t(i64 noundef %{{.*}}, i64 noundef 32)
+// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 i8* @_ZnamSt11align_val_t(i64 noundef %{{.*}}, i64 allocalign noundef 32)
 // No array cookie.
 // CHECK-NOT: store
 // CHECK: invoke void @_ZN1AC1Ev(
 // CHECK: call void @_ZdaPvSt11align_val_t(i8* noundef %[[ALLOC]], i64 noundef 32)
 // CHECK-MS-LABEL: define {{.*}} @"?a1@@YAPEAXJ@Z"(
-// CHECK-MS: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 i8* @"??_U@YAPEAX_KW4align_val_t@std@@@Z"(i64 noundef %{{.*}}, i64 noundef 32)
+// CHECK-MS: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 i8* @"??_U@YAPEAX_KW4align_val_t@std@@@Z"(i64 noundef %{{.*}}, i64 allocalign noundef 32)
 // No array cookie.
 // CHECK-MS-NOT: store
 // CHECK-MS: invoke noundef %struct.A* @"??0A@@QEAA@XZ"(
@@ -84,7 +84,7 @@
 void *b0() { return new B; }
 
 // CHECK-LABEL: define {{.*}} @_Z2b1l(
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 i8* @_ZnamSt11align_val_t(i64 noundef %{{.*}}, i64 noundef 32)
+// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 32 i8* @_ZnamSt11align_val_t(i64 noundef %{{.*}}, i64 allocalign noundef 32)
 // No array cookie.
 // CHECK-NOT: store
 // CHECK: invoke void @_ZN1BC1Ev(
@@ -169,7 +169,7 @@
 
 #ifndef UNALIGNED
 // CHECK-LABEL: define {{.*}} @_Z2e0v(
-// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 4 i8* @_ZnwmSt11align_val_t(i64 noundef 512, i64 noundef 4)
+// CHECK: %[[ALLOC:.*]] = call noalias noundef nonnull align 4 i8* @_ZnwmSt11align_val_t(i64 noundef 512, i64 allocalign noundef 4)
 // CHECK: call void @_ZdlPvSt11align_val_t(i8* noundef %[[ALLOC]], i64 noundef 4)
 void *e0() { return new (std::align_val_t(4)) A; }
 
Index: clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
===
--- clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
+++ clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
@@ -47,7 +47,7 @@
 
 // CHECK-LABEL: define{{.*}} void @test_aligned_alloc(
 extern "C" void test_aligned_alloc() {
-  // CHECK: call noalias noundef nonnull align 4 i8* @_ZnwmSt11align_val_t(i64 noundef 4, i64 noundef 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
+  // CHECK: call noalias noundef nonnull align 4 i8* @_ZnwmSt11align_val_t(i64 noundef 4, i64 allocalign noundef 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
   // CHECK: call void @_ZdlPvSt11align_val_t({{.*}}, i64 noundef 4) [[ATTR_BUILTIN_DELETE:#[^ ]*]]
   __builtin_operator_delete(__builtin_operator_new(4, std::align_val_t(4)), std::align_val_t(4));
 }
Index: clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
===

[PATCH] D119215: [clang] Properly cache member pointer LLVM types

2022-02-08 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk 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/D119215/new/

https://reviews.llvm.org/D119215

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


[PATCH] D118804: Revert "[Clang] Propagate guaranteed alignment for malloc and others"

2022-02-08 Thread James Y Knight 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 rG9545976ff160: Revert [Clang] Propagate guaranteed 
alignment for malloc and others (authored by jyknight).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118804

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGen/alloc-fns-alignment.c

Index: clang/test/CodeGen/alloc-fns-alignment.c
===
--- clang/test/CodeGen/alloc-fns-alignment.c
+++ clang/test/CodeGen/alloc-fns-alignment.c
@@ -1,12 +1,9 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm < %s | FileCheck %s --check-prefix=ALIGN16
-// RUN: %clang_cc1 -triple x86_64-windows-msvc  -emit-llvm < %s | FileCheck %s --check-prefix=ALIGN16
-// RUN: %clang_cc1 -triple i386-apple-darwin-emit-llvm < %s | FileCheck %s --check-prefix=ALIGN16
-// RUN: %clang_cc1 -triple i386-unknown-linux-gnu   -emit-llvm < %s | FileCheck %s --check-prefix=ALIGN8
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-malloc  -emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-MALLOC
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-calloc  -emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-CALLOC
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-realloc -emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-REALLOC
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-aligned_alloc -emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-ALIGNED_ALLOC
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-memalign -emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-MEMALIGN
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm < %s | FileCheck %s
+
+// Note: this test originally asserted that malloc/calloc/realloc got alignment
+// attributes on their return pointer. However, that was reverted in
+// https://reviews.llvm.org/D118804 and it now asserts that they do _NOT_ get
+// align attributes.
 
 typedef __SIZE_TYPE__ size_t;
 
@@ -49,57 +46,36 @@
 }
 
 // CHECK-LABEL: @malloc_test
-// ALIGN16: align 16 i8* @malloc
-
-// CHECK-LABEL: @calloc_test
-// ALIGN16: align 16 i8* @calloc
-
-// CHECK-LABEL: @realloc_test
-// ALIGN16: align 16 i8* @realloc
+// CHECK: call i8* @malloc
 
-// CHECK-LABEL: @aligned_alloc_variable_test
-// ALIGN16:  %[[ALLOCATED:.*]] = call align 16 i8* @aligned_alloc({{i32|i64}} noundef %[[ALIGN:.*]], {{i32|i64}} noundef %[[NBYTES:.*]])
-// ALIGN16-NEXT: call void @llvm.assume(i1 true) [ "align"(i8* %[[ALLOCATED]], {{i32|i64}} %[[ALIGN]]) ]
-
-// CHECK-LABEL: @memalign_variable_test
-// ALIGN16:  %[[ALLOCATED:.*]] = call align 16 i8* @memalign({{i32|i64}} noundef %[[ALIGN:.*]], {{i32|i64}} noundef %[[NBYTES:.*]])
-// ALIGN16-NEXT: call void @llvm.assume(i1 true) [ "align"(i8* %[[ALLOCATED]], {{i32|i64}} %[[ALIGN]]) ]
-
-// CHECK-LABEL: @aligned_alloc_constant_test
-// ALIGN16: align 16 i8* @aligned_alloc
-
-// CHECK-LABEL: @aligned_alloc_large_constant_test
-// ALIGN16: align 4096 i8* @aligned_alloc
-
-// CHECK-LABEL: @memalign_large_constant_test
-// ALIGN16: align 4096 i8* @memalign
-
-// CHECK-LABEL: @malloc_test
-// ALIGN8: align 8 i8* @malloc
+// CHECK: declare i8* @malloc
 
 // CHECK-LABEL: @calloc_test
-// ALIGN8: align 8 i8* @calloc
+// CHECK: call i8* @calloc
+
+// CHECK: declare i8* @calloc
 
 // CHECK-LABEL: @realloc_test
-// ALIGN8: align 8 i8* @realloc
+// CHECK: call i8* @realloc
+
+// CHECK: declare i8* @realloc
 
 // CHECK-LABEL: @aligned_alloc_variable_test
-// ALIGN8: align 8 i8* @aligned_alloc
+// CHECK:  %[[ALLOCATED:.*]] = call i8* @aligned_alloc({{i32|i64}} noundef %[[ALIGN:.*]], {{i32|i64}} noundef %[[NBYTES:.*]])
+// CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(i8* %[[ALLOCATED]], {{i32|i64}} %[[ALIGN]]) ]
+
+// CHECK: declare i8* @aligned_alloc
 
 // CHECK-LABEL: @memalign_variable_test
-// ALIGN8: align 8 i8* @memalign
+// CHECK:  %[[ALLOCATED:.*]] = call i8* @memalign({{i32|i64}} noundef %[[ALIGN:.*]], {{i32|i64}} noundef %[[NBYTES:.*]])
+// CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(i8* %[[ALLOCATED]], {{i32|i64}} %[[ALIGN]]) ]
 
 // CHECK-LABEL: @aligned_alloc_constant_test
-// ALIGN8: align 8 i8* @aligned_alloc
+// CHECK: call align 8 i8* @aligned_alloc
 
 // CHECK-LABEL: @aligned_alloc_large_constant_test
-// ALIGN8: align 4096 i8* @aligned_alloc
+// CHECK: call align 4096 i8* @aligned_alloc
 
 // CHECK-LABEL: @memalign_large_constant_test
-// ALIGN8: align 4096 i8* @memalign
+// CHECK: align 4096 i8* @memalign
 
-// NOBUILTIN-MALLOC: declare i8* @malloc
-// NOBUILTIN-CALLOC: declare i8* @calloc
-// NOBUILTIN-REALLOC: declare i8* @realloc
-// NOBUILTIN-ALIGNED_ALLOC: declare i8* @aligned_alloc
-// NOBUILTIN-MEMALIGN: declare i8* @memalign

[clang] 9545976 - Revert "[Clang] Propagate guaranteed alignment for malloc and others"

2022-02-08 Thread James Y Knight via cfe-commits

Author: James Y Knight
Date: 2022-02-08T14:34:44-05:00
New Revision: 9545976ff160e19805a84a06a7e59d446f9994d9

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

LOG: Revert "[Clang] Propagate guaranteed alignment for malloc and others"

The above change assumed that malloc (and friends) would always
allocate memory to getNewAlign(), even for allocations which have a
smaller size. This is not actually required by spec (a 1-byte
allocation may validly have 1-byte alignment).

Some real-world malloc implementations do not provide this guarantee,
and thus this optimization is breaking programs.

Fixes #53540

This reverts commit c2297544c04764237cedc523083c7be2fb3833d4.

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

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Sema/SemaDecl.cpp
clang/test/CodeGen/alloc-fns-alignment.c

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 324c123e5be72..22918f7e12e84 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -646,8 +646,8 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   }
 
   /// Return the largest alignment for which a suitably-sized allocation with
-  /// '::operator new(size_t)' or 'malloc' is guaranteed to produce a
-  /// correctly-aligned pointer.
+  /// '::operator new(size_t)' is guaranteed to produce a correctly-aligned
+  /// pointer.
   unsigned getNewAlign() const {
 return NewAlign ? NewAlign : std::max(LongDoubleAlign, LongLongAlign);
   }

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index fce33991c4aa4..71c5fa5509760 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -15320,23 +15320,7 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl 
*FD) {
   if (!FD->hasAttr())
 FD->addAttr(AllocAlignAttr::CreateImplicit(Context, ParamIdx(1, FD),
FD->getLocation()));
-  LLVM_FALLTHROUGH;
-case Builtin::BIcalloc:
-case Builtin::BImalloc:
-case Builtin::BIrealloc:
-case Builtin::BIstrdup:
-case Builtin::BIstrndup: {
-  if (!FD->hasAttr()) {
-unsigned NewAlign = Context.getTargetInfo().getNewAlign() /
-Context.getTargetInfo().getCharWidth();
-IntegerLiteral *Alignment = IntegerLiteral::Create(
-Context, Context.MakeIntValue(NewAlign, Context.UnsignedIntTy),
-Context.UnsignedIntTy, FD->getLocation());
-FD->addAttr(AssumeAlignedAttr::CreateImplicit(
-Context, Alignment, /*Offset=*/nullptr, FD->getLocation()));
-  }
   break;
-}
 default:
   break;
 }

diff  --git a/clang/test/CodeGen/alloc-fns-alignment.c 
b/clang/test/CodeGen/alloc-fns-alignment.c
index 29d6e9e4fb380..bbd213a2bf048 100644
--- a/clang/test/CodeGen/alloc-fns-alignment.c
+++ b/clang/test/CodeGen/alloc-fns-alignment.c
@@ -1,12 +1,9 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm < %s | 
FileCheck %s --check-prefix=ALIGN16
-// RUN: %clang_cc1 -triple x86_64-windows-msvc  -emit-llvm < %s | 
FileCheck %s --check-prefix=ALIGN16
-// RUN: %clang_cc1 -triple i386-apple-darwin-emit-llvm < %s | 
FileCheck %s --check-prefix=ALIGN16
-// RUN: %clang_cc1 -triple i386-unknown-linux-gnu   -emit-llvm < %s | 
FileCheck %s --check-prefix=ALIGN8
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-malloc  
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-MALLOC
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-calloc  
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-CALLOC
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-realloc 
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-REALLOC
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-aligned_alloc 
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-ALIGNED_ALLOC
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-builtin-memalign 
-emit-llvm < %s  | FileCheck %s --check-prefix=NOBUILTIN-MEMALIGN
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm < %s | 
FileCheck %s
+
+// Note: this test originally asserted that malloc/calloc/realloc got alignment
+// attributes on their return pointer. However, that was reverted in
+// https://reviews.llvm.org/D118804 and it now asserts that they do _NOT_ get
+// align attributes.
 
 typedef __SIZE_TYPE__ size_t;
 
@@ -49,57 +46,36 @@ void *memalign_large_constant_test(size_t n) {
 }
 
 // CHECK-LABEL: @malloc_test
-// ALIGN16: align 16 i8* @malloc
-
-// CHECK-LABEL: @calloc_test
-// ALIGN16: align 16 i8* @calloc
-
-// CHECK-LABEL: 

[PATCH] D119215: [clang] Properly cache member pointer LLVM types

2022-02-08 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 406908.
aeubanks added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119215

Files:
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/CodeGenTypes.h
  clang/test/CodeGenCXX/type-cache-2.cpp
  clang/test/CodeGenCXX/type-cache-3.cpp
  clang/test/CodeGenCXX/type-cache.cpp

Index: clang/test/CodeGenCXX/type-cache.cpp
===
--- clang/test/CodeGenCXX/type-cache.cpp
+++ clang/test/CodeGenCXX/type-cache.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -mllvm -verify-type-cache -emit-llvm %s -o - -triple i386-pc-windows-msvc19.16.0 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple i386-pc-windows-msvc19.16.0 | FileCheck %s
 // REQUIRES: asserts, x86-registered-target
 
 // CHECK: call {}* @"?f@@YA?AUz@@XZ"()
Index: clang/test/CodeGenCXX/type-cache-3.cpp
===
--- clang/test/CodeGenCXX/type-cache-3.cpp
+++ clang/test/CodeGenCXX/type-cache-3.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -mllvm -verify-type-cache -emit-llvm %s -o - -triple i386-pc-windows-msvc19.16.0 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple i386-pc-windows-msvc19.16.0 | FileCheck %s
 // REQUIRES: asserts, x86-registered-target
 
 // CHECK-LABEL: define {{.*}}@"?f@@YAXXZ"(
Index: clang/test/CodeGenCXX/type-cache-2.cpp
===
--- clang/test/CodeGenCXX/type-cache-2.cpp
+++ clang/test/CodeGenCXX/type-cache-2.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -mllvm -verify-type-cache -emit-llvm %s -o - -triple i386-pc-windows-msvc19.16.0 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple i386-pc-windows-msvc19.16.0 | FileCheck %s
 // REQUIRES: asserts, x86-registered-target
 
 // CHECK: call void @"?dc@z@@SAXU1@@Z"
Index: clang/lib/CodeGen/CodeGenTypes.h
===
--- clang/lib/CodeGen/CodeGenTypes.h
+++ clang/lib/CodeGen/CodeGenTypes.h
@@ -96,7 +96,7 @@
   /// corresponding llvm::Type.
   llvm::DenseMap TypeCache;
 
-  llvm::SmallSet RecordsWithOpaqueMemberPointers;
+  llvm::DenseMap RecordsWithOpaqueMemberPointers;
 
   /// Helper for ConvertType.
   llvm::Type *ConvertFunctionTypeInternal(QualType FT);
Index: clang/lib/CodeGen/CodeGenTypes.cpp
===
--- clang/lib/CodeGen/CodeGenTypes.cpp
+++ clang/lib/CodeGen/CodeGenTypes.cpp
@@ -29,16 +29,6 @@
 using namespace clang;
 using namespace CodeGen;
 
-#ifndef NDEBUG
-#include "llvm/Support/CommandLine.h"
-// TODO: turn on by default when defined(EXPENSIVE_CHECKS) once check-clang is
-// -verify-type-cache clean.
-static llvm::cl::opt VerifyTypeCache(
-"verify-type-cache",
-llvm::cl::desc("Verify that the type cache matches the computed type"),
-llvm::cl::init(false), llvm::cl::Hidden);
-#endif
-
 CodeGenTypes::CodeGenTypes(CodeGenModule )
   : CGM(cgm), Context(cgm.getContext()), TheModule(cgm.getModule()),
 Target(cgm.getTarget()), TheCXXABI(cgm.getCXXABI()),
@@ -437,14 +427,12 @@
 TypeCache.find(Ty);
 if (TCI != TypeCache.end())
   CachedType = TCI->second;
-if (CachedType) {
-#ifndef NDEBUG
-  if (!VerifyTypeCache)
-return CachedType;
-#else
+  // With expensive checks, check that the type we compute matches the
+  // cached type.
+#ifndef EXPENSIVE_CHECKS
+if (CachedType)
   return CachedType;
 #endif
-}
   }
 
   // If we don't have it in the cache, convert it now.
@@ -784,8 +772,11 @@
   case Type::MemberPointer: {
 auto *MPTy = cast(Ty);
 if (!getCXXABI().isMemberPointerConvertible(MPTy)) {
-  RecordsWithOpaqueMemberPointers.insert(MPTy->getClass());
-  ResultType = llvm::StructType::create(getLLVMContext());
+  auto *C = MPTy->getClass();
+  auto Insertion = RecordsWithOpaqueMemberPointers.insert({C, nullptr});
+  if (Insertion.second)
+Insertion.first->second = llvm::StructType::create(getLLVMContext());
+  ResultType = Insertion.first->second;
 } else {
   ResultType = getCXXABI().ConvertMemberPointerType(MPTy);
 }
@@ -822,13 +813,8 @@
   }
 
   assert(ResultType && "Didn't convert a type?");
-
-#ifndef NDEBUG
-  if (CachedType) {
-assert(CachedType == ResultType &&
-   "Cached type doesn't match computed type");
-  }
-#endif
+  assert((!CachedType || CachedType == ResultType) &&
+ "Cached type doesn't match computed type");
 
   if (ShouldUseCache)
 TypeCache[Ty] = ResultType;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119051: Fix pod-packed functionality to use the C++11 definition of pod-ness

2022-02-08 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Yeah, looks like GCC believes `cxx11_pod::t1` to be C++03 POD even though it 
doesn't quite follow the letter of the standard - but since teh "= default" is 
an extension, I guess they get to define what that extension means.

Here's an example:

  struct t1 { int i; };
  #if USER_DECLARED
  struct t2 { t2() = default; int i; };
  #endif
  #if USER_DEFINED
  struct t3 { t3(); int i; };
  #endif
  void f(int i) {
switch (i) {
  t1 v1;
  #if USER_DECLARED
  t2 v2;
  #endif
  #if USER_DEFINED
  t3 v3;
  #endif
  case 1: {
  }
}
  }

  $ g++ pod.cpp -std=c++03 -fsyntax-only -w -DUSER_DECLARED
  $ g++ pod.cpp -std=c++03 -fsyntax-only -w -DUSER_DEFINED
  pod.cpp: In function ‘void f(int)’:
  pod.cpp:17:10: error: jump to case label
 17 | case 1: {
|  ^
  pod.cpp:15:8: note:   crosses initialization of ‘t3 v3’
 15 | t3 v3;
|^~

  $ clang++ pod.cpp -std=c++03 -fsyntax-only -w -DUSER_DEFINED
  pod.cpp:17:5: error: cannot jump from switch statement to this case label
  case 1: {
  ^
  pod.cpp:15:8: note: jump bypasses variable initialization
  t3 v3;
 ^
  1 error generated.
  $ clang++ pod.cpp -std=c++03 -fsyntax-only -w -DUSER_DECLARED
  pod.cpp:17:5: error: cannot jump from switch statement to this case label
  case 1: {
  ^
  pod.cpp:12:8: note: jump bypasses initialization of non-POD variable
  t2 v2;
 ^
  1 error generated.

And with the updated version of this patch, we get this behavior, matching 
GCC's:

  $ clang++-tot pod.cpp -std=c++03 -fsyntax-only -w -DUSER_DECLARED
  $ clang++-tot pod.cpp -std=c++03 -fsyntax-only -w -DUSER_DEFINED
  pod.cpp:17:5: error: cannot jump from switch statement to this case label
  case 1: {
  ^
  pod.cpp:15:8: note: jump bypasses variable initialization
  t3 v3;
 ^
  1 error generated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119051

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


[PATCH] D119051: Fix pod-packed functionality to use the C++11 definition of pod-ness

2022-02-08 Thread David Blaikie via Phabricator via cfe-commits
dblaikie updated this revision to Diff 406904.
dblaikie added a comment.

- Change the definition of C++03 POD to include defaulted functions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119051

Files:
  clang/lib/AST/DeclCXX.cpp
  clang/test/AST/ast-dump-record-definition-data-json.cpp
  clang/test/SemaCXX/class-layout.cpp

Index: clang/test/SemaCXX/class-layout.cpp
===
--- clang/test/SemaCXX/class-layout.cpp
+++ clang/test/SemaCXX/class-layout.cpp
@@ -1,9 +1,9 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++98 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=13
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -fclang-abi-compat=13 -DCLANG_ABI_COMPAT=13
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -Wno-c++11-extensions -DCLANG_ABI_COMPAT=13
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -Wno-c++11-extensions -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -Wno-c++11-extensions -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base -Wno-c++11-extensions -fclang-abi-compat=13 -DCLANG_ABI_COMPAT=13
 // expected-no-diagnostics
 
 #define SA(n, p) int a##n[(p) ? 1 : -1]
@@ -641,3 +641,14 @@
 _Static_assert(_Alignof(t1) == 1, "");
 _Static_assert(_Alignof(t2) == 1, "");
 } // namespace non_pod_packed
+
+namespace cxx11_pod {
+struct t1 {
+  t1() = default;
+  int a;
+};
+struct t2 {
+  t1 v1;
+} __attribute__((packed));
+_Static_assert(_Alignof(t2) == 1, "");
+}
Index: clang/test/AST/ast-dump-record-definition-data-json.cpp
===
--- clang/test/AST/ast-dump-record-definition-data-json.cpp
+++ clang/test/AST/ast-dump-record-definition-data-json.cpp
@@ -772,6 +772,7 @@
 // CHECK-NEXT:   "isAggregate": true,
 // CHECK-NEXT:   "isEmpty": true,
 // CHECK-NEXT:   "isLiteral": true,
+// CHECK-NEXT:   "isPOD": true,
 // CHECK-NEXT:   "isStandardLayout": true,
 // CHECK-NEXT:   "isTriviallyCopyable": true,
 // CHECK-NEXT:   "moveAssign": {},
@@ -2460,6 +2461,7 @@
 // CHECK-NEXT:   "isAggregate": true,
 // CHECK-NEXT:   "isEmpty": true,
 // CHECK-NEXT:   "isLiteral": true,
+// CHECK-NEXT:   "isPOD": true,
 // CHECK-NEXT:   "isStandardLayout": true,
 // CHECK-NEXT:   "isTrivial": true,
 // CHECK-NEXT:   "isTriviallyCopyable": true,
@@ -3665,6 +3667,7 @@
 // CHECK-NEXT:   "isAggregate": true,
 // CHECK-NEXT:   "isEmpty": true,
 // CHECK-NEXT:   "isLiteral": true,
+// CHECK-NEXT:   "isPOD": true,
 // CHECK-NEXT:   "isStandardLayout": true,
 // CHECK-NEXT:   "isTrivial": true,
 // CHECK-NEXT:   "isTriviallyCopyable": true,
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -768,12 +768,14 @@
 // Note that we have a user-declared constructor.
 data().UserDeclaredConstructor = true;
 
-// C++ [class]p4:
-//   A POD-struct is an aggregate class [...]
-// Since the POD bit is meant to be C++03 POD-ness, clear it even if
-// the type is technically an aggregate in C++0x since it wouldn't be
-// in 03.
-data().PlainOldData = false;
+if (!Constructor->isDefaulted()) {
+  // C++ [class]p4:
+  //   A POD-struct is an aggregate class [...]
+  // Since the POD bit is meant to be C++03 POD-ness, clear it even if
+  // the type is technically an aggregate in C++0x since it wouldn't be
+  // in 03.
+  data().PlainOldData = false;
+}
   }
 
   if (Constructor->isDefaultConstructor()) {
@@ -921,18 +923,21 @@
   if (!Method->isImplicit()) {
 data().UserDeclaredSpecialMembers |= SMKind;
 
-// C++03 [class]p4:
-//  

[PATCH] D119268: avoid the warning of assignment operation inside the if statement

2022-02-08 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets created this revision.
Herald added a subscriber: martong.
phyBrackets 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/D119268

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -946,7 +946,7 @@
   // FIXME: This is a simplified version of what's in CFRefCount.cpp -- it 
makes
   // some assumptions about the value that CFRefCount can't. Even so, it should
   // probably be refactored.
-  if (Optional MR = L->getAs()) {
+  if ((Optional MR = L->getAs())) {
 const MemRegion *R = MR->getRegion()->StripCasts();
 
 // Are we dealing with an ElementRegion?  If so, we should be invalidating


Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -946,7 +946,7 @@
   // FIXME: This is a simplified version of what's in CFRefCount.cpp -- it makes
   // some assumptions about the value that CFRefCount can't. Even so, it should
   // probably be refactored.
-  if (Optional MR = L->getAs()) {
+  if ((Optional MR = L->getAs())) {
 const MemRegion *R = MR->getRegion()->StripCasts();
 
 // Are we dealing with an ElementRegion?  If so, we should be invalidating
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118948: [MTE] Add -fsanitize=memtag* and friends.

2022-02-08 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:475
 def err_stack_tagging_requires_hardware_feature : Error<
-  "'-fsanitize=memtag' requires hardware support (+memtag)">;
+  "'-fsanitize=memtag-stack' requires hardware support (+memtag). For Armv8, "
+  "try compiling with -march=armv8a+memtag.">;

Split out renaming of memtag to memtag-stack first? This will remove a lot of 
diff from this patch.



Comment at: clang/include/clang/Driver/Options.td:1619
+Group,
+HelpText<"Set default MTE mode to 
'async' (default) or 'sync'.">;
 def fsanitize_hwaddress_experimental_aliasing

Let's make "sync" the default mode.



Comment at: lld/ELF/Config.h:346
+  // Mode of MTE to write to the ELF note. Should be one of NT_MEMTAG_ASYNC 
(for
+  // async), NT_MEMTAG_SYNC (for sync), or NT_MEMTAG_DEFAULT (for none). If
+  // async or sync is enabled, write the ELF note specifying the default MTE

NT_MEMTAG_DEFAULT -> NT_MEMTAG_LEVEL_NONE



Comment at: lld/ELF/Driver.cpp:691
+  error("When using --memtag-stack or --memtag-heap, a --memtag-mode value 
"
+"is required.");
+  } else {

Should it be required? We could assume default Sync here the same as in clang 
frontend, that's one less flag to pass around or list in manual linker 
invocations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118948

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


[PATCH] D119166: [clang][ARM] Re-word PACBTI warning.

2022-02-08 Thread Amilendra Kodithuwakku via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG424e850f1ebc: [clang][ARM] Re-word PACBTI warning. (authored 
by amilendra).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119166

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/arm-security-options.c


Index: clang/test/Driver/arm-security-options.c
===
--- clang/test/Driver/arm-security-options.c
+++ clang/test/Driver/arm-security-options.c
@@ -90,4 +90,4 @@
 // BAD-B-KEY-COMBINATION: invalid branch protection option 'b-key' in 
'-mbranch-protection={{.*}}'
 // BAD-LEAF-COMBINATION: invalid branch protection option 'leaf' in 
'-mbranch-protection={{.*}}'
 
-// INCOMPATIBLE-ARCH: ignoring '-mbranch-protection=' option because the 
'{{.*}}' architecture does not support it
+// INCOMPATIBLE-ARCH: '-mbranch-protection=' option is incompatible with the 
'{{.*}}' architecture
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1639,7 +1639,7 @@
   const Driver  = TC.getDriver();
   const llvm::Triple  = TC.getEffectiveTriple();
   if (!(isAArch64 || (Triple.isArmT32() && Triple.isArmMClass(
-D.Diag(diag::warn_target_unsupported_branch_protection_option)
+D.Diag(diag::warn_incompatible_branch_protection_option)
 << Triple.getArchName();
 
   StringRef Scope, Key;
Index: clang/include/clang/Basic/DiagnosticCommonKinds.td
===
--- clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -145,8 +145,8 @@
 def err_nullability_conflicting : Error<
   "nullability specifier %0 conflicts with existing specifier %1">;
 
-def warn_target_unsupported_branch_protection_option: Warning <
-  "ignoring '-mbranch-protection=' option because the '%0' architecture does 
not support it">,
+def warn_incompatible_branch_protection_option: Warning <
+  "'-mbranch-protection=' option is incompatible with the '%0' architecture">,
   InGroup;
 
 def warn_target_unsupported_branch_protection_attribute: Warning <


Index: clang/test/Driver/arm-security-options.c
===
--- clang/test/Driver/arm-security-options.c
+++ clang/test/Driver/arm-security-options.c
@@ -90,4 +90,4 @@
 // BAD-B-KEY-COMBINATION: invalid branch protection option 'b-key' in '-mbranch-protection={{.*}}'
 // BAD-LEAF-COMBINATION: invalid branch protection option 'leaf' in '-mbranch-protection={{.*}}'
 
-// INCOMPATIBLE-ARCH: ignoring '-mbranch-protection=' option because the '{{.*}}' architecture does not support it
+// INCOMPATIBLE-ARCH: '-mbranch-protection=' option is incompatible with the '{{.*}}' architecture
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1639,7 +1639,7 @@
   const Driver  = TC.getDriver();
   const llvm::Triple  = TC.getEffectiveTriple();
   if (!(isAArch64 || (Triple.isArmT32() && Triple.isArmMClass(
-D.Diag(diag::warn_target_unsupported_branch_protection_option)
+D.Diag(diag::warn_incompatible_branch_protection_option)
 << Triple.getArchName();
 
   StringRef Scope, Key;
Index: clang/include/clang/Basic/DiagnosticCommonKinds.td
===
--- clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -145,8 +145,8 @@
 def err_nullability_conflicting : Error<
   "nullability specifier %0 conflicts with existing specifier %1">;
 
-def warn_target_unsupported_branch_protection_option: Warning <
-  "ignoring '-mbranch-protection=' option because the '%0' architecture does not support it">,
+def warn_incompatible_branch_protection_option: Warning <
+  "'-mbranch-protection=' option is incompatible with the '%0' architecture">,
   InGroup;
 
 def warn_target_unsupported_branch_protection_attribute: Warning <
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 424e850 - [clang][ARM] Re-word PACBTI warning.

2022-02-08 Thread Amilendra Kodithuwakku via cfe-commits

Author: Amilendra Kodithuwakku
Date: 2022-02-08T19:13:02Z
New Revision: 424e850f1ebc3e7011cb4af44cb2d62c02a58fbe

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

LOG: [clang][ARM] Re-word PACBTI warning.

The original warning added in D115501 when pacbti is used with an
incompatible architecture was not exactly correct because it was
not really ignored and can affect codegen.

Therefore reword to say that the pacbti option is incompatible with
the given architecture.

Reviewed By: chill

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticCommonKinds.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/arm-security-options.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index 5ea55b0fd31ba..421527827a4bd 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -145,8 +145,8 @@ def 
warn_conflicting_nullability_attr_overriding_param_types : Warning<
 def err_nullability_conflicting : Error<
   "nullability specifier %0 conflicts with existing specifier %1">;
 
-def warn_target_unsupported_branch_protection_option: Warning <
-  "ignoring '-mbranch-protection=' option because the '%0' architecture does 
not support it">,
+def warn_incompatible_branch_protection_option: Warning <
+  "'-mbranch-protection=' option is incompatible with the '%0' architecture">,
   InGroup;
 
 def warn_target_unsupported_branch_protection_attribute: Warning <

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index cfeb965f99e2f..ddc9926aef87a 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1639,7 +1639,7 @@ static void CollectARMPACBTIOptions(const ToolChain , 
const ArgList ,
   const Driver  = TC.getDriver();
   const llvm::Triple  = TC.getEffectiveTriple();
   if (!(isAArch64 || (Triple.isArmT32() && Triple.isArmMClass(
-D.Diag(diag::warn_target_unsupported_branch_protection_option)
+D.Diag(diag::warn_incompatible_branch_protection_option)
 << Triple.getArchName();
 
   StringRef Scope, Key;

diff  --git a/clang/test/Driver/arm-security-options.c 
b/clang/test/Driver/arm-security-options.c
index 79367d7bbb965..fc1b5da78d2cf 100644
--- a/clang/test/Driver/arm-security-options.c
+++ b/clang/test/Driver/arm-security-options.c
@@ -90,4 +90,4 @@
 // BAD-B-KEY-COMBINATION: invalid branch protection option 'b-key' in 
'-mbranch-protection={{.*}}'
 // BAD-LEAF-COMBINATION: invalid branch protection option 'leaf' in 
'-mbranch-protection={{.*}}'
 
-// INCOMPATIBLE-ARCH: ignoring '-mbranch-protection=' option because the 
'{{.*}}' architecture does not support it
+// INCOMPATIBLE-ARCH: '-mbranch-protection=' option is incompatible with the 
'{{.*}}' architecture



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


[PATCH] D118804: Revert "[Clang] Propagate guaranteed alignment for malloc and others"

2022-02-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D118804#3304261 , @urnathan wrote:

> While C2X has blessed such smaller alignments, the x86_64 ABI (in 
> particular), has not.  However, using that ABI to justify 'It. Is. 16. 
> Bytes.', is really an exercise in reality denial at this point.  just thought 
> I'd make it clear we have conflicting standards and practicality to attend to.

By x86-64 ABI, do you mean "System V Application Binary Interface AMD64 
Architecture Processor Supplement"? I have searched a bit but do not find the 
relevant wording on memory allocation.
If there is one, you can report issues on 
https://gitlab.com/x86-psABIs/x86-64-ABI/-/issues (gitlab account needed).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118804

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


[PATCH] D119257: Revert "Re-land [LLD] Remove global state in lldCommon"

2022-02-08 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

@krzysz00 I will revert and re-land with both fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119257

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


[PATCH] D119201: [clang][Fuchsia] Ensure static sanitizer libs are only linked in after the -nostdlib check

2022-02-08 Thread Leonard Chan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
leonardchan marked an inline comment as done.
Closed by commit rG4ac58b61022d: [clang][Fuchsia] Ensure static sanitizer libs 
are only linked in after the… (authored by leonardchan).

Changed prior to commit:
  https://reviews.llvm.org/D119201?vs=406871=406896#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119201

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp


Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -127,10 +127,7 @@
   D.getLTOMode() == LTOK_Thin);
   }
 
-  bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
-  bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
options::OPT_r)) {
@@ -153,11 +150,14 @@
   }
 }
 
-if (NeedsSanitizerDeps)
-  linkSanitizerRuntimeDeps(ToolChain, CmdArgs);
+// Note that Fuchsia never needs to link in sanitizer runtime deps.  Any
+// sanitizer runtimes with system dependencies use the `.deplibs` feature
+// instead.
+addSanitizerRuntimes(ToolChain, Args, CmdArgs);
 
-if (NeedsXRayDeps)
-  linkXRayRuntimeDeps(ToolChain, CmdArgs);
+addXRayRuntime(ToolChain, Args, CmdArgs);
+
+ToolChain.addProfileRTLibs(Args, CmdArgs);
 
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -771,11 +771,6 @@
 
 void tools::linkSanitizerRuntimeDeps(const ToolChain ,
  ArgStringList ) {
-  // Fuchsia never needs these.  Any sanitizer runtimes with system
-  // dependencies use the `.deplibs` feature instead.
-  if (TC.getTriple().isOSFuchsia())
-return;
-
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
   CmdArgs.push_back(getAsNeededOption(TC, false));


Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -127,10 +127,7 @@
   D.getLTOMode() == LTOK_Thin);
   }
 
-  bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
-  bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
options::OPT_r)) {
@@ -153,11 +150,14 @@
   }
 }
 
-if (NeedsSanitizerDeps)
-  linkSanitizerRuntimeDeps(ToolChain, CmdArgs);
+// Note that Fuchsia never needs to link in sanitizer runtime deps.  Any
+// sanitizer runtimes with system dependencies use the `.deplibs` feature
+// instead.
+addSanitizerRuntimes(ToolChain, Args, CmdArgs);
 
-if (NeedsXRayDeps)
-  linkXRayRuntimeDeps(ToolChain, CmdArgs);
+addXRayRuntime(ToolChain, Args, CmdArgs);
+
+ToolChain.addProfileRTLibs(Args, CmdArgs);
 
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -771,11 +771,6 @@
 
 void tools::linkSanitizerRuntimeDeps(const ToolChain ,
  ArgStringList ) {
-  // Fuchsia never needs these.  Any sanitizer runtimes with system
-  // dependencies use the `.deplibs` feature instead.
-  if (TC.getTriple().isOSFuchsia())
-return;
-
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
   CmdArgs.push_back(getAsNeededOption(TC, false));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4ac58b6 - [clang][Fuchsia] Ensure static sanitizer libs are only linked in after the -nostdlib check

2022-02-08 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2022-02-08T10:53:22-08:00
New Revision: 4ac58b61022d128d60ffea06c20611b8eaf8601a

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

LOG: [clang][Fuchsia] Ensure static sanitizer libs are only linked in after the 
-nostdlib check

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/Fuchsia.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 8addee22a2bd..40364d23c559 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -771,11 +771,6 @@ static const char *getAsNeededOption(const ToolChain , 
bool as_needed) {
 
 void tools::linkSanitizerRuntimeDeps(const ToolChain ,
  ArgStringList ) {
-  // Fuchsia never needs these.  Any sanitizer runtimes with system
-  // dependencies use the `.deplibs` feature instead.
-  if (TC.getTriple().isOSFuchsia())
-return;
-
   // Force linking against the system libraries sanitizers depends on
   // (see PR15823 why this is necessary).
   CmdArgs.push_back(getAsNeededOption(TC, false));

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index bd1600d060c8..9e0b259dfcae 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -127,10 +127,7 @@ void fuchsia::Linker::ConstructJob(Compilation , const 
JobAction ,
   D.getLTOMode() == LTOK_Thin);
   }
 
-  bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
-  bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
options::OPT_r)) {
@@ -153,11 +150,14 @@ void fuchsia::Linker::ConstructJob(Compilation , const 
JobAction ,
   }
 }
 
-if (NeedsSanitizerDeps)
-  linkSanitizerRuntimeDeps(ToolChain, CmdArgs);
+// Note that Fuchsia never needs to link in sanitizer runtime deps.  Any
+// sanitizer runtimes with system dependencies use the `.deplibs` feature
+// instead.
+addSanitizerRuntimes(ToolChain, Args, CmdArgs);
 
-if (NeedsXRayDeps)
-  linkXRayRuntimeDeps(ToolChain, CmdArgs);
+addXRayRuntime(ToolChain, Args, CmdArgs);
+
+ToolChain.addProfileRTLibs(Args, CmdArgs);
 
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 



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


[PATCH] D114439: [Annotation] Allow parameter pack expansions and initializer lists in annotate attribute

2022-02-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I've commit on your behalf in ead1690d31f815c00fdd2bc23db4766191bbeabc 
, thank 
you!


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

https://reviews.llvm.org/D114439

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


[clang] ead1690 - Allow parameter pack expansions and initializer lists in annotate attribute

2022-02-08 Thread Aaron Ballman via cfe-commits

Author: Steffen Larsen
Date: 2022-02-08T13:38:07-05:00
New Revision: ead1690d31f815c00fdd2bc23db4766191bbeabc

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

LOG: Allow parameter pack expansions and initializer lists in annotate attribute

These changes make the Clang parser recognize expression parameter pack
expansion and initializer lists in attribute arguments. Because
expression parameter pack expansion requires additional handling while
creating and instantiating templates, the support for them must be
explicitly supported through the AcceptsExprPack flag.

Handling expression pack expansions may require a delay to when the
arguments of an attribute are correctly populated. To this end,
attributes that are set to accept these - through setting the
AcceptsExprPack flag - will automatically have an additional variadic
expression argument member named DelayedArgs. This member is not
exposed the same way other arguments are but is set through the new
CreateWithDelayedArgs creator function generated for applicable
attributes.

To illustrate how to implement support for expression pack expansion
support, clang::annotate is made to support pack expansions. This is
done by making handleAnnotationAttr delay setting the actual attribute
arguments until after template instantiation if it was unable to
populate the arguments due to dependencies in the parsed expressions.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/ParsedAttr.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Sema/ParsedAttr.cpp
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/Parser/cxx0x-attributes.cpp
clang/test/Sema/annotate.c
clang/test/SemaCXX/attr-annotate.cpp
clang/test/SemaTemplate/attributes.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7f568dcb591ec..9055514d80293 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -75,6 +75,8 @@ New Pragmas in Clang
 Attribute Changes in Clang
 --
 
+- Added support for parameter pack expansion in `clang::annotate`.
+
 Windows Support
 ---
 
@@ -144,6 +146,12 @@ Floating Point Support in Clang
 Internal API Changes
 
 
+- Added a new attribute flag `AcceptsExprPack` that when set allows expression
+  pack expansions in the parsed arguments of the corresponding attribute.
+  Additionally it introduces delaying of attribute arguments, adding common
+  handling for creating attributes that cannot be fully initialized prior to
+  template instantiation.
+
 Build System Changes
 
 

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index be56373cc3ca4..dfc609e8ca28c 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -541,6 +541,8 @@ class Attr {
   //   match rules.
   // - It has GNU/CXX11 spelling and doesn't require delayed parsing.
   bit PragmaAttributeSupport;
+  // Set to true if this attribute accepts parameter pack expansion 
expressions.
+  bit AcceptsExprPack = 0;
   // Lists language options, one of which is required to be true for the
   // attribute to be applicable. If empty, no language options are required.
   list LangOpts = [];
@@ -784,6 +786,7 @@ def Annotate : InheritableParamAttr {
   }
   }];
   let PragmaAttributeSupport = 1;
+  let AcceptsExprPack = 1;
   let Documentation = [Undocumented];
 }
 

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 770ddb3ab16f6..e23810f402365 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -719,6 +719,8 @@ def err_attributes_misplaced : Error<"misplaced attributes; 
expected attributes
 def err_l_square_l_square_not_attribute : Error<
   "C++11 only allows consecutive left square brackets when "
   "introducing an attribute">;
+def err_attribute_argument_parm_pack_not_supported : Error<
+  "attribute %0 does not support argument pack expansion">;
 def err_ms_declspec_type : Error<
   "__declspec attributes must be an identifier or string literal">;
 def err_ms_property_no_getter_or_putter : Error<

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 74010ca66f99a..8c37ac721aed4 100644
--- a/clang/include/clang/Parse/Parser.h
+++ 

[PATCH] D119216: [AMDGPU] replace hostcall module flag with function attribute

2022-02-08 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert requested changes to this revision.
jdoerfert added a comment.
This revision now requires changes to proceed.

@kpyzhov Usually people don't accept without comment, especially if there is 
clearly ongoing discussion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119216

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


[PATCH] D119216: [AMDGPU] replace hostcall module flag with function attribute

2022-02-08 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp:566
+  return false;
+};
+

sameerds wrote:
> jdoerfert wrote:
> > jdoerfert wrote:
> > > sameerds wrote:
> > > > jdoerfert wrote:
> > > > > You can use AAPointerInfo for the call site return IRPosition. It 
> > > > > will (through the iterations) gather all accesses and put them into 
> > > > > "bins" based on offset and size. It deals with uses in calls, etc. 
> > > > > and if there is stuff missing it is better to add it in one place so 
> > > > > we benefit throughout. 
> > > > I am not following what you have in mind. "implicitarg_ptr" is a 
> > > > pointer returned by an intrinsic that reads an ABI-defined register. I 
> > > > need to check that for a given call-graph, a particular range of bytes 
> > > > relative to that base pointer are never accessed. The above DFS on the 
> > > > uses conservatively assumes that such a load exists unless it can 
> > > > conclusively trace every use of the base pointer. This may include the 
> > > > pointer being passed to an extern function or being stored into a 
> > > > different memory location (although we don't expect ABI registers being 
> > > > capture this way). I am not seeing how to construct this around 
> > > > AAPointerInfo. As far as I can see, the public interface only talks 
> > > > about uses that are recognized as loads and stores.
> > > Not actually tested, replaces the function body. Depends on D119249.
> > > ```
> > > const auto PointerInfoAA = A.getAAFor(*this, 
> > > IRPosition::callback_returned(cast(Ptr)), DepClassTy::Required);
> > > if (!PointerInfoAA.getState().isValidState())
> > >   return true; // Abort (which is weird as false is abort in the other 
> > > CB).
> > > AAPointerInfo::OffsetAndSize OAS(*Position, /* probably look pointer 
> > > width up in DL */ 8);
> > > return !forallInterferingAccesses(OAS, [](const AAPointerInfo::Access 
> > > , bool IsExact) {
> > >return Acc.getRemoteInst()->isDroppable(); });
> > > ```
> > You don't actually need the state check.
> > And as I said, this will take care of following pointers passed into 
> > callees or through memory to other places, all while ignoring dead code, 
> > etc.
> I see now. forallInterferingAccesses() does check for valid state on entry, 
> which is sufficient to take care of all the opaque uses like a call to an 
> extern function or a complicated phi or a capturing store. Thanks a ton ... 
> this has been very educational!
Yes, all "forAll" functions will return `false` if we cannot visit "all". 
Though, these methods will utilize the smarts, e.g., ignore what is dead, look 
at loads if the value is stored in a way we can track it through memory, 
transfer accesses in a callee to the caller "space" if a pointer is passed to 
the callee,... etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119216

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


[PATCH] D119216: [AMDGPU] replace hostcall module flag with function attribute

2022-02-08 Thread Sameer Sahasrabuddhe via Phabricator via cfe-commits
sameerds updated this revision to Diff 406889.
sameerds added a comment.

added tests for i128 load. hostcall position is now independent of subtarget.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119216

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/amdgpu-asan-printf.cu
  clang/test/CodeGenCUDA/amdgpu-asan.cu
  llvm/lib/Target/AMDGPU/AMDGPUAttributes.def
  llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
  llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
  llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp
  llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h
  llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
  llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
  llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
  llvm/test/CodeGen/AMDGPU/addrspacecast-constantexpr.ll
  llvm/test/CodeGen/AMDGPU/annotate-kernel-features-hsa-call.ll
  llvm/test/CodeGen/AMDGPU/annotate-kernel-features-hsa.ll
  llvm/test/CodeGen/AMDGPU/annotate-kernel-features.ll
  llvm/test/CodeGen/AMDGPU/direct-indirect-call.ll
  llvm/test/CodeGen/AMDGPU/duplicate-attribute-indirect.ll
  llvm/test/CodeGen/AMDGPU/hsa-metadata-enqueue-kernel-v3.ll
  llvm/test/CodeGen/AMDGPU/hsa-metadata-enqueue-kernel.ll
  llvm/test/CodeGen/AMDGPU/hsa-metadata-hidden-args-v3.ll
  llvm/test/CodeGen/AMDGPU/hsa-metadata-hidden-args-v5.ll
  llvm/test/CodeGen/AMDGPU/hsa-metadata-hidden-args.ll
  llvm/test/CodeGen/AMDGPU/hsa-metadata-hostcall-absent-v3.ll
  llvm/test/CodeGen/AMDGPU/hsa-metadata-hostcall-absent.ll
  llvm/test/CodeGen/AMDGPU/hsa-metadata-hostcall-present-v3-asan.ll
  llvm/test/CodeGen/AMDGPU/hsa-metadata-hostcall-present-v3.ll
  llvm/test/CodeGen/AMDGPU/hsa-metadata-hostcall-present.ll
  llvm/test/CodeGen/AMDGPU/hsa-metadata-hostcall-v3.ll
  llvm/test/CodeGen/AMDGPU/hsa-metadata-hostcall-v5.ll
  llvm/test/CodeGen/AMDGPU/propagate-flat-work-group-size.ll
  llvm/test/CodeGen/AMDGPU/simple-indirect-call.ll
  llvm/test/CodeGen/AMDGPU/uniform-work-group-attribute-missing.ll
  llvm/test/CodeGen/AMDGPU/uniform-work-group-multistep.ll
  llvm/test/CodeGen/AMDGPU/uniform-work-group-nested-function-calls.ll
  llvm/test/CodeGen/AMDGPU/uniform-work-group-prevent-attribute-propagation.ll
  llvm/test/CodeGen/AMDGPU/uniform-work-group-recursion-test.ll
  llvm/test/CodeGen/AMDGPU/uniform-work-group-test.ll
  mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp

Index: mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
===
--- mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
+++ mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
@@ -308,11 +308,6 @@
 }
   }
 
-  // Set amdgpu_hostcall if host calls have been linked, as needed by newer LLVM
-  // FIXME: Is there a way to set this during printf() lowering that makes sense
-  if (ret->getFunction("__ockl_hostcall_internal"))
-if (!ret->getModuleFlag("amdgpu_hostcall"))
-  ret->addModuleFlag(llvm::Module::Override, "amdgpu_hostcall", 1);
   return ret;
 }
 
Index: llvm/test/CodeGen/AMDGPU/uniform-work-group-test.ll
===
--- llvm/test/CodeGen/AMDGPU/uniform-work-group-test.ll
+++ llvm/test/CodeGen/AMDGPU/uniform-work-group-test.ll
@@ -61,5 +61,5 @@
 
 attributes #0 = { "uniform-work-group-size"="false" }
 ;.
-; CHECK: attributes #[[ATTR0]] = { "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
+; CHECK: attributes #[[ATTR0]] = { "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
 ;.
Index: llvm/test/CodeGen/AMDGPU/uniform-work-group-recursion-test.ll
===
--- llvm/test/CodeGen/AMDGPU/uniform-work-group-recursion-test.ll
+++ llvm/test/CodeGen/AMDGPU/uniform-work-group-recursion-test.ll
@@ -101,7 +101,7 @@
 attributes #0 = { nounwind readnone }
 attributes #1 = { "uniform-work-group-size"="true" }
 ;.
-; CHECK: attributes #[[ATTR0]] = { nounwind readnone "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
-; CHECK: attributes #[[ATTR1]] = { nounwind readnone "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" 

[PATCH] D118428: [clang-cl] Support the /JMC flag

2022-02-08 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: llvm/lib/CodeGen/JMCInstrumenter.cpp:180
+ "JMC instrument more than once?");
+  FunctionCallee Fn =
+  M.getOrInsertFunction(CheckFunctionName, getCheckFunctionType(Ctx));

might as well get the Function* already here?

```
CheckFunction = cast(M.getOrInsertFunction(...).getCallee());
```



Comment at: llvm/lib/CodeGen/TargetPassConfig.cpp:1096
+  if (TM->Options.JMCInstrument)
+addPass(createJMCInstrumenterPass());
   addCodeGenPrepare();

could this be moved into addIRPasses()?



Comment at: llvm/test/CodeGen/X86/jmc-instrument.ll:2
+; Check that the flag symbol is not full-qualified.
+; RUN: llc < %s -enable-jmc-instrument | FileCheck %s
+

hans wrote:
> Since it's an IR pass, I think we don't need to have an llc test at all.
I still think it's unusual to have an llc test for an IR pass. Are there any 
other examples where we do something similar?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118428

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


[PATCH] D118804: Revert "[Clang] Propagate guaranteed alignment for malloc and others"

2022-02-08 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I'm not sure your new wording is any clearer; a

In D118804#3304337 , @urnathan wrote:

> In D118804#3304280 , @aaron.ballman 
> wrote:
>
>> In D118804#3304261 , @urnathan 
>> wrote:
>>
>>> While C2X has blessed such smaller alignments, the x86_64 ABI (in 
>>> particular), has not.  However, using that ABI to justify 'It. Is. 16. 
>>> Bytes.', is really an exercise in reality denial at this point.  just 
>>> thought I'd make it clear we have conflicting standards and practicality to 
>>> attend to.
>>
>> Do we want me to report back to WG14 with information that N2293 might not 
>> suitable for adoption into C2x?
>
> I think N2293 is fine for C2x.  It is blessing an implementation of lower 
> alignment allocations.  Putting the programmer on notice that they can no 
> longer assume some things.
>
> As a compiler I think we need to deal with the reality that there are non-ABI 
> conforming [system-dependent] allocators out there, and not simply say 'But 
> the ABI says ...'

If a platform's ABI guarantees something, and the platform's system allocator 
actually does it, then that's the required behavior there, and replacement 
allocators that don't live up to it are non-conformant.  But if the system 
allocator intentionally *doesn't* do it, and the platform's ABI is a generic 
ABI, then yeah, we have to understand that as an intent to declare a 
platform-specific deviation from the generic ABI.

> There is already at least one thing the ABI says that is not valid on some 
> systems [sret return behaviour and Swift], for equally good reasons.  The 
> compiler deals with that.

Can you explain what you mean here?  Swift's conventions are not really bound 
by the C ABI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118804

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


[PATCH] D119257: Revert "Re-land [LLD] Remove global state in lldCommon"

2022-02-08 Thread Krzysztof Drewniak via Phabricator via cfe-commits
krzysz00 added a comment.

@aganea Can we expect fixes for both the issues with this revision (the 
HIP-on-Windows problems noted last night and the MLIR breakage) shortly or 
should we revert while y'all work out fixes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119257

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


[PATCH] D72404: [ThinLTO/FullLTO] Support Os and Oz

2022-02-08 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In D72404#3304205 , @aykevl wrote:

> I would be very interested in this patch, because for me to use ThinLTO 
> without size regressions I need to set the optimization size level in the 
> linker (`PassManagerBuilder.SizeLevel` etc).

Why can't you build the object files with `-Os` in the first place instead of 
changing the optimization level between the compilation and the linking phases?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72404

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


[PATCH] D118862: [clang][driver] add clang driver support for emitting macho files with two build version load commands

2022-02-08 Thread Steven Wu via Phabricator via cfe-commits
steven_wu accepted this revision.
steven_wu 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/D118862/new/

https://reviews.llvm.org/D118862

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


[PATCH] D72404: [ThinLTO/FullLTO] Support Os and Oz

2022-02-08 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

I just saw this. I know it is a good idea to have choice during link time for 
the pipeline configuration and from your benchmark it also has size impact on 
the output. I also feel like this is going in the wrong direction as if I have 
part of the object files built with -O3 and part built with -Oz, I need to make 
a choice of unoptimized part of the program.

Before I say yes or no to this patch, have you figured out what are the passes 
that causes the most size regression? Ideally, with function attributes on the 
function, it shouldn't be much size impact on the output.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72404

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


[PATCH] D119215: [clang] Properly cache member pointer LLVM types

2022-02-08 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Seems reasonable




Comment at: clang/lib/CodeGen/CodeGenTypes.cpp:776
+  auto *C = MPTy->getClass();
+  auto I = RecordsWithOpaqueMemberPointers.find(C);
+  if (I == RecordsWithOpaqueMemberPointers.end()) {

Can this use something like the `insert` get-or-create pattern?
  auto Insertion = RecordsWithOpaqueMemberPointers.insert({C, StructType*{}});
  if (Insertion.second) Insertion.first->second = llvm::StructType::create(...);
  return Insertion.first->second;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119215

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


[PATCH] D114439: [Annotation] Allow parameter pack expansions and initializer lists in annotate attribute

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

LGTM! Thank you for all the good discussion and work on this! I'll commit on 
your behalf once the precommit CI pipeline comes back green.


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

https://reviews.llvm.org/D114439

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


[PATCH] D119201: [clang][Fuchsia] Ensure static sanitizer libs are only linked in after the -nostdlib check

2022-02-08 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/Driver/ToolChains/Fuchsia.cpp:158-160
+bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
 if (NeedsXRayDeps)
   linkXRayRuntimeDeps(ToolChain, CmdArgs);

I think this can be dropped as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119201

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


  1   2   3   >