[PATCH] D110833: [clang-format] Refactor SpaceBeforeParens to add options

2021-11-03 Thread Christian Rayroud via Phabricator via cfe-commits
crayroud updated this revision to Diff 384352.
crayroud marked an inline comment as done.
crayroud added a comment.

Reorder the options


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

https://reviews.llvm.org/D110833

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14133,6 +14133,173 @@
   verifyFormat("X A::operator++ (T);", SomeSpace);
   verifyFormat("int x = int (y);", SomeSpace);
   verifyFormat("auto lambda = []() { return 0; };", SomeSpace);
+
+  FormatStyle SpaceControlStatements = getLLVMStyle();
+  SpaceControlStatements.SpaceBeforeParens = FormatStyle::SBPO_Custom;
+  SpaceControlStatements.SpaceBeforeParensOptions.AfterControlStatements = true;
+
+  verifyFormat("while (true)\n"
+   "  continue;",
+   SpaceControlStatements);
+  verifyFormat("if (true)\n"
+   "  f();\n"
+   "else if (true)\n"
+   "  f();",
+   SpaceControlStatements);
+  verifyFormat("for (;;) {\n"
+   "  do_something();\n"
+   "}",
+   SpaceControlStatements);
+  verifyFormat("do {\n"
+   "  do_something();\n"
+   "} while (something());",
+   SpaceControlStatements);
+  verifyFormat("switch (x) {\n"
+   "default:\n"
+   "  break;\n"
+   "}",
+   SpaceControlStatements);
+
+  FormatStyle SpaceFuncDecl = getLLVMStyle();
+  SpaceFuncDecl.SpaceBeforeParens = FormatStyle::SBPO_Custom;
+  SpaceFuncDecl.SpaceBeforeParensOptions.AfterFunctionDeclarationName = true;
+
+  verifyFormat("int f ();", SpaceFuncDecl);
+  verifyFormat("void f(int a, T b) {}", SpaceFuncDecl);
+  verifyFormat("A::A() : a(1) {}", SpaceFuncDecl);
+  verifyFormat("void f () __attribute__((asdf));", SpaceFuncDecl);
+  verifyFormat("#define A(x) x", SpaceFuncDecl);
+  verifyFormat("#define A (x) x", SpaceFuncDecl);
+  verifyFormat("#if defined(x)\n"
+   "#endif",
+   SpaceFuncDecl);
+  verifyFormat("auto i = std::make_unique(5);", SpaceFuncDecl);
+  verifyFormat("size_t x = sizeof(x);", SpaceFuncDecl);
+  verifyFormat("auto f (int x) -> decltype(x);", SpaceFuncDecl);
+  verifyFormat("auto f (int x) -> typeof(x);", SpaceFuncDecl);
+  verifyFormat("auto f (int x) -> _Atomic(x);", SpaceFuncDecl);
+  verifyFormat("auto f (int x) -> __underlying_type(x);", SpaceFuncDecl);
+  verifyFormat("int f (T x) noexcept(x.create());", SpaceFuncDecl);
+  verifyFormat("alignas(128) char a[128];", SpaceFuncDecl);
+  verifyFormat("size_t x = alignof(MyType);", SpaceFuncDecl);
+  verifyFormat("static_assert(sizeof(char) == 1, \"Impossible!\");",
+   SpaceFuncDecl);
+  verifyFormat("int f () throw(Deprecated);", SpaceFuncDecl);
+  verifyFormat("typedef void (*cb)(int);", SpaceFuncDecl);
+  verifyFormat("T A::operator() ();", SpaceFuncDecl);
+  verifyFormat("X A::operator++ (T);", SpaceFuncDecl);
+  verifyFormat("T A::operator()() {}", SpaceFuncDecl);
+  verifyFormat("auto lambda = []() { return 0; };", SpaceFuncDecl);
+  verifyFormat("int x = int(y);", SpaceFuncDecl);
+  verifyFormat("M(std::size_t R, std::size_t C) : C(C), data(R) {}",
+   SpaceFuncDecl);
+
+  FormatStyle SpaceFuncDef = getLLVMStyle();
+  SpaceFuncDef.SpaceBeforeParens = FormatStyle::SBPO_Custom;
+  SpaceFuncDef.SpaceBeforeParensOptions.AfterFunctionDefinitionName = true;
+
+  verifyFormat("int f();", SpaceFuncDef);
+  verifyFormat("void f (int a, T b) {}", SpaceFuncDef);
+  verifyFormat("A::A() : a(1) {}", SpaceFuncDef);
+  verifyFormat("void f() __attribute__((asdf));", SpaceFuncDef);
+  verifyFormat("#define A(x) x", SpaceFuncDef);
+  verifyFormat("#define A (x) x", SpaceFuncDef);
+  verifyFormat("#if defined(x)\n"
+   "#endif",
+   SpaceFuncDef);
+  verifyFormat("auto i = std::make_unique(5);", SpaceFuncDef);
+  verifyFormat("size_t x = sizeof(x);", SpaceFuncDef);
+  verifyFormat("auto f(int x) -> decltype(x);", SpaceFuncDef);
+  verifyFormat("auto f(int x) -> typeof(x);", SpaceFuncDef);
+  verifyFormat("auto f(int x) -> _Atomic(x);", SpaceFuncDef);
+  verifyFormat("auto f(int x) -> __underlying_type(x);", SpaceFuncDef);
+  verifyFormat("int f(T x) noexcept(x.create());", SpaceFuncDef);
+  verifyFormat("alignas(128) char a[128];", SpaceFuncDef);
+  verifyFormat("size_t x = alignof(MyType);", SpaceFuncDef);
+  verifyFormat("static_assert(sizeof(char) == 1, \"Impossible!\");",
+   SpaceFuncDef);
+  verifyFormat("int f() throw(Deprecated);", SpaceFuncDef);
+  verifyFormat("typedef void (*cb)(int);", SpaceFuncDef);
+  verifyFormat("T A::operator()();", Spa

[PATCH] D110833: [clang-format] Refactor SpaceBeforeParens to add options

2021-11-03 Thread Christian Rayroud via Phabricator via cfe-commits
crayroud marked an inline comment as done.
crayroud added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:14275
+  verifyFormat("A::A() : a (1) {}", SomeSpace2);
+  verifyFormat("void f() __attribute__ ((asdf));", SomeSpace2);
+  verifyFormat("*(&a + 1);\n"

HazardyKnusperkeks wrote:
> Is this really desired?
It is allowed to have a space after `__attribute__` and the behaviour is the 
same with `SpaceBeforeParens: NonEmptyParentheses`.


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

https://reviews.llvm.org/D110833

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


[PATCH] D112349: [Verifier] Add verification logic for GlobalIFuncs

2021-11-03 Thread Itay Bookstein via Phabricator via cfe-commits
ibookstein added a comment.

Note that (as the examples demonstrate) clang self-verifies and checks among 
other things that ifuncs that it emits point to definitions; this happens in 
`CodeGenModule::checkAliases()`.
I haven't read the cpu_specific/cpu_dispatch-related code in CodeGenModule yet, 
but I'm guessing that it doesn't register the generated aliases/ifuncs into the 
`CodeGenModule::Aliases` vector for deferred verification, which is why this 
didn't trigger the same error that my ifunc example did so far.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112349

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


[PATCH] D112941: [clang] Add support for the new pointer authentication builtins.

2021-11-03 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

The original `ptrauth.h` has the same comment style. Would doxygen style be an 
improvement?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112941

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


[PATCH] D95168: [clang-format] Add InsertBraces option

2021-11-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D95168#3102511 , @MyDeveloperDay 
wrote:

> Then this is definitely why we want to think about these now and NOT leave 
> them to a separate review after the Insert case is committed.

We can just leave a placeholder for the RemoveBraces options and deal with them 
when we get there. Unless I misunderstood, your suggestion of the 
AutomaticBraces option (with `enum` values Insert, Remove, LLVM, etc) would 
accomplish that.

> If we think remove braces would be a struct then we'd better go for a struct 
> now and not later so there is some symmetry, I'm slightly wondering what 
> would be in the struct?

I already had an implementation of RemoveBraces for the LLVM style (minus some 
exceptions). I started with an `enum` to accommodate different levels of 
aggressiveness of removal with LLVM at the minimum end. After looking at 
several prominent styles, I realized that a `struct` would work better.

> 1. Do we want to remove {} from an else or elseif when the if needs braces
>
>   if (x==1) {
>  foo();
>  bar();
>   }
>   else  if (x==2)
> baz();
>   else 
> foo();
>
> 2. Do we want to remove braces from a commented if  (this can throw your eye 
> out when looking)
>
>   if (x==1)
>  // some longish comment
>  return x;
>
> 3. Do we want sub scope to be removed of braces too?
>
>   if (x==1)
>   for (int i=0;i<10;i++)
> foo();
>
> 4. Do we want to prevent the remove for MultiLine scope, where what follows 
> would be spread over multiple lines (a little like the comment really)
>
>   if (x== 1)
>   os << "This is a very very very long" 
><< data
><< "More data"
><< "endl;"
>   `

I've seen both yes and no for all the above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95168

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


[PATCH] D95168: [clang-format] Add InsertBraces option

2021-11-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

> I already had an implementation of RemoveBraces for the LLVM style (minus 
> some exceptions).

Why not share the implementation in a review then we can combine them here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95168

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


[PATCH] D105169: [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default

2021-11-03 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune added a comment.

In D105169#3104262 , @eugenis wrote:

> You are absolutely right. X86 variant uses an "=a" constraint (rax register), 
> others pin the output variable to a specific register with __asm__ 
> declaration. It appears we've missed it in Aarch64.
>
> Could you check if __asm__("x0") in the declaration of res helps?

Thank you, It worked!
Only a couple of failures in ASAN left, and we are investigating them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105169

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


[PATCH] D95168: [clang-format] Add InsertBraces option

2021-11-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D95168#3102550 , @MyDeveloperDay 
wrote:

> This is a demo of what I mean {https://reviews.llvm.org/D113000} you can see 
> its pretty aggressive, I could kind of imagine people wanting a little more 
> control
>
> Sometimes this feels inconsistent
>
> F20029866: image.png 
>
> and in this case the expression seem so separated from the if() that you 
> might want to keep the {}
>
> F20029887: image.png 

In my experience, the simplest thing to do is to remove all optional braces as 
allowed by the language syntax. When you want to add exceptions for matching 
if-else braces, avoiding dangling-else warnings, etc, things get much more 
complicated very quickly. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95168

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


[PATCH] D95168: [clang-format] Add InsertBraces option

2021-11-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.



> I'm in favor of a struct of enums:
>
>   AutomaticBraces:
> AfterIf: OnlyIfElse
> AfterElse: Remove #this is obviously only to remove, if the else body is 
> a single line
> AfterWhile: ...
>
> And we can gradually add new enumerators to handle the delicate nuances of 
> adding or removing the braces.
> And we should add them one after another.

I like this approach, let me switch over to a struct (that might take me a bit, 
I'll reorder on the way), I do sort of feel this is for both Inserting/Removing 
of Braces at the same time should also be the reverse.

i.e. we may not always want to add braces (but allow similar rules to LLVM 
style)

So a clang-format could be a combination of adding and removing braces 
depending on the location and usecase, hence in my view why we might as well do 
this all in one review. I personally wouldn't want 1 implementation for 
inserting and 1 for removing hence they need to share that configuration.

@tiagoma, I'm going to change the name of the class and file too, just to make 
that its both Inserting and Removing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95168

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


[clang] 3d32218 - [VE] Change to omitting the frame pointer on leaf functions

2021-11-03 Thread Kazushi Marukawa via cfe-commits

Author: Kazushi (Jam) Marukawa
Date: 2021-11-03T17:45:18+09:00
New Revision: 3d32218d1af29a86389357b75af31af36dec051a

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

LOG: [VE] Change to omitting the frame pointer on leaf functions

Change to omitting the frame pointer on leaf functions by default for VE.

Reviewed By: simoll

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/frame-pointer-elim.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c77413ddf1ace..2dd10a7b31061 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -613,7 +613,8 @@ getFramePointerKind(const ArgList &Args, const llvm::Triple 
&Triple) {
   A && A->getOption().matches(options::OPT_fno_omit_frame_pointer);
   bool OmitLeafFP = Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
  options::OPT_mno_omit_leaf_frame_pointer,
- Triple.isAArch64() || Triple.isPS4CPU());
+ Triple.isAArch64() || Triple.isPS4CPU() ||
+ Triple.isVE());
   if (NoOmitFP || mustUseNonLeafFramePointerForTarget(Triple) ||
   (!OmitFP && useFramePointerForTargetByDefault(Args, Triple))) {
 if (OmitLeafFP)

diff  --git a/clang/test/Driver/frame-pointer-elim.c 
b/clang/test/Driver/frame-pointer-elim.c
index 83dbf3816b684..beb14a9a671a6 100644
--- a/clang/test/Driver/frame-pointer-elim.c
+++ b/clang/test/Driver/frame-pointer-elim.c
@@ -90,7 +90,8 @@
 // WARN-OMIT-LEAF-7S-NOT: warning: optimization flag 
'-momit-leaf-frame-pointer' is not supported for target 'armv7s'
 // WARN-OMIT-LEAF-7S: "-mframe-pointer=non-leaf"
 
-// On AArch64 and PS4, default to omitting the frame pointer on leaf functions
+// On AArch64, PS4, and VE, default to omitting the frame pointer on leaf
+// functions
 // RUN: %clang -### -target aarch64 -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 // RUN: %clang -### -target x86_64-scei-ps4 -S %s 2>&1 | \
@@ -99,6 +100,8 @@
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 // RUN: %clang -### -target aarch64-apple-darwin -arch arm64_32 -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
+// RUN: %clang -### -target ve-unknown-linux-gnu -S %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 
 // RUN: %clang -### -target powerpc64 -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-ALL %s



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


[PATCH] D113087: [VE] Change to omitting the frame pointer on leaf functions

2021-11-03 Thread Kazushi Marukawa via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3d32218d1af2: [VE] Change to omitting the frame pointer on 
leaf functions (authored by kaz7).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113087

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/frame-pointer-elim.c


Index: clang/test/Driver/frame-pointer-elim.c
===
--- clang/test/Driver/frame-pointer-elim.c
+++ clang/test/Driver/frame-pointer-elim.c
@@ -90,7 +90,8 @@
 // WARN-OMIT-LEAF-7S-NOT: warning: optimization flag 
'-momit-leaf-frame-pointer' is not supported for target 'armv7s'
 // WARN-OMIT-LEAF-7S: "-mframe-pointer=non-leaf"
 
-// On AArch64 and PS4, default to omitting the frame pointer on leaf functions
+// On AArch64, PS4, and VE, default to omitting the frame pointer on leaf
+// functions
 // RUN: %clang -### -target aarch64 -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 // RUN: %clang -### -target x86_64-scei-ps4 -S %s 2>&1 | \
@@ -99,6 +100,8 @@
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 // RUN: %clang -### -target aarch64-apple-darwin -arch arm64_32 -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
+// RUN: %clang -### -target ve-unknown-linux-gnu -S %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 
 // RUN: %clang -### -target powerpc64 -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-ALL %s
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -613,7 +613,8 @@
   A && A->getOption().matches(options::OPT_fno_omit_frame_pointer);
   bool OmitLeafFP = Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
  options::OPT_mno_omit_leaf_frame_pointer,
- Triple.isAArch64() || Triple.isPS4CPU());
+ Triple.isAArch64() || Triple.isPS4CPU() ||
+ Triple.isVE());
   if (NoOmitFP || mustUseNonLeafFramePointerForTarget(Triple) ||
   (!OmitFP && useFramePointerForTargetByDefault(Args, Triple))) {
 if (OmitLeafFP)


Index: clang/test/Driver/frame-pointer-elim.c
===
--- clang/test/Driver/frame-pointer-elim.c
+++ clang/test/Driver/frame-pointer-elim.c
@@ -90,7 +90,8 @@
 // WARN-OMIT-LEAF-7S-NOT: warning: optimization flag '-momit-leaf-frame-pointer' is not supported for target 'armv7s'
 // WARN-OMIT-LEAF-7S: "-mframe-pointer=non-leaf"
 
-// On AArch64 and PS4, default to omitting the frame pointer on leaf functions
+// On AArch64, PS4, and VE, default to omitting the frame pointer on leaf
+// functions
 // RUN: %clang -### -target aarch64 -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 // RUN: %clang -### -target x86_64-scei-ps4 -S %s 2>&1 | \
@@ -99,6 +100,8 @@
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 // RUN: %clang -### -target aarch64-apple-darwin -arch arm64_32 -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
+// RUN: %clang -### -target ve-unknown-linux-gnu -S %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 
 // RUN: %clang -### -target powerpc64 -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-ALL %s
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -613,7 +613,8 @@
   A && A->getOption().matches(options::OPT_fno_omit_frame_pointer);
   bool OmitLeafFP = Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
  options::OPT_mno_omit_leaf_frame_pointer,
- Triple.isAArch64() || Triple.isPS4CPU());
+ Triple.isAArch64() || Triple.isPS4CPU() ||
+ Triple.isVE());
   if (NoOmitFP || mustUseNonLeafFramePointerForTarget(Triple) ||
   (!OmitFP && useFramePointerForTargetByDefault(Args, Triple))) {
 if (OmitLeafFP)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95168: [clang-format] Add InsertBraces option

2021-11-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

> In my experience, the simplest thing to do is to remove all optional braces 
> as allowed by the language syntax. When you want to add exceptions for 
> matching if-else braces, avoiding dangling-else warnings, etc, things get 
> much more complicated very quickly. :)

I can well imagine. I already hit this once where I mutated the 
TokenAnnotator.cpp incorrect (which caused the unit tests to break). 
TokenAnnotator.cpp is if/else hell as far as I'm concerned, its a really good 
test best for some of this stuff!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95168

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


[PATCH] D95168: [clang-format] Add InsertBraces option

2021-11-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D95168#3105340 , @MyDeveloperDay 
wrote:

>> I already had an implementation of RemoveBraces for the LLVM style (minus 
>> some exceptions).
>
> Why not share the implementation in a review then we can combine them here.

I want to try implementing the remaining exceptions for LLVM and tighten some 
loose ends before submitting the patch. I don't think we should combine Insert 
and Remove (even if it's technically possible) before each has been tested 
against a large codebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95168

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


[clang] a8083d4 - [X86][clang] Disable long double type for -mno-x87 option

2021-11-03 Thread Andrew Savonichev via cfe-commits

Author: Andrew Savonichev
Date: 2021-11-03T12:08:39+03:00
New Revision: a8083d42b1c346e21623a1d36d1f0cadd7801d83

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

LOG: [X86][clang] Disable long double type for -mno-x87 option

This patch attempts to fix a compiler crash that occurs when long
double type is used with -mno-x87 compiler option.

The option disables x87 target feature, which in turn disables x87
registers, so CG cannot select them for x86_fp80 LLVM IR type. Long
double is lowered as x86_fp80 for some targets, so it leads to a
crash.

The option seems to contradict the SystemV ABI, which requires long
double to be represented as a 80-bit floating point, and it also
requires to use x87 registers.

To avoid that, `long double` type is disabled when -mno-x87 option is
set. In addition to that, `float` and `double` also use x87 registers
for return values on 32-bit x86, so they are disabled as well.

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

Added: 
clang/test/Sema/x86-no-x87.cpp
clang/test/Sema/x86_64-no-x87.cpp

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/X86.cpp
clang/lib/Basic/Targets/X86.h
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaSYCL/float128.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index a67ef684f1e5c..fd5d7fb8168c6 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10714,8 +10714,8 @@ def err_omp_invariant_or_linear_dependency : Error<
 def err_omp_wrong_dependency_iterator_type : Error<
   "expected an integer or a pointer type of the outer loop counter '%0' for 
non-rectangular nests">;
 def err_target_unsupported_type
-: Error<"%0 requires %select{|%2 bit size}1 %3 type support, but target "
-"'%4' does not support it">;
+: Error<"%0 requires %select{|%2 bit size}1 %3 %select{|return }4type 
support,"
+" but target '%5' does not support it">;
 def err_omp_lambda_capture_in_declare_target_not_to : Error<
   "variable captured in declare target region must appear in a to clause">;
 def err_omp_device_type_mismatch : Error<

diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 77a510462a65e..3e1e09417c661 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -203,6 +203,8 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   bool HasFloat16;
   bool HasBFloat16;
   bool HasIbm128;
+  bool HasLongDouble;
+  bool HasFPReturn;
   bool HasStrictFP;
 
   unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
@@ -601,6 +603,13 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Determine whether the __ibm128 type is supported on this target.
   virtual bool hasIbm128Type() const { return HasIbm128; }
 
+  /// Determine whether the long double type is supported on this target.
+  virtual bool hasLongDoubleType() const { return HasLongDouble; }
+
+  /// Determine whether return of a floating point value is supported
+  /// on this target.
+  virtual bool hasFPReturn() const { return HasFPReturn; }
+
   /// Determine whether constrained floating point is supported on this target.
   virtual bool hasStrictFP() const { return HasStrictFP; }
 

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 76855b0c045c5..646bbe8b73873 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -37,6 +37,8 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), 
Triple(T) {
   HasIbm128 = false;
   HasFloat16 = false;
   HasBFloat16 = false;
+  HasLongDouble = true;
+  HasFPReturn = true;
   HasStrictFP = false;
   PointerWidth = PointerAlign = 32;
   BoolWidth = BoolAlign = 8;

diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index f40d8a6ed7312..454a7743dded3 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -338,6 +338,8 @@ bool 
X86TargetInfo::handleTargetFeatures(std::vector &Features,
   HasUINTR = true;
 } else if (Feature == "+crc32") {
   HasCRC32 = true;
+} else if (Feature == "+x87") {
+  HasX87 = true;
 }
 
 X86SSEEnum Level = llvm::StringSwitch(Feature)
@@ -379,6 +381,14 @@ bool 
X86TargetInfo::handleTargetFeatures(std::vector &Features,
 
   SimdDefaultAlign =
   hasFeature("avx512f") ? 512 : hasFeature("avx") ? 256 : 128;
+
+  if (!HasX87) {
+if (LongDoubleFormat == &llvm::APFloat::x87DoubleExtended())
+  Has

[PATCH] D98895: [X86][clang] Disable long double type for -mno-x87 option

2021-11-03 Thread Andrew Savonichev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa8083d42b1c3: [X86][clang] Disable long double type for 
-mno-x87 option (authored by asavonic).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98895

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/x86-no-x87.cpp
  clang/test/Sema/x86_64-no-x87.cpp
  clang/test/SemaSYCL/float128.cpp

Index: clang/test/SemaSYCL/float128.cpp
===
--- clang/test/SemaSYCL/float128.cpp
+++ clang/test/SemaSYCL/float128.cpp
@@ -22,6 +22,8 @@
   C.field1 = A;
 }
 
+long double ld_func(long double arg);
+
 void usage() {
   // expected-note@+1 3{{'A' defined here}}
   __float128 A;
@@ -48,6 +50,9 @@
 float F2 = 0.1f;
 // expected-error@+1 3{{expression requires 128 bit size '__float128' type support, but target 'spir64' does not support it}}
 float F3 = ((__float128)F1 * (__float128)F2) / 2.0f;
+
+// assume that long double is supported
+float F4 = ld_func(F3);
   };
 
   // expected-note@+1 {{called by 'usage'}}
Index: clang/test/Sema/x86_64-no-x87.cpp
===
--- /dev/null
+++ clang/test/Sema/x86_64-no-x87.cpp
@@ -0,0 +1,145 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -target-feature -x87
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -DNOERROR
+
+#ifdef NOERROR
+// expected-no-diagnostics
+#endif
+
+typedef long double long_double;
+
+// Declaration is fine, unless it is called or defined.
+double decl(long_double x, long_double y);
+
+template 
+T decl_ld_del(T);
+
+// No code is generated for deleted functions
+long_double decl_ld_del(long_double) = delete;
+double decl_ld_del(double) = delete;
+float decl_ld_del(float) = delete;
+
+#ifndef NOERROR
+// expected-error@+4{{'def' requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+// expected-note@+3{{'def' defined here}}
+// expected-note@+2{{'x' defined here}}
+#endif
+int def(long_double x) {
+#ifndef NOERROR
+// expected-error@+2{{'x' requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+#endif
+  return (int)x;
+}
+
+#ifndef NOERROR
+// expected-note@+3{{'ld_args' defined here}}
+// expected-note@+2{{'ld_args' defined here}}
+#endif
+int ld_args(long_double x, long_double y);
+
+int call1(float x, float y) {
+#ifndef NOERROR
+  // expected-error@+2 2{{'ld_args' requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+#endif
+  return ld_args(x, y);
+}
+
+#ifndef NOERROR
+// expected-note@+2{{'ld_ret' defined here}}
+#endif
+long_double ld_ret(double x, double y);
+
+int call2(float x, float y) {
+#ifndef NOERROR
+  // expected-error@+2{{'ld_ret' requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+#endif
+  return (int)ld_ret(x, y);
+}
+
+int binop(double x, double y) {
+#ifndef NOERROR
+  // expected-error@+2 2{{expression requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+#endif
+  double z = (long_double)x * (long_double)y;
+  return (int)z;
+}
+
+void assign1(long_double *ret, double x) {
+#ifndef NOERROR
+  // expected-error@+2{{expression requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+#endif
+  *ret = x;
+}
+
+struct st_long_double1 {
+#ifndef NOERROR
+  // expected-note@+2{{'ld' defined here}}
+#endif
+  long_double ld;
+};
+
+struct st_long_double2 {
+#ifndef NOERROR
+  // expected-note@+2{{'ld' defined here}}
+#endif
+  long_double ld;
+};
+
+struct st_long_double3 {
+#ifndef NOERROR
+  // expected-note@+2{{'ld' defined here}}
+#endif
+  long_double ld;
+};
+
+void assign2() {
+  struct st_long_double1 st;
+#ifndef NOERROR
+  // expected-error@+3{{expression requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+  // expected-error@+2{{'ld' requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+#endif
+  st.ld = 0.42;
+}
+
+void assign3() {
+  struct st_long_double2 st;
+#ifndef NOERROR
+  // expected-error@+3{{expression requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+  // expected-error@+2{{'ld' requires  'long_double' (aka 'long doubl

[PATCH] D106823: [analyzer][solver] Iterate to a fixpoint during symbol simplification with constants

2021-11-03 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1732
+  if (!State)
+return false;
+}

martong wrote:
> steakhal wrote:
> > I'd love to see a coverage report of the tests you add with this patch.
> Ok, I am going to check the coverage and add the missing cases.
> Ok, I am going to check the coverage and add the missing cases.
As of diff 5, line 1767 and all the code in the block at line 2184 are 
uncovered by the tests you provided.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106823

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


[PATCH] D112055: [PowerPC] Implement longdouble pack/unpack builtins

2021-11-03 Thread Qiu Chaofan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
qiucf marked 3 inline comments as done.
Closed by commit rG741aeda97d63: [PowerPC] Implement longdouble pack/unpack 
builtins (authored by qiucf).

Changed prior to commit:
  https://reviews.llvm.org/D112055?vs=380596&id=384378#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112055

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc.c
  llvm/include/llvm/IR/Intrinsics.h
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/IR/Function.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/longdouble-pack.ll
  llvm/utils/TableGen/IntrinsicEmitter.cpp

Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
===
--- llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -249,7 +249,8 @@
   IIT_BF16 = 48,
   IIT_STRUCT9 = 49,
   IIT_V256 = 50,
-  IIT_AMX  = 51
+  IIT_AMX  = 51,
+  IIT_PPCF128 = 52
 };
 
 static void EncodeFixedValueType(MVT::SimpleValueType VT,
@@ -274,6 +275,7 @@
   case MVT::f32: return Sig.push_back(IIT_F32);
   case MVT::f64: return Sig.push_back(IIT_F64);
   case MVT::f128: return Sig.push_back(IIT_F128);
+  case MVT::ppcf128: return Sig.push_back(IIT_PPCF128);
   case MVT::token: return Sig.push_back(IIT_TOKEN);
   case MVT::Metadata: return Sig.push_back(IIT_METADATA);
   case MVT::x86mmx: return Sig.push_back(IIT_MMX);
Index: llvm/test/CodeGen/PowerPC/longdouble-pack.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/longdouble-pack.ll
@@ -0,0 +1,34 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=powerpc64le-unknown-linux < %s | FileCheck %s
+; RUN: llc -mtriple=powerpc64-ibm-aix-xcoff < %s | FileCheck %s
+
+define double @ldbl_1(ppc_fp128 %x) {
+; CHECK-LABEL: ldbl_1:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:fmr 1, 2
+; CHECK-NEXT:blr
+entry:
+  %0 = call double @llvm.ppc.unpack.longdouble(ppc_fp128 %x, i32 0)
+  ret double %0
+}
+
+define double @ldbl_2(ppc_fp128 %x) {
+; CHECK-LABEL: ldbl_2:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:blr
+entry:
+  %0 = call double @llvm.ppc.unpack.longdouble(ppc_fp128 %x, i32 1)
+  ret double %0
+}
+
+define ppc_fp128 @ldbl_pack(double %x, double %y) {
+; CHECK-LABEL: ldbl_pack:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:blr
+entry:
+  %0 = call ppc_fp128 @llvm.ppc.pack.longdouble(double %x, double %y)
+  ret ppc_fp128 %0
+}
+
+declare double @llvm.ppc.unpack.longdouble(ppc_fp128, i32)
+declare ppc_fp128 @llvm.ppc.pack.longdouble(double, double)
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -601,6 +601,8 @@
 
   // We want to custom lower some of our intrinsics.
   setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::Other, Custom);
+  setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::f64, Custom);
+  setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::ppcf128, Custom);
 
   // To handle counter-based loop conditions.
   setOperationAction(ISD::INTRINSIC_W_CHAIN, MVT::i1, Custom);
@@ -10428,6 +10430,16 @@
 }
 return DAG.getMergeValues(RetOps, dl);
   }
+
+  case Intrinsic::ppc_unpack_longdouble: {
+auto *Idx = dyn_cast(Op.getOperand(2));
+assert(Idx && (Idx->getSExtValue() == 0 || Idx->getSExtValue() == 1) &&
+   "Argument of long double unpack must be 0 or 1!");
+return DAG.getNode(ISD::EXTRACT_ELEMENT, dl, MVT::f64, Op.getOperand(1),
+   DAG.getConstant(!!(Idx->getSExtValue()), dl,
+   Idx->getValueType(0)));
+  }
+
   case Intrinsic::ppc_compare_exp_lt:
   case Intrinsic::ppc_compare_exp_gt:
   case Intrinsic::ppc_compare_exp_eq:
@@ -11109,6 +11121,15 @@
 Results.push_back(NewInt.getValue(1));
 break;
   }
+  case ISD::INTRINSIC_WO_CHAIN: {
+unsigned IntrinsicID =
+cast(N->getOperand(0))->getZExtValue();
+
+if (IntrinsicID == Intrinsic::ppc_pack_longdouble)
+  Results.push_back(DAG.getNode(ISD::BUILD_PAIR, dl, MVT::ppcf128,
+N->getOperand(2), N->getOperand(1)));
+break;
+  }
   case ISD::VAARG: {
 if (!Subtarget.isSVR4ABI() || Subtarget.isPPC64())
   return;
Index: llvm/lib/IR/Function.cpp
===
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -979,7 +979,8 @@
   IIT_BF16 = 48,
   IIT_STRUCT9 = 49,
   IIT_V256 = 50,
-  IIT_AMX  = 51
+  IIT_AMX  = 51,
+  IIT_PPCF1

[clang] 741aeda - [PowerPC] Implement longdouble pack/unpack builtins

2021-11-03 Thread Qiu Chaofan via cfe-commits

Author: Qiu Chaofan
Date: 2021-11-03T17:57:25+08:00
New Revision: 741aeda97d6327edd9905b21a5308fcee21bbefd

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

LOG: [PowerPC] Implement longdouble pack/unpack builtins

Implement two builtins to pack/unpack IBM extended long double float,
according to GCC 'Basic PowerPC Builtin Functions Available ISA 2.05'.

Reviewed By: jsji

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

Added: 
llvm/test/CodeGen/PowerPC/longdouble-pack.ll

Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/builtins-ppc.c
llvm/include/llvm/IR/Intrinsics.h
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/IR/Function.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/utils/TableGen/IntrinsicEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index f82d455506860..cd6b2df10e521 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -780,6 +780,10 @@ BUILTIN(__builtin_cfuged, "ULLiULLiULLi", "")
 BUILTIN(__builtin_cntlzdm, "ULLiULLiULLi", "")
 BUILTIN(__builtin_cnttzdm, "ULLiULLiULLi", "")
 
+// Double-double (un)pack
+BUILTIN(__builtin_unpack_longdouble, "dLdIi", "")
+BUILTIN(__builtin_pack_longdouble, "Lddd", "")
+
 // Generate random number
 BUILTIN(__builtin_darn, "LLi", "")
 BUILTIN(__builtin_darn_raw, "LLi", "")

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index fd5d7fb8168c6..1f2f84bdee4b8 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9802,6 +9802,8 @@ def err_ppc_builtin_only_on_arch : Error<
   "this builtin is only valid on POWER%0 or later CPUs">;
 def err_ppc_builtin_requires_vsx : Error<
   "this builtin requires VSX to be enabled">;
+def err_ppc_builtin_requires_abi : Error<
+  "this builtin requires ABI -mabi=%0">;
 def err_ppc_invalid_use_mma_type : Error<
   "invalid use of PPC MMA type">;
 def err_ppc_invalid_test_data_class_type : Error<

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 84cebb03b5f02..172357be9d862 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3382,6 +3382,18 @@ bool Sema::CheckPPCBuiltinFunctionCall(const TargetInfo 
&TI, unsigned BuiltinID,
   case PPC::BI__builtin_tabortdci:
 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31) ||
SemaBuiltinConstantArgRange(TheCall, 2, 0, 31);
+  // According to GCC 'Basic PowerPC Built-in Functions Available on ISA 2.05',
+  // __builtin_(un)pack_longdouble are available only if long double uses IBM
+  // extended double representation.
+  case PPC::BI__builtin_unpack_longdouble:
+if (SemaBuiltinConstantArgRange(TheCall, 1, 0, 1))
+  return true;
+LLVM_FALLTHROUGH;
+  case PPC::BI__builtin_pack_longdouble:
+if (&TI.getLongDoubleFormat() != &llvm::APFloat::PPCDoubleDouble())
+  return Diag(TheCall->getBeginLoc(), diag::err_ppc_builtin_requires_abi)
+ << "ibmlongdouble";
+return false;
   case PPC::BI__builtin_altivec_dst:
   case PPC::BI__builtin_altivec_dstt:
   case PPC::BI__builtin_altivec_dstst:

diff  --git a/clang/test/CodeGen/builtins-ppc.c 
b/clang/test/CodeGen/builtins-ppc.c
index 89c2df45a9f56..cbd53346d4b0f 100644
--- a/clang/test/CodeGen/builtins-ppc.c
+++ b/clang/test/CodeGen/builtins-ppc.c
@@ -36,3 +36,13 @@ void test_builtin_ppc_flm() {
   // CHECK: call double @llvm.ppc.setflm(double %1)
   res = __builtin_setflm(res);
 }
+
+double test_builtin_unpack_ldbl(long double x) {
+  // CHECK: call double @llvm.ppc.unpack.longdouble(ppc_fp128 %0, i32 1)
+  return __builtin_unpack_longdouble(x, 1);
+}
+
+long double test_builtin_pack_ldbl(double x, double y) {
+  // CHECK: call ppc_fp128 @llvm.ppc.pack.longdouble(double %0, double %1)
+  return __builtin_pack_longdouble(x, y);
+}

diff  --git a/llvm/include/llvm/IR/Intrinsics.h 
b/llvm/include/llvm/IR/Intrinsics.h
index 80a2f5a8cd3e4..2ff48380ac282 100644
--- a/llvm/include/llvm/IR/Intrinsics.h
+++ b/llvm/include/llvm/IR/Intrinsics.h
@@ -140,7 +140,8 @@ namespace Intrinsic {
   Subdivide2Argument,
   Subdivide4Argument,
   VecOfBitcastsToInt,
-  AMX
+  AMX,
+  PPCQuad,
 } Kind;
 
 union {

diff  --git a/llvm/include/llvm/IR/IntrinsicsPowerPC.td 
b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
index e60bad8fd9f0c..8b158aa99de0e 100644
--- a/llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -50,6 +50,15 @@ let TargetPrefix = "ppc

[PATCH] D112914: Misleading identifier detection

2021-11-03 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 384381.
serge-sans-paille added a comment.

Fix comments


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

https://reviews.llvm.org/D112914

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.cpp
  clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-misleading-identifier.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-misleading-identifier.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc-misleading-identifier.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc-misleading-identifier.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s misc-misleading-identifier %t
+
+#include 
+
+// CHECK-MESSAGES: :[[@LINE+1]]:1: warning: identifier has right-to-left codepoints
+short int א = (short int)0;
+// CHECK-MESSAGES: :[[@LINE+1]]:1: warning: identifier has right-to-left codepoints
+short int ג = (short int)12345;
+
+int main() {
+  // CHECK-MESSAGES: :[[@LINE+1]]:5: warning: identifier has right-to-left codepoints
+  int א = ג; // a local variable, set to zero?
+  printf("ג is %d\n", ג);
+  printf("א is %d\n", א);
+}
Index: clang-tools-extra/docs/clang-tidy/checks/misc-misleading-identifier.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/misc-misleading-identifier.rst
@@ -0,0 +1,23 @@
+.. title:: clang-tidy - misc-misleading-identifier
+
+misc-misleading-identifier
+==
+
+Finds identifiers that contain Unicode characters with right-to-left direction,
+which can be confusing as they may change the understanding of a whole statement
+line, as described in `Trojan Source `_.
+
+An example of such misleading code follows:
+
+.. code-block:: c
+
+#include 
+
+short int א = (short int)0;
+short int ג = (short int)12345;
+
+int main() {
+  int א = ג; // a local variable, set to zero?
+  printf("ג is %d\n", ג);
+  printf("א is %d\n", א);
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -211,6 +211,7 @@
`llvmlibc-implementation-in-namespace `_,
`llvmlibc-restrict-system-libc-headers `_, "Yes"
`misc-definitions-in-headers `_, "Yes"
+   `misc-misleading-identifier `_,
`misc-misplaced-const `_,
`misc-new-delete-overloads `_,
`misc-no-recursion `_,
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -94,12 +94,15 @@
   Reports identifiers whose names are too short. Currently checks local
   variables and function parameters only.
 
-
 - New :doc:`readability-data-pointer ` check.
 
   Finds cases where code could use ``data()`` rather than the address of the
   element at index 0 in a container.
 
+- New :doc:`misc-misleading-identifier ` check.
+
+  Reports identifier with unicode right-to-left characters.
+
 New check aliases
 ^
 
Index: clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.h
@@ -0,0 +1,31 @@
+//===--- MisleadingIdentifierCheck.h - clang-tidy ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIERCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIERCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+class MisleadingIdentifierCheck : public ClangTidyCheck {
+public:
+  MisleadingIdentifierCheck(StringRef Name, ClangTidyContext *Context);
+  ~MisleadingIdentifierCheck();
+
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace misc
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIERCHECK_H
Index: clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.cpp
===
--- /dev/null
+++ clang-tools-extra/clan

[PATCH] D103395: PR45879: Keep evaluated expression in LValue object

2021-11-03 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 384386.
sepavloff added a comment.

Updated patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103395

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp

Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1447,3 +1447,11 @@
   constexpr bool b = [a = S(), b = S()] { return a.p == b.p; }();
   static_assert(!b);
 }
+
+namespace PR45879 {
+struct Base {
+  int m;
+};
+struct Derived : Base {};
+constexpr int k = ((Base{} = Derived{}), 0);
+} // namespace PR45879
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -1546,6 +1546,7 @@
 APValue::LValueBase Base;
 CharUnits Offset;
 SubobjectDesignator Designator;
+const Expr *LExpr = nullptr;
 bool IsNullPtr : 1;
 bool InvalidBase : 1;
 
@@ -1554,6 +1555,7 @@
 const CharUnits &getLValueOffset() const { return Offset; }
 SubobjectDesignator &getLValueDesignator() { return Designator; }
 const SubobjectDesignator &getLValueDesignator() const { return Designator;}
+const Expr *getExpr() const { return LExpr; }
 bool isNullPointer() const { return IsNullPtr;}
 
 unsigned getLValueCallIndex() const { return Base.getCallIndex(); }
@@ -1591,6 +1593,8 @@
   Offset = CharUnits::fromQuantity(0);
   InvalidBase = BInvalid;
   Designator = SubobjectDesignator(getType(B));
+  if (!LExpr)
+LExpr = B.dyn_cast();
   IsNullPtr = false;
 }
 
@@ -6100,8 +6104,11 @@
 if (!handleTrivialCopy(Info, MD->getParamDecl(0), Args[0], RHSValue,
MD->getParent()->isUnion()))
   return false;
+const Expr *LHS = This->getExpr();
+if (!LHS)
+  return false;
 if (Info.getLangOpts().CPlusPlus20 && MD->isTrivial() &&
-!HandleUnionActiveMemberChange(Info, Args[0], *This))
+!HandleUnionActiveMemberChange(Info, LHS, *This))
   return false;
 if (!handleAssignment(Info, Args[0], *This, MD->getThisType(),
   RHSValue))
@@ -8058,10 +8065,20 @@
 namespace {
 class LValueExprEvaluator
   : public LValueExprEvaluatorBase {
+  friend class LValueExprEvaluatorBase;
+  friend class ExprEvaluatorBase;
+  friend class ConstStmtVisitor;
+  friend class StmtVisitorBase;
 public:
   LValueExprEvaluator(EvalInfo &Info, LValue &Result, bool InvalidBaseOK) :
 LValueExprEvaluatorBaseTy(Info, Result, InvalidBaseOK) {}
 
+  bool Evaluate(const Expr *E) {
+Result.LExpr = E;
+return Visit(E);
+  }
+
+protected:
   bool VisitVarDecl(const Expr *E, const VarDecl *VD);
   bool VisitUnaryPreIncDec(const UnaryOperator *UO);
 
@@ -8123,7 +8140,7 @@
   assert(!E->isValueDependent());
   assert(E->isGLValue() || E->getType()->isFunctionType() ||
  E->getType()->isVoidType() || isa(E));
-  return LValueExprEvaluator(Info, Result, InvalidBaseOK).Visit(E);
+  return LValueExprEvaluator(Info, Result, InvalidBaseOK).Evaluate(E);
 }
 
 bool LValueExprEvaluator::VisitDeclRefExpr(const DeclRefExpr *E) {
@@ -8424,7 +8441,7 @@
 
   // C++17 onwards require that we evaluate the RHS first.
   APValue RHS;
-  if (!Evaluate(RHS, this->Info, CAO->getRHS())) {
+  if (!::Evaluate(RHS, this->Info, CAO->getRHS())) {
 if (!Info.noteFailure())
   return false;
 Success = false;
@@ -8448,7 +8465,7 @@
 
   // C++17 onwards require that we evaluate the RHS first.
   APValue NewVal;
-  if (!Evaluate(NewVal, this->Info, E->getRHS())) {
+  if (!::Evaluate(NewVal, this->Info, E->getRHS())) {
 if (!Info.noteFailure())
   return false;
 Success = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95168: [clang-format] Add InsertBraces option

2021-11-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/BraceInserter.cpp:105
+  FormatToken *getNext(int &Line, FormatToken *current) {
+if (Line == 0 && current == nullptr) {
+  return Lines[0]->First;

HazardyKnusperkeks wrote:
> Remove the {
> Oh the irony. :)
I know!, I'm glad you liked that! (sorry!)

To be honest I can't help myself when I work in LLVM, because this is our 
company's style, but really this is why I'm keen to add "Remove" support 
because I need something to keep me honest.

I'm not going to feel that bad, I've run this ability to remove {} over parts 
of the LLVM code already, its "carnage!!!"

We ALL haven't been keeping a consistent style, My only hope is as we cover 
some of the LLVM specific cases the amount of churn will reduce (but don't hold 
your breath!!!) 

But I think this is why this is a good idea of @tiagoma , having something like 
this in clang-format is quite an eye opener. I've already used the Insert 
ability in our company's legacy code and its great!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95168

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


[PATCH] D103395: PR45879: Keep evaluated expression in LValue object

2021-11-03 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Thank you for feedback!

In D103395#3096177 , @tambre wrote:

> This breaks the following code:
>
>   struct sub
>   {
>   char data;
>   };
>   
>   struct main
>   {
>   constexpr main()
>   {
>   member = {};
>   }
>   
>   sub member;
>   };
>   
>   constexpr main a{};
>
> With:
>
>   fmt.cpp:16:16: error: constexpr variable 'a' must be initialized by a 
> constant expression
>   constexpr main a{};
>  ^~~
>   1 error generated.
>
> Clang trunk and GCC (Debian 11.2.0-10) handle it fine.
> Noticed in libfmt 
> .

Strange, I see that it cannot be compiled neither by gcc nor by clang: 
https://godbolt.org/z/1dY9Gs6zM. Do I miss something?




Comment at: clang/lib/AST/ExprConstant.cpp:1584-1585
   Designator = SubobjectDesignator(getType(B));
+  if (!LExpr)
+LExpr = B.dyn_cast();
   IsNullPtr = false;

aaron.ballman wrote:
> Should we be asserting that `LExpr` is null?
`LExpr` is initialized only once, when LValue starts evaluation. Later on the 
evaluation can proceed to subexpressions but the upper expression is sufficient 
to detect active union member change.



Comment at: clang/lib/AST/ExprConstant.cpp:8049
 
+  bool evaluate(const Expr *E) {
+Result.LExpr = E;

aaron.ballman wrote:
> It's not super clear to me when consumers should call `Evaluate()` instead of 
> calling `Visit()`. Some comments on the function may help make it more clear.
`Visit` methods are now made non-public, hopefully it can make usage more clear.



Comment at: clang/lib/AST/ExprConstant.cpp:8050
+  bool evaluate(const Expr *E) {
+Result.LExpr = E;
+return Visit(E);

aaron.ballman wrote:
> Should we be asserting that `Result.LExpr` is not already set?
`Result.LExpr` is updated while evaluator descend the evaluated tree, so it is 
normal to see it set. 



Comment at: clang/lib/AST/ExprConstant.cpp:8586
 
+  bool evaluate(const Expr *E) { return Visit(E); }
+

aaron.ballman wrote:
> Is there a reason we're not setting `Result.LExpr` here?
Actually This method was used in the initial implementation, now it can be 
removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103395

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


[PATCH] D111199: [Clang][LLVM][Attr] support btf_type_tag attribute

2021-11-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D99#3104804 , @yonghong-song 
wrote:

> @aaron.ballman I checked the source. Looks like we can easily get TypeLoc 
> from TypeSourceInfo, but not from TypeSourceInfo to TypeLoc. But We need 
> TypeLoc so we can get attr information and also traverse TypeLoc's.. We might 
> be able to pass TypeSourceInfo in a few functions e.g., createFieldType(), 
> but we still need to do TSI->getTypeLoc() and pass TypeLoc to other functions 
> like getOrCreateType(), createType() etc. So I am inclined to just use 
> TypeLoc.
>
> @dblaikie Based on the discussion so far, I suspect we might have to use 
> TypeLoc. Please let me know what you think.

That sounds reasonable to me, but one possibility would be to change 
`createType()` and `getOrCreateType()` to take a `TypeSourceInfo *` rather than 
a `QualType` (because you can go from the `TypeSourceInfo *` back to the 
`QualType` by calling `getType()` on it). However, that could also be a heavier 
lift due to the number of call sites.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99

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


[PATCH] D103395: PR45879: Keep evaluated expression in LValue object

2021-11-03 Thread Raul Tambre via Phabricator via cfe-commits
tambre added a comment.

In D103395#3105668 , @sepavloff wrote:

> Strange, I see that it cannot be compiled neither by gcc nor by clang: 
> https://godbolt.org/z/1dY9Gs6zM. Do I miss something?

Sorry, should've been more specific. Try in C++20 mode: 
https://godbolt.org/z/4v8b3nsET
I think the difference might be due to P1331R2 
, but I'm 
not sure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103395

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


[PATCH] D113096: [X86][MS-InlineAsm] Add constraint *m for memory access w/ global var

2021-11-03 Thread Kan Shengchen via Phabricator via cfe-commits
skan created this revision.
Herald added subscribers: pengfei, hiraditya.
skan requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Constraint `*m` should be used when the address of a variable is passed
as a value. And the constraint is missing for MS inline assembly when sth
is written to the address of the variable.

The missing would cause FE delete the definition of the static varible,
and then result in "undefined reference to xxx" issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113096

Files:
  clang/test/CodeGen/X86/ms_fmul.c
  clang/test/CodeGen/ms-inline-asm-static-variable.c
  clang/test/CodeGen/ms-inline-asm-variables.c
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
  llvm/test/CodeGen/X86/ms-inline-asm-array.ll

Index: llvm/test/CodeGen/X86/ms-inline-asm-array.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/ms-inline-asm-array.ll
@@ -0,0 +1,22 @@
+; RUN: llc < %s -mcpu=x86-64  | FileCheck %s
+
+@arr = internal global [10 x i32] zeroinitializer, align 16
+
+; CHECK: movl%edx, arr(,%rdx,4)
+define dso_local i32 @main() #0 {
+entry:
+  call void asm sideeffect inteldialect "mov dword ptr $0[rdx * $$4],edx", "=*m,~{dirflag},~{fpsr},~{flags}"([10 x i32]* @arr) #1, !srcloc !4
+  ret i32 0
+}
+
+attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+attributes #1 = { nounwind }
+
+!llvm.module.flags = !{!0, !1, !2}
+!llvm.ident = !{!3}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{i32 7, !"uwtable", i32 1}
+!2 = !{i32 7, !"frame-pointer", i32 2}
+!3 = !{!"clang"}
+!4 = !{i64 63}
Index: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
===
--- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1759,7 +1759,7 @@
   // registers in a mmory expression, and though unaccessible via rip/eip.
   if (IsGlobalLV && (BaseReg || IndexReg)) {
 Operands.push_back(
-X86Operand::CreateMem(getPointerWidth(), Disp, Start, End, Size));
+X86Operand::CreateMem(getPointerWidth(), Disp, Start, End, Size, Identifier, Decl));
 return false;
   }
   // Otherwise, we set the base register to a non-zero value
@@ -2551,6 +2551,8 @@
   StringRef ErrMsg;
   unsigned BaseReg = SM.getBaseReg();
   unsigned IndexReg = SM.getIndexReg();
+  if (IndexReg && BaseReg == X86::RIP)
+BaseReg = 0;
   unsigned Scale = SM.getScale();
   if (!PtrInOperand)
 Size = SM.getElementSize() << 3;
Index: clang/test/CodeGen/ms-inline-asm-variables.c
===
--- clang/test/CodeGen/ms-inline-asm-variables.c
+++ clang/test/CodeGen/ms-inline-asm-variables.c
@@ -3,19 +3,19 @@
 
 int gVar;
 void t1() {
-  // CHECK: add eax, dword ptr gVar[eax]
+  // CHECK: add eax, dword ptr ${{[0-9]}}[eax]
   __asm add eax, dword ptr gVar[eax]
-  // CHECK: add dword ptr gVar[eax], eax
+  // CHECK: add dword ptr ${{[0-9]}}[eax], eax
   __asm add dword ptr [eax+gVar], eax
-  // CHECK: add ebx, dword ptr gVar[ebx + $$270]
+  // CHECK: add ebx, dword ptr ${{[0-9]}}[ebx + $$270]
   __asm add ebx, dword ptr gVar[271 - 82 + 81 + ebx]
-  // CHECK: add dword ptr gVar[ebx + $$828], ebx
+  // CHECK: add dword ptr ${{[0-9]}}[ebx + $$828], ebx
   __asm add dword ptr [ebx + gVar + 828], ebx
-  // CHECK: add ecx, dword ptr gVar[ecx + ecx * $$4 + $$4590]
+  // CHECK: add ecx, dword ptr ${{[0-9]}}[ecx + ecx * $$4 + $$4590]
   __asm add ecx, dword ptr gVar[4590 + ecx + ecx*4]
-  // CHECK: add dword ptr gVar[ecx + ecx * $$8 + $$73], ecx
+  // CHECK: add dword ptr ${{[0-9]}}[ecx + ecx * $$8 + $$73], ecx
   __asm add dword ptr [gVar + ecx + 45 + 23 - 53 + 60 - 2 + ecx*8], ecx
-  // CHECK: add gVar[ecx + ebx + $$7], eax
+  // CHECK: add ${{[0-9]}}[ecx + ebx + $$7], eax
   __asm add 1 + 1 + 2 + 3[gVar + ecx + ebx], eax
 }
 
@@ -32,4 +32,3 @@
   // CHECK: mov ${{[0-9]}}[ebx + $$47], eax
   __asm mov 5 + 8 + 13 + 21[lVar + ebx], eax
 }
-
Index: clang/test/CodeGen/ms-inline-asm-static-variable.c
===
--- /dev/null
+++ clang/test/CodeGen/ms-inline-asm-static-variable.c
@@ -0,0 +1,10 @@
+// REQUIRES: x86-registered-target
+// Check the constraint "*m" of operand arr and the definition of arr is not removed by FE
+// RUN: %clang_cc1 %s -fasm-blocks -triple i386-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+static int arr[10];
+void t1() {
+  // CHECK: @arr = internal global [10 x i32]
+  // CHECK: call void asm sideeffect inteldialect "mov dword ptr $0[edx * $$4],edx", "=*m,{{.*}}([10 x i32]* @arr)
+  __asm mov  dword ptr arr[edx*4],edx
+}
Index: clang/test/CodeGen/X86/ms_

[PATCH] D113096: [X86][MS-InlineAsm] Add constraint *m for memory access w/ global var

2021-11-03 Thread Kan Shengchen via Phabricator via cfe-commits
skan updated this revision to Diff 384401.
skan added a comment.

clang-format the diff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113096

Files:
  clang/test/CodeGen/X86/ms_fmul.c
  clang/test/CodeGen/ms-inline-asm-static-variable.c
  clang/test/CodeGen/ms-inline-asm-variables.c
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
  llvm/test/CodeGen/X86/ms-inline-asm-array.ll

Index: llvm/test/CodeGen/X86/ms-inline-asm-array.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/ms-inline-asm-array.ll
@@ -0,0 +1,22 @@
+; RUN: llc < %s -mcpu=x86-64  | FileCheck %s
+
+@arr = internal global [10 x i32] zeroinitializer, align 16
+
+; CHECK: movl%edx, arr(,%rdx,4)
+define dso_local i32 @main() #0 {
+entry:
+  call void asm sideeffect inteldialect "mov dword ptr $0[rdx * $$4],edx", "=*m,~{dirflag},~{fpsr},~{flags}"([10 x i32]* @arr) #1, !srcloc !4
+  ret i32 0
+}
+
+attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+attributes #1 = { nounwind }
+
+!llvm.module.flags = !{!0, !1, !2}
+!llvm.ident = !{!3}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{i32 7, !"uwtable", i32 1}
+!2 = !{i32 7, !"frame-pointer", i32 2}
+!3 = !{!"clang"}
+!4 = !{i64 63}
Index: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
===
--- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1758,8 +1758,8 @@
   // It is widely common for MS InlineAsm to use a global variable and one/two
   // registers in a mmory expression, and though unaccessible via rip/eip.
   if (IsGlobalLV && (BaseReg || IndexReg)) {
-Operands.push_back(
-X86Operand::CreateMem(getPointerWidth(), Disp, Start, End, Size));
+Operands.push_back(X86Operand::CreateMem(getPointerWidth(), Disp, Start,
+ End, Size, Identifier, Decl));
 return false;
   }
   // Otherwise, we set the base register to a non-zero value
@@ -2551,6 +2551,8 @@
   StringRef ErrMsg;
   unsigned BaseReg = SM.getBaseReg();
   unsigned IndexReg = SM.getIndexReg();
+  if (IndexReg && BaseReg == X86::RIP)
+BaseReg = 0;
   unsigned Scale = SM.getScale();
   if (!PtrInOperand)
 Size = SM.getElementSize() << 3;
Index: clang/test/CodeGen/ms-inline-asm-variables.c
===
--- clang/test/CodeGen/ms-inline-asm-variables.c
+++ clang/test/CodeGen/ms-inline-asm-variables.c
@@ -3,19 +3,19 @@
 
 int gVar;
 void t1() {
-  // CHECK: add eax, dword ptr gVar[eax]
+  // CHECK: add eax, dword ptr ${{[0-9]}}[eax]
   __asm add eax, dword ptr gVar[eax]
-  // CHECK: add dword ptr gVar[eax], eax
+  // CHECK: add dword ptr ${{[0-9]}}[eax], eax
   __asm add dword ptr [eax+gVar], eax
-  // CHECK: add ebx, dword ptr gVar[ebx + $$270]
+  // CHECK: add ebx, dword ptr ${{[0-9]}}[ebx + $$270]
   __asm add ebx, dword ptr gVar[271 - 82 + 81 + ebx]
-  // CHECK: add dword ptr gVar[ebx + $$828], ebx
+  // CHECK: add dword ptr ${{[0-9]}}[ebx + $$828], ebx
   __asm add dword ptr [ebx + gVar + 828], ebx
-  // CHECK: add ecx, dword ptr gVar[ecx + ecx * $$4 + $$4590]
+  // CHECK: add ecx, dword ptr ${{[0-9]}}[ecx + ecx * $$4 + $$4590]
   __asm add ecx, dword ptr gVar[4590 + ecx + ecx*4]
-  // CHECK: add dword ptr gVar[ecx + ecx * $$8 + $$73], ecx
+  // CHECK: add dword ptr ${{[0-9]}}[ecx + ecx * $$8 + $$73], ecx
   __asm add dword ptr [gVar + ecx + 45 + 23 - 53 + 60 - 2 + ecx*8], ecx
-  // CHECK: add gVar[ecx + ebx + $$7], eax
+  // CHECK: add ${{[0-9]}}[ecx + ebx + $$7], eax
   __asm add 1 + 1 + 2 + 3[gVar + ecx + ebx], eax
 }
 
@@ -32,4 +32,3 @@
   // CHECK: mov ${{[0-9]}}[ebx + $$47], eax
   __asm mov 5 + 8 + 13 + 21[lVar + ebx], eax
 }
-
Index: clang/test/CodeGen/ms-inline-asm-static-variable.c
===
--- /dev/null
+++ clang/test/CodeGen/ms-inline-asm-static-variable.c
@@ -0,0 +1,10 @@
+// REQUIRES: x86-registered-target
+// Check the constraint "*m" of operand arr and the definition of arr is not removed by FE
+// RUN: %clang_cc1 %s -fasm-blocks -triple i386-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+static int arr[10];
+void t1() {
+  // CHECK: @arr = internal global [10 x i32]
+  // CHECK: call void asm sideeffect inteldialect "mov dword ptr $0[edx * $$4],edx", "=*m,{{.*}}([10 x i32]* @arr)
+  __asm mov  dword ptr arr[edx*4],edx
+}
Index: clang/test/CodeGen/X86/ms_fmul.c
===
--- clang/test/CodeGen/X86/ms_fmul.c
+++ clang/test/CodeGen/X86/ms_fmul.c
@@ -18,4 +18,4 @@
 }}
 
 // CHECK-LABEL: foo
-// CHECK: call void asm sideef

[clang] 1427742 - [Sema][NFC] Improve test coverage for builtin operators.

2021-11-03 Thread Clement Courbet via cfe-commits

Author: Clement Courbet
Date: 2021-11-03T13:32:48+01:00
New Revision: 1427742750ed1fcd2ead639c4ec5178fc34c9257

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

LOG: [Sema][NFC] Improve test coverage for builtin operators.

In preparation for D112453.

Added: 
clang/test/CXX/over/over.built/p10.cpp
clang/test/CXX/over/over.built/p11.cpp
clang/test/CXX/over/over.built/p24.cpp
clang/test/CXX/over/over.built/p4.cpp
clang/test/CXX/over/over.built/p5.cpp
clang/test/CXX/over/over.built/p6.cpp
clang/test/CXX/over/over.built/p7-ast.cpp
clang/test/CXX/over/over.built/p7.cpp
clang/test/CXX/over/over.built/p8.cpp
clang/test/CXX/over/over.built/p9.cpp

Modified: 


Removed: 




diff  --git a/clang/test/CXX/over/over.built/p10.cpp 
b/clang/test/CXX/over/over.built/p10.cpp
new file mode 100644
index 0..678056da58205
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p10.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-tautological-compare
+
+struct A{};
+
+template 
+void f(int i, float f, bool b, char c, int* pi, A* pa, T* pt) {
+  (void)+i;
+  (void)-i;
+  (void)+f;
+  (void)-f;
+  (void)+b;
+  (void)-b;
+  (void)+c;
+  (void)-c;
+
+  (void)-pi; // expected-error {{invalid argument type}}
+  (void)-pa; // expected-error {{invalid argument type}}
+  (void)-pt; // FIXME: we should be able to give an error here.
+}
+

diff  --git a/clang/test/CXX/over/over.built/p11.cpp 
b/clang/test/CXX/over/over.built/p11.cpp
new file mode 100644
index 0..7ebf16b95439f
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p11.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-tautological-compare
+
+template 
+void f(int i, float f, bool b, char c, int* pi, T* pt) {
+  (void)~i;
+  (void)~f; // expected-error {{invalid argument type}}
+  (void)~b;
+  (void)~c;
+  (void)~pi; // expected-error {{invalid argument type}}
+  (void)~pt; // FIXME: we should be able to give an error here.
+}
+

diff  --git a/clang/test/CXX/over/over.built/p24.cpp 
b/clang/test/CXX/over/over.built/p24.cpp
new file mode 100644
index 0..3c48dcd9aa673
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p24.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-tautological-compare
+
+template 
+void f(int i, float f, bool b, char c, int* pi, T* pt) {
+  (void)!i;
+  (void)!f;
+  (void)!b;
+  (void)!c;
+  (void)!pi;
+  (void)!pt;
+}
+// expected-no-diagnostics

diff  --git a/clang/test/CXX/over/over.built/p4.cpp 
b/clang/test/CXX/over/over.built/p4.cpp
new file mode 100644
index 0..d7cd99c68d6a2
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p4.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s -Wno-tautological-compare
+
+void f(int i, bool b) {
+  (void)++i;
+  (void)i++;
+
+  (void)++b; // expected-error {{ISO C++17 does not allow incrementing 
expression of type bool}}
+  (void)b++; // expected-error {{ISO C++17 does not allow incrementing 
expression of type bool}}
+}
+

diff  --git a/clang/test/CXX/over/over.built/p5.cpp 
b/clang/test/CXX/over/over.built/p5.cpp
new file mode 100644
index 0..4ba32564e9ad8
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p5.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-tautological-compare
+
+void f(int i, bool b) {
+  (void)--i;
+  (void)i--;
+
+  (void)--b; // expected-error {{cannot decrement expression of type bool}}
+  (void)b--; // expected-error {{cannot decrement expression of type bool}}
+}
+

diff  --git a/clang/test/CXX/over/over.built/p6.cpp 
b/clang/test/CXX/over/over.built/p6.cpp
new file mode 100644
index 0..ca81c9aecce86
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p6.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-tautological-compare
+
+struct A{};
+
+template 
+void f(int* pi, A* pa, T* pt) {
+  (void)++pi;
+  (void)pi++;
+  (void)--pi;
+  (void)pi--;
+
+  (void)++pa;
+  (void)pa++;
+  (void)--pa;
+  (void)pa--;
+
+  (void)++pt;
+  (void)pt++;
+  (void)--pt;
+  (void)pt--;
+}
+// expected-no-diagnostics
+

diff  --git a/clang/test/CXX/over/over.built/p7-ast.cpp 
b/clang/test/CXX/over/over.built/p7-ast.cpp
new file mode 100644
index 0..9f501a496fea8
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p7-ast.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++17 -ast-dump %s -ast-dump-filter Test | FileCheck %s
+
+struct A{};
+
+template 
+auto Test(T* pt) {
+  // CHECK: UnaryOperator {{.*}} '' prefix '*'
+  // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
+  return *pt;
+}
+
+

diff  --git a/clang/test/CXX/over/over.built/p7.cpp 
b/clang/test/CXX/over/over.built/p7.cpp
new file mode 100644
index 0..348c4cdf37830
--- /dev/n

[PATCH] D112996: [CodeCompletion] Generally consider header files without extension

2021-11-03 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler updated this revision to Diff 384407.
ckandeler added a comment.

Limited the matching to Qt headers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112996

Files:
  clang/lib/Sema/SemaCodeComplete.cpp


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -9615,6 +9615,7 @@
   }
 }
 
+const StringRef &Dirname = llvm::sys::path::filename(Dir);
 std::error_code EC;
 unsigned Count = 0;
 for (auto It = FS.dir_begin(Dir, EC);
@@ -9648,7 +9649,9 @@
   if (!(Filename.endswith_insensitive(".h") ||
 Filename.endswith_insensitive(".hh") ||
 Filename.endswith_insensitive(".hpp") ||
-Filename.endswith_insensitive(".inc")))
+Filename.endswith_insensitive(".inc") ||
+Dirname == "Headers" ||
+Dirname.startswith("Qt") || Dirname == "ActiveQt"))
 break;
 }
 AddCompletion(Filename, /*IsDirectory=*/false);


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -9615,6 +9615,7 @@
   }
 }
 
+const StringRef &Dirname = llvm::sys::path::filename(Dir);
 std::error_code EC;
 unsigned Count = 0;
 for (auto It = FS.dir_begin(Dir, EC);
@@ -9648,7 +9649,9 @@
   if (!(Filename.endswith_insensitive(".h") ||
 Filename.endswith_insensitive(".hh") ||
 Filename.endswith_insensitive(".hpp") ||
-Filename.endswith_insensitive(".inc")))
+Filename.endswith_insensitive(".inc") ||
+Dirname == "Headers" ||
+Dirname.startswith("Qt") || Dirname == "ActiveQt"))
 break;
 }
 AddCompletion(Filename, /*IsDirectory=*/false);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112996: [CodeCompletion] Generally consider header files without extension

2021-11-03 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

>> For framework builds, the directory would be "Headers", which also seems 
>> safe.
>
> I agree extensionless headers in frameworks seem fine to show.
> We already know which includepath entries are frameworks, so we can just use 
> that info directly (see line 9674)

These aren't technically framework includes, as in order to make prefix-less 
headers work, the include path has to point directly into the Headers directory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112996

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


[PATCH] D112903: [C++20] [Module] Fix front end crashes when trying to export a type out of a module

2021-11-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:7784-7785
   "because namespace %1 does not enclose namespace %2">;
+def err_invalid_declarator_in_export : Error<"cannot export %0 here "
+  "because it had be declared in %1.">;
 def err_invalid_declarator_global_scope : Error<

aaron.ballman wrote:
> I think this diagnostic text is more clear based on the standards text you 
> cited. This would also come with a note diagnostic to point to the previous 
> declaration.
Given that this is not intended for p6 specifically, I think my suggestion is 
incorrect. But I am also not certain your diagnostic is either, but it's really 
hard to tell given where our current support is for modules. All of the other 
compilers suggest that an unqualified id is expected to be found, and I tend to 
agree -- there's no declaration there *to* export, just the type specifier for 
a declaration. This makes me think the issue is elsewhere and perhaps we 
shouldn't even be getting into `diagnoseQualifiedDeclaration()`.



Comment at: clang/lib/Sema/SemaDecl.cpp:5748-5750
+else if (isa(Cur))
+  Diag(Loc, diag::err_invalid_declarator_in_export)
+  << Name << cast(DC) << SS.getRange();

ChuanqiXu wrote:
> aaron.ballman wrote:
> > I don't believe this is sufficient to cover [module.interface]p6. I tried 
> > out the example from the paragraph in the standard and we still silently 
> > accept it.
> Yes, this patch is not intended to cover [module.interface]p6. The intention 
> is to fix the crash since I feel it would take a longer time to support 
> [module.interface]p6. And crash is not good any way. I plan to support 
> [module.interface]p6 in successive patches. Do you happy with this?
> BTW, I have a plan to support clang's c++20 module to a workable state. And I 
> am working on the reachable definition in 
> https://eel.is/c++draft/module.reach#3 and  
> https://eel.is/c++draft/module.global.frag#3.
Thank you for the clarification! Fixing the crash is definitely a step in the 
right direction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112903

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


[PATCH] D112349: [Verifier] Add verification logic for GlobalIFuncs

2021-11-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.



In D112349#3104479 , @ibookstein 
wrote:

> Hmm. When I try to compile an object file where the resolver is a 
> declaration, both clang-13, clang-14, and gcc-9.3 complain that the ifunc 
> must point to a defined function:
>
>   void *foo_resolver();
>   void foo(void) __attribute__((ifunc("foo_resolver")));
>
> clang (13 and 14) complain:
>
>   obj.c:2:31: error: ifunc must point to a defined function
>   void foo(void) __attribute__((ifunc("foo_resolver")));
> ^
>   1 error generated.
>
> gcc 9.3.0 complains:
>
>   obj.c:3:6: error: ‘foo’ aliased to undefined symbol ‘foo_resolver’
>   3 | void foo(void) __attribute__((ifunc("foo_resolver")));
> |  ^~~
>
> I realize that the fact that frontends reject this doesn't necessarily mean 
> that the IR they would have hypothetically produced is invalid, I'm just 
> wondering about the semantics.
> Drawing some parallels to GlobalAliases, you'll see that they also check that 
> the aliasee is a definition rather than a declaration 
> (`Verifier::visitAliaseeSubExpr`), which was the reason I added the same 
> check to `Verifier::visitGlobalIFunc`.

My understanding is the frontend's semantic rules are/were different from the 
IR rules, which is why we implemented it that way.

> Should an object file be produced with an UND ifunc symbol in that case? 
> Wouldn't it be more correct to emit a plain old function declaration? (see 
> `llvm/test/Linker/ifunc.ll` for behavior of linking an ifunc on top of a 
> function declaration, should work correctly).

I'm not sure what you mean here?  Are you suggesting that an undefined resolver 
should instead just implement an undefined 'function' for the .ifunc?  This 
doesn't seem right?  Wouldn't that cause ODR issues?

> At the very least to alleviate the breakage I think we can just rip out the 
> `Assert(!Resolver->isDeclarationForLinker(), "...")` from the Verifier, but I 
> have a feeling that this is not the right long-term solution.

I guess I still don't understand what the practical limitation that requires 
ifuncs to have a defined resolver?  The resolver is just a normal function, so 
it seems to me that allowing them to have normal linking rules makes sense?  I 
personally think this is the least obtrusive change; this patch is adding a 
limitation that didn't exist previously unnecessarily.

> The cpu_specific/cpu_dispatch attributes are completely new to me, so bear 
> with me if I'm misunderstanding; wouldn't the following implementation both 
> provide the correct semantics and avoid an ifunc-with-an-undefined-resolver 
> situation?
>
> - The cpu_specific attribute emits
>   1. A Function Declaration with a computed name "x.ifunc"

It just seems odd I guess to name a function .ifunc, and not have it be an 
ifunc?  What does our linker think about that?

>   1. A single Function with the cpu-specific body
>   2. Multiple GlobalAliases with computed names whose aliasee is the function 
> from 2)
> - The cpu_dispatch attribute emits a strongly-defined non-interposable ifunc 
> with the same computed name "x.ifunc", and a hidden defined resolver. Both IR 
> linking and regular linking should resolve the plain 
> function-delcaration-references to the ifunc properly.

I'm not sure what you mean by 'non-interposable'?  We are intentionally forming 
the .ifunc to have the same linkage as the original function, so anything we do 
that would break that is not acceptable.  Additionally, I'd hope that this 
wouldn't be an ABI break?  Additionally, the way the CFE generates these calls 
would require a pretty massive overhaul, since we'd have to "know" when to 
replace those in cases where the cpu-specific and cpu-dispatch are in the same 
TU.  Previously we did something similar for attribute-target multiversioning, 
but the idea of doing a replace-all-uses was considered unacceptable by the CFE 
code owners.

In D112349#3105292 , @ibookstein 
wrote:

> Note that (as the examples demonstrate) clang self-verifies and checks among 
> other things that ifuncs that it emits point to definitions; this happens in 
> `CodeGenModule::checkAliases()`.
> I haven't read the cpu_specific/cpu_dispatch-related code in CodeGenModule 
> yet, but I'm guessing that it doesn't register the generated aliases/ifuncs 
> into the `CodeGenModule::Aliases` vector for deferred verification, which is 
> why this didn't trigger the same error that my ifunc example did so far.

Thats correct, these aren't 'aliases' or 'ifuncs' as far as the CFE is 
concerned; they are multiversioned functions.  That 'Aliases' and 'ifunc' list 
in the CFE are the AST-constructs of those, not the IR constructs, so there is 
no reason to put the multiversioned thinks in that list, since they are 
implementation details.  Emitting an error "invalid alias!"/etc for


Repository:
  rG LLVM Github Monorepo

CHAN

[PATCH] D108832: [Builtins] Support ext_vector_type args for __builtin_fminf.

2021-11-03 Thread Florian Hahn via Phabricator via cfe-commits
fhahn abandoned this revision.
fhahn added a comment.

The vector builtin support took a different direction, see  D111529 
 and following


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108832

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


[PATCH] D108482: [Clang] Fix instantiation of OpaqueValueExprs (Bug #45964)

2021-11-03 Thread Raul Tambre via Phabricator via cfe-commits
tambre added a comment.

I presume you lack the permissions to push this to the main repo yourself. 
Would you like me to do that for you?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108482

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


[PATCH] D113049: [AIX] Disable tests that fail because of no 64-bit XCOFF object file support

2021-11-03 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

This seems not right. Now we disable too many debug cases for object mode even 
for 32bit target. Maybe we should test clang (built with 
`--default-target-triple=powerpc64-ibm-aix`)  after our backend support 64-bit 
object mode(`-filetype=obj`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113049

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


[PATCH] D112349: [Verifier] Add verification logic for GlobalIFuncs

2021-11-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

To 'unbreak' us for now, I've committed the suggested change to remove the 
definition check here: 09233412edae388a7bfa349cf792dba5aced057f 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112349

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


[PATCH] D112996: [CodeCompletion] Generally consider header files without extension

2021-11-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D112996#3105783 , @ckandeler wrote:

>>> For framework builds, the directory would be "Headers", which also seems 
>>> safe.
>>
>> I agree extensionless headers in frameworks seem fine to show.
>> We already know which includepath entries are frameworks, so we can just use 
>> that info directly (see line 9674)
>
> These aren't technically framework includes, as in order to make prefix-less 
> headers work, the include path has to point directly into the Headers 
> directory.

I see. In that case we can detect this pattern in any framework by checking 
whether the directory contains ".framework/Headers", right? Headers itself 
doesn't seem specific enough.




Comment at: clang/lib/Sema/SemaCodeComplete.cpp:9654
+Dirname == "Headers" ||
+Dirname.startswith("Qt") || Dirname == "ActiveQt"))
 break;

can you extract this up near dirname, and give a name that explains the idea 
(e.g. `ExtensionlessHeaders`)



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:9654
+Dirname == "Headers" ||
+Dirname.startswith("Qt") || Dirname == "ActiveQt"))
 break;

sammccall wrote:
> can you extract this up near dirname, and give a name that explains the idea 
> (e.g. `ExtensionlessHeaders`)
we've lost the condition that there's no extension, and now accept *any* 
extension (e.g. `.DS_Store`!)
Unless this is important I think we should keep that check.

And to keep the number of cases/paths low, I think it's fine to bundle system 
headers into the same bucket - really this is just for the C++ standard 
library, which does not have extensions.

So some logic like:

```
bool ExtensionlessHeaders = IsSystem || Dir.endswith(".framework/Headers") || 
Dirname.startswith("Qt");
...
case regular_file:
  bool IsHeader = Filename.endswith(...) || Filename.endswith(...) || 
(ExtensionlessHeaders && !Filename.contains('.'));
  if (!IsHeader) break;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112996

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


[PATCH] D112868: [Sema] Diagnose and reject non-function ifunc resolvers

2021-11-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

One thing that surprises me is that the test changes are in Sema but the code 
changes are in CodeGen. I see that this test actually emits LLVM IR. Should it 
be moved (as an NFC change)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112868

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


[PATCH] D112868: [Sema] Diagnose and reject non-function ifunc resolvers

2021-11-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:320
 // linear structure.
 static const llvm::GlobalValue *getAliasedGlobal(const llvm::GlobalValue *GV) {
+  const llvm::Constant *C;

Can you explain a bit better how this change here works?  The previous version 
appears to have done quite a bit of work in the loop to look through 
aliases/ifuncs, and it seems we don't do that anymore?  



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:397
 
+bool IsIFunc = isa(Alias);
 llvm::Constant *Aliasee =

What is the purpose of changing this from checking the declaration to the IR?  
It seems that this is something we should be able to catch at the AST level and 
not have to revert to IR checks like this.



Comment at: clang/test/Sema/attr-ifunc.c:16
 
-void* f2_a() __attribute__((ifunc("f2_b")));
-//expected-error@-1 {{ifunc definition is part of a cycle}}
+void *f2_a() __attribute__((alias("f2_b")));
 void* f2_b() __attribute__((ifunc("f2_a")));

Did we lose this previous error?  We still want that to happen, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112868

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


[PATCH] D112041: [InferAddressSpaces] Support assumed addrspaces from addrspace predicates.

2021-11-03 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.
Herald added a subscriber: asavonic.

Sorry for the late reply.




Comment at: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:903-905
 Optional InferAddressSpacesImpl::updateAddressSpace(
-const Value &V, const ValueToAddrSpaceMapTy &InferredAddrSpace) const {
+const Value &V, const ValueToAddrSpaceMapTy &InferredAddrSpace,
+PredicatedAddrSpaceMapTy &PredicatedAS) const {

tra wrote:
> hliao wrote:
> > tra wrote:
> > > I can't say I'm happy about the way updateAddressSpace updates 
> > > PredicateAS here, but delegates updates to InferredAddrSpace to the 
> > > caller. I think both should be updated in one place -- either here, or in 
> > > the callee.
> > the difference is that, here, we assume a use of pointer could be inferred 
> > with a new addrspace. The original is on a def of value.
> I'm not sure how it explains why the function returns values to update 
> InferredAddrSpace outside of it, but updates PredicatedAS inside.
> 
> For consistency sake, I'd update InferredAddrSpace here as well and, 
> possibly, combine both maps into a single structure as I've suggested above.
PredicatedAS holds only the deduced operand AS based on the assumption or other 
conditions. It may or may not help to infer its user's final AS. In case the 
user still cannot be inferred, PredicatedAS won't be used to change the final 
IR anyway. It's only an intermediate state during the inferring. However, I 
think it's a good idea to put relevant updates into `updateAddressSpace`. That 
seems a little bit cleaner.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112041

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


[PATCH] D111833: [clang] Fortify warning for scanf calls with field width too big.

2021-11-03 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield updated this revision to Diff 384431.
mbenfield added a comment.

Ignore specifiers with *.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111833

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/warn-fortify-scanf.c

Index: clang/test/Sema/warn-fortify-scanf.c
===
--- /dev/null
+++ clang/test/Sema/warn-fortify-scanf.c
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 %s -verify
+
+typedef struct _FILE FILE;
+extern int scanf(const char *format, ...);
+extern int fscanf(FILE *f, const char *format, ...);
+extern int sscanf(const char *input, const char *format, ...);
+
+void call_scanf() {
+  char buf10[10];
+  char buf20[20];
+  char buf30[30];
+  scanf("%4s %5s %10s", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 4 has size 10, but the corresponding specifier may require size 11}}
+  scanf("%4s %5s %11s", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 4 has size 10, but the corresponding specifier may require size 12}}
+  scanf("%4s %5s %9s", buf20, buf30, buf10);
+  scanf("%20s %5s %9s", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 2 has size 20, but the corresponding specifier may require size 21}}
+  scanf("%21s %5s %9s", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 2 has size 20, but the corresponding specifier may require size 22}}
+  scanf("%19s %5s %9s", buf20, buf30, buf10);
+  scanf("%19s %29s %9s", buf20, buf30, buf10);
+
+  scanf("%*21s %*30s %10s", buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 2 has size 10, but the corresponding specifier may require size 11}}
+  scanf("%*21s %5s", buf10);
+  scanf("%10s %*30s", buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 2 has size 10, but the corresponding specifier may require size 11}}
+  scanf("%9s %*30s", buf10);
+
+  scanf("%4[a] %5[a] %10[a]", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 4 has size 10, but the corresponding specifier may require size 11}}
+  scanf("%4[a] %5[a] %11[a]", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 4 has size 10, but the corresponding specifier may require size 12}}
+  scanf("%4[a] %5[a] %9[a]", buf20, buf30, buf10);
+  scanf("%20[a] %5[a] %9[a]", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 2 has size 20, but the corresponding specifier may require size 21}}
+  scanf("%21[a] %5[a] %9[a]", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 2 has size 20, but the corresponding specifier may require size 22}}
+  scanf("%19[a] %5[a] %9[a]", buf20, buf30, buf10);
+  scanf("%19[a] %29[a] %9[a]", buf20, buf30, buf10);
+
+  scanf("%4c %5c %10c", buf20, buf30, buf10);
+  scanf("%4c %5c %11c", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 4 has size 10, but the corresponding specifier may require size 11}}
+  scanf("%4c %5c %9c", buf20, buf30, buf10);
+  scanf("%20c %5c %9c", buf20, buf30, buf10);
+  scanf("%21c %5c %9c", buf20, buf30, buf10); // expected-warning {{'scanf' may overflow; destination buffer in argument 2 has size 20, but the corresponding specifier may require size 21}}
+
+  // Don't warn for other specifiers.
+  int x;
+  scanf("%12d", &x);
+}
+
+void call_sscanf() {
+  char buf10[10];
+  char buf20[20];
+  char buf30[30];
+  sscanf("a b c", "%4s %5s %10s", buf20, buf30, buf10); // expected-warning {{'sscanf' may overflow; destination buffer in argument 5 has size 10, but the corresponding specifier may require size 11}}
+  sscanf("a b c", "%4s %5s %11s", buf20, buf30, buf10); // expected-warning {{'sscanf' may overflow; destination buffer in argument 5 has size 10, but the corresponding specifier may require size 12}}
+  sscanf("a b c", "%4s %5s %9s", buf20, buf30, buf10);
+  sscanf("a b c", "%20s %5s %9s", buf20, buf30, buf10); // expected-warning {{'sscanf' may overflow; destination buffer in argument 3 has size 20, but the corresponding specifier may require size 21}}
+  sscanf("a b c", "%21s %5s %9s", buf20, buf30, buf10); // expected-warning {{'sscanf' may overflow; destination buffer in argument 3 has size 20, but the corresponding specifier may require size 22}}
+  sscanf("a b c", "%19s %5s %9s", buf20, buf30, buf10);
+  sscanf("a b c", "%19s %29s %9s", buf20, buf30, buf10);
+}
+
+void call_fscanf() {
+  char buf10[10];
+  char buf20[20];
+  char buf30[30];
+  fscanf(0, "%4s %5s %10s", buf20, buf30, buf10); // expected-warning {{'fscanf' may

[clang] b2cbdf6 - Update ast-dump-decl.mm test to work on 32 bit windows

2021-11-03 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2021-11-03T07:42:06-07:00
New Revision: b2cbdf6c134a0aaa30f877b1e6fe42b9e16391e7

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

LOG: Update ast-dump-decl.mm test to work on 32 bit windows

Windows member functions have __attribute__((thiscall)) on their type,
so any machine running this that is 32 bit windows fails this test, add
a wildcard, plus an additional run line to explain why.

Added: 


Modified: 
clang/test/AST/ast-dump-decl.mm

Removed: 




diff  --git a/clang/test/AST/ast-dump-decl.mm b/clang/test/AST/ast-dump-decl.mm
index 16ca27e3b139c..69ff46101da1e 100644
--- a/clang/test/AST/ast-dump-decl.mm
+++ b/clang/test/AST/ast-dump-decl.mm
@@ -1,6 +1,8 @@
 // Test without serialization:
 // RUN: %clang_cc1 -Wno-unused -fblocks -ast-dump -ast-dump-filter Test %s \
 // RUN: | FileCheck --strict-whitespace %s
+// RUN: %clang_cc1 -Wno-unused -fblocks -ast-dump -triple i386-windows-pc 
-ast-dump-filter Test %s \
+// RUN: | FileCheck --strict-whitespace %s
 //
 // Test with serialization:
 // RUN: %clang_cc1 -Wno-unused -fblocks -emit-pch -o %t %s
@@ -55,7 +57,7 @@ void f() {
 // CHECK-NEXT:   CXXThisExpr {{.*}}  'Test *' this
   }
   void yada();
-  // CHECK:  CXXMethodDecl {{.*}}  col:8 used 
yada 'void ()'
+  // CHECK:  CXXMethodDecl {{.*}}  col:8 used 
yada 'void (){{.*}}'
 };
 
 @protocol P



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


