[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-09-02 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng updated this revision to Diff 370174.
kito-cheng marked an inline comment as done.
kito-cheng added a comment.

Changes:

- Check feature combination is valid.
- Change return type of parseFeatures to 
llvm::Expected>.
- Set default extension version in getExtensionVersion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-abi.c
  clang/test/Driver/riscv-arch.c
  clang/test/Driver/riscv-features.c
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/attribute-with-insts.s
  llvm/test/MC/RISCV/invalid-attribute.s

Index: llvm/test/MC/RISCV/invalid-attribute.s
===
--- llvm/test/MC/RISCV/invalid-attribute.s
+++ llvm/test/MC/RISCV/invalid-attribute.s
@@ -7,10 +7,10 @@
 # RUN: not llvm-mc %s -triple=riscv64 -filetype=asm 2>&1 | FileCheck %s
 
 .attribute arch, "foo"
-# CHECK: [[@LINE-1]]:18: error: bad arch string foo
+# CHECK: [[@LINE-1]]:18: error: invalid arch name 'foo', string must begin with rv32{i,e,g} or rv64{i,g}
 
 .attribute arch, "rv32i2p0_y2p0"
-# CHECK: [[@LINE-1]]:18: error: bad arch string y2p0
+# CHECK: [[@LINE-1]]:18: error: invalid arch name 'rv32i2p0_y2p0', invalid standard user-level extension 'y'
 
 .attribute stack_align, "16"
 # CHECK: [[@LINE-1]]:25: error: expected numeric constant
Index: llvm/test/MC/RISCV/attribute-with-insts.s
===
--- llvm/test/MC/RISCV/attribute-with-insts.s
+++ llvm/test/MC/RISCV/attribute-with-insts.s
@@ -10,7 +10,7 @@
 # RUN:   | llvm-objdump --triple=riscv64 -d -M no-aliases - \
 # RUN:   | FileCheck -check-prefix=CHECK-INST %s
 
-.attribute arch, "rv64i2p0_m2p0_a2p0_d2p0_c2p0"
+.attribute arch, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
 
 # CHECK-INST: lr.w t0, (t1)
 lr.w t0, (t1)
Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -9,9 +9,6 @@
 .attribute arch, "rv32i2"
 # CHECK: attribute  5, "rv32i2p0"
 
-.attribute arch, "rv32i2p"
-# CHECK: attribute  5, "rv32i2p0"
-
 .attribute arch, "rv32i2p0"
 # CHECK: attribute  5, "rv32i2p0"
 
@@ -33,14 +30,14 @@
 .attribute arch, "rv32ima2p0_fdc"
 # CHECK: attribute  5, "rv32i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
 
-.attribute arch, "rv32ima2p_fdc"
+.attribute arch, "rv32ima2p0_fdc"
 # CHECK: attribute  5, "rv32i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
 
 .attribute arch, "rv32ib"
 # CHECK: attribute  5, "rv32i2p0_b0p93_zba0p93_zbb0p93_zbc0p93_zbe0p93_zbf0p93_zbm0p93_zbp0p93_zbr0p93_zbs0p93_zbt0p93"
 
 .attribute arch, "rv32iv"
-# CHECK: attribute  5, "rv32i2p0_v0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvlsseg0p10"
 
 .attribute arch, "rv32izba"
 # CHECK: attribute  5, "rv32i2p0_zba0p93"
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
===
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
@@ -11,9 +11,11 @@
 //===--===//
 
 #include "RISCVTargetStreamer.h"
+#include "RISCVBaseInfo.h"
 #include "RISCVMCTargetDesc.h"
 #include "llvm/Support/FormattedStream.h"
 #include "llvm/Support/RISCVAttributes.h"
+#include "llvm/Support/RISCVISAInfo.h"
 
 using namespace llvm;
 
@@ -43,57 +45,19 @@
   else
 emitAttribute(RISCVAttrs::STACK_ALIGN, RISCVAttrs::ALIGN_16);
 
-  std::string Arch = "rv32";
-  if (STI.hasFeature(RISCV::Feature64Bit))
-Arch = "rv64";
-  if (STI.hasFeature(RISCV::FeatureRV32E))
-Arch += "e1p9";
-  else
-Arch += "i2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtM))
-Arch += "_m2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtA))
-Arch += "_a2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtF))
-Arch += "_f2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtD))
-Arch += "_d2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtC))
-Arch += "_c2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtB))
-Arch += "_b0p93";
-  if (STI.hasFeature(RISCV::FeatureStdExtV))
-Arch += "_v0p10";
-  if (STI.hasFeature(RISCV::FeatureExtZfh))
-Arch += "_zfh0p1";
-  if (STI.hasFeature(RISCV::FeatureExtZba))
-Arch += "_zba0p93";
-  if (STI.hasFeature(RISCV::Featu

[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-09-02 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng marked 2 inline comments as done.
kito-cheng added inline comments.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:387
+ExtensionInfoIterator->Version.Minor);
+  if (ExtName == "e")
+HasE = true;

Jim wrote:
> Does this need to check it is invalid if XLen is 64?
Add check, and parseFeatures might return Error now.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:394
+  if (!HasE)
+ISAInfo->addExtension("i", 2, 0);
+

Jim wrote:
> Why not get the version of i from SupportedExtensions?
Updated :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

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


[PATCH] D107547: [CodeGen] More bits for calling convention

2021-09-02 Thread Xinglong Liao via Phabricator via cfe-commits
Xinglong updated this revision to Diff 370177.
Xinglong retitled this revision from "[CodeGen] Align calling convention 
bit-width to bitcode" to "[CodeGen] More bits for calling convention".
Xinglong edited the summary of this revision.
Xinglong added a comment.

Some patch broken the single 32-bit unit, so here use 16 bits is better.


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

https://reviews.llvm.org/D107547

Files:
  clang/include/clang/CodeGen/CGFunctionInfo.h


Index: clang/include/clang/CodeGen/CGFunctionInfo.h
===
--- clang/include/clang/CodeGen/CGFunctionInfo.h
+++ clang/include/clang/CodeGen/CGFunctionInfo.h
@@ -552,14 +552,14 @@
 
   /// The LLVM::CallingConv to use for this function (as specified by the
   /// user).
-  unsigned CallingConvention : 8;
+  unsigned CallingConvention : 16;
 
   /// The LLVM::CallingConv to actually use for this function, which may
   /// depend on the ABI.
-  unsigned EffectiveCallingConvention : 8;
+  unsigned EffectiveCallingConvention : 16;
 
   /// The clang::CallingConv that this was originally created with.
-  unsigned ASTCallingConvention : 6;
+  unsigned ASTCallingConvention : 16;
 
   /// Whether this is an instance method.
   unsigned InstanceMethod : 1;


Index: clang/include/clang/CodeGen/CGFunctionInfo.h
===
--- clang/include/clang/CodeGen/CGFunctionInfo.h
+++ clang/include/clang/CodeGen/CGFunctionInfo.h
@@ -552,14 +552,14 @@
 
   /// The LLVM::CallingConv to use for this function (as specified by the
   /// user).
-  unsigned CallingConvention : 8;
+  unsigned CallingConvention : 16;
 
   /// The LLVM::CallingConv to actually use for this function, which may
   /// depend on the ABI.
-  unsigned EffectiveCallingConvention : 8;
+  unsigned EffectiveCallingConvention : 16;
 
   /// The clang::CallingConv that this was originally created with.
-  unsigned ASTCallingConvention : 6;
+  unsigned ASTCallingConvention : 16;
 
   /// Whether this is an instance method.
   unsigned InstanceMethod : 1;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107547: [CodeGen] More bits for calling convention

2021-09-02 Thread Xinglong Liao via Phabricator via cfe-commits
Xinglong marked an inline comment as done.
Xinglong added inline comments.



Comment at: clang/include/clang/CodeGen/CGFunctionInfo.h:562
   /// The clang::CallingConv that this was originally created with.
-  unsigned ASTCallingConvention : 6;
+  unsigned ASTCallingConvention : 10;
 

rjmccall wrote:
> At some point, these bit-fields fit into a single 32-bit unit.  There's 
> currently 33 bits, so that hasn't been true for a while, and we might as well 
> make all three of these fields 16 bits.
> 
> It doesn't look like there's a good opportunity to pack the struct because 
> we're at an odd number of 32-bit chunks overall, so that'll do for now.
Yes, 32-bit unit is broken, here use 16 bits is better and llvm backend need a 
patch to align to 16 bits.


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

https://reviews.llvm.org/D107547

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


[PATCH] D107764: [OpenMP][OpenMPIRBuilder] Implement loop unrolling.

2021-09-02 Thread Kai Luo via Phabricator via cfe-commits
lkail added a comment.

This looks has broken build if `-DBUILD_SHARED_LIBS=On` is specified.

  CMake Error: The inter-target dependency graph contains the following 
strongly connected component (cycle):
"LLVMFrontendOpenMP" of type SHARED_LIBRARY
  depends on "LLVMPasses" (weak)
"LLVMipo" of type SHARED_LIBRARY
  depends on "LLVMFrontendOpenMP" (weak)
"LLVMCoroutines" of type SHARED_LIBRARY
  depends on "LLVMipo" (weak)
"LLVMPasses" of type SHARED_LIBRARY
  depends on "LLVMCoroutines" (weak)
  depends on "LLVMipo" (weak)
  At least one of these targets is not a STATIC_LIBRARY.  Cyclic dependencies 
are allowed only among static libraries.
  CMake Generate step failed.  Build files cannot be regenerated correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107764

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


[PATCH] D109137: [clang] NFC: Remove duplicate DependentSizedMatrixType methods

2021-09-02 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes created this revision.
c-rhodes added a reviewer: fhahn.
c-rhodes requested review of this revision.
Herald added a project: clang.

Inherited from MatrixType.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109137

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


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -3524,14 +3524,10 @@
Expr *ColumnExpr, SourceLocation loc);
 
 public:
-  QualType getElementType() const { return ElementType; }
   Expr *getRowExpr() const { return RowExpr; }
   Expr *getColumnExpr() const { return ColumnExpr; }
   SourceLocation getAttributeLoc() const { return loc; }
 
-  bool isSugared() const { return false; }
-  QualType desugar() const { return QualType(this, 0); }
-
   static bool classof(const Type *T) {
 return T->getTypeClass() == DependentSizedMatrix;
   }


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -3524,14 +3524,10 @@
Expr *ColumnExpr, SourceLocation loc);
 
 public:
-  QualType getElementType() const { return ElementType; }
   Expr *getRowExpr() const { return RowExpr; }
   Expr *getColumnExpr() const { return ColumnExpr; }
   SourceLocation getAttributeLoc() const { return loc; }
 
-  bool isSugared() const { return false; }
-  QualType desugar() const { return QualType(this, 0); }
-
   static bool classof(const Type *T) {
 return T->getTypeClass() == DependentSizedMatrix;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107547: [CodeGen] More bits for calling convention

2021-09-02 Thread Xinglong Liao via Phabricator via cfe-commits
Xinglong updated this revision to Diff 370185.
Xinglong marked an inline comment as done.
Xinglong added a comment.

rebase


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

https://reviews.llvm.org/D107547

Files:
  clang/include/clang/CodeGen/CGFunctionInfo.h


Index: clang/include/clang/CodeGen/CGFunctionInfo.h
===
--- clang/include/clang/CodeGen/CGFunctionInfo.h
+++ clang/include/clang/CodeGen/CGFunctionInfo.h
@@ -552,14 +552,14 @@
 
   /// The LLVM::CallingConv to use for this function (as specified by the
   /// user).
-  unsigned CallingConvention : 8;
+  unsigned CallingConvention : 16;
 
   /// The LLVM::CallingConv to actually use for this function, which may
   /// depend on the ABI.
-  unsigned EffectiveCallingConvention : 8;
+  unsigned EffectiveCallingConvention : 16;
 
   /// The clang::CallingConv that this was originally created with.
-  unsigned ASTCallingConvention : 6;
+  unsigned ASTCallingConvention : 16;
 
   /// Whether this is an instance method.
   unsigned InstanceMethod : 1;


Index: clang/include/clang/CodeGen/CGFunctionInfo.h
===
--- clang/include/clang/CodeGen/CGFunctionInfo.h
+++ clang/include/clang/CodeGen/CGFunctionInfo.h
@@ -552,14 +552,14 @@
 
   /// The LLVM::CallingConv to use for this function (as specified by the
   /// user).
-  unsigned CallingConvention : 8;
+  unsigned CallingConvention : 16;
 
   /// The LLVM::CallingConv to actually use for this function, which may
   /// depend on the ABI.
-  unsigned EffectiveCallingConvention : 8;
+  unsigned EffectiveCallingConvention : 16;
 
   /// The clang::CallingConv that this was originally created with.
-  unsigned ASTCallingConvention : 6;
+  unsigned ASTCallingConvention : 16;
 
   /// Whether this is an instance method.
   unsigned InstanceMethod : 1;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109137: [clang] NFC: Remove duplicate DependentSizedMatrixType methods

2021-09-02 Thread Florian Hahn via Phabricator via cfe-commits
fhahn accepted this revision.
fhahn 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/D109137/new/

https://reviews.llvm.org/D109137

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


[PATCH] D109139: [AIX][RFC] Undefine __STDC_NO_ATOMICS__ to enable c11 atomics functionality

2021-09-02 Thread Kai Luo via Phabricator via cfe-commits
lkail created this revision.
lkail added reviewers: PowerPC, hubert.reinterpretcast, jsji, cebowleratibm, 
Jake-Egan.
Herald added subscribers: jfb, kbarton, nemanjai.
lkail requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In https://reviews.llvm.org/D103707, `__STDC_NO_ATOMICS__` is predefined to 
indicate clang on AIX doesn't support `_Atomic` and not shipped with 
`stdatomic.h` yet. Actually `_Atomic` is already supported. For `stdatomic.h`, 
clang has implemented one in `clang/lib/Headers/stdatomic.h`. The remaining 
problem is

  void atomic_thread_fence(memory_order);
  void atomic_signal_fence(memory_order);
  _Bool atomic_flag_test_and_set(volatile atomic_flag *);
  _Bool atomic_flag_test_and_set_explicit(volatile atomic_flag *, memory_order);

are defined as macros and don't have external linkage required by C11 standard, 
since current libc of AIX doesn't have them now. So is it worthwhile to violate 
the standard a bit, but make c11's atomics functionality available to users? If 
not, we may have to wait for upgrading of AIX's libc to define above routines.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109139

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/Preprocessor/init-ppc.c


Index: clang/test/Preprocessor/init-ppc.c
===
--- clang/test/Preprocessor/init-ppc.c
+++ clang/test/Preprocessor/init-ppc.c
@@ -755,11 +755,9 @@
 // RUN: %clang_cc1 -x c -std=c11 -E -dM -ffreestanding 
-triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck 
-match-full-lines -check-prefix PPC-AIX-STDC %s
 // RUN: %clang_cc1 -x c -std=gnu11 -E -dM -ffreestanding 
-triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck 
-match-full-lines -check-prefix PPC-AIX-STDC %s
 // RUN: %clang_cc1 -x c -std=c17 -E -dM -ffreestanding 
-triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck 
-match-full-lines -check-prefix PPC-AIX-STDC %s
-// PPC-AIX-STDC:#define __STDC_NO_ATOMICS__ 1
 // PPC-AIX-STDC:#define __STDC_NO_THREADS__ 1
 
 // RUN: %clang_cc1 -x c -std=c99 -E -dM -ffreestanding 
-triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck 
-match-full-lines -check-prefix PPC-AIX-STDC-N %s
-// PPC-AIX-STDC-N-NOT:#define __STDC_NO_ATOMICS__ 1
 // PPC-AIX-STDC-N-NOT:#define __STDC_NO_THREADS__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 
-mlong-double-64 < /dev/null | FileCheck -match-full-lines -check-prefix 
PPC-AIX-LD64 %s
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -679,10 +679,8 @@
 Builder.defineMacro("__TOS_AIX__");
 Builder.defineMacro("__HOS_AIX__");
 
-if (Opts.C11) {
-  Builder.defineMacro("__STDC_NO_ATOMICS__");
+if (Opts.C11)
   Builder.defineMacro("__STDC_NO_THREADS__");
-}
 
 if (Opts.EnableAIXExtendedAltivecABI)
   Builder.defineMacro("__EXTABI__");


Index: clang/test/Preprocessor/init-ppc.c
===
--- clang/test/Preprocessor/init-ppc.c
+++ clang/test/Preprocessor/init-ppc.c
@@ -755,11 +755,9 @@
 // RUN: %clang_cc1 -x c -std=c11 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX-STDC %s
 // RUN: %clang_cc1 -x c -std=gnu11 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX-STDC %s
 // RUN: %clang_cc1 -x c -std=c17 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX-STDC %s
-// PPC-AIX-STDC:#define __STDC_NO_ATOMICS__ 1
 // PPC-AIX-STDC:#define __STDC_NO_THREADS__ 1
 
 // RUN: %clang_cc1 -x c -std=c99 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX-STDC-N %s
-// PPC-AIX-STDC-N-NOT:#define __STDC_NO_ATOMICS__ 1
 // PPC-AIX-STDC-N-NOT:#define __STDC_NO_THREADS__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -mlong-double-64 < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX-LD64 %s
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -679,10 +679,8 @@
 Builder.defineMacro("__TOS_AIX__");
 Builder.defineMacro("__HOS_AIX__");
 
-if (Opts.C11) {
-  Builder.defineMacro("__STDC_NO_ATOMICS__");
+if (Opts.C11)
   Builder.defineMacro("__STDC_NO_THREADS__");
-}
 
 if (Opts.EnableAIXExtendedAltivecABI)
   Builder.defineMacro("__EXTABI__");
___
cfe-com

[PATCH] D107764: [OpenMP][OpenMPIRBuilder] Implement loop unrolling.

2021-09-02 Thread David Sherwood via Phabricator via cfe-commits
david-arm added a comment.

Hi, this has broken the build for me too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107764

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


[PATCH] D106262: [clang][analyzer] Use generic note tag in alpha.unix.Stream .

2021-09-02 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 370192.
balazske added a comment.

Using again bug type dependent note tag messages.
Some new tests are added.
The planned debug functions are not added yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106262

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream-note.c

Index: clang/test/Analysis/stream-note.c
===
--- clang/test/Analysis/stream-note.c
+++ clang/test/Analysis/stream-note.c
@@ -33,12 +33,12 @@
 // expected-note@-2 {{Opened stream never closed. Potential resource leak}}
 
 void check_note_freopen() {
-  FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
+  FILE *F = fopen("file", "r");
   if (!F)
 // expected-note@-1 {{'F' is non-null}}
 // expected-note@-2 {{Taking false branch}}
 return;
-  F = freopen(0, "w", F); // expected-note {{Stream reopened here}}
+  F = freopen(0, "w", F); // expected-note {{Stream opened here}}
   if (!F)
 // expected-note@-1 {{'F' is non-null}}
 // expected-note@-2 {{Taking false branch}}
@@ -47,6 +47,32 @@
 // expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
 // expected-note@-2 {{Opened stream never closed. Potential resource leak}}
 
+void check_note_fopen_fail() {
+  FILE *F = fopen("file", "r"); // expected-note {{Assuming opening the stream fails here}} expected-note {{Assuming pointer value is null}} expected-note {{'F' initialized here}}
+  fclose(F);// expected-warning {{Stream pointer might be NULL}}
+  // expected-note@-1 {{Stream pointer might be NULL}}
+}
+
+void check_note_freopen_fail() {
+  FILE *F = fopen("file", "r");
+  if (!F) // expected-note {{'F' is non-null}} expected-note {{Taking false branch}}
+return;
+  freopen(0, "w", F); // expected-note {{Assuming opening the stream fails here}}
+  fclose(F);  // expected-warning {{Stream might be invalid after (re-)opening it has failed. Can cause undefined behaviour}}
+  // expected-note@-1 {{Stream might be invalid after (re-)opening it has failed. Can cause undefined behaviour}}
+}
+
+void check_note_freopen_fail_null() {
+  // FIXME: The following note should not be here.
+  FILE *F = fopen("file", "r"); // expected-note {{Assuming opening the stream fails here}}
+  if (!F) // expected-note {{'F' is non-null}} expected-note {{Taking false branch}}
+return;
+  // FIXME: Note about failing open belongs here.
+  F = freopen(0, "w", F); // expected-note {{Null pointer value stored to 'F'}}
+  fclose(F);  // expected-warning {{Stream pointer might be NULL}}
+  // expected-note@-1 {{Stream pointer might be NULL}}
+}
+
 void check_note_leak_2(int c) {
   FILE *F1 = fopen("foo1.c", "r"); // expected-note {{Stream opened here}}
   if (!F1)
@@ -80,7 +106,7 @@
 
 void check_track_null() {
   FILE *F;
-  F = fopen("foo1.c", "r"); // expected-note {{Value assigned to 'F'}} expected-note {{Assuming pointer value is null}}
+  F = fopen("foo1.c", "r"); // expected-note {{Value assigned to 'F'}} expected-note {{Assuming pointer value is null}} expected-note {{Assuming opening the stream fails here}}
   if (F != NULL) {  // expected-note {{Taking false branch}} expected-note {{'F' is equal to NULL}}
 fclose(F);
 return;
@@ -100,7 +126,7 @@
   if (feof(F)) { // expected-note {{Taking true branch}}
 clearerr(F);
 fread(Buf, 1, 1, F);   // expected-note {{Assuming stream reaches end-of-file here}}
-if (feof(F)) { // expected-note {{Taking true branch}}
+if (feof(F)) { // expected-note {{The end-of-file flag is set on the stream}} expected-note {{Taking true branch}}
   fread(Buf, 1, 1, F); // expected-warning {{Read function called when stream is in EOF state. Function has no effect}}
   // expected-note@-1 {{Read function called when stream is in EOF state. Function has no effect}}
 }
@@ -124,7 +150,7 @@
 return;
   }
   fread(Buf, 1, 1, F);   // expected-note {{Assuming stream reaches end-of-file here}}
-  if (feof(F)) { // expected-note {{Taking true branch}}
+  if (feof(F)) { // expected-note {{The end-of-file flag is set on the stream}} expected-note {{Taking true branch}}
 fread(Buf, 1, 1, F); // expected-warning {{Read function called when stream is in EOF state. Function has no effect}}
 // expected-note@-1 {{Read function called when stream is in EOF state. Function has no effect}}
   }
@@ -138,10 +164,99 @@
   if (F == NULL) // expected-note {{Taking false branch}} expected-note {{'F' is not equal to NULL}}
 return;
   int RRet = fread(Buf, 1, 1, F); // expected-note {{Assuming stream reaches end-of-file here}}
-  if (ferror(F)) {// expected-note {{Taking false branch}}
+  if (ferror(F)) {// expected-note {{The error flag is not set on the strea

[PATCH] D108696: [Coroutines] [Frontend] Lookup in std namespace first

2021-09-02 Thread Adrian Vogelsgesang via Phabricator via cfe-commits
avogelsgesang added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11015
+  "coroutine_traits defined in std::experimental namespace is deprecated. "
+  "Considering update libcxx and include  instead of 
.">,
+  InGroup;

Considering update -> Consider updating


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

https://reviews.llvm.org/D108696

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


[PATCH] D108975: [clangd] Omit default template arguments from type hints

2021-09-02 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

thanks, lgtm!




Comment at: clang-tools-extra/clangd/InlayHints.cpp:353
   const HeuristicResolver *Resolver;
   PrintingPolicy TypeHintPolicy;
+  PrintingPolicy StructuredBindingPolicy;

can we document why we need to policies here, probably something like:

```
We want to suppress default template arguments and print canonical types, 
unfortunately they're conflicting policies hence we can't have both.
For regular types, suppressing default template arguments is more important, 
whereas printing canonical types is crucial for structured bindings. Therefore 
we use 2 separate policies.
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108975

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


[libunwind] f5b997e - [Unwind] Harmonise exception class for EHABI spec.

2021-09-02 Thread Daniel Kiss via cfe-commits

Author: Daniel Kiss
Date: 2021-09-02T11:31:03+02:00
New Revision: f5b997e6b7061323fff13fafcc0c311d9e78e848

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

LOG: [Unwind] Harmonise exception class for EHABI spec.

EHABI defines the exception class as char[8] instead of uint64_t [1].
For ABI compatibility the ABI the definition needs to be updated.

[1] 
https://github.com/ARM-software/abi-aa/blob/main/ehabi32/ehabi32.rst#82language-independent-unwinding-types-and-functions

Reviewed By: manojgupta, MaskRay, #libunwind

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

Added: 


Modified: 
libcxxabi/test/forced_unwind1.pass.cpp
libcxxabi/test/forced_unwind2.pass.cpp
libunwind/include/unwind.h
libunwind/include/unwind_arm_ehabi.h
libunwind/include/unwind_itanium.h
libunwind/src/UnwindLevel1-gcc-ext.c
libunwind/test/forceunwind.pass.cpp

Removed: 




diff  --git a/libcxxabi/test/forced_unwind1.pass.cpp 
b/libcxxabi/test/forced_unwind1.pass.cpp
index b6963a0242996..de376a8ad94f0 100644
--- a/libcxxabi/test/forced_unwind1.pass.cpp
+++ b/libcxxabi/test/forced_unwind1.pass.cpp
@@ -53,7 +53,7 @@ static void cleanup(_Unwind_Reason_Code, struct 
_Unwind_Exception* exc) {
 
 static void forced_unwind() {
   _Unwind_Exception* exc = new _Unwind_Exception;
-  exc->exception_class = 0;
+  memset(&exc->exception_class, 0, sizeof(exc->exception_class));
   exc->exception_cleanup = cleanup;
   _Unwind_ForcedUnwind(exc, Stop<_Unwind_Stop_Fn>::stop, 0);
   abort();

diff  --git a/libcxxabi/test/forced_unwind2.pass.cpp 
b/libcxxabi/test/forced_unwind2.pass.cpp
index 037f0499282f6..a221dfc2e282b 100644
--- a/libcxxabi/test/forced_unwind2.pass.cpp
+++ b/libcxxabi/test/forced_unwind2.pass.cpp
@@ -41,7 +41,7 @@ struct Stop {
 
 static void forced_unwind() {
   _Unwind_Exception* exc = new _Unwind_Exception;
-  exc->exception_class = 0;
+  memset(&exc->exception_class, 0, sizeof(exc->exception_class));
   exc->exception_cleanup = 0;
   _Unwind_ForcedUnwind(exc, Stop<_Unwind_Stop_Fn>::stop, 0);
   abort();

diff  --git a/libunwind/include/unwind.h b/libunwind/include/unwind.h
index 87c3cf6c804ec..2101401337082 100644
--- a/libunwind/include/unwind.h
+++ b/libunwind/include/unwind.h
@@ -64,7 +64,7 @@ typedef struct _Unwind_Context _Unwind_Context;   // opaque
 typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
 (int version,
  _Unwind_Action actions,
- uint64_t exceptionClass,
+ _Unwind_Exception_Class exceptionClass,
  _Unwind_Exception* exceptionObject,
  struct _Unwind_Context* context,
  void* stop_parameter);

diff  --git a/libunwind/include/unwind_arm_ehabi.h 
b/libunwind/include/unwind_arm_ehabi.h
index 5ad0887225605..747129af5e7e7 100644
--- a/libunwind/include/unwind_arm_ehabi.h
+++ b/libunwind/include/unwind_arm_ehabi.h
@@ -27,9 +27,10 @@ typedef uint32_t _Unwind_EHT_Header;
 struct _Unwind_Control_Block;
 typedef struct _Unwind_Control_Block _Unwind_Control_Block;
 #define _Unwind_Exception _Unwind_Control_Block /* Alias */
+typedef uint8_t _Unwind_Exception_Class[8];
 
 struct _Unwind_Control_Block {
-  uint64_t exception_class;
+  _Unwind_Exception_Class exception_class;
   void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block*);
 
   /* Unwinder cache, private fields for the unwinder's use */

diff  --git a/libunwind/include/unwind_itanium.h 
b/libunwind/include/unwind_itanium.h
index eeb45f6228323..794e990dc076d 100644
--- a/libunwind/include/unwind_itanium.h
+++ b/libunwind/include/unwind_itanium.h
@@ -16,9 +16,10 @@
 struct _Unwind_Context;   // opaque
 struct _Unwind_Exception; // forward declaration
 typedef struct _Unwind_Exception _Unwind_Exception;
+typedef uint64_t _Unwind_Exception_Class;
 
 struct _Unwind_Exception {
-  uint64_t exception_class;
+  _Unwind_Exception_Class exception_class;
   void (*exception_cleanup)(_Unwind_Reason_Code reason,
 _Unwind_Exception *exc);
 #if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)

diff  --git a/libunwind/src/UnwindLevel1-gcc-ext.c 
b/libunwind/src/UnwindLevel1-gcc-ext.c
index d69267ba25fe6..c3fa8b6655713 100644
--- a/libunwind/src/UnwindLevel1-gcc-ext.c
+++ b/libunwind/src/UnwindLevel1-gcc-ext.c
@@ -109,7 +109,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
   // Create a mock exception object for force unwinding.
   _Unwind_Exception ex;
   memset(&ex, '\0', sizeof(ex));
-  ex.exception_class = 0x434C4E47554E5700; // CLNGUNW\0
+  strcpy(&ex.exception_class, "CLNGUNW");
 #endif
 
   // walk each frame

diff  --git a/libunwind/test/forceunwind.pass.cpp 
b/libunwind/test/forceunwind.pass.cpp
index e74aa3faa0803..466697264035b 100644
--- a/libunwind/test/forceunwind.pass.cpp
+++ b/libunwind/test/forceunwind.pass.cpp
@@ -

[PATCH] D108695: [analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it

2021-09-02 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:683-685
+  /// between \p CallEnterN and \p CallExitEndN. Mind that the stack frame
+  /// retrieved from a CallEnter is the *caller's* stack frame! The inlined
+  /// function's stack should be retrieved from \p CallExitEndN.

Whoops, this is wildly incorrect. Gotta fix that. The inlined function's stack 
frame is retrievable from the `CallEnter`s first successor, or `CallExitEnd`s 
first predecessor.


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

https://reviews.llvm.org/D108695

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


[libunwind] d212bdf - [libunwind] Compile with -Wunused-but-set-variable

2021-09-02 Thread Daniel Kiss via cfe-commits

Author: Daniel Kiss
Date: 2021-09-02T11:43:20+02:00
New Revision: d212bdf82883c8880da5a2ee67ce6b7b9a239f88

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

LOG: [libunwind] Compile with -Wunused-but-set-variable

-Wunused-but-set-variable triggers a warning even the block of code is 
effectively dead.

Reviewed By: MaskRay

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

Added: 


Modified: 
libunwind/CMakeLists.txt

Removed: 




diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index b6017382646b..3d4c4be6fb8b 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -207,7 +207,6 @@ add_compile_flags_if_supported(-Wsign-compare)
 add_compile_flags_if_supported(-Wsign-conversion)
 add_compile_flags_if_supported(-Wstrict-aliasing=2)
 add_compile_flags_if_supported(-Wstrict-overflow=4)
-add_compile_flags_if_supported(-Wunused-but-set-variable)
 add_compile_flags_if_supported(-Wunused-parameter)
 add_compile_flags_if_supported(-Wunused-variable)
 add_compile_flags_if_supported(-Wwrite-strings)



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


[PATCH] D109144: [SPIR-V] Add SPIR-V triple architecture and clang target info

2021-09-02 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki created this revision.
Herald added subscribers: Naghasan, dexonsmith, wenlei, Anastasia, arphaman, 
hiraditya.
linjamaki requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Add new architectures ‘spirv32’, ‘spirv64’ and ‘spirlogical’
in Triple, ported from LLVM SPIR-V Backend repository
(https://github.com/KhronosGroup/LLVM-SPIRV-Backend). Add basic and
code generation target info for ‘spirv32’ and ‘spirv64’ and, thus,
enabling clang (LLVM IR) code emission to SPIR-V target. The target
information for SPIR-V is mostly reused from the SPIR target info as
starter.

Enable testing for SPIR-V target in many existing code generation
related clang tests where the SPIR target is tested and added two new
tests. SYCL related tests were skipped - they are left for SYCL
developers to decide if they want to enable or switch to SPIR-V
target.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109144

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/SPIR.cpp
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Headers/opencl-c.h
  clang/test/CodeGen/complex-math.c
  clang/test/CodeGen/ext-int-cc.c
  clang/test/CodeGen/spir-half-type.cpp
  clang/test/CodeGen/target-data.c
  clang/test/CodeGenCXX/builtin-calling-conv.cpp
  clang/test/CodeGenOpenCL/as_type.cl
  clang/test/CodeGenOpenCL/atomic-ops-libcall.cl
  clang/test/CodeGenOpenCL/blocks.cl
  clang/test/CodeGenOpenCL/cast_image.cl
  clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
  clang/test/CodeGenOpenCL/constant-addr-space-globals.cl
  clang/test/CodeGenOpenCL/enqueue-kernel-non-entry-block.cl
  clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl
  clang/test/CodeGenOpenCL/fpmath.cl
  clang/test/CodeGenOpenCL/half.cl
  clang/test/CodeGenOpenCL/kernel-arg-info.cl
  clang/test/CodeGenOpenCL/opencl_types.cl
  clang/test/CodeGenOpenCL/overload.cl
  clang/test/CodeGenOpenCL/partial_initializer.cl
  clang/test/CodeGenOpenCL/preserve_vec3.cl
  clang/test/CodeGenOpenCL/printf.cl
  clang/test/CodeGenOpenCL/private-array-initialization.cl
  clang/test/CodeGenOpenCL/sampler.cl
  clang/test/CodeGenOpenCL/size_t.cl
  clang/test/CodeGenOpenCL/spir-calling-conv.cl
  clang/test/CodeGenOpenCL/spir-debug-info-pointer-address-space.cl
  clang/test/CodeGenOpenCL/spirv32_target.cl
  clang/test/CodeGenOpenCL/spirv64_target.cl
  clang/test/CodeGenOpenCL/to_addr_builtin.cl
  clang/test/CodeGenOpenCL/vectorLoadStore.cl
  clang/test/CodeGenOpenCL/vla.cl
  clang/test/CodeGenOpenCLCXX/address-space-castoperators.cpp
  clang/test/CodeGenOpenCLCXX/address-space-deduction.clcpp
  clang/test/CodeGenOpenCLCXX/address-space-deduction2.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-conversion.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-new-delete.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-of-this.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-operators.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-references.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-with-class.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace_cast.clcpp
  clang/test/CodeGenOpenCLCXX/atexit.clcpp
  clang/test/CodeGenOpenCLCXX/constexpr.clcpp
  clang/test/CodeGenOpenCLCXX/global_init.clcpp
  clang/test/CodeGenOpenCLCXX/local_addrspace_init.clcpp
  clang/test/CodeGenOpenCLCXX/method-overload-address-space.clcpp
  clang/test/CodeGenOpenCLCXX/reinterpret_cast.clcpp
  clang/test/CodeGenOpenCLCXX/template-address-spaces.clcpp
  clang/test/Driver/opencl.cl
  clang/test/Headers/opencl-builtins.cl
  clang/test/Headers/opencl-c-header.cl
  clang/test/Index/pipe-size.cl
  clang/test/Preprocessor/predefined-macros.c
  clang/test/Sema/Float16.c
  clang/test/SemaCXX/Float16.cpp
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp
  llvm/unittests/ADT/TripleTest.cpp

Index: llvm/unittests/ADT/TripleTest.cpp
===
--- llvm/unittests/ADT/TripleTest.cpp
+++ llvm/unittests/ADT/TripleTest.cpp
@@ -224,6 +224,21 @@
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::UnknownOS, T.getOS());
 
+  T = Triple("spirv32-unknown-unknown");
+  EXPECT_EQ(Triple::spirv32, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::UnknownOS, T.getOS());
+
+  T = Triple("spirv64-unknown-unknown");
+  EXPECT_EQ(Triple::spirv64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::UnknownOS, T.getOS());
+
+  T = Triple("spirvlogical-unknown-unknown");
+  EXPECT_EQ(Triple::spirvlogical, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::UnknownOS, T.getOS());

[PATCH] D106809: [clang-offload-bundler] Make Bundle Entry ID backward compatible

2021-09-02 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 370219.
saiislam added a comment.

Added test cases for compatibility old and new formats of bundle entry id.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106809

Files:
  clang/docs/ClangOffloadBundler.rst
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Driver/hip-rdc-device-only.hip
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -134,21 +134,32 @@
 ///  * Offload Kind - Host, OpenMP, or HIP
 ///  * Triple - Standard LLVM Triple
 ///  * GPUArch (Optional) - Processor name, like gfx906 or sm_30
-/// In presence of Proc, the Triple should contain separator "-" for all
-/// standard four components, even if they are empty.
+
 struct OffloadTargetInfo {
   StringRef OffloadKind;
   llvm::Triple Triple;
   StringRef GPUArch;
 
   OffloadTargetInfo(const StringRef Target) {
-SmallVector Components;
-Target.split(Components, '-', 5);
-Components.resize(6);
-this->OffloadKind = Components[0];
-this->Triple = llvm::Triple(Components[1], Components[2], Components[3],
-Components[4]);
-this->GPUArch = Components[5];
+auto TargetFeatures = Target.split(':');
+auto TripleOrGPU = TargetFeatures.first.rsplit('-');
+
+// Check if the last option before any colon is a triple field or a GPU name
+if (TripleOrGPU.second.startswith("gfx") ||
+TripleOrGPU.second.startswith("sm_")) {
+  auto KindTriple = TripleOrGPU.first.split('-');
+  this->OffloadKind = KindTriple.first;
+  this->Triple = llvm::Triple(KindTriple.second);
+  auto TID = Target.substr(Target.find("gfx"));
+  if (TID.empty())
+TID = Target.substr(Target.find("sm_"));
+  this->GPUArch = TID;
+} else {
+  auto KindTriple = TargetFeatures.first.split('-');
+  this->OffloadKind = KindTriple.first;
+  this->Triple = llvm::Triple(KindTriple.second);
+  this->GPUArch = "";
+}
   }
 
   bool hasHostKind() const { return this->OffloadKind == "host"; }
@@ -1063,9 +1074,10 @@
 
   // Compatible in case of exact match.
   if (CodeObjectInfo == TargetInfo) {
-DEBUG_WITH_TYPE(
-"CodeObjectCompatibility",
-dbgs() << "Compatible: Exact match: " << CodeObjectInfo.str() << "\n");
+DEBUG_WITH_TYPE("CodeObjectCompatibility",
+dbgs() << "Compatible: Exact match: \t[CodeObject: "
+   << CodeObjectInfo.str()
+   << "]\t:\t[Target: " << TargetInfo.str() << "]\n");
 return true;
   }
 
@@ -1279,6 +1291,16 @@
 "' in heterogenous archive library: " + IFName)
   .str();
   return createStringError(inconvertibleErrorCode(), ErrMsg);
+} else { // Create an empty archive file if no compatible code object is
+ // found and "allow-missing-bundles" is enabled. It ensures that
+ // the linker using output of this step doesn't complain about
+ // the missing input file.
+  std::vector EmptyArchive;
+  EmptyArchive.clear();
+  if (Error WriteErr = writeArchive(FileName, EmptyArchive, true,
+getDefaultArchiveKindForHost(), true,
+false, nullptr))
+return WriteErr;
 }
   }
 
Index: clang/test/Driver/hip-toolchain-rdc-separate.hip
===
--- clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -44,7 +44,7 @@
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
-// CHECK-SAME: "-targets=hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx900,host-x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-targets=hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900,host-x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-outputs=[[A_O:.*a.o]]" "-inputs=[[A_BC1]],[[A_BC2]],[[A_OBJ_HOST]]"
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
@@ -79,7 +79,7 @@
 // CHECK-SAME: {{.*}} [[B_SRC]]
 
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
-// CHECK-SAME: "-targets=hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx900,host-x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-targets=hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900,host-x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-outputs=[[B_O:.*b.o]]" "-inputs=[[B_BC1]],[[B_BC2]],[[B_OBJ_HOST]]"
 
 // RUN: touch %T/a.o
@@ -91,22 +91,22 @@
 // RUN: 2>&1 | FileCheck -check-prefix=LINK %s
 
 // LINK: [[

[PATCH] D108584: [clangd] Use the active file's language for hover code blocks

2021-09-02 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.

thanks, lgtm!




Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:968
+// fixed one to make sure tests passes on different platform.
+TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
+auto AST = TU.build();

nit: we can drop that since we're only checking for definition language field.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108584

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


[PATCH] D108696: [Coroutines] [Frontend] Lookup in std namespace first

2021-09-02 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11015
+  "coroutine_traits defined in std::experimental namespace is deprecated. "
+  "Considering update libcxx and include  instead of 
.">,
+  InGroup;

avogelsgesang wrote:
> Considering update -> Consider updating
Done. Thanks for suggestion!


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

https://reviews.llvm.org/D108696

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


[PATCH] D108695: [analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it

2021-09-02 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

Thanks! My concerns are addressed, looks good to me!


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

https://reviews.llvm.org/D108695

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


[clang] 9722e8f - [clang] NFC: Remove duplicate DependentSizedMatrixType methods

2021-09-02 Thread Cullen Rhodes via cfe-commits

Author: Cullen Rhodes
Date: 2021-09-02T10:46:20Z
New Revision: 9722e8ff9eab9ec9c0d8fc0008fd368f93210ba5

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

LOG: [clang] NFC: Remove duplicate DependentSizedMatrixType methods

Inherited from MatrixType.

Reviewed By: fhahn

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

Added: 


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

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index fc83c895afa2e..49ff9861d165f 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -3524,14 +3524,10 @@ class DependentSizedMatrixType final : public 
MatrixType {
Expr *ColumnExpr, SourceLocation loc);
 
 public:
-  QualType getElementType() const { return ElementType; }
   Expr *getRowExpr() const { return RowExpr; }
   Expr *getColumnExpr() const { return ColumnExpr; }
   SourceLocation getAttributeLoc() const { return loc; }
 
-  bool isSugared() const { return false; }
-  QualType desugar() const { return QualType(this, 0); }
-
   static bool classof(const Type *T) {
 return T->getTypeClass() == DependentSizedMatrix;
   }



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


[PATCH] D109137: [clang] NFC: Remove duplicate DependentSizedMatrixType methods

2021-09-02 Thread Cullen Rhodes 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 rG9722e8ff9eab: [clang] NFC: Remove duplicate 
DependentSizedMatrixType methods (authored by c-rhodes).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109137

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


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -3524,14 +3524,10 @@
Expr *ColumnExpr, SourceLocation loc);
 
 public:
-  QualType getElementType() const { return ElementType; }
   Expr *getRowExpr() const { return RowExpr; }
   Expr *getColumnExpr() const { return ColumnExpr; }
   SourceLocation getAttributeLoc() const { return loc; }
 
-  bool isSugared() const { return false; }
-  QualType desugar() const { return QualType(this, 0); }
-
   static bool classof(const Type *T) {
 return T->getTypeClass() == DependentSizedMatrix;
   }


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -3524,14 +3524,10 @@
Expr *ColumnExpr, SourceLocation loc);
 
 public:
-  QualType getElementType() const { return ElementType; }
   Expr *getRowExpr() const { return RowExpr; }
   Expr *getColumnExpr() const { return ColumnExpr; }
   SourceLocation getAttributeLoc() const { return loc; }
 
-  bool isSugared() const { return false; }
-  QualType desugar() const { return QualType(this, 0); }
-
   static bool classof(const Type *T) {
 return T->getTypeClass() == DependentSizedMatrix;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107647: [PowerPC] MMA - Add __builtin_vsx_build_pair and __builtin_mma_build_acc builtins

2021-09-02 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai requested changes to this revision.
nemanjai added a comment.
This revision now requires changes to proceed.

There are some questions to answer here before proceeding:

1. Why do we not get paired vector loads and stores in the back end test cases 
for either little or big endian and regardless of whether we use the old or new 
builtins/intrinsics?
2. Is the code generated the same as that for GCC when:
  - The inputs are all from registers
  - The inputs are all from memory
  - The inputs are a mix of memory and registers
3. What do execution tests show for both little endian and big endian targets? 
Namely, write execution test cases that do everything mentioned in 2. above for 
both sets of builtins and confirm:
  - The behaviour is the same both with GCC and Clang for both LE and BE
  - The behaviour for new builtins is the same on LE and BE with both GCC and 
Clang
  - The behaviour for old builtins is different on LE and BE with both GCC and 
Clang

I am requesting changes until these questions are adequately addressed.




Comment at: llvm/include/llvm/IR/IntrinsicsPowerPC.td:1442
 
+  def int_ppc_vsx_build_pair :
+Intrinsic<[llvm_v256i1_ty],

I find the need for this rather surprising. The new builtins should do the 
exact same thing as the old builtins but with elements in reversed order. So 
why do we need new intrinsics? Can we not just call the old intrinsics in the 
front end codegen but with arguments in reversed order?



Comment at: llvm/test/CodeGen/PowerPC/paired-vector-intrinsics.ll:73
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:vmr v3, v2
+; CHECK-BE-NEXT:stxv v2, 16(r3)

This indicates some kind of problem. Why are we moving a value from `v2` to 
`v3` and then not using `v3`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107647

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


[PATCH] D102531: PR45881: Properly use CXXThisOverride for templated lambda

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

LGTM, but please wait a day or so before landing in case @rsmith spots 
something I've missed (the only change I wasn't 100% certain on was lifting the 
assert predicate; it seems correct to me, but I'm wary of removing asserts).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102531

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


[PATCH] D109126: [PowerPC] [NFC] Add Big-Endian checks for existing MMA tests

2021-09-02 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

LGTM. Please update the description and commit message as to why this is being 
added.




Comment at: clang/test/CodeGen/builtins-ppc-pair-mma.c:5
+// RUN: %clang_cc1 -O3 -triple powerpc64-unknown-unknown -target-cpu pwr10 \
+// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-BE
 

qiucf wrote:
> Seems just adding `%clang_cc1 -O3 -triple powerpc64-unknown-unknown 
> -target-cpu pwr10 -emit-llvm %s -o - | FileCheck %s` also makes the test 
> pass. `CHECK` and `CHECK-BE` contents are the same.
The existing builtins produce the same IR but I think this is done in 
preparation for https://reviews.llvm.org/D107647 which will add builtins very 
similar to these but that produce different IR on LE and BE. The description of 
the patch should probably mention that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109126

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


[PATCH] D109002: [OpenCL] Supports optional image types in C++ for OpenCL 2021

2021-09-02 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna updated this revision to Diff 370237.
Topotuna added a comment.

Boolean variable renamed to `IsOpenCLC30Compatible`. `FIXME` comment added.


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

https://reviews.llvm.org/D109002

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCL/unsupported-image.cl


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images %s
 
 #if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1725,7 +1725,12 @@
 
   if (S.getLangOpts().OpenCL) {
 const auto &OpenCLOptions = S.getOpenCLOptions();
+// FIXME: both variables IsOpenCLC30 and IsOpenCLC30Compatible should be
+// unified into one when __opencl_c_3d_image_writes option is enables in
+// C++ for OpenCL 2021
 bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
+bool IsOpenCLC30Compatible =
+S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
 // support.
 // OpenCL C v3.0 s6.2.1 - OpenCL 3d image write types requires support
@@ -1734,7 +1739,7 @@
 // that support OpenCL 3.0, cl_khr_3d_image_writes must be returned when 
and
 // only when the optional feature is supported
 if ((Result->isImageType() || Result->isSamplerT()) &&
-(IsOpenCLC30 &&
+(IsOpenCLC30Compatible &&
  !OpenCLOptions.isSupported("__opencl_c_images", S.getLangOpts( {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
   << 0 << Result << "__opencl_c_images";


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=+__opencl_c_images %s
 
 #if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1725,7 +1725,12 @@
 
   if (S.getLangOpts().OpenCL) {
 const auto &OpenCLOptions = S.getOpenCLOptions();
+// FIXME: both variables IsOpenCLC30 and IsOpenCLC30Compatible should be
+// unified into one when __opencl_c_3d_image_writes option is enables in
+// C++ for OpenCL 2021
 bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
+bool IsOpenCLC30Compatible =
+S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
 // support.
 // OpenCL C v3.0 s6.2.1 - OpenCL 3d image write types requires support
@@ -1734,7 +1739,7 @@
 // that support OpenCL 3.0, cl_khr_3d_image_writes must be returned when and
 // only when the optional feature is supported
 if ((Result->isImageType() || Result->isSamplerT()) &&
-(IsOpenCLC30 &&
+   

[PATCH] D109002: [OpenCL] Supports optional image types in C++ for OpenCL 2021

2021-09-02 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna marked an inline comment as done.
Topotuna added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:1729
 bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
+bool IsOpenCLC30Comp = S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images

Anastasia wrote:
> Topotuna wrote:
> > Anastasia wrote:
> > > I think we should just replace `IsOpenCLC30` as it is when only used in 
> > > the diagnostic that we should report the same as for OpenCL 3.0.
> > > 
> > > 
> > > Also I would suggest changing name to `IsOpenCLC30Compatible` to make it 
> > > clearer. 
> > That diagnostic is responsible for `__opencl_c_3d_image_writes` feature 
> > while current commit addresses `__opencl_c_images`. I wanted to keep 
> > commits separate and was planning to finish transitioning from 
> > `IsOpenCLC30` to `IsOpenCLC30Compatible` in a future commit.
> > 
> > I agree that `IsOpenCLC30Compatible` would be clearer. Thank you.
> Ok, let's just only rename it for now and add a FIXME comment explaining that 
> the variables should be unified later on.
> 
> I suspect your subsequent commits would include the unification?
Yes, I will perform unification when adding support for 
`__opencl_c_3d_image_writes` optional core feature.


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

https://reviews.llvm.org/D109002

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


[PATCH] D108918: [clang] NFC: Extract DiagnosticOptions parsing

2021-09-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 370238.
jansvoboda11 added a comment.

Switch to unique_ptr, leave -fno-intergrated-cc1 behind.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108918

Files:
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
  clang/lib/Tooling/Tooling.cpp
  clang/tools/driver/driver.cpp

Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -278,27 +278,6 @@
   DiagClient->setPrefix(std::string(ExeBasename));
 }
 
-// This lets us create the DiagnosticsEngine with a properly-filled-out
-// DiagnosticOptions instance.
-static DiagnosticOptions *
-CreateAndPopulateDiagOpts(ArrayRef argv, bool &UseNewCC1Process) {
-  auto *DiagOpts = new DiagnosticOptions;
-  unsigned MissingArgIndex, MissingArgCount;
-  InputArgList Args = getDriverOptTable().ParseArgs(
-  argv.slice(1), MissingArgIndex, MissingArgCount);
-  // We ignore MissingArgCount and the return value of ParseDiagnosticArgs.
-  // Any errors that would be diagnosed here will also be diagnosed later,
-  // when the DiagnosticsEngine actually exists.
-  (void)ParseDiagnosticArgs(*DiagOpts, Args);
-
-  UseNewCC1Process =
-  Args.hasFlag(clang::driver::options::OPT_fno_integrated_cc1,
-   clang::driver::options::OPT_fintegrated_cc1,
-   /*Default=*/CLANG_SPAWN_CC1);
-
-  return DiagOpts;
-}
-
 static void SetInstallDir(SmallVectorImpl &argv,
   Driver &TheDriver, bool CanonicalPrefixes) {
   // Attempt to find the original path used to invoke the driver, to determine
@@ -459,10 +438,15 @@
   // should spawn a new clang subprocess (old behavior).
   // Not having an additional process saves some execution time of Windows,
   // and makes debugging and profiling easier.
-  bool UseNewCC1Process;
+  bool UseNewCC1Process = CLANG_SPAWN_CC1;
+  for (const char *Arg : Args)
+UseNewCC1Process = llvm::StringSwitch(Arg)
+   .Case("-fno-integrated-cc1", true)
+   .Case("-fintegrated-cc1", false)
+   .Default(UseNewCC1Process);
 
   IntrusiveRefCntPtr DiagOpts =
-  CreateAndPopulateDiagOpts(Args, UseNewCC1Process);
+  CreateAndPopulateDiagOpts(Args);
 
   TextDiagnosticPrinter *DiagClient
 = new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -343,11 +343,8 @@
   for (const std::string &Str : CommandLine)
 Argv.push_back(Str.c_str());
   const char *const BinaryName = Argv[0];
-  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
-  unsigned MissingArgIndex, MissingArgCount;
-  llvm::opt::InputArgList ParsedArgs = driver::getDriverOptTable().ParseArgs(
-  ArrayRef(Argv).slice(1), MissingArgIndex, MissingArgCount);
-  ParseDiagnosticArgs(*DiagOpts, ParsedArgs);
+  IntrusiveRefCntPtr DiagOpts =
+  CreateAndPopulateDiagOpts(Argv);
   TextDiagnosticPrinter DiagnosticPrinter(
   llvm::errs(), &*DiagOpts);
   DiagnosticsEngine Diagnostics(
Index: clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
===
--- clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
+++ clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
@@ -91,12 +91,8 @@
   llvm::transform(Args, Argv.begin(),
   [](const std::string &Arg) { return Arg.c_str(); });
 
-  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
-  unsigned MissingArgIndex, MissingArgCount;
-  auto Opts = driver::getDriverOptTable();
-  auto ParsedArgs = Opts.ParseArgs(llvm::makeArrayRef(Argv).slice(1),
-   MissingArgIndex, MissingArgCount);
-  ParseDiagnosticArgs(*DiagOpts, ParsedArgs);
+  IntrusiveRefCntPtr DiagOpts =
+  CreateAndPopulateDiagOpts(Argv);
 
   // Don't output diagnostics, because common scenarios such as
   // cross-compiling fail with diagnostics.  This is not fatal, but
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -147,15 +147,10 @@
   // Buffer diagnostics from argument parsing so that we can output them using a
   // well formed diagnostic object.
   IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
-  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  IntrusiveRefCntPtr DiagOpts =
+  CreateAndPopulateDiagOpts(ClangArgv);
   TextDiagnosticBuffer *DiagsBuffer = new TextDiagnosticBuffer;
   DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagsBuffer);
-  u

[clang] 555a817 - [clang] NFC: Extract DiagnosticOptions parsing

2021-09-02 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-09-02T14:37:14+02:00
New Revision: 555a817d1dac5d88fdb445cd7c93cf66b769bc37

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

LOG: [clang] NFC: Extract DiagnosticOptions parsing

The way we parse `DiagnosticOptions` is a bit involved.

`DiagnosticOptions` are parsed as part of the cc1-parsing function 
`CompilerInvocation::CreateFromArgs` which takes `DiagnosticsEngine` as an 
argument to be able to report errors in command-line arguments. But to create 
`DiagnosticsEngine`, `DiagnosticOptions` are needed. This is solved by exposing 
the `ParseDiagnosticArgs` to clients and making its `DiagnosticsEngine` 
argument optional, essentially breaking the dependency cycle.

The `ParseDiagnosticArgs` function takes `llvm::opt::ArgList &`, which each 
client needs to create from the command-line (typically represented as 
`std::vector`). Creating this data structure in this context is 
somewhat particular. This code pattern is copy-pasted in some places across the 
upstream code base and also in downstream repos. To make things a bit more 
uniform, this patch extracts the code into a new reusable function: 
`CreateAndPopulateDiagOpts`.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Frontend/CompilerInvocation.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Interpreter/Interpreter.cpp
clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
clang/lib/Tooling/Tooling.cpp
clang/tools/driver/driver.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/CompilerInvocation.h 
b/clang/include/clang/Frontend/CompilerInvocation.h
index 2245439d06326..922c84a3bee2c 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -50,6 +50,11 @@ class HeaderSearchOptions;
 class PreprocessorOptions;
 class TargetOptions;
 
+// This lets us create the DiagnosticsEngine with a properly-filled-out
+// DiagnosticOptions instance.
+std::unique_ptr
+CreateAndPopulateDiagOpts(ArrayRef Argv);
+
 /// Fill out Opts based on the options given in Args.
 ///
 /// Args must have been created from the OptTable returned by

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 64800b19708bb..0da2cb3e2ebe5 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2256,6 +2256,19 @@ void CompilerInvocation::GenerateDiagnosticArgs(
   }
 }
 
+std::unique_ptr
+clang::CreateAndPopulateDiagOpts(ArrayRef Argv) {
+  auto DiagOpts = std::make_unique();
+  unsigned MissingArgIndex, MissingArgCount;
+  InputArgList Args = getDriverOptTable().ParseArgs(
+  Argv.slice(1), MissingArgIndex, MissingArgCount);
+  // We ignore MissingArgCount and the return value of ParseDiagnosticArgs.
+  // Any errors that would be diagnosed here will also be diagnosed later,
+  // when the DiagnosticsEngine actually exists.
+  (void)ParseDiagnosticArgs(*DiagOpts, Args);
+  return DiagOpts;
+}
+
 bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
 DiagnosticsEngine *Diags,
 bool DefaultDiagColor) {

diff  --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index 937504f34739f..3e8d3884049ba 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -147,15 +147,10 @@ IncrementalCompilerBuilder::create(std::vector &ClangArgv) {
   // Buffer diagnostics from argument parsing so that we can output them using 
a
   // well formed diagnostic object.
   IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
-  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  IntrusiveRefCntPtr DiagOpts =
+  CreateAndPopulateDiagOpts(ClangArgv);
   TextDiagnosticBuffer *DiagsBuffer = new TextDiagnosticBuffer;
   DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagsBuffer);
-  unsigned MissingArgIndex, MissingArgCount;
-  const llvm::opt::OptTable &Opts = driver::getDriverOptTable();
-  llvm::opt::InputArgList ParsedArgs =
-  Opts.ParseArgs(ArrayRef(ClangArgv).slice(1),
- MissingArgIndex, MissingArgCount);
-  ParseDiagnosticArgs(*DiagOpts, ParsedArgs, &Diags);
 
   driver::Driver Driver(/*MainBinaryName=*/ClangArgv[0],
 llvm::sys::getProcessTriple(), Diags);

diff  --git a/clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp 
b/clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
index 8091a467d056c..9c825428f2ea7 100644
--- a/clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
+++ b/clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
@@ -91,12 +91,8 @@ int main(int argc, const char **argv) {
   ll

[PATCH] D108918: [clang] NFC: Extract DiagnosticOptions parsing

2021-09-02 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 rG555a817d1dac: [clang] NFC: Extract DiagnosticOptions parsing 
(authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108918

Files:
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
  clang/lib/Tooling/Tooling.cpp
  clang/tools/driver/driver.cpp

Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -278,27 +278,6 @@
   DiagClient->setPrefix(std::string(ExeBasename));
 }
 
-// This lets us create the DiagnosticsEngine with a properly-filled-out
-// DiagnosticOptions instance.
-static DiagnosticOptions *
-CreateAndPopulateDiagOpts(ArrayRef argv, bool &UseNewCC1Process) {
-  auto *DiagOpts = new DiagnosticOptions;
-  unsigned MissingArgIndex, MissingArgCount;
-  InputArgList Args = getDriverOptTable().ParseArgs(
-  argv.slice(1), MissingArgIndex, MissingArgCount);
-  // We ignore MissingArgCount and the return value of ParseDiagnosticArgs.
-  // Any errors that would be diagnosed here will also be diagnosed later,
-  // when the DiagnosticsEngine actually exists.
-  (void)ParseDiagnosticArgs(*DiagOpts, Args);
-
-  UseNewCC1Process =
-  Args.hasFlag(clang::driver::options::OPT_fno_integrated_cc1,
-   clang::driver::options::OPT_fintegrated_cc1,
-   /*Default=*/CLANG_SPAWN_CC1);
-
-  return DiagOpts;
-}
-
 static void SetInstallDir(SmallVectorImpl &argv,
   Driver &TheDriver, bool CanonicalPrefixes) {
   // Attempt to find the original path used to invoke the driver, to determine
@@ -459,10 +438,15 @@
   // should spawn a new clang subprocess (old behavior).
   // Not having an additional process saves some execution time of Windows,
   // and makes debugging and profiling easier.
-  bool UseNewCC1Process;
+  bool UseNewCC1Process = CLANG_SPAWN_CC1;
+  for (const char *Arg : Args)
+UseNewCC1Process = llvm::StringSwitch(Arg)
+   .Case("-fno-integrated-cc1", true)
+   .Case("-fintegrated-cc1", false)
+   .Default(UseNewCC1Process);
 
   IntrusiveRefCntPtr DiagOpts =
-  CreateAndPopulateDiagOpts(Args, UseNewCC1Process);
+  CreateAndPopulateDiagOpts(Args);
 
   TextDiagnosticPrinter *DiagClient
 = new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -343,11 +343,8 @@
   for (const std::string &Str : CommandLine)
 Argv.push_back(Str.c_str());
   const char *const BinaryName = Argv[0];
-  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
-  unsigned MissingArgIndex, MissingArgCount;
-  llvm::opt::InputArgList ParsedArgs = driver::getDriverOptTable().ParseArgs(
-  ArrayRef(Argv).slice(1), MissingArgIndex, MissingArgCount);
-  ParseDiagnosticArgs(*DiagOpts, ParsedArgs);
+  IntrusiveRefCntPtr DiagOpts =
+  CreateAndPopulateDiagOpts(Argv);
   TextDiagnosticPrinter DiagnosticPrinter(
   llvm::errs(), &*DiagOpts);
   DiagnosticsEngine Diagnostics(
Index: clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
===
--- clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
+++ clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
@@ -91,12 +91,8 @@
   llvm::transform(Args, Argv.begin(),
   [](const std::string &Arg) { return Arg.c_str(); });
 
-  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
-  unsigned MissingArgIndex, MissingArgCount;
-  auto Opts = driver::getDriverOptTable();
-  auto ParsedArgs = Opts.ParseArgs(llvm::makeArrayRef(Argv).slice(1),
-   MissingArgIndex, MissingArgCount);
-  ParseDiagnosticArgs(*DiagOpts, ParsedArgs);
+  IntrusiveRefCntPtr DiagOpts =
+  CreateAndPopulateDiagOpts(Argv);
 
   // Don't output diagnostics, because common scenarios such as
   // cross-compiling fail with diagnostics.  This is not fatal, but
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -147,15 +147,10 @@
   // Buffer diagnostics from argument parsing so that we can output them using a
   // well formed diagnostic object.
   IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
-  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  IntrusiveRefCntPtr DiagOpts =
+  CreateAndPopulateDiagOpts(ClangArgv);
   TextDiagnosticBuffer *DiagsB

[PATCH] D109150: [OpenCL] Disallows static kernel functions in C++ for OpenCL

2021-09-02 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It is disallowed in OpenCL C to declare static kernel functions and
C++ for OpenCL is expected to inherit such behaviour. Error is now
correctly reported in C++ for OpenCL when declaring a static kernel
function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109150

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaOpenCL/storageclass-cl20.cl


Index: clang/test/SemaOpenCL/storageclass-cl20.cl
===
--- clang/test/SemaOpenCL/storageclass-cl20.cl
+++ clang/test/SemaOpenCL/storageclass-cl20.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
 
 int G2 = 0;
 global int G3 = 0;
@@ -18,6 +19,9 @@
 extern private float g_private_extern_var; // expected-error {{extern variable 
must reside in global or constant address space}}
 extern generic float g_generic_extern_var; // expected-error {{extern variable 
must reside in global or constant address space}}
 
+static void kernel bar() { // expected-error{{kernel functions cannot be 
declared static}}
+}
+
 void kernel foo() {
   constant int L1 = 0;
   local int L2;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -9969,8 +9969,8 @@
 
   if (getLangOpts().OpenCL && NewFD->hasAttr()) {
 // OpenCL v1.2 s6.8 static is invalid for kernel functions.
-if ((getLangOpts().OpenCLVersion >= 120)
-&& (SC == SC_Static)) {
+if ((getLangOpts().getOpenCLCompatibleVersion() >= 120) &&
+(SC == SC_Static)) {
   Diag(D.getIdentifierLoc(), diag::err_static_kernel);
   D.setInvalidType();
 }


Index: clang/test/SemaOpenCL/storageclass-cl20.cl
===
--- clang/test/SemaOpenCL/storageclass-cl20.cl
+++ clang/test/SemaOpenCL/storageclass-cl20.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
 
 int G2 = 0;
 global int G3 = 0;
@@ -18,6 +19,9 @@
 extern private float g_private_extern_var; // expected-error {{extern variable must reside in global or constant address space}}
 extern generic float g_generic_extern_var; // expected-error {{extern variable must reside in global or constant address space}}
 
+static void kernel bar() { // expected-error{{kernel functions cannot be declared static}}
+}
+
 void kernel foo() {
   constant int L1 = 0;
   local int L2;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -9969,8 +9969,8 @@
 
   if (getLangOpts().OpenCL && NewFD->hasAttr()) {
 // OpenCL v1.2 s6.8 static is invalid for kernel functions.
-if ((getLangOpts().OpenCLVersion >= 120)
-&& (SC == SC_Static)) {
+if ((getLangOpts().getOpenCLCompatibleVersion() >= 120) &&
+(SC == SC_Static)) {
   Diag(D.getIdentifierLoc(), diag::err_static_kernel);
   D.setInvalidType();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109144: [SPIR-V] Add SPIR-V triple architecture and clang target info

2021-09-02 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Generally LGTM!

I only have one suggestion regarding testing - I feel that it makes more sense 
to just omit the tests that are not specific to the target itself. This is 
mainly because SPIR-V is now inherited from SPIR so the same logic applies in 
most of places. I think it would make sense that we only add tests for the 
logic which is not identical to SPIR. For example, tests that verify the target 
properties and target specific macros, etc make sense to keep but most of the 
tests that are just checking the language semantic using SPIR triple are not 
going to be different for SPIR-V (at least not now). So we can slowly build up 
relevant testing in the subsequent patches and therefore avoid unnessasary test 
time increase.




Comment at: clang/lib/Basic/Targets.cpp:609
   }
+  case llvm::Triple::spirv32: {
+if (os != llvm::Triple::UnknownOS ||

I wonder how complete is the support of logical addressing SPIR-V triple? It 
seems like you don't test it in the clang invocation at the moment and it is 
therefore missing from `TargetInfo`. 

Do you have plans to implement it in the subsequent patches? If not it might be 
better to leave it out for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109144

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


[PATCH] D108918: [clang] NFC: Extract DiagnosticOptions parsing

2021-09-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2270-2274
+  if (UseNewCC1Process)
+*UseNewCC1Process =
+Args.hasFlag(clang::driver::options::OPT_fno_integrated_cc1,
+ clang::driver::options::OPT_fintegrated_cc1,
+ /*Default=*/CLANG_SPAWN_CC1);

dexonsmith wrote:
> I don't think `-fintegrated-cc1` is related to diagnostic options. I suggest 
> leaving it behind in the driver code and using:
> ```
> lang=c++
> std::unique_ptr
> clang::createAndPopulateDiagOpts(ArrayRef Argv) {
>   return createAndPopulateDiagOptsImpl(Argv);
> }
> ```
I left the `-fintegrated-cc1`-related code in the function, since it works on 
the parsed `InputArgList`. The whole point of this function is to free its 
clients of parsing the command-line options into `InputArgList`. If we leave 
`-fintegrated-cc1`-related code in the driver, we'll need to parse the 
arguments into `InputArgList` twice (not a big fan of that), or iterate over 
the raw command-line manually (not a big fan of that either, but should be more 
efficient). I decided to leave the code in the driver and go with the second 
option. Let me know it that doesn't seem reasonable to you and I can revisit 
this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108918

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


[PATCH] D109144: [SPIR-V] Add SPIR-V triple architecture and clang target info

2021-09-02 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added subscribers: svenvh, bader.
Anastasia added a comment.

CC: @bader @svenvh


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109144

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


[PATCH] D108979: [clang][deps] NFC: Stop going through ClangTool

2021-09-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

I think `ToolInvocation` is somewhat well-suited for the dependency scanner. It 
takes care of the `DiagnosticOptions` setup, running the driver, extracting 
source-reading cc1 command-line, creating `CompilerInvocation` and invoking the 
action itself. This is what we'd need to do anyways.

I agree that the `std::vector` interface is unfortunate, 
especially since `ToolInvocation::run` converts that into `std::vector` anyways. I think we can move that conversion into the current 
constructor that accepts `std::vector`, add another constructor 
that takes `ArrayRef` and use that from the dependency scanner.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108979

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


[PATCH] D108753: [analyzer] MallocChecker: Add notes from NoOwnershipChangeVisitor only when a function "intents", but doesn't change ownership, enable by default

2021-09-02 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:281-288
 /// Tells if the callee is one of the builtin new/delete operators, including
 /// placement operators and other standard overloads.
 static bool isStandardNewDelete(const FunctionDecl *FD);
 static bool isStandardNewDelete(const CallEvent &Call) {
   if (!Call.getDecl() || !isa(Call.getDecl()))
 return false;
   return isStandardNewDelete(cast(Call.getDecl()));

These serve to identify new/delete operators. I've done a lot of work to make 
this better, but I don't remember why `isFreeingCall` doesn't call these.



Comment at: clang/test/Analysis/NewDeleteLeaks.cpp:23
 
+// TODO: AST analysis of sink would reveal that it doesn't indent to free the
+// allocated memory, but in this instance, its also the only function with

martong wrote:
> intent
> 
> BTW, why is this TODO here? It is obvious that `sink` does not have a 
> `delete`, so we don't expect any warning. Or am I missing something?
Well, its debatable, I suppose, but in this case, `sink` is noteworthy, as no 
other function had the ability to take care of this memory.

https://lists.llvm.org/pipermail/cfe-dev/2021-June/068469.html
> Kristof's case is interesting in a different manner. If taken literally, it 
> doesn't satisfy our criteria of "there exists another execution path on which 
> it did actually do ${Something}". We probably shouldn't emit a note every 
> time the function simply accepts the value of interest by pointer, because 
> this doesn't necessarily prove the intent to delete the pointer; there are a 
> million other reasons to accept a pointer. However, Kristof's case does still 
> deserve a note because sink() is the *only* function that had a chance to 
> delete the pointer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108753

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


[PATCH] D108976: [clang][tooling] Allow providing custom diagnostic options to ToolInvocation

2021-09-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 370257.
jansvoboda11 added a comment.

Reorder patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108976

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


Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -343,10 +343,17 @@
   for (const std::string &Str : CommandLine)
 Argv.push_back(Str.c_str());
   const char *const BinaryName = Argv[0];
-  IntrusiveRefCntPtr DiagOpts =
-  CreateAndPopulateDiagOpts(Argv);
-  TextDiagnosticPrinter DiagnosticPrinter(
-  llvm::errs(), &*DiagOpts);
+
+  // Parse diagnostic options from the driver command-line only if none were
+  // explicitly set.
+  IntrusiveRefCntPtr ParsedDiagOpts;
+  DiagnosticOptions *DiagOpts = this->DiagOpts;
+  if (!DiagOpts) {
+ParsedDiagOpts = CreateAndPopulateDiagOpts(Argv);
+DiagOpts = &*ParsedDiagOpts;
+  }
+
+  TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), DiagOpts);
   DiagnosticsEngine Diagnostics(
   IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts,
   DiagConsumer ? DiagConsumer : &DiagnosticPrinter, false);
Index: clang/include/clang/Tooling/Tooling.h
===
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -268,11 +268,17 @@
 
   ~ToolInvocation();
 
-  /// Set a \c DiagnosticConsumer to use during parsing.
+  /// Set a \c DiagnosticConsumer to use during driver command-line parsing and
+  /// the action invocation itself.
   void setDiagnosticConsumer(DiagnosticConsumer *DiagConsumer) {
 this->DiagConsumer = DiagConsumer;
   }
 
+  /// Set a \c DiagnosticOptions to use during driver command-line parsing.
+  void setDiagnosticOptions(DiagnosticOptions *DiagOpts) {
+this->DiagOpts = DiagOpts;
+  }
+
   /// Run the clang invocation.
   ///
   /// \returns True if there were no errors during execution.
@@ -290,6 +296,7 @@
   FileManager *Files;
   std::shared_ptr PCHContainerOps;
   DiagnosticConsumer *DiagConsumer = nullptr;
+  DiagnosticOptions *DiagOpts = nullptr;
 };
 
 /// Utility to run a FrontendAction over a set of files.


Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -343,10 +343,17 @@
   for (const std::string &Str : CommandLine)
 Argv.push_back(Str.c_str());
   const char *const BinaryName = Argv[0];
-  IntrusiveRefCntPtr DiagOpts =
-  CreateAndPopulateDiagOpts(Argv);
-  TextDiagnosticPrinter DiagnosticPrinter(
-  llvm::errs(), &*DiagOpts);
+
+  // Parse diagnostic options from the driver command-line only if none were
+  // explicitly set.
+  IntrusiveRefCntPtr ParsedDiagOpts;
+  DiagnosticOptions *DiagOpts = this->DiagOpts;
+  if (!DiagOpts) {
+ParsedDiagOpts = CreateAndPopulateDiagOpts(Argv);
+DiagOpts = &*ParsedDiagOpts;
+  }
+
+  TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), DiagOpts);
   DiagnosticsEngine Diagnostics(
   IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts,
   DiagConsumer ? DiagConsumer : &DiagnosticPrinter, false);
Index: clang/include/clang/Tooling/Tooling.h
===
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -268,11 +268,17 @@
 
   ~ToolInvocation();
 
-  /// Set a \c DiagnosticConsumer to use during parsing.
+  /// Set a \c DiagnosticConsumer to use during driver command-line parsing and
+  /// the action invocation itself.
   void setDiagnosticConsumer(DiagnosticConsumer *DiagConsumer) {
 this->DiagConsumer = DiagConsumer;
   }
 
+  /// Set a \c DiagnosticOptions to use during driver command-line parsing.
+  void setDiagnosticOptions(DiagnosticOptions *DiagOpts) {
+this->DiagOpts = DiagOpts;
+  }
+
   /// Run the clang invocation.
   ///
   /// \returns True if there were no errors during execution.
@@ -290,6 +296,7 @@
   FileManager *Files;
   std::shared_ptr PCHContainerOps;
   DiagnosticConsumer *DiagConsumer = nullptr;
+  DiagnosticOptions *DiagOpts = nullptr;
 };
 
 /// Utility to run a FrontendAction over a set of files.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108976: [clang][tooling] Accept custom diagnostic options in ToolInvocation

2021-09-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Tests that cover this functionality were moved into a follow-up patch D108974 
. The reason is to avoid temporary regression 
pointed out here .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108976

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


[PATCH] D108982: [clang][deps] Avoid creating diagnostic serialization file, add test

2021-09-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 370260.
jansvoboda11 added a comment.

Split out tests into a separate patch in order to avoid temporary regression.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108982

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -269,8 +269,6 @@
 DependencyScanningWorker::DependencyScanningWorker(
 DependencyScanningService &Service)
 : Format(Service.getFormat()) {
-  DiagOpts = new DiagnosticOptions();
-
   PCHContainerOps = std::make_shared();
   PCHContainerOps->registerReader(
   std::make_unique());
@@ -290,16 +288,20 @@
 Files = new FileManager(FileSystemOptions(), RealFS);
 }
 
-static llvm::Error runWithDiags(
-DiagnosticOptions *DiagOpts,
-llvm::function_ref BodyShouldSucceed) {
+static llvm::Error
+runWithDiags(DiagnosticOptions *DiagOpts,
+ llvm::function_ref
+ BodyShouldSucceed) {
+  // Avoid serializing diagnostics.
+  DiagOpts->DiagnosticSerializationFile.clear();
+
   // Capture the emitted diagnostics and report them to the client
   // in the case of a failure.
   std::string DiagnosticOutput;
   llvm::raw_string_ostream DiagnosticsOS(DiagnosticOutput);
   TextDiagnosticPrinter DiagPrinter(DiagnosticsOS, DiagOpts);
 
-  if (BodyShouldSucceed(DiagPrinter))
+  if (BodyShouldSucceed(DiagPrinter, *DiagOpts))
 return llvm::Error::success();
   return llvm::make_error(DiagnosticsOS.str(),
  llvm::inconvertibleErrorCode());
@@ -313,15 +315,22 @@
   llvm::IntrusiveRefCntPtr CurrentFiles =
   Files ? Files : new FileManager(FileSystemOptions(), RealFS);
 
-  return runWithDiags(DiagOpts.get(), [&](DiagnosticConsumer &DC) {
-DependencyScanningAction Action(WorkingDirectory, Consumer, DepFS,
-PPSkipMappings.get(), Format);
-// Create an invocation that uses the underlying file system to ensure that
-// any file system requests that are made by the driver do not go through
-// the dependency scanning filesystem.
-ToolInvocation Invocation(CommandLine, &Action, CurrentFiles.get(),
-  PCHContainerOps);
-Invocation.setDiagnosticConsumer(&DC);
-return Invocation.run();
-  });
+  std::vector CCommandLine(CommandLine.size(), nullptr);
+  llvm::transform(CommandLine, CCommandLine.begin(),
+  [](const std::string &Str) { return Str.c_str(); });
+
+  return runWithDiags(
+  CreateAndPopulateDiagOpts(CCommandLine).release(),
+  [&](DiagnosticConsumer &DC, DiagnosticOptions &DiagOpts) {
+DependencyScanningAction Action(WorkingDirectory, Consumer, DepFS,
+PPSkipMappings.get(), Format);
+// Create an invocation that uses the underlying file system to ensure
+// that any file system requests that are made by the driver do not go
+// through the dependency scanning filesystem.
+ToolInvocation Invocation(CommandLine, &Action, CurrentFiles.get(),
+  PCHContainerOps);
+Invocation.setDiagnosticConsumer(&DC);
+Invocation.setDiagnosticOptions(&DiagOpts);
+return Invocation.run();
+  });
 }
Index: clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
===
--- clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
+++ clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
@@ -66,7 +66,6 @@
   DependencyConsumer &Consumer);
 
 private:
-  IntrusiveRefCntPtr DiagOpts;
   std::shared_ptr PCHContainerOps;
   std::unique_ptr PPSkipMappings;
 


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -269,8 +269,6 @@
 DependencyScanningWorker::DependencyScanningWorker(
 DependencyScanningService &Service)
 : Format(Service.getFormat()) {
-  DiagOpts = new DiagnosticOptions();
-
   PCHContainerOps = std::make_shared();
   PCHContainerOps->registerReader(
   std::make_unique());
@@ -290,16 +288,20 @@
 Files = new FileManager(FileSystemOptions(), RealFS);
 }
 
-static llvm::Error runWithDiags(
-DiagnosticOptions *DiagOpts,
-llvm::function_ref BodyShouldSucceed) {
+static llvm::Erro

[PATCH] D109105: [clang-cl] Emit nicer warning on unknown /arch: arguments

2021-09-02 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm, nice!




Comment at: llvm/include/llvm/ADT/StringMap.h:301
+  /// is inserted .
+  template  void insert(InputIt First, InputIt Last) {
+for (InputIt It = First; It != Last; ++It)

nit: i think typename is more common than class in llvm code

unittests/ADT/StringMapTest.cpp has tests for the insert methods, maybe it's 
worth adding one for this too (or the initializer_list one perhaps) even though 
it's pretty trivial?


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

https://reviews.llvm.org/D109105

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


[PATCH] D108974: [clang][tooling] Properly initialize DiagnosticsEngine for cc1 command-line construction

2021-09-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 370262.
jansvoboda11 added a comment.

Shuffling patches around.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108974

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
@@ -224,6 +224,82 @@
   EXPECT_TRUE(Invocation.run());
 }
 
+struct ErrorCountingDiagnosticConsumer : public DiagnosticConsumer {
+  ErrorCountingDiagnosticConsumer() : NumErrorsSeen(0) {}
+  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+const Diagnostic &Info) override {
+if (DiagLevel == DiagnosticsEngine::Level::Error)
+  ++NumErrorsSeen;
+  }
+  unsigned NumErrorsSeen;
+};
+
+TEST(ToolInvocation, DiagnosticsEngineProperlyInitializedForCC1Construction) {
+  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");
+  Args.push_back("-target");
+  // Invalid argument that by default results in an error diagnostic:
+  Args.push_back("i386-apple-ios14.0-simulator");
+  // Argument that downgrades the error into a warning:
+  Args.push_back("-Wno-error=invalid-ios-deployment-target");
+  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 a() {}\n"));
+  ErrorCountingDiagnosticConsumer Consumer;
+  Invocation.setDiagnosticConsumer(&Consumer);
+  EXPECT_TRUE(Invocation.run());
+  // Check that `-Wno-error=invalid-ios-deployment-target` downgraded the error
+  // into a warning.
+  EXPECT_EQ(Consumer.NumErrorsSeen, 0u);
+}
+
+TEST(ToolInvocation, CustomDiagnosticOptionsOverwriteParsedOnes) {
+  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");
+  Args.push_back("-target");
+  // Invalid argument that by default results in an error diagnostic:
+  Args.push_back("i386-apple-ios14.0-simulator");
+  // Argument that downgrades the error into a warning:
+  Args.push_back("-Wno-error=invalid-ios-deployment-target");
+  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 a() {}\n"));
+  ErrorCountingDiagnosticConsumer Consumer;
+  Invocation.setDiagnosticConsumer(&Consumer);
+
+  auto DiagOpts = llvm::makeIntrusiveRefCnt();
+  Invocation.setDiagnosticOptions(&*DiagOpts);
+
+  EXPECT_TRUE(Invocation.run());
+  // Check that `-Wno-error=invalid-ios-deployment-target` didn't downgrade the
+  // error into a warning due to being overwritten by custom diagnostic options.
+  EXPECT_EQ(Consumer.NumErrorsSeen, 1u);
+}
+
 struct DiagnosticConsumerExpectingSourceManager : public DiagnosticConsumer {
   bool SawSourceManager;
 
Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -354,16 +354,16 @@
   }
 
   TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), DiagOpts);
-  DiagnosticsEngine Diagnostics(
-  IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts,
-  DiagConsumer ? DiagConsumer : &DiagnosticPrinter, false);
+  IntrusiveRefCntPtr Diagnostics =
+  CompilerInstance::createDiagnostics(
+  &*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);
+  SourceManager SrcMgr(*Diagnostics, *Files);
+  Diagnostics->setSourceManager(&SrcMgr);
 
   const std::unique_ptr Driver(
-  newDriver(&Diagnostics, BinaryName, &Files->getVirtualFileSystem()));
+  newDriver(&*Diagnostics, BinaryName, &Files->getVirtualFileSystem()));
   // The "input file not fou

[PATCH] D109085: clang/win: Add __readfsdword to intrin.h

2021-09-02 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


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

https://reviews.llvm.org/D109085

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


[PATCH] D109157: [ARM] Mitigate the cve-2021-35465 security vulnurability.

2021-09-02 Thread Alexandros Lamprineas via Phabricator via cfe-commits
labrinea created this revision.
labrinea added reviewers: llvm-commits, momchil.velikov.
Herald added subscribers: dang, hiraditya, kristof.beyls.
labrinea requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

Recently a vulnerability issue is found in the implementation of VLLDM 
instruction in the Arm Cortex-M33, Cortex-M35P and Cortex-M55. If the VLLDM 
instruction is abandoned due to an exception when it is partially completed, it 
is possible for subsequent non-secure handler to access and modify the partial 
restored register values. This vulnerability is identified as CVE-2021-35465. 
The mitigation sequence varies between v8-m and v8.1-m as follows:

v8-m.main

  mrsr5, control
  tstr5, #8   /* CONTROL_S.SFPA */
  it ne
  .inst.w0xeeb00a40   /* vmovne s0, s0 */
  1:
  vlldm  sp   /* Lazy restore of d0-d16 and FPSCR. */

v8.1-m.main

  vscclrm{vpr}/* Clear VPR. */
  vlldm  sp   /* Lazy restore of d0-d16 and FPSCR. */

More details on 
https://developer.arm.com/support/arm-security-updates/vlldm-instruction-security-vulnerability


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109157

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/arm-cmse-cve-2021-35465.c
  llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp
  llvm/test/CodeGen/ARM/cmse-cve-2021-35465-return.ll
  llvm/test/CodeGen/ARM/cmse-cve-2021-35465.ll

Index: llvm/test/CodeGen/ARM/cmse-cve-2021-35465.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/cmse-cve-2021-35465.ll
@@ -0,0 +1,101 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+;
+; RUN: llc %s -o - -mtriple=thumbv8m.main -mattr=+fp-armv8d16sp \
+; RUN:   -arm-fix-cmse-cve-2021-35465=1 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-8M-FP-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8m.main -mattr=-fpregs \
+; RUN:   -arm-fix-cmse-cve-2021-35465=1 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-8M-NOFP-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mattr=+fp-armv8d16sp \
+; RUN:   -arm-fix-cmse-cve-2021-35465=1 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-81M-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mattr=-fpregs \
+; RUN:   -arm-fix-cmse-cve-2021-35465=1 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-81M-CVE-2021-35465
+
+
+define void @non_secure_call(void ()* %fptr) {
+; CHECK-8M-FP-CVE-2021-35465-LABEL: non_secure_call:
+; CHECK-8M-FP-CVE-2021-35465:   @ %bb.0:
+; CHECK-8M-FP-CVE-2021-35465-NEXT:push {r7, lr}
+; CHECK-8M-FP-CVE-2021-35465-NEXT:push.w {r4, r5, r6, r7, r8, r9, r10, r11}
+; CHECK-8M-FP-CVE-2021-35465-NEXT:bic r0, r0, #1
+; CHECK-8M-FP-CVE-2021-35465-NEXT:sub sp, #136
+; CHECK-8M-FP-CVE-2021-35465-NEXT:vlstm sp
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r1, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r2, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r3, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r4, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r5, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r6, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r7, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r8, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r9, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r10, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r11, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r12, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:msr apsr_nzcvq, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:blxns r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mrs r12, control
+; CHECK-8M-FP-CVE-2021-35465-NEXT:tst.w r12, #8
+; CHECK-8M-FP-CVE-2021-35465-NEXT:it ne
+; CHECK-8M-FP-CVE-2021-35465-NEXT:vmovne.f32 s0, s0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:vlldm sp
+; CHECK-8M-FP-CVE-2021-35465-NEXT:add sp, #136
+; CHECK-8M-FP-CVE-2021-35465-NEXT:pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
+; CHECK-8M-FP-CVE-2021-35465-NEXT:pop {r7, pc}
+;
+; CHECK-8M-NOFP-CVE-2021-35465-LABEL: non_secure_call:
+; CHECK-8M-NOFP-CVE-2021-35465:   @ %bb.0:
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:push {r7, lr}
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:push.w {r4, r5, r6, r7, r8, r9, r10, r11}
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:bic r0, r0, #1
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:sub sp, #136
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:vlstm sp
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r1, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r2, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r3, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r4, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r5, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r6, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r7, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r8, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r9, r0
+; CHECK-8M

[PATCH] D109105: [clang-cl] Emit nicer warning on unknown /arch: arguments

2021-09-02 Thread Nico Weber via Phabricator via cfe-commits
thakis marked an inline comment as done.
thakis added a comment.

Thanks!


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

https://reviews.llvm.org/D109105

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


[PATCH] D109126: [PowerPC] [NFC] Add Big-Endian checks for existing MMA tests

2021-09-02 Thread Lei Huang via Phabricator via cfe-commits
lei added a comment.

Is it really necessary to add the BE checks in this patch if they are the same 
as LE checks?  Why not just add it later when there is a diff seen?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109126

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


[clang] 9735198 - [clang-cl] Emit nicer warning on unknown /arch: arguments

2021-09-02 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-09-02T10:37:32-04:00
New Revision: 973519826edb7690270261a5b3512f32ae64063c

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

LOG: [clang-cl] Emit nicer warning on unknown /arch: arguments

Now prints the list of known archs. This requires plumbing a Driver
arg through a few functions.

Also add two more convenience insert() overlods to StringMap.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/ToolChains/AVR.cpp
clang/lib/Driver/ToolChains/Arch/Mips.cpp
clang/lib/Driver/ToolChains/Arch/Mips.h
clang/lib/Driver/ToolChains/Arch/X86.cpp
clang/lib/Driver/ToolChains/Arch/X86.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.h
clang/lib/Driver/ToolChains/FreeBSD.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Linux.cpp
clang/lib/Driver/ToolChains/NetBSD.cpp
clang/lib/Driver/ToolChains/OpenBSD.cpp
clang/test/Driver/cl-x86-flags.c
llvm/include/llvm/ADT/StringMap.h
llvm/unittests/ADT/StringMapTest.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 57e91bf52ef19..7c52607d362bc 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -29,6 +29,9 @@ def err_drv_invalid_riscv_arch_name : Error<
   "invalid arch name '%0', %1">;
 def err_drv_invalid_riscv_ext_arch_name : Error<
   "invalid arch name '%0', %1 '%2'">;
+def warn_drv_invalid_arch_name_with_suggestion : Warning<
+  "ignoring invalid /arch: argument '%0'; for %select{64|32}1-bit expected one 
of %2">,
+  InGroup;
 def warn_drv_avr_mcu_not_specified : Warning<
   "no target microcontroller specified on command line, cannot "
   "link standard libraries, please pass -mmcu=">,

diff  --git a/clang/lib/Driver/ToolChains/AVR.cpp 
b/clang/lib/Driver/ToolChains/AVR.cpp
index 5a12406a51cc6..896afcc3474a4 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -315,7 +315,7 @@ AVRToolChain::AVRToolChain(const Driver &D, const 
llvm::Triple &Triple,
   if (!Args.hasArg(options::OPT_nostdlib) &&
   !Args.hasArg(options::OPT_nodefaultlibs) &&
   !Args.hasArg(options::OPT_c /* does not apply when not linking */)) {
-std::string CPU = getCPUName(Args, Triple);
+std::string CPU = getCPUName(D, Args, Triple);
 
 if (CPU.empty()) {
   // We cannot link any standard libraries without an MCU specified.
@@ -389,8 +389,10 @@ void AVR::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs, const ArgList 
&Args,
const char *LinkingOutput) const {
+  const Driver &D = getToolChain().getDriver();
+
   // Compute information about the target AVR.
-  std::string CPU = getCPUName(Args, getToolChain().getTriple());
+  std::string CPU = getCPUName(D, Args, getToolChain().getTriple());
   llvm::Optional FamilyName = GetMCUFamilyName(CPU);
   llvm::Optional SectionAddressData = GetMCUSectionAddressData(CPU);
 
@@ -414,9 +416,7 @@ void AVR::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back(Args.MakeArgString(DataSectionArg));
   } else {
 // We do not have an entry for this CPU in the address mapping table yet.
-getToolChain().getDriver().Diag(
-diag::warn_drv_avr_linker_section_addresses_not_implemented)
-<< CPU;
+D.Diag(diag::warn_drv_avr_linker_section_addresses_not_implemented) << CPU;
   }
 
   // If the family name is known, we can link with the device-specific libgcc.

diff  --git a/clang/lib/Driver/ToolChains/Arch/Mips.cpp 
b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
index 5a509dbb2bd31..c374d745da384 100644
--- a/clang/lib/Driver/ToolChains/Arch/Mips.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -441,7 +441,8 @@ bool mips::isUCLibc(const ArgList &Args) {
   return A && A->getOption().matches(options::OPT_muclibc);
 }
 
-bool mips::isNaN2008(const ArgList &Args, const llvm::Triple &Triple) {
+bool mips::isNaN2008(const Driver &D, const ArgList &Args,
+ const llvm::Triple &Triple) {
   if (Arg *NaNArg = Args.getLastArg(options::OPT_mnan_EQ))
 return llvm::StringSwitch(NaNArg->getValue())
 .Case("2008", true)
@@ -449,7 +450,7 @@ bool mips::isNaN2008(const ArgList &Args, const 
llvm::Triple &Triple) {
 .Default(false);
 
   // NaN2008 is the default for MIPS32r6/MIPS64r6.
-  return llvm::StringSwitch(ge

[PATCH] D109105: [clang-cl] Emit nicer warning on unknown /arch: arguments

2021-09-02 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG973519826edb: [clang-cl] Emit nicer warning on unknown 
/arch: arguments (authored by thakis).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D109105?vs=370128&id=370267#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109105

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/Arch/Mips.cpp
  clang/lib/Driver/ToolChains/Arch/Mips.h
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/lib/Driver/ToolChains/Arch/X86.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/test/Driver/cl-x86-flags.c
  llvm/include/llvm/ADT/StringMap.h
  llvm/unittests/ADT/StringMapTest.cpp

Index: llvm/unittests/ADT/StringMapTest.cpp
===
--- llvm/unittests/ADT/StringMapTest.cpp
+++ llvm/unittests/ADT/StringMapTest.cpp
@@ -111,6 +111,13 @@
   EXPECT_TRUE(constTestMap.find(testKeyStr) == constTestMap.end());
 }
 
+// initializer_list ctor test; also implicitly tests initializer_list and
+// iterator overloads of insert().
+TEST_F(StringMapTest, InitializerListCtor) {
+  testMap = StringMap({{"key", 1}});
+  assertSingleItemMap();
+}
+
 // A map with a single entry.
 TEST_F(StringMapTest, SingleEntryMapTest) {
   testMap[testKey] = testValue;
Index: llvm/include/llvm/ADT/StringMap.h
===
--- llvm/include/llvm/ADT/StringMap.h
+++ llvm/include/llvm/ADT/StringMap.h
@@ -126,9 +126,7 @@
 
   StringMap(std::initializer_list> List)
   : StringMapImpl(List.size(), static_cast(sizeof(MapEntryTy))) {
-for (const auto &P : List) {
-  insert(P);
-}
+insert(List);
   }
 
   StringMap(StringMap &&RHS)
@@ -297,6 +295,21 @@
 return try_emplace(KV.first, std::move(KV.second));
   }
 
+  /// Inserts elements from range [first, last). If multiple elements in the
+  /// range have keys that compare equivalent, it is unspecified which element
+  /// is inserted .
+  template  void insert(InputIt First, InputIt Last) {
+for (InputIt It = First; It != Last; ++It)
+  insert(*It);
+  }
+
+  ///  Inserts elements from initializer list ilist. If multiple elements in
+  /// the range have keys that compare equivalent, it is unspecified which
+  /// element is inserted
+  void insert(std::initializer_list> List) {
+insert(List.begin(), List.end());
+  }
+
   /// Inserts an element or assigns to the current element if the key already
   /// exists. The return type is the same as try_emplace.
   template 
Index: clang/test/Driver/cl-x86-flags.c
===
--- clang/test/Driver/cl-x86-flags.c
+++ clang/test/Driver/cl-x86-flags.c
@@ -6,7 +6,8 @@
 // flag space.
 // RUN: %clang_cl /Zs /WX -m32 -m64 -msse3 -msse4.1 -mavx -mno-avx \
 // RUN: --target=i386-pc-win32 -### -- 2>&1 %s | FileCheck -check-prefix=MFLAGS %s
-// MFLAGS-NOT: argument unused during compilation
+// MFLAGS-NOT: invalid /arch: argument
+//
 
 // RUN: %clang_cl -m32 -arch:IA32 --target=i386-pc-windows /c /Fo%t.obj -Xclang -verify -DTEST_32_ARCH_IA32 -- %s
 #if defined(TEST_32_ARCH_IA32)
@@ -17,10 +18,10 @@
 
 // arch: args are case-sensitive.
 // RUN: %clang_cl -m32 -arch:ia32 --target=i386-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=ia32 %s
-// ia32: argument unused during compilation
+// ia32: invalid /arch: argument 'ia32'; for 32-bit expected one of AVX, AVX2, AVX512, AVX512F, IA32, SSE, SSE2
 
 // RUN: %clang_cl -m64 -arch:IA32 --target=x86_64-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=IA3264 %s
-// IA3264: argument unused during compilation
+// IA3264: invalid /arch: argument 'IA32'; for 64-bit expected one of AVX, AVX2, AVX512, AVX512F
 
 // RUN: %clang_cl -m32 -arch:SSE --target=i386-pc-windows /c /Fo%t.obj -Xclang -verify -DTEST_32_ARCH_SSE -- %s
 #if defined(TEST_32_ARCH_SSE)
@@ -30,7 +31,7 @@
 #endif
 
 // RUN: %clang_cl -m32 -arch:sse --target=i386-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=sse %s
-// sse: argument unused during compilation
+// sse: invalid /arch: argument
 
 // RUN: %clang_cl -m32 -arch:SSE2 --target=i386-pc-windows /c /Fo%t.obj -Xclang -verify -DTEST_32_ARCH_SSE2 -- %s
 #if defined(TEST_32_ARCH_SSE2)
@@ -40,13 +41,13 @@
 #endif
 
 // RUN: %clang_cl -m32 -arch:sse2 --target=i386-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=sse %s
-// sse2: argument unused during compilation
+// sse2: invalid /arch: argument
 
 // RUN: %clang_cl -m64 -arch:SSE --

[PATCH] D107775: [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from isSpecifierType

2021-09-02 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

In D107775#2967134 , @dgoldman wrote:

>> I put a case for it in the declprinter so it is handled appropriately so it 
>> would get the pointee type, whereas before this was neglected.
>>
>> Other than that, there should be no difference.
>
> It looks like DeclPrinter only uses that method here 
> 
>  - so it shouldn't make a difference.
>
> but TypePrinter does call `isSpecifierType()` so this changes that behavior, 
> right? Can you add a test to TypePrinterTest for this change?

Like for the function itself or an integration test?


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

https://reviews.llvm.org/D107775

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


[PATCH] D109158: [clang][deps] Test diagnostic options are being respected

2021-09-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch tests code in D108976 . This split 
is necessary to avoid temporary regression.

Depends on D108974 ,


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109158

Files:
  clang/test/ClangScanDeps/Inputs/diagnostics/cdb.json.template
  clang/test/ClangScanDeps/Inputs/diagnostics/mod.h
  clang/test/ClangScanDeps/Inputs/diagnostics/module.modulemap
  clang/test/ClangScanDeps/Inputs/diagnostics/tu.c
  clang/test/ClangScanDeps/diagnostics.c


Index: clang/test/ClangScanDeps/diagnostics.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/diagnostics.c
@@ -0,0 +1,50 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: cp %S/Inputs/diagnostics/* %t
+
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/diagnostics/cdb.json.template > %t/cdb.json
+// RUN: echo -%t > %t/result.json
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format 
experimental-full 2>&1 >> %t/result.json
+// RUN: cat %t/result.json | sed 's:\?:/:g' | FileCheck %s
+
+// Check that the '-Wno-error=invalid-ios-deployment-target' option is being
+// respected and invalid arguments like '-target i386-apple-ios14.0-simulator'
+// do not result in an error.
+
+// CHECK-NOT:  error:
+// CHECK:  -[[PREFIX:.*]]
+// CHECK-NEXT: {
+// CHECK-NEXT:   "modules": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
+// CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-cc1"
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "[[HASH_MOD:.*]]",
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/mod.h"
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "name": "mod"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "translation-units": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-context-hash": "[[HASH_TU:.*]],
+// CHECK-NEXT:   "clang-module-deps": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "context-hash": "[[HASH_MOD]]",
+// CHECK-NEXT:   "module-name": "mod"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-fno-implicit-modules"
+// CHECK-NEXT: "-fno-implicit-module-maps"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/tu.c"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "input-file": "[[PREFIX]]/tu.c"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ]
+// CHECK-NEXT: }
Index: clang/test/ClangScanDeps/Inputs/diagnostics/tu.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/diagnostics/tu.c
@@ -0,0 +1 @@
+#include "mod.h"
Index: clang/test/ClangScanDeps/Inputs/diagnostics/module.modulemap
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/diagnostics/module.modulemap
@@ -0,0 +1 @@
+module mod { header "mod.h" }
Index: clang/test/ClangScanDeps/Inputs/diagnostics/cdb.json.template
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/diagnostics/cdb.json.template
@@ -0,0 +1,7 @@
+[
+  {
+"directory": "DIR",
+"command": "clang -c DIR/tu.c -fmodules -target 
i386-apple-ios14.0-simulator -Wno-error=invalid-ios-deployment-target -o 
DIR/tu.o",
+"file": "DIR/tu.c"
+  }
+]


Index: clang/test/ClangScanDeps/diagnostics.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/diagnostics.c
@@ -0,0 +1,50 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: cp %S/Inputs/diagnostics/* %t
+
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/diagnostics/cdb.json.template > %t/cdb.json
+// RUN: echo -%t > %t/result.json
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full 2>&1 >> %t/result.json
+// RUN: cat %t/result.json | sed 's:\?:/:g' | FileCheck %s
+
+// Check that the '-Wno-error=invalid-ios-deployment-target' option is being
+// respected and invalid arguments like '-target i386-apple-ios14.0-simulator'
+// do not result in an error.
+
+// CHECK-NOT:  error:
+// CHECK:  -[[PREFIX:.*]]
+// CHECK-NEXT: {
+// CHECK-NEXT:   "modules": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
+// CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-cc1"
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "[[HASH_MOD:.*]]",
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[

[PATCH] D108982: [clang][deps] Use correct DiagnosticOptions for command-line handling

2021-09-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Thanks for the reviews. I had to split out the tests from this patch into 
D109158  to prevent the temporary regression 
you pointed out. Your remarks should be addressed there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108982

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


[clang] 7d0e62b - [analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it

2021-09-02 Thread Kristóf Umann via cfe-commits

Author: Kristóf Umann
Date: 2021-09-02T16:56:32+02:00
New Revision: 7d0e62bfb773c68d2bc8831fddcc8536f4613190

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

LOG: [analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire 
function calls, rather than each ExplodedNode in it

D105553 added NoStateChangeFuncVisitor, an abstract class to aid in creating
notes such as "Returning without writing to 'x'", or "Returning without changing
the ownership status of allocated memory". Its clients need to define, among
other things, what a change of state is.

For code like this:

f() {
  g();
}

foo() {
  f();
  h();
}

We'd have a path in the ExplodedGraph that looks like this:

 --  -->
/  \
 --- >---  --->
/\  /\
 -- -->

When we're interested in whether f neglected to change some property,
NoStateChangeFuncVisitor asks these questions:

   ÷×~
--  -->
   ß   /  \$@&#*
--- >---  --->
   /\  /\
    -- -->

Has anything changed in between # and *?
Has anything changed in between & and *?
Has anything changed in between @ and *?
...
Has anything changed in between $ and *?
Has anything changed in between × and ~?
Has anything changed in between ÷ and ~?
...
Has anything changed in between ß and *?
...
This is a rather thorough line of questioning, which is why in D105819, I was
only interested in whether state *right before* and *right after* a function
call changed, and early returned to the CallEnter location:

if (!CurrN->getLocationAs())
  return;
Except that I made a typo, and forgot to negate the condition. So, in this
patch, I'm fixing that, and under the same hood allow all clients to decide to
do this whole-function check instead of the thorough one.

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

Added: 
clang/unittests/StaticAnalyzer/NoStateChangeFuncVisitorTest.cpp

Modified: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/unittests/StaticAnalyzer/CMakeLists.txt
clang/unittests/StaticAnalyzer/CallEventTest.cpp
clang/unittests/StaticAnalyzer/CheckerRegistration.h
clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
index 139b0dcd51704..c42521376af92 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -633,6 +633,9 @@ class CXXConstructorCall;
 /// Descendants can define what a "state change is", like a change of value
 /// to a memory region, liveness, etc. For function calls where the state did
 /// not change as defined, a custom note may be constructed.
+///
+/// For a minimal example, check out
+/// clang/unittests/StaticAnalyzer/NoStateChangeFuncVisitorTest.cpp.
 class NoStateChangeFuncVisitor : public BugReporterVisitor {
 private:
   /// Frames modifying the state as defined in \c wasModifiedBeforeCallExit.
@@ -643,6 +646,8 @@ class NoStateChangeFuncVisitor : public BugReporterVisitor {
   /// many times (going up the path for each node and checking whether the
   /// region was written into) we instead lazily compute the stack frames
   /// along the path.
+  // TODO: Can't we just use a map instead? This is likely not as cheap as it
+  // makes the code 
diff icult to read.
   llvm::SmallPtrSet FramesModifying;
   llvm::SmallPtrSet FramesModifyingCalculated;
 
@@ -651,6 +656,8 @@ class NoStateChangeFuncVisitor : public BugReporterVisitor {
   /// The calculation is cached in FramesModifying.
   bool isModifiedInFrame(const ExplodedNode *CallExitBeginN);
 
+  void markFrameAsModifying(const StackFrameContext *SCtx);
+
   /// Write to \c FramesModifying all stack frames along the path in the 
current
   /// stack frame which modifies the state.
   void findModifyingFrames(const ExplodedNode *const CallExitBeginN);
@@ -658,11 +665,37 @@ class NoStateChangeFuncVisitor : public 
BugReporterVisitor {
 protected:
   bugreporter::TrackingKind TKind;
 
-  /// \return Whether the state was modified from the current node, \CurrN, to
-  /// the end of the stack fram, at \p CallExitBeginN.
-  vi

[PATCH] D108695: [analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it

2021-09-02 Thread Kristóf Umann 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 rG7d0e62bfb773: [analyzer][NFCI] Allow clients of 
NoStateChangeFuncVisitor to check entire… (authored by Szelethus).

Changed prior to commit:
  https://reviews.llvm.org/D108695?vs=369935&id=370274#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108695

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/StaticAnalyzer/CallEventTest.cpp
  clang/unittests/StaticAnalyzer/CheckerRegistration.h
  clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
  clang/unittests/StaticAnalyzer/NoStateChangeFuncVisitorTest.cpp
  clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp

Index: clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
===
--- clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
+++ clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
@@ -51,7 +51,7 @@
 TEST(RegisterCustomCheckers, RegisterChecker) {
   std::string Diags;
   EXPECT_TRUE(runCheckerOnCode("void f() {;}", Diags));
-  EXPECT_EQ(Diags, "test.CustomChecker:Custom diagnostic description\n");
+  EXPECT_EQ(Diags, "test.CustomChecker: Custom diagnostic description\n");
 }
 
 //===--===//
@@ -169,7 +169,7 @@
 TEST(RegisterDeps, UnsatisfiedDependency) {
   std::string Diags;
   EXPECT_TRUE(runCheckerOnCode("void f() {int i;}", Diags));
-  EXPECT_EQ(Diags, "test.RegistrationOrder:test.RegistrationOrder\n");
+  EXPECT_EQ(Diags, "test.RegistrationOrder: test.RegistrationOrder\n");
 }
 
 //===--===//
@@ -272,7 +272,7 @@
   std::string Diags;
   EXPECT_TRUE(runCheckerOnCode(
   "void f() {int i;}", Diags));
-  EXPECT_EQ(Diags, "test.RegistrationOrder:test.WeakDep\ntest."
+  EXPECT_EQ(Diags, "test.RegistrationOrder: test.WeakDep\ntest."
"Dep\ntest.RegistrationOrder\n");
   Diags.clear();
 
@@ -280,31 +280,33 @@
   // but the dependencies are switched.
   EXPECT_TRUE(runCheckerOnCode(
   "void f() {int i;}", Diags));
-  EXPECT_EQ(Diags, "test.RegistrationOrder:test.Dep\ntest."
+  EXPECT_EQ(Diags, "test.RegistrationOrder: test.Dep\ntest."
"RegistrationOrder\ntest.WeakDep\n");
   Diags.clear();
 
   // Weak dependencies dont prevent dependent checkers from being enabled.
   EXPECT_TRUE(runCheckerOnCode(
   "void f() {int i;}", Diags));
-  EXPECT_EQ(Diags, "test.RegistrationOrder:test.Dep\ntest.RegistrationOrder\n");
+  EXPECT_EQ(Diags,
+"test.RegistrationOrder: test.Dep\ntest.RegistrationOrder\n");
   Diags.clear();
 
   // Nor will they be enabled just because a dependent checker is.
   EXPECT_TRUE(runCheckerOnCode(
   "void f() {int i;}", Diags));
-  EXPECT_EQ(Diags, "test.RegistrationOrder:test.Dep\ntest.RegistrationOrder\n");
+  EXPECT_EQ(Diags,
+"test.RegistrationOrder: test.Dep\ntest.RegistrationOrder\n");
   Diags.clear();
 
   EXPECT_TRUE(
   runCheckerOnCode("void f() {int i;}", Diags));
-  EXPECT_EQ(Diags, "test.RegistrationOrder:test.WeakDep2\ntest."
+  EXPECT_EQ(Diags, "test.RegistrationOrder: test.WeakDep2\ntest."
"Dep\ntest.RegistrationOrder\n");
   Diags.clear();
 
   EXPECT_TRUE(
   runCheckerOnCode("void f() {int i;}", Diags));
-  EXPECT_EQ(Diags, "test.RegistrationOrder:test.WeakDep2\ntest."
+  EXPECT_EQ(Diags, "test.RegistrationOrder: test.WeakDep2\ntest."
"WeakDep\ntest.Dep\ntest.RegistrationOrder\n");
   Diags.clear();
 }
@@ -414,7 +416,7 @@
   std::string Diags;
   EXPECT_TRUE(
   runCheckerOnCode("void f() {int i;}", Diags));
-  EXPECT_EQ(Diags, "test.RegistrationOrder:test.StrongDep\ntest."
+  EXPECT_EQ(Diags, "test.RegistrationOrder: test.StrongDep\ntest."
"WeakDep\ntest.Dep\ntest.RegistrationOrder\n");
   Diags.clear();
 
@@ -424,14 +426,14 @@
   // established in between the modeling portion and the weak dependency.
   EXPECT_TRUE(
   runCheckerOnCode("void f() {int i;}", Diags));
-  EXPECT_EQ(Diags, "test.RegistrationOrder:test.WeakDep\ntest."
+  EXPECT_EQ(Diags, "test.RegistrationOrder: test.WeakDep\ntest."
"StrongDep\ntest.Dep\ntest.RegistrationOrder\n");
   Diags.clear();
 
   // If a weak dependency is disabled, the checker itself can still be enabled.
   EXPECT_TRUE(runCheckerOnCode(
   "void f() {int i;}", Diags));
-  EXPECT_EQ(Diags, "test.RegistrationOrder:test.Dep\ntest."
+  EXPECT_EQ(Diags, "test.RegistrationOrder: test.Dep\ntest."
"Regi

[PATCH] D108695: [analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it

2021-09-02 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This seems to break tests: http://45.33.8.238/linux/54991/step_7.txt

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108695

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


[PATCH] D104386: [PowerPC][Builtins] Added a number of builtins for compatibility with XL.

2021-09-02 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

In D104386#2977302 , @nemanjai wrote:

> The idea with putting all of these in a separate function was to:
>
> 1. Make it easy to limit it to specific targets as I suggested above
> 2. Have them all in one place to easily identify which ones are added for 
> this compatibility so we can eventually pull this support once they are no 
> longer needed
> 3. Just kind of isolate this to keep it out of the way
>
> I really think the best way forward might be to limit this to Linux and AIX. 
> I don't think IBM provided XLC/C++ on FreeBSD.

Well, glibc also uses at least some of these `__` aliases, e.g. for `__bcopy`:

https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/powerpc/powerpc64/power7/memmove.S;h=f61949d30fa317ec487deb81b20e67ed3df05e32;hb=HEAD#l829

and

https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/powerpc/powerpc64/le/power10/memmove.S;h=7dfd57edeb37e8e47a31fe6e19f254bc1fcd312b;hb=HEAD#l312

but there might be more collisions...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104386

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


[clang] 3891b45 - Revert "[analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it"

2021-09-02 Thread Kristóf Umann via cfe-commits

Author: Kristóf Umann
Date: 2021-09-02T17:19:49+02:00
New Revision: 3891b45a06f9192b7185d03269717cd60dfdea13

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

LOG: Revert "[analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to 
check entire function calls, rather than each ExplodedNode in it"

This reverts commit 7d0e62bfb773c68d2bc8831fddcc8536f4613190.

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/unittests/StaticAnalyzer/CMakeLists.txt
clang/unittests/StaticAnalyzer/CallEventTest.cpp
clang/unittests/StaticAnalyzer/CheckerRegistration.h
clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp

Removed: 
clang/unittests/StaticAnalyzer/NoStateChangeFuncVisitorTest.cpp



diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
index c42521376af92..139b0dcd51704 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -633,9 +633,6 @@ class CXXConstructorCall;
 /// Descendants can define what a "state change is", like a change of value
 /// to a memory region, liveness, etc. For function calls where the state did
 /// not change as defined, a custom note may be constructed.
-///
-/// For a minimal example, check out
-/// clang/unittests/StaticAnalyzer/NoStateChangeFuncVisitorTest.cpp.
 class NoStateChangeFuncVisitor : public BugReporterVisitor {
 private:
   /// Frames modifying the state as defined in \c wasModifiedBeforeCallExit.
@@ -646,8 +643,6 @@ class NoStateChangeFuncVisitor : public BugReporterVisitor {
   /// many times (going up the path for each node and checking whether the
   /// region was written into) we instead lazily compute the stack frames
   /// along the path.
-  // TODO: Can't we just use a map instead? This is likely not as cheap as it
-  // makes the code 
diff icult to read.
   llvm::SmallPtrSet FramesModifying;
   llvm::SmallPtrSet FramesModifyingCalculated;
 
@@ -656,8 +651,6 @@ class NoStateChangeFuncVisitor : public BugReporterVisitor {
   /// The calculation is cached in FramesModifying.
   bool isModifiedInFrame(const ExplodedNode *CallExitBeginN);
 
-  void markFrameAsModifying(const StackFrameContext *SCtx);
-
   /// Write to \c FramesModifying all stack frames along the path in the 
current
   /// stack frame which modifies the state.
   void findModifyingFrames(const ExplodedNode *const CallExitBeginN);
@@ -665,37 +658,11 @@ class NoStateChangeFuncVisitor : public 
BugReporterVisitor {
 protected:
   bugreporter::TrackingKind TKind;
 
-  /// \return Whether the state was modified from the current node, \p CurrN, 
to
-  /// the end of the stack frame, at \p CallExitBeginN. \p CurrN and
-  /// \p CallExitBeginN are always in the same stack frame.
-  /// Clients should override this callback when a state change is important
-  /// not only on the entire function call, but inside of it as well.
-  /// Example: we may want to leave a note about the lack of locking/unlocking
-  /// on a particular mutex, but not if inside the function its state was
-  /// changed, but also restored. wasModifiedInFunction() wouldn't know of this
-  /// change.
-  virtual bool wasModifiedBeforeCallExit(const ExplodedNode *CurrN,
- const ExplodedNode *CallExitBeginN) {
-return false;
-  }
-
-  /// \return Whether the state was modified in the inlined function call in
-  /// between \p CallEnterN and \p CallExitEndN. Mind that the stack frame
-  /// retrieved from a CallEnterN and CallExitEndN is the *caller's* stack
-  /// frame! The inlined function's stack should be retrieved from either the
-  /// immediate successor to \p CallEnterN or immediate predecessor to
-  /// \p CallExitEndN.
-  /// Clients should override this function if a state changes local to the
-  /// inlined function are not interesting, only the change occuring as a
-  /// result of it.
-  /// Example: we want to leave a not about a leaked resource object not being
-  /// deallocated / its ownership changed inside a function, and we don't care
-  /// if it was assigned to a local variable (its change in ownership is
-  /// inconsequential).
-  virtual bool wasModifiedInFunction(const ExplodedNode *CallEnterN,
- const ExplodedNode *CallExitEndN) {
-return false;
-  }
+  /// \return Whether the state was modified from the current n

[PATCH] D108976: [clang][tooling] Accept custom diagnostic options in ToolInvocation

2021-09-02 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Could you add a test case for this change? Maybe a unit test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108976

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


[PATCH] D108976: [clang][tooling] Accept custom diagnostic options in ToolInvocation

2021-09-02 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In D108976#2979867 , @arphaman wrote:

> Could you add a test case for this change? Maybe a unit test?

Ah I see, you mentioned that the tests are in a follow-up patch. Sorry about 
that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108976

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


[PATCH] D108982: [clang][deps] Use correct DiagnosticOptions for command-line handling

2021-09-02 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.

LGTM, thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108982

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


[PATCH] D108370: [clang-tidy] Fix wrong FixIt about union in cppcoreguidelines-pro-type-member-init

2021-09-02 Thread gehry via Phabricator via cfe-commits
Sockke added a comment.

Hi, Could anyone please review this diff?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108370

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


[PATCH] D105092: [RISCV] Add the tail policy argument to builtins/intrinsics.

2021-09-02 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai updated this revision to Diff 370285.
HsiangKai added a comment.

Update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105092

Files:
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
  llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/rvv/common-shuffle-patterns.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-buildvec.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-shuffles.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-shuffles.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
  llvm/test/CodeGen/RISCV/rvv/interleave-crash.ll
  llvm/test/CodeGen/RISCV/rvv/mgather-sdnode.ll
  llvm/test/CodeGen/RISCV/rvv/tail-agnostic-impdef-copy.mir
  llvm/test/CodeGen/RISCV/rvv/vaadd-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vaadd-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vaaddu-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vaaddu-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vadd-policy.ll
  llvm/test/CodeGen/RISCV/rvv/vadd-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vadd-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vand-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vand-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vasub-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vasub-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vasubu-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vasubu-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vdiv-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vdiv-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vdivu-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vdivu-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfadd-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfadd-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfcvt-f-x-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfcvt-f-x-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfcvt-f-xu-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfcvt-f-xu-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfcvt-rtz-x-f-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfcvt-rtz-x-f-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfcvt-rtz-xu-f-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfcvt-rtz-xu-f-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfcvt-x-f-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfcvt-x-f-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfcvt-xu-f-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfcvt-xu-f-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfdiv-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfdiv-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfmax-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfmax-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfmin-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfmin-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfmul-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfmul-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-f-f-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-f-f-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-f-x-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-f-x-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-f-xu-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-f-xu-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-rod-f-f-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-rod-f-f-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-rtz-x-f-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-rtz-x-f-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-rtz-xu-f-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-rtz-xu-f-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-x-f-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-x-f-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-xu-f-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-xu-f-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfrdiv-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfrdiv-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfrec7-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfrec7-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfrsqrt7-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfrsqrt7-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfrsub-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfrsub-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfsgnj-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfsgnj-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfsgnjn-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfsgnjn-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfsgnjx-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfsgnjx-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfslide1down-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfslide1down-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfslide1up-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfslide1up-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfsqrt-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfsqrt-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfsub-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfsub-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfwadd-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfwadd-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfwadd.w-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfwadd.w-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfwcvt-f-f-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vfwcvt-f-f-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vfwc

[PATCH] D104285: [analyzer] Retrieve a value from list initialization of constant array declaration in a global scope.

2021-09-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 370284.
ASDenysPetrov retitled this revision from "[analyzer][AST] Retrieve value by 
direct index from list initialization of constant array declaration." to 
"[analyzer] Retrieve a value from list initialization of constant array 
declaration in a global scope.".
ASDenysPetrov edited the summary of this revision.
ASDenysPetrov added a comment.

Changed the Title. Changed the Summary.


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

https://reviews.llvm.org/D104285

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/initialization.c
  clang/test/Analysis/initialization.cpp

Index: clang/test/Analysis/initialization.cpp
===
--- clang/test/Analysis/initialization.cpp
+++ clang/test/Analysis/initialization.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++14 -triple i386-apple-darwin10 -analyze -analyzer-checker=core.builtin,debug.ExprInspection -verify %s
+// RUN: %clang_cc1 -std=c++14 -triple i386-apple-darwin10 -analyze -analyzer-config eagerly-assume=false -analyzer-checker=core.uninitialized.Assign,core.builtin,debug.ExprInspection,core.uninitialized.UndefReturn -verify %s
 
 void clang_analyzer_eval(int);
 
@@ -18,3 +18,113 @@
   // FIXME: Should recognize that it is 0.
   clang_analyzer_eval(arr[i][0]); // expected-warning{{UNKNOWN}}
 }
+
+int const glob_arr1[3] = {};
+void glob_array_index1() {
+  clang_analyzer_eval(glob_arr1[0] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr1[1] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr1[2] == 0); // expected-warning{{TRUE}}
+}
+
+void glob_invalid_index1() {
+  const int *ptr = glob_arr1;
+  int idx = -42;
+  auto x = ptr[idx]; // expected-warning{{garbage or undefined}}
+}
+
+int const glob_arr2[4] = {1, 2};
+void glob_ptr_index1() {
+  int const *ptr = glob_arr2;
+  clang_analyzer_eval(ptr[0] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr[1] == 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr[2] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr[3] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr[4] == 0); // expected-warning{{UNDEFINED}}
+}
+
+void glob_invalid_index2() {
+  const int *ptr = glob_arr2;
+  int idx = 42;
+  auto x = ptr[idx]; // expected-warning{{garbage or undefined}}
+}
+
+const float glob_arr3[] = {
+0., 0.0235, 0.0470, 0.0706, 0.0941, 0.1176};
+float no_warn_garbage_value() {
+  return glob_arr3[0]; // no-warning (garbage or undefined)
+}
+
+// TODO: Support multidimensional array.
+int const glob_arr4[4][2] = {};
+void glob_array_index2() {
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(glob_arr4[1][0] == 0); // expected-warning{{UNKNOWN}}
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(glob_arr4[1][1] == 0); // expected-warning{{UNKNOWN}}
+}
+
+// TODO: Support multidimensional array.
+void glob_invalid_index3() {
+  int idx = -42;
+  // FIXME: Should warn {{garbage or undefined}}.
+  auto x = glob_arr4[1][idx]; // no-warning
+}
+
+// TODO: Support multidimensional array.
+void glob_invalid_index4() {
+  const int *ptr = glob_arr4[1];
+  int idx = -42;
+  // FIXME: Should warn {{garbage or undefined}}.
+  auto x = ptr[idx]; // no-warning
+}
+
+// TODO: Support multidimensional array.
+int const glob_arr5[4][2] = {{1}, 3, 4, 5};
+void glob_array_index3() {
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(glob_arr5[0][0] == 1); // expected-warning{{UNKNOWN}}
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(glob_arr5[0][1] == 0); // expected-warning{{UNKNOWN}}
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(glob_arr5[1][0] == 3); // expected-warning{{UNKNOWN}}
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(glob_arr5[1][1] == 4); // expected-warning{{UNKNOWN}}
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(glob_arr5[2][0] == 5); // expected-warning{{UNKNOWN}}
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(glob_arr5[2][1] == 0); // expected-warning{{UNKNOWN}}
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(glob_arr5[3][0] == 0); // expected-warning{{UNKNOWN}}
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(glob_arr5[3][1] == 0); // expected-warning{{UNKNOWN}}
+}
+
+// TODO: Support multidimensional array.
+void glob_ptr_index2() {
+  int const *ptr = glob_arr5[1];
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(ptr[0] == 3); // expected-warning{{UNKNOWN}}
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(ptr[1] == 4); // expected-warning{{UNKNOWN}}
+  // FIXME: Should be UNDEFINED.
+  clang_analyzer_eval(ptr[2] == 5); // expected-warning{{UNKNOWN}}
+  // FIXME: Should be UNDEFINED.
+  clang_analyzer_eval(ptr[3] == 0); // expected-warning{{UNKNOWN}}
+  // FIXME: Should be UNDEFINED.
+  clang_analyzer_eval(ptr[4] == 0); // expected-warning{{UNKNOWN}}
+}
+
+// TODO: Support multidimensional array.
+void glob_invalid_index5() {
+  int idx = -42;
+  // FI

[PATCH] D107430: [OMPIRBuilder] Add ordered directive to OMPIRBuilder

2021-09-02 Thread Peixin Qiao via Phabricator via cfe-commits
peixin added a comment.

@Meinersbur  Thanks a lot for your review and accepting this patch.
BTW, I finished the implementation of the codegen of ordered construct for LLVM 
Flang and the OpenMP IRBuilder of ordered construct in this patch also works 
well for LLVM Flang. Is it OK to land this patch now or does it need more 
review?


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

https://reviews.llvm.org/D107430

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


[PATCH] D104285: [analyzer] Retrieve a value from list initialization of constant array declaration in a global scope.

2021-09-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

Now this patch supports only one-dimensional arrays. Previously there were a 
bug when didn't take into account array's dimension.


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

https://reviews.llvm.org/D104285

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


[PATCH] D107430: [OMPIRBuilder] Add ordered directive to OMPIRBuilder

2021-09-02 Thread Peixin Qiao via Phabricator via cfe-commits
peixin added a comment.

Here is the PR for codegen of ordered construct for LLVM Flang: 
https://github.com/flang-compiler/f18-llvm-project/pull/1027.
I create the PR on fir-dev branch since the test of lowering parse-tree to MLIR 
for LLVM Flang is still not supported in upstream llvm-project.


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

https://reviews.llvm.org/D107430

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


[PATCH] D109127: Use python 3 in add_new_check.py and rename_check.py

2021-09-02 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

Hey, thanks for noticing!

Ugh, I think that's not good, I was trying to make sure the `io.open` piece 
really works with Python 2 and Python 3 as this was the purpose fo the patch :( 
I need t check that again, I think it's really unfortunate to lose Python 2 
support if that's the only reason here. Personally, I think moving to Python 3 
completely is a great idea but I would anticipate many buildbots and some older 
distro versions not having it/being reluctant. As of right now, we still have 
the >= 2.7 requirement so I think the best option is to keep both somehow :(

Thanks for bringing it up!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109127

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


[PATCH] D107430: [OMPIRBuilder] Add ordered directive to OMPIRBuilder

2021-09-02 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan added a comment.

Thanks @peixin. I am going through the patch today and will accept or provide 
some comments.


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

https://reviews.llvm.org/D107430

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


[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-09-02 Thread Varun Gandhi via Phabricator via cfe-commits
varungandhi-apple added a comment.

cc @JDevlieghere


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109128

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


[clang] 123f811 - Try to unbreak Win build after 973519826edb76

2021-09-02 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-09-02T12:06:53-04:00
New Revision: 123f811fe5b0ba33f271c1c6172e6dff1463717a

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

LOG: Try to unbreak Win build after 973519826edb76

Apparently some versions of the MS STL don't like constructing a
vector from a StringMapKeyIterator<>: http://45.33.8.238/win/44999/step_4.txt
It builds fine with the MS STL on my Windows box, so just sidestep the issue.

Full error for posterity:

VC\Tools\MSVC\14.14.26428\include\xmemory(218,75):
  error: indirection requires pointer operand ('const 
llvm::StringMapKeyIterator' invalid)
  _Uses_default_construct_t<_Alloc, decltype(_Unfancy(_UDest)), 
decltype(*_UFirst)>(;
VC\Tools\MSVC\14.14.26428\include\vector(1922,11):
  note: in instantiation of function template specialization 
'std::_Uninitialized_copy<...>' requested here
return (_Uninitialized_copy(_First, _Last, _Dest, 
this->_Getal()));
VC\Tools\MSVC\14.14.26428\include\vector(757,22):
  note: in instantiation of function template specialization

'std::vector::_Ucopy>'
 requested here
this->_Mylast() = _Ucopy(_First, _Last, 
this->_Myfirst());
VC\Tools\MSVC\14.14.26428\include\vector(772,3):
  note: in instantiation of function template specialization

'std::vector::_Range_construct_or_tidy>'
 requested here
_Range_construct_or_tidy(_Unchecked(_First), 
_Unchecked(_Last), _Iter_cat_t<_Iter>{});
../../clang/lib/Driver/ToolChains/Arch/X86.cpp(62,30):
  note: in instantiation of function template specialization

'std::vector::vector,
 void>' requested here
  std::vector ValidArchs{ArchMap.keys().begin(),

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/X86.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index bfa008f964e19..2e43c455b28fd 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -59,8 +59,9 @@ std::string x86::getX86TargetCPU(const Driver &D, const 
ArgList &Args,
 }
 StringRef CPU = ArchMap.lookup(A->getValue());
 if (CPU.empty()) {
-  std::vector ValidArchs{ArchMap.keys().begin(),
-ArchMap.keys().end()};
+  std::vector ValidArchs;
+  for (StringRef Key : ArchMap.keys())
+ValidArchs.push_back(Key);
   sort(ValidArchs);
   D.Diag(diag::warn_drv_invalid_arch_name_with_suggestion)
   << A->getValue() << (Triple.getArch() == llvm::Triple::x86)



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


[clang-tools-extra] e1bb54b - [clangd, llvm] Remove redundant calls to c_str() (NFC)

2021-09-02 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2021-09-02T09:07:13-07:00
New Revision: e1bb54b5930544b48c3a94069c037648a6adfc65

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

LOG: [clangd, llvm] Remove redundant calls to c_str() (NFC)

Identified with readability-redundant-string-cstr.

Added: 


Modified: 
clang-tools-extra/clangd/PathMapping.cpp
llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
llvm/tools/bugpoint/OptimizerDriver.cpp
llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
llvm/tools/llvm-lto/llvm-lto.cpp
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/PathMapping.cpp 
b/clang-tools-extra/clangd/PathMapping.cpp
index 0cd9d22b998ca..cc98025393841 100644
--- a/clang-tools-extra/clangd/PathMapping.cpp
+++ b/clang-tools-extra/clangd/PathMapping.cpp
@@ -40,7 +40,7 @@ llvm::Optional doPathMapping(llvm::StringRef S,
 llvm::StringRef Body = Uri->body();
 if (Body.consume_front(From) && (Body.empty() || Body.front() == '/')) {
   std::string MappedBody = (To + Body).str();
-  return URI(Uri->scheme(), Uri->authority(), MappedBody.c_str())
+  return URI(Uri->scheme(), Uri->authority(), MappedBody)
   .toString();
 }
   }

diff  --git a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp 
b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
index fe335f154703c..1cbd650bdf064 100644
--- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
+++ b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
@@ -26,7 +26,7 @@ NVPTXTargetStreamer::~NVPTXTargetStreamer() = default;
 
 void NVPTXTargetStreamer::outputDwarfFileDirectives() {
   for (const std::string &S : DwarfFiles)
-getStreamer().emitRawText(S.data());
+getStreamer().emitRawText(S);
   DwarfFiles.clear();
 }
 

diff  --git a/llvm/tools/bugpoint/OptimizerDriver.cpp 
b/llvm/tools/bugpoint/OptimizerDriver.cpp
index ca78735202fcb..848baf90965be 100644
--- a/llvm/tools/bugpoint/OptimizerDriver.cpp
+++ b/llvm/tools/bugpoint/OptimizerDriver.cpp
@@ -223,8 +223,8 @@ bool BugDriver::runPasses(Module &Program,
   for (std::vector::const_iterator I = pass_args.begin(),
 E = pass_args.end();
I != E; ++I)
-Args.push_back(I->c_str());
-  Args.push_back(Temp->TmpName.c_str());
+Args.push_back(*I);
+  Args.push_back(Temp->TmpName);
   Args.append(ExtraArgs.begin(), ExtraArgs.end());
 
   LLVM_DEBUG(errs() << "\nAbout to run:\t";

diff  --git a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp 
b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
index fbb882e4d2a8f..83c83197118d5 100644
--- a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
+++ b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
@@ -337,7 +337,7 @@ static llvm::Error handleObjectFile(ObjectFile &Obj,
   // Save the GSYM file to disk.
   support::endianness Endian =
   Obj.makeTriple().isLittleEndian() ? support::little : support::big;
-  if (auto Err = Gsym.save(OutFile.c_str(), Endian))
+  if (auto Err = Gsym.save(OutFile, Endian))
 return Err;
 
   // Verify the DWARF if requested. This will ensure all the info in the DWARF
@@ -359,7 +359,7 @@ static llvm::Error handleBuffer(StringRef Filename, 
MemoryBufferRef Buffer,
 Triple ObjTriple(Obj->makeTriple());
 auto ArchName = ObjTriple.getArchName();
 outs() << "Output file (" << ArchName << "): " << OutFile << "\n";
-if (auto Err = handleObjectFile(*Obj, OutFile.c_str()))
+if (auto Err = handleObjectFile(*Obj, OutFile))
   return Err;
   } else if (auto *Fat = dyn_cast(BinOrErr->get())) {
 // Iterate over all contained architectures and filter out any that were

diff  --git a/llvm/tools/llvm-lto/llvm-lto.cpp 
b/llvm/tools/llvm-lto/llvm-lto.cpp
index 183798634a8be..5332ef28d94e7 100644
--- a/llvm/tools/llvm-lto/llvm-lto.cpp
+++ b/llvm/tools/llvm-lto/llvm-lto.cpp
@@ -1059,7 +1059,7 @@ int main(int argc, char **argv) {
 CodeGen.addMustPreserveSymbol(KeptDSOSyms[i]);
 
   // Set cpu and attrs strings for the default target/subtarget.
-  CodeGen.setCpu(codegen::getMCPU().c_str());
+  CodeGen.setCpu(codegen::getMCPU());
 
   CodeGen.setOptLevel(OptLevel - '0');
   CodeGen.setAttrs(codegen::getMAttrs());

diff  --git a/llvm/tools/llvm-readobj/ELFDumper.cpp 
b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 1073f22ddd091..273fa8ae9b439 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -4362,7 +4362,7 @@ template  void 
GNUELFDumper::printDynamicTable() {
   for (auto Entry : Table) {
 uintX_t Tag = Entry.getTag();
 std::string Type =
-std::string("(") + this->Obj.getDynamicTagAsString(Tag).c_str() + ")";
+std::string("(") + this->Obj.getDynamicTagAsString(Tag) + ")";
 std:

[clang] e5438f3 - clang/win: Add __readfsdword to intrin.h

2021-09-02 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-09-02T12:22:07-04:00
New Revision: e5438f386854136d848989315f53788808afa37a

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

LOG: clang/win: Add __readfsdword to intrin.h

When using __readfsdword(), clang used to warn that one has
to include  -- no matter if that was already included
or not.

Now it only warns if it's not yet included.

To verify that this was the only intrin with this problem, I ran:

$ for f in $(grep intrin.h clang/include/clang/Basic/BuiltinsX86* |
 egrep -o '\([^,]+,' | egrep -o '[^(,]*'); do
if ! grep -q $f clang/lib/Headers/intrin.h; then echo $f; fi;
  done

This printed 9 more functions, but those are all in emmintrin.h,
xsaveintrin.h (which are included by intrin.h based on /arch: flags).
So this is indeed the only built-in that was missing in intrin.h.

Fixes PR51188.

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

Added: 


Modified: 
clang/lib/Headers/intrin.h
clang/test/CodeGen/X86/ms-x86-intrinsics.c

Removed: 




diff  --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h
index 34ec79d6acbc6..4803277472ee8 100644
--- a/clang/lib/Headers/intrin.h
+++ b/clang/lib/Headers/intrin.h
@@ -97,8 +97,9 @@ unsigned long __readcr8(void);
 unsigned int __readdr(unsigned int);
 #ifdef __i386__
 unsigned char __readfsbyte(unsigned long);
-unsigned __int64 __readfsqword(unsigned long);
 unsigned short __readfsword(unsigned long);
+unsigned long __readfsdword(unsigned long);
+unsigned __int64 __readfsqword(unsigned long);
 #endif
 unsigned __int64 __readmsr(unsigned long);
 unsigned __int64 __readpmc(unsigned long);

diff  --git a/clang/test/CodeGen/X86/ms-x86-intrinsics.c 
b/clang/test/CodeGen/X86/ms-x86-intrinsics.c
index 6f745ff00f54e..0eca455bb5c32 100644
--- a/clang/test/CodeGen/X86/ms-x86-intrinsics.c
+++ b/clang/test/CodeGen/X86/ms-x86-intrinsics.c
@@ -1,10 +1,12 @@
-// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
+// RUN: %clang_cc1 -Werror -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple i686--windows -Oz -emit-llvm %s -o - \
 // RUN: | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-I386
-// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
+// RUN: %clang_cc1 -Werror -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple x86_64--windows -Oz -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-X64
 
+#include 
+
 #if defined(__i386__)
 char test__readfsbyte(unsigned long Offset) {
   return __readfsbyte(++Offset);



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


[PATCH] D109085: clang/win: Add __readfsdword to intrin.h

2021-09-02 Thread Nico Weber 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 rGe5438f386854: clang/win: Add __readfsdword to intrin.h 
(authored by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109085

Files:
  clang/lib/Headers/intrin.h
  clang/test/CodeGen/X86/ms-x86-intrinsics.c


Index: clang/test/CodeGen/X86/ms-x86-intrinsics.c
===
--- clang/test/CodeGen/X86/ms-x86-intrinsics.c
+++ clang/test/CodeGen/X86/ms-x86-intrinsics.c
@@ -1,10 +1,12 @@
-// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
+// RUN: %clang_cc1 -Werror -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple i686--windows -Oz -emit-llvm %s -o - \
 // RUN: | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-I386
-// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
+// RUN: %clang_cc1 -Werror -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple x86_64--windows -Oz -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-X64
 
+#include 
+
 #if defined(__i386__)
 char test__readfsbyte(unsigned long Offset) {
   return __readfsbyte(++Offset);
Index: clang/lib/Headers/intrin.h
===
--- clang/lib/Headers/intrin.h
+++ clang/lib/Headers/intrin.h
@@ -97,8 +97,9 @@
 unsigned int __readdr(unsigned int);
 #ifdef __i386__
 unsigned char __readfsbyte(unsigned long);
-unsigned __int64 __readfsqword(unsigned long);
 unsigned short __readfsword(unsigned long);
+unsigned long __readfsdword(unsigned long);
+unsigned __int64 __readfsqword(unsigned long);
 #endif
 unsigned __int64 __readmsr(unsigned long);
 unsigned __int64 __readpmc(unsigned long);


Index: clang/test/CodeGen/X86/ms-x86-intrinsics.c
===
--- clang/test/CodeGen/X86/ms-x86-intrinsics.c
+++ clang/test/CodeGen/X86/ms-x86-intrinsics.c
@@ -1,10 +1,12 @@
-// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
+// RUN: %clang_cc1 -Werror -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
 // RUN: -triple i686--windows -Oz -emit-llvm %s -o - \
 // RUN: | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-I386
-// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
+// RUN: %clang_cc1 -Werror -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
 // RUN: -triple x86_64--windows -Oz -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-X64
 
+#include 
+
 #if defined(__i386__)
 char test__readfsbyte(unsigned long Offset) {
   return __readfsbyte(++Offset);
Index: clang/lib/Headers/intrin.h
===
--- clang/lib/Headers/intrin.h
+++ clang/lib/Headers/intrin.h
@@ -97,8 +97,9 @@
 unsigned int __readdr(unsigned int);
 #ifdef __i386__
 unsigned char __readfsbyte(unsigned long);
-unsigned __int64 __readfsqword(unsigned long);
 unsigned short __readfsword(unsigned long);
+unsigned long __readfsdword(unsigned long);
+unsigned __int64 __readfsqword(unsigned long);
 #endif
 unsigned __int64 __readmsr(unsigned long);
 unsigned __int64 __readpmc(unsigned long);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108560: [clang-tidy] Add support for NOLINTBEGIN ... NOLINTEND comments to suppress clang-tidy warnings over multiple lines

2021-09-02 Thread Salman Javed via Phabricator via cfe-commits
salman-javed-nz updated this revision to Diff 370293.
salman-javed-nz added a comment.

Add additional checks in `test/clang-tidy/infrastructure/nolintbeginend.cpp` to 
check that error suppressions in one file are carried over when the file is 
`#included` in another file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108560

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/nolintbeginend/error_in_include.inc
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/nolintbeginend/nolint_in_include.inc
  clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
@@ -0,0 +1,82 @@
+// RUN: %check_clang_tidy %s google-explicit-constructor %t -- --header-filter=.* -system-headers -- -isystem %S/Inputs/nolintbeginend
+
+class A { A(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+// NOLINTBEGIN
+class B { B(int i); };
+// NOLINTEND
+
+// NOLINTBEGIN
+// NOLINTEND
+// NOLINTBEGIN
+class B1 { B1(int i); };
+// NOLINTEND
+
+// NOLINTBEGIN
+// NOLINTEND
+class B2 { B2(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// NOLINTBEGIN(google-explicit-constructor)
+class C { C(int i); };
+// NOLINTEND(google-explicit-constructor)
+
+// NOLINTBEGIN(*)
+class C1 { C1(int i); };
+// NOLINTEND(*)
+
+// NOLINTBEGIN(some-other-check)
+class C2 { C2(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+// NOLINTEND(some-other-check)
+
+// NOLINTBEGIN(some-other-check, google-explicit-constructor)
+class C3 { C3(int i); };
+// NOLINTEND(some-other-check, google-explicit-constructor)
+
+// NOLINTBEGIN(some-other-check, google-explicit-constructor)
+// NOLINTEND(some-other-check)
+class C4 { C4(int i); };
+// NOLINTEND(google-explicit-constructor)
+
+// NOLINTBEGIN(some-other-check, google-explicit-constructor)
+// NOLINTEND(google-explicit-constructor)
+class C5 { C5(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+// NOLINTEND(some-other-check)
+
+// NOLINTBEGIN(google-explicit-constructor)
+// NOLINTBEGIN(some-other-check)
+class C6 { C6(int i); };
+// NOLINTEND(some-other-check)
+// NOLINTEND(google-explicit-constructor)
+
+// NOLINTBEGIN(not-closed-bracket-is-treated-as-skip-all
+class C7 { C7(int i); };
+// NOLINTEND(not-closed-bracket-is-treated-as-skip-all
+
+// NOLINTBEGIN without-brackets-skip-all, another-check
+class C8 { C8(int i); };
+// NOLINTEND without-brackets-skip-all, another-check
+
+#define MACRO(X) class X { X(int i); };
+
+MACRO(D1)
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
+
+// NOLINTBEGIN
+MACRO(D2)
+// NOLINTEND
+
+#define MACRO_NOARG class E { E(int i); };
+// NOLINTBEGIN
+MACRO_NOARG
+// NOLINTEND
+
+#include "error_in_include.inc"
+// CHECK-MESSAGES: warning: single-argument constructors must be marked explicit
+
+#include "nolint_in_include.inc"
+
+// CHECK-MESSAGES: Suppressed 12 warnings (12 NOLINT)
Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/nolintbeginend/nolint_in_include.inc
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/Inputs/nolintbeginend/nolint_in_include.inc
@@ -0,0 +1,3 @@
+// NOLINTBEGIN
+class G { G(int i); };
+// NOLINTEND
Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/nolintbeginend/error_in_include.inc
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/Inputs/nolintbeginend/error_in_include.inc
@@ -0,0 +1 @@
+class F { F(int i); };
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -295,17 +295,19 @@
 
 If a specific suppression mechanism is not available for a certain warning, or
 its use is not desired for some reason, :program:`clang-tidy` has a generic
-mechanism to suppress diagnostics using ``NOLINT`` or ``NOLINTNEXTLINE``
-comments.
+mechanism to suppress diagnostics using ``NOLINT``, ``NOLINTNEXTLINE``, and
+``NOLINTBEGIN`` ... ``NOLINTEND`` comments.
 
 The ``NOLINT`` comment instructs :program:`clang-tidy` to ignore warnings on the
 *same line* (it doesn't apply to a function, a block of code or any other
 language cons

[PATCH] D109078: [clang][driver][AIX] Add system libc++ header paths to driver

2021-09-02 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA added inline comments.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:237
+addSystemInclude(DriverArgs, CC1Args, PathCPP.str());
+CC1Args.push_back("-D__LIBC_NO_CPP_MATH_OVERLOADS__");
+return;

Maybe a comment as to why we need this, something like:
```
// Required  order to suppress conflicting C++ overloads in the system libc 
headers that were used by XL C++
```



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:240-242
+  case ToolChain::CST_Libstdcxx:
+llvm::report_fatal_error(
+"picking up libstdc++ headers is unimplemented on AIX");

nit: it would be my preference to have the error case first but I also that 
`AIX::AddCXXStdlibLibArgs` is set up the same way so keeping them consistent 
may be more important.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109078

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


[libunwind] 1bc175d - [Unwind] Cast exception class pointer for strcpy

2021-09-02 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-09-02T19:01:30+02:00
New Revision: 1bc175d486b5bf2ae5dd46c1e85342f2f2734b1f

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

LOG: [Unwind] Cast exception class pointer for strcpy

Follow-up to f5b997e6b706, see comment on
https://reviews.llvm.org/D109047

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

Added: 


Modified: 
libunwind/src/UnwindLevel1-gcc-ext.c

Removed: 




diff  --git a/libunwind/src/UnwindLevel1-gcc-ext.c 
b/libunwind/src/UnwindLevel1-gcc-ext.c
index c3fa8b6655713..4172540ef0874 100644
--- a/libunwind/src/UnwindLevel1-gcc-ext.c
+++ b/libunwind/src/UnwindLevel1-gcc-ext.c
@@ -109,7 +109,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
   // Create a mock exception object for force unwinding.
   _Unwind_Exception ex;
   memset(&ex, '\0', sizeof(ex));
-  strcpy(&ex.exception_class, "CLNGUNW");
+  strcpy((char *)&ex.exception_class, "CLNGUNW");
 #endif
 
   // walk each frame



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


[PATCH] D109174: [MSP430][Clang] Infer CPU type from -mcpu= or -mmcu=

2021-09-02 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl created this revision.
jozefl added reviewers: asl, atrosinenko.
Herald added a subscriber: hiraditya.
jozefl requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

clang::driver::tools::getCPUName can now infer the CPU being used by
examining either the MCU specified with the -mmcu= option, or the CPU
directly specified with -mcpu=.

This means Clang will now pass the correct "-target-cpu" to downstream
tools, enabling CPU-specific features in LLVM.

The MSP430X CPU can now be selected, in addition to the "generic" MSP430
CPU.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109174

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Basic/Targets/MSP430.cpp
  clang/lib/Basic/Targets/MSP430.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/lib/Driver/ToolChains/MSP430.h
  clang/test/Driver/msp430-cpu.c
  clang/test/Driver/msp430-mmcu.c
  clang/test/Driver/msp430-toolchain.c
  clang/test/Misc/target-invalid-cpu-note.c
  clang/test/Preprocessor/msp430-defs.c
  llvm/lib/Target/MSP430/MSP430.td
  llvm/lib/Target/MSP430/MSP430Subtarget.cpp
  llvm/lib/Target/MSP430/MSP430Subtarget.h
  llvm/test/CodeGen/MSP430/build-attrs.ll

Index: llvm/test/CodeGen/MSP430/build-attrs.ll
===
--- llvm/test/CodeGen/MSP430/build-attrs.ll
+++ llvm/test/CodeGen/MSP430/build-attrs.ll
@@ -8,6 +8,8 @@
 ; RUN:   | llvm-readelf -A - | FileCheck %s --check-prefixes COMMON,MSP430,SMALL
 ; RUN: llc -mtriple=msp430 -mcpu=msp430x -filetype=obj < %s \
 ; RUN:   | llvm-readelf -A - | FileCheck %s --check-prefixes COMMON,MSP430X,SMALL
+; RUN: llc -mtriple=msp430 -mcpu=msp430xv2 -filetype=obj < %s \
+; RUN:   | llvm-readelf -A - | FileCheck %s --check-prefixes COMMON,MSP430X,SMALL
 
 ; COMMON: BuildAttributes {
 ; COMMON: FormatVersion: 0x41
Index: llvm/lib/Target/MSP430/MSP430Subtarget.h
===
--- llvm/lib/Target/MSP430/MSP430Subtarget.h
+++ llvm/lib/Target/MSP430/MSP430Subtarget.h
@@ -36,7 +36,7 @@
 
 private:
   virtual void anchor();
-  bool ExtendedInsts = false;
+  bool MSP430X = false;
   HWMultEnum HWMultMode = NoHWMult;
   MSP430FrameLowering FrameLowering;
   MSP430InstrInfo InstrInfo;
@@ -60,6 +60,8 @@
   bool hasHWMult32() const { return HWMultMode == HWMult32; }
   bool hasHWMultF5() const { return HWMultMode == HWMultF5; }
 
+  bool hasMSP430X() const { return MSP430X; }
+
   const TargetFrameLowering *getFrameLowering() const override {
 return &FrameLowering;
   }
Index: llvm/lib/Target/MSP430/MSP430Subtarget.cpp
===
--- llvm/lib/Target/MSP430/MSP430Subtarget.cpp
+++ llvm/lib/Target/MSP430/MSP430Subtarget.cpp
@@ -40,9 +40,6 @@
 
 MSP430Subtarget &
 MSP430Subtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
-  ExtendedInsts = false;
-  HWMultMode = NoHWMult;
-
   StringRef CPUName = CPU;
   if (CPUName.empty())
 CPUName = "msp430";
Index: llvm/lib/Target/MSP430/MSP430.td
===
--- llvm/lib/Target/MSP430/MSP430.td
+++ llvm/lib/Target/MSP430/MSP430.td
@@ -18,8 +18,8 @@
 // Subtarget Features. 
 //===--===//
 def FeatureX
- : SubtargetFeature<"ext", "ExtendedInsts", "true",
-"Enable MSP430-X extensions">;
+ : SubtargetFeature<"msp430x", "MSP430X", "true",
+"Enable MSP430X extensions">;
 
 def FeatureHWMult16
  : SubtargetFeature<"hwmult16", "HWMultMode", "HWMult16",
@@ -42,6 +42,7 @@
 def : Proc<"generic", []>;
 def : Proc<"msp430",  []>;
 def : Proc<"msp430x", [FeatureX]>;
+def : Proc<"msp430xv2",   [FeatureX]>;
 
 //===--===//
 // Register File Description
Index: clang/test/Preprocessor/msp430-defs.c
===
--- /dev/null
+++ clang/test/Preprocessor/msp430-defs.c
@@ -0,0 +1,20 @@
+// Check the correct macros are defined for each CPU.
+
+// RUN: %clang -target msp430 -x c -E -dM %s -o - | FileCheck  %s
+// RUN: %clang -target msp430 -mcpu=generic -x c -E -dM %s -o - | FileCheck %s
+// RUN: %clang -target msp430 -mcpu=msp430 -x c -E -dM %s -o - | FileCheck %s
+
+// CHECK: MSP430
+// CHECK: __ELF__
+// CHECK-NOT: __MSP430X__
+// CHECK: __MSP430__
+
+// RUN: %clang -target msp430 -mcpu=msp430x -x c -E -dM %s -o - \
+// RUN:   | FileCheck --check-prefix=MSP430X %s
+// RUN: %clang -target msp430 -mcpu=msp430xv2 -x c -E -dM %s -o - \
+// RUN:   | FileCheck --check-prefix=MSP430X %s
+
+// MSP430X: MSP430
+// MSP430X: __ELF__
+// MSP430X: __MSP430X__
+// MSP430X: __MSP430__
Index: clang/test/Misc/target-invalid-

[clang] 37f23ea - [AIX][PowerPC] Define __powerpc and __PPC macros

2021-09-02 Thread Jake Egan via cfe-commits

Author: Jake Egan
Date: 2021-09-02T13:32:35-04:00
New Revision: 37f23ea97fdef4484ef33877c6d8464beafd3b0f

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

LOG: [AIX][PowerPC] Define __powerpc and __PPC macros

%%%
This patch defines the macros __powerpc and __PPC on AIX to be consistent with 
XL for AIX. See: 
https://www.ibm.com/docs/en/xl-c-and-cpp-aix/13.1.0?topic=macros-related-platform

Note: GCC does not currently define __powerpc and __PPC so users should prefer 
the __powerpc__ and __PPC__ forms.
%%%

Reviewed By: cebowleratibm

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

Added: 


Modified: 
clang/lib/Basic/Targets/PPC.cpp
clang/test/Preprocessor/init-ppc.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index c8afb71e7dfd1..8f16f3d9b475c 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -264,6 +264,9 @@ void PPCTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   }
   if (getTriple().isOSAIX()) {
 Builder.defineMacro("__THW_PPC__");
+// Define __PPC and __powerpc for AIX XL C/C++ compatibility
+Builder.defineMacro("__PPC");
+Builder.defineMacro("__powerpc");
   }
 
   // Target properties.

diff  --git a/clang/test/Preprocessor/init-ppc.c 
b/clang/test/Preprocessor/init-ppc.c
index 4f1c33b1dcc3a..611b16dfb8f7e 100644
--- a/clang/test/Preprocessor/init-ppc.c
+++ b/clang/test/Preprocessor/init-ppc.c
@@ -322,6 +322,7 @@
 // PPC:#define __NATURAL_ALIGNMENT__ 1
 // PPC:#define __POINTER_WIDTH__ 32
 // PPC:#define __POWERPC__ 1
+// PPC-NOT:#define __PPC 1
 // PPC:#define __PPC__ 1
 // PPC:#define __PTRDIFF_TYPE__ long int
 // PPC:#define __PTRDIFF_WIDTH__ 32
@@ -386,6 +387,7 @@
 // PPC:#define __WCHAR_WIDTH__ 32
 // PPC:#define __WINT_TYPE__ int
 // PPC:#define __WINT_WIDTH__ 32
+// PPC-NOT:#define __powerpc 1
 // PPC:#define __ppc__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 
-fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix 
PPC-AIX %s
@@ -520,6 +522,7 @@
 // PPC-AIX-NOT:#define __NATURAL_ALIGNMENT__ 1
 // PPC-AIX:#define __POINTER_WIDTH__ 32
 // PPC-AIX:#define __POWERPC__ 1
+// PPC-AIX:#define __PPC 1
 // PPC-AIX:#define __PPC__ 1
 // PPC-AIX:#define __PTRDIFF_TYPE__ long int
 // PPC-AIX:#define __PTRDIFF_WIDTH__ 32
@@ -587,6 +590,7 @@
 // PPC-AIX:#define __WCHAR_WIDTH__ 16
 // PPC-AIX:#define __WINT_TYPE__ int
 // PPC-AIX:#define __WINT_WIDTH__ 32
+// PPC-AIX:#define __powerpc 1
 // PPC-AIX:#define __powerpc__ 1
 // PPC-AIX:#define __ppc__ 1
 



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


[PATCH] D108917: [AIX][PowerPC] Define __powerpc and __PPC macros

2021-09-02 Thread Jake Egan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG37f23ea97fde: [AIX][PowerPC] Define __powerpc and __PPC 
macros (authored by Jake-Egan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108917

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/Preprocessor/init-ppc.c


Index: clang/test/Preprocessor/init-ppc.c
===
--- clang/test/Preprocessor/init-ppc.c
+++ clang/test/Preprocessor/init-ppc.c
@@ -322,6 +322,7 @@
 // PPC:#define __NATURAL_ALIGNMENT__ 1
 // PPC:#define __POINTER_WIDTH__ 32
 // PPC:#define __POWERPC__ 1
+// PPC-NOT:#define __PPC 1
 // PPC:#define __PPC__ 1
 // PPC:#define __PTRDIFF_TYPE__ long int
 // PPC:#define __PTRDIFF_WIDTH__ 32
@@ -386,6 +387,7 @@
 // PPC:#define __WCHAR_WIDTH__ 32
 // PPC:#define __WINT_TYPE__ int
 // PPC:#define __WINT_WIDTH__ 32
+// PPC-NOT:#define __powerpc 1
 // PPC:#define __ppc__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 
-fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix 
PPC-AIX %s
@@ -520,6 +522,7 @@
 // PPC-AIX-NOT:#define __NATURAL_ALIGNMENT__ 1
 // PPC-AIX:#define __POINTER_WIDTH__ 32
 // PPC-AIX:#define __POWERPC__ 1
+// PPC-AIX:#define __PPC 1
 // PPC-AIX:#define __PPC__ 1
 // PPC-AIX:#define __PTRDIFF_TYPE__ long int
 // PPC-AIX:#define __PTRDIFF_WIDTH__ 32
@@ -587,6 +590,7 @@
 // PPC-AIX:#define __WCHAR_WIDTH__ 16
 // PPC-AIX:#define __WINT_TYPE__ int
 // PPC-AIX:#define __WINT_WIDTH__ 32
+// PPC-AIX:#define __powerpc 1
 // PPC-AIX:#define __powerpc__ 1
 // PPC-AIX:#define __ppc__ 1
 
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -264,6 +264,9 @@
   }
   if (getTriple().isOSAIX()) {
 Builder.defineMacro("__THW_PPC__");
+// Define __PPC and __powerpc for AIX XL C/C++ compatibility
+Builder.defineMacro("__PPC");
+Builder.defineMacro("__powerpc");
   }
 
   // Target properties.


Index: clang/test/Preprocessor/init-ppc.c
===
--- clang/test/Preprocessor/init-ppc.c
+++ clang/test/Preprocessor/init-ppc.c
@@ -322,6 +322,7 @@
 // PPC:#define __NATURAL_ALIGNMENT__ 1
 // PPC:#define __POINTER_WIDTH__ 32
 // PPC:#define __POWERPC__ 1
+// PPC-NOT:#define __PPC 1
 // PPC:#define __PPC__ 1
 // PPC:#define __PTRDIFF_TYPE__ long int
 // PPC:#define __PTRDIFF_WIDTH__ 32
@@ -386,6 +387,7 @@
 // PPC:#define __WCHAR_WIDTH__ 32
 // PPC:#define __WINT_TYPE__ int
 // PPC:#define __WINT_WIDTH__ 32
+// PPC-NOT:#define __powerpc 1
 // PPC:#define __ppc__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-ibm-aix7.1.0.0 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC-AIX %s
@@ -520,6 +522,7 @@
 // PPC-AIX-NOT:#define __NATURAL_ALIGNMENT__ 1
 // PPC-AIX:#define __POINTER_WIDTH__ 32
 // PPC-AIX:#define __POWERPC__ 1
+// PPC-AIX:#define __PPC 1
 // PPC-AIX:#define __PPC__ 1
 // PPC-AIX:#define __PTRDIFF_TYPE__ long int
 // PPC-AIX:#define __PTRDIFF_WIDTH__ 32
@@ -587,6 +590,7 @@
 // PPC-AIX:#define __WCHAR_WIDTH__ 16
 // PPC-AIX:#define __WINT_TYPE__ int
 // PPC-AIX:#define __WINT_WIDTH__ 32
+// PPC-AIX:#define __powerpc 1
 // PPC-AIX:#define __powerpc__ 1
 // PPC-AIX:#define __ppc__ 1
 
Index: clang/lib/Basic/Targets/PPC.cpp
===
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -264,6 +264,9 @@
   }
   if (getTriple().isOSAIX()) {
 Builder.defineMacro("__THW_PPC__");
+// Define __PPC and __powerpc for AIX XL C/C++ compatibility
+Builder.defineMacro("__PPC");
+Builder.defineMacro("__powerpc");
   }
 
   // Target properties.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109175: [openmp] Add clang cc1 option -fopenmp-skip-deferred-diags

2021-09-02 Thread Wei Wang via Phabricator via cfe-commits
weiwang created this revision.
Herald added subscribers: hoy, dexonsmith, wenlei, dang, guansong, yaxunl.
weiwang requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

There are cases where no target compilation/offloading would ever happen, but
we are still paying the price for handling deferred diags. The new cc1 option
allows user to explictly skip deferred diags handling in FE.

This results in considerable build time improvement from our internal
workloads.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109175

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/OpenMP/declare_target_messages.cpp


Index: clang/test/OpenMP/declare_target_messages.cpp
===
--- clang/test/OpenMP/declare_target_messages.cpp
+++ clang/test/OpenMP/declare_target_messages.cpp
@@ -6,6 +6,9 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 
-verify=expected,omp5,host5 -fopenmp-simd -fopenmp-is-device -fnoopenmp-use-tls 
-ferror-limit 100 -o - %s
 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp45 
-fopenmp-version=45 -fopenmp-simd -fnoopenmp-use-tls -ferror-limit 100 -o - %s
 
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp5,dev5 
-fopenmp -fopenmp-is-device -fopenmp-targets=x86_64-apple-macos10.7.0 
-aux-triple x86_64-apple-macos10.7.0 -fnoopenmp-use-tls 
-fopenmp-skip-deferred-diags -ferror-limit 100 -o - %s
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 
-verify=expected,omp5,host5 -fopenmp-simd -fopenmp-is-device -fnoopenmp-use-tls 
-fopenmp-skip-deferred-diags -ferror-limit 100 -o - %s
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp5 
-fopenmp -fnoopenmp-use-tls -fopenmp-skip-deferred-diags -ferror-limit 100 -o - 
%s
 #pragma omp end declare target // expected-error {{unexpected OpenMP directive 
'#pragma omp end declare target'}}
 
 int a, b, z; // omp5-error {{variable captured in declare target region must 
appear in a to clause}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12609,7 +12609,8 @@
 VDecl->setInitStyle(VarDecl::ListInit);
   }
 
-  if (LangOpts.OpenMP && VDecl->isFileVarDecl())
+  if (LangOpts.OpenMP && !LangOpts.OpenMPSkipDeferredDiags &&
+  VDecl->isFileVarDecl())
 DeclsToCheckForDeferredDiags.insert(VDecl);
   CheckCompleteVariableDeclaration(VDecl);
 }
@@ -14839,7 +14840,8 @@
 DiscardCleanupsInEvaluationContext();
   }
 
-  if (FD && (LangOpts.OpenMP || LangOpts.CUDA || LangOpts.SYCLIsDevice)) {
+  if (FD && ((LangOpts.OpenMP && !LangOpts.OpenMPSkipDeferredDiags) ||
+ LangOpts.CUDA || LangOpts.SYCLIsDevice)) {
 auto ES = getEmissionStatus(FD);
 if (ES == Sema::FunctionEmissionStatus::Emitted ||
 ES == Sema::FunctionEmissionStatus::Unknown)
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3489,6 +3489,9 @@
   if (Opts.OpenMPCUDAForceFullRuntime)
 GenerateArg(Args, OPT_fopenmp_cuda_force_full_runtime, SA);
 
+  if (Opts.OpenMPSkipDeferredDiags)
+GenerateArg(Args, OPT_fopenmp_skip_deferred_diags, SA);
+
   // The arguments used to set Optimize, OptimizeSize and NoInlineDefine are
   // generated from CodeGenOptions.
 
@@ -3928,6 +3931,10 @@
   Opts.OpenMPIsDevice && (T.isNVPTX() || T.isAMDGCN()) &&
   Args.hasArg(options::OPT_fopenmp_cuda_force_full_runtime);
 
+  Opts.OpenMPSkipDeferredDiags =
+  Opts.OpenMP && !Opts.OpenMPSimd && !IsTargetSpecified &&
+  Args.hasArg(options::OPT_fopenmp_skip_deferred_diags);
+
   // FIXME: Eliminate this dependency.
   unsigned Opt = getOptimizationLevel(Args, IK, Diags),
OptSize = getOptimizationLevelSize(Args);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5799,6 +5799,8 @@
   HelpText<"Generate code only for an OpenMP target device.">;
 def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">,
   HelpText<"Path to the IR file produced by the frontend for the host.">;
+def fopenmp_skip_deferred_diags : Flag<["-"], "fopenmp-skip-deferred-diags">,
+  HelpText<"Do not generate deferred diagnostics for function host/device 
availability. Use this flag only when no offloading or omp target directive is 
used.">;
 
 
//===--===//
 // SYCL Options
Index: clang/include/clang/Basic/LangOptio

[PATCH] D36850: [ThinLTO] Add norecurse function attribute propagation

2021-09-02 Thread Di Mo via Phabricator via cfe-commits
modimo added a comment.

gentle ping @tejohnson


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36850

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


[PATCH] D109175: [openmp] Add clang cc1 option -fopenmp-skip-deferred-diags

2021-09-02 Thread Wei Wang via Phabricator via cfe-commits
weiwang added a comment.

Our internal codebase never uses the target directive. Once the deferred diags 
is bypassed, we observed 18% e2e build time improvement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109175

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


[PATCH] D108982: [clang][deps] Use correct DiagnosticOptions for command-line handling

2021-09-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM too, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108982

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


[PATCH] D108974: [clang][tooling] Properly initialize DiagnosticsEngine for cc1 command-line construction

2021-09-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108974

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


[PATCH] D108976: [clang][tooling] Accept custom diagnostic options in ToolInvocation

2021-09-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.

In D108976#2979598 , @jansvoboda11 
wrote:

> Tests that cover this functionality were moved into a follow-up patch D108974 
> . The reason is to avoid temporary 
> regression pointed out here .

Please document in the commit message that tests are coming later and why. With 
that, LGTM too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108976

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


[PATCH] D91944: OpenMP 5.0 metadirective

2021-09-02 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen added a comment.

I'm guessing the tests were not pass on buildbot but passed on the author's 
side is due to the assertion was disabled on the author's side.
Here is the patch for avoiding all the assertion errors and I'm able to get all 
the metadirective tests passed (and no regression for the existing omp tests) 
with this change:

  diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
  index 5ac6dd0fb55a..3313efe524f3 100644
  --- a/clang/lib/Parse/ParseOpenMP.cpp
  +++ b/clang/lib/Parse/ParseOpenMP.cpp
  @@ -2277,8 +2277,10 @@ Parser::DeclGroupPtrTy 
Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
   ///
   StmtResult
   Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext 
StmtCtx) {
  -  assert(Tok.is(tok::annot_pragma_openmp) && "Not an OpenMP directive!");
 static bool ReadDirectiveWithinMetadirective = false;
  +  if (!ReadDirectiveWithinMetadirective)
  +assert(Tok.isOneOf(tok::annot_pragma_openmp, tok::annot_attr_openmp) &&
  +   "Not an OpenMP directive!");
 ParsingOpenMPDirectiveRAII DirScope(*this);
 ParenBraceBracketBalancer BalancerRAIIObj(*this);
 SmallVector Clauses;
  @@ -2288,7 +2290,7 @@ 
Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
 unsigned ScopeFlags = Scope::FnScope | Scope::DeclScope |
   Scope::CompoundStmtScope | 
Scope::OpenMPDirectiveScope;
 if (!ReadDirectiveWithinMetadirective)
  -  ConsumeAnnotationToken();
  +ConsumeAnnotationToken();
 SourceLocation Loc = Tok.getLocation(), EndLoc;
 OpenMPDirectiveKind DKind = parseOpenMPDirectiveKind(*this);
 if (ReadDirectiveWithinMetadirective && DKind == OMPD_unknown) {
  @@ -2331,6 +2333,7 @@ 
Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
   parseOMPContextSelectors(Loc, TI);
   if (TI.Sets.size() == 0) {
 Diag(Tok, diag::err_omp_expected_context_selector) << "when 
clause";
  +  TPA.Commit();
 return Directive;
   }
  
  @@ -2339,6 +2342,7 @@ 
Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
 ConsumeAnyToken();
   else {
 Diag(Tok, diag::err_omp_expected_colon) << "when clause";
  +  TPA.Commit();
 return Directive;
   }
 }
  @@ -2352,6 +2356,8 @@ 
Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
   if (Tok.is(tok::annot_pragma_openmp_end)) {
 Diag(Tok, diag::err_omp_expected_punc)
 << getOpenMPClauseName(CKind) << 0;
  +  T.skipToEnd();
  +  TPA.Commit();
 return Directive;
   }
   ConsumeAnyToken();
  @@ -2627,7 +2633,7 @@ 
Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
 // ends with a ')'.
 if (ReadDirectiveWithinMetadirective && Tok.is(tok::r_paren)) {
   while (Tok.isNot(tok::annot_pragma_openmp_end))
  -  ConsumeToken();
  +  ConsumeAnyToken();
   break;
 }
 bool HasImplicitClause = false;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D107547: [CodeGen] More bits for calling convention

2021-09-02 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D107547

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


[PATCH] D109139: [AIX][RFC] Undefine __STDC_NO_ATOMICS__ to enable c11 atomics functionality

2021-09-02 Thread David Tenty via Phabricator via cfe-commits
daltenty added a comment.

Hmm, I'm not sure that the limitations you outline in the description are the 
only problems that cause us to define the macro in the first place (though the 
lack of libc implementation was part of it). I'll try to dig up the original 
issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109139

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


[PATCH] D109175: [openmp] Add clang cc1 option -fopenmp-skip-deferred-diags

2021-09-02 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D109175#2980333 , @weiwang wrote:

> Our internal codebase never uses the target directive. Once the deferred 
> diags is bypassed, we observed 18% e2e build time improvement.

Is that with `-fopenmp` or without?
That seems, kinda a lot more than i would have expected,
perhaps there are some other ways to reduce the overhead other than this 
approach?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109175

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


[PATCH] D109178: [PowerPC] Disable vector types when not supported by subtarget features

2021-09-02 Thread Lei Huang via Phabricator via cfe-commits
lei created this revision.
lei added reviewers: hubert.reinterpretcast, nemanjai, power-llvm-team.
Herald added a subscriber: shchenz.
lei requested review of this revision.
Herald added a project: clang.

Update clang to treat vector unsigned long long and friends as invalid
for AlttiVec without VSX.

Reported in: https://bugs.llvm.org/show_bug.cgi?id=47782


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109178

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Headers/altivec.h
  clang/lib/Sema/DeclSpec.cpp
  clang/test/CodeGen/builtins-ppc-int128.c
  clang/test/CodeGen/builtins-ppc-vsx.c
  clang/test/Parser/altivec-bool-128.c
  clang/test/Parser/altivec.c
  clang/test/Parser/cxx-altivec-bool-128.cpp
  clang/test/Parser/cxx-altivec.cpp
  clang/test/Sema/altivec-generic-overload.c
  clang/test/Sema/builtins-ppc.c

Index: clang/test/Sema/builtins-ppc.c
===
--- clang/test/Sema/builtins-ppc.c
+++ clang/test/Sema/builtins-ppc.c
@@ -6,6 +6,9 @@
 // RUN: %clang_cc1 -target-feature +altivec -target-feature +crypto\
 // RUN: -triple powerpc64le-unknown-unknown -DTEST_CRYPTO -fsyntax-only  \
 // RUN: -verify %s
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +crypto \
+// RUN: -triple powerpc64le-unknown-unknown -DTEST_CRYPTO -fsyntax-only \
+// RUN: -target-feature +vsx -verify %s
 
 #ifdef TEST_HTM
 void test_htm() {
@@ -37,6 +40,7 @@
   return __builtin_crypto_vshasigmaw(a, 1, 15);
 }
 
+#ifdef __VSX__
 vector unsigned long long test_vshasigmad_or(void)
 {
   vector unsigned long long a = D_INIT
@@ -46,6 +50,7 @@
   vector unsigned long long e = __builtin_crypto_vshasigmad(a, 1, -15); // expected-error-re {{argument value {{.*}} is outside the valid range}}
   return __builtin_crypto_vshasigmad(a, 0, 15);
 }
+#endif
 
 #endif
 
Index: clang/test/Sema/altivec-generic-overload.c
===
--- clang/test/Sema/altivec-generic-overload.c
+++ clang/test/Sema/altivec-generic-overload.c
@@ -1,4 +1,8 @@
-// RUN: %clang_cc1 %s -triple=powerpc64le-unknown-linux -target-feature +altivec -target-feature +vsx -verify -verify-ignore-unexpected=note -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -triple=powerpc64le-unknown-linux -target-feature +altivec \
+// RUN:  -target-feature +vsx -verify -verify-ignore-unexpected=note -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -triple=powerpc64le-unknown-linux -target-feature +altivec \
+// RUN:  -target-feature +vsx -verify -verify-ignore-unexpected=note -pedantic -fsyntax-only \
+// RUN:  -target-cpu pwr8
 
 typedef signed char __v16sc __attribute__((__vector_size__(16)));
 typedef unsigned char __v16uc __attribute__((__vector_size__(16)));
@@ -20,9 +24,6 @@
 __v4si *__attribute__((__overloadable__)) convert1(vector signed int);
 __v4ui *__attribute__((__overloadable__)) convert1(vector unsigned int);
 __v2sll *__attribute__((__overloadable__)) convert1(vector signed long long);
-__v2ull *__attribute__((__overloadable__)) convert1(vector unsigned long long);
-__v1slll *__attribute__((__overloadable__)) convert1(vector signed __int128);
-__v1ulll *__attribute__((__overloadable__)) convert1(vector unsigned __int128);
 __v4f *__attribute__((__overloadable__)) convert1(vector float);
 __v2d *__attribute__((__overloadable__)) convert1(vector double);
 void __attribute__((__overloadable__)) convert1(vector bool int);
@@ -36,11 +37,17 @@
 vector unsigned int *__attribute__((__overloadable__)) convert2(__v4ui);
 vector signed long long *__attribute__((__overloadable__)) convert2(__v2sll);
 vector unsigned long long *__attribute__((__overloadable__)) convert2(__v2ull);
-vector signed __int128 *__attribute__((__overloadable__)) convert2(__v1slll);
-vector unsigned __int128 *__attribute__((__overloadable__)) convert2(__v1ulll);
 vector float *__attribute__((__overloadable__)) convert2(__v4f);
 vector double *__attribute__((__overloadable__)) convert2(__v2d);
 
+#ifdef __POWER8_VECTOR__
+__v1slll *__attribute__((__overloadable__)) convert1(vector signed __int128);
+__v1ulll *__attribute__((__overloadable__)) convert1(vector unsigned __int128);
+__v2ull *__attribute__((__overloadable__)) convert1(vector unsigned long long);
+vector signed __int128 *__attribute__((__overloadable__)) convert2(__v1slll);
+vector unsigned __int128 *__attribute__((__overloadable__)) convert2(__v1ulll);
+#endif
+
 void test() {
   __v16sc gv1;
   __v16uc gv2;
@@ -49,11 +56,14 @@
   __v4si gv5;
   __v4ui gv6;
   __v2sll gv7;
+  __v4f gv11;
+  __v2d gv12;
+
+#ifdef __POWER8_VECTOR__
   __v2ull gv8;
   __v1slll gv9;
   __v1ulll gv10;
-  __v4f gv11;
-  __v2d gv12;
+#endif
 
   vector signed char av1;
   vector unsigned char av2;
@@ -63,8 +73,10 @@
   vector unsigned int av6;
   vector signed long long av7;
   vector unsigned long long av8;
+#ifdef __POWER8_VECTOR__
   vector signed __int128 av9;
   vector unsigned __int128 av1

[PATCH] D109175: [openmp] Add clang cc1 option -fopenmp-skip-deferred-diags

2021-09-02 Thread Wei Wang via Phabricator via cfe-commits
weiwang added a comment.

In D109175#2980446 , @lebedev.ri 
wrote:

> In D109175#2980333 , @weiwang wrote:
>
>> Our internal codebase never uses the target directive. Once the deferred 
>> diags is bypassed, we observed 18% e2e build time improvement.
>
> Is that with `-fopenmp` or without?
> That seems, kinda a lot more than i would have expected,
> perhaps there are some other ways to reduce the overhead other than this 
> approach?

This is with -fopenmp and no other omp related flags. I'd prefer a more generic 
way of fixing this, but right now this seems to be most direct way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109175

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


[clang] 5881dcf - Try to unbreak Win build differently after 973519826edb76

2021-09-02 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-09-02T14:45:56-04:00
New Revision: 5881dcff7e76a68323edc8bb3c6e14420ad9cf7c

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

LOG: Try to unbreak Win build differently after 973519826edb76

Looks like the MS STL wants StringMapKeyIterator::operator*() to be const.
Return the result by copy instead of reference to do that.
Assigning to a hash map key iterator doesn't make sense anyways.

Also reverts 123f811fe5b0b which is now hopefully no longer needed.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/X86.cpp
llvm/include/llvm/ADT/StringMap.h
llvm/unittests/ADT/StringMapTest.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 2e43c455b28fd..bfa008f964e19 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -59,9 +59,8 @@ std::string x86::getX86TargetCPU(const Driver &D, const 
ArgList &Args,
 }
 StringRef CPU = ArchMap.lookup(A->getValue());
 if (CPU.empty()) {
-  std::vector ValidArchs;
-  for (StringRef Key : ArchMap.keys())
-ValidArchs.push_back(Key);
+  std::vector ValidArchs{ArchMap.keys().begin(),
+ArchMap.keys().end()};
   sort(ValidArchs);
   D.Diag(diag::warn_drv_invalid_arch_name_with_suggestion)
   << A->getValue() << (Triple.getArch() == llvm::Triple::x86)

diff  --git a/llvm/include/llvm/ADT/StringMap.h 
b/llvm/include/llvm/ADT/StringMap.h
index 003e62d98ec23..fa99ecd81106e 100644
--- a/llvm/include/llvm/ADT/StringMap.h
+++ b/llvm/include/llvm/ADT/StringMap.h
@@ -478,13 +478,9 @@ class StringMapKeyIterator
   explicit StringMapKeyIterator(StringMapConstIterator Iter)
   : base(std::move(Iter)) {}
 
-  StringRef &operator*() {
-Key = this->wrapped()->getKey();
-return Key;
+  StringRef operator*() const {
+return this->wrapped()->getKey();
   }
-
-private:
-  StringRef Key;
 };
 
 } // end namespace llvm

diff  --git a/llvm/unittests/ADT/StringMapTest.cpp 
b/llvm/unittests/ADT/StringMapTest.cpp
index 6a3cca5a4a324..f38a60452e3c7 100644
--- a/llvm/unittests/ADT/StringMapTest.cpp
+++ b/llvm/unittests/ADT/StringMapTest.cpp
@@ -308,7 +308,21 @@ TEST_F(StringMapTest, InsertOrAssignTest) {
   EXPECT_EQ(0, try1.first->second.copy);
 }
 
-TEST_F(StringMapTest, IterMapKeys) {
+TEST_F(StringMapTest, IterMapKeysVector) {
+  StringMap Map;
+  Map["A"] = 1;
+  Map["B"] = 2;
+  Map["C"] = 3;
+  Map["D"] = 3;
+
+  std::vector Keys{Map.keys().begin(), Map.keys().end()};
+  llvm::sort(Keys);
+
+  std::vector Expected{{"A", "B", "C", "D"}};
+  EXPECT_EQ(Expected, Keys);
+}
+
+TEST_F(StringMapTest, IterMapKeysSmallVector) {
   StringMap Map;
   Map["A"] = 1;
   Map["B"] = 2;



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


[PATCH] D109167: Try to unbreak Win build differently after 973519826edb76

2021-09-02 Thread Nico Weber 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 rG5881dcff7e76: Try to unbreak Win build differently after 
973519826edb76 (authored by thakis).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109167

Files:
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  llvm/include/llvm/ADT/StringMap.h
  llvm/unittests/ADT/StringMapTest.cpp


Index: llvm/unittests/ADT/StringMapTest.cpp
===
--- llvm/unittests/ADT/StringMapTest.cpp
+++ llvm/unittests/ADT/StringMapTest.cpp
@@ -308,7 +308,21 @@
   EXPECT_EQ(0, try1.first->second.copy);
 }
 
-TEST_F(StringMapTest, IterMapKeys) {
+TEST_F(StringMapTest, IterMapKeysVector) {
+  StringMap Map;
+  Map["A"] = 1;
+  Map["B"] = 2;
+  Map["C"] = 3;
+  Map["D"] = 3;
+
+  std::vector Keys{Map.keys().begin(), Map.keys().end()};
+  llvm::sort(Keys);
+
+  std::vector Expected{{"A", "B", "C", "D"}};
+  EXPECT_EQ(Expected, Keys);
+}
+
+TEST_F(StringMapTest, IterMapKeysSmallVector) {
   StringMap Map;
   Map["A"] = 1;
   Map["B"] = 2;
Index: llvm/include/llvm/ADT/StringMap.h
===
--- llvm/include/llvm/ADT/StringMap.h
+++ llvm/include/llvm/ADT/StringMap.h
@@ -478,13 +478,9 @@
   explicit StringMapKeyIterator(StringMapConstIterator Iter)
   : base(std::move(Iter)) {}
 
-  StringRef &operator*() {
-Key = this->wrapped()->getKey();
-return Key;
+  StringRef operator*() const {
+return this->wrapped()->getKey();
   }
-
-private:
-  StringRef Key;
 };
 
 } // end namespace llvm
Index: clang/lib/Driver/ToolChains/Arch/X86.cpp
===
--- clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -59,9 +59,8 @@
 }
 StringRef CPU = ArchMap.lookup(A->getValue());
 if (CPU.empty()) {
-  std::vector ValidArchs;
-  for (StringRef Key : ArchMap.keys())
-ValidArchs.push_back(Key);
+  std::vector ValidArchs{ArchMap.keys().begin(),
+ArchMap.keys().end()};
   sort(ValidArchs);
   D.Diag(diag::warn_drv_invalid_arch_name_with_suggestion)
   << A->getValue() << (Triple.getArch() == llvm::Triple::x86)


Index: llvm/unittests/ADT/StringMapTest.cpp
===
--- llvm/unittests/ADT/StringMapTest.cpp
+++ llvm/unittests/ADT/StringMapTest.cpp
@@ -308,7 +308,21 @@
   EXPECT_EQ(0, try1.first->second.copy);
 }
 
-TEST_F(StringMapTest, IterMapKeys) {
+TEST_F(StringMapTest, IterMapKeysVector) {
+  StringMap Map;
+  Map["A"] = 1;
+  Map["B"] = 2;
+  Map["C"] = 3;
+  Map["D"] = 3;
+
+  std::vector Keys{Map.keys().begin(), Map.keys().end()};
+  llvm::sort(Keys);
+
+  std::vector Expected{{"A", "B", "C", "D"}};
+  EXPECT_EQ(Expected, Keys);
+}
+
+TEST_F(StringMapTest, IterMapKeysSmallVector) {
   StringMap Map;
   Map["A"] = 1;
   Map["B"] = 2;
Index: llvm/include/llvm/ADT/StringMap.h
===
--- llvm/include/llvm/ADT/StringMap.h
+++ llvm/include/llvm/ADT/StringMap.h
@@ -478,13 +478,9 @@
   explicit StringMapKeyIterator(StringMapConstIterator Iter)
   : base(std::move(Iter)) {}
 
-  StringRef &operator*() {
-Key = this->wrapped()->getKey();
-return Key;
+  StringRef operator*() const {
+return this->wrapped()->getKey();
   }
-
-private:
-  StringRef Key;
 };
 
 } // end namespace llvm
Index: clang/lib/Driver/ToolChains/Arch/X86.cpp
===
--- clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -59,9 +59,8 @@
 }
 StringRef CPU = ArchMap.lookup(A->getValue());
 if (CPU.empty()) {
-  std::vector ValidArchs;
-  for (StringRef Key : ArchMap.keys())
-ValidArchs.push_back(Key);
+  std::vector ValidArchs{ArchMap.keys().begin(),
+ArchMap.keys().end()};
   sort(ValidArchs);
   D.Diag(diag::warn_drv_invalid_arch_name_with_suggestion)
   << A->getValue() << (Triple.getArch() == llvm::Triple::x86)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109178: [PowerPC] Disable vector types when not supported by subtarget features

2021-09-02 Thread Lei Huang via Phabricator via cfe-commits
lei updated this revision to Diff 370349.
lei added a comment.

fix spelling in commit message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109178

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Headers/altivec.h
  clang/lib/Sema/DeclSpec.cpp
  clang/test/CodeGen/builtins-ppc-int128.c
  clang/test/CodeGen/builtins-ppc-vsx.c
  clang/test/Parser/altivec-bool-128.c
  clang/test/Parser/altivec.c
  clang/test/Parser/cxx-altivec-bool-128.cpp
  clang/test/Parser/cxx-altivec.cpp
  clang/test/Sema/altivec-generic-overload.c
  clang/test/Sema/builtins-ppc.c

Index: clang/test/Sema/builtins-ppc.c
===
--- clang/test/Sema/builtins-ppc.c
+++ clang/test/Sema/builtins-ppc.c
@@ -6,6 +6,9 @@
 // RUN: %clang_cc1 -target-feature +altivec -target-feature +crypto\
 // RUN: -triple powerpc64le-unknown-unknown -DTEST_CRYPTO -fsyntax-only  \
 // RUN: -verify %s
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +crypto \
+// RUN: -triple powerpc64le-unknown-unknown -DTEST_CRYPTO -fsyntax-only \
+// RUN: -target-feature +vsx -verify %s
 
 #ifdef TEST_HTM
 void test_htm() {
@@ -37,6 +40,7 @@
   return __builtin_crypto_vshasigmaw(a, 1, 15);
 }
 
+#ifdef __VSX__
 vector unsigned long long test_vshasigmad_or(void)
 {
   vector unsigned long long a = D_INIT
@@ -46,6 +50,7 @@
   vector unsigned long long e = __builtin_crypto_vshasigmad(a, 1, -15); // expected-error-re {{argument value {{.*}} is outside the valid range}}
   return __builtin_crypto_vshasigmad(a, 0, 15);
 }
+#endif
 
 #endif
 
Index: clang/test/Sema/altivec-generic-overload.c
===
--- clang/test/Sema/altivec-generic-overload.c
+++ clang/test/Sema/altivec-generic-overload.c
@@ -1,4 +1,8 @@
-// RUN: %clang_cc1 %s -triple=powerpc64le-unknown-linux -target-feature +altivec -target-feature +vsx -verify -verify-ignore-unexpected=note -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -triple=powerpc64le-unknown-linux -target-feature +altivec \
+// RUN:  -target-feature +vsx -verify -verify-ignore-unexpected=note -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -triple=powerpc64le-unknown-linux -target-feature +altivec \
+// RUN:  -target-feature +vsx -verify -verify-ignore-unexpected=note -pedantic -fsyntax-only \
+// RUN:  -target-cpu pwr8
 
 typedef signed char __v16sc __attribute__((__vector_size__(16)));
 typedef unsigned char __v16uc __attribute__((__vector_size__(16)));
@@ -20,9 +24,6 @@
 __v4si *__attribute__((__overloadable__)) convert1(vector signed int);
 __v4ui *__attribute__((__overloadable__)) convert1(vector unsigned int);
 __v2sll *__attribute__((__overloadable__)) convert1(vector signed long long);
-__v2ull *__attribute__((__overloadable__)) convert1(vector unsigned long long);
-__v1slll *__attribute__((__overloadable__)) convert1(vector signed __int128);
-__v1ulll *__attribute__((__overloadable__)) convert1(vector unsigned __int128);
 __v4f *__attribute__((__overloadable__)) convert1(vector float);
 __v2d *__attribute__((__overloadable__)) convert1(vector double);
 void __attribute__((__overloadable__)) convert1(vector bool int);
@@ -36,11 +37,17 @@
 vector unsigned int *__attribute__((__overloadable__)) convert2(__v4ui);
 vector signed long long *__attribute__((__overloadable__)) convert2(__v2sll);
 vector unsigned long long *__attribute__((__overloadable__)) convert2(__v2ull);
-vector signed __int128 *__attribute__((__overloadable__)) convert2(__v1slll);
-vector unsigned __int128 *__attribute__((__overloadable__)) convert2(__v1ulll);
 vector float *__attribute__((__overloadable__)) convert2(__v4f);
 vector double *__attribute__((__overloadable__)) convert2(__v2d);
 
+#ifdef __POWER8_VECTOR__
+__v1slll *__attribute__((__overloadable__)) convert1(vector signed __int128);
+__v1ulll *__attribute__((__overloadable__)) convert1(vector unsigned __int128);
+__v2ull *__attribute__((__overloadable__)) convert1(vector unsigned long long);
+vector signed __int128 *__attribute__((__overloadable__)) convert2(__v1slll);
+vector unsigned __int128 *__attribute__((__overloadable__)) convert2(__v1ulll);
+#endif
+
 void test() {
   __v16sc gv1;
   __v16uc gv2;
@@ -49,11 +56,14 @@
   __v4si gv5;
   __v4ui gv6;
   __v2sll gv7;
+  __v4f gv11;
+  __v2d gv12;
+
+#ifdef __POWER8_VECTOR__
   __v2ull gv8;
   __v1slll gv9;
   __v1ulll gv10;
-  __v4f gv11;
-  __v2d gv12;
+#endif
 
   vector signed char av1;
   vector unsigned char av2;
@@ -63,8 +73,10 @@
   vector unsigned int av6;
   vector signed long long av7;
   vector unsigned long long av8;
+#ifdef __POWER8_VECTOR__
   vector signed __int128 av9;
   vector unsigned __int128 av10;
+#endif
   vector float av11;
   vector double av12;
   vector bool int av13;
@@ -77,9 +89,11 @@
   __v4si *gv5_p = convert1(gv5);
   __v4ui *gv6_p = convert1(gv6);
   __v2sll *gv7_p = convert1(g

[PATCH] D109174: [MSP430][Clang] Infer CPU type from -mcpu= or -mmcu=

2021-09-02 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl updated this revision to Diff 370350.
jozefl added a comment.

Rebased onto current upstream.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109174

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Basic/Targets/MSP430.cpp
  clang/lib/Basic/Targets/MSP430.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/lib/Driver/ToolChains/MSP430.h
  clang/test/Driver/msp430-cpu.c
  clang/test/Driver/msp430-mmcu.c
  clang/test/Driver/msp430-toolchain.c
  clang/test/Misc/target-invalid-cpu-note.c
  clang/test/Preprocessor/msp430-defs.c
  llvm/lib/Target/MSP430/MSP430.td
  llvm/lib/Target/MSP430/MSP430Subtarget.cpp
  llvm/lib/Target/MSP430/MSP430Subtarget.h
  llvm/test/CodeGen/MSP430/build-attrs.ll

Index: llvm/test/CodeGen/MSP430/build-attrs.ll
===
--- llvm/test/CodeGen/MSP430/build-attrs.ll
+++ llvm/test/CodeGen/MSP430/build-attrs.ll
@@ -8,6 +8,8 @@
 ; RUN:   | llvm-readelf -A - | FileCheck %s --check-prefixes COMMON,MSP430,SMALL
 ; RUN: llc -mtriple=msp430 -mcpu=msp430x -filetype=obj < %s \
 ; RUN:   | llvm-readelf -A - | FileCheck %s --check-prefixes COMMON,MSP430X,SMALL
+; RUN: llc -mtriple=msp430 -mcpu=msp430xv2 -filetype=obj < %s \
+; RUN:   | llvm-readelf -A - | FileCheck %s --check-prefixes COMMON,MSP430X,SMALL
 
 ; COMMON: BuildAttributes {
 ; COMMON: FormatVersion: 0x41
Index: llvm/lib/Target/MSP430/MSP430Subtarget.h
===
--- llvm/lib/Target/MSP430/MSP430Subtarget.h
+++ llvm/lib/Target/MSP430/MSP430Subtarget.h
@@ -36,7 +36,7 @@
 
 private:
   virtual void anchor();
-  bool ExtendedInsts = false;
+  bool MSP430X = false;
   HWMultEnum HWMultMode = NoHWMult;
   MSP430FrameLowering FrameLowering;
   MSP430InstrInfo InstrInfo;
@@ -60,6 +60,8 @@
   bool hasHWMult32() const { return HWMultMode == HWMult32; }
   bool hasHWMultF5() const { return HWMultMode == HWMultF5; }
 
+  bool hasMSP430X() const { return MSP430X; }
+
   const TargetFrameLowering *getFrameLowering() const override {
 return &FrameLowering;
   }
Index: llvm/lib/Target/MSP430/MSP430Subtarget.cpp
===
--- llvm/lib/Target/MSP430/MSP430Subtarget.cpp
+++ llvm/lib/Target/MSP430/MSP430Subtarget.cpp
@@ -40,9 +40,6 @@
 
 MSP430Subtarget &
 MSP430Subtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
-  ExtendedInsts = false;
-  HWMultMode = NoHWMult;
-
   StringRef CPUName = CPU;
   if (CPUName.empty())
 CPUName = "msp430";
Index: llvm/lib/Target/MSP430/MSP430.td
===
--- llvm/lib/Target/MSP430/MSP430.td
+++ llvm/lib/Target/MSP430/MSP430.td
@@ -18,8 +18,8 @@
 // Subtarget Features. 
 //===--===//
 def FeatureX
- : SubtargetFeature<"ext", "ExtendedInsts", "true",
-"Enable MSP430-X extensions">;
+ : SubtargetFeature<"msp430x", "MSP430X", "true",
+"Enable MSP430X extensions">;
 
 def FeatureHWMult16
  : SubtargetFeature<"hwmult16", "HWMultMode", "HWMult16",
@@ -42,6 +42,7 @@
 def : Proc<"generic", []>;
 def : Proc<"msp430",  []>;
 def : Proc<"msp430x", [FeatureX]>;
+def : Proc<"msp430xv2",   [FeatureX]>;
 
 //===--===//
 // Register File Description
Index: clang/test/Preprocessor/msp430-defs.c
===
--- /dev/null
+++ clang/test/Preprocessor/msp430-defs.c
@@ -0,0 +1,20 @@
+// Check the correct macros are defined for each CPU.
+
+// RUN: %clang -target msp430 -x c -E -dM %s -o - | FileCheck  %s
+// RUN: %clang -target msp430 -mcpu=generic -x c -E -dM %s -o - | FileCheck %s
+// RUN: %clang -target msp430 -mcpu=msp430 -x c -E -dM %s -o - | FileCheck %s
+
+// CHECK: MSP430
+// CHECK: __ELF__
+// CHECK-NOT: __MSP430X__
+// CHECK: __MSP430__
+
+// RUN: %clang -target msp430 -mcpu=msp430x -x c -E -dM %s -o - \
+// RUN:   | FileCheck --check-prefix=MSP430X %s
+// RUN: %clang -target msp430 -mcpu=msp430xv2 -x c -E -dM %s -o - \
+// RUN:   | FileCheck --check-prefix=MSP430X %s
+
+// MSP430X: MSP430
+// MSP430X: __ELF__
+// MSP430X: __MSP430X__
+// MSP430X: __MSP430__
Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -205,3 +205,7 @@
 // RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
 // TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
 // TUNE-RISCV64: note: valid target CPU values are: generic-rv64, rock

[PATCH] D109167: Try to unbreak Win build differently after 973519826edb76

2021-09-02 Thread Geoffrey Martin-Noble via Phabricator via cfe-commits
GMNGeoffrey added a comment.

I'm seeing a build failure coming out of this:

> llvm-project/lld/wasm/Writer.cpp:521:16: error: non-const lvalue reference to 
> type 'llvm::StringRef' cannot bind to a temporary of type 'llvm::StringRef'
>
>   for (auto &feature : used.keys()) {

Looks like pre-merge checks failed with the same error: 
https://buildkite.com/llvm-project/premerge-checks/builds/54930#07373971-3d37-49cf-9def-22c0d724ee23


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109167

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


[clang] df052e1 - Revert "Try to unbreak Win build differently after 973519826edb76"

2021-09-02 Thread Geoffrey Martin-Noble via cfe-commits

Author: Geoffrey Martin-Noble
Date: 2021-09-02T12:05:33-07:00
New Revision: df052e1732ab57f5d9c684ceeaed3ab39073cd9f

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

LOG: Revert "Try to unbreak Win build differently after 973519826edb76"

Breaks the build and failed pre-merge checks:
https://buildkite.com/llvm-project/premerge-checks/builds/54930#07373971-3d37-49cf-9def-22c0d724ee23

> llvm-project/lld/wasm/Writer.cpp:521:16: error: non-const lvalue reference to
>  type 'llvm::StringRef' cannot bind to a temporary of type 'llvm::StringRef'
>for (auto &feature : used.keys()) {

This reverts commit 5881dcff7e76a68323edc8bb3c6e14420ad9cf7c.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/X86.cpp
llvm/include/llvm/ADT/StringMap.h
llvm/unittests/ADT/StringMapTest.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index bfa008f964e19..2e43c455b28fd 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -59,8 +59,9 @@ std::string x86::getX86TargetCPU(const Driver &D, const 
ArgList &Args,
 }
 StringRef CPU = ArchMap.lookup(A->getValue());
 if (CPU.empty()) {
-  std::vector ValidArchs{ArchMap.keys().begin(),
-ArchMap.keys().end()};
+  std::vector ValidArchs;
+  for (StringRef Key : ArchMap.keys())
+ValidArchs.push_back(Key);
   sort(ValidArchs);
   D.Diag(diag::warn_drv_invalid_arch_name_with_suggestion)
   << A->getValue() << (Triple.getArch() == llvm::Triple::x86)

diff  --git a/llvm/include/llvm/ADT/StringMap.h 
b/llvm/include/llvm/ADT/StringMap.h
index fa99ecd81106e..003e62d98ec23 100644
--- a/llvm/include/llvm/ADT/StringMap.h
+++ b/llvm/include/llvm/ADT/StringMap.h
@@ -478,9 +478,13 @@ class StringMapKeyIterator
   explicit StringMapKeyIterator(StringMapConstIterator Iter)
   : base(std::move(Iter)) {}
 
-  StringRef operator*() const {
-return this->wrapped()->getKey();
+  StringRef &operator*() {
+Key = this->wrapped()->getKey();
+return Key;
   }
+
+private:
+  StringRef Key;
 };
 
 } // end namespace llvm

diff  --git a/llvm/unittests/ADT/StringMapTest.cpp 
b/llvm/unittests/ADT/StringMapTest.cpp
index f38a60452e3c7..6a3cca5a4a324 100644
--- a/llvm/unittests/ADT/StringMapTest.cpp
+++ b/llvm/unittests/ADT/StringMapTest.cpp
@@ -308,21 +308,7 @@ TEST_F(StringMapTest, InsertOrAssignTest) {
   EXPECT_EQ(0, try1.first->second.copy);
 }
 
-TEST_F(StringMapTest, IterMapKeysVector) {
-  StringMap Map;
-  Map["A"] = 1;
-  Map["B"] = 2;
-  Map["C"] = 3;
-  Map["D"] = 3;
-
-  std::vector Keys{Map.keys().begin(), Map.keys().end()};
-  llvm::sort(Keys);
-
-  std::vector Expected{{"A", "B", "C", "D"}};
-  EXPECT_EQ(Expected, Keys);
-}
-
-TEST_F(StringMapTest, IterMapKeysSmallVector) {
+TEST_F(StringMapTest, IterMapKeys) {
   StringMap Map;
   Map["A"] = 1;
   Map["B"] = 2;



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


[PATCH] D109167: Try to unbreak Win build differently after 973519826edb76

2021-09-02 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D109167#2980560 , @GMNGeoffrey 
wrote:

> I'm seeing a build failure coming out of this:
>
>> llvm-project/lld/wasm/Writer.cpp:521:16: error: non-const lvalue reference 
>> to type 'llvm::StringRef' cannot bind to a temporary of type 
>> 'llvm::StringRef'
>>
>>   for (auto &feature : used.keys()) {
>
> Looks like pre-merge checks failed with the same error: 
> https://buildkite.com/llvm-project/premerge-checks/builds/54930#07373971-3d37-49cf-9def-22c0d724ee23

I had fixed this in 
https://github.com/llvm/llvm-project/commit/9d227543890e721b95303430ee1427ce5aa7292f
 . Precommit bot on this change was green though as far as I can tell.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109167

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


[PATCH] D109181: Reland "Try to unbreak Win build differently after 973519826edb76""

2021-09-02 Thread Geoffrey Martin-Noble via Phabricator via cfe-commits
GMNGeoffrey created this revision.
Herald added subscribers: dexonsmith, mgrang.
GMNGeoffrey requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Build should be fixed by
https://github.com/llvm/llvm-project/commit/9d22754389

This reverts commit df052e1732ab57f5d9c684ceeaed3ab39073cd9f 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109181

Files:
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  llvm/include/llvm/ADT/StringMap.h
  llvm/unittests/ADT/StringMapTest.cpp


Index: llvm/unittests/ADT/StringMapTest.cpp
===
--- llvm/unittests/ADT/StringMapTest.cpp
+++ llvm/unittests/ADT/StringMapTest.cpp
@@ -308,7 +308,21 @@
   EXPECT_EQ(0, try1.first->second.copy);
 }
 
-TEST_F(StringMapTest, IterMapKeys) {
+TEST_F(StringMapTest, IterMapKeysVector) {
+  StringMap Map;
+  Map["A"] = 1;
+  Map["B"] = 2;
+  Map["C"] = 3;
+  Map["D"] = 3;
+
+  std::vector Keys{Map.keys().begin(), Map.keys().end()};
+  llvm::sort(Keys);
+
+  std::vector Expected{{"A", "B", "C", "D"}};
+  EXPECT_EQ(Expected, Keys);
+}
+
+TEST_F(StringMapTest, IterMapKeysSmallVector) {
   StringMap Map;
   Map["A"] = 1;
   Map["B"] = 2;
Index: llvm/include/llvm/ADT/StringMap.h
===
--- llvm/include/llvm/ADT/StringMap.h
+++ llvm/include/llvm/ADT/StringMap.h
@@ -478,13 +478,7 @@
   explicit StringMapKeyIterator(StringMapConstIterator Iter)
   : base(std::move(Iter)) {}
 
-  StringRef &operator*() {
-Key = this->wrapped()->getKey();
-return Key;
-  }
-
-private:
-  StringRef Key;
+  StringRef operator*() const { return this->wrapped()->getKey(); }
 };
 
 } // end namespace llvm
Index: clang/lib/Driver/ToolChains/Arch/X86.cpp
===
--- clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -59,9 +59,8 @@
 }
 StringRef CPU = ArchMap.lookup(A->getValue());
 if (CPU.empty()) {
-  std::vector ValidArchs;
-  for (StringRef Key : ArchMap.keys())
-ValidArchs.push_back(Key);
+  std::vector ValidArchs{ArchMap.keys().begin(),
+ArchMap.keys().end()};
   sort(ValidArchs);
   D.Diag(diag::warn_drv_invalid_arch_name_with_suggestion)
   << A->getValue() << (Triple.getArch() == llvm::Triple::x86)


Index: llvm/unittests/ADT/StringMapTest.cpp
===
--- llvm/unittests/ADT/StringMapTest.cpp
+++ llvm/unittests/ADT/StringMapTest.cpp
@@ -308,7 +308,21 @@
   EXPECT_EQ(0, try1.first->second.copy);
 }
 
-TEST_F(StringMapTest, IterMapKeys) {
+TEST_F(StringMapTest, IterMapKeysVector) {
+  StringMap Map;
+  Map["A"] = 1;
+  Map["B"] = 2;
+  Map["C"] = 3;
+  Map["D"] = 3;
+
+  std::vector Keys{Map.keys().begin(), Map.keys().end()};
+  llvm::sort(Keys);
+
+  std::vector Expected{{"A", "B", "C", "D"}};
+  EXPECT_EQ(Expected, Keys);
+}
+
+TEST_F(StringMapTest, IterMapKeysSmallVector) {
   StringMap Map;
   Map["A"] = 1;
   Map["B"] = 2;
Index: llvm/include/llvm/ADT/StringMap.h
===
--- llvm/include/llvm/ADT/StringMap.h
+++ llvm/include/llvm/ADT/StringMap.h
@@ -478,13 +478,7 @@
   explicit StringMapKeyIterator(StringMapConstIterator Iter)
   : base(std::move(Iter)) {}
 
-  StringRef &operator*() {
-Key = this->wrapped()->getKey();
-return Key;
-  }
-
-private:
-  StringRef Key;
+  StringRef operator*() const { return this->wrapped()->getKey(); }
 };
 
 } // end namespace llvm
Index: clang/lib/Driver/ToolChains/Arch/X86.cpp
===
--- clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -59,9 +59,8 @@
 }
 StringRef CPU = ArchMap.lookup(A->getValue());
 if (CPU.empty()) {
-  std::vector ValidArchs;
-  for (StringRef Key : ArchMap.keys())
-ValidArchs.push_back(Key);
+  std::vector ValidArchs{ArchMap.keys().begin(),
+ArchMap.keys().end()};
   sort(ValidArchs);
   D.Diag(diag::warn_drv_invalid_arch_name_with_suggestion)
   << A->getValue() << (Triple.getArch() == llvm::Triple::x86)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108482: [Clang] Fix instantiation of OpaqueValueExprs (Bug #45964)

2021-09-02 Thread Jason Rice via Phabricator via cfe-commits
ricejasonf updated this revision to Diff 370353.
ricejasonf marked 2 inline comments as done.
ricejasonf added a comment.

Fixed minor formatting issue. 😅 (Perhaps this should be in the tests included 
with check-clang?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108482

Files:
  clang/lib/Sema/TreeTransform.h
  clang/test/CodeGenCXX/pr45964-decomp-transform.cpp


Index: clang/test/CodeGenCXX/pr45964-decomp-transform.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr45964-decomp-transform.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++1z -triple x86_64-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
+
+int a[1];
+// CHECK: @a = global [1 x i32] zeroinitializer
+template 
+void test_transform() {
+  auto [b] = a;
+}
+void (*d)(){test_transform<0>};
+// CHECK-LABEL: define {{.*}} @_Z14test_transformILi0EEvv
+// CHECK:   [[ENTRY:.*]]:
+// CHECK-NEXT:  [[ARR:%.*]] = alloca [1 x i32]
+// CHECK-NEXT:  [[BEGIN:%.*]] = getelementptr inbounds [1 x i32], [1 x i32]* 
[[ARR]], i64 0, i64 0
+// CHECK-NEXT:  br label %[[BODY:.*]]
+// CHECK-EMPTY:
+// CHECK-NEXT:  [[BODY]]:
+// CHECK-NEXT:  [[CUR:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[NEXT:%.*]], 
%[[BODY]] ]
+// CHECK-NEXT:  [[DEST:%.*]] = getelementptr inbounds i32, i32* [[BEGIN]], i64 
[[CUR]]
+// CHECK-NEXT:  [[SRC:%.*]] = getelementptr inbounds [1 x i32], [1 x i32]* @a, 
i64 0, i64 [[CUR]]
+// CHECK-NEXT:  [[X:%.*]] = load i32, i32* [[SRC]]
+// CHECK-NEXT:  store i32 [[X]], i32* [[DEST]]
+// CHECK-NEXT:  [[NEXT]] = add nuw i64 [[CUR]], 1
+// CHECK-NEXT:  [[EQ:%.*]] = icmp eq i64 [[NEXT]], 1
+// CHECK-NEXT:  br i1 [[EQ]], label %[[FIN:.*]], label %[[BODY]]
+// CHECK-EMPTY:
+// CHECK-NEXT:  [[FIN]]:
+// CHECK-NEXT:  ret void
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -3840,8 +3840,10 @@
   if (auto *FE = dyn_cast(Init))
 Init = FE->getSubExpr();
 
-  if (auto *AIL = dyn_cast(Init))
-Init = AIL->getCommonExpr();
+  if (auto *AIL = dyn_cast(Init)) {
+OpaqueValueExpr *OVE = cast(AIL->getCommonExpr());
+Init = OVE->getSourceExpr();
+  }
 
   if (MaterializeTemporaryExpr *MTE = dyn_cast(Init))
 Init = MTE->getSubExpr();


Index: clang/test/CodeGenCXX/pr45964-decomp-transform.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pr45964-decomp-transform.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++1z -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+int a[1];
+// CHECK: @a = global [1 x i32] zeroinitializer
+template 
+void test_transform() {
+  auto [b] = a;
+}
+void (*d)(){test_transform<0>};
+// CHECK-LABEL: define {{.*}} @_Z14test_transformILi0EEvv
+// CHECK:   [[ENTRY:.*]]:
+// CHECK-NEXT:  [[ARR:%.*]] = alloca [1 x i32]
+// CHECK-NEXT:  [[BEGIN:%.*]] = getelementptr inbounds [1 x i32], [1 x i32]* [[ARR]], i64 0, i64 0
+// CHECK-NEXT:  br label %[[BODY:.*]]
+// CHECK-EMPTY:
+// CHECK-NEXT:  [[BODY]]:
+// CHECK-NEXT:  [[CUR:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[NEXT:%.*]], %[[BODY]] ]
+// CHECK-NEXT:  [[DEST:%.*]] = getelementptr inbounds i32, i32* [[BEGIN]], i64 [[CUR]]
+// CHECK-NEXT:  [[SRC:%.*]] = getelementptr inbounds [1 x i32], [1 x i32]* @a, i64 0, i64 [[CUR]]
+// CHECK-NEXT:  [[X:%.*]] = load i32, i32* [[SRC]]
+// CHECK-NEXT:  store i32 [[X]], i32* [[DEST]]
+// CHECK-NEXT:  [[NEXT]] = add nuw i64 [[CUR]], 1
+// CHECK-NEXT:  [[EQ:%.*]] = icmp eq i64 [[NEXT]], 1
+// CHECK-NEXT:  br i1 [[EQ]], label %[[FIN:.*]], label %[[BODY]]
+// CHECK-EMPTY:
+// CHECK-NEXT:  [[FIN]]:
+// CHECK-NEXT:  ret void
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -3840,8 +3840,10 @@
   if (auto *FE = dyn_cast(Init))
 Init = FE->getSubExpr();
 
-  if (auto *AIL = dyn_cast(Init))
-Init = AIL->getCommonExpr();
+  if (auto *AIL = dyn_cast(Init)) {
+OpaqueValueExpr *OVE = cast(AIL->getCommonExpr());
+Init = OVE->getSourceExpr();
+  }
 
   if (MaterializeTemporaryExpr *MTE = dyn_cast(Init))
 Init = MTE->getSubExpr();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109181: Reland "Try to unbreak Win build differently after 973519826edb76""

2021-09-02 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109181

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


  1   2   >