[PATCH] D105478: [clang] Make CXXRecrdDecl invalid if it contains any undeduced fields.

2021-07-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/test/SemaCXX/cxx11-crashes.cpp:117
+  // The missing expression makes A undeduced.
+  static constexpr auto A = ;  // expected-error {{expected expression}}
+  Foo::type B;  // The type of B is also undeduced (wrapped in 
Elaborated).

I think the root cause is that this incomplete var declaration is marked valid.

Looks like there are a few inconsistencies in clang:

```
struct Bar {
  static constexpr auto A1; // case1: invalid
  static constexpr auto A2 = ; // case2: valid
};

// static var decl in global context
static constexpr auto A3; // case3: invalid
static constexpr auto A4 = ; // case4: invalid
```

so it looks like marking case2 valid is a bug, I think we should invalidate it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105478

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


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

2021-07-07 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng updated this revision to Diff 356890.
kito-cheng added a comment.

Changes:

- Rebase to master, resolve conflict for zvamo change.
- New function filterSupportedExtensionInfosByName to simplify itearting 
SupportedExtensionInfos.
- Remove RISCVTargetInfo::HasA, look-up ISAInfo instead.
- Change retrun type for `RISCVISAInfo::parse(unsigned XLen, const 
std::vector &Features)` to void, the only error is the XLEN 
checking, remove that and and add assertion instead.
- Address @craig.topper's comment
- Address @jrtc27's comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.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/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/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/RISCVAttributes.h"
+#include "llvm/Support/RISCVISAInfo.h"
 #include "llvm/Support/TargetRegistry.h"
 
 #include 
@@ -50,6 +51,13 @@
 STATISTIC(RISCVNumInstrsCompressed,
   "Number of RISC-V Compressed instructions emitted");
 
+namespace llvm {
+extern const SubtargetFeatureKV RISCVFeatureKV[];
+}
+
+static ArrayRef RISCVFeatureTable =
+makeArrayRef(RISCVFeatureKV, RISCV::NumSubtargetFeatures);
+
 namespace {
 struct RISCVOperand;
 
@@ -2027,113 +2035,39 @@
 
   if (Tag == RISCVAttrs::ARCH) {
 StringRef Arch = StringValue;
-if (Arch.consume_front("rv32"))
+for (auto Feature : RISCVFeatureTable) {
+  if (llvm::RISCVISAInfo::isSupportedExtension(
+  Feature.Key, /* CheckExperimental */ true)) {
+clearFeatureBits(Feature.Value, Feature.Key);
+  }
+}
+
+llvm::RISCVISAInfo ISAInfo;
+if (auto E =
+ISAInfo.parse(StringValue, /* EnableExperimentalExtension */ true,
+  /* ExperimentalExtensionVersionCheck */ false)) {
+  std::string Buffer;
+  raw_string_ostream OutputErrMsg(Buffer);
+  handleAllErrors(std::move(E), [&](llvm::StringError &ErrMsg) {
+OutputErrMsg << "invalid arch name '" << Arch << "'

[PATCH] D105533: [clang] Fix an infinite loop during typo-correction

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

Great analysis, and the bailout seems reasonable. The overall algorithm seems 
terribly confusing though :-(




Comment at: clang/lib/Sema/SemaExprCXX.cpp:8340
   }
+  // Bail out if we didn't make any correction progress on the checking
+  // TypoExpr TE, otherwise we risk running the loop forever.

Comment is good but maybe could mention the high-level effect of breaking out 
(treat as unambiguous)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105533

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


[clang] 94d5f2a - [Clang] Add test dependency on llvm-ar

2021-07-07 Thread Saiyedul Islam via cfe-commits

Author: Saiyedul Islam
Date: 2021-07-07T14:30:57+05:30
New Revision: 94d5f2afbef0bc18cf92f6d147c336da990e7a40

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

LOG: [Clang] Add test dependency on llvm-ar

Following clang driver tests invoke llvm-ar, so ensure that
check-clang rebuilds llvm-ar.

 * test/Driver/clang-offload-bundler.c
 * test/Driver/hip-link-save-temps.hip
 * test/Driver/hip-link-static-library.hip
 * test/Driver/hip-toolchain-rdc-static-lib.hip

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

Added: 


Modified: 
clang/test/CMakeLists.txt

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 8e3460f75c37..e2f6d6772dea 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -108,6 +108,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-config
 FileCheck count not
 llc
+llvm-ar
 llvm-as
 llvm-bcanalyzer
 llvm-cat



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


[PATCH] D105285: [Clang] Add test dependency on llvm-ar

2021-07-07 Thread Saiyedul Islam via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG94d5f2afbef0: [Clang] Add test dependency on llvm-ar 
(authored by saiislam).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105285

Files:
  clang/test/CMakeLists.txt


Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -108,6 +108,7 @@
 llvm-config
 FileCheck count not
 llc
+llvm-ar
 llvm-as
 llvm-bcanalyzer
 llvm-cat


Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -108,6 +108,7 @@
 llvm-config
 FileCheck count not
 llc
+llvm-ar
 llvm-as
 llvm-bcanalyzer
 llvm-cat
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89913: SourceManager: Encapsulate line number mapping into SrcMgr::LineOffsetMapping

2021-07-07 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

@dexonsmith thanks for doing that cleanup!

I am currently trying to rebase https://reviews.llvm.org/D33275 on top of our 
internal infrastructure. We (cling) use `SourceManager::overrideFileContents` 
to provide virtual file content. It seems that every call to 
`ContentCache::getBufferOrNone` should somehow consider if the content was not 
overridden. Do you see an easy way to get D33275 
 aligned to `LineOffsetMapping`? 
Alternatively, we could require a `SourceManager&` argument to 
`ContentCache::getBufferOrNone` and return the overridden buffer...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89913

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


[PATCH] D103668: [PowerPC] Implement trap and conversion builtins for XL compatibility

2021-07-07 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.

It appears that Victor's comments have not been addressed yet and this is not 
ready for the next round of review. Requesting changes again to take it out of 
the queue until Victor's comments are addressed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103668

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


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

2021-07-07 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng marked 13 inline comments as done.
kito-cheng added inline comments.



Comment at: clang/lib/Basic/Targets/RISCV.cpp:230
+  unsigned XLEN = getTriple().isArch64Bit() ? 64 : 32;
+  if (auto E = ISAInfo.parse(XLEN, Features))
+return false;

jrtc27 wrote:
> Unused variable; I think this should either be consumeError'ed or propagated 
> up?
Change return type to `void`, we only checking XLEN inside parse function for 
feature vector, so change it to an assertion.



Comment at: clang/lib/Basic/Targets/RISCV.h:29
   std::string ABI, CPU;
-  bool HasM = false;
-  bool HasA = false;
-  bool HasF = false;
-  bool HasD = false;
-  bool HasC = false;
-  bool HasB = false;
-  bool HasV = false;
-  bool HasZba = false;
-  bool HasZbb = false;
-  bool HasZbc = false;
-  bool HasZbe = false;
-  bool HasZbf = false;
-  bool HasZbm = false;
-  bool HasZbp = false;
-  bool HasZbproposedc = false;
-  bool HasZbr = false;
-  bool HasZbs = false;
-  bool HasZbt = false;
-  bool HasZfh = false;
-  bool HasZvamo = false;
-  bool HasZvlsseg = false;
-
+  bool HasA;
+  llvm::RISCVISAInfo ISAInfo;

craig.topper wrote:
> Why is A treated differently?
Removed, look-up ISAInfo instead.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:117
+static Optional isExperimentalExtension(StringRef Ext) {
+  for (auto const &SupportedExtensionInfo : SupportedExtensionInfos) {
+if (!SupportedExtensionInfo.Experimental)

craig.topper wrote:
> Would it be better to have a findExtensionByName function that contains the 
> loop that can be shared by all these functions. Then you just check the 
> fields of the returned value for the additional checks?
I add an helper function `filterSupportedExtensionInfosByName` here rather than 
`findExtensionByName`, since I suppose we might support multiple version for 
one extension in future, e.g. `F` with version `2.0`, `2.1`, `2.2`, so I think 
keep a loop here might be easier to extend.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:625
+  SmallVector AllExts;
+  SmallVector Prefix{"z", "x", "s", "sx"};
+  auto I = Prefix.begin();

craig.topper wrote:
> Can this be a regular array instead of a SmallVector? You'll need to use 
> std::begin(Prefix) and std::end(Prefix) in place of begin()/end() below
Using std::arrary here, the cost should be cheap as built-in/plain array, but 
with utils functions.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:644
+   "invalid extension prefix '%s'",
+   Ext.str().c_str());
+}

jrtc27 wrote:
> craig.topper wrote:
> > craig.topper wrote:
> > > does createStringError really require going to from StringRef to 
> > > std::string to char*?
> > I guess it does if you use it with %s. Maybe better to use 
> > 
> > ```
> > "invalid extension prefix '" + Ext + "'"
> > ```
> > 
> > since the format string is really a Twine.
> That will break if the user-provided extension contains a %. Sadly 
> `.str().c_str()` is what you need.
Seems like `"invalid extension prefix '" + Ext + "'"` is work, 
createStringError has an overload is accept Twine as argument, and no format 
string interpretation 


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] D105168: [RISCV] Unify the arch string parsing logic to to RISCVArchStringParser.

2021-07-07 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng updated this revision to Diff 356916.
kito-cheng marked 3 inline comments as done.
kito-cheng added a comment.

Minor update for createStringError.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.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/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/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/RISCVAttributes.h"
+#include "llvm/Support/RISCVISAInfo.h"
 #include "llvm/Support/TargetRegistry.h"
 
 #include 
@@ -50,6 +51,13 @@
 STATISTIC(RISCVNumInstrsCompressed,
   "Number of RISC-V Compressed instructions emitted");
 
+namespace llvm {
+extern const SubtargetFeatureKV RISCVFeatureKV[];
+}
+
+static ArrayRef RISCVFeatureTable =
+makeArrayRef(RISCVFeatureKV, RISCV::NumSubtargetFeatures);
+
 namespace {
 struct RISCVOperand;
 
@@ -2027,113 +2035,39 @@
 
   if (Tag == RISCVAttrs::ARCH) {
 StringRef Arch = StringValue;
-if (Arch.consume_front("rv32"))
+for (auto Feature : RISCVFeatureTable) {
+  if (llvm::RISCVISAInfo::isSupportedExtension(
+  Feature.Key, /* CheckExperimental */ true)) {
+clearFeatureBits(Feature.Value, Feature.Key);
+  }
+}
+
+llvm::RISCVISAInfo ISAInfo;
+if (auto E =
+ISAInfo.parse(StringValue, /* EnableExperimentalExtension */ true,
+  /* ExperimentalExtensionVersionCheck */ false)) {
+  std::string Buffer;
+  raw_string_ostream OutputErrMsg(Buffer);
+  handleAllErrors(std::move(E), [&](llvm::StringError &ErrMsg) {
+OutputErrMsg << "invalid arch name '" << Arch << "', "
+ << ErrMsg.getMessage();
+  });
+
+  return Error(ValueExprLoc, OutputErrMsg.str());
+}
+
+for (auto Feature : RISCVFeatureTable) {
+  if (ISAInfo.hasExtension(Feature.Key)) {
+setFeatureBits(Feature.Value, Feature.Key);
+  }
+}
+
+if (ISAInfo.getXLen() == 32)
   clearFeatureBits(RISCV::Feature64Bit, "64bit");
-  

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

2021-07-07 Thread David Chisnall via Phabricator via cfe-commits
theraven added a comment.

Here's a minimal test:

  void tail(int, float);
  
  __attribute__((always_inline))
  void caller(float x)
  {
[[clang::musttail]]
return tail(42, x);
  }
  
  void outer(int x, float y)
  {
  return caller(y);
  }

This raises this error:

  tail.cc:7:3: error: cannot perform a tail call to function 'tail' because its 
signature is incompatible with the calling function
return tail(42, x);
^
  tail.cc:1:1: note: target function has different number of parameters 
(expected 1 but has 2)
  void tail(int, float);
  ^
  tail.cc:6:5: note: tail call required by 'musttail' attribute here
[[clang::musttail]]
  ^

There's also an interesting counterexample:

  void tail(int, float);
  
  __attribute__((always_inline))
  void caller(int a, float x)
  {
[[clang::musttail]]
return tail(a, x);
  }
  
  void outer(float y)
  {
  return caller(42, y);
  }

This *is* accepted by clang, but then generates this IR at -O0:

  define dso_local void @_Z5outerf(float %0) #2 {
%2 = alloca i32, align 4
%3 = alloca float, align 4
%4 = alloca float, align 4
store float %0, float* %4, align 4
%5 = load float, float* %4, align 4
store i32 42, i32* %2, align 4
store float %5, float* %3, align 4
%6 = load i32, i32* %2, align 4
%7 = load float, float* %3, align 4
call void @_Z4tailif(i32 %6, float %7)
ret void
  }

And this IR at -O1:

  ; Function Attrs: uwtable mustprogress
  define dso_local void @_Z5outerf(float %0) local_unnamed_addr #2 {
call void @_Z4tailif(i32 42, float %0)
ret void
  }

Note that in both cases, the alway-inline attribute is respected (even at -O0, 
the always-inline inliner runs) but the musttail annotation is lost.  The 
inlining has inserted the call into a function with a different set of 
parameters and so it cannot have a `musttail` IR annotation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99517

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


[PATCH] D105518: [clang] disable P2266 simpler implicit moves under -fms-compatibility

2021-07-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: rsmith.
aaron.ballman added a comment.

Thank you for working on this! I applied the patch locally and confirmed that 
it solves the issue at hand.

However, I'm not certain this is the right approach; what's the plan moving 
forward? This patch means that users of clang-cl will not get the simpler 
implicit moves. Once the STL gets fixed, then what? We can't remove this check 
for MS compat because then people using older STLs will go back to getting 
unacceptable compile errors and I'd hate to have to wait for long enough that 
old MSVC STLs have fallen out of circulation before enabling simpler implicit 
moves for clang-cl users.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105518

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


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

2021-07-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D99005#2860494 , @mizvekov wrote:

>> I'd prefer to keep existing code working without requiring users to enable a 
>> flag, if at all possible (esp because I don't expect the flag to be needed 
>> forever). That said, I still think it makes sense to temporarily revert this 
>> while doing that work.
>
> I'd like to give some time for other stakeholders to give their opinion if 
> this is not too urgent, specially @Quuxplusone and @rsmith.

This makes clang-cl basically unusable for a significant portion of people 
(enough so that I'm asking for a temporary revert) and I don't think we should 
continue to leave trunk in a broken state while deciding what to do. Our usual 
community approach is to revert out changes that cause significant breakage 
because we always want people (such as downstreams) to be able to track against 
trunk. That said, based on below, hold off on reversion as I may have 
misunderstood the fix patch (see below) and that may be the quicker and less 
disruptive approach.

> But thinking of another option, almost as easy as a global revert for this, 
> we could suppress the effect under -fms-compatibility for now, and then 
> implement a more targetted fix where we only suppress this when parsing the 
> STL system headers themselves under fms-compatibility.

Ah! I missed that context in the other patch, thank you for this! I'll go 
comment on the other review so we keep the discussion in one place, but that 
makes me more comfortable with the approach from that review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99005

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


[PATCH] D105518: [clang] disable P2266 simpler implicit moves under -fms-compatibility

2021-07-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D105518#2861635 , @aaron.ballman 
wrote:

> Thank you for working on this! I applied the patch locally and confirmed that 
> it solves the issue at hand.
>
> However, I'm not certain this is the right approach; what's the plan moving 
> forward? This patch means that users of clang-cl will not get the simpler 
> implicit moves. Once the STL gets fixed, then what? We can't remove this 
> check for MS compat because then people using older STLs will go back to 
> getting unacceptable compile errors and I'd hate to have to wait for long 
> enough that old MSVC STLs have fallen out of circulation before enabling 
> simpler implicit moves for clang-cl users.

I had missed some important context that was in 
https://reviews.llvm.org/D99005#2860494, namely that this is just to get us 
back to a good state immediately but there will be further follow-up work to 
target just the problematic part of the MSVC STL. So long as the follow-up work 
happens, I think this patch gets us moving forward without causing a lot of 
churn. If we find that a more targeted approach isn't feasible for some reason, 
we'll still have to figure out what to do, but at least this enables the 
feature for users who can use it, which is great.

Can you add a test case to demonstrate the behavior with this patch under 
`-fms-compatibility` and some comments explaining what's going on (just in case 
anyone comes peeking while the work is happening)? I'd suggest adding a FIXME 
comment to SemaStmt.cpp as well, just to be safe, in case the follow-up work is 
delayed for some reason.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105518

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


[PATCH] D105478: [clang] Make CXXRecrdDecl invalid if it contains any undeduced fields.

2021-07-07 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz updated this revision to Diff 356925.
adamcz added a comment.

changed to marking field type as invalid


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105478

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/ast-dump-undeduced-field.cpp
  clang/test/SemaCXX/cxx11-crashes.cpp


Index: clang/test/SemaCXX/cxx11-crashes.cpp
===
--- clang/test/SemaCXX/cxx11-crashes.cpp
+++ clang/test/SemaCXX/cxx11-crashes.cpp
@@ -104,3 +104,20 @@
   bool baz() { return __has_nothrow_constructor(B); }
   bool qux() { return __has_nothrow_copy(B); }
 }
+
+namespace undeduced_field {
+template
+struct Foo {
+  typedef T type;
+};
+
+struct Bar {
+  Bar();
+  // The missing expression makes A undeduced.
+  static constexpr auto A = ;  // expected-error {{expected expression}}
+  Foo::type B;  // The type of B is also undeduced (wrapped in 
Elaborated).
+};
+
+// This used to crash when trying to get the layout of B.
+Bar x;
+}
Index: clang/test/AST/ast-dump-undeduced-field.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-undeduced-field.cpp
@@ -0,0 +1,15 @@
+// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -ast-dump 
%s | FileCheck %s
+
+template< class T >
+struct Foo {
+  typedef T type;
+};
+
+struct Bar {
+  Bar();
+  static constexpr auto A = ;
+  Foo::type baz;
+};
+
+// CHECK: -CXXRecordDecl {{.*}} invalid struct Bar definition
+// CHECK: -FieldDecl {{.*}} invalid baz {{.*}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16759,6 +16759,9 @@
   TInfo = Context.getTrivialTypeSourceInfo(T, Loc);
 }
   }
+  if (const auto *U = T->getUnqualifiedDesugaredType())
+if (U->isUndeducedType())
+  D.setInvalidType();
 
   DiagnoseFunctionSpecifiers(D.getDeclSpec());
 


Index: clang/test/SemaCXX/cxx11-crashes.cpp
===
--- clang/test/SemaCXX/cxx11-crashes.cpp
+++ clang/test/SemaCXX/cxx11-crashes.cpp
@@ -104,3 +104,20 @@
   bool baz() { return __has_nothrow_constructor(B); }
   bool qux() { return __has_nothrow_copy(B); }
 }
+
+namespace undeduced_field {
+template
+struct Foo {
+  typedef T type;
+};
+
+struct Bar {
+  Bar();
+  // The missing expression makes A undeduced.
+  static constexpr auto A = ;  // expected-error {{expected expression}}
+  Foo::type B;  // The type of B is also undeduced (wrapped in Elaborated).
+};
+
+// This used to crash when trying to get the layout of B.
+Bar x;
+}
Index: clang/test/AST/ast-dump-undeduced-field.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-undeduced-field.cpp
@@ -0,0 +1,15 @@
+// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -ast-dump %s | FileCheck %s
+
+template< class T >
+struct Foo {
+  typedef T type;
+};
+
+struct Bar {
+  Bar();
+  static constexpr auto A = ;
+  Foo::type baz;
+};
+
+// CHECK: -CXXRecordDecl {{.*}} invalid struct Bar definition
+// CHECK: -FieldDecl {{.*}} invalid baz {{.*}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16759,6 +16759,9 @@
   TInfo = Context.getTrivialTypeSourceInfo(T, Loc);
 }
   }
+  if (const auto *U = T->getUnqualifiedDesugaredType())
+if (U->isUndeducedType())
+  D.setInvalidType();
 
   DiagnoseFunctionSpecifiers(D.getDeclSpec());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105478: [clang] Make CXXRecrdDecl invalid if it contains any undeduced fields.

2021-07-07 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added inline comments.



Comment at: clang/test/SemaCXX/cxx11-crashes.cpp:117
+  // The missing expression makes A undeduced.
+  static constexpr auto A = ;  // expected-error {{expected expression}}
+  Foo::type B;  // The type of B is also undeduced (wrapped in 
Elaborated).

hokein wrote:
> I think the root cause is that this incomplete var declaration is marked 
> valid.
> 
> Looks like there are a few inconsistencies in clang:
> 
> ```
> struct Bar {
>   static constexpr auto A1; // case1: invalid
>   static constexpr auto A2 = ; // case2: valid
> };
> 
> // static var decl in global context
> static constexpr auto A3; // case3: invalid
> static constexpr auto A4 = ; // case4: invalid
> ```
> 
> so it looks like marking case2 valid is a bug, I think we should invalidate 
> it.
I updated the change to mark a FieldDecl with undeduced type as invalid, thus 
making the record invalid too. Also added a test using -ast-dump to verify that 
both field and record are invalid, but kept the crash test too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105478

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


[PATCH] D105526: opencl-c.h: CL3.0 generic address space

2021-07-07 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Headers/opencl-c.h:7341
 half8 __ovld fract(half8 x, __private half8 *iptr);
 half16 __ovld fract(half16 x, __private half16 *iptr);

This one is not generic address space pointer though but I think this bit is 
part of an `#else` block? If you could just re-upload as a full diff, this will 
make it less confusing to review: 
https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105526

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


[clang] b3c80dd - [OPENMP]Remove const firstprivate allocation as a variable in a constant space.

2021-07-07 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2021-07-07T05:56:48-07:00
New Revision: b3c80dd8943a0d962bea1969b7a9e0147504d293

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

LOG: [OPENMP]Remove const firstprivate allocation as a variable in a constant 
space.