[PATCH] D112916: Confusable identifiers detection

2021-11-03 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

In D112916#3102767 , 
@serge-sans-paille wrote:

> @tonic / @tstellar as members of the LLVM fundation board, can you tell us if 
> it's okay to ship the `confusables.txt` file from 
> https://www.unicode.org/Public/security/latest/confusables.txt and what are 
> the steps to do so? Alternatively, I can ship the derived header and provide 
> an optional rule that fetches `confisables.txt` from its latest version and 
> updates the header file.

Side note: `llvm/include/llvm/Support/ConvertUTF.h` and 
`llvm/lib/Support/ConvertUTF.cpp` are already licensed under `Copyright 
2001-2004 Unicode, Inc.`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112916

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


[PATCH] D112041: [InferAddressSpaces] Support assumed addrspaces from addrspace predicates.

2021-11-03 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 384433.
hliao added a comment.

Move the updating action into `updateAddrSpace` and return a boolean true if 
it's really updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112041

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/AssumptionCache.h
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/lib/Analysis/AssumptionCache.cpp
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
  llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Transforms/InferAddressSpaces/AMDGPU/builtin-assumed-addrspace.ll
  llvm/test/Transforms/InferAddressSpaces/NVPTX/builtin-assumed-addrspace.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp

Index: llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
===
--- llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
+++ llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
@@ -518,8 +518,7 @@
   BasicBlock::iterator First = F->begin()->begin();
   BasicBlock::iterator Second = F->begin()->begin();
   Second++;
