[llvm] [compiler-rt] [clang] [clang-tools-extra] [compiler-rt] Mark more calls as blocking (PR #77789)

2024-02-01 Thread Pavel Labath via cfe-commits

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/77789

>From 97c29cab7c7d8af9bf7a5d79baf468154bb83fad Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Thu, 11 Jan 2024 12:50:37 +0100
Subject: [PATCH] [compiler-rt] Mark more calls as blocking

If we're in a blocking call, we need to run the signal immediately,
as the call may not return for a very long time (if ever). Not
running the handler can cause deadlocks if the rest of the program waits
(in one way or another) for the signal handler to execute.

I've gone throught the list of functions in
sanitizer_common_interceptors and marked as blocking those that I know
can block, but I don't claim the list to be exhaustive. In particular, I
did not mark libc FILE* functions as blocking, because these can end up
calling user functions. To do that correctly, /I think/ it would be
necessary to clear the "is in blocking call" flag inside the fopencookie
wrappers.

The test for the bug (deadlock) uses the read call (which is the one
that I ran into originally), but the same kind of test could be written
for any other blocking syscall.
---
 .../sanitizer_common_interceptors.inc | 83 ++-
 .../test/tsan/pthread_atfork_deadlock3.c  |  4 +-
 compiler-rt/test/tsan/signal_in_read.c| 59 +
 3 files changed, 107 insertions(+), 39 deletions(-)
 create mode 100644 compiler-rt/test/tsan/signal_in_read.c

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc 
b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index 1b56bebac64e6..cdf3eb3978004 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -974,7 +974,7 @@ INTERCEPTOR(SSIZE_T, read, int fd, void *ptr, SIZE_T count) 
{
   // FIXME: under ASan the call below may write to freed memory and corrupt
   // its metadata. See
   // https://github.com/google/sanitizers/issues/321.
-  SSIZE_T res = REAL(read)(fd, ptr, count);
+  SSIZE_T res = COMMON_INTERCEPTOR_BLOCK_REAL(read)(fd, ptr, count);
   if (res > 0) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ptr, res);
   if (res >= 0 && fd >= 0) COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd);
   return res;
@@ -1009,7 +1009,7 @@ INTERCEPTOR(SSIZE_T, pread, int fd, void *ptr, SIZE_T 
count, OFF_T offset) {
   // FIXME: under ASan the call below may write to freed memory and corrupt
   // its metadata. See
   // https://github.com/google/sanitizers/issues/321.
-  SSIZE_T res = REAL(pread)(fd, ptr, count, offset);
+  SSIZE_T res = COMMON_INTERCEPTOR_BLOCK_REAL(pread)(fd, ptr, count, offset);
   if (res > 0) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ptr, res);
   if (res >= 0 && fd >= 0) COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd);
   return res;
@@ -1027,7 +1027,7 @@ INTERCEPTOR(SSIZE_T, pread64, int fd, void *ptr, SIZE_T 
count, OFF64_T offset) {
   // FIXME: under ASan the call below may write to freed memory and corrupt
   // its metadata. See
   // https://github.com/google/sanitizers/issues/321.
-  SSIZE_T res = REAL(pread64)(fd, ptr, count, offset);
+  SSIZE_T res = COMMON_INTERCEPTOR_BLOCK_REAL(pread64)(fd, ptr, count, offset);
   if (res > 0) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ptr, res);
   if (res >= 0 && fd >= 0) COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd);
   return res;
@@ -1043,7 +1043,7 @@ INTERCEPTOR_WITH_SUFFIX(SSIZE_T, readv, int fd, 
__sanitizer_iovec *iov,
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, readv, fd, iov, iovcnt);
   COMMON_INTERCEPTOR_FD_ACCESS(ctx, fd);
-  SSIZE_T res = REAL(readv)(fd, iov, iovcnt);
+  SSIZE_T res = COMMON_INTERCEPTOR_BLOCK_REAL(readv)(fd, iov, iovcnt);
   if (res > 0) write_iovec(ctx, iov, iovcnt, res);
   if (res >= 0 && fd >= 0) COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd);
   return res;
@@ -1059,7 +1059,7 @@ INTERCEPTOR(SSIZE_T, preadv, int fd, __sanitizer_iovec 
*iov, int iovcnt,
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, preadv, fd, iov, iovcnt, offset);
   COMMON_INTERCEPTOR_FD_ACCESS(ctx, fd);
-  SSIZE_T res = REAL(preadv)(fd, iov, iovcnt, offset);
+  SSIZE_T res = COMMON_INTERCEPTOR_BLOCK_REAL(preadv)(fd, iov, iovcnt, offset);
   if (res > 0) write_iovec(ctx, iov, iovcnt, res);
   if (res >= 0 && fd >= 0) COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd);
   return res;
@@ -1075,7 +1075,8 @@ INTERCEPTOR(SSIZE_T, preadv64, int fd, __sanitizer_iovec 
*iov, int iovcnt,
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, preadv64, fd, iov, iovcnt, offset);
   COMMON_INTERCEPTOR_FD_ACCESS(ctx, fd);
-  SSIZE_T res = REAL(preadv64)(fd, iov, iovcnt, offset);
+  SSIZE_T res =
+  COMMON_INTERCEPTOR_BLOCK_REAL(preadv64)(fd, iov, iovcnt, offset);
   if (res > 0) write_iovec(ctx, iov, iovcnt, res);
   if (res >= 0 && fd >= 0) COMMON_INTERCEPTOR_FD_ACQUIRE(ctx, fd);
   return res;