Current implementation is not compatible with asynchronous target
regions, need to remove it.

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
clang/test/OpenMP/target_firstprivate_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 71b34a1578fe..c2ef95cb1d28 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8224,10 +8224,6 @@ class MappableExprsHandler {
 // 'private ptr' and 'map to' flag. Return the right flags if the captured
 // declaration is known as first-private in this handler.
 if (FirstPrivateDecls.count(Cap.getCapturedVar())) {
-  if (Cap.getCapturedVar()->getType().isConstant(CGF.getContext()) &&
-  Cap.getCaptureKind() == CapturedStmt::VCK_ByRef)
-return MappableExprsHandler::OMP_MAP_ALWAYS |
-   MappableExprsHandler::OMP_MAP_TO;
   if (Cap.getCapturedVar()->getType()->isAnyPointerType())
 return MappableExprsHandler::OMP_MAP_TO |
MappableExprsHandler::OMP_MAP_PTR_AND_OBJ;
@@ -9163,30 +9159,15 @@ class MappableExprsHandler {
   CombinedInfo.Types.push_back(getMapModifiersForPrivateClauses(CI));
   const VarDecl *VD = CI.getCapturedVar();
   auto I = FirstPrivateDecls.find(VD);
-  if (I != FirstPrivateDecls.end() &&
-  VD->getType().isConstant(CGF.getContext())) {
-llvm::Constant *Addr =
-CGF.CGM.getOpenMPRuntime().registerTargetFirstprivateCopy(CGF, VD);
-// Copy the value of the original variable to the new global copy.
-CGF.Builder.CreateMemCpy(
-CGF.MakeNaturalAlignAddrLValue(Addr, ElementType).getAddress(CGF),
-Address(CV, CGF.getContext().getTypeAlignInChars(ElementType)),
-CombinedInfo.Sizes.back(), /*IsVolatile=*/false);
-// Use new global variable as the base pointers.
-CombinedInfo.Exprs.push_back(VD->getCanonicalDecl());
-CombinedInfo.BasePointers.push_back(Addr);
-CombinedInfo.Pointers.push_back(Addr);
+  CombinedInfo.Exprs.push_back(VD->getCanonicalDecl());
+  CombinedInfo.BasePointers.push_back(CV);
+  if (I != FirstPrivateDecls.end() && ElementType->isAnyPointerType()) {
+Address PtrAddr = CGF.EmitLoadOfReference(CGF.MakeAddrLValue(
+CV, ElementType, CGF.getContext().getDeclAlign(VD),
+AlignmentSource::Decl));
+CombinedInfo.Pointers.push_back(PtrAddr.getPointer());
   } else {
-CombinedInfo.Exprs.push_back(VD->getCanonicalDecl());
-CombinedInfo.BasePointers.push_back(CV);
-if (I != FirstPrivateDecls.end() && ElementType->isAnyPointerType()) {
-  Address PtrAddr = CGF.EmitLoadOfReference(CGF.MakeAddrLValue(
-  CV, ElementType, CGF.getContext().getDeclAlign(VD),
-  AlignmentSource::Decl));
-  CombinedInfo.Pointers.push_back(PtrAddr.getPointer());
-} else {
-  CombinedInfo.Pointers.push_back(CV);
-}
+CombinedInfo.Pointers.push_back(CV);
   }
   if (I != FirstPrivateDecls.end())
 IsImplicit = I->getSecond();
@@ -10579,45 +10560,6 @@ bool 
CGOpenMPRuntime::emitTargetGlobalVariable(GlobalDecl GD) {
   return false;
 }
 
-llvm::Constant *
-CGOpenMPRuntime::registerTargetFirstprivateCopy(CodeGenFunction &CGF,
-const VarDecl *VD) {
-  assert(VD->getType().isConstant(CGM.getContext()) &&
- "Expected constant variable.");
-  StringRef VarName;
-  llvm::Constant *Addr;
-  llvm::GlobalValue::LinkageTypes Linkage;
-  QualType Ty = VD->getType();
-  SmallString<128> Buffer;
-  {
-unsigned DeviceID;
-unsigned FileID;
-unsigned Line;
-getTargetEntryUniqueInfo(CGM.getContext(), VD->getLocation(), DeviceID,
- FileID, Line);
-llvm::raw_svector_ostream OS(Buffer);
-OS << "__omp_offloading_firstprivate_" << llvm::format("_%x", DeviceID)
-   << llvm::format("_%x_", FileID);
-if (CGM.getLangOpts().CPlusPlus) {
-  CGM.getCXXABI().getMangleContext().mangleTypeName(VD->getType(), OS);
-  OS << "_";
-}
-OS << VD->getName() << "_l" 

[PATCH] D105375: [OPENMP]Remove const firstprivate allocation as a variable in a constant space.

2021-07-07 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb3c80dd8943a: [OPENMP]Remove const firstprivate allocation 
as a variable in a constant space. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105375

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp

Index: clang/test/OpenMP/target_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/target_firstprivate_codegen.cpp
+++ clang/test/OpenMP/target_firstprivate_codegen.cpp
@@ -55,12 +55,11 @@
 // TCHECK-DAG:  [[TTII:%.+]] = type { i32, i32 }
 // TCHECK-DAG:  [[S1:%.+]] = type { double }
 
-// CHECK-DAG:  [[FP_E:@__omp_offloading_firstprivate_.+_e_l79]] = internal global [[TTII]] zeroinitializer
 // CHECK-DAG:  [[SIZET:@.+]] = private unnamed_addr constant [3 x i{{32|64}}] [i[[SZ:32|64]] 4, i{{64|32}} {{8|4}}, i[[SZ:32|64]] 4]
 // CHECK-DAG:  [[MAPT:@.+]] = private unnamed_addr constant [3 x i64] [i64 288, i64 49, i64 288]
 // CHECK-DAG:  [[MAPT2:@.+]] = private unnamed_addr constant [9 x i64] [i64 288, i64 161, i64 800, i64 161, i64 161, i64 800, i64 800, i64 161, i64 161]
 // CHECK-DAG:  [[SIZET3:@.+]] = private unnamed_addr constant [2 x i{{32|64}}] [i{{32|64}} 0, i{{32|64}} 8]
-// CHECK-DAG:  [[MAPT3:@.+]] = private unnamed_addr constant [2 x i64] [i64 32, i64 37]
+// CHECK-DAG:  [[MAPT3:@.+]] = private unnamed_addr constant [2 x i64] [i64 32, i64 161]
 // CHECK-DAG:  [[MAPT4:@.+]] = private unnamed_addr constant [5 x i64] [i64 547, i64 288, i64 800, i64 800, i64 161]
 // CHECK-DAG:  [[SIZET5:@.+]] = private unnamed_addr constant [3 x i{{32|64}}] [i[[SZ]] 4, i[[SZ]] 1, i[[SZ]] 40]
 // CHECK-DAG:  [[MAPT5:@.+]] = private unnamed_addr constant [3 x i64] [i64 288, i64 288, i64 161]
@@ -92,6 +91,7 @@
   // CHECK:  [[SSTACK:%.+]] = alloca i8*,
   // CHECK:  [[C:%.+]] = alloca [5 x [10 x double]],
   // CHECK:  [[D:%.+]] = alloca [[TT]],
+  // CHECK:  [[FP_E:%.+]] = alloca [[TTII]],
   // CHECK:  [[P:%.+]] = alloca i32*, align 64
   // CHECK:  [[ACAST:%.+]] = alloca i{{[0-9]+}},
   // CHECK:  [[BASE_PTR_ARR:%.+]] = alloca [3 x i8*],
@@ -347,8 +347,6 @@
   }
   // CHECK:  [[PTR_ADDR_REF:%.+]] = load double*, double** [[PTR_ADDR]],
 
-  // CHECK:  [[E_BC:%.+]] = bitcast [[TTII]]* [[E:%.+]] to i8*
-  // CHECK:  call void @llvm.memcpy.p0i8.p0i8.i{{64|32}}(i8* {{.*}} bitcast ([[TTII]]* [[FP_E]] to i8*), i8* {{.*}} [[E_BC]], i{{64|32}} 8, i1 false)
   // CHECK:  [[BASE_PTR_GEP3_0:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[BASE_PTR_ARR3]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
   // CHECK:  [[BCAST_TOPTR:%.+]] = bitcast i8** [[BASE_PTR_GEP3_0]] to double**
   // CHECK:  store double* [[PTR_ADDR_REF]], double** [[BCAST_TOPTR]],
@@ -367,9 +365,8 @@
   // CHECK: {{.+}} = call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}}, i64 -1, {{.+}}, i32 2, i8** [[BASE_PTR_GEP_ARG3]], i8** [[PTR_GEP_ARG3]], i[[SZ]]* getelementptr inbounds ([2 x i[[SZ]]], [2 x i[[SZ]]]* [[SIZET3]], i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[MAPT3]], i32 0, i32 0), i8** null, i8** null)
 
   // TCHECK:  define weak void @__omp_offloading_{{.+}}(double* [[PTR_IN:%.+]], [[TTII]]* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[E:%.+]])
-  // TCHECK-NOT: alloca [[TTII]],
   // TCHECK:  [[PTR_ADDR:%.+]] = alloca double*,
-  // TCHECK-NOT: alloca [[TTII]],
+  // TCHECK: alloca [[TTII]],
   // TCHECK-NOT: alloca double*,
   // TCHECK:  store double* [[PTR_IN]], double** [[PTR_ADDR]],
   // TCHECK-NOT: store double* %
Index: clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
+++ clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
@@ -18,9 +18,6 @@
 // TCHECK-DAG:  [[TT:%.+]] = type { i64, i8 }
 // TCHECK-DAG:  [[S1:%.+]] = type { double }
 
-// TCHECK: @__omp_offloading_firstprivate__{{.+}}_e_l30 = internal addrspace(4) global [[TTII]] zeroinitializer
-// TCHECK: @__omp_offloading_firstprivate__{{.+}}_ZTSK2TTIiiE_t_l143 = internal addrspace(4) global [[TTII]] zeroinitializer
-// TCHECK: @__omp_offloading_firstprivate__{{.+}}_ZTSK2TTIccE_t_l143 = internal addrspace(4) global [[TTIC]] zeroinitializer
 int foo(int n, double *ptr) {
   int a = 0;
   short aa = 0;
@@ -37,11 +34,9 @@
   }
 
   // TCHECK:  define {{.*}}void @__omp_offloading_{{.+}}([10 x float] addrspace(1)* noalias [[B_IN:%.+]], i{{[0-9]+}} [[A_IN:%.+]], [[TTII]]* noalias [[E_IN:%.+]])
-  // TCHECK-NOT: alloca [[TTII]],
   // TCHECK:  [[A_ADDR:%.+]] = alloca i{{[0-9]+}},
-  // TCHECK-NOT: alloca [[TTII]],
- 

[PATCH] D105518: [clang] disable P2266 simpler implicit moves under -fms-compatibility

2021-07-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I agree with Aaron for the need of a test.  At one point, we may wish to 
replace these calls with `getLangOpts().isCompatibleWithMSVC` or some similar 
inspection of `MSCompatibilityVersion`, but I acknowledge we can't do that 
until we figure out what the correct version IS!

Otherwise this seems like an appropriate temporary solution.




Comment at: clang/lib/Frontend/InitPreprocessor.cpp:602
+if (!LangOpts.MSVCCompat)
+  Builder.defineMacro("__cpp_implicit_move", "202011L");
 Builder.defineMacro("__cpp_size_t_suffix", "202011L");

This isn't adding a 'tab' character here, is it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105518

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


[PATCH] D105478: [clang] Make CXXRecrdDecl invalid if it contains any undeduced fields.

2021-07-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/test/SemaCXX/cxx11-crashes.cpp:117
+  // The missing expression makes A undeduced.
+  static constexpr auto A = ;  // expected-error {{expected expression}}
+  Foo::type B;  // The type of B is also undeduced (wrapped in 
Elaborated).

adamcz wrote:
> hokein wrote:
> > I think the root cause is that this incomplete var declaration is marked 
> > valid.
> > 
> > Looks like there are a few inconsistencies in clang:
> > 
> > ```
> > struct Bar {
> >   static constexpr auto A1; // case1: invalid
> >   static constexpr auto A2 = ; // case2: valid
> > };
> > 
> > // static var decl in global context
> > static constexpr auto A3; // case3: invalid
> > static constexpr auto A4 = ; // case4: invalid
> > ```
> > 
> > so it looks like marking case2 valid is a bug, I think we should invalidate 
> > it.
> I updated the change to mark a FieldDecl with undeduced type as invalid, thus 
> making the record invalid too. Also added a test using -ast-dump to verify 
> that both field and record are invalid, but kept the crash test too.
sorry, my comment was not clear enough -- if I understand your new change 
correctly, the change makes the field decl `Foo::type B;` but not 
the decl `A`. 

The problem here is `static constexpr auto A = ;`, this declaration (var, not 
field) is valid, which causes the field decl below `Foo::type B;` 
valid. If we invalidate the Decl `A`, then the filed decl B should be 
invalidated automatically.

leaving `A` valid is problematic -- we can't have a valid decl with an 
undeduced auto type in clang. the following case would lead another crash:

```
struct Bar {
  static constexpr auto A = ;
};
constexpr int s = sizeof(Bar::A);
```

So the solution is to make Decl `A` invalid.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105478

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


[PATCH] D105451: [clang] Fix crash when there is an invalid declaration with flag -Wcast-align

2021-07-07 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.

Thank you for the fix, LGTM! Do you need help landing the change? If so, please 
let me know what name and email address you'd like me to use for patch 
attribution.


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

https://reviews.llvm.org/D105451

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


[PATCH] D105512: [AIX] Don't pass no-integrated-as by default

2021-07-07 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

I think it is ok to not passing `-no-integrated-as` to cc1 as the default value 
for backend for XCOFF is no integrated assembler. Can we make the logic be 
simpler here?




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5043
+  // option to disable integrated-as explictly.
+  if (!TC.useIntegratedAs() && !TC.parseInlineAsmUsingAsmParser())
 CmdArgs.push_back("-no-integrated-as");

Do we need a new virtual function `parseInlineAsmUsingAsmParser()` in the tool 
chain file? Maybe we can use `isOSAIX()` and `Args.hasFlag(` here to change the 
behaviour for AIX. inline assembly parser sounds like not a toolchain level 
flag?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105512

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


[PATCH] D105512: [AIX] Don't pass no-integrated-as by default

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



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5043
+  // option to disable integrated-as explictly.
+  if (!TC.useIntegratedAs() && !TC.parseInlineAsmUsingAsmParser())
 CmdArgs.push_back("-no-integrated-as");

shchenz wrote:
> Do we need a new virtual function `parseInlineAsmUsingAsmParser()` in the 
> tool chain file? Maybe we can use `isOSAIX()` and `Args.hasFlag(` here to 
> change the behaviour for AIX. inline assembly parser sounds like not a 
> toolchain level flag?
I think we should avoid adding os specific code here. The new abstraction 
virtual function is designed to be usable by any target, just that aix is the 
only one for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105512

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


[PATCH] D105551: [libTooling] Add support for implicit `this` to `buildAddressOf`.

2021-07-07 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: tdl-g.
ymandel requested review of this revision.
Herald added a project: clang.

Changes `buildAddressOf` to return `this` when given an implicit `this` 
expression.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105551

Files:
  clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
  clang/unittests/Tooling/SourceCodeBuildersTest.cpp


Index: clang/unittests/Tooling/SourceCodeBuildersTest.cpp
===
--- clang/unittests/Tooling/SourceCodeBuildersTest.cpp
+++ clang/unittests/Tooling/SourceCodeBuildersTest.cpp
@@ -172,6 +172,24 @@
   testBuilder(buildAddressOf, "S x; x + x;", "&(x + x)");
 }
 
+TEST(SourceCodeBuildersTest, BuildAddressOfImplicitThis) {
+  StringRef Snippet = R"cc(
+struct Struct {
+  void foo() {}
+  void bar() {
+foo();
+  }
+};
+  )cc";
+  auto StmtMatch = matchStmt(
+  Snippet,
+  cxxMemberCallExpr(onImplicitObjectArgument(cxxThisExpr().bind("expr";
+  ASSERT_TRUE(StmtMatch);
+  EXPECT_THAT(buildAddressOf(*StmtMatch->Result.Nodes.getNodeAs("expr"),
+ *StmtMatch->Result.Context),
+  ValueIs(std::string("this")));
+}
+
 TEST(SourceCodeBuildersTest, BuildDereferencePointer) {
   testBuilder(buildDereference, "S *x; x;", "*x");
 }
Index: clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
===
--- clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
+++ clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
@@ -93,6 +93,8 @@
 
 llvm::Optional tooling::buildAddressOf(const Expr &E,
 const ASTContext &Context) 
{
+  if (E.isImplicitCXXThis())
+return std::string("this");
   if (const auto *Op = dyn_cast(&E))
 if (Op->getOpcode() == UO_Deref) {
   // Strip leading '*'.


Index: clang/unittests/Tooling/SourceCodeBuildersTest.cpp
===
--- clang/unittests/Tooling/SourceCodeBuildersTest.cpp
+++ clang/unittests/Tooling/SourceCodeBuildersTest.cpp
@@ -172,6 +172,24 @@
   testBuilder(buildAddressOf, "S x; x + x;", "&(x + x)");
 }
 
+TEST(SourceCodeBuildersTest, BuildAddressOfImplicitThis) {
+  StringRef Snippet = R"cc(
+struct Struct {
+  void foo() {}
+  void bar() {
+foo();
+  }
+};
+  )cc";
+  auto StmtMatch = matchStmt(
+  Snippet,
+  cxxMemberCallExpr(onImplicitObjectArgument(cxxThisExpr().bind("expr";
+  ASSERT_TRUE(StmtMatch);
+  EXPECT_THAT(buildAddressOf(*StmtMatch->Result.Nodes.getNodeAs("expr"),
+ *StmtMatch->Result.Context),
+  ValueIs(std::string("this")));
+}
+
 TEST(SourceCodeBuildersTest, BuildDereferencePointer) {
   testBuilder(buildDereference, "S *x; x;", "*x");
 }
Index: clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
===
--- clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
+++ clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
@@ -93,6 +93,8 @@
 
 llvm::Optional tooling::buildAddressOf(const Expr &E,
 const ASTContext &Context) {
+  if (E.isImplicitCXXThis())
+return std::string("this");
   if (const auto *Op = dyn_cast(&E))
 if (Op->getOpcode() == UO_Deref) {
   // Strip leading '*'.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105552: [analyzer][NFC] NoStoreFuncVisitor: Compact parameters for region pretty printing into a class

2021-07-07 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, vsavchenko, steakhal, martong, ASDenysPetrov.
Szelethus added a project: clang.
Herald added subscribers: manas, gamesh411, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun, 
whisperity.
Szelethus requested review of this revision.
Herald added a subscriber: cfe-commits.

Exactly what it says on the tin! I personally find this easier to read.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105552

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -357,7 +357,6 @@
   const SubRegion *RegionOfInterest;
   MemRegionManager &MmrMgr;
   const SourceManager &SM;
-  const PrintingPolicy &PP;
   bugreporter::TrackingKind TKind;
 
   /// Recursion limit for dereferencing fields when looking for the
@@ -378,11 +377,44 @@
 
   using RegionVector = SmallVector;
 
+  class RegionPrinter {
+const RegionVector &FieldChain;
+const MemRegion *RegionOfInterest;
+const MemRegion *MatchedRegion;
+const StringRef FirstElement;
+const bool FirstIsReferenceType;
+unsigned IndirectionLevel;
+const PrintingPolicy &PP;
+
+  private:
+/// Print first item in the chain, return new separator.
+static StringRef prettyPrintFirstElement(StringRef FirstElement,
+ bool MoreItemsExpected,
+ int IndirectionLevel,
+ llvm::raw_svector_ostream &os);
+
+  public:
+RegionPrinter(const RegionVector &FieldChain,
+  const MemRegion *RegionOfInterest,
+  const MemRegion *MatchedRegion, StringRef FirstElement,
+  bool FirstIsReferenceType, unsigned IndirectionLevel)
+: FieldChain(FieldChain), RegionOfInterest(RegionOfInterest),
+  MatchedRegion(MatchedRegion), FirstElement(FirstElement),
+  FirstIsReferenceType(FirstIsReferenceType),
+  IndirectionLevel(IndirectionLevel),
+  PP(RegionOfInterest->getMemRegionManager()
+ .getContext()
+ .getPrintingPolicy()) {}
+
+/// Pretty-print region \p MatchedRegion to \p os.
+/// \return Whether printing succeeded.
+bool prettyPrintRegionName(llvm::raw_svector_ostream &os);
+  };
+
 public:
   NoStoreFuncVisitor(const SubRegion *R, bugreporter::TrackingKind TKind)
   : RegionOfInterest(R), MmrMgr(R->getMemRegionManager()),
-SM(MmrMgr.getContext().getSourceManager()),
-PP(MmrMgr.getContext().getPrintingPolicy()), TKind(TKind) {}
+SM(MmrMgr.getContext().getSourceManager()), TKind(TKind) {}
 
   void Profile(llvm::FoldingSetNodeID &ID) const override {
 static int Tag = 0;
@@ -430,25 +462,9 @@
   /// either emit a note or suppress the report enirely.
   /// \return Diagnostics piece for region not modified in the current function,
   /// if it decides to emit one.
-  PathDiagnosticPieceRef
-  maybeEmitNote(PathSensitiveBugReport &R, const CallEvent &Call,
-const ExplodedNode *N, const RegionVector &FieldChain,
-const MemRegion *MatchedRegion, StringRef FirstElement,
-bool FirstIsReferenceType, unsigned IndirectionLevel);
-
-  /// Pretty-print region \p MatchedRegion to \p os.
-  /// \return Whether printing succeeded.
-  bool prettyPrintRegionName(StringRef FirstElement, bool FirstIsReferenceType,
- const MemRegion *MatchedRegion,
- const RegionVector &FieldChain,
- int IndirectionLevel,
- llvm::raw_svector_ostream &os);
-
-  /// Print first item in the chain, return new separator.
-  static StringRef prettyPrintFirstElement(StringRef FirstElement,
-   bool MoreItemsExpected,
-   int IndirectionLevel,
-   llvm::raw_svector_ostream &os);
+  PathDiagnosticPieceRef maybeEmitNote(PathSensitiveBugReport &R,
+   const CallEvent &Call,
+   const ExplodedNode *N, RegionPrinter RP);
 };
 
 } // end of anonymous namespace
@@ -587,8 +603,13 @@
   if (RegionOfInterest->isSubRegionOf(SelfRegion) &&
   potentiallyWritesIntoIvar(Call->getRuntimeDefinition().getDecl(),
 IvarR->getDecl()))
-return maybeEmitNote(R, *Call, N, {}, SelfRegion, "self",
- /*FirstIsReferenceType=*/false, 1);
+return maybeEmitNote(R, *Call, N,
+ RegionPrinter{{},
+   

[PATCH] D105142: RFC: Implementing new mechanism for hard register operands to inline asm as a constraint.

2021-07-07 Thread Anirudh Prasad via Phabricator via cfe-commits
anirudhp added a comment.

In D105142#2860885 , @MaskRay wrote:

> This is great.
>
>   unsigned long foo(unsigned long addr, unsigned long a0,
> unsigned long a1, unsigned long a2,
> unsigned long a3, unsigned long a4,
> unsigned long a5) {
> unsigned long result asm("rax");
> unsigned long b2 asm("rdx") = a2;
> unsigned long b3 asm("rcx") = a3;
> unsigned long b4 asm("r8") = a4;
> unsigned long b5 asm("r9") = a5;
> asm("call *%1" : "=r" (result) : "{rax}"(addr), "{rdi}"(a0), "{rsi}"(a1), 
> "r"(b2), "r"(b3), "r"(b4), "r"(b5));
> return result;
>   }
>
> this compiles to`%0 = tail call i64 asm "call *$1", 
> "=r,{r{ax}x},{r{dx}i},{rsi},r,r,r,r,~{dirflag},~{fpsr},~{flags}"(i64 %addr, 
> i64 %a0, i64 %a1, i64 %a2, i64 %a3, i64 %a4, i64 %a5) #1, !srcloc !3`
> (note `{r{ax}x},{r{dx}i}`) which will cause a backend failure `error: 
> couldn't allocate input reg for constraint '{r{dx}'`.
> Can you investigate it?

Definitely!

I'm assuming this is the X86 target from the usage of the registers in the 
example. So the issue here seems to be that before a constraint is emitted into 
the IR, the `SimplifyConstraint` (in CGStmt.cpp) 
/`TargetInfo::ConvertConstraint` (Target overridden) function(s) is/are called 
to "convert" the constraint into a simpler form if it exists. So, in this 
particular case, {rax}, gets "simplified" to {r{ax}} because:

  { -> no simplification rule exists -> simply emit it
  r -> no simplification rule exists -> simply emit it
  a -> simplified to {ax}-> {ax} is emitted
  x -> no simplification rule exists -> simply emit it
  } -> no simplification rule exists -> simply emit it

Thanks for bringing up this point because I missed it.

Looking into it in more detail, I think we can just forego the 
"simplification"/"conversion" of the constraint while emitting, if we have the 
[&]{.*} form, since this already maps to the lower level LLVM inline assembly 
IR which is responsible for telling the backend to allocate a specific 
register. All validation is already performed in the Sema stage, and/or in the 
AddVariableConstraints function. So what can be done imo, is to simply early 
return in the `SimplifyConstraint` function in CGStmt.cpp, when you have the 
constraint of the form [&]{.*}. What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105142

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


[PATCH] D105378: [dfsan][NFC] Add Origin Tracking into doc

2021-07-07 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse accepted this revision.
morehouse added a comment.
This revision is now accepted and ready to land.

We may also want to consider creating a frontend flag like MSan's origin 
tracking (`-fsanitize-memory-track-origins`).




Comment at: clang/docs/DataFlowSanitizer.rst:214
+
+% clang -fsanitize=dataflow -mllvm -dfsan-track-origins=1 
-fno-omit-frame-pointer -g -O2 test.cc
+% ./a.out




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105378

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


[PATCH] D105552: [analyzer][NFC] NoStoreFuncVisitor: Compact parameters for region pretty printing into a class

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

Honestly, I don't really see how this is better.
IMO `Printer` is something that prints, it should be everything that it does.  
It can accept different parameters tweaking how it prints in its constructor, 
but if it is a region printer, you should give it a region, and it should print 
it.  It's not a one-use thing.

Here it looks like you aggregate all the information about the region inside of 
this class, and it knows how to print it.  And it looks like this is actually a 
primary reason here, you want a good way to aggregate all these million 
parameters into one single object.  A better name (and purpose) for abstraction 
like this would be to actually make all these parameters to make sense 
together.  So that the visitor produces them together and then we process them 
together.  And one nice property of such aggregated result would be ability to 
print it.

Another problem that I see is that even for such a small class, I have no idea 
how to use it.  It has too many parameters and it doesn't tell me what is the 
relationship between them.  My guess is that in this form this class will never 
be reused outside of `NoStoreFuncVisitor`, then why do we need it?

At this point, I don't see how this abstraction adds any meaningful layering.  
Meaningful abstraction defines a language for a problem that we are trying to 
solve, so we can use it naturally when we talk.

Sorry about being pretty harsh here.  I do think that `NoStoreFuncVisitor` 
needs refactoring and better abstractions, I just don't think that this is the 
way to go.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105552

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


[PATCH] D105553: [analyzer][NFC] Split the main logic of NoStoreFuncVisitor to an abstract NoStateChangeVisitor class

2021-07-07 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, vsavchenko, martong, steakhal, ASDenysPetrov.
Szelethus added a project: clang.
Herald added subscribers: manas, gamesh411, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, sunfish, rnkovacs, szepet, baloghadamsoftware, 
xazax.hun, whisperity.
Szelethus requested review of this revision.
Herald added subscribers: cfe-commits, aheejin.

Preceding discussion on cfe-dev: 
https://lists.llvm.org/pipermail/cfe-dev/2021-June/068450.html

`NoStoreFuncVisitor` is a rather unique visitor. As `VisitNode` is invoked on 
most other visitors, they are looking for the point where something changed -- 
change on a value, some checker-specific GDM trait, a new constraint. 
`NoStoreFuncVisitor`, however, looks specifically for functions that *didn't* 
write to a `MemRegion` of interesting. Quoting from its comments:

  /// Put a diagnostic on return statement of all inlined functions
  /// for which  the region of interest \p RegionOfInterest was passed into,
  /// but not written inside, and it has caused an undefined read or a null
  /// pointer dereference outside.

It so happens that there are a number of other similar properties that are 
worth checking. For instance, if some memory leaks, it might be interesting why 
a function didn't take ownership of said memory:

  void sink(int *P) {} // no notes
  
  void f() {
sink(new int(5)); // note: Memory is allocated
  // Well hold on, sink() was supposed to deal with
  // that, this must be a false positive...
  } // warning: Potential memory leak [cplusplus.NewDeleteLeaks]

In here, the entity of interest isn't a `MemRegion`, but a symbol. The property 
that changed here isn't a change of value, but rather liveness and GDM traits 
managed by `MalloChecker`.

This patch moves some of the logic of `NoStoreFuncVisitor` to a new abstract 
class, `NoStateChangeFuncVisitor`. This is mostly calculating and caching the 
stack frames in which the entity of interest wasn't changed.

Descendants of this interface have to define 3 things:

- What constitutes as a change to an entity (this is done by overriding 
`wasModifiedBeforeCallExit`)
- What the diagnostic message should be (this is done by overriding 
`maybeEmitNote`)
- What constitutes as the entity of interest being passed into the function 
(this is also done by overriding `maybeEmitNote`, to be factored out a bit more 
in a later patch)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105553

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -343,38 +343,118 @@
   return P;
 }
 
+//===--===//
+// Implementation of NoStateChangeFuncVisitor.
+//===--===//
+
+bool NoStateChangeFuncVisitor::isModifiedInFrame(const ExplodedNode *N) {
+  const LocationContext *Ctx = N->getLocationContext();
+  const StackFrameContext *SCtx = Ctx->getStackFrame();
+  if (!FramesModifyingCalculated.count(SCtx))
+findModifyingFrames(N);
+  return FramesModifying.count(SCtx);
+}
+
+void NoStateChangeFuncVisitor::findModifyingFrames(
+const ExplodedNode *const CallExitN) {
+
+  assert(CallExitN->getLocationAs());
+  const ExplodedNode *LastReturnN = CallExitN;
+  const StackFrameContext *const OriginalSCtx =
+  CallExitN->getLocationContext()->getStackFrame();
+
+  const ExplodedNode *CurrN = CallExitN;
+
+  do {
+ProgramStateRef State = CurrN->getState();
+auto CallExitLoc = CurrN->getLocationAs();
+if (CallExitLoc) {
+  LastReturnN = CurrN;
+}
+
+FramesModifyingCalculated.insert(
+CurrN->getLocationContext()->getStackFrame());
+
+if (wasModifiedBeforeCallExit(CurrN, LastReturnN)) {
+  const StackFrameContext *SCtx = CurrN->getStackFrame();
+  while (!SCtx->inTopFrame()) {
+auto p = FramesModifying.insert(SCtx);
+if (!p.second)
+  break; // Frame and all its parents already inserted.
+SCtx = SCtx->getParent()->getStackFrame();
+  }
+}
+
+// Stop calculation at the call to the current function.
+if (auto CE = CurrN->getLocationAs())
+  if (CE->getCalleeContext() == OriginalSCtx)
+break;
+
+CurrN = CurrN->getFirstPred();
+  } while (CurrN);
+}
+
+PathDiagnosticPieceRef NoStateChangeFuncVisitor::VisitNode(
+const ExplodedNode *N, BugReporterContext &BR, PathSensitiveBugReport &R) {
+
+  const LocationContext *Ctx = N->getLocationContext();
+  const StackFrameContext *SCtx = Ctx->getStackFrame();
+  ProgramStateRef State = N->getState();
+  

[PATCH] D105142: RFC: Implementing new mechanism for hard register operands to inline asm as a constraint.

2021-07-07 Thread Anirudh Prasad via Phabricator via cfe-commits
anirudhp updated this revision to Diff 356961.
anirudhp added a comment.

- Disable constraint simplification when you already have a constraint of the 
form {...}. Constraint simplification is usually done character by character, 
with different targets having different implementations.
- Furthermore, a constraint of the form {...} already maps to the LLVM inline 
assembly IR that tells the backend to allocate a suitable physical register.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105142

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/x86-asm-register-constraint-mix.c


Index: clang/test/CodeGen/x86-asm-register-constraint-mix.c
===
--- /dev/null
+++ clang/test/CodeGen/x86-asm-register-constraint-mix.c
@@ -0,0 +1,63 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O2 -emit-llvm %s -o - | 
FileCheck %s
+
+unsigned long foo(unsigned long addr, unsigned long a0,
+  unsigned long a1, unsigned long a2,
+  unsigned long a3, unsigned long a4,
+  unsigned long a5) {
+  register unsigned long result asm("rax");
+  register unsigned long addr1 asm("rax") = addr;
+  register unsigned long b0 asm("rdi") = a0;
+  register unsigned long b1 asm("rsi") = a1;
+  register unsigned long b2 asm("rdx") = a2;
+  register unsigned long b3 asm("rcx") = a3;
+  register unsigned long b4 asm("r8") = a4;
+  register unsigned long b5 asm("r9") = a5;
+
+  // CHECK: tail call i64 asm "call *$1", 
"={rax},{rax},{rdi},{rsi},{rdx},{rcx},{r8},{r9},{rax},~{dirflag},~{fpsr},~{flags}"(i64
 %addr, i64 %a0, i64 %a1, i64 %a2, i64 %a3, i64 %a4, i64 %a5, i64 undef)
+  asm("call *%1" 
+  : "+r" (result) 
+  : "r"(addr1), "r"(b0), "r"(b1), "r"(b2), "r"(b3), "r"(b4), "r"(b5));
+  return result;
+}
+
+unsigned long foo1(unsigned long addr, unsigned long a0,
+  unsigned long a1, unsigned long a2,
+  unsigned long a3, unsigned long a4,
+  unsigned long a5) {
+  unsigned long result;
+  unsigned long addr1 = addr;
+  unsigned long b0 = a0;
+  unsigned long b1 = a1;
+  unsigned long b2 = a2;
+  unsigned long b3 = a3;
+  unsigned long b4 = a4;
+  unsigned long b5 = a5;
+
+  // CHECK: tail call i64 asm "call *$1", 
"={rax},{rax},{rdi},{rsi},{rdx},{rcx},{r8},{r9},{rax},~{dirflag},~{fpsr},~{flags}"(i64
 %addr, i64 %a0, i64 %a1, i64 %a2, i64 %a3, i64 %a4, i64 %a5, i64 undef)
+  asm("call *%1" 
+  : "+{rax}" (result) 
+  : "{rax}"(addr1), "{rdi}"(b0), "{rsi}"(b1), "{rdx}"(b2), "{rcx}"(b3), 
"{r8}"(b4), "{r9}"(b5));
+  return result;
+}
+
+unsigned long foo2(unsigned long addr, unsigned long a0,
+  unsigned long a1, unsigned long a2,
+  unsigned long a3, unsigned long a4,
+  unsigned long a5) {
+  register unsigned long result asm("rax");
+  unsigned long addr1 = addr;
+  unsigned long b0 = a0;
+  register unsigned long b1 asm ("rsi") = a1;
+  unsigned long b2 = a2;
+  unsigned long b3 = a3;
+  register unsigned long b4 asm ("r8") = a4;
+  unsigned long b5 = a5;
+
+  // CHECK: tail call i64 asm "call *$1", 
"={rax},{rax},{rdi},{rsi},{rdx},{rcx},{r8},{r9},{rax},~{dirflag},~{fpsr},~{flags}"(i64
 %addr, i64 %a0, i64 %a1, i64 %a2, i64 %a3, i64 %a4, i64 %a5, i64 undef)
+  asm("call *%1" 
+  : "+r" (result) 
+  : "{rax}"(addr1), "{rdi}"(b0), "r"(b1), "{rdx}"(b2), "{rcx}"(b3), 
"r"(b4), "{r9}"(b5));
+  return result;
+}
+
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -1966,6 +1966,13 @@
 static std::string
 SimplifyConstraint(const char *Constraint, const TargetInfo &Target,
  SmallVectorImpl *OutCons=nullptr) 
{
+  // If we have only the {...} constraint, do not do any simplifications. This 
already
+  // maps to the lower level LLVM inline assembly IR that tells the backend to 
allocate
+  // a specific register. Any validations would have already been done in the 
Sema stage
+  // or will be done in the AddVariableConstraints function.
+  if (Constraint[0] == '{' || (Constraint[0] == '&' && Constraint[1] == '{'))
+return std::string(Constraint);
+
   std::string Result;
 
   while (*Constraint) {


Index: clang/test/CodeGen/x86-asm-register-constraint-mix.c
===
--- /dev/null
+++ clang/test/CodeGen/x86-asm-register-constraint-mix.c
@@ -0,0 +1,63 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O2 -emit-llvm %s -o - | FileCheck %s
+
+unsigned long foo(unsigned long addr, unsigned long a0,
+  unsigned long a1, unsigned long a2,
+  unsigned long a3, unsigned long a4,
+  unsigned long a5) {
+  register unsigned

[PATCH] D105533: [clang] Fix an infinite loop during typo-correction

2021-07-07 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:8340
   }
+  // Bail out if we didn't make any correction progress on the checking
+  // TypoExpr TE, otherwise we risk running the loop forever.

sammccall wrote:
> Comment is good but maybe could mention the high-level effect of breaking out 
> (treat as unambiguous)
At this point we know the tree is so invalid that transforming no longer works, 
so our correction didn't really help. Is it even worth suggesting a correction 
(if we treat it as ambiguous we won't)?



Comment at: clang/lib/Sema/SemaExprCXX.cpp:8341-8344
+  // TypoExpr TE, otherwise we risk running the loop forever.
+  if (CurrentCorrection ==
+  &SemaRef.getTypoExprState(TE).Consumer->getCurrentCorrection())
+break;

Is all of this needed - can you just change the while below to also be && Next 
!= TC? Could move Next assignment up into the body if we want to change how we 
handle stalled progress


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105533

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


[PATCH] D105142: RFC: Implementing new mechanism for hard register operands to inline asm as a constraint.

2021-07-07 Thread Anirudh Prasad via Phabricator via cfe-commits
anirudhp updated this revision to Diff 356968.
anirudhp added a comment.

- Something went wrong with the previous time updating the diff. I'm not too 
sure, but I'm just doing it again, and this time the it looks a lot better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105142

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/SystemZ/systemz-inline-asm-02.c
  clang/test/CodeGen/SystemZ/systemz-inline-asm.c
  clang/test/CodeGen/aarch64-inline-asm.c
  clang/test/CodeGen/asm-goto.c
  clang/test/CodeGen/ms-intrinsics.c
  clang/test/CodeGen/x86-asm-register-constraint-mix.c
  clang/test/CodeGen/z-hard-register-inline-asm.c
  clang/test/Sema/z-hard-register-inline-asm.c

Index: clang/test/Sema/z-hard-register-inline-asm.c
===
--- /dev/null
+++ clang/test/Sema/z-hard-register-inline-asm.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 %s -triple s390x-ibm-linux -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple s390x-ibm-zos -fsyntax-only -verify
+
+void f1() {
+  int a, b;
+  __asm("lhi %0,5\n"
+: "={r2}"(a)
+:);
+
+  __asm("lgr %0,%1\n"
+: "={r2}"(a)
+: "{r1}"(b));
+
+  __asm("lgr %0,%1\n"
+: "={r2}"(a)
+: "{%r1}"(b));
+
+  __asm("lgr %0,%1\n"
+: "=&{r1}"(a)
+: "{r2}"(b));
+
+  __asm("lhi %0,5\n"
+: "={r2"(a) // expected-error {{invalid output constraint '={r2' in asm}}
+:);
+
+  __asm("lhi %0,5\n"
+: "={r17}"(a) // expected-error {{invalid output constraint '={r17}' in asm}}
+:);
+
+  __asm("lhi %0,5\n"
+: "={}"(a) // expected-error {{invalid output constraint '={}' in asm}}
+:);
+
+  __asm("lhi %0,5\n"
+: "=&{r2"(a) // expected-error {{invalid output constraint '=&{r2' in asm}}
+:);
+
+  __asm("lgr %0,%1\n"
+: "=r"(a)
+: "{r1"(b)); // expected-error {{invalid input constraint '{r1' in asm}}
+
+  __asm("lgr %0,%1\n"
+: "=r"(a)
+: "{}"(b)); // expected-error {{invalid input constraint '{}' in asm}}
+
+  __asm("lgr %0,%1\n"
+: "={r1}"(a)
+: "{r17}"(b)); // expected-error {{invalid input constraint '{r17}' in asm}}
+}
Index: clang/test/CodeGen/z-hard-register-inline-asm.c
===
--- /dev/null
+++ clang/test/CodeGen/z-hard-register-inline-asm.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple s390x-ibm-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple s390x-ibm-zos -emit-llvm -o - %s | FileCheck %s
+
+void f1() {
+  int a, b;
+  register int c asm("r1");
+  register int d asm("r2");
+
+  // CHECK-COUNT-2: call i32 asm "lhi $0,5\0A", "={r1}"
+  __asm("lhi %0,5\n"
+: "={r1}"(a)
+:
+:);
+  __asm("lhi %0,5\n"
+: "=r"(c)
+:
+:);
+
+  // CHECK-COUNT-2: call i32 asm "lgr $0,$1\0A", "={r1},{r2}"
+  __asm("lgr %0,%1\n"
+: "={r1}"(a)
+: "{r2}"(b)
+:);
+  __asm("lgr %0,%1\n"
+: "=r"(c)
+: "r"(d)
+:);
+
+  // CHECK-COUNT-2: call i32 asm "lgr $0,$1\0A", "={r1},{r2}"
+  __asm("lgr %0,%1\n"
+: "={%r1}"(a)
+: "{%r2}"(b)
+:);
+  __asm("lgr %0,%1\n"
+: "={r1}"(a)
+: "{%r2}"(b)
+:);
+
+  // CHECK-COUNT-2: call i32 asm "lgr $0,$1\0A", "=&{r1},{r2}"
+  __asm("lgr %0,%1\n"
+: "=&{r1}"(a)
+: "{%r2}"(b)
+:);
+  __asm("lgr %0,%1\n"
+: "=&r"(c)
+: "r"(d)
+:);
+}
Index: clang/test/CodeGen/x86-asm-register-constraint-mix.c
===
--- /dev/null
+++ clang/test/CodeGen/x86-asm-register-constraint-mix.c
@@ -0,0 +1,63 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O2 -emit-llvm %s -o - | FileCheck %s
+
+unsigned long foo(unsigned long addr, unsigned long a0,
+  unsigned long a1, unsigned long a2,
+  unsigned long a3, unsigned long a4,
+  unsigned long a5) {
+  register unsigned long result asm("rax");
+  register unsigned long addr1 asm("rax") = addr;
+  register unsigned long b0 asm("rdi") = a0;
+  register unsigned long b1 asm("rsi") = a1;
+  register unsigned long b2 asm("rdx") = a2;
+  register unsigned long b3 asm("rcx") = a3;
+  register unsigned long b4 asm("r8") = a4;
+  register unsigned long b5 asm("r9") = a5;
+
+  // CHECK: tail call i64 asm "call *$1", "={rax},{rax},{rdi},{rsi},{rdx},{rcx},{r8},{r9},{rax},~{dirflag},~{fpsr},~{flags}"(i64 %addr, i64 %a0, i64 %a1, i64 %a2, i64 %a3, i64 %a4, i64 %a5, i64 undef)
+  asm("call *%1" 
+  : "+r" (result) 
+  : "r"(addr1), "r"(b0), "r"(b1), "r"(b2), "r"(b3), "r"(b4), "r"(b5));
+  return result;
+}
+
+unsigned long foo1(unsigned long addr, unsigned long a0,
+  uns

[PATCH] D105142: RFC: Implementing new mechanism for hard register operands to inline asm as a constraint.

2021-07-07 Thread Anirudh Prasad via Phabricator via cfe-commits
anirudhp added a comment.

@MaskRay Could you please look at the latest changeset, I have added your 
example as a separate test case for the x86 target.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105142

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


[PATCH] D105555: [PoC][RISCV][Clang] Compute the default target-abi if it's empty.

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

Address https://reviews.llvm.org/D102582#2860849

Explicitly target-abi encoded in IR is clear than empty target-abi.

I have one more question When I was working on this feature.
In riscv::getRISCVABI, default ABI value is based on march, and the default 
march is base on mcpu if the march is empty.
So do we need to consider getting the default ABI according to target-cpu's 
default march?
If yes, does it mean we also need to update default target-feature in 
RISCVTargetInfo based on -target-cpu?

In clang driver, missing -march with mcpu is clear intention so we could use 
default march from mcpu.
But in cc1, I feel it's not clear when missing -target-feature with target-cpu 
option. maybe user really want to use the
default isa.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D10

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/test/CodeGen/RISCV/riscv-metadata.c


Index: clang/test/CodeGen/RISCV/riscv-metadata.c
===
--- clang/test/CodeGen/RISCV/riscv-metadata.c
+++ clang/test/CodeGen/RISCV/riscv-metadata.c
@@ -1,14 +1,22 @@
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -o - %s | FileCheck 
-check-prefix=EMPTY-ILP32 %s
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm -target-feature +f 
-target-feature +d -o - %s | FileCheck -check-prefix=EMPTY-ILP32D %s
 // RUN: %clang_cc1 -triple riscv32 -target-abi ilp32 -emit-llvm -o - %s | 
FileCheck -check-prefix=ILP32 %s
 // RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-abi ilp32f 
-emit-llvm -o - %s | FileCheck -check-prefix=ILP32F %s
 // RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-abi ilp32d 
-emit-llvm -o - %s | FileCheck -check-prefix=ILP32D %s
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -o - %s | FileCheck 
-check-prefix=EMPTY-LP64 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d 
-emit-llvm -o - %s | FileCheck -check-prefix=EMPTY-LP64D %s
 // RUN: %clang_cc1 -triple riscv64 -target-abi lp64 -emit-llvm -o - %s | 
FileCheck -check-prefix=LP64 %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-abi lp64f 
-emit-llvm -o - %s | FileCheck -check-prefix=LP64F %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +d -target-abi lp64d 
-emit-llvm -o - %s | FileCheck -check-prefix=LP64D %s
 
+// EMPTY-ILP32: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32"}
+// EMPTY-ILP32D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32d"}
 // ILP32: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32"}
 // ILP32F: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32f"}
 // ILP32D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32d"}
 
+// EMPTY-LP64: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64"}
+// EMPTY-LP64D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64d"}
 // LP64: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64"}
 // LP64F: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64f"}
 // LP64D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64d"}
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -69,7 +69,6 @@
 return true;
   }
 
-  StringRef getABI() const override { return ABI; }
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override;
 
@@ -129,6 +128,8 @@
 return false;
   }
 
+  StringRef getABI() const override;
+
   bool isValidCPUName(StringRef Name) const override;
   void fillValidCPUList(SmallVectorImpl &Values) const override;
   bool isValidTuneCPUName(StringRef Name) const override;
@@ -158,6 +159,8 @@
 return false;
   }
 
+  StringRef getABI() const override;
+
   bool isValidCPUName(StringRef Name) const override;
   void fillValidCPUList(SmallVectorImpl &Values) const override;
   bool isValidTuneCPUName(StringRef Name) const override;
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -332,6 +332,16 @@
   return true;
 }
 
+StringRef RISCV32TargetInfo::getABI() const {
+  if (!ABI.empty())
+return ABI;
+  // Choose a default based on the target architecture.
+  // The logic sync with riscv::getRISCVABI
+  if (HasD)
+return "ilp32d";
+  return "ilp32";
+}
+
 bool RISCV32TargetInfo::isValidCPUName(StringRef Name) const {
   return llvm::RISCV::checkCPUKind(llvm::RISCV::parseCPUKind(Name),
   

[PATCH] D105552: [analyzer][NFC] NoStoreFuncVisitor: Compact parameters for region pretty printing into a class

2021-07-07 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D105552#2861924 , @vsavchenko 
wrote:

> Sorry about being pretty harsh here.  I do think that `NoStoreFuncVisitor` 
> needs refactoring and better abstractions, I just don't think that this is 
> the way to go.

Nah, you're totally right. In retrospect, this refactoring feela a lot like it 
was done by a robot, not a human. It was a part of some greater plan that I 
abandoned later, so its luckily not a consequential change to my overall 
refactoring efforts.

Cheers for the enlightening! I suppose I never saw similar changed that way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105552

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


[PATCH] D105555: [PoC][RISCV][Clang] Compute the default target-abi if it's empty.

2021-07-07 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Extract the code out into a shared function, don't duplicate it otherwise we'll 
get confusing inconsistent defaults. Especially when there are proposals to 
change the defaults as currently there are some weird interactions where 
specifying seemingly-redundant flags changes the behaviour (e.g. clang -target 
riscv32-unknown-elf gets you rv32imac/ilp32, but clang -target 
riscv32-unknown-elf -mabi=ilp32 gets you rv32imafdc/ilp32).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D10

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


[PATCH] D102782: Add support for Warning Flag "-Wstack-usage="

2021-07-07 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic added a comment.

@MaskRay Yes this would unblock applications. Regarding your concern, the 
information from this implementation as well as GCC's should be used 
conservatively as both are approximate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102782

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


[PATCH] D103461: [clang][deps] NFC: Preserve the original frontend action

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

In D103461#2841918 , @bmahjour wrote:

> @jansvoboda11 This change is causing the following LIT tests to fail on AIX:
>
>   Clang :: ClangScanDeps/headerwithdirname.cpp
>   Clang :: ClangScanDeps/headerwithdirnamefollowedbyinclude.cpp
>
> The reason seems to be related to the fact that `-fno-integrated-as` is on by 
> default on that platform. I get the same failure on Linux if I change the 
> "compilation database" file to add `-fno-integrated-as` to the "command" line:
>
>   > /build_llvm/bin/clang-scan-deps -compilation-database 
> ./headerwithdirname.cpp.tmp.cdb -j 1
>   > Error while scanning dependencies for 
> /build_llvm/tools/clang/test/ClangScanDeps/Output/headerwithdirname.cpp.tmp.dir/headerwithdirname_input.cpp:
>   error: unable to handle compilation, expected exactly one compiler job in ' 
> "clang" "-cc1" "-triple" "powerpc64le-unknown-linux-gnu" "-S" ...;  
> "/usr/bin/as" "-a64" "-mppc64" "-mlittle-endian" "-mpower8" "-I" 
> "/build_llvm/tools/clang/test/ClangScanDeps/Output/headerwithdirname.cpp.tmp.dir"
>  "-I" 
> "/build_llvm/tools/clang/test/ClangScanDeps/Output/headerwithdirname.cpp.tmp.dir/foodir"
>  "-I" "Inputs" "-o" "headerwithdirname_input.o" 
> "/tmp/headerwithdirname_input-2e0050.s"; '

Thanks for the report and the reproducer. I'll try to get a fix ready tomorrow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103461

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


[PATCH] D104742: [UpdateCCTestChecks] Implement --global-value-regex

2021-07-07 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

Ping.


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

https://reviews.llvm.org/D104742

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


[PATCH] D105533: [clang] Fix an infinite loop during typo-correction

2021-07-07 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:8340
   }
+  // Bail out if we didn't make any correction progress on the checking
+  // TypoExpr TE, otherwise we risk running the loop forever.

dgoldman wrote:
> sammccall wrote:
> > Comment is good but maybe could mention the high-level effect of breaking 
> > out (treat as unambiguous)
> At this point we know the tree is so invalid that transforming no longer 
> works, so our correction didn't really help. Is it even worth suggesting a 
> correction (if we treat it as ambiguous we won't)?
Nevermind, misunderstood, left some comments on the bug there. What happens if 
the right correction actually was ambiguous though? Would we skip it here?



Comment at: clang/test/Sema/typo-correction-no-hang.c:4-14
+struct a {
+  int xxx;
+};
+
+int g_107;
+int g_108;
+int g_109;

Could you add another test case for the same thing but making the correction 
ambiguous, e.g. g_998 or similar?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105533

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


[PATCH] D103668: [PowerPC] Implement trap and conversion builtins for XL compatibility

2021-07-07 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 356985.
Conanap marked 15 inline comments as done.
Conanap added a comment.

Addressed comments, separated 64 bit C test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103668

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-conversionfunc.c
  clang/test/CodeGen/builtins-ppc-xlcompat-error.c
  clang/test/CodeGen/builtins-ppc-xlcompat-trap-64bit-only.c
  clang/test/CodeGen/builtins-ppc-xlcompat-trap.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstr64Bit.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-conversionfunc.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap-64bit-only.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll
@@ -0,0 +1,139 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+
+; tw
+declare void @llvm.ppc.tw(i32 %a, i32 %b, i32 %c)
+define dso_local void @test__twlgt(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twlgt:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twlgt 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 1)
+  ret void
+}
+
+define dso_local void @test__twllt(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twllt:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twllt 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 2)
+  ret void
+}
+
+define dso_local void @test__twne3(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twne3:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twne 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 3)
+  ret void
+}
+
+define dso_local void @test__tweq(i32 %a, i32 %b) {
+; CHECK-LABEL: test__tweq:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tweq 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 4)
+  ret void
+}
+
+define dso_local void @test__twlge(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twlge:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 5, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 5)
+  ret void
+}
+
+define dso_local void @test__twlle(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twlle:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 6, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 6)
+  ret void
+}
+
+define dso_local void @test__twgt(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twgt:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twgt 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 8)
+  ret void
+}
+
+define dso_local void @test__twge(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twge:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 12, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 12)
+  ret void
+}
+
+define dso_local void @test__twlt(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twlt:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twlt 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 16)
+  ret void
+}
+
+define dso_local void @test__twle(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twle:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 20, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 20)
+  ret void
+}
+
+define dso_local void @test__twne24(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twne24:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twne 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 24)
+  ret void
+}
+
+define dso_local void @test__tweq31(i32 %a, i32 %b) {
+; CHECK-LABEL: test__tweq31:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tweq 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 31)
+  ret void
+}
+
+define dso_local void @test__tw_no_match(i32 %a, i32 %b) {
+; CHECK-LABEL: test__tw_no_match:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 13, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 13)
+  ret void
+}
+
+; trap
+declare void @llvm.ppc.trap(i32 %a)
+define dso_local void @test__trap(i32 %a) {
+; CHECK-LABEL: test__trap:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twnei 3, 0
+; CHECK-NEXT:blr
+  call void @llvm.ppc.trap(i32 %a)
+  ret void
+}
Index: llvm/test/CodeGen/PowerPC/builtins

[PATCH] D103668: [PowerPC] Implement trap and conversion builtins for XL compatibility

2021-07-07 Thread Albion Fung via Phabricator via cfe-commits
Conanap added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsPPC.def:50
 BUILTIN(__builtin_ppc_compare_and_swaplp, "iLiD*Li*Li", "")
+BUILTIN(__builtin_ppc_tdw, "vLLiLLiIi", "")
+BUILTIN(__builtin_ppc_tw, "viiIi", "")

NeHuang wrote:
> definition here not matching prototype in document 
> ```
> void __tdw ( long a, long b, unsigned int TO);
> ```
the document had been incorrect; the document is now updated to to `long long`.



Comment at: llvm/lib/Target/PowerPC/PPCInstrInfo.td:2233
 
+def : InstAlias<"tdlle $rA, $rB", (TD 6, g8rc:$rA, g8rc:$rB)>;
+def : InstAlias<"tdlge $rA, $rB", (TD 5, g8rc:$rA, g8rc:$rB)>;

amyk wrote:
> Are `tdne`, `tweq` supposed to be aliases that are intended to be added here, 
> too?
the compiler seem to already know `tdne` and `tweq` so I didn't add those.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103668

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


[PATCH] D103668: [PowerPC] Implement trap and conversion builtins for XL compatibility

2021-07-07 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 356988.
Conanap added a comment.

Moved inst alias for 64bit to the 64 bit file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103668

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-conversionfunc.c
  clang/test/CodeGen/builtins-ppc-xlcompat-error.c
  clang/test/CodeGen/builtins-ppc-xlcompat-trap-64bit-only.c
  clang/test/CodeGen/builtins-ppc-xlcompat-trap.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstr64Bit.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-conversionfunc.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap-64bit-only.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll
@@ -0,0 +1,139 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+
+; tw
+declare void @llvm.ppc.tw(i32 %a, i32 %b, i32 %c)
+define dso_local void @test__twlgt(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twlgt:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twlgt 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 1)
+  ret void
+}
+
+define dso_local void @test__twllt(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twllt:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twllt 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 2)
+  ret void
+}
+
+define dso_local void @test__twne3(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twne3:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twne 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 3)
+  ret void
+}
+
+define dso_local void @test__tweq(i32 %a, i32 %b) {
+; CHECK-LABEL: test__tweq:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tweq 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 4)
+  ret void
+}
+
+define dso_local void @test__twlge(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twlge:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 5, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 5)
+  ret void
+}
+
+define dso_local void @test__twlle(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twlle:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 6, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 6)
+  ret void
+}
+
+define dso_local void @test__twgt(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twgt:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twgt 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 8)
+  ret void
+}
+
+define dso_local void @test__twge(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twge:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 12, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 12)
+  ret void
+}
+
+define dso_local void @test__twlt(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twlt:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twlt 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 16)
+  ret void
+}
+
+define dso_local void @test__twle(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twle:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 20, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 20)
+  ret void
+}
+
+define dso_local void @test__twne24(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twne24:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twne 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 24)
+  ret void
+}
+
+define dso_local void @test__tweq31(i32 %a, i32 %b) {
+; CHECK-LABEL: test__tweq31:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tweq 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 31)
+  ret void
+}
+
+define dso_local void @test__tw_no_match(i32 %a, i32 %b) {
+; CHECK-LABEL: test__tw_no_match:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 13, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 13)
+  ret void
+}
+
+; trap
+declare void @llvm.ppc.trap(i32 %a)
+define dso_local void @test__trap(i32 %a) {
+; CHECK-LABEL: test__trap:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twnei 3, 0
+; CHECK-NEXT:blr
+  call void @llvm.ppc.trap(i32 %a)
+  ret void
+}
Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap-64bit-only.ll
===

