[llvm-branch-commits] [libcxx] de212de - [libc++] [www] Mark P0482 as "In Progress", as some parts of it are already implemented.

2020-11-23 Thread Marek Kurdej via llvm-branch-commits

Author: Marek Kurdej
Date: 2020-11-23T09:10:20+01:00
New Revision: de212de22edc5ce9786c1814c829fefcd94ab564

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

LOG: [libc++] [www] Mark P0482 as "In Progress", as some parts of it are 
already implemented.

Added: 


Modified: 
libcxx/www/cxx2a_status.html

Removed: 




diff  --git a/libcxx/www/cxx2a_status.html b/libcxx/www/cxx2a_status.html
index f0d1acfccdf5..f90714493f8f 100644
--- a/libcxx/www/cxx2a_status.html
+++ b/libcxx/www/cxx2a_status.html
@@ -72,7 +72,7 @@ Paper Status
https://wg21.link/P0768R1";>P0768R1CWGLibrary 
Support for the Spaceship (Comparison) 
OperatorAlbuquerqueComplete
https://wg21.link/P0777R1";>P0777R1LWGTreating 
Unnecessary 
decayAlbuquerqueComplete7.0
https://wg21.link/P0122R7";>P0122R7LWGJacksonvilleComplete7.0
-   https://wg21.link/P0355R7";>P0355R7LWGExtending 
chrono to Calendars and Time ZonesJacksonvilleIn 
progress
+   https://wg21.link/P0355R7";>P0355R7LWGExtending 
chrono to Calendars and Time ZonesJacksonvilleIn 
Progress
https://wg21.link/P0551R3";>P0551R3LWGThou Shalt Not 
Specialize std Function 
Templates!JacksonvilleComplete11.0
https://wg21.link/P0753R2";>P0753R2LWGManipulators 
for C++ Synchronized Buffered 
OstreamJacksonville
https://wg21.link/P0754R2";>P0754R2LWGJacksonvilleComplete7.0
@@ -101,7 +101,7 @@ Paper Status
https://wg21.link/P0892R2";>P0892R2CWGexplicit(bool)Rapperswil
https://wg21.link/P0898R3";>P0898R3LWGStandard 
Library ConceptsRapperswil
https://wg21.link/P0935R0";>P0935R0LWGEradicating 
unnecessarily explicit default constructors from the standard 
libraryRapperswil
-   https://wg21.link/P0941R2";>P0941R2CWGIntegrating 
feature-test macros into the C++ WDRapperswilIn 
progress
+   https://wg21.link/P0941R2";>P0941R2CWGIntegrating 
feature-test macros into the C++ WDRapperswilIn 
Progress
https://wg21.link/P1023R0";>P1023R0LWGconstexpr 
comparison operators for 
std::arrayRapperswilComplete8.0
https://wg21.link/P1025R1";>P1025R1CWGUpdate The 
Reference To The Unicode StandardRapperswil
https://wg21.link/P1120R0";>P1120R0CWGConsistency 
improvements for <=> and other comparison 
operatorsRapperswil
@@ -110,7 +110,7 @@ Paper Status
https://wg21.link/P0318R1";>P0318R1LWGunwrap_ref_decay
 and unwrap_referenceSan DiegoComplete8.0
https://wg21.link/P0356R5";>P0356R5LWGSimplified 
partial function applicationSan Diego 

https://wg21.link/P0357R3";>P0357R3LWGreference_wrapper
 for incomplete typesSan DiegoComplete8.0
-   https://wg21.link/P0482R6";>P0482R6CWGchar8_t: A 
type for UTF-8 characters and stringsSan Diego 

+   https://wg21.link/P0482R6";>P0482R6CWGchar8_t: A 
type for UTF-8 characters and stringsSan DiegoIn 
Progress
https://wg21.link/P0487R1";>P0487R1LWGFixing 
operator>>(basic_istream&, CharT*) (LWG 2499)San 
DiegoComplete8.0
https://wg21.link/P0591R4";>P0591R4LWGUtility 
functions to implement uses-allocator constructionSan 
Diego 
https://wg21.link/P0595R2";>P0595R2CWGP0595R2 
std::is_constant_evaluated()San 
DiegoComplete9.0
@@ -182,7 +182,7 @@ Paper Status
https://wg21.link/P1522";>P1522LWGIterator 
Difference Type and Integer OverflowCologne
https://wg21.link/P1523";>P1523LWGViews and Size 
TypesCologne
https://wg21.link/P1612";>P1612LWGRelocate Endian’s 
SpecificationCologneComplete10.0
-   https://wg21.link/P1614";>P1614LWGThe Mothership has 
LandedCologneIn progress
+   https://wg21.link/P1614";>P1614LWGThe Mothership has 
LandedCologneIn Progress
https://wg21.link/P1638";>P1638LWGbasic_istream_view::iterator
 should not be copyableCologne
https://wg21.link/P1643";>P1643LWGAdd wait/notify to 
atomic_refCologne
https://wg21.link/P1644";>P1644LWGAdd wait/notify to 
atomicCologne



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


[llvm-branch-commits] [clang-tools-extra] 0dc2589 - [clangd] Attempt at fixing ExternalIndex tests on windows

2020-11-23 Thread Kadir Cetinkaya via llvm-branch-commits

Author: Kadir Cetinkaya
Date: 2020-11-23T09:16:06+01:00
New Revision: 0dc2589d4a72474f3956d4472ad25a1085dda260

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

LOG: [clangd] Attempt at fixing ExternalIndex tests on windows

Added: 


Modified: 
clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp 
b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
index 9e7fc5a49868..2b4605eb97e2 100644
--- a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -229,11 +229,13 @@ TEST_F(ConfigCompileTests, ExternalBlockErrOnNoSource) {
 }
 
 TEST_F(ConfigCompileTests, ExternalBlockDisablesBackgroundIndex) {
-  Parm.Path = "/foo/bar/baz.h";
+  auto BazPath = testPath("foo/bar/baz.h", llvm::sys::path::Style::posix);
+  Parm.Path = BazPath;
   Frag.Index.Background.emplace("Build");
   Fragment::IndexBlock::ExternalBlock External;
-  External.File.emplace("/foo");
-  External.MountPoint.emplace("/foo/bar");
+  External.File.emplace(testPath("foo"));
+  External.MountPoint.emplace(
+  testPath("foo/bar", llvm::sys::path::Style::posix));
   Frag.Index.External = std::move(External);
   compileAndApply();
   EXPECT_EQ(Conf.Index.Background, Config::BackgroundPolicy::Skip);
@@ -245,14 +247,15 @@ TEST_F(ConfigCompileTests, ExternalBlockMountPoint) {
 Fragment Frag;
 Frag.Source.Directory = Directory.str();
 Fragment::IndexBlock::ExternalBlock External;
-External.File.emplace("/foo");
+External.File.emplace(testPath("foo"));
 if (MountPoint)
   External.MountPoint.emplace(*MountPoint);
 Frag.Index.External = std::move(External);
 return Frag;
   };
 
-  Parm.Path = "/foo/bar.h";
+  auto BarPath = testPath("foo/bar.h", llvm::sys::path::Style::posix);
+  Parm.Path = BarPath;
   // Non-absolute MountPoint without a directory raises an error.
   Frag = GetFrag("", "foo");
   compileAndApply();
@@ -264,41 +267,44 @@ TEST_F(ConfigCompileTests, ExternalBlockMountPoint) {
 DiagKind(llvm::SourceMgr::DK_Error;
   ASSERT_FALSE(Conf.Index.External);
 
+  auto FooPath = testPath("foo/", llvm::sys::path::Style::posix);
   // Ok when relative.
-  Frag = GetFrag("/", "foo");
+  Frag = GetFrag(testRoot(), "foo/");
   compileAndApply();
   ASSERT_THAT(Diags.Diagnostics, IsEmpty());
   ASSERT_TRUE(Conf.Index.External);
-  EXPECT_THAT(Conf.Index.External->MountPoint, "/foo");
+  EXPECT_THAT(Conf.Index.External->MountPoint, FooPath);
 
   // None defaults to ".".
-  Frag = GetFrag("/", llvm::None);
+  Frag = GetFrag(FooPath, llvm::None);
   compileAndApply();
   ASSERT_THAT(Diags.Diagnostics, IsEmpty());
   ASSERT_TRUE(Conf.Index.External);
-  EXPECT_THAT(Conf.Index.External->MountPoint, "/");
+  EXPECT_THAT(Conf.Index.External->MountPoint, FooPath);
 
   // Without a file, external index is empty.
   Parm.Path = "";
-  Frag = GetFrag("", "/foo");
+  Frag = GetFrag("", FooPath.c_str());
   compileAndApply();
   ASSERT_THAT(Diags.Diagnostics, IsEmpty());
   ASSERT_FALSE(Conf.Index.External);
 
   // File outside MountPoint, no index.
-  Parm.Path = "/bar/baz.h";
-  Frag = GetFrag("", "/foo");
+  auto BazPath = testPath("bar/baz.h", llvm::sys::path::Style::posix);
+  Parm.Path = BazPath;
+  Frag = GetFrag("", FooPath.c_str());
   compileAndApply();
   ASSERT_THAT(Diags.Diagnostics, IsEmpty());
   ASSERT_FALSE(Conf.Index.External);
 
   // File under MountPoint, index should be set.
-  Parm.Path = "/foo/baz.h";
-  Frag = GetFrag("", "/foo");
+  BazPath = testPath("foo/baz.h", llvm::sys::path::Style::posix);
+  Parm.Path = BazPath;
+  Frag = GetFrag("", FooPath.c_str());
   compileAndApply();
   ASSERT_THAT(Diags.Diagnostics, IsEmpty());
   ASSERT_TRUE(Conf.Index.External);
-  EXPECT_THAT(Conf.Index.External->MountPoint, "/foo");
+  EXPECT_THAT(Conf.Index.External->MountPoint, FooPath);
 }
 } // namespace
 } // namespace config



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


[llvm-branch-commits] [lldb] 7b7c372 - [lldb] [Process/FreeBSD] Add missing 'override' kws to POSIXStopInfo

2020-11-23 Thread Michał Górny via llvm-branch-commits

Author: Michał Górny
Date: 2020-11-23T09:22:41+01:00
New Revision: 7b7c372e3fcadfd5ee6ab3fb68d9f0f1c25e0247

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

LOG: [lldb] [Process/FreeBSD] Add missing 'override' kws to POSIXStopInfo

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

Added: 


Modified: 
lldb/source/Plugins/Process/FreeBSD/POSIXStopInfo.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/FreeBSD/POSIXStopInfo.h 
b/lldb/source/Plugins/Process/FreeBSD/POSIXStopInfo.h
index 88fb7f31fe06..5a022c485b68 100644
--- a/lldb/source/Plugins/Process/FreeBSD/POSIXStopInfo.h
+++ b/lldb/source/Plugins/Process/FreeBSD/POSIXStopInfo.h
@@ -34,13 +34,13 @@ class POSIXLimboStopInfo : public POSIXStopInfo {
 
   ~POSIXLimboStopInfo();
 
-  lldb::StopReason GetStopReason() const;
+  lldb::StopReason GetStopReason() const override;
 
-  const char *GetDescription();
+  const char *GetDescription() override;
 
-  bool ShouldStop(lldb_private::Event *event_ptr);
+  bool ShouldStop(lldb_private::Event *event_ptr) override;
 
-  bool ShouldNotify(lldb_private::Event *event_ptr);
+  bool ShouldNotify(lldb_private::Event *event_ptr) override;
 };
 
 
//===--===//
@@ -54,13 +54,13 @@ class POSIXNewThreadStopInfo : public POSIXStopInfo {
 
   ~POSIXNewThreadStopInfo();
 
-  lldb::StopReason GetStopReason() const;
+  lldb::StopReason GetStopReason() const override;
 
-  const char *GetDescription();
+  const char *GetDescription() override;
 
-  bool ShouldStop(lldb_private::Event *event_ptr);
+  bool ShouldStop(lldb_private::Event *event_ptr) override;
 
-  bool ShouldNotify(lldb_private::Event *event_ptr);
+  bool ShouldNotify(lldb_private::Event *event_ptr) override;
 };
 
 #endif



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


[llvm-branch-commits] [lldb] 8f2f9a8 - [lldb] [Process/Utility] Declare register overlaps between ST and MM

2020-11-23 Thread Michał Górny via llvm-branch-commits

Author: Michał Górny
Date: 2020-11-23T09:23:14+01:00
New Revision: 8f2f9a82e2cc333d36ddd1b6bb0523623e065cdc

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

LOG: [lldb] [Process/Utility] Declare register overlaps between ST and MM

Explicitly declare register overlaps/invalidation between ST(i) and MMi
registers.

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

Added: 


Modified: 
lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
lldb/source/Plugins/Process/Utility/RegisterInfos_i386.h
lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
index bf9282d8c0cc..2c7f63503d7c 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
@@ -286,6 +286,74 @@ uint32_t RegisterContextPOSIX_x86::g_invalidate_fip[] = {
 uint32_t RegisterContextPOSIX_x86::g_invalidate_fdp[] = {
 lldb_fdp_x86_64, lldb_fooff_x86_64, lldb_foseg_x86_64, 
LLDB_INVALID_REGNUM};
 
+uint32_t RegisterContextPOSIX_x86::g_contained_st0_32[] = {lldb_st0_i386,
+   
LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_contained_st1_32[] = {lldb_st1_i386,
+   
LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_contained_st2_32[] = {lldb_st2_i386,
+   
LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_contained_st3_32[] = {lldb_st3_i386,
+   
LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_contained_st4_32[] = {lldb_st4_i386,
+   
LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_contained_st5_32[] = {lldb_st5_i386,
+   
LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_contained_st6_32[] = {lldb_st6_i386,
+   
LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_contained_st7_32[] = {lldb_st7_i386,
+   
LLDB_INVALID_REGNUM};
+
+uint32_t RegisterContextPOSIX_x86::g_invalidate_st0_32[] = {
+lldb_st0_i386, lldb_mm0_i386, LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_invalidate_st1_32[] = {
+lldb_st1_i386, lldb_mm1_i386, LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_invalidate_st2_32[] = {
+lldb_st2_i386, lldb_mm2_i386, LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_invalidate_st3_32[] = {
+lldb_st3_i386, lldb_mm3_i386, LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_invalidate_st4_32[] = {
+lldb_st4_i386, lldb_mm4_i386, LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_invalidate_st5_32[] = {
+lldb_st5_i386, lldb_mm5_i386, LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_invalidate_st6_32[] = {
+lldb_st6_i386, lldb_mm6_i386, LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_invalidate_st7_32[] = {
+lldb_st7_i386, lldb_mm7_i386, LLDB_INVALID_REGNUM};
+
+uint32_t RegisterContextPOSIX_x86::g_contained_st0_64[] = {lldb_st0_x86_64,
+   
LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_contained_st1_64[] = {lldb_st1_x86_64,
+   
LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_contained_st2_64[] = {lldb_st2_x86_64,
+   
LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_contained_st3_64[] = {lldb_st3_x86_64,
+   
LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_contained_st4_64[] = {lldb_st4_x86_64,
+   
LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_contained_st5_64[] = {lldb_st5_x86_64,
+   
LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_contained_st6_64[] = {lldb_st6_x86_64,
+   
LLDB_INVALID_REGNUM};
+uint32_t RegisterContextPOSIX_x86::g_contained_st7_64[] = {lldb_st7_x86_64,
+   
LLDB_INVALID_REGNUM};
+
+uint32_t RegisterContextPOSIX_x86::g_invalidat

[llvm-branch-commits] [lldb] 9367b57 - [lldb] [test] Fix qRegisterInfo lldb-server tests to handle missing registers

2020-11-23 Thread Michał Górny via llvm-branch-commits

Author: Michał Górny
Date: 2020-11-23T09:26:23+01:00
New Revision: 9367b57dadb7a8515fa454cb4bb8e4cc45bf57d2

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

LOG: [lldb] [test] Fix qRegisterInfo lldb-server tests to handle missing 
registers

Fix qRegisterInfo tests to handle Exx error response when querying
registers that are not supported on the platform in question.  This
is how FreeBSD and NetBSD platforms reporting missing registers right
now, and there certainly is value from verifying the remaining
registers.

This change fixes the test for FreeBSD but NetBSD has other regressions
that still need to be researched.

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

Added: 


Modified: 
lldb/test/API/tools/lldb-server/TestLldbGdbServer.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py 
b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
index 13fe9c3c0398..9fb8cc1892ea 100644
--- a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -585,9 +585,15 @@ def 
p_returns_correct_data_size_for_each_qRegisterInfo(self):
 p_response = context.get("p_response")
 self.assertIsNotNone(p_response)
 
+# Skip erraneous (unsupported) registers.
+# TODO: remove this once we make unsupported registers disappear.
+if p_response.startswith("E") and len(p_response) == 3:
+continue
+
 if "dynamic_size_dwarf_expr_bytes" in reg_info:
 self.updateRegInfoBitsize(reg_info, byte_order)
-self.assertEqual(len(p_response), 2 * int(reg_info["bitsize"]) / 8)
+self.assertEqual(len(p_response), 2 * int(reg_info["bitsize"]) / 8,
+ reg_info)
 
 # Increment loop
 reg_index += 1
@@ -601,7 +607,7 @@ def 
test_p_returns_correct_data_size_for_each_qRegisterInfo_launch_debugserver(
 self.set_inferior_startup_launch()
 self.p_returns_correct_data_size_for_each_qRegisterInfo()
 
-@expectedFailureAll(oslist=["freebsd", "netbsd"])
+@expectedFailureAll(oslist=["netbsd"])
 @llgs_test
 def test_p_returns_correct_data_size_for_each_qRegisterInfo_launch_llgs(
 self):
@@ -619,7 +625,7 @@ def 
test_p_returns_correct_data_size_for_each_qRegisterInfo_attach_debugserver(
 self.set_inferior_startup_attach()
 self.p_returns_correct_data_size_for_each_qRegisterInfo()
 
-@expectedFailureAll(oslist=["freebsd", "netbsd"])
+@expectedFailureAll(oslist=["netbsd"])
 @llgs_test
 def test_p_returns_correct_data_size_for_each_qRegisterInfo_attach_llgs(
 self):



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


[llvm-branch-commits] [lldb] 8018e7b - [lldb] [Process/FreeBSDRemote] Fix regset names and related tests

2020-11-23 Thread Michał Górny via llvm-branch-commits

Author: Michał Górny
Date: 2020-11-23T09:28:20+01:00
New Revision: 8018e7b447dacb37a520fe989ab42c0586730961

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

LOG: [lldb] [Process/FreeBSDRemote] Fix regset names and related tests

Restore Linux-alike regset names for AVX/MPX registers
as TestLldbGdbServer seems to depend on them.  At the same time, fix
TestRegisters to be aware that they are not available on FreeBSD
and NetBSD, at least until we figure out a better way of reporting
unsupported register sets.

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

Added: 


Modified: 

lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
lldb/test/API/commands/register/register/register_command/TestRegisters.py
lldb/test/API/tools/lldb-server/TestLldbGdbServer.py

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
index ea5400c55713..8f1ba2eb4137 100644
--- 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
+++ 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
@@ -215,9 +215,9 @@ static const RegisterSet 
g_reg_sets_i386[k_num_register_sets] = {
 {"Floating Point Registers", "fpu", k_num_fpr_registers_i386,
  g_fpu_regnums_i386},
 {"Debug Registers", "dbr", k_num_dbr_registers_i386, g_dbr_regnums_i386},
-{"Extended AVX registers", "avx", k_num_avx_registers_i386,
+{"Advanced Vector Extensions", "avx", k_num_avx_registers_i386,
  g_avx_regnums_i386},
-{"Extended MPX registers", "mpx", k_num_mpx_registers_i386,
+{"Memory Protection Extensions", "mpx", k_num_mpx_registers_i386,
  g_mpx_regnums_i386},
 };
 
@@ -229,9 +229,9 @@ static const RegisterSet 
g_reg_sets_x86_64[k_num_register_sets] = {
  g_fpu_regnums_x86_64},
 {"Debug Registers", "dbr", k_num_dbr_registers_x86_64,
  g_dbr_regnums_x86_64},
-{"Extended AVX registers", "avx", k_num_avx_registers_x86_64,
+{"Advanced Vector Extensions", "avx", k_num_avx_registers_x86_64,
  g_avx_regnums_x86_64},
-{"Extended MPX registers", "mpx", k_num_mpx_registers_x86_64,
+{"Memory Protection Extensions", "mpx", k_num_mpx_registers_x86_64,
  g_mpx_regnums_x86_64},
 };
 

diff  --git 
a/lldb/test/API/commands/register/register/register_command/TestRegisters.py 
b/lldb/test/API/commands/register/register/register_command/TestRegisters.py
index 98024a83bf42..5e26f3317b41 100644
--- a/lldb/test/API/commands/register/register/register_command/TestRegisters.py
+++ b/lldb/test/API/commands/register/register/register_command/TestRegisters.py
@@ -404,7 +404,12 @@ def fp_register_write(self):
 for registerSet in registerSets:
 if 'advanced vector extensions' in 
registerSet.GetName().lower():
 has_avx = True
-if 'memory protection extension' in 
registerSet.GetName().lower():
+# FreeBSD/NetBSD reports missing register sets 
diff erently
+# at the moment and triggers false positive here.
+# TODO: remove FreeBSD/NetBSD exception when we make 
unsupported
+# register groups correctly disappear.
+if ('memory protection extension' in 
registerSet.GetName().lower()
+and self.getPlatform() not in ["freebsd", "netbsd"]):
 has_mpx = True
 
 if has_avx:

diff  --git a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py 
b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
index 9fb8cc1892ea..609931e1f892 100644
--- a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -433,7 +433,7 @@ def qRegisterInfo_contains_avx_registers(self):
 "Advanced Vector Extensions" in register_sets)
 
 @expectedFailureAll(oslist=["windows"]) # no avx for now.
-@expectedFailureAll(oslist=["freebsd", "netbsd"])
+@expectedFailureAll(oslist=["netbsd"])
 @llgs_test
 def test_qRegisterInfo_contains_avx_registers_llgs(self):
 self.init_llgs_test()



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


[llvm-branch-commits] [lldb] 18e4272 - [lldb] Prevent 'process connect' from using local-only plugins

2020-11-23 Thread Michał Górny via llvm-branch-commits

Author: Michał Górny
Date: 2020-11-23T09:48:55+01:00
New Revision: 18e4272a4fe4667a44f4d323140645a83ddfd864

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

LOG: [lldb] Prevent 'process connect' from using local-only plugins

Add a 'can_connect' parameter to Process plugin initialization, and use
it to filter plugins to these capable of remote connections.  This is
used to prevent 'process connect' from picking up a plugin that can only
be used locally, e.g. the legacy FreeBSD plugin.

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

Added: 


Modified: 
lldb/include/lldb/Target/Process.h
lldb/include/lldb/Target/ProcessTrace.h
lldb/include/lldb/Target/Target.h
lldb/include/lldb/lldb-private-interfaces.h
lldb/source/API/SBTarget.cpp
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/source/Plugins/Process/minidump/ProcessMinidump.h
lldb/source/Target/Platform.cpp
lldb/source/Target/Process.cpp
lldb/source/Target/ProcessTrace.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/TraceSessionFileParser.cpp
lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
lldb/test/Shell/Commands/command-process-connect.test

Removed: 




diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 7f1e1e876556..744deab276c4 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -537,7 +537,8 @@ class Process : public 
std::enable_shared_from_this,
   static lldb::ProcessSP FindPlugin(lldb::TargetSP target_sp,
 llvm::StringRef plugin_name,
 lldb::ListenerSP listener_sp,
-const FileSpec *crash_file_path);
+const FileSpec *crash_file_path,
+bool can_connect);
 
   /// Static function that can be used with the \b host function
   /// Host::StartMonitoringChildProcess ().

diff  --git a/lldb/include/lldb/Target/ProcessTrace.h 
b/lldb/include/lldb/Target/ProcessTrace.h
index f947fbe8cdb4..53b3e704c17b 100644
--- a/lldb/include/lldb/Target/ProcessTrace.h
+++ b/lldb/include/lldb/Target/ProcessTrace.h
@@ -77,7 +77,8 @@ class ProcessTrace : public PostMortemProcess {
 private:
   static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
 lldb::ListenerSP listener_sp,
-const FileSpec *crash_file_path);
+const FileSpec *crash_file_path,
+bool can_connect);
 };
 
 } // namespace lldb_private

diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index f77917a8812f..47568c9e4429 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -573,7 +573,8 @@ class Target : public std::enable_shared_from_this,
   // used.
   const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener_sp,
llvm::StringRef plugin_name,
-   const FileSpec *crash_file);
+   const FileSpec *crash_file,
+   bool can_connect);
 
   const lldb::ProcessSP &GetProcessSP() const;
 

diff  --git a/lldb/include/lldb/lldb-private-interfaces.h 
b/lldb/include/lldb/lldb-private-interfaces.h
index 1a4eaba7cc5e..df33f8af0e14 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -76,7 +76,7 @@ typedef lldb::PlatformSP (*PlatformCreateInstance)(bool force,
const ArchSpec *arch);
 typedef l

[llvm-branch-commits] [llvm] 33b2c88 - [LoopFlatten] Widen IV, support ZExt.

2020-11-23 Thread Sjoerd Meijer via llvm-branch-commits

Author: Sjoerd Meijer
Date: 2020-11-23T08:57:19Z
New Revision: 33b2c88fa8223dbf15846ce18cc957e33e0d67fc

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

LOG: [LoopFlatten] Widen IV, support ZExt.

I disabled the widening in fa5cb4b because it run in an assert, which was
related to replacing values with different types. I forgot that an extend could
also be a zero-extend, which I have added now. This means that the approach now
is to create and insert a trunc value of the outerloop for each user, and use
that to replace IV values.

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

Added: 


Modified: 
llvm/lib/Transforms/Scalar/LoopFlatten.cpp
llvm/test/Transforms/LoopFlatten/widen-iv.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp 
b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
index 3d9617d43aea..aaff68436c13 100644
--- a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/Function.h"
+#include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PatternMatch.h"
 #include "llvm/IR/Verifier.h"
@@ -66,7 +67,7 @@ static cl::opt
 
 static cl::opt
 WidenIV("loop-flatten-widen-iv", cl::Hidden,
-cl::init(false),
+cl::init(true),
 cl::desc("Widen the loop induction variables, if possible, so "
  "overflow checks won't reject flattening"));
 
@@ -84,6 +85,9 @@ struct FlattenInfo {
   SmallPtrSet LinearIVUses;
   SmallPtrSet InnerPHIsToTransform;
 
+  // Whether this holds the flatten info before or after widening.
+  bool Widened = false;
+
   FlattenInfo(Loop *OL, Loop *IL) : OuterLoop(OL), InnerLoop(IL) {};
 };
 
@@ -335,8 +339,9 @@ static bool checkIVUsers(struct FlattenInfo &FI) {
   // transformation wouldn't be profitable.
 
   Value *InnerLimit = FI.InnerLimit;
-  if (auto *I = dyn_cast(InnerLimit))
-InnerLimit = I->getOperand(0);
+  if (FI.Widened &&
+  (isa(InnerLimit) || isa(InnerLimit)))
+InnerLimit = cast(InnerLimit)->getOperand(0);
 
   // Check that all uses of the inner loop's induction variable match the
   // expected pattern, recording the uses of the outer IV.
@@ -347,7 +352,7 @@ static bool checkIVUsers(struct FlattenInfo &FI) {
 
 // After widening the IVs, a trunc instruction might have been introduced, 
so
 // look through truncs.
-if (dyn_cast(U) ) {
+if (isa(U)) {
   if (!U->hasOneUse())
 return false;
   U = *U->user_begin();
@@ -544,20 +549,18 @@ static bool DoFlattenLoopPair(struct FlattenInfo &FI, 
DominatorTree *DT,
   BranchInst::Create(InnerExitBlock, InnerExitingBlock);
   DT->deleteEdge(InnerExitingBlock, FI.InnerLoop->getHeader());
 
-  auto HasSExtUser = [] (Value *V) -> Value * {
-for (User *U : V->users() )
-  if (dyn_cast(U))
-return U;
-return nullptr;
-  };
-
   // Replace all uses of the polynomial calculated from the two induction
   // variables with the one new one.
+  IRBuilder<> Builder(FI.OuterInductionPHI->getParent()->getTerminator());
   for (Value *V : FI.LinearIVUses) {
-// If the induction variable has been widened, look through the SExt.
-if (Value *U = HasSExtUser(V))
-  V = U;
-V->replaceAllUsesWith(FI.OuterInductionPHI);
+Value *OuterValue = FI.OuterInductionPHI;
+if (FI.Widened)
+  OuterValue = Builder.CreateTrunc(FI.OuterInductionPHI, V->getType(),
+   "flatten.trunciv");
+
+LLVM_DEBUG(dbgs() << "Replacing: "; V->dump();
+   dbgs() << "with:  "; OuterValue->dump());
+V->replaceAllUsesWith(OuterValue);
   }
 
   // Tell LoopInfo, SCEV and the pass manager that the inner loop has been
@@ -613,6 +616,8 @@ static bool CanWidenIV(struct FlattenInfo &FI, 
DominatorTree *DT,
 RecursivelyDeleteDeadPHINode(WideIVs[i].NarrowIV);
   }
   // After widening, rediscover all the loop components.
+  assert(Widened && "Widenend IV expected");
+  FI.Widened = true;
   return CanFlattenLoopPair(FI, DT, LI, SE, AC, TTI);
 }
 

diff  --git a/llvm/test/Transforms/LoopFlatten/widen-iv.ll 
b/llvm/test/Transforms/LoopFlatten/widen-iv.ll
index 579061833bf4..9ac9215a8d95 100644
--- a/llvm/test/Transforms/LoopFlatten/widen-iv.ll
+++ b/llvm/test/Transforms/LoopFlatten/widen-iv.ll
@@ -4,6 +4,9 @@
 
 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 
+; DONTWIDEN-NOT:   %flatten.tripcount
+; DONTWIDEN-NOT:   %flatten.trunciv
+
 ; Function Attrs: nounwind
 define void @foo(i32* %A, i32 %N, i32 %M) {
 ; CHECK-LABEL: @foo(
@@ -22,13 +25,14 @@ define void @foo(i32* %A, i32 %N, i32 %M) {
 ; CHECK-NEXT:[[INDVAR1:%.*]] = p

[llvm-branch-commits] [llvm] 6ef7835 - [DebugInfo] Refactor code for emitting DWARF expressions for FP constants

2020-11-23 Thread Pavel Labath via llvm-branch-commits

Author: Pavel Labath
Date: 2020-11-23T09:59:07+01:00
New Revision: 6ef7835afca246e623e9990dcd8c71204f5691e5

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

LOG: [DebugInfo] Refactor code for emitting DWARF expressions for FP constants

This patch moves the selection of the style used to emit the numbers
(DW_OP_implicit_value vs. DW_OP_const+DW_OP_stack_value) into
DwarfExpression::addUnsignedConstant. This logic is not FP-specific, and
it will be needed for large integers too.

The refactor also makes DW_OP_implicit_value (DW_OP_stack_value worked
already) be used for floating point constants other than float and
double, so I've added a _Float16 test for it.

Split off from D90916.

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

Added: 
llvm/test/DebugInfo/ARM/implicit_value-_Float16.ll

Modified: 
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h

Removed: 




diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp 
b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 5054ed81fcfc..eb20c9cfa487 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2466,24 +2466,11 @@ void DwarfDebug::emitDebugLocValue(const AsmPrinter 
&AP, const DIBasicType *BT,
 // TODO TargetIndexLocation is a target-independent. Currently only the 
WebAssembly-specific
 // encoding is supported.
 DwarfExpr.addWasmLocation(Loc.Index, static_cast(Loc.Offset));
-  DwarfExpr.addExpression(std::move(ExprCursor));
-  return;
+DwarfExpr.addExpression(std::move(ExprCursor));
+return;
   } else if (Value.isConstantFP()) {
-if (AP.getDwarfVersion() >= 4 && !AP.getDwarfDebug()->tuneForSCE()) {
-  DwarfExpr.addConstantFP(Value.getConstantFP()->getValueAPF(), AP);
-  return;
-} else if (Value.getConstantFP()
-   ->getValueAPF()
-   .bitcastToAPInt()
-   .getBitWidth() <= 64 /*bits*/)
-  DwarfExpr.addUnsignedConstant(
-  Value.getConstantFP()->getValueAPF().bitcastToAPInt());
-else
-  LLVM_DEBUG(
-  dbgs()
-  << "Skipped DwarfExpression creation for ConstantFP of size"
-  << 
Value.getConstantFP()->getValueAPF().bitcastToAPInt().getBitWidth()
-  << " bits\n");
+DwarfExpr.addConstantFP(Value.getConstantFP()->getValueAPF(), AP);
+return;
   }
   DwarfExpr.addExpression(std::move(ExprCursor));
 }

diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp 
b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
index 59ad7646ce1c..21f7ad1b7b80 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
@@ -200,10 +200,29 @@ void DwarfExpression::addUnsignedConstant(uint64_t Value) 
{
   emitConstu(Value);
 }
 
-void DwarfExpression::addUnsignedConstant(const APInt &Value) {
+void DwarfExpression::addUnsignedConstant(APInt Value, const AsmPrinter &AP) {
   assert(isImplicitLocation() || isUnknownLocation());
   LocationKind = Implicit;
 
+  if (AP.getDwarfVersion() >= 4 && !AP.getDwarfDebug()->tuneForSCE()) {
+int NumBytes = Value.getBitWidth() / 8;
+emitOp(dwarf::DW_OP_implicit_value);
+emitUnsigned(NumBytes /*Size of the block in bytes*/);
+
+// The loop below is emitting the value starting at least significant
+// byte, so we need to perform a byte-swap to get the byte order correct
+// in case of a big-endian target.
+if (AP.getDataLayout().isBigEndian())
+  Value = Value.byteSwap();
+
+for (int i = 0; i < NumBytes; ++i) {
+  emitData1(Value.getRawData()[0] & 0xFF);
+  Value = Value.lshr(8);
+}
+
+return;
+  }
+
   unsigned Size = Value.getBitWidth();
   const uint64_t *Data = Value.getRawData();
 
@@ -212,9 +231,9 @@ void DwarfExpression::addUnsignedConstant(const APInt 
&Value) {
   unsigned Offset = 0;
   while (Offset < Size) {
 addUnsignedConstant(*Data++);
+addStackValue();
 if (Offset == 0 && Size <= 64)
   break;
-addStackValue();
 addOpPiece(std::min(Size - Offset, 64u), Offset);
 Offset += 64;
   }
@@ -224,27 +243,13 @@ void DwarfExpression::addConstantFP(const APFloat &APF, 
const AsmPrinter &AP) {
   assert(isImplicitLocation() || isUnknownLocation());
   APInt API = APF.bitcastToAPInt();
   int NumBytes = API.getBitWidth() / 8;
-  if (NumBytes == 4 /*float*/ || NumBytes == 8 /*double*/) {
-// FIXME: Add support for `long double`.
-emitOp(dwarf::DW_OP_implicit_value);
-emitUnsigned(NumBytes /*Size of the block in bytes*/);
-
-// The loop below is emitting the value starting at least significant byte,
-// so we need to perform a byte-swap to get the byt

[llvm-branch-commits] [clang-tools-extra] fee78fb - [clangd] Second attempt at fixing windows buildbots

2020-11-23 Thread Kadir Cetinkaya via llvm-branch-commits

Author: Kadir Cetinkaya
Date: 2020-11-23T10:06:48+01:00
New Revision: fee78fb0049ae2556c99768a06421d7cdbb9d016

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

LOG: [clangd] Second attempt at fixing windows buildbots

Added: 


Modified: 
clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp 
b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
index 2b4605eb97e2..a2423094b17a 100644
--- a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -255,6 +255,7 @@ TEST_F(ConfigCompileTests, ExternalBlockMountPoint) {
   };
 
   auto BarPath = testPath("foo/bar.h", llvm::sys::path::Style::posix);
+  BarPath = llvm::sys::path::convert_to_slash(BarPath);
   Parm.Path = BarPath;
   // Non-absolute MountPoint without a directory raises an error.
   Frag = GetFrag("", "foo");
@@ -268,6 +269,7 @@ TEST_F(ConfigCompileTests, ExternalBlockMountPoint) {
   ASSERT_FALSE(Conf.Index.External);
 
   auto FooPath = testPath("foo/", llvm::sys::path::Style::posix);
+  FooPath = llvm::sys::path::convert_to_slash(FooPath);
   // Ok when relative.
   Frag = GetFrag(testRoot(), "foo/");
   compileAndApply();
@@ -291,6 +293,7 @@ TEST_F(ConfigCompileTests, ExternalBlockMountPoint) {
 
   // File outside MountPoint, no index.
   auto BazPath = testPath("bar/baz.h", llvm::sys::path::Style::posix);
+  BazPath = llvm::sys::path::convert_to_slash(BazPath);
   Parm.Path = BazPath;
   Frag = GetFrag("", FooPath.c_str());
   compileAndApply();
@@ -299,6 +302,7 @@ TEST_F(ConfigCompileTests, ExternalBlockMountPoint) {
 
   // File under MountPoint, index should be set.
   BazPath = testPath("foo/baz.h", llvm::sys::path::Style::posix);
+  BazPath = llvm::sys::path::convert_to_slash(BazPath);
   Parm.Path = BazPath;
   Frag = GetFrag("", FooPath.c_str());
   compileAndApply();



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


[llvm-branch-commits] [llvm] 4dcdf0d - [llvm-readobj] - Stop using `unwrapOrError` in `DumpStyle::getGroups()`

2020-11-23 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2020-11-23T12:48:33+03:00
New Revision: 4dcdf0df31259c1c02a1f7bbaa7ae45ca6c814dc

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

LOG: [llvm-readobj] - Stop using `unwrapOrError` in 
`DumpStyle::getGroups()`

With this we are able to diagnose possible issues much better and
don't exit on an error.

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

Added: 


Modified: 
llvm/test/tools/llvm-readobj/ELF/groups.test
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/llvm/test/tools/llvm-readobj/ELF/groups.test 
b/llvm/test/tools/llvm-readobj/ELF/groups.test
index a5f4338729d0..00696470e078 100644
--- a/llvm/test/tools/llvm-readobj/ELF/groups.test
+++ b/llvm/test/tools/llvm-readobj/ELF/groups.test
@@ -48,28 +48,32 @@ FileHeader:
 Sections:
   - Name: .group
 Type: SHT_GROUP
-Link: .symtab
+Link: [[SYMTAB1=.symtab]]
 Info: foo
 Members:
   - SectionOrType: GRP_COMDAT
   - SectionOrType: .text.foo
-  - SectionOrType: .rela.text.foo
+  - SectionOrType: [[MEMBER1=.rela.text.foo]]
+ShSize: [[SECSIZE1=]]
+ShName: [[GROUP1SHNAME=]]
   - Name: .group1
 Type: SHT_GROUP
-Link: .symtab
+Link: [[SYMTAB2=.symtab]]
 Info: bar
 Members:
   - SectionOrType: GRP_COMDAT
-  - SectionOrType: [[TEXTBARNAME=.text.bar]]
+  - SectionOrType: [[MEMBER2=.text.bar]]
   - SectionOrType: .rela.text.bar
+ShSize: [[SECSIZE2=]]
   - Name:  .text.foo
 Type:  SHT_PROGBITS
   - Name: .rela.text.foo
 Type: SHT_RELA
 Link: .symtab
 Info: .text.foo
-  - Name: .text.bar
-Type: SHT_PROGBITS
+  - Name:   .text.bar
+Type:   SHT_PROGBITS
+ShName: [[TEXTBARSHNAME=]]
   - Name: .rela.text.bar
 Type: SHT_RELA
 Link: .symtab
@@ -86,7 +90,7 @@ Symbols:
 ## Check that we report a warning and continue dumping when a section is 
included
 ## in two group sections at the same time.
 
-# RUN: yaml2obj %s -DTEXTBARNAME=.text.foo -o %t.dup.o
+# RUN: yaml2obj %s -DMEMBER2=.text.foo -o %t.dup.o
 # RUN: llvm-readobj --elf-section-groups %t.dup.o 2>&1 | FileCheck %s 
-DFILE=%t.dup.o --check-prefix=DUP-LLVM
 # RUN: llvm-readelf --elf-section-groups %t.dup.o 2>&1 | FileCheck %s 
-DFILE=%t.dup.o --check-prefix=DUP-GNU
 
@@ -127,6 +131,11 @@ Symbols:
 # DUP-GNU-NEXT:[3]   .text.foo
 # DUP-GNU-NEXT:[6]   .rela.text.bar
 
+## Check what we do when we are unable to dump the signature symbol name.
+## In this case the index of the string table section, linked to the symbol 
table used by a group section,
+## is broken (section does not exist).
+## Check we report a warning in this case. Check we don't print the same 
warning message twice.
+
 # RUN: yaml2obj %s -DSYMTABLINK=0xFF -o %t.symtab.o
 # RUN: llvm-readobj --elf-section-groups %t.symtab.o 2>&1 | \
 # RUN:   FileCheck -DFILE=%t.symtab.o %s --check-prefix=SYMTAB-LLVM 
--implicit-check-not=warning:
@@ -172,3 +181,201 @@ Symbols:
 # SYMTAB-GNU-NEXT:  [Index]Name
 # SYMTAB-GNU-NEXT:  [5]   .text.bar
 # SYMTAB-GNU-NEXT:  [6]   .rela.text.bar
+
+## This tests the behavior for two more cases when we are unable to dump the 
signature symbol name.
+## In the first case we link the group section to the section with index 255, 
which does not exist.
+## We check that a warning is reported when we are unable to locate the symbol 
table.
+## In the second case we link the SHT_GROUP section to itself. This documents 
that we don't check the
+## type of the linked section (we assume it is the symbol table) and checks 
that we report a warning
+## when we are unable to read a signature symbol.
+
+# RUN: yaml2obj %s -DSYMTAB1=0xFF -DSYMTAB2=0x1 -o %t.symtab2.o
+# RUN: llvm-readobj --elf-section-groups %t.symtab2.o 2>&1 | \
+# RUN:   FileCheck -DFILE=%t.symtab2.o %s --check-prefix=SIGNATURE-LLVM 
--implicit-check-not=warning:
+# RUN: llvm-readelf --elf-section-groups %t.symtab2.o 2>&1 | \
+# RUN:   FileCheck -DFILE=%t.symtab2.o %s --check-prefix=SIGNATURE-GNU 
--implicit-check-not=warning:
+
+# SIGNATURE:  Groups {
+# SIGNATURE-LLVM: warning: '[[FILE]]': unable to get the symbol table for 
SHT_GROUP section with index 1: invalid section index: 255
+# SIGNATURE-LLVM: warning: '[[FILE]]': unable to get the signature symbol for 
SHT_GROUP section with index 2: section [index 1] has invalid sh_entsize: 
expected 24, but got 4
+# SIGNATURE-LLVM:   Group {
+# SIGNATURE-LLVM: Name: .group (16)
+# SIGNATURE-LLVM: Index: 1
+# SIGNATURE-LLVM: Link: 255
+# SIGNATURE-LLVM: Info: 1
+# SIGNATURE-LLVM: Type: COMDAT (0x1)
+# SIGNATURE-LLVM: Signature: 
+# SIGNATURE-LLVM: Section(s) in group [
+# SIGNATURE-LLVM:   .text.foo (3)
+# SIGNATURE-LLVM:   .rela.text.foo (4)
+# SIGNAT

[llvm-branch-commits] [llvm] 48d7cc6 - [SCEV] Fix incorrect treatment of max taken count. PR48225

2020-11-23 Thread Max Kazantsev via llvm-branch-commits

Author: Max Kazantsev
Date: 2020-11-23T16:52:39+07:00
New Revision: 48d7cc6ae23b0e5b1922457462d0f6e4582a1ae7

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

LOG: [SCEV] Fix incorrect treatment of max taken count. PR48225

SCEV makes a logical mistake when handling EitherMayExit in
case when both conditions must be met to exit the loop. The
mistake looks like follows: "if condition `A` fails within at most `X` first
iterations, and `B` fails within at most `Y` first iterations, then `A & B`
fails at most within `min (X, Y)` first iterations". This is wrong, because
both of them must fail at the same time.

Simple example illustrating this is following: we have an IV with step 1,
condition `A` = "IV is even", condition `B` = "IV is odd". Both `A` and `B`
will fail within first two iterations. But it doesn't mean that both of them
will fail within first two first iterations at the same time, which would mean
that IV is neither even nor odd at the same time within first 2 iterations.

We can only do so for known exact BE counts, but not for max.

Differential Revision: https://reviews.llvm.org/D91942
Reviewed By: nikic

Added: 


Modified: 
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/ScalarEvolution/pr48225.ll

Removed: 




diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp 
b/llvm/lib/Analysis/ScalarEvolution.cpp
index 496b0da8853a..a366ad355233 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -7611,8 +7611,6 @@ ScalarEvolution::computeExitLimitFromCondFromBinOpHelper(
   } else {
 // Both conditions must be same at the same time for the loop to exit.
 // For now, be conservative.
-if (EL0.MaxNotTaken == EL1.MaxNotTaken)
-  MaxBECount = EL0.MaxNotTaken;
 if (EL0.ExactNotTaken == EL1.ExactNotTaken)
   BECount = EL0.ExactNotTaken;
   }

diff  --git a/llvm/test/Analysis/ScalarEvolution/pr48225.ll 
b/llvm/test/Analysis/ScalarEvolution/pr48225.ll
index bd7dac26ebd3..eaf9b18d7c5a 100644
--- a/llvm/test/Analysis/ScalarEvolution/pr48225.ll
+++ b/llvm/test/Analysis/ScalarEvolution/pr48225.ll
@@ -4,7 +4,6 @@
 
 ; Tests demonstrate the bug reported as PR48225 by Congzhe Cao.
 
-; FIXME: This test demonstrates a bug in max backedge taken count computation.
 ; When %boolcond = false and %cond = 0:
 ; - %cond.false.on.first.iter is false on 1st iteration;
 ; - %cond.false.on.second.iter is false on 2nd iteration;
@@ -17,16 +16,16 @@ define void @test_and(i1 %boolcond) {
 ; CHECK-NEXT:%conv = zext i1 %boolcond to i32
 ; CHECK-NEXT:--> (zext i1 %boolcond to i32) U: [0,2) S: [0,2)
 ; CHECK-NEXT:%iv = phi i32 [ 0, %entry ], [ %inc, %backedge ]
-; CHECK-NEXT:--> {0,+,1}<%loop> U: [0,2) S: [0,2) Exits: 
<> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:--> {0,+,1}<%loop> U: [0,3) S: [0,3) Exits: 
<> LoopDispositions: { %loop: Computable }
 ; CHECK-NEXT:%or.cond = and i1 %cond.false.on.first.iter, 
%cond.false.on.second.iter
 ; CHECK-NEXT:--> %or.cond U: full-set S: full-set Exits: <> 
LoopDispositions: { %loop: Variant }
 ; CHECK-NEXT:%inc = add nuw nsw i32 %iv, 1
-; CHECK-NEXT:--> {1,+,1}<%loop> U: [1,3) S: [1,3) Exits: 
<> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:--> {1,+,1}<%loop> U: [1,4) S: [1,4) Exits: 
<> LoopDispositions: { %loop: Computable }
 ; CHECK-NEXT:  Determining loop execution counts for: @test_and
 ; CHECK-NEXT:  Loop %loop:  Unpredictable backedge-taken count.
 ; CHECK-NEXT:exit count for loop: 2
 ; CHECK-NEXT:exit count for backedge: ***COULDNOTCOMPUTE***
-; CHECK-NEXT:  Loop %loop: max backedge-taken count is 1
+; CHECK-NEXT:  Loop %loop: max backedge-taken count is 2
 ; CHECK-NEXT:  Loop %loop: Unpredictable predicated backedge-taken count.
 ;
 entry:
@@ -52,7 +51,6 @@ for.end:
   ret void
 }
 
-; FIXME: This test demonstrates a bug in max backedge taken count computation.
 ; When %boolcond = false and %cond = 0:
 ; - %cond.true.on.first.iter is true on 1st iteration;
 ; - %cond.true.on.second.iter is true on 2nd iteration;
@@ -65,16 +63,16 @@ define void @test_or(i1 %boolcond) {
 ; CHECK-NEXT:%conv = zext i1 %boolcond to i32
 ; CHECK-NEXT:--> (zext i1 %boolcond to i32) U: [0,2) S: [0,2)
 ; CHECK-NEXT:%iv = phi i32 [ 0, %entry ], [ %inc, %backedge ]
-; CHECK-NEXT:--> {0,+,1}<%loop> U: [0,2) S: [0,2) Exits: 
<> LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:--> {0,+,1}<%loop> U: [0,3) S: [0,3) Exits: 
<> LoopDispositions: { %loop: Computable }
 ; CHECK-NEXT:%or.cond = or i1 %cond.true.on.first.iter, 
%cond.true.on.second.iter
 ; CHECK-NEXT:--> %or.cond U: full-set S: full-set Exits: <> 
LoopDispositions: { %loop: Variant }
 ; CHECK-NEXT:%inc = add nuw nsw i32 %iv, 1
-; CHECK-NEXT:  

[llvm-branch-commits] [llvm] 76a626b - [llvm-readelf/obj] - Fix the possible crash when dumping group sections.

2020-11-23 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2020-11-23T13:05:12+03:00
New Revision: 76a626b2061bc8a33656a49ebcabbfa75c317d4c

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

LOG: [llvm-readelf/obj] - Fix the possible crash when dumping group sections.

It is possible to trigger a crash/misbehavior when the st_name field of
the signature symbol goes past the end of the string table.

This patch fixes it.

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

Added: 


Modified: 
llvm/test/tools/llvm-readobj/ELF/groups.test
llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 




diff  --git a/llvm/test/tools/llvm-readobj/ELF/groups.test 
b/llvm/test/tools/llvm-readobj/ELF/groups.test
index 00696470e078..afdc63e9dc0b 100644
--- a/llvm/test/tools/llvm-readobj/ELF/groups.test
+++ b/llvm/test/tools/llvm-readobj/ELF/groups.test
@@ -81,11 +81,16 @@ Sections:
   - Name: .symtab
 Type: SHT_SYMTAB
 Link: [[SYMTABLINK=.strtab]]
+  - Name:.strtab
+Type:SHT_STRTAB
+Content: [[STRTABCONTENT=]]
 Symbols:
   - Name:foo
 Section: .text.foo
+StName:  [[SYM1STNAME=]]
   - Name:bar
 Section: .text.bar
+StName:  [[SYM2STNAME=]]
 
 ## Check that we report a warning and continue dumping when a section is 
included
 ## in two group sections at the same time.
@@ -379,3 +384,37 @@ Symbols:
 # MEMBER-GNU-NEXT: [Index]Name
 # MEMBER-GNU-NEXT: [  255]   
 # MEMBER-GNU-NEXT: [6]   .rela.text.bar
+
+## Check warnings that are reported when the st_name field of the signature 
symbol goes past the end of the string table.
+
+## We set the content of the string table to '0061626300' ('\0abc\0') to fixup 
the size of the string table.
+## This makes it easier to test the boundary conditions.
+# RUN: yaml2obj %s -DSTRTABCONTENT="0061626300" -DSYM1STNAME=4 -DSYM2STNAME=5 
-o %t.signame.o
+# RUN: llvm-readobj --elf-section-groups %t.signame.o 2>&1 | \
+# RUN:   FileCheck -DFILE=%t.signame.o %s 
--check-prefixes=SIGNAME1-WARN,SIGNAME1-LLVM --implicit-check-not=warning:
+# RUN: llvm-readelf --elf-section-groups %t.signame.o 2>&1 | \
+# RUN:   FileCheck -DFILE=%t.signame.o %s 
--check-prefixes=SIGNAME1-WARN,SIGNAME1-GNU --implicit-check-not=warning:
+
+# SIGNAME1-WARN: warning: '[[FILE]]': unable to get the name of the symbol 
with index 2: st_name (0x5) is past the end of the string table of size 0x5
+
+# SIGNAME1-LLVM: Signature: {{$}}
+# SIGNAME1-LLVM: Signature: 
+
+# SIGNAME1-GNU: COMDAT group section [1] `.group' [] contains 2 sections:
+# SIGNAME1-GNU: COMDAT group section [2] `.group1' [] contains 2 
sections:
+
+## Chech we report a warning when the string table that contains the signature 
symbol name is not null-terminated.
+
+# RUN: yaml2obj %s -DSTRTABCONTENT="0061626361" -DSYM1STNAME=4 -DSYM2STNAME=5 
-o %t.signame2.o
+# RUN: llvm-readobj --elf-section-groups %t.signame2.o 2>&1 | \
+# RUN:   FileCheck -DFILE=%t.signame2.o %s 
--check-prefixes=SIGNAME2-WARN,SIGNAME2-LLVM --implicit-check-not=warning:
+# RUN: llvm-readelf --elf-section-groups %t.signame2.o 2>&1 | \
+# RUN:   FileCheck -DFILE=%t.signame2.o %s 
--check-prefixes=SIGNAME2-WARN,SIGNAME2-GNU --implicit-check-not=warning:
+
+# SIGNAME2-WARN: warning: '[[FILE]]': unable to get the string table for 
SHT_SYMTAB section with index 7: SHT_STRTAB string table section [index 8] is 
non-null terminated
+
+# SIGNAME2-LLVM: Signature: 
+# SIGNAME2-LLVM: Signature: 
+
+# SIGNAME2-GNU: COMDAT group section [1] `.group' [] contains 2 
sections:
+# SIGNAME2-GNU: COMDAT group section [2] `.group1' [] contains 2 
sections:

diff  --git a/llvm/tools/llvm-readobj/ELFDumper.cpp 
b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 3e54c3599428..c5eb2d628b0b 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -3595,7 +3595,7 @@ static StringRef tryGetSectionName(const ELFFile 
&Obj,
 }
 
 template  std::vector DumpStyle::getGroups() {
-  auto GetSignature = [&](const Elf_Sym &Sym,
+  auto GetSignature = [&](const Elf_Sym &Sym, unsigned SymNdx,
   const Elf_Shdr &Symtab) -> StringRef {
 Expected StrTableOrErr = Obj.getStringTableForSymtab(Symtab);
 if (!StrTableOrErr) {
@@ -3605,8 +3605,16 @@ template  std::vector 
DumpStyle::getGroups() {
   return "";
 }
 
-// TODO: this might lead to a crash or produce a wrong result, when the
-// st_name goes past the end of the string table.
+StringRef Strings = *StrTableOrErr;
+if (Sym.st_name >= Strings.size()) {
+  reportUniqueWarning(createError(
+  "unable to get the name of the symbol with index " + Twine(SymNdx) +
+  ": st_name (0x" + Twine::utohexstr(Sym.st_name) +
+  ") is past the end of the string table of size 0x" +
+ 

[llvm-branch-commits] [mlir] 01c4418 - [mlir][Linalg] NFC - Factor out Linalg functionality for shape and loop bounds computation

2020-11-23 Thread Nicolas Vasilache via llvm-branch-commits

Author: Nicolas Vasilache
Date: 2020-11-23T10:17:18Z
New Revision: 01c4418544b7934f8216a6616562bbaf34dc6979

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

LOG: [mlir][Linalg] NFC - Factor out Linalg functionality for shape and loop 
bounds computation

This revision refactors code used in various Linalg transformations and makes 
it a first class citizen to the LinalgStructureOpInterface. This is in 
preparation to allowing more advanced Linalg behavior but is otherwise NFC.

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

Added: 


Modified: 
mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp
mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
mlir/lib/Dialect/Linalg/Utils/Utils.cpp
mlir/test/Dialect/Linalg/invalid.mlir

Removed: 




diff  --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h 
b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h
index 713fb192f073..f8002279132f 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.h
@@ -11,12 +11,13 @@
 
 #include "mlir/Dialect/Linalg/IR/LinalgTraits.h"
 #include "mlir/Dialect/Linalg/IR/LinalgTypes.h"
+#include "mlir/Dialect/StandardOps/IR/Ops.h"
 #include "mlir/Dialect/Utils/StructuredOpsUtils.h"
 #include "mlir/IR/AffineExpr.h"
 #include "mlir/IR/AffineMap.h"
 #include "mlir/IR/BlockAndValueMapping.h"
 #include "mlir/IR/Builders.h"
-#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/BuiltinDialect.h"
 #include "mlir/IR/OpDefinition.h"
 #include "mlir/IR/StandardTypes.h"
 #include "mlir/IR/TypeUtilities.h"
@@ -32,10 +33,29 @@ namespace mlir {
 namespace linalg {
 
 class ConvOp;
+class LinalgOp;
 class PoolingMaxOp;
 class PoolingMinOp;
 class PoolingSumOp;
 
+// TOFO: allow an extra ValueRange to specify an indexing and allow
+// non-hyperrectangular shapes.
+using LoopRangeBuilder =
+std::function(OpBuilder &, Location)>;
+
+/// Returns the values obtained by applying `map` to the list of values.
+SmallVector applyMapToValues(OpBuilder &b, Location loc,
+   AffineMap map, ValueRange values);
+
+/// Provide a very simple inference procedure to build the loop ranges from the
+/// op and its operands. This only works with permutation affine maps and
+/// patterns of the form `(m, n)[s] -> (m + n - s floordiv 2)`.
+/// A more advanced Tensor-Comprehension like inference is possible but has
+/// proven to be ambiguous in unfavorable case.
+/// As a consequence, we relax the default behavior very conservatively and
+/// provide an op-specified hook so that Linalg ops may override the behavior.
+LoopRangeBuilder defaultLoopRangesBuilder(LinalgOp op);
+
 using ReassociationIndices = SmallVector;
 using ReassociationExprs = SmallVector;
 

diff  --git 
a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td 
b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
index 0373bf3f6adf..6c7da083d7af 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
@@ -765,6 +765,59 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
   }]
 >,
 
+
//===--===//
+// Linalg generalization hooks.
+
//===--===//
+InterfaceMethod<
+  /*desc=*/[{
+Hook to provide a custom AffineMap used to compute all the operand
+subshapes given loop bounds. This is used to answer the question: 
"given
+an iteration space over the codomain, what are the subshapes of the
+operands involved in the computation".
+The default behavior is to just concatenate all the indexing maps.
+A custom AffineMap allows providing a map that can be used to
+compute subshapes even in cases where the concatenation of indexing 
maps
+(i.e. the data traversal order) is not a simple permutation of the loop
+traversal order. It is then possible to define ops with skewed data
+traversal order for which we can still easily compute hyperrectangular
+loop bounds and subviews.
+  }],
+  /*retTy=*/"AffineMap",
+  /*methodName=*/"getLoopsToShapesMap",
+  /*args=*/(ins),
+  /*methodBody=*/"",
+  /*defaultImplementation=*/[{
+auto r = $_op.indexing_maps().template

[llvm-branch-commits] [clang] b1444ed - [AST] Build recovery expression by default for all language.

2020-11-23 Thread Haojian Wu via llvm-branch-commits

Author: Haojian Wu
Date: 2020-11-23T11:08:28+01:00
New Revision: b1444edbf41c1fe9f7e676df6e873e9c9318283e

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

LOG: [AST] Build recovery expression by default for all language.

The dependency mechanism for C has been implemented, and we have rolled out
this to all internal users, didn't see crashy issues, we consider it is stable
enough.

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

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/Basic/LangOptions.def
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/SystemZ/builtins-systemz-zvector-error.c
clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-error.c
clang/test/CodeGen/SystemZ/builtins-systemz-zvector3-error.c
clang/test/CodeGen/builtins-ppc-error.c
clang/test/Index/complete-switch.c
clang/test/OpenMP/begin_declare_variant_messages.c
clang/test/OpenMP/declare_variant_messages.c
clang/test/Parser/objc-foreach-syntax.m
clang/test/Sema/__try.c
clang/test/Sema/enum.c
clang/test/Sema/typo-correction.c

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 11b05ce7a5f5e..3ea2817f1926c 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -6330,9 +6330,6 @@ class TypoExpr : public Expr {
 ///
 /// One can also reliably suppress all bogus errors on expressions containing
 /// recovery expressions by examining results of Expr::containsErrors().
-///
-/// FIXME: RecoveryExpr is currently generated by default in C++ mode only, as
-/// dependence isn't handled properly on several C-only codepaths.
 class RecoveryExpr final : public Expr,
private llvm::TrailingObjects 
{
 public:

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 9c573b43049c7..e4113789f07ce 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -148,8 +148,8 @@ LANGOPT(RelaxedTemplateTemplateArgs, 1, 0, "C++17 relaxed 
matching of template t
 
 LANGOPT(DoubleSquareBracketAttributes, 1, 0, "'[[]]' attributes extension for 
all language standard modes")
 
-COMPATIBLE_LANGOPT(RecoveryAST, 1, 0, "Preserve expressions in AST when 
encountering errors")
-COMPATIBLE_LANGOPT(RecoveryASTType, 1, 0, "Preserve the type in recovery 
expressions")
+COMPATIBLE_LANGOPT(RecoveryAST, 1, 1, "Preserve expressions in AST when 
encountering errors")
+COMPATIBLE_LANGOPT(RecoveryASTType, 1, 1, "Preserve the type in recovery 
expressions")
 
 BENIGN_LANGOPT(ThreadsafeStatics , 1, 1, "thread-safe static initializers")
 LANGOPT(POSIXThreads  , 1, 0, "POSIX thread support")

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index f6753b5b91a03..35025a9829ef8 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3020,11 +3020,9 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
   !Args.hasArg(OPT_fno_concept_satisfaction_caching);
   if (Args.hasArg(OPT_fconcepts_ts))
 Diags.Report(diag::warn_fe_concepts_ts_flag);
-  // Recovery AST still heavily relies on dependent-type machinery.
-  Opts.RecoveryAST =
-  Args.hasFlag(OPT_frecovery_ast, OPT_fno_recovery_ast, Opts.CPlusPlus);
-  Opts.RecoveryASTType = Args.hasFlag(
-  OPT_frecovery_ast_type, OPT_fno_recovery_ast_type, Opts.CPlusPlus);
+  Opts.RecoveryAST = Args.hasFlag(OPT_frecovery_ast, OPT_fno_recovery_ast);
+  Opts.RecoveryASTType =
+  Args.hasFlag(OPT_frecovery_ast_type, OPT_fno_recovery_ast_type);
   Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
   Opts.AccessControl = !Args.hasArg(OPT_fno_access_control);
   Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);

diff  --git a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector-error.c 
b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector-error.c
index 5fdcb4061850f..77e90b5ad4b84 100644
--- a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector-error.c
+++ b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector-error.c
@@ -67,7 +67,7 @@ void test_core(void) {
   len = __lcbb(cptr, 8192);  // expected-error {{no matching function}}
  // expected-note@vecintrin.h:* {{must be a 
constant power of 2 from 64 to 4096}}
 
-  vsl = vec_permi(vsl, vsl, idx); // expected-error {{no matching function}}
+  vsl = vec_permi(vsl, vsl, idx); // expected-error {{no matching function}} 
expected-error {{argument to '__builtin_s390_vpdi' must be a constant integer}}
   // expected-note@vecintrin.h:* 3 {{candidate 
function

[llvm-branch-commits] [clang-tools-extra] cf39bdb - [clangd] Implement Decl canonicalization rules for rename

2020-11-23 Thread Kirill Bobyrev via llvm-branch-commits

Author: Kirill Bobyrev
Date: 2020-11-23T11:42:56+01:00
New Revision: cf39bdb49086350e7178a0a058273907d180e809

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

LOG: [clangd] Implement Decl canonicalization rules for rename

This patch introduces new canonicalization rules which are used for AST-based
rename in Clangd. By comparing two canonical declarations of inspected nodes,
Clangd determines whether both of them belong to the same entity user would
like to rename. Such functionality is relatively concise compared to the
Clang-Rename API that is used right now. It also helps to overcome the
limitations that Clang-Rename originally had and helps to eliminate several
classes of bugs.

Clangd AST-based rename currently relies on Clang-Rename which has design
limitations and also lacks some features. This patch breaks this dependency and
significantly reduces the amount of code to maintain (Clang-Rename is ~2000 LOC,
this patch is just <30 LOC of replacement code).

We eliminate technical debt by simultaneously

* Maintaining feature parity and ensuring no regressions
* Opening a straightforward path to improving existing rename bugs
* Making it possible to add more capabilities to rename feature which would not
  be possible with Clang-Rename

Reviewed By: hokein

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 33a9c845beaa..d10a7a4574ba 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -18,7 +18,6 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Tooling/Refactoring/Rename/USRFindingAction.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
@@ -76,6 +75,58 @@ llvm::Optional getOtherRefFile(const Decl &D, 
StringRef MainFile,
   return OtherFile;
 }
 
+// Canonical declarations help simplify the process of renaming. Examples:
+// - Template's canonical decl is the templated declaration (i.e.
+//   ClassTemplateDecl is canonicalized to its child CXXRecordDecl,
+//   FunctionTemplateDecl - to child FunctionDecl)
+// - Given a constructor/destructor, canonical declaration is the parent
+//   CXXRecordDecl because we want to rename both type name and its ctor/dtor.
+// - All specializations are canonicalized to the primary template. For 
example:
+//
+//template 
+//bool Foo = true; (1)
+//
+//template 
+//bool Foo = true; (2)
+//
+//template <>
+//bool Foo = true; (3)
+//
+// Here, both partial (2) and full (3) specializations are canonicalized to (1)
+// which ensures all three of them are renamed.
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D) {
+  if (const auto *VarTemplate = dyn_cast(D))
+return canonicalRenameDecl(
+VarTemplate->getSpecializedTemplate()->getTemplatedDecl());
+  if (const auto *Template = dyn_cast(D))
+if (const NamedDecl *TemplatedDecl = Template->getTemplatedDecl())
+  return canonicalRenameDecl(TemplatedDecl);
+  if (const auto *ClassTemplateSpecialization =
+  dyn_cast(D))
+return canonicalRenameDecl(
+ClassTemplateSpecialization->getSpecializedTemplate()
+->getTemplatedDecl());
+  if (const auto *Method = dyn_cast(D)) {
+if (Method->getDeclKind() == Decl::Kind::CXXConstructor ||
+Method->getDeclKind() == Decl::Kind::CXXDestructor)
+  return canonicalRenameDecl(Method->getParent());
+if (const FunctionDecl *InstantiatedMethod =
+Method->getInstantiatedFromMemberFunction())
+  Method = cast(InstantiatedMethod);
+// FIXME(kirillbobyrev): For virtual methods with
+// size_overridden_methods() > 1, this will not rename all functions it
+// overrides, because this code assumes there is a single canonical
+// declaration.
+while (Method->isVirtual() && Method->size_overridden_methods())
+  Method = *Method->overridden_methods().begin();
+return dyn_cast(Method->getCanonicalDecl());
+  }
+  if (const auto *Function = dyn_cast(D))
+if (const FunctionTemplateDecl *Template = Function->getPrimaryTemplate())
+  return canonicalRenameDecl(Template);
+  return dyn_cast(D->getCanonicalDecl());
+}
+
 llvm::DenseSet locateDeclAt(ParsedAST &AST,
SourceLocation TokenStartLoc) {
   unsigned Offset =
@@ -91,9 +142,7 @@ llvm::DenseSet locateDeclAt(ParsedAST 
&AST,
   for (const NamedDecl *D :
targetDecl(SelectedNode->ASTNode,
   DeclRelation::Alias | DeclRelat

[llvm-branch-commits] [clang] 3c696a2 - [AArch64][SVE] Allow lax conversion between VLATs and GNU vectors

2020-11-23 Thread Joe Ellis via llvm-branch-commits

Author: Joe Ellis
Date: 2020-11-23T10:47:17Z
New Revision: 3c696a212ba4328e4f8f92136bc4d728a6490ef7

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

LOG: [AArch64][SVE] Allow lax conversion between VLATs and GNU vectors

Previously, lax conversions were only allowed between SVE vector-length
agnostic types and vector-length specific types. This meant that code
such as the following:

#include 
#define N __ARM_FEATURE_SVE_BITS
#define FIXED_ATTR __attribute__ ((vector_size (N/8)))
typedef float fixed_float32_t FIXED_ATTR;

void foo() {
fixed_float32_t fs32;
svfloat64_t s64;
fs32 = s64;
}

was not allowed.

This patch makes a minor change to areLaxCompatibleSveTypes to allow for
lax conversions to be performed between SVE vector-length agnostic types
and GNU vectors.

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

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/test/Sema/aarch64-sve-lax-vector-conversions.c
clang/test/Sema/attr-arm-sve-vector-bits.c
clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index f54916babed7..67ee8c0956d6 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -8586,10 +8586,20 @@ bool ASTContext::areLaxCompatibleSveTypes(QualType 
FirstType,
 
 const auto *VecTy = SecondType->getAs();
 if (VecTy &&
-VecTy->getVectorKind() == VectorType::SveFixedLengthDataVector) {
+(VecTy->getVectorKind() == VectorType::SveFixedLengthDataVector ||
+ VecTy->getVectorKind() == VectorType::GenericVector)) {
   const LangOptions::LaxVectorConversionKind LVCKind =
   getLangOpts().getLaxVectorConversions();
 
+  // If __ARM_FEATURE_SVE_BITS != N do not allow GNU vector lax conversion.
+  // "Whenever __ARM_FEATURE_SVE_BITS==N, GNUT implicitly
+  // converts to VLAT and VLAT implicitly converts to GNUT."
+  // ACLE Spec Version 00bet6, 3.7.3.2. Behavior common to vectors and
+  // predicates.
+  if (VecTy->getVectorKind() == VectorType::GenericVector &&
+  getTypeSize(SecondType) != getLangOpts().ArmSveVectorBits)
+return false;
+
   // If -flax-vector-conversions=all is specified, the types are
   // certainly compatible.
   if (LVCKind == LangOptions::LaxVectorConversionKind::All)

diff  --git a/clang/test/Sema/aarch64-sve-lax-vector-conversions.c 
b/clang/test/Sema/aarch64-sve-lax-vector-conversions.c
index e2fe87f7dd20..1a1addcf1c1b 100644
--- a/clang/test/Sema/aarch64-sve-lax-vector-conversions.c
+++ b/clang/test/Sema/aarch64-sve-lax-vector-conversions.c
@@ -7,32 +7,61 @@
 #include 
 
 #define N __ARM_FEATURE_SVE_BITS
-#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+#define SVE_FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+#define GNU_FIXED_ATTR __attribute__((vector_size(N / 8)))
 
-typedef svfloat32_t fixed_float32_t FIXED_ATTR;
-typedef svint32_t fixed_int32_t FIXED_ATTR;
+typedef svfloat32_t sve_fixed_float32_t SVE_FIXED_ATTR;
+typedef svint32_t sve_fixed_int32_t SVE_FIXED_ATTR;
+typedef float gnu_fixed_float32_t GNU_FIXED_ATTR;
+typedef int gnu_fixed_int32_t GNU_FIXED_ATTR;
 
-void allowed_with_integer_lax_conversions() {
-  fixed_int32_t fi32;
+void sve_allowed_with_integer_lax_conversions() {
+  sve_fixed_int32_t fi32;
   svint64_t si64;
 
   // The implicit cast here should fail if -flax-vector-conversions=none, but 
pass if
   // -flax-vector-conversions={integer,all}.
   fi32 = si64;
-  // lax-vector-none-error@-1 {{assigning to 'fixed_int32_t' (vector of 16 
'int' values) from incompatible type}}
+  // lax-vector-none-error@-1 {{assigning to 'sve_fixed_int32_t' (vector of 16 
'int' values) from incompatible type}}
   si64 = fi32;
   // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') 
from incompatible type}}
 }
 
-void allowed_with_all_lax_conversions() {
-  fixed_float32_t ff32;
+void sve_allowed_with_all_lax_conversions() {
+  sve_fixed_float32_t ff32;
   svfloat64_t sf64;
 
   // The implicit cast here should fail if 
-flax-vector-conversions={none,integer}, but pass if
   // -flax-vector-conversions=all.
   ff32 = sf64;
-  // lax-vector-none-error@-1 {{assigning to 'fixed_float32_t' (vector of 16 
'float' values) from incompatible type}}
-  // lax-vector-integer-error@-2 {{assigning to 'fixed_float32_t' (vector of 
16 'float' values) from incompatible type}}
+  // lax-vector-none-error@-1 {{assigning to 'sve_fixed_float32_t' (vector of 
16 'float' values) from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'sve_fixed_float32_t' (vector 
of 16 'float' values) from incompatible type}}
+  sf64 = ff32;
+  //

[llvm-branch-commits] [clang-tools-extra] 1319c66 - [clangd] Get rid of clangToolingRefactoring dependency

2020-11-23 Thread Kirill Bobyrev via llvm-branch-commits

Author: Kirill Bobyrev
Date: 2020-11-23T11:59:38+01:00
New Revision: 1319c6624ed6b0a6fb48d975bbf278263a85fcef

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

LOG: [clangd] Get rid of clangToolingRefactoring dependency

D71880 makes this dependency redundant and we can safely remove it. Tested for
both shared lib build and static lib build.

Reviewed By: hokein

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

Added: 


Modified: 
clang-tools-extra/clangd/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index 72b232b92c08..b8300ddaf548 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -140,7 +140,6 @@ clang_target_link_libraries(clangDaemon
   clangTooling
   clangToolingCore
   clangToolingInclusions
-  clangToolingRefactoring
   clangToolingSyntax
   )
 



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


[llvm-branch-commits] [llvm] d3a0f9b - [APInt] Add the truncOrSelf resizing operator to APInt

2020-11-23 Thread Kerry McLaughlin via llvm-branch-commits

Author: Kerry McLaughlin
Date: 2020-11-23T11:27:30Z
New Revision: d3a0f9b9ec88ce0737470652330262f8ed46daa7

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

LOG: [APInt] Add the truncOrSelf resizing operator to APInt

Truncates the APInt if the bit width is greater than the width specified,
otherwise do nothing

Reviewed By: RKSimon

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

Added: 


Modified: 
llvm/include/llvm/ADT/APInt.h
llvm/lib/Support/APInt.cpp
llvm/unittests/ADT/APIntTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index f5860f6c7517..b97ea2cd9aee 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -1403,6 +1403,12 @@ class LLVM_NODISCARD APInt {
   /// extended, truncated, or left alone to make it that width.
   APInt zextOrTrunc(unsigned width) const;
 
+  /// Truncate to width
+  ///
+  /// Make this APInt have the bit width given by \p width. The value is
+  /// truncated or left alone to make it that width.
+  APInt truncOrSelf(unsigned width) const;
+
   /// Sign extend or truncate to width
   ///
   /// Make this APInt have the bit width given by \p width. The value is sign

diff  --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index fc339de45af4..12ceb2df112e 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -961,6 +961,12 @@ APInt APInt::sextOrTrunc(unsigned width) const {
   return *this;
 }
 
+APInt APInt::truncOrSelf(unsigned width) const {
+  if (BitWidth > width)
+return trunc(width);
+  return *this;
+}
+
 APInt APInt::zextOrSelf(unsigned width) const {
   if (BitWidth < width)
 return zext(width);

diff  --git a/llvm/unittests/ADT/APIntTest.cpp 
b/llvm/unittests/ADT/APIntTest.cpp
index 673a2110af09..ef5423e332e1 100644
--- a/llvm/unittests/ADT/APIntTest.cpp
+++ b/llvm/unittests/ADT/APIntTest.cpp
@@ -2598,6 +2598,13 @@ TEST(APIntTest, sext) {
   EXPECT_EQ(63U, i32_neg1.countPopulation());
 }
 
+TEST(APIntTest, truncOrSelf) {
+  APInt val(32, 0x);
+  EXPECT_EQ(0x, val.truncOrSelf(16));
+  EXPECT_EQ(0x, val.truncOrSelf(32));
+  EXPECT_EQ(0x, val.truncOrSelf(64));
+}
+
 TEST(APIntTest, multiply) {
   APInt i64(64, 1234);
 



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


[llvm-branch-commits] [clang-tools-extra] 8cec8de - [clangd] testPath's final result agrees with the passed in Style

2020-11-23 Thread Kadir Cetinkaya via llvm-branch-commits

Author: Kadir Cetinkaya
Date: 2020-11-23T12:45:06+01:00
New Revision: 8cec8de2a4e6692da6226bb02cf417eb0e50adde

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

LOG: [clangd] testPath's final result agrees with the passed in Style

This was confusing, as testRoot on windows results in C:\\clangd-test
and testPath generated with posix explicitly still contained backslashes.

This patch ensures not only the relative part, but the whole final result
respects passed in Style.

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
clang-tools-extra/clangd/unittests/TestFS.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp 
b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
index a2423094b17a..2b4605eb97e2 100644
--- a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -255,7 +255,6 @@ TEST_F(ConfigCompileTests, ExternalBlockMountPoint) {
   };
 
   auto BarPath = testPath("foo/bar.h", llvm::sys::path::Style::posix);
-  BarPath = llvm::sys::path::convert_to_slash(BarPath);
   Parm.Path = BarPath;
   // Non-absolute MountPoint without a directory raises an error.
   Frag = GetFrag("", "foo");
@@ -269,7 +268,6 @@ TEST_F(ConfigCompileTests, ExternalBlockMountPoint) {
   ASSERT_FALSE(Conf.Index.External);
 
   auto FooPath = testPath("foo/", llvm::sys::path::Style::posix);
-  FooPath = llvm::sys::path::convert_to_slash(FooPath);
   // Ok when relative.
   Frag = GetFrag(testRoot(), "foo/");
   compileAndApply();
@@ -293,7 +291,6 @@ TEST_F(ConfigCompileTests, ExternalBlockMountPoint) {
 
   // File outside MountPoint, no index.
   auto BazPath = testPath("bar/baz.h", llvm::sys::path::Style::posix);
-  BazPath = llvm::sys::path::convert_to_slash(BazPath);
   Parm.Path = BazPath;
   Frag = GetFrag("", FooPath.c_str());
   compileAndApply();
@@ -302,7 +299,6 @@ TEST_F(ConfigCompileTests, ExternalBlockMountPoint) {
 
   // File under MountPoint, index should be set.
   BazPath = testPath("foo/baz.h", llvm::sys::path::Style::posix);
-  BazPath = llvm::sys::path::convert_to_slash(BazPath);
   Parm.Path = BazPath;
   Frag = GetFrag("", FooPath.c_str());
   compileAndApply();

diff  --git a/clang-tools-extra/clangd/unittests/TestFS.cpp 
b/clang-tools-extra/clangd/unittests/TestFS.cpp
index ba4010cb4581..f343a85331d0 100644
--- a/clang-tools-extra/clangd/unittests/TestFS.cpp
+++ b/clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -80,12 +80,10 @@ const char *testRoot() {
 }
 
 std::string testPath(PathRef File, llvm::sys::path::Style Style) {
-  assert(llvm::sys::path::is_relative(File) && "FileName should be relative");
-
-  llvm::SmallString<32> NativeFile = File;
-  llvm::sys::path::native(NativeFile, Style);
+  assert(llvm::sys::path::is_relative(File, Style));
   llvm::SmallString<32> Path;
-  llvm::sys::path::append(Path, Style, testRoot(), NativeFile);
+  llvm::sys::path::append(Path, testRoot(), File);
+  llvm::sys::path::native(Path, Style);
   return std::string(Path.str());
 }
 



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


[llvm-branch-commits] [llvm] 3a30234 - [VE][NFC] Clean stack frame description

2020-11-23 Thread Kazushi Marukawa via llvm-branch-commits

Author: Kazushi (Jam) Marukawa
Date: 2020-11-23T20:59:43+09:00
New Revision: 3a302349ebd11279d0c49fbd03c66ed502968f19

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

LOG: [VE][NFC] Clean stack frame description

Move stack frame description from VESubtarget.cpp to VEFrameLowering.cpp
and add detail.

Reviewed By: simoll

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

Added: 


Modified: 
llvm/lib/Target/VE/VEFrameLowering.cpp
llvm/lib/Target/VE/VESubtarget.cpp

Removed: 




diff  --git a/llvm/lib/Target/VE/VEFrameLowering.cpp 
b/llvm/lib/Target/VE/VEFrameLowering.cpp
index ec18bee74329..8be298b46f0d 100644
--- a/llvm/lib/Target/VE/VEFrameLowering.cpp
+++ b/llvm/lib/Target/VE/VEFrameLowering.cpp
@@ -8,6 +8,105 @@
 //
 // This file contains the VE implementation of TargetFrameLowering class.
 //
+// On VE, stack frames are structured as follows:
+//
+// The stack grows downward.
+//
+// All of the individual frame areas on the frame below are optional, i.e. it's
+// possible to create a function so that the particular area isn't present
+// in the frame.
+//
+// At function entry, the "frame" looks as follows:
+//
+// |  | Higher address
+// |--|
+// | Parameter area for this function |
+// |--|
+// | Register save area (RSA) for this function   |
+// |--|
+// | Return address for this function |
+// |--|
+// | Frame pointer for this function  |
+// |--| <- sp
+// |  | Lower address
+//
+// VE doesn't use on demand stack allocation, so user code generated by LLVM
+// needs to call VEOS to allocate stack frame.  VE's ABI want to reduce the
+// number of VEOS calls, so ABI requires to allocate not only RSA (in general
+// CSR, callee saved register) area but also call frame at the prologue of
+// caller function.
+//
+// After the prologue has run, the frame has the following general structure.
+// Note that technically the last frame area (VLAs) doesn't get created until
+// in the main function body, after the prologue is run. However, it's depicted
+// here for completeness.
+//
+// |  | Higher address
+// |--|
+// | Parameter area for this function |
+// |--|
+// | Register save area (RSA) for this function   |
+// |--|
+// | Return address for this function |
+// |--|
+// | Frame pointer for this function  |
+// |--| <- fp(=old sp)
+// |.empty.space.to.make.part.below.aligned.in|
+// |.case.it.needs.more.than.the.standard.16-byte.| (size of this area is
+// |.alignment|  unknown at compile time)
+// |--|
+// | Local variables of fixed size including spill|
+// | slots|
+// |--| <- bp(not defined by ABI,
+// |.variable-sized.local.variables.(VLAs)|   LLVM chooses SX17)
+// |..| (size of this area is
+// |..|  unknown at compile time)
+// |--| <- stack top (returned by
+// | Parameter area for callee|   alloca)
+// |--|
+// | Register save area (RSA) for callee  |
+// |--|
+// | Return address for callee|
+// |--|
+// | Frame pointer for callee |
+// |--| <- sp
+// |  | Lower address
+//
+// To access the data in a frame, at-compile time, a constant offset must be
+// computable from one of the pointers (fp, bp, sp) to access it. The size
+// of the areas with a dotted background cannot be computed at compile-time
+// if they are present, making it required to have all three of fp, bp and
+// sp to be set up to be able to access all contents in the frame areas,
+// assuming all of the frame areas are non-empty.
+//
+// For most functions, some of the frame areas are empty. For those functions,
+// it may not be necessary to set up 

[llvm-branch-commits] [llvm] 677e94c - [VE] Clean canRealignStack implementation

2020-11-23 Thread Kazushi Marukawa via llvm-branch-commits

Author: Kazushi (Jam) Marukawa
Date: 2020-11-23T21:09:03+09:00
New Revision: 677e94c0f09bf48d92b57a34ba7cf2e0d94016fb

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

LOG: [VE] Clean canRealignStack implementation

Old canRealignStack calls TRI::canRealignStack and hasReservedCallFrame.
But, this hasReservedCallFrame return true whenever for VE since VE
allocates call frame all the time.  It means this canRealignStack is
identical to TRI::canRealignStack.  This patch removes VE's
canRealignStack and let caller call TRI::canRealignStack directly.

Reviewed By: simoll

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

Added: 


Modified: 
llvm/lib/Target/VE/VERegisterInfo.cpp
llvm/lib/Target/VE/VERegisterInfo.h

Removed: 




diff  --git a/llvm/lib/Target/VE/VERegisterInfo.cpp 
b/llvm/lib/Target/VE/VERegisterInfo.cpp
index 0559c330368f..07249616c249 100644
--- a/llvm/lib/Target/VE/VERegisterInfo.cpp
+++ b/llvm/lib/Target/VE/VERegisterInfo.cpp
@@ -174,26 +174,3 @@ void 
VERegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
 Register VERegisterInfo::getFrameRegister(const MachineFunction &MF) const {
   return VE::SX9;
 }
-
-// VE has no architectural need for stack realignment support,
-// except that LLVM unfortunately currently implements overaligned
-// stack objects by depending upon stack realignment support.
-// If that ever changes, this can probably be deleted.
-bool VERegisterInfo::canRealignStack(const MachineFunction &MF) const {
-  if (!TargetRegisterInfo::canRealignStack(MF))
-return false;
-
-  // VE always has a fixed frame pointer register, so don't need to
-  // worry about needing to reserve it. [even if we don't have a frame
-  // pointer for our frame, it still cannot be used for other things,
-  // or register window traps will be SADNESS.]
-
-  // If there's a reserved call frame, we can use VE to access locals.
-  if (getFrameLowering(MF)->hasReservedCallFrame(MF))
-return true;
-
-  // Otherwise, we'd need a base pointer, but those aren't implemented
-  // for VE at the moment.
-
-  return false;
-}

diff  --git a/llvm/lib/Target/VE/VERegisterInfo.h 
b/llvm/lib/Target/VE/VERegisterInfo.h
index 9a32da16bea6..334fb965a986 100644
--- a/llvm/lib/Target/VE/VERegisterInfo.h
+++ b/llvm/lib/Target/VE/VERegisterInfo.h
@@ -40,8 +40,6 @@ struct VERegisterInfo : public VEGenRegisterInfo {
RegScavenger *RS = nullptr) const override;
 
   Register getFrameRegister(const MachineFunction &MF) const override;
-
-  bool canRealignStack(const MachineFunction &MF) const override;
 };
 
 } // namespace llvm



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


[llvm-branch-commits] [clang-tools-extra] 61e538b - Revert "[clangd] testPath's final result agrees with the passed in Style"

2020-11-23 Thread Kadir Cetinkaya via llvm-branch-commits

Author: Kadir Cetinkaya
Date: 2020-11-23T13:12:59+01:00
New Revision: 61e538b15ddb2de9250277d151f0f655c2220d9b

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

LOG: Revert "[clangd] testPath's final result agrees with the passed in Style"

This reverts commit 8cec8de2a4e6692da6226bb02cf417eb0e50adde as it
breaks windows buildbots.

Added: 


Modified: 
clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
clang-tools-extra/clangd/unittests/TestFS.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp 
b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
index 2b4605eb97e2..a2423094b17a 100644
--- a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -255,6 +255,7 @@ TEST_F(ConfigCompileTests, ExternalBlockMountPoint) {
   };
 
   auto BarPath = testPath("foo/bar.h", llvm::sys::path::Style::posix);
+  BarPath = llvm::sys::path::convert_to_slash(BarPath);
   Parm.Path = BarPath;
   // Non-absolute MountPoint without a directory raises an error.
   Frag = GetFrag("", "foo");
@@ -268,6 +269,7 @@ TEST_F(ConfigCompileTests, ExternalBlockMountPoint) {
   ASSERT_FALSE(Conf.Index.External);
 
   auto FooPath = testPath("foo/", llvm::sys::path::Style::posix);
+  FooPath = llvm::sys::path::convert_to_slash(FooPath);
   // Ok when relative.
   Frag = GetFrag(testRoot(), "foo/");
   compileAndApply();
@@ -291,6 +293,7 @@ TEST_F(ConfigCompileTests, ExternalBlockMountPoint) {
 
   // File outside MountPoint, no index.
   auto BazPath = testPath("bar/baz.h", llvm::sys::path::Style::posix);
+  BazPath = llvm::sys::path::convert_to_slash(BazPath);
   Parm.Path = BazPath;
   Frag = GetFrag("", FooPath.c_str());
   compileAndApply();
@@ -299,6 +302,7 @@ TEST_F(ConfigCompileTests, ExternalBlockMountPoint) {
 
   // File under MountPoint, index should be set.
   BazPath = testPath("foo/baz.h", llvm::sys::path::Style::posix);
+  BazPath = llvm::sys::path::convert_to_slash(BazPath);
   Parm.Path = BazPath;
   Frag = GetFrag("", FooPath.c_str());
   compileAndApply();

diff  --git a/clang-tools-extra/clangd/unittests/TestFS.cpp 
b/clang-tools-extra/clangd/unittests/TestFS.cpp
index f343a85331d0..ba4010cb4581 100644
--- a/clang-tools-extra/clangd/unittests/TestFS.cpp
+++ b/clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -80,10 +80,12 @@ const char *testRoot() {
 }
 
 std::string testPath(PathRef File, llvm::sys::path::Style Style) {
-  assert(llvm::sys::path::is_relative(File, Style));
+  assert(llvm::sys::path::is_relative(File) && "FileName should be relative");
+
+  llvm::SmallString<32> NativeFile = File;
+  llvm::sys::path::native(NativeFile, Style);
   llvm::SmallString<32> Path;
-  llvm::sys::path::append(Path, testRoot(), File);
-  llvm::sys::path::native(Path, Style);
+  llvm::sys::path::append(Path, Style, testRoot(), NativeFile);
   return std::string(Path.str());
 }
 



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


[llvm-branch-commits] [mlir] 9ac0b31 - [mlir][Linalg] Drop symbol_source abstraction which does not pay for itself.

2020-11-23 Thread Nicolas Vasilache via llvm-branch-commits

Author: Nicolas Vasilache
Date: 2020-11-23T12:43:02Z
New Revision: 9ac0b314a431405aa6a681124f83138f7544807e

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

LOG: [mlir][Linalg] Drop symbol_source abstraction which does not pay for 
itself.

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

Added: 


Modified: 
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
mlir/include/mlir/Dialect/Linalg/Passes.td
mlir/include/mlir/Dialect/Utils/StructuredOpsUtils.h
mlir/lib/Dialect/Linalg/EDSC/Builders.cpp
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp
mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
mlir/test/Dialect/Linalg/invalid.mlir
mlir/test/Dialect/Linalg/loops.mlir

Removed: 




diff  --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td 
b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
index aba4f9d61fe0..66f39104d7e7 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
@@ -503,9 +503,7 @@ class GenericOpBase : 
LinalgStructuredBase_Op:$doc,
OptionalAttr:$library_call,
// ArrayAttr of StrArrayAttr:
-   OptionalAttr:$sparse,
-   Confined, [IntMinValue<0>]>
- :$symbol_source);
+   OptionalAttr:$sparse);
   let results = (outs Variadic:$result_tensors);
   let regions = (region AnyRegion:$region);
   let extraClassDeclaration = [{
@@ -513,18 +511,13 @@ class GenericOpBase : 
LinalgStructuredBase_Op{
 getDocAttrName(),
 getIndexingMapsAttrName(), getLibraryCallAttrName(),
-getIteratorTypesAttrName(), getSymbolSourceAttrName()
+getIteratorTypesAttrName(),
   };
 }
 std::string getLibraryCallName() {
   return library_call().hasValue() ?
 library_call()->str() : "op_has_no_registered_library_name";
 }
-llvm::Optional getSymbolSource() {
-  auto ss = symbol_source();
-  return ss.hasValue() ?
-llvm::Optional(ss.getValue()) : llvm::None;
-}
 
 static std::function getRegionBuilder() {
   return nullptr;
@@ -566,10 +559,6 @@ def GenericOp : GenericOpBase<"generic"> {
   parallel, reduction, window
   - sparse: an optional list with per-dimension sparsity annotations 
(either
 "D" for dense or "S" for sparse) for each input and output view.
-  - symbol_source: index of the operand whose dimensions will be propagated
-as symbols to the indexing maps. When specified the number of symbols
-in each of the indexing maps has to be either 0 or the rank of the
-specified operand.
 
 Example:
 Defining a #matmul_trait attribute in MLIR can be done as follows:
@@ -646,50 +635,17 @@ def GenericOp : GenericOpBase<"generic"> {
 Tensor values must be legalized by a buffer allocation pass before most
 transformations can be applied. Such legalizations move tensor return 
values
 into output buffer operands and updates the region arguments accordingly.
-
-The `symbol_source` attribute allows selecting a particular operand and
-introducing symbols for each operand dimension. Such symbols can then be
-used in the indexing maps.
-
-Example of 1D convolution with symbols:
-```mlir
-#conv_1d_accesses = [
-  affine_map<(m, n)[dimN] -> (m + n - dimN floordiv 2)>, // in
-  affine_map<(m, n)[dimN] -> (n)>, // filter
-  affine_map<(m, n)[dimN] -> (m)> // out
-]
-
-#conv_1d_trait = {
-  doc = "O(m) += I(m + n - size(n) floordiv 2) * K(n)",
-  indexing_maps = #conv_1d_accesses,
-  library_call  = "linalg_conv_1d",
-  iterator_types = ["parallel", "parallel"],
-  symbol_source = 1
-}
-
-linalg.generic #conv_1d_trait
-  ins(%in, %filter : memref, memref)
-  outs(%out : memref) {
-  ^bb0(%a: f32, %b: f32, %c: f32) :
-%d = mulf %a, %b : f32
-%e = addf %c, %d : f32
-linalg.yield %e : f32
-}
-```
-where symbol s0 will be substituted with `dim %filter, %c0` i.e. the first
-and only dimension of the second operand as specified by the symbol_source
-attribute.
   }];
 
   let builders = [
 OpBuilderDAG<(ins "TypeRange":$resultTensorTypes, "ValueRange":$inputs,
   "ValueRange":$outputBuffers, "ValueRange":$initTensors,
   "ArrayRef":$indexingMaps, 
"ArrayRef":$iteratorTypes,
-  "StringRef":$doc, "StringRef":$libraryCall, "IntegerAttr":$symbolSource,
+  "StringRef":$doc, "StringRef":$libraryCall,
   CArg<"function_ref", 
"nullptr">)>,
 Op

[llvm-branch-commits] [clang-tools-extra] b31486a - [clangd] textDocument/implementation (LSP layer)

2020-11-23 Thread Utkarsh Saxena via llvm-branch-commits

Author: Utkarsh Saxena
Date: 2020-11-23T13:50:44+01:00
New Revision: b31486ad971774c859e3e031fc0d8d9b77e3b083

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

LOG: [clangd] textDocument/implementation (LSP layer)

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

Added: 
clang-tools-extra/clangd/test/implementations.test

Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/test/initialize-params.test

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index e726271fe7cbe..335a6fc9ad94e 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -604,6 +604,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
&Params,
  }},
 {"declarationProvider", true},
 {"definitionProvider", true},
+{"implementationProvider", true},
 {"documentHighlightProvider", true},
 {"documentLinkProvider",
  llvm::json::Object{
@@ -1291,6 +1292,22 @@ void ClangdLSPServer::onReference(const ReferenceParams 
&Params,
  });
 }
 
+void ClangdLSPServer::onGoToImplementation(
+const TextDocumentPositionParams &Params,
+Callback> Reply) {
+  Server->findImplementations(
+  Params.textDocument.uri.file(), Params.position,
+  [Reply = std::move(Reply)](
+  llvm::Expected> Overrides) mutable {
+if (!Overrides)
+  return Reply(Overrides.takeError());
+std::vector Impls;
+for (const LocatedSymbol &Sym : *Overrides)
+  Impls.push_back(Sym.PreferredDeclaration);
+return Reply(std::move(Impls));
+  });
+}
+
 void ClangdLSPServer::onSymbolInfo(const TextDocumentPositionParams &Params,
Callback> Reply) 
{
   Server->symbolInfo(Params.textDocument.uri.file(), Params.position,
@@ -1431,6 +1448,7 @@ ClangdLSPServer::ClangdLSPServer(class Transport &Transp,
   MsgHandler->bind("textDocument/signatureHelp", 
&ClangdLSPServer::onSignatureHelp);
   MsgHandler->bind("textDocument/definition", 
&ClangdLSPServer::onGoToDefinition);
   MsgHandler->bind("textDocument/declaration", 
&ClangdLSPServer::onGoToDeclaration);
+  MsgHandler->bind("textDocument/implementation", 
&ClangdLSPServer::onGoToImplementation);
   MsgHandler->bind("textDocument/references", &ClangdLSPServer::onReference);
   MsgHandler->bind("textDocument/switchSourceHeader", 
&ClangdLSPServer::onSwitchSourceHeader);
   MsgHandler->bind("textDocument/prepareRename", 
&ClangdLSPServer::onPrepareRename);

diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.h 
b/clang-tools-extra/clangd/ClangdLSPServer.h
index b9200f6a2e1b8..4d568bc13d8bf 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.h
+++ b/clang-tools-extra/clangd/ClangdLSPServer.h
@@ -115,6 +115,8 @@ class ClangdLSPServer : private ClangdServer::Callbacks {
  Callback>);
   void onGoToDefinition(const TextDocumentPositionParams &,
 Callback>);
+  void onGoToImplementation(const TextDocumentPositionParams &,
+Callback>);
   void onReference(const ReferenceParams &, Callback>);
   void onSwitchSourceHeader(const TextDocumentIdentifier &,
 Callback>);

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index b6f9fcfd23da8..889d2cbcf2807 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -718,6 +718,18 @@ void ClangdServer::foldingRanges(llvm::StringRef File,
TUScheduler::InvalidateOnUpdate);
 }
 
+void ClangdServer::findImplementations(
+PathRef File, Position Pos, Callback> CB) {
+  auto Action = [Pos, CB = std::move(CB),
+ this](llvm::Expected InpAST) mutable {
+if (!InpAST)
+  return CB(InpAST.takeError());
+CB(clangd::findImplementations(InpAST->AST, Pos, Index));
+  };
+
+  WorkScheduler.runWithAST("Implementations", File, std::move(Action));
+}
+
 void ClangdServer::findReferences(PathRef File, Position Pos, uint32_t Limit,
   Callback CB) {
   auto Action = [Pos, Limit, CB = std::move(CB),

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 0056f5072cca3..1ccb4c5899f81 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -253,6 +253,10 @@ class ClangdServer {
   /// Retrieve ranges that

[llvm-branch-commits] [mlir] 1ec6086 - [mlir] Avoid cloning ops in SCF parallel conversion to CFG

2020-11-23 Thread Alex Zinenko via llvm-branch-commits

Author: Alex Zinenko
Date: 2020-11-23T14:01:22+01:00
New Revision: 1ec60862d7024118b2db5bcbb280eafcd9193ac5

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

LOG: [mlir] Avoid cloning ops in SCF parallel conversion to CFG

The existing implementation of the conversion from SCF Parallel operation to
SCF "for" loops in order to further convert those loops to branch-based CFG has
been cloning the loop and reduction body operations into the new loop because
ConversionPatternRewriter was missing support for moving blocks while replacing
their arguments. This functionality now available, use it to implement the
conversion and avoid cloning operations, which may lead to doubling of the IR
size during the conversion.

In addition, this fixes an issue with converting nested SCF "if" conditionals
present in "parallel" operations that would cause the conversion infrastructure
to stop because of the repeated application of the pattern converting "newly"
created "if"s (which were in fact just moved). Arguably, this should be fixed
at the infrastructure level and this fix is a workaround.

Reviewed By: herhut

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

Added: 


Modified: 
mlir/lib/Conversion/SCFToStandard/SCFToStandard.cpp
mlir/test/Conversion/SCFToStandard/convert-to-cfg.mlir

Removed: 




diff  --git a/mlir/lib/Conversion/SCFToStandard/SCFToStandard.cpp 
b/mlir/lib/Conversion/SCFToStandard/SCFToStandard.cpp
index 56f6bf2f05fc..b8f3140dee73 100644
--- a/mlir/lib/Conversion/SCFToStandard/SCFToStandard.cpp
+++ b/mlir/lib/Conversion/SCFToStandard/SCFToStandard.cpp
@@ -404,7 +404,6 @@ LogicalResult
 ParallelLowering::matchAndRewrite(ParallelOp parallelOp,
   PatternRewriter &rewriter) const {
   Location loc = parallelOp.getLoc();
-  BlockAndValueMapping mapping;
 
   // For a parallel loop, we essentially need to create an n-dimensional loop
   // nest. We do this by translating to scf.for ops and have those lowered in
@@ -412,6 +411,8 @@ ParallelLowering::matchAndRewrite(ParallelOp parallelOp,
   // values), forward the initial values for the reductions down the loop
   // hierarchy and bubble up the results by modifying the "yield" terminator.
   SmallVector iterArgs = llvm::to_vector<4>(parallelOp.initVals());
+  SmallVector ivs;
+  ivs.reserve(parallelOp.getNumLoops());
   bool first = true;
   SmallVector loopResults(iterArgs);
   for (auto loop_operands :
@@ -420,7 +421,7 @@ ParallelLowering::matchAndRewrite(ParallelOp parallelOp,
 Value iv, lower, upper, step;
 std::tie(iv, lower, upper, step) = loop_operands;
 ForOp forOp = rewriter.create(loc, lower, upper, step, iterArgs);
-mapping.map(iv, forOp.getInductionVar());
+ivs.push_back(forOp.getInductionVar());
 auto iterRange = forOp.getRegionIterArgs();
 iterArgs.assign(iterRange.begin(), iterRange.end());
 
@@ -439,33 +440,33 @@ ParallelLowering::matchAndRewrite(ParallelOp parallelOp,
 rewriter.setInsertionPointToStart(forOp.getBody());
   }
 
-  // Now copy over the contents of the body.
+  // First, merge reduction blocks into the main region.
   SmallVector yieldOperands;
   yieldOperands.reserve(parallelOp.getNumResults());
-  for (auto &op : parallelOp.getBody()->without_terminator()) {
-// Reduction blocks are handled 
diff erently.
+  for (auto &op : *parallelOp.getBody()) {
 auto reduce = dyn_cast(op);
-if (!reduce) {
-  rewriter.clone(op, mapping);
+if (!reduce)
   continue;
-}
 
-// Clone the body of the reduction operation into the body of the loop,
-// using operands of "scf.reduce" and iteration arguments corresponding
-// to the reduction value to replace arguments of the reduction block.
-// Collect operands of "scf.reduce.return" to be returned by a final
-// "scf.yield" instead.
-Value arg = iterArgs[yieldOperands.size()];
 Block &reduceBlock = reduce.reductionOperator().front();
-mapping.map(reduceBlock.getArgument(0), mapping.lookupOrDefault(arg));
-mapping.map(reduceBlock.getArgument(1),
-mapping.lookupOrDefault(reduce.operand()));
-for (auto &nested : reduceBlock.without_terminator())
-  rewriter.clone(nested, mapping);
-yieldOperands.push_back(
-mapping.lookup(reduceBlock.getTerminator()->getOperand(0)));
+Value arg = iterArgs[yieldOperands.size()];
+yieldOperands.push_back(reduceBlock.getTerminator()->getOperand(0));
+rewriter.eraseOp(reduceBlock.getTerminator());
+rewriter.mergeBlockBefore(&reduceBlock, &op, {arg, reduce.operand()});
+rewriter.eraseOp(reduce);
   }
 
+  // Then merge the loop body without the terminator.
+  rewriter.eraseOp(parallelOp.getBody()->getTerminator());
+  Block *newBody = rewriter.getIn

[llvm-branch-commits] [clang] 00dad9d - Ignore noderef attribute in unevaluated context

2020-11-23 Thread Aaron Ballman via llvm-branch-commits

Author: Jann Horn
Date: 2020-11-23T08:10:35-05:00
New Revision: 00dad9d028ce31739b992a3ce2df5de054a9fa3c

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

LOG: Ignore noderef attribute in unevaluated context

The noderef attribute is for catching code that accesses pointers in
a different address space. Unevaluated code is always safe in that regard.

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprMember.cpp
clang/test/Frontend/noderef.c
clang/test/Frontend/noderef.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 60a685bfdf15..5580cdf13691 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -4751,6 +4751,9 @@ void Sema::CheckAddressOfNoDeref(const Expr *E) {
 }
 
 void Sema::CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E) {
+  if (isUnevaluatedContext())
+return;
+
   QualType ResultTy = E->getType();
   ExpressionEvaluationContextRecord &LastRecord = ExprEvalContexts.back();
 
@@ -14666,7 +14669,8 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation 
OpLoc,
 OpLoc, CanOverflow, CurFPFeatureOverrides());
 
   if (Opc == UO_Deref && UO->getType()->hasAttr(attr::NoDeref) &&
-  !isa(UO->getType().getDesugaredType(Context)))
+  !isa(UO->getType().getDesugaredType(Context)) &&
+  !isUnevaluatedContext())
 ExprEvalContexts.back().PossibleDerefs.insert(UO);
 
   // Convert the result back to a half vector.

diff  --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 93ed756e084b..23cfae81df46 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -1734,6 +1734,9 @@ ExprResult Sema::ActOnMemberAccessExpr(Scope *S, Expr 
*Base,
 }
 
 void Sema::CheckMemberAccessOfNoDeref(const MemberExpr *E) {
+  if (isUnevaluatedContext())
+return;
+
   QualType ResultTy = E->getType();
 
   // Do not warn on member accesses to arrays since this returns an array

diff  --git a/clang/test/Frontend/noderef.c b/clang/test/Frontend/noderef.c
index b072b995fcf6..3388f2a39992 100644
--- a/clang/test/Frontend/noderef.c
+++ b/clang/test/Frontend/noderef.c
@@ -57,12 +57,19 @@ int test() {
   p = &*(p + 1);
 
   // Struct member access
-  struct S NODEREF *s;  // expected-note 2 {{s declared here}}
+  struct S NODEREF *s; // expected-note 3 {{s declared here}}
   x = s->a;   // expected-warning{{dereferencing s; was declared with a 
'noderef' type}}
   x = (*s).b; // expected-warning{{dereferencing s; was declared with a 
'noderef' type}}
   p = &s->a;
   p = &(*s).b;
 
+  // Most things in sizeof() can't actually access memory
+  x = sizeof(s->a);  // ok
+  x = sizeof(*s);// ok
+  x = sizeof(s[0]);  // ok
+  x = sizeof(s->a + (s->b)); // ok
+  x = sizeof(int[++s->a]);   // expected-warning{{dereferencing s; was 
declared with a 'noderef' type}}
+
   // Nested struct access
   struct S2 NODEREF *s2_noderef;// expected-note 5 {{s2_noderef declared 
here}}
   p = s2_noderef->a;  // ok since result is an array in a struct

diff  --git a/clang/test/Frontend/noderef.cpp b/clang/test/Frontend/noderef.cpp
index 32d5ca34d1b1..68342a8e6467 100644
--- a/clang/test/Frontend/noderef.cpp
+++ b/clang/test/Frontend/noderef.cpp
@@ -6,6 +6,11 @@
 
 #define NODEREF __attribute__((noderef))
 
+// Stub out types for 'typeid' to work.
+namespace std {
+class type_info {};
+} // namespace std
+
 void Normal() {
   int NODEREF i;// expected-warning{{'noderef' can only be used on an 
array or pointer type}}
   int NODEREF *i_ptr;   // expected-note 2 {{i_ptr declared here}}
@@ -102,6 +107,18 @@ int ChildCall(NODEREF Child *child) { // 
expected-note{{child declared here}}
   return child->func();   // expected-warning{{dereferencing 
child; was declared with a 'noderef' type}}
 }
 
+std::type_info TypeIdPolymorphic(NODEREF A *a) { // expected-note{{a declared 
here}}
+  return typeid(*a); // 
expected-warning{{dereferencing a; was declared with a 'noderef' type}}
+}
+
+class SimpleClass {
+  int a;
+};
+
+std::type_info TypeIdNonPolymorphic(NODEREF SimpleClass *simple) {
+  return typeid(*simple);
+}
+
 template 
 class B {
   Ty NODEREF *member;



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


[llvm-branch-commits] [llvm] ce44bf2 - [AMDGPU][MC] Improved diagnostic messages

2020-11-23 Thread Dmitry Preobrazhensky via llvm-branch-commits

Author: Dmitry Preobrazhensky
Date: 2020-11-23T16:15:05+03:00
New Revision: ce44bf2cf229c179948b97639587c92c3f2e8b19

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

LOG: [AMDGPU][MC] Improved diagnostic messages

See bug 47518 (https://bugs.llvm.org/show_bug.cgi?id=47518)

Reviewers: rampitec

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

Added: 


Modified: 
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
llvm/test/MC/AMDGPU/gfx10_err_pos.s
llvm/test/MC/AMDGPU/gfx908_err_pos.s
llvm/test/MC/AMDGPU/gfx9_err_pos.s

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp 
b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index fa5e05ae8801..4f05ba5ab576 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -1396,8 +1396,8 @@ class AMDGPUAsmParser : public MCTargetAsmParser {
   bool validateFlatOffset(const MCInst &Inst, const OperandVector &Operands);
   bool validateSMEMOffset(const MCInst &Inst, const OperandVector &Operands);
   bool validateSOPLiteral(const MCInst &Inst) const;
-  bool validateConstantBusLimitations(const MCInst &Inst);
-  bool validateEarlyClobberLimitations(const MCInst &Inst);
+  bool validateConstantBusLimitations(const MCInst &Inst, const OperandVector 
&Operands);
+  bool validateEarlyClobberLimitations(const MCInst &Inst, const OperandVector 
&Operands);
   bool validateIntClampSupported(const MCInst &Inst);
   bool validateMIMGAtomicDMask(const MCInst &Inst);
   bool validateMIMGGatherDMask(const MCInst &Inst);
@@ -1410,7 +1410,7 @@ class AMDGPUAsmParser : public MCTargetAsmParser {
   bool validateOpSel(const MCInst &Inst);
   bool validateVccOperand(unsigned Reg) const;
   bool validateVOP3Literal(const MCInst &Inst, const OperandVector &Operands);
-  bool validateMAIAccWrite(const MCInst &Inst);
+  bool validateMAIAccWrite(const MCInst &Inst, const OperandVector &Operands);
   bool validateDivScale(const MCInst &Inst);
   bool validateCoherencyBits(const MCInst &Inst, const OperandVector &Operands,
  const SMLoc &IDLoc);
@@ -3062,9 +3062,12 @@ bool AMDGPUAsmParser::usesConstantBus(const MCInst 
&Inst, unsigned OpIdx) {
   }
 }
 
-bool AMDGPUAsmParser::validateConstantBusLimitations(const MCInst &Inst) {
+bool
+AMDGPUAsmParser::validateConstantBusLimitations(const MCInst &Inst,
+const OperandVector &Operands) 
{
   const unsigned Opcode = Inst.getOpcode();
   const MCInstrDesc &Desc = MII.get(Opcode);
+  unsigned LastSGPR = AMDGPU::NoRegister;
   unsigned ConstantBusUseCount = 0;
   unsigned NumLiterals = 0;
   unsigned LiteralSize;
@@ -3098,15 +3101,15 @@ bool 
AMDGPUAsmParser::validateConstantBusLimitations(const MCInst &Inst) {
   const MCOperand &MO = Inst.getOperand(OpIdx);
   if (usesConstantBus(Inst, OpIdx)) {
 if (MO.isReg()) {
-  const unsigned Reg = mc2PseudoReg(MO.getReg());
+  LastSGPR = mc2PseudoReg(MO.getReg());
   // Pairs of registers with a partial intersections like these
   //   s0, s[0:1]
   //   flat_scratch_lo, flat_scratch
   //   flat_scratch_lo, flat_scratch_hi
   // are theoretically valid but they are disabled anyway.
   // Note that this code mimics SIInstrInfo::verifyInstruction
-  if (!SGPRsUsed.count(Reg)) {
-SGPRsUsed.insert(Reg);
+  if (!SGPRsUsed.count(LastSGPR)) {
+SGPRsUsed.insert(LastSGPR);
 ++ConstantBusUseCount;
   }
 } else { // Expression or a literal
@@ -3138,10 +3141,19 @@ bool 
AMDGPUAsmParser::validateConstantBusLimitations(const MCInst &Inst) {
   }
   ConstantBusUseCount += NumLiterals;
 
-  return ConstantBusUseCount <= getConstantBusLimit(Opcode);
+  if (ConstantBusUseCount <= getConstantBusLimit(Opcode))
+return true;
+
+  SMLoc LitLoc = getLitLoc(Operands);
+  SMLoc RegLoc = getRegLoc(LastSGPR, Operands);
+  SMLoc Loc = (LitLoc.getPointer() < RegLoc.getPointer()) ? RegLoc : LitLoc;
+  Error(Loc, "invalid operand (violates constant bus restrictions)");
+  return false;
 }
 
-bool AMDGPUAsmParser::validateEarlyClobberLimitations(const MCInst &Inst) {
+bool
+AMDGPUAsmParser::validateEarlyClobberLimitations(const MCInst &Inst,
+ const OperandVector 
&Operands) {
   const unsigned Opcode = Inst.getOpcode();
   const MCInstrDesc &Desc = MII.get(Opcode);
 
@@ -3170,6 +3182,8 @@ bool 
AMDGPUAsmParser::validateEarlyClobberLimitations(const MCInst &Inst) {
 if (Src.isReg()) {
   const unsigned SrcReg = mc2PseudoReg(Src.getReg());
   if (isRegIntersect(DstReg, SrcReg, TRI)) {
+Error(getReg

[llvm-branch-commits] [llvm] 2745d9c - [llvm-readobj][test] - Simplify the gnu-notes.test

2020-11-23 Thread Georgii Rymar via llvm-branch-commits

Author: Georgii Rymar
Date: 2020-11-23T16:26:02+03:00
New Revision: 2745d9c586d1fea438f5542dfd0718feefd14ad9

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

LOG: [llvm-readobj][test] - Simplify the gnu-notes.test

This test contains YAMLs that can be merged with use of macros.
This opens road for adding more test cases.

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

Added: 


Modified: 
llvm/test/tools/llvm-readobj/ELF/gnu-notes.test

Removed: 




diff  --git a/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test 
b/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
index efc7f6e57094..04430577daaf 100644
--- a/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
+++ b/llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
@@ -112,7 +112,7 @@ ProgramHeaders:
 ## Test tools report an error if a note section has an invalid offset
 ## that goes past the end of file.
 
-# RUN: yaml2obj --docnum=2 %s -o %t2.so
+# RUN: yaml2obj --docnum=2 -DSHOFFSET=0x %s -o %t2.so
 # RUN: not llvm-readelf --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s 
--check-prefix=ERR1
 # RUN: not llvm-readobj --notes %t2.so 2>&1 | FileCheck -DFILE=%t2.so %s 
--check-prefix=ERR1
 
@@ -127,32 +127,22 @@ Sections:
   - Name: .note
 Type: SHT_NOTE
 Notes:[]
-ShOffset: 0x
+ShOffset: [[SHOFFSET=]]
+ShSize:   [[SHSIZE=]]
 
 ## Test tools report an error if a note section has invalid size
 ## that goes past the end of file.
 
-# RUN: yaml2obj --docnum=3 %s -o %t3.so
+# RUN: yaml2obj --docnum=2 -DSHSIZE=0x %s -o %t3.so
 # RUN: not llvm-readelf --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s 
--check-prefix=ERR2
 # RUN: not llvm-readobj --notes %t3.so 2>&1 | FileCheck -DFILE=%t3.so %s 
--check-prefix=ERR2
 
 # ERR2: error: '[[FILE]]': SHT_NOTE section [index 1] has invalid offset 
(0x40) or size (0x)
 
 !ELF
-FileHeader:
-  Class: ELFCLASS64
-  Data:  ELFDATA2LSB
-  Type:  ET_EXEC
-Sections:
-  - Name:   .note
-Type:   SHT_NOTE
-ShSize: 0x
-Notes:  []
-
 ## Test tools report an error if a note program header has an invalid offset 
that
 ## goes past the end of file.
 
-# RUN: yaml2obj --docnum=4 %s -o %t4.so
+# RUN: yaml2obj --docnum=3 -DPHOFFSET=0x %s -o %t4.so
 # RUN: not llvm-readelf --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s 
--check-prefix=ERR3
 # RUN: not llvm-readobj --notes %t4.so 2>&1 | FileCheck -DFILE=%t4.so %s 
--check-prefix=ERR3
 
@@ -164,32 +154,18 @@ FileHeader:
   Data:  ELFDATA2LSB
   Type:  ET_CORE
 ProgramHeaders:
-  - Type:   PT_NOTE
-Offset: 0x
+  - Type: PT_NOTE
+Offset:   [[PHOFFSET=]]
+FileSize: [[PHFILESIZE=]]
 
 ## Test tools report an error if a note program header has an invalid size that
 ## goes past the end of file.
 
-# RUN: yaml2obj --docnum=5 %s -o %t5.so
+# RUN: yaml2obj --docnum=3 -DPHFILESIZE=0x %s -o %t5.so
 # RUN: not llvm-readelf --notes %t5.so 2>&1 | FileCheck -DFILE=%t5.so  %s 
--check-prefix=ERR4
 # RUN: not llvm-readobj --notes %t5.so 2>&1 | FileCheck -DFILE=%t5.so %s 
--check-prefix=ERR4
 
-# ERR4: error: '[[FILE]]': PT_NOTE header has invalid offset (0x78) or size 
(0x)
-
 !ELF
-FileHeader:
-  Class: ELFCLASS64
-  Data:  ELFDATA2LSB
-  Type:  ET_CORE
-Sections:
-  - Name:  .note
-Type:  SHT_NOTE
-Notes: []
-ProgramHeaders:
-  - Type: PT_NOTE
-FileSize: 0x
-FirstSec: .note
-LastSec:  .note
+# ERR4: error: '[[FILE]]': PT_NOTE header has invalid offset (0x0) or size 
(0x)
 
 ## Check we report a warning when we are unable to locate the PT_NOTE
 ## segment because of broken program headers.



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


[llvm-branch-commits] [lldb] a8f6f4e - [lldb] [test] Restore Windows-skip on 'process connect' tests

2020-11-23 Thread Michał Górny via llvm-branch-commits

Author: Michał Górny
Date: 2020-11-23T14:27:32+01:00
New Revision: a8f6f4e8733cd601246ddc3e391cd82236231846

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

LOG: [lldb] [test] Restore Windows-skip on 'process connect' tests

Added: 


Modified: 
lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
lldb/test/Shell/Commands/command-process-connect.test

Removed: 




diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
index e9152f02a15e..c2d06ad5d67e 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestProcessConnect.py
@@ -33,6 +33,7 @@ def test_gdb_remote_async(self):
 finally:
 self.dbg.GetSelectedPlatform().DisconnectRemote()
 
+@skipIfWindows
 def test_process_connect_sync(self):
 """Test the gdb-remote command in synchronous mode"""
 try:
@@ -43,6 +44,7 @@ def test_process_connect_sync(self):
 finally:
 self.dbg.GetSelectedPlatform().DisconnectRemote()
 
+@skipIfWindows
 @skipIfReproducer # Reproducer don't support async.
 def test_process_connect_async(self):
 """Test the gdb-remote command in asynchronous mode"""

diff  --git a/lldb/test/Shell/Commands/command-process-connect.test 
b/lldb/test/Shell/Commands/command-process-connect.test
index c4761360d541..30782243d4ed 100644
--- a/lldb/test/Shell/Commands/command-process-connect.test
+++ b/lldb/test/Shell/Commands/command-process-connect.test
@@ -1,3 +1,5 @@
+# UNSUPPORTED: system-windows
+
 # Synchronous
 # RUN: %lldb -o 'platform select remote-gdb-server' -o 'process connect 
connect://localhost:4321' 2>&1 | FileCheck %s
 



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


[llvm-branch-commits] [llvm] faf848a - [Inline] Fix in handling of ptrtoint in InlineCost

2020-11-23 Thread Mikael Holmen via llvm-branch-commits

Author: Mikael Holmen
Date: 2020-11-23T14:33:06+01:00
New Revision: faf848ac321801ba92b1d3038fccc84988d46ac8

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

LOG: [Inline] Fix in handling of ptrtoint in InlineCost

ConstantOffsetPtrs contains mappings from a Value to a base pointer and
an offset. The offset is typed and has a size, and at least when dealing
with ptrtoint, it could happen that we had a mapping from a ptrtoint
with type i32 to an offset with type i16. This could later cause
problems, showing up in PR 47969 and PR 38500.

In PR 47969 we ended up in an assert complaining that trunc i16 to i16
is invalid and in Pr 38500 that a cmp on an i32 and i16 value isn't
valid.

Reviewed By: spatel

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

Added: 
llvm/test/Transforms/Inline/inline-ptrtoint-different-sizes.ll

Modified: 
llvm/lib/Analysis/InlineCost.cpp

Removed: 




diff  --git a/llvm/lib/Analysis/InlineCost.cpp 
b/llvm/lib/Analysis/InlineCost.cpp
index 8a4b779e5084..80be0040e7b3 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -1101,7 +1101,7 @@ bool CallAnalyzer::visitPtrToInt(PtrToIntInst &I) {
   // integer is large enough to represent the pointer.
   unsigned IntegerSize = I.getType()->getScalarSizeInBits();
   unsigned AS = I.getOperand(0)->getType()->getPointerAddressSpace();
-  if (IntegerSize >= DL.getPointerSizeInBits(AS)) {
+  if (IntegerSize == DL.getPointerSizeInBits(AS)) {
 std::pair BaseAndOffset =
 ConstantOffsetPtrs.lookup(I.getOperand(0));
 if (BaseAndOffset.first)

diff  --git a/llvm/test/Transforms/Inline/inline-ptrtoint-
diff erent-sizes.ll b/llvm/test/Transforms/Inline/inline-ptrtoint-
diff erent-sizes.ll
new file mode 100644
index ..b412504a800c
--- /dev/null
+++ b/llvm/test/Transforms/Inline/inline-ptrtoint-
diff erent-sizes.ll
@@ -0,0 +1,40 @@
+; RUN: opt < %s -inline -S | FileCheck %s
+
+; InlineCost used to have problems with the ptrtoint, leading to
+; crashes when visiting the trunc in pr48908_help and the icmp in
+; pr38500_help.
+
+target datalayout = "p:16:16"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @pr48980_help(i16* %p) {
+  %cast = ptrtoint i16* %p to i32
+  %sub = sub i32 %cast, %cast
+  %conv = trunc i32 %sub to i16
+  ret void
+}
+
+define void @pr48980(i16* %x) {
+  call void @pr48980_help(i16* %x)
+  ret void
+}
+
+; CHECK-LABEL: @pr48980(i16* %x)
+; CHECK-NOT: call
+; CHECK: ret void
+
+define void @pr38500_help(i16* %p) {
+  %cast = ptrtoint i16* %p to i32
+  %sub = sub i32 %cast, %cast
+  %cmp = icmp eq i32 %sub, 0
+  ret void
+}
+
+define void @pr38500(i16* %x) {
+  call void @pr38500_help(i16* %x)
+  ret void
+}
+
+; CHECK-LABEL: @pr38500(i16* %x)
+; CHECK-NOT: call
+; CHECK: ret void



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


[llvm-branch-commits] [mlir] 31a233d - [mlir] canonicalize away zero-iteration SCF for loops

2020-11-23 Thread Alex Zinenko via llvm-branch-commits

Author: Alex Zinenko
Date: 2020-11-23T15:04:31+01:00
New Revision: 31a233d46367636f94c487b51aa2931a1cc9cf79

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

LOG: [mlir] canonicalize away zero-iteration SCF for loops

An SCF 'for' loop does not iterate if its lower bound is equal to its upper
bound. Remove loops where both bounds are the same SSA value as such bounds are
guaranteed to be equal. Similarly, remove 'parallel' loops where at least one
pair of respective lower/upper bounds is specified by the same SSA value.

Reviewed By: gysit

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

Added: 


Modified: 
mlir/lib/Dialect/SCF/SCF.cpp
mlir/test/Dialect/SCF/canonicalize.mlir

Removed: 




diff  --git a/mlir/lib/Dialect/SCF/SCF.cpp b/mlir/lib/Dialect/SCF/SCF.cpp
index 5da9f7c29cab..48b1b473f86d 100644
--- a/mlir/lib/Dialect/SCF/SCF.cpp
+++ b/mlir/lib/Dialect/SCF/SCF.cpp
@@ -521,6 +521,13 @@ struct SimplifyTrivialLoops : public 
OpRewritePattern {
 
   LogicalResult matchAndRewrite(ForOp op,
 PatternRewriter &rewriter) const override {
+// If the upper bound is the same as the lower bound, the loop does not
+// iterate, just remove it.
+if (op.lowerBound() == op.upperBound()) {
+  rewriter.replaceOp(op, op.getIterOperands());
+  return success();
+}
+
 auto lb = op.lowerBound().getDefiningOp();
 auto ub = op.upperBound().getDefiningOp();
 if (!lb || !ub)
@@ -1066,11 +1073,30 @@ struct CollapseSingleIterationLoops : public 
OpRewritePattern {
 return success();
   }
 };
+
+/// Removes parallel loops in which at least one lower/upper bound pair 
consists
+/// of the same values - such loops have an empty iteration domain.
+struct RemoveEmptyParallelLoops : public OpRewritePattern {
+  using OpRewritePattern::OpRewritePattern;
+
+  LogicalResult matchAndRewrite(ParallelOp op,
+PatternRewriter &rewriter) const override {
+for (auto dim : llvm::zip(op.lowerBound(), op.upperBound())) {
+  if (std::get<0>(dim) == std::get<1>(dim)) {
+rewriter.replaceOp(op, op.initVals());
+return success();
+  }
+}
+return failure();
+  }
+};
+
 } // namespace
 
 void ParallelOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
  MLIRContext *context) {
-  results.insert(context);
+  results.insert(
+  context);
 }
 
 
//===--===//

diff  --git a/mlir/test/Dialect/SCF/canonicalize.mlir 
b/mlir/test/Dialect/SCF/canonicalize.mlir
index faac86b94cdb..d57563461241 100644
--- a/mlir/test/Dialect/SCF/canonicalize.mlir
+++ b/mlir/test/Dialect/SCF/canonicalize.mlir
@@ -32,30 +32,6 @@ func @single_iteration(%A: memref) {
 
 // -
 
-func @no_iteration(%A: memref) {
-  %c0 = constant 0 : index
-  %c1 = constant 1 : index
-  scf.parallel (%i0, %i1) = (%c0, %c0) to (%c1, %c0) step (%c1, %c1) {
-%c42 = constant 42 : i32
-store %c42, %A[%i0, %i1] : memref
-scf.yield
-  }
-  return
-}
-
-// CHECK-LABEL:   func @no_iteration(
-// CHECK-SAME:[[ARG0:%.*]]: memref) {
-// CHECK:   [[C0:%.*]] = constant 0 : index
-// CHECK:   [[C1:%.*]] = constant 1 : index
-// CHECK:   [[C42:%.*]] = constant 42 : i32
-// CHECK:   scf.parallel ([[V1:%.*]]) = ([[C0]]) to ([[C0]]) step 
([[C1]]) {
-// CHECK: store [[C42]], [[ARG0]]{{\[}}[[C0]], [[V1]]] : 
memref
-// CHECK: scf.yield
-// CHECK:   }
-// CHECK:   return
-
-// -
-
 func @one_unused(%cond: i1) -> (index) {
   %c0 = constant 0 : index
   %c1 = constant 1 : index
@@ -241,6 +217,22 @@ func @remove_zero_iteration_loop() {
   return
 }
 
+// CHECK-LABEL: @remove_zero_iteration_loop_vals
+func @remove_zero_iteration_loop_vals(%arg0: index) {
+  %c2 = constant 2 : index
+  // CHECK: %[[INIT:.*]] = "test.init"
+  %init = "test.init"() : () -> i32
+  // CHECK-NOT: scf.for
+  // CHECK-NOT: test.op
+  %0 = scf.for %i = %arg0 to %arg0 step %c2 iter_args(%arg = %init) -> (i32) {
+%1 = "test.op"(%i, %arg) : (index, i32) -> i32
+scf.yield %1 : i32
+  }
+  // CHECK: "test.consume"(%[[INIT]])
+  "test.consume"(%0) : (i32) -> ()
+  return
+}
+
 // CHECK-LABEL: @replace_single_iteration_loop
 func @replace_single_iteration_loop() {
   // CHECK: %[[LB:.*]] = constant 42
@@ -278,3 +270,24 @@ func @replace_single_iteration_loop_non_unit_step() {
   "test.consume"(%0) : (i32) -> ()
   return
 }
+
+// CHECK-LABEL: @remove_empty_parallel_loop
+func @remove_empty_parallel_loop(%lb: index, %ub: index, %s: index) {
+  // CHECK: %[[INIT:.*]] = "test.init"
+  %init = "test.init"() : () -> f32
+  // CHECK-NOT: s

[llvm-branch-commits] [llvm] 410c150 - [test] Update PR reference in testcase [NFC]

2020-11-23 Thread Mikael Holmen via llvm-branch-commits

Author: Mikael Holmen
Date: 2020-11-23T15:12:50+01:00
New Revision: 410c150abb20b71895ea75749b1393647c7ec79f

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

LOG: [test] Update PR reference in testcase [NFC]

The testcase was added in faf848ac32 to test the fix of PR 47969, but
it was named pr48980 (which happens to be the TR number in my downstream
issue system).

Added: 


Modified: 
llvm/test/Transforms/Inline/inline-ptrtoint-different-sizes.ll

Removed: 




diff  --git a/llvm/test/Transforms/Inline/inline-ptrtoint-
diff erent-sizes.ll b/llvm/test/Transforms/Inline/inline-ptrtoint-
diff erent-sizes.ll
index b412504a800c..818792fb55a9 100644
--- a/llvm/test/Transforms/Inline/inline-ptrtoint-
diff erent-sizes.ll
+++ b/llvm/test/Transforms/Inline/inline-ptrtoint-
diff erent-sizes.ll
@@ -1,25 +1,25 @@
 ; RUN: opt < %s -inline -S | FileCheck %s
 
 ; InlineCost used to have problems with the ptrtoint, leading to
-; crashes when visiting the trunc in pr48908_help and the icmp in
+; crashes when visiting the trunc in pr47969_help and the icmp in
 ; pr38500_help.
 
 target datalayout = "p:16:16"
 target triple = "x86_64-unknown-linux-gnu"
 
-define void @pr48980_help(i16* %p) {
+define void @pr47969_help(i16* %p) {
   %cast = ptrtoint i16* %p to i32
   %sub = sub i32 %cast, %cast
   %conv = trunc i32 %sub to i16
   ret void
 }
 
-define void @pr48980(i16* %x) {
-  call void @pr48980_help(i16* %x)
+define void @pr47969(i16* %x) {
+  call void @pr47969_help(i16* %x)
   ret void
 }
 
-; CHECK-LABEL: @pr48980(i16* %x)
+; CHECK-LABEL: @pr47969(i16* %x)
 ; CHECK-NOT: call
 ; CHECK: ret void
 



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


[llvm-branch-commits] [clang] 72a9f36 - Remove automatic traversal from forEach matcher

2020-11-23 Thread Stephen Kelly via llvm-branch-commits

Author: Stephen Kelly
Date: 2020-11-23T14:27:47Z
New Revision: 72a9f365e9933d68645f796592932a27d11bbfd0

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

LOG: Remove automatic traversal from forEach matcher

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/lib/ASTMatchers/ASTMatchFinder.cpp
clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8da9490f7b6f..737f165c80cb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -234,6 +234,9 @@ AST Matchers
   has been changed to no longer match on template instantiations or on
   implicit nodes which are not spelled in the source.
 
+- The behavior of the forEach() matcher was changed to not internally ignore
+  implicit and parenthesis nodes.
+
 clang-format
 
 

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h 
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 480a12b0dafb..fdc4f66f5d9c 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -679,8 +679,7 @@ class ASTMatchFinder {
 
   template 
   bool matchesChildOf(const T &Node, const DynTypedMatcher &Matcher,
-  BoundNodesTreeBuilder *Builder, TraversalKind Traverse,
-  BindKind Bind) {
+  BoundNodesTreeBuilder *Builder, BindKind Bind) {
 static_assert(std::is_base_of::value ||
   std::is_base_of::value ||
   std::is_base_of::value ||
@@ -689,7 +688,7 @@ class ASTMatchFinder {
   std::is_base_of::value,
   "unsupported type for recursive matching");
 return matchesChildOf(DynTypedNode::create(Node), getASTContext(), Matcher,
-  Builder, Traverse, Bind);
+  Builder, Bind);
   }
 
   template 
@@ -730,7 +729,7 @@ class ASTMatchFinder {
   virtual bool matchesChildOf(const DynTypedNode &Node, ASTContext &Ctx,
   const DynTypedMatcher &Matcher,
   BoundNodesTreeBuilder *Builder,
-  TraversalKind Traverse, BindKind Bind) = 0;
+  BindKind Bind) = 0;
 
   virtual bool matchesDescendantOf(const DynTypedNode &Node, ASTContext &Ctx,
const DynTypedMatcher &Matcher,
@@ -1367,7 +1366,6 @@ class HasMatcher : public MatcherInterface {
   bool matches(const T &Node, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder) const override {
 return Finder->matchesChildOf(Node, this->InnerMatcher, Builder,
-  TraversalKind::TK_AsIs,
   ASTMatchFinder::BK_First);
   }
 };
@@ -1392,7 +1390,6 @@ class ForEachMatcher : public MatcherInterface {
BoundNodesTreeBuilder *Builder) const override {
 return Finder->matchesChildOf(
 Node, this->InnerMatcher, Builder,
-TraversalKind::TK_IgnoreImplicitCastsAndParentheses,
 ASTMatchFinder::BK_All);
   }
 };

diff  --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp 
b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index e43778b4fe8f..cc9537144524 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -95,12 +95,11 @@ class MatchChildASTVisitor
   // matching the descendants.
   MatchChildASTVisitor(const DynTypedMatcher *Matcher, ASTMatchFinder *Finder,
BoundNodesTreeBuilder *Builder, int MaxDepth,
-   TraversalKind Traversal, bool IgnoreImplicitChildren,
+   bool IgnoreImplicitChildren,
ASTMatchFinder::BindKind Bind)
   : Matcher(Matcher), Finder(Finder), Builder(Builder), CurrentDepth(0),
-MaxDepth(MaxDepth), Traversal(Traversal),
-IgnoreImplicitChildren(IgnoreImplicitChildren), Bind(Bind),
-Matches(false) {}
+MaxDepth(MaxDepth), IgnoreImplicitChildren(IgnoreImplicitChildren),
+Bind(Bind), Matches(false) {}
 
   // Returns true if a match is found in the subtree rooted at the
   // given AST node. This is done via a set of mutually recursive
@@ -168,10 +167,6 @@ class MatchChildASTVisitor
 Finder->getASTContext().getParentMapContext().traverseIgnored(
 ExprNode);
 }
-if (Traversal == TraversalKind::TK_IgnoreImplicitCastsAndParentheses) {
-  if (Expr *ExprNode = dyn_cast_or_

[llvm-branch-commits] [clang] f052cf4 - Update mode used in traverse() examples

2020-11-23 Thread Stephen Kelly via llvm-branch-commits

Author: Stephen Kelly
Date: 2020-11-23T14:27:48Z
New Revision: f052cf494f07a33af5aa7c680cfe0bfcca24beae

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

LOG: Update mode used in traverse() examples

traverse() predates the IgnoreUnlessSpelledInSource mode. Update example
and test code to use the newer mode.

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

Added: 


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

Removed: 




diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index fbc53ed743a2..9f14ab9f4c5b 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -5567,7 +5567,7 @@ AST Traversal Matchers
   int i = 3.0;
   }
 The matcher
-  traverse(TK_IgnoreImplicitCastsAndParentheses,
+  traverse(TK_IgnoreUnlessSpelledInSource,
 varDecl(hasInitializer(floatLiteral().bind("init")))
   )
 matches the variable declaration with "init" bound to the "3.0".

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index d8b049f45341..0da469ea0f78 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -782,7 +782,7 @@ AST_POLYMORPHIC_MATCHER_P(
 /// \endcode
 /// The matcher
 /// \code
-///   traverse(TK_IgnoreImplicitCastsAndParentheses,
+///   traverse(TK_IgnoreUnlessSpelledInSource,
 /// varDecl(hasInitializer(floatLiteral().bind("init")))
 ///   )
 /// \endcode

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
index 004c667f053d..b0ec1719daaf 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1873,8 +1873,8 @@ void foo()
   auto Matcher = varDecl(hasInitializer(floatLiteral()));
 
   EXPECT_TRUE(notMatches(VarDeclCode, traverse(TK_AsIs, Matcher)));
-  EXPECT_TRUE(matches(VarDeclCode,
-  traverse(TK_IgnoreImplicitCastsAndParentheses, 
Matcher)));
+  EXPECT_TRUE(
+  matches(VarDeclCode, traverse(TK_IgnoreUnlessSpelledInSource, Matcher)));
 
   auto ParentMatcher = floatLiteral(hasParent(varDecl(hasName("i";
 
@@ -2715,14 +2715,14 @@ void foo()
 )cpp";
 
   EXPECT_TRUE(
-  matches(Code, traverse(TK_IgnoreImplicitCastsAndParentheses,
+  matches(Code, traverse(TK_IgnoreUnlessSpelledInSource,
  callExpr(has(callExpr(traverse(
  TK_AsIs, callExpr(has(implicitCastExpr(
   has(floatLiteral(;
 
   EXPECT_TRUE(matches(
   Code,
-  traverse(TK_IgnoreImplicitCastsAndParentheses,
+  traverse(TK_IgnoreUnlessSpelledInSource,
traverse(TK_AsIs, implicitCastExpr(has(floatLiteral()));
 }
 
@@ -2738,8 +2738,7 @@ void constructImplicit() {
 }
   )cpp";
 
-  auto Matcher =
-  traverse(TK_IgnoreImplicitCastsAndParentheses, implicitCastExpr());
+  auto Matcher = traverse(TK_IgnoreUnlessSpelledInSource, implicitCastExpr());
 
   // Verfiy that it does not segfault
   EXPECT_FALSE(matches(Code, Matcher));
@@ -2766,7 +2765,7 @@ void foo()
   EXPECT_TRUE(matches(
   Code,
   functionDecl(anyOf(hasDescendant(Matcher),
- traverse(TK_IgnoreImplicitCastsAndParentheses,
+ traverse(TK_IgnoreUnlessSpelledInSource,
   functionDecl(hasDescendant(Matcher)));
 }
 



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


[llvm-branch-commits] [clang-tools-extra] 5e18018 - Remove the IgnoreImplicitCastsAndParentheses traversal kind

2020-11-23 Thread Stephen Kelly via llvm-branch-commits

Author: Stephen Kelly
Date: 2020-11-23T14:27:48Z
New Revision: 5e1801813d93210acae84ff3c68a01512c2df9bc

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

LOG: Remove the IgnoreImplicitCastsAndParentheses traversal kind

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

Added: 


Modified: 
clang-tools-extra/clang-query/QueryParser.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/ASTNodeTraverser.h
clang/include/clang/AST/ASTTypeTraits.h
clang/lib/AST/ParentMapContext.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-query/QueryParser.cpp 
b/clang-tools-extra/clang-query/QueryParser.cpp
index 2f1965e77ab4..45a0d425b7c2 100644
--- a/clang-tools-extra/clang-query/QueryParser.cpp
+++ b/clang-tools-extra/clang-query/QueryParser.cpp
@@ -134,8 +134,6 @@ QueryRef QueryParser::parseSetTraversalKind(
   unsigned Value =
   LexOrCompleteWord(this, ValStr)
   .Case("AsIs", ast_type_traits::TK_AsIs)
-  .Case("IgnoreImplicitCastsAndParentheses",
-ast_type_traits::TK_IgnoreImplicitCastsAndParentheses)
   .Case("IgnoreUnlessSpelledInSource",
 ast_type_traits::TK_IgnoreUnlessSpelledInSource)
   .Default(~0u);

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 5e78de2b0edc..c99a589b1212 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -57,7 +57,7 @@ The improvements are...
 Improvements to clang-query
 ---
 
-The improvements are...
+- The IgnoreImplicitCastsAndParentheses traversal mode has been removed.
 
 Improvements to clang-rename
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 737f165c80cb..d62c62dad3d2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -234,6 +234,9 @@ AST Matchers
   has been changed to no longer match on template instantiations or on
   implicit nodes which are not spelled in the source.
 
+- The TK_IgnoreImplicitCastsAndParentheses traversal kind was removed. It
+  is recommended to use TK_IgnoreUnlessSpelledInSource instead.
+
 - The behavior of the forEach() matcher was changed to not internally ignore
   implicit and parenthesis nodes.
 

diff  --git a/clang/include/clang/AST/ASTNodeTraverser.h 
b/clang/include/clang/AST/ASTNodeTraverser.h
index 4f33b0c67e94..6f7affe66273 100644
--- a/clang/include/clang/AST/ASTNodeTraverser.h
+++ b/clang/include/clang/AST/ASTNodeTraverser.h
@@ -126,9 +126,6 @@ class ASTNodeTraverser
 switch (Traversal) {
 case TK_AsIs:
   break;
-case TK_IgnoreImplicitCastsAndParentheses:
-  S = E->IgnoreParenImpCasts();
-  break;
 case TK_IgnoreUnlessSpelledInSource:
   S = E->IgnoreUnlessSpelledInSource();
   break;

diff  --git a/clang/include/clang/AST/ASTTypeTraits.h 
b/clang/include/clang/AST/ASTTypeTraits.h
index bd817b75bb84..034260cc8ed3 100644
--- a/clang/include/clang/AST/ASTTypeTraits.h
+++ b/clang/include/clang/AST/ASTTypeTraits.h
@@ -40,10 +40,6 @@ enum TraversalKind {
   /// Will traverse all child nodes.
   TK_AsIs,
 
-  /// Will not traverse implicit casts and parentheses.
-  /// Corresponds to Expr::IgnoreParenImpCasts()
-  TK_IgnoreImplicitCastsAndParentheses,
-
   /// Ignore AST nodes not written in the source
   TK_IgnoreUnlessSpelledInSource
 };
@@ -542,8 +538,6 @@ using ASTNodeKind = ::clang::ASTNodeKind;
 using TraversalKind = ::clang::TraversalKind;
 
 constexpr TraversalKind TK_AsIs = ::clang::TK_AsIs;
-constexpr TraversalKind TK_IgnoreImplicitCastsAndParentheses =
-::clang::TK_IgnoreImplicitCastsAndParentheses;
 constexpr TraversalKind TK_IgnoreUnlessSpelledInSource =
 ::clang::TK_IgnoreUnlessSpelledInSource;
 } // namespace ast_type_traits

diff  --git a/clang/lib/AST/ParentMapContext.cpp 
b/clang/lib/AST/ParentMapContext.cpp
index c80c8bc23e00..cb4995312efa 100644
--- a/clang/lib/AST/ParentMapContext.cpp
+++ b/clang/lib/AST/ParentMapContext.cpp
@@ -36,8 +36,6 @@ Expr *ParentMapContext::traverseIgnored(Expr *E) const {
   switch (Traversal) {
   case TK_AsIs:
 return E;
-  case TK_IgnoreImplicitCastsAndParentheses:
-return E->IgnoreParenImpCasts();
   case TK_IgnoreUnlessSpelledInSource:
 return E->IgnoreUnlessSpelledInSource();
   }



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


[llvm-branch-commits] [llvm] 000400c - Fix speling in comments. NFC.

2020-11-23 Thread Jay Foad via llvm-branch-commits

Author: Jay Foad
Date: 2020-11-23T14:43:24Z
New Revision: 000400ca0aeb32e347eefd110a4ed58ebc23d333

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

LOG: Fix speling in comments. NFC.

Added: 


Modified: 
llvm/include/llvm/ADT/DenseMap.h
llvm/lib/Analysis/GlobalsModRef.cpp
llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
llvm/lib/Target/AMDGPU/SIDefines.h

Removed: 




diff  --git a/llvm/include/llvm/ADT/DenseMap.h 
b/llvm/include/llvm/ADT/DenseMap.h
index 34d397cc9793..42e4fc84175c 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -954,7 +954,7 @@ class SmallDenseMap
   std::swap(*LHSB, *RHSB);
   continue;
 }
-// Swap separately and handle any assymetry.
+// Swap separately and handle any asymmetry.
 std::swap(LHSB->getFirst(), RHSB->getFirst());
 if (hasLHSValue) {
   ::new (&RHSB->getSecond()) ValueT(std::move(LHSB->getSecond()));

diff  --git a/llvm/lib/Analysis/GlobalsModRef.cpp 
b/llvm/lib/Analysis/GlobalsModRef.cpp
index 37a345885b33..1a42c69b8b66 100644
--- a/llvm/lib/Analysis/GlobalsModRef.cpp
+++ b/llvm/lib/Analysis/GlobalsModRef.cpp
@@ -44,7 +44,7 @@ STATISTIC(NumIndirectGlobalVars, "Number of indirect global 
objects");
 // An option to enable unsafe alias results from the GlobalsModRef analysis.
 // When enabled, GlobalsModRef will provide no-alias results which in extremely
 // rare cases may not be conservatively correct. In particular, in the face of
-// transforms which cause assymetry between how effective getUnderlyingObject
+// transforms which cause asymmetry between how effective getUnderlyingObject
 // is for two pointers, it may produce incorrect results.
 //
 // These unsafe results have been returned by GMR for many years without

diff  --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
index 351f532ad4a3..cbbb0755b124 100644
--- a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
@@ -1649,7 +1649,7 @@ void AArch64FrameLowering::emitEpilogue(MachineFunction 
&MF,
 // If the prologue didn't contain any SEH opcodes and didn't set the
 // MF.hasWinCFI() flag, assume the epilogue won't either, and skip the
 // EpilogStart - to avoid generating CFI for functions that don't need it.
-// (And as we didn't generate any prologue at all, it would be assymetrical
+// (And as we didn't generate any prologue at all, it would be asymmetrical
 // to the epilogue.) By the end of the function, we assert that
 // HasWinCFI is equal to MF.hasWinCFI(), to verify this assumption.
 HasWinCFI = true;

diff  --git a/llvm/lib/Target/AMDGPU/SIDefines.h 
b/llvm/lib/Target/AMDGPU/SIDefines.h
index 0abd96dc4607..65c486ef73e2 100644
--- a/llvm/lib/Target/AMDGPU/SIDefines.h
+++ b/llvm/lib/Target/AMDGPU/SIDefines.h
@@ -33,7 +33,7 @@ enum : uint64_t {
   VOP2 = 1 << 8,
   VOPC = 1 << 9,
 
- // TODO: Should this be spilt into VOP3 a and b?
+  // TODO: Should this be spilt into VOP3 a and b?
   VOP3 = 1 << 10,
   VOP3P = 1 << 12,
 



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


[llvm-branch-commits] [llvm] 590aaa5 - [VE] Remove magic numbers 176

2020-11-23 Thread Kazushi Marukawa via llvm-branch-commits

Author: Kazushi (Jam) Marukawa
Date: 2020-11-24T00:13:24+09:00
New Revision: 590aaa5077330e97203999f08946cb2c25dd56d1

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

LOG: [VE] Remove magic numbers 176

Remove magic numbers 176 from VE source codes and update comments.

Reviewed By: simoll

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

Added: 


Modified: 
llvm/lib/Target/VE/VEFrameLowering.cpp
llvm/lib/Target/VE/VEISelLowering.cpp
llvm/lib/Target/VE/VEInstrInfo.cpp
llvm/lib/Target/VE/VESubtarget.cpp
llvm/lib/Target/VE/VESubtarget.h

Removed: 




diff  --git a/llvm/lib/Target/VE/VEFrameLowering.cpp 
b/llvm/lib/Target/VE/VEFrameLowering.cpp
index 8be298b46f0d..e15e4130f74b 100644
--- a/llvm/lib/Target/VE/VEFrameLowering.cpp
+++ b/llvm/lib/Target/VE/VEFrameLowering.cpp
@@ -323,8 +323,8 @@ void VEFrameLowering::emitPrologue(MachineFunction &MF,
   // Get the number of bytes to allocate from the FrameInfo
   uint64_t NumBytes = MFI.getStackSize();
 
-  // The VE ABI requires a reserved 176 bytes area at the top
-  // of stack as described in VESubtarget.cpp.  So, we adjust it here.
+  // The VE ABI requires a reserved area at the top of stack as described
+  // in VESubtarget.cpp.  So, we adjust it here.
   NumBytes = STI.getAdjustedFrameSize(NumBytes);
 
   // Finally, ensure that the size is sufficiently aligned for the

diff  --git a/llvm/lib/Target/VE/VEISelLowering.cpp 
b/llvm/lib/Target/VE/VEISelLowering.cpp
index eb47d01afc77..30b6aa96edec 100644
--- a/llvm/lib/Target/VE/VEISelLowering.cpp
+++ b/llvm/lib/Target/VE/VEISelLowering.cpp
@@ -341,7 +341,7 @@ SDValue VETargetLowering::LowerFormalArguments(
   MachineFunction &MF = DAG.getMachineFunction();
 
   // Get the base offset of the incoming arguments stack space.
-  unsigned ArgsBaseOffset = 176;
+  unsigned ArgsBaseOffset = Subtarget->getRsaSize();
   // Get the size of the preserved arguments area
   unsigned ArgsPreserved = 64;
 
@@ -411,7 +411,7 @@ SDValue VETargetLowering::LowerFormalArguments(
 // The registers are exhausted. This argument was passed on the stack.
 assert(VA.isMemLoc());
 // The CC_VE_Full/Half functions compute stack offsets relative to the
-// beginning of the arguments area at %fp+176.
+// beginning of the arguments area at %fp + the size of reserved area.
 unsigned Offset = VA.getLocMemOffset() + ArgsBaseOffset;
 unsigned ValSize = VA.getValVT().getSizeInBits() / 8;
 
@@ -446,7 +446,7 @@ SDValue VETargetLowering::LowerFormalArguments(
   // TODO: need to calculate offset correctly once we support f128.
   unsigned ArgOffset = ArgLocs.size() * 8;
   VEMachineFunctionInfo *FuncInfo = MF.getInfo();
-  // Skip the 176 bytes of register save area.
+  // Skip the reserved area at the top of stack.
   FuncInfo->setVarArgsFrameOffset(ArgOffset + ArgsBaseOffset);
 
   return Chain;
@@ -489,7 +489,7 @@ SDValue 
VETargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
   CLI.IsTailCall = false;
 
   // Get the base offset of the outgoing arguments stack space.
-  unsigned ArgsBaseOffset = 176;
+  unsigned ArgsBaseOffset = Subtarget->getRsaSize();
   // Get the size of the preserved arguments area
   unsigned ArgsPreserved = 8 * 8u;
 
@@ -631,8 +631,7 @@ SDValue 
VETargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
 
 // Create a store off the stack pointer for this argument.
 SDValue StackPtr = DAG.getRegister(VE::SX11, PtrVT);
-// The argument area starts at %fp+176 in the callee frame,
-// %sp+176 in ours.
+// The argument area starts at %fp/%sp + the size of reserved area.
 SDValue PtrOff =
 DAG.getIntPtrConstant(VA.getLocMemOffset() + ArgsBaseOffset, DL);
 PtrOff = DAG.getNode(ISD::ADD, DL, PtrVT, StackPtr, PtrOff);

diff  --git a/llvm/lib/Target/VE/VEInstrInfo.cpp 
b/llvm/lib/Target/VE/VEInstrInfo.cpp
index c6c77aface52..eb375ccca371 100644
--- a/llvm/lib/Target/VE/VEInstrInfo.cpp
+++ b/llvm/lib/Target/VE/VEInstrInfo.cpp
@@ -915,8 +915,8 @@ bool VEInstrInfo::expandGetStackTopPseudo(MachineInstr &MI) 
const {
   const MachineFrameInfo &MFI = MF.getFrameInfo();
   const VEFrameLowering &TFL = *STI.getFrameLowering();
 
-  // The VE ABI requires a reserved 176 bytes area at the top
-  // of stack as described in VESubtarget.cpp.  So, we adjust it here.
+  // The VE ABI requires a reserved area at the top of stack as described
+  // in VEFrameLowering.cpp.  So, we adjust it here.
   unsigned NumBytes = STI.getAdjustedFrameSize(0);
 
   // Also adds the size of parameter area.

diff  --git a/llvm/lib/Target/VE/VESubtarget.cpp 
b/llvm/lib/Target/VE/VESubtarget.cpp
index a484e7c2c7aa..3406a613e89d 100644
--- a/llvm/lib/Target/VE/VESubtarget.cpp
+++ b/llvm/lib/Target/VE/VESubtarget.cpp
@@ -50,9 +

[llvm-branch-commits] [mlir] c6b2c17 - [mlir] Add a print function for memref<*xi64>.

2020-11-23 Thread Alexander Belyaev via llvm-branch-commits

Author: Alexander Belyaev
Date: 2020-11-23T16:17:41+01:00
New Revision: c6b2c17e9c28afec7ec6ea10d78d7705d2ec49ea

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

LOG: [mlir] Add a print function for memref<*xi64>.

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

Added: 


Modified: 
mlir/include/mlir/ExecutionEngine/RunnerUtils.h
mlir/lib/ExecutionEngine/RunnerUtils.cpp

Removed: 




diff  --git a/mlir/include/mlir/ExecutionEngine/RunnerUtils.h 
b/mlir/include/mlir/ExecutionEngine/RunnerUtils.h
index 02e5c153bdbd..4f3cc7753a48 100644
--- a/mlir/include/mlir/ExecutionEngine/RunnerUtils.h
+++ b/mlir/include/mlir/ExecutionEngine/RunnerUtils.h
@@ -225,6 +225,8 @@ _mlir_ciface_print_memref_f64(UnrankedMemRefType 
*M);
 
 extern "C" MLIR_RUNNERUTILS_EXPORT void print_memref_i32(int64_t rank,
  void *ptr);
+extern "C" MLIR_RUNNERUTILS_EXPORT void print_memref_i64(int64_t rank,
+ void *ptr);
 extern "C" MLIR_RUNNERUTILS_EXPORT void print_memref_f32(int64_t rank,
  void *ptr);
 extern "C" MLIR_RUNNERUTILS_EXPORT void print_memref_f64(int64_t rank,

diff  --git a/mlir/lib/ExecutionEngine/RunnerUtils.cpp 
b/mlir/lib/ExecutionEngine/RunnerUtils.cpp
index 6df88b2e11ac..19315d7d1e6d 100644
--- a/mlir/lib/ExecutionEngine/RunnerUtils.cpp
+++ b/mlir/lib/ExecutionEngine/RunnerUtils.cpp
@@ -32,6 +32,10 @@ extern "C" void 
_mlir_ciface_print_memref_i32(UnrankedMemRefType *M) {
   impl::printMemRef(*M);
 }
 
+extern "C" void _mlir_ciface_print_memref_i64(UnrankedMemRefType *M) {
+  impl::printMemRef(*M);
+}
+
 extern "C" void _mlir_ciface_print_memref_f32(UnrankedMemRefType *M) {
   impl::printMemRef(*M);
 }
@@ -45,6 +49,11 @@ extern "C" void print_memref_i32(int64_t rank, void *ptr) {
   _mlir_ciface_print_memref_i32(&descriptor);
 }
 
+extern "C" void print_memref_i64(int64_t rank, void *ptr) {
+  UnrankedMemRefType descriptor = {rank, ptr};
+  _mlir_ciface_print_memref_i64(&descriptor);
+}
+
 extern "C" void print_memref_f32(int64_t rank, void *ptr) {
   UnrankedMemRefType descriptor = {rank, ptr};
   _mlir_ciface_print_memref_f32(&descriptor);



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


[llvm-branch-commits] [clang-tools-extra] 76bd444 - Fix tests for clang-query completion

2020-11-23 Thread Stephen Kelly via llvm-branch-commits

Author: Stephen Kelly
Date: 2020-11-23T15:23:13Z
New Revision: 76bde36197465f1c72f4b6f1d59721012a59

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

LOG: Fix tests for clang-query completion

Added: 


Modified: 
clang-tools-extra/unittests/clang-query/QueryParserTest.cpp

Removed: 




diff  --git a/clang-tools-extra/unittests/clang-query/QueryParserTest.cpp 
b/clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
index 4a0a80146af4..78d6f593777d 100644
--- a/clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
+++ b/clang-tools-extra/unittests/clang-query/QueryParserTest.cpp
@@ -232,14 +232,12 @@ TEST_F(QueryParserTest, Complete) {
   EXPECT_EQ("dump", Comps[3].DisplayText);
 
   Comps = QueryParser::complete("set traversal ", 14, QS);
-  ASSERT_EQ(3u, Comps.size());
+  ASSERT_EQ(2u, Comps.size());
 
   EXPECT_EQ("AsIs ", Comps[0].TypedText);
   EXPECT_EQ("AsIs", Comps[0].DisplayText);
-  EXPECT_EQ("IgnoreImplicitCastsAndParentheses ", Comps[1].TypedText);
-  EXPECT_EQ("IgnoreImplicitCastsAndParentheses", Comps[1].DisplayText);
-  EXPECT_EQ("IgnoreUnlessSpelledInSource ", Comps[2].TypedText);
-  EXPECT_EQ("IgnoreUnlessSpelledInSource", Comps[2].DisplayText);
+  EXPECT_EQ("IgnoreUnlessSpelledInSource ", Comps[1].TypedText);
+  EXPECT_EQ("IgnoreUnlessSpelledInSource", Comps[1].DisplayText);
 
   Comps = QueryParser::complete("match while", 11, QS);
   ASSERT_EQ(1u, Comps.size());



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


[llvm-branch-commits] [llvm] b955c7e - [VE] VE Vector Predicated SDNode, vector add isel and tests

2020-11-23 Thread Simon Moll via llvm-branch-commits

Author: Simon Moll
Date: 2020-11-23T17:17:07+01:00
New Revision: b955c7e63001068f7829827c327dc96ca9a05e8c

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

LOG: [VE] VE Vector Predicated SDNode, vector add isel and tests

VE Vector Predicated (VVP) SDNodes form an intermediate layer between VE
vector instructions and the initial SDNodes.

We introduce 'vvp_add' with isel and tests as the first of these VVP
nodes. VVP nodes have a mask and explicit vector length operand, which
we will make proper use of later.

Reviewed By: kaz7

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

Added: 
llvm/lib/Target/VE/VVPInstrInfo.td
llvm/lib/Target/VE/VVPInstrPatternsVec.td
llvm/lib/Target/VE/VVPNodes.def
llvm/test/CodeGen/VE/Vector/vec_add.ll

Modified: 
llvm/lib/Target/VE/VEISelLowering.cpp
llvm/lib/Target/VE/VEISelLowering.h
llvm/lib/Target/VE/VEInstrInfo.td
llvm/lib/Target/VE/VEInstrPatternsVec.td

Removed: 




diff  --git a/llvm/lib/Target/VE/VEISelLowering.cpp 
b/llvm/lib/Target/VE/VEISelLowering.cpp
index 30b6aa96edec..cc7f5f6800ec 100644
--- a/llvm/lib/Target/VE/VEISelLowering.cpp
+++ b/llvm/lib/Target/VE/VEISelLowering.cpp
@@ -254,8 +254,17 @@ void VETargetLowering::initSPUActions() {
 }
 
 void VETargetLowering::initVPUActions() {
-  for (MVT LegalVecVT : AllVectorVTs)
+  for (MVT LegalVecVT : AllVectorVTs) {
 setOperationAction(ISD::BUILD_VECTOR, LegalVecVT, Custom);
+// Translate all vector instructions with legal element types to VVP_*
+// nodes.
+// TODO We will custom-widen into VVP_* nodes in the future. While we are
+// buildling the infrastructure for this, we only do this for legal vector
+// VTs.
+#define ADD_VVP_OP(VVP_NAME, ISD_NAME) 
\
+  setOperationAction(ISD::ISD_NAME, LegalVecVT, Custom);
+#include "VVPNodes.def"
+  }
 }
 
 SDValue
@@ -846,6 +855,10 @@ const char *VETargetLowering::getTargetNodeName(unsigned 
Opcode) const {
 TARGET_NODE_CASE(VEC_BROADCAST)
 TARGET_NODE_CASE(RET_FLAG)
 TARGET_NODE_CASE(GLOBAL_BASE_REG)
+
+// Register the VVP_* SDNodes.
+#define ADD_VVP_OP(VVP_NAME, ...) TARGET_NODE_CASE(VVP_NAME)
+#include "VVPNodes.def"
   }
 #undef TARGET_NODE_CASE
   return nullptr;
@@ -1403,6 +1416,10 @@ SDValue VETargetLowering::LowerOperation(SDValue Op, 
SelectionDAG &DAG) const {
 return lowerVASTART(Op, DAG);
   case ISD::VAARG:
 return lowerVAARG(Op, DAG);
+
+#define ADD_BINARY_VVP_OP(VVP_NAME, ISD_NAME) case ISD::ISD_NAME:
+#include "VVPNodes.def"
+return lowerToVVP(Op, DAG);
   }
 }
 /// } Custom Lower
@@ -1665,3 +1682,53 @@ bool VETargetLowering::hasAndNot(SDValue Y) const {
   // It's ok for generic registers.
   return true;
 }
+
+/// \returns the VVP_* SDNode opcode corresponsing to \p OC.
+static Optional getVVPOpcode(unsigned OC) {
+  switch (OC) {
+#define ADD_VVP_OP(VVPNAME, SDNAME)
\
+  case VEISD::VVPNAME: 
\
+  case ISD::SDNAME:
\
+return VEISD::VVPNAME;
+#include "VVPNodes.def"
+  }
+  return None;
+}
+
+SDValue VETargetLowering::lowerToVVP(SDValue Op, SelectionDAG &DAG) const {
+  // Can we represent this as a VVP node.
+  auto OCOpt = getVVPOpcode(Op->getOpcode());
+  if (!OCOpt.hasValue())
+return SDValue();
+  unsigned VVPOC = OCOpt.getValue();
+
+  // The representative and legalized vector type of this operation.
+  EVT OpVecVT = Op.getValueType();
+  EVT LegalVecVT = getTypeToTransformTo(*DAG.getContext(), OpVecVT);
+
+  // Materialize the VL parameter.
+  SDLoc DL(Op);
+  SDValue AVL = DAG.getConstant(OpVecVT.getVectorNumElements(), DL, MVT::i32);
+  MVT MaskVT = MVT::v256i1;
+  SDValue ConstTrue = DAG.getConstant(1, DL, MVT::i32);
+  SDValue Mask = DAG.getNode(VEISD::VEC_BROADCAST, DL, MaskVT,
+ ConstTrue); // emit a VEISD::VEC_BROADCAST here.
+
+  // Categories we are interested in.
+  bool IsBinaryOp = false;
+
+  switch (VVPOC) {
+#define ADD_BINARY_VVP_OP(VVPNAME, ...)
\
+  case VEISD::VVPNAME: 
\
+IsBinaryOp = true; 
\
+break;
+#include "VVPNodes.def"
+  }
+
+  if (IsBinaryOp) {
+assert(LegalVecVT.isSimple());
+return DAG.getNode(VVPOC, DL, LegalVecVT, Op->getOperand(0),
+   Op->getOperand(1), Mask, AVL);
+  }
+  llvm_unreachable("lowerToVVP called for unexpected SDNode.");
+}

diff  --git a/llvm/lib/Target/VE/VEISelLowering.h 
b/llvm/lib/Target/VE/VEISelLowering.h
index e12bef882d8a..9924db647f46 100644
--- a/llvm/lib/Target/VE/

[llvm-branch-commits] [llvm] b23e84f - [TableGen] Eliminte source location from CodeInit

2020-11-23 Thread Paul C. Anagnostopoulos via llvm-branch-commits

Author: Paul C. Anagnostopoulos
Date: 2020-11-23T11:30:13-05:00
New Revision: b23e84ffcff8957e095599a6b7fd3f24ecf1f18c

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

LOG: [TableGen] Eliminte source location from CodeInit

Step 1 in eliminating the 'code' type.

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

Added: 


Modified: 
llvm/docs/TableGen/BackGuide.rst
llvm/include/llvm/TableGen/Record.h
llvm/lib/TableGen/Record.cpp
llvm/lib/TableGen/TGParser.cpp
llvm/unittests/TableGen/CodeExpanderTest.cpp
llvm/utils/TableGen/GICombinerEmitter.cpp
llvm/utils/TableGen/GlobalISel/CodeExpander.cpp

Removed: 




diff  --git a/llvm/docs/TableGen/BackGuide.rst 
b/llvm/docs/TableGen/BackGuide.rst
index 59a1ed1450f1..515eeab2403a 100644
--- a/llvm/docs/TableGen/BackGuide.rst
+++ b/llvm/docs/TableGen/BackGuide.rst
@@ -336,14 +336,11 @@ The class provides the following additional functions.
 The ``CodeInit`` class is a subclass of ``TypedInit``. Its instances
 represent arbitrary-length strings produced from ``code`` literals in the
 TableGen files. It includes a data member that contains a ``StringRef`` of
-the value. It also includes a data member specifying the source code
-location of the code string.
+the value.
 
 The class provides the usual ``get()`` and ``getValue()`` functions. The
 latter function returns the ``StringRef``.
 
-The ``getLoc()`` function returns the source code location.
-
 
 ``DagInit``
 ~~~

diff  --git a/llvm/include/llvm/TableGen/Record.h 
b/llvm/include/llvm/TableGen/Record.h
index 2ff4df462b04..567908f93e55 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -597,7 +597,13 @@ class IntInit : public TypedInit {
 
 /// "foo" - Represent an initialization by a string value.
 class StringInit : public TypedInit {
+  enum StringFormat {
+SF_String,  // Format as "text"
+SF_Code,// Format as [{text}]
+  };
+
   StringRef Value;
+  StringFormat Format;
 
   explicit StringInit(StringRef V)
   : TypedInit(IK_StringInit, StringRecTy::get()), Value(V) {}
@@ -630,11 +636,10 @@ class StringInit : public TypedInit {
 
 class CodeInit : public TypedInit {
   StringRef Value;
-  SMLoc Loc;
 
-  explicit CodeInit(StringRef V, const SMLoc &Loc)
+  explicit CodeInit(StringRef V)
   : TypedInit(IK_CodeInit, static_cast(CodeRecTy::get())),
-Value(V), Loc(Loc) {}
+Value(V) {}
 
 public:
   CodeInit(const StringInit &) = delete;
@@ -644,10 +649,9 @@ class CodeInit : public TypedInit {
 return I->getKind() == IK_CodeInit;
   }
 
-  static CodeInit *get(StringRef, const SMLoc &Loc);
+  static CodeInit *get(StringRef);
 
   StringRef getValue() const { return Value; }
-  const SMLoc &getLoc() const { return Loc; }
 
   Init *convertInitializerTo(RecTy *Ty) const override;
 
@@ -1649,6 +1653,9 @@ class Record {
   // High-level methods useful to tablegen back-ends
   //
 
+  ///Return the source location for the named field.
+  SMLoc getFieldLoc(StringRef FieldName) const;
+
   /// Return the initializer for a value with the specified name,
   /// or throw an exception if the field does not exist.
   Init *getValueInit(StringRef FieldName) const;

diff  --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index 43b906ea2248..a8f0e19a2bbd 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -514,20 +514,13 @@ IntInit::convertInitializerBitRange(ArrayRef 
Bits) const {
   return BitsInit::get(NewBits);
 }
 
-CodeInit *CodeInit::get(StringRef V, const SMLoc &Loc) {
-  static StringSet ThePool(Allocator);
+CodeInit *CodeInit::get(StringRef V) {
+  static StringMap ThePool(Allocator);
 
-  CodeInitsConstructed++;
-
-  // Unlike StringMap, StringSet doesn't accept empty keys.
-  if (V.empty())
-return new (Allocator) CodeInit("", Loc);
-
-  // Location tracking prevents us from de-duping CodeInits as we're never
-  // called with the same string and same location twice. However, we can at
-  // least de-dupe the strings for a modest saving.
-  auto &Entry = *ThePool.insert(V).first;
-  return new(Allocator) CodeInit(Entry.getKey(), Loc);
+  auto &Entry = *ThePool.insert(std::make_pair(V, nullptr)).first;
+  if (!Entry.second)
+Entry.second = new(Allocator) CodeInit(Entry.getKey());
+  return Entry.second;
 }
 
 StringInit *StringInit::get(StringRef V) {
@@ -543,7 +536,7 @@ Init *StringInit::convertInitializerTo(RecTy *Ty) const {
   if (isa(Ty))
 return const_cast(this);
   if (isa(Ty))
-return CodeInit::get(getValue(), SMLoc());
+return CodeInit::get(getValue());
 
   return nullptr;
 }
@@ -1046,8 +1039,6 @@ Init *BinOpInit::Fold(Record *CurRec) const {
   default: llvm_unreachable("un

[llvm-branch-commits] [llvm] 3a1c6ce - [AArch64] Add tests for masked.gather costs.

2020-11-23 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2020-11-23T17:33:27Z
New Revision: 3a1c6cec15e32e4aa5593ce624915bda790dadff

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

LOG: [AArch64] Add tests for masked.gather costs.

Added: 


Modified: 
llvm/test/Analysis/CostModel/AArch64/mem-op-cost-model.ll
llvm/test/Transforms/SLPVectorizer/AArch64/gather-cost.ll

Removed: 




diff  --git a/llvm/test/Analysis/CostModel/AArch64/mem-op-cost-model.ll 
b/llvm/test/Analysis/CostModel/AArch64/mem-op-cost-model.ll
index 3a4e0f080a49..300339313f06 100644
--- a/llvm/test/Analysis/CostModel/AArch64/mem-op-cost-model.ll
+++ b/llvm/test/Analysis/CostModel/AArch64/mem-op-cost-model.ll
@@ -86,3 +86,27 @@ define <8 x i64> @load_512(<8 x i64>* %ptr) {
   %out = load <8 x i64>, <8 x i64>* %ptr
   ret <8 x i64> %out
 }
+
+define <4 x i8> @gather_load_4xi8(<4 x i8*> %ptrs) {
+; CHECK: gather_load_4xi8
+; CHECK-NEON:Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i8> @llvm.masked.gather.v4i8.v4p0i8
+; CHECK-SVE-128: Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i8> @llvm.masked.gather.v4i8.v4p0i8
+; CHECK-SVE-256: Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i8> @llvm.masked.gather.v4i8.v4p0i8
+; CHECK-SVE-512: Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i8> @llvm.masked.gather.v4i8.v4p0i8
+;
+  %lv = call <4 x i8> @llvm.masked.gather.v4i8.v4p0i8(<4 x i8*> %ptrs, i32 1, 
<4 x i1> , <4 x i8> undef)
+  ret <4 x i8> %lv
+}
+declare <4 x i8> @llvm.masked.gather.v4i8.v4p0i8(<4 x i8*>, i32 immarg, <4 x 
i1>, <4 x i8>)
+
+define <4 x i32> @gather_load_4xi32(<4 x i32*> %ptrs) {
+; CHECK: gather_load_4xi32
+; CHECK-NEON:Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i32> @llvm.masked.gather.v4i32.v4p0i32
+; CHECK-SVE-128: Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i32> @llvm.masked.gather.v4i32.v4p0i32
+; CHECK-SVE-256: Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i32> @llvm.masked.gather.v4i32.v4p0i32
+; CHECK-SVE-512: Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i32> @llvm.masked.gather.v4i32.v4p0i32
+;
+  %lv = call <4 x i32> @llvm.masked.gather.v4i32.v4p0i32(<4 x i32*> %ptrs, i32 
1, <4 x i1> , <4 x i32> undef)
+  ret <4 x i32> %lv
+}
+declare <4 x i32> @llvm.masked.gather.v4i32.v4p0i32(<4 x i32*>, i32 immarg, <4 
x i1>, <4 x i32>)

diff  --git a/llvm/test/Transforms/SLPVectorizer/AArch64/gather-cost.ll 
b/llvm/test/Transforms/SLPVectorizer/AArch64/gather-cost.ll
index 4c2d51b188e6..021f9d5d9419 100644
--- a/llvm/test/Transforms/SLPVectorizer/AArch64/gather-cost.ll
+++ b/llvm/test/Transforms/SLPVectorizer/AArch64/gather-cost.ll
@@ -1,7 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -S -slp-vectorizer -instcombine -pass-remarks-output=%t | 
FileCheck %s
 ; RUN: cat %t | FileCheck -check-prefix=REMARK %s
-; RUN: opt < %s -S -passes='slp-vectorizer,instcombine' 
-pass-remarks-output=%t | FileCheck %s
+; RUN: opt < %s -S -aa-pipeline=basic-aa -passes='slp-vectorizer,instcombine' 
-pass-remarks-output=%t | FileCheck %s
 ; RUN: cat %t | FileCheck -check-prefix=REMARK %s
 
 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
@@ -12,6 +12,11 @@ target triple = "aarch64--linux-gnu"
 ; REMARK-NEXT:- String: 'Vectorized horizontal reduction with cost '
 ; REMARK-NEXT:- Cost: '-7'
 ;
+; REMARK-LABEL: Function: gather_load
+; REMARK:   Args:
+; REMARK-NEXT:- String: 'Stores SLP vectorized with cost
+; REMARK-NEXT:- Cost: '-2'
+
 define internal i32 @gather_multiple_use(i32 %a, i32 %b, i32 %c, i32 %d) {
 ; CHECK-LABEL: @gather_multiple_use(
 ; CHECK-NEXT:[[TMP1:%.*]] = insertelement <4 x i32> undef, i32 [[C:%.*]], 
i32 0
@@ -51,3 +56,41 @@ define internal i32 @gather_multiple_use(i32 %a, i32 %b, i32 
%c, i32 %d) {
   %tmp22 = add i32 %tmp21, %tmp19
   ret i32 %tmp22
 }
+
+@data = global [6 x [258 x i8]] zeroinitializer, align 1
+define void @gather_load(i16* noalias %ptr) {
+; CHECK-LABEL: @gather_load(
+; CHECK-NEXT:[[ARRAYIDX182:%.*]] = getelementptr inbounds i16, i16* 
[[PTR:%.*]], i64 1
+; CHECK-NEXT:[[TMP1:%.*]] = call <4 x i8> 
@llvm.masked.gather.v4i8.v4p0i8(<4 x i8*> , i32 1, <4 x i1> , <4 x i8> undef)
+; CHECK-NEXT:[[TMP2:%.*]] = zext <4 x i8> [[TMP1]] to <4 x i16>
+; CHECK-NEXT:[[TMP3:%.*]] = add nuw nsw <4 x i16> [[TMP2]], 
+; CHECK-NEXT:[[TMP4:%.*]] = bitcast i16* [[ARRAYIDX182]] to <4 x i16>*
+; CHECK-NEXT:store <4 x i16> [[TMP3]], <4 x i16>* [[TMP4]], align 2
+; CHECK-NEXT:ret void
+;
+  %arrayidx182 = getelementptr inbounds 

[llvm-branch-commits] [mlir] 0c5cff3 - Add userData to the diagnostic handler C API

2020-11-23 Thread via llvm-branch-commits

Author: George
Date: 2020-11-23T09:52:45-08:00
New Revision: 0c5cff300ffa1d5cc55f2b11e4546f18b3389aa6

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

LOG: Add userData to the diagnostic handler C API

Previously, there was no way to add context to the diagnostic engine via the C 
API. Adding this ability makes it much easier to reason about memory ownership, 
particularly in reference-counted languages such as Swift. There are more 
details in the review comments.

Reviewed By: ftynse, mehdi_amini

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

Added: 


Modified: 
mlir/include/mlir-c/Diagnostics.h
mlir/lib/CAPI/IR/Diagnostics.cpp
mlir/test/CAPI/ir.c

Removed: 




diff  --git a/mlir/include/mlir-c/Diagnostics.h 
b/mlir/include/mlir-c/Diagnostics.h
index cc6d15be6061..14206b8454e7 100644
--- a/mlir/include/mlir-c/Diagnostics.h
+++ b/mlir/include/mlir-c/Diagnostics.h
@@ -40,12 +40,14 @@ typedef enum MlirDiagnosticSeverity MlirDiagnosticSeverity;
 /// Opaque identifier of a diagnostic handler, useful to detach a handler.
 typedef uint64_t MlirDiagnosticHandlerID;
 
-/** Diagnostic handler type. Acceps a reference to a diagnostic, which is only
- * guaranteed to be live during the call. If the handler processed the
- * diagnostic completely, it is expected to return success. Otherwise, it is
- * expected to return failure to indicate that other handlers should attempt to
- * process the diagnostic. */
-typedef MlirLogicalResult (*MlirDiagnosticHandler)(MlirDiagnostic);
+/** Diagnostic handler type. Accepts a reference to a diagnostic, which is only
+ * guaranteed to be live during the call. The handler is passed the `userData`
+ * that was provided when the handler was attached to a context. If the handler
+ * processed the diagnostic completely, it is expected to return success.
+ * Otherwise, it is expected to return failure to indicate that other handlers
+ * should attempt to process the diagnostic. */
+typedef MlirLogicalResult (*MlirDiagnosticHandler)(MlirDiagnostic,
+   void *userData);
 
 /// Prints a diagnostic using the provided callback.
 MLIR_CAPI_EXPORTED void mlirDiagnosticPrint(MlirDiagnostic diagnostic,
@@ -71,9 +73,15 @@ mlirDiagnosticGetNote(MlirDiagnostic diagnostic, intptr_t 
pos);
 
 /** Attaches the diagnostic handler to the context. Handlers are invoked in the
  * reverse order of attachment until one of them processes the diagnostic
- * completely. Returns an identifier that can be used to detach the handler. */
+ * completely. When a handler is invoked it is passed the `userData` that was
+ * provided when it was attached. If non-NULL, `deleteUserData` is called once
+ * the system no longer needs to call the handler (for instance after the
+ * handler is detached or the context is destroyed). Returns an identifier that
+ * can be used to detach the handler.
+ */
 MLIR_CAPI_EXPORTED MlirDiagnosticHandlerID mlirContextAttachDiagnosticHandler(
-MlirContext context, MlirDiagnosticHandler handler);
+MlirContext context, MlirDiagnosticHandler handler, void *userData,
+void (*deleteUserData)(void *));
 
 /** Detaches an attached diagnostic handler from the context given its
  * identifier. */

diff  --git a/mlir/lib/CAPI/IR/Diagnostics.cpp 
b/mlir/lib/CAPI/IR/Diagnostics.cpp
index 9cf422bb1b4f..2ed05a5a06e6 100644
--- a/mlir/lib/CAPI/IR/Diagnostics.cpp
+++ b/mlir/lib/CAPI/IR/Diagnostics.cpp
@@ -51,14 +51,19 @@ MlirDiagnostic mlirDiagnosticGetNote(MlirDiagnostic 
diagnostic, intptr_t pos) {
   return wrap(*std::next(unwrap(diagnostic).getNotes().begin(), pos));
 }
 
-MlirDiagnosticHandlerID
-mlirContextAttachDiagnosticHandler(MlirContext context,
-   MlirDiagnosticHandler handler) {
+static void deleteUserDataNoop(void *userData) {}
+
+MlirDiagnosticHandlerID mlirContextAttachDiagnosticHandler(
+MlirContext context, MlirDiagnosticHandler handler, void *userData,
+void (*deleteUserData)(void *)) {
   assert(handler && "unexpected null diagnostic handler");
+  if (deleteUserData == NULL)
+deleteUserData = deleteUserDataNoop;
+  std::shared_ptr sharedUserData(userData, deleteUserData);
   DiagnosticEngine::HandlerID id =
   unwrap(context)->getDiagEngine().registerHandler(
-  [handler](Diagnostic &diagnostic) {
-return unwrap(handler(wrap(diagnostic)));
+  [handler, sharedUserData](Diagnostic &diagnostic) {
+return unwrap(handler(wrap(diagnostic), sharedUserData.get()));
   });
   return static_cast(id);
 }

diff  --git a/mlir/test/CAPI/ir.c b/mlir/test/CAPI/ir.c
index 83d66555dba7..821ead52c166 100644
--- a/mlir/test/CAPI/ir.c
+++ b/mlir/test/CAPI/ir.c
@@ -1248,31 +1248,37 @@ int registerOnlyS

[llvm-branch-commits] [clang] e0e334a - [mac/arm] make clang/test/Driver/clang_f_opts.c pass consistently

2020-11-23 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-11-23T12:56:52-05:00
New Revision: e0e334a9c1ace7dd9339ca6cb5866ff7b7885e11

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

LOG: [mac/arm] make clang/test/Driver/clang_f_opts.c pass consistently

Part of PR46644, see comment 7/8.

Added: 


Modified: 
clang/test/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/test/Driver/clang_f_opts.c 
b/clang/test/Driver/clang_f_opts.c
index 27380413b7fe..123ad7e2aa99 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -541,6 +541,12 @@
 // CHECK-NO-RECORD-GCC-SWITCHES-NOT: "-record-command-line"
 // CHECK-RECORD-GCC-SWITCHES-ERROR: error: unsupported option 
'-frecord-command-line' for target
 // Test when clang is in a path containing a space.
+// The initial `rm` is a workaround for https://openradar.appspot.com/FB8914243
+// (Scenario: Run tests once, `clang` gets copied and run at new location and 
signature
+// is cached at the new clang's inode, then clang is changed, tests run again, 
old signature
+// is still cached with old clang's inode, so it won't execute this time. 
Removing the dir
+// first guarantees a new inode without old cache entries.)
+// RUN: rm -rf "%t.r/with spaces"
 // RUN: mkdir -p "%t.r/with spaces"
 // RUN: cp %clang "%t.r/with spaces/clang"
 // RUN: "%t.r/with spaces/clang" -### -S -target x86_64-unknown-linux 
-frecord-gcc-switches %s 2>&1 | FileCheck 
-check-prefix=CHECK-RECORD-GCC-SWITCHES-ESCAPED %s



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


[llvm-branch-commits] [llvm] 4252f77 - [SelectionDAG][ARM][AArch64][Hexagon][RISCV][X86] Add SDNPCommutative to fma and fmad nodes in tablegen. Remove explicit commuted patterns from targets.

2020-11-23 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-11-23T10:09:20-08:00
New Revision: 4252f7773a5b98b825d17e5f77c7d349cb2fb7c7

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

LOG: [SelectionDAG][ARM][AArch64][Hexagon][RISCV][X86] Add SDNPCommutative to 
fma and fmad nodes in tablegen. Remove explicit commuted patterns from targets.

X86 was already specially marking fma as commutable which allowed
tablegen to autogenerate commuted patterns. This moves it to the target
independent definition and fix up the targets to remove now
unneeded patterns.

Unfortunately, the tests change because the commuted version of
the patterns are generating operands in a different than the
explicit patterns.

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

Added: 


Modified: 
llvm/include/llvm/Target/TargetSelectionDAG.td
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/lib/Target/ARM/ARMInstrMVE.td
llvm/lib/Target/ARM/ARMInstrVFP.td
llvm/lib/Target/Hexagon/HexagonPatterns.td
llvm/lib/Target/RISCV/RISCVInstrInfoD.td
llvm/lib/Target/RISCV/RISCVInstrInfoF.td
llvm/lib/Target/X86/X86InstrAVX512.td
llvm/lib/Target/X86/X86InstrFMA.td
llvm/lib/Target/X86/X86InstrFragmentsSIMD.td
llvm/test/CodeGen/AArch64/GlobalISel/select-with-no-legality-check.mir
llvm/test/CodeGen/AArch64/arm64-vmul.ll
llvm/test/CodeGen/ARM/GlobalISel/arm-instruction-select-combos.mir
llvm/test/CodeGen/ARM/GlobalISel/select-pr35926.mir
llvm/test/CodeGen/ARM/fp16-fusedMAC.ll
llvm/test/CodeGen/RISCV/double-arith.ll
llvm/test/CodeGen/RISCV/float-arith.ll
llvm/test/CodeGen/Thumb2/mve-float32regloops.ll
llvm/test/CodeGen/Thumb2/mve-fma-loops.ll
llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll

Removed: 




diff  --git a/llvm/include/llvm/Target/TargetSelectionDAG.td 
b/llvm/include/llvm/Target/TargetSelectionDAG.td
index 20a51cea35ec..e37cdc8d301e 100644
--- a/llvm/include/llvm/Target/TargetSelectionDAG.td
+++ b/llvm/include/llvm/Target/TargetSelectionDAG.td
@@ -440,8 +440,8 @@ def fsub   : SDNode<"ISD::FSUB"   , SDTFPBinOp>;
 def fmul   : SDNode<"ISD::FMUL"   , SDTFPBinOp, [SDNPCommutative]>;
 def fdiv   : SDNode<"ISD::FDIV"   , SDTFPBinOp>;
 def frem   : SDNode<"ISD::FREM"   , SDTFPBinOp>;
-def fma: SDNode<"ISD::FMA", SDTFPTernaryOp>;
-def fmad   : SDNode<"ISD::FMAD"   , SDTFPTernaryOp>;
+def fma: SDNode<"ISD::FMA", SDTFPTernaryOp, [SDNPCommutative]>;
+def fmad   : SDNode<"ISD::FMAD"   , SDTFPTernaryOp, [SDNPCommutative]>;
 def fabs   : SDNode<"ISD::FABS"   , SDTFPUnaryOp>;
 def fminnum: SDNode<"ISD::FMINNUM", SDTFPBinOp,
   [SDNPCommutative, SDNPAssociative]>;
@@ -498,7 +498,7 @@ def strict_fdiv   : SDNode<"ISD::STRICT_FDIV",
 def strict_frem   : SDNode<"ISD::STRICT_FREM",
SDTFPBinOp, [SDNPHasChain]>;
 def strict_fma: SDNode<"ISD::STRICT_FMA",
-   SDTFPTernaryOp, [SDNPHasChain]>;
+   SDTFPTernaryOp, [SDNPHasChain, 
SDNPCommutative]>;
 def strict_fsqrt  : SDNode<"ISD::STRICT_FSQRT",
SDTFPUnaryOp, [SDNPHasChain]>;
 def strict_fsin   : SDNode<"ISD::STRICT_FSIN",

diff  --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td 
b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index 8798890b2fe4..88392b258d94 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -3738,18 +3738,6 @@ def : Pat<(f32 (fma (fneg FPR32:$Rn), FPR32:$Rm, (fneg 
FPR32:$Ra))),
 def : Pat<(f64 (fma (fneg FPR64:$Rn), FPR64:$Rm, (fneg FPR64:$Ra))),
   (FNMADDDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
 
-// And here "(-a) + b*(-c)"
-
-let Predicates = [HasNEON, HasFullFP16] in
-def : Pat<(f16 (fma FPR16:$Rn, (fneg FPR16:$Rm), (fneg FPR16:$Ra))),
-  (FNMADDHrrr FPR16:$Rn, FPR16:$Rm, FPR16:$Ra)>;
-
-def : Pat<(f32 (fma FPR32:$Rn, (fneg FPR32:$Rm), (fneg FPR32:$Ra))),
-  (FNMADDSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
-
-def : Pat<(f64 (fma FPR64:$Rn, (fneg FPR64:$Rm), (fneg FPR64:$Ra))),
-  (FNMADDDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
-
 
//===--===//
 // Floating point comparison instructions.
 
//===--===//
@@ -4067,17 +4055,6 @@ defm FMLA : SIMDThreeSameVectorFPTied<0, 0, 0b001, 
"fmla",
 defm FMLS : SIMDThreeSameVectorFPTied<0, 1, 0b001, "fmls",
 TriOpFrag<(fma node:$MHS, (fneg node:$RHS), node:$LHS)> >;
 
-// The following def pats catch the case where the LHS of an FMA is negated.
-// The TriOpFrag above 

[llvm-branch-commits] [mlir] e65a5e5 - [mlir][Linalg] Fuse sequence of Linalg operation (on buffers)

2020-11-23 Thread via llvm-branch-commits

Author: MaheshRavishankar
Date: 2020-11-23T10:30:51-08:00
New Revision: e65a5e5b00a37700a79e0a9f2fb1c1e60a2584bf

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

LOG: [mlir][Linalg] Fuse sequence of Linalg operation (on buffers)

Enhance the tile+fuse logic to allow fusing a sequence of operations.

Make sure the value used to obtain tile shape is a
SubViewOp/SubTensorOp. Current logic used to get the bounds of loop
depends on the use of `getOrCreateRange` method on `SubViewOp` and
`SubTensorOp`. Make sure that the value/dim used to compute the range
is from such ops.  This fix is a reasonable WAR, but a btter fix would
be to make `getOrCreateRange` method be a method of `ViewInterface`.

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

Added: 
mlir/test/Dialect/Linalg/fusion-sequence.mlir

Modified: 
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
mlir/test/Dialect/Linalg/fusion-pattern.mlir
mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp
mlir/tools/mlir-opt/mlir-opt.cpp

Removed: 




diff  --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h 
b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index b7cfa6f023a7..d2d6cef1954d 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -37,14 +37,6 @@ struct TiledLinalgOp {
   SmallVector tensorResults;
 };
 
-struct TiledAndFusedLinalgOps {
-  LinalgOp op;
-  SmallVector fusedProducers;
-  SmallVector originalProducers;
-  SmallVector fusedLoops;
-  SmallVector unfusedLoops;
-};
-
 /// Populates patterns for vectorization of all ConvN-D ops.
 void populateConvVectorizationPatterns(
 MLIRContext *context, SmallVectorImpl &patterns,
@@ -73,14 +65,11 @@ void populateLinalgBufferizePatterns(MLIRContext *context,
 Optional tileLinalgOp(OpBuilder &b, LinalgOp op,
  const LinalgTilingOptions &options);
 
-/// Tile and fuse the `op` with its producers. The tile and fuse proceeds in
-/// three steps
-/// - Find tile loops that are fusable with its producer tile loops (a.k.a. 
tile
-///   + fuse loops).
-/// - Tile just these loops of the consumer (root operation) and fuse with
-///   the producer.
-/// - Tile again the tiled consumer operation produced above to do rest of
-///   the tiling specified by the `tilingOptions`.
+/// Fuse a sequence of linalg operations (`ops`) using tile-and-fuse. This
+/// proceeds as follows:
+/// - Find outer parallel loops in these ops that can be fused.
+/// - Tile fusable outer parallel loops of the last operation in the sequence.
+/// - Fuse the remaining operations with the tiled operation
 ///
 /// For example, consider the sequence of matmul below
 ///
@@ -107,36 +96,39 @@ Optional tileLinalgOp(OpBuilder &b, 
LinalgOp op,
 /// : memref<256x32xf32> to memref<16x32xf32, #map0>
 ///   %3 = subview %arg1[0, 0] [32, 32] [1, 1]
 /// : memref<32x32xf32> to memref<32x32xf32, #map1>
+///   %4 = subview %arg3[0, 0] [32, 32] [1, 1]
+/// : memref<32x32xf32> to memref<32x32xf32, #map1>
 ///   linalg.matmul
 /// ins(%2, %3 : memref<16x32xf32, #map0>, memref<32x32xf32, #map1>)
 /// outs(%0 : memref<16x32xf32, #map0>)
-///   scf.parallel (%arg6) = (%c0) to (%c32) step (%c8) {
-///   scf.for %arg7 = %c0 to %c32 step %c4 {
-/// %4 = subview %0[0, %arg7] [16, 4] [1, 1]
-///   : memref<16x32xf32, #map0> to memref<16x4xf32, #map0>
-/// %5 = subview %arg3[%arg7, %arg6] [4, 8] [1, 1]
-///   : memref<32x32xf32> to memref<4x8xf32, #map0>
-/// %6 = subview %1[0, %arg6] [16, 8] [1, 1]
-///   : memref<16x32xf32, #map0> to memref<16x8xf32, #map0>
-/// linalg.matmul
-///   ins(%4, %5 : memref<16x4xf32, #map0>, memref<4x8xf32, #map0>)
-///   outs(%6 : memref<16x8xf32, #map0>)
-/// }
-/// scf.yield
-///   }
-///   scf.yield
+///   linalg.matmul
+/// ins(%0, %4 : memref<16x4xf32, #map0>, memref<4x8xf32, #map0>)
+/// outs(%1 : memref<16x8xf32, #map0>)
 /// }
 ///
-/// The following tiling options are handled 
diff erently in tile+fuse (compared
-/// to tile only)
+/// `tilingOptions` are used to tile the corresponding operation in `ops` (the
+/// size of the former should be same as size of the latter. Based on how
+/// tile+fuse is implemented, the fused loops are generated based on the last
+/// operation in the sequence. For example, the tile sizes for the fused loops
+/// is obtained from `tilingOptions.back()`. The following tiling options are
+/// handled 
diff erently in tile+fuse (compared to tile only)
 /// - Interchange of the tiling loops is not supported right now.
-/// - Dis

[llvm-branch-commits] [clang] 47eb5ce - [mac/arm] fix clang/test/Driver/darwin-ld-dedup.c

2020-11-23 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-11-23T13:32:29-05:00
New Revision: 47eb5ce19ab10bcfe00af04e6a6e39613e2cb3c9

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

LOG: [mac/arm] fix clang/test/Driver/darwin-ld-dedup.c

The test needs an object file, which it currenty gets with
`-target x86_64-apple-darwin10`.  Rather than adding `REQUIRES: X86`, create
the object file via yaml2obj. This way, the test runs and passes even if the
host arch isn't x86 and only the host arch is built.

Part of PR46644.

Added: 
clang/test/Driver/Inputs/empty-x86_64-apple-darwin.yaml

Modified: 
clang/test/CMakeLists.txt
clang/test/Driver/darwin-ld-dedup.c
clang/test/lit.cfg.py
llvm/utils/gn/secondary/clang/test/BUILD.gn

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 1eb434e192db..4e9a1840fec3 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -124,6 +124,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-readobj
 llvm-symbolizer
 opt
+yaml2obj
 )
 
   if(TARGET llvm-lto)

diff  --git a/clang/test/Driver/Inputs/empty-x86_64-apple-darwin.yaml 
b/clang/test/Driver/Inputs/empty-x86_64-apple-darwin.yaml
new file mode 100644
index ..c4561050b8b6
--- /dev/null
+++ b/clang/test/Driver/Inputs/empty-x86_64-apple-darwin.yaml
@@ -0,0 +1,44 @@
+# Created by `clang -target x86_64-apple-darwin10 -c -x c /dev/null -o - | 
obj2yaml`.
+--- !mach-o
+FileHeader:
+  magic:   0xFEEDFACF
+  cputype: 0x107
+  cpusubtype:  0x3
+  filetype:0x1
+  ncmds:   2
+  sizeofcmds:  176
+  flags:   0x2000
+  reserved:0x0
+LoadCommands:
+  - cmd: LC_SEGMENT_64
+cmdsize: 152
+segname: ''
+vmaddr:  0
+vmsize:  0
+fileoff: 208
+filesize:0
+maxprot: 7
+initprot:7
+nsects:  1
+flags:   0
+Sections:
+  - sectname:__text
+segname: __TEXT
+addr:0x0
+size:0
+offset:  0xD0
+align:   0
+reloff:  0x0
+nreloc:  0
+flags:   0x8000
+reserved1:   0x0
+reserved2:   0x0
+reserved3:   0x0
+content: ''
+  - cmd: LC_BUILD_VERSION
+cmdsize: 24
+platform:1
+minos:   720896
+sdk: 720896
+ntools:  0
+...

diff  --git a/clang/test/Driver/darwin-ld-dedup.c 
b/clang/test/Driver/darwin-ld-dedup.c
index a06ca7bebe57..1d866f40291a 100644
--- a/clang/test/Driver/darwin-ld-dedup.c
+++ b/clang/test/Driver/darwin-ld-dedup.c
@@ -29,7 +29,7 @@
 // Do *not* add -no_deduplicate when no -O option is specified and this is 
just a link
 // (since we can't imply -O0)
 // RUN: rm -f %t.o %t.bin
-// RUN: %clang -target x86_64-apple-darwin10 -c -o %t.o %s
+// RUN: yaml2obj %S/Inputs/empty-x86_64-apple-darwin.yaml -o %t.o
 // RUN: %clang -target x86_64-apple-darwin10 %t.o -### -mlinker-version=262 \
 // RUN:   -o %t.bin 2>&1 | FileCheck -check-prefix=LINK_DEDUP %s
 // RUN: %clang -target x86_64-apple-darwin10 %t.o -### -mlinker-version=262 \

diff  --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 1a6e73ed9783..863ab444fb02 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -64,7 +64,7 @@
 
 tools = [
 'apinotes-test', 'c-index-test', 'clang-
diff ', 'clang-format',
-'clang-tblgen', 'opt', 'llvm-ifs',
+'clang-tblgen', 'opt', 'llvm-ifs', 'yaml2obj',
 ToolSubst('%clang_extdef_map', command=FindTool(
 'clang-extdef-mapping'), unresolved='ignore'),
 ]

diff  --git a/llvm/utils/gn/secondary/clang/test/BUILD.gn 
b/llvm/utils/gn/secondary/clang/test/BUILD.gn
index 9219d2d7bfad..8f436ac10586 100644
--- a/llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -168,6 +168,7 @@ group("test") {
 "//llvm/utils/count",
 "//llvm/utils/llvm-lit",
 "//llvm/utils/not",
+"//llvm/tools/yaml2obj",
   ]
   if (clang_enable_arcmt) {
 deps += [



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


[llvm-branch-commits] [mlir] 11ea2e2 - [mlir][Linalg] NFC: Expose some utility functions used for promotion.

2020-11-23 Thread via llvm-branch-commits

Author: MaheshRavishankar
Date: 2020-11-23T10:35:42-08:00
New Revision: 11ea2e2448a5f071a04463f94b7bccfe0a32d264

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

LOG: [mlir][Linalg] NFC: Expose some utility functions used for promotion.

Exposing some utility functions from Linalg to allow for promotion of
fused views outside of the core tile+fuse logic.
This is an alternative to patch D91322 which adds the promotion logic
to the tileAndFuse method. Downside with that approach is that it is
not easily customizable based on needs.

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

Added: 


Modified: 
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp

Removed: 




diff  --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h 
b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index d2d6cef1954d..d67e81ceab87 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -234,6 +234,20 @@ struct LinalgPromotionOptions {
   }
 };
 
+/// Creates a new buffer using the `allocationFn` provided. The size of this
+/// buffer is the smallest constant bounding size along each dimension that can
+/// be computed for the size of the result of `subView`. Returns the allocated
+/// buffer as `fullLocalView` and the view that matches the size of the result
+/// of subview operation as `partialLocalView`.
+struct PromotionInfo {
+  Value fullLocalView;
+  Value partialLocalView;
+};
+Optional
+promoteSubviewAsNewBuffer(OpBuilder &b, Location loc, SubViewOp subView,
+  AllocBufferCallbackFn allocationFn,
+  OperationFolder *folder = nullptr);
+
 /// Promotes the `subViews` into a new buffer allocated at the insertion point
 /// `b`. Promotion occurs in 3 steps:
 ///   1. Create a new buffer for a full tile (i.e. not clipped at the 
boundary).

diff  --git a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h 
b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
index a6b8afdce9d3..fb916d3962e3 100644
--- a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
+++ b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
@@ -17,6 +17,7 @@
 #include "mlir/Dialect/StandardOps/EDSC/Intrinsics.h"
 #include "mlir/Dialect/StandardOps/IR/Ops.h"
 
+#include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/SetVector.h"
 
 using mlir::edsc::intrinsics::AffineIndexedValue;
@@ -82,6 +83,13 @@ bool isProducerLastWriteOfView(const LinalgDependenceGraph 
&graph,
 bool isFusableInto(const LinalgDependenceGraph &graph, LinalgOp consumer,
Value consumedView, LinalgOp producer);
 
+using FusableOpDependencesTy = llvm::MapVector<
+Operation *,
+SmallVector>;
+FusableOpDependencesTy
+findAllFusableDependences(ArrayRef ops,
+  const LinalgDependenceGraph &dependenceGraph);
+
 /// Fuses producer into consumer if the producer is structurally feasible and
 /// the fusion would not violate dependencies.
 /// Implements the fusion part of the "tileAndFuse on buffers"

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
index 8ec71eec75b8..3160e8f8be0b 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
@@ -542,10 +542,6 @@ static AffineMap 
pruneReductionDimsFromMap(ArrayRef iteratorTypes,
   return getProjectedMap(map, projectedDims);
 }
 
-using FusableOpDependencesTy = llvm::MapVector<
-Operation *,
-SmallVector>;
-
 /// Returns the mapping from iterations in the consumer that write to the same
 /// location as the iterations in the producer. To do so use
 /// - indexing map of the fused view in the consumer : consumerIndexMap
@@ -729,10 +725,9 @@ collectFusableLoops(ArrayRef ops,
   return fusableLoops;
 }
 
-/// Find all dependences that are to be fusable.
-static FusableOpDependencesTy
-findAllFusableDependences(ArrayRef ops,
-  const LinalgDependenceGraph &dependenceGraph) {
+/// Find all dependences that are fusable.
+FusableOpDependencesTy mlir::linalg::findAllFusableDependences(
+ArrayRef ops, const LinalgDependenceGraph &dependenceGraph) {
   FusableOpDependencesTy fusableDependences;
   // TODO: Currently fusion would not be legal if the fusable dependence is to
   // the same producer but 
diff erent indexing map in the consumer. Fix this, but
@@ -836,6 +831,7 @@ fuseOperations(OpBuilder &builder, LinalgOp tiledOp,
 fusedLoopsAndRanges[loop] = getRangeFromOperandShape(
 builder, tiledOp.getLoc(), shapeDim.shape, shapeDim.dimen

[llvm-branch-commits] [llvm] 14c0185 - [AArch64] Add scatter cost model tests.

2020-11-23 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2020-11-23T18:36:56Z
New Revision: 14c0185bfeb64f714a0b45f104942531e09e

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

LOG: [AArch64] Add scatter cost model tests.

Added: 


Modified: 
llvm/test/Analysis/CostModel/AArch64/mem-op-cost-model.ll

Removed: 




diff  --git a/llvm/test/Analysis/CostModel/AArch64/mem-op-cost-model.ll 
b/llvm/test/Analysis/CostModel/AArch64/mem-op-cost-model.ll
index 300339313f06..9e9081fe4aea 100644
--- a/llvm/test/Analysis/CostModel/AArch64/mem-op-cost-model.ll
+++ b/llvm/test/Analysis/CostModel/AArch64/mem-op-cost-model.ll
@@ -87,8 +87,9 @@ define <8 x i64> @load_512(<8 x i64>* %ptr) {
   ret <8 x i64> %out
 }
 
-define <4 x i8> @gather_load_4xi8(<4 x i8*> %ptrs) {
-; CHECK: gather_load_4xi8
+declare <4 x i8> @llvm.masked.gather.v4i8.v4p0i8(<4 x i8*>, i32 immarg, <4 x 
i1>, <4 x i8>)
+define <4 x i8> @gather_load_4xi8_constant_mask(<4 x i8*> %ptrs) {
+; CHECK: gather_load_4xi8_constant_mask
 ; CHECK-NEON:Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i8> @llvm.masked.gather.v4i8.v4p0i8
 ; CHECK-SVE-128: Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i8> @llvm.masked.gather.v4i8.v4p0i8
 ; CHECK-SVE-256: Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i8> @llvm.masked.gather.v4i8.v4p0i8
@@ -97,10 +98,44 @@ define <4 x i8> @gather_load_4xi8(<4 x i8*> %ptrs) {
   %lv = call <4 x i8> @llvm.masked.gather.v4i8.v4p0i8(<4 x i8*> %ptrs, i32 1, 
<4 x i1> , <4 x i8> undef)
   ret <4 x i8> %lv
 }
-declare <4 x i8> @llvm.masked.gather.v4i8.v4p0i8(<4 x i8*>, i32 immarg, <4 x 
i1>, <4 x i8>)
 
-define <4 x i32> @gather_load_4xi32(<4 x i32*> %ptrs) {
-; CHECK: gather_load_4xi32
+define <4 x i8> @gather_load_4xi8_variable_mask(<4 x i8*> %ptrs, <4 x i1> 
%cond) {
+; CHECK: gather_load_4xi8_variable_mask
+; CHECK-NEON:Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i8> @llvm.masked.gather.v4i8.v4p0i8
+; CHECK-SVE-128: Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i8> @llvm.masked.gather.v4i8.v4p0i8
+; CHECK-SVE-256: Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i8> @llvm.masked.gather.v4i8.v4p0i8
+; CHECK-SVE-512: Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i8> @llvm.masked.gather.v4i8.v4p0i8
+;
+  %lv = call <4 x i8> @llvm.masked.gather.v4i8.v4p0i8(<4 x i8*> %ptrs, i32 1, 
<4 x i1> %cond, <4 x i8> undef)
+  ret <4 x i8> %lv
+}
+
+declare void @llvm.masked.scatter.v4i8.v4p0i8(<4 x i8>, <4 x i8*>, i32 immarg, 
<4 x i1>)
+define void @scatter_store_4xi8_constant_mask(<4 x i8> %val, <4 x i8*> %ptrs) {
+; CHECK: scatter_store_4xi8_constant_mask
+; CHECK-NEON:Cost Model: Found an estimated cost of 1 for instruction:   
call void @llvm.masked.scatter.v4i8.v4p0i8(
+; CHECK-SVE-128: Cost Model: Found an estimated cost of 1 for instruction:   
call void @llvm.masked.scatter.v4i8.v4p0i8(
+; CHECK-SVE-256: Cost Model: Found an estimated cost of 1 for instruction:   
call void @llvm.masked.scatter.v4i8.v4p0i8(
+; CHECK-SVE-512: Cost Model: Found an estimated cost of 1 for instruction:   
call void @llvm.masked.scatter.v4i8.v4p0i8(
+;
+  call void @llvm.masked.scatter.v4i8.v4p0i8(<4 x i8> %val, <4 x i8*> %ptrs, 
i32 1, <4 x i1> )
+  ret void
+}
+
+define void @scatter_store_4xi8_variable_mask(<4 x i8> %val, <4 x i8*> %ptrs, 
<4 x i1> %cond) {
+; CHECK: scatter_store_4xi8_variable_mask
+; CHECK-NEON:Cost Model: Found an estimated cost of 1 for instruction:   
call void @llvm.masked.scatter.v4i8.v4p0i8(
+; CHECK-SVE-128: Cost Model: Found an estimated cost of 1 for instruction:   
call void @llvm.masked.scatter.v4i8.v4p0i8(
+; CHECK-SVE-256: Cost Model: Found an estimated cost of 1 for instruction:   
call void @llvm.masked.scatter.v4i8.v4p0i8(
+; CHECK-SVE-512: Cost Model: Found an estimated cost of 1 for instruction:   
call void @llvm.masked.scatter.v4i8.v4p0i8(
+;
+  call void @llvm.masked.scatter.v4i8.v4p0i8(<4 x i8> %val, <4 x i8*> %ptrs, 
i32 1, <4 x i1> %cond)
+  ret void
+}
+
+declare <4 x i32> @llvm.masked.gather.v4i32.v4p0i32(<4 x i32*>, i32 immarg, <4 
x i1>, <4 x i32>)
+define <4 x i32> @gather_load_4xi32_constant_mask(<4 x i32*> %ptrs) {
+; CHECK: gather_load_4xi32_constant_mask
 ; CHECK-NEON:Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i32> @llvm.masked.gather.v4i32.v4p0i32
 ; CHECK-SVE-128: Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i32> @llvm.masked.gather.v4i32.v4p0i32
 ; CHECK-SVE-256: Cost Model: Found an estimated cost of 1 for instruction:   
%lv = call <4 x i32> @llvm.masked.ga

[llvm-branch-commits] [llvm] b4902bc - [NFC] remove print statement I accidentally added.

2020-11-23 Thread Amy Huang via llvm-branch-commits

Author: Amy Huang
Date: 2020-11-23T10:51:09-08:00
New Revision: b4902bcd986ddbda30a210fc320c1fd8657e5b0d

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

LOG: [NFC] remove print statement I accidentally added.

Added: 


Modified: 
llvm/lib/DebugInfo/PDB/Native/NativeFunctionSymbol.cpp

Removed: 




diff  --git a/llvm/lib/DebugInfo/PDB/Native/NativeFunctionSymbol.cpp 
b/llvm/lib/DebugInfo/PDB/Native/NativeFunctionSymbol.cpp
index dc4d256b614a..708ed36eb50b 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeFunctionSymbol.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeFunctionSymbol.cpp
@@ -121,7 +121,6 @@ NativeFunctionSymbol::findInlineFramesByVA(uint64_t VA) 
const {
   InlineSiteSym IS =
   cantFail(SymbolDeserializer::deserializeAs(*Start));
   if (inlineSiteContainsAddress(IS, CodeOffset)) {
-fprintf(stderr, "inline: %d\n", Start.offset());
 // Insert frames in reverse order.
 SymIndexId Id = Session.getSymbolCache().getOrCreateInlineSymbol(
 IS, getVirtualAddress(), Modi, Start.offset());



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


[llvm-branch-commits] [clang] b3f1b19 - [AArch64] Update clang CodeGen tests I missed in 4252f7773a5b98b825d17e5f77c7d349cb2fb7c7.

2020-11-23 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-11-23T11:10:27-08:00
New Revision: b3f1b19c9cecd2ac8f8153aa25f8025dbd5702b8

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

LOG: [AArch64] Update clang CodeGen tests I missed in 
4252f7773a5b98b825d17e5f77c7d349cb2fb7c7.

These tests invoke opt and llc even though they are in the frontend.

We now do a better job of generating commuted patterns for fma so
these tests now form fmls instead of fmla+fneg.

Added: 


Modified: 
clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c 
b/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
index 7ebb7eb65057..3f88b6ed1db5 100644
--- a/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
+++ b/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
@@ -69,10 +69,9 @@ float16x8_t test_vfmaq_f16(float16x8_t a, float16x8_t b, 
float16x8_t c) {
 
 // COMMON-LABEL: test_vfms_f16
 // COMMONIR:   [[SUB:%.*]] = fneg <4 x half> %b
-// CHECK-ASM:  fneg v{{[0-9]+}}.4h, v{{[0-9]+}}.4h
 // UNCONSTRAINED:  [[ADD:%.*]] = call <4 x half> @llvm.fma.v4f16(<4 x half> 
[[SUB]], <4 x half> %c, <4 x half> %a)
 // CONSTRAINED:[[ADD:%.*]] = call <4 x half> 
@llvm.experimental.constrained.fma.v4f16(<4 x half> [[SUB]], <4 x half> %c, <4 
x half> %a, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
-// CHECK-ASM:  fmla v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, v{{[0-9]+}}.4h
+// CHECK-ASM:  fmls v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, v{{[0-9]+}}.4h
 // COMMONIR:   ret <4 x half> [[ADD]]
 float16x4_t test_vfms_f16(float16x4_t a, float16x4_t b, float16x4_t c) {
   return vfms_f16(a, b, c);
@@ -80,10 +79,9 @@ float16x4_t test_vfms_f16(float16x4_t a, float16x4_t b, 
float16x4_t c) {
 
 // COMMON-LABEL: test_vfmsq_f16
 // COMMONIR:   [[SUB:%.*]] = fneg <8 x half> %b
-// CHECK-ASM:  fneg v{{[0-9]+}}.8h, v{{[0-9]+}}.8h
 // UNCONSTRAINED:  [[ADD:%.*]] = call <8 x half> @llvm.fma.v8f16(<8 x half> 
[[SUB]], <8 x half> %c, <8 x half> %a)
 // CONSTRAINED:[[ADD:%.*]] = call <8 x half> 
@llvm.experimental.constrained.fma.v8f16(<8 x half> [[SUB]], <8 x half> %c, <8 
x half> %a, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
-// CHECK-ASM:  fmla v{{[0-9]+}}.8h, v{{[0-9]+}}.8h, v{{[0-9]+}}.8h
+// CHECK-ASM:  fmls v{{[0-9]+}}.8h, v{{[0-9]+}}.8h, v{{[0-9]+}}.8h
 // COMMONIR:   ret <8 x half> [[ADD]]
 float16x8_t test_vfmsq_f16(float16x8_t a, float16x8_t b, float16x8_t c) {
   return vfmsq_f16(a, b, c);



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


[llvm-branch-commits] [llvm] 454f32e - [ms] [llvm-ml] Support macro function invocations in expressions

2020-11-23 Thread Eric Astor via llvm-branch-commits

Author: Eric Astor
Date: 2020-11-23T14:16:28-05:00
New Revision: 454f32e4d572a85693d99bbb61513c63a84a1388

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

LOG: [ms] [llvm-ml] Support macro function invocations in expressions

Accept macro function definitions, and apply them when invoked in operand 
position.

Reviewed By: thakis

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

Added: 
llvm/test/tools/llvm-ml/macro_function.test

Modified: 
llvm/lib/MC/MCParser/MasmParser.cpp

Removed: 




diff  --git a/llvm/lib/MC/MCParser/MasmParser.cpp 
b/llvm/lib/MC/MCParser/MasmParser.cpp
index 9cdd2eb2cc93..d717cadf4e4a 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -108,6 +108,9 @@ struct ParseStatementInfo {
   /// Was there an error parsing the inline assembly?
   bool ParseError = false;
 
+  /// The value associated with a macro exit.
+  Optional ExitValue;
+
   SmallVectorImpl *AsmRewrites = nullptr;
 
   ParseStatementInfo() = delete;
@@ -368,6 +371,7 @@ class MasmParser : public MCAsmParser {
   /// This is the current buffer index we're lexing from as managed by the
   /// SourceMgr object.
   unsigned CurBuffer;
+  std::vector EndStatementAtEOFStack;
 
   AsmCond TheCondState;
   std::vector TheCondStack;
@@ -539,8 +543,6 @@ class MasmParser : public MCAsmParser {
   bool parseCurlyBlockScope(SmallVectorImpl& AsmStrRewrites);
   bool parseCppHashLineFilenameComment(SMLoc L);
 
-  void checkForBadMacro(SMLoc DirectiveLoc, StringRef Name, StringRef Body,
-ArrayRef Parameters);
   bool expandMacro(raw_svector_ostream &OS, StringRef Body,
ArrayRef Parameters,
ArrayRef A,
@@ -553,7 +555,15 @@ class MasmParser : public MCAsmParser {
   ///
   /// \param M The macro.
   /// \param NameLoc Instantiation location.
-  bool handleMacroEntry(const MCAsmMacro *M, SMLoc NameLoc);
+  bool handleMacroEntry(
+  const MCAsmMacro *M, SMLoc NameLoc,
+  AsmToken::TokenKind ArgumentEndTok = AsmToken::EndOfStatement);
+
+  /// Handle invocation of macro function.
+  ///
+  /// \param M The macro.
+  /// \param NameLoc Invocation location.
+  bool handleMacroInvocation(const MCAsmMacro *M, SMLoc NameLoc);
 
   /// Handle exit from macro instantiation.
   void handleMacroExit();
@@ -593,7 +603,8 @@ class MasmParser : public MCAsmParser {
   ///
   /// \param InBuffer If not 0, should be the known buffer id that contains the
   /// location.
-  void jumpToLoc(SMLoc Loc, unsigned InBuffer = 0);
+  void jumpToLoc(SMLoc Loc, unsigned InBuffer = 0,
+ bool EndStatementAtEOF = true);
 
   /// Parse up to a token of kind \p EndTok and return the contents from the
   /// current token up to (but not including) this token; the current token on
@@ -901,7 +912,7 @@ class MasmParser : public MCAsmParser {
 
   // macro directives
   bool parseDirectivePurgeMacro(SMLoc DirectiveLoc);
-  bool parseDirectiveExitMacro(StringRef Directive);
+  bool parseDirectiveExitMacro(StringRef Directive, std::string &Value);
   bool parseDirectiveEndMacro(StringRef Directive);
   bool parseDirectiveMacro(StringRef Name, SMLoc NameLoc);
 
@@ -1011,6 +1022,7 @@ MasmParser::MasmParser(SourceMgr &SM, MCContext &Ctx, 
MCStreamer &Out,
   // Set our own handler which calls the saved handler.
   SrcMgr.setDiagHandler(DiagHandler, this);
   Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer());
+  EndStatementAtEOFStack.push_back(true);
 
   // Initialize the platform / file format parser.
   switch (Ctx.getObjectFileInfo()->getObjectFileType()) {
@@ -1080,13 +1092,15 @@ bool MasmParser::enterIncludeFile(const std::string 
&Filename) {
 
   CurBuffer = NewBuf;
   Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer());
+  EndStatementAtEOFStack.push_back(true);
   return false;
 }
 
-void MasmParser::jumpToLoc(SMLoc Loc, unsigned InBuffer) {
+void MasmParser::jumpToLoc(SMLoc Loc, unsigned InBuffer,
+   bool EndStatementAtEOF) {
   CurBuffer = InBuffer ? InBuffer : SrcMgr.FindBufferContainingLoc(Loc);
   Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer(),
-  Loc.getPointer());
+  Loc.getPointer(), EndStatementAtEOF);
 }
 
 const AsmToken &MasmParser::Lex() {
@@ -1115,6 +1129,7 @@ const AsmToken &MasmParser::Lex() {
 getTok().getEndLoc());
   Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer(), nullptr,
   /*EndStatementAtEOF=*/false);
+  EndStatementAtEOFStack.push_back(false);
   tok = &Lexer.Lex();
 } else {
   break;
@@ -1141,9 +1156,12 @@ const AsmToken &MasmParser::Lex() {
 // include stack.
 SMLoc ParentIncl

[llvm-branch-commits] [llvm] 53c5fdd - [llvm-elfabi] Emit ELF header and string table sections

2020-11-23 Thread Haowei Wu via llvm-branch-commits

Author: Haowei Wu
Date: 2020-11-23T11:31:57-08:00
New Revision: 53c5fdd59a5cf7fbb4dcb7a7e84c9c4a40d32a84

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

LOG: [llvm-elfabi] Emit ELF header and string table sections

This change serves to create the initial framework for outputting ELF
files from llvm-elfabi.

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

Added: 
llvm/test/tools/llvm-elfabi/fail-file-write-windows.test
llvm/test/tools/llvm-elfabi/fail-file-write.test
llvm/test/tools/llvm-elfabi/output-target-error.test
llvm/test/tools/llvm-elfabi/write-stub.test

Modified: 
llvm/include/llvm/InterfaceStub/ELFObjHandler.h
llvm/lib/InterfaceStub/ELFObjHandler.cpp
llvm/tools/llvm-elfabi/llvm-elfabi.cpp

Removed: 




diff  --git a/llvm/include/llvm/InterfaceStub/ELFObjHandler.h 
b/llvm/include/llvm/InterfaceStub/ELFObjHandler.h
index 1ffd9a614eec..cbb9420cb666 100644
--- a/llvm/include/llvm/InterfaceStub/ELFObjHandler.h
+++ b/llvm/include/llvm/InterfaceStub/ELFObjHandler.h
@@ -23,9 +23,21 @@ class MemoryBuffer;
 
 namespace elfabi {
 
+enum class ELFTarget { ELF32LE, ELF32BE, ELF64LE, ELF64BE };
+
 /// Attempt to read a binary ELF file from a MemoryBuffer.
 Expected> readELFFile(MemoryBufferRef Buf);
 
+/// Attempt to write a binary ELF stub.
+/// This function determines appropriate ELFType using the passed ELFTarget and
+/// then writes a binary ELF stub to a specified file path.
+///
+/// @param FilePath File path for writing the ELF binary.
+/// @param Stub Source ELFStub to generate a binary ELF stub from.
+/// @param OutputFormat Target ELFType to write binary as.
+Error writeBinaryStub(StringRef FilePath, const ELFStub &Stub,
+  ELFTarget OutputFormat);
+
 } // end namespace elfabi
 } // end namespace llvm
 

diff  --git a/llvm/lib/InterfaceStub/ELFObjHandler.cpp 
b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
index cc9a8743cd08..76c637b88827 100644
--- a/llvm/lib/InterfaceStub/ELFObjHandler.cpp
+++ b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
@@ -8,11 +8,14 @@
 
 #include "llvm/InterfaceStub/ELFObjHandler.h"
 #include "llvm/InterfaceStub/ELFStub.h"
+#include "llvm/MC/StringTableBuilder.h"
 #include "llvm/Object/Binary.h"
 #include "llvm/Object/ELFObjectFile.h"
 #include "llvm/Object/ELFTypes.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 
 using llvm::MemoryBufferRef;
@@ -38,6 +41,158 @@ struct DynamicEntries {
   Optional GnuHash;
 };
 
+/// This initializes an ELF file header with information specific to a binary
+/// dynamic shared object.
+/// Offsets, indexes, links, etc. for section and program headers are just
+/// zero-initialized as they will be updated elsewhere.
+///
+/// @param ElfHeader Target ELFT::Ehdr to populate.
+/// @param Machine Target architecture (e_machine from ELF specifications).
+template 
+static void initELFHeader(typename ELFT::Ehdr &ElfHeader, uint16_t Machine) {
+  memset(&ElfHeader, 0, sizeof(ElfHeader));
+  // ELF identification.
+  ElfHeader.e_ident[EI_MAG0] = ElfMagic[EI_MAG0];
+  ElfHeader.e_ident[EI_MAG1] = ElfMagic[EI_MAG1];
+  ElfHeader.e_ident[EI_MAG2] = ElfMagic[EI_MAG2];
+  ElfHeader.e_ident[EI_MAG3] = ElfMagic[EI_MAG3];
+  ElfHeader.e_ident[EI_CLASS] = ELFT::Is64Bits ? ELFCLASS64 : ELFCLASS32;
+  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
+  ElfHeader.e_ident[EI_DATA] = IsLittleEndian ? ELFDATA2LSB : ELFDATA2MSB;
+  ElfHeader.e_ident[EI_VERSION] = EV_CURRENT;
+  ElfHeader.e_ident[EI_OSABI] = ELFOSABI_NONE;
+
+  // Remainder of ELF header.
+  ElfHeader.e_type = ET_DYN;
+  ElfHeader.e_machine = Machine;
+  ElfHeader.e_version = EV_CURRENT;
+  ElfHeader.e_ehsize = sizeof(typename ELFT::Ehdr);
+  ElfHeader.e_phentsize = sizeof(typename ELFT::Phdr);
+  ElfHeader.e_shentsize = sizeof(typename ELFT::Shdr);
+}
+
+namespace {
+template  struct OutputSection {
+  using Elf_Shdr = typename ELFT::Shdr;
+  std::string Name;
+  Elf_Shdr Shdr;
+  uint64_t Addr;
+  uint64_t Offset;
+  uint64_t Size;
+  uint64_t Align;
+  uint32_t Index;
+  bool NoBits = true;
+};
+
+template 
+struct ContentSection : public OutputSection {
+  T Content;
+  ContentSection() { this->NoBits = false; }
+};
+
+// This class just wraps StringTableBuilder for the purpose of adding a
+// default constructor.
+class ELFStringTableBuilder : public StringTableBuilder {
+public:
+  ELFStringTableBuilder() : StringTableBuilder(StringTableBuilder::ELF) {}
+};
+
+template  class ELFStubBuilder {
+public:
+  using Elf_Ehdr = typename ELFT::Ehdr;
+  using Elf_Shdr = typename ELFT::Shdr;
+  using Elf_Phdr = typename ELFT::Phdr;
+  using Elf_Sym = typename ELFT::Sym;
+  usin

[llvm-branch-commits] [llvm] 9e9d9ab - [test] Pin tests using -dot-callgraph to legacy PM

2020-11-23 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-11-23T11:48:59-08:00
New Revision: 9e9d9aba147561f4463d27a9570c99937d53563b

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

LOG: [test] Pin tests using -dot-callgraph to legacy PM

-dot-callgraph is not ported to the NPM yet. It can be ported at a later
time if necessary.

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

Added: 


Modified: 
llvm/test/Other/heat-colors-graphs.ll
llvm/test/Other/heat-colors-multigraph.ll

Removed: 




diff  --git a/llvm/test/Other/heat-colors-graphs.ll 
b/llvm/test/Other/heat-colors-graphs.ll
index 4cc58a640cd5..cf19820c4ff0 100644
--- a/llvm/test/Other/heat-colors-graphs.ll
+++ b/llvm/test/Other/heat-colors-graphs.ll
@@ -1,6 +1,6 @@
-; RUN: opt < %s -dot-cfg -cfg-heat-colors -cfg-dot-filename-prefix=%t 
2>/dev/null
+; RUN: opt %s -dot-cfg -cfg-heat-colors -cfg-dot-filename-prefix=%t 
-disable-output
 ; RUN: FileCheck %s -input-file=%t.f.dot --check-prefixes=CHECK-CFG,CHECK-BOTH
-; RUN: opt %s -dot-callgraph -callgraph-heat-colors 
-callgraph-dot-filename-prefix=%t 2>/dev/null
+; RUN: opt -enable-new-pm=0 %s -dot-callgraph -callgraph-heat-colors 
-callgraph-dot-filename-prefix=%t -disable-output
 ; RUN: FileCheck %s -input-file=%t.callgraph.dot --check-prefix=CHECK-BOTH
 
 ; CHECK-BOTH: color="#{{[(a-z)(0-9)]+}}", style={{[a-z]+}}, 
fillcolor="#{{[(a-z)(0-9)]+}}"

diff  --git a/llvm/test/Other/heat-colors-multigraph.ll 
b/llvm/test/Other/heat-colors-multigraph.ll
index a951ec29a194..4aab4f4ba06c 100644
--- a/llvm/test/Other/heat-colors-multigraph.ll
+++ b/llvm/test/Other/heat-colors-multigraph.ll
@@ -1,6 +1,6 @@
-; RUN: opt %s -dot-callgraph -callgraph-multigraph 
-callgraph-dot-filename-prefix=%t 2>/dev/null
+; RUN: opt -enable-new-pm=0 %s -dot-callgraph -callgraph-multigraph 
-callgraph-dot-filename-prefix=%t -disable-output
 ; RUN: FileCheck %s -input-file=%t.callgraph.dot 
--check-prefix=CHECK-MULTIGRAPH
-; RUN: opt %s -dot-callgraph -callgraph-dot-filename-prefix=%t 2>/dev/null
+; RUN: opt -enable-new-pm=0 %s -dot-callgraph 
-callgraph-dot-filename-prefix=%t -disable-output
 ; RUN: FileCheck %s -input-file=%t.callgraph.dot --check-prefix=CHECK
 
 ; CHECK-MULTIGRAPH: {external caller}



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


[llvm-branch-commits] [llvm] 01b3e6e - [AIX] Support init priority

2020-11-23 Thread Xiangling Liao via llvm-branch-commits

Author: Xiangling Liao
Date: 2020-11-23T14:50:05-05:00
New Revision: 01b3e6e026332d66b18a658f31926436669f3bb9

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

LOG: [AIX] Support init priority

Support reserved [0-100] and non-reserved[101-65535] Clang/GNU init
priority values on AIX.
This patch maps Clang/GNU values into priority values used in sinit/sterm
functions. User can play with values and be able to get init to occur
before or after XL init and vice versa.

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

Added: 


Modified: 
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
llvm/test/CodeGen/PowerPC/aix-static-init-non-default-priority.ll

Removed: 




diff  --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp 
b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index 22aa9a5e1e45..f7102dccf6ee 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -1996,6 +1996,48 @@ bool PPCAIXAsmPrinter::doFinalization(Module &M) {
   return PPCAsmPrinter::doFinalization(M);
 }
 
+static unsigned mapToSinitPriority(int P) {
+  if (P < 0 || P > 65535)
+report_fatal_error("invalid init priority");
+
+  if (P <= 20)
+return P;
+
+  if (P < 81)
+return 20 + (P - 20) * 16;
+
+  if (P <= 1124)
+return 1004 + (P - 81);
+
+  if (P < 64512)
+return 2047 + (P - 1124) * 33878;
+
+  return 2147482625 + (P - 64512);
+}
+
+static std::string convertToSinitPriority(int Priority) {
+  // This helper function converts clang init priority to values used in sinit
+  // and sterm functions.
+  //
+  // The conversion strategies are:
+  // We map the reserved clang/gnu priority range [0, 100] into the sinit/sterm
+  // reserved priority range [0, 1023] by
+  // - directly mapping the first 21 and the last 20 elements of the ranges
+  // - linear interpolating the intermediate values with a step size of 16.
+  //
+  // We map the non reserved clang/gnu priority range of [101, 65535] into the
+  // sinit/sterm priority range [1024, 2147483648] by:
+  // - directly mapping the first and the last 1024 elements of the ranges
+  // - linear interpolating the intermediate values with a step size of 33878.
+  unsigned int P = mapToSinitPriority(Priority);
+
+  std::string PrioritySuffix;
+  llvm::raw_string_ostream os(PrioritySuffix);
+  os << llvm::format_hex_no_prefix(P, 8);
+  os.flush();
+  return PrioritySuffix;
+}
+
 void PPCAIXAsmPrinter::emitXXStructorList(const DataLayout &DL,
   const Constant *List, bool IsCtor) {
   SmallVector Structors;
@@ -2005,14 +2047,14 @@ void PPCAIXAsmPrinter::emitXXStructorList(const 
DataLayout &DL,
 
   unsigned Index = 0;
   for (Structor &S : Structors) {
-if (S.Priority != 65535)
-  report_fatal_error(
-  "prioritized sinit and sterm functions are not yet supported on 
AIX");
+if (const ConstantExpr *CE = dyn_cast(S.Func))
+  S.Func = CE->getOperand(0);
 
 llvm::GlobalAlias::create(
 GlobalValue::ExternalLinkage,
 (IsCtor ? llvm::Twine("__sinit") : llvm::Twine("__sterm")) +
-llvm::Twine("8000_", FormatIndicatorAndUniqueModId) +
+llvm::Twine(convertToSinitPriority(S.Priority)) +
+llvm::Twine("_", FormatIndicatorAndUniqueModId) +
 llvm::Twine("_", llvm::utostr(Index++)),
 cast(S.Func));
   }

diff  --git a/llvm/test/CodeGen/PowerPC/aix-static-init-non-default-priority.ll 
b/llvm/test/CodeGen/PowerPC/aix-static-init-non-default-priority.ll
index 96566a912bb8..81777c2dec14 100644
--- a/llvm/test/CodeGen/PowerPC/aix-static-init-non-default-priority.ll
+++ b/llvm/test/CodeGen/PowerPC/aix-static-init-non-default-priority.ll
@@ -1,10 +1,146 @@
-; RUN: not --crash llc -mtriple powerpc-ibm-aix-xcoff < %s 2>&1 | FileCheck %s
-; RUN: not --crash llc -mtriple powerpc64-ibm-aix-xcoff < %s 2>&1 | FileCheck 
%s
+; RUN: llc -mtriple powerpc-ibm-aix-xcoff -verify-machineinstrs < %s | 
FileCheck %s
+; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -verify-machineinstrs < %s | 
FileCheck %s
 
-@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, 
void ()*, i8* } { i32 655, void ()* @foo, i8* null }]
+@llvm.global_ctors = appending global [5 x { i32, void ()*, i8* }] [{ i32, 
void ()*, i8* } { i32 0, void ()* bitcast (i32 (i32)* @cf1 to void ()*), i8* 
null }, { i32, void ()*, i8* } { i32 21, void ()* @cf2, i8* null }, { i32, void 
()*, i8* } { i32 81, void ()* @cf3, i8* null }, { i32, void ()*, i8* } { i32 
1125, void ()* @cf4, i8* null }, { i32, void ()*, i8* } { i32 64512, void ()* 
@cf5, i8* null }]
+@llvm.global_dtors = appending global [5 x { i32, void ()*, i8* }] [{ i32, 
void ()*, i8* } { i32 20, void ()* bitcast (i32 (i32)* @df1 to void ()*), i8* 
null }, { i

[llvm-branch-commits] [llvm] 14a68b4 - [CGSCC] Detect devirtualization in more cases

2020-11-23 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-11-23T11:55:20-08:00
New Revision: 14a68b4aa9732293ad7e16f105b0feb53dc8dbe2

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

LOG: [CGSCC] Detect devirtualization in more cases

The devirtualization wrapper misses cases where if it wraps a pass
manager, an individual pass may devirtualize an indirect call created by
a previous pass. For example, inlining may create a new indirect call
which is devirtualized by instcombine. Currently the devirtualization
wrapper will not see that because it only checks cgscc edges at the very
beginning and end of the pass (manager) it wraps.

This fixes some tests testing this exact behavior in the legacy PM.

Instead of checking WeakTrackingVHs for CallBases at the very beginning
and end of the pass it wraps, check every time
updateCGAndAnalysisManagerForPass() is called.

check-llvm and check-clang with -abort-on-max-devirt-iterations-reached
on by default doesn't show any failures outside of tests specifically
testing it so it doesn't needlessly rerun passes more than necessary.
(The NPM -O2/3 pipeline run the inliner/function simplification pipeline
under a devirtualization repeater pass up to 4 times by default).

http://llvm-compile-time-tracker.com/?config=O3&stat=instructions&remote=aeubanks
shows that 7zip has ~1% compile time regression. I looked at it and saw
that there indeed was devirtualization happening that was not previously
caught, so now it reruns the CGSCC pipeline on some SCCs, which is WAI.

Reviewed By: asbirlea

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

Added: 
llvm/test/Transforms/Inline/devirtualize-5.ll
llvm/test/Transforms/Inline/devirtualize-6.ll

Modified: 
llvm/include/llvm/Analysis/CGSCCPassManager.h
llvm/lib/Analysis/CGSCCPassManager.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/test/Transforms/Inline/devirtualize-3.ll
llvm/test/Transforms/Inline/devirtualize.ll

Removed: 




diff  --git a/llvm/include/llvm/Analysis/CGSCCPassManager.h 
b/llvm/include/llvm/Analysis/CGSCCPassManager.h
index 755bc92ddccf6..b2b690ddd28bf 100644
--- a/llvm/include/llvm/Analysis/CGSCCPassManager.h
+++ b/llvm/include/llvm/Analysis/CGSCCPassManager.h
@@ -90,6 +90,7 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/PriorityWorklist.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -314,6 +315,16 @@ struct CGSCCUpdateResult {
   /// for a better technique.
   SmallDenseSet, 4>
   &InlinedInternalEdges;
+
+  /// Weak VHs to keep track of indirect calls for the purposes of detecting
+  /// devirtualization.
+  ///
+  /// This is a map to avoid having duplicate entries. If a Value is
+  /// deallocated, its corresponding WeakTrackingVH will be nulled out. When
+  /// checking if a Value is in the map or not, also check if the corresponding
+  /// WeakTrackingVH is null to avoid issues with a new Value sharing the same
+  /// address as a deallocated one.
+  SmallMapVector IndirectVHs;
 };
 
 /// The core module pass which does a post-order walk of the SCCs and
@@ -596,9 +607,6 @@ class DevirtSCCRepeatedPass
 // a pointer that we can update.
 LazyCallGraph::SCC *C = &InitialC;
 
-// Collect value handles for all of the indirect call sites.
-SmallVector CallHandles;
-
 // Struct to track the counts of direct and indirect calls in each function
 // of the SCC.
 struct CallCount {
@@ -608,35 +616,37 @@ class DevirtSCCRepeatedPass
 
 // Put value handles on all of the indirect calls and return the number of
 // direct calls for each function in the SCC.
-auto ScanSCC = [](LazyCallGraph::SCC &C,
-  SmallVectorImpl &CallHandles) {
-  assert(CallHandles.empty() && "Must start with a clear set of handles.");
-
-  SmallDenseMap CallCounts;
-  CallCount CountLocal = {0, 0};
-  for (LazyCallGraph::Node &N : C) {
-CallCount &Count =
-CallCounts.insert(std::make_pair(&N.getFunction(), CountLocal))
-.first->second;
-for (Instruction &I : instructions(N.getFunction()))
-  if (auto *CB = dyn_cast(&I)) {
-if (CB->getCalledFunction()) {
-  ++Count.Direct;
-} else {
-  ++Count.Indirect;
-  CallHandles.push_back(WeakTrackingVH(&I));
-}
+auto ScanSCC =
+[](LazyCallGraph::SCC &C,
+   SmallMapVector &CallHandles) {
+  assert(CallHandles.empty() &&
+ "Must start with a clear set of handles.");
+
+  SmallDenseMap CallCounts;
+  CallCount CountLocal = {0, 0};
+  for (LazyCallGraph::Node &N : C) {
+CallCount &Count =
+

[llvm-branch-commits] [llvm] 8eec395 - [test] Pin memory-dereferenceable.ll to legacy PM

2020-11-23 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-11-23T11:56:17-08:00
New Revision: 8eec3959ef38eb30d6d9e89d70a4f3a8ed334a2a

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

LOG: [test] Pin memory-dereferenceable.ll to legacy PM

-print-memderefs is only used for one test and hasn't been touched in a while.

Added: 


Modified: 
llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll

Removed: 




diff  --git a/llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll 
b/llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll
index d158426404ec..3cdcab1a83d4 100644
--- a/llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll
+++ b/llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll
@@ -1,4 +1,4 @@
-; RUN: opt -print-memderefs -analyze -S <%s | FileCheck %s
+; RUN: opt -print-memderefs -analyze -S < %s -enable-new-pm=0 | FileCheck %s
 
 ; Uses the print-deref (+ analyze to print) pass to run
 ; isDereferenceablePointer() on many load instruction operands



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


[llvm-branch-commits] [llvm] 7167e52 - Port -print-memderefs to NPM

2020-11-23 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-11-23T11:56:22-08:00
New Revision: 7167e5203acd1602dc174a6a79acee727e5c0b0b

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

LOG: Port -print-memderefs to NPM

There is lots of code duplication, but hopefully it won't matter soon.

Reviewed By: ychen

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

Added: 
llvm/include/llvm/Analysis/MemDerefPrinter.h

Modified: 
llvm/lib/Analysis/MemDerefPrinter.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def
llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll

Removed: 




diff  --git a/llvm/include/llvm/Analysis/MemDerefPrinter.h 
b/llvm/include/llvm/Analysis/MemDerefPrinter.h
new file mode 100644
index ..bafdc543eeaf
--- /dev/null
+++ b/llvm/include/llvm/Analysis/MemDerefPrinter.h
@@ -0,0 +1,24 @@
+//===- MemDerefPrinter.h - Printer for isDereferenceablePointer 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_ANALYSIS_MEMDEREFPRINTER_H
+#define LLVM_ANALYSIS_MEMDEREFPRINTER_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+class MemDerefPrinterPass : public PassInfoMixin {
+  raw_ostream &OS;
+
+public:
+  MemDerefPrinterPass(raw_ostream &OS) : OS(OS) {}
+  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+};
+} // namespace llvm
+
+#endif // LLVM_ANALYSIS_MEMDEREFPRINTER_H

diff  --git a/llvm/lib/Analysis/MemDerefPrinter.cpp 
b/llvm/lib/Analysis/MemDerefPrinter.cpp
index 564410b8af08..0078ceacbad2 100644
--- a/llvm/lib/Analysis/MemDerefPrinter.cpp
+++ b/llvm/lib/Analysis/MemDerefPrinter.cpp
@@ -6,6 +6,7 @@
 //
 
//===--===//
 
+#include "llvm/Analysis/MemDerefPrinter.h"
 #include "llvm/Analysis/Loads.h"
 #include "llvm/Analysis/Passes.h"
 #include "llvm/IR/DataLayout.h"
@@ -17,6 +18,7 @@
 #include "llvm/Pass.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
+
 using namespace llvm;
 
 namespace {
@@ -76,3 +78,35 @@ void MemDerefPrinter::print(raw_ostream &OS, const Module 
*M) const {
 OS << "\n\n";
   }
 }
+
+PreservedAnalyses MemDerefPrinterPass::run(Function &F,
+   FunctionAnalysisManager &AM) {
+  OS << "Memory Dereferencibility of pointers in function '" << F.getName()
+ << "'\n";
+
+  SmallVector Deref;
+  SmallPtrSet DerefAndAligned;
+
+  const DataLayout &DL = F.getParent()->getDataLayout();
+  for (auto &I : instructions(F)) {
+if (LoadInst *LI = dyn_cast(&I)) {
+  Value *PO = LI->getPointerOperand();
+  if (isDereferenceablePointer(PO, LI->getType(), DL))
+Deref.push_back(PO);
+  if (isDereferenceableAndAlignedPointer(
+  PO, LI->getType(), MaybeAlign(LI->getAlignment()), DL))
+DerefAndAligned.insert(PO);
+}
+  }
+
+  OS << "The following are dereferenceable:\n";
+  for (Value *V : Deref) {
+V->print(OS);
+if (DerefAndAligned.count(V))
+  OS << "\t(aligned)";
+else
+  OS << "\t(unaligned)";
+OS << "\n\n";
+  }
+  return PreservedAnalyses::all();
+}

diff  --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 9fb4ce1b90e1..53a8dfb82a12 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -47,6 +47,7 @@
 #include "llvm/Analysis/LoopCacheAnalysis.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/LoopNestAnalysis.h"
+#include "llvm/Analysis/MemDerefPrinter.h"
 #include "llvm/Analysis/MemoryDependenceAnalysis.h"
 #include "llvm/Analysis/MemorySSA.h"
 #include "llvm/Analysis/ModuleDebugInfoPrinter.h"

diff  --git a/llvm/lib/Passes/PassRegistry.def 
b/llvm/lib/Passes/PassRegistry.def
index c761945e6768..7f0f51ad0977 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -286,6 +286,7 @@ FUNCTION_PASS("print", 
StackSafetyPrinterPass(dbgs()))
 FUNCTION_PASS("print-alias-sets", AliasSetsPrinterPass(dbgs()))
 FUNCTION_PASS("print-predicateinfo", PredicateInfoPrinterPass(dbgs()))
 FUNCTION_PASS("print-mustexecute", MustExecutePrinterPass(dbgs()))
+FUNCTION_PASS("print-memderefs", MemDerefPrinterPass(dbgs()))
 FUNCTION_PASS("reassociate", ReassociatePass())
 FUNCTION_PASS("redundant-dbg-inst-elim", RedundantDbgInstEliminationPass())
 FUNCTION_PASS("reg2mem", RegToMemPass())

diff  --git a/llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll 
b/llvm/test/Analysis/ValueTracking/memory-dereferenceable.ll
index 3cdcab1a83d4.

[llvm-branch-commits] [llvm] ae736d2 - Revert "[llvm-elfabi] Emit ELF header and string table sections"

2020-11-23 Thread Haowei Wu via llvm-branch-commits

Author: Haowei Wu
Date: 2020-11-23T11:58:51-08:00
New Revision: ae736d295763b05a2047fb64cec821c3d4a63d4d

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

LOG: Revert "[llvm-elfabi] Emit ELF header and string table sections"

This reverts commit 53c5fdd59a5cf7fbb4dcb7a7e84c9c4a40d32a84.

Reason of revert: Some builders failed to build with ld.

Added: 


Modified: 
llvm/include/llvm/InterfaceStub/ELFObjHandler.h
llvm/lib/InterfaceStub/ELFObjHandler.cpp
llvm/tools/llvm-elfabi/llvm-elfabi.cpp

Removed: 
llvm/test/tools/llvm-elfabi/fail-file-write-windows.test
llvm/test/tools/llvm-elfabi/fail-file-write.test
llvm/test/tools/llvm-elfabi/output-target-error.test
llvm/test/tools/llvm-elfabi/write-stub.test



diff  --git a/llvm/include/llvm/InterfaceStub/ELFObjHandler.h 
b/llvm/include/llvm/InterfaceStub/ELFObjHandler.h
index cbb9420cb666..1ffd9a614eec 100644
--- a/llvm/include/llvm/InterfaceStub/ELFObjHandler.h
+++ b/llvm/include/llvm/InterfaceStub/ELFObjHandler.h
@@ -23,21 +23,9 @@ class MemoryBuffer;
 
 namespace elfabi {
 
-enum class ELFTarget { ELF32LE, ELF32BE, ELF64LE, ELF64BE };
-
 /// Attempt to read a binary ELF file from a MemoryBuffer.
 Expected> readELFFile(MemoryBufferRef Buf);
 
-/// Attempt to write a binary ELF stub.
-/// This function determines appropriate ELFType using the passed ELFTarget and
-/// then writes a binary ELF stub to a specified file path.
-///
-/// @param FilePath File path for writing the ELF binary.
-/// @param Stub Source ELFStub to generate a binary ELF stub from.
-/// @param OutputFormat Target ELFType to write binary as.
-Error writeBinaryStub(StringRef FilePath, const ELFStub &Stub,
-  ELFTarget OutputFormat);
-
 } // end namespace elfabi
 } // end namespace llvm
 

diff  --git a/llvm/lib/InterfaceStub/ELFObjHandler.cpp 
b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
index 76c637b88827..cc9a8743cd08 100644
--- a/llvm/lib/InterfaceStub/ELFObjHandler.cpp
+++ b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
@@ -8,14 +8,11 @@
 
 #include "llvm/InterfaceStub/ELFObjHandler.h"
 #include "llvm/InterfaceStub/ELFStub.h"
-#include "llvm/MC/StringTableBuilder.h"
 #include "llvm/Object/Binary.h"
 #include "llvm/Object/ELFObjectFile.h"
 #include "llvm/Object/ELFTypes.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
-#include "llvm/Support/FileOutputBuffer.h"
-#include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 
 using llvm::MemoryBufferRef;
@@ -41,158 +38,6 @@ struct DynamicEntries {
   Optional GnuHash;
 };
 
-/// This initializes an ELF file header with information specific to a binary
-/// dynamic shared object.
-/// Offsets, indexes, links, etc. for section and program headers are just
-/// zero-initialized as they will be updated elsewhere.
-///
-/// @param ElfHeader Target ELFT::Ehdr to populate.
-/// @param Machine Target architecture (e_machine from ELF specifications).
-template 
-static void initELFHeader(typename ELFT::Ehdr &ElfHeader, uint16_t Machine) {
-  memset(&ElfHeader, 0, sizeof(ElfHeader));
-  // ELF identification.
-  ElfHeader.e_ident[EI_MAG0] = ElfMagic[EI_MAG0];
-  ElfHeader.e_ident[EI_MAG1] = ElfMagic[EI_MAG1];
-  ElfHeader.e_ident[EI_MAG2] = ElfMagic[EI_MAG2];
-  ElfHeader.e_ident[EI_MAG3] = ElfMagic[EI_MAG3];
-  ElfHeader.e_ident[EI_CLASS] = ELFT::Is64Bits ? ELFCLASS64 : ELFCLASS32;
-  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
-  ElfHeader.e_ident[EI_DATA] = IsLittleEndian ? ELFDATA2LSB : ELFDATA2MSB;
-  ElfHeader.e_ident[EI_VERSION] = EV_CURRENT;
-  ElfHeader.e_ident[EI_OSABI] = ELFOSABI_NONE;
-
-  // Remainder of ELF header.
-  ElfHeader.e_type = ET_DYN;
-  ElfHeader.e_machine = Machine;
-  ElfHeader.e_version = EV_CURRENT;
-  ElfHeader.e_ehsize = sizeof(typename ELFT::Ehdr);
-  ElfHeader.e_phentsize = sizeof(typename ELFT::Phdr);
-  ElfHeader.e_shentsize = sizeof(typename ELFT::Shdr);
-}
-
-namespace {
-template  struct OutputSection {
-  using Elf_Shdr = typename ELFT::Shdr;
-  std::string Name;
-  Elf_Shdr Shdr;
-  uint64_t Addr;
-  uint64_t Offset;
-  uint64_t Size;
-  uint64_t Align;
-  uint32_t Index;
-  bool NoBits = true;
-};
-
-template 
-struct ContentSection : public OutputSection {
-  T Content;
-  ContentSection() { this->NoBits = false; }
-};
-
-// This class just wraps StringTableBuilder for the purpose of adding a
-// default constructor.
-class ELFStringTableBuilder : public StringTableBuilder {
-public:
-  ELFStringTableBuilder() : StringTableBuilder(StringTableBuilder::ELF) {}
-};
-
-template  class ELFStubBuilder {
-public:
-  using Elf_Ehdr = typename ELFT::Ehdr;
-  using Elf_Shdr = typename ELFT::Shdr;
-  using Elf_Phdr = typename ELFT::Phdr;
-  using Elf_Sym = typename ELFT::Sym;
-  using Elf_Addr = typename

[llvm-branch-commits] [llvm] 1e41e22 - [ms] [llvm-ml] Support purging macro definitions

2020-11-23 Thread Eric Astor via llvm-branch-commits

Author: Eric Astor
Date: 2020-11-23T15:03:13-05:00
New Revision: 1e41e22323a33d7b7977e48ff6ec243e46860257

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

LOG: [ms] [llvm-ml] Support purging macro definitions

Support MASM's PURGE directive.

Reviewed By: thakis

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

Added: 


Modified: 
llvm/lib/MC/MCParser/COFFMasmParser.cpp
llvm/lib/MC/MCParser/MasmParser.cpp
llvm/test/tools/llvm-ml/macro.test

Removed: 




diff  --git a/llvm/lib/MC/MCParser/COFFMasmParser.cpp 
b/llvm/lib/MC/MCParser/COFFMasmParser.cpp
index 61d69ee4e7e8..aacce928c141 100644
--- a/llvm/lib/MC/MCParser/COFFMasmParser.cpp
+++ b/llvm/lib/MC/MCParser/COFFMasmParser.cpp
@@ -118,9 +118,7 @@ class COFFMasmParser : public MCAsmParserExtension {
 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>("title");
 
 // Macro directives
-// exitm
 // goto
-// purge
 
 // Miscellaneous directives
 addDirectiveHandler<&COFFMasmParser::ParseDirectiveAlias>("alias");
@@ -153,9 +151,6 @@ class COFFMasmParser : public MCAsmParserExtension {
 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".mmx");
 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".xmm");
 
-// Repeat blocks directives
-// goto
-
 // Scope directives
 // comm
 // externdef

diff  --git a/llvm/lib/MC/MCParser/MasmParser.cpp 
b/llvm/lib/MC/MCParser/MasmParser.cpp
index d717cadf4e4a..9b63148c6860 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -734,7 +734,7 @@ class MasmParser : public MCAsmParser {
 DK_MACRO,
 DK_EXITM,
 DK_ENDM,
-DK_PURGEM,
+DK_PURGE,
 DK_ERR,
 DK_ERRB,
 DK_ERRNB,
@@ -2311,7 +2311,7 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info,
 case DK_ENDM:
   Info.ExitValue = "";
   return parseDirectiveEndMacro(IDVal);
-case DK_PURGEM:
+case DK_PURGE:
   return parseDirectivePurgeMacro(IDLoc);
 case DK_END:
   return parseDirectiveEnd(IDLoc);
@@ -5544,23 +5544,27 @@ bool MasmParser::parseDirectiveEndMacro(StringRef 
Directive) {
 }
 
 /// parseDirectivePurgeMacro
-/// ::= .purgem
+/// ::= purge identifier ( , identifier )*
 bool MasmParser::parseDirectivePurgeMacro(SMLoc DirectiveLoc) {
   StringRef Name;
-  SMLoc Loc;
-  if (parseTokenLoc(Loc) ||
-  check(parseIdentifier(Name), Loc,
-"expected identifier in '.purgem' directive") ||
-  parseToken(AsmToken::EndOfStatement,
- "unexpected token in '.purgem' directive"))
-return true;
+  while (true) {
+SMLoc NameLoc;
+if (parseTokenLoc(NameLoc) ||
+check(parseIdentifier(Name), NameLoc,
+  "expected identifier in 'purge' directive"))
+  return true;
 
-  if (!getContext().lookupMacro(Name))
-return Error(DirectiveLoc, "macro '" + Name + "' is not defined");
+DEBUG_WITH_TYPE("asm-macros", dbgs()
+  << "Un-defining macro: " << Name << 
"\n");
+if (!getContext().lookupMacro(Name))
+  return Error(NameLoc, "macro '" + Name + "' is not defined");
+getContext().undefineMacro(Name);
+
+if (!parseOptionalToken(AsmToken::Comma))
+  break;
+parseOptionalToken(AsmToken::EndOfStatement);
+  }
 
-  getContext().undefineMacro(Name);
-  DEBUG_WITH_TYPE("asm-macros", dbgs()
-<< "Un-defining macro: " << Name << "\n");
   return false;
 }
 
@@ -6322,7 +6326,7 @@ void MasmParser::initializeDirectiveKindMap() {
   DirectiveKindMap["macro"] = DK_MACRO;
   DirectiveKindMap["exitm"] = DK_EXITM;
   DirectiveKindMap["endm"] = DK_ENDM;
-  // DirectiveKindMap[".purgem"] = DK_PURGEM;
+  DirectiveKindMap["purge"] = DK_PURGE;
   DirectiveKindMap[".err"] = DK_ERR;
   DirectiveKindMap[".errb"] = DK_ERRB;
   DirectiveKindMap[".errnb"] = DK_ERRNB;

diff  --git a/llvm/test/tools/llvm-ml/macro.test 
b/llvm/test/tools/llvm-ml/macro.test
index 255cd485e36b..3a356c0abe3e 100644
--- a/llvm/test/tools/llvm-ml/macro.test
+++ b/llvm/test/tools/llvm-ml/macro.test
@@ -134,4 +134,23 @@ local_symbol_test PROC
 ; CHECK-NEXT: jmp "??0001"
 local_symbol_test ENDP
 
+PURGE ambiguous_substitution_macro, local_symbol_macro,
+  optional_parameter_macro
+
+; Redefinition
+local_symbol_macro MACRO
+  LOCAL b
+b: xor eax, eax
+   jmp b
+ENDM
+
+purge_test PROC
+; CHECK-LABEL: purge_test:
+
+  local_symbol_macro
+; CHECK: "??0002":
+; CHECK-NEXT: xor eax, eax
+; CHECK-NEXT: jmp "??0002"
+purge_test ENDP
+
 END



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


[llvm-branch-commits] [clang-tools-extra] 9f3edc3 - [clang-tidy] Fix RenamerClangTidy checks trying to emit a fix that isnt a valid identifier

2020-11-23 Thread Nathan James via llvm-branch-commits

Author: Nathan James
Date: 2020-11-23T20:04:51Z
New Revision: 9f3edc323a88c1a179a0a5a9dc9a87a2964c0d48

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

LOG: [clang-tidy] Fix RenamerClangTidy checks trying to emit a fix that isnt a 
valid identifier

Addresses https://bugs.llvm.org/show_bug.cgi?id=48230.
Handle the case when the Fixup suggested isn't a valid c/c++ identifer.

Reviewed By: aaron.ballman, gribozavr2

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h

clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-bugfix-name-conflicts.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
index 6a25813eb748..2bb97eca14ab 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -10,6 +10,7 @@
 #include "ASTUtils.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/CharInfo.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
@@ -463,6 +464,8 @@ void RenamerClangTidyCheck::check(const 
MatchFinder::MatchResult &Result) {
 Failure.FixStatus = ShouldFixStatus::ConflictsWithKeyword;
   else if (Ident->hasMacroDefinition())
 Failure.FixStatus = ShouldFixStatus::ConflictsWithMacroDefinition;
+} else if (!isValidIdentifier(Info.Fixup)) {
+  Failure.FixStatus = ShouldFixStatus::FixInvalidIdentifier;
 }
 
 Failure.Info = std::move(Info);
@@ -503,7 +506,8 @@ void RenamerClangTidyCheck::expandMacro(const Token 
&MacroNameTok,
 static std::string
 getDiagnosticSuffix(const RenamerClangTidyCheck::ShouldFixStatus FixStatus,
 const std::string &Fixup) {
-  if (Fixup.empty())
+  if (Fixup.empty() ||
+  FixStatus == 
RenamerClangTidyCheck::ShouldFixStatus::FixInvalidIdentifier)
 return "; cannot be fixed automatically";
   if (FixStatus == RenamerClangTidyCheck::ShouldFixStatus::ShouldFix)
 return {};
@@ -517,7 +521,6 @@ getDiagnosticSuffix(const 
RenamerClangTidyCheck::ShouldFixStatus FixStatus,
   RenamerClangTidyCheck::ShouldFixStatus::ConflictsWithMacroDefinition)
 return "; cannot be fixed because '" + Fixup +
"' would conflict with a macro definition";
-
   llvm_unreachable("invalid ShouldFixStatus");
 }
 

diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h 
b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
index aabb80133939..fd5b32075cbe 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
@@ -59,6 +59,9 @@ class RenamerClangTidyCheck : public ClangTidyCheck {
 /// automatically.
 ConflictsWithMacroDefinition,
 
+/// The fixup results in an identifier that is not a valid c/c++ 
identifier.
+FixInvalidIdentifier,
+
 /// Values pass this threshold will be ignored completely
 /// i.e no message, no fixup.
 IgnoreFailureThreshold,

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-bugfix-name-conflicts.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-bugfix-name-conflicts.cpp
index 12ddcf55c119..bee93c99976b 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-bugfix-name-conflicts.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-bugfix-name-conflicts.cpp
@@ -25,3 +25,13 @@ int func2(int Foo) {
 
   return 0;
 }
+
+int func3(int _0Bad) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for 
parameter '_0Bad'; cannot be fixed automatically [readability-identifier-naming]
+  // CHECK-FIXES: {{^}}int func3(int _0Bad) {{{$}}
+  if (_0Bad == 1) {
+// CHECK-FIXES: {{^}}  if (_0Bad == 1) {{{$}}
+return 2;
+  }
+  return 0;
+}



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


[llvm-branch-commits] [llvm] cf43308 - [llvm-elfabi] Emit ELF header and string table sections

2020-11-23 Thread Haowei Wu via llvm-branch-commits

Author: Haowei Wu
Date: 2020-11-23T12:18:58-08:00
New Revision: cf4330871844f58075023a9ace9ba0728cf48d57

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

LOG: [llvm-elfabi] Emit ELF header and string table sections

This change serves to create the initial framework for outputting ELF
files from llvm-elfabi.

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

Added: 
llvm/test/tools/llvm-elfabi/fail-file-write-windows.test
llvm/test/tools/llvm-elfabi/fail-file-write.test
llvm/test/tools/llvm-elfabi/output-target-error.test
llvm/test/tools/llvm-elfabi/write-stub.test

Modified: 
llvm/include/llvm/InterfaceStub/ELFObjHandler.h
llvm/lib/InterfaceStub/CMakeLists.txt
llvm/lib/InterfaceStub/ELFObjHandler.cpp
llvm/tools/llvm-elfabi/llvm-elfabi.cpp

Removed: 




diff  --git a/llvm/include/llvm/InterfaceStub/ELFObjHandler.h 
b/llvm/include/llvm/InterfaceStub/ELFObjHandler.h
index 1ffd9a614eec..cbb9420cb666 100644
--- a/llvm/include/llvm/InterfaceStub/ELFObjHandler.h
+++ b/llvm/include/llvm/InterfaceStub/ELFObjHandler.h
@@ -23,9 +23,21 @@ class MemoryBuffer;
 
 namespace elfabi {
 
+enum class ELFTarget { ELF32LE, ELF32BE, ELF64LE, ELF64BE };
+
 /// Attempt to read a binary ELF file from a MemoryBuffer.
 Expected> readELFFile(MemoryBufferRef Buf);
 
+/// Attempt to write a binary ELF stub.
+/// This function determines appropriate ELFType using the passed ELFTarget and
+/// then writes a binary ELF stub to a specified file path.
+///
+/// @param FilePath File path for writing the ELF binary.
+/// @param Stub Source ELFStub to generate a binary ELF stub from.
+/// @param OutputFormat Target ELFType to write binary as.
+Error writeBinaryStub(StringRef FilePath, const ELFStub &Stub,
+  ELFTarget OutputFormat);
+
 } // end namespace elfabi
 } // end namespace llvm
 

diff  --git a/llvm/lib/InterfaceStub/CMakeLists.txt 
b/llvm/lib/InterfaceStub/CMakeLists.txt
index 4aacebf16cf9..17801999c485 100644
--- a/llvm/lib/InterfaceStub/CMakeLists.txt
+++ b/llvm/lib/InterfaceStub/CMakeLists.txt
@@ -4,6 +4,7 @@ add_llvm_component_library(LLVMInterfaceStub
   TBEHandler.cpp
 
   LINK_COMPONENTS
+  MC
   Object
   Support
 )

diff  --git a/llvm/lib/InterfaceStub/ELFObjHandler.cpp 
b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
index cc9a8743cd08..76c637b88827 100644
--- a/llvm/lib/InterfaceStub/ELFObjHandler.cpp
+++ b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
@@ -8,11 +8,14 @@
 
 #include "llvm/InterfaceStub/ELFObjHandler.h"
 #include "llvm/InterfaceStub/ELFStub.h"
+#include "llvm/MC/StringTableBuilder.h"
 #include "llvm/Object/Binary.h"
 #include "llvm/Object/ELFObjectFile.h"
 #include "llvm/Object/ELFTypes.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 
 using llvm::MemoryBufferRef;
@@ -38,6 +41,158 @@ struct DynamicEntries {
   Optional GnuHash;
 };
 
+/// This initializes an ELF file header with information specific to a binary
+/// dynamic shared object.
+/// Offsets, indexes, links, etc. for section and program headers are just
+/// zero-initialized as they will be updated elsewhere.
+///
+/// @param ElfHeader Target ELFT::Ehdr to populate.
+/// @param Machine Target architecture (e_machine from ELF specifications).
+template 
+static void initELFHeader(typename ELFT::Ehdr &ElfHeader, uint16_t Machine) {
+  memset(&ElfHeader, 0, sizeof(ElfHeader));
+  // ELF identification.
+  ElfHeader.e_ident[EI_MAG0] = ElfMagic[EI_MAG0];
+  ElfHeader.e_ident[EI_MAG1] = ElfMagic[EI_MAG1];
+  ElfHeader.e_ident[EI_MAG2] = ElfMagic[EI_MAG2];
+  ElfHeader.e_ident[EI_MAG3] = ElfMagic[EI_MAG3];
+  ElfHeader.e_ident[EI_CLASS] = ELFT::Is64Bits ? ELFCLASS64 : ELFCLASS32;
+  bool IsLittleEndian = ELFT::TargetEndianness == support::little;
+  ElfHeader.e_ident[EI_DATA] = IsLittleEndian ? ELFDATA2LSB : ELFDATA2MSB;
+  ElfHeader.e_ident[EI_VERSION] = EV_CURRENT;
+  ElfHeader.e_ident[EI_OSABI] = ELFOSABI_NONE;
+
+  // Remainder of ELF header.
+  ElfHeader.e_type = ET_DYN;
+  ElfHeader.e_machine = Machine;
+  ElfHeader.e_version = EV_CURRENT;
+  ElfHeader.e_ehsize = sizeof(typename ELFT::Ehdr);
+  ElfHeader.e_phentsize = sizeof(typename ELFT::Phdr);
+  ElfHeader.e_shentsize = sizeof(typename ELFT::Shdr);
+}
+
+namespace {
+template  struct OutputSection {
+  using Elf_Shdr = typename ELFT::Shdr;
+  std::string Name;
+  Elf_Shdr Shdr;
+  uint64_t Addr;
+  uint64_t Offset;
+  uint64_t Size;
+  uint64_t Align;
+  uint32_t Index;
+  bool NoBits = true;
+};
+
+template 
+struct ContentSection : public OutputSection {
+  T Content;
+  ContentSection() { this->NoBits = false; }
+};
+
+// This class just wraps StringTableBuilder for the purpose of ad

[llvm-branch-commits] [llvm] 64802d4 - Make check-clang depend on the LLVM split-file utility

2020-11-23 Thread Reid Kleckner via llvm-branch-commits

Author: Reid Kleckner
Date: 2020-11-23T12:21:44-08:00
New Revision: 64802d48d51d651bd2e4567b2f228f8795569542

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

LOG: Make check-clang depend on the LLVM split-file utility

Fixes a recently added test that has this dependency. IMO this utility
is generally useful, so we should go ahead and take the new dependency.

Added: 


Modified: 
clang/test/CMakeLists.txt
llvm/utils/gn/secondary/clang/test/BUILD.gn

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 4e9a1840fec3..2aff029cfbf1 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -124,6 +124,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-readobj
 llvm-symbolizer
 opt
+split-file
 yaml2obj
 )
 

diff  --git a/llvm/utils/gn/secondary/clang/test/BUILD.gn 
b/llvm/utils/gn/secondary/clang/test/BUILD.gn
index 8f436ac10586..70f28c8b5812 100644
--- a/llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -164,6 +164,7 @@ group("test") {
 "//llvm/tools/llvm-readobj:symlinks",
 "//llvm/tools/llvm-symbolizer:symlinks",
 "//llvm/tools/opt",
+"//llvm/tools/split-file",
 "//llvm/utils/FileCheck",
 "//llvm/utils/count",
 "//llvm/utils/llvm-lit",



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


[llvm-branch-commits] [mlir] 5073e7e - [mlir] Add mising dependency

2020-11-23 Thread Nicolas Vasilache via llvm-branch-commits

Author: Nicolas Vasilache
Date: 2020-11-23T20:36:50Z
New Revision: 5073e7edb64b61d130f2a0eac4731a0585bad28f

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

LOG: [mlir] Add mising dependency

Added: 


Modified: 
mlir/lib/Dialect/Linalg/IR/CMakeLists.txt

Removed: 




diff  --git a/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt 
b/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt
index 963260adad66..15e29d749e65 100644
--- a/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt
+++ b/mlir/lib/Dialect/Linalg/IR/CMakeLists.txt
@@ -11,6 +11,7 @@ add_mlir_dialect_library(MLIRLinalg
   MLIRLinalgStructuredOpsInterfaceIncGen
 
   LINK_LIBS PUBLIC
+  MLIRAffine
   MLIRIR
   MLIRSideEffectInterfaces
   MLIRViewLikeInterface



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


[llvm-branch-commits] [clang-tools-extra] 269ef31 - [clang-tidy] Use compiled regex for AllowedRegexp in macro usage check

2020-11-23 Thread Nathan James via llvm-branch-commits

Author: smhc
Date: 2020-11-23T20:46:43Z
New Revision: 269ef315d1beaff534a038b60389226b0f0f5d4f

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

LOG: [clang-tidy] Use compiled regex for AllowedRegexp in macro usage check

Current check compiles the regex on every attempt at matching. The check also 
populates and enables a regex value by default so the default behaviour results 
in regex re-compilation for every macro - if the check is enabled. If people 
used this check there's a reasonable chance they would have relatively complex 
regexes in use.

This is a quick and simple fix to store and use the compiled regex.

Reviewed By: njames93

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
index febc295d78e6..eb21bb44f63d 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
@@ -32,8 +32,8 @@ bool isCapsOnly(StringRef Name) {
 class MacroUsageCallbacks : public PPCallbacks {
 public:
   MacroUsageCallbacks(MacroUsageCheck *Check, const SourceManager &SM,
-  StringRef RegExp, bool CapsOnly, bool IgnoreCommandLine)
-  : Check(Check), SM(SM), RegExp(RegExp), CheckCapsOnly(CapsOnly),
+  StringRef RegExpStr, bool CapsOnly, bool 
IgnoreCommandLine)
+  : Check(Check), SM(SM), RegExp(RegExpStr), CheckCapsOnly(CapsOnly),
 IgnoreCommandLineMacros(IgnoreCommandLine) {}
   void MacroDefined(const Token &MacroNameTok,
 const MacroDirective *MD) override {
@@ -47,7 +47,7 @@ class MacroUsageCallbacks : public PPCallbacks {
   return;
 
 StringRef MacroName = MacroNameTok.getIdentifierInfo()->getName();
-if (!CheckCapsOnly && !llvm::Regex(RegExp).match(MacroName))
+if (!CheckCapsOnly && !RegExp.match(MacroName))
   Check->warnMacro(MD, MacroName);
 
 if (CheckCapsOnly && !isCapsOnly(MacroName))
@@ -57,7 +57,7 @@ class MacroUsageCallbacks : public PPCallbacks {
 private:
   MacroUsageCheck *Check;
   const SourceManager &SM;
-  StringRef RegExp;
+  const llvm::Regex RegExp;
   bool CheckCapsOnly;
   bool IgnoreCommandLineMacros;
 };



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


[llvm-branch-commits] [lldb] 5b8e4a1 - [lldb/test] Remove flaky `process connect` test.

2020-11-23 Thread Jordan Rupprecht via llvm-branch-commits

Author: Jordan Rupprecht
Date: 2020-11-23T12:49:50-08:00
New Revision: 5b8e4a11029ff169fdac7caa3c7aa211f318adf6

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

LOG: [lldb/test] Remove flaky `process connect` test.

This test is flaky because it assumes port 4321 is not already open on a 
machine.

Added: 


Modified: 


Removed: 
lldb/test/Shell/Commands/command-process-connect.test



diff  --git a/lldb/test/Shell/Commands/command-process-connect.test 
b/lldb/test/Shell/Commands/command-process-connect.test
deleted file mode 100644
index 30782243d4ed..
--- a/lldb/test/Shell/Commands/command-process-connect.test
+++ /dev/null
@@ -1,11 +0,0 @@
-# UNSUPPORTED: system-windows
-
-# Synchronous
-# RUN: %lldb -o 'platform select remote-gdb-server' -o 'process connect 
connect://localhost:4321' 2>&1 | FileCheck %s
-
-# Asynchronous
-# RUN: echo -e 'platform select remote-gdb-server\nprocess connect 
connect://localhost:4321' | %lldb 2>&1 | FileCheck %s
-
-# CHECK: Platform: remote-gdb-server
-# CHECK: Connected: no
-# CHECK: error: Failed to connect port



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


[llvm-branch-commits] [llvm] 3c811ce - [NPM] Share pass building options with legacy PM

2020-11-23 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-11-23T13:04:05-08:00
New Revision: 3c811ce4f390c8570690b042f4e6199f20255e26

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

LOG: [NPM] Share pass building options with legacy PM

We should share options when possible.

Reviewed By: asbirlea

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

Added: 


Modified: 
llvm/lib/Analysis/CallGraphSCCPass.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/test/Transforms/Inline/crash2.ll
llvm/test/Transforms/Inline/gvn-inline-iteration.ll
llvm/test/Transforms/LoopUnrollAndJam/opt-levels.ll

Removed: 




diff  --git a/llvm/lib/Analysis/CallGraphSCCPass.cpp 
b/llvm/lib/Analysis/CallGraphSCCPass.cpp
index 2de18fe3863d..de5cada85fe2 100644
--- a/llvm/lib/Analysis/CallGraphSCCPass.cpp
+++ b/llvm/lib/Analysis/CallGraphSCCPass.cpp
@@ -43,8 +43,8 @@ using namespace llvm;
 
 #define DEBUG_TYPE "cgscc-passmgr"
 
-static cl::opt
-MaxIterations("max-cg-scc-iterations", cl::ReallyHidden, cl::init(4));
+cl::opt MaxDevirtIterations("max-devirt-iterations", 
cl::ReallyHidden,
+  cl::init(4));
 
 STATISTIC(MaxSCCIterations, "Maximum CGSCCPassMgr iterations on one SCC");
 
@@ -539,12 +539,12 @@ bool CGPassManager::runOnModule(Module &M) {
  << '\n');
   DevirtualizedCall = false;
   Changed |= RunAllPassesOnSCC(CurSCC, CG, DevirtualizedCall);
-} while (Iteration++ < MaxIterations && DevirtualizedCall);
+} while (Iteration++ < MaxDevirtIterations && DevirtualizedCall);
 
 if (DevirtualizedCall)
   LLVM_DEBUG(dbgs() << "  CGSCCPASSMGR: Stopped iteration after "
 << Iteration
-<< " times, due to -max-cg-scc-iterations\n");
+<< " times, due to -max-devirt-iterations\n");
 
 MaxSCCIterations.updateMax(Iteration);
   }

diff  --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 53a8dfb82a12..e5189bdb4fd9 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -233,26 +233,7 @@
 
 using namespace llvm;
 
-static cl::opt MaxDevirtIterations("pm-max-devirt-iterations",
- cl::ReallyHidden, cl::init(4));
-static cl::opt
-RunPartialInlining("enable-npm-partial-inlining", cl::init(false),
-   cl::Hidden, cl::ZeroOrMore,
-   cl::desc("Run Partial inlinining pass"));
-
-static cl::opt PreInlineThreshold(
-"npm-preinline-threshold", cl::Hidden, cl::init(75), cl::ZeroOrMore,
-cl::desc("Control the amount of inlining in pre-instrumentation inliner "
- "(default = 75)"));
-
-static cl::opt
-RunNewGVN("enable-npm-newgvn", cl::init(false),
-  cl::Hidden, cl::ZeroOrMore,
-  cl::desc("Run NewGVN instead of GVN"));
-
-static cl::opt EnableGVNHoist(
-"enable-npm-gvn-hoist", cl::init(false), cl::Hidden,
-cl::desc("Enable the GVN hoisting pass for the new PM (default = off)"));
+extern cl::opt MaxDevirtIterations;
 
 static cl::opt UseInlineAdvisor(
 "enable-ml-inliner", cl::init(InliningAdvisorMode::Default), cl::Hidden,
@@ -264,18 +245,6 @@ static cl::opt UseInlineAdvisor(
clEnumValN(InliningAdvisorMode::Release, "release",
   "Use release mode (AOT-compiled model).")));
 
-static cl::opt EnableGVNSink(
-"enable-npm-gvn-sink", cl::init(false), cl::Hidden,
-cl::desc("Enable the GVN hoisting pass for the new PM (default = off)"));
-
-static cl::opt EnableUnrollAndJam(
-"enable-npm-unroll-and-jam", cl::init(false), cl::Hidden,
-cl::desc("Enable the Unroll and Jam pass for the new PM (default = off)"));
-
-static cl::opt EnableLoopFlatten(
-"enable-npm-loop-flatten", cl::init(false), cl::Hidden,
-cl::desc("Enable the Loop flattening pass for the new PM (default = 
off)"));
-
 static cl::opt EnableSyntheticCounts(
 "enable-npm-synthetic-counts", cl::init(false), cl::Hidden, cl::ZeroOrMore,
 cl::desc("Run synthetic function entry count generation "
@@ -284,12 +253,6 @@ static cl::opt EnableSyntheticCounts(
 static const Regex DefaultAliasRegex(
 "^(default|thinlto-pre-link|thinlto|lto-pre-link|lto)<(O[0123sz])>$");
 
-// This option is used in simplifying testing SampleFDO optimizations for
-// profile loading.
-static cl::opt
-EnableCHR("enable-chr-npm", cl::init(true), cl::Hidden,
-  cl::desc("Enable control height reduction optimization (CHR)"));
-
 /// Flag to enable inline deferral during PGO.
 static cl::opt
 EnablePGOInlineDeferral("enable-npm-pgo-inline-deferral", cl::init(true),
@@ -313,8 +276,15 @@ PipelineTuningOptions::PipelineTuni

[llvm-branch-commits] [llvm] 6f79204 - Reapply "[CodeGen] [WinException] Only produce handler data at the end of the function if needed"

2020-11-23 Thread Martin Storsjö via llvm-branch-commits

Author: Martin Storsjö
Date: 2020-11-23T23:17:03+02:00
New Revision: 6f792041a5cb964b4099614952a54c4961bfb872

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

LOG: Reapply "[CodeGen] [WinException] Only produce handler data at the end of 
the function if needed"

This reapplies 36c64af9d7f97414d48681b74352c9684077259b in updated
form.

Emit the xdata for each function at .seh_endproc. This keeps the
exact same output header order for most code generated by the LLVM
CodeGen layer. (Sections still change order for code built from
assembly where functions lack an explicit .seh_handlerdata
directive, and functions with chained unwind info.)

The practical effect should be that assembly output lacks
superfluous ".seh_handlerdata; .text" pairs at the end of functions
that don't handle exceptions, which allows such functions to use
the AArch64 packed unwind format again.

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

Added: 


Modified: 
llvm/include/llvm/MC/MCStreamer.h
llvm/include/llvm/MC/MCWin64EH.h
llvm/include/llvm/MC/MCWinEH.h
llvm/lib/CodeGen/AsmPrinter/WinException.cpp
llvm/lib/MC/MCStreamer.cpp
llvm/lib/MC/MCWin64EH.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64WinCOFFStreamer.cpp
llvm/lib/Target/X86/MCTargetDesc/X86WinCOFFStreamer.cpp
llvm/test/CodeGen/AArch64/win64-jumptable.ll
llvm/test/CodeGen/AArch64/wineh1.mir
llvm/test/CodeGen/X86/avx512-intel-ocl.ll
llvm/test/CodeGen/X86/avx512-regcall-Mask.ll
llvm/test/CodeGen/X86/avx512-regcall-NoMask.ll
llvm/test/CodeGen/X86/break-false-dep.ll
llvm/test/CodeGen/X86/conditional-tailcall-pgso.ll
llvm/test/CodeGen/X86/conditional-tailcall.ll
llvm/test/CodeGen/X86/gnu-seh-nolpads.ll
llvm/test/CodeGen/X86/mixed-ptr-sizes.ll
llvm/test/CodeGen/X86/musttail-varargs.ll
llvm/test/CodeGen/X86/no-sse-win64.ll
llvm/test/CodeGen/X86/win64-jumptable.ll
llvm/test/CodeGen/X86/win64_frame.ll

Removed: 




diff  --git a/llvm/include/llvm/MC/MCStreamer.h 
b/llvm/include/llvm/MC/MCStreamer.h
index 6a0ef5360cd4..9581a08fc5cf 100644
--- a/llvm/include/llvm/MC/MCStreamer.h
+++ b/llvm/include/llvm/MC/MCStreamer.h
@@ -206,6 +206,7 @@ class MCStreamer {
   std::vector> WinFrameInfos;
 
   WinEH::FrameInfo *CurrentWinFrameInfo;
+  size_t CurrentProcWinFrameInfoStartIndex;
 
   /// Tracks an index to represent the order a symbol was emitted in.
   /// Zero means we did not emit that symbol.
@@ -244,6 +245,8 @@ class MCStreamer {
 return CurrentWinFrameInfo;
   }
 
+  virtual void EmitWindowsUnwindTables(WinEH::FrameInfo *Frame);
+
   virtual void EmitWindowsUnwindTables();
 
   virtual void emitRawTextImpl(StringRef String);

diff  --git a/llvm/include/llvm/MC/MCWin64EH.h 
b/llvm/include/llvm/MC/MCWin64EH.h
index 60ec06e61b7c..065161d1759e 100644
--- a/llvm/include/llvm/MC/MCWin64EH.h
+++ b/llvm/include/llvm/MC/MCWin64EH.h
@@ -53,14 +53,15 @@ struct Instruction {
 class UnwindEmitter : public WinEH::UnwindEmitter {
 public:
   void Emit(MCStreamer &Streamer) const override;
-  void EmitUnwindInfo(MCStreamer &Streamer, WinEH::FrameInfo *FI) const 
override;
+  void EmitUnwindInfo(MCStreamer &Streamer, WinEH::FrameInfo *FI,
+  bool HandlerData) const override;
 };
 
 class ARM64UnwindEmitter : public WinEH::UnwindEmitter {
 public:
   void Emit(MCStreamer &Streamer) const override;
-  void EmitUnwindInfo(MCStreamer &Streamer,
-  WinEH::FrameInfo *FI) const override;
+  void EmitUnwindInfo(MCStreamer &Streamer, WinEH::FrameInfo *FI,
+  bool HandlerData) const override;
 };
 
 }

diff  --git a/llvm/include/llvm/MC/MCWinEH.h b/llvm/include/llvm/MC/MCWinEH.h
index a46f56d708ce..5688255810d0 100644
--- a/llvm/include/llvm/MC/MCWinEH.h
+++ b/llvm/include/llvm/MC/MCWinEH.h
@@ -80,7 +80,8 @@ class UnwindEmitter {
 
   /// This emits the unwind info sections (.pdata and .xdata in PE/COFF).
   virtual void Emit(MCStreamer &Streamer) const = 0;
-  virtual void EmitUnwindInfo(MCStreamer &Streamer, FrameInfo *FI) const = 0;
+  virtual void EmitUnwindInfo(MCStreamer &Streamer, FrameInfo *FI,
+  bool HandlerData) const = 0;
 };
 }
 }

diff  --git a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp 
b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
index 26b6a322da38..3a9c9df79783 100644
--- a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
@@ -258,11 +258,11 @@ void WinException::endFuncletImpl() {
 if (F.hasPersonalityFn())
   Per = classifyEHPersonality(F.getPersonalityFn()->stripPointerCasts());
 
-// Emit an UNWIND_INFO struct describing the prologue.
-Asm->OutStreamer->EmitWinEHHandlerData();
-
 if (Per == EHPersonality::MSVC

[llvm-branch-commits] [llvm] 6a2799c - Revert "[CGSCC] Detect devirtualization in more cases"

2020-11-23 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-11-23T13:21:05-08:00
New Revision: 6a2799cf8ecf1b649cfa511aec64256a01f79436

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

LOG: Revert "[CGSCC] Detect devirtualization in more cases"

This reverts commit 14a68b4aa9732293ad7e16f105b0feb53dc8dbe2.

Causes building self hosted clang to crash when using NPM.

Added: 


Modified: 
llvm/include/llvm/Analysis/CGSCCPassManager.h
llvm/lib/Analysis/CGSCCPassManager.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/test/Transforms/Inline/devirtualize-3.ll
llvm/test/Transforms/Inline/devirtualize.ll

Removed: 
llvm/test/Transforms/Inline/devirtualize-5.ll
llvm/test/Transforms/Inline/devirtualize-6.ll



diff  --git a/llvm/include/llvm/Analysis/CGSCCPassManager.h 
b/llvm/include/llvm/Analysis/CGSCCPassManager.h
index b2b690ddd28b..755bc92ddccf 100644
--- a/llvm/include/llvm/Analysis/CGSCCPassManager.h
+++ b/llvm/include/llvm/Analysis/CGSCCPassManager.h
@@ -90,7 +90,6 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/PriorityWorklist.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -315,16 +314,6 @@ struct CGSCCUpdateResult {
   /// for a better technique.
   SmallDenseSet, 4>
   &InlinedInternalEdges;
-
-  /// Weak VHs to keep track of indirect calls for the purposes of detecting
-  /// devirtualization.
-  ///
-  /// This is a map to avoid having duplicate entries. If a Value is
-  /// deallocated, its corresponding WeakTrackingVH will be nulled out. When
-  /// checking if a Value is in the map or not, also check if the corresponding
-  /// WeakTrackingVH is null to avoid issues with a new Value sharing the same
-  /// address as a deallocated one.
-  SmallMapVector IndirectVHs;
 };
 
 /// The core module pass which does a post-order walk of the SCCs and
@@ -607,6 +596,9 @@ class DevirtSCCRepeatedPass
 // a pointer that we can update.
 LazyCallGraph::SCC *C = &InitialC;
 
+// Collect value handles for all of the indirect call sites.
+SmallVector CallHandles;
+
 // Struct to track the counts of direct and indirect calls in each function
 // of the SCC.
 struct CallCount {
@@ -616,37 +608,35 @@ class DevirtSCCRepeatedPass
 
 // Put value handles on all of the indirect calls and return the number of
 // direct calls for each function in the SCC.
-auto ScanSCC =
-[](LazyCallGraph::SCC &C,
-   SmallMapVector &CallHandles) {
-  assert(CallHandles.empty() &&
- "Must start with a clear set of handles.");
-
-  SmallDenseMap CallCounts;
-  CallCount CountLocal = {0, 0};
-  for (LazyCallGraph::Node &N : C) {
-CallCount &Count =
-CallCounts.insert(std::make_pair(&N.getFunction(), CountLocal))
-.first->second;
-for (Instruction &I : instructions(N.getFunction()))
-  if (auto *CB = dyn_cast(&I)) {
-if (CB->getCalledFunction()) {
-  ++Count.Direct;
-} else {
-  ++Count.Indirect;
-  CallHandles.insert({CB, WeakTrackingVH(CB)});
-}
-  }
+auto ScanSCC = [](LazyCallGraph::SCC &C,
+  SmallVectorImpl &CallHandles) {
+  assert(CallHandles.empty() && "Must start with a clear set of handles.");
+
+  SmallDenseMap CallCounts;
+  CallCount CountLocal = {0, 0};
+  for (LazyCallGraph::Node &N : C) {
+CallCount &Count =
+CallCounts.insert(std::make_pair(&N.getFunction(), CountLocal))
+.first->second;
+for (Instruction &I : instructions(N.getFunction()))
+  if (auto *CB = dyn_cast(&I)) {
+if (CB->getCalledFunction()) {
+  ++Count.Direct;
+} else {
+  ++Count.Indirect;
+  CallHandles.push_back(WeakTrackingVH(&I));
+}
   }
+  }
 
-  return CallCounts;
-};
+  return CallCounts;
+};
 
-UR.IndirectVHs.clear();
 // Populate the initial call handles and get the initial call counts.
-auto CallCounts = ScanSCC(*C, UR.IndirectVHs);
+auto CallCounts = ScanSCC(*C, CallHandles);
 
 for (int Iteration = 0;; ++Iteration) {
+
   if (!PI.runBeforePass(Pass, *C))
 continue;
 
@@ -669,22 +659,33 @@ class DevirtSCCRepeatedPass
   assert(C->begin() != C->end() && "Cannot have an empty SCC!");
 
   // Check whether any of the handles were devirtualized.
-  bool Devirt = llvm::any_of(UR.IndirectVHs, [](auto &P) -> bool {
-if (P.second) {
-  CallBase *CB = cast(P.second);
-  if (CB->getCalledFunction()) 

[llvm-branch-commits] [clang] f6b02ec - APINotes: add property models for YAML attributes

2020-11-23 Thread Saleem Abdulrasool via llvm-branch-commits

Author: Saleem Abdulrasool
Date: 2020-11-23T21:29:17Z
New Revision: f6b02ecd027a825f1f4a1804c464f9f96d9372c9

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

LOG: APINotes: add property models for YAML attributes

This adds internal representation of the attributes in a more usable
form.  This is meant to allow programmatic access to the attributes that
are specified in the YAML data.

This is based upon the work contributed by Apple at
https://github.com/llvm/llvm-project-staging/tree/staging/swift/apinotes.

Differential Revision: https://reviews.llvm.org/D91104
Reviewed By: Gabor Marton

Added: 
clang/lib/APINotes/APINotesTypes.cpp

Modified: 
clang/include/clang/APINotes/Types.h
clang/lib/APINotes/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/APINotes/Types.h 
b/clang/include/clang/APINotes/Types.h
index be2a99ad6fd0..3095bfbf1718 100644
--- a/clang/include/clang/APINotes/Types.h
+++ b/clang/include/clang/APINotes/Types.h
@@ -9,6 +9,12 @@
 #ifndef LLVM_CLANG_APINOTES_TYPES_H
 #define LLVM_CLANG_APINOTES_TYPES_H
 
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
 namespace clang {
 namespace api_notes {
 enum class RetainCountConventionKind {
@@ -34,6 +40,694 @@ enum class SwiftNewTypeKind {
   Struct,
   Enum,
 };
+
+/// Describes API notes data for any entity.
+///
+/// This is used as the base of all API notes.
+class CommonEntityInfo {
+public:
+  /// Message to use when this entity is unavailable.
+  std::string UnavailableMsg;
+
+  /// Whether this entity is marked unavailable.
+  unsigned Unavailable : 1;
+
+  /// Whether this entity is marked unavailable in Swift.
+  unsigned UnavailableInSwift : 1;
+
+private:
+  /// Whether SwiftPrivate was specified.
+  unsigned SwiftPrivateSpecified : 1;
+
+  /// Whether this entity is considered "private" to a Swift overlay.
+  unsigned SwiftPrivate : 1;
+
+public:
+  /// Swift name of this entity.
+  std::string SwiftName;
+
+  CommonEntityInfo()
+  : Unavailable(0), UnavailableInSwift(0), SwiftPrivateSpecified(0),
+SwiftPrivate(0) {}
+
+  llvm::Optional isSwiftPrivate() const {
+return SwiftPrivateSpecified ? llvm::Optional(SwiftPrivate)
+ : llvm::None;
+  }
+
+  void setSwiftPrivate(llvm::Optional Private) {
+SwiftPrivateSpecified = Private.hasValue();
+SwiftPrivate = Private.hasValue() ? *Private : 0;
+  }
+
+  friend bool operator==(const CommonEntityInfo &, const CommonEntityInfo &);
+
+  CommonEntityInfo &operator|=(const CommonEntityInfo &RHS) {
+// Merge unavailability.
+if (RHS.Unavailable) {
+  Unavailable = true;
+  if (UnavailableMsg.empty())
+UnavailableMsg = RHS.UnavailableMsg;
+}
+
+if (RHS.UnavailableInSwift) {
+  UnavailableInSwift = true;
+  if (UnavailableMsg.empty())
+UnavailableMsg = RHS.UnavailableMsg;
+}
+
+if (!SwiftPrivateSpecified)
+  setSwiftPrivate(RHS.isSwiftPrivate());
+
+if (SwiftName.empty())
+  SwiftName = RHS.SwiftName;
+
+return *this;
+  }
+
+  LLVM_DUMP_METHOD void dump(llvm::raw_ostream &OS);
+};
+
+inline bool operator==(const CommonEntityInfo &LHS,
+   const CommonEntityInfo &RHS) {
+  return LHS.UnavailableMsg == RHS.UnavailableMsg &&
+ LHS.Unavailable == RHS.Unavailable &&
+ LHS.UnavailableInSwift == RHS.UnavailableInSwift &&
+ LHS.SwiftPrivateSpecified == RHS.SwiftPrivateSpecified &&
+ LHS.SwiftPrivate == RHS.SwiftPrivate && LHS.SwiftName == 
RHS.SwiftName;
+}
+
+inline bool operator!=(const CommonEntityInfo &LHS,
+   const CommonEntityInfo &RHS) {
+  return !(LHS == RHS);
+}
+
+/// Describes API notes for types.
+class CommonTypeInfo : public CommonEntityInfo {
+  /// The Swift type to which a given type is bridged.
+  ///
+  /// Reflects the swift_bridge attribute.
+  llvm::Optional SwiftBridge;
+
+  /// The NS error domain for this type.
+  llvm::Optional NSErrorDomain;
+
+public:
+  CommonTypeInfo() : CommonEntityInfo() {}
+
+  const llvm::Optional &getSwiftBridge() const {
+return SwiftBridge;
+  }
+
+  void setSwiftBridge(const llvm::Optional &SwiftType) {
+SwiftBridge = SwiftType;
+  }
+
+  void setSwiftBridge(const llvm::Optional &SwiftType) {
+SwiftBridge = SwiftType
+  ? llvm::Optional(std::string(*SwiftType))
+  : llvm::None;
+  }
+
+  const llvm::Optional &getNSErrorDomain() const {
+return NSErrorDomain;
+  }
+
+  void setNSErrorDomain(const llvm::Optional &Domain) {
+NSErrorDomain = Domain;
+  }
+
+  void setNSErrorDomain(const llvm::Optional &Domain) {
+NSErrorDomain =
+Domain ? llvm::Optional(std::string(

[llvm-branch-commits] [llvm] a1c342b - [gn build] Port f6b02ecd027

2020-11-23 Thread LLVM GN Syncbot via llvm-branch-commits

Author: LLVM GN Syncbot
Date: 2020-11-23T21:33:46Z
New Revision: a1c342bf1146d52873648368210fbcaecc26f1b6

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

LOG: [gn build] Port f6b02ecd027

Added: 


Modified: 
llvm/utils/gn/secondary/clang/lib/APINotes/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/clang/lib/APINotes/BUILD.gn 
b/llvm/utils/gn/secondary/clang/lib/APINotes/BUILD.gn
index e49d3d08dc07..e2cf85f12a62 100644
--- a/llvm/utils/gn/secondary/clang/lib/APINotes/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/lib/APINotes/BUILD.gn
@@ -5,5 +5,8 @@ static_library("APINotes") {
 "//clang/lib/Basic",
 "//llvm/lib/Support",
   ]
-  sources = [ "APINotesYAMLCompiler.cpp" ]
+  sources = [
+"APINotesTypes.cpp",
+"APINotesYAMLCompiler.cpp",
+  ]
 }



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


[llvm-branch-commits] [llvm] ab29f09 - [InstCombine] propagate 'nsw' on pointer difference of 'inbounds' geps

2020-11-23 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2020-11-23T16:50:09-05:00
New Revision: ab29f091eb64c8608ba943df604b218bcff41a26

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

LOG: [InstCombine] propagate 'nsw' on pointer difference of 'inbounds' geps

This is a retry of 324a53205. I cautiously reverted that at 6aa3fc4
because the rules about gep math were not clear. Since then, we
have added this line to LangRef for gep inbounds:
"The successive addition of offsets (without adding the base address)
does not wrap the pointer index type in a signed sense (nsw)."

See D90708 and post-commit comments on the revert patch for more details.

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/test/Transforms/InstCombine/sub-gep.ll
llvm/test/Transforms/InstCombine/sub.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index b8431a5a4532..9a6a790aefaf 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -1678,11 +1678,12 @@ Value 
*InstCombinerImpl::OptimizePointerDifference(Value *LHS, Value *RHS,
 I->getOpcode() == Instruction::Mul)
   I->setHasNoUnsignedWrap();
 
-  // If we had a constant expression GEP on the other side offsetting the
-  // pointer, subtract it from the offset we have.
+  // If we have a 2nd GEP of the same base pointer, subtract the offsets.
+  // If both GEPs are inbounds, then the subtract does not have signed 
overflow.
   if (GEP2) {
 Value *Offset = EmitGEPOffset(GEP2);
-Result = Builder.CreateSub(Result, Offset, "gep
diff ");
+Result = Builder.CreateSub(Result, Offset, "gep
diff ", /* NUW */ false,
+   GEP1->isInBounds() && GEP2->isInBounds());
   }
 
   // If we have p - gep(p, ...)  then we have to negate the result.

diff  --git a/llvm/test/Transforms/InstCombine/sub-gep.ll 
b/llvm/test/Transforms/InstCombine/sub-gep.ll
index 9868ed1cdf57..2389b70c3452 100644
--- a/llvm/test/Transforms/InstCombine/sub-gep.ll
+++ b/llvm/test/Transforms/InstCombine/sub-gep.ll
@@ -245,7 +245,7 @@ define i64 @test24b(i8* %P, i64 %A){
 define i64 @test25(i8* %P, i64 %A){
 ; CHECK-LABEL: @test25(
 ; CHECK-NEXT:[[B_IDX:%.*]] = shl nsw i64 [[A:%.*]], 1
-; CHECK-NEXT:[[GEPDIFF:%.*]] = add i64 [[B_IDX]], -84
+; CHECK-NEXT:[[GEPDIFF:%.*]] = add nsw i64 [[B_IDX]], -84
 ; CHECK-NEXT:ret i64 [[GEPDIFF]]
 ;
   %B = getelementptr inbounds [42 x i16], [42 x i16]* @Arr, i64 0, i64 %A
@@ -260,7 +260,7 @@ define i16 @test25_as1(i8 addrspace(1)* %P, i64 %A) {
 ; CHECK-LABEL: @test25_as1(
 ; CHECK-NEXT:[[TMP1:%.*]] = trunc i64 [[A:%.*]] to i16
 ; CHECK-NEXT:[[B_IDX:%.*]] = shl nsw i16 [[TMP1]], 1
-; CHECK-NEXT:[[GEPDIFF:%.*]] = add i16 [[B_IDX]], -84
+; CHECK-NEXT:[[GEPDIFF:%.*]] = add nsw i16 [[B_IDX]], -84
 ; CHECK-NEXT:ret i16 [[GEPDIFF]]
 ;
   %B = getelementptr inbounds [42 x i16], [42 x i16] addrspace(1)* @Arr_as1, 
i64 0, i64 %A
@@ -272,7 +272,7 @@ define i16 @test25_as1(i8 addrspace(1)* %P, i64 %A) {
 define i64 @test30(i8* %foo, i64 %i, i64 %j) {
 ; CHECK-LABEL: @test30(
 ; CHECK-NEXT:[[GEP1_IDX:%.*]] = shl nsw i64 [[I:%.*]], 2
-; CHECK-NEXT:[[GEPDIFF:%.*]] = sub i64 [[GEP1_IDX]], [[J:%.*]]
+; CHECK-NEXT:[[GEPDIFF:%.*]] = sub nsw i64 [[GEP1_IDX]], [[J:%.*]]
 ; CHECK-NEXT:ret i64 [[GEPDIFF]]
 ;
   %bit = bitcast i8* %foo to i32*
@@ -287,7 +287,7 @@ define i64 @test30(i8* %foo, i64 %i, i64 %j) {
 define i16 @test30_as1(i8 addrspace(1)* %foo, i16 %i, i16 %j) {
 ; CHECK-LABEL: @test30_as1(
 ; CHECK-NEXT:[[GEP1_IDX:%.*]] = shl nsw i16 [[I:%.*]], 2
-; CHECK-NEXT:[[GEPDIFF:%.*]] = sub i16 [[GEP1_IDX]], [[J:%.*]]
+; CHECK-NEXT:[[GEPDIFF:%.*]] = sub nsw i16 [[GEP1_IDX]], [[J:%.*]]
 ; CHECK-NEXT:ret i16 [[GEPDIFF]]
 ;
   %bit = bitcast i8 addrspace(1)* %foo to i32 addrspace(1)*
@@ -299,9 +299,11 @@ define i16 @test30_as1(i8 addrspace(1)* %foo, i16 %i, i16 
%j) {
   ret i16 %sub
 }
 
+; Inbounds translates to 'nsw' on sub
+
 define i64 @gep_
diff _both_inbounds(i8* %foo, i64 %i, i64 %j) {
 ; CHECK-LABEL: @gep_
diff _both_inbounds(
-; CHECK-NEXT:[[GEPDIFF:%.*]] = sub i64 [[I:%.*]], [[J:%.*]]
+; CHECK-NEXT:[[GEPDIFF:%.*]] = sub nsw i64 [[I:%.*]], [[J:%.*]]
 ; CHECK-NEXT:ret i64 [[GEPDIFF]]
 ;
   %gep1 = getelementptr inbounds i8, i8* %foo, i64 %i
@@ -312,6 +314,8 @@ define i64 @gep_
diff _both_inbounds(i8* %foo, i64 %i, i64 %j) {
   ret i64 %sub
 }
 
+; Negative test for 'nsw' - both geps must be inbounds
+
 define i64 @gep_
diff _first_inbounds(i8* %foo, i64 %i, i64 %j) {
 ; CHECK-LABEL: @gep_
diff _first_inbounds(
 ; CHECK-NEXT:[[GEPDIFF:%.*]] = sub i64 [[I:%.*]], [[J:%.*]]
@@ 

[llvm-branch-commits] [mlir] df9ae59 - Use MlirStringRef throughout the C API

2020-11-23 Thread via llvm-branch-commits

Author: George
Date: 2020-11-23T14:07:30-08:00
New Revision: df9ae5992889560a8f3c6760b54d5051b47c7bf5

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

LOG: Use MlirStringRef throughout the C API

While this makes the unit tests a bit more verbose, this simplifies the 
creation of bindings because only the bidirectional mapping between the host 
language's string type and MlirStringRef need to be implemented.

Reviewed By: mehdi_amini

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

Added: 


Modified: 
mlir/include/mlir-c/IR.h
mlir/include/mlir-c/Support.h
mlir/include/mlir/CAPI/Utils.h
mlir/lib/CAPI/IR/IR.cpp
mlir/lib/CAPI/IR/StandardAttributes.cpp
mlir/test/CAPI/ir.c
mlir/test/CAPI/pass.c

Removed: 




diff  --git a/mlir/include/mlir-c/IR.h b/mlir/include/mlir-c/IR.h
index 6c9394c38b17..2ca5b80b825a 100644
--- a/mlir/include/mlir-c/IR.h
+++ b/mlir/include/mlir-c/IR.h
@@ -69,7 +69,7 @@ DEFINE_C_API_STRUCT(MlirValue, const void);
  * a string.
  */
 struct MlirNamedAttribute {
-  const char *name;
+  MlirStringRef name;
   MlirAttribute attribute;
 };
 typedef struct MlirNamedAttribute MlirNamedAttribute;
@@ -143,10 +143,8 @@ MLIR_CAPI_EXPORTED MlirStringRef 
mlirDialectGetNamespace(MlirDialect dialect);
 
//===--===//
 
 /// Creates an File/Line/Column location owned by the given context.
-MLIR_CAPI_EXPORTED MlirLocation mlirLocationFileLineColGet(MlirContext context,
-   const char 
*filename,
-   unsigned line,
-   unsigned col);
+MLIR_CAPI_EXPORTED MlirLocation mlirLocationFileLineColGet(
+MlirContext context, MlirStringRef filename, unsigned line, unsigned col);
 
 /// Creates a location with unknown position owned by the given context.
 MLIR_CAPI_EXPORTED MlirLocation mlirLocationUnknownGet(MlirContext context);
@@ -170,7 +168,7 @@ MLIR_CAPI_EXPORTED MlirModule 
mlirModuleCreateEmpty(MlirLocation location);
 
 /// Parses a module from the string and transfers ownership to the caller.
 MLIR_CAPI_EXPORTED MlirModule mlirModuleCreateParse(MlirContext context,
-const char *module);
+MlirStringRef module);
 
 /// Gets the context that a module was created with.
 MLIR_CAPI_EXPORTED MlirContext mlirModuleGetContext(MlirModule module);
@@ -202,7 +200,7 @@ MLIR_CAPI_EXPORTED MlirOperation 
mlirModuleGetOperation(MlirModule module);
  * mlirOperationState* functions instead.
  */
 struct MlirOperationState {
-  const char *name;
+  MlirStringRef name;
   MlirLocation location;
   intptr_t nResults;
   MlirType *results;
@@ -218,16 +216,16 @@ struct MlirOperationState {
 typedef struct MlirOperationState MlirOperationState;
 
 /// Constructs an operation state from a name and a location.
-MLIR_CAPI_EXPORTED MlirOperationState mlirOperationStateGet(const char *name,
+MLIR_CAPI_EXPORTED MlirOperationState mlirOperationStateGet(MlirStringRef name,
 MlirLocation loc);
 
 /// Adds a list of components to the operation state.
 MLIR_CAPI_EXPORTED void mlirOperationStateAddResults(MlirOperationState *state,
  intptr_t n,
  MlirType const *results);
-MLIR_CAPI_EXPORTED void mlirOperationStateAddOperands(MlirOperationState 
*state,
-  intptr_t n,
-  MlirValue const 
*operands);
+MLIR_CAPI_EXPORTED void
+mlirOperationStateAddOperands(MlirOperationState *state, intptr_t n,
+  MlirValue const *operands);
 MLIR_CAPI_EXPORTED void
 mlirOperationStateAddOwnedRegions(MlirOperationState *state, intptr_t n,
   MlirRegion const *regions);
@@ -349,18 +347,18 @@ mlirOperationGetAttribute(MlirOperation op, intptr_t pos);
 
 /// Returns an attribute attached to the operation given its name.
 MLIR_CAPI_EXPORTED MlirAttribute
-mlirOperationGetAttributeByName(MlirOperation op, const char *name);
+mlirOperationGetAttributeByName(MlirOperation op, MlirStringRef name);
 
 /** Sets an attribute by name, replacing the existing if it exists or
  * adding a new one otherwise. */
 MLIR_CAPI_EXPORTED void mlirOperationSetAttributeByName(MlirOperation op,
-const char *name,
+MlirStringRef name,
  

[llvm-branch-commits] [llvm] 03dab46 - [RISCV] Remove unused VM register class

2020-11-23 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-11-23T14:17:06-08:00
New Revision: 03dab46d7f7323ba2b37416829cc364a4de4f294

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

LOG: [RISCV] Remove unused VM register class

Nothing references this class today so it looks like some leftover.

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

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVRegisterInfo.td

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td 
b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
index cda75c816ed1..6d6babce98ca 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
@@ -331,13 +331,6 @@ def VRM8 : RegisterClass<"RISCV", [nxv32i16, nxv16i32, 
nxv8i64], 64,
 
 def VMaskVT : RegisterTypes<[nxv1i1, nxv2i1, nxv4i1, nxv8i1, nxv16i1, 
nxv32i1]>;
 
-def VM : RegisterClass<"RISCV", VMaskVT.types, 64, (add
-(sequence "V%u", 25, 31),
-(sequence "V%u", 8, 24),
-(sequence "V%u", 0, 7))> {
-  let Size = 64;
-}
-
 def VMV0 : RegisterClass<"RISCV", VMaskVT.types, 64, (add V0)> {
   let Size = 64;
 }



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


[llvm-branch-commits] [libcxx] 0a20660 - [libcxx] Resolve LWG 2724 protected -> private.

2020-11-23 Thread via llvm-branch-commits

Author: zoecarver
Date: 2020-11-23T14:27:22-08:00
New Revision: 0a20660c8fcb5bb8469e323585eeaecacea67c44

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

LOG: [libcxx] Resolve LWG 2724 protected -> private.

Fixes LWG issue 2724: "The protected virtual member functions of 
memory_resource should be private."

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

Added: 

libcxx/test/std/experimental/memory/memory.resource/memory.resource.priv/private_members.fail.cpp

Modified: 
libcxx/include/experimental/memory_resource

Removed: 

libcxx/test/std/experimental/memory/memory.resource/memory.resource.priv/protected_members.fail.cpp



diff  --git a/libcxx/include/experimental/memory_resource 
b/libcxx/include/experimental/memory_resource
index f999fb9befda..816d21f51368 100644
--- a/libcxx/include/experimental/memory_resource
+++ b/libcxx/include/experimental/memory_resource
@@ -116,7 +116,7 @@ public:
 { return do_is_equal(__other); }
 
 // 8.5.3, memory.resource.priv
-protected:
+private:
 virtual void* do_allocate(size_t, size_t) = 0;
 virtual void do_deallocate(void*, size_t, size_t) = 0;
 virtual bool do_is_equal(memory_resource const &) const _NOEXCEPT = 0;
@@ -381,7 +381,7 @@ public:
 { return __alloc_; }
 
 // 8.7.3, memory.resource.adaptor.mem
-protected:
+private:
 virtual void * do_allocate(size_t __bytes, size_t)
 {
 if (__bytes > __max_size()) {
@@ -407,7 +407,6 @@ protected:
 return __p  ? __alloc_ == __p->__alloc_ : false;
 }
 
-private:
 _LIBCPP_INLINE_VISIBILITY
 size_t __max_size() const _NOEXCEPT {
 return numeric_limits::max() - _MaxAlign;

diff  --git 
a/libcxx/test/std/experimental/memory/memory.resource/memory.resource.priv/protected_members.fail.cpp
 
b/libcxx/test/std/experimental/memory/memory.resource/memory.resource.priv/private_members.fail.cpp
similarity index 73%
rename from 
libcxx/test/std/experimental/memory/memory.resource/memory.resource.priv/protected_members.fail.cpp
rename to 
libcxx/test/std/experimental/memory/memory.resource/memory.resource.priv/private_members.fail.cpp
index 85c4ce4ee91c..a0c84b0fa83c 100644
--- 
a/libcxx/test/std/experimental/memory/memory.resource/memory.resource.priv/protected_members.fail.cpp
+++ 
b/libcxx/test/std/experimental/memory/memory.resource/memory.resource.priv/private_members.fail.cpp
@@ -10,9 +10,9 @@
 
 // 
 
-// memory_resource::do_allocate(size_t, size_t);  /* protected */
-// memory_resource::do_deallocate(void*, size_t, size_t); /* protected */
-// memory_resource::do_is_equal(memory_resource const&);  /* protected */
+// memory_resource::do_allocate(size_t, size_t);  /* private */
+// memory_resource::do_deallocate(void*, size_t, size_t); /* private */
+// memory_resource::do_is_equal(memory_resource const&);  /* private */
 
 #include 
 
@@ -20,9 +20,9 @@ namespace ex = std::experimental::pmr;
 
 int main(int, char**) {
 ex::memory_resource *m = ex::new_delete_resource();
-m->do_allocate(0, 0); // expected-error{{'do_allocate' is a protected 
member}}
-m->do_deallocate(nullptr, 0, 0); // expected-error{{'do_deallocate' is a 
protected member}}
-m->do_is_equal(*m); // expected-error{{'do_is_equal' is a protected 
member}}
+m->do_allocate(0, 0); // expected-error{{'do_allocate' is a private 
member}}
+m->do_deallocate(nullptr, 0, 0); // expected-error{{'do_deallocate' is a 
private member}}
+m->do_is_equal(*m); // expected-error{{'do_is_equal' is a private member}}
 
   return 0;
 }



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


[llvm-branch-commits] [mlir] f7d033f - [mlir] Support WsLoopOp in OpenMP to LLVM dialect conversion

2020-11-23 Thread Alex Zinenko via llvm-branch-commits

Author: Alex Zinenko
Date: 2020-11-23T23:28:02+01:00
New Revision: f7d033f4d80f476246a70f165e7455639818f907

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

LOG: [mlir] Support WsLoopOp in OpenMP to LLVM dialect conversion

It is a simple conversion that only requires to change the region argument
types, generalize it from ParallelOp.

Reviewed By: kiranchandramohan

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

Added: 


Modified: 
mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir

Removed: 




diff  --git a/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp 
b/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
index cfb553da407c..91e97ca1ec50 100644
--- a/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
+++ b/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
@@ -16,18 +16,23 @@
 using namespace mlir;
 
 namespace {
-struct ParallelOpConversion : public ConvertToLLVMPattern {
-  explicit ParallelOpConversion(MLIRContext *context,
-LLVMTypeConverter &typeConverter)
-  : ConvertToLLVMPattern(omp::ParallelOp::getOperationName(), context,
+/// A pattern that converts the region arguments in a single-region OpenMP
+/// operation to the LLVM dialect. The body of the region is not modified and 
is
+/// expected to either be processed by the conversion infrastructure or already
+/// contain ops compatible with LLVM dialect types.
+template 
+struct RegionOpConversion : public ConvertToLLVMPattern {
+  explicit RegionOpConversion(MLIRContext *context,
+  LLVMTypeConverter &typeConverter)
+  : ConvertToLLVMPattern(OpType::getOperationName(), context,
  typeConverter) {}
 
   LogicalResult
   matchAndRewrite(Operation *op, ArrayRef operands,
   ConversionPatternRewriter &rewriter) const override {
-auto curOp = cast(op);
-auto newOp = rewriter.create(curOp.getLoc(), TypeRange(),
-  operands, curOp.getAttrs());
+auto curOp = cast(op);
+auto newOp = rewriter.create(curOp.getLoc(), TypeRange(), operands,
+ curOp.getAttrs());
 rewriter.inlineRegionBefore(curOp.region(), newOp.region(),
 newOp.region().end());
 if (failed(rewriter.convertRegionTypes(&newOp.region(), typeConverter)))
@@ -42,7 +47,8 @@ struct ParallelOpConversion : public ConvertToLLVMPattern {
 void mlir::populateOpenMPToLLVMConversionPatterns(
 MLIRContext *context, LLVMTypeConverter &converter,
 OwningRewritePatternList &patterns) {
-  patterns.insert(context, converter);
+  patterns.insert,
+  RegionOpConversion>(context, converter);
 }
 
 namespace {
@@ -63,8 +69,8 @@ void ConvertOpenMPToLLVMPass::runOnOperation() {
   populateOpenMPToLLVMConversionPatterns(context, converter, patterns);
 
   LLVMConversionTarget target(getContext());
-  target.addDynamicallyLegalOp(
-  [&](omp::ParallelOp op) { return converter.isLegal(&op.getRegion()); });
+  target.addDynamicallyLegalOp(
+  [&](Operation *op) { return converter.isLegal(&op->getRegion(0)); });
   target.addLegalOp();
   if (failed(applyPartialConversion(module, target, std::move(patterns

diff  --git a/mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir 
b/mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir
index d38a6ea7e3a9..62ea39f078b2 100644
--- a/mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir
+++ b/mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir
@@ -28,3 +28,22 @@ func @branch_loop() {
   }
   return
 }
+
+// CHECK-LABEL: @wsloop
+// CHECK: (%[[ARG0:.*]]: !llvm.i64, %[[ARG1:.*]]: !llvm.i64, %[[ARG2:.*]]: 
!llvm.i64, %[[ARG3:.*]]: !llvm.i64, %[[ARG4:.*]]: !llvm.i64, %[[ARG5:.*]]: 
!llvm.i64)
+func @wsloop(%arg0: index, %arg1: index, %arg2: index, %arg3: index, %arg4: 
index, %arg5: index) {
+  // CHECK: omp.parallel
+  omp.parallel {
+// CHECK: omp.wsloop
+// CHECK: (%[[ARG0]], %[[ARG1]], %[[ARG2]], %[[ARG3]], %[[ARG4]], 
%[[ARG5]])
+"omp.wsloop"(%arg0, %arg1, %arg2, %arg3, %arg4, %arg5) ( {
+// CHECK: ^{{.*}}(%[[ARG6:.*]]: !llvm.i64, %[[ARG7:.*]]: !llvm.i64):
+^bb0(%arg6: index, %arg7: index):  // no predecessors
+  // CHECK: "test.payload"(%[[ARG6]], %[[ARG7]]) : (!llvm.i64, !llvm.i64) 
-> ()
+  "test.payload"(%arg6, %arg7) : (index, index) -> ()
+  omp.yield
+}) {operand_segment_sizes = dense<[2, 2, 2, 0, 0, 0, 0, 0, 0]> : 
vector<9xi32>} : (index, index, index, index, index, index) -> ()
+omp.terminator
+  }
+  return
+}



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.

[llvm-branch-commits] [llvm] b06a2ad - [LoopVectorizer] Lower uniform loads as a single load (instead of relying on CSE)

2020-11-23 Thread Philip Reames via llvm-branch-commits

Author: Philip Reames
Date: 2020-11-23T15:32:17-08:00
New Revision: b06a2ad94f45abc18970ecc3cec93d140d036d8f

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

LOG: [LoopVectorizer] Lower uniform loads as a single load (instead of relying 
on CSE)

A uniform load is one which loads from a uniform address across all lanes. As 
currently implemented, we cost model such loads as if we did a single scalar 
load + a broadcast, but the actual lowering replicates the load once per lane.

This change tweaks the lowering to use the REPLICATE strategy by marking such 
loads (and the computation leading to their memory operand) as uniform after 
vectorization. This is a useful change in itself, but it's real purpose is to 
pave the way for a following change which will generalize our uniformity logic.

In review discussion, there was an issue raised with coupling cost modeling 
with the lowering strategy for uniform inputs.  The discussion on that item 
remains unsettled and is pending larger architectural discussion.  We decided 
to move forward with this patch as is, and revise as warranted once the bigger 
picture design questions are settled.

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

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/X86/cost-model-assert.ll
llvm/test/Transforms/LoopVectorize/X86/uniform_mem_op.ll
llvm/test/Transforms/LoopVectorize/multiple-strides-vectorization.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index a6cdcd720343..15a3bd39c0f9 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2661,7 +2661,12 @@ void 
InnerLoopVectorizer::scalarizeInstruction(Instruction *Instr, VPUser &User,
   // Replace the operands of the cloned instructions with their scalar
   // equivalents in the new loop.
   for (unsigned op = 0, e = User.getNumOperands(); op != e; ++op) {
-auto *NewOp = State.get(User.getOperand(op), Instance);
+auto *Operand = dyn_cast(Instr->getOperand(op));
+auto InputInstance = Instance;
+if (!Operand || !OrigLoop->contains(Operand) ||
+(Cost->isUniformAfterVectorization(Operand, State.VF)))
+  InputInstance.Lane = 0;
+auto *NewOp = State.get(User.getOperand(op), InputInstance);
 Cloned->setOperand(op, NewOp);
   }
   addNewMetadata(Cloned, Instr);
@@ -5031,6 +5036,11 @@ void 
LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
   // replicating region where only a single instance out of VF should be 
formed.
   // TODO: optimize such seldom cases if found important, see PR40816.
   auto addToWorklistIfAllowed = [&](Instruction *I) -> void {
+if (isOutOfScope(I)) {
+  LLVM_DEBUG(dbgs() << "LV: Found not uniform due to scope: "
+<< *I << "\n");
+  return;
+}
 if (isScalarWithPredication(I, VF)) {
   LLVM_DEBUG(dbgs() << "LV: Found not uniform being ScalarWithPredication: 
"
 << *I << "\n");
@@ -5051,16 +5061,25 @@ void 
LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
   // are pointers that are treated like consecutive pointers during
   // vectorization. The pointer operands of interleaved accesses are an
   // example.
-  SmallSetVector ConsecutiveLikePtrs;
+  SmallSetVector ConsecutiveLikePtrs;
 
   // Holds pointer operands of instructions that are possibly non-uniform.
-  SmallPtrSet PossibleNonUniformPtrs;
+  SmallPtrSet PossibleNonUniformPtrs;
 
   auto isUniformDecision = [&](Instruction *I, ElementCount VF) {
 InstWidening WideningDecision = getWideningDecision(I, VF);
 assert(WideningDecision != CM_Unknown &&
"Widening decision should be ready at this moment");
 
+// The address of a uniform mem op is itself uniform.  We exclude stores
+// here as there's an assumption in the current code that all uses of
+// uniform instructions are uniform and, as noted below, uniform stores are
+// still handled via replication (i.e. aren't uniform after vectorization).
+if (isa(I) && Legal->isUniformMemOp(*I)) {
+  assert(WideningDecision == CM_Scalarize);
+  return true;
+}
+
 return (WideningDecision == CM_Widen ||
 WideningDecision == CM_Widen_Reverse ||
 WideningDecision == CM_Interleave);
@@ -5076,10 +5095,21 @@ void 
LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
   for (auto *BB : TheLoop->blocks())
 for (auto &I : *BB) {
   // If there's no pointer operand, there's nothing to do.
-  auto *Ptr = 
dyn_cast_or_null(getLoadStorePointerOperand(&I));
+  auto *Ptr = getLoadStorePo

[llvm-branch-commits] [llvm] d6239b3 - [test] pre-comit test for D91451

2020-11-23 Thread Philip Reames via llvm-branch-commits

Author: Philip Reames
Date: 2020-11-23T15:36:08-08:00
New Revision: d6239b3ea6c143a0c395eb3b8512677feaf6acc0

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

LOG: [test] pre-comit test for D91451

Added: 


Modified: 
llvm/test/Transforms/LoopVectorize/X86/uniform_mem_op.ll

Removed: 




diff  --git a/llvm/test/Transforms/LoopVectorize/X86/uniform_mem_op.ll 
b/llvm/test/Transforms/LoopVectorize/X86/uniform_mem_op.ll
index 3c0ec386f073..a7e38c2115fb 100644
--- a/llvm/test/Transforms/LoopVectorize/X86/uniform_mem_op.ll
+++ b/llvm/test/Transforms/LoopVectorize/X86/uniform_mem_op.ll
@@ -131,6 +131,68 @@ loopexit:
   ret i32 %accum.next
 }
 
+define i32 @uniform_address(i32* align(4) %addr, i32 %byte_offset) {
+; CHECK-LABEL: @uniform_address(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
+; CHECK:   vector.ph:
+; CHECK-NEXT:br label [[VECTOR_BODY:%.*]]
+; CHECK:   vector.body:
+; CHECK-NEXT:[[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ 
[[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
+; CHECK-NEXT:[[TMP0:%.*]] = add i64 [[INDEX]], 0
+; CHECK-NEXT:[[TMP1:%.*]] = add i64 [[INDEX]], 4
+; CHECK-NEXT:[[TMP2:%.*]] = add i64 [[INDEX]], 8
+; CHECK-NEXT:[[TMP3:%.*]] = add i64 [[INDEX]], 12
+; CHECK-NEXT:[[TMP4:%.*]] = udiv i32 [[BYTE_OFFSET:%.*]], 4
+; CHECK-NEXT:[[TMP5:%.*]] = udiv i32 [[BYTE_OFFSET]], 4
+; CHECK-NEXT:[[TMP6:%.*]] = udiv i32 [[BYTE_OFFSET]], 4
+; CHECK-NEXT:[[TMP7:%.*]] = udiv i32 [[BYTE_OFFSET]], 4
+; CHECK-NEXT:[[TMP8:%.*]] = getelementptr i32, i32* [[ADDR:%.*]], i32 
[[TMP4]]
+; CHECK-NEXT:[[TMP9:%.*]] = getelementptr i32, i32* [[ADDR]], i32 [[TMP5]]
+; CHECK-NEXT:[[TMP10:%.*]] = getelementptr i32, i32* [[ADDR]], i32 [[TMP6]]
+; CHECK-NEXT:[[TMP11:%.*]] = getelementptr i32, i32* [[ADDR]], i32 [[TMP7]]
+; CHECK-NEXT:[[TMP12:%.*]] = load i32, i32* [[TMP8]], align 4
+; CHECK-NEXT:[[TMP13:%.*]] = load i32, i32* [[TMP9]], align 4
+; CHECK-NEXT:[[TMP14:%.*]] = load i32, i32* [[TMP10]], align 4
+; CHECK-NEXT:[[TMP15:%.*]] = load i32, i32* [[TMP11]], align 4
+; CHECK-NEXT:[[INDEX_NEXT]] = add i64 [[INDEX]], 16
+; CHECK-NEXT:[[TMP16:%.*]] = icmp eq i64 [[INDEX_NEXT]], 4096
+; CHECK-NEXT:br i1 [[TMP16]], label [[MIDDLE_BLOCK:%.*]], label 
[[VECTOR_BODY]], [[LOOP6:!llvm.loop !.*]]
+; CHECK:   middle.block:
+; CHECK-NEXT:[[CMP_N:%.*]] = icmp eq i64 4097, 4096
+; CHECK-NEXT:br i1 [[CMP_N]], label [[LOOPEXIT:%.*]], label [[SCALAR_PH]]
+; CHECK:   scalar.ph:
+; CHECK-NEXT:[[BC_RESUME_VAL:%.*]] = phi i64 [ 4096, [[MIDDLE_BLOCK]] ], [ 
0, [[ENTRY:%.*]] ]
+; CHECK-NEXT:br label [[FOR_BODY:%.*]]
+; CHECK:   for.body:
+; CHECK-NEXT:[[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[FOR_BODY]] ], [ 
[[BC_RESUME_VAL]], [[SCALAR_PH]] ]
+; CHECK-NEXT:[[OFFSET:%.*]] = udiv i32 [[BYTE_OFFSET]], 4
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr i32, i32* [[ADDR]], i32 [[OFFSET]]
+; CHECK-NEXT:[[LOAD:%.*]] = load i32, i32* [[GEP]], align 4
+; CHECK-NEXT:[[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
+; CHECK-NEXT:[[EXITCOND:%.*]] = icmp eq i64 [[IV]], 4096
+; CHECK-NEXT:br i1 [[EXITCOND]], label [[LOOPEXIT]], label [[FOR_BODY]], 
[[LOOP7:!llvm.loop !.*]]
+; CHECK:   loopexit:
+; CHECK-NEXT:[[LOAD_LCSSA:%.*]] = phi i32 [ [[LOAD]], [[FOR_BODY]] ], [ 
[[TMP15]], [[MIDDLE_BLOCK]] ]
+; CHECK-NEXT:ret i32 [[LOAD_LCSSA]]
+;
+entry:
+  br label %for.body
+
+for.body:
+  %iv = phi i64 [ %iv.next, %for.body ], [ 0, %entry ]
+  %offset = udiv i32 %byte_offset, 4
+  %gep = getelementptr i32, i32* %addr, i32 %offset
+  %load = load i32, i32* %gep
+  %iv.next = add nuw nsw i64 %iv, 1
+  %exitcond = icmp eq i64 %iv, 4096
+  br i1 %exitcond, label %loopexit, label %for.body
+
+loopexit:
+  ret i32 %load
+}
+
+
 
 define void @uniform_store_uniform_value(i32* align(4) %addr) {
 ; CHECK-LABEL: @uniform_store_uniform_value(
@@ -162,7 +224,7 @@ define void @uniform_store_uniform_value(i32* align(4) 
%addr) {
 ; CHECK-NEXT:store i32 0, i32* [[ADDR]], align 4
 ; CHECK-NEXT:[[INDEX_NEXT]] = add i64 [[INDEX]], 16
 ; CHECK-NEXT:[[TMP4:%.*]] = icmp eq i64 [[INDEX_NEXT]], 4096
-; CHECK-NEXT:br i1 [[TMP4]], label [[MIDDLE_BLOCK:%.*]], label 
[[VECTOR_BODY]], [[LOOP6:!llvm.loop !.*]]
+; CHECK-NEXT:br i1 [[TMP4]], label [[MIDDLE_BLOCK:%.*]], label 
[[VECTOR_BODY]], [[LOOP8:!llvm.loop !.*]]
 ; CHECK:   middle.block:
 ; CHECK-NEXT:[[CMP_N:%.*]] = icmp eq i64 4097, 4096
 ; CHECK-NEXT:br i1 [[CMP_N]], label [[LOOPEXIT:%.*]], label [[SCALAR_PH]]
@@ -174,7 +236,7 @@ define void @uniform_store_uniform_value(i32* align(4) 
%addr) {
 ; CHECK-NEXT:store i32 0, i32* [[ADDR]], align 4
 ; CHECK-NEXT:[[IV_NEXT]] = a

[llvm-branch-commits] [llvm] c74b427 - [llvm-symbolizer] Switch to using native symbolizer by default on Windows

2020-11-23 Thread Amy Huang via llvm-branch-commits

Author: Amy Huang
Date: 2020-11-23T15:57:08-08:00
New Revision: c74b427cb2a90309ee0c29df21ad1ca26390263c

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

LOG: [llvm-symbolizer] Switch to using native symbolizer by default on Windows

llvm-symbolizer used to use the DIA SDK for symbolization on
Windows; this patch switches to using native symbolization, which was
implemented recently.

Users can still make the symbolizer use DIA by adding the `-dia` flag
in the LLVM_SYMBOLIZER_OPTS environment variable.

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

Added: 


Modified: 
lld/test/COFF/symbolizer-inline.s
llvm/docs/CommandGuide/llvm-symbolizer.rst
llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
llvm/test/tools/llvm-symbolizer/pdb/pdb-columns.test
llvm/test/tools/llvm-symbolizer/pdb/pdb.test
llvm/tools/llvm-symbolizer/Opts.td
llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp

Removed: 




diff  --git a/lld/test/COFF/symbolizer-inline.s 
b/lld/test/COFF/symbolizer-inline.s
index c0db693f784c..9a032f999866 100644
--- a/lld/test/COFF/symbolizer-inline.s
+++ b/lld/test/COFF/symbolizer-inline.s
@@ -1,7 +1,7 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj %s -o %t.obj -triple x86_64-windows-msvc
 # RUN: lld-link -entry:main -nodefaultlib %t.obj -out:%t.exe -pdb:%t.pdb -debug
-# RUN: llvm-symbolizer --obj=%t.exe --use-native-pdb-reader --relative-address 
\
+# RUN: llvm-symbolizer --obj=%t.exe --relative-address \
 # RUN:   0x1014 0x1018 0x101c 0x1023 0x1024 | FileCheck %s
 
 # Compiled from this cpp code, with modifications to add extra inline line and 

diff  --git a/llvm/docs/CommandGuide/llvm-symbolizer.rst 
b/llvm/docs/CommandGuide/llvm-symbolizer.rst
index c5d094f9552d..f2a8d8ef6801 100644
--- a/llvm/docs/CommandGuide/llvm-symbolizer.rst
+++ b/llvm/docs/CommandGuide/llvm-symbolizer.rst
@@ -354,6 +354,14 @@ OPTIONS
 
   Read command-line options from response file ``.
 
+WINDOWS/PDB SPECIFIC OPTIONS
+-
+
+.. option:: --dia
+
+  Use the Windows DIA SDK for symbolization. If the DIA SDK is not found,
+  llvm-symbolizer will fall back to the native implementation.
+
 MACH-O SPECIFIC OPTIONS
 ---
 

diff  --git a/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h 
b/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
index 085e4bb4ccb8..1c8fa11660af 100644
--- a/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
+++ b/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
@@ -43,7 +43,7 @@ class LLVMSymbolizer {
 bool Demangle = true;
 bool RelativeAddresses = false;
 bool UntagAddresses = false;
-bool UseNativePDBReader = false;
+bool UseDIA = false;
 std::string DefaultArch;
 std::vector DsymHints;
 std::string FallbackDebugPath;

diff  --git a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp 
b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
index 383e2c0d3054..3eb84a141b81 100644
--- a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -557,11 +557,8 @@ LLVMSymbolizer::getOrCreateModuleInfo(const std::string 
&ModuleName) {
   using namespace pdb;
   std::unique_ptr Session;
 
-  PDB_ReaderType ReaderType = PDB_ReaderType::Native;
-#if LLVM_ENABLE_DIA_SDK
-  if (!Opts.UseNativePDBReader)
-ReaderType = PDB_ReaderType::DIA;
-#endif
+  PDB_ReaderType ReaderType =
+  Opts.UseDIA ? PDB_ReaderType::DIA : PDB_ReaderType::Native;
   if (auto Err = loadDataForEXE(ReaderType, Objects.first->getFileName(),
 Session)) {
 Modules.emplace(ModuleName, std::unique_ptr());

diff  --git a/llvm/test/tools/llvm-symbolizer/pdb/pdb-columns.test 
b/llvm/test/tools/llvm-symbolizer/pdb/pdb-columns.test
index 425d58d4d46f..a564847ef94e 100644
--- a/llvm/test/tools/llvm-symbolizer/pdb/pdb-columns.test
+++ b/llvm/test/tools/llvm-symbolizer/pdb/pdb-columns.test
@@ -8,8 +8,6 @@ RUN: echo 0x140006C40 >> %t.input
 RUN: echo 0x140006C70 >> %t.input
 RUN:llvm-symbolizer -obj="%p/Inputs/test-columns.exe" < %t.input \
 RUN:| FileCheck %s
-RUN:llvm-symbolizer -obj="%p/Inputs/test-columns.exe" 
-use-native-pdb-reader < %t.input \
-RUN:| FileCheck %s
 
 This tests that the symbolizer outputs column info when it is present in the 
pdb.
 

diff  --git a/llvm/test/tools/llvm-symbolizer/pdb/pdb.test 
b/llvm/test/tools/llvm-symbolizer/pdb/pdb.test
index d9e42416ad56..46a1ae9814e6 100644
--- a/llvm/test/tools/llvm-symbolizer/pdb/pdb.test
+++ b/llvm/test/tools/llvm-symbolizer/pdb/pdb.test
@@ -6,17 +6,18 @@ RUN: echo 0x4013D0 >> %t.input
 RUN: echo 0x4013E0 >> %t.input
 RUN: echo 0x4013F0 >> %t.input
 RUN: echo 0x401420 >> %t.input
-RUN: llvm-symb

[llvm-branch-commits] [compiler-rt] 237b024 - [hwasan] Fix tests when vm.overcommit_memory=1.

2020-11-23 Thread Evgenii Stepanov via llvm-branch-commits

Author: Evgenii Stepanov
Date: 2020-11-23T16:05:56-08:00
New Revision: 237b024b06df4305b1a0400f60cffc6b39fb3f5a

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

LOG: [hwasan] Fix tests when vm.overcommit_memory=1.

Remove an invalid check from sizes.cpp that only passes when overcommit is 
disabled.

Fixes PR48274.

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

Added: 


Modified: 
compiler-rt/test/hwasan/TestCases/sizes.cpp

Removed: 




diff  --git a/compiler-rt/test/hwasan/TestCases/sizes.cpp 
b/compiler-rt/test/hwasan/TestCases/sizes.cpp
index f397256e52e4..1bfc760e1f9e 100644
--- a/compiler-rt/test/hwasan/TestCases/sizes.cpp
+++ b/compiler-rt/test/hwasan/TestCases/sizes.cpp
@@ -49,8 +49,6 @@ int main(int argc, char **argv) {
   if (!untag_strcmp(argv[1], "malloc")) {
 void *p = malloc(MallocSize);
 assert(!p);
-p = malloc(kMaxAllowedMallocSize - kChunkHeaderSize);
-assert(!p);
   } else if (!untag_strcmp(argv[1], "calloc")) {
 // Trigger an overflow in calloc.
 size_t size = std::numeric_limits::max();



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


[llvm-branch-commits] [lld] 1b63177 - Revert "[llvm-symbolizer] Switch to using native symbolizer by default on Windows"

2020-11-23 Thread Amy Huang via llvm-branch-commits

Author: Amy Huang
Date: 2020-11-23T16:29:45-08:00
New Revision: 1b63177a56e8cd6196778d2b90295f03e96b5800

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

LOG: Revert "[llvm-symbolizer] Switch to using native symbolizer by default on 
Windows"

Breaks some asan tests on the buildbot.

This reverts commit c74b427cb2a90309ee0c29df21ad1ca26390263c.

Added: 


Modified: 
lld/test/COFF/symbolizer-inline.s
llvm/docs/CommandGuide/llvm-symbolizer.rst
llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
llvm/test/tools/llvm-symbolizer/pdb/pdb-columns.test
llvm/test/tools/llvm-symbolizer/pdb/pdb.test
llvm/tools/llvm-symbolizer/Opts.td
llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp

Removed: 




diff  --git a/lld/test/COFF/symbolizer-inline.s 
b/lld/test/COFF/symbolizer-inline.s
index 9a032f999866..c0db693f784c 100644
--- a/lld/test/COFF/symbolizer-inline.s
+++ b/lld/test/COFF/symbolizer-inline.s
@@ -1,7 +1,7 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj %s -o %t.obj -triple x86_64-windows-msvc
 # RUN: lld-link -entry:main -nodefaultlib %t.obj -out:%t.exe -pdb:%t.pdb -debug
-# RUN: llvm-symbolizer --obj=%t.exe --relative-address \
+# RUN: llvm-symbolizer --obj=%t.exe --use-native-pdb-reader --relative-address 
\
 # RUN:   0x1014 0x1018 0x101c 0x1023 0x1024 | FileCheck %s
 
 # Compiled from this cpp code, with modifications to add extra inline line and 

diff  --git a/llvm/docs/CommandGuide/llvm-symbolizer.rst 
b/llvm/docs/CommandGuide/llvm-symbolizer.rst
index f2a8d8ef6801..c5d094f9552d 100644
--- a/llvm/docs/CommandGuide/llvm-symbolizer.rst
+++ b/llvm/docs/CommandGuide/llvm-symbolizer.rst
@@ -354,14 +354,6 @@ OPTIONS
 
   Read command-line options from response file ``.
 
-WINDOWS/PDB SPECIFIC OPTIONS
--
-
-.. option:: --dia
-
-  Use the Windows DIA SDK for symbolization. If the DIA SDK is not found,
-  llvm-symbolizer will fall back to the native implementation.
-
 MACH-O SPECIFIC OPTIONS
 ---
 

diff  --git a/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h 
b/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
index 1c8fa11660af..085e4bb4ccb8 100644
--- a/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
+++ b/llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
@@ -43,7 +43,7 @@ class LLVMSymbolizer {
 bool Demangle = true;
 bool RelativeAddresses = false;
 bool UntagAddresses = false;
-bool UseDIA = false;
+bool UseNativePDBReader = false;
 std::string DefaultArch;
 std::vector DsymHints;
 std::string FallbackDebugPath;

diff  --git a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp 
b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
index 3eb84a141b81..383e2c0d3054 100644
--- a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -557,8 +557,11 @@ LLVMSymbolizer::getOrCreateModuleInfo(const std::string 
&ModuleName) {
   using namespace pdb;
   std::unique_ptr Session;
 
-  PDB_ReaderType ReaderType =
-  Opts.UseDIA ? PDB_ReaderType::DIA : PDB_ReaderType::Native;
+  PDB_ReaderType ReaderType = PDB_ReaderType::Native;
+#if LLVM_ENABLE_DIA_SDK
+  if (!Opts.UseNativePDBReader)
+ReaderType = PDB_ReaderType::DIA;
+#endif
   if (auto Err = loadDataForEXE(ReaderType, Objects.first->getFileName(),
 Session)) {
 Modules.emplace(ModuleName, std::unique_ptr());

diff  --git a/llvm/test/tools/llvm-symbolizer/pdb/pdb-columns.test 
b/llvm/test/tools/llvm-symbolizer/pdb/pdb-columns.test
index a564847ef94e..425d58d4d46f 100644
--- a/llvm/test/tools/llvm-symbolizer/pdb/pdb-columns.test
+++ b/llvm/test/tools/llvm-symbolizer/pdb/pdb-columns.test
@@ -8,6 +8,8 @@ RUN: echo 0x140006C40 >> %t.input
 RUN: echo 0x140006C70 >> %t.input
 RUN:llvm-symbolizer -obj="%p/Inputs/test-columns.exe" < %t.input \
 RUN:| FileCheck %s
+RUN:llvm-symbolizer -obj="%p/Inputs/test-columns.exe" 
-use-native-pdb-reader < %t.input \
+RUN:| FileCheck %s
 
 This tests that the symbolizer outputs column info when it is present in the 
pdb.
 

diff  --git a/llvm/test/tools/llvm-symbolizer/pdb/pdb.test 
b/llvm/test/tools/llvm-symbolizer/pdb/pdb.test
index 46a1ae9814e6..d9e42416ad56 100644
--- a/llvm/test/tools/llvm-symbolizer/pdb/pdb.test
+++ b/llvm/test/tools/llvm-symbolizer/pdb/pdb.test
@@ -6,18 +6,17 @@ RUN: echo 0x4013D0 >> %t.input
 RUN: echo 0x4013E0 >> %t.input
 RUN: echo 0x4013F0 >> %t.input
 RUN: echo 0x401420 >> %t.input
-RUN: llvm-symbolizer --obj="%p/Inputs/test.exe" < %t.input \
+RUN: llvm-symbolizer -obj="%p/Inputs/test.exe" < %t.input \
 RUN:| FileCheck %s
 RUN: llvm-symbolizer --obj="%p/Inputs/test.exe" --no-demangle < %t.input \
 RUN: