[PATCH] D84453: [clang-tidy] Suppress one unittest on macOS.

2020-07-27 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8c9241a051fd: [clang-tidy] Suppress one unittest on macOS. 
(authored by dergachev.a).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84453

Files:
  clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp


Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -223,6 +223,7 @@
 }
 
 // FIXME: Figure out why this test causes crashes on mac os.
+// See also comments around the ClangTidyDiagnosticConsumer.SortsErrors test.
 #ifndef __APPLE__
 TEST(ValidConfiguration, ValidEnumOptions) {
 
Index: 
clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
@@ -21,6 +21,16 @@
   }
 };
 
+// FIXME: This test seems to cause a strange linking interference
+// with the ValidConfiguration.ValidEnumOptions test on macOS.
+// If both tests are enabled, this test will fail as if
+// runCheckOnCode() is not invoked at all. Looks like a linker bug.
+// For now both tests are disabled on macOS. It is not sufficient
+// to only disable the other test because this test keeps failing
+// under Address Sanitizer, which may be an indication of more
+// such linking interference with other tests and this test
+// seems to be in the center of it.
+#ifndef __APPLE__
 TEST(ClangTidyDiagnosticConsumer, SortsErrors) {
   std::vector Errors;
   runCheckOnCode("int a;", );
@@ -28,6 +38,7 @@
   EXPECT_EQ("type specifier", Errors[0].Message.Message);
   EXPECT_EQ("variable", Errors[1].Message.Message);
 }
+#endif
 
 } // namespace test
 } // namespace tidy


Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -223,6 +223,7 @@
 }
 
 // FIXME: Figure out why this test causes crashes on mac os.
+// See also comments around the ClangTidyDiagnosticConsumer.SortsErrors test.
 #ifndef __APPLE__
 TEST(ValidConfiguration, ValidEnumOptions) {
 
Index: clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
@@ -21,6 +21,16 @@
   }
 };
 
+// FIXME: This test seems to cause a strange linking interference
+// with the ValidConfiguration.ValidEnumOptions test on macOS.
+// If both tests are enabled, this test will fail as if
+// runCheckOnCode() is not invoked at all. Looks like a linker bug.
+// For now both tests are disabled on macOS. It is not sufficient
+// to only disable the other test because this test keeps failing
+// under Address Sanitizer, which may be an indication of more
+// such linking interference with other tests and this test
+// seems to be in the center of it.
+#ifndef __APPLE__
 TEST(ClangTidyDiagnosticConsumer, SortsErrors) {
   std::vector Errors;
   runCheckOnCode("int a;", );
@@ -28,6 +38,7 @@
   EXPECT_EQ("type specifier", Errors[0].Message.Message);
   EXPECT_EQ("variable", Errors[1].Message.Message);
 }
+#endif
 
 } // namespace test
 } // namespace tidy
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 8c9241a - [clang-tidy] Suppress one unittest on macOS.

2020-07-27 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2020-07-27T22:38:53-07:00
New Revision: 8c9241a051fd677cfbfd9c79c6af9d714be7c792

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

LOG: [clang-tidy] Suppress one unittest on macOS.

Possibly a linker bug but I'm in a hurry to fix a buildbot.

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

Added: 


Modified: 
clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Removed: 




diff  --git 
a/clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp 
b/clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
index 2a4ed64b8850..a8729660bdce 100644
--- a/clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
@@ -21,6 +21,16 @@ class TestCheck : public ClangTidyCheck {
   }
 };
 
+// FIXME: This test seems to cause a strange linking interference
+// with the ValidConfiguration.ValidEnumOptions test on macOS.
+// If both tests are enabled, this test will fail as if
+// runCheckOnCode() is not invoked at all. Looks like a linker bug.
+// For now both tests are disabled on macOS. It is not sufficient
+// to only disable the other test because this test keeps failing
+// under Address Sanitizer, which may be an indication of more
+// such linking interference with other tests and this test
+// seems to be in the center of it.
+#ifndef __APPLE__
 TEST(ClangTidyDiagnosticConsumer, SortsErrors) {
   std::vector Errors;
   runCheckOnCode("int a;", );
@@ -28,6 +38,7 @@ TEST(ClangTidyDiagnosticConsumer, SortsErrors) {
   EXPECT_EQ("type specifier", Errors[0].Message.Message);
   EXPECT_EQ("variable", Errors[1].Message.Message);
 }
+#endif
 
 } // namespace test
 } // namespace tidy

diff  --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp 
b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
index 63f9a06e91be..c4239af0e767 100644
--- a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -223,6 +223,7 @@ TEST(CheckOptionsValidation, ValidIntOptions) {
 }
 
 // FIXME: Figure out why this test causes crashes on mac os.
+// See also comments around the ClangTidyDiagnosticConsumer.SortsErrors test.
 #ifndef __APPLE__
 TEST(ValidConfiguration, ValidEnumOptions) {
 



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


[PATCH] D84453: [clang-tidy] Suppress one unittest on macOS.

2020-07-27 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 281112.
NoQ retitled this revision from "[clang-tidy] Suppress one unittest under 
ASan." to "[clang-tidy] Suppress one unittest on macOS.".
NoQ added a comment.

Update comments with the updated investigation details.


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

https://reviews.llvm.org/D84453

Files:
  clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp


Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -223,6 +223,7 @@
 }
 
 // FIXME: Figure out why this test causes crashes on mac os.
+// See also comments around the ClangTidyDiagnosticConsumer.SortsErrors test.
 #ifndef __APPLE__
 TEST(ValidConfiguration, ValidEnumOptions) {
 
Index: 
clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
@@ -21,6 +21,16 @@
   }
 };
 
+// FIXME: This test seems to cause a strange linking interference
+// with the ValidConfiguration.ValidEnumOptions test on macOS.
+// If both tests are enabled, this test will fail as if
+// runCheckOnCode() is not invoked at all. Looks like a linker bug.
+// For now both tests are disabled on macOS. It is not sufficient
+// to only disable the other test because this test keeps failing
+// under Address Sanitizer, which may be an indication of more
+// such linking interference with other tests and this test
+// seems to be in the center of it.
+#ifndef __APPLE__
 TEST(ClangTidyDiagnosticConsumer, SortsErrors) {
   std::vector Errors;
   runCheckOnCode("int a;", );
@@ -28,6 +38,7 @@
   EXPECT_EQ("type specifier", Errors[0].Message.Message);
   EXPECT_EQ("variable", Errors[1].Message.Message);
 }
+#endif
 
 } // namespace test
 } // namespace tidy


Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -223,6 +223,7 @@
 }
 
 // FIXME: Figure out why this test causes crashes on mac os.
+// See also comments around the ClangTidyDiagnosticConsumer.SortsErrors test.
 #ifndef __APPLE__
 TEST(ValidConfiguration, ValidEnumOptions) {
 
Index: clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
@@ -21,6 +21,16 @@
   }
 };
 
+// FIXME: This test seems to cause a strange linking interference
+// with the ValidConfiguration.ValidEnumOptions test on macOS.
+// If both tests are enabled, this test will fail as if
+// runCheckOnCode() is not invoked at all. Looks like a linker bug.
+// For now both tests are disabled on macOS. It is not sufficient
+// to only disable the other test because this test keeps failing
+// under Address Sanitizer, which may be an indication of more
+// such linking interference with other tests and this test
+// seems to be in the center of it.
+#ifndef __APPLE__
 TEST(ClangTidyDiagnosticConsumer, SortsErrors) {
   std::vector Errors;
   runCheckOnCode("int a;", );
@@ -28,6 +38,7 @@
   EXPECT_EQ("type specifier", Errors[0].Message.Message);
   EXPECT_EQ("variable", Errors[1].Message.Message);
 }
+#endif
 
 } // namespace test
 } // namespace tidy
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84453: [clang-tidy] Suppress one unittest under ASan.

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

In D84453#2171548 , @njames93 wrote:

> I was having issues with this test case under macos in D82188 
> .
> It would fail for seemingly no apparent reason until I disable a test in a 
> different translation unit.
> This made me think there is a subtle bug in the linker used on macos. That 
> could also explain why asan is having a hard time with this as well. 
> I got as far as seeing that runCheckOnCode was called, the check was 
> instantiated but its matchers never got registered effectively meaning it 
> didn't run.

Damn, i'm very glad you showed up. I can reproduce your problem as well, so 
ASan is probably not at fault. I'll try to talk to linker folks to see if they 
can fix this.

I guess i'll still commit this patch so that to unbreak the buildbots but i'll 
keep an eye on this issue.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D84453

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


[PATCH] D84707: [DFSan][NewPM] Port DataFlowSanitizer to NewPM

2020-07-27 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks marked an inline comment as done.
aeubanks added inline comments.



Comment at: llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h:11
+
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Module.h"

ychen wrote:
> Is Function.h needed?
Nope, removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84707

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


[PATCH] D84707: [DFSan][NewPM] Port DataFlowSanitizer to NewPM

2020-07-27 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 281109.
aeubanks added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84707

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/bindings/go/llvm/InstrumentationBindings.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/test/Instrumentation/DataFlowSanitizer/call.ll

Index: llvm/test/Instrumentation/DataFlowSanitizer/call.ll
===
--- llvm/test/Instrumentation/DataFlowSanitizer/call.ll
+++ llvm/test/Instrumentation/DataFlowSanitizer/call.ll
@@ -1,4 +1,5 @@
 ; RUN: opt < %s -dfsan -S | FileCheck %s
+; RUN: opt < %s -passes=dfsan -S | FileCheck %s
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
Index: llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
===
--- llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
+++ llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
@@ -119,7 +119,7 @@
   initializeHWAddressSanitizerLegacyPassPass(Registry);
   initializeThreadSanitizerLegacyPassPass(Registry);
   initializeModuleSanitizerCoverageLegacyPassPass(Registry);
-  initializeDataFlowSanitizerPass(Registry);
+  initializeDataFlowSanitizerLegacyPassPass(Registry);
 }
 
 /// LLVMInitializeInstrumentation - C binding for
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -46,6 +46,7 @@
 //
 //===--===//
 
+#include "llvm/Transforms/Instrumentation/DataFlowSanitizer.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/DepthFirstIterator.h"
@@ -78,6 +79,7 @@
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/User.h"
 #include "llvm/IR/Value.h"
@@ -292,7 +294,7 @@
   llvm::makeArrayRef(ArgumentAttributes));
 }
 
-class DataFlowSanitizer : public ModulePass {
+class DataFlowSanitizer {
   friend struct DFSanFunction;
   friend class DFSanVisitor;
 
@@ -390,14 +392,12 @@
   void initializeCallbackFunctions(Module );
   void initializeRuntimeFunctions(Module );
 
-public:
-  static char ID;
+  bool init(Module );
 
-  DataFlowSanitizer(const std::vector  =
-std::vector());
+public:
+  DataFlowSanitizer(const std::vector );
 
-  bool doInitialization(Module ) override;
-  bool runOnModule(Module ) override;
+  bool runImpl(Module );
 };
 
 struct DFSanFunction {
@@ -482,19 +482,8 @@
 
 } // end anonymous namespace
 
-char DataFlowSanitizer::ID;
-
-INITIALIZE_PASS(DataFlowSanitizer, "dfsan",
-"DataFlowSanitizer: dynamic data flow analysis.", false, false)
-
-ModulePass *llvm::createDataFlowSanitizerPass(
-const std::vector ) {
-  return new DataFlowSanitizer(ABIListFiles);
-}
-
 DataFlowSanitizer::DataFlowSanitizer(
-const std::vector )
-: ModulePass(ID) {
+const std::vector ) {
   std::vector AllABIListFiles(std::move(ABIListFiles));
   AllABIListFiles.insert(AllABIListFiles.end(), ClABIListFiles.begin(),
  ClABIListFiles.end());
@@ -559,7 +548,7 @@
   ArgumentIndexMapping);
 }
 
-bool DataFlowSanitizer::doInitialization(Module ) {
+bool DataFlowSanitizer::init(Module ) {
   Triple TargetTriple(M.getTargetTriple());
   bool IsX86_64 = TargetTriple.getArch() == Triple::x86_64;
   bool IsMIPS64 = TargetTriple.isMIPS64();
@@ -785,7 +774,9 @@
 DFSanLoadStoreCmpCallbackFnTy);
 }
 