[PATCH] D102782: Add support for Warning Flag "-Wstack-usage="

2021-07-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D102782#2862065 , @rsanthir.quic 
wrote:

> @MaskRay Yes this would unblock applications. Regarding your concern, the 
> information from this implementation as well as GCC's should be used 
> conservatively as both are approximate.

Do your applications parse the diagnostic to take some actions? Note that clang 
diagnostic format is different from GCC's.
If you need any adaptation, can you just change the -Wstack-usage= option to 
-Wframe-larger-than= (the former is stronger but Clang doesn't implement the 
full functionality)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102782

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


[PATCH] D105526: opencl-c.h: CL3.0 generic address space

2021-07-07 Thread Dave Airlie via Phabricator via cfe-commits
airlied updated this revision to Diff 356992.
airlied added a comment.

updated to full diff.


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

https://reviews.llvm.org/D105526

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Headers/opencl-c.h

Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -7259,7 +7259,7 @@
  * Returns fmin(x - floor (x), 0x1.fep-1f ).
  * floor(x) is returned in iptr.
  */
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld fract(float x, float *iptr);
 float2 __ovld fract(float2 x, float2 *iptr);
 float3 __ovld fract(float3 x, float3 *iptr);
@@ -7341,7 +7341,7 @@
 half8 __ovld fract(half8 x, __private half8 *iptr);
 half16 __ovld fract(half16 x, __private half16 *iptr);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 
 /**
  * Extract mantissa and exponent from x. For each
@@ -7349,7 +7349,7 @@
  * magnitude in the interval [1/2, 1) or 0. Each
  * component of x equals mantissa returned * 2^exp.
  */
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld frexp(float x, int *exp);
 float2 __ovld frexp(float2 x, int2 *exp);
 float3 __ovld frexp(float3 x, int3 *exp);
