[PATCH] D83369: hwasan: Don't pass the tagged-globals target-feature to non-aarch64 backends.

2020-07-07 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: pcc, vitalybuka, hctim.
Herald added subscribers: danielkiss, kristof.beyls.
Herald added a project: clang.

The other backends don't know what this feature is and print a
message to stderr.

I recently tried to rework some target feature stuff in X86 and
this unknown feature tripped an assert I added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83369

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/Driver/fsanitize.c


Index: clang/test/Driver/fsanitize.c
===
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -868,9 +868,7 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress 
-fsanitize-hwaddress-abi=platform %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-HWASAN-PLATFORM-ABI
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress 
-fsanitize-hwaddress-abi=foo %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-HWASAN-FOO-ABI
 // CHECK-HWASAN-INTERCEPTOR-ABI: "-default-function-attr" 
"hwasan-abi=interceptor"
-// CHECK-HWASAN-INTERCEPTOR-ABI: "-target-feature" "+tagged-globals"
 // CHECK-HWASAN-PLATFORM-ABI: "-default-function-attr" "hwasan-abi=platform"
-// CHECK-HWASAN-PLATFORM-ABI: "-target-feature" "+tagged-globals"
 // CHECK-HWASAN-FOO-ABI: error: invalid value 'foo' in 
'-fsanitize-hwaddress-abi=foo'
 
 // RUN: %clang -target x86_64-linux-gnu 
-fsanitize=address,pointer-compare,pointer-subtract %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-POINTER-ALL
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -1068,7 +1068,7 @@
 CmdArgs.push_back(Args.MakeArgString("hwasan-abi=" + HwasanAbi));
   }
 
-  if (Sanitizers.has(SanitizerKind::HWAddress)) {
+  if (Sanitizers.has(SanitizerKind::HWAddress) && TC.getTriple().isAArch64()) {
 CmdArgs.push_back("-target-feature");
 CmdArgs.push_back("+tagged-globals");
   }


Index: clang/test/Driver/fsanitize.c
===
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -868,9 +868,7 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -fsanitize-hwaddress-abi=platform %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-PLATFORM-ABI
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -fsanitize-hwaddress-abi=foo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-FOO-ABI
 // CHECK-HWASAN-INTERCEPTOR-ABI: "-default-function-attr" "hwasan-abi=interceptor"
-// CHECK-HWASAN-INTERCEPTOR-ABI: "-target-feature" "+tagged-globals"
 // CHECK-HWASAN-PLATFORM-ABI: "-default-function-attr" "hwasan-abi=platform"
-// CHECK-HWASAN-PLATFORM-ABI: "-target-feature" "+tagged-globals"
 // CHECK-HWASAN-FOO-ABI: error: invalid value 'foo' in '-fsanitize-hwaddress-abi=foo'
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address,pointer-compare,pointer-subtract %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-POINTER-ALL
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -1068,7 +1068,7 @@
 CmdArgs.push_back(Args.MakeArgString("hwasan-abi=" + HwasanAbi));
   }
 
-  if (Sanitizers.has(SanitizerKind::HWAddress)) {
+  if (Sanitizers.has(SanitizerKind::HWAddress) && TC.getTriple().isAArch64()) {
 CmdArgs.push_back("-target-feature");
 CmdArgs.push_back("+tagged-globals");
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83286: [analyzer][solver] Track symbol disequalities

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

This looks great to me but i'd very much rather have someone else have a look, 
just because of the nature of the problem (:




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1586
+  // 4. Update disequality relations
+  if (const ClassSet *DisequalToOther = DisequalityInfo.lookup(Other)) {
+ClassSet DisequalToThis = getDisequalClasses(State);

Nit: I think it's a bit messy to use `getDisequalClasses()` in some places but 
manual lookup in other places. Like, someone may change the function and 
believe that they changed the entire lookup mechanism but fail to notice that 
the function wasn't used consitently. I think this may be worth encapsulating.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1727
+
+  // Let's check if know anything about these two classes being not equal to
+  // each other.

Parse error; missing "we"?



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1913-1915
+// DisequalToDisequalSet is guaranteed to be non-null for consistent
+// disequality info.
+ClassSet NewSet = ClassSetFactory.remove(*DisequalToDisequalSet, 
Class);

I actually wouldn't mind duplicating a direct assertion here, given that 
consistency checks are pretty complicated on their own :)



Comment at: clang/test/Analysis/mutually_exclusive_null_fp.cpp:25
+
+  return compare(*aData, *bData);
+}

`// no-warning` please? These marks make tests a lot easier to understand when 
you break them 5 years later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83286



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


[PATCH] D81583: Update SystemZ ABI to handle C++20 [[no_unique_address]] attribute

2020-07-07 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added a comment.

Thanks for this patch!

If I understand correctly, only `isEmptyRecord`/`isEmptyField` and places 
checking any field is zero bit-width may need change for this? Since 
`isSingleElementStruct` and `isHomogeneousAggregate` just use them to skip 
empty fields in aggregate. I didn't see direct checking for empty fields on 
PowerPC. So all change needed on PPC seems to be generic. By enabling 
`AllowNoUniqueAddr` in these methods, case in 
https://lists.llvm.org/pipermail/llvm-dev/2020-July/143141.html can be 
correctly recognized as homogeneous aggregate.


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

https://reviews.llvm.org/D81583



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


[clang] 065fc1e - PR45521: Preserve the value kind when performing a standard conversion

2020-07-07 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-07-07T18:28:28-07:00
New Revision: 065fc1eafe7c6f67f8029bcd38e6864b3c429e35

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

LOG: PR45521: Preserve the value kind when performing a standard conversion
sequence on a glvalue expression.

If the sequence is supposed to perform an lvalue-to-rvalue conversion,
then one will be specified as the first conversion in the sequence.
Otherwise, one should not be invented.

Added: 


Modified: 
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaCXX/references.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 0a0bb3952cd8..d885920b6c14 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -4203,8 +4203,8 @@ Sema::PerformImplicitConversion(Expr *From, QualType 
ToType,
 break;
 
   case ICK_Compatible_Conversion:
-  From = ImpCastExprToType(From, ToType, CK_NoOp,
-   VK_RValue, /*BasePath=*/nullptr, CCK).get();
+From = ImpCastExprToType(From, ToType, CK_NoOp, From->getValueKind(),
+ /*BasePath=*/nullptr, CCK).get();
 break;
 
   case ICK_Writeback_Conversion:
@@ -4441,11 +4441,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType 
ToType,
 break;
 
   case ICK_Qualification: {
-// The qualification keeps the category of the inner expression, unless the
-// target type isn't a reference.
-ExprValueKind VK =
-ToType->isReferenceType() ? From->getValueKind() : VK_RValue;
-
+ExprValueKind VK = From->getValueKind();
 CastKind CK = CK_NoOp;
 
 if (ToType->isReferenceType() &&

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index d68be854aeeb..599e81d1b4d0 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -4709,7 +4709,7 @@ TryReferenceInit(Sema , Expr *Init, QualType DeclType,
   Sema::ReferenceConversions::NestedQualification)
  ? ICK_Qualification
  : ICK_Identity;
-ICS.Standard.FromTypePtr = T2.getAsOpaquePtr();
+ICS.Standard.setFromType(T2);
 ICS.Standard.setToType(0, T2);
 ICS.Standard.setToType(1, T1);
 ICS.Standard.setToType(2, T1);

diff  --git a/clang/test/SemaCXX/references.cpp 
b/clang/test/SemaCXX/references.cpp
index f30e16d990eb..eaab1ae833e4 100644
--- a/clang/test/SemaCXX/references.cpp
+++ b/clang/test/SemaCXX/references.cpp
@@ -201,3 +201,9 @@ namespace RefCollapseTypePrinting {
   template void add_rref(); // expected-note {{instantiation of}}
   template void add_rref(); // expected-note {{instantiation of}}
 }
+
+namespace PR45521 {
+  struct a { template a(const b * const&); };
+  int *d;
+  const a  = d;
+}



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


[PATCH] D82477: [lldb-vscode] Add Support for Module Event

2020-07-07 Thread Yifan Shen via Phabricator via cfe-commits
aelitashen updated this revision to Diff 276294.
aelitashen added a comment.

Add Path Verification in Test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82477

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/module/Makefile
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/test/API/tools/lldb-vscode/module/main.cpp
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Option/Arg.h"
@@ -434,6 +435,30 @@
 g_vsc.SendJSON(llvm::json::Value(std::move(bp_event)));
   }
 }
+  } else if (lldb::SBTarget::EventIsTargetEvent(event)) {
+if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded ||
+event_mask & lldb::SBTarget::eBroadcastBitModulesUnloaded ||
+event_mask & lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
+  int num_modules = lldb::SBTarget::GetNumModulesFromEvent(event);
+  for (int i = 0; i < num_modules; i++) {
+auto module = lldb::SBTarget::GetModuleAtIndexFromEvent(i, event);
+auto module_event = CreateEventObject("module");
+llvm::json::Value module_value = CreateModule(module);
+llvm::json::Object body;
+if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded) {
+  body.try_emplace("reason", "new");
+} else if (event_mask &
+lldb::SBTarget::eBroadcastBitModulesUnloaded) {
+  body.try_emplace("reason", "removed");
+} else if (event_mask &
+lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
+  body.try_emplace("reason", "changed");
+}
+body.try_emplace("module", module_value);
+module_event.try_emplace("body", std::move(body));
+g_vsc.SendJSON(llvm::json::Value(std::move(module_event)));
+  }
+}
   } else if (event.BroadcasterMatchesRef(g_vsc.broadcaster)) {
 if (event_mask & eBroadcastBitStopEventThread) {
   done = true;
Index: lldb/tools/lldb-vscode/VSCode.cpp
===
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -358,6 +358,11 @@
 lldb::SBTarget::eBroadcastBitBreakpointChanged);
 listener.StartListeningForEvents(this->broadcaster,
  eBroadcastBitStopEventThread);
+listener.StartListeningForEvents(
+  this->target.GetBroadcaster(),
+  lldb::SBTarget::eBroadcastBitModulesLoaded |
+  lldb::SBTarget::eBroadcastBitModulesUnloaded |
+  lldb::SBTarget::eBroadcastBitSymbolsLoaded);
   }
 }
 
Index: lldb/tools/lldb-vscode/JSONUtils.h
===
--- lldb/tools/lldb-vscode/JSONUtils.h
+++ lldb/tools/lldb-vscode/JSONUtils.h
@@ -13,6 +13,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "VSCodeForward.h"
+#include "lldb/API/SBModule.h"
 
 namespace lldb_vscode {
 
@@ -237,6 +238,16 @@
  llvm::Optional request_path = llvm::None,
  llvm::Optional request_line = llvm::None);
 
+/// Converts a LLDB module to a VS Code DAP module for use in "modules" events.
+///
+/// \param[in] module
+/// A LLDB module object to convert into a JSON value
+///
+/// \return
+/// A "Module" JSON object with that follows the formal JSON
+/// definition outlined by Microsoft.
+llvm::json::Value CreateModule(lldb::SBModule );
+
 /// Create a "Event" JSON object using \a event_name as the event name
 ///
 /// \param[in] event_name
Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -327,6 +327,41 @@
   return llvm::json::Value(std::move(object));
 }
 