@@ -1091,8 +1092,9 @@ INTERCEPTOR(SSIZE_T, write, int fd, void *ptr, SIZE_T 
count) {
   COMMON_INTERCEPTOR_ENTER(ctx, write, fd, ptr, count);
   COMMON_INTERCEPTOR_FD_ACCESS(ctx, fd);
   

Re: [Lldb-commits] [lldb] aee4925 - Recommit: Compress formatting of array type names (int [4] -> int[4])

2021-10-28 Thread Pavel Labath via cfe-commits

On 26/10/2021 23:14, Jim Ingham via lldb-commits wrote:




On Oct 26, 2021, at 12:45 PM, David Blaikie  wrote:

On Tue, Oct 26, 2021 at 12:15 PM Raphael Isemann  wrote:
Not sure how many LLDB users would (or can) write AST matchers though. And
 (lldb) type summary add "foo[4]" ...
is arguably easier on the eyes than
 type summary add
constantArrayType(allOf(hasSize(4),hasDeclaration(namedDecl(hasName("foo")`

Though presumably (& the example I think Jim was giving) more often the desire 
would be to write a matcher for arrays of any dimension, where it's:

"foo[\d+]" or similar (maybe having to escape the "[]"
compared to
arrayType(hasElementType(hasDeclaration(cxxRecordDecl(hasName("foo")
  
Which is, admittedly, still pretty verbose. But more type checked (for better and worse - annoying to get right (took me ages to figure out I needed "hasDeclaration" in there) but more robust once it is right)


(that's my best shot at a good AST matcher, not sure if we could make
this shorter, but that's probably what a user ends up with).

In this case it seems just comparing tokens instead of direct strings
is enough to make most users happy. And it doesn't require building
clang ASTs (which is always expensive).

Yeah, as much as I like the abstract purity of structural comparison, token 
comparison is probably close enough. (guess that has to involve LLDB walking 
through typedefs incrementally, etc - if typedefs can be used in pretty printer 
matching/searching, otherwise got to go strip out all the typedefs (from the 
users regex (if they are allowed there) and from the type of the thing being 
printed) and other sugar before comparison - guess that's done today somewhere)




The formatter matching does use a type hierarchy if it has one.  We walk the 
chain of typedefs looking for a match, first one wins.  We also match down 
class hierarchies, since if you only format the base class fields, it would be 
annoying to have to write a new formatter for each derived class just to get 
the base class fields printed.

We could also invent some mini-language for the type specification, like "char 
[*]" to mean an array of any size.  But I hesitate to introduce non-language 
features in here because then some other language we need to support will use those 
characters making them ambiguous.  And it's better to rely on facts people already know 
to specify this sort of thing, if possible.  But maybe having a slightly smart tokenizer 
and a few conventions for the common cases might make specifying matches less awkward.

But it doesn't require that we know about then names being matched, and will 
fall back now on either plain string matching or regex-es.



I've recently approached this issue from a slightly different angle 
(trying to format sizeless char arrays (char[]), and I've learned a 
couple of things which might be interesting to this discussion:
- besides typedefs, we also strip cv qualifiers (so a formatter for char 
* applies to const char * as well). However, we didn't to this for array 
types (so one had to include char [.*] and const char [.*] separately. 
(D112708 extends this behavior to arrays too)
- our formatters were not handling cv arrays separately, and the reason 
this worked is because they used unachored regexes, so "char [.*]" 
matched the last part of "const volatile char [47]"
- the unachored matching meant that these formatters were getting 
applied to completely unrelated types as well (e.g. MyStruct). 
(D112709 fixes the second two issues)


While I don't think it's realistic to expect that our users will learn 
how clang ast matchers (or any similar language) work, I think all of 
these examples show that the regex approach has a lot of pitfalls as 
well. It might be good to consider switching to a full-match regexes at 
least, as I think the template trick will affect most formatters, and I 
doubt users will remember to surround their expressions with ^$.


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


[clang-tools-extra] r351319 - Fix build breakage from llvm r351317

2019-01-16 Thread Pavel Labath via cfe-commits
Author: labath
Date: Wed Jan 16 02:26:52 2019
New Revision: 351319

URL: http://llvm.org/viewvc/llvm-project?rev=351319=rev
Log:
Fix build breakage from llvm r351317

The two-argument version of  llvm::sys::fs::make_absolute no longer
returns an error code.

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=351319=351318=351319=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Wed Jan 16 02:26:52 2019
@@ -76,10 +76,7 @@ std::string MakeAbsolutePath(StringRef C
 return "";
   llvm::SmallString<128> InitialDirectory(CurrentDir);
   llvm::SmallString<128> AbsolutePath(Path);
-  if (std::error_code EC =
-  llvm::sys::fs::make_absolute(InitialDirectory, AbsolutePath))
-llvm::errs() << "Warning: could not make absolute file: '" << EC.message()
- << '\n';
+  llvm::sys::fs::make_absolute(InitialDirectory, AbsolutePath);
   return CleanPath(std::move(AbsolutePath));
 }
 

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=351319=351318=351319=diff
==
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Wed Jan 16 02:26:52 2019
@@ -223,9 +223,7 @@ public:
 Body = Body.ltrim('/');
 llvm::SmallVector Path(Body.begin(), Body.end());
 path::native(Path);
-auto Err = fs::make_absolute(TestScheme::TestDir, Path);
-if (Err)
-  llvm_unreachable("Failed to make absolute path in test scheme.");
+fs::make_absolute(TestScheme::TestDir, Path);
 return std::string(Path.begin(), Path.end());
   }
 


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


r351317 - [Support] Remove error return value from one overload of fs::make_absolute

2019-01-16 Thread Pavel Labath via cfe-commits
Author: labath
Date: Wed Jan 16 01:55:32 2019
New Revision: 351317

URL: http://llvm.org/viewvc/llvm-project?rev=351317=rev
Log:
[Support] Remove error return value from one overload of fs::make_absolute

Summary:
The version of make_absolute which accepted a specific directory to use
as the "base" for the computation could never fail, even though it
returned a std::error_code. The reason for that seems to be historical
-- the CWD flavour (which can fail due to failure to retrieve CWD) was
there first, and the new version was implemented by extending that.

This removes the error return value from the non-CWD overload and
reimplements the CWD version on top of that. This enables us to remove
some dead code where people were pessimistically trying to handle the
errors returned from this function.

Reviewers: zturner, sammccall

Subscribers: hiraditya, kristina, llvm-commits

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

Modified:
cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=351317=351316=351317=diff
==
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Wed Jan 16 01:55:32 2019
@@ -1678,9 +1678,8 @@ std::string HeaderSearch::suggestPathToF
 StringRef Dir = SearchDirs[I].getDir()->getName();
 llvm::SmallString<32> DirPath(Dir.begin(), Dir.end());
 if (!WorkingDir.empty() && !path::is_absolute(Dir)) {
-  auto err = fs::make_absolute(WorkingDir, DirPath);
-  if (!err)
-path::remove_dots(DirPath, /*remove_dot_dot=*/true);
+  fs::make_absolute(WorkingDir, DirPath);
+  path::remove_dots(DirPath, /*remove_dot_dot=*/true);
   Dir = DirPath;
 }
 for (auto NI = path::begin(File), NE = path::end(File),


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


r341564 - Re-commit "Enable DWARF accelerator tables by default when tuning for lldb (-glldb => -gpubnames)""

2018-09-06 Thread Pavel Labath via cfe-commits
Author: labath
Date: Thu Sep  6 10:01:45 2018
New Revision: 341564

URL: http://llvm.org/viewvc/llvm-project?rev=341564=rev
Log:
Re-commit "Enable DWARF accelerator tables by default when tuning for lldb 
(-glldb => -gpubnames)""

This recommits r341472, which was reverted due to test failures on macos bots.

The issue was that a macos target implies -glldb which, together with
this patch added a -gpubnames switch where there previously wasn't one.
The intentions of those checks was to check that -gpubnames is not
emitted by default so I add an explicit -ggdb arg to those command lines
to get same behavior on all platforms (the fact that -glldb *does* set
-gpubnames is tested by a separate test).

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=341564=341563=341564=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Sep  6 10:01:45 2018
@@ -3072,7 +3072,7 @@ static void RenderDebugOptions(const Too
   const auto *PubnamesArg =
   Args.getLastArg(options::OPT_ggnu_pubnames, 
options::OPT_gno_gnu_pubnames,
   options::OPT_gpubnames, options::OPT_gno_pubnames);
-  if (SplitDWARFArg ||
+  if (SplitDWARFArg || DebuggerTuning == llvm::DebuggerKind::LLDB ||
   (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC)))
 if (!PubnamesArg ||
 (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&

Modified: cfe/trunk/test/Driver/debug-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=341564=341563=341564=diff
==
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Thu Sep  6 10:01:45 2018
@@ -153,18 +153,21 @@
 // RUN:| FileCheck -check-prefix=GIGNORE %s
 //
 // RUN: %clang -### -c -ggnu-pubnames %s 2>&1 | FileCheck -check-prefix=GPUB %s
-// RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=NOPUB %s
+// RUN: %clang -### -c -ggdb %s 2>&1 | FileCheck -check-prefix=NOPUB %s
 // RUN: %clang -### -c -ggnu-pubnames -gno-gnu-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
 // RUN: %clang -### -c -ggnu-pubnames -gno-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
 //
 // RUN: %clang -### -c -gpubnames %s 2>&1 | FileCheck -check-prefix=PUB %s
-// RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=NOPUB %s
+// RUN: %clang -### -c -ggdb %s 2>&1 | FileCheck -check-prefix=NOPUB %s
 // RUN: %clang -### -c -gpubnames -gno-gnu-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
 // RUN: %clang -### -c -gpubnames -gno-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
 //
 // RUN: %clang -### -c -gsplit-dwarf %s 2>&1 | FileCheck -check-prefix=GPUB %s
 // RUN: %clang -### -c -gsplit-dwarf -gno-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
 //
+// RUN: %clang -### -c -glldb %s 2>&1 | FileCheck -check-prefix=GPUB %s
+// RUN: %clang -### -c -glldb -gno-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
+//
 // RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck 
-check-prefix=GARANGE %s
 //
 // RUN: %clang -### -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 
\


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


r341492 - Revert "Enable DWARF accelerator tables by default when tuning for lldb (-glldb => -gpubnames)"

2018-09-05 Thread Pavel Labath via cfe-commits
Author: labath
Date: Wed Sep  5 13:20:28 2018
New Revision: 341492

URL: http://llvm.org/viewvc/llvm-project?rev=341492=rev
Log:
Revert "Enable DWARF accelerator tables by default when tuning for lldb (-glldb 
=> -gpubnames)"

This reverts commit r341472 due to breakage in green dragon bots.

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=341492=341491=341492=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Sep  5 13:20:28 2018
@@ -3072,7 +3072,7 @@ static void RenderDebugOptions(const Too
   const auto *PubnamesArg =
   Args.getLastArg(options::OPT_ggnu_pubnames, 
options::OPT_gno_gnu_pubnames,
   options::OPT_gpubnames, options::OPT_gno_pubnames);
-  if (SplitDWARFArg || DebuggerTuning == llvm::DebuggerKind::LLDB ||
+  if (SplitDWARFArg ||
   (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC)))
 if (!PubnamesArg ||
 (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&

Modified: cfe/trunk/test/Driver/debug-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=341492=341491=341492=diff
==
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Wed Sep  5 13:20:28 2018
@@ -165,9 +165,6 @@
 // RUN: %clang -### -c -gsplit-dwarf %s 2>&1 | FileCheck -check-prefix=GPUB %s
 // RUN: %clang -### -c -gsplit-dwarf -gno-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
 //
-// RUN: %clang -### -c -glldb %s 2>&1 | FileCheck -check-prefix=GPUB %s
-// RUN: %clang -### -c -glldb -gno-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
-//
 // RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck 
-check-prefix=GARANGE %s
 //
 // RUN: %clang -### -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 
\


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


r341472 - Enable DWARF accelerator tables by default when tuning for lldb (-glldb => -gpubnames)

2018-09-05 Thread Pavel Labath via cfe-commits
Author: labath
Date: Wed Sep  5 07:38:44 2018
New Revision: 341472

URL: http://llvm.org/viewvc/llvm-project?rev=341472=rev
Log:
Enable DWARF accelerator tables by default when tuning for lldb (-glldb => 
-gpubnames)

Summary:
DWARF v5 accelerator tables provide a considerable performance
improvement for lldb and will make the default -glldb behavior same on
all targets (right now we emit apple tables on apple targets, but these
are not controlled by -gpubnames, only by -glldb).

Reviewers: dblaikie

Subscribers: probinson, clayborg, JDevlieghere, aprantl, cfe-commits

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=341472=341471=341472=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Sep  5 07:38:44 2018
@@ -3072,7 +3072,7 @@ static void RenderDebugOptions(const Too
   const auto *PubnamesArg =
   Args.getLastArg(options::OPT_ggnu_pubnames, 
options::OPT_gno_gnu_pubnames,
   options::OPT_gpubnames, options::OPT_gno_pubnames);
-  if (SplitDWARFArg ||
+  if (SplitDWARFArg || DebuggerTuning == llvm::DebuggerKind::LLDB ||
   (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC)))
 if (!PubnamesArg ||
 (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&

Modified: cfe/trunk/test/Driver/debug-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=341472=341471=341472=diff
==
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Wed Sep  5 07:38:44 2018
@@ -165,6 +165,9 @@
 // RUN: %clang -### -c -gsplit-dwarf %s 2>&1 | FileCheck -check-prefix=GPUB %s
 // RUN: %clang -### -c -gsplit-dwarf -gno-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
 //
+// RUN: %clang -### -c -glldb %s 2>&1 | FileCheck -check-prefix=GPUB %s
+// RUN: %clang -### -c -glldb -gno-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
+//
 // RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck 
-check-prefix=GARANGE %s
 //
 // RUN: %clang -### -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 
\


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


Re: r337456 - [CodeGen] Disable aggressive structor optimizations at -O0, take 3

2018-07-30 Thread Pavel Labath via cfe-commits
I've managed to hack together an implementation of this proposal. I've
put it up at <https://reviews.llvm.org/D49989> so you have an idea of
where I'm going with this. It seems to work fine (I've managed to
bootstrap clang with it), though I'm not exactly proud of the
implementation.

Let me know what you think.

pl
On Mon, 30 Jul 2018 at 12:06, Pavel Labath  wrote:
>
> Thank you for the explanation Chandler. This patch is not on a
> critical path for me, so I don't mind it taking a while (though it
> would be nice to fix as this is a also long standing cause of
> expression evaluation failures in LLDB).
>
> I believe that best solution here would be extend the set of
> conditions under which we can emit the C1/D1 structor flavour as an
> alias. There is no fundamental reason why these symbols cannot be
> aliases even for linkonce linkage types. In fact, gcc will already
> emit aliases in the situations we resort to separate functions.
>
> The reason I could not do it in this patch (*) is that the emission of
> the specific flavours for linkonce structors happens in a lazy matter
> (i.e. only if they are referenced), but in order to correctly decide
> what kind of emission strategy to choose, one needs to know the full
> set of structors that will be emitted (**). This information is not
> accessible (or at least I couldn't find a way to access it, maybe
> someone with more knowledge of the codebase will) from the place which
> does the decision.
>
> If we are able to do that, then the object file size should be almost
> unaffected (the only difference would be an extra symtab entry), and
> it would also solve another issue, which this patch has inadvertently
> caused: PR38338 - debugger stops twice for some constructor
> breakpoints because of how we generate the line tables. In fact on
> Friday, I was considering reverting this patch myself due to this
> issue, but I eventually choose to leave it in as it did not seem too
> hard to fix it going forward.
>
> Let me know what you think about this idea. I am happy to do some of
> the implementation work here, but I think I will need some guidance as
> to how to collect and plumb the required information.
>
> regards,
> pavel
>
>
> (*) It also didn't seem like it was necessary at the time, as this was
> already strictly better than what we are doing on other platforms,
> which is to emit separate functions unconditionally.
>
> (**) If we don't emit a C1 alias, the C2 constructor needs to go to
> the C2 comdat. If we emit the alias, we need to use the C5 comdat. The
> situation is even more complicated with virtual destructors, as there
> D0, D1 and D2 need to go to the same D5 comdat (and D1 can be an
> alias). If D0 is missing/not emitted, then D2 needs to go to the D2
> comdat, and D1 cannot be an alias.
>
>
>
>
>
>
> On Sun, 29 Jul 2018 at 03:15, Chandler Carruth  wrote:
> >
> > On Sat, Jul 28, 2018 at 2:26 AM Chandler Carruth  
> > wrote:
> >>
> >> On Thu, Jul 19, 2018 at 7:10 AM Pavel Labath via cfe-commits 
> >>  wrote:
> >>>
> >>> Author: labath
> >>> Date: Thu Jul 19 07:05:22 2018
> >>> New Revision: 337456
> >>>
> >>> URL: http://llvm.org/viewvc/llvm-project?rev=337456=rev
> >>> Log:
> >>> [CodeGen] Disable aggressive structor optimizations at -O0, take 3
> >>
> >>
> >> I'm really sorry to do this, but I need to revert this patch Let me 
> >> try to explain
> >>
> >> We're seeing at least two issues with it that are causing *serious* issues 
> >> for our users, and due to numerous other things, we really need to get 
> >> top-of-tree into usable shape sooner rather than later. As this is 
> >> improving a long-standing deficiency in Clang, I think it is reasonable to 
> >> revert temporarily while we sort it out. I'm CC-ing Richard Smith and Eric 
> >> Christopher directly as I'm going to ask them to make sure we get 
> >> satisfactory answers to why this patch causes us so many problems and how 
> >> we can make progress here.
> >>
> >> I don't have a test case at the moment, and I want to *very clearly* call 
> >> out that it is on us to find a test case or otherwise clearly explain what 
> >> problem this patch causes and how it can be addressed, or else this patch 
> >> should be re-landed.
> >>
> >> To at least give some idea of what is going wrong here..
> >>
> >> First, this patch does increase object code size. This isn't really 
> >> unexpected based on the nature of the patch, and it does so ostensibly in 
> >

Re: r337456 - [CodeGen] Disable aggressive structor optimizations at -O0, take 3

2018-07-30 Thread Pavel Labath via cfe-commits
Thank you for the explanation Chandler. This patch is not on a
critical path for me, so I don't mind it taking a while (though it
would be nice to fix as this is a also long standing cause of
expression evaluation failures in LLDB).

I believe that best solution here would be extend the set of
conditions under which we can emit the C1/D1 structor flavour as an
alias. There is no fundamental reason why these symbols cannot be
aliases even for linkonce linkage types. In fact, gcc will already
emit aliases in the situations we resort to separate functions.

The reason I could not do it in this patch (*) is that the emission of
the specific flavours for linkonce structors happens in a lazy matter
(i.e. only if they are referenced), but in order to correctly decide
what kind of emission strategy to choose, one needs to know the full
set of structors that will be emitted (**). This information is not
accessible (or at least I couldn't find a way to access it, maybe
someone with more knowledge of the codebase will) from the place which
does the decision.

If we are able to do that, then the object file size should be almost
unaffected (the only difference would be an extra symtab entry), and
it would also solve another issue, which this patch has inadvertently
caused: PR38338 - debugger stops twice for some constructor
breakpoints because of how we generate the line tables. In fact on
Friday, I was considering reverting this patch myself due to this
issue, but I eventually choose to leave it in as it did not seem too
hard to fix it going forward.

Let me know what you think about this idea. I am happy to do some of
the implementation work here, but I think I will need some guidance as
to how to collect and plumb the required information.

regards,
pavel


(*) It also didn't seem like it was necessary at the time, as this was
already strictly better than what we are doing on other platforms,
which is to emit separate functions unconditionally.

(**) If we don't emit a C1 alias, the C2 constructor needs to go to
the C2 comdat. If we emit the alias, we need to use the C5 comdat. The
situation is even more complicated with virtual destructors, as there
D0, D1 and D2 need to go to the same D5 comdat (and D1 can be an
alias). If D0 is missing/not emitted, then D2 needs to go to the D2
comdat, and D1 cannot be an alias.






On Sun, 29 Jul 2018 at 03:15, Chandler Carruth  wrote:
>
> On Sat, Jul 28, 2018 at 2:26 AM Chandler Carruth  wrote:
>>
>> On Thu, Jul 19, 2018 at 7:10 AM Pavel Labath via cfe-commits 
>>  wrote:
>>>
>>> Author: labath
>>> Date: Thu Jul 19 07:05:22 2018
>>> New Revision: 337456
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=337456=rev
>>> Log:
>>> [CodeGen] Disable aggressive structor optimizations at -O0, take 3
>>
>>
>> I'm really sorry to do this, but I need to revert this patch Let me try 
>> to explain
>>
>> We're seeing at least two issues with it that are causing *serious* issues 
>> for our users, and due to numerous other things, we really need to get 
>> top-of-tree into usable shape sooner rather than later. As this is improving 
>> a long-standing deficiency in Clang, I think it is reasonable to revert 
>> temporarily while we sort it out. I'm CC-ing Richard Smith and Eric 
>> Christopher directly as I'm going to ask them to make sure we get 
>> satisfactory answers to why this patch causes us so many problems and how we 
>> can make progress here.
>>
>> I don't have a test case at the moment, and I want to *very clearly* call 
>> out that it is on us to find a test case or otherwise clearly explain what 
>> problem this patch causes and how it can be addressed, or else this patch 
>> should be re-landed.
>>
>> To at least give some idea of what is going wrong here..
>>
>> First, this patch does increase object code size. This isn't really 
>> unexpected based on the nature of the patch, and it does so ostensibly in 
>> order to gain material fidelity improvements to debug information. Despite 
>> the fact that the increased object size causes us problems (it made a few 
>> hundered of our binaries' inputs too large to fit into the quota for the 
>> input files to our internal distributed build system) we tried to soldier 
>> onward...
>>
>> But it also causes the Gold linker at least to use considerably more memory 
>> than it used to. This has resulted in over 400 failures to link executables 
>> due to running out of available memory on the system.
>>
>> There are a number of possible causes for both the input size issues and the 
>> linker memory issue:
>> - An unexpected side-effect of this change causes lots of redundant sections 
>> to be output

r337456 - [CodeGen] Disable aggressive structor optimizations at -O0, take 3

2018-07-19 Thread Pavel Labath via cfe-commits
Author: labath
Date: Thu Jul 19 07:05:22 2018
New Revision: 337456

URL: http://llvm.org/viewvc/llvm-project?rev=337456=rev
Log:
[CodeGen] Disable aggressive structor optimizations at -O0, take 3

The previous version of this patch (r332839) was reverted because it was
causing "definition with same mangled name as another definition" errors
in some module builds. This was caused by an unrelated bug in module
importing which it exposed. The importing problem was fixed in r336240,
so this recommits the original patch (r332839).

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

Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp
cfe/trunk/test/CodeGenCXX/float16-declarations.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=337456=337455=337456=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu Jul 19 07:05:22 2018
@@ -3737,12 +3737,22 @@ static StructorCodegen getCodegenToUse(C
   }
   llvm::GlobalValue::LinkageTypes Linkage = CGM.getFunctionLinkage(AliasDecl);
 
-  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage))
-return StructorCodegen::RAUW;
+  // All discardable structors can be RAUWed, but we don't want to do that in
+  // unoptimized code, as that makes complete structor symbol disappear
+  // completely, which degrades debugging experience.
+  // Symbols with private linkage can be safely aliased, so we special case 
them
+  // here.
+  if (llvm::GlobalValue::isLocalLinkage(Linkage))
+return CGM.getCodeGenOpts().OptimizationLevel > 0 ? StructorCodegen::RAUW
+  : StructorCodegen::Alias;
 
+  // Linkonce structors cannot be aliased nor placed in a comdat, so these need
+  // to be emitted separately.
   // FIXME: Should we allow available_externally aliases?
-  if (!llvm::GlobalAlias::isValidLinkage(Linkage))
-return StructorCodegen::RAUW;
+  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) ||
+  !llvm::GlobalAlias::isValidLinkage(Linkage))
+return CGM.getCodeGenOpts().OptimizationLevel > 0 ? StructorCodegen::RAUW
+  : StructorCodegen::Emit;
 
   if (llvm::GlobalValue::isWeakForLinker(Linkage)) {
 // Only ELF and wasm support COMDATs with arbitrary names (C5/D5).

Modified: cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp?rev=337456=337455=337456=diff
==
--- cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp Thu Jul 19 07:05:22 2018
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases 
| FileCheck --check-prefix=NOOPT %s
-
+// RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases 
> %t
+// RUN: FileCheck --check-prefix=NOOPT1 --input-file=%t %s
+// RUN: FileCheck --check-prefix=NOOPT2 --input-file=%t %s
+// RUN: FileCheck --check-prefix=NOOPT3 --input-file=%t %s
 // RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases 
-O1 -disable-llvm-passes > %t
 // RUN: FileCheck --check-prefix=CHECK1 --input-file=%t %s
 // RUN: FileCheck --check-prefix=CHECK2 --input-file=%t %s
@@ -21,6 +23,13 @@ namespace test1 {
 // CHECK1: define weak_odr void @_ZN5test16foobarIvED0Ev({{.*}} 
comdat($_ZN5test16foobarIvED5Ev)
 // CHECK1-NOT: comdat
 
+// This should happen regardless of the opt level.
+// NOOPT1: @_ZN5test16foobarIvEC1Ev = weak_odr unnamed_addr alias void {{.*}} 
@_ZN5test16foobarIvEC2Ev
+// NOOPT1: @_ZN5test16foobarIvED1Ev = weak_odr unnamed_addr alias void 
(%"struct.test1::foobar"*), void (%"struct.test1::foobar"*)* 
@_ZN5test16foobarIvED2Ev
+// NOOPT1: define weak_odr void @_ZN5test16foobarIvEC2Ev({{.*}} 
comdat($_ZN5test16foobarIvEC5Ev)
+// NOOPT1: define weak_odr void @_ZN5test16foobarIvED2Ev({{.*}} 
comdat($_ZN5test16foobarIvED5Ev)
+// NOOPT1: define weak_odr void @_ZN5test16foobarIvED0Ev({{.*}} 
comdat($_ZN5test16foobarIvED5Ev)
+
 // COFF doesn't support comdats with arbitrary names (C5/D5).
 // COFF: define weak_odr {{.*}} void @_ZN5test16foobarIvEC2Ev({{.*}} comdat 
align
 // COFF: define weak_odr {{.*}} void @_ZN5test16foobarIvEC1Ev({{.*}} comdat 
align
@@ -37,12 +46,17 @@ template struct foobar;
 }
 
 namespace test2 {
-// test that when the destrucor is linkonce_odr we just replace every use of
+// test that when the destructor is linkonce_odr we just replace every use of
 // C1 with C2.
 
 // CHECK1: define internal void @__cxx_global_var_init()
 // CHECK1: call void @_ZN5test26foobarIvEC2Ev
 // CHECK1: define linkonce_odr void @_ZN5test26foobarIvEC2Ev({{.*}} comdat 
align
+
+// 

r334399 - Move VersionTuple from clang/Basic to llvm/Support

2018-06-11 Thread Pavel Labath via cfe-commits
Author: labath
Date: Mon Jun 11 03:28:04 2018
New Revision: 334399

URL: http://llvm.org/viewvc/llvm-project?rev=334399=rev
Log:
Move VersionTuple from clang/Basic to llvm/Support

Summary:
This kind of functionality is useful to other project apart from clang.
LLDB works with version numbers a lot, but it does not have a convenient
abstraction for this. Moving this class to a lower level library allows
it to be freely used within LLDB.

Since this class is used in a lot of places in clang, and it used to be
in the clang namespace, it seemed appropriate to add it to the list of
adopted classes in LLVM.h to avoid prefixing all uses with "llvm::".

Also, I didn't find any tests specific for this class, so I wrote a
couple of quick ones for the more interesting bits of functionality.

Reviewers: zturner, erik.pilkington

Subscribers: mgorny, cfe-commits, llvm-commits

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

Removed:
cfe/trunk/include/clang/Basic/VersionTuple.h
cfe/trunk/lib/Basic/VersionTuple.cpp
Modified:
cfe/trunk/include/clang/AST/Attr.h
cfe/trunk/include/clang/AST/Availability.h
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/AST/ExprObjC.h
cfe/trunk/include/clang/Basic/AlignedAllocation.h
cfe/trunk/include/clang/Basic/LLVM.h
cfe/trunk/include/clang/Basic/ObjCRuntime.h
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/AttributeList.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Basic/CMakeLists.txt
cfe/trunk/lib/Basic/ObjCRuntime.cpp
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains/Cuda.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/AST/Attr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=334399=334398=334399=diff
==
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Mon Jun 11 03:28:04 2018
@@ -23,9 +23,9 @@
 #include "clang/Basic/OpenMPKinds.h"
 #include "clang/Basic/Sanitizers.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Basic/VersionTuple.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/VersionTuple.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 

Modified: cfe/trunk/include/clang/AST/Availability.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Availability.h?rev=334399=334398=334399=diff
==
--- cfe/trunk/include/clang/AST/Availability.h (original)
+++ cfe/trunk/include/clang/AST/Availability.h Mon Jun 11 03:28:04 2018
@@ -15,8 +15,8 @@
 #define LLVM_CLANG_AST_AVAILABILITY_H
 
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Basic/VersionTuple.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/VersionTuple.h"
 
 namespace clang {
 

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=334399=334398=334399=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Mon Jun 11 03:28:04 2018
@@ -19,7 +19,6 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
-#include "clang/Basic/VersionTuple.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/PointerUnion.h"
@@ -28,6 +27,7 @@
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/VersionTuple.h"
 #include 
 #include 
 #include 

Modified: cfe/trunk/include/clang/AST/ExprObjC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprObjC.h?rev=334399=334398=334399=diff
==
--- cfe/trunk/include/clang/AST/ExprObjC.h (original)
+++ cfe/trunk/include/clang/AST/ExprObjC.h Mon Jun 11 03:28:04 2018
@@ -25,7 +25,6 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
-#include "clang/Basic/VersionTuple.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
@@ -36,6 +35,7 @@
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/TrailingObjects.h"
+#include "llvm/Support/VersionTuple.h"
 #include "llvm/Support/type_traits.h"
 #include 
 #include 


r332839 - [CodeGen] Disable aggressive structor optimizations at -O0, take 2

2018-05-21 Thread Pavel Labath via cfe-commits
Author: labath
Date: Mon May 21 04:47:45 2018
New Revision: 332839

URL: http://llvm.org/viewvc/llvm-project?rev=332839=rev
Log:
[CodeGen] Disable aggressive structor optimizations at -O0, take 2

The first version of the patch (r332228) was flawed because it was
putting structors into C5/D5 comdats very eagerly. This is correct only
if we can ensure the comdat contains all required versions of the
structor (which wasn't the case). This version uses a more nuanced
approach:
- for local structor symbols we use an alias because we don't have to
  worry about comdats or other compilation units.
- linkonce symbols are emitted separately, as we cannot guarantee we
  will have all symbols we need to form a comdat (they are emitted
  lazily, only when referenced).
- available_externally symbols are also emitted separately, as the code
  seemed to be worried about emitting an alias in this case.
- other linkage types are not affected by the optimization level. They
  either get put into a comdat (weak) or get aliased (external).

Reviewers: rjmccall, aprantl

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp
cfe/trunk/test/CodeGenCXX/float16-declarations.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=332839=332838=332839=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Mon May 21 04:47:45 2018
@@ -3628,12 +3628,22 @@ static StructorCodegen getCodegenToUse(C
   }
   llvm::GlobalValue::LinkageTypes Linkage = CGM.getFunctionLinkage(AliasDecl);
 
-  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage))
-return StructorCodegen::RAUW;
+  // All discardable structors can be RAUWed, but we don't want to do that in
+  // unoptimized code, as that makes complete structor symbol disappear
+  // completely, which degrades debugging experience.
+  // Symbols with private linkage can be safely aliased, so we special case 
them
+  // here.
+  if (llvm::GlobalValue::isLocalLinkage(Linkage))
+return CGM.getCodeGenOpts().OptimizationLevel > 0 ? StructorCodegen::RAUW
+  : StructorCodegen::Alias;
 
+  // Linkonce structors cannot be aliased nor placed in a comdat, so these need
+  // to be emitted separately.
   // FIXME: Should we allow available_externally aliases?
-  if (!llvm::GlobalAlias::isValidLinkage(Linkage))
-return StructorCodegen::RAUW;
+  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) ||
+  !llvm::GlobalAlias::isValidLinkage(Linkage))
+return CGM.getCodeGenOpts().OptimizationLevel > 0 ? StructorCodegen::RAUW
+  : StructorCodegen::Emit;
 
   if (llvm::GlobalValue::isWeakForLinker(Linkage)) {
 // Only ELF and wasm support COMDATs with arbitrary names (C5/D5).

Modified: cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp?rev=332839=332838=332839=diff
==
--- cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp Mon May 21 04:47:45 2018
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases 
| FileCheck --check-prefix=NOOPT %s
-
+// RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases 
> %t
+// RUN: FileCheck --check-prefix=NOOPT1 --input-file=%t %s
+// RUN: FileCheck --check-prefix=NOOPT2 --input-file=%t %s
+// RUN: FileCheck --check-prefix=NOOPT3 --input-file=%t %s
 // RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases 
-O1 -disable-llvm-passes > %t
 // RUN: FileCheck --check-prefix=CHECK1 --input-file=%t %s
 // RUN: FileCheck --check-prefix=CHECK2 --input-file=%t %s
@@ -21,6 +23,13 @@ namespace test1 {
 // CHECK1: define weak_odr void @_ZN5test16foobarIvED0Ev({{.*}} 
comdat($_ZN5test16foobarIvED5Ev)
 // CHECK1-NOT: comdat
 
+// This should happen regardless of the opt level.
+// NOOPT1: @_ZN5test16foobarIvEC1Ev = weak_odr alias void {{.*}} 
@_ZN5test16foobarIvEC2Ev
+// NOOPT1: @_ZN5test16foobarIvED1Ev = weak_odr alias void 
(%"struct.test1::foobar"*), void (%"struct.test1::foobar"*)* 
@_ZN5test16foobarIvED2Ev
+// NOOPT1: define weak_odr void @_ZN5test16foobarIvEC2Ev({{.*}} 
comdat($_ZN5test16foobarIvEC5Ev)
+// NOOPT1: define weak_odr void @_ZN5test16foobarIvED2Ev({{.*}} 
comdat($_ZN5test16foobarIvED5Ev)
+// NOOPT1: define weak_odr void @_ZN5test16foobarIvED0Ev({{.*}} 
comdat($_ZN5test16foobarIvED5Ev)
+
 // COFF doesn't support comdats with arbitrary names (C5/D5).
 // COFF: define weak_odr {{.*}} void @_ZN5test16foobarIvEC2Ev({{.*}} 

r332232 - Revert "[CodeGen] Disable aggressive structor optimizations at -O0"

2018-05-14 Thread Pavel Labath via cfe-commits
Author: labath
Date: Mon May 14 04:35:44 2018
New Revision: 332232

URL: http://llvm.org/viewvc/llvm-project?rev=332232=rev
Log:
Revert "[CodeGen] Disable aggressive structor optimizations at -O0"

It breaks the sanitizer build


This reverts commit r332228.

Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp
cfe/trunk/test/CodeGenCXX/float16-declarations.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=332232=332231=332232=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Mon May 14 04:35:44 2018
@@ -3630,16 +3630,12 @@ static StructorCodegen getCodegenToUse(C
   }
   llvm::GlobalValue::LinkageTypes Linkage = CGM.getFunctionLinkage(AliasDecl);
 
-  // Only use RAUW in optimized code, as it makes the complete structor symbol
-  // disappear completely, which degrades debugging experience.
-  if (CGM.getCodeGenOpts().OptimizationLevel > 0) {
-if (llvm::GlobalValue::isDiscardableIfUnused(Linkage))
-  return StructorCodegen::RAUW;
+  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage))
+return StructorCodegen::RAUW;
 
-// FIXME: Should we allow available_externally aliases?
-if (!llvm::GlobalAlias::isValidLinkage(Linkage))
-  return StructorCodegen::RAUW;
-  }
+  // FIXME: Should we allow available_externally aliases?
+  if (!llvm::GlobalAlias::isValidLinkage(Linkage))
+return StructorCodegen::RAUW;
 
   if (llvm::GlobalValue::isWeakForLinker(Linkage)) {
 // Only ELF and wasm support COMDATs with arbitrary names (C5/D5).

Modified: cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp?rev=332232=332231=332232=diff
==
--- cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp Mon May 14 04:35:44 2018
@@ -77,12 +77,11 @@ namespace test4 {
   // CHECK1: call i32 @__cxa_atexit{{.*}}_ZN5test41AD2Ev
   // CHECK1: define linkonce_odr void @_ZN5test41AD2Ev({{.*}} comdat align
 
-  // test that we don't do this optimization at -O0 and call the complete
-  // destructor for B instead. This enables the debugger to see both
-  // destructors.
-  // NOOPT: @_ZN5test41BD1Ev = linkonce_odr alias void {{.*}} @_ZN5test41BD2Ev
+  // test that we don't do this optimization at -O0 so that the debugger can
+  // see both destructors.
   // NOOPT: define internal void @__cxx_global_var_init.2()
-  // NOOPT: call i32 @__cxa_atexit{{.*}}@_ZN5test41BD1Ev
+  // NOOPT: call i32 @__cxa_atexit{{.*}}@_ZN5test41BD2Ev
+  // NOOPT: define linkonce_odr void @_ZN5test41BD2Ev({{.*}} comdat align
   struct A {
 virtual ~A() {}
   };

Modified: cfe/trunk/test/CodeGenCXX/float16-declarations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/float16-declarations.cpp?rev=332232=332231=332232=diff
==
--- cfe/trunk/test/CodeGenCXX/float16-declarations.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/float16-declarations.cpp Mon May 14 04:35:44 2018
@@ -103,7 +103,7 @@ int main(void) {
 
   C1 c1(f1l);
 // CHECK-DAG:  [[F1L:%[a-z0-9]+]] = load half, half* %{{.*}}, align 2
-// CHECK-DAG:  call void @_ZN2C1C1EDF16_(%class.C1* %{{.*}}, half %{{.*}})
+// CHECK-DAG:  call void @_ZN2C1C2EDF16_(%class.C1* %{{.*}}, half %{{.*}})
 
   S1<_Float16> s1 = { 132.f16 };
 // CHECK-DAG: @_ZZ4mainE2s1 = private unnamed_addr constant %struct.S1 { half 
0xH5820 }, align 2


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


r332228 - [CodeGen] Disable aggressive structor optimizations at -O0

2018-05-14 Thread Pavel Labath via cfe-commits
Author: labath
Date: Mon May 14 04:02:23 2018
New Revision: 332228

URL: http://llvm.org/viewvc/llvm-project?rev=332228=rev
Log:
[CodeGen] Disable aggressive structor optimizations at -O0

Summary:
Removing the full structor and replacing all usages with the base one
can degrade debug quality as it will leave the debugger unable to locate
the full object structor. This is apparent when evaluating an expression
in the debugger which requires constructing an object of class which has
had this optimization applied to it.  When compiling the expression, we
pretend that the class and its methods have been defined in another
compilation unit, so the expression compiler assumes the structor
definition must be available. This didn't use to be the case for
structors with internal linkage. Less aggressive optimizations like
emitting the full structor as an alias remain in place, as they do not
cause the structor symbol to disappear completely.

This improves debug quality on non-darwin platforms (darwin does not
have -mconstructor-aliases on by default, so it is spared these
problems) and enable us to remove some workarounds from LLDB which attempt to
mitigate this issue.

Reviewers: rjmccall, aprantl

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp
cfe/trunk/test/CodeGenCXX/float16-declarations.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=332228=332227=332228=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Mon May 14 04:02:23 2018
@@ -3630,12 +3630,16 @@ static StructorCodegen getCodegenToUse(C
   }
   llvm::GlobalValue::LinkageTypes Linkage = CGM.getFunctionLinkage(AliasDecl);
 
-  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage))
-return StructorCodegen::RAUW;
+  // Only use RAUW in optimized code, as it makes the complete structor symbol
+  // disappear completely, which degrades debugging experience.
+  if (CGM.getCodeGenOpts().OptimizationLevel > 0) {
+if (llvm::GlobalValue::isDiscardableIfUnused(Linkage))
+  return StructorCodegen::RAUW;
 
-  // FIXME: Should we allow available_externally aliases?
-  if (!llvm::GlobalAlias::isValidLinkage(Linkage))
-return StructorCodegen::RAUW;
+// FIXME: Should we allow available_externally aliases?
+if (!llvm::GlobalAlias::isValidLinkage(Linkage))
+  return StructorCodegen::RAUW;
+  }
 
   if (llvm::GlobalValue::isWeakForLinker(Linkage)) {
 // Only ELF and wasm support COMDATs with arbitrary names (C5/D5).

Modified: cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp?rev=332228=332227=332228=diff
==
--- cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp Mon May 14 04:02:23 2018
@@ -77,11 +77,12 @@ namespace test4 {
   // CHECK1: call i32 @__cxa_atexit{{.*}}_ZN5test41AD2Ev
   // CHECK1: define linkonce_odr void @_ZN5test41AD2Ev({{.*}} comdat align
 
-  // test that we don't do this optimization at -O0 so that the debugger can
-  // see both destructors.
+  // test that we don't do this optimization at -O0 and call the complete
+  // destructor for B instead. This enables the debugger to see both
+  // destructors.
+  // NOOPT: @_ZN5test41BD1Ev = linkonce_odr alias void {{.*}} @_ZN5test41BD2Ev
   // NOOPT: define internal void @__cxx_global_var_init.2()
-  // NOOPT: call i32 @__cxa_atexit{{.*}}@_ZN5test41BD2Ev
-  // NOOPT: define linkonce_odr void @_ZN5test41BD2Ev({{.*}} comdat align
+  // NOOPT: call i32 @__cxa_atexit{{.*}}@_ZN5test41BD1Ev
   struct A {
 virtual ~A() {}
   };

Modified: cfe/trunk/test/CodeGenCXX/float16-declarations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/float16-declarations.cpp?rev=332228=332227=332228=diff
==
--- cfe/trunk/test/CodeGenCXX/float16-declarations.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/float16-declarations.cpp Mon May 14 04:02:23 2018
@@ -103,7 +103,7 @@ int main(void) {
 
   C1 c1(f1l);
 // CHECK-DAG:  [[F1L:%[a-z0-9]+]] = load half, half* %{{.*}}, align 2
-// CHECK-DAG:  call void @_ZN2C1C2EDF16_(%class.C1* %{{.*}}, half %{{.*}})
+// CHECK-DAG:  call void @_ZN2C1C1EDF16_(%class.C1* %{{.*}}, half %{{.*}})
 
   S1<_Float16> s1 = { 132.f16 };
 // CHECK-DAG: @_ZZ4mainE2s1 = private unnamed_addr constant %struct.S1 { half 
0xH5820 }, align 2


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


r327491 - StaticAnalyzer: fix compiler warning. NFC

2018-03-14 Thread Pavel Labath via cfe-commits
Author: labath
Date: Wed Mar 14 03:16:40 2018
New Revision: 327491

URL: http://llvm.org/viewvc/llvm-project?rev=327491=rev
Log:
StaticAnalyzer: fix compiler warning. NFC

My compiler (clang-3.8) complains that the RCC variable is unused.
That's not really true, as it's checked by the if-declaration, but it's
also kinda true, because we don't need to declaration if we only check
it in the if statement.

In reality, all this means that the dyn_cast<> can be replaced by isa<>,
so that's what I do here.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=327491=327490=327491=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Wed Mar 14 03:16:40 2018
@@ -464,7 +464,7 @@ ProgramStateRef ExprEngine::addAllNecess
 
 // If the temporary is being returned from the function, it will be
 // destroyed or lifetime-extended in the caller stack frame.
-if (const auto *RCC = dyn_cast(CC)) {
+if (isa(CC)) {
   const StackFrameContext *SFC = LC->getCurrentStackFrame();
   assert(SFC);
   if (SFC->getParent()) {


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


r327383 - clang-import-test: fix build with clang-3.8

2018-03-13 Thread Pavel Labath via cfe-commits
Author: labath
Date: Tue Mar 13 04:28:27 2018
New Revision: 327383

URL: http://llvm.org/viewvc/llvm-project?rev=327383=rev
Log:
clang-import-test: fix build with clang-3.8

clang-3.8 complains that constructor for '...' must explicitly
initialize the const object. Newer clangs and gcc seem to be fine with
this, but explicitly initializing the variable does not hurt.

Modified:
cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Modified: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-import-test/clang-import-test.cpp?rev=327383=327382=327383=diff
==
--- cfe/trunk/tools/clang-import-test/clang-import-test.cpp (original)
+++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp Tue Mar 13 04:28:27 
2018
@@ -245,7 +245,7 @@ struct CIAndOrigins {
   ASTContext () { return CI->getASTContext(); }
   FileManager () { return CI->getFileManager(); }
   const OriginMap () {
-static const OriginMap EmptyOriginMap;
+static const OriginMap EmptyOriginMap{};
 if (ExternalASTSource *Source = CI->getASTContext().getExternalSource())
   return static_cast(Source)->GetOrigins();
 return EmptyOriginMap;


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


r322268 - [Lex] Use WritableMemoryBuffer in ScratchBuffer.cpp

2018-01-11 Thread Pavel Labath via cfe-commits
Author: labath
Date: Thu Jan 11 02:43:45 2018
New Revision: 322268

URL: http://llvm.org/viewvc/llvm-project?rev=322268=rev
Log:
[Lex] Use WritableMemoryBuffer in ScratchBuffer.cpp

This avoids the need to const_cast the buffer contents to write to it.

NFCI.

Modified:
cfe/trunk/lib/Lex/ScratchBuffer.cpp

Modified: cfe/trunk/lib/Lex/ScratchBuffer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ScratchBuffer.cpp?rev=322268=322267=322268=diff
==
--- cfe/trunk/lib/Lex/ScratchBuffer.cpp (original)
+++ cfe/trunk/lib/Lex/ScratchBuffer.cpp Thu Jan 11 02:43:45 2018
@@ -74,11 +74,11 @@ void ScratchBuffer::AllocScratchBuffer(u
 
   // Get scratch buffer. Zero-initialize it so it can be dumped into a PCH file
   // deterministically.
-  std::unique_ptr OwnBuf =
-  llvm::MemoryBuffer::getNewMemBuffer(RequestLen, "");
-  llvm::MemoryBuffer  = *OwnBuf;
+  std::unique_ptr OwnBuf =
+  llvm::WritableMemoryBuffer::getNewMemBuffer(RequestLen,
+  "");
+  CurBuffer = OwnBuf->getBufferStart();
   FileID FID = SourceMgr.createFileID(std::move(OwnBuf));
   BufferStartLoc = SourceMgr.getLocForStartOfFile(FID);
-  CurBuffer = const_cast(Buf.getBufferStart());
   BytesUsed = 0;
 }


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


r292914 - Replace use of chdir with llvm::sys::fs::set_current_path

2017-01-24 Thread Pavel Labath via cfe-commits
Author: labath
Date: Tue Jan 24 05:14:29 2017
New Revision: 292914

URL: http://llvm.org/viewvc/llvm-project?rev=292914=rev
Log:
Replace use of chdir with llvm::sys::fs::set_current_path

NFCI

Modified:
cfe/trunk/lib/Basic/VirtualFileSystem.cpp

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=292914=292913=292914=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Tue Jan 24 05:14:29 2017
@@ -27,13 +27,6 @@
 #include 
 #include 
 
-// For chdir.
-#ifdef LLVM_ON_WIN32
-#  include 
-#else
-#  include 
-#endif
-
 using namespace clang;
 using namespace clang::vfs;
 using namespace llvm;
@@ -235,11 +228,7 @@ std::error_code RealFileSystem::setCurre
   // difference for example on network filesystems, where symlinks might be
   // switched during runtime of the tool. Fixing this depends on having a
   // file system abstraction that allows openat() style interactions.
-  SmallString<256> Storage;
-  StringRef Dir = Path.toNullTerminatedStringRef(Storage);
-  if (int Err = ::chdir(Dir.data()))
-return std::error_code(Err, std::generic_category());
-  return std::error_code();
+  return llvm::sys::fs::set_current_path(Path);
 }
 
 IntrusiveRefCntPtr vfs::getRealFileSystem() {


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


r286357 - Replace TimeValue with TimePoint in BuildSystem.cpp. NFC.

2016-11-09 Thread Pavel Labath via cfe-commits
Author: labath
Date: Wed Nov  9 05:19:39 2016
New Revision: 286357

URL: http://llvm.org/viewvc/llvm-project?rev=286357=rev
Log:
Replace TimeValue with TimePoint in BuildSystem.cpp. NFC.

Modified:
cfe/trunk/tools/libclang/BuildSystem.cpp

Modified: cfe/trunk/tools/libclang/BuildSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/BuildSystem.cpp?rev=286357=286356=286357=diff
==
--- cfe/trunk/tools/libclang/BuildSystem.cpp (original)
+++ cfe/trunk/tools/libclang/BuildSystem.cpp Wed Nov  9 05:19:39 2016
@@ -16,15 +16,15 @@
 #include "clang/Basic/VirtualFileSystem.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/CBindingWrapping.h"
+#include "llvm/Support/Chrono.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/TimeValue.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
 using namespace llvm::sys;
 
 unsigned long long clang_getBuildSessionTimestamp(void) {
-  return llvm::sys::TimeValue::now().toEpochTime();
+  return llvm::sys::toTimeT(std::chrono::system_clock::now());
 }
 
 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(clang::vfs::YAMLVFSWriter,


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


r286356 - [VFS] Replace TimeValue usage with std::chrono

2016-11-09 Thread Pavel Labath via cfe-commits
Author: labath
Date: Wed Nov  9 04:52:22 2016
New Revision: 286356

URL: http://llvm.org/viewvc/llvm-project?rev=286356=rev
Log:
[VFS] Replace TimeValue usage with std::chrono

Summary: NFCI

Reviewers: benlangmuir, zturner

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/lib/Basic/FileSystemStatCache.cpp
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Serialization/ModuleManager.cpp
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=286356=286355=286356=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Wed Nov  9 04:52:22 2016
@@ -16,10 +16,10 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/Support/Chrono.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/SourceMgr.h"
-#include "llvm/Support/TimeValue.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -34,7 +34,7 @@ namespace vfs {
 class Status {
   std::string Name;
   llvm::sys::fs::UniqueID UID;
-  llvm::sys::TimeValue MTime;
+  llvm::sys::TimePoint<> MTime;
   uint32_t User;
   uint32_t Group;
   uint64_t Size;
@@ -48,7 +48,7 @@ public:
   Status() : Type(llvm::sys::fs::file_type::status_error) {}
   Status(const llvm::sys::fs::file_status );
   Status(StringRef Name, llvm::sys::fs::UniqueID UID,
- llvm::sys::TimeValue MTime, uint32_t User, uint32_t Group,
+ llvm::sys::TimePoint<> MTime, uint32_t User, uint32_t Group,
  uint64_t Size, llvm::sys::fs::file_type Type,
  llvm::sys::fs::perms Perms);
 
@@ -64,7 +64,7 @@ public:
   /// @{
   llvm::sys::fs::file_type getType() const { return Type; }
   llvm::sys::fs::perms getPermissions() const { return Perms; }
-  llvm::sys::TimeValue getLastModificationTime() const { return MTime; }
+  llvm::sys::TimePoint<> getLastModificationTime() const { return MTime; }
   llvm::sys::fs::UniqueID getUniqueID() const { return UID; }
   uint32_t getUser() const { return User; }
   uint32_t getGroup() const { return Group; }

Modified: cfe/trunk/lib/Basic/FileSystemStatCache.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileSystemStatCache.cpp?rev=286356=286355=286356=diff
==
--- cfe/trunk/lib/Basic/FileSystemStatCache.cpp (original)
+++ cfe/trunk/lib/Basic/FileSystemStatCache.cpp Wed Nov  9 04:52:22 2016
@@ -23,7 +23,7 @@ static void copyStatusToFileData(const v
  FileData ) {
   Data.Name = Status.getName();
   Data.Size = Status.getSize();
-  Data.ModTime = Status.getLastModificationTime().toEpochTime();
+  Data.ModTime = llvm::sys::toTimeT(Status.getLastModificationTime());
   Data.UniqueID = Status.getUniqueID();
   Data.IsDirectory = Status.isDirectory();
   Data.IsNamedPipe = Status.getType() == llvm::sys::fs::file_type::fifo_file;

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=286356=286355=286356=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Wed Nov  9 04:52:22 2016
@@ -47,7 +47,7 @@ Status::Status(const file_status 
   User(Status.getUser()), Group(Status.getGroup()), Size(Status.getSize()),
   Type(Status.type()), Perms(Status.permissions()), IsVFSMapped(false)  {}
 
-Status::Status(StringRef Name, UniqueID UID, sys::TimeValue MTime,
+Status::Status(StringRef Name, UniqueID UID, sys::TimePoint<> MTime,
uint32_t User, uint32_t Group, uint64_t Size, file_type Type,
perms Perms)
 : Name(Name), UID(UID), MTime(MTime), User(User), Group(Group), Size(Size),
@@ -494,8 +494,8 @@ public:
 
 InMemoryFileSystem::InMemoryFileSystem(bool UseNormalizedPaths)
 : Root(new detail::InMemoryDirectory(
-  Status("", getNextVirtualUniqueID(), llvm::sys::TimeValue::MinTime(),
- 0, 0, 0, llvm::sys::fs::file_type::directory_file,
+  Status("", getNextVirtualUniqueID(), llvm::sys::TimePoint<>(), 0, 0,
+ 0, llvm::sys::fs::file_type::directory_file,
  llvm::sys::fs::perms::all_all))),
   UseNormalizedPaths(UseNormalizedPaths) {}
 
@@ -532,7 +532,7 @@ bool InMemoryFileSystem::addFile(const T
 // End of the path, create a new file.
 // FIXME: expose the status details in the interface.
 Status Stat(P.str(), 

[PATCH] D25948: [VFS] Replace TimeValue usage with std::chrono

2016-11-09 Thread Pavel Labath via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286356: [VFS] Replace TimeValue usage with std::chrono 
(authored by labath).

Changed prior to commit:
  https://reviews.llvm.org/D25948?vs=75723=77330#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25948

Files:
  cfe/trunk/include/clang/Basic/VirtualFileSystem.h
  cfe/trunk/lib/Basic/FileSystemStatCache.cpp
  cfe/trunk/lib/Basic/VirtualFileSystem.cpp
  cfe/trunk/lib/Frontend/ASTUnit.cpp
  cfe/trunk/lib/Serialization/ModuleManager.cpp
  cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Index: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
===
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h
@@ -16,10 +16,10 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/Support/Chrono.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/SourceMgr.h"
-#include "llvm/Support/TimeValue.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -34,7 +34,7 @@
 class Status {
   std::string Name;
   llvm::sys::fs::UniqueID UID;
-  llvm::sys::TimeValue MTime;
+  llvm::sys::TimePoint<> MTime;
   uint32_t User;
   uint32_t Group;
   uint64_t Size;
@@ -48,7 +48,7 @@
   Status() : Type(llvm::sys::fs::file_type::status_error) {}
   Status(const llvm::sys::fs::file_status );
   Status(StringRef Name, llvm::sys::fs::UniqueID UID,
- llvm::sys::TimeValue MTime, uint32_t User, uint32_t Group,
+ llvm::sys::TimePoint<> MTime, uint32_t User, uint32_t Group,
  uint64_t Size, llvm::sys::fs::file_type Type,
  llvm::sys::fs::perms Perms);
 
@@ -64,7 +64,7 @@
   /// @{
   llvm::sys::fs::file_type getType() const { return Type; }
   llvm::sys::fs::perms getPermissions() const { return Perms; }
-  llvm::sys::TimeValue getLastModificationTime() const { return MTime; }
+  llvm::sys::TimePoint<> getLastModificationTime() const { return MTime; }
   llvm::sys::fs::UniqueID getUniqueID() const { return UID; }
   uint32_t getUser() const { return User; }
   uint32_t getGroup() const { return Group; }
Index: cfe/trunk/lib/Basic/FileSystemStatCache.cpp
===
--- cfe/trunk/lib/Basic/FileSystemStatCache.cpp
+++ cfe/trunk/lib/Basic/FileSystemStatCache.cpp
@@ -23,7 +23,7 @@
  FileData ) {
   Data.Name = Status.getName();
   Data.Size = Status.getSize();
-  Data.ModTime = Status.getLastModificationTime().toEpochTime();
+  Data.ModTime = llvm::sys::toTimeT(Status.getLastModificationTime());
   Data.UniqueID = Status.getUniqueID();
   Data.IsDirectory = Status.isDirectory();
   Data.IsNamedPipe = Status.getType() == llvm::sys::fs::file_type::fifo_file;
Index: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
===
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp
@@ -47,7 +47,7 @@
   User(Status.getUser()), Group(Status.getGroup()), Size(Status.getSize()),
   Type(Status.type()), Perms(Status.permissions()), IsVFSMapped(false)  {}
 
-Status::Status(StringRef Name, UniqueID UID, sys::TimeValue MTime,
+Status::Status(StringRef Name, UniqueID UID, sys::TimePoint<> MTime,
uint32_t User, uint32_t Group, uint64_t Size, file_type Type,
perms Perms)
 : Name(Name), UID(UID), MTime(MTime), User(User), Group(Group), Size(Size),
@@ -494,8 +494,8 @@
 
 InMemoryFileSystem::InMemoryFileSystem(bool UseNormalizedPaths)
 : Root(new detail::InMemoryDirectory(
-  Status("", getNextVirtualUniqueID(), llvm::sys::TimeValue::MinTime(),
- 0, 0, 0, llvm::sys::fs::file_type::directory_file,
+  Status("", getNextVirtualUniqueID(), llvm::sys::TimePoint<>(), 0, 0,
+ 0, llvm::sys::fs::file_type::directory_file,
  llvm::sys::fs::perms::all_all))),
   UseNormalizedPaths(UseNormalizedPaths) {}
 
@@ -532,7 +532,7 @@
 // End of the path, create a new file.
 // FIXME: expose the status details in the interface.
 Status Stat(P.str(), getNextVirtualUniqueID(),
-llvm::sys::TimeValue(ModificationTime, 0), 0, 0,
+llvm::sys::toTimePoint(ModificationTime), 0, 0,
 Buffer->getBufferSize(),
 llvm::sys::fs::file_type::regular_file,
 llvm::sys::fs::all_all);
@@ -545,9 +545,9 @@
   // FIXME: expose the status details in the interface.
   Status Stat(
   StringRef(Path.str().begin(), Name.end() - Path.str().begin()),
-  getNextVirtualUniqueID(), llvm::sys::TimeValue(ModificationTime, 0),
-  0, 0, Buffer->getBufferSize(),
-  llvm::sys::fs::file_type::directory_file, 

[PATCH] D25948: [VFS] Replace TimeValue usage with std::chrono

2016-11-08 Thread Pavel Labath via cfe-commits
labath added a comment.

If noone objects, I am going to commit this tomorrow.


https://reviews.llvm.org/D25948



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


[PATCH] D25948: [VFS] Replace TimeValue usage with std::chrono

2016-10-25 Thread Pavel Labath via cfe-commits
labath created this revision.
labath added reviewers: benlangmuir, zturner.
labath added a subscriber: cfe-commits.

NFCI


https://reviews.llvm.org/D25948

Files:
  include/clang/Basic/VirtualFileSystem.h
  lib/Basic/FileSystemStatCache.cpp
  lib/Basic/VirtualFileSystem.cpp
  lib/Frontend/ASTUnit.cpp
  lib/Serialization/ModuleManager.cpp
  unittests/Basic/VirtualFileSystemTest.cpp

Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -115,20 +115,23 @@
   }
 
   void addRegularFile(StringRef Path, sys::fs::perms Perms = sys::fs::all_all) {
-vfs::Status S(Path, UniqueID(FSID, FileID++), sys::TimeValue::now(), 0, 0,
-  1024, sys::fs::file_type::regular_file, Perms);
+vfs::Status S(Path, UniqueID(FSID, FileID++),
+  std::chrono::system_clock::now(), 0, 0, 1024,
+  sys::fs::file_type::regular_file, Perms);
 addEntry(Path, S);
   }
 
   void addDirectory(StringRef Path, sys::fs::perms Perms = sys::fs::all_all) {
-vfs::Status S(Path, UniqueID(FSID, FileID++), sys::TimeValue::now(), 0, 0,
-  0, sys::fs::file_type::directory_file, Perms);
+vfs::Status S(Path, UniqueID(FSID, FileID++),
+  std::chrono::system_clock::now(), 0, 0, 0,
+  sys::fs::file_type::directory_file, Perms);
 addEntry(Path, S);
   }
 
   void addSymlink(StringRef Path) {
-vfs::Status S(Path, UniqueID(FSID, FileID++), sys::TimeValue::now(), 0, 0,
-  0, sys::fs::file_type::symlink_file, sys::fs::all_all);
+vfs::Status S(Path, UniqueID(FSID, FileID++),
+  std::chrono::system_clock::now(), 0, 0, 0,
+  sys::fs::file_type::symlink_file, sys::fs::all_all);
 addEntry(Path, S);
   }
 };
Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -102,7 +102,7 @@
   // A cached stat value would be fine as well.
   if (!FileMgr.getNoncachedStatValue(TimestampFilename, Status))
 ModuleEntry->InputFilesValidationTimestamp =
-Status.getLastModificationTime().toEpochTime();
+llvm::sys::toTimeT(Status.getLastModificationTime());
 }
 
 // Load the contents of the module
Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -1392,7 +1392,8 @@
 }
 
 OverriddenFiles[Status.getUniqueID()] = PreambleFileHash::createForFile(
-Status.getSize(), Status.getLastModificationTime().toEpochTime());
+Status.getSize(),
+llvm::sys::toTimeT(Status.getLastModificationTime()));
   }
 
   for (const auto  : PreprocessorOpts.RemappedFileBuffers) {
@@ -1433,8 +1434,8 @@
 
 // The file was not remapped; check whether it has changed on disk.
 if (Status.getSize() != uint64_t(F->second.Size) ||
-Status.getLastModificationTime().toEpochTime() !=
-uint64_t(F->second.ModTime))
+llvm::sys::toTimeT(Status.getLastModificationTime()) !=
+F->second.ModTime)
   AnyFileChanged = true;
   }
   
Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -47,7 +47,7 @@
   User(Status.getUser()), Group(Status.getGroup()), Size(Status.getSize()),
   Type(Status.type()), Perms(Status.permissions()), IsVFSMapped(false)  {}
 
-Status::Status(StringRef Name, UniqueID UID, sys::TimeValue MTime,
+Status::Status(StringRef Name, UniqueID UID, sys::TimePoint<> MTime,
uint32_t User, uint32_t Group, uint64_t Size, file_type Type,
perms Perms)
 : Name(Name), UID(UID), MTime(MTime), User(User), Group(Group), Size(Size),
@@ -494,8 +494,8 @@
 
 InMemoryFileSystem::InMemoryFileSystem(bool UseNormalizedPaths)
 : Root(new detail::InMemoryDirectory(
-  Status("", getNextVirtualUniqueID(), llvm::sys::TimeValue::MinTime(),
- 0, 0, 0, llvm::sys::fs::file_type::directory_file,
+  Status("", getNextVirtualUniqueID(), llvm::sys::TimePoint<>(), 0, 0,
+ 0, llvm::sys::fs::file_type::directory_file,
  llvm::sys::fs::perms::all_all))),
   UseNormalizedPaths(UseNormalizedPaths) {}
 
@@ -532,7 +532,7 @@
 // End of the path, create a new file.
 // FIXME: expose the status details in the interface.
 Status Stat(P.str(), getNextVirtualUniqueID(),
-llvm::sys::TimeValue(ModificationTime, 0), 0, 0,
+llvm::sys::toTimePoint(ModificationTime), 0, 0,
 

r284964 - Adjust for TimePoint interface change in llvm: D25730. NFC

2016-10-24 Thread Pavel Labath via cfe-commits
Author: labath
Date: Mon Oct 24 05:59:13 2016
New Revision: 284964

URL: http://llvm.org/viewvc/llvm-project?rev=284964=rev
Log:
Adjust for TimePoint interface change in llvm: D25730. NFC

Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=284964=284963=284964=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Mon Oct 24 05:59:13 2016
@@ -19,6 +19,7 @@
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/TimeValue.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=284964=284963=284964=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Oct 24 05:59:13 2016
@@ -5576,9 +5576,11 @@ void Clang::ConstructJob(Compilation ,
 llvm::sys::fs::file_status Status;
 if (llvm::sys::fs::status(A->getValue(), Status))
   D.Diag(diag::err_drv_no_such_file) << A->getValue();
-CmdArgs.push_back(Args.MakeArgString(
-"-fbuild-session-timestamp=" +
-Twine((uint64_t)Status.getLastModificationTime().toEpochTime(;
+CmdArgs.push_back(
+Args.MakeArgString("-fbuild-session-timestamp=" +
+   Twine((uint64_t)Status.getLastModificationTime()
+ .time_since_epoch()
+ .count(;
   }
 
   if (Args.getLastArg(options::OPT_fmodules_validate_once_per_build_session)) {


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


r271565 - [cmake] Fix-up r271533

2016-06-02 Thread Pavel Labath via cfe-commits
Author: labath
Date: Thu Jun  2 13:49:42 2016
New Revision: 271565

URL: http://llvm.org/viewvc/llvm-project?rev=271565=rev
Log:
[cmake] Fix-up r271533

I was appending to the wrong variable (over-zealous copy-paste from llvm on my 
part).

Modified:
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=271565=271564=271565=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Thu Jun  2 13:49:42 2016
@@ -76,11 +76,11 @@ if( NOT CLANG_BUILT_STANDALONE )
 )
 
   if(TARGET llvm-lto)
-set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} llvm-lto)
+list(APPEND CLANG_TEST_DEPS llvm-lto)
   endif()
 
   if(TARGET LTO)
-set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} LTO)
+list(APPEND CLANG_TEST_DEPS LTO)
   endif()
 endif()
 


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


Re: [PATCH] D20883: [cmake] Fix builds with LLVM_ENABLE_PIC=0

2016-06-02 Thread Pavel Labath via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271533: [cmake] Fix builds with LLVM_ENABLE_PIC=0 (authored 
by labath).

Changed prior to commit:
  http://reviews.llvm.org/D20883?vs=59293=59405#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20883

Files:
  cfe/trunk/test/CMakeLists.txt

Index: cfe/trunk/test/CMakeLists.txt
===
--- cfe/trunk/test/CMakeLists.txt
+++ cfe/trunk/test/CMakeLists.txt
@@ -68,14 +68,20 @@
 FileCheck count not
 llc
 llvm-bcanalyzer
-llvm-lto
 llvm-objdump
 llvm-profdata
 llvm-readobj
 llvm-symbolizer
-LTO
 opt
 )
+
+  if(TARGET llvm-lto)
+set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} llvm-lto)
+  endif()
+
+  if(TARGET LTO)
+set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} LTO)
+  endif()
 endif()
 
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})


Index: cfe/trunk/test/CMakeLists.txt
===
--- cfe/trunk/test/CMakeLists.txt
+++ cfe/trunk/test/CMakeLists.txt
@@ -68,14 +68,20 @@
 FileCheck count not
 llc
 llvm-bcanalyzer
-llvm-lto
 llvm-objdump
 llvm-profdata
 llvm-readobj
 llvm-symbolizer
-LTO
 opt
 )
+
+  if(TARGET llvm-lto)
+set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} llvm-lto)
+  endif()
+
+  if(TARGET LTO)
+set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} LTO)
+  endif()
 endif()
 
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r271533 - [cmake] Fix builds with LLVM_ENABLE_PIC=0

2016-06-02 Thread Pavel Labath via cfe-commits
Author: labath
Date: Thu Jun  2 11:35:24 2016
New Revision: 271533

URL: http://llvm.org/viewvc/llvm-project?rev=271533=rev
Log:
[cmake] Fix builds with LLVM_ENABLE_PIC=0

Summary:
When this flag is specified, the target llvm-lto is not built, but is still
used as a dependency of the test targets. cmake 2.8 silently ignored this
situation, but with cmake_minimum_required(3.4) it becomes an error. Fix this
by avoiding the inclusion the target as a dependency.

Reviewers: beanz

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D20883

Modified:
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=271533=271532=271533=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Thu Jun  2 11:35:24 2016
@@ -68,14 +68,20 @@ if( NOT CLANG_BUILT_STANDALONE )
 FileCheck count not
 llc
 llvm-bcanalyzer
-llvm-lto
 llvm-objdump
 llvm-profdata
 llvm-readobj
 llvm-symbolizer
-LTO
 opt
 )
+
+  if(TARGET llvm-lto)
+set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} llvm-lto)
+  endif()
+
+  if(TARGET LTO)
+set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} LTO)
+  endif()
 endif()
 
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})


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


[PATCH] D20883: [cmake] Fix builds with LLVM_ENABLE_PIC=0

2016-06-01 Thread Pavel Labath via cfe-commits
labath created this revision.
labath added a reviewer: beanz.
labath added a subscriber: cfe-commits.

When this flag is specified, the target llvm-lto is not built, but is still
used as a dependency of the test targets. cmake 2.8 silently ignored this
situation, but with cmake_minimum_required(3.4) it becomes an error. Fix this
by avoiding the inclusion the target as a dependency.

http://reviews.llvm.org/D20883

Files:
  test/CMakeLists.txt

Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -68,14 +68,20 @@
 FileCheck count not
 llc
 llvm-bcanalyzer
-llvm-lto
 llvm-objdump
 llvm-profdata
 llvm-readobj
 llvm-symbolizer
-LTO
 opt
 )
+
+  if(TARGET llvm-lto)
+set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} llvm-lto)
+  endif()
+
+  if(TARGET LTO)
+set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} LTO)
+  endif()
 endif()
 
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -68,14 +68,20 @@
 FileCheck count not
 llc
 llvm-bcanalyzer
-llvm-lto
 llvm-objdump
 llvm-profdata
 llvm-readobj
 llvm-symbolizer
-LTO
 opt
 )
+
+  if(TARGET llvm-lto)
+set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} llvm-lto)
+  endif()
+
+  if(TARGET LTO)
+set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} LTO)
+  endif()
 endif()
 
 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262700 - [SemaExprCXX] Avoid calling isInSystemHeader for invalid source locations

2016-03-04 Thread Pavel Labath via cfe-commits
Author: labath
Date: Fri Mar  4 04:00:08 2016
New Revision: 262700

URL: http://llvm.org/viewvc/llvm-project?rev=262700=rev
Log:
[SemaExprCXX] Avoid calling isInSystemHeader for invalid source locations

Summary:
While diagnosing a CXXNewExpr warning, we were calling isInSystemHeader(), 
which expect to be
called with a valid source location. This causes an assertion failure if the 
location is unknown.
A quick grep shows it's not without precedent to guard calls to the function 
with a
"Loc.isValid()".

This fixes a test failure in LLDB, which always creates object with invalid 
source locations as it
does not (always) have access to the source.

Reviewers: nlewycky

Subscribers: lldb-commits, cfe-commits

Differential Revision: http://reviews.llvm.org/D17847

Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=262700=262699=262700=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Mar  4 04:00:08 2016
@@ -1551,7 +1551,8 @@ Sema::BuildCXXNew(SourceRange Range, boo
   // new.
   if (PlacementArgs.empty() && OperatorNew &&
   (OperatorNew->isImplicit() ||
-   getSourceManager().isInSystemHeader(OperatorNew->getLocStart( {
+   (OperatorNew->getLocStart().isValid() &&
+getSourceManager().isInSystemHeader(OperatorNew->getLocStart() {
 if (unsigned Align = 
Context.getPreferredTypeAlign(AllocType.getTypePtr())){
   unsigned SuitableAlign = Context.getTargetInfo().getSuitableAlign();
   if (Align > SuitableAlign)


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


Re: [PATCH] D17845: [ASTImporter] Import "implicit" attribute of FunctionDecls

2016-03-03 Thread Pavel Labath via cfe-commits
labath added a subscriber: lldb-commits.
labath added a comment.

I noticed this while debugging an importing issue in LLDB.

I am not sure if I have selected the right reviewer, and also how/if to test 
this...


http://reviews.llvm.org/D17845



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


[PATCH] D17845: [ASTImporter] Import "implicit" attribute of FunctionDecls

2016-03-03 Thread Pavel Labath via cfe-commits
labath created this revision.
labath added a reviewer: akyrtzi.
labath added a subscriber: cfe-commits.

ASTImporter was importing this attribute only on destructor and constructor 
decls, as they take
it in the constructor, but other decls can have this attribute as well, notably 
the global
operator new. Make sure we import the attribute on all FunctionDecls.

http://reviews.llvm.org/D17845

Files:
  lib/AST/ASTImporter.cpp

Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -2922,6 +2922,7 @@
   ToFunction->setVirtualAsWritten(D->isVirtualAsWritten());
   ToFunction->setTrivial(D->isTrivial());
   ToFunction->setPure(D->isPure());
+  ToFunction->setImplicit(D->isImplicit());
   Importer.Imported(D, ToFunction);
 
   // Set the parameters.


Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -2922,6 +2922,7 @@
   ToFunction->setVirtualAsWritten(D->isVirtualAsWritten());
   ToFunction->setTrivial(D->isTrivial());
   ToFunction->setPure(D->isPure());
+  ToFunction->setImplicit(D->isImplicit());
   Importer.Imported(D, ToFunction);
 
   // Set the parameters.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13959: Fix crash in EmitDeclMetadata mode

2015-10-22 Thread Pavel Labath via cfe-commits
labath resigned from this revision.
labath removed a reviewer: labath.
labath added a comment.

I'll just observe this one. Someone with more knowledge of clang needs to 
review this.


Repository:
  rL LLVM

http://reviews.llvm.org/D13959



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