-  AssumptionCacheTracker ACT;
-  AssumptionCache &AC = ACT.getAssumptionCache(*F);
+  AssumptionCache AC(*F);
   auto AR = AC.assumptionsFor(F->getArg(3));
   ASSERT_EQ(AR.size(), 0u);
   AR = AC.assumptionsFor(F->getArg(1));
Index: llvm/test/Transforms/LoopRotate/pr35210.ll
===
--- llvm/test/Transforms/LoopRotate/pr35210.ll
+++ llvm/test/Transforms/LoopRotate/pr35210.ll
@@ -11,11 +11,11 @@
 ; CHECK-NEXT: Running analysis: LoopAnalysis on f
 ; CHECK-NEXT: Running analysis: DominatorTreeAnalysis on f
 ; CHECK-NEXT: Running analysis: AssumptionAnalysis on f
+; CHECK-NEXT: Running analysis: TargetIRAnalysis on f
 ; CHECK-NEXT: Running pass: LCSSAPass on f
 ; CHECK-NEXT: Running analysis: AAManager on f
 ; CHECK-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; CHECK-NEXT: Running analysis: ScalarEvolutionAnalysis on f
-; CHECK-NEXT: Running analysis: TargetIRAnalysis on f
 ; CHECK-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f
 ; CHECK-NEXT: Running pass: LoopRotatePass on Loop at depth 1 containing: %bb,%bb4
 ; CHECK-NEXT: Folding loop latch bb4 into bb
