[PATCH] D99810: [ifs][elfabi] Merge llvm-elfabi tool into llvm-ifs

2021-04-06 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This change is pretty large so I'm wondering if we could possibly split it into 
two changes, one that does the purely mechanical renaming of ELF and TBE to 
IFS, and second one that merges the two tools?




Comment at: clang/lib/Driver/ToolChains/InterfaceStubs.cpp:26
   const bool WriteBin = !Args.getLastArg(options::OPT_emit_merged_ifs);
-  CmdArgs.push_back(WriteBin ? "write-bin" : "write-ifs");
+  CmdArgs.push_back(WriteBin ? "--output-format=ELF" : "--output-format=IFS");
   CmdArgs.push_back("-o");

Do we know whether the binary output format for the current target is ELF? 
Shouldn't we check it first?



Comment at: llvm/include/llvm/InterfaceStub/IFSStub.h:28-52
+enum class IFSSymbolType {
   NoType = ELF::STT_NOTYPE,
   Object = ELF::STT_OBJECT,
   Func = ELF::STT_FUNC,
   TLS = ELF::STT_TLS,
 
   // Type information is 4 bits, so 16 is safely out of range.

Since IFS is supposed to be binary format agnostic, it's a bit confusing to use 
ELF constants here. Could we instead define these values ourselves and convert 
them to the corresponding ELF values when generating the stub?



Comment at: llvm/include/llvm/InterfaceStub/IFSStub.h:42
 
   // Endianness info is 1 bytes, 256 is safely out of rance.
   Unknown = 256,





Comment at: llvm/include/llvm/InterfaceStub/IFSStub.h:50
 
   // Bit width info is 1 bytes, 256 is safely out of rance.
   Unknown = 256,





Comment at: llvm/tools/llvm-elfabi/llvm-elfabi.cpp:83
 /// of the YAML parser.
-static Error writeTBE(StringRef FilePath, ELFStub &Stub) {
+static Error writeTBE(StringRef FilePath, IFSStub &Stub) {
   // Write TBE to memory first.





Comment at: llvm/tools/llvm-ifs/llvm-ifs.cpp:139
 
-  if (Stub->IfsVersion > IFSVersionCurrent)
-return make_error(
-"IFS version " + Stub->IfsVersion.getAsString() + " is unsupported.",
-std::make_error_code(std::errc::invalid_argument));
+  // Fall back to reading as a tbe.
+  if (InputFormat.getNumOccurrences() == 0 || InputFormat == FileFormat::IFS) {





Comment at: llvm/tools/llvm-ifs/llvm-ifs.cpp:141
+  if (InputFormat.getNumOccurrences() == 0 || InputFormat == FileFormat::IFS) {
+Expected> StubFromTBE =
+readIFSFromBuffer(FileReadBuffer->getBuffer());





Comment at: llvm/tools/llvm-ifs/llvm-ifs.cpp:233
+/// of the YAML parser.
+static Error writeTBE(StringRef FilePath, IFSStub &Stub) {
+  // Write TBE to memory first.





Comment at: llvm/tools/llvm-ifs/llvm-ifs.cpp:374
+  if (SOName.getNumOccurrences() == 1)
+Stub.SoName = SOName;
+  Optional OverrideArch;

The case difference on the left and right side (`SoName` vs `SOName`) is 
confusing, I'd unify them.



Comment at: llvm/tools/llvm-ifs/llvm-ifs.cpp:379-381
+  if (OptArch.getNumOccurrences() == 1) {
+OverrideArch = ELF::convertArchNameToEMachine(OptArch.getValue());
+  }

No need for curly braces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99810

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


[PATCH] D99860: Remove `COMPILER_RT_INSTALL_PATH`

2021-04-06 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

I'm worried that overriding `CMAKE_INSTALL_PREFIX` is going to break the 
runtimes build where we build compiler-rt, libcxx, libcxxabi, libunwind in a 
single CMake build, and compiler-rt always comes first see 
https://github.com/llvm/llvm-project/blob/98742e42fc50f58d3f2d3f2cdbbf540288c134b9/runtimes/CMakeLists.txt#L57.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99860

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


[PATCH] D99158: [RISCV][WIP] Implement intrinsics for P extension

2021-04-06 Thread Jim Lin via Phabricator via cfe-commits
Jim updated this revision to Diff 335416.
Jim edited the summary of this revision.
Jim added a comment.

Address comments.


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

https://reviews.llvm.org/D99158

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/RISCV/rvp-intrinsics/rv32p.c
  clang/test/CodeGen/RISCV/rvp-intrinsics/rv64p.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoP.td
  llvm/test/CodeGen/RISCV/rvp/intrinsics-rv32p.ll
  llvm/test/CodeGen/RISCV/rvp/intrinsics-rv64p.ll

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


[PATCH] D99158: [RISCV][WIP] Implement intrinsics for P extension

2021-04-06 Thread Jim Lin via Phabricator via cfe-commits
Jim added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:706
+
+  setOperationAction(ISD::BITCAST, VT, Legal);
+

craig.topper wrote:
> What about bitcast from float/double to any of these vector types? I'm guess 
> that's not legal.
Yes, it is not legal bitcast from float/double to any of these vector types.
All operations of these vector types have been expanded on line 760.
Only bitcast from/to v4i8/v2i16, v8i8/v4i16/v2i32 to/from i32, i64 are legal.


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

https://reviews.llvm.org/D99158

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


[PATCH] D99669: [RISCV][Clang] Add more RVV Floating-Point intrinsic functions.

2021-04-06 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:315
+multiclass RVVFloatingWidenTerBuiltinSet {
+  let HasMaskedOffOperand = false, Log2LMUL = [-2, -1, 0, 1, 2] in {
+defm "" : RVVOutOp1Op2BuiltinSethttps://reviews.llvm.org/D99669/new/

https://reviews.llvm.org/D99669

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


[PATCH] D95590: [RISCV] Define preprocessor definitions for 'P' extension

2021-04-06 Thread Jim Lin via Phabricator via cfe-commits
Jim abandoned this revision.
Jim added a comment.
Herald added a subscriber: vkmr.

Merge this patch into https://reviews.llvm.org/D95588


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95590

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


[PATCH] D95589: [RISCV] Support experimental 'P' extension 0.9

2021-04-06 Thread Jim Lin via Phabricator via cfe-commits
Jim abandoned this revision.
Jim added a comment.
Herald added a subscriber: vkmr.

Merge this patch into https://reviews.llvm.org/D95588


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95589

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


[clang] cc26943 - [clang][cli] Ensure plugin args are generated in deterministic order

2021-04-06 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-04-06T09:24:42+02:00
New Revision: cc26943313def7a985f72eadc7499ac981daabc6

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

LOG: [clang][cli] Ensure plugin args are generated in deterministic order

The '-plugin-arg' command-line arguments are not being generated in 
deterministic order.

This patch changes the storage from `std::unordered_map` to `std::map` to 
enforce ordering.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Frontend/FrontendOptions.h
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/FrontendOptions.h 
b/clang/include/clang/Frontend/FrontendOptions.h
index 5c9a21813b62..d7f9039872e6 100644
--- a/clang/include/clang/Frontend/FrontendOptions.h
+++ b/clang/include/clang/Frontend/FrontendOptions.h
@@ -16,9 +16,9 @@
 #include "clang/Serialization/ModuleFileExtension.h"
 #include "llvm/ADT/StringRef.h"
 #include 
+#include 
 #include 
 #include 
-#include 
 #include 
 
 namespace llvm {
@@ -404,7 +404,7 @@ class FrontendOptions {
   std::string ActionName;
 
   /// Args to pass to the plugins
-  std::unordered_map> PluginArgs;
+  std::map> PluginArgs;
 
   /// The list of plugin actions to run in addition to the normal action.
   std::vector AddPluginActions;

diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index b846e6ead28c..066d02b02fa9 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -877,4 +877,15 @@ TEST_F(CommandLineTest, RoundTrip) {
 ShowIncludesDestination::Stdout);
   ASSERT_TRUE(Invocation.getDependencyOutputOpts().ShowHeaderIncludes);
 }
+
+TEST_F(CommandLineTest, PluginArgsRoundTripDeterminism) {
+  const char *Args[] = {
+  "-plugin-arg-blink-gc-plugin", "no-members-in-stack-allocated",
+  "-plugin-arg-find-bad-constructs", "checked-ptr-as-trivial-member",
+  "-plugin-arg-find-bad-constructs", "check-ipc",
+  // Enable round-trip to ensure '-plugin-arg' generation is deterministic.
+  "-round-trip-args"};
+
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+}
 } // anonymous namespace



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


[PATCH] D99879: [clang][cli] Ensure plugin args are generated in deterministic order

2021-04-06 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcc26943313de: [clang][cli] Ensure plugin args are generated 
in deterministic order (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99879

Files:
  clang/include/clang/Frontend/FrontendOptions.h
  clang/unittests/Frontend/CompilerInvocationTest.cpp


Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -877,4 +877,15 @@
 ShowIncludesDestination::Stdout);
   ASSERT_TRUE(Invocation.getDependencyOutputOpts().ShowHeaderIncludes);
 }
+
+TEST_F(CommandLineTest, PluginArgsRoundTripDeterminism) {
+  const char *Args[] = {
+  "-plugin-arg-blink-gc-plugin", "no-members-in-stack-allocated",
+  "-plugin-arg-find-bad-constructs", "checked-ptr-as-trivial-member",
+  "-plugin-arg-find-bad-constructs", "check-ipc",
+  // Enable round-trip to ensure '-plugin-arg' generation is deterministic.
+  "-round-trip-args"};
+
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+}
 } // anonymous namespace
Index: clang/include/clang/Frontend/FrontendOptions.h
===
--- clang/include/clang/Frontend/FrontendOptions.h
+++ clang/include/clang/Frontend/FrontendOptions.h
@@ -16,9 +16,9 @@
 #include "clang/Serialization/ModuleFileExtension.h"
 #include "llvm/ADT/StringRef.h"
 #include 
+#include 
 #include 
 #include 
-#include 
 #include 
 
 namespace llvm {
@@ -404,7 +404,7 @@
   std::string ActionName;
 
   /// Args to pass to the plugins
-  std::unordered_map> PluginArgs;
+  std::map> PluginArgs;
 
   /// The list of plugin actions to run in addition to the normal action.
   std::vector AddPluginActions;


Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -877,4 +877,15 @@
 ShowIncludesDestination::Stdout);
   ASSERT_TRUE(Invocation.getDependencyOutputOpts().ShowHeaderIncludes);
 }
+
+TEST_F(CommandLineTest, PluginArgsRoundTripDeterminism) {
+  const char *Args[] = {
+  "-plugin-arg-blink-gc-plugin", "no-members-in-stack-allocated",
+  "-plugin-arg-find-bad-constructs", "checked-ptr-as-trivial-member",
+  "-plugin-arg-find-bad-constructs", "check-ipc",
+  // Enable round-trip to ensure '-plugin-arg' generation is deterministic.
+  "-round-trip-args"};
+
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+}
 } // anonymous namespace
Index: clang/include/clang/Frontend/FrontendOptions.h
===
--- clang/include/clang/Frontend/FrontendOptions.h
+++ clang/include/clang/Frontend/FrontendOptions.h
@@ -16,9 +16,9 @@
 #include "clang/Serialization/ModuleFileExtension.h"
 #include "llvm/ADT/StringRef.h"
 #include 
+#include 
 #include 
 #include 
-#include 
 #include 
 
 namespace llvm {
@@ -404,7 +404,7 @@
   std::string ActionName;
 
   /// Args to pass to the plugins
-  std::unordered_map> PluginArgs;
+  std::map> PluginArgs;
 
   /// The list of plugin actions to run in addition to the normal action.
   std::vector AddPluginActions;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99527: [RISCV][Clang] Add RVV Widening Integer Extension intrinsic functions.

2021-04-06 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai accepted this revision.
HsiangKai added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: clang/include/clang/Basic/riscv_vector.td:338
+ string type_range> {
+  let IRName = intrinsic_name, IRNameMask = intrinsic_name #"_mask",
+  MangledName = NAME, IntrinsicTypes = [-1, 0] in {

space after '#'.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99527

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


[PATCH] D99158: [RISCV][WIP] Implement intrinsics for P extension

2021-04-06 Thread Jim Lin via Phabricator via cfe-commits
Jim added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:17944
+
+  // P extension
+#define EMIT_BUILTIN(NAME, INT) \

I have concern here. It has lots of duplicate code if the code style is the 
same as B in the top.
And the name of macro is not good.


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

https://reviews.llvm.org/D99158

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


[PATCH] D99160: [X86][FastISEL] Support DW_TAG_call_site_parameter with FastISEL

2021-04-06 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

In D99160#2669576 , @dblaikie wrote:

> In D99160#2668977 , @djtodoro wrote:
>
>> I think that the Debug Entry Values feature should not be enabled by default 
>> for non optimized code, so the `TargetOptions::ShouldEmitDebugEntryValues()` 
>> should be patched with checking of optimization level (it should be > 0).
>
> That's currently intended to be already handled by the frontend, right? 
> (clang only sets `EnableDebugEntryValues` (which `ShouldEmitDebugEntryValues` 
> checks (hmm, it checks under 'or', not 'and', so I'm not sure where the "only 
> above -O0" is implemented, but it is implemented somewhere?) if optimizations 
> are enabled, yeah?)
>
> Oh, is entry_values actually not conditionalized? It's only the call_site 
> support that's currently conditionalized on "above -O0"?

Looks like there is no explicit check of optimization level (above "-O0"), 
neither on frontend nor backend for entry-values generation. I think it is the 
situation since there should not be any optimization (at least that I am aware 
of, in the case of C/C++) that would cause the entry-values generation...

> Hmm - If that's the case, and we currently have some cases where entry_values 
> are emitted at -O0, I'm not sure /not/ emitting those is the right call 
> either. If we believe/have data to show that there are so few useful uses of 
> entry_value at -O0 that it's not worth the DWARF size growth to put 
> call_sites in at -O0, then I think it might still be worth leaving the 
> entry_values in (unless they take up a bunch of extra space) for the cases of 
> mixed optimization compilation (-O0 some code you're debugging, but building 
> the rest with optimizations).

Yeah... That is valuable example... I am thinking in that direction as well, 
and I am closer to the enabling it for -O0 case if that is useful (and there is 
no dramatic cost in terms of DWARF size).


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

https://reviews.llvm.org/D99160

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


[PATCH] D99708: [X86] Enable compilation of user interrupt handlers.

2021-04-06 Thread Wang Tianqing via Phabricator via cfe-commits
tianqing updated this revision to Diff 335426.
tianqing added a comment.

Update handling of -mcmodel=kernel.


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

https://reviews.llvm.org/D99708

Files:
  clang/lib/Headers/uintrintrin.h
  llvm/lib/Target/X86/X86ExpandPseudo.cpp
  llvm/test/CodeGen/X86/x86-64-intrcc-uintr.ll

Index: llvm/test/CodeGen/X86/x86-64-intrcc-uintr.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/x86-64-intrcc-uintr.ll
@@ -0,0 +1,117 @@
+; RUN: llc < %s | FileCheck %s -check-prefixes=CHECK,CHECK-USER
+; RUN: llc -O0 < %s | FileCheck %s -check-prefixes=CHECK0,CHECK0-USER
+; RUN: llc -code-model=kernel < %s | FileCheck %s -check-prefixes=CHECK,CHECK-KERNEL
+; RUN: llc -O0 -code-model=kernel < %s | FileCheck %s -check-prefixes=CHECK0,CHECK0-KERNEL
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%struct.__uintr_frame = type { i64, i64, i64 }
+
+; #include 
+;
+; void
+; __attribute__ ((interrupt))
+; test_uintr_isr_cc_empty(struct __uintr_frame *frame, unsigned long long uirrv)
+; {
+; }
+
+define dso_local x86_intrcc void @test_uintr_isr_cc_empty(%struct.__uintr_frame* nocapture byval(%struct.__uintr_frame) %frame, i64 %uirrv) #0 {
+; CHECK-LABEL: test_uintr_isr_cc_empty:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:pushq %rax
+; CHECK-NEXT:cld
+; CHECK-NEXT:addq $16, %rsp
+; CHECK-USER:uiret
+; CHECK-KERNEL:  iretq
+;
+; CHECK0-LABEL: test_uintr_isr_cc_empty:
+; CHECK0:   # %bb.0: # %entry
+; CHECK0-NEXT:pushq %rax
+; CHECK0-NEXT:cld
+; CHECK0-NEXT:addq $16, %rsp
+; CHECK0-USER:uiret
+; CHECK0-KERNEL:  iretq
+entry:
+  ret void
+}
+
+; unsigned long long g_rip;
+; unsigned long long g_rflags;
+; unsigned long long g_rsp;
+; unsigned long long g_uirrv;
+;
+; void
+; __attribute__((interrupt))
+; test_uintr_isr_cc_args(struct __uintr_frame *frame, unsigned long long uirrv)
+; {
+;   g_rip = frame->rip;
+;   g_rflags = frame->rflags;
+;   g_rsp = frame->rsp;
+;   g_uirrv = uirrv;
+; }
+@g_rip = dso_local local_unnamed_addr global i64 0, align 8
+@g_rflags = dso_local local_unnamed_addr global i64 0, align 8
+@g_rsp = dso_local local_unnamed_addr global i64 0, align 8
+@g_uirrv = dso_local local_unnamed_addr global i64 0, align 8
+
+define dso_local x86_intrcc void @test_uintr_isr_cc_args(%struct.__uintr_frame* nocapture readonly byval(%struct.__uintr_frame) %frame, i64 %uirrv) #0 {
+; CHECK-LABEL: test_uintr_isr_cc_args:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:pushq %rax
+; CHECK-NEXT:pushq %rax
+; CHECK-NEXT:pushq %rdx
+; CHECK-NEXT:pushq %rcx
+; CHECK-NEXT:cld
+; CHECK-NEXT:movq 32(%rsp), %rax
+; CHECK-NEXT:movq 40(%rsp), %rcx
+; CHECK-NEXT:movq 48(%rsp), %rdx
+; CHECK-NEXT:movq %rcx, g_rip(%rip)
+; CHECK-NEXT:movq %rdx, g_rflags(%rip)
+; CHECK-NEXT:movq 56(%rsp), %rcx
+; CHECK-NEXT:movq %rcx, g_rsp(%rip)
+; CHECK-NEXT:movq %rax, g_uirrv(%rip)
+; CHECK-NEXT:popq %rcx
+; CHECK-NEXT:popq %rdx
+; CHECK-NEXT:popq %rax
+; CHECK-NEXT:addq $16, %rsp
+; CHECK-USER:uiret
+; CHECK-KERNEL:  iretq
+;
+; CHECK0-LABEL: test_uintr_isr_cc_args:
+; CHECK0:   # %bb.0: # %entry
+; CHECK0-NEXT:pushq %rax
+; CHECK0-NEXT:pushq %rax
+; CHECK0-NEXT:pushq %rdx
+; CHECK0-NEXT:pushq %rcx
+; CHECK0-NEXT:cld
+; CHECK0-NEXT:movq 32(%rsp), %rax
+; CHECK0-NEXT:leaq 40(%rsp), %rcx
+; CHECK0-NEXT:movq (%rcx), %rdx
+; CHECK0-NEXT:movq %rdx, g_rip(%rip)
+; CHECK0-NEXT:movq 8(%rcx), %rdx
+; CHECK0-NEXT:movq %rdx, g_rflags(%rip)
+; CHECK0-NEXT:movq 16(%rcx), %rcx
+; CHECK0-NEXT:movq %rcx, g_rsp(%rip)
+; CHECK0-NEXT:movq %rax, g_uirrv(%rip)
+; CHECK0-NEXT:popq %rcx
+; CHECK0-NEXT:popq %rdx
+; CHECK0-NEXT:popq %rax
+; CHECK0-NEXT:addq $16, %rsp
+; CHECK0-USER:uiret
+; CHECK0-KERNEL:  iretq
+entry:
+  %rip = getelementptr inbounds %struct.__uintr_frame, %struct.__uintr_frame* %frame, i64 0, i32 0
+  %0 = load i64, i64* %rip, align 8
+  store i64 %0, i64* @g_rip, align 8
+  %rflags = getelementptr inbounds %struct.__uintr_frame, %struct.__uintr_frame* %frame, i64 0, i32 1
+  %1 = load i64, i64* %rflags, align 8
+  store i64 %1, i64* @g_rflags, align 8
+  %rsp = getelementptr inbounds %struct.__uintr_frame, %struct.__uintr_frame* %frame, i64 0, i32 2
+  %2 = load i64, i64* %rsp, align 8
+  store i64 %2, i64* @g_rsp, align 8
+  store i64 %uirrv, i64* @g_uirrv, align 8
+  ret void
+}
+
+attributes #0 = { nofree norecurse nounwind willreturn "disable-tail-calls"="true" "frame-pointer"="none" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+uintr" "tune-cpu"="generic" }
Index: llvm/lib/Target/X86/X86ExpandPseudo.cpp
===
--- llvm/lib/Target/X86/X86ExpandPseudo.cpp
+++ llvm/lib/T

[PATCH] D99683: [HIP] Support ThinLTO

2021-04-06 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1904-1907
+def foffload_lto : Flag<["-"], "foffload-lto">, Flags<[CoreOption]>, 
Group,
+  HelpText<"Enable LTO in 'full' mode for offload compilation">;
+def fno_offload_lto : Flag<["-"], "fno-offload-lto">, Flags<[CoreOption]>, 
Group,
+  HelpText<"Disable LTO mode (default) for offload compilation">;

yaxunl wrote:
> tra wrote:
> > Should it be `BoolFOption` ? 
> Yes. will fix
The `BoolFOption` marshalling multiclass should be only used for flags where 
either the positive or the negative (or both) are -cc1 options and map to a 
field in `CompilerInvocation`.

Since this patch only deals with the driver (not the cc1 frontend) using 
`BoolFOption` is not correct. Please, revert this change to the previous state.

I might need to explicitly call this out in the documentation 
https://clang.llvm.org/docs/InternalsManual.html#adding-new-command-line-option.


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

https://reviews.llvm.org/D99683

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


[PATCH] D99158: [RISCV][WIP] Implement intrinsics for P extension

2021-04-06 Thread Jim Lin via Phabricator via cfe-commits
Jim updated this revision to Diff 335428.
Jim added a comment.

Subtarget.hasStdExtP() -> Subtarget.hasStdExtZpn() for addRegisterClass


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

https://reviews.llvm.org/D99158

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/RISCV/rvp-intrinsics/rv32p.c
  clang/test/CodeGen/RISCV/rvp-intrinsics/rv64p.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoP.td
  llvm/test/CodeGen/RISCV/rvp/intrinsics-rv32p.ll
  llvm/test/CodeGen/RISCV/rvp/intrinsics-rv64p.ll

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


[clang] 2935737 - [clang][tooling] Create SourceManager for DiagnosticsEngine before command-line parsing

2021-04-06 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-04-06T10:40:47+02:00
New Revision: 2935737da32dd21bf02e1a3c912a340de660d557

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

LOG: [clang][tooling] Create SourceManager for DiagnosticsEngine before 
command-line parsing

In D84673, we started using `DiagnosticsEngine` during command-line parsing in 
more contexts.

When using `ToolInvocation`, a custom `DiagnosticsConsumer` can be specified 
and it might expect `SourceManager` to be present on the emitted diagnostics.

This patch ensures the `SourceManager` is set up in such scenarios.

Test authored by Jordan Rupprecht.

Reviewed By: rupprecht

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

Added: 


Modified: 
clang/lib/Tooling/Tooling.cpp
clang/unittests/Tooling/ToolingTest.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp
index b28e8f6a7c96..463f466d9b76 100644
--- a/clang/lib/Tooling/Tooling.cpp
+++ b/clang/lib/Tooling/Tooling.cpp
@@ -334,6 +334,10 @@ bool ToolInvocation::run() {
   DiagnosticsEngine Diagnostics(
   IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts,
   DiagConsumer ? DiagConsumer : &DiagnosticPrinter, false);
+  // Although `Diagnostics` are used only for command-line parsing, the custom
+  // `DiagConsumer` might expect a `SourceManager` to be present.
+  SourceManager SrcMgr(Diagnostics, *Files);
+  Diagnostics.setSourceManager(&SrcMgr);
 
   const std::unique_ptr Driver(
   newDriver(&Diagnostics, BinaryName, &Files->getVirtualFileSystem()));

diff  --git a/clang/unittests/Tooling/ToolingTest.cpp 
b/clang/unittests/Tooling/ToolingTest.cpp
index 691a847d5a71..313e8325c615 100644
--- a/clang/unittests/Tooling/ToolingTest.cpp
+++ b/clang/unittests/Tooling/ToolingTest.cpp
@@ -221,6 +221,43 @@ TEST(ToolInvocation, TestVirtualModulesCompilation) {
   EXPECT_TRUE(Invocation.run());
 }
 
+struct DiagnosticConsumerExpectingSourceManager : public DiagnosticConsumer {
+  bool SawSourceManager;
+
+  DiagnosticConsumerExpectingSourceManager() : SawSourceManager(false) {}
+
+  void HandleDiagnostic(clang::DiagnosticsEngine::Level,
+const clang::Diagnostic &info) override {
+SawSourceManager = info.hasSourceManager();
+  }
+};
+
+TEST(ToolInvocation, DiagConsumerExpectingSourceManager) {
+  llvm::IntrusiveRefCntPtr OverlayFileSystem(
+  new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
+  llvm::IntrusiveRefCntPtr Files(
+  new FileManager(FileSystemOptions(), OverlayFileSystem));
+  std::vector Args;
+  Args.push_back("tool-executable");
+  // Note: intentional error; user probably meant -ferror-limit=0.
+  Args.push_back("-ferror-limit=-1");
+  Args.push_back("-fsyntax-only");
+  Args.push_back("test.cpp");
+  clang::tooling::ToolInvocation Invocation(
+  Args, std::make_unique(), Files.get());
+  InMemoryFileSystem->addFile(
+  "test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int main() {}\n"));
+
+  DiagnosticConsumerExpectingSourceManager Consumer;
+  Invocation.setDiagnosticConsumer(&Consumer);
+
+  EXPECT_TRUE(Invocation.run());
+  EXPECT_TRUE(Consumer.SawSourceManager);
+}
+
 struct VerifyEndCallback : public SourceFileCallbacks {
   VerifyEndCallback() : BeginCalled(0), EndCalled(0), Matched(false) {}
   bool handleBeginSource(CompilerInstance &CI) override {



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


[PATCH] D99414: [clang][tooling] Create SourceManager for DiagnosticsEngine before command-line parsing

2021-04-06 Thread Jan Svoboda 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 rG2935737da32d: [clang][tooling] Create SourceManager for 
DiagnosticsEngine before command-line… (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99414

Files:
  clang/lib/Tooling/Tooling.cpp
  clang/unittests/Tooling/ToolingTest.cpp


Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -221,6 +221,43 @@
   EXPECT_TRUE(Invocation.run());
 }
 
+struct DiagnosticConsumerExpectingSourceManager : public DiagnosticConsumer {
+  bool SawSourceManager;
+
+  DiagnosticConsumerExpectingSourceManager() : SawSourceManager(false) {}
+
+  void HandleDiagnostic(clang::DiagnosticsEngine::Level,
+const clang::Diagnostic &info) override {
+SawSourceManager = info.hasSourceManager();
+  }
+};
+
+TEST(ToolInvocation, DiagConsumerExpectingSourceManager) {
+  llvm::IntrusiveRefCntPtr OverlayFileSystem(
+  new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
+  llvm::IntrusiveRefCntPtr Files(
+  new FileManager(FileSystemOptions(), OverlayFileSystem));
+  std::vector Args;
+  Args.push_back("tool-executable");
+  // Note: intentional error; user probably meant -ferror-limit=0.
+  Args.push_back("-ferror-limit=-1");
+  Args.push_back("-fsyntax-only");
+  Args.push_back("test.cpp");
+  clang::tooling::ToolInvocation Invocation(
+  Args, std::make_unique(), Files.get());
+  InMemoryFileSystem->addFile(
+  "test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int main() {}\n"));
+
+  DiagnosticConsumerExpectingSourceManager Consumer;
+  Invocation.setDiagnosticConsumer(&Consumer);
+
+  EXPECT_TRUE(Invocation.run());
+  EXPECT_TRUE(Consumer.SawSourceManager);
+}
+
 struct VerifyEndCallback : public SourceFileCallbacks {
   VerifyEndCallback() : BeginCalled(0), EndCalled(0), Matched(false) {}
   bool handleBeginSource(CompilerInstance &CI) override {
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -334,6 +334,10 @@
   DiagnosticsEngine Diagnostics(
   IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts,
   DiagConsumer ? DiagConsumer : &DiagnosticPrinter, false);
+  // Although `Diagnostics` are used only for command-line parsing, the custom
+  // `DiagConsumer` might expect a `SourceManager` to be present.
+  SourceManager SrcMgr(Diagnostics, *Files);
+  Diagnostics.setSourceManager(&SrcMgr);
 
   const std::unique_ptr Driver(
   newDriver(&Diagnostics, BinaryName, &Files->getVirtualFileSystem()));


Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -221,6 +221,43 @@
   EXPECT_TRUE(Invocation.run());
 }
 
+struct DiagnosticConsumerExpectingSourceManager : public DiagnosticConsumer {
+  bool SawSourceManager;
+
+  DiagnosticConsumerExpectingSourceManager() : SawSourceManager(false) {}
+
+  void HandleDiagnostic(clang::DiagnosticsEngine::Level,
+const clang::Diagnostic &info) override {
+SawSourceManager = info.hasSourceManager();
+  }
+};
+
+TEST(ToolInvocation, DiagConsumerExpectingSourceManager) {
+  llvm::IntrusiveRefCntPtr OverlayFileSystem(
+  new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
+  llvm::IntrusiveRefCntPtr Files(
+  new FileManager(FileSystemOptions(), OverlayFileSystem));
+  std::vector Args;
+  Args.push_back("tool-executable");
+  // Note: intentional error; user probably meant -ferror-limit=0.
+  Args.push_back("-ferror-limit=-1");
+  Args.push_back("-fsyntax-only");
+  Args.push_back("test.cpp");
+  clang::tooling::ToolInvocation Invocation(
+  Args, std::make_unique(), Files.get());
+  InMemoryFileSystem->addFile(
+  "test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int main() {}\n"));
+
+  DiagnosticConsumerExpectingSourceManager Consumer;
+  Invocation.setDiagnosticConsumer(&Consumer);
+
+  EXPECT_TRUE(Invocation.run());
+  EXPECT_TRUE(Consumer.SawSourceManager);
+}
+
 struct VerifyEndCallback : public SourceFileCallbacks {
   VerifyEndCallback() : BeginCalled(0), EndCalled(0), Matched(false) {}
   bool handleBeginSource(CompilerInstance &CI) override {
Index: clang/lib/Tooling/Tooling.cpp
=

[PATCH] D99158: [RISCV][WIP] Implement intrinsics for P extension

2021-04-06 Thread Jim Lin via Phabricator via cfe-commits
Jim added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:706
+
+  setOperationAction(ISD::BITCAST, VT, Legal);
+

Jim wrote:
> craig.topper wrote:
> > What about bitcast from float/double to any of these vector types? I'm 
> > guess that's not legal.
> Yes, it is not legal bitcast from float/double to any of these vector types.
> All operations of these vector types have been expanded on line 760.
> Only bitcast from/to v4i8/v2i16, v8i8/v4i16/v2i32 to/from i32, i64 are legal.
Oh, it is a issue. I will try to fix it.


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

https://reviews.llvm.org/D99158

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


[PATCH] D98128: [clang][clangd] Avoid inconsistent target creation

2021-04-06 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

sorry for the delay here. thanks, this LGTM!

i've got a single concern in `CompilerInstance::createTarget` though. it will 
overwrite aux target for cuda, openmp and sycl (as it unconditionally sets 
auxtarget even if it exists).
it doesn't cause any problems today, because `CompilerInstance::setAuxTarget` 
is (AFAICT) only called within `createTarget`, but it might be nice to (on a 
separate patch) either:

- leave a comment explaining why we overwrite if there's a reason or,
- put it behind the condition of auxtarget being missing

so that future travellers do know what to do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98128

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


[PATCH] D99893: [WIP] Replace std::forward & std::move by cast expressions during Sema

2021-04-06 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

> Treating a namespace-`std` function template as a builtin isn't entirely 
> novel; we already do this for MSVC's `std::_GetExceptionInfo` (though we 
> don't actually handle that properly: we're missing the "namespace `std`" 
> check, at least). Treating the builtin definition as overriding an inline 
> library definition might be novel, though that doesn't seem like a huge 
> problem.

This was my initial approach, I found some issues

- I struggled getting a built in forward to return a reference
- I had no clue how to inject them in namespace `std` (knowing about 
`std::_GetExceptionInfo` will certainly help, thanks!
- I really didn't want to modify standard headers and wasn't sure how to 
override the declaration.

But overall, I agree with all of you, it's a better design if we can make it 
work. Back to the drawing board, and thanks for the feedbacks :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99893

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


[clang] bee4813 - [clang][Checkers] Fix PthreadLockChecker state cleanup at dead symbol.

2021-04-06 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2021-04-06T11:15:29+02:00
New Revision: bee4813789a378584d43c65497a5efd2353a6606

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

LOG: [clang][Checkers] Fix PthreadLockChecker state cleanup at dead symbol.

It is possible that an entry in 'DestroyRetVal' lives longer
than an entry in 'LockMap' if not removed at checkDeadSymbols.
The added test case demonstrates this.

Reviewed By: NoQ

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
clang/test/Analysis/pthreadlock.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
index eb10a42b7d3d..ee71b55a39e6 100644
--- a/clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -647,8 +647,10 @@ void PthreadLockChecker::checkDeadSymbols(SymbolReaper 
&SymReaper,
 
   for (auto I : State->get()) {
 // Stop tracking dead mutex regions as well.
-if (!SymReaper.isLiveRegion(I.first))
+if (!SymReaper.isLiveRegion(I.first)) {
   State = State->remove(I.first);
+  State = State->remove(I.first);
+}
   }
 
   // TODO: We probably need to clean up the lock stack as well.

diff  --git a/clang/test/Analysis/pthreadlock.c 
b/clang/test/Analysis/pthreadlock.c
index 6eb45ce4ae5b..85b34cbed918 100644
--- a/clang/test/Analysis/pthreadlock.c
+++ b/clang/test/Analysis/pthreadlock.c
@@ -513,3 +513,9 @@ void bad33(void) {
   fake_system_function();
   pthread_mutex_lock(pmtx); // expected-warning{{This lock has already been 
acquired}}
 }
+
+void nocrash1(pthread_mutex_t *mutex) {
+  int ret = pthread_mutex_destroy(mutex);
+  if (ret == 0) // no crash
+;
+}



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


[PATCH] D98504: [clang][Checkers] Fix PthreadLockChecker state cleanup at dead symbol.

2021-04-06 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbee4813789a3: [clang][Checkers] Fix PthreadLockChecker state 
cleanup at dead symbol. (authored by balazske).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98504

Files:
  clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
  clang/test/Analysis/pthreadlock.c


Index: clang/test/Analysis/pthreadlock.c
===
--- clang/test/Analysis/pthreadlock.c
+++ clang/test/Analysis/pthreadlock.c
@@ -513,3 +513,9 @@
   fake_system_function();
   pthread_mutex_lock(pmtx); // expected-warning{{This lock has already been 
acquired}}
 }
+
+void nocrash1(pthread_mutex_t *mutex) {
+  int ret = pthread_mutex_destroy(mutex);
+  if (ret == 0) // no crash
+;
+}
Index: clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -647,8 +647,10 @@
 
   for (auto I : State->get()) {
 // Stop tracking dead mutex regions as well.
-if (!SymReaper.isLiveRegion(I.first))
+if (!SymReaper.isLiveRegion(I.first)) {
   State = State->remove(I.first);
+  State = State->remove(I.first);
+}
   }
 
   // TODO: We probably need to clean up the lock stack as well.


Index: clang/test/Analysis/pthreadlock.c
===
--- clang/test/Analysis/pthreadlock.c
+++ clang/test/Analysis/pthreadlock.c
@@ -513,3 +513,9 @@
   fake_system_function();
   pthread_mutex_lock(pmtx); // expected-warning{{This lock has already been acquired}}
 }
+
+void nocrash1(pthread_mutex_t *mutex) {
+  int ret = pthread_mutex_destroy(mutex);
+  if (ret == 0) // no crash
+;
+}
Index: clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -647,8 +647,10 @@
 
   for (auto I : State->get()) {
 // Stop tracking dead mutex regions as well.
-if (!SymReaper.isLiveRegion(I.first))
+if (!SymReaper.isLiveRegion(I.first)) {
   State = State->remove(I.first);
+  State = State->remove(I.first);
+}
   }
 
   // TODO: We probably need to clean up the lock stack as well.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99715: [CMake] Respect LLVM_MINIMUM_PYTHON_VERSION in Tooling/CMakeLists.txt

2021-04-06 Thread Dominik Montada via Phabricator via cfe-commits
gargaroff updated this revision to Diff 335438.
gargaroff added a comment.

Remove find_package call from Tooling/CMakeLists.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99715

Files:
  clang/lib/Tooling/CMakeLists.txt


Index: clang/lib/Tooling/CMakeLists.txt
===
--- clang/lib/Tooling/CMakeLists.txt
+++ clang/lib/Tooling/CMakeLists.txt
@@ -13,8 +13,6 @@
 add_subdirectory(DependencyScanning)
 add_subdirectory(Transformer)
 
-find_package(Python3 COMPONENTS Interpreter)
-
 # Replace the last lib component of the current binary directory with include
 string(FIND ${CMAKE_CURRENT_BINARY_DIR} "/lib/" PATH_LIB_START REVERSE)
 if(PATH_LIB_START EQUAL -1)


Index: clang/lib/Tooling/CMakeLists.txt
===
--- clang/lib/Tooling/CMakeLists.txt
+++ clang/lib/Tooling/CMakeLists.txt
@@ -13,8 +13,6 @@
 add_subdirectory(DependencyScanning)
 add_subdirectory(Transformer)
 
-find_package(Python3 COMPONENTS Interpreter)
-
 # Replace the last lib component of the current binary directory with include
 string(FIND ${CMAKE_CURRENT_BINARY_DIR} "/lib/" PATH_LIB_START REVERSE)
 if(PATH_LIB_START EQUAL -1)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99708: [X86] Enable compilation of user interrupt handlers.

2021-04-06 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added a comment.

LGMT. Thank you!


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

https://reviews.llvm.org/D99708

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


[PATCH] D99715: [CMake] Fix Python 3 lookup when building LLVM with tests

2021-04-06 Thread serge via Phabricator via cfe-commits
serge-sans-paille accepted this revision.
serge-sans-paille added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99715

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


[PATCH] D99934: [clang][Syntax] Handle invalid source range in expandedTokens.

2021-04-06 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 created this revision.
usaxena95 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

sammccall


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99934

Files:
  clang/lib/Tooling/Syntax/Tokens.cpp


Index: clang/lib/Tooling/Syntax/Tokens.cpp
===
--- clang/lib/Tooling/Syntax/Tokens.cpp
+++ clang/lib/Tooling/Syntax/Tokens.cpp
@@ -189,11 +189,16 @@
 return;
   ExpandedTokIndex.reserve(ExpandedTokens.size());
   // Index ExpandedTokens for faster lookups by SourceLocation.
-  for (size_t I = 0, E = ExpandedTokens.size(); I != E; ++I)
-ExpandedTokIndex[ExpandedTokens[I].location()] = I;
+  for (size_t I = 0, E = ExpandedTokens.size(); I != E; ++I) {
+SourceLocation Loc = ExpandedTokens[I].location();
+if (Loc.isValid())
+  ExpandedTokIndex[Loc] = I;
+  }
 }
 
 llvm::ArrayRef TokenBuffer::expandedTokens(SourceRange R) const 
{
+  if (R.isInvalid())
+return {};
   if (!ExpandedTokIndex.empty()) {
 // Quick lookup if `R` is a token range.
 // This is a huge win since majority of the users use ranges provided by an
@@ -201,9 +206,12 @@
 const auto B = ExpandedTokIndex.find(R.getBegin());
 const auto E = ExpandedTokIndex.find(R.getEnd());
 if (B != ExpandedTokIndex.end() && E != ExpandedTokIndex.end()) {
+  const Token *L = ExpandedTokens.data() + B->getSecond();
   // Add 1 to End to make a half-open range.
-  return {ExpandedTokens.data() + B->getSecond(),
-  ExpandedTokens.data() + E->getSecond() + 1};
+  const Token *R = ExpandedTokens.data() + E->getSecond() + 1;
+  if (L > R)
+return {};
+  return {L, R};
 }
   }
   // Slow case. Use `isBeforeInTranslationUnit` to binary search for the


Index: clang/lib/Tooling/Syntax/Tokens.cpp
===
--- clang/lib/Tooling/Syntax/Tokens.cpp
+++ clang/lib/Tooling/Syntax/Tokens.cpp
@@ -189,11 +189,16 @@
 return;
   ExpandedTokIndex.reserve(ExpandedTokens.size());
   // Index ExpandedTokens for faster lookups by SourceLocation.
-  for (size_t I = 0, E = ExpandedTokens.size(); I != E; ++I)
-ExpandedTokIndex[ExpandedTokens[I].location()] = I;
+  for (size_t I = 0, E = ExpandedTokens.size(); I != E; ++I) {
+SourceLocation Loc = ExpandedTokens[I].location();
+if (Loc.isValid())
+  ExpandedTokIndex[Loc] = I;
+  }
 }
 
 llvm::ArrayRef TokenBuffer::expandedTokens(SourceRange R) const {
+  if (R.isInvalid())
+return {};
   if (!ExpandedTokIndex.empty()) {
 // Quick lookup if `R` is a token range.
 // This is a huge win since majority of the users use ranges provided by an
@@ -201,9 +206,12 @@
 const auto B = ExpandedTokIndex.find(R.getBegin());
 const auto E = ExpandedTokIndex.find(R.getEnd());
 if (B != ExpandedTokIndex.end() && E != ExpandedTokIndex.end()) {
+  const Token *L = ExpandedTokens.data() + B->getSecond();
   // Add 1 to End to make a half-open range.
-  return {ExpandedTokens.data() + B->getSecond(),
-  ExpandedTokens.data() + E->getSecond() + 1};
+  const Token *R = ExpandedTokens.data() + E->getSecond() + 1;
+  if (L > R)
+return {};
+  return {L, R};
 }
   }
   // Slow case. Use `isBeforeInTranslationUnit` to binary search for the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99524: [RISCV][Clang] Add some RVV Integer intrinsic functions.

2021-04-06 Thread Zakk Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG66c05609e0d5: [RISCV][Clang] Add some RVV Integer intrinsic 
functions. (authored by khchen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99524

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnmsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vrem.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vrsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsll.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsra.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsrl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vxor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vnmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vnmsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vrem.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vrsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsll.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsra.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsrl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vxor.c

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


[PATCH] D99525: [RISCV][Clang] Add RVV vnsra, vnsrl and vwmul intrinsic functions.

2021-04-06 Thread Zakk Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0a18ea01f197: [RISCV][Clang] Add RVV vnsra, vnsrl and vwmul 
intrinsic functions. (authored by khchen).

Changed prior to commit:
  https://reviews.llvm.org/D99525?vs=333945&id=335449#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99525

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnsra.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnsrl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vwmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vnsra.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vnsrl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vwmul.c

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


[PATCH] D99528: [RISCV][Clang] Add more RVV Integer intrinsic functions.

2021-04-06 Thread Zakk Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfe252b509ee6: [RISCV][Clang] Add more RVV Integer intrinsic 
functions. (authored by khchen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99528

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vadc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmadc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsbc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmseq.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsle.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmslt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsne.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsbc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vwmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vadc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmadc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsbc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmseq.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsle.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmslt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsne.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsbc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vwmacc.c

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


[PATCH] D99610: [RISCV][Clang] Add all RVV Fixed-Point Arithmetic intrinsic functions.

2021-04-06 Thread Zakk Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf2a3601aa5a5: [RISCV][Clang] Add all RVV Fixed-Point 
Arithmetic intrinsic functions. (authored by khchen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99610

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vaadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vasub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnclip.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vssra.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vssrl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vssub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vaadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vasub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vnclip.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vssra.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vssrl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vssub.c

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


[PATCH] D99936: [clang][parser] Unify rejecting (non) decl stmt with gnu attributes

2021-04-06 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, rsmith.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

I randomly noticed this comment (introduced in 
a3e01cf822f7415337e5424af3c6f4c94a12c1b9 from @rsmith),  which is now incorrect.

It suggests that decl statements and others should be handled the same here.

I'm just posting this since it seems correct (according to the comment from 
2013), but I'm not sure if the new diagnostic in the test case is really better 
than the old one.

If the old one is preferred, I can just reword the comment instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99936

Files:
  clang/lib/Parse/ParseStmt.cpp
  clang/test/SemaCXX/warn-unused-label-error.cpp


Index: clang/test/SemaCXX/warn-unused-label-error.cpp
===
--- clang/test/SemaCXX/warn-unused-label-error.cpp
+++ clang/test/SemaCXX/warn-unused-label-error.cpp
@@ -12,8 +12,8 @@
 
   void g() {
 C: // unused label 'C' will not appear here because an error has occurred
-  __attribute__((unused))
-  #pragma weak unused_local_static  // expected-error {{expected ';' after 
__attribute__}}
+  __attribute__((unused)) // expected-error {{an attribute list cannot 
appear here}}
+  #pragma weak unused_local_static
   ;
   }
 
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -648,18 +648,12 @@
 // attributes as part of a statement in that case). That looks like a bug.
 if (!getLangOpts().CPlusPlus || Tok.is(tok::semi))
   attrs.takeAllFrom(TempAttrs);
-else if (isDeclarationStatement()) {
+else {
   StmtVector Stmts;
-  // FIXME: We should do this whether or not we have a declaration
-  // statement, but that doesn't work correctly (because ProhibitAttributes
-  // can't handle GNU attributes), so only call it in the one case where
-  // GNU attributes are allowed.
   SubStmt = ParseStatementOrDeclarationAfterAttributes(Stmts, StmtCtx,
nullptr, TempAttrs);
   if (!TempAttrs.empty() && !SubStmt.isInvalid())
 SubStmt = Actions.ActOnAttributedStmt(TempAttrs, SubStmt.get());
-} else {
-  Diag(Tok, diag::err_expected_after) << "__attribute__" << tok::semi;
 }
   }
 


Index: clang/test/SemaCXX/warn-unused-label-error.cpp
===
--- clang/test/SemaCXX/warn-unused-label-error.cpp
+++ clang/test/SemaCXX/warn-unused-label-error.cpp
@@ -12,8 +12,8 @@
 
   void g() {
 C: // unused label 'C' will not appear here because an error has occurred
-  __attribute__((unused))
-  #pragma weak unused_local_static  // expected-error {{expected ';' after __attribute__}}
+  __attribute__((unused)) // expected-error {{an attribute list cannot appear here}}
+  #pragma weak unused_local_static
   ;
   }
 
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -648,18 +648,12 @@
 // attributes as part of a statement in that case). That looks like a bug.
 if (!getLangOpts().CPlusPlus || Tok.is(tok::semi))
   attrs.takeAllFrom(TempAttrs);
-else if (isDeclarationStatement()) {
+else {
   StmtVector Stmts;
-  // FIXME: We should do this whether or not we have a declaration
-  // statement, but that doesn't work correctly (because ProhibitAttributes
-  // can't handle GNU attributes), so only call it in the one case where
-  // GNU attributes are allowed.
   SubStmt = ParseStatementOrDeclarationAfterAttributes(Stmts, StmtCtx,
nullptr, TempAttrs);
   if (!TempAttrs.empty() && !SubStmt.isInvalid())
 SubStmt = Actions.ActOnAttributedStmt(TempAttrs, SubStmt.get());
-} else {
-  Diag(Tok, diag::err_expected_after) << "__attribute__" << tok::semi;
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95536: [clang][sema] Note decl location on missing member

2021-04-06 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder abandoned this revision.
tbaeder added a comment.

Abandoning this since it's probably not worth it.


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

https://reviews.llvm.org/D95536

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


[PATCH] D99601: [-Wcompletion-handler] Don't recognize init methods as conventional

2021-04-06 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 335462.
vsavchenko added a comment.

Use builtin way of checking for init methods


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99601

Files:
  clang/lib/Analysis/CalledOnceCheck.cpp
  clang/test/SemaObjC/warn-called-once.m


Index: clang/test/SemaObjC/warn-called-once.m
===
--- clang/test/SemaObjC/warn-called-once.m
+++ clang/test/SemaObjC/warn-called-once.m
@@ -13,6 +13,7 @@
 @protocol NSObject
 @end
 @interface NSObject 
+- (instancetype)init;
 - (id)copy;
 - (id)class;
 - autorelease;
@@ -1235,4 +1236,13 @@
   handler(); // expected-warning{{completion handler is called twice}}
 }
 
+- (void)initWithAdditions:(int)cond
+   withCompletion:(void (^)(void))handler {
+  self = [self init];
+  if (self) {
+escape(handler);
+  }
+  // no-warning
+}
+
 @end
Index: clang/lib/Analysis/CalledOnceCheck.cpp
===
--- clang/lib/Analysis/CalledOnceCheck.cpp
+++ clang/lib/Analysis/CalledOnceCheck.cpp
@@ -1011,11 +1011,16 @@
 return llvm::None;
   }
 
+  /// Return true if the specified selector represents init method.
+  static bool isInitMethod(Selector MethodSelector) {
+return MethodSelector.getMethodFamily() == OMF_init;
+  }
+
   /// Return true if the specified selector piece matches conventions.
   static bool isConventionalSelectorPiece(Selector MethodSelector,
   unsigned PieceIndex,
   QualType PieceType) {
-if (!isConventional(PieceType)) {
+if (!isConventional(PieceType) || isInitMethod(MethodSelector)) {
   return false;
 }
 


Index: clang/test/SemaObjC/warn-called-once.m
===
--- clang/test/SemaObjC/warn-called-once.m
+++ clang/test/SemaObjC/warn-called-once.m
@@ -13,6 +13,7 @@
 @protocol NSObject
 @end
 @interface NSObject 
+- (instancetype)init;
 - (id)copy;
 - (id)class;
 - autorelease;
@@ -1235,4 +1236,13 @@
   handler(); // expected-warning{{completion handler is called twice}}
 }
 
+- (void)initWithAdditions:(int)cond
+   withCompletion:(void (^)(void))handler {
+  self = [self init];
+  if (self) {
+escape(handler);
+  }
+  // no-warning
+}
+
 @end
Index: clang/lib/Analysis/CalledOnceCheck.cpp
===
--- clang/lib/Analysis/CalledOnceCheck.cpp
+++ clang/lib/Analysis/CalledOnceCheck.cpp
@@ -1011,11 +1011,16 @@
 return llvm::None;
   }
 
+  /// Return true if the specified selector represents init method.
+  static bool isInitMethod(Selector MethodSelector) {
+return MethodSelector.getMethodFamily() == OMF_init;
+  }
+
   /// Return true if the specified selector piece matches conventions.
   static bool isConventionalSelectorPiece(Selector MethodSelector,
   unsigned PieceIndex,
   QualType PieceType) {
-if (!isConventional(PieceType)) {
+if (!isConventional(PieceType) || isInitMethod(MethodSelector)) {
   return false;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99601: [-Wcompletion-handler] Don't recognize init methods as conventional

2021-04-06 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko marked an inline comment as done.
vsavchenko added inline comments.



Comment at: clang/lib/Analysis/CalledOnceCheck.cpp:1017
+  static bool isInitMethod(Selector MethodSelector) {
+return MethodSelector.getNameForSlot(0).startswith_lower(INIT_PREFIX);
+  }

NoQ wrote:
> You can formally check whether it's an init method by querying its 
> `ObjCMethodFamily`.
That's awesome, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99601

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


[PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-06 Thread Yvan Roux via Phabricator via cfe-commits
yroux added a comment.

Hi,

Sorry I'm bit lost in the various patches proposed to fix the issue introduced 
by https://reviews.llvm.org/D97785 
My understanding is that this is missing one to fix our Windows on ARM bots 
(broken for more than 2 weeks now)
So it'd be great to have it applied


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[clang] b78e883 - [CMake] Fix Python 3 lookup when building LLVM with tests

2021-04-06 Thread Dominik Montada via cfe-commits

Author: Dominik Montada
Date: 2021-04-06T13:09:06+02:00
New Revision: b78e883fd8b3745250220776dd8bb635edd95539

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

LOG: [CMake] Fix Python 3 lookup when building LLVM with tests

Remove the find_package(Python3 ...) call from Tooling/CMakeLists.txt as
it would override the python 3 version determined in llvm/CMakeLists.txt.
This call did not respect the LLVM_MINIMUM_PYTHON_VERSION.

This fixes the check-all target when building LLVM on a system where the
default python version is not the minimum required version for running tests.

Reviewed By: serge-sans-paille

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

Added: 


Modified: 
clang/lib/Tooling/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Tooling/CMakeLists.txt 
b/clang/lib/Tooling/CMakeLists.txt
index 0a6fb99152dc..ce7936a53671 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -13,8 +13,6 @@ add_subdirectory(Syntax)
 add_subdirectory(DependencyScanning)
 add_subdirectory(Transformer)
 
-find_package(Python3 COMPONENTS Interpreter)
-
 # Replace the last lib component of the current binary directory with include
 string(FIND ${CMAKE_CURRENT_BINARY_DIR} "/lib/" PATH_LIB_START REVERSE)
 if(PATH_LIB_START EQUAL -1)



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


[PATCH] D99715: [CMake] Fix Python 3 lookup when building LLVM with tests

2021-04-06 Thread Dominik Montada via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb78e883fd8b3: [CMake] Fix Python 3 lookup when building LLVM 
with tests (authored by gargaroff).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99715

Files:
  clang/lib/Tooling/CMakeLists.txt


Index: clang/lib/Tooling/CMakeLists.txt
===
--- clang/lib/Tooling/CMakeLists.txt
+++ clang/lib/Tooling/CMakeLists.txt
@@ -13,8 +13,6 @@
 add_subdirectory(DependencyScanning)
 add_subdirectory(Transformer)
 
-find_package(Python3 COMPONENTS Interpreter)
-
 # Replace the last lib component of the current binary directory with include
 string(FIND ${CMAKE_CURRENT_BINARY_DIR} "/lib/" PATH_LIB_START REVERSE)
 if(PATH_LIB_START EQUAL -1)


Index: clang/lib/Tooling/CMakeLists.txt
===
--- clang/lib/Tooling/CMakeLists.txt
+++ clang/lib/Tooling/CMakeLists.txt
@@ -13,8 +13,6 @@
 add_subdirectory(DependencyScanning)
 add_subdirectory(Transformer)
 
-find_package(Python3 COMPONENTS Interpreter)
-
 # Replace the last lib component of the current binary directory with include
 string(FIND ${CMAKE_CURRENT_BINARY_DIR} "/lib/" PATH_LIB_START REVERSE)
 if(PATH_LIB_START EQUAL -1)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99526: [RISCV][Clang] Add RVV Widening Integer Add/Subtract intrinsic functions.

2021-04-06 Thread Zakk Chen via Phabricator via cfe-commits
khchen added inline comments.



Comment at: clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vwadd.c:35
+vint16mf4_t test_vwadd_vx_i16mf4(vint8mf8_t op1, int8_t op2, size_t vl) {
+  return vwadd_vx(op1, op2, vl);
+}

khchen wrote:
> craig.topper wrote:
> > Why do scalars require _wx or _vx, but vector don't need a suffix?
> https://github.com/riscv/rvv-intrinsic-doc/blob/master/rvv-intrinsic-rfc.md#widening-vector-scalar-arithmetic-instructions
> There is different overloading naming rule for _wx and _vx, and I just keep 
> the default naming rule for vector version because I felt the overloading 
> rule did not care about the naming consistent. 
> 
> But in https://github.com/riscv/rvv-intrinsic-doc/pull/76 we start to make 
> overloading name seems more consistent. So I think making this case 
> consistent is ok to me.
> 
> I could send a PR to intrinsic-doc, what do you think?
Should I update this patch for 
https://github.com/riscv/rvv-intrinsic-doc/pull/77 PR?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99526

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


[clang] 65c22ac - Silence -Woverloaded-virtual warnings from generated code; NFC

2021-04-06 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-04-06T07:19:07-04:00
New Revision: 65c22acfa4a412066e47c3171ff26fcbd62f970e

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

LOG: Silence -Woverloaded-virtual warnings from generated code; NFC

Added: 


Modified: 
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 0d8439b697c84..6b76ad8ccc0d1 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3672,6 +3672,11 @@ static void GenerateMutualExclusionsChecks(const Record 
&Attr,
 }
   }
 
+  // If there are any decl or stmt attributes, silence -Woverloaded-virtual
+  // warnings for them both.
+  if (!DeclAttrs.empty() || !StmtAttrs.empty())
+OS << "  using ParsedAttrInfo::diagMutualExclusion;\n\n";
+
   // If we discovered any decl or stmt attributes to test for, generate the
   // predicates for them now.
   if (!DeclAttrs.empty()) {



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


[PATCH] D99896: Rework the way statement attributes are processed; NFC

2021-04-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/TreeTransform.h:1316
Stmt *SubStmt) {
-return SemaRef.ActOnAttributedStmt(AttrLoc, Attrs, SubStmt);
+return SemaRef.BuildAttributedStmt(AttrLoc, Attrs, SubStmt);
   }

haberman wrote:
> aaron.ballman wrote:
> > haberman wrote:
> > > aaron.ballman wrote:
> > > > erichkeane wrote:
> > > > > Am I missing where the attributes themselves are being 
> > > > > rebuilt/transformed??  
> > > > > 
> > > > > 
> > > > The transformation happens in 
> > > > `TreeTransform::TransformAttributedStmt()` which calls 
> > > > `RebuildAttributedStmt()` with the rebuilt attributes.
> > > It appears that neither `TransformAttributedStmt()` nor 
> > > `RebuildAttributedStmt()` calls `ProcessStmtAttributes()`, either 
> > > directly or transitively, so I'm not seeing where we can run 
> > > instantiation-time attribute processing logic. What am I missing?
> > My thinking is: 
> > 
> > * From `handleMustTailAttr()` in SemaStmtAttr.cpp, call 
> > `CheckMustTailAttr()` to do the shared semantic checking.
> > * Add a `TransformMustTailAttr()` to `TreeTransform`, have it call 
> > `SemaRef.CheckMustTailAttr()` as well.
> I see. My main concern then is that `TransformMustTailAttr()` could get 
> access to the `ReturnExpr` to perform the validation. Right now the 
> `MustTailAttr` doesn't appear to have any reference to the `ReturnExpr`, and 
> I don't know how to give it one.
> 
> If there is a solution to this problem, I don't have any objection. My main 
> concern is to unblock my change which is a high priority for me and my team.
> I see. My main concern then is that TransformMustTailAttr() could get access 
> to the ReturnExpr to perform the validation. Right now the MustTailAttr 
> doesn't appear to have any reference to the ReturnExpr, and I don't know how 
> to give it one.

I'll add a way for that to happen today or tomorrow and we can iterate from 
there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99896

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


[clang-tools-extra] 82b3e28 - [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-06 Thread Abhina Sreeskantharajan via cfe-commits

Author: Abhina Sreeskantharajan
Date: 2021-04-06T07:23:31-04:00
New Revision: 82b3e28e836d2f5c8cfd6e1047b93c088522365a

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

LOG: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag 
instead of OF_Text

Problem:
On SystemZ we need to open text files in text mode. On Windows, files opened in 
text mode adds a CRLF '\r\n' which may not be desirable.

Solution:
This patch adds two new flags

  - OF_CRLF which indicates that CRLF translation is used.
  - OF_TextWithCRLF = OF_Text | OF_CRLF indicates that the file is text and 
uses CRLF translation.

Developers should now use either the OF_Text or OF_TextWithCRLF for text files 
and OF_None for binary files. If the developer doesn't want carriage returns on 
Windows, they should use OF_Text, if they do want carriage returns on Windows, 
they should use OF_TextWithCRLF.

So this is the behaviour per platform with my patch:

z/OS:
OF_None: open in binary mode
OF_Text : open in text mode
OF_TextWithCRLF: open in text mode

Windows:
OF_None: open file with no carriage return
OF_Text: open file with no carriage return
OF_TextWithCRLF: open file with carriage return

The Major change is in llvm/lib/Support/Windows/Path.inc to only set text mode 
if the OF_CRLF is set.
```
  if (Flags & OF_CRLF)
CrtOpenFlags |= _O_TEXT;
```

These following files are the ones that still use OF_Text which I left 
unchanged. I modified all these except raw_ostream.cpp in recent patches so I 
know these were previously in Binary mode on Windows.
./llvm/lib/Support/raw_ostream.cpp
./llvm/lib/TableGen/Main.cpp
./llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
./llvm/unittests/Support/Path.cpp
./clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
./clang/lib/Frontend/CompilerInstance.cpp
./clang/lib/Driver/Driver.cpp
./clang/lib/Driver/ToolChains/Clang.cpp

Reviewed By: MaskRay

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

Added: 


Modified: 
clang-tools-extra/clang-move/tool/ClangMove.cpp
clang-tools-extra/modularize/ModuleAssistant.cpp
clang-tools-extra/pp-trace/PPTrace.cpp
clang/lib/ARCMigrate/PlistReporter.cpp
clang/lib/Driver/Compilation.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/DependencyFile.cpp
clang/lib/Frontend/DependencyGraph.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Frontend/HeaderIncludeGen.cpp
clang/lib/Frontend/ModuleDependencyCollector.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
clang/tools/clang-refactor/ClangRefactor.cpp
clang/tools/driver/cc1as_main.cpp
flang/lib/Frontend/CompilerInstance.cpp
lld/COFF/DriverUtils.cpp
lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
lldb/include/lldb/Utility/ReproducerProvider.h
lldb/source/Utility/GDBRemote.cpp
lldb/source/Utility/ReproducerProvider.cpp
lldb/tools/lldb-server/LLDBServerUtilities.cpp
llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
llvm/include/llvm/Support/FileSystem.h
llvm/lib/CodeGen/RegAllocPBQP.cpp
llvm/lib/IR/Core.cpp
llvm/lib/IR/LLVMRemarkStreamer.cpp
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/MC/MCParser/DarwinAsmParser.cpp
llvm/lib/ProfileData/GCOV.cpp
llvm/lib/ProfileData/SampleProfWriter.cpp
llvm/lib/Support/FileCollector.cpp
llvm/lib/Support/MemoryBuffer.cpp
llvm/lib/Support/TimeProfiler.cpp
llvm/lib/Support/Timer.cpp
llvm/lib/Support/Unix/Program.inc
llvm/lib/Support/Windows/Path.inc
llvm/lib/Support/Windows/Program.inc
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/LowerTypeTests.cpp
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/lib/Transforms/Utils/Debugify.cpp
llvm/tools/dsymutil/dsymutil.cpp
llvm/tools/llc/llc.cpp
llvm/tools/lli/lli.cpp
llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
llvm/tools/llvm-dis/llvm-dis.cpp
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
llvm/tools/llvm-link/llvm-link.cpp
llvm/tools/llvm-mc/llvm-mc.cpp
llvm/tools/llvm-mca/llvm-mca.cpp
llvm/tools/llvm-opt-report/OptReport.cpp
llvm/tools/llvm-profdata/llvm-profdata.cpp
llvm/tools/llvm-xray/xray-account.cpp
llvm/tools/llvm-xray/xray-converter.cpp
llvm/tools/llvm-xray/xray-extract.cpp
llvm/tools/llvm-xray/xray-graph-diff.cpp
llvm/tools/llvm-xray/xray-graph.cpp
llvm/tools/opt/opt.cpp
llvm/tools/verify-uselistorder/verify-uselistorder.cpp
llvm/unittests/Support/Path.cpp
polly/lib/Exchange/JSONExporter.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-move/tool/

[clang] 2901dc7 - Don't directly dereference getAs<> casts to avoid potential null dereferences. NFCI.

2021-04-06 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2021-04-06T12:24:19+01:00
New Revision: 2901dc7575873ed4bdfa1d7a0e79020e7a9ffb3d

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

LOG: Don't directly dereference getAs<> casts to avoid potential null 
dereferences. NFCI.

Replace with castAs<> which asserts the cast is valid.

Fixes a number of static analyzer warnings.

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/lib/Analysis/CalledOnceCheck.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGCUDANV.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprMember.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 624b1bfde4e64..b42f3b695ec57 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -10307,10 +10307,10 @@ bool VectorExprEvaluator::VisitBinaryOperator(const 
BinaryOperator *E) {
  "Must both be vector types");
   // Checking JUST the types are the same would be fine, except shifts don't
   // need to have their types be the same (since you always shift by an int).
-  assert(LHS->getType()->getAs()->getNumElements() ==
- E->getType()->getAs()->getNumElements() &&
- RHS->getType()->getAs()->getNumElements() ==
- E->getType()->getAs()->getNumElements() &&
+  assert(LHS->getType()->castAs()->getNumElements() ==
+ E->getType()->castAs()->getNumElements() &&
+ RHS->getType()->castAs()->getNumElements() ==
+ E->getType()->castAs()->getNumElements() &&
  "All operands must be the same size.");
 
   APValue LHSValue;

diff  --git a/clang/lib/Analysis/CalledOnceCheck.cpp 
b/clang/lib/Analysis/CalledOnceCheck.cpp
index 00bb51a1c0d3d..9fa8ac30404c3 100644
--- a/clang/lib/Analysis/CalledOnceCheck.cpp
+++ b/clang/lib/Analysis/CalledOnceCheck.cpp
@@ -983,9 +983,9 @@ class CalledOnceChecker : public 
ConstStmtVisitor {
   return false;
 }
 
-QualType BlockType = Ty->getAs()->getPointeeType();
+QualType BlockType = Ty->castAs()->getPointeeType();
 // Completion handlers should have a block type with void return type.
-return BlockType->getAs()->getReturnType()->isVoidType();
+return BlockType->castAs()->getReturnType()->isVoidType();
   }
 
   /// Return true if the only parameter of the function is conventional.

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 6b43a8de218e2..a38176af390d4 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -8760,7 +8760,7 @@ Value *CodeGenFunction::EmitSVEMaskedLoad(const CallExpr 
*E,
   bool IsZExtReturn) {
   QualType LangPTy = E->getArg(1)->getType();
   llvm::Type *MemEltTy = CGM.getTypes().ConvertType(
-  LangPTy->getAs()->getPointeeType());
+  LangPTy->castAs()->getPointeeType());
 
   // The vector type that is returned may be 
diff erent from the
   // eventual type loaded from memory.
@@ -8785,7 +8785,7 @@ Value *CodeGenFunction::EmitSVEMaskedStore(const CallExpr 
*E,
unsigned BuiltinID) {
   QualType LangPTy = E->getArg(1)->getType();
   llvm::Type *MemEltTy = CGM.getTypes().ConvertType(
-  LangPTy->getAs()->getPointeeType());
+  LangPTy->castAs()->getPointeeType());
 
   // The vector type that is stored may be 
diff erent from the
   // eventual type stored to memory.

diff  --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index d53a623b258c1..b224de7c197ae 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -1027,9 +1027,8 @@ void CGNVCUDARuntime::handleVarRegistration(const VarDecl 
*D,
  D->getType()->isCUDADeviceBuiltinTextureType()) {
 // Builtin surfaces and textures and their template arguments are
 // also registered with CUDA runtime.
-const ClassTemplateSpecializationDecl *TD =
-cast(
-D->getType()->getAs()->getDecl());
+const auto *TD = cast(
+D->getType()->castAs()->getDecl());
 const TemplateArgumentList &Args = TD->getTemplateArgs();
 if (TD->hasAttr()) {
   assert(Args.size() == 2 &&

diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index ef3e27ecec997..c4d49d3ac6958 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -1729,7 +1729,7 @@ Value 
*ScalarExprEmitter::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
   llvm::MatrixB

[PATCH] D99517: Implemented [[clang::musttail]] attribute for guaranteed tail calls.

2021-04-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaStmt.cpp:561-568
+  for (const auto *A : Attrs) {
+if (A->getKind() == attr::MustTail) {
+  if (!checkMustTailAttr(SubStmt, *A)) {
+return SubStmt;
+  }
+  setFunctionHasMustTail();
+}

haberman wrote:
> aaron.ballman wrote:
> > rsmith wrote:
> > > aaron.ballman wrote:
> > > > aaron.ballman wrote:
> > > > > haberman wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > haberman wrote:
> > > > > > > > haberman wrote:
> > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > haberman wrote:
> > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > This functionality belongs in SemaStmtAttr.cpp, I think.
> > > > > > > > > > > That is where I had originally put it, but that didn't 
> > > > > > > > > > > work for templates. The semantic checks can only be 
> > > > > > > > > > > performed at instantiation time. `ActOnAttributedStmt` 
> > > > > > > > > > > seems to be the right hook point where I can evaluate the 
> > > > > > > > > > > semantic checks for both template and non-template 
> > > > > > > > > > > functions (with template functions getting checked at 
> > > > > > > > > > > instantiation time).
> > > > > > > > > > I disagree that `ActOnAttributedStmt()` is the correct 
> > > > > > > > > > place for this checking -- template checking should occur 
> > > > > > > > > > when the template is instantiated, same as happens for 
> > > > > > > > > > declaration attributes. I'd like to see this functionality 
> > > > > > > > > > moved to SemaStmtAttr.cpp. Keeping the attribute logic 
> > > > > > > > > > together and following the same patterns is what allows us 
> > > > > > > > > > to tablegenerate more of the attribute logic. Statement 
> > > > > > > > > > attributes are just starting to get more such automation.
> > > > > > > > > I tried commenting out this code and adding the following 
> > > > > > > > > code into `handleMustTailAttr()` in `SemaStmtAttr.cpp`:
> > > > > > > > > 
> > > > > > > > > ```
> > > > > > > > >   if (!S.checkMustTailAttr(St, MTA))
> > > > > > > > > return nullptr;
> > > > > > > > > ```
> > > > > > > > > 
> > > > > > > > > This caused my test cases related to templates to fail. It 
> > > > > > > > > also seemed to break test cases related to `JumpDiagnostics`. 
> > > > > > > > > My interpretation of this is that `handleMustTailAttr()` is 
> > > > > > > > > called during parsing only, and cannot catch errors at 
> > > > > > > > > template instantiation time or that require a more complete 
> > > > > > > > > AST.
> > > > > > > > > 
> > > > > > > > > What am I missing? Where in SemaStmtAttr.cpp are you 
> > > > > > > > > suggesting that I put this check?
> > > > > > > > Scratch the part about `JumpDiagnostics`, that was me failing 
> > > > > > > > to call `S.setFunctionHasMustTail()`. I added that and now the 
> > > > > > > > `JumpDiagnostics` tests pass.
> > > > > > > > 
> > > > > > > > But the template test cases still fail, and I can't find any 
> > > > > > > > hook point in `SemaStmtAttr.cpp` that will let me evaluate 
> > > > > > > > these checks at template instantiation time.
> > > > > > > I think there's a bit of an architectural mixup, but I'm curious 
> > > > > > > if @rsmith agrees before anyone starts doing work to make changes.
> > > > > > > 
> > > > > > > When transforming declarations, `RebuildWhatever()` calls the 
> > > > > > > `ActOnWhatever()` function which calls 
> > > > > > > `ProcessDeclAttributeList()` so that attributes are processed. 
> > > > > > > `RebuildAttributedStmt()` similarly calls 
> > > > > > > `ActOnAttributedStmt()`. However, `ActOnAttributedStmt()` doesn't 
> > > > > > > call `ProcessStmtAttributes()` -- the logic is reversed so that 
> > > > > > > `ProcessStmtAttributes()` is what calls `ActOnAttributedStmt()`.
> > > > > > > 
> > > > > > > I think the correct answer is to switch the logic so that 
> > > > > > > `ActOnAttributedStmt()` calls `ProcessStmtAttributes()`, then the 
> > > > > > > template logic should automatically work.
> > > > > > > I think the correct answer is to switch the logic so that 
> > > > > > > ActOnAttributedStmt() calls ProcessStmtAttributes()
> > > > > > 
> > > > > > I think this would require `ProcessStmtAttributes()` to be split 
> > > > > > into two separate functions. Currently that function is doing two 
> > > > > > separate things:
> > > > > > 
> > > > > > 1. Translation of `ParsedAttr` into various subclasses of `Attr`.
> > > > > > 2. Validation that the attribute is semantically valid.
> > > > > > 
> > > > > > The function signature for `ActOnAttributedStmt()` uses `Attr` (not 
> > > > > > `ParsedAttr`), so (1) must happen during the parse, before 
> > > > > > `ActOnAttributedStmt()` is called. But (2) must be deferred until 
> > > > > > template instantiation time for some cases, like `musttail`.
> > > > > I don't think the signature for `ActOnAttributedStmt()` is correct to 

[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2021-04-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 335489.
yaxunl added a comment.

revised by John's comments


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

https://reviews.llvm.org/D71726

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/fp-atomic-ops.c
  clang/test/CodeGenCUDA/amdgpu-atomic-ops.cu
  clang/test/CodeGenOpenCL/atomic-ops.cl
  clang/test/Sema/atomic-ops.c
  clang/test/SemaOpenCL/atomic-ops.cl

Index: clang/test/SemaOpenCL/atomic-ops.cl
===
--- clang/test/SemaOpenCL/atomic-ops.cl
+++ clang/test/SemaOpenCL/atomic-ops.cl
@@ -1,10 +1,13 @@
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only -triple=spir64
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only -triple=amdgcn-amdhsa-amd-opencl
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify=expected,spir \
+// RUN:   -fsyntax-only -triple=spir64
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only \
+// RUN:   -triple=amdgcn-amd-amdhsa
 
 // Basic parsing/Sema tests for __opencl_atomic_*
 
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
 typedef __INTPTR_TYPE__ intptr_t;
 typedef int int8 __attribute__((ext_vector_type(8)));
@@ -36,7 +39,7 @@
 
 atomic_int gn;
 void f(atomic_int *i, const atomic_int *ci,
-   atomic_intptr_t *p, atomic_float *d,
+   atomic_intptr_t *p, atomic_float *f, atomic_double *d, atomic_half *h, // expected-error {{unknown type name 'atomic_half'}}
int *I, const int *CI,
intptr_t *P, float *D, struct S *s1, struct S *s2,
global atomic_int *i_g, local atomic_int *i_l, private atomic_int *i_p,
@@ -57,37 +60,38 @@
 
   __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(p, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_load(d, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_load(f, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(i_c, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to non-constant _Atomic type ('__constant atomic_int *' (aka '__constant _Atomic(int) *') invalid)}}
 
   __opencl_atomic_store(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_store(p, 1, memory_order_seq_cst, memory_scope_work_group);
-  (int)__opencl_atomic_store(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{operand of type 'void' where arithmetic or pointer type is required}}
+  (int)__opencl_atomic_store(f, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{operand of type 'void' where arithmetic or pointer type is required}}
 
   int exchange_1 = __opencl_atomic_exchange(i, 1, memory_order_seq_cst, memory_scope_work_group);
   int exchange_2 = __opencl_atomic_exchange(I, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to _Atomic}}
 
   __opencl_atomic_fetch_add(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_add(p, 1, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_fetch_add(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer or pointer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_add(f, 1.0f, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_fetch_add(d, 1.0, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_and(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_and(p, 1, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_fetch_and(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_and(f, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
 
   __opencl_atomic_fetch_min(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_max(i, 1, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_fetch_min(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
-  __opencl_atomic_fetch_max

[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-04-06 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal created this revision.
pdhaliwal added reviewers: JonChesterfield, ronlieb, jdoerfert, ABataev, 
gregrodgers.
Herald added subscribers: kerbowa, guansong, t-tye, tpr, dstuttard, yaxunl, 
mgorny, nhaehnle, jvesely, kzhuravl.
pdhaliwal requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, wdng.
Herald added a project: clang.

This patch adds new clang tool named amdgpu-arch which uses
HSA to detect installed AMDGPU and report back latter's march.
This tool is built only if system has HSA installed.

The value printed by amdgpu-arch is used to fill -march when
latter is not explicitly provided in -Xopenmp-target.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99949

Files:
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/tools/CMakeLists.txt
  clang/tools/amdgpu-arch/AMDGPUArch.cpp
  clang/tools/amdgpu-arch/CMakeLists.txt

Index: clang/tools/amdgpu-arch/CMakeLists.txt
===
--- /dev/null
+++ clang/tools/amdgpu-arch/CMakeLists.txt
@@ -0,0 +1,19 @@
+# //===--===//
+# //
+# // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# // See https://llvm.org/LICENSE.txt for details.
+# // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+# //
+# //===--===//
+
+include_directories(${LIBOMP_INCLUDE_DIR})
+
+find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
+if (NOT ${hsa-runtime64_FOUND})
+  message(INFO "Not building amdgpu-arch: hsa-runtime64 not found")
+  return()
+endif()
+  
+add_clang_tool(amdgpu-arch AMDGPUArch.cpp)
+
+clang_target_link_libraries(amdgpu-arch PRIVATE hsa-runtime64::hsa-runtime64)
Index: clang/tools/amdgpu-arch/AMDGPUArch.cpp
===
--- /dev/null
+++ clang/tools/amdgpu-arch/AMDGPUArch.cpp
@@ -0,0 +1,76 @@
+//===- AMDGPUArch.cpp - list AMDGPU installed --*- 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
+//
+//===--===//
+//
+// This file implements a tool for detecting name of AMDGPU installed in system
+// using HSA. This tool is used by AMDGPU OpenMP driver.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+
+namespace {
+
+class HSAAgentCollector {
+public:
+  static hsa_status_t iterateAgentsCallback(hsa_agent_t Agent, void *Data) {
+hsa_device_type_t DeviceType;
+hsa_status_t Status =
+hsa_agent_get_info(Agent, HSA_AGENT_INFO_DEVICE, &DeviceType);
+
+// continue only if device type if GPU
+if (Status != HSA_STATUS_SUCCESS || DeviceType != HSA_DEVICE_TYPE_GPU) {
+  return Status;
+}
+
+HSAAgentCollector *Self = static_cast(Data);
+char GPUName[64];
+Status = hsa_agent_get_info(Agent, HSA_AGENT_INFO_NAME, GPUName);
+if (Status != HSA_STATUS_SUCCESS) {
+  return Status;
+}
+Self->GPUs.push_back(GPUName);
+return HSA_STATUS_SUCCESS;
+  }
+
+  int execute() {
+hsa_status_t Status = hsa_init();
+if (Status != HSA_STATUS_SUCCESS) {
+  fprintf(stderr, "Unable to initialize HSA\n");
+}
+
+Status = hsa_iterate_agents(HSAAgentCollector::iterateAgentsCallback, this);
+if (Status != HSA_STATUS_SUCCESS) {
+  fprintf(stderr, "Error in hsa_iterate_agents\n");
+  return 1;
+}
+
+for (unsigned I = 0; I < GPUs.size(); I++) {
+  printf("%s", GPUs[I].c_str());
+  if (I != GPUs.size() - 1) {
+printf(",");
+  }
+}
+if (GPUs.size() < 1)
+  return 1;
+
+hsa_shut_down();
+return 0;
+  }
+
+private:
+  std::vector GPUs;
+};
+
+} // namespace
+
+int main() {
+  HSAAgentCollector Collector;
+  return Collector.execute();
+}
Index: clang/tools/CMakeLists.txt
===
--- clang/tools/CMakeLists.txt
+++ clang/tools/CMakeLists.txt
@@ -43,3 +43,5 @@
 
 # libclang may require clang-tidy in clang-tools-extra.
 add_clang_subdirectory(libclang)
+
+add_clang_subdirectory(amdgpu-arch)
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -15,7 +15,11 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include 
 
 using namespace clang::driver

[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-04-06 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal planned changes to this revision.
pdhaliwal added a comment.

Working on tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D99898: [clang, test] Fix use of undef FileCheck var

2021-04-06 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added inline comments.



Comment at: clang/test/CodeGen/libcalls.c:127
 // CHECK-NO-DAG: attributes [[NUW_RN]] = { nounwind readnone{{.*}} }
+// CHECK-YES-NOT: attributes [[NUW_RN]] = { nounwind readnone{{.*}} }
 // CHECK-NO-DAG: attributes [[NUW_RNI]] = { nofree nosync nounwind readnone 
speculatable willreturn }

Can we use a positive CHECK for the expected attributes instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99898

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


[clang] 849d372 - [NFC][Clang] Speculative fix for builtins-ppc-quadword-noi128.c

2021-04-06 Thread Roman Lebedev via cfe-commits

Author: Roman Lebedev
Date: 2021-04-06T16:15:23+03:00
New Revision: 849d3729433e05e6d89892c1814fa07ed3ec18e2

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

LOG: [NFC][Clang] Speculative fix for builtins-ppc-quadword-noi128.c

Added: 


Modified: 
clang/test/CodeGen/builtins-ppc-quadword-noi128.c

Removed: 




diff  --git a/clang/test/CodeGen/builtins-ppc-quadword-noi128.c 
b/clang/test/CodeGen/builtins-ppc-quadword-noi128.c
index bc97db2be1e9..d42a82958b08 100644
--- a/clang/test/CodeGen/builtins-ppc-quadword-noi128.c
+++ b/clang/test/CodeGen/builtins-ppc-quadword-noi128.c
@@ -75,8 +75,8 @@ vector unsigned char test_sube(vector unsigned char a, vector 
unsigned char b,
 // CHECK-LE-NEXT:[[TMP0:%.*]] = bitcast <16 x i8> [[B:%.*]] to <1 x i128>
 // CHECK-LE-NEXT:[[TMP1:%.*]] = bitcast <16 x i8> [[C:%.*]] to <1 x i128>
 // CHECK-LE-NEXT:[[TMP2:%.*]] = bitcast <16 x i8> [[A:%.*]] to <1 x i128>
-// CHECK-LE-NEXT:[[VADDUQM_I_NEG:%.*]] = sub <1 x i128> [[TMP2]], [[TMP0]]
-// CHECK-LE-NEXT:[[VSUBUQM_I:%.*]] = sub <1 x i128> [[VADDUQM_I_NEG]], 
[[TMP1]]
+// CHECK-LE-NEXT:[[VADDUQM_I_NEG:%.*]] = add <1 x i128> [[TMP0]], [[TMP1]]
+// CHECK-LE-NEXT:[[VSUBUQM_I:%.*]] = sub <1 x i128> [[TMP2]], 
[[VADDUQM_I_NEG]]
 // CHECK-LE-NEXT:[[TMP3:%.*]] = bitcast <1 x i128> [[VSUBUQM_I]] to <16 x 
i8>
 // CHECK-LE-NEXT:ret <16 x i8> [[TMP3]]
 //
@@ -85,8 +85,8 @@ vector unsigned char test_sube(vector unsigned char a, vector 
unsigned char b,
 // CHECK-AIX-NEXT:[[TMP0:%.*]] = bitcast <16 x i8> [[B:%.*]] to <1 x i128>
 // CHECK-AIX-NEXT:[[TMP1:%.*]] = bitcast <16 x i8> [[C:%.*]] to <1 x i128>
 // CHECK-AIX-NEXT:[[TMP2:%.*]] = bitcast <16 x i8> [[A:%.*]] to <1 x i128>
-// CHECK-AIX-NEXT:[[VADDUQM_I_NEG:%.*]] = sub <1 x i128> [[TMP2]], [[TMP0]]
-// CHECK-AIX-NEXT:[[VSUBUQM_I:%.*]] = sub <1 x i128> [[VADDUQM_I_NEG]], 
[[TMP1]]
+// CHECK-AIX-NEXT:[[VADDUQM_I_NEG:%.*]] = add <1 x i128> [[TMP0]], [[TMP1]]
+// CHECK-AIX-NEXT:[[VSUBUQM_I:%.*]] = sub <1 x i128> [[TMP2]], 
[[VADDUQM_I_NEG]]
 // CHECK-AIX-NEXT:[[TMP3:%.*]] = bitcast <1 x i128> [[VSUBUQM_I]] to <16 x 
i8>
 // CHECK-AIX-NEXT:ret <16 x i8> [[TMP3]]
 //



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


[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-04-06 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

This change is partly motivated by wanting to check in runtime tests for openmp 
that execute on whatever hardware is available locally. It is functionally 
similar to an out of tree bash script called mygpu that contains manually 
curated tables of pci.ids and to a python script called rocm_agent_enumerator 
that calls a c++ tool called rocminfo and tries to parse the output, with a 
different table of pci.ids for when that fails.

Ultimately, the bottom of this stack is a map from pci.id to gfx number stored 
in the user space driver thunk library, roct. That is linked into hsa. It would 
be simpler programming to copy&paste that map from roct into the openmp clang 
driver at the cost of inevitable divergence between the architecture clang 
detects and the architecture the runtime libraries detect. Spawning a process 
and reading stdout is a bit messy, but it beats copying the table, and it beats 
linking the gpu driver into clang in order to get at the table of numbers. This 
seems the right balance to me.

It should be possible to do something similar with cuda for nvptx, but that 
should be a separate executable. Partly to handle the permutations of cuda / 
hsa that may be present on a system. I haven't found the corresponding API call 
in cuda. The standalone tool nvidia-smi might be willing to emit sm_70 or 
similar to stdout, but I haven't found the right command line flags for that 
either. Rocminfo does not appear to be configurable, and is not necessarily 
present when compiling for amdgpu.

A bunch of comments inline, mostly style. I think there's a use-after-free bug.

It looks like our existing command line handling could be more robust. In 
particular, there should be error messages about march where there seem to be 
asserts. That makes it slightly unclear how we should handle things like the 
helper tool returning a string clang doesn't recognise (e.g. doesn't start with 
gfx). Something to revise separate to this patch I think.




Comment at: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp:78
+detectSystemGPUs(const ToolChain &T) {
+  auto Program = T.GetProgramPath("amdgpu-arch");
+  llvm::SmallVector execArgs;

AMDGPU_ARCH_PROGRAM_NAME?



Comment at: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp:83
+ OutputFile);
+  llvm::FileRemover OutputRemover(OutputFile.c_str());
+  llvm::Optional Redirects[] = {

This looks like there are too many stringrefs. Redirecting stdout to a 
temporary file seems reasonable, but I'd expect the pointers into OutputBuf to 
be invalid when it drops out of scope. Perhaps return a smallvector of 
smallstrings instead?

Also, we're probably expecting fewer than 8 different gpus, probably as few as 
1 in the most common case, so maybe a smallvector



Comment at: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp:90
+
+  if (const int RC =
+  llvm::sys::ExecuteAndWait(Program.c_str(), execArgs, {}, Redirects)) 
{

`s/const int RC =//`



Comment at: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp:91
+  if (const int RC =
+  llvm::sys::ExecuteAndWait(Program.c_str(), execArgs, {}, Redirects)) 
{
+return {};

can we pass {} for execArgs here?



Comment at: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp:111
+  }
+  if (GPUArchs.size() > 1) {
+bool AllSame = std::all_of(

Perhaps run all_of against the whole range and drop if size () > 1 test?



Comment at: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp:208
   assert(GPUArch.startswith("gfx") && "Unsupported sub arch");
+  assert(!GPUArch.empty() && "Unable to detect system GPU");
 

We shouldn't be handling unknown or missing march= fields with asserts. I see 
that this is already the case in multiple places, so let's go with a matching 
assert for this and aspire to fix that in a separate patch.



Comment at: clang/tools/amdgpu-arch/AMDGPUArch.cpp:32
+
+HSAAgentCollector *Self = static_cast(Data);
+char GPUName[64];

Simpler code if we drop the class and pass in the vector itself as the 
void*



Comment at: clang/tools/amdgpu-arch/AMDGPUArch.cpp:34
+char GPUName[64];
+Status = hsa_agent_get_info(Agent, HSA_AGENT_INFO_NAME, GPUName);
+if (Status != HSA_STATUS_SUCCESS) {

Does this null terminate for any length of GPU name? Wondering if we should 
explicitly zero out the last char.



Comment at: clang/tools/amdgpu-arch/AMDGPUArch.cpp:45
+if (Status != HSA_STATUS_SUCCESS) {
+  fprintf(stderr, "Unable to initialize HSA\n");
+}

Unsure these should be writing to stderr. We capture stdout, stderr probably 
goes to the user. We could exit 1 instead as clang is going to treat any 
failure to guess the arch identically 


=

[PATCH] D99901: [Driver][test] Test intended target only

2021-04-06 Thread Jinsong Ji via Phabricator via cfe-commits
jsji updated this revision to Diff 335499.
jsji added a comment.

Use -arch instead


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99901

Files:
  clang/test/Driver/nostdincxx.cpp


Index: clang/test/Driver/nostdincxx.cpp
===
--- clang/test/Driver/nostdincxx.cpp
+++ clang/test/Driver/nostdincxx.cpp
@@ -1,7 +1,7 @@
 // RUN: not %clangxx -nostdinc %s 2>&1 | FileCheck %s
 // RUN: not %clangxx -nostdinc++ %s 2>&1 | FileCheck %s
 // RUN: not %clangxx -nostdlibinc %s 2>&1 | FileCheck %s
-// RUN: not %clangxx -fsyntax-only -nostdinc -nostdinc++ %s 2>&1 | FileCheck 
/dev/null --implicit-check-not=-Wunused-command-line-argument
+// RUN: not %clangxx -triple x86_64-unknown-unknown-gnu unknown-unknown-gnu 
-fsyntax-only -nostdinc -nostdinc++ %s 2>&1 | FileCheck /dev/null 
--implicit-check-not=-Wunused-command-line-argument
 // CHECK: file not found
 #include  
 


Index: clang/test/Driver/nostdincxx.cpp
===
--- clang/test/Driver/nostdincxx.cpp
+++ clang/test/Driver/nostdincxx.cpp
@@ -1,7 +1,7 @@
 // RUN: not %clangxx -nostdinc %s 2>&1 | FileCheck %s
 // RUN: not %clangxx -nostdinc++ %s 2>&1 | FileCheck %s
 // RUN: not %clangxx -nostdlibinc %s 2>&1 | FileCheck %s
-// RUN: not %clangxx -fsyntax-only -nostdinc -nostdinc++ %s 2>&1 | FileCheck /dev/null --implicit-check-not=-Wunused-command-line-argument
+// RUN: not %clangxx -triple x86_64-unknown-unknown-gnu unknown-unknown-gnu -fsyntax-only -nostdinc -nostdinc++ %s 2>&1 | FileCheck /dev/null --implicit-check-not=-Wunused-command-line-argument
 // CHECK: file not found
 #include  
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99901: [Driver][test] Test intended target only

2021-04-06 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added inline comments.



Comment at: clang/test/Driver/nostdincxx.cpp:4
 // RUN: not %clangxx -nostdlibinc %s 2>&1 | FileCheck %s
-// RUN: not %clangxx -fsyntax-only -nostdinc -nostdinc++ %s 2>&1 | FileCheck 
/dev/null --implicit-check-not=-Wunused-command-line-argument
+// RUN: not %clangxx -target unknown-unknown-gnu -fsyntax-only -nostdinc 
-nostdinc++ %s 2>&1 | FileCheck /dev/null 
--implicit-check-not=-Wunused-command-line-argument
 // CHECK: file not found

MaskRay wrote:
> `error: unknown target triple 'unknown-unknown-hurd-gnu', please use -triple 
> or -arch`
> 
> Perhaps this should UNSUPPORTED aix if aix does not support -nostdinc++.
No, AIX does support `-nostdinc++`, we don't want to unsupport this whole test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99901

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


[PATCH] D99901: [Driver][test] Test intended target only

2021-04-06 Thread Jinsong Ji via Phabricator via cfe-commits
jsji updated this revision to Diff 335500.
jsji added a comment.

Remove typo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99901

Files:
  clang/test/Driver/nostdincxx.cpp


Index: clang/test/Driver/nostdincxx.cpp
===
--- clang/test/Driver/nostdincxx.cpp
+++ clang/test/Driver/nostdincxx.cpp
@@ -1,7 +1,7 @@
 // RUN: not %clangxx -nostdinc %s 2>&1 | FileCheck %s
 // RUN: not %clangxx -nostdinc++ %s 2>&1 | FileCheck %s
 // RUN: not %clangxx -nostdlibinc %s 2>&1 | FileCheck %s
-// RUN: not %clangxx -fsyntax-only -nostdinc -nostdinc++ %s 2>&1 | FileCheck 
/dev/null --implicit-check-not=-Wunused-command-line-argument
+// RUN: not %clangxx -triple x86_64-unknown-unknown-gnu -fsyntax-only 
-nostdinc -nostdinc++ %s 2>&1 | FileCheck /dev/null 
--implicit-check-not=-Wunused-command-line-argument
 // CHECK: file not found
 #include  
 


Index: clang/test/Driver/nostdincxx.cpp
===
--- clang/test/Driver/nostdincxx.cpp
+++ clang/test/Driver/nostdincxx.cpp
@@ -1,7 +1,7 @@
 // RUN: not %clangxx -nostdinc %s 2>&1 | FileCheck %s
 // RUN: not %clangxx -nostdinc++ %s 2>&1 | FileCheck %s
 // RUN: not %clangxx -nostdlibinc %s 2>&1 | FileCheck %s
-// RUN: not %clangxx -fsyntax-only -nostdinc -nostdinc++ %s 2>&1 | FileCheck /dev/null --implicit-check-not=-Wunused-command-line-argument
+// RUN: not %clangxx -triple x86_64-unknown-unknown-gnu -fsyntax-only -nostdinc -nostdinc++ %s 2>&1 | FileCheck /dev/null --implicit-check-not=-Wunused-command-line-argument
 // CHECK: file not found
 #include  
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99669: [RISCV][Clang] Add more RVV Floating-Point intrinsic functions.

2021-04-06 Thread Zakk Chen via Phabricator via cfe-commits
khchen marked 2 inline comments as done.
khchen added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:315
+multiclass RVVFloatingWidenTerBuiltinSet {
+  let HasMaskedOffOperand = false, Log2LMUL = [-2, -1, 0, 1, 2] in {
+defm "" : RVVOutOp1Op2BuiltinSet why is there not -3 in Log2LMUL?
Because there is no vector floating type with `mf8`. 
The minimum faction LMUL for floating is `mf2` and half float is `mf4`.
In fact, we can give all LMUL combinations because the clang generator will 
make sure the type is legal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99669

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


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2021-04-06 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

It would be good for @rjmccall / @rsmith / etc to actually finish reviewing 
this and accept it.
I would personally want to see the next patches - what changes are needed for 
llvm analysis, transforms?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

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


[PATCH] D99949: [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed

2021-04-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp:105
+
+llvm::StringRef getSystemGPUArch(const ToolChain &T) {
+  // detect the AMDGPU installed in system

This function is useful for AMDGPU toolchain and HIP toolchain. Can it be a 
member of AMDGPU toolchain?



Comment at: clang/tools/amdgpu-arch/CMakeLists.txt:9
+
+include_directories(${LIBOMP_INCLUDE_DIR})
+

This tool does not use omp header file. Why is this needed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99949

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


[PATCH] D97196: [clang-tidy] Add new check 'bugprone-unhandled-exception-at-new'.

2021-04-06 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 335505.
balazske added a comment.

Removed check of possible exceptions from constructor call.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97196

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-unhandled-exception-at-new.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-exception-at-new.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-exception-at-new.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-unhandled-exception-at-new.cpp
@@ -0,0 +1,175 @@
+// RUN: %check_clang_tidy -std=c++14 %s bugprone-unhandled-exception-at-new %t
+
+namespace std {
+typedef __typeof__(sizeof(0)) size_t;
+enum class align_val_t : std::size_t {};
+class exception {};
+class bad_alloc : public exception {};
+struct nothrow_t {};
+extern const nothrow_t nothrow;
+} // namespace std
+
+void *operator new(std::size_t, const std::nothrow_t &) noexcept;
+void *operator new(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept;
+void *operator new(std::size_t, void *) noexcept;
+
+class A {};
+typedef std::bad_alloc badalloc1;
+using badalloc2 = std::bad_alloc;
+using badalloc3 = std::bad_alloc &;
+
+void *operator new(std::size_t, int, int);
+void *operator new(std::size_t, int, int, int) noexcept;
+
+struct ClassSpecificNew {
+  void *operator new(std::size_t);
+  void *operator new(std::size_t, std::align_val_t);
+  void *operator new(std::size_t, int, int) noexcept;
+  void *operator new(std::size_t, int, int, int);
+};
+
+void f1() noexcept {
+  int *I1 = new int;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: missing exception handler for allocation failure at 'new'
+  try {
+int *I2 = new int;
+try {
+  int *I3 = new int;
+} catch (A) {
+}
+  } catch (std::bad_alloc) {
+  }
+
+  try {
+int *I = new int;
+  } catch (std::bad_alloc &) {
+  }
+
+  try {
+int *I = new int;
+  } catch (const std::bad_alloc &) {
+  }
+
+  try {
+int *I = new int;
+  } catch (badalloc1) {
+  }
+
+  try {
+int *I = new int;
+  } catch (badalloc1 &) {
+  }
+
+  try {
+int *I = new int;
+  } catch (const badalloc1 &) {
+  }
+
+  try {
+int *I = new int;
+  } catch (badalloc2) {
+  }
+
+  try {
+int *I = new int;
+  } catch (badalloc3) {
+  }
+
+  try {
+int *I = new int;
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: missing exception handler for allocation failure at 'new'
+  } catch (std::bad_alloc *) {
+  }
+
+  try {
+int *I = new int;
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: missing exception handler for allocation failure at 'new'
+  } catch (A) {
+  }
+}
+
+void f2() noexcept {
+  try {
+int *I = new int;
+  } catch (A) {
+  } catch (std::bad_alloc) {
+  }
+
+  try {
+int *I = new int;
+  } catch (...) {
+  }
+
+  try {
+int *I = new int;
+  } catch (const std::exception &) {
+  }
+}
+
+void f_new_nothrow() noexcept {
+  int *I1 = new (std::nothrow) int;
+  int *I2 = new (static_cast(1), std::nothrow) int;
+}
+
+void f_new_placement() noexcept {
+  char buf[100];
+  int *I = new (buf) int;
+}
+
+void f_new_user_defined() noexcept {
+  int *I1 = new (1, 2) int;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: missing exception handler for allocation failure at 'new'
+  int *I2 = new (1, 2, 3) int;
+}
+
+void f_class_specific() noexcept {
+  ClassSpecificNew *N1 = new ClassSpecificNew;
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: missing exception handler for allocation failure at 'new'
+  ClassSpecificNew *N2 = new (static_cast(1)) ClassSpecificNew;
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: missing exception handler for allocation failure at 'new'
+  ClassSpecificNew *N3 = new (1, 2) ClassSpecificNew;
+  ClassSpecificNew *N4 = new (1, 2, 3) ClassSpecificNew;
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: missing exception handler for allocation failure at 'new'
+}
+
+void f_est_none() {
+  int *I = new int;
+}
+
+void f_est_noexcept_false() noexcept(false) {
+  int *I = new int;
+}
+
+void f_est_noexcept_true() noexcept(true) {
+  int *I = new int;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: missing exception handler for allocation failure at 'new'
+}
+
+void f_est_dynamic_none() throw() {
+  int *I = new int;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: missing exception handler for allocation failure at 'new'
+}
+
+void f_est_dynamic_1() throw(std::bad_alloc) {
+  int *I = new int;
+}
+
+void f_est_dynamic_2() throw(A) {

[PATCH] D99860: Remove `COMPILER_RT_INSTALL_PATH`

2021-04-06 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

In D99860#2670359 , @phosek wrote:

> I'm worried that overriding `CMAKE_INSTALL_PREFIX` is going to break the 
> runtimes build where we build compiler-rt, libcxx, libcxxabi, libunwind in a 
> single CMake build, and compiler-rt always comes first see 
> https://github.com/llvm/llvm-project/blob/98742e42fc50f58d3f2d3f2cdbbf540288c134b9/runtimes/CMakeLists.txt#L57.

Gotcha, and `if (LLVM_TREE_AVAILABLE)` would be true in that case? That means 
compiler-rt-specific variables are here to stay, but I no longer think that's 
so bad. See the latest https://reviews.llvm.org/D99484 for how polly works now, 
I can do that here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99860

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


[PATCH] D97196: [clang-tidy] Add new check 'bugprone-unhandled-exception-at-new'.

2021-04-06 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

Rename the check to "unhandled-bad_alloc" (or similar")? And the error message 
to " missing exception handler 'std::bad_alloc' "?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97196

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


[PATCH] D99181: [analyzer] Fix crash on spaceship operator (PR47511)

2021-04-06 Thread Loïc Joly via Phabricator via cfe-commits
loic-joly-sonarsource added inline comments.



Comment at: clang/test/Analysis/PR47511.cpp:5
+
+#include "Inputs/std-compare.h"
+

For such a simple test, there is no need to use the full-fledged header, the 
following would suffice:
```
namespace std { 
struct strong_ordering {
  int n;
  constexpr operator int() const { return n; }
  static const strong_ordering equal, greater, less;
};
constexpr strong_ordering strong_ordering::equal = { 0 };
constexpr strong_ordering strong_ordering::greater = { 1 };
constexpr strong_ordering strong_ordering::less = { -1 };
} // namespace std
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99181

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


[PATCH] D99658: [analyzer] Fix clang_analyzer_getExtent for heap regions

2021-04-06 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D99658#2665730 , @NoQ wrote:

> What about `clang_analyzer_getExtent(&x[2])` then?

I guess `(extent of heap segment that starts at symbol of type 'int *' conjured 
at statement 'new int [ext]') - 8` is the value I expect - which is the size of 
the remaining part of the memory region from `x+2 in bytes.`
We can argue about the semantics of this debug intrinsic or the name of it 
though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99658

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


[PATCH] D99837: [Windows] Turn off text mode correctly in Rewriter to stop CRLF translation

2021-04-06 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea accepted this revision.
aganea added a comment.
This revision is now accepted and ready to land.

It works now, thanks! :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99837

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


[clang] 23929af - [Windows] Turn off text mode correctly in Rewriter to stop CRLF translation

2021-04-06 Thread Abhina Sreeskantharajan via cfe-commits

Author: Abhina Sreeskantharajan
Date: 2021-04-06T10:49:09-04:00
New Revision: 23929af383f27a6ddf23704192a25591481152b3

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

LOG: [Windows] Turn off text mode correctly in Rewriter to stop CRLF translation

I incorrectly changed the RewriteTestAction::ExecuteAction's file to binary 
instead of the proper RewriteIncludesAction::BeginSourceFileAction in 
https://reviews.llvm.org/rGbc5d4bcc2deb71ab647270c9754a83484b3d6f87. In the 
original commit, I actually changed 
RewriteIncludesAction::BeginSourceFileAction in 
https://reviews.llvm.org/rGfdb640ea30d416368b76b68b106deda580c6aced. This 
should fix the issue @aganea is facing.

Reviewed By: aganea

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

Added: 


Modified: 
clang/lib/Frontend/Rewrite/FrontendActions.cpp

Removed: 




diff  --git a/clang/lib/Frontend/Rewrite/FrontendActions.cpp 
b/clang/lib/Frontend/Rewrite/FrontendActions.cpp
index 45960068220b..09ed07be923e 100644
--- a/clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ b/clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -194,7 +194,7 @@ void RewriteMacrosAction::ExecuteAction() {
 void RewriteTestAction::ExecuteAction() {
   CompilerInstance &CI = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(/*Binary=*/true, 
getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/false, 
getCurrentFileOrBufferName());
   if (!OS) return;
 
   DoRewriteTest(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@ class RewriteIncludesAction::RewriteImportsListener : 
public ASTReaderListener {
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance &CI) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(/*Binary=*/false, 
getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(/*Binary=*/true, 
getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }



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


[PATCH] D99837: [Windows] Turn off text mode correctly in Rewriter to stop CRLF translation

2021-04-06 Thread Abhina Sree 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 rG23929af383f2: [Windows] Turn off text mode correctly in 
Rewriter to stop CRLF translation (authored by abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99837

Files:
  clang/lib/Frontend/Rewrite/FrontendActions.cpp


Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -194,7 +194,7 @@
 void RewriteTestAction::ExecuteAction() {
   CompilerInstance &CI = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(/*Binary=*/true, 
getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/false, 
getCurrentFileOrBufferName());
   if (!OS) return;
 
   DoRewriteTest(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance &CI) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(/*Binary=*/false, 
getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(/*Binary=*/true, 
getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }


Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -194,7 +194,7 @@
 void RewriteTestAction::ExecuteAction() {
   CompilerInstance &CI = getCompilerInstance();
   std::unique_ptr OS =
-  CI.createDefaultOutputFile(/*Binary=*/true, getCurrentFileOrBufferName());
+  CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
   if (!OS) return;
 
   DoRewriteTest(CI.getPreprocessor(), OS.get());
@@ -270,7 +270,7 @@
 bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance &CI) {
   if (!OutputStream) {
 OutputStream =
-CI.createDefaultOutputFile(/*Binary=*/false, getCurrentFileOrBufferName());
+CI.createDefaultOutputFile(/*Binary=*/true, getCurrentFileOrBufferName());
 if (!OutputStream)
   return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99959: [analyzer][NFC] Add tests for extents

2021-04-06 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: NoQ, vsavchenko, Charusso.
Herald added subscribers: ASDenysPetrov, martong, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun, 
whisperity.
Herald added a reviewer: Szelethus.
steakhal requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If we allocate memory, the extent of the MemRegion will be the symbolic
value of the size parameter. This way, if that symbol gets constrained,
the extent will be also constrained.

This test demonstrates that the extent is indeed the same symbol.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99959

Files:
  clang/test/Analysis/malloc.c


Index: clang/test/Analysis/malloc.c
===
--- clang/test/Analysis/malloc.c
+++ clang/test/Analysis/malloc.c
@@ -8,6 +8,8 @@
 #include "Inputs/system-header-simulator.h"
 
 void clang_analyzer_eval(int);
+void clang_analyzer_dump(int);
+void clang_analyzer_dumpExtent(void *);
 
 // Without -fms-compatibility, wchar_t isn't a builtin type. MSVC defines
 // _WCHAR_T_DEFINED if wchar_t is available. Microsoft recommends that you use
@@ -1883,3 +1885,14 @@
   s->memP = malloc(sizeof(int));
   free(s);
 } // FIXME: should warn here
+
+int conjure();
+void testExtent() {
+  int x = conjure();
+  clang_analyzer_dump(x);
+  // expected-warning-re@-1 ^conj_\$[[:digit:]]+{int, LC1, S[[:digit:]]+, 
#1}}
+  int *p = (int *)malloc(x);
+  clang_analyzer_dumpExtent(p);
+  // expected-warning-re@-1 ^conj_\$[[:digit:]]+{int, LC1, S[[:digit:]]+, 
#1}}
+  free(p);
+}


Index: clang/test/Analysis/malloc.c
===
--- clang/test/Analysis/malloc.c
+++ clang/test/Analysis/malloc.c
@@ -8,6 +8,8 @@
 #include "Inputs/system-header-simulator.h"
 
 void clang_analyzer_eval(int);
+void clang_analyzer_dump(int);
+void clang_analyzer_dumpExtent(void *);
 
 // Without -fms-compatibility, wchar_t isn't a builtin type. MSVC defines
 // _WCHAR_T_DEFINED if wchar_t is available. Microsoft recommends that you use
@@ -1883,3 +1885,14 @@
   s->memP = malloc(sizeof(int));
   free(s);
 } // FIXME: should warn here
+
+int conjure();
+void testExtent() {
+  int x = conjure();
+  clang_analyzer_dump(x);
+  // expected-warning-re@-1 ^conj_\$[[:digit:]]+{int, LC1, S[[:digit:]]+, #1}}
+  int *p = (int *)malloc(x);
+  clang_analyzer_dumpExtent(p);
+  // expected-warning-re@-1 ^conj_\$[[:digit:]]+{int, LC1, S[[:digit:]]+, #1}}
+  free(p);
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b660abc - [ObjC] Add a command line flag that disables recognition of objc_direct for testability

2021-04-06 Thread Erik Pilkington via cfe-commits

Author: Erik Pilkington
Date: 2021-04-06T11:17:01-04:00
New Revision: b660abc80d0d0943c54e9440636ddfa89c2d626d

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

LOG: [ObjC] Add a command line flag that disables recognition of objc_direct 
for testability

Programmers would like to be able to test direct methods by calling them from a
different linkage unit or mocking them, both of which are impossible. This
patch adds a flag that effectively disables the attribute, which will fix this
when enabled in testable builds. rdar://71190891

Differential revision: https://reviews.llvm.org/D95845

Added: 
clang/test/CodeGenObjC/disable-direct-method.m
clang/test/SemaObjC/disable-direct-method.m

Modified: 
clang/include/clang/AST/DeclObjC.h
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/lib/AST/DeclObjC.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaDeclObjC.cpp
clang/test/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/include/clang/AST/DeclObjC.h 
b/clang/include/clang/AST/DeclObjC.h
index b1bce069920c..6bb9cdf67034 100644
--- a/clang/include/clang/AST/DeclObjC.h
+++ b/clang/include/clang/AST/DeclObjC.h
@@ -852,9 +852,7 @@ class ObjCPropertyDecl : public NamedDecl {
   bool isClassProperty() const {
 return PropertyAttributes & ObjCPropertyAttribute::kind_class;
   }
-  bool isDirectProperty() const {
-return PropertyAttributes & ObjCPropertyAttribute::kind_direct;
-  }
+  bool isDirectProperty() const;
 
   ObjCPropertyQueryKind getQueryKind() const {
 return isClassProperty() ? ObjCPropertyQueryKind::OBJC_PR_query_class :

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 1560a1f38aeb..b29dae5e2076 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -298,6 +298,8 @@ LANGOPT(ObjCSubscriptingLegacyRuntime , 1, 0, 
"Subscripting support in l
 BENIGN_LANGOPT(CompatibilityQualifiedIdBlockParamTypeChecking, 1, 0,
"compatibility mode for type checking block parameters "
"involving qualified id types")
+LANGOPT(ObjCDisableDirectMethodsForTesting, 1, 0,
+"Disable recognition of objc_direct methods")
 LANGOPT(CFProtectionBranch , 1, 0, "Control-Flow Branch Protection enabled")
 LANGOPT(FakeAddressSpaceMap , 1, 0, "OpenCL fake address space map")
 ENUM_LANGOPT(AddressSpaceMapMangling , AddrSpaceMapMangling, 2, ASMM_Target, 
"OpenCL address space map mangling mode")

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 38977cc0b874..1a71d68ec4e2 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2225,6 +2225,12 @@ def fobjc_nonfragile_abi : Flag<["-"], 
"fobjc-nonfragile-abi">, Group;
 def fno_objc_nonfragile_abi : Flag<["-"], "fno-objc-nonfragile-abi">, 
Group;
 
 def fobjc_sender_dependent_dispatch : Flag<["-"], 
"fobjc-sender-dependent-dispatch">, Group;
+def fobjc_disable_direct_methods_for_testing :
+  Flag<["-"], "fobjc-disable-direct-methods-for-testing">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Ignore attribute objc_direct so that direct methods can be 
tested">,
+  MarshallingInfoFlag>;
+
 def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group;
 def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, 
NoArgumentUnused, FlangOption, FC1Option]>,
   HelpText<"Parse OpenMP pragmas and generate parallel code.">;

diff  --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 5f82fcec90e3..6e790f03b027 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -826,7 +826,8 @@ ObjCMethodDecl 
*ObjCMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
 }
 
 bool ObjCMethodDecl::isDirectMethod() const {
-  return hasAttr();
+  return hasAttr() &&
+ !getASTContext().getLangOpts().ObjCDisableDirectMethodsForTesting;
 }
 
 bool ObjCMethodDecl::isThisDeclarationADesignatedInitializer() const {
@@ -2295,6 +2296,11 @@ QualType ObjCPropertyDecl::getUsageType(QualType 
objectType) const {
   ObjCSubstitutionContext::Property);
 }
 
+bool ObjCPropertyDecl::isDirectProperty() const {
+  return (PropertyAttributes & ObjCPropertyAttribute::kind_direct) &&
+ !getASTContext().getLangOpts().ObjCDisableDirectMethodsForTesting;
+}
+
 
//===--===//
 // ObjCPropertyImplDecl
 
//===--===//

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 96a43656bf99..aaf6f83a0cfa 100644

[PATCH] D95845: [ObjC] Add a command line flag that disables recognition of objc_direct for testability

2021-04-06 Thread Erik Pilkington via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb660abc80d0d: [ObjC] Add a command line flag that disables 
recognition of objc_direct for… (authored by erik.pilkington).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95845

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/DeclObjC.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/test/CodeGenObjC/disable-direct-method.m
  clang/test/Driver/clang_f_opts.c
  clang/test/SemaObjC/disable-direct-method.m

Index: clang/test/SemaObjC/disable-direct-method.m
===
--- /dev/null
+++ clang/test/SemaObjC/disable-direct-method.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -verify -fobjc-disable-direct-methods-for-testing %s
+
+// expected-no-diagnostics
+
+#define DIRECT __attribute__((objc_direct))
+#define DIRECT_MEMBERS __attribute__((objc_direct_members))
+
+__attribute__((objc_root_class))
+@interface X
+-(void)direct_method DIRECT;
+@end
+
+@implementation X
+-(void)direct_method DIRECT {}
+@end
+
+__attribute__((objc_root_class))
+DIRECT_MEMBERS
+@interface Y
+-(void)direct_method2;
+@end
+
+@implementation Y
+-(void)direct_method2 {}
+@end
+
+__attribute__((objc_root_class))
+@interface Z
+@property (direct) int direct_property;
+@end
+
+@implementation Z @end
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -576,3 +576,8 @@
 
 // RUN: %clang -### -S -fno-temp-file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-TEMP-FILE %s
 // CHECK-NO-TEMP-FILE: "-fno-temp-file"
+
+// RUN: %clang -### -xobjective-c -fobjc-disable-direct-methods-for-testing %s 2>&1 | FileCheck -check-prefix=CHECK_DISABLE_DIRECT %s
+// RUN: %clang -### -xobjective-c %s 2>&1 | FileCheck -check-prefix=CHECK_NO_DISABLE_DIRECT %s
+// CHECK_DISABLE_DIRECT: -fobjc-disable-direct-methods-for-testing
+// CHECK_NO_DISABLE_DIRECT-NOT: -fobjc-disable-direct-methods-for-testing
Index: clang/test/CodeGenObjC/disable-direct-method.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/disable-direct-method.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10 -fobjc-disable-direct-methods-for-testing %s -o - | FileCheck %s
+
+@interface Y
+@property (direct) int direct_property;
+@end
+@implementation Y @end
+
+// CHECK: @OBJC_PROP_NAME_ATTR_ = private unnamed_addr constant [16 x i8] c"direct_property\00"
+// CHECK: @"_OBJC_$_PROP_LIST_Y" =
+// CHECK-SAME: @OBJC_PROP_NAME_ATTR_,
+
+@interface X
+-(void)m __attribute__((objc_direct));
+@end
+
+// CHECK-LABEL: define void @f
+void f(X *x) {
+  [x m];
+
+  // CHECK: call void bitcast ({{.*}} @objc_msgSend to {{.*}})
+}
Index: clang/lib/Sema/SemaDeclObjC.cpp
===
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ clang/lib/Sema/SemaDeclObjC.cpp
@@ -4407,10 +4407,12 @@
 
 void Sema::CheckObjCMethodDirectOverrides(ObjCMethodDecl *method,
   ObjCMethodDecl *overridden) {
-  if (const auto *attr = overridden->getAttr()) {
+  if (overridden->isDirectMethod()) {
+const auto *attr = overridden->getAttr();
 Diag(method->getLocation(), diag::err_objc_override_direct_method);
 Diag(attr->getLocation(), diag::note_previous_declaration);
-  } else if (const auto *attr = method->getAttr()) {
+  } else if (method->isDirectMethod()) {
+const auto *attr = method->getAttr();
 Diag(attr->getLocation(), diag::err_objc_direct_on_override)
 << isa(overridden->getDeclContext());
 Diag(overridden->getLocation(), diag::note_previous_declaration);
@@ -4856,7 +4858,8 @@
 // the canonical declaration.
 if (!ObjCMethod->isDirectMethod()) {
   const ObjCMethodDecl *CanonicalMD = ObjCMethod->getCanonicalDecl();
-  if (const auto *attr = CanonicalMD->getAttr()) {
+  if (CanonicalMD->isDirectMethod()) {
+const auto *attr = CanonicalMD->getAttr();
 ObjCMethod->addAttr(
 ObjCDirectAttr::CreateImplicit(Context, attr->getLocation()));
   }
@@ -4901,14 +4904,16 @@
 Diag(IMD->getLocation(), diag::note_previous_declaration);
   };
 
-  if (const auto *attr = ObjCMethod->getAttr()) {
+  if (ObjCMethod->isDirectMethod()) {
+const auto *attr = ObjCMethod->getAttr();
 if (ObjCMethod->getCanonicalDecl() != IMD) {
   diagContainerMismatch();
 } else if (!IMD->isDirectMethod()) {
   Diag(attr->getLocation(), diag::err_objc_direct_missing_on_decl);
   Diag(IMD->getLocation(), d

[PATCH] D98128: [clang][clangd] Avoid inconsistent target creation

2021-04-06 Thread Tommy Chiang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG14a7296c0120: [clang][clangd] Avoid inconsistent target 
creation (authored by oToToT).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98128

Files:
  clang-tools-extra/clangd/Compiler.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp

Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -365,17 +365,9 @@
   Clang->setDiagnostics(&Diagnostics);
 
   // Create the target instance.
-  Clang->setTarget(TargetInfo::CreateTargetInfo(
-  Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
-  if (!Clang->hasTarget())
+  if (!Clang->createTarget())
 return BuildPreambleError::CouldntCreateTargetInfo;
 
-  // Inform the target of the language options.
-  //
-  // FIXME: We shouldn't need to do this, the target should be immutable once
-  // created. This complexity should be lifted elsewhere.
-  Clang->getTarget().adjust(Clang->getLangOpts());
-
   if (Clang->getFrontendOpts().Inputs.size() != 1 ||
   Clang->getFrontendOpts().Inputs[0].getKind().getFormat() !=
   InputKind::Source ||
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -1150,17 +1150,9 @@
   Clang->setDiagnostics(&getDiagnostics());
 
   // Create the target instance.
-  Clang->setTarget(TargetInfo::CreateTargetInfo(
-  Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
-  if (!Clang->hasTarget())
+  if (!Clang->createTarget())
 return true;
 
-  // Inform the target of the language options.
-  //
-  // FIXME: We shouldn't need to do this, the target should be immutable once
-  // created. This complexity should be lifted elsewhere.
-  Clang->getTarget().adjust(Clang->getLangOpts());
-
   assert(Clang->getFrontendOpts().Inputs.size() == 1 &&
  "Invocation must have exactly one source file!");
   assert(Clang->getFrontendOpts().Inputs[0].getKind().getFormat() ==
@@ -1568,17 +1560,9 @@
   Clang->setDiagnostics(&AST->getDiagnostics());
 
   // Create the target instance.
-  Clang->setTarget(TargetInfo::CreateTargetInfo(
-  Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
-  if (!Clang->hasTarget())
+  if (!Clang->createTarget())
 return nullptr;
 
-  // Inform the target of the language options.
-  //
-  // FIXME: We shouldn't need to do this, the target should be immutable once
-  // created. This complexity should be lifted elsewhere.
-  Clang->getTarget().adjust(Clang->getLangOpts());
-
   assert(Clang->getFrontendOpts().Inputs.size() == 1 &&
  "Invocation must have exactly one source file!");
   assert(Clang->getFrontendOpts().Inputs[0].getKind().getFormat() ==
@@ -2194,19 +2178,11 @@
   ProcessWarningOptions(Diag, Inv.getDiagnosticOpts());
 
   // Create the target instance.
-  Clang->setTarget(TargetInfo::CreateTargetInfo(
-  Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
-  if (!Clang->hasTarget()) {
+  if (!Clang->createTarget()) {
 Clang->setInvocation(nullptr);
 return;
   }
 
-  // Inform the target of the language options.
-  //
-  // FIXME: We shouldn't need to do this, the target should be immutable once
-  // created. This complexity should be lifted elsewhere.
-  Clang->getTarget().adjust(Clang->getLangOpts());
-
   assert(Clang->getFrontendOpts().Inputs.size() == 1 &&
  "Invocation must have exactly one source file!");
   assert(Clang->getFrontendOpts().Inputs[0].getKind().getFormat() ==
Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -118,9 +118,7 @@
 VFS = VFSWithRemapping;
   Clang->createFileManager(VFS);
 
-  Clang->setTarget(TargetInfo::CreateTargetInfo(
-  Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
-  if (!Clang->hasTarget())
+  if (!Clang->createTarget())
 return nullptr;
 
   // RemappedFileBuffers will handle the lifetime of the Buffer pointer,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 14a7296 - [clang][clangd] Avoid inconsistent target creation

2021-04-06 Thread via cfe-commits

Author: oToToT
Date: 2021-04-06T23:23:34+08:00
New Revision: 14a7296c0120913e949739e4e90ea5a5f1bd8af1

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

LOG: [clang][clangd] Avoid inconsistent target creation

As proposed in D97109, I tried to make target creation consistent in `clang` 
and `clangd` by replacing the original procedure with a single function 
introduced in D97493.

This also helps `clangd` works with CUDA, OpenMP, etc.

Reviewed By: kadircet

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

Added: 


Modified: 
clang-tools-extra/clangd/Compiler.cpp
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/PrecompiledPreamble.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Compiler.cpp 
b/clang-tools-extra/clangd/Compiler.cpp
index bcae67d82050..0a1e43d80864 100644
--- a/clang-tools-extra/clangd/Compiler.cpp
+++ b/clang-tools-extra/clangd/Compiler.cpp
@@ -118,9 +118,7 @@ 
prepareCompilerInstance(std::unique_ptr CI,
 VFS = VFSWithRemapping;
   Clang->createFileManager(VFS);
 
-  Clang->setTarget(TargetInfo::CreateTargetInfo(
-  Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
-  if (!Clang->hasTarget())
+  if (!Clang->createTarget())
 return nullptr;
 
   // RemappedFileBuffers will handle the lifetime of the Buffer pointer,

diff  --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index e7a87dc6b23c..988090a8b1b1 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -1150,17 +1150,9 @@ bool 
ASTUnit::Parse(std::shared_ptr PCHContainerOps,
   Clang->setDiagnostics(&getDiagnostics());
 
   // Create the target instance.
-  Clang->setTarget(TargetInfo::CreateTargetInfo(
-  Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
-  if (!Clang->hasTarget())
+  if (!Clang->createTarget())
 return true;
 
-  // Inform the target of the language options.
-  //
-  // FIXME: We shouldn't need to do this, the target should be immutable once
-  // created. This complexity should be lifted elsewhere.
-  Clang->getTarget().adjust(Clang->getLangOpts());
-
   assert(Clang->getFrontendOpts().Inputs.size() == 1 &&
  "Invocation must have exactly one source file!");
   assert(Clang->getFrontendOpts().Inputs[0].getKind().getFormat() ==
@@ -1568,17 +1560,9 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
   Clang->setDiagnostics(&AST->getDiagnostics());
 
   // Create the target instance.
-  Clang->setTarget(TargetInfo::CreateTargetInfo(
-  Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
-  if (!Clang->hasTarget())
+  if (!Clang->createTarget())
 return nullptr;
 
-  // Inform the target of the language options.
-  //
-  // FIXME: We shouldn't need to do this, the target should be immutable once
-  // created. This complexity should be lifted elsewhere.
-  Clang->getTarget().adjust(Clang->getLangOpts());
-
   assert(Clang->getFrontendOpts().Inputs.size() == 1 &&
  "Invocation must have exactly one source file!");
   assert(Clang->getFrontendOpts().Inputs[0].getKind().getFormat() ==
@@ -2194,19 +2178,11 @@ void ASTUnit::CodeComplete(
   ProcessWarningOptions(Diag, Inv.getDiagnosticOpts());
 
   // Create the target instance.
-  Clang->setTarget(TargetInfo::CreateTargetInfo(
-  Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
-  if (!Clang->hasTarget()) {
+  if (!Clang->createTarget()) {
 Clang->setInvocation(nullptr);
 return;
   }
 
-  // Inform the target of the language options.
-  //
-  // FIXME: We shouldn't need to do this, the target should be immutable once
-  // created. This complexity should be lifted elsewhere.
-  Clang->getTarget().adjust(Clang->getLangOpts());
-
   assert(Clang->getFrontendOpts().Inputs.size() == 1 &&
  "Invocation must have exactly one source file!");
   assert(Clang->getFrontendOpts().Inputs[0].getKind().getFormat() ==

diff  --git a/clang/lib/Frontend/PrecompiledPreamble.cpp 
b/clang/lib/Frontend/PrecompiledPreamble.cpp
index 77b93713ce68..af82ab3f5558 100644
--- a/clang/lib/Frontend/PrecompiledPreamble.cpp
+++ b/clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -365,17 +365,9 @@ llvm::ErrorOr 
PrecompiledPreamble::Build(
   Clang->setDiagnostics(&Diagnostics);
 
   // Create the target instance.
-  Clang->setTarget(TargetInfo::CreateTargetInfo(
-  Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
-  if (!Clang->hasTarget())
+  if (!Clang->createTarget())
 return BuildPreambleError::CouldntCreateTargetInfo;
 
-  // Inform the target of the language options.
-  //
-  // FIXME: We shouldn't need to do this, the target should be immutable once
-  // created. This complexity should be lifted elsewhere.
-  Clang->getTarget().adjust(Clang->getLangOpts());
-
   i

[PATCH] D98747: Thread safety analysis: Don't warn about managed locks on join points

2021-04-06 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Ping @aaron.ballman, @delesley.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98747

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


[PATCH] D99696: [clang] NRVO: Improvements and handling of more cases.

2021-04-06 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 335532.
mizvekov added a comment.

- small Doxygen fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99696

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CodeGen/nrvo-tracking.cpp

Index: clang/test/CodeGen/nrvo-tracking.cpp
===
--- clang/test/CodeGen/nrvo-tracking.cpp
+++ clang/test/CodeGen/nrvo-tracking.cpp
@@ -29,8 +29,6 @@
 
 // CHECK-LABEL: define{{.*}} void @_Z2l3v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
-// CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  ret void
 L(3, t, T);
@@ -45,8 +43,6 @@
 
 // CHECK-LABEL: define{{.*}} void @_Z2l5v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
-// CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  ret void
 L(5, t, auto);
@@ -61,8 +57,6 @@
 
 // CHECK-LABEL: define{{.*}} void @_Z2l7v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
-// CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  ret void
 L(7, t, decltype(auto));
@@ -113,8 +107,6 @@
 
 // CHECK-LABEL: define{{.*}} void @_Z2f5v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
-// CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  ret void
 F(5, t, auto);
@@ -129,8 +121,6 @@
 
 // CHECK-LABEL: define{{.*}} void @_Z2f7v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
-// CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  ret void
 F(7, t, decltype(auto));
@@ -152,7 +142,11 @@
   }; }()();\
 }
 
-//B(1, X); // Uncomment this line at your own peril ;)
+// CHECK-LABEL: define{{.*}} void @_Z2b1v
+// CHECK:   call {{.*}} @_ZN1XC1Ev
+// CHECK-NEXT:  call void @llvm.lifetime.end
+// CHECK-NEXT:  ret void
+B(1, X);
 
 // CHECK-LABEL: define{{.*}} void @_Z2b2v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
@@ -164,8 +158,6 @@
 
 // CHECK-LABEL: define{{.*}} void @_Z2b3v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
-// CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  ret void
 B(3, T);
@@ -180,8 +172,6 @@
 
 // CHECK-LABEL: define{{.*}} void @_Z2b5v
 // CHECK:   call {{.*}} @_ZN1XC1Ev
-// CHECK-NEXT:  call {{.*}} @_ZN1XC1EOS_
-// CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  call void @llvm.lifetime.end
 // CHECK-NEXT:  ret void
 B(5, );
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1052,9 +1052,18 @@
  StartingScope, InstantiatingVarTemplate);
 
   if (D->isNRVOVariable()) {
-QualType ReturnType = cast(DC)->getReturnType();
-if (SemaRef.isCopyElisionCandidate(ReturnType, Var, Sema::CES_Strict))
-  Var->setNRVOVariable(true);
+QualType ReturnType;
+if (auto *F = dyn_cast(DC))
+  ReturnType = F->getReturnType();
+else if (auto *F = dyn_cast(DC))
+  // FIXME: get the return type here somehow...
+  ReturnType = SemaRef.Context.getAutoDeductType();
+else
+  assert(false && "Unknown context type");
+
+Sema::NRVOResult Res = SemaRef.getNRVOResult(Var);
+SemaRef.updNRVOResultWithRetType(Res, ReturnType);
+Var->setNRVOVariable(Res.isCopyElidable());
   }
 
   Var->setImplicit(D->isImplicit());
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3026,99 +3026,155 @@
   return new (Context) BreakStmt(BreakLoc);
 }
 
-/// Determine whether the given expression is a candidate for
-/// copy elision in either a return statement or a throw expression.
+static void downgradeNRVOResult(Sema::NRVOResult &Res, bool CanMove) {
+  Res.S = Res.S != Sema::NRVOResult::None && CanMove
+  ? Sema::NRVOResult::MoveEligible
+  : Sema::NRVOResult::None;
+}
+
+/// Determine whether the given NRVO candidate variable is move-eligible or
+/// copy-elidable, without considering function return type.
 ///
-/// \param ReturnType If we're determining the copy elision candidate for
-/// a return statement, this is the return type of the function. If we're
-/// determining the copy elision candidate

[PATCH] D99964: [RISCV][Clang] Add all RVV Reduction intrinsic functions.

2021-04-06 Thread Zakk Chen via Phabricator via cfe-commits
khchen created this revision.
khchen added reviewers: craig.topper, rogfer01, HsiangKai, evandro, liaolucy, 
jrtc27.
Herald added subscribers: vkmr, frasercrmck, dexonsmith, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, edward-jones, zzheng, shiva0217, kito-cheng, niosHD, 
sabuasal, simoncook, johnrusso, rbar, asb.
khchen requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Authored-by: Roger Ferrer Ibanez 
Co-Authored-by: Zakk Chen 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99964

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredxor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vwredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfredmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfredmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfwredosum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfwredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vredand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vredmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vredmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vredor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vredxor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vwredsum.c

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


[PATCH] D99965: [RISCV][Clang] Add more RVV load/store intrinsic functions.

2021-04-06 Thread Zakk Chen via Phabricator via cfe-commits
khchen created this revision.
khchen added reviewers: craig.topper, rogfer01, HsiangKai, evandro, liaolucy, 
jrtc27.
Herald added subscribers: vkmr, frasercrmck, dexonsmith, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, edward-jones, zzheng, shiva0217, kito-cheng, niosHD, 
sabuasal, simoncook, johnrusso, rbar, asb.
khchen requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Support the following instructions.

1. Mask load and store
2. Vector Strided Instructions
3. Vector Indexed Store Instructions

Authored-by: Roger Ferrer Ibanez 
Co-Authored-by: Zakk Chen 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99965

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vlse.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vse.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsoxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsse.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsuxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vle.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlse.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vse.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsoxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsse.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vsuxei.c

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


[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

2021-04-06 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

@Charusso 
It looks like this patch introduced a some weird false positive on PostgreSQL 
F16161734: report-guc.c-ParseLongOption-13-1.html 

I'll try to look at it myself and minimize it, but maybe you can get an idea 
from a full report.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69726

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


[PATCH] D99005: [clang] Implement P2266 Simpler implicit move

2021-04-06 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 335542.
mizvekov added a comment.

- Rebased on top of D99696 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99005

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-cxx14.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-cxx14.cpp
  clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constant-expression-cxx14.cpp
  clang/test/SemaCXX/coroutine-rvo.cpp
  clang/test/SemaCXX/coroutines.cpp
  clang/test/SemaCXX/deduced-return-type-cxx14.cpp
  clang/test/SemaCXX/return-stack-addr.cpp
  clang/test/SemaCXX/warn-return-std-move.cpp

Index: clang/test/SemaCXX/warn-return-std-move.cpp
===
--- clang/test/SemaCXX/warn-return-std-move.cpp
+++ clang/test/SemaCXX/warn-return-std-move.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=cxx20_2b -fcxx-exceptions -Wreturn-std-move %s
-// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=cxx20_2b -fcxx-exceptions -Wreturn-std-move %s
-// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
-// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=cxx11_17 -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=cxx20_2b,cxx2b -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=cxx20_2b   -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=cxx11_17   -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify=cxx11_17   -fcxx-exceptions -Wreturn-std-move %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=cxx11_17   -fcxx-exceptions -Wreturn-std-move %s
 
 // RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
 // RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s -check-prefix=CHECK
@@ -217,8 +217,8 @@
 }
 
 // But if the return type is a reference type, then moving would be wrong.
-Derived& testRetRef1(Derived&& d) { return d; }
-Base& testRetRef2(Derived&& d) { return d; }
+Derived &testRetRef1(Derived &&d) { return d; } // cxx2b-error {{on-const lvalue reference to type 'Derived' cannot bind to a temporary of type 'Derived'}}
+Base &testRetRef2(Derived &&d) { return d; }// cxx2b-error {{non-const lvalue reference to type 'Base' cannot bind to a temporary of type 'Derived'}}
 #if __cplusplus >= 201402L
 auto&& testRetRef3(Derived&& d) { return d; }
 decltype(auto) testRetRef4(Derived&& d) { return (d); }
Index: clang/test/SemaCXX/return-stack-addr.cpp
===
--- clang/test/SemaCXX/return-stack-addr.cpp
+++ clang/test/SemaCXX/return-stack-addr.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=expected   %s
-// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected   %s
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=expected,cxx11 %s
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=expected,cxx2b  %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,cxx11_20   %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=expected,cxx11_20,cxx11 %s
 
 int* ret_local() {
   int x = 1;
@@ -29,7 +29,8 @@
 
 int& ret_local_ref() {
   int x = 1;
-  return x;  // expected-warning {{reference to stack memory}}
+  return x; // cxx11_20-warning {{reference to stack memory}}
+  // cxx2b-error@-1 {{non-const lvalue reference to type 'int' cannot bind to a temporary of type 'int'}}
 }
 
 int* ret_local_addrOf() {
@@ -154,8 +155,10 @@
   (void) [&]() -> int& { return b; };
   (void) [=]() mutable -> int& { return a; };
   (void) [=]() mutable -> int& { return b; };
-  (void) [&]() -> int& { int a; return a; }; // expected-warning {{reference to stack}}
-  (void) [=]() -> int& { int a; return a; }; // expected-warning {{reference to stack}}
+  (void) [&]() -> int& { int a; return a; }; // cxx11_20-warning {{reference to stack}}
+  // cxx2b-error@-1 {{non-const lvalue reference to type 'int' cannot bind to a temporary of type 'int'}}
+  (void) [=]() -> int& { int a; return a; }; // cxx11_20-warning {{reference to stack}}
+  // cxx2b-error@-1 {{non-const lvalue reference to type 'int' cannot bind to a temporary of type 'int'}}
   (void) [&]() -> int& { i

[PATCH] D99934: [clang][Syntax] Handle invalid source range in expandedTokens.

2021-04-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

(Do we have a bug this fixes?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99934

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


[clang] 93c87fc - [index] Improve macro indexing support

2021-04-06 Thread Ben Langmuir via cfe-commits

Author: Ben Langmuir
Date: 2021-04-06T09:12:14-07:00
New Revision: 93c87fc06eca8d8a65ff6c0bdd9f2671227224ac

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

LOG: [index] Improve macro indexing support

The major change here is to index macro occurrences in more places than
before, specifically

* In non-expansion references such as `#if`, `#ifdef`, etc.
* When the macro is a reference to a builtin macro such as __LINE__.
* When using the preprocessor state instead of callbacks, we now include
  all definition locations and undefinitions instead of just the latest
  one (which may also have had the wrong location previously).
* When indexing an existing module file (.pcm), we now include module
  macros, and we no longer report unrelated preprocessor macros during
  indexing the module, which could have caused duplication.

Additionally, we now correctly obey the system symbol filter for macros,
so by default in system headers only definition/undefinition occurrences
are reported, but it can be configured to report references as well if
desired.

Extends FileIndexRecord to support occurrences of macros. Since the
design of this type is to keep a single list of entities organized by
source location, we incorporate macros into the existing DeclOccurrence
struct.

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

Added: 


Modified: 
clang/include/clang/Index/DeclOccurrence.h
clang/include/clang/Index/IndexingOptions.h
clang/lib/Index/FileIndexRecord.cpp
clang/lib/Index/FileIndexRecord.h
clang/lib/Index/IndexingAction.cpp
clang/lib/Index/IndexingContext.cpp
clang/lib/Index/IndexingContext.h
clang/lib/Index/USRGeneration.cpp
clang/test/Index/Core/Inputs/module/ModA.h
clang/test/Index/Core/Inputs/module/SubModA.h
clang/test/Index/Core/Inputs/sys/system-head.h
clang/test/Index/Core/index-macros.c
clang/test/Index/Core/index-with-module.m
clang/tools/c-index-test/core_main.cpp
clang/unittests/Index/IndexTests.cpp

Removed: 




diff  --git a/clang/include/clang/Index/DeclOccurrence.h 
b/clang/include/clang/Index/DeclOccurrence.h
index 16f03a84579e..72f5799466bd 100644
--- a/clang/include/clang/Index/DeclOccurrence.h
+++ b/clang/include/clang/Index/DeclOccurrence.h
@@ -9,26 +9,31 @@
 #ifndef LLVM_CLANG_INDEX_DECLOCCURRENCE_H
 #define LLVM_CLANG_INDEX_DECLOCCURRENCE_H
 
+#include "clang/AST/DeclBase.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Index/IndexSymbol.h"
+#include "clang/Lex/MacroInfo.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/SmallVector.h"
 
 namespace clang {
-class Decl;
-
 namespace index {
 
 struct DeclOccurrence {
   SymbolRoleSet Roles;
   unsigned Offset;
-  const Decl *Dcl;
+  llvm::PointerUnion DeclOrMacro;
+  const IdentifierInfo *MacroName = nullptr;
   SmallVector Relations;
 
   DeclOccurrence(SymbolRoleSet R, unsigned Offset, const Decl *D,
  ArrayRef Relations)
-  : Roles(R), Offset(Offset), Dcl(D),
+  : Roles(R), Offset(Offset), DeclOrMacro(D),
 Relations(Relations.begin(), Relations.end()) {}
+  DeclOccurrence(SymbolRoleSet R, unsigned Offset, const IdentifierInfo *Name,
+ const MacroInfo *MI)
+  : Roles(R), Offset(Offset), DeclOrMacro(MI), MacroName(Name) {}
 
   friend bool operator<(const DeclOccurrence &LHS, const DeclOccurrence &RHS) {
 return LHS.Offset < RHS.Offset;

diff  --git a/clang/include/clang/Index/IndexingOptions.h 
b/clang/include/clang/Index/IndexingOptions.h
index 9f5c03d1b3b9..d19653848d59 100644
--- a/clang/include/clang/Index/IndexingOptions.h
+++ b/clang/include/clang/Index/IndexingOptions.h
@@ -28,6 +28,7 @@ struct IndexingOptions {
   SystemSymbolFilterKind::DeclarationsOnly;
   bool IndexFunctionLocals = false;
   bool IndexImplicitInstantiation = false;
+  bool IndexMacros = true;
   // Whether to index macro definitions in the Preprocesor when preprocessor
   // callback is not available (e.g. after parsing has finished). Note that
   // macro references are not available in Proprocessor.

diff  --git a/clang/lib/Index/FileIndexRecord.cpp 
b/clang/lib/Index/FileIndexRecord.cpp
index df18a9aed8b7..950a99a2304b 100644
--- a/clang/lib/Index/FileIndexRecord.cpp
+++ b/clang/lib/Index/FileIndexRecord.cpp
@@ -17,42 +17,68 @@
 using namespace clang;
 using namespace clang::index;
 
-void FileIndexRecord::addDeclOccurence(SymbolRoleSet Roles, unsigned Offset,
-   const Decl *D,
-   ArrayRef Relations) {
-  assert(D->isCanonicalDecl() &&
- "Occurrences should be associated with their canonical decl");
-
+static void addOccurrence(std::vector &Decls,
+  DeclOccurren

[PATCH] D99758: [index] Improve macro indexing support

2021-04-06 Thread Ben Langmuir via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG93c87fc06eca: [index] Improve macro indexing support 
(authored by benlangmuir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99758

Files:
  clang/include/clang/Index/DeclOccurrence.h
  clang/include/clang/Index/IndexingOptions.h
  clang/lib/Index/FileIndexRecord.cpp
  clang/lib/Index/FileIndexRecord.h
  clang/lib/Index/IndexingAction.cpp
  clang/lib/Index/IndexingContext.cpp
  clang/lib/Index/IndexingContext.h
  clang/lib/Index/USRGeneration.cpp
  clang/test/Index/Core/Inputs/module/ModA.h
  clang/test/Index/Core/Inputs/module/SubModA.h
  clang/test/Index/Core/Inputs/sys/system-head.h
  clang/test/Index/Core/index-macros.c
  clang/test/Index/Core/index-with-module.m
  clang/tools/c-index-test/core_main.cpp
  clang/unittests/Index/IndexTests.cpp

Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -161,12 +161,41 @@
 }
 
 TEST(IndexTest, IndexPreprocessorMacros) {
-  std::string Code = "#define INDEX_MAC 1";
+  std::string Code = R"cpp(
+#define INDEX_MAC 1
+#define INDEX_MAC_UNDEF 1
+#undef INDEX_MAC_UNDEF
+#define INDEX_MAC_REDEF 1
+#undef INDEX_MAC_REDEF
+#define INDEX_MAC_REDEF 2
+  )cpp";
   auto Index = std::make_shared();
   IndexingOptions Opts;
   Opts.IndexMacrosInPreprocessor = true;
   tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
-  EXPECT_THAT(Index->Symbols, Contains(QName("INDEX_MAC")));
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("INDEX_MAC"), WrittenAt(Position(2, 13)),
+ DeclAt(Position(2, 13)),
+ HasRole(SymbolRole::Definition;
+  EXPECT_THAT(
+  Index->Symbols,
+  AllOf(Contains(AllOf(QName("INDEX_MAC_UNDEF"), WrittenAt(Position(3, 13)),
+   DeclAt(Position(3, 13)),
+   HasRole(SymbolRole::Definition))),
+Contains(AllOf(QName("INDEX_MAC_UNDEF"), WrittenAt(Position(4, 12)),
+   DeclAt(Position(3, 13)),
+   HasRole(SymbolRole::Undefinition);
+  EXPECT_THAT(
+  Index->Symbols,
+  AllOf(Contains(AllOf(QName("INDEX_MAC_REDEF"), WrittenAt(Position(5, 13)),
+   DeclAt(Position(5, 13)),
+   HasRole(SymbolRole::Definition))),
+Contains(AllOf(QName("INDEX_MAC_REDEF"), WrittenAt(Position(6, 12)),
+   DeclAt(Position(5, 13)),
+   HasRole(SymbolRole::Undefinition))),
+Contains(AllOf(QName("INDEX_MAC_REDEF"), WrittenAt(Position(7, 13)),
+   DeclAt(Position(7, 13)),
+   HasRole(SymbolRole::Definition);
 
   Opts.IndexMacrosInPreprocessor = false;
   Index->Symbols.clear();
Index: clang/tools/c-index-test/core_main.cpp
===
--- clang/tools/c-index-test/core_main.cpp
+++ clang/tools/c-index-test/core_main.cpp
@@ -63,6 +63,9 @@
 static cl::opt
 IncludeLocals("include-locals", cl::desc("Print local symbols"));
 
+static cl::opt IgnoreMacros("ignore-macros",
+  cl::desc("Skip indexing macros"));
+
 static cl::opt
 ModuleFilePath("module-file",
cl::desc("Path to module file to print symbols from"));
@@ -210,7 +213,8 @@
 
 static bool printSourceSymbols(const char *Executable,
ArrayRef Args,
-   bool dumpModuleImports, bool indexLocals) {
+   bool dumpModuleImports, bool indexLocals,
+   bool ignoreMacros) {
   SmallVector ArgsWithProgName;
   ArgsWithProgName.push_back(Executable);
   ArgsWithProgName.append(Args.begin(), Args.end());
@@ -224,6 +228,8 @@
   auto DataConsumer = std::make_shared(OS);
   IndexingOptions IndexOpts;
   IndexOpts.IndexFunctionLocals = indexLocals;
+  IndexOpts.IndexMacros = !ignoreMacros;
+  IndexOpts.IndexMacrosInPreprocessor = !ignoreMacros;
   std::unique_ptr IndexAction =
   createIndexingAction(DataConsumer, IndexOpts);
 
@@ -357,7 +363,7 @@
 }
 return printSourceSymbols(Executable.c_str(), CompArgs,
   options::DumpModuleImports,
-  options::IncludeLocals);
+  options::IncludeLocals, options::IgnoreMacros);
   }
 
   return 0;
Index: clang/test/Index/Core/index-with-module.m
===
--- clang/test/Index/Core/index-with-module.m
+++ clang/test/Index/Core/index-with-module.m
@@ -18,7 +18,10 @@
 }
 
 // CHECK:  Module ModA 
-// CHECK: 2:6 | function/C | ModA_

[PATCH] D99659: [analyzer][taint] Extent of heap regions should get taint sometimes

2021-04-06 Thread Balázs Benics via Phabricator via cfe-commits
steakhal abandoned this revision.
steakhal added a comment.

Obsoleted by D69726 .

This effort continues as the NFC D99959  patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99659

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


[PATCH] D98747: Thread safety analysis: Don't warn about managed locks on join points

2021-04-06 Thread Delesley Hutchins via Phabricator via cfe-commits
delesley accepted this revision.
delesley added a comment.
This revision is now accepted and ready to land.

I am convinced by your argument.  I think it is reasonable to assume that if 
someone is using an RAII object, then the underlying object is responsible for 
managing double locks/unlocks, and we can restrict our efforts to detecting 
race conditions.  Thanks for the detailed explanation!  :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98747

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


[clang] 04b3c8c - Pass -fcrash-diagnostics-dir along to LLVM

2021-04-06 Thread Paul Robinson via cfe-commits

Author: Paul Robinson
Date: 2021-04-06T09:30:52-07:00
New Revision: 04b3c8c52c549ee57e69a1b23484b8c4109f83b8

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

LOG: Pass -fcrash-diagnostics-dir along to LLVM

This allows frontend and backend diagnostic files to all go into the
same place.  Have it control the Windows (mini-)dump location.

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

Added: 
clang/test/Driver/crash-diagnostics-dir-2.c

Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
llvm/lib/Support/Signals.cpp
llvm/lib/Support/Windows/Signals.inc

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index aaf6f83a0cfa5..22f4ad15ac370 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5156,6 +5156,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   if (D.CCGenDiagnostics)
 CmdArgs.push_back("-disable-pragma-debug-crash");
 
+  // Allow backend to put its diagnostic files in the same place as frontend
+  // crash diagnostics files.
+  if (Args.hasArg(options::OPT_fcrash_diagnostics_dir)) {
+StringRef Dir = Args.getLastArgValue(options::OPT_fcrash_diagnostics_dir);
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back(Args.MakeArgString("-crash-diagnostics-dir=" + Dir));
+  }
+
   bool UseSeparateSections = isUseSeparateSections(Triple);
 
   if (Args.hasFlag(options::OPT_ffunction_sections,

diff  --git a/clang/test/Driver/crash-diagnostics-dir-2.c 
b/clang/test/Driver/crash-diagnostics-dir-2.c
new file mode 100644
index 0..432a8893f8786
--- /dev/null
+++ b/clang/test/Driver/crash-diagnostics-dir-2.c
@@ -0,0 +1,5 @@
+// RUN: %clang -### -fcrash-diagnostics-dir=mydumps -c %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=OPTION
+// OPTION: "-crash-diagnostics-dir=mydumps"
+// RUN: %clang -### -c %s 2>&1 | FileCheck %s --check-prefix=NOOPTION
+// NOOPTION-NOT: "-crash-diagnostics-dir

diff  --git a/llvm/lib/Support/Signals.cpp b/llvm/lib/Support/Signals.cpp
index 29be4df959543..5aa1a9efcf595 100644
--- a/llvm/lib/Support/Signals.cpp
+++ b/llvm/lib/Support/Signals.cpp
@@ -43,6 +43,11 @@ static cl::opt
 DisableSymbolication("disable-symbolication",
  cl::desc("Disable symbolizing crash backtraces."),
  cl::location(DisableSymbolicationFlag), cl::Hidden);
+static std::string CrashDiagnosticsDirectory;
+static cl::opt
+CrashDiagnosticsDir("crash-diagnostics-dir", cl::value_desc("directory"),
+cl::desc("Directory for crash diagnostic files."),
+cl::location(CrashDiagnosticsDirectory), cl::Hidden);
 
 constexpr char DisableSymbolizationEnv[] = "LLVM_DISABLE_SYMBOLIZATION";
 constexpr char LLVMSymbolizerPathEnv[] = "LLVM_SYMBOLIZER_PATH";

diff  --git a/llvm/lib/Support/Windows/Signals.inc 
b/llvm/lib/Support/Windows/Signals.inc
index 3758582b35f76..df5fcb1b151bc 100644
--- a/llvm/lib/Support/Windows/Signals.inc
+++ b/llvm/lib/Support/Windows/Signals.inc
@@ -766,16 +766,18 @@ WriteWindowsDumpFile(PMINIDUMP_EXCEPTION_INFORMATION 
ExceptionInfo) {
 if (!GetDumpType(DefaultLocalDumpsKey, DumpType))
   DumpType = MiniDumpNormal;
 
-  // Look to see if a dump location is specified in the registry; first with 
the
+  // Look to see if a dump location is specified on the command line.  If not,
+  // look to see if a dump location is specified in the registry; first with 
the
   // app-specific key and failing that with the global key.  If none are found
   // we'll just create the dump file in the default temporary file location
   // (GetDumpFolder will return false either if the key is NULL or if there is
   // no valid DumpFolder value at its location).
   bool ExplicitDumpDirectorySet = true;
-  SmallString DumpDirectory;
-  if (!GetDumpFolder(AppSpecificKey, DumpDirectory))
-if (!GetDumpFolder(DefaultLocalDumpsKey, DumpDirectory))
-  ExplicitDumpDirectorySet = false;
+  SmallString DumpDirectory(CrashDiagnosticsDirectory);
+  if (DumpDirectory.empty())
+if (!GetDumpFolder(AppSpecificKey, DumpDirectory))
+  if (!GetDumpFolder(DefaultLocalDumpsKey, DumpDirectory))
+ExplicitDumpDirectorySet = false;
 
   int FD;
   SmallString DumpPath;



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


[PATCH] D99199: Make -fcrash-diagnostics-dir control the Windows (mini-)dump location

2021-04-06 Thread Paul Robinson 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 rG04b3c8c52c54: Pass -fcrash-diagnostics-dir along to LLVM 
(authored by probinson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99199

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/crash-diagnostics-dir-2.c
  llvm/lib/Support/Signals.cpp
  llvm/lib/Support/Windows/Signals.inc


Index: llvm/lib/Support/Windows/Signals.inc
===
--- llvm/lib/Support/Windows/Signals.inc
+++ llvm/lib/Support/Windows/Signals.inc
@@ -766,16 +766,18 @@
 if (!GetDumpType(DefaultLocalDumpsKey, DumpType))
   DumpType = MiniDumpNormal;
 
-  // Look to see if a dump location is specified in the registry; first with 
the
+  // Look to see if a dump location is specified on the command line.  If not,
+  // look to see if a dump location is specified in the registry; first with 
the
   // app-specific key and failing that with the global key.  If none are found
   // we'll just create the dump file in the default temporary file location
   // (GetDumpFolder will return false either if the key is NULL or if there is
   // no valid DumpFolder value at its location).
   bool ExplicitDumpDirectorySet = true;
-  SmallString DumpDirectory;
-  if (!GetDumpFolder(AppSpecificKey, DumpDirectory))
-if (!GetDumpFolder(DefaultLocalDumpsKey, DumpDirectory))
-  ExplicitDumpDirectorySet = false;
+  SmallString DumpDirectory(CrashDiagnosticsDirectory);
+  if (DumpDirectory.empty())
+if (!GetDumpFolder(AppSpecificKey, DumpDirectory))
+  if (!GetDumpFolder(DefaultLocalDumpsKey, DumpDirectory))
+ExplicitDumpDirectorySet = false;
 
   int FD;
   SmallString DumpPath;
Index: llvm/lib/Support/Signals.cpp
===
--- llvm/lib/Support/Signals.cpp
+++ llvm/lib/Support/Signals.cpp
@@ -43,6 +43,11 @@
 DisableSymbolication("disable-symbolication",
  cl::desc("Disable symbolizing crash backtraces."),
  cl::location(DisableSymbolicationFlag), cl::Hidden);
+static std::string CrashDiagnosticsDirectory;
+static cl::opt
+CrashDiagnosticsDir("crash-diagnostics-dir", cl::value_desc("directory"),
+cl::desc("Directory for crash diagnostic files."),
+cl::location(CrashDiagnosticsDirectory), cl::Hidden);
 
 constexpr char DisableSymbolizationEnv[] = "LLVM_DISABLE_SYMBOLIZATION";
 constexpr char LLVMSymbolizerPathEnv[] = "LLVM_SYMBOLIZER_PATH";
Index: clang/test/Driver/crash-diagnostics-dir-2.c
===
--- /dev/null
+++ clang/test/Driver/crash-diagnostics-dir-2.c
@@ -0,0 +1,5 @@
+// RUN: %clang -### -fcrash-diagnostics-dir=mydumps -c %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=OPTION
+// OPTION: "-crash-diagnostics-dir=mydumps"
+// RUN: %clang -### -c %s 2>&1 | FileCheck %s --check-prefix=NOOPTION
+// NOOPTION-NOT: "-crash-diagnostics-dir
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5156,6 +5156,14 @@
   if (D.CCGenDiagnostics)
 CmdArgs.push_back("-disable-pragma-debug-crash");
 
+  // Allow backend to put its diagnostic files in the same place as frontend
+  // crash diagnostics files.
+  if (Args.hasArg(options::OPT_fcrash_diagnostics_dir)) {
+StringRef Dir = Args.getLastArgValue(options::OPT_fcrash_diagnostics_dir);
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back(Args.MakeArgString("-crash-diagnostics-dir=" + Dir));
+  }
+
   bool UseSeparateSections = isUseSeparateSections(Triple);
 
   if (Args.hasFlag(options::OPT_ffunction_sections,


Index: llvm/lib/Support/Windows/Signals.inc
===
--- llvm/lib/Support/Windows/Signals.inc
+++ llvm/lib/Support/Windows/Signals.inc
@@ -766,16 +766,18 @@
 if (!GetDumpType(DefaultLocalDumpsKey, DumpType))
   DumpType = MiniDumpNormal;
 
-  // Look to see if a dump location is specified in the registry; first with the
+  // Look to see if a dump location is specified on the command line.  If not,
+  // look to see if a dump location is specified in the registry; first with the
   // app-specific key and failing that with the global key.  If none are found
   // we'll just create the dump file in the default temporary file location
   // (GetDumpFolder will return false either if the key is NULL or if there is
   // no valid DumpFolder value at its location).
   bool ExplicitDumpDirectorySet = true;
-  SmallString DumpDirectory;
-  if (!GetDumpFolder(AppSpecificKey, DumpDirectory))
-if (!GetDumpFolder(DefaultLocalDumpsKey, Dump

[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

2021-04-06 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D69726#2671526 , @vsavchenko wrote:

> @Charusso 
> It looks like this patch introduced a some weird false positive on PostgreSQL 
> F16161734: report-guc.c-ParseLongOption-13-1.html 
> 
> I'll try to look at it myself and minimize it, but maybe you can get an idea 
> from a full report.

Could you supply us with all the divergence please? If there is only one case, 
may we can ignore it by appending it to @NoQ's `extremely-weird-bugs.txt` so 
people can focus on more important stuff.

What I see in the bug report is that: `line 3290 - guc_malloc()` returns null 
and it is a true positive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69726

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


[PATCH] D99969: [OpenCL] Accept .rgba in OpenCL 3.0

2021-04-06 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added reviewers: Anastasia, azabaznov.
svenvh added a project: clang.
Herald added subscribers: ldrumm, yaxunl.
svenvh requested review of this revision.
Herald added a subscriber: cfe-commits.

The .rgba vector component accessors are supported in OpenCL C 3.0.

Previously, the diagnostic would check `OpenCLVersion` for version 2.2
(value 220) and report those accessors are an OpenCL 2.2 feature.
However, there is no "OpenCL C version 2.2", so change the check and
diagnostic text to 3.0 only.

A spurious `OpenCLVersion` argument was passed into the diagnostic;
remove that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99969

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExprMember.cpp
  clang/test/SemaOpenCL/ext_vectors.cl


Index: clang/test/SemaOpenCL/ext_vectors.cl
===
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -1,11 +1,20 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
 void test_ext_vector_accessors(float4 V) {
   V = V.wzyx;
-  V = V.abgr; // expected-warning {{vector component name 'a' is an OpenCL 
version 2.2 feature}}
-  V = V.xyzr; // expected-warning {{vector component name 'r' is an OpenCL 
version 2.2 feature}} \
-  // expected-error {{illegal vector component name 'r'}}
+
+  V = V.abgr;
+#if (__OPENCL_C_VERSION__ < 300)
+  // expected-warning@-2 {{vector component name 'a' is an OpenCL C version 
3.0 feature}}
+#endif
+
+  V = V.xyzr;
+  // expected-error@-1 {{illegal vector component name 'r'}}
+#if (__OPENCL_C_VERSION__ < 300)
+  // expected-warning@-3 {{vector component name 'r' is an OpenCL C version 
3.0 feature}}
+#endif
 }
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -338,13 +338,12 @@
   compStr++;
 } while (*compStr && (Idx = vecType->getPointAccessorIdx(*compStr)) != -1);
 
-// Emit a warning if an rgba selector is used earlier than OpenCL 2.2
+// Emit a warning if an rgba selector is used earlier than OpenCL C 3.0.
 if (HasRGBA || (*compStr && IsRGBA(*compStr))) {
-  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion < 220) {
+  if (S.getLangOpts().OpenCLVersion < 300) {
 const char *DiagBegin = HasRGBA ? CompName->getNameStart() : compStr;
 S.Diag(OpLoc, diag::ext_opencl_ext_vector_type_rgba_selector)
-  << StringRef(DiagBegin, 1)
-  << S.getLangOpts().OpenCLVersion << SourceRange(CompLoc);
+  << StringRef(DiagBegin, 1) << SourceRange(CompLoc);
   }
 }
   } else {
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9996,9 +9996,9 @@
 def err_opencl_builtin_expected_type : Error<
   "illegal call to %0, expected %1 argument type">;
 
-// OpenCL v2.2 s2.1.2.3 - Vector Component Access
+// OpenCL v3.0 s6.3.7 - Vector Components
 def ext_opencl_ext_vector_type_rgba_selector: ExtWarn<
-  "vector component name '%0' is an OpenCL version 2.2 feature">,
+  "vector component name '%0' is an OpenCL C version 3.0 feature">,
   InGroup;
 
 def err_openclcxx_placement_new : Error<


Index: clang/test/SemaOpenCL/ext_vectors.cl
===
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -1,11 +1,20 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
 void test_ext_vector_accessors(float4 V) {
   V = V.wzyx;
-  V = V.abgr; // expected-warning {{vector component name 'a' is an OpenCL version 2.2 feature}}
-  V = V.xyzr; // expected-warning {{vector component name 'r' is an OpenCL version 2.2 feature}} \
-  // expected-error {{illegal vector component name 'r'}}
+
+  V = V.abgr;
+#if (__OPENCL_C_VERSION__ < 300)
+  // expected-warning@-2 {{vector component name 'a' is an OpenCL C version 3.0 feature}}
+#endif
+
+  V = V.xyzr;
+  // expected-error@-1 {{illegal vector component name 'r'}}
+#if (__OPENCL_C_VERSION__ < 300)
+  // expected-warning@-3 {{vector component name 'r' is an OpenCL C version 3.0 feature}}
+#endif
 }
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/Sem

[PATCH] D99630: phase 01: add new command line flag to enable UAR in 3 modes (always, [runtime], never).

2021-04-06 Thread Kevin Athey via Phabricator via cfe-commits
kda updated this revision to Diff 335558.
kda added a comment.

fixed tests for asan_interface.inc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99630

Files:
  clang/docs/AddressSanitizer.rst
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/Sanitizers.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Basic/Sanitizers.cpp
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  compiler-rt/lib/asan/asan_fake_stack.cpp
  compiler-rt/lib/asan/asan_interface.inc
  compiler-rt/test/asan/TestCases/Posix/stack-use-after-return.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -29,6 +29,7 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/BinaryFormat/MachO.h"
+#include "llvm/CodeGen/CodeGenPassBuilder.h"
 #include "llvm/IR/Argument.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/BasicBlock.h"
@@ -72,6 +73,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizerCommon.h"
+#include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
 #include "llvm/Transforms/Utils/ASanStackFrameLayout.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 #include "llvm/Transforms/Utils/Local.h"
@@ -152,6 +154,8 @@
 const char kAsanHandleNoReturnName[] = "__asan_handle_no_return";
 static const int kMaxAsanStackMallocSizeClass = 10;
 const char kAsanStackMallocNameTemplate[] = "__asan_stack_malloc_";
+const char kAsanStackFlaglessMallocNameTemplate[] =
+"__asan_stack_flagless_malloc_";
 const char kAsanStackFreeNameTemplate[] = "__asan_stack_free_";
 const char kAsanGenPrefix[] = "___asan_gen_";
 const char kODRGenPrefix[] = "__odr_asan_gen_";
@@ -597,13 +601,17 @@
 
 /// AddressSanitizer: instrument the code in module to find memory bugs.
 struct AddressSanitizer {
-  AddressSanitizer(Module &M, const GlobalsMetadata *GlobalsMD,
-   bool CompileKernel = false, bool Recover = false,
-   bool UseAfterScope = false)
+  AddressSanitizer(
+  Module &M, const GlobalsMetadata *GlobalsMD, bool CompileKernel = false,
+  bool Recover = false, bool UseAfterScope = false,
+  llvm::AsanDetectStackUseAfterReturnMode DetectStackUseAfterReturnMode =
+  llvm::AsanDetectStackUseAfterReturnMode::Never)
   : CompileKernel(ClEnableKasan.getNumOccurrences() > 0 ? ClEnableKasan
 : CompileKernel),
 Recover(ClRecover.getNumOccurrences() > 0 ? ClRecover : Recover),
-UseAfterScope(UseAfterScope || ClUseAfterScope), GlobalsMD(*GlobalsMD) {
+UseAfterScope(UseAfterScope || ClUseAfterScope),
+DetectStackUseAfterReturnMode(DetectStackUseAfterReturnMode),
+GlobalsMD(*GlobalsMD) {
 C = &(M.getContext());
 LongSize = M.getDataLayout().getPointerSizeInBits();
 IntptrTy = Type::getIntNTy(*C, LongSize);
@@ -689,6 +697,7 @@
   bool CompileKernel;
   bool Recover;
   bool UseAfterScope;
+  llvm::AsanDetectStackUseAfterReturnMode DetectStackUseAfterReturnMode;
   Type *IntptrTy;
   ShadowMapping Mapping;
   FunctionCallee AsanHandleNoReturnFunc;
@@ -713,11 +722,14 @@
 public:
   static char ID;
 
-  explicit AddressSanitizerLegacyPass(bool CompileKernel = false,
-  bool Recover = false,
-  bool UseAfterScope = false)
+  explicit AddressSanitizerLegacyPass(
+  bool CompileKernel = false, bool Recover = false,
+  bool UseAfterScope = false,
+  llvm::AsanDetectStackUseAfterReturnMode DetectStackUseAfterReturnMode =
+  llvm::AsanDetectStackUseAfterReturnMode::Never)
   : FunctionPass(ID), CompileKernel(CompileKernel), Recover(Recover),
-UseAfterScope(UseAfterScope) {
+UseAfterScope(UseAfterScope),
+DetectStackUseAfterReturnMode(DetectStackUseAfterReturnMode) {
 initializeAddressSanitizerLegacyPassPass(*PassRegistry::getPassRegistry());
   }
 
@@ -736,7 +748,7 @@
 const TargetLibraryInfo *TLI =
 &getAnalysis().getTLI(F);
 AddressSanitizer ASan(*F.getParent(), &GlobalsMD, CompileKernel, Recover,
-  UseAfterScope);
+  UseAfterScope, DetectStackUseAfterReturnMode);
 return ASan.instrumentFunction(F, TLI);
   }
 
@@ -744,6 +756,7 @@
   b

[PATCH] D99158: [RISCV][WIP] Implement intrinsics for P extension

2021-04-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:17944
+
+  // P extension
+#define EMIT_BUILTIN(NAME, INT) \

Please put this above the vector extension since the comment says "vector 
builtins are handled from here"



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:18201
+  BUILTIN_AAAB_WITH_V(kmmawt2_u)
   }
 

Please undef the macros when you're done with them.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:17944
+
+  // P extension
+#define EMIT_BUILTIN(NAME, INT) \

Jim wrote:
> I have concern here. It has lots of duplicate code if the code style is the 
> same as B in the top.
> And the name of macro is not good.
Each assignment to IntrinsicTypes invokes the SmallVector constructor so each 
one generates a call in the final binary unless the compiler does a good job of 
merging them.



Comment at: llvm/include/llvm/IR/IntrinsicsRISCV.td:1254
+
+multiclass RISCVUnary {
+  def "int_riscv_" # NAME   : RISCVUnaryScalar;

I haven't followed the P extension closely. Why do we need 2 kinds of 
intrinsics for most instructions?



Comment at: llvm/include/llvm/IR/IntrinsicsRISCV.td:1254
+
+multiclass RISCVUnary {
+  def "int_riscv_" # NAME   : RISCVUnaryScalar;

craig.topper wrote:
> I haven't followed the P extension closely. Why do we need 2 kinds of 
> intrinsics for most instructions?
RISCVUnary is a generic name, but the scalar and vector intrinsic inside make 
it P extension specific.



Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:762
+  for (unsigned Opc = 0; Opc < ISD::BUILTIN_OP_END; ++Opc)
+setOperationAction(Opc, VT, Expand);
+

You probably need handling for insert_vector_elt and extract_vector_elt or some 
of the expansions will probably break.


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

https://reviews.llvm.org/D99158

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


[PATCH] D99194: [analyzer] Fix body farm for Obj-C++ properties

2021-04-06 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/Analysis/BodyFarm.cpp:757
+  if (PI->getPropertyDecl()) {
+Prop = PI->getPropertyDecl();
+if (Prop->getGetterName() == MD->getSelector())

At this point `Prop` may contain a completely unrelated property decl. It 
doesn't necessarily correspond to the `IVar` or have the right name. We keep it 
after the end of the loop and use it later. This doesn't sound right.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99194

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


[PATCH] D99645: [flang][driver] Add debug options not requiring semantic checks

2021-04-06 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski updated this revision to Diff 335566.
awarzynski added a comment.

Update `f18.cpp` and  driver-help.f90 to improve testing

- added -fdebug-unparse-no-sema and -fdebug-dump-parse-tree-no-sema in f18.cpp 
(for compatibility with flang-new)
- updated driver-help.f90 with the new options


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99645

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Driver/driver-help.f90
  flang/test/Parser/omp-allocate-unparse.f90
  flang/test/Parser/omp-atomic-unparse.f90
  flang/tools/f18/f18.cpp

Index: flang/tools/f18/f18.cpp
===
--- flang/tools/f18/f18.cpp
+++ flang/tools/f18/f18.cpp
@@ -564,6 +564,13 @@
   options.instrumentedParse = true;
 } else if (arg == "-fdebug-no-semantics") {
   driver.debugNoSemantics = true;
+} else if (arg == "-fdebug-unparse-no-sema") {
+  driver.debugNoSemantics = true;
+  driver.dumpUnparse = true;
+} else if (arg == "-fdebug-dump-parse-tree-no-sema") {
+  driver.debugNoSemantics = true;
+  driver.dumpParseTree = true;
+  driver.syntaxOnly = true;
 } else if (arg == "-funparse" || arg == "-fdebug-unparse") {
   driver.dumpUnparse = true;
 } else if (arg == "-funparse-with-symbols" ||
Index: flang/test/Parser/omp-atomic-unparse.f90
===
--- flang/test/Parser/omp-atomic-unparse.f90
+++ flang/test/Parser/omp-atomic-unparse.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -fdebug-no-semantics -funparse -fopenmp %s | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse-no-sema -fopenmp %s | FileCheck %s
 
 program main
implicit none
Index: flang/test/Parser/omp-allocate-unparse.f90
===
--- flang/test/Parser/omp-allocate-unparse.f90
+++ flang/test/Parser/omp-allocate-unparse.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -fdebug-no-semantics -funparse -fopenmp %s | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse-no-sema -fopenmp %s | FileCheck %s
 ! Check Unparsing of OpenMP Allocate directive
 
 program allocate_unparse
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -66,6 +66,8 @@
 ! HELP-FC1-NEXT: -falternative-parameter-statement
 ! HELP-FC1-NEXT: Enable the old style PARAMETER statement
 ! HELP-FC1-NEXT: -fbackslashSpecify that backslash in string introduces an escape character
+! HELP-FC1-NEXT: -fdebug-dump-parse-tree-no-sema
+! HELP-FC1-NEXT:Dump the parse tree (skips the semantic checks)
 ! HELP-FC1-NEXT: -fdebug-dump-parse-tree Dump the parse tree
 ! HELP-FC1-NEXT: -fdebug-dump-parsing-log
 ! HELP-FC1-NEXT:   Run instrumented parse and dump the parsing log
@@ -75,6 +77,7 @@
 ! HELP-FC1-NEXT: Measure the parse tree
 ! HELP-FC1-NEXT: -fdebug-module-writer   Enable debug messages while writing module files
 ! HELP-FC1-NEXT: -fdebug-pre-fir-treeDump the pre-FIR tree
+! HELP-FC1-NEXT: -fdebug-unparse-no-sema Unparse and stop (skips the semantic checks)
 ! HELP-FC1-NEXT: -fdebug-unparse-with-symbols
 ! HELP-FC1-NEXT:Unparse and stop.
 ! HELP-FC1-NEXT: -fdebug-unparseUnparse and stop.
Index: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -40,6 +40,9 @@
   case DebugUnparse:
 return std::make_unique();
 break;
+  case DebugUnparseNoSema:
+return std::make_unique();
+break;
   case DebugUnparseWithSymbols:
 return std::make_unique();
 break;
@@ -49,6 +52,9 @@
   case DebugDumpParseTree:
 return std::make_unique();
 break;
+  case DebugDumpParseTreeNoSema:
+return std::make_unique();
+break;
   case DebugDumpProvenance:
 return std::make_unique();
 break;
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -78,6 +78,57 @@
   return true;
 }
 
+bool PrescanAndParseAction::BeginSourceFileAction(CompilerInstance &c1) {
+  CompilerInstance &ci = this->instance();
+
+  std::string currentInputPath{GetCurrentFileOrBufferName()};
+
+  Fortran::parser::Options parserOptions = ci.invocation().fortranOpts();
+
+  if (ci.invocation().frontendOpts().fortranForm_ == FortranForm::Unknown) {

[PATCH] D99708: [X86] Enable compilation of user interrupt handlers.

2021-04-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/test/CodeGen/X86/x86-64-intrcc-uintr.ll:1
+; RUN: llc < %s | FileCheck %s -check-prefixes=CHECK,CHECK-USER
+; RUN: llc -O0 < %s | FileCheck %s -check-prefixes=CHECK0,CHECK0-USER

Please use update_llc_test_checks.py


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

https://reviews.llvm.org/D99708

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


[PATCH] D99683: [HIP] Support ThinLTO

2021-04-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added a comment.

In D99683#2669136 , @yaxunl wrote:

> In D99683#2669080 , @tejohnson wrote:
>
>> In D99683#2669047 , @yaxunl wrote:
>>
>>> In D99683#2664674 , @tejohnson 
>>> wrote:
>>>
 I haven't looked extensively yet, but why import noinline functions? Also, 
 please add a patch description.
>>>
>>> AMDGPU backend does not support linking of object files containing external 
>>> symbols, i.e. one object file calling a function defined in another object 
>>> file. Therefore the LLVM module passed to AMDGPU backend needs to contain 
>>> definitions of all callees, even if a callee has noinline attribute. To 
>>> support backends like this, the function importer needs to be able to 
>>> import functions with noinline attribute. Therefore we add an LLVM option 
>>> for allowing that, which is off by default. We have comments at line 70 of 
>>> HIP.cpp about this.
>>
>> How does a non-LTO build work, or is (full) LTO currently required? Because 
>> with ThinLTO we only import functions that are externally defined but 
>> referenced in the current module. Also, when ThinLTO imports functions it 
>> makes them available_externally, which means they are dropped and made 
>> external symbols again after inlining. So anything imported but not inlined 
>> will go back to being an external symbol.
>
> AMDGPU backend by default uses full LTO for linking. It does not support 
> non-LTO linking. Currently, it inlines all functions except kernels. However 
> we want to be able to be able not to inline all functions. Is it OK to add an 
> LLVM option to mark imported functions as linkonce_odr so that AMDGPU backend 
> can keep the definitions of the imported functions?

Actually AMDGPU backend will internalize all non-kernel functions before 
codegen. Those functions with available_externally linkage will have internal 
linkage before codegen, therefore they will not be dropped.




Comment at: clang/include/clang/Driver/Options.td:1904-1907
+def foffload_lto : Flag<["-"], "foffload-lto">, Flags<[CoreOption]>, 
Group,
+  HelpText<"Enable LTO in 'full' mode for offload compilation">;
+def fno_offload_lto : Flag<["-"], "fno-offload-lto">, Flags<[CoreOption]>, 
Group,
+  HelpText<"Disable LTO mode (default) for offload compilation">;

jansvoboda11 wrote:
> yaxunl wrote:
> > tra wrote:
> > > Should it be `BoolFOption` ? 
> > Yes. will fix
> The `BoolFOption` marshalling multiclass should be only used for flags where 
> either the positive or the negative (or both) are -cc1 options and map to a 
> field in `CompilerInvocation`.
> 
> Since this patch only deals with the driver (not the cc1 frontend) using 
> `BoolFOption` is not correct. Please, revert this change to the previous 
> state.
> 
> I might need to explicitly call this out in the documentation 
> https://clang.llvm.org/docs/InternalsManual.html#adding-new-command-line-option.
will do


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

https://reviews.llvm.org/D99683

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


[PATCH] D99959: [analyzer][NFC] Add tests for extents

2021-04-06 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

More tests are great!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99959

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


[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

2021-04-06 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D69726#2671611 , @Charusso wrote:

> In D69726#2671526 , @vsavchenko 
> wrote:
>
>> @Charusso 
>> It looks like this patch introduced a some weird false positive on 
>> PostgreSQL F16161734: report-guc.c-ParseLongOption-13-1.html 
>> 
>> I'll try to look at it myself and minimize it, but maybe you can get an idea 
>> from a full report.
>
> Could you supply us with all the divergence please? If there is only one 
> case, may we can ignore it by appending it to @NoQ's 
> `extremely-weird-bugs.txt` so people can focus on more important stuff.
>
> What I see in the bug report is that: `line 3290 - guc_malloc()` returns null 
> and it is a true positive.



1. It's the only bug in divergence.
2. The analyzer doesn't explain why it thinks that `guc_malloc` returns null 
pointer.  I find it alarming that it might assume it for all the wrong reasons.
3. It is a false positive because `guc_malloc` is called with `elevel == 
FATAL`, which causes `ereport` to fail the whole execution.

I believe that this problem is important because it is definitely a regression.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69726

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


[PATCH] D99526: [RISCV][Clang] Add RVV Widening Integer Add/Subtract intrinsic functions.

2021-04-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vwadd.c:35
+vint16mf4_t test_vwadd_vx_i16mf4(vint8mf8_t op1, int8_t op2, size_t vl) {
+  return vwadd_vx(op1, op2, vl);
+}

khchen wrote:
> khchen wrote:
> > craig.topper wrote:
> > > Why do scalars require _wx or _vx, but vector don't need a suffix?
> > https://github.com/riscv/rvv-intrinsic-doc/blob/master/rvv-intrinsic-rfc.md#widening-vector-scalar-arithmetic-instructions
> > There is different overloading naming rule for _wx and _vx, and I just keep 
> > the default naming rule for vector version because I felt the overloading 
> > rule did not care about the naming consistent. 
> > 
> > But in https://github.com/riscv/rvv-intrinsic-doc/pull/76 we start to make 
> > overloading name seems more consistent. So I think making this case 
> > consistent is ok to me.
> > 
> > I could send a PR to intrinsic-doc, what do you think?
> Should I update this patch for 
> https://github.com/riscv/rvv-intrinsic-doc/pull/77 PR?
I think that makes sense. It's more consistent for someone writing intrinsic 
code if the suffix is always there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99526

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


[PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-06 Thread Abhina Sree 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 rG82b3e28e836d: [SystemZ][z/OS][Windows] Add new 
OF_TextWithCRLF flag and use this flag instead… (authored by 
abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

Files:
  clang-tools-extra/clang-move/tool/ClangMove.cpp
  clang-tools-extra/modularize/ModuleAssistant.cpp
  clang-tools-extra/pp-trace/PPTrace.cpp
  clang/lib/ARCMigrate/PlistReporter.cpp
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Frontend/DependencyGraph.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/lib/Frontend/ModuleDependencyCollector.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  clang/tools/driver/cc1as_main.cpp
  flang/lib/Frontend/CompilerInstance.cpp
  lld/COFF/DriverUtils.cpp
  lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  lldb/include/lldb/Utility/ReproducerProvider.h
  lldb/source/Utility/GDBRemote.cpp
  lldb/source/Utility/ReproducerProvider.cpp
  lldb/tools/lldb-server/LLDBServerUtilities.cpp
  llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/CodeGen/RegAllocPBQP.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/LLVMRemarkStreamer.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/FileCollector.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/Timer.cpp
  llvm/lib/Support/Unix/Program.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/lib/Support/Windows/Program.inc
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
  llvm/tools/llvm-dis/llvm-dis.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
  llvm/tools/llvm-link/llvm-link.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/tools/llvm-profdata/llvm-profdata.cpp
  llvm/tools/llvm-xray/xray-account.cpp
  llvm/tools/llvm-xray/xray-converter.cpp
  llvm/tools/llvm-xray/xray-extract.cpp
  llvm/tools/llvm-xray/xray-graph-diff.cpp
  llvm/tools/llvm-xray/xray-graph.cpp
  llvm/tools/opt/opt.cpp
  llvm/tools/verify-uselistorder/verify-uselistorder.cpp
  llvm/unittests/Support/Path.cpp
  polly/lib/Exchange/JSONExporter.cpp

Index: polly/lib/Exchange/JSONExporter.cpp
===
--- polly/lib/Exchange/JSONExporter.cpp
+++ polly/lib/Exchange/JSONExporter.cpp
@@ -178,7 +178,7 @@
 
   // Write to file.
   std::error_code EC;
-  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_Text);
+  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_TextWithCRLF);
 
   std::string FunctionName = S.getFunction().getName().str();
   errs() << "Writing JScop '" << S.getNameStr() << "' in function '"
Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1253,7 +1253,7 @@
   path::append(FilePathname, "test");
 
   {
-raw_fd_ostream File(FilePathname, EC, sys::fs::OF_Text);
+raw_fd_ostream File(FilePathname, EC, sys::fs::OF_TextWithCRLF);
 ASSERT_NO_ERROR(EC);
 File << '\n';
   }
Index: llvm/tools/verify-uselistorder/verify-uselistorder.cpp
===
--- llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -136,7 +136,7 @@
 bool TempFile::writeAssembly(const Module &M) const {
   LLVM_DEBUG(dbgs() << " - write assembly\n");
   std::error_code EC;
-  raw_fd_ostream OS(Filename, EC, sys::fs::OF_Text);
+  raw_fd_ostream OS(Filename, EC, sys::fs::OF_TextWithCRLF);
   if (EC) {
 errs() << "verify-uselistorder: error: " << EC.message() << "\n";
 return true;
Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -700,8 +700,8 @@
   OutputFilename = "-";
 
 std::error_code EC;
-sys::fs::OpenFlags Flags = OutputAssembly ? sys::fs::OF_Text
-  : sys::fs::OF_None;
+sys::fs::OpenFlags Flags =
+   

[PATCH] D99250: [DebugInfo] Fix the mismatching of C++ language tags and Dwarf versions.

2021-04-06 Thread EsmeYi via Phabricator via cfe-commits
Esme added a comment.

If there are no more comments, I'll commit the patch soon. 
What do you think? @aprantl


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99250

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


[PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-06 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D99426#2670552 , @yroux wrote:

> Hi,
>
> Sorry I'm bit lost in the various patches proposed to fix the issue 
> introduced by https://reviews.llvm.org/D97785 
> My understanding is that this is missing one to fix our Windows on ARM bots 
> (broken for more than 2 weeks now)
> So it'd be great to have it applied

I've committed this and it looks like the bot is back to green :) 
https://lab.llvm.org/buildbot/#/builders/65/builds/1400. Sorry for the delayed 
fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-06 Thread Yvan Roux via Phabricator via cfe-commits
yroux added a comment.



> I've committed this and it looks like the bot is back to green :) 
> https://lab.llvm.org/buildbot/#/builders/65/builds/1400. Sorry for the 
> delayed fix

Great, thanks a lot


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99658: [analyzer] Fix clang_analyzer_getExtent for heap regions

2021-04-06 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

I mean, the extent of an `ElementRegion` //is// the size of a single element. 
The reason why our intrinsic isn't doing what you expect is because we 
represent the pointer with offset as `ElementRegion` regardless of whether 
operator `[]` was used. On the other hand, an `SVal` doesn't ever represent a 
region at all, it only points to its first byte, regardless of the structure of 
`MemRegion` inside it; for that reason `clang_analyzer_getExtent()` is 
impossible to implement correctly in our current model.

So i think both behaviors are incorrect but if you think it makes it easier to 
write tests then absolutely go for it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99658

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


[PATCH] D99683: [HIP] Support ThinLTO

2021-04-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 335571.
yaxunl marked an inline comment as done.
yaxunl added a comment.

revert the change about option


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

https://reviews.llvm.org/D99683

Files:
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/hip-options.hip
  llvm/lib/Transforms/IPO/FunctionImport.cpp
  llvm/test/Transforms/FunctionImport/Inputs/noinline.ll
  llvm/test/Transforms/FunctionImport/noinline.ll

Index: llvm/test/Transforms/FunctionImport/noinline.ll
===
--- /dev/null
+++ llvm/test/Transforms/FunctionImport/noinline.ll
@@ -0,0 +1,23 @@
+; Do setup work for all below tests: generate bitcode and combined index
+; RUN: opt -module-summary %s -o %t.main.bc
+; RUN: opt -module-summary %p/Inputs/noinline.ll -o %t.inputs.noinline.bc
+; RUN: llvm-lto -thinlto -o %t.summary %t.main.bc %t.inputs.noinline.bc
+
+; Attempt the import now, ensure below that file containing noinline
+; is not imported by default but imported with -import-noinline.
+
+; RUN: opt -function-import -summary-file %t.summary.thinlto.bc %t.main.bc -S 2>&1 \
+; RUN:   | FileCheck -check-prefix=NOIMPORT %s
+; RUN: opt -function-import -import-noinline -summary-file %t.summary.thinlto.bc \
+; RUN:   %t.main.bc -S 2>&1 | FileCheck -check-prefix=IMPORT %s
+
+define i32 @main() #0 {
+entry:
+  %f = alloca i64, align 8
+  call void @foo(i64* %f)
+  ret i32 0
+}
+
+; NOIMPORT: declare void @foo(i64*)
+; IMPORT: define available_externally void @foo
+declare void @foo(i64*) #1
Index: llvm/test/Transforms/FunctionImport/Inputs/noinline.ll
===
--- /dev/null
+++ llvm/test/Transforms/FunctionImport/Inputs/noinline.ll
@@ -0,0 +1,8 @@
+define void @foo(i64* %v) #0 {
+entry:
+  %v.addr = alloca i64*, align 8
+  store i64* %v, i64** %v.addr, align 8
+  ret void
+}
+
+attributes #0 = { noinline }
\ No newline at end of file
Index: llvm/lib/Transforms/IPO/FunctionImport.cpp
===
--- llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -84,6 +84,10 @@
 "import-cutoff", cl::init(-1), cl::Hidden, cl::value_desc("N"),
 cl::desc("Only import first N functions if N>=0 (default -1)"));
 
+static cl::opt
+ImportNoInline("import-noinline", cl::init(false), cl::Hidden,
+   cl::desc("Import functions with noinline attribute"));
+
 static cl::opt
 ImportInstrFactor("import-instr-evolution-factor", cl::init(0.7),
   cl::Hidden, cl::value_desc("x"),
@@ -240,7 +244,7 @@
 }
 
 // Don't bother importing if we can't inline it anyway.
-if (Summary->fflags().NoInline) {
+if (Summary->fflags().NoInline && !ImportNoInline) {
   Reason = FunctionImporter::ImportFailureReason::NoInline;
   return false;
 }
Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -51,3 +51,12 @@
 // RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck -check-prefix=CTA %s
 // CTA: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-mconstructor-aliases"
 // CTA-NOT: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-mconstructor-aliases"
+
+// Check -foffload-lto=thin translated correctly.
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --cuda-gpu-arch=gfx906 -fgpu-rdc -foffload-lto=thin %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=THINLTO %s
+// THINLTO-NOT: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-flto-unit"
+// THINLTO: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-flto-unit"
+// THINLTO: lld{{.*}}"-plugin-opt=mcpu=gfx906" "-plugin-opt=thinlto" "-plugin-opt=-import-instr-limit=10" "-plugin-opt=-import-noinline"
Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -49,8 +49,8 @@
   auto &TC = getToolChain();
   auto &D = TC.getDriver();
   assert(!Inputs.empty() && "Must have at least one input.");
-  addLTOOptions(TC, Args, LldArgs, Output, Inputs[0],
-D.getLTOMode() == LTOK_Thin);
+  bool IsThinLTO = D.getLTOMode(/*IsOffload=*/true) == LTOK_Thin;
+  addLTOOptions(TC, Args, LldArgs, Output, Inputs[0], IsThinLTO);
 
   // Extract all the -m options
   std::vector Features;
@@ -66,6 +66,14 @@
   if (!Features.empty())
 LldArgs.push_back(Args.MakeArgString(MAttrString));
 
+  // ToDo: Remove these options after AMDGPU backend supports ISA-level linking.
+  // Since AMDGPU backend currently doe

[PATCH] D99601: [-Wcompletion-handler] Don't recognize init methods as conventional

2021-04-06 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Looks great now!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99601

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


[PATCH] D99683: [HIP] Support ThinLTO

2021-04-06 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 335573.
yaxunl added a comment.

rebase


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

https://reviews.llvm.org/D99683

Files:
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/hip-options.hip
  llvm/lib/Transforms/IPO/FunctionImport.cpp
  llvm/test/Transforms/FunctionImport/Inputs/noinline.ll
  llvm/test/Transforms/FunctionImport/noinline.ll

Index: llvm/test/Transforms/FunctionImport/noinline.ll
===
--- /dev/null
+++ llvm/test/Transforms/FunctionImport/noinline.ll
@@ -0,0 +1,23 @@
+; Do setup work for all below tests: generate bitcode and combined index
+; RUN: opt -module-summary %s -o %t.main.bc
+; RUN: opt -module-summary %p/Inputs/noinline.ll -o %t.inputs.noinline.bc
+; RUN: llvm-lto -thinlto -o %t.summary %t.main.bc %t.inputs.noinline.bc
+
+; Attempt the import now, ensure below that file containing noinline
+; is not imported by default but imported with -import-noinline.
+
+; RUN: opt -function-import -summary-file %t.summary.thinlto.bc %t.main.bc -S 2>&1 \
+; RUN:   | FileCheck -check-prefix=NOIMPORT %s
+; RUN: opt -function-import -import-noinline -summary-file %t.summary.thinlto.bc \
+; RUN:   %t.main.bc -S 2>&1 | FileCheck -check-prefix=IMPORT %s
+
+define i32 @main() #0 {
+entry:
+  %f = alloca i64, align 8
+  call void @foo(i64* %f)
+  ret i32 0
+}
+
+; NOIMPORT: declare void @foo(i64*)
+; IMPORT: define available_externally void @foo
+declare void @foo(i64*) #1
Index: llvm/test/Transforms/FunctionImport/Inputs/noinline.ll
===
--- /dev/null
+++ llvm/test/Transforms/FunctionImport/Inputs/noinline.ll
@@ -0,0 +1,8 @@
+define void @foo(i64* %v) #0 {
+entry:
+  %v.addr = alloca i64*, align 8
+  store i64* %v, i64** %v.addr, align 8
+  ret void
+}
+
+attributes #0 = { noinline }
\ No newline at end of file
Index: llvm/lib/Transforms/IPO/FunctionImport.cpp
===
--- llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -84,6 +84,10 @@
 "import-cutoff", cl::init(-1), cl::Hidden, cl::value_desc("N"),
 cl::desc("Only import first N functions if N>=0 (default -1)"));
 
+static cl::opt
+ImportNoInline("import-noinline", cl::init(false), cl::Hidden,
+   cl::desc("Import functions with noinline attribute"));
+
 static cl::opt
 ImportInstrFactor("import-instr-evolution-factor", cl::init(0.7),
   cl::Hidden, cl::value_desc("x"),
@@ -240,7 +244,7 @@
 }
 
 // Don't bother importing if we can't inline it anyway.
-if (Summary->fflags().NoInline) {
+if (Summary->fflags().NoInline && !ImportNoInline) {
   Reason = FunctionImporter::ImportFailureReason::NoInline;
   return false;
 }
Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -51,3 +51,12 @@
 // RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck -check-prefix=CTA %s
 // CTA: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-mconstructor-aliases"
 // CTA-NOT: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-mconstructor-aliases"
+
+// Check -foffload-lto=thin translated correctly.
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --cuda-gpu-arch=gfx906 -fgpu-rdc -foffload-lto=thin %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=THINLTO %s
+// THINLTO-NOT: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-flto-unit"
+// THINLTO: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-flto-unit"
+// THINLTO: lld{{.*}}"-plugin-opt=mcpu=gfx906" "-plugin-opt=thinlto" "-plugin-opt=-import-instr-limit=10" "-plugin-opt=-import-noinline"
Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -49,8 +49,8 @@
   auto &TC = getToolChain();
   auto &D = TC.getDriver();
   assert(!Inputs.empty() && "Must have at least one input.");
-  addLTOOptions(TC, Args, LldArgs, Output, Inputs[0],
-D.getLTOMode() == LTOK_Thin);
+  bool IsThinLTO = D.getLTOMode(/*IsOffload=*/true) == LTOK_Thin;
+  addLTOOptions(TC, Args, LldArgs, Output, Inputs[0], IsThinLTO);
 
   // Extract all the -m options
   std::vector Features;
@@ -66,6 +66,14 @@
   if (!Features.empty())
 LldArgs.push_back(Args.MakeArgString(MAttrString));
 
+  // ToDo: Remove these options after AMDGPU backend supports ISA-level linking.
+  // Since AMDGPU backend currently does not support ISA-level linking, all
+  // called functions need 

  1   2   3   >