+llvm::json::Value CreateModule(lldb::SBModule ) {
+  llvm::json::Object object;
+  if (!module.IsValid())
+return llvm::json::Value(std::move(object));
+  object.try_emplace("id", std::string(module.GetUUIDString()));
+  object.try_emplace("name", std::string(module.GetFileSpec().GetFilename()));
+  char module_path_arr[PATH_MAX];
+  module.GetFileSpec().GetPath(module_path_arr, sizeof(module_path_arr));
+  std::string module_path(module_path_arr);
+  object.try_emplace("path", module_path);
+  if 

[PATCH] D83364: [PowerPC][Power10] Implement Instruction definition and MC Tests for Load and Store VSX Vector with Zero or Sign Extend

2020-07-07 Thread Albion Fung via Phabricator via cfe-commits
Conanap created this revision.
Conanap added reviewers: power-llvm-team, PowerPC, saghir, nemanjai, hfinkel.
Conanap added projects: LLVM, clang, PowerPC.

Includes instruction defintion and MC Tests for above instructions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83364

Files:
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
  llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s


Index: llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
===
--- llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
+++ llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
@@ -405,3 +405,27 @@
 # CHECK-BE: vinsdrx 1, 2, 3   # encoding: 
[0x10,0x22,0x1b,0xcf]
 # CHECK-LE: vinsdrx 1, 2, 3   # encoding: 
[0xcf,0x1b,0x22,0x10]
 vinsdrx 1, 2, 3
+# CHECK-BE: lxvrbx 32, 1, 2   # encoding: 
[0x7c,0x01,0x10,0x1b]
+# CHECK-LE: lxvrbx 32, 1, 2   # encoding: 
[0x1b,0x10,0x01,0x7c]
+lxvrbx 32, 1, 2
+# CHECK-BE: lxvrhx 33, 1, 2   # encoding: 
[0x7c,0x21,0x10,0x5b]
+# CHECK-LE: lxvrhx 33, 1, 2   # encoding: 
[0x5b,0x10,0x21,0x7c]
+lxvrhx 33, 1, 2
+# CHECK-BE: lxvrdx 34, 1, 2   # encoding: 
[0x7c,0x41,0x10,0xdb]
+# CHECK-LE: lxvrdx 34, 1, 2   # encoding: 
[0xdb,0x10,0x41,0x7c]
+lxvrdx 34, 1, 2
+# CHECK-BE: lxvrwx 35, 1, 2   # encoding: 
[0x7c,0x61,0x10,0x9b]
+# CHECK-LE: lxvrwx 35, 1, 2   # encoding: 
[0x9b,0x10,0x61,0x7c]
+lxvrwx 35, 1, 2
+# CHECK-BE: stxvrbx 32, 3, 1  # encoding: 
[0x7c,0x03,0x09,0x1b]
+# CHECK-LE: stxvrbx 32, 3, 1  # encoding: 
[0x1b,0x09,0x03,0x7c]
+stxvrbx 32, 3, 1
+# CHECK-BE: stxvrhx 33, 3, 1  # encoding: 
[0x7c,0x23,0x09,0x5b]
+# CHECK-LE: stxvrhx 33, 3, 1  # encoding: 
[0x5b,0x09,0x23,0x7c]
+stxvrhx 33, 3, 1
+# CHECK-BE: stxvrwx 34, 3, 1  # encoding: 
[0x7c,0x43,0x09,0x9b]
+# CHECK-LE: stxvrwx 34, 3, 1  # encoding: 
[0x9b,0x09,0x43,0x7c]
+stxvrwx 34, 3, 1
+# CHECK-BE: stxvrdx 35, 3, 1  # encoding: 
[0x7c,0x63,0x09,0xdb]
+# CHECK-LE: stxvrdx 35, 3, 1  # encoding: 
[0xdb,0x09,0x63,0x7c]
+stxvrdx 35, 3, 1
Index: llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
===
--- llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
+++ llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
@@ -278,3 +278,27 @@
 
 # CHECK: vinsdrx 1, 2, 3
 0x10 0x22 0x1b 0xcf
+
+# CHECK: lxvrbx 32, 1, 2
+0x7c 0x01 0x10 0x1b
+
+# CHECK: lxvrhx 33, 1, 2
+0x7c 0x21 0x10 0x5b
+
+# CHECK: lxvrdx 34, 1, 2
+0x7c 0x41 0x10 0xdb
+
+# CHECK: lxvrwx 35, 1, 2
+0x7c 0x61 0x10 0x9b
+
+# CHECK: stxvrbx 32, 3, 1
+0x7c 0x03 0x09 0x1b
+
+# CHECK: stxvrhx 33, 3, 1
+0x7c 0x23 0x09 0x5b
+
+# CHECK: stxvrwx 34, 3, 1
+0x7c 0x43 0x09 0x9b
+
+# CHECK: stxvrdx 35, 3, 1
+0x7c 0x63 0x09 0xdb
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -428,6 +428,22 @@
 def PrefixInstrs : Predicate<"Subtarget->hasPrefixInstrs()">;
 def IsISA3_1 : Predicate<"Subtarget->isISA3_1()">;
 
+let mayLoad = 1, mayStore = 0, Predicates = [IsISA3_1] in {
+  // The XFormMemOp flag is set on the instruction format.
+  def LXVRBX : X_XT6_RA5_RB5<31, 13, "lxvrbx", vsrc, []>;
+  def LXVRHX : X_XT6_RA5_RB5<31, 45, "lxvrhx", vsrc, []>;
+  def LXVRWX : X_XT6_RA5_RB5<31, 77, "lxvrwx", vsrc, []>;
+  def LXVRDX : X_XT6_RA5_RB5<31, 109, "lxvrdx", vsrc, []>;
+}
+
+let mayLoad = 0, mayStore = 1, Predicates = [IsISA3_1] in {
+  // The XFormMemOp flag is set on the instruction format.
+  def STXVRBX : X_XS6_RA5_RB5<31, 141, "stxvrbx", vsrc, []>;
+  def STXVRHX : X_XS6_RA5_RB5<31, 173, "stxvrhx", vsrc, []>;
+  def STXVRWX : X_XS6_RA5_RB5<31, 205, "stxvrwx", vsrc, []>;
+  def STXVRDX : X_XS6_RA5_RB5<31, 237, "stxvrdx", vsrc, []>;
+}
+
 let Predicates = [PrefixInstrs] in {
   let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
 defm PADDI8 :


Index: llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
===
--- llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
+++ llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
@@ -405,3 +405,27 @@
 # CHECK-BE: vinsdrx 1, 2, 3   # encoding: [0x10,0x22,0x1b,0xcf]
 # CHECK-LE: vinsdrx 1, 2, 3   # encoding: [0xcf,0x1b,0x22,0x10]
 vinsdrx 1, 2, 3
+# CHECK-BE: lxvrbx 32, 1, 2   # encoding: [0x7c,0x01,0x10,0x1b]
+# CHECK-LE: lxvrbx 32, 1, 2

[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-07-07 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1254
+  // space or zero-extent array.
+  if (DefaultsToAIXPowerAlignment && !getDataSize().isZero()) {
+PreferredBaseAlign = BaseAlign;

This needs to check `HandledFirstNonOverlappingEmptyField`:
```
struct A {
  char x[0];
};
struct B {
  double d;
};
struct C : A, B { char x; } c;
```



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1255
+  if (DefaultsToAIXPowerAlignment && !getDataSize().isZero()) {
+PreferredBaseAlign = BaseAlign;
+  }

Note that `PreferredBaseAlign` is only truly meaningful after this line, and 
related fields, such as `UnpackedPreferredBaseAlign`, require similar 
treatment. With `UnpackedAlignTo` being dependent on a meaningful value of 
`UnpackedPreferredBaseAlign`, it needs an update here as well.

Consider the following source. Noting that `C` and `D` are identical except for 
the packed attribute and yield identical layout properties despite that 
difference, we should be getting a `-Wpacked` warning with `-Wpacked` (but it 
is missing).
```
struct A {
  double d;
};

struct B {
  char x[8];
};

struct [[gnu::packed]] C : B, A { // expected-warning {{packed attribute is 
unnecessary}}
  char x alignas(4)[8];
} c;

struct D : B, A {
  char x alignas(4)[8];
} d;
```
```
*** Dumping AST Record Layout
 0 | struct C
 0 |   struct B (base)
 0 | char [8] x
 8 |   struct A (base)
 8 | double d
16 |   char [8] x
   | [sizeof=24, dsize=24, align=4, preferredalign=4,
   |  nvsize=24, nvalign=4, preferrednvalign=4]
```
```
*** Dumping AST Record Layout
 0 | struct D
 0 |   struct B (base)
 0 | char [8] x
 8 |   struct A (base)
 8 | double d
16 |   char [8] x
   | [sizeof=24, dsize=24, align=4, preferredalign=4,
   |  nvsize=24, nvalign=4, preferrednvalign=4]
```



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

https://reviews.llvm.org/D79719



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


[PATCH] D83004: [UpdateCCTestChecks] Include generated functions if asked

2020-07-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: llvm/utils/update_cc_test_checks.py:133
+  parser.add_argument('--include-generated-funcs', action='store_true',
+  help='Output checks for functions not in source')
   parser.add_argument('tests', nargs='+')

greened wrote:
> jdoerfert wrote:
> > greened wrote:
> > > greened wrote:
> > > > jdoerfert wrote:
> > > > > I think this should go into common.py (after D78618). I would also 
> > > > > make this the default but OK.
> > > > Yes I suppose it should in case `opt` and friends generate functions.  
> > > > I hadn't considered that use-case.
> > > > 
> > > > While I would like to make it default unfortunately it would require 
> > > > updating a bunch of the existing clang tests which doesn't seem too 
> > > > friendly.  See the patch update comment for details.
> > > > 
> > > Just realized it wouldn't necessarily require regeneration of tests, it 
> > > would just cause regenerated tests to change a lot when they are 
> > > eventually regenerated.  We should discuss as to whether that's 
> > > acceptable.  I think for now this should be non-default to at least get 
> > > the functionality in without disturbing existing users and then we can 
> > > discuss a separate change to make it default.
> > > 
> > > It's also possible we could change how clang orders functions.  I 
> > > discovered there's a difference in clang 10 vs. 11 in the order functions 
> > > are output when OpenMP outlining happens.  clang 10 seems to preserve the 
> > > source order of functions and clang 11 does not.  Perhaps that needs to 
> > > be fixed as I don't know whether that change was intentional or not.
> > Best case, without the option the original behavior is preserved. Is that 
> > not the case?
> That's right.  I was referring to making this behavior default.  If we do 
> that, we could clean up the script code a bit but it would mean clang tests 
> would change pretty dramatically when they are regenerated.  If we fix the 
> clang output, the test changes wouldn't be so dramatic.
> 
> The way clang is behaving now, I would expect any tests that use `-fopenmp`, 
> have multiple functions with OpenMP regions and use function prototypes for 
> some of those functions would break given clang's reordering of function 
> definitions.  Perhaps we don't have any tests like that though.
We (almost) do not have OpenMP tests with autogenerated test lines. Partially, 
because we do not test new functions. I would really like this to be available 
for OpenMP, both in _cc_ and IR tests. If people can opt out of this, 
especially if the default is "off", the ordering is not a problem (IMHO). With 
UTC_ARGS we also remember the choice so I really don't see the downside to this 
being in the common part for all scripts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83004



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


[PATCH] D83317: [Sema] Teach -Wcast-align to compute alignment of CXXThisExpr

2020-07-07 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG04027052a72f: [Sema] Teach -Wcast-align to compute alignment 
of CXXThisExpr (authored by ahatanak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83317

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaCXX/warn-cast-align.cpp


Index: clang/test/SemaCXX/warn-cast-align.cpp
===
--- clang/test/SemaCXX/warn-cast-align.cpp
+++ clang/test/SemaCXX/warn-cast-align.cpp
@@ -44,9 +44,16 @@
   c = IntPtr(P);
 }
 
+struct __attribute__((aligned(16))) AlignedS {
+  char m[16];
+};
+
 struct __attribute__((aligned(16))) A {
   char m0[16];
   char m1[16];
+  AlignedS *getAlignedS() {
+return (AlignedS *)m1;
+  }
 };
 
 struct B0 {
@@ -92,6 +99,9 @@
 
 struct D5 : virtual D0 {
   char m0[16];
+  AlignedS *get() {
+return (AlignedS *)m0; // expected-warning {{cast from 'char *' to 
'AlignedS *'}}
+  }
 };
 
 struct D6 : virtual D5 {
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13560,12 +13560,14 @@
   }
   case Stmt::MemberExprClass: {
 auto *ME = cast(E);
-if (ME->isArrow())
-  break;
 auto *FD = dyn_cast(ME->getMemberDecl());
 if (!FD || FD->getType()->isReferenceType())
   break;
-auto P = getBaseAlignmentAndOffsetFromLValue(ME->getBase(), Ctx);
+Optional> P;
+if (ME->isArrow())
+  P = getBaseAlignmentAndOffsetFromPtr(ME->getBase(), Ctx);
+else
+  P = getBaseAlignmentAndOffsetFromLValue(ME->getBase(), Ctx);
 if (!P)
   break;
 const ASTRecordLayout  = Ctx.getASTRecordLayout(FD->getParent());
@@ -13629,6 +13631,11 @@
 }
 break;
   }
+  case Stmt::CXXThisExprClass: {
+auto *RD = E->getType()->getPointeeType()->getAsCXXRecordDecl();
+CharUnits Alignment = Ctx.getASTRecordLayout(RD).getNonVirtualAlignment();
+return std::make_pair(Alignment, CharUnits::Zero());
+  }
   case Stmt::UnaryOperatorClass: {
 auto *UO = cast(E);
 if (UO->getOpcode() == UO_AddrOf)


Index: clang/test/SemaCXX/warn-cast-align.cpp
===
--- clang/test/SemaCXX/warn-cast-align.cpp
+++ clang/test/SemaCXX/warn-cast-align.cpp
@@ -44,9 +44,16 @@
   c = IntPtr(P);
 }
 
+struct __attribute__((aligned(16))) AlignedS {
+  char m[16];
+};
+
 struct __attribute__((aligned(16))) A {
   char m0[16];
   char m1[16];
+  AlignedS *getAlignedS() {
+return (AlignedS *)m1;
+  }
 };
 
 struct B0 {
@@ -92,6 +99,9 @@
 
 struct D5 : virtual D0 {
   char m0[16];
+  AlignedS *get() {
+return (AlignedS *)m0; // expected-warning {{cast from 'char *' to 'AlignedS *'}}
+  }
 };
 
 struct D6 : virtual D5 {
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13560,12 +13560,14 @@
   }
   case Stmt::MemberExprClass: {
 auto *ME = cast(E);
-if (ME->isArrow())
-  break;
 auto *FD = dyn_cast(ME->getMemberDecl());
 if (!FD || FD->getType()->isReferenceType())
   break;
-auto P = getBaseAlignmentAndOffsetFromLValue(ME->getBase(), Ctx);
+Optional> P;
+if (ME->isArrow())
+  P = getBaseAlignmentAndOffsetFromPtr(ME->getBase(), Ctx);
+else
+  P = getBaseAlignmentAndOffsetFromLValue(ME->getBase(), Ctx);
 if (!P)
   break;
 const ASTRecordLayout  = Ctx.getASTRecordLayout(FD->getParent());
@@ -13629,6 +13631,11 @@
 }
 break;
   }
+  case Stmt::CXXThisExprClass: {
+auto *RD = E->getType()->getPointeeType()->getAsCXXRecordDecl();
+CharUnits Alignment = Ctx.getASTRecordLayout(RD).getNonVirtualAlignment();
+return std::make_pair(Alignment, CharUnits::Zero());
+  }
   case Stmt::UnaryOperatorClass: {
 auto *UO = cast(E);
 if (UO->getOpcode() == UO_AddrOf)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0402705 - [Sema] Teach -Wcast-align to compute alignment of CXXThisExpr

2020-07-07 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2020-07-07T17:45:04-07:00
New Revision: 04027052a72f982c9e09472427ec7339415fb777

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

LOG: [Sema] Teach -Wcast-align to compute alignment of CXXThisExpr

This fixes https://bugs.llvm.org/show_bug.cgi?id=46605.

rdar://problem/65158878

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 77858b17d62c..efaf36a69306 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -13560,12 +13560,14 @@ static getBaseAlignmentAndOffsetFromLValue(const Expr 
*E, ASTContext ) {
   }
   case Stmt::MemberExprClass: {
 auto *ME = cast(E);
-if (ME->isArrow())
-  break;
 auto *FD = dyn_cast(ME->getMemberDecl());
 if (!FD || FD->getType()->isReferenceType())
   break;
-auto P = getBaseAlignmentAndOffsetFromLValue(ME->getBase(), Ctx);
+Optional> P;
+if (ME->isArrow())
+  P = getBaseAlignmentAndOffsetFromPtr(ME->getBase(), Ctx);
+else
+  P = getBaseAlignmentAndOffsetFromLValue(ME->getBase(), Ctx);
 if (!P)
   break;
 const ASTRecordLayout  = Ctx.getASTRecordLayout(FD->getParent());
@@ -13629,6 +13631,11 @@ static getBaseAlignmentAndOffsetFromPtr(const Expr *E, 
ASTContext ) {
 }
 break;
   }
+  case Stmt::CXXThisExprClass: {
+auto *RD = E->getType()->getPointeeType()->getAsCXXRecordDecl();
+CharUnits Alignment = Ctx.getASTRecordLayout(RD).getNonVirtualAlignment();
+return std::make_pair(Alignment, CharUnits::Zero());
+  }
   case Stmt::UnaryOperatorClass: {
 auto *UO = cast(E);
 if (UO->getOpcode() == UO_AddrOf)

diff  --git a/clang/test/SemaCXX/warn-cast-align.cpp 
b/clang/test/SemaCXX/warn-cast-align.cpp
index 53cd75fb1405..1e84ba9cd67a 100644
--- a/clang/test/SemaCXX/warn-cast-align.cpp
+++ b/clang/test/SemaCXX/warn-cast-align.cpp
@@ -44,9 +44,16 @@ void test1(void *P) {
   c = IntPtr(P);
 }
 
+struct __attribute__((aligned(16))) AlignedS {
+  char m[16];
+};
+
 struct __attribute__((aligned(16))) A {
   char m0[16];
   char m1[16];
+  AlignedS *getAlignedS() {
+return (AlignedS *)m1;
+  }
 };
 
 struct B0 {
@@ -92,6 +99,9 @@ struct __attribute__((aligned(16))) D4 : virtual D2 {
 
 struct D5 : virtual D0 {
   char m0[16];
+  AlignedS *get() {
+return (AlignedS *)m0; // expected-warning {{cast from 'char *' to 
'AlignedS *'}}
+  }
 };
 
 struct D6 : virtual D5 {



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


[PATCH] D82728: [clang] Add -Wsuggest-override

2020-07-07 Thread Logan Smith via Phabricator via cfe-commits
logan-5 marked an inline comment as done.
logan-5 added inline comments.



Comment at: clang/test/SemaCXX/warn-suggest-destructor-override:1
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify 
-Wsuggest-destructor-override
+

logan-5 wrote:
> dblaikie wrote:
> > Does GCC have suggest-destructor-override as a separate warning too?
> It does not. In fact, there's no way to get GCC to warn about destructors 
> missing `override`. (Which is somewhat defensible, since `override` is really 
> great for preventing subtle signature mismatches/typos, but destructors don't 
> really have those problems.) However, Clang already has a destructor-specific 
> flavor of the inconsistent-override warning, so I added 
> -Wsuggest-destructor-override for symmetry with 
> -Winconsistent-missing-[destructor-]override.
Note that this really is the best of both worlds, since it lets Clang's 
-Wsuggest-override behave identically to GCC's (not warning on destructors), as 
well as be consistent with its own already existing override warnings (with a 
special extra flag to enable warnings for destructors).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728



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


[PATCH] D82728: [clang] Add -Wsuggest-override

2020-07-07 Thread Logan Smith via Phabricator via cfe-commits
logan-5 marked an inline comment as done.
logan-5 added inline comments.



Comment at: clang/test/SemaCXX/warn-suggest-destructor-override:1
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify 
-Wsuggest-destructor-override
+

dblaikie wrote:
> Does GCC have suggest-destructor-override as a separate warning too?
It does not. In fact, there's no way to get GCC to warn about destructors 
missing `override`. (Which is somewhat defensible, since `override` is really 
great for preventing subtle signature mismatches/typos, but destructors don't 
really have those problems.) However, Clang already has a destructor-specific 
flavor of the inconsistent-override warning, so I added 
-Wsuggest-destructor-override for symmetry with 
-Winconsistent-missing-[destructor-]override.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728



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


[PATCH] D82477: [lldb-vscode] Add Support for Module Event

2020-07-07 Thread Greg Clayton via Phabricator via cfe-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

Just test for paths and this will be good to go!




Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:35
+self.assertEqual(program_basename, program_module['name'])
+self.assertIn('path', program_module, 'make sure path is in module')
+self.assertTrue('symbolFilePath' not in program_module, 'Make sure 
a.out.stripped has no debug info')

add a check for the path:
```
self.assertEqual(program, program_module['path'])
```



Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:42
+program_module = active_modules[program_basename]
+self.assertEqual(program_basename, program_module['name'])
+self.assertEqual('Symbols loaded.', program_module['symbolStatus'])

check 'path' again here.



Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:47
+self.assertIn('addressRange', program_module)
\ No newline at end of file


add a newline


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82477



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


[PATCH] D83362: Fix warning caused by __builtin_expect_with_probability was not handled in places such as constant folding

2020-07-07 Thread Zhi Zhuang via Phabricator via cfe-commits
LukeZhuang created this revision.
LukeZhuang added reviewers: lebedev.ri, erichkeane, xbolva00, RKSimon, rsmith.
LukeZhuang added a project: clang.
Herald added subscribers: cfe-commits, martong.

Previously some places that should have handled 
`__builtin_expect_with_probability` is missing, so in some case it acts 
differently than `__builtin_expect`.
For example it was not handled in constant folding, thus in the following 
program, the "if" condition should be constantly true and folded, but 
previously it was not handled and cause warning "control may reach end of 
non-void function" (while `__builtin_expect` does not):

  __attribute__((noreturn)) extern void bar();
  int foo(int x, int y) {
if (y) {
  if (__builtin_expect_with_probability(1, 1, 1))
bar();
}
 else
  return 0;
  }

Now it's fixed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83362

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  clang/test/Sema/builtin-expect-with-probability.cpp


Index: clang/test/Sema/builtin-expect-with-probability.cpp
===
--- clang/test/Sema/builtin-expect-with-probability.cpp
+++ clang/test/Sema/builtin-expect-with-probability.cpp
@@ -1,4 +1,16 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+
+__attribute__((noreturn)) extern void bar();
+
+int test_no_warn(int x) {
+  if (x) {
+if (__builtin_expect_with_probability(1, 1, 1))
+  bar();
+  } else {
+return 0;
+  }
+}  // should not emit warn "control may reach end of non-void function" here 
since expr is constantly true, so the "if(__bui..)" should be constantly true 
condition and be ignored
+
 extern int global;
 
 struct S {
Index: clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
@@ -64,10 +64,12 @@
 
   case Builtin::BI__builtin_unpredictable:
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
   case Builtin::BI__builtin_assume_aligned:
   case Builtin::BI__builtin_addressof: {
-// For __builtin_unpredictable, __builtin_expect, and
-// __builtin_assume_aligned, just return the value of the subexpression.
+// For __builtin_unpredictable, __builtin_expect,
+// __builtin_expect_with_probability and __builtin_assume_aligned,
+// just return the value of the subexpression.
 // __builtin_addressof is going from a reference to a pointer, but those
 // are represented the same way in the analyzer.
 assert (Call.getNumArgs() > 0);
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11200,6 +11200,7 @@
   }
 
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
 return Visit(E->getArg(0));
 
   case Builtin::BI__builtin_ffs:


Index: clang/test/Sema/builtin-expect-with-probability.cpp
===
--- clang/test/Sema/builtin-expect-with-probability.cpp
+++ clang/test/Sema/builtin-expect-with-probability.cpp
@@ -1,4 +1,16 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+
+__attribute__((noreturn)) extern void bar();
+
+int test_no_warn(int x) {
+  if (x) {
+if (__builtin_expect_with_probability(1, 1, 1))
+  bar();
+  } else {
+return 0;
+  }
+}  // should not emit warn "control may reach end of non-void function" here since expr is constantly true, so the "if(__bui..)" should be constantly true condition and be ignored
+
 extern int global;
 
 struct S {
Index: clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
@@ -64,10 +64,12 @@
 
   case Builtin::BI__builtin_unpredictable:
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
   case Builtin::BI__builtin_assume_aligned:
   case Builtin::BI__builtin_addressof: {
-// For __builtin_unpredictable, __builtin_expect, and
-// __builtin_assume_aligned, just return the value of the subexpression.
+// For __builtin_unpredictable, __builtin_expect,
+// __builtin_expect_with_probability and __builtin_assume_aligned,
+// just return the value of the subexpression.
 // __builtin_addressof is going from a reference to a pointer, but those
 // are represented the same way in the analyzer.
 assert (Call.getNumArgs() > 0);
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ 

[PATCH] D82728: [clang] Add -Wsuggest-override

2020-07-07 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Generally looks good to me (description/commit message should be updated now 
that the inconsistent inconsistency is no longer an issue)




Comment at: clang/test/SemaCXX/warn-suggest-destructor-override:1
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify 
-Wsuggest-destructor-override
+

Does GCC have suggest-destructor-override as a separate warning too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728



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


[PATCH] D82477: [lldb-vscode] Add Support for Module Event

2020-07-07 Thread Yifan Shen via Phabricator via cfe-commits
aelitashen updated this revision to Diff 276274.
aelitashen added a comment.

Fix messy diff stack


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82477

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/module/Makefile
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/test/API/tools/lldb-vscode/module/main.cpp
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Option/Arg.h"
@@ -434,6 +435,30 @@
 g_vsc.SendJSON(llvm::json::Value(std::move(bp_event)));
   }
 }
+  } else if (lldb::SBTarget::EventIsTargetEvent(event)) {
+if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded ||
+event_mask & lldb::SBTarget::eBroadcastBitModulesUnloaded ||
+event_mask & lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
+  int num_modules = lldb::SBTarget::GetNumModulesFromEvent(event);
+  for (int i = 0; i < num_modules; i++) {
+auto module = lldb::SBTarget::GetModuleAtIndexFromEvent(i, event);
+auto module_event = CreateEventObject("module");
+llvm::json::Value module_value = CreateModule(module);
+llvm::json::Object body;
+if (event_mask & lldb::SBTarget::eBroadcastBitModulesLoaded) {
+  body.try_emplace("reason", "new");
+} else if (event_mask &
+lldb::SBTarget::eBroadcastBitModulesUnloaded) {
+  body.try_emplace("reason", "removed");
+} else if (event_mask &
+lldb::SBTarget::eBroadcastBitSymbolsLoaded) {
+  body.try_emplace("reason", "changed");
+}
+body.try_emplace("module", module_value);
+module_event.try_emplace("body", std::move(body));
+g_vsc.SendJSON(llvm::json::Value(std::move(module_event)));
+  }
+}
   } else if (event.BroadcasterMatchesRef(g_vsc.broadcaster)) {
 if (event_mask & eBroadcastBitStopEventThread) {
   done = true;
Index: lldb/tools/lldb-vscode/VSCode.cpp
===
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -358,6 +358,11 @@
 lldb::SBTarget::eBroadcastBitBreakpointChanged);
 listener.StartListeningForEvents(this->broadcaster,
  eBroadcastBitStopEventThread);
+listener.StartListeningForEvents(
+  this->target.GetBroadcaster(),
+  lldb::SBTarget::eBroadcastBitModulesLoaded |
+  lldb::SBTarget::eBroadcastBitModulesUnloaded |
+  lldb::SBTarget::eBroadcastBitSymbolsLoaded);
   }
 }
 
Index: lldb/tools/lldb-vscode/JSONUtils.h
===
--- lldb/tools/lldb-vscode/JSONUtils.h
+++ lldb/tools/lldb-vscode/JSONUtils.h
@@ -13,6 +13,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/JSON.h"
 #include "VSCodeForward.h"
+#include "lldb/API/SBModule.h"
 
 namespace lldb_vscode {
 
@@ -237,6 +238,16 @@
  llvm::Optional request_path = llvm::None,
  llvm::Optional request_line = llvm::None);
 
+/// Converts a LLDB module to a VS Code DAP module for use in "modules" events.
+///
+/// \param[in] module
+/// A LLDB module object to convert into a JSON value
+///
+/// \return
+/// A "Module" JSON object with that follows the formal JSON
+/// definition outlined by Microsoft.
+llvm::json::Value CreateModule(lldb::SBModule );
+
 /// Create a "Event" JSON object using \a event_name as the event name
 ///
 /// \param[in] event_name
Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -327,6 +327,41 @@
   return llvm::json::Value(std::move(object));
 }
 
+llvm::json::Value CreateModule(lldb::SBModule ) {
+  llvm::json::Object object;
+  if (!module.IsValid())
+return llvm::json::Value(std::move(object));
+  object.try_emplace("id", std::string(module.GetUUIDString()));
+  object.try_emplace("name", std::string(module.GetFileSpec().GetFilename()));
+  char module_path_arr[PATH_MAX];
+  module.GetFileSpec().GetPath(module_path_arr, sizeof(module_path_arr));
+  std::string module_path(module_path_arr);
+  object.try_emplace("path", module_path);
+  if (module.GetNumCompileUnits() > 0) {

[PATCH] D71739: [AssumeBundles] Use operand bundles to encode alignment assumptions

2020-07-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.

LGTM. @lebedev.ri ?




Comment at: llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp:227
   }
-
-  if (!AAPtr)
-return false;
-
-  // Sign extend the offset to 64 bits (so that it is like all of the other
-  // expressions).
-  unsigned OffSCEVBits = OffSCEV->getType()->getPrimitiveSizeInBits();
-  if (OffSCEVBits < 64)
-OffSCEV = SE->getSignExtendExpr(OffSCEV, Int64Ty);
-  else if (OffSCEVBits > 64)
-return false;
-
-  AAPtr = AAPtr->stripPointerCasts();
-  return true;
+  return false;
 }

Early exit please.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71739



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


[PATCH] D79147: Switch to using -debug-info-kind=constructor as default (from =limited)

2020-07-07 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Could you include some comparative data in the description/commit message 
demonstrating this generally ends up emitting all the same types for a clang 
build before/after (& explanations for a sample of any differences)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79147



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


[PATCH] D83176: [OpenMPIRBuilder][Fix] Move llvm::omp::types to OpenMPIRBuilder.

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

LGTM.




Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:1125
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
+}

While we are here, remove `uninitializeTypes`



Comment at: llvm/lib/Transforms/IPO/OpenMPOpt.cpp:313
   {
\
 SmallVector ArgsTypes({__VA_ARGS__});   
\
 Function *F = M.getFunction(_Name);
\

hoyFB wrote:
> sstefan1 wrote:
> > I wasn't sure how to handle `__VA_ARGS__` here, since we would need 
> > `OMPBuilder` in front of every type. 
> > That is why helper macros above exist. The problem with this is that this 
> > creates some unused variables in `OpenMPOpt`.
> > 
> > Not sure if `-Wno-unused-variable` would be a good thing to do temporarily? 
> > Is there another way to handle `__VA_ARGS__` here?
> Could it be possible to use `OMPBuilder. _Name`, `OMPBuilder. _ReturnType` 
> everywhere?
Since this will (soonish) be replaced by tablegen definitions we can apply the 
following workaround:

Keep your helper macros but add
`(void) VarName;`
after each declaration :) 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83176



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


[PATCH] D82906: [flang][openmp] Use common Directive and Clause enum from llvm/Frontend

2020-07-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

YAY :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82906



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


[clang] 64788d7 - [clang] Include missing LangOpts in `getModuleHash`.

2020-07-07 Thread Michael Spencer via cfe-commits

Author: Michael Spencer
Date: 2020-07-07T17:13:23-06:00
New Revision: 64788d7d5377345af5e3080d26cb6a76c324ab5b

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

LOG: [clang] Include missing LangOpts in `getModuleHash`.

`ObjCRuntime` and `CommentOpts.BlockCommandNames` are checked by
`ASTReader::checkLanguageOptions`, but are not part of the module
context hash. This can lead to errors when using implicit modules if
different TUs have different values for these options when using the
same module cache.

This was not hit very often due to the rare usage of
`-fblock-command-names=` and that `ObjCRuntime` is by default set by
the target triple, which is part of the existing context hash.

Added: 


Modified: 
clang/include/clang/Basic/ObjCRuntime.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Modules/context-hash.c
llvm/include/llvm/Support/VersionTuple.h

Removed: 




diff  --git a/clang/include/clang/Basic/ObjCRuntime.h 
b/clang/include/clang/Basic/ObjCRuntime.h
index 1c4a69269dee..26403bfa98c9 100644
--- a/clang/include/clang/Basic/ObjCRuntime.h
+++ b/clang/include/clang/Basic/ObjCRuntime.h
@@ -476,6 +476,10 @@ class ObjCRuntime {
   friend bool operator!=(const ObjCRuntime , const ObjCRuntime ) {
 return !(left == right);
   }
+
+  friend llvm::hash_code hash_value(const ObjCRuntime ) {
+return llvm::hash_combine(OCR.getKind(), OCR.getVersion());
+  }
 };
 
 raw_ostream <<(raw_ostream , const ObjCRuntime );

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index f58854cd9e08..6f6af917e3a3 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3852,6 +3852,10 @@ std::string CompilerInvocation::getModuleHash() const {
   for (StringRef Feature : LangOpts->ModuleFeatures)
 code = hash_combine(code, Feature);
 
+  code = hash_combine(code, LangOpts->ObjCRuntime);
+  const auto  = LangOpts->CommentOpts.BlockCommandNames;
+  code = hash_combine(code, hash_combine_range(BCN.begin(), BCN.end()));
+
   // Extend the signature with the target options.
   code = hash_combine(code, TargetOpts->Triple, TargetOpts->CPU,
   TargetOpts->ABI);

diff  --git a/clang/test/Modules/context-hash.c 
b/clang/test/Modules/context-hash.c
index 33dfb2f15a2c..8bb7422f6a54 100644
--- a/clang/test/Modules/context-hash.c
+++ b/clang/test/Modules/context-hash.c
@@ -1,3 +1,6 @@
+// This test verifies that only strict hashing includes search paths and
+// diagnostics in the module context hash.
+
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fsyntax-only -internal-isystem \
 // RUN:   %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps \
@@ -20,8 +23,25 @@
 // RUN: echo %t > %t.path
 // RUN: cat %t.path %t1 %t2 %t3 %t4 | FileCheck %s
 
-// This test verifies that only strict hashing includes search paths and
-// diagnostics in the module context hash.
+// This tests things verified by ASTReader::checkLanguageOptions that are not
+// part of LangOpts.def.
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -internal-isystem \
+// RUN:   %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t -x objective-c %s -Rmodule-build 2> %t1
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -internal-isystem \
+// RUN:   %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps \
+// RUN:   -fobjc-runtime=macosx-1.0.0.0 \
+// RUN:   -fmodules-cache-path=%t -x objective-c %s -Rmodule-build 2> %t2
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -internal-isystem \
+// RUN:   %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps \
+// RUN:   -fcomment-block-commands=lp,bj \
+// RUN:   -fmodules-cache-path=%t -x objective-c %s -Rmodule-build 2> %t3
+// RUN: echo %t > %t.path
+// RUN: cat %t.path %t1 %t2 %t3 | FileCheck --check-prefix=LANGOPTS %s
 
 #include 
 
@@ -32,3 +52,10 @@
 // CHECK: cstd-[[AST_HASH]].pcm'
 // CHECK-NOT: building module 'cstd' as '{{.*[/\\]}}[[CONTEXT_HASH]]{{[/\\]}}
 // CHECK: cstd-[[AST_HASH]].pcm'
+
+// LANGOPTS: [[PREFIX:(.*[/\\])+[a-zA-Z0-9.-]+]]
+// LANGOPTS: building module 'cstd' as 
'[[PREFIX]]{{[/\\]}}[[CONTEXT_HASH:[A-Z0-9]+]]{{[/\\]}}cstd-[[AST_HASH:[A-Z0-9]+]].pcm'
+// LANGOPTS-NOT: building module 'cstd' as 
'{{.*[/\\]}}[[CONTEXT_HASH]]{{[/\\]}}
+// LANGOPTS: cstd-[[AST_HASH]].pcm'
+// LANGOPTS-NOT: building module 'cstd' as 
'{{.*[/\\]}}[[CONTEXT_HASH]]{{[/\\]}}
+// LANGOPTS: cstd-[[AST_HASH]].pcm'

diff  --git a/llvm/include/llvm/Support/VersionTuple.h 
b/llvm/include/llvm/Support/VersionTuple.h
index ad89e40f0f14..6f3711f06f1a 100644
--- a/llvm/include/llvm/Support/VersionTuple.h
+++ b/llvm/include/llvm/Support/VersionTuple.h
@@ -14,6 +14,7 @@
 #ifndef 

[PATCH] D79147: [WIP] Merge -debug-info-kind=constructor into -debug-info-kind=limited

2020-07-07 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 276252.
akhuang added a comment.
Herald added a subscriber: fedor.sergeev.

Instead of merging =constructor and =limited, change the default to use 
=constructor


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79147

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang-g-opts.c
  clang/test/Driver/cuda-dwarf-2.cu
  clang/test/Driver/debug-options-as.c
  clang/test/Driver/debug-options.c
  clang/test/Driver/integrated-as.s
  clang/test/Driver/myriad-toolchain.c
  clang/test/Driver/split-debug.c
  lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp

Index: lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp
===
--- lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp
+++ lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp
@@ -106,6 +106,7 @@
 int main() {
   MemberTest::Base B1;
   B1.Get();
+  MemberTest::Class C1;
   MemberTest::Class::StaticMemberFunc(1, 10, 2);
   return 0;
 }
Index: clang/test/Driver/split-debug.c
===
--- clang/test/Driver/split-debug.c
+++ clang/test/Driver/split-debug.c
@@ -68,18 +68,18 @@
 // RUN: FileCheck -check-prefix=CHECK-NOINLINE-WITHOUT-SPLIT < %t %s
 //
 // CHECK-NOINLINE-WITHOUT-SPLIT: "-fno-split-dwarf-inlining"
-// CHECK-NOINLINE-WITHOUT-SPLIT: "-debug-info-kind=limited"
+// CHECK-NOINLINE-WITHOUT-SPLIT: "-debug-info-kind=constructor"
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -gmlt -gsplit-dwarf -fno-split-dwarf-inlining -S -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-SPLIT-WITH-GMLT < %t %s
 //
-// CHECK-SPLIT-WITH-GMLT: "-debug-info-kind=limited"
+// CHECK-SPLIT-WITH-GMLT: "-debug-info-kind=constructor"
 // CHECK-SPLIT-WITH-GMLT: "-split-dwarf-output"
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -fno-split-dwarf-inlining -S -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-SPLIT-WITH-NOINL < %t %s
 //
-// CHECK-SPLIT-WITH-NOINL: "-debug-info-kind=limited"
+// CHECK-SPLIT-WITH-NOINL: "-debug-info-kind=constructor"
 // CHECK-SPLIT-WITH-NOINL: "-split-dwarf-output"
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -gmlt -fsplit-dwarf-inlining -S -### %s 2> %t
@@ -92,7 +92,7 @@
 // RUN: %clang -target x86_64-unknown-linux-gnu -gmlt -gsplit-dwarf -S -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-SPLIT-OVER-GMLT < %t %s
 //
-// CHECK-SPLIT-OVER-GMLT: "-debug-info-kind=limited"
+// CHECK-SPLIT-OVER-GMLT: "-debug-info-kind=constructor"
 // CHECK-SPLIT-OVER-GMLT: "-split-dwarf-file"
 // CHECK-SPLIT-OVER-GMLT: "-split-dwarf-output"
 
@@ -117,6 +117,6 @@
 // RUN: %clang -target x86_64-unknown-linux-gnu -g0 -gsplit-dwarf=split -S -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-SPLIT-OVER-G0 < %t %s
 //
-// CHECK-SPLIT-OVER-G0: "-debug-info-kind=limited"
+// CHECK-SPLIT-OVER-G0: "-debug-info-kind=constructor"
 // CHECK-SPLIT-OVER-G0: "-split-dwarf-file"
 // CHECK-SPLIT-OVER-G0: "-split-dwarf-output"
Index: clang/test/Driver/myriad-toolchain.c
===
--- clang/test/Driver/myriad-toolchain.c
+++ clang/test/Driver/myriad-toolchain.c
@@ -83,7 +83,7 @@
 // NOSTDLIB-NOT: "-lc"
 
 // RUN: %clang -### -c -g %s -target sparc-myriad 2>&1 | FileCheck -check-prefix=G_SPARC %s
-// G_SPARC: "-debug-info-kind=limited" "-dwarf-version=2"
+// G_SPARC: "-debug-info-kind=constructor" "-dwarf-version=2"
 
 // RUN: %clang -### -c %s -target sparc-myriad-rtems -fuse-init-array 2>&1 \
 // RUN: | FileCheck -check-prefix=USE-INIT-ARRAY %s
Index: clang/test/Driver/integrated-as.s
===
--- clang/test/Driver/integrated-as.s
+++ clang/test/Driver/integrated-as.s
@@ -27,19 +27,19 @@
 // XA_INCLUDE2: "-Ifoo_dir"
 
 // RUN: %clang -### -target x86_64--- -c -integrated-as %s -gdwarf-4 -gdwarf-2 2>&1 | FileCheck --check-prefix=DWARF2 %s
-// DWARF2: "-debug-info-kind=limited" "-dwarf-version=2"
+// DWARF2: "-debug-info-kind=constructor" "-dwarf-version=2"
 
 // RUN: %clang -### -target x86_64--- -c -integrated-as %s -gdwarf-3 2>&1 | FileCheck --check-prefix=DWARF3 %s
-// DWARF3: "-debug-info-kind=limited" "-dwarf-version=3"
+// DWARF3: "-debug-info-kind=constructor" "-dwarf-version=3"
 
 // RUN: %clang -### -target x86_64--- -c -integrated-as %s -gdwarf-4 2>&1 | FileCheck --check-prefix=DWARF4 %s
-// DWARF4: "-debug-info-kind=limited" "-dwarf-version=4"
+// DWARF4: "-debug-info-kind=constructor" "-dwarf-version=4"
 
 // RUN: %clang -### -target x86_64--- -c -integrated-as %s -Xassembler -gdwarf-2 2>&1 | FileCheck --check-prefix=DWARF2XASSEMBLER %s
-// DWARF2XASSEMBLER: "-debug-info-kind=limited" "-dwarf-version=2"
+// DWARF2XASSEMBLER: "-debug-info-kind=constructor" "-dwarf-version=2"
 
 // RUN: %clang -### 

[PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments

2020-07-07 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

__kmpc_spmd_kernel_init is always called with RequiresDataSharing == 0
Specifically, it's only called from clang, and emitSPMDEntryHeader 
unconditionally passes zero to it

I.e. I think there's more stuff that can be cleaned up in the theme of the 
above, suggest in later patches


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83268



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


[PATCH] D78655: [CUDA][HIP] Let lambda be host device by default

2020-07-07 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Sema/SemaCUDA.cpp:757-759
+  // In host compilation, deferred diagnostics are only emitted for functions
+  // which are sure to be emitted on host side since there is no reliable
+  // way to check if a function is emitted on device side. Therefore in

I don't think this is completely correct. Postponed diags get emitted if we 
know we're attempoting to codegen wrong things.
E.g. during host compilation when HD function used by host code ends up 
attempting to call a device function.
It also works in the other direction -- it kicks in during device compilation 
when HD function calls a host function.
AFAICT it has nothing to do with what happens on the other side of the 
compilation, but rather what we're attempting to codegen during *this* 
compilation.

I don't think that we can reason that checks can be done on the host side only, 
based only on the argument you're making above (at least based on the way I 
understand it).

The point you're making below that a captured lambda created by device code 
can't ever be used by the host code is probably a better argument why the check 
may not be necessary.



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

https://reviews.llvm.org/D78655



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


[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

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

I still haven't seen a strong argument keeping a command line option 
`-enable-npm-call-graph-profile`. Asked in D62627 
.

`Opts.getProfileUse() != CodeGenOptions::ProfileNone ` in

  Opts.CallGraphProfile = Opts.getProfileUse() != CodeGenOptions::ProfileNone &&
!Opts.DisableIntegratedAS;

is redundant. CGProfile.cpp is a no-op if no function provides `getEntryFreq()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013



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


[PATCH] D81315: [analyzer] Warning for default constructed unique pointer dereferences

2020-07-07 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar marked an inline comment as done.
vrnithinkumar added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:202-219
+ProgramStateRef
+SmartPtrModeling::updateTrackedRegion(const CallEvent , CheckerContext ,
+  const MemRegion *ThisValRegion) const {
+  ProgramStateRef State = C.getState();
+  auto NumArgs = Call.getNumArgs();
+
+  if (NumArgs == 0) {

NoQ wrote:
> Szelethus wrote:
> > Hmm, this function feels clunky. So, if the call has no arguments, we set 
> > the smart pointer to null, otherwise if its a single-argument then we set 
> > it to whatever the argument is? 
> > 
> > How about `operator[]`, that also takes a single argument, but isn't a 
> > memory region? `get`, `get_deleter` don't take any arguments, but they 
> > don't set the internal pointee to null either. The name 
> > `updateTrackedRegion` however suggests that whatever operation was done, 
> > this is the one-tool-to-solve-it-all function to take care of it.
> > 
> > I think this function handles too many things as once, and the name and 
> > lack of documentation obfuscates its purpose. How about we put the relevant 
> > code to `handleRelease`, and repurpose the rest of the function like this:
> > 
> > `updateOwnedRegion(CallEvent, CheckerContext, MemRegion of the smart 
> > pointer, MemRegion to take ownership of)`
> > 
> > What do you think?
> Yup, I completely agree. I think this structure will naturally evolve into 
> something cleaner once more modeling gets added.
Thanks for the detailed comment.

I totally agree this method is handling many things. 
For methods like `get`, `get_deleter` this makes no sense at all.

I will add TODO there,  will address this  in a later patch once we get a clear 
picture after more modeling added.


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

https://reviews.llvm.org/D81315



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


[PATCH] D83349: [OpenMP][NFC] Remove unused and untested code from the device runtime

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

Applied to the amdgcn implementation. Compiles fine, tests all passing. Seems 
likely that this lot really is dead.

Interesting that this removes*_data_sharing_environment. I think some of the 
allocated objects will be more obviously dead after this patch.

Love it. Thanks! We can have this as soon as we hit consensus on dropping the 
API stability aspiration


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83349



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


[PATCH] D82728: [clang] Add -Wsuggest-override

2020-07-07 Thread Logan Smith via Phabricator via cfe-commits
logan-5 updated this revision to Diff 276248.
logan-5 added a comment.

Fall back to -Wsuggest-override if -Winconsistent-missing-override is disabled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/warn-suggest-destructor-override
  clang/test/SemaCXX/warn-suggest-override

Index: clang/test/SemaCXX/warn-suggest-override
===
--- /dev/null
+++ clang/test/SemaCXX/warn-suggest-override
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wsuggest-override
+
+struct A {
+  ~A();
+  void run();
+};
+
+struct B : public A {
+  ~B();
+  void run();
+};
+
+struct C {
+  virtual void run(); // expected-note 2{{overridden virtual function is here}}
+  virtual ~C();
+};
+
+struct D : public C {
+  void run();
+  // expected-warning@-1 {{'run()' overrides a member function but is not marked 'override'}}
+  ~D();
+};
+
+struct E : public C {
+  virtual void run();
+  // expected-warning@-1 {{'run()' overrides a member function but is not marked 'override'}}
+  virtual ~E();
+};
+
+struct F : public C {
+  void run() override;
+  ~F() override;
+};
+
+struct G : public C {
+  void run() final;
+  ~G() final;
+};
Index: clang/test/SemaCXX/warn-suggest-destructor-override
===
--- /dev/null
+++ clang/test/SemaCXX/warn-suggest-destructor-override
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wsuggest-destructor-override
+
+struct A {
+  ~A();
+  virtual void run();
+};
+
+struct B : public A {
+  ~B();
+};
+
+struct C {
+  virtual void run();
+  virtual ~C();  // expected-note 2{{overridden virtual function is here}}
+};
+
+struct D : public C {
+  void run();
+  ~D();
+  // expected-warning@-1 {{'~D' overrides a destructor but is not marked 'override'}}
+};
+
+struct E : public C {
+  void run();
+  virtual ~E();
+  // expected-warning@-1 {{'~E' overrides a destructor but is not marked 'override'}}
+};
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -3045,7 +3045,7 @@
   << MD->getDeclName();
 }
 
-void Sema::DiagnoseAbsenceOfOverrideControl(NamedDecl *D) {
+void Sema::DiagnoseAbsenceOfOverrideControl(NamedDecl *D, bool Inconsistent) {
   if (D->isInvalidDecl() || D->hasAttr())
 return;
   CXXMethodDecl *MD = dyn_cast(D);
@@ -3061,12 +3061,22 @@
   return;
 
   if (MD->size_overridden_methods() > 0) {
-unsigned DiagID = isa(MD)
-  ? diag::warn_destructor_marked_not_override_overriding
-  : diag::warn_function_marked_not_override_overriding;
-Diag(MD->getLocation(), DiagID) << MD->getDeclName();
-const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
-Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
+auto EmitDiag = [&](unsigned DiagInconsistent, unsigned DiagSuggest) {
+  unsigned DiagID =
+  Inconsistent && !Diags.isIgnored(DiagInconsistent, MD->getLocation())
+  ? DiagInconsistent
+  : DiagSuggest;
+  Diag(MD->getLocation(), DiagID) << MD->getDeclName();
+  const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
+  Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
+};
+if (isa(MD))
+  EmitDiag(
+  diag::warn_inconsistent_destructor_marked_not_override_overriding,
+  diag::warn_suggest_destructor_marked_not_override_overriding);
+else
+  EmitDiag(diag::warn_inconsistent_function_marked_not_override_overriding,
+   diag::warn_suggest_function_marked_not_override_overriding);
   }
 }
 
@@ -6749,13 +6759,10 @@
 }
   }
 
-  if (HasMethodWithOverrideControl &&
-  HasOverridingMethodWithoutOverrideControl) {
-// At least one method has the 'override' control declared.
-// Diagnose all other overridden methods which do not have 'override'
-// specified on them.
+  if (HasOverridingMethodWithoutOverrideControl) {
+bool HasInconsistentOverrideControl = HasMethodWithOverrideControl;
 for (auto *M : Record->methods())
-  DiagnoseAbsenceOfOverrideControl(M);
+  DiagnoseAbsenceOfOverrideControl(M, HasInconsistentOverrideControl);
   }
 
   // Check the defaulted secondary comparisons after any other member functions.
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -6961,7 +6961,7 @@
 
   /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
   /// 

[PATCH] D82728: [clang] Add -Wsuggest-override

2020-07-07 Thread Logan Smith via Phabricator via cfe-commits
logan-5 added a comment.

In D82728#2137492 , @dblaikie wrote:

> Oh, yep, there's a way - it's usually used for performance-costly warnings, 
> to not spend the resources computing the warning if it's disabled anyway.


Wow, thanks--overlooked that in a big way. That'll definitely solve the 
problem. Fixed up patch on the way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728



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


[PATCH] D82085: [TRE] allow TRE for non-capturing calls.

2020-07-07 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:94
 /// If it contains any dynamic allocas, returns false.
 static bool canTRE(Function ) {
   // Because of PR962, we don't TRE dynamic allocas.

If we're not going to try to do TRE at all on calls not marked "tail", we can 
probably drop this check.



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:808
   // Until this is resolved, disable this transformation if that would ever
   // happen.  This bug is PR962.
   for (Function::iterator BBI = F.begin(), E = F.end(); BBI != E; /*in loop*/) 
{

Can you move this FIXME into a more appropriate spot?



Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:335
+II->getIntrinsicID() == Intrinsic::assume)
+  return true;
+

avl wrote:
> efriedma wrote:
> > What is the new handling for lifetime.end/assume doing?
> They are just skipped. In following test case:
> 
> 
> ```
>   call void @_Z5test5i(i32 %sub)
>   call void @llvm.lifetime.end.p0i8(i64 24, i8* nonnull %1) #5
>   call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %0) #5
>   br label %return
> 
> ```
> 
> they are generated in between call and ret. It is safe to ignore them while 
> checking whether transformation is possible.
It makes sense we can ignore lifetime.end on an alloca: we know the call 
doesn't refer to the alloca.  (Maybe we should check that the pointer argument 
is pointing at an alloca?  That should usually be true anyway, but better to be 
on the safe side, I guess.)

I don't think it's safe to hoist assume without additional checks; I think we'd 
need to check that the call is marked "willreturn"?

Since this is sort of tricky, I'd prefer to split this off into a followup.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[PATCH] D82728: [clang] Add -Wsuggest-override

2020-07-07 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D82728#2137061 , @logan-5 wrote:

> In D82728#2137021 , @dblaikie wrote:
>
> > I think it might be nice to make the -Wno-inconsistent-missing-override 
> > -Wsuggest-override situation a bit better (by having it still do the same 
> > thing as -Wsuggest-override) but I don't feel /too/ strongly about it.
>
>
> So, ironing this out would mean the code would need this structure:
>
>   if (Inconsistent && IsWarningEnabled(-Winconsistent-missing-override))
>Emit(-Winconsistent-missing-override);
>else
>Emit(-Wsuggest-override);
>
> The issue is that I wasn't able to find a way to ask if a warning is enabled 
> and make a control flow decision based on that. If there is an API for doing 
> this, it's hidden well. :) So I fell back to just doing `if (Inconsistent)` 
> instead, which has this quirk if the inconsistent version of the warning is 
> disabled.


Oh, yep, there's a way - it's usually used for performance-costly warnings, to 
not spend the resources computing the warning if it's disabled anyway.

Here's an arbitrary example: 
https://github.com/llvm-mirror/clang/blob/master/lib/Sema/SemaDecl.cpp#L7237


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728



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


[PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the correct bases class offsets from the external source

2020-07-07 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 276229.
shafik marked 5 inline comments as done.
shafik added a comment.

- Removing spurious local variables in test
- Simplifying the test


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

https://reviews.llvm.org/D83008

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  lldb/test/Shell/Expr/Inputs/layout.cpp
  lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test


Index: lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test
===
--- /dev/null
+++ lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test
@@ -0,0 +1,7 @@
+# RUN: %clangxx_host %p/Inputs/layout.cpp -g -o %t
+
+# RUN: %lldb %t -b -s %s | FileCheck %s
+
+expr (intptr_t) - (intptr_t)
+# CHECK: (lldb) expr (intptr_t) - (intptr_t)
+# CHECK: (long) $0 = 8
Index: lldb/test/Shell/Expr/Inputs/layout.cpp
===
--- /dev/null
+++ lldb/test/Shell/Expr/Inputs/layout.cpp
@@ -0,0 +1,17 @@
+#include 
+
+struct B1 {
+  char f1;
+};
+
+struct alignas(8) B2 {
+  char f2;
+};
+
+struct D : B1, B2 {
+};
+
+D d3g;
+
+int main() {
+}
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1187,11 +1187,10 @@
   // Query the external layout to see if it provides an offset.
   bool HasExternalLayout = false;
   if (UseExternalLayout) {
-// FIXME: This appears to be reversed.
 if (Base->IsVirtual)
-  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, 
Offset);
-else
   HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset);
+else
+  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, 
Offset);
   }
 
   // Clang <= 6 incorrectly applied the 'packed' attribute to base classes.


Index: lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test
===
--- /dev/null
+++ lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test
@@ -0,0 +1,7 @@
+# RUN: %clangxx_host %p/Inputs/layout.cpp -g -o %t
+
+# RUN: %lldb %t -b -s %s | FileCheck %s
+
+expr (intptr_t) - (intptr_t)
+# CHECK: (lldb) expr (intptr_t) - (intptr_t)
+# CHECK: (long) $0 = 8
Index: lldb/test/Shell/Expr/Inputs/layout.cpp
===
--- /dev/null
+++ lldb/test/Shell/Expr/Inputs/layout.cpp
@@ -0,0 +1,17 @@
+#include 
+
+struct B1 {
+  char f1;
+};
+
+struct alignas(8) B2 {
+  char f2;
+};
+
+struct D : B1, B2 {
+};
+
+D d3g;
+
+int main() {
+}
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1187,11 +1187,10 @@
   // Query the external layout to see if it provides an offset.
   bool HasExternalLayout = false;
   if (UseExternalLayout) {
-// FIXME: This appears to be reversed.
 if (Base->IsVirtual)
-  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
-else
   HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset);
+else
+  HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
   }
 
   // Clang <= 6 incorrectly applied the 'packed' attribute to base classes.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83349: [OpenMP][NFC] Remove unused and untested code from the device runtime

2020-07-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Please let me know if something slipped through my "clever" grep logic and is 
actually used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83349



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


[PATCH] D83349: [OpenMP][NFC] Remove unused and untested code from the device runtime

2020-07-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: hfinkel, jhuber6, fghanim, JonChesterfield, grokos, 
AndreyChurbanov, ye-luo, tianshilei1992, ggeorgakoudis, Hahnfeld, ABataev, 
hbae, ronlieb, gregrodgers.
Herald added subscribers: cfe-commits, aaron.ballman, sstefan1, jfb, guansong, 
bollu, yaxunl, jvesely.
Herald added projects: clang, OpenMP.

We carried a lot of unused and untested code in the device runtime.
Among other reasons, we are planning major rewrites for which reduced
size is going to help a lot.

The number of code lines reduced by 14%!

Before:
---

Language files  blankcomment   code
---

CUDA13489841   2454
C/C++ Header14322493   1377
C   12117124559
CMake4 64 64262

C++  1  6  6 39
---

SUM:44998   1528   4691
---

After:
--

Language files  blankcomment   code
---

CUDA13366733   1879
C/C++ Header14317484   1293
C   12117124559
CMake4 64 64262

C++  1  6  6 39
---

SUM:44870   1411   4032
---


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83349

Files:
  clang/test/OpenMP/nvptx_target_simd_codegen.cpp
  openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
  openmp/libomptarget/deviceRTLs/common/omptarget.h
  openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
  openmp/libomptarget/deviceRTLs/common/src/libcall.cu
  openmp/libomptarget/deviceRTLs/common/src/loop.cu
  openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
  openmp/libomptarget/deviceRTLs/common/src/parallel.cu
  openmp/libomptarget/deviceRTLs/common/src/reduction.cu
  openmp/libomptarget/deviceRTLs/common/src/support.cu
  openmp/libomptarget/deviceRTLs/common/src/sync.cu
  openmp/libomptarget/deviceRTLs/common/support.h
  openmp/libomptarget/deviceRTLs/interface.h
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h

Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
===
--- openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
@@ -195,15 +195,6 @@
 INLINE unsigned GetWarpId() { return GetThreadIdInBlock() / WARPSIZE; }
 INLINE unsigned GetLaneId() { return GetThreadIdInBlock() & (WARPSIZE - 1); }
 
-// Return true if this is the first active thread in the warp.
-INLINE bool __kmpc_impl_is_first_active_thread() {
-  unsigned long long Mask = __kmpc_impl_activemask();
-  unsigned long long ShNum = WARPSIZE - (GetThreadIdInBlock() % WARPSIZE);
-  unsigned long long Sh = Mask << ShNum;
-  // Truncate Sh to the 32 lower bits
-  return (unsigned)Sh == 0;
-}
-
 // Locks
 EXTERN void __kmpc_impl_init_lock(omp_lock_t *lock);
 EXTERN void __kmpc_impl_destroy_lock(omp_lock_t *lock);
Index: openmp/libomptarget/deviceRTLs/interface.h
===
--- openmp/libomptarget/deviceRTLs/interface.h
+++ openmp/libomptarget/deviceRTLs/interface.h
@@ -193,17 +193,10 @@
 
 // parallel defs
 typedef ident_t kmp_Ident;
-typedef void (*kmp_ParFctPtr)(int32_t *global_tid, int32_t *bound_tid, ...);
-typedef void (*kmp_ReductFctPtr)(void *lhsData, void *rhsData);
 typedef void (*kmp_InterWarpCopyFctPtr)(void *src, int32_t warp_num);
 typedef void (*kmp_ShuffleReductFctPtr)(void *rhsData, int16_t lane_id,
 int16_t lane_offset,
 int16_t shortCircuit);
-typedef void (*kmp_CopyToScratchpadFctPtr)(void *reduceData, void *scratchpad,
-   int32_t index, int32_t width);
-typedef void (*kmp_LoadReduceFctPtr)(void *reduceData, void *scratchpad,
- int32_t index, int32_t width,
- int32_t 

[PATCH] D78655: [CUDA][HIP] Let lambda be host device by default

2020-07-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 276211.
yaxunl added a comment.

refactor CUDACheckLambdaCapture and add comments


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

https://reviews.llvm.org/D78655

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/SemaCUDA/Inputs/cuda.h
  clang/test/SemaCUDA/lambda.cu

Index: clang/test/SemaCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/lambda.cu
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=com %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcuda-is-device -verify=com,dev %s
+
+#include "Inputs/cuda.h"
+
+auto global_lambda = [] () { return 123; };
+
+template
+__global__ void kernel(F f) { f(); }
+// dev-note@-1 7{{called by 'kernel<(lambda}}
+
+__host__ __device__ void hd(int x);
+
+class A {
+  int b;
+public:
+  void test() {
+[=](){ hd(b); }();
+
+[&](){ hd(b); }();
+
+kernel<<<1,1>>>([](){ hd(0); });
+
+kernel<<<1,1>>>([=](){ hd(b); });
+// dev-error@-1 {{capture host side class data member by this pointer in device or host device lambda function}}
+
+kernel<<<1,1>>>([&](){ hd(b); });
+// dev-error@-1 {{capture host side class data member by this pointer in device or host device lambda function}}
+
+kernel<<<1,1>>>([&] __device__ (){ hd(b); });
+// dev-error@-1 {{capture host side class data member by this pointer in device or host device lambda function}}
+
+kernel<<<1,1>>>([&](){
+  auto f = [&]{ hd(b); };
+  // dev-error@-1 {{capture host side class data member by this pointer in device or host device lambda function}}
+  f();
+});
+  }
+};
+
+int main(void) {
+  auto lambda_kernel = [&]__global__(){};
+  // com-error@-1 {{kernel function 'operator()' must be a free function or static member function}}
+
+  int b;
+  [&](){ hd(b); }();
+
+  [=, ](){ hd(b); }();
+
+  kernel<<<1,1>>>(global_lambda);
+
+  kernel<<<1,1>>>([](){ hd(0); });
+
+  kernel<<<1,1>>>([=](){ hd(b); });
+
+  kernel<<<1,1>>>([b](){ hd(b); });
+
+  kernel<<<1,1>>>([&](){ hd(b); });
+  // dev-error@-1 {{capture host variable 'b' by reference in device or host device lambda function}}
+
+  kernel<<<1,1>>>([=, ](){ hd(b); });
+  // dev-error@-1 {{capture host variable 'b' by reference in device or host device lambda function}}
+
+  kernel<<<1,1>>>([&, b](){ hd(b); });
+
+  kernel<<<1,1>>>([&](){
+  auto f = [&]{ hd(b); };
+  // dev-error@-1 {{capture host variable 'b' by reference in device or host device lambda function}}
+  f();
+  });
+
+  return 0;
+}
Index: clang/test/SemaCUDA/Inputs/cuda.h
===
--- clang/test/SemaCUDA/Inputs/cuda.h
+++ clang/test/SemaCUDA/Inputs/cuda.h
@@ -17,6 +17,19 @@
   __host__ __device__ dim3(unsigned x, unsigned y = 1, unsigned z = 1) : x(x), y(y), z(z) {}
 };
 
+#ifdef __HIP__
+typedef struct hipStream *hipStream_t;
+typedef enum hipError {} hipError_t;
+int hipConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0,
+ hipStream_t stream = 0);
+extern "C" hipError_t __hipPushCallConfiguration(dim3 gridSize, dim3 blockSize,
+ size_t sharedSize = 0,
+ hipStream_t stream = 0);
+extern "C" hipError_t hipLaunchKernel(const void *func, dim3 gridDim,
+  dim3 blockDim, void **args,
+  size_t sharedMem,
+  hipStream_t stream);
+#else
 typedef struct cudaStream *cudaStream_t;
 typedef enum cudaError {} cudaError_t;
 
@@ -29,6 +42,7 @@
 extern "C" cudaError_t cudaLaunchKernel(const void *func, dim3 gridDim,
 dim3 blockDim, void **args,
 size_t sharedMem, cudaStream_t stream);
+#endif
 
 // Host- and device-side placement new overloads.
 void *operator new(__SIZE_TYPE__, void *p) { return p; }
Index: clang/test/CodeGenCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/lambda.cu
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple x86_64-linux-gnu \
+// RUN:   | FileCheck -check-prefix=HOST %s
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+// Device side kernel name.
+// HOST: @[[KERN_CAPTURE:[0-9]+]] = {{.*}} c"_Z1gIZ12test_capturevEUlvE_EvT_\00"
+// HOST: @[[KERN_RESOLVE:[0-9]+]] = {{.*}} c"_Z1gIZ12test_resolvevEUlvE_EvT_\00"
+
+// Check functions emitted for test_capture in host compilation.
+// Check lambda is not 

[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-07 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 276208.
zequanwu marked an inline comment as done.
zequanwu added a comment.
Herald added subscribers: dexonsmith, steven_wu.

- Disable `enable-call-graph-profile` by default in opt.
- Disable `CGProfilePass` by default in clang unless `-no-integrated-as` is not 
given and `-fprofile-instrument-use-path=` is given, as this pass only 
generates module metadata when profile data is given.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
  llvm/include/llvm/Transforms/Instrumentation/CGProfile.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Instrumentation/CGProfile.cpp
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/test/Instrumentation/cgprofile.ll
  llvm/test/Other/new-pm-cgprofile.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/tools/opt/NewPMDriver.cpp
  llvm/tools/opt/NewPMDriver.h
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -278,6 +278,10 @@
 cl::desc("Specify time trace file destination"),
 cl::value_desc("filename"));
 
+static cl::opt EnableCallGraphProfile(
+"enable-call-graph-profile", cl::init(false), cl::Hidden,
+cl::desc("Enable call graph profile pass (default = on)"));
+
 static cl::opt RemarksWithHotness(
 "pass-remarks-with-hotness",
 cl::desc("With PGO, include profile count in optimization remarks"),
@@ -414,6 +418,8 @@
 
   Builder.SLPVectorize = OptLevel > 1 && SizeLevel < 2;
 
+  Builder.CallGraphProfile = EnableCallGraphProfile;
+
   if (TM)
 TM->adjustPassManager(Builder);
 
@@ -767,7 +773,8 @@
RemarksFile.get(), PassPipeline, Passes, OK, VK,
PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex,
-   EmitModuleHash, EnableDebugify, Coroutines)
+   EmitModuleHash, EnableDebugify, Coroutines,
+   EnableCallGraphProfile)
? 0
: 1;
   }
Index: llvm/tools/opt/NewPMDriver.h
===
--- llvm/tools/opt/NewPMDriver.h
+++ llvm/tools/opt/NewPMDriver.h
@@ -66,7 +66,8 @@
  bool ShouldPreserveAssemblyUseListOrder,
  bool ShouldPreserveBitcodeUseListOrder,
  bool EmitSummaryIndex, bool EmitModuleHash,
- bool EnableDebugify, bool Coroutines);
+ bool EnableDebugify, bool Coroutines,
+ bool CallGraphProfile);
 } // namespace llvm
 
 #endif
Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -220,7 +220,8 @@
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder,
bool EmitSummaryIndex, bool EmitModuleHash,
-   bool EnableDebugify, bool Coroutines) {
+   bool EnableDebugify, bool Coroutines,
+   bool CallGraphProfile) {
   bool VerifyEachPass = VK == VK_VerifyEachPass;
 
   Optional P;
@@ -266,6 +267,7 @@
   SI.registerCallbacks(PIC);
 
   PipelineTuningOptions PTO;
+  PTO.CallGraphProfile = CallGraphProfile;
   // LoopUnrolling defaults on to true and DisableLoopUnrolling is initialized
   // to false above so we shouldn't necessarily need to check whether or not the
   // option has been enabled.
Index: llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
@@ -227,7 +227,6 @@
 ; CHECK-O-NEXT: Running pass: SimplifyCFGPass
 ; CHECK-O-NEXT: Running pass: SpeculateAroundPHIsPass
 ; CHECK-O-NEXT: Finished {{.*}}Function pass manager run.
-; CHECK-O-NEXT: Running pass: CGProfilePass
 ; CHECK-O-NEXT: Running pass: GlobalDCEPass
 ; CHECK-O-NEXT: Running pass: ConstantMergePass
 ; CHECK-O-NEXT: Finished {{.*}}Module pass manager run.
Index: llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll

[PATCH] D81583: Update SystemZ ABI to handle C++20 [[no_unique_address]] attribute

2020-07-07 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:521
+  // [[no_unique_address]] attribute (since C++20).  Those do count
+  // as empty according to the Itanium ABI.  This property is currently
+  // only respected if the AllowNoUniqueAddr parameter is true.

This check is being done after removal of the array types by `AllowArrays`, so 
this code is also conferring the property of being empty to arrays. It seems 
GCC erroneously does the same for base class fields (but not for direct 
members).

```
struct Empty {};

struct A {
  Empty emp [[no_unique_address]][3];
};

struct B : A {
  float f;
};

struct C {
  Empty emp [[no_unique_address]][3];
  float f;
};

extern char szb[sizeof(B)];
extern char szb[sizeof(float)]; // GCC likes this
extern char szc[sizeof(C)];
extern char szc[sizeof(float)]; // GCC does not like this
```

Compiler Explorer link: https://godbolt.org/z/NFuca9



Comment at: clang/lib/CodeGen/TargetInfo.cpp:7231
 // Empty bases don't affect things either way.
-if (isEmptyRecord(getContext(), Base, true))
+if (isEmptyRecord(getContext(), Base, true, true))
   continue;

The Itanium ABI defines "empty data member" as:
> A potentially-overlapping non-static data member of empty class type.

That definition does not include non-static data members of array type whose 
base element type is an empty class type.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:7249
+if (FD->hasAttr() &&
+isEmptyRecord(getContext(), FD->getType(), true, true))
+  continue;

Should this be controlled by an `-fclang-abi-compat` option?


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

https://reviews.llvm.org/D81583



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


[PATCH] D83079: [clang][aarch64] Generate preprocessor macros for -march=armv8.6a+sve.

2020-07-07 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 276204.
fpetrogalli added a comment.

Addressed code review, moving the code and adding more testing, including the 
`v8.5` one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83079

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


Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -112,6 +112,60 @@
 // CHECK-SVE-F64MM: __ARM_FEATURE_SVE 1
 // CHECK-SVE-F64MM: __ARM_FEATURE_SVE_MATMUL_FP64 1
 
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.5-a+sve -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-SVE-8_5 %s
+// CHECK-SVE-8_5-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_5-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_5-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_5: __ARM_FEATURE_SVE 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-SVE-8_6 %s
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE_MATMUL_INT8 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+noi8mm -x c 
-E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOI8MM %s
+// CHECK-SVE-8_6-NOI8MM-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_6-NOI8MM: __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOI8MM: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOI8MM: __ARM_FEATURE_SVE_MATMUL_FP32 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+nobf16 -x c 
-E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOBF16 %s
+// CHECK-SVE-8_6-NOBF16-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOBF16: __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOBF16: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOBF16: __ARM_FEATURE_SVE_MATMUL_INT8 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+nof32mm -x 
c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOF32MM %s
+// CHECK-SVE-8_6-NOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOF32MM: __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOF32MM: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOF32MM: __ARM_FEATURE_SVE_MATMUL_INT8 1
+
+// RUN: %clang -target aarch64-none-linux-gnu 
-march=armv8.6-a+sve+noi8mm+nobf16 -x c -E -dM %s -o - | FileCheck 
--check-prefix=CHECK-SVE-8_6-NOI8MMNOBF16 %s
+// CHECK-SVE-8_6-NOI8MMNOBF16-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOI8MMNOBF16-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_6-NOI8MMNOBF16: __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOI8MMNOBF16: __ARM_FEATURE_SVE_MATMUL_FP32 1
+
+// RUN: %clang -target aarch64-none-linux-gnu 
-march=armv8.6-a+sve+noi8mm+nof32mm -x c -E -dM %s -o - | FileCheck 
--check-prefix=CHECK-SVE-8_6-NOI8MMNOF32MM %s
+// CHECK-SVE-8_6-NOI8MMNOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOI8MMNOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_6-NOI8MMNOF32MM: __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOI8MMNOF32MM: __ARM_FEATURE_SVE_BF16 1
+
+// RUN: %clang -target aarch64-none-linux-gnu 
-march=armv8.6-a+sve+nobf16+nof32mm -x c -E -dM %s -o - | FileCheck 
--check-prefix=CHECK-SVE-8_6-NOBF16NOF32MM %s
+// CHECK-SVE-8_6-NOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOBF16NOF32MM: __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOBF16NOF32MM: __ARM_FEATURE_SVE_MATMUL_INT8 1
+
+// RUN: %clang -target aarch64-none-linux-gnu 
-march=armv8.6-a+sve+noi8mm+nobf16+nof32mm -x c -E -dM %s -o - | FileCheck 
--check-prefix=CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM %s
+// CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM: __ARM_FEATURE_SVE 1
+
 // The following tests may need to be revised in the future since
 // SVE2 is currently still part of Future Architecture Technologies
 // (https://developer.arm.com/docs/ddi0602/latest)
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -365,6 +365,15 @@
 }
   }
 
+  if (llvm::is_contained(Features, "+v8.6a")) {
+if (!llvm::is_contained(Features, "-i8mm") &&
+!llvm::is_contained(Features, "+noi8mm"))
+  Features.push_back("+i8mm");
+if (!llvm::is_contained(Features, "-bf16") &&
+!llvm::is_contained(Features, 

[PATCH] D82728: [clang] Add -Wsuggest-override

2020-07-07 Thread Logan Smith via Phabricator via cfe-commits
logan-5 updated this revision to Diff 276187.
logan-5 added a comment.

Addressed minor feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/warn-suggest-destructor-override
  clang/test/SemaCXX/warn-suggest-override

Index: clang/test/SemaCXX/warn-suggest-override
===
--- /dev/null
+++ clang/test/SemaCXX/warn-suggest-override
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wsuggest-override
+
+struct A {
+  ~A();
+  void run();
+};
+
+struct B : public A {
+  ~B();
+  void run();
+};
+
+struct C {
+  virtual void run(); // expected-note 2{{overridden virtual function is here}}
+  virtual ~C();
+};
+
+struct D : public C {
+  void run();
+  // expected-warning@-1 {{'run()' overrides a member function but is not marked 'override'}}
+  ~D();
+};
+
+struct E : public C {
+  virtual void run();
+  // expected-warning@-1 {{'run()' overrides a member function but is not marked 'override'}}
+  virtual ~E();
+};
+
+struct F : public C {
+  void run() override;
+  ~F() override;
+};
+
+struct G : public C {
+  void run() final;
+  ~G() final;
+};
Index: clang/test/SemaCXX/warn-suggest-destructor-override
===
--- /dev/null
+++ clang/test/SemaCXX/warn-suggest-destructor-override
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wsuggest-destructor-override
+
+struct A {
+  ~A();
+  virtual void run();
+};
+
+struct B : public A {
+  ~B();
+};
+
+struct C {
+  virtual void run();
+  virtual ~C();  // expected-note 2{{overridden virtual function is here}}
+};
+
+struct D : public C {
+  void run();
+  ~D();
+  // expected-warning@-1 {{'~D' overrides a destructor but is not marked 'override'}}
+};
+
+struct E : public C {
+  void run();
+  virtual ~E();
+  // expected-warning@-1 {{'~E' overrides a destructor but is not marked 'override'}}
+};
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -3045,7 +3045,7 @@
   << MD->getDeclName();
 }
 
-void Sema::DiagnoseAbsenceOfOverrideControl(NamedDecl *D) {
+void Sema::DiagnoseAbsenceOfOverrideControl(NamedDecl *D, bool Inconsistent) {
   if (D->isInvalidDecl() || D->hasAttr())
 return;
   CXXMethodDecl *MD = dyn_cast(D);
@@ -3061,12 +3061,19 @@
   return;
 
   if (MD->size_overridden_methods() > 0) {
-unsigned DiagID = isa(MD)
-  ? diag::warn_destructor_marked_not_override_overriding
-  : diag::warn_function_marked_not_override_overriding;
-Diag(MD->getLocation(), DiagID) << MD->getDeclName();
-const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
-Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
+auto EmitDiag = [&](unsigned DiagDtor, unsigned DiagFn) {
+  unsigned DiagID = isa(MD) ? DiagDtor : DiagFn;
+  Diag(MD->getLocation(), DiagID) << MD->getDeclName();
+  const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
+  Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
+};
+if (Inconsistent)
+  EmitDiag(
+  diag::warn_inconsistent_destructor_marked_not_override_overriding,
+  diag::warn_inconsistent_function_marked_not_override_overriding);
+else
+  EmitDiag(diag::warn_suggest_destructor_marked_not_override_overriding,
+   diag::warn_suggest_function_marked_not_override_overriding);
   }
 }
 
@@ -6749,13 +6756,10 @@
 }
   }
 
-  if (HasMethodWithOverrideControl &&
-  HasOverridingMethodWithoutOverrideControl) {
-// At least one method has the 'override' control declared.
-// Diagnose all other overridden methods which do not have 'override'
-// specified on them.
+  if (HasOverridingMethodWithoutOverrideControl) {
+bool HasInconsistentOverrideControl = HasMethodWithOverrideControl;
 for (auto *M : Record->methods())
-  DiagnoseAbsenceOfOverrideControl(M);
+  DiagnoseAbsenceOfOverrideControl(M, HasInconsistentOverrideControl);
   }
 
   // Check the defaulted secondary comparisons after any other member functions.
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -6961,7 +6961,7 @@
 
   /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
   /// not used in the declaration of an overriding method.
-  void DiagnoseAbsenceOfOverrideControl(NamedDecl *D);
+  void DiagnoseAbsenceOfOverrideControl(NamedDecl *D, bool 

[PATCH] D81583: Update SystemZ ABI to handle C++20 [[no_unique_address]] attribute

2020-07-07 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I'm tempted to say this is a bugfix for the implementation of 
no_unique_address, and just fix it globally for all ABIs.  We're never going to 
get anything done here if we require a separate patch for each ABI variant 
clang supports.




Comment at: clang/lib/CodeGen/TargetInfo.cpp:524
+  if (isa(RT->getDecl()) &&
+  !(AllowNoUniqueAddr && FD->hasAttr()))
 return false;

Does this do the right thing with a field that's an array of empty classes?



Comment at: clang/lib/CodeGen/TargetInfo.cpp:7245
   // do count.  So do anonymous bitfields that aren't zero-sized.
-  if (getContext().getLangOpts().CPlusPlus &&
-  FD->isZeroLengthBitField(getContext()))
-continue;
+  if (getContext().getLangOpts().CPlusPlus) {
+if (FD->isZeroLengthBitField(getContext()))

Only loosely relevant to this patch, but checking getLangOpts().CPlusPlus here 
seems weird; doesn't that break calling functions defined in C from C++ code?


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

https://reviews.llvm.org/D81583



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


[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-07 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added inline comments.



Comment at: llvm/test/Other/opt-O2-pipeline.ll:289
+; CHECK-NEXT: Branch Probability Analysis
+; CHECK-NEXT: Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager

MaskRay wrote:
> zequanwu wrote:
> > zequanwu wrote:
> > > nikic wrote:
> > > > hans wrote:
> > > > > nikic wrote:
> > > > > > Is it possible to switch this pass to use LazyBPI / LazyBFA, only 
> > > > > > fetched if PGO is actually in use?
> > > > > > 
> > > > > > PGO functionality that most people don't use adding expensive 
> > > > > > analysis passes like PDT should be avoided.
> > > > > I wonder if just switching to LazyBlockFrequencyInfo would help 
> > > > > though. It looks to me like the CGProfile would request info about 
> > > > > each function anyway.
> > > > > 
> > > > > I was surprised to see that Clang sets Opts.CallGraphProfile solely 
> > > > > based on whether the integrated assembler is used. Maybe a better fix 
> > > > > is to only set that to true when a profile is actually being used?
> > > > > I wonder if just switching to LazyBlockFrequencyInfo would help 
> > > > > though. It looks to me like the CGProfile would request info about 
> > > > > each function anyway.
> > > > 
> > > > It would only help if there is some way to only fetch the analysis 
> > > > conditionally. I believe many PGO passes use something like 
> > > > PSI.hasProfileSummary() or F.hasProfileData() for that.
> > > > 
> > > > > I was surprised to see that Clang sets Opts.CallGraphProfile solely 
> > > > > based on whether the integrated assembler is used. Maybe a better fix 
> > > > > is to only set that to true when a profile is actually being used?
> > > > 
> > > > Right, just disabling this by default in clang/opt would also work.
> > > > 
> > > > For reference, the current compile-time numbers for this patch: 
> > > > https://llvm-compile-time-tracker.com/compare.php?from=516ff1d4baee28b1911737e47b42973567adf8ff=8df840660bb764b6653fcfd9ac7a72cc6adebde6=instructions
> > > >  Not huge, but it adds up (some similar regressions have been 
> > > > introduced in LLVM 10).
> > > Do you mean disabling it just for LPM or both?
> > > I was surprised to see that Clang sets Opts.CallGraphProfile solely based 
> > > on whether the integrated assembler is used. Maybe a better fix is to 
> > > only set that to true when a profile is actually being used?
> > For Clang, a better fix I think is that `Opts.CallGraphProfile` should 
> > based on both whether the integrated assembler is used and whether profile 
> > instrumentation is turned on. What do you think?
> I'd prefer not having `CallGraphProfile`
> 
> * `-no-integrated-as -S` => no .cgprofile (.llvm_addrsig behaves this way)
> * `-S` -> .cgprofile
As discussed above, I think `CGProfilePass` should be disabled by default in 
clang unless `-no-integrated-as` is not given and 
`-fprofile-instrument-use-path=` is given. So, `Opts.CallGraphProfile` is a 
convenient switch for that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013



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


[PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses

2020-07-07 Thread Zola Bridges via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9d9e499840af: [x86][seses] Add clang flag; Use lvi-cfi with 
seses (authored by zbrid).
Herald added a subscriber: jfb.

Changed prior to commit:
  https://reviews.llvm.org/D79910?vs=272117=275687#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79910

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll

Index: llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll
===
--- llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll
+++ llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll
@@ -1,8 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable %s -o - | FileCheck %s
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable -x86-seses-one-lfence-per-bb %s -o - | FileCheck %s --check-prefix=X86-ONE-LFENCE
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable -x86-seses-omit-branch-lfences %s -o - | FileCheck %s --check-prefix=X86-OMIT-BR
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable -x86-seses-only-lfence-non-const %s -o - | FileCheck %s --check-prefix=X86-NON-CONST
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi %s -o - | FileCheck %s
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi -x86-seses-one-lfence-per-bb %s -o - | FileCheck %s --check-prefix=X86-ONE-LFENCE
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi -x86-seses-omit-branch-lfences %s -o - | FileCheck %s --check-prefix=X86-OMIT-BR
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi -x86-seses-only-lfence-non-const %s -o - | FileCheck %s --check-prefix=X86-NON-CONST
 
 define void @_Z4buzzv() {
 ; CHECK-LABEL: _Z4buzzv:
Index: llvm/lib/Target/X86/X86Subtarget.h
===
--- llvm/lib/Target/X86/X86Subtarget.h
+++ llvm/lib/Target/X86/X86Subtarget.h
@@ -442,6 +442,9 @@
   /// POP+LFENCE+JMP sequence.
   bool UseLVIControlFlowIntegrity = false;
 
+  /// Enable Speculative Execution Side Effect Suppression
+  bool UseSpeculativeExecutionSideEffectSuppression = false;
+
   /// Insert LFENCE instructions to prevent data speculatively injected into
   /// loads from being used maliciously.
   bool UseLVILoadHardening = false;
@@ -759,6 +762,9 @@
   bool useGLMDivSqrtCosts() const { return UseGLMDivSqrtCosts; }
   bool useLVIControlFlowIntegrity() const { return UseLVIControlFlowIntegrity; }
   bool useLVILoadHardening() const { return UseLVILoadHardening; }
+  bool useSpeculativeExecutionSideEffectSuppression() const {
+return UseSpeculativeExecutionSideEffectSuppression;
+  }
 
   unsigned getPreferVectorWidth() const { return PreferVectorWidth; }
   unsigned getRequiredVectorWidth() const { return RequiredVectorWidth; }
Index: llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
===
--- llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
+++ llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
@@ -30,7 +30,7 @@
 STATISTIC(NumLFENCEsInserted, "Number of lfence instructions inserted");
 
 static cl::opt EnableSpeculativeExecutionSideEffectSuppression(
-"x86-seses-enable",
+"x86-seses-enable-without-lvi-cfi",
 cl::desc("Force enable speculative execution side effect suppression. "
  "(Note: User must pass -mlvi-cfi in order to mitigate indirect "
  "branches and returns.)"),
@@ -91,10 +91,12 @@
   const auto  = MF.getTarget().getOptLevel();
   const X86Subtarget  = MF.getSubtarget();
 
-  // Check whether SESES needs to run as the fallback for LVI at O0 or if the
-  // user explicitly passed the SESES flag.
+  // Check whether SESES needs to run as the fallback for LVI at O0, whether the
+  // user explicitly passed an SESES flag, or whether the SESES target feature
+  // was set.
   if (!EnableSpeculativeExecutionSideEffectSuppression &&
-  !(Subtarget.useLVILoadHardening() && OptLevel == CodeGenOpt::None))
+  !(Subtarget.useLVILoadHardening() && OptLevel == CodeGenOpt::None) &&
+  !Subtarget.useSpeculativeExecutionSideEffectSuppression())
 return false;
 
   LLVM_DEBUG(dbgs() << "** " << getPassName() << " : " << MF.getName()
Index: llvm/lib/Target/X86/X86.td

[PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses

2020-07-07 Thread Zola Bridges via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9d9e499840af: [x86][seses] Add clang flag; Use lvi-cfi with 
seses (authored by zbrid).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79910

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll

Index: llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll
===
--- llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll
+++ llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll
@@ -1,8 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable %s -o - | FileCheck %s
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable -x86-seses-one-lfence-per-bb %s -o - | FileCheck %s --check-prefix=X86-ONE-LFENCE
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable -x86-seses-omit-branch-lfences %s -o - | FileCheck %s --check-prefix=X86-OMIT-BR
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable -x86-seses-only-lfence-non-const %s -o - | FileCheck %s --check-prefix=X86-NON-CONST
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi %s -o - | FileCheck %s
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi -x86-seses-one-lfence-per-bb %s -o - | FileCheck %s --check-prefix=X86-ONE-LFENCE
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi -x86-seses-omit-branch-lfences %s -o - | FileCheck %s --check-prefix=X86-OMIT-BR
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi -x86-seses-only-lfence-non-const %s -o - | FileCheck %s --check-prefix=X86-NON-CONST
 
 define void @_Z4buzzv() {
 ; CHECK-LABEL: _Z4buzzv:
Index: llvm/lib/Target/X86/X86Subtarget.h
===
--- llvm/lib/Target/X86/X86Subtarget.h
+++ llvm/lib/Target/X86/X86Subtarget.h
@@ -442,6 +442,9 @@
   /// POP+LFENCE+JMP sequence.
   bool UseLVIControlFlowIntegrity = false;
 
+  /// Enable Speculative Execution Side Effect Suppression
+  bool UseSpeculativeExecutionSideEffectSuppression = false;
+
   /// Insert LFENCE instructions to prevent data speculatively injected into
   /// loads from being used maliciously.
   bool UseLVILoadHardening = false;
@@ -759,6 +762,9 @@
   bool useGLMDivSqrtCosts() const { return UseGLMDivSqrtCosts; }
   bool useLVIControlFlowIntegrity() const { return UseLVIControlFlowIntegrity; }
   bool useLVILoadHardening() const { return UseLVILoadHardening; }
+  bool useSpeculativeExecutionSideEffectSuppression() const {
+return UseSpeculativeExecutionSideEffectSuppression;
+  }
 
   unsigned getPreferVectorWidth() const { return PreferVectorWidth; }
   unsigned getRequiredVectorWidth() const { return RequiredVectorWidth; }
Index: llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
===
--- llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
+++ llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
@@ -30,7 +30,7 @@
 STATISTIC(NumLFENCEsInserted, "Number of lfence instructions inserted");
 
 static cl::opt EnableSpeculativeExecutionSideEffectSuppression(
-"x86-seses-enable",
+"x86-seses-enable-without-lvi-cfi",
 cl::desc("Force enable speculative execution side effect suppression. "
  "(Note: User must pass -mlvi-cfi in order to mitigate indirect "
  "branches and returns.)"),
@@ -91,10 +91,12 @@
   const auto  = MF.getTarget().getOptLevel();
   const X86Subtarget  = MF.getSubtarget();
 
-  // Check whether SESES needs to run as the fallback for LVI at O0 or if the
-  // user explicitly passed the SESES flag.
+  // Check whether SESES needs to run as the fallback for LVI at O0, whether the
+  // user explicitly passed an SESES flag, or whether the SESES target feature
+  // was set.
   if (!EnableSpeculativeExecutionSideEffectSuppression &&
-  !(Subtarget.useLVILoadHardening() && OptLevel == CodeGenOpt::None))
+  !(Subtarget.useLVILoadHardening() && OptLevel == CodeGenOpt::None) &&
+  !Subtarget.useSpeculativeExecutionSideEffectSuppression())
 return false;
 
   LLVM_DEBUG(dbgs() << "** " << getPassName() << " : " << MF.getName()
Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ 

[clang] 9d9e499 - [x86][seses] Add clang flag; Use lvi-cfi with seses

2020-07-07 Thread Zola Bridges via cfe-commits

Author: Zola Bridges
Date: 2020-07-07T13:20:13-07:00
New Revision: 9d9e499840af670b9644af77ce846c52085c23a1

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

LOG: [x86][seses] Add clang flag; Use lvi-cfi with seses

This patch creates a clang flag to enable SESES. This flag also ensures that
lvi-cfi is on when using seses via clang.

SESES should use lvi-cfi to mitigate returns and indirect branches.

The flag to enable the SESES functionality only without lvi-cfi is now
-x86-seses-enable-without-lvi-cfi to warn users part of the mitigation is not
enabled if they use this flag. This is useful in case folks want to see the
cost of SESES separate from the LVI-CFI.

Reviewed By: sconstab

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

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Arch/X86.cpp
clang/test/Driver/x86-target-features.c
llvm/lib/Target/X86/X86.td
llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
llvm/lib/Target/X86/X86Subtarget.h
llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 672c4ae80e73..0b56b7ac4206 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -2755,6 +2755,10 @@ Generate a \_\_mcount\_loc section entry for each 
\_\_fentry\_\_ call.
 
 Make StdCall calling convention the default
 
+.. option:: -mseses, -mno-seses
+
+Enable speculative execution side effect suppression (SESES). Includes LVI 
control flow integrity mitigations
+
 .. option:: -msign-return-address=
 
 Select return address signing scope

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 745c696bcaa3..c95d427da267 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2264,6 +2264,11 @@ def mlvi_cfi : Flag<["-"], "mlvi-cfi">, Group, 
Flags<[CoreOption,Driver
   HelpText<"Enable only control-flow mitigations for Load Value Injection 
(LVI)">;
 def mno_lvi_cfi : Flag<["-"], "mno-lvi-cfi">, Group, 
Flags<[CoreOption,DriverOption]>,
   HelpText<"Disable control-flow mitigations for Load Value Injection (LVI)">;
+def m_seses : Flag<["-"], "mseses">, Group, Flags<[CoreOption, 
DriverOption]>,
+  HelpText<"Enable speculative execution side effect suppression (SESES). "
+"Includes LVI control flow integrity mitigations">;
+def mno_seses : Flag<["-"], "mno-seses">, Group, Flags<[CoreOption, 
DriverOption]>,
+  HelpText<"Disable speculative execution side effect suppression (SESES)">;
 
 def mrelax : Flag<["-"], "mrelax">, Group,
   HelpText<"Enable linker relaxation">;

diff  --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index dbbc025de38c..aa95c4189d1e 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -184,6 +184,24 @@ void x86::getX86TargetFeatures(const Driver , const 
llvm::Triple ,
 LVIOpt = options::OPT_mlvi_cfi;
   }
 
+  if (Args.hasFlag(options::OPT_m_seses, options::OPT_mno_seses, false)) {
+if (LVIOpt == options::OPT_mlvi_hardening)
+  D.Diag(diag::err_drv_argument_not_allowed_with)
+  << D.getOpts().getOptionName(options::OPT_mlvi_hardening)
+  << D.getOpts().getOptionName(options::OPT_m_seses);
+
+if (SpectreOpt != clang::driver::options::ID::OPT_INVALID)
+  D.Diag(diag::err_drv_argument_not_allowed_with)
+  << D.getOpts().getOptionName(SpectreOpt)
+  << D.getOpts().getOptionName(options::OPT_m_seses);
+
+Features.push_back("+seses");
+if (!Args.hasArg(options::OPT_mno_lvi_cfi)) {
+  Features.push_back("+lvi-cfi");
+  LVIOpt = options::OPT_mlvi_cfi;
+}
+  }
+
   if (SpectreOpt != clang::driver::options::ID::OPT_INVALID &&
   LVIOpt != clang::driver::options::ID::OPT_INVALID) {
 D.Diag(diag::err_drv_argument_not_allowed_with)

diff  --git a/clang/test/Driver/x86-target-features.c 
b/clang/test/Driver/x86-target-features.c
index 817caeecd71e..85a9374ab905 100644
--- a/clang/test/Driver/x86-target-features.c
+++ b/clang/test/Driver/x86-target-features.c
@@ -178,6 +178,27 @@
 // RUN: %clang -target i386-linux-gnu -mlvi-hardening 
-mretpoline-external-thunk %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=LVIHARDENING-RETPOLINE-EXTERNAL-THUNK %s
 // LVIHARDENING-RETPOLINE-EXTERNAL-THUNK: error: invalid argument 
'mretpoline-external-thunk' not allowed with 'mlvi-hardening'
 
+// RUN: %clang -target i386-linux-gnu -mseses %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=SESES %s
+// RUN: %clang 

[PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses

2020-07-07 Thread Zola Bridges via Phabricator via cfe-commits
zbrid updated this revision to Diff 276196.
zbrid added a comment.

rebase prior to commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79910

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll

Index: llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll
===
--- llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll
+++ llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll
@@ -1,8 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable %s -o - | FileCheck %s
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable -x86-seses-one-lfence-per-bb %s -o - | FileCheck %s --check-prefix=X86-ONE-LFENCE
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable -x86-seses-omit-branch-lfences %s -o - | FileCheck %s --check-prefix=X86-OMIT-BR
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable -x86-seses-only-lfence-non-const %s -o - | FileCheck %s --check-prefix=X86-NON-CONST
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi %s -o - | FileCheck %s
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi -x86-seses-one-lfence-per-bb %s -o - | FileCheck %s --check-prefix=X86-ONE-LFENCE
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi -x86-seses-omit-branch-lfences %s -o - | FileCheck %s --check-prefix=X86-OMIT-BR
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi -x86-seses-only-lfence-non-const %s -o - | FileCheck %s --check-prefix=X86-NON-CONST
 
 define void @_Z4buzzv() {
 ; CHECK-LABEL: _Z4buzzv:
Index: llvm/lib/Target/X86/X86Subtarget.h
===
--- llvm/lib/Target/X86/X86Subtarget.h
+++ llvm/lib/Target/X86/X86Subtarget.h
@@ -442,6 +442,9 @@
   /// POP+LFENCE+JMP sequence.
   bool UseLVIControlFlowIntegrity = false;
 
+  /// Enable Speculative Execution Side Effect Suppression
+  bool UseSpeculativeExecutionSideEffectSuppression = false;
+
   /// Insert LFENCE instructions to prevent data speculatively injected into
   /// loads from being used maliciously.
   bool UseLVILoadHardening = false;
@@ -759,6 +762,9 @@
   bool useGLMDivSqrtCosts() const { return UseGLMDivSqrtCosts; }
   bool useLVIControlFlowIntegrity() const { return UseLVIControlFlowIntegrity; }
   bool useLVILoadHardening() const { return UseLVILoadHardening; }
+  bool useSpeculativeExecutionSideEffectSuppression() const {
+return UseSpeculativeExecutionSideEffectSuppression;
+  }
 
   unsigned getPreferVectorWidth() const { return PreferVectorWidth; }
   unsigned getRequiredVectorWidth() const { return RequiredVectorWidth; }
Index: llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
===
--- llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
+++ llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
@@ -30,7 +30,7 @@
 STATISTIC(NumLFENCEsInserted, "Number of lfence instructions inserted");
 
 static cl::opt EnableSpeculativeExecutionSideEffectSuppression(
-"x86-seses-enable",
+"x86-seses-enable-without-lvi-cfi",
 cl::desc("Force enable speculative execution side effect suppression. "
  "(Note: User must pass -mlvi-cfi in order to mitigate indirect "
  "branches and returns.)"),
@@ -91,10 +91,12 @@
   const auto  = MF.getTarget().getOptLevel();
   const X86Subtarget  = MF.getSubtarget();
 
-  // Check whether SESES needs to run as the fallback for LVI at O0 or if the
-  // user explicitly passed the SESES flag.
+  // Check whether SESES needs to run as the fallback for LVI at O0, whether the
+  // user explicitly passed an SESES flag, or whether the SESES target feature
+  // was set.
   if (!EnableSpeculativeExecutionSideEffectSuppression &&
-  !(Subtarget.useLVILoadHardening() && OptLevel == CodeGenOpt::None))
+  !(Subtarget.useLVILoadHardening() && OptLevel == CodeGenOpt::None) &&
+  !Subtarget.useSpeculativeExecutionSideEffectSuppression())
 return false;
 
   LLVM_DEBUG(dbgs() << "** " << getPassName() << " : " << MF.getName()
Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -455,6 +455,15 @@
   "LFENCE instruction to serialize control 

[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-07-07 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1064
 setSize(getSize() + PtrWidth);
 setDataSize(getSize());
   }

I would suggest setting `HandledFirstNonOverlappingEmptyField` to `true` here 
with an assertion that the current type is not a union.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1796
+  bool FoundFirstNonOverlappingEmptyFieldToHandle =
+  DefaultsToAIXPowerAlignment && FieldOffset == CharUnits::Zero() &&
+  !HandledFirstNonOverlappingEmptyField && !IsOverlappingEmptyField;

The condition is still more complex than I think it should be.

If we have found a "first" other-than-overlapping-empty-field, then we should 
set `HandledFirstNonOverlappingEmptyField` to `true` for non-union cases.

If `HandledFirstNonOverlappingEmptyField` being `false` is not enough for 
`FieldOffset == CharUnits::Zero()` to be true, then I think the correction 
would be to set `HandledFirstNonOverlappingEmptyField` in more places.

I would like to remove the check on `FieldOffset == CharUnits::Zero()` from 
here and instead have an assertion that `!HandledFirstNonOverlappingEmptyField` 
implies `FieldOffset == CharUnits::Zero()`.

Also, since we're managing `HandledFirstNonOverlappingEmptyField` in non-AIX 
cases, we should remove the `DefaultsToAIXPowerAlignment` condition for what is 
currently named `FoundFirstNonOverlappingEmptyFieldToHandle` (adjusting uses of 
it as necessary) and rename `FoundFirstNonOverlappingEmptyFieldToHandle` to 
`FoundFirstNonOverlappingEmptyField`.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1832
 EffectiveFieldSize = FieldSize = CharUnits::Zero();
 const ArrayType* ATy = Context.getAsArrayType(D->getType());
+TypeInfo TI = Context.getTypeInfo(D->getType());

`ATy` seems to be an unused variable now.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1834
+TypeInfo TI = Context.getTypeInfo(D->getType());
+FieldAlign = Context.toCharUnitsFromBits(TI.Align);
+AlignIsRequired = TI.AlignIsRequired;

I guess this works (we have a test for it), but the previous code made a point 
to use the element type and not the array type (and the comment above says we 
can't directly query `getTypeInfo` with the array type). @Xiangling_L, can you 
confirm if the comment is out-of-date and update it?



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1909
+  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+  (IsUnion || FoundFirstNonOverlappingEmptyFieldToHandle)) {
+auto upgradeAlignment = [&](const BuiltinType *BTy) {

It should now be the case that `FoundFirstNonOverlappingEmptyFieldToHandle` is 
`true` for all union members that are not empty, meaning that the `IsUnion` 
part of the check only serves to admit attempts to handle types that are empty 
(and thus does not have subobjects that would induce an alignment upgrade).


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

https://reviews.llvm.org/D79719



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


[PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST)

2020-07-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Parse/ParseExpr.cpp:1933
 }
+if (getLangOpts().OpenMP >= 50 && Tok.is(tok::colon)) {
+  // Consume ':'

cchen wrote:
> cchen wrote:
> > ABataev wrote:
> > > You need to insert an additional check for `OMPClauseKind == 
> > > llvm::omp::Clause::OMPC_to || OMPClauseKind == 
> > > llvm::omp::Clause::OMPC_from` here. I.e. we shall expect stride not only 
> > > if the version is 5.0, but also if the current clauses is `to` or `from`
> > Got it, I was thinking that we might want to emit diagnostic message for 
> > OpenMP version < 50. Thanks for your explaination.
> Just want to make sure the error message for OpenMP5.0, for this case: 
> `#pragma omp target data map(to: marr[10][0:2:2])`.
> 
> OpenMP45:
> We don't expect stride at all, so we only emit the error message expecting 
> ']' just as before.
> 
> OpenMP50:
> Should I emit the new error message to inform user that stride can not use in 
> clause other than to or from?
> 
> Thanks.
I think, the same behavior just like for OpenMP 4.5 should be fine here since 
stride is not allowed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82800



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


[PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST)

2020-07-07 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked an inline comment as done.
cchen added inline comments.



Comment at: clang/lib/Parse/ParseExpr.cpp:1933
 }
+if (getLangOpts().OpenMP >= 50 && Tok.is(tok::colon)) {
+  // Consume ':'

cchen wrote:
> ABataev wrote:
> > You need to insert an additional check for `OMPClauseKind == 
> > llvm::omp::Clause::OMPC_to || OMPClauseKind == 
> > llvm::omp::Clause::OMPC_from` here. I.e. we shall expect stride not only if 
> > the version is 5.0, but also if the current clauses is `to` or `from`
> Got it, I was thinking that we might want to emit diagnostic message for 
> OpenMP version < 50. Thanks for your explaination.
Just want to make sure the error message for OpenMP5.0, for this case: `#pragma 
omp target data map(to: marr[10][0:2:2])`.

OpenMP45:
We don't expect stride at all, so we only emit the error message expecting ']' 
just as before.

OpenMP50:
Should I emit the new error message to inform user that stride can not use in 
clause other than to or from?

Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82800



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


[PATCH] D82278: Fix traversal over CXXConstructExpr in Syntactic mode

2020-07-07 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Thanks for this fix!




Comment at: clang/lib/AST/Expr.cpp:3001
 Expr *A = C->getArg(0);
-if (A->getSourceRange() == SR || !isa(C))
+if (A->getSourceRange() == SR || C->isElidable()) {
   E = A;

aaron.ballman wrote:
> Looks like the change introduced new curly braces for a single-line if.
Why is it necessary to check isElidable?  I think the logic here is subtle 
(since the AST doesn't explicitly tag implicit expressions), so please add an 
explanatory comment.



Comment at: clang/lib/AST/ParentMapContext.cpp:163
   if (const auto *C = dyn_cast(E)) {
-if (C->getSourceRange() == SR || !isa(C))
+if (C->getSourceRange() == SR || C->isElidable())
   return true;

Same here. Please comment on the logic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82278



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


[PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST)

2020-07-07 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked an inline comment as done.
cchen added inline comments.



Comment at: clang/lib/Parse/ParseExpr.cpp:1933
 }
+if (getLangOpts().OpenMP >= 50 && Tok.is(tok::colon)) {
+  // Consume ':'

ABataev wrote:
> You need to insert an additional check for `OMPClauseKind == 
> llvm::omp::Clause::OMPC_to || OMPClauseKind == llvm::omp::Clause::OMPC_from` 
> here. I.e. we shall expect stride not only if the version is 5.0, but also if 
> the current clauses is `to` or `from`
Got it, I was thinking that we might want to emit diagnostic message for OpenMP 
version < 50. Thanks for your explaination.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82800



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


[PATCH] D83301: [clang-tidy] More strict on matching the standard memset function in memset-usage check.

2020-07-07 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

If you want to be super explicit. Why not add `parameterCountIs(3)`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83301



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


[PATCH] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute

2020-07-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

@aaron.ballman We will need to do something like this in general, but I'm not 
sure it's going to be as easy as just inheriting the attribute in the general 
case. What do you think?




Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:3540
+Attr *IA = Previous->getAttr();
+D->addAttr(IA);
+  } else if (!Previous->hasAttr() &&

I think it would be more consistent to clone the attribute here (and mark it as 
inherited) rather than attaching the same attribute to multiple declarations.



Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:3544
+Attr *IA = D->getAttr();
+Previous->addAttr(IA);
+  }

I think we should only propagate attributes forwards along redeclaration 
chains. Is this single-step-backwards propagation necessary?



Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:3709
+  // it needs to be added to all the declarations in the redeclarable chain.
+  mergeInheritableAttributes(D, Previous);
 }

Please add a FIXME to do this is general.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83174



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


[PATCH] D83338: [PowerPC][Power10] Implemented Vector Shift Builtins

2020-07-07 Thread Albion Fung via Phabricator via cfe-commits
Conanap created this revision.
Conanap added reviewers: PowerPC, power-llvm-team, saghir, nemanjai, hfinkel.
Conanap added projects: LLVM, clang, PowerPC.

Implemented the following vector right and left shift builtins and its test 
cases:

  vector unsigned __int128 vec_sl(vector unsigned __int128 a, vector unsigned 
__int128 b)
  vector signed __int128 vec_sl(vector signed __int128 a, vector unsigned 
__int128 b)
  vector unsigned __int128 vec_sr(vector unsigned __int128 a, vector unsigned 
__int128 b)
  vector signed __int128 vec_sr(vector signed __int128 a, vector unsigned 
__int128 b)
  vector unsigned __int128 vec_sra(vector unsigned __int128 a, vector unsigned 
__int128 b)
  vector signed __int128 vec_sra(vector signed __int128 a, vector unsigned 
__int128 b)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83338

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
  llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s

Index: llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
===
--- llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
+++ llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
@@ -405,3 +405,12 @@
 # CHECK-BE: vinsdrx 1, 2, 3   # encoding: [0x10,0x22,0x1b,0xcf]
 # CHECK-LE: vinsdrx 1, 2, 3   # encoding: [0xcf,0x1b,0x22,0x10]
 vinsdrx 1, 2, 3
+# CHECK-BE: vslq 2, 3, 4  # encoding: [0x10,0x43,0x21,0x05]
+# CHECK-LE: vslq 2, 3, 4  # encoding: [0x05,0x21,0x43,0x10]
+vslq 2, 3, 4
+# CHECK-BE: vsraq 2, 3, 4 # encoding: [0x10,0x43,0x23,0x05]
+# CHECK-LE: vsraq 2, 3, 4 # encoding: [0x05,0x23,0x43,0x10]
+vsraq 2, 3, 4
+# CHECK-BE: vsrq 2, 3, 4  # encoding: [0x10,0x43,0x22,0x05]
+# CHECK-LE: vsrq 2, 3, 4  # encoding: [0x05,0x22,0x43,0x10]
+vsrq 2, 3, 4
Index: llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
===
--- llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
+++ llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
@@ -278,3 +278,12 @@
 
 # CHECK: vinsdrx 1, 2, 3
 0x10 0x22 0x1b 0xcf
+
+# CHECK: vsrq 2, 3, 4
+0x10 0x43 0x22 0x05
+
+# CHECK: vslq 2, 3, 4
+0x10 0x43 0x21 0x05
+
+# CHECK: vsraq 2, 3, 4
+0x10 0x43 0x23 0x05
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -915,6 +915,11 @@
  "vclrrb $vD, $vA, $rB", IIC_VecGeneral,
  [(set v16i8:$vD,
(int_ppc_altivec_vclrrb v16i8:$vA, i32:$rB))]>;
+
+  def VSLQ   : VX1_Int_Ty< 261, "vslq", int_ppc_altivec_vslq, v1i128>;
+  def VSRAQ  : VX1_Int_Ty< 773, "vsraq", int_ppc_altivec_vsraq, v1i128>;
+  def VSRQ   : VX1_Int_Ty< 517, "vsrq" , int_ppc_altivec_vsrq, v1i128>;
+
 }
 
 // Anonymous Patterns //
Index: llvm/include/llvm/IR/IntrinsicsPowerPC.td
===
--- llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -788,6 +788,7 @@
 def int_ppc_altivec_vsrv  : PowerPC_Vec_BBB_Intrinsic<"vsrv">;
 def int_ppc_altivec_vslh  : PowerPC_Vec_HHH_Intrinsic<"vslh">;
 def int_ppc_altivec_vslw  : PowerPC_Vec_WWW_Intrinsic<"vslw">;
+def int_ppc_altivec_vslq  : PowerPC_Vec_QQQ_Intrinsic<"vslq">;
 
 // Right Shifts.
 def int_ppc_altivec_vsr   : PowerPC_Vec_WWW_Intrinsic<"vsr">;
@@ -796,9 +797,11 @@
 def int_ppc_altivec_vsrb  : PowerPC_Vec_BBB_Intrinsic<"vsrb">;
 def int_ppc_altivec_vsrh  : PowerPC_Vec_HHH_Intrinsic<"vsrh">;
 def int_ppc_altivec_vsrw  : PowerPC_Vec_WWW_Intrinsic<"vsrw">;
+def int_ppc_altivec_vsrq   : PowerPC_Vec_QQQ_Intrinsic<"vsrq">;
 def int_ppc_altivec_vsrab : PowerPC_Vec_BBB_Intrinsic<"vsrab">;
 def int_ppc_altivec_vsrah : PowerPC_Vec_HHH_Intrinsic<"vsrah">;
 def int_ppc_altivec_vsraw : PowerPC_Vec_WWW_Intrinsic<"vsraw">;
+def int_ppc_altivec_vsraq : PowerPC_Vec_QQQ_Intrinsic<"vsraq">;
 
 // Rotates.
 def int_ppc_altivec_vrlb  : PowerPC_Vec_BBB_Intrinsic<"vrlb">;
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -17095,6 +17095,37 @@
   return __builtin_vsx_xxblendvd(__a, __b, __c);
 }
 #endif /* __VSX__ */
+
+/* vector shifts for quadwords */
+static __inline__ vector unsigned __int128 __ATTRS_o_ai
+vec_sl(vector unsigned __int128 __a, vector unsigned __int128 __b) {
+  return 

[PATCH] D82477: [lldb-vscode] Add Support for Module Event

2020-07-07 Thread Greg Clayton via Phabricator via cfe-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

So looks like you didn't use "git commit --amend -a" again here. These changes 
are incremental changes on your patch which hasn't been submitted yet?




Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:21
+program_basename = "a.out.stripped"
+program= self.getBuildArtifact(program_basename)
 self.build_and_launch(program)

add a space after "program"



Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:33-34
+program_module = active_modules[program_basename]
+self.assertIn('name', program_module, 'make sure name is in module')
+self.assertEqual(program_basename, program_module['name'])
+self.assertTrue('symbolFilePath' not in program_module, 'Make sure 
a.out.stripped has no debug info')

Do a similar check for ='path'
```
self.assertIn('name', program_module, 'make sure "name" is in module')
self.assertEqual(program_basename, program_module['name'])
self.assertIn('path', program_module, 'make sure "path" is in module')
self.assertEqual(program, program_module['path'])
```
In general, make sure you test every key that you have added support for.



Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:35
+self.assertEqual(program_basename, program_module['name'])
+self.assertTrue('symbolFilePath' not in program_module, 'Make sure 
a.out.stripped has no debug info')
+symbol_path = self.getBuildArtifact("a.out")

Check for the symbol status here:
```
self.assertEqual('Symbols not found.', program_module['symbolStatus'])
```



Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:40
+program_module = active_modules[program_basename]
+self.assertEqual(program_basename, program_module['name'])
+self.assertEqual('Symbols loaded.', program_module['symbolStatus'])

verify 'path' again



Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:346
+object.try_emplace("symbolFilePath", symbol_path);
   }
   std::string loaded_addr = std::to_string(

Add an else clause here:

```
} else {
  object.try_emplace("symbolStatus", "Symbols not found.");
}
```



Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:352-357
+  uint32_t num_versions = module.GetVersion(version_nums, 
sizeof(version_nums)/sizeof(uint32_t));
+  for (uint32_t i=0; ihttps://reviews.llvm.org/D82477/new/

https://reviews.llvm.org/D82477



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


[PATCH] D82728: [clang] Add -Wsuggest-override

2020-07-07 Thread Logan Smith via Phabricator via cfe-commits
logan-5 marked 2 inline comments as done.
logan-5 added a comment.

In D82728#2137021 , @dblaikie wrote:

> I think it might be nice to make the -Wno-inconsistent-missing-override 
> -Wsuggest-override situation a bit better (by having it still do the same 
> thing as -Wsuggest-override) but I don't feel /too/ strongly about it.


So, ironing this out would mean the code would need this structure:

  if (Inconsistent && IsWarningEnabled(-Winconsistent-missing-override))
  Emit(-Winconsistent-missing-override);
  else
  Emit(-Wsuggest-override);

The issue is that I wasn't able to find a way to ask if a warning is enabled 
and make a control flow decision based on that. If there is an API for doing 
this, it's hidden well. :) So I fell back to just doing `if (Inconsistent)` 
instead, which has this quirk if the inconsistent version of the warning is 
disabled.




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:3064
   if (MD->size_overridden_methods() > 0) {
-unsigned DiagID = isa(MD)
-  ? 
diag::warn_destructor_marked_not_override_overriding
-  : diag::warn_function_marked_not_override_overriding;
-Diag(MD->getLocation(), DiagID) << MD->getDeclName();
-const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
-Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
+auto EmitDiag = [this, MD](unsigned DiagDtor, unsigned DiagFn) {
+  unsigned DiagID = isa(MD) ? DiagDtor : DiagFn;

dblaikie wrote:
> Generally I'd recommend default ref capture `[&]` on any lambda that doesn't 
> escape its scope - normal scopes don't need to document which variables you 
> use inside them, and I think the same applies to lambdas (bit more debatable 
> when the lambda is named and called later, even within the same scope - so if 
> you feel strongly about keeping it the way it is, that's OK)
I don't feel strongly at all; I'm fine with `[&]`. I'll make that change.



Comment at: clang/test/SemaCXX/warn-suggest-override:3-4
+
+class A {
+ public:
+  ~A() {}

dblaikie wrote:
> I'd probably simplify these tests by using struct, so everything's implicitly 
> public, rather than class and having to make things public.
> 
> Also probably member function declarations rather than definitions would be 
> simpler?
Can do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728



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


[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-07-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78478



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


[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/test/Other/opt-O2-pipeline.ll:289
+; CHECK-NEXT: Branch Probability Analysis
+; CHECK-NEXT: Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager

zequanwu wrote:
> zequanwu wrote:
> > nikic wrote:
> > > hans wrote:
> > > > nikic wrote:
> > > > > Is it possible to switch this pass to use LazyBPI / LazyBFA, only 
> > > > > fetched if PGO is actually in use?
> > > > > 
> > > > > PGO functionality that most people don't use adding expensive 
> > > > > analysis passes like PDT should be avoided.
> > > > I wonder if just switching to LazyBlockFrequencyInfo would help though. 
> > > > It looks to me like the CGProfile would request info about each 
> > > > function anyway.
> > > > 
> > > > I was surprised to see that Clang sets Opts.CallGraphProfile solely 
> > > > based on whether the integrated assembler is used. Maybe a better fix 
> > > > is to only set that to true when a profile is actually being used?
> > > > I wonder if just switching to LazyBlockFrequencyInfo would help though. 
> > > > It looks to me like the CGProfile would request info about each 
> > > > function anyway.
> > > 
> > > It would only help if there is some way to only fetch the analysis 
> > > conditionally. I believe many PGO passes use something like 
> > > PSI.hasProfileSummary() or F.hasProfileData() for that.
> > > 
> > > > I was surprised to see that Clang sets Opts.CallGraphProfile solely 
> > > > based on whether the integrated assembler is used. Maybe a better fix 
> > > > is to only set that to true when a profile is actually being used?
> > > 
> > > Right, just disabling this by default in clang/opt would also work.
> > > 
> > > For reference, the current compile-time numbers for this patch: 
> > > https://llvm-compile-time-tracker.com/compare.php?from=516ff1d4baee28b1911737e47b42973567adf8ff=8df840660bb764b6653fcfd9ac7a72cc6adebde6=instructions
> > >  Not huge, but it adds up (some similar regressions have been introduced 
> > > in LLVM 10).
> > Do you mean disabling it just for LPM or both?
> > I was surprised to see that Clang sets Opts.CallGraphProfile solely based 
> > on whether the integrated assembler is used. Maybe a better fix is to only 
> > set that to true when a profile is actually being used?
> For Clang, a better fix I think is that `Opts.CallGraphProfile` should based 
> on both whether the integrated assembler is used and whether profile 
> instrumentation is turned on. What do you think?
I'd prefer not having `CallGraphProfile`

* `-no-integrated-as -S` => no .cgprofile (.llvm_addrsig behaves this way)
* `-S` -> .cgprofile


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013



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


[PATCH] D83149: [gcov] Add __gcov_dump/__gcov_reset and delete __gcov_flush

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

`compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c.gcov` is 
clumsy to update. The filename is also wrong: gcov has nothing to do with 
instrprof.

I'll update the tests separately like my 
fba8523fb55c8e3bc853df7a250845cf51e5fc99 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83149



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


[PATCH] D83149: [gcov] Add __gcov_dump/__gcov_reset and delete __gcov_flush

2020-07-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 276173.
MaskRay marked 6 inline comments as done.
MaskRay added a comment.

Test __gcov_dump


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83149

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/CodeGen/code-coverage.c
  clang/test/Driver/darwin-ld.c
  compiler-rt/lib/profile/GCDAProfiling.c
  compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c
  compiler-rt/test/profile/Posix/gcov-dlopen.c
  compiler-rt/test/profile/Posix/gcov-shared-flush.c
  compiler-rt/test/profile/gcov-__gcov_flush-terminate.c
  compiler-rt/test/profile/gcov-dump-and-remove.c
  llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

Index: llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -130,7 +130,6 @@
   Function *
   insertCounterWriteout(ArrayRef>);
   Function *insertReset(ArrayRef>);
-  Function *insertFlush(Function *ResetF);
 
   bool AddFlushBeforeForkAndExec();
 
@@ -909,7 +908,6 @@
 
 Function *WriteoutF = insertCounterWriteout(CountersBySP);
 Function *ResetF = insertReset(CountersBySP);
-Function *FlushF = insertFlush(ResetF);
 
 // Create a small bit of code that registers the "__llvm_gcov_writeout" to
 // be executed at exit and the "__llvm_gcov_flush" function to be executed
@@ -927,14 +925,13 @@
 IRBuilder<> Builder(BB);
 
 FTy = FunctionType::get(Type::getVoidTy(*Ctx), false);
-Type *Params[] = {PointerType::get(FTy, 0), PointerType::get(FTy, 0),
-  PointerType::get(FTy, 0)};
-FTy = FunctionType::get(Builder.getVoidTy(), Params, false);
+auto *PFTy = PointerType::get(FTy, 0);
+FTy = FunctionType::get(Builder.getVoidTy(), {PFTy, PFTy}, false);
 
 // Initialize the environment and register the local writeout, flush and
 // reset functions.
 FunctionCallee GCOVInit = M->getOrInsertFunction("llvm_gcov_init", FTy);
-Builder.CreateCall(GCOVInit, {WriteoutF, FlushF, ResetF});
+Builder.CreateCall(GCOVInit, {WriteoutF, ResetF});
 Builder.CreateRetVoid();
 
 appendToGlobalCtors(*M, F, 0);
@@ -1266,36 +1263,3 @@
 
   return ResetF;
 }
-
-Function *GCOVProfiler::insertFlush(Function *ResetF) {
-  FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), false);
-  Function *FlushF = M->getFunction("__llvm_gcov_flush");
-  if (!FlushF)
-FlushF = Function::Create(FTy, GlobalValue::InternalLinkage,
-  "__llvm_gcov_flush", M);
-  FlushF->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
-  FlushF->addFnAttr(Attribute::NoInline);
-  if (Options.NoRedZone)
-FlushF->addFnAttr(Attribute::NoRedZone);
-
-  BasicBlock *Entry = BasicBlock::Create(*Ctx, "entry", FlushF);
-
-  // Write out the current counters.
-  Function *WriteoutF = M->getFunction("__llvm_gcov_writeout");
-  assert(WriteoutF && "Need to create the writeout function first!");
-
-  IRBuilder<> Builder(Entry);
-  Builder.CreateCall(WriteoutF, {});
-  Builder.CreateCall(ResetF, {});
-
-  Type *RetTy = FlushF->getReturnType();
-  if (RetTy->isVoidTy())
-Builder.CreateRetVoid();
-  else if (RetTy->isIntegerTy())
-// Used if __llvm_gcov_flush was implicitly declared.
-Builder.CreateRet(ConstantInt::get(RetTy, 0));
-  else
-report_fatal_error("invalid return type for __llvm_gcov_flush");
-
-  return FlushF;
-}
Index: compiler-rt/test/profile/gcov-dump-and-remove.c
===
--- compiler-rt/test/profile/gcov-dump-and-remove.c
+++ compiler-rt/test/profile/gcov-dump-and-remove.c
@@ -8,16 +8,19 @@
 // RUN: rm -f gcov-dump-and-remove.gcda && %run %t
 // RUN: llvm-cov gcov -t gcov-dump-and-remove.gcda | FileCheck %s
 
-extern void __gcov_flush(void);
+extern void __gcov_dump(void);
+extern void __gcov_reset(void);
 extern int remove(const char *);   // CHECK:  -: [[#@LINE]]:extern int remove
 int main(void) {   // CHECK-NEXT: #: [[#@LINE]]:
-  __gcov_flush();  // CHECK-NEXT: #: [[#@LINE]]:
+  __gcov_dump();   // CHECK-NEXT: #: [[#@LINE]]:
+  __gcov_reset();  // CHECK-NEXT: #: [[#@LINE]]:
   if (remove("gcov-dump-and-remove.gcda") != 0) // CHECK-NEXT: #: [[#@LINE]]:
 return 1;  // CHECK-NEXT: #: [[#@LINE]]: return 1;
// CHECK-NEXT: -: [[#@LINE]]:
-  __gcov_flush();  // CHECK-NEXT: #: [[#@LINE]]:
-  __gcov_flush();  // CHECK-NEXT: #: [[#@LINE]]:
-  if (remove("gcov-dump-and-remove.gcda") != 0) // CHECK-NEXT: #: [[#@LINE]]:
+  __gcov_dump();   // CHECK-NEXT: 1: [[#@LINE]]:
+  __gcov_reset();  // CHECK-NEXT: 1: 

[PATCH] D82477: [lldb-vscode] Add Support for Module Event

2020-07-07 Thread Yifan Shen via Phabricator via cfe-commits
aelitashen updated this revision to Diff 276172.
aelitashen added a comment.

Add test for loading symbols, other module info and Add version to module info


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82477

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/module/Makefile
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/test/API/tools/lldb-vscode/module/main.cpp
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1171,31 +1171,6 @@
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
 }
 
-void request_getCompileUnits(const llvm::json::Object ) {
-  llvm::json::Object response;
-  FillResponse(request, response);
-  lldb::SBProcess process = g_vsc.target.GetProcess();
-  llvm::json::Object body;
-  llvm::json::Array units;
-  auto arguments = request.getObject("arguments");
-  std::string module_id = std::string(GetString(arguments, "moduleId"));
-  int num_modules = g_vsc.target.GetNumModules();
-  for (int i = 0; i < num_modules; i++) {
-auto curr_module = g_vsc.target.GetModuleAtIndex(i);
-if (module_id == curr_module.GetUUIDString()) {
-  int num_units = curr_module.GetNumCompileUnits();
-  for (int j = 0; j < num_units; j++) {
-auto curr_unit = curr_module.GetCompileUnitAtIndex(j);
-units.emplace_back(CreateCompileUnit(curr_unit));
-  }
-  body.try_emplace("compileUnits", std::move(units));
-  break;
-}
-  }
-  response.try_emplace("body", std::move(body));
-  g_vsc.SendJSON(llvm::json::Value(std::move(response)));
-}
-
 // "InitializeRequest": {
 //   "allOf": [ { "$ref": "#/definitions/Request" }, {
 // "type": "object",
@@ -2779,7 +2754,6 @@
   REQUEST_CALLBACK(disconnect),
   REQUEST_CALLBACK(evaluate),
   REQUEST_CALLBACK(exceptionInfo),
-  REQUEST_CALLBACK(getCompileUnits),
   REQUEST_CALLBACK(initialize),
   REQUEST_CALLBACK(launch),
   REQUEST_CALLBACK(next),
Index: lldb/tools/lldb-vscode/JSONUtils.h
===
--- lldb/tools/lldb-vscode/JSONUtils.h
+++ lldb/tools/lldb-vscode/JSONUtils.h
@@ -441,8 +441,6 @@
 llvm::json::Value CreateVariable(lldb::SBValue v, int64_t variablesReference,
  int64_t varID, bool format_hex);
 
-llvm::json::Value CreateCompileUnit(lldb::SBCompileUnit unit);
-
 } // namespace lldb_vscode
 
 #endif
Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -342,25 +342,22 @@
 char symbol_path_arr[PATH_MAX];
 module.GetSymbolFileSpec().GetPath(symbol_path_arr, sizeof(symbol_path_arr));
 std::string symbol_path(symbol_path_arr);
-if (symbol_path != module_path) {
-  object.try_emplace("symbolFilePath", symbol_path);
-}
+object.try_emplace("symbolFilePath", symbol_path);
   }
   std::string loaded_addr = std::to_string(
   module.GetObjectFileHeaderAddress().GetLoadAddress(g_vsc.target));
   object.try_emplace("addressRange", loaded_addr);
-  // uint32_t version_nums[5];
-  // const uint32_t num_versions = module.GetVersion(version_nums, sizeof(version_nums));
-  // std::string version_str = "dummy";
-  // for (uint32_t i = 0; i < num_versions; ++i) {
-  //   if (!version_str.empty()) {
-  // version_str += ".";
-  //   }
-  //   version_str += std::to_string(version_nums[i]);
-  // }
-  // if (!version_str.empty()) {
-  //   object.try_emplace("version", version_str);
-  // }
+  std::string version_str;
+  uint32_t version_nums[3];
+  uint32_t num_versions = module.GetVersion(version_nums, sizeof(version_nums)/sizeof(uint32_t));
+  for (uint32_t i=0; i___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82728: [clang] Add -Wsuggest-override

2020-07-07 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

I'm generally on board with this, but would like @rsmith 's sign off to be sure.

I think it might be nice to make the -Wno-inconsistent-missing-override 
-Wsuggest-override situation a bit better (by having it still do the same thing 
as -Wsuggest-override) but I don't feel /too/ strongly about it.




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:3064
   if (MD->size_overridden_methods() > 0) {
-unsigned DiagID = isa(MD)
-  ? 
diag::warn_destructor_marked_not_override_overriding
-  : diag::warn_function_marked_not_override_overriding;
-Diag(MD->getLocation(), DiagID) << MD->getDeclName();
-const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
-Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
+auto EmitDiag = [this, MD](unsigned DiagDtor, unsigned DiagFn) {
+  unsigned DiagID = isa(MD) ? DiagDtor : DiagFn;

Generally I'd recommend default ref capture `[&]` on any lambda that doesn't 
escape its scope - normal scopes don't need to document which variables you use 
inside them, and I think the same applies to lambdas (bit more debatable when 
the lambda is named and called later, even within the same scope - so if you 
feel strongly about keeping it the way it is, that's OK)



Comment at: clang/test/SemaCXX/warn-suggest-override:3-4
+
+class A {
+ public:
+  ~A() {}

I'd probably simplify these tests by using struct, so everything's implicitly 
public, rather than class and having to make things public.

Also probably member function declarations rather than definitions would be 
simpler?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728



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


[PATCH] D83334: [OPENMP]Fix PR46593: Reduction initializer missing construnctor call.

2020-07-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: guansong, yaxunl.
Herald added a project: clang.

If user-defined reductions with the initializer are used with classes,
wthe compiler misses the constructor call whe trying to create a private
copy of the reduction variable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83334

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/for_reduction_codegen_UDR.cpp

Index: clang/test/OpenMP/for_reduction_codegen_UDR.cpp
===
--- clang/test/OpenMP/for_reduction_codegen_UDR.cpp
+++ clang/test/OpenMP/for_reduction_codegen_UDR.cpp
@@ -203,9 +203,11 @@
 // For + reduction operation initial value of private variable is -1.
 // CHECK: call void [[RED_INIT1:@.+]](float* %{{.+}}, float* %{{.+}})
 
+// CHECK: call void @_ZN1SIfEC1Ev([[S_FLOAT_TY]]* [[VAR_PRIV]]
 // For & reduction operation initial value of private variable is defined by call of 'init()' function.
 // CHECK: call void [[RED_INIT2:@.+]](
 
+// CHECK: call void @_ZN1SIfEC1Ev([[S_FLOAT_TY]]* [[VAR1_PRIV]]
 // For && reduction operation initial value of private variable is 1.0.
 // CHECK: call void [[RED_INIT3:@.+]](
 
@@ -599,6 +601,17 @@
 
 // Check initialization of private copy.
 // CHECK: [[BEGIN:%.+]] = getelementptr inbounds [10 x [4 x [[S_FLOAT_TY, [10 x [4 x [[S_FLOAT_TY* [[ARRS_PRIV]], i32 0, i32 0, i32 0
+// CHECK: [[END:%.+]] = getelementptr inbounds [[S_FLOAT_TY]], [[S_FLOAT_TY]]* [[BEGIN]], i64 40
+// CHECK: br label %[[CTOR:[^,]+]]
+// CHECK: [[CTOR]]:
+// CHECK: [[CUR:%.+]] = phi [[S_FLOAT_TY]]* [ [[BEGIN]], %{{.+}} ], [ [[NEXT:%.+]], %[[CTOR]] ]
+// CHECK: call void @_ZN1SIfEC1Ev([[S_FLOAT_TY]]* [[CUR]])
+// CHECK: [[NEXT:%.+]] = getelementptr inbounds [[S_FLOAT_TY]], [[S_FLOAT_TY]]* [[CUR]], i64 1
+// CHECK: [[IS_DONE:%.+]] = icmp eq [[S_FLOAT_TY]]* [[NEXT]], [[END]]
+// CHECK: br i1 [[IS_DONE]], label %[[DONE:[^,]+]], label %[[CTOR]]
+// CHECK: [[DONE]]:
+
+// CHECK: [[BEGIN:%.+]] = getelementptr inbounds [10 x [4 x [[S_FLOAT_TY, [10 x [4 x [[S_FLOAT_TY* [[ARRS_PRIV]], i32 0, i32 0, i32 0
 // CHECK: [[LHS_BEGIN:%.+]] = bitcast [10 x [4 x [[S_FLOAT_TY* %{{.+}} to [[S_FLOAT_TY]]*
 // CHECK: [[END:%.+]] = getelementptr [[S_FLOAT_TY]], [[S_FLOAT_TY]]* [[BEGIN]], i64 40
 // CHECK: [[ISEMPTY:%.+]] = icmp eq [[S_FLOAT_TY]]* [[BEGIN]], [[END]]
@@ -901,9 +914,11 @@
 // For + reduction operation initial value of private variable is 0.
 // CHECK: call void [[RED_INIT6:@.+]](
 
+// CHECK: call void @_ZN1SIiEC1Ev([[S_INT_TY]]* [[VAR_PRIV]]
 // For & reduction operation initial value of private variable is ones in all bits.
 // CHECK: call void [[RED_INIT2:@.+]](
 
+// CHECK: call void @_ZN1SIiEC1Ev([[S_INT_TY]]* [[VAR1_PRIV]]
 // For && reduction operation initial value of private variable is 1.0.
 // CHECK: call void [[RED_INIT7:@.+]](
 
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15105,6 +15105,7 @@
   auto *DRDRef = DeclareReductionRef.getAs();
   auto *DRD = cast(DRDRef->getDecl());
   if (DRD->getInitializer()) {
+S.ActOnUninitializedDecl(PrivateVD);
 Init = DRDRef;
 RHSVD->setInit(DRDRef);
 RHSVD->setInitStyle(VarDecl::CallInit);
@@ -15211,10 +15212,19 @@
 llvm_unreachable("Unexpected reduction operation");
   }
 }
-if (Init && DeclareReductionRef.isUnset())
+if (Init && DeclareReductionRef.isUnset()) {
   S.AddInitializerToDecl(RHSVD, Init, /*DirectInit=*/false);
-else if (!Init)
+  // Store initializer for single element in private copy. Will be used
+  // during codegen.
+  PrivateVD->setInit(RHSVD->getInit());
+  PrivateVD->setInitStyle(RHSVD->getInitStyle());
+} else if (!Init) {
   S.ActOnUninitializedDecl(RHSVD);
+  // Store initializer for single element in private copy. Will be used
+  // during codegen.
+  PrivateVD->setInit(RHSVD->getInit());
+  PrivateVD->setInitStyle(RHSVD->getInitStyle());
+}
 if (RHSVD->isInvalidDecl())
   continue;
 if (!RHSVD->hasInit() &&
@@ -15228,10 +15238,6 @@
   << D;
   continue;
 }
-// Store initializer for single element in private copy. Will be used during
-// codegen.
-PrivateVD->setInit(RHSVD->getInit());
-PrivateVD->setInitStyle(RHSVD->getInitStyle());
 DeclRefExpr *PrivateDRE = buildDeclRefExpr(S, PrivateVD, PrivateTy, ELoc);
 ExprResult ReductionOp;
 if (DeclareReductionRef.isUsable()) {
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -886,8 +886,11 @@
   SharedType, 

[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-07-07 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 276166.
kpn added a comment.

Add the -fexperimental-strict-floating-point flag to enable on hosts that are 
not marked as supporting strict FP yet. Add test and documentation.

Update tests to use the new flag. This eliminates the XFAIL lines and should 
keep the tests running like before.

Hopefully this will work for 11.


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

https://reviews.llvm.org/D80952

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/SystemZ.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aarch64-neon-misc-constrained.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
  clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
  clang/test/CodeGen/arm64-vrnd-constrained.c
  clang/test/CodeGen/builtins-ppc-fpconstrained.c
  clang/test/CodeGen/fp-strictfp-exp.cpp
  clang/test/CodeGen/fp-strictfp.cpp
  clang/test/CodeGen/fpconstrained-cmp-double.c
  clang/test/CodeGen/fpconstrained-cmp-float.c
  clang/test/CodeGen/fpconstrained.c
  clang/test/CodeGen/fpconstrained.cpp

Index: clang/test/CodeGen/fpconstrained.cpp
===
--- clang/test/CodeGen/fpconstrained.cpp
+++ clang/test/CodeGen/fpconstrained.cpp
@@ -1,10 +1,11 @@
-// RUN: %clang_cc1 -x c++ -ftrapping-math -fexceptions -fcxx-exceptions -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
+// RUN: %clang_cc1 -x c++ -ftrapping-math -fexceptions -fcxx-exceptions -frounding-math -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
 // RUN: %clang_cc1 -x c++ -ffp-contract=fast -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix=PRECISE
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix=FASTNOCONTRACT
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
-// RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT
-// RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP
+// RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT
+// RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=maytrap -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP
+
 float f0, f1, f2;
 
   template 
Index: clang/test/CodeGen/fpconstrained.c
===
--- clang/test/CodeGen/fpconstrained.c
+++ clang/test/CodeGen/fpconstrained.c
@@ -1,10 +1,11 @@
-// RUN: %clang_cc1 -ftrapping-math -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
+// RUN: %clang_cc1 -ftrapping-math -frounding-math -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
 // RUN: %clang_cc1 -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=PRECISE
 // RUN: %clang_cc1 -ffast-math -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
 // RUN: %clang_cc1 -ffast-math -emit-llvm -o - %s | FileCheck %s -check-prefix=FASTNOCONTRACT
 // RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
-// RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT
-// RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP
+// RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT
+// RUN: 

[PATCH] D82728: [clang] Add -Wsuggest-override

2020-07-07 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D82728#2136887 , @logan-5 wrote:

> In D82728#2135149 , @dblaikie wrote:
>
> > Is the implementation you're proposing fairly consistent with GCC's? Run it 
> > over any big codebases to check it warns in the same places GCC does?
>
>
> This patch has the same behavior as `-Wsuggest-override` in GCC >= 9. In GCC 
> <9, it would suggest adding `override` to `void foo() final`, but in GCC >=9, 
> `final` is enough to suppress the warning. This patch's `-Wsuggest-override`, 
> as well as Clang's pre-existing `-Winconsistent-missing-override`, are also 
> silenced by `final`. (https://godbolt.org/z/hbxLK6)
>
> I built Clang itself with a Clang that had this patch, and with GCC with 
> `-Wsuggest-override`, and compared the results--they were identical (except 
> for the warning text). (618 warnings, for those interested.)


Awesome! Really appreciate the data.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728



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


[PATCH] D82930: [HIP] Fix rocm detection

2020-07-07 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:167
+llvm::ErrorOr> VersionFile =
+FS.getBufferForFile(BinPath + "/.hipVersion");
+if (!VersionFile)

arsenm wrote:
> tra wrote:
> > arsenm wrote:
> > > yaxunl wrote:
> > > > yaxunl wrote:
> > > > > yaxunl wrote:
> > > > > > tra wrote:
> > > > > > > arsenm wrote:
> > > > > > > > yaxunl wrote:
> > > > > > > > > arsenm wrote:
> > > > > > > > > > arsenm wrote:
> > > > > > > > > > > yaxunl wrote:
> > > > > > > > > > > > arsenm wrote:
> > > > > > > > > > > > > I don't think the detection should fail if this is 
> > > > > > > > > > > > > missing
> > > > > > > > > > > > why? this file is unique to HIP installation. If it is 
> > > > > > > > > > > > missing, the installation is broken.
> > > > > > > > > > > Because I should be able to use this without a complete 
> > > > > > > > > > > hip installation. Without a specified version, it should 
> > > > > > > > > > > assume the most modern layout. This will for example 
> > > > > > > > > > > break pointing --rocm-path at the device library build 
> > > > > > > > > > > directory for library tests
> > > > > > > > > > I also don't see what value checking the version really 
> > > > > > > > > > provides; it may be informative to print it, but I don't 
> > > > > > > > > > think it's useful to derive information from it
> > > > > > > > > what is the directory structure of your most modern layout?
> > > > > > > > /opt/rocm/amdgcn/bitcode/foo.bc
> > > > > > > > 
> > > > > > > > The plan is to remove this and rely on symlinks in the resource 
> > > > > > > > directory though
> > > > > > > > I also don't see what value checking the version really 
> > > > > > > > provides; it may be informative to print it, but I don't think 
> > > > > > > > it's useful to derive information from it
> > > > > > > 
> > > > > > > In CUDA it's used to detect which back-end features to enable 
> > > > > > > (they depend on what's supported by ptxas supplied by that CUDA 
> > > > > > > version). I don't think that would be relevant to AMDGPU as it 
> > > > > > > does not need external dependencies to generate GPU code.
> > > > > > > 
> > > > > > > It may be useful for filesystem layout detection. E.g. where to 
> > > > > > > find bitcode files and what names to expect. This part seems to 
> > > > > > > be relevant for ROCm, but I'm not sure if the layout is closely 
> > > > > > > tied to the version.
> > > > > > > 
> > > > > > We are required to support previous ROCm releases for certain time 
> > > > > > range. To do that we need to detect HIP version and enable/disable 
> > > > > > certain HIP features based on HIP version when necessary.
> > > > > > 
> > > > > > Therefore if we have a new directory structure for ROCm, that 
> > > > > > directory structure should contain a HIP version file so that we 
> > > > > > can detect HIP version.
> > > > > > 
> > > > > > 
> > > > > Currently clang includes some wrapper headers by default, which does 
> > > > > not work with ROCm 3.5 since those device functions are defined in 
> > > > > HIP headers of ROCm 3.5. To support ROCm 3.5, we have to disable 
> > > > > including those wrapper headers. This is one example why we need 
> > > > > detect HIP version.
> > > > I think we need to separate HIP runtime detection and device library 
> > > > detection and also separate hasValidHIPRuntime and 
> > > > hasValidDeviceLibrary. ROCm toolchain only need to make sure 
> > > > hasValidDeviceLibrary but HIP toolchain need both hasValidDeviceLibrary 
> > > > and hasValidHIPRuntime.
> > > Regardless of whether there's a version file or if does anything, I think 
> > > the absence of one implies do the most modern thing
> > "The most modern thing" is an ever moving target. If the failure modes keep 
> > changing it will create a source of new problems every time something 
> > changes. Probably not a big issue in this case, but with (eventually) wide 
> > enough user base there will be some.
> > 
> > I assume that AMD does not have much of legacy user base yet for 
> > compilations with clang, so defaulting to a recent version may be sensible 
> > (unlike CUDA where clang had to deal with a lot of existing CUDA users 
> > using old CUDA versions). That said, I'd recommend pinning it to a 
> > **specific** version, so the expectations remain stable. Then we can 
> > document the failure/fallback in a way users can deal with -- `if no 
> > version file is found, clang assumes version x.y and expects to find files 
> > X, Y and Z in directory A, B, C. You can specify the locations manually 
> > with --something-something-X=A or specify the version with 
> > --hip-version=3.7`. 
> > 
> > Considering that clang is being used from various derived tools, you may 
> > not always have the luxury of having the whole ROCm installation around and 
> > need to be able to override the expectations via command line flags.
> > 
> > If we have a way to 

[PATCH] D82659: Fix missing build dependency on omp_gen.

2020-07-07 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

In D82659#2136909 , @michele.scandale 
wrote:

> Why `omp_gen` is now a dependency of `clang-tablegen-targets` rather than 
> being in the `LLVM_COMMON_DEPENDS` list like `clang-tablegen-targets`?
>
> Moreover I've noticed that with the recent changes where  `omp_gen` has been 
> added as a dependency in several libraries, this was done unconditionally 
> breaking the Clang standalone build.
>  For the same issue `intrinsics_gen` is added only if `CLANG_BUILT_STANDALONE 
> ` is false.
>
> At this point I think that something like:
>
>   # All targets below may depend on all tablegen'd files.
>   get_property(CLANG_TABLEGEN_TARGETS GLOBAL PROPERTY CLANG_TABLEGEN_TARGETS)
>   add_custom_target(clang-tablegen-targets DEPENDS ${CLANG_TABLEGEN_TARGETS})
>   set_target_properties(clang-tablegen-targets PROPERTIES FOLDER "Misc")
>   list(APPEND LLVM_COMMON_DEPENDS clang-tablegen-targets)
>   if(NOT CLANG_BUILT_STANDALONE)
> list(APPEND LLVM_COMMON_DEPENDS omg_gen)
>   endif()
>
>
> would fix all the issues, and it would allow removing the explicit 
> dependencies added to each clang library.
>
> Is there any issue with my reasoning?


Looks good but just one question ... When clang is built as standalone it does 
not build the OpenMP part inside Clang? I haven't seen any code to avoid 
compiling the OpenMP parsing and semantic checking inside clang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82659



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


[PATCH] D83079: [clang][aarch64] Generate preprocessor macros for -march=armv8.6a+sve.

2020-07-07 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:118
+
+  if (!llvm::AArch64::getArchFeatures(ArchKind, Features))
+return false;

Would it be more consistent to move this



Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:273
   const auto ItRFP16FML = std::find(Features.rbegin(), Features.rend(), 
"+fp16fml");
   if (llvm::is_contained(Features, "+v8.4a")) {
 const auto ItRFullFP16  = std::find(Features.rbegin(), Features.rend(), 
"+fullfp16");

...to somewhere here where implied target features are handled



Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:373
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,

For example, to here.



Comment at: clang/test/Preprocessor/aarch64-target-features.c:115
 
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-SVE-8_6 %s
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE 1

Can you add a run line for v8.5 if there isn't already one, and add CHECK-NOTs 
for these macros.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83079



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


[PATCH] D62574: Initial draft of target-configurable address spaces.

2020-07-07 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan updated this revision to Diff 276163.
ebevhan added a comment.

Rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62574

Files:
  clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/CanonicalType.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaFixItUtils.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CodeGenCXX/address-space-cast.cpp
  clang/test/Sema/address_space_print_macro.c
  clang/test/Sema/address_spaces.c

Index: clang/test/Sema/address_spaces.c
===
--- clang/test/Sema/address_spaces.c
+++ clang/test/Sema/address_spaces.c
@@ -71,7 +71,8 @@
 
 // Clang extension doesn't forbid operations on pointers to different address spaces.
 char* cmp(_AS1 char *x,  _AS2 char *y) {
-  return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type  ('_AS1 char *' and '_AS2 char *') which are pointers to non-overlapping address spaces}}
+  return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type  ('_AS1 char *' and '_AS2 char *') which are pointers to non-overlapping address spaces}} \
+// expected-error{{comparison between  ('_AS1 char *' and '_AS2 char *') which are pointers to non-overlapping address spaces}}
 }
 
 char *sub(_AS1 char *x, _AS2 char *y) {
Index: clang/test/Sema/address_space_print_macro.c
===
--- clang/test/Sema/address_space_print_macro.c
+++ clang/test/Sema/address_space_print_macro.c
@@ -14,7 +14,8 @@
 }
 
 char *cmp(AS1 char *x, AS2 char *y) {
-  return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type  ('AS1 char *' and 'AS2 char *') which are pointers to non-overlapping address spaces}}
+  return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type  ('AS1 char *' and 'AS2 char *') which are pointers to non-overlapping address spaces}} \
+// expected-error{{comparison between  ('AS1 char *' and 'AS2 char *') which are pointers to non-overlapping address spaces}}
 }
 
 __attribute__((address_space(1))) char test_array[10];
Index: clang/test/CodeGenCXX/address-space-cast.cpp
===
--- clang/test/CodeGenCXX/address-space-cast.cpp
+++ clang/test/CodeGenCXX/address-space-cast.cpp
@@ -37,8 +37,9 @@
   // CHECK-NEXT: store i8 addrspace(5)* %[[cast]]
   priv_void_ptr = (__private__ void *)gen_void_ptr;
 
-  // CHECK: %[[cast:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(5)*
-  // CHECK-NEXT: store i8 addrspace(5)* %[[cast]]
+  // CHECK: %[[cast:.*]] = bitcast i32* %{{.*}} to i8*
+  // CHECK-NEXT: %[[cast2:.*]] = addrspacecast i8* %[[cast]] to i8 addrspace(5)*
+  // CHECK-NEXT: store i8 addrspace(5)* %[[cast2]]
   priv_void_ptr = (__private__ void *)gen_int_ptr;
 
   // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i32 addrspace(5)*
@@ -65,8 +66,9 @@
   // CHECK-NEXT: call void @_Z10func_pvoidPU3AS5v(i8 addrspace(5)* %[[cast]])
   func_pvoid((__private__ void *)gen_void_ptr);
 
-  // CHECK: %[[cast:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(5)*
-  // CHECK-NEXT: call void @_Z10func_pvoidPU3AS5v(i8 addrspace(5)* %[[cast]])
+  // CHECK: %[[cast:.*]] = bitcast i32* %{{.*}} to i8*
+  // CHECK-NEXT: %[[cast2:.*]] = addrspacecast i8* %[[cast]] to i8 addrspace(5)*
+  // CHECK-NEXT: call void @_Z10func_pvoidPU3AS5v(i8 addrspace(5)* %[[cast2]])
   func_pvoid((__private__ void *)gen_int_ptr);
 
   // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i32 addrspace(5)*
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1457,7 +1457,8 @@
   // C++ [temp.deduct.conv]p4:
   //   If the original A is a reference type, A can be more cv-qualified
   //   than the deduced A
-  if (!Arg.getQualifiers().compatiblyIncludes(Param.getQualifiers()))
+  if (!S.Context.compatiblyIncludes(Arg.getQualifiers(),
+Param.getQualifiers()))
 return Sema::TDK_NonDeducedMismatch;
 
   // Strip out all extra qualifiers from the argument to figure out the
@@ -3389,7 +3390,7 @@
 
 if 

[clang] a707da4 - Clang crashed while checking for deletion of copy and move ctors

2020-07-07 Thread Vy Nguyen via cfe-commits

Author: Vy Nguyen
Date: 2020-07-07T14:40:37-04:00
New Revision: a707da4728dea51c1446cf582a46fb271f3969c3

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

LOG: Clang crashed while checking for deletion of copy and move ctors

Crash:
   @ 0x559d129463fc  
clang::CXXRecordDecl::defaultedCopyConstructorIsDeleted()
@ 0x559d1288d3e5  
clang::Sema::checkIllFormedTrivialABIStruct()::$_7::operator()()
@ 0x559d12884c34  clang::Sema::checkIllFormedTrivialABIStruct()
@ 0x559d1288412e  clang::Sema::CheckCompletedCXXClass()
@ 0x559d1288d843  clang::Sema::ActOnFinishCXXMemberSpecification()
@ 0x559d12020109  clang::Parser::ParseCXXMemberSpecification()
@ 0x559d1201e80c  clang::Parser::ParseClassSpecifier()
@ 0x559d1204e807  clang::Parser::ParseDeclarationSpecifiers()
@ 0x559d120e9aa9  
clang::Parser::ParseSingleDeclarationAfterTemplate()
@ 0x559d120e8f21  
clang::Parser::ParseTemplateDeclarationOrSpecialization()
@ 0x559d120e8886  
clang::Parser::ParseDeclarationStartingWithTemplate()
@ 0x559d1204a1d4  clang::Parser::ParseDeclaration()
@ 0x559d12004b1d  clang::Parser::ParseExternalDeclaration()
@ 0x559d12017689  clang::Parser::ParseInnerNamespace()
@ 0x559d12017024  clang::Parser::ParseNamespace()
@ 0x559d1204a29b  clang::Parser::ParseDeclaration()
@ 0x559d12004c74  clang::Parser::ParseExternalDeclaration()

Subscribers: cfe-commits

Tags: #clang

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

Added: 
clang/test/SemaCXX/attr-trivial-abi.cpp

Modified: 
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaObjCXX/attr-trivial-abi.mm

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index ef555788ee0e..eb001a77518b 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9719,6 +9719,10 @@ void Sema::checkIllFormedTrivialABIStruct(CXXRecordDecl 
) {
 
   // Ill-formed if the copy and move constructors are deleted.
   auto HasNonDeletedCopyOrMoveConstructor = [&]() {
+// If the type is dependent, then assume it might have
+// implicit copy or move ctor because we won't know yet at this point.
+if (RD.isDependentType())
+  return true;
 if (RD.needsImplicitCopyConstructor() &&
 !RD.defaultedCopyConstructorIsDeleted())
   return true;

diff  --git a/clang/test/SemaCXX/attr-trivial-abi.cpp 
b/clang/test/SemaCXX/attr-trivial-abi.cpp
new file mode 100644
index ..334b471d2ab8
--- /dev/null
+++ b/clang/test/SemaCXX/attr-trivial-abi.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+void __attribute__((trivial_abi)) foo(); // expected-warning {{'trivial_abi' 
attribute only applies to classes}}
+
+// Should not crash.
+template 
+class __attribute__((trivial_abi)) a { a(a &&); };
+
+struct [[clang::trivial_abi]] S0 {
+  int a;
+};
+
+struct __attribute__((trivial_abi)) S1 {
+  int a;
+};
+
+struct __attribute__((trivial_abi)) S3 { // expected-warning {{'trivial_abi' 
cannot be applied to 'S3'}} expected-note {{is polymorphic}}
+  virtual void m();
+};
+
+struct S3_2 {
+  virtual void m();
+} __attribute__((trivial_abi)); // expected-warning {{'trivial_abi' cannot be 
applied to 'S3_2'}} expected-note {{is polymorphic}}
+
+struct __attribute__((trivial_abi)) S3_3 { // expected-warning {{'trivial_abi' 
cannot be applied to 'S3_3'}} expected-note {{has a field of a non-trivial 
class type}}
+  S3_3(S3_3 &&);
+  S3_2 s32;
+};
+
+// Diagnose invalid trivial_abi even when the type is templated because it has 
a non-trivial field.
+template 
+struct __attribute__((trivial_abi)) S3_4 { // expected-warning {{'trivial_abi' 
cannot be applied to 'S3_4'}} expected-note {{has a field of a non-trivial 
class type}}
+  S3_4(S3_4 &&);
+  S3_2 s32;
+};
+
+struct S4 {
+  int a;
+};
+
+struct __attribute__((trivial_abi)) S5 : public virtual S4 { // 
expected-warning {{'trivial_abi' cannot be applied to 'S5'}} expected-note 
{{has a virtual base}}
+};
+
+struct __attribute__((trivial_abi)) S9 : public S4 {
+};
+
+struct __attribute__((trivial_abi(1))) S8 { // expected-error {{'trivial_abi' 
attribute takes no arguments}}
+  int a;
+};
+
+// Do not warn about deleted ctors  when 'trivial_abi' is used to annotate a 
template class.
+template 
+struct __attribute__((trivial_abi)) S10 {
+  T p;
+};
+
+S10 p1;
+
+template 
+struct S14 {
+  T a;
+};
+
+template 
+struct __attribute__((trivial_abi)) S15 : S14 {
+};
+
+S15 s15;
+
+template 
+struct __attribute__((trivial_abi)) S16 {
+  S14 a;
+};
+
+S16 s16;
+
+template 
+struct __attribute__((trivial_abi)) S17 {
+};
+

