[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-15 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

I checked in a fix in https://reviews.llvm.org/rGfc8200633122, but I haven't 
yet verified it addresses all the failures reported.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

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


[PATCH] D87673: [clangd] Don't use zlib when it's unavailable.

2020-09-15 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 292116.
ArcsinX added a comment.

Remove {}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87673

Files:
  clang-tools-extra/clangd/index/Serialization.cpp


Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -201,12 +201,13 @@
   llvm::SmallString<1> UncompressedStorage;
   if (UncompressedSize == 0) // No compression
 Uncompressed = R.rest();
-  else {
+  else if (llvm::zlib::isAvailable()) {
 if (llvm::Error E = llvm::zlib::uncompress(R.rest(), UncompressedStorage,
UncompressedSize))
   return std::move(E);
 Uncompressed = UncompressedStorage;
-  }
+  } else
+return error("Compressed string table, but zlib is unavailable");
 
   StringTableIn Table;
   llvm::StringSaver Saver(Table.Arena);


Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -201,12 +201,13 @@
   llvm::SmallString<1> UncompressedStorage;
   if (UncompressedSize == 0) // No compression
 Uncompressed = R.rest();
-  else {
+  else if (llvm::zlib::isAvailable()) {
 if (llvm::Error E = llvm::zlib::uncompress(R.rest(), UncompressedStorage,
UncompressedSize))
   return std::move(E);
 Uncompressed = UncompressedStorage;
-  }
+  } else
+return error("Compressed string table, but zlib is unavailable");
 
   StringTableIn Table;
   llvm::StringSaver Saver(Table.Arena);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78902: [Driver] Add output file to properties of Command

2020-09-15 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a reviewer: jyknight.
sepavloff added a comment.

This change is similar to D82782 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78902

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


[PATCH] D78899: [Driver] Add callback to Command execution

2020-09-15 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 292113.
sepavloff added a comment.

Rebased patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78899

Files:
  clang/include/clang/Driver/Compilation.h
  clang/lib/Driver/Compilation.cpp
  clang/unittests/Driver/ToolChainTest.cpp


Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -259,4 +259,29 @@
   EXPECT_STREQ(Res.DriverMode, "--driver-mode=cl");
   EXPECT_FALSE(Res.TargetIsValid);
 }
+
+TEST(ToolChainTest, PostCallback) {
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+  struct TestDiagnosticConsumer : public DiagnosticConsumer {};
+  DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
+  IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+
+  // The executable path must not exist.
+  Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
+  "clang LLVM compiler", InMemoryFileSystem);
+  CCDriver.setCheckInputsExist(false);
+  std::unique_ptr CC(
+  CCDriver.BuildCompilation({"/home/test/bin/clang", "foo.cpp"}));
+  bool CallbackHasCalled = false;
+  CC->setPostCallback(
+  [&](const Command &C, int Ret) { CallbackHasCalled = true; });
+  const JobList &Jobs = CC->getJobs();
+  auto &CmdCompile = Jobs.getJobs().front();
+  const Command *FailingCmd = nullptr;
+  CC->ExecuteCommand(*CmdCompile, FailingCmd);
+  EXPECT_TRUE(CallbackHasCalled);
+}
+
 } // end anonymous namespace.
Index: clang/lib/Driver/Compilation.cpp
===
--- clang/lib/Driver/Compilation.cpp
+++ clang/lib/Driver/Compilation.cpp
@@ -193,6 +193,8 @@
   std::string Error;
   bool ExecutionFailed;
   int Res = C.Execute(Redirects, &Error, &ExecutionFailed);
+  if (PostCallback)
+PostCallback(C, Res);
   if (!Error.empty()) {
 assert(Res && "Error string set with 0 result code!");
 getDriver().Diag(diag::err_drv_command_failure) << Error;
Index: clang/include/clang/Driver/Compilation.h
===
--- clang/include/clang/Driver/Compilation.h
+++ clang/include/clang/Driver/Compilation.h
@@ -115,6 +115,9 @@
   /// Optional redirection for stdin, stdout, stderr.
   std::vector> Redirects;
 
+  /// Callback called after the command has been executed.
+  std::function PostCallback;
+
   /// Whether we're compiling for diagnostic purposes.
   bool ForDiagnostics = false;
 
@@ -212,6 +215,10 @@
 return FailureResultFiles;
   }
 
+  void setPostCallback(const std::function &CB) {
+PostCallback = CB;
+  }
+
   /// Returns the sysroot path.
   StringRef getSysRoot() const;
 


Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -259,4 +259,29 @@
   EXPECT_STREQ(Res.DriverMode, "--driver-mode=cl");
   EXPECT_FALSE(Res.TargetIsValid);
 }
+
+TEST(ToolChainTest, PostCallback) {
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+  struct TestDiagnosticConsumer : public DiagnosticConsumer {};
+  DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
+  IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+
+  // The executable path must not exist.
+  Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
+  "clang LLVM compiler", InMemoryFileSystem);
+  CCDriver.setCheckInputsExist(false);
+  std::unique_ptr CC(
+  CCDriver.BuildCompilation({"/home/test/bin/clang", "foo.cpp"}));
+  bool CallbackHasCalled = false;
+  CC->setPostCallback(
+  [&](const Command &C, int Ret) { CallbackHasCalled = true; });
+  const JobList &Jobs = CC->getJobs();
+  auto &CmdCompile = Jobs.getJobs().front();
+  const Command *FailingCmd = nullptr;
+  CC->ExecuteCommand(*CmdCompile, FailingCmd);
+  EXPECT_TRUE(CallbackHasCalled);
+}
+
 } // end anonymous namespace.
Index: clang/lib/Driver/Compilation.cpp
===
--- clang/lib/Driver/Compilation.cpp
+++ clang/lib/Driver/Compilation.cpp
@@ -193,6 +193,8 @@
   std::string Error;
   bool ExecutionFailed;
   int Res = C.Execute(Redirects, &Error, &ExecutionFailed);
+  if (PostCallback)
+PostCallback(C, Res);
   if (!Error.empty()) {
 assert(Res && "Error string set with 0 result code!");
 getDriver().Diag(diag::err_drv_command_failure) << Error;
Index: clang/include/clang/Driver/Compilation.h
===
--- clang/include/clang/Driver/Compilation.h
+

[clang] 8ea7ef8 - [ThinLTO] Relax thinlto_embed_bitcode.ll check

2020-09-15 Thread Mircea Trofin via cfe-commits

Author: Mircea Trofin
Date: 2020-09-15T22:42:22-07:00
New Revision: 8ea7ef8eda93aa144c339275fc6d9db2615a0118

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

LOG: [ThinLTO] Relax thinlto_embed_bitcode.ll check

Fixes fuscia test [1] - the thinlto annotations may not always be there.

[1] http://lab.llvm.org:8011/builders/fuchsia-x86_64-linux/builds/11312

Added: 


Modified: 
clang/test/CodeGen/thinlto_embed_bitcode.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto_embed_bitcode.ll 
b/clang/test/CodeGen/thinlto_embed_bitcode.ll
index 4efb525e5f3e..2d60e16e54e1 100644
--- a/clang/test/CodeGen/thinlto_embed_bitcode.ll
+++ b/clang/test/CodeGen/thinlto_embed_bitcode.ll
@@ -26,5 +26,5 @@
 ; CHECK:  define void @foo() 
 ; CHECK-OPT-NEXT:   ret void
 ; CHECK-NOOPT-NEXT: call void @bar()
-; CHECK-NOOPT: define available_externally void @bar() !thinlto_src_module !0 {
+; CHECK-NOOPT: define available_externally void @bar()
 ; CHECK-NOOPT-NEXT: ret void



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


[libclc] 291bfff - libclc: Add a __builtin to let SPIRV targets select between SW and HW FMA

2020-09-15 Thread Jan Vesely via cfe-commits

Author: Daniel Stone
Date: 2020-09-16T01:37:22-04:00
New Revision: 291bfff5dbb70360730e91b4019f8080e4e3d7f5

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

LOG: libclc: Add a __builtin to let SPIRV targets select between SW and HW FMA

Reviewer: jenatali jvesely
Differential Revision: https://reviews.llvm.org/D85910

Added: 


Modified: 
libclc/generic/lib/math/math.h
libclc/spirv/lib/math/fma.cl
libclc/spirv64/lib/math/fma.cl

Removed: 




diff  --git a/libclc/generic/lib/math/math.h b/libclc/generic/lib/math/math.h
index c931d19a380c..351e37dc3f12 100644
--- a/libclc/generic/lib/math/math.h
+++ b/libclc/generic/lib/math/math.h
@@ -40,6 +40,9 @@
 
 #if (defined __AMDGCN__ || defined __R600__) && !defined __HAS_FMAF__
 #define HAVE_HW_FMA32() (0)
+#elif defined CLC_SPIRV || defined CLC_SPIRV64
+bool __attribute__((noinline)) __clc_runtime_has_hw_fma32(void);
+#define HAVE_HW_FMA32() __clc_runtime_has_hw_fma32()
 #else
 #define HAVE_HW_FMA32() (1)
 #endif

diff  --git a/libclc/spirv/lib/math/fma.cl b/libclc/spirv/lib/math/fma.cl
index 982ddc4374f3..79142425e52d 100644
--- a/libclc/spirv/lib/math/fma.cl
+++ b/libclc/spirv/lib/math/fma.cl
@@ -4,3 +4,8 @@
 #define __CLC_BODY 
 #define __FLOAT_ONLY
 #include 
+
+bool __clc_runtime_has_hw_fma32()
+{
+return false;
+}

diff  --git a/libclc/spirv64/lib/math/fma.cl b/libclc/spirv64/lib/math/fma.cl
index 982ddc4374f3..79142425e52d 100644
--- a/libclc/spirv64/lib/math/fma.cl
+++ b/libclc/spirv64/lib/math/fma.cl
@@ -4,3 +4,8 @@
 #define __CLC_BODY 
 #define __FLOAT_ONLY
 #include 
+
+bool __clc_runtime_has_hw_fma32()
+{
+return false;
+}



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


[PATCH] D87627: [clang-tidy] Fix crash in modernize-use-noexcept on uninstantiated throw class

2020-09-15 Thread Zinovy Nis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG96c6d012dfe2: [clang-tidy] Fix crash in 
modernize-use-noexcept on uninstantiated throw class (authored by zinovy.nis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87627

Files:
  clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
@@ -4,6 +4,7 @@
 // This test is not run in C++17 or later because dynamic exception
 // specifications were removed in C++17.
 
+using size_t = __SIZE_TYPE__;
 class A {};
 class B {};
 
@@ -19,6 +20,11 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 
'throw(int(int))' is deprecated; consider removing it instead 
[modernize-use-noexcept]
 // CHECK-FIXES: void k() ;
 
+// Shouldn't crash due to llvm_unreachable in canThrow() on EST_Uninstantiated
+template  class c { void *operator new(size_t) throw (int);};
+void s() { c<1> doesnt_crash; }
+// CHECK-MESSAGES: :[[@LINE-2]]:53: warning: dynamic exception specification 
'throw (int)' is deprecated; consider removing it instead 
[modernize-use-noexcept]
+
 void foobar() throw(A, B)
 {}
 // CHECK-MESSAGES: :[[@LINE-2]]:15: warning: dynamic exception specification 
'throw(A, B)' is deprecated; consider removing it instead 
[modernize-use-noexcept]
Index: clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
@@ -77,13 +77,16 @@
   .getExceptionSpecRange();
   }
 
+  assert(FnTy && "FunctionProtoType is null.");
+  if (isUnresolvedExceptionSpec(FnTy->getExceptionSpecType()))
+return;
+
   assert(Range.isValid() && "Exception Source Range is invalid.");
 
   CharSourceRange CRange = Lexer::makeFileCharRange(
   CharSourceRange::getTokenRange(Range), *Result.SourceManager,
   Result.Context->getLangOpts());
 
-  assert(FnTy && "FunctionProtoType is null.");
   bool IsNoThrow = FnTy->isNothrow();
   StringRef ReplacementStr =
   IsNoThrow


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
@@ -4,6 +4,7 @@
 // This test is not run in C++17 or later because dynamic exception
 // specifications were removed in C++17.
 
+using size_t = __SIZE_TYPE__;
 class A {};
 class B {};
 
@@ -19,6 +20,11 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int))' is deprecated; consider removing it instead [modernize-use-noexcept]
 // CHECK-FIXES: void k() ;
 
+// Shouldn't crash due to llvm_unreachable in canThrow() on EST_Uninstantiated
+template  class c { void *operator new(size_t) throw (int);};
+void s() { c<1> doesnt_crash; }
+// CHECK-MESSAGES: :[[@LINE-2]]:53: warning: dynamic exception specification 'throw (int)' is deprecated; consider removing it instead [modernize-use-noexcept]
+
 void foobar() throw(A, B)
 {}
 // CHECK-MESSAGES: :[[@LINE-2]]:15: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider removing it instead [modernize-use-noexcept]
Index: clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
@@ -77,13 +77,16 @@
   .getExceptionSpecRange();
   }
 
+  assert(FnTy && "FunctionProtoType is null.");
+  if (isUnresolvedExceptionSpec(FnTy->getExceptionSpecType()))
+return;
+
   assert(Range.isValid() && "Exception Source Range is invalid.");
 
   CharSourceRange CRange = Lexer::makeFileCharRange(
   CharSourceRange::getTokenRange(Range), *Result.SourceManager,
   Result.Context->getLangOpts());
 
-  assert(FnTy && "FunctionProtoType is null.");
   bool IsNoThrow = FnTy->isNothrow();
   StringRef ReplacementStr =
   IsNoThrow
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 96c6d01 - [clang-tidy] Fix crash in modernize-use-noexcept on uninstantiated throw class

2020-09-15 Thread Zinovy Nis via cfe-commits

Author: Zinovy Nis
Date: 2020-09-16T08:13:00+03:00
New Revision: 96c6d012dfe2492891d0f0450dd7cd5f3c1ca88c

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

LOG: [clang-tidy] Fix crash in modernize-use-noexcept on uninstantiated throw 
class

Bug: https://bugs.llvm.org/show_bug.cgi?id=47446

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
index cc4bc05a35dd..c4e7f12e74ac 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
@@ -77,13 +77,16 @@ void UseNoexceptCheck::check(const MatchFinder::MatchResult 
&Result) {
   .getExceptionSpecRange();
   }
 
+  assert(FnTy && "FunctionProtoType is null.");
+  if (isUnresolvedExceptionSpec(FnTy->getExceptionSpecType()))
+return;
+
   assert(Range.isValid() && "Exception Source Range is invalid.");
 
   CharSourceRange CRange = Lexer::makeFileCharRange(
   CharSourceRange::getTokenRange(Range), *Result.SourceManager,
   Result.Context->getLangOpts());
 
-  assert(FnTy && "FunctionProtoType is null.");
   bool IsNoThrow = FnTy->isNothrow();
   StringRef ReplacementStr =
   IsNoThrow

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
index 92c1387d64d6..b0f52a18edf5 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
@@ -4,6 +4,7 @@
 // This test is not run in C++17 or later because dynamic exception
 // specifications were removed in C++17.
 
+using size_t = __SIZE_TYPE__;
 class A {};
 class B {};
 
@@ -19,6 +20,11 @@ void k() throw(int(int));
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 
'throw(int(int))' is deprecated; consider removing it instead 
[modernize-use-noexcept]
 // CHECK-FIXES: void k() ;
 
+// Shouldn't crash due to llvm_unreachable in canThrow() on EST_Uninstantiated
+template  class c { void *operator new(size_t) throw (int);};
+void s() { c<1> doesnt_crash; }
+// CHECK-MESSAGES: :[[@LINE-2]]:53: warning: dynamic exception specification 
'throw (int)' is deprecated; consider removing it instead 
[modernize-use-noexcept]
+
 void foobar() throw(A, B)
 {}
 // CHECK-MESSAGES: :[[@LINE-2]]:15: warning: dynamic exception specification 
'throw(A, B)' is deprecated; consider removing it instead 
[modernize-use-noexcept]



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


[PATCH] D87081: [analyzer][StdLibraryFunctionsChecker] Elaborate the summary of fread and fwrite

2020-09-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Post-commit LGTM on the post-commit changes!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87081

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


[PATCH] D87081: [analyzer][StdLibraryFunctionsChecker] Elaborate the summary of fread and fwrite

2020-09-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

> Actually, the test added here could have catched that regression.

Correction: It is the new BufferSize argument constraint in `fread`'s summary 
and the existing test `test_fread_uninitialized` in `std-c-library-functions.c` 
that could have catched that regression. (Not the test in 
`std-c-library-functions-vs-stream-checker.c`.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87081

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


[PATCH] D86156: [BFI] Make BFI information available through loop passes inside LoopStandardAnalysisResults

2020-09-15 Thread Wenlei He via Phabricator via cfe-commits
wenlei added subscribers: asbirlea, modimo.
wenlei added a comment.

Just saw this. Thanks @Alina Sbirlea for fixing the tests, much appreciated!

On 9/15/20, 6:44 PM, "Nico Weber via Phabricator"  
wrote:

  thakis added a comment.
  
  Looks like this breaks tests: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__45.33.8.238_linux_27942_step-5F12.txt&d=DwIFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=KfYo542rDdZQGClmgz-RBw&m=WVDTkMJEgC2QBjCWKFwyWX-ftSq4MQIeuJdkzkhJdck&s=u5nGzx9n7KhDMJ5K5977aCoxEF8XTrwovmuF0w0QVhw&e=
 
  
  Ptal, and revert for now if it takes a while to fix.
  
  
  Repository:
rG LLVM Github Monorepo
  
  CHANGES SINCE LAST ACTION

https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D86156_new_&d=DwIFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=KfYo542rDdZQGClmgz-RBw&m=WVDTkMJEgC2QBjCWKFwyWX-ftSq4MQIeuJdkzkhJdck&s=7S7jBRn6nAdqYCKhAJ2_bj-1GFfwhTmDvykaV67bOd4&e=
 
  
  
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D86156&d=DwIFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=KfYo542rDdZQGClmgz-RBw&m=WVDTkMJEgC2QBjCWKFwyWX-ftSq4MQIeuJdkzkhJdck&s=whWFyZ-i_C3g_NJi7ZrVBm4HMklqSjbBalaSQEIf22g&e=


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86156

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


[PATCH] D87729: [PowerPC] Implement the 128-bit Vector Divide Extended Builtins in Clang/LLVM

2020-09-15 Thread Albion Fung via Phabricator via cfe-commits
Conanap accepted this revision.
Conanap 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/D87729/new/

https://reviews.llvm.org/D87729

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


[PATCH] D87737: Add -fprofile-update={atomic,prefer-atomic,single}

2020-09-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: davidxl, vsk, xur.
Herald added subscribers: cfe-commits, dang, jfb.
Herald added a project: clang.
MaskRay requested review of this revision.

GCC 7 introduced -fprofile-update={atomic,prefer-atomic} (prefer-atomic is for
best efforts (some targets do not support atomics)) to increment counters
atomically, which is exactly what we have done with -fprofile-instr-generate
(D50867 ) and -fprofile-arcs 
(b5ef137c11b1cc6ae839ee75b49233825772bdd0 
).
This patch adds the option to clang to surface the internal options at driver 
level.

GCC 7 also turned on -fprofile-update=prefer-atomic when -pthread is specified,
but it has performance regression
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89307). So we don't follow suit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87737

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/code-coverage-tsan.c
  clang/test/CodeGen/tsan-instrprof-atomic.c
  clang/test/Driver/fprofile-update.c

Index: clang/test/Driver/fprofile-update.c
===
--- /dev/null
+++ clang/test/Driver/fprofile-update.c
@@ -0,0 +1,15 @@
+/// For -fprofile-instr-generate and -fprofile-arcs, increment counters atomically
+/// if -fprofile-update={atomic,prefer-atomic} or -fsanitize=thread is specified.
+// RUN: %clang -### %s -c -target x86_64-linux -fsanitize=thread %s 2>&1 | FileCheck %s
+// RUN: %clang -### %s -c -fprofile-update=atomic 2>&1 | FileCheck %s
+// RUN: %clang -### %s -c -fprofile-update=prefer-atomic 2>&1 | FileCheck %s
+
+// CHECK: "-fprofile-update=atomic"
+
+// RUN: %clang -### %s -c -fprofile-update=atomic -fprofile-update=single 2>&1 | FileCheck %s --check-prefix=SINGLE
+
+// SINGLE-NOT: "-fprofile-update=atomic"
+
+// RUN: not %clang %s -c -fprofile-update=unknown 2>&1 | FileCheck %s --check-prefix=ERROR
+
+// ERROR: error: unsupported argument 'unknown' to option 'fprofile-update='
Index: clang/test/CodeGen/tsan-instrprof-atomic.c
===
--- clang/test/CodeGen/tsan-instrprof-atomic.c
+++ clang/test/CodeGen/tsan-instrprof-atomic.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -fprofile-instrument=clang -fsanitize=thread -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -fprofile-instrument=clang -fprofile-update=atomic -o - | FileCheck %s
 
 // CHECK: define {{.*}}@foo
 // CHECK-NOT: load {{.*}}foo
Index: clang/test/CodeGen/code-coverage-tsan.c
===
--- clang/test/CodeGen/code-coverage-tsan.c
+++ clang/test/CodeGen/code-coverage-tsan.c
@@ -1,11 +1,12 @@
-/// -fsanitize=thread requires the (potentially concurrent) counter updates to be atomic.
-// RUN: %clang_cc1 %s -triple x86_64 -emit-llvm -fsanitize=thread -femit-coverage-notes -femit-coverage-data \
+/// -fprofile-update=atmomic (implied by -fsanitize=thread) requires the
+/// (potentially concurrent) counter updates to be atomic.
+// RUN: %clang_cc1 %s -triple x86_64 -emit-llvm -fprofile-update=atomic -femit-coverage-notes -femit-coverage-data \
 // RUN:   -coverage-notes-file /dev/null -coverage-data-file /dev/null -o - | FileCheck %s
 
 // CHECK-LABEL: void @foo()
 /// Two counters are incremented by __tsan_atomic64_fetch_add.
-// CHECK: call i64 @__tsan_atomic64_fetch_add
-// CHECK-NEXT:call i32 @__tsan_atomic32_fetch_sub
+// CHECK: atomicrmw add i64* {{.*}} @__llvm_gcov_ctr
+// CHECK-NEXT:atomicrmw sub i32*
 
 _Atomic(int) cnt;
 void foo() { cnt--; }
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -884,6 +884,7 @@
   Opts.DebugRangesBaseAddress = Args.hasArg(OPT_fdebug_ranges_base_address);
 
   setPGOInstrumentor(Opts, Args, Diags);
+  Opts.AtomicProfileUpdate = Args.hasArg(OPT_fprofile_update_EQ);
   Opts.InstrProfileOutput =
   std::string(Args.getLastArgValue(OPT_fprofile_instrument_path_EQ));
   Opts.ProfileInstrumentUsePath =
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -868,6 +868,17 @@
 CmdArgs.push_back(Args.MakeArgString(Twine("-fprofile-filter-files=" + v)));
   }
 
+  if (const auto *A = Args.getLastArg(options::OPT_fprofile_update_EQ)) {
+StringRef Val = A->getValue();
+if (Val == "atomic" || Val == "prefer-atomic")
+  CmdArgs.push_back("-fprofile-update=atomic");
+else if (Val != "single")
+  D.Diag

[PATCH] D87729: [PowerPC] Implement the 128-bit Vector Divide Extended Builtins in Clang/LLVM

2020-09-15 Thread Albion Fung via Phabricator via cfe-commits
Conanap requested changes to this revision.
Conanap added a comment.
This revision now requires changes to proceed.

Looks like there's some unit test failures; could you double check?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87729

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


[PATCH] D87352: Fix typo

2020-09-15 Thread YangZhihui via Phabricator via cfe-commits
YangZhihui updated this revision to Diff 292076.
YangZhihui retitled this revision from "Fix typo in Format.h" to "Fix typo".

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

https://reviews.llvm.org/D87352

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -1860,7 +1860,7 @@
   bool ObjCSpaceAfterProperty;
 
   /// Break parameters list into lines when there is nested block
-  /// parameters in a fuction call.
+  /// parameters in a function call.
   /// \code
   ///   false:
   ///- (void)_aMethod
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -758,10 +758,14 @@
  int b) {
}
 
+
+
 **AttributeMacros** (``std::vector``)
   A vector of strings that should be interpreted as attributes/qualifiers
   instead of identifiers. This can be useful for language extensions or
-  static analyzer annotations:
+  static analyzer annotations.
+
+  For example:
 
   .. code-block:: c++
 
@@ -775,8 +779,6 @@
 
 AttributeMacros: ['__capability', '__output', '__ununsed']
 
-  For example: __capability.
-
 **BinPackArguments** (``bool``)
   If ``false``, a function call's arguments will either be all on the
   same line or will have one line each.
@@ -2246,7 +2248,7 @@
 
 **ObjCBreakBeforeNestedBlockParam** (``bool``)
   Break parameters list into lines when there is nested block
-  parameters in a fuction call.
+  parameters in a function call.
 
   .. code-block:: c++
 


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -1860,7 +1860,7 @@
   bool ObjCSpaceAfterProperty;
 
   /// Break parameters list into lines when there is nested block
-  /// parameters in a fuction call.
+  /// parameters in a function call.
   /// \code
   ///   false:
   ///- (void)_aMethod
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -758,10 +758,14 @@
  int b) {
}
 
+
+
 **AttributeMacros** (``std::vector``)
   A vector of strings that should be interpreted as attributes/qualifiers
   instead of identifiers. This can be useful for language extensions or
-  static analyzer annotations:
+  static analyzer annotations.
+
+  For example:
 
   .. code-block:: c++
 
@@ -775,8 +779,6 @@
 
 AttributeMacros: ['__capability', '__output', '__ununsed']
 
-  For example: __capability.
-
 **BinPackArguments** (``bool``)
   If ``false``, a function call's arguments will either be all on the
   same line or will have one line each.
@@ -2246,7 +2248,7 @@
 
 **ObjCBreakBeforeNestedBlockParam** (``bool``)
   Break parameters list into lines when there is nested block
-  parameters in a fuction call.
+  parameters in a function call.
 
   .. code-block:: c++
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87629: Thread safety analysis: Improve documentation for ASSERT_CAPABILITY

2020-09-15 Thread Russell Yanofsky via Phabricator via cfe-commits
ryanofsky added a comment.

Great feedback! I need to absorb it all then I'll fix the changeset. The 
mistakes about exceptions came from me taking "(no return)" in the previous 
documentation too literally thinking it was referring to 
https://en.cppreference.com/w/cpp/language/attributes/noreturn.

Re: "I got the impression that you want both runtime checks and compile-time 
checks in parallel". Personally I only want the compile checks, and would like 
to drop all the runtime checks except in handful of places where compile time 
checks don't work. ASSERT_CAPABILITY does a great job in these places so I 
don't want people to be scared off from using it unduly because of 
documentation!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87629

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


[PATCH] D86156: [BFI] Make BFI information available through loop passes inside LoopStandardAnalysisResults

2020-09-15 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests: http://45.33.8.238/linux/27942/step_12.txt

Ptal, and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86156

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


[PATCH] D85685: Support dwarf fission for wasm object files

2020-09-15 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

Seems reasonable.   Do you think this way is cleaner than the way elf does it?  
 Looks like ELF creates two different ELFWriter inside the ELFDwoObjectWriter 
subclass right?

Are we going need to wasm-ld tests to followup or is this really independent of 
the linker?




Comment at: llvm/lib/MC/WasmObjectWriter.cpp:224
 class WasmObjectWriter : public MCObjectWriter {
-  support::endian::Writer W;
+  support::endian::Writer *W;
 

Kind of a same this change means changing so many line in this file ..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85685

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


[PATCH] D83154: clang: Add -fcoverage-prefix-map

2020-09-15 Thread Keith Smiley via Phabricator via cfe-commits
keith added inline comments.



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:1334
+  llvm::SmallString<256> Path(Filename);
+  llvm::sys::fs::make_absolute(Path);
+  llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);

