[clang] [NFC][clang][test][asan] Make `instantiation-depth-default.cpp` a valid test case under `asan` and `ubsan` configs (PR #75254)

2024-04-02 Thread Mitch Phillips via cfe-commits

hctim wrote:

Hey folks, unfortunately this started supriously failing again on AArch64+ASan. 
So I've disabled it again under sanitizers (by reverting this patch): 
https://lab.llvm.org/buildbot/#/builders/239/builds/6363

https://github.com/llvm/llvm-project/pull/75254
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bcac3ed - Revert "[NFC][clang][test][asan] Make `instantiation-depth-default.cpp` a valid test case under `asan` and `ubsan` configs (#75254)"

2024-04-02 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2024-04-02T16:15:45+02:00
New Revision: bcac3edac80044962d5dfe96b96f781fa0a70b2e

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

LOG: Revert "[NFC][clang][test][asan] Make `instantiation-depth-default.cpp` a 
valid test case under `asan` and `ubsan` configs (#75254)"

Disables the recursive template expansion test under ASan again. This
patch re-enabled this test with sanitizers, but it's started spuriously
failing with a stack overflow again on AArch64+ASan:
https://lab.llvm.org/buildbot/#/builders/239/builds/6363

This reverts commit c458f928fad7bbcf08ab1da9949eb2969fc9f89c.

Added: 


Modified: 
clang/test/SemaTemplate/instantiation-depth-default.cpp

Removed: 




diff  --git a/clang/test/SemaTemplate/instantiation-depth-default.cpp 
b/clang/test/SemaTemplate/instantiation-depth-default.cpp
index 430d042d7e0f49..f5835b86b3a385 100644
--- a/clang/test/SemaTemplate/instantiation-depth-default.cpp
+++ b/clang/test/SemaTemplate/instantiation-depth-default.cpp
@@ -1,12 +1,18 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-backtrace-limit=2 %if 
{{asan|ubsan}} %{ -Wno-stack-exhausted %} %s
+// RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-backtrace-limit=2 %s
+//
+// FIXME: Disable this test when Clang was built with ASan, because ASan
+// increases our per-frame stack usage enough that this test no longer fits
+// within our normal stack space allocation.
+// UNSUPPORTED: asan
+//
 // The default stack size on NetBSD is too small for this test.
 // UNSUPPORTED: system-netbsd
 
 template struct X : X {};
-// expected-error-re@5 {{recursive template instantiation exceeded maximum 
depth of 1024{{$
-// expected-note@5 {{instantiation of template class}}
-// expected-note@5 {{skipping 1023 contexts in backtrace}}
-// expected-note@5 {{use -ftemplate-depth=N to increase recursive template 
instantiation depth}}
+// expected-error-re@11 {{recursive template instantiation exceeded maximum 
depth of 1024{{$
+// expected-note@11 {{instantiation of template class}}
+// expected-note@11 {{skipping 1023 contexts in backtrace}}
+// expected-note@11 {{use -ftemplate-depth=N to increase recursive template 
instantiation depth}}
 
 X<0, int> x; // expected-note {{in instantiation of}}
 



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


[clang] [llvm] [ASAN] For Asan instrumented global, emit two symbols, one with actual size and other with instrumented size. (PR #70166)

2024-02-15 Thread Mitch Phillips via cfe-commits

hctim wrote:

Messing around with global variables (changing their size, padding, alignment) 
is a common theme amongst sanitizers. We'd therefore want any strategy applied 
to ASan to be generic and apply across other sanitizers.

The patch might not cause issues right now with ASan - but I think it's best to 
reserve the right to change the way that ASan's global variable instrumentation 
works. The padding bytes are currently unused. But, I've heard at least one 
idea come across my desk to change that and to use the "free" metadata space. 
That would be incompatible with your patch. In contrary - I still don't know 
why the small section of AMDGPU's symbol-copying code can't be just built 
without `__attribute__((no_sanitize("address")))`

https://github.com/llvm/llvm-project/pull/70166
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [ASAN] For Asan instrumented global, emit two symbols, one with actual size and other with instrumented size. (PR #70166)

2024-02-09 Thread Mitch Phillips via cfe-commits

hctim wrote:

Hi,

My apologies for the delay.

I started to hack together the same idea using `SanitizerMetadata`, which is 
definitely the preferred way of adding sanitizer globalvariable instrumentation 
(given that everything else already lives there). You can see the WIP here: 
https://pastebin.com/vXzHmnMg

Part way through patching up all the tests though, I've come to the conclusion 
that this really isn't a great idea. For just ASan, sure we can just emit a 
secondary symbol and everything is hunky dory. But I think that we shouldn't do 
something like this for just ASan, it needs to also work for HWASan and 
MTE-globals as well. And it really doesn't compose well with the MTE-globals 
model. If you were to emit the unpadded symbol as the dominant name (from the 
c/cpp definition), then the linker gets super confused if you're linking 
multiple DSOs, as it needs to ensure that *all* of the DSOs use the tagged 
definition (or they all get demoted to being untagged). So, you'd need the 
padded one to be the dominant name, which I think is not what you want.

This feels like a behaviour that we don't want the additional complexity for 
AMDGPU's drivers, because I highly suspect you can just deal with the 
sanitizers in the AMDGPU driver itself.

How does your driver work? If it's basically doing a `dlsym` -> `memcpy` (and 
the memcpy interceptor in ASan is firing because you're going OOB on the 
unpadded symbol), can't you just have an `internal_memcpy` that's built with 
`__attribute__((no_sanitize("address")))`?

We'd also potentially like to put some data in the padding. This has been 
discussed between some colleagues and I. If you end up not copying the padding 
as well, you might drop some metadata and things could explode in future.

HTH,
Mitch.

https://github.com/llvm/llvm-project/pull/70166
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MTE] Disable all MTE protection of globals in sections (PR #78443)

2024-01-22 Thread Mitch Phillips via cfe-commits

https://github.com/hctim closed https://github.com/llvm/llvm-project/pull/78443
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [MTE] Disable all MTE protection of globals in sections (PR #78443)

2024-01-17 Thread Mitch Phillips via cfe-commits

https://github.com/hctim created https://github.com/llvm/llvm-project/pull/78443

Previous work in this area (#70186) disabled MTE in constructor
sections. Looks like I missed one, ".preinit_array".

Also, in the meantime, I found an exciting feature in the linker where
globals placed into an explicit section, where the section name is a
valid C identifer, gets an implicit '__start_' and
'__stop_' symbol as well. This is convenient for iterating
over some globals, but of course iteration over differently-tagged
globals in MTE explodes.

Thus, disable MTE globals for anything that has a section.


>From dc9acd4b2dcd6f234175125e2ed4b027ab0e7619 Mon Sep 17 00:00:00 2001
From: Mitch Phillips 
Date: Wed, 17 Jan 2024 14:08:21 +0100
Subject: [PATCH] [MTE] Disable all MTE protection of globals in sections

Previous work in this area (#70186) disabled MTE in constructor
sections. Looks like I missed one, ".preinit_array".

Also, in the meantime, I found an exciting feature in the linker where
globals placed into an explicit section, where the section name is a
valid C identifer, gets an implicit '__start_' and
'__stop_' symbol as well. This is convenient for iterating
over some globals, but of course iteration over differently-tagged
globals in MTE explodes.

Thus, disable MTE globals for anything that has a section.
---
 clang/test/CodeGen/memtag-globals-asm.cpp |  8 ++
 .../Target/AArch64/AArch64GlobalsTagging.cpp  | 26 ++-
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/clang/test/CodeGen/memtag-globals-asm.cpp 
b/clang/test/CodeGen/memtag-globals-asm.cpp
index 4b76b394e0c1dc..186045f8f2fb5b 100644
--- a/clang/test/CodeGen/memtag-globals-asm.cpp
+++ b/clang/test/CodeGen/memtag-globals-asm.cpp
@@ -271,6 +271,10 @@ CONSTRUCTOR(".ctors") func_t func_ctors = func_constructor;
 CONSTRUCTOR(".dtors") func_t func_dtors = func_constructor;
 CONSTRUCTOR(".init_array") func_t func_init_array = func_constructor;
 CONSTRUCTOR(".fini_array") func_t func_fini_array = func_constructor;
+CONSTRUCTOR(".preinit_array") func_t preinit_array = func_constructor;
+CONSTRUCTOR("array_of_globals") int global1;
+CONSTRUCTOR("array_of_globals") int global2;
+CONSTRUCTOR("array_of_globals") int global_string;
 
 // CHECK-NOT: .memtag func_constructor
 // CHECK-NOT: .memtag func_init
@@ -279,3 +283,7 @@ CONSTRUCTOR(".fini_array") func_t func_fini_array = 
func_constructor;
 // CHECK-NOT: .memtag func_dtors
 // CHECK-NOT: .memtag func_init_array
 // CHECK-NOT: .memtag func_fini_array
+// CHECK-NOT: .memtag preinit_array
+// CHECK-NOT: .memtag global1
+// CHECK-NOT: .memtag global2
+// CHECK-NOT: .memtag global_string
diff --git a/llvm/lib/Target/AArch64/AArch64GlobalsTagging.cpp 
b/llvm/lib/Target/AArch64/AArch64GlobalsTagging.cpp
index 8ce6f94e7341de..27959489e7dfa4 100644
--- a/llvm/lib/Target/AArch64/AArch64GlobalsTagging.cpp
+++ b/llvm/lib/Target/AArch64/AArch64GlobalsTagging.cpp
@@ -43,13 +43,25 @@ static bool shouldTagGlobal(GlobalVariable ) {
 return false;
   }
 
-  // Don't instrument function pointers that are going into various init arrays
-  // via `__attribute__((section()))`:
-  // https://github.com/llvm/llvm-project/issues/69939
-  if (G.hasSection() &&
-  (G.getSection() == ".init" || G.getSection() == ".fini" ||
-   G.getSection() == ".init_array" || G.getSection() == ".fini_array" ||
-   G.getSection() == ".ctors" || G.getSection() == ".dtors")) {
+  // Globals can be placed implicitly or explicitly in sections. There's two
+  // different types of globals that meet this criteria that cause problems:
+  //  1. Function pointers that are going into various init arrays (either
+  // explicitly through `__attribute__((section()))` or implicitly
+  // through `__attribute__((constructor)))`, such as ".(pre)init(_array)",
+  // ".fini(_array)", ".ctors", and ".dtors". These function pointers end 
up
+  // overaligned and overpadded, making iterating over them problematic, 
and
+  // each function pointer is individually tagged (so the iteration over
+  // them causes SIGSEGV/MTE[AS]ERR).
+  //  2. Global variables put into an explicit section, where the section's 
name
+  // is a valid C-style identifier. The linker emits a `__start_` and
+  // `__stop_` symbol for the section, so that you can iterate over
+  // globals within this section. Unfortunately, again, these globals would
+  // be tagged and so iteration causes SIGSEGV/MTE[AS]ERR.
+  //
+  // To mitigate both these cases, and because specifying a section is rare
+  // outside of these two cases, disable MTE protection for globals in any
+  // section.
+  if (G.hasSection()) {
 Meta.Memtag = false;
 G.setSanitizerMetadata(Meta);
 return false;

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


[clang] [clang][analyzer] Add function 'ungetc' to StreamChecker. (PR #77331)

2024-01-09 Thread Mitch Phillips via cfe-commits
=?utf-8?q?Balázs_Kéri?= ,
=?utf-8?q?Balázs_Kéri?= 
Message-ID:
In-Reply-To: 


https://github.com/hctim updated https://github.com/llvm/llvm-project/pull/77331

>From 9bcc43b5c62ba969f91c495d4d570c5c4337aca2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Mon, 8 Jan 2024 16:42:58 +0100
Subject: [PATCH 1/3] [clang][analyzer] Add 'ungetc' to StreamChecker.

---
 clang/docs/ReleaseNotes.rst   |  4 +-
 .../Checkers/StdLibraryFunctionsChecker.cpp   | 19 
 .../StaticAnalyzer/Checkers/StreamChecker.cpp | 44 +++
 .../Analysis/Inputs/system-header-simulator.h |  1 +
 clang/test/Analysis/stream-error.c| 16 +++
 clang/test/Analysis/stream-noopen.c   | 25 +++
 clang/test/Analysis/stream.c  |  6 +++
 7 files changed, 113 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c7bf162426a68c..3bfcd7997faa19 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1162,8 +1162,8 @@ Improvements
   (`c3a87ddad62a 
`_,
   `0954dc3fb921 
`_)
 
-- Improved the ``alpha.unix.Stream`` checker by modeling more functions like,
-  ``fflush``, ``fputs``, ``fgetc``, ``fputc``, ``fopen``, ``fdopen``, 
``fgets``, ``tmpfile``.
+- Improved the ``alpha.unix.Stream`` checker by modeling more functions:
+  ``fputs``, ``fputc``, ``fgets``, ``fgetc``, ``fdopen``, ``ungetc``, 
``fflush``.
   (`#76776 `_,
   `#74296 `_,
   `#73335 `_,
diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 20068653d530a3..e16bf9feb5b1c4 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -2201,6 +2201,25 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
   ErrnoNEZeroIrrelevant, GenericFailureMsg)
 .ArgConstraint(NotNull(ArgNo(0;
 
+// int ungetc(int c, FILE *stream);
+addToFunctionSummaryMap(
+"ungetc", Signature(ArgTypes{IntTy, FilePtrTy}, RetType{IntTy}),
+Summary(NoEvalCall)
+.Case({ReturnValueCondition(BO_EQ, ArgNo(0)),
+   ArgumentCondition(0, WithinRange, {{0, UCharRangeMax}})},
+  ErrnoMustNotBeChecked, GenericSuccessMsg)
+.Case({ReturnValueCondition(WithinRange, SingleValue(EOFv)),
+   ArgumentCondition(0, WithinRange, {{EOFv, EOFv}})},
+  ErrnoNEZeroIrrelevant,
+  "Assuming that 'ungetc' fails because EOF was passed as "
+  "character")
+.Case({ReturnValueCondition(WithinRange, SingleValue(EOFv)),
+   ArgumentCondition(0, WithinRange, {{0, UCharRangeMax}})},
+  ErrnoNEZeroIrrelevant, GenericFailureMsg)
+.ArgConstraint(ArgumentCondition(
+0, WithinRange, {{EOFv, EOFv}, {0, UCharRangeMax}}))
+.ArgConstraint(NotNull(ArgNo(1;
+
 // int fseek(FILE *stream, long offset, int whence);
 // FIXME: It can be possible to get the 'SEEK_' values (like EOFv) and use
 // these for condition of arg 2.
diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 25da3c18e8519f..a3d1f34d3d1a9a 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -263,6 +263,9 @@ class StreamChecker : public Checker(Call.getOriginExpr());
+  if (!CE)
+return;
+
+  const StreamState *OldSS = State->get(StreamSym);
+  if (!OldSS)
+return;
+
+  assertStreamStateOpened(OldSS);
+
+  // Generate a transition for the success state.
+  std::optional PutVal = Call.getArgSVal(0).getAs();
+  if (!PutVal)
+return;
+  ProgramStateRef StateNotFailed =
+  State->BindExpr(CE, C.getLocationContext(), *PutVal);
+  StateNotFailed =
+  StateNotFailed->set(StreamSym, StreamState::getOpened(Desc));
+  C.addTransition(StateNotFailed);
+
+  // Add transition for the failed state.
+  // Failure of 'ungetc' does not result in feof or ferror state.
+  // If the PutVal has value of EofVal the function should "fail", but this is
+  // the same transition as the success state.
+  // FIXME: Is it possible that StateFailed == StateNotFailed ?
+  ProgramStateRef StateFailed = bindInt(*EofVal, State, C, CE);
+  StreamState NewSS = StreamState::getOpened(Desc);
+  StateFailed = StateFailed->set(StreamSym, NewSS);
+  C.addTransition(StateFailed);
+}
+
 void StreamChecker::preFseek(const 

[clang] 26993f6 - Revert "[clang-format] Optimize processing .clang-format-ignore files (#76733)"

2024-01-04 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2024-01-04T10:47:51+01:00
New Revision: 26993f61673e3d9b29785f9baa5bac50c09f8bcf

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

LOG: Revert "[clang-format] Optimize processing .clang-format-ignore files 
(#76733)"

This reverts commit 42ec976184acd40436acd7104ad715c60ca3e7ed.

Reason: Broke the sanitizer buildbots. See more information on the
github comment thread at
https://github.com/llvm/llvm-project/commit/42ec976184acd40436acd7104ad715c60ca3e7ed

Added: 


Modified: 
clang/docs/ClangFormat.rst
clang/test/Format/clang-format-ignore.cpp
clang/tools/clang-format/ClangFormat.cpp

Removed: 




diff  --git a/clang/docs/ClangFormat.rst b/clang/docs/ClangFormat.rst
index 819d9ee9f9cde1..8d4017b29fb8ee 100644
--- a/clang/docs/ClangFormat.rst
+++ b/clang/docs/ClangFormat.rst
@@ -131,9 +131,6 @@ An easy way to create the ``.clang-format`` file is:
 
 Available style options are described in :doc:`ClangFormatStyleOptions`.
 
-.clang-format-ignore
-
-
 You can create ``.clang-format-ignore`` files to make ``clang-format`` ignore
 certain files. A ``.clang-format-ignore`` file consists of patterns of file 
path
 names. It has the following format:
@@ -144,8 +141,7 @@ names. It has the following format:
 * A non-comment line is a single pattern.
 * The slash (``/``) is used as the directory separator.
 * A pattern is relative to the directory of the ``.clang-format-ignore`` file
-  (or the root directory if the pattern starts with a slash). Patterns
-  containing drive names (e.g. ``C:``) are not supported.
+  (or the root directory if the pattern starts with a slash).
 * Patterns follow the rules specified in `POSIX 2.13.1, 2.13.2, and Rule 1 of
   2.13.3 `_.

diff  --git a/clang/test/Format/clang-format-ignore.cpp 
b/clang/test/Format/clang-format-ignore.cpp
index 5a2267b302d22f..0d6396a64a668d 100644
--- a/clang/test/Format/clang-format-ignore.cpp
+++ b/clang/test/Format/clang-format-ignore.cpp
@@ -21,26 +21,13 @@
 
 // RUN: touch .clang-format-ignore
 // RUN: clang-format -verbose foo.c foo.js 2> %t.stderr
-// RUN: grep -Fx "Formatting [1/2] foo.c" %t.stderr
-// RUN: grep -Fx "Formatting [2/2] foo.js" %t.stderr
+// RUN: grep "Formatting \[1/2] foo.c" %t.stderr
+// RUN: grep "Formatting \[2/2] foo.js" %t.stderr
 
 // RUN: echo "*.js" > .clang-format-ignore
 // RUN: clang-format -verbose foo.c foo.js 2> %t.stderr
-// RUN: grep -Fx "Formatting [1/2] foo.c" %t.stderr
-// RUN: not grep -F foo.js %t.stderr
+// RUN: grep "Formatting \[1/2] foo.c" %t.stderr
+// RUN: not grep "Formatting \[2/2] foo.js" %t.stderr
 
-// RUN: cd ../..
-// RUN: clang-format -verbose *.cc level1/*.c* level1/level2/foo.* 2> %t.stderr
-// RUN: grep -x "Formatting \[1/5] .*foo\.c" %t.stderr
-// RUN: not grep -F foo.js %t.stderr
-
-// RUN: rm .clang-format-ignore
-// RUN: clang-format -verbose *.cc level1/*.c* level1/level2/foo.* 2> %t.stderr
-// RUN: grep -x "Formatting \[1/5] .*foo\.cc" %t.stderr
-// RUN: grep -x "Formatting \[2/5] .*bar\.cc" %t.stderr
-// RUN: grep -x "Formatting \[3/5] .*baz\.c" %t.stderr
-// RUN: grep -x "Formatting \[4/5] .*foo\.c" %t.stderr
-// RUN: not grep -F foo.js %t.stderr
-
-// RUN: cd ..
-// RUN: rm -r %t.dir
+// RUN: cd ../../..
+// RUN: rm -rf %t.dir

diff  --git a/clang/tools/clang-format/ClangFormat.cpp 
b/clang/tools/clang-format/ClangFormat.cpp
index 787e56a6eccc0e..be34dbbe886a15 100644
--- a/clang/tools/clang-format/ClangFormat.cpp
+++ b/clang/tools/clang-format/ClangFormat.cpp
@@ -571,11 +571,6 @@ static int dumpConfig(bool IsSTDIN) {
   return 0;
 }
 
-using String = SmallString<128>;
-static String IgnoreDir; // Directory of .clang-format-ignore file.
-static StringRef PrevDir;// Directory of previous `FilePath`.
-static SmallVector Patterns; // Patterns in .clang-format-ignore file.
-
 // Check whether `FilePath` is ignored according to the nearest
 // .clang-format-ignore file based on the rules below:
 // - A blank line is skipped.
@@ -591,50 +586,33 @@ static bool isIgnored(StringRef FilePath) {
   if (!is_regular_file(FilePath))
 return false;
 
-  String Path;
-  String AbsPath{FilePath};
-
   using namespace llvm::sys::path;
+  SmallString<128> Path, AbsPath{FilePath};
+
   make_absolute(AbsPath);
   remove_dots(AbsPath, /*remove_dot_dot=*/true);
 
-  if (StringRef Dir{parent_path(AbsPath)}; PrevDir != Dir) {
-PrevDir = Dir;
-
-for (;;) {
-  Path = Dir;
-  append(Path, ".clang-format-ignore");
-  if (is_regular_file(Path))
-break;
-  Dir = parent_path(Dir);
-  if (Dir.empty())
-return false;
-}
-
-IgnoreDir = convert_to_slash(Dir);
-
-

[clang] d1fb930 - Revert "[AMDGPU] const-fold imm operands of amdgcn_update_dpp intrinsic (#71139)"

2023-11-08 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2023-11-08T12:50:53+01:00
New Revision: d1fb9307951319eea3e869d78470341d603c8363

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

LOG: Revert "[AMDGPU] const-fold imm operands of amdgcn_update_dpp intrinsic 
(#71139)"

This reverts commit 32a3f2afe6ea7ffb02a6a188b123ded6f4c89f6c.

Reason: Broke the sanitizer buildbots. More details at
https://github.com/llvm/llvm-project/commit/32a3f2afe6ea7ffb02a6a188b123ded6f4c89f6c

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 
clang/test/CodeGenHIP/dpp-const-fold.hip



diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index e7e498e8a933131..5ab81cc605819c3 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -5708,7 +5708,18 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 llvm::FunctionType *FTy = F->getFunctionType();
 
 for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
-  Value *ArgValue = EmitScalarOrConstFoldImmArg(ICEArguments, i, E);
+  Value *ArgValue;
+  // If this is a normal argument, just emit it as a scalar.
+  if ((ICEArguments & (1 << i)) == 0) {
+ArgValue = EmitScalarExpr(E->getArg(i));
+  } else {
+// If this is required to be a constant, constant fold it so that we
+// know that the generated intrinsic gets a ConstantInt.
+ArgValue = llvm::ConstantInt::get(
+getLLVMContext(),
+*E->getArg(i)->getIntegerConstantExpr(getContext()));
+  }
+
   // If the intrinsic arg type is 
diff erent from the builtin arg type
   // we need to do a bit cast.
   llvm::Type *PTy = FTy->getParamType(i);
@@ -8588,7 +8599,15 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned 
BuiltinID,
   }
 }
 
-Ops.push_back(EmitScalarOrConstFoldImmArg(ICEArguments, i, E));
+if ((ICEArguments & (1 << i)) == 0) {
+  Ops.push_back(EmitScalarExpr(E->getArg(i)));
+} else {
+  // If this is required to be a constant, constant fold it so that we know
+  // that the generated intrinsic gets a ConstantInt.
+  Ops.push_back(llvm::ConstantInt::get(
+  getLLVMContext(),
+  *E->getArg(i)->getIntegerConstantExpr(getContext(;
+}
   }
 
   switch (BuiltinID) {
@@ -11075,7 +11094,15 @@ Value 
*CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
 continue;
   }
 }
-Ops.push_back(EmitScalarOrConstFoldImmArg(ICEArguments, i, E));
+if ((ICEArguments & (1 << i)) == 0) {
+  Ops.push_back(EmitScalarExpr(E->getArg(i)));
+} else {
+  // If this is required to be a constant, constant fold it so that we know
+  // that the generated intrinsic gets a ConstantInt.
+  Ops.push_back(llvm::ConstantInt::get(
+  getLLVMContext(),
+  *E->getArg(i)->getIntegerConstantExpr(getContext(;
+}
   }
 
   auto SISDMap = ArrayRef(AArch64SISDIntrinsicMap);
@@ -13787,7 +13814,16 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
   assert(Error == ASTContext::GE_None && "Should not codegen an error");
 
   for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) {
-Ops.push_back(EmitScalarOrConstFoldImmArg(ICEArguments, i, E));
+// If this is a normal argument, just emit it as a scalar.
+if ((ICEArguments & (1 << i)) == 0) {
+  Ops.push_back(EmitScalarExpr(E->getArg(i)));
+  continue;
+}
+
+// If this is required to be a constant, constant fold it so that we know
+// that the generated intrinsic gets a ConstantInt.
+Ops.push_back(llvm::ConstantInt::get(
+getLLVMContext(), 
*E->getArg(i)->getIntegerConstantExpr(getContext(;
   }
 
   // These exist so that the builtin that takes an immediate can be bounds
@@ -17552,23 +17588,6 @@ void CodeGenFunction::ProcessOrderScopeAMDGCN(Value 
*Order, Value *Scope,
   SSID = getLLVMContext().getOrInsertSyncScopeID(scp);
 }
 
-llvm::Value *CodeGenFunction::EmitScalarOrConstFoldImmArg(unsigned 
ICEArguments,
-  unsigned Idx,
-  const CallExpr *E) {
-  llvm::Value *Arg = nullptr;
-  if ((ICEArguments & (1 << Idx)) == 0) {
-Arg = EmitScalarExpr(E->getArg(Idx));
-  } else {
-// If this is required to be a constant, constant fold it so that we
-// know that the generated intrinsic gets a ConstantInt.
-std::optional Result =
-E->getArg(Idx)->getIntegerConstantExpr(getContext());
-assert(Result && "Expected argument to be a constant");
-Arg = llvm::ConstantInt::get(getLLVMContext(), *Result);
-  }
-  return Arg;
-}
-
 Value 

[clang] a141a9f - Revert "[OpenMP] atomic compare fail : Parser & AST support"

2023-11-08 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2023-11-08T11:20:17+01:00
New Revision: a141a9fa9706e939415a929a46b6f2f77cd56c55

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

LOG: Revert "[OpenMP] atomic compare fail : Parser & AST support"

This reverts commit 086b65340cca2648a2a91a0a47d28c7d9bafd1e5.

Reason: Broke under -Werror. More details in
https://reviews.llvm.org/D123235

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/atomic_ast_print.cpp
clang/test/OpenMP/atomic_messages.cpp
clang/tools/libclang/CIndex.cpp
flang/lib/Semantics/check-omp-structure.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index f7ecffe6154af80..549f12e87df597a 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -2513,104 +2513,6 @@ class OMPRelaxedClause final : public OMPClause {
   }
 };
 
-/// This represents 'fail' clause in the '#pragma omp atomic'
-/// directive.
-///
-/// \code
-/// #pragma omp atomic compare fail
-/// \endcode
-/// In this example directive '#pragma omp atomic compare' has 'fail' clause.
-class OMPFailClause final : public OMPClause {
-
-  // FailParameter is a memory-order-clause. Storing the ClauseKind is
-  // sufficient for our purpose.
-  OpenMPClauseKind FailParameter = llvm::omp::Clause::OMPC_unknown;
-  SourceLocation FailParameterLoc;
-  SourceLocation LParenLoc;
-
-  friend class OMPClauseReader;
-
-  /// Sets the location of '(' in fail clause.
-  void setLParenLoc(SourceLocation Loc) {
-LParenLoc = Loc;
-  }
-
-  /// Sets the location of memoryOrder clause argument in fail clause.
-  void setFailParameterLoc(SourceLocation Loc) { FailParameterLoc = Loc; }
-
-  /// Sets the mem_order clause for 'atomic compare fail' directive.
-  void setFailParameter(OpenMPClauseKind FailParameter) {
-switch (FailParameter) {
-case llvm::omp::OMPC_acq_rel:
-case llvm::omp::OMPC_acquire:
-  this->FailParameter = llvm::omp::OMPC_acquire;
-  break;
-case llvm::omp::OMPC_relaxed:
-case llvm::omp::OMPC_release:
-  this->FailParameter = llvm::omp::OMPC_relaxed;
-  break;
-case llvm::omp::OMPC_seq_cst:
-  this->FailParameter = llvm::omp::OMPC_seq_cst;
-  break;
-default:
-  this->FailParameter = llvm::omp::OMPC_unknown;
-  break;
-}
-  }
-
-public:
-  /// Build 'fail' clause.
-  ///
-  /// \param StartLoc Starting location of the clause.
-  /// \param EndLoc Ending location of the clause.
-  OMPFailClause(SourceLocation StartLoc, SourceLocation EndLoc)
-  : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc) {}
-
-  OMPFailClause(OpenMPClauseKind FailParameter, SourceLocation 
FailParameterLoc,
-SourceLocation StartLoc, SourceLocation LParenLoc,
-SourceLocation EndLoc)
-  : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc),
-FailParameterLoc(FailParameterLoc), LParenLoc(LParenLoc) {
-
-setFailParameter(FailParameter);
-  }
-
-  /// Build an empty clause.
-  OMPFailClause()
-  : OMPClause(llvm::omp::OMPC_fail, SourceLocation(), SourceLocation()) {}
-
-  child_range children() {
-return child_range(child_iterator(), child_iterator());
-  }
-
-  const_child_range children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
-  }
-
-  child_range used_children() {
-return child_range(child_iterator(), child_iterator());
-  }
-  const_child_range used_children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
-  }
-
-  static bool classof(const OMPClause *T) {
-return T->getClauseKind() == llvm::omp::OMPC_fail;
-  }
-
-  /// Gets the location of '(' (for the parameter) in fail clause.
-  SourceLocation getLParenLoc() const {
-return LParenLoc;
-  }
-
-  /// Gets the location of Fail Parameter (type memory-order-clause) in
-  /// fail clause.
-  SourceLocation getFailParameterLoc() const { return FailParameterLoc; }
-
-  /// Gets the parameter (type memory-order-clause) in Fail clause.
-  OpenMPClauseKind getFailParameter() const { return FailParameter; }
-};
-
 /// This represents 

[clang] [llvm] [ASAN] For Asan instrumented global, emit two symbols, one with actual size and other with instrumented size. (PR #70166)

2023-11-01 Thread Mitch Phillips via cfe-commits

hctim wrote:

Will wait for a rebase on some changes requested in #68865, but it'd also be 
really important to write tests for a couple more scenarios:

 1. Building with `-fsanitize=address -S -emit-llvm` results in GVs with 
`sanitized_padded_global` (and results in GVs without `sanitized_padded_global` 
if they have `__attribute__((no_sanitize("address")))` for example). See 
`clang/test/CodeGen/memtag-globals.cpp`.
 2. Running #1 through bitcode back/forth to make sure you still have the same 
attributes sets (to ensure you got the parser/writer logic correct). See 
`llvm/test/Bitcode/compatibility.ll` and 
`llvm/test/Assembler/globalvariable-attributes.ll`.


https://github.com/llvm/llvm-project/pull/70166
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [ASAN] For Asan instrumented global, emit two symbols, one with actual size and other with instrumented size. (PR #70166)

2023-11-01 Thread Mitch Phillips via cfe-commits

hctim wrote:

> > It's my understanding your problem is that you are asan-trapping on the 
> > redzones when you copy data to/from the device. Is it possible instead to 
> > just make those copy-from and copy-to functions in the runtime 
> > `__attribute__((no_sanitize("address")))` and copy the padding as well?
> 
> Yes it is possible, but it would result in bugs being hidden...the very bugs 
> that ASAN is meant to catch. This is not an acceptable option for us.

Only bugs in the `copy_from_` and `copy_to_` functions though (which should be 
pretty clear)?

--

Alright, let's give this a crack. I'll leave some comments here and on #68865, 
but let's not worry about potential unknown problems and we can see what shakes 
out once we actually submit the patches.

https://github.com/llvm/llvm-project/pull/70166
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Disable memtag sanitization for global fnptrs going into .ctors (PR #70186)

2023-11-01 Thread Mitch Phillips via cfe-commits

https://github.com/hctim closed https://github.com/llvm/llvm-project/pull/70186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ASAN] For Asan instrumented global, emit two symbols, one with actual size and other with instrumented size. (PR #70166)

2023-10-27 Thread Mitch Phillips via cfe-commits

hctim wrote:

I talked with some folks internally and we came to the consensus that this'll 
almost certainly break some debugging tools and such, it probably won't effect 
the runtime of binaries, but I wouldn't say that this is a super 
confidence-inspiring thing to do.

> AMD language runtimes provide queries for the size of device global symbols 
> and functions to copy data to and from device global variables. Runtime gets 
> the needed information form the ELF symbol table. So, when it querires the 
> size of device global variable, it gets the padded size rather than actual 
> size.

It's my understanding your problem is that you are asan-trapping on the 
redzones when you copy data to/from the device. Is it possible instead to just 
make those copy-from and copy-to functions in the runtime 
`__attribute__((no_sanitize("address")))` and copy the padding as well?

https://github.com/llvm/llvm-project/pull/70166
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Disable memtag sanitization for global fnptrs going into .ctors (PR #70186)

2023-10-27 Thread Mitch Phillips via cfe-commits

hctim wrote:

(friendly ping @eugenis / @vitalybuka)

https://github.com/llvm/llvm-project/pull/70186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Disable memtag sanitization for global fnptrs going into .ctors (PR #70186)

2023-10-25 Thread Mitch Phillips via cfe-commits

hctim wrote:

@P1119r1m

https://github.com/llvm/llvm-project/pull/70186
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Disable memtag sanitization for global fnptrs going into .ctors (PR #70186)

2023-10-25 Thread Mitch Phillips via cfe-commits

https://github.com/hctim created https://github.com/llvm/llvm-project/pull/70186

Looks like there's code out there that, instead of using
'__attribute__((constructor(x)))' to add constructor functions, they
just declare a global function pointer and use
'__attribute__((section('.ctors')))' instead.

Problem is, with memtag-globals, we pad the global function pointer to
be 16 bytes large. This of course means we have an 8-byte real function
pointer, then 8 bytes of zero padding, and this trips up the loader when
it processes this section.

Fixes #69939


>From f70a2dba661163a436c40e9e8f97cd9a27a726ca Mon Sep 17 00:00:00 2001
From: Mitch Phillips 
Date: Wed, 25 Oct 2023 11:35:29 +0200
Subject: [PATCH] Disable memtag sanitization for global fnptrs going into
 .ctors

Looks like there's code out there that, instead of using
'__attribute__((constructor(x)))' to add constructor functions, they
just declare a global function pointer and use
'__attribute__((section('.ctors')))' instead.

Problem is, with memtag-globals, we pad the global function pointer to
be 16 bytes large. This of course means we have an 8-byte real function
pointer, then 8 bytes of zero padding, and this trips up the loader when
it processes this section.

Fixes #69939
---
 clang/test/CodeGen/memtag-globals-asm.cpp | 20 +++
 .../Target/AArch64/AArch64GlobalsTagging.cpp  | 12 +++
 2 files changed, 32 insertions(+)

diff --git a/clang/test/CodeGen/memtag-globals-asm.cpp 
b/clang/test/CodeGen/memtag-globals-asm.cpp
index 3f18671562def71..4b76b394e0c1dc3 100644
--- a/clang/test/CodeGen/memtag-globals-asm.cpp
+++ b/clang/test/CodeGen/memtag-globals-asm.cpp
@@ -259,3 +259,23 @@ int f(int x) {
   // CHECK-Q-DAG: ldr   {{.*}}, [[[REG_O2]]]
   function_int;
 }
+
+typedef void (*func_t)(void);
+#define CONSTRUCTOR(section_name) \
+  __attribute__((used)) __attribute__((section(section_name)))
+
+__attribute__((constructor(0))) void func_constructor() {}
+CONSTRUCTOR(".init") func_t func_init = func_constructor;
+CONSTRUCTOR(".fini") func_t func_fini = func_constructor;
+CONSTRUCTOR(".ctors") func_t func_ctors = func_constructor;
+CONSTRUCTOR(".dtors") func_t func_dtors = func_constructor;
+CONSTRUCTOR(".init_array") func_t func_init_array = func_constructor;
+CONSTRUCTOR(".fini_array") func_t func_fini_array = func_constructor;
+
+// CHECK-NOT: .memtag func_constructor
+// CHECK-NOT: .memtag func_init
+// CHECK-NOT: .memtag func_fini
+// CHECK-NOT: .memtag func_ctors
+// CHECK-NOT: .memtag func_dtors
+// CHECK-NOT: .memtag func_init_array
+// CHECK-NOT: .memtag func_fini_array
diff --git a/llvm/lib/Target/AArch64/AArch64GlobalsTagging.cpp 
b/llvm/lib/Target/AArch64/AArch64GlobalsTagging.cpp
index 2ed668712897ce7..88e44eb0bfbb99f 100644
--- a/llvm/lib/Target/AArch64/AArch64GlobalsTagging.cpp
+++ b/llvm/lib/Target/AArch64/AArch64GlobalsTagging.cpp
@@ -43,6 +43,18 @@ static bool shouldTagGlobal(GlobalVariable ) {
 return false;
   }
 
+  // Don't instrument function pointers that are going into various init arrays
+  // via `__attribute__((section()))`:
+  // https://github.com/llvm/llvm-project/issues/69939
+  if (G.hasSection() &&
+  (G.getSection() == ".init" || G.getSection() == ".fini" ||
+   G.getSection() == ".init_array" || G.getSection() == ".fini_array" ||
+   G.getSection() == ".ctors" || G.getSection() == ".dtors")) {
+Meta.Memtag = false;
+G.setSanitizerMetadata(Meta);
+return false;
+  }
+
   return true;
 }
 

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


[clang] [ASAN] Adjust asan instrumented GlobalVariable size to not include redzone (PR #66666)

2023-10-13 Thread Mitch Phillips via cfe-commits

hctim wrote:

My assumption is that you have some driver code or preloaded DSO that 
effectively implements `copy_to_amdgpu`, which would do something with the 
symtab.

Can you just make your driver not be asan-ified (either by not building it with 
`-fsanitize=address` or using `__attribute__((no_sanitize("address")))` on the 
`copy_to_amdgpu` function? Then you'd copy the right quantity of data, and the 
access of the redzone would be ignored as there's no instrumentation there.

This seems like a more appropriate thing than making `st_other` symtab entries 
not actually the right size.

https://github.com/llvm/llvm-project/pull/6
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ASAN] Adjust asan instrumented GlobalVariable size to not include redzone (PR #66666)

2023-10-12 Thread Mitch Phillips via cfe-commits

hctim wrote:

My gut feeling is that it's a really bad idea to have a global variable whose 
symtab size differs from the underlying GV size. So I tested against lld, gold, 
and ld, and they all seem to end up with `int`-typed GVs having a filesize of 
32 bytes and an ELF `st_size` of 4 bytes, and the runtime seems okay, but I 
think this breaks ELF rules:

https://docs.oracle.com/cd/E19683-01/816-1386/chapter6-79797/index.html#:~:text=Symbol%20Values%22.-,st_size,-Many%20symbols%20have

> st_size: Many symbols have associated sizes. For example, a data object's 
> size is the number of bytes contained in the object. This member holds 0 if 
> the symbol has no size or an unknown size.

I suspect this could break relinkers and various other things.

It doesn't seem clear to me *why* amdgpu has problems with copying the extra 
redzone padding. We may also actually use the redzone for metadata and would 
expect that it would be consistent.

https://github.com/llvm/llvm-project/pull/6
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ASAN] Adjust asan instrumented GlobalVariable size to not include redzone (PR #66666)

2023-09-28 Thread Mitch Phillips via cfe-commits

hctim wrote:

> > Yeah, `clang/test/CodeGen/memtag-globals-asm.cpp` is for MTE Globals, not 
> > ASan - and the sizes of the GVs should be multiple-of-16 bytes: 
> > https://github.com/ARM-software/abi-aa/blob/main/memtagabielf64/memtagabielf64.rst#compilation
> > What problem are you trying to solve here?
> 
> ASAN pass identifies the global variables that needs to be instrumented and 
> replaces them with new globals with size equal to actual size + redzone size. 
> To identify such instrumented global variables, added SanitizerMetadata to 
> the new global, which will have NoAddress set to false(which implies asan 
> instrumented global). At asm printer stage, such gloabal would be identified 
> and actual value without redzone size would be emitted.
> 
> This change was done under assumption that any target would only want the 
> actual size of global in the elf and not the padded size. AMDGPU needs this 
> change. Please let me know if it causes issue with other targets?

Under MTE globals (not asan, but the test you're changing in 
memtag-globals-asm.cpp), there are no redzones - the round-to-16-byte size is 
what we want to be in the ELF.

Copying the sanitizer metadata over seems fine, but reusing `NoAddress` as an 
identifier that this is a sanitizer-instrumented GV is wrong. Other GVs that 
are explicitly not asan-ified (e.g. by using the 
`__attribute__((no_sanitize("address")))` attribute) end up with the same 
attribute.

Also, to the premise, _why_ is ANDGPU unhappy about having the sizeof(GV) == 
global+redzone in the ELF?

https://github.com/llvm/llvm-project/pull/6
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ASAN] Adjust asan instrumented GlobalVariable size to not include redzone (PR #66666)

2023-09-28 Thread Mitch Phillips via cfe-commits

https://github.com/hctim requested changes to this pull request.

Yeah, `clang/test/CodeGen/memtag-globals-asm.cpp` is for MTE Globals, not ASan 
- and the sizes of the GVs should be multiple-of-16 bytes: 
https://github.com/ARM-software/abi-aa/blob/main/memtagabielf64/memtagabielf64.rst#compilation

What problem are you trying to solve here?

https://github.com/llvm/llvm-project/pull/6
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AArch64]: Refactor target parser to use Bitset. (PR #65423)

2023-09-12 Thread Mitch Phillips via cfe-commits

hctim wrote:

Looks like this is causing problems:

https://lab.llvm.org/buildbot/#/builders/18/builds/10698

```
FAILED: 
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/AArch64.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /bin/ccache 
/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm_build0/bin/clang++
 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D_LIBCPP_ENABLE_HARDENED_MODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS 
-I/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm_build64/tools/clang/lib/Basic
 
-I/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm-project/clang/lib/Basic
 
-I/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm-project/clang/include
 
-I/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm_build64/tools/clang/include
 
-I/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm_build64/include
 
-I/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm-project/llvm/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti 
-UNDEBUG -std=c++17 -MD -MT 
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/AArch64.cpp.o -MF 
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/AArch64.cpp.o.d -o 
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/AArch64.cpp.o -c 
/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm-project/clang/lib/Basic/Targets/AArch64.cpp
In file included from 
/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm-project/clang/lib/Basic/Targets/AArch64.cpp:13:
In file included from 
/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm-project/clang/lib/Basic/Targets/AArch64.h:18:
/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm-project/llvm/include/llvm/TargetParser/AArch64TargetParser.h:350:91:
 error: 'Bitset' may not intend to support class template argument deduction 
[-Werror,-Wctad-maybe-unsupported]
inline constexpr ArchInfo ARMV8R= { VersionTuple{8, 0}, RProfile, 
"armv8-r", "+v8r", (Bitset(ARMV8_5A.DefaultExts) |

  ^
/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm-project/llvm/include/llvm/ADT/Bitset.h:31:7:
 note: add a deduction guide to suppress this warning
class Bitset {
  ^
/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm-project/clang/lib/Basic/Targets/AArch64.cpp:982:5:
 error: 'Bitset' may not intend to support class template argument deduction 
[-Werror,-Wctad-maybe-unsupported]
llvm::Bitset Exts = CpuInfo->getImpliedExtensions();
^
/home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm-project/llvm/include/llvm/ADT/Bitset.h:31:7:
 note: add a deduction guide to suppress this warning
class Bitset {
  ^
2 errors generated.
```

I'm gonna go out on a limb and say this is probably not sanitizer-bot-specific 
:)

https://github.com/llvm/llvm-project/pull/65423
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3be6c4d - Revert "Revert "Revert ExtractAPI from https://reviews.llvm.org/D146656""

2023-03-29 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2023-03-29T11:39:44-07:00
New Revision: 3be6c4d413f6ccabdcc8205ce73970bf3df162d3

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

LOG: Revert "Revert "Revert ExtractAPI from https://reviews.llvm.org/D146656";

This reverts commit 79116475124112051625b1a0665e35c861bb13fd.

Broke the ASan bots. See more information in
https://reviews.llvm.org/rG79116475124112051625b1a0665e35c861bb13fd

Added: 
clang/lib/ExtractAPI/ExtractAPIVisitor.cpp
clang/lib/ExtractAPI/TypedefUnderlyingTypeResolver.h

Modified: 
clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
clang/lib/ExtractAPI/CMakeLists.txt
clang/lib/ExtractAPI/DeclarationFragments.cpp
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
clang/lib/ExtractAPI/TypedefUnderlyingTypeResolver.cpp
clang/test/Index/extract-api-cursor.m
clang/tools/c-index-test/c-index-test.c
clang/tools/libclang/CXExtractAPI.cpp

Removed: 
clang/include/clang/ExtractAPI/TypedefUnderlyingTypeResolver.h



diff  --git a/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h 
b/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
index a31648b80195a..f6546fb4776a6 100644
--- a/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
+++ b/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
@@ -14,27 +14,24 @@
 #ifndef LLVM_CLANG_EXTRACTAPI_EXTRACT_API_VISITOR_H
 #define LLVM_CLANG_EXTRACTAPI_EXTRACT_API_VISITOR_H
 
-#include "llvm/ADT/FunctionExtras.h"
-
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/ParentMapContext.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/ExtractAPI/API.h"
-#include "clang/ExtractAPI/TypedefUnderlyingTypeResolver.h"
-#include 
+#include "llvm/ADT/FunctionExtras.h"
 
 namespace clang {
 namespace extractapi {
-namespace impl {
-
-template 
-class ExtractAPIVisitorBase : public RecursiveASTVisitor {
-protected:
-  ExtractAPIVisitorBase(ASTContext , APISet )
-  : Context(Context), API(API) {}
 
+/// The RecursiveASTVisitor to traverse symbol declarations and collect API
+/// information.
+class ExtractAPIVisitor : public RecursiveASTVisitor {
 public:
+  ExtractAPIVisitor(ASTContext ,
+llvm::unique_function 
LocationChecker,
+APISet )
+  : Context(Context), API(API),
+LocationChecker(std::move(LocationChecker)) {}
+
   const APISet () const { return API; }
 
   bool VisitVarDecl(const VarDecl *Decl);
@@ -53,11 +50,7 @@ class ExtractAPIVisitorBase : public 
RecursiveASTVisitor {
 
   bool VisitObjCCategoryDecl(const ObjCCategoryDecl *Decl);
 
-  bool shouldDeclBeIncluded(const Decl *Decl) const;
-
-  const RawComment *fetchRawCommentForDecl(const Decl *Decl) const;
-
-protected:
+private:
   /// Collect API information for the enum constants and associate with the
   /// parent enum.
   void recordEnumConstants(EnumRecord *EnumRecord,
@@ -84,582 +77,9 @@ class ExtractAPIVisitorBase : public 
RecursiveASTVisitor {
 
   void recordObjCProtocols(ObjCContainerRecord *Container,
ObjCInterfaceDecl::protocol_range Protocols);
-
   ASTContext 
   APISet 
-
-  StringRef getTypedefName(const TagDecl *Decl) {
-if (const auto *TypedefDecl = Decl->getTypedefNameForAnonDecl())
-  return TypedefDecl->getName();
-
-return {};
-  }
-
-  bool isInSystemHeader(const Decl *D) {
-return Context.getSourceManager().isInSystemHeader(D->getLocation());
-  }
-
-private:
-  Derived () {
-return *static_cast(this);
-  }
-};
-
-template 
-bool ExtractAPIVisitorBase::VisitVarDecl(const VarDecl *Decl) {
-  // skip function parameters.
-  if (isa(Decl))
-return true;
-
-  // Skip non-global variables in records (struct/union/class).
-  if (Decl->getDeclContext()->isRecord())
-return true;
-
-  // Skip local variables inside function or method.
-  if (!Decl->isDefinedOutsideFunctionOrMethod())
-return true;
-
-  // If this is a template but not specialization or instantiation, skip.
-  if (Decl->getASTContext().getTemplateOrSpecializationInfo(Decl) &&
-  Decl->getTemplateSpecializationKind() == TSK_Undeclared)
-return true;
-
-  if (!getDerivedExtractAPIVisitor().shouldDeclBeIncluded(Decl))
-return true;
-
-  // Collect symbol information.
-  StringRef Name = Decl->getName();
-  StringRef USR = API.recordUSR(Decl);
-  PresumedLoc Loc =
-  Context.getSourceManager().getPresumedLoc(Decl->getLocation());
-  LinkageInfo Linkage = Decl->getLinkageAndVisibility();
-  DocComment Comment;
-  if (auto *RawComment =
-  getDerivedExtractAPIVisitor().fetchRawCommentForDecl(Decl))
-Comment = RawComment->getFormattedLines(Context.getSourceManager(),
-Context.getDiagnostics());
-
-  // Build 

[clang] 96f028c - Revert "[clang][ExtractAPI] Add queried symbol to parent contexts in libclang"

2023-03-29 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2023-03-29T11:39:32-07:00
New Revision: 96f028c0a2826c1fe13d126124692ba5470d227a

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

LOG: Revert "[clang][ExtractAPI] Add queried symbol to parent contexts in 
libclang"

This reverts commit 1cfe1e732ad8e8148f6fa8fc0f0c86f4b965d567.

Depends on reverted commit 158a431227a876306fe5838936413dd51588d0c6. See
https://reviews.llvm.org/rG79116475124112051625b1a0665e35c861bb13fd for
more information, this broke the ASan bots.

Added: 


Modified: 
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
clang/test/Index/extract-api-cursor.m
clang/test/Index/extract-api-usr.m

Removed: 




diff  --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp 
b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 7676c74af6869..8a98f5cf0c71f 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -547,6 +547,10 @@ Array generateParentContexts(const RecordTy , const 
APISet ,
serializeParentContext(PC, Lang));
  });
 
+  // The last component would be the record itself so let's remove it.
+  if (!ParentContexts.empty())
+ParentContexts.pop_back();
+
   return ParentContexts;
 }
 

diff  --git a/clang/test/Index/extract-api-cursor.m 
b/clang/test/Index/extract-api-cursor.m
index 1b27b6f61437b..16844ca1674ee 100644
--- a/clang/test/Index/extract-api-cursor.m
+++ b/clang/test/Index/extract-api-cursor.m
@@ -34,7 +34,7 @@ - (void)derivedMethodWithValue:(id)value {
 @end
 
 // RUN: c-index-test -single-symbol-sgf-at=%s:4:9 local %s | FileCheck 
-check-prefix=CHECK-FOO %s
-// CHECK-FOO: 
"parentContexts":[{"kind":"objective-c.struct","name":"Foo","usr":"c:@S@Foo"}]
+// CHECK-FOO: "parentContexts":[]
 // CHECK-FOO: "relatedSymbols":[]
 // CHECK-FOO: "relationships":[]
 // CHECK-FOO: "text":"Foo docs"
@@ -42,7 +42,7 @@ - (void)derivedMethodWithValue:(id)value {
 // CHECK-FOO: "title":"Foo"
 
 // RUN: c-index-test -single-symbol-sgf-at=%s:6:9 local %s | FileCheck 
-check-prefix=CHECK-BAR %s
-// CHECK-BAR: 
"parentContexts":[{"kind":"objective-c.struct","name":"Foo","usr":"c:@S@Foo"},{"kind":"objective-c.property","name":"bar","usr":"c:@S@Foo@FI@bar"}]
+// CHECK-BAR: 
"parentContexts":[{"kind":"objective-c.struct","name":"Foo","usr":"c:@S@Foo"}]
 // CHECK-BAR: "relatedSymbols":[]
 // CHECK-BAR: 
"relationships":[{"kind":"memberOf","source":"c:@S@Foo@FI@bar","target":"c:@S@Foo"
 // CHECK-BAR: "text":"Bar docs"
@@ -50,7 +50,7 @@ - (void)derivedMethodWithValue:(id)value {
 // CHECK-BAR: "title":"bar"
 
 // RUN: c-index-test -single-symbol-sgf-at=%s:10:11 local %s | FileCheck 
-check-prefix=CHECK-BASE %s
-// CHECK-BASE: 
"parentContexts":[{"kind":"objective-c.class","name":"Base","usr":"c:objc(cs)Base"}]
+// CHECK-BASE: "parentContexts":[]
 // CHECK-BASE: "relatedSymbols":[]
 // CHECK-BASE: "relationships":[]
 // CHECK-BASE: "text":"Base docs"
@@ -58,7 +58,7 @@ - (void)derivedMethodWithValue:(id)value {
 // CHECK-BASE: "title":"Base"
 
 // RUN: c-index-test -single-symbol-sgf-at=%s:12:25 local %s | FileCheck 
-check-prefix=CHECK-BASE-PROP %s
-// CHECK-BASE-PROP: 
"parentContexts":[{"kind":"objective-c.class","name":"Base","usr":"c:objc(cs)Base"},{"kind":"objective-c.property","name":"baseProperty","usr":"c:objc(cs)Base(py)baseProperty"}]
+// CHECK-BASE-PROP: 
"parentContexts":[{"kind":"objective-c.class","name":"Base","usr":"c:objc(cs)Base"}]
 // CHECK-BASE-PROP: 
"relatedSymbols":[{"accessLevel":"public","declarationLanguage":"objective-c"
 // CHECK-BASE-PROP: "isSystem":false
 // CHECK-BASE-PROP: "usr":"c:@S@Foo"}]
@@ -68,7 +68,7 @@ - (void)derivedMethodWithValue:(id)value {
 // CHECK-BASE-PROP: "title":"baseProperty"
 
 // RUN: c-index-test -single-symbol-sgf-at=%s:15:9 local %s | FileCheck 
-check-prefix=CHECK-BASE-METHOD %s
-// CHECK-BASE-METHOD: 
"parentContexts":[{"kind":"objective-c.class","name":"Base","usr":"c:objc(cs)Base"},{"kind":"objective-c.method","name":"baseMethodWithArg:","usr":"c:objc(cs)Base(im)baseMethodWithArg:"}]
+// CHECK-BASE-METHOD: 
"parentContexts":[{"kind":"objective-c.class","name":"Base","usr":"c:objc(cs)Base"}]
 // CHECK-BASE-METHOD: "relatedSymbols":[]
 // CHECK-BASE-METHOD: 
"relationships":[{"kind":"memberOf","source":"c:objc(cs)Base(im)baseMethodWithArg:","target":"c:objc(cs)Base"
 // CHECK-BASE-METHOD: "text":"Base method docs"
@@ -76,7 +76,7 @@ - (void)derivedMethodWithValue:(id)value {
 // CHECK-BASE-METHOD: "title":"baseMethodWithArg:"
 
 // RUN: c-index-test -single-symbol-sgf-at=%s:19:11 local %s | FileCheck 
-check-prefix=CHECK-PROTOCOL %s
-// CHECK-PROTOCOL: 

[clang] 074f6fd - Revert "[C++20][Modules] Introduce an implementation module."

2023-03-27 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2023-03-27T05:01:53-07:00
New Revision: 074f6fd61d382ff6bf108472ea701d214b02f64b

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

LOG: Revert "[C++20][Modules] Introduce an implementation module."

This reverts commit c6e9823724ef6bdfee262289ee34d162db436af0.

Reason: Broke the ASan buildbots, see https://reviews.llvm.org/D126959
(the original phabricator review) for more info.

Added: 


Modified: 
clang/include/clang/Basic/Module.h
clang/include/clang/Lex/ModuleMap.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/Decl.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Lex/ModuleMap.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaModule.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/CXX/module/basic/basic.def.odr/p4.cppm
clang/test/CXX/module/basic/basic.link/p2.cppm
clang/test/CodeGenCXX/module-intializer.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index c0c99eb8b6d62..387ce4d6e9b17 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -103,22 +103,16 @@ class alignas(8) Module {
   /// The location of the module definition.
   SourceLocation DefinitionLoc;
 
-  // FIXME: Consider if reducing the size of this enum (having Partition and
-  // Named modules only) then representing interface/implementation separately
-  // is more efficient.
   enum ModuleKind {
 /// This is a module that was defined by a module map and built out
 /// of header files.
 ModuleMapModule,
 
-/// This is a C++ 20 header unit.
-ModuleHeaderUnit,
-
 /// This is a C++20 module interface unit.
 ModuleInterfaceUnit,
 
-/// This is a C++20 module implementation unit.
-ModuleImplementationUnit,
+/// This is a C++ 20 header unit.
+ModuleHeaderUnit,
 
 /// This is a C++ 20 module partition interface.
 ModulePartitionInterface,
@@ -175,16 +169,9 @@ class alignas(8) Module {
   /// Does this Module scope describe part of the purview of a standard named
   /// C++ module?
   bool isModulePurview() const {
-switch (Kind) {
-case ModuleInterfaceUnit:
-case ModuleImplementationUnit:
-case ModulePartitionInterface:
-case ModulePartitionImplementation:
-case PrivateModuleFragment:
-  return true;
-default:
-  return false;
-}
+return Kind == ModuleInterfaceUnit || Kind == ModulePartitionInterface ||
+   Kind == ModulePartitionImplementation ||
+   Kind == PrivateModuleFragment;
   }
 
   /// Does this Module scope describe a fragment of the global module within
@@ -574,11 +561,6 @@ class alignas(8) Module {
Kind == ModulePartitionImplementation;
   }
 
-  /// Is this a module implementation.
-  bool isModuleImplementation() const {
-return Kind == ModuleImplementationUnit;
-  }
-
   /// Is this module a header unit.
   bool isHeaderUnit() const { return Kind == ModuleHeaderUnit; }
   // Is this a C++20 module interface or a partition.

diff  --git a/clang/include/clang/Lex/ModuleMap.h 
b/clang/include/clang/Lex/ModuleMap.h
index f155c609b06cb..a0ddd13c11bfd 100644
--- a/clang/include/clang/Lex/ModuleMap.h
+++ b/clang/include/clang/Lex/ModuleMap.h
@@ -560,11 +560,6 @@ class ModuleMap {
   Module *createPrivateModuleFragmentForInterfaceUnit(Module *Parent,
   SourceLocation Loc);
 
-  /// Create a new C++ module with the specified kind, and reparent any pending
-  /// global module fragment(s) to it.
-  Module *createModuleUnitWithKind(SourceLocation Loc, StringRef Name,
-   Module::ModuleKind Kind);
-
   /// Create a new module for a C++ module interface unit.
   /// The module must not already exist, and will be configured for the current
   /// compilation.
@@ -574,13 +569,6 @@ class ModuleMap {
   /// \returns The newly-created module.
   Module *createModuleForInterfaceUnit(SourceLocation Loc, StringRef Name);
 
-  /// Create a new module for a C++ module implementation unit.
-  /// The interface module for this implementation (implicitly imported) must
-  /// exist and be loaded and present in the modules map.
-  ///
-  /// \returns The newly-created module.
-  Module *createModuleForImplementationUnit(SourceLocation Loc, StringRef 
Name);
-
   /// Create a C++20 header unit.
   Module *createHeaderUnit(SourceLocation Loc, StringRef Name,
Module::Header H);

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 9f7d58a4a3cd6..92ca3772dbef8 100644
--- a/clang/include/clang/Sema/Sema.h
+++ 

[clang] 5ca710a - Revert "Silence unused variable warning in NDEBUG builds"

2023-03-27 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2023-03-27T05:01:53-07:00
New Revision: 5ca710ab148b0815c2b7b03fe2af643e637bbc7d

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

LOG: Revert "Silence unused variable warning in NDEBUG builds"

This reverts commit 8c7c1f11ffaacf762e612c65440fd2cbb58ee426.

Reason: Dependent change https://reviews.llvm.org/D126959 broke the ASan
buildbots. See that phabricator review for more comments.

Added: 


Modified: 
clang/lib/Lex/ModuleMap.cpp

Removed: 




diff  --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 44c872336ce9c..f2b2d0b8c69f1 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -936,7 +936,6 @@ Module 
*ModuleMap::createModuleForImplementationUnit(SourceLocation Loc,
   // Mark the main source file as being within the newly-created module so that
   // declarations and macros are properly visibility-restricted to it.
   auto *MainFile = SourceMgr.getFileEntryForID(SourceMgr.getMainFileID());
-  (void)MainFile;
   assert(MainFile && "no input file for module implementation");
 
   return Result;



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


[clang] b88ebb3 - Revert "Add CFI integer types normalization"

2023-02-02 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2023-02-02T15:48:50-08:00
New Revision: b88ebb3d94cbd2bdf6ffd17fa7c5559579a249a2

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

LOG: Revert "Add CFI integer types normalization"

This reverts commit b1e9ab7438a098a18fecda88fc87ef4ccadfcf1e.

Reason: Looks like it broke the MSan buildbot, more details in the
phabricator review: https://reviews.llvm.org/D139395

Added: 


Modified: 
clang/docs/ControlFlowIntegrity.rst
clang/docs/UsersManual.rst
clang/include/clang/AST/Mangle.h
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/include/clang/Driver/SanitizerArgs.h
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/SanitizerArgs.cpp

Removed: 
clang/test/CodeGen/cfi-icall-normalize.c
clang/test/CodeGen/cfi-icall-normalize2.c
clang/test/CodeGen/kcfi-normalize.c



diff  --git a/clang/docs/ControlFlowIntegrity.rst 
b/clang/docs/ControlFlowIntegrity.rst
index f375199f40617..ef47b1c5b4b2b 100644
--- a/clang/docs/ControlFlowIntegrity.rst
+++ b/clang/docs/ControlFlowIntegrity.rst
@@ -236,25 +236,6 @@ long as the qualifiers for the type they point to match. 
For example, ``char*``,
 ``-fsanitize-cfi-icall-generalize-pointers`` is not compatible with
 ``-fsanitize-cfi-cross-dso``.
 
-.. _cfi-icall-experimental-normalize-integers:
-
-``-fsanitize-cfi-icall-experimental-normalize-integers``
-
-
-This option enables normalizing integer types as vendor extended types for
-cross-language LLVM CFI/KCFI support with other languages that can't represent
-and encode C/C++ integer types.
-
-Specifically, integer types are encoded as their defined representations (e.g.,
-8-bit signed integer, 16-bit signed integer, 32-bit signed integer, ...) for
-compatibility with languages that define explicitly-sized integer types (e.g.,
-i8, i16, i32, ..., in Rust).
-
-``-fsanitize-cfi-icall-experimental-normalize-integers`` is compatible with
-``-fsanitize-cfi-icall-generalize-pointers``.
-
-This option is currently experimental.
-
 .. _cfi-canonical-jump-tables:
 
 ``-fsanitize-cfi-canonical-jump-tables``

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index dfb062ee034cf..7dd8ecb5fcc4d 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1992,14 +1992,6 @@ are listed below.
checked by Control Flow Integrity indirect call checking. See
:doc:`ControlFlowIntegrity` for more details.
 
-.. option:: -fsanitize-cfi-icall-experimental-normalize-integers
-
-   Normalize integers in return and argument types in function type signatures
-   checked by Control Flow Integrity indirect call checking. See
-   :doc:`ControlFlowIntegrity` for more details.
-
-   This option is currently experimental.
-
 .. option:: -fstrict-vtable-pointers
 
Enable optimizations based on the strict rules for overwriting polymorphic

diff  --git a/clang/include/clang/AST/Mangle.h 
b/clang/include/clang/AST/Mangle.h
index c04bcc7f01cb4..9662a33c61cb7 100644
--- a/clang/include/clang/AST/Mangle.h
+++ b/clang/include/clang/AST/Mangle.h
@@ -140,8 +140,7 @@ class MangleContext {
 unsigned ManglingNumber,
 raw_ostream &) = 0;
   virtual void mangleCXXRTTI(QualType T, raw_ostream &) = 0;
-  virtual void mangleCXXRTTIName(QualType T, raw_ostream &,
- bool NormalizeIntegers = false) = 0;
+  virtual void mangleCXXRTTIName(QualType T, raw_ostream &) = 0;
   virtual void mangleStringLiteral(const StringLiteral *SL, raw_ostream &) = 0;
   virtual void mangleMSGuidDecl(const MSGuidDecl *GD, raw_ostream&);
 
@@ -178,8 +177,7 @@ class MangleContext {
   /// or type uniquing.
   /// TODO: Extend this to internal types by generating names that are unique
   /// across translation units so it can be used with LTO.
-  virtual void mangleTypeName(QualType T, raw_ostream &,
-  bool NormalizeIntegers = false) = 0;
+  virtual void mangleTypeName(QualType T, raw_ostream &) = 0;
 
   /// @}
 };

diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 6383ebea40a5a..436226c6f178f 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -257,8 +257,6 @@ CODEGENOPT(SanitizeMinimalRuntime, 1, 0) ///< Use 
"_minimal" sanitizer runtime f
  ///< diagnostics.
 CODEGENOPT(SanitizeCfiICallGeneralizePointers, 1, 0) ///< Generalize pointer 
types in
 

[clang] 15e33c6 - Revert "[MTE] Add AArch64GlobalsTagging Pass"

2023-01-31 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2023-01-31T12:25:58-08:00
New Revision: 15e33c699cefe0e8528ec661a2b6477f21b6cb10

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

LOG: Revert "[MTE] Add AArch64GlobalsTagging Pass"

This reverts commit 4edfcff71e150770675a19576f698c7bbe788ee2.

Broke the non-aarch64-containing target builds.
https://reviews.llvm.org/D133392 has more context.

Added: 


Modified: 
llvm/lib/CodeGen/GlobalMerge.cpp
llvm/lib/Target/AArch64/AArch64.h
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/AArch64/CMakeLists.txt
llvm/test/CodeGen/AArch64/O0-pipeline.ll
llvm/test/CodeGen/AArch64/O3-pipeline.ll

Removed: 
clang/test/CodeGen/memtag-globals-asm.cpp
llvm/lib/Target/AArch64/AArch64GlobalsTagging.cpp



diff  --git a/clang/test/CodeGen/memtag-globals-asm.cpp 
b/clang/test/CodeGen/memtag-globals-asm.cpp
deleted file mode 100644
index 0e9ab316cc185..0
--- a/clang/test/CodeGen/memtag-globals-asm.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-// RUN: %clang_cc1 -S -x c++ -std=c++11 -triple aarch64-linux-android31 \
-// RUN:   -fsanitize=memtag-globals -o %t.out %s
-// RUN: FileCheck %s --input-file=%t.out
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-A
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-B
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-C
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-D
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-E
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-F
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-G
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-H
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-I
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-J
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-K
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-L
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-M
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-N
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-O
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-P
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-Q
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-R
-
-// RUN: %clang_cc1 -O3 -S -x c++ -std=c++11 -triple aarch64-linux-android31 \
-// RUN:   -fsanitize=memtag-globals -o %t.out %s
-// RUN: FileCheck %s --input-file=%t.out
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-A
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-B
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-C
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-D
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-E
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-F
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-G
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-H
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-I
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-J
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-K
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-L
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-M
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-N
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-O
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-P
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-Q
-// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-R
-
-/// Ensure that emulated TLS also doesn't get sanitized.
-// RUN: %clang_cc1 -S -x c++ -std=c++11 -triple aarch64-linux-android31 \
-// RUN:   -fsanitize=memtag-globals -o - %s | FileCheck %s
-
-// CHECK-A: .memtag global_int
-// CHECK-A: .globl global_int
-// CHECK-A: .p2align 4, 0x0
-// CHECK-A: .size global_int, 16
-int global_int;
-// CHECK-B: .memtag _ZL9local_int
-// CHECK-B: .local _ZL9local_int
-// CHECK-B: .comm _ZL9local_int,16,16
-static int local_int;
-
-// CHECK-C: .memtag _ZL12local_buffer
-// CHECK-C: .local _ZL12local_buffer
-// CHECK-C: .comm _ZL12local_buffer,16,16
-static char local_buffer[16];
-// CHECK-D: .memtag _ZL22local_buffer_local_end
-// CHECK-D: .p2align 4, 0x0
-// CHECK-D: _ZL22local_buffer_local_end:
-// CHECK-D: .xword _ZL12local_buffer+16
-// CHECK-D: .size _ZL22local_buffer_local_end, 16
-static char* local_buffer_local_end = _buffer[16];
-// CHECK-E: .memtag local_buffer_global_end
-// CHECK-E: .globl local_buffer_global_end
-// CHECK-E  .p2align 4, 0x0
-// CHECK-E: 

[clang] 4edfcff - [MTE] Add AArch64GlobalsTagging Pass

2023-01-31 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2023-01-31T09:24:18-08:00
New Revision: 4edfcff71e150770675a19576f698c7bbe788ee2

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

LOG: [MTE] Add AArch64GlobalsTagging Pass

Adds an IR pass for -fsanitize=memtag-globals. This pass goes over the
tag-capable global variables, and replaces them with a tagged global
variable of the same contents. This new global variable will have its
size and alignment adjusted if neccesary so that they're both a multiple
of the tag granule size (16 bytes).

Global merge must also be suppressed for tagged globals, as each global
variable must have a unique tag. This can possibly be relaxed in future;
globals that are identical in size, alignment, and content can possibly
be merged. The major problem comes from tail- or head-merging, which if
left unchecked, could have partially-overlapping global variables with
different memory tags, leading to crashes at runtime.

Reviewed By: fmayer, eugenis

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

Added: 
clang/test/CodeGen/memtag-globals-asm.cpp
llvm/lib/Target/AArch64/AArch64GlobalsTagging.cpp

Modified: 
llvm/lib/CodeGen/GlobalMerge.cpp
llvm/lib/Target/AArch64/AArch64.h
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/AArch64/CMakeLists.txt
llvm/test/CodeGen/AArch64/O0-pipeline.ll
llvm/test/CodeGen/AArch64/O3-pipeline.ll

Removed: 




diff  --git a/clang/test/CodeGen/memtag-globals-asm.cpp 
b/clang/test/CodeGen/memtag-globals-asm.cpp
new file mode 100644
index 0..0e9ab316cc185
--- /dev/null
+++ b/clang/test/CodeGen/memtag-globals-asm.cpp
@@ -0,0 +1,259 @@
+// RUN: %clang_cc1 -S -x c++ -std=c++11 -triple aarch64-linux-android31 \
+// RUN:   -fsanitize=memtag-globals -o %t.out %s
+// RUN: FileCheck %s --input-file=%t.out
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-A
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-B
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-C
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-D
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-E
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-F
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-G
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-H
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-I
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-J
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-K
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-L
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-M
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-N
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-O
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-P
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-Q
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-R
+
+// RUN: %clang_cc1 -O3 -S -x c++ -std=c++11 -triple aarch64-linux-android31 \
+// RUN:   -fsanitize=memtag-globals -o %t.out %s
+// RUN: FileCheck %s --input-file=%t.out
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-A
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-B
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-C
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-D
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-E
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-F
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-G
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-H
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-I
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-J
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-K
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-L
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-M
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-N
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-O
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-P
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-Q
+// RUN: FileCheck %s --input-file=%t.out --check-prefix=CHECK-R
+
+/// Ensure that emulated TLS also doesn't get sanitized.
+// RUN: %clang_cc1 -S -x c++ -std=c++11 -triple aarch64-linux-android31 \
+// RUN:   -fsanitize=memtag-globals -o - %s | FileCheck %s
+
+// CHECK-A: .memtag global_int
+// CHECK-A: .globl global_int
+// CHECK-A: .p2align 4, 0x0
+// CHECK-A: .size global_int, 16
+int global_int;
+// CHECK-B: .memtag _ZL9local_int
+// 

[clang] 74dd8c1 - Revert "[AArch64][NFC] Fix aarch64 target features test."

2022-12-20 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-12-20T17:16:17-08:00
New Revision: 74dd8c1bf80bbc415f8f6f45cb8f3f9bd83b3850

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

LOG: Revert "[AArch64][NFC] Fix aarch64 target features test."

This reverts commit bf94eac6a3f7c5cd8941956d44c15524fa3751bd.

Reason: Depends on reverted change https://reviews.llvm.org/D127812

Added: 


Modified: 
clang/test/Driver/aarch64-features.c

Removed: 




diff  --git a/clang/test/Driver/aarch64-features.c 
b/clang/test/Driver/aarch64-features.c
index b5ffc95f26d04..5c079b62768ae 100644
--- a/clang/test/Driver/aarch64-features.c
+++ b/clang/test/Driver/aarch64-features.c
@@ -13,7 +13,7 @@
 // RUN: %clang -target aarch64-linux-android -rtlib=compiler-rt -mno-fmv \
 // RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-FMV-OFF %s
 
-// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc \
+// RUN: %clang -target aarch64-linux-gnu \
 // RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-FMV-OFF %s
 
 // RUN: %clang -target arm64-unknown-linux -rtlib=libgcc \



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


[clang] c414bbe - Make -fsanitize=scudo use scudo_standalone. Delete check-scudo.

2022-12-02 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-12-02T11:29:41-08:00
New Revision: c414bbefe45ace832a0857d508fb4abfae24c5e6

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

LOG: Make -fsanitize=scudo use scudo_standalone. Delete check-scudo.

Leaves the implementation and tests files in-place for right now, but
deletes the ability to build the old sanitizer-common based scudo. This
has been on life-support for a long time, and the newer scudo_standalone
is much better supported and maintained.

Also patches up some GWP-ASan wording, primarily related to the fact
that -fsanitize=scudo now is scudo_standalone, and therefore the way to
reference the GWP-ASan options through the environment variable has
changed.

Future follow-up patches will delete the original scudo, and migrate all
its tests over to be part of the scudo_standalone test suite.

Reviewed By: vitalybuka

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/fuchsia.c
clang/test/Driver/sanitizer-ld.c
compiler-rt/cmake/config-ix.cmake
compiler-rt/lib/CMakeLists.txt
compiler-rt/test/CMakeLists.txt
compiler-rt/test/scudo/standalone/CMakeLists.txt
llvm/docs/GwpAsan.rst

Removed: 
compiler-rt/test/scudo/CMakeLists.txt



diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 47f09732f95af..17e39948eea75 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1034,10 +1034,7 @@ collectSanitizerRuntimes(const ToolChain , const 
ArgList ,
 SharedRuntimes.push_back("ubsan_standalone");
 }
 if (SanArgs.needsScudoRt() && SanArgs.linkRuntimes()) {
-  if (SanArgs.requiresMinimalRuntime())
-SharedRuntimes.push_back("scudo_minimal");
-  else
-SharedRuntimes.push_back("scudo");
+  SharedRuntimes.push_back("scudo_standalone");
 }
 if (SanArgs.needsTsanRt() && SanArgs.linkRuntimes())
   SharedRuntimes.push_back("tsan");
@@ -1134,15 +1131,9 @@ collectSanitizerRuntimes(const ToolChain , const 
ArgList ,
 RequiredSymbols.push_back("__sanitizer_stats_register");
   }
   if (!SanArgs.needsSharedRt() && SanArgs.needsScudoRt() && 
SanArgs.linkRuntimes()) {
-if (SanArgs.requiresMinimalRuntime()) {
-  StaticRuntimes.push_back("scudo_minimal");
-  if (SanArgs.linkCXXRuntimes())
-StaticRuntimes.push_back("scudo_cxx_minimal");
-} else {
-  StaticRuntimes.push_back("scudo");
-  if (SanArgs.linkCXXRuntimes())
-StaticRuntimes.push_back("scudo_cxx");
-}
+StaticRuntimes.push_back("scudo_standalone");
+if (SanArgs.linkCXXRuntimes())
+  StaticRuntimes.push_back("scudo_standalone_cxx");
   }
 }
 

diff  --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index 099a88c2e4e36..339fd92309796 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -183,7 +183,7 @@
 // CHECK-SCUDO-X86: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-SCUDO-X86: "-fsanitize=safe-stack,scudo"
 // CHECK-SCUDO-X86: "-pie"
-// CHECK-SCUDO-X86: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}x86_64-unknown-fuchsia{{/|}}libclang_rt.scudo.so"
+// CHECK-SCUDO-X86: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}fuchsia{{/|}}libclang_rt.scudo_standalone-x86_64.so"
 
 // RUN: %clang -### %s --target=aarch64-unknown-fuchsia \
 // RUN: -fsanitize=scudo 2>&1 \
@@ -193,7 +193,7 @@
 // CHECK-SCUDO-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-SCUDO-AARCH64: "-fsanitize=shadow-call-stack,scudo"
 // CHECK-SCUDO-AARCH64: "-pie"
-// CHECK-SCUDO-AARCH64: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aarch64-unknown-fuchsia{{/|}}libclang_rt.scudo.so"
+// CHECK-SCUDO-AARCH64: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}fuchsia{{/|}}libclang_rt.scudo_standalone-aarch64.so"
 
 // RUN: %clang -### %s --target=x86_64-unknown-fuchsia \
 // RUN: -fsanitize=scudo -fPIC -shared 2>&1 \
@@ -202,7 +202,7 @@
 // RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-SHARED
 // CHECK-SCUDO-SHARED: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-SCUDO-SHARED: "-fsanitize=safe-stack,scudo"
-// CHECK-SCUDO-SHARED: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}x86_64-unknown-fuchsia{{/|}}libclang_rt.scudo.so"
+// CHECK-SCUDO-SHARED: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}fuchsia{{/|}}libclang_rt.scudo_standalone-x86_64.so"
 
 // RUN: %clang -### %s --target=aarch64-unknown-fuchsia \
 // RUN: -fsanitize=leak 2>&1 \

diff  --git a/clang/test/Driver/sanitizer-ld.c 
b/clang/test/Driver/sanitizer-ld.c
index 1c9b6d783be3d..e58a6e51547ff 100644
--- a/clang/test/Driver/sanitizer-ld.c
+++ b/clang/test/Driver/sanitizer-ld.c
@@ -852,23 +852,12 @@
 

[clang] 850defb - Add assembler plumbing for sanitize_memtag

2022-12-01 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-12-01T10:50:34-08:00
New Revision: 850defb86164f1a68816b21f31529d871400a454

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

LOG: Add assembler plumbing for sanitize_memtag

Extends the Asm reader/writer to support reading and writing the
'.memtag' directive (including allowing it on internal global
variables). Also add some extra tooling support, including objdump and
yaml2obj/obj2yaml.

Test that the sanitize_memtag IR attribute produces the expected asm
directive.

Uses the new Aarch64 MemtagABI specification
(https://github.com/ARM-software/abi-aa/blob/main/memtagabielf64/memtagabielf64.rst)
to identify symbols as tagged in object files. This is done using a
R_AARCH64_NONE relocation that identifies each tagged symbol, and these
relocations are tagged in a special SHT_AARCH64_MEMTAG_GLOBALS_STATIC
section. This signals to the linker that the global variable should be
tagged.

Reviewed By: fmayer, MaskRay, peter.smith

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

Added: 
clang/test/Driver/memtag-stack_lto.c
llvm/test/MC/AArch64/global-tagging.ll

Modified: 
clang/test/Driver/memtag-stack.c
llvm/include/llvm/BinaryFormat/ELF.h
llvm/include/llvm/MC/MCAsmInfo.h
llvm/include/llvm/MC/MCDirectives.h
llvm/include/llvm/MC/MCELFObjectWriter.h
llvm/include/llvm/MC/MCSymbolELF.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/MC/ELFObjectWriter.cpp
llvm/lib/MC/MCAsmStreamer.cpp
llvm/lib/MC/MCELFStreamer.cpp
llvm/lib/MC/MCMachOStreamer.cpp
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/MC/MCSymbolELF.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp

Removed: 
clang/test/Driver/memtag_lto.c



diff  --git a/clang/test/Driver/memtag-stack.c 
b/clang/test/Driver/memtag-stack.c
index 9f22f6687f86..58003fd1b02b 100644
--- a/clang/test/Driver/memtag-stack.c
+++ b/clang/test/Driver/memtag-stack.c
@@ -1,7 +1,7 @@
-// RUN: %clang -target aarch64-unknown-linux -march=armv8+memtag 
-fsanitize=memtag -mllvm -stack-safety-print=1 %s -S -o - 2>&1 | FileCheck %s 
--check-prefix=CHECK-NO-SAFETY
-// RUN: %clang -O1 -target aarch64-unknown-linux -march=armv8+memtag 
-fsanitize=memtag -mllvm -stack-safety-print=1 %s -S -o - 2>&1 | FileCheck %s 
--check-prefix=CHECK-SAFETY
-// RUN: %clang -O2 -target aarch64-unknown-linux -march=armv8+memtag 
-fsanitize=memtag -mllvm -stack-safety-print=1 %s -S -o - 2>&1 | FileCheck %s 
--check-prefix=CHECK-SAFETY
-// RUN: %clang -O3 -target aarch64-unknown-linux -march=armv8+memtag 
-fsanitize=memtag -mllvm -stack-safety-print=1 %s -S -o - 2>&1 | FileCheck %s 
--check-prefix=CHECK-SAFETY
+// RUN: %clang -target aarch64-unknown-linux -march=armv8+memtag 
-fsanitize=memtag-stack -mllvm -stack-safety-print=1 %s -S -o - 2>&1 | 
FileCheck %s --check-prefix=CHECK-NO-SAFETY
+// RUN: %clang -O1 -target aarch64-unknown-linux -march=armv8+memtag 
-fsanitize=memtag-stack -mllvm -stack-safety-print=1 %s -S -o - 2>&1 | 
FileCheck %s --check-prefix=CHECK-SAFETY
+// RUN: %clang -O2 -target aarch64-unknown-linux -march=armv8+memtag 
-fsanitize=memtag-stack -mllvm -stack-safety-print=1 %s -S -o - 2>&1 | 
FileCheck %s --check-prefix=CHECK-SAFETY
+// RUN: %clang -O3 -target aarch64-unknown-linux -march=armv8+memtag 
-fsanitize=memtag-stack -mllvm -stack-safety-print=1 %s -S -o - 2>&1 | 
FileCheck %s --check-prefix=CHECK-SAFETY
 
 // REQUIRES: aarch64-registered-target
 

diff  --git a/clang/test/Driver/memtag_lto.c 
b/clang/test/Driver/memtag-stack_lto.c
similarity index 85%
rename from clang/test/Driver/memtag_lto.c
rename to clang/test/Driver/memtag-stack_lto.c
index 2ad22141608c..2fe15a119d2a 100644
--- a/clang/test/Driver/memtag_lto.c
+++ b/clang/test/Driver/memtag-stack_lto.c
@@ -33,14 +33,14 @@
 // RUN: rm -f %t*
 
 // -O0: both are unsafe.
-// RUN: %clang -O0 -target aarch64-unknown-linux -march=armv8+memtag 
-fsanitize=memtag -mllvm -stack-safety-print %s -S -o - 2>&1 | FileCheck %s
+// RUN: %clang -O0 -target aarch64-unknown-linux -march=armv8+memtag 
-fsanitize=memtag-stack -mllvm -stack-safety-print %s -S -o - 2>&1 | FileCheck 
%s
 
 // No LTO: just one is safe.
-// RUN: %clang -O1 -target aarch64-unknown-linux -march=armv8+memtag 
-fsanitize=memtag -mllvm -stack-safety-print %s -S -o /dev/null 2>&1 | 
FileCheck %s -check-prefixes=SSI,XUNSAFE,YSAFE
+// RUN: %clang -O1 -target aarch64-unknown-linux -march=armv8+memtag 
-fsanitize=memtag-stack -mllvm -stack-safety-print %s -S -o /dev/null 2>&1 | 
FileCheck %s -check-prefixes=SSI,XUNSAFE,YSAFE
 
 // Full LTO: both are safe.
-// RUN: %clang -O1 -target aarch64-unknown-linux -march=armv8+memtag 
-fsanitize=memtag -c %s -Xclang -opaque-pointers -flto=full -o %t.ltonewpm1.bc
-// RUN: %clang -O1 -target 

[clang] ab1a599 - Make -fsanitize=scudo use scudo_standalone. Delete check-scudo.

2022-11-22 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-11-22T12:08:30-08:00
New Revision: ab1a5991fe765d71c0f3262f25726d6b4d66a545

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

LOG: Make -fsanitize=scudo use scudo_standalone. Delete check-scudo.

Leaves the implementation and tests files in-place for right now, but
deletes the ability to build the old sanitizer-common based scudo. This
has been on life-support for a long time, and the newer scudo_standalone
is much better supported and maintained.

Also patches up some GWP-ASan wording, primarily related to the fact
that -fsanitize=scudo now is scudo_standalone, and therefore the way to
reference the GWP-ASan options through the environment variable has
changed.

Future follow-up patches will delete the original scudo, and migrate all
its tests over to be part of the scudo_standalone test suite.

Reviewed By: vitalybuka

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/fuchsia.c
clang/test/Driver/sanitizer-ld.c
compiler-rt/cmake/config-ix.cmake
compiler-rt/lib/CMakeLists.txt
compiler-rt/test/CMakeLists.txt
llvm/docs/GwpAsan.rst

Removed: 
compiler-rt/test/scudo/CMakeLists.txt



diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 30fca3a4c0590..d45721b0bd3b6 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -941,10 +941,7 @@ collectSanitizerRuntimes(const ToolChain , const 
ArgList ,
 SharedRuntimes.push_back("ubsan_standalone");
 }
 if (SanArgs.needsScudoRt() && SanArgs.linkRuntimes()) {
-  if (SanArgs.requiresMinimalRuntime())
-SharedRuntimes.push_back("scudo_minimal");
-  else
-SharedRuntimes.push_back("scudo");
+  SharedRuntimes.push_back("scudo_standalone");
 }
 if (SanArgs.needsTsanRt() && SanArgs.linkRuntimes())
   SharedRuntimes.push_back("tsan");
@@ -1041,15 +1038,9 @@ collectSanitizerRuntimes(const ToolChain , const 
ArgList ,
 RequiredSymbols.push_back("__sanitizer_stats_register");
   }
   if (!SanArgs.needsSharedRt() && SanArgs.needsScudoRt() && 
SanArgs.linkRuntimes()) {
-if (SanArgs.requiresMinimalRuntime()) {
-  StaticRuntimes.push_back("scudo_minimal");
-  if (SanArgs.linkCXXRuntimes())
-StaticRuntimes.push_back("scudo_cxx_minimal");
-} else {
-  StaticRuntimes.push_back("scudo");
-  if (SanArgs.linkCXXRuntimes())
-StaticRuntimes.push_back("scudo_cxx");
-}
+StaticRuntimes.push_back("scudo_standalone");
+if (SanArgs.linkCXXRuntimes())
+  StaticRuntimes.push_back("scudo_standalone_cxx");
   }
 }
 

diff  --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index 099a88c2e4e36..339fd92309796 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -183,7 +183,7 @@
 // CHECK-SCUDO-X86: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-SCUDO-X86: "-fsanitize=safe-stack,scudo"
 // CHECK-SCUDO-X86: "-pie"
-// CHECK-SCUDO-X86: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}x86_64-unknown-fuchsia{{/|}}libclang_rt.scudo.so"
+// CHECK-SCUDO-X86: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}fuchsia{{/|}}libclang_rt.scudo_standalone-x86_64.so"
 
 // RUN: %clang -### %s --target=aarch64-unknown-fuchsia \
 // RUN: -fsanitize=scudo 2>&1 \
@@ -193,7 +193,7 @@
 // CHECK-SCUDO-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-SCUDO-AARCH64: "-fsanitize=shadow-call-stack,scudo"
 // CHECK-SCUDO-AARCH64: "-pie"
-// CHECK-SCUDO-AARCH64: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}aarch64-unknown-fuchsia{{/|}}libclang_rt.scudo.so"
+// CHECK-SCUDO-AARCH64: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}fuchsia{{/|}}libclang_rt.scudo_standalone-aarch64.so"
 
 // RUN: %clang -### %s --target=x86_64-unknown-fuchsia \
 // RUN: -fsanitize=scudo -fPIC -shared 2>&1 \
@@ -202,7 +202,7 @@
 // RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-SHARED
 // CHECK-SCUDO-SHARED: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-SCUDO-SHARED: "-fsanitize=safe-stack,scudo"
-// CHECK-SCUDO-SHARED: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}x86_64-unknown-fuchsia{{/|}}libclang_rt.scudo.so"
+// CHECK-SCUDO-SHARED: 
"[[RESOURCE_DIR]]{{/|}}lib{{/|}}fuchsia{{/|}}libclang_rt.scudo_standalone-x86_64.so"
 
 // RUN: %clang -### %s --target=aarch64-unknown-fuchsia \
 // RUN: -fsanitize=leak 2>&1 \

diff  --git a/clang/test/Driver/sanitizer-ld.c 
b/clang/test/Driver/sanitizer-ld.c
index 1c9b6d783be3d..e58a6e51547ff 100644
--- a/clang/test/Driver/sanitizer-ld.c
+++ b/clang/test/Driver/sanitizer-ld.c
@@ -852,23 +852,12 @@
 // RUN:   | FileCheck --check-prefix=CHECK-SCUDO-LINUX 

[clang] 041d401 - Revert "Rewording "static_assert" diagnostics"

2022-07-14 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-07-14T10:59:20-07:00
New Revision: 041d4012e4c0898bb4e31ffb75655d8163e3ee89

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

LOG: Revert "Rewording "static_assert" diagnostics"

This reverts commit b7e77ff25fb2412f6ab6d6cc75b0e2f97bd3.

Reason: Broke sanitizer builds bots + libcxx. 'static assertion
expression is not an integral constant expression'. More details
available in the Phabricator review: https://reviews.llvm.org/D129048

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/Parser.cpp
clang/test/C/drs/dr0xx.c
clang/test/CXX/dcl.dcl/p4-0x.cpp
clang/test/CXX/drs/dr19xx.cpp
clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp

clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
clang/test/PCH/cxx-static_assert.cpp
clang/test/PCH/cxx-templates.cpp
clang/test/Parser/objc-static-assert.m
clang/test/Parser/objc-static-assert.mm
clang/test/Sema/builtin-align.c
clang/test/Sema/sizeless-1.c
clang/test/Sema/static-assert.c
clang/test/SemaCXX/access-base-class.cpp
clang/test/SemaCXX/alias-template.cpp
clang/test/SemaCXX/builtin-is-constant-evaluated.cpp
clang/test/SemaCXX/builtin-std-move.cpp
clang/test/SemaCXX/builtins.cpp
clang/test/SemaCXX/complex-folding.cpp
clang/test/SemaCXX/constant-expression-cxx11.cpp
clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
clang/test/SemaCXX/coroutines-exp-namespace.cpp
clang/test/SemaCXX/coroutines.cpp
clang/test/SemaCXX/cxx2a-template-lambdas.cpp
clang/test/SemaCXX/cxx98-compat.cpp
clang/test/SemaCXX/delete-and-function-templates.cpp
clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
clang/test/SemaCXX/recovery-expr-type.cpp
clang/test/SemaCXX/sizeless-1.cpp
clang/test/SemaCXX/static-assert-cxx17.cpp
clang/test/SemaCXX/static-assert.cpp
clang/test/SemaCXX/using-decl-templates.cpp
clang/test/SemaCXX/weak-init.cpp
clang/test/SemaTemplate/instantiate-var-template.cpp
clang/test/SemaTemplate/pr52909.cpp
clang/test/SemaTemplate/pr52970.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index cca251cab801e..352a050ba5cf1 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -282,7 +282,7 @@ def err_inline_nested_namespace_definition : Error<
 def err_expected_semi_after_attribute_list : Error<
   "expected ';' after attribute list">;
 def err_expected_semi_after_static_assert : Error<
-  "expected ';' after '%0'">;
+  "expected ';' after static_assert">;
 def err_expected_semi_for : Error<"expected ';' in 'for' statement specifier">;
 def err_single_decl_assign_in_for_range : Error<
   "range-based 'for' statement uses ':', not '='">;
@@ -425,7 +425,7 @@ def err_unexpected_token_in_nested_name_spec : Error<
 def err_bool_redeclaration : Error<
   "redeclaration of C++ built-in type 'bool'">;
 def warn_cxx98_compat_static_assert : Warning<
-  "'static_assert' declarations are incompatible with C++98">,
+  "static_assert declarations are incompatible with C++98">,
   InGroup, DefaultIgnore;
 def ext_ms_static_assert : ExtWarn<
   "use of 'static_assert' without inclusion of  is a Microsoft "

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index bd02659c9c9dc..550029f58b546 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1526,12 +1526,12 @@ def err_messaging_class_with_direct_method : Error<
 
 // C++ declarations
 def err_static_assert_expression_is_not_constant : Error<
-  "static assertion expression is not an integral constant expression">;
+  "static_assert expression is not an integral constant expression">;
 def err_constexpr_if_condition_expression_is_not_constant : Error<
   "constexpr if condition is not a constant expression">;
-def err_static_assert_failed : Error<"static assertion failed%select{: %1|}0">;
+def err_static_assert_failed : Error<"static_assert failed%select{: %1|}0">;
 def err_static_assert_requirement_failed : Error<
-  "static assertion failed due to requirement '%0'%select{: %2|}1">;
+  "static_assert failed due to requirement '%0'%select{: %2|}1">;
 
 def warn_consteval_if_always_true : 

[clang] 7045519 - Add missing sanitizer metadata plumbing from CFE.

2022-07-13 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-07-13T08:54:41-07:00
New Revision: 7045519359de7fe717e29b24d2601679c923ca98

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

LOG: Add missing sanitizer metadata plumbing from CFE.

clang misses attaching sanitizer metadata for external globals.

Reviewed By: eugenis

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/asan-globals.cpp
clang/test/CodeGen/hwasan-globals.cpp
clang/test/CodeGen/memtag-globals.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index f832a067237e..06123cacc6e4 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4293,6 +4293,9 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef 
MangledName, llvm::Type *Ty,
   getCUDARuntime().handleVarRegistration(D, *GV);
   }
 
+  if (D)
+SanitizerMD->reportGlobal(GV, *D);
+
   LangAS ExpectedAS =
   D ? D->getType().getAddressSpace()
 : (LangOpts.OpenCL ? LangAS::opencl_global : LangAS::Default);

diff  --git a/clang/test/CodeGen/asan-globals.cpp 
b/clang/test/CodeGen/asan-globals.cpp
index a3b786fe2e5d..4a370cbd4465 100644
--- a/clang/test/CodeGen/asan-globals.cpp
+++ b/clang/test/CodeGen/asan-globals.cpp
@@ -12,6 +12,7 @@ int dyn_init_global = global;
 int __attribute__((no_sanitize("address"))) attributed_global;
 int __attribute__((disable_sanitizer_instrumentation)) 
disable_instrumentation_global;
 int ignorelisted_global;
+extern int __attribute__((no_sanitize("address"))) external_global;
 
 int __attribute__((section("__DATA, __common"))) sectioned_global; // KASAN - 
ignore globals in a section
 extern "C" {
@@ -21,6 +22,7 @@ int __special_global; // KASAN - ignore globals with __-prefix
 void func() {
   static int static_var = 0;
   const char *literal = "Hello, world!";
+  external_global = 1;
 }
 
 // GLOBS: @{{.*}}extra_global{{.*}} ={{.*}} global
@@ -49,6 +51,8 @@ void func() {
 // GLOBS: @{{.*}} = {{.*}}c"Hello, world!\00"
 // GLOBS-NOT: no_sanitize_address
 
+// GLOBS: @{{.*}}external_global{{.*}} ={{.*}} no_sanitize_address
+
 /// Without -fasynchronous-unwind-tables, ctor and dtor get the uwtable 
attribute.
 // CHECK-LABEL: define internal void @asan.module_ctor() #[[#ATTR:]] {
 // ASAN-NEXT: call void @__asan_init
@@ -83,3 +87,4 @@ void func() {
 // IGNORELIST-SRC: @{{.*}}__special_global{{.*}} ={{.*}} global {{.*}} 
no_sanitize_address
 // IGNORELIST-SRC: @{{.*}}static_var{{.*}} ={{.*}} global {{.*}} 
no_sanitize_address
 // IGNORELIST-SRC: @{{.*}} ={{.*}} c"Hello, world!\00"{{.*}} 
no_sanitize_address
+// IGNORELIST-SRC: @{{.*}}external_global{{.*}} ={{.*}} no_sanitize_address

diff  --git a/clang/test/CodeGen/hwasan-globals.cpp 
b/clang/test/CodeGen/hwasan-globals.cpp
index d9f2e699c2ef..0ab6025834bf 100644
--- a/clang/test/CodeGen/hwasan-globals.cpp
+++ b/clang/test/CodeGen/hwasan-globals.cpp
@@ -14,15 +14,18 @@ int global;
 int __attribute__((no_sanitize("hwaddress"))) attributed_global;
 int __attribute__((disable_sanitizer_instrumentation)) 
disable_instrumentation_global;
 int ignorelisted_global;
+extern int __attribute__((no_sanitize("hwaddress"))) external_global;
 
 void func() {
   static int static_var = 0;
   const char *literal = "Hello, world!";
+  external_global = 1;
 }
 
 // CHECK: @{{.*}}attributed_global{{.*}} ={{.*}} global {{.*}}, 
no_sanitize_hwaddress
 // CHECK: @{{.*}}disable_instrumentation_global{{.*}} ={{.*}} global {{.*}}, 
no_sanitize_hwaddress
 // CHECK: @{{.*}}ignorelisted_global{{.*}} ={{.*}} global {{.*}}, 
no_sanitize_hwaddress
+// CHECK: @{{.*}}external_global{{.*}} ={{.*}}, no_sanitize_hwaddress
 // CHECK: @{{.*}}extra_global{{.*}}.hwasan{{.*}} =
 // CHECK: @{{.*}}global{{.*}}.hwasan{{.*}} =
 // CHECK: @{{.*}}static_var{{.*}}.hwasan{{.*}} =
@@ -34,4 +37,5 @@ void func() {
 // IGNORELIST: @{{.*}}ignorelisted_globa{{.*}} ={{.*}} global {{.*}}, 
no_sanitize_hwaddress
 // IGNORELIST: @{{.*}}static_var{{.*}} ={{.*}} global {{.*}}, 
no_sanitize_hwaddress
 // IGNORELIST: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}}, 
no_sanitize_hwaddress
+// IGNORELIST: @{{.*}}external_global{{.*}} ={{.*}}, no_sanitize_hwaddress
 // IGNORELIST: @{{.*}}extra_global{{.*}}.hwasan{{.*}} =

diff  --git a/clang/test/CodeGen/memtag-globals.cpp 
b/clang/test/CodeGen/memtag-globals.cpp
index da801cc9d633..b4f5dc0d7dcf 100644
--- a/clang/test/CodeGen/memtag-globals.cpp
+++ b/clang/test/CodeGen/memtag-globals.cpp
@@ -11,10 +11,12 @@ int global;
 int __attribute__((no_sanitize("memtag"))) attributed_global;
 int __attribute__((disable_sanitizer_instrumentation)) 
disable_instrumentation_global;
 int ignorelisted_global;

[clang] 90e5a8a - Remove 'no_sanitize_memtag'. Add 'sanitize_memtag'.

2022-07-13 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-07-13T08:54:41-07:00
New Revision: 90e5a8ac475fa3c2fa7c22a341e798d6f7356b54

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

LOG: Remove 'no_sanitize_memtag'. Add 'sanitize_memtag'.

For MTE globals, we should have clang emit the attribute for all GV's
that it creates, and then use that in the upcoming AArch64 global
tagging IR pass. We need a positive attribute for this sanitizer (rather
than implicit sanitization of all globals) because it needs to interact
with other parts of LLVM, including:

  1. Suppressing certain global optimisations (like merging),
  2. Emitting extra directives by the ASM writer, and
  3. Putting extra information in the symbol table entries.

While this does technically make the LLVM IR / bitcode format
non-backwards-compatible, nobody should have used this attribute yet,
because it's a no-op.

Reviewed By: eugenis

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

Added: 


Modified: 
clang/lib/CodeGen/SanitizerMetadata.cpp
clang/test/CodeGen/memtag-globals.cpp
clang/test/CodeGen/sanitizer-special-case-list-globals.c
llvm/include/llvm/AsmParser/LLToken.h
llvm/include/llvm/IR/GlobalValue.h
llvm/lib/AsmParser/LLLexer.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/IR/AsmWriter.cpp
llvm/test/Assembler/globalvariable-attributes.ll
llvm/test/Bitcode/compatibility.ll

Removed: 




diff  --git a/clang/lib/CodeGen/SanitizerMetadata.cpp 
b/clang/lib/CodeGen/SanitizerMetadata.cpp
index 0c752304b13df..7848cf0126335 100644
--- a/clang/lib/CodeGen/SanitizerMetadata.cpp
+++ b/clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -60,8 +60,10 @@ void SanitizerMetadata::reportGlobal(llvm::GlobalVariable 
*GV,
   Meta.NoHWAddress |= CGM.isInNoSanitizeList(
   FsanitizeArgument.Mask & SanitizerKind::HWAddress, GV, Loc, Ty);
 
-  Meta.NoMemtag |= NoSanitizeAttrSet.hasOneOf(SanitizerKind::MemTag);
-  Meta.NoMemtag |= CGM.isInNoSanitizeList(
+  Meta.Memtag |=
+  static_cast(FsanitizeArgument.Mask & SanitizerKind::MemtagGlobals);
+  Meta.Memtag &= !NoSanitizeAttrSet.hasOneOf(SanitizerKind::MemTag);
+  Meta.Memtag &= !CGM.isInNoSanitizeList(
   FsanitizeArgument.Mask & SanitizerKind::MemTag, GV, Loc, Ty);
 
   Meta.IsDynInit = IsDynInit && !Meta.NoAddress &&

diff  --git a/clang/test/CodeGen/memtag-globals.cpp 
b/clang/test/CodeGen/memtag-globals.cpp
index 2eee42de283c6..da801cc9d633e 100644
--- a/clang/test/CodeGen/memtag-globals.cpp
+++ b/clang/test/CodeGen/memtag-globals.cpp
@@ -17,23 +17,30 @@ void func() {
   const char *literal = "Hello, world!";
 }
 
-// CHECK: @{{.*}}extra_global{{.*}} =
-// CHECK-NOT: no_sanitize_memtag
-// CHECK: @{{.*}}global{{.*}} =
-// CHECK-NOT: no_sanitize_memtag
-// CHECK: @{{.*}}attributed_global{{.*}} ={{.*}} global {{.*}}, 
no_sanitize_memtag
-// CHECK: @{{.*}}disable_instrumentation_global{{.*}} ={{.*}} global {{.*}}, 
no_sanitize_memtag
-// CHECK: @{{.*}}ignorelisted_global{{.*}} ={{.*}} global {{.*}}, 
no_sanitize_memtag
-// CHECK: @{{.*}}static_var{{.*}} =
-// CHECK-NOT: no_sanitize_memtag
-// CHECK: @{{.*}} = {{.*}} c"Hello, world!\00"
-// CHECK-NOT: no_sanitize_memtag
-
-// IGNORELIST: @{{.*}}extra_global{{.*}} ={{.*}} global
-// IGNORELIST-NOT: no_sanitize_memtag
-// IGNORELIST: @{{.*}}global{{.*}} ={{.*}} global {{.*}}, no_sanitize_memtag
-// IGNORELIST: @{{.*}}attributed_global{{.*}} ={{.*}} global {{.*}}, 
no_sanitize_memtag
-// IGNORELIST: @{{.*}}disable_instrumentation_global{{.*}} ={{.*}} global 
{{.*}}, no_sanitize_memtag
-// IGNORELIST: @{{.*}}ignorelisted_globa{{.*}} ={{.*}} global {{.*}}, 
no_sanitize_memtag
-// IGNORELIST: @{{.*}}static_var{{.*}} ={{.*}} global {{.*}}, 
no_sanitize_memtag
-// IGNORELIST: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}}, no_sanitize_memtag
+// CHECK: @{{.*}}extra_global{{.*}} ={{.*}} sanitize_memtag
+// CHECK: @{{.*}}global{{.*}} ={{.*}} sanitize_memtag
+
+// CHECK: @{{.*}}attributed_global{{.*}} =
+// CHECK-NOT: sanitize_memtag
+// CHECK: @{{.*}}disable_instrumentation_global{{.*}} =
+// CHECK-NOT: sanitize_memtag
+// CHECK: @{{.*}}ignorelisted_global{{.*}} =
+// CHECK-NOT: sanitize_memtag
+
+// CHECK: @{{.*}}static_var{{.*}} ={{.*}} sanitize_memtag
+// CHECK: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}} sanitize_memtag
+
+// IGNORELIST: @{{.*}}extra_global{{.*}} ={{.*}} sanitize_memtag
+
+// IGNORELIST: @{{.*}}global{{.*}} =
+// IGNORELIST-NOT: sanitize_memtag
+// IGNORELIST: @{{.*}}attributed_global{{.*}} =
+// IGNORELIST-NOT: sanitize_memtag
+// IGNORELIST: @{{.*}}disable_instrumentation_global{{.*}} =
+// IGNORELIST-NOT: sanitize_memtag
+// IGNORELIST: @{{.*}}ignorelisted_globa{{.*}} =
+// 

[clang] f18de76 - Update DynInit generation for ASan globals.

2022-07-11 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-07-11T12:23:37-07:00
New Revision: f18de7619e5d5dde301d8d4f6f3ec0f8260be710

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

LOG: Update DynInit generation for ASan globals.

Address a follow-up TODO for Sanitizer Metadata.

Reviewed By: vitalybuka

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

Added: 


Modified: 
clang/lib/CodeGen/SanitizerMetadata.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/SanitizerMetadata.cpp 
b/clang/lib/CodeGen/SanitizerMetadata.cpp
index 5f4eb9be981f..0c752304b13d 100644
--- a/clang/lib/CodeGen/SanitizerMetadata.cpp
+++ b/clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -64,13 +64,11 @@ void SanitizerMetadata::reportGlobal(llvm::GlobalVariable 
*GV,
   Meta.NoMemtag |= CGM.isInNoSanitizeList(
   FsanitizeArgument.Mask & SanitizerKind::MemTag, GV, Loc, Ty);
 
-  if (FsanitizeArgument.has(SanitizerKind::Address)) {
-// TODO(hctim): Make this conditional when we migrate off 
llvm.asan.globals.
-IsDynInit &= !CGM.isInNoSanitizeList(SanitizerKind::Address |
- SanitizerKind::KernelAddress,
- GV, Loc, Ty, "init");
-Meta.IsDynInit = IsDynInit;
-  }
+  Meta.IsDynInit = IsDynInit && !Meta.NoAddress &&
+   FsanitizeArgument.has(SanitizerKind::Address) &&
+   !CGM.isInNoSanitizeList(SanitizerKind::Address |
+   SanitizerKind::KernelAddress,
+   GV, Loc, Ty, "init");
 
   GV->setSanitizerMetadata(Meta);
 }



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


[clang] a2095d1 - Allow mangled names in sanitizer clang IR gen tests.

2022-06-28 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-06-28T09:27:43-07:00
New Revision: a2095d1aff847ab7f7035744fb718c32cf680a01

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

LOG: Allow mangled names in sanitizer clang IR gen tests.

Looks like with https://reviews.llvm.org/D127911, Windows emits more
globals with mangled names into the IR. Relax the tests in order to
allow these mangled names.

Added: 


Modified: 
clang/test/CodeGen/asan-globals.cpp
clang/test/CodeGen/hwasan-globals.cpp

Removed: 




diff  --git a/clang/test/CodeGen/asan-globals.cpp 
b/clang/test/CodeGen/asan-globals.cpp
index 74c461d1cafff..a3b786fe2e5d3 100644
--- a/clang/test/CodeGen/asan-globals.cpp
+++ b/clang/test/CodeGen/asan-globals.cpp
@@ -30,23 +30,23 @@ void func() {
 // GLOBS: @{{.*}}dyn_init_global{{.*}} ={{.*}} global {{.*}}, 
sanitize_address_dyninit
 // GLOBS-NOT: no_sanitize_address
 
-// GLOBS: @attributed_global = global {{.*}} no_sanitize_address
-// GLOBS: @disable_instrumentation_global = global {{.*}} 
no_sanitize_address
-// GLOBS: @ignorelisted_global = global {{.*}} no_sanitize_address
+// GLOBS: @{{.*}}attributed_global{{.*}} ={{.*}} global {{.*}} 
no_sanitize_address
+// GLOBS: @{{.*}}disable_instrumentation_global{{.*}} ={{.*}} global 
{{.*}} no_sanitize_address
+// GLOBS: @{{.*}}ignorelisted_global{{.*}} ={{.*}} global {{.*}} 
no_sanitize_address
 
-// ASAN: sectioned_global{{.*}} global { i32, [28 x i8] }{{.*}}, align 32
+// ASAN: @{{.*}}sectioned_global{{.*}} ={{.*}} global { i32, [28 x i8] 
}{{.*}}, align 32
 // ASAN-NOT: no_sanitize_address
-// ASAN: @__special_global{{.*}} global { i32, [28 x i8] }{{.*}}, align 32
+// ASAN: @{{.*}}__special_global{{.*}} ={{.*}} global { i32, [28 x i8] 
}{{.*}}, align 32
 // ASAN-NOT: no_sanitize_address
 
 /// Note: No attribute is added by the IR pass, but the type didn't change, so
 /// that checks our assertions that the globals didn't get instrumented.
-// KASAN:sectioned_global{{.*}} global i32 {{.*}}
-// KASAN:@__special_global{{.*}} global i32 {{.*}}
+// KASAN:@{{.*}}sectioned_global{{.*}} ={{.*}} global i32 {{.*}}
+// KASAN:@{{.*}}__special_global{{.*}} ={{.*}} global i32 {{.*}}
 
-// GLOBS: @{{[^ ]*}}static_var{{[^ ]*}} = internal global {{.*}}
+// GLOBS: @{{[^ ]*}}static_var{{[^ ]*}} ={{.*}} global {{.*}}
 // GLOBS-NOT: no_sanitize_address
-// GLOBS: @{{.*}} = internal constant {{.*}}"Hello, world!{{.*}}
+// GLOBS: @{{.*}} = {{.*}}c"Hello, world!\00"
 // GLOBS-NOT: no_sanitize_address
 
 /// Without -fasynchronous-unwind-tables, ctor and dtor get the uwtable 
attribute.
@@ -72,14 +72,14 @@ void func() {
 // UWTABLE: attributes #[[#ATTR]] = { nounwind uwtable }
 // UWTABLE: ![[#]] = !{i32 7, !"uwtable", i32 2}
 
-// IGNORELIST-SRC: @extra_global = global {{.*}}
+// IGNORELIST-SRC: @{{.*}}extra_global{{.*}} ={{.*}} global
 // IGNORELIST-SRC-NOT: no_sanitize_address
-// IGNORELIST-SRC: @global = global {{.*}} no_sanitize_address
-// IGNORELIST-SRC: @dyn_init_global = global {{.*}} no_sanitize_address
-// IGNORELIST-SRC: @attributed_global = global {{.*}} no_sanitize_address
-// IGNORELIST-SRC: @disable_instrumentation_global = global {{.*}} 
no_sanitize_address
-// IGNORELIST-SRC: @ignorelisted_global = global {{.*}} no_sanitize_address
-// IGNORELIST-SRC: @sectioned_global = global {{.*}} no_sanitize_address
-// IGNORELIST-SRC: @__special_global = global {{.*}} no_sanitize_address
-// IGNORELIST-SRC: @{{[^ ]*}}static_var{{[^ ]*}} = internal global {{.*}} 
no_sanitize_address
-// IGNORELIST-SRC: @.str = {{.*}} constant {{.*}}"Hello, world!{{.*}} 
no_sanitize_address
+// IGNORELIST-SRC: @{{.*}}global{{.*}} ={{.*}} global {{.*}} 
no_sanitize_address
+// IGNORELIST-SRC: @{{.*}}dyn_init_global{{.*}} ={{.*}} global {{.*}} 
no_sanitize_address
+// IGNORELIST-SRC: @{{.*}}attributed_global{{.*}} ={{.*}} global {{.*}} 
no_sanitize_address
+// IGNORELIST-SRC: @{{.*}}disable_instrumentation_global{{.*}} ={{.*}} 
global {{.*}} no_sanitize_address
+// IGNORELIST-SRC: @{{.*}}ignorelisted_global{{.*}} ={{.*}} global {{.*}} 
no_sanitize_address
+// IGNORELIST-SRC: @{{.*}}sectioned_global{{.*}} ={{.*}} global {{.*}} 
no_sanitize_address
+// IGNORELIST-SRC: @{{.*}}__special_global{{.*}} ={{.*}} global {{.*}} 
no_sanitize_address
+// IGNORELIST-SRC: @{{.*}}static_var{{.*}} ={{.*}} global {{.*}} 
no_sanitize_address
+// IGNORELIST-SRC: @{{.*}} ={{.*}} c"Hello, world!\00"{{.*}} 
no_sanitize_address

diff  --git a/clang/test/CodeGen/hwasan-globals.cpp 
b/clang/test/CodeGen/hwasan-globals.cpp
index a81bcb7110233..d9f2e699c2eff 100644
--- a/clang/test/CodeGen/hwasan-globals.cpp
+++ 

[clang] 243fc3d - fix-forward hwasan-globals.cpp (round 2)

2022-06-24 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-06-24T14:49:37-07:00
New Revision: 243fc3daf675ea047bb80c21c62d24a331da8b16

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

LOG: fix-forward hwasan-globals.cpp (round 2)

Just force the aarch64 target compilation (after making sure the test
only runs if that target is available).

Because global metadata isn't target-specific, just selecting a target
here is fine.

Should fix https://reviews.llvm.org/D127544#3609312

Added: 


Modified: 
clang/test/CodeGen/hwasan-globals.cpp

Removed: 




diff  --git a/clang/test/CodeGen/hwasan-globals.cpp 
b/clang/test/CodeGen/hwasan-globals.cpp
index 9424efacb381..39460d3297b4 100644
--- a/clang/test/CodeGen/hwasan-globals.cpp
+++ b/clang/test/CodeGen/hwasan-globals.cpp
@@ -1,13 +1,14 @@
-// REQUIRES: aarch64-registered-target || x86-registered-target
+// REQUIRES: aarch64-registered-target
 
 // RUN: %clang_cc1 -include %S/Inputs/sanitizer-extra-source.cpp \
 // RUN:   -fsanitize-ignorelist=%S/Inputs/sanitizer-ignorelist-global.txt \
-// RUN:   -fsanitize=hwaddress -emit-llvm -o - %s | FileCheck %s
+// RUN:   -fsanitize=hwaddress -emit-llvm -triple aarch64-linux-android31 -o -\
+// RUN:%s | FileCheck %s
 
 // RUN: %clang_cc1 -include %S/Inputs/sanitizer-extra-source.cpp \
 // RUN:   -fsanitize-ignorelist=%S/Inputs/sanitizer-ignorelist-src.txt \
-// RUN:   -fsanitize=hwaddress -emit-llvm -o - %s | \
-// RUN:   FileCheck %s --check-prefix=IGNORELIST
+// RUN:   -fsanitize=hwaddress -emit-llvm -triple aarch64-linux-android31 -o -\
+// RUN:   %s | FileCheck %s --check-prefix=IGNORELIST
 
 int global;
 int __attribute__((no_sanitize("hwaddress"))) attributed_global;
@@ -31,14 +32,14 @@ void func() {
 // CHECK: ![[EXTRA_GLOBAL]] = !{{{.*}} ![[EXTRA_GLOBAL_LOC:[0-9]+]], 
!"extra_global", i1 false, i1 false}
 // CHECK: ![[EXTRA_GLOBAL_LOC]] = !{!"{{.*}}extra-source.cpp", i32 1, i32 5}
 // CHECK: ![[GLOBAL]] = !{{{.*}} ![[GLOBAL_LOC:[0-9]+]], !"global", i1 false, 
i1 false}
-// CHECK: ![[GLOBAL_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 12, i32 5}
+// CHECK: ![[GLOBAL_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 13, i32 5}
 // CHECK: ![[ATTR_GLOBAL]] = !{{{.*attributed_global.*}}, null, null, i1 
false, i1 true}
 // CHECK: ![[DISABLE_INSTR_GLOBAL]] = 
!{{{.*disable_instrumentation_global.*}}, null, null, i1 false, i1 true}
 // CHECK: ![[IGNORELISTED_GLOBAL]] = !{{{.*ignorelisted_global.*}}, null, 
null, i1 false, i1 true}
 // CHECK: ![[STATIC_VAR]] = !{{{.*}} ![[STATIC_LOC:[0-9]+]], !"static_var", i1 
false, i1 false}
-// CHECK: ![[STATIC_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 18, i32 14}
+// CHECK: ![[STATIC_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 19, i32 14}
 // CHECK: ![[LITERAL]] = !{{{.*}} ![[LITERAL_LOC:[0-9]+]], !"", i1 false, i1 false}
-// CHECK: ![[LITERAL_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 19, i32 25}
+// CHECK: ![[LITERAL_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 20, i32 25}
 
 // IGNORELIST: @{{.*}}global{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress
 // IGNORELIST: @{{.*}}attributed_global{{.*}} ={{.*}} global {{.*}}, 
no_sanitize_hwaddress



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


[clang] fadc98b - Don't run hwasan-globals.cpp test on non-x86/aarch64

2022-06-24 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-06-24T14:33:41-07:00
New Revision: fadc98b06befb674fa47da4f3d8606bf61bed681

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

LOG: Don't run hwasan-globals.cpp test on non-x86/aarch64

Fix-forward for https://reviews.llvm.org/D127544#3609312

IR pass has some target-specific inline asm lowering that check-fails
for non-x86 non-aarch64 targets.

For now, just run these tests only on those targets.

Added: 


Modified: 
clang/test/CodeGen/hwasan-globals.cpp

Removed: 




diff  --git a/clang/test/CodeGen/hwasan-globals.cpp 
b/clang/test/CodeGen/hwasan-globals.cpp
index 7edf6e6b7e57..9424efacb381 100644
--- a/clang/test/CodeGen/hwasan-globals.cpp
+++ b/clang/test/CodeGen/hwasan-globals.cpp
@@ -1,3 +1,5 @@
+// REQUIRES: aarch64-registered-target || x86-registered-target
+
 // RUN: %clang_cc1 -include %S/Inputs/sanitizer-extra-source.cpp \
 // RUN:   -fsanitize-ignorelist=%S/Inputs/sanitizer-ignorelist-global.txt \
 // RUN:   -fsanitize=hwaddress -emit-llvm -o - %s | FileCheck %s
@@ -29,14 +31,14 @@ void func() {
 // CHECK: ![[EXTRA_GLOBAL]] = !{{{.*}} ![[EXTRA_GLOBAL_LOC:[0-9]+]], 
!"extra_global", i1 false, i1 false}
 // CHECK: ![[EXTRA_GLOBAL_LOC]] = !{!"{{.*}}extra-source.cpp", i32 1, i32 5}
 // CHECK: ![[GLOBAL]] = !{{{.*}} ![[GLOBAL_LOC:[0-9]+]], !"global", i1 false, 
i1 false}
-// CHECK: ![[GLOBAL_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 10, i32 5}
+// CHECK: ![[GLOBAL_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 12, i32 5}
 // CHECK: ![[ATTR_GLOBAL]] = !{{{.*attributed_global.*}}, null, null, i1 
false, i1 true}
 // CHECK: ![[DISABLE_INSTR_GLOBAL]] = 
!{{{.*disable_instrumentation_global.*}}, null, null, i1 false, i1 true}
 // CHECK: ![[IGNORELISTED_GLOBAL]] = !{{{.*ignorelisted_global.*}}, null, 
null, i1 false, i1 true}
 // CHECK: ![[STATIC_VAR]] = !{{{.*}} ![[STATIC_LOC:[0-9]+]], !"static_var", i1 
false, i1 false}
-// CHECK: ![[STATIC_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 16, i32 14}
+// CHECK: ![[STATIC_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 18, i32 14}
 // CHECK: ![[LITERAL]] = !{{{.*}} ![[LITERAL_LOC:[0-9]+]], !"", i1 false, i1 false}
-// CHECK: ![[LITERAL_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 17, i32 25}
+// CHECK: ![[LITERAL_LOC]] = !{!"{{.*}}hwasan-globals.cpp", i32 19, i32 25}
 
 // IGNORELIST: @{{.*}}global{{.*}} ={{.*}} global {{.*}}, no_sanitize_hwaddress
 // IGNORELIST: @{{.*}}attributed_global{{.*}} ={{.*}} global {{.*}}, 
no_sanitize_hwaddress



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


[clang] faf5e0e - Add no_sanitize('hwaddress') (and 'memtag', but that's a no-op).

2022-06-24 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-06-24T12:04:11-07:00
New Revision: faf5e0ec737a676088649d7c13cb50f3f91a703a

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

LOG: Add no_sanitize('hwaddress') (and 'memtag', but that's a no-op).

Currently, `__attribute__((no_sanitize('hwaddress')))` is not possible. Add 
this piece of plumbing, and now that we properly support copying attributes 
between an old and a new global variable, add a regression test for the 
GlobalOpt bug that previously lost the attribute.

Reviewed By: aaron.ballman

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

Added: 
clang/test/CodeGen/Inputs/sanitizer-extra-source.cpp
clang/test/CodeGen/Inputs/sanitizer-ignorelist-global.txt
clang/test/CodeGen/Inputs/sanitizer-ignorelist-src.txt
clang/test/CodeGen/hwasan-globals.cpp
clang/test/CodeGen/memtag-globals.cpp
compiler-rt/test/hwasan/TestCases/global-with-reduction.c

Modified: 
clang/lib/Sema/SemaDeclAttr.cpp
compiler-rt/test/hwasan/TestCases/global.c

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 2563a07b4034..73a4be54861b 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -7859,6 +7859,11 @@ static bool isGlobalVar(const Decl *D) {
   return false;
 }
 
+static bool isSanitizerAttributeAllowedOnGlobals(StringRef Sanitizer) {
+  return Sanitizer == "address" || Sanitizer == "hwaddress" ||
+ Sanitizer == "memtag";
+}
+
 static void handleNoSanitizeAttr(Sema , Decl *D, const ParsedAttr ) {
   if (!AL.checkAtLeastNumArgs(S, 1))
 return;
@@ -7876,7 +7881,7 @@ static void handleNoSanitizeAttr(Sema , Decl *D, const 
ParsedAttr ) {
 SanitizerMask() &&
 SanitizerName != "coverage")
   S.Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << 
SanitizerName;
-else if (isGlobalVar(D) && SanitizerName != "address")
+else if (isGlobalVar(D) && 
!isSanitizerAttributeAllowedOnGlobals(SanitizerName))
   S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
   << AL << ExpectedFunctionOrMethod;
 Sanitizers.push_back(SanitizerName);

diff  --git a/clang/test/CodeGen/Inputs/sanitizer-extra-source.cpp 
b/clang/test/CodeGen/Inputs/sanitizer-extra-source.cpp
new file mode 100644
index ..21371d534255
--- /dev/null
+++ b/clang/test/CodeGen/Inputs/sanitizer-extra-source.cpp
@@ -0,0 +1 @@
+int extra_global;

diff  --git a/clang/test/CodeGen/Inputs/sanitizer-ignorelist-global.txt 
b/clang/test/CodeGen/Inputs/sanitizer-ignorelist-global.txt
new file mode 100644
index ..40a1d07fb895
--- /dev/null
+++ b/clang/test/CodeGen/Inputs/sanitizer-ignorelist-global.txt
@@ -0,0 +1 @@
+global:*ignorelisted_global*

diff  --git a/clang/test/CodeGen/Inputs/sanitizer-ignorelist-src.txt 
b/clang/test/CodeGen/Inputs/sanitizer-ignorelist-src.txt
new file mode 100644
index ..67e50c852606
--- /dev/null
+++ b/clang/test/CodeGen/Inputs/sanitizer-ignorelist-src.txt
@@ -0,0 +1 @@
+src:*-globals.cpp

diff  --git a/clang/test/CodeGen/hwasan-globals.cpp 
b/clang/test/CodeGen/hwasan-globals.cpp
new file mode 100644
index ..7edf6e6b7e57
--- /dev/null
+++ b/clang/test/CodeGen/hwasan-globals.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -include %S/Inputs/sanitizer-extra-source.cpp \
+// RUN:   -fsanitize-ignorelist=%S/Inputs/sanitizer-ignorelist-global.txt \
+// RUN:   -fsanitize=hwaddress -emit-llvm -o - %s | FileCheck %s
+
+// RUN: %clang_cc1 -include %S/Inputs/sanitizer-extra-source.cpp \
+// RUN:   -fsanitize-ignorelist=%S/Inputs/sanitizer-ignorelist-src.txt \
+// RUN:   -fsanitize=hwaddress -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefix=IGNORELIST
+
+int global;
+int __attribute__((no_sanitize("hwaddress"))) attributed_global;
+int __attribute__((disable_sanitizer_instrumentation)) 
disable_instrumentation_global;
+int ignorelisted_global;
+
+void func() {
+  static int static_var = 0;
+  const char *literal = "Hello, world!";
+}
+
+// CHECK: @{{.*}}attributed_global{{.*}} ={{.*}} global {{.*}}, 
no_sanitize_hwaddress
+// CHECK: @{{.*}}disable_instrumentation_global{{.*}} ={{.*}} global {{.*}}, 
no_sanitize_hwaddress
+// CHECK: @{{.*}}ignorelisted_global{{.*}} ={{.*}} global {{.*}}, 
no_sanitize_hwaddress
+// CHECK: @{{.*}}extra_global{{.*}}.hwasan{{.*}} =
+// CHECK: @{{.*}}global{{.*}}.hwasan{{.*}} =
+// CHECK: @{{.*}}static_var{{.*}}.hwasan{{.*}} =
+// CHECK: @{{.*}}.hwasan{{.*}} = {{.*}} c"Hello, world!\00"
+
+// CHECK: !llvm.asan.globals = !{![[EXTRA_GLOBAL:[0-9]+]], ![[GLOBAL:[0-9]+]], 
![[ATTR_GLOBAL:[0-9]+]], ![[DISABLE_INSTR_GLOBAL:[0-9]+]], 
![[IGNORELISTED_GLOBAL:[0-9]+]], ![[STATIC_VAR:[0-9]+]], ![[LITERAL:[0-9]+]]}
+// CHECK: ![[EXTRA_GLOBAL]] = !{{{.*}} 

[clang] ee28837 - [NFCI] Whitespace in SemaDeclAttr.cpp

2022-06-16 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-06-16T15:10:32-07:00
New Revision: ee28837a1fbd574dbec14b9f09cb4effab6a492a

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

LOG: [NFCI] Whitespace in SemaDeclAttr.cpp

Added: 


Modified: 
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index af8dc853eba69..bd4d9414365e1 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -8876,7 +8876,7 @@ ProcessDeclAttribute(Sema , Scope *scope, Decl *D, 
const ParsedAttr ,
   case ParsedAttr::AT_Thread:
 handleDeclspecThreadAttr(S, D, AL);
 break;
-  
+
   // HLSL attributes:
   case ParsedAttr::AT_HLSLNumThreads:
 handleHLSLNumThreadsAttr(S, D, AL);



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


[clang] 011e060 - Add DWARF string debug to clang release notes.

2022-06-16 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-06-16T14:54:12-07:00
New Revision: 011e0604ebc9d85db3585ebb2f63df465f726417

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

LOG: Add DWARF string debug to clang release notes.

D12353 added inline strings to the DWARF info produced by clang. This
turns out to break some debugging software that assumes that a
DW_TAG_variable *must* come with a DW_AT_name. Add a release note to
broadcast this change.

Reviewed By: paulkirth

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2f17fbf406285..ecf574b3b0f8d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -498,6 +498,13 @@ X86 Support in Clang
 DWARF Support in Clang
 --
 
+- clang now adds DWARF information for inline strings in C/C++ programs,
+  allowing ``line:column`` symbolization of strings. Some debugging programs 
may
+  require updating, as this takes advantage of DWARF ``DW_TAG_variable``
+  structures *without* a ``DW_AT_name`` field, which is valid DWARF, but may be
+  handled incorrectly by some software (e.g. new failures with incorrect
+  assertions).
+
 Arm and AArch64 Support in Clang
 
 



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


[clang] 45d88cd - [clang] Add -fsanitize=memtag-globals (no-op).

2022-06-15 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-06-15T10:07:53-07:00
New Revision: 45d88cd008463be54b8f907bd6eea6c65c8049b6

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

LOG: [clang] Add -fsanitize=memtag-globals (no-op).

Adds the -fsanitize plumbing for memtag-globals. Makes -fsanitize=memtag
imply -fsanitize=memtag-globals.

This has no effect on codegen for now.

Reviewed By: eugenis, aaron.ballman

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

Added: 


Modified: 
clang/include/clang/Basic/Features.def
clang/include/clang/Basic/Sanitizers.def
clang/include/clang/Driver/SanitizerArgs.h
clang/lib/Driver/SanitizerArgs.cpp
clang/test/Driver/fsanitize.c

Removed: 




diff  --git a/clang/include/clang/Basic/Features.def 
b/clang/include/clang/Basic/Features.def
index f241d68a23ed9..a7f0ae03e0beb 100644
--- a/clang/include/clang/Basic/Features.def
+++ b/clang/include/clang/Basic/Features.def
@@ -49,6 +49,8 @@ FEATURE(memtag_stack,
 LangOpts.Sanitize.has(SanitizerKind::MemtagStack))
 FEATURE(memtag_heap,
 LangOpts.Sanitize.has(SanitizerKind::MemtagHeap))
+FEATURE(memtag_globals,
+LangOpts.Sanitize.has(SanitizerKind::MemtagGlobals))
 FEATURE(xray_instrument, LangOpts.XRayInstrument)
 FEATURE(undefined_behavior_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined))

diff  --git a/clang/include/clang/Basic/Sanitizers.def 
b/clang/include/clang/Basic/Sanitizers.def
index 714934445cf95..8e7b6cd0a7e29 100644
--- a/clang/include/clang/Basic/Sanitizers.def
+++ b/clang/include/clang/Basic/Sanitizers.def
@@ -58,7 +58,8 @@ SANITIZER("kernel-hwaddress", KernelHWAddress)
 // A variant of AddressSanitizer using AArch64 MTE extension.
 SANITIZER("memtag-stack", MemtagStack)
 SANITIZER("memtag-heap", MemtagHeap)
-SANITIZER_GROUP("memtag", MemTag, MemtagStack | MemtagHeap)
+SANITIZER("memtag-globals", MemtagGlobals)
+SANITIZER_GROUP("memtag", MemTag, MemtagStack | MemtagHeap | MemtagGlobals)
 
 // MemorySanitizer
 SANITIZER("memory", Memory)

diff  --git a/clang/include/clang/Driver/SanitizerArgs.h 
b/clang/include/clang/Driver/SanitizerArgs.h
index a681ad3b2e05b..1b29b1151224f 100644
--- a/clang/include/clang/Driver/SanitizerArgs.h
+++ b/clang/include/clang/Driver/SanitizerArgs.h
@@ -99,13 +99,18 @@ class SanitizerArgs {
   bool needsStatsRt() const { return Stats; }
   bool needsScudoRt() const { return Sanitizers.has(SanitizerKind::Scudo); }
 
-  bool hasMemTag() const { return hasMemtagHeap() || hasMemtagStack(); }
+  bool hasMemTag() const {
+return hasMemtagHeap() || hasMemtagStack() || hasMemtagGlobals();
+  }
   bool hasMemtagHeap() const {
 return Sanitizers.has(SanitizerKind::MemtagHeap);
   }
   bool hasMemtagStack() const {
 return Sanitizers.has(SanitizerKind::MemtagStack);
   }
+  bool hasMemtagGlobals() const {
+return Sanitizers.has(SanitizerKind::MemtagGlobals);
+  }
   const std::string () const {
 assert(!MemtagMode.empty());
 return MemtagMode;

diff  --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index 9ebcc9e76e228..edb1bfbe9bdf8 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -45,7 +45,8 @@ static const SanitizerMask SupportsCoverage =
 SanitizerKind::Address | SanitizerKind::HWAddress |
 SanitizerKind::KernelAddress | SanitizerKind::KernelHWAddress |
 SanitizerKind::MemtagStack | SanitizerKind::MemtagHeap |
-SanitizerKind::Memory | SanitizerKind::KernelMemory | SanitizerKind::Leak |
+SanitizerKind::MemtagGlobals | SanitizerKind::Memory |
+SanitizerKind::KernelMemory | SanitizerKind::Leak |
 SanitizerKind::Undefined | SanitizerKind::Integer | SanitizerKind::Bounds |
 SanitizerKind::ImplicitConversion | SanitizerKind::Nullability |
 SanitizerKind::DataFlow | SanitizerKind::Fuzzer |
@@ -73,7 +74,8 @@ static const SanitizerMask CFIClasses =
 SanitizerKind::CFIUnrelatedCast;
 static const SanitizerMask CompatibleWithMinimalRuntime =
 TrappingSupported | SanitizerKind::Scudo | SanitizerKind::ShadowCallStack |
-SanitizerKind::MemtagStack | SanitizerKind::MemtagHeap;
+SanitizerKind::MemtagStack | SanitizerKind::MemtagHeap |
+SanitizerKind::MemtagGlobals;
 
 enum CoverageFeature {
   CoverageFunc = 1 << 0,

diff  --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index 75587f8ddc5f0..1d97e99058b9e 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -193,9 +193,9 @@
 // RUN: %clang -target x86_64-linux-android -fsanitize=memtag -fno-rtti %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-SANMT-BAD-ARCH
 // CHECK-SANMT-BAD-ARCH: unsupported option '-fsanitize=memtag' for target
 
-// RUN: %clang -target aarch64-linux 

[clang] 2a5d567 - Fix-forward broken ASan test on Windows.

2022-06-13 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-06-13T14:23:23-07:00
New Revision: 2a5d567041565a2c6b8bc8aa7845ad176dbf5d54

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

LOG: Fix-forward broken ASan test on Windows.

Hopefully the final whack-a-mole.

Relevant differential revision: https://reviews.llvm.org/D126929

Added: 


Modified: 
clang/test/CodeGen/sanitize-init-order.cpp

Removed: 




diff  --git a/clang/test/CodeGen/sanitize-init-order.cpp 
b/clang/test/CodeGen/sanitize-init-order.cpp
index f3cc2c3387969..dd7e3c5b4b124 100644
--- a/clang/test/CodeGen/sanitize-init-order.cpp
+++ b/clang/test/CodeGen/sanitize-init-order.cpp
@@ -37,11 +37,11 @@ const volatile PODWithCtor array[5][5];
 // Check that ASan init-order checking ignores structs with trivial default
 // constructor.
 
-// CHECK: @s1 ={{.*}} global
+// CHECK: @{{.*}}s1{{.*}} ={{.*}} global
 // CHECK-NOT: sanitize_address_dyninit
-// CHECK: @s2 ={{.*}} global
+// CHECK: @{{.*}}s2{{.*}} ={{.*}} global
 // CHECK-NOT: sanitize_address_dyninit
-// CHECK: @s3 ={{.*}} global {{.*}}, sanitize_address_dyninit
+// CHECK: @{{.*}}s3{{.*}} ={{.*}} global {{.*}}, sanitize_address_dyninit
 // CHECK: @{{.*}}array{{.*}} ={{.*}} global {{.*}}, sanitize_address_dyninit
 
 // CHECK: !llvm.asan.globals = !{![[GLOB_1:[0-9]+]], ![[GLOB_2:[0-9]+]], 
![[GLOB_3:[0-9]+]], ![[GLOB_4:[0-9]+]]
@@ -50,11 +50,11 @@ const volatile PODWithCtor array[5][5];
 // CHECK: ![[GLOB_3]] = !{%struct.PODWithCtorAndDtor* {{.*}}, i1 true, i1 
false}
 // CHECK: ![[GLOB_4]] = !{{{.*}}class.NS::PODWithCtor{{.*}}, i1 true, i1 false}
 
-// IGNORELIST: @s1 ={{.*}} global
+// IGNORELIST: @{{.*}}s1{{.*}} ={{.*}} global
 // IGNORELIST-NOT: sanitize_address_dyninit
-// IGNORELIST: @s2 ={{.*}} global
+// IGNORELIST: @{{.*}}s2{{.*}} ={{.*}} global
 // IGNORELIST-NOT: sanitize_address_dyninit
-// IGNORELIST: @s3 ={{.*}} global
+// IGNORELIST: @{{.*}}s3{{.*}} ={{.*}} global
 // IGNORELIST-NOT: sanitize_address_dyninit
 // IGNORELIST: @{{.*}}array{{.*}} ={{.*}} global
 // IGNORELIST-NOT: sanitize_address_dyninit



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


[clang] 77475ff - Reland "Add sanitizer metadata attributes to clang IR gen."

2022-06-13 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-06-13T12:23:27-07:00
New Revision: 77475ffd22418ca7249f5457dddba15ab7cda0cc

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

LOG: Reland "Add sanitizer metadata attributes to clang IR gen."

RE-LAND (reverts a revert):
This reverts commit 8e1f47b596b28fbc88cf32e8f46eb2fecb145fb2.

This patch adds generation of sanitizer metadata attributes (which were
added in D126100) to the clang frontend.

We still currently generate the llvm.asan.globals that's consumed by
the IR pass, but the plan is to eventually migrate off of that onto
purely debuginfo and these IR attributes.

Reviewed By: vitalybuka, kstoimenov

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

Added: 
clang/test/CodeGen/Inputs/sanitizer-special-case-list-globals.txt
clang/test/CodeGen/sanitizer-special-case-list-globals.c

Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/SanitizerMetadata.cpp
clang/lib/CodeGen/SanitizerMetadata.h
clang/test/CodeGen/asan-globals.cpp
clang/test/CodeGen/sanitize-init-order.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 95d1a4c5f1bcf..05738c03796be 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2760,21 +2760,14 @@ bool CodeGenModule::isInNoSanitizeList(SanitizerMask 
Kind, llvm::Function *Fn,
   return false;
 }
 
-bool CodeGenModule::isInNoSanitizeList(llvm::GlobalVariable *GV,
+bool CodeGenModule::isInNoSanitizeList(SanitizerMask Kind,
+   llvm::GlobalVariable *GV,
SourceLocation Loc, QualType Ty,
StringRef Category) const {
-  // For now globals can be ignored only in ASan and KASan.
-  const SanitizerMask EnabledAsanMask =
-  LangOpts.Sanitize.Mask &
-  (SanitizerKind::Address | SanitizerKind::KernelAddress |
-   SanitizerKind::HWAddress | SanitizerKind::KernelHWAddress |
-   SanitizerKind::MemTag);
-  if (!EnabledAsanMask)
-return false;
   const auto  = getContext().getNoSanitizeList();
-  if (NoSanitizeL.containsGlobal(EnabledAsanMask, GV->getName(), Category))
+  if (NoSanitizeL.containsGlobal(Kind, GV->getName(), Category))
 return true;
-  if (NoSanitizeL.containsLocation(EnabledAsanMask, Loc, Category))
+  if (NoSanitizeL.containsLocation(Kind, Loc, Category))
 return true;
   // Check global type.
   if (!Ty.isNull()) {
@@ -2786,7 +2779,7 @@ bool 
CodeGenModule::isInNoSanitizeList(llvm::GlobalVariable *GV,
 // Only record types (classes, structs etc.) are ignored.
 if (Ty->isRecordType()) {
   std::string TypeStr = Ty.getAsString(getContext().getPrintingPolicy());
-  if (NoSanitizeL.containsType(EnabledAsanMask, TypeStr, Category))
+  if (NoSanitizeL.containsType(Kind, TypeStr, Category))
 return true;
 }
   }

diff  --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index 5097ef018942a..779d94ad62d98 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1314,8 +1314,9 @@ class CodeGenModule : public CodeGenTypeCache {
   bool isInNoSanitizeList(SanitizerMask Kind, llvm::Function *Fn,
   SourceLocation Loc) const;
 
-  bool isInNoSanitizeList(llvm::GlobalVariable *GV, SourceLocation Loc,
-  QualType Ty, StringRef Category = StringRef()) const;
+  bool isInNoSanitizeList(SanitizerMask Kind, llvm::GlobalVariable *GV,
+  SourceLocation Loc, QualType Ty,
+  StringRef Category = StringRef()) const;
 
   /// Imbue XRay attributes to a function, applying the always/never attribute
   /// lists in the process. Returns true if we did imbue attributes this way,

diff  --git a/clang/lib/CodeGen/SanitizerMetadata.cpp 
b/clang/lib/CodeGen/SanitizerMetadata.cpp
index 8127e15192612..c3e23c31b37a4 100644
--- a/clang/lib/CodeGen/SanitizerMetadata.cpp
+++ b/clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -22,19 +22,66 @@ using namespace CodeGen;
 
 SanitizerMetadata::SanitizerMetadata(CodeGenModule ) : CGM(CGM) {}
 
+// TODO(hctim): Can be removed when we migrate off of llvm.asan.globals. This
+// prevents llvm.asan.globals from being emitted for
+// __attribute__((disable_sanitizer_instrumentation)) and uses of
+// -fsanitize-ignorelist when a sanitizer isn't enabled.
 static bool isAsanHwasanOrMemTag(const SanitizerSet ) {
   return SS.hasOneOf(SanitizerKind::Address | SanitizerKind::KernelAddress |
- SanitizerKind::HWAddress | SanitizerKind::KernelHWAddress 
|
- SanitizerKind::MemTag);
+

[clang] 8e1f47b - Revert "Add sanitizer metadata attributes to clang IR gen."

2022-06-13 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-06-13T12:11:13-07:00
New Revision: 8e1f47b596b28fbc88cf32e8f46eb2fecb145fb2

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

LOG: Revert "Add sanitizer metadata attributes to clang IR gen."

This reverts commit e7766972a6790e25dbb4ce3481f57e9792b49269.

Broke the Windows buildbots.

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/SanitizerMetadata.cpp
clang/lib/CodeGen/SanitizerMetadata.h
clang/test/CodeGen/asan-globals.cpp
clang/test/CodeGen/sanitize-init-order.cpp

Removed: 
clang/test/CodeGen/Inputs/sanitizer-special-case-list-globals.txt
clang/test/CodeGen/sanitizer-special-case-list-globals.c



diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 05738c03796be..95d1a4c5f1bcf 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2760,14 +2760,21 @@ bool CodeGenModule::isInNoSanitizeList(SanitizerMask 
Kind, llvm::Function *Fn,
   return false;
 }
 
-bool CodeGenModule::isInNoSanitizeList(SanitizerMask Kind,
-   llvm::GlobalVariable *GV,
+bool CodeGenModule::isInNoSanitizeList(llvm::GlobalVariable *GV,
SourceLocation Loc, QualType Ty,
StringRef Category) const {
+  // For now globals can be ignored only in ASan and KASan.
+  const SanitizerMask EnabledAsanMask =
+  LangOpts.Sanitize.Mask &
+  (SanitizerKind::Address | SanitizerKind::KernelAddress |
+   SanitizerKind::HWAddress | SanitizerKind::KernelHWAddress |
+   SanitizerKind::MemTag);
+  if (!EnabledAsanMask)
+return false;
   const auto  = getContext().getNoSanitizeList();
-  if (NoSanitizeL.containsGlobal(Kind, GV->getName(), Category))
+  if (NoSanitizeL.containsGlobal(EnabledAsanMask, GV->getName(), Category))
 return true;
-  if (NoSanitizeL.containsLocation(Kind, Loc, Category))
+  if (NoSanitizeL.containsLocation(EnabledAsanMask, Loc, Category))
 return true;
   // Check global type.
   if (!Ty.isNull()) {
@@ -2779,7 +2786,7 @@ bool CodeGenModule::isInNoSanitizeList(SanitizerMask Kind,
 // Only record types (classes, structs etc.) are ignored.
 if (Ty->isRecordType()) {
   std::string TypeStr = Ty.getAsString(getContext().getPrintingPolicy());
-  if (NoSanitizeL.containsType(Kind, TypeStr, Category))
+  if (NoSanitizeL.containsType(EnabledAsanMask, TypeStr, Category))
 return true;
 }
   }

diff  --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index 779d94ad62d98..5097ef018942a 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1314,9 +1314,8 @@ class CodeGenModule : public CodeGenTypeCache {
   bool isInNoSanitizeList(SanitizerMask Kind, llvm::Function *Fn,
   SourceLocation Loc) const;
 
-  bool isInNoSanitizeList(SanitizerMask Kind, llvm::GlobalVariable *GV,
-  SourceLocation Loc, QualType Ty,
-  StringRef Category = StringRef()) const;
+  bool isInNoSanitizeList(llvm::GlobalVariable *GV, SourceLocation Loc,
+  QualType Ty, StringRef Category = StringRef()) const;
 
   /// Imbue XRay attributes to a function, applying the always/never attribute
   /// lists in the process. Returns true if we did imbue attributes this way,

diff  --git a/clang/lib/CodeGen/SanitizerMetadata.cpp 
b/clang/lib/CodeGen/SanitizerMetadata.cpp
index c3e23c31b37a4..8127e15192612 100644
--- a/clang/lib/CodeGen/SanitizerMetadata.cpp
+++ b/clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -22,66 +22,19 @@ using namespace CodeGen;
 
 SanitizerMetadata::SanitizerMetadata(CodeGenModule ) : CGM(CGM) {}
 
-// TODO(hctim): Can be removed when we migrate off of llvm.asan.globals. This
-// prevents llvm.asan.globals from being emitted for
-// __attribute__((disable_sanitizer_instrumentation)) and uses of
-// -fsanitize-ignorelist when a sanitizer isn't enabled.
 static bool isAsanHwasanOrMemTag(const SanitizerSet ) {
   return SS.hasOneOf(SanitizerKind::Address | SanitizerKind::KernelAddress |
- SanitizerKind::HWAddress | SanitizerKind::MemTag);
-}
-
-SanitizerMask expandKernelSanitizerMasks(SanitizerMask Mask) {
-  if (Mask & (SanitizerKind::Address | SanitizerKind::KernelAddress))
-Mask |= SanitizerKind::Address | SanitizerKind::KernelAddress;
-  // Note: KHWASan doesn't support globals.
-  return Mask;
+ SanitizerKind::HWAddress | SanitizerKind::KernelHWAddress 
|
+ SanitizerKind::MemTag);
 }
 
 void SanitizerMetadata::reportGlobal(llvm::GlobalVariable 

[clang] e776697 - Add sanitizer metadata attributes to clang IR gen.

2022-06-13 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-06-13T11:19:15-07:00
New Revision: e7766972a6790e25dbb4ce3481f57e9792b49269

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

LOG: Add sanitizer metadata attributes to clang IR gen.

This patch adds generation of sanitizer metadata attributes (which were
added in D126100) to the clang frontend.

We still currently generate the `llvm.asan.globals` that's consumed by
the IR pass, but the plan is to eventually migrate off of that onto
purely debuginfo and these IR attributes.

Reviewed By: vitalybuka, kstoimenov

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

Added: 
clang/test/CodeGen/Inputs/sanitizer-special-case-list-globals.txt
clang/test/CodeGen/sanitizer-special-case-list-globals.c

Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/SanitizerMetadata.cpp
clang/lib/CodeGen/SanitizerMetadata.h
clang/test/CodeGen/asan-globals.cpp
clang/test/CodeGen/sanitize-init-order.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 95d1a4c5f1bcf..05738c03796be 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2760,21 +2760,14 @@ bool CodeGenModule::isInNoSanitizeList(SanitizerMask 
Kind, llvm::Function *Fn,
   return false;
 }
 
-bool CodeGenModule::isInNoSanitizeList(llvm::GlobalVariable *GV,
+bool CodeGenModule::isInNoSanitizeList(SanitizerMask Kind,
+   llvm::GlobalVariable *GV,
SourceLocation Loc, QualType Ty,
StringRef Category) const {
-  // For now globals can be ignored only in ASan and KASan.
-  const SanitizerMask EnabledAsanMask =
-  LangOpts.Sanitize.Mask &
-  (SanitizerKind::Address | SanitizerKind::KernelAddress |
-   SanitizerKind::HWAddress | SanitizerKind::KernelHWAddress |
-   SanitizerKind::MemTag);
-  if (!EnabledAsanMask)
-return false;
   const auto  = getContext().getNoSanitizeList();
-  if (NoSanitizeL.containsGlobal(EnabledAsanMask, GV->getName(), Category))
+  if (NoSanitizeL.containsGlobal(Kind, GV->getName(), Category))
 return true;
-  if (NoSanitizeL.containsLocation(EnabledAsanMask, Loc, Category))
+  if (NoSanitizeL.containsLocation(Kind, Loc, Category))
 return true;
   // Check global type.
   if (!Ty.isNull()) {
@@ -2786,7 +2779,7 @@ bool 
CodeGenModule::isInNoSanitizeList(llvm::GlobalVariable *GV,
 // Only record types (classes, structs etc.) are ignored.
 if (Ty->isRecordType()) {
   std::string TypeStr = Ty.getAsString(getContext().getPrintingPolicy());
-  if (NoSanitizeL.containsType(EnabledAsanMask, TypeStr, Category))
+  if (NoSanitizeL.containsType(Kind, TypeStr, Category))
 return true;
 }
   }

diff  --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index 5097ef018942a..779d94ad62d98 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1314,8 +1314,9 @@ class CodeGenModule : public CodeGenTypeCache {
   bool isInNoSanitizeList(SanitizerMask Kind, llvm::Function *Fn,
   SourceLocation Loc) const;
 
-  bool isInNoSanitizeList(llvm::GlobalVariable *GV, SourceLocation Loc,
-  QualType Ty, StringRef Category = StringRef()) const;
+  bool isInNoSanitizeList(SanitizerMask Kind, llvm::GlobalVariable *GV,
+  SourceLocation Loc, QualType Ty,
+  StringRef Category = StringRef()) const;
 
   /// Imbue XRay attributes to a function, applying the always/never attribute
   /// lists in the process. Returns true if we did imbue attributes this way,

diff  --git a/clang/lib/CodeGen/SanitizerMetadata.cpp 
b/clang/lib/CodeGen/SanitizerMetadata.cpp
index 8127e15192612..c3e23c31b37a4 100644
--- a/clang/lib/CodeGen/SanitizerMetadata.cpp
+++ b/clang/lib/CodeGen/SanitizerMetadata.cpp
@@ -22,19 +22,66 @@ using namespace CodeGen;
 
 SanitizerMetadata::SanitizerMetadata(CodeGenModule ) : CGM(CGM) {}
 
+// TODO(hctim): Can be removed when we migrate off of llvm.asan.globals. This
+// prevents llvm.asan.globals from being emitted for
+// __attribute__((disable_sanitizer_instrumentation)) and uses of
+// -fsanitize-ignorelist when a sanitizer isn't enabled.
 static bool isAsanHwasanOrMemTag(const SanitizerSet ) {
   return SS.hasOneOf(SanitizerKind::Address | SanitizerKind::KernelAddress |
- SanitizerKind::HWAddress | SanitizerKind::KernelHWAddress 
|
- SanitizerKind::MemTag);
+ SanitizerKind::HWAddress | SanitizerKind::MemTag);
+}
+
+SanitizerMask 

[clang] d3ddc25 - Revert "[CodeGen] Keep track info of lazy-emitted symbols in ModuleBuilder"

2022-06-13 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-06-13T10:12:38-07:00
New Revision: d3ddc251acae631bf5ab4da13878f7e8b5b5a451

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

LOG: Revert "[CodeGen] Keep track info of lazy-emitted symbols in ModuleBuilder"

This reverts commit b8f9459715815fa055b3e1c5f970c616797dfcfb.

Broke the ASan buildbot. See https://reviews.llvm.org/D126781 for more
information.

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/ModuleBuilder.cpp
clang/test/Interpreter/execute.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index b7c180f1c8859..0ac476dd6dbcc 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1477,31 +1477,6 @@ class CodeGenModule : public CodeGenTypeCache {
   void printPostfixForExternalizedDecl(llvm::raw_ostream ,
const Decl *D) const;
 
-  /// Move some lazily-emitted states to the NewBuilder. This is especially
-  /// essential for the incremental parsing environment like Clang Interpreter,
-  /// because we'll lose all important information after each repl.
-  void moveLazyEmissionStates(CodeGenModule *NewBuilder) {
-assert(DeferredDeclsToEmit.empty() &&
-   "Should have emitted all decls deferred to emit.");
-assert(NewBuilder->DeferredDecls.empty() &&
-   "Newly created module should not have deferred decls");
-NewBuilder->DeferredDecls = std::move(DeferredDecls);
-
-assert(NewBuilder->DeferredVTables.empty() &&
-   "Newly created module should not have deferred vtables");
-NewBuilder->DeferredVTables = std::move(DeferredVTables);
-
-assert(NewBuilder->MangledDeclNames.empty() &&
-   "Newly created module should not have mangled decl names");
-assert(NewBuilder->Manglings.empty() &&
-   "Newly created module should not have manglings");
-NewBuilder->Manglings = std::move(Manglings);
-
-assert(WeakRefReferences.empty() &&
-   "Not all WeakRefRefs have been applied");
-NewBuilder->TBAA = std::move(TBAA);
-  }
-
 private:
   llvm::Constant *GetOrCreateLLVMFunction(
   StringRef MangledName, llvm::Type *Ty, GlobalDecl D, bool ForVTable,

diff  --git a/clang/lib/CodeGen/ModuleBuilder.cpp 
b/clang/lib/CodeGen/ModuleBuilder.cpp
index 8e97a298ce7fa..50b7fd8eb993c 100644
--- a/clang/lib/CodeGen/ModuleBuilder.cpp
+++ b/clang/lib/CodeGen/ModuleBuilder.cpp
@@ -134,14 +134,7 @@ namespace {
   llvm::LLVMContext ) {
   assert(!M && "Replacing existing Module?");
   M.reset(new llvm::Module(ExpandModuleName(ModuleName, CodeGenOpts), C));
-
-  std::unique_ptr OldBuilder = std::move(Builder);
-
   Initialize(*Ctx);
-
-  if (OldBuilder)
-OldBuilder->moveLazyEmissionStates(Builder.get());
-
   return M.get();
 }
 

diff  --git a/clang/test/Interpreter/execute.cpp 
b/clang/test/Interpreter/execute.cpp
index 61e68990acf96..298046c068c37 100644
--- a/clang/test/Interpreter/execute.cpp
+++ b/clang/test/Interpreter/execute.cpp
@@ -13,8 +13,4 @@ struct S { float f = 1.0; S *m = nullptr;} s;
 
 auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, reinterpret_cast(s.m));
 // CHECK-NEXT: S[f=1.00, m=0x0]
-
-inline int foo() { return 42; }
-int r3 = foo();
-
 quit



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


[clang] d90eecf - Revert "Also move WeakRefReferences in CodeGenModule::moveLazyEmssionStates"

2022-06-13 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-06-13T10:12:38-07:00
New Revision: d90eecff5c9e7e9f8263de6cd72d70322400829f

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

LOG: Revert "Also move WeakRefReferences in 
CodeGenModule::moveLazyEmssionStates"

This reverts commit 0ecbedc0986bd4b7b90a60a5f31d32337160d4c4.

Parent change broke the ASan buildbot. See
https://reviews.llvm.org/D126781 for more information.

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.h

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index 1eaeeb880597e..b7c180f1c8859 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1499,8 +1499,6 @@ class CodeGenModule : public CodeGenTypeCache {
 
 assert(WeakRefReferences.empty() &&
"Not all WeakRefRefs have been applied");
-NewBuilder->WeakRefReferences = std::move(WeakRefReferences);
-
 NewBuilder->TBAA = std::move(TBAA);
   }
 



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


[clang] 7aa1fa0 - Reland "[dwarf] Emit a DIGlobalVariable for constant strings."

2022-05-18 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-05-18T13:56:45-07:00
New Revision: 7aa1fa0a0a07f7949d2d77c099aab43cf9b75a91

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

LOG: Reland "[dwarf] Emit a DIGlobalVariable for constant strings."

An upcoming patch will extend llvm-symbolizer to provide the source line
information for global variables. The goal is to move AddressSanitizer
off of internal debug info for symbolization onto the DWARF standard
(and doing a clean-up in the process). Currently, ASan reports the line
information for constant strings if a memory safety bug happens around
them. We want to keep this behaviour, so we need to emit debuginfo for
these variables as well.

Reviewed By: dblaikie, rnk, aprantl

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

Added: 
clang/test/CodeGen/debug-info-variables.c
llvm/test/DebugInfo/COFF/global-no-strings.ll

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/VFS/external-names.c
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp

Removed: 
llvm/test/Assembler/invalid-diglobalvariable-missing-name.ll



diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 3d73bfb8ce79..753427029441 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -5132,7 +5132,7 @@ std::string CGDebugInfo::GetName(const Decl *D, bool 
Qualified) const {
 return Name;
   codegenoptions::DebugTemplateNamesKind TemplateNamesKind =
   CGM.getCodeGenOpts().getDebugSimpleTemplateNames();
-  
+
   if (!CGM.getCodeGenOpts().hasReducedDebugInfo())
 TemplateNamesKind = codegenoptions::DebugTemplateNamesKind::Full;
 
@@ -5459,6 +5459,21 @@ void CGDebugInfo::EmitGlobalAlias(const 
llvm::GlobalValue *GV,
   ImportedDeclCache[GD.getCanonicalDecl().getDecl()].reset(ImportDI);
 }
 
+void CGDebugInfo::AddStringLiteralDebugInfo(llvm::GlobalVariable *GV,
+const StringLiteral *S) {
+  SourceLocation Loc = S->getStrTokenLoc(0);
+  PresumedLoc PLoc = CGM.getContext().getSourceManager().getPresumedLoc(Loc);
+  if (!PLoc.isValid())
+return;
+
+  llvm::DIFile *File = getOrCreateFile(Loc);
+  llvm::DIGlobalVariableExpression *Debug =
+  DBuilder.createGlobalVariableExpression(
+  nullptr, StringRef(), StringRef(), getOrCreateFile(Loc),
+  getLineNumber(Loc), getOrCreateType(S->getType(), File), true);
+  GV->addDebugInfo(Debug);
+}
+
 llvm::DIScope *CGDebugInfo::getCurrentContextDescriptor(const Decl *D) {
   if (!LexicalBlockStack.empty())
 return LexicalBlockStack.back();

diff  --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 8984f3eb1d7a..38e3fa5b2fa9 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -533,6 +533,14 @@ class CGDebugInfo {
   /// Emit an @import declaration.
   void EmitImportDecl(const ImportDecl );
 
+  /// DebugInfo isn't attached to string literals by default. While certain
+  /// aspects of debuginfo aren't useful for string literals (like a name), 
it's
+  /// nice to be able to symbolize the line and column information. This is
+  /// especially useful for sanitizers, as it allows symbolization of
+  /// heap-buffer-overflows on constant strings.
+  void AddStringLiteralDebugInfo(llvm::GlobalVariable *GV,
+ const StringLiteral *S);
+
   /// Emit C++ namespace alias.
   llvm::DIImportedEntity *EmitNamespaceAlias(const NamespaceAliasDecl );
 

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index f8bf210dc0e2..703cf4edf5f5 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5670,6 +5670,11 @@ CodeGenModule::GetAddrOfConstantStringFromLiteral(const 
StringLiteral *S,
   }
 
   auto GV = GenerateStringLiteral(C, LT, *this, GlobalVariableName, Alignment);
+
+  CGDebugInfo *DI = getModuleDebugInfo();
+  if (DI && getCodeGenOpts().hasReducedDebugInfo())
+DI->AddStringLiteralDebugInfo(GV, S);
+
   if (Entry)
 *Entry = GV;
 

diff  --git a/clang/test/CodeGen/debug-info-variables.c 
b/clang/test/CodeGen/debug-info-variables.c
new file mode 100644
index ..8ec60ff7c1d9
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-variables.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -debug-info-kind=standalone -S -emit-llvm -o - | 
FileCheck %s
+
+// CHECK: DIGlobalVariable(name: "global",{{.*}} line: [[@LINE+1]]
+int global = 42;
+
+// CHECK: DIGlobalVariable({{.*}}line: [[@LINE+4]],{{.*}} type: 
[[TYPEID:![0-9]+]]
+// CHECK: [[TYPEID]] = 

[clang] ed2c321 - Revert "[dwarf] Emit a DIGlobalVariable for constant strings."

2022-05-16 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-05-16T19:07:38-07:00
New Revision: ed2c3218f5badf88cb7897fabf8faa01e8aa2044

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

LOG: Revert "[dwarf] Emit a DIGlobalVariable for constant strings."

This reverts commit 4680982b36a84770a1600fc438be8ec090671724.

Broke a fuchsia windows bot. More details in the review:
https://reviews.llvm.org/D123534

Added: 
llvm/test/Assembler/invalid-diglobalvariable-missing-name.ll

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/VFS/external-names.c
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp

Removed: 
clang/test/CodeGen/debug-info-variables.c
llvm/test/DebugInfo/COFF/global-no-strings.ll



diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 7534270294415..3d73bfb8ce793 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -5132,7 +5132,7 @@ std::string CGDebugInfo::GetName(const Decl *D, bool 
Qualified) const {
 return Name;
   codegenoptions::DebugTemplateNamesKind TemplateNamesKind =
   CGM.getCodeGenOpts().getDebugSimpleTemplateNames();
-
+  
   if (!CGM.getCodeGenOpts().hasReducedDebugInfo())
 TemplateNamesKind = codegenoptions::DebugTemplateNamesKind::Full;
 
@@ -5459,21 +5459,6 @@ void CGDebugInfo::EmitGlobalAlias(const 
llvm::GlobalValue *GV,
   ImportedDeclCache[GD.getCanonicalDecl().getDecl()].reset(ImportDI);
 }
 
-void CGDebugInfo::AddStringLiteralDebugInfo(llvm::GlobalVariable *GV,
-const StringLiteral *S) {
-  SourceLocation Loc = S->getStrTokenLoc(0);
-  PresumedLoc PLoc = CGM.getContext().getSourceManager().getPresumedLoc(Loc);
-  if (!PLoc.isValid())
-return;
-
-  llvm::DIFile *File = getOrCreateFile(Loc);
-  llvm::DIGlobalVariableExpression *Debug =
-  DBuilder.createGlobalVariableExpression(
-  nullptr, StringRef(), StringRef(), getOrCreateFile(Loc),
-  getLineNumber(Loc), getOrCreateType(S->getType(), File), true);
-  GV->addDebugInfo(Debug);
-}
-
 llvm::DIScope *CGDebugInfo::getCurrentContextDescriptor(const Decl *D) {
   if (!LexicalBlockStack.empty())
 return LexicalBlockStack.back();

diff  --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 38e3fa5b2fa96..8984f3eb1d7a0 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -533,14 +533,6 @@ class CGDebugInfo {
   /// Emit an @import declaration.
   void EmitImportDecl(const ImportDecl );
 
-  /// DebugInfo isn't attached to string literals by default. While certain
-  /// aspects of debuginfo aren't useful for string literals (like a name), 
it's
-  /// nice to be able to symbolize the line and column information. This is
-  /// especially useful for sanitizers, as it allows symbolization of
-  /// heap-buffer-overflows on constant strings.
-  void AddStringLiteralDebugInfo(llvm::GlobalVariable *GV,
- const StringLiteral *S);
-
   /// Emit C++ namespace alias.
   llvm::DIImportedEntity *EmitNamespaceAlias(const NamespaceAliasDecl );
 

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 703cf4edf5f56..f8bf210dc0e21 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5670,11 +5670,6 @@ CodeGenModule::GetAddrOfConstantStringFromLiteral(const 
StringLiteral *S,
   }
 
   auto GV = GenerateStringLiteral(C, LT, *this, GlobalVariableName, Alignment);
-
-  CGDebugInfo *DI = getModuleDebugInfo();
-  if (DI && getCodeGenOpts().hasReducedDebugInfo())
-DI->AddStringLiteralDebugInfo(GV, S);
-
   if (Entry)
 *Entry = GV;
 

diff  --git a/clang/test/CodeGen/debug-info-variables.c 
b/clang/test/CodeGen/debug-info-variables.c
deleted file mode 100644
index 1e3b4fb979d7a..0
--- a/clang/test/CodeGen/debug-info-variables.c
+++ /dev/null
@@ -1,19 +0,0 @@
-// RUN: %clang_cc1 %s -debug-info-kind=standalone -S -emit-llvm -o - | 
FileCheck %s
-
-// CHECK: DIGlobalVariable(name: "global",{{.*}} line: [[@LINE+1]]
-int global = 42;
-
-// CHECK: DIGlobalVariable({{.*}}line: [[@LINE+4]],{{.*}} type: 
[[TYPEID:![0-9]+]]
-// CHECK: [[TYPEID]] = !DICompositeType(tag: DW_TAG_array_type, baseType: 
[[BASETYPE:![0-9]+]]
-// CHECK: [[BASETYPE]] = !DIBasicType(name: "char"
-const char* s() {
-  return "1234567890";
-}
-
-// CHECK: DILocalVariable(name: "p"
-// CHECK: DILocalVariable(name: "q"
-// CHECK: DILocalVariable(name: "r"
-int sum(int p, int q) {
-  int r = p + q;
-  return r;
-}

diff  --git a/clang/test/VFS/external-names.c 

[clang] 4680982 - [dwarf] Emit a DIGlobalVariable for constant strings.

2022-05-16 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-05-16T16:52:16-07:00
New Revision: 4680982b36a84770a1600fc438be8ec090671724

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

LOG: [dwarf] Emit a DIGlobalVariable for constant strings.

An upcoming patch will extend llvm-symbolizer to provide the source line
information for global variables. The goal is to move AddressSanitizer
off of internal debug info for symbolization onto the DWARF standard
(and doing a clean-up in the process). Currently, ASan reports the line
information for constant strings if a memory safety bug happens around
them. We want to keep this behaviour, so we need to emit debuginfo for
these variables as well.

Reviewed By: dblaikie, rnk, aprantl

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

Added: 
clang/test/CodeGen/debug-info-variables.c
llvm/test/DebugInfo/COFF/global-no-strings.ll

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/VFS/external-names.c
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp

Removed: 
llvm/test/Assembler/invalid-diglobalvariable-missing-name.ll



diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 3d73bfb8ce793..7534270294415 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -5132,7 +5132,7 @@ std::string CGDebugInfo::GetName(const Decl *D, bool 
Qualified) const {
 return Name;
   codegenoptions::DebugTemplateNamesKind TemplateNamesKind =
   CGM.getCodeGenOpts().getDebugSimpleTemplateNames();
-  
+
   if (!CGM.getCodeGenOpts().hasReducedDebugInfo())
 TemplateNamesKind = codegenoptions::DebugTemplateNamesKind::Full;
 
@@ -5459,6 +5459,21 @@ void CGDebugInfo::EmitGlobalAlias(const 
llvm::GlobalValue *GV,
   ImportedDeclCache[GD.getCanonicalDecl().getDecl()].reset(ImportDI);
 }
 
+void CGDebugInfo::AddStringLiteralDebugInfo(llvm::GlobalVariable *GV,
+const StringLiteral *S) {
+  SourceLocation Loc = S->getStrTokenLoc(0);
+  PresumedLoc PLoc = CGM.getContext().getSourceManager().getPresumedLoc(Loc);
+  if (!PLoc.isValid())
+return;
+
+  llvm::DIFile *File = getOrCreateFile(Loc);
+  llvm::DIGlobalVariableExpression *Debug =
+  DBuilder.createGlobalVariableExpression(
+  nullptr, StringRef(), StringRef(), getOrCreateFile(Loc),
+  getLineNumber(Loc), getOrCreateType(S->getType(), File), true);
+  GV->addDebugInfo(Debug);
+}
+
 llvm::DIScope *CGDebugInfo::getCurrentContextDescriptor(const Decl *D) {
   if (!LexicalBlockStack.empty())
 return LexicalBlockStack.back();

diff  --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 8984f3eb1d7a0..38e3fa5b2fa96 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -533,6 +533,14 @@ class CGDebugInfo {
   /// Emit an @import declaration.
   void EmitImportDecl(const ImportDecl );
 
+  /// DebugInfo isn't attached to string literals by default. While certain
+  /// aspects of debuginfo aren't useful for string literals (like a name), 
it's
+  /// nice to be able to symbolize the line and column information. This is
+  /// especially useful for sanitizers, as it allows symbolization of
+  /// heap-buffer-overflows on constant strings.
+  void AddStringLiteralDebugInfo(llvm::GlobalVariable *GV,
+ const StringLiteral *S);
+
   /// Emit C++ namespace alias.
   llvm::DIImportedEntity *EmitNamespaceAlias(const NamespaceAliasDecl );
 

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index f8bf210dc0e21..703cf4edf5f56 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5670,6 +5670,11 @@ CodeGenModule::GetAddrOfConstantStringFromLiteral(const 
StringLiteral *S,
   }
 
   auto GV = GenerateStringLiteral(C, LT, *this, GlobalVariableName, Alignment);
+
+  CGDebugInfo *DI = getModuleDebugInfo();
+  if (DI && getCodeGenOpts().hasReducedDebugInfo())
+DI->AddStringLiteralDebugInfo(GV, S);
+
   if (Entry)
 *Entry = GV;
 

diff  --git a/clang/test/CodeGen/debug-info-variables.c 
b/clang/test/CodeGen/debug-info-variables.c
new file mode 100644
index 0..1e3b4fb979d7a
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-variables.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -debug-info-kind=standalone -S -emit-llvm -o - | 
FileCheck %s
+
+// CHECK: DIGlobalVariable(name: "global",{{.*}} line: [[@LINE+1]]
+int global = 42;
+
+// CHECK: DIGlobalVariable({{.*}}line: [[@LINE+4]],{{.*}} type: 
[[TYPEID:![0-9]+]]
+// CHECK: [[TYPEID]] = 

[clang] fa34951 - Reland "[MTE] Add -fsanitize=memtag* and friends."

2022-04-08 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-04-08T14:28:33-07:00
New Revision: fa34951fbc9bde7592897b0e81e99abd84c0bfd7

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

LOG: Reland "[MTE] Add -fsanitize=memtag* and friends."

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

Added: 
clang/test/Driver/memtag-ld.c
clang/test/Driver/memtag-stack.c
clang/test/Lexer/has_feature_memtag.cpp

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/Features.def
clang/include/clang/Basic/Sanitizers.def
clang/include/clang/Driver/Options.td
clang/include/clang/Driver/SanitizerArgs.h
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/SanitizerArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/CodeGen/memtag-attr.cpp
clang/test/Driver/fsanitize.c

Removed: 
clang/test/Driver/memtag.c
clang/test/Lexer/has_feature_memtag_sanitizer.cpp



diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 5909fb8ad73a4..1100f775ed6ab 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -483,7 +483,8 @@ def err_drv_ropi_incompatible_with_cxx : Error<
   "ROPI is not compatible with c++">;
 
 def err_stack_tagging_requires_hardware_feature : Error<
-  "'-fsanitize=memtag' requires hardware support (+memtag)">;
+  "'-fsanitize=memtag-stack' requires hardware support (+memtag). For Armv8 or 
"
+  "Armv9, try compiling with -march=armv8a+memtag or -march=armv9a+memtag">;
 
 def err_cmse_pi_are_incompatible : Error<
   "cmse is not compatible with %select{RWPI|ROPI}0">;

diff  --git a/clang/include/clang/Basic/Features.def 
b/clang/include/clang/Basic/Features.def
index 522ae5951499b..fbaa6174f9bff 100644
--- a/clang/include/clang/Basic/Features.def
+++ b/clang/include/clang/Basic/Features.def
@@ -45,7 +45,10 @@ FEATURE(leak_sanitizer,
 FEATURE(hwaddress_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress |
SanitizerKind::KernelHWAddress))
-FEATURE(memtag_sanitizer, LangOpts.Sanitize.has(SanitizerKind::MemTag))
+FEATURE(memtag_stack,
+LangOpts.Sanitize.has(SanitizerKind::MemtagStack))
+FEATURE(memtag_heap,
+LangOpts.Sanitize.has(SanitizerKind::MemtagHeap))
 FEATURE(xray_instrument, LangOpts.XRayInstrument)
 FEATURE(undefined_behavior_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined))

diff  --git a/clang/include/clang/Basic/Sanitizers.def 
b/clang/include/clang/Basic/Sanitizers.def
index 9b8936cc520cb..714934445cf95 100644
--- a/clang/include/clang/Basic/Sanitizers.def
+++ b/clang/include/clang/Basic/Sanitizers.def
@@ -56,7 +56,9 @@ SANITIZER("hwaddress", HWAddress)
 SANITIZER("kernel-hwaddress", KernelHWAddress)
 
 // A variant of AddressSanitizer using AArch64 MTE extension.
-SANITIZER("memtag", MemTag)
+SANITIZER("memtag-stack", MemtagStack)
+SANITIZER("memtag-heap", MemtagHeap)
+SANITIZER_GROUP("memtag", MemTag, MemtagStack | MemtagHeap)
 
 // MemorySanitizer
 SANITIZER("memory", Memory)

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 105f0496bfffb..98443b2757c93 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1641,6 +1641,9 @@ def fsanitize_address_outline_instrumentation : 
Flag<["-"], "fsanitize-address-o
 def fno_sanitize_address_outline_instrumentation : Flag<["-"], 
"fno-sanitize-address-outline-instrumentation">,
Group,
HelpText<"Use default code 
inlining logic for the address sanitizer">;
+def fsanitize_memtag_mode_EQ : Joined<["-"], "fsanitize-memtag-mode=">,
+Group,
+HelpText<"Set default MTE mode to 
'sync' (default) or 'async'">;
 def fsanitize_hwaddress_experimental_aliasing
   : Flag<["-"], "fsanitize-hwaddress-experimental-aliasing">,
 Group,

diff  --git a/clang/include/clang/Driver/SanitizerArgs.h 
b/clang/include/clang/Driver/SanitizerArgs.h
index d288b0151c9f7..a681ad3b2e05b 100644
--- a/clang/include/clang/Driver/SanitizerArgs.h
+++ b/clang/include/clang/Driver/SanitizerArgs.h
@@ -64,6 +64,8 @@ class SanitizerArgs {
   llvm::AsanDetectStackUseAfterReturnMode AsanUseAfterReturn =
   llvm::AsanDetectStackUseAfterReturnMode::Invalid;
 
+  std::string MemtagMode;
+
 public:
   /// Parses the sanitizer arguments from an argument list.
   SanitizerArgs(const ToolChain , const llvm::opt::ArgList ,
@@ -97,6 

[clang] 8aa1490 - [MTE] Add -fsanitize=memtag* and friends.

2022-04-08 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-04-08T12:13:15-07:00
New Revision: 8aa1490513f111afd407d87c3f07d26f65c8a686

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

LOG: [MTE] Add -fsanitize=memtag* and friends.

Currently, enablement of heap MTE on Android is specified by an ELF note, which
signals to the linker to enable heap MTE. This change allows
-fsanitize=memtag-heap to synthesize these notes, rather than adding them
through the build system. We need to extend this feature to also signal the
linker to do special work for MTE globals (in future) and MTE stack (currently
implemented in the toolchain, but not implemented in the loader).

Current Android uses a non-backwards-compatible ELF note, called
".note.android.memtag". Stack MTE is an ABI break anyway, so we don't mind that
we won't be able to run executables with stack MTE on Android 11/12 devices.

The current expectation is to support the verbiage used by Android, in
that "SYNC" means MTE Synchronous mode, and "ASYNC" effectively means
"fast", using the Kernel auto-upgrade feature that allows
hardware-specific and core-specific configuration as to whether "ASYNC"
would end up being Asynchronous, Asymmetric, or Synchronous on that
particular core, whichever has a reasonable performance delta. Of
course, this is platform and loader-specific.

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

Added: 
clang/test/Driver/memtag-ld.c
clang/test/Driver/memtag-stack.c
clang/test/Lexer/has_feature_memtag.cpp

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/Features.def
clang/include/clang/Basic/Sanitizers.def
clang/include/clang/Driver/Options.td
clang/include/clang/Driver/SanitizerArgs.h
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/SanitizerArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/CodeGen/memtag-attr.cpp
clang/test/Driver/fsanitize.c

Removed: 
clang/test/Driver/memtag.c
clang/test/Lexer/has_feature_memtag_sanitizer.cpp



diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 63913b933c8fb..89260a5f4b47d 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -481,7 +481,8 @@ def err_drv_ropi_incompatible_with_cxx : Error<
   "ROPI is not compatible with c++">;
 
 def err_stack_tagging_requires_hardware_feature : Error<
-  "'-fsanitize=memtag' requires hardware support (+memtag)">;
+  "'-fsanitize=memtag-stack' requires hardware support (+memtag). For Armv8 or 
"
+  "Armv9, try compiling with -march=armv8a+memtag or -march=armv9a+memtag">;
 
 def err_cmse_pi_are_incompatible : Error<
   "cmse is not compatible with %select{RWPI|ROPI}0">;

diff  --git a/clang/include/clang/Basic/Features.def 
b/clang/include/clang/Basic/Features.def
index 522ae5951499b..fbaa6174f9bff 100644
--- a/clang/include/clang/Basic/Features.def
+++ b/clang/include/clang/Basic/Features.def
@@ -45,7 +45,10 @@ FEATURE(leak_sanitizer,
 FEATURE(hwaddress_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress |
SanitizerKind::KernelHWAddress))
-FEATURE(memtag_sanitizer, LangOpts.Sanitize.has(SanitizerKind::MemTag))
+FEATURE(memtag_stack,
+LangOpts.Sanitize.has(SanitizerKind::MemtagStack))
+FEATURE(memtag_heap,
+LangOpts.Sanitize.has(SanitizerKind::MemtagHeap))
 FEATURE(xray_instrument, LangOpts.XRayInstrument)
 FEATURE(undefined_behavior_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined))

diff  --git a/clang/include/clang/Basic/Sanitizers.def 
b/clang/include/clang/Basic/Sanitizers.def
index 9b8936cc520cb..714934445cf95 100644
--- a/clang/include/clang/Basic/Sanitizers.def
+++ b/clang/include/clang/Basic/Sanitizers.def
@@ -56,7 +56,9 @@ SANITIZER("hwaddress", HWAddress)
 SANITIZER("kernel-hwaddress", KernelHWAddress)
 
 // A variant of AddressSanitizer using AArch64 MTE extension.
-SANITIZER("memtag", MemTag)
+SANITIZER("memtag-stack", MemtagStack)
+SANITIZER("memtag-heap", MemtagHeap)
+SANITIZER_GROUP("memtag", MemTag, MemtagStack | MemtagHeap)
 
 // MemorySanitizer
 SANITIZER("memory", Memory)

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index adce93dbfef1e..799fd1b62f185 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1641,6 +1641,9 @@ def fsanitize_address_outline_instrumentation : 
Flag<["-"], "fsanitize-address-o
 def fno_sanitize_address_outline_instrumentation : Flag<["-"], 
"fno-sanitize-address-outline-instrumentation">,
   

[clang] 9262d03 - [NFCI] clang-format SanitizerArgs.cpp

2022-04-01 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-04-01T16:38:15-07:00
New Revision: 9262d031a452c96bf69d2db75ef62e3ea973a828

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

LOG: [NFCI] clang-format SanitizerArgs.cpp

Added: 


Modified: 
clang/lib/Driver/SanitizerArgs.cpp

Removed: 




diff  --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index 598fe9a3bf0fd..86a22900df555 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -14,9 +14,9 @@
 #include "clang/Driver/ToolChain.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/AArch64TargetParser.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/SpecialCaseList.h"
-#include "llvm/Support/AArch64TargetParser.h"
 #include "llvm/Support/TargetParser.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
@@ -218,9 +218,9 @@ static SanitizerMask setGroupBits(SanitizerMask Kinds) {
 static SanitizerMask parseSanitizeTrapArgs(const Driver ,
const llvm::opt::ArgList ,
bool DiagnoseErrors) {
-  SanitizerMask TrapRemove; // During the loop below, the accumulated set 
of
-// sanitizers disabled by the current sanitizer
-// argument or any argument after it.
+  SanitizerMask TrapRemove; // During the loop below, the accumulated set of
+// sanitizers disabled by the current sanitizer
+// argument or any argument after it.
   SanitizerMask TrappingKinds;
   SanitizerMask TrappingSupportedWithGroups = setGroupBits(TrappingSupported);
 
@@ -233,8 +233,8 @@ static SanitizerMask parseSanitizeTrapArgs(const Driver ,
   if (InvalidValues && DiagnoseErrors) {
 SanitizerSet S;
 S.Mask = InvalidValues;
-D.Diag(diag::err_drv_unsupported_option_argument) << "-fsanitize-trap"
-  << toString(S);
+D.Diag(diag::err_drv_unsupported_option_argument)
+<< "-fsanitize-trap" << toString(S);
   }
   TrappingKinds |= expandSanitizerGroups(Add) & ~TrapRemove;
 } else if (Arg->getOption().matches(options::OPT_fno_sanitize_trap_EQ)) {
@@ -293,13 +293,13 @@ SanitizerArgs::SanitizerArgs(const ToolChain ,
   SanitizerMask AllRemove;  // During the loop below, the accumulated set 
of
 // sanitizers disabled by the current sanitizer
 // argument or any argument after it.
-  SanitizerMask AllAddedKinds;  // Mask of all sanitizers ever enabled by
-// -fsanitize= flags (directly or via group
-// expansion), some of which may be 
disabled
-// later. Used to carefully prune
-// unused-argument diagnostics.
-  SanitizerMask DiagnosedKinds;  // All Kinds we have diagnosed up to now.
- // Used to deduplicate diagnostics.
+  SanitizerMask AllAddedKinds;  // Mask of all sanitizers ever enabled by
+// -fsanitize= flags (directly or via group
+// expansion), some of which may be disabled
+// later. Used to carefully prune
+// unused-argument diagnostics.
+  SanitizerMask DiagnosedKinds; // All Kinds we have diagnosed up to now.
+// Used to deduplicate diagnostics.
   SanitizerMask Kinds;
   const SanitizerMask Supported = setGroupBits(TC.getSupportedSanitizers());
 
@@ -402,7 +402,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain ,
   if ((Add & SanitizerKind::Vptr) && (RTTIMode == ToolChain::RM_Disabled)) 
{
 if (const llvm::opt::Arg *NoRTTIArg = TC.getRTTIArg()) {
   assert(NoRTTIArg->getOption().matches(options::OPT_fno_rtti) &&
-  "RTTI disabled without -fno-rtti option?");
+ "RTTI disabled without -fno-rtti option?");
   // The user explicitly passed -fno-rtti with -fsanitize=vptr, but
   // the vptr sanitizer requires RTTI, so this is a user error.
   if (DiagnoseErrors)
@@ -638,10 +638,9 @@ SanitizerArgs::SanitizerArgs(const ToolChain ,
 }
   }
 }
-MsanUseAfterDtor =
-Args.hasFlag(options::OPT_fsanitize_memory_use_after_dtor,
- options::OPT_fno_sanitize_memory_use_after_dtor,
- MsanUseAfterDtor);
+MsanUseAfterDtor = 

[clang] 65e9d7e - Improve UBSan documentation

2021-08-02 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2021-08-02T15:10:21-07:00
New Revision: 65e9d7efb090756e16bbb5ff929efbc795a8b0d4

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

LOG: Improve UBSan documentation

Add more checks, info on -fno-sanitize=..., and reference to 5/2021 UBSan 
Oracle blog.

Authored By: DianeMeirowitz
Reviewed By: hctim

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

Added: 


Modified: 
clang/docs/UndefinedBehaviorSanitizer.rst

Removed: 




diff  --git a/clang/docs/UndefinedBehaviorSanitizer.rst 
b/clang/docs/UndefinedBehaviorSanitizer.rst
index 3d48c38bf2211..da6779927e669 100644
--- a/clang/docs/UndefinedBehaviorSanitizer.rst
+++ b/clang/docs/UndefinedBehaviorSanitizer.rst
@@ -12,7 +12,9 @@ UndefinedBehaviorSanitizer (UBSan) is a fast undefined 
behavior detector.
 UBSan modifies the program at compile-time to catch various kinds of undefined
 behavior during program execution, for example:
 
-* Using misaligned or null pointer
+* Array subscript out of bounds, where the bounds can be statically determined
+* Bitwise shifts that are out of bounds for their data type
+* Dereferencing misaligned or null pointers
 * Signed integer overflow
 * Conversion to, from, or between floating-point types which would
   overflow the destination
@@ -53,6 +55,7 @@ and define the desired behavior for each kind of check:
 * ``-fsanitize=...``: print a verbose error report and continue execution 
(default);
 * ``-fno-sanitize-recover=...``: print a verbose error report and exit the 
program;
 * ``-fsanitize-trap=...``: execute a trap instruction (doesn't require UBSan 
run-time support).
+* ``-fno-sanitize=...``: disable any check, e.g., -fno-sanitize=alignment.
 
 Note that the ``trap`` / ``recover`` options do not enable the corresponding
 sanitizer, and in general need to be accompanied by a suitable ``-fsanitize=``
@@ -357,6 +360,9 @@ For a file called ``/code/library/file.cpp``, here is what 
would be emitted:
 More Information
 
 
+* From Oracle blog, including a discussion of error messages:
+  `Improving Application Security with UndefinedBehaviorSanitizer (UBSan) and 
GCC
+  
`_
 * From LLVM project blog:
   `What Every C Programmer Should Know About Undefined Behavior
   `_



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


[clang] 3ec88ca - Revert "[clang-repl] Allow passing in code as positional arguments."

2021-07-02 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2021-07-02T11:04:28-07:00
New Revision: 3ec88ca60b24418b2216de88fad1da4f269f6b8c

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

LOG: Revert "[clang-repl] Allow passing in code as positional arguments."

This reverts commit e386871e1d21cf206a1287356e88c5853563fc77.

Reason: Broke the ASan buildbots
(https://lab.llvm.org/buildbot/#/builders/5/builds/9291). See comments
on https://reviews.llvm.org/D104898 for more information.

Added: 


Modified: 
clang/test/Interpreter/execute.cpp
clang/tools/clang-repl/ClangRepl.cpp

Removed: 




diff  --git a/clang/test/Interpreter/execute.cpp 
b/clang/test/Interpreter/execute.cpp
index 730796bd4016a..108b79b23a59d 100644
--- a/clang/test/Interpreter/execute.cpp
+++ b/clang/test/Interpreter/execute.cpp
@@ -1,12 +1,7 @@
-// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
-// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck 
--check-prefix=CHECK-DRIVER %s
+// RUN: cat %s | clang-repl | FileCheck %s
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
 
-// CHECK-DRIVER: i = 10
-
-// RUN: cat %s | clang-repl | FileCheck %s
-
 extern "C" int printf(const char *, ...);
 int i = 42;
 auto r1 = printf("i = %d\n", i);

diff  --git a/clang/tools/clang-repl/ClangRepl.cpp 
b/clang/tools/clang-repl/ClangRepl.cpp
index ba6bb11abc867..b5b5bf6e0c6bb 100644
--- a/clang/tools/clang-repl/ClangRepl.cpp
+++ b/clang/tools/clang-repl/ClangRepl.cpp
@@ -28,9 +28,6 @@ static llvm::cl::list
   llvm::cl::CommaSeparated);
 static llvm::cl::opt OptHostSupportsJit("host-supports-jit",
   llvm::cl::Hidden);
-static llvm::cl::list OptInputs(llvm::cl::Positional,
- llvm::cl::ZeroOrMore,
- llvm::cl::desc("[code to run]"));
 
 static void LLVMErrorHandler(void *UserData, const std::string ,
  bool GenCrashDiag) {
@@ -81,22 +78,15 @@ int main(int argc, const char **argv) {
 static_cast(>getDiagnostics()));
 
   auto Interp = ExitOnErr(clang::Interpreter::create(std::move(CI)));
-  for (const std::string  : OptInputs) {
-if (auto Err = Interp->ParseAndExecute(input))
+  llvm::LineEditor LE("clang-repl");
+  // FIXME: Add LE.setListCompleter
+  while (llvm::Optional Line = LE.readLine()) {
+if (*Line == "quit")
+  break;
+if (auto Err = Interp->ParseAndExecute(*Line))
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
   }
 
-  if (OptInputs.empty()) {
-llvm::LineEditor LE("clang-repl");
-// FIXME: Add LE.setListCompleter
-while (llvm::Optional Line = LE.readLine()) {
-  if (*Line == "quit")
-break;
-  if (auto Err = Interp->ParseAndExecute(*Line))
-llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
-}
-  }
-
   // Our error handler depends on the Diagnostics object, which we're
   // potentially about to delete. Uninstall the handler now so that any
   // later errors use the default handling behavior instead.



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


[clang] f7c5c0d - Revert "[Scudo] Make -fsanitize=scudo use standalone. Migrate tests."

2021-05-26 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2021-05-26T10:50:26-07:00
New Revision: f7c5c0d87b8ae5e55006fd3a31994cd68d64f102

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

LOG: Revert "[Scudo] Make -fsanitize=scudo use standalone. Migrate tests."

This reverts commit 694d8cbed06a8a809c34ae07f4e3e89ab252.

Broke the QEMU sanitizer bots due to a missing header dependency. This
actually needs to be fixed on the bot-side, but for now reverting this
patch until I can fix up the bot.

Added: 

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/aarch64-unknown-fuchsia/libclang_rt.scudo.so

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/x86_64-unknown-fuchsia/libclang_rt.scudo.so
compiler-rt/test/scudo/aligned-new.cpp
compiler-rt/test/scudo/alignment.c
compiler-rt/test/scudo/dealloc-race.c
compiler-rt/test/scudo/double-free.cpp
compiler-rt/test/scudo/fsanitize.c
compiler-rt/test/scudo/interface.cpp
compiler-rt/test/scudo/lit.cfg.py
compiler-rt/test/scudo/lit.site.cfg.py.in
compiler-rt/test/scudo/malloc.cpp
compiler-rt/test/scudo/memalign.c
compiler-rt/test/scudo/mismatch.cpp
compiler-rt/test/scudo/options.cpp
compiler-rt/test/scudo/overflow.c
compiler-rt/test/scudo/preinit.c
compiler-rt/test/scudo/preload.cpp
compiler-rt/test/scudo/quarantine.c
compiler-rt/test/scudo/random_shuffle.cpp
compiler-rt/test/scudo/realloc.cpp
compiler-rt/test/scudo/rss.c
compiler-rt/test/scudo/secondary.c
compiler-rt/test/scudo/sized-delete.cpp
compiler-rt/test/scudo/sizes.cpp
compiler-rt/test/scudo/stats.c
compiler-rt/test/scudo/symbols.test
compiler-rt/test/scudo/threads.c
compiler-rt/test/scudo/tsd_destruction.c
compiler-rt/test/scudo/valloc.c

Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/fuchsia.c
clang/test/Driver/sanitizer-ld.c
compiler-rt/lib/scudo/standalone/wrappers_cpp.cpp
compiler-rt/test/scudo/CMakeLists.txt
compiler-rt/test/scudo/standalone/CMakeLists.txt

Removed: 

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/aarch64-unknown-fuchsia/libclang_rt.scudo_standalone.so

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/x86_64-unknown-fuchsia/libclang_rt.scudo_standalone.so
compiler-rt/test/scudo/standalone/aligned-new.cpp
compiler-rt/test/scudo/standalone/alignment.c
compiler-rt/test/scudo/standalone/dealloc-race.c
compiler-rt/test/scudo/standalone/double-free.cpp
compiler-rt/test/scudo/standalone/fsanitize.c
compiler-rt/test/scudo/standalone/lit-unmigrated/overflow.c
compiler-rt/test/scudo/standalone/lit-unmigrated/quarantine.c
compiler-rt/test/scudo/standalone/lit-unmigrated/realloc.cpp
compiler-rt/test/scudo/standalone/lit-unmigrated/rss.c
compiler-rt/test/scudo/standalone/lit-unmigrated/secondary.c
compiler-rt/test/scudo/standalone/lit-unmigrated/sizes.cpp
compiler-rt/test/scudo/standalone/lit-unmigrated/threads.c
compiler-rt/test/scudo/standalone/lit-unmigrated/valloc.c
compiler-rt/test/scudo/standalone/lit.cfg.py
compiler-rt/test/scudo/standalone/lit.site.cfg.py.in
compiler-rt/test/scudo/standalone/malloc.cpp
compiler-rt/test/scudo/standalone/memalign.c
compiler-rt/test/scudo/standalone/mismatch.cpp
compiler-rt/test/scudo/standalone/options.cpp
compiler-rt/test/scudo/standalone/preinit.c
compiler-rt/test/scudo/standalone/preload.cpp
compiler-rt/test/scudo/standalone/random_shuffle.cpp
compiler-rt/test/scudo/standalone/sized-delete.cpp
compiler-rt/test/scudo/standalone/stats.c
compiler-rt/test/scudo/standalone/tsd_destruction.c



diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 79779052418ad..b74a9fe3eb927 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -809,7 +809,10 @@ collectSanitizerRuntimes(const ToolChain , const 
ArgList ,
 SharedRuntimes.push_back("ubsan_standalone");
 }
 if (SanArgs.needsScudoRt() && SanArgs.linkRuntimes()) {
-  SharedRuntimes.push_back("scudo_standalone");
+  if (SanArgs.requiresMinimalRuntime())
+SharedRuntimes.push_back("scudo_minimal");
+  else
+SharedRuntimes.push_back("scudo");
 }
 if (SanArgs.needsTsanRt() && SanArgs.linkRuntimes())
   SharedRuntimes.push_back("tsan");
@@ -900,9 +903,15 @@ collectSanitizerRuntimes(const ToolChain , const 
ArgList ,
 RequiredSymbols.push_back("__sanitizer_stats_register");
   }
   if (!SanArgs.needsSharedRt() && SanArgs.needsScudoRt() && 
SanArgs.linkRuntimes()) {
-StaticRuntimes.push_back("scudo_standalone");
-if 

[clang] 6911114 - [Scudo] Make -fsanitize=scudo use standalone. Migrate tests.

2021-05-26 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2021-05-26T10:03:17-07:00
New Revision: 694d8cbed06a8a809c34ae07f4e3e89ab252

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

LOG: [Scudo] Make -fsanitize=scudo use standalone. Migrate tests.

This patch moves -fsanitize=scudo to link the standalone scudo library,
rather than the original compiler-rt based library. This is one of the
major remaining roadblocks to deleting the compiler-rt based scudo,
which should not be used any more. The standalone Scudo is better in
pretty much every way and is much more suitable for production usage.

As well as patching the litmus tests for checking that the
scudo_standalone lib is linked instead of the scudo lib, this patch also
ports all the scudo lit tests to run under scudo standalone.

This patch also adds a feature to scudo standalone that was under test
in the original scudo - that arguments passed to an aligned operator new
were checked that the alignment was a power of two.

Some lit tests could not be migrated, due to the following issues:
 1. Features that aren't supported in scudo standalone, like the rss
 limit.
 2. Different quarantine implementation where the test needs some more
 thought.
 3. Small bugs in scudo standalone that should probably be fixed, like
 the Secondary allocator having a full page on the LHS of an allocation
 that only contains the chunk header, so underflows by <= a page aren't
 caught.
 4. Slight differences in behaviour that's technically correct, like
 'realloc(malloc(1), 0)' returns nullptr in standalone, but a real
 pointer in old scudo.
 5. Some tests that might be migratable, but not easily.

Tests that are obviously not applicable to scudo standalone (like
testing that no sanitizer symbols made it into the DSO) have been
deleted.

After this patch, the remaining work is:
 1. Update the Scudo documentation. The flags have changed, etc.
 2. Delete the old version of scudo.
 3. Patch up the tests in lit-unmigrated, or fix Scudo standalone.

Reviewed By: cryptoad, vitalybuka

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

Added: 

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/aarch64-unknown-fuchsia/libclang_rt.scudo_standalone.so

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/x86_64-unknown-fuchsia/libclang_rt.scudo_standalone.so
compiler-rt/test/scudo/standalone/aligned-new.cpp
compiler-rt/test/scudo/standalone/alignment.c
compiler-rt/test/scudo/standalone/dealloc-race.c
compiler-rt/test/scudo/standalone/double-free.cpp
compiler-rt/test/scudo/standalone/fsanitize.c
compiler-rt/test/scudo/standalone/lit-unmigrated/overflow.c
compiler-rt/test/scudo/standalone/lit-unmigrated/quarantine.c
compiler-rt/test/scudo/standalone/lit-unmigrated/realloc.cpp
compiler-rt/test/scudo/standalone/lit-unmigrated/rss.c
compiler-rt/test/scudo/standalone/lit-unmigrated/secondary.c
compiler-rt/test/scudo/standalone/lit-unmigrated/sizes.cpp
compiler-rt/test/scudo/standalone/lit-unmigrated/threads.c
compiler-rt/test/scudo/standalone/lit-unmigrated/valloc.c
compiler-rt/test/scudo/standalone/lit.cfg.py
compiler-rt/test/scudo/standalone/lit.site.cfg.py.in
compiler-rt/test/scudo/standalone/malloc.cpp
compiler-rt/test/scudo/standalone/memalign.c
compiler-rt/test/scudo/standalone/mismatch.cpp
compiler-rt/test/scudo/standalone/options.cpp
compiler-rt/test/scudo/standalone/preinit.c
compiler-rt/test/scudo/standalone/preload.cpp
compiler-rt/test/scudo/standalone/random_shuffle.cpp
compiler-rt/test/scudo/standalone/sized-delete.cpp
compiler-rt/test/scudo/standalone/stats.c
compiler-rt/test/scudo/standalone/tsd_destruction.c

Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/fuchsia.c
clang/test/Driver/sanitizer-ld.c
compiler-rt/lib/scudo/standalone/wrappers_cpp.cpp
compiler-rt/test/scudo/CMakeLists.txt
compiler-rt/test/scudo/standalone/CMakeLists.txt

Removed: 

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/aarch64-unknown-fuchsia/libclang_rt.scudo.so

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/x86_64-unknown-fuchsia/libclang_rt.scudo.so
compiler-rt/test/scudo/aligned-new.cpp
compiler-rt/test/scudo/alignment.c
compiler-rt/test/scudo/dealloc-race.c
compiler-rt/test/scudo/double-free.cpp
compiler-rt/test/scudo/fsanitize.c
compiler-rt/test/scudo/interface.cpp
compiler-rt/test/scudo/lit.cfg.py
compiler-rt/test/scudo/lit.site.cfg.py.in
compiler-rt/test/scudo/malloc.cpp
compiler-rt/test/scudo/memalign.c
compiler-rt/test/scudo/mismatch.cpp
compiler-rt/test/scudo/options.cpp
compiler-rt/test/scudo/overflow.c
compiler-rt/test/scudo/preinit.c
compiler-rt/test/scudo/preload.cpp

[clang] e58d68f - Revert "[AMDGPU] Restore the s_memtime instruction in gfx1030"

2021-03-05 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2021-03-05T18:24:59-08:00
New Revision: e58d68fcd06ddc7743e0419c0b364df3d44121b6

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

LOG: Revert "[AMDGPU] Restore the s_memtime instruction in gfx1030"

Broke the ASan/MSan buildbots. See more comments in the original patch,
https://reviews.llvm.org/D97928.

Build failure at http://lab.llvm.org:8011/#/builders/5/builds/5327

This reverts commit fc28f600e558c1344618bda149a068d6162b6f0b.

Added: 
clang/test/SemaOpenCL/builtins-amdgcn-error-gfx1030.cl

Modified: 
clang/lib/Basic/Targets/AMDGPU.cpp
clang/test/CodeGenOpenCL/amdgpu-features.cl
llvm/lib/Target/AMDGPU/AMDGPU.td
llvm/lib/Target/AMDGPU/GCNSubtarget.h
llvm/lib/Target/AMDGPU/SMInstructions.td
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.memtime.ll
llvm/test/MC/AMDGPU/gfx1030_err.s

Removed: 




diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index a84422e412ff..0f1211d6c409 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -192,7 +192,6 @@ bool AMDGPUTargetInfo::initFeatureMap(
   Features["gfx10-insts"] = true;
   Features["gfx10-3-insts"] = true;
   Features["s-memrealtime"] = true;
-  Features["s-memtime-inst"] = true;
   break;
 case GK_GFX1012:
 case GK_GFX1011:

diff  --git a/clang/test/CodeGenOpenCL/amdgpu-features.cl 
b/clang/test/CodeGenOpenCL/amdgpu-features.cl
index 930c53705d84..f387c93bd6e0 100644
--- a/clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ b/clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -58,9 +58,9 @@
 // GFX1010: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dpp,+flat-address-space,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst"
 // GFX1011: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst"
 // GFX1012: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst"
-// GFX1030: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-3-insts,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst"
-// GFX1031: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-3-insts,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst"
-// GFX1032: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-3-insts,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst"
-// GFX1033: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-3-insts,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst"
+// GFX1030: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-3-insts,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
+// GFX1031: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-3-insts,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
+// GFX1032: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-3-insts,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
+// GFX1033: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-3-insts,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
 
 kernel void test() {}

diff  --git a/clang/test/SemaOpenCL/builtins-amdgcn-error-gfx1030.cl 
b/clang/test/SemaOpenCL/builtins-amdgcn-error-gfx1030.cl
new file mode 100644
index ..34149148a5f3
--- /dev/null
+++ b/clang/test/SemaOpenCL/builtins-amdgcn-error-gfx1030.cl
@@ -0,0 +1,7 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx1030 -verify -S -o - %s
+
+void test_gfx1030_s_memtime()
+{
+  __builtin_amdgcn_s_memtime(); // expected-error 
{{'__builtin_amdgcn_s_memtime' needs target feature s-memtime-inst}}
+}

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPU.td 
b/llvm/lib/Target/AMDGPU/AMDGPU.td
index e2e9c42dc985..452d3bb6c9a9 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.td
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.td
@@ -563,12 +563,6 @@ def FeatureSMemTimeInst : 

[clang] e174da4 - [Clang][IFS][Test] Work around in-process cc1 ASAN issues #2.

2020-01-23 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2020-01-23T14:25:53-08:00
New Revision: e174da447c180b586719cb28f7bd556e30625762

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

LOG: [Clang][IFS][Test] Work around in-process cc1 ASAN issues #2.

Using the same strategy as c38e42527b21.

D69825 revealed (introduced?) a problem when building with ASan, and
some memory leaks somewhere. More details are available in the original
patch.

Looks like we missed one failing tests, this patch adds the workaround
to this test as well.

Added: 


Modified: 
clang/test/Driver/cl-showfilenames.c

Removed: 




diff  --git a/clang/test/Driver/cl-showfilenames.c 
b/clang/test/Driver/cl-showfilenames.c
index b2932f1a01ac..73205978c44c 100644
--- a/clang/test/Driver/cl-showfilenames.c
+++ b/clang/test/Driver/cl-showfilenames.c
@@ -2,11 +2,19 @@
 // target Windows.
 // REQUIRES: x86-registered-target
 
-// RUN: %clang_cl --target=i686-pc-win32 /c /Fo%T/ /showFilenames -- %s 2>&1 | 
FileCheck -check-prefix=show %s
-// RUN: %clang_cl --target=i686-pc-win32 /c /Fo%T/ /showFilenames -- %s 
%S/Inputs/wildcard*.c 2>&1 | FileCheck -check-prefix=multiple %s
+// NOTE: -fno-integrated-cc1 has been added to work around an ASAN failure
+//   caused by in-process cc1 invocation. Clang InterfaceStubs is not the
+//   culprit, but Clang Interface Stubs' Driver pipeline setup uncovers an
+//   existing ASAN issue when invoking multiple normal cc1 jobs along with
+//   multiple Clang Interface Stubs cc1 jobs together.
+//   There is currently a discussion of this going on at:
+// https://reviews.llvm.org/D69825
 
-// RUN: %clang_cl --target=i686-pc-win32 /c /Fo%T/ -- %s 2>&1 | FileCheck 
-check-prefix=noshow %s
-// RUN: %clang_cl --target=i686-pc-win32 /c /Fo%T/ /showFilenames 
/showFilenames- -- %s 2>&1 | FileCheck -check-prefix=noshow %s
+// RUN: %clang_cl -fno-integrated-cc1 --target=i686-pc-win32 /c /Fo%T/ 
/showFilenames -- %s 2>&1 | FileCheck -check-prefix=show %s
+// RUN: %clang_cl -fno-integrated-cc1 --target=i686-pc-win32 /c /Fo%T/ 
/showFilenames -- %s %S/Inputs/wildcard*.c 2>&1 | FileCheck 
-check-prefix=multiple %s
+
+// RUN: %clang_cl -fno-integrated-cc1 --target=i686-pc-win32 /c /Fo%T/ -- %s 
2>&1 | FileCheck -check-prefix=noshow %s
+// RUN: %clang_cl -fno-integrated-cc1 --target=i686-pc-win32 /c /Fo%T/ 
/showFilenames /showFilenames- -- %s 2>&1 | FileCheck -check-prefix=noshow %s
 
 
 #pragma message "Hello"



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


[clang] edd4398 - Revert "PR17164: Change clang's default behavior from -flax-vector-conversions=all to -flax-vector-conversions=integer."

2020-01-20 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2020-01-20T16:34:09-08:00
New Revision: edd4398f4cd33a305afbca76ac4e6590e9337f4d

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

LOG: Revert "PR17164: Change clang's default behavior from 
-flax-vector-conversions=all to -flax-vector-conversions=integer."

This patch broke the Sanitizer buildbots. Please see the commit's
differential revision for more information
(https://reviews.llvm.org/D67678).

This reverts commit b72a8c65e4e34779b6bc9e466203f553f5294486.

Added: 


Modified: 
clang/docs/CommandGuide/clang.rst
clang/include/clang/Basic/LangOptions.def
clang/test/Headers/altivec-header.c
clang/test/Headers/arm-neon-header.c
clang/test/Headers/x86-intrinsics-headers.c
clang/test/Headers/x86intrin-2.c
clang/test/Headers/x86intrin.c
clang/test/Sema/vector-assign.c
clang/test/Sema/vector-cast.c
clang/test/Sema/vector-ops.c

Removed: 




diff  --git a/clang/docs/CommandGuide/clang.rst 
b/clang/docs/CommandGuide/clang.rst
index 6947450beb43..7b0873600fc3 100644
--- a/clang/docs/CommandGuide/clang.rst
+++ b/clang/docs/CommandGuide/clang.rst
@@ -278,18 +278,9 @@ Language Selection and Mode Options
  Make all string literals default to writable.  This disables uniquing of
  strings and other optimizations.
 
-.. option:: -flax-vector-conversions, -flax-vector-conversions=, 
-fno-lax-vector-conversions
+.. option:: -flax-vector-conversions
 
  Allow loose type checking rules for implicit vector conversions.
- Possible values of :
-
- - ``none``: allow no implicit conversions between vectors
- - ``integer``: allow implicit bitcasts between integer vectors of the same
-   overall bit-width
- - ``all``: allow implicit bitcasts between any vectors of the same
-   overall bit-width
-
-  defaults to ``integer`` if unspecified.
 
 .. option:: -fblocks
 

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 4bbe6ea26fba..068f206f4484 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -121,7 +121,7 @@ BENIGN_LANGOPT(PascalStrings, 1, 0, "Pascal string support")
 LANGOPT(WritableStrings   , 1, 0, "writable string support")
 LANGOPT(ConstStrings  , 1, 0, "const-qualified string support")
 ENUM_LANGOPT(LaxVectorConversions, LaxVectorConversionKind, 2,
- LaxVectorConversionKind::Integer, "lax vector conversions")
+ LaxVectorConversionKind::All, "lax vector conversions")
 LANGOPT(ConvergentFunctions, 1, 1, "Assume convergent functions")
 LANGOPT(AltiVec   , 1, 0, "AltiVec-style vector initializers")
 LANGOPT(ZVector   , 1, 0, "System z vector extensions")

diff  --git a/clang/test/Headers/altivec-header.c 
b/clang/test/Headers/altivec-header.c
index aa85a33d26da..00e5f444de7c 100644
--- a/clang/test/Headers/altivec-header.c
+++ b/clang/test/Headers/altivec-header.c
@@ -1,5 +1,5 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-feature +altivec 
-ffreestanding -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-feature +altivec 
-ffreestanding -emit-llvm -flax-vector-conversions=none -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-feature +altivec 
-ffreestanding -emit-llvm -flax-vector-conversions=all -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-feature +altivec 
-ffreestanding -emit-llvm -x c++ -o - %s | FileCheck %s
 
 #include 

diff  --git a/clang/test/Headers/arm-neon-header.c 
b/clang/test/Headers/arm-neon-header.c
index 8626a883fdf3..f6362886010a 100644
--- a/clang/test/Headers/arm-neon-header.c
+++ b/clang/test/Headers/arm-neon-header.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -flax-vector-conversions=all -Wvector-conversions -ffreestanding 
%s
+// RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -Wvector-conversions -ffreestanding %s
 // RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -flax-vector-conversions=none -ffreestanding %s
 // RUN: %clang_cc1 -x c++ -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -Wvector-conversions -ffreestanding %s
 

diff  --git a/clang/test/Headers/x86-intrinsics-headers.c 
b/clang/test/Headers/x86-intrinsics-headers.c
index 2efd3505bca6..59ca354e1160 100644
--- a/clang/test/Headers/x86-intrinsics-headers.c
+++ b/clang/test/Headers/x86-intrinsics-headers.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -ffreestanding -flax-vector-conversions=all %s
+// RUN: %clang_cc1 -fsyntax-only -ffreestanding %s
 // RUN: %clang_cc1 -fsyntax-only -ffreestanding 

[clang] b19d87b - Revert "Add an -fno-temp-file flag for compilation"

2019-12-18 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2019-12-18T09:05:09-08:00
New Revision: b19d87b16f81e7c0a22a0a103c867c1b844eb8bc

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

LOG: Revert "Add an -fno-temp-file flag for compilation"

This reverts commit d129aa1d5369781deff6c6b854cb612e160d3fb2.

This broke the MSan buildbots. More information available in the
original PR: https://reviews.llvm.org/D70615

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/FrontendOptions.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/test/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2a72b87355d0..38504d6330da 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1563,9 +1563,6 @@ def fno_strict_enums : Flag<["-"], "fno-strict-enums">, 
Group;
 def fno_strict_vtable_pointers: Flag<["-"], "fno-strict-vtable-pointers">,
   Group;
 def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group;
-def fno_temp_file : Flag<["-"], "fno-temp-file">, Group,
-  Flags<[CC1Option, CoreOption]>, HelpText<
-  "Directly create compilation output files. This may lead to incorrect 
incremental builds if the compiler crashes">;
 def fno_threadsafe_statics : Flag<["-"], "fno-threadsafe-statics">, 
Group,
   Flags<[CC1Option]>, HelpText<"Do not emit code to make initialization of 
local statics thread safe">;
 def fno_use_cxa_atexit : Flag<["-"], "fno-use-cxa-atexit">, Group, 
Flags<[CC1Option]>,

diff  --git a/clang/include/clang/Frontend/FrontendOptions.h 
b/clang/include/clang/Frontend/FrontendOptions.h
index 305a66006218..70eb3425b0da 100644
--- a/clang/include/clang/Frontend/FrontendOptions.h
+++ b/clang/include/clang/Frontend/FrontendOptions.h
@@ -294,9 +294,6 @@ class FrontendOptions {
   /// Whether timestamps should be written to the produced PCH file.
   unsigned IncludeTimestamps : 1;
 
-  /// Should a temporary file be used during compilation.
-  unsigned UseTemporary : 1;
-
   CodeCompleteOptions CodeCompleteOpts;
 
   /// Specifies the output format of the AST.

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 5febd55cc0d6..5bf0efcf0503 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5029,7 +5029,6 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_granularity_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
   Args.AddLastArg(CmdArgs, options::OPT_malign_double);
-  Args.AddLastArg(CmdArgs, options::OPT_fno_temp_file);
 
   if (Arg *A = Args.getLastArg(options::OPT_ftrapv_handler_EQ)) {
 CmdArgs.push_back("-ftrapv-handler");

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 688f21dd0908..05ecc3f447cc 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -672,7 +672,7 @@ CompilerInstance::createDefaultOutputFile(bool Binary, 
StringRef InFile,
   StringRef Extension) {
   return createOutputFile(getFrontendOpts().OutputFile, Binary,
   /*RemoveFileOnSignal=*/true, InFile, Extension,
-  getFrontendOpts().UseTemporary);
+  /*UseTemporary=*/true);
 }
 
 std::unique_ptr CompilerInstance::createNullOutputFile() {

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index d68244dce5c4..8631536e8f60 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1887,7 +1887,6 @@ static InputKind ParseFrontendArgs(FrontendOptions , 
ArgList ,
   Opts.ModulesEmbedFiles = Args.getAllArgValues(OPT_fmodules_embed_file_EQ);
   Opts.ModulesEmbedAllFiles = Args.hasArg(OPT_fmodules_embed_all_files);
   Opts.IncludeTimestamps = !Args.hasArg(OPT_fno_pch_timestamp);
-  Opts.UseTemporary = !Args.hasArg(OPT_fno_temp_file);
 
   Opts.CodeCompleteOpts.IncludeMacros
 = Args.hasArg(OPT_code_completion_macros);

diff  --git a/clang/lib/Frontend/FrontendActions.cpp 
b/clang/lib/Frontend/FrontendActions.cpp
index 1dbfad06a710..aeea63ca323f 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -140,7 +140,7 @@ GeneratePCHAction::CreateOutputFile(CompilerInstance , 
StringRef InFile,
   std::unique_ptr OS =
   CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
   

r372353 - Revert "[CUDA][HIP] Fix typo in `BestViableFunction`"

2019-09-19 Thread Mitch Phillips via cfe-commits
Author: hctim
Date: Thu Sep 19 14:11:28 2019
New Revision: 372353

URL: http://llvm.org/viewvc/llvm-project?rev=372353=rev
Log:
Revert "[CUDA][HIP] Fix typo in `BestViableFunction`"

Broke the msan buildbots (see comments on rL372318 for more details).

This reverts commit eb231d15825ac345b546f4c99372d1cac8f14f02.

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCUDA/function-overload.cu
cfe/trunk/test/SemaCUDA/implicit-member-target-collision-cxx11.cu

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=372353=372352=372353=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Sep 19 14:11:28 2019
@@ -9422,19 +9422,17 @@ OverloadCandidateSet::BestViableFunction
 const FunctionDecl *Caller = dyn_cast(S.CurContext);
 bool ContainsSameSideCandidate =
 llvm::any_of(Candidates, [&](OverloadCandidate *Cand) {
-  // Consider viable function only.
-  return Cand->Viable && Cand->Function &&
+  return Cand->Function &&
  S.IdentifyCUDAPreference(Caller, Cand->Function) ==
  Sema::CFP_SameSide;
 });
 if (ContainsSameSideCandidate) {
-  // Clear viable flag for WrongSide varible candidates.
-  llvm::for_each(Candidates, [&](OverloadCandidate *Cand) {
-if (Cand->Viable && Cand->Function &&
-S.IdentifyCUDAPreference(Caller, Cand->Function) ==
-Sema::CFP_WrongSide)
-  Cand->Viable = false;
-  });
+  auto IsWrongSideCandidate = [&](OverloadCandidate *Cand) {
+return Cand->Function &&
+   S.IdentifyCUDAPreference(Caller, Cand->Function) ==
+   Sema::CFP_WrongSide;
+  };
+  llvm::erase_if(Candidates, IsWrongSideCandidate);
 }
   }
 

Modified: cfe/trunk/test/SemaCUDA/function-overload.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/function-overload.cu?rev=372353=372352=372353=diff
==
--- cfe/trunk/test/SemaCUDA/function-overload.cu (original)
+++ cfe/trunk/test/SemaCUDA/function-overload.cu Thu Sep 19 14:11:28 2019
@@ -402,20 +402,3 @@ __host__ void test_host_template_overloa
 __device__ void test_device_template_overload() {
   template_overload(1); // OK. Attribute-based overloading picks __device__ 
variant.
 }
-
-// Two classes with `operator-` defined. One of them is device only.
-struct C1;
-struct C2;
-__device__
-int operator-(const C1 , const C1 );
-int operator-(const C2 , const C2 );
-
-template 
-__host__ __device__ int constexpr_overload(const T , const T ) {
-  return x - y;
-}
-
-// Verify that function overloading doesn't prune candidate wrongly.
-int test_constexpr_overload(C2 , C2 ) {
-  return constexpr_overload(x, y);
-}

Modified: cfe/trunk/test/SemaCUDA/implicit-member-target-collision-cxx11.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/implicit-member-target-collision-cxx11.cu?rev=372353=372352=372353=diff
==
--- cfe/trunk/test/SemaCUDA/implicit-member-target-collision-cxx11.cu (original)
+++ cfe/trunk/test/SemaCUDA/implicit-member-target-collision-cxx11.cu Thu Sep 
19 14:11:28 2019
@@ -74,13 +74,11 @@ struct B4_with_device_copy_ctor {
 struct C4_with_collision : A4_with_host_copy_ctor, B4_with_device_copy_ctor {
 };
 
-// expected-note@-3 {{candidate constructor (the implicit copy constructor) 
not viable: call to invalid function from __host__ function}}
-// expected-note@-4 {{implicit copy constructor inferred target collision: 
call to both __host__ and __device__ members}}
-// expected-note@-5 {{candidate constructor (the implicit default constructor) 
not viable: requires 0 arguments, but 1 was provided}}
+// expected-note@-3 {{copy constructor of 'C4_with_collision' is implicitly 
deleted because base class 'B4_with_device_copy_ctor' has no copy constructor}}
 
 void hostfoo4() {
   C4_with_collision c;
-  C4_with_collision c2 = c; // expected-error {{no matching constructor for 
initialization of 'C4_with_collision'}}
+  C4_with_collision c2 = c; // expected-error {{call to implicitly-deleted 
copy constructor of 'C4_with_collision'}}
 }
 
 
//--


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


r362138 - [GWP-ASan] Mutex implementation [2].

2019-05-30 Thread Mitch Phillips via cfe-commits
Author: hctim
Date: Thu May 30 12:45:32 2019
New Revision: 362138

URL: http://llvm.org/viewvc/llvm-project?rev=362138=rev
Log:
[GWP-ASan] Mutex implementation [2].

Summary:
See D60593 for further information.
This patch pulls out the mutex implementation and the required definitions file.

We implement our own mutex for GWP-ASan currently, because:

1. We must be compatible with the sum of the most restrictive elements of the 
supporting allocator's build system. Current targets for GWP-ASan include Scudo 
(on Linux and Fuchsia), and bionic (on Android).
2. Scudo specifies `-nostdlib++ -nonodefaultlibs`, meaning we can't use 
`std::mutex` or `mtx_t`.
3. We can't use `sanitizer_common`'s mutex, as the supporting allocators cannot 
afford the extra maintenance (Android, Fuchsia) and code size (Fuchsia) 
overheads that this would incur.

In future, we would like to implement a shared base mutex for GWP-ASan, Scudo 
and sanitizer_common. This will likely happen when both GWP-ASan and Scudo 
standalone are not in the development phase, at which point they will have 
stable requirements.

Reviewers: vlad.tsyrklevich, morehouse, jfb

Reviewed By: morehouse

Subscribers: dexonsmith, srhines, cfe-commits, kubamracek, mgorny, cryptoad, 
jfb, #sanitizers, llvm-commits, vitalybuka, eugenis

Tags: #sanitizers, #llvm, #clang

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

Modified:
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=362138=362137=362138=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Thu May 30 12:45:32 2019
@@ -132,7 +132,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E
 # Add top-level targets for various compiler-rt test suites.
 set(COMPILER_RT_TEST_SUITES check-fuzzer check-asan check-hwasan 
check-asan-dynamic check-dfsan
   check-lsan check-msan check-sanitizer check-tsan check-ubsan 
check-ubsan-minimal
-  check-profile check-cfi check-cfi-and-supported check-safestack)
+  check-profile check-cfi check-cfi-and-supported check-safestack 
check-gwp_asan)
 foreach(test_suite ${COMPILER_RT_TEST_SUITES})
   get_ext_project_build_command(run_test_suite ${test_suite})
   add_custom_target(${test_suite}


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


r355616 - Rollback of rL355585.

2019-03-07 Thread Mitch Phillips via cfe-commits
Author: hctim
Date: Thu Mar  7 10:13:39 2019
New Revision: 355616

URL: http://llvm.org/viewvc/llvm-project?rev=355616=rev
Log:
Rollback of rL355585.

Introduces memory leak in FunctionTest.GetPointerAlignment that breaks 
sanitizer buildbots:

```
=
==2453==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 128 byte(s) in 1 object(s) allocated from:
#0 0x610428 in operator new(unsigned long) 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:105
#1 0x16936bc in llvm::User::operator new(unsigned long) 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/IR/User.cpp:151:19
#2 0x7c3fe9 in Create 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/include/llvm/IR/Function.h:144:12
#3 0x7c3fe9 in (anonymous 
namespace)::FunctionTest_GetPointerAlignment_Test::TestBody() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/unittests/IR/FunctionTest.cpp:136
#4 0x1a836a0 in HandleExceptionsInMethodIfSupported 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc
#5 0x1a836a0 in testing::Test::Run() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2474
#6 0x1a85c55 in testing::TestInfo::Run() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11
#7 0x1a870d0 in testing::TestCase::Run() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28
#8 0x1aa5b84 in testing::internal::UnitTestImpl::RunAllTests() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43
#9 0x1aa4d30 in 
HandleExceptionsInMethodIfSupported 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc
#10 0x1aa4d30 in testing::UnitTest::Run() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:4257
#11 0x1a6b656 in RUN_ALL_TESTS 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46
#12 0x1a6b656 in main 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:50
#13 0x7f5af37a22e0 in __libc_start_main 
(/lib/x86_64-linux-gnu/libc.so.6+0x202e0)

Indirect leak of 40 byte(s) in 1 object(s) allocated from:
#0 0x610428 in operator new(unsigned long) 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:105
#1 0x151be6b in make_unique 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/include/llvm/ADT/STLExtras.h:1349:29
#2 0x151be6b in llvm::Function::Function(llvm::FunctionType*, 
llvm::GlobalValue::LinkageTypes, unsigned int, llvm::Twine const&, 
llvm::Module*) 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/lib/IR/Function.cpp:241
#3 0x7c4006 in Create 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/include/llvm/IR/Function.h:144:16
#4 0x7c4006 in (anonymous 
namespace)::FunctionTest_GetPointerAlignment_Test::TestBody() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/unittests/IR/FunctionTest.cpp:136
#5 0x1a836a0 in HandleExceptionsInMethodIfSupported 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc
#6 0x1a836a0 in testing::Test::Run() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2474
#7 0x1a85c55 in testing::TestInfo::Run() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11
#8 0x1a870d0 in testing::TestCase::Run() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28
#9 0x1aa5b84 in testing::internal::UnitTestImpl::RunAllTests() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43
#10 0x1aa4d30 in 
HandleExceptionsInMethodIfSupported 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc
#11 0x1aa4d30 in testing::UnitTest::Run() 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/src/gtest.cc:4257
#12 0x1a6b656 in RUN_ALL_TESTS 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46
#13 0x1a6b656 in main 
/b/sanitizer-x86_64-linux-bootstrap/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:50
#14 0x7f5af37a22e0 in __libc_start_main 
(/lib/x86_64-linux-gnu/libc.so.6+0x202e0)

SUMMARY: AddressSanitizer: 168 byte(s) leaked in 2 allocation(s).
```

See 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/11358/steps/check-llvm%20asan/logs/stdio
 for more information.

Also introduces use-of-uninitialized-value in 
ConstantsTest.FoldGlobalVariablePtr:
```
==7070==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x14e703c in User 
/b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/IR/User.h:79:5
#1 0x14e703c in Constant 

r355537 - Revert "[IR][ARM] Add function pointer alignment to datalayout"

2019-03-06 Thread Mitch Phillips via cfe-commits
Author: hctim
Date: Wed Mar  6 11:17:18 2019
New Revision: 355537

URL: http://llvm.org/viewvc/llvm-project?rev=355537=rev
Log:
Revert "[IR][ARM] Add function pointer alignment to datalayout"

This reverts commit 2391bfca97290181ae65796ea6da135d1b6d037b.

This reverts rL355522 (https://reviews.llvm.org/D57335).

Kills buildbots that use '-Werror' with the following error:

/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm/lib/IR/Value.cpp:657:7:
 error: default label in switch which covers all enumeration values 
[-Werror,-Wcovered-switch-default]

See buildbots 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/30200/steps/check-llvm%20asan/logs/stdio
 for more information.

Modified:
cfe/trunk/lib/Basic/Targets/ARM.cpp
cfe/trunk/test/CodeGen/armv7k-abi.c
cfe/trunk/test/CodeGen/target-data.c

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=355537=355536=355537=diff
==
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Wed Mar  6 11:17:18 2019
@@ -40,14 +40,13 @@ void ARMTargetInfo::setABIAAPCS() {
   // so set preferred for small types to 32.
   if (T.isOSBinFormatMachO()) {
 resetDataLayout(BigEndian
-? "E-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
-: 
"e-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64");
+? "E-m:o-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+: "e-m:o-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64");
   } else if (T.isOSWindows()) {
 assert(!BigEndian && "Windows on ARM does not support big endian");
 resetDataLayout("e"
 "-m:w"
 "-p:32:32"
-"-Fi8"
 "-i64:64"
 "-v128:64:128"
 "-a:0:32"
@@ -55,11 +54,11 @@ void ARMTargetInfo::setABIAAPCS() {
 "-S64");
   } else if (T.isOSNaCl()) {
 assert(!BigEndian && "NaCl on ARM does not support big endian");
-resetDataLayout("e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S128");
+resetDataLayout("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S128");
   } else {
 resetDataLayout(BigEndian
-? "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
-: 
"e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64");
+? "E-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64");
   }
 
   // FIXME: Enumerated types are variable width in straight AAPCS.
@@ -88,17 +87,17 @@ void ARMTargetInfo::setABIAPCS(bool IsAA
 
   if (T.isOSBinFormatMachO() && IsAAPCS16) {
 assert(!BigEndian && "AAPCS16 does not support big-endian");
-resetDataLayout("e-m:o-p:32:32-Fi8-i64:64-a:0:32-n32-S128");
+resetDataLayout("e-m:o-p:32:32-i64:64-a:0:32-n32-S128");
   } else if (T.isOSBinFormatMachO())
 resetDataLayout(
 BigEndian
-? 
"E-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
-: 
"e-m:o-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32");
+? "E-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
+: "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32");
   else
 resetDataLayout(
 BigEndian
-? 
"E-m:e-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
-: 
"e-m:e-p:32:32-Fi8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32");
+? "E-m:e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
+: "e-m:e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32");
 
   // FIXME: Override "preferred align" for double and long long.
 }
@@ -1056,7 +1055,7 @@ CygwinARMTargetInfo::CygwinARMTargetInfo
   this->WCharType = TargetInfo::UnsignedShort;
   TLSSupported = false;
   DoubleAlign = LongLongAlign = 64;
-  resetDataLayout("e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64");
+  resetDataLayout("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64");
 }
 
 void CygwinARMTargetInfo::getTargetDefines(const LangOptions ,

Modified: cfe/trunk/test/CodeGen/armv7k-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/armv7k-abi.c?rev=355537=355536=355537=diff
==
--- cfe/trunk/test/CodeGen/armv7k-abi.c (original)
+++ cfe/trunk/test/CodeGen/armv7k-abi.c Wed Mar  6 11:17:18 2019
@@ -4,7 +4,7 @@
 
 // Make sure 64 and 128 bit types are naturally aligned by the v7k ABI:
 
-// CHECK: target datalayout = "e-m:o-p:32:32-Fi8-i64:64-a:0:32-n32-S128"
+// CHECK: target datalayout = "e-m:o-p:32:32-i64:64-a:0:32-n32-S128"
 
 typedef struct {
   float arr[4];

Modified: 

r353990 - [HWASAN] Updated HWASAN design document to better portray the chance of missing a bug.

2019-02-14 Thread Mitch Phillips via cfe-commits
Author: hctim
Date: Wed Feb 13 15:14:54 2019
New Revision: 353990

URL: http://llvm.org/viewvc/llvm-project?rev=353990=rev
Log:
[HWASAN] Updated HWASAN design document to better portray the chance of missing 
a bug.

Summary: Provided rule of thumb percentage chances of miss for 4 and 8 bit tag 
sizes.

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst

Modified: cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst?rev=353990=353989=353990=diff
==
--- cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst (original)
+++ cfe/trunk/docs/HardwareAssistedAddressSanitizerDesign.rst Wed Feb 13 
15:14:54 2019
@@ -131,7 +131,8 @@ HWASAN:
 https://www.kernel.org/doc/Documentation/arm64/tagged-pointers.txt).
   * **Does not require redzones to detect buffer overflows**,
 but the buffer overflow detection is probabilistic, with roughly
-`(2**TS-1)/(2**TS)` probability of catching a bug.
+`1/(2**TS)` chance of missing a bug (6.25% or 0.39% with 4 and 8-bit TS
+respectively).
   * **Does not require quarantine to detect heap-use-after-free,
 or stack-use-after-return**.
 The detection is similarly probabilistic.


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


r317616 - Update SanitizerSpecialCaseList to use renamed functions in base class.

2017-11-07 Thread Mitch Phillips via cfe-commits
Author: hctim
Date: Tue Nov  7 13:16:37 2017
New Revision: 317616

URL: http://llvm.org/viewvc/llvm-project?rev=317616=rev
Log:
Update SanitizerSpecialCaseList to use renamed functions in base class.

Note: This change has a cyclical dependency on D39485. Both these changes must 
be submitted at the same time to avoid a build breakage.

Reviewers: vlad.tsyrklevich

Subscribers: llvm-commits

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

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

Modified: cfe/trunk/lib/Basic/SanitizerSpecialCaseList.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SanitizerSpecialCaseList.cpp?rev=317616=317615=317616=diff
==
--- cfe/trunk/lib/Basic/SanitizerSpecialCaseList.cpp (original)
+++ cfe/trunk/lib/Basic/SanitizerSpecialCaseList.cpp Tue Nov  7 13:16:37 2017
@@ -57,7 +57,7 @@ bool SanitizerSpecialCaseList::inSection
  StringRef Category) const {
   for (auto  : SanitizerSections)
 if ((S.Mask & Mask) &&
-SpecialCaseList::inSection(S.Entries, Prefix, Query, Category))
+SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category))
   return true;
 
   return false;


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