-bool DataFlowSanitizer::runOnModule(Module ) {
+bool DataFlowSanitizer::runImpl(Module ) {
+  init(M);
+
   if (ABIList.isIn(M, "skip"))
 return false;
 
@@ -1817,3 +1808,37 @@
   DFSF.PHIFixups.push_back(std::make_pair(, ShadowPN));
   DFSF.setShadow(, ShadowPN);
 }
+
+class DataFlowSanitizerLegacyPass : public ModulePass {
+private:
+  std::vector ABIListFiles;
+
+public:
+  static char ID;
+
+  DataFlowSanitizerLegacyPass(
+  const std::vector  = std::vector())
+  : ModulePass(ID), ABIListFiles(ABIListFiles) {}
+
+  bool runOnModule(Module ) override {
+return DataFlowSanitizer(ABIListFiles).runImpl(M);
+  }
+};
+
+char 

[PATCH] D82502: [PowerPC] Implement Load VSX Vector and Sign Extend and Zero Extend

2020-07-27 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

Could we also elaborate in the description on how we are utilizing the new load 
instructions for zero extend case but not the sign extend case?




Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:14197
+
+ SDValue LoadOps[] = {LD->getChain(), LD->getBasePtr(), 
DAG.getIntPtrConstant(MemoryType.getScalarSizeInBits(), dl)};
+

Over 80 characters?



Comment at: llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll:5
+; RUN:   FileCheck %s --check-prefix=CHECK-LE
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O0 \
 ; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \

This line actually is for `-O0` and not a BE RUN line. I believe the most up to 
date version of the test includes the LE, BE and O0 line. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82502

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


[PATCH] D84197: [PowerPC][Power10] 128-bit Vector String Isolate instruction definitions and MC Tests

2020-07-27 Thread Amy Kwan via Phabricator via cfe-commits
amyk accepted this revision.
amyk added a comment.
This revision is now accepted and ready to land.

Thanks for recovering the tests. LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84197

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


[PATCH] D82675: [PowerPC] Implement Vector Extract Mask builtins in LLVM/Clang

2020-07-27 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 281107.
amyk added a comment.

- Rebased patch
- Updated patch to remove instruction definitions and MC tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82675

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-vector-mask-ops.ll

Index: llvm/test/CodeGen/PowerPC/p10-vector-mask-ops.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/p10-vector-mask-ops.ll
@@ -0,0 +1,66 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+; This test case aims to test the vector mask manipulation operations
+; on Power10.
+
+declare i32 @llvm.ppc.altivec.vextractbm(<16 x i8>)
+declare i32 @llvm.ppc.altivec.vextracthm(<8 x i16>)
+declare i32 @llvm.ppc.altivec.vextractwm(<4 x i32>)
+declare i32 @llvm.ppc.altivec.vextractdm(<2 x i64>)
+declare i32 @llvm.ppc.altivec.vextractqm(<1 x i128>)
+
+define i32 @test_vextractbm(<16 x i8> %a) {
+; CHECK-LABEL: test_vextractbm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vextractbm r3, v2
+; CHECK-NEXT:blr
+entry:
+  %ext = tail call i32 @llvm.ppc.altivec.vextractbm(<16 x i8> %a)
+  ret i32 %ext
+}
+
+define i32 @test_vextracthm(<8 x i16> %a) {
+; CHECK-LABEL: test_vextracthm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vextracthm r3, v2
+; CHECK-NEXT:blr
+entry:
+  %ext = tail call i32 @llvm.ppc.altivec.vextracthm(<8 x i16> %a)
+  ret i32 %ext
+}
+
+define i32 @test_vextractwm(<4 x i32> %a) {
+; CHECK-LABEL: test_vextractwm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vextractwm r3, v2
+; CHECK-NEXT:blr
+entry:
+  %ext = tail call i32 @llvm.ppc.altivec.vextractwm(<4 x i32> %a)
+  ret i32 %ext
+}
+
+define i32 @test_vextractdm(<2 x i64> %a) {
+; CHECK-LABEL: test_vextractdm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vextractdm r3, v2
+; CHECK-NEXT:blr
+entry:
+  %ext = tail call i32 @llvm.ppc.altivec.vextractdm(<2 x i64> %a)
+  ret i32 %ext
+}
+
+define i32 @test_vextractqm(<1 x i128> %a) {
+; CHECK-LABEL: test_vextractqm:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vextractqm r3, v2
+; CHECK-NEXT:blr
+entry:
+  %ext = tail call i32 @llvm.ppc.altivec.vextractqm(<1 x i128> %a)
+  ret i32 %ext
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -823,19 +823,24 @@
 let Predicates = [IsISA3_1] in {
   def VEXTRACTBM : VXForm_RD5_XO5_RS5<1602, 8, (outs gprc:$rD), (ins vrrc:$vB),
   "vextractbm $rD, $vB", IIC_VecGeneral,
-  []>;
+  [(set i32:$rD,
+  (int_ppc_altivec_vextractbm v16i8:$vB))]>;
   def VEXTRACTHM : VXForm_RD5_XO5_RS5<1602, 9, (outs gprc:$rD), (ins vrrc:$vB),
   "vextracthm $rD, $vB", IIC_VecGeneral,
-  []>;
+  [(set i32:$rD,
+  (int_ppc_altivec_vextracthm v8i16:$vB))]>;
   def VEXTRACTWM : VXForm_RD5_XO5_RS5<1602, 10, (outs gprc:$rD), (ins vrrc:$vB),
   "vextractwm $rD, $vB", IIC_VecGeneral,
-  []>;
+  [(set i32:$rD,
+  (int_ppc_altivec_vextractwm v4i32:$vB))]>;
   def VEXTRACTDM : VXForm_RD5_XO5_RS5<1602, 11, (outs gprc:$rD), (ins vrrc:$vB),
   "vextractdm $rD, $vB", IIC_VecGeneral,
-  []>;
+  [(set i32:$rD,
+  (int_ppc_altivec_vextractdm v2i64:$vB))]>;
   def VEXTRACTQM : VXForm_RD5_XO5_RS5<1602, 12, (outs gprc:$rD), (ins vrrc:$vB),
   "vextractqm $rD, $vB", IIC_VecGeneral,
-  []>;
+  [(set i32:$rD,
+  (int_ppc_altivec_vextractqm v1i128:$vB))]>;
   def VEXPANDBM : VXForm_RD5_XO5_RS5<1602, 0, (outs vrrc:$vD), (ins vrrc:$vB),
  "vexpandbm $vD, $vB", IIC_VecGeneral,

[PATCH] D80858: [CUDA][HIP] Support accessing static device variable in host code

2020-07-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D80858#2177159 , @tra wrote:

> It's a good point. Perhaps this is one of the cases where we should *not* 
> follow nvcc.
>  We can't have our cake (preserve static behavior) and eat it (treat it as 
> non-static in case something on the host side may decide to use an API which 
> uses symbol names). Something's got to give. While we could make it work in 
> some cases, I don't think we can make it work consistently.
>  I think it would be reasonable to restrict APIs that access symbols by name 
> to be applicable to visible symbols only.


Agree, we only need to support accessing static device var by shadow var 
(runtime API), which is sufficient for most apps.


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

https://reviews.llvm.org/D80858



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


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-07-27 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:2435-2437
+* ``__builtin_memcpy_overloaded(QUAL void *dst, QUAL const void *src, size_t 
byte_size, size_t byte_element_size = )``
+* ``__builtin_memmove_overloaded(QUAL void *dst, QUAL const void *src, size_t 
byte_size, size_t byte_element_size = )``
+* ``__builtin_memset_overloaded(QUAL void *dst, unsigned char val, size_t 
byte_size, size_t byte_element_size = )``

What happens if `byte_element_size` does not divide `byte_size`?



Comment at: clang/docs/LanguageExtensions.rst:2435-2437
+* ``__builtin_memcpy_overloaded(QUAL void *dst, QUAL const void *src, size_t 
byte_size, size_t byte_element_size = )``
+* ``__builtin_memmove_overloaded(QUAL void *dst, QUAL const void *src, size_t 
byte_size, size_t byte_element_size = )``
+* ``__builtin_memset_overloaded(QUAL void *dst, unsigned char val, size_t 
byte_size, size_t byte_element_size = )``

rsmith wrote:
> What happens if `byte_element_size` does not divide `byte_size`?
Did you really mean `void*` here? I've been pretty confused by some of the 
stuff happening below that seems to depend on the actual type of the passed 
pointer, which would make more sense if you meant `QUAL T *` here rather than 
`QUAL void*`. Do the builtins do different things for different argument 
pointee types or not?



Comment at: clang/docs/LanguageExtensions.rst:2444-2445
+parameter can be provided to specify element access size in bytes. When the
+element size is provided, the memory will be accessed with a sequence of
+operations of size equal to or a multiple of the pointer's element size. The
+order of operations is unspecified, and each access has unordered atomic

"the pointer's element size" -- do you mean "the provided element size"?

Does the element size need to be a compile-time constant? (Presumably, but you 
don't say so.)



Comment at: clang/docs/LanguageExtensions.rst:2446-2447
+operations of size equal to or a multiple of the pointer's element size. The
+order of operations is unspecified, and each access has unordered atomic
+semantics. This means that reads and writes do not tear at the individual
+element level, and they each occur exactly once, but the order in which they

Presumably this means that it's an error if we don't provide lock-free atomic 
access for that size. Would be worth saying so.



Comment at: clang/docs/LanguageExtensions.rst:2450-2451
+occur (and in which they are observable) can only be guaranteed using
+appropriate fences around the function call. Atomic memory operations must be 
to
+memory locations which are aligned to no less than the element size.
+

What happens if they're not? Is it UB, or is it just not guaranteed to be 
atomic?



Comment at: clang/docs/LanguageExtensions.rst:2456
+
+These can be used as building blocks for different facitilies:
+

*facilities



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8937-8938
+  "(%0 is volatile)">;
+def err_elsz_on_sizeless : Error<
+  "element size must not be on a sizeless type (%0 invalid)">;
+def err_elsz_must_be_lock_free : Error<

Given the new documentation, I would expect you don't need this any more.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8941-8943
+def err_atomic_builtin_ext_size_mismatches_el : Error<
+  "number of bytes to copy must be a multiple of pointer element size, "
+  "got %0 bytes to copy with element size %1 for %2">;

Presumably the number of bytes need not be a compile-time constant? It's a bit 
weird to produce an error rather than a warning on a case that would be valid 
but (perhaps?) UB if the argument were non-constant.



Comment at: clang/lib/AST/ExprConstant.cpp:8793
+BuiltinOp == Builtin::BI__builtin_memmove_overloaded ||
 BuiltinOp == Builtin::BI__builtin_wmemmove;
 

jfb wrote:
> If we end up making alignment a runtime constraint, then I'll need to check 
> it in consteval. Otherwise I don't think we need to check anything since Sema 
> ought to have done all the required checks already.
I don't see how you can check the alignment at compile time given a `void*` 
argument.

We presumably need to check that the element size (if given) divides the total 
size, assuming the outcome is UB if not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79279



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


[PATCH] D80925: Fix compiler crash when an expression parsed in the tentative parsing and must be claimed in the another evaluation context.

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

In D80925#2177446 , @rsmith wrote:

> I'm going to try to fix this a different way, by fixing the bad case in 
> `Sema::ClassifyName` instead.


Done in llvmorg-12-init-1234-g23d6525cbdc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80925



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


[clang] 23d6525 - Don't form a 'context-independent expr' reference to a member during

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

Author: Richard Smith
Date: 2020-07-27T19:38:22-07:00
New Revision: 23d6525cbdc9de7cbfe7640d1e9e4f25a0c5dd85

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

LOG: Don't form a 'context-independent expr' reference to a member during
name annotation.

Instead, defer forming the member access expression or DeclRefExpr until
we build the use of ClassifyName's result. Just build an
UnresolvedLookupExpr to track the LookupResult until we're ready to
consume it.

This also reverts commit 2f7269b6773de2750f9cd1417ef5f21cd6cf7a91 (other
than its testcase). That change was an attempted workaround for the same
problem.

Added: 


Modified: 
clang/include/clang/Basic/TokenKinds.def
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParseTentative.cpp
clang/lib/Parse/Parser.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExprMember.cpp
clang/test/SemaTemplate/member-access-expr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 2b353269ed52d..daaa54c3db7c2 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -757,10 +757,10 @@ ANNOTATION(non_type_undeclared) // annotation for an 
undeclared identifier that
 // was assumed to be an ADL-only function name
 ANNOTATION(non_type_dependent)  // annotation for an assumed non-type member of
 // a dependent base class
-ANNOTATION(primary_expr) // annotation for a primary expression
-ANNOTATION(
-uneval_primary_expr) // annotation for a primary expression which should be
- // transformed to potentially evaluated
+ANNOTATION(overload_set) // annotation for an unresolved overload set
+ANNOTATION(primary_expr) // annotation for a primary expression, used when
+ // tentatively parsing a lambda init-capture or ObjC
+ // message send
 ANNOTATION(decltype) // annotation for a decltype expression,
  // e.g., "decltype(foo.bar())"
 

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 0721720f79085..63e2d0d17fca2 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2117,9 +2117,11 @@ class Sema final {
 /// resolved. ActOnNameClassifiedAsDependentNonType should be called to
 /// convert the result to an expression.
 NC_DependentNonType,
-/// The name was classified as a non-type, and an expression representing
-/// that name has been formed.
-NC_ContextIndependentExpr,
+/// The name was classified as an overload set, and an expression
+/// representing that overload set has been formed.
+/// ActOnNameClassifiedAsOverloadSet should be called to form a suitable
+/// expression referencing the overload set.
+NC_OverloadSet,
 /// The name was classified as a template whose specializations are types.
 NC_TypeTemplate,
 /// The name was classified as a variable template name.
@@ -2156,8 +2158,8 @@ class Sema final {
   return NameClassification(NC_Unknown);
 }
 
-static NameClassification ContextIndependentExpr(ExprResult E) {
-  NameClassification Result(NC_ContextIndependentExpr);
+static NameClassification OverloadSet(ExprResult E) {
+  NameClassification Result(NC_OverloadSet);
   Result.Expr = E;
   return Result;
 }
@@ -2209,7 +2211,7 @@ class Sema final {
 NameClassificationKind getKind() const { return Kind; }
 
 ExprResult getExpression() const {
-  assert(Kind == NC_ContextIndependentExpr);
+  assert(Kind == NC_OverloadSet);
   return Expr;
 }
 
@@ -2289,6 +2291,8 @@ class Sema final {
   NamedDecl *Found,
   SourceLocation NameLoc,
   const Token );
+  /// Act on the result of classifying a name as an overload set.
+  ExprResult ActOnNameClassifiedAsOverloadSet(Scope *S, Expr *OverloadSet);
 
   /// Describes the detailed kind of a template name. Used in diagnostics.
   enum class TemplateNameKindForDiagnostics {
@@ -4846,11 +4850,10 @@ class Sema final {
   Expr *baseObjectExpr = nullptr,
   SourceLocation opLoc = SourceLocation());
 
-  ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec ,
- SourceLocation TemplateKWLoc,
- LookupResult ,
-const TemplateArgumentListInfo *TemplateArgs,
- const Scope 

[PATCH] D84422: [OpenMP] Fix `present` for exit from `omp target data`

2020-07-27 Thread George Rokos via Phabricator via cfe-commits
grokos added a comment.

This looks much better now. I don't have any other comments. Since this patch 
is now essentially a clang-only patch, I'll let @ABataev accept it or post 
comments.


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

https://reviews.llvm.org/D84422



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


[PATCH] D84405: CodeGen: Improve generated IR for __builtin_mul_overflow(uint, uint, int)

2020-07-27 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

Here is the assembly comparison for the 64-bit test I added between gcc and 
clang trunk + patch: https://reviews.llvm.org/P8227


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84405



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


[PATCH] D84405: CodeGen: Improve generated IR for __builtin_mul_overflow(uint, uint, int)

2020-07-27 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

This is the test driver I used for testing.  I compared the clang 11 + this 
patch with gcc 10 and saw no differences: 
https://gist.github.com/tstellar/80dae2ab8a18d810b10b8e42777f4fe4


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84405



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


[PATCH] D84405: CodeGen: Improve generated IR for __builtin_mul_overflow(uint, uint, int)

2020-07-27 Thread Tom Stellard via Phabricator via cfe-commits
tstellar updated this revision to Diff 281092.
tstellar added a comment.
Herald added a subscriber: mstorsjo.

Add 64-bit test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84405

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-overflow.c

Index: clang/test/CodeGen/builtins-overflow.c
===
--- clang/test/CodeGen/builtins-overflow.c
+++ clang/test/CodeGen/builtins-overflow.c
@@ -1,9 +1,9 @@
 // Test CodeGen for Security Check Overflow Builtins.
 // rdar://13421498
 
-// RUN: %clang_cc1 -triple "i686-unknown-unknown"   -emit-llvm -x c %s -o - | FileCheck %s
-// RUN: %clang_cc1 -triple "x86_64-unknown-unknown" -emit-llvm -x c %s -o - | FileCheck %s
-// RUN: %clang_cc1 -triple "x86_64-mingw32" -emit-llvm -x c %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple "i686-unknown-unknown"   -emit-llvm -x c %s -o - | FileCheck -DLONG_TYPE=i32 -DLONG_MAX=2147483647 %s
+// RUN: %clang_cc1 -triple "x86_64-unknown-unknown" -emit-llvm -x c %s -o - | FileCheck -DLONG_TYPE=i64 -DLONG_MAX=9223372036854775807 %s
+// RUN: %clang_cc1 -triple "x86_64-mingw32" -emit-llvm -x c %s -o - | FileCheck -DLONG_TYPE=i32 -DLONG_MAX=2147483647 %s
 
 extern unsigned UnsignedErrorCode;
 extern unsigned long UnsignedLongErrorCode;
@@ -111,6 +111,36 @@
   return r;
 }
 
+int test_mul_overflow_uint_uint_int(unsigned x, unsigned y) {
+  // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_uint_uint_int
+  // CHECK: [[S:%.+]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %{{.+}}, i32 %{{.+}})
+  // CHECK-DAG: [[Q:%.+]] = extractvalue { i32, i1 } [[S]], 0
+  // CHECK-DAG: [[C:%.+]] = extractvalue { i32, i1 } [[S]], 1
+  // CHECK: [[C1:%.+]] = icmp ugt i32 [[Q]], 2147483647
+  // CHECK: [[C2:%.+]] = or i1 [[C]], [[C1]]
+  // CHECK: store i32 [[Q]], i32*
+  // CHECK: br i1 [[C2]]
+  int r;
+  if (__builtin_mul_overflow(x, y, ))
+overflowed();
+  return r;
+}
+
+long test_mul_overflow_ulong_ulong_long(unsigned long x, unsigned long y) {
+  // CHECK-LABEL: @test_mul_overflow_ulong_ulong_long
+  // CHECK: [[S:%.+]] =  call { [[LONG_TYPE]], i1 } @llvm.umul.with.overflow.[[LONG_TYPE]]([[LONG_TYPE]] %{{.+}}, [[LONG_TYPE]] %{{.+}})
+  // CHECK-DAG: [[Q:%.+]] = extractvalue { [[LONG_TYPE]], i1 } [[S]], 0
+  // CHECK-DAG: [[C:%.+]] = extractvalue { [[LONG_TYPE]], i1 } [[S]], 1
+  // CHECK: [[C1:%.+]] = icmp ugt [[LONG_TYPE]] [[Q]], [[LONG_MAX]]
+  // CHECK: [[C2:%.+]] = or i1 [[C]], [[C1]]
+  // LONG64: store [[LONG_TYPE]] [[Q]], [[LONG_TYPE]]*
+  // LONG64: br i1 [[C2]]
+  long r;
+  if (__builtin_mul_overflow(x, y, ))
+overflowed();
+  return r;
+}
+
 int test_mul_overflow_int_int_int(int x, int y) {
   // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_int_int_int
   // CHECK-NOT: ext
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -1408,6 +1408,47 @@
   return RValue::get(BufAddr.getPointer());
 }
 
+static bool isSpecialUnsignedMultiplySignedResult(
+unsigned BuiltinID, WidthAndSignedness Op1Info, WidthAndSignedness Op2Info,
+WidthAndSignedness ResultInfo) {
+  return BuiltinID == Builtin::BI__builtin_mul_overflow &&
+ Op1Info.Width == Op2Info.Width && Op2Info.Width == ResultInfo.Width &&
+ !Op1Info.Signed && !Op2Info.Signed && ResultInfo.Signed;
+}
+
+static RValue EmitCheckedUnsignedMultiplySignedResult(
+CodeGenFunction , const clang::Expr *Op1, WidthAndSignedness Op1Info,
+const clang::Expr *Op2, WidthAndSignedness Op2Info,
+const clang::Expr *ResultArg, QualType ResultQTy,
+WidthAndSignedness ResultInfo) {
+  assert(isSpecialUnsignedMultiplySignedResult(
+ Builtin::BI__builtin_mul_overflow, Op1Info, Op2Info, ResultInfo) &&
+ "Cannot specialize this multiply");
+
+  llvm::Value *V1 = CGF.EmitScalarExpr(Op1);
+  llvm::Value *V2 = CGF.EmitScalarExpr(Op2);
+
+  llvm::Value *HasOverflow;
+  llvm::Value *Result = EmitOverflowIntrinsic(
+  CGF, llvm::Intrinsic::umul_with_overflow, V1, V2, HasOverflow);
+
+  // The intrinsic call will detect overflow when the value is > UINT_MAX,
+  // however, since the original builtin had a signed result, we need to report
+  // an overflow when the result is greater than INT_MAX.
+  auto IntMax = llvm::APInt::getSignedMaxValue(ResultInfo.Width);
+  llvm::Value *IntMaxValue = llvm::ConstantInt::get(Result->getType(), IntMax);
+
+  llvm::Value *IntMaxOverflow = CGF.Builder.CreateICmpUGT(Result, IntMaxValue);
+  HasOverflow = CGF.Builder.CreateOr(HasOverflow, IntMaxOverflow);
+
+  bool isVolatile =
+  ResultArg->getType()->getPointeeType().isVolatileQualified();
+  Address ResultPtr = CGF.EmitPointerWithAlignment(ResultArg);
+  CGF.Builder.CreateStore(CGF.EmitToMemory(Result, ResultQTy), ResultPtr,
+

[PATCH] D80925: Fix compiler crash when an expression parsed in the tentative parsing and must be claimed in the another evaluation context.

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

This is at best only a partial fix. `Sema::NC_ContextIndependentExpr` is 
supposed to be used (unsurprisingly) only if we form a context-independent 
annotation, but here we're forming a context-dependent expression that depends 
on whether it appears in an unevaluated context. I think the better approach 
would be to fix the case in `Sema::ClassifyName` that violates 
context-independence instead (there's a FIXME there for this issue).

This fix changed us from producing a bad AST if the member reference was not 
supposed to be evaluated, to producing a bad AST if the member reference 
**was** supposed to be annotated and is type-dependent -- we now crash in 
CodeGen on this invalid code:

  struct C { void g(); };
  template struct A {
T x;
static void f() {
  (x.g());
}
  };
  void h() { A::f(); }

... because we now incorrectly form an unevaluated `DeclRefExpr` for `x` when 
disambiguating between a cast and a parenthesized expression (and we don't fix 
it due to the added "type-dependent" check).

I'm going to try to fix this a different way, by fixing the bad case in 
`Sema::ClassifyName` instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80925



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


[PATCH] D84707: [DFSan][NewPM] Port DataFlowSanitizer to NewPM

2020-07-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen accepted this revision.
ychen added a comment.
This revision is now accepted and ready to land.

LGTM with two nits. Please wait one day or two in case other reviewers want to 
have a look.




Comment at: llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h:8
+//===--===//
+#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_DATAFLOWSANITIZERPASS_H
+#define LLVM_TRANSFORMS_INSTRUMENTATION_DATAFLOWSANITIZERPASS_H

LLVM_TRANSFORMS_INSTRUMENTATION_DATAFLOWSANITIZER_H



Comment at: llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h:11
+
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Module.h"

Is Function.h needed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84707



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


[PATCH] D84713: [DominatorTree] Simplify ChildrenGetter.

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

In D84713#2177408 , @kuhar wrote:

> LGTM.
>
> One tiny nit: the function name `ChildrenGet` sounds kind of backwards to me, 
> but it seems like the other direction is already taken.


If there are both "ChildrenGet" and "GetChildren" in the same scope, seems like 
we probably should address that rather than having one awkwardly named & the 
ensuing lack of clarity.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84713



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


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-07-27 Thread JF Bastien via Phabricator via cfe-commits
jfb marked an inline comment as done.
jfb added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:8793
+BuiltinOp == Builtin::BI__builtin_memmove_overloaded ||
 BuiltinOp == Builtin::BI__builtin_wmemmove;
 

If we end up making alignment a runtime constraint, then I'll need to check it 
in consteval. Otherwise I don't think we need to check anything since Sema 
ought to have done all the required checks already.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79279



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


[PATCH] D84713: [DominatorTree] Simplify ChildrenGetter.

2020-07-27 Thread Jakub Kuderski via Phabricator via cfe-commits
kuhar accepted this revision.
kuhar added a comment.
This revision is now accepted and ready to land.

LGTM.

One tiny nit: the function name `ChildrenGet` sounds kind of backwards to me, 
but it seems like the other direction is already taken.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84713



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


[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-07-27 Thread JF Bastien via Phabricator via cfe-commits
jfb added a subscriber: dneilson.
jfb added a comment.

I've addressed @rsmith @rjmccall suggestions (unless noted), thanks!
An open question: as of 6e4aa1e48138182685431c76184dfc36e620aea2 @dneilson 
added an assertion on `CreateElementUnorderedAtomicMemCpy` to check that the 
pointer arguments have alignments of at least the element size. That makes 
sense when the IR is only ever built internally to LLVM, but now that I'm 
adding a builtin it's more of a dynamic property. Should I also force this in 
the frontend (understanding that alignment isn't always well known at compile 
time), or should simply assume that the alignment is correct because it's a 
dynamic property?

I left some FIXMEs in the CodeGen test for this.




Comment at: clang/docs/LanguageExtensions.rst:2439-2440
 
+Clang provides versions of the following functions which are overloaded based 
on
+the pointer parameter types:
+

rsmith wrote:
> This is missing some important details:
> 
> - What does the size parameter mean? Is it number of bytes or number of 
> elements? If it's number of bytes, what happens if it's not a multiple of the 
> element size, particularly in the `_Atomic` case?
> - What does the value parameter to `memset` mean? Is it splatted to the 
> element width? Does it specify a complete element value?
> - For `_Atomic`, what memory order is used?
> - For `volatile`, what access size / type is used? Do we want to make any 
> promises?
> - Are the loads and stores typed or untyped? (In particular, do we annotate 
> with TBAA metadata?)
> - Do we guarantee to copy the object representation or only the value 
> representation? (Do we preserve the values of padding bits in the source, and 
> initialize padding bits in the destination?)
> 
> You should also document whether constant evaluation of these builtins is 
> supported.
Most of these are answered in the update.

Some of the issue is that the current documentation is silent on these points 
already, by saying "same as C's `mem*` function". I'm relying on that approach 
here as well.

Size is bytes.

`memset` value is an `unsigned char`.

Memory order is unordered, and accesses themselves are done in indeterminate 
order.

For `volatile`, it falls out of the new wording that we don't provide access 
size guarantees. We'd need to nail down IR better to do so, and I don't think 
it's the salient property (though as discussed above, it might be useful, and 
the `element_size` parameter make it easy to do so).

Same on TBAA, no mention because "same as C" (no TBAA annotations).

Same on copying bits as-is.

Good point on constant evaluation. I added support. Note that we don't have 
`memset` constant evaluation, so I didn't support it. Seems easy, but ought to 
be a separate patch.



Comment at: clang/docs/LanguageExtensions.rst:2446-2448
+These overloads support destinations and sources which are a mix of
+``volatile``, ``_Atomic``, ``restrict``, ``__unaligned``, and use non-default
+address spaces. These can be used as building blocks for different facitilies:

rsmith wrote:
> Mixing those qualifiers doesn't seem like it will work in many cases: we 
> don't allow mixing `volatile` and `_Atomic` (though I'm not sure why; LLVM 
> supports volatile atomic operations), and presumably we shouldn't allow 
> mixing `__unaligned` and `_Atomic` (although I don't see any tests for that, 
> and maybe we should just outright disallow combining `_Atomic` with 
> `__unaligned` in general).
`volatile` and `_Atomic` ought to work...

For this code I didn't make it work (even if it might be useful), because we'd 
need IR support for it.

On mixing `_Atomic __unaligned`: I left a FIXME because I'm not 100% sure, 
given the alignment discussion on atomic in general. Let's see where we settle: 
if we make it a pure runtime property then `__unaligned` ought to be fine 
because it's a constraint violation if the actual pointer is truly unaligned.



Comment at: clang/include/clang/Basic/Builtins.def:471
 
 // Random GCC builtins
 BUILTIN(__builtin_constant_p, "i.", "nctu")

rsmith wrote:
> Are these really GCC builtins?
Oops, I didn't see that comment, was just copying `__builtin_memcpy_inline`. 
I'll move it too.



Comment at: clang/lib/Sema/SemaChecking.cpp:1277-1278
 CallExpr *Call) {
-  if (Call->getNumArgs() != 1) {
-S.Diag(Call->getBeginLoc(), diag::err_opencl_builtin_to_addr_arg_num)
-<< Call->getDirectCallee() << Call->getSourceRange();
+  if (checkArgCount(S, Call, 1))
 return true;
 

rsmith wrote:
> There are a bunch of places in this file that do manual argument count 
> checking and could use `checkArgCount` instead (search for 
> `err_typecheck_call_too_` to find them). If you want to clean this up, please 
> do so in a separate change.
D84666



Comment at: 

[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-07-27 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 281087.
jfb marked 15 inline comments as done.
jfb added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79279

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-overloaded-memfns.c
  clang/test/CodeGenObjC/builtin-memfns.m
  clang/test/Sema/builtin-overloaded-memfns.cpp

Index: clang/test/Sema/builtin-overloaded-memfns.cpp
===
--- /dev/null
+++ clang/test/Sema/builtin-overloaded-memfns.cpp
@@ -0,0 +1,245 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=arm64-unknown-unknown -fms-extensions -DCPY=1
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=arm64-unknown-unknown -fms-extensions -DCPY=0
+
+// Test memcpy and memmove with the same code, since they're basically the same constraints.
+#if CPY
+#define MEM(...) __builtin_memcpy_overloaded(__VA_ARGS__)
+#else
+#define MEM(...) __builtin_memmove_overloaded(__VA_ARGS__)
+#endif
+
+#define NULL (void *)0
+#define nullptr __nullptr
+using size_t = __SIZE_TYPE__;
+using sizeless_t = __SVInt8_t;
+using float4 = float __attribute__((ext_vector_type(4)));
+struct Intish {
+  int i;
+};
+struct NotLockFree {
+  char buf[512];
+};
+struct TrivialCpy {
+  char buf[8];
+  TrivialCpy();
+  TrivialCpy(const TrivialCpy &) = default;
+};
+struct NotTrivialCpy {
+  char buf[8];
+  NotTrivialCpy();
+  NotTrivialCpy(const NotTrivialCpy &);
+};
+
+void arg_count() {
+  MEM();  // expected-error {{too few arguments to function call, expected 3, have 0}}
+  MEM(0); // expected-error {{too few arguments to function call, expected 3, have 1}}
+  MEM(0, 0);  // expected-error {{too few arguments to function call, expected 3, have 2}}
+  MEM(0, 0, 0, 0, 0); // expected-error {{too many arguments to function call, expected 4, have 5}}
+  __builtin_memset_overloaded();  // expected-error {{too few arguments to function call, expected 3, have 0}}
+  __builtin_memset_overloaded(0); // expected-error {{too few arguments to function call, expected 3, have 1}}
+  __builtin_memset_overloaded(0, 0);  // expected-error {{too few arguments to function call, expected 3, have 2}}
+  __builtin_memset_overloaded(0, 0, 0, 0, 0); // expected-error {{too many arguments to function call, expected 4, have 5}}
+}
+
+void null(char *dst, const char *src, size_t size) {
+  MEM(0, src, 0);  // expected-error{{cannot initialize a parameter of type 'void *' with an rvalue of type 'int'}}
+  MEM(0, src, size);   // expected-error{{cannot initialize a parameter of type 'void *' with an rvalue of type 'int'}}
+  MEM(dst, 0, 0);  // expected-error{{cannot initialize a parameter of type 'void *' with an rvalue of type 'int'}}
+  MEM(dst, 0, size);   // expected-error{{cannot initialize a parameter of type 'void *' with an rvalue of type 'int'}}
+  __builtin_memset_overloaded(0, 0, 0);// expected-error{{cannot initialize a parameter of type 'void *' with an rvalue of type 'int'}}
+  __builtin_memset_overloaded(0, 0, size); // expected-error{{cannot initialize a parameter of type 'void *' with an rvalue of type 'int'}}
+  MEM(dst, 0, 42); // expected-error{{cannot initialize a parameter of type 'void *' with an rvalue of type 'int'}}
+  MEM(dst, 0, 42); // expected-error{{cannot initialize a parameter of type 'void *' with an rvalue of type 'int'}}
+  MEM(dst, NULL, 42);  // expected-warning {{null passed to a callee that requires a non-null argument}}
+  MEM(dst, nullptr, 42);   // expected-error{{cannot initialize a parameter of type 'void *' with an rvalue of type 'nullptr_t'}}
+  MEM(0, src, 42); // expected-error{{cannot initialize a parameter of type 'void *' with an rvalue of type 'int'}}
+  MEM(NULL, src, 42);  // expected-warning {{null passed to a callee that requires a non-null argument}}
+  MEM(nullptr, src, 42);   // expected-error{{cannot initialize a parameter of type 'void *' with an rvalue of type 'nullptr_t'}}
+  __builtin_memset_overloaded(0, 0, 42);   // expected-error{{cannot initialize a parameter of type 'void *' with an rvalue of type 'int'}}
+  __builtin_memset_overloaded(NULL, 0, 42);// expected-warning {{null 

[PATCH] D84691: [CMake] Move find_package(ZLIB) to LLVMConfig

2020-07-27 Thread Stephen Neuendorffer via Phabricator via cfe-commits
stephenneuendorffer added a comment.

Perfect!  Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84691



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


[clang] 64d99cc - [CMake] Move find_package(ZLIB) to LLVMConfig

2020-07-27 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2020-07-27T17:13:55-07:00
New Revision: 64d99cc6abed78c00a2a7863b02ce54911a5264f

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

LOG: [CMake] Move find_package(ZLIB) to LLVMConfig

This way, downstream projects don't have to invoke find_package(ZLIB)
reducing the amount of boilerplate.

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

Added: 


Modified: 
clang/CMakeLists.txt
lld/CMakeLists.txt
lldb/cmake/modules/LLDBStandalone.cmake
llvm/cmake/modules/LLVMConfig.cmake.in
mlir/examples/standalone/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 1c4c22b1aaad..1a6a20a271f3 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -114,10 +114,6 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
   option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF)
   option(LLVM_ENABLE_LIBXML2 "Use libxml2 if available." ON)
 
-  if(LLVM_ENABLE_ZLIB)
-find_package(ZLIB)
-  endif()
-
   include(AddLLVM)
   include(TableGen)
   include(HandleLLVMOptions)

diff  --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index bcfc2c6270b3..e9bd1bd29c5c 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -51,10 +51,6 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} 
NO_DEFAULT_PATH)
 
-  if(LLVM_ENABLE_ZLIB)
-find_package(ZLIB)
-  endif()
-
   include(AddLLVM)
   include(TableGen)
   include(HandleLLVMOptions)

diff  --git a/lldb/cmake/modules/LLDBStandalone.cmake 
b/lldb/cmake/modules/LLDBStandalone.cmake
index edd2b34ec865..94781c358374 100644
--- a/lldb/cmake/modules/LLDBStandalone.cmake
+++ b/lldb/cmake/modules/LLDBStandalone.cmake
@@ -74,10 +74,6 @@ endif()
 # CMake modules to be in that directory as well.
 list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
-if(LLVM_ENABLE_ZLIB)
-  find_package(ZLIB)
-endif()
-
 include(AddLLVM)
 include(TableGen)
 include(HandleLLVMOptions)

diff  --git a/llvm/cmake/modules/LLVMConfig.cmake.in 
b/llvm/cmake/modules/LLVMConfig.cmake.in
index e729a839f614..17cc5eacc57b 100644
--- a/llvm/cmake/modules/LLVMConfig.cmake.in
+++ b/llvm/cmake/modules/LLVMConfig.cmake.in
@@ -50,6 +50,9 @@ set(LLVM_ENABLE_THREADS @LLVM_ENABLE_THREADS@)
 set(LLVM_ENABLE_UNWIND_TABLES @LLVM_ENABLE_UNWIND_TABLES@)
 
 set(LLVM_ENABLE_ZLIB @LLVM_ENABLE_ZLIB@)
+if(LLVM_ENABLE_ZLIB)
+  find_package(ZLIB)
+endif()
 
 set(LLVM_LIBXML2_ENABLED @LLVM_LIBXML2_ENABLED@)
 

diff  --git a/mlir/examples/standalone/CMakeLists.txt 
b/mlir/examples/standalone/CMakeLists.txt
index 59d3c693546f..3f46dda4e4f6 100644
--- a/mlir/examples/standalone/CMakeLists.txt
+++ b/mlir/examples/standalone/CMakeLists.txt
@@ -29,10 +29,6 @@ set(MLIR_BINARY_DIR ${CMAKE_BINARY_DIR})
 list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
 list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
 
-if(LLVM_ENABLE_ZLIB)
-  find_package(ZLIB)
-endif()
-
 include(TableGen)
 include(AddLLVM)
 include(AddMLIR)



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


[PATCH] D84691: [CMake] Move find_package(ZLIB) to LLVMConfig

2020-07-27 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG64d99cc6abed: [CMake] Move find_package(ZLIB) to LLVMConfig 
(authored by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84691

Files:
  clang/CMakeLists.txt
  lld/CMakeLists.txt
  lldb/cmake/modules/LLDBStandalone.cmake
  llvm/cmake/modules/LLVMConfig.cmake.in
  mlir/examples/standalone/CMakeLists.txt


Index: mlir/examples/standalone/CMakeLists.txt
===
--- mlir/examples/standalone/CMakeLists.txt
+++ mlir/examples/standalone/CMakeLists.txt
@@ -29,10 +29,6 @@
 list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
 list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
 
-if(LLVM_ENABLE_ZLIB)
-  find_package(ZLIB)
-endif()
-
 include(TableGen)
 include(AddLLVM)
 include(AddMLIR)
Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -50,6 +50,9 @@
 set(LLVM_ENABLE_UNWIND_TABLES @LLVM_ENABLE_UNWIND_TABLES@)
 
 set(LLVM_ENABLE_ZLIB @LLVM_ENABLE_ZLIB@)
+if(LLVM_ENABLE_ZLIB)
+  find_package(ZLIB)
+endif()
 
 set(LLVM_LIBXML2_ENABLED @LLVM_LIBXML2_ENABLED@)
 
Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -74,10 +74,6 @@
 # CMake modules to be in that directory as well.
 list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
-if(LLVM_ENABLE_ZLIB)
-  find_package(ZLIB)
-endif()
-
 include(AddLLVM)
 include(TableGen)
 include(HandleLLVMOptions)
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -51,10 +51,6 @@
   set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} 
NO_DEFAULT_PATH)
 
-  if(LLVM_ENABLE_ZLIB)
-find_package(ZLIB)
-  endif()
-
   include(AddLLVM)
   include(TableGen)
   include(HandleLLVMOptions)
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -114,10 +114,6 @@
   option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF)
   option(LLVM_ENABLE_LIBXML2 "Use libxml2 if available." ON)
 
-  if(LLVM_ENABLE_ZLIB)
-find_package(ZLIB)
-  endif()
-
   include(AddLLVM)
   include(TableGen)
   include(HandleLLVMOptions)


Index: mlir/examples/standalone/CMakeLists.txt
===
--- mlir/examples/standalone/CMakeLists.txt
+++ mlir/examples/standalone/CMakeLists.txt
@@ -29,10 +29,6 @@
 list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
 list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
 
-if(LLVM_ENABLE_ZLIB)
-  find_package(ZLIB)
-endif()
-
 include(TableGen)
 include(AddLLVM)
 include(AddMLIR)
Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -50,6 +50,9 @@
 set(LLVM_ENABLE_UNWIND_TABLES @LLVM_ENABLE_UNWIND_TABLES@)
 
 set(LLVM_ENABLE_ZLIB @LLVM_ENABLE_ZLIB@)
+if(LLVM_ENABLE_ZLIB)
+  find_package(ZLIB)
+endif()
 
 set(LLVM_LIBXML2_ENABLED @LLVM_LIBXML2_ENABLED@)
 
Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -74,10 +74,6 @@
 # CMake modules to be in that directory as well.
 list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
-if(LLVM_ENABLE_ZLIB)
-  find_package(ZLIB)
-endif()
-
 include(AddLLVM)
 include(TableGen)
 include(HandleLLVMOptions)
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -51,10 +51,6 @@
   set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH)
 
-  if(LLVM_ENABLE_ZLIB)
-find_package(ZLIB)
-  endif()
-
   include(AddLLVM)
   include(TableGen)
   include(HandleLLVMOptions)
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -114,10 +114,6 @@
   option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF)
   option(LLVM_ENABLE_LIBXML2 "Use libxml2 if available." ON)
 
-  if(LLVM_ENABLE_ZLIB)
-find_package(ZLIB)
-  endif()
-
   include(AddLLVM)
   include(TableGen)
   include(HandleLLVMOptions)
___
cfe-commits mailing list

[PATCH] D84691: [CMake] Move find_package(ZLIB) to LLVMConfig

2020-07-27 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84691



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


[PATCH] D84713: [DominatorTree] Simplify ChildrenGetter.

2020-07-27 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea created this revision.
asbirlea added reviewers: kuhar, dblaikie.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

Simplify ChildrenGetter to a simple wrapper around a GraphDiff call.
GraphDiff already handles nullptr in children, so the special casing in
clang can also be removed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84713

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h

Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -103,31 +103,13 @@
 // in progress, we need this information to continue it.
   }
 
-  template  struct ChildrenGetter {
-using ResultTy = SmallVector;
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto RChildren = reverse(children(N));
-  return ResultTy(RChildren.begin(), RChildren.end());
-}
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto IChildren = inverse_children(N);
-  return ResultTy(IChildren.begin(), IChildren.end());
-}
-
-using Tag = std::integral_constant;
-
-// The function below is the core part of the batch updater. It allows the
-// Depth Based Search algorithm to perform incremental updates in lockstep
-// with updates to the CFG. We emulated lockstep CFG updates by getting its
-// next snapshots by reverse-applying future updates.
-static ResultTy Get(NodePtr N, BatchUpdatePtr BUI) {
-  if (!BUI)
-return Get(N, Tag());
+  template 
+  static SmallVector ChildrenGet(NodePtr N, BatchUpdatePtr BUI) {
+if (BUI)
   return BUI->PreViewCFG.template getChildren(N);
-}
-  };
+GraphDiffT GD;
+return GD.template getChildren(N);
+  }
 
   NodePtr getIDom(NodePtr BB) const {
 auto InfoIt = NodeToInfo.find(BB);
@@ -194,8 +176,7 @@
   NumToNode.push_back(BB);
 
   constexpr bool Direction = IsReverse != IsPostDom;  // XOR.
-  for (const NodePtr Succ :
-   ChildrenGetter::Get(BB, BatchUpdates)) {
+  for (const NodePtr Succ : ChildrenGet(BB, BatchUpdates)) {
 const auto SIT = NodeToInfo.find(Succ);
 // Don't visit nodes more than once but remember to collect
 // ReverseChildren.
@@ -330,7 +311,7 @@
   // to CFG nodes within infinite loops.
   static bool HasForwardSuccessors(const NodePtr N, BatchUpdatePtr BUI) {
 assert(N && "N must be a valid node");
-return !ChildrenGetter::Get(N, BUI).empty();
+return !ChildrenGet(N, BUI).empty();
   }
 
   static NodePtr GetEntryNode(const DomTreeT ) {
@@ -748,8 +729,7 @@
 //
 // Invariant: there is an optimal path from `To` to TN with the minimum
 // depth being CurrentLevel.
-for (const NodePtr Succ :
- ChildrenGetter::Get(TN->getBlock(), BUI)) {
+for (const NodePtr Succ : ChildrenGet(TN->getBlock(), BUI)) {
   const TreeNodePtr SuccTN = DT.getNode(Succ);
   assert(SuccTN &&
  "Unreachable successor found at reachable insertion");
@@ -879,7 +859,7 @@
 // the DomTree about it.
 // The check is O(N), so run it only in debug configuration.
 auto IsSuccessor = [BUI](const NodePtr SuccCandidate, const NodePtr Of) {
-  auto Successors = ChildrenGetter::Get(Of, BUI);
+  auto Successors = ChildrenGet(Of, BUI);
   return llvm::find(Successors, SuccCandidate) != Successors.end();
 };
 (void)IsSuccessor;
@@ -967,7 +947,7 @@
 LLVM_DEBUG(dbgs() << "IsReachableFromIDom " << BlockNamePrinter(TN)
   << "\n");
 auto TNB = TN->getBlock();
-for (const NodePtr Pred : ChildrenGetter::Get(TNB, BUI)) {
+for (const NodePtr Pred : ChildrenGet(TNB, BUI)) {
   LLVM_DEBUG(dbgs() << "\tPred " << BlockNamePrinter(Pred) << "\n");
   if (!DT.getNode(Pred)) continue;
 
Index: clang/include/clang/Analysis/Analyses/Dominators.h
===
--- clang/include/clang/Analysis/Analyses/Dominators.h
+++ clang/include/clang/Analysis/Analyses/Dominators.h
@@ -273,76 +273,6 @@
 
 namespace llvm {
 
-/// Clang's CFG contains nullpointers for unreachable succesors, e.g. when an
-/// if statement's condition is always false, it's 'then' branch is represented
-/// with a nullptr. This however will result in a nullpointer derefernece for
-/// dominator tree calculation.
-///
-/// To circumvent this, let's just crudely specialize the children getters
-/// used in LLVM's dominator tree builder.
-namespace DomTreeBuilder {
-
-using ClangCFGDomChildrenGetter =
-SemiNCAInfo::ChildrenGetter<
- /*Inverse=*/false>;
-
-template <>
-template <>
-inline ClangCFGDomChildrenGetter::ResultTy 

[PATCH] D82609: [PowerPC] Implement Vector Multiply High/Divide Extended Builtins in LLVM/Clang

2020-07-27 Thread Amy Kwan via Phabricator via cfe-commits
amyk updated this revision to Diff 281080.
amyk added a comment.

Addressed the following comments:

- updated CHECK lines to check for the full intrinsic call
- updated indentation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82609

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
  llvm/test/CodeGen/PowerPC/p10-vector-multiply.ll

Index: llvm/test/CodeGen/PowerPC/p10-vector-multiply.ll
===
--- llvm/test/CodeGen/PowerPC/p10-vector-multiply.ll
+++ llvm/test/CodeGen/PowerPC/p10-vector-multiply.ll
@@ -76,3 +76,49 @@
   %tr = trunc <4 x i64> %shr to <4 x i32>
   ret <4 x i32> %tr
 }
+
+; Test the vector multiply high intrinsics.
+declare <4 x i32> @llvm.ppc.altivec.vmulhsw(<4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.ppc.altivec.vmulhuw(<4 x i32>, <4 x i32>)
+declare <2 x i64> @llvm.ppc.altivec.vmulhsd(<2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.ppc.altivec.vmulhud(<2 x i64>, <2 x i64>)
+
+define <4 x i32> @test_vmulhsw_intrinsic(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmulhsw_intrinsic:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmulhsw v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %mulh = tail call <4 x i32> @llvm.ppc.altivec.vmulhsw(<4 x i32> %a, <4 x i32> %b)
+  ret <4 x i32> %mulh
+}
+
+define <4 x i32> @test_vmulhuw_intrinsic(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmulhuw_intrinsic:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmulhuw v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %mulh = tail call <4 x i32> @llvm.ppc.altivec.vmulhuw(<4 x i32> %a, <4 x i32> %b)
+  ret <4 x i32> %mulh
+}
+
+define <2 x i64> @test_vmulhsd_intrinsic(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vmulhsd_intrinsic:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmulhsd v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %mulh = tail call <2 x i64> @llvm.ppc.altivec.vmulhsd(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %mulh
+}
+
+define <2 x i64> @test_vmulhud_intrinsic(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vmulhud_intrinsic:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vmulhud v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %mulh = tail call <2 x i64> @llvm.ppc.altivec.vmulhud(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %mulh
+}
Index: llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
===
--- llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
+++ llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
@@ -49,3 +49,49 @@
   %div = sdiv <4 x i32> %a, %b
   ret <4 x i32> %div
 }
+
+; Test the vector divide extended intrinsics.
+declare <4 x i32> @llvm.ppc.altivec.vdivesw(<4 x i32>, <4 x i32>)
+declare <4 x i32> @llvm.ppc.altivec.vdiveuw(<4 x i32>, <4 x i32>)
+declare <2 x i64> @llvm.ppc.altivec.vdivesd(<2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.ppc.altivec.vdiveud(<2 x i64>, <2 x i64>)
+
+define <4 x i32> @test_vdivesw(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vdivesw:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vdivesw v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %div = tail call <4 x i32> @llvm.ppc.altivec.vdivesw(<4 x i32> %a, <4 x i32> %b)
+  ret <4 x i32> %div
+}
+
+define <4 x i32> @test_vdiveuw(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vdiveuw:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vdiveuw v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %div = tail call <4 x i32> @llvm.ppc.altivec.vdiveuw(<4 x i32> %a, <4 x i32> %b)
+  ret <4 x i32> %div
+}
+
+define <2 x i64> @test_vdivesd(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vdivesd:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vdivesd v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %div = tail call <2 x i64> @llvm.ppc.altivec.vdivesd(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %div
+}
+
+define <2 x i64> @test_vdiveud(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vdiveud:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vdiveud v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %div = tail call <2 x i64> @llvm.ppc.altivec.vdiveud(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %div
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -1044,13 +1044,21 @@
 "vdivud $vD, $vA, $vB", IIC_VecGeneral,
 [(set v2i64:$vD, (udiv v2i64:$vA, v2i64:$vB))]>;
   def VDIVESW : VXForm_1<907, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
- "vdivesw $vD, $vA, $vB", IIC_VecGeneral, []>;
+ "vdivesw $vD, $vA, $vB", IIC_VecGeneral,
+   

[clang] f250eb3 - [OpenMP][Docs] Update `present` modifier status

2020-07-27 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-27T19:23:55-04:00
New Revision: f250eb37cd4fabcc9f222ca2da80b62d110d9fff

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

LOG: [OpenMP][Docs] Update `present` modifier status

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 26fbfab96bc8..a1d1b120bcec 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -268,5 +268,7 @@ want to help with the implementation.
 
+--+--+--+---+
 | loop extension   | Loop tiling transformation
   | :part:`claimed`  | 
  |
 
+--+--+--+---+
-| device extension | 'present' map type modifier   
   | :part:`worked on`| D83061, D83062  
  |
+| device extension | 'present' map type modifier   
   | :part:`mostly done`  | D83061, D83062, D84422  
  |
++--+--+--+---+
+| device extension | 'present' motion modifier 
   | :part:`worked on`| D84711, D84712  
  |
 
+--+--+--+---+



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


[PATCH] D83490: [cmake] Support running compiler-rt tests in CrossWinToARMLinux.cmake

2020-07-27 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
broadwaylamb added a comment.

In D83490#2177256 , @vvereschaka wrote:

> - looks like `ssh.py` arguments have been changed since the diff file was 
> placed. Currently the correct string for `COMPILER_RT_EMULATOR` is the 
> following: ``` set(COMPILER_RT_EMULATOR
> "\\\"${Python3_EXECUTABLE}\\\" 
> \\\"${LLVM_PROJECT_DIR}/libcxx/utils/ssh.py\\\" --execdir %%T --host 
> ${REMOTE_TEST_USER}@${REMOTE_TEST_HOST} %%t" CACHE STRING "") ```


The usage of this `ssh.py` syntax depends on D83429 
, which is kind of controversial and probably 
won't be accepted as is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83490



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


[PATCH] D84246: [clang][LTO] Pass-through remarks options and set auto hotness threshold

2020-07-27 Thread Wei Wang via Phabricator via cfe-commits
weiwang updated this revision to Diff 281077.
weiwang added a comment.

Fix msvc build failure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84246

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/remarks-pass-through.c
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/LTO.cpp
  lld/ELF/Options.td
  lld/test/ELF/lto/opt-remarks.ll
  llvm/include/llvm/Analysis/ProfileSummaryInfo.h
  llvm/include/llvm/IR/LLVMContext.h
  llvm/include/llvm/IR/LLVMRemarkStreamer.h
  llvm/include/llvm/IR/Module.h
  llvm/include/llvm/LTO/Config.h
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/Remarks/HotnessThresholdParser.h
  llvm/lib/Analysis/OptimizationRemarkEmitter.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/IR/LLVMRemarkStreamer.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/test/LTO/X86/diagnostic-handler-remarks-with-hotness.ll
  llvm/test/Other/optimization-remarks-auto.ll
  llvm/test/Transforms/SampleProfile/Inputs/remarks-hotness.prof
  llvm/test/Transforms/SampleProfile/remarks-hotness.ll
  llvm/tools/llc/llc.cpp
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -38,6 +38,7 @@
 #include "llvm/LinkAllIR.h"
 #include "llvm/LinkAllPasses.h"
 #include "llvm/MC/SubtargetFeature.h"
+#include "llvm/Remarks/HotnessThresholdParser.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Host.h"
@@ -272,11 +273,13 @@
 cl::desc("With PGO, include profile count in optimization remarks"),
 cl::Hidden);
 
-static cl::opt
-RemarksHotnessThreshold("pass-remarks-hotness-threshold",
-cl::desc("Minimum profile count required for "
- "an optimization remark to be output"),
-cl::Hidden);
+static cl::opt, false, remarks::HotnessThresholdParser>
+RemarksHotnessThreshold(
+"pass-remarks-hotness-threshold",
+cl::desc("Minimum profile count required for "
+ "an optimization remark to be output. "
+ "Use 'auto' to apply the threshold from profile summary."),
+cl::value_desc("N or 'auto'"), cl::init(0), cl::Hidden);
 
 static cl::opt
 RemarksFilename("pass-remarks-output",
Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -37,6 +37,7 @@
 #include "llvm/InitializePasses.h"
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Pass.h"
+#include "llvm/Remarks/HotnessThresholdParser.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/FileSystem.h"
@@ -142,11 +143,13 @@
 cl::desc("With PGO, include profile count in optimization remarks"),
 cl::Hidden);
 
-static cl::opt
-RemarksHotnessThreshold("pass-remarks-hotness-threshold",
-cl::desc("Minimum profile count required for "
- "an optimization remark to be output"),
-cl::Hidden);
+static cl::opt, false, remarks::HotnessThresholdParser>
+RemarksHotnessThreshold(
+"pass-remarks-hotness-threshold",
+cl::desc("Minimum profile count required for "
+ "an optimization remark to be output. "
+ "Use 'auto' to apply the threshold from profile summary."),
+cl::value_desc("N or 'auto'"), cl::init(0), cl::Hidden);
 
 static cl::opt
 RemarksFilename("pass-remarks-output",
Index: llvm/test/Transforms/SampleProfile/remarks-hotness.ll
===
--- /dev/null
+++ llvm/test/Transforms/SampleProfile/remarks-hotness.ll
@@ -0,0 +1,96 @@
+;; This test verifies 'auto' hotness threshold when profile file is provided.
+;;
+;; new PM
+; RUN: rm -f %t.yaml %t.hot.yaml
+; RUN: opt %s --enable-new-pm --passes='sample-profile,cgscc(inline)' \
+; RUN: --sample-profile-file=%S/Inputs/remarks-hotness.prof \
+; RUN: -S --pass-remarks-filter=inline --pass-remarks-output=%t.yaml \
+; RUN: -pass-remarks-with-hotness --disable-output
+; RUN: FileCheck %s -check-prefix=YAML-PASS < %t.yaml
+; RUN: FileCheck %s -check-prefix=YAML-MISS < %t.yaml
+
+;; test 'auto' threshold
+; RUN: opt %s --enable-new-pm --passes='sample-profile,cgscc(inline)' \
+; RUN: 

[PATCH] D84711: [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

2020-07-27 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny created this revision.
jdenny added reviewers: ABataev, grokos, jdoerfert, RaviNarayanaswamy.
Herald added subscribers: cfe-commits, sstefan1, guansong, yaxunl.
Herald added a project: clang.

This patch implements Clang front end support for the OpenMP TR8 
`present` motion modifier for `omp target update` directives.  The 
next patch in this series implements OpenMP runtime support.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84711

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/OpenMPKinds.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/declare_mapper_ast_print.c
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/target_update_ast_print.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_messages.cpp

Index: clang/test/OpenMP/target_update_messages.cpp
===
--- clang/test/OpenMP/target_update_messages.cpp
+++ clang/test/OpenMP/target_update_messages.cpp
@@ -1,8 +1,10 @@
-// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,lt50,lt51 -fopenmp -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,ge50,lt51 -fopenmp -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,ge50,ge51 -fopenmp -fopenmp-version=51 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
 
-// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
-// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,lt50,lt51 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,ge50,lt51 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,ge50,ge51 -fopenmp-simd -fopenmp-version=51 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized
 
 void xxx(int argc) {
   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
@@ -25,6 +27,10 @@
   return 0;
 }
 
+struct S {
+  int i;
+};
+
 int main(int argc, char **argv) {
   int m;
   #pragma omp target update // expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
@@ -34,15 +40,114 @@
   #pragma omp target update to(m) ] // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}}
   #pragma omp target update to(m) ) // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}}
 
+  #pragma omp declare mapper(id: S s) map(s.i)
+  S s;
+
+  // Check parsing with no modifiers.
+  // lt51-error@+2 {{expected expression}}
+  // lt51-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update to(: s)
+  // expected-error@+2 {{expected expression}}
+  // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update to(:)
+  // expected-error@+2 2 {{expected expression}}
+  // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update to(,:)
+
+  // Check parsing with one modifier.
+  // expected-error@+2 {{use of undeclared identifier 'foobar'}}
+  // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update to(foobar: s)
+  // expected-error@+3 {{expected ',' or ')' in 'to' clause}}
+  // expected-error@+2 {{expected ')'}}
+  // expected-note@+1 {{to match this '('}}
+  #pragma omp target update to(m: s)
+  #pragma omp target update to(mapper(id): s)
+  // lt51-error@+2 {{use of undeclared identifier 'present'}}
+  // lt51-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
+  #pragma omp target update to(present: s)
+  // ge51-warning@+4 {{missing ':' after motion modifier - ignoring}}
+  // lt51-warning@+3 {{missing ':' after ) - ignoring}}
+  // 

[PATCH] D84710: [OpenMP][NFC] Consolidate `to` and `from` clause modifiers

2020-07-27 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny created this revision.
jdenny added reviewers: ABataev, grokos, jdoerfert, RaviNarayanaswamy.
Herald added subscribers: cfe-commits, sstefan1, guansong, yaxunl.
Herald added a project: clang.

`to` and `from` clauses take the same modifiers, which are called
"motion modifiers" in TR8, so implement handling of their modifiers
once not twice.  This will make it easier to implement additional
motion modifiers in the future.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84710

Files:
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/OpenMPKinds.h
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/Parse/ParseOpenMP.cpp

Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -3442,21 +3442,10 @@
   Data.ColonLoc = ConsumeToken();
   } else if (Kind == OMPC_to || Kind == OMPC_from) {
 if (Tok.is(tok::identifier)) {
-  bool IsMapperModifier = false;
-  if (Kind == OMPC_to) {
-auto Modifier =
-static_cast(getOpenMPSimpleClauseType(
-Kind, PP.getSpelling(Tok), getLangOpts().OpenMP));
-if (Modifier == OMPC_TO_MODIFIER_mapper)
-  IsMapperModifier = true;
-  } else {
-auto Modifier =
-static_cast(getOpenMPSimpleClauseType(
-Kind, PP.getSpelling(Tok), getLangOpts().OpenMP));
-if (Modifier == OMPC_FROM_MODIFIER_mapper)
-  IsMapperModifier = true;
-  }
-  if (IsMapperModifier) {
+  auto Modifier =
+  static_cast(getOpenMPSimpleClauseType(
+  Kind, PP.getSpelling(Tok), getLangOpts().OpenMP));
+  if (Modifier == OMPC_MOTION_MODIFIER_mapper) {
 // Parse the mapper modifier.
 ConsumeToken();
 IsInvalidMapperModifier = parseMapperModifier(Data);
Index: clang/lib/Basic/OpenMPKinds.cpp
===
--- clang/lib/Basic/OpenMPKinds.cpp
+++ clang/lib/Basic/OpenMPKinds.cpp
@@ -64,17 +64,12 @@
 return Type;
   }
   case OMPC_to:
-return llvm::StringSwitch(Str)
-#define OPENMP_TO_MODIFIER_KIND(Name)  \
-  .Case(#Name, static_cast(OMPC_TO_MODIFIER_##Name))
-#include "clang/Basic/OpenMPKinds.def"
-.Default(OMPC_TO_MODIFIER_unknown);
   case OMPC_from:
 return llvm::StringSwitch(Str)
-#define OPENMP_FROM_MODIFIER_KIND(Name) \
-  .Case(#Name, static_cast(OMPC_FROM_MODIFIER_##Name))
+#define OPENMP_MOTION_MODIFIER_KIND(Name)  \
+  .Case(#Name, static_cast(OMPC_MOTION_MODIFIER_##Name))
 #include "clang/Basic/OpenMPKinds.def"
-.Default(OMPC_FROM_MODIFIER_unknown);
+.Default(OMPC_MOTION_MODIFIER_unknown);
   case OMPC_dist_schedule:
 return llvm::StringSwitch(Str)
 #define OPENMP_DIST_SCHEDULE_KIND(Name) .Case(#Name, OMPC_DIST_SCHEDULE_##Name)
@@ -258,29 +253,18 @@
 }
 llvm_unreachable("Invalid OpenMP 'map' clause type");
   case OMPC_to:
-switch (Type) {
-case OMPC_TO_MODIFIER_unknown:
-  return "unknown";
-#define OPENMP_TO_MODIFIER_KIND(Name)  \
-  case OMPC_TO_MODIFIER_##Name:\
-return #Name;
-#include "clang/Basic/OpenMPKinds.def"
-default:
-  break;
-}
-llvm_unreachable("Invalid OpenMP 'to' clause type");
   case OMPC_from:
 switch (Type) {
-case OMPC_FROM_MODIFIER_unknown:
+case OMPC_MOTION_MODIFIER_unknown:
   return "unknown";
-#define OPENMP_FROM_MODIFIER_KIND(Name)\
-  case OMPC_FROM_MODIFIER_##Name:  \
+#define OPENMP_MOTION_MODIFIER_KIND(Name)  \
+  case OMPC_MOTION_MODIFIER_##Name:\
 return #Name;
 #include "clang/Basic/OpenMPKinds.def"
 default:
   break;
 }
-llvm_unreachable("Invalid OpenMP 'from' clause type");
+llvm_unreachable("Invalid OpenMP 'to' or 'from' clause type");
   case OMPC_dist_schedule:
 switch (Type) {
 case OMPC_DIST_SCHEDULE_unknown:
Index: clang/include/clang/Basic/OpenMPKinds.h
===
--- clang/include/clang/Basic/OpenMPKinds.h
+++ clang/include/clang/Basic/OpenMPKinds.h
@@ -86,20 +86,12 @@
 static constexpr unsigned NumberOfOMPMapClauseModifiers =
 OMPC_MAP_MODIFIER_last - OMPC_MAP_MODIFIER_unknown - 1;
 
-/// OpenMP modifier kind for 'to' clause.
-enum OpenMPToModifierKind {
-#define OPENMP_TO_MODIFIER_KIND(Name) \
-  OMPC_TO_MODIFIER_##Name,
+/// OpenMP modifier kind for 'to' or 'from' clause.
+enum OpenMPMotionModifierKind {
+#define OPENMP_MOTION_MODIFIER_KIND(Name) \
+  OMPC_MOTION_MODIFIER_##Name,
 #include "clang/Basic/OpenMPKinds.def"
-  

[PATCH] D83490: [cmake] Support running compiler-rt tests in CrossWinToARMLinux.cmake

2020-07-27 Thread Vlad Vereschaka via Phabricator via cfe-commits
vvereschaka added a comment.

Hi Sergei,
sorry for a late answer.
I have tested these changes on Windows cross build to Aarch64 and I found the 
following problems:

- looks like `ssh.py` arguments have been changed since the diff file was 
placed. Currently the correct string for `COMPILER_RT_EMULATOR` is the 
following:

  set(COMPILER_RT_EMULATOR"\\\"${Python3_EXECUTABLE}\\\" 
\\\"${LLVM_PROJECT_DIR}/libcxx/utils/ssh.py\\\" --execdir %%T --host 
${REMOTE_TEST_USER}@${REMOTE_TEST_HOST} %%t" CACHE STRING "")



- but I'm getting the following error during execution the tests:

  $ "C:/buildbot/temp/build/./bin/clang.exe" "-gline-tables-only" "-gcodeview" 
"-gcolumn-info" "-fno-builtin" "-I" "C:/buildbot/temp/llvm-proj
  ect/compiler-rt\lib\builtins" "-nodefaultlibs" 
"C:\buildbot\temp\llvm-project\compiler-rt\test\builtins\Unit\udivmodti4_test.c"
 "C:/buildbot
  /temp/build/./lib/clang/12.0.0/lib/aarch64-linux-gnu\libclang_rt.builtins.a" 
"-lc" "-lm" "-o" "C:\buildbot\temp\build\runtimes\runtimes-bins
  
\compiler-rt\test\builtins\Unit\AARCH64LinuxConfig\Output\udivmodti4_test.c.tmp"
  $ "C:/Python38/python.exe" 
"C:/buildbot/temp/llvm-project/libcxx/utils/ssh.py" "--execdir" 
"C:\buildbot\temp\build\runtimes\runtimes-bins\co
  mpiler-rt\test\builtins\Unit\AARCH64LinuxConfig\Output" "--host" 
"ubu...@jetson8.lab.llvm.org" "C:\buildbot\temp\build\runtimes\runtimes-bin
  
s\compiler-rt\test\builtins\Unit\AARCH64LinuxConfig\Output\udivmodti4_test.c.tmp"
 "C:\buildbot\temp\build\runtimes\runtimes-bins\compiler-rt
  \test\builtins\Unit\AARCH64LinuxConfig\Output\udivmodti4_test.c.tmp"
  # command stderr:
  bash: 
C:buildbottempbuildruntimesruntimes-binscompiler-rttestbuiltinsUnitAARCH64LinuxConfigOutputudivmodti4_test.c.tmp:
 command not found
  
  error: command failed with exit status: 127

the problem is with path format, it is getting converted into 
`C:buildbottempbuildruntimesruntimes-binscompiler-rttestbuiltinsUnitAARCH64LinuxConfigOutputudivmodti4_test.c.tmp`
 during the test execution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83490



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


[PATCH] D82727: [PowerPC][Power10] Implement Vector Expand Mask builtins in LLVM/Clang

2020-07-27 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

I will need to update this patch to remove the instruction definition and MC 
tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82727



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


[PATCH] D82675: [PowerPC][Power10] Implement Vector Extract Mask builtins in LLVM/Clang

2020-07-27 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

I will need to update this patch to remove the instruction definition and MC 
tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82675



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


[PATCH] D82725: [PowerPC][Power10] Implement Move to VSR Mask builtins in LLVM/Clang

2020-07-27 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

I will need to update this patch to remove the instruction definition and MC 
tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82725



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


[PATCH] D82726: [PowerPC] Implement Vector Count Mask Bits builtins in LLVM/Clang

2020-07-27 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

I will need to update this patch to remove the instruction definition and MC 
tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82726



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


[PATCH] D84422: [OpenMP] Fix `present` for exit from `omp target data`

2020-07-27 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 281067.
jdenny edited the summary of this revision.
jdenny added a comment.

Rewrite patch as discussed: instead of generating different runtime calls for 
the end of an `omp target data` vs. the beginning of an `omp target exit data` 
so that the runtime can determine when to ignore `present`, change Clang to 
filter `present` from the map types at the end of an `omp target data`.


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

https://reviews.llvm.org/D84422

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/test/OpenMP/target_data_codegen.cpp
  openmp/libomptarget/src/omptarget.cpp
  openmp/libomptarget/test/mapping/present/target_data_at_exit.c

Index: openmp/libomptarget/test/mapping/present/target_data_at_exit.c
===
--- /dev/null
+++ openmp/libomptarget/test/mapping/present/target_data_at_exit.c
@@ -0,0 +1,37 @@
+// RUN: %libomptarget-compile-aarch64-unknown-linux-gnu -fopenmp-version=51
+// RUN: %libomptarget-run-aarch64-unknown-linux-gnu 2>&1 \
+// RUN: | %fcheck-aarch64-unknown-linux-gnu
+
+// RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu -fopenmp-version=51
+// RUN: %libomptarget-run-powerpc64-ibm-linux-gnu 2>&1 \
+// RUN: | %fcheck-powerpc64-ibm-linux-gnu
+
+// RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu -fopenmp-version=51
+// RUN: %libomptarget-run-powerpc64le-ibm-linux-gnu 2>&1 \
+// RUN: | %fcheck-powerpc64le-ibm-linux-gnu
+
+// RUN: %libomptarget-compile-x86_64-pc-linux-gnu -fopenmp-version=51
+// RUN: %libomptarget-run-x86_64-pc-linux-gnu 2>&1 \
+// RUN: | %fcheck-x86_64-pc-linux-gnu
+
+#include 
+
+int main() {
+  int i;
+
+#pragma omp target enter data map(alloc:i)
+
+  // i isn't present at the end of the target data region, but the "present"
+  // modifier is only checked at the beginning of a region.
+#pragma omp target data map(present, alloc: i)
+  {
+#pragma omp target exit data map(delete:i)
+  }
+
+  // CHECK-NOT: Libomptarget
+  // CHECK: success
+  // CHECK-NOT: Libomptarget
+  fprintf(stderr, "success\n");
+
+  return 0;
+}
Index: openmp/libomptarget/src/omptarget.cpp
===
--- openmp/libomptarget/src/omptarget.cpp
+++ openmp/libomptarget/src/omptarget.cpp
@@ -484,8 +484,14 @@
   DP("Mapping does not exist (%s)\n",
  (HasPresentModifier ? "'present' map type modifier" : "ignored"));
   if (HasPresentModifier) {
-// FIXME: This should not be an error on exit from "omp target data",
-// but it should be an error upon entering an "omp target exit data".
+// This should be an error upon entering an "omp target exit data".  It
+// should not be an error upon exiting an "omp target data" or "omp
+// target".  For "omp target data", Clang thus doesn't include present
+// modifiers for end calls.  For "omp target", we have not found a valid
+// OpenMP program for which the error matters: it appears that, if a
+// program can guarantee that data is present at the beginning of an
+// "omp target" region so that there's no error there, that data is also
+// guaranteed to be present at the end.
 MESSAGE("device mapping required by 'present' map type modifier does "
 "not exist for host address " DPxMOD " (%ld bytes)",
 DPxPTR(HstPtrBegin), data_size);
Index: clang/test/OpenMP/target_data_codegen.cpp
===
--- clang/test/OpenMP/target_data_codegen.cpp
+++ clang/test/OpenMP/target_data_codegen.cpp
@@ -256,10 +256,16 @@
 double gc[100];
 
 // PRESENT=0x1000 | TARGET_PARAM=0x20 | TO=0x1 = 0x1021
-// CK1A: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x1021]]]
+// CK1A: [[MTYPE00Begin:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x1021]]]
+
+// TARGET_PARAM=0x20 | TO=0x1 = 0x21
+// CK1A: [[MTYPE00End:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x21]]]
 
 // PRESENT=0x1000 | CLOSE=0x400 | TARGET_PARAM=0x20 | ALWAYS=0x4 | TO=0x1 = 0x1425
-// CK1A: [[MTYPE01:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x1425]]]
+// CK1A: [[MTYPE01Begin:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x1425]]]
+
+// CLOSE=0x400 | TARGET_PARAM=0x20 | ALWAYS=0x4 | TO=0x1 = 0x425
+// CK1A: [[MTYPE01End:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x425]]]
 
 // CK1A-LABEL: _Z3fooi
 void foo(int arg) {
@@ -267,7 +273,7 @@
   float lb[arg];
 
   // Region 00
-  // CK1A-DAG: call void @__tgt_target_data_begin_mapper(i64 -1, i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], i[[sz:32|64]]* [[GEPS:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE00]]{{.+}})
+  // CK1A-DAG: call void @__tgt_target_data_begin_mapper(i64 -1, i32 1, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], i[[sz:32|64]]* [[GEPS:%.+]], {{.+}}getelementptr {{.+}}[1 x i{{.+}}]* [[MTYPE00Begin]]{{.+}})
   // CK1A-DAG: [[GEPBP]] = getelementptr 

[PATCH] D84707: [DFSan][NewPM] Port DataFlowSanitizer to NewPM

2020-07-27 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
Herald added subscribers: llvm-commits, cfe-commits, aaron.ballman, hiraditya.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84707

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/bindings/go/llvm/InstrumentationBindings.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/test/Instrumentation/DataFlowSanitizer/call.ll

Index: llvm/test/Instrumentation/DataFlowSanitizer/call.ll
===
--- llvm/test/Instrumentation/DataFlowSanitizer/call.ll
+++ llvm/test/Instrumentation/DataFlowSanitizer/call.ll
@@ -1,4 +1,5 @@
 ; RUN: opt < %s -dfsan -S | FileCheck %s
+; RUN: opt < %s -passes=dfsan -S | FileCheck %s
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
Index: llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
===
--- llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
+++ llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
@@ -119,7 +119,7 @@
   initializeHWAddressSanitizerLegacyPassPass(Registry);
   initializeThreadSanitizerLegacyPassPass(Registry);
   initializeModuleSanitizerCoverageLegacyPassPass(Registry);
-  initializeDataFlowSanitizerPass(Registry);
+  initializeDataFlowSanitizerLegacyPassPass(Registry);
 }
 
 /// LLVMInitializeInstrumentation - C binding for
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -46,6 +46,7 @@
 //
 //===--===//
 
+#include "llvm/Transforms/Instrumentation/DataFlowSanitizer.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/DepthFirstIterator.h"
@@ -78,6 +79,7 @@
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/User.h"
 #include "llvm/IR/Value.h"
@@ -292,7 +294,7 @@
   llvm::makeArrayRef(ArgumentAttributes));
 }
 
-class DataFlowSanitizer : public ModulePass {
+class DataFlowSanitizer {
   friend struct DFSanFunction;
   friend class DFSanVisitor;
 
@@ -390,14 +392,12 @@
   void initializeCallbackFunctions(Module );
   void initializeRuntimeFunctions(Module );
 
-public:
-  static char ID;
+  bool init(Module );
 
-  DataFlowSanitizer(const std::vector  =
-std::vector());
+public:
+  DataFlowSanitizer(const std::vector );
 
-  bool doInitialization(Module ) override;
-  bool runOnModule(Module ) override;
+  bool runImpl(Module );
 };
 
 struct DFSanFunction {
@@ -482,19 +482,8 @@
 
 } // end anonymous namespace
 
-char DataFlowSanitizer::ID;
-
-INITIALIZE_PASS(DataFlowSanitizer, "dfsan",
-"DataFlowSanitizer: dynamic data flow analysis.", false, false)
-
-ModulePass *llvm::createDataFlowSanitizerPass(
-const std::vector ) {
-  return new DataFlowSanitizer(ABIListFiles);
-}
-
 DataFlowSanitizer::DataFlowSanitizer(
-const std::vector )
-: ModulePass(ID) {
+const std::vector ) {
   std::vector AllABIListFiles(std::move(ABIListFiles));
   AllABIListFiles.insert(AllABIListFiles.end(), ClABIListFiles.begin(),
  ClABIListFiles.end());
@@ -559,7 +548,7 @@
   ArgumentIndexMapping);
 }
 
-bool DataFlowSanitizer::doInitialization(Module ) {
+bool DataFlowSanitizer::init(Module ) {
   Triple TargetTriple(M.getTargetTriple());
   bool IsX86_64 = TargetTriple.getArch() == Triple::x86_64;
   bool IsMIPS64 = TargetTriple.isMIPS64();
@@ -785,7 +774,9 @@
 DFSanLoadStoreCmpCallbackFnTy);
 }
 
-bool DataFlowSanitizer::runOnModule(Module ) {
+bool DataFlowSanitizer::runImpl(Module ) {
+  init(M);
+
   if (ABIList.isIn(M, "skip"))
 return false;
 
@@ -1817,3 +1808,37 @@
   DFSF.PHIFixups.push_back(std::make_pair(, ShadowPN));
   DFSF.setShadow(, ShadowPN);
 }
+
+class DataFlowSanitizerLegacyPass : public ModulePass {
+private:
+  std::vector ABIListFiles;
+
+public:
+  static char ID;
+
+  DataFlowSanitizerLegacyPass(
+  const std::vector  = std::vector())
+  : ModulePass(ID), ABIListFiles(ABIListFiles) {}
+
+  bool runOnModule(Module ) override {
+return DataFlowSanitizer(ABIListFiles).runImpl(M);
+  }
+};
+
+char 

[PATCH] D83592: [Coverage] Add comment to skipped regions

2020-07-27 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

@vsk Do you think it's ok to reland this commit?


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

https://reviews.llvm.org/D83592



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


[PATCH] D84565: [Darwin] [Driver] Clang should invoke dsymutil for lto builds -g*

2020-07-27 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: clang/lib/Driver/ToolChains/Darwin.cpp:173
+  Arg *A = Args.getLastArg(options::OPT_g_Group);
+  if (A && !A->getOption().matches(options::OPT_g0) &&
+  !A->getOption().matches(options::OPT_gstabs))

Why not hoist the `nullptr` check into the assignment?

```
if (Arg *A = Args.getLastArg(options::OPT_g_Group)
  if (!A->getOption().matches(options::OPT_g0) &&
  !A->getOption().matches(options::OPT_gstabs))
return true;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84565



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


[PATCH] D84414: [RISCV] Support Shadow Call Stack

2020-07-27 Thread Z. Zheng via Phabricator via cfe-commits
zzheng updated this revision to Diff 281062.
zzheng added a comment.

clang-formatted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84414

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/test/CodeGen/shadowcallstack-attr.c
  clang/test/Driver/sanitizer-ld.c
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.cpp
  llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.h
  llvm/test/CodeGen/RISCV/shadowcallstack.ll

Index: llvm/test/CodeGen/RISCV/shadowcallstack.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/shadowcallstack.ll
@@ -0,0 +1,174 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x18 -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s --check-prefix=RV32
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x18 -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s --check-prefix=RV64
+
+define void @f1() shadowcallstack {
+; RV32-LABEL: f1:
+; RV32:   # %bb.0:
+; RV32-NEXT:ret
+;
+; RV64-LABEL: f1:
+; RV64:   # %bb.0:
+; RV64-NEXT:ret
+  ret void
+}
+
+declare void @foo()
+
+define void @f2() shadowcallstack {
+; RV32-LABEL: f2:
+; RV32:   # %bb.0:
+; RV32-NEXT:tail foo
+;
+; RV64-LABEL: f2:
+; RV64:   # %bb.0:
+; RV64-NEXT:tail foo
+  tail call void @foo()
+  ret void
+}
+
+declare i32 @bar()
+
+define i32 @f3() shadowcallstack {
+; RV32-LABEL: f3:
+; RV32:   # %bb.0:
+; RV32-NEXT:sw ra, 0(s2)
+; RV32-NEXT:addi s2, s2, 4
+; RV32-NEXT:addi sp, sp, -16
+; RV32-NEXT:.cfi_def_cfa_offset 16
+; RV32-NEXT:sw ra, 12(sp)
+; RV32-NEXT:.cfi_offset ra, -4
+; RV32-NEXT:call bar
+; RV32-NEXT:lw ra, 12(sp)
+; RV32-NEXT:addi sp, sp, 16
+; RV32-NEXT:addi s2, s2, -4
+; RV32-NEXT:lw ra, 0(s2)
+; RV32-NEXT:ret
+;
+; RV64-LABEL: f3:
+; RV64:   # %bb.0:
+; RV64-NEXT:sd ra, 0(s2)
+; RV64-NEXT:addi s2, s2, 8
+; RV64-NEXT:addi sp, sp, -16
+; RV64-NEXT:.cfi_def_cfa_offset 16
+; RV64-NEXT:sd ra, 8(sp)
+; RV64-NEXT:.cfi_offset ra, -8
+; RV64-NEXT:call bar
+; RV64-NEXT:ld ra, 8(sp)
+; RV64-NEXT:addi sp, sp, 16
+; RV64-NEXT:addi s2, s2, -8
+; RV64-NEXT:ld ra, 0(s2)
+; RV64-NEXT:ret
+  %res = call i32 @bar()
+  %res1 = add i32 %res, 1
+  ret i32 %res
+}
+
+define i32 @f4() shadowcallstack {
+; RV32-LABEL: f4:
+; RV32:   # %bb.0:
+; RV32-NEXT:sw ra, 0(s2)
+; RV32-NEXT:addi s2, s2, 4
+; RV32-NEXT:addi sp, sp, -16
+; RV32-NEXT:.cfi_def_cfa_offset 16
+; RV32-NEXT:sw ra, 12(sp)
+; RV32-NEXT:sw s0, 8(sp)
+; RV32-NEXT:sw s1, 4(sp)
+; RV32-NEXT:sw s3, 0(sp)
+; RV32-NEXT:.cfi_offset ra, -4
+; RV32-NEXT:.cfi_offset s0, -8
+; RV32-NEXT:.cfi_offset s1, -12
+; RV32-NEXT:.cfi_offset s3, -16
+; RV32-NEXT:call bar
+; RV32-NEXT:mv s3, a0
+; RV32-NEXT:call bar
+; RV32-NEXT:mv s1, a0
+; RV32-NEXT:call bar
+; RV32-NEXT:mv s0, a0
+; RV32-NEXT:call bar
+; RV32-NEXT:add a1, s3, s1
+; RV32-NEXT:add a0, s0, a0
+; RV32-NEXT:add a0, a1, a0
+; RV32-NEXT:lw s3, 0(sp)
+; RV32-NEXT:lw s1, 4(sp)
+; RV32-NEXT:lw s0, 8(sp)
+; RV32-NEXT:lw ra, 12(sp)
+; RV32-NEXT:addi sp, sp, 16
+; RV32-NEXT:addi s2, s2, -4
+; RV32-NEXT:lw ra, 0(s2)
+; RV32-NEXT:ret
+;
+; RV64-LABEL: f4:
+; RV64:   # %bb.0:
+; RV64-NEXT:sd ra, 0(s2)
+; RV64-NEXT:addi s2, s2, 8
+; RV64-NEXT:addi sp, sp, -32
+; RV64-NEXT:.cfi_def_cfa_offset 32
+; RV64-NEXT:sd ra, 24(sp)
+; RV64-NEXT:sd s0, 16(sp)
+; RV64-NEXT:sd s1, 8(sp)
+; RV64-NEXT:sd s3, 0(sp)
+; RV64-NEXT:.cfi_offset ra, -8
+; RV64-NEXT:.cfi_offset s0, -16
+; RV64-NEXT:.cfi_offset s1, -24
+; RV64-NEXT:.cfi_offset s3, -32
+; RV64-NEXT:call bar
+; RV64-NEXT:mv s3, a0
+; RV64-NEXT:call bar
+; RV64-NEXT:mv s1, a0
+; RV64-NEXT:call bar
+; RV64-NEXT:mv s0, a0
+; RV64-NEXT:call bar
+; RV64-NEXT:add a1, s3, s1
+; RV64-NEXT:add a0, s0, a0
+; RV64-NEXT:addw a0, a1, a0
+; RV64-NEXT:ld s3, 0(sp)
+; RV64-NEXT:ld s1, 8(sp)
+; RV64-NEXT:ld s0, 16(sp)
+; RV64-NEXT:ld ra, 24(sp)
+; RV64-NEXT:addi sp, sp, 32
+; RV64-NEXT:addi s2, s2, -8
+; RV64-NEXT:ld ra, 0(s2)
+; RV64-NEXT:ret
+  %res1 = call i32 @bar()
+  %res2 = call i32 @bar()
+  %res3 = call i32 @bar()
+  %res4 = call i32 @bar()
+  %res12 = add i32 %res1, %res2
+  %res34 = add i32 %res3, %res4
+  %res1234 = add i32 %res12, %res34
+  ret i32 %res1234
+}
+
+define i32 @f5() shadowcallstack nounwind {
+; RV32-LABEL: f5:
+; RV32:   # %bb.0:
+; RV32-NEXT:sw ra, 0(s2)
+; RV32-NEXT:addi s2, s2, 4
+; RV32-NEXT:addi sp, sp, -16
+; RV32-NEXT:sw ra, 12(sp)
+; RV32-NEXT:call bar
+; RV32-NEXT:lw ra, 12(sp)
+; RV32-NEXT:addi 

[PATCH] D80858: [CUDA][HIP] Support accessing static device variable in host code

2020-07-27 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

It's a good point. Perhaps this is one of the cases where we should *not* 
follow nvcc.
We can't have our cake (preserve static behavior) and eat it (treat it as 
non-static in case something on the host side may decide to use an API which 
uses symbol names). Something's got to give. While we could make it work in 
some cases, I don't think we can make it work consistently.
I think it would be reasonable to restrict APIs that access symbols by name to 
be applicable to visible symbols only.


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

https://reviews.llvm.org/D80858



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


[PATCH] D84691: [CMake] Move find_package(ZLIB) to LLVMConfig

2020-07-27 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added a comment.
This revision is now accepted and ready to land.

Thanks, this is a great idea!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84691



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


[PATCH] D84678: [clang] False line number in a function definition with "void" parameter

2020-07-27 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: clang/test/Sema/void-argument.cpp:1
+// RUN: not %clang_cc1 %s 2>&1 | FileCheck %s
+

These kinds of tests are typically done with a `-verify` test. See the other 
tests in `Sema/` for examples.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84678



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


[PATCH] D80858: [CUDA][HIP] Support accessing static device variable in host code

2020-07-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D80858#2171266 , @hliao wrote:

> We may try to solve the issue without RDC firstly, where we don't need to 
> change that static variable name (if the runtime maintains the device 
> binaries correctly.) We only need to ensure the linker won't remove their 
> symbols.


This is essentially externalizing it in linker. However, it may not work.

Consider a static device var was accessed in host code through 
hipMemCpyToSymbol or hipMemCpyFromSymbol. In device code, this static var may 
be initialized through host code, or its final value may be read by host code 
after kernel execution. The existence of these operations mean that this static 
device variable `is` actually having `external` linkage, instead of `internal` 
linkage, since it is accessed by external modules. Fail to reflect this truth 
in IR will cause optimization passes to make incorrect assumptions about this 
variable and perform incorrect optimizations on it. e.g. the llvm passes can 
assume the value in this static var never changes, or its final value will not 
be used, then the llvm passes may simply remove it. Marking it as `used` will 
not solve the issue, since the llvm passes may still assume its value never 
changes after initialization, whereas in reality it may be changed by 
hipMemCpyToSymbol before kernel execution.


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

https://reviews.llvm.org/D80858



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


[PATCH] D84473: Dump Accumulator

2020-07-27 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin accepted this revision.
mtrofin added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84473



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


[PATCH] D84473: Dump Accumulator

2020-07-27 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin added inline comments.



Comment at: llvm/include/llvm/Analysis/DumpAccumulator.h:43
+//
+// Note that ThinLTO is not supported yet.
+//

kazu wrote:
> mtrofin wrote:
> > I'd clarify that transferring the data from pre-link thinlto to post-link 
> > isn't supported, but one could use this in post-link, correct?
> We don't add DumpAccumulator to the post-link ThinLTO pipeline yet.
> 
> Note that we add DumpAccumulator in buildPerModuleDefaultPipeline, but 
> post-link ThinLTO doesn't call the function.
> 
Yes - my point is that one could enable it in post-link and 'it'd just work'; 
the thing that doesn't work is making pre-link data jump over to post-link, 
which would require more plumbing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84473



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


[PATCH] D84246: [clang][LTO] Pass-through remarks options and set auto hotness threshold

2020-07-27 Thread Wei Wang via Phabricator via cfe-commits
weiwang added a comment.

I put everything together in a single diff so that it is easier to get the 
whole idea. The change itself is too big to go in as a single diff, and I'd 
like to get inputs on how to split it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84246



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


[PATCH] D84703: [clang codegen][AArch64] Use llvm.aarch64.neon.fcvtzs/u where it's necessary

2020-07-27 Thread Eli Friedman via Phabricator via cfe-commits
efriedma created this revision.
efriedma added reviewers: sdesmalen, SjoerdMeijer, t.p.northover, 
cameron.mcinally.
Herald added subscribers: cfe-commits, danielkiss, kristof.beyls.
Herald added a project: clang.

fptosi/fptoui have similar, but not identical, semantics.  In particular, the 
behavior on overflow is different.

Fixes https://bugs.llvm.org/show_bug.cgi?id=46844 for 64-bit.  (This is missing 
the corresponding change for 32-bit; the 32-bit equivalent to 
llvm.aarch64.neon.fcvtzs isn't implemented, as far as I can tell.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84703

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
  clang/test/CodeGen/aarch64-neon-intrinsics.c
  clang/test/CodeGen/aarch64-neon-misc.c
  clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c

Index: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
===
--- clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
+++ clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
@@ -130,28 +130,28 @@
 }
 
 // CHECK-LABEL: test_vcvt_s16_f16
-// CHECK:  [[VCVT:%.*]] = fptosi <4 x half> %a to <4 x i16>
+// CHECK:  [[VCVT:%.*]] = call <4 x i16> @llvm.aarch64.neon.fcvtzs.v4i16.v4f16(<4 x half> %a)
 // CHECK:  ret <4 x i16> [[VCVT]]
 int16x4_t test_vcvt_s16_f16 (float16x4_t a) {
   return vcvt_s16_f16(a);
 }
 
 // CHECK-LABEL: test_vcvtq_s16_f16
-// CHECK:  [[VCVT:%.*]] = fptosi <8 x half> %a to <8 x i16>
+// CHECK:  [[VCVT:%.*]] = call <8 x i16> @llvm.aarch64.neon.fcvtzs.v8i16.v8f16(<8 x half> %a)
 // CHECK:  ret <8 x i16> [[VCVT]]
 int16x8_t test_vcvtq_s16_f16 (float16x8_t a) {
   return vcvtq_s16_f16(a);
 }
 
 // CHECK-LABEL: test_vcvt_u16_f16
-// CHECK:  [[VCVT:%.*]] = fptoui <4 x half> %a to <4 x i16>
+// CHECK:  [[VCVT:%.*]] = call <4 x i16> @llvm.aarch64.neon.fcvtzu.v4i16.v4f16(<4 x half> %a)
 // CHECK:  ret <4 x i16> [[VCVT]]
 uint16x4_t test_vcvt_u16_f16 (float16x4_t a) {
   return vcvt_u16_f16(a);
 }
 
 // CHECK-LABEL: test_vcvtq_u16_f16
-// CHECK:  [[VCVT:%.*]] = fptoui <8 x half> %a to <8 x i16>
+// CHECK:  [[VCVT:%.*]] = call <8 x i16> @llvm.aarch64.neon.fcvtzu.v8i16.v8f16(<8 x half> %a)
 // CHECK:  ret <8 x i16> [[VCVT]]
 uint16x8_t test_vcvtq_u16_f16 (float16x8_t a) {
   return vcvtq_u16_f16(a);
Index: clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
===
--- clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
+++ clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
@@ -97,42 +97,44 @@
 }
 
 // CHECK-LABEL: test_vcvth_s16_f16
-// CHECK:  [[VCVT:%.*]] = fptosi half %a to i16
-// CHECK:  ret i16 [[VCVT]]
+// CHECK:  [[VCVT:%.*]] = call i32 @llvm.aarch64.neon.fcvtzs.i32.f16(half %a)
+// CHECK:  [[TRUNC:%.*]] = trunc i32 [[VCVT]] to i16
+// CHECK:  ret i16 [[TRUNC]]
 int16_t test_vcvth_s16_f16 (float16_t a) {
   return vcvth_s16_f16(a);
 }
 
 // CHECK-LABEL: test_vcvth_s32_f16
-// CHECK:  [[VCVT:%.*]] = fptosi half %a to i32
+// CHECK:  [[VCVT:%.*]] = call i32 @llvm.aarch64.neon.fcvtzs.i32.f16(half %a)
 // CHECK:  ret i32 [[VCVT]]
 int32_t test_vcvth_s32_f16 (float16_t a) {
   return vcvth_s32_f16(a);
 }
 
 // CHECK-LABEL: test_vcvth_s64_f16
-// CHECK:  [[VCVT:%.*]] = fptosi half %a to i64
+// CHECK:  [[VCVT:%.*]] = call i64 @llvm.aarch64.neon.fcvtzs.i64.f16(half %a)
 // CHECK:  ret i64 [[VCVT]]
 int64_t test_vcvth_s64_f16 (float16_t a) {
   return vcvth_s64_f16(a);
 }
 
 // CHECK-LABEL: test_vcvth_u16_f16
-// CHECK:  [[VCVT:%.*]] = fptoui half %a to i16
-// CHECK:  ret i16 [[VCVT]]
+// CHECK:  [[VCVT:%.*]] = call i32 @llvm.aarch64.neon.fcvtzu.i32.f16(half %a)
+// CHECK:  [[TRUNC:%.*]] = trunc i32 [[VCVT]] to i16
+// CHECK:  ret i16 [[TRUNC]]
 uint16_t test_vcvth_u16_f16 (float16_t a) {
   return vcvth_u16_f16(a);
 }
 
 // CHECK-LABEL: test_vcvth_u32_f16
-// CHECK:  [[VCVT:%.*]] = fptoui half %a to i32
+// CHECK:  [[VCVT:%.*]] = call i32 @llvm.aarch64.neon.fcvtzu.i32.f16(half %a)
 // CHECK:  ret i32 [[VCVT]]
 uint32_t test_vcvth_u32_f16 (float16_t a) {
   return vcvth_u32_f16(a);
 }
 
 // CHECK-LABEL: test_vcvth_u64_f16
-// CHECK:  [[VCVT:%.*]] = fptoui half %a to i64
+// CHECK:  [[VCVT:%.*]] = call i64 @llvm.aarch64.neon.fcvtzu.i64.f16(half %a)
 // CHECK:  ret i64 [[VCVT]]
 uint64_t test_vcvth_u64_f16 (float16_t a) {
   return vcvth_u64_f16(a);
Index: clang/test/CodeGen/aarch64-neon-misc.c
===
--- clang/test/CodeGen/aarch64-neon-misc.c
+++ clang/test/CodeGen/aarch64-neon-misc.c
@@ -2311,7 +2311,7 @@
 
 // CHECK-LABEL: @test_vcvt_s32_f32(
 // CHECK:   [[TMP0:%.*]] = bitcast <2 x float> %a to <8 x i8>
-// CHECK:   [[TMP1:%.*]] = fptosi <2 x float> %a to <2 x i32>
+// CHECK:   [[TMP1:%.*]] = call <2 x i32> @llvm.aarch64.neon.fcvtzs.v2i32.v2f32(<2 x float> %a)
 // CHECK:   ret <2 x i32> [[TMP1]]
 int32x2_t test_vcvt_s32_f32(float32x2_t 

[PATCH] D84572: Allow .dSYM's to be directly placed in an alternate directory

2020-07-27 Thread Daniel Sanders via Phabricator via cfe-commits
dsanders marked an inline comment as done.
dsanders added inline comments.



Comment at: clang/include/clang/Driver/Options.td:693
 def e : JoinedOrSeparate<["-"], "e">, Group;
+def external_dsym_dir : JoinedOrSeparate<["-"], "external-dsym-dir">,
+  Flags<[DriverOption, RenderAsInput]>,

JDevlieghere wrote:
> Could we drop the `external` prefix or did you pick this for consistency with 
> other flags? It seems rather specific for the externalize debug info scenario 
> while the functionality seems generic enough by itself. 
Sure, I wasn't terribly keen on the name and I didn't find any precedent to 
work from


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84572



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


[PATCH] D84658: [clang] Overload NamedDecl::printName to provide a user-friendly name for unnamed entities

2020-07-27 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno marked an inline comment as done.
riccibruno added inline comments.



Comment at: clang/lib/AST/Decl.cpp:2032
+  // additional complexity needed to prevent this is not worthwhile.
+  OS << (Policy.MSVCFormatting ? '`' : '(')
+ << (IsAnonymousStructOrUnion ? "anonymous" : "unnamed") << ' '

riccibruno wrote:
> erichkeane wrote:
> > riccibruno wrote:
> > > erichkeane wrote:
> > > > This pattern is happening a bunch too  Does it deserve some 
> > > > function?  Perhaps a function that either takes Policy, or a member of 
> > > > Policy to get the formatting open-tick or close-tick?
> > > Do you mean a member function of `PrintingPolicy`, something like 
> > > `getOpenTick` and `getCloseTick`?
> > Yeah, exactly, something like that. "Delimiter" is perhaps better than 
> > 'tick', but I'm not attached to either.
> "Delimiter" sounds good to me. Thanks for the suggestion!
I will fix the other instances of this pattern elsewhere as a follow-up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84658



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


[PATCH] D84658: [clang] Overload NamedDecl::printName to provide a user-friendly name for unnamed entities

2020-07-27 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 281044.
riccibruno marked 3 inline comments as done.
riccibruno added a comment.

Address Erich's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84658

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/PrettyPrinter.h
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/ast-dump-APValue-anon-union.cpp
  clang/test/AST/ast-dump-record-definition-data-json.cpp
  clang/test/Analysis/explain-svals.cpp
  clang/test/CXX/special/class.dtor/p5-0x.cpp
  clang/test/Index/annotate-comments-typedef.m
  clang/test/Index/annotate-tokens.cpp
  clang/test/Index/c-index-api-loadTU-test.m
  clang/test/Index/c-index-getCursor-test.m
  clang/test/Index/linkage.c
  clang/test/Index/load-decls.c
  clang/test/Index/load-namespaces.cpp
  clang/test/Index/preamble.c
  clang/test/Index/print-bitwidth.c
  clang/test/Index/print-type.c
  clang/test/Index/print-type.cpp
  clang/test/Index/recursive-cxx-member-calls.cpp
  clang/test/Index/targeted-annotation.c
  clang/test/Index/targeted-cursor.c
  clang/test/Index/usrs.m
  clang/test/Modules/module-private.cpp
  clang/test/Sema/address-packed.c
  clang/test/Sema/attr-flag-enum.c
  clang/test/Sema/transparent-union.c
  clang/test/SemaCXX/attr-unused.cpp
  clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
  clang/test/SemaCXX/lambda-expressions.cpp
  clang/test/SemaCXX/ms-interface.cpp
  clang/test/SemaCXX/warn-large-by-value-copy.cpp
  clang/test/SemaObjCXX/arc-0x.mm
  clang/test/Tooling/clang-diff-ast.cpp
  clang/unittests/AST/ASTTraverserTest.cpp

Index: clang/unittests/AST/ASTTraverserTest.cpp
===
--- clang/unittests/AST/ASTTraverserTest.cpp
+++ clang/unittests/AST/ASTTraverserTest.cpp
@@ -825,7 +825,7 @@
 | |-FieldDecl ''
 | |-FieldDecl ''
 | |-FieldDecl ''
-| `-CXXDestructorDecl '~'
+| `-CXXDestructorDecl '~(unnamed class at input.cc:9:3)'
 |-ImplicitCastExpr
 | `-DeclRefExpr 'a'
 |-DeclRefExpr 'b'
Index: clang/test/Tooling/clang-diff-ast.cpp
===
--- clang/test/Tooling/clang-diff-ast.cpp
+++ clang/test/Tooling/clang-diff-ast.cpp
@@ -56,7 +56,7 @@
   int not_initialized;
   // CHECK: CXXConstructorDecl: :X(void (char, int){{( __attribute__\(\(thiscall\)\))?}})(
   // CHECK-NEXT: ParmVarDecl: s(char)
-  // CHECK-NEXT: ParmVarDecl: (int)
+  // CHECK-NEXT: ParmVarDecl: (unnamed variable at {{.*}}:64:16 of type int)(int)
   // CHECK-NEXT: CXXCtorInitializer: Base
   // CHECK-NEXT: CXXConstructExpr
   // CHECK-NEXT: CXXCtorInitializer: m
Index: clang/test/SemaObjCXX/arc-0x.mm
===
--- clang/test/SemaObjCXX/arc-0x.mm
+++ clang/test/SemaObjCXX/arc-0x.mm
@@ -154,15 +154,17 @@
   // functions of the containing class.
   struct S0 {
 union {
-  id f0; // expected-note 6 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+  id f0; // expected-note-re 6 {{of '(anonymous union at {{.*}}:156:5)' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
   char f1;
 };
   };
 
   struct S1 {
 union {
-  union { // expected-note {{copy constructor of 'S1' is implicitly deleted because field '' has a deleted copy constructor}} expected-note {{copy assignment operator of 'S1' is implicitly deleted because field '' has a deleted copy assignment operator}} expected-note 4 {{'S1' is implicitly deleted because field '' has a deleted}}
-id f0; // expected-note 2 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+  union {  // expected-note-re {{copy constructor of 'S1' is implicitly deleted because field '(unnamed field of type test_union::S1::(anonymous union at {{.*}}:164:7))' has a deleted copy constructor}}
+   // expected-note-re@-1 {{copy assignment operator of 'S1' is implicitly deleted because field '(unnamed field of type test_union::S1::(anonymous union at{{.*}}:164:7))' has a deleted copy assignment operator}}
+   // expected-note-re@-2 4{{'S1' is implicitly deleted because field '(unnamed field of type test_union::S1::(anonymous union at {{.*}}:164:7))' has a deleted}}
+id f0; // expected-note-re 2 {{of '(anonymous union at {{.*}}:164:7)' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
 char f1;
   };
   int f2;
@@ -172,7 +174,7 @@
   struct S2 {
 union {
   // FIXME: the note should say 'f0' is causing the special functions to be deleted.
-  struct { // expected-note 6 {{'S2' is implicitly deleted because variant field '' has a non-trivial}}
+  struct { // expected-note-re 6 {{of 'S2' is implicitly deleted because variant field '(unnamed field of type test_union::S2::(anonymous struct at {{.*}}:177:7))' has a non-trivial}}
 id f0;
 int f1;

[PATCH] D84473: Dump Accumulator

2020-07-27 Thread Kazu Hirata via Phabricator via cfe-commits
kazu marked an inline comment as done.
kazu added inline comments.



Comment at: llvm/include/llvm/Analysis/DumpAccumulator.h:43
+//
+// Note that ThinLTO is not supported yet.
+//

mtrofin wrote:
> I'd clarify that transferring the data from pre-link thinlto to post-link 
> isn't supported, but one could use this in post-link, correct?
We don't add DumpAccumulator to the post-link ThinLTO pipeline yet.

Note that we add DumpAccumulator in buildPerModuleDefaultPipeline, but 
post-link ThinLTO doesn't call the function.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84473



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


[PATCH] D84197: [PowerPC][Power10] 128-bit Vector String Isolate instruction definitions and MC Tests

2020-07-27 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 281042.
Conanap added a comment.

Recovered accidentally deleted test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84197

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
@@ -585,3 +585,24 @@
 # CHECK-BE: xscvsqqp 8, 28# encoding: [0xfd,0x0b,0xe6,0x88]
 # CHECK-LE: xscvsqqp 8, 28# encoding: [0x88,0xe6,0x0b,0xfd]
 xscvsqqp 8, 28
+# CHECK-BE: vstribr 2, 2  # encoding: [0x10,0x41,0x10,0x0d]
+# CHECK-LE: vstribr 2, 2  # encoding: [0x0d,0x10,0x41,0x10]
+vstribr 2, 2
+# CHECK-BE: vstribl 2, 2  # encoding: [0x10,0x40,0x10,0x0d]
+# CHECK-LE: vstribl 2, 2  # encoding: [0x0d,0x10,0x40,0x10]
+vstribl 2, 2
+# CHECK-BE: vstrihr 2, 2  # encoding: [0x10,0x43,0x10,0x0d]
+# CHECK-LE: vstrihr 2, 2  # encoding: [0x0d,0x10,0x43,0x10]
+vstrihr 2, 2
+# CHECK-BE: vstribr. 2, 2 # encoding: [0x10,0x41,0x14,0x0d]
+# CHECK-LE: vstribr. 2, 2 # encoding: [0x0d,0x14,0x41,0x10]
+vstribr. 2, 2
+# CHECK-BE: vstribl. 2, 2 # encoding: [0x10,0x40,0x14,0x0d]
+# CHECK-LE: vstribl. 2, 2 # encoding: [0x0d,0x14,0x40,0x10]
+vstribl. 2, 2
+# CHECK-BE: vstrihr. 2, 2 # encoding: [0x10,0x43,0x14,0x0d]
+# CHECK-LE: vstrihr. 2, 2 # encoding: [0x0d,0x14,0x43,0x10]
+vstrihr. 2, 2
+# CHECK-BE: vstrihl. 2, 2 # encoding: [0x10,0x42,0x14,0x0d]
+# CHECK-LE: vstrihl. 2, 2 # encoding: [0x0d,0x14,0x42,0x10]
+vstrihl. 2, 2
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
@@ -459,3 +459,26 @@
 # CHECK: xscvsqqp 8, 28
 0xfd 0xb 0xe6 0x88
 
+# CHECK: vstribr 2, 2
+0x10 0x41 0x10 0x0d
+
+# CHECK: vstribl 2, 2
+0x10 0x40 0x10 0x0d
+
+# CHECK: vstrihr 2, 2
+0x10 0x43 0x10 0x0d
+
+# CHECK: vstrihl 2, 2
+0x10 0x42 0x10 0x0d
+
+# CHECK: vstribr. 2, 2
+0x10 0x41 0x14 0x0d
+
+# CHECK: vstribl. 2, 2
+0x10 0x40 0x14 0x0d
+
+# CHECK: vstrihr. 2, 2
+0x10 0x43 0x14 0x0d
+
+# CHECK: vstrihl. 2, 2
+0x10 0x42 0x14 0x0d
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -59,6 +59,39 @@
   string BaseName = "";
 }
 
+// VX-Form: [ PO VT R VB RC XO ]
+class VXForm_VTB5_RC xo, bits<5> R, dag OOL, dag IOL, string asmstr,
+  InstrItinClass itin, list pattern>
+  : I<4, OOL, IOL, asmstr, itin> {
+  bits<5> VT;
+  bits<5> VB;
+  bit RC = 0;
+
+  let Pattern = pattern;
+
+  let Inst{6-10} = VT;
+  let Inst{11-15} = R;
+  let Inst{16-20} = VB;
+  let Inst{21} = RC;
+  let Inst{22-31} = xo;
+}
+
+// Multiclass definition to account for record and non-record form
+// instructions of VXRForm.
+multiclass VXForm_VTB5_RCr xo, bits<5> R, dag OOL, dag IOL,
+string asmbase, string asmstr,
+InstrItinClass itin, list pattern> {
+  let BaseName = asmbase in {
+def NAME : VXForm_VTB5_RC, RecFormRel;
+let Defs = [CR6] in
+def _rec : VXForm_VTB5_RC, isRecordForm, RecFormRel;
+  }
+}
+
 class MLS_DForm_R_SI34_RTA5_MEM opcode, dag OOL, dag IOL, string asmstr,
 InstrItinClass itin, list pattern>
   : PI<1, opcode, OOL, IOL, asmstr, itin> {
@@ -821,6 +854,14 @@
   (int_ppc_altivec_vsrdbi v16i8:$VRA,
   v16i8:$VRB, 
   i32:$SH))]>;
+  defm VSTRIBR : VXForm_VTB5_RCr<13, 1, (outs vrrc:$vT), (ins vrrc:$vB),
+ "vstribr", "$vT, $vB", IIC_VecGeneral, []>;
+  defm VSTRIBL : VXForm_VTB5_RCr<13, 0, (outs vrrc:$vT), (ins vrrc:$vB),
+ "vstribl", "$vT, $vB", IIC_VecGeneral, []>;
+  defm VSTRIHR : VXForm_VTB5_RCr<13, 3, (outs vrrc:$vT), (ins vrrc:$vB),
+ "vstrihr", "$vT, $vB", IIC_VecGeneral, []>;
+  defm VSTRIHL : VXForm_VTB5_RCr<13, 2, (outs vrrc:$vT), (ins vrrc:$vB),
+   

[PATCH] D84414: [RISCV] Support Shadow Call Stack

2020-07-27 Thread Z. Zheng via Phabricator via cfe-commits
zzheng marked 2 inline comments as done.
zzheng added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVFrameLowering.cpp:33-37
+  std::vector  = MF.getFrameInfo().getCalleeSavedInfo();
+  if (std::none_of(CSI.begin(), CSI.end(), [](CalleeSavedInfo ) {
+return CSR.getReg() == RISCV::X1;
+  }))
+return;

MaskRay wrote:
> jrtc27 wrote:
> > ```
> > if (find(CSI, RISCV::X1) == CSI.end())
> >   return;
> > ```
> > (using `llvm::find` as a convenient wrapper around `std::find`, ie 
> > shorthand for `std::find(CSI.begin(), CSI.end(), RISCV::X1)`). Though 
> > personally I'd prefer to see X1 come from `RI.getRARegister()` rather than 
> > be hard-coded; other functions in this file already hard-code it, but in 
> > our CHERI fork we need to replace RISCV::X1 with RISCV::C1 everywhere so 
> > have changed those. Having said that, CHERI renders a shadow call stack 
> > unnecessary, so I don't particularly care if it's broken there, personally. 
> > But I still think it's nicer code.
> `!llvm::is_contained(CSI, RISCV::X1)`
Not sure how to make llvm::find or llvm::is_contained work in this scenario.

CSI is a std::vector. We need a getReg() for each 
element in it before comparing to a 'Register'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84414



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


[PATCH] D84697: [clangd] Use elog instead of llvm::errs, log instead of llvm::outs

2020-07-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks for sending this... after looking at the examples and thinking again 
about our conversation I may have shifted a bit :-\

I think it's important *log() should only be used for messages intended to be 
logged! (i.e. read later as a sequence of log messages).
We happen to write these to stderr by default, but this is an implementation 
detail that I'd like to leave flexible.

So a good question is: "if we were writing the log to a different file instead, 
would we want to write this there or stderr?"
By that measure:

- the messages followed by exit() should go to stderr
- dexp's output should go to stder
- the others seem good to go to the log

WDYT?




Comment at: clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp:101
   if (argc < 3) {
-llvm::errs() << "Usage: " << argv[0]
- << " global-symbol-index.yaml requests.json "
-"BENCHMARK_OPTIONS...\n";
+clang::clangd::elog("Usage: {0} global-symbol-index.yaml requests.json "
+"BENCHMARK_OPTIONS...",

this is fine, but just writes to errs with no log formatting... you need to set 
up a logger if you want one.



Comment at: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp:185
 if (ID.getNumOccurrences() == 0 && Name.getNumOccurrences() == 0) {
-  llvm::errs()
-  << "Missing required argument: please provide id or -name.\n";
+  elog("Missing required argument: please provide id or -name.");
   return;

hmm... since this is explicitly supposed to be an interactive tool, I think "we 
are writing to stderr" is important rather than a detail to be abstracted.

e.g. there's no timestamp etc decoration (which is good!) because you haven't 
installed an actual logger and the fallback behavior is to write to stderr. But 
neither of these things are explicit at the callsite and either could be 
changed elsewhere.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:176
   std::unique_ptr Server(Builder.BuildAndStart());
-  llvm::outs() << "Server listening on " << ServerAddress << '\n';
+  vlog("Server listening on {0}", ServerAddress);
 

I'd suggest this is log() rather than vlog() - the port is sometimes important 
to know but *progress through the startup sequence* is useful to have in the 
log.



Comment at: clang-tools-extra/clangd/indexer/IndexerMain.cpp:116
   if (!Executor) {
-llvm::errs() << llvm::toString(Executor.takeError()) << "\n";
+clang::clangd::elog("{0}", llvm::toString(Executor.takeError()));
 return 1;

unneccesary toString



Comment at: clang-tools-extra/clangd/indexer/IndexerMain.cpp:126
   if (Err) {
-llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+clang::clangd::elog("{0}", llvm::toString(std::move(Err)));
   }

unneccesary toString



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:567
   if (!Sync && WorkerThreadsCount == 0) {
-llvm::errs() << "A number of worker threads cannot be 0. Did you mean to "
-"specify -sync?";
+elog("A number of worker threads cannot be 0. Did you mean to "
+ "specify -sync?");

Don't use elog before the logger is set up to print messages to stderr - it 
seems needlessly confusing where the current version is very clear.

(it *is* better for the basic validation to happen early and us to log flag 
failures "before the stream enters log mode" where it's convenient)



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:624
   if (llvm::outs().is_displayed() && llvm::errs().is_displayed())
-llvm::errs() << Overview << "\n";
+elog(Overview);
   // Use buffered stream to stderr (we still flush each log message). 
Unbuffered

this isn't an error, and we're explicitly trying to get it in front of the user 
*before* the log starts


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84697



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


[PATCH] D84414: [RISCV] Support Shadow Call Stack

2020-07-27 Thread Z. Zheng via Phabricator via cfe-commits
zzheng updated this revision to Diff 281038.
zzheng marked 7 inline comments as done.
zzheng edited the summary of this revision.
zzheng added a comment.

Addressed styling & code clarity issues.

Fixed wrong opcode for RV64.

Unlike x18 on AArch64,  there's no register that should normally be 
reserved/not-used on RISCV. So using any eligible register would break ABI 
compatibility. x18 is neither a better nor a worse choice than other registers. 
Non-SCS code should be built with -ffixed-x18 to be compatible with SCS-enabled 
code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84414

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/test/CodeGen/shadowcallstack-attr.c
  clang/test/Driver/sanitizer-ld.c
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.cpp
  llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.h
  llvm/test/CodeGen/RISCV/shadowcallstack.ll

Index: llvm/test/CodeGen/RISCV/shadowcallstack.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/shadowcallstack.ll
@@ -0,0 +1,174 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=+reserve-x18 -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s --check-prefix=RV32
+; RUN: llc -mtriple=riscv64 -mattr=+reserve-x18 -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s --check-prefix=RV64
+
+define void @f1() shadowcallstack {
+; RV32-LABEL: f1:
+; RV32:   # %bb.0:
+; RV32-NEXT:ret
+;
+; RV64-LABEL: f1:
+; RV64:   # %bb.0:
+; RV64-NEXT:ret
+  ret void
+}
+
+declare void @foo()
+
+define void @f2() shadowcallstack {
+; RV32-LABEL: f2:
+; RV32:   # %bb.0:
+; RV32-NEXT:tail foo
+;
+; RV64-LABEL: f2:
+; RV64:   # %bb.0:
+; RV64-NEXT:tail foo
+  tail call void @foo()
+  ret void
+}
+
+declare i32 @bar()
+
+define i32 @f3() shadowcallstack {
+; RV32-LABEL: f3:
+; RV32:   # %bb.0:
+; RV32-NEXT:sw ra, 0(s2)
+; RV32-NEXT:addi s2, s2, 4
+; RV32-NEXT:addi sp, sp, -16
+; RV32-NEXT:.cfi_def_cfa_offset 16
+; RV32-NEXT:sw ra, 12(sp)
+; RV32-NEXT:.cfi_offset ra, -4
+; RV32-NEXT:call bar
+; RV32-NEXT:lw ra, 12(sp)
+; RV32-NEXT:addi sp, sp, 16
+; RV32-NEXT:addi s2, s2, -4
+; RV32-NEXT:lw ra, 0(s2)
+; RV32-NEXT:ret
+;
+; RV64-LABEL: f3:
+; RV64:   # %bb.0:
+; RV64-NEXT:sd ra, 0(s2)
+; RV64-NEXT:addi s2, s2, 8
+; RV64-NEXT:addi sp, sp, -16
+; RV64-NEXT:.cfi_def_cfa_offset 16
+; RV64-NEXT:sd ra, 8(sp)
+; RV64-NEXT:.cfi_offset ra, -8
+; RV64-NEXT:call bar
+; RV64-NEXT:ld ra, 8(sp)
+; RV64-NEXT:addi sp, sp, 16
+; RV64-NEXT:addi s2, s2, -8
+; RV64-NEXT:ld ra, 0(s2)
+; RV64-NEXT:ret
+  %res = call i32 @bar()
+  %res1 = add i32 %res, 1
+  ret i32 %res
+}
+
+define i32 @f4() shadowcallstack {
+; RV32-LABEL: f4:
+; RV32:   # %bb.0:
+; RV32-NEXT:sw ra, 0(s2)
+; RV32-NEXT:addi s2, s2, 4
+; RV32-NEXT:addi sp, sp, -16
+; RV32-NEXT:.cfi_def_cfa_offset 16
+; RV32-NEXT:sw ra, 12(sp)
+; RV32-NEXT:sw s0, 8(sp)
+; RV32-NEXT:sw s1, 4(sp)
+; RV32-NEXT:sw s3, 0(sp)
+; RV32-NEXT:.cfi_offset ra, -4
+; RV32-NEXT:.cfi_offset s0, -8
+; RV32-NEXT:.cfi_offset s1, -12
+; RV32-NEXT:.cfi_offset s3, -16
+; RV32-NEXT:call bar
+; RV32-NEXT:mv s3, a0
+; RV32-NEXT:call bar
+; RV32-NEXT:mv s1, a0
+; RV32-NEXT:call bar
+; RV32-NEXT:mv s0, a0
+; RV32-NEXT:call bar
+; RV32-NEXT:add a1, s3, s1
+; RV32-NEXT:add a0, s0, a0
+; RV32-NEXT:add a0, a1, a0
+; RV32-NEXT:lw s3, 0(sp)
+; RV32-NEXT:lw s1, 4(sp)
+; RV32-NEXT:lw s0, 8(sp)
+; RV32-NEXT:lw ra, 12(sp)
+; RV32-NEXT:addi sp, sp, 16
+; RV32-NEXT:addi s2, s2, -4
+; RV32-NEXT:lw ra, 0(s2)
+; RV32-NEXT:ret
+;
+; RV64-LABEL: f4:
+; RV64:   # %bb.0:
+; RV64-NEXT:sd ra, 0(s2)
+; RV64-NEXT:addi s2, s2, 8
+; RV64-NEXT:addi sp, sp, -32
+; RV64-NEXT:.cfi_def_cfa_offset 32
+; RV64-NEXT:sd ra, 24(sp)
+; RV64-NEXT:sd s0, 16(sp)
+; RV64-NEXT:sd s1, 8(sp)
+; RV64-NEXT:sd s3, 0(sp)
+; RV64-NEXT:.cfi_offset ra, -8
+; RV64-NEXT:.cfi_offset s0, -16
+; RV64-NEXT:.cfi_offset s1, -24
+; RV64-NEXT:.cfi_offset s3, -32
+; RV64-NEXT:call bar
+; RV64-NEXT:mv s3, a0
+; RV64-NEXT:call bar
+; RV64-NEXT:mv s1, a0
+; RV64-NEXT:call bar
+; RV64-NEXT:mv s0, a0
+; RV64-NEXT:call bar
+; RV64-NEXT:add a1, s3, s1
+; RV64-NEXT:add a0, s0, a0
+; RV64-NEXT:addw a0, a1, a0
+; RV64-NEXT:ld s3, 0(sp)
+; RV64-NEXT:ld s1, 8(sp)
+; RV64-NEXT:ld s0, 16(sp)
+; RV64-NEXT:ld ra, 24(sp)
+; RV64-NEXT:addi sp, sp, 32
+; RV64-NEXT:addi s2, s2, -8
+; RV64-NEXT:ld ra, 0(s2)
+; RV64-NEXT:ret
+  %res1 = call i32 @bar()
+  %res2 = call i32 @bar()
+  %res3 = call i32 

[libunwind] 145acac - [libunwind] Remove old keymgr related logic

2020-07-27 Thread Louis Dionne via cfe-commits

Author: Louis Dionne
Date: 2020-07-27T16:12:59-04:00
New Revision: 145acacaea1d7fb4ffc055a3e92ee8fee7c58634

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

LOG: [libunwind] Remove old keymgr related logic

keymgr used to be used on MacOSX <= 10.6, however we don't build libunwind
from scratch for such old systems anymore. Hence, this code isn't useful
anymore.

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

Added: 


Modified: 
libunwind/src/AddressSpace.hpp
libunwind/src/Unwind_AppleExtras.cpp

Removed: 




diff  --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp
index 764aaa3489f2..3d1e810f43c0 100644
--- a/libunwind/src/AddressSpace.hpp
+++ b/libunwind/src/AddressSpace.hpp
@@ -39,13 +39,6 @@ struct EHABIIndexEntry {
 };
 #endif
 
-#ifdef __APPLE__
-#include 
-namespace libunwind {
-   bool checkKeyMgrRegisteredFDEs(uintptr_t targetAddr, void *);
-}
-#endif
-
 #include "libunwind.h"
 #include "config.h"
 #include "dwarf2.h"
@@ -651,14 +644,10 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t 
targetAddr,
 
 
 inline bool LocalAddressSpace::findOtherFDE(pint_t targetAddr, pint_t ) {
-#ifdef __APPLE__
-  return checkKeyMgrRegisteredFDEs(targetAddr, *((void**)));
-#else
   // TO DO: if OS has way to dynamically register FDEs, check that.
   (void)targetAddr;
   (void)fde;
   return false;
-#endif
 }
 
 inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,

diff  --git a/libunwind/src/Unwind_AppleExtras.cpp 
b/libunwind/src/Unwind_AppleExtras.cpp
index 536303993eff..1d9948aced35 100644
--- a/libunwind/src/Unwind_AppleExtras.cpp
+++ b/libunwind/src/Unwind_AppleExtras.cpp
@@ -12,33 +12,6 @@
 #include "DwarfParser.hpp"
 
 
-// private keymgr stuff
-#define KEYMGR_GCC3_DW2_OBJ_LIST 302
-extern "C" {
- extern void _keymgr_set_and_unlock_processwide_ptr(int key, void *ptr);
- extern void *_keymgr_get_and_lock_processwide_ptr(int key);
-}
-
-// undocumented libgcc "struct object"
-struct libgcc_object {
-  void  *start;
-  void  *unused1;
-  void  *unused2;
-  void  *fde;
-  unsigned long  encoding;
-  void  *fde_end;
-  libgcc_object *next;
-};
-
-// undocumented libgcc "struct km_object_info" referenced by
-// KEYMGR_GCC3_DW2_OBJ_LIST
-struct libgcc_object_info {
-  libgcc_object   *seen_objects;
-  libgcc_object   *unseen_objects;
-  unsigned spare[2];
-};
-
-
 // static linker symbols to prevent wrong two level namespace for _Unwind 
symbols
 #if defined(__arm__)
#define NOT_HERE_BEFORE_5_0(sym) \
@@ -140,44 +113,3 @@ NOT_HERE_BEFORE_5_0(_Unwind_SjLj_Resume_or_Rethrow)
 NOT_HERE_BEFORE_5_0(_Unwind_SjLj_Unregister)
 
 #endif // defined(_LIBUNWIND_BUILD_SJLJ_APIS)
-
-
-namespace libunwind {
-
-_LIBUNWIND_HIDDEN
-bool checkKeyMgrRegisteredFDEs(uintptr_t pc, void *) {
-#if __MAC_OS_X_VERSION_MIN_REQUIRED
-  // lastly check for old style keymgr registration of dynamically generated
-  // FDEs acquire exclusive access to libgcc_object_info
-  libgcc_object_info *head = (libgcc_object_info *)
-_keymgr_get_and_lock_processwide_ptr(KEYMGR_GCC3_DW2_OBJ_LIST);
-  if (head != NULL) {
-// look at each FDE in keymgr
-for (libgcc_object *ob = head->unseen_objects; ob != NULL; ob = ob->next) {
-  CFI_Parser::FDE_Info fdeInfo;
-  CFI_Parser::CIE_Info cieInfo;
-  const char *msg = CFI_Parser::decodeFDE(
-  LocalAddressSpace::sThisAddressSpace,
-  (uintptr_t)ob->fde, , );
-  if (msg == NULL) {
-// Check if this FDE is for a function that includes the pc
-if ((fdeInfo.pcStart <= pc) && (pc < fdeInfo.pcEnd)) {
-  fde = (void*)fdeInfo.pcStart;
-  _keymgr_set_and_unlock_processwide_ptr(KEYMGR_GCC3_DW2_OBJ_LIST,
- head);
-  return true;
-}
-  }
-}
-  }
-  // release libgcc_object_info
-  _keymgr_set_and_unlock_processwide_ptr(KEYMGR_GCC3_DW2_OBJ_LIST, head);
-#else
-  (void)pc;
-  (void)fde;
-#endif
-  return false;
-}
-
-}
-



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


[PATCH] D82502: [PowerPC] Implement Load VSX Vector and Sign Extend and Zero Extend

2020-07-27 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 281035.
Conanap added a comment.

Included sext test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82502

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll
@@ -1,10 +1,10 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
 ; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
-; RUN:   FileCheck %s
-; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O0 \
+; RUN:   FileCheck %s --check-prefix=CHECK-LE
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O0 \
 ; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
-; RUN:   FileCheck %s
+; RUN:   FileCheck %s --check-prefix=CHECK-BE
 
 ; These test cases aims to test the builtins for the Power10 VSX vector
 ; instructions introduced in ISA 3.1.
@@ -12,27 +12,224 @@
 declare i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8>, i32)
 
 define signext i32 @test_vec_test_lsbb_all_ones(<16 x i8> %vuca) {
-; CHECK-LABEL: test_vec_test_lsbb_all_ones:
-; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:xvtlsbb cr0, v2
-; CHECK-NEXT:mfocrf r3, 128
-; CHECK-NEXT:srwi r3, r3, 31
-; CHECK-NEXT:extsw r3, r3
-; CHECK-NEXT:blr
+; CHECK-LE-LABEL: test_vec_test_lsbb_all_ones:
+; CHECK-LE:   # %bb.0: # %entry
+; CHECK-LE-NEXT:xvtlsbb cr0, v2
+; CHECK-LE-NEXT:mfocrf r3, 128
+; CHECK-LE-NEXT:srwi r3, r3, 31
+; CHECK-LE-NEXT:extsw r3, r3
+; CHECK-LE-NEXT:blr
+;
+; CHECK-BE-LABEL: test_vec_test_lsbb_all_ones:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:xvtlsbb cr0, v2
+; CHECK-BE-NEXT:mfocrf r3, 128
+; CHECK-BE-NEXT:srwi r3, r3, 31
+; CHECK-BE-NEXT:extsw r3, r3
+; CHECK-BE-NEXT:blr
 entry:
   %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i32 1)
   ret i32 %0
 }
 
 define signext i32 @test_vec_test_lsbb_all_zeros(<16 x i8> %vuca) {
-; CHECK-LABEL: test_vec_test_lsbb_all_zeros:
-; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:xvtlsbb cr0, v2
-; CHECK-NEXT:mfocrf r3, 128
-; CHECK-NEXT:rlwinm r3, r3, 3, 31, 31
-; CHECK-NEXT:extsw r3, r3
-; CHECK-NEXT:blr
+; CHECK-LE-LABEL: test_vec_test_lsbb_all_zeros:
+; CHECK-LE:   # %bb.0: # %entry
+; CHECK-LE-NEXT:xvtlsbb cr0, v2
+; CHECK-LE-NEXT:mfocrf r3, 128
+; CHECK-LE-NEXT:rlwinm r3, r3, 3, 31, 31
+; CHECK-LE-NEXT:extsw r3, r3
+; CHECK-LE-NEXT:blr
+;
+; CHECK-BE-LABEL: test_vec_test_lsbb_all_zeros:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:xvtlsbb cr0, v2
+; CHECK-BE-NEXT:mfocrf r3, 128
+; CHECK-BE-NEXT:rlwinm r3, r3, 3, 31, 31
+; CHECK-BE-NEXT:extsw r3, r3
+; CHECK-BE-NEXT:blr
 entry:
   %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i32 0)
   ret i32 %0
 }
+
+; These test cases tests that zero extending loads utilize the Load VSX Vector Rightmost
+; (lxvr[b|h|w|d]x) instructions in Power10.
+
+define dso_local <1 x i128> @vec_xl_zext(i64 %__offset, i8* nocapture readonly %__pointer) {
+; CHECK-LE-LABEL: vec_xl_zext:
+; CHECK-LE:   # %bb.0: # %entry
+; CHECK-LE-NEXT:lxvrbx v2, r4, r3
+; CHECK-LE-NEXT:blr
+;
+; CHECK-BE-LABEL: vec_xl_zext:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:lxvrbx vs0, r4, r3
+; CHECK-BE-NEXT:xxlor v2, vs0, vs0
+; CHECK-BE-NEXT:blr
+entry:
+  %add.ptr = getelementptr inbounds i8, i8* %__pointer, i64 %__offset
+  %0 = load i8, i8* %add.ptr, align 1
+  %conv = zext i8 %0 to i128
+  %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
+  ret <1 x i128> %splat.splatinsert
+}
+
+define dso_local <1 x i128> @vec_xl_zext_short(i64 %__offset, i16* nocapture readonly %__pointer) {
+; CHECK-LE-LABEL: vec_xl_zext_short:
+; CHECK-LE:   # %bb.0: # %entry
+; CHECK-LE-NEXT:sldi r3, r3, 1
+; CHECK-LE-NEXT:lxvrhx v2, r4, r3
+; CHECK-LE-NEXT:blr
+;
+; CHECK-BE-LABEL: vec_xl_zext_short:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:sldi r3, r3, 1
+; CHECK-BE-NEXT:lxvrhx vs0, r4, r3
+; CHECK-BE-NEXT:xxlor v2, vs0, vs0
+; CHECK-BE-NEXT:blr
+entry:
+  %add.ptr = getelementptr inbounds i16, i16* %__pointer, i64 %__offset
+  %0 = load i16, i16* %add.ptr, align 2
+  %conv = zext i16 %0 to i128
+  %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
+  ret <1 x i128> %splat.splatinsert
+}
+
+define dso_local <1 x i128> 

[PATCH] D84697: [clangd] Use elog instead of llvm::errs, log instead of llvm::outs

2020-07-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 281027.
kbobyrev added a comment.

Don't use llvm::toString in elog


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84697

Files:
  clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/indexer/IndexerMain.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -564,14 +564,14 @@
   }
 
   if (!Sync && WorkerThreadsCount == 0) {
-llvm::errs() << "A number of worker threads cannot be 0. Did you mean to "
-"specify -sync?";
+elog("A number of worker threads cannot be 0. Did you mean to "
+ "specify -sync?");
 return 1;
   }
 
   if (Sync) {
 if (WorkerThreadsCount.getNumOccurrences())
-  llvm::errs() << "Ignoring -j because -sync is set.\n";
+  elog("Ignoring -j because -sync is set.");
 WorkerThreadsCount = 0;
   }
   if (FallbackStyle.getNumOccurrences())
@@ -585,8 +585,7 @@
   llvm::sys::fs::FA_Read | llvm::sys::fs::FA_Write);
 if (EC) {
   InputMirrorStream.reset();
-  llvm::errs() << "Error while opening an input mirror file: "
-   << EC.message();
+  elog("Error while opening an input mirror file: {0}", EC.message());
 } else {
   InputMirrorStream->SetUnbuffered();
 }
@@ -606,8 +605,7 @@
  llvm::sys::fs::FA_Read | llvm::sys::fs::FA_Write);
 if (EC) {
   TracerStream.reset();
-  llvm::errs() << "Error while opening trace file " << TracerFile << ": "
-   << EC.message();
+  elog("Error while opening trace file {0}: {1}", TracerFile, EC.message());
 } else {
   Tracer = (TracerFile == JSONTraceFile)
? trace::createJSONTracer(*TracerStream, PrettyPrint)
@@ -623,7 +621,7 @@
   // it's somewhat likely they're confused about how to use clangd.
   // Show them the help overview, which explains.
   if (llvm::outs().is_displayed() && llvm::errs().is_displayed())
-llvm::errs() << Overview << "\n";
+elog(Overview);
   // Use buffered stream to stderr (we still flush each log message). Unbuffered
   // stream can cause significant (non-deterministic) latency for the logger.
   llvm::errs().SetBuffered();
@@ -657,16 +655,16 @@
   // continuing.
   llvm::SmallString<128> Path(CompileCommandsDir);
   if (std::error_code EC = llvm::sys::fs::make_absolute(Path)) {
-llvm::errs() << "Error while converting the relative path specified by "
-"--compile-commands-dir to an absolute path: "
- << EC.message() << ". The argument will be ignored.\n";
+elog("Error while converting the relative path specified by "
+ "--compile-commands-dir to an absolute path: {0}. The argument "
+ "will be ignored.",
+ EC.message());
   } else {
 CompileCommandsDirPath = std::string(Path.str());
   }
 } else {
-  llvm::errs()
-  << "Path specified by --compile-commands-dir does not exist. The "
- "argument will be ignored.\n";
+  elog("Path specified by --compile-commands-dir does not exist. The "
+   "argument will be ignored.");
 }
   }
 
@@ -698,8 +696,8 @@
   }
 #if CLANGD_ENABLE_REMOTE
   if (RemoteIndexAddress.empty() != ProjectRoot.empty()) {
-llvm::errs() << "remote-index-address and project-path have to be "
-"specified at the same time.";
+elog("remote-index-address and project-path have to be specified at the "
+ "same time.");
 return 1;
   }
   if (!RemoteIndexAddress.empty()) {
@@ -750,7 +748,7 @@
   elog("Couldn't determine user config file, not loading");
 }
 std::vector ProviderPointers;
-for (const auto& P : ProviderStack)
+for (const auto  : ProviderStack)
   ProviderPointers.push_back(P.get());
 Config = config::Provider::combine(std::move(ProviderPointers));
 Opts.ConfigProvider = Config.get();
@@ -766,7 +764,7 @@
 log("Starting LSP over XPC service");
 TransportLayer = newXPCTransport();
 #else
-llvm::errs() << "This clangd binary wasn't built with XPC support.\n";
+elog("This clangd binary wasn't built with XPC support.");
 return (int)ErrorResultCode::CantRunAsXPCService;
 #endif
   } else {
Index: clang-tools-extra/clangd/indexer/IndexerMain.cpp
===
--- clang-tools-extra/clangd/indexer/IndexerMain.cpp
+++ clang-tools-extra/clangd/indexer/IndexerMain.cpp
@@ -16,6 +16,7 @@
 #include "index/Serialization.h"
 #include 

[PATCH] D84697: [clangd] Use elog instead of llvm::errs, log instead of llvm::outs

2020-07-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84697

Files:
  clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/indexer/IndexerMain.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -564,14 +564,14 @@
   }
 
   if (!Sync && WorkerThreadsCount == 0) {
-llvm::errs() << "A number of worker threads cannot be 0. Did you mean to "
-"specify -sync?";
+elog("A number of worker threads cannot be 0. Did you mean to "
+ "specify -sync?");
 return 1;
   }
 
   if (Sync) {
 if (WorkerThreadsCount.getNumOccurrences())
-  llvm::errs() << "Ignoring -j because -sync is set.\n";
+  elog("Ignoring -j because -sync is set.");
 WorkerThreadsCount = 0;
   }
   if (FallbackStyle.getNumOccurrences())
@@ -585,8 +585,7 @@
   llvm::sys::fs::FA_Read | llvm::sys::fs::FA_Write);
 if (EC) {
   InputMirrorStream.reset();
-  llvm::errs() << "Error while opening an input mirror file: "
-   << EC.message();
+  elog("Error while opening an input mirror file: {0}", EC.message());
 } else {
   InputMirrorStream->SetUnbuffered();
 }
@@ -606,8 +605,7 @@
  llvm::sys::fs::FA_Read | llvm::sys::fs::FA_Write);
 if (EC) {
   TracerStream.reset();
-  llvm::errs() << "Error while opening trace file " << TracerFile << ": "
-   << EC.message();
+  elog("Error while opening trace file {0}: {1}", TracerFile, EC.message());
 } else {
   Tracer = (TracerFile == JSONTraceFile)
? trace::createJSONTracer(*TracerStream, PrettyPrint)
@@ -623,7 +621,7 @@
   // it's somewhat likely they're confused about how to use clangd.
   // Show them the help overview, which explains.
   if (llvm::outs().is_displayed() && llvm::errs().is_displayed())
-llvm::errs() << Overview << "\n";
+elog(Overview);
   // Use buffered stream to stderr (we still flush each log message). Unbuffered
   // stream can cause significant (non-deterministic) latency for the logger.
   llvm::errs().SetBuffered();
@@ -657,16 +655,16 @@
   // continuing.
   llvm::SmallString<128> Path(CompileCommandsDir);
   if (std::error_code EC = llvm::sys::fs::make_absolute(Path)) {
-llvm::errs() << "Error while converting the relative path specified by "
-"--compile-commands-dir to an absolute path: "
- << EC.message() << ". The argument will be ignored.\n";
+elog("Error while converting the relative path specified by "
+ "--compile-commands-dir to an absolute path: {0}. The argument "
+ "will be ignored.",
+ EC.message());
   } else {
 CompileCommandsDirPath = std::string(Path.str());
   }
 } else {
-  llvm::errs()
-  << "Path specified by --compile-commands-dir does not exist. The "
- "argument will be ignored.\n";
+  elog("Path specified by --compile-commands-dir does not exist. The "
+   "argument will be ignored.");
 }
   }
 
@@ -698,8 +696,8 @@
   }
 #if CLANGD_ENABLE_REMOTE
   if (RemoteIndexAddress.empty() != ProjectRoot.empty()) {
-llvm::errs() << "remote-index-address and project-path have to be "
-"specified at the same time.";
+elog("remote-index-address and project-path have to be specified at the "
+ "same time.");
 return 1;
   }
   if (!RemoteIndexAddress.empty()) {
@@ -750,7 +748,7 @@
   elog("Couldn't determine user config file, not loading");
 }
 std::vector ProviderPointers;
-for (const auto& P : ProviderStack)
+for (const auto  : ProviderStack)
   ProviderPointers.push_back(P.get());
 Config = config::Provider::combine(std::move(ProviderPointers));
 Opts.ConfigProvider = Config.get();
@@ -766,7 +764,7 @@
 log("Starting LSP over XPC service");
 TransportLayer = newXPCTransport();
 #else
-llvm::errs() << "This clangd binary wasn't built with XPC support.\n";
+elog("This clangd binary wasn't built with XPC support.");
 return (int)ErrorResultCode::CantRunAsXPCService;
 #endif
   } else {
Index: clang-tools-extra/clangd/indexer/IndexerMain.cpp
===
--- clang-tools-extra/clangd/indexer/IndexerMain.cpp
+++ clang-tools-extra/clangd/indexer/IndexerMain.cpp
@@ -16,6 +16,7 @@
 #include 

[PATCH] D84656: [clang] Pass the NamedDecl* instead of the DeclarationName into many diagnostics.

2020-07-27 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

In D84656#2176139 , @aaron.ballman 
wrote:

> The changes LGTM but it seems like there may be some formatting issues with 
> the patch (or the lint tool is acting up).


Looks like the bot is right this time. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84656



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


[PATCH] D84422: [OpenMP] Fix `present` for exit from `omp target data`

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

In D84422#2176802 , @grokos wrote:

> In D84422#2173500 , @jdenny wrote:
>
> > I've added a comment to the runtime code that performs the check.  As you 
> > can see, the check is performed regardless.  It's just a question of 
> > whether the runtime treats it as an error.  I don't think performance is an 
> > issue.
> >
> > My concern here is that it will be hard to justify changes to the runtime 
> > if I cannot formulate a use case.
>
>
> Thinking about it, I don't think there can be a case where something is 
> present upon entering a target region and not be present when we're exiting. 
> Whatever code comprises the target region is code executed on the device - it 
> cannot modify the state of host objects (i.e. libomptarget) in any possible 
> way. E.g. the kernel cannot invoke libomptarget functions, allocate memory, 
> map/unmap data etc.
>
> The only case where something like this would be possible is if we have 
> multiple host threads executing async offloading. In such a case, one thread 
> may launch a target region at a moment when the requested mapping is 
> `present` on the device and while the kernel is executing some other thread 
> performs a `target data exit` on the desired mapping. Upon exiting the 
> kernel, the mapping will no longer be present but this is clearly a race 
> condition (user's fault), so I don't think we should pay attention to such a 
> scenario.


Exactly.  As far as I can tell, the runtime simply needs a comment that 
explains this issue in the case of `omp target`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84422



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


[PATCH] D84422: [OpenMP] Fix `present` for exit from `omp target data`

2020-07-27 Thread George Rokos via Phabricator via cfe-commits
grokos added a comment.

In D84422#2173500 , @jdenny wrote:

> I've added a comment to the runtime code that performs the check.  As you can 
> see, the check is performed regardless.  It's just a question of whether the 
> runtime treats it as an error.  I don't think performance is an issue.
>
> My concern here is that it will be hard to justify changes to the runtime if 
> I cannot formulate a use case.


Thinking about it, I don't think there can be a case where something is present 
upon entering a target region and not be present when we're exiting. Whatever 
code comprises the target region is code executed on the device - it cannot 
modify the state of host objects (i.e. libomptarget) in any possible way. E.g. 
the kernel cannot invoke libomptarget functions, allocate memory, map/unmap 
data etc.

The only case where something like this would be possible is if we have 
multiple host threads executing async offloading. In such a case, one thread 
may launch a target region at a moment when the requested mapping is `present` 
on the device and while the kernel is executing some other thread performs a 
`target data exit` on the desired mapping. Upon exiting the kernel, the mapping 
will no longer be present but this is clearly a race condition (user's fault), 
so I don't think we should pay attention to such a scenario.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84422



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


[PATCH] D84306: [clang-format][NFC] Be more careful about the layout of FormatToken.

2020-07-27 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 281019.
riccibruno marked 2 inline comments as done.
riccibruno added a comment.

Remove a few missed `getPackingKind`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84306

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/WhitespaceManager.cpp

Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -49,7 +49,7 @@
   bool IsAligned, bool InPPDirective) {
   if (Tok.Finalized)
 return;
-  Tok.Decision = (Newlines > 0) ? FD_Break : FD_Continue;
+  Tok.setDecision((Newlines > 0) ? FD_Break : FD_Continue);
   Changes.push_back(Change(Tok, /*CreateReplacement=*/true, Tok.WhitespaceRange,
Spaces, StartOfTokenColumn, Newlines, "", "",
IsAligned, InPPDirective && !Tok.IsFirst,
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -472,19 +472,19 @@
   // individual members in a type member list, which would normally
   // trigger BK_Block. In both cases, this must be parsed as an inline
   // braced init.
-  Tok->BlockKind = BK_BracedInit;
+  Tok->setBlockKind(BK_BracedInit);
 else if (PrevTok->is(tok::r_paren))
   // `) { }` can only occur in function or method declarations in JS.
-  Tok->BlockKind = BK_Block;
+  Tok->setBlockKind(BK_Block);
   } else {
-Tok->BlockKind = BK_Unknown;
+Tok->setBlockKind(BK_Unknown);
   }
   LBraceStack.push_back(Tok);
   break;
 case tok::r_brace:
   if (LBraceStack.empty())
 break;
-  if (LBraceStack.back()->BlockKind == BK_Unknown) {
+  if (LBraceStack.back()->is(BK_Unknown)) {
 bool ProbablyBracedList = false;
 if (Style.Language == FormatStyle::LK_Proto) {
   ProbablyBracedList = NextTok->isOneOf(tok::comma, tok::r_square);
@@ -524,11 +524,11 @@
   }
 }
 if (ProbablyBracedList) {
-  Tok->BlockKind = BK_BracedInit;
-  LBraceStack.back()->BlockKind = BK_BracedInit;
+  Tok->setBlockKind(BK_BracedInit);
+  LBraceStack.back()->setBlockKind(BK_BracedInit);
 } else {
-  Tok->BlockKind = BK_Block;
-  LBraceStack.back()->BlockKind = BK_Block;
+  Tok->setBlockKind(BK_Block);
+  LBraceStack.back()->setBlockKind(BK_Block);
 }
   }
   LBraceStack.pop_back();
@@ -545,8 +545,8 @@
 case tok::kw_switch:
 case tok::kw_try:
 case tok::kw___try:
-  if (!LBraceStack.empty() && LBraceStack.back()->BlockKind == BK_Unknown)
-LBraceStack.back()->BlockKind = BK_Block;
+  if (!LBraceStack.empty() && LBraceStack.back()->is(BK_Unknown))
+LBraceStack.back()->setBlockKind(BK_Block);
   break;
 default:
   break;
@@ -557,8 +557,8 @@
 
   // Assume other blocks for all unclosed opening braces.
   for (unsigned i = 0, e = LBraceStack.size(); i != e; ++i) {
-if (LBraceStack[i]->BlockKind == BK_Unknown)
-  LBraceStack[i]->BlockKind = BK_Block;
+if (LBraceStack[i]->is(BK_Unknown))
+  LBraceStack[i]->setBlockKind(BK_Block);
   }
 
   FormatTok = Tokens->setPosition(StoredPosition);
@@ -584,7 +584,7 @@
   assert(FormatTok->isOneOf(tok::l_brace, TT_MacroBlockBegin) &&
  "'{' or macro block token expected");
   const bool MacroBlock = FormatTok->is(TT_MacroBlockBegin);
-  FormatTok->BlockKind = BK_Block;
+  FormatTok->setBlockKind(BK_Block);
 
   size_t PPStartHash = computePPHash();
 
@@ -614,7 +614,7 @@
   if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd)
  : !FormatTok->is(tok::r_brace)) {
 Line->Level = InitialLevel;
-FormatTok->BlockKind = BK_Block;
+FormatTok->setBlockKind(BK_Block);
 return;
   }
 
@@ -690,7 +690,7 @@
 }
 
 void UnwrappedLineParser::parseChildBlock() {
-  FormatTok->BlockKind = BK_Block;
+  FormatTok->setBlockKind(BK_Block);
   nextToken();
   {
 bool SkipIndent = (Style.Language == FormatStyle::LK_JavaScript &&
@@ -1476,7 +1476,7 @@
 // C# needs this change to ensure that array initialisers and object
 // initialisers are indented the same way.
 if (Style.isCSharp())
-  FormatTok->BlockKind = BK_BracedInit;
+  FormatTok->setBlockKind(BK_BracedInit);
 nextToken();
 parseBracedList();
   } else if 

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

2020-07-27 Thread Xiangling Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG05ad8e942996: [AIX] Implement AIX special alignment rule 
about double/long double (authored by Xiangling_L).

Repository:
  rG LLVM Github Monorepo

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-expecting-diagnostics.cpp
  clang/test/Layout/aix-Wpacked-no-diagnostics.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-2.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 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK32 %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -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 | 

[clang] 05ad8e9 - [AIX] Implement AIX special alignment rule about double/long double

2020-07-27 Thread Xiangling Liao via cfe-commits

Author: Xiangling Liao
Date: 2020-07-27T15:13:03-04:00
New Revision: 05ad8e942996f36cc694478542ccd84aa5bbb80f

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

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

Implement AIX default `power` alignment rule by adding `PreferredAlignment` and
`PreferredNVAlignment` in ASTRecordLayout class.

The patchh aims at returning correct value for `__alignof(x)` and `alignof(x)`
under `power` alignment rules.

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

Added: 
clang/test/Layout/aix-Wpacked-expecting-diagnostics.cpp
clang/test/Layout/aix-Wpacked-no-diagnostics.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-2.cpp
clang/test/Layout/aix-power-alignment-typedef.cpp
clang/test/Layout/aix-virtual-function-and-base-with-double.cpp

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

Removed: 




diff  --git a/clang/include/clang/AST/RecordLayout.h 
b/clang/include/clang/AST/RecordLayout.h
index b259791af509..946fbd8f4ce2 100644
--- a/clang/include/clang/AST/RecordLayout.h
+++ b/clang/include/clang/AST/RecordLayout.h
@@ -70,6 +70,11 @@ class ASTRecordLayout {
   // Alignment - Alignment of record in characters.
   CharUnits Alignment;
 
+  // PreferredAlignment - Preferred alignment of record in characters. This
+  // can be 
diff erent than Alignment in cases where it is beneficial for
+  // performance or backwards compatibility preserving (e.g. AIX-ABI).
+  CharUnits PreferredAlignment;
+
   // UnadjustedAlignment - Maximum of the alignments of the record members in
   // characters.
   CharUnits UnadjustedAlignment;
@@ -91,6 +96,11 @@ class ASTRecordLayout {
 /// which is the alignment of the object without virtual bases.
 CharUnits NonVirtualAlignment;
 
+/// PreferredNVAlignment - The preferred non-virtual alignment (in chars) 
of
+/// an object, which is the preferred alignment of the object without
+/// virtual bases.
+CharUnits PreferredNVAlignment;
+
 /// SizeOfLargestEmptySubobject - The size of the largest empty subobject
 /// (either a base or a member). Will be zero if the class doesn't contain
 /// any empty subobjects.
@@ -139,30 +149,26 @@ class ASTRecordLayout {
   CXXRecordLayoutInfo *CXXInfo = nullptr;
 
   ASTRecordLayout(const ASTContext , CharUnits size, CharUnits alignment,
-  CharUnits unadjustedAlignment,
+  CharUnits preferredAlignment, CharUnits unadjustedAlignment,
   CharUnits requiredAlignment, CharUnits datasize,
   ArrayRef fieldoffsets);
 
   using BaseOffsetsMapTy = CXXRecordLayoutInfo::BaseOffsetsMapTy;
 
   // Constructor for C++ records.
-  ASTRecordLayout(const ASTContext ,
-  CharUnits size, CharUnits alignment,
-  CharUnits unadjustedAlignment,
-  CharUnits requiredAlignment,
-  bool hasOwnVFPtr, bool hasExtendableVFPtr,
-  CharUnits vbptroffset,
-  CharUnits datasize,
-  ArrayRef fieldoffsets,
+  ASTRecordLayout(const ASTContext , CharUnits size, CharUnits alignment,
+  CharUnits preferredAlignment, CharUnits unadjustedAlignment,
+  CharUnits requiredAlignment, bool hasOwnVFPtr,
+  bool hasExtendableVFPtr, CharUnits vbptroffset,
+  CharUnits datasize, ArrayRef fieldoffsets,
   CharUnits nonvirtualsize, CharUnits nonvirtualalignment,
+  CharUnits preferrednvalignment,
   CharUnits SizeOfLargestEmptySubobject,
-  const CXXRecordDecl *PrimaryBase,
-  bool IsPrimaryBaseVirtual,
+  const CXXRecordDecl *PrimaryBase, bool IsPrimaryBaseVirtual,
   const CXXRecordDecl *BaseSharingVBPtr,
-  bool EndsWithZeroSizedObject,
-  bool LeadsWithZeroSizedBase,
-  const BaseOffsetsMapTy& BaseOffsets,
-  const VBaseOffsetsMapTy& VBaseOffsets);
+  bool EndsWithZeroSizedObject, bool LeadsWithZeroSizedBase,
+  const BaseOffsetsMapTy ,
+  const VBaseOffsetsMapTy );
 
   ~ASTRecordLayout() = default;
 
@@ -175,6 +181,10 @@ class ASTRecordLayout {
   /// getAlignment - Get the record alignment in characters.
   

[PATCH] D79219: [CMake] Simplify CMake handling for zlib

2020-07-27 Thread Petr Hosek via Phabricator via cfe-commits
phosek marked 4 inline comments as done.
phosek added inline comments.



Comment at: mlir/examples/standalone/CMakeLists.txt:35
+endif()
+
 include(TableGen)

stephenneuendorffer wrote:
> mehdi_amini wrote:
> > mehdi_amini wrote:
> > > I am a bit unsure that it is desirable that it is desirable to need this 
> > > change?
> > > This requires every single user of LLVM to do this. Is there a way this 
> > > can be done in the call to `find_package(LLVM)` instead?
> > (Doc for the usual way to integrate LLVM: 
> > https://llvm.org/docs/CMake.html#embedding-llvm-in-your-project )
> I tend to agree with Mehdi.  I think stuff like this which is *required* to 
> use LLVM should get pushed into what LLVM exports.  (Actually there is a 
> bunch of other configuration stuff which also needs to get pushed into the 
> export, otherwise configuration defaults are all wrong and things like that.)
Implemented in D84691.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79219



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


[PATCH] D84691: [CMake] Move find_package(ZLIB) to LLVMConfig

2020-07-27 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: smeenai, compnerd, mehdi_amini.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits, msifontes, 
jurahul, Kayjukh, grosul1, Joonsoo, stephenneuendorffer, liufengdb, aartbik, 
lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, 
jpienaar, rriddle, mgorny.
Herald added projects: clang, LLDB, MLIR, LLVM.

This way, downstream projects don't have to invoke find_package(ZLIB)
reducing the amount of boilerplate.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84691

Files:
  clang/CMakeLists.txt
  lld/CMakeLists.txt
  lldb/cmake/modules/LLDBStandalone.cmake
  llvm/cmake/modules/LLVMConfig.cmake.in
  mlir/examples/standalone/CMakeLists.txt


Index: mlir/examples/standalone/CMakeLists.txt
===
--- mlir/examples/standalone/CMakeLists.txt
+++ mlir/examples/standalone/CMakeLists.txt
@@ -29,10 +29,6 @@
 list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
 list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
 
-if(LLVM_ENABLE_ZLIB)
-  find_package(ZLIB)
-endif()
-
 include(TableGen)
 include(AddLLVM)
 include(AddMLIR)
Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -50,6 +50,9 @@
 set(LLVM_ENABLE_UNWIND_TABLES @LLVM_ENABLE_UNWIND_TABLES@)
 
 set(LLVM_ENABLE_ZLIB @LLVM_ENABLE_ZLIB@)
+if(LLVM_ENABLE_ZLIB)
+  find_package(ZLIB)
+endif()
 
 set(LLVM_LIBXML2_ENABLED @LLVM_LIBXML2_ENABLED@)
 
Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -74,10 +74,6 @@
 # CMake modules to be in that directory as well.
 list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
-if(LLVM_ENABLE_ZLIB)
-  find_package(ZLIB)
-endif()
-
 include(AddLLVM)
 include(TableGen)
 include(HandleLLVMOptions)
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -51,10 +51,6 @@
   set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} 
NO_DEFAULT_PATH)
 
-  if(LLVM_ENABLE_ZLIB)
-find_package(ZLIB)
-  endif()
-
   include(AddLLVM)
   include(TableGen)
   include(HandleLLVMOptions)
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -114,10 +114,6 @@
   option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF)
   option(LLVM_ENABLE_LIBXML2 "Use libxml2 if available." ON)
 
-  if(LLVM_ENABLE_ZLIB)
-find_package(ZLIB)
-  endif()
-
   include(AddLLVM)
   include(TableGen)
   include(HandleLLVMOptions)


Index: mlir/examples/standalone/CMakeLists.txt
===
--- mlir/examples/standalone/CMakeLists.txt
+++ mlir/examples/standalone/CMakeLists.txt
@@ -29,10 +29,6 @@
 list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
 list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
 
-if(LLVM_ENABLE_ZLIB)
-  find_package(ZLIB)
-endif()
-
 include(TableGen)
 include(AddLLVM)
 include(AddMLIR)
Index: llvm/cmake/modules/LLVMConfig.cmake.in
===
--- llvm/cmake/modules/LLVMConfig.cmake.in
+++ llvm/cmake/modules/LLVMConfig.cmake.in
@@ -50,6 +50,9 @@
 set(LLVM_ENABLE_UNWIND_TABLES @LLVM_ENABLE_UNWIND_TABLES@)
 
 set(LLVM_ENABLE_ZLIB @LLVM_ENABLE_ZLIB@)
+if(LLVM_ENABLE_ZLIB)
+  find_package(ZLIB)
+endif()
 
 set(LLVM_LIBXML2_ENABLED @LLVM_LIBXML2_ENABLED@)
 
Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -74,10 +74,6 @@
 # CMake modules to be in that directory as well.
 list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
-if(LLVM_ENABLE_ZLIB)
-  find_package(ZLIB)
-endif()
-
 include(AddLLVM)
 include(TableGen)
 include(HandleLLVMOptions)
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -51,10 +51,6 @@
   set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} NO_DEFAULT_PATH)
 
-  if(LLVM_ENABLE_ZLIB)
-find_package(ZLIB)
-  endif()
-
   include(AddLLVM)
   include(TableGen)
   include(HandleLLVMOptions)
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -114,10 +114,6 @@
   option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF)
   

[PATCH] D84603: Thread safety analysis: More consistent warning message

2020-07-27 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: clang/lib/Analysis/ThreadSafety.cpp:1644
 if (!LDat) {
-  Analyzer->Handler.handleMutexNotHeld("", D, POK, Cp.toString(),
-   LK_Shared, Loc);
+  Analyzer->Handler.handleMutexNotHeld("negative capability", D, POK,
+   Cp.toString(), LK_Shared, Loc);

aaron.ballman wrote:
> It's a bit odd that we aren't using `DiagKind` as below, I assume that's 
> because this is a negative test and the others are positive tests, but 
> doesn't this introduce a terminology difference where a positive failure may 
> call it a mutex and a negative failure may call it a negative capability? 
> Should this be hooked in to `ClassifyDiagnostic()` (perhaps we need a 
> `ClassifyNegativeDiagnostic()`?
My thinking was that whatever the positive capability is called, we should only 
talk about a "negative capability" instead of a "negative mutex" or a "negative 
role". Also because not holding a capability is in some way its own kind of 
capability.



Comment at: clang/test/SemaCXX/warn-thread-safety-negative.cpp:46
   void foo() {
 mu.Lock();// expected-warning {{acquiring mutex 'mu' requires negative 
capability '!mu'}}
 baz();// expected-warning {{cannot call function 'baz' while mutex 
'mu' is held}}

Here we're always referring to a "negative capability", I believe it's 
hardcoded into the message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84603



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


[PATCH] D84499: [clangd] Add more logs and attach tracers to remote index server routines

2020-07-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG731043c0c494: [clangd] Add more logs and attach tracers to 
remote index server routines (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84499

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/server/Server.cpp

Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -6,10 +6,13 @@
 //
 //===--===//
 
+#include "Index.pb.h"
 #include "index/Index.h"
 #include "index/Serialization.h"
+#include "index/Symbol.h"
 #include "index/remote/marshalling/Marshalling.h"
 #include "support/Logger.h"
+#include "support/Trace.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Path.h"
@@ -36,6 +39,16 @@
 llvm::cl::opt IndexRoot(llvm::cl::desc(""),
  llvm::cl::Positional, llvm::cl::Required);
 
+llvm::cl::opt TraceFile(
+"trace-file",
+llvm::cl::desc("Path to the file where tracer logs will be stored"));
+
+llvm::cl::opt PrettyPrint{
+"pretty",
+llvm::cl::desc("Pretty-print JSON output in the trace"),
+llvm::cl::init(false),
+};
+
 llvm::cl::opt ServerAddress(
 "server-address", llvm::cl::init("0.0.0.0:50051"),
 llvm::cl::desc("Address of the invoked server. Defaults to 0.0.0.0:50051"));
@@ -60,66 +73,90 @@
   grpc::Status Lookup(grpc::ServerContext *Context,
   const LookupRequest *Request,
   grpc::ServerWriter *Reply) override {
+trace::Span Tracer(LookupRequest::descriptor()->name());
 auto Req = ProtobufMarshaller->fromProtobuf(Request);
 if (!Req) {
   elog("Can not parse LookupRequest from protobuf: {0}", Req.takeError());
   return grpc::Status::CANCELLED;
 }
-Index->lookup(*Req, [&](const clangd::Symbol ) {
-  auto SerializedSymbol = ProtobufMarshaller->toProtobuf(Sym);
-  if (!SerializedSymbol)
+unsigned Sent = 0;
+unsigned FailedToSend = 0;
+Index->lookup(*Req, [&](const auto ) {
+  auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
+  if (!SerializedItem) {
+++FailedToSend;
 return;
+  }
   LookupReply NextMessage;
-  *NextMessage.mutable_stream_result() = *SerializedSymbol;
+  *NextMessage.mutable_stream_result() = *SerializedItem;
   Reply->Write(NextMessage);
+  ++Sent;
 });
 LookupReply LastMessage;
 LastMessage.set_final_result(true);
 Reply->Write(LastMessage);
+SPAN_ATTACH(Tracer, "Sent", Sent);
+SPAN_ATTACH(Tracer, "Failed to send", FailedToSend);
 return grpc::Status::OK;
   }
 
   grpc::Status FuzzyFind(grpc::ServerContext *Context,
  const FuzzyFindRequest *Request,
  grpc::ServerWriter *Reply) override {
+trace::Span Tracer(FuzzyFindRequest::descriptor()->name());
 auto Req = ProtobufMarshaller->fromProtobuf(Request);
 if (!Req) {
   elog("Can not parse FuzzyFindRequest from protobuf: {0}",
Req.takeError());
   return grpc::Status::CANCELLED;
 }
-bool HasMore = Index->fuzzyFind(*Req, [&](const clangd::Symbol ) {
-  auto SerializedSymbol = ProtobufMarshaller->toProtobuf(Sym);
-  if (!SerializedSymbol)
+unsigned Sent = 0;
+unsigned FailedToSend = 0;
+bool HasMore = Index->fuzzyFind(*Req, [&](const auto ) {
+  auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
+  if (!SerializedItem) {
+++FailedToSend;
 return;
+  }
   FuzzyFindReply NextMessage;
-  *NextMessage.mutable_stream_result() = *SerializedSymbol;
+  *NextMessage.mutable_stream_result() = *SerializedItem;
   Reply->Write(NextMessage);
+  ++Sent;
 });
 FuzzyFindReply LastMessage;
 LastMessage.set_final_result(HasMore);
 Reply->Write(LastMessage);
+SPAN_ATTACH(Tracer, "Sent", Sent);
+SPAN_ATTACH(Tracer, "Failed to send", FailedToSend);
 return grpc::Status::OK;
   }
 
   grpc::Status Refs(grpc::ServerContext *Context, const RefsRequest *Request,
 grpc::ServerWriter *Reply) override {
+trace::Span Tracer(RefsRequest::descriptor()->name());
 auto Req = ProtobufMarshaller->fromProtobuf(Request);
 if (!Req) {
   elog("Can not parse RefsRequest from protobuf: {0}", Req.takeError());
   return grpc::Status::CANCELLED;
 }
-bool HasMore = Index->refs(*Req, [&](const clangd::Ref ) {
-  auto SerializedRef = ProtobufMarshaller->toProtobuf(Reference);
-  if (!SerializedRef)
+unsigned Sent = 0;
+unsigned FailedToSend = 

[clang-tools-extra] 731043c - [clangd] Add more logs and attach tracers to remote index server routines

2020-07-27 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-07-27T20:45:18+02:00
New Revision: 731043c0c494672efe1eeea9ee0f0c7788813dea

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

LOG: [clangd] Add more logs and attach tracers to remote index server routines

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: sammccall, ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/Client.cpp
clang-tools-extra/clangd/index/remote/server/Server.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/Client.cpp 
b/clang-tools-extra/clangd/index/remote/Client.cpp
index 35ce84068f40..5a33fd2eaf14 100644
--- a/clang-tools-extra/clangd/index/remote/Client.cpp
+++ b/clang-tools-extra/clangd/index/remote/Client.cpp
@@ -37,12 +37,15 @@ class IndexClient : public clangd::SymbolIndex {
 bool FinalResult = false;
 trace::Span Tracer(RequestT::descriptor()->name());
 const auto RPCRequest = ProtobufMarshaller->toProtobuf(Request);
+SPAN_ATTACH(Tracer, "Request", RPCRequest.DebugString());
 grpc::ClientContext Context;
 std::chrono::system_clock::time_point Deadline =
 std::chrono::system_clock::now() + DeadlineWaitingTime;
 Context.set_deadline(Deadline);
 auto Reader = (Stub.get()->*RPCCall)(, RPCRequest);
 ReplyT Reply;
+unsigned Successful = 0;
+unsigned FailedToParse = 0;
 while (Reader->Read()) {
   if (!Reply.has_stream_result()) {
 FinalResult = Reply.final_result();
@@ -51,11 +54,15 @@ class IndexClient : public clangd::SymbolIndex {
   auto Response = ProtobufMarshaller->fromProtobuf(Reply.stream_result());
   if (!Response) {
 elog("Received invalid {0}", ReplyT::descriptor()->name());
+++FailedToParse;
 continue;
   }
   Callback(*Response);
+  ++Successful;
 }
-SPAN_ATTACH(Tracer, "status", Reader->Finish().ok());
+SPAN_ATTACH(Tracer, "Status", Reader->Finish().ok());
+SPAN_ATTACH(Tracer, "Successful", Successful);
+SPAN_ATTACH(Tracer, "Failed to parse", FailedToParse);
 return FinalResult;
   }
 

diff  --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp 
b/clang-tools-extra/clangd/index/remote/server/Server.cpp
index 7bf47a288e79..364e4db6503c 100644
--- a/clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -6,10 +6,13 @@
 //
 
//===--===//
 
+#include "Index.pb.h"
 #include "index/Index.h"
 #include "index/Serialization.h"
+#include "index/Symbol.h"
 #include "index/remote/marshalling/Marshalling.h"
 #include "support/Logger.h"
+#include "support/Trace.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Path.h"
@@ -36,6 +39,16 @@ llvm::cl::opt IndexPath(llvm::cl::desc(""),
 llvm::cl::opt IndexRoot(llvm::cl::desc(""),
  llvm::cl::Positional, llvm::cl::Required);
 
+llvm::cl::opt TraceFile(
+"trace-file",
+llvm::cl::desc("Path to the file where tracer logs will be stored"));
+
+llvm::cl::opt PrettyPrint{
+"pretty",
+llvm::cl::desc("Pretty-print JSON output in the trace"),
+llvm::cl::init(false),
+};
+
 llvm::cl::opt ServerAddress(
 "server-address", llvm::cl::init("0.0.0.0:50051"),
 llvm::cl::desc("Address of the invoked server. Defaults to 
0.0.0.0:50051"));
@@ -60,66 +73,90 @@ class RemoteIndexServer final : public SymbolIndex::Service 
{
   grpc::Status Lookup(grpc::ServerContext *Context,
   const LookupRequest *Request,
   grpc::ServerWriter *Reply) override {
+trace::Span Tracer(LookupRequest::descriptor()->name());
 auto Req = ProtobufMarshaller->fromProtobuf(Request);
 if (!Req) {
   elog("Can not parse LookupRequest from protobuf: {0}", Req.takeError());
   return grpc::Status::CANCELLED;
 }
-Index->lookup(*Req, [&](const clangd::Symbol ) {
-  auto SerializedSymbol = ProtobufMarshaller->toProtobuf(Sym);
-  if (!SerializedSymbol)
+unsigned Sent = 0;
+unsigned FailedToSend = 0;
+Index->lookup(*Req, [&](const auto ) {
+  auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
+  if (!SerializedItem) {
+++FailedToSend;
 return;
+  }
   LookupReply NextMessage;
-  *NextMessage.mutable_stream_result() = *SerializedSymbol;
+  *NextMessage.mutable_stream_result() = *SerializedItem;
   Reply->Write(NextMessage);
+  ++Sent;
 });
 LookupReply LastMessage;
 LastMessage.set_final_result(true);
 

[PATCH] D84499: [clangd] Add more logs and attach tracers to remote index server routines

2020-07-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 280997.
kbobyrev marked an inline comment as done.
kbobyrev added a comment.

Switch from llvm::errs() to elog()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84499

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/server/Server.cpp

Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -6,10 +6,13 @@
 //
 //===--===//
 
+#include "Index.pb.h"
 #include "index/Index.h"
 #include "index/Serialization.h"
+#include "index/Symbol.h"
 #include "index/remote/marshalling/Marshalling.h"
 #include "support/Logger.h"
+#include "support/Trace.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Path.h"
@@ -36,6 +39,16 @@
 llvm::cl::opt IndexRoot(llvm::cl::desc(""),
  llvm::cl::Positional, llvm::cl::Required);
 
+llvm::cl::opt TraceFile(
+"trace-file",
+llvm::cl::desc("Path to the file where tracer logs will be stored"));
+
+llvm::cl::opt PrettyPrint{
+"pretty",
+llvm::cl::desc("Pretty-print JSON output in the trace"),
+llvm::cl::init(false),
+};
+
 llvm::cl::opt ServerAddress(
 "server-address", llvm::cl::init("0.0.0.0:50051"),
 llvm::cl::desc("Address of the invoked server. Defaults to 0.0.0.0:50051"));
@@ -60,66 +73,90 @@
   grpc::Status Lookup(grpc::ServerContext *Context,
   const LookupRequest *Request,
   grpc::ServerWriter *Reply) override {
+trace::Span Tracer(LookupRequest::descriptor()->name());
 auto Req = ProtobufMarshaller->fromProtobuf(Request);
 if (!Req) {
   elog("Can not parse LookupRequest from protobuf: {0}", Req.takeError());
   return grpc::Status::CANCELLED;
 }
-Index->lookup(*Req, [&](const clangd::Symbol ) {
-  auto SerializedSymbol = ProtobufMarshaller->toProtobuf(Sym);
-  if (!SerializedSymbol)
+unsigned Sent = 0;
+unsigned FailedToSend = 0;
+Index->lookup(*Req, [&](const auto ) {
+  auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
+  if (!SerializedItem) {
+++FailedToSend;
 return;
+  }
   LookupReply NextMessage;
-  *NextMessage.mutable_stream_result() = *SerializedSymbol;
+  *NextMessage.mutable_stream_result() = *SerializedItem;
   Reply->Write(NextMessage);
+  ++Sent;
 });
 LookupReply LastMessage;
 LastMessage.set_final_result(true);
 Reply->Write(LastMessage);
+SPAN_ATTACH(Tracer, "Sent", Sent);
+SPAN_ATTACH(Tracer, "Failed to send", FailedToSend);
 return grpc::Status::OK;
   }
 
   grpc::Status FuzzyFind(grpc::ServerContext *Context,
  const FuzzyFindRequest *Request,
  grpc::ServerWriter *Reply) override {
+trace::Span Tracer(FuzzyFindRequest::descriptor()->name());
 auto Req = ProtobufMarshaller->fromProtobuf(Request);
 if (!Req) {
   elog("Can not parse FuzzyFindRequest from protobuf: {0}",
Req.takeError());
   return grpc::Status::CANCELLED;
 }
-bool HasMore = Index->fuzzyFind(*Req, [&](const clangd::Symbol ) {
-  auto SerializedSymbol = ProtobufMarshaller->toProtobuf(Sym);
-  if (!SerializedSymbol)
+unsigned Sent = 0;
+unsigned FailedToSend = 0;
+bool HasMore = Index->fuzzyFind(*Req, [&](const auto ) {
+  auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
+  if (!SerializedItem) {
+++FailedToSend;
 return;
+  }
   FuzzyFindReply NextMessage;
-  *NextMessage.mutable_stream_result() = *SerializedSymbol;
+  *NextMessage.mutable_stream_result() = *SerializedItem;
   Reply->Write(NextMessage);
+  ++Sent;
 });
 FuzzyFindReply LastMessage;
 LastMessage.set_final_result(HasMore);
 Reply->Write(LastMessage);
+SPAN_ATTACH(Tracer, "Sent", Sent);
+SPAN_ATTACH(Tracer, "Failed to send", FailedToSend);
 return grpc::Status::OK;
   }
 
   grpc::Status Refs(grpc::ServerContext *Context, const RefsRequest *Request,
 grpc::ServerWriter *Reply) override {
+trace::Span Tracer(RefsRequest::descriptor()->name());
 auto Req = ProtobufMarshaller->fromProtobuf(Request);
 if (!Req) {
   elog("Can not parse RefsRequest from protobuf: {0}", Req.takeError());
   return grpc::Status::CANCELLED;
 }
-bool HasMore = Index->refs(*Req, [&](const clangd::Ref ) {
-  auto SerializedRef = ProtobufMarshaller->toProtobuf(Reference);
-  if (!SerializedRef)
+unsigned Sent = 0;
+unsigned FailedToSend = 0;
+bool HasMore = Index->refs(*Req, [&](const 

[PATCH] D84499: [clangd] Add more logs and attach tracers to remote index server routines

2020-07-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev marked an inline comment as not done.
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:203
+  TracerStream.reset();
+  llvm::errs() << "Error while opening trace file " << TraceFile << ": "
+   << EC.message();

kadircet wrote:
> any reasons for not using elog in here (and in other places using 
> `llvm::errs()` ?
I think we tend to use `llvm::errs()` instead of logs in CLI tools 
(ClangdMain.cpp and particularly `TraceFile` handling were the inspiration and 
it uses `llvm::errs()` although there are many `elog`s there, too) and I'm a 
little confused about when to use either of those. Could you explain how those 
are chosen in each case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84499



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


[PATCH] D84499: [clangd] Add more logs and attach tracers to remote index server routines

2020-07-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 280993.
kbobyrev marked 2 inline comments as done.
kbobyrev added a comment.

Resolve all but 1 post-LGTM comment and rebase on top of master.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84499

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/server/Server.cpp

Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -6,10 +6,13 @@
 //
 //===--===//
 
+#include "Index.pb.h"
 #include "index/Index.h"
 #include "index/Serialization.h"
+#include "index/Symbol.h"
 #include "index/remote/marshalling/Marshalling.h"
 #include "support/Logger.h"
+#include "support/Trace.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Path.h"
@@ -36,6 +39,16 @@
 llvm::cl::opt IndexRoot(llvm::cl::desc(""),
  llvm::cl::Positional, llvm::cl::Required);
 
+llvm::cl::opt TraceFile(
+"trace-file",
+llvm::cl::desc("Path to the file where tracer logs will be stored"));
+
+llvm::cl::opt PrettyPrint{
+"pretty",
+llvm::cl::desc("Pretty-print JSON output in the trace"),
+llvm::cl::init(false),
+};
+
 llvm::cl::opt ServerAddress(
 "server-address", llvm::cl::init("0.0.0.0:50051"),
 llvm::cl::desc("Address of the invoked server. Defaults to 0.0.0.0:50051"));
@@ -60,66 +73,90 @@
   grpc::Status Lookup(grpc::ServerContext *Context,
   const LookupRequest *Request,
   grpc::ServerWriter *Reply) override {
+trace::Span Tracer(LookupRequest::descriptor()->name());
 auto Req = ProtobufMarshaller->fromProtobuf(Request);
 if (!Req) {
   elog("Can not parse LookupRequest from protobuf: {0}", Req.takeError());
   return grpc::Status::CANCELLED;
 }
-Index->lookup(*Req, [&](const clangd::Symbol ) {
-  auto SerializedSymbol = ProtobufMarshaller->toProtobuf(Sym);
-  if (!SerializedSymbol)
+unsigned Sent = 0;
+unsigned FailedToSend = 0;
+Index->lookup(*Req, [&](const auto ) {
+  auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
+  if (!SerializedItem) {
+++FailedToSend;
 return;
+  }
   LookupReply NextMessage;
-  *NextMessage.mutable_stream_result() = *SerializedSymbol;
+  *NextMessage.mutable_stream_result() = *SerializedItem;
   Reply->Write(NextMessage);
+  ++Sent;
 });
 LookupReply LastMessage;
 LastMessage.set_final_result(true);
 Reply->Write(LastMessage);
+SPAN_ATTACH(Tracer, "Sent", Sent);
+SPAN_ATTACH(Tracer, "Failed to send", FailedToSend);
 return grpc::Status::OK;
   }
 
   grpc::Status FuzzyFind(grpc::ServerContext *Context,
  const FuzzyFindRequest *Request,
  grpc::ServerWriter *Reply) override {
+trace::Span Tracer(FuzzyFindRequest::descriptor()->name());
 auto Req = ProtobufMarshaller->fromProtobuf(Request);
 if (!Req) {
   elog("Can not parse FuzzyFindRequest from protobuf: {0}",
Req.takeError());
   return grpc::Status::CANCELLED;
 }
-bool HasMore = Index->fuzzyFind(*Req, [&](const clangd::Symbol ) {
-  auto SerializedSymbol = ProtobufMarshaller->toProtobuf(Sym);
-  if (!SerializedSymbol)
+unsigned Sent = 0;
+unsigned FailedToSend = 0;
+bool HasMore = Index->fuzzyFind(*Req, [&](const auto ) {
+  auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
+  if (!SerializedItem) {
+++FailedToSend;
 return;
+  }
   FuzzyFindReply NextMessage;
-  *NextMessage.mutable_stream_result() = *SerializedSymbol;
+  *NextMessage.mutable_stream_result() = *SerializedItem;
   Reply->Write(NextMessage);
+  ++Sent;
 });
 FuzzyFindReply LastMessage;
 LastMessage.set_final_result(HasMore);
 Reply->Write(LastMessage);
+SPAN_ATTACH(Tracer, "Sent", Sent);
+SPAN_ATTACH(Tracer, "Failed to send", FailedToSend);
 return grpc::Status::OK;
   }
 
   grpc::Status Refs(grpc::ServerContext *Context, const RefsRequest *Request,
 grpc::ServerWriter *Reply) override {
+trace::Span Tracer(RefsRequest::descriptor()->name());
 auto Req = ProtobufMarshaller->fromProtobuf(Request);
 if (!Req) {
   elog("Can not parse RefsRequest from protobuf: {0}", Req.takeError());
   return grpc::Status::CANCELLED;
 }
-bool HasMore = Index->refs(*Req, [&](const clangd::Ref ) {
-  auto SerializedRef = ProtobufMarshaller->toProtobuf(Reference);
-  if (!SerializedRef)
+unsigned Sent = 0;
+unsigned FailedToSend = 0;
+bool HasMore = 

[PATCH] D84602: [MSP430] Expose msp430_builtin calling convention to C code

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

In D84602#2176584 , @rjmccall wrote:

> I don't have a problem with introducing a new convention even if it's only 
> used for "builtin" functions.


To be clear, I also don't have a problem with it, but if users aren't supposed 
to be writing this attribute themselves and if we can apply the calling 
convention from markings in a .def file instead, I think it could be a cleaner 
approach to go that route instead. There's a lot of "ifs" in that sentence 
though. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84602



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


[PATCH] D81865: [clang] Use string tables for static diagnostic descriptions

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

In D81865#2176148 , @froydnj wrote:

> In D81865#2176014 , @bkramer wrote:
>
> > Nice, those relocations have annoyed me for years. I'm worried about 
> > whether the way you're accessing StaticDiagInfoDescriptionStringTable might 
> > be undefined behavior. I won't block this change on that though.
>
>
> Is there somebody who should review that particular bit?  My understanding is 
> that it is OK, but my understanding of the C++ standard is not necessarily 
> complete, and I'd like to get a second opinion.


I believe this falls under the (using cppreference ( 
https://en.cppreference.com/w/cpp/language/union ) , since it's a bit easier to 
read) UB clause: " It's undefined behavior to read from the member of the union 
that wasn't most recently written. Many compilers implement, as a non-standard 
language extension, the ability to read inactive members of a union."

Last member written to was the "StringTable" member, but then it's read from 
the "String" member, so that'd be UB. Commonly supported, but UB - not sure if 
we have a general statement that we depend on this behavior in LLVM, even 
though it's non-standard (but it's possible that we do make such an assumption 
about the compiler that's building LLVM). It'd be nice to avoid that, though - 
and not too difficult, I think - I /believe/ it's valid to take a pointer to an 
object, cast it to char*, compute a pointer to some specific member and then 
cast it back to the right type and access. But I could be wrong there. @rsmith 
would be the person to give an authoritative answer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81865



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


[clang] b52b2e1 - Recommit "[libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given."

2020-07-27 Thread Dokyung Song via cfe-commits

Author: Dokyung Song
Date: 2020-07-27T18:27:49Z
New Revision: b52b2e1c188072e3cbc91500cfd503fb26d50ffc

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

LOG: Recommit "[libFuzzer] Disable implicit builtin knowledge about memcmp-like 
functions when -fsanitize=fuzzer-no-link is given."

Summary: This patch disables implicit builtin knowledge about memcmp-like 
functions when compiling the program for fuzzing, i.e., when 
-fsanitize=fuzzer(-no-link) is given. This allows libFuzzer to always intercept 
memcmp-like functions as it effectively disables optimizing calls to such 
functions into different forms. This is done by adding a set of flags 
(-fno-builtin-memcmp and others) in the clang driver. Individual -fno-builtin-* 
flags previously used in several libFuzzer tests are now removed, as it is now 
done automatically in the clang driver.

The patch was once reverted in 8ef9e2bf355d05bc81d8b0fe1e5333eec59a0a91, as 
this patch was dependent on a reverted commit 
f78d9fceea736d431e9e3cbca291e3909e3aa46d. This reverted commit was recommitted 
in 831ae45e3dc609e43ba561af07670a8fe47461ef, so relanding this dependent patch 
too.

Reviewers: morehouse, hctim

Subscribers: cfe-commits, #sanitizers

Tags: #clang, #sanitizers

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

Added: 
compiler-rt/test/fuzzer/noasan-bcmp.test

Modified: 
clang/lib/Driver/SanitizerArgs.cpp
compiler-rt/test/fuzzer/noasan-memcmp.test
compiler-rt/test/fuzzer/noasan-memcmp64.test
compiler-rt/test/fuzzer/noasan-strcmp.test
compiler-rt/test/fuzzer/noasan-strncmp.test
compiler-rt/test/fuzzer/noasan-strstr.test

Removed: 




diff  --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index e4fda752c041..8c49e92b2c0f 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -1088,6 +1088,23 @@ void SanitizerArgs::addArgs(const ToolChain , const 
llvm::opt::ArgList ,
   Sanitizers.has(SanitizerKind::Address))
 CmdArgs.push_back("-fno-assume-sane-operator-new");
 
+  // libFuzzer wants to intercept calls to certain library functions, so the
+  // following -fno-builtin-* flags force the compiler to emit interposable
+  // libcalls to these functions. Other sanitizers effectively do the same 
thing
+  // by marking all library call sites with NoBuiltin attribute in their LLVM
+  // pass. (see llvm::maybeMarkSanitizerLibraryCallNoBuiltin)
+  if (Sanitizers.has(SanitizerKind::FuzzerNoLink)) {
+CmdArgs.push_back("-fno-builtin-bcmp");
+CmdArgs.push_back("-fno-builtin-memcmp");
+CmdArgs.push_back("-fno-builtin-strncmp");
+CmdArgs.push_back("-fno-builtin-strcmp");
+CmdArgs.push_back("-fno-builtin-strncasecmp");
+CmdArgs.push_back("-fno-builtin-strcasecmp");
+CmdArgs.push_back("-fno-builtin-strstr");
+CmdArgs.push_back("-fno-builtin-strcasestr");
+CmdArgs.push_back("-fno-builtin-memmem");
+  }
+
   // Require -fvisibility= flag on non-Windows when compiling if vptr CFI is
   // enabled.
   if (Sanitizers.hasOneOf(CFIClasses) && !TC.getTriple().isOSWindows() &&

diff  --git a/compiler-rt/test/fuzzer/noasan-bcmp.test 
b/compiler-rt/test/fuzzer/noasan-bcmp.test
new file mode 100644
index ..a3dd17bf6e2b
--- /dev/null
+++ b/compiler-rt/test/fuzzer/noasan-bcmp.test
@@ -0,0 +1,4 @@
+UNSUPPORTED: darwin, freebsd, windows
+RUN: %cpp_compiler -fno-sanitize=address -DMEMCMP=bcmp %S/MemcmpTest.cpp -o %t
+RUN: not %run %t -seed=1 -runs=1000 2>&1 | FileCheck %s
+CHECK: BINGO

diff  --git a/compiler-rt/test/fuzzer/noasan-memcmp.test 
b/compiler-rt/test/fuzzer/noasan-memcmp.test
index c90755c53a90..c5ce2fff8c9f 100644
--- a/compiler-rt/test/fuzzer/noasan-memcmp.test
+++ b/compiler-rt/test/fuzzer/noasan-memcmp.test
@@ -1,9 +1,9 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp 
-o %t-NoAsanMemcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/MemcmpTest.cpp -o 
%t-NoAsanMemcmpTest
 RUN: not %run %t-NoAsanMemcmpTest -seed=1 -runs=1000   2>&1 | FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc 
-fno-builtin-memcmp %S/CustomAllocator.cpp %S/MemcmpTest.cpp -o 
%t-NoAsanCustomAllocatorMemcmpTest
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc 
%S/CustomAllocator.cpp %S/MemcmpTest.cpp -o %t-NoAsanCustomAllocatorMemcmpTest
 RUN: not %run %t-NoAsanCustomAllocatorMemcmpTest -seed=1 -runs=1000   2>&1 
| FileCheck %s
 
 CHECK: BINGO

diff  --git a/compiler-rt/test/fuzzer/noasan-memcmp64.test 
b/compiler-rt/test/fuzzer/noasan-memcmp64.test
index a6b8f88594d0..496ee386193e 100644
--- a/compiler-rt/test/fuzzer/noasan-memcmp64.test
+++ b/compiler-rt/test/fuzzer/noasan-memcmp64.test
@@ 

[PATCH] D83987: Recommit "[libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given."

2020-07-27 Thread Dokyung Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb52b2e1c1880: Recommit [libFuzzer] Disable implicit 
builtin knowledge about memcmp-like… (authored by dokyungs).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83987

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  compiler-rt/test/fuzzer/noasan-bcmp.test
  compiler-rt/test/fuzzer/noasan-memcmp.test
  compiler-rt/test/fuzzer/noasan-memcmp64.test
  compiler-rt/test/fuzzer/noasan-strcmp.test
  compiler-rt/test/fuzzer/noasan-strncmp.test
  compiler-rt/test/fuzzer/noasan-strstr.test

Index: compiler-rt/test/fuzzer/noasan-strstr.test
===
--- compiler-rt/test/fuzzer/noasan-strstr.test
+++ compiler-rt/test/fuzzer/noasan-strstr.test
@@ -1,9 +1,9 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp -o %t-NoAsanStrstrTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrstrTest.cpp -o %t-NoAsanStrstrTest
 RUN: not %run %t-NoAsanStrstrTest -seed=1 -runs=200   2>&1 | FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc -fno-builtin-strstr %S/CustomAllocator.cpp %S/StrstrTest.cpp -o %t-NoAsanCustomAllocatorStrstrTest
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc %S/CustomAllocator.cpp %S/StrstrTest.cpp -o %t-NoAsanCustomAllocatorStrstrTest
 RUN: not %run %t-NoAsanCustomAllocatorStrstrTest -seed=1 -runs=200   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/noasan-strncmp.test
===
--- compiler-rt/test/fuzzer/noasan-strncmp.test
+++ compiler-rt/test/fuzzer/noasan-strncmp.test
@@ -1,9 +1,9 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp %S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
 RUN: not %run %t-NoAsanStrncmpTest -seed=2 -runs=1000   2>&1 | FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc -fno-builtin-strncmp %S/CustomAllocator.cpp %S/StrncmpTest.cpp -o %t-NoAsanCustomAllocatorStrncmpTest
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc %S/CustomAllocator.cpp %S/StrncmpTest.cpp -o %t-NoAsanCustomAllocatorStrncmpTest
 RUN: not %run %t-NoAsanCustomAllocatorStrncmpTest -seed=2 -runs=1000   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/noasan-strcmp.test
===
--- compiler-rt/test/fuzzer/noasan-strcmp.test
+++ compiler-rt/test/fuzzer/noasan-strcmp.test
@@ -1,9 +1,9 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strcmp %S/StrcmpTest.cpp -o %t-NoAsanStrcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrcmpTest.cpp -o %t-NoAsanStrcmpTest
 RUN: not %run %t-NoAsanStrcmpTest -seed=1 -runs=200   2>&1 | FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc -fno-builtin-strcmp %S/CustomAllocator.cpp %S/StrcmpTest.cpp -o %t-NoAsanCustomAllocatorStrcmpTest
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc %S/CustomAllocator.cpp %S/StrcmpTest.cpp -o %t-NoAsanCustomAllocatorStrcmpTest
 RUN: not %run %t-NoAsanCustomAllocatorStrcmpTest -seed=1 -runs=200   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/noasan-memcmp64.test
===
--- compiler-rt/test/fuzzer/noasan-memcmp64.test
+++ compiler-rt/test/fuzzer/noasan-memcmp64.test
@@ -1,6 +1,6 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
+RUN: %cpp_compiler -fno-sanitize=address %S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
 RUN: not %run %t-NoAsanMemcmp64BytesTest -seed=1 -runs=100   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/noasan-memcmp.test
===
--- compiler-rt/test/fuzzer/noasan-memcmp.test
+++ compiler-rt/test/fuzzer/noasan-memcmp.test
@@ -1,9 +1,9 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp -o %t-NoAsanMemcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/MemcmpTest.cpp -o %t-NoAsanMemcmpTest
 RUN: not %run %t-NoAsanMemcmpTest -seed=1 -runs=1000   2>&1 | FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc -fno-builtin-memcmp %S/CustomAllocator.cpp %S/MemcmpTest.cpp -o %t-NoAsanCustomAllocatorMemcmpTest
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc %S/CustomAllocator.cpp %S/MemcmpTest.cpp -o %t-NoAsanCustomAllocatorMemcmpTest
 RUN: not %run 

[PATCH] D84602: [MSP430] Expose msp430_builtin calling convention to C code

2020-07-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Is there only one special calling convention, or is there any chance that 
different builtin functions would use different conventions?

I don't have a problem with introducing a new convention even if it's only used 
for "builtin" functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84602



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


[PATCH] D84602: [MSP430] Expose msp430_builtin calling convention to C code

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



Comment at: clang/include/clang/Basic/Attr.td:1465
+  let Spellings = [Clang<"msp430_builtin">];
+  let Documentation = [Undocumented];
+}

No new, undocumented attributes, please. Or is this attribute not expected to 
be used by users? (If it's not to be used by end users, is there a way we can 
skip exposing the attribute in the frontend and automatically generate the LLVM 
calling convention when lowering the builtin?)



Comment at: clang/lib/Basic/Targets/MSP430.h:100
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+switch (CC) {

I think the lint warning about the formatting is actually correct in this case 
(but not in the other cases, unfortunately).



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1233
 return llvm::dwarf::DW_CC_LLVM_X86RegCall;
+  // TODO case CC_MSP430Builtin:
   }

This is likely to cause -Werror failures because the switch won't be fully 
covered. Are you planning to do this TODO as part of this patch, or in a follow 
up?



Comment at: clang/test/Sema/attr-msp430.c:15
+
+__attribute__((msp430_builtin)) int t2; // expected-warning {{'msp430_builtin' 
only applies to function types; type here is 'int'}}
+__attribute__((msp430_builtin)) void f8(long long a, long long b);

Can you also add a sema test that the attribute accepts no arguments?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84602



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


[PATCH] D83987: Recommit "[libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given."

2020-07-27 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse accepted this revision.
morehouse added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83987



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


[PATCH] D83987: Recommit "[libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given."

2020-07-27 Thread Dokyung Song via Phabricator via cfe-commits
dokyungs updated this revision to Diff 280982.
dokyungs added a comment.

Disable noasan-bcmp.test on darwin.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83987

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  compiler-rt/test/fuzzer/noasan-bcmp.test
  compiler-rt/test/fuzzer/noasan-memcmp.test
  compiler-rt/test/fuzzer/noasan-memcmp64.test
  compiler-rt/test/fuzzer/noasan-strcmp.test
  compiler-rt/test/fuzzer/noasan-strncmp.test
  compiler-rt/test/fuzzer/noasan-strstr.test

Index: compiler-rt/test/fuzzer/noasan-strstr.test
===
--- compiler-rt/test/fuzzer/noasan-strstr.test
+++ compiler-rt/test/fuzzer/noasan-strstr.test
@@ -1,9 +1,9 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp -o %t-NoAsanStrstrTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrstrTest.cpp -o %t-NoAsanStrstrTest
 RUN: not %run %t-NoAsanStrstrTest -seed=1 -runs=200   2>&1 | FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc -fno-builtin-strstr %S/CustomAllocator.cpp %S/StrstrTest.cpp -o %t-NoAsanCustomAllocatorStrstrTest
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc %S/CustomAllocator.cpp %S/StrstrTest.cpp -o %t-NoAsanCustomAllocatorStrstrTest
 RUN: not %run %t-NoAsanCustomAllocatorStrstrTest -seed=1 -runs=200   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/noasan-strncmp.test
===
--- compiler-rt/test/fuzzer/noasan-strncmp.test
+++ compiler-rt/test/fuzzer/noasan-strncmp.test
@@ -1,9 +1,9 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp %S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
 RUN: not %run %t-NoAsanStrncmpTest -seed=2 -runs=1000   2>&1 | FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc -fno-builtin-strncmp %S/CustomAllocator.cpp %S/StrncmpTest.cpp -o %t-NoAsanCustomAllocatorStrncmpTest
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc %S/CustomAllocator.cpp %S/StrncmpTest.cpp -o %t-NoAsanCustomAllocatorStrncmpTest
 RUN: not %run %t-NoAsanCustomAllocatorStrncmpTest -seed=2 -runs=1000   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/noasan-strcmp.test
===
--- compiler-rt/test/fuzzer/noasan-strcmp.test
+++ compiler-rt/test/fuzzer/noasan-strcmp.test
@@ -1,9 +1,9 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strcmp %S/StrcmpTest.cpp -o %t-NoAsanStrcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrcmpTest.cpp -o %t-NoAsanStrcmpTest
 RUN: not %run %t-NoAsanStrcmpTest -seed=1 -runs=200   2>&1 | FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc -fno-builtin-strcmp %S/CustomAllocator.cpp %S/StrcmpTest.cpp -o %t-NoAsanCustomAllocatorStrcmpTest
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc %S/CustomAllocator.cpp %S/StrcmpTest.cpp -o %t-NoAsanCustomAllocatorStrcmpTest
 RUN: not %run %t-NoAsanCustomAllocatorStrcmpTest -seed=1 -runs=200   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/noasan-memcmp64.test
===
--- compiler-rt/test/fuzzer/noasan-memcmp64.test
+++ compiler-rt/test/fuzzer/noasan-memcmp64.test
@@ -1,6 +1,6 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
+RUN: %cpp_compiler -fno-sanitize=address %S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
 RUN: not %run %t-NoAsanMemcmp64BytesTest -seed=1 -runs=100   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/noasan-memcmp.test
===
--- compiler-rt/test/fuzzer/noasan-memcmp.test
+++ compiler-rt/test/fuzzer/noasan-memcmp.test
@@ -1,9 +1,9 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp -o %t-NoAsanMemcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/MemcmpTest.cpp -o %t-NoAsanMemcmpTest
 RUN: not %run %t-NoAsanMemcmpTest -seed=1 -runs=1000   2>&1 | FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc -fno-builtin-memcmp %S/CustomAllocator.cpp %S/MemcmpTest.cpp -o %t-NoAsanCustomAllocatorMemcmpTest
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc %S/CustomAllocator.cpp %S/MemcmpTest.cpp -o %t-NoAsanCustomAllocatorMemcmpTest
 RUN: not %run %t-NoAsanCustomAllocatorMemcmpTest -seed=1 -runs=1000   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: 

[PATCH] D83987: Recommit "[libFuzzer] Disable implicit builtin knowledge about memcmp-like functions when -fsanitize=fuzzer-no-link is given."

2020-07-27 Thread Dokyung Song via Phabricator via cfe-commits
dokyungs updated this revision to Diff 280981.
dokyungs added a comment.

Add '-fno-builtin-bcmp' and a corresponding test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83987

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  compiler-rt/test/fuzzer/noasan-bcmp.test
  compiler-rt/test/fuzzer/noasan-memcmp.test
  compiler-rt/test/fuzzer/noasan-memcmp64.test
  compiler-rt/test/fuzzer/noasan-strcmp.test
  compiler-rt/test/fuzzer/noasan-strncmp.test
  compiler-rt/test/fuzzer/noasan-strstr.test

Index: compiler-rt/test/fuzzer/noasan-strstr.test
===
--- compiler-rt/test/fuzzer/noasan-strstr.test
+++ compiler-rt/test/fuzzer/noasan-strstr.test
@@ -1,9 +1,9 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strstr %S/StrstrTest.cpp -o %t-NoAsanStrstrTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrstrTest.cpp -o %t-NoAsanStrstrTest
 RUN: not %run %t-NoAsanStrstrTest -seed=1 -runs=200   2>&1 | FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc -fno-builtin-strstr %S/CustomAllocator.cpp %S/StrstrTest.cpp -o %t-NoAsanCustomAllocatorStrstrTest
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc %S/CustomAllocator.cpp %S/StrstrTest.cpp -o %t-NoAsanCustomAllocatorStrstrTest
 RUN: not %run %t-NoAsanCustomAllocatorStrstrTest -seed=1 -runs=200   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/noasan-strncmp.test
===
--- compiler-rt/test/fuzzer/noasan-strncmp.test
+++ compiler-rt/test/fuzzer/noasan-strncmp.test
@@ -1,9 +1,9 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strncmp %S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrncmpTest.cpp -o %t-NoAsanStrncmpTest
 RUN: not %run %t-NoAsanStrncmpTest -seed=2 -runs=1000   2>&1 | FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc -fno-builtin-strncmp %S/CustomAllocator.cpp %S/StrncmpTest.cpp -o %t-NoAsanCustomAllocatorStrncmpTest
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc %S/CustomAllocator.cpp %S/StrncmpTest.cpp -o %t-NoAsanCustomAllocatorStrncmpTest
 RUN: not %run %t-NoAsanCustomAllocatorStrncmpTest -seed=2 -runs=1000   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/noasan-strcmp.test
===
--- compiler-rt/test/fuzzer/noasan-strcmp.test
+++ compiler-rt/test/fuzzer/noasan-strcmp.test
@@ -1,9 +1,9 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-strcmp %S/StrcmpTest.cpp -o %t-NoAsanStrcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/StrcmpTest.cpp -o %t-NoAsanStrcmpTest
 RUN: not %run %t-NoAsanStrcmpTest -seed=1 -runs=200   2>&1 | FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc -fno-builtin-strcmp %S/CustomAllocator.cpp %S/StrcmpTest.cpp -o %t-NoAsanCustomAllocatorStrcmpTest
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc %S/CustomAllocator.cpp %S/StrcmpTest.cpp -o %t-NoAsanCustomAllocatorStrcmpTest
 RUN: not %run %t-NoAsanCustomAllocatorStrcmpTest -seed=1 -runs=200   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/noasan-memcmp64.test
===
--- compiler-rt/test/fuzzer/noasan-memcmp64.test
+++ compiler-rt/test/fuzzer/noasan-memcmp64.test
@@ -1,6 +1,6 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
+RUN: %cpp_compiler -fno-sanitize=address %S/Memcmp64BytesTest.cpp -o %t-NoAsanMemcmp64BytesTest
 RUN: not %run %t-NoAsanMemcmp64BytesTest -seed=1 -runs=100   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: compiler-rt/test/fuzzer/noasan-memcmp.test
===
--- compiler-rt/test/fuzzer/noasan-memcmp.test
+++ compiler-rt/test/fuzzer/noasan-memcmp.test
@@ -1,9 +1,9 @@
 UNSUPPORTED: darwin, freebsd, windows
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp -o %t-NoAsanMemcmpTest
+RUN: %cpp_compiler -fno-sanitize=address %S/MemcmpTest.cpp -o %t-NoAsanMemcmpTest
 RUN: not %run %t-NoAsanMemcmpTest -seed=1 -runs=1000   2>&1 | FileCheck %s
 
-RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc -fno-builtin-memcmp %S/CustomAllocator.cpp %S/MemcmpTest.cpp -o %t-NoAsanCustomAllocatorMemcmpTest
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-calloc %S/CustomAllocator.cpp %S/MemcmpTest.cpp -o %t-NoAsanCustomAllocatorMemcmpTest
 RUN: not %run %t-NoAsanCustomAllocatorMemcmpTest -seed=1 -runs=1000   2>&1 | FileCheck %s
 
 CHECK: BINGO
Index: 

[PATCH] D84603: Thread safety analysis: More consistent warning message

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



Comment at: clang/lib/Analysis/ThreadSafety.cpp:1644
 if (!LDat) {
-  Analyzer->Handler.handleMutexNotHeld("", D, POK, Cp.toString(),
-   LK_Shared, Loc);
+  Analyzer->Handler.handleMutexNotHeld("negative capability", D, POK,
+   Cp.toString(), LK_Shared, Loc);

It's a bit odd that we aren't using `DiagKind` as below, I assume that's 
because this is a negative test and the others are positive tests, but doesn't 
this introduce a terminology difference where a positive failure may call it a 
mutex and a negative failure may call it a negative capability? Should this be 
hooked in to `ClassifyDiagnostic()` (perhaps we need a 
`ClassifyNegativeDiagnostic()`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84603



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


[PATCH] D82756: Port some floating point options to new option marshalling infrastructure

2020-07-27 Thread Daniel Grumberg via Phabricator via cfe-commits
dang marked an inline comment as done.
dang added inline comments.



Comment at: clang/test/CodeGen/fp-function-attrs.cpp:2
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -ffast-math -ffinite-math-only 
-menable-unsafe-fp-math \
+// RUN:   -menable-no-infs -menable-no-nans -fno-signed-zeros 
-freciprocal-math \
+// RUN:   -fapprox-func -mreassociate -ffp-contract=fast -emit-llvm -o - %s | 
FileCheck %s

Anastasia wrote:
> dang wrote:
> > Anastasia wrote:
> > > Not clear why do you need to pass these extra flags now?
> > Previously passing -ffast-math to CC1 implied all these other flags. I am 
> > trying to make CC1 option parsing as simple as possible, so that we can 
> > then make it easy to generate a command line from a CompilerInvocation 
> > instance. You can refer to [[ 
> > http://lists.llvm.org/pipermail/cfe-dev/2020-May/065421.html | 
> > http://lists.llvm.org/pipermail/cfe-dev/2020-May/065421.html ]] for more 
> > details on why we want to be able to do this
> Just to understand, there used to be implied flags and it made the manual 
> command line use of clang more compact and easy... Is the idea now to change 
> those compound flags such that individul flags always need to be passed?
> 
> Although I thought you are still adding the implicit flags:
> 
>   {options::OPT_cl_fast_relaxed_math,
>[&](const Arg *Arg) {
>  RenderArg(Arg);
> 
>  CmdArgs.push_back(GetArgString(options::OPT_cl_mad_enable));
>  CmdArgs.push_back(GetArgString(options::OPT_ffast_math));
>  CmdArgs.push_back(GetArgString(options::OPT_ffinite_math_only));
>  CmdArgs.push_back(
>  GetArgString(options::OPT_menable_unsafe_fp_math));
>  CmdArgs.push_back(GetArgString(options::OPT_mreassociate));
>  CmdArgs.push_back(GetArgString(options::OPT_menable_no_nans));
>  CmdArgs.push_back(
>  GetArgString(options::OPT_menable_no_infinities));
>  CmdArgs.push_back(GetArgString(options::OPT_fno_signed_zeros));
>  CmdArgs.push_back(GetArgString(options::OPT_freciprocal_math));
>  CmdArgs.push_back(GetArgString(options::OPT_fapprox_func));
>}}
> 
> Do I just misunderstand something?
The command line of the driver doesn't change. This patch only affects what CC1 
understands, now CC1 doesn't know anymore that `-cl-fast-relaxed-math` implies 
all these other options so the driver is responsible for specifying them when 
it constructs the CC1 command line.

To summarize, the clang driver command line isn't affected by this patch and it 
shouldn't be so let me know if something is wrong there. However, manually 
constructed `clang -cc1` invocations need to specify the all the implied flags 
manually now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82756



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


[PATCH] D83722: [PowerPC] Add options to control paired vector memops support

2020-07-27 Thread Amy Kwan via Phabricator via cfe-commits
amyk accepted this revision as: amyk.
amyk added a comment.
This revision is now accepted and ready to land.

This LGTM. Thanks for addressing the comments Baptiste.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83722



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


[PATCH] D83915: [PowerPC] Remove QPX/A2Q BGQ/BGP CNK support

2020-07-27 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel accepted this revision as: hfinkel.
hfinkel added a comment.
This revision is now accepted and ready to land.

LGTM. Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83915



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


[PATCH] D84678: [clang] False line number in a function definition with "void" parameter

2020-07-27 Thread Jaydeep Chauhan via Phabricator via cfe-commits
Jac1494 created this revision.
Jac1494 added a reviewer: rsmith.
Jac1494 added a project: clang.
Herald added a subscriber: cfe-commits.

This patch fixes  false line number in a function definition with "void" 
parameter.
For more details PR46417.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84678

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/void-argument.cpp


Index: clang/test/Sema/void-argument.cpp
===
--- /dev/null
+++ clang/test/Sema/void-argument.cpp
@@ -0,0 +1,15 @@
+// RUN: not %clang_cc1 %s 2>&1 | FileCheck %s
+
+// CHECK: void-argument.cpp:9:6: error: 'void' must be the first and only 
parameter if specified
+// CHECK: void-argument.cpp:12:7: error: 'void' must be the first and only 
parameter if specified
+// CHECK: void-argument.cpp:14:6: error: 'void' must be the first and only 
parameter if specified
+// CHECK: 3 errors generated.
+
+void foo (
+void a,
+double b,
+int c,
+void  d,
+int e,
+void f)
+{}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5109,7 +5109,7 @@
 // is an incomplete type (C99 6.2.5p19) and function decls cannot
 // have parameters of incomplete type.
 if (FTI.NumParams != 1 || FTI.isVariadic) {
-  S.Diag(DeclType.Loc, diag::err_void_only_param);
+  S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
   ParamTy = Context.IntTy;
   Param->setType(ParamTy);
 } else if (FTI.Params[i].Ident) {


Index: clang/test/Sema/void-argument.cpp
===
--- /dev/null
+++ clang/test/Sema/void-argument.cpp
@@ -0,0 +1,15 @@
+// RUN: not %clang_cc1 %s 2>&1 | FileCheck %s
+
+// CHECK: void-argument.cpp:9:6: error: 'void' must be the first and only parameter if specified
+// CHECK: void-argument.cpp:12:7: error: 'void' must be the first and only parameter if specified
+// CHECK: void-argument.cpp:14:6: error: 'void' must be the first and only parameter if specified
+// CHECK: 3 errors generated.
+
+void foo (
+void a,
+double b,
+int c,
+void  d,
+int e,
+void f)
+{}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5109,7 +5109,7 @@
 // is an incomplete type (C99 6.2.5p19) and function decls cannot
 // have parameters of incomplete type.
 if (FTI.NumParams != 1 || FTI.isVariadic) {
-  S.Diag(DeclType.Loc, diag::err_void_only_param);
+  S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
   ParamTy = Context.IntTy;
   Param->setType(ParamTy);
 } else if (FTI.Params[i].Ident) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84676: Add new diagnostic for invalid value provided for enum-based option

2020-07-27 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith.
Herald added projects: clang, LLVM.

This adds a more precise diagnostics for options that have a well defined set of
acceptable values.

Depends on D84675 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84676

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/debug-options.c
  clang/test/Driver/eabi.c
  clang/test/Driver/fveclib.c
  clang/test/Driver/reloc-model.c
  clang/test/Profile/c-generate.c
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -90,6 +90,7 @@
 struct SimpleEnumValueTable {
   const SimpleEnumValue *Table;
   unsigned Size;
+  const char *EnumValuesString;
 };
 )";
 
@@ -452,16 +453,21 @@
   OS << "#ifdef SIMPLE_ENUM_VALUE_TABLE";
   OS << "\n";
   OS << MarshallingInfo::ValueTablePreamble;
-  std::vector ValueTableNames;
+  std::vector> ValueTableDescs;
   for (const auto  : OptsWithMarshalling)
 if (auto MaybeValueTableName = KindInfo->emitValueTable(OS))
-  ValueTableNames.push_back(*MaybeValueTableName);
+  ValueTableDescs.push_back(
+  {*MaybeValueTableName, KindInfo->R.getValueAsString("Values")});
 
   OS << MarshallingInfo::ValueTablesDecl << "{";
-  for (auto ValueTableName : ValueTableNames)
-OS << "{" << ValueTableName << ", sizeof(" << ValueTableName
-   << ") / sizeof(SimpleEnumValue)"
-   << "},\n";
+  for (auto ValueTable : ValueTableDescs) {
+auto Name = ValueTable.first;
+auto ValuesString = ValueTable.second;
+OS << "{" << Name << ", sizeof(" << Name << ") / sizeof(SimpleEnumValue)"
+   << ", ";
+write_cstring(OS, ValuesString);
+OS << "},\n";
+  }
   OS << "};\n";
   OS << "static const unsigned SimpleEnumValueTablesSize = "
 "sizeof(SimpleEnumValueTables) / sizeof(SimpleEnumValueTable);\n";
Index: clang/test/Profile/c-generate.c
===
--- clang/test/Profile/c-generate.c
+++ clang/test/Profile/c-generate.c
@@ -7,7 +7,7 @@
 //
 // PROF-INSTR-NONE-NOT: __llvm_prf
 //
-// PROF-INSTR-GARBAGE: invalid value 'garbage' in '-fprofile-instrument=garbage'
+// PROF-INSTR-GARBAGE: invalid value 'garbage' in '-fprofile-instrument=garbage', expected one of none,clang,llvm,csllvm
 
 int main(void) {
   return 0;
Index: clang/test/Driver/reloc-model.c
===
--- clang/test/Driver/reloc-model.c
+++ clang/test/Driver/reloc-model.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -cc1 -mrelocation-model tinkywinky \
 // RUN: -emit-llvm %s 2>&1 | FileCheck -check-prefix CHECK-INVALID %s
 
-// CHECK-INVALID: error: invalid value 'tinkywinky' in '-mrelocation-model tinkywinky'
+// CHECK-INVALID: error: invalid value 'tinkywinky' in '-mrelocation-model tinkywinky', expected one of static,pic,ropi,rwpi,ropi-rwpi,dynamic-no-pic
Index: clang/test/Driver/fveclib.c
===
--- clang/test/Driver/fveclib.c
+++ clang/test/Driver/fveclib.c
@@ -7,7 +7,7 @@
 // CHECK-ACCELERATE: "-fveclib=Accelerate"
 // CHECK-MASSV: "-fveclib=MASSV"
 
-// CHECK-INVALID: error: invalid value 'something' in '-fveclib=something'
+// CHECK-INVALID: error: invalid value 'something' in '-fveclib=something', expected one of Accelerate,MASSV,SVML,none
 
 // RUN: %clang -fveclib=Accelerate %s -target arm64-apple-ios8.0.0 -### 2>&1 | FileCheck --check-prefix=CHECK-LINK %s
 // CHECK-LINK: "-framework" "Accelerate"
Index: clang/test/Driver/eabi.c
===
--- clang/test/Driver/eabi.c
+++ clang/test/Driver/eabi.c
@@ -10,4 +10,4 @@
 // CHECK-EABI4: "-meabi" "4"
 // CHECK-EABI5: "-meabi" "5"
 // CHECK-GNUEABI: "-meabi" "gnu"
-// CHECK-UNKNOWN: error: invalid value 'unknown' in '-meabi unknown'
+// CHECK-UNKNOWN: error: invalid value 'unknown' in '-meabi unknown', expected one of default,4,5,gnu
Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -342,7 +342,7 @@
 // GEXTREFS: "-debug-info-kind={{standalone|constructor}}"
 
 // RUN: not %clang -cc1 -debug-info-kind=watkind 2>&1 | FileCheck -check-prefix=BADSTRING1 %s
-// BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind'
+// BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind', expected one of line-tables-only,line-directives-only,constructor,limited,standalone
 // RUN: not %clang -cc1 -debugger-tuning=gmodal 2>&1 | FileCheck -check-prefix=BADSTRING2 %s
 // BADSTRING2: 

[PATCH] D84675: Streamline MarhsallingInfoFlag description

2020-07-27 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1, dexonsmith, 
aheejin.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, LLVM.

This replaces the existing `MarshallingInfoFlag` and `IsNegative` with simpler
`MarshalllingInfoFlag` and `MarshallingInfoNegativeFlag` mixins. This change
makes existing marshalling info specifications in Options.td easier to read.

Depends on D84674 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84675

Files:
  clang/include/clang/Driver/Options.td
  llvm/include/llvm/Option/OptParser.td

Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -164,20 +164,26 @@
   code Denormalizer = "denormalizeString";
 }
 
-class MarshallingInfoFlag
-  : MarshallingInfo {
+class MarshallingInfoFlag
+  : MarshallingInfo {
   code Normalizer = "normalizeSimpleFlag";
   code Denormalizer = "denormalizeSimpleFlag";
 }
 
-class MarshallingInfoBitfieldFlag : MarshallingInfoFlag {
+class MarshallingInfoNegativeFlag
+  : MarshallingInfo {
+  code Normalizer = "normalizeSimpleNegativeFlag";
+  code Denormalizer = "denormalizeSimpleFlag";
+}
+
+class MarshallingInfoBitfieldFlag : MarshallingInfo {
   code Normalizer = "(normalizeFlagToValue)";
   code ValueMerger = "mergeMaskValue";
   code ValueExtractor = "(extractMaskValue)";
 }
 
 class MarshallingInfoBooleanFlag
-  : MarshallingInfoFlag {
+  : MarshallingInfo {
   bit ShouldAlwaysEmit = 1;
   string MarshallingInfoKind = "BooleanFlag";
   code Normalizer = "normalizeBooleanFlag";
@@ -187,9 +193,7 @@
 
 // Mixins for additional marshalling attributes.
 
-class IsNegative {
-  code Normalizer = "normalizeSimpleNegativeFlag";
-}
+class DefaultValue { code DefaultValue = defaultvalue; }
 class AlwaysEmit { bit ShouldAlwaysEmit = 1; }
 class Normalizer { code Normalizer = normalizer; }
 class Denormalizer { code Denormalizer = denormalizer; }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -233,7 +233,7 @@
   string help="", list flags=[], code keypath=""> {
   def f#NAME : Flag<["-"], "f"#name>, Flags,
Group, HelpText,
-   MarshallingInfoFlag;
+   MarshallingInfoFlag;
   def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
Group, HelpText;
 }
@@ -246,7 +246,7 @@
Group, HelpText;
   def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
Group, HelpText,
-   MarshallingInfoFlag;
+   MarshallingInfoFlag;
 }
 
 multiclass BooleanMarshalledFFlag {
@@ -331,7 +331,7 @@
 // Comment Options
 
 def fparse_all_comments : Flag<["-"], "fparse-all-comments">, Group, Flags<[CC1Option]>,
-  MarshallingInfoFlag<"LangOpts->CommentOpts.ParseAllComments", "false">;
+  MarshallingInfoFlag<"LangOpts->CommentOpts.ParseAllComments">;
 
 // Filesystem Options FileSystemOpts
 
@@ -345,17 +345,18 @@
 
 def MV : Flag<["-"], "MV">, Group, Flags<[CC1Option]>,
 HelpText<"Use NMake/Jom format for the depfile">,
-MarshallingInfoFlag<"DependencyOutputOpts.OutputFormat", "DependencyOutputFormat::Make">,
+MarshallingInfoFlag<"DependencyOutputOpts.OutputFormat">,
+DefaultValue<"DependencyOutputFormat::Make">,
 Normalizer<"(normalizeFlagToValue)">;
 def H : Flag<["-"], "H">, Flags<[CC1Option]>, Group,
 HelpText<"Show header includes and nesting depth">,
-MarshallingInfoFlag<"DependencyOutputOpts.ShowHeaderIncludes", "false">;
+MarshallingInfoFlag<"DependencyOutputOpts.ShowHeaderIncludes">;
 def MG : Flag<["-"], "MG">, Group, Flags<[CC1Option]>,
 HelpText<"Add missing headers to depfile">,
-MarshallingInfoFlag<"DependencyOutputOpts.AddMissingHeaderDeps", "false">;
+MarshallingInfoFlag<"DependencyOutputOpts.AddMissingHeaderDeps">;
 def MP : Flag<["-"], "MP">, Group, Flags<[CC1Option]>,
 HelpText<"Create phony target for each dependency (other than main file)">,
-MarshallingInfoFlag<"DependencyOutputOpts.UsePhonyTargets", "false">;
+MarshallingInfoFlag<"DependencyOutputOpts.UsePhonyTargets">;
 
 def dependency_file : Separate<["-"], "dependency-file">, Flags<[CC1Option]>,
   HelpText<"Filename (or -) to write dependency output to">,
@@ -371,10 +372,10 @@
 
 def sys_header_deps : Flag<["-"], "sys-header-deps">,
   HelpText<"Include system headers in dependency output">,
-  MarshallingInfoFlag<"DependencyOutputOpts.IncludeSystemHeaders", "false">;
+  MarshallingInfoFlag<"DependencyOutputOpts.IncludeSystemHeaders">;
 def module_file_deps : Flag<["-"], "module-file-deps">,
   HelpText<"Include module files in dependency output">,
-  

[PATCH] D84674: Allow users to specify a conditional to prevent parsing options with MarshallingInfo

2020-07-27 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith.
Herald added projects: clang, LLVM.

Depends on D84673 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84674

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -66,6 +66,7 @@
   const char *MacroName;
   const Record 
   bool ShouldAlwaysEmit;
+  StringRef ShouldParse;
   StringRef KeyPath;
   StringRef DefaultValue;
   StringRef NormalizedValuesScope;
@@ -107,6 +108,8 @@
 OS << ", ";
 OS << ShouldAlwaysEmit;
 OS << ", ";
+OS << ShouldParse;
+OS << ", ";
 OS << KeyPath;
 OS << ", ";
 emitScopedNormalizedValue(OS, DefaultValue);
@@ -194,6 +197,7 @@
   }
 
   Ret->ShouldAlwaysEmit = R.getValueAsBit("ShouldAlwaysEmit");
+  Ret->ShouldParse = R.getValueAsString("ShouldParse");
   Ret->KeyPath = R.getValueAsString("KeyPath");
   Ret->DefaultValue = R.getValueAsString("DefaultValue");
   Ret->NormalizedValuesScope = R.getValueAsString("NormalizedValuesScope");
Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -102,6 +102,7 @@
   code KeyPath = ?;
   code DefaultValue = ?;
   bit ShouldAlwaysEmit = 0;
+  code ShouldParse = "true";
   code NormalizedValuesScope = "";
   code Normalizer = "";
   code Denormalizer = "";
@@ -201,6 +202,7 @@
 class ValueMerger { code ValueMerger = merger; }
 class ValueExtractor { code ValueExtractor = extractor; }
 class DiagnosticArg { bit IsDiagnosticArg = 1; }
+class ShouldParseIf { code ShouldParse = shouldparse; }
 
 // Predefined options.
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1260,9 +1260,9 @@
 
 #define DIAG_OPTION_WITH_MARSHALLING(  \
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
-HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
-NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  \
-  {\
+HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, SHOULD_PARSE, KEYPATH,   \
+DEFAULT_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)   \
+  if (SHOULD_PARSE) {  \
 if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags))  \
   Opts.KEYPATH = MERGER(Opts.KEYPATH,  \
 static_cast(*MaybeValue)); \
@@ -1272,10 +1272,10 @@
 
 #define DIAG_OPTION_WITH_MARSHALLING_BOOLEAN(  \
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
-HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
-NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,  \
-NEG_SPELLING)  \
-  {\
+HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, SHOULD_PARSE, KEYPATH,   \
+DEFAULT_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX,   \
+NEG_ID, NEG_SPELLING)  \
+  if (SHOULD_PARSE) {  \
 if (auto MaybeValue =  \
 NORMALIZER(OPT_##ID, OPT_##NEG_ID, TABLE_INDEX, Args, Diags))  \
   Opts.KEYPATH = MERGER(Opts.KEYPATH,  \
@@ -2065,21 +2065,6 @@
   }
 
   Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device);
-  if (Opts.SYCL) {
-// -sycl-std applies to any SYCL source, not only those containing kernels,
-// but also those using the SYCL API
-if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) {
-  Opts.SYCLVersion = llvm::StringSwitch(A->getValue())
- .Cases("2017", "1.2.1", "121", "sycl-1.2.1", 2017)
- .Default(0U);
-
-  if (Opts.SYCLVersion == 0U) {
-// User has passed an invalid value to the flag, this is an error
-Diags.Report(diag::err_drv_invalid_value)
-<< A->getAsString(Args) << 

[PATCH] D84673: Port DiagnosticOpts to new option parsing system

2020-07-27 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith.
Herald added projects: clang, LLVM.

DiagnosticOpts are special because the parsing is code is shared with
the driver. To ensure the code can still be shared this commit let's
diagnostic options be handled seperately so that the behavior of
ParseDiagnosticArgs can be preserved.

Depends on D84672 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84673

Files:
  clang/include/clang/Basic/DiagnosticOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -156,6 +156,9 @@
   MarshallingInfoBooleanFlag(const Record , const Record )
   : MarshallingInfo("OPTION_WITH_MARSHALLING_BOOLEAN", Option),
 NegOption(NegOption) {}
+  MarshallingInfoBooleanFlag(const char *MacroName, const Record ,
+ const Record )
+  : MarshallingInfo(MacroName, Option), NegOption(NegOption) {}
 
   void emit(raw_ostream ) const override {
 MarshallingInfo::emit(OS);
@@ -176,10 +179,18 @@
   MarshallingInfo::Ptr Ret;
   StringRef KindString = R.getValueAsString("MarshallingInfoKind");
   if (KindString == "Default") {
-Ret = std::make_unique(R);
+if (R.getValueAsBit("IsDiagnosticsArg"))
+  Ret =
+  std::make_unique("DIAG_OPTION_WITH_MARSHALLING", R);
+else
+  Ret = std::make_unique(R);
   } else if (KindString == "BooleanFlag") {
-Ret = std::make_unique(
-R, *R.getValueAsDef("NegOption"));
+const Record  = *R.getValueAsDef("NegOption");
+if (R.getValueAsBit("IsDiagnosticsArg"))
+  Ret = std::make_unique(
+  "DIAG_OPTION_WITH_MARSHALLING_BOOLEAN", R, NegOption);
+else
+  Ret = std::make_unique(R, NegOption);
   }
 
   Ret->ShouldAlwaysEmit = R.getValueAsBit("ShouldAlwaysEmit");
Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -98,6 +98,7 @@
   Option Alias = ?;
   list AliasArgs = [];
   string MarshallingInfoKind = ?;
+  bit IsDiagnosticsArg = 0;
   code KeyPath = ?;
   code DefaultValue = ?;
   bit ShouldAlwaysEmit = 0;
@@ -199,6 +200,7 @@
 }
 class ValueMerger { code ValueMerger = merger; }
 class ValueExtractor { code ValueExtractor = extractor; }
+class DiagnosticArg { bit IsDiagnosticArg = 1; }
 
 // Predefined options.
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -129,13 +129,13 @@
 static llvm::Optional normalizeSimpleFlag(OptSpecifier Opt,
 unsigned TableIndex,
 const ArgList ,
-DiagnosticsEngine ) {
+DiagnosticsEngine *Diags) {
   return Args.hasArg(Opt);
 }
 
 static llvm::Optional
 normalizeSimpleNegativeFlag(OptSpecifier Opt, unsigned TableIndex,
-const ArgList , DiagnosticsEngine ) {
+const ArgList , DiagnosticsEngine *Diags) {
   return !Args.hasArg(Opt);
 }
 
@@ -151,7 +151,7 @@
 template 
 static llvm::Optional
 normalizeFlagToValue(OptSpecifier Opt, unsigned TableIndex, const ArgList ,
- DiagnosticsEngine ) {
+ DiagnosticsEngine *Diags) {
   if (Args.hasArg(Opt))
 return Value;
   return None;
@@ -161,7 +161,7 @@
OptSpecifier NegOpt,
unsigned TableIndex,
const ArgList ,
-   DiagnosticsEngine ) {
+   DiagnosticsEngine *Diags) {
   if (const Arg *A = Args.getLastArg(PosOpt, NegOpt))
 return A->getOption().matches(PosOpt);
   return None;
@@ -180,7 +180,7 @@
 
 static Optional normalizeString(OptSpecifier Opt, int TableIndex,
  const ArgList ,
- DiagnosticsEngine ) {
+ DiagnosticsEngine *Diags) {
   auto *Arg = Args.getLastArg(Opt);
   if (!Arg)
 return None;
@@ -231,7 +231,7 @@
 static llvm::Optional normalizeSimpleEnum(OptSpecifier Opt,
 unsigned TableIndex,
 

[PATCH] D84672: Port PreprocessorOpts simple string based options to new option parsing system

2020-07-27 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

Depends on D84671 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84672

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2677,11 +2677,8 @@
 static void ParsePreprocessorArgs(PreprocessorOptions , ArgList ,
   DiagnosticsEngine ,
   frontend::ActionKind Action) {
-  Opts.ImplicitPCHInclude = std::string(Args.getLastArgValue(OPT_include_pch));
   Opts.PCHWithHdrStop = Args.hasArg(OPT_pch_through_hdrstop_create) ||
 Args.hasArg(OPT_pch_through_hdrstop_use);
-  Opts.PCHThroughHeader =
-  std::string(Args.getLastArgValue(OPT_pch_through_header_EQ));
 
   for (const auto *A : Args.filtered(OPT_error_on_deserialized_pch_decl))
 Opts.DeserializedPCHDeclsToErrorOn.insert(A->getValue());
@@ -2747,19 +2744,6 @@
 Opts.addRemappedFile(Split.first, Split.second);
   }
 
-  if (Arg *A = Args.getLastArg(OPT_fobjc_arc_cxxlib_EQ)) {
-StringRef Name = A->getValue();
-unsigned Library = llvm::StringSwitch(Name)
-  .Case("libc++", ARCXX_libcxx)
-  .Case("libstdc++", ARCXX_libstdcxx)
-  .Case("none", ARCXX_nolib)
-  .Default(~0U);
-if (Library == ~0U)
-  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << 
Name;
-else
-  Opts.ObjCXXARCStandardLibrary = (ObjCXXARCStandardLibraryKind)Library;
-  }
-
   // Always avoid lexing editor placeholders when we're just running the
   // preprocessor as we never want to emit the
   // "editor placeholder in source file" error in PP only mode.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1783,6 +1783,10 @@
   HelpText<"undef all system defines">,
   MarshallingInfoFlag<"PreprocessorOpts->UsePredefines", "true">, IsNegative;
 
+def include_pch : Separate<["-"], "include-pch">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Include precompiled header file">, MetaVarName<"">,
+  MarshallingInfoString<"PreprocessorOpts->ImplicitPCHInclude">;
+
 let Flags = [CC1Option, NoDriverOption] in {
 
 def pch_through_hdrstop_create : Flag<["-"], "pch-through-hdrstop-create">,
@@ -1807,6 +1811,15 @@
   HelpText<"Disable any #pragma clang __debug that can lead to crashing 
behavior. This is meant for testing.">,
   MarshallingInfoFlag<"PreprocessorOpts->DisablePragmaDebugCrash", "false">;
 
+def pch_through_header_EQ : Joined<["-"], "pch-through-header=">,
+  HelpText<"Stop PCH generation after including this file.  When using a PCH, "
+   "skip tokens until after this file is included.">,
+  MarshallingInfoString<"PreprocessorOpts->PCHThroughHeader">;
+def fobjc_arc_cxxlib_EQ : Joined<["-"], "fobjc-arc-cxxlib=">,
+  HelpText<"Objective-C++ Automatic Reference Counting standard library 
kind">, Values<"libc++,libstdc++,none">,
+  MarshallingInfoString<"PreprocessorOpts->ObjCXXARCStandardLibrary", 
"ARCXX_nolib">,
+  NormalizedValues<["ARCXX_libcxx", "ARCXX_libstdcxx", "ARCXX_nolib"]>, 
AutoNormalizeEnum; 
+
 } // Flags = [CC1Option, NoDriverOption]
 
 // Preprocessor Output Options
@@ -3034,8 +3047,6 @@
 def image__base : Separate<["-"], "image_base">;
 def include_ : JoinedOrSeparate<["-", "--"], "include">, Group, 
EnumName<"include">,
 MetaVarName<"">, HelpText<"Include file before parsing">, 
Flags<[CC1Option]>;
-def include_pch : Separate<["-"], "include-pch">, Group, 
Flags<[CC1Option]>,
-  HelpText<"Include precompiled header file">, MetaVarName<"">;
 def verify_pch : Flag<["-"], "verify-pch">, Group, 
Flags<[CC1Option]>,
   HelpText<"Load and verify that a pre-compiled header file is not stale">;
 def init : Separate<["-"], "init">;
@@ -4706,9 +4717,6 @@
 def fdump_record_layouts : Flag<["-"], "fdump-record-layouts">,
   HelpText<"Dump record layout information">;
 
-def pch_through_header_EQ : Joined<["-"], "pch-through-header=">,
-  HelpText<"Stop PCH generation after including this file.  When using a PCH, "
-   "skip tokens until after this file is included.">;
 def pch_through_hdrstop_use : Flag<["-"], "pch-through-hdrstop-use">,
   HelpText<"When using a PCH, skip tokens until after a #pragma hdrstop.">;
 
@@ -4721,8 +4729,6 @@
 
 def fno_wchar : Flag<["-"], "fno-wchar">,
   HelpText<"Disable C++ builtin type wchar_t">;
-def fobjc_arc_cxxlib_EQ : Joined<["-"], "fobjc-arc-cxxlib=">,
-  HelpText<"Objective-C++ Automatic Reference Counting standard library 
kind">, Values<"libc++,libstdc++,none">;
 def fobjc_runtime_has_weak 

[PATCH] D84671: Port LangOpts simple string based options to new option parsing system

2020-07-27 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, mgrang.
Herald added projects: clang, LLVM.

Depends on D84670 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84671

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -228,7 +228,8 @@
   // Get the option groups and options.
   const std::vector  =
 Records.getAllDerivedDefinitions("OptionGroup");
-  std::vector Opts = Records.getAllDerivedDefinitions("Option");
+  std::vector Opts = Records.getAllDerivedDefinitions("Option");
+  llvm::sort(Opts.begin(), Opts.end(), LessRecordByID());
 
   emitSourceFileHeader("Option Parsing Definitions", OS);
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -327,12 +327,36 @@
   LangOpts.OptimizeSize = CodeGenOpts.OptimizeSize != 0;
   LangOpts.ForceEmitVTables = CodeGenOpts.ForceEmitVTables;
   LangOpts.SpeculativeLoadHardening = CodeGenOpts.SpeculativeLoadHardening;
+  LangOpts.CurrentModule = LangOpts.ModuleName;
 
   llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes);
 
   if (LangOpts.AppleKext && !LangOpts.CPlusPlus)
 Diags.Report(diag::warn_c_kext);
 
+  if (LangOpts.NewAlignOverride &&
+  !llvm::isPowerOf2_32(LangOpts.NewAlignOverride)) {
+Arg *A = Args.getLastArg(OPT_fnew_alignment_EQ);
+Diags.Report(diag::err_fe_invalid_alignment)
+<< A->getAsString(Args) << A->getValue();
+LangOpts.NewAlignOverride = 0;
+  }
+
+  if (auto *Arg = Args.getLastArg(OPT_fdefault_calling_conv_EQ)) {
+llvm::Triple T(TargetOpts.Triple);
+llvm::Triple::ArchType Arch = T.getArch();
+auto DefaultCC = LangOpts.getDefaultCallingConv();
+bool emitError = (DefaultCC == LangOptions::DCC_FastCall ||
+  DefaultCC == LangOptions::DCC_StdCall) &&
+ Arch != llvm::Triple::x86;
+emitError |= (DefaultCC == LangOptions::DCC_VectorCall ||
+  DefaultCC == LangOptions::DCC_RegCall) &&
+ !T.isX86();
+if (emitError)
+  Diags.Report(diag::err_drv_argument_not_allowed_with)
+  << Arg->getSpelling() << T.getTriple();
+  }
+
   if (CodeGenOpts.ThreadModel != "posix" && CodeGenOpts.ThreadModel != "single")
 Diags.Report(diag::err_drv_invalid_value)
 << Args.getLastArg(OPT_mthread_model)->getAsString(Args)
@@ -2228,24 +2252,6 @@
   Opts.GNUInline = 1;
   }
 
-  if (const auto *A = Args.getLastArg(OPT_fcf_runtime_abi_EQ))
-Opts.CFRuntime =
-llvm::StringSwitch(A->getValue())
-.Cases("unspecified", "standalone", "objc",
-   LangOptions::CoreFoundationABI::ObjectiveC)
-.Cases("swift", "swift-5.0",
-   LangOptions::CoreFoundationABI::Swift5_0)
-.Case("swift-4.2", LangOptions::CoreFoundationABI::Swift4_2)
-.Case("swift-4.1", LangOptions::CoreFoundationABI::Swift4_1)
-.Default(LangOptions::CoreFoundationABI::ObjectiveC);
-
-  // The value-visibility mode defaults to "default".
-  if (Arg *visOpt = Args.getLastArg(OPT_fvisibility)) {
-Opts.setValueVisibilityMode(parseVisibility(visOpt, Args, Diags));
-  } else {
-Opts.setValueVisibilityMode(DefaultVisibility);
-  }
-
   // The type-visibility mode defaults to the value-visibility mode.
   if (Arg *typeVisOpt = Args.getLastArg(OPT_ftype_visibility)) {
 Opts.setTypeVisibilityMode(parseVisibility(typeVisOpt, Args, Diags));
@@ -2285,20 +2291,6 @@
   Opts.DollarIdents = Args.hasFlag(OPT_fdollars_in_identifiers,
OPT_fno_dollars_in_identifiers,
Opts.DollarIdents);
-  Opts.setVtorDispMode(
-  MSVtorDispMode(getLastArgIntValue(Args, OPT_vtordisp_mode_EQ, 1, Diags)));
-  if (Arg *A = Args.getLastArg(OPT_flax_vector_conversions_EQ)) {
-using LaxKind = LangOptions::LaxVectorConversionKind;
-if (auto Kind = llvm::StringSwitch>(A->getValue())
-.Case("none", LaxKind::None)
-.Case("integer", LaxKind::Integer)
-.Case("all", LaxKind::All)
-.Default(llvm::None))
-  Opts.setLaxVectorConversions(*Kind);
-else
-  Diags.Report(diag::err_drv_invalid_value)
-  << A->getAsString(Args) << A->getValue();
-  }
 
   // -ffixed-point
   Opts.FixedPoint =
@@ -2352,15 +2344,6 @@
   Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char);
   Opts.WChar = Opts.CPlusPlus && 

[PATCH] D84670: Port HeaderSearch simple string options to new option parsing system

2020-07-27 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

Depends on D84669 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84670

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1678,10 +1678,8 @@
 
 static void ParseHeaderSearchArgs(HeaderSearchOptions , ArgList ,
   const std::string ) {
-  Opts.Sysroot = std::string(Args.getLastArgValue(OPT_isysroot, "/"));
   if (const Arg *A = Args.getLastArg(OPT_stdlib_EQ))
 Opts.UseLibcxx = (strcmp(A->getValue(), "libc++") == 0);
-  Opts.ResourceDir = std::string(Args.getLastArgValue(OPT_resource_dir));
 
   // Canonicalize -fmodules-cache-path before storing it.
   SmallString<128> P(Args.getLastArgValue(OPT_fmodules_cache_path));
@@ -1694,8 +1692,6 @@
   llvm::sys::path::remove_dots(P);
   Opts.ModuleCachePath = std::string(P.str());
 
-  Opts.ModuleUserBuildPath =
-  std::string(Args.getLastArgValue(OPT_fmodules_user_build_path));
   // Only the -fmodule-file== form.
   for (const auto *A : Args.filtered(OPT_fmodule_file)) {
 StringRef Val = A->getValue();
@@ -1707,14 +1703,6 @@
   }
   for (const auto *A : Args.filtered(OPT_fprebuilt_module_path))
 Opts.AddPrebuiltModulePath(A->getValue());
-  Opts.ModuleCachePruneInterval =
-  getLastArgIntValue(Args, OPT_fmodules_prune_interval, 7 * 24 * 60 * 60);
-  Opts.ModuleCachePruneAfter =
-  getLastArgIntValue(Args, OPT_fmodules_prune_after, 31 * 24 * 60 * 60);
-  Opts.BuildSessionTimestamp =
-  getLastArgUInt64Value(Args, OPT_fbuild_session_timestamp, 0);
-  if (const Arg *A = Args.getLastArg(OPT_fmodule_format_EQ))
-Opts.ModuleFormat = A->getValue();
 
   for (const auto *A : Args.filtered(OPT_fmodules_ignore_macro)) {
 StringRef MacroDef = A->getValue();
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1279,6 +1279,30 @@
   HelpText<"Show commands to run and use verbose output">,
   MarshallingInfoFlag<"HeaderSearchOpts->Verbose", "false">;
 
+def fmodules_user_build_path : Separate<["-"], "fmodules-user-build-path">, Group,
+  Flags<[DriverOption, CC1Option]>, MetaVarName<"">,
+  HelpText<"Specify the module user build path">,
+  MarshallingInfoString<"HeaderSearchOpts->ModuleUserBuildPath">;
+def fmodules_prune_interval : Joined<["-"], "fmodules-prune-interval=">, Group,
+  Flags<[CC1Option]>, MetaVarName<"">,
+  HelpText<"Specify the interval (in seconds) between attempts to prune the module cache">,
+  MarshallingInfoStringInt<"HeaderSearchOpts->ModuleCachePruneInterval", "7 * 24 * 60 * 60">;
+def fmodules_prune_after : Joined<["-"], "fmodules-prune-after=">, Group,
+  Flags<[CC1Option]>, MetaVarName<"">,
+  HelpText<"Specify the interval (in seconds) after which a module file will be considered unused">,
+  MarshallingInfoStringInt<"HeaderSearchOpts->ModuleCachePruneAfter", "31 * 24 *60 * 60">;
+def fbuild_session_timestamp : Joined<["-"], "fbuild-session-timestamp=">,
+  Group, Flags<[CC1Option]>, MetaVarName<"">,
+  HelpText<"Time when the current build session started">,
+  MarshallingInfoStringInt<"HeaderSearchOpts->BuildSessionTimestamp">;
+def isysroot : JoinedOrSeparate<["-"], "isysroot">, Group, Flags<[CC1Option]>,
+  HelpText<"Set the system root directory (usually /)">, MetaVarName<"">,
+  MarshallingInfoString<"HeaderSearchOpts->Sysroot", [{std::string("/")}]>;
+def resource_dir : Separate<["-"], "resource-dir">,
+  Flags<[DriverOption, CC1Option, CoreOption, HelpHidden]>,
+  HelpText<"The directory which holds the compiler resource files">,
+  MarshallingInfoString<"HeaderSearchOpts->ResourceDir">;
+
 let Flags = [CC1Option, NoDriverOption] in {
 
 def fmodule_map_file_home_is_cwd : Flag<["-"], "fmodule-map-file-home-is-cwd">,
@@ -1299,6 +1323,11 @@
"semantics of a module in an implicit build">,
   MarshallingInfoFlag<"HeaderSearchOpts->ModulesStrictContextHash", "false">;
 
+def fmodule_format_EQ : Joined<["-"], "fmodule-format=">,
+  HelpText<"Select the container format for clang modules and PCH. "
+   "Supported options are 'raw' and 'obj'.">,
+  MarshallingInfoString<"HeaderSearchOpts->ModuleFormat", [{std::string("raw")}]>;
+
 } // Flags = [CC1Option, NoDriverOption]
 
 // Language Options
@@ -2443,24 +2472,12 @@
 def fmodules_cache_path : Joined<["-"], "fmodules-cache-path=">, Group,
   Flags<[DriverOption, CC1Option]>, MetaVarName<"">,
   HelpText<"Specify the module cache path">;
-def fmodules_user_build_path : Separate<["-"], "fmodules-user-build-path">, Group,
-  

  1   2   3   >