@@ -29,12 +29,12 @@
 ; MSSA-NEXT: Running analysis: LoopAnalysis on f
 ; MSSA-NEXT: Running analysis: DominatorTreeAnalysis on f
 ; MSSA-NEXT: Running analysis: AssumptionAnalysis on f
+; MSSA-NEXT: Running analysis: TargetIRAnalysis on f
 ; MSSA-NEXT: Running pass: LCSSAPass on f
 ; MSSA-NEXT: Running analysis: MemorySSAAnalysis on f
 ; MSSA-NEXT: Running analysis: AAManager on f
 ; MSSA-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; MSSA-NEXT: Running analysis: ScalarEvolutionAnalysis on f
-; MSSA-NEXT: Running analysis: TargetIRAnalysis on f
 ; MSSA-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f
 ; MSSA-NEXT: Running pass: LoopRotatePass on Loop at depth 1 containing: %bb,%bb4
 ; MSSA-NEXT: Folding loop latch bb4 into bb
Index: llvm/test/Transforms/InferAddressSpaces/NVPTX/builtin-assumed-addrspace.ll
===
--- /dev/null
+++ llvm/test/Transforms/InferAddressSpaces/NVPTX/builtin-assumed-addrspace.ll
@@ -0,0 +1,107 @@
+; RUN: opt -S -mtriple=nvptx64-nvidia-cuda -infer-address-spaces -o - %s | FileCheck %s
+
+; CHECK-LABEL: @f0
+; CHECK: addrspacecast float* {{%.*}} to float addrspace(4)*
+; CHECK: getelementptr inbounds float, float addrspace(4)*
+; CHECK: load float, float addrspace(4)*
+define float @f0(float* %p) {
+entry:
+  %0 = bitcast float* %p to i8*
+  %1 = call i1 @llvm.nvvm.isspacep.const(i8* %0)
+  tail call void @llvm.assume(i1 %1)
+  %2 = tail call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  %idxprom = zext i32 %2 to i64
+  %arrayidx = getelementptr inbounds float, float* %p, i64 %idxprom
+  %3 = load float, float* %arrayidx, align 4
+  ret float %3
+}
+
+; CHECK-LABEL: @f1
+; CHECK: addrspacecast float* {{%.*}} to float addrspace(1)*
+; CHECK: getelementptr inbounds float, float addrspace(1)*
+; CHECK: load float, float addrspace(1)*
+define float @f1(float* %p) {
+entry:
+  %0 = bitcast float* %p to i8*
+  %1 = call i1 @llvm.nvvm.isspacep.global(i8* %0)
+  tail call void @llvm.assume(i1 %1)
+  %2 = tail call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  %idxprom = zext i32 %2 to i64

[clang] 45b84a5 - [Sema][NFC] Improve test coverage for builtin binary operators.

2021-11-03 Thread Clement Courbet via cfe-commits

Author: Clement Courbet
Date: 2021-11-03T15:51:35+01:00
New Revision: 45b84a547efe8991b28883c73efa2de798dc2c30

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

LOG: [Sema][NFC] Improve test coverage for builtin binary operators.

In preparation for D112453.

Added: 
clang/test/CXX/over/over.built/p13.cpp
clang/test/CXX/over/over.built/p14.cpp

Modified: 
clang/test/CXX/over/over.built/p7-ast.cpp

Removed: 




diff  --git a/clang/test/CXX/over/over.built/p13.cpp 
b/clang/test/CXX/over/over.built/p13.cpp
new file mode 100644
index ..de57130386e8
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p13.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-tautological-compare
+
+template 
+void f(int i, float f, bool b, char c, int* pi, T* pt) {
+  (void)(i*i);
+  (void)(i*f);
+  (void)(i*b);
+  (void)(i*c);
+  (void)(i*pi); // expected-error {{invalid operands to binary expression}}
+  (void)(i*pt); // FIXME
+
+  (void)(i/i);
+  (void)(i/f);
+  (void)(i/b);
+  (void)(i/c);
+  (void)(i/pi); // expected-error {{invalid operands to binary expression}}
+  (void)(i/pt); // FIXME
+
+  (void)(i-i);
+  (void)(i-f);
+  (void)(i-b);
+  (void)(i-c);
+  (void)(i-pi); // expected-error {{invalid operands to binary expression}}
+  (void)(i-pt); // FIXME
+
+  (void)(i
+void f(int* pi, T* pt) {
+  (void)(pi+3);
+  (void)(3+pi);
+  (void)(pi-3);
+  (void)(pi[3]);
+  (void)(3[pi]);
+
+  (void)(pt+3);
+  (void)(3+pt);
+  (void)(pt-3);
+  (void)(pt[3]);
+  (void)(3[pt]);
+}
+// expected-no-diagnostics

diff  --git a/clang/test/CXX/over/over.built/p7-ast.cpp 
b/clang/test/CXX/over/over.built/p7-ast.cpp
index 9f501a496fea..f3c44cff3951 100644
--- a/clang/test/CXX/over/over.built/p7-ast.cpp
+++ b/clang/test/CXX/over/over.built/p7-ast.cpp
@@ -6,7 +6,25 @@ template 
 auto Test(T* pt) {
   // CHECK: UnaryOperator {{.*}} '' prefix '*'
   // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
-  return *pt;
+  (void)*pt;
+
+  // CHECK: UnaryOperator {{.*}} '' prefix '++'
+  // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
+  (void)(++pt);
+
+  // CHECK: UnaryOperator {{.*}} '' prefix '+'
+  // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
+  (void)(+pt);
+
+  // CHECK: BinaryOperator {{.*}} '' '+'
+  // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
+  // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 3
+  (void)(pt + 3);
+
+  // CHECK: BinaryOperator {{.*}} '' '-'
+  // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
+  // CHECK-NEXT: DeclRefExpr {{.*}} 'T *' lvalue ParmVar {{.*}} 'pt' 'T *'
+  (void)(pt -pt);
 }
 
 



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


[PATCH] D112285: [PowerPC] PPC backend optimization to lower int_ppc_tdw/int_ppc_tw intrinsics to TDI/TWI machine instructions

2021-11-03 Thread Victor Huang via Phabricator via cfe-commits
NeHuang added inline comments.



Comment at: 
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-trap-64bit-only.ll:131
+; CHECK:   # %bb.0:
+; CHECK-NEXT:tdi 3, 3, 32767
+; CHECK-NEXT:blr

amyk wrote:
> amyk wrote:
> > nemanjai wrote:
> > > Can we add `-ppc-asm-full-reg-names` to the RUN lines so it is more clear 
> > > which operand is a register and which is an immediate. This works on AIX 
> > > now since https://reviews.llvm.org/D94282 landed.
> > Maybe it would be good to pre-commit the change with 
> > `-ppc-asm-full-reg-names` added to the run lines so then this patch can 
> > only contain the pertinent `td`/`tdi`/`tw`/`twi` changes.
> I meant, maybe it is a better idea to commit the test cases with 
> `-ppc-asm-full-reg-names` first, so then this revision does not contain the 
> additional updates of adding the registers in places that is not affected by 
> your patch. However, perhaps if Nemanja thinks adding the option to this 
> patch is OK, then that's fine with me, too. 
Good catch. Let me rebase this patch with ToT. The NFC patch was committed at 
40cad47fd82ecaf253ba9b11fcd34f67dd557e9d.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112285

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


[PATCH] D112041: [InferAddressSpaces] Support assumed addrspaces from addrspace predicates.

2021-11-03 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:240
 
+  Optional getPredicatedAddrSpace(const Value &V, Value *Opnd) const;
+

The pass is already using UninitializedAddressSpace as a sentinal value; just 
use that instead of Optional?



Comment at: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:958
+ << "  deduce operand AS from the predicate addrspace "
+ << AS.getValue() << '\n');
+  OperandAS = AS.getValue();

*AS instead of getValue


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112041

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


[PATCH] D112024: [clang] diagnose_as attribute for Fortify diagnosing like builtins.

2021-11-03 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield updated this revision to Diff 384451.
mbenfield added a comment.

Renamed to diagnose_as_builtin (since two people suggested that name). Let me
know if a name mentioning fortify is preferred.

Validation in handleDiagnoseAsBuiltinAttr:

- first argument is a builtin function
- number of arguments matches number of parameters of that function
- subsequent arguments are integers
- indices are in bounds for the parameters of the declared function
- types match for declared function and builtin function

Added diagnostics for the above errors.

Added some consts.

Moved tests to new file attr-diagnose-as-builtin.c.

Added many test cases.

Fixed diagnostic around checkUInt32Argument.

Clarified documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112024

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/attr-diagnose-as-builtin.c

Index: clang/test/Sema/attr-diagnose-as-builtin.c
===
--- /dev/null
+++ clang/test/Sema/attr-diagnose-as-builtin.c
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 %s -verify
+// RUN: %clang_cc1 -xc++ -triple x86_64-apple-macosx10.14.0 %s -verify
+
+typedef unsigned long size_t;
+
+void *test_memcpy(const void *src, size_t c, void *dst) __attribute__((diagnose_as_builtin(__builtin_memcpy, 3, 1, 2))) {
+  return __builtin_memcpy(dst, src, c);
+}
+
+void call_test_memcpy() {
+  char bufferA[10];
+  char bufferB[11];
+  test_memcpy(bufferB, 10, bufferA);
+  test_memcpy(bufferB, 11, bufferA); // expected-warning {{'memcpy' will always overflow; destination buffer has size 10, but size argument is 11}}
+}
+
+void failure_function_doesnt_exist() __attribute__((diagnose_as_builtin(__function_that_doesnt_exist))) {} // expected-error {{use of undeclared identifier '__function_that_doesnt_exist'}}
+
+void not_a_builtin() {}
+
+void failure_not_a_builtin() __attribute__((diagnose_as_builtin(not_a_builtin))) {} // expected-error {{'diagnose_as_builtin' attribute requires parameter 1 to be a builtin function}}
+
+void failure_too_many_parameters(void *dst, const void *src, size_t count, size_t nothing) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3, 4))) {} // expected-error {{'diagnose_as_builtin' attribute references function __builtin_memcpy, which requires exactly 3 arguments}}
+
+void failure_too_few_parameters(void *dst, const void *src) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2))) {} // expected-error{{'diagnose_as_builtin' attribute references function __builtin_memcpy, which requires exactly 3 arguments}}
+
+void failure_not_an_integer(void *dst, const void *src, size_t count) __attribute__((diagnose_as_builtin(__builtin_memcpy, "abc", 2, 3))) {} // expected-error{{'diagnose_as_builtin' attribute requires parameter 2 to be an integer constant}}
+
+void failure_not_a_builtin2() __attribute__((diagnose_as_builtin("abc"))) {} // expected-error{{'diagnose_as_builtin' attribute requires parameter 1 to be a builtin function}}
+
+void failure_parameter_index_bounds(void *dst, const void *src) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3))) {} // expected-error{{'diagnose_as_builtin' attribute references parameter 3, but the function failure_parameter_index_bounds has only 2 parameters}}
+
+void failure_parameter_types(double dst, const void *src, size_t count) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3))) {} // expected-error{{'diagnose_as_builtin' attribute parameter types do not match: parameter 1 of function 'failure_parameter_types' has type 'double', but parameter 1 of function '__builtin_memcpy' has type 'void *'}}
+
+void to_redeclare(void *dst, const void *src, size_t count);
+
+void use_to_redeclare() {
+  char src[10];
+  char dst[9];
+  // We shouldn't get an error yet.
+  to_redeclare(dst, src, 10);
+}
+
+void to_redeclare(void *dst, const void *src, size_t count) __attribute((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3)));
+
+void error_to_redeclare() {
+  char src[10];
+  char dst[9];
+  // Now we get an error.
+  to_redeclare(dst, src, 10); // expected-warning {{'memcpy' will always overflow; destination buffer has size 9, but size argument is 10}}
+}
+
+// Make sure this works even with extra qualifiers and the pass_object_size attribute.
+void *memcpy2(void *const dst __attribute__((pass_object_size(0))), const void *src, size_t copy_amount) __attribute((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3)));
+
+void call_memcpy2() {
+  char buf1[10];
+  char buf2[11];
+  memcpy2(buf1, buf2, 11); // expected-warning {{'memcpy' will always overflow; destination buffer has size 10, but size argument is 11}}
+}
+
+#ifdef __cp

[PATCH] D111477: DO NOT SUBMIT: workaround for context-sensitive use of non-type-template-parameter integer suffixes

2021-11-03 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

This broke libc++'s CI: 
https://buildkite.com/llvm-project/libcxx-ci/builds/6374#7569da95-c852-44f9-8b69-947245cf0b65

When you make a change to Clang AND the libc++ tests at the same time, you have 
to account for the fact that we support older versions of Clang. For example, 
here, you changed the pretty printer test, but we still run that test with 
Clang 12 and Clang 13, not only with Clang `main`. Since older Clangs don't 
contain your change, the test fails (and rightfully so). I'll add the necessary 
`XFAIL`s, but please look out for these breakages since they are somewhat 
disruptive. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111477

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


[PATCH] D113096: [X86][MS-InlineAsm] Add constraint *m for memory access w/ global var

2021-11-03 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

How about the GV is function pointer? I believe @xiangzhangllvm has lots of 
experience on it :)




Comment at: clang/test/CodeGen/ms-inline-asm-static-variable.c:8
+  // CHECK: @arr = internal global [10 x i32]
+  // CHECK: call void asm sideeffect inteldialect "mov dword ptr $0[edx * 
$$4],edx", "=*m,{{.*}}([10 x i32]* @arr)
+  __asm mov  dword ptr arr[edx*4],edx

IIRC, we have limitation on the number. Can you check if it works when we have 
more than 10 global variables.



Comment at: clang/test/CodeGen/ms-inline-asm-variables.c:35
 }
-

Unrelated change.



Comment at: llvm/test/CodeGen/X86/ms-inline-asm-array.ll:15-22
+!llvm.module.flags = !{!0, !1, !2}
+!llvm.ident = !{!3}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{i32 7, !"uwtable", i32 1}
+!2 = !{i32 7, !"frame-pointer", i32 2}
+!3 = !{!"clang"}

These seem unnecessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113096

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


[PATCH] D112453: [Sema] When dereferencing a pointer of dependent type, infer the result type.

2021-11-03 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

In D112453#3103515 , @rsmith wrote:

> I think this change is being made in an imperfect place, though. Instead of 
> putting a special case in here, how would we feel about making 
> `Type::isOverloadableType()` smarter, to return `false` for dependent types 
> that can't possibly be class or enum types (eg, dependent pointer types, 
> array types, and maybe more exotic things like function types, atomic types, 
> and complex types)? This would then apply to all operators, not only unary 
> `*`. Eg, we know the type of `&p` where `p` is `T*`, and we know the type of 
> `p + n` where  `p` is `T*` and  `n` is integral. That change might have a lot 
> more fallout, but it'd certainly be interesting to see what it breaks.