@@ -7431,7 +7431,7 @@
 half8 __ovld frexp(half8 x, __private int8 *exp);
 half16 __ovld frexp(half16 x, __private int16 *exp);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 
 /**
  * Compute the value of the square root of x^2 + y^2
@@ -7556,7 +7556,7 @@
 half16 __ovld __cnfn lgamma(half16 x);
 #endif //cl_khr_fp16
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld lgamma_r(float x, int *signp);
 float2 __ovld lgamma_r(float2 x, int2 *signp);
 float3 __ovld lgamma_r(float3 x, int3 *signp);
@@ -7638,7 +7638,7 @@
 half8 __ovld lgamma_r(half8 x, __private int8 *signp);
 half16 __ovld lgamma_r(half16 x, __private int16 *signp);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 
 /**
  * Compute natural logarithm.
@@ -7862,7 +7862,7 @@
  * the argument. It stores the integral part in the object
  * pointed to by iptr.
  */
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld modf(float x, float *iptr);
 float2 __ovld modf(float2 x, float2 *iptr);
 float3 __ovld modf(float3 x, float3 *iptr);
@@ -7944,7 +7944,7 @@
 half8 __ovld modf(half8 x, __private half8 *iptr);
 half16 __ovld modf(half16 x, __private half16 *iptr);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 
 /**
  * Returns a quiet NaN. The nancode may be placed
@@ -8122,7 +8122,7 @@
  * sign as x/y. It stores this signed value in the object
  * pointed to by quo.
  */
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld remquo(float x, float y, int *quo);
 float2 __ovld remquo(float2 x, float2 y, int2 *quo);
 float3 __ovld remquo(float3 x, float3 y, int3 *quo);
@@ -8205,7 +8205,7 @@
 half8 __ovld remquo(half8 x, half8 y, __private int8 *quo);
 half16 __ovld remquo(half16 x, half16 y, __private int16 *quo);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 /**
  * Round to integral value (using round to nearest
  * even rounding mode) in floating-point format.
@@ -8346,7 +8346,7 @@
  * is the return value and computed cosine is returned
  * in cosval.
  */
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld sincos(float x, float *cosval);
 float2 __ovld sincos(float2 x, float2 *cosval);
 float3 __ovld sincos(float3 x, float3 *cosval);