phosek wrote:
> andrewjcg wrote:
> > keith wrote:
> > > rnk wrote:
> > > > keith wrote:
> > > > > rnk wrote:
> > > > > > Please only make the path absolute if nothing in the prefix map 
> > > > > > matches. Otherwise, the user must embed the CWD into the prefix 
> > > > > > map, which is needlessly difficult for the build system. I believe 
> > > > > > it is also consistent with the way that the debug info prefix map 
> > > > > > works. It appears to operate on the possibly relative source paths 
> > > > > > received on the command line (-I...).
> > > > > Are you suggesting that I try to remap them relatively, and if that 
> > > > > fails, absolutize it and attempt the remapping again? Or don't 
> > > > > absolutize them at all anymore?
> > > > I'd prefer to do the remapping once without any absolutization, and if 
> > > > that fails, preserve the behavior of absolutizing.
> > > > 
> > > > It would be my preference to not absolutize paths at all, since that is 
> > > > what is done for debug info. However, @vsk implemented things this way, 
> > > > and I do understand that this is convenient default behavior for most 
> > > > users: the paths in the coverage are valid anywhere on their system. 
> > > > So, changing this behavior is out of scope for this patch.
> > > I'm not sure how this changed would work for our use case. With bazel the 
> > > usage of this works something like:
> > > 
> > > 1. Relative paths are passed to the compiler `clang ... foo.c`
> > > 2. We would normally do `-fprofile-prefix-map=$PWD=.` to remap them
> > > 
> > > I think if we made this change, we would either have to:
> > > 
> > > 1. Make the paths we pass absolute, which we couldn't do for 
> > > reproducibility
> > > 2. Add some known prefix to the paths, like `.`, so we could 
> > > `-fprofile-prefix-map=.=.` just to avoid this absolutizing codepath
> > > 
> > > So I think without actually removing the absolutizing behavior at the 
> > > same time, this wouldn't work as we'd hope.
> > > 
> > > Let me know if I'm mis-understanding your suggestion!
> > > 
> > > If we did what I said above, I think it would work since relative path 
> > > remapping would fail, but then prefix mapping the absolute path would 
> > > work.
> > FWIW, there's a similar issue with doing the absolutizing for the Buck 
> > build tool, which by default sets `-fdebug-compilation-dir=.` for all 
> > compilations, then expects to use `-fdebug-prefix-map` (or 
> > `-ffile-prefix-map`) to fixup relative paths of sandboxed header symlink 
> > trees to point to their *real* paths (e.g. something like `clang -c 
> > -fdebug-compilation-dir=. -Iheader-tree-sandbox 
> > -ffile-prefix-map=header-tree-sandbox=original_dir`) (e.g. 
> > https://github.com/facebook/buck/blob/master/src/com/facebook/buck/cxx/toolchain/PrefixMapDebugPathSanitizer.java#L134).
> > 
> > So, in this case, *not* absolutizing would help here, but it kind of feels 
> > that the real issue is that there's not an equivalent 
> > `-fprofile-compilation-dir` to opt-out of the absolutizing of profile paths 
> > (which is orthogonal to this change)...
> FWIW this is something we've already discussed on the list and I started 
> prototyping that feature, I'm hoping to upload the change for review in the 
> next few days.
It's probably worth going back to the mailing list for some of these 
discussions. I think everyone was happy with the idea of one of the 
`-*compilation-dir` flags, but we decided to only add this flag for now 
https://lists.llvm.org/pipermail/cfe-dev/2020-June/066014.html

Also bazel "gets around" excluding PWD from command lines by hiding it in 
nested flags 
https://github.com/bazelbuild/bazel/blob/e3c8eb48dc05a666c68ae18e996f5d37cac5a607/tools/osx/crosstool/wrapped_clang.cc#L219-L221
 which is why this case was good enough for me as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83154

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


[PATCH] D31413: [libc++] Use __attribute__((init_priority(101))) to ensure streams get initialized early

2020-09-15 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

This came up again in wasi-sdk: 
https://github.com/WebAssembly/wasi-sdk/issues/153


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

https://reviews.llvm.org/D31413

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


[PATCH] D85685: Support dwarf fission for wasm object files

2020-09-15 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

OK, I think this is ready to review for real. Can you take another look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85685

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


[PATCH] D82118: [clang][module] Improve incomplete-umbrella warning

2020-09-15 Thread Zixu Wang via Phabricator via cfe-commits
zixuw updated this revision to Diff 292058.
zixuw added a comment.

Address review:

- Use explicit type name `Module::Header` instead of `auto` since it's a short

typename and using `auto` does not improve readability;

- Change variable `EndLoc` to `ExpectedHeadersLoc` so it's self-explanatory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82118

Files:
  clang/lib/Lex/PPLexerChange.cpp
  clang/test/Modules/incomplete-umbrella.m


Index: clang/test/Modules/incomplete-umbrella.m
===
--- clang/test/Modules/incomplete-umbrella.m
+++ clang/test/Modules/incomplete-umbrella.m
@@ -6,8 +6,12 @@
 #import 
 @import Foo.Private;
 
-// CHECK: warning: umbrella header for module 'Foo' does not include header 
'Bar.h'
-// CHECK: warning: umbrella header for module 'Foo.Private' does not include 
header 'Baz.h'
+// CHECK: While building module 'Foo' imported from 
{{.*[/\]}}incomplete-umbrella.m:4:
+// CHECK-NEXT: In file included from :1:
+// CHECK-NEXT: {{.*Foo[.]framework[/\]Headers[/\]}}FooPublic.h:2:1: warning: 
umbrella header for module 'Foo' does not include header 'Bar.h'
+// CHECK: While building module 'Foo' imported from 
{{.*[/\]}}incomplete-umbrella.m:4:
+// CHECK-NEXT: In file included from :2:
+// CHECK-NEXT: {{.*Foo[.]framework[/\]PrivateHeaders[/\]}}Foo.h:2:1: warning: 
umbrella header for module 'Foo.Private' does not include header 'Baz.h'
 int foo() {
   int a = BAR_PUBLIC;
   int b = BAZ_PRIVATE;
Index: clang/lib/Lex/PPLexerChange.cpp
===
--- clang/lib/Lex/PPLexerChange.cpp
+++ clang/lib/Lex/PPLexerChange.cpp
@@ -263,10 +263,12 @@
 }
 
 void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) {
-  assert(Mod.getUmbrellaHeader() && "Module must use umbrella header");
-  SourceLocation StartLoc =
-  SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
-  if (getDiagnostics().isIgnored(diag::warn_uncovered_module_header, StartLoc))
+  const Module::Header &UmbrellaHeader = Mod.getUmbrellaHeader();
+  assert(UmbrellaHeader.Entry && "Module must use umbrella header");
+  const FileID &File = SourceMgr.translateFile(UmbrellaHeader.Entry);
+  SourceLocation ExpectedHeadersLoc = SourceMgr.getLocForEndOfFile(File);
+  if (getDiagnostics().isIgnored(diag::warn_uncovered_module_header,
+ ExpectedHeadersLoc))
 return;
 
   ModuleMap &ModMap = getHeaderSearchInfo().getModuleMap();
@@ -291,7 +293,7 @@
   // Find the relative path that would access this header.
   SmallString<128> RelativePath;
   computeRelativePath(FileMgr, Dir, *Header, RelativePath);
-  Diag(StartLoc, diag::warn_uncovered_module_header)
+  Diag(ExpectedHeadersLoc, diag::warn_uncovered_module_header)
   << Mod.getFullModuleName() << RelativePath;
 }
   }


Index: clang/test/Modules/incomplete-umbrella.m
===
--- clang/test/Modules/incomplete-umbrella.m
+++ clang/test/Modules/incomplete-umbrella.m
@@ -6,8 +6,12 @@
 #import 
 @import Foo.Private;
 
-// CHECK: warning: umbrella header for module 'Foo' does not include header 'Bar.h'
-// CHECK: warning: umbrella header for module 'Foo.Private' does not include header 'Baz.h'
+// CHECK: While building module 'Foo' imported from {{.*[/\]}}incomplete-umbrella.m:4:
+// CHECK-NEXT: In file included from :1:
+// CHECK-NEXT: {{.*Foo[.]framework[/\]Headers[/\]}}FooPublic.h:2:1: warning: umbrella header for module 'Foo' does not include header 'Bar.h'
+// CHECK: While building module 'Foo' imported from {{.*[/\]}}incomplete-umbrella.m:4:
+// CHECK-NEXT: In file included from :2:
+// CHECK-NEXT: {{.*Foo[.]framework[/\]PrivateHeaders[/\]}}Foo.h:2:1: warning: umbrella header for module 'Foo.Private' does not include header 'Baz.h'
 int foo() {
   int a = BAR_PUBLIC;
   int b = BAZ_PRIVATE;
Index: clang/lib/Lex/PPLexerChange.cpp
===
--- clang/lib/Lex/PPLexerChange.cpp
+++ clang/lib/Lex/PPLexerChange.cpp
@@ -263,10 +263,12 @@
 }
 
 void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) {
-  assert(Mod.getUmbrellaHeader() && "Module must use umbrella header");
-  SourceLocation StartLoc =
-  SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
-  if (getDiagnostics().isIgnored(diag::warn_uncovered_module_header, StartLoc))
+  const Module::Header &UmbrellaHeader = Mod.getUmbrellaHeader();
+  assert(UmbrellaHeader.Entry && "Module must use umbrella header");
+  const FileID &File = SourceMgr.translateFile(UmbrellaHeader.Entry);
+  SourceLocation ExpectedHeadersLoc = SourceMgr.getLocForEndOfFile(File);
+  if (getDiagnostics().isIgnored(diag::warn_uncovered_module_header,
+ ExpectedHeadersLoc))

[PATCH] D85685: [WIP] Support dwarf fission for wasm object files

2020-09-15 Thread Derek Schuff via Phabricator via cfe-commits
dschuff updated this revision to Diff 292056.
dschuff added a comment.
Herald added subscribers: sstefan1, ormris, jgravelle-google.
Herald added a reviewer: jdoerfert.

upload the correct diff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85685

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/split-debug.c
  llvm/include/llvm/MC/MCWasmObjectWriter.h
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/MC/WasmObjectWriter.cpp
  llvm/test/DebugInfo/WebAssembly/fission-cu.ll
  llvm/test/DebugInfo/WebAssembly/fission-sections.ll

Index: llvm/test/DebugInfo/WebAssembly/fission-sections.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/WebAssembly/fission-sections.ll
@@ -0,0 +1,48 @@
+; RUN: llc -split-dwarf-file=baz.dwo -split-dwarf-output=%t.dwo  -O0 %s -mtriple=wasm32-unknown-unknown -filetype=obj -o %t
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t.dwo | FileCheck --check-prefix=DWO %s
+
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+; But it checks that the output objects have the expected sections
+
+source_filename = "test/DebugInfo/WebAssembly/fission-cu.ll"
+
+@a = global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "/usr/local/google/home/echristo/tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+!6 = !{!0}
+!7 = !{i32 1, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: Sections:
+
+; OBJ: Idx Name
+; OBJ-NEXT: 0 IMPORT
+; OBJ-NEXT: DATACOUNT
+; OBJ-NEXT: DATA
+; OBJ-NEXT: .debug_abbrev
+; OBJ-NEXT: .debug_info
+; OBJ-NEXT: .debug_str
+; OBJ-NEXT: .debug_addr
+; OBJ-NEXT: .debug_pubnames
+; OBJ-NEXT: .debug_pubtypes
+; OBJ-NEXT: .debug_line
+; OBJ-NEXT: linking
+
+
+; DWO: Idx Name
+; DWO-NOT: IMPORT
+; DWO-NOT: DATA
+; DWO: 0 .debug_str.dwo
+; DWO-NEXT: .debug_str_offsets.dwo
+; DWO-NEXT: .debug_info.dwo
+; DWO-NEXT: .debug_abbrev.dwo
+; DWO-NEXT: producers
Index: llvm/test/DebugInfo/WebAssembly/fission-cu.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/WebAssembly/fission-cu.ll
@@ -0,0 +1,121 @@
+; RUN: llc -split-dwarf-file=baz.dwo  -O0 %s -mtriple=wasm32-unknown-unknown -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+
+source_filename = "test/DebugInfo/WebAssembly/fission-cu.ll"
+
+@a = global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "/usr/local/google/home/echristo/tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+; Check that the skeleton compile unit contains the proper attributes:
+; This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+; DW_AT_ranges_base, DW_AT_addr_base.
+
+; CHECK: .debug_abbrev contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_no
+; CHECK: DW_AT_stmt_list DW_FORM_sec_offset
+; CHECK: DW_AT_comp_dir  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; Check that we're using the right forms.
+; CHECK: .debug_abbrev.dwo contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_yes
+; CHECK: DW_AT_producer  DW_FORM_GNU_str_index
+; CHECK: DW_AT_language  DW_FORM_data2
+; CHECK: DW_AT_name  DW_FORM_GNU_str_index
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_GNU_str_index
+; CHECK-NOT: DW_AT_low_pc
+; CHECK-NOT: DW_AT_stmt_l

[PATCH] D87394: [PowerPC][Power10] Implementation of 128-bit Binary Vector Mod and Sign Extend builtins

2020-09-15 Thread Amy Kwan via Phabricator via cfe-commits
amyk requested changes to this revision.
amyk added a comment.
This revision now requires changes to proceed.

A question I have is, is it possible for the 128-bit vector modulo instructions 
be open coded?




Comment at: clang/lib/Headers/altivec.h:17394
+static __inline__ vector signed __int128 __ATTRS_o_ai
+vec_mod(vector signed __int128 __a, vector signed __int128 __b) {
+  return __builtin_altivec_vmodsq(__a, __b);

nit: Move these under the existing `vec_mod` builtins.
Also, is it possible for these to be open coded instead? We have `vec_mod` for 
other types that are open coded. 




Comment at: llvm/lib/Target/PowerPC/PPCInstrPrefix.td:1300
+   [(set v1i128:$vD, (int_ppc_altivec_vmodsq 
v1i128:$vA,
+   v1i128:$vB))]>;
   def VMODUQ : VXForm_1<1547, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),

nit: Indent `v1i128` underneath the top `v1i128`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87394

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


[PATCH] D85685: [WIP] Support dwarf fission for wasm object files

2020-09-15 Thread Derek Schuff via Phabricator via cfe-commits
dschuff updated this revision to Diff 292055.
dschuff added a comment.

Get the right sections in the objects, add tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85685

Files:
  llvm/lib/MC/WasmObjectWriter.cpp


Index: llvm/lib/MC/WasmObjectWriter.cpp
===
--- llvm/lib/MC/WasmObjectWriter.cpp
+++ llvm/lib/MC/WasmObjectWriter.cpp
@@ -321,9 +321,8 @@
 
   void executePostLayoutBinding(MCAssembler &Asm,
 const MCAsmLayout &Layout) override;
-  void prepareImports(SmallVectorImpl& Imports,
-  MCAssembler &Asm,
-  const MCAsmLayout &Layout);
+  void prepareImports(SmallVectorImpl &Imports,
+  MCAssembler &Asm, const MCAsmLayout &Layout);
   uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) override;
 
   uint64_t writeOneObject(MCAssembler &Asm, const MCAsmLayout &Layout,
@@ -963,7 +962,7 @@
   encodeULEB128(0, W->OS); // memory index
 if ((Segment.InitFlags & wasm::WASM_SEGMENT_IS_PASSIVE) == 0) {
   W->OS << char(Segment.Offset > INT32_MAX ? wasm::WASM_OPCODE_I64_CONST
-  : wasm::WASM_OPCODE_I32_CONST);
+   : wasm::WASM_OPCODE_I32_CONST);
   encodeSLEB128(Segment.Offset, W->OS); // offset
   W->OS << char(wasm::WASM_OPCODE_END);
 }
@@ -1198,9 +1197,9 @@
 
   return true;
 }
-void WasmObjectWriter::prepareImports(SmallVectorImpl& 
Imports,
-  MCAssembler &Asm,
-  const MCAsmLayout &Layout) {
+void WasmObjectWriter::prepareImports(
+SmallVectorImpl &Imports, MCAssembler &Asm,
+const MCAsmLayout &Layout) {
   // For now, always emit the memory import, since loads and stores are not
   // valid without it. In the future, we could perhaps be more clever and omit
   // it if there are no loads or stores.


Index: llvm/lib/MC/WasmObjectWriter.cpp
===
--- llvm/lib/MC/WasmObjectWriter.cpp
+++ llvm/lib/MC/WasmObjectWriter.cpp
@@ -321,9 +321,8 @@
 
   void executePostLayoutBinding(MCAssembler &Asm,
 const MCAsmLayout &Layout) override;
-  void prepareImports(SmallVectorImpl& Imports,
-  MCAssembler &Asm,
-  const MCAsmLayout &Layout);
+  void prepareImports(SmallVectorImpl &Imports,
+  MCAssembler &Asm, const MCAsmLayout &Layout);
   uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) override;
 
   uint64_t writeOneObject(MCAssembler &Asm, const MCAsmLayout &Layout,
@@ -963,7 +962,7 @@
   encodeULEB128(0, W->OS); // memory index
 if ((Segment.InitFlags & wasm::WASM_SEGMENT_IS_PASSIVE) == 0) {
   W->OS << char(Segment.Offset > INT32_MAX ? wasm::WASM_OPCODE_I64_CONST
-  : wasm::WASM_OPCODE_I32_CONST);
+   : wasm::WASM_OPCODE_I32_CONST);
   encodeSLEB128(Segment.Offset, W->OS); // offset
   W->OS << char(wasm::WASM_OPCODE_END);
 }
@@ -1198,9 +1197,9 @@
 
   return true;
 }