Thanks for the suggestion ! I've improved test coverage for unary operators in 
rG1427742750ed 
. There 
was a minor breakage with this change in `Sema::DefaultLvalueConversion` which 
did not handle dependant pointers.

Binary operators look like they break more things. Working on it now.

> Is this change observable in some way? We should include a test with this 
> change that demonstrates what effect it has. (The existing test in this patch 
> passes with or without the change.)

Yes, I agree. The idea of this test was just to check that adding this did not 
have side effects on how clang was handling what the standard mandates, but 
you've covered this in the first part of your answer, thanks.
I don't think it's observable directly (I'm observing the type using 
`getType()` directly in my case), so I'll add an AST dump test, thanks for the 
suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112453

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


[PATCH] D111100: enable plugins for clang-tidy

2021-11-03 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

bump? tagging some more people who seemed like possible reviewers. I realized 
my original list of candidates might have mostly been inactive people.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D00

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


[PATCH] D113115: Add diagnostic groups for attribute extensions

2021-11-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, rjmccall, jyknight, erichkeane.
aaron.ballman requested review of this revision.
Herald added a project: clang.

Some users have a need to control attribute extension diagnostics independent 
of other extension diagnostics. Consider something like use of [[nodiscard]] 
within C++11:

  #if __has_cpp_attribute(nodiscard)
  [[nodiscard]] 
  #endif
  int f();

If compiled with -Wc++17-extensions enabled, this will produce `warning: use of 
the 'nodiscard' attribute is a C++17 extension`. This diagnostic is correct -- 
using `[[nodiscard]]` in C++11 mode is a C++17 extension. And the behavior of 
`__has_cpp_attribute(nodiscard)` is also correct -- we support `[[nodiscard]]` 
in C++11 mode as a conforming extension. But this makes use of `-Werror` or 
-pedantic-errors` builds more onerous.

This patch adds diagnostic groups for attribute extensions so that users can 
selectively disable attribute extension diagnostics. I believe this is 
preferable to requiring users to specify additional flags because it means 
`-Wc++17-extensions` continues to be the way we enable all C++17-related 
extension diagnostics. It would be quite easy for someone to use that flag 
thinking they're protected from some portability issues without realizing it 
skipped attribute extensions if we went the other way.

This addresses PR33518.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113115

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/SemaCXX/attr-extension-diags.cpp


Index: clang/test/SemaCXX/attr-extension-diags.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-extension-diags.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++11 -verify=ext -fsyntax-only 
-Wfuture-attribute-extensions %s
+// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only 
-Wno-future-attribute-extensions %s
+// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only 
-Wno-c++14-attribute-extensions -Wno-c++17-attribute-extensions 
-Wno-c++20-attribute-extensions %s
+
+// expected-no-diagnostics
+
+[[deprecated]] int func1(); // ext-warning {{use of the 'deprecated' attribute 
is a C++14 extension}}
+[[deprecated("msg")]] int func2(); // ext-warning {{use of the 'deprecated' 
attribute is a C++14 extension}}
+
+[[nodiscard]] int func3(); // ext-warning {{use of the 'nodiscard' attribute 
is a C++17 extension}}
+[[nodiscard("msg")]] int func4(); // ext-warning {{use of the 'nodiscard' 
attribute is a C++20 extension}}
+
+void func5() {
+  if (true) [[likely]]; // ext-warning {{use of the 'likely' attribute is a 
C++20 extension}}  
+}
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8617,11 +8617,11 @@
   InGroup>;
 
 def ext_cxx14_attr : Extension<
-  "use of the %0 attribute is a C++14 extension">, InGroup;
+  "use of the %0 attribute is a C++14 extension">, InGroup;
 def ext_cxx17_attr : Extension<
-  "use of the %0 attribute is a C++17 extension">, InGroup;
+  "use of the %0 attribute is a C++17 extension">, InGroup;
 def ext_cxx20_attr : Extension<
-  "use of the %0 attribute is a C++20 extension">, InGroup;
+  "use of the %0 attribute is a C++20 extension">, InGroup;
 
 def warn_unused_comparison : Warning<
   "%select{equality|inequality|relational|three-way}0 comparison result 
unused">,
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -1040,6 +1040,13 @@
 def NonGCC : DiagGroup<"non-gcc",
 [SignCompare, Conversion, LiteralRange]>;
 
+def CXX14Attrs : DiagGroup<"c++14-attribute-extensions">;
+def CXX17Attrs : DiagGroup<"c++17-attribute-extensions">;
+def CXX20Attrs : DiagGroup<"c++20-attribute-extensions">;
+def FutureAttrs : DiagGroup<"future-attribute-extensions", [CXX14Attrs,
+CXX17Attrs,
+CXX20Attrs]>;
+
 // A warning group for warnings about using C++11 features as extensions in
 // earlier C++ versions.
 def CXX11 : DiagGroup<"c++11-extensions", [CXX11ExtraSemi, 
CXX11InlineNamespace,
@@ -1047,15 +1054,15 @@
 
 // A warning group for warnings about using C++14 features as extensions in
 // earlier C++ versions.
-def CXX14 : DiagGroup<"c++14-extensions", [CXX14BinaryLiteral]>;
+def CXX14 : DiagGroup<"c++14-extensions", [CXX14BinaryLiteral, CXX14Attrs]>;
 
 // A warning group for warnings about using C++17 features as extensions in
 // earlier C++ versions.
-def CXX17 : DiagGroup<"c++17-extensions">;
+def CXX17 : DiagGroup<"c++17-extensions", [CXX17Attrs]>

[PATCH] D111477: DO NOT SUBMIT: workaround for context-sensitive use of non-type-template-parameter integer suffixes

2021-11-03 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Trying to fix this in https://reviews.llvm.org/D113112.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111477

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


[PATCH] D112732: [ASan] Process functions in Asan module pass

2021-11-03 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 384465.
kstoimenov added a comment.

Moved module instumentation back ahead of function instrumentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112732

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
  llvm/test/Other/new-pm-print-pipeline.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -340,19 +340,16 @@
   PB.registerPipelineParsingCallback(
   [](StringRef Name, ModulePassManager &MPM,
  ArrayRef) {
-AddressSanitizerOptions Opts;
 if (Name == "asan-pipeline") {
   MPM.addPass(
   RequireAnalysisPass());
-  MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
   MPM.addPass(ModuleAddressSanitizerPass());
   return true;
 } else if (Name == "asan-function-pipeline") {
+  // FIXME: now this is the same as asan-pipeline and can me removed.
   MPM.addPass(
   RequireAnalysisPass());
-  MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
+  MPM.addPass(ModuleAddressSanitizerPass());
   return true;
 }
 return false;
Index: llvm/test/Other/new-pm-print-pipeline.ll
===
--- llvm/test/Other/new-pm-print-pipeline.ll
+++ llvm/test/Other/new-pm-print-pipeline.ll
@@ -46,8 +46,8 @@
 ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(hwasan<>,hwasan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-14
 ; CHECK-14: hwasan<>,hwasan
 
-; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(asan<>,asan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-15
-; CHECK-15: function(asan<>,asan)
+; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(asan<>,asan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-15
+; CHECK-15: asan<>,asan
 
 ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(loop-extract<>,loop-extract)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-16
 ; CHECK-16: loop-extract<>,loop-extract
Index: llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
@@ -2,7 +2,7 @@
 ; Make sure asan does not instrument __sancov_gen_
 
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
-; RUN: opt < %s -passes='module(require,sancov-module,asan-module),function(asan)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
+; RUN: opt < %s -passes='module(require,sancov-module,asan)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 $Foo = comdat any
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1295,17 +1295,27 @@
 
 ModuleAddressSanitizerPass::ModuleAddressSanitizerPass(
 bool CompileKernel, bool Recover, bool UseGlobalGC, bool UseOdrIndicator,
-AsanDtorKind DestructorKind)
+AsanDtorKind DestructorKind, bool UseAfterScope,
+AsanDetectStackUseAfterReturnMode UseAfterReturn)
 : CompileKernel(CompileKernel), Recover(Recover), UseGlobalGC(UseGlobalGC),
-  UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {}
+  UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind),
+  UseAfterScope(UseAfterScope), UseAfterReturn(UseAfterReturn) {}
 
 PreservedAnalyses ModuleAddressSanitizerPass::run(Module &M,
-  AnalysisManager &AM) {
-  GlobalsMetadata &GlobalsMD = AM.getResult(M);
-  ModuleAddressSanitizer Sanitizer(M, &GlobalsMD, CompileKernel, Recover,
-   UseGlobalGC, UseOdrIndicator,
-   DestructorKind);
-  if (Sanitizer.instrumentModule(M))
+  ModuleAnalysisManager &MAM) {
+  GlobalsMetadata &GlobalsM

[PATCH] D112732: [ASan] Process functions in Asan module pass

2021-11-03 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 384467.
kstoimenov added a comment.

Moved empty check to the top of the function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112732

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
  llvm/test/Other/new-pm-print-pipeline.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -340,19 +340,16 @@
   PB.registerPipelineParsingCallback(
   [](StringRef Name, ModulePassManager &MPM,
  ArrayRef) {
-AddressSanitizerOptions Opts;
 if (Name == "asan-pipeline") {
   MPM.addPass(
   RequireAnalysisPass());
-  MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
   MPM.addPass(ModuleAddressSanitizerPass());
   return true;
 } else if (Name == "asan-function-pipeline") {
+  // FIXME: now this is the same as asan-pipeline and can me removed.
   MPM.addPass(
   RequireAnalysisPass());
-  MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
+  MPM.addPass(ModuleAddressSanitizerPass());
   return true;
 }
 return false;
Index: llvm/test/Other/new-pm-print-pipeline.ll
===
--- llvm/test/Other/new-pm-print-pipeline.ll
+++ llvm/test/Other/new-pm-print-pipeline.ll
@@ -46,8 +46,8 @@
 ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(hwasan<>,hwasan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-14
 ; CHECK-14: hwasan<>,hwasan
 
-; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(asan<>,asan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-15
-; CHECK-15: function(asan<>,asan)
+; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(asan<>,asan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-15
+; CHECK-15: asan<>,asan
 
 ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(loop-extract<>,loop-extract)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-16
 ; CHECK-16: loop-extract<>,loop-extract
Index: llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
@@ -2,7 +2,7 @@
 ; Make sure asan does not instrument __sancov_gen_
 
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
-; RUN: opt < %s -passes='module(require,sancov-module,asan-module),function(asan)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
+; RUN: opt < %s -passes='module(require,sancov-module,asan)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 $Foo = comdat any
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1295,17 +1295,27 @@
 
 ModuleAddressSanitizerPass::ModuleAddressSanitizerPass(
 bool CompileKernel, bool Recover, bool UseGlobalGC, bool UseOdrIndicator,
-AsanDtorKind DestructorKind)
+AsanDtorKind DestructorKind, bool UseAfterScope,
+AsanDetectStackUseAfterReturnMode UseAfterReturn)
 : CompileKernel(CompileKernel), Recover(Recover), UseGlobalGC(UseGlobalGC),
-  UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {}
+  UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind),
+  UseAfterScope(UseAfterScope), UseAfterReturn(UseAfterReturn) {}
 
 PreservedAnalyses ModuleAddressSanitizerPass::run(Module &M,
-  AnalysisManager &AM) {
-  GlobalsMetadata &GlobalsMD = AM.getResult(M);
-  ModuleAddressSanitizer Sanitizer(M, &GlobalsMD, CompileKernel, Recover,
-   UseGlobalGC, UseOdrIndicator,
-   DestructorKind);
-  if (Sanitizer.instrumentModule(M))
+  ModuleAnalysisManager &MAM) {
+  GlobalsMetadata &GlobalsMD = MAM.getResult(M);

[PATCH] D113115: Add diagnostic groups for attribute extensions

2021-11-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

I like the approach, and a pretty trivial implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113115

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


[PATCH] D113118: [clang][AST] Check context of record in structural equivalence.

2021-11-03 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: steakhal, martong, gamesh411, Szelethus, dkrupp.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The AST structural equivalence check did not differentiate between
a struct and a struct with same name in different namespace. When
type of a member is checked it is possible to encounter such a case
and wrongly decide that the types are similar. This problem is fixed
by check for the namespaces of a record declaration.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113118

Files:
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/unittests/AST/StructuralEquivalenceTest.cpp

Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -929,6 +929,107 @@
   EXPECT_TRUE(testStructuralMatch(First, Second));
 }
 
+struct StructuralEquivalenceRecordContextTest : StructuralEquivalenceTest {};
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNoVsNamed) {
+  auto Decls = makeDecls("class X;", "namespace N { class X; }",
+Lang_CXX03, cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNamedVsNamed) {
+  auto Decls = makeDecls("namespace A { class X; }",
+"namespace B { class X; }", Lang_CXX03,
+cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceAnonVsNamed) {
+  auto Decls = makeDecls("namespace { class X; }",
+"namespace N { class X; }", Lang_CXX03,
+cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNoVsAnon) {
+  auto Decls = makeDecls("class X;", "namespace { class X; }",
+Lang_CXX03, cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceAnonVsAnon) {
+  auto Decls = makeDecls("namespace { class X; }",
+"namespace { class X; }", Lang_CXX03,
+cxxRecordDecl());
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceAnonVsAnonAnon) {
+  auto Decls = makeDecls("namespace { class X; }",
+"namespace { namespace { class X; } }",
+Lang_CXX03, cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest,
+   NamespaceNamedNamedVsNamedNamed) {
+  auto Decls = makeDecls(
+  "namespace A { namespace N { class X; } }",
+  "namespace B { namespace N { class X; } }", Lang_CXX03, cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceNamedVsInline) {
+  auto Decls = makeDecls(
+  "namespace A { namespace A { class X; } }",
+  "namespace A { inline namespace A { class X; } }", Lang_CXX17,
+  cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, NamespaceInlineVsInline) {
+  auto Decls = makeDecls(
+  "namespace A { inline namespace A { class X; } }",
+  "namespace A { inline namespace B { class X; } }", Lang_CXX17,
+  cxxRecordDecl());
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, TransparentContext) {
+  auto Decls = makeDecls("extern \"C\" { class X; }", "class X;",
+Lang_CXX17, cxxRecordDecl());
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceRecordContextTest, TransparentContextNE) {
+  auto Decls = makeDecls("extern \"C\" { class X; }",
+"namespace { class X; }", Lang_CXX17,
+cxxRecordDecl());
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceTest, NamespaceOfRecordMember) {
+  auto Decls = makeDecls(
+  R"(
+  class X;
+  class Y { X* x; };
+  )",
+  R"(
+  namespace N { class X; }
+  class Y { N::X* x; };
+  )",
+  Lang_CXX03, cxxRecordDecl(hasName("Y")));
+  EXPECT_FALSE(testStructuralMatch(Decls));
+}
+
+TEST_F(StructuralEquivalenceTest, StructDefinitionInPrototype) {
+  auto Decls = makeDecls(
+  "struct Param { int a; }; void f(struct Param *p);",
+  "void f(struct Param { int a; } *p);", Lang_C89,
+  parmVarDecl(hasName("p")));
+  EXPECT_TRUE(testStructuralMatch(Decls));
+}

[PATCH] D113120: [clang] Add early exit when checking for const init of arrays.

2021-11-03 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
adamcz added a reviewer: kadircet.
adamcz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Before this commit, on code like:

  struct S { ... };
  S arr[1000];

while checking if arr is constexpr, clang would reserve memory for
arr before running constructor for S. If S turned out to not have a
valid constexpr c-tor, clang would still try to initialize each element
(and, in case the c-tor was trivial, even skipping the constexpr step
limit), only to discard that whole APValue later, since the first
element generated a diagnostic.

With this change, we start by allocating just 1 element in the array to
try out the c-tor and take an early exit if any diagnostics are
generated, avoiding possibly large memory allocation and a lot of work
initializing to-be-discarded APValues.

Fixes 51712 and 51843.

In the future we may want to be smarter about large possibly-constexrp
arrays and maybe make the allocation lazy.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113120

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/PR51712-large-array-constexpr-check-oom.cpp


Index: clang/test/SemaCXX/PR51712-large-array-constexpr-check-oom.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/PR51712-large-array-constexpr-check-oom.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// This used to require too much memory and crash with OOM.
+struct {
+  int a, b, c, d;
+} arr[1<<30];
+
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10596,28 +10596,53 @@
   bool HadZeroInit = Value->hasValue();
 
   if (const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(Type)) {
-unsigned N = CAT->getSize().getZExtValue();
+unsigned FinalSize = CAT->getSize().getZExtValue();
 
 // Preserve the array filler if we had prior zero-initialization.
 APValue Filler =
   HadZeroInit && Value->hasArrayFiller() ? Value->getArrayFiller()
  : APValue();
 
-*Value = APValue(APValue::UninitArray(), N, N);
-
-if (HadZeroInit)
-  for (unsigned I = 0; I != N; ++I)
-Value->getArrayInitializedElt(I) = Filler;
+*Value = APValue(APValue::UninitArray(), 0, FinalSize);
+if (FinalSize == 0)
+  return true;
 
-// Initialize the elements.
 LValue ArrayElt = Subobject;
 ArrayElt.addArray(Info, E, CAT);
-for (unsigned I = 0; I != N; ++I)
-  if (!VisitCXXConstructExpr(E, ArrayElt, 
&Value->getArrayInitializedElt(I),
- CAT->getElementType()) ||
-  !HandleLValueArrayAdjustment(Info, E, ArrayElt,
-   CAT->getElementType(), 1))
-return false;
+// We do the whole initialization in two passes, first for just one 
element,
+// then for the whole array. It's possible we may find out we can't do 
const
+// init in the first pass, in which case we avoid allocating a potentially
+// large array. We don't do more passes because expanding array requires
+// copying the data, which is wasteful.
+for (const unsigned N : {1u, FinalSize}) {
+  unsigned OldElts = Value->getArrayInitializedElts();
+  if (OldElts == N)
+break;
+
+  // Expand the array to appropriate size.
+  APValue NewValue(APValue::UninitArray(), N, FinalSize);
+  for (unsigned I = 0; I < OldElts; ++I)
+NewValue.getArrayInitializedElt(I).swap(
+Value->getArrayInitializedElt(I));
+  Value->swap(NewValue);
+
+  if (HadZeroInit)
+for (unsigned I = OldElts; I < N; ++I)
+  Value->getArrayInitializedElt(I) = Filler;
+
+  // Initialize the elements.
+  for (unsigned I = OldElts; I < N; ++I) {
+if (!VisitCXXConstructExpr(E, ArrayElt,
+   &Value->getArrayInitializedElt(I),
+   CAT->getElementType()) ||
+!HandleLValueArrayAdjustment(Info, E, ArrayElt,
+ CAT->getElementType(), 1))
+  return false;
+if (Info.EvalStatus.Diag && !Info.EvalStatus.Diag->empty() &&
+!Info.keepEvaluatingAfterFailure())
+  return false;
+  }
+}
 
 return true;
   }


Index: clang/test/SemaCXX/PR51712-large-array-constexpr-check-oom.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/PR51712-large-array-constexpr-check-oom.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// This used to require too much memory and crash with OOM.
+struct {
+  int a, b, c, d;
+} arr[1<<30];
+
Index: clang/lib/AST/ExprConsta

[PATCH] D113120: [clang] Add early exit when checking for const init of arrays.

2021-11-03 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added a comment.

Hey Kadir. This is my naive approach at solving that large memory usage issue 
you reported. It works, although I wish this was more generic. I'm not an 
expert on this piece of code, so I tried to keep things similar to how they 
worked previously. Let me know what you think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113120

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


[PATCH] D113115: Add diagnostic groups for attribute extensions

2021-11-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D113115#3106360 , @erichkeane 
wrote:

> I like the approach, and a pretty trivial implementation.

Thanks for the review! I'm going to hold off on landing for a little bit in 
case @rsmith has opinions because he had other ideas on the bug report itself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113115

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


[PATCH] D111669: No longer crash when a consteval function returns a structure

2021-11-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Ping


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

https://reviews.llvm.org/D111669

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


[PATCH] D112915: WIP: [clang][modules] Granular tracking of includes

2021-11-03 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 384484.
jansvoboda11 added a comment.

Avoid copying data between submodules


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112915

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/Inputs/import-submodule-visibility/A.framework/Headers/A.h
  
clang/test/Modules/Inputs/import-submodule-visibility/A.framework/Modules/module.modulemap
  clang/test/Modules/Inputs/import-submodule-visibility/B.framework/Headers/B1.h
  clang/test/Modules/Inputs/import-submodule-visibility/B.framework/Headers/B2.h
  
clang/test/Modules/Inputs/import-submodule-visibility/B.framework/Modules/module.modulemap
  clang/test/Modules/Inputs/import-submodule-visibility/C/C.h
  clang/test/Modules/Inputs/import-submodule-visibility/C/module.modulemap
  clang/test/Modules/Inputs/import-submodule-visibility/D/D1.h
  clang/test/Modules/Inputs/import-submodule-visibility/D/D2.h
  clang/test/Modules/Inputs/import-submodule-visibility/D/module.modulemap
  clang/test/Modules/Inputs/import-submodule-visibility/Textual.h
  clang/test/Modules/import-submodule-visibility.c

Index: clang/test/Modules/import-submodule-visibility.c
===
--- /dev/null
+++ clang/test/Modules/import-submodule-visibility.c
@@ -0,0 +1,58 @@
+// RUN: rm -rf %t && mkdir -p %t
+
+// This test checks that imports of headers that appeared in a different submodule than
+// what is imported by the current TU don't affect the compilation.
+
+// Framework "A" includes "Textual.h" in the top-level module.
+// This test checks that simply specifying the PCM file on the command line (without actually importing "A") does not
+// prevent "Textual.h" to be included in the TU.
+//
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/import-submodule-visibility \
+// RUN:   -emit-module %S/Inputs/import-submodule-visibility/A.framework/Modules/module.modulemap -fmodule-name=A -o %t/A.pcm
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/import-submodule-visibility -fsyntax-only %s -DA \
+// RUN:   -fmodule-file=%t/A.pcm -fmodule-map-file=%S/Inputs/import-submodule-visibility/A.framework/Modules/module.modulemap
+
+// Framework "B" includes "Textual.h" in the "B1" submodule and its "B2" submodule does not include "Textual.h" at all.
+// This test checks that specifying the PCM file on the command line and importing "B2" in the source does not
+// prevent "Textual.h" to be included in the TU.
+//
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/import-submodule-visibility \
+// RUN:   -emit-module %S/Inputs/import-submodule-visibility/B.framework/Modules/module.modulemap -fmodule-name=B -o %t/B.pcm
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/import-submodule-visibility -fsyntax-only %s -DB -iframework %S/Inputs/import-submodule-visibility \
+// RUN:   -fmodule-file=%t/B.pcm -fmodule-map-file=%S/Inputs/import-submodule-visibility/B.framework/Modules/module.modulemap
+
+// Module "C" includes "Textual.h" in the top level module.
+// This is a module-only version of the test with framework A.
+//
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/import-submodule-visibility \
+// RUN:   -emit-module %S/Inputs/import-submodule-visibility/C/module.modulemap -fmodule-name=C -o %t/C.pcm
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/import-submodule-visibility -fsyntax-only %s -DC \
+// RUN:   -fmodule-file=%t/C.pcm -fmodule-map-file=%S/Inputs/import-submodule-visibility/C/module.modulemap
+
+// Module "D" includes "Textual.h" in the "D1" submodule and its "D2" submodules does not include "Textual.h" at all.
+// This is a module-only version of the test with framework B.
+//
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/import-submodule-visibility \
+// RUN:   -emit-module %S/Inputs/import-submodule-visibility/D/module.modulemap -fmodule-name=D -o %t/D.pcm
+// RUN: %clang_cc1 -fmodules -I %S/Inputs/import-submodule-visibility -fsyntax-only %s -DD \
+// RUN:   -fmodule-file=%t/D.pcm -fmodule-map-file=%S/Inputs/import-submodule-visibility/D/module.modulemap
+
+#ifdef A
+//
+#endif
+
+#ifdef B
+#import 
+#endif
+
+#ifdef C
+//
+#endif
+
+#ifdef D
+#import "D/D2.h"
+#endif
+
+#import "Textual.h"
+
+static int x = MACRO_TEXTUAL;
Index: clang/test/Modules/Inputs/import-submodule-visibility/Textual.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/import-submodule-visibility/Textual.h
@@ -0,0 +1 @@
+#define MACRO_TEXTUAL 1
Index: clang/test/Modules/Inputs/import-submodule-visibility/D/module.modulemap
===

[PATCH] D112616: Fix crash on invalid code involving late parsed inline methods

2021-11-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112616

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


[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

2021-11-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Ping


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

https://reviews.llvm.org/D108643

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


[PATCH] D112996: [CodeCompletion] Generally consider header files without extension

2021-11-03 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler updated this revision to Diff 384485.
ckandeler added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112996

Files:
  clang/lib/Sema/SemaCodeComplete.cpp


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -9613,6 +9613,10 @@
   }
 }
 
+const StringRef &Dirname = llvm::sys::path::filename(Dir);
+const bool isQt = Dirname.startswith("Qt") || Dirname == "ActiveQt";
+const bool ExtensionlessHeaders = IsSystem || isQt
+|| Dir.endswith(".framework/Headers");
 std::error_code EC;
 unsigned Count = 0;
 for (auto It = FS.dir_begin(Dir, EC);
@@ -9639,15 +9643,16 @@
 
 AddCompletion(Filename, /*IsDirectory=*/true);
 break;
-  case llvm::sys::fs::file_type::regular_file:
-// Only files that really look like headers. (Except in system dirs).
-if (!IsSystem) {
-  // Header extensions from Types.def, which we can't depend on here.
-  if (!(Filename.endswith_insensitive(".h") ||
-Filename.endswith_insensitive(".hh") ||
-Filename.endswith_insensitive(".hpp") ||
-Filename.endswith_insensitive(".inc")))
-break;
+  case llvm::sys::fs::file_type::regular_file: {
+// Only files that really look like headers. (Except in special dirs).
+// Header extensions from Types.def, which we can't depend on here.
+const bool IsHeader = Filename.endswith_insensitive(".h") ||
+Filename.endswith_insensitive(".hh") ||
+Filename.endswith_insensitive(".hpp") ||
+Filename.endswith_insensitive(".inc") ||
+(ExtensionlessHeaders && !Filename.contains('.'));
+if (!IsHeader)
+  break;
 }
 AddCompletion(Filename, /*IsDirectory=*/false);
 break;


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -9613,6 +9613,10 @@
   }
 }
 
+const StringRef &Dirname = llvm::sys::path::filename(Dir);
+const bool isQt = Dirname.startswith("Qt") || Dirname == "ActiveQt";
+const bool ExtensionlessHeaders = IsSystem || isQt
+|| Dir.endswith(".framework/Headers");
 std::error_code EC;
 unsigned Count = 0;
 for (auto It = FS.dir_begin(Dir, EC);
@@ -9639,15 +9643,16 @@
 
 AddCompletion(Filename, /*IsDirectory=*/true);
 break;
-  case llvm::sys::fs::file_type::regular_file:
-// Only files that really look like headers. (Except in system dirs).
-if (!IsSystem) {
-  // Header extensions from Types.def, which we can't depend on here.
-  if (!(Filename.endswith_insensitive(".h") ||
-Filename.endswith_insensitive(".hh") ||
-Filename.endswith_insensitive(".hpp") ||
-Filename.endswith_insensitive(".inc")))
-break;
+  case llvm::sys::fs::file_type::regular_file: {
+// Only files that really look like headers. (Except in special dirs).
+// Header extensions from Types.def, which we can't depend on here.
+const bool IsHeader = Filename.endswith_insensitive(".h") ||
+Filename.endswith_insensitive(".hh") ||
+Filename.endswith_insensitive(".hpp") ||
+Filename.endswith_insensitive(".inc") ||
+(ExtensionlessHeaders && !Filename.contains('.'));
+if (!IsHeader)
+  break;
 }
 AddCompletion(Filename, /*IsDirectory=*/false);
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112996: [CodeCompletion] Generally consider header files without extension

2021-11-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

LG, thanks! can we the tests again though?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112996

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


[PATCH] D112996: [CodeCompletion] Generally consider header files without extension

2021-11-03 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added inline comments.



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:9619
+const bool ExtensionlessHeaders = IsSystem || isQt
+|| Dir.endswith(".framework/Headers");
 std::error_code EC;

I'm just noticing that this is often a symlink into a versioned directory (e.g. 
xxx.framework/Version/5/Headers). The include paths are not canonicalized, I 
hope?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112996

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


[PATCH] D112996: [CodeCompletion] Generally consider header files without extension

2021-11-03 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

In D112996#3106459 , @sammccall wrote:

> can we the tests again though?

Sorry, I don't understand what you mean by that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112996

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


[PATCH] D112915: WIP: [clang][modules] Granular tracking of includes

2021-11-03 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D112915#3104873 , @vsapsai wrote:

> There can be other reasons to keep `IncludeMap` out of `SubmoduleState` but 
> I'm not sure the local submodule visibility is the right reason. I might be 
> reading the code incorrectly but looks like `CurSubmoduleState` is used when 
> local submodule visibility is disabled. The difference is it's tracking the 
> aggregate state instead of per-submodule state. Need to experiment more but 
> so far tracking includes in `SubmoduleState` follows the spirit of local 
> submodule visibility. Though it's not guaranteed it'll work perfectly from 
> the technical perspective.

Yes, `CurSubmoduleState` is being used unconditionally. However, without local 
submodule visibility enabled, it always points to `NullSubmoduleState`. Only 
with the feature enabled does it point to the current submodule state (stored 
in `Submodules`). The change happens in `Preprocessor::{Enter,Leave}Submodule`.

> Also I think we'll need to increase granularity to track other HeaderFileInfo 
> attributes, not just NumIncludes. Don't have a test case to illustrate that 
> right now and no need to change that now but something to keep in mind.

That's interesting. I think `HeaderFileInfo::isImport` should definitely be 
tracked in the preprocessor, not in `HeaderFileInfo`. The fact that the header 
was `#import`ed is not an intrinsic property of the file itself, but rather a 
preprocessor state. Can you think of other fields that don't really belong to 
`HeaderFileInfo`?