@@ -8428,7 +8428,7 @@
 half8 __ovld sincos(half8 x, __private half8 *cosval);
 half16 __ovld sincos(half16 x, __private half16 *cosval);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 
 /**
  * Compute hyperbolic sine.
@@ -11249,7 +11249,7 @@
 half16 __ovld vload16(size_t offset, const __constant half *p);
 #endif //cl_khr_fp16
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_

[PATCH] D103938: Diagnose -Wunused-value in constant evaluation context

2021-07-07 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

ping..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938

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


[PATCH] D105562: [OPENMP]Fix overlapped mapping for dereferenced pointer members.

2021-07-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: jdoerfert, mikerice, abhinavgaba.
Herald added subscribers: guansong, yaxunl.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

If the base is used in a map clause and later we have a memberexpr with
this base, and the member is a pointer, and this pointer is dereferenced
anyhow (subscript, array section, dereference, etc.), such components
should be considered as overlapped, otherwise it may lead to incorrect
size computations, since we try to map a pointee as a part of the whole
struct, which is not true for the pointer members.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105562

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_map_codegen_29.cpp

Index: clang/test/OpenMP/target_map_codegen_29.cpp
===
--- clang/test/OpenMP/target_map_codegen_29.cpp
+++ clang/test/OpenMP/target_map_codegen_29.cpp
@@ -38,9 +38,9 @@
 
 // CK30-LABEL: @.__omp_offloading_{{.*}}map_with_deep_copy{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0
 // The first element: 0x20 - OMP_MAP_TARGET_PARAM
-// 2-4: 0x10003 - OMP_MAP_MEMBER_OF(0) | OMP_MAP_TO | OMP_MAP_FROM - copies all the data in structs excluding deep-copied elements (from &s to &s.ptrBase1, from &s.ptr to &s.ptr1, from &s.ptr1 to end of s).
-// 5-6: 0x10013 - OMP_MAP_MEMBER_OF(0) | OMP_MAP_PTR_AND_OBJ | OMP_MAP_TO | OMP_MAP_FROM - deep copy of the pointers + pointee.
-// CK30: [[MTYPE00:@.+]] = private {{.*}}constant [6 x i64] [i64 32, i64 281474976710659, i64 281474976710659, i64 281474976710659, i64 281474976710675, i64 281474976710675]
+// 2: 0x10003 - OMP_MAP_MEMBER_OF(0) | OMP_MAP_TO | OMP_MAP_FROM - copies all the data in structs excluding deep-copied elements (from &s to end of s).
+// 3-4: 0x10013 - OMP_MAP_MEMBER_OF(0) | OMP_MAP_PTR_AND_OBJ | OMP_MAP_TO | OMP_MAP_FROM - deep copy of the pointers + pointee.
+// CK30: [[MTYPE00:@.+]] = private {{.*}}constant [4 x i64] [i64 32, i64 281474976710659, i64 281474976710675, i64 281474976710675]
 
 typedef struct {
   int *ptrBase;
@@ -55,18 +55,18 @@
   int *ptr1;
 } StructWithPtr;
 
-// CK30-DAG: call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}}, i64 -1, i8* @.__omp_offloading_{{.*}}map_with_deep_copy{{.*}}_l{{[0-9]+}}.region_id, i32 6, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], i64* [[GEPS:%.+]], i64* getelementptr inbounds ([6 x i64], [6 x i64]* [[MTYPE00]], i32 0, i32 0), i8** null, i8** null)
-// CK30-DAG: [[GEPS]] = getelementptr inbounds [6 x i{{64|32}}], [6 x i64]* [[SIZES:%.+]], i32 0, i32 0
-// CK30-DAG: [[GEPP]] = getelementptr inbounds [6 x i8*], [6 x i8*]* [[PTRS:%.+]], i32 0, i32 0
-// CK30-DAG: [[GEPBP]] = getelementptr inbounds [6 x i8*], [6 x i8*]* [[BASES:%.+]], i32 0, i32 0
+// CK30-DAG: call i32 @__tgt_target_mapper(%struct.ident_t* @{{.+}}, i64 -1, i8* @.__omp_offloading_{{.*}}map_with_deep_copy{{.*}}_l{{[0-9]+}}.region_id, i32 4, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], i64* [[GEPS:%.+]], i64* getelementptr inbounds ([4 x i64], [4 x i64]* [[MTYPE00]], i32 0, i32 0), i8** null, i8** null)
+// CK30-DAG: [[GEPS]] = getelementptr inbounds [4 x i{{64|32}}], [4 x i64]* [[SIZES:%.+]], i32 0, i32 0
+// CK30-DAG: [[GEPP]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[PTRS:%.+]], i32 0, i32 0
+// CK30-DAG: [[GEPBP]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[BASES:%.+]], i32 0, i32 0
 
-// CK30-DAG: [[BASE_PTR:%.+]] = getelementptr inbounds [6 x i8*], [6 x i8*]* [[BASES]], i32 0, i32 0
+// CK30-DAG: [[BASE_PTR:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[BASES]], i32 0, i32 0
 // CK30-DAG: [[BC:%.+]] = bitcast i8** [[BASE_PTR]] to [[STRUCT]]**
 // CK30-DAG: store [[STRUCT]]* [[S:%.+]], [[STRUCT]]** [[BC]],
-// CK30-DAG: [[PTR:%.+]] = getelementptr inbounds [6 x i8*], [6 x i8*]* [[PTRS]], i32 0, i32 0
+// CK30-DAG: [[PTR:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[PTRS]], i32 0, i32 0
 // CK30-DAG: [[BC:%.+]] = bitcast i8** [[PTR]] to [[STRUCT]]**
 // CK30-DAG: store [[STRUCT]]* [[S]], [[STRUCT]]** [[BC]],
-// CK30-DAG: [[SIZE:%.+]] = getelementptr inbounds [6 x i{{64|32}}], [6 x i64]* [[SIZES]], i32 0, i32 0
+// CK30-DAG: [[SIZE:%.+]] = getelementptr inbounds [4 x i{{64|32}}], [4 x i64]* [[SIZES]], i32 0, i32 0
 // CK30-DAG: store i64 [[S_ALLOC_SIZE:%.+]], i64* [[SIZE]],
 // CK30-DAG: [[S_ALLOC_SIZE]] = sdiv exact i64 [[DIFF:%.+]], ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64)
 // CK30-DAG: [[DIFF]] = sub i64 [[S_END_BC:%.+]], [[S_BEGIN_BC:%.+]]
@@ -76,78 +76,35 @@
 // CK30-DAG: [[S_END]] = bitcast [[STRUCT]]* [[REAL_S_END:%.+]] to i8*
 // CK30-DAG: [[REAL_S_END]] = getelementptr [[STRUCT]], [[STRUCT]]* [[S]], i32 1
 
-// CK30-DAG: [[BASE_PTR:%.+]] = getelementptr inbounds [6 x i8*], [6 x i8*]* [[BASES]], i32 0, i32 1
+// CK30-DAG: [[BASE_PTR:%.+]] = getelementptr inbounds [4 x i8*], [4 x i8*]* [[BASES]], i32

[clang] d2e32fa - [libTooling] Add support for implicit `this` to `buildAddressOf`.

2021-07-07 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2021-07-07T17:35:04Z
New Revision: d2e32fa493a272c21dee2c6cbf52e501f9ee3908

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

LOG: [libTooling] Add support for implicit `this` to `buildAddressOf`.

Changes `buildAddressOf` to return `this` when given an implicit `this` 
expression.

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

Added: 


Modified: 
clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
clang/unittests/Tooling/SourceCodeBuildersTest.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp 
b/clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
index 56ec45e8fd1dc..a1c99b60216b7 100644
--- a/clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
+++ b/clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
@@ -93,6 +93,8 @@ tooling::buildDereference(const Expr &E, const ASTContext 
&Context) {
 
 llvm::Optional tooling::buildAddressOf(const Expr &E,
 const ASTContext &Context) 
{
+  if (E.isImplicitCXXThis())
+return std::string("this");
   if (const auto *Op = dyn_cast(&E))
 if (Op->getOpcode() == UO_Deref) {
   // Strip leading '*'.

diff  --git a/clang/unittests/Tooling/SourceCodeBuildersTest.cpp 
b/clang/unittests/Tooling/SourceCodeBuildersTest.cpp
index b6f6aba63e2f1..ce99d1e7f5217 100644
--- a/clang/unittests/Tooling/SourceCodeBuildersTest.cpp
+++ b/clang/unittests/Tooling/SourceCodeBuildersTest.cpp
@@ -172,6 +172,24 @@ TEST(SourceCodeBuildersTest, 
BuildAddressOfBinaryOperation) {
   testBuilder(buildAddressOf, "S x; x + x;", "&(x + x)");
 }
 
+TEST(SourceCodeBuildersTest, BuildAddressOfImplicitThis) {
+  StringRef Snippet = R"cc(
+struct Struct {
+  void foo() {}
+  void bar() {
+foo();
+  }
+};
+  )cc";
+  auto StmtMatch = matchStmt(
+  Snippet,
+  cxxMemberCallExpr(onImplicitObjectArgument(cxxThisExpr().bind("expr";
+  ASSERT_TRUE(StmtMatch);
+  EXPECT_THAT(buildAddressOf(*StmtMatch->Result.Nodes.getNodeAs("expr"),
+ *StmtMatch->Result.Context),
+  ValueIs(std::string("this")));
+}
+
 TEST(SourceCodeBuildersTest, BuildDereferencePointer) {
   testBuilder(buildDereference, "S *x; x;", "*x");
 }



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


[PATCH] D105551: [libTooling] Add support for implicit `this` to `buildAddressOf`.

2021-07-07 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd2e32fa493a2: [libTooling] Add support for implicit `this` 
to `buildAddressOf`. (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105551

Files:
  clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
  clang/unittests/Tooling/SourceCodeBuildersTest.cpp


Index: clang/unittests/Tooling/SourceCodeBuildersTest.cpp
===
--- clang/unittests/Tooling/SourceCodeBuildersTest.cpp
+++ clang/unittests/Tooling/SourceCodeBuildersTest.cpp
@@ -172,6 +172,24 @@
   testBuilder(buildAddressOf, "S x; x + x;", "&(x + x)");
 }
 
+TEST(SourceCodeBuildersTest, BuildAddressOfImplicitThis) {
+  StringRef Snippet = R"cc(
+struct Struct {
+  void foo() {}
+  void bar() {
+foo();
+  }
+};
+  )cc";
+  auto StmtMatch = matchStmt(
+  Snippet,
+  cxxMemberCallExpr(onImplicitObjectArgument(cxxThisExpr().bind("expr";
+  ASSERT_TRUE(StmtMatch);
+  EXPECT_THAT(buildAddressOf(*StmtMatch->Result.Nodes.getNodeAs("expr"),
+ *StmtMatch->Result.Context),
+  ValueIs(std::string("this")));
+}
+
 TEST(SourceCodeBuildersTest, BuildDereferencePointer) {
   testBuilder(buildDereference, "S *x; x;", "*x");
 }
Index: clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
===
--- clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
+++ clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
@@ -93,6 +93,8 @@
 
 llvm::Optional tooling::buildAddressOf(const Expr &E,
 const ASTContext &Context) 
{
+  if (E.isImplicitCXXThis())
+return std::string("this");
   if (const auto *Op = dyn_cast(&E))
 if (Op->getOpcode() == UO_Deref) {
   // Strip leading '*'.


Index: clang/unittests/Tooling/SourceCodeBuildersTest.cpp
===
--- clang/unittests/Tooling/SourceCodeBuildersTest.cpp
+++ clang/unittests/Tooling/SourceCodeBuildersTest.cpp
@@ -172,6 +172,24 @@
   testBuilder(buildAddressOf, "S x; x + x;", "&(x + x)");
 }
 
+TEST(SourceCodeBuildersTest, BuildAddressOfImplicitThis) {
+  StringRef Snippet = R"cc(
+struct Struct {
+  void foo() {}
+  void bar() {
+foo();
+  }
+};
+  )cc";
+  auto StmtMatch = matchStmt(
+  Snippet,
+  cxxMemberCallExpr(onImplicitObjectArgument(cxxThisExpr().bind("expr";
+  ASSERT_TRUE(StmtMatch);
+  EXPECT_THAT(buildAddressOf(*StmtMatch->Result.Nodes.getNodeAs("expr"),
+ *StmtMatch->Result.Context),
+  ValueIs(std::string("this")));
+}
+
 TEST(SourceCodeBuildersTest, BuildDereferencePointer) {
   testBuilder(buildDereference, "S *x; x;", "*x");
 }
Index: clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
===
--- clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
+++ clang/lib/Tooling/Transformer/SourceCodeBuilders.cpp
@@ -93,6 +93,8 @@
 
 llvm::Optional tooling::buildAddressOf(const Expr &E,
 const ASTContext &Context) {
+  if (E.isImplicitCXXThis())
+return std::string("this");
   if (const auto *Op = dyn_cast(&E))
 if (Op->getOpcode() == UO_Deref) {
   // Strip leading '*'.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105451: [clang] Fix crash when there is an invalid declaration with flag -Wcast-align

2021-07-07 Thread Queen Dela Cruz via Phabricator via cfe-commits
qdelacru added a comment.

Please use Queen Dela Cruz, qdela...@cisco.com. Thanks!


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

https://reviews.llvm.org/D105451

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


[PATCH] D105564: Fix for DWARF parsing to better handle auto return type for member functions

2021-07-07 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik created this revision.
shafik added reviewers: aprantl, teemperor, labath.
Herald added a subscriber: arphaman.
shafik requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

Currently when we have a member function that has an auto return type and the 
definition is out of line we generate two DWARF DIE. 
One for the declaration and a second one for the definition, the definition 
holds the deduced type but does not contain a DW_AT_name nor
a DW_AT_linkage_name so there was not way to look up the definition DIE.

This fix modifies `CGDebugInfo::CreateCXXMemberFunction` so that it now only 
emits the linkage name for the definition of a method with a
deduced return type. It also modifies the `DWARFASTParserClang` to detect we 
have a function with deduced return type and lookup the 
defintion to obtain the correct return type and adjust the `FunctionDecl` to 
reflect this.

This required modifying the various indexes to support a lookup method for this 
case similar to `FindCompleteObjCDefinitionTypeForDIE`


https://reviews.llvm.org/D105564

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/test/Shell/SymbolFile/DWARF/x86/auto_return_appleDwarfIndex.s
  lldb/test/Shell/SymbolFile/DWARF/x86/auto_return_manualDwarfIndex.s

Index: lldb/test/Shell/SymbolFile/DWARF/x86/auto_return_manualDwarfIndex.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/auto_return_manualDwarfIndex.s
@@ -0,0 +1,255 @@
+# This tests that lldb when using ManualDWARFIndex is able to find the definition
+# for an auto return function.
+
+# RUN: llvm-mc -triple x86_64-gnu-linux %s -filetype=obj > %t.o
+# RUN: lldb-test symbols --dump-clang-ast %t.o | FileCheck %s
+
+# CHECK: CXXMethodDecl {{.*}} <>  f 'int ()'
+
+# This was compiled from the following code:
+#
+# struct A {
+# auto f();
+# };
+#
+# auto A::f() {
+# return 0;
+# }
+#
+# Compiled using:
+#
+#   -target x86_64-gnu-linux
+
+
+	.text
+	.globl	_ZN1A1fEv   # -- Begin function _ZN1A1fEv
+	.p2align	4, 0x90
+	.type	_ZN1A1fEv,@function
+_ZN1A1fEv:  # @_ZN1A1fEv
+.Lfunc_begin0:
+	.cfi_startproc
+# %bb.0:# %entry
+	pushq	%rbp
+	.cfi_def_cfa_offset 16
+	.cfi_offset %rbp, -16
+	movq	%rsp, %rbp
+	.cfi_def_cfa_register %rbp
+	movq	%rdi, -8(%rbp)
+.Ltmp0:
+	xorl	%eax, %eax
+	popq	%rbp
+	.cfi_def_cfa %rsp, 8
+	retq
+.Ltmp1:
+.Lfunc_end0:
+	.size	_ZN1A1fEv, .Lfunc_end0-_ZN1A1fEv
+	.cfi_endproc
+# -- End function
+	.section	.debug_abbrev,"",@progbits
+	.byte	1   # Abbreviation Code
+	.byte	17  # DW_TAG_compile_unit
+	.byte	1   # DW_CHILDREN_yes
+	.byte	37  # DW_AT_producer
+	.byte	14  # DW_FORM_strp
+	.byte	19  # DW_AT_language
+	.byte	5   # DW_FORM_data2
+	.byte	3   # DW_AT_name
+	.byte	14  # DW_FORM_strp
+	.byte	16  # DW_AT_stmt_list
+	.byte	23  # DW_FORM_sec_offset
+	.byte	27  # DW_AT_comp_dir
+	.byte	14  # DW_FORM_strp
+	.byte	17  # DW_AT_low_pc
+	.byte	1   # DW_FORM_addr
+	.byte	18  # DW_AT_high_pc
+	.byte	6   # DW_FORM_data4
+	.byte	0   # EOM(1)
+	.byte	0   # EOM(2)
+	.byte	2   # Abbreviation Code
+	.byte	19  # DW_TAG_structure_type
+	.byte	1   # DW_CHILDREN_yes
+	.byte	54  # DW_AT_calling_convention
+	.byte	11  # DW_FORM_data1
+	.byte	3   # DW_AT_name
+	.byte	14  # DW_FORM_strp
+	.byte	11  # DW_AT_byte_size
+	.byte	11  # DW_FORM_data1
+	.byte	58  # DW_AT_decl_file
+	.byte	11 

[PATCH] D105564: Fix for DWARF parsing to better handle auto return type for member functions

2021-07-07 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

I think it would be best to split out the Clang change into a separately tested 
patch.




Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1694
+  // If the declared return type is "auto" we want the linkage name to go
+  // with the defintion. In case the definiton is out of line, it needs to
+  // have a name so we can find it via DWARF index.

typo: definition (2x)




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

https://reviews.llvm.org/D105564

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


[PATCH] D105564: Fix for DWARF parsing to better handle auto return type for member functions

2021-07-07 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

I think it would be best to split out the Clang change into a separately tested 
patch.




Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2693
+if (!try_resolving_type)
+  return true;
+

This block looks like it's more complicated than it needs to be. Could you just 
say

```
if (other_die != die)
  if (other_die.Tag()) != DW_TAG_subprogram)
   return false;

```
or am I missing something?


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

https://reviews.llvm.org/D105564

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


[PATCH] D105564: Fix for DWARF parsing to better handle auto return type for member functions

2021-07-07 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2693
+if (!try_resolving_type)
+  return true;
+

aprantl wrote:
> This block looks like it's more complicated than it needs to be. Could you 
> just say
> 
> ```
> if (other_die != die)
>   if (other_die.Tag()) != DW_TAG_subprogram)
>return false;
> 
> ```
> or am I missing something?
Definitely missed something :-)

```
if (other_die == die || (other_die.Tag()) != DW_TAG_subprogram))
return false;
```


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

https://reviews.llvm.org/D105564

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


[PATCH] D105518: [clang] disable P2266 simpler implicit moves under -fms-compatibility

2021-07-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Ping? Normally I wouldn't bother people so quickly, but this patch is 
addressing a major regression on trunk that had a revert request. We either 
need to get this landed ASAP or revert the original commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105518

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


[clang] 3c5721d - Fix a failing assertion with -Wcast-align

2021-07-07 Thread Aaron Ballman via cfe-commits

Author: Queen Dela Cruz
Date: 2021-07-07T14:00:31-04:00
New Revision: 3c5721d77275d2a7bdaeeadd0b1c3864f1166110

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

LOG: Fix a failing assertion with -Wcast-align

When there is unknown type in a struct in code compiled with
-Wcast-align, the compiler crashes due to
clang::ASTContext::getASTRecordLayout() failing an assert.

Added check that the RecordDecl is valid before calling
getASTRecordLayout().

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/warn-cast-align.c

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 0c9d2010e3777..64d838d2cd74f 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -14477,7 +14477,8 @@ static getBaseAlignmentAndOffsetFromLValue(const Expr 
*E, ASTContext &Ctx) {
   case Stmt::MemberExprClass: {
 auto *ME = cast(E);
 auto *FD = dyn_cast(ME->getMemberDecl());
-if (!FD || FD->getType()->isReferenceType())
+if (!FD || FD->getType()->isReferenceType() ||
+FD->getParent()->isInvalidDecl())
   break;
 Optional> P;
 if (ME->isArrow())

diff  --git a/clang/test/Sema/warn-cast-align.c 
b/clang/test/Sema/warn-cast-align.c
index 389c0c17d2f7d..7df71997bf3e2 100644
--- a/clang/test/Sema/warn-cast-align.c
+++ b/clang/test/Sema/warn-cast-align.c
@@ -67,3 +67,11 @@ unsigned int func5(void);
 FnTy test5(void) {
   return (FnTy)&func5;
 }
+
+void test6() {
+  struct {
+int hello;
+doesnotexist world; // expected-error {{unknown type name 'doesnotexist'}}
+  } foo;
+  void **repro = (void **)&foo.hello; // expected-warning {{cast from 'int *' 
to 'void **' increases required alignment from 4 to 8}}
+}



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


[PATCH] D105451: [clang] Fix crash when there is an invalid declaration with flag -Wcast-align

2021-07-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thank you for the fix! I've applied in 3c5721d77275d2a7bdaeeadd0b1c3864f1166110 



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

https://reviews.llvm.org/D105451

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


[PATCH] D105447: [analyzer] Allow cmake options to be passed to satest container

2021-07-07 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko accepted this revision.
vsavchenko added a comment.
This revision is now accepted and ready to land.

Awesome, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105447

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


[PATCH] D105378: [dfsan][NFC] Add Origin Tracking into doc

2021-07-07 Thread stephan.yichao.zhao via Phabricator via cfe-commits
stephan.yichao.zhao updated this revision to Diff 357004.
stephan.yichao.zhao marked an inline comment as done.
stephan.yichao.zhao retitled this revision from " [dfsan][NFC] Add Origin 
Tracking into doc" to "[dfsan][NFC] Add Origin Tracking into doc".
stephan.yichao.zhao added a comment.

clang -> clange++


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105378

Files:
  clang/docs/DataFlowSanitizer.rst


Index: clang/docs/DataFlowSanitizer.rst
===
--- clang/docs/DataFlowSanitizer.rst
+++ clang/docs/DataFlowSanitizer.rst
@@ -191,6 +191,44 @@
 return 0;
   }
 
+Origin Tracking
+===
+
+DataFlowSanitizer can track origins of labeled values. This feature is enabled 
by
+``-mllvm -dfsan-track-origins=1``. For example,
+
+.. code-block:: console
+
+% cat test.cc
+#include 
+#include 
+
+int main(int argc, char** argv) {
+  int i = 0;
+  dfsan_set_label(i_label, &i, sizeof(i));
+  int j = i + 1;
+  dfsan_print_origin_trace(&j, "A flow from i to j");
+  return 0;
+}
+
+% clang++ -fsanitize=dataflow -mllvm -dfsan-track-origins=1 
-fno-omit-frame-pointer -g -O2 test.cc
+% ./a.out
+Taint value 0x1 (at 0x7ffd42bf415c) origin tracking (A flow from i to j)
+Origin value: 0x1391, Taint value was stored to memory at
+  #0 0x55676db85a62 in main test.cc:7:7
+  #1 0x7f0083611bbc in __libc_start_main libc-start.c:285
+
+Origin value: 0x9e1, Taint value was created at
+  #0 0x55676db85a08 in main test.cc:6:3
+  #1 0x7f0083611bbc in __libc_start_main libc-start.c:285
+
+By ``-mllvm -dfsan-track-origins=1`` DataFlowSanitizer collects only
+intermediate stores a labeled value went through. Origin tracking slows down
+program execution by a factor of 2x on top of the usual DataFlowSanitizer
+slowdown and increases memory overhead by 1x. By ``-mllvm 
-dfsan-track-origins=2``
+DataFlowSanitizer also collects intermediate loads a labeled value went 
through.
+This mode slows down program execution by a factor of 4x.
+
 Current status
 ==
 


Index: clang/docs/DataFlowSanitizer.rst
===
--- clang/docs/DataFlowSanitizer.rst
+++ clang/docs/DataFlowSanitizer.rst
@@ -191,6 +191,44 @@
 return 0;
   }
 
+Origin Tracking
+===
+
+DataFlowSanitizer can track origins of labeled values. This feature is enabled by
+``-mllvm -dfsan-track-origins=1``. For example,
+
+.. code-block:: console
+
+% cat test.cc
+#include 
+#include 
+
+int main(int argc, char** argv) {
+  int i = 0;
+  dfsan_set_label(i_label, &i, sizeof(i));
+  int j = i + 1;
+  dfsan_print_origin_trace(&j, "A flow from i to j");
+  return 0;
+}
+
+% clang++ -fsanitize=dataflow -mllvm -dfsan-track-origins=1 -fno-omit-frame-pointer -g -O2 test.cc
+% ./a.out
+Taint value 0x1 (at 0x7ffd42bf415c) origin tracking (A flow from i to j)
+Origin value: 0x1391, Taint value was stored to memory at
+  #0 0x55676db85a62 in main test.cc:7:7
+  #1 0x7f0083611bbc in __libc_start_main libc-start.c:285
+
+Origin value: 0x9e1, Taint value was created at
+  #0 0x55676db85a08 in main test.cc:6:3
+  #1 0x7f0083611bbc in __libc_start_main libc-start.c:285
+
+By ``-mllvm -dfsan-track-origins=1`` DataFlowSanitizer collects only
+intermediate stores a labeled value went through. Origin tracking slows down
+program execution by a factor of 2x on top of the usual DataFlowSanitizer
+slowdown and increases memory overhead by 1x. By ``-mllvm -dfsan-track-origins=2``
+DataFlowSanitizer also collects intermediate loads a labeled value went through.
+This mode slows down program execution by a factor of 4x.
+
 Current status
 ==
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 71dc0f1 - [dfsan][NFC] Add Origin Tracking into doc

2021-07-07 Thread Jianzhou Zhao via cfe-commits

Author: Jianzhou Zhao
Date: 2021-07-07T18:13:26Z
New Revision: 71dc0f1c02cd00a431fc327b0ea86524fad28afe

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

LOG: [dfsan][NFC] Add Origin Tracking into doc

Reviewed By: morehouse

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

Added: 


Modified: 
clang/docs/DataFlowSanitizer.rst

Removed: 




diff  --git a/clang/docs/DataFlowSanitizer.rst 
b/clang/docs/DataFlowSanitizer.rst
index 8bbc2534ad4db..143b6e3d3242e 100644
--- a/clang/docs/DataFlowSanitizer.rst
+++ b/clang/docs/DataFlowSanitizer.rst
@@ -191,6 +191,44 @@ the correct labels are propagated.
 return 0;
   }
 
+Origin Tracking
+===
+
+DataFlowSanitizer can track origins of labeled values. This feature is enabled 
by
+``-mllvm -dfsan-track-origins=1``. For example,
+
+.. code-block:: console
+
+% cat test.cc
+#include 
+#include 
+
+int main(int argc, char** argv) {
+  int i = 0;
+  dfsan_set_label(i_label, &i, sizeof(i));
+  int j = i + 1;
+  dfsan_print_origin_trace(&j, "A flow from i to j");
+  return 0;
+}
+
+% clang++ -fsanitize=dataflow -mllvm -dfsan-track-origins=1 
-fno-omit-frame-pointer -g -O2 test.cc
+% ./a.out
+Taint value 0x1 (at 0x7ffd42bf415c) origin tracking (A flow from i to j)
+Origin value: 0x1391, Taint value was stored to memory at
+  #0 0x55676db85a62 in main test.cc:7:7
+  #1 0x7f0083611bbc in __libc_start_main libc-start.c:285
+
+Origin value: 0x9e1, Taint value was created at
+  #0 0x55676db85a08 in main test.cc:6:3
+  #1 0x7f0083611bbc in __libc_start_main libc-start.c:285
+
+By ``-mllvm -dfsan-track-origins=1`` DataFlowSanitizer collects only
+intermediate stores a labeled value went through. Origin tracking slows down
+program execution by a factor of 2x on top of the usual DataFlowSanitizer
+slowdown and increases memory overhead by 1x. By ``-mllvm 
-dfsan-track-origins=2``
+DataFlowSanitizer also collects intermediate loads a labeled value went 
through.
+This mode slows down program execution by a factor of 4x.
+
 Current status
 ==
 



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


[PATCH] D105378: [dfsan][NFC] Add Origin Tracking into doc

2021-07-07 Thread 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 rG71dc0f1c02cd: [dfsan][NFC] Add Origin Tracking into doc 
(authored by Jianzhou Zhao ).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105378

Files:
  clang/docs/DataFlowSanitizer.rst


Index: clang/docs/DataFlowSanitizer.rst
===
--- clang/docs/DataFlowSanitizer.rst
+++ clang/docs/DataFlowSanitizer.rst
@@ -191,6 +191,44 @@
 return 0;
   }
 
+Origin Tracking
+===
+
+DataFlowSanitizer can track origins of labeled values. This feature is enabled 
by
+``-mllvm -dfsan-track-origins=1``. For example,
+
+.. code-block:: console
+
+% cat test.cc
+#include 
+#include 
+
+int main(int argc, char** argv) {
+  int i = 0;
+  dfsan_set_label(i_label, &i, sizeof(i));
+  int j = i + 1;
+  dfsan_print_origin_trace(&j, "A flow from i to j");
+  return 0;
+}
+
+% clang++ -fsanitize=dataflow -mllvm -dfsan-track-origins=1 
-fno-omit-frame-pointer -g -O2 test.cc
+% ./a.out
+Taint value 0x1 (at 0x7ffd42bf415c) origin tracking (A flow from i to j)
+Origin value: 0x1391, Taint value was stored to memory at
+  #0 0x55676db85a62 in main test.cc:7:7
+  #1 0x7f0083611bbc in __libc_start_main libc-start.c:285
+
+Origin value: 0x9e1, Taint value was created at
+  #0 0x55676db85a08 in main test.cc:6:3
+  #1 0x7f0083611bbc in __libc_start_main libc-start.c:285
+
+By ``-mllvm -dfsan-track-origins=1`` DataFlowSanitizer collects only
+intermediate stores a labeled value went through. Origin tracking slows down
+program execution by a factor of 2x on top of the usual DataFlowSanitizer
+slowdown and increases memory overhead by 1x. By ``-mllvm 
-dfsan-track-origins=2``
+DataFlowSanitizer also collects intermediate loads a labeled value went 
through.
+This mode slows down program execution by a factor of 4x.
+
 Current status
 ==
 


Index: clang/docs/DataFlowSanitizer.rst
===
--- clang/docs/DataFlowSanitizer.rst
+++ clang/docs/DataFlowSanitizer.rst
@@ -191,6 +191,44 @@
 return 0;
   }
 
+Origin Tracking
+===
+
+DataFlowSanitizer can track origins of labeled values. This feature is enabled by
+``-mllvm -dfsan-track-origins=1``. For example,
+
+.. code-block:: console
+
+% cat test.cc
+#include 
+#include 
+
+int main(int argc, char** argv) {
+  int i = 0;
+  dfsan_set_label(i_label, &i, sizeof(i));
+  int j = i + 1;
+  dfsan_print_origin_trace(&j, "A flow from i to j");
+  return 0;
+}
+
+% clang++ -fsanitize=dataflow -mllvm -dfsan-track-origins=1 -fno-omit-frame-pointer -g -O2 test.cc
+% ./a.out
+Taint value 0x1 (at 0x7ffd42bf415c) origin tracking (A flow from i to j)
+Origin value: 0x1391, Taint value was stored to memory at
+  #0 0x55676db85a62 in main test.cc:7:7
+  #1 0x7f0083611bbc in __libc_start_main libc-start.c:285
+
+Origin value: 0x9e1, Taint value was created at
+  #0 0x55676db85a08 in main test.cc:6:3
+  #1 0x7f0083611bbc in __libc_start_main libc-start.c:285
+
+By ``-mllvm -dfsan-track-origins=1`` DataFlowSanitizer collects only
+intermediate stores a labeled value went through. Origin tracking slows down
+program execution by a factor of 2x on top of the usual DataFlowSanitizer
+slowdown and increases memory overhead by 1x. By ``-mllvm -dfsan-track-origins=2``
+DataFlowSanitizer also collects intermediate loads a labeled value went through.
+This mode slows down program execution by a factor of 4x.
+
 Current status
 ==
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105564: Fix for DWARF parsing to better handle auto return type for member functions

2021-07-07 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Could LLDB find the linkage name on the declaration, look that name up in the 
symbol table, and find the DW_TAG_subprogram DIE for the symbol's start address?


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

https://reviews.llvm.org/D105564

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


[PATCH] D105378: [dfsan][NFC] Add Origin Tracking into doc

2021-07-07 Thread stephan.yichao.zhao via Phabricator via cfe-commits
stephan.yichao.zhao added a comment.

In D105378#2861914 , @morehouse wrote:

> We may also want to consider creating a frontend flag like MSan's origin 
> tracking (`-fsanitize-memory-track-origins`).

I will follow up this in a separate change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105378

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


[PATCH] D97915: [Coroutines] Handle overaligned frame allocation

2021-07-07 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D97915#2861178 , @ChuanqiXu wrote:

> In D97915#2861036 , @ychen wrote:
>
>> In D97915#2860984 , @ChuanqiXu 
>> wrote:
>>
>>> In D97915#2860916 , @ychen wrote:
>>>
 In D97915#2859237 , @ChuanqiXu 
 wrote:

> In D97915#2848816 , @ychen wrote:
>
>>> Thanks for clarifying. Let's solve the semantics problem first.
>>> With the introduction about 'raw frame', I think it's necessary to 
>>> introduce this concept in the section 'Switched-Resume Lowering' or 
>>> even the section 'Introduction' in the document. Add a section to tell 
>>> the terminology is satisfied too.
>>
>> Done.
>>
>>> Then why we defined both 'llvm.coro.raw.frame.ptr.offset' and 
>>> 'llvm.coro.raw.frame.ptr.addr' together? It looks like refer to the 
>>> same value finally. It looks like 'llvm.coro.raw.frame.ptr.offset' are 
>>> trying to solve the problem about memory leak. But I think we could use 
>>> llvm.coro.raw.frame.ptr.addr directly instead of traversing the frame 
>>> (Maybe we need to add an intrinsic `llvm.coro.raw.size`).  Then we can 
>>> omit a field in the frame to save space.
>>
>> ("llvm.coro.raw.frame.ptr.offset" is an offset from coroutine frame 
>> address instead of raw frame pointer)
>>
>> Apologies for the confusion. I've briefly explained it here 
>> https://reviews.llvm.org/D102145#2752445 I think it is not clear. 
>> "llvm.coro.raw.frame.ptr.addr" is conceptually "the address of a 
>> coroutine frame field storing the `raw frame pointer`" only after 
>> `insertSpills` in CoroFrame.cpp. Before that, 
>> "llvm.coro.raw.frame.ptr.addr" is actually an alloca storing the `raw 
>> frame pointer` (try grepping "alloc.frame.ptr" in this review page). 
>> Using  "llvm.coro.raw.frame.ptr.offset" instead of  
>> "llvm.coro.raw.frame.ptr.addr" is doable which looks like below, please 
>> check line 31. The downside is that the write to coroutine frame is not 
>> through an alloca but a direct write. It is unusual because all fields 
>> in the frame are stored as 1. special/header fields 2. alloca 3. 
>> splills. Doing the write indirectly as Alloca makes me comfortable. The 
>> tradeoff is one extra intrinsic "llvm.coro.raw.frame.ptr.addr". What do 
>> you think?
>>
>>   19 coro.alloc.align: ; preds = 
>> %coro.alloc.check.align
>>   20   %3 = sub nsw i64 64, 16
>>   21   %4 = add i64 128, %3
>>   22   %call1 = call noalias nonnull i8* @_Znwm(i64 %4) #13
>>   23   %mask = sub i64 64, 1
>>   24   %intptr = ptrtoint i8* %call1 to i64
>>   25   %over_boundary = add i64 %intptr, %mask
>>   26   %inverted_mask = xor i64 %mask, -1
>>   27   %aligned_intptr = and i64 %over_boundary, %inverted_mask
>>   28   %diff = sub i64 %aligned_intptr, %intptr
>>   29   %aligned_result = getelementptr inbounds i8, i8* %call1, i64 %diff
>>   30   call void @llvm.assume(i1 true) [ "align"(i8* %aligned_result, 
>> i64 64) ]
>>   31   store i8* %call1, i8** %alloc.frame.ptr, align 8  
>>
>>   
>>; Replace line 31 with below, and must makes sure line 46~line 48 
>> is skipped.
>>; %poff = call i32 @llvm.coro.raw.frame.ptr.offset.i32()
>>; %addr = getelementptr inbounds i8, i8* %aligned_result, i32 
>> %poff
>>; %addr1 = bitcast i8* %addr to i8**
>>; store i8* %call1, i8** %addr1, align 8
>>   
>>   
>>   32   br label %coro.init.from.coro.alloc.align
>>   33
>>   34 coro.init.from.coro.alloc.align:  ; preds = 
>> %coro.alloc.align
>>   35   %aligned_result.coro.init = phi i8* [ %aligned_result, 
>> %coro.alloc.align ]
>>   36   br label %coro.init
>>   37
>>   38 coro.init:; preds = 
>> %coro.init.from.entry, %coro.init.from.coro.alloc.align, %cor
>>  o.init.from.coro.alloc
>>   39   %5 = phi i8* [ %.coro.init, %coro.init.from.entry ], [ 
>> %call.coro.init, %coro.init.from.coro.alloc ], [ %aligned_result
>>  .coro.init, %coro.init.from.coro.alloc.align ]
>>   40   %FramePtr = bitcast i8* %5 to %f0.Frame*
>>   41   %resume.addr = getelementptr inbounds %f0.Frame, %f0.Frame* 
>> %FramePtr, i32 0, i32 0
>>   42   store void (%f0.Frame*)* @f0.resume, void (%f0.Frame*)** 
>> %resume.addr, align 8
>>   43   %6 = select i1 true, void (%f0.Frame*)* @f0.destroy, void 
>> (%f0.Frame*)* @f0.cleanup
>>   44   %destroy.addr = getelementptr inbounds %f0.Frame, %f0.Frame* 
>> %FramePtr, i32 0, 

[PATCH] D105518: [clang] disable P2266 simpler implicit moves under -fms-compatibility

2021-07-07 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

@aaron.ballman Yeah don't worry, having dinner, my hobby shift is starting soon 
though :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105518

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


[PATCH] D103668: [PowerPC] Implement trap and conversion builtins for XL compatibility

2021-07-07 Thread Victor Huang via Phabricator via cfe-commits
NeHuang resigned from this revision.
NeHuang added inline comments.



Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-conversionfunc.c:2
+// RUN: %clang_cc1 -O2 -triple powerpc64-unknown-unknown \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr8 | FileCheck %s
+// RUN: %clang_cc1 -O2 -triple powerpc64le-unknown-unknown \

Please use `pwr7` for BE test and `pwr8` for LE test.



Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-trap-64bit-only.c:8
+// RUN: not %clang_cc1 -O2 -triple powerpc-unknown-aix \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr8 2>&1 | \
+// RUN:  FileCheck %s -check-prefixes=CHECK32-ERROR

pwr8 -> pwr7



Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-trap-64bit-only.c:11
+// RUN: %clang_cc1 -O2 -triple powerpc64-unknown-aix \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr8 | \
+// RUN:  FileCheck %s --check-prefixes=CHECK64

pwr8 -> pwr7



Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-trap.c:8
+// RUN: %clang_cc1 -O2 -triple powerpc-unknown-aix \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr8 | \
+// RUN:  FileCheck %s

same as above



Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-trap.c:11
+// RUN: %clang_cc1 -O2 -triple powerpc64-unknown-aix \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr8 | \
+// RUN:  FileCheck %s

same as above.



Comment at: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-conversionfunc.ll:7
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \

same target cpu issue for the aix run lines in back end test cases.



Comment at: 
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap-64bit-only.ll:28
+}
+
+define dso_local void @test__tdweq(i64 %a, i64 %b) {

can you add another test case for `call void @llvm.ppc.tdw(i64 %a, i64 %b, i32 
3)` to verify the backend change below:
```
// tdne
def : Pat<(int_ppc_tdw g8rc:$A, g8rc:$B, 3),
  (TD 24, $A, $B)>;
```



Comment at: 
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap-64bit-only.ll:41
+; CHECK:   # %bb.0:
+; CHECK-NEXT:td 5, 3, 4
+; CHECK-NEXT:blr

seems the InstAlias defined for `td` and `tw` not working as expected 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103668

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


[PATCH] D105142: RFC: Implementing new mechanism for hard register operands to inline asm as a constraint.

2021-07-07 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

This code doesn't handle multiple alternatives in a constraint.

E.g. `"={eax}{ebx}"` or `"={eax}{ebx},m"`.

See the GCC docs for the C-level syntax
https://gcc.gnu.org/onlinedocs/gcc/Multi-Alternative.html#Multi-Alternative
and LLVM IR docs for the IR syntax:
https://llvm.org/docs/LangRef.html#constraint-codes

LLVM doesn't handle alternatives very well in the backend, but Clang at least 
should parse and properly generate LLVM asm strings for these cases I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105142

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


[PATCH] D105421: [analyzer] Handle << operator for std::unique_ptr

2021-07-07 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 357031.
RedDocMD added a comment.

Invalidating regions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105421

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp

Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -81,6 +81,20 @@
 
 REGISTER_MAP_WITH_PROGRAMSTATE(TrackedRegionMap, const MemRegion *, SVal)
 
+// Checks if RD has name in Names and is in std namespace
+bool hasStdClassWithName(const CXXRecordDecl *RD,
+ const SmallVectorImpl &Names) {
+  if (!RD || !RD->getDeclContext()->isStdNamespace())
+return false;
+  if (RD->getDeclName().isIdentifier()) {
+StringRef Name = RD->getName();
+return llvm::any_of(Names, [&Name](StringRef GivenName) -> bool {
+  return Name == GivenName;
+});
+  }
+  return false;
+}
+
 // Define the inter-checker API.
 namespace clang {
 namespace ento {
@@ -89,16 +103,16 @@
   const auto *MethodDecl = dyn_cast_or_null(Call.getDecl());
   if (!MethodDecl || !MethodDecl->getParent())
 return false;
+  return isStdSmartPtr(MethodDecl->getParent());
+}
 
-  const auto *RecordDecl = MethodDecl->getParent();
-  if (!RecordDecl || !RecordDecl->getDeclContext()->isStdNamespace())
-return false;
+bool isStdSmartPtr(const CXXRecordDecl *RD) {
+  return hasStdClassWithName(
+  RD, SmallVector{"shared_ptr", "unique_ptr", "weak_ptr"});
+}
 
-  if (RecordDecl->getDeclName().isIdentifier()) {
-StringRef Name = RecordDecl->getName();
-return Name == "shared_ptr" || Name == "unique_ptr" || Name == "weak_ptr";
-  }
-  return false;
+bool isStdSmartPtr(const Expr *E) {
+  return isStdSmartPtr(E->getType()->getAsCXXRecordDecl());
 }
 
 bool isNullSmartPtr(const ProgramStateRef State, const MemRegion *ThisRegion) {
@@ -175,9 +189,46 @@
   return CD && CD->getConversionType()->isBooleanType();
 }
 
+bool isStdBasicOstream(const Expr *E) {
+  const auto *RD = E->getType()->getAsCXXRecordDecl();
+  return hasStdClassWithName(RD, SmallVector{"basic_ostream"});
+}
+
+bool isStdOstreamOperatorCall(const CallEvent &Call) {
+  if (Call.getNumArgs() != 2 ||
+  !Call.getDecl()->getDeclContext()->isStdNamespace())
+return false;
+  const auto *FC = dyn_cast(&Call);
+  if (!FC)
+return false;
+  const FunctionDecl *FD = FC->getDecl();
+  if (!FD->isOverloadedOperator())
+return false;
+  const OverloadedOperatorKind OOK = FD->getOverloadedOperator();
+  if (OOK != clang::OO_LessLess)
+return false;
+  return smartptr::isStdSmartPtr(Call.getArgExpr(1)) &&
+ isStdBasicOstream(Call.getArgExpr(0));
+}
+
 bool SmartPtrModeling::evalCall(const CallEvent &Call,
 CheckerContext &C) const {
   ProgramStateRef State = C.getState();
+
+  if (isStdOstreamOperatorCall(Call)) {
+const auto StreamVal = Call.getArgSVal(0);
+const MemRegion *StreamThisRegion = StreamVal.getAsRegion();
+assert(StreamThisRegion &&
+   "expected to retrieve this pointer of basic_ostream");
+State =
+State->invalidateRegions({StreamThisRegion}, Call.getOriginExpr(),
+ C.blockCount(), C.getLocationContext(), false);
+State = State->BindExpr(Call.getOriginExpr(), C.getLocationContext(),
+StreamVal);
+C.addTransition(State);
+return true;
+  }
+
   if (!smartptr::isStdSmartPtrCall(Call))
 return false;
 
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
@@ -22,6 +22,8 @@
 
 /// Returns true if the event call is on smart pointer.
 bool isStdSmartPtrCall(const CallEvent &Call);
+bool isStdSmartPtr(const CXXRecordDecl *RD);
+bool isStdSmartPtr(const Expr *E);
 
 /// Returns whether the smart pointer is null or not.
 bool isNullSmartPtr(const ProgramStateRef State, const MemRegion *ThisRegion);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105421: [analyzer] Handle << operator for std::unique_ptr

2021-07-07 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:218-219
+
+  if (isStdOstreamOperatorCall(Call))
+return true;
+

NoQ wrote:
> When you're doing `evalCall` you're responsible for modeling *all* aspects of 
> the call. One does not simply say that they modeled all aspects of the call 
> when they didn't even set the return value :)
> 
> Similarly to how `make_unique` delegates work to the constructor of the 
> managed object and `~unique_ptr` delegates work to the destructor of the 
> managed object, I suspect this code could delegate work to 
> `basic_ostream::operator<<(T *)`. We don't yet have any facilities to 
> implement such logic yet (i.e., entering function call from a checker 
> callback).
> 
> Given that we don't do much modeling of `basic_ostream` yet, I think it's 
> perfectly fine to invalidate the stream entirely (which would be as precise 
> as whatever the default evaluation gave us) (see 
> `ProgramState::invalidateRegions`) and return the reference to the stream 
> (which is already better than what the default evaluation gave us); 
> additionally, we get extra precision because we don't invalidate the rest of 
> the heap. That's the bare minimum of what we have to do here if we are to do 
> anything at all.
> 
> This also gives some ideas of how to write tests for this patch.
> 
> That said, I suspect that this patch is not critical to enabling the checker 
> by default, because we probably already know that this method doesn't change 
> the inner pointer value (simply through not doing anything special) (and 
> accepting the smart pointer by `const` reference, so even if we implement 
> invalidation it will probably still "just work") (?).
Does this work?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105421

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


[PATCH] D95588: [RISCV] Implement the MC layer support of P extension

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



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoP.td:599
+   Sched<[]>;
+def SMBB32   : RVPBinary<0b100, 0b010, "smbb32">,
+   Sched<[]>;

It looks like the 0.9.3 spec lists this as an alias of MULSR64 and does not 
give it an encoding.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoP.td:737
+   Sched<[]>;
+def KMADA32  : RVPTernary<0b0100100, 0b010, "kmada32">,
+   Sched<[]>;

0.9.3 spec has this as an alias of KMAR64



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoP.td:835
+Predicates = [HasStdExtZpn] in
+def INSB : RVInstR<0b1010110, 0b000, OPC_OP_P, (outs GPR:$rd),
+   (ins GPR:$rs2, GPR:$rs1, uimmlog2xlenbytes:$shamt),

I believe way this has been done on other extensions is to have `(outs 
GPR:$rd_wb), (ins GPR:$rd, GPR:$rs1, uimmlog2xlenbytes:$shamt)` and `let 
Constraints = "$rd = $rd_wb"`

And I don't think it should inherit from RVInstR since it doesn't have a real 
rs2.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95588

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


[PATCH] D103668: [PowerPC] Implement trap and conversion builtins for XL compatibility

2021-07-07 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added inline comments.



Comment at: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll:135
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twnei 3, 0
+; CHECK-NEXT:blr

Where are the aliases `twnei` and `tdnei` coming from? You don't seem to add 
them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103668

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


[PATCH] D105421: [analyzer] Handle << operator for std::unique_ptr

2021-07-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Yes, I think this totally works now!

Can you also add some tests?




Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:85
+// Checks if RD has name in Names and is in std namespace
+bool hasStdClassWithName(const CXXRecordDecl *RD,
+ const SmallVectorImpl &Names) {

This should be `static` right?



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:98
+
 // Define the inter-checker API.
 namespace clang {

I think the new functions that you've added aren't yet used in an inter-checker 
manner. Maybe keep them as `static` too until we have an actual use case?



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:221-222
+const MemRegion *StreamThisRegion = StreamVal.getAsRegion();
+assert(StreamThisRegion &&
+   "expected to retrieve this pointer of basic_ostream");
+State =

Might also be an `UnknownVal` which doesn't have a region. It's hard to test 
because there doesn't exist a test in which `UnknownVal` appears for a good 
reason (they only appear for bad reasons) but I'd still rather bail out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105421

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


[PATCH] D103668: [PowerPC] Implement trap and conversion builtins for XL compatibility

2021-07-07 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 357052.
Conanap marked 6 inline comments as done.
Conanap added a comment.

Rebased and changed aix test cases to pwr 7


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103668

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-conversionfunc.c
  clang/test/CodeGen/builtins-ppc-xlcompat-error.c
  clang/test/CodeGen/builtins-ppc-xlcompat-trap-64bit-only.c
  clang/test/CodeGen/builtins-ppc-xlcompat-trap.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstr64Bit.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-conversionfunc.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap-64bit-only.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll
@@ -0,0 +1,139 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr7 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+
+; tw
+declare void @llvm.ppc.tw(i32 %a, i32 %b, i32 %c)
+define dso_local void @test__twlgt(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twlgt:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twlgt 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 1)
+  ret void
+}
+
+define dso_local void @test__twllt(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twllt:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twllt 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 2)
+  ret void
+}
+
+define dso_local void @test__twne3(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twne3:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twne 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 3)
+  ret void
+}
+
+define dso_local void @test__tweq(i32 %a, i32 %b) {
+; CHECK-LABEL: test__tweq:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tweq 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 4)
+  ret void
+}
+
+define dso_local void @test__twlge(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twlge:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 5, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 5)
+  ret void
+}
+
+define dso_local void @test__twlle(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twlle:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 6, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 6)
+  ret void
+}
+
+define dso_local void @test__twgt(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twgt:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twgt 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 8)
+  ret void
+}
+
+define dso_local void @test__twge(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twge:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 12, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 12)
+  ret void
+}
+
+define dso_local void @test__twlt(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twlt:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twlt 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 16)
+  ret void
+}
+
+define dso_local void @test__twle(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twle:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 20, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 20)
+  ret void
+}
+
+define dso_local void @test__twne24(i32 %a, i32 %b) {
+; CHECK-LABEL: test__twne24:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twne 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 24)
+  ret void
+}
+
+define dso_local void @test__tweq31(i32 %a, i32 %b) {
+; CHECK-LABEL: test__tweq31:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tweq 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 31)
+  ret void
+}
+
+define dso_local void @test__tw_no_match(i32 %a, i32 %b) {
+; CHECK-LABEL: test__tw_no_match:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tw 13, 3, 4
+; CHECK-NEXT:blr
+  call void @llvm.ppc.tw(i32 %a, i32 %b, i32 13)
+  ret void
+}
+
+; trap
+declare void @llvm.ppc.trap(i32 %a)
+define dso_local void @test__trap(i32 %a) {
+; CHECK-LABEL: test__trap:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twnei 3, 0
+; CHECK-NEXT:blr
+  call void @llvm.ppc.trap(i32 %a)
+  ret void
+}
Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlc

[PATCH] D105479: [clang-tidy] [PR50069] readability-braces-around-statements doesn't work well with [[likely]] [[unlikely]]

2021-07-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for working on this!




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp:7-14
+  if (b) [[likely]] {
+// CHECK-FIXES-NOT: if (b) { {{[[][[]}}likely{{[]][]]}} {
+return;
+  }
+  if (b) [[unlikely]] {
+// CHECK-FIXES-NOT: if (b) { {{[[][[]}}unlikely{{[]][]]}} {
+return;

Can you also add tests that show we do the correct thing for:
```
if (b) [[likely]]
  return;
if (b) [[unlikely]]
  return;
```
where there were no braces involved? We should ensure that it wants to insert 
the braces after the attribute.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105479

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


[PATCH] D105135: [Internalize] Preserve variables externally initialized.

2021-07-07 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 357053.
hliao added a comment.

Revert part of tests back and convert them into positive ones.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105135

Files:
  clang/test/CodeGenCUDA/host-used-device-var.cu
  clang/test/CodeGenCUDA/unused-global-var.cu
  llvm/lib/Transforms/IPO/Internalize.cpp
  llvm/test/Transforms/Internalize/externally-initialized.ll


Index: llvm/test/Transforms/Internalize/externally-initialized.ll
===
--- /dev/null
+++ llvm/test/Transforms/Internalize/externally-initialized.ll
@@ -0,0 +1,7 @@
+; RUN: opt < %s -internalize -S | FileCheck %s
+; RUN: opt < %s -passes=internalize -S | FileCheck %s
+
+; CHECK: @G0
+; CHECK-NOT: internal
+; CHECK-SAME: global i32
+@G0 = protected externally_initialized global i32 0, align 4
Index: llvm/lib/Transforms/IPO/Internalize.cpp
===
--- llvm/lib/Transforms/IPO/Internalize.cpp
+++ llvm/lib/Transforms/IPO/Internalize.cpp
@@ -101,6 +101,12 @@
   if (GV.hasDLLExportStorageClass())
 return true;
 
+  // As the name suggests, externally initialized variables need preserving as
+  // they would be initialized elsewhere externally.
+  if (const auto *G = dyn_cast(&GV))
+if (G->isExternallyInitialized())
+  return true;
+
   // Already local, has nothing to do.
   if (GV.hasLocalLinkage())
 return false;
Index: clang/test/CodeGenCUDA/unused-global-var.cu
===
--- clang/test/CodeGenCUDA/unused-global-var.cu
+++ clang/test/CodeGenCUDA/unused-global-var.cu
@@ -15,14 +15,14 @@
 // DCE before internalization. This test makes sure unused global variables
 // are eliminated.
 
-// Check unused device/constant variables are eliminated.
-
-// NEGCHK-NOT: @v1
+// CHECK-DAG: @v1
 __device__ int v1;
 
-// NEGCHK-NOT: @v2
+// CHECK-DAG: @v2
 __constant__ int v2;
 
+// Check unused device/constant variables are eliminated.
+
 // NEGCHK-NOT: @_ZL2v3
 constexpr int v3 = 1;
 
Index: clang/test/CodeGenCUDA/host-used-device-var.cu
===
--- clang/test/CodeGenCUDA/host-used-device-var.cu
+++ clang/test/CodeGenCUDA/host-used-device-var.cu
@@ -15,14 +15,14 @@
 
 #include "Inputs/cuda.h"
 
-// Check device variables used by neither host nor device functioins are not 
kept.
-
-// DEV-NEG-NOT: @v1
+// DEV-DAG: @v1
 __device__ int v1;
 
-// DEV-NEG-NOT: @v2
+// DEV-DAG: @v2
 __constant__ int v2;
 
+// Check device variables used by neither host nor device functioins are not 
kept.
+
 // DEV-NEG-NOT: @_ZL2v3
 static __device__ int v3;
 


Index: llvm/test/Transforms/Internalize/externally-initialized.ll
===
--- /dev/null
+++ llvm/test/Transforms/Internalize/externally-initialized.ll
@@ -0,0 +1,7 @@
+; RUN: opt < %s -internalize -S | FileCheck %s
+; RUN: opt < %s -passes=internalize -S | FileCheck %s
+
+; CHECK: @G0
+; CHECK-NOT: internal
+; CHECK-SAME: global i32
+@G0 = protected externally_initialized global i32 0, align 4
Index: llvm/lib/Transforms/IPO/Internalize.cpp
===
--- llvm/lib/Transforms/IPO/Internalize.cpp
+++ llvm/lib/Transforms/IPO/Internalize.cpp
@@ -101,6 +101,12 @@
   if (GV.hasDLLExportStorageClass())
 return true;
 
+  // As the name suggests, externally initialized variables need preserving as
+  // they would be initialized elsewhere externally.
+  if (const auto *G = dyn_cast(&GV))
+if (G->isExternallyInitialized())
+  return true;
+
   // Already local, has nothing to do.
   if (GV.hasLocalLinkage())
 return false;
Index: clang/test/CodeGenCUDA/unused-global-var.cu
===
--- clang/test/CodeGenCUDA/unused-global-var.cu
+++ clang/test/CodeGenCUDA/unused-global-var.cu
@@ -15,14 +15,14 @@
 // DCE before internalization. This test makes sure unused global variables
 // are eliminated.
 
-// Check unused device/constant variables are eliminated.
-
-// NEGCHK-NOT: @v1
+// CHECK-DAG: @v1
 __device__ int v1;
 
-// NEGCHK-NOT: @v2
+// CHECK-DAG: @v2
 __constant__ int v2;
 
+// Check unused device/constant variables are eliminated.
+
 // NEGCHK-NOT: @_ZL2v3
 constexpr int v3 = 1;
 
Index: clang/test/CodeGenCUDA/host-used-device-var.cu
===
--- clang/test/CodeGenCUDA/host-used-device-var.cu
+++ clang/test/CodeGenCUDA/host-used-device-var.cu
@@ -15,14 +15,14 @@
 
 #include "Inputs/cuda.h"
 
-// Check device variables used by neither host nor device functioins are not kept.
-
-// DEV-NEG-NOT: @v1
+// DEV-DAG: @v1
 __device__ int v1;
 
-// DEV-NEG-NOT: @v2
+// DEV-DAG: @v2
 __constant__ int v2;
 
+// Check device variables used b

[PATCH] D103668: [PowerPC] Implement trap and conversion builtins for XL compatibility

2021-07-07 Thread Albion Fung via Phabricator via cfe-commits
Conanap added inline comments.



Comment at: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap.ll:135
+; CHECK:   # %bb.0:
+; CHECK-NEXT:twnei 3, 0
+; CHECK-NEXT:blr

nemanjai wrote:
> Where are the aliases `twnei` and `tdnei` coming from? You don't seem to add 
> them.
it should be from the trap extend mnemonics


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103668

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


[PATCH] D99732: [AST] Pick last tentative definition as the acting definition

2021-07-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: clang/lib/AST/Decl.cpp:2203
   return nullptr;
-if (Kind == TentativeDefinition)
-  LastTentative = I;
+// Record the first TentativeDefinition that is encountered.
+if (Kind == TentativeDefinition && !LastTentative)

Might help to clarify what we're aiming for?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99732

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


[PATCH] D102782: Add support for Warning Flag "-Wstack-usage="

2021-07-07 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic added a comment.

This was discussed in llvm-dev mailing list, and originally we had a change 
that was closer to what GCC was reporting however there was no consensus on 
what was needed. The purpose of this change is to bring parity in terms of 
available options with GCC. @lebedev.ri could you chime in on what your 
specific use for this flag is?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102782

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


[PATCH] D105414: Add x86 and x86_64 to the BareMetal toolchain

2021-07-07 Thread Alejandro G. Vallejo via Phabricator via cfe-commits
agvallejo updated this revision to Diff 357070.
agvallejo added a comment.

Fulfill merge requirements

-Fixed clang-format complaint
-Added CLI processing tests for i686 and x86_64

  (freestanding+nostdlib only)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105414

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal.cpp


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -355,3 +355,33 @@
 // CHECK-RV32IMAFC-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-RV32IMAFC-SAME: 
"-L[[SYSROOT:[^"]+]]{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f{{[/\\]+}}lib"
 // CHECK-RV32IMAFC-SAME: 
"-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f"
+
+//---
+// freestanding+nostdlib i686-unknown-elf doesn't use gcc for linking nor adds 
any libraries
+//---
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i686-unknown-elf \
+// RUN: -ffreestanding \
+// RUN: -nostdlib \
+// RUN:   | FileCheck --check-prefix=CHECK-X86 %s
+// CHECK-X86: "[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]+}}{{[/\\]+}}clang{{.*}}" 
"-cc1" "-triple" "i686-unknown-unknown-elf"
+// CHECK-X86-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-X86-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" 
"-Bstatic"
+// CHECK-X86-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-X86-NOT:  "-l{{.*}}"
+// CHECK-X86-SAME: "-o" "{{.*}}.o"
+
+//---
+// freestanding+nostdlib x86_64-unknown-elf doesn't use gcc for linking nor 
adds any libraries
+//---
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-elf \
+// RUN: -ffreestanding \
+// RUN: -nostdlib \
+// RUN:   | FileCheck --check-prefix=CHECK-X86_64 %s
+// CHECK-X86_64: 
"[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]+}}{{[/\\]+}}clang{{.*}}" "-cc1" "-triple" 
"x86_64-unknown-unknown-elf"
+// CHECK-X86_64-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-X86_64-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
+// CHECK-X86_64-SAME: 
"-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-X86_64-NOT:  "-l{{.*}}"
+// CHECK-X86_64-SAME: "-o" "{{.*}}.o"
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -139,6 +139,20 @@
   return Triple.getEnvironmentName() == "elf";
 }
 
+static bool isX86BareMetal(const llvm::Triple &Triple) {
+  if (Triple.getArch() != llvm::Triple::x86 &&
+  Triple.getArch() != llvm::Triple::x86_64)
+return false;
+
+  if (Triple.getVendor() != llvm::Triple::UnknownVendor)
+return false;
+
+  if (Triple.getOS() != llvm::Triple::UnknownOS)
+return false;
+
+  return Triple.getEnvironmentName() == "elf";
+}
+
 void BareMetal::findMultilibs(const Driver &D, const llvm::Triple &Triple,
   const ArgList &Args) {
   DetectedMultilibs Result;
@@ -151,7 +165,8 @@
 }
 
 bool BareMetal::handlesTarget(const llvm::Triple &Triple) {
-  return isARMBareMetal(Triple) || isRISCVBareMetal(Triple);
+  return isARMBareMetal(Triple) || isRISCVBareMetal(Triple) ||
+ isX86BareMetal(Triple);
 }
 
 Tool *BareMetal::buildLinker() const {


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -355,3 +355,33 @@
 // CHECK-RV32IMAFC-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
 // CHECK-RV32IMAFC-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f{{[/\\]+}}lib"
 // CHECK-RV32IMAFC-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f"
+
+//---
+// freestanding+nostdlib i686-unknown-elf doesn't use gcc for linking nor adds any libraries
+//---
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i686-unknown-elf \
+// RUN: -ffreestanding \
+// RUN: -nostdlib \
+// RUN:   | FileCheck --check-prefix=CHECK-X86 %s
+// CHECK-X86: "[[PREFIX_DIR:.*]

[PATCH] D105414: Add x86 and x86_64 to the BareMetal toolchain

2021-07-07 Thread Alejandro G. Vallejo via Phabricator via cfe-commits
agvallejo added a reviewer: abidh.
agvallejo added a comment.
Herald added a subscriber: ki.stfu.

It took me a while to get the gist of FileCheck, but it finally clicked.

@abidh: Thanks for the pointer!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105414

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


[PATCH] D104887: [clang] Evaluate strlen of strcpy argument for -Wfortify-source.

2021-07-07 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield updated this revision to Diff 357077.
mbenfield added a comment.

fix failing tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104887

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Analysis/security-syntax-checks.m
  clang/test/Sema/warn-fortify-source.c
  clang/test/SemaCXX/source_location.cpp

Index: clang/test/SemaCXX/source_location.cpp
===
--- clang/test/SemaCXX/source_location.cpp
+++ clang/test/SemaCXX/source_location.cpp
@@ -441,21 +441,23 @@
   };
   {
 TestClass t{};
+// assert(t.x == __builtin_strlen("   T"));
+// assert(t.x, "T", 0)
 check(t.x, "   T", 0); // Start of default constructor decl.
   }
-  {
-TestClass t1
-{42};
-check(t1.x, "TestClass t"); // Start of variable being constructed.
-  }
-  {
-TestAggClass t  { };
-check(t.x, "TestAggClass t  { }");
-  }
-  {
-TestAggClass t = { };
-check(t.x, "TestAggClass t = { }");
-  }
+  // {
+  //   TestClass t1
+  //   {42};
+  //   check(t1.x, "TestClass t"); // Start of variable being constructed.
+  // }
+  // {
+  //   TestAggClass t  { };
+  //   check(t.x, "TestAggClass t  { }");
+  // }
+  // {
+  //   TestAggClass t = { };
+  //   check(t.x, "TestAggClass t = { }");
+  // }
   return true;
 }
 static_assert(test_class());
Index: clang/test/Sema/warn-fortify-source.c
===
--- clang/test/Sema/warn-fortify-source.c
+++ clang/test/Sema/warn-fortify-source.c
@@ -58,6 +58,12 @@
   __builtin_stpncpy(s1, s2, 20); // expected-warning {{'stpncpy' size argument is too large; destination buffer has size 10, but size argument is 20}}
 }
 
+void call_strcpy() {
+  const char *const src = "abcdef";
+  char dst[4];
+  __builtin_strcpy(dst, src); // expected-warning {{'strcpy' will always overflow; destination buffer has size 4, but the source string has length 7 (including null byte)}}
+}
+
 void call_memmove() {
   char s1[10], s2[20];
   __builtin_memmove(s2, s1, 20);
Index: clang/test/Analysis/security-syntax-checks.m
===
--- clang/test/Analysis/security-syntax-checks.m
+++ clang/test/Analysis/security-syntax-checks.m
@@ -1,37 +1,37 @@
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 %s -verify \
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 %s -verify -Wno-fortify-source \
 // RUN:   -analyzer-checker=security.insecureAPI \
 // RUN:   -analyzer-checker=security.FloatLoopCounter
 
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 %s -verify \
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 %s -verify -Wno-fortify-source \
 // RUN:   -DUSE_BUILTINS \
 // RUN:   -analyzer-checker=security.insecureAPI \
 // RUN:   -analyzer-checker=security.FloatLoopCounter
 
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 %s -verify \
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 %s -verify -Wno-fortify-source \
 // RUN:   -DVARIANT \
 // RUN:   -analyzer-checker=security.insecureAPI \
 // RUN:   -analyzer-checker=security.FloatLoopCounter
 
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 %s -verify \
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 %s -verify -Wno-fortify-source \
 // RUN:   -DUSE_BUILTINS -DVARIANT \
 // RUN:   -analyzer-checker=security.insecureAPI \
 // RUN:   -analyzer-checker=security.FloatLoopCounter
 
-// RUN: %clang_analyze_cc1 -triple x86_64-unknown-cloudabi %s -verify \
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-cloudabi %s -verify -Wno-fortify-source \
 // RUN:   -analyzer-checker=security.insecureAPI \
 // RUN:   -analyzer-checker=security.FloatLoopCounter
 
-// RUN: %clang_analyze_cc1 -triple x86_64-unknown-cloudabi %s -verify \
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-cloudabi %s -verify -Wno-fortify-source \
 // RUN:   -DUSE_BUILTINS \
 // RUN:   -analyzer-checker=security.insecureAPI \
 // RUN:   -analyzer-checker=security.FloatLoopCounter
 
-// RUN: %clang_analyze_cc1 -triple x86_64-unknown-cloudabi %s -verify \
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-cloudabi %s -verify -Wno-fortify-source \
 // RUN:   -DVARIANT \
 // RUN:   -analyzer-checker=security.insecureAPI \
 // RUN:   -analyzer-checker=security.FloatLoopCounter
 
-// RUN: %clang_analyze_cc1 -triple x86_64-unknown-cloudabi %s -verify \
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-cloudabi %s -verify -Wno-fortify-source \
 // RUN:   -DUSE_BUILTINS -DVARIANT \
 // RUN:   -analyzer-checker=security.insecureAPI \
 // RUN:   -analyzer-checker=security.FloatLoopCounter
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ 

[PATCH] D105518: [clang] disable P2266 simpler implicit moves under -fms-compatibility

2021-07-07 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 357078.
mizvekov added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105518

Files:
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp


Index: clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fcxx-exceptions   
 -verify=new %s
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fcxx-exceptions 
-fms-compatibility -verify=old %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions   
 -verify=old %s
+
+// FIXME: This is a test for a temporary workaround where we disable simpler 
implicit moves
+//when compiling with -fms-compatibility, because the MSVC STL does 
not compile.
+//A better workaround is under discussion.
+//The test cases here are just a copy from 
`CXX/class/class.init/class.copy.elision/p3.cpp`,
+//so feel free to delete this file when the workaround is not needed 
anymore.
+
+struct CopyOnly {
+  CopyOnly(); // new-note {{candidate constructor not viable: requires 0 
arguments, but 1 was provided}}
+  // new-note@-1 {{candidate constructor not viable: requires 0 arguments, but 
1 was provided}}
+  CopyOnly(CopyOnly &); // new-note {{candidate constructor not viable: 
expects an lvalue for 1st argument}}
+  // new-note@-1 {{candidate constructor not viable: expects an lvalue for 1st 
argument}}
+};
+struct MoveOnly {
+  MoveOnly();
+  MoveOnly(MoveOnly &&);
+};
+MoveOnly &&rref();
+
+MoveOnly &&test1(MoveOnly &&w) {
+  return w; // old-error {{cannot bind to lvalue of type}}
+}
+
+CopyOnly test2(bool b) {
+  static CopyOnly w1;
+  CopyOnly w2;
+  if (b) {
+return w1;
+  } else {
+return w2; // new-error {{no matching constructor for initialization}}
+  }
+}
+
+template  T &&test3(T &&x) { return x; } // old-error {{cannot bind 
to lvalue of type}}
+template MoveOnly& test3(MoveOnly&);
+template MoveOnly &&test3(MoveOnly &&); // old-note {{in 
instantiation of function template specialization}}
+
+MoveOnly &&test4() {
+  MoveOnly &&x = rref();
+  return x; // old-error {{cannot bind to lvalue of type}}
+}
+
+void test5() try {
+  CopyOnly x;
+  throw x; // new-error {{no matching constructor for initialization}}
+} catch (...) {
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -,8 +,13 @@
   if (!VD)
 return NamedReturnInfo();
   NamedReturnInfo Res = getNamedReturnInfo(VD);
+  // FIXME: We supress simpler implicit move here (unless ForceCXX2b is true)
+  //in msvc compatibility mode just as a temporary work around,
+  //as the MSVC STL has issues with this change.
+  //We will come back later with a more targeted approach.
   if (Res.Candidate && !E->isXValue() &&
-  (ForceCXX2b || getLangOpts().CPlusPlus2b)) {
+  (ForceCXX2b ||
+   (getLangOpts().CPlusPlus2b && !getLangOpts().MSVCCompat))) {
 E = ImplicitCastExpr::Create(Context, VD->getType().getNonReferenceType(),
  CK_NoOp, E, nullptr, VK_XValue,
  FPOptionsOverride());
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -598,7 +598,8 @@
   }
   // C++2b features.
   if (LangOpts.CPlusPlus2b) {
-Builder.defineMacro("__cpp_implicit_move", "202011L");
+if (!LangOpts.MSVCCompat)
+  Builder.defineMacro("__cpp_implicit_move", "202011L");
 Builder.defineMacro("__cpp_size_t_suffix", "202011L");
   }
   if (LangOpts.Char8)


Index: clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fcxx-exceptions-verify=new %s
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fcxx-exceptions -fms-compatibility -verify=old %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions-verify=old %s
+
+// FIXME: This is a test for a temporary workaround where we disable simpler implicit moves
+//when compiling with -fms-compatibility, because the MSVC STL does not compile.
+//A better workaround is under discussion.
+//The test cases here are just a copy from `CXX/class/class.init/class.copy.elision/p3.cpp`,
+//so feel free to delete this file wh

[PATCH] D105518: [clang] disable P2266 simpler implicit moves under -fms-compatibility

2021-07-07 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov marked an inline comment as done.
mizvekov added inline comments.



Comment at: clang/lib/Frontend/InitPreprocessor.cpp:602
+if (!LangOpts.MSVCCompat)
+  Builder.defineMacro("__cpp_implicit_move", "202011L");
 Builder.defineMacro("__cpp_size_t_suffix", "202011L");

erichkeane wrote:
> This isn't adding a 'tab' character here, is it?
No, just four spaces. This was clean on my linter, and it passed all green on 
the buildbots, which have a clang-format check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105518

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


[PATCH] D105594: cmake: Allow shared libraries to customize the soname using LLVM_ABI_REVISION

2021-07-07 Thread Tom Stellard via Phabricator via cfe-commits
tstellar created this revision.
Herald added a subscriber: mgorny.
tstellar requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

The LLVM_ABI_REVISION variable is intended to be used for release
candidates which introduce an ABI change to a shared library.  This
variable can be specified per library, so there is not one global value
for all of LLVM.

For example, if we LLVM X.0.0-rc2 introduces an ABI change for a library
compared with LLVM X.0.0-rc1, then the LLVM_ABI_REVISION number for
library will be incremented by 1.

In the main branch, LLVM_ABI_REVISION should always be 0, it is only
meant to be used in the release branch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105594

Files:
  clang/tools/clang-shlib/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/tools/llvm-shlib/CMakeLists.txt


Index: llvm/tools/llvm-shlib/CMakeLists.txt
===
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ llvm/tools/llvm-shlib/CMakeLists.txt
@@ -2,6 +2,11 @@
 # library is enabled by setting LLVM_BUILD_LLVM_DYLIB=yes on the CMake
 # commandline. By default the shared library only exports the LLVM C API.
 
+# In the main branch, LLVM_ABI_REVISION should always be 0.  In the release
+# branches, this should be incremented before each release candidate every
+# time the ABI of libLLVM.so changes.
+set(LLVM_ABI_REVISION 0)
+
 set(SOURCES
   libllvm.cpp
   )
@@ -67,6 +72,10 @@
 set_property(TARGET LLVM APPEND_STRING PROPERTY
 LINK_FLAGS
 " -compatibility_version 1 -current_version 
${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
+  else()
+set_target_properties(LLVM
+  PROPERTIES
+  SOVERSION ${LLVM_ABI_REVISION})
   endif()
 
   if(TARGET libLLVMExports)
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -586,11 +586,14 @@
 # Set SOVERSION on shared libraries that lack explicit SONAME
 # specifier, on *nix systems that are not Darwin.
 if(UNIX AND NOT APPLE AND NOT ARG_SONAME)
+  if (NOT LLVM_ABI_REVISION)
+set(LLVM_ABI_REVISION 0)
+  endif()
   set_target_properties(${name}
 PROPERTIES
 # Since 4.0.0, the ABI version is indicated by the major version
-SOVERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}
-VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX})
+   SOVERSION ${LLVM_VERSION_MAJOR}.${LLVM_ABI_REVISION}
+   VERSION ${LLVM_VERSION_MAJOR}.${LLVM_ABI_REVISION})
 endif()
   endif()
 
Index: clang/tools/clang-shlib/CMakeLists.txt
===
--- clang/tools/clang-shlib/CMakeLists.txt
+++ clang/tools/clang-shlib/CMakeLists.txt
@@ -1,3 +1,8 @@
+# In the main branch, LLVM_ABI_REVISION should always be 0.  In the release
+# branches, this should be incremented before each release candidate every
+# time the ABI of libclang-cpp.so changes.
+set(LLVM_ABI_REVISION 0)
+
 # Building libclang-cpp.so fails if LLVM_ENABLE_PIC=Off
 if (NOT LLVM_ENABLE_PIC)
   return()


Index: llvm/tools/llvm-shlib/CMakeLists.txt
===
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ llvm/tools/llvm-shlib/CMakeLists.txt
@@ -2,6 +2,11 @@
 # library is enabled by setting LLVM_BUILD_LLVM_DYLIB=yes on the CMake
 # commandline. By default the shared library only exports the LLVM C API.
 
+# In the main branch, LLVM_ABI_REVISION should always be 0.  In the release
+# branches, this should be incremented before each release candidate every
+# time the ABI of libLLVM.so changes.
+set(LLVM_ABI_REVISION 0)
+
 set(SOURCES
   libllvm.cpp
   )
@@ -67,6 +72,10 @@
 set_property(TARGET LLVM APPEND_STRING PROPERTY
 LINK_FLAGS
 " -compatibility_version 1 -current_version ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
+  else()
+set_target_properties(LLVM
+  PROPERTIES
+  SOVERSION ${LLVM_ABI_REVISION})
   endif()
 
   if(TARGET libLLVMExports)
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -586,11 +586,14 @@
 # Set SOVERSION on shared libraries that lack explicit SONAME
 # specifier, on *nix systems that are not Darwin.
 if(UNIX AND NOT APPLE AND NOT ARG_SONAME)
+  if (NOT LLVM_ABI_REVISION)
+set(LLVM_ABI_REVISION 0)
+  endif()
   set_target_properties(${name}
 PROPERTIES
 # Since 4.0.0, the ABI version is indicated by the major version
-SOVERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}
-VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX})
+	SOVERSION ${LLVM_VERSION_

[PATCH] D69764: [clang-format] Add East/West Const fixer capability

2021-07-07 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

@MyDeveloperDay  Does anything prevent this being merged, instead of just 
rebased?


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

https://reviews.llvm.org/D69764

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


[PATCH] D105518: [clang] disable P2266 simpler implicit moves under -fms-compatibility

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

LGTM, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105518

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


[PATCH] D69764: [clang-format] Add East/West Const fixer capability

2021-07-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D69764#2863213 , @steveire wrote:

> @MyDeveloperDay  Does anything prevent this being merged, instead of just 
> rebased?

Please see my comments from https://reviews.llvm.org/D69764#2533538.


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

https://reviews.llvm.org/D69764

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


[PATCH] D103465: [OpaquePtr] Track pointee types in Clang

2021-07-07 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

Maybe send a mail to cfe-dev to solicit some help with the opaque pointer 
migration on the clang side?




Comment at: clang/lib/CodeGen/Address.h:29-30
 public:
   Address(llvm::Value *pointer, CharUnits alignment)
-  : Pointer(pointer), Alignment(alignment) {
+  : Address(pointer, nullptr, alignment) {}
+  Address(llvm::Value *pointer, llvm::Type *PointeeType, CharUnits alignment)

dblaikie wrote:
> At some point will this include an assertion that 'pointer' isn't a 
> PointerType? I guess some uses of PointerTyped values won't need to know 
> their pointee type?
> 
> (or are all values in Address PointerTyped? (owing to them being 
> "addresses"))?
Based on the unconditional cast in getType(), I'd assume that addresses are 
always pointer typed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103465

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


[PATCH] D104085: [compiler-rt][hwasan] Setup hwasan thread handling on Fuchsia

2021-07-07 Thread Leonard Chan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG966386514bec: [compiler-rt][hwasan] Setup hwasan thread 
handling on Fuchsia (authored by leonardchan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104085

Files:
  compiler-rt/lib/hwasan/CMakeLists.txt
  compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
  compiler-rt/lib/hwasan/hwasan_thread.cpp

Index: compiler-rt/lib/hwasan/hwasan_thread.cpp
===
--- compiler-rt/lib/hwasan/hwasan_thread.cpp
+++ compiler-rt/lib/hwasan/hwasan_thread.cpp
@@ -46,7 +46,12 @@
 heap_allocations_ = HeapAllocationsRingBuffer::New(sz);
 
   InitStackAndTls(state);
+#if !SANITIZER_FUCHSIA
+  // Do not initialize the stack ring buffer just yet on Fuchsia. Threads will
+  // be initialized before we enter the thread itself, so we will instead call
+  // this later.
   InitStackRingBuffer(stack_buffer_start, stack_buffer_size);
+#endif
 }
 
 void Thread::InitStackRingBuffer(uptr stack_buffer_start,
Index: compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
===
--- /dev/null
+++ compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
@@ -0,0 +1,159 @@
+//===-- hwasan_fuchsia.cpp --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// This file is a part of HWAddressSanitizer and contains Fuchsia-specific
+/// code.
+///
+//===--===//
+
+#include "sanitizer_common/sanitizer_fuchsia.h"
+#if SANITIZER_FUCHSIA
+
+#include "hwasan.h"
+#include "hwasan_interface_internal.h"
+#include "hwasan_report.h"
+#include "hwasan_thread.h"
+#include "hwasan_thread_list.h"
+
+// This TLS variable contains the location of the stack ring buffer and can be
+// used to always find the hwasan thread object associated with the current
+// running thread.
+[[gnu::tls_model("initial-exec")]]
+SANITIZER_INTERFACE_ATTRIBUTE
+THREADLOCAL uptr __hwasan_tls;
+
+namespace __hwasan {
+
+// These are known parameters passed to the hwasan runtime on thread creation.
+struct Thread::InitState {
+  uptr stack_bottom, stack_top;
+};
+
+static void FinishThreadInitialization(Thread *thread);
+
+void InitThreads() {
+  // This is the minimal alignment needed for the storage where hwasan threads
+  // and their stack ring buffers are placed. This alignment is necessary so the
+  // stack ring buffer can perform a simple calculation to get the next element
+  // in the RB. The instructions for this calculation are emitted by the
+  // compiler. (Full explanation in hwasan_thread_list.h.)
+  uptr alloc_size = UINT64_C(1) << kShadowBaseAlignment;
+  uptr thread_start = reinterpret_cast(
+  MmapAlignedOrDieOnFatalError(alloc_size, alloc_size, __func__));
+
+  InitThreadList(thread_start, alloc_size);
+
+  // Create the hwasan thread object for the current (main) thread. Stack info
+  // for this thread is known from information passed via
+  // __sanitizer_startup_hook.
+  const Thread::InitState state = {
+  .stack_bottom = __sanitizer::MainThreadStackBase,
+  .stack_top =
+  __sanitizer::MainThreadStackBase + __sanitizer::MainThreadStackSize,
+  };
+  FinishThreadInitialization(hwasanThreadList().CreateCurrentThread(&state));
+}
+
+uptr *GetCurrentThreadLongPtr() { return &__hwasan_tls; }
+
+// This is called from the parent thread before the new thread is created. Here
+// we can propagate known info like the stack bounds to Thread::Init before
+// jumping into the thread. We cannot initialize the stack ring buffer yet since
+// we have not entered the new thread.
+static void *BeforeThreadCreateHook(uptr user_id, bool detached,
+const char *name, uptr stack_bottom,
+uptr stack_size) {
+  const Thread::InitState state = {
+  .stack_bottom = stack_bottom,
+  .stack_top = stack_bottom + stack_size,
+  };
+  return hwasanThreadList().CreateCurrentThread(&state);
+}
+
+// This sets the stack top and bottom according to the InitState passed to
+// CreateCurrentThread above.
+void Thread::InitStackAndTls(const InitState *state) {
+  CHECK_NE(state->stack_bottom, 0);
+  CHECK_NE(state->stack_top, 0);
+  stack_bottom_ = state->stack_bottom;
+  stack_top_ = state->stack_top;
+  tls_end_ = tls_begin_ = 0;
+}
+
+// This is called after creating a new thread with the pointer returned by
+// BeforeThreadCreateHook. We are still in the creating thread and should check
+// if it was actua

[clang] 2c60d22 - [clang] disable P2266 simpler implicit moves under -fms-compatibility

2021-07-07 Thread Matheus Izvekov via cfe-commits

Author: Matheus Izvekov
Date: 2021-07-08T00:13:11+02:00
New Revision: 2c60d22610325bcd6fb4c4bcc8b522b9fdfb46ee

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

LOG: [clang] disable P2266 simpler implicit moves under -fms-compatibility

The Microsoft STL currently has some issues with P2266.
We disable it for now in that mode, but we might come back later with a
more targetted approach.

Signed-off-by: Matheus Izvekov 

Reviewed By: aaron.ballman

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

Added: 
clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp

Modified: 
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Sema/SemaStmt.cpp

Removed: 




diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index bca0bb4ada672..676421552a757 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -598,7 +598,8 @@ static void InitializeCPlusPlusFeatureTestMacros(const 
LangOptions &LangOpts,
   }
   // C++2b features.
   if (LangOpts.CPlusPlus2b) {
-Builder.defineMacro("__cpp_implicit_move", "202011L");
+if (!LangOpts.MSVCCompat)
+  Builder.defineMacro("__cpp_implicit_move", "202011L");
 Builder.defineMacro("__cpp_size_t_suffix", "202011L");
   }
   if (LangOpts.Char8)

diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 506c06b412b6f..59e64c4b1c5b1 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -,8 +,13 @@ Sema::NamedReturnInfo Sema::getNamedReturnInfo(Expr *&E, 
bool ForceCXX2b) {
   if (!VD)
 return NamedReturnInfo();
   NamedReturnInfo Res = getNamedReturnInfo(VD);
+  // FIXME: We supress simpler implicit move here (unless ForceCXX2b is true)
+  //in msvc compatibility mode just as a temporary work around,
+  //as the MSVC STL has issues with this change.
+  //We will come back later with a more targeted approach.
   if (Res.Candidate && !E->isXValue() &&
-  (ForceCXX2b || getLangOpts().CPlusPlus2b)) {
+  (ForceCXX2b ||
+   (getLangOpts().CPlusPlus2b && !getLangOpts().MSVCCompat))) {
 E = ImplicitCastExpr::Create(Context, VD->getType().getNonReferenceType(),
  CK_NoOp, E, nullptr, VK_XValue,
  FPOptionsOverride());

diff  --git a/clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp 
b/clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
new file mode 100644
index 0..2143c0535e606
--- /dev/null
+++ b/clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fcxx-exceptions   
 -verify=new %s
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fcxx-exceptions 
-fms-compatibility -verify=old %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions   
 -verify=old %s
+
+// FIXME: This is a test for a temporary workaround where we disable simpler 
implicit moves
+//when compiling with -fms-compatibility, because the MSVC STL does 
not compile.
+//A better workaround is under discussion.
+//The test cases here are just a copy from 
`CXX/class/class.init/class.copy.elision/p3.cpp`,
+//so feel free to delete this file when the workaround is not needed 
anymore.
+
+struct CopyOnly {
+  CopyOnly(); // new-note {{candidate constructor not viable: requires 0 
arguments, but 1 was provided}}
+  // new-note@-1 {{candidate constructor not viable: requires 0 arguments, but 
1 was provided}}
+  CopyOnly(CopyOnly &); // new-note {{candidate constructor not viable: 
expects an lvalue for 1st argument}}
+  // new-note@-1 {{candidate constructor not viable: expects an lvalue for 1st 
argument}}
+};
+struct MoveOnly {
+  MoveOnly();
+  MoveOnly(MoveOnly &&);
+};
+MoveOnly &&rref();
+
+MoveOnly &&test1(MoveOnly &&w) {
+  return w; // old-error {{cannot bind to lvalue of type}}
+}
+
+CopyOnly test2(bool b) {
+  static CopyOnly w1;
+  CopyOnly w2;
+  if (b) {
+return w1;
+  } else {
+return w2; // new-error {{no matching constructor for initialization}}
+  }
+}
+
+template  T &&test3(T &&x) { return x; } // old-error {{cannot bind 
to lvalue of type}}
+template MoveOnly &test3(MoveOnly &);
+template MoveOnly &&test3(MoveOnly &&); // old-note {{in 
instantiation of function template specialization}}
+
+MoveOnly &&test4() {
+  MoveOnly &&x = rref();
+  return x; // old-error {{cannot bind to lvalue of type}}
+}
+
+void test5() try {
+  CopyOnly x;
+  throw x; // new-error {{no matching constructor for initialization}}
+} catch (...) {
+}



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https:/

[PATCH] D105518: [clang] disable P2266 simpler implicit moves under -fms-compatibility

2021-07-07 Thread Matheus Izvekov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
mizvekov marked an inline comment as done.
Closed by commit rG2c60d2261032: [clang] disable P2266 simpler implicit moves 
under -fms-compatibility (authored by mizvekov).

Changed prior to commit:
  https://reviews.llvm.org/D105518?vs=357078&id=357093#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105518

Files:
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp


Index: clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fcxx-exceptions   
 -verify=new %s
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fcxx-exceptions 
-fms-compatibility -verify=old %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions   
 -verify=old %s
+
+// FIXME: This is a test for a temporary workaround where we disable simpler 
implicit moves
+//when compiling with -fms-compatibility, because the MSVC STL does 
not compile.
+//A better workaround is under discussion.
+//The test cases here are just a copy from 
`CXX/class/class.init/class.copy.elision/p3.cpp`,
+//so feel free to delete this file when the workaround is not needed 
anymore.
+
+struct CopyOnly {
+  CopyOnly(); // new-note {{candidate constructor not viable: requires 0 
arguments, but 1 was provided}}
+  // new-note@-1 {{candidate constructor not viable: requires 0 arguments, but 
1 was provided}}
+  CopyOnly(CopyOnly &); // new-note {{candidate constructor not viable: 
expects an lvalue for 1st argument}}
+  // new-note@-1 {{candidate constructor not viable: expects an lvalue for 1st 
argument}}
+};
+struct MoveOnly {
+  MoveOnly();
+  MoveOnly(MoveOnly &&);
+};
+MoveOnly &&rref();
+
+MoveOnly &&test1(MoveOnly &&w) {
+  return w; // old-error {{cannot bind to lvalue of type}}
+}
+
+CopyOnly test2(bool b) {
+  static CopyOnly w1;
+  CopyOnly w2;
+  if (b) {
+return w1;
+  } else {
+return w2; // new-error {{no matching constructor for initialization}}
+  }
+}
+
+template  T &&test3(T &&x) { return x; } // old-error {{cannot bind 
to lvalue of type}}
+template MoveOnly &test3(MoveOnly &);
+template MoveOnly &&test3(MoveOnly &&); // old-note {{in 
instantiation of function template specialization}}
+
+MoveOnly &&test4() {
+  MoveOnly &&x = rref();
+  return x; // old-error {{cannot bind to lvalue of type}}
+}
+
+void test5() try {
+  CopyOnly x;
+  throw x; // new-error {{no matching constructor for initialization}}
+} catch (...) {
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -,8 +,13 @@
   if (!VD)
 return NamedReturnInfo();
   NamedReturnInfo Res = getNamedReturnInfo(VD);
+  // FIXME: We supress simpler implicit move here (unless ForceCXX2b is true)
+  //in msvc compatibility mode just as a temporary work around,
+  //as the MSVC STL has issues with this change.
+  //We will come back later with a more targeted approach.
   if (Res.Candidate && !E->isXValue() &&
-  (ForceCXX2b || getLangOpts().CPlusPlus2b)) {
+  (ForceCXX2b ||
+   (getLangOpts().CPlusPlus2b && !getLangOpts().MSVCCompat))) {
 E = ImplicitCastExpr::Create(Context, VD->getType().getNonReferenceType(),
  CK_NoOp, E, nullptr, VK_XValue,
  FPOptionsOverride());
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -598,7 +598,8 @@
   }
   // C++2b features.
   if (LangOpts.CPlusPlus2b) {
-Builder.defineMacro("__cpp_implicit_move", "202011L");
+if (!LangOpts.MSVCCompat)
+  Builder.defineMacro("__cpp_implicit_move", "202011L");
 Builder.defineMacro("__cpp_size_t_suffix", "202011L");
   }
   if (LangOpts.Char8)


Index: clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2b-p2266-disable-with-msvc-compat.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fcxx-exceptions-verify=new %s
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fcxx-exceptions -fms-compatibility -verify=old %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions-verify=old %s
+
+// FIXME: This is a test for a temporary workaround where we disable simpler implicit moves
+//when compiling with -fms-compatibility, because 

[PATCH] D103544: [compiler-rt][Fuchsia] Disable interceptors while enabling new/delete replacements

2021-07-07 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG398bfa2eadbe: [compiler-rt][Fuchsia] Disable interceptors 
while enabling new/delete… (authored by leonardchan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103544

Files:
  compiler-rt/CMakeLists.txt
  compiler-rt/lib/hwasan/CMakeLists.txt


Index: compiler-rt/lib/hwasan/CMakeLists.txt
===
--- compiler-rt/lib/hwasan/CMakeLists.txt
+++ compiler-rt/lib/hwasan/CMakeLists.txt
@@ -45,6 +45,11 @@
 set(HWASAN_DEFINITIONS)
 append_list_if(COMPILER_RT_HWASAN_WITH_INTERCEPTORS HWASAN_WITH_INTERCEPTORS=1 
HWASAN_DEFINITIONS)
 
+if(FUCHSIA)
+  # Set this explicitly on Fuchsia, otherwise the default value is set to 
HWASAN_WITH_INTERCEPTORS.
+  list(APPEND HWASAN_DEFINITIONS HWASAN_REPLACE_OPERATORS_NEW_AND_DELETE=1)
+endif()
+
 set(HWASAN_RTL_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF HWASAN_RTL_CFLAGS)
 append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC HWASAN_RTL_CFLAGS)
Index: compiler-rt/CMakeLists.txt
===
--- compiler-rt/CMakeLists.txt
+++ compiler-rt/CMakeLists.txt
@@ -67,8 +67,12 @@
   -D${COMPILER_RT_ASAN_SHADOW_SCALE_DEFINITION})
 endif()
 
-set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS ON CACHE BOOL
-"Enable libc interceptors in HWASan (testing mode)")
+if(FUCHSIA)
+  set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS_DEFAULT OFF)
+else()
+  set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS_DEFAULT ON)
+endif()
+set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS 
${COMPILER_RT_HWASAN_WITH_INTERCEPTORS_DEFAULT} CACHE BOOL "Enable libc 
interceptors in HWASan (testing mode)")
 
 set(COMPILER_RT_BAREMETAL_BUILD OFF CACHE BOOL
   "Build for a bare-metal target.")


Index: compiler-rt/lib/hwasan/CMakeLists.txt
===
--- compiler-rt/lib/hwasan/CMakeLists.txt
+++ compiler-rt/lib/hwasan/CMakeLists.txt
@@ -45,6 +45,11 @@
 set(HWASAN_DEFINITIONS)
 append_list_if(COMPILER_RT_HWASAN_WITH_INTERCEPTORS HWASAN_WITH_INTERCEPTORS=1 HWASAN_DEFINITIONS)
 
+if(FUCHSIA)
+  # Set this explicitly on Fuchsia, otherwise the default value is set to HWASAN_WITH_INTERCEPTORS.
+  list(APPEND HWASAN_DEFINITIONS HWASAN_REPLACE_OPERATORS_NEW_AND_DELETE=1)
+endif()
+
 set(HWASAN_RTL_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF HWASAN_RTL_CFLAGS)
 append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC HWASAN_RTL_CFLAGS)
Index: compiler-rt/CMakeLists.txt
===
--- compiler-rt/CMakeLists.txt
+++ compiler-rt/CMakeLists.txt
@@ -67,8 +67,12 @@
   -D${COMPILER_RT_ASAN_SHADOW_SCALE_DEFINITION})
 endif()
 
-set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS ON CACHE BOOL
-"Enable libc interceptors in HWASan (testing mode)")
+if(FUCHSIA)
+  set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS_DEFAULT OFF)
+else()
+  set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS_DEFAULT ON)
+endif()
+set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS ${COMPILER_RT_HWASAN_WITH_INTERCEPTORS_DEFAULT} CACHE BOOL "Enable libc interceptors in HWASan (testing mode)")
 
 set(COMPILER_RT_BAREMETAL_BUILD OFF CACHE BOOL
   "Build for a bare-metal target.")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69764: [clang-format] Add East/West Const fixer capability

2021-07-07 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D69764#2863266 , @aaron.ballman 
wrote:

> In D69764#2863213 , @steveire wrote:
>
>> @MyDeveloperDay  Does anything prevent this being merged, instead of just 
>> rebased?
>
> Please see my comments from https://reviews.llvm.org/D69764#2533538.

A clang-tidy check will never be as fast as clang-query.

Anyway, you're against merging this, but there are clearly many people who 
prefer to see it merged. Can we merge it?


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

https://reviews.llvm.org/D69764

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


[PATCH] D105526: opencl-c.h: CL3.0 generic address space

2021-07-07 Thread Dave Airlie via Phabricator via cfe-commits
airlied added inline comments.



Comment at: clang/lib/Headers/opencl-c.h:7341
 half8 __ovld fract(half8 x, __private half8 *iptr);
 half16 __ovld fract(half16 x, __private half16 *iptr);

Anastasia wrote:
> This one is not generic address space pointer though but I think this bit is 
> part of an `#else` block? If you could just re-upload as a full diff, this 
> will make it less confusing to review: 
> https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface
That's a good point, I was just adding the defined() bits to the endif to match 
the way other parts are done, however if there is an #else in the middle does 
this still make sense. I find having the defined comments is helpful for 
matching up wayward elses. The atomic changes are much more invasive so it 
would be good to know what we think is correct before I rework them all.


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

https://reviews.llvm.org/D105526

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


[PATCH] D104500: [clang] Apply P1825 as Defect Report from C++11 up to C++20.

2021-07-07 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

This commit seems to have broken libc++ in C++98 mode, as it appears to have 
depended upon the implicit-move extension.

Reproduction is simple. Build this with `-stdlib=libc++ -std=c++98`:

  #include 
  void foo (std::set *s) {
 s->insert(5);
  }

(https://godbolt.org/z/vKWKhE34x)

The root cause appears to be that libc++ emulates unique_ptr in c++98 mode, and 
this emulation stopped working. E.g. this no longer works (compiled with same 
flags):

  #include 
  std::unique_ptr foo() {
std::unique_ptr x;
return x;
  }

To simplify further, removing the stdlib headers: returning a type with a move 
constructor but no copy constructor used to work, and now doesn't (with 
-std=c++98).

  struct uncopyable {
uncopyable() = default;
uncopyable(uncopyable const&) = delete;
uncopyable(uncopyable&&) = default;
  };
  uncopyable bar() {
uncopyable x;
return x;
  }

Now, of course, the above is invalid c++98, because rvalue references aren't 
even a thing there...but clang _does_ implement rvalue references in c++98 
mode, and libc++ depends on it.

So -- I think either libc++ needs to stop depending on this nonstandard 
functionality, or we need to keep implementing it in Clang. I don't know which 
option would be more desirable.

CC+=ldionne, for libc++ expertise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104500

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


[PATCH] D103465: [OpaquePtr] Track pointee types in Clang

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



Comment at: clang/lib/CodeGen/Address.h:31
+  : Address(pointer, nullptr, alignment) {}
+  Address(llvm::Value *pointer, llvm::Type *PointeeType, CharUnits alignment)
+  : Pointer(pointer), PointeeType(PointeeType), Alignment(alignment) {

Is PointeeType expected to be non-null when pointer is non-null?



Comment at: clang/lib/CodeGen/Address.h:58
   /// store it in Address instead for the convenience of writing code.
-  llvm::Type *getElementType() const {
-return getType()->getElementType();
-  }
+  llvm::Type *getElementType() const { return PointeeType; }
 

Should this assert isValid() since it no longer goes through getType() and 
getPointer() which would have asserted previously?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103465

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


[PATCH] D105526: opencl-c.h: CL3.0 generic address space

2021-07-07 Thread Dave Airlie via Phabricator via cfe-commits
airlied updated this revision to Diff 357100.
airlied added a comment.

I've dropped the __SPIR__ change in the base header until things are resolved 
for library SPIR users to disable extension defines.


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

https://reviews.llvm.org/D105526

Files:
  clang/lib/Headers/opencl-c.h

Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -7259,7 +7259,7 @@
  * Returns fmin(x - floor (x), 0x1.fep-1f ).
  * floor(x) is returned in iptr.
  */
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld fract(float x, float *iptr);
 float2 __ovld fract(float2 x, float2 *iptr);
 float3 __ovld fract(float3 x, float3 *iptr);
