[PATCH] D118876: [HIPSPV] Fix literals are mapped to Generic address space

2022-02-03 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki added a comment.

Thanks for the review, @yaxunl. Could you push this to the LLVM? And to the 
LLVM 14 release branch too, if possible?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118876

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


[PATCH] D118257: [AArch64] Generate fcmps when appropriate for neon intrinsics

2022-02-03 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.
This revision is now accepted and ready to land.

This seems OK. LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118257

___
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-03 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D110869#3295906 , @void wrote:

> In D110869#3295578 , 
> @nickdesaulniers wrote:
>
>> In D110869#3295559 , @void wrote:
>>
>>> Weird. We generate similar code to GCC:
>>>
>>>   Clang:
>>>   _paravirt_ident_64: # @_paravirt_ident_64
>>>   movq%rdi, %rax
>>>   xorq%rdi, %rdi
>>>   retq
>>>   
>>>   GCC:
>>>   _paravirt_ident_64:
>>>   movq%rdi, %rax  # tmp85, x
>>>   xorl%edi, %edi  #
>>>   ret
>>
>> Does `xorl` not zero the upper 32b?
>
> I'm thinking no. But it's odd, because both are using `%rdi` but GCC is only 
> zeroing out the bottom 32-bits. Seems a bit counter-intuitive.

Every write to a 32-bit register on x86-64 zeros bits 63:32 of the register. 
`xorl %edi, %edi` has the same behavior as `xorq %rdi, %rdi`, but is 1 byte 
shorter to encode.


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] D118969: [clang-format][NFC] Fix a bug in setting type FunctionLBrace

2022-02-03 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Well, I thought about this approach but actually a macro line should never be 
merged together with a preceding line, so I went for a generic approach.
That's because one never knows what's in a macro, it can well be a function 
brace after all depending on what goes before...
Apart from that, could you add an annotator test please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118969

___
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-03 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

In D110869#3295578 , @nickdesaulniers 
wrote:

> In D110869#3295559 , @void wrote:
>
>> Weird. We generate similar code to GCC:
>>
>>   Clang:
>>   _paravirt_ident_64: # @_paravirt_ident_64
>>   movq%rdi, %rax
>>   xorq%rdi, %rdi
>>   retq
>>   
>>   GCC:
>>   _paravirt_ident_64:
>>   movq%rdi, %rax  # tmp85, x
>>   xorl%edi, %edi  #
>>   ret
>
> Does `xorl` not zero the upper 32b?

I'm thinking no. But it's odd, because both are using `%rdi` but GCC is only 
zeroing out the bottom 32-bits. Seems a bit counter-intuitive.

> Definitely something magical about this function. Perhaps it should have the 
> function attribute to disable zeroing added to the kernel sources?
>
> tools/objtool/objtool.c mentions something about `_paravirt_ident_64` and 
> `paravirt_patch`.
>
> I'm curious @nathanchance if you move the definition of `_paravirt_ident_64` 
> to an external assembler file, and see whether the mere `xorl` vs `xorq` 
> makes a difference for some reason for boot?




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] D118104: Make run-clang-tidy.py print the configured checks correctly

2022-02-03 Thread Jesko Appelfeller via Phabricator via cfe-commits
JesApp added a comment.

In D118104#3294883 , 
@LegalizeAdulthood wrote:

> What is the feasibility of Python unit tests Instead of a heavy-weight `lit` 
> oriented test?

I don't know the code-base well enough to answer that. Is python used for 
testing purposes anywhere else? I'm pretty sure the actual effort of writing 
the tests would be roughly the same, regardless.

Anyway, I'm new here, so I don't want to tell you guys how to run things, but: 
In the projects I usually work on, a fix would get merged quickly and things 
like "let's write a test suite for this script" would go in the backlog. What's 
your opinion on that?


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

https://reviews.llvm.org/D118104

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


[PATCH] D117616: GCC ABI Compatibility: Preserve alignment of non-pod members in packed structs

2022-02-03 Thread Bhramar Vatsa via Phabricator via cfe-commits
Bhramar.vatsa added a comment.

@dblaikie 
The condition "FieldClass->isPOD()" returns false for the following case (when 
considering field 'struct foo t' of 'struct foo1') :

  class foo {
 foo() = default;
 int _a;
  };
  
  struct foo1 {
  struct foo t;
  } t1;

The same code though doesn't give any warning for gcc: 
https://godbolt.org/z/f4chraerY

This is because the way it works for CXXRecordDecl : 
https://github.com/llvm/llvm-project/blob/1e3a02162db20264e9615b1346420c8d199cb347/clang/lib/AST/DeclCXX.cpp#L928

So, there seems to be a difference the way GCC is handling this case, in 
comparison to how now clang handles it.

For the same case, `D->getType().isCXX11PODType()` (or `isPODType()`) indicates 
it to be a POD type. So, we think that this should be further changed such that 
it doesn't break the code that works with GCC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117616

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


[PATCH] D118969: [clang-format][NFC] Fix a bug in setting type FunctionLBrace

2022-02-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: curdeius, MyDeveloperDay, HazardyKnusperkeks.
owenpan added a project: clang-format.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The `l_brace` token in a macro definition should not be set to 
`TT_FunctionLBrace`.

This patch could have fixed https://github.com/llvm/llvm-project/issues/42087.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118969

Files:
  clang/lib/Format/UnwrappedLineParser.cpp


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1571,7 +1571,8 @@
 } else if (Style.BraceWrapping.AfterFunction) {
   addUnwrappedLine();
 }
-FormatTok->setType(TT_FunctionLBrace);
+if (!Line->InPPDirective)
+  FormatTok->setType(TT_FunctionLBrace);
 parseBlock();
 addUnwrappedLine();
 return;


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1571,7 +1571,8 @@
 } else if (Style.BraceWrapping.AfterFunction) {
   addUnwrappedLine();
 }
-FormatTok->setType(TT_FunctionLBrace);
+if (!Line->InPPDirective)
+  FormatTok->setType(TT_FunctionLBrace);
 parseBlock();
 addUnwrappedLine();
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118965: [OpenMP] Add search path for llvm-strip

2022-02-03 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 created this revision.
kkwli0 added reviewers: jhuber6, jdoerfert.
Herald added subscribers: guansong, yaxunl.
kkwli0 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Add the search path for llvm-strip instead of solely relying on the PATH 
environment variable setting.

Currently, `make check-openmp` has a few failures with the error:

  /build-llvm/./bin/clang-linker-wrapper: error: Unable to find 'llvm-strip' in 
path


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118965

Files:
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp


Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -303,7 +303,13 @@
 
   // We will use llvm-strip to remove the now unneeded section containing the
   // offloading code.
-  ErrorOr StripPath = sys::findProgramByName("llvm-strip");
+  void *P = (void *)(intptr_t)
+  StringRef COWDir = "";
+  auto COWPath = sys::fs::getMainExecutable("llvm-strip", P);
+  if (!COWPath.empty())
+COWDir = sys::path::parent_path(COWPath);
+  ErrorOr StripPath =
+  sys::findProgramByName("llvm-strip", {COWDir});
   if (!StripPath)
 return createStringError(StripPath.getError(),
  "Unable to find 'llvm-strip' in path");


Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -303,7 +303,13 @@
 
   // We will use llvm-strip to remove the now unneeded section containing the
   // offloading code.
-  ErrorOr StripPath = sys::findProgramByName("llvm-strip");
+  void *P = (void *)(intptr_t)
+  StringRef COWDir = "";
+  auto COWPath = sys::fs::getMainExecutable("llvm-strip", P);
+  if (!COWPath.empty())
+COWDir = sys::path::parent_path(COWPath);
+  ErrorOr StripPath =
+  sys::findProgramByName("llvm-strip", {COWDir});
   if (!StripPath)
 return createStringError(StripPath.getError(),
  "Unable to find 'llvm-strip' in path");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118964: Fix broken 2-stage build when -tblgen tools may depend on runpath that is not yet built

2022-02-03 Thread Arcadiy Ivanov via Phabricator via cfe-commits
arcivanov created this revision.
arcivanov added reviewers: LLVM, clang.
arcivanov added projects: clang, LLVM.
Herald added a subscriber: mgorny.
arcivanov requested review of this revision.
Herald added a subscriber: cfe-commits.

In my case `-tblgen` tools in the **second stage** end up being built depending 
on `libc++.so`. 
While the the dependency is correct and the tools are built successfully, 
`-tblgen` tools would not function until `libc++.so` is built in the 
`$ORIGIN/../lib`. 
But `libc++.so` of the second stage cannot be built without second stage 
`llvm-tblgen` and `clang-tblgen` functioning.

This patch makes sure that in a bootstrapped build `llvm-tblgen`and 
`clang-tblgen` are always used from the bootstrap //even when not 
crosscompiling//.

See https://github.com/llvm/llvm-project/issues/53561 for extensive logs, 
printouts and cmake caches.

If accepted please also send to 13.x and 14.x.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118964

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -747,6 +747,13 @@
 -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/${C_COMPILER}
 -DCMAKE_ASM_COMPILER_ID=Clang)
 
+  # If -tblgen is linked to libc++.so and it's not available in the system, 
the tool can't run
+  # since the runpath doesn't yet contain libc++.so, which can't be built 
without -tblgen
+  # See https://github.com/llvm/llvm-project/issues/53561
+  set(${CLANG_STAGE}_TABLEGEN
+-DLLVM_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-tblgen
+-DCLANG_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-tblgen)
+
   # cmake requires CMAKE_LINKER to be specified if the compiler is MSVC-like,
   # otherwise it defaults the linker to be link.exe.
   if(BOOTSTRAP_LLVM_ENABLE_LLD)
@@ -757,9 +764,6 @@
 
   if(BOOTSTRAP_CMAKE_SYSTEM_NAME)
 set(${CLANG_STAGE}_CONFIG 
-DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config)
-set(${CLANG_STAGE}_TABLEGEN
-  -DLLVM_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-tblgen
-  -DCLANG_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-tblgen)
 if(BOOTSTRAP_CMAKE_SYSTEM_NAME STREQUAL "Linux")
   if(BOOTSTRAP_LLVM_ENABLE_LLD)
 set(${CLANG_STAGE}_LINKER 
-DCMAKE_LINKER=${LLVM_RUNTIME_OUTPUT_INTDIR}/ld.lld)


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -747,6 +747,13 @@
 -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/${C_COMPILER}
 -DCMAKE_ASM_COMPILER_ID=Clang)
 
+  # If -tblgen is linked to libc++.so and it's not available in the system, the tool can't run
+  # since the runpath doesn't yet contain libc++.so, which can't be built without -tblgen
+  # See https://github.com/llvm/llvm-project/issues/53561
+  set(${CLANG_STAGE}_TABLEGEN
+-DLLVM_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-tblgen
+-DCLANG_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-tblgen)
+
   # cmake requires CMAKE_LINKER to be specified if the compiler is MSVC-like,
   # otherwise it defaults the linker to be link.exe.
   if(BOOTSTRAP_LLVM_ENABLE_LLD)
@@ -757,9 +764,6 @@
 
   if(BOOTSTRAP_CMAKE_SYSTEM_NAME)
 set(${CLANG_STAGE}_CONFIG -DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config)
-set(${CLANG_STAGE}_TABLEGEN
-  -DLLVM_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-tblgen
-  -DCLANG_TABLEGEN=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-tblgen)
 if(BOOTSTRAP_CMAKE_SYSTEM_NAME STREQUAL "Linux")
   if(BOOTSTRAP_LLVM_ENABLE_LLD)
 set(${CLANG_STAGE}_LINKER -DCMAKE_LINKER=${LLVM_RUNTIME_OUTPUT_INTDIR}/ld.lld)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118949: [HIP] Support code object v5

2022-02-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

Will revise as recommended when committing. Thanks.


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

https://reviews.llvm.org/D118949

___
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-03 Thread Mitch Phillips via Phabricator via cfe-commits
hctim updated this revision to Diff 405842.
hctim added a comment.

(forgot to add REQUIRES: aarch64 to the lld test)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118948

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.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/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/CodeGen/memtag-attr.cpp
  clang/test/Driver/fsanitize.c
  clang/test/Driver/memtag-ld.c
  clang/test/Driver/memtag-stack.c
  clang/test/Driver/memtag.c
  clang/test/Lexer/has_feature_memtag_heap.cpp
  clang/test/Lexer/has_feature_memtag_sanitizer.cpp
  clang/test/Lexer/has_feature_memtag_stack.cpp
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/Options.td
  lld/ELF/SyntheticSections.cpp
  lld/ELF/SyntheticSections.h
  lld/ELF/Writer.cpp
  lld/test/ELF/aarch64-memtag-android-abi.s
  llvm/include/llvm/BinaryFormat/ELF.h

Index: llvm/include/llvm/BinaryFormat/ELF.h
===
--- llvm/include/llvm/BinaryFormat/ELF.h
+++ llvm/include/llvm/BinaryFormat/ELF.h
@@ -1531,6 +1531,22 @@
   NT_GNU_PROPERTY_TYPE_0 = 5,
 };
 
+// Android note types.
+enum {
+  NT_ANDROID_TYPE_IDENT = 1,
+  NT_ANDROID_TYPE_KUSER = 3,
+  NT_ANDROID_TYPE_MEMTAG = 4,
+};
+
+enum {
+  NT_MEMTAG_LEVEL_DEFAULT = 0,
+  NT_MEMTAG_LEVEL_ASYNC = 1,
+  NT_MEMTAG_LEVEL_SYNC = 2,
+  NT_MEMTAG_LEVEL_MASK = 3,
+  NT_MEMTAG_HEAP = 4,
+  NT_MEMTAG_STACK = 8,
+};
+
 // Property types used in GNU_PROPERTY_TYPE_0 notes.
 enum : unsigned {
   GNU_PROPERTY_STACK_SIZE = 1,
Index: lld/test/ELF/aarch64-memtag-android-abi.s
===
--- /dev/null
+++ lld/test/ELF/aarch64-memtag-android-abi.s
@@ -0,0 +1,80 @@
+# REQUIRES: aarch64
+
+# 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
+# the ABI" check. Basically below is the copied version of the Android parsing
+# logic. We create a no-op aarch64 binary with an elf note, and then consume it
+# using the parsing logic on the host system. Because we don't pull in any
+# libraries or headers, this should be runnable on any system that uses linux
+# (technically, any system that can parse ELF, but I'm not rewriting it in
+# python to run on Windows...). Note that MTE stack is an ABI break, so we
+# expect it to crash under this parsing logic.
+
+# RUN: llvm-mc --filetype=obj -triple=aarch64-linux-none-gnu %s -o %t.o
+# RUN: ld.lld --memtag-mode=async --memtag-heap %t.o -o %t
+# RUN: llvm-readelf -n %t | \
+# RUN:FileCheck %s --check-prefixes=NOTE,HEAP-ASYNC-NOTE
+
+# RUN: ld.lld --memtag-mode=sync --memtag-heap %t.o -o %t
+# RUN: llvm-readelf -n %t | \
+# RUN:FileCheck %s --check-prefixes=NOTE,HEAP-SYNC-NOTE
+
+# RUN: ld.lld --memtag-mode=async --memtag-stack %t.o -o %t
+# RUN: llvm-readelf -n %t | \
+# RUN:FileCheck %s --check-prefixes=NOTE,STACK-ASYNC
+
+# RUN: ld.lld --memtag-mode=sync --memtag-stack %t.o -o %t
+# RUN: llvm-readelf -n %t | \
+# RUN:FileCheck %s --check-prefixes=NOTE,STACK-SYNC
+
+# RUN: ld.lld --memtag-mode=async --memtag-heap --memtag-stack %t.o -o %t
+# RUN: llvm-readelf -n %t | \
+# RUN:FileCheck %s --check-prefixes=NOTE,BOTH-ASYNC
+
+# RUN: ld.lld --memtag-mode=sync --memtag-heap --memtag-stack %t.o -o %t
+# RUN: llvm-readelf -n %t | \
+# RUN:FileCheck %s --check-prefixes=NOTE,BOTH-SYNC
+
+# NOTE: .note.android.memtag
+# NOTE-NEXT: Owner
+# TODO(hctim): Update llvm-readelf to understand this note type.
+# NOTE-NEXT: Android  0x0004  Unknown note type: (0x0004)
+
+# The next few lines are an ABI enforcement for Android 11 and 12. If you're
+# compiling with just heap MTE (i.e just --memtag-mode), then these lines MUST
+# be unchanging.
+# HEAP-ASYNC-NOTE-NEXT: description data: 05 00 00 00
+# HEAP-SYNC-NOTE-NEXT: description data: 06 00 00 00
+
+# Stack MTE is, as of Android 12, unimplemented. However, we pre-emptively emit
+# a bit that signifies to the dynamic loader to map the primary and thread
+# stacks as PROT_MTE, in preparation for the bionic support.
+# STACK-ASYNC-NEXT: description data: 09 00 00 00
+# STACK-SYNC-NEXT: description data: 0a 00 00 00
+
+# Stack MTE is, as of Android 12, unimplemented. However, we pre-emptively emit
+# a bit that signifies to the dynamic loader to map the primary and thread
+# stacks as PROT_MTE, in preparation for the bionic support.
+# BOTH-ASYNC-NEXT: description data: 0d 00 00 00
+# BOTH-SYNC-NEXT: description data: 0e 00 00 00
+
+# RUN: not ld.lld --memtag-stack 2>&1 | \
+# RUN:FileCheck %s 

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

2022-02-03 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added a comment.

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?


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] D110869: [X86] Implement -fzero-call-used-regs option

2022-02-03 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D110869#3295559 , @void wrote:

> Weird. We generate similar code to GCC:
>
>   Clang:
>   _paravirt_ident_64: # @_paravirt_ident_64
>   movq%rdi, %rax
>   xorq%rdi, %rdi
>   retq
>   
>   GCC:
>   _paravirt_ident_64:
>   movq%rdi, %rax  # tmp85, x
>   xorl%edi, %edi  #
>   ret

Does `xorl` not zero the upper 32b?

Definitely something magical about this function. Perhaps it should have the 
function attribute to disable zeroing added to the kernel sources?

tools/objtool/objtool.c mentions something about `_paravirt_ident_64` and 
`paravirt_patch`.

I'm curious @nathanchance if you move the definition of `_paravirt_ident_64` to 
an external assembler file, and see whether the mere `xorl` vs `xorq` makes a 
difference for some reason for boot?


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] D118948: [MTE] Add -fsanitize=memtag* and friends.

2022-02-03 Thread Mitch Phillips via Phabricator via cfe-commits
hctim updated this revision to Diff 405839.
hctim marked an inline comment as done.
hctim added a comment.

Address Ray's comments, and made it so that stack MTE doesn't imply heap.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118948

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.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/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/CodeGen/memtag-attr.cpp
  clang/test/Driver/fsanitize.c
  clang/test/Driver/memtag-ld.c
  clang/test/Driver/memtag-stack.c
  clang/test/Driver/memtag.c
  clang/test/Lexer/has_feature_memtag_heap.cpp
  clang/test/Lexer/has_feature_memtag_sanitizer.cpp
  clang/test/Lexer/has_feature_memtag_stack.cpp
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/Options.td
  lld/ELF/SyntheticSections.cpp
  lld/ELF/SyntheticSections.h
  lld/ELF/Writer.cpp
  lld/test/ELF/aarch64-memtag-android-abi.s
  llvm/include/llvm/BinaryFormat/ELF.h

Index: llvm/include/llvm/BinaryFormat/ELF.h
===
--- llvm/include/llvm/BinaryFormat/ELF.h
+++ llvm/include/llvm/BinaryFormat/ELF.h
@@ -1531,6 +1531,22 @@
   NT_GNU_PROPERTY_TYPE_0 = 5,
 };
 