[PATCH] D82728: [clang] Add -Wsuggest-override

2020-07-07 Thread Logan Smith via Phabricator via cfe-commits
logan-5 updated this revision to Diff 276162.
logan-5 added a comment.

clang-formatted the diff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/warn-suggest-destructor-override
  clang/test/SemaCXX/warn-suggest-override

Index: clang/test/SemaCXX/warn-suggest-override
===
--- /dev/null
+++ clang/test/SemaCXX/warn-suggest-override
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wsuggest-override
+
+class A {
+ public:
+  ~A() {}
+  void run() {}
+};
+
+class B : public A {
+ public:
+  ~B() {}
+  void run() {}
+};
+
+class C {
+ public:
+  virtual void run() {} // expected-note 2{{overridden virtual function is here}}
+  virtual ~C() {}
+};
+
+class D : public C {
+ public:
+  void run() {}
+  // expected-warning@-1 {{'run()' overrides a member function but is not marked 'override'}}
+  ~D() {}
+};
+
+class E : public C {
+ public:
+  virtual void run() {}
+  // expected-warning@-1 {{'run()' overrides a member function but is not marked 'override'}}
+  virtual ~E() {}
+};
+
+class F : public C {
+ public:
+  void run() override {}
+  ~F() override {}
+};
+
+class G : public C {
+ public:
+  void run() final {}
+  ~G() final {}
+};
Index: clang/test/SemaCXX/warn-suggest-destructor-override
===
--- /dev/null
+++ clang/test/SemaCXX/warn-suggest-destructor-override
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wsuggest-destructor-override
+
+class A {
+ public:
+  ~A() {}
+  virtual void run() {}
+};
+
+class B : public A {
+ public:
+  ~B() {}
+};
+
+class C {
+ public:
+  virtual void run() {}
+  virtual ~C() {}  // expected-note 2{{overridden virtual function is here}}
+};
+
+class D : public C {
+ public:
+  void run() {}
+  ~D() {}
+  // expected-warning@-1 {{'~D' overrides a destructor but is not marked 'override'}}
+};
+
+class E : public C {
+ public:
+  void run() {}
+  virtual ~E() {}
+  // expected-warning@-1 {{'~E' overrides a destructor but is not marked 'override'}}
+};
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -3045,7 +3045,7 @@
   << MD->getDeclName();
 }
 