-void WasmObjectWriter::prepareImports(SmallVectorImpl& Imports,
-  MCAssembler &Asm,
-  const MCAsmLayout &Layout) {
+void WasmObjectWriter::prepareImports(
+SmallVectorImpl &Imports, MCAssembler &Asm,
+const MCAsmLayout &Layout) {
   // For now, always emit the memory import, since loads and stores are not
   // valid without it. In the future, we could perhaps be more clever and omit
   // it if there are no loads or stores.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87729: [PowerPC] Implement the 128-bit Vector Divide Extended Builtins in Clang/LLVM

2020-09-15 Thread Amy Kwan via Phabricator via cfe-commits
amyk created this revision.
amyk added reviewers: power-llvm-team, PowerPC, Conanap, nemanjai.
amyk added projects: LLVM, PowerPC.
Herald added subscribers: shchenz, hiraditya.
Herald added a project: clang.
amyk requested review of this revision.

This patch implements the 128-bit vector divide extended builtins in Clang/LLVM.
These builtins map to the `vdivesq` and `vdiveuq` instructions respectively.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87729

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

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
@@ -9,6 +9,7 @@
 ; This test case aims to test the vector divide instructions on Power10.
 ; This includes the low order and extended versions of vector divide,
 ; that operate on signed and unsigned words and doublewords.
+; This also includes 128 bit vector divide instructions.
 
 define <2 x i64> @test_vdivud(<2 x i64> %a, <2 x i64> %b) {
 ; CHECK-LABEL: test_vdivud:
@@ -113,3 +114,25 @@
   %div = tail call <2 x i64> @llvm.ppc.altivec.vdiveud(<2 x i64> %a, <2 x i64> %b)
   ret <2 x i64> %div
 }
+
+declare <1 x i128> @llvm.ppc.altivec.vdivesq(<1 x i128>, <1 x i128>) nounwind readnone
+declare <1 x i128> @llvm.ppc.altivec.vdiveuq(<1 x i128>, <1 x i128>) nounwind readnone
+
+define <1 x i128> @test_vdivesq(<1 x i128> %x, <1 x i128> %y) nounwind readnone {
+; CHECK-LABEL: test_vdivesq:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vdivesq v2, v2, v3
+; CHECK-NEXT:blr
+  %tmp = tail call <1 x i128> @llvm.ppc.altivec.vdivesq(<1 x i128> %x, <1 x i128> %y)
+  ret <1 x i128> %tmp
+}
+
+
+define <1 x i128> @test_vdiveuq(<1 x i128> %x, <1 x i128> %y) nounwind readnone {
+; CHECK-LABEL: test_vdiveuq:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vdiveuq v2, v2, v3
+; CHECK-NEXT:blr
+  %tmp = call <1 x i128> @llvm.ppc.altivec.vdiveuq(<1 x i128> %x, <1 x i128> %y)
+  ret <1 x i128> %tmp
+}
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -1291,9 +1291,13 @@
 "vdivuq $vD, $vA, $vB", IIC_VecGeneral,
 [(set v1i128:$vD, (udiv v1i128:$vA, v1i128:$vB))]>;
   def VDIVESQ : VXForm_1<779, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
- "vdivesq $vD, $vA, $vB", IIC_VecGeneral, []>;
+ "vdivesq $vD, $vA, $vB", IIC_VecGeneral,
+ [(set v1i128:$vD, (int_ppc_altivec_vdivesq v1i128:$vA,
+			   v1i128:$vB))]>;
   def VDIVEUQ : VXForm_1<523, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
- "vdiveuq $vD, $vA, $vB", IIC_VecGeneral, []>;
+ "vdiveuq $vD, $vA, $vB", IIC_VecGeneral,
+ [(set v1i128:$vD, (int_ppc_altivec_vdiveuq v1i128:$vA,
+			   v1i128:$vB))]>;
   def VCMPEQUQ : VCMP <455, "vcmpequq $vD, $vA, $vB" , v1i128>;
   def VCMPGTSQ : VCMP <903, "vcmpgtsq $vD, $vA, $vB" , v1i128>;
   def VCMPGTUQ : VCMP <647, "vcmpgtuq $vD, $vA, $vB" , v1i128>;
Index: llvm/include/llvm/IR/IntrinsicsPowerPC.td
===
--- llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -981,6 +981,8 @@
 def int_ppc_altivec_vdiveuw : PowerPC_Vec_WWW_Intrinsic<"vdiveuw">;
 def int_ppc_altivec_vdivesd : PowerPC_Vec_DDD_Intrinsic<"vdivesd">;
 def int_ppc_altivec_vdiveud : PowerPC_Vec_DDD_Intrinsic<"vdiveud">;
+def int_ppc_altivec_vdivesq : PowerPC_Vec_QQQ_Intrinsic<"vdivesq">;
+def int_ppc_altivec_vdiveuq : PowerPC_Vec_QQQ_Intrinsic<"vdiveuq">;
 
 // Vector Multiply High Intrinsics.
 def int_ppc_altivec_vmulhsw : PowerPC_Vec_WWW_Intrinsic<"vmulhsw">;
Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -106,6 +106,18 @@
   return vec_dive(vulla, vullb);
 }
 
+vector unsigned __int128 test_vec_dive_u128(void) {
+  // CHECK: @llvm.ppc.altivec.vdiveuq(<1 x i128> %{{.+}}, <1 x i128> %{{.+}})
+  // CHECK-NEXT: ret <1 x i128>
+  return vec_dive(vui128a, vui128b);
+}
+
+vector signed __int128 test_vec_dive_s128(void) {
+  // CHECK: @llvm.ppc.altivec.vdivesq(<1 x i128> %{{.+}}, <1 x i128> %{{.+}})
+  // CHECK-NEXT: ret <1 x i128>
+  return vec_dive(vsi128a, vsi128b);
+}
+
 vector signed int test_vec_mulh_si(void) {
   // CHECK: @llvm.ppc.altivec.vmulhsw(<4 x i32> %{{.+}}, <4 x i32> %{{.+}})
   // CHECK-NEXT: ret <4

[PATCH] D86156: [BFI] Make BFI information available through loop passes inside LoopStandardAnalysisResults

2020-09-15 Thread Wenlei He via Phabricator via cfe-commits
wenlei added a comment.

Committed on behalf of @modimo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86156

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


[PATCH] D86156: [BFI] Make BFI information available through loop passes inside LoopStandardAnalysisResults

2020-09-15 Thread Wenlei He via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2ea4c2c598b7: [BFI] Make BFI information available through 
loop passes inside… (authored by wenlei).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86156

Files:
  llvm/include/llvm/Analysis/LoopAnalysisManager.h
  llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/Scalar/LICM.cpp
  llvm/lib/Transforms/Scalar/LoopDistribute.cpp
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
  llvm/lib/Transforms/Utils/LoopVersioning.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -9,7 +9,10 @@
 #include "llvm/Transforms/Scalar/LoopPassManager.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/AssumptionCache.h"
+#include "llvm/Analysis/BlockFrequencyInfo.h"
+#include "llvm/Analysis/BranchProbabilityInfo.h"
 #include "llvm/Analysis/MemorySSA.h"
+#include "llvm/Analysis/PostDominators.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
@@ -294,6 +297,9 @@
 // those.
 FAM.registerPass([&] { return AAManager(); });
 FAM.registerPass([&] { return AssumptionAnalysis(); });
+FAM.registerPass([&] { return BlockFrequencyAnalysis(); });
+FAM.registerPass([&] { return BranchProbabilityAnalysis(); });
+FAM.registerPass([&] { return PostDominatorTreeAnalysis(); });
 FAM.registerPass([&] { return MemorySSAAnalysis(); });
 FAM.registerPass([&] { return ScalarEvolutionAnalysis(); });
 FAM.registerPass([&] { return TargetLibraryAnalysis(); });
Index: llvm/test/Other/opt-Os-pipeline.ll
===
--- llvm/test/Other/opt-Os-pipeline.ll
+++ llvm/test/Other/opt-Os-pipeline.ll
@@ -97,6 +97,8 @@
 ; CHECK-NEXT: Loop Pass Manager
 ; CHECK-NEXT:   Rotate Loops
 ; CHECK-NEXT: Memory SSA
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: Loop Pass Manager
 ; CHECK-NEXT:   Loop Invariant Code Motion
 ; CHECK-NEXT:   Unswitch loops
@@ -154,6 +156,8 @@
 ; CHECK-NEXT: LCSSA Verifier
 ; CHECK-NEXT: Loop-Closed SSA Form Pass
 ; CHECK-NEXT: Scalar Evolution Analysis
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: Loop Pass Manager
 ; CHECK-NEXT:   Loop Invariant Code Motion
 ; CHECK-NEXT: Post-Dominator Tree Construction
@@ -256,10 +260,10 @@
 ; CHECK-NEXT:   LCSSA Verifier
 ; CHECK-NEXT:   Loop-Closed SSA Form Pass
 ; CHECK-NEXT:   Scalar Evolution Analysis
-; CHECK-NEXT:   Loop Pass Manager
-; CHECK-NEXT: Loop Invariant Code Motion
 ; CHECK-NEXT:   Lazy Branch Probability Analysis
 ; CHECK-NEXT:   Lazy Block Frequency Analysis
+; CHECK-NEXT:   Loop Pass Manager
+; CHECK-NEXT: Loop Invariant Code Motion
 ; CHECK-NEXT:   Optimization Remark Emitter
 ; CHECK-NEXT:   Warn about non-applied transformations
 ; CHECK-NEXT:   Alignment from assumptions
Index: llvm/test/Other/opt-O3-pipeline.ll
===
--- llvm/test/Other/opt-O3-pipeline.ll
+++ llvm/test/Other/opt-O3-pipeline.ll
@@ -116,6 +116,8 @@
 ; CHECK-NEXT: Loop Pass Manager
 ; CHECK-NEXT:   Rotate Loops
 ; CHECK-NEXT: Memory SSA
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: Loop Pass Manager
 ; CHECK-NEXT:   Loop Invariant Code Motion
 ; CHECK-NEXT:   Unswitch loops
@@ -173,6 +175,8 @@
 ; CHECK-NEXT: LCSSA Verifier
 ; CHECK-NEXT: Loop-Closed SSA Form Pass
 ; CHECK-NEXT: Scalar Evolution Analysis
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: Loop Pass Manager
 ; CHECK-NEXT:   Loop Invariant Code Motion
 ; CHECK-NEXT: Post-Dominator Tree Construction
@@ -275,10 +279,10 @@
 ; CHECK-NEXT:   LCSSA Verifier
 ; CHECK-NEXT:   Loop-Closed SSA Form Pass
 ; CHECK-NEXT:   Scalar Evolution Analysis
-; CHECK-NEXT:   Loop Pass Manager
-; CHECK-NEXT

[PATCH] D86156: [BFI] Make BFI information available through loop passes inside LoopStandardAnalysisResults

2020-09-15 Thread Di Mo via Phabricator via cfe-commits
modimo updated this revision to Diff 292044.
modimo added a comment.

Rebase #2


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

https://reviews.llvm.org/D86156

Files:
  llvm/include/llvm/Analysis/LoopAnalysisManager.h
  llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/Scalar/LICM.cpp
  llvm/lib/Transforms/Scalar/LoopDistribute.cpp
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
  llvm/lib/Transforms/Utils/LoopVersioning.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -9,7 +9,10 @@
 #include "llvm/Transforms/Scalar/LoopPassManager.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/AssumptionCache.h"
+#include "llvm/Analysis/BlockFrequencyInfo.h"
+#include "llvm/Analysis/BranchProbabilityInfo.h"
 #include "llvm/Analysis/MemorySSA.h"
+#include "llvm/Analysis/PostDominators.h"
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
@@ -294,6 +297,9 @@
 // those.
 FAM.registerPass([&] { return AAManager(); });
 FAM.registerPass([&] { return AssumptionAnalysis(); });
+FAM.registerPass([&] { return BlockFrequencyAnalysis(); });
+FAM.registerPass([&] { return BranchProbabilityAnalysis(); });
+FAM.registerPass([&] { return PostDominatorTreeAnalysis(); });
 FAM.registerPass([&] { return MemorySSAAnalysis(); });
 FAM.registerPass([&] { return ScalarEvolutionAnalysis(); });
 FAM.registerPass([&] { return TargetLibraryAnalysis(); });
Index: llvm/test/Other/opt-Os-pipeline.ll
===
--- llvm/test/Other/opt-Os-pipeline.ll
+++ llvm/test/Other/opt-Os-pipeline.ll
@@ -97,6 +97,8 @@
 ; CHECK-NEXT: Loop Pass Manager
 ; CHECK-NEXT:   Rotate Loops
 ; CHECK-NEXT: Memory SSA
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: Loop Pass Manager
 ; CHECK-NEXT:   Loop Invariant Code Motion
 ; CHECK-NEXT:   Unswitch loops
@@ -154,6 +156,8 @@
 ; CHECK-NEXT: LCSSA Verifier
 ; CHECK-NEXT: Loop-Closed SSA Form Pass
 ; CHECK-NEXT: Scalar Evolution Analysis
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: Loop Pass Manager
 ; CHECK-NEXT:   Loop Invariant Code Motion
 ; CHECK-NEXT: Post-Dominator Tree Construction
@@ -256,10 +260,10 @@
 ; CHECK-NEXT:   LCSSA Verifier
 ; CHECK-NEXT:   Loop-Closed SSA Form Pass
 ; CHECK-NEXT:   Scalar Evolution Analysis
-; CHECK-NEXT:   Loop Pass Manager
-; CHECK-NEXT: Loop Invariant Code Motion
 ; CHECK-NEXT:   Lazy Branch Probability Analysis
 ; CHECK-NEXT:   Lazy Block Frequency Analysis
+; CHECK-NEXT:   Loop Pass Manager
+; CHECK-NEXT: Loop Invariant Code Motion
 ; CHECK-NEXT:   Optimization Remark Emitter
 ; CHECK-NEXT:   Warn about non-applied transformations
 ; CHECK-NEXT:   Alignment from assumptions
Index: llvm/test/Other/opt-O3-pipeline.ll
===
--- llvm/test/Other/opt-O3-pipeline.ll
+++ llvm/test/Other/opt-O3-pipeline.ll
@@ -116,6 +116,8 @@
 ; CHECK-NEXT: Loop Pass Manager
 ; CHECK-NEXT:   Rotate Loops
 ; CHECK-NEXT: Memory SSA
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: Loop Pass Manager
 ; CHECK-NEXT:   Loop Invariant Code Motion
 ; CHECK-NEXT:   Unswitch loops
@@ -173,6 +175,8 @@
 ; CHECK-NEXT: LCSSA Verifier
 ; CHECK-NEXT: Loop-Closed SSA Form Pass
 ; CHECK-NEXT: Scalar Evolution Analysis
+; CHECK-NEXT: Lazy Branch Probability Analysis
+; CHECK-NEXT: Lazy Block Frequency Analysis
 ; CHECK-NEXT: Loop Pass Manager
 ; CHECK-NEXT:   Loop Invariant Code Motion
 ; CHECK-NEXT: Post-Dominator Tree Construction
@@ -275,10 +279,10 @@
 ; CHECK-NEXT:   LCSSA Verifier
 ; CHECK-NEXT:   Loop-Closed SSA Form Pass
 ; CHECK-NEXT:   Scalar Evolution Analysis
-; CHECK-NEXT:   Loop Pass Manager
-; CHECK-NEXT: Loop Invariant Code Motion
 ; CHECK-NEXT:   Lazy Branch Probability Analysis
 ; CHECK-NEXT:   Lazy Block Frequency Analysis
+; CHECK-NE

[PATCH] D87636: [ThinLTO] add post-thinlto-merge option to -lto-embed-bitcode

2020-09-15 Thread Mircea Trofin via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG61fc10d6a520: [ThinLTO] add post-thinlto-merge option to 
-lto-embed-bitcode (authored by mtrofin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87636

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/Inputs/start-lib1.ll
  clang/test/CodeGen/Inputs/start-lib2.ll
  clang/test/CodeGen/thinlto_embed_bitcode.ll
  llvm/include/llvm/LTO/LTOBackend.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/test/LTO/X86/Inputs/start-lib1.ll
  llvm/test/LTO/X86/embed-bitcode.ll

Index: llvm/test/LTO/X86/embed-bitcode.ll
===
--- llvm/test/LTO/X86/embed-bitcode.ll
+++ llvm/test/LTO/X86/embed-bitcode.ll
@@ -11,13 +11,20 @@
 ; RUN: llvm-lto2 run -r %t1.o,_start,px -r %t2.o,foo,px -r %t3.o,bar,px -r %t2.o,bar,lx -lto-embed-bitcode=optimized -o %t3 %t1.o %t2.o %t3.o
 ; RUN: llvm-readelf -S %t3.0 | FileCheck %s --check-prefix=CHECK-ELF
 ; RUN: llvm-objcopy --dump-section=.llvmbc=%t-embedded.bc %t3.0 /dev/null
-; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefix=CHECK-LL
+; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefixes=CHECK-LL,CHECK-OPT
+
+; RUN: llvm-lto2 run -r %t1.o,_start,px -r %t2.o,foo,px -r %t3.o,bar,px -r %t2.o,bar,lx -lto-embed-bitcode=post-merge-pre-opt -o %t3 %t1.o %t2.o %t3.o
+; RUN: llvm-readelf -S %t3.0 | FileCheck %s --check-prefix=CHECK-ELF
+; RUN: llvm-objcopy --dump-section=.llvmbc=%t-embedded.bc %t3.0 /dev/null
+; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefixes=CHECK-LL,CHECK-NOOPT
 
 ; CHECK-ELF:  .text   PROGBITS  [[#%x,OFF:]] [[#%x,SIZE:]] 00 AX 0
 ; CHECK-ELF-NEXT: .llvmbc PROGBITS  [[#%x,OFF:]] [[#%x,SIZE:]] 000
 
 ; CHECK-LL: @_start
 ; CHECK-LL: @foo
+; CHECK-OPT-NEXT: ret void
+; CHECK-NOOPT-NEXT: call void @bar
 ; CHECK-LL: @bar
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
Index: llvm/lib/LTO/LTOBackend.cpp
===
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -50,9 +50,12 @@
 using namespace llvm;
 using namespace lto;
 
+#define DEBUG_TYPE "lto-backend"
+
 enum class LTOBitcodeEmbedding {
   DoNotEmbed = 0,
   EmbedOptimized = 1,
+  EmbedPostMergePreOptimized = 2
 };
 
 static cl::opt EmbedBitcode(
@@ -60,7 +63,10 @@
 cl::values(clEnumValN(LTOBitcodeEmbedding::DoNotEmbed, "none",
   "Do not embed"),
clEnumValN(LTOBitcodeEmbedding::EmbedOptimized, "optimized",
-  "Embed after all optimization passes")),
+  "Embed after all optimization passes"),
+   clEnumValN(LTOBitcodeEmbedding::EmbedPostMergePreOptimized,
+  "post-merge-pre-opt",
+  "Embed post merge, but before optimizations")),
 cl::desc("Embed LLVM bitcode in object files produced by LTO"));
 
 LLVM_ATTRIBUTE_NORETURN static void reportOpenError(StringRef Path, Twine Msg) {
@@ -346,7 +352,25 @@
 
 bool opt(const Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod,
  bool IsThinLTO, ModuleSummaryIndex *ExportSummary,
- const ModuleSummaryIndex *ImportSummary) {
+ const ModuleSummaryIndex *ImportSummary,
+ const std::vector *CmdArgs = nullptr) {
+  if (EmbedBitcode == LTOBitcodeEmbedding::EmbedPostMergePreOptimized) {
+// FIXME: the motivation for capturing post-merge bitcode and command line
+// is replicating the compilation environment from bitcode, without needing
+// to understand the dependencies (the functions to be imported). This
+// assumes a clang - based invocation, case in which we have the command
+// line.
+// It's not very clear how the above motivation would map in the
+// linker-based case, so we currently don't plumb the command line args in
+// that case.
+if (CmdArgs == nullptr)
+  LLVM_DEBUG(
+  dbgs() << "Post-(Thin)LTO merge bitcode embedding was requested, but "
+"command line arguments are not available");
+llvm::EmbedBitcodeInModule(Mod, llvm::MemoryBufferRef(),
+   /*EmbedBitcode*/ true,
+   /*EmbedMarker*/ false, CmdArgs);
+  }
   // FIXME: Plumb the combined index into the new pass manager.
   if (!Conf.OptPipeline.empty())
 runNewPMCustomPasses(Conf, Mod, TM, Conf.OptPipeline, Conf.AAPipeline,
@@ -531,7 +555,8 @@
Module &Mod, const ModuleSummaryIndex &CombinedIndex,
const FunctionImporter::ImportMapTy &ImportList,
const GVSummaryMapTy &DefinedGlobals,
-   MapVector &ModuleMap) {
+   MapVector &Module

[clang] 61fc10d - [ThinLTO] add post-thinlto-merge option to -lto-embed-bitcode

2020-09-15 Thread Mircea Trofin via cfe-commits

Author: Mircea Trofin
Date: 2020-09-15T15:56:11-07:00
New Revision: 61fc10d6a520f267e11009ce8fce88d73615796b

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

LOG: [ThinLTO] add post-thinlto-merge option to -lto-embed-bitcode

This will embed bitcode after (Thin)LTO merge, but before optimizations.
In the case the thinlto backend is called from clang, the .llvmcmd
section is also produced. Doing so in the case where the caller is the
linker doesn't yet have a motivation, and would require plumbing through
command line args.

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

Added: 
clang/test/CodeGen/Inputs/start-lib1.ll
clang/test/CodeGen/Inputs/start-lib2.ll
clang/test/CodeGen/thinlto_embed_bitcode.ll

Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/LTO/LTOBackend.h
llvm/lib/LTO/LTOBackend.cpp
llvm/test/LTO/X86/Inputs/start-lib1.ll
llvm/test/LTO/X86/embed-bitcode.ll

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 5fc80d4fae71..01f7e239f790 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1647,9 +1647,10 @@ static void runThinLTOBackend(
 Conf.CGFileType = getCodeGenFileType(Action);
 break;
   }
-  if (Error E = thinBackend(
-  Conf, -1, AddStream, *M, *CombinedIndex, ImportList,
-  ModuleToDefinedGVSummaries[M->getModuleIdentifier()], ModuleMap)) {
+  if (Error E =
+  thinBackend(Conf, -1, AddStream, *M, *CombinedIndex, ImportList,
+  ModuleToDefinedGVSummaries[M->getModuleIdentifier()],
+  ModuleMap, &CGOpts.CmdArgs)) {
 handleAllErrors(std::move(E), [&](ErrorInfoBase &EIB) {
   errs() << "Error running ThinLTO backend: " << EIB.message() << '\n';
 });

diff  --git a/clang/test/CodeGen/Inputs/start-lib1.ll 
b/clang/test/CodeGen/Inputs/start-lib1.ll
new file mode 100644
index ..18b6ea25386f
--- /dev/null
+++ b/clang/test/CodeGen/Inputs/start-lib1.ll
@@ -0,0 +1,9 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @bar()
+
+define void @foo() {
+  call void @bar()
+  ret void
+}

diff  --git a/clang/test/CodeGen/Inputs/start-lib2.ll 
b/clang/test/CodeGen/Inputs/start-lib2.ll
new file mode 100644
index ..68b3c8362808
--- /dev/null
+++ b/clang/test/CodeGen/Inputs/start-lib2.ll
@@ -0,0 +1,6 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @bar() {
+  ret void
+}

diff  --git a/clang/test/CodeGen/thinlto_embed_bitcode.ll 
b/clang/test/CodeGen/thinlto_embed_bitcode.ll
new file mode 100644
index ..4efb525e5f3e
--- /dev/null
+++ b/clang/test/CodeGen/thinlto_embed_bitcode.ll
@@ -0,0 +1,30 @@
+; REQUIRES: x86-registered-target
+
+; check the -lto-embed-bitcode=post-thinlto-merge does not perform 
optimizations
+; we expect 't1' - i.e start-lib1.ll's products - have both foo and bar 
defined,
+; but the bar call is still made from foo.
+; RUN: opt -module-summary %p/Inputs/start-lib1.ll -o %t1.bc
+; RUN: opt -module-summary %p/Inputs/start-lib2.ll -o %t2.bc
+; RUN: llvm-lto -thinlto -o %t.o %t1.bc %t2.bc
+
+; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t.o -x ir %t1.bc -c 
-fthinlto-index=%t.o.thinlto.bc -mllvm -lto-embed-bitcode=post-merge-pre-opt
+; RUN: llvm-readelf -S %t.o | FileCheck %s --check-prefixes=CHECK-ELF,CHECK-CMD
+; RUN: llvm-objcopy --dump-section=.llvmbc=%t-embedded.bc %t.o /dev/null
+; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-NOOPT
+
+; For the optimized case, we expect the inlining of foo into bar to happen.
+; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t.o -x ir %t1.bc -c 
-fthinlto-index=%t.o.thinlto.bc -mllvm -lto-embed-bitcode=optimized
+; RUN: llvm-readelf -S %t.o | FileCheck %s 
--check-prefixes=CHECK-ELF,CHECK-NO-CMD
+; RUN: llvm-objcopy --dump-section=.llvmbc=%t-embedded.bc %t.o /dev/null
+; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-OPT
+
+; CHECK-ELF:  .text   PROGBITS  [[#%x,OFF:]] [[#%x,SIZE:]] 
00 AX 0
+; CHECK-ELF-NEXT: .llvmbc PROGBITS  [[#%x,OFF:]] [[#%x,SIZE:]] 
000
+; CHECK-ELF-CMD:  .llvmcmd
+; CHECK-ELF-NO-CMD-NOT: .llvmcmd
+
+; CHECK:  define void @foo() 
+; CHECK-OPT-NEXT:   ret void
+; CHECK-NOOPT-NEXT: call void @bar()
+; CHECK-NOOPT: define available_externally void @bar() !thinlto_src_module !0 {
+; CHECK-NOOPT-NEXT: ret void

diff  --git a/llvm/include/llvm/LTO/LTOBackend.h 
b/llvm/include/llvm/LTO/LTOBackend.h
index 0226e4a3fbf5..735969c47039 100644
--- a/llvm/include/llvm/LTO/LTOBackend.h
+++ b/ll

[clang] ae726fe - [SourceManager] Explicitly check for potential iterator underflow

2020-09-15 Thread Jan Korous via cfe-commits

Author: Jan Korous
Date: 2020-09-15T15:54:16-07:00
New Revision: ae726fecae9a1cc9c50de5a9f6e860056f82c556

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

LOG: [SourceManager] Explicitly check for potential iterator underflow

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

Added: 


Modified: 
clang/lib/Basic/SourceManager.cpp

Removed: 




diff  --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 0a76c78cd44f..0f194403bf04 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -1936,6 +1936,11 @@ 
SourceManager::getMacroArgExpandedLocation(SourceLocation Loc) const {
 
   assert(!MacroArgsCache->empty());
   MacroArgsMap::iterator I = MacroArgsCache->upper_bound(Offset);
+  // In case every element in MacroArgsCache is greater than Offset we can't
+  // decrement the iterator.
+  if (I == MacroArgsCache->begin())
+return Loc;
+
   --I;
 
   unsigned MacroArgBeginOffs = I->first;



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


[PATCH] D86231: [SourceManager] Explicitly check for potential iterator underflow

2020-09-15 Thread Jan Korous via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGae726fecae9a: [SourceManager] Explicitly check for potential 
iterator underflow (authored by jkorous).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86231

Files:
  clang/lib/Basic/SourceManager.cpp


Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -1936,6 +1936,11 @@
 
   assert(!MacroArgsCache->empty());
   MacroArgsMap::iterator I = MacroArgsCache->upper_bound(Offset);
+  // In case every element in MacroArgsCache is greater than Offset we can't
+  // decrement the iterator.
+  if (I == MacroArgsCache->begin())
+return Loc;
+
   --I;
 
   unsigned MacroArgBeginOffs = I->first;


Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -1936,6 +1936,11 @@
 
   assert(!MacroArgsCache->empty());
   MacroArgsMap::iterator I = MacroArgsCache->upper_bound(Offset);
+  // In case every element in MacroArgsCache is greater than Offset we can't
+  // decrement the iterator.
+  if (I == MacroArgsCache->begin())
+return Loc;
+
   --I;
 
   unsigned MacroArgBeginOffs = I->first;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87636: [ThinLTO] add post-thinlto-merge option to -lto-embed-bitcode

2020-09-15 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin updated this revision to Diff 292041.
mtrofin marked 3 inline comments as done.
mtrofin added a comment.

comment update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87636

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/Inputs/start-lib1.ll
  clang/test/CodeGen/Inputs/start-lib2.ll
  clang/test/CodeGen/thinlto_embed_bitcode.ll
  llvm/include/llvm/LTO/LTOBackend.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/test/LTO/X86/Inputs/start-lib1.ll
  llvm/test/LTO/X86/embed-bitcode.ll

Index: llvm/test/LTO/X86/embed-bitcode.ll
===
--- llvm/test/LTO/X86/embed-bitcode.ll
+++ llvm/test/LTO/X86/embed-bitcode.ll
@@ -11,13 +11,20 @@
 ; RUN: llvm-lto2 run -r %t1.o,_start,px -r %t2.o,foo,px -r %t3.o,bar,px -r %t2.o,bar,lx -lto-embed-bitcode=optimized -o %t3 %t1.o %t2.o %t3.o
 ; RUN: llvm-readelf -S %t3.0 | FileCheck %s --check-prefix=CHECK-ELF
 ; RUN: llvm-objcopy --dump-section=.llvmbc=%t-embedded.bc %t3.0 /dev/null
-; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefix=CHECK-LL
+; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefixes=CHECK-LL,CHECK-OPT
+
+; RUN: llvm-lto2 run -r %t1.o,_start,px -r %t2.o,foo,px -r %t3.o,bar,px -r %t2.o,bar,lx -lto-embed-bitcode=post-merge-pre-opt -o %t3 %t1.o %t2.o %t3.o
+; RUN: llvm-readelf -S %t3.0 | FileCheck %s --check-prefix=CHECK-ELF
+; RUN: llvm-objcopy --dump-section=.llvmbc=%t-embedded.bc %t3.0 /dev/null
+; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefixes=CHECK-LL,CHECK-NOOPT
 
 ; CHECK-ELF:  .text   PROGBITS  [[#%x,OFF:]] [[#%x,SIZE:]] 00 AX 0
 ; CHECK-ELF-NEXT: .llvmbc PROGBITS  [[#%x,OFF:]] [[#%x,SIZE:]] 000
 
 ; CHECK-LL: @_start
 ; CHECK-LL: @foo
+; CHECK-OPT-NEXT: ret void
+; CHECK-NOOPT-NEXT: call void @bar
 ; CHECK-LL: @bar
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
Index: llvm/lib/LTO/LTOBackend.cpp
===
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -50,9 +50,12 @@
 using namespace llvm;
 using namespace lto;
 
+#define DEBUG_TYPE "lto-backend"
+
 enum class LTOBitcodeEmbedding {
   DoNotEmbed = 0,
   EmbedOptimized = 1,
+  EmbedPostMergePreOptimized = 2
 };
 
 static cl::opt EmbedBitcode(
@@ -60,7 +63,10 @@
 cl::values(clEnumValN(LTOBitcodeEmbedding::DoNotEmbed, "none",
   "Do not embed"),
clEnumValN(LTOBitcodeEmbedding::EmbedOptimized, "optimized",
-  "Embed after all optimization passes")),
+  "Embed after all optimization passes"),
+   clEnumValN(LTOBitcodeEmbedding::EmbedPostMergePreOptimized,
+  "post-merge-pre-opt",
+  "Embed post merge, but before optimizations")),
 cl::desc("Embed LLVM bitcode in object files produced by LTO"));
 
 LLVM_ATTRIBUTE_NORETURN static void reportOpenError(StringRef Path, Twine Msg) {
@@ -346,7 +352,25 @@
 
 bool opt(const Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod,
  bool IsThinLTO, ModuleSummaryIndex *ExportSummary,
- const ModuleSummaryIndex *ImportSummary) {
+ const ModuleSummaryIndex *ImportSummary,
+ const std::vector *CmdArgs = nullptr) {
+  if (EmbedBitcode == LTOBitcodeEmbedding::EmbedPostMergePreOptimized) {
+// FIXME: the motivation for capturing post-merge bitcode and command line
+// is replicating the compilation environment from bitcode, without needing
+// to understand the dependencies (the functions to be imported). This
+// assumes a clang - based invocation, case in which we have the command
+// line.
+// It's not very clear how the above motivation would map in the
+// linker-based case, so we currently don't plumb the command line args in
+// that case.
+if (CmdArgs == nullptr)
+  LLVM_DEBUG(
+  dbgs() << "Post-(Thin)LTO merge bitcode embedding was requested, but "
+"command line arguments are not available");
+llvm::EmbedBitcodeInModule(Mod, llvm::MemoryBufferRef(),
+   /*EmbedBitcode*/ true,
+   /*EmbedMarker*/ false, CmdArgs);
+  }
   // FIXME: Plumb the combined index into the new pass manager.
   if (!Conf.OptPipeline.empty())
 runNewPMCustomPasses(Conf, Mod, TM, Conf.OptPipeline, Conf.AAPipeline,
@@ -531,7 +555,8 @@
Module &Mod, const ModuleSummaryIndex &CombinedIndex,
const FunctionImporter::ImportMapTy &ImportList,
const GVSummaryMapTy &DefinedGlobals,
-   MapVector &ModuleMap) {
+   MapVector &ModuleMap,
+   const std::vector *CmdArgs) {
   Expected TOrErr = initAndLookupTarget(Conf, Mod);
   if (

[PATCH] D87636: [ThinLTO] add post-thinlto-merge option to -lto-embed-bitcode

2020-09-15 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin added inline comments.



Comment at: llvm/lib/LTO/LTOBackend.cpp:368
+  LLVM_DEBUG(
+  dbgs() << "Post-ThinLTO merge bitcode embedding was requested, but "
+"command line arguments are not available");

tejohnson wrote:
> Update comment
oh, yes... done


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87636

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


[PATCH] D87636: [ThinLTO] add post-thinlto-merge option to -lto-embed-bitcode

2020-09-15 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

LGTM, just needs a comment update as noted below and also an update to the 
patch title.




Comment at: llvm/lib/LTO/LTOBackend.cpp:368
+  LLVM_DEBUG(
+  dbgs() << "Post-ThinLTO merge bitcode embedding was requested, but "
+"command line arguments are not available");

Update comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87636

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


[PATCH] D87636: [ThinLTO] add post-thinlto-merge option to -lto-embed-bitcode

2020-09-15 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin updated this revision to Diff 292040.
mtrofin added a comment.

feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87636

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/Inputs/start-lib1.ll
  clang/test/CodeGen/Inputs/start-lib2.ll
  clang/test/CodeGen/thinlto_embed_bitcode.ll
  llvm/include/llvm/LTO/LTOBackend.h
  llvm/lib/LTO/LTOBackend.cpp
  llvm/test/LTO/X86/Inputs/start-lib1.ll
  llvm/test/LTO/X86/embed-bitcode.ll

Index: llvm/test/LTO/X86/embed-bitcode.ll
===
--- llvm/test/LTO/X86/embed-bitcode.ll
+++ llvm/test/LTO/X86/embed-bitcode.ll
@@ -11,13 +11,20 @@
 ; RUN: llvm-lto2 run -r %t1.o,_start,px -r %t2.o,foo,px -r %t3.o,bar,px -r %t2.o,bar,lx -lto-embed-bitcode=optimized -o %t3 %t1.o %t2.o %t3.o
 ; RUN: llvm-readelf -S %t3.0 | FileCheck %s --check-prefix=CHECK-ELF
 ; RUN: llvm-objcopy --dump-section=.llvmbc=%t-embedded.bc %t3.0 /dev/null
-; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefix=CHECK-LL
+; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefixes=CHECK-LL,CHECK-OPT
+
+; RUN: llvm-lto2 run -r %t1.o,_start,px -r %t2.o,foo,px -r %t3.o,bar,px -r %t2.o,bar,lx -lto-embed-bitcode=post-merge-pre-opt -o %t3 %t1.o %t2.o %t3.o
+; RUN: llvm-readelf -S %t3.0 | FileCheck %s --check-prefix=CHECK-ELF
+; RUN: llvm-objcopy --dump-section=.llvmbc=%t-embedded.bc %t3.0 /dev/null
+; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefixes=CHECK-LL,CHECK-NOOPT
 
 ; CHECK-ELF:  .text   PROGBITS  [[#%x,OFF:]] [[#%x,SIZE:]] 00 AX 0
 ; CHECK-ELF-NEXT: .llvmbc PROGBITS  [[#%x,OFF:]] [[#%x,SIZE:]] 000
 
 ; CHECK-LL: @_start
 ; CHECK-LL: @foo
+; CHECK-OPT-NEXT: ret void
+; CHECK-NOOPT-NEXT: call void @bar
 ; CHECK-LL: @bar
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
Index: llvm/lib/LTO/LTOBackend.cpp
===
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -50,9 +50,12 @@
 using namespace llvm;
 using namespace lto;
 
+#define DEBUG_TYPE "lto-backend"
+
 enum class LTOBitcodeEmbedding {
   DoNotEmbed = 0,
   EmbedOptimized = 1,
+  EmbedPostMergePreOptimized = 2
 };
 
 static cl::opt EmbedBitcode(
@@ -60,7 +63,10 @@
 cl::values(clEnumValN(LTOBitcodeEmbedding::DoNotEmbed, "none",
   "Do not embed"),
clEnumValN(LTOBitcodeEmbedding::EmbedOptimized, "optimized",
-  "Embed after all optimization passes")),
+  "Embed after all optimization passes"),
+   clEnumValN(LTOBitcodeEmbedding::EmbedPostMergePreOptimized,
+  "post-merge-pre-opt",
+  "Embed post merge, but before optimizations")),
 cl::desc("Embed LLVM bitcode in object files produced by LTO"));
 
 LLVM_ATTRIBUTE_NORETURN static void reportOpenError(StringRef Path, Twine Msg) {
@@ -346,7 +352,25 @@
 
 bool opt(const Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod,
  bool IsThinLTO, ModuleSummaryIndex *ExportSummary,
- const ModuleSummaryIndex *ImportSummary) {
+ const ModuleSummaryIndex *ImportSummary,
+ const std::vector *CmdArgs = nullptr) {
+  if (EmbedBitcode == LTOBitcodeEmbedding::EmbedPostMergePreOptimized) {
+// FIXME: the motivation for capturing post-merge bitcode and command line
+// is replicating the compilation environment from bitcode, without needing
+// to understand the dependencies (the functions to be imported). This
+// assumes a clang - based invocation, case in which we have the command
+// line.
+// It's not very clear how the above motivation would map in the
+// linker-based case, so we currently don't plumb the command line args in
+// that case.
+if (CmdArgs == nullptr)
+  LLVM_DEBUG(
+  dbgs() << "Post-ThinLTO merge bitcode embedding was requested, but "
+"command line arguments are not available");
+llvm::EmbedBitcodeInModule(Mod, llvm::MemoryBufferRef(),
+   /*EmbedBitcode*/ true,
+   /*EmbedMarker*/ false, CmdArgs);
+  }
   // FIXME: Plumb the combined index into the new pass manager.
   if (!Conf.OptPipeline.empty())
 runNewPMCustomPasses(Conf, Mod, TM, Conf.OptPipeline, Conf.AAPipeline,
@@ -531,7 +555,8 @@
Module &Mod, const ModuleSummaryIndex &CombinedIndex,
const FunctionImporter::ImportMapTy &ImportList,
const GVSummaryMapTy &DefinedGlobals,
-   MapVector &ModuleMap) {
+   MapVector &ModuleMap,
+   const std::vector *CmdArgs) {
   Expected TOrErr = initAndLookupTarget(Conf, Mod);
   if (!TOrErr)
 return TOrErr.takeError();
@@ -599,7

[PATCH] D87636: [ThinLTO] add post-thinlto-merge option to -lto-embed-bitcode

2020-09-15 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: llvm/lib/LTO/LTOBackend.cpp:621
+"command line arguments are not available");
+llvm::EmbedBitcodeInModule(Mod, llvm::MemoryBufferRef(),
+   /*EmbedBitcode*/ true,

How about putting this at the start of opt() instead? Then it works for both 
Thin and Regular LTO. I would change the name to something like 
EmbedPreOptimized or something like that. Or EmbedPostMergePreOptimized if you 
want to be very exact (either name fits for the regular LTO scenario as well).



Comment at: llvm/test/LTO/X86/embed-bitcode.ll:11
 
 ; RUN: llvm-lto2 run -r %t1.o,_start,px -r %t2.o,foo,px -r %t3.o,bar,px -r 
%t2.o,bar,lx -lto-embed-bitcode=optimized -o %t3 %t1.o %t2.o %t3.o
 ; RUN: llvm-readelf -S %t3.0 | FileCheck %s --check-prefix=CHECK-ELF

Probably check the new case here too once it works for regular LTO as suggested 
above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87636

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


[PATCH] D84887: [OPENMP]Fix codegen for is_device_ptr component, captured by reference.

2020-09-15 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9e3842d60351: [OPENMP]Fix codegen for is_device_ptr 
component, captured by reference. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84887

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


Index: clang/test/OpenMP/target_is_device_ptr_codegen.cpp
===
--- clang/test/OpenMP/target_is_device_ptr_codegen.cpp
+++ clang/test/OpenMP/target_is_device_ptr_codegen.cpp
@@ -285,4 +285,41 @@
   ++arg;
 }
 #endif
+///==///
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix 
CK3 --check-prefix CK3-64
+// RUN: %clang_cc1 -DCK3 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ 
-triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s  --check-prefix CK3 --check-prefix CK3-64
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu 
-x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  
--check-prefix CK3 --check-prefix CK3-32
+// RUN: %clang_cc1 -DCK3 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ 
-std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple 
i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s  --check-prefix CK3 --check-prefix CK3-32
+
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp-simd 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix 
SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -fopenmp-simd 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x 
c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp-simd 
-fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x 
c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ 
-triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm 
-o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
+#ifdef CK3
+
+// CK3-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[SZ:64|32]]] [i{{64|32}} 
{{8|4}}]
+// OMP_MAP_TARGET_PARAM = 0x20 | OMP_MAP_TO = 0x1 = 0x21
+// CK3-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x21]]]
+void bar() {
+  __attribute__((aligned(64))) double *ptr;
+  // CK3-DAG: call i32 @__tgt_target_mapper(i64 {{.+}}, i8* {{.+}}, i32 1, 
i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZES]]{{.+}}, 
{{.+}}[[TYPES]]{{.+}}, i8** null)
+  // CK3-DAG: [[BPGEP]] = getelementptr inbounds {{.+}}[[BPS:%[^,]+]], i32 0, 
i32 0
+  // CK3-DAG: [[PGEP]] = getelementptr inbounds {{.+}}[[PS:%[^,]+]], i32 0, 
i32 0
+  // CK3-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BPS]], i32 0, i32 0
+  // CK3-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[PS]], i32 0, i32 0
+  // CK3-DAG: [[CBP1:%.+]] = bitcast i8** [[BP1]] to double***
+  // CK3-DAG: [[CP1:%.+]] = bitcast i8** [[P1]] to double***
+  // CK3-DAG: store double** [[PTR:%.+]], double*** [[CBP1]]
+  // CK3-DAG: store double** [[PTR]], double*** [[CP1]]
+
+  // CK3: call void [[KERNEL:@.+]](double** [[PTR]])
+#pragma omp target is_device_ptr(ptr)
+  *ptr = 0;
+}
+#endif
 #endif
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8460,10 +8460,12 @@
 if (DevPointersMap.count(VD)) {
   CombinedInfo.BasePointers.emplace_back(Arg, VD);
   CombinedInfo.Pointers.push_back(Arg);
-  CombinedInfo.Sizes.push_back(
-  
CGF.Builder.CreateIntCast(CGF.getTypeSize(CGF.getContext().VoidPtrTy),
-CGF.Int64Ty, /*isSigned=*/true));
-  CombinedInfo.Types.push_back(OMP_MAP_LITERAL | OMP_MAP_TARGET_PARAM);
+  CombinedInfo.Sizes.push_back(CGF.Builder.CreateIntCast(
+  CGF.getTypeSize(CGF.getContext().VoidPtrTy), CGF.Int64Ty,
+ 

[clang] 9e3842d - [OPENMP]Fix codegen for is_device_ptr component, captured by reference.

2020-09-15 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-09-15T17:21:38-04:00
New Revision: 9e3842d60351f986d77dfe0a94f76e4fd895f188

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

LOG: [OPENMP]Fix codegen for is_device_ptr component, captured by reference.

Need to map the component as TO instead of the literal, because need to
pass a reference to a component if the pointer is overaligned.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/target_is_device_ptr_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index e507e434d9e1..dfd9752c20c9 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8460,10 +8460,12 @@ class MappableExprsHandler {
 if (DevPointersMap.count(VD)) {
   CombinedInfo.BasePointers.emplace_back(Arg, VD);
   CombinedInfo.Pointers.push_back(Arg);
-  CombinedInfo.Sizes.push_back(
-  
CGF.Builder.CreateIntCast(CGF.getTypeSize(CGF.getContext().VoidPtrTy),
-CGF.Int64Ty, /*isSigned=*/true));
-  CombinedInfo.Types.push_back(OMP_MAP_LITERAL | OMP_MAP_TARGET_PARAM);
+  CombinedInfo.Sizes.push_back(CGF.Builder.CreateIntCast(
+  CGF.getTypeSize(CGF.getContext().VoidPtrTy), CGF.Int64Ty,
+  /*isSigned=*/true));
+  CombinedInfo.Types.push_back(
+  (Cap->capturesVariable() ? OMP_MAP_TO : OMP_MAP_LITERAL) |
+  OMP_MAP_TARGET_PARAM);
   CombinedInfo.Mappers.push_back(nullptr);
   return;
 }

diff  --git a/clang/test/OpenMP/target_is_device_ptr_codegen.cpp 
b/clang/test/OpenMP/target_is_device_ptr_codegen.cpp
index 7c2eef577f9f..a7c585751161 100644
--- a/clang/test/OpenMP/target_is_device_ptr_codegen.cpp
+++ b/clang/test/OpenMP/target_is_device_ptr_codegen.cpp
@@ -285,4 +285,41 @@ void bar(double *arg){
   ++arg;
 }
 #endif
+///==///
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix 
CK3 --check-prefix CK3-64
+// RUN: %clang_cc1 -DCK3 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ 
-triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s  --check-prefix CK3 --check-prefix CK3-64
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu 
-x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  
--check-prefix CK3 --check-prefix CK3-32
+// RUN: %clang_cc1 -DCK3 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ 
-std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple 
i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s  --check-prefix CK3 --check-prefix CK3-32
+
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp-simd 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix 
SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -fopenmp-simd 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x 
c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -verify -fopenmp-simd 
-fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// RUN: %clang_cc1 -DCK3 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x 
c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ 
-triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm 
-o - | FileCheck --check-prefix SIMD-ONLY1 %s
+// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
+#ifdef CK3
+
+// CK3-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i[[SZ:64|32]]] [i{{64|32}} 
{{8|4}}]
+// OMP_MAP_TARGET_PARAM = 0x20 | OMP_MAP_TO = 0x1 = 0x21
+// CK3-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x21]]]
+void bar() {
+  __attribute__((aligned(64))) double *ptr;
+  // CK3-DAG: call i32 @__tgt_target_mapper(i64 {{.+}}, i8* {{.+}}, i32 1, 
i8** [[BPGEP:%[0-9]+]], i8** [[PGEP:%[0-9]+]], {{.+}}[[SIZES]]{{.+}}, 
{{.+}}[[

[PATCH] D87710: [clangd] Actually parse Index section of the YAML file.

2020-09-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

oh shoot, thanks for catching this. i'll leave the stamp to sam, just came here 
to remind that this needs to be cherry-picked into release branch :/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87710

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


[PATCH] D87450: [clangd] Implement hot index reloading for clangd-index-server

2020-09-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

oops, looks like i forgot to hit submit in the morning..




Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:228
+  auto Status = FS->status(IndexPath);
+  if (!Status || Status->equivalent(LastStatus))
+return;

i beleive `equivalent` checks for inode number equivalence (at least on linux, 
using realfilesystem). That's not guranteed to change when you overwrite/modify 
a file.

Sorry if it felt like i meant this, but I was literally suggesting to use `!=` 
instead of `<=` when comparing modifcation time, and also incorporating size 
into the check.

Also please let me know if there's something i am missing with the `equivalent`.

It would be also nice to have some tests, as we are starting to add non-trivial 
functionality to server but not blocking for this patch. (i suppose it would've 
catched the equivalent problem)



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:234
+   LastStatus.getLastModificationTime(), 
Status->getLastModificationTime());
+  std::unique_ptr NewIndex = loadIndex(IndexPath);
+  if (!NewIndex) {

i think we should update `LastStatus` here, as we are going to fail loading the 
index unless the file changes. so there's no need to retry loading the index if 
the file hasn't changed.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:236
+  if (!NewIndex) {
+vlog("Failed to load new index. Old index will be served.");
+return;

i believe, this should be an `elog`.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:240
+  Index.reset(std::move(NewIndex));
+  log("New index version loaded. Last modification time: {0}.",
+  Status->getLastModificationTime());

nit: maybe also print the size.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:318
+  if (!Status) {
+elog("File {0} does not exist.", IndexPath);
+return Status.getError().value();

nit: drop `File`



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:335
+  std::this_thread::sleep_for(RefreshFrequency);
+  hotReload(*Index, llvm::StringRef(IndexPath), LastStatus, FS);
+}

nit: i would first call `hotReload` and then sleep to get rid of one extra 
reload of the index when we are shutting down.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:342
+  HotReloadThread.join();
 }

nit: `return 0;` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87450

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


[PATCH] D87532: Sema: add support for `__attribute__((__swift_bridge__))`

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

LGTM!




Comment at: clang/include/clang/Basic/Attr.td:2134
+def SwiftBridge : Attr {
+  let Spellings = [GNU<"swift_bridge">];
+  let Args = [StringArgument<"SwiftType">];

compnerd wrote:
> aaron.ballman wrote:
> > Is it intentional that this is `swift_bridge` but we just added 
> > `swift_bridged_typedef` (bridge vs bridged)? That seems like a bit of a 
> > spelling gotcha, if it can be corrected.
> Yes, that is intentional.  This has already shipped, so Im afraid that 
> changing the spelling isn't really reasonable at this point.  I agree that it 
> is is a spelling gotcha, but fortunately, most of the uses of these are done 
> through macros (e.g. `CF_REFINED_FOR_SWIFT`).
Okie dokie, that's what I figured.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87532

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


[PATCH] D87534: Sema: introduce `__attribute__((__swift_name__))`

2020-09-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2173
+  SubjectList<[Enum, EnumConstant, Field, Function, GlobalVar, Struct, 
TypedefName,
+   ObjCInterface, ObjCClassMethod, ObjCInstanceMethod, 
ObjCProperty, ObjCProtocol],
+  ErrorDiag, "ExpectedSwiftNameSubjects">;

doug.gregor wrote:
> compnerd wrote:
> > Note for @rjmccall and @doug.gregor - this version actually enumerates the 
> > subjects to which this attribute appertains unlike what was in the original 
> > swift version.  Are there other subjects which this should list?
> Hmm. If we enumerate the subjects, we're going to have to update Clang 
> whenever Swift's Clang importer learns a new trick. For example, this is 
> probably missing CXXMethod and FunctionTmpl based on work that's going on in 
> Swift. I suspect we're also missing ObjCCompatibilityAlias. I'm inclined to 
> treat this more like AsmLabelAttr and not try to enumerate subjects at all.
That seems fair to me.  I'll try to remove the subject list and try to clean up 
the fallout.



Comment at: clang/test/SemaObjC/attr-swift-name.m:1
+// RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc -fblocks %s
+

aaron.ballman wrote:
> The `fblocks` makes me wonder -- should this attribute be one you can write 
> on a block?
This is not something that can be applied to blocks.  Removing the `-fblocks` 
is probably a good idea since it isn't actually used.  copy-paste failure on my 
part :-(.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87534

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


[PATCH] D87532: Sema: add support for `__attribute__((__swift_bridge__))`

2020-09-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 292018.
compnerd added a comment.

Address feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87532

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/AST/attr-swift_bridge.m
  clang/test/SemaObjC/attr-swift_bridge.m

Index: clang/test/SemaObjC/attr-swift_bridge.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-swift_bridge.m
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+// expected-error@+1 {{'__swift_bridge__' attribute takes one argument}}
+__attribute__((__swift_bridge__))
+@interface I
+@end
+
+// expected-error@+1 {{'__swift_bridge__' attribute requires a string}}
+__attribute__((__swift_bridge__(1)))
+@interface J
+@end
+
+// expected-error@+1 {{'__swift_bridge__' attribute takes one argument}}
+__attribute__((__swift_bridge__("K", 1)))
+@interface K
+@end
+
+@interface L
+// expected-error@+1 {{'__swift_bridge__' attribute only applies to tag types, typedefs, Objective-C interfaces, and Objective-C protocols}}
+- (void)method __attribute__((__swift_bridge__("method")));
+@end
+
+__attribute__((__swift_bridge__("Array")))
+@interface NSArray
+@end
+
+__attribute__((__swift_bridge__("ProtocolP")))
+@protocol P
+@end
+
+typedef NSArray *NSArrayAlias __attribute__((__swift_bridge__("ArrayAlias")));
+
+struct __attribute__((__swift_bridge__("StructT"))) T {};
Index: clang/test/AST/attr-swift_bridge.m
===
--- /dev/null
+++ clang/test/AST/attr-swift_bridge.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -ast-dump %s | FileCheck %s
+
+struct __attribute__((__swift_bridge__("BridgedS"))) S;
+// CHECK: RecordDecl {{.*}} struct S
+// CHECK: SwiftBridgeAttr {{.*}} "BridgedS"
+
+struct S {
+};
+
+// CHECK: RecordDecl {{.*}} struct S definition
+// CHECK: SwiftBridgeAttr {{.*}} Inherited "BridgedS"
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5524,6 +5524,22 @@
   D->addAttr(::new (S.Context) ObjCPreciseLifetimeAttr(S.Context, AL));
 }
 
+static void handleSwiftBridge(Sema &S, Decl *D, const ParsedAttr &AL) {
+  // Make sure that there is a string literal as the annotation's single
+  // argument.
+  StringRef BT;
+  if (!S.checkStringLiteralArgumentAttr(AL, 0, BT))
+return;
+
+  // Don't duplicate annotations that are already set.
+  if (D->hasAttr()) {
+S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL;
+return;
+  }
+
+  D->addAttr(::new (S.Context) SwiftBridgeAttr(S.Context, AL, BT));
+}
+
 static bool isErrorParameter(Sema &S, QualType QT) {
   const auto *PT = QT->getAs();
   if (!PT)
@@ -7533,6 +7549,9 @@
 break;
 
   // Swift attributes.
+  case ParsedAttr::AT_SwiftBridge:
+handleSwiftBridge(S, D, AL);
+break;
   case ParsedAttr::AT_SwiftBridgedTypedef:
 handleSimpleAttribute(S, D, AL);
 break;
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -3476,6 +3476,30 @@
   }];
 }
 
+def SwiftBridgeDocs : Documentation {
+  let Category = SwiftDocs;
+  let Heading = "swift_bridge";
+  let Content = [{
+The ``swift_bridge`` attribute indicates that the declaration to which the
+attribute appertains is bridged to the named Swift type.
+
+  .. code-block:: c
+
+__attribute__((__objc_root__))
+@interface Base
+- (instancetype)init;
+@end
+
+__attribute__((__swift_bridge__("BridgedI")))
+@interface I : Base
+@end
+
+In this example, the Objective-C interface ``I`` will be made available to Swift
+with the name ``BridgedI``.  It would be possible for the compiler to refer to
+``I`` still in order to bridge the type back to Objective-C.
+  }];
+}
+
 def SwiftBridgedTypedefDocs : Documentation {
   let Category = SwiftDocs;
   let Heading = "swift_bridged";
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -2130,6 +2130,14 @@
   let ASTNode = 0;
 }
 
+def SwiftBridge : InheritableAttr {
+  let Spellings = [GNU<"swift_bridge">];
+  let Args = [StringArgument<"SwiftType">];
+  let Subjects = SubjectList<[Tag, TypedefName, ObjCInterface, ObjCProtocol],
+ ErrorDiag>;
+  let Documentation = [SwiftBridgeDocs];
+}
+
 def SwiftBridgedTypedef : InheritableAttr {
   let Spellings = [GNU<"swift_bridged_typedef">];
   let Subjects = SubjectList<[TypedefName], ErrorDiag>;
___
cfe-commits mailing list
cfe-commits@lists.llvm.

[PATCH] D84362: [NFC] Add missing functions to PartialDiagnostic

2020-09-15 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D84362#2275029 , @yaxunl wrote:

> 

Perhaps we could inherit `PartialDiagnostic` from `DiagnosticBuilder` base 
class. This would probably be the least invasive approach as it would preserve 
existing uses while allowing reuse of common `DiagnosticBuilder` functionality. 
That said, it would muddle the meaning of PartialDiagnostic even more -- is it 
the diagnostic itself, or a thing that produces the diagnostic?

To think of it, we actually don't need the `DiagnosticBuilderBase` per se, but 
rather a limited subset of operations for implementing freestanding 
`operator<<`.  So the base class for `DiagnosticBuilder` and 
`PartialDiagnostic` could be called `StreamableDiagnosticBase` and only provide 
those bits. This way the arrangement looks a bit less awkward. Both 
DiagnosticBuilder and PartialDiagnostic would inherit from it and would work 
with `operator<<(StreamableDiagnosticBase)`. We may need to convert  
StreamableDiagnosticBase results back to the original type.


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

https://reviews.llvm.org/D84362

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


[PATCH] D86369: [Sema][MSVC] warn at dynamic_cast when /GR- is given

2020-09-15 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 292017.
zequanwu added a comment.

reopen the diff and update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86369

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/ms-no-rtti-data.cpp
  clang/test/SemaCXX/no-rtti-data.cpp

Index: clang/test/SemaCXX/no-rtti-data.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/no-rtti-data.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux -fno-rtti-data -fsyntax-only -verify
+
+namespace std {
+struct type_info {};
+} // namespace std
+class B {
+public:
+  virtual ~B() = default;
+};
+
+class D1 : public B {
+public:
+  ~D1() = default;
+};
+
+void f() {
+  B* b = new D1();
+  auto d = dynamic_cast(b); // expected-warning{{dynamic_cast will not work since RTTI data is disabled by -fno-rtti-data}}
+  void* v = dynamic_cast(b);
+
+  (void)typeid(int);
+  (void)typeid(b);
+  (void)typeid(*b); // expected-warning{{typeid will not work since RTTI data is disabled by -fno-rtti-data}}
+  B b2 = *b;
+  (void)typeid(b2);
+  (void)typeid(*&b2); // expected-warning{{typeid will not work since RTTI data is disabled by -fno-rtti-data}}
+  (void)typeid((B&)b2);
+  
+  B& br = b2;
+  (void)typeid(br); // expected-warning{{typeid will not work since RTTI data is disabled by -fno-rtti-data}}
+  (void)typeid(&br);
+}
\ No newline at end of file
Index: clang/test/SemaCXX/ms-no-rtti-data.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/ms-no-rtti-data.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -triple x86_64-windows-msvc -fdiagnostics-format msvc -fno-rtti-data -fsyntax-only -verify
+
+namespace std {
+struct type_info {};
+} // namespace std
+class B {
+public:
+  virtual ~B() = default;
+};
+
+class D1 : public B {
+public:
+  ~D1() = default;
+};
+
+void f() {
+  B* b = new D1();
+  auto d = dynamic_cast(b); // expected-warning{{dynamic_cast will not work since RTTI data is disabled by /GR-}}
+  void* v = dynamic_cast(b); // expected-warning{{dynamic_cast will not work since RTTI data is disabled by /GR-}}
+
+  (void)typeid(int);
+  (void)typeid(b);
+  (void)typeid(*b); // expected-warning{{typeid will not work since RTTI data is disabled by /GR-}}
+  B b2 = *b;
+  (void)typeid(b2);
+  (void)typeid(*&b2); // expected-warning{{typeid will not work since RTTI data is disabled by /GR-}}
+  (void)typeid((B&)b2);
+  
+  B& br = b2;
+  (void)typeid(br); // expected-warning{{typeid will not work since RTTI data is disabled by /GR-}}
+  (void)typeid(&br);
+}
\ No newline at end of file
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -663,7 +663,16 @@
   }
 
   // The operand is an expression.
-  return BuildCXXTypeId(TypeInfoType, OpLoc, (Expr*)TyOrExpr, RParenLoc);
+  ExprResult Result =
+  BuildCXXTypeId(TypeInfoType, OpLoc, (Expr *)TyOrExpr, RParenLoc);
+
+  if (!getLangOpts().RTTIData && !Result.isInvalid())
+if (auto *CTE = dyn_cast(Result.get()))
+  if (CTE->isPotentiallyEvaluated() && !CTE->isMostDerived(Context))
+Diag(OpLoc, diag::warn_no_typeid_with_rtti_disabled)
+<< (getDiagnostics().getDiagnosticOptions().getFormat() ==
+DiagnosticOptions::MSVC);
+  return Result;
 }
 
 /// Grabs __declspec(uuid()) off a type, or returns 0 if we cannot resolve to
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -889,6 +889,18 @@
 return;
   }
 
+  // Warns when dynamic_cast is used with RTTI data disabled.
+  if (!Self.getLangOpts().RTTIData) {
+bool MicrosoftABI =
+Self.getASTContext().getTargetInfo().getCXXABI().isMicrosoft();
+bool isClangCL = Self.getDiagnostics().getDiagnosticOptions().getFormat() ==
+ DiagnosticOptions::MSVC;
+if (MicrosoftABI || !DestPointee->isVoidType())
+  Self.Diag(OpRange.getBegin(),
+diag::warn_no_dynamic_cast_with_rtti_disabled)
+  << isClangCL;
+  }
+
   // Done. Everything else is run-time checks.
   Kind = CK_Dynamic;
 }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7451,6 +7451,12 @@
   "use of typeid requires -frtti">;
 def err_no_dynamic_cast_with_fno_rtti : Error<
   "use of dynamic_cast requires -frtti">;
+def warn_no_dynamic_cast_with_rtti_disabled: Warning<
+  "dynamic_cast will not work since RTTI data is d

[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-15 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Right!
I believe the solution is to set the location size to unknown after a phi 
translation with the same ptr, but I need to properly verify that.

  // include/llvm/Analysis/MemorySSA.h:1233
  CurrentPair.second = Location.getWithNewSize(LocationSize::unknown());
  return


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

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


[PATCH] D87532: Sema: add support for `__attribute__((__swift_bridge__))`

2020-09-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd marked an inline comment as done.
compnerd added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2134
+def SwiftBridge : Attr {
+  let Spellings = [GNU<"swift_bridge">];
+  let Args = [StringArgument<"SwiftType">];

aaron.ballman wrote:
> Is it intentional that this is `swift_bridge` but we just added 
> `swift_bridged_typedef` (bridge vs bridged)? That seems like a bit of a 
> spelling gotcha, if it can be corrected.
Yes, that is intentional.  This has already shipped, so Im afraid that changing 
the spelling isn't really reasonable at this point.  I agree that it is is a 
spelling gotcha, but fortunately, most of the uses of these are done through 
macros (e.g. `CF_REFINED_FOR_SWIFT`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87532

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


[PATCH] D87720: Sema: add support for `__attribute__((__swift_private__))`

2020-09-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added a reviewer: aaron.ballman.
Herald added a project: clang.
compnerd requested review of this revision.

This attribute allows declarations to be restricted to the framework
itself, enabling Swift to remove the declarations when importing
libraries.  This is useful in the case that the functions can be
implemented in a more natural way for Swift.

This is based on the work of the original changes in
https://github.com/llvm/llvm-project-staging/commit/8afaf3aad2af43cfedca7a24cd817848c4e95c0c


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87720

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaObjC/attr-swift-private.m

Index: clang/test/SemaObjC/attr-swift-private.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-swift-private.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc -fblocks %s
+
+__attribute__((__swift_private__))
+@protocol P
+@end
+
+__attribute__((__swift_private__))
+@interface I
+@end
+
+@interface J
+@property id property __attribute__((__swift_private__));
+- (void)instanceMethod __attribute__((__swift_private__));
++ (void)classMethod __attribute__((__swift_private__));
+@end
+
+void f(void) __attribute__((__swift_private__));
+
+struct __attribute__((__swift_private__)) S {};
+
+enum __attribute__((__swift_private__)) E {
+  one,
+  two,
+};
+
+typedef struct { } T __attribute__((__swift_private__));
+
+void g(void) __attribute__((__swift_private__("private")));
+// expected-error@-1 {{'__swift_private__' attribute takes no arguments}}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -7853,6 +7853,9 @@
   case ParsedAttr::AT_SwiftObjCMembers:
 handleSimpleAttribute(S, D, AL);
 break;
+  case ParsedAttr::AT_SwiftPrivate:
+handleSimpleAttribute(S, D, AL);
+break;
 
   // XRay attributes.
   case ParsedAttr::AT_XRayLogArgs:
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2610,6 +2610,8 @@
   else if (const auto *SNA = dyn_cast(Attr))
 NewAttr = S.mergeSwiftNameAttr(D, *SNA,
SNA->getName(), AMK == Sema::AMK_Override);
+  else if (isa(Attr) && AMK == Sema::AMK_Override)
+NewAttr = nullptr;
   else if (const auto *OA = dyn_cast(Attr))
 NewAttr = S.mergeOptimizeNoneAttr(D, *OA);
   else if (const auto *InternalLinkageA = dyn_cast(Attr))
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -3585,6 +3585,19 @@
   }];
 }
 
+def SwiftPrivateDocs : Documentation {
+  let Category = SwiftDocs;
+  let Heading = "swift_private";
+  let Content = [{
+Objective-C declarations marked with the ``swift_private`` attribute are hidden
+from the framework client but are still made available for use within the
+framework or Swift SDK overlay.
+
+The purpose of this attribute is to permit a more idomatic implementation of
+declarations in Swift.
+  }];
+}
+
 def OMPDeclareSimdDocs : Documentation {
   let Category = DocCatFunction;
   let Heading = "#pragma omp declare simd";
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -2183,6 +2183,15 @@
   let Documentation = [SwiftNewTypeDocs];
 }
 
+def SwiftPrivate : InheritableAttr {
+  let Spellings = [GNU<"swift_private">];
+  let Subjects =
+  SubjectList<[Enum, Function, Struct, TypedefName,
+   ObjCClassMethod, ObjCInstanceMethod, ObjCInterface, ObjCProperty, ObjCProtocol],
+  ErrorDiag>;
+  let Documentation = [SwiftPrivateDocs];
+}
+
 def NoDeref : TypeAttr {
   let Spellings = [Clang<"noderef">];
   let Documentation = [NoDerefDocs];
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87396: Sema: add support for `__attribute__((__swift_bridged_typedef__))`

2020-09-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7d26d6a1b062: Sema: add support for 
`__attribute__((__swift_bridged_typedef__))` (authored by compnerd).

Changed prior to commit:
  https://reviews.llvm.org/D87396?vs=291687&id=292009#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87396

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/AST/attr-swift_bridged_typedef.m
  clang/test/AST/attr-swift_bridged_typedef.mm
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaObjC/attr-swift_bridged_typedef.m

Index: clang/test/SemaObjC/attr-swift_bridged_typedef.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-swift_bridged_typedef.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+@interface NSString
+@end
+
+typedef NSString *NSStringAlias __attribute__((__swift_bridged_typedef__));
+
+typedef int IntAlias __attribute__((__swift_bridged_typedef__));
+
+struct __attribute__((swift_bridged_typedef)) S {};
+// expected-error@-1 {{'swift_bridged_typedef' attribute only applies to typedefs}}
+
+typedef unsigned char UnsignedChar __attribute__((__swift_bridged_typedef__("UnsignedChar")));
+// expected-error@-1 {{'__swift_bridged_typedef__' attribute takes no arguments}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -146,6 +146,7 @@
 // CHECK-NEXT: Section (SubjectMatchRule_function, SubjectMatchRule_variable_is_global, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
 // CHECK-NEXT: SetTypestate (SubjectMatchRule_function_is_member)
 // CHECK-NEXT: SpeculativeLoadHardening (SubjectMatchRule_function, SubjectMatchRule_objc_method)
+// CHECK-NEXT: SwiftBridgedTypedef (SubjectMatchRule_type_alias)
 // CHECK-NEXT: SwiftContext (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: SwiftError (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: SwiftErrorResult (SubjectMatchRule_variable_is_parameter)
Index: clang/test/AST/attr-swift_bridged_typedef.mm
===
--- /dev/null
+++ clang/test/AST/attr-swift_bridged_typedef.mm
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only %s -ast-dump | FileCheck %s
+
+@interface NSString
+@end
+
+using NSStringAlias __attribute__((__swift_bridged_typedef__)) = NSString *;
+// CHECK: TypeAliasDecl {{.*}} NSStringAlias 'NSString *'
+// CHECK: SwiftBridgedTypedefAttr
Index: clang/test/AST/attr-swift_bridged_typedef.m
===
--- /dev/null
+++ clang/test/AST/attr-swift_bridged_typedef.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -ast-dump %s | FileCheck %s
+
+typedef struct T TBridged __attribute((__swift_bridged_typedef__));
+// CHECK: TypedefDecl {{.*}} TBridged 'struct T'
+// CHECK: SwiftBridgedTypedefAttr
+
+typedef struct T TBridged;
+// CHECK: TypedefDecl {{.*}} TBridged 'struct T'
+// CHECK: SwiftBridgedTypedefAttr
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -7533,6 +7533,9 @@
 break;
 
   // Swift attributes.
+  case ParsedAttr::AT_SwiftBridgedTypedef:
+handleSimpleAttribute(S, D, AL);
+break;
   case ParsedAttr::AT_SwiftError:
 handleSwiftError(S, D, AL);
 break;
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -3476,6 +3476,27 @@
   }];
 }
 
+def SwiftBridgedTypedefDocs : Documentation {
+  let Category = SwiftDocs;
+  let Heading = "swift_bridged";
+  let Content = [{
+The ``swift_bridged_typedef`` attribute indicates that when the typedef to which
+the attribute appertains is imported into Swift, it should refer to the bridged
+Swift type (e.g. Swift's ``String``) rather than the Objective-C type as written
+(e.g. ``NSString``).
+
+  .. code-block:: c
+
+@interface NSString;
+typedef NSString *AliasedString __attribute__((__swift_bridged_typedef__));
+
+extern void acceptsAliasedString(AliasedString _Nonnull parameter);
+
+In this case, the function ``acceptsAliasedString`` will be imported into Swift
+as a function which accepts a ``String`` type parameter.
+  }];
+}
+
 def SwiftObjCMembersDocs : Documentation {
   let Category = SwiftDocs;
   let Heading = "swift_objc_members";
Index: clang/include/clang/Basic/Attr.td
===

[clang] 7d26d6a - Sema: add support for `__attribute__((__swift_bridged_typedef__))`

2020-09-15 Thread Saleem Abdulrasool via cfe-commits

Author: Saleem Abdulrasool
Date: 2020-09-15T20:15:34Z
New Revision: 7d26d6a1b062f7ce820b02b39d102d5f8f15fa5f

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

LOG: Sema: add support for `__attribute__((__swift_bridged_typedef__))`

Extend the semantic attributes that clang processes for Swift to include
`swift_bridged_typedef`.  This attribute enables typedefs to be bridged
into Swift with a bridged name.

This is based on the work of the original changes in
https://github.com/llvm/llvm-project-staging/commit/8afaf3aad2af43cfedca7a24cd817848c4e95c0c

Differential Revision: https://reviews.llvm.org/D87396
Reviewed By: Aaron Ballman

Added: 
clang/test/AST/attr-swift_bridged_typedef.m
clang/test/AST/attr-swift_bridged_typedef.mm
clang/test/SemaObjC/attr-swift_bridged_typedef.m

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 3221cf23c4b5..6df348618260 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2130,6 +2130,12 @@ def Regparm : TypeAttr {
   let ASTNode = 0;
 }
 
+def SwiftBridgedTypedef : InheritableAttr {
+  let Spellings = [GNU<"swift_bridged_typedef">];
+  let Subjects = SubjectList<[TypedefName], ErrorDiag>;
+  let Documentation = [SwiftBridgedTypedefDocs];
+}
+
 def SwiftObjCMembers : Attr {
   let Spellings = [GNU<"swift_objc_members">];
   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 939f52dae3d5..7aff443e9a12 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -3476,6 +3476,27 @@ Swift.
   }];
 }
 
+def SwiftBridgedTypedefDocs : Documentation {
+  let Category = SwiftDocs;
+  let Heading = "swift_bridged";
+  let Content = [{
+The ``swift_bridged_typedef`` attribute indicates that when the typedef to 
which
+the attribute appertains is imported into Swift, it should refer to the bridged
+Swift type (e.g. Swift's ``String``) rather than the Objective-C type as 
written
+(e.g. ``NSString``).
+
+  .. code-block:: c
+
+@interface NSString;
+typedef NSString *AliasedString __attribute__((__swift_bridged_typedef__));
+
+extern void acceptsAliasedString(AliasedString _Nonnull parameter);
+
+In this case, the function ``acceptsAliasedString`` will be imported into Swift
+as a function which accepts a ``String`` type parameter.
+  }];
+}
+
 def SwiftObjCMembersDocs : Documentation {
   let Category = SwiftDocs;
   let Heading = "swift_objc_members";

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index bf9d8497f5a2..02ffd752233d 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -7533,6 +7533,9 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, 
Decl *D,
 break;
 
   // Swift attributes.
+  case ParsedAttr::AT_SwiftBridgedTypedef:
+handleSimpleAttribute(S, D, AL);
+break;
   case ParsedAttr::AT_SwiftError:
 handleSwiftError(S, D, AL);
 break;

diff  --git a/clang/test/AST/attr-swift_bridged_typedef.m 
b/clang/test/AST/attr-swift_bridged_typedef.m
new file mode 100644
index ..8c7c0987569e
--- /dev/null
+++ b/clang/test/AST/attr-swift_bridged_typedef.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -ast-dump %s | FileCheck %s
+
+typedef struct T TBridged __attribute((__swift_bridged_typedef__));
+// CHECK: TypedefDecl {{.*}} TBridged 'struct T'
+// CHECK: SwiftBridgedTypedefAttr
+
+typedef struct T TBridged;
+// CHECK: TypedefDecl {{.*}} TBridged 'struct T'
+// CHECK: SwiftBridgedTypedefAttr

diff  --git a/clang/test/AST/attr-swift_bridged_typedef.mm 
b/clang/test/AST/attr-swift_bridged_typedef.mm
new file mode 100644
index ..44fd022d5ea7
--- /dev/null
+++ b/clang/test/AST/attr-swift_bridged_typedef.mm
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only %s -ast-dump | FileCheck %s
+
+@interface NSString
+@end
+
+using NSStringAlias __attribute__((__swift_bridged_typedef__)) = NSString *;
+// CHECK: TypeAliasDecl {{.*}} NSStringAlias 'NSString *'
+// CHECK: SwiftBridgedTypedefAttr

diff  --git a/clang/test/Misc/pragma-attribute-supported-attributes-list.test 
b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
index dcf7cd2b7f1a..024081b02e3e 100644
--- a/clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -146,6 +146,7 @@
 // CHECK-NEXT: Section (SubjectMatchRule_function, 
SubjectMatchRule_variable_is_

[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-15 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D87163#2275058 , @asbirlea wrote:

> Yes, the load should have the Phi as the defining access. I'm still looking 
> into where this information should come from, but it's not hitting the phi 
> translation.
> Thank you for the revert, I'll update with the fix once I have it available.

Thanks! I also started looking into where things go wrong. It appears that this 
happens during MemorySSA use optimization. 
(https://github.com/llvm/llvm-project/blob/master/llvm/lib/Analysis/MemorySSA.cpp#L1447).
 It seems like `getClobberingMemoryAccess` does not account for the fact that 
the query location could map to multiple memory locations if it is loop 
dependent. Just querying AA for both pointers will return `noalias`, because 
they only alias for different concrete phi values. I am not sure if we have a 
safe way to detect that a location actually refers to a range of locations. I 
am currently experimenting with being more conservative in 
`getClobberingMemoryAccess` for locations for which we cannot prove that they 
are loop-invariant for possible cycle in the function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

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


[PATCH] D87717: [docs] Update ControlFlowIntegrity.rst.

2020-09-15 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis created this revision.
eugenis added a reviewer: pcc.
Herald added a subscriber: dexonsmith.
Herald added a project: clang.
eugenis requested review of this revision.
Herald added a subscriber: aheejin.

Expand the list of targets that support cfi-icall.
Add ThinLTO everywhere LTO is mentioned. AFAIK all CFI features are
supported with ThinLTO.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87717

Files:
  clang/docs/ControlFlowIntegrity.rst


Index: clang/docs/ControlFlowIntegrity.rst
===
--- clang/docs/ControlFlowIntegrity.rst
+++ clang/docs/ControlFlowIntegrity.rst
@@ -76,8 +76,8 @@
 to use all schemes except for non-virtual member function call and indirect 
call
 checking.
 
-Remember that you have to provide ``-flto`` if at least one CFI scheme is
-enabled.
+Remember that you have to provide ``-flto`` or ``-flto=thin`` if at
+least one CFI scheme is enabled.
 
 Trapping and Diagnostics
 
@@ -217,7 +217,8 @@
 shared library boundaries are handled as if the callee was not compiled with
 ``-fsanitize=cfi-icall``.
 
-This scheme is currently only supported on the x86 and x86_64 architectures.
+This scheme is currently supported on a limited set of targets: x86,
+x86_64, arm, arch64 and wasm.
 
 ``-fsanitize-cfi-icall-generalize-pointers``
 
@@ -368,7 +369,7 @@
 Use **-f[no-]sanitize-cfi-cross-dso** to enable the cross-DSO control
 flow integrity mode, which allows all CFI schemes listed above to
 apply across DSO boundaries. As in the regular CFI, each DSO must be
-built with ``-flto``.
+built with ``-flto`` or ``flto=thin``.
 
 Normally, CFI checks will only be performed for classes that have hidden LTO
 visibility. With this flag enabled, the compiler will emit cross-DSO CFI


Index: clang/docs/ControlFlowIntegrity.rst
===
--- clang/docs/ControlFlowIntegrity.rst
+++ clang/docs/ControlFlowIntegrity.rst
@@ -76,8 +76,8 @@
 to use all schemes except for non-virtual member function call and indirect call
 checking.
 
-Remember that you have to provide ``-flto`` if at least one CFI scheme is
-enabled.
+Remember that you have to provide ``-flto`` or ``-flto=thin`` if at
+least one CFI scheme is enabled.
 
 Trapping and Diagnostics
 
@@ -217,7 +217,8 @@
 shared library boundaries are handled as if the callee was not compiled with
 ``-fsanitize=cfi-icall``.
 
-This scheme is currently only supported on the x86 and x86_64 architectures.
+This scheme is currently supported on a limited set of targets: x86,
+x86_64, arm, arch64 and wasm.
 
 ``-fsanitize-cfi-icall-generalize-pointers``
 
@@ -368,7 +369,7 @@
 Use **-f[no-]sanitize-cfi-cross-dso** to enable the cross-DSO control
 flow integrity mode, which allows all CFI schemes listed above to
 apply across DSO boundaries. As in the regular CFI, each DSO must be
-built with ``-flto``.
+built with ``-flto`` or ``flto=thin``.
 
 Normally, CFI checks will only be performed for classes that have hidden LTO
 visibility. With this flag enabled, the compiler will emit cross-DSO CFI
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-15 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

Yes, the load should have the Phi as the defining access. I'm still looking 
into where this information should come from, but it's not hitting the phi 
translation.
Thank you for the revert, I'll update with the fix once I have it available.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

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


[PATCH] D87047: [clang] Add command line options for the Machine Function Splitter.

2020-09-15 Thread Snehasish Kumar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf1a3ab904439: [clang] Add a command line flag for the 
Machine Function Splitter. (authored by snehasish).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87047

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fsplit-machine-functions.c


Index: clang/test/Driver/fsplit-machine-functions.c
===
--- /dev/null
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -0,0 +1,9 @@
+// RUN: %clang -### -target x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
+// RUN: %clang -### -target x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck 
-check-prefix=CHECK-NOOPT %s
+// RUN: %clang -### -target x86_64 -fsplit-machine-functions %s 2>&1 | 
FileCheck -check-prefix=CHECK-WARN %s
+// RUN: not %clang -c -target arm-unknown-linux -fsplit-machine-functions %s 
2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+
+// CHECK-OPT:   "-fsplit-machine-functions"
+// CHECK-NOOPT-NOT: "-fsplit-machine-functions"
+// CHECK-WARN:  warning: argument '-fsplit-machine-functions' requires 
profile-guided optimization information
+// CHECK-TRIPLE:error: unsupported option '-fsplit-machine-functions' for 
target
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -998,6 +998,8 @@
   Opts.UniqueInternalLinkageNames =
   Args.hasArg(OPT_funique_internal_linkage_names);
 
+  Opts.SplitMachineFunctions = Args.hasArg(OPT_fsplit_machine_functions);
+
   Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
 
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4911,6 +4911,26 @@
options::OPT_fno_unique_basic_block_section_names, false))
 CmdArgs.push_back("-funique-basic-block-section-names");
 
+  if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
+   options::OPT_fno_split_machine_functions)) {
+// This codegen pass is only available on x86-elf targets.
+if (Triple.isX86() && Triple.isOSBinFormatELF()) {
+  if (A->getOption().matches(options::OPT_fsplit_machine_functions)) {
+// If the flag is enabled but no profile information is available then
+// emit a warning.
+if (getLastProfileUseArg(Args) || getLastProfileSampleUseArg(Args)) {
+  A->render(Args, CmdArgs);
+} else {
+  D.Diag(diag::warn_drv_diagnostics_hotness_requires_pgo)
+  << A->getAsString(Args);
+}
+  }
+} else {
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;
+}
+  }
+
   Args.AddLastArg(CmdArgs, options::OPT_finstrument_functions,
   options::OPT_finstrument_functions_after_inlining,
   options::OPT_finstrument_function_entry_bare);
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -514,6 +514,7 @@
   Options.BBSectionsFuncListBuf = std::move(*MBOrErr);
   }
 
+  Options.EnableMachineFunctionSplitter = CodeGenOpts.SplitMachineFunctions;
   Options.FunctionSections = CodeGenOpts.FunctionSections;
   Options.DataSections = CodeGenOpts.DataSections;
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1996,6 +1996,9 @@
 defm unique_section_names : OptOutFFlag<"unique-section-names",
   "", "Don't use unique names for text and data sections">;
 
+defm split_machine_functions: OptInFFlag<"split-machine-functions",
+  "Enable", "Disable", " late function splitting using profile information 
(x86 ELF)">;
+
 defm strict_return : OptOutFFlag<"strict-return", "",
   "Don't treat control flow paths that fall off the end of a non-void function 
as unreachable">;
 
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.d

[clang] f1a3ab9 - [clang] Add a command line flag for the Machine Function Splitter.

2020-09-15 Thread Snehasish Kumar via cfe-commits

Author: Snehasish Kumar
Date: 2020-09-15T12:41:58-07:00
New Revision: f1a3ab904439a63b21ba1c4521765c46630687c6

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

LOG: [clang] Add a command line flag for the Machine Function Splitter.

This patch adds a command line flag for the machine function splitter
(added in rG94faadaca4e1).

-fsplit-machine-functions
Split machine functions using profile information (x86 ELF). On
other targets an error is emitted. If profile information is not
provided a warning is emitted notifying the user that profile
information is required.

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

Added: 
clang/test/Driver/fsplit-machine-functions.c

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index feb4ed01f6e8..b5da2a9cde1a 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -162,6 +162,7 @@ CODEGENOPT(NoImplicitFloat   , 1, 0) ///< Set when 
-mno-implicit-float is enable
 CODEGENOPT(NullPointerIsValid , 1, 0) ///< Assume Null pointer deference is 
defined.
 CODEGENOPT(CorrectlyRoundedDivSqrt, 1, 0) ///< 
-cl-fp32-correctly-rounded-divide-sqrt
 CODEGENOPT(UniqueInternalLinkageNames, 1, 0) ///< Internal Linkage symbols get 
unique names.
+CODEGENOPT(SplitMachineFunctions, 1, 0) ///< Split machine functions using 
profile information.
 
 /// When false, this attempts to generate code as if the result of an
 /// overflowing conversion matches the overflowing behavior of a target's 
native

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f196c1b72d27..5b39ea513b24 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1996,6 +1996,9 @@ defm unique_internal_linkage_names : 
OptInFFlag<"unique-internal-linkage-names",
 defm unique_section_names : OptOutFFlag<"unique-section-names",
   "", "Don't use unique names for text and data sections">;
 
+defm split_machine_functions: OptInFFlag<"split-machine-functions",
+  "Enable", "Disable", " late function splitting using profile information 
(x86 ELF)">;
+
 defm strict_return : OptOutFFlag<"strict-return", "",
   "Don't treat control flow paths that fall off the end of a non-void function 
as unreachable">;
 

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 472d86ea2e36..5fc80d4fae71 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -514,6 +514,7 @@ static void initTargetOptions(DiagnosticsEngine &Diags,
   Options.BBSectionsFuncListBuf = std::move(*MBOrErr);
   }
 
+  Options.EnableMachineFunctionSplitter = CodeGenOpts.SplitMachineFunctions;
   Options.FunctionSections = CodeGenOpts.FunctionSections;
   Options.DataSections = CodeGenOpts.DataSections;
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 40659ebb1395..51056960761d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4911,6 +4911,26 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
options::OPT_fno_unique_basic_block_section_names, false))
 CmdArgs.push_back("-funique-basic-block-section-names");
 
+  if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
+   options::OPT_fno_split_machine_functions)) {
+// This codegen pass is only available on x86-elf targets.
+if (Triple.isX86() && Triple.isOSBinFormatELF()) {
+  if (A->getOption().matches(options::OPT_fsplit_machine_functions)) {
+// If the flag is enabled but no profile information is available then
+// emit a warning.
+if (getLastProfileUseArg(Args) || getLastProfileSampleUseArg(Args)) {
+  A->render(Args, CmdArgs);
+} else {
+  D.Diag(diag::warn_drv_diagnostics_hotness_requires_pgo)
+  << A->getAsString(Args);
+}
+  }
+} else {
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;
+}
+  }
+
   Args.AddLastArg(CmdArgs, options::OPT_finstrument_functions,
   options::OPT_finstrument_functions_after_inlining,
   options::OPT_finstrument_function_entry_bare);

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocatio

[PATCH] D87615: [X86] Fix stack alignment on 32-bit Solaris/x86

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

Also, it would be nice to have some regression test coverage; add a Solaris RUN 
line to llvm/test/CodeGen/X86/stack-align2.ll ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87615

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


[PATCH] D84362: [NFC] Add missing functions to PartialDiagnostic

2020-09-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D84362#2274884 , @tra wrote:

> In D84362#2274790 , @yaxunl wrote:
>
>> There are use patterns expecting `PartialDiagnosticInst << X << Y` to 
>> continue to be a `PartialDiagnostic&`, e.g.
>>
>>   PartialDiagnosticAt PDAt(SourceLoc, PartialDiagnosticInst << X << Y);
>>
>> However if we derive PartialDiagnostic and DiagnosticBuilder from a base 
>> class DiagnosticBuilderBase which implements the `<<` operators, 
>> `PartialDiagnosticInst << X << Y` will become a `DiagnosticBuilderBase&`, 
>> then we can no longer write the above code.
>>
>> That's one reason I use templates to implement `<<` operators.
>>
>> Do we want to sacrifice this convenience?
>
> I don't think we have to. 
> AFAICT, virtually all such patterns (and there are only 20-ish of them in 
> total) are used with `EmitFormatDiagnostic(S.PDiag())` which could be adapted 
> to accept `DiagnosticBuilderBase` and `Sema::PDiag()` changed to return 
> `PartialDiagnosticBuilder` with no loss of convenience.

I saw lots of usage of PartialDiagnosticAt, which is defined at

https://github.com/llvm/llvm-project/blob/8c3d0d6a5f5a2a521c4cbae7acbad82a49e2a92f/clang/include/clang/Basic/PartialDiagnostic.h#L417

It requres a PartialDiagnostic as the second argument.

A typical use is like

https://github.com/llvm/llvm-project/blob/69f98311ca42127df92527b6fc3be99841a15f12/clang/lib/Sema/AnalysisBasedWarnings.cpp#L1741

If we use a base class DiagnosticBuilderBase to implement `<<` operators, 
`S.PDiag(diag::warn_unlock_but_no_lock) << Kind << LockName` becomes 
`DiagnosticBuilderBase&` and we can no longer write the above code.

There are ~100 uses like that.


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

https://reviews.llvm.org/D84362

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


[PATCH] D87615: [X86] Fix stack alignment on 32-bit Solaris/x86

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



Comment at: llvm/lib/Target/X86/X86Subtarget.cpp:270
+  else if (isTargetSolaris() && !In64BitMode)
+stackAlignment = Align(4);
 

stackAlignment is initialized to 4 in the header, so `stackAlignment = 
Align(4)` here is a no-op.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87615

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


[clang] 05aa997 - [PowerPC] Implement __int128 vector divide operations

2020-09-15 Thread Albion Fung via cfe-commits

Author: Albion Fung
Date: 2020-09-15T15:19:35-04:00
New Revision: 05aa997d511eed530305e2f3aa401584d0691186

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

LOG: [PowerPC] Implement __int128 vector divide operations

This patch implements __int128 vector divide operations for ISA3.1.

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

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-p10vector.c
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCInstrPrefix.td
llvm/test/CodeGen/PowerPC/p10-vector-divide.ll

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 22744adefbef..51fd3d21b5e1 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -3368,6 +3368,18 @@ vec_dive(vector unsigned long long __a, vector unsigned 
long long __b) {
 }
 #endif
 
+#ifdef __POWER10_VECTOR__
+static __inline__ vector unsigned __int128 __ATTRS_o_ai
+vec_div(vector unsigned __int128 __a, vector unsigned __int128 __b) {
+  return __a / __b;
+}
+
+static __inline__ vector signed __int128 __ATTRS_o_ai
+vec_div(vector signed __int128 __a, vector signed __int128 __b) {
+  return __a / __b;
+}
+#endif __POWER10_VECTOR__
+
 /* vec_dss */
 
 #define vec_dss __builtin_altivec_dss

diff  --git a/clang/test/CodeGen/builtins-ppc-p10vector.c 
b/clang/test/CodeGen/builtins-ppc-p10vector.c
index ad63d646196c..12ec3a6ab8f3 100644
--- a/clang/test/CodeGen/builtins-ppc-p10vector.c
+++ b/clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -17,6 +17,7 @@ vector signed int vsia, vsib;
 vector unsigned int vuia, vuib, vuic;
 vector signed long long vslla, vsllb;
 vector unsigned long long vulla, vullb, vullc;
+vector signed __int128 vsi128a, vsi128b;
 vector unsigned __int128 vui128a, vui128b, vui128c;
 vector float vfa, vfb;
 vector double vda, vdb;
@@ -69,6 +70,18 @@ vector unsigned long long test_vec_div_ull(void) {
   return vec_div(vulla, vullb);
 }
 
+vector unsigned __int128 test_vec_div_u128(void) {
+  // CHECK: udiv <1 x i128>
+  // CHECK-NEXT: ret <1 x i128>
+  return vec_div(vui128a, vui128b);
+}
+
+vector signed __int128 test_vec_div_s128(void) {
+  // CHECK: sdiv <1 x i128>
+  // CHECK-NEXT: ret <1 x i128>
+  return vec_div(vsi128a, vsi128b);
+}
+
 vector signed int test_vec_dive_si(void) {
   // CHECK: @llvm.ppc.altivec.vdivesw(<4 x i32> %{{.+}}, <4 x i32> %{{.+}})
   // CHECK-NEXT: ret <4 x i32>

diff  --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp 
b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 66711f69a645..3b0acfa76ec8 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -888,6 +888,8 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine 
&TM,
   setOperationAction(ISD::SREM, MVT::v2i64, Legal);
   setOperationAction(ISD::UREM, MVT::v4i32, Legal);
   setOperationAction(ISD::SREM, MVT::v4i32, Legal);
+  setOperationAction(ISD::UDIV, MVT::v1i128, Legal);
+  setOperationAction(ISD::SDIV, MVT::v1i128, Legal);
 }
 
 setOperationAction(ISD::MUL, MVT::v8i16, Legal);

diff  --git a/llvm/lib/Target/PowerPC/PPCInstrPrefix.td 
b/llvm/lib/Target/PowerPC/PPCInstrPrefix.td
index 55872a493dd6..4e951114b90f 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ b/llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -1285,9 +1285,11 @@ let Predicates = [IsISA3_1] in {
[(set v1i128:$vD, (int_ppc_altivec_vmsumcud
  v2i64:$vA, v2i64:$vB, v1i128:$vC))]>;
   def VDIVSQ : VXForm_1<267, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
-"vdivsq $vD, $vA, $vB", IIC_VecGeneral, []>;
+"vdivsq $vD, $vA, $vB", IIC_VecGeneral,
+[(set v1i128:$vD, (sdiv v1i128:$vA, v1i128:$vB))]>;
   def VDIVUQ : VXForm_1<11, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
-"vdivuq $vD, $vA, $vB", IIC_VecGeneral, []>;
+"vdivuq $vD, $vA, $vB", IIC_VecGeneral,
+[(set v1i128:$vD, (udiv v1i128:$vA, v1i128:$vB))]>;
   def VDIVESQ : VXForm_1<779, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  "vdivesq $vD, $vA, $vB", IIC_VecGeneral, []>;
   def VDIVEUQ : VXForm_1<523, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),

diff  --git a/llvm/test/CodeGen/PowerPC/p10-vector-divide.ll 
b/llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
index dc21b4fb49ee..b5f36a78b2b2 100644
--- a/llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
+++ b/llvm/test/CodeGen/PowerPC/p10-vector-divide.ll
@@ -76,6 +76,24 @@ entry:
   ret <4 x i32> %div
 }
 
+define <1 x i128> @test_vdivsq(<1 x i128> %x, <1 x i128> %y) nounwind readnone 
{
+; CHECK-LABEL: test_vdivsq

[PATCH] D85453: [PowerPC] Implement __int128 vector divide operations

2020-09-15 Thread Albion Fung via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG05aa997d511e: [PowerPC] Implement __int128 vector divide 
operations (authored by Conanap).

Changed prior to commit:
  https://reviews.llvm.org/D85453?vs=283671&id=291999#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85453

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

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
@@ -76,6 +76,24 @@
   ret <4 x i32> %div
 }
 
+define <1 x i128> @test_vdivsq(<1 x i128> %x, <1 x i128> %y) nounwind readnone {
+; CHECK-LABEL: test_vdivsq:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vdivsq v2, v2, v3
+; CHECK-NEXT:blr
+  %tmp = sdiv <1 x i128> %x, %y
+  ret <1 x i128> %tmp
+}
+
+define <1 x i128> @test_vdivuq(<1 x i128> %x, <1 x i128> %y) nounwind readnone {
+; CHECK-LABEL: test_vdivuq:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vdivuq v2, v2, v3
+; CHECK-NEXT:blr
+  %tmp = udiv <1 x i128> %x, %y
+  ret <1 x i128> %tmp
+}
+
 define <2 x i64> @test_vdivesd(<2 x i64> %a, <2 x i64> %b) {
 ; CHECK-LABEL: test_vdivesd:
 ; CHECK:   # %bb.0: # %entry
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -1285,9 +1285,11 @@
[(set v1i128:$vD, (int_ppc_altivec_vmsumcud
  v2i64:$vA, v2i64:$vB, v1i128:$vC))]>;
   def VDIVSQ : VXForm_1<267, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
-"vdivsq $vD, $vA, $vB", IIC_VecGeneral, []>;
+"vdivsq $vD, $vA, $vB", IIC_VecGeneral,
+[(set v1i128:$vD, (sdiv v1i128:$vA, v1i128:$vB))]>;
   def VDIVUQ : VXForm_1<11, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
-"vdivuq $vD, $vA, $vB", IIC_VecGeneral, []>;
+"vdivuq $vD, $vA, $vB", IIC_VecGeneral,
+[(set v1i128:$vD, (udiv v1i128:$vA, v1i128:$vB))]>;
   def VDIVESQ : VXForm_1<779, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
  "vdivesq $vD, $vA, $vB", IIC_VecGeneral, []>;
   def VDIVEUQ : VXForm_1<523, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -888,6 +888,8 @@
   setOperationAction(ISD::SREM, MVT::v2i64, Legal);
   setOperationAction(ISD::UREM, MVT::v4i32, Legal);
   setOperationAction(ISD::SREM, MVT::v4i32, Legal);
+  setOperationAction(ISD::UDIV, MVT::v1i128, Legal);
+  setOperationAction(ISD::SDIV, MVT::v1i128, Legal);
 }
 
 setOperationAction(ISD::MUL, MVT::v8i16, Legal);
Index: clang/test/CodeGen/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -17,6 +17,7 @@
 vector unsigned int vuia, vuib, vuic;
 vector signed long long vslla, vsllb;
 vector unsigned long long vulla, vullb, vullc;
+vector signed __int128 vsi128a, vsi128b;
 vector unsigned __int128 vui128a, vui128b, vui128c;
 vector float vfa, vfb;
 vector double vda, vdb;
@@ -69,6 +70,18 @@
   return vec_div(vulla, vullb);
 }
 
+vector unsigned __int128 test_vec_div_u128(void) {
+  // CHECK: udiv <1 x i128>
+  // CHECK-NEXT: ret <1 x i128>
+  return vec_div(vui128a, vui128b);
+}
+
+vector signed __int128 test_vec_div_s128(void) {
+  // CHECK: sdiv <1 x i128>
+  // CHECK-NEXT: ret <1 x i128>
+  return vec_div(vsi128a, vsi128b);
+}
+
 vector signed int test_vec_dive_si(void) {
   // CHECK: @llvm.ppc.altivec.vdivesw(<4 x i32> %{{.+}}, <4 x i32> %{{.+}})
   // CHECK-NEXT: ret <4 x i32>
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -3368,6 +3368,18 @@
 }
 #endif
 
+#ifdef __POWER10_VECTOR__
+static __inline__ vector unsigned __int128 __ATTRS_o_ai
+vec_div(vector unsigned __int128 __a, vector unsigned __int128 __b) {
+  return __a / __b;
+}
+
+static __inline__ vector signed __int128 __ATTRS_o_ai
+vec_div(vector signed __int128 __a, vector signed __int128 __b) {
+  return __a / __b;
+}
+#endif __POWER10_VECTOR__
+
 /* vec_dss */
 
 #define vec_dss __builtin_altivec_dss
__

[PATCH] D87425: [CodeGen][typeid] Emit typeinfo directly if type is known at compile-time

2020-09-15 Thread Zequan Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
zequanwu marked an inline comment as done.
Closed by commit rGf975ae4867d1: [CodeGen][typeid] Emit typeinfo directly if 
type is known at compile-time (authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87425

Files:
  clang/include/clang/AST/ExprCXX.h
  clang/lib/AST/ExprCXX.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/test/CodeGenCXX/microsoft-abi-typeid.cpp


Index: clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
@@ -46,9 +46,11 @@
 
 const std::type_info* test5_typeid() { return &typeid(v); }
 // CHECK: define dso_local %struct.type_info* 
@"?test5_typeid@@YAPBUtype_info@@XZ"()
-// CHECK:[[RT:%.*]] = call i8* @__RTtypeid(i8* bitcast (%struct.V* 
@"?v@@3UV@@A" to i8*))
-// CHECK-NEXT:   [[RET:%.*]] = bitcast i8* [[RT]] to %struct.type_info*
-// CHECK-NEXT:   ret %struct.type_info* [[RET]]
+// CHECK:   ret %struct.type_info* bitcast (%rtti.TypeDescriptor7* 
@"??_R0?AUV@@@8" to %struct.type_info*)
+
+const std::type_info *test6_typeid() { return &typeid((V &)v); }
+// CHECK: define dso_local %struct.type_info* 
@"?test6_typeid@@YAPBUtype_info@@XZ"()
+// CHECK:   ret %struct.type_info* bitcast (%rtti.TypeDescriptor7* 
@"??_R0?AUV@@@8" to %struct.type_info*)
 
 namespace PR26329 {
 struct Polymorphic {
Index: clang/lib/CodeGen/CGExprCXX.cpp
===
--- clang/lib/CodeGen/CGExprCXX.cpp
+++ clang/lib/CodeGen/CGExprCXX.cpp
@@ -2199,7 +2199,8 @@
   //   polymorphic class type, the result refers to a std::type_info object
   //   representing the type of the most derived object (that is, the dynamic
   //   type) to which the glvalue refers.
-  if (E->isPotentiallyEvaluated())
+  // If the operand is already most derived object, no need to look up vtable.
+  if (E->isPotentiallyEvaluated() && !E->isMostDerived(getContext()))
 return EmitTypeidFromVTable(*this, E->getExprOperand(),
 StdTypeInfoPtrTy);
 
Index: clang/lib/AST/ExprCXX.cpp
===
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -146,6 +146,18 @@
   return false;
 }
 
+bool CXXTypeidExpr::isMostDerived(ASTContext &Context) const {
+  assert(!isTypeOperand() && "Cannot call isMostDerived for typeid(type)");
+  const Expr *E = getExprOperand()->IgnoreParenNoopCasts(Context);
+  if (const auto *DRE = dyn_cast(E)) {
+QualType Ty = DRE->getDecl()->getType();
+if (!Ty->isPointerType() && !Ty->isReferenceType())
+  return true;
+  }
+
+  return false;
+}
+
 QualType CXXTypeidExpr::getTypeOperand(ASTContext &Context) const {
   assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
   Qualifiers Quals;
Index: clang/include/clang/AST/ExprCXX.h
===
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -858,6 +858,10 @@
   /// evaluated, per C++11 [expr.typeid]p3.
   bool isPotentiallyEvaluated() const;
 
+  /// Best-effort check if the expression operand refers to a most derived
+  /// object. This is not a strong guarantee.
+  bool isMostDerived(ASTContext &Context) const;
+
   bool isTypeOperand() const { return Operand.is(); }
 
   /// Retrieves the type operand of this typeid() expression after


Index: clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
@@ -46,9 +46,11 @@
 
 const std::type_info* test5_typeid() { return &typeid(v); }
 // CHECK: define dso_local %struct.type_info* @"?test5_typeid@@YAPBUtype_info@@XZ"()
-// CHECK:[[RT:%.*]] = call i8* @__RTtypeid(i8* bitcast (%struct.V* @"?v@@3UV@@A" to i8*))
-// CHECK-NEXT:   [[RET:%.*]] = bitcast i8* [[RT]] to %struct.type_info*
-// CHECK-NEXT:   ret %struct.type_info* [[RET]]
+// CHECK:   ret %struct.type_info* bitcast (%rtti.TypeDescriptor7* @"??_R0?AUV@@@8" to %struct.type_info*)
+
+const std::type_info *test6_typeid() { return &typeid((V &)v); }
+// CHECK: define dso_local %struct.type_info* @"?test6_typeid@@YAPBUtype_info@@XZ"()
+// CHECK:   ret %struct.type_info* bitcast (%rtti.TypeDescriptor7* @"??_R0?AUV@@@8" to %struct.type_info*)
 
 namespace PR26329 {
 struct Polymorphic {
Index: clang/lib/CodeGen/CGExprCXX.cpp
===
--- clang/lib/CodeGen/CGExprCXX.cpp
+++ clang/lib/CodeGen/CGExprCXX.cpp
@@ -2199,7 +2199,8 @@
   //   polymorphic class type, the result refers to a std::type_inf

[clang] f975ae4 - [CodeGen][typeid] Emit typeinfo directly if type is known at compile-time

2020-09-15 Thread Zequan Wu via cfe-commits

Author: Zequan Wu
Date: 2020-09-15T12:15:47-07:00
New Revision: f975ae4867d1fdfaba11a3ec7e479da8fbfd82d8

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

LOG: [CodeGen][typeid] Emit typeinfo directly if type is known at compile-time

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

Added: 


Modified: 
clang/include/clang/AST/ExprCXX.h
clang/lib/AST/ExprCXX.cpp
clang/lib/CodeGen/CGExprCXX.cpp
clang/test/CodeGenCXX/microsoft-abi-typeid.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 0ba5e417fd58e..9658f37723e18 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -858,6 +858,10 @@ class CXXTypeidExpr : public Expr {
   /// evaluated, per C++11 [expr.typeid]p3.
   bool isPotentiallyEvaluated() const;
 
+  /// Best-effort check if the expression operand refers to a most derived
+  /// object. This is not a strong guarantee.
+  bool isMostDerived(ASTContext &Context) const;
+
   bool isTypeOperand() const { return Operand.is(); }
 
   /// Retrieves the type operand of this typeid() expression after

diff  --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 3f3f2303587dd..1fd2b8e3b4e26 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -146,6 +146,18 @@ bool CXXTypeidExpr::isPotentiallyEvaluated() const {
   return false;
 }
 
+bool CXXTypeidExpr::isMostDerived(ASTContext &Context) const {
+  assert(!isTypeOperand() && "Cannot call isMostDerived for typeid(type)");
+  const Expr *E = getExprOperand()->IgnoreParenNoopCasts(Context);
+  if (const auto *DRE = dyn_cast(E)) {
+QualType Ty = DRE->getDecl()->getType();
+if (!Ty->isPointerType() && !Ty->isReferenceType())
+  return true;
+  }
+
+  return false;
+}
+
 QualType CXXTypeidExpr::getTypeOperand(ASTContext &Context) const {
   assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
   Qualifiers Quals;

diff  --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index 50b6079bd80bf..e33730b9ae901 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -2199,7 +2199,8 @@ llvm::Value *CodeGenFunction::EmitCXXTypeidExpr(const 
CXXTypeidExpr *E) {
   //   polymorphic class type, the result refers to a std::type_info object
   //   representing the type of the most derived object (that is, the dynamic
   //   type) to which the glvalue refers.
-  if (E->isPotentiallyEvaluated())
+  // If the operand is already most derived object, no need to look up vtable.
+  if (E->isPotentiallyEvaluated() && !E->isMostDerived(getContext()))
 return EmitTypeidFromVTable(*this, E->getExprOperand(),
 StdTypeInfoPtrTy);
 

diff  --git a/clang/test/CodeGenCXX/microsoft-abi-typeid.cpp 
b/clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
index f3bd7e6fd6c80..8598396f06441 100644
--- a/clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
+++ b/clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
@@ -46,9 +46,11 @@ const std::type_info* test4_typeid() { return &typeid(b); }
 
 const std::type_info* test5_typeid() { return &typeid(v); }
 // CHECK: define dso_local %struct.type_info* 
@"?test5_typeid@@YAPBUtype_info@@XZ"()
-// CHECK:[[RT:%.*]] = call i8* @__RTtypeid(i8* bitcast (%struct.V* 
@"?v@@3UV@@A" to i8*))
-// CHECK-NEXT:   [[RET:%.*]] = bitcast i8* [[RT]] to %struct.type_info*
-// CHECK-NEXT:   ret %struct.type_info* [[RET]]
+// CHECK:   ret %struct.type_info* bitcast (%rtti.TypeDescriptor7* 
@"??_R0?AUV@@@8" to %struct.type_info*)
+
+const std::type_info *test6_typeid() { return &typeid((V &)v); }
+// CHECK: define dso_local %struct.type_info* 
@"?test6_typeid@@YAPBUtype_info@@XZ"()
+// CHECK:   ret %struct.type_info* bitcast (%rtti.TypeDescriptor7* 
@"??_R0?AUV@@@8" to %struct.type_info*)
 
 namespace PR26329 {
 struct Polymorphic {



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


[PATCH] D87588: [ASTMatchers] extract public matchers from const-analysis into own patch

2020-09-15 Thread Jonas Toth via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG69f98311ca42: [ASTMatchers] extract public matchers from 
const-analysis into own patch (authored by JonasToth).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87588

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -741,6 +741,164 @@
 std::make_unique>("v", 4)));
 }
 
+TEST(ForEachArgumentWithParamType, ReportsNoFalsePositives) {
+  StatementMatcher ArgumentY =
+  declRefExpr(to(varDecl(hasName("y".bind("arg");
+  TypeMatcher IntType = qualType(isInteger()).bind("type");
+  StatementMatcher CallExpr =
+  callExpr(forEachArgumentWithParamType(ArgumentY, IntType));
+
+  // IntParam does not match.
+  EXPECT_TRUE(notMatches("void f(int* i) { int* y; f(y); }", CallExpr));
+  // ArgumentY does not match.
+  EXPECT_TRUE(notMatches("void f(int i) { int x; f(x); }", CallExpr));
+}
+
+TEST(ForEachArgumentWithParamType, MatchesCXXMemberCallExpr) {
+  StatementMatcher ArgumentY =
+  declRefExpr(to(varDecl(hasName("y".bind("arg");
+  TypeMatcher IntType = qualType(isInteger()).bind("type");
+  StatementMatcher CallExpr =
+  callExpr(forEachArgumentWithParamType(ArgumentY, IntType));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "struct S {"
+  "  const S& operator[](int i) { return *this; }"
+  "};"
+  "void f(S S1) {"
+  "  int y = 1;"
+  "  S1[y];"
+  "}",
+  CallExpr, std::make_unique>("type", 1)));
+
+  StatementMatcher CallExpr2 =
+  callExpr(forEachArgumentWithParamType(ArgumentY, IntType));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "struct S {"
+  "  static void g(int i);"
+  "};"
+  "void f() {"
+  "  int y = 1;"
+  "  S::g(y);"
+  "}",
+  CallExpr2, std::make_unique>("type", 1)));
+}
+
+TEST(ForEachArgumentWithParamType, MatchesCallExpr) {
+  StatementMatcher ArgumentY =
+  declRefExpr(to(varDecl(hasName("y".bind("arg");
+  TypeMatcher IntType = qualType(isInteger()).bind("type");
+  StatementMatcher CallExpr =
+  callExpr(forEachArgumentWithParamType(ArgumentY, IntType));
+
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "void f(int i) { int y; f(y); }", CallExpr,
+  std::make_unique>("type")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "void f(int i) { int y; f(y); }", CallExpr,
+  std::make_unique>("arg")));
+
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "void f(int i, int j) { int y; f(y, y); }", CallExpr,
+  std::make_unique>("type", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "void f(int i, int j) { int y; f(y, y); }", CallExpr,
+  std::make_unique>("arg", 2)));
+}
+
+TEST(ForEachArgumentWithParamType, MatchesConstructExpr) {
+  StatementMatcher ArgumentY =
+  declRefExpr(to(varDecl(hasName("y".bind("arg");
+  TypeMatcher IntType = qualType(isInteger()).bind("type");
+  StatementMatcher ConstructExpr =
+  cxxConstructExpr(forEachArgumentWithParamType(ArgumentY, IntType));
+
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "struct C {"
+  "  C(int i) {}"
+  "};"
+  "int y = 0;"
+  "C Obj(y);",
+  ConstructExpr, std::make_unique>("type")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "struct C {"
+  "  C(int i) {}"
+  "};"
+  "int y = 0;"
+  "C Obj(y);",
+  ConstructExpr, std::make_unique>("arg")));
+}
+
+TEST(ForEachArgumentWithParamType, HandlesKandRFunctions) {
+  StatementMatcher ArgumentY =
+  declRefExpr(to(varDecl(hasName("y".bind("arg");
+  TypeMatcher IntType = qualType(isInteger()).bind("type");
+  StatementMatcher CallExpr =
+  callExpr(forEachArgumentWithParamType(ArgumentY, IntType));
+
+  EXPECT_TRUE(matchesC("void f();\n"
+   "void call_it(void) { int x, y; f(x, y); }\n"
+   "void f(a, b) int a, b; {}\n"
+   "void call_it2(void) { int x, y; f(x, y); }",
+   CallExpr));
+}
+
+TEST(ForEachArgumentWithParamType, HandlesBoundNodesForNonMatches) {
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "void g(int i, int j) {"
+  "  int a;"
+  "  int b;"
+  "  int c;"
+  "  g(a, 0);"
+  "  g(a, b);"
+  "  g(0, b);"
+  "}",
+  functionDecl(
+  forEachDescendant(varDecl().bind("v")),
+  forEachDescendant(callExpr(forEachArgumentWithParamType(
+  de

[clang] 69f9831 - [ASTMatchers] extract public matchers from const-analysis into own patch

2020-09-15 Thread Jonas Toth via cfe-commits

Author: Jonas Toth
Date: 2020-09-15T21:07:30+02:00
New Revision: 69f98311ca42127df92527b6fc3be99841a15f12

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

LOG: [ASTMatchers] extract public matchers from const-analysis into own patch

The analysis for const-ness of local variables required a view generally useful
matchers that are extracted into its own patch.

They are decompositionDecl and forEachArgumentWithParamType, that works
for calls through function pointers as well.

This is a reupload of https://reviews.llvm.org/D72505, that already landed,
but had to be reverted due to a GCC crash on powerpc
(https://reviews.llvm.org/rG4c48ea68e491cb42f1b5d43ffba89f6a7f0dadc4)

Because this took a long time to adress, i decided to redo this patch and
have a clean workflow.
I try to coordinate with someone that has a PPC to apply this patch and
test for the crash. If everything is fine, I intend to just commit.
If the crash is still happening, i hope to at least find the cause.

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

Added: 


Modified: 
clang/docs/LibASTMatchersReference.html
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index eb85e420e7e4..c4c6de117c1c 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -649,6 +649,30 @@ Node Matchers
 
 
 
+MatcherDecompositionDecl>decompositionDeclMatcherDecompositionDecl>...
+Matches 
decomposition-declarations.
+
+Examples matches the declaration node with foo and bar, but not
+number.
+(matcher = declStmt(has(decompositionDecl(
+
+  int number = 42;
+  auto [foo, bar] = std::make_pair{42, 42};
+
+
+
+MatcherDecompositionDecl>decompositionDeclMatcherDecompositionDecl>...
+Matches 
decomposition-declarations.
+
+Examples matches the declaration node with foo and bar, but not
+number.
+(matcher = declStmt(has(decompositionDecl(
+
+  int number = 42;
+  auto [foo, bar] = std::make_pair{42, 42};
+
+
+
 MatcherNestedNameSpecifierLoc>nestedNameSpecifierLocMatcherNestedNameSpecifierLoc>...
 Same as 
nestedNameSpecifier but matches NestedNameSpecifierLoc.
 
@@ -5322,6 +5346,60 @@ AST Traversal Matchers
 
 
 
+MatcherCXXConstructExpr>forEachArgumentWithParamTypeMatcherExpr> 
ArgMatcher, MatcherQualType>
 ParamMatcher
+Matches all arguments and their 
respective types for a CallExpr or
+CXXConstructExpr. It is very similar to forEachArgumentWithParam but
+it works on calls through function pointers as well.
+
+The 
diff erence is, that function pointers do not provide access to a
+ParmVarDecl, but only the QualType for each argument.
+
+Given
+  void f(int i);
+  int y;
+  f(y);
+  void (*f_ptr)(int) = f;
+  f_ptr(y);
+callExpr(
+  forEachArgumentWithParamType(
+declRefExpr(to(varDecl(hasName("y",
+qualType(isInteger()).bind("type)
+))
+  matches f(y) and f_ptr(y)
+with declRefExpr(...)
+  matching int y
+and qualType(...)
+  matching int
+
+
+
+MatcherCXXConstructExpr>forEachArgumentWithParamTypeMatcherExpr> 
ArgMatcher, MatcherQualType>
 ParamMatcher
+Matches all arguments and their 
respective types for a CallExpr or
+CXXConstructExpr. It is very similar to forEachArgumentWithParam but
+it works on calls through function pointers as well.
+
+The 
diff erence is, that function pointers do not provide access to a
+ParmVarDecl, but only the QualType for each argument.
+
+Given
+  void f(int i);
+  int y;
+  f(y);
+  void (*f_ptr)(int) = f;
+  f_ptr(y);
+callExpr(
+  forEachArgumentWithParamType(
+declRefExpr(to(varDecl(hasName("y",
+qualType(isInteger()).bind("type)
+))
+  matches f(y) and f_ptr(y)
+with declRefExpr(...)
+  matching int y
+and qualType(...)
+  matching int
+
+
+
 Matcher

[PATCH] D87588: [ASTMatchers] extract public matchers from const-analysis into own patch

2020-09-15 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 291996.
JonasToth added a comment.

- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87588

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -741,6 +741,164 @@
 std::make_unique>("v", 4)));
 }
 
+TEST(ForEachArgumentWithParamType, ReportsNoFalsePositives) {
+  StatementMatcher ArgumentY =
+  declRefExpr(to(varDecl(hasName("y".bind("arg");
+  TypeMatcher IntType = qualType(isInteger()).bind("type");
+  StatementMatcher CallExpr =
+  callExpr(forEachArgumentWithParamType(ArgumentY, IntType));
+
+  // IntParam does not match.
+  EXPECT_TRUE(notMatches("void f(int* i) { int* y; f(y); }", CallExpr));
+  // ArgumentY does not match.
+  EXPECT_TRUE(notMatches("void f(int i) { int x; f(x); }", CallExpr));
+}
+
+TEST(ForEachArgumentWithParamType, MatchesCXXMemberCallExpr) {
+  StatementMatcher ArgumentY =
+  declRefExpr(to(varDecl(hasName("y".bind("arg");
+  TypeMatcher IntType = qualType(isInteger()).bind("type");
+  StatementMatcher CallExpr =
+  callExpr(forEachArgumentWithParamType(ArgumentY, IntType));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "struct S {"
+  "  const S& operator[](int i) { return *this; }"
+  "};"
+  "void f(S S1) {"
+  "  int y = 1;"
+  "  S1[y];"
+  "}",
+  CallExpr, std::make_unique>("type", 1)));
+
+  StatementMatcher CallExpr2 =
+  callExpr(forEachArgumentWithParamType(ArgumentY, IntType));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "struct S {"
+  "  static void g(int i);"
+  "};"
+  "void f() {"
+  "  int y = 1;"
+  "  S::g(y);"
+  "}",
+  CallExpr2, std::make_unique>("type", 1)));
+}
+
+TEST(ForEachArgumentWithParamType, MatchesCallExpr) {
+  StatementMatcher ArgumentY =
+  declRefExpr(to(varDecl(hasName("y".bind("arg");
+  TypeMatcher IntType = qualType(isInteger()).bind("type");
+  StatementMatcher CallExpr =
+  callExpr(forEachArgumentWithParamType(ArgumentY, IntType));
+
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "void f(int i) { int y; f(y); }", CallExpr,
+  std::make_unique>("type")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "void f(int i) { int y; f(y); }", CallExpr,
+  std::make_unique>("arg")));
+
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "void f(int i, int j) { int y; f(y, y); }", CallExpr,
+  std::make_unique>("type", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "void f(int i, int j) { int y; f(y, y); }", CallExpr,
+  std::make_unique>("arg", 2)));
+}
+
+TEST(ForEachArgumentWithParamType, MatchesConstructExpr) {
+  StatementMatcher ArgumentY =
+  declRefExpr(to(varDecl(hasName("y".bind("arg");
+  TypeMatcher IntType = qualType(isInteger()).bind("type");
+  StatementMatcher ConstructExpr =
+  cxxConstructExpr(forEachArgumentWithParamType(ArgumentY, IntType));
+
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "struct C {"
+  "  C(int i) {}"
+  "};"
+  "int y = 0;"
+  "C Obj(y);",
+  ConstructExpr, std::make_unique>("type")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "struct C {"
+  "  C(int i) {}"
+  "};"
+  "int y = 0;"
+  "C Obj(y);",
+  ConstructExpr, std::make_unique>("arg")));
+}
+
+TEST(ForEachArgumentWithParamType, HandlesKandRFunctions) {
+  StatementMatcher ArgumentY =
+  declRefExpr(to(varDecl(hasName("y".bind("arg");
+  TypeMatcher IntType = qualType(isInteger()).bind("type");
+  StatementMatcher CallExpr =
+  callExpr(forEachArgumentWithParamType(ArgumentY, IntType));
+
+  EXPECT_TRUE(matchesC("void f();\n"
+   "void call_it(void) { int x, y; f(x, y); }\n"
+   "void f(a, b) int a, b; {}\n"
+   "void call_it2(void) { int x, y; f(x, y); }",
+   CallExpr));
+}
+
+TEST(ForEachArgumentWithParamType, HandlesBoundNodesForNonMatches) {
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "void g(int i, int j) {"
+  "  int a;"
+  "  int b;"
+  "  int c;"
+  "  g(a, 0);"
+  "  g(a, b);"
+  "  g(0, b);"
+  "}",
+  functionDecl(
+  forEachDescendant(varDecl().bind("v")),
+  forEachDescendant(callExpr(forEachArgumentWithParamType(
+  declRefExpr(to(decl(equalsBoundNode("v", qualType(),
+  std::make_unique>("v", 4)));
+}
+
+TEST(ForEachArgumentWithParamType, MatchesFunctionPtrCalls) {
+  StatementMatcher ArgumentY =
+  declRefExpr(to(varDecl(hasName("y".bind("arg");
+  Ty

[PATCH] D87425: [CodeGen][typeid] Emit typeinfo directly if type is known at compile-time

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

lgtm




Comment at: clang/test/SemaCXX/constant-expression-cxx2a.cpp:312
   // expected-note@+1 {{typeid applied to object 'extern_b2' whose dynamic 
type is not constant}}
-  static_assert(&typeid(extern_b2) == &typeid(B2)); // expected-error 
{{constant expression}}
+  static_assert(&typeid(*&extern_b2) == &typeid(B2)); // expected-error 
{{constant expression}}
 

zequanwu wrote:
> hans wrote:
> > This appears to be changing semantics. It could be that this test is 
> > unnecessary strict (that's my understanding), but usually these checks are 
> > based on examples in the standard, or the current understanding of the 
> > standard. I think it would be best to check with Richard before changing 
> > this.
> > 
> > Actually, I'm surprised this affected since you're only updating CodeGen, 
> > not Sema. Is the static_assert really invoking Codegen?
> This was caused by my previous changes on isPotentiallyEvaluated, which is 
> used by Sema. I reverted this.
Ah, great. That makes more sense :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87425

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


[PATCH] D87607: [clang][aarch64] Support implicit casts between GNU and SVE vectors

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



Comment at: clang/lib/AST/ASTContext.cpp:8522
+  return VT->getElementType().getCanonicalType() ==
+ getBuiltinVectorTypeInfo(BT).ElementType;
   }

c-rhodes wrote:
> efriedma wrote:
> > We allow casting SVE fixed-width vectors only if the element type is 
> > identical, but we allow casting to GNU fixed-width vectors if the vector 
> > width is the same?  That seems sort of loose; could allow weird casts, 
> > particularly when bool vectors are involved.
> > We allow casting SVE fixed-width vectors only if the element type is 
> > identical, but we allow casting to GNU fixed-width vectors if the vector 
> > width is the same? That seems sort of loose; could allow weird casts, 
> > particularly when bool vectors are involved.
> 
> Fixed-length SVE vectors are created with the attribute and the vector width 
> must match `-msve-vector-bits`, which should guarantee consistent vector 
> widths for a given input. This is checking the vector width is the same and 
> the element type matches when casting between GNU and SVE vectors, although 
> since neither of those types are created by the attribute it's necessary to 
> check the vector width to validate `__ARM_FEATURE_SVE_BITS==N`.
> 
> Predicates are treated differently in the ACLE and it doesn't mention 
> supporting casts between GNU bool vectors and SVE VLS/VLA predicates. I'm 
> also not sure the GNU vector_size extension is defined for bool elements yet, 
> but I did notice Simon Moll is working on this (D81083).
I think you need to check both the size and the element type here?



Comment at: clang/test/Sema/attr-arm-sve-vector-bits.c:237
+// Test implicit conversion between SVE and GNU vector is invalid when
+// __ARM_FEATURE_SVE_BITS != N
+#if defined(__ARM_FEATURE_SVE_BITS) && __ARM_FEATURE_SVE_BITS == 512

This test isn't checking what it says it is; int4 and svint64_t have different 
element types.


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

https://reviews.llvm.org/D87607

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


[PATCH] D87627: [clang-tidy] Fix crash in modernize-use-noexcept on uninstantiated throw class

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

LGTM!


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

https://reviews.llvm.org/D87627

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


[PATCH] D87532: Sema: add support for `__attribute__((__swift_bridge__))`

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



Comment at: clang/include/clang/Basic/Attr.td:2134
+def SwiftBridge : Attr {
+  let Spellings = [GNU<"swift_bridge">];
+  let Args = [StringArgument<"SwiftType">];

Is it intentional that this is `swift_bridge` but we just added 
`swift_bridged_typedef` (bridge vs bridged)? That seems like a bit of a 
spelling gotcha, if it can be corrected.



Comment at: clang/include/clang/Basic/Attr.td:2133
 
+def SwiftBridge : Attr {
+  let Spellings = [GNU<"swift_bridge">];

compnerd wrote:
> aaron.ballman wrote:
> > Is this a type or a declaration attribute? It looks like a declaration 
> > attribute based on the declaration and the list of subjects, but it looks 
> > like a type based on the `ExpectedType` diagnostic and the documentation. 
> > Or is this one of those unholy GNU attributes that's confused about what it 
> > appertains to?
> > 
> > Should this be inherited by redeclarations? Might be worth adding a test:
> > ```
> > struct __attribute__((swift_bridge)) S;
> > 
> > struct S { // Should still have the attribute
> >   int i;
> > };
> > ```
> It is a declaration attribute, and yes, it should be inheritable.
Okay, you should mark the attribute as an `InheritableAttr` above and a test.



Comment at: clang/include/clang/Basic/AttrDocs.td:3483
+  let Content = [{
+The ``swift_bridged`` attribute indicates that the type to which the attribute
+appertains is bridged to the named Swift type.

aaron.ballman wrote:
> If this is a type attribute, should it be listed as a `TypeAttr` above?
The documentation should probably also say that it is bridging the declarations 
rather than the types, just to be clear. Maybe something like: The 
`swift_bridge` attribute indicates that the declaration to which the attribute 
is applied is bridged to the named Swift type. ?

If not that formulation, you should at least change `swift_bridged` to be 
`swift_bridge`.

Adding a code example of how to use this properly would also be appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87532

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


[PATCH] D87561: [Sema] List conversion validate character array

2020-09-15 Thread Mark de Wever via Phabricator via cfe-commits
Mordante marked 2 inline comments as done.
Mordante added inline comments.



Comment at: clang/lib/Sema/SemaOverload.cpp:4989
+if (ToType->isArrayType() && ToType->isCharType() &&
+isa(From->getInit(0))) {
   InitializedEntity Entity =

rsmith wrote:
> This is too narrow a check in two ways: we should allow parenthesized string 
> literals here, and we should allow `ObjCEncodeExpr`.
Actually it seems the code isn't behaving properly at all. It seems the 
conversion is done by
https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaOverload.cpp#L5174
resulting in an array-to-pointer conversion instead of an identity conversion.

It can solve it by manually removing the decay like:
```
if (const auto *DT = dyn_cast(ToType))
  if (const auto *AT = S.Context.getAsArrayType(DT->getOriginalType()))
if (S.IsStringInit(From->getInit(0), AT) {
   ...
```
This code works and results in an identity conversion. But it feels a bit odd 
to manually peel away the array-to-pointer decay. Is this the best solution or 
do you have a better suggestions?
  



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87561

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


[PATCH] D83154: clang: Add -fcoverage-prefix-map

2020-09-15 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:1334
+  llvm::SmallString<256> Path(Filename);
+  llvm::sys::fs::make_absolute(Path);
+  llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);

andrewjcg wrote:
> keith wrote:
> > rnk wrote:
> > > keith wrote:
> > > > rnk wrote:
> > > > > Please only make the path absolute if nothing in the prefix map 
> > > > > matches. Otherwise, the user must embed the CWD into the prefix map, 
> > > > > which is needlessly difficult for the build system. I believe it is 
> > > > > also consistent with the way that the debug info prefix map works. It 
> > > > > appears to operate on the possibly relative source paths received on 
> > > > > the command line (-I...).
> > > > Are you suggesting that I try to remap them relatively, and if that 
> > > > fails, absolutize it and attempt the remapping again? Or don't 
> > > > absolutize them at all anymore?
> > > I'd prefer to do the remapping once without any absolutization, and if 
> > > that fails, preserve the behavior of absolutizing.
> > > 
> > > It would be my preference to not absolutize paths at all, since that is 
> > > what is done for debug info. However, @vsk implemented things this way, 
> > > and I do understand that this is convenient default behavior for most 
> > > users: the paths in the coverage are valid anywhere on their system. So, 
> > > changing this behavior is out of scope for this patch.
> > I'm not sure how this changed would work for our use case. With bazel the 
> > usage of this works something like:
> > 
> > 1. Relative paths are passed to the compiler `clang ... foo.c`
> > 2. We would normally do `-fprofile-prefix-map=$PWD=.` to remap them
> > 
> > I think if we made this change, we would either have to:
> > 
> > 1. Make the paths we pass absolute, which we couldn't do for reproducibility
> > 2. Add some known prefix to the paths, like `.`, so we could 
> > `-fprofile-prefix-map=.=.` just to avoid this absolutizing codepath
> > 
> > So I think without actually removing the absolutizing behavior at the same 
> > time, this wouldn't work as we'd hope.
> > 
> > Let me know if I'm mis-understanding your suggestion!
> > 
> > If we did what I said above, I think it would work since relative path 
> > remapping would fail, but then prefix mapping the absolute path would work.
> FWIW, there's a similar issue with doing the absolutizing for the Buck build 
> tool, which by default sets `-fdebug-compilation-dir=.` for all compilations, 
> then expects to use `-fdebug-prefix-map` (or `-ffile-prefix-map`) to fixup 
> relative paths of sandboxed header symlink trees to point to their *real* 
> paths (e.g. something like `clang -c -fdebug-compilation-dir=. 
> -Iheader-tree-sandbox -ffile-prefix-map=header-tree-sandbox=original_dir`) 
> (e.g. 
> https://github.com/facebook/buck/blob/master/src/com/facebook/buck/cxx/toolchain/PrefixMapDebugPathSanitizer.java#L134).
> 
> So, in this case, *not* absolutizing would help here, but it kind of feels 
> that the real issue is that there's not an equivalent 
> `-fprofile-compilation-dir` to opt-out of the absolutizing of profile paths 
> (which is orthogonal to this change)...
FWIW this is something we've already discussed on the list and I started 
prototyping that feature, I'm hoping to upload the change for review in the 
next few days.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83154

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


[PATCH] D87321: Fix -gz=zlib options for linker

2020-09-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D87321#2274731 , @nemanjai wrote:

> This broke the PPC LLD bot and the failure has been ignored for 4 days. I 
> believe it should be fixed with 3bc3983f229 
> .

Sorry I thought I have fixed that but forgot to check. Not sure if this will 
cause regression on cygwin or msvc. If so pls let me know. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87321

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


[PATCH] D87683: [clang-tidy] Crash fix for bugprone-misplaced-pointer-arithmetic-in-alloc

2020-09-15 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

In D87683#2274883 , @martong wrote:

> In D87683#2274663 , 
> @baloghadamsoftware wrote:
>
>> In D87683#2274569 , @njames93 wrote:
>>
>>> Please fix the test case first, can't call `operator new(unsigned long, 
>>> void*)` with an argument of type `void*`
>>> The other failures the pre merge bot detected can safely be disregarded
>>
>> Placement new is defined per standard:
>>
>>   void* operator new  ( std::size_t count, void* ptr );
>>
>> Here, the problem is that `size_t` is `unsigned long` on //Linux// and it 
>> seems that it is `unsigned long long` on //Windows//. How should I overcome 
>> this?
>
> In CSA, to overcome the platform problem, it is common to add a target triple 
> for the RUN line:
> https://github.com/llvm/llvm-project/blob/master/clang/test/Analysis/std-c-library-functions.c#L14

Please make the tests generic if possible:

  typedef decltype(sizeof(void*)) size_t;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87683

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


[PATCH] D84362: [NFC] Add missing functions to PartialDiagnostic

2020-09-15 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D84362#2274790 , @yaxunl wrote:

> There are use patterns expecting `PartialDiagnosticInst << X << Y` to 
> continue to be a `PartialDiagnostic&`, e.g.
>
>   PartialDiagnosticAt PDAt(SourceLoc, PartialDiagnosticInst << X << Y);
>
> However if we derive PartialDiagnostic and DiagnosticBuilder from a base 
> class DiagnosticBuilderBase which implements the `<<` operators, 
> `PartialDiagnosticInst << X << Y` will become a `DiagnosticBuilderBase&`, 
> then we can no longer write the above code.
>
> That's one reason I use templates to implement `<<` operators.
>
> Do we want to sacrifice this convenience?

I don't think we have to. 
AFAICT, virtually all such patterns (and there are only 20-ish of them in 
total) are used with `EmitFormatDiagnostic(S.PDiag())` which could be adapted 
to accept `DiagnosticBuilderBase` and `Sema::PDiag()` changed to return 
`PartialDiagnosticBuilder` with no loss of convenience.


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

https://reviews.llvm.org/D84362

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


[PATCH] D87683: [clang-tidy] Crash fix for bugprone-misplaced-pointer-arithmetic-in-alloc

2020-09-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D87683#2274663 , 
@baloghadamsoftware wrote:

> In D87683#2274569 , @njames93 wrote:
>
>> Please fix the test case first, can't call `operator new(unsigned long, 
>> void*)` with an argument of type `void*`
>> The other failures the pre merge bot detected can safely be disregarded
>
> Placement new is defined per standard:
>
>   void* operator new  ( std::size_t count, void* ptr );
>
> Here, the problem is that `size_t` is `unsigned long` on //Linux// and it 
> seems that it is `unsigned long long` on //Windows//. How should I overcome 
> this?

In CSA, to overcome the platform problem, it is common to add a target triple 
for the RUN line:
https://github.com/llvm/llvm-project/blob/master/clang/test/Analysis/std-c-library-functions.c#L14


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87683

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


[PATCH] D87425: [CodeGen][typeid] Emit typeinfo directly if type is known at compile-time

2020-09-15 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu marked 4 inline comments as done.
zequanwu added inline comments.



Comment at: clang/test/SemaCXX/constant-expression-cxx2a.cpp:312
   // expected-note@+1 {{typeid applied to object 'extern_b2' whose dynamic 
type is not constant}}
-  static_assert(&typeid(extern_b2) == &typeid(B2)); // expected-error 
{{constant expression}}
+  static_assert(&typeid(*&extern_b2) == &typeid(B2)); // expected-error 
{{constant expression}}
 

hans wrote:
> This appears to be changing semantics. It could be that this test is 
> unnecessary strict (that's my understanding), but usually these checks are 
> based on examples in the standard, or the current understanding of the 
> standard. I think it would be best to check with Richard before changing this.
> 
> Actually, I'm surprised this affected since you're only updating CodeGen, not 
> Sema. Is the static_assert really invoking Codegen?
This was caused by my previous changes on isPotentiallyEvaluated, which is used 
by Sema. I reverted this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87425

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


[PATCH] D87425: [CodeGen][typeid] Emit typeinfo directly if type is known at compile-time

2020-09-15 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 291988.
zequanwu added a comment.

Address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87425

Files:
  clang/include/clang/AST/ExprCXX.h
  clang/lib/AST/ExprCXX.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/test/CodeGenCXX/microsoft-abi-typeid.cpp


Index: clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
@@ -46,9 +46,11 @@
 
 const std::type_info* test5_typeid() { return &typeid(v); }
 // CHECK: define dso_local %struct.type_info* 
@"?test5_typeid@@YAPBUtype_info@@XZ"()
-// CHECK:[[RT:%.*]] = call i8* @__RTtypeid(i8* bitcast (%struct.V* 
@"?v@@3UV@@A" to i8*))
-// CHECK-NEXT:   [[RET:%.*]] = bitcast i8* [[RT]] to %struct.type_info*
-// CHECK-NEXT:   ret %struct.type_info* [[RET]]
+// CHECK:   ret %struct.type_info* bitcast (%rtti.TypeDescriptor7* 
@"??_R0?AUV@@@8" to %struct.type_info*)
+
+const std::type_info *test6_typeid() { return &typeid((V &)v); }
+// CHECK: define dso_local %struct.type_info* 
@"?test6_typeid@@YAPBUtype_info@@XZ"()
+// CHECK:   ret %struct.type_info* bitcast (%rtti.TypeDescriptor7* 
@"??_R0?AUV@@@8" to %struct.type_info*)
 
 namespace PR26329 {
 struct Polymorphic {
Index: clang/lib/CodeGen/CGExprCXX.cpp
===
--- clang/lib/CodeGen/CGExprCXX.cpp
+++ clang/lib/CodeGen/CGExprCXX.cpp
@@ -2199,7 +2199,8 @@
   //   polymorphic class type, the result refers to a std::type_info object
   //   representing the type of the most derived object (that is, the dynamic
   //   type) to which the glvalue refers.
-  if (E->isPotentiallyEvaluated())
+  // If the operand is already most derived object, no need to look up vtable.
+  if (E->isPotentiallyEvaluated() && !E->isMostDerived(getContext()))
 return EmitTypeidFromVTable(*this, E->getExprOperand(),
 StdTypeInfoPtrTy);
 
Index: clang/lib/AST/ExprCXX.cpp
===
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -146,6 +146,18 @@
   return false;
 }
 
+bool CXXTypeidExpr::isMostDerived(ASTContext &Context) const {
+  assert(!isTypeOperand() && "Cannot call isMostDerived for typeid(type)");
+  const Expr *E = getExprOperand()->IgnoreParenNoopCasts(Context);
+  if (const auto *DRE = dyn_cast(E)) {
+QualType Ty = DRE->getDecl()->getType();
+if (!Ty->isPointerType() && !Ty->isReferenceType())
+  return true;
+  }
+
+  return false;
+}
+
 QualType CXXTypeidExpr::getTypeOperand(ASTContext &Context) const {
   assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
   Qualifiers Quals;
Index: clang/include/clang/AST/ExprCXX.h
===
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -840,6 +840,10 @@
   /// evaluated, per C++11 [expr.typeid]p3.
   bool isPotentiallyEvaluated() const;
 
+  /// Best-effort check if the expression operand refers to a most derived
+  /// object. This is not a strong guarantee.
+  bool isMostDerived(ASTContext &Context) const;
+
   bool isTypeOperand() const { return Operand.is(); }
 
   /// Retrieves the type operand of this typeid() expression after


Index: clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
@@ -46,9 +46,11 @@
 
 const std::type_info* test5_typeid() { return &typeid(v); }
 // CHECK: define dso_local %struct.type_info* @"?test5_typeid@@YAPBUtype_info@@XZ"()
-// CHECK:[[RT:%.*]] = call i8* @__RTtypeid(i8* bitcast (%struct.V* @"?v@@3UV@@A" to i8*))
-// CHECK-NEXT:   [[RET:%.*]] = bitcast i8* [[RT]] to %struct.type_info*
-// CHECK-NEXT:   ret %struct.type_info* [[RET]]
+// CHECK:   ret %struct.type_info* bitcast (%rtti.TypeDescriptor7* @"??_R0?AUV@@@8" to %struct.type_info*)
+
+const std::type_info *test6_typeid() { return &typeid((V &)v); }
+// CHECK: define dso_local %struct.type_info* @"?test6_typeid@@YAPBUtype_info@@XZ"()
+// CHECK:   ret %struct.type_info* bitcast (%rtti.TypeDescriptor7* @"??_R0?AUV@@@8" to %struct.type_info*)
 
 namespace PR26329 {
 struct Polymorphic {
Index: clang/lib/CodeGen/CGExprCXX.cpp
===
--- clang/lib/CodeGen/CGExprCXX.cpp
+++ clang/lib/CodeGen/CGExprCXX.cpp
@@ -2199,7 +2199,8 @@
   //   polymorphic class type, the result refers to a std::type_info object
   //   representing the type of the most derived object (that is, the dynamic
   //   type) to which the glvalue refers.
-  if (E->isPotentiallyEvaluated())
+  // If the operand is already most derived o

[PATCH] D83154: clang: Add -fcoverage-prefix-map

2020-09-15 Thread Andrew Gallagher via Phabricator via cfe-commits
andrewjcg added inline comments.



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:1334
+  llvm::SmallString<256> Path(Filename);
+  llvm::sys::fs::make_absolute(Path);
+  llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);

keith wrote:
> rnk wrote:
> > keith wrote:
> > > rnk wrote:
> > > > Please only make the path absolute if nothing in the prefix map 
> > > > matches. Otherwise, the user must embed the CWD into the prefix map, 
> > > > which is needlessly difficult for the build system. I believe it is 
> > > > also consistent with the way that the debug info prefix map works. It 
> > > > appears to operate on the possibly relative source paths received on 
> > > > the command line (-I...).
> > > Are you suggesting that I try to remap them relatively, and if that 
> > > fails, absolutize it and attempt the remapping again? Or don't absolutize 
> > > them at all anymore?
> > I'd prefer to do the remapping once without any absolutization, and if that 
> > fails, preserve the behavior of absolutizing.
> > 
> > It would be my preference to not absolutize paths at all, since that is 
> > what is done for debug info. However, @vsk implemented things this way, and 
> > I do understand that this is convenient default behavior for most users: 
> > the paths in the coverage are valid anywhere on their system. So, changing 
> > this behavior is out of scope for this patch.
> I'm not sure how this changed would work for our use case. With bazel the 
> usage of this works something like:
> 
> 1. Relative paths are passed to the compiler `clang ... foo.c`
> 2. We would normally do `-fprofile-prefix-map=$PWD=.` to remap them
> 
> I think if we made this change, we would either have to:
> 
> 1. Make the paths we pass absolute, which we couldn't do for reproducibility
> 2. Add some known prefix to the paths, like `.`, so we could 
> `-fprofile-prefix-map=.=.` just to avoid this absolutizing codepath
> 
> So I think without actually removing the absolutizing behavior at the same 
> time, this wouldn't work as we'd hope.
> 
> Let me know if I'm mis-understanding your suggestion!
> 
> If we did what I said above, I think it would work since relative path 
> remapping would fail, but then prefix mapping the absolute path would work.
FWIW, there's a similar issue with doing the absolutizing for the Buck build 
tool, which by default sets `-fdebug-compilation-dir=.` for all compilations, 
then expects to use `-fdebug-prefix-map` (or `-ffile-prefix-map`) to fixup 
relative paths of sandboxed header symlink trees to point to their *real* paths 
(e.g. something like `clang -c -fdebug-compilation-dir=. -Iheader-tree-sandbox 
-ffile-prefix-map=header-tree-sandbox=original_dir`) (e.g. 
https://github.com/facebook/buck/blob/master/src/com/facebook/buck/cxx/toolchain/PrefixMapDebugPathSanitizer.java#L134).

So, in this case, *not* absolutizing would help here, but it kind of feels that 
the real issue is that there's not an equivalent `-fprofile-compilation-dir` to 
opt-out of the absolutizing of profile paths (which is orthogonal to this 
change)...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83154

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


[PATCH] D87047: [clang] Add command line options for the Machine Function Splitter.

2020-09-15 Thread Snehasish Kumar via Phabricator via cfe-commits
snehasish added a comment.

Thanks for the review.




Comment at: clang/include/clang/Driver/Options.td:2000
+defm split_machine_functions: OptInFFlag<"split-machine-functions",
+  "Enable", "Disable", " late function splitting using profile information 
(x86-elf only)">;
+

MaskRay wrote:
> MaskRay wrote:
> > If this can be adapted to other targets, there is no need to specifically 
> > mention x86-elf only ("x86 ELF")
> So I take quickly a look at rG94faadaca4e1704f674d2e9d4a1d25643b9ca52c. There 
> is nothing ELF specific, right? At least I don't expect AArch64 ELF to fail. 
> If you do think this merits a "ELF only" comment, adding it seems feasible.
The machine function splitter uses the basic block sections feature. This has 
not been tested on AArch64, there is some target specific code in the CFI 
handling as well idiosyncrasies of each target which need to be worked out. I'm 
going to leave this as it is since the checks included in this patch enforce 
x86 & ELF. This is on our longer term roadmap and we will revisit this in the 
future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87047

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


[PATCH] D87047: [clang] Add command line options for the Machine Function Splitter.

2020-09-15 Thread Snehasish Kumar via Phabricator via cfe-commits
snehasish updated this revision to Diff 291986.
snehasish marked 2 inline comments as done.
snehasish added a comment.

Update the test.

- Added "warning: " prefix to be checked.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87047

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fsplit-machine-functions.c


Index: clang/test/Driver/fsplit-machine-functions.c
===
--- /dev/null
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -0,0 +1,9 @@
+// RUN: %clang -### -target x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
+// RUN: %clang -### -target x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck 
-check-prefix=CHECK-NOOPT %s
+// RUN: %clang -### -target x86_64 -fsplit-machine-functions %s 2>&1 | 
FileCheck -check-prefix=CHECK-WARN %s
+// RUN: not %clang -c -target arm-unknown-linux -fsplit-machine-functions %s 
2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
+
+// CHECK-OPT:   "-fsplit-machine-functions"
+// CHECK-NOOPT-NOT: "-fsplit-machine-functions"
+// CHECK-WARN:  warning: argument '-fsplit-machine-functions' requires 
profile-guided optimization information
+// CHECK-TRIPLE:error: unsupported option '-fsplit-machine-functions' for 
target
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -998,6 +998,8 @@
   Opts.UniqueInternalLinkageNames =
   Args.hasArg(OPT_funique_internal_linkage_names);
 
+  Opts.SplitMachineFunctions = Args.hasArg(OPT_fsplit_machine_functions);
+
   Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
 
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4911,6 +4911,26 @@
options::OPT_fno_unique_basic_block_section_names, false))
 CmdArgs.push_back("-funique-basic-block-section-names");
 
+  if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
+   options::OPT_fno_split_machine_functions)) {
+// This codegen pass is only available on x86-elf targets.
+if (Triple.isX86() && Triple.isOSBinFormatELF()) {
+  if (A->getOption().matches(options::OPT_fsplit_machine_functions)) {
+// If the flag is enabled but no profile information is available then
+// emit a warning.
+if (getLastProfileUseArg(Args) || getLastProfileSampleUseArg(Args)) {
+  A->render(Args, CmdArgs);
+} else {
+  D.Diag(diag::warn_drv_diagnostics_hotness_requires_pgo)
+  << A->getAsString(Args);
+}
+  }
+} else {
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;
+}
+  }
+
   Args.AddLastArg(CmdArgs, options::OPT_finstrument_functions,
   options::OPT_finstrument_functions_after_inlining,
   options::OPT_finstrument_function_entry_bare);
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -514,6 +514,7 @@
   Options.BBSectionsFuncListBuf = std::move(*MBOrErr);
   }
 
+  Options.EnableMachineFunctionSplitter = CodeGenOpts.SplitMachineFunctions;
   Options.FunctionSections = CodeGenOpts.FunctionSections;
   Options.DataSections = CodeGenOpts.DataSections;
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1996,6 +1996,9 @@
 defm unique_section_names : OptOutFFlag<"unique-section-names",
   "", "Don't use unique names for text and data sections">;
 
+defm split_machine_functions: OptInFFlag<"split-machine-functions",
+  "Enable", "Disable", " late function splitting using profile information 
(x86 ELF)">;
+
 defm strict_return : OptOutFFlag<"strict-return", "",
   "Don't treat control flow paths that fall off the end of a non-void function 
as unreachable">;
 
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -162,6 +162,7

[PATCH] D87701: Do not apply calling conventions to MSVC entry points

2020-09-15 Thread Reid "Away June-Sep" Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm, thanks.


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

https://reviews.llvm.org/D87701

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


[PATCH] D86048: [AST][RecoveryExpr] Popagate the error-bit from a VarDecl's initializer to DeclRefExpr.

2020-09-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D86048#2270400 , @rsmith wrote:

> In D86048#2254607 , @sammccall wrote:
>
>> The crux is we're forcing `decltype(N)` to be a (unique) dependent type, 
>> which feels wrong.
>> [...]
>> There are three behaviors:
>>
>> - standard up to C++14: traversing the expr looking for a template param to 
>> be lexically included (this is my reading of the standard)
>
> FWIW, "involves a template parameter" is exactly the same phrasing that 
> [temp.over.link] uses to refer to instantiation-dependence; that's why Clang 
> uses instantiation-dependence in this case at the moment.
>
>> - what clang actually does: check instantiation dependence, which I think 
>> pulls in too many cases
>> - standard after http://wg21.link/cwg2064: check type dependence
>>
>> I think it's probably OK to adopt the C++17 behavior for all versions (if 
>> I'm right that the current behavior is a bug).
>> @rsmith It's your DR, what do you think :-)
>
> Let's try it and see what happens. I think this will reveal a collection of 
> cases where we don't properly handle 
> instantiation-dependent-but-not-type-dependent constructs (such as, if I 
> remember correctly, the types of non-type template parameters), but we should 
> be fixing those bugs anyway :)

https://reviews.llvm.org/D87349 is an attempt.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86048

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


[PATCH] D87710: [clangd] Actually parse Index section of the YAML file.

2020-09-15 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
adamcz added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous.
Herald added a project: clang.
adamcz requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

This fixes a bug in dbf486c0de92c76df77c1a1f815cf16533ecbb3a 
, which
introduced the Index section of the config, but did not register the
parse method, so it didn't work in a YAML file (but did in a test).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87710

Files:
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp


Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -47,16 +47,21 @@
   Add: |
 b
 az
+---
+Index:
+  Background: Skip
   )yaml";
   auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
-  ASSERT_EQ(Results.size(), 2u);
-  EXPECT_FALSE(Results.front().If.HasUnrecognizedCondition);
-  EXPECT_THAT(Results.front().If.PathMatch, ElementsAre(Val("abc")));
-  EXPECT_THAT(Results.front().CompileFlags.Add,
-  ElementsAre(Val("foo"), Val("bar")));
+  ASSERT_EQ(Results.size(), 3u);
+  EXPECT_FALSE(Results[0].If.HasUnrecognizedCondition);
+  EXPECT_THAT(Results[0].If.PathMatch, ElementsAre(Val("abc")));
+  EXPECT_THAT(Results[0].CompileFlags.Add, ElementsAre(Val("foo"), 
Val("bar")));
+
+  EXPECT_THAT(Results[1].CompileFlags.Add, ElementsAre(Val("b\naz\n")));
 
-  EXPECT_THAT(Results.back().CompileFlags.Add, ElementsAre(Val("b\naz\n")));
+  ASSERT_TRUE(Results[2].Index.Background);
+  EXPECT_EQ("Skip", *Results[2].Index.Background.getValue());
 }
 
 TEST(ParseYAML, Locations) {
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -38,6 +38,7 @@
 DictParser Dict("Config", this);
 Dict.handle("If", [&](Node &N) { parse(F.If, N); });
 Dict.handle("CompileFlags", [&](Node &N) { parse(F.CompileFlags, N); });
+Dict.handle("Index", [&](Node &N) { parse(F.Index, N); });
 Dict.parse(N);
 return !(N.failed() || HadError);
   }


Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -47,16 +47,21 @@
   Add: |
 b
 az
+---
+Index:
+  Background: Skip
   )yaml";
   auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
-  ASSERT_EQ(Results.size(), 2u);
-  EXPECT_FALSE(Results.front().If.HasUnrecognizedCondition);
-  EXPECT_THAT(Results.front().If.PathMatch, ElementsAre(Val("abc")));
-  EXPECT_THAT(Results.front().CompileFlags.Add,
-  ElementsAre(Val("foo"), Val("bar")));
+  ASSERT_EQ(Results.size(), 3u);
+  EXPECT_FALSE(Results[0].If.HasUnrecognizedCondition);
+  EXPECT_THAT(Results[0].If.PathMatch, ElementsAre(Val("abc")));
+  EXPECT_THAT(Results[0].CompileFlags.Add, ElementsAre(Val("foo"), Val("bar")));
+
+  EXPECT_THAT(Results[1].CompileFlags.Add, ElementsAre(Val("b\naz\n")));
 
-  EXPECT_THAT(Results.back().CompileFlags.Add, ElementsAre(Val("b\naz\n")));
+  ASSERT_TRUE(Results[2].Index.Background);
+  EXPECT_EQ("Skip", *Results[2].Index.Background.getValue());
 }
 
 TEST(ParseYAML, Locations) {
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -38,6 +38,7 @@
 DictParser Dict("Config", this);
 Dict.handle("If", [&](Node &N) { parse(F.If, N); });
 Dict.handle("CompileFlags", [&](Node &N) { parse(F.CompileFlags, N); });
+Dict.handle("Index", [&](Node &N) { parse(F.Index, N); });
 Dict.parse(N);
 return !(N.failed() || HadError);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87470: [Coroutine][Sema] Tighten the lifetime of symmetric transfer returned handle

2020-09-15 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D87470#2273310 , @junparser wrote:

> @lxfind , could you backport this to branch 11?

I am actually seeing some problems with this change. Still investigating.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87470

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


[PATCH] D84362: [NFC] Add missing functions to PartialDiagnostic

2020-09-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D84362#2274315 , @aaron.ballman 
wrote:

> In D84362#2271585 , @tra wrote:
>
>> So, the idea here is to do some sort of duck-typing and allow DiagBuilder to 
>> work with both `DiagnosticBuilder` and `PartialDiagnostic`.
>>
>> What bothers me is that unlike `Diagnostic` `PartialDiagnostic` seems to be 
>> commingling functionality of the builder with that of the diagnostic itself. 
>> I'm not sure if that's by design or just happened to be that way.
>>
>> I think a better approach would be to refactor `PartialDiagnostic` and 
>> separate the builder functionality. That should make it possible to create a 
>> common diagnostic builder base class with Partial/Full diagnostic deriving 
>> their own builder, if needed.
>>
>> That said, I'm not that familiar with the diags. Perhaps  @rtrieu 
>> @aaron.ballman would have better ideas.
>
> I'm similarly a bit uncomfortable with adding the SFINAE magic to make this 
> work instead of making a base class that will work for either kind of 
> diagnostic builder. I'm adding @rsmith to see if he has opinions as well.

There are use patterns expecting `PartialDiagnosticInst << X << Y` to continue 
to be a `PartialDiagnostic&`, e.g.

  PartialDiagnosticAt PDAt(SourceLoc, PartialDiagnosticInst << X << Y);

However if we derive PartialDiagnostic and DiagnosticBuilder from a base class 
DiagnosticBuilderBase which implements the `<<` operators, 
`PartialDiagnosticInst << X << Y` will become a `DiagnosticBuilderBase&`, then 
we can no longer write the above code.

That's one reason I use templates to implement `<<` operators.

Do we want to sacrifice this convenience?


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

https://reviews.llvm.org/D84362

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


[PATCH] D86558: [OPENMP]Add support for allocate vars in untied tasks.

2020-09-15 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG738bab743b5c: [OPENMP]Add support for allocate vars in 
untied tasks. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86558

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/allocate_codegen.cpp
  clang/test/OpenMP/for_lastprivate_codegen.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen_UDR.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_private_codegen.cpp
  clang/test/OpenMP/task_codegen.cpp

Index: clang/test/OpenMP/task_codegen.cpp
===
--- clang/test/OpenMP/task_codegen.cpp
+++ clang/test/OpenMP/task_codegen.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix UNTIEDRT
-// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ -emit-llvm %s -o - -DUNTIEDRT | FileCheck %s --check-prefix CHECK --check-prefix UNTIEDRT
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s -DUNTIEDRT
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix UNTIEDRT
 //
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
@@ -14,6 +14,19 @@
 #ifndef HEADER
 #define HEADER
 
+enum omp_allocator_handle_t {
+  omp_null_allocator = 0,
+  omp_default_mem_alloc = 1,
+  omp_large_cap_mem_alloc = 2,
+  omp_const_mem_alloc = 3,
+  omp_high_bw_mem_alloc = 4,
+  omp_low_lat_mem_alloc = 5,
+  omp_cgroup_mem_alloc = 6,
+  omp_pteam_mem_alloc = 7,
+  omp_thread_mem_alloc = 8,
+  KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
+};
+
 // CHECK-DAG: [[IDENT_T:%.+]] = type { i32, i32, i32, i32, i8* }
 // CHECK-DAG: [[STRUCT_SHAREDS:%.+]] = type { i8*, [2 x [[STRUCT_S:%.+]]]* }
 // CHECK-DAG: [[STRUCT_SHAREDS1:%.+]] = type { [2 x [[STRUCT_S:%.+]]]* }
@@ -258,21 +271,26 @@
 a = 4;
 c = 5;
   }
-// CHECK: [[ORIG_TASK_PTR:%.+]] = call i8* @__kmpc_omp_task_alloc([[IDENT_T]]* @{{.+}}, i32 {{%.*}}, i32 0, i64 48, i64 1, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T]]{{.*}}*)* [[TASK_ENTRY6:@.+]] to i32 (i32, i8*)*))
+// CHECK: [[ORIG_TASK_PTR:%.+]] = call i8* @__kmpc_omp_task_alloc([[IDENT_T]]* @{{.+}}, i32 {{%.*}}, i32 0, i64 256, i64 1, i32 (i32, i8*)* bitcast (i32 (i32, [[KMP_TASK_T]]{{.*}}*)* [[TASK_ENTRY6:@.+]] to i32 (i32, i8*)*))
 // CHECK: call i32 @__kmpc_omp_task([[IDENT_T]]* @{{.+}}, i32 {{%.*}}, i8* [[ORIG_TASK_PTR]])
-#pragma omp task untied
+#pragma omp task untied firstprivate(c) allocate(omp_pteam_mem_alloc:c)
   {
-S s1;
+S s1, s2;
+#ifdef UNTIEDRT
+#pragma omp allocate(s2) allocator(omp_pteam_mem_alloc)
+#endif
+s2.a = 0;
 #pragma omp task
-a = 4;
+a = c = 4;
 #pragma omp taskyield
 s1 = S();
+s2.a = 10;
 #pragma omp taskwait
   }
   return a;
 }
 // CHECK: define internal i32 [[TASK_ENTRY1]](i32 %0, [[KMP_TASK_T]]{{.*}}* noalias %1)
-// CHECK: store i32 15, i32* [[A_PTR:@.+]]
+// CHECK: store i32 15, i32* [[A_PTR:@.+]],
 // CHECK: [[A_VAL:%.+]] = load i32, i32* [[A_PTR]]
 // CHECK: [[A_VAL_I8:%.+]] = trunc i32 [[A_VAL]] to i8
 // CHECK: store i8 [[A_VAL_I8]], i8* %{{.+}}
@@ -294,10 +312,13 @@
 // CHECK: define internal i32
 // CHECK: store i32 4, i32* [[A_PTR]]
 
-// CHECK: define internal i32 [[TASK_ENTRY6]](i32 %0, [[KMP_TASK_T]]{{.*}}* noalias %1)
+// CHECK: define internal i32 [[TASK_ENTRY6]](i32 %0, [[KMP_TASK_T]]{{.*}}* noalias %{{.+}})
 // UNTIEDRT: [[S1_ADDR_PTR:%.+]] = alloca %struct.S*,
-// UNTIEDRT: call void (i8*, ...) %{{.+}}(i8* %{{.+}}, %struct.S** [[S1_ADDR_PTR]])
-// UNTIEDRT: [[S1_ADDR:%.+]] = load %struct.S*, %struct.S** [[S1_ADDR_PTR]],
+// UNTIEDRT: [[S2_ADDR_PTR_REF:%.+]] = alloca %struct.S**,
+// UNTIEDRT: call void (i8*, ...) %{{.+}}(i8* %{{.+}}, %struct.S** [[S1_ADDR_PTR]], %struct.S*** [[S2_ADDR_PTR_REF]])
+// UNTIEDRT-DAG: [[S1_ADDR:%.+]] = load %struct.S*, %struct.S** [[S1_ADDR_PTR]],
+// UNTIEDRT-DAG: [[S2_ADDR_PTR:%.+]] = load %struct.S**, %struct.S*** [[S2_ADDR_PTR_REF]],
+// UNTIEDRT-DAG: [[S2_ADDR:%.+]] = load %struct.S*, %struct.S** [[S2_ADDR_PTR]],
 // CHECK: switch i32 %{{.+}}, label %[[DONE:.+]] [
 
 // CHECK: [[DONE]]:
@@ -309,16 +330,25 @@
 // UNTIEDRT: br label %[[EXIT:[^,]+]]
 
 // 

[clang] 738bab7 - [OPENMP]Add support for allocate vars in untied tasks.

2020-09-15 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-09-15T13:39:14-04:00
New Revision: 738bab743b5c6cfcf1a1feb116de9e35a3f1e326

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

LOG: [OPENMP]Add support for allocate vars in untied tasks.

Local vars, marked with pragma allocate, mustbe allocate by the call of
the runtime function and cannot be allocated as other local variables.
Instead, we allocate a space for the pointer in private record and store
the address, returned by kmpc_alloc call in this pointer.
So, for untied tasks

```
 #pragma omp task untied
 {
   S s;
#pragma omp allocate(s) allocator(allocator)
   s = x;
 }
```
compiler generates something like this:
```
struct task_with_privates {
  S *ptr;
};

void entry(task_with_privates *p) {
  S *s = p->s;
  switch(partid) {
  case 1:
p->s = (S*)kmpc_alloc();
kmpc_omp_task();
br exit;
  case 2:
*s = x;
kmpc_omp_task();
br exit;
  case 2:
~S(s);
kmpc_free((void*)s);
br exit;
  }
exit:
}
```

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/allocate_codegen.cpp
clang/test/OpenMP/for_lastprivate_codegen.cpp
clang/test/OpenMP/for_linear_codegen.cpp
clang/test/OpenMP/for_reduction_codegen_UDR.cpp
clang/test/OpenMP/parallel_firstprivate_codegen.cpp
clang/test/OpenMP/parallel_private_codegen.cpp
clang/test/OpenMP/task_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 5384e9196896..e507e434d9e1 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1526,6 +1526,7 @@ void CGOpenMPRuntime::functionFinished(CodeGenFunction 
&CGF) {
 FunctionUDMMap.erase(I);
   }
   LastprivateConditionalToTypes.erase(CGF.CurFn);
+  FunctionToUntiedTaskStackMap.erase(CGF.CurFn);
 }
 
 llvm::Type *CGOpenMPRuntime::getIdentTyPointerTy() {
@@ -3382,6 +3383,17 @@ struct PrivateHelpersTy {
 typedef std::pair PrivateDataTy;
 } // anonymous namespace
 
+static bool isAllocatableDecl(const VarDecl *VD) {
+  const VarDecl *CVD = VD->getCanonicalDecl();
+  if (!CVD->hasAttr())
+return false;
+  const auto *AA = CVD->getAttr();
+  // Use the default allocation.
+  return !((AA->getAllocatorType() == OMPAllocateDeclAttr::OMPDefaultMemAlloc 
||
+AA->getAllocatorType() == OMPAllocateDeclAttr::OMPNullMemAlloc) &&
+   !AA->getAllocator());
+}
+
 static RecordDecl *
 createPrivatesRecordDecl(CodeGenModule &CGM, ArrayRef Privates) 
{
   if (!Privates.empty()) {
@@ -3396,9 +3408,12 @@ createPrivatesRecordDecl(CodeGenModule &CGM, 
ArrayRef Privates) {
   QualType Type = VD->getType().getNonReferenceType();
   // If the private variable is a local variable with lvalue ref type,
   // allocate the pointer instead of the pointee type.
-  if (Pair.second.isLocalPrivate() &&
-  VD->getType()->isLValueReferenceType())
-Type = C.getPointerType(Type);
+  if (Pair.second.isLocalPrivate()) {
+if (VD->getType()->isLValueReferenceType())
+  Type = C.getPointerType(Type);
+if (isAllocatableDecl(VD))
+  Type = C.getPointerType(Type);
+  }
   FieldDecl *FD = addFieldToRecordDecl(C, RD, Type);
   if (VD->hasAttrs()) {
 for (specific_attr_iterator I(VD->getAttrs().begin()),
@@ -3700,6 +3715,8 @@ emitTaskPrivateMappingFunction(CodeGenModule &CGM, 
SourceLocation Loc,
 QualType Ty = VD->getType().getNonReferenceType();
 if (VD->getType()->isLValueReferenceType())
   Ty = C.getPointerType(Ty);
+if (isAllocatableDecl(VD))
+  Ty = C.getPointerType(Ty);
 Args.push_back(ImplicitParamDecl::Create(
 C, /*DC=*/nullptr, Loc, /*Id=*/nullptr,
 C.getPointerType(C.getPointerType(Ty)).withConst().withRestrict(),
@@ -3780,8 +3797,10 @@ static void emitPrivatesInit(CodeGenFunction &CGF,
   FI = cast(FI->getType()->getAsTagDecl())->field_begin();
   for (const PrivateDataTy &Pair : Privates) {
 // Do not initialize private locals.
-if (Pair.second.isLocalPrivate())
+if (Pair.second.isLocalPrivate()) {
+  ++FI;
   continue;
+}
 const VarDecl *VD = Pair.second.PrivateCopy;
 const Expr *Init = VD->getAnyInitializer();
 if (Init && (!ForDup || (isa(Init) &&
@@ -4146,8 +4165,12 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, 
SourceLocation Loc,
  /*PrivateElemInit=*/nullptr));
 ++I;
   }
-  for (const VarDecl *VD : Data.PrivateLocals)
-Privates.emplace_back(C.getDeclAlign(VD), PrivateHelpersTy(VD));
+  for (const VarDecl *VD : Data.

[PATCH] D87627: [clang-tidy] Fix crash in modernize-use-noexcept on uninstantiated throw class

2020-09-15 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

Done.


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

https://reviews.llvm.org/D87627

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


[PATCH] D87627: [clang-tidy] Fix crash in modernize-use-noexcept on uninstantiated throw class

2020-09-15 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 291971.
zinovy.nis marked 2 inline comments as done.
zinovy.nis added a comment.

- Fixed the test.
- Fixed clang-format issues.


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

https://reviews.llvm.org/D87627

Files:
  clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
@@ -4,6 +4,7 @@
 // This test is not run in C++17 or later because dynamic exception
 // specifications were removed in C++17.
 
+using size_t = __SIZE_TYPE__;
 class A {};
 class B {};
 
@@ -19,6 +20,11 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 
'throw(int(int))' is deprecated; consider removing it instead 
[modernize-use-noexcept]
 // CHECK-FIXES: void k() ;
 
+// Shouldn't crash due to llvm_unreachable in canThrow() on EST_Uninstantiated
+template  class c { void *operator new(size_t) throw (int);};
+void s() { c<1> doesnt_crash; }
+// CHECK-MESSAGES: :[[@LINE-2]]:53: warning: dynamic exception specification 
'throw (int)' is deprecated; consider removing it instead 
[modernize-use-noexcept]
+
 void foobar() throw(A, B)
 {}
 // CHECK-MESSAGES: :[[@LINE-2]]:15: warning: dynamic exception specification 
'throw(A, B)' is deprecated; consider removing it instead 
[modernize-use-noexcept]
Index: clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
@@ -77,13 +77,16 @@
   .getExceptionSpecRange();
   }
 
+  assert(FnTy && "FunctionProtoType is null.");
+  if (isUnresolvedExceptionSpec(FnTy->getExceptionSpecType()))
+return;
+
   assert(Range.isValid() && "Exception Source Range is invalid.");
 
   CharSourceRange CRange = Lexer::makeFileCharRange(
   CharSourceRange::getTokenRange(Range), *Result.SourceManager,
   Result.Context->getLangOpts());
 
-  assert(FnTy && "FunctionProtoType is null.");
   bool IsNoThrow = FnTy->isNothrow();
   StringRef ReplacementStr =
   IsNoThrow


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
@@ -4,6 +4,7 @@
 // This test is not run in C++17 or later because dynamic exception
 // specifications were removed in C++17.
 
+using size_t = __SIZE_TYPE__;
 class A {};
 class B {};
 
@@ -19,6 +20,11 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int))' is deprecated; consider removing it instead [modernize-use-noexcept]
 // CHECK-FIXES: void k() ;
 
+// Shouldn't crash due to llvm_unreachable in canThrow() on EST_Uninstantiated
+template  class c { void *operator new(size_t) throw (int);};
+void s() { c<1> doesnt_crash; }
+// CHECK-MESSAGES: :[[@LINE-2]]:53: warning: dynamic exception specification 'throw (int)' is deprecated; consider removing it instead [modernize-use-noexcept]
+
 void foobar() throw(A, B)
 {}
 // CHECK-MESSAGES: :[[@LINE-2]]:15: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider removing it instead [modernize-use-noexcept]
Index: clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
@@ -77,13 +77,16 @@
   .getExceptionSpecRange();
   }
 
+  assert(FnTy && "FunctionProtoType is null.");
+  if (isUnresolvedExceptionSpec(FnTy->getExceptionSpecType()))
+return;
+
   assert(Range.isValid() && "Exception Source Range is invalid.");
 
   CharSourceRange CRange = Lexer::makeFileCharRange(
   CharSourceRange::getTokenRange(Range), *Result.SourceManager,
   Result.Context->getLangOpts());
 
-  assert(FnTy && "FunctionProtoType is null.");
   bool IsNoThrow = FnTy->isNothrow();
   StringRef ReplacementStr =
   IsNoThrow
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87673: [clangd] Don't use zlib when it's unavailable.

2020-09-15 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz accepted this revision.
adamcz added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/index/Serialization.cpp:209
 Uncompressed = UncompressedStorage;
+  } else {
+return error("Compressed string table, but zlib is unavailable");

nit: skip { } to stay consistent with local style


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87673

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


[PATCH] D84962: [PowerPC] Correct cpsgn's behaviour on PowerPC to match that of the ABI

2020-09-15 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

Yes, this definitely needs a test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84962

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


[PATCH] D87321: Fix -gz=zlib options for linker

2020-09-15 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

This broke the PPC LLD bot and the failure has been ignored for 4 days. I 
believe it should be fixed with 3bc3983f229 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87321

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


[clang] 3bc3983 - Fix bot failure after ccb4124a4172

2020-09-15 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2020-09-15T12:36:47-05:00
New Revision: 3bc3983f229f9277d5bea3692b691f72ab8740dd

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

LOG: Fix bot failure after ccb4124a4172

The test case has a check line for the option on a line that includes
the string lld surrounded by any characters. This causes failures
when said string is in the build path. What the test case presumably
means to test is the actual invocation of the LLD linker (i.e. a
linker that has that string as a suffix). This patch simply removes
the erroneous wildcard after the string.

Added: 


Modified: 
clang/test/Driver/hip-gz-options.hip

Removed: 




diff  --git a/clang/test/Driver/hip-gz-options.hip 
b/clang/test/Driver/hip-gz-options.hip
index b2544a42ebed..705c1be7b94e 100644
--- a/clang/test/Driver/hip-gz-options.hip
+++ b/clang/test/Driver/hip-gz-options.hip
@@ -9,6 +9,6 @@
 // RUN:   -ggdb -gz=zlib 2>&1 | FileCheck %s
 
 // CHECK-DAG: {{".*clang.*" .* "--compress-debug-sections=zlib"}}
-// CHECK-DAG: {{".*lld.*" .* "--compress-debug-sections=zlib"}}
+// CHECK-DAG: {{".*lld" .* "--compress-debug-sections=zlib"}}
 // CHECK-DAG: {{".*clang.*" .* "--compress-debug-sections=zlib"}}
 // CHECK: "--compress-debug-sections=zlib"



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


[PATCH] D87451: add new clang option -mignore-xcoff-visibility

2020-09-15 Thread Digger via Phabricator via cfe-commits
DiggerLin updated this revision to Diff 291962.
DiggerLin retitled this revision from "add new clang option -fnovisibility." to 
"add new clang option -mignore-xcoff-visibility".

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87451

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/Decl.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/ignore-xcoff-visibility.cpp

Index: clang/test/Driver/ignore-xcoff-visibility.cpp
===
--- /dev/null
+++ clang/test/Driver/ignore-xcoff-visibility.cpp
@@ -0,0 +1,81 @@
+// RUN: %clang-target powerpc-unknown-aix  -emit-llvm  -o - -S  %s  |\
+// RUN:   FileCheck --check-prefix=IGNOREVISIBILITY %s
+
+// RUN: %clang -target powerpc-unknown-linux  -emit-llvm  -o - -S %s  | \
+// RUN: FileCheck -check-prefix=VISIBILITY %s
+
+// RUN: %clang -mignore-xcoff-visibility -target powerpc-unknown-aix  -emit-llvm -o -  -S %s  | \
+// RUN: FileCheck -check-prefix=IGNOREVISIBILITY %s
+
+// RUN: not %clang -mignore-xcoff-visibility -target powerpc-unknown-linux  -emit-llvm -o - -S %s  2>&1 | \
+// RUN: FileCheck -check-prefix=ERROR %s
+
+// RUN: %clang -fvisibility=default -target powerpc-unknown-aix  -emit-llvm -o -  -S %s  | \
+// RUN: FileCheck -check-prefix=VISIBILITY %s
+
+// RUN: %clang -fvisibility=default -target powerpc-unknown-linux  -emit-llvm -o - -S %s  | \
+// RUN: FileCheck -check-prefix=VISIBILITY %s
+
+// RUN: %clang -mignore-xcoff-visibility -fvisibility=default -target powerpc-unknown-aix  -emit-llvm  -o - -S %s  | \
+// RUN: FileCheck -check-prefix=IGNOREVISIBILITY %s
+
+// RUN: not %clang -mignore-xcoff-visibility -fvisibility=default -target powerpc-unknown-linux  -emit-llvm -o - -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=ERROR %s
+
+__attribute__((visibility("hidden"))) void foo_h(int *p) {
+  (*p)++;
+}
+
+__attribute__((visibility("protected"))) int b;
+
+extern __attribute__((visibility("hidden"))) void zoo_extern_h(void);
+
+void (*foo_p)(void) = zoo_extern_h;
+
+__attribute__((visibility("protected"))) void bar() {
+  foo_h(&b);
+  foo_p();
+}
+
+class TestClass {
+public:
+  __attribute__((__visibility__("hidden"))) int value() const noexcept { return 0; }
+};
+
+int main() {
+  TestClass TC;
+  return TC.value();
+}
+
+template 
+class basic {
+public:
+  __attribute__((__visibility__("protected"))) int getdata() { return 1; }
+};
+
+template class basic;
+
+#pragma GCC visibility push(hidden)
+int pramb;
+void prambar() {}
+#pragma GCC visibility pop
+
+// IGNOREVISIBILITY:@b = global i32 0
+// IGNOREVISIBILITY:@pramb = global i32 0
+// IGNOREVISIBILITY:define void @_Z5foo_hPi(i32* %p)
+// IGNOREVISIBILITY:declare void @_Z12zoo_extern_hv()
+// IGNOREVISIBILITY:define void @_Z3barv()
+// IGNOREVISIBILITY:define linkonce_odr i32 @_ZNK9TestClass5valueEv(%class.TestClass* %this)
+// IGNOREVISIBILITY:define weak_odr i32 @_ZN5basicIiE7getdataEv(%class.basic* %this)
+// IGNOREVISIBILITY:define void @_Z7prambarv()
+
+// VISIBILITY:@b = protected global i32 0
+// VISIBILITY:@pramb = hidden global i32 0
+// VISIBILITY:define hidden void @_Z5foo_hPi(i32* %p)
+// VISIBILITY:declare hidden void @_Z12zoo_extern_hv()
+// VISIBILITY:define protected void @_Z3barv()
+// VISIBILITY:define linkonce_odr hidden i32 @_ZNK9TestClass5valueEv(%class.TestClass* %this)
+// VISIBILITY:define weak_odr protected i32 @_ZN5basicIiE7getdataEv(%class.basic* %this)
+// VISIBILITY:define hidden void @_Z7prambarv()
+
+// ERROR: unsupported option '-mignore-xcoff-visibility' for target 'powerpc-unknown-linux'
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2749,9 +2749,19 @@
 
   // The value-visibility mode defaults to "default".
   if (Arg *visOpt = Args.getLastArg(OPT_fvisibility)) {
-Opts.setValueVisibilityMode(parseVisibility(visOpt, Args, Diags));
+// In AIX Os, if there is -mignore_xcoff_visibility and -fvisibility=* at
+// sametime, the option "mignore_xcoff_visibility" take effect.
+if (T.isOSAIX() && Args.hasArg(OPT_mignore_xcoff_visibility))
+  Opts.IgnoreXCOFFVisibility = 1;
+else
+  Opts.setValueVisibilityMode(parseVisibility(visOpt, Args, Diags));
   } else {
-Opts.setValueVisibilityMode(DefaultVisibility);
+// In AIX oS, the -mignore_xcoff_visibility is enable by default if there is
+// not -fvisibility=*
+if (T.isOSAIX())
+  Opts.IgnoreXCOFFVisibility = 1;
+else
+  Opts.setValueVisibilityMode(DefaultVisibility);
   }
 
   // The type-visibility mode defaults to the value-visibility m

[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-15 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D87163#2274549 , @dmajor wrote:

> Reduced a bit more: https://godbolt.org/z/j59evK (C++) and 
> https://godbolt.org/z/8xG688 (IR) -- the store at line 43 of `while.end` has 
> been removed.

Thanks! I reverted the change for now in fb109c42d91c 
.

I think the problem here is that the load in the loop has `liveOnEntry` as 
defining access (which is outside the loop), so according to MemorySSA, the 
load does not read the memory written by the store. A slightly further IR 
example with the MemorySSA printed: https://godbolt.org/z/G34oM4. I think this 
is similar to the issue https://bugs.llvm.org/show_bug.cgi?id=47498.

@asbirlea do you have any thoughts on the issue? Do I understand correctly that 
in the example, `%use = load i32, i32* %ptr.1, align 4` should have `; 8 = 
MemoryPhi({entry,1},{loop.latch,7})` as defining access?

  define i32 @test() {
  entry:
%nodeStack = alloca [12 x i32], align 4
%nodeStack.cast = bitcast [12 x i32]* %nodeStack to i8*
  ; 1 = MemoryDef(liveOnEntry)
%c.1 = call i1 @cond(i32 1)
br i1 %c.1, label %cleanup, label %loop.header
  
  loop.header:  ; preds = %loop.latch, 
%entry
  ; 8 = MemoryPhi({entry,1},{loop.latch,7})
%depth.1 = phi i32 [ %depth.1.be, %loop.latch ], [ 0, %entry ]
%cmp = icmp sgt i32 %depth.1, 0
br i1 %cmp, label %cond.read, label %cond.store
  
  cond.read:; preds = %loop.header
%sub = add nsw i32 %depth.1, -1
%ptr.1 = getelementptr inbounds [12 x i32], [12 x i32]* %nodeStack, i32 0, 
i32 %sub
  ; MemoryUse(liveOnEntry)
%use = load i32, i32* %ptr.1, align 4
  ; 2 = MemoryDef(8)
%c.2 = call i1 @cond(i32 %use)
br i1 %c.2, label %loop.latch, label %cond.store
  
  cond.store:   ; preds = %cond.read, 
%loop.header
  ; 9 = MemoryPhi({loop.header,8},{cond.read,2})
%ptr.2 = getelementptr inbounds [12 x i32], [12 x i32]* %nodeStack, i32 0, 
i32 %depth.1
  ; 3 = MemoryDef(9)
store i32 10, i32* %ptr.2, align 4
%inc = add nsw i32 %depth.1, 1
  ; 4 = MemoryDef(3)
%c.3 = call i1 @cond(i32 20)
br i1 %c.3, label %cleanup, label %loop.latch
  
  loop.latch:   ; preds = %cond.store, 
%cond.read
  ; 7 = MemoryPhi({cond.read,2},{cond.store,4})
%depth.1.be = phi i32 [ %sub, %cond.read ], [ %inc, %cond.store ]
br label %loop.header
  
  cleanup:  ; preds = %cond.store, 
%entry
  ; 6 = MemoryPhi({entry,1},{cond.store,4})
  ; 5 = MemoryDef(6)
call void @llvm.lifetime.end.p0i8(i64 48, i8* nonnull %nodeStack.cast)
ret i32 20
  }




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

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


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

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

In D83004#2274573 , @greened wrote:

> In D83004#2168427 , @jdoerfert wrote:
>
>> Due to D82995  I realized we should have a 
>> test of this in `llvm/test/tools/UpdateTestChecks` as well.
>
> Do you mean a test for recognizing the option in `common.py`?  I'm not sure 
> what you're asking for here.

The function is recognized in common.py, right? Can't you run the 
update_test_check.py it with that option now? If so, we could have a test for 
it, using, for example, hot-cold splitting or attributor with the 
`-attributor-allow-deep-wrappers` and a `linkonce_odr` function that is called.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83004

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


[PATCH] D86694: [scudo] Allow -fsanitize=scudo on Linux and Windows (WIP, don't land as is)

2020-09-15 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad added a comment.

In D86694#2274548 , @russell.gallop 
wrote:

> I guess using scudo as a general purpose allocator that could set a limit on 
> the number of cores that can be used at once as @aganea found. Would there be 
> any problem with making this very small (e.g. a couple of GB)?

You can reduce the size of the Primary for Windows with an additional define in 
the platform file. You probably want to make sure there is at least a few gigs 
per region (eg: the total size could be 256G).

Once again the memory is reserved but not committed, and this is on a 
per-process basis. There shouldn't be more than one Primary, and as such we 
shouldn't run out of VA space. We could possibly run out of memory if we 
allocate past the amount of RAM (+swap), but this is the committed amount.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86694

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


[clang] 3a59628 - Revert "[DSE] Switch to MemorySSA-backed DSE by default."

2020-09-15 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2020-09-15T18:07:56+01:00
New Revision: 3a59628f3cc26eb085acfc9cbdc97243ef71a6c5

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

LOG: Revert "[DSE] Switch to MemorySSA-backed DSE by default."

This reverts commit fb109c42d91c30c8c7497ef1fd7aff6f2969c6e7.

Temporarily revert due to a mis-compile pointed out at D87163.

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
clang/test/CodeGenObjC/exceptions.m
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/test/Analysis/BasicAA/modref.ll
llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
llvm/test/Other/new-pm-defaults.ll
llvm/test/Other/new-pm-lto-defaults.ll
llvm/test/Other/new-pm-thinlto-defaults.ll
llvm/test/Other/opt-O2-pipeline.ll
llvm/test/Other/opt-O3-pipeline-enable-matrix.ll
llvm/test/Other/opt-O3-pipeline.ll
llvm/test/Other/opt-Os-pipeline.ll
llvm/test/Transforms/Coroutines/ArgAddr.ll
llvm/test/Transforms/Coroutines/coro-retcon.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/2011-03-25-DSEMiscompile.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/2011-09-06-EndOfFunction.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/2011-09-06-MemCpy.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/2016-07-17-UseAfterFree.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/OverwriteStoreBegin.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/OverwriteStoreEnd.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/PartialStore.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/PartialStore2.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/X86/gather-null-pointer.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/atomic-overlapping.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/atomic-todo.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/atomic.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/calloc-store.ll

llvm/test/Transforms/DeadStoreElimination/MSSA/combined-partial-overwrites.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/const-pointers.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/crash.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/cs-cs-aliasing.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/debug-counter.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/debuginfo.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/dominate.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/fence-todo.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/fence.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/free.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/inst-limits.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/int_sideeffect.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/invariant.start.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/launder.invariant.group.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/libcalls.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/lifetime.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/mda-with-dbg-values.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/memcpy-complete-overwrite.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/memintrinsics.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/memoryssa-scan-limit.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/memset-and-memcpy.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/memset-missing-debugloc.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/memset-unknown-sizes.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/merge-stores-big-endian.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/merge-stores.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-captures.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-exceptions.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-loops.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-malloc-free.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-memintrinsics.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-memoryphis.ll

llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-multipath-throwing.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-multipath.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-overlap.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-partial.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-simple.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-throwing.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-unreachable.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/no-targetdata.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/noop-stores.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/operand-bundles.

  1   2   3   >