+// Android note types.
+enum {
+  NT_ANDROID_TYPE_IDENT = 1,
+  NT_ANDROID_TYPE_KUSER = 3,
+  NT_ANDROID_TYPE_MEMTAG = 4,
+};
+
+enum {
+  NT_MEMTAG_LEVEL_DEFAULT = 0,
+  NT_MEMTAG_LEVEL_ASYNC = 1,
+  NT_MEMTAG_LEVEL_SYNC = 2,
+  NT_MEMTAG_LEVEL_MASK = 3,
+  NT_MEMTAG_HEAP = 4,
+  NT_MEMTAG_STACK = 8,
+};
+
 // Property types used in GNU_PROPERTY_TYPE_0 notes.
 enum : unsigned {
   GNU_PROPERTY_STACK_SIZE = 1,
Index: lld/test/ELF/aarch64-memtag-android-abi.s
===
--- /dev/null
+++ lld/test/ELF/aarch64-memtag-android-abi.s
@@ -0,0 +1,78 @@
+# 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
+# the ABI" check. Basically below is the copied version of the Android parsing
+# logic. We create a no-op aarch64 binary with an elf note, and then consume it
+# using the parsing logic on the host system. Because we don't pull in any
+# libraries or headers, this should be runnable on any system that uses linux
+# (technically, any system that can parse ELF, but I'm not rewriting it in
+# python to run on Windows...). Note that MTE stack is an ABI break, so we
+# expect it to crash under this parsing logic.
+
+# RUN: llvm-mc --filetype=obj -triple=aarch64-linux-none-gnu %s -o %t.o
+# RUN: ld.lld --memtag-mode=async --memtag-heap %t.o -o %t
+# RUN: llvm-readelf -n %t | \
+# RUN:FileCheck %s --check-prefixes=NOTE,HEAP-ASYNC-NOTE
+
+# RUN: ld.lld --memtag-mode=sync --memtag-heap %t.o -o %t
+# RUN: llvm-readelf -n %t | \
+# RUN:FileCheck %s --check-prefixes=NOTE,HEAP-SYNC-NOTE
+
+# RUN: ld.lld --memtag-mode=async --memtag-stack %t.o -o %t
+# RUN: llvm-readelf -n %t | \
+# RUN:FileCheck %s --check-prefixes=NOTE,STACK-ASYNC
+
+# RUN: ld.lld --memtag-mode=sync --memtag-stack %t.o -o %t
+# RUN: llvm-readelf -n %t | \
+# RUN:FileCheck %s --check-prefixes=NOTE,STACK-SYNC
+
+# RUN: ld.lld --memtag-mode=async --memtag-heap --memtag-stack %t.o -o %t
+# RUN: llvm-readelf -n %t | \
+# RUN:FileCheck %s --check-prefixes=NOTE,BOTH-ASYNC
+
+# RUN: ld.lld --memtag-mode=sync --memtag-heap --memtag-stack %t.o -o %t
+# RUN: llvm-readelf -n %t | \
+# RUN:FileCheck %s --check-prefixes=NOTE,BOTH-SYNC
+
+# NOTE: .note.android.memtag
+# NOTE-NEXT: Owner
+# TODO(hctim): Update llvm-readelf to understand this note type.
+# NOTE-NEXT: Android  0x0004  Unknown note type: (0x0004)
+
+# The next few lines are an ABI enforcement for Android 11 and 12. If you're
+# compiling with just heap MTE (i.e just --memtag-mode), then these lines MUST
+# be unchanging.
+# HEAP-ASYNC-NOTE-NEXT: description data: 05 00 00 00
+# HEAP-SYNC-NOTE-NEXT: description data: 06 00 00 00
+
+# Stack MTE is, as of Android 12, unimplemented. However, we pre-emptively emit
+# a bit that signifies to the dynamic loader to map the primary and thread
+# stacks as PROT_MTE, in preparation for the bionic support.
+# STACK-ASYNC-NEXT: description data: 09 00 00 00
+# STACK-SYNC-NEXT: description data: 0a 00 00 00
+
+# Stack MTE is, as of Android 12, unimplemented. However, we pre-emptively emit
+# a bit that signifies to the dynamic loader to map the primary and thread
+# stacks as PROT_MTE, in preparation for the bionic support.
+# BOTH-ASYNC-NEXT: description data: 0d 00 00 00
+# BOTH-SYNC-NEXT: description data: 0e 00 00 00
+
+# RUN: not ld.lld --memtag-stack 2>&1 | \
+# 

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

2022-02-03 Thread Mitch Phillips via Phabricator via cfe-commits
hctim marked 9 inline comments as done.
hctim added inline comments.



Comment at: llvm/include/llvm/BinaryFormat/ELF.h:1536
+enum {
+  NT_TYPE_IDENT = 1,
+  NT_TYPE_KUSER = 3,

MaskRay wrote:
> If Android wants to define notes, can it use a namespace `NT_ANDROID_*` like 
> GNU?
> 
> Please see `https://reviews.llvm.org/D107949` how I add ELF attributes and 
> related tests when new additions are added to BinaryFormat/ELF.h
Android currently defines their internal note types in this naming scheme 
(https://cs.android.com/android/platform/superproject/+/master:bionic/libc/private/bionic_asm_note.h).

However, it seems like these are not used outside of Android internally, so let 
me slap some prefixes on them. Maybe I'll even get around to updating them in 
the Android tree as well, who knows.


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] D118944: [OpenMP] Add Cuda path to linker wrapper tool

2022-02-03 Thread Joseph Huber via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8cc4ca95b02b: [OpenMP] Add Cuda path to linker wrapper tool 
(authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118944

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -99,8 +99,8 @@
 
 static cl::list
 PtxasArgs("ptxas-args", cl::ZeroOrMore,
-cl::desc("Argument to pass to the ptxas invocation"),
-cl::cat(ClangLinkerWrapperCategory));
+  cl::desc("Argument to pass to the ptxas invocation"),
+  cl::cat(ClangLinkerWrapperCategory));
 
 static cl::opt Verbose("v", cl::ZeroOrMore,
  cl::desc("Verbose output from tools"),
@@ -118,6 +118,10 @@
cl::desc("Save intermediary results."),
cl::cat(ClangLinkerWrapperCategory));
 
+static cl::opt CudaPath("cuda-path", cl::ZeroOrMore,
+ cl::desc("Save intermediary results."),
+ cl::cat(ClangLinkerWrapperCategory));
+
 // Do not parse linker options.
 static cl::list
 HostLinkerArgs(cl::Positional,
@@ -129,6 +133,9 @@
 /// Filename of the executable being created.
 static StringRef ExecutableName;
 
+/// Binary path for the CUDA installation.
+static std::string CudaBinaryPath;
+
 /// Temporary files created by the linker wrapper.
 static SmallVector TempFiles;
 
@@ -507,9 +514,9 @@
 namespace nvptx {
 Expected assemble(StringRef InputFile, Triple TheTriple,
StringRef Arch) {
-  // NVPTX uses the nvlink binary to link device object files.
+  // NVPTX uses the ptxas binary to create device object files.
   ErrorOr PtxasPath =
-  sys::findProgramByName("ptxas", sys::path::parent_path(LinkerExecutable));
+  sys::findProgramByName("ptxas", {CudaBinaryPath});
   if (!PtxasPath)
 PtxasPath = sys::findProgramByName("ptxas");
   if (!PtxasPath)
@@ -554,7 +561,10 @@
 Expected link(ArrayRef InputFiles, Triple TheTriple,
StringRef Arch) {
   // NVPTX uses the nvlink binary to link device object files.
-  ErrorOr NvlinkPath = sys::findProgramByName("nvlink");
+  ErrorOr NvlinkPath =
+  sys::findProgramByName("nvlink", {CudaBinaryPath});
+  if (!NvlinkPath)
+NvlinkPath = sys::findProgramByName("nvlink");
   if (!NvlinkPath)
 return createStringError(NvlinkPath.getError(),
  "Unable to find 'nvlink' in path");
@@ -1097,6 +1107,9 @@
 return EXIT_FAILURE;
   };
 
+  if (!CudaPath.empty())
+CudaBinaryPath = CudaPath + "/bin";
+
   ExecutableName = *(llvm::find(HostLinkerArgs, "-o") + 1);
   SmallVector LinkerArgs;
   for (const std::string  : HostLinkerArgs)
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -8148,11 +8148,25 @@
  const InputInfoList ,
  const ArgList ,
  const char *LinkingOutput) const {
+  const Driver  = getToolChain().getDriver();
+  const llvm::Triple TheTriple = getToolChain().getTriple();
+  auto OpenMPTCRange = C.getOffloadToolChains();
   ArgStringList CmdArgs;
 
-  if (getToolChain().getDriver().isUsingLTO(/* IsOffload */ true)) {
+  // Pass the CUDA path to the linker wrapper tool.
+  for (auto  : llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
+const ToolChain *TC = I.second;
+if (TC->getTriple().isNVPTX()) {
+  CudaInstallationDetector CudaInstallation(D, TheTriple, Args);
+  if (CudaInstallation.isValid())
+CmdArgs.push_back(Args.MakeArgString(
+"--cuda-path=" + CudaInstallation.getInstallPath()));
+  break;
+}
+  }
+
+  if (D.isUsingLTO(/* IsOffload */ true)) {
 // Pass in target features for each toolchain.
-auto OpenMPTCRange = C.getOffloadToolChains();
 for (auto  :
  llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
   const ToolChain *TC = I.second;
@@ -8165,9 +8179,10 @@
 }
 
 // Pass in the bitcode library to be linked during LTO.
-for (auto  : llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
+for (auto  :
+ llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
   const ToolChain *TC = I.second;
-  const Driver  = TC->getDriver();
+  const Driver  = 

[clang] 8cc4ca9 - [OpenMP] Add Cuda path to linker wrapper tool

2022-02-03 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-02-03T20:39:18-05:00
New Revision: 8cc4ca95b02bc5b5b668b3d537b45a6585575cba

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

LOG: [OpenMP] Add Cuda path to linker wrapper tool

The linker wrapper tool uses the 'nvlink' and 'ptxas' binaries to link
and assemble device files. Previously we searched for this using the
binaries in the user's path. This didn't work in cases where the user
passed in a specific Cuda path to Clang. This patch changes the linker
wrapper to accept an argument for the Cuda path we can get from Clang.
This should fix #53573.

Reviewed By: tianshilei1992

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 7aac977209eba..5b2984ea2496f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -8148,11 +8148,25 @@ void LinkerWrapper::ConstructJob(Compilation , const 
JobAction ,
  const InputInfoList ,
  const ArgList ,
  const char *LinkingOutput) const {
+  const Driver  = getToolChain().getDriver();
+  const llvm::Triple TheTriple = getToolChain().getTriple();
+  auto OpenMPTCRange = C.getOffloadToolChains();
   ArgStringList CmdArgs;
 
-  if (getToolChain().getDriver().isUsingLTO(/* IsOffload */ true)) {
+  // Pass the CUDA path to the linker wrapper tool.
+  for (auto  : llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
+const ToolChain *TC = I.second;
+if (TC->getTriple().isNVPTX()) {
+  CudaInstallationDetector CudaInstallation(D, TheTriple, Args);
+  if (CudaInstallation.isValid())
+CmdArgs.push_back(Args.MakeArgString(
+"--cuda-path=" + CudaInstallation.getInstallPath()));
+  break;
+}
+  }
+
+  if (D.isUsingLTO(/* IsOffload */ true)) {
 // Pass in target features for each toolchain.
-auto OpenMPTCRange = C.getOffloadToolChains();
 for (auto  :
  llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
   const ToolChain *TC = I.second;
@@ -8165,9 +8179,10 @@ void LinkerWrapper::ConstructJob(Compilation , const 
JobAction ,
 }
 
 // Pass in the bitcode library to be linked during LTO.
-for (auto  : llvm::make_range(OpenMPTCRange.first, 
OpenMPTCRange.second)) {
+for (auto  :
+ llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
   const ToolChain *TC = I.second;
-  const Driver  = TC->getDriver();
+  const Driver  = TC->getDriver();
   const ArgList  = C.getArgsForToolChain(TC, "", 
Action::OFK_OpenMP);
   StringRef Arch = TCArgs.getLastArgValue(options::OPT_march_EQ);
 
@@ -8182,7 +8197,7 @@ void LinkerWrapper::ConstructJob(Compilation , const 
JobAction ,
   BitcodeSuffix += Arch;
 
   ArgStringList BitcodeLibrary;
-  addOpenMPDeviceRTL(D, TCArgs, BitcodeLibrary, BitcodeSuffix,
+  addOpenMPDeviceRTL(TCDriver, TCArgs, BitcodeLibrary, BitcodeSuffix,
  TC->getTriple());
 
   if (!BitcodeLibrary.empty())
@@ -8210,12 +8225,8 @@ void LinkerWrapper::ConstructJob(Compilation , const 
JobAction ,
 }
   }
 
-  // Construct the link job so we can wrap around it.
-  Linker->ConstructJob(C, JA, Output, Inputs, Args, LinkingOutput);
-  const auto  = C.getJobs().getJobs().back();
-
   CmdArgs.push_back("-host-triple");
-  CmdArgs.push_back(Args.MakeArgString(getToolChain().getTripleString()));
+  CmdArgs.push_back(Args.MakeArgString(TheTriple.getTriple()));
   if (Args.hasArg(options::OPT_v))
 CmdArgs.push_back("-v");
 
@@ -8246,6 +8257,10 @@ void LinkerWrapper::ConstructJob(Compilation , const 
JobAction ,
   if (Args.getLastArg(options::OPT_save_temps_EQ))
 CmdArgs.push_back("-save-temps");
 
+  // Construct the link job so we can wrap around it.
+  Linker->ConstructJob(C, JA, Output, Inputs, Args, LinkingOutput);
+  const auto  = C.getJobs().getJobs().back();
+
   // Add the linker arguments to be forwarded by the wrapper.
   CmdArgs.push_back("-linker-path");
   CmdArgs.push_back(LinkCommand->getExecutable());

diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 4ec4d6b134049..de0af187731d3 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -99,8 +99,8 @@ static cl::opt
 
 static cl::list
 PtxasArgs("ptxas-args", cl::ZeroOrMore,
-cl::desc("Argument to pass to the ptxas invocation"),

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

2022-02-03 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

In D110869#3295477 , @nathanchance 
wrote:

> It looks like `_paravirt_ident_64()` is the problematic function. This diff 
> on top of v5.17-rc2 allows me to boot:
>
>   diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
>   index 4420499f7bb4..c1b68504136c 100644
>   --- a/arch/x86/kernel/paravirt.c
>   +++ b/arch/x86/kernel/paravirt.c
>   @@ -96,7 +96,7 @@ static unsigned paravirt_patch_call(void *insn_buff, 
> const void *target,
>   
>#ifdef CONFIG_PARAVIRT_XXL
>/* identity function, which can be inlined */
>   -u64 notrace _paravirt_ident_64(u64 x)
>   +u64 notrace __attribute__((zero_call_used_regs("skip"))) 
> _paravirt_ident_64(u64 x)
>{
>   return x;
>}
>
> Rather interesting function to have problems with as a result of this patch 
> but it seems like this function is being used in a very specific way further 
> down the file with the `__PV_IS_CALLEE_SAVE` macro.

Weird. We generate similar code to GCC:

  Clang:
  _paravirt_ident_64: # @_paravirt_ident_64
  .Lfunc_begin2:
  .loc2 100 0 is_stmt 1   # 
arch/x86/kernel/paravirt.c:100:0
  .cfi_startproc
  # %bb.0:# %entry
  #DEBUG_VALUE: _paravirt_ident_64:x <- $rdi
  movq%rdi, %rax
  .Ltmp21:
  .loc2 101 2 prologue_end# 
arch/x86/kernel/paravirt.c:101:2
  xorq%rdi, %rdi
  .Ltmp22:
  #DEBUG_VALUE: _paravirt_ident_64:x <- $rax
  retq
  .Ltmp23:
  .Lfunc_end2:
  .size   _paravirt_ident_64, .Lfunc_end2-_paravirt_ident_64
  .cfi_endproc
  
  GCC:
  _paravirt_ident_64:
  # arch/x86/kernel/paravirt.c:100: {
  movq%rdi, %rax  # tmp85, x
  # arch/x86/kernel/paravirt.c:102: }
  xorl%edi, %edi  #
  ret
  .size   _paravirt_ident_64, .-_paravirt_ident_64

I'm a bit confused...


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] D116637: [Clang][Sema][OpenMP] Sema support for `atomic compare`

2022-02-03 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 405837.
tianshilei1992 added a comment.

add final test and fix comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116637

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/atomic_ast_print.cpp
  clang/test/OpenMP/atomic_messages.c
  clang/test/OpenMP/atomic_messages.cpp

Index: clang/test/OpenMP/atomic_messages.cpp
===
--- clang/test/OpenMP/atomic_messages.cpp
+++ clang/test/OpenMP/atomic_messages.cpp
@@ -1,10 +1,10 @@
 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 150 %s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -ferror-limit 150 %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp50,omp51 -fopenmp -fopenmp-version=51 -ferror-limit 150 %s -Wuninitialized
+// RUN: %clang_cc1 -DOMP51 -verify=expected,omp50,omp51 -fopenmp -fopenmp-version=51 -ferror-limit 150 %s -Wuninitialized
 
 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 150 %s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -ferror-limit 150 %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp50,omp51 -fopenmp-simd -fopenmp-version=51 -ferror-limit 150 %s -Wuninitialized
+// RUN: %clang_cc1 -DOMP51 -verify=expected,omp50,omp51 -fopenmp-simd -fopenmp-version=51 -ferror-limit 150 %s -Wuninitialized
 
 int foo() {
 L1:
@@ -914,6 +914,16 @@
 // expected-note@+1 2 {{'capture' clause used here}}
 #pragma omp atomic capture read
   a = ++b;
+#ifdef OMP51
+// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
+// expected-note@+1 2 {{'write' clause used here}}
+#pragma omp atomic write compare
+  a = b;
+// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
+// expected-note@+1 2 {{'read' clause used here}}
+#pragma omp atomic read compare
+  a = b;
+#endif
   return T();
 }
 
@@ -935,6 +945,16 @@
 // expected-note@+1 {{'write' clause used here}}
 #pragma omp atomic write capture
   a = b;
+#ifdef OMP51
+// expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
+// expected-note@+1 {{'write' clause used here}}
+#pragma omp atomic write compare
+  a = b;
+// expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
+// expected-note@+1 {{'read' clause used here}}
+#pragma omp atomic read compare
+  a = b;
+#endif
   // expected-note@+1 {{in instantiation of function template specialization 'mixed' requested here}}
   return mixed();
 }
Index: clang/test/OpenMP/atomic_messages.c
===
--- clang/test/OpenMP/atomic_messages.c
+++ clang/test/OpenMP/atomic_messages.c
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -DOMP51 -verify=expected,omp50,omp51 -fopenmp -fopenmp-version=51 -ferror-limit 100 %s -Wuninitialized
 
 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -DOMP51 -verify=expected,omp50,omp51 -fopenmp-simd -fopenmp-version=51 -ferror-limit 100 %s -Wuninitialized
 
 void xxx(int argc) {
   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
@@ -394,3 +396,92 @@
 #pragma omp atomic hint(1) hint(1) // omp45-error 2 {{unexpected OpenMP clause 'hint' in directive '#pragma omp atomic'}} expected-error {{directive '#pragma omp atomic' cannot contain more than one 'hint' clause}}
   a += 1;
 }
+
+#ifdef OMP51
+extern void bbar();
+extern int ffoo();
+
+void compare() {
+  int x = 0;
+  int d = 0;
+  int e = 0;
+// omp51-error@+3 {{the statement for 'atomic compare' must be a compound statement of form '{x = expr ordop x ? expr : x;}', '{x = x ordop expr? expr : x;}', '{x = x == e ? d : x;}', '{x = e == x ? d : x;}', or 'if(expr ordop x) {x = expr;}', 'if(x ordop expr) {x = expr;}', 'if(x == e) {x = d;}', 'if(e == x) {x = d;}' where 'x' is an lvalue expression with scalar type, 'expr', 'e', and 'd' are expressions with scalar type, and 'ordop' is one of '<' or '>'.}}
+// omp51-note@+2 {{expected compound statement}}
+#pragma omp atomic compare
+  {}
+// omp51-error@+3 {{the statement for 'atomic compare' must be a compound statement of form '{x = expr ordop x ? expr : x;}', 

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

2022-02-03 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

It looks like `_paravirt_ident_64()` is the problematic function. This diff on 
top of v5.17-rc2 allows me to boot:

  diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
  index 4420499f7bb4..c1b68504136c 100644
  --- a/arch/x86/kernel/paravirt.c
  +++ b/arch/x86/kernel/paravirt.c
  @@ -96,7 +96,7 @@ static unsigned paravirt_patch_call(void *insn_buff, const 
void *target,
  
   #ifdef CONFIG_PARAVIRT_XXL
   /* identity function, which can be inlined */
  -u64 notrace _paravirt_ident_64(u64 x)
  +u64 notrace __attribute__((zero_call_used_regs("skip"))) 
_paravirt_ident_64(u64 x)
   {
  return x;
   }

Rather interesting function to have problems with as a result of this patch but 
it seems like this function is being used in a very specific way further down 
the file with the `__PV_IS_CALLEE_SAVE` macro.


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] D116637: [Clang][Sema][OpenMP] Sema support for `atomic compare`

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



Comment at: clang/lib/Sema/SemaOpenMP.cpp:11206
+if (!E->isInstantiationDependent()) {
+  auto Type = E->getType();
+  if (!Type->isScalarType()) {

ABataev wrote:
> `QualType`
Do you mean by not using `auto`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116637

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


[PATCH] D116637: [Clang][Sema][OpenMP] Sema support for `atomic compare`

2022-02-03 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 405827.
tianshilei1992 marked an inline comment as done.
tianshilei1992 added a comment.

add more tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116637

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/atomic_ast_print.cpp
  clang/test/OpenMP/atomic_messages.c
  clang/test/OpenMP/atomic_messages.cpp

Index: clang/test/OpenMP/atomic_messages.cpp
===
--- clang/test/OpenMP/atomic_messages.cpp
+++ clang/test/OpenMP/atomic_messages.cpp
@@ -1,10 +1,10 @@
 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 150 %s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -ferror-limit 150 %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp50,omp51 -fopenmp -fopenmp-version=51 -ferror-limit 150 %s -Wuninitialized
+// RUN: %clang_cc1 -DOMP51 -verify=expected,omp50,omp51 -fopenmp -fopenmp-version=51 -ferror-limit 150 %s -Wuninitialized
 
 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 150 %s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -ferror-limit 150 %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp50,omp51 -fopenmp-simd -fopenmp-version=51 -ferror-limit 150 %s -Wuninitialized
+// RUN: %clang_cc1 -DOMP51 -verify=expected,omp50,omp51 -fopenmp-simd -fopenmp-version=51 -ferror-limit 150 %s -Wuninitialized
 
 int foo() {
 L1:
@@ -914,6 +914,16 @@
 // expected-note@+1 2 {{'capture' clause used here}}
 #pragma omp atomic capture read
   a = ++b;
+#ifdef OMP51
+// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
+// expected-note@+1 2 {{'write' clause used here}}
+#pragma omp atomic write compare
+  a = b;
+// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
+// expected-note@+1 2 {{'read' clause used here}}
+#pragma omp atomic read compare
+  a = b;
+#endif
   return T();
 }
 
@@ -935,6 +945,16 @@
 // expected-note@+1 {{'write' clause used here}}
 #pragma omp atomic write capture
   a = b;
+#ifdef OMP51
+// expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
+// expected-note@+1 {{'write' clause used here}}
+#pragma omp atomic write compare
+  a = b;
+// expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
+// expected-note@+1 {{'read' clause used here}}
+#pragma omp atomic read compare
+  a = b;
+#endif
   // expected-note@+1 {{in instantiation of function template specialization 'mixed' requested here}}
   return mixed();
 }
Index: clang/test/OpenMP/atomic_messages.c
===
--- clang/test/OpenMP/atomic_messages.c
+++ clang/test/OpenMP/atomic_messages.c
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -DOMP51 -verify=expected,omp50,omp51 -fopenmp -fopenmp-version=51 -ferror-limit 100 %s -Wuninitialized
 
 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+// RUN: %clang_cc1 -DOMP51 -verify=expected,omp50,omp51 -fopenmp-simd -fopenmp-version=51 -ferror-limit 100 %s -Wuninitialized
 
 void xxx(int argc) {
   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
@@ -394,3 +396,82 @@
 #pragma omp atomic hint(1) hint(1) // omp45-error 2 {{unexpected OpenMP clause 'hint' in directive '#pragma omp atomic'}} expected-error {{directive '#pragma omp atomic' cannot contain more than one 'hint' clause}}
   a += 1;
 }
+
+#ifdef OMP51
+extern void bbar();
+extern int ffoo();
+
+void compare() {
+  int x = 0;
+  int d = 0;
+  int e = 0;
+// omp51-error@+3 {{the statement for 'atomic compare' must be a compound statement of form '{x = expr ordop x ? expr : x;}', '{x = x ordop expr? expr : x;}', '{x = x == e ? d : x;}', '{x = e == x ? d : x;}', or 'if(expr ordop x) {x = expr;}', 'if(x ordop expr) {x = expr;}', 'if(x == e) {x = d;}', 'if(e == x) {x = d;}' where 'x' is an lvalue expression with scalar type, 'expr', 'e', and 'd' are expressions with scalar type, and 'ordop' is one of '<' or '>'.}}
+// omp51-note@+2 {{expected compound statement}}
+#pragma omp atomic compare
+  {}
+// omp51-error@+3 {{the statement for 'atomic compare' must be a compound statement of form 

[PATCH] D118890: [clang][deps] Disable global module index

2022-02-03 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

lgtm. I agree that testing this isn't really necessary given the difficulty of 
even constructing one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118890

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


[PATCH] D118915: [clang][deps] Generate '-fmodule-file=' only for direct dependencies

2022-02-03 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese 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/D118915/new/

https://reviews.llvm.org/D118915

___
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-03 Thread Steffen Larsen via Phabricator via cfe-commits
steffenlarsen marked 3 inline comments as done.
steffenlarsen added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:421-424
+  // Parse variadic identifier arg. This can either consume identifiers or
+  // expressions.
+  // FIXME: Variadic identifier args do not currently support parameter
+  //packs.

aaron.ballman wrote:
> steffenlarsen wrote:
> > aaron.ballman wrote:
> > > (Might need to re-flow comments to 80 col.) I don't think this is a FIXME 
> > > so much as a "this just doesn't work like that" situation.
> > I think it makes sense to have it be a FIXME because in theory it could be 
> > possible to have expression parameter packs expanded in an identifier list 
> > as it accepts expressions. I have reworded it slightly. Do you think this 
> > is better?
> Maybe we're thinking about identifier lists differently. We only have two 
> attributes that use those (`cpu_specific` and `cpu_dispatch`) and in both 
> cases (and all cases I would expect), what's being received is effectively a 
> list of enumerators (not enumerators in the C or C++ sense) that could not be 
> mixed with expressions. Expressions would go through sema and do all the 
> usual lookup work to turn them into a value, but these are not real objects 
> and so the lookup would fail for them. e.g., we're not going to be able to 
> support something like: `[[clang::cpu_specific(generic, pentium, Ts..., 
> atom)]]`. So I don't think there's anything here to be fixed (I prefer my 
> comment formulation as that makes it more clear).
I see what you mean. I have applied your wording instead.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4203
+  if (AllArgs.size() && AllArgs[0]->isValueDependent()) {
+auto *Attr = AnnotateAttr::CreateWithDelayedArgs(
+S.getASTContext(), AllArgs.data(), AllArgs.size(), AL);

aaron.ballman wrote:
> erichkeane wrote:
> > aaron.ballman wrote:
> > > erichkeane wrote:
> > > > I would like @aaron.ballman to comment on this, but I think we probably 
> > > > want this case to be covered in the top of `HandleDeclAttr`, which 
> > > > would mean in the 'not all values filled' case, we skip the 
> > > > 'handleAnnotateAttr'.  
> > > > 
> > > > WDYT Aaron?  The downside is that this function couldn't check a 
> > > > 'partially filled in' attribute, but it would make us that much closer 
> > > > to this flag being a very simple thing to opt into.
> > > Do you mean `ProcessDeclAttribute()`? I don't think we should have 
> > > attribute-specific logic in there, but are you thinking of something more 
> > > general than that (I'm not seeing how the suggestion makes the flag 
> > > easier to opt into)?
> > Ah, yes, thats what I mean.  The question for ME is whether there should be 
> > a generic "this supports variadic pack, so check to see if all the named 
> > non-expr arguments are fill-in-able.  If not, do the 'delayed' version.
> > 
> > This would mean that HandleAnnotateAttr NEVER sees the 
> > "CreateWithDelayedArgs" case.
> Thanks for clarifying -- yes, I think that would be preferable if it works 
> out in a clean, generic way. I'd be fine with tablegen emitting something 
> else (if necessary) to help generalize it.
`handleAnnotateAttr` is now oblivious to the concept of "delayed arguments". 
Instead tablegen generates a common handle function 
(`handleAttrWithDelayedArgs`) which will, based on the given `ParsedAttr` that 
supports delayed arguments, create and add the corresponding attribute with 
delayed arguments by calling the corresponding `CreateWithDelayedArgs`. The 
need for delaying arguments is decided as described in 
`MustDelayAttributeArguments`.

Is this approximately what you were thinking?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4179-4182
+  if (AllArgs.size() < 1) {
+Diag(CI.getLoc(), diag::err_attribute_too_few_arguments) << CI << 1;
+return;
+  }

aaron.ballman wrote:
> Please double-check that the call to `checkCommonAttributeFeatures()` from 
> `ProcessDeclAttribute()` doesn't already handle this for you. If it does, 
> then I think this can be replaced with `assert(!AllArgs.empty() && "expected 
> at least one argument");`
It does go through `checkCommonAttributeFeatures` but (as of the recent 
changes) it will skip size-checks if arguments are delayed as a pack expansion 
could potentially populate the seemingly missing expressions after template 
instantiation for some attribute.
For annotate we could also have a pack as the only expression, which would then 
evaluate to an empty list of expressions. Since this path is also taken by 
`instantiateDependentAnnotationAttr` if there are delayed args. In reality it 
is only really needed after template instantiations, given as you said 
`checkCommonAttributeFeatures` will do the checking in the other case, but I 
personally think it is cleaner to have it here. If you disagree I will 

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

2022-02-03 Thread Steffen Larsen via Phabricator via cfe-commits
steffenlarsen updated this revision to Diff 405820.
steffenlarsen added a comment.

Adjusted for comments and introduced common handling for creating attributes 
with delayed arguments.


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

https://reviews.llvm.org/D114439

Files:
  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

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -202,9 +202,9 @@
 bool Fake;
 
   public:
-Argument(const Record , StringRef Attr)
-: lowerName(std::string(Arg.getValueAsString("Name"))),
-  upperName(lowerName), attrName(Attr), isOpt(false), Fake(false) {
+Argument(StringRef Arg, StringRef Attr)
+: lowerName(std::string(Arg)), upperName(lowerName), attrName(Attr),
+  isOpt(false), Fake(false) {
   if (!lowerName.empty()) {
 lowerName[0] = std::tolower(lowerName[0]);
 upperName[0] = std::toupper(upperName[0]);
@@ -215,6 +215,8 @@
   if (lowerName == "interface")
 lowerName = "interface_";
 }
+Argument(const Record , StringRef Attr)
+: Argument(Arg.getValueAsString("Name"), Attr) {}
 virtual ~Argument() = default;
 
 StringRef getLowerName() const { return lowerName; }
@@ -666,6 +668,11 @@
   ArgName(getLowerName().str() + "_"), ArgSizeName(ArgName + "Size"),
   RangeName(std::string(getLowerName())) {}
 
+VariadicArgument(StringRef Arg, StringRef Attr, std::string T)
+: Argument(Arg, Attr), Type(std::move(T)),
+  ArgName(getLowerName().str() + "_"), ArgSizeName(ArgName + "Size"),
+  RangeName(std::string(getLowerName())) {}
+
 const std::string () const { return Type; }
 const std::string () const { return ArgName; }
 const std::string () const { return ArgSizeName; }
@@ -688,6 +695,18 @@
  << "); }\n";
 }
 
+void writeSetter(raw_ostream ) const {
+  OS << "  void set" << getUpperName() << "(ASTContext , ";
+  writeCtorParameters(OS);
+  OS << ") {\n";
+  OS << "" << ArgSizeName << " = " << getUpperName() << "Size;\n";
+  OS << "" << ArgName << " = new (Ctx, 16) " << getType() << "["
+ << ArgSizeName << "];\n";
+  OS << "  ";
+  writeCtorBody(OS);
+  OS << "  }\n";
+}
+
 void writeCloneArgs(raw_ostream ) const override {
   OS << ArgName << ", " << ArgSizeName;
 }
@@ -1169,6 +1188,9 @@
   : VariadicArgument(Arg, Attr, "Expr *")
 {}
 
+VariadicExprArgument(StringRef ArgName, StringRef Attr)
+: VariadicArgument(ArgName, Attr, "Expr *") {}
+
 void writeASTVisitorTraversal(raw_ostream ) const override {
   OS << "  {\n";
   OS << "" << getType() << " *I = A->" << getLowerName()
@@ -2138,6 +2160,11 @@
   }
 }
 
+static bool isTypeArgument(const Record *Arg) {
+  return !Arg->getSuperClasses().empty() &&
+ Arg->getSuperClasses().back().first->getName() == "TypeArgument";
+}
+
 /// Emits the first-argument-is-type property for attributes.
 static void emitClangAttrTypeArgList(RecordKeeper , raw_ostream ) {
   OS << "#if defined(CLANG_ATTR_TYPE_ARG_LIST)\n";
@@ -2149,7 +2176,7 @@
 if (Args.empty())
   continue;
 
-if (Args[0]->getSuperClasses().back().first->getName() != "TypeArgument")
+if (!isTypeArgument(Args[0]))
   continue;
 
 // All these spellings take a single type argument.
@@ -2179,7 +2206,7 @@
   OS << "#endif // CLANG_ATTR_ARG_CONTEXT_LIST\n\n";
 }
 
-static bool isIdentifierArgument(Record *Arg) {
+static bool isIdentifierArgument(const Record *Arg) {
   return !Arg->getSuperClasses().empty() &&
 llvm::StringSwitch(Arg->getSuperClasses().back().first->getName())
 .Case("IdentifierArgument", true)
@@ -2188,7 +2215,7 @@
 .Default(false);
 }
 
-static bool isVariadicIdentifierArgument(Record *Arg) {
+static bool isVariadicIdentifierArgument(const Record *Arg) {
   return !Arg->getSuperClasses().empty() &&
  llvm::StringSwitch(
  Arg->getSuperClasses().back().first->getName())
@@ -2264,6 +2291,26 @@
   OS << "#endif // CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST\n\n";
 }
 
+static void emitClangAttrAcceptsExprPack(RecordKeeper ,
+ raw_ostream ) {
+  OS << "#if 

[PATCH] D118944: [OpenMP] Add Cuda path to linker wrapper tool

2022-02-03 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 accepted this revision.
tianshilei1992 added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118944

___
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-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: lld/ELF/SyntheticSections.cpp:3871
+  return sizeof(llvm::ELF::Elf64_Nhdr) +
+ /* namesz */ sizeof(kMemtagAndroidNoteName) +
+ /* descsz */ sizeof(uint32_t);

`/*namesz=*/`



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;

`/*alignment=*/4`



Comment at: lld/ELF/Writer.cpp:367
+if (config->emachine == EM_AARCH64 &&
+config->memtagMode != llvm::ELF::NT_MEMTAG_LEVEL_DEFAULT) {
+  part.memtagAndroidNote = std::make_unique();




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-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

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




Comment at: lld/ELF/SyntheticSections.cpp:3842
 
+static constexpr char kMemtagAndroidNoteName[] = "Android";
+void MemtagAndroidNote::writeTo(uint8_t *buf) {





Comment at: lld/ELF/SyntheticSections.cpp:3846
+  llvm::ELF::Elf64_Nhdr header;
+  header.n_namesz = sizeof(kMemtagAndroidNoteName);
+  header.n_descsz = sizeof(uint32_t);

See `GnuPropertySection::writeTo`



Comment at: lld/ELF/SyntheticSections.h:1235
   std::unique_ptr verSym;
+  std::unique_ptr memtagAndroidNote;
 

keep variable names alphabetically



Comment at: lld/test/ELF/memtag-android-abi.s:1
+// 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

REQUIRES: aarch64

Use `#` for comments. Rename this to `aarch64-*`



Comment at: lld/test/ELF/memtag-android-abi.s:19
+// RUN: llvm-readelf -S %t | FileCheck %s
+// RUN: llvm-objdump -Dz -j .note.android.memtag %t | \
+// RUN:FileCheck %s --check-prefixes=NOTE,SYNC-NOTE

use `llvm-readelf -x .note.android.memtag` to dump the bytes of a section.

If this is a note section, consider `llvm-readelf -n`



Comment at: llvm/include/llvm/BinaryFormat/ELF.h:1536
+enum {
+  NT_TYPE_IDENT = 1,
+  NT_TYPE_KUSER = 3,

If Android wants to define notes, can it use a namespace `NT_ANDROID_*` like 
GNU?

Please see `https://reviews.llvm.org/D107949` how I add ELF attributes and 
related tests when new additions are added to BinaryFormat/ELF.h


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] D116987: [clang][utils] Remove StringRef lldb summary provider

2022-02-03 Thread Dave Lee via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG65aa47301372: [clang][utils] Remove StringRef lldb summary 
provider (authored by kastiglione).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116987

Files:
  clang/utils/ClangDataFormat.py


Index: clang/utils/ClangDataFormat.py
===
--- clang/utils/ClangDataFormat.py
+++ clang/utils/ClangDataFormat.py
@@ -24,7 +24,6 @@
 def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand("type summary add -F 
ClangDataFormat.SourceLocation_summary clang::SourceLocation")
debugger.HandleCommand("type summary add -F 
ClangDataFormat.QualType_summary clang::QualType")
-   debugger.HandleCommand("type summary add -F 
ClangDataFormat.StringRef_summary llvm::StringRef")
 
 def SourceLocation_summary(srcloc, internal_dict):
return SourceLocation(srcloc).summary()
@@ -32,9 +31,6 @@
 def QualType_summary(qualty, internal_dict):
return QualType(qualty).summary()
 
-def StringRef_summary(strref, internal_dict):
-   return StringRef(strref).summary()
-
 class SourceLocation(object):
def __init__(self, srcloc):
self.srcloc = srcloc
@@ -79,23 +75,6 @@
return ""
return desc
 
-class StringRef(object):
-   def __init__(self, strref):
-   self.strref = strref
-   self.Data_value = strref.GetChildAtIndex(0)
-   self.Length = strref.GetChildAtIndex(1).GetValueAsUnsigned()
-
-   def summary(self):
-   if self.Length == 0:
-   return '""'
-   data = self.Data_value.GetPointeeData(0, self.Length)
-   error = lldb.SBError()
-   string = data.ReadRawData(error, 0, data.GetByteSize())
-   if error.Fail():
-   return None
-   return '"%s"' % string
-
-
 # Key is a (function address, type name) tuple, value is the expression path 
for
 # an object with such a type name from inside that function.
 FramePathMapCache = {}


Index: clang/utils/ClangDataFormat.py
===
--- clang/utils/ClangDataFormat.py
+++ clang/utils/ClangDataFormat.py
@@ -24,7 +24,6 @@
 def __lldb_init_module(debugger, internal_dict):
 	debugger.HandleCommand("type summary add -F ClangDataFormat.SourceLocation_summary clang::SourceLocation")
 	debugger.HandleCommand("type summary add -F ClangDataFormat.QualType_summary clang::QualType")
-	debugger.HandleCommand("type summary add -F ClangDataFormat.StringRef_summary llvm::StringRef")
 
 def SourceLocation_summary(srcloc, internal_dict):
 	return SourceLocation(srcloc).summary()
@@ -32,9 +31,6 @@
 def QualType_summary(qualty, internal_dict):
 	return QualType(qualty).summary()
 
-def StringRef_summary(strref, internal_dict):
-	return StringRef(strref).summary()
-
 class SourceLocation(object):
 	def __init__(self, srcloc):
 		self.srcloc = srcloc
@@ -79,23 +75,6 @@
 			return ""
 		return desc
 
-class StringRef(object):
-	def __init__(self, strref):
-		self.strref = strref
-		self.Data_value = strref.GetChildAtIndex(0)
-		self.Length = strref.GetChildAtIndex(1).GetValueAsUnsigned()
-
-	def summary(self):
-		if self.Length == 0:
-			return '""'
-		data = self.Data_value.GetPointeeData(0, self.Length)
-		error = lldb.SBError()
-		string = data.ReadRawData(error, 0, data.GetByteSize())
-		if error.Fail():
-			return None
-		return '"%s"' % string
-
-
 # Key is a (function address, type name) tuple, value is the expression path for
 # an object with such a type name from inside that function.
 FramePathMapCache = {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 65aa473 - [clang][utils] Remove StringRef lldb summary provider

2022-02-03 Thread Dave Lee via cfe-commits

Author: Dave Lee
Date: 2022-02-03T15:16:31-08:00
New Revision: 65aa47301372b0f46d69977eb87aec60976e8246

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

LOG: [clang][utils] Remove StringRef lldb summary provider

Remove the `StringRef` summary provider in favor of the implementation in
`llvm/utils/lldbDataFormatters.py`.

This implementation was resulting in errors in some cases.

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

Added: 


Modified: 
clang/utils/ClangDataFormat.py

Removed: 




diff  --git a/clang/utils/ClangDataFormat.py b/clang/utils/ClangDataFormat.py
index 38ef76b325354..2a5906db65848 100644
--- a/clang/utils/ClangDataFormat.py
+++ b/clang/utils/ClangDataFormat.py
@@ -24,7 +24,6 @@
 def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand("type summary add -F 
ClangDataFormat.SourceLocation_summary clang::SourceLocation")
debugger.HandleCommand("type summary add -F 
ClangDataFormat.QualType_summary clang::QualType")
-   debugger.HandleCommand("type summary add -F 
ClangDataFormat.StringRef_summary llvm::StringRef")
 
 def SourceLocation_summary(srcloc, internal_dict):
return SourceLocation(srcloc).summary()
@@ -32,9 +31,6 @@ def SourceLocation_summary(srcloc, internal_dict):
 def QualType_summary(qualty, internal_dict):
return QualType(qualty).summary()
 
-def StringRef_summary(strref, internal_dict):
-   return StringRef(strref).summary()
-
 class SourceLocation(object):
def __init__(self, srcloc):
self.srcloc = srcloc
@@ -79,23 +75,6 @@ def summary(self):
return ""
return desc
 
-class StringRef(object):
-   def __init__(self, strref):
-   self.strref = strref
-   self.Data_value = strref.GetChildAtIndex(0)
-   self.Length = strref.GetChildAtIndex(1).GetValueAsUnsigned()
-
-   def summary(self):
-   if self.Length == 0:
-   return '""'
-   data = self.Data_value.GetPointeeData(0, self.Length)
-   error = lldb.SBError()
-   string = data.ReadRawData(error, 0, data.GetByteSize())
-   if error.Fail():
-   return None
-   return '"%s"' % string
-
-
 # Key is a (function address, type name) tuple, value is the expression path 
for
 # an object with such a type name from inside that function.
 FramePathMapCache = {}



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


[PATCH] D116987: [clang][utils] Remove StringRef lldb summary provider

2022-02-03 Thread Dave Lee via Phabricator via cfe-commits
kastiglione added a comment.

The StringRef provider was improved in D117779 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116987

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


[PATCH] D118755: [clangd] Crash in __memcmp_avx2_movbe

2022-02-03 Thread Ivan Murashko via Phabricator via cfe-commits
ivanmurashko updated this revision to Diff 405814.
ivanmurashko added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118755

Files:
  clang-tools-extra/clangd/test/repeated_includes.test
  clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp


Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -333,7 +333,7 @@
 int Priority = Categories.getIncludePriority(
 CurInclude.Name, /*CheckMainHeader=*/FirstIncludeOffset < 0);
 CategoryEndOffsets[Priority] = NextLineOffset;
-IncludesByPriority[Priority].push_back();
+IncludesByPriority[Priority].push_back(CurInclude);
 if (FirstIncludeOffset < 0)
   FirstIncludeOffset = CurInclude.R.getOffset();
   }
@@ -361,9 +361,9 @@
   unsigned InsertOffset = CatOffset->second; // Fall back offset
   auto Iter = IncludesByPriority.find(Priority);
   if (Iter != IncludesByPriority.end()) {
-for (const auto *Inc : Iter->second) {
-  if (QuotedName < Inc->Name) {
-InsertOffset = Inc->R.getOffset();
+for (const auto  : Iter->second) {
+  if (QuotedName < Inc.Name) {
+InsertOffset = Inc.R.getOffset();
 break;
   }
 }
Index: clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
===
--- clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
+++ clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
@@ -105,8 +105,7 @@
   /// in the order they appear in the source file.
   /// See comment for "FormatStyle::IncludeCategories" for details about 
include
   /// priorities.
-  std::unordered_map>
-  IncludesByPriority;
+  std::unordered_map> IncludesByPriority;
 
   int FirstIncludeOffset;
   // All new headers should be inserted after this offset (e.g. after header
Index: clang-tools-extra/clangd/test/repeated_includes.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/repeated_includes.test
@@ -0,0 +1,33 @@
+# RUN: rm -rf %/t
+# RUN: mkdir -p %t && touch %t/t.h && touch %t/t2.h && touch %t/t3.h
+# RUN: echo '#pragma once' > %t/t.h
+# RUN: echo '#include "t2.h"' >> %t/t.h
+# RUN: echo 'void bar();' >> %t/t.h
+# RUN: echo '#pragma once' > %t/t2.h
+# RUN: echo 'void bar2();' >> %t/t2.h
+
+
+# Run clangd
+# RUN: clangd -lit-test -log error --path-mappings 'C:\client=%t' < %s | 
FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///C:/client/main.cpp","languageId":"cpp","version":1,"text":"#include
 \"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include 
\"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include 
\"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include 
\"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include 
\"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include 
\"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include 
\"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include 
\"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include 
\"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include 
\"t.h\"\n#include \"t.h\"\n#include \"t.h\"\n#include \"t.h\"\nbar();\n"}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///C:/client/main.cpp"},"position":{"line":40,"character":3}}}
+#  CHECK:  "id": 1
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": {
+# CHECK-NEXT:"isIncomplete": false,
+# CHECK-NEXT:"items": [
+# CHECK-NEXT:  {
+# CHECK-NEXT:"detail": "void",
+# CHECK-NEXT:"documentation": {
+# CHECK-NEXT:  "kind": "plaintext",
+# CHECK-NEXT:  "value": "From \"t.h\""
+# CHECK-NEXT:},
+# CHECK-NEXT:"filterText": "bar",
+# CHECK-NEXT:"insertText": "bar",
+---
+{"jsonrpc":"2.0","id":4,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}


Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -333,7 +333,7 @@
 int Priority = Categories.getIncludePriority(
 CurInclude.Name, /*CheckMainHeader=*/FirstIncludeOffset < 0);
 CategoryEndOffsets[Priority] = NextLineOffset;
-IncludesByPriority[Priority].push_back();
+IncludesByPriority[Priority].push_back(CurInclude);
 

[PATCH] D118949: [HIP] Support code object v5

2022-02-03 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Few nits, LGTM in general.




Comment at: clang/lib/Driver/ToolChains/ROCm.h:27
+struct DeviceLibABIVersion {
+  unsigned Value = 0;
+  DeviceLibABIVersion(unsigned V) : Value(V) {}

`ABIVersion`?



Comment at: clang/lib/Driver/ToolChains/ROCm.h:29
+  DeviceLibABIVersion(unsigned V) : Value(V) {}
+  static DeviceLibABIVersion fromCodeObjectVersion(unsigned V) {
+if (V < 4)

CodeObjectVersion



Comment at: clang/lib/Driver/ToolChains/ROCm.h:34-39
+  /// Whether ABI version bc file is requested.
+  bool requiresLibrary() { return Value >= 500; }
+  std::string toString() {
+assert(Value % 100 == 0 && "Not supported");
+return Twine(Value / 100).str();
+  }

This could use a comment on how code object version relates to the ABI version 
and what makes ABI version 500 special.


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

https://reviews.llvm.org/D118949

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


[PATCH] D118858: [OpenMP] Don't use bound architecture when checking cache on the host

2022-02-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D118858#3295210 , @thakis wrote:

> Looks like this breaks tests on Mac: http://45.33.8.238/macm1/27158/step_7.txt
>
> Please take a look and revert for now if it takes a while to fix.

Can you do me a favor and run the command `clang -### -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-new-driver -no-canonical-prefixes 
-ccc-print-bindings 
$HOME/Documents/code/llvm-project/clang/test/Driver/openmp-offload-gpu.c -o 
openmp-offload-gpu -fopenmp -fopenmp-targets=nvptx64 -fopenmp-new-driver 
-ccc-print-bindings`

  diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
  index 3bfddeefc7b2..cba9cecd7d5e 100644
  --- a/clang/lib/Driver/Driver.cpp
  +++ b/clang/lib/Driver/Driver.cpp
  @@ -4745,6 +4745,7 @@ InputInfoList Driver::BuildJobsForAction(
   Action::OffloadKind TargetDeviceOffloadKind) const {
 std::pair ActionTC = {
 A, GetTriplePlusArchString(TC, BoundArch, TargetDeviceOffloadKind)};
  +  llvm::errs() << "Insert: " << A << " " << TC->getTriple().getTriple() << " 
" << BoundArch << " " << TargetDeviceOffloadKind << "\n";
 auto CachedResult = CachedResults.find(ActionTC);
 if (CachedResult != CachedResults.end()) {
   return CachedResult->second;
  @@ -4831,6 +4832,7 @@ InputInfoList Driver::BuildJobsForActionNoCache(
   std::pair ActionTC = {
   OA->getHostDependence(),
   GetTriplePlusArchString(TC, BoundArch, TargetDeviceOffloadKind)};
  +  llvm::errs() << "Check: " << A << " " << TC->getTriple().getTriple() << " 
" << BoundArch << " " << TargetDeviceOffloadKind << "\n";
   if (CachedResults.find(ActionTC) != CachedResults.end()) {
 InputInfoList Inputs = CachedResults[ActionTC];
 Inputs.append(OffloadDependencesInputInfo);


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118858

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


[clang] da20df2 - Revert "[OpenMP] Don't use bound architecture when checking cache on the host"

2022-02-03 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-02-03T17:43:10-05:00
New Revision: da20df21157f316648447b21f2ce6cf79a5ef57c

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

LOG: Revert "[OpenMP] Don't use bound architecture when checking cache on the 
host"

This reverts commit 9138d96f8b01605b213e8c4d587853a46cca3f44.

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/test/Driver/openmp-offload-gpu.c

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 18dc6561b4d49..3bfddeefc7b2b 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4828,11 +4828,9 @@ InputInfoList Driver::BuildJobsForActionNoCache(
 
 // We may have already built this action as a part of the offloading
 // toolchain, return the cached input if so.
-StringRef Arch =
-(TargetDeviceOffloadKind == Action::OFK_Host) ? StringRef() : 
BoundArch;
 std::pair ActionTC = {
 OA->getHostDependence(),
-GetTriplePlusArchString(TC, Arch, TargetDeviceOffloadKind)};
+GetTriplePlusArchString(TC, BoundArch, TargetDeviceOffloadKind)};
 if (CachedResults.find(ActionTC) != CachedResults.end()) {
   InputInfoList Inputs = CachedResults[ActionTC];
   Inputs.append(OffloadDependencesInputInfo);

diff  --git a/clang/test/Driver/openmp-offload-gpu.c 
b/clang/test/Driver/openmp-offload-gpu.c
index a9fc3e7b33a42..af7ba7c802e5d 100644
--- a/clang/test/Driver/openmp-offload-gpu.c
+++ b/clang/test/Driver/openmp-offload-gpu.c
@@ -358,8 +358,6 @@
 // NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "clang", inputs: ["[[HOST_INPUT:.+]]"], 
output: "[[HOST_BC:.+]]" 
 // NEW_DRIVER: "nvptx64-nvidia-cuda" - "clang", inputs: 
["[[DEVICE_INPUT:.+]]", "[[HOST_BC]]"], output: "[[DEVICE_ASM:.+]]"
 // NEW_DRIVER: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: 
["[[DEVICE_ASM]]"], output: "[[DEVICE_OBJ:.+]]" 
-// NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "clang", inputs: ["[[HOST_BC]]", 
"[[DEVICE_OBJ]]"], output: "[[HOST_OBJ:.+]]" 
-// NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "[[LINKER:.+]]", inputs: 
["[[HOST_OBJ]]"], output: "openmp-offload-gpu"
 
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target=nvptx64-nvida-cuda -march=sm_70 \
 // RUN:  
--libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-new-nvptx-test.bc
 \



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


[PATCH] D118858: [OpenMP] Don't use bound architecture when checking cache on the host

2022-02-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D118858#3295210 , @thakis wrote:

> Looks like this breaks tests on Mac: http://45.33.8.238/macm1/27158/step_7.txt
>
> Please take a look and revert for now if it takes a while to fix.

This fixed it on the mac I got to test it on, I'll revert and try to figure it 
out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118858

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


[PATCH] D118858: [OpenMP] Don't use bound architecture when checking cache on the host

2022-02-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests on Mac: http://45.33.8.238/macm1/27158/step_7.txt

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118858

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


[PATCH] D118949: [HIP] Support code object v5

2022-02-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, b-sumner.
Herald added subscribers: dang, kerbowa, jvesely.
yaxunl requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

New device library supporting v4 and v5 has abi_version_400.bc and 
abi_version_500.bc.

For v5, abi_version_500.bc is linked.

For v2-4, abi_version_400.bc is linked.

For old device library, for v2-4, none of the above is linked. For v5, error is 
emitted about unsupported ABI version.


https://reviews.llvm.org/D118949

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/ROCm.h
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/asanrtl.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/hip.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/ockl.bc
  
clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/oclc_correctly_rounded_sqrt_off.bc
  
clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/oclc_correctly_rounded_sqrt_on.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/oclc_daz_opt_off.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/oclc_daz_opt_on.bc
  
clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/oclc_finite_only_off.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/oclc_finite_only_on.bc
  
clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/oclc_isa_version_1010.bc
  
clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/oclc_isa_version_1011.bc
  
clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/oclc_isa_version_1012.bc
  
clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/oclc_isa_version_803.bc
  
clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/oclc_isa_version_900.bc
  
clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/oclc_isa_version_908.bc
  
clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/oclc_unsafe_math_off.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/oclc_unsafe_math_on.bc
  
clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/oclc_wavefrontsize64_off.bc
  
clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/oclc_wavefrontsize64_on.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/ocml.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode-no-abi-ver/opencl.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/abi_version_400.bc
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/abi_version_500.bc
  clang/test/Driver/hip-code-object-version.hip
  clang/test/Driver/hip-device-libs.hip

Index: clang/test/Driver/hip-device-libs.hip
===
--- clang/test/Driver/hip-device-libs.hip
+++ clang/test/Driver/hip-device-libs.hip
@@ -137,6 +137,49 @@
 // RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s --check-prefixes=DIVSQRT
 
+// Test default code object version.
+// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx900 \
+// RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ABI4
+
+// Test default code object version with old device library without abi_version_400.bc
+// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx900 \
+// RUN:   --hip-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode-no-abi-ver   \
+// RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=NOABI4
+
+// Test -mcode-object-version=3
+// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx900 \
+// RUN:   -mcode-object-version=3 \
+// RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ABI4
+
+// Test -mcode-object-version=4
+// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx900 \
+// RUN:   -mcode-object-version=4 \
+// RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ABI4
+
+// Test -mcode-object-version=4 with old device library without abi_version_400.bc
+// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx900 \
+// RUN:   -mcode-object-version=4 \
+// RUN:   --hip-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode-no-abi-ver   \
+// RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=NOABI4
+
+// Test -mcode-object-version=5
+// RUN: %clang -### -target x86_64-linux-gnu --offload-arch=gfx900 \
+// RUN:   -mcode-object-version=5 \
+// RUN:   --rocm-path=%S/Inputs/rocm %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ABI5
+
+// Test -mcode-object-version=5 with old device library without abi_version_400.bc
+// RUN: %clang -### -target 

[PATCH] D118944: [OpenMP] Add Cuda path to linker wrapper tool

2022-02-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 405799.
jhuber6 added a comment.

Use long version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118944

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -99,8 +99,8 @@
 
 static cl::list
 PtxasArgs("ptxas-args", cl::ZeroOrMore,
-cl::desc("Argument to pass to the ptxas invocation"),
-cl::cat(ClangLinkerWrapperCategory));
+  cl::desc("Argument to pass to the ptxas invocation"),
+  cl::cat(ClangLinkerWrapperCategory));
 
 static cl::opt Verbose("v", cl::ZeroOrMore,
  cl::desc("Verbose output from tools"),
@@ -118,6 +118,10 @@
cl::desc("Save intermediary results."),
cl::cat(ClangLinkerWrapperCategory));
 
+static cl::opt CudaPath("cuda-path", cl::ZeroOrMore,
+ cl::desc("Save intermediary results."),
+ cl::cat(ClangLinkerWrapperCategory));
+
 // Do not parse linker options.
 static cl::list
 HostLinkerArgs(cl::Positional,
@@ -129,6 +133,9 @@
 /// Filename of the executable being created.
 static StringRef ExecutableName;
 
+/// Binary path for the CUDA installation.
+static std::string CudaBinaryPath;
+
 /// Temporary files created by the linker wrapper.
 static SmallVector TempFiles;
 
@@ -507,9 +514,9 @@
 namespace nvptx {
 Expected assemble(StringRef InputFile, Triple TheTriple,
StringRef Arch) {
-  // NVPTX uses the nvlink binary to link device object files.
+  // NVPTX uses the ptxas binary to create device object files.
   ErrorOr PtxasPath =
-  sys::findProgramByName("ptxas", sys::path::parent_path(LinkerExecutable));
+  sys::findProgramByName("ptxas", {CudaBinaryPath});
   if (!PtxasPath)
 PtxasPath = sys::findProgramByName("ptxas");
   if (!PtxasPath)
@@ -554,7 +561,10 @@
 Expected link(ArrayRef InputFiles, Triple TheTriple,
StringRef Arch) {
   // NVPTX uses the nvlink binary to link device object files.
-  ErrorOr NvlinkPath = sys::findProgramByName("nvlink");
+  ErrorOr NvlinkPath =
+  sys::findProgramByName("nvlink", {CudaBinaryPath});
+  if (!NvlinkPath)
+NvlinkPath = sys::findProgramByName("nvlink");
   if (!NvlinkPath)
 return createStringError(NvlinkPath.getError(),
  "Unable to find 'nvlink' in path");
@@ -1097,6 +1107,9 @@
 return EXIT_FAILURE;
   };
 
+  if (!CudaPath.empty())
+CudaBinaryPath = CudaPath + "/bin";
+
   ExecutableName = *(llvm::find(HostLinkerArgs, "-o") + 1);
   SmallVector LinkerArgs;
   for (const std::string  : HostLinkerArgs)
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -8148,11 +8148,25 @@
  const InputInfoList ,
  const ArgList ,
  const char *LinkingOutput) const {
+  const Driver  = getToolChain().getDriver();
+  const llvm::Triple TheTriple = getToolChain().getTriple();
+  auto OpenMPTCRange = C.getOffloadToolChains();
   ArgStringList CmdArgs;
 
-  if (getToolChain().getDriver().isUsingLTO(/* IsOffload */ true)) {
+  // Pass the CUDA path to the linker wrapper tool.
+  for (auto  : llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
+const ToolChain *TC = I.second;
+if (TC->getTriple().isNVPTX()) {
+  CudaInstallationDetector CudaInstallation(D, TheTriple, Args);
+  if (CudaInstallation.isValid())
+CmdArgs.push_back(Args.MakeArgString(
+"--cuda-path=" + CudaInstallation.getInstallPath()));
+  break;
+}
+  }
+
+  if (D.isUsingLTO(/* IsOffload */ true)) {
 // Pass in target features for each toolchain.
-auto OpenMPTCRange = C.getOffloadToolChains();
 for (auto  :
  llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
   const ToolChain *TC = I.second;
@@ -8165,9 +8179,10 @@
 }
 
 // Pass in the bitcode library to be linked during LTO.
-for (auto  : llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
+for (auto  :
+ llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
   const ToolChain *TC = I.second;
-  const Driver  = TC->getDriver();
+  const Driver  = TC->getDriver();
   const ArgList  = C.getArgsForToolChain(TC, "", Action::OFK_OpenMP);
   StringRef Arch = 

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

2022-02-03 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

In D110869#3295147 , @nathanchance 
wrote:

> 



> I tested this patch but it did not change the hang.

Okay. We need to determine which function is failing. Could you do something 
like this:

  #define zcur __attribute__((zero_call_used_regs("used-gpr")))

and then add `zcur` to each function, while compiling the module with 
`-fzero-call-used-regs=skip`. Then remove the `zcur` attribute from functions 
until it works? I know it's a PITA, but otherwise I'm just guessing at which 
function's causing the failure...


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] D118948: [MTE] Add -fsanitize=memtag* and friends.

2022-02-03 Thread Mitch Phillips via Phabricator via cfe-commits
hctim created this revision.
hctim added a reviewer: eugenis.
Herald added subscribers: dexonsmith, dang, arichardson, emaste.
Herald added a reviewer: MaskRay.
hctim requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Currently, enablement of heap MTE on Android is specified by an ELF note, which
signals to the linker to enable heap MTE. This change allows
-fsanitize=memtag-heap to synthesize these notes, rather than adding them
through the build system. We need to extend this feature to also signal the
linker to do special work for MTE globals (in future) and MTE stack (currently
implemented in the toolchain, but not implemented in the loader).

Current Android uses a non-backwards-compatible ELF note, called
".note.android.memtag". Stack MTE is an ABI break anyway, so we don't mind that
we won't be able to run executables with stack MTE on Android 11/12 devices.

The current expectation is to support the verbiage used by Android, in
that "SYNC" means MTE Synchronous mode, and "ASYNC" effectively means
"fast", using the Kernel auto-upgrade feature that allows
hardware-specific and core-specific configuration as to whether "ASYNC"
would end up being Asynchronous, Asymmetric, or Synchronous on that
particular core, whichever has a reasonable performance delta. Of
course, this is platform and loader-specific.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118948

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.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/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/CodeGen/memtag-attr.cpp
  clang/test/Driver/fsanitize.c
  clang/test/Driver/memtag-ld.c
  clang/test/Driver/memtag-stack.c
  clang/test/Driver/memtag.c
  clang/test/Lexer/has_feature_memtag_heap.cpp
  clang/test/Lexer/has_feature_memtag_sanitizer.cpp
  clang/test/Lexer/has_feature_memtag_stack.cpp
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/Options.td
  lld/ELF/SyntheticSections.cpp
  lld/ELF/SyntheticSections.h
  lld/ELF/Writer.cpp
  lld/test/ELF/memtag-android-abi.s
  llvm/include/llvm/BinaryFormat/ELF.h

Index: llvm/include/llvm/BinaryFormat/ELF.h
===
--- llvm/include/llvm/BinaryFormat/ELF.h
+++ llvm/include/llvm/BinaryFormat/ELF.h
@@ -1531,6 +1531,22 @@
   NT_GNU_PROPERTY_TYPE_0 = 5,
 };
 
+// Android note types.
+enum {
+  NT_TYPE_IDENT = 1,
+  NT_TYPE_KUSER = 3,
+  NT_TYPE_MEMTAG = 4,
+};
+
+enum {
+  NT_MEMTAG_LEVEL_DEFAULT = 0,
+  NT_MEMTAG_LEVEL_ASYNC = 1,
+  NT_MEMTAG_LEVEL_SYNC = 2,
+  NT_MEMTAG_LEVEL_MASK = 3,
+  NT_MEMTAG_HEAP = 4,
+  NT_MEMTAG_STACK = 8,
+};
+
 // Property types used in GNU_PROPERTY_TYPE_0 notes.
 enum : unsigned {
   GNU_PROPERTY_STACK_SIZE = 1,
Index: lld/test/ELF/memtag-android-abi.s
===
--- /dev/null
+++ lld/test/ELF/memtag-android-abi.s
@@ -0,0 +1,63 @@
+// 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
+// the ABI" check. Basically below is the copied version of the Android parsing
+// logic. We create a no-op aarch64 binary with an elf note, and then consume it
+// using the parsing logic on the host system. Because we don't pull in any
+// libraries or headers, this should be runnable on any system that uses linux
+// (technically, any system that can parse ELF, but I'm not rewriting it in
+// python to run on Windows...). Note that MTE stack is an ABI break, so we
+// expect it to crash under this parsing logic.
+
+// RUN: llvm-mc --filetype=obj -triple=aarch64-linux-none-gnu %s -o %t.o
+// RUN: ld.lld --memtag-mode=async %t.o -o %t
+// RUN: llvm-readelf -S %t | FileCheck %s
+// RUN: llvm-objdump -Dz -j .note.android.memtag %t | \
+// RUN:FileCheck %s --check-prefixes=NOTE,ASYNC-NOTE
+
+// RUN: ld.lld --memtag-mode=sync %t.o -o %t
+// RUN: llvm-readelf -S %t | FileCheck %s
+// RUN: llvm-objdump -Dz -j .note.android.memtag %t | \
+// RUN:FileCheck %s --check-prefixes=NOTE,SYNC-NOTE
+
+// RUN: ld.lld --memtag-mode=async --memtag-stack %t.o -o %t
+// RUN: llvm-readelf -S %t | FileCheck %s
+// RUN: llvm-objdump -Dz -j .note.android.memtag %t | \
+// RUN:FileCheck %s --check-prefixes=NOTE,STACK-ASYNC
+
+// RUN: ld.lld --memtag-mode=sync --memtag-stack %t.o -o %t
+// RUN: llvm-readelf -S %t | FileCheck %s
+// RUN: llvm-objdump -Dz -j .note.android.memtag %t | \
+// RUN:FileCheck %s --check-prefixes=NOTE,STACK-SYNC
+
+// CHECK: .note.android.memtag
+
+// NOTE: <.note.android.memtag>:
+// NOTE-NEXT: : 08 00 00 00
+// NOTE-NEXT: : 04 00 00 00

[PATCH] D116153: [ARM][AArch64] Add missing v8.x checks

2022-02-03 Thread Son Tuan Vu via Phabricator via cfe-commits
tyb0807 marked 2 inline comments as done.
tyb0807 added inline comments.



Comment at: clang/lib/Basic/Targets/ARM.cpp:937
   case llvm::ARM::ArchKind::ARMV9_2A:
 getTargetDefinesARMV83A(Opts, Builder);
 break;

SjoerdMeijer wrote:
> Perhaps unrelated to this patch, but I am surprised to see that from v 8.3 
> and up we only include `getTargetDefinesARMV83A`, so no other target defines 
> were introduced or are necessary? This is not rhetorical questionI 
> haven't paid attention to this since v8.4.
It seems that most of the time, `getTargetDefinesARMV8(x)A` only includes 
`getTargetDefinesARMV8(x-1)A` (see `AArch64TargetInfo::getTargetDefines`). What 
we have here is a equivalent way to do that, with less boilerplate code.


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

https://reviews.llvm.org/D116153

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


[PATCH] D118855: [modules] Add a flag for TagDecl if it was a definition demoted to a declaration.

2022-02-03 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

`libomptarget :: x86_64-pc-linux-gnu :: mapping/delete_inf_refcount.c` has 
failed due to

> /usr/bin/ld: final link failed: bad value

As far as I can tell, it's not related to my change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118855

___
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-03 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

In D110869#3295012 , @void wrote:

> In D110869#3294696 , @nathanchance 
> wrote:
>
>> This diff allows me to boot on bare metal as of v5.17-rc2:
>>
>>   diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
>>   index 6aef9ee28a39..8ee176dac669 100644
>>   --- a/arch/x86/kernel/Makefile
>>   +++ b/arch/x86/kernel/Makefile
>>   @@ -125,6 +125,7 @@ obj-$(CONFIG_DEBUG_NMI_SELFTEST) += nmi_selftest.o
>>   
>>obj-$(CONFIG_KVM_GUEST)+= kvm.o kvmclock.o
>>obj-$(CONFIG_PARAVIRT) += paravirt.o
>>   +CFLAGS_paravirt.o += -fzero-call-used-regs=skip
>>obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= paravirt-spinlocks.o
>>obj-$(CONFIG_PARAVIRT_CLOCK)   += pvclock.o
>>obj-$(CONFIG_X86_PMEM_LEGACY_DEVICE) += pmem.o
>>
>> I have uploaded the config used, the preprocessed file, and the "good" 
>> object (with the following diff) and the "bad" object (without the above 
>> diff) here: 
>> https://github.com/nathanchance/bug-files/tree/052a31e6d94c1b349cf6f312808794dace24/D110869
>>
>> If there is any more information I can give, please let me know!
>
> Thanks for the information!
>
> Could you test this patch for me? (Applied over the patch in this review.)
>
>   diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp 
> b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
>   index 968a14548813..46ae48bd6a3c 100644
>   --- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp
>   +++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
>   @@ -1217,7 +1217,8 @@ void PEI::insertZeroCallUsedRegs(MachineFunction ) 
> {
>continue;
>   
>  MCRegister Reg = MO.getReg();
>   -  if ((MO.isDef() || MO.isUse()) && AllocatableSet[Reg])
>   +  if (AllocatableSet[Reg] && !MO.isImplicit() &&
>   +  (MO.isDef() || MO.isUse()))
>UsedRegs.set(Reg);
>}

I tested this patch but it did not change the hang.


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] D118904: [clang][CodeGen] Use memory type representation in `va_arg`

2022-02-03 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/test/CodeGen/arm64-arguments.c:203
+  __builtin_va_start(ap, i);
+  // TODO: Add proper checks here.
+  _Bool b = __builtin_va_arg(ap, _Bool);

jansvoboda11 wrote:
> Not sure what to check here. Currently, we're just verifying the compiler 
> doesn't crash.
If `CreateStore` is crashing, you can check the store instruction is being 
emitted with the correct type.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118904

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


[PATCH] D118944: [OpenMP] Add Cuda path to linker wrapper tool

2022-02-03 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:8163
+CmdArgs.push_back(Args.MakeArgString(
+"-cuda-path=" + CudaInstallation.getInstallPath()));
+  break;

Would be better to keep aligned with `clang` to use `--cuda-path`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118944

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


[PATCH] D116153: [ARM][AArch64] Add missing v8.x checks

2022-02-03 Thread Son Tuan Vu via Phabricator via cfe-commits
tyb0807 updated this revision to Diff 405786.
tyb0807 edited the summary of this revision.
tyb0807 added a comment.

Add more tests


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

https://reviews.llvm.org/D116153

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


Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -294,7 +294,7 @@
 // CHECK-MCPU-CARMEL: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8.2a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+fullfp16" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+sha2" "-target-feature" "+aes"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-ARCH-ARM64 %s
-// CHECK-ARCH-ARM64: "-target-cpu" "apple-m1" "-target-feature" "+v8.5a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+dotprod" 
"-target-feature" "+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" 
"-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" 
"-target-feature" "+zcz" "-target-feature" "+fullfp16" "-target-feature" 
"+sha2" "-target-feature" "+aes"
+// CHECK-ARCH-ARM64: "-target-cpu" "apple-m1" "-target-feature" "+v8.5a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+dotprod" 
"-target-feature" "+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" 
"-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" 
"-target-feature" "+zcz" "-target-feature" "+fullfp16" "-target-feature" "+sm4" 
"-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" "+aes"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64_32 -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-ARCH-ARM64_32 %s
 // CHECK-ARCH-ARM64_32: "-target-cpu" "apple-s4" "-target-feature" "+v8.3a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+fullfp16" 
"-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" 
"-target-feature" "+rcpc" "-target-feature" "+zcm" "-target-feature" "+zcz" 
"-target-feature" "+sha2" "-target-feature" "+aes"
@@ -390,7 +390,13 @@
 // Check +crypto:
 //
 // RUN: %clang -target aarch64 -march=armv8.4a+crypto -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CRYPTO84 %s
-// CHECK-CRYPTO84: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8.4a" "-target-feature" "+crypto" "-target-feature" "+sm4" "-target-feature" 
"+sha3" "-target-feature" "+sha2" "-target-feature" "+aes"
+// RUN: %clang -target aarch64 -march=armv8.5a+crypto -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CRYPTO85 %s
+// RUN: %clang -target aarch64 -march=armv8.6a+crypto -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CRYPTO86 %s
+// RUN: %clang -target aarch64 -march=armv8.7a+crypto -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CRYPTO87 %s
+// CHECK-CRYPTO84: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8.4a"{{.*}} "-target-feature" "+crypto" "-target-feature" "+sm4" 
"-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" "+aes"
+// CHECK-CRYPTO85: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8.5a"{{.*}} "-target-feature" "+crypto" "-target-feature" "+sm4" 
"-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" "+aes"
+// CHECK-CRYPTO86: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8.6a"{{.*}} "-target-feature" "+crypto" "-target-feature" "+sm4" 
"-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" "+aes"
+// CHECK-CRYPTO87: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8.7a"{{.*}} "-target-feature" "+crypto" "-target-feature" "+sm4" 
"-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" "+aes"
 //
 // Check -crypto:
 //
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -394,6 +394,9 @@
   }
 
   if (std::find(ItBegin, ItEnd, "+v8.4a") != ItEnd ||
+  std::find(ItBegin, ItEnd, "+v8.5a") != ItEnd ||
+  std::find(ItBegin, ItEnd, "+v8.6a") != ItEnd ||
+  std::find(ItBegin, ItEnd, "+v8.7a") != ItEnd ||
   std::find(ItBegin, ItEnd, "+v8.8a") != ItEnd ||
   std::find(ItBegin, ItEnd, "+v9a") != ItEnd ||
   std::find(ItBegin, ItEnd, "+v9.1a") != ItEnd ||
Index: clang/lib/Basic/Targets/ARM.cpp

[PATCH] D118858: [OpenMP] Don't use bound architecture when checking cache on the host

2022-02-03 Thread Joseph Huber via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9138d96f8b01: [OpenMP] Dont use bound architecture 
when checking cache on the host (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118858

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/openmp-offload-gpu.c


Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -358,6 +358,8 @@
 // NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "clang", inputs: ["[[HOST_INPUT:.+]]"], 
output: "[[HOST_BC:.+]]" 
 // NEW_DRIVER: "nvptx64-nvidia-cuda" - "clang", inputs: 
["[[DEVICE_INPUT:.+]]", "[[HOST_BC]]"], output: "[[DEVICE_ASM:.+]]"
 // NEW_DRIVER: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: 
["[[DEVICE_ASM]]"], output: "[[DEVICE_OBJ:.+]]" 
+// NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "clang", inputs: ["[[HOST_BC]]", 
"[[DEVICE_OBJ]]"], output: "[[HOST_OBJ:.+]]" 
+// NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "[[LINKER:.+]]", inputs: 
["[[HOST_OBJ]]"], output: "openmp-offload-gpu"
 
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target=nvptx64-nvida-cuda -march=sm_70 \
 // RUN:  
--libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-new-nvptx-test.bc
 \
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4828,9 +4828,11 @@
 
 // We may have already built this action as a part of the offloading
 // toolchain, return the cached input if so.
+StringRef Arch =
+(TargetDeviceOffloadKind == Action::OFK_Host) ? StringRef() : 
BoundArch;
 std::pair ActionTC = {
 OA->getHostDependence(),
-GetTriplePlusArchString(TC, BoundArch, TargetDeviceOffloadKind)};
+GetTriplePlusArchString(TC, Arch, TargetDeviceOffloadKind)};
 if (CachedResults.find(ActionTC) != CachedResults.end()) {
   InputInfoList Inputs = CachedResults[ActionTC];
   Inputs.append(OffloadDependencesInputInfo);


Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -358,6 +358,8 @@
 // NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "clang", inputs: ["[[HOST_INPUT:.+]]"], output: "[[HOST_BC:.+]]" 
 // NEW_DRIVER: "nvptx64-nvidia-cuda" - "clang", inputs: ["[[DEVICE_INPUT:.+]]", "[[HOST_BC]]"], output: "[[DEVICE_ASM:.+]]"
 // NEW_DRIVER: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: ["[[DEVICE_ASM]]"], output: "[[DEVICE_OBJ:.+]]" 
+// NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "clang", inputs: ["[[HOST_BC]]", "[[DEVICE_OBJ]]"], output: "[[HOST_OBJ:.+]]" 
+// NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "[[LINKER:.+]]", inputs: ["[[HOST_OBJ]]"], output: "openmp-offload-gpu"
 
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvida-cuda -march=sm_70 \
 // RUN:  --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-new-nvptx-test.bc \
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4828,9 +4828,11 @@
 
 // We may have already built this action as a part of the offloading
 // toolchain, return the cached input if so.
+StringRef Arch =
+(TargetDeviceOffloadKind == Action::OFK_Host) ? StringRef() : BoundArch;
 std::pair ActionTC = {
 OA->getHostDependence(),
-GetTriplePlusArchString(TC, BoundArch, TargetDeviceOffloadKind)};
+GetTriplePlusArchString(TC, Arch, TargetDeviceOffloadKind)};
 if (CachedResults.find(ActionTC) != CachedResults.end()) {
   InputInfoList Inputs = CachedResults[ActionTC];
   Inputs.append(OffloadDependencesInputInfo);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9138d96 - [OpenMP] Don't use bound architecture when checking cache on the host

2022-02-03 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-02-03T17:17:38-05:00
New Revision: 9138d96f8b01605b213e8c4d587853a46cca3f44

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

LOG: [OpenMP] Don't use bound architecture when checking cache on the host

When we are creating jobs for the new driver we first check the cache to
see if the job was already created as a part of the offloading
toolchain. This would sometimes fail if the bound architecture was set
for the host during offloading. We want to ingore this because it is not
relevant for looking up host actions. Previously it was set on some
machines and would cause the cache lookup to fail.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/test/Driver/openmp-offload-gpu.c

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 3bfddeefc7b2b..18dc6561b4d49 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4828,9 +4828,11 @@ InputInfoList Driver::BuildJobsForActionNoCache(
 
 // We may have already built this action as a part of the offloading
 // toolchain, return the cached input if so.
+StringRef Arch =
+(TargetDeviceOffloadKind == Action::OFK_Host) ? StringRef() : 
BoundArch;
 std::pair ActionTC = {
 OA->getHostDependence(),
-GetTriplePlusArchString(TC, BoundArch, TargetDeviceOffloadKind)};
+GetTriplePlusArchString(TC, Arch, TargetDeviceOffloadKind)};
 if (CachedResults.find(ActionTC) != CachedResults.end()) {
   InputInfoList Inputs = CachedResults[ActionTC];
   Inputs.append(OffloadDependencesInputInfo);

diff  --git a/clang/test/Driver/openmp-offload-gpu.c 
b/clang/test/Driver/openmp-offload-gpu.c
index af7ba7c802e5d..a9fc3e7b33a42 100644
--- a/clang/test/Driver/openmp-offload-gpu.c
+++ b/clang/test/Driver/openmp-offload-gpu.c
@@ -358,6 +358,8 @@
 // NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "clang", inputs: ["[[HOST_INPUT:.+]]"], 
output: "[[HOST_BC:.+]]" 
 // NEW_DRIVER: "nvptx64-nvidia-cuda" - "clang", inputs: 
["[[DEVICE_INPUT:.+]]", "[[HOST_BC]]"], output: "[[DEVICE_ASM:.+]]"
 // NEW_DRIVER: "nvptx64-nvidia-cuda" - "NVPTX::Assembler", inputs: 
["[[DEVICE_ASM]]"], output: "[[DEVICE_OBJ:.+]]" 
+// NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "clang", inputs: ["[[HOST_BC]]", 
"[[DEVICE_OBJ]]"], output: "[[HOST_OBJ:.+]]" 
+// NEW_DRIVER: "[[HOST_TRIPLE:.+]]" - "[[LINKER:.+]]", inputs: 
["[[HOST_OBJ]]"], output: "openmp-offload-gpu"
 
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target=nvptx64-nvida-cuda -march=sm_70 \
 // RUN:  
--libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-new-nvptx-test.bc
 \



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


[PATCH] D118944: [OpenMP] Add Cuda path to linker wrapper tool

2022-02-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 405785.
jhuber6 added a comment.

Decided to add break.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118944

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -99,8 +99,8 @@
 
 static cl::list
 PtxasArgs("ptxas-args", cl::ZeroOrMore,
-cl::desc("Argument to pass to the ptxas invocation"),
-cl::cat(ClangLinkerWrapperCategory));
+  cl::desc("Argument to pass to the ptxas invocation"),
+  cl::cat(ClangLinkerWrapperCategory));
 
 static cl::opt Verbose("v", cl::ZeroOrMore,
  cl::desc("Verbose output from tools"),
@@ -118,6 +118,10 @@
cl::desc("Save intermediary results."),
cl::cat(ClangLinkerWrapperCategory));
 
+static cl::opt CudaPath("cuda-path", cl::ZeroOrMore,
+ cl::desc("Save intermediary results."),
+ cl::cat(ClangLinkerWrapperCategory));
+
 // Do not parse linker options.
 static cl::list
 HostLinkerArgs(cl::Positional,
@@ -129,6 +133,9 @@
 /// Filename of the executable being created.
 static StringRef ExecutableName;
 
+/// Binary path for the CUDA installation.
+static std::string CudaBinaryPath;
+
 /// Temporary files created by the linker wrapper.
 static SmallVector TempFiles;
 
@@ -507,9 +514,9 @@
 namespace nvptx {
 Expected assemble(StringRef InputFile, Triple TheTriple,
StringRef Arch) {
-  // NVPTX uses the nvlink binary to link device object files.
+  // NVPTX uses the ptxas binary to create device object files.
   ErrorOr PtxasPath =
-  sys::findProgramByName("ptxas", sys::path::parent_path(LinkerExecutable));
+  sys::findProgramByName("ptxas", {CudaBinaryPath});
   if (!PtxasPath)
 PtxasPath = sys::findProgramByName("ptxas");
   if (!PtxasPath)
@@ -554,7 +561,10 @@
 Expected link(ArrayRef InputFiles, Triple TheTriple,
StringRef Arch) {
   // NVPTX uses the nvlink binary to link device object files.
-  ErrorOr NvlinkPath = sys::findProgramByName("nvlink");
+  ErrorOr NvlinkPath =
+  sys::findProgramByName("nvlink", {CudaBinaryPath});
+  if (!NvlinkPath)
+NvlinkPath = sys::findProgramByName("nvlink");
   if (!NvlinkPath)
 return createStringError(NvlinkPath.getError(),
  "Unable to find 'nvlink' in path");
@@ -1097,6 +1107,9 @@
 return EXIT_FAILURE;
   };
 
+  if (!CudaPath.empty())
+CudaBinaryPath = CudaPath + "/bin";
+
   ExecutableName = *(llvm::find(HostLinkerArgs, "-o") + 1);
   SmallVector LinkerArgs;
   for (const std::string  : HostLinkerArgs)
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -8148,11 +8148,25 @@
  const InputInfoList ,
  const ArgList ,
  const char *LinkingOutput) const {
+  const Driver  = getToolChain().getDriver();
+  const llvm::Triple TheTriple = getToolChain().getTriple();
+  auto OpenMPTCRange = C.getOffloadToolChains();
   ArgStringList CmdArgs;
 
-  if (getToolChain().getDriver().isUsingLTO(/* IsOffload */ true)) {
+  // Pass the CUDA path to the linker wrapper tool.
+  for (auto  : llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
+const ToolChain *TC = I.second;
+if (TC->getTriple().isNVPTX()) {
+  CudaInstallationDetector CudaInstallation(D, TheTriple, Args);
+  if (CudaInstallation.isValid())
+CmdArgs.push_back(Args.MakeArgString(
+"-cuda-path=" + CudaInstallation.getInstallPath()));
+  break;
+}
+  }
+
+  if (D.isUsingLTO(/* IsOffload */ true)) {
 // Pass in target features for each toolchain.
-auto OpenMPTCRange = C.getOffloadToolChains();
 for (auto  :
  llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
   const ToolChain *TC = I.second;
@@ -8165,9 +8179,10 @@
 }
 
 // Pass in the bitcode library to be linked during LTO.
-for (auto  : llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
+for (auto  :
+ llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
   const ToolChain *TC = I.second;
-  const Driver  = TC->getDriver();
+  const Driver  = TC->getDriver();
   const ArgList  = C.getArgsForToolChain(TC, "", Action::OFK_OpenMP);
   StringRef Arch = 

[PATCH] D118944: [OpenMP] Add Cuda path to linker wrapper tool

2022-02-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 405783.
jhuber6 added a comment.

Address style.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118944

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -99,8 +99,8 @@
 
 static cl::list
 PtxasArgs("ptxas-args", cl::ZeroOrMore,
-cl::desc("Argument to pass to the ptxas invocation"),
-cl::cat(ClangLinkerWrapperCategory));
+  cl::desc("Argument to pass to the ptxas invocation"),
+  cl::cat(ClangLinkerWrapperCategory));
 
 static cl::opt Verbose("v", cl::ZeroOrMore,
  cl::desc("Verbose output from tools"),
@@ -118,6 +118,10 @@
cl::desc("Save intermediary results."),
cl::cat(ClangLinkerWrapperCategory));
 
+static cl::opt CudaPath("cuda-path", cl::ZeroOrMore,
+ cl::desc("Save intermediary results."),
+ cl::cat(ClangLinkerWrapperCategory));
+
 // Do not parse linker options.
 static cl::list
 HostLinkerArgs(cl::Positional,
@@ -129,6 +133,9 @@
 /// Filename of the executable being created.
 static StringRef ExecutableName;
 
+/// Binary path for the CUDA installation.
+static std::string CudaBinaryPath;
+
 /// Temporary files created by the linker wrapper.
 static SmallVector TempFiles;
 
@@ -507,9 +514,9 @@
 namespace nvptx {
 Expected assemble(StringRef InputFile, Triple TheTriple,
StringRef Arch) {
-  // NVPTX uses the nvlink binary to link device object files.
+  // NVPTX uses the ptxas binary to create device object files.
   ErrorOr PtxasPath =
-  sys::findProgramByName("ptxas", sys::path::parent_path(LinkerExecutable));
+  sys::findProgramByName("ptxas", {CudaBinaryPath});
   if (!PtxasPath)
 PtxasPath = sys::findProgramByName("ptxas");
   if (!PtxasPath)
@@ -554,7 +561,10 @@
 Expected link(ArrayRef InputFiles, Triple TheTriple,
StringRef Arch) {
   // NVPTX uses the nvlink binary to link device object files.
-  ErrorOr NvlinkPath = sys::findProgramByName("nvlink");
+  ErrorOr NvlinkPath =
+  sys::findProgramByName("nvlink", {CudaBinaryPath});
+  if (!NvlinkPath)
+NvlinkPath = sys::findProgramByName("nvlink");
   if (!NvlinkPath)
 return createStringError(NvlinkPath.getError(),
  "Unable to find 'nvlink' in path");
@@ -1097,6 +1107,9 @@
 return EXIT_FAILURE;
   };
 
+  if (!CudaPath.empty())
+CudaBinaryPath = CudaPath + "/bin";
+
   ExecutableName = *(llvm::find(HostLinkerArgs, "-o") + 1);
   SmallVector LinkerArgs;
   for (const std::string  : HostLinkerArgs)
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -8148,11 +8148,24 @@
  const InputInfoList ,
  const ArgList ,
  const char *LinkingOutput) const {
+  const Driver  = getToolChain().getDriver();
+  const llvm::Triple TheTriple = getToolChain().getTriple();
+  auto OpenMPTCRange = C.getOffloadToolChains();
   ArgStringList CmdArgs;
 
-  if (getToolChain().getDriver().isUsingLTO(/* IsOffload */ true)) {
+  // Pass the CUDA path to the linker wrapper tool.
+  for (auto  : llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
+const ToolChain *TC = I.second;
+if (TC->getTriple().isNVPTX()) {
+  CudaInstallationDetector CudaInstallation(D, TheTriple, Args);
+  if (CudaInstallation.isValid())
+CmdArgs.push_back(Args.MakeArgString(
+"-cuda-path=" + CudaInstallation.getInstallPath()));
+}
+  }
+
+  if (D.isUsingLTO(/* IsOffload */ true)) {
 // Pass in target features for each toolchain.
-auto OpenMPTCRange = C.getOffloadToolChains();
 for (auto  :
  llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
   const ToolChain *TC = I.second;
@@ -8165,9 +8178,10 @@
 }
 
 // Pass in the bitcode library to be linked during LTO.
-for (auto  : llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
+for (auto  :
+ llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
   const ToolChain *TC = I.second;
-  const Driver  = TC->getDriver();
+  const Driver  = TC->getDriver();
   const ArgList  = C.getArgsForToolChain(TC, "", Action::OFK_OpenMP);
   StringRef Arch = TCArgs.getLastArgValue(options::OPT_march_EQ);
 
@@ 

[PATCH] D118944: [OpenMP] Add Cuda path to linker wrapper tool

2022-02-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:8161-8162
+  if (CudaInstallation.isValid())
+CmdArgs.push_back(Args.MakeArgString(
+"-cuda-path=" + CudaInstallation.getInstallPath()));
+}

Meinersbur wrote:
> Since there is no `break`, would this potentially add multiple `--cuda-path`?
Right now the tool chains are initialized based on triples. I don't think it's 
technically possible for the user to perform an action like 
`-fopenmp-targets=nvptx64-nvidia-cuda,nvptx-nvidia-cuda`. The flag is listed 
`ZeroOrMore`, so I'm not sure if it's worth explicitly preventing, we'll just 
take the most recently passed in one.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:8183
   const ToolChain *TC = I.second;
-  const Driver  = TC->getDriver();
+  const Driver  = TC->getDriver();
   const ArgList  = C.getArgsForToolChain(TC, "", 
Action::OFK_OpenMP);

Meinersbur wrote:
> [nit] unrelated rename
Avoids shadowing the new `D` I added.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:8258-8261
+  // Construct the link job so we can wrap around it.
+  Linker->ConstructJob(C, JA, Output, Inputs, Args, LinkingOutput);
+  const auto  = C.getJobs().getJobs().back();
+

Meinersbur wrote:
> Is moving this relevant?
No, but I wanted to move it so I figured I might as well while I'm here, 
similar with the other unrelated changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118944

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


[PATCH] D114732: [clang] Mark `trivial_abi` types as "trivially relocatable".

2022-02-03 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

In D114732#3294794 , 
@devin.jeanpierre wrote:

> Oops, sorry about that. What is the correct way to test/reproduce the change? 
> Do I / can I submit builds to the buildbot manually for testing?
>
> Also, should I be rolling back this change, or no? Not sure of the protocol 
> here, this is my first change to Clang.
>
> P.S. that breakage is disturbing -- I would not have expected this sort of 
> failure on any platform, and I'm not sure if it reflects a bug on PS4. (It 
> seems to be that structs are passed in registers, even if the member 
> variables of that struct cannot be.)

Reproducing it should be as simple as just rerunning the test with the PS4 
triple, x86_64-scei-ps4 and comparing that output with what is expected. If it 
helps, I noticed that it seems to reproduce on both linux/windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114732

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


[PATCH] D118944: [OpenMP] Add Cuda path to linker wrapper tool

2022-02-03 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

Thanks for the fix




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:8151-8152
  const char *LinkingOutput) const {
+  const auto  = getToolChain().getDriver();
+  const auto TheTriple = getToolChain().getTriple();
+  auto OpenMPTCRange = C.getOffloadToolChains();

[style] Avoid "Almost Always Auto"



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:8161-8162
+  if (CudaInstallation.isValid())
+CmdArgs.push_back(Args.MakeArgString(
+"-cuda-path=" + CudaInstallation.getInstallPath()));
+}

Since there is no `break`, would this potentially add multiple `--cuda-path`?



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:8183
   const ToolChain *TC = I.second;
-  const Driver  = TC->getDriver();
+  const Driver  = TC->getDriver();
   const ArgList  = C.getArgsForToolChain(TC, "", 
Action::OFK_OpenMP);

[nit] unrelated rename



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:8258-8261
+  // Construct the link job so we can wrap around it.
+  Linker->ConstructJob(C, JA, Output, Inputs, Args, LinkingOutput);
+  const auto  = C.getJobs().getJobs().back();
+

Is moving this relevant?



Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:102-103
 PtxasArgs("ptxas-args", cl::ZeroOrMore,
-cl::desc("Argument to pass to the ptxas invocation"),
-cl::cat(ClangLinkerWrapperCategory));
 

[nit] unrelated whitespace change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118944

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


[PATCH] D115060: [clang-format][NFC] Code Tidies in UnwrappedLineFormatter

2022-02-03 Thread Björn Schäpers via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
HazardyKnusperkeks marked an inline comment as done.
Closed by commit rG3d0b61926139: [clang-format][NFC] Code Tidies in 
UnwrappedLineFormatter (authored by HazardyKnusperkeks).

Changed prior to commit:
  https://reviews.llvm.org/D115060?vs=400449=405778#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115060

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp

Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -228,10 +228,11 @@
 const AnnotatedLine *TheLine = *I;
 if (TheLine->Last->is(TT_LineComment))
   return 0;
-if (I[1]->Type == LT_Invalid || I[1]->First->MustBreakBefore)
+const auto  = *I[1];
+if (NextLine.Type == LT_Invalid || NextLine.First->MustBreakBefore)
   return 0;
 if (TheLine->InPPDirective &&
-(!I[1]->InPPDirective || I[1]->First->HasUnescapedNewline))
+(!NextLine.InPPDirective || NextLine.First->HasUnescapedNewline))
   return 0;
 
 if (Style.ColumnLimit > 0 && Indent > Style.ColumnLimit)
@@ -248,15 +249,16 @@
 if (TheLine->Last->is(TT_FunctionLBrace) &&
 TheLine->First == TheLine->Last &&
 !Style.BraceWrapping.SplitEmptyFunction &&
-I[1]->First->is(tok::r_brace))
+NextLine.First->is(tok::r_brace))
   return tryMergeSimpleBlock(I, E, Limit);
 
-// Handle empty record blocks where the brace has already been wrapped
-if (TheLine->Last->is(tok::l_brace) && TheLine->First == TheLine->Last &&
-I != AnnotatedLines.begin()) {
-  bool EmptyBlock = I[1]->First->is(tok::r_brace);
+const auto *PreviousLine = I != AnnotatedLines.begin() ? I[-1] : nullptr;
+// Handle empty record blocks where the brace has already been wrapped.
+if (PreviousLine && TheLine->Last->is(tok::l_brace) &&
+TheLine->First == TheLine->Last) {
+  bool EmptyBlock = NextLine.First->is(tok::r_brace);
 
-  const FormatToken *Tok = I[-1]->First;
+  const FormatToken *Tok = PreviousLine->First;
   if (Tok && Tok->is(tok::comment))
 Tok = Tok->getNextNonComment();
 
@@ -278,48 +280,44 @@
 return 0;
 }
 
-auto ShouldMergeShortFunctions =
-[this, B = AnnotatedLines.begin()](
-SmallVectorImpl::const_iterator I) {
-  if (Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_All)
-return true;
-  if (Style.AllowShortFunctionsOnASingleLine >=
-  FormatStyle::SFS_Empty &&
-  I[1]->First->is(tok::r_brace))
-return true;
-
-  if (Style.AllowShortFunctionsOnASingleLine &
-  FormatStyle::SFS_InlineOnly) {
-// Just checking TheLine->Level != 0 is not enough, because it
-// provokes treating functions inside indented namespaces as short.
-if (Style.isJavaScript() && (*I)->Last->is(TT_FunctionLBrace))
-  return true;
-
-if ((*I)->Level != 0) {
-  if (I == B)
-return false;
-
-  // TODO: Use IndentTracker to avoid loop?
-  // Find the last line with lower level.
-  auto J = I - 1;
-  for (; J != B; --J)
-if ((*J)->Level < (*I)->Level)
-  break;
-
-  // Check if the found line starts a record.
-  for (const FormatToken *RecordTok = (*J)->Last; RecordTok;
-   RecordTok = RecordTok->Previous)
-if (RecordTok->is(tok::l_brace))
-  return RecordTok->is(TT_RecordLBrace);
-
-  return false;
-}
-  }
+auto ShouldMergeShortFunctions = [this, , , PreviousLine,
+  TheLine]() {
+  if (Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_All)
+return true;
+  if (Style.AllowShortFunctionsOnASingleLine >= FormatStyle::SFS_Empty &&
+  NextLine.First->is(tok::r_brace))
+return true;
+
+  if (Style.AllowShortFunctionsOnASingleLine &
+  FormatStyle::SFS_InlineOnly) {
+// Just checking TheLine->Level != 0 is not enough, because it
+// provokes treating functions inside indented namespaces as short.
+if (Style.isJavaScript() && TheLine->Last->is(TT_FunctionLBrace))
+  return true;
+
+if (TheLine->Level != 0) {
+  if (!PreviousLine)
+return false;
+
+  // TODO: Use IndentTracker to avoid loop?
+  // Find the last line with lower level.
+  auto J = I - 1;
+  for (; J != AnnotatedLines.begin(); --J)
+if ((*J)->Level < TheLine->Level)
+  

[clang] 3d0b619 - [clang-format][NFC] Code Tidies in UnwrappedLineFormatter

2022-02-03 Thread Björn Schäpers via cfe-commits

Author: Björn Schäpers
Date: 2022-02-03T22:55:27+01:00
New Revision: 3d0b619261392f5f24a7b9961b24cdd621829c13

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

LOG: [clang-format][NFC] Code Tidies in UnwrappedLineFormatter

* Give I[1] and I[-1] a name:
  - Easier to understand
  - Easier to debug (since you don't go through operator[] everytime)
* TheLine->First != TheLine->Last follows since last is a l brace and
  first isn't.
* Factor the check for is(tok::l_brace) out.
* Drop else after return.

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineFormatter.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index f7d26b813f4f..9f49410f741a 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -228,10 +228,11 @@ class LineJoiner {
 const AnnotatedLine *TheLine = *I;
 if (TheLine->Last->is(TT_LineComment))
   return 0;
-if (I[1]->Type == LT_Invalid || I[1]->First->MustBreakBefore)
+const auto  = *I[1];
+if (NextLine.Type == LT_Invalid || NextLine.First->MustBreakBefore)
   return 0;
 if (TheLine->InPPDirective &&
-(!I[1]->InPPDirective || I[1]->First->HasUnescapedNewline))
+(!NextLine.InPPDirective || NextLine.First->HasUnescapedNewline))
   return 0;
 
 if (Style.ColumnLimit > 0 && Indent > Style.ColumnLimit)
@@ -248,15 +249,16 @@ class LineJoiner {
 if (TheLine->Last->is(TT_FunctionLBrace) &&
 TheLine->First == TheLine->Last &&
 !Style.BraceWrapping.SplitEmptyFunction &&
-I[1]->First->is(tok::r_brace))
+NextLine.First->is(tok::r_brace))
   return tryMergeSimpleBlock(I, E, Limit);
 
-// Handle empty record blocks where the brace has already been wrapped
-if (TheLine->Last->is(tok::l_brace) && TheLine->First == TheLine->Last &&
-I != AnnotatedLines.begin()) {
-  bool EmptyBlock = I[1]->First->is(tok::r_brace);
+const auto *PreviousLine = I != AnnotatedLines.begin() ? I[-1] : nullptr;
+// Handle empty record blocks where the brace has already been wrapped.
+if (PreviousLine && TheLine->Last->is(tok::l_brace) &&
+TheLine->First == TheLine->Last) {
+  bool EmptyBlock = NextLine.First->is(tok::r_brace);
 
-  const FormatToken *Tok = I[-1]->First;
+  const FormatToken *Tok = PreviousLine->First;
   if (Tok && Tok->is(tok::comment))
 Tok = Tok->getNextNonComment();
 
@@ -278,48 +280,44 @@ class LineJoiner {
 return 0;
 }
 
-auto ShouldMergeShortFunctions =
-[this, B = AnnotatedLines.begin()](
-SmallVectorImpl::const_iterator I) {
-  if (Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_All)
-return true;
-  if (Style.AllowShortFunctionsOnASingleLine >=
-  FormatStyle::SFS_Empty &&
-  I[1]->First->is(tok::r_brace))
-return true;
-
-  if (Style.AllowShortFunctionsOnASingleLine &
-  FormatStyle::SFS_InlineOnly) {
-// Just checking TheLine->Level != 0 is not enough, because it
-// provokes treating functions inside indented namespaces as short.
-if (Style.isJavaScript() && (*I)->Last->is(TT_FunctionLBrace))
-  return true;
-
-if ((*I)->Level != 0) {
-  if (I == B)
-return false;
-
-  // TODO: Use IndentTracker to avoid loop?
-  // Find the last line with lower level.
-  auto J = I - 1;
-  for (; J != B; --J)
-if ((*J)->Level < (*I)->Level)
-  break;
-
-  // Check if the found line starts a record.
-  for (const FormatToken *RecordTok = (*J)->Last; RecordTok;
-   RecordTok = RecordTok->Previous)
-if (RecordTok->is(tok::l_brace))
-  return RecordTok->is(TT_RecordLBrace);
-
-  return false;
-}
-  }
+auto ShouldMergeShortFunctions = [this, , , PreviousLine,
+  TheLine]() {
+  if (Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_All)
+return true;
+  if (Style.AllowShortFunctionsOnASingleLine >= FormatStyle::SFS_Empty &&
+  NextLine.First->is(tok::r_brace))
+return true;
+
+  if (Style.AllowShortFunctionsOnASingleLine &
+  FormatStyle::SFS_InlineOnly) {
+// Just checking TheLine->Level != 0 is not enough, because it
+// provokes treating functions inside indented namespaces as short.
+if (Style.isJavaScript() && 

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

2022-02-03 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

In D110869#3294696 , @nathanchance 
wrote:

> This diff allows me to boot on bare metal as of v5.17-rc2:
>
>   diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
>   index 6aef9ee28a39..8ee176dac669 100644
>   --- a/arch/x86/kernel/Makefile
>   +++ b/arch/x86/kernel/Makefile
>   @@ -125,6 +125,7 @@ obj-$(CONFIG_DEBUG_NMI_SELFTEST) += nmi_selftest.o
>   
>obj-$(CONFIG_KVM_GUEST)+= kvm.o kvmclock.o
>obj-$(CONFIG_PARAVIRT) += paravirt.o
>   +CFLAGS_paravirt.o += -fzero-call-used-regs=skip
>obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= paravirt-spinlocks.o
>obj-$(CONFIG_PARAVIRT_CLOCK)   += pvclock.o
>obj-$(CONFIG_X86_PMEM_LEGACY_DEVICE) += pmem.o
>
> I have uploaded the config used, the preprocessed file, and the "good" object 
> (with the following diff) and the "bad" object (without the above diff) here: 
> https://github.com/nathanchance/bug-files/tree/052a31e6d94c1b349cf6f312808794dace24/D110869
>
> If there is any more information I can give, please let me know!

Thanks for the information!

Could you test this patch for me? (Applied over the patch in this review.)

  diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp 
b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
  index 968a14548813..46ae48bd6a3c 100644
  --- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp
  +++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
  @@ -1217,7 +1217,8 @@ void PEI::insertZeroCallUsedRegs(MachineFunction ) {
   continue;
  
 MCRegister Reg = MO.getReg();
  -  if ((MO.isDef() || MO.isUse()) && AllocatableSet[Reg])
  +  if (AllocatableSet[Reg] && !MO.isImplicit() &&
  +  (MO.isDef() || MO.isUse()))
   UsedRegs.set(Reg);
   }


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] D118869: [clang-format] Non-latin comment prefix whitespace

2022-02-03 Thread ksyx 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 rG88e4e6be16ea: [clang-format] Use wider comment prefix space 
rule (authored by ksyx).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118869

Files:
  clang/lib/Format/BreakableToken.cpp
  clang/unittests/Format/FormatTestComments.cpp

Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -3322,6 +3322,18 @@
   "\n"
   "///   Free Doxygen with 3 spaces\n"
   "\n"
+  "//🐉 A nice dragon\n"
+  "\n"
+  "//\t abccba\n"
+  "\n"
+  "//\\t deffed\n"
+  "\n"
+  "//   🐉 Another nice dragon\n"
+  "\n"
+  "//   \t Three leading spaces following tab\n"
+  "\n"
+  "//   \\t Three leading spaces following backslash\n"
+  "\n"
   "/// A Doxygen Comment with a nested list:\n"
   "/// - Foo\n"
   "/// - Bar\n"
@@ -3381,6 +3393,18 @@
 "\n"
 "///   Free Doxygen with 3 spaces\n"
 "\n"
+"// 🐉 A nice dragon\n"
+"\n"
+"//\t abccba\n"
+"\n"
+"//\\t deffed\n"
+"\n"
+"//   🐉 Another nice dragon\n"
+"\n"
+"//   \t Three leading spaces following tab\n"
+"\n"
+"//   \\t Three leading spaces following backslash\n"
+"\n"
 "/// A Doxygen Comment with a nested list:\n"
 "/// - Foo\n"
 "/// - Bar\n"
@@ -3442,6 +3466,18 @@
 "\n"
 "///Free Doxygen with 3 spaces\n"
 "\n"
+"//🐉 A nice dragon\n"
+"\n"
+"//\t abccba\n"
+"\n"
+"//\\t deffed\n"
+"\n"
+"//🐉 Another nice dragon\n"
+"\n"
+"//\t Three leading spaces following tab\n"
+"\n"
+"//\\t Three leading spaces following backslash\n"
+"\n"
 "///A Doxygen Comment with a nested list:\n"
 "///- Foo\n"
 "///- Bar\n"
@@ -3503,6 +3539,18 @@
 "\n"
 "///   Free Doxygen with 3 spaces\n"
 "\n"
+"//  🐉 A nice dragon\n"
+"\n"
+"//\t abccba\n"
+"\n"
+"//\\t deffed\n"
+"\n"
+"//   🐉 Another nice dragon\n"
+"\n"
+"//   \t Three leading spaces following tab\n"
+"\n"
+"//   \\t Three leading spaces following backslash\n"
+"\n"
 "///  A Doxygen Comment with a nested list:\n"
 "///  - Foo\n"
 "///  - Bar\n"
@@ -3809,6 +3857,18 @@
 "\n"
 "///   Free Doxygen with 3 spaces\n"
 "\n"
+"// 🐉 A nice dragon\n"
+"\n"
+"//\t abccba\n"
+"\n"
+"//\\t deffed\n"
+"\n"
+"//   🐉 Another nice dragon\n"
+"\n"
+"//   \t Three leading spaces following tab\n"
+"\n"
+"//   \\t Three leading spaces following backslash\n"
+"\n"
 "/// A Doxygen Comment with a nested list:\n"
 "/// - Foo\n"
 "/// - Bar\n"
@@ -3870,6 +3930,18 @@
 "\n"
 "///Free Doxygen with 3 spaces\n"
 "\n"
+"//🐉 A nice dragon\n"
+"\n"
+"//\t abccba\n"
+"\n"
+"//\\t deffed\n"
+"\n"
+"//🐉 Another nice dragon\n"
+"\n"
+"//\t Three leading spaces following tab\n"
+"\n"
+"//\\t Three leading spaces following backslash\n"
+"\n"
 "///A Doxygen Comment with a nested list:\n"
 "///- Foo\n"
 "///- Bar\n"
@@ -3931,6 +4003,18 @@
 "\n"
 "///   Free Doxygen with 3 spaces\n"
 "\n"
+"//  🐉 A nice dragon\n"
+"\n"
+"//\t abccba\n"
+"\n"
+"//\\t deffed\n"
+"\n"
+"//   🐉 Another nice dragon\n"
+"\n"
+"//   \t Three leading spaces following tab\n"
+"\n"
+"//   \\t Three leading spaces following backslash\n"
+"\n"
 "///  A Doxygen Comment with a nested list:\n"
 "///  - Foo\n"
 "///  - Bar\n"
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -771,6 +771,20 @@
   

[clang] 88e4e6b - [clang-format] Use wider comment prefix space rule

2022-02-03 Thread via cfe-commits

Author: ksyx
Date: 2022-02-03T21:49:10Z
New Revision: 88e4e6be16ea400948c06f972f1b5f19478528df

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

LOG: [clang-format] Use wider comment prefix space rule

This commit changes the condition of requiring comment to start with
alphanumeric characters to make no change only for a certain set of
characters, currently horizontal whitespace and punctuation characters,
to support wider set of leading characters unrelated to documentation
generation directives.

Reviewed By: HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D118869

Added: 


Modified: 
clang/lib/Format/BreakableToken.cpp
clang/unittests/Format/FormatTestComments.cpp

Removed: 




diff  --git a/clang/lib/Format/BreakableToken.cpp 
b/clang/lib/Format/BreakableToken.cpp
index 7cdbbbd5dd7fa..ef8dc2a864a2a 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -771,6 +771,20 @@ BreakableLineCommentSection::BreakableLineCommentSection(
   OriginalPrefix[i] = IndentPrefix;
   const unsigned SpacesInPrefix = llvm::count(IndentPrefix, ' ');
 
+  // This lambda also considers multibyte character that is not handled in
+  // functions like isPunctuation provided by CharInfo.
+  const auto NoSpaceBeforeFirstCommentChar = [&]() {
+assert(Lines[i].size() > IndentPrefix.size());
+const char FirstCommentChar = Lines[i][IndentPrefix.size()];
+const unsigned FirstCharByteSize =
+encoding::getCodePointNumBytes(FirstCommentChar, Encoding);
+return encoding::columnWidth(
+   Lines[i].substr(IndentPrefix.size(), FirstCharByteSize),
+   Encoding) == 1 &&
+   (FirstCommentChar == '\\' || isPunctuation(FirstCommentChar) ||
+isHorizontalWhitespace(FirstCommentChar));
+  };
+
   // On the first line of the comment section we calculate how many spaces
   // are to be added or removed, all lines after that just get only the
   // change and we will not look at the maximum anymore. Additionally to 
the
@@ -780,7 +794,7 @@ BreakableLineCommentSection::BreakableLineCommentSection(
 OriginalPrefix[i - 1].rtrim(Blanks)) {
 if (SpacesInPrefix < Style.SpacesInLineCommentPrefix.Minimum &&
 Lines[i].size() > IndentPrefix.size() &&
-isAlphanumeric(Lines[i][IndentPrefix.size()])) {
+!NoSpaceBeforeFirstCommentChar()) {
   FirstLineSpaceChange =
   Style.SpacesInLineCommentPrefix.Minimum - SpacesInPrefix;
 } else if (SpacesInPrefix > Style.SpacesInLineCommentPrefix.Maximum) {
@@ -804,7 +818,7 @@ BreakableLineCommentSection::BreakableLineCommentSection(
 const auto FirstNonSpace = Lines[i][IndentPrefix.size()];
 const auto AllowsSpaceChange =
 SpacesInPrefix != 0 ||
-(isAlphanumeric(FirstNonSpace) ||
+(!NoSpaceBeforeFirstCommentChar() ||
  (FirstNonSpace == '}' && FirstLineSpaceChange != 0));
 
 if (PrefixSpaceChange[i] > 0 && AllowsSpaceChange) {

diff  --git a/clang/unittests/Format/FormatTestComments.cpp 
b/clang/unittests/Format/FormatTestComments.cpp
index b487440a06a3b..282bc46cd0482 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -3322,6 +3322,18 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
   "\n"
   "///   Free Doxygen with 3 spaces\n"
   "\n"
+  "// A nice dragon\n"
+  "\n"
+  "//\t abccba\n"
+  "\n"
+  "//\\t deffed\n"
+  "\n"
+  "//    Another nice dragon\n"
+  "\n"
+  "//   \t Three leading spaces following tab\n"
+  "\n"
+  "//   \\t Three leading spaces following backslash\n"
+  "\n"
   "/// A Doxygen Comment with a nested list:\n"
   "/// - Foo\n"
   "/// - Bar\n"
@@ -3381,6 +3393,18 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
 "\n"
 "///   Free Doxygen with 3 spaces\n"
 "\n"
+"//  A nice dragon\n"
+"\n"
+"//\t abccba\n"
+"\n"
+"//\\t deffed\n"
+"\n"
+"//    Another nice dragon\n"
+"\n"
+"//   \t Three leading spaces following tab\n"
+"\n"
+"//   \\t Three leading spaces following backslash\n"
+"\n"
 "/// A Doxygen Comment with a nested list:\n"
 "/// - Foo\n"
 "/// - Bar\n"
@@ -3442,6 +3466,18 @@ TEST_F(FormatTestComments, SpaceAtLineCommentBegin) {
 "\n"
 "///Free Doxygen with 3 spaces\n"
 "\n"
+"// A nice 

[PATCH] D117569: Constexpr not supported with __declspec(dllimport).

2022-02-03 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 405775.

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

https://reviews.llvm.org/D117569

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/CodeGenCXX/PR19955.cpp
  clang/test/CodeGenCXX/dllimport.cpp
  clang/test/SemaCXX/PR19955.cpp
  clang/test/SemaCXX/dllimport-constexpr.cpp

Index: clang/test/SemaCXX/dllimport-constexpr.cpp
===
--- clang/test/SemaCXX/dllimport-constexpr.cpp
+++ clang/test/SemaCXX/dllimport-constexpr.cpp
@@ -40,7 +40,6 @@
 // constexpr initialization doesn't work for dllimport things.
 // expected-error@+1{{must be initialized by a constant expression}}
 constexpr void (*constexpr_import_func)() = _func;
-// expected-error@+1{{must be initialized by a constant expression}}
 constexpr int *constexpr_import_int = _int;
 // expected-error@+1{{must be initialized by a constant expression}}
 constexpr void (Foo::*constexpr_memptr)() = ::imported_method;
@@ -60,3 +59,14 @@
   // expected-note@+1 {{requested here}}
   StaticConstexpr::g_fp();
 }
+
+void foo() {
+  extern int __declspec(dllimport) dll_import_int;
+  constexpr int _import_constexpr_ref = dll_import_int;
+}
+
+extern int __declspec(dllimport) dll_import_int;
+constexpr int _import_constexpr_ref = dll_import_int;
+int goo() {
+  return dll_import_constexpr_ref;
+}
Index: clang/test/SemaCXX/PR19955.cpp
===
--- clang/test/SemaCXX/PR19955.cpp
+++ clang/test/SemaCXX/PR19955.cpp
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -triple i686-mingw32 -verify -std=c++11 %s
 
 extern int __attribute__((dllimport)) var;
-constexpr int *varp =  // expected-error {{must be initialized by a constant expression}}
+constexpr int *varp = 
 
 extern __attribute__((dllimport)) void fun();
 constexpr void (*funp)(void) =  // expected-error {{must be initialized by a constant expression}}
Index: clang/test/CodeGenCXX/dllimport.cpp
===
--- clang/test/CodeGenCXX/dllimport.cpp
+++ clang/test/CodeGenCXX/dllimport.cpp
@@ -98,8 +98,8 @@
 USE(inlineStaticLocalsFunc);
 
 // The address of a dllimport global cannot be used in constant initialization.
-// M32-DAG: @"?arr@?1??initializationFunc@@YAPAHXZ@4QBQAHB" = internal global [1 x i32*] zeroinitializer
-// GNU-DAG: @_ZZ18initializationFuncvE3arr = internal global [1 x i32*] zeroinitializer
+// M32-DAG: @"?arr@?1??initializationFunc@@YAPAHXZ@4QBQAHB" = internal constant [1 x i32*] [i32* @"?ExternGlobalDecl@@3HA"]
+// GNU-DAG: @_ZZ18initializationFuncvE3arr = internal constant [1 x i32*] [i32* @ExternGlobalDecl]
 int *initializationFunc() {
   static int *const arr[] = {};
   return arr[0];
Index: clang/test/CodeGenCXX/PR19955.cpp
===
--- clang/test/CodeGenCXX/PR19955.cpp
+++ clang/test/CodeGenCXX/PR19955.cpp
@@ -6,20 +6,16 @@
 
 extern int *varp;
 int *varp = 
-// CHECK-DAG: @"?varp@@3PAHA" = dso_local global i32* null
-// X64-DAG: @"?varp@@3PEAHEA" = dso_local global i32* null
+// CHECK-DAG: @"?var@@3HA" = external dllimport global i32
+// CHECK-DAG: @"?varp@@3PAHA" = dso_local global i32* @"?var@@3HA"
+// X64-DAG: @"?var@@3HA" = external dllimport global i32, align 4
+// X64-DAG: @"?varp@@3PEAHEA" = dso_local global i32* @"?var@@3HA"
 
 extern void (*funp)();
 void (*funp)() = 
 // CHECK-DAG: @"?funp@@3P6AXXZA" = dso_local global void ()* null
 // X64-DAG: @"?funp@@3P6AXXZEA" = dso_local global void ()* null
 
-// CHECK-LABEL: @"??__Evarp@@YAXXZ"
-// CHECK-DAG: store i32* @"?var@@3HA", i32** @"?varp@@3PAHA"
-
-// X64-LABEL: @"??__Evarp@@YAXXZ"
-// X64-DAG: store i32* @"?var@@3HA", i32** @"?varp@@3PEAHEA"
-
 // CHECK-LABEL: @"??__Efunp@@YAXXZ"()
 // CHECK-DAG: store void ()* @"?fun@@YAXXZ", void ()** @"?funp@@3P6AXXZA"
 
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -2211,9 +2211,13 @@
 // FIXME: Diagnostic!
 return false;
 
-  // A dllimport variable never acts like a constant, unless we're
-  // evaluating a value for use only in name mangling.
-  if (!isForManglingOnly(Kind) && Var->hasAttr())
+  // A dllimport variable in C99, or a dllexport variable in C++ never acts
+  // like a constant, unless we're evaluating a value for use only in name
+  // mangling.
+   if (Info.getLangOpts().C99 && !isForManglingOnly(Kind) &&
+   Var->hasAttr() ||
+   Info.getLangOpts().CPlusPlus && !isForManglingOnly(Kind) &&
+   Var->hasAttr())
 // FIXME: Diagnostic!
 return false;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118944: [OpenMP] Add Cuda path to linker wrapper tool

2022-02-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, Meinersbur.
Herald added subscribers: guansong, yaxunl.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

The linker wrapper tool uses the 'nvlink' and 'ptxas' binaries to link
and assemble device files. Previously we searched for this using the
binaries in the user's path. This didn't work in cases where the user
passed in a specific Cuda path to Clang. This patch changes the linker
wrapper to accept an argument for the Cuda path we can get from Clang.
This should fix #53573.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118944

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -99,8 +99,8 @@
 
 static cl::list
 PtxasArgs("ptxas-args", cl::ZeroOrMore,
-cl::desc("Argument to pass to the ptxas invocation"),
-cl::cat(ClangLinkerWrapperCategory));
+  cl::desc("Argument to pass to the ptxas invocation"),
+  cl::cat(ClangLinkerWrapperCategory));
 
 static cl::opt Verbose("v", cl::ZeroOrMore,
  cl::desc("Verbose output from tools"),
@@ -118,6 +118,10 @@
cl::desc("Save intermediary results."),
cl::cat(ClangLinkerWrapperCategory));
 
+static cl::opt CudaPath("cuda-path", cl::ZeroOrMore,
+ cl::desc("Save intermediary results."),
+ cl::cat(ClangLinkerWrapperCategory));
+
 // Do not parse linker options.
 static cl::list
 HostLinkerArgs(cl::Positional,
@@ -129,6 +133,9 @@
 /// Filename of the executable being created.
 static StringRef ExecutableName;
 
+/// Binary path for the CUDA installation.
+static std::string CudaBinaryPath;
+
 /// Temporary files created by the linker wrapper.
 static SmallVector TempFiles;
 
@@ -507,9 +514,9 @@
 namespace nvptx {
 Expected assemble(StringRef InputFile, Triple TheTriple,
StringRef Arch) {
-  // NVPTX uses the nvlink binary to link device object files.
+  // NVPTX uses the ptxas binary to create device object files.
   ErrorOr PtxasPath =
-  sys::findProgramByName("ptxas", sys::path::parent_path(LinkerExecutable));
+  sys::findProgramByName("ptxas", {CudaBinaryPath});
   if (!PtxasPath)
 PtxasPath = sys::findProgramByName("ptxas");
   if (!PtxasPath)
@@ -554,7 +561,10 @@
 Expected link(ArrayRef InputFiles, Triple TheTriple,
StringRef Arch) {
   // NVPTX uses the nvlink binary to link device object files.
-  ErrorOr NvlinkPath = sys::findProgramByName("nvlink");
+  ErrorOr NvlinkPath =
+  sys::findProgramByName("nvlink", {CudaBinaryPath});
+  if (!NvlinkPath)
+NvlinkPath = sys::findProgramByName("nvlink");
   if (!NvlinkPath)
 return createStringError(NvlinkPath.getError(),
  "Unable to find 'nvlink' in path");
@@ -1097,6 +1107,9 @@
 return EXIT_FAILURE;
   };
 
+  if (!CudaPath.empty())
+CudaBinaryPath = CudaPath + "/bin";
+
   ExecutableName = *(llvm::find(HostLinkerArgs, "-o") + 1);
   SmallVector LinkerArgs;
   for (const std::string  : HostLinkerArgs)
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -8148,11 +8148,23 @@
  const InputInfoList ,
  const ArgList ,
  const char *LinkingOutput) const {
+  const auto  = getToolChain().getDriver();
+  const auto TheTriple = getToolChain().getTriple();
+  auto OpenMPTCRange = C.getOffloadToolChains();
   ArgStringList CmdArgs;
 
-  if (getToolChain().getDriver().isUsingLTO(/* IsOffload */ true)) {
+  for (auto  : llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
+const ToolChain *TC = I.second;
+if (TC->getTriple().isNVPTX()) {
+  CudaInstallationDetector CudaInstallation(D, TheTriple, Args);
+  if (CudaInstallation.isValid())
+CmdArgs.push_back(Args.MakeArgString(
+"-cuda-path=" + CudaInstallation.getInstallPath()));
+}
+  }
+
+  if (D.isUsingLTO(/* IsOffload */ true)) {
 // Pass in target features for each toolchain.
-auto OpenMPTCRange = C.getOffloadToolChains();
 for (auto  :
  llvm::make_range(OpenMPTCRange.first, OpenMPTCRange.second)) {
   const ToolChain *TC = I.second;
@@ -8165,9 +8177,10 @@
 }
 
 // Pass in the bitcode library to be linked during LTO.
-for (auto  : 

[PATCH] D114732: [clang] Mark `trivial_abi` types as "trivially relocatable".

2022-02-03 Thread Devin Jeanpierre via Phabricator via cfe-commits
devin.jeanpierre added a comment.

Thank you @gribozavr2 ! I'll hopefully have a roll-forward ready for you either 
today or tomorrow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114732

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


[PATCH] D114732: [clang] Mark `trivial_abi` types as "trivially relocatable".

2022-02-03 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

I rolled it back while @devin.jeanpierre investigates.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114732

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


[clang] 852afed - Revert "[clang] Mark `trivial_abi` types as "trivially relocatable"."

2022-02-03 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2022-02-03T22:31:44+01:00
New Revision: 852afed5e0200b70047c28ccf4424a17089d17b0

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

LOG: Revert "[clang] Mark `trivial_abi` types as "trivially relocatable"."

This reverts commit 19aa2db023c0128913da223d4fb02c474541ee22. It breaks
a PS4 buildbot.

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/include/clang/AST/Type.h
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/TokenKinds.def
clang/lib/AST/Type.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/attr-trivial-abi.cpp
clang/test/SemaCXX/type-traits.cpp
clang/test/SemaObjCXX/arc-type-traits.mm
clang/test/SemaObjCXX/objc-weak-type-traits.mm

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index e74539d650ce0..f848fb01d8c5e 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1365,11 +1365,6 @@ The following type trait primitives are supported by 
Clang. Those traits marked
 * ``__is_trivially_constructible`` (C++, GNU, Microsoft)
 * ``__is_trivially_copyable`` (C++, GNU, Microsoft)
 * ``__is_trivially_destructible`` (C++, MSVC 2013)
-* ``__is_trivially_relocatable`` (Clang): Returns true if moving an object
-  of the given type, and then destroying the source object, is known to be
-  functionally equivalent to copying the underlying bytes and then dropping the
-  source object on the floor. This is true of trivial types and types which
-  were made trivially relocatable via the ``clang::trivial_abi`` attribute.
 * ``__is_union`` (C++, GNU, Microsoft, Embarcadero)
 * ``__is_unsigned`` (C++, Embarcadero):
   Returns false for enumeration types. Note, before Clang 13, returned true for

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 3c71cbbb9c8f3..a69c0ae67d0a0 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -829,8 +829,6 @@ class QualType {
   /// Return true if this is a trivially copyable type (C++0x [basic.types]p9)
   bool isTriviallyCopyableType(const ASTContext ) const;
 
-  /// Return true if this is a trivially relocatable type.
-  bool isTriviallyRelocatableType(const ASTContext ) const;
 
   /// Returns true if it is a class and it might be dynamic.
   bool mayBeDynamicClass() const;

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index e12a0b259cc2e..efd2af1ab1df3 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -3295,9 +3295,6 @@ If a type is trivial for the purposes of calls, has a 
non-trivial destructor,
 and is passed as an argument by value, the convention is that the callee will
 destroy the object before returning.
 
-If a type is trivial for the purpose of calls, it is assumed to be trivially
-relocatable for the purpose of ``__is_trivially_relocatable``.
-
 Attribute ``trivial_abi`` has no effect in the following cases:
 
 - The class directly declares a virtual base or virtual methods.

diff  --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index b9d5cd76d51d6..e55244e1c3ac9 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -510,7 +510,6 @@ TYPE_TRAIT_1(__has_unique_object_representations,
 KEYWORD(__underlying_type   , KEYCXX)
 
 // Clang-only C++ Type Traits
-TYPE_TRAIT_1(__is_trivially_relocatable, IsTriviallyRelocatable, KEYCXX)
 TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX)
 
 // Embarcadero Expression Traits

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 1c7499c3c237e..774b3e94159db 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2495,25 +2495,6 @@ bool QualType::isTriviallyCopyableType(const ASTContext 
) const {
   return false;
 }
 
-bool QualType::isTriviallyRelocatableType(const ASTContext ) const {
-  QualType BaseElementType = Context.getBaseElementType(*this);
-
-  if (BaseElementType->isIncompleteType()) {
-return false;
-  } else if (const auto *RD = BaseElementType->getAsRecordDecl()) {
-return RD->canPassInRegisters();
-  } else {
-switch (isNonTrivialToPrimitiveDestructiveMove()) {
-case PCK_Trivial:
-  return !isDestructedType();
-case PCK_ARCStrong:
-  return true;
-default:
-  return false;
-}
-  }
-}
-
 bool QualType::isNonWeakInMRRWithObjCWeak(const ASTContext ) const {
   return !Context.getLangOpts().ObjCAutoRefCount &&
  Context.getLangOpts().ObjCWeak &&

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 

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

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

In D118428#3294935 , @ychen wrote:

> The instrumentation is per-function, ideally for each function that has 
> debuginfo and ends up in the executable. So I want it to happen the last in 
> the IR codegen pipeline (target could arrange additional IR passes, they may 
> duplicate functions or anything). Making it codegen pass also makes it 
> LTO-friendly, otherwise, I need to make sure the pass runs once. The JMC pass 
> could be a machine-independent MIR pass too, but I think there is not much 
> benefit for that.

I would argue that function passes shouldn't do function duplication, but being 
LTO friendly is a pretty good reason to want to do instrumentation as part of 
the codegen pipeline. We have encountered problems with sanitizer passes 
running twice in LTO scenarios, and it's annoying to deal with.

So, I think that's a compelling reason to go with your current structure.


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] D118428: [clang-cl] Support the /JMC flag

2022-02-03 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D118428#3294880 , @rnk wrote:

> In D118428#3294411 , @ychen wrote:
>
>> The passes in `lib/Transforms/Instrumentation` runs with 
>> `EmitAssemblyHelper::RunOptimizationPipeline`. JMC pass runs with 
>> `EmitAssemblyHelper::RunCodegenPipeline`.
>
> Sure, but that's a choice. Most of the instrumentation passes (ASan) are also 
> designed to run late to avoid interfering with middle end optimization. Is 
> there a specific reason that JMC has to be a codegen pass? Maybe you've 
> already mentioned it, apologies if so.

The instrumentation is per-function, ideally for each function that has 
debuginfo and ends up in the executable. So I want it to happen the last in the 
IR codegen pipeline (target could arrange additional IR passes, they may 
duplicate functions or anything). Making it codegen pass also makes it 
LTO-friendly, otherwise, I need to make sure the pass runs once. The JMC pass 
could be a machine-independent MIR pass too, but I think there is not much 
benefit for that.


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] D116385: [clangd] Code action for creating an ObjC initializer

2022-02-03 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 405765.
dgoldman added a comment.

mergingEdit --> manual file checks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116385

Files:
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/tweaks/ObjCMemberwiseInitializerTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/ObjCMemberwiseInitializerTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/tweaks/ObjCMemberwiseInitializerTests.cpp
@@ -0,0 +1,153 @@
+//===-- ObjCMemberwiseInitializerTests.cpp --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestTU.h"
+#include "TweakTesting.h"
+#include "gmock/gmock-matchers.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TWEAK_TEST(ObjCMemberwiseInitializer);
+
+TEST_F(ObjCMemberwiseInitializerTest, TestAvailability) {
+  FileName = "TestTU.m";
+
+  // Ensure the action can't be triggered since arc is disabled.
+  EXPECT_UNAVAILABLE(R"cpp(
+@interface Fo^o
+@end
+  )cpp");
+
+  ExtraArgs.push_back("-fobjc-arc");
+
+  // Ensure the action can be initiated on the interface and implementation,
+  // but not on the forward declaration.
+  EXPECT_AVAILABLE(R"cpp(
+@interface Fo^o
+@end
+  )cpp");
+  EXPECT_AVAILABLE(R"cpp(
+@interface Foo
+@end
+
+@implementation F^oo
+@end
+  )cpp");
+  EXPECT_UNAVAILABLE("@class Fo^o;");
+
+  // Ensure that the action can be triggered on ivars and properties,
+  // including selecting both.
+  EXPECT_AVAILABLE(R"cpp(
+@interface Foo {
+  id _fi^eld;
+}
+@end
+  )cpp");
+  EXPECT_AVAILABLE(R"cpp(
+@interface Foo
+@property(nonatomic) id fi^eld;
+@end
+  )cpp");
+  EXPECT_AVAILABLE(R"cpp(
+@interface Foo {
+  id _fi^eld;
+}
+@property(nonatomic) id pr^op;
+@end
+  )cpp");
+
+  // Ensure that the action can't be triggered on property synthesis
+  // and methods.
+  EXPECT_UNAVAILABLE(R"cpp(
+@interface Foo
+@property(nonatomic) id prop;
+@end
+
+@implementation Foo
+@dynamic pr^op;
+@end
+  )cpp");
+  EXPECT_UNAVAILABLE(R"cpp(
+@interface Foo
+@end
+
+@implementation Foo
+- (void)fo^o {}
+@end
+  )cpp");
+}
+
+TEST_F(ObjCMemberwiseInitializerTest, Test) {
+  FileName = "TestTU.m";
+  ExtraArgs.push_back("-fobjc-arc");
+
+  const char *Input = R"cpp(
+@interface Foo {
+  id [[_field;
+}
+@property(nonatomic) id prop]];
+@property(nonatomic) id notSelected;
+@end)cpp";
+  const char *Output = R"cpp(
+@interface Foo {
+  id _field;
+}
+@property(nonatomic) id prop;
+@property(nonatomic) id notSelected;
+- (instancetype)initWithField:(id)field prop:(id)prop;
+
+@end)cpp";
+  EXPECT_EQ(apply(Input), Output);
+
+  Input = R"cpp(
+@interface Foo
+@property(nonatomic, nullable) id somePrettyLongPropertyName;
+@property(nonatomic, nonnull) id someReallyLongPropertyName;
+@end
+
+@implementation F^oo
+
+- (instancetype)init {
+  return self;
+}
+
+@end)cpp";
+  Output = R"cpp(
+@interface Foo
+@property(nonatomic, nullable) id somePrettyLongPropertyName;
+@property(nonatomic, nonnull) id someReallyLongPropertyName;
+- (instancetype)initWithSomePrettyLongPropertyName:(nullable id)somePrettyLongPropertyName someReallyLongPropertyName:(nonnull id)someReallyLongPropertyName;
+
+@end
+
+@implementation Foo
+
+- (instancetype)init {
+  return self;
+}
+
+- (instancetype)initWithSomePrettyLongPropertyName:(nullable id)somePrettyLongPropertyName someReallyLongPropertyName:(nonnull id)someReallyLongPropertyName {
+  self = [super init];
+  if (self) {
+_somePrettyLongPropertyName = somePrettyLongPropertyName;
+_someReallyLongPropertyName = someReallyLongPropertyName;
+  }
+  return self;
+}
+
+@end)cpp";
+  EXPECT_EQ(apply(Input), Output);
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -118,6 +118,7 @@
   tweaks/ExtractFunctionTests.cpp
   tweaks/ExtractVariableTests.cpp
   tweaks/ObjCLocalizeStringLiteralTests.cpp
+  tweaks/ObjCMemberwiseInitializerTests.cpp
   tweaks/PopulateSwitchTests.cpp
   tweaks/RawStringLiteralTests.cpp
   tweaks/RemoveUsingNamespaceTests.cpp
Index: 

[PATCH] D118104: Make run-clang-tidy.py print the configured checks correctly

2022-02-03 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment.

In D118104#3292862 , @JesApp wrote:

> In general though, I think the script is complex enough to warrant some 
> testing.

What is the feasibility of Python unit tests Instead of a heavy-weight `lit` 
oriented test?


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

https://reviews.llvm.org/D118104

___
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-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D118428#3294411 , @ychen wrote:

> The passes in `lib/Transforms/Instrumentation` runs with 
> `EmitAssemblyHelper::RunOptimizationPipeline`. JMC pass runs with 
> `EmitAssemblyHelper::RunCodegenPipeline`.

Sure, but that's a choice. Most of the instrumentation passes (ASan) are also 
designed to run late to avoid interfering with middle end optimization. Is 
there a specific reason that JMC has to be a codegen pass? Maybe you've already 
mentioned it, apologies if so.

As for whether this should be addressed in a follow-up, I think it's best to 
make sure we have the right library structure first, and then iterate on the 
implementation.


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] D118942: [Driver][Android] Removed obsoleted --warn-shared-textrel

2022-02-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: danalbert, srhines.
Herald added a subscriber: danielkiss.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

--warn-shared-textrel is ignored in ld.lld and obsoleted in GNU ld
(https://sourceware.org/bugzilla/show_bug.cgi?id=22909).

Note: binutils can be configured with --enable-textrel-check=[yes|error]
to make GNU ld error for text relocations by default, like ld.lld.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118942

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/linux-ld.c


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -989,12 +989,6 @@
 // CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
 
-// RUN: %clang %s -### -o %t.o 2>&1 \
-// RUN: --target=armv7-linux-android21 \
-// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-WARN-SHARED-TEXTREL %s
-// CHECK-ANDROID-WARN-SHARED-TEXTREL: "{{.*}}ld{{(.exe)?}}"
-// CHECK-ANDROID-WARN-SHARED-TEXTREL: "--warn-shared-textrel"
-
 // RUN: %clang %s -### -o %t.o 2>&1 --target=mips64-linux-gnuabin32 \
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL-GNUABIN32 %s
 // CHECK-MIPS64EL-GNUABIN32: "{{.*}}ld{{(.exe)?}}"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -451,11 +451,6 @@
   CmdArgs.push_back("--fix-cortex-a53-843419");
   }
 
-  // Android does not allow shared text relocations. Emit a warning if the
-  // user's code contains any.
-  if (isAndroid)
-  CmdArgs.push_back("--warn-shared-textrel");
-
   ToolChain.addExtraOpts(CmdArgs);
 
   CmdArgs.push_back("--eh-frame-hdr");


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -989,12 +989,6 @@
 // CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
 
-// RUN: %clang %s -### -o %t.o 2>&1 \
-// RUN: --target=armv7-linux-android21 \
-// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-WARN-SHARED-TEXTREL %s
-// CHECK-ANDROID-WARN-SHARED-TEXTREL: "{{.*}}ld{{(.exe)?}}"
-// CHECK-ANDROID-WARN-SHARED-TEXTREL: "--warn-shared-textrel"
-
 // RUN: %clang %s -### -o %t.o 2>&1 --target=mips64-linux-gnuabin32 \
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL-GNUABIN32 %s
 // CHECK-MIPS64EL-GNUABIN32: "{{.*}}ld{{(.exe)?}}"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -451,11 +451,6 @@
   CmdArgs.push_back("--fix-cortex-a53-843419");
   }
 
-  // Android does not allow shared text relocations. Emit a warning if the
-  // user's code contains any.
-  if (isAndroid)
-  CmdArgs.push_back("--warn-shared-textrel");
-
   ToolChain.addExtraOpts(CmdArgs);
 
   CmdArgs.push_back("--eh-frame-hdr");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D117937: [VFS] Add a "redirecting-with" field to overlays

2022-02-03 Thread Keith Smiley 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 rG502f14d6f2ee: [VFS] Add a redirecting-with field 
to overlays (authored by bnbarham, committed by keith).

Changed prior to commit:
  https://reviews.llvm.org/D117937?vs=404999=405758#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117937

Files:
  clang/test/VFS/Inputs/redirect-and-fallthrough.yaml
  clang/test/VFS/Inputs/unknown-redirect.yaml
  clang/test/VFS/fallback.c
  clang/test/VFS/parse-errors.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1910,7 +1910,25 @@
   Lower);
   EXPECT_EQ(nullptr, FS.get());
 
-  EXPECT_EQ(26, NumDiagnostics);
+  // invalid redirect kind
+  FS = getFromYAMLString("{ 'redirecting-with': 'none', 'roots': [{\n"
+ "  'type': 'directory-remap',\n"
+ "  'name': '//root/A',\n"
+ "  'external-contents': '//root/B' }]}",
+ Lower);
+  EXPECT_EQ(nullptr, FS.get());
+
+  // redirect and fallthrough passed
+  FS = getFromYAMLString("{ 'redirecting-with': 'fallthrough',\n"
+ "  'fallthrough': true,\n"
+ "  'roots': [{\n"
+ "'type': 'directory-remap',\n"
+ "'name': '//root/A',\n"
+ "'external-contents': '//root/B' }]}",
+ Lower);
+  EXPECT_EQ(nullptr, FS.get());
+
+  EXPECT_EQ(28, NumDiagnostics);
 }
 
 TEST_F(VFSFromYAMLTest, UseExternalName) {
@@ -2710,6 +2728,121 @@
   EXPECT_FALSE(FS->exists(_c.path("c")));
 }
 
+TEST_F(VFSFromYAMLTest, RedirectingWith) {
+  IntrusiveRefCntPtr Both(new DummyFileSystem());
+  Both->addDirectory("//root/a");
+  Both->addRegularFile("//root/a/f");
+  Both->addDirectory("//root/b");
+  Both->addRegularFile("//root/b/f");
+
+  IntrusiveRefCntPtr AOnly(new DummyFileSystem());
+  AOnly->addDirectory("//root/a");
+  AOnly->addRegularFile("//root/a/f");
+
+  IntrusiveRefCntPtr BOnly(new DummyFileSystem());
+  BOnly->addDirectory("//root/b");
+  BOnly->addRegularFile("//root/b/f");
+
+  auto BaseStr = std::string("  'roots': [\n"
+ "{\n"
+ "  'type': 'directory-remap',\n"
+ "  'name': '//root/a',\n"
+ "  'external-contents': '//root/b'\n"
+ "}\n"
+ "  ]\n"
+ "}");
+  auto FallthroughStr = "{ 'redirecting-with': 'fallthrough',\n" + BaseStr;
+  auto FallbackStr = "{ 'redirecting-with': 'fallback',\n" + BaseStr;
+  auto RedirectOnlyStr = "{ 'redirecting-with': 'redirect-only',\n" + BaseStr;
+
+  auto ExpectPath = [&](vfs::FileSystem , StringRef Expected,
+StringRef Message) {
+auto AF = FS.openFileForRead("//root/a/f");
+ASSERT_FALSE(AF.getError()) << Message;
+auto AFName = (*AF)->getName();
+ASSERT_FALSE(AFName.getError()) << Message;
+EXPECT_EQ(Expected.str(), AFName.get()) << Message;
+
+auto AS = FS.status("//root/a/f");
+ASSERT_FALSE(AS.getError()) << Message;
+EXPECT_EQ(Expected.str(), AS->getName()) << Message;
+  };
+
+  auto ExpectFailure = [&](vfs::FileSystem , StringRef Message) {
+EXPECT_TRUE(FS.openFileForRead("//root/a/f").getError()) << Message;
+EXPECT_TRUE(FS.status("//root/a/f").getError()) << Message;
+  };
+
+  {
+// `f` in both `a` and `b`
+
+// `fallthrough` tries `external-name` first, so should be `b`
+IntrusiveRefCntPtr Fallthrough =
+getFromYAMLString(FallthroughStr, Both);
+ASSERT_TRUE(Fallthrough.get() != nullptr);
+ExpectPath(*Fallthrough, "//root/b/f", "fallthrough, both exist");
+
+// `fallback` tries the original name first, so should be `a`
+IntrusiveRefCntPtr Fallback =
+getFromYAMLString(FallbackStr, Both);
+ASSERT_TRUE(Fallback.get() != nullptr);
+ExpectPath(*Fallback, "//root/a/f", "fallback, both exist");
+
+// `redirect-only` is the same as `fallthrough` but doesn't try the
+// original on failure, so no change here (ie. `b`)
+IntrusiveRefCntPtr Redirect =
+getFromYAMLString(RedirectOnlyStr, Both);
+ASSERT_TRUE(Redirect.get() != nullptr);
+ExpectPath(*Redirect, "//root/b/f", "redirect-only, both exist");
+  }
+
+  {
+// `f` in `a` only
+
+// Fallthrough to the original path, `a`
+IntrusiveRefCntPtr Fallthrough =
+

[clang] 502f14d - [VFS] Add a "redirecting-with" field to overlays

2022-02-03 Thread Keith Smiley via cfe-commits

Author: Ben Barham
Date: 2022-02-03T13:10:23-08:00
New Revision: 502f14d6f2eee10d2993ed22d820f12cf52462d6

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

LOG: [VFS] Add a "redirecting-with" field to overlays

Extend "fallthrough" to allow a third option: "fallback". Fallthrough
allows the original path to used if the redirected (or mapped) path
fails. Fallback is the reverse of this, ie. use the original path and
fallback to the mapped path otherwise.

While this result *can* be achieved today using multiple overlays, this
adds a much more intuitive option. As an example, take two directories
"A" and "B". We would like files from "A" to be used, unless they don't
exist, in which case the VFS should fallback to those in "B".

With the current fallthrough option this is possible by adding two
overlays: one mapping from A -> B and another mapping from B -> A. Since
the frontend *nests* the two RedirectingFileSystems, the result will
be that "A" is mapped to "B" and back to "A", unless it isn't in "A" in
which case it fallsthrough to "B" (or fails if it exists in neither).

Using "fallback" semantics allows a single overlay instead: one mapping
from "A" to "B" but only using that mapping if the operation in "A"
fails first.

"redirect-only" is used to represent the current "fallthrough: false"
case.

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

Added: 
clang/test/VFS/Inputs/redirect-and-fallthrough.yaml
clang/test/VFS/Inputs/unknown-redirect.yaml
clang/test/VFS/fallback.c

Modified: 
clang/test/VFS/parse-errors.c
llvm/include/llvm/Support/VirtualFileSystem.h
llvm/lib/Support/VirtualFileSystem.cpp
llvm/unittests/Support/VirtualFileSystemTest.cpp

Removed: 




diff  --git a/clang/test/VFS/Inputs/redirect-and-fallthrough.yaml 
b/clang/test/VFS/Inputs/redirect-and-fallthrough.yaml
new file mode 100644
index ..0b6ca03f28c5
--- /dev/null
+++ b/clang/test/VFS/Inputs/redirect-and-fallthrough.yaml
@@ -0,0 +1,11 @@
+{
+  'redirecting-with': 'fallthrough',
+  'fallthrough': true,
+  'roots': [
+{
+  'type': 'directory-remap',
+  'name': '//root/a',
+  'external-contents': '//root/b'
+}
+  ]
+}

diff  --git a/clang/test/VFS/Inputs/unknown-redirect.yaml 
b/clang/test/VFS/Inputs/unknown-redirect.yaml
new file mode 100644
index ..d836fefbe832
--- /dev/null
+++ b/clang/test/VFS/Inputs/unknown-redirect.yaml
@@ -0,0 +1,10 @@
+{
+  'redirecting-with': 'none',
+  'roots': [
+{
+  'type': 'directory-remap',
+  'name': '//root/a',
+  'external-contents': '//root/b'
+}
+  ]
+}

diff  --git a/clang/test/VFS/fallback.c b/clang/test/VFS/fallback.c
new file mode 100644
index ..11392bdc4e44
--- /dev/null
+++ b/clang/test/VFS/fallback.c
@@ -0,0 +1,86 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// Test fallback directory remapping, ie. a directory "Base" which is used as
+// a fallback if files are missing from "UseFirst"
+
+// RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/Both/Base@g" -e 
"s@NAME_DIR@%{/t:regex_replacement}/Both/UseFirst@g" %t/vfs/base.yaml > 
%t/vfs/both.yaml
+
+// RUN: cp -R %t/Both %t/UseFirstOnly
+// RUN: rm -rf %t/UseFirstOnly/Base
+// RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/UseFirstOnly/Base@g" -e 
"s@NAME_DIR@%{/t:regex_replacement}/UseFirstOnly/UseFirst@g" %t/vfs/base.yaml > 
%t/vfs/use-first-only.yaml
+
+// RUN: cp -R %t/Both %t/BaseOnly
+// RUN: rm -rf %t/BaseOnly/UseFirst
+// RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/BaseOnly/Base@g" -e 
"s@NAME_DIR@%{/t:regex_replacement}/BaseOnly/UseFirst@g" %t/vfs/base.yaml > 
%t/vfs/base-only.yaml
+
+// RUN: cp -R %t/Both %t/BFallback
+// RUN: rm %t/BFallback/UseFirst/B.h
+// RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/BFallback/Base@g" -e 
"s@NAME_DIR@%{/t:regex_replacement}/BFallback/UseFirst@g" %t/vfs/base.yaml > 
%t/vfs/b-fallback.yaml
+
+// RUN: cp -R %t/Both %t/CFallback
+// RUN: rm %t/CFallback/UseFirst/C.h
+// RUN: sed -e "s@EXTERNAL_DIR@%{/t:regex_replacement}/CFallback/Base@g" -e 
"s@NAME_DIR@%{/t:regex_replacement}/CFallback/UseFirst@g" %t/vfs/base.yaml > 
%t/vfs/c-fallback.yaml
+
+// Both B.h and C.h are in both folders
+// RUN: %clang_cc1 -Werror -I %t/Both/UseFirst -ivfsoverlay %t/vfs/both.yaml 
-fsyntax-only -E -C %t/main.c 2>&1 | FileCheck --check-prefix=IN_UF %s
+
+// IN_UF: # 1 "{{.*(/|)UseFirst(/|)}}B.h"
+// IN_UF-NEXT: // B.h in UseFirst
+// IN_UF: # 1 "{{.*(/|)UseFirst(/|)}}C.h"
+// IN_UF-NEXT: // C.h in UseFirst
+
+// Base missing, so now they are only in UseFirst
+// RUN: %clang_cc1 -Werror -I %t/UseFirstOnly/UseFirst -ivfsoverlay 
%t/vfs/use-first-only.yaml -fsyntax-only -E -C %t/main.c 2>&1 | FileCheck 
--check-prefix=IN_UF %s
+
+// UseFirst missing, 

[PATCH] D118171: [HWASan] Add __hwasan_init to .preinit_array.

2022-02-03 Thread Matt Morehouse 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 rG95d609b549bb: [HWASan] Add __hwasan_init to .preinit_array. 
(authored by morehouse).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118171

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  compiler-rt/lib/hwasan/CMakeLists.txt
  compiler-rt/lib/hwasan/hwasan_preinit.cpp
  compiler-rt/test/hwasan/TestCases/preinit_array.c

Index: compiler-rt/test/hwasan/TestCases/preinit_array.c
===
--- /dev/null
+++ compiler-rt/test/hwasan/TestCases/preinit_array.c
@@ -0,0 +1,12 @@
+// Test that HWASan shadow is initialized before .preinit_array functions run.
+
+// RUN: %clang_hwasan %s -o %t
+// RUN: %run %t
+
+volatile int Global;
+void StoreToGlobal() { Global = 42; }
+
+__attribute__((section(".preinit_array"), used))
+void (*__StoreToGlobal_preinit)() = StoreToGlobal;
+
+int main() { return Global != 42; }
Index: compiler-rt/lib/hwasan/hwasan_preinit.cpp
===
--- /dev/null
+++ compiler-rt/lib/hwasan/hwasan_preinit.cpp
@@ -0,0 +1,23 @@
+//===-- hwasan_preinit.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file is a part of HWAddressSanitizer, an address sanity checker.
+//
+// Call __hwasan_init at the very early stage of process startup.
+//===--===//
+#include "hwasan_interface_internal.h"
+#include "sanitizer_common/sanitizer_internal_defs.h"
+
+#if SANITIZER_CAN_USE_PREINIT_ARRAY
+// The symbol is called __local_hwasan_preinit, because it's not intended to
+// be exported.
+// This code linked into the main executable when -fsanitize=hwaddress is in
+// the link flags. It can only use exported interface functions.
+__attribute__((section(".preinit_array"), used)) static void (
+*__local_hwasan_preinit)(void) = __hwasan_init;
+#endif
Index: compiler-rt/lib/hwasan/CMakeLists.txt
===
--- compiler-rt/lib/hwasan/CMakeLists.txt
+++ compiler-rt/lib/hwasan/CMakeLists.txt
@@ -27,6 +27,10 @@
   hwasan_new_delete.cpp
   )
 
+set(HWASAN_RTL_PREINIT_SOURCES
+  hwasan_preinit.cpp
+  )
+
 set(HWASAN_RTL_HEADERS
   hwasan.h
   hwasan_allocator.h
@@ -103,6 +107,12 @@
   ADDITIONAL_HEADERS ${HWASAN_RTL_HEADERS}
   CFLAGS ${HWASAN_DYNAMIC_CFLAGS}
   DEFS ${HWASAN_DEFINITIONS})
+add_compiler_rt_object_libraries(RTHwasan_preinit
+  ARCHS ${HWASAN_SUPPORTED_ARCH}
+  SOURCES ${HWASAN_RTL_PREINIT_SOURCES}
+  ADDITIONAL_HEADERS ${HWASAN_RTL_HEADERS}
+  CFLAGS ${HWASAN_RTL_CFLAGS}
+  DEFS ${HWASAN_DEFINITIONS})
 
 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp "")
 add_compiler_rt_object_libraries(RTHwasan_dynamic_version_script_dummy
@@ -143,6 +153,7 @@
 STATIC
 ARCHS ${arch}
 OBJECT_LIBS ${hwasan_object_lib}
+RTHwasan_preinit
 RTInterception
 RTSanitizerCommon
 RTSanitizerCommonLibc
@@ -218,6 +229,13 @@
   endif()
 endforeach()
 
+add_compiler_rt_runtime(clang_rt.hwasan-preinit
+  STATIC
+  ARCHS ${HWASAN_SUPPORTED_ARCH}
+  OBJECT_LIBS RTHwasan_preinit
+  CFLAGS ${HWASAN_RTL_CFLAGS}
+  PARENT_TARGET hwasan)
+
 add_compiler_rt_resource_file(hwasan_ignorelist hwasan_ignorelist.txt hwasan)
 
 add_subdirectory("scripts")
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -838,6 +838,8 @@
 SharedRuntimes.push_back("hwasan_aliases");
   else
 SharedRuntimes.push_back("hwasan");
+  if (!Args.hasArg(options::OPT_shared))
+HelperStaticRuntimes.push_back("hwasan-preinit");
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 95d609b - [HWASan] Add __hwasan_init to .preinit_array.

2022-02-03 Thread Matt Morehouse via cfe-commits

Author: Matt Morehouse
Date: 2022-02-03T13:07:58-08:00
New Revision: 95d609b549bbdc3c1b7368eac427b9e6628f4ace

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

LOG: [HWASan] Add __hwasan_init to .preinit_array.

Fixes segfaults on x86_64 caused by instrumented code running before
shadow is set up.

Reviewed By: pcc

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

Added: 
compiler-rt/lib/hwasan/hwasan_preinit.cpp
compiler-rt/test/hwasan/TestCases/preinit_array.c

Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
compiler-rt/lib/hwasan/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 6364cd133e0b..aa6e852efd50 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -838,6 +838,8 @@ collectSanitizerRuntimes(const ToolChain , const ArgList 
,
 SharedRuntimes.push_back("hwasan_aliases");
   else
 SharedRuntimes.push_back("hwasan");
+  if (!Args.hasArg(options::OPT_shared))
+HelperStaticRuntimes.push_back("hwasan-preinit");
 }
   }
 

diff  --git a/compiler-rt/lib/hwasan/CMakeLists.txt 
b/compiler-rt/lib/hwasan/CMakeLists.txt
index 9e6125594be7..1f0aa0b2777f 100644
--- a/compiler-rt/lib/hwasan/CMakeLists.txt
+++ b/compiler-rt/lib/hwasan/CMakeLists.txt
@@ -27,6 +27,10 @@ set(HWASAN_RTL_CXX_SOURCES
   hwasan_new_delete.cpp
   )
 
+set(HWASAN_RTL_PREINIT_SOURCES
+  hwasan_preinit.cpp
+  )
+
 set(HWASAN_RTL_HEADERS
   hwasan.h
   hwasan_allocator.h
@@ -103,6 +107,12 @@ add_compiler_rt_object_libraries(RTHwasan_dynamic
   ADDITIONAL_HEADERS ${HWASAN_RTL_HEADERS}
   CFLAGS ${HWASAN_DYNAMIC_CFLAGS}
   DEFS ${HWASAN_DEFINITIONS})
+add_compiler_rt_object_libraries(RTHwasan_preinit
+  ARCHS ${HWASAN_SUPPORTED_ARCH}
+  SOURCES ${HWASAN_RTL_PREINIT_SOURCES}
+  ADDITIONAL_HEADERS ${HWASAN_RTL_HEADERS}
+  CFLAGS ${HWASAN_RTL_CFLAGS}
+  DEFS ${HWASAN_DEFINITIONS})
 
 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp "")
 add_compiler_rt_object_libraries(RTHwasan_dynamic_version_script_dummy
@@ -143,6 +153,7 @@ function(add_hwasan_runtimes arch use_aliases)
 STATIC
 ARCHS ${arch}
 OBJECT_LIBS ${hwasan_object_lib}
+RTHwasan_preinit
 RTInterception
 RTSanitizerCommon
 RTSanitizerCommonLibc
@@ -218,6 +229,13 @@ foreach(arch ${HWASAN_SUPPORTED_ARCH})
   endif()
 endforeach()
 
+add_compiler_rt_runtime(clang_rt.hwasan-preinit
+  STATIC
+  ARCHS ${HWASAN_SUPPORTED_ARCH}
+  OBJECT_LIBS RTHwasan_preinit
+  CFLAGS ${HWASAN_RTL_CFLAGS}
+  PARENT_TARGET hwasan)
+
 add_compiler_rt_resource_file(hwasan_ignorelist hwasan_ignorelist.txt hwasan)
 
 add_subdirectory("scripts")

diff  --git a/compiler-rt/lib/hwasan/hwasan_preinit.cpp 
b/compiler-rt/lib/hwasan/hwasan_preinit.cpp
new file mode 100644
index ..8c9c95f413be
--- /dev/null
+++ b/compiler-rt/lib/hwasan/hwasan_preinit.cpp
@@ -0,0 +1,23 @@
+//===-- hwasan_preinit.cpp 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file is a part of HWAddressSanitizer, an address sanity checker.
+//
+// Call __hwasan_init at the very early stage of process startup.
+//===--===//
+#include "hwasan_interface_internal.h"
+#include "sanitizer_common/sanitizer_internal_defs.h"
+
+#if SANITIZER_CAN_USE_PREINIT_ARRAY
+// The symbol is called __local_hwasan_preinit, because it's not intended to
+// be exported.
+// This code linked into the main executable when -fsanitize=hwaddress is in
+// the link flags. It can only use exported interface functions.
+__attribute__((section(".preinit_array"), used)) static void (
+*__local_hwasan_preinit)(void) = __hwasan_init;
+#endif

diff  --git a/compiler-rt/test/hwasan/TestCases/preinit_array.c 
b/compiler-rt/test/hwasan/TestCases/preinit_array.c
new file mode 100644
index ..54d3ee7eea15
--- /dev/null
+++ b/compiler-rt/test/hwasan/TestCases/preinit_array.c
@@ -0,0 +1,12 @@
+// Test that HWASan shadow is initialized before .preinit_array functions run.
+
+// RUN: %clang_hwasan %s -o %t
+// RUN: %run %t
+
+volatile int Global;
+void StoreToGlobal() { Global = 42; }
+
+__attribute__((section(".preinit_array"), used))
+void (*__StoreToGlobal_preinit)() = StoreToGlobal;
+
+int main() { return Global != 42; }



___
cfe-commits 

[PATCH] D118171: [HWASan] Add __hwasan_init to .preinit_array.

2022-02-03 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc 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/D118171/new/

https://reviews.llvm.org/D118171

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


[PATCH] D118934: [OpenMP] Completely remove old device runtime

2022-02-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Don't backport. Deprecate the flag and that's fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118934

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


[PATCH] D118858: [OpenMP] Don't use bound architecture when checking cache on the host

2022-02-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118858

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


[PATCH] D118781: Reduce dependencies on llvm/BinaryFormat/Dwarf.h

2022-02-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay 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/D118781/new/

https://reviews.llvm.org/D118781

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


[PATCH] D114732: [clang] Mark `trivial_abi` types as "trivially relocatable".

2022-02-03 Thread Devin Jeanpierre via Phabricator via cfe-commits
devin.jeanpierre added a comment.

Oops, sorry about that. What is the correct way to test/reproduce the change? 
Do I / can I submit builds to the buildbot manually for testing?

Also, should I be rolling back this change, or no? Not sure of the protocol 
here, this is my first change to Clang.

P.S. that breakage is disturbing -- I would not have expected this sort of 
failure on any platform, and I'm not sure if it reflects a bug on PS4. (It 
seems to be that structs are passed in registers, even if the member variables 
of that struct cannot be.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114732

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


[PATCH] D118782: clangd: Add a break for every case in the PopulateSwitch tweak

2022-02-03 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp:208-209
   Text.append({EnumD->getName(), "::"});
 Text.append({EnumConstant.second.getEnumConstant()->getName(), ":"});
+Text += "break;";
   }




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118782

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


[PATCH] D118781: Reduce dependencies on llvm/BinaryFormat/Dwarf.h

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

  after: 10978519
  before: 11245451

Doesn't appear to be a /huge/ win to me... but I don't mind too much.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118781

___
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-03 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

This diff allows me to boot on bare metal as of v5.17-rc2:

  diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
  index 6aef9ee28a39..8ee176dac669 100644
  --- a/arch/x86/kernel/Makefile
  +++ b/arch/x86/kernel/Makefile
  @@ -125,6 +125,7 @@ obj-$(CONFIG_DEBUG_NMI_SELFTEST) += nmi_selftest.o
  
   obj-$(CONFIG_KVM_GUEST)+= kvm.o kvmclock.o
   obj-$(CONFIG_PARAVIRT) += paravirt.o
  +CFLAGS_paravirt.o += -fzero-call-used-regs=skip
   obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= paravirt-spinlocks.o
   obj-$(CONFIG_PARAVIRT_CLOCK)   += pvclock.o
   obj-$(CONFIG_X86_PMEM_LEGACY_DEVICE) += pmem.o

I have uploaded the config used, the preprocessed file, and the "good" object 
(with the following diff) and the "bad" object (without the above diff) here: 
https://github.com/nathanchance/bug-files/tree/052a31e6d94c1b349cf6f312808794dace24/D110869

If there is any more information I can give, please let me know!


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] D118755: [clangd] Crash in __memcmp_avx2_movbe

2022-02-03 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

@ivanmurashko

Overall looks good to me but please re-upload patch on top of some stable 
revision where failed test passes (it seems unrelated to your changes).

`struct Include` is a light weight structure so having a copy seems to be the 
simplest solution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118755

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


[PATCH] D114732: [clang] Mark `trivial_abi` types as "trivially relocatable".

2022-02-03 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

Hi, your change is causing a test failure in the test attr-trivial-abi.cpp that 
you modified on the PS4 Windows box:

https://lab.llvm.org/staging/#/builders/204/builds/758/steps/7/logs/FAIL__Clang__attr-trivial-abi_cpp

   TEST 'Clang :: SemaCXX/attr-trivial-abi.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 1';   
c:\buildbot-root\llvm-clang-x86_64-sie-win\build\bin\clang.exe -cc1 
-internal-isystem 
c:\buildbot-root\llvm-clang-x86_64-sie-win\build\lib\clang\15.0.0\include 
-nostdsysteminc -fsyntax-only -verify 
C:\buildbot-root\llvm-clang-x86_64-sie-win\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp
 -std=c++11
  --
  Exit Code: 1
  Command Output (stdout):
  --
  $ ":" "RUN: at line 1"
  $ "c:\buildbot-root\llvm-clang-x86_64-sie-win\build\bin\clang.exe" "-cc1" 
"-internal-isystem" 
"c:\buildbot-root\llvm-clang-x86_64-sie-win\build\lib\clang\15.0.0\include" 
"-nostdsysteminc" "-fsyntax-only" "-verify" 
"C:\buildbot-root\llvm-clang-x86_64-sie-win\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp"
 "-std=c++11"
  # command stderr:
  error: 'error' diagnostics seen but not expected: 
File 
C:\buildbot-root\llvm-clang-x86_64-sie-win\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp
 Line 42: static_assert failed due to requirement 
'!__is_trivially_relocatable(S3_3)' ""
File 
C:\buildbot-root\llvm-clang-x86_64-sie-win\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp
 Line 114: static_assert failed due to requirement 
'!__is_trivially_relocatable(deletedCopyMoveConstructor::CopyMoveDeleted)' ""
File 
C:\buildbot-root\llvm-clang-x86_64-sie-win\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp
 Line 119: static_assert failed due to requirement 
'!__is_trivially_relocatable(deletedCopyMoveConstructor::S18)' ""
File 
C:\buildbot-root\llvm-clang-x86_64-sie-win\llvm-project\clang\test\SemaCXX\attr-trivial-abi.cpp
 Line 141: static_assert failed due to requirement 
'!__is_trivially_relocatable(deletedCopyMoveConstructor::S19)' ""
  4 errors generated.
  error: command failed with exit status: 1
  --
  

Can you take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114732

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


[PATCH] D116637: [Clang][Sema][OpenMP] Sema support for `atomic compare`

2022-02-03 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 marked an inline comment as done.
tianshilei1992 added inline comments.



Comment at: clang/test/OpenMP/atomic_ast_print.cpp:964
+  // CHECK-51-NEXT: }
+  // omp51-note@+1 {{in instantiation of function template specialization 
'foo' requested here}}
   return foo(a);

jdoerfert wrote:
> tianshilei1992 wrote:
> > I cannot figure out why I have to add this line and it's not needed before.
> it's caused by the error.
Aha, I see. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116637

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


[PATCH] D118934: [OpenMP] Completely remove old device runtime

2022-02-03 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

If this patch can be back ported to 14, then it's totally fine to remove the 
argument. Otherwise keeping it sounds more reasonable. If we keep it, we'd 
better to emit a warning and then we could remove it in 15 or other version w/o 
any concern that we don't tell users this flag is deprecated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118934

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


[PATCH] D118924: [clang-format] Fix formatting of macro definitions with a leading comment.

2022-02-03 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius planned changes to this revision.
curdeius added a comment.

I'll test it tomorrow but probably a define with a hash as the last character 
may do the job and show the faulty behaviour.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118924

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


[PATCH] D118924: [clang-format] Fix formatting of macro definitions with a leading comment.

2022-02-03 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3574
+  // line.
+  FirstNonCommentOnLine |= FirstOnLine;
+} else {

HazardyKnusperkeks wrote:
> I really don't like bitwise operations on bool. Hit some nasty bugs at my job.
Ok, will do.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3580
 while (!Line->InPPDirective && FormatTok->Tok.is(tok::hash) &&
-   (FormatTok->HasUnescapedNewline || FormatTok->IsFirst)) {
+   FirstNonCommentOnLine) {
   distributeComments(Comments, FormatTok);

HazardyKnusperkeks wrote:
> This does not change within the loop, is that on purpose? Then it should be 
> an if around the loop.
Oh, good catch. It was certainly not on purpose. And it means that I need to 
find a new test case that covers that (if appropriate). Ideas welcome!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118924

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


[PATCH] D118792: [lld][clang][cmake] Clean up a few things

2022-02-03 Thread John Ericson 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 rGe0eeae9a4470: [lld][clang][cmake] Clean up a few things 
(authored by Ericson2314).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118792

Files:
  clang/CMakeLists.txt
  lld/CMakeLists.txt


Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -15,6 +15,10 @@
 
   # Rely on llvm-config.
   set(LLVM_CONFIG_OUTPUT)
+  if(NOT LLVM_CONFIG)
+   # back compat
+   set(LLVM_CONFIG "${LLVM_CONFIG_PATH}")
+  endif()
   if(LLVM_CONFIG)
 set (LLVM_CONFIG_FOUND 1)
 message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
@@ -55,20 +59,22 @@
   endif()
 
   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-  list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
+  list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
   # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
   # LLVM_CONFIG.
   if (NOT LLVM_CONFIG_FOUND)
 # Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
 # path is removed.
-set(MAIN_INCLUDE_DIR ${LLVM_INCLUDE_DIR})
-set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR})
+set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}")
+set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
+# N.B. this is just a default value, the CACHE PATHs below can be 
overriden.
+set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
   endif()
 
-  set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to 
llvm/include")
-  set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
-  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
+  set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to 
llvm/include")
+  set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")
+  set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source 
tree")
 
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -71,24 +71,26 @@
   endif()
 
   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-  list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
+  list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
   # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
   # LLVM_CONFIG.
   if (NOT LLVM_CONFIG_FOUND)
 # Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
 # path is removed.
-set(MAIN_INCLUDE_DIR ${LLVM_INCLUDE_DIR})
-set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR})
-set(TOOLS_BINARY_DIR ${LLVM_TOOLS_BINARY_DIR})
-set(LIBRARY_DIR ${LLVM_LIBRARY_DIR})
-  endif()
-
-  set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to 
llvm/include")
-  set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
-  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
-  set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
-  set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
+set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}")
+set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
+# N.B. this is just a default value, the CACHE PATHs below can be 
overriden.
+set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
+set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}")
+set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}")
+  endif()
+
+  set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to 
llvm/include")
+  set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")
+  set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source 
tree")
+  set(LLVM_TOOLS_BINARY_DIR "${TOOLS_BINARY_DIR}" CACHE PATH "Path to 
llvm/bin")
+  set(LLVM_LIBRARY_DIR "${LIBRARY_DIR}" CACHE PATH "Path to llvm/lib")
 
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)


Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -15,6 +15,10 @@
 
   # Rely on llvm-config.
   set(LLVM_CONFIG_OUTPUT)
+  if(NOT LLVM_CONFIG)
+   # back compat
+   set(LLVM_CONFIG "${LLVM_CONFIG_PATH}")
+  endif()
   if(LLVM_CONFIG)
 set (LLVM_CONFIG_FOUND 1)
 message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
@@ -55,20 +59,22 @@
   endif()
 
   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-  list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
+  list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
   # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
   # LLVM_CONFIG.
   if (NOT LLVM_CONFIG_FOUND)
 # Pull values from LLVMConfig.cmake.  We can drop this once the 

[clang] e0eeae9 - [lld][clang][cmake] Clean up a few things

2022-02-03 Thread John Ericson via cfe-commits

Author: John Ericson
Date: 2022-02-03T20:01:28Z
New Revision: e0eeae9a447004cc346d9bf36c0d02f45e276a7c

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

LOG: [lld][clang][cmake] Clean up a few things

- If not using `llvm-config`, `LLVM_MAIN_SRC_DIR` now has a sane default

- `LLVM_CONFIG_PATH` will continue to work for LLD for back compat.

- More quoting of paths in an abundance of caution.

Reviewed By: nikic

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

Added: 


Modified: 
clang/CMakeLists.txt
lld/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 2bb395ffece53..1cc9bacf4e5eb 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -71,24 +71,26 @@ if(CLANG_BUILT_STANDALONE)
   endif()
 
   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-  list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
+  list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
   # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
   # LLVM_CONFIG.
   if (NOT LLVM_CONFIG_FOUND)
 # Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
 # path is removed.
-set(MAIN_INCLUDE_DIR ${LLVM_INCLUDE_DIR})
-set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR})
-set(TOOLS_BINARY_DIR ${LLVM_TOOLS_BINARY_DIR})
-set(LIBRARY_DIR ${LLVM_LIBRARY_DIR})
-  endif()
-
-  set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to 
llvm/include")
-  set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
-  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
-  set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
-  set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
+set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}")
+set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
+# N.B. this is just a default value, the CACHE PATHs below can be 
overriden.
+set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
+set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}")
+set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}")
+  endif()
+
+  set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to 
llvm/include")
+  set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")
+  set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source 
tree")
+  set(LLVM_TOOLS_BINARY_DIR "${TOOLS_BINARY_DIR}" CACHE PATH "Path to 
llvm/bin")
+  set(LLVM_LIBRARY_DIR "${LIBRARY_DIR}" CACHE PATH "Path to llvm/lib")
 
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)

diff  --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index 1a53c5bf47a8d..9bcc135665d02 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -15,6 +15,10 @@ if(LLD_BUILT_STANDALONE)
 
   # Rely on llvm-config.
   set(LLVM_CONFIG_OUTPUT)
+  if(NOT LLVM_CONFIG)
+   # back compat
+   set(LLVM_CONFIG "${LLVM_CONFIG_PATH}")
+  endif()
   if(LLVM_CONFIG)
 set (LLVM_CONFIG_FOUND 1)
 message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
@@ -55,20 +59,22 @@ if(LLD_BUILT_STANDALONE)
   endif()
 
   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-  list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
+  list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
   # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
   # LLVM_CONFIG.
   if (NOT LLVM_CONFIG_FOUND)
 # Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
 # path is removed.
-set(MAIN_INCLUDE_DIR ${LLVM_INCLUDE_DIR})
-set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR})
+set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}")
+set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
+# N.B. this is just a default value, the CACHE PATHs below can be 
overriden.
+set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
   endif()
 
-  set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to 
llvm/include")
-  set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
-  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
+  set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to 
llvm/include")
+  set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")
+  set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source 
tree")
 
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)



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


[PATCH] D118934: [OpenMP] Completely remove old device runtime

2022-02-03 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2470
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",
-  LangOpts<"OpenMPTargetNewRuntime">, DefaultTrue,

tianshilei1992 wrote:
> Since LLVM 14 has this flags, we probably want to keep this argument, mark it 
> as deprecated, and emit a warning saying there is no old runtime anymore.
Or port this to 14


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118934

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


[PATCH] D118934: [OpenMP] Completely remove old device runtime

2022-02-03 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2470
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",
-  LangOpts<"OpenMPTargetNewRuntime">, DefaultTrue,

tianshilei1992 wrote:
> Since LLVM 14 has this flags, we probably want to keep this argument, mark it 
> as deprecated, and emit a warning saying there is no old runtime anymore.
What's LLVM's policy on deprecating flags? I would prefer to remove it but 
keeping it as a no-op would be fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118934

___
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-03 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
aeubanks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

-O1 doesn't seem necessary here.


Repository:
  rG LLVM Github Monorepo

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


[PATCH] D118934: [OpenMP] Completely remove old device runtime

2022-02-03 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

I've read this closely and can't think of anywhere else that needs to be 
patched. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118934

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


[PATCH] D118934: [OpenMP] Completely remove old device runtime

2022-02-03 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2470
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",
-  LangOpts<"OpenMPTargetNewRuntime">, DefaultTrue,

Since LLVM 14 has this flags, we probably want to keep this argument, mark it 
as deprecated, and emit a warning saying there is no old runtime anymore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118934

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


[PATCH] D118935: [SYCL] Disallow explicit casts between mismatching address spaces

2022-02-03 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon created this revision.
Fznamznon added a reviewer: bader.
Herald added subscribers: Naghasan, Anastasia, ebevhan, yaxunl.
Fznamznon 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/D118935

Files:
  clang/lib/Sema/SemaCast.cpp
  clang/test/CodeGenSYCL/address-space-conversions.cpp
  clang/test/SemaSYCL/address-space-conversions.cpp


Index: clang/test/SemaSYCL/address-space-conversions.cpp
===
--- clang/test/SemaSYCL/address-space-conversions.cpp
+++ clang/test/SemaSYCL/address-space-conversions.cpp
@@ -55,6 +55,9 @@
   baz(NoAS);   // expected-error {{no matching 
function for call to 'baz'}}
   __attribute__((opencl_local)) int *l = NoAS; // expected-error {{cannot 
initialize a variable of type '__local int *' with an lvalue of type 'int *'}}
 
+  // Explicit casts between disjoint address spaces are disallowed
+  GLOB = (__attribute__((opencl_global)) int *)PRIV; // expected-error 
{{C-style cast from '__private int *' to '__global int *' converts between 
mismatching address spaces}}
+
   (void)static_cast(GLOB);
   (void)static_cast(GLOB);
   int *i = GLOB;
Index: clang/test/CodeGenSYCL/address-space-conversions.cpp
===
--- clang/test/CodeGenSYCL/address-space-conversions.cpp
+++ clang/test/CodeGenSYCL/address-space-conversions.cpp
@@ -35,7 +35,7 @@
   __attribute__((opencl_global_host)) int *GLOBHOST;
 
   // Explicit conversions
-  // From names address spaces to default address space
+  // From named address spaces to default address space
   // CHECK-DAG: [[GLOB_LOAD:%[a-zA-Z0-9]+]] = load i32 addrspace(1)*, i32 
addrspace(1)* addrspace(4)* [[GLOB]].ascast
   // CHECK-DAG: [[GLOB_CAST:%[a-zA-Z0-9]+]] = addrspacecast i32 addrspace(1)* 
[[GLOB_LOAD]] to i32 addrspace(4)*
   // CHECK-DAG: store i32 addrspace(4)* [[GLOB_CAST]], i32 addrspace(4)* 
addrspace(4)* [[NoAS]].ascast
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2545,7 +2545,7 @@
 static TryCastResult TryAddressSpaceCast(Sema , ExprResult ,
  QualType DestType, bool CStyle,
  unsigned , CastKind ) {
-  if (!Self.getLangOpts().OpenCL)
+  if (!Self.getLangOpts().OpenCL && !Self.getLangOpts().SYCLIsDevice)
 // FIXME: As compiler doesn't have any information about overlapping addr
 // spaces at the moment we have to be permissive here.
 return TC_NotApplicable;


Index: clang/test/SemaSYCL/address-space-conversions.cpp
===
--- clang/test/SemaSYCL/address-space-conversions.cpp
+++ clang/test/SemaSYCL/address-space-conversions.cpp
@@ -55,6 +55,9 @@
   baz(NoAS);   // expected-error {{no matching function for call to 'baz'}}
   __attribute__((opencl_local)) int *l = NoAS; // expected-error {{cannot initialize a variable of type '__local int *' with an lvalue of type 'int *'}}
 
+  // Explicit casts between disjoint address spaces are disallowed
+  GLOB = (__attribute__((opencl_global)) int *)PRIV; // expected-error {{C-style cast from '__private int *' to '__global int *' converts between mismatching address spaces}}
+
   (void)static_cast(GLOB);
   (void)static_cast(GLOB);
   int *i = GLOB;
Index: clang/test/CodeGenSYCL/address-space-conversions.cpp
===
--- clang/test/CodeGenSYCL/address-space-conversions.cpp
+++ clang/test/CodeGenSYCL/address-space-conversions.cpp
@@ -35,7 +35,7 @@
   __attribute__((opencl_global_host)) int *GLOBHOST;
 
   // Explicit conversions
-  // From names address spaces to default address space
+  // From named address spaces to default address space
   // CHECK-DAG: [[GLOB_LOAD:%[a-zA-Z0-9]+]] = load i32 addrspace(1)*, i32 addrspace(1)* addrspace(4)* [[GLOB]].ascast
   // CHECK-DAG: [[GLOB_CAST:%[a-zA-Z0-9]+]] = addrspacecast i32 addrspace(1)* [[GLOB_LOAD]] to i32 addrspace(4)*
   // CHECK-DAG: store i32 addrspace(4)* [[GLOB_CAST]], i32 addrspace(4)* addrspace(4)* [[NoAS]].ascast
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2545,7 +2545,7 @@
 static TryCastResult TryAddressSpaceCast(Sema , ExprResult ,
  QualType DestType, bool CStyle,
  unsigned , CastKind ) {
-  if (!Self.getLangOpts().OpenCL)
+  if (!Self.getLangOpts().OpenCL && !Self.getLangOpts().SYCLIsDevice)
 // FIXME: As compiler doesn't have any information about overlapping addr
 // spaces at 

[PATCH] D118924: [clang-format] Fix formatting of macro definitions with a leading comment.

2022-02-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3574
+  // line.
+  FirstNonCommentOnLine |= FirstOnLine;
+} else {

I really don't like bitwise operations on bool. Hit some nasty bugs at my job.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3580
 while (!Line->InPPDirective && FormatTok->Tok.is(tok::hash) &&
-   (FormatTok->HasUnescapedNewline || FormatTok->IsFirst)) {
+   FirstNonCommentOnLine) {
   distributeComments(Comments, FormatTok);

This does not change within the loop, is that on purpose? Then it should be an 
if around the loop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118924

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


[PATCH] D116637: [Clang][Sema][OpenMP] Sema support for `atomic compare`

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



Comment at: clang/test/OpenMP/atomic_ast_print.cpp:964
+  // CHECK-51-NEXT: }
+  // omp51-note@+1 {{in instantiation of function template specialization 
'foo' requested here}}
   return foo(a);

tianshilei1992 wrote:
> I cannot figure out why I have to add this line and it's not needed before.
it's caused by the error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116637

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


  1   2   3   >