Based on your feedback, I simplified the patch quite a bit. We're no longer 
copying the include state between submodules. In its current form, this patch 
essentially moves `HeaderFileInfo::NumIncludes` into 
`Preprocessor::NumIncludes` and still uses it as the source of truth.
However, we're also tracking `NumIncludes` separately in each submodule and 
serializing this into the PCM. Instead of merging `NumIncludes` of the whole 
module when loading it (which we did before), we can merge `NumIncludes` only 
of the modules we actually import.




Comment at: clang/lib/Lex/Preprocessor.cpp:1323
+auto &ModNumIncludes = SubmoduleIncludeStates[M].NumIncludes;
+for (unsigned UID = 0; UID <= ModNumIncludes.maxUID(); ++UID) {
+  CurSubmoduleIncludeState->NumIncludes[UID] += ModNumIncludes[UID];

Iterating over all FileEntries is probably not very efficient, as Volodymyr 
mentioned. Thinking about how to make this more efficient...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112915

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


[PATCH] D112732: [ASan] Process functions in Asan module pass

2021-11-03 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 384488.
kstoimenov marked 3 inline comments as done.
kstoimenov added a comment.

Moved module after function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112732

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
  llvm/test/Other/new-pm-print-pipeline.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -340,19 +340,16 @@
   PB.registerPipelineParsingCallback(
   [](StringRef Name, ModulePassManager &MPM,
  ArrayRef) {
-AddressSanitizerOptions Opts;
 if (Name == "asan-pipeline") {
   MPM.addPass(
   RequireAnalysisPass());
-  MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
   MPM.addPass(ModuleAddressSanitizerPass());
   return true;
 } else if (Name == "asan-function-pipeline") {
+  // FIXME: now this is the same as asan-pipeline and can me removed.
   MPM.addPass(
   RequireAnalysisPass());
-  MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
+  MPM.addPass(ModuleAddressSanitizerPass());
   return true;
 }
 return false;
Index: llvm/test/Other/new-pm-print-pipeline.ll
===
--- llvm/test/Other/new-pm-print-pipeline.ll
+++ llvm/test/Other/new-pm-print-pipeline.ll
@@ -46,8 +46,8 @@
 ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(hwasan<>,hwasan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-14
 ; CHECK-14: hwasan<>,hwasan
 
-; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(asan<>,asan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-15
-; CHECK-15: function(asan<>,asan)
+; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(asan<>,asan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-15
+; CHECK-15: asan<>,asan
 
 ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(loop-extract<>,loop-extract)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-16
 ; CHECK-16: loop-extract<>,loop-extract
Index: llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
@@ -2,7 +2,7 @@
 ; Make sure asan does not instrument __sancov_gen_
 
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
-; RUN: opt < %s -passes='module(require,sancov-module,asan-module),function(asan)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
+; RUN: opt < %s -passes='module(require,sancov-module,asan)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 $Foo = comdat any
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1295,17 +1295,28 @@
 
 ModuleAddressSanitizerPass::ModuleAddressSanitizerPass(
 bool CompileKernel, bool Recover, bool UseGlobalGC, bool UseOdrIndicator,
-AsanDtorKind DestructorKind)
+AsanDtorKind DestructorKind, bool UseAfterScope,
+AsanDetectStackUseAfterReturnMode UseAfterReturn)
 : CompileKernel(CompileKernel), Recover(Recover), UseGlobalGC(UseGlobalGC),
-  UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {}
+  UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind),
+  UseAfterScope(UseAfterScope), UseAfterReturn(UseAfterReturn) {}
 
 PreservedAnalyses ModuleAddressSanitizerPass::run(Module &M,
-  AnalysisManager &AM) {
-  GlobalsMetadata &GlobalsMD = AM.getResult(M);
-  ModuleAddressSanitizer Sanitizer(M, &GlobalsMD, CompileKernel, Recover,
-   UseGlobalGC, UseOdrIndicator,
-   DestructorKind);
-  if (Sanitizer.instrumentModule(M))
+  ModuleAnalysisManager &MAM) {
+  GlobalsMetadata &Gl

[PATCH] D111669: No longer crash when a consteval function returns a structure

2021-11-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.

Looks to accomplish this exactly the way that @rjmccall  suggested!


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

https://reviews.llvm.org/D111669

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


[PATCH] D111477: DO NOT SUBMIT: workaround for context-sensitive use of non-type-template-parameter integer suffixes

2021-11-03 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D111477#3106171 , @ldionne wrote:

> This broke libc++'s CI: 
> https://buildkite.com/llvm-project/libcxx-ci/builds/6374#7569da95-c852-44f9-8b69-947245cf0b65
>
> When you make a change to Clang AND the libc++ tests at the same time, you 
> have to account for the fact that we support older versions of Clang. For 
> example, here, you changed the pretty printer test, but we still run that 
> test with Clang 12 and Clang 13, not only with Clang `main`. Since older 
> Clangs don't contain your change, the test fails (and rightfully so). I'll 
> add the necessary `XFAIL`s, but please look out for these breakages since 
> they are somewhat disruptive. Thanks!

Thanks for the context/fix - I'll try to keep it in mind.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111477

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


[PATCH] D112768: [ARM] implement support for TLS register based stack protector

2021-11-03 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3190-3191
+  }
+  CmdArgs.push_back("-target-feature");
+  CmdArgs.push_back("+read-tp-hard");
+}

ardb wrote:
> nickdesaulniers wrote:
> > Isn't this redundant/set elsewhere?
> No, it is not. The alternative is requiring the user to pass -mtp=cp15 when 
> using the TLS stack protector, which is silly because it is implied.
Right. Perhaps we could emit `diag::err_drv_argument_not_allowed_with` if the 
user specified `-mtp=soft` with `-mstack-protector-guard=tls`.

It looks like a call to clang::driver::tools::arm::getReadTPMode() should being 
able to tell us whether someone explicitly tried to use soft.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112768

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


[PATCH] D112041: [InferAddressSpaces] Support assumed addrspaces from addrspace predicates.

2021-11-03 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

LGTM in general, modulo remaining nits.




Comment at: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:196
   void inferAddressSpaces(ArrayRef Postorder,
-  ValueToAddrSpaceMapTy *InferredAddrSpace) const;
+  ValueToAddrSpaceMapTy *InferredAddrSpace,
+  PredicatedAddrSpaceMapTy &PredicatedAS) const;

hliao wrote:
> tra wrote:
> > I think this could've been a reference, too.
> yeah, but we should address that in another change.
You're already changing function signatures.It would be reasonable to 
incorporate this cleanup, too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112041

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


[PATCH] D112732: [ASan] Process functions in Asan module pass

2021-11-03 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 384515.
kstoimenov added a comment.

After rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112732

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
  llvm/test/Other/new-pm-print-pipeline.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -340,19 +340,16 @@
   PB.registerPipelineParsingCallback(
   [](StringRef Name, ModulePassManager &MPM,
  ArrayRef) {
-AddressSanitizerOptions Opts;
 if (Name == "asan-pipeline") {
   MPM.addPass(
   RequireAnalysisPass());
-  MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
   MPM.addPass(ModuleAddressSanitizerPass());
   return true;
 } else if (Name == "asan-function-pipeline") {
+  // FIXME: now this is the same as asan-pipeline and can me removed.
   MPM.addPass(
   RequireAnalysisPass());
-  MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
+  MPM.addPass(ModuleAddressSanitizerPass());
   return true;
 }
 return false;
Index: llvm/test/Other/new-pm-print-pipeline.ll
===
--- llvm/test/Other/new-pm-print-pipeline.ll
+++ llvm/test/Other/new-pm-print-pipeline.ll
@@ -46,8 +46,8 @@
 ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(hwasan<>,hwasan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-14
 ; CHECK-14: hwasan<>,hwasan
 
-; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(asan<>,asan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-15
-; CHECK-15: function(asan<>,asan)
+; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(asan<>,asan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-15
+; CHECK-15: asan<>,asan
 
 ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(loop-extract<>,loop-extract)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-16
 ; CHECK-16: loop-extract<>,loop-extract
Index: llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
@@ -2,7 +2,7 @@
 ; Make sure asan does not instrument __sancov_gen_
 
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
-; RUN: opt < %s -passes='module(require,sancov-module,asan-module),function(asan)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
+; RUN: opt < %s -passes='module(require,sancov-module,asan)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 $Foo = comdat any
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1295,17 +1295,28 @@
 
 ModuleAddressSanitizerPass::ModuleAddressSanitizerPass(
 bool CompileKernel, bool Recover, bool UseGlobalGC, bool UseOdrIndicator,
-AsanDtorKind DestructorKind)
+AsanDtorKind DestructorKind, bool UseAfterScope,
+AsanDetectStackUseAfterReturnMode UseAfterReturn)
 : CompileKernel(CompileKernel), Recover(Recover), UseGlobalGC(UseGlobalGC),
-  UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {}
+  UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind),
+  UseAfterScope(UseAfterScope), UseAfterReturn(UseAfterReturn) {}
 
 PreservedAnalyses ModuleAddressSanitizerPass::run(Module &M,
-  AnalysisManager &AM) {
-  GlobalsMetadata &GlobalsMD = AM.getResult(M);
-  ModuleAddressSanitizer Sanitizer(M, &GlobalsMD, CompileKernel, Recover,
-   UseGlobalGC, UseOdrIndicator,
-   DestructorKind);
-  if (Sanitizer.instrumentModule(M))
+  ModuleAnalysisManager &MAM) {
+  GlobalsMetadata &GlobalsMD = MAM.getResult(M);
+  ModuleAddressSanitizer Module

[clang] 76ea87b - [ASan] Process functions in Asan module pass

2021-11-03 Thread Kirill Stoimenov via cfe-commits

Author: Kirill Stoimenov
Date: 2021-11-03T17:51:01Z
New Revision: 76ea87b94e5cba335d691e4e18e3464ad45c8b52

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

LOG: [ASan] Process functions in Asan module pass

This came up as recommendation while reviewing D112098.

Reviewed By: vitalybuka

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
llvm/test/Other/new-pm-print-pipeline.ll
llvm/tools/opt/NewPMDriver.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 534d98be4344a..cca6eb44938ca 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1185,11 +1185,9 @@ static void addSanitizers(const Triple &TargetTriple,
 llvm::AsanDetectStackUseAfterReturnMode UseAfterReturn =
 CodeGenOpts.getSanitizeAddressUseAfterReturn();
 MPM.addPass(RequireAnalysisPass());
-MPM.addPass(ModuleAddressSanitizerPass(CompileKernel, Recover,
-   UseGlobalGC, UseOdrIndicator,
-   DestructorKind));
-MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(
-{CompileKernel, Recover, UseAfterScope, UseAfterReturn})));
+MPM.addPass(ModuleAddressSanitizerPass(
+CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,
+DestructorKind, UseAfterScope, UseAfterReturn));
   }
 };
 ASanPass(SanitizerKind::Address, false);

diff  --git a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h 
b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
index ea18974798570..fb65c59408466 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
@@ -128,7 +128,10 @@ class ModuleAddressSanitizerPass
   explicit ModuleAddressSanitizerPass(
   bool CompileKernel = false, bool Recover = false, bool UseGlobalGC = 
true,
   bool UseOdrIndicator = false,
-  AsanDtorKind DestructorKind = AsanDtorKind::Global);
+  AsanDtorKind DestructorKind = AsanDtorKind::Global,
+  bool UseAfterScope = false,
+  AsanDetectStackUseAfterReturnMode UseAfterReturn =
+  AsanDetectStackUseAfterReturnMode::Runtime);
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
   void printPipeline(raw_ostream &OS,
  function_ref MapClassName2PassName);
@@ -140,6 +143,8 @@ class ModuleAddressSanitizerPass
   bool UseGlobalGC;
   bool UseOdrIndicator;
   AsanDtorKind DestructorKind;
+  bool UseAfterScope;
+  AsanDetectStackUseAfterReturnMode UseAfterReturn;
 };
 
 // Insert AddressSanitizer (address sanity checking) instrumentation

diff  --git a/llvm/lib/Passes/PassRegistry.def 
b/llvm/lib/Passes/PassRegistry.def
index 655c472878a00..58966d3e715d3 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -136,7 +136,7 @@ MODULE_PASS_WITH_PARAMS("hwasan",
 },
 parseHWASanPassOptions,
 "kernel;recover")