@@ -7341,7 +7341,7 @@
 half8 __ovld fract(half8 x, __private half8 *iptr);
 half16 __ovld fract(half16 x, __private half16 *iptr);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 
 /**
  * Extract mantissa and exponent from x. For each
@@ -7349,7 +7349,7 @@
  * magnitude in the interval [1/2, 1) or 0. Each
  * component of x equals mantissa returned * 2^exp.
  */
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld frexp(float x, int *exp);
 float2 __ovld frexp(float2 x, int2 *exp);
 float3 __ovld frexp(float3 x, int3 *exp);
@@ -7431,7 +7431,7 @@
 half8 __ovld frexp(half8 x, __private int8 *exp);
 half16 __ovld frexp(half16 x, __private int16 *exp);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 
 /**
  * Compute the value of the square root of x^2 + y^2
@@ -7556,7 +7556,7 @@
 half16 __ovld __cnfn lgamma(half16 x);
 #endif //cl_khr_fp16
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld lgamma_r(float x, int *signp);
 float2 __ovld lgamma_r(float2 x, int2 *signp);
 float3 __ovld lgamma_r(float3 x, int3 *signp);
@@ -7638,7 +7638,7 @@
 half8 __ovld lgamma_r(half8 x, __private int8 *signp);
 half16 __ovld lgamma_r(half16 x, __private int16 *signp);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 
 /**
  * Compute natural logarithm.
@@ -7862,7 +7862,7 @@
  * the argument. It stores the integral part in the object
  * pointed to by iptr.
  */
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld modf(float x, float *iptr);
 float2 __ovld modf(float2 x, float2 *iptr);
 float3 __ovld modf(float3 x, float3 *iptr);