-void Sema::DiagnoseAbsenceOfOverrideControl(NamedDecl *D) {
+void Sema::DiagnoseAbsenceOfOverrideControl(NamedDecl *D, bool Inconsistent) {
   if (D->isInvalidDecl() || D->hasAttr())
 return;
   CXXMethodDecl *MD = dyn_cast(D);
@@ -3061,12 +3061,19 @@
   return;
 
   if (MD->size_overridden_methods() > 0) {
-unsigned DiagID = isa(MD)
-  ? diag::warn_destructor_marked_not_override_overriding
-  : diag::warn_function_marked_not_override_overriding;
-Diag(MD->getLocation(), DiagID) << MD->getDeclName();
-const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
-Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
+auto EmitDiag = [this, MD](unsigned DiagDtor, unsigned DiagFn) {
+  unsigned DiagID = isa(MD) ? DiagDtor : DiagFn;
+  Diag(MD->getLocation(), DiagID) << MD->getDeclName();
+  const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
+  Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
+};
+if (Inconsistent)
+  EmitDiag(
+  diag::warn_inconsistent_destructor_marked_not_override_overriding,
+  diag::warn_inconsistent_function_marked_not_override_overriding);
+else
+  EmitDiag(diag::warn_suggest_destructor_marked_not_override_overriding,
+   diag::warn_suggest_function_marked_not_override_overriding);
   }
 }
 
@@ -6749,13 +6756,10 @@
 }
   }
 