-MODULE_PASS_WITH_PARAMS("asan-module",
+MODULE_PASS_WITH_PARAMS("asan",
 "ModuleAddressSanitizerPass",
 [](bool CompileKernel) {
   return ModuleAddressSanitizerPass(CompileKernel,
@@ -393,13 +393,6 @@ FUNCTION_PASS_WITH_PARAMS("loop-unroll",
   "no-profile-peeling;profile-peeling;"
   "no-runtime;runtime;"
   "no-upperbound;upperbound")
-FUNCTION_PASS_WITH_PARAMS("asan",
-  "AddressSanitizerPass",
-   [](AddressSanitizerOptions Opts) {
- return AddressSanitizerPass(Opts);
-   },
-  parseASanPassOptions,
-  "kernel")
 FUNCTION_PASS_WITH_PARAMS("msan",
   "MemorySanitizerPass",
[](MemorySanitizerOptions Opts) {

diff  --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 5563fc14d151b..9cd63574d266d 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1295,17 +1295,28 @@ void ModuleAddressSanitizerPass::printPipeline

[PATCH] D112732: [ASan] Process functions in Asan module pass

2021-11-03 Thread Kirill Stoimenov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG76ea87b94e5c: [ASan] Process functions in Asan module pass 
(authored by kstoimenov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112732

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
  llvm/test/Other/new-pm-print-pipeline.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -340,19 +340,16 @@
   PB.registerPipelineParsingCallback(
   [](StringRef Name, ModulePassManager &MPM,
  ArrayRef) {
-AddressSanitizerOptions Opts;
 if (Name == "asan-pipeline") {
   MPM.addPass(
   RequireAnalysisPass());
-  MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
   MPM.addPass(ModuleAddressSanitizerPass());
   return true;
 } else if (Name == "asan-function-pipeline") {
+  // FIXME: now this is the same as asan-pipeline and can me removed.
   MPM.addPass(
   RequireAnalysisPass());
-  MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
+  MPM.addPass(ModuleAddressSanitizerPass());
   return true;
 }
 return false;
Index: llvm/test/Other/new-pm-print-pipeline.ll
===
--- llvm/test/Other/new-pm-print-pipeline.ll
+++ llvm/test/Other/new-pm-print-pipeline.ll
@@ -46,8 +46,8 @@
 ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(hwasan<>,hwasan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-14
 ; CHECK-14: hwasan<>,hwasan
 
-; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(asan<>,asan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-15
-; CHECK-15: function(asan<>,asan)
+; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(asan<>,asan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-15
+; CHECK-15: asan<>,asan
 
 ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(loop-extract<>,loop-extract)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-16
 ; CHECK-16: loop-extract<>,loop-extract
Index: llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
@@ -2,7 +2,7 @@
 ; Make sure asan does not instrument __sancov_gen_
 
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
-; RUN: opt < %s -passes='module(require,sancov-module,asan-module),function(asan)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
+; RUN: opt < %s -passes='module(require,sancov-module,asan)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 $Foo = comdat any
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1295,17 +1295,28 @@
 
 ModuleAddressSanitizerPass::ModuleAddressSanitizerPass(
 bool CompileKernel, bool Recover, bool UseGlobalGC, bool UseOdrIndicator,
-AsanDtorKind DestructorKind)
+AsanDtorKind DestructorKind, bool UseAfterScope,
+AsanDetectStackUseAfterReturnMode UseAfterReturn)
 : CompileKernel(CompileKernel), Recover(Recover), UseGlobalGC(UseGlobalGC),
-  UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {}
+  UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind),
+  UseAfterScope(UseAfterScope), UseAfterReturn(UseAfterReturn) {}
 
 PreservedAnalyses ModuleAddressSanitizerPass::run(Module &M,
-  AnalysisManager &AM) {
-  GlobalsMetadata &GlobalsMD = AM.getResult(M);
-  ModuleAddressSanitizer Sanitizer(M, &GlobalsMD, CompileKernel, Recover,
-   UseGlobalGC, UseOdrIndicator,
-   DestructorKind);
-  if (Sanitizer.instrumentModule(M))
+

[PATCH] D113049: [AIX] Disable tests that fail because of no 64-bit XCOFF object file support

2021-11-03 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan updated this revision to Diff 384521.
Jake-Egan added a comment.

Updated patch to XFAIL only on 64-bit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113049

Files:
  clang/test/ASTMerge/anonymous-fields/test.cpp
  clang/test/ASTMerge/codegen-body/test.c
  clang/test/ASTMerge/injected-class-name-decl/test.cpp
  clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
  clang/test/ClangScanDeps/modules-pch-common-submodule.c
  clang/test/ClangScanDeps/modules-pch-common-via-submodule.c
  clang/test/ClangScanDeps/modules-pch.c
  clang/test/ClangScanDeps/resource_directory.c
  clang/test/CodeGenCXX/crash.cpp
  clang/test/CodeGenCXX/ubsan-coroutines.cpp
  clang/test/Driver/as-version.s
  clang/test/Driver/cc-print-proc-stat.c
  clang/test/Driver/compilation_database.c
  clang/test/Driver/modules-ts.cpp
  clang/test/Driver/report-stat.c
  clang/test/Misc/clear-ast-before-backend.c
  clang/test/Misc/time-passes.c
  clang/test/Modules/DebugInfoSubmodules.c
  clang/test/Modules/lsv-debuginfo.cpp
  clang/test/Modules/odr_hash-Friend.cpp
  clang/test/Modules/path-resolution.modulemap
  clang/test/Modules/self-referencing-lambda.cpp
  clang/test/PCH/debug-info-pch-container-path.c
  clang/test/PCH/debug-info-pch-path.c
  clang/test/PCH/pch-hdrstop-warn.cpp
  clang/test/PCH/pch-hdrstop.cpp
  clang/test/PCH/pch-no-hdrstop.cpp
  clang/test/PCH/pch-through4.cpp
  clang/test/PCH/pch-through4a.cpp
  llvm/test/CodeGen/X86/dbg-distringtype-uint.ll
  llvm/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll
  llvm/test/DebugInfo/Generic/2010-05-10-MultipleCU.ll
  llvm/test/DebugInfo/Generic/DICommonBlock.ll
  llvm/test/DebugInfo/Generic/PR20038.ll
  llvm/test/DebugInfo/Generic/constant-pointers.ll
  llvm/test/DebugInfo/Generic/containing-type-extension.ll
  llvm/test/DebugInfo/Generic/cross-cu-inlining.ll
  llvm/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll
  llvm/test/DebugInfo/Generic/cross-cu-linkonce.ll
  llvm/test/DebugInfo/Generic/cu-range-hole.ll
  llvm/test/DebugInfo/Generic/cu-ranges.ll
  llvm/test/DebugInfo/Generic/dead-argument-order.ll
  llvm/test/DebugInfo/Generic/debug-info-enum.ll
  llvm/test/DebugInfo/Generic/debug-info-qualifiers.ll
  llvm/test/DebugInfo/Generic/debug-label-inline.ll
  llvm/test/DebugInfo/Generic/debug-label.ll
  llvm/test/DebugInfo/Generic/debug-names-empty-cu.ll
  llvm/test/DebugInfo/Generic/def-line.ll
  llvm/test/DebugInfo/Generic/discriminated-union.ll
  llvm/test/DebugInfo/Generic/discriminator.ll
  llvm/test/DebugInfo/Generic/disubrange_vla.ll
  llvm/test/DebugInfo/Generic/disubrange_vla_no_dbgvalue.ll
  llvm/test/DebugInfo/Generic/dwarf-public-names.ll
  llvm/test/DebugInfo/Generic/empty.ll
  llvm/test/DebugInfo/Generic/enum.ll
  llvm/test/DebugInfo/Generic/fortran-subprogram-attr.ll
  llvm/test/DebugInfo/Generic/global.ll
  llvm/test/DebugInfo/Generic/gmlt.test
  llvm/test/DebugInfo/Generic/gmlt_profiling.ll
  llvm/test/DebugInfo/Generic/imported-name-inlined.ll
  llvm/test/DebugInfo/Generic/incorrect-variable-debugloc.ll
  llvm/test/DebugInfo/Generic/inline-scopes.ll
  llvm/test/DebugInfo/Generic/inlined-arguments.ll
  llvm/test/DebugInfo/Generic/inlined-strings.ll
  llvm/test/DebugInfo/Generic/linkage-name-abstract.ll
  llvm/test/DebugInfo/Generic/lto-comp-dir.ll
  llvm/test/DebugInfo/Generic/mainsubprogram.ll
  llvm/test/DebugInfo/Generic/member-order.ll
  llvm/test/DebugInfo/Generic/member-pointers.ll
  llvm/test/DebugInfo/Generic/namespace_function_definition.ll
  llvm/test/DebugInfo/Generic/namespace_inline_function_definition.ll
  llvm/test/DebugInfo/Generic/no-empty-child-vars.ll
  llvm/test/DebugInfo/Generic/noscopes.ll
  llvm/test/DebugInfo/Generic/pass-by-value.ll
  llvm/test/DebugInfo/Generic/ptrsize.ll
  llvm/test/DebugInfo/Generic/recursive_inlining.ll
  llvm/test/DebugInfo/Generic/skeletoncu.ll
  llvm/test/DebugInfo/Generic/sugared-constants.ll
  llvm/test/DebugInfo/Generic/template-recursive-void.ll
  llvm/test/DebugInfo/Generic/thrownTypes.ll
  llvm/test/DebugInfo/Generic/two-cus-from-same-file.ll
  llvm/test/DebugInfo/Generic/typedef.ll
  llvm/test/DebugInfo/Generic/unconditional-branch.ll
  llvm/test/DebugInfo/Generic/univariant-discriminated-union.ll
  llvm/test/DebugInfo/Generic/version.ll
  llvm/test/DebugInfo/Generic/virtual-index.ll
  llvm/test/DebugInfo/X86/dwarfdump-generic_subrange.ll
  llvm/test/DebugInfo/X86/dwarfdump-generic_subrange_const.ll
  llvm/test/DebugInfo/X86/dwarfdump-generic_subrange_count.ll
  llvm/test/DebugInfo/X86/dwarfdump-rankConst.ll
  llvm/test/DebugInfo/X86/dwarfdump-rankExp.ll
  llvm/test/DebugInfo/X86/dwarfdump-signed_const.ll
  llvm/test/DebugInfo/X86/global-constants.ll
  llvm/test/DebugInfo/X86/invalid-global-constants.ll
  llvm/test/DebugInfo/cross-cu-scope.ll
  llvm/test/DebugInfo/dwo.ll
  llvm/test/DebugInfo/omit-empty.ll
  llvm/test/DebugInfo/skeletoncu.ll
  llvm/test/LTO/X86/bcsection.ll
  llvm/test/LTO/X86/remangle_intrins

[PATCH] D113129: Revert "[ASan] Process functions in Asan module pass"

2021-11-03 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov created this revision.
Herald added subscribers: ormris, hiraditya.
kstoimenov requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This reverts commit 76ea87b94e5cba335d691e4e18e3464ad45c8b52 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113129

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
  llvm/test/Other/new-pm-print-pipeline.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -340,16 +340,19 @@
   PB.registerPipelineParsingCallback(
   [](StringRef Name, ModulePassManager &MPM,
  ArrayRef) {
+AddressSanitizerOptions Opts;
 if (Name == "asan-pipeline") {
   MPM.addPass(
   RequireAnalysisPass());
+  MPM.addPass(
+  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
   MPM.addPass(ModuleAddressSanitizerPass());
   return true;
 } else if (Name == "asan-function-pipeline") {
-  // FIXME: now this is the same as asan-pipeline and can me removed.
   MPM.addPass(
   RequireAnalysisPass());
-  MPM.addPass(ModuleAddressSanitizerPass());
+  MPM.addPass(
+  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
   return true;
 }
 return false;
Index: llvm/test/Other/new-pm-print-pipeline.ll
===
--- llvm/test/Other/new-pm-print-pipeline.ll
+++ llvm/test/Other/new-pm-print-pipeline.ll
@@ -46,8 +46,8 @@
 ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(hwasan<>,hwasan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-14
 ; CHECK-14: hwasan<>,hwasan
 
-; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(asan<>,asan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-15
-; CHECK-15: asan<>,asan
+; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(asan<>,asan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-15
+; CHECK-15: function(asan<>,asan)
 
 ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(loop-extract<>,loop-extract)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-16
 ; CHECK-16: loop-extract<>,loop-extract
Index: llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
@@ -2,7 +2,7 @@
 ; Make sure asan does not instrument __sancov_gen_
 
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
-; RUN: opt < %s -passes='module(require,sancov-module,asan)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
+; RUN: opt < %s -passes='module(require,sancov-module,asan-module),function(asan)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 $Foo = comdat any
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1295,28 +1295,17 @@
 
 ModuleAddressSanitizerPass::ModuleAddressSanitizerPass(
 bool CompileKernel, bool Recover, bool UseGlobalGC, bool UseOdrIndicator,
-AsanDtorKind DestructorKind, bool UseAfterScope,
-AsanDetectStackUseAfterReturnMode UseAfterReturn)
+AsanDtorKind DestructorKind)
 : CompileKernel(CompileKernel), Recover(Recover), UseGlobalGC(UseGlobalGC),
-  UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind),
-  UseAfterScope(UseAfterScope), UseAfterReturn(UseAfterReturn) {}
+  UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {}
 
 PreservedAnalyses ModuleAddressSanitizerPass::run(Module &M,
-  ModuleAnalysisManager &MAM) {
-  GlobalsMetadata &GlobalsMD = MAM.getResult(M);
-  ModuleAddressSanitizer ModuleSanitizer(M, &GlobalsMD, CompileKernel, Recover,
- UseGlobalGC, UseOdrIndicator,
- Des

[clang] b314532 - Revert "[ASan] Process functions in Asan module pass"

2021-11-03 Thread Kirill Stoimenov via cfe-commits

Author: Kirill Stoimenov
Date: 2021-11-03T18:01:01Z
New Revision: b3145323b549eea95b3b088cb2064bf0bf81cfe6

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

LOG: Revert "[ASan] Process functions in Asan module pass"

This reverts commit 76ea87b94e5cba335d691e4e18e3464ad45c8b52.

Reviewed By: kstoimenov

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
llvm/test/Other/new-pm-print-pipeline.ll
llvm/tools/opt/NewPMDriver.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index cca6eb44938ca..534d98be4344a 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1185,9 +1185,11 @@ static void addSanitizers(const Triple &TargetTriple,
 llvm::AsanDetectStackUseAfterReturnMode UseAfterReturn =
 CodeGenOpts.getSanitizeAddressUseAfterReturn();
 MPM.addPass(RequireAnalysisPass());
-MPM.addPass(ModuleAddressSanitizerPass(
-CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,
-DestructorKind, UseAfterScope, UseAfterReturn));
+MPM.addPass(ModuleAddressSanitizerPass(CompileKernel, Recover,
+   UseGlobalGC, UseOdrIndicator,
+   DestructorKind));
+MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(
+{CompileKernel, Recover, UseAfterScope, UseAfterReturn})));
   }
 };
 ASanPass(SanitizerKind::Address, false);

diff  --git a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h 
b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
index fb65c59408466..ea18974798570 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
@@ -128,10 +128,7 @@ class ModuleAddressSanitizerPass
   explicit ModuleAddressSanitizerPass(
   bool CompileKernel = false, bool Recover = false, bool UseGlobalGC = 
true,
   bool UseOdrIndicator = false,
-  AsanDtorKind DestructorKind = AsanDtorKind::Global,
-  bool UseAfterScope = false,
-  AsanDetectStackUseAfterReturnMode UseAfterReturn =
-  AsanDetectStackUseAfterReturnMode::Runtime);
+  AsanDtorKind DestructorKind = AsanDtorKind::Global);
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
   void printPipeline(raw_ostream &OS,
  function_ref MapClassName2PassName);
@@ -143,8 +140,6 @@ class ModuleAddressSanitizerPass
   bool UseGlobalGC;
   bool UseOdrIndicator;
   AsanDtorKind DestructorKind;
-  bool UseAfterScope;
-  AsanDetectStackUseAfterReturnMode UseAfterReturn;
 };
 
 // Insert AddressSanitizer (address sanity checking) instrumentation

diff  --git a/llvm/lib/Passes/PassRegistry.def 
b/llvm/lib/Passes/PassRegistry.def
index 58966d3e715d3..655c472878a00 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -136,7 +136,7 @@ MODULE_PASS_WITH_PARAMS("hwasan",
 },
 parseHWASanPassOptions,
 "kernel;recover")
-MODULE_PASS_WITH_PARAMS("asan",
+MODULE_PASS_WITH_PARAMS("asan-module",
 "ModuleAddressSanitizerPass",
 [](bool CompileKernel) {
   return ModuleAddressSanitizerPass(CompileKernel,
@@ -393,6 +393,13 @@ FUNCTION_PASS_WITH_PARAMS("loop-unroll",
   "no-profile-peeling;profile-peeling;"
   "no-runtime;runtime;"
   "no-upperbound;upperbound")
+FUNCTION_PASS_WITH_PARAMS("asan",
+  "AddressSanitizerPass",
+   [](AddressSanitizerOptions Opts) {
+ return AddressSanitizerPass(Opts);
+   },
+  parseASanPassOptions,
+  "kernel")
 FUNCTION_PASS_WITH_PARAMS("msan",
   "MemorySanitizerPass",
[](MemorySanitizerOptions Opts) {

diff  --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 9cd63574d266d..5563fc14d151b 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1295,28 +1295,17 @@ void ModuleAddressSanitizerPass

[PATCH] D113129: Revert "[ASan] Process functions in Asan module pass"

2021-11-03 Thread Kirill Stoimenov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb3145323b549: Revert "[ASan] Process functions in Asan 
module pass" (authored by kstoimenov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113129

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
  llvm/test/Other/new-pm-print-pipeline.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -340,16 +340,19 @@
   PB.registerPipelineParsingCallback(
   [](StringRef Name, ModulePassManager &MPM,
  ArrayRef) {
+AddressSanitizerOptions Opts;
 if (Name == "asan-pipeline") {
   MPM.addPass(
   RequireAnalysisPass());
+  MPM.addPass(
+  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
   MPM.addPass(ModuleAddressSanitizerPass());
   return true;
 } else if (Name == "asan-function-pipeline") {
-  // FIXME: now this is the same as asan-pipeline and can me removed.
   MPM.addPass(
   RequireAnalysisPass());
-  MPM.addPass(ModuleAddressSanitizerPass());
+  MPM.addPass(
+  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
   return true;
 }
 return false;
Index: llvm/test/Other/new-pm-print-pipeline.ll
===
--- llvm/test/Other/new-pm-print-pipeline.ll
+++ llvm/test/Other/new-pm-print-pipeline.ll
@@ -46,8 +46,8 @@
 ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(hwasan<>,hwasan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-14
 ; CHECK-14: hwasan<>,hwasan
 
-; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(asan<>,asan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-15
-; CHECK-15: asan<>,asan
+; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(asan<>,asan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-15
+; CHECK-15: function(asan<>,asan)
 
 ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(loop-extract<>,loop-extract)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-16
 ; CHECK-16: loop-extract<>,loop-extract
Index: llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
@@ -2,7 +2,7 @@
 ; Make sure asan does not instrument __sancov_gen_
 
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
-; RUN: opt < %s -passes='module(require,sancov-module,asan)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
+; RUN: opt < %s -passes='module(require,sancov-module,asan-module),function(asan)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 $Foo = comdat any
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1295,28 +1295,17 @@
 
 ModuleAddressSanitizerPass::ModuleAddressSanitizerPass(
 bool CompileKernel, bool Recover, bool UseGlobalGC, bool UseOdrIndicator,
-AsanDtorKind DestructorKind, bool UseAfterScope,
-AsanDetectStackUseAfterReturnMode UseAfterReturn)
+AsanDtorKind DestructorKind)
 : CompileKernel(CompileKernel), Recover(Recover), UseGlobalGC(UseGlobalGC),
-  UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind),
-  UseAfterScope(UseAfterScope), UseAfterReturn(UseAfterReturn) {}
+  UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {}
 
 PreservedAnalyses ModuleAddressSanitizerPass::run(Module &M,
-  ModuleAnalysisManager &MAM) {
-  GlobalsMetadata &GlobalsMD = MAM.getResult(M);
-  ModuleAddressSanitizer ModuleSanitizer(M, &GlobalsMD, CompileKernel, Recover,
- UseGlobalGC, UseOdrIndicator,
- DestructorKind);
-  bool Modified = false

[PATCH] D112732: [ASan] Process functions in Asan module pass

2021-11-03 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1189
+MPM.addPass(ModuleAddressSanitizerPass(
+CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,
+DestructorKind, UseAfterScope, UseAfterReturn));

I'm seeing build errors here, and I'm not sure what this is supposed to be?

```
/home/rupprecht/src/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1189:37: 
error: use of undeclared identifier 'ModuleUseAfterScope'; did you mean 
'UseAfterScope'?
CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,
^~~
UseAfterScope
```

https://buildkite.com/llvm-project/upstream-bazel-rbe/builds/11193#bbebbf99-a2c1-4959-b6f7-f7fb816591c0


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112732

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


[PATCH] D112732: [ASan] Process functions in Asan module pass

2021-11-03 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1189
+MPM.addPass(ModuleAddressSanitizerPass(
+CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,
+DestructorKind, UseAfterScope, UseAfterReturn));

rupprecht wrote:
> I'm seeing build errors here, and I'm not sure what this is supposed to be?
> 
> ```
> /home/rupprecht/src/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1189:37: 
> error: use of undeclared identifier 'ModuleUseAfterScope'; did you mean 
> 'UseAfterScope'?
> CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,
> ^~~
> UseAfterScope
> ```
> 
> https://buildkite.com/llvm-project/upstream-bazel-rbe/builds/11193#bbebbf99-a2c1-4959-b6f7-f7fb816591c0
I see it was reverted already, sorry!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112732

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


[PATCH] D112732: [ASan] Process functions in Asan module pass

2021-11-03 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1189
+MPM.addPass(ModuleAddressSanitizerPass(
+CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,
+DestructorKind, UseAfterScope, UseAfterReturn));

rupprecht wrote:
> rupprecht wrote:
> > I'm seeing build errors here, and I'm not sure what this is supposed to be?
> > 
> > ```
> > /home/rupprecht/src/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1189:37: 
> > error: use of undeclared identifier 'ModuleUseAfterScope'; did you mean 
> > 'UseAfterScope'?
> > CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,
> > ^~~
> > UseAfterScope
> > ```
> > 
> > https://buildkite.com/llvm-project/upstream-bazel-rbe/builds/11193#bbebbf99-a2c1-4959-b6f7-f7fb816591c0
> I see it was reverted already, sorry!
Sorry about breaking the build. I can't understand how my local tests passed. 
Functions with a long list of boolean params are so error prone. The downside 
of not using the builder pattern :-( 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112732

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


[PATCH] D113131: [ASan] Process functions in Asan module pass.

2021-11-03 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov created this revision.
kstoimenov added a reviewer: vitalybuka.
Herald added subscribers: ormris, hiraditya.
kstoimenov requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Re-land of D112732  with fixes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113131

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
  llvm/test/Other/new-pm-print-pipeline.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -340,19 +340,16 @@
   PB.registerPipelineParsingCallback(
   [](StringRef Name, ModulePassManager &MPM,
  ArrayRef) {
-AddressSanitizerOptions Opts;
 if (Name == "asan-pipeline") {
   MPM.addPass(
   RequireAnalysisPass());
-  MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
   MPM.addPass(ModuleAddressSanitizerPass());
   return true;
 } else if (Name == "asan-function-pipeline") {
+  // FIXME: now this is the same as asan-pipeline and can me removed.
   MPM.addPass(
   RequireAnalysisPass());
-  MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
+  MPM.addPass(ModuleAddressSanitizerPass());
   return true;
 }
 return false;
Index: llvm/test/Other/new-pm-print-pipeline.ll
===
--- llvm/test/Other/new-pm-print-pipeline.ll
+++ llvm/test/Other/new-pm-print-pipeline.ll
@@ -46,8 +46,8 @@
 ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(hwasan<>,hwasan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-14
 ; CHECK-14: hwasan<>,hwasan
 
-; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(asan<>,asan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-15
-; CHECK-15: function(asan<>,asan)
+; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(asan<>,asan)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-15
+; CHECK-15: asan<>,asan
 
 ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(loop-extract<>,loop-extract)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-16
 ; CHECK-16: loop-extract<>,loop-extract
Index: llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
@@ -2,7 +2,7 @@
 ; Make sure asan does not instrument __sancov_gen_
 
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
-; RUN: opt < %s -passes='module(require,sancov-module,asan-module),function(asan)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
+; RUN: opt < %s -passes='module(require,sancov-module,asan)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 $Foo = comdat any
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1295,17 +1295,28 @@
 
 ModuleAddressSanitizerPass::ModuleAddressSanitizerPass(
 bool CompileKernel, bool Recover, bool UseGlobalGC, bool UseOdrIndicator,
-AsanDtorKind DestructorKind)
+AsanDtorKind DestructorKind, bool UseAfterScope,
+AsanDetectStackUseAfterReturnMode UseAfterReturn)
 : CompileKernel(CompileKernel), Recover(Recover), UseGlobalGC(UseGlobalGC),
-  UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {}
+  UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind),
+  UseAfterScope(UseAfterScope), UseAfterReturn(UseAfterReturn) {}
 
 PreservedAnalyses ModuleAddressSanitizerPass::run(Module &M,
-  AnalysisManager &AM) {
-  GlobalsMetadata &GlobalsMD = AM.getResult(M);
-  ModuleAddressSanitizer Sanitizer(M, &GlobalsMD, CompileKernel, Recover,
-   UseGlobalGC, UseOdrIndicator,
-   DestructorKind);
-  if (Sanitizer.instrumentModule(M))

[PATCH] D112041: [InferAddressSpaces] Support assumed addrspaces from addrspace predicates.

2021-11-03 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 384535.
hliao added a comment.

Updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112041

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/AssumptionCache.h
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/Target/TargetMachine.h
  llvm/lib/Analysis/AssumptionCache.cpp
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
  llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
  llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Transforms/InferAddressSpaces/AMDGPU/builtin-assumed-addrspace.ll
  llvm/test/Transforms/InferAddressSpaces/NVPTX/builtin-assumed-addrspace.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp

Index: llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
===
--- llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
+++ llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
@@ -518,8 +518,7 @@
   BasicBlock::iterator First = F->begin()->begin();
   BasicBlock::iterator Second = F->begin()->begin();
   Second++;
-  AssumptionCacheTracker ACT;
-  AssumptionCache &AC = ACT.getAssumptionCache(*F);
+  AssumptionCache AC(*F);
   auto AR = AC.assumptionsFor(F->getArg(3));
   ASSERT_EQ(AR.size(), 0u);
   AR = AC.assumptionsFor(F->getArg(1));
Index: llvm/test/Transforms/LoopRotate/pr35210.ll
===
--- llvm/test/Transforms/LoopRotate/pr35210.ll
+++ llvm/test/Transforms/LoopRotate/pr35210.ll
@@ -11,11 +11,11 @@
 ; CHECK-NEXT: Running analysis: LoopAnalysis on f
 ; CHECK-NEXT: Running analysis: DominatorTreeAnalysis on f
 ; CHECK-NEXT: Running analysis: AssumptionAnalysis on f
+; CHECK-NEXT: Running analysis: TargetIRAnalysis on f
 ; CHECK-NEXT: Running pass: LCSSAPass on f
 ; CHECK-NEXT: Running analysis: AAManager on f
 ; CHECK-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; CHECK-NEXT: Running analysis: ScalarEvolutionAnalysis on f
-; CHECK-NEXT: Running analysis: TargetIRAnalysis on f
 ; CHECK-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f
 ; CHECK-NEXT: Running pass: LoopRotatePass on Loop at depth 1 containing: %bb,%bb4
 ; CHECK-NEXT: Folding loop latch bb4 into bb
@@ -29,12 +29,12 @@
 ; MSSA-NEXT: Running analysis: LoopAnalysis on f
 ; MSSA-NEXT: Running analysis: DominatorTreeAnalysis on f
 ; MSSA-NEXT: Running analysis: AssumptionAnalysis on f
+; MSSA-NEXT: Running analysis: TargetIRAnalysis on f
 ; MSSA-NEXT: Running pass: LCSSAPass on f
 ; MSSA-NEXT: Running analysis: MemorySSAAnalysis on f
 ; MSSA-NEXT: Running analysis: AAManager on f
 ; MSSA-NEXT: Running analysis: TargetLibraryAnalysis on f
 ; MSSA-NEXT: Running analysis: ScalarEvolutionAnalysis on f
-; MSSA-NEXT: Running analysis: TargetIRAnalysis on f
 ; MSSA-NEXT: Running analysis: InnerAnalysisManagerProxy{{.*}} on f
 ; MSSA-NEXT: Running pass: LoopRotatePass on Loop at depth 1 containing: %bb,%bb4
 ; MSSA-NEXT: Folding loop latch bb4 into bb
Index: llvm/test/Transforms/InferAddressSpaces/NVPTX/builtin-assumed-addrspace.ll
===
--- /dev/null
+++ llvm/test/Transforms/InferAddressSpaces/NVPTX/builtin-assumed-addrspace.ll
@@ -0,0 +1,107 @@
+; RUN: opt -S -mtriple=nvptx64-nvidia-cuda -infer-address-spaces -o - %s | FileCheck %s
+
+; CHECK-LABEL: @f0
+; CHECK: addrspacecast float* {{%.*}} to float addrspace(4)*
+; CHECK: getelementptr inbounds float, float addrspace(4)*
+; CHECK: load float, float addrspace(4)*
+define float @f0(float* %p) {
+entry:
+  %0 = bitcast float* %p to i8*
+  %1 = call i1 @llvm.nvvm.isspacep.const(i8* %0)
+  tail call void @llvm.assume(i1 %1)
+  %2 = tail call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  %idxprom = zext i32 %2 to i64
+  %arrayidx = getelementptr inbounds float, float* %p, i64 %idxprom
+  %3 = load float, float* %arrayidx, align 4
+  ret float %3
+}
+
+; CHECK-LABEL: @f1
+; CHECK: addrspacecast float* {{%.*}} to float addrspace(1)*
+; CHECK: getelementptr inbounds float, float addrspace(1)*
+; CHECK: load float, float addrspace(1)*
+define float @f1(float* %p) {
+entry:
+  %0 = bitcast float* %p to i8*
+  %1 = call i1 @llvm.nvvm.isspacep.global(i8* %0)
+  tail call void @llvm.assume(i1 %1)
+  %2 = tail call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  %idxprom = zext i32 %2 to i64
+  %arrayidx = getelementptr inbounds float, float* %p, i64 %idxprom
+  %3 = load float, 

[clang] 3131714 - [NFC][asan] Use AddressSanitizerOptions in ModuleAddressSanitizerPass

2021-11-03 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2021-11-03T11:32:14-07:00
New Revision: 3131714f8daca338492a7d5b189e4d63131bc808

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

LOG: [NFC][asan] Use AddressSanitizerOptions in ModuleAddressSanitizerPass

Reviewed By: kstoimenov

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/tools/opt/NewPMDriver.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 534d98be4344a..64f972fe11a52 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1176,20 +1176,20 @@ static void addSanitizers(const Triple &TargetTriple,
 
 auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
   if (LangOpts.Sanitize.has(Mask)) {
-bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
-bool UseAfterScope = CodeGenOpts.SanitizeAddressUseAfterScope;
 bool UseGlobalGC = asanUseGlobalsGC(TargetTriple, CodeGenOpts);
 bool UseOdrIndicator = CodeGenOpts.SanitizeAddressUseOdrIndicator;
 llvm::AsanDtorKind DestructorKind =
 CodeGenOpts.getSanitizeAddressDtor();
-llvm::AsanDetectStackUseAfterReturnMode UseAfterReturn =
-CodeGenOpts.getSanitizeAddressUseAfterReturn();
+AddressSanitizerOptions Opts;
+Opts.CompileKernel = CompileKernel;
+Opts.Recover = CodeGenOpts.SanitizeRecover.has(Mask);
+Opts.UseAfterScope = CodeGenOpts.SanitizeAddressUseAfterScope;
+Opts.UseAfterReturn = CodeGenOpts.getSanitizeAddressUseAfterReturn();
 MPM.addPass(RequireAnalysisPass());
-MPM.addPass(ModuleAddressSanitizerPass(CompileKernel, Recover,
-   UseGlobalGC, UseOdrIndicator,
-   DestructorKind));
-MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(
-{CompileKernel, Recover, UseAfterScope, UseAfterReturn})));
+MPM.addPass(ModuleAddressSanitizerPass(
+Opts, UseGlobalGC, UseOdrIndicator, DestructorKind));
+MPM.addPass(
+createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
   }
 };
 ASanPass(SanitizerKind::Address, false);

diff  --git a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h 
b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
index ea18974798570..c13407a440913 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
@@ -106,7 +106,7 @@ struct AddressSanitizerOptions {
 /// surrounding requested memory to be checked for invalid accesses.
 class AddressSanitizerPass : public PassInfoMixin {
 public:
-  explicit AddressSanitizerPass(AddressSanitizerOptions Options)
+  AddressSanitizerPass(const AddressSanitizerOptions &Options)
   : Options(Options){};
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
   void printPipeline(raw_ostream &OS,
@@ -125,8 +125,8 @@ class AddressSanitizerPass : public 
PassInfoMixin {
 class ModuleAddressSanitizerPass
 : public PassInfoMixin {
 public:
-  explicit ModuleAddressSanitizerPass(
-  bool CompileKernel = false, bool Recover = false, bool UseGlobalGC = 
true,
+  ModuleAddressSanitizerPass(
+  const AddressSanitizerOptions &Options, bool UseGlobalGC = true,
   bool UseOdrIndicator = false,
   AsanDtorKind DestructorKind = AsanDtorKind::Global);
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
@@ -135,8 +135,7 @@ class ModuleAddressSanitizerPass
   static bool isRequired() { return true; }
 
 private:
-  bool CompileKernel;
-  bool Recover;
+  AddressSanitizerOptions Options;
   bool UseGlobalGC;
   bool UseOdrIndicator;
   AsanDtorKind DestructorKind;

diff  --git a/llvm/lib/Passes/PassRegistry.def 
b/llvm/lib/Passes/PassRegistry.def
index 655c472878a00..80ec9f839fd25 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -138,12 +138,10 @@ MODULE_PASS_WITH_PARAMS("hwasan",
 "kernel;recover")
 MODULE_PASS_WITH_PARAMS("asan-module",
 "ModuleAddressSanitizerPass",
-[](bool CompileKernel) {
-  return ModuleAddressSanitizerPass(CompileKernel,
-false, true,
-false);
+[](AddressSanitizerOpt

[PATCH] D113072: [NFC][asan] Use AddressSanitizerOptions in ModuleAddressSanitizerPass

2021-11-03 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3131714f8dac: [NFC][asan] Use AddressSanitizerOptions in 
ModuleAddressSanitizerPass (authored by vitalybuka).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113072

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -346,7 +346,7 @@
   RequireAnalysisPass());
   MPM.addPass(
   createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
-  MPM.addPass(ModuleAddressSanitizerPass());
+  MPM.addPass(ModuleAddressSanitizerPass(Opts));
   return true;
 } else if (Name == "asan-function-pipeline") {
   MPM.addPass(
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1288,23 +1288,23 @@
   static_cast *>(this)->printPipeline(
   OS, MapClassName2PassName);
   OS << "<";
-  if (CompileKernel)
+  if (Options.CompileKernel)
 OS << "kernel";
   OS << ">";
 }
 
 ModuleAddressSanitizerPass::ModuleAddressSanitizerPass(
-bool CompileKernel, bool Recover, bool UseGlobalGC, bool UseOdrIndicator,
-AsanDtorKind DestructorKind)
-: CompileKernel(CompileKernel), Recover(Recover), UseGlobalGC(UseGlobalGC),
+const AddressSanitizerOptions &Options, bool UseGlobalGC,
+bool UseOdrIndicator, AsanDtorKind DestructorKind)
+: Options(Options), UseGlobalGC(UseGlobalGC),
   UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {}
 
 PreservedAnalyses ModuleAddressSanitizerPass::run(Module &M,
   AnalysisManager &AM) {
   GlobalsMetadata &GlobalsMD = AM.getResult(M);
-  ModuleAddressSanitizer Sanitizer(M, &GlobalsMD, CompileKernel, Recover,
-   UseGlobalGC, UseOdrIndicator,
-   DestructorKind);
+  ModuleAddressSanitizer Sanitizer(M, &GlobalsMD, Options.CompileKernel,
+   Options.Recover, UseGlobalGC,
+   UseOdrIndicator, DestructorKind);
   if (Sanitizer.instrumentModule(M))
 return PreservedAnalyses::none();
   return PreservedAnalyses::all();
Index: llvm/lib/Passes/PassRegistry.def
===
--- llvm/lib/Passes/PassRegistry.def
+++ llvm/lib/Passes/PassRegistry.def
@@ -138,12 +138,10 @@
 "kernel;recover")
 MODULE_PASS_WITH_PARAMS("asan-module",
 "ModuleAddressSanitizerPass",
-[](bool CompileKernel) {
-  return ModuleAddressSanitizerPass(CompileKernel,
-false, true,
-false);
+[](AddressSanitizerOptions Opts) {
+  return ModuleAddressSanitizerPass(Opts);
 },
-parseModuleAddressSanitizerPassOptions,
+parseASanPassOptions,
 "kernel")
 #undef MODULE_PASS_WITH_PARAMS
 
Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
===
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
@@ -106,7 +106,7 @@
 /// surrounding requested memory to be checked for invalid accesses.
 class AddressSanitizerPass : public PassInfoMixin {
 public:
-  explicit AddressSanitizerPass(AddressSanitizerOptions Options)
+  AddressSanitizerPass(const AddressSanitizerOptions &Options)
   : Options(Options){};
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
   void printPipeline(raw_ostream &OS,
@@ -125,8 +125,8 @@
 class ModuleAddressSanitizerPass
 : public PassInfoMixin {
 public:
-  explicit ModuleAddressSanitizerPass(
-  bool CompileKernel = false, bool Recover = false, bool UseGlobalGC = true,
+  ModuleAddressSanitizerPass(
+  const AddressSanitizerOptions &Options, bool UseGlobalGC = true,
   bool UseOdrIndicator = false,
   AsanDtorKind DestructorKind = AsanDtorKind::Global);
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
@@ -135,8 +135,7 @@
   static bool isRequired() { return true; }
 
 private:
-  bool

[PATCH] D112041: [InferAddressSpaces] Support assumed addrspaces from addrspace predicates.

2021-11-03 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

I'd still like an answer to:

In D112041#3073464 , @nikic wrote:

> Is it actually necessary to thread this through AssumptionCache, given how 
> InferAddressSpaces is the only place that looks at these assumes?

I'd prefer not to infect AC with TTI if not necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112041

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


[PATCH] D112732: [ASan] Process functions in Asan module pass

2021-11-03 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 384539.
vitalybuka added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112732

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
  llvm/tools/opt/NewPMDriver.cpp


Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -344,8 +344,6 @@
 if (Name == "asan-pipeline") {
   MPM.addPass(
   RequireAnalysisPass());
-  MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
   MPM.addPass(ModuleAddressSanitizerPass(Opts));
   return true;
 } else if (Name == "asan-function-pipeline") {
Index: llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
@@ -2,7 +2,7 @@
 ; Make sure asan does not instrument __sancov_gen_
 
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 
-sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
-; RUN: opt < %s 
-passes='module(require,sancov-module,asan-module),function(asan)'
 -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | 
FileCheck %s
+; RUN: opt < %s 
-passes='module(require,sancov-module,asan-module)' 
-sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck 
%s
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 $Foo = comdat any
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1300,14 +1300,22 @@
   UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {}
 
 PreservedAnalyses ModuleAddressSanitizerPass::run(Module &M,
-  AnalysisManager &AM) 
{
-  GlobalsMetadata &GlobalsMD = AM.getResult(M);
-  ModuleAddressSanitizer Sanitizer(M, &GlobalsMD, Options.CompileKernel,
-   Options.Recover, UseGlobalGC,
-   UseOdrIndicator, DestructorKind);
-  if (Sanitizer.instrumentModule(M))
-return PreservedAnalyses::none();
-  return PreservedAnalyses::all();
+  ModuleAnalysisManager &MAM) {
+  GlobalsMetadata &GlobalsMD = MAM.getResult(M);
+  ModuleAddressSanitizer ModuleSanitizer(M, &GlobalsMD, Options.CompileKernel,
+ Options.Recover, UseGlobalGC,
+ UseOdrIndicator, DestructorKind);
+  bool Modified = false;
+  auto &FAM = 
MAM.getResult(M).getManager();
+  for (Function &F : M) {
+AddressSanitizer FunctionSanitizer(M, &GlobalsMD, Options.CompileKernel,
+   Options.Recover, Options.UseAfterScope,
+   Options.UseAfterReturn);
+const TargetLibraryInfo &TLI = FAM.getResult(F);
+Modified |= FunctionSanitizer.instrumentFunction(F, &TLI);
+  }
+  Modified |= ModuleSanitizer.instrumentModule(M);
+  return Modified ? PreservedAnalyses::none() : PreservedAnalyses::all();
 }
 
 INITIALIZE_PASS(ASanGlobalsMetadataWrapperPass, "asan-globals-md",
@@ -2841,6 +2849,8 @@
 
 bool AddressSanitizer::instrumentFunction(Function &F,
   const TargetLibraryInfo *TLI) {
+  if (F.empty())
+return false;
   if (F.getLinkage() == GlobalValue::AvailableExternallyLinkage) return false;
   if (!ClDebugFunc.empty() && ClDebugFunc == F.getName()) return false;
   if (F.getName().startswith("__asan_")) return false;
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -580,10 +580,6 @@
   return parseSinglePassOption(Params, "minimal", "LowerMatrixIntrinsics");
 }
 
-Expected parseModuleAddressSanitizerPassOptions(StringRef Params) {
-  return parseSinglePassOption(Params, "kernel", "ModuleAddressSanitizer");
-}
-
 Expected parseASanPassOptions(StringRef Params) {
   AddressSanitizerOptions Result;
   while (!Params.empty()) {
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1188,8 +1188,6 @@
 MPM.addPass(RequireAnalysisPass());
  

[PATCH] D112041: [InferAddressSpaces] Support assumed addrspaces from addrspace predicates.

2021-11-03 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D112041#3106936 , @nikic wrote:

> I'd still like an answer to:
>
> In D112041#3073464 , @nikic wrote:
>
>> Is it actually necessary to thread this through AssumptionCache, given how 
>> InferAddressSpaces is the only place that looks at these assumes?
>
> I'd prefer not to infect AC with TTI if not necessary.

We need `assume` intrinsic to preserve those predicates through optimizations 
as `infer-addrespace` may run several times. With `assume` used the same way, 
we probably just duplicate the logic in AC if we want to track them inside this 
pass. That's not a good practice though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112041

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


[PATCH] D112732: [ASan] Process functions in Asan module pass

2021-11-03 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 384544.
kstoimenov added a comment.

After merging D113072 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112732

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
  llvm/tools/opt/NewPMDriver.cpp


Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -344,8 +344,6 @@
 if (Name == "asan-pipeline") {
   MPM.addPass(
   RequireAnalysisPass());
-  MPM.addPass(
-  createModuleToFunctionPassAdaptor(AddressSanitizerPass(Opts)));
   MPM.addPass(ModuleAddressSanitizerPass(Opts));
   return true;
 } else if (Name == "asan-function-pipeline") {
Index: llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
@@ -2,7 +2,7 @@
 ; Make sure asan does not instrument __sancov_gen_
 
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 
-sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
-; RUN: opt < %s 
-passes='module(require,sancov-module,asan-module),function(asan)'
 -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | 
FileCheck %s
+; RUN: opt < %s 
-passes='module(require,sancov-module,asan-module)' 
-sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck 
%s
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 $Foo = comdat any
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1300,14 +1300,22 @@
   UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind) {}
 
 PreservedAnalyses ModuleAddressSanitizerPass::run(Module &M,
-  AnalysisManager &AM) 
{
-  GlobalsMetadata &GlobalsMD = AM.getResult(M);
-  ModuleAddressSanitizer Sanitizer(M, &GlobalsMD, Options.CompileKernel,
-   Options.Recover, UseGlobalGC,
-   UseOdrIndicator, DestructorKind);
-  if (Sanitizer.instrumentModule(M))
-return PreservedAnalyses::none();
-  return PreservedAnalyses::all();
+  ModuleAnalysisManager &MAM) {
+  GlobalsMetadata &GlobalsMD = MAM.getResult(M);
+  ModuleAddressSanitizer ModuleSanitizer(M, &GlobalsMD, Options.CompileKernel,
+ Options.Recover, UseGlobalGC,
+ UseOdrIndicator, DestructorKind);
+  bool Modified = false;
+  auto &FAM = 
MAM.getResult(M).getManager();
+  for (Function &F : M) {
+AddressSanitizer FunctionSanitizer(M, &GlobalsMD, Options.CompileKernel,
+   Options.Recover, Options.UseAfterScope,
+   Options.UseAfterReturn);
+const TargetLibraryInfo &TLI = FAM.getResult(F);
+Modified |= FunctionSanitizer.instrumentFunction(F, &TLI);
+  }
+  Modified |= ModuleSanitizer.instrumentModule(M);
+  return Modified ? PreservedAnalyses::none() : PreservedAnalyses::all();
 }
 
 INITIALIZE_PASS(ASanGlobalsMetadataWrapperPass, "asan-globals-md",
@@ -2841,6 +2849,8 @@
 
 bool AddressSanitizer::instrumentFunction(Function &F,
   const TargetLibraryInfo *TLI) {
+  if (F.empty())
+return false;
   if (F.getLinkage() == GlobalValue::AvailableExternallyLinkage) return false;
   if (!ClDebugFunc.empty() && ClDebugFunc == F.getName()) return false;
   if (F.getName().startswith("__asan_")) return false;
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -580,10 +580,6 @@
   return parseSinglePassOption(Params, "minimal", "LowerMatrixIntrinsics");
 }
 
-Expected parseModuleAddressSanitizerPassOptions(StringRef Params) {
-  return parseSinglePassOption(Params, "kernel", "ModuleAddressSanitizer");
-}
-
 Expected parseASanPassOptions(StringRef Params) {
   AddressSanitizerOptions Result;
   while (!Params.empty()) {
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1188,8 +1188,6 @@

[PATCH] D113080: [Support] Improve Caching conformance with Support library behavior

2021-11-03 Thread Noah Shutty via Phabricator via cfe-commits
noajshu updated this revision to Diff 384545.
noajshu added a comment.

Improve error handling in Caching support library.
Most of the functions now return Expected<>, except for the non-trivial 
destructor of CacheStream.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113080

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  lld/COFF/LTO.cpp
  lld/ELF/LTO.cpp
  lld/MachO/LTO.cpp
  lld/wasm/LTO.cpp
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/Support/Caching.h
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Support/Caching.cpp
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp

Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -362,20 +362,20 @@
   if (HasErrors)
 return 1;
 
-  auto AddStream = [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> std::unique_ptr {
 std::string Path = OutputFilename + "." + utostr(Task);
 
 std::error_code EC;
 auto S = std::make_unique(Path, EC, sys::fs::OF_None);
 check(EC, Path);
-return std::make_unique(std::move(S));
+return std::make_unique(std::move(S));
   };
 
   auto AddBuffer = [&](size_t Task, std::unique_ptr MB) {
 *AddStream(Task)->OS << MB->getBuffer();
   };
 
-  NativeObjectCache Cache;
+  FileCache Cache;
   if (!CacheDir.empty())
 Cache = check(localCache("ThinLTO", "Thin", CacheDir, AddBuffer),
   "failed to create cache");
Index: llvm/tools/llvm-lto/llvm-lto.cpp
===
--- llvm/tools/llvm-lto/llvm-lto.cpp
+++ llvm/tools/llvm-lto/llvm-lto.cpp
@@ -1097,7 +1097,7 @@
 error("writing merged module failed.");
 }
 
-auto AddStream = [&](size_t Task) -> std::unique_ptr {
+auto AddStream = [&](size_t Task) -> std::unique_ptr {
   std::string PartFilename = OutputFilename;
   if (Parallelism != 1)
 PartFilename += "." + utostr(Task);
@@ -1107,7 +1107,7 @@
   std::make_unique(PartFilename, EC, sys::fs::OF_None);
   if (EC)
 error("error opening the file '" + PartFilename + "': " + EC.message());
-  return std::make_unique(std::move(S));
+  return std::make_unique(std::move(S));
 };
 
 if (!CodeGen.compileOptimized(AddStream, Parallelism))
Index: llvm/tools/gold/gold-plugin.cpp
===
--- llvm/tools/gold/gold-plugin.cpp
+++ llvm/tools/gold/gold-plugin.cpp
@@ -1081,11 +1081,11 @@
   size_t MaxTasks = Lto->getMaxTasks();
   std::vector, bool>> Files(MaxTasks);
 
-  auto AddStream = [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> std::unique_ptr {
 Files[Task].second = !SaveTemps;
 int FD = getOutputFileName(Filename, /* TempOutFile */ !SaveTemps,
Files[Task].first, Task);
-return std::make_unique(
+return std::make_unique(
 std::make_unique(FD, true));
   };
 
@@ -1093,7 +1093,7 @@
 *AddStream(Task)->OS << MB->getBuffer();
   };
 
-  NativeObjectCache Cache;
+  FileCache Cache;
   if (!options::cache_dir.empty())
 Cache = check(localCache("ThinLTO", "Thin", options::cache_dir, AddBuffer));
 
Index: llvm/lib/Support/Caching.cpp
===
--- llvm/lib/Support/Caching.cpp
+++ llvm/lib/Support/Caching.cpp
@@ -1,4 +1,4 @@
-//===-Caching.cpp - LLVM File Cache Handling --===//
+//===-Caching.cpp - LLVM Local File Cache -===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,18 +6,17 @@
 //
 //===--===//
 //
-// This file implements the Caching used by ThinLTO.
+// This file implements the localCache function, which simplifies creating,
+// adding to, and querying a local file system cache. localCache takes care of
+// periodically pruning older files from the cache using a CachePruningPolicy.
 //
 //===--===//
 
 #include "llvm/Support/Caching.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/Process.h"
-#include "llvm/Support/raw_ostream.h"
 
 #if !defined(_MSC_VER) && !defined(__MINGW32__)
 #include 
@@ -27,10 +26,10 @@
 
 using namespace llvm;
 
-Expected llvm::localCache(Twine CacheNameRef,
- Twine TempFilePrefixRef,
- 

[PATCH] D112408: [RISCV] Add the zve extension according to the v1.0 spec

2021-11-03 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVSubtarget.h:170
   // D and Zfh imply F.
   bool hasVInstructionsAnyF() const { return HasStdExtV && hasStdExtF(); }
   unsigned getMaxInterleaveFactor() const {

This needs to be the same as hasVInstructionsF32.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112408

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


[PATCH] D113136: [Clang] Pass -z rel to linker for Fuchsia

2021-11-03 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr created this revision.
mcgrathr added a reviewer: phosek.
Herald added a subscriber: abrachet.
mcgrathr requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fuchsia already supports the more compact relocation format.
Make it the default.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113136

Files:
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/test/Driver/fuchsia.c


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -35,7 +35,7 @@
 // CHECK-X86_64: "-fsanitize=safe-stack"
 // CHECK: "-stack-protector" "2"
 // CHECK-NOT: "-fcommon"
-// CHECK: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" 
"rodynamic" "-z" "separate-loadable-segments" "--pack-dyn-relocs=relr"
+// CHECK: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" 
"rodynamic" "-z" "separate-loadable-segments" "--pack-dyn-relocs=relr" "-z" 
"rel"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -61,6 +61,8 @@
 CmdArgs.push_back("-z");
 CmdArgs.push_back("separate-loadable-segments");
 CmdArgs.push_back("--pack-dyn-relocs=relr");
+CmdArgs.push_back("-z");
+CmdArgs.push_back("rel");
   }
 
   if (!D.SysRoot.empty())


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -35,7 +35,7 @@
 // CHECK-X86_64: "-fsanitize=safe-stack"
 // CHECK: "-stack-protector" "2"
 // CHECK-NOT: "-fcommon"
-// CHECK: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" "rodynamic" "-z" "separate-loadable-segments" "--pack-dyn-relocs=relr"
+// CHECK: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" "rodynamic" "-z" "separate-loadable-segments" "--pack-dyn-relocs=relr" "-z" "rel"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -61,6 +61,8 @@
 CmdArgs.push_back("-z");
 CmdArgs.push_back("separate-loadable-segments");
 CmdArgs.push_back("--pack-dyn-relocs=relr");
+CmdArgs.push_back("-z");
+CmdArgs.push_back("rel");
   }
 
   if (!D.SysRoot.empty())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113126: [OpenMP][NFCI] Embed the source location string size in the ident_t

2021-11-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 384554.
jdoerfert added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Include the clang changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113126

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Index: llvm/lib/Transforms/IPO/OpenMPOpt.cpp
===
--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -1589,8 +1589,10 @@
 &F.getEntryBlock(), F.getEntryBlock().begin()));
   // Create a fallback location if non was found.
   // TODO: Use the debug locations of the calls instead.
-  Constant *Loc = OMPInfoCache.OMPBuilder.getOrCreateDefaultSrcLocStr();
-  Ident = OMPInfoCache.OMPBuilder.getOrCreateIdent(Loc);
+  uint32_t SrcLocStrSize;
+  Constant *Loc =
+  OMPInfoCache.OMPBuilder.getOrCreateDefaultSrcLocStr(SrcLocStrSize);
+  Ident = OMPInfoCache.OMPBuilder.getOrCreateIdent(Loc, SrcLocStrSize);
 }
 return Ident;
   }
@@ -3216,8 +3218,11 @@
   OpenMPIRBuilder::LocationDescription Loc(
   InsertPointTy(ParentBB, ParentBB->end()), DL);
   OMPInfoCache.OMPBuilder.updateToLocation(Loc);
-  auto *SrcLocStr = OMPInfoCache.OMPBuilder.getOrCreateSrcLocStr(Loc);
-  Value *Ident = OMPInfoCache.OMPBuilder.getOrCreateIdent(SrcLocStr);
+  uint32_t SrcLocStrSize;
+  auto *SrcLocStr =
+  OMPInfoCache.OMPBuilder.getOrCreateSrcLocStr(Loc, SrcLocStrSize);
+  Value *Ident =
+  OMPInfoCache.OMPBuilder.getOrCreateIdent(SrcLocStr, SrcLocStrSize);
   BranchInst::Create(RegionCheckTidBB, ParentBB)->setDebugLoc(DL);
 
   // Add check for Tid in RegionCheckTidBB
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -21,7 +21,9 @@
 #include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/IR/CFG.h"
+#include "llvm/IR/Constants.h"
 #include "llvm/IR/DebugInfo.h"
+#include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/PassManager.h"
@@ -37,6 +39,7 @@
 #include "llvm/Transforms/Utils/ModuleUtils.h"
 #include "llvm/Transforms/Utils/UnrollLoop.h"
 
+#include 
 #include 
 
 #define DEBUG_TYPE "openmp-ir-builder"
@@ -255,19 +258,21 @@
   return GV;
 }
 
-Value *OpenMPIRBuilder::getOrCreateIdent(Constant *SrcLocStr,
- IdentFlag LocFlags,
- unsigned Reserve2Flags) {
+Constant *OpenMPIRBuilder::getOrCreateIdent(Constant *SrcLocStr,
+uint32_t SrcLocStrSize,
+IdentFlag LocFlags,
+unsigned Reserve2Flags) {
   // Enable "C-mode".
   LocFlags |= OMP_IDENT_FLAG_KMPC;
 
-  Value *&Ident =
+  Constant *&Ident =
   IdentMap[{SrcLocStr, uint64_t(LocFlags) << 31 | Reserve2Flags}];
   if (!Ident) {
 Constant *I32Null = ConstantInt::getNullValue(Int32);
-Constant *IdentData[] = {
-I32Null, ConstantInt::get(Int32, uint32_t(LocFlags)),
-ConstantInt::get(Int32, Reserve2Flags), I32Null, SrcLocStr};
+Constant *IdentData[] = {I32Null,
+ ConstantInt::get(Int32, uint32_t(LocFlags)),
+ ConstantInt::get(Int32, Reserve2Flags),
+ ConstantInt::get(Int32, SrcLocStrSize), SrcLocStr};
 Constant *Initializer =
 ConstantStruct::get(OpenMPIRBuilder::Ident, IdentData);
 
@@ -290,10 +295,12 @@
 }
   }
 
-  return Builder.CreatePointerCast(Ident, IdentPtr);
+  return ConstantExpr::getPointerBitCastOrAddrSpaceCast(Ident, IdentPtr);
 }
 
-Constant *OpenMPIRBuilder::getOrCreateSrcLocStr(StringRef LocStr) {
+Constant *OpenMPIRBuilder::getOrCreateSrcLocStr(StringRef LocStr,
+uint32_t &SrcLocStrSize) {
+  SrcLocStrSize = LocStr.size();
   Constant *&SrcLocStr = SrcLocStrMap[LocStr];
   if (!SrcLocStr) {
 Constant *Initializer =
@@ -314,8 +321,8 @@
 
 Constant *OpenMPIRBuilder::getOrCreateSrcLocStr(StringRef FunctionName,
 StringRef FileName,
-unsigned Line,
-unsigned Column) {
+unsigned Line, unsigned Column,
+uint32_t &SrcLocStrSize) {
   SmallString<128> Buffer;
   Buffer.push_back(';');
   Buff

[PATCH] D112408: [RISCV] Add the zve extension according to the v1.0 spec

2021-11-03 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCV.td:225
+def HasStdExtVIntegerEEW32
+: Predicate<"Subtarget->hasStdExtV() || SubTarget->hasStdExtZve32x()">,
+  AssemblerPredicate<

StdExtV depends on Zve64d which depends on FeatureStdExtZve64f which depends on 
FeatureStdExtZve32f which depends on FeatureStdExtZve32x. Do we need to check 
both hasStdExtV and hasStdExtZve32x here or could we just check hasStdExtZve32x?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112408

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


[PATCH] D112408: [RISCV] Add the zve extension according to the v1.0 spec

2021-11-03 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCV.td:224
+
+def HasStdExtVIntegerEEW32
+: Predicate<"Subtarget->hasStdExtV() || SubTarget->hasStdExtZve32x()">,

Can we add the AssemblerPredicate to HasVInstructions and use that? Or we can 
rename it to HasVInstructionsAnyInt? Similar for HasStdExtZveFloating and 
HasVInstructionsAnyF.

And maybe rename HasStdExtVIntegerEEW64 to something like HasVInstructionsEEW64?

I'd like to avoid using the term "StdExt" in the name for something that isn't 
truly an extension name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112408

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


[PATCH] D113080: [Support] Improve Caching conformance with Support library behavior

2021-11-03 Thread Chris Lattner via Phabricator via cfe-commits
lattner accepted this revision.
lattner added a comment.
This revision is now accepted and ready to land.

nice, thank you for improving this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113080

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


[PATCH] D112577: [clang][OpenMP] Initial parsing/sema for 'align' clause

2021-11-03 Thread David Pagan via Phabricator via cfe-commits
ddpagan added a comment.

Thanks for reviewing the code, Aaron.




Comment at: clang/lib/Serialization/ASTWriter.cpp:5018
 Record.AddStmt(A->getAllocator());
+Record.AddStmt(A->getAlignment());
 Record.AddSourceRange(A->getRange());

aaron.ballman wrote:
> This can potentially add a null statement to emit to the serialized form.
The same thing can occur with A->getAllocator(). However, it's expected 
behavior. When these values are read in later, the allocator and alignment 
values are use to set the appropriate fields in the allocate directive. Null 
values are okay as they indicate whether or not a field has been specified (via 
an align or allocator clause).



Comment at: clang/lib/Serialization/ASTWriter.cpp:6224
+void OMPClauseWriter::VisitOMPAlignClause(OMPAlignClause *C) {
+  Record.AddStmt(C->getAlignment());
+  Record.AddSourceLocation(C->getLParenLoc());

aaron.ballman wrote:
> Same for this one, maybe?
This is called only when an align clause has been specified, so it's guaranteed 
to not be null.


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

https://reviews.llvm.org/D112577

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


  1   2   >