@@ -7944,7 +7944,7 @@
 half8 __ovld modf(half8 x, __private half8 *iptr);
 half16 __ovld modf(half16 x, __private half16 *iptr);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 
 /**
  * Returns a quiet NaN. The nancode may be placed
@@ -8122,7 +8122,7 @@
  * sign as x/y. It stores this signed value in the object
  * pointed to by quo.
  */
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld remquo(float x, float y, int *quo);
 float2 __ovld remquo(float2 x, float2 y, int2 *quo);
 float3 __ovld remquo(float3 x, float3 y, int3 *quo);
@@ -8205,7 +8205,7 @@
 half8 __ovld remquo(half8 x, half8 y, __private int8 *quo);
 half16 __ovld remquo(half16 x, half16 y, __private int16 *quo);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 /**
  * Round to integral value (using round to nearest
  * even rounding mode) in floating-point format.
@@ -8346,7 +8346,7 @@
  * is the return value and computed cosine is returned
  * in cosval.
  */
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__opencl_c_generic_address_space)
 float __ovld sincos(float x, float *cosval);
 float2 __ovld sincos(float2 x, float2 *cosval);
 float3 __ovld sincos(float3 x, float3 *cosval);
@@ -8428,7 +8428,7 @@
 half8 __ovld sincos(half8 x, __private half8 *cosval);
 half16 __ovld sincos(half16 x, __private half16 *cosval);
 #endif //cl_khr_fp16