-  if (HasMethodWithOverrideControl &&
-  HasOverridingMethodWithoutOverrideControl) {
-// At least one method has the 'override' control declared.
-// Diagnose all other overridden methods which do not have 'override'
-// specified on them.
+  if (HasOverridingMethodWithoutOverrideControl) {
+bool HasInconsistentOverrideControl = HasMethodWithOverrideControl;
 for (auto *M : Record->methods())
-  DiagnoseAbsenceOfOverrideControl(M);
+  DiagnoseAbsenceOfOverrideControl(M, HasInconsistentOverrideControl);
   }
 
   // Check the defaulted secondary comparisons after any other member functions.
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -6961,7 +6961,7 @@
 
   /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was
   /// not used in the 

[PATCH] D82659: Fix missing build dependency on omp_gen.

2020-07-07 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale added a comment.

Why `omp_gen` is now a dependency of `clang-tablegen-targets` rather than being 
in the `LLVM_COMMON_DEPENDS` list like `clang-tablegen-targets`?

Moreover I've noticed that with the recent changes where  `omp_gen` has been 
added as a dependency in several libraries, this was done unconditionally 
breaking the Clang standalone build.
For the same issue `intrinsics_gen` is added only if `CLANG_BUILT_STANDALONE ` 
is false.

At this point I think that something like:

  # All targets below may depend on all tablegen'd files.
  get_property(CLANG_TABLEGEN_TARGETS GLOBAL PROPERTY CLANG_TABLEGEN_TARGETS)
  add_custom_target(clang-tablegen-targets DEPENDS ${CLANG_TABLEGEN_TARGETS})
  set_target_properties(clang-tablegen-targets PROPERTIES FOLDER "Misc")
  list(APPEND LLVM_COMMON_DEPENDS clang-tablegen-targets)
  if(NOT CLANG_BUILT_STANDALONE)
list(APPEND LLVM_COMMON_DEPENDS omg_gen)
  endif()

would fix all the issues, and it would allow removing the explicit dependencies 
added to each clang library.

Is there any issue with my reasoning?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82659



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


[PATCH] D82930: [HIP] Fix rocm detection

2020-07-07 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:167
+llvm::ErrorOr> VersionFile =
+FS.getBufferForFile(BinPath + "/.hipVersion");
+if (!VersionFile)

tra wrote:
> arsenm wrote:
> > yaxunl wrote:
> > > yaxunl wrote:
> > > > yaxunl wrote:
> > > > > tra wrote:
> > > > > > arsenm wrote:
> > > > > > > yaxunl wrote:
> > > > > > > > arsenm wrote:
> > > > > > > > > arsenm wrote:
> > > > > > > > > > yaxunl wrote:
> > > > > > > > > > > arsenm wrote:
> > > > > > > > > > > > I don't think the detection should fail if this is 
> > > > > > > > > > > > missing
> > > > > > > > > > > why? this file is unique to HIP installation. If it is 
> > > > > > > > > > > missing, the installation is broken.
> > > > > > > > > > Because I should be able to use this without a complete hip 
> > > > > > > > > > installation. Without a specified version, it should assume 
> > > > > > > > > > the most modern layout. This will for example break 
> > > > > > > > > > pointing --rocm-path at the device library build directory 
> > > > > > > > > > for library tests
> > > > > > > > > I also don't see what value checking the version really 
> > > > > > > > > provides; it may be informative to print it, but I don't 
> > > > > > > > > think it's useful to derive information from it
> > > > > > > > what is the directory structure of your most modern layout?
> > > > > > > /opt/rocm/amdgcn/bitcode/foo.bc
> > > > > > > 
> > > > > > > The plan is to remove this and rely on symlinks in the resource 
> > > > > > > directory though
> > > > > > > I also don't see what value checking the version really provides; 
> > > > > > > it may be informative to print it, but I don't think it's useful 
> > > > > > > to derive information from it
> > > > > > 
> > > > > > In CUDA it's used to detect which back-end features to enable (they 
> > > > > > depend on what's supported by ptxas supplied by that CUDA version). 
> > > > > > I don't think that would be relevant to AMDGPU as it does not need 
> > > > > > external dependencies to generate GPU code.
> > > > > > 
> > > > > > It may be useful for filesystem layout detection. E.g. where to 
> > > > > > find bitcode files and what names to expect. This part seems to be 
> > > > > > relevant for ROCm, but I'm not sure if the layout is closely tied 
> > > > > > to the version.
> > > > > > 
> > > > > We are required to support previous ROCm releases for certain time 
> > > > > range. To do that we need to detect HIP version and enable/disable 
> > > > > certain HIP features based on HIP version when necessary.
> > > > > 
> > > > > Therefore if we have a new directory structure for ROCm, that 
> > > > > directory structure should contain a HIP version file so that we can 
> > > > > detect HIP version.
> > > > > 
> > > > > 
> > > > Currently clang includes some wrapper headers by default, which does 
> > > > not work with ROCm 3.5 since those device functions are defined in HIP 
> > > > headers of ROCm 3.5. To support ROCm 3.5, we have to disable including 
> > > > those wrapper headers. This is one example why we need detect HIP 
> > > > version.
> > > I think we need to separate HIP runtime detection and device library 
> > > detection and also separate hasValidHIPRuntime and hasValidDeviceLibrary. 
> > > ROCm toolchain only need to make sure hasValidDeviceLibrary but HIP 
> > > toolchain need both hasValidDeviceLibrary and hasValidHIPRuntime.
> > Regardless of whether there's a version file or if does anything, I think 
> > the absence of one implies do the most modern thing
> "The most modern thing" is an ever moving target. If the failure modes keep 
> changing it will create a source of new problems every time something 
> changes. Probably not a big issue in this case, but with (eventually) wide 
> enough user base there will be some.
> 
> I assume that AMD does not have much of legacy user base yet for compilations 
> with clang, so defaulting to a recent version may be sensible (unlike CUDA 
> where clang had to deal with a lot of existing CUDA users using old CUDA 
> versions). That said, I'd recommend pinning it to a **specific** version, so 
> the expectations remain stable. Then we can document the failure/fallback in 
> a way users can deal with -- `if no version file is found, clang assumes 
> version x.y and expects to find files X, Y and Z in directory A, B, C. You 
> can specify the locations manually with --something-something-X=A or specify 
> the version with --hip-version=3.7`. 
> 
> Considering that clang is being used from various derived tools, you may not 
> always have the luxury of having the whole ROCm installation around and need 
> to be able to override the expectations via command line flags.
> 
> If we have a way to override the version, then it does not matter all that 
> much which version we pick as a fallback. If the guess is wrong, we can 
> always correct it with a flag.
Unlike CUDA we're not really 

[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-07 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu marked an inline comment as done.
zequanwu added inline comments.



Comment at: llvm/test/Other/opt-O2-pipeline.ll:289
+; CHECK-NEXT: Branch Probability Analysis
+; CHECK-NEXT: Block Frequency Analysis
 ; CHECK-NEXT: FunctionPass Manager

zequanwu wrote:
> nikic wrote:
> > hans wrote:
> > > nikic wrote:
> > > > Is it possible to switch this pass to use LazyBPI / LazyBFA, only 
> > > > fetched if PGO is actually in use?
> > > > 
> > > > PGO functionality that most people don't use adding expensive analysis 
> > > > passes like PDT should be avoided.
> > > I wonder if just switching to LazyBlockFrequencyInfo would help though. 
> > > It looks to me like the CGProfile would request info about each function 
> > > anyway.
> > > 
> > > I was surprised to see that Clang sets Opts.CallGraphProfile solely based 
> > > on whether the integrated assembler is used. Maybe a better fix is to 
> > > only set that to true when a profile is actually being used?
> > > I wonder if just switching to LazyBlockFrequencyInfo would help though. 
> > > It looks to me like the CGProfile would request info about each function 
> > > anyway.
> > 
> > It would only help if there is some way to only fetch the analysis 
> > conditionally. I believe many PGO passes use something like 
> > PSI.hasProfileSummary() or F.hasProfileData() for that.
> > 
> > > I was surprised to see that Clang sets Opts.CallGraphProfile solely based 
> > > on whether the integrated assembler is used. Maybe a better fix is to 
> > > only set that to true when a profile is actually being used?
> > 
> > Right, just disabling this by default in clang/opt would also work.
> > 
> > For reference, the current compile-time numbers for this patch: 
> > https://llvm-compile-time-tracker.com/compare.php?from=516ff1d4baee28b1911737e47b42973567adf8ff=8df840660bb764b6653fcfd9ac7a72cc6adebde6=instructions
> >  Not huge, but it adds up (some similar regressions have been introduced in 
> > LLVM 10).
> Do you mean disabling it just for LPM or both?
> I was surprised to see that Clang sets Opts.CallGraphProfile solely based on 
> whether the integrated assembler is used. Maybe a better fix is to only set 
> that to true when a profile is actually being used?
For Clang, a better fix I think is that `Opts.CallGraphProfile` should based on 
both whether the integrated assembler is used and whether profile 
instrumentation is turned on. What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013



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


[PATCH] D82728: [clang] Add -Wsuggest-override

2020-07-07 Thread Logan Smith via Phabricator via cfe-commits
logan-5 added a comment.

In D82728#2135149 , @dblaikie wrote:

> Is the implementation you're proposing fairly consistent with GCC's? Run it 
> over any big codebases to check it warns in the same places GCC does?


This patch has the same behavior as `-Wsuggest-override` in GCC >= 9. In GCC 
<9, it would suggest adding `override` to `void foo() final`, but in GCC >=9, 
`final` is enough to suppress the warning. This patch's `-Wsuggest-override`, 
as well as Clang's pre-existing `-Winconsistent-missing-override`, are also 
silenced by `final`. (https://godbolt.org/z/hbxLK6)

I built Clang itself with a Clang that had this patch, and with GCC with 
`-Wsuggest-override`, and compared the results--they were identical (except for 
the warning text). (618 warnings, for those interested.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728



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


[PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses

2020-07-07 Thread Zola Bridges via Phabricator via cfe-commits
zbrid updated this revision to Diff 276153.
zbrid added a comment.
Herald added a subscriber: jfb.

update seses flag


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79910

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll

Index: llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll
===
--- llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll
+++ llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll
@@ -1,8 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable %s -o - | FileCheck %s
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable -x86-seses-one-lfence-per-bb %s -o - | FileCheck %s --check-prefix=X86-ONE-LFENCE
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable -x86-seses-omit-branch-lfences %s -o - | FileCheck %s --check-prefix=X86-OMIT-BR
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable -x86-seses-only-lfence-non-const %s -o - | FileCheck %s --check-prefix=X86-NON-CONST
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi %s -o - | FileCheck %s
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi -x86-seses-one-lfence-per-bb %s -o - | FileCheck %s --check-prefix=X86-ONE-LFENCE
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi -x86-seses-omit-branch-lfences %s -o - | FileCheck %s --check-prefix=X86-OMIT-BR
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi -x86-seses-only-lfence-non-const %s -o - | FileCheck %s --check-prefix=X86-NON-CONST
 
 define void @_Z4buzzv() {
 ; CHECK-LABEL: _Z4buzzv:
Index: llvm/lib/Target/X86/X86Subtarget.h
===
--- llvm/lib/Target/X86/X86Subtarget.h
+++ llvm/lib/Target/X86/X86Subtarget.h
@@ -442,6 +442,9 @@
   /// POP+LFENCE+JMP sequence.
   bool UseLVIControlFlowIntegrity = false;
 
+  /// Enable Speculative Execution Side Effect Suppression
+  bool UseSpeculativeExecutionSideEffectSuppression = false;
+
   /// Insert LFENCE instructions to prevent data speculatively injected into
   /// loads from being used maliciously.
   bool UseLVILoadHardening = false;
@@ -759,6 +762,9 @@
   bool useGLMDivSqrtCosts() const { return UseGLMDivSqrtCosts; }
   bool useLVIControlFlowIntegrity() const { return UseLVIControlFlowIntegrity; }
   bool useLVILoadHardening() const { return UseLVILoadHardening; }
+  bool useSpeculativeExecutionSideEffectSuppression() const {
+return UseSpeculativeExecutionSideEffectSuppression;
+  }
 
   unsigned getPreferVectorWidth() const { return PreferVectorWidth; }
   unsigned getRequiredVectorWidth() const { return RequiredVectorWidth; }
Index: llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
===
--- llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
+++ llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
@@ -30,7 +30,7 @@
 STATISTIC(NumLFENCEsInserted, "Number of lfence instructions inserted");
 
 static cl::opt EnableSpeculativeExecutionSideEffectSuppression(
-"x86-seses-enable",
+"x86-seses-enable-without-lvi-cfi",
 cl::desc("Force enable speculative execution side effect suppression. "
  "(Note: User must pass -mlvi-cfi in order to mitigate indirect "
  "branches and returns.)"),
@@ -91,10 +91,12 @@
   const auto  = MF.getTarget().getOptLevel();
   const X86Subtarget  = MF.getSubtarget();
 
-  // Check whether SESES needs to run as the fallback for LVI at O0 or if the
-  // user explicitly passed the SESES flag.
+  // Check whether SESES needs to run as the fallback for LVI at O0, whether the
+  // user explicitly passed an SESES flag, or whether the SESES target feature
+  // was set.
   if (!EnableSpeculativeExecutionSideEffectSuppression &&
-  !(Subtarget.useLVILoadHardening() && OptLevel == CodeGenOpt::None))
+  !(Subtarget.useLVILoadHardening() && OptLevel == CodeGenOpt::None) &&
+  !Subtarget.useSpeculativeExecutionSideEffectSuppression())
 return false;
 
   LLVM_DEBUG(dbgs() << "** " << getPassName() << " : " << MF.getName()
Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -455,6 +455,15 @@
   "LFENCE 

[PATCH] D81583: Update SystemZ ABI to handle C++20 [[no_unique_address]] attribute

2020-07-07 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand updated this revision to Diff 276151.
uweigand added a comment.

Rebased against mainline.


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

https://reviews.llvm.org/D81583

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/systemz-abi.cpp

Index: clang/test/CodeGen/systemz-abi.cpp
===
--- clang/test/CodeGen/systemz-abi.cpp
+++ clang/test/CodeGen/systemz-abi.cpp
@@ -23,3 +23,28 @@
 // CHECK-LABEL: define void @_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret align 4 %{{.*}}, float %{{.*}})
 // SOFT-FLOAT-LABEL:  define void @_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret align 4 %{{.*}}, i32 %{{.*}})
 
+
+// A field member of empty class type in C++ makes the record nonhomogeneous,
+// unless it is marked as [[no_unique_address]];
+struct empty { };
+struct agg_nofloat_empty { float a; empty dummy; };
+struct agg_nofloat_empty pass_agg_nofloat_empty(struct agg_nofloat_empty arg) { return arg; }
+// CHECK-LABEL: define void @_Z22pass_agg_nofloat_empty17agg_nofloat_empty(%struct.agg_nofloat_empty* noalias sret align 4 %{{.*}}, i64 %{{.*}})
+// SOFT-FLOAT-LABEL:  define void @_Z22pass_agg_nofloat_empty17agg_nofloat_empty(%struct.agg_nofloat_empty* noalias sret align 4 %{{.*}}, i64 %{{.*}})
+struct agg_float_empty { float a; [[no_unique_address]] empty dummy; };
+struct agg_float_empty pass_agg_float_empty(struct agg_float_empty arg) { return arg; }
+// CHECK-LABEL: define void @_Z20pass_agg_float_empty15agg_float_empty(%struct.agg_float_empty* noalias sret align 4 %{{.*}}, float %{{.*}})
+// SOFT-FLOAT-LABEL:  define void @_Z20pass_agg_float_empty15agg_float_empty(%struct.agg_float_empty* noalias sret align 4 %{{.*}}, i32 %{{.*}})
+
+// And likewise for members of base classes.
+struct noemptybase { empty dummy; };
+struct agg_nofloat_emptybase : noemptybase { float a; };
+struct agg_nofloat_emptybase pass_agg_nofloat_emptybase(struct agg_nofloat_emptybase arg) { return arg; }
+// CHECK-LABEL: define void @_Z26pass_agg_nofloat_emptybase21agg_nofloat_emptybase(%struct.agg_nofloat_emptybase* noalias sret align 4 %{{.*}}, i64 %{{.*}})
+// SOFT-FLOAT-LABEL:  define void @_Z26pass_agg_nofloat_emptybase21agg_nofloat_emptybase(%struct.agg_nofloat_emptybase* noalias sret align 4 %{{.*}}, i64 %{{.*}})
+struct emptybase { [[no_unique_address]] empty dummy; };
+struct agg_float_emptybase : emptybase { float a; };
+struct agg_float_emptybase pass_agg_float_emptybase(struct agg_float_emptybase arg) { return arg; }
+// CHECK-LABEL: define void @_Z24pass_agg_float_emptybase19agg_float_emptybase(%struct.agg_float_emptybase* noalias sret align 4 %{{.*}}, float %{{.*}})
+// SOFT-FLOAT-LABEL:  define void @_Z24pass_agg_float_emptybase19agg_float_emptybase(%struct.agg_float_emptybase* noalias sret align 4 %{{.*}}, i32 %{{.*}})
+
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -486,12 +486,13 @@
   return Ctx.getOrInsertSyncScopeID(""); /* default sync scope */
 }
 
-static bool isEmptyRecord(ASTContext , QualType T, bool AllowArrays);
+static bool isEmptyRecord(ASTContext , QualType T, bool AllowArrays,
+  bool AllowNoUniqueAddr = false);
 
 /// isEmptyField - Return true iff a the field is "empty", that is it
 /// is an unnamed bit-field or an (array of) empty record(s).
 static bool isEmptyField(ASTContext , const FieldDecl *FD,
- bool AllowArrays) {
+ bool AllowArrays, bool AllowNoUniqueAddr = false) {
   if (FD->isUnnamedBitfield())
 return true;
 
@@ -514,16 +515,23 @@
   //
   // FIXME: We should use a predicate for whether this behavior is true in the
   // current ABI.
-  if (isa(RT->getDecl()))
+  //
+  // The exception to the above rule are fields marked with the
+  // [[no_unique_address]] attribute (since C++20).  Those do count
+  // as empty according to the Itanium ABI.  This property is currently
+  // only respected if the AllowNoUniqueAddr parameter is true.
+  if (isa(RT->getDecl()) &&
+  !(AllowNoUniqueAddr && FD->hasAttr()))
 return false;
 
-  return isEmptyRecord(Context, FT, AllowArrays);
+  return isEmptyRecord(Context, FT, AllowArrays, AllowNoUniqueAddr);
 }
 
 /// isEmptyRecord - Return true iff a structure contains only empty
 /// fields. Note that a structure with a flexible array member is not
 /// considered empty.
-static bool isEmptyRecord(ASTContext , QualType T, bool AllowArrays) {
+static bool isEmptyRecord(ASTContext , QualType T, bool AllowArrays,
+  bool AllowNoUniqueAddr) {
   const RecordType *RT = T->getAs();
   if (!RT)
 return false;
@@ -534,11 +542,11 @@
   // If this is a C++ record, check the bases first.
   if (const CXXRecordDecl *CXXRD = dyn_cast(RD))
 for (const auto  : 

[PATCH] D83149: [gcov] Add __gcov_dump/__gcov_reset and delete __gcov_flush

2020-07-07 Thread serge via Phabricator via cfe-commits
serge-sans-paille added inline comments.



Comment at: compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c:49
   dlerror();
-  void (*gcov_flush1)() = (void (*)())dlsym(f1_handle, "__gcov_flush");
-  if (gcov_flush1 == NULL) {
-fprintf(stderr, "unable to find __gcov_flush in func.shared': %s\n", 
dlerror());
+  void (*gcov_reset1)() = (void (*)())dlsym(f1_handle, "__gcov_reset");
+  if (gcov_reset1 == NULL) {

MaskRay wrote:
> serge-sans-paille wrote:
> > Do we also need to test gcov_flush symbol here too?
> `__gcov_flush` is deleted. We don't need to test it.
Sorry, I meant `__gcov_dump`



Comment at: 
compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c.gcov:56
+// CHECK-NEXT:1:   50:  if (gcov_reset1 == NULL) {
+// CHECK-NEXT:#:   51:fprintf(stderr, "unable to find __gcov_reset 
in func.shared': %s\n", dlerror());
 // CHECK-NEXT:#:   52:return EXIT_FAILURE;

MaskRay wrote:
> serge-sans-paille wrote:
> > Same question here, what about gcov_flush symbol?
> `__gcov_flush` is deleted. We don't need to test it.
Sorry, I meant `__gcov_dump`



Comment at: 
compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main_three-libs.c.gcov:55
+// CHECK-NEXT:1:   49:  void (*gcov_reset1)() = (void 
(*)())dlsym(f1_handle, "__gcov_reset");
+// CHECK-NEXT:1:   50:  if (gcov_reset1 == NULL) {
+// CHECK-NEXT:#:   51:fprintf(stderr, "unable to find __gcov_reset 
in func.shared': %s\n", dlerror());

MaskRay wrote:
> serge-sans-paille wrote:
> > And here.
> `__gcov_flush` is deleted. We don't need to test it.
Sorry, I meant `__gcov_dump`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83149



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


[PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang

2020-07-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2787
+  if (getLangOpts().OpenMP < 51 && Kind == OMPC_default &&
+  static_cast(Val.getValue().Type) ==
+  OMP_DEFAULT_firstprivate) {

atmnpatel wrote:
> ABataev wrote:
> > atmnpatel wrote:
> > > ABataev wrote:
> > > > ABataev wrote:
> > > > > No need for cast here. 
> > > > Still no need for the cast
> > > Sorry, I saw that before and checked if I could remove it and I can't. 
> > > Val.getValue().Type is an unsigned int and the other is an enum.
> > This enum should be converted to `int` implicitly, no?
> When we moved the definition of this enum over from clang to llvm, we 
> converted them to strongly typed enums.
I see. Ok then, leave it as is


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75591



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


[PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang

2020-07-07 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel marked an inline comment as done.
atmnpatel added inline comments.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2787
+  if (getLangOpts().OpenMP < 51 && Kind == OMPC_default &&
+  static_cast(Val.getValue().Type) ==
+  OMP_DEFAULT_firstprivate) {

ABataev wrote:
> atmnpatel wrote:
> > ABataev wrote:
> > > ABataev wrote:
> > > > No need for cast here. 
> > > Still no need for the cast
> > Sorry, I saw that before and checked if I could remove it and I can't. 
> > Val.getValue().Type is an unsigned int and the other is an enum.
> This enum should be converted to `int` implicitly, no?
When we moved the definition of this enum over from clang to llvm, we converted 
them to strongly typed enums.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75591



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


[PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses

2020-07-07 Thread Zola Bridges via Phabricator via cfe-commits
zbrid updated this revision to Diff 276147.
zbrid added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79910

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
  llvm/lib/Target/X86/X86Subtarget.h

Index: llvm/lib/Target/X86/X86Subtarget.h
===
--- llvm/lib/Target/X86/X86Subtarget.h
+++ llvm/lib/Target/X86/X86Subtarget.h
@@ -442,6 +442,9 @@
   /// POP+LFENCE+JMP sequence.
   bool UseLVIControlFlowIntegrity = false;
 
+  /// Enable Speculative Execution Side Effect Suppression
+  bool UseSpeculativeExecutionSideEffectSuppression = false;
+
   /// Insert LFENCE instructions to prevent data speculatively injected into
   /// loads from being used maliciously.
   bool UseLVILoadHardening = false;
@@ -759,6 +762,9 @@
   bool useGLMDivSqrtCosts() const { return UseGLMDivSqrtCosts; }
   bool useLVIControlFlowIntegrity() const { return UseLVIControlFlowIntegrity; }
   bool useLVILoadHardening() const { return UseLVILoadHardening; }
+  bool useSpeculativeExecutionSideEffectSuppression() const {
+return UseSpeculativeExecutionSideEffectSuppression;
+  }
 
   unsigned getPreferVectorWidth() const { return PreferVectorWidth; }
   unsigned getRequiredVectorWidth() const { return RequiredVectorWidth; }
Index: llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
===
--- llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
+++ llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
@@ -91,10 +91,12 @@
   const auto  = MF.getTarget().getOptLevel();
   const X86Subtarget  = MF.getSubtarget();
 
-  // Check whether SESES needs to run as the fallback for LVI at O0 or if the
-  // user explicitly passed the SESES flag.
+  // Check whether SESES needs to run as the fallback for LVI at O0, whether the
+  // user explicitly passed an SESES flag, or whether the SESES target feature
+  // was set.
   if (!EnableSpeculativeExecutionSideEffectSuppression &&
-  !(Subtarget.useLVILoadHardening() && OptLevel == CodeGenOpt::None))
+  !(Subtarget.useLVILoadHardening() && OptLevel == CodeGenOpt::None) &&
+  !Subtarget.useSpeculativeExecutionSideEffectSuppression())
 return false;
 
   LLVM_DEBUG(dbgs() << "** " << getPassName() << " : " << MF.getName()
Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -455,6 +455,15 @@
   "LFENCE instruction to serialize control flow. Also decompose RET "
   "instructions into a POP+LFENCE+JMP sequence.">;
 
+// Enable SESES to mitigate speculative execution attacks
+def FeatureSpeculativeExecutionSideEffectSuppression
+: SubtargetFeature<
+  "seses", "UseSpeculativeExecutionSideEffectSuppression", "true",
+  "Prevent speculative execution side channel timing attacks by "
+  "inserting a speculation barrier before memory reads, memory writes, "
+  "and conditional branches. Implies LVI Control Flow integrity.",
+  [FeatureLVIControlFlowIntegrity]>;
+
 // Mitigate LVI attacks against data loads
 def FeatureLVILoadHardening
 : SubtargetFeature<
Index: clang/test/Driver/x86-target-features.c
===
--- clang/test/Driver/x86-target-features.c
+++ clang/test/Driver/x86-target-features.c
@@ -178,6 +178,27 @@
 // RUN: %clang -target i386-linux-gnu -mlvi-hardening -mretpoline-external-thunk %s -### -o %t.o 2>&1 | FileCheck -check-prefix=LVIHARDENING-RETPOLINE-EXTERNAL-THUNK %s
 // LVIHARDENING-RETPOLINE-EXTERNAL-THUNK: error: invalid argument 'mretpoline-external-thunk' not allowed with 'mlvi-hardening'
 
+// RUN: %clang -target i386-linux-gnu -mseses %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES %s
+// RUN: %clang -target i386-linux-gnu -mno-seses %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-SESES %s
+// SESES: "-target-feature" "+seses"
+// SESES: "-target-feature" "+lvi-cfi"
+// NO-SESES-NOT: seses
+// NO-SESES-NOT: lvi-cfi
+
+// RUN: %clang -target i386-linux-gnu -mseses -mno-lvi-cfi %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES-NOLVICFI %s
+// SESES-NOLVICFI: "-target-feature" "+seses"
+// SESES-NOLVICFI-NOT: lvi-cfi
+
+// RUN: %clang -target i386-linux-gnu -mseses -mspeculative-load-hardening %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES-SLH %s
+// SESES-SLH: error: invalid argument 'mspeculative-load-hardening' not allowed with 'mseses'
+// RUN: %clang -target i386-linux-gnu -mseses -mretpoline %s -### -o %t.o 2>&1 | 

[PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang

2020-07-07 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2787
+  if (getLangOpts().OpenMP < 51 && Kind == OMPC_default &&
+  static_cast(Val.getValue().Type) ==
+  OMP_DEFAULT_firstprivate) {

atmnpatel wrote:
> ABataev wrote:
> > ABataev wrote:
> > > No need for cast here. 
> > Still no need for the cast
> Sorry, I saw that before and checked if I could remove it and I can't. 
> Val.getValue().Type is an unsigned int and the other is an enum.
This enum should be converted to `int` implicitly, no?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75591



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


[PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang

2020-07-07 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel added inline comments.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2787
+  if (getLangOpts().OpenMP < 51 && Kind == OMPC_default &&
+  static_cast(Val.getValue().Type) ==
+  OMP_DEFAULT_firstprivate) {

ABataev wrote:
> ABataev wrote:
> > No need for cast here. 
> Still no need for the cast
Sorry, I saw that before and checked if I could remove it and I can't. 
Val.getValue().Type is an unsigned int and the other is an enum.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75591



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


[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-07-07 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 276143.
Xiangling_L marked 14 inline comments as done.
Xiangling_L added a comment.

Fixed typedef issue on incomplete array field and add a test for it;
Added a test for where pack attribute on object also apply on base classes;
Addressed other comments;


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

https://reviews.llvm.org/D79719

Files:
  clang/include/clang/AST/RecordLayout.h
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayout.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/PPC.h
  clang/test/Layout/aix-Wpacked.cpp
  clang/test/Layout/aix-double-struct-member.cpp
  clang/test/Layout/aix-no-unique-address-with-double.cpp
  clang/test/Layout/aix-pack-attr-on-base.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Layout/aix-virtual-function-and-base-with-double.cpp

Index: clang/test/Layout/aix-virtual-function-and-base-with-double.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-virtual-function-and-base-with-double.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple powerpc-ibm-aix-xcoff \
+// RUN: -fdump-record-layouts -fsyntax-only %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK32 %s
+
+// RUN: %clang_cc1 -emit-llvm-only -triple powerpc64-ibm-aix-xcoff \
+// RUN: -fdump-record-layouts -fsyntax-only %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK64 %s
+
+namespace test1 {
+struct A {
+  double d1;
+  virtual void boo() {}
+};
+
+struct B {
+  double d2;
+  A a;
+};
+
+struct C : public A {
+  double d3;
+};
+
+int i = sizeof(B);
+int j = sizeof(C);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::A
+// CHECK-NEXT:0 |   (A vtable pointer)
+// CHECK32-NEXT:  4 |   double d1
+// CHECK32-NEXT:| [sizeof=12, dsize=12, align=4, preferredalign=4,
+// CHECK32-NEXT:|  nvsize=12, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:  8 |   double d1
+// CHECK64-NEXT:| [sizeof=16, dsize=16, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=16, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::B
+// CHECK-NEXT:0 |   double d2
+// CHECK-NEXT:8 |   struct test1::A a
+// CHECK-NEXT:8 | (A vtable pointer)
+// CHECK32-NEXT: 12 | double d1
+// CHECK32-NEXT:| [sizeof=24, dsize=20, align=4, preferredalign=8,
+// CHECK32-NEXT:|  nvsize=20, nvalign=4, preferrednvalign=8]
+// CHECK64-NEXT: 16 | double d1
+// CHECK64-NEXT:| [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=24, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::C
+// CHECK-NEXT:0 |   struct test1::A (primary base)
+// CHECK-NEXT:0 | (A vtable pointer)
+// CHECK32-NEXT:  4 | double d1
+// CHECK32-NEXT: 12 |   double d3
+// CHECK32-NEXT:| [sizeof=20, dsize=20, align=4, preferredalign=4,
+// CHECK32-NEXT:|  nvsize=20, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:  8 | double d1
+// CHECK64-NEXT: 16 |   double d3
+// CHECK64-NEXT:| [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=24, nvalign=8, preferrednvalign=8]
+
+} // namespace test1
+
+namespace test2 {
+struct A {
+  long long l1;
+};
+
+struct B : public virtual A {
+  double d2;
+};
+
+#pragma pack(2)
+struct C : public virtual A {
+  double __attribute__((aligned(4))) d3;
+};
+
+int i = sizeof(B);
+int j = sizeof(C);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::A
+// CHECK-NEXT:0 |   long long l1
+// CHECK-NEXT:  | [sizeof=8, dsize=8, align=8, preferredalign=8,
+// CHECK-NEXT:  |  nvsize=8, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::B
+// CHECK-NEXT:0 |   (B vtable pointer)
+// CHECK32-NEXT:  4 |   double d2
+// CHECK64-NEXT:  8 |   double d2
+// CHECK-NEXT:   16 |   struct test2::A (virtual base)
+// CHECK-NEXT:   16 | long long l1
+// CHECK-NEXT:  | [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK32-NEXT:|  nvsize=12, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:|  nvsize=16, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::C
+// CHECK-NEXT:0 |   (C vtable pointer)
+// CHECK32-NEXT:  4 |   double d3
+// CHECK32-NEXT: 

[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-07-07 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1225
+   Context.getTargetInfo().getTriple().isPS4() ||
+   Context.getTargetInfo().getTriple().isOSAIX()))
+   ? CharUnits::One()

hubert.reinterpretcast wrote:
> Thanks; verified that this is correct with `xlclang++` from IBM XL C/C++ for 
> AIX with:
> ```
> struct A {
>   char x;
> };
> struct B {
>   int x;
> };
> struct __attribute__((__packed__)) C : A, B {} c;
> ```
> 
> Length is 5:
> ```
> [10]m   0x0004  .bss 1  externc
> [11]a4  0x0005   00 CM   RW00
> ```
> 
> @Xiangling_L, I suggest adding a case for this to the tests.
Sure, I will add it.


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

https://reviews.llvm.org/D79719



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


[PATCH] D79842: [clang][Driver] Correct tool search path priority

2020-07-07 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

Yes, this issue was hit with the reland applied. When given a 
`--` format LLVM_DEFAULT_TARGET_TRIPLE, Clang would expand the 
target triple to `---`, and therefore causes the name 
mismatch between what the driver searches for and what the test case creates as 
the dummy tool.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79842



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


[clang] 80a1b95 - [SystemZ ABI] Allow class types in GetSingleElementType

2020-07-07 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2020-07-07T19:56:19+02:00
New Revision: 80a1b95b8e72674cef7efb39636dc73c248ae6f3

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

LOG: [SystemZ ABI] Allow class types in GetSingleElementType

The SystemZ ABI specifies that aggregate types with just a single
member of floating-point type shall be passed as if they were just
a scalar of that type.  This applies to both struct and class types
(but not unions).

However, the current ABI support code in clang only checks this
case for struct types, which means that for class types, generated
code does not adhere to the platform ABI.

Fixed by accepting both struct and class types in the
SystemZABIInfo::GetSingleElementType routine.

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/systemz-abi.c
clang/test/CodeGen/systemz-abi.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 7947aff6cc2f..801adc29acd1 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -7208,7 +7208,9 @@ bool SystemZABIInfo::isFPArgumentType(QualType Ty) const {
 }
 
 QualType SystemZABIInfo::GetSingleElementType(QualType Ty) const {
-  if (const RecordType *RT = Ty->getAsStructureType()) {
+  const RecordType *RT = Ty->getAs();
+
+  if (RT && RT->isStructureOrClassType()) {
 const RecordDecl *RD = RT->getDecl();
 QualType Found;
 

diff  --git a/clang/test/CodeGen/systemz-abi.c 
b/clang/test/CodeGen/systemz-abi.c
index 35adbbe301c4..9f9cb2275bfa 100644
--- a/clang/test/CodeGen/systemz-abi.c
+++ b/clang/test/CodeGen/systemz-abi.c
@@ -155,6 +155,17 @@ struct agg_nofloat3 pass_agg_nofloat3(struct agg_nofloat3 
arg) { return arg; }
 // CHECK-LABEL: define void @pass_agg_nofloat3(%struct.agg_nofloat3* noalias 
sret align 4 %{{.*}}, i32 %{{.*}})
 
 
+// Union types likewise are *not* float-like aggregate types
+
+union union_float { float a; };
+union union_float pass_union_float(union union_float arg) { return arg; }
+// CHECK-LABEL: define void @pass_union_float(%union.union_float* noalias sret 
align 4 %{{.*}}, i32 %{{.*}})
+
+union union_double { double a; };
+union union_double pass_union_double(union union_double arg) { return arg; }
+// CHECK-LABEL: define void @pass_union_double(%union.union_double* noalias 
sret align 8 %{{.*}}, i64 %{{.*}})
+
+
 // Accessing variable argument lists
 
 int va_int(__builtin_va_list l) { return __builtin_va_arg(l, int); }

diff  --git a/clang/test/CodeGen/systemz-abi.cpp 
b/clang/test/CodeGen/systemz-abi.cpp
index cb381e88dd8f..7604dea41dde 100644
--- a/clang/test/CodeGen/systemz-abi.cpp
+++ b/clang/test/CodeGen/systemz-abi.cpp
@@ -2,10 +2,24 @@
 // RUN: %clang_cc1 -triple s390x-linux-gnu -emit-llvm -x c++ -o - %s 
-mfloat-abi soft \
 // RUN:   | FileCheck %s --check-prefix=SOFT-FLOAT
 
+// Verify that class types are also recognized as float-like aggregate types
+
+class agg_float_class { float a; };
+class agg_float_class pass_agg_float_class(class agg_float_class arg) { return 
arg; }
+// CHECK-LABEL: define void 
@_Z20pass_agg_float_class15agg_float_class(%class.agg_float_class* noalias sret 
align 4 %{{.*}}, float %{{.*}})
+// SOFT-FLOAT-LABEL: define void 
@_Z20pass_agg_float_class15agg_float_class(%class.agg_float_class* noalias sret 
align 4 %{{.*}}, i32 %{{.*}})
+
+class agg_double_class { double a; };
+class agg_double_class pass_agg_double_class(class agg_double_class arg) { 
return arg; }
+// CHECK-LABEL: define void 
@_Z21pass_agg_double_class16agg_double_class(%class.agg_double_class* noalias 
sret align 8 %{{.*}}, double %{{.*}})
+// SOFT-FLOAT-LABEL: define void 
@_Z21pass_agg_double_class16agg_double_class(%class.agg_double_class* noalias 
sret align 8 %{{.*}}, i64 %{{.*}})
+
+
 // For compatibility with GCC, this structure is passed in an FPR in C++,
 // but passed in a GPR in C (checked in systemz-abi.c).
 
 struct agg_float_cpp { float a; int : 0; };
 struct agg_float_cpp pass_agg_float_cpp(struct agg_float_cpp arg) { return 
arg; }
 // CHECK-LABEL: define void 
@_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret 
align 4 %{{.*}}, float %{{.*}})
-// SOFT-FLOAT:  define void 
@_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret 
align 4 %{{.*}}, i32 %{{.*}})
+// SOFT-FLOAT-LABEL:  define void 
@_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret 
align 4 %{{.*}}, i32 %{{.*}})
+



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


[PATCH] D82904: [clang-tidy] Warn pointer captured in async block

2020-07-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst:13
+
+  .. code-block:: objc
+void foo(__attribute__((noescape)) int *p) {

ellis wrote:
> It looks like I triggered a build failure for the clang-tools docs 
> http://lab.llvm.org:8011/builders/clang-tools-sphinx-docs/builds/62418
> 
> I think the fix is to add a new line here, but I haven't been able to test it 
> locally.
I pushed that fix up before getting your email. I'll keep an eye on the bot to 
ensure the fix worked. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82904



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


[clang-tools-extra] aef04d3 - Speculatively fix the sphinx build.

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

Author: Aaron Ballman
Date: 2020-07-07T13:54:28-04:00
New Revision: aef04d3306bff492f69f50675f65c9c4eedfab57

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

LOG: Speculatively fix the sphinx build.

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst

Removed: 




diff  --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
index ea137b9679cc..770a71cc0425 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
@@ -11,6 +11,7 @@ asynchronously-executed block. The block arguments in 
``dispatch_async()`` and
 The following is an example of an invalid use of the ``noescape`` attribute.
 
   .. code-block:: objc
+
 void foo(__attribute__((noescape)) int *p) {
   dispatch_async(queue, ^{
 *p = 123;



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


[PATCH] D82904: [clang-tidy] Warn pointer captured in async block

2020-07-07 Thread Ellis Hoag via Phabricator via cfe-commits
ellis marked an inline comment as done.
ellis added inline comments.



Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst:13
+
+  .. code-block:: objc
+void foo(__attribute__((noescape)) int *p) {

It looks like I triggered a build failure for the clang-tools docs 
http://lab.llvm.org:8011/builders/clang-tools-sphinx-docs/builds/62418

I think the fix is to add a new line here, but I haven't been able to test it 
locally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82904



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


[PATCH] D83149: [gcov] Add __gcov_dump/__gcov_reset and delete __gcov_flush

2020-07-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked 6 inline comments as done.
MaskRay added inline comments.



Comment at: compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c:49
   dlerror();
-  void (*gcov_flush1)() = (void (*)())dlsym(f1_handle, "__gcov_flush");
-  if (gcov_flush1 == NULL) {
-fprintf(stderr, "unable to find __gcov_flush in func.shared': %s\n", 
dlerror());
+  void (*gcov_reset1)() = (void (*)())dlsym(f1_handle, "__gcov_reset");
+  if (gcov_reset1 == NULL) {

serge-sans-paille wrote:
> Do we also need to test gcov_flush symbol here too?
`__gcov_flush` is deleted. We don't need to test it.



Comment at: 
compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c.gcov:56
+// CHECK-NEXT:1:   50:  if (gcov_reset1 == NULL) {
+// CHECK-NEXT:#:   51:fprintf(stderr, "unable to find __gcov_reset 
in func.shared': %s\n", dlerror());
 // CHECK-NEXT:#:   52:return EXIT_FAILURE;

serge-sans-paille wrote:
> Same question here, what about gcov_flush symbol?
`__gcov_flush` is deleted. We don't need to test it.



Comment at: 
compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main_three-libs.c.gcov:55
+// CHECK-NEXT:1:   49:  void (*gcov_reset1)() = (void 
(*)())dlsym(f1_handle, "__gcov_reset");
+// CHECK-NEXT:1:   50:  if (gcov_reset1 == NULL) {
+// CHECK-NEXT:#:   51:fprintf(stderr, "unable to find __gcov_reset 
in func.shared': %s\n", dlerror());

serge-sans-paille wrote:
> And here.
`__gcov_flush` is deleted. We don't need to test it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83149



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


[PATCH] D82611: [SemaObjC] Add a warning for @selector expressions that potentially refer to objc_direct methods

2020-07-07 Thread Erik Pilkington via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
erik.pilkington marked an inline comment as done.
Closed by commit rG7437a9496528: [SemaObjC] Add a warning for @selector 
expressions that potentially refer to… (authored by erik.pilkington).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D82611?vs=273549=275674#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82611

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExprObjC.cpp
  clang/test/SemaObjC/potentially-direct-selector.m

Index: clang/test/SemaObjC/potentially-direct-selector.m
===
--- /dev/null
+++ clang/test/SemaObjC/potentially-direct-selector.m
@@ -0,0 +1,157 @@
+// RUN: %clang_cc1 %s -Wpotentially-direct-selector -verify
+// RUN: %clang_cc1 %s -Wstrict-potentially-direct-selector -verify=expected,strict
+
+#define NS_DIRECT __attribute__((objc_direct))
+
+__attribute__((objc_root_class))
+@interface Dummies
+-(void)inBase;
+-(void)inBaseImpl;
+-(void)inBaseCat;
+-(void)inBaseCatImpl;
+-(void)inDerived;
+-(void)inDerivedImpl;
+-(void)inDerivedCat;
+-(void)inDerivedCatImpl;
++(void)inBaseClass;
++(void)inDerivedClass;
++(void)inDerivedCatClass;
+@end
+
+__attribute__((objc_root_class))
+@interface Base
+-(void)inBase NS_DIRECT; // expected-note + {{direct method}}
++(void)inBaseClass NS_DIRECT;  // expected-note + {{direct method}}
+@end
+
+@implementation Base
+-(void)inBaseImpl NS_DIRECT { // expected-note + {{direct method}}
+}
+-(void)inBase {}
++(void)inBaseClass {}
+@end
+
+@interface Base (Cat)
+-(void)inBaseCat NS_DIRECT; // expected-note + {{direct method}}
+@end
+
+@implementation Base (Cat)
+-(void)inBaseCatImpl NS_DIRECT { // expected-note + {{direct method}}
+}
+-(void)inBaseCat {}
+@end
+
+@interface Derived : Base
+-(void)inDerived NS_DIRECT; // expected-note + {{direct method}}
++(void)inDerivedClass NS_DIRECT;  // expected-note + {{direct method}}
+@end
+
+@implementation Derived
+-(void)inDerivedImpl NS_DIRECT { // expected-note + {{direct method}}
+}
+-(void)inDerived {}
++(void)inDerivedClass {}
+@end
+
+@interface Derived (Cat)
+-(void)inDerivedCat NS_DIRECT; // expected-note + {{direct method}}
++(void)inDerivedCatClass NS_DIRECT; // expected-note + {{direct method}}
+@end
+
+@implementation Derived (Cat)
+-(void)inDerivedCatImpl NS_DIRECT { // expected-note + {{direct method}}
+}
+-(void)inDerivedCat {}
++(void)inDerivedCatClass {}
+
+-(void)test1 {
+  (void)@selector(inBase); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseCat); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseCatImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerived); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCat); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCatImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedClass); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseClass); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCatClass); // expected-warning{{@selector expression formed with potentially direct selector}}
+}
+@end
+
+void test2() {
+  (void)@selector(inBase); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseCat); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseCatImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerived); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCat); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCatImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
+  

[PATCH] D81751: [SemaObjC] Fix a -Wobjc-signed-char-bool false-positive with binary conditional operator

2020-07-07 Thread Erik Pilkington via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2f71cf6d77c5: [SemaObjC] Fix a -Wobjc-signed-char-bool 
false-positive with binary conditional… (authored by erik.pilkington).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D81751?vs=270455=275675#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81751

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaObjC/signed-char-bool-conversion.m


Index: clang/test/SemaObjC/signed-char-bool-conversion.m
===
--- clang/test/SemaObjC/signed-char-bool-conversion.m
+++ clang/test/SemaObjC/signed-char-bool-conversion.m
@@ -108,3 +108,15 @@
   f(); // expected-note {{in instantiation of function template 
specialization 'f' requested here}}
 }
 #endif
+
+void t5(BOOL b) {
+  int i;
+  b = b ?: YES; // no warning
+  b = b ?: i; // expected-warning {{implicit conversion from integral type 
'int' to 'BOOL'}}
+  b = (b = i) // expected-warning {{implicit conversion from integral type 
'int' to 'BOOL'}}
+   ?: YES;
+  b = (1 ? YES : i) ?: YES; // expected-warning {{implicit conversion from 
integral type 'int' to 'BOOL'}}
+  b = b ?: (1 ? i : i); // expected-warning 2 {{implicit conversion from 
integral type 'int' to 'BOOL'}}
+
+  b = b ? YES : (i ?: 0); // expected-warning {{implicit conversion from 
integral type 'int' to 'BOOL'}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11936,27 +11936,31 @@
   }
 }
 
-static void CheckConditionalOperator(Sema , ConditionalOperator *E,
+static void CheckConditionalOperator(Sema , AbstractConditionalOperator *E,
  SourceLocation CC, QualType T);
 
 static void CheckConditionalOperand(Sema , Expr *E, QualType T,
 SourceLocation CC, bool ) {
   E = E->IgnoreParenImpCasts();
 
-  if (isa(E))
-return CheckConditionalOperator(S, cast(E), CC, T);
+  if (auto *CO = dyn_cast(E))
+return CheckConditionalOperator(S, CO, CC, T);
 
   AnalyzeImplicitConversions(S, E, CC);
   if (E->getType() != T)
 return CheckImplicitConversion(S, E, T, CC, );
 }
 
-static void CheckConditionalOperator(Sema , ConditionalOperator *E,
+static void CheckConditionalOperator(Sema , AbstractConditionalOperator *E,
  SourceLocation CC, QualType T) {
   AnalyzeImplicitConversions(S, E->getCond(), E->getQuestionLoc());
 
+  Expr *TrueExpr = E->getTrueExpr();
+  if (auto *BCO = dyn_cast(E))
+TrueExpr = BCO->getCommon();
+
   bool Suspicious = false;
-  CheckConditionalOperand(S, E->getTrueExpr(), T, CC, Suspicious);
+  CheckConditionalOperand(S, TrueExpr, T, CC, Suspicious);
   CheckConditionalOperand(S, E->getFalseExpr(), T, CC, Suspicious);
 
   if (T->isBooleanType())
@@ -11975,7 +11979,7 @@
   if (E->getType() == T) return;
 
   Suspicious = false;
-  CheckImplicitConversion(S, E->getTrueExpr()->IgnoreParenImpCasts(),
+  CheckImplicitConversion(S, TrueExpr->IgnoreParenImpCasts(),
   E->getType(), CC, );
   if (!Suspicious)
 CheckImplicitConversion(S, E->getFalseExpr()->IgnoreParenImpCasts(),
@@ -12038,7 +12042,7 @@
 
   // For conditional operators, we analyze the arguments as if they
   // were being fed directly into the output.
-  if (auto *CO = dyn_cast(SourceExpr)) {
+  if (auto *CO = dyn_cast(SourceExpr)) {
 CheckConditionalOperator(S, CO, CC, T);
 return;
   }


Index: clang/test/SemaObjC/signed-char-bool-conversion.m
===
--- clang/test/SemaObjC/signed-char-bool-conversion.m
+++ clang/test/SemaObjC/signed-char-bool-conversion.m
@@ -108,3 +108,15 @@
   f(); // expected-note {{in instantiation of function template specialization 'f' requested here}}
 }
 #endif
+
+void t5(BOOL b) {
+  int i;
+  b = b ?: YES; // no warning
+  b = b ?: i; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+  b = (b = i) // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+   ?: YES;
+  b = (1 ? YES : i) ?: YES; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+  b = b ?: (1 ? i : i); // expected-warning 2 {{implicit conversion from integral type 'int' to 'BOOL'}}
+
+  b = b ? YES : (i ?: 0); // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11936,27 +11936,31 @@
   }
 }
 
-static void 

[PATCH] D82832: Correctly generate invert xor value for Binary Atomics of int size > 64

2020-07-07 Thread Jennifer Yu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6cf0dac1ca3f: orrectly generate invert xor value for Binary 
Atomics of int size  64 (authored by jyu2).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82832

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/Atomics.c


Index: clang/test/CodeGen/Atomics.c
===
--- clang/test/CodeGen/Atomics.c
+++ clang/test/CodeGen/Atomics.c
@@ -10,6 +10,8 @@
 unsigned int ui;
 signed long long sll;
 unsigned long long ull;
+__int128 s128;
+unsigned  __int128 u128;
 
 void test_op_ignore (void) // CHECK-LABEL: define void @test_op_ignore
 {
@@ -48,6 +50,8 @@
   (void) __sync_fetch_and_xor (, 1); // CHECK: atomicrmw xor i32
   (void) __sync_fetch_and_xor (, 1); // CHECK: atomicrmw xor i64
   (void) __sync_fetch_and_xor (, 1); // CHECK: atomicrmw xor i64
+  (void) __sync_fetch_and_xor (, 1); // CHECK: atomicrmw xor i128
+  (void) __sync_fetch_and_xor (, 1); // CHECK: atomicrmw xor i128
 
   (void) __sync_fetch_and_nand (, 1); // CHECK: atomicrmw nand i8
   (void) __sync_fetch_and_nand (, 1); // CHECK: atomicrmw nand i8
@@ -168,27 +172,43 @@
   sc = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
 // CHECK: and
 // CHECK: xor
+// CHECK: -1
   uc = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
 // CHECK: and
 // CHECK: xor
+// CHECK: -1
   ss = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
 // CHECK: and
 // CHECK: xor
+// CHECK: -1
   us = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
 // CHECK: and
 // CHECK: xor
+// CHECK: -1
   si = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
 // CHECK: and
 // CHECK: xor
+// CHECK: -1
   ui = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
 // CHECK: and
 // CHECK: xor
+// CHECK: -1
   sll = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
   // CHECK: and
   // CHECK: xor
+  // CHECK: -1
   ull = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
   // CHECK: and
   // CHECK: xor
+  // CHECK: -1
+  u128 = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
+  // CHECK: and
+  // CHECK: xor
+  // CHECK: -1
+  s128 = __sync_nand_and_fetch (, uc); // CHECK: atomicrmw nand
+  // CHECK: and
+  // CHECK: xor
+  // CHECK: -1
 
   sc = __sync_and_and_fetch (, uc); // CHECK: atomicrmw and
   uc = __sync_and_and_fetch (, uc); // CHECK: atomicrmw and
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -219,8 +219,9 @@
   Kind, Args[0], Args[1], llvm::AtomicOrdering::SequentiallyConsistent);
   Result = CGF.Builder.CreateBinOp(Op, Result, Args[1]);
   if (Invert)
-Result = CGF.Builder.CreateBinOp(llvm::Instruction::Xor, Result,
- llvm::ConstantInt::get(IntType, -1));
+Result =
+CGF.Builder.CreateBinOp(llvm::Instruction::Xor, Result,
+llvm::ConstantInt::getAllOnesValue(IntType));
   Result = EmitFromInt(CGF, Result, T, ValueType);
   return RValue::get(Result);
 }


Index: clang/test/CodeGen/Atomics.c
===
--- clang/test/CodeGen/Atomics.c
+++ clang/test/CodeGen/Atomics.c
@@ -10,6 +10,8 @@
 unsigned int ui;
 signed long long sll;
 unsigned long long ull;
+__int128 s128;
+unsigned  __int128 u128;
 
 void test_op_ignore (void) // CHECK-LABEL: define void @test_op_ignore
 {
@@ -48,6 +50,8 @@
   (void) __sync_fetch_and_xor (, 1); // CHECK: atomicrmw xor i32
   (void) __sync_fetch_and_xor (, 1); // CHECK: 

[PATCH] D82574: Merge TableGen files used for clang options

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

LGTM. We can look at splitting it up again once we know what the dependencies 
are.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82574



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


[PATCH] D62574: Initial draft of target-configurable address spaces.

2020-07-07 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment.

In D62574#2136553 , @danilaml wrote:

> In D62574#2135662 , @ebevhan wrote:
>
> > It's generally not safe to alter address spaces below the top level. C is 
> > just very permissive about it.
>
>
> Isn't that also true for the top-level casts? Unless when it is. And the 
> target should know when it's safe or not. It's just that for non top-level 
> casts there is added condition that casts are noop (i.e. don't change the bit 
> pattern of the pointer). At least that's how I see it.


Yes, I see what you mean. I think that the default assumption in Clang at the 
moment is that it is not safe to do so, hence the current design. Not that 
there are many targets that use address spaces, so perhaps that assumption is 
too conservative for ones that do downstream.


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

https://reviews.llvm.org/D62574



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


[PATCH] D83325: [Sema] Be more thorough when unpacking the AS-qualified pointee for a pointer conversion.

2020-07-07 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan created this revision.
ebevhan added reviewers: svenvh, rjmccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When performing a pointer conversion as the second conversion
in an SCS where the conversion is a derived-to-base and the
address space of the type wants to change, we need to defer
the address space conversion until the third step since we
must perform two ImplicitCasts at once otherwise. We do this
by repacking the destination type we give to
CheckPointerConversion with the source address space.

However, this repacking does not take sugar into account, so
if the address spaces in question are hidden behind nodes like
AttributedType or MacroQualifiedType, it won't work properly.
Also, if the source AS is Default, getAddrSpaceQualType fails,
since it cannot apply a Default AS.

Use the canonical destination type to ensure that we strip
any sugar that would get in the way.

I'm unsure if this is currently broken upstream without other
patches to exploit the behavior, but the fix seems to work for
the use case in D62574 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83325

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CodeGenCXX/address-space-cast.cpp


Index: clang/test/CodeGenCXX/address-space-cast.cpp
===
--- clang/test/CodeGenCXX/address-space-cast.cpp
+++ clang/test/CodeGenCXX/address-space-cast.cpp
@@ -6,6 +6,16 @@
 void func_pvoid(__private__ void *x);
 void func_pint(__private__ int *x);
 
+class Base {
+};
+
+class Derived : public Base {
+};
+
+void fn(Derived *p) {
+  __private__ Base *b = (__private__ Base *)p;
+}
+
 void test_cast(char *gen_char_ptr, void *gen_void_ptr, int *gen_int_ptr) {
   // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)*
   // CHECK-NEXT: store i8 addrspace(5)* %[[cast]]
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4237,14 +4237,21 @@
 }
 
 // Defer address space conversion to the third conversion.
+// FIXME: If PerformImplicitConversion did not try to pass the final
+// destination type to every conversion function in here, this would not
+// be necessary since the address space conversion would be handled as
+// a qualification conversion instead.
 QualType FromPteeType = From->getType()->getPointeeType();
 QualType ToPteeType = ToType->getPointeeType();
 QualType NewToType = ToType;
 if (!FromPteeType.isNull() && !ToPteeType.isNull() &&
 FromPteeType.getAddressSpace() != ToPteeType.getAddressSpace()) {
-  NewToType = Context.removeAddrSpaceQualType(ToPteeType);
-  NewToType = Context.getAddrSpaceQualType(NewToType,
-   FromPteeType.getAddressSpace());
+  NewToType =
+  Context.removeAddrSpaceQualType(ToPteeType.getCanonicalType());
+  if (FromPteeType.getAddressSpace() != LangAS::Default)
+NewToType = Context.getAddrSpaceQualType(
+NewToType, FromPteeType.getAddressSpace());
+
   if (ToType->isObjCObjectPointerType())
 NewToType = Context.getObjCObjectPointerType(NewToType);
   else if (ToType->isBlockPointerType())


Index: clang/test/CodeGenCXX/address-space-cast.cpp
===
--- clang/test/CodeGenCXX/address-space-cast.cpp
+++ clang/test/CodeGenCXX/address-space-cast.cpp
@@ -6,6 +6,16 @@
 void func_pvoid(__private__ void *x);
 void func_pint(__private__ int *x);
 
+class Base {
+};
+
+class Derived : public Base {
+};
+
+void fn(Derived *p) {
+  __private__ Base *b = (__private__ Base *)p;
+}
+
 void test_cast(char *gen_char_ptr, void *gen_void_ptr, int *gen_int_ptr) {
   // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)*
   // CHECK-NEXT: store i8 addrspace(5)* %[[cast]]
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4237,14 +4237,21 @@
 }
 
 // Defer address space conversion to the third conversion.
+// FIXME: If PerformImplicitConversion did not try to pass the final
+// destination type to every conversion function in here, this would not
+// be necessary since the address space conversion would be handled as
+// a qualification conversion instead.
 QualType FromPteeType = From->getType()->getPointeeType();
 QualType ToPteeType = ToType->getPointeeType();
 QualType NewToType = ToType;
 if (!FromPteeType.isNull() && !ToPteeType.isNull() &&
 FromPteeType.getAddressSpace() != ToPteeType.getAddressSpace()) {
-  NewToType = Context.removeAddrSpaceQualType(ToPteeType);
-  NewToType = Context.getAddrSpaceQualType(NewToType,
-  

[PATCH] D82904: [clang-tidy] Warn pointer captured in async block

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

In D82904#2136686 , @ellis wrote:

> Hey @aaron.ballman, thanks for accepting my diff! Would you mind landing my 
> diff since I don't have commit access yet?


Gladly -- I've committed on your behalf in 
dfa0db79d0e37d5cf24a63d1e2b7ba5f40617574 
, thank 
you for the patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82904



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


[clang-tools-extra] dfa0db7 - Warn pointer captured in async block

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

Author: Ellis Hoag
Date: 2020-07-07T13:31:14-04:00
New Revision: dfa0db79d0e37d5cf24a63d1e2b7ba5f40617574

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

LOG: Warn pointer captured in async block

The block arguments in dispatch_async() and dispatch_after() are
guaranteed to escape. If those blocks capture any pointers with the
noescape attribute then it is an error.

Added: 
clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp
clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m

Modified: 
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index d010c3ce7e52..3f735a8484d8 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -34,6 +34,7 @@
 #include "MisplacedWideningCastCheck.h"
 #include "MoveForwardingReferenceCheck.h"
 #include "MultipleStatementMacroCheck.h"
+#include "NoEscapeCheck.h"
 #include "NotNullTerminatedResultCheck.h"
 #include "ParentVirtualCallCheck.h"
 #include "PosixReturnCheck.h"
@@ -120,6 +121,7 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-multiple-statement-macro");
 CheckFactories.registerCheck(
 "bugprone-narrowing-conversions");
+CheckFactories.registerCheck("bugprone-no-escape");
 CheckFactories.registerCheck(
 "bugprone-not-null-terminated-result");
 CheckFactories.registerCheck(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 6cc60ff0d7bc..6e7a94928a5a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -29,6 +29,7 @@ add_clang_library(clangTidyBugproneModule
   MisplacedWideningCastCheck.cpp
   MoveForwardingReferenceCheck.cpp
   MultipleStatementMacroCheck.cpp
+  NoEscapeCheck.cpp
   NotNullTerminatedResultCheck.cpp
   ParentVirtualCallCheck.cpp
   PosixReturnCheck.cpp

diff  --git a/clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp
new file mode 100644
index ..654e80d9a9c6
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp
@@ -0,0 +1,51 @@
+//===--- NoEscapeCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "NoEscapeCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+void NoEscapeCheck::registerMatchers(MatchFinder *Finder) {
+  
Finder->addMatcher(callExpr(callee(functionDecl(hasName("::dispatch_async"))),
+  argumentCountIs(2),
+  hasArgument(1, blockExpr().bind("arg-block"))),
+ this);
+  
Finder->addMatcher(callExpr(callee(functionDecl(hasName("::dispatch_after"))),
+  argumentCountIs(3),
+  hasArgument(2, blockExpr().bind("arg-block"))),
+ this);
+}
+
+void NoEscapeCheck::check(const MatchFinder::MatchResult ) {
+  const auto *MatchedEscapingBlock =
+  Result.Nodes.getNodeAs("arg-block");
+  const BlockDecl *EscapingBlockDecl = MatchedEscapingBlock->getBlockDecl();
+  for (const BlockDecl::Capture  : EscapingBlockDecl->captures()) {
+const VarDecl *Var = CapturedVar.getVariable();
+if (Var && Var->hasAttr()) {
+  // FIXME: Add a method to get the location of the use of a CapturedVar so
+  // that we can diagnose the use of the pointer instead of the block.
+  diag(MatchedEscapingBlock->getBeginLoc(),
+   "pointer %0 with attribute 'noescape' is captured by an "
+   "asynchronously-executed block")
+  << Var;
+  diag(Var->getBeginLoc(), "the 'noescape' attribute is declared here.",
+   DiagnosticIDs::Note);
+}
+  }
+}
+
+} // namespace bugprone
+} // namespace tidy
+} // namespace clang

diff  --git 

[PATCH] D83315: Turn arcmt-* options into a single option

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

I have a slight preference for `-arcmt-action=`, but up to you if you want to 
change it. Otherwise LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83315



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


[PATCH] D81751: [SemaObjC] Fix a -Wobjc-signed-char-bool false-positive with binary conditional operator

2020-07-07 Thread Erik Pilkington via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2f71cf6d77c5: [SemaObjC] Fix a -Wobjc-signed-char-bool 
false-positive with binary conditional… (authored by erik.pilkington).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D81751?vs=270455=276130#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81751

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaObjC/signed-char-bool-conversion.m


Index: clang/test/SemaObjC/signed-char-bool-conversion.m
===
--- clang/test/SemaObjC/signed-char-bool-conversion.m
+++ clang/test/SemaObjC/signed-char-bool-conversion.m
@@ -108,3 +108,15 @@
   f(); // expected-note {{in instantiation of function template 
specialization 'f' requested here}}
 }
 #endif
+
+void t5(BOOL b) {
+  int i;
+  b = b ?: YES; // no warning
+  b = b ?: i; // expected-warning {{implicit conversion from integral type 
'int' to 'BOOL'}}
+  b = (b = i) // expected-warning {{implicit conversion from integral type 
'int' to 'BOOL'}}
+   ?: YES;
+  b = (1 ? YES : i) ?: YES; // expected-warning {{implicit conversion from 
integral type 'int' to 'BOOL'}}
+  b = b ?: (1 ? i : i); // expected-warning 2 {{implicit conversion from 
integral type 'int' to 'BOOL'}}
+
+  b = b ? YES : (i ?: 0); // expected-warning {{implicit conversion from 
integral type 'int' to 'BOOL'}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11936,27 +11936,31 @@
   }
 }
 
-static void CheckConditionalOperator(Sema , ConditionalOperator *E,
+static void CheckConditionalOperator(Sema , AbstractConditionalOperator *E,
  SourceLocation CC, QualType T);
 
 static void CheckConditionalOperand(Sema , Expr *E, QualType T,
 SourceLocation CC, bool ) {
   E = E->IgnoreParenImpCasts();
 
-  if (isa(E))
-return CheckConditionalOperator(S, cast(E), CC, T);
+  if (auto *CO = dyn_cast(E))
+return CheckConditionalOperator(S, CO, CC, T);
 
   AnalyzeImplicitConversions(S, E, CC);
   if (E->getType() != T)
 return CheckImplicitConversion(S, E, T, CC, );
 }
 
-static void CheckConditionalOperator(Sema , ConditionalOperator *E,
+static void CheckConditionalOperator(Sema , AbstractConditionalOperator *E,
  SourceLocation CC, QualType T) {
   AnalyzeImplicitConversions(S, E->getCond(), E->getQuestionLoc());
 
+  Expr *TrueExpr = E->getTrueExpr();
+  if (auto *BCO = dyn_cast(E))
+TrueExpr = BCO->getCommon();
+
   bool Suspicious = false;
-  CheckConditionalOperand(S, E->getTrueExpr(), T, CC, Suspicious);
+  CheckConditionalOperand(S, TrueExpr, T, CC, Suspicious);
   CheckConditionalOperand(S, E->getFalseExpr(), T, CC, Suspicious);
 
   if (T->isBooleanType())
@@ -11975,7 +11979,7 @@
   if (E->getType() == T) return;
 
   Suspicious = false;
-  CheckImplicitConversion(S, E->getTrueExpr()->IgnoreParenImpCasts(),
+  CheckImplicitConversion(S, TrueExpr->IgnoreParenImpCasts(),
   E->getType(), CC, );
   if (!Suspicious)
 CheckImplicitConversion(S, E->getFalseExpr()->IgnoreParenImpCasts(),
@@ -12038,7 +12042,7 @@
 
   // For conditional operators, we analyze the arguments as if they
   // were being fed directly into the output.
-  if (auto *CO = dyn_cast(SourceExpr)) {
+  if (auto *CO = dyn_cast(SourceExpr)) {
 CheckConditionalOperator(S, CO, CC, T);
 return;
   }


Index: clang/test/SemaObjC/signed-char-bool-conversion.m
===
--- clang/test/SemaObjC/signed-char-bool-conversion.m
+++ clang/test/SemaObjC/signed-char-bool-conversion.m
@@ -108,3 +108,15 @@
   f(); // expected-note {{in instantiation of function template specialization 'f' requested here}}
 }
 #endif
+
+void t5(BOOL b) {
+  int i;
+  b = b ?: YES; // no warning
+  b = b ?: i; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+  b = (b = i) // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+   ?: YES;
+  b = (1 ? YES : i) ?: YES; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+  b = b ?: (1 ? i : i); // expected-warning 2 {{implicit conversion from integral type 'int' to 'BOOL'}}
+
+  b = b ? YES : (i ?: 0); // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11936,27 +11936,31 @@
   }
 }
 
-static void 

  1   2   3   >