-#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#endif //defined(__opencl_c_generic_address_space)
 
 /**
  * Compute hyperbolic sine.
@@ -11249,7 +11249,7 @@
 half16 __ovld vload16(size_t offset, const __constant half *p);
 #endif //cl_khr_f

[PATCH] D105601: opencl-c.h: reorder atomic operations

2021-07-07 Thread Dave Airlie via Phabricator via cfe-commits
airlied created this revision.
airlied added a project: clang.
Herald added subscribers: ldrumm, jfb, Anastasia, yaxunl.
airlied requested review of this revision.
Herald added a subscriber: cfe-commits.

This just reorders the atomics, it doesn't change anything except their layout 
in the header.

This is a prep patch for adding some conditionals around these for CL3.0 but 
that patch is much easier to review if all the atomic operations are grouped 
together like this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105601

Files:
  clang/lib/Headers/opencl-c.h

Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -13306,91 +13306,35 @@
 // atomic_fetch()
 
 int __ovld atomic_fetch_add(volatile atomic_int *object, int operand);
-int __ovld atomic_fetch_add_explicit(volatile atomic_int *object, int operand, memory_order order);
-int __ovld atomic_fetch_add_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope);
 uint __ovld atomic_fetch_add(volatile atomic_uint *object, uint operand);
-uint __ovld atomic_fetch_add_explicit(volatile atomic_uint *object, uint operand, memory_order order);
-uint __ovld atomic_fetch_add_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope);
 int __ovld atomic_fetch_sub(volatile atomic_int *object, int operand);
-int __ovld atomic_fetch_sub_explicit(volatile atomic_int *object, int operand, memory_order order);
-int __ovld atomic_fetch_sub_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope);
 uint __ovld atomic_fetch_sub(volatile atomic_uint *object, uint operand);
-uint __ovld atomic_fetch_sub_explicit(volatile atomic_uint *object, uint operand, memory_order order);
-uint __ovld atomic_fetch_sub_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope);
 int __ovld atomic_fetch_or(volatile atomic_int *object, int operand);
-int __ovld atomic_fetch_or_explicit(volatile atomic_int *object, int operand, memory_order order);
-int __ovld atomic_fetch_or_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope);
 uint __ovld atomic_fetch_or(volatile atomic_uint *object, uint operand);
-uint __ovld atomic_fetch_or_explicit(volatile atomic_uint *object, uint operand, memory_order order);
-uint __ovld atomic_fetch_or_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope);
 int __ovld atomic_fetch_xor(volatile atomic_int *object, int operand);
-int __ovld atomic_fetch_xor_explicit(volatile atomic_int *object, int operand, memory_order order);
-int __ovld atomic_fetch_xor_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope);
 uint __ovld atomic_fetch_xor(volatile atomic_uint *object, uint operand);
-uint __ovld atomic_fetch_xor_explicit(volatile atomic_uint *object, uint operand, memory_order order);
-uint __ovld atomic_fetch_xor_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope);
 int __ovld atomic_fetch_and(volatile atomic_int *object, int operand);
-int __ovld atomic_fetch_and_explicit(volatile atomic_int *object, int operand, memory_order order);
-int __ovld atomic_fetch_and_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope);
 uint __ovld atomic_fetch_and(volatile atomic_uint *object, uint operand);
-uint __ovld atomic_fetch_and_explicit(volatile atomic_uint *object, uint operand, memory_order order);
-uint __ovld atomic_fetch_and_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope);
 int __ovld atomic_fetch_min(volatile atomic_int *object, int operand);
-int __ovld atomic_fetch_min_explicit(volatile atomic_int *object, int operand, memory_order order);
-int __ovld atomic_fetch_min_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope);
 uint __ovld atomic_fetch_min(volatile atomic_uint *object, uint operand);
-uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object, uint operand, memory_order order);
-uint __ovld atomic_fetch_min_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope);
 int __ovld atomic_fetch_max(volatile atomic_int *object, int operand);
-int __ovld atomic_fetch_max_explicit(volatile atomic_int *object, int operand, memory_order order);
-int __ovld atomic_fetch_max_explicit(volatile atomic_int *object, int operand, memory_order order, memory_scope scope);
 uint __ovld atomic_fetch_max(volatile atomic_uint *object, uint operand);
-uint __ovld atomic_fetch_max_explicit(volatile atomic_uint *object, uint operand, memory_order order);
-uint __ovld atomic_fetch_max_explicit(volatile atomic_uint *object, uint operand, memory_order order, memory_scope scope);
 
 #if defined(cl_

[PATCH] D105439: [clang] protects users from relying on libc++ detail headers

2021-07-07 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

I tried the following, but it doesn't work with modules, so it looks like a 
compiler solution is necessary.

  // in 
  #define _LIBCPP_PRIVATE_HEADER_ALLOWED
  
  // in <__algorithm/find.h>
  #ifndef _LIBCPP_PRIVATE_HEADER_ALLOWED
  #error This is a libc++ detail header. Please instead include .
  #endif


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105439

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


[PATCH] D105512: [AIX] Don't pass no-integrated-as by default

2021-07-07 Thread ChenZheng via Phabricator via cfe-commits
shchenz accepted this revision.
shchenz 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/D105512/new/

https://reviews.llvm.org/D105512

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


  1   2   >