[PATCH] D96816: [ObjC] Encode pointers to C++ classes as "^v" if the encoded string would otherwise include template specialization types

2021-02-17 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 324540.
ahatanak added a comment.

Add test cases for nested class.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96816

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenObjCXX/encode.mm
  clang/test/Driver/objc-encode-cxx-class-template-spec.m

Index: clang/test/Driver/objc-encode-cxx-class-template-spec.m
===
--- /dev/null
+++ clang/test/Driver/objc-encode-cxx-class-template-spec.m
@@ -0,0 +1,7 @@
+// RUN: %clang -target arm64-apple-ios11 -### %s -o - 2>&1 | FileCheck -check-prefix=DISABLE-ENC %s
+// RUN: %clang -target arm64-apple-ios11 -fobjc-encode-cxx-class-template-spec -### %s -o - 2>&1 | FileCheck -check-prefix=ENABLE-ENC %s
+// RUN: %clang -target x86_64-linux-gnu -fobjc-runtime=gnustep -### %s -o - 2>&1 | FileCheck -check-prefix=ENABLE-ENC %s
+// RUN: %clang -target x86_64-linux-gnu -fobjc-runtime=gnustep -fno-objc-encode-cxx-class-template-spec -### %s -o - 2>&1 |  FileCheck -check-prefix=DISABLE-ENC %s
+
+// DISABLE-ENC-NOT: -fobjc-encode-cxx-class-template-spec
+// ENABLE-ENC: -fobjc-encode-cxx-class-template-spec
Index: clang/test/CodeGenObjCXX/encode.mm
===
--- clang/test/CodeGenObjCXX/encode.mm
+++ clang/test/CodeGenObjCXX/encode.mm
@@ -1,5 +1,6 @@
-// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++98 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX98 %s
-// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++20 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX20 %s
+// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++98 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX98,CHECK-NO-TEMP-SPEC %s
+// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++20 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX20,CHECK-NO-TEMP-SPEC %s
+// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++20 %s -triple=x86_64-apple-darwin10 -fobjc-encode-cxx-class-template-spec -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX20,CHECK-TEMP-SPEC %s
 
 // CHECK: v17@0:8{vector=}16
 // CHECK: {vector=}
@@ -260,3 +261,82 @@
   extern const char x[] = @encode(I);
 }
 #endif
+
+namespace test_cxx_template_specialization {
+template 
+struct B0 {
+  T a;
+};
+struct D0 : B0 {};
+struct D1 : D0 {};
+struct D2 : virtual B0 {};
+struct S0 {
+  B0 a;
+};
+struct S1 {
+  B0 *a;
+};
+struct S2 {
+  S1 *a;
+};
+template 
+union U0 {
+  T a;
+};
+typedef B0 TD0;
+typedef B0 *Array0[4];
+
+template 
+struct Outer0 {
+  struct Inner0 {
+int a;
+  };
+  template 
+  struct Inner1 {
+T a;
+T1 b;
+  };
+};
+
+// CHECK: @[[STR22:.*]] = {{.*}} [12 x i8] c"{B0=i}\00"
+// CHECK: @_ZN32test_cxx_template_specialization2b0E = {{.*}} ([12 x i8], [12 x i8]* @[[STR22]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @[[STR23:.*]] = {{.*}} [3 x i8] c"^v\00"
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization3b01E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-TEMP-SPEC: @[[STR23:.*]] = {{.*}} [13 x i8] c"^{B0=i}\00"
+// CHECK-TEMP-SPEC: @_ZN32test_cxx_template_specialization3b01E = {{.*}} ([13 x i8], [13 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization3b02E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2d0E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2d1E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2d2E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK: @[[STR24:.*]] = {{.*}} [7 x i8] c"^^{D2}\00"
+// CHECK: @_ZN32test_cxx_template_specialization3d21E = {{.*}} ([7 x i8], [7 x i8]* @[[STR24]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2s0E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2s1E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK: @[[STR25:.*]] = {{.*}} [12 x i8] c"^{S2=^{S1}}\00"
+// CHECK: @_ZN32test_cxx_template_specialization2s2E = {{.*}} ([12 x i8], [12 x i8]* @[[STR25]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2u0E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization3td0E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @[[STR26:.*]] = {{.*}} [6 x i8] c"[4^v]\00"
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2a0E 

[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2021-02-17 Thread Ten Tzen via Phabricator via cfe-commits
tentzen marked an inline comment as not done.
tentzen added a comment.

thank you for the thorough review again.  My answer for each comment below:




Comment at: clang/lib/CodeGen/CGCleanup.cpp:1341
+  llvm::FunctionCallee SehCppScope =
+  CGM.CreateRuntimeFunction(FTy, "llvm.seh.scope.begin");
+  EmitSehScope(*this, SehCppScope);

rjmccall wrote:
> We generally prefer to get intrinsic functions with `CGM.getIntrinsic`.
Does this really matter? there are more than 200 uses of 
CGM.CreateRuntimeFunction().



Comment at: clang/lib/CodeGen/CGException.cpp:465
 if (const CapturedDecl* CD = dyn_cast_or_null(D)) {
-  if (CD->isNothrow())
+  if (CD->isNothrow() && !getLangOpts().EHAsynch /* !IsEHa */)
 EHStack.pushTerminate();

rjmccall wrote:
> Please remove the comment here.  The option name should be sufficiently 
> self-descriptive.
> 
> Anyway, I don't think this change is right, because we *do* still need to 
> push a terminate scope: we need C++ exceptions to trigger a call to 
> `std::terminate`.  It's just that such scopes aren't fully terminal when 
> async exceptions are enabled, because MSVC defines those exceptions as 
> passing through `noexcept` and so on.  (I assume that's true; can you link to 
> documentation about it?)
Yes, MSVC terminate() runtime bypasses HW exceptions to its caller.
Hmm, it's been a whole. I think I placed that code there because Clang's 
terminate runtime does not dispatch HW exception to caller when I tried a year 
ago.  It issues an unhandled exception.  I felt if a user explicitly specify 
-EHa, HW exception probably is more significant than C++ noexcept/nothrow 
directive.
Anyways, I can undo this code and let terminate-runtime handler it one way or 
the other.



Comment at: clang/lib/CodeGen/CGException.cpp:554
+  if (isNoexceptExceptionSpec(EST) && Proto->canThrow() == CT_Cannot &&
+  !EHStack.empty() /* possible empty when -EHa */) {
 EHStack.popTerminate();

rjmccall wrote:
> Again, please try to refer to this in a more driver-agnostic way: "under 
> async exceptions" rather than "when -EHa".  But actually as mentioned above I 
> think this is incorrect.
will do.



Comment at: clang/lib/CodeGen/CGException.cpp:1668
+  } else if (isa(J)) {
+auto *MCI = cast(J);
+MCI->setVolatile(llvm::ConstantInt::get(Builder.getInt1Ty(), 1));

rjmccall wrote:
> Please use `dyn_cast` for all of these.
ok will fix them. thanks.



Comment at: clang/lib/CodeGen/CGException.cpp:1678
+  VolatilizeTryBlocks(TI->getSuccessor(I), V);
+  }
+}

rjmccall wrote:
> Volatilizing every block that's reachable from the `try` block seems like it 
> makes a lot of assumptions about where branches within the `try` can reach.  
> For example, a `goto` could certainly go to a block that's already been 
> emitted, as could `break` or `continue` if the emitter just makes slightly 
> different decisions about emission order.  Please look at how 
> `FragileHazards` (in the ObjC emission code) collects blocks in order to do 
> its transforms — I think you can probably extract a reasonable common base 
> out.  Alternatively, I think you could handle this directly in the insertion 
> callback (`CodeGenFunction::InsertHelper`) when we're in an appropriate `try` 
> scope.
A _try region is a Single Entry Multiple Exits regions. this code starts from 
Entry block and follows control-flow to reach all successors.  Yes a block 
could have multi-predecessors.  Note the 2nd line of this function: a visit 
flag is marked and checked
   !V.insert(BB).second /* already visited */ 

As long as it follows control-flows, it does not matter what the lexical order 
is.



Comment at: clang/lib/CodeGen/CGException.cpp:603
+
+  //  For IsEHa catch(...) must handle HW exception
+  //  Adjective = HT_IsStdDotDot (0x40), only catch C++ exceptions

rjmccall wrote:
> asmith wrote:
> > nit - extra space after //
> The comment here isn't explaining anything, it's just repeating what the code 
> is doing.  If you want a useful comment, you could explain why it's important 
> to mark the scope.
Yes, will do. thanks.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6584
+if (EH.Asynch)
+  CmdArgs.push_back("-feh-asynch");
   }

rjmccall wrote:
> For consistency with the existing options, please spell this option 
> `-fasync-exceptions`, and please spell the corresponding LangOption 
> `AsyncExceptions`.
OK will do.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2786
   Opts.CXXExceptions = Args.hasArg(OPT_fcxx_exceptions);
+  Opts.EHAsynch = Args.hasArg(OPT_feh_asynch);
 

rjmccall wrote:
> You should emit an error if this is enabled on targets that are not in the 
> appropriate Windows 

[PATCH] D96456: [ThinLTO, NewPM] Register sanitizers with OptimizerLastPassBuilderHook

2021-02-17 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 324529.
vitalybuka added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96456

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/thinlto-distributed-sanitizers.ll
  clang/test/Driver/asan.c
  clang/test/Driver/dfsan.c
  clang/test/Driver/msan.c
  clang/test/Driver/sancov.c
  clang/test/Driver/tsan.c
  llvm/include/llvm/LTO/Config.h
  llvm/lib/LTO/LTOBackend.cpp

Index: llvm/lib/LTO/LTOBackend.cpp
===
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -258,6 +258,9 @@
   PB.registerLoopAnalyses(LAM);
   PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
 
+  if (Conf.OptimizerLastPassBuilderHook)
+Conf.OptimizerLastPassBuilderHook(PB);
+
   ModulePassManager MPM(Conf.DebugPassManager);
 
   if (!Conf.DisableVerify)
Index: llvm/include/llvm/LTO/Config.h
===
--- llvm/include/llvm/LTO/Config.h
+++ llvm/include/llvm/LTO/Config.h
@@ -48,6 +48,8 @@
   TargetOptions Options;
   std::vector MAttrs;
   std::vector PassPlugins;
+  /// For adding passes that run by optimizer (NewPM only).
+  std::function OptimizerLastPassBuilderHook;
   /// For adding passes that run right before codegen.
   std::function PreCodeGenPassesHook;
   Optional RelocModel = Reloc::PIC_;
Index: clang/test/Driver/tsan.c
===
--- clang/test/Driver/tsan.c
+++ clang/test/Driver/tsan.c
@@ -19,9 +19,10 @@
 // RUN: %clang -O3 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | FileCheck %s
-// FIX: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | FileCheck %s
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefixes=NOTSAN
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto -o - | FileCheck %s
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto -o - | FileCheck %s
 
 int foo(int *a) { return *a; }
 // CHECK: __tsan_init
+// NOTSAN-NOT: __tsan
Index: clang/test/Driver/sancov.c
===
--- clang/test/Driver/sancov.c
+++ clang/test/Driver/sancov.c
@@ -3,7 +3,7 @@
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -O3 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto=thin -o - | FileCheck %s
-// FIX: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto=thin -o - | FileCheck %s
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefixes=NOSANCOV
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto -o - | FileCheck %s
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto -o - | FileCheck %s
 
@@ -20,3 +20,4 @@
 
 int foo(int *a) { return *a; }
 // CHECK: _sancov_
+// NOSANCOV-NOT: _sancov
Index: clang/test/Driver/msan.c
===
--- clang/test/Driver/msan.c
+++ clang/test/Driver/msan.c
@@ -31,7 +31,7 @@
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -O3 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefixes=CHECK0
-// FIX: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | FileCheck %s
+// RUN: %clang -O2 -fexperimental-new-pass-manager 

[PATCH] D96456: [ThinLTO, NewPM] Register sanitizers with OptimizerLastPassBuilderHook

2021-02-17 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 324528.
vitalybuka added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96456

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/thinlto-distributed-sanitizers.ll
  clang/test/Driver/asan.c
  clang/test/Driver/dfsan.c
  clang/test/Driver/msan.c
  clang/test/Driver/sancov.c
  clang/test/Driver/tsan.c
  llvm/include/llvm/LTO/Config.h
  llvm/lib/LTO/LTOBackend.cpp

Index: llvm/lib/LTO/LTOBackend.cpp
===
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -258,6 +258,9 @@
   PB.registerLoopAnalyses(LAM);
   PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
 
+  if (Conf.OptimizerLastPassBuilderHook)
+Conf.OptimizerLastPassBuilderHook(PB);
+
   ModulePassManager MPM(Conf.DebugPassManager);
 
   if (!Conf.DisableVerify)
Index: llvm/include/llvm/LTO/Config.h
===
--- llvm/include/llvm/LTO/Config.h
+++ llvm/include/llvm/LTO/Config.h
@@ -48,6 +48,8 @@
   TargetOptions Options;
   std::vector MAttrs;
   std::vector PassPlugins;
+  /// For adding passes that run by optimizer (NewPM only).
+  std::function OptimizerLastPassBuilderHook;
   /// For adding passes that run right before codegen.
   std::function PreCodeGenPassesHook;
   Optional RelocModel = Reloc::PIC_;
Index: clang/test/Driver/tsan.c
===
--- clang/test/Driver/tsan.c
+++ clang/test/Driver/tsan.c
@@ -19,9 +19,10 @@
 // RUN: %clang -O3 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | FileCheck %s
-// FIX: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | FileCheck %s
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefixes=NOTSAN
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto -o - | FileCheck %s
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto -o - | FileCheck %s
 
 int foo(int *a) { return *a; }
 // CHECK: __tsan_init
+// NOTSAN-NOT: __tsan
Index: clang/test/Driver/sancov.c
===
--- clang/test/Driver/sancov.c
+++ clang/test/Driver/sancov.c
@@ -3,7 +3,7 @@
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -O3 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto=thin -o - | FileCheck %s
-// FIX: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto=thin -o - | FileCheck %s
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefixes=NOSANCOV
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto -o - | FileCheck %s
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto -o - | FileCheck %s
 
@@ -20,3 +20,4 @@
 
 int foo(int *a) { return *a; }
 // CHECK: _sancov_
+// NOSANCOV-NOT: _sancov
Index: clang/test/Driver/msan.c
===
--- clang/test/Driver/msan.c
+++ clang/test/Driver/msan.c
@@ -1,51 +1,54 @@
 // REQUIRES: x86-registered-target
 
-// RUN: %clang -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O0
-// RUN: %clang -O1 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O1
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O1
-// RUN: %clang -O3 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S 

[PATCH] D96320: [ThinLTO, NewPM] Run OptimizerLastEPCallbacks from buildThinLTOPreLinkDefaultPipeline

2021-02-17 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 324527.
vitalybuka added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96320

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/Driver/asan.c
  clang/test/Driver/dfsan.c
  clang/test/Driver/msan.c
  clang/test/Driver/sancov.c
  clang/test/Driver/tsan.c
  llvm/lib/Passes/PassBuilder.cpp

Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -1497,6 +1497,12 @@
   if (PGOOpt && PGOOpt->PseudoProbeForProfiling)
 MPM.addPass(PseudoProbeUpdatePass());
 
+  // Handle OptimizerLastEPCallbacks added by clang on PreLink. Actual
+  // optimization is going to be done in PostLink stage, but clang can't
+  // add callbacks there in case of in-process ThinLTO called by linker.
+  for (auto  : OptimizerLastEPCallbacks)
+C(MPM, Level);
+
   // Emit annotation remarks.
   addAnnotationRemarksPass(MPM);
 
Index: clang/test/Driver/tsan.c
===
--- clang/test/Driver/tsan.c
+++ clang/test/Driver/tsan.c
@@ -19,7 +19,7 @@
 // RUN: %clang -O3 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | FileCheck %s
-// FIX: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | FileCheck %s
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto -o - | FileCheck %s
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto -o - | FileCheck %s
 
Index: clang/test/Driver/sancov.c
===
--- clang/test/Driver/sancov.c
+++ clang/test/Driver/sancov.c
@@ -3,7 +3,7 @@
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -O3 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto=thin -o - | FileCheck %s
-// FIX: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto=thin -o - | FileCheck %s
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto=thin -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto -o - | FileCheck %s
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto -o - | FileCheck %s
 
Index: clang/test/Driver/msan.c
===
--- clang/test/Driver/msan.c
+++ clang/test/Driver/msan.c
@@ -31,7 +31,7 @@
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -O3 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefixes=CHECK0
-// FIX: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | FileCheck %s
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto -o - | FileCheck %s --check-prefixes=CHECK0
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto -o - | FileCheck %s
 
@@ -40,7 +40,7 @@
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=kernel-memory  %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -O3 -fexperimental-new-pass-manager 

[clang] 3afc816 - [NFC] Simplify msan test

2021-02-17 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2021-02-17T22:10:42-08:00
New Revision: 3afc8161b06529a38d24d6991b42cda1fba09a45

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

LOG: [NFC] Simplify msan test

Added: 


Modified: 
clang/test/Driver/msan.c

Removed: 




diff  --git a/clang/test/Driver/msan.c b/clang/test/Driver/msan.c
index 8b69ca574eac..0023cad5ba8a 100644
--- a/clang/test/Driver/msan.c
+++ b/clang/test/Driver/msan.c
@@ -1,51 +1,52 @@
 // REQUIRES: x86-registered-target
 
-// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,O0
-// RUN: %clang -O1 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,O1
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,O1
-// RUN: %clang -O3 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,O1
-// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s --check-prefixes=CHECK,O0
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s --check-prefixes=CHECK,O1
-// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto -o - | FileCheck 
%s --check-prefixes=CHECK,O0
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto -o - | FileCheck 
%s --check-prefixes=CHECK,O1
-
-// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -o - | FileCheck 
%s --check-prefixes=CHECK,O0
-// RUN: %clang -O1 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -o - | FileCheck 
%s --check-prefixes=CHECK,O1
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -o - | FileCheck 
%s --check-prefixes=CHECK,O1
-// RUN: %clang -O3 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -o - | FileCheck 
%s --check-prefixes=CHECK,O1
-// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto=thin -o - 
| FileCheck %s --check-prefixes=CHECK,O0
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto=thin -o - 
| FileCheck %s --check-prefixes=CHECK,O1
-// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto -o - | 
FileCheck %s --check-prefixes=CHECK,O0
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=kernel-memory %s -S -emit-llvm -flto -o - | 
FileCheck %s --check-prefixes=CHECK,O1
-
-// RUN: %clang -target mips64-linux-gnu -fsanitize=memory %s -S -emit-llvm -o 
- | FileCheck %s --check-prefixes=CHECK,O0
-// RUN: %clang -target mips64el-unknown-linux-gnu -fsanitize=memory %s -S 
-emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O0
-// RUN: %clang -target powerpc64-unknown-linux-gnu -fsanitize=memory %s -S 
-emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O0
-// RUN: %clang -target powerpc64le-unknown-linux-gnu -fsanitize=memory %s -S 
-emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O0
+// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK0
+// RUN: %clang -O1 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O3 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s --check-prefixes=CHECK0
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | 
FileCheck %s
+// RUN: %clang 

[PATCH] D96320: [ThinLTO, NewPM] Run OptimizerLastEPCallbacks from buildThinLTOPreLinkDefaultPipeline

2021-02-17 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

I recovered this patch as PreLink alternative to  D96456 
.

Short term either of them will fix internal google builds.
Long term D96320  is going to be easier to 
maintain, e.g. if other users, without distributed LTO, like android will need 
sanitizers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96320

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


[PATCH] D96320: [ThinLTO, NewPM] Run OptimizerLastEPCallbacks from buildThinLTOPreLinkDefaultPipeline

2021-02-17 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 324526.
vitalybuka edited the summary of this revision.
vitalybuka added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

restore


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96320

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/Driver/asan.c
  clang/test/Driver/dfsan.c
  clang/test/Driver/msan.c
  clang/test/Driver/sancov.c
  clang/test/Driver/tsan.c
  llvm/lib/Passes/PassBuilder.cpp

Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -1497,6 +1497,12 @@
   if (PGOOpt && PGOOpt->PseudoProbeForProfiling)
 MPM.addPass(PseudoProbeUpdatePass());
 
+  // Handle OptimizerLastEPCallbacks added by clang on PreLink. Actual
+  // optimization is going to be done in PostLink stage, but clang can't
+  // add callbacks there in case of in-process ThinLTO called by linker.
+  for (auto  : OptimizerLastEPCallbacks)
+C(MPM, Level);
+
   // Emit annotation remarks.
   addAnnotationRemarksPass(MPM);
 
Index: clang/test/Driver/tsan.c
===
--- clang/test/Driver/tsan.c
+++ clang/test/Driver/tsan.c
@@ -19,7 +19,7 @@
 // RUN: %clang -O3 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | FileCheck %s
-// FIX: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | FileCheck %s
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto=thin -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto -o - | FileCheck %s
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=thread %s -S -emit-llvm -flto -o - | FileCheck %s
 
Index: clang/test/Driver/sancov.c
===
--- clang/test/Driver/sancov.c
+++ clang/test/Driver/sancov.c
@@ -3,7 +3,7 @@
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -O3 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto=thin -o - | FileCheck %s
-// FIX: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto=thin -o - | FileCheck %s
+// RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto=thin -o - | FileCheck %s
 // RUN: %clang -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto -o - | FileCheck %s
 // RUN: %clang -O2 -fexperimental-new-pass-manager -target x86_64-unknown-linux -fsanitize-coverage=trace-pc-guard %s -S -emit-llvm -flto -o - | FileCheck %s
 
@@ -19,4 +19,4 @@
 // Verify that -fsanitize-coverage invokes ModuleSanitizerCoveragePass instrumentation.
 
 int foo(int *a) { return *a; }
-// CHECK: _sancov_
+// CHECK: _sancov_
\ No newline at end of file
Index: clang/test/Driver/msan.c
===
--- clang/test/Driver/msan.c
+++ clang/test/Driver/msan.c
@@ -1,51 +1,53 @@
 // REQUIRES: x86-registered-target
 
-// RUN: %clang -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O0
-// RUN: %clang -O1 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O1
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O1
-// RUN: %clang -O3 -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,O1
-// RUN: %clang -fno-experimental-new-pass-manager -target x86_64-unknown-linux -fsanitize=memory %s -S -emit-llvm -flto=thin -o - | FileCheck %s --check-prefixes=CHECK,O0
-// RUN: %clang -O2 -fno-experimental-new-pass-manager 

[PATCH] D96832: [Clang][Attributes] Allow not_tail_called attribute to be applied to virtual function.

2021-02-17 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:4109
-  [[clang::not_tail_called]] int foo2() override;
-};
   }];

Quuxplusone wrote:
> (Moving into a thread)
> 
> > This patch doesn't prevent the call to method in the code below from being 
> > tail called,
> > but I suppose users would expect the attribute to prevent the tail call?
> ```
> struct B {
>   virtual void method();  
> };
> struct D : B {
>   [[clang::not_tail_called]] void method() override; 
> };
> ```
> 
> The way virtual calls are handled in C++ is, all attributes and properties of 
> the call are determined based on the //static// type at the call site; and 
> then the //runtime destination// of the call is determined from the pointer 
> in the vtable. Attributes and properties have no runtime existence, and so 
> they physically cannot affect anything at runtime. Consider 
> https://godbolt.org/z/P3799e :
> 
> ```
> struct Ba {
>   virtual Ba *method(int x = 1);  
> };
> struct Da : Ba {
>   [[clang::not_tail_called]] [[nodiscard]] Da *method(int x = 2) noexcept 
> override; 
> };
> auto callera(Da& da) {
> Ba& ba = da;
> ba.method();
> }
> ```
> Here the call that is made is a //virtual// call (because `Ba::method` is 
> virtual); with a default argument value of `1` (because `Ba::method`'s `x` 
> parameter has a default value of `1`); and it returns something of type `Ba*` 
> (because that's what `Ba::method` returns); and it is not considered to be 
> noexcept (because `Ba::method` isn't marked noexcept); and it's okay to 
> discard the result (because `Ba::method` is not nodiscard) and it is 
> tail-called (because `Ba::method` doesn't disallow tail calls). All of these 
> attributes and properties are based on the //static// type of variable `ba`, 
> despite the fact that //at runtime// we'll end up jumping to the code for 
> `Da::method`. According to the source code, statically, `Da::method` has a 
> default argument of `2`, returns `Da*`, is noexcept, and is nodiscard, and 
> disallows tail-calls. But we're not calling `da.method()`, we're calling 
> `ba.method()`; so none of that matters to our call site at `callera`.
> 
> I think this patch is a good thing.
OK, I see. I think this patch is fine then.

Should we add an explanation of how virtual functions are handled? The doc 
currently just says the attribute prevents tail-call optimization on statically 
bound calls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96832

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


[PATCH] D96816: [ObjC] Encode pointers to C++ classes as "^v" if the encoded string would otherwise include template specialization types

2021-02-17 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 324519.
ahatanak added a comment.

Upload patch with context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96816

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenObjCXX/encode.mm
  clang/test/Driver/objc-encode-cxx-class-template-spec.m

Index: clang/test/Driver/objc-encode-cxx-class-template-spec.m
===
--- /dev/null
+++ clang/test/Driver/objc-encode-cxx-class-template-spec.m
@@ -0,0 +1,7 @@
+// RUN: %clang -target arm64-apple-ios11 -### %s -o - 2>&1 | FileCheck -check-prefix=DISABLE-ENC %s
+// RUN: %clang -target arm64-apple-ios11 -fobjc-encode-cxx-class-template-spec -### %s -o - 2>&1 | FileCheck -check-prefix=ENABLE-ENC %s
+// RUN: %clang -target x86_64-linux-gnu -fobjc-runtime=gnustep -### %s -o - 2>&1 | FileCheck -check-prefix=ENABLE-ENC %s
+// RUN: %clang -target x86_64-linux-gnu -fobjc-runtime=gnustep -fno-objc-encode-cxx-class-template-spec -### %s -o - 2>&1 |  FileCheck -check-prefix=DISABLE-ENC %s
+
+// DISABLE-ENC-NOT: -fobjc-encode-cxx-class-template-spec
+// ENABLE-ENC: -fobjc-encode-cxx-class-template-spec
Index: clang/test/CodeGenObjCXX/encode.mm
===
--- clang/test/CodeGenObjCXX/encode.mm
+++ clang/test/CodeGenObjCXX/encode.mm
@@ -1,5 +1,6 @@
-// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++98 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX98 %s
-// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++20 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX20 %s
+// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++98 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX98,CHECK-NO-TEMP-SPEC %s
+// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++20 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX20,CHECK-NO-TEMP-SPEC %s
+// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++20 %s -triple=x86_64-apple-darwin10 -fobjc-encode-cxx-class-template-spec -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX20,CHECK-TEMP-SPEC %s
 
 // CHECK: v17@0:8{vector=}16
 // CHECK: {vector=}
@@ -260,3 +261,63 @@
   extern const char x[] = @encode(I);
 }
 #endif
+
+namespace test_cxx_template_specialization {
+template 
+struct B0 {
+  T a;
+};
+struct D0 : B0 {};
+struct D1 : D0 {};
+struct D2 : virtual B0 {};
+struct S0 {
+  B0 a;
+};
+struct S1 {
+  B0 *a;
+};
+struct S2 {
+  S1 *a;
+};
+template 
+union U0 {
+  T a;
+};
+typedef B0 TD0;
+typedef B0 *Array0[4];
+
+// CHECK: @[[STR22:.*]] = {{.*}} [12 x i8] c"{B0=i}\00"
+// CHECK: @_ZN32test_cxx_template_specialization2b0E = {{.*}} ([12 x i8], [12 x i8]* @[[STR22]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @[[STR23:.*]] = {{.*}} [3 x i8] c"^v\00"
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization3b01E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-TEMP-SPEC: @[[STR23:.*]] = {{.*}} [13 x i8] c"^{B0=i}\00"
+// CHECK-TEMP-SPEC: @_ZN32test_cxx_template_specialization3b01E = {{.*}} ([13 x i8], [13 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization3b02E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2d0E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2d1E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2d2E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK: @[[STR24:.*]] = {{.*}} [7 x i8] c"^^{D2}\00"
+// CHECK: @_ZN32test_cxx_template_specialization3d21E = {{.*}} ([7 x i8], [7 x i8]* @[[STR24]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2s0E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2s1E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK: @[[STR25:.*]] = {{.*}} [12 x i8] c"^{S2=^{S1}}\00"
+// CHECK: @_ZN32test_cxx_template_specialization2s2E = {{.*}} ([12 x i8], [12 x i8]* @[[STR25]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2u0E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization3td0E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @[[STR26:.*]] = {{.*}} [6 x i8] c"[4^v]\00"
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2a0E = {{.*}} ([6 x i8], [6 x i8]* @[[STR26]], i32 0, i32 0)
+
+const char *b0 = @encode(B0);
+const char *b01 = @encode(B0 *);
+const char 

[PATCH] D96816: [ObjC] Encode pointers to C++ classes as "^v" if the encoded string would otherwise include template specialization types

2021-02-17 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 324515.
ahatanak edited the summary of this revision.
ahatanak added a comment.

Enable this optimization only on Darwin.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96816

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenObjCXX/encode.mm
  clang/test/Driver/objc-encode-cxx-class-template-spec.m

Index: clang/test/Driver/objc-encode-cxx-class-template-spec.m
===
--- /dev/null
+++ clang/test/Driver/objc-encode-cxx-class-template-spec.m
@@ -0,0 +1,7 @@
+// RUN: %clang -target arm64-apple-ios11 -### %s -o - 2>&1 | FileCheck -check-prefix=DISABLE-ENC %s
+// RUN: %clang -target arm64-apple-ios11 -fobjc-encode-cxx-class-template-spec -### %s -o - 2>&1 | FileCheck -check-prefix=ENABLE-ENC %s
+// RUN: %clang -target x86_64-linux-gnu -fobjc-runtime=gnustep -### %s -o - 2>&1 | FileCheck -check-prefix=ENABLE-ENC %s
+// RUN: %clang -target x86_64-linux-gnu -fobjc-runtime=gnustep -fno-objc-encode-cxx-class-template-spec -### %s -o - 2>&1 |  FileCheck -check-prefix=DISABLE-ENC %s
+
+// DISABLE-ENC-NOT: -fobjc-encode-cxx-class-template-spec
+// ENABLE-ENC: -fobjc-encode-cxx-class-template-spec
Index: clang/test/CodeGenObjCXX/encode.mm
===
--- clang/test/CodeGenObjCXX/encode.mm
+++ clang/test/CodeGenObjCXX/encode.mm
@@ -1,5 +1,6 @@
-// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++98 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX98 %s
-// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++20 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX20 %s
+// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++98 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX98,CHECK-NO-TEMP-SPEC %s
+// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++20 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX20,CHECK-NO-TEMP-SPEC %s
+// RUN: %clang_cc1 -Wno-objc-root-class -std=gnu++20 %s -triple=x86_64-apple-darwin10 -fobjc-encode-cxx-class-template-spec -emit-llvm -o - | FileCheck --check-prefixes CHECK,CHECKCXX20,CHECK-TEMP-SPEC %s
 
 // CHECK: v17@0:8{vector=}16
 // CHECK: {vector=}
@@ -260,3 +261,63 @@
   extern const char x[] = @encode(I);
 }
 #endif
+
+namespace test_cxx_template_specialization {
+template 
+struct B0 {
+  T a;
+};
+struct D0 : B0 {};
+struct D1 : D0 {};
+struct D2 : virtual B0 {};
+struct S0 {
+  B0 a;
+};
+struct S1 {
+  B0 *a;
+};
+struct S2 {
+  S1 *a;
+};
+template 
+union U0 {
+  T a;
+};
+typedef B0 TD0;
+typedef B0 *Array0[4];
+
+// CHECK: @[[STR22:.*]] = {{.*}} [12 x i8] c"{B0=i}\00"
+// CHECK: @_ZN32test_cxx_template_specialization2b0E = {{.*}} ([12 x i8], [12 x i8]* @[[STR22]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @[[STR23:.*]] = {{.*}} [3 x i8] c"^v\00"
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization3b01E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-TEMP-SPEC: @[[STR23:.*]] = {{.*}} [13 x i8] c"^{B0=i}\00"
+// CHECK-TEMP-SPEC: @_ZN32test_cxx_template_specialization3b01E = {{.*}} ([13 x i8], [13 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization3b02E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2d0E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2d1E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2d2E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK: @[[STR24:.*]] = {{.*}} [7 x i8] c"^^{D2}\00"
+// CHECK: @_ZN32test_cxx_template_specialization3d21E = {{.*}} ([7 x i8], [7 x i8]* @[[STR24]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2s0E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2s1E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK: @[[STR25:.*]] = {{.*}} [12 x i8] c"^{S2=^{S1}}\00"
+// CHECK: @_ZN32test_cxx_template_specialization2s2E = {{.*}} ([12 x i8], [12 x i8]* @[[STR25]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2u0E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization3td0E = {{.*}} ([3 x i8], [3 x i8]* @[[STR23]], i32 0, i32 0)
+// CHECK-NO-TEMP-SPEC: @[[STR26:.*]] = {{.*}} [6 x i8] c"[4^v]\00"
+// CHECK-NO-TEMP-SPEC: @_ZN32test_cxx_template_specialization2a0E = {{.*}} ([6 x i8], [6 x i8]* @[[STR26]], i32 0, i32 0)
+
+const char *b0 = 

[PATCH] D96835: [HIP] Support device sanitizer

2021-02-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 324510.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

revised by Artem's comments


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

https://reviews.llvm.org/D96835

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Driver/ToolChains/HIP.h
  clang/lib/Driver/ToolChains/ROCm.h
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/hip.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/ockl.bc
  
clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc
  
clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_daz_opt_off.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_daz_opt_on.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_finite_only_off.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_finite_only_on.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_1010.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_1011.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_1012.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_803.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_900.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_isa_version_908.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_unsafe_math_off.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_unsafe_math_on.bc
  
clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_wavefrontsize64_off.bc
  
clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/oclc_wavefrontsize64_on.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/ocml.bc
  clang/test/Driver/Inputs/rocm-invalid/amdgcn/bitcode/opencl.bc
  clang/test/Driver/Inputs/rocm-invalid/bin/.hipVersion
  clang/test/Driver/Inputs/rocm-invalid/include/hip/hip_runtime.h
  clang/test/Driver/Inputs/rocm/amdgcn/bitcode/asanrtl.bc
  clang/test/Driver/hip-sanitize-options.hip

Index: clang/test/Driver/hip-sanitize-options.hip
===
--- clang/test/Driver/hip-sanitize-options.hip
+++ clang/test/Driver/hip-sanitize-options.hip
@@ -1,9 +1,40 @@
 // REQUIRES: clang-driver, x86-registered-target, amdgpu-registered-target
 
-// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx906 \
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900 \
 // RUN:   -fsanitize=address \
-// RUN:   -nogpuinc -nogpulib \
+// RUN:   -nogpuinc --rocm-path=%S/Inputs/rocm \
 // RUN:   %s 2>&1 | FileCheck %s
 
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900 \
+// RUN:   -fsanitize=address -fno-gpu-sanitize \
+// RUN:   -nogpuinc --rocm-path=%S/Inputs/rocm \
+// RUN:   %s 2>&1 | FileCheck %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900 \
+// RUN:   -fsanitize=address -fgpu-sanitize \
+// RUN:   -nogpuinc --rocm-path=%S/Inputs/rocm \
+// RUN:   %s 2>&1 | FileCheck -check-prefixes=NORDC %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900 \
+// RUN:   -fsanitize=address -fgpu-sanitize -fgpu-rdc \
+// RUN:   -nogpuinc --rocm-path=%S/Inputs/rocm \
+// RUN:   %s 2>&1 | FileCheck -check-prefixes=RDC %s
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx900 \
+// RUN:   -fsanitize=address -fgpu-sanitize \
+// RUN:   -nogpuinc --rocm-path=%S/Inputs/rocm-invalid \
+// RUN:   %s 2>&1 | FileCheck -check-prefixes=FAIL %s
+
 // CHECK-NOT: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address"}}
+// CHECK-NOT: {{"[^"]*lld[^"]*".* ".*hip.bc"}}
 // CHECK: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* "-fsanitize=address"}}
+
+// NORDC: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address".*}} "-o" "[[OUT:[^"]*.bc]]"
+// NORDC: {{"[^"]*lld[^"]*".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
+// NORDC: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* "-fsanitize=address"}}
+
+// RDC: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* "-fsanitize=address"}}
+// RDC: {{"[^"]*clang[^"]*".* "-emit-llvm-bc".* "-fcuda-is-device".* "-fsanitize=address".*}} "-o" "[[OUT:[^"]*.bc]]"
+// RDC: {{"[^"]*lld[^"]*".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
+
+// FAIL: AMDGPU address sanitizer runtime library (asanrtl) is not found. Please install ROCm device library which supports address sanitizer
Index: clang/test/Driver/Inputs/rocm-invalid/bin/.hipVersion
===
--- 

[PATCH] D96835: [HIP] Support device sanitizer

2021-02-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added inline comments.



Comment at: clang/include/clang/Driver/Options.td:939
   "__cyg_profile_func_enter and __cyg_profile_func_exit">;
+def fgpu_sanitize : Flag<["-"], "fgpu-sanitize">,
+  HelpText<"Enable sanitizer for AMDGPU target.">;

tra wrote:
> We do have `BoolFOption` for `-fsomething`/`-fno-something` options. 
done



Comment at: clang/lib/Driver/ToolChains/HIP.cpp:117
+   false))
+TC.addHIPDeviceLibArgs(Args, LldArgs, /*UseMLinkOpt=*/false);
+

tra wrote:
> I'd pass the library prefix argument as a string, instead of a boolean flag. 
> Makes it easier to tell what's going on without having to annotate it as a 
> comment. 
> 
> Also, maybe consider separating "get the list of bitcode files" from 
> "construct aguments for tool X for the given list of bitcode files". Right 
> now `addHIPDeviceLibArgs` does both and has to plumb the `UseMLinkOpt`through 
> multiple function calls. Adding the prefix argument can be done at the 
> `constructLldCommand`/`addClangTargetOptions`. 
Will refactor to get the list of bitcode files.


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

https://reviews.llvm.org/D96835

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


[PATCH] D96838: CodeGen: Set !retain metadata on UsedAttr definitions for FreeBSD/Fuchsia/Linux

2021-02-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 324504.
MaskRay retitled this revision from "CodeGen: Set !retain metadata on UsedAttr 
definitions for Linux/FreeBSD" to "CodeGen: Set !retain metadata on UsedAttr 
definitions for FreeBSD/Fuchsia/Linux".
MaskRay added a comment.

Add Fuchsia


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96838

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGen/attr-used.c
  clang/test/CodeGenCXX/attr-used.cpp
  clang/test/CodeGenCXX/extern-c.cpp

Index: clang/test/CodeGenCXX/extern-c.cpp
===
--- clang/test/CodeGenCXX/extern-c.cpp
+++ clang/test/CodeGenCXX/extern-c.cpp
@@ -75,11 +75,14 @@
   // CHECK-NOT: @unused
   // CHECK-NOT: @duplicate_internal
   // CHECK: @internal_var = internal alias i32, i32* @_ZL12internal_var
+  // CHECK-NOT: !retain
   // CHECK-NOT: @unused
   // CHECK-NOT: @duplicate_internal
   // CHECK: @internal_fn = internal alias i32 (), i32 ()* @_ZL11internal_fnv
+  // CHECK-NOT: !retain
   // CHECK-NOT: @unused
   // CHECK-NOT: @duplicate_internal
+  // CHECK: define internal i32 @_ZL11internal_fnv()
 }
 
 namespace PR19411 {
Index: clang/test/CodeGenCXX/attr-used.cpp
===
--- clang/test/CodeGenCXX/attr-used.cpp
+++ clang/test/CodeGenCXX/attr-used.cpp
@@ -1,10 +1,13 @@
 // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux -o - %s | FileCheck %s --check-prefix=RETAIN
 
 // : clang++ not respecting __attribute__((used)) on destructors
 struct X0 {
   // CHECK-DAG: define linkonce_odr {{.*}} @_ZN2X0C1Ev
+  // RETAIN-DAG: define linkonce_odr {{.*}} @_ZN2X0C1Ev({{.*}} !retain
   __attribute__((used)) X0() {}
   // CHECK-DAG: define linkonce_odr {{.*}} @_ZN2X0D1Ev
+  // RETAIN-DAG: define linkonce_odr {{.*}} @_ZN2X0D1Ev({{.*}} !retain
   __attribute__((used)) ~X0() {}
 };
 
@@ -12,6 +15,7 @@
 struct X1 {
   struct Nested {
 // CHECK-DAG: define linkonce_odr {{.*}} @_ZN2X16Nested1fEv
+// RETAIN-DAG: define linkonce_odr {{.*}} @_ZN2X16Nested1fEv({{.*}} !retain
 void __attribute__((used)) f() {}
   };
 };
@@ -24,4 +28,5 @@
 
   // CHECK-DAG: define linkonce_odr {{.*}} @_ZN2X23barEv
   // CHECK-DAG: define linkonce_odr {{.*}} @_ZN2X23fooEv
+  // RETAIN-DAG: define linkonce_odr {{.*}} @_ZN2X23barEv({{.*}} !retain
 };
Index: clang/test/CodeGen/attr-used.c
===
--- clang/test/CodeGen/attr-used.c
+++ clang/test/CodeGen/attr-used.c
@@ -1,10 +1,25 @@
-// RUN: %clang_cc1 -emit-llvm -o %t %s
-// RUN: grep '@llvm.used = .*@a0' %t
-// RUN: grep '@llvm.used = .*@g0' %t
-// RUN: grep '@llvm.used = .*@f0' %t
-// RUN: grep '@llvm.used = .*@f1.l0' %t
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux %s -o - | FileCheck %s --check-prefixes=CHECK,RETAIN
+// RUN: %clang_cc1 -emit-llvm -triple powerpc64-freebsd %s -o - | FileCheck %s --check-prefixes=CHECK,RETAIN
+// RUN: %clang_cc1 -emit-llvm -triple aarch64-fuchsia %s -o - | FileCheck %s --check-prefixes=CHECK,RETAIN
 
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin %s -o - | FileCheck %s --check-prefixes=CHECK,NORETAIN
 
+// RETAIN:  @r0 ={{.*}} constant i32 {{.*}} !retain ![[#EMPTY:]]
+// RETAIN:  @f1.l0 = internal global i32 {{.*}} !retain ![[#EMPTY]]
+// RETAIN:  @a0 ={{.*}} global i32 {{.*}} !retain ![[#EMPTY]]
+// RETAIN:  @g0 ={{.*}} global i32 {{.*}} !retain ![[#EMPTY]]
+
+/// Set !retain only on Linux and FreeBSD.
+// NORETAIN-NOT: !retain
+
+// CHECK:   @llvm.used ={{.*}} @f0
+// CHECK-SAME:@f1.l0
+// CHECK-SAME:@g0
+// CHECK-SAME:@a0
+
+// RETAIN:  [[#EMPTY]] = !{}
+
+const int r0 __attribute__((used)) = 42;
 int g0 __attribute__((used));
 
 static void __attribute__((used)) f0(void) {
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1048,6 +1048,9 @@
   template
   void MaybeHandleStaticInExternC(const SomeDecl *D, llvm::GlobalValue *GV);
 
+  /// Set !retain metadata if the target supports.
+  void maybeSetRetain(llvm::GlobalObject *GO);
+
   /// Add a global to a list to be added to the llvm.used metadata.
   void addUsedGlobal(llvm::GlobalValue *GV);
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1886,6 +1886,8 @@
 
   if (D) {
 if (auto *GV = dyn_cast(GO)) {
+  if (D->hasAttr())
+maybeSetRetain(GV);
   if (auto *SA = D->getAttr())
 GV->addAttribute("bss-section", SA->getName());
   if (auto *SA = D->getAttr())
@@ 

[PATCH] D96865: [Driver] Honor "-gdwarf-N" at any position for assembler sources

2021-02-17 Thread Igor Kudrin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa0c9ec1f5e70: [Driver] Honor -gdwarf-N at any 
position for assembler sources (authored by ikudrin).

Changed prior to commit:
  https://reviews.llvm.org/D96865?vs=324291=324502#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96865

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/debug-options-as.c


Index: clang/test/Driver/debug-options-as.c
===
--- clang/test/Driver/debug-options-as.c
+++ clang/test/Driver/debug-options-as.c
@@ -60,3 +60,18 @@
 // GDWARF64_VER:  error: invalid argument '-gdwarf64' only allowed with 
'DWARFv3 or greater'
 // GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 
bit architecture'
 // GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF 
platforms'
+
+// Check that -gdwarf-N can be placed before other options of the "-g" group.
+// RUN: %clang -### -c -g -gdwarf-3 -target %itanium_abi_triple 
-fintegrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF3 %s
+// RUN: %clang -### -c -gdwarf-3 -g -target %itanium_abi_triple 
-fintegrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF3 %s
+// RUN: %clang -### -c -g -gdwarf-5 -target %itanium_abi_triple 
-fintegrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF5 %s
+// RUN: %clang -### -c -gdwarf-5 -g -target %itanium_abi_triple 
-fintegrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF5 %s
+
+// DWARF3: "-cc1as"
+// DWARF3: "-dwarf-version=3"
+// DWARF5: "-cc1as"
+// DWARF5: "-dwarf-version=5"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -981,6 +981,14 @@
   .Default(0);
 }
 
+// Find a DWARF format version option.
+// This function is a complementary for DwarfVersionNum().
+static const Arg *getDwarfNArg(const ArgList ) {
+  return Args.getLastArg(options::OPT_gdwarf_2, options::OPT_gdwarf_3,
+ options::OPT_gdwarf_4, options::OPT_gdwarf_5,
+ options::OPT_gdwarf);
+}
+
 static void RenderDebugEnablingArgs(const ArgList , ArgStringList 
,
 codegenoptions::DebugInfoKind 
DebugInfoKind,
 unsigned DwarfVersion,
@@ -3848,9 +3856,7 @@
   }
 
   // If a -gdwarf argument appeared, remember it.
-  const Arg *GDwarfN = Args.getLastArg(
-  options::OPT_gdwarf_2, options::OPT_gdwarf_3, options::OPT_gdwarf_4,
-  options::OPT_gdwarf_5, options::OPT_gdwarf);
+  const Arg *GDwarfN = getDwarfNArg(Args);
   bool EmitDwarf = false;
   if (GDwarfN) {
 if (checkDebugInfoOption(GDwarfN, Args, D, TC))
@@ -7168,18 +7174,14 @@
   // Forward -g and handle debug info related flags, assuming we are dealing
   // with an actual assembly file.
   bool WantDebug = false;
-  unsigned DwarfVersion = 0;
   Args.ClaimAllArgs(options::OPT_g_Group);
-  if (Arg *A = Args.getLastArg(options::OPT_g_Group)) {
+  if (Arg *A = Args.getLastArg(options::OPT_g_Group))
 WantDebug = !A->getOption().matches(options::OPT_g0) &&
 !A->getOption().matches(options::OPT_ggdb0);
-if (WantDebug)
-  DwarfVersion = DwarfVersionNum(A->getSpelling());
-  }
 
-  unsigned DefaultDwarfVersion = ParseDebugDefaultVersion(getToolChain(), 
Args);
-  if (DwarfVersion == 0)
-DwarfVersion = DefaultDwarfVersion;
+  unsigned DwarfVersion = ParseDebugDefaultVersion(getToolChain(), Args);
+  if (const Arg *GDwarfN = getDwarfNArg(Args))
+DwarfVersion = DwarfVersionNum(GDwarfN->getSpelling());
 
   if (DwarfVersion == 0)
 DwarfVersion = getToolChain().GetDefaultDwarfVersion();


Index: clang/test/Driver/debug-options-as.c
===
--- clang/test/Driver/debug-options-as.c
+++ clang/test/Driver/debug-options-as.c
@@ -60,3 +60,18 @@
 // GDWARF64_VER:  error: invalid argument '-gdwarf64' only allowed with 'DWARFv3 or greater'
 // GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 bit architecture'
 // GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF platforms'
+
+// Check that -gdwarf-N can be placed before other options of the "-g" group.
+// RUN: %clang -### -c -g -gdwarf-3 -target %itanium_abi_triple -fintegrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF3 %s
+// RUN: %clang -### -c -gdwarf-3 -g -target %itanium_abi_triple -fintegrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF3 %s
+// RUN: %clang -### -c -g -gdwarf-5 -target %itanium_abi_triple -fintegrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF5 %s
+// 

[clang] a0c9ec1 - [Driver] Honor "-gdwarf-N" at any position for assembler sources

2021-02-17 Thread Igor Kudrin via cfe-commits

Author: Igor Kudrin
Date: 2021-02-18T10:36:42+07:00
New Revision: a0c9ec1f5e70e8f15da170667b2a8e63d024f3ab

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

LOG: [Driver] Honor "-gdwarf-N" at any position for assembler sources

This fixes an issue when "-gdwarf-N" switch was ignored if it was given
before another debug option.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/debug-options-as.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 2ae6c400f692..eaaef6b78ffb 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -981,6 +981,14 @@ static unsigned DwarfVersionNum(StringRef ArgValue) {
   .Default(0);
 }
 
+// Find a DWARF format version option.
+// This function is a complementary for DwarfVersionNum().
+static const Arg *getDwarfNArg(const ArgList ) {
+  return Args.getLastArg(options::OPT_gdwarf_2, options::OPT_gdwarf_3,
+ options::OPT_gdwarf_4, options::OPT_gdwarf_5,
+ options::OPT_gdwarf);
+}
+
 static void RenderDebugEnablingArgs(const ArgList , ArgStringList 
,
 codegenoptions::DebugInfoKind 
DebugInfoKind,
 unsigned DwarfVersion,
@@ -3848,9 +3856,7 @@ static void renderDebugOptions(const ToolChain , const 
Driver ,
   }
 
   // If a -gdwarf argument appeared, remember it.
-  const Arg *GDwarfN = Args.getLastArg(
-  options::OPT_gdwarf_2, options::OPT_gdwarf_3, options::OPT_gdwarf_4,
-  options::OPT_gdwarf_5, options::OPT_gdwarf);
+  const Arg *GDwarfN = getDwarfNArg(Args);
   bool EmitDwarf = false;
   if (GDwarfN) {
 if (checkDebugInfoOption(GDwarfN, Args, D, TC))
@@ -7168,18 +7174,14 @@ void ClangAs::ConstructJob(Compilation , const 
JobAction ,
   // Forward -g and handle debug info related flags, assuming we are dealing
   // with an actual assembly file.
   bool WantDebug = false;
-  unsigned DwarfVersion = 0;
   Args.ClaimAllArgs(options::OPT_g_Group);
-  if (Arg *A = Args.getLastArg(options::OPT_g_Group)) {
+  if (Arg *A = Args.getLastArg(options::OPT_g_Group))
 WantDebug = !A->getOption().matches(options::OPT_g0) &&
 !A->getOption().matches(options::OPT_ggdb0);
-if (WantDebug)
-  DwarfVersion = DwarfVersionNum(A->getSpelling());
-  }
 
-  unsigned DefaultDwarfVersion = ParseDebugDefaultVersion(getToolChain(), 
Args);
-  if (DwarfVersion == 0)
-DwarfVersion = DefaultDwarfVersion;
+  unsigned DwarfVersion = ParseDebugDefaultVersion(getToolChain(), Args);
+  if (const Arg *GDwarfN = getDwarfNArg(Args))
+DwarfVersion = DwarfVersionNum(GDwarfN->getSpelling());
 
   if (DwarfVersion == 0)
 DwarfVersion = getToolChain().GetDefaultDwarfVersion();

diff  --git a/clang/test/Driver/debug-options-as.c 
b/clang/test/Driver/debug-options-as.c
index f36188e8ab2b..90062d7d 100644
--- a/clang/test/Driver/debug-options-as.c
+++ b/clang/test/Driver/debug-options-as.c
@@ -60,3 +60,18 @@
 // GDWARF64_VER:  error: invalid argument '-gdwarf64' only allowed with 
'DWARFv3 or greater'
 // GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 
bit architecture'
 // GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF 
platforms'
+
+// Check that -gdwarf-N can be placed before other options of the "-g" group.
+// RUN: %clang -### -c -g -gdwarf-3 -target %itanium_abi_triple 
-fintegrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF3 %s
+// RUN: %clang -### -c -gdwarf-3 -g -target %itanium_abi_triple 
-fintegrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF3 %s
+// RUN: %clang -### -c -g -gdwarf-5 -target %itanium_abi_triple 
-fintegrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF5 %s
+// RUN: %clang -### -c -gdwarf-5 -g -target %itanium_abi_triple 
-fintegrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF5 %s
+
+// DWARF3: "-cc1as"
+// DWARF3: "-dwarf-version=3"
+// DWARF5: "-cc1as"
+// DWARF5: "-dwarf-version=5"



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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-02-17 Thread Lang Hames via Phabricator via cfe-commits
lhames added inline comments.



Comment at: clang/lib/CodeGen/CodeGenAction.cpp:908
 
+CodeGenerator *CodeGenAction::getCodeGenerator() const {
+  return BEConsumer->getCodeGenerator();

v.g.vassilev wrote:
> sgraenitz wrote:
> > v.g.vassilev wrote:
> > > @rjmccall, we were wondering if there is a better way to ask CodeGen to 
> > > start a new module. The current approach seems to be drilling hole in a 
> > > number of abstraction layers.
> > > 
> > > In the past we have touched that area a little in 
> > > https://reviews.llvm.org/D3 and the answer may be already there but I 
> > > fail to connect the dots.
> > > 
> > > Recently, we thought about having a new FrontendAction callback for 
> > > beginning a new phase when compiling incremental input. We need to keep 
> > > track of the created objects (needed for error recovery) in our 
> > > Transaction. We can have a map of `Transaction*` to `llvm::Module*` in 
> > > CodeGen. The issue is that new JITs take ownership of the `llvm::Module*` 
> > > which seems to make it impossible to support jitted code removal with 
> > > that model (cc: @lhames, @rsmith).
> > When compiling incrementally, doeas a "new phase" mean that all subsequent 
> > code will go into a new module from then on? How will dependencies to 
> > previous symbols be handled? Are all symbols external?
> > 
> > > The issue is that new JITs take ownership of the llvm::Module*
> > 
> > That's true, but you can still keep a raw pointer to it, which will be 
> > valid at least as long as the module wasn't linked. Afterwards it depends 
> > on the linker:
> > * RuntimeDyld can return ownership of the object's memory range via 
> > `NotifyEmittedFunction`
> > * JITLink provides the `ReturnObjectBufferFunction` for the same purpose
> > 
> > > seems to make it impossible to support jitted code removal with that model
> > 
> > Can you figure out what symbols are affected and remove these? A la: 
> > https://github.com/llvm/llvm-project/blob/13f4448ae7db1a47/llvm/include/llvm/ExecutionEngine/Orc/Core.h#L1020
> > 
> > I think @anarazel has ported a client with code removal to OrcV2 
> > successfully in the past. Maybe there's something we can learn from it.
> > When compiling incrementally, doeas a "new phase" mean that all subsequent 
> > code will go into a new module from then on? How will dependencies to 
> > previous symbols be handled? Are all symbols external?
> 
> There is some discussion on this here https://reviews.llvm.org/D3#812418
> 
> I think the relevant bit is that 'we have just one ever growing TU [...] 
> which we send to the RuntimeDyLD allowing only JIT to resolve symbols from 
> it.  We aid the JIT when resolving symbols with internal linkage by changing 
> all internal linkage to external (We haven't seen issues with that approach)'.
> 
> > 
> > > The issue is that new JITs take ownership of the llvm::Module*
> > 
> > That's true, but you can still keep a raw pointer to it, which will be 
> > valid at least as long as the module wasn't linked. 
> 
> That was my first implementation when I upgraded cling to llvm9 where the 
> `shared_ptr`s went to `unique_ptr`s. This was quite problematic for many of 
> the use cases we support as the JIT is somewhat unpredictable to the 
> high-level API user. 
> 
> 
> >Afterwards it depends on the linker:
> > * RuntimeDyld can return ownership of the object's memory range via 
> > `NotifyEmittedFunction`
> > * JITLink provides the `ReturnObjectBufferFunction` for the same purpose
> > 
> 
> That's exactly what we ended up doing (I would like to thank Lang here who 
> gave a similar advice).
> 
> > > seems to make it impossible to support jitted code removal with that model
> > 
> > Can you figure out what symbols are affected and remove these? A la: 
> > https://github.com/llvm/llvm-project/blob/13f4448ae7db1a47/llvm/include/llvm/ExecutionEngine/Orc/Core.h#L1020
> > 
> > I think @anarazel has ported a client with code removal to OrcV2 
> > successfully in the past. Maybe there's something we can learn from it.
> 
> Indeed. That's not yet on my radar as seemed somewhat distant in time.
> 
> Recently, we thought about having a new FrontendAction callback for beginning 
> a new phase when compiling incremental input. We need to keep track of the 
> created objects (needed for error recovery) in our Transaction. We can have a 
> map of Transaction* to llvm::Module* in CodeGen. The issue is that new JITs 
> take ownership of the llvm::Module* which seems to make it impossible to 
> support jitted code removal with that model (cc: @lhames, @rsmith).

In the new APIs, in order to enable removable code, you can associate Modules 
with ResourceTrackers when they're added to the JIT. The ResourceTrackers then 
allow for removal. Idiomatic usage looks like:

  auto Mod = /* create module */;
  auto RT = JD.createResourceTracker();
  J.addModule(RT, std::move(Mod));
  //...
  if (auto Err = RT.remove())
/* handle 

[PATCH] D94973: [clang][OpenMP] Use OpenMPIRBuilder for workshare loops.

2021-02-17 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.h:292
+  /// nest would extend.
+  SmallVector OMPLoopNestStack;
+

jdenny wrote:
> Unless I missed something, the only accesses to `OMPLoopNestStack` are 
> `push_back`, `clear`, `back`, and `size`.  It's never popped.  That is, every 
> push appears to mean that all existing elements will never be accessed again. 
>  So why is it a stack?  Is that purely for the sake of the assertion that 
> calls `size`?
When eventually supporting loop nests, we will need not only the outermost 
loop, but also inner ones.



Comment at: clang/lib/Sema/TreeTransform.h:8321
+TreeTransform::TransformOMPCanonicalLoop(OMPCanonicalLoop *L) {
+  // The OMPCanonicalLoop will be recreated when transforming the 
loop-associted
+  // directive.

jdenny wrote:
> I'm used to seeing `TransformX` call `RebuildX` call `ActOnX`.  Why not do 
> that for `X=OMPCanonicalLoop`?  Does `TransformOMPExecutableDirective` really 
> need a special case for `OMPCanonicalLoop`?
The intended behaviour is: 

1. Transform the child loop
2. Return the child loop as representing the OMPCanonicalLoop (i.e. 
OMPCanonicalLoop wrapper is removed).
3. Parent loop-associated directive (e.g. workshare) is processed.
4. `ActOnOpenMPCanonicalLoop` adds new OMPCanonicalLoop wrapper for loop nest.

This guarantees maximum flexibility on what of the loop can be changed, such as
* Change lower bound, upper bound, step
* Convert between CXXForRangeStmt and ForStmt
* Change the associated depth (e.g. different value for `collapse` clause)
* Remove the directive and no OMPCanonicalLoop remain

This also saves adding many lines of code handling transforming each member of 
OMPCanonicalLoop separately.



Comment at: clang/tools/libclang/CIndex.cpp:2839
+  VisitStmt(L);
+  EnqueueChildren(L);
+}

jdenny wrote:
> Doesn't `VisitStmt(L)` already call `EnqueueChildren(L)`?
It does indeed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94973

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


[clang] 766ee10 - [Clang][RISCV] Define RISC-V V builtin types

2021-02-17 Thread Hsiangkai Wang via cfe-commits

Author: Hsiangkai Wang
Date: 2021-02-18T10:17:31+08:00
New Revision: 766ee1096f0b32616c3e96b7acddc293e56c16ef

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

LOG: [Clang][RISCV] Define RISC-V V builtin types

Add the types for the RISC-V V extension builtins.

These types will be used by the RISC-V V intrinsics which require
types of the form (LMUL=1 element size=64) or
(LMUL=2 element size=32), etc. The vector_size
attribute does not work for us as it doesn't create a scalable
vector type. We want these types to be opaque and have no operators
defined for them. We want them to be sizeless. This makes them
similar to the ARM SVE builtin types. But we will have quite a bit
more types. This patch adds around 60. Later patches will add
another 230 or so types representing tuples of these types similar
to the x2/x3/x4 types in ARM SVE. But with extra complexity that
these types are combined with the LMUL concept that is unique to
RISCV.

For more background see this RFC
http://lists.llvm.org/pipermail/llvm-dev/2020-October/145850.html

Authored-by: Roger Ferrer Ibanez 
Co-Authored-by: Hsiangkai Wang 

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

Added: 
clang/include/clang/Basic/RISCVVTypes.def
clang/test/CodeGen/RISCV/riscv-v-debuginfo.c
clang/test/Sema/riscv-types.c

Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/Type.h
clang/include/clang/AST/TypeProperties.td
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/include/clang/module.modulemap
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/AST/NSAPI.cpp
clang/lib/AST/PrintfFormatString.cpp
clang/lib/AST/Type.cpp
clang/lib/AST/TypeLoc.cpp
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/RISCV.h
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CodeGenTypes.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/Index/USRGeneration.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Serialization/ASTCommon.cpp
clang/lib/Serialization/ASTReader.cpp
clang/tools/libclang/CIndex.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index ae69a68608b7..f256f9762b50 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1020,6 +1020,9 @@ class ASTContext : public RefCountedBase {
 #define PPC_VECTOR_TYPE(Name, Id, Size) \
   CanQualType Id##Ty;
 #include "clang/Basic/PPCTypes.def"
+#define RVV_TYPE(Name, Id, SingletonId) \
+  CanQualType SingletonId;
+#include "clang/Basic/RISCVVTypes.def"
 
   // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
   mutable QualType AutoDeductTy; // Deduction against 'auto'.

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 66ed32a9e9e5..530b3cecc023 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2492,6 +2492,9 @@ class BuiltinType : public Type {
 // PPC MMA Types
 #define PPC_VECTOR_TYPE(Name, Id, Size) Id,
 #include "clang/Basic/PPCTypes.def"
+// RVV Types
+#define RVV_TYPE(Name, Id, SingletonId) Id,
+#include "clang/Basic/RISCVVTypes.def"
 // All other builtin types
 #define BUILTIN_TYPE(Id, SingletonId) Id,
 #define LAST_BUILTIN_TYPE(Id) LastKind = Id

diff  --git a/clang/include/clang/AST/TypeProperties.td 
b/clang/include/clang/AST/TypeProperties.td
index ffcc8290938f..438d5af5a2e2 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -769,6 +769,10 @@ let Class = BuiltinType in {
   case BuiltinType::ID: return ctx.ID##Ty;
 #include "clang/Basic/PPCTypes.def"
 
+#define RVV_TYPE(NAME, ID, SINGLETON_ID) \
+  case BuiltinType::ID: return ctx.SINGLETON_ID;
+#include "clang/Basic/RISCVVTypes.def"
+
 #define BUILTIN_TYPE(ID, SINGLETON_ID) \
   case BuiltinType::ID: return ctx.SINGLETON_ID;
 #include "clang/AST/BuiltinTypes.def"

diff  --git a/clang/include/clang/Basic/RISCVVTypes.def 
b/clang/include/clang/Basic/RISCVVTypes.def
new file mode 100644
index ..f6ef62a64636
--- /dev/null
+++ b/clang/include/clang/Basic/RISCVVTypes.def
@@ -0,0 +1,147 @@
+//===-- RISCVVTypes.def - Metadata for the RISC-V V types --*- 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
+//

[PATCH] D96802: [Clang] Add proper target checks for SwiftAsync convention.

2021-02-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D96802#2569810 , @varungandhi-apple 
wrote:

>> The TargetInfo classes are already target-architecture-specific, so it's 
>> somewhat strange for them all to funnel to a single function that then 
>> immediately switches on the target architecture.
>
> IMO ideally, the whole thing would be stored as a table of Target x 
> CallingConvention. Each entry of the table would have a 
> CallingConvCheckResult. That way, you can quickly figure out both:
>
> - which targets is a calling convention supported for
> - what calling conventions are supported for a particular target
>
> Certainly, that's not the state of the code right now. So I do agree with 
> your point that it looks a bit strange. However, given that things are 
> somewhat in flux for `CC_SwiftAsync`, I think it is valuable to centralize 
> the information for it in one place instead of spreading it out over multiple 
> files.

I don't see why.  I can't really imagine adding a second dimension to the 
decision here — there's no reason to ever make this OS-dependent, for example — 
and so the only likely evolution is adding support for a new architecture, 
which means adding another case to your centralized function instead of just 
changing how the CC is handled in the target-specific function.  And for this 
patch, just implementing the new case as `return CCCR_Error` seems much more 
obvious than calling a centralized function which just switches out again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96802

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


[libunwind] 78eabca - [libunwind] Add support for PC reg column in arm64

2021-02-17 Thread Marco Vanotti via cfe-commits

Author: Marco Vanotti
Date: 2021-02-17T17:42:19-08:00
New Revision: 78eabcaa48df72e01b352b4b5077cece0693950c

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

LOG: [libunwind] Add support for PC reg column in arm64

This change adds support for the dwarf PC register column in arm64, allowing
CFI directives to make use of it.

As of the last revision of the DWARF for ARM 64-bit architecture[0], the pc
register has been added as a valir register, with number 32.

This allows libunwinder to restore both pc and lr, which is useful
for stack switches and signal contexts.

[0]:
https://github.com/ARM-software/abi-aa/blob/f52e1ad3f81254497a83578dc102f6aac89e52d0/aadwarf64/aadwarf64.rst

Reviewed By: phosek, #libunwind

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

Added: 


Modified: 
libunwind/include/libunwind.h
libunwind/src/Registers.hpp

Removed: 




diff  --git a/libunwind/include/libunwind.h b/libunwind/include/libunwind.h
index 5bae8d02f799..0feecd7bd6fc 100644
--- a/libunwind/include/libunwind.h
+++ b/libunwind/include/libunwind.h
@@ -493,16 +493,16 @@ enum {
 
 // 64-bit ARM64 registers
 enum {
-  UNW_ARM64_X0  = 0,
-  UNW_ARM64_X1  = 1,
-  UNW_ARM64_X2  = 2,
-  UNW_ARM64_X3  = 3,
-  UNW_ARM64_X4  = 4,
-  UNW_ARM64_X5  = 5,
-  UNW_ARM64_X6  = 6,
-  UNW_ARM64_X7  = 7,
-  UNW_ARM64_X8  = 8,
-  UNW_ARM64_X9  = 9,
+  UNW_ARM64_X0 = 0,
+  UNW_ARM64_X1 = 1,
+  UNW_ARM64_X2 = 2,
+  UNW_ARM64_X3 = 3,
+  UNW_ARM64_X4 = 4,
+  UNW_ARM64_X5 = 5,
+  UNW_ARM64_X6 = 6,
+  UNW_ARM64_X7 = 7,
+  UNW_ARM64_X8 = 8,
+  UNW_ARM64_X9 = 9,
   UNW_ARM64_X10 = 10,
   UNW_ARM64_X11 = 11,
   UNW_ARM64_X12 = 12,
@@ -523,24 +523,25 @@ enum {
   UNW_ARM64_X27 = 27,
   UNW_ARM64_X28 = 28,
   UNW_ARM64_X29 = 29,
-  UNW_ARM64_FP  = 29,
+  UNW_ARM64_FP = 29,
   UNW_ARM64_X30 = 30,
-  UNW_ARM64_LR  = 30,
+  UNW_ARM64_LR = 30,
   UNW_ARM64_X31 = 31,
-  UNW_ARM64_SP  = 31,
+  UNW_ARM64_SP = 31,
+  UNW_ARM64_PC = 32,
   // reserved block
   UNW_ARM64_RA_SIGN_STATE = 34,
   // reserved block
-  UNW_ARM64_D0  = 64,
-  UNW_ARM64_D1  = 65,
-  UNW_ARM64_D2  = 66,
-  UNW_ARM64_D3  = 67,
-  UNW_ARM64_D4  = 68,
-  UNW_ARM64_D5  = 69,
-  UNW_ARM64_D6  = 70,
-  UNW_ARM64_D7  = 71,
-  UNW_ARM64_D8  = 72,
-  UNW_ARM64_D9  = 73,
+  UNW_ARM64_D0 = 64,
+  UNW_ARM64_D1 = 65,
+  UNW_ARM64_D2 = 66,
+  UNW_ARM64_D3 = 67,
+  UNW_ARM64_D4 = 68,
+  UNW_ARM64_D5 = 69,
+  UNW_ARM64_D6 = 70,
+  UNW_ARM64_D7 = 71,
+  UNW_ARM64_D8 = 72,
+  UNW_ARM64_D9 = 73,
   UNW_ARM64_D10 = 74,
   UNW_ARM64_D11 = 75,
   UNW_ARM64_D12 = 76,

diff  --git a/libunwind/src/Registers.hpp b/libunwind/src/Registers.hpp
index efeaf435591e..de8e067b9d0c 100644
--- a/libunwind/src/Registers.hpp
+++ b/libunwind/src/Registers.hpp
@@ -1849,31 +1849,39 @@ inline bool Registers_arm64::validRegister(int regNum) 
const {
 return false;
   if (regNum == UNW_ARM64_RA_SIGN_STATE)
 return true;
-  if ((regNum > 31) && (regNum < 64))
+  if ((regNum > 32) && (regNum < 64))
 return false;
   return true;
 }
 
 inline uint64_t Registers_arm64::getRegister(int regNum) const {
-  if (regNum == UNW_REG_IP)
+  if (regNum == UNW_REG_IP || regNum == UNW_ARM64_PC)
 return _registers.__pc;
-  if (regNum == UNW_REG_SP)
+  if (regNum == UNW_REG_SP || regNum == UNW_ARM64_SP)
 return _registers.__sp;
   if (regNum == UNW_ARM64_RA_SIGN_STATE)
 return _registers.__ra_sign_state;
-  if ((regNum >= 0) && (regNum < 32))
+  if (regNum == UNW_ARM64_FP)
+return _registers.__fp;
+  if (regNum == UNW_ARM64_LR)
+return _registers.__lr;
+  if ((regNum >= 0) && (regNum < 29))
 return _registers.__x[regNum];
   _LIBUNWIND_ABORT("unsupported arm64 register");
 }
 
 inline void Registers_arm64::setRegister(int regNum, uint64_t value) {
-  if (regNum == UNW_REG_IP)
+  if (regNum == UNW_REG_IP || regNum == UNW_ARM64_PC)
 _registers.__pc = value;
-  else if (regNum == UNW_REG_SP)
+  else if (regNum == UNW_REG_SP || regNum == UNW_ARM64_SP)
 _registers.__sp = value;
   else if (regNum == UNW_ARM64_RA_SIGN_STATE)
 _registers.__ra_sign_state = value;
-  else if ((regNum >= 0) && (regNum < 32))
+  else if (regNum == UNW_ARM64_FP)
+_registers.__fp = value;
+  else if (regNum == UNW_ARM64_LR)
+_registers.__lr = value;
+  else if ((regNum >= 0) && (regNum < 29))
 _registers.__x[regNum] = value;
   else
 _LIBUNWIND_ABORT("unsupported arm64 register");
@@ -1943,12 +1951,14 @@ inline const char *Registers_arm64::getRegisterName(int 
regNum) {
 return "x27";
   case UNW_ARM64_X28:
 return "x28";
-  case UNW_ARM64_X29:
+  case UNW_ARM64_FP:
 return "fp";
-  case UNW_ARM64_X30:
+  case UNW_ARM64_LR:
 return "lr";
-  case UNW_ARM64_X31:
+  case UNW_ARM64_SP:
 return "sp";
+  case UNW_ARM64_PC:
+return "pc";
   case 

[PATCH] D96905: [libclang] Add missing fixed point literal CursorKind to cindex.py

2021-02-17 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 324473.
vabridgers added a comment.

Remove extraneous line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96905

Files:
  clang/bindings/python/clang/cindex.py
  clang/bindings/python/tests/cindex/test_cursor_kind.py


Index: clang/bindings/python/tests/cindex/test_cursor_kind.py
===
--- clang/bindings/python/tests/cindex/test_cursor_kind.py
+++ clang/bindings/python/tests/cindex/test_cursor_kind.py
@@ -23,6 +23,7 @@
 self.assertIn(CursorKind.MS_ASM_STMT, kinds)
 self.assertIn(CursorKind.MODULE_IMPORT_DECL, kinds)
 self.assertIn(CursorKind.TYPE_ALIAS_TEMPLATE_DECL, kinds)
+self.assertIn(CursorKind.FIXED_POINT_LITERAL, kinds)
 
 def test_kind_groups(self):
 """Check that every kind classifies to exactly one group."""
Index: clang/bindings/python/clang/cindex.py
===
--- clang/bindings/python/clang/cindex.py
+++ clang/bindings/python/clang/cindex.py
@@ -1084,6 +1084,8 @@
 # Represents an @available(...) check.
 CursorKind.OBJC_AVAILABILITY_CHECK_EXPR = CursorKind(148)
 
+# A fixed point literal
+CursorKind.FIXED_POINT_LITERAL = CursorKind(149)
 
 # A statement whose specific kind is not exposed via this interface.
 #


Index: clang/bindings/python/tests/cindex/test_cursor_kind.py
===
--- clang/bindings/python/tests/cindex/test_cursor_kind.py
+++ clang/bindings/python/tests/cindex/test_cursor_kind.py
@@ -23,6 +23,7 @@
 self.assertIn(CursorKind.MS_ASM_STMT, kinds)
 self.assertIn(CursorKind.MODULE_IMPORT_DECL, kinds)
 self.assertIn(CursorKind.TYPE_ALIAS_TEMPLATE_DECL, kinds)
+self.assertIn(CursorKind.FIXED_POINT_LITERAL, kinds)
 
 def test_kind_groups(self):
 """Check that every kind classifies to exactly one group."""
Index: clang/bindings/python/clang/cindex.py
===
--- clang/bindings/python/clang/cindex.py
+++ clang/bindings/python/clang/cindex.py
@@ -1084,6 +1084,8 @@
 # Represents an @available(...) check.
 CursorKind.OBJC_AVAILABILITY_CHECK_EXPR = CursorKind(148)
 
+# A fixed point literal
+CursorKind.FIXED_POINT_LITERAL = CursorKind(149)
 
 # A statement whose specific kind is not exposed via this interface.
 #
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-02-17 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

An upshot of looking at this is that `-Xclang -emit-llvm-bc -save-temps` does 
not work, and nor does `-Xclang -emit-llvm -save-temps`. However `-emit-llvm 
-save-temps` is fine. Opened https://bugs.llvm.org/show_bug.cgi?id=49234 to 
track.

Skipping the phases still looks right to me, instead of passing -emit-llvm-bc, 
but I suppose we could stall fixing this until we reach consensus on how to fix 
49234. I can carry the patch locally for debugging until then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

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


[PATCH] D96905: Add missing fixed point literal CursorKind to cindex.py

2021-02-17 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 324470.
vabridgers added a comment.

Add test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96905

Files:
  clang/bindings/python/clang/cindex.py
  clang/bindings/python/tests/cindex/test_cursor_kind.py


Index: clang/bindings/python/tests/cindex/test_cursor_kind.py
===
--- clang/bindings/python/tests/cindex/test_cursor_kind.py
+++ clang/bindings/python/tests/cindex/test_cursor_kind.py
@@ -23,6 +23,7 @@
 self.assertIn(CursorKind.MS_ASM_STMT, kinds)
 self.assertIn(CursorKind.MODULE_IMPORT_DECL, kinds)
 self.assertIn(CursorKind.TYPE_ALIAS_TEMPLATE_DECL, kinds)
+self.assertIn(CursorKind.FIXED_POINT_LITERAL, kinds)
 
 def test_kind_groups(self):
 """Check that every kind classifies to exactly one group."""
Index: clang/bindings/python/clang/cindex.py
===
--- clang/bindings/python/clang/cindex.py
+++ clang/bindings/python/clang/cindex.py
@@ -1084,6 +1084,9 @@
 # Represents an @available(...) check.
 CursorKind.OBJC_AVAILABILITY_CHECK_EXPR = CursorKind(148)
 
+# A fixed point literal
+CursorKind.FIXED_POINT_LITERAL = CursorKind(149)
+
 
 # A statement whose specific kind is not exposed via this interface.
 #


Index: clang/bindings/python/tests/cindex/test_cursor_kind.py
===
--- clang/bindings/python/tests/cindex/test_cursor_kind.py
+++ clang/bindings/python/tests/cindex/test_cursor_kind.py
@@ -23,6 +23,7 @@
 self.assertIn(CursorKind.MS_ASM_STMT, kinds)
 self.assertIn(CursorKind.MODULE_IMPORT_DECL, kinds)
 self.assertIn(CursorKind.TYPE_ALIAS_TEMPLATE_DECL, kinds)
+self.assertIn(CursorKind.FIXED_POINT_LITERAL, kinds)
 
 def test_kind_groups(self):
 """Check that every kind classifies to exactly one group."""
Index: clang/bindings/python/clang/cindex.py
===
--- clang/bindings/python/clang/cindex.py
+++ clang/bindings/python/clang/cindex.py
@@ -1084,6 +1084,9 @@
 # Represents an @available(...) check.
 CursorKind.OBJC_AVAILABILITY_CHECK_EXPR = CursorKind(148)
 
+# A fixed point literal
+CursorKind.FIXED_POINT_LITERAL = CursorKind(149)
+
 
 # A statement whose specific kind is not exposed via this interface.
 #
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2628e91 - [NetBSD] Use cortex-a8 as default CPU for ARMv7

2021-02-17 Thread Joerg Sonnenberger via cfe-commits

Author: Joerg Sonnenberger
Date: 2021-02-18T01:53:04+01:00
New Revision: 2628e9146120507b2cf025f5c4ccc857cc3724c4

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

LOG: [NetBSD] Use cortex-a8 as default CPU for ARMv7

This matches the platform default for GCC. It primarily matters when the
integrated assembler is not used as there is no default CPU defined for
ARMv7-A and GNU as is upset with -mcpu=generic.

Added: 


Modified: 
clang/test/Driver/netbsd.c
llvm/lib/Support/Triple.cpp

Removed: 




diff  --git a/clang/test/Driver/netbsd.c b/clang/test/Driver/netbsd.c
index 83486c73d281..812889309a0f 100644
--- a/clang/test/Driver/netbsd.c
+++ b/clang/test/Driver/netbsd.c
@@ -236,6 +236,7 @@
 // ARMEB: "{{.*}}/usr/lib{{/|}}eabi{{/|}}crti.o"
 // ARMEB: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc"
 // ARMEB: "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o"
+// ARMV7EB: as{{.*}}" "-mcpu=cortex-a8"
 // ARMV7EB: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
 // ARMV7EB: "--be8" "-m" "armelfb_nbsd_eabi"
 

diff  --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp
index 40c4f3db8b53..2ec123fcca73 100644
--- a/llvm/lib/Support/Triple.cpp
+++ b/llvm/lib/Support/Triple.cpp
@@ -1699,6 +1699,8 @@ StringRef Triple::getARMCPUForArch(StringRef MArch) const 
{
   case llvm::Triple::NetBSD:
 if (!MArch.empty() && MArch == "v6")
   return "arm1176jzf-s";
+if (!MArch.empty() && MArch == "v7")
+  return "cortex-a8";
 break;
   case llvm::Triple::Win32:
 // FIXME: this is invalid for WindowsCE



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


[PATCH] D96919: [clang] Emit type metadata on available_externally vtables for WPD

2021-02-17 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added a reviewer: pcc.
Herald added a subscriber: Prazek.
tejohnson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When WPD is enabled, via WholeProgramVTables, emit type metadata for
available_externally vtables. Additionally, add the vtables to the
llvm.compiler.used global so that they are not prematurely eliminated
(before *LTO analysis).

This is needed to avoid devirtualizing calls to a function overriding a
class defined in a header file but with a strong definition in a shared
library. Without type metadata on the available_externally vtables from
the header, the WPD analysis never sees what a derived class is
overriding. Even if the available_externally base class functions are
pure virtual, because shared library definitions are already treated
conservatively (committed patches D91583 , 
D96721 , and D96722 
) we will
not devirtualize, which would be unsafe since the library might contain
overrides that aren't visible to the LTO unit.

An example is std::error_category, which is overridden in LLVM
and causing failures after a self build with WPD enabled, because
libstdc++ contains hidden overrides of the virtual base class methods.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96919

Files:
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/type-metadata.cpp


Index: clang/test/CodeGenCXX/type-metadata.cpp
===
--- clang/test/CodeGenCXX/type-metadata.cpp
+++ clang/test/CodeGenCXX/type-metadata.cpp
@@ -7,6 +7,7 @@
 // Tests for the whole-program-vtables feature:
 // RUN: %clang_cc1 -flto -flto-unit -triple x86_64-unknown-linux -fvisibility 
hidden -fwhole-program-vtables -emit-llvm -o - %s | FileCheck 
--check-prefix=VTABLE-OPT --check-prefix=ITANIUM --check-prefix=TT-ITANIUM %s
 // RUN: %clang_cc1 -flto -flto-unit -triple x86_64-unknown-linux 
-fwhole-program-vtables -emit-llvm -o - %s | FileCheck 
--check-prefix=VTABLE-OPT --check-prefix=ITANIUM-DEFAULTVIS 
--check-prefix=TT-ITANIUM %s
+// RUN: %clang_cc1 -O2 -flto -flto-unit -triple x86_64-unknown-linux 
-fwhole-program-vtables -emit-llvm -o - %s | FileCheck 
--check-prefix=ITANIUM-OPT %s
 // RUN: %clang_cc1 -flto -flto-unit -triple x86_64-pc-windows-msvc 
-fwhole-program-vtables -emit-llvm -o - %s | FileCheck 
--check-prefix=VTABLE-OPT --check-prefix=MS --check-prefix=TT-MS %s
 
 // Tests for cfi + whole-program-vtables:
@@ -79,6 +80,13 @@
 // ITANIUM-DIAG-SAME: !type [[ALL16]]
 // ITANIUM-SAME: !type [[FAF16:![0-9]+]]
 
+// ITANIUM: @_ZTVN5test31EE = external unnamed_addr constant
+// ITANIUM-DEFAULTVIS: @_ZTVN5test31EE = external unnamed_addr constant
+// ITANIUM-OPT: @_ZTVN5test31EE = available_externally unnamed_addr constant 
{{[^!]*}},
+// ITANIUM-OPT-SAME: !type [[E16:![0-9]+]],
+// ITANIUM-OPT-SAME: !type [[EF16:![0-9]+]]
+// ITANIUM-OPT: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast 
({ [3 x i8*] }* @_ZTVN5test31EE to i8*)]
+
 // MS: comdat($"??_7A@@6B@"), !type [[A8:![0-9]+]]
 // MS: comdat($"??_7B@@6B0@@"), !type [[B8:![0-9]+]]
 // MS: comdat($"??_7B@@6BA@@@"), !type [[A8]]
@@ -253,6 +261,20 @@
 
 }
 
+namespace test3 {
+// All virtual functions are outline, so we can assume that it will
+// be generated in translation unit where foo is defined.
+struct E {
+  virtual void foo();
+};
+
+void g() {
+  E e;
+  e.foo();
+}
+
+}  // Test9
+
 // ITANIUM: [[A16]] = !{i64 16, !"_ZTS1A"}
 // ITANIUM-DIAG: [[ALL16]] = !{i64 16, !"all-vtables"}
 // ITANIUM: [[AF16]] = !{i64 16, !"_ZTSM1AFvvE.virtual"}
@@ -286,6 +308,9 @@
 // ITANIUM: [[FAF16]] = !{i64 16, [[FAF_ID:![0-9]+]]}
 // ITANIUM: [[FAF_ID]] = distinct !{}
 
+// ITANIUM-OPT: [[E16]] = !{i64 16, !"_ZTSN5test31EE"}
+// ITANIUM-OPT: [[EF16]] = !{i64 16, !"_ZTSMN5test31EEFvvE.virtual"}
+
 // MS: [[A8]] = !{i64 8, !"?AUA@@"}
 // MS: [[B8]] = !{i64 8, !"?AUB@@"}
 // MS: [[D8]] = !{i64 8, [[D_ID:![0-9]+]]}
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -1767,8 +1767,12 @@
   DC->getParent()->isTranslationUnit())
 EmitFundamentalRTTIDescriptors(RD);
 
-  if (!VTable->isDeclarationForLinker())
+  if (!VTable->isDeclarationForLinker() ||
+  CGM.getCodeGenOpts().WholeProgramVTables) {
 CGM.EmitVTableTypeMetadata(RD, VTable, VTLayout);
+if (VTable->isDeclarationForLinker())
+  CGM.addCompilerUsedGlobal(VTable);
+  }
 
   if (VTContext.isRelativeLayout() && !VTable->isDSOLocal())
 CGVT.GenerateRelativeVTableAlias(VTable, VTable->getName());


Index: clang/test/CodeGenCXX/type-metadata.cpp
===
--- clang/test/CodeGenCXX/type-metadata.cpp
+++ 

[PATCH] D96865: [Driver] Honor "-gdwarf-N" at any position for assembler sources

2021-02-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/debug-options-as.c:65
+// Check that -gdwarf-N can be placed before other options of the "-g" group.
+// RUN: %clang -### -c -g -gdwarf-3 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF3 %s

ikudrin wrote:
> MaskRay wrote:
> > Nit: use the more common spelling `-fintegrated-as`
> > 
> > `-triple %itanium_abi_triple`
> > 
> > msvc windows triples ideally don't need `-dwarf-version=`, but that can be 
> > a separate clean-up.
> > Nit: use the more common spelling -fintegrated-as
> `-integrated-as` is what other tests in this file use. Is it OK if these 
> lines will not follow the common template?
> 
I think it should be fine...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96865

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


[PATCH] D96865: [Driver] Honor "-gdwarf-N" at any position for assembler sources

2021-02-17 Thread Igor Kudrin via Phabricator via cfe-commits
ikudrin added a comment.

Thanks!




Comment at: clang/test/Driver/debug-options-as.c:65
+// Check that -gdwarf-N can be placed before other options of the "-g" group.
+// RUN: %clang -### -c -g -gdwarf-3 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF3 %s

MaskRay wrote:
> Nit: use the more common spelling `-fintegrated-as`
> 
> `-triple %itanium_abi_triple`
> 
> msvc windows triples ideally don't need `-dwarf-version=`, but that can be a 
> separate clean-up.
> Nit: use the more common spelling -fintegrated-as
`-integrated-as` is what other tests in this file use. Is it OK if these lines 
will not follow the common template?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96865

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


[PATCH] D96832: [Clang][Attributes] Allow not_tail_called attribute to be applied to virtual function.

2021-02-17 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In D96832#2570009 , @zequanwu wrote:

> In D96832#2569987 , @ahatanak wrote:
>
>> In D96832#2569481 , @zequanwu wrote:
>>
>>> In D96832#2568257 , @aaron.ballman 
>>> wrote:
>>>
 It was explicitly disallowed in the initial patch: 
 https://reviews.llvm.org/D12922 and the original author said "I'm still 
 trying to figure out the best way to handle c++ virtual functions: this 
 attribute is not very useful for someone who is looking for a way to 
 reliably prevent tail-call to a virtual function." and "I made this change 
 because this attribute isn't useful when the compiler cannot resolve the 
 function call statically at compile time and it isn't important for the 
 use case I have." Has this situation changed in the backend?
>>>
>>> Oh, I didn't see that. But when I tested `not_tail_called` on normal 
>>> functions,  it seems like not working(https://godbolt.org/z/znr5b5, `f1` is 
>>> marked as `not_tail_called`, it still get inlined). Or, I misunderstand how 
>>> to use it properly?
>>
>> I'm still trying to remember the discussions we had, but I think we banned 
>> the attribute on virtual functions because you can't in general promise a 
>> call to an annotated function won't be tail called if the function is 
>> virtual.
>>
>> This patch doesn't prevent the call to `method` in the code below from being 
>> tail called, but I suppose users would except the attribute to prevent the 
>> tail call?
>>
>>   struct B {
>> virtual void method();  
>>   };
>>   
>>   struct D : B {
>> [[clang::not_tail_called]] void method() override; 
>>   };
>>   
>>   void test(D *d) {
>> B *b = D;
>> b->method();
>>   }
>
> I got the point about why preventing it on virtual functions. But, on the 
> above godbolt link, I provided a example where `not_tail_called` doesn't 
> prevent a non-virtual function from tail call. I wonder if I use it correctly.

`not_tail_called` adds `notail` to the call `c->f1` in the IR, but doesn't do 
anything to prevent the calls inside `f1` from being tail called. You can use 
`disable-tail-calls` instead for that purpose.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96832

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


[PATCH] D96903: [WebAssembly] Remove dependency of reference types from EH

2021-02-17 Thread Heejin Ahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0b5d2b0efd3e: [WebAssembly] Remove dependency of reference 
types from EH (authored by aheejin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96903

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/test/Driver/wasm-toolchain.c


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -79,11 +79,11 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_SIGN_EXT %s
 // PTHREAD_NO_SIGN_EXT: invalid argument '-pthread' not allowed with 
'-mno-sign-ext'
 
-// '-fwasm-exceptions' sets +exception-handling and +reference-types
+// '-fwasm-exceptions' sets +exception-handling
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fwasm-exceptions 2>&1 \
 // RUN:  | FileCheck -check-prefix=WASM_EXCEPTIONS %s
-// WASM_EXCEPTIONS: clang{{.*}}" "-cc1" {{.*}} "-target-feature" 
"+exception-handling" "-target-feature" "+reference-types"
+// WASM_EXCEPTIONS: clang{{.*}}" "-cc1" {{.*}} "-target-feature" 
"+exception-handling"
 
 // '-fwasm-exceptions' not allowed with '-mno-exception-handling'
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
@@ -91,12 +91,6 @@
 // RUN:   | FileCheck -check-prefix=WASM_EXCEPTIONS_NO_EH %s
 // WASM_EXCEPTIONS_NO_EH: invalid argument '-fwasm-exceptions' not allowed 
with '-mno-exception-handling'
 
-// '-fwasm-exceptions' not allowed with '-mno-reference-types'
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
-// RUN: --sysroot=/foo %s -fwasm-exceptions -mno-reference-types 2>&1 \
-// RUN:   | FileCheck -check-prefix=WASM_EXCEPTIONS_NO_REFTYPES %s
-// WASM_EXCEPTIONS_NO_REFTYPES: invalid argument '-fwasm-exceptions' not 
allowed with '-mno-reference-types'
-
 // '-fwasm-exceptions' not allowed with
 // '-mllvm -enable-emscripten-cxx-exceptions'
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -282,12 +282,6 @@
   getDriver().Diag(diag::err_drv_argument_not_allowed_with)
   << "-fwasm-exceptions"
   << "-mno-exception-handling";
-// '-fwasm-exceptions' is not compatible with '-mno-reference-types'
-if (DriverArgs.hasFlag(options::OPT_mno_reference_types,
-   options::OPT_mexception_handing, false))
-  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
-  << "-fwasm-exceptions"
-  << "-mno-reference-types";
 // '-fwasm-exceptions' is not compatible with
 // '-mllvm -enable-emscripten-cxx-exceptions'
 for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
@@ -296,11 +290,9 @@
 << "-fwasm-exceptions"
 << "-mllvm -enable-emscripten-cxx-exceptions";
 }
-// '-fwasm-exceptions' implies exception-handling and reference-types
+// '-fwasm-exceptions' implies exception-handling feature
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+exception-handling");
-CC1Args.push_back("-target-feature");
-CC1Args.push_back("+reference-types");
   }
 }
 


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -79,11 +79,11 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_SIGN_EXT %s
 // PTHREAD_NO_SIGN_EXT: invalid argument '-pthread' not allowed with '-mno-sign-ext'
 
-// '-fwasm-exceptions' sets +exception-handling and +reference-types
+// '-fwasm-exceptions' sets +exception-handling
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fwasm-exceptions 2>&1 \
 // RUN:  | FileCheck -check-prefix=WASM_EXCEPTIONS %s
-// WASM_EXCEPTIONS: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+exception-handling" "-target-feature" "+reference-types"
+// WASM_EXCEPTIONS: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+exception-handling"
 
 // '-fwasm-exceptions' not allowed with '-mno-exception-handling'
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
@@ -91,12 +91,6 @@
 // RUN:   | FileCheck -check-prefix=WASM_EXCEPTIONS_NO_EH %s
 // WASM_EXCEPTIONS_NO_EH: invalid argument '-fwasm-exceptions' not allowed with '-mno-exception-handling'
 
-// '-fwasm-exceptions' not allowed with '-mno-reference-types'
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
-// RUN: --sysroot=/foo %s -fwasm-exceptions -mno-reference-types 2>&1 \
-// RUN:   | FileCheck 

[clang] 0b5d2b0 - [WebAssembly] Remove dependency of reference types from EH

2021-02-17 Thread Heejin Ahn via cfe-commits

Author: Heejin Ahn
Date: 2021-02-17T16:10:59-08:00
New Revision: 0b5d2b0efd3eb9a6c1d454a7fc50942e906f522c

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

LOG: [WebAssembly] Remove dependency of reference types from EH

The new spec does not have `exnref` so EH does not have dependency of
the reference types proposal anymore.

Reviewed By: dschuff

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/WebAssembly.cpp
clang/test/Driver/wasm-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 83a895b47142..8c4d99b8ad07 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -282,12 +282,6 @@ void WebAssembly::addClangTargetOptions(const ArgList 
,
   getDriver().Diag(diag::err_drv_argument_not_allowed_with)
   << "-fwasm-exceptions"
   << "-mno-exception-handling";
-// '-fwasm-exceptions' is not compatible with '-mno-reference-types'
-if (DriverArgs.hasFlag(options::OPT_mno_reference_types,
-   options::OPT_mexception_handing, false))
-  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
-  << "-fwasm-exceptions"
-  << "-mno-reference-types";
 // '-fwasm-exceptions' is not compatible with
 // '-mllvm -enable-emscripten-cxx-exceptions'
 for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
@@ -296,11 +290,9 @@ void WebAssembly::addClangTargetOptions(const ArgList 
,
 << "-fwasm-exceptions"
 << "-mllvm -enable-emscripten-cxx-exceptions";
 }
-// '-fwasm-exceptions' implies exception-handling and reference-types
+// '-fwasm-exceptions' implies exception-handling feature
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+exception-handling");
-CC1Args.push_back("-target-feature");
-CC1Args.push_back("+reference-types");
   }
 }
 

diff  --git a/clang/test/Driver/wasm-toolchain.c 
b/clang/test/Driver/wasm-toolchain.c
index 3c2eb66f9e19..17037819cfda 100644
--- a/clang/test/Driver/wasm-toolchain.c
+++ b/clang/test/Driver/wasm-toolchain.c
@@ -79,11 +79,11 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_SIGN_EXT %s
 // PTHREAD_NO_SIGN_EXT: invalid argument '-pthread' not allowed with 
'-mno-sign-ext'
 
-// '-fwasm-exceptions' sets +exception-handling and +reference-types
+// '-fwasm-exceptions' sets +exception-handling
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fwasm-exceptions 2>&1 \
 // RUN:  | FileCheck -check-prefix=WASM_EXCEPTIONS %s
-// WASM_EXCEPTIONS: clang{{.*}}" "-cc1" {{.*}} "-target-feature" 
"+exception-handling" "-target-feature" "+reference-types"
+// WASM_EXCEPTIONS: clang{{.*}}" "-cc1" {{.*}} "-target-feature" 
"+exception-handling"
 
 // '-fwasm-exceptions' not allowed with '-mno-exception-handling'
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
@@ -91,12 +91,6 @@
 // RUN:   | FileCheck -check-prefix=WASM_EXCEPTIONS_NO_EH %s
 // WASM_EXCEPTIONS_NO_EH: invalid argument '-fwasm-exceptions' not allowed 
with '-mno-exception-handling'
 
-// '-fwasm-exceptions' not allowed with '-mno-reference-types'
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
-// RUN: --sysroot=/foo %s -fwasm-exceptions -mno-reference-types 2>&1 \
-// RUN:   | FileCheck -check-prefix=WASM_EXCEPTIONS_NO_REFTYPES %s
-// WASM_EXCEPTIONS_NO_REFTYPES: invalid argument '-fwasm-exceptions' not 
allowed with '-mno-reference-types'
-
 // '-fwasm-exceptions' not allowed with
 // '-mllvm -enable-emscripten-cxx-exceptions'
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \



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


[PATCH] D96760: [clang-format] Suppress diagnostics on second parse

2021-02-17 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D96760#2569151 , 
@HazardyKnusperkeks wrote:

> In D96760#2565171 , @njames93 wrote:
>
>> I did have another plan for a different way to go about this, not sure if 
>> its really any better though.
>> It involved building a vector of the edits the config would apply to its 
>> parent. Then after the parent is parsed just applying those edits.
>> It results in only 1 pass over the config file however it's a little more 
>> involved to get it to work.
>
> But then I need to rewrite the complete parsing process? Because in a normal 
> style I can not parse, because it is not apparent which entries are changed 
> because of the config, or do I oversee something?
>
> In D93844#2536354 , @njames93 wrote:
>
>> As a follow up it may be wise to pass a diag handler to parseConfiguration 
>> as when we parse it a second time, we probably want to disregard any 
>> warnings (like unknown key) detected as they will have been printed on the 
>> first pass.
>
> And this is what you proposed. :)

The diaghandler is a perfectly good solution, I was just spit balling ideas. 
But it is possible to store changes, though not much is gained for this use 
case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96760

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


[PATCH] D96832: [Clang][Attributes] Allow not_tail_called attribute to be applied to virtual function.

2021-02-17 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:4109
-  [[clang::not_tail_called]] int foo2() override;
-};
   }];

(Moving into a thread)

> This patch doesn't prevent the call to method in the code below from being 
> tail called,
> but I suppose users would expect the attribute to prevent the tail call?
```
struct B {
  virtual void method();  
};
struct D : B {
  [[clang::not_tail_called]] void method() override; 
};
```

The way virtual calls are handled in C++ is, all attributes and properties of 
the call are determined based on the //static// type at the call site; and then 
the //runtime destination// of the call is determined from the pointer in the 
vtable. Attributes and properties have no runtime existence, and so they 
physically cannot affect anything at runtime. Consider 
https://godbolt.org/z/P3799e :

```
struct Ba {
  virtual Ba *method(int x = 1);  
};
struct Da : Ba {
  [[clang::not_tail_called]] [[nodiscard]] Da *method(int x = 2) noexcept 
override; 
};
auto callera(Da& da) {
Ba& ba = da;
ba.method();
}
```
Here the call that is made is a //virtual// call (because `Ba::method` is 
virtual); with a default argument value of `1` (because `Ba::method`'s `x` 
parameter has a default value of `1`); and it returns something of type `Ba*` 
(because that's what `Ba::method` returns); and it is not considered to be 
noexcept (because `Ba::method` isn't marked noexcept); and it's okay to discard 
the result (because `Ba::method` is not nodiscard) and it is tail-called 
(because `Ba::method` doesn't disallow tail calls). All of these attributes and 
properties are based on the //static// type of variable `ba`, despite the fact 
that //at runtime// we'll end up jumping to the code for `Da::method`. 
According to the source code, statically, `Da::method` has a default argument 
of `2`, returns `Da*`, is noexcept, and is nodiscard, and disallows tail-calls. 
But we're not calling `da.method()`, we're calling `ba.method()`; so none of 
that matters to our call site at `callera`.

I think this patch is a good thing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96832

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


[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-02-17 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

I don't think there's a general bug here. Maybe save-temps could strip out some 
arguments that collide with E, or pass E at the end of the list instead of the 
start, but that seems pretty invasive for a problem that doesn't seem to affect 
anyone.

Passing emit-llvm-bc was an amdgcn specific hack because we can't do much with 
linking object files compiled from assembly, so passing bitcode into lld works 
much better. This patch changes that to a mostly equivalent amdgcn specific 
hack, just one that collides with fewer assumptions elsewhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

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


[PATCH] D96832: [Clang][Attributes] Allow not_tail_called attribute to be applied to virtual function.

2021-02-17 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

In D96832#2569987 , @ahatanak wrote:

> In D96832#2569481 , @zequanwu wrote:
>
>> In D96832#2568257 , @aaron.ballman 
>> wrote:
>>
>>> It was explicitly disallowed in the initial patch: 
>>> https://reviews.llvm.org/D12922 and the original author said "I'm still 
>>> trying to figure out the best way to handle c++ virtual functions: this 
>>> attribute is not very useful for someone who is looking for a way to 
>>> reliably prevent tail-call to a virtual function." and "I made this change 
>>> because this attribute isn't useful when the compiler cannot resolve the 
>>> function call statically at compile time and it isn't important for the use 
>>> case I have." Has this situation changed in the backend?
>>
>> Oh, I didn't see that. But when I tested `not_tail_called` on normal 
>> functions,  it seems like not working(https://godbolt.org/z/znr5b5, `f1` is 
>> marked as `not_tail_called`, it still get inlined). Or, I misunderstand how 
>> to use it properly?
>
> I'm still trying to remember the discussions we had, but I think we banned 
> the attribute on virtual functions because you can't in general promise a 
> call to an annotated function won't be tail called if the function is virtual.
>
> This patch doesn't prevent the call to `method` in the code below from being 
> tail called, but I suppose users would except the attribute to prevent the 
> tail call?
>
>   struct B {
> virtual void method();  
>   };
>   
>   struct D : B {
> [[clang::not_tail_called]] void method() override; 
>   };
>   
>   void test(D *d) {
> B *b = D;
> b->method();
>   }

I got the point about why preventing it on virtual functions. But, on the above 
godbolt link, I provided a example where `not_tail_called` doesn't prevent a 
non-virtual function from tail call. I wonder if I use it correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96832

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


[PATCH] D95765: [OpenMP] Introduce the `disable_selector_propagation` variant selector trait

2021-02-17 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 accepted this revision.
tianshilei1992 added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95765

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


[PATCH] D96568: [CFE, SystemZ] Emit s390.tdc instrincic for __builtin_isnan in Constrained FP mode.

2021-02-17 Thread Jonas Paulsson via Phabricator via cfe-commits
jonpa added a comment.

In D96568#2569710 , @thopre wrote:

> In D96568#2569296 , @jonpa wrote:
>
>>> Sounds good to me. Hopefully I'll get round to __builtin_isinf soon and a 
>>> single hook will make the patch slightly smaller.
>>
>> Patch updated to call the new hook testFPKind() and make it take a BuiltinID 
>> as argument (that seems to work at least for the moment - maybe an enum type 
>> will become necessary at some point per your suggestion..?)
>>
>> I am not sure if this is "only" or "typically" used in constrained FP mode, 
>> or if the mode should be independent of calling this hook. The patch as it 
>> is asserts that it is called for an FP type but leaves it to the target to 
>> decide based on the FP mode, where SystemZ opts out unless it is constrained 
>> (which I think is what is wanted...).
>
> LGTM, we can adapt the hook later if needed. I do not know whether allowing 
> the hook to be used for non constrained FP will prove useful but it is easy 
> enough to ignore it for non FP so why not. Thanks for changing that!

Thanks for review!

@uweigand: looks good on the SystemZ parts?


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

https://reviews.llvm.org/D96568

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


[PATCH] D96832: [Clang][Attributes] Allow not_tail_called attribute to be applied to virtual function.

2021-02-17 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In D96832#2569481 , @zequanwu wrote:

> In D96832#2568257 , @aaron.ballman 
> wrote:
>
>> It was explicitly disallowed in the initial patch: 
>> https://reviews.llvm.org/D12922 and the original author said "I'm still 
>> trying to figure out the best way to handle c++ virtual functions: this 
>> attribute is not very useful for someone who is looking for a way to 
>> reliably prevent tail-call to a virtual function." and "I made this change 
>> because this attribute isn't useful when the compiler cannot resolve the 
>> function call statically at compile time and it isn't important for the use 
>> case I have." Has this situation changed in the backend?
>
> Oh, I didn't see that. But when I tested `not_tail_called` on normal 
> functions,  it seems like not working(https://godbolt.org/z/znr5b5, `f1` is 
> marked as `not_tail_called`, it still get inlined). Or, I misunderstand how 
> to use it properly?

I'm still trying to remember the discussions we had, but I think we banned the 
attribute on virtual functions because you can't in general promise a call to 
an annotated function won't be tail called if the function is virtual.

This patch doesn't prevent the call to `method` in the code below from being 
tail called, but I suppose users would except the attribute to prevent the tail 
call?

  struct B {
virtual void method();  
  };
  
  struct D : B {
[[clang::not_tail_called]] void method() override; 
  };
  
  void test(D *d) {
B *b = D;
b->method();
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96832

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


[PATCH] D96877: [libomptarget] Try a fallback devicertl if the preferred one is missing

2021-02-17 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D96877#2569863 , @tianshilei1992 
wrote:

> Please also update the test.
>
> In D96877#2569861 , @JonChesterfield 
> wrote:
>
>> Suggestion is to resolve libomptarget-nvptx-unknown.bc to a cp of the 
>> bitcode libary built for the newest sm_xx and ptx version clang knows of.
>
> Why a copy instead of a symlink?

I don't trust symlinks to survive packaging (tar or deb) or copying around the 
filesystem during install. Possibly showing scars from windows development 
there.

Tests passing locally, as expected. Do you mean add a new one that jury rigs 
cuda version and has a libomptarget-nvptx-unknown.bc on disk somewhere?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96877

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


[PATCH] D96877: [libomptarget] Try a fallback devicertl if the preferred one is missing

2021-02-17 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 32.
JonChesterfield added a comment.

- address review comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96877

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1628,6 +1628,33 @@
   }
 }
 
+namespace {
+bool tryAppendBuiltinBitcode(const llvm::opt::ArgList ,
+ llvm::opt::ArgStringList , StringRef lib) 
{
+  if (llvm::sys::fs::exists(lib)) {
+CC1Args.push_back("-mlink-builtin-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(lib));
+return true;
+  } else {
+return false;
+  }
+}
+
+bool tryAppendBuiltinBitcodeGivenPaths(
+const SmallVector ,
+const llvm::opt::ArgList , llvm::opt::ArgStringList ,
+StringRef lib) {
+  for (StringRef LibraryPath : LibraryPaths) {
+SmallString<128> TargetFile(LibraryPath);
+llvm::sys::path::append(TargetFile, lib);
+if (tryAppendBuiltinBitcode(DriverArgs, CC1Args, TargetFile)) {
+  return true;
+}
+  }
+  return false;
+}
+} // namespace
+
 void tools::addOpenMPDeviceRTL(const Driver ,
const llvm::opt::ArgList ,
llvm::opt::ArgStringList ,
@@ -1658,27 +1685,24 @@
   // First check whether user specifies bc library
   if (const Arg *A = DriverArgs.getLastArg(LibomptargetBCPathOpt)) {
 std::string LibOmpTargetName(A->getValue());
-if (llvm::sys::fs::exists(LibOmpTargetName)) {
-  CC1Args.push_back("-mlink-builtin-bitcode");
-  CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetName));
-} else {
+if (!tryAppendBuiltinBitcode(DriverArgs, CC1Args, LibOmpTargetName)) {
   D.Diag(diag::err_drv_omp_offload_target_bcruntime_not_found)
   << LibOmpTargetName;
 }
   } else {
-bool FoundBCLibrary = false;
-
-std::string LibOmpTargetName =
-"libomptarget-" + BitcodeSuffix.str() + ".bc";
-
-for (StringRef LibraryPath : LibraryPaths) {
-  SmallString<128> LibOmpTargetFile(LibraryPath);
-  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
-  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
-CC1Args.push_back("-mlink-builtin-bitcode");
-CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
-FoundBCLibrary = true;
-break;
+std::string Root = "libomptarget-";
+std::string LibOmpTargetName = Root + BitcodeSuffix.str() + ".bc";
+std::string FallbackTargetName = Root + ArchPrefix.str() + "-unknown.bc";
+
+bool FoundBCLibrary = tryAppendBuiltinBitcodeGivenPaths(
+LibraryPaths, DriverArgs, CC1Args, LibOmpTargetName);
+
+if (!FoundBCLibrary) {
+  FoundBCLibrary = tryAppendBuiltinBitcodeGivenPaths(
+  LibraryPaths, DriverArgs, CC1Args, FallbackTargetName);
+  if (FoundBCLibrary) {
+D.Diag(diag::warn_drv_omp_offload_target_missingbcruntime)
+<< LibOmpTargetName << FallbackTargetName;
   }
 }
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -262,6 +262,7 @@
   "The option -fopenmp-targets must be used in conjunction with a -fopenmp 
option compatible with offloading, please use -fopenmp=libomp or 
-fopenmp=libiomp5.">;
 def err_drv_omp_offload_target_missingbcruntime : Error<
   "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Please use --libomptarget-%1-bc-path to specify %1 bitcode 
library.">;
+def warn_drv_omp_offload_target_missingbcruntime : Warning<"No library '%0' 
found in the default clang lib directory or in LIBRARY_PATH. Fall back to '%1' 
instead.">;
 def err_drv_omp_offload_target_bcruntime_not_found : Error<"Bitcode library 
'%0' does not exist.">;
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">,


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1628,6 +1628,33 @@
   }
 }
 
+namespace {
+bool tryAppendBuiltinBitcode(const llvm::opt::ArgList ,
+ llvm::opt::ArgStringList , StringRef lib) {
+  if (llvm::sys::fs::exists(lib)) {
+CC1Args.push_back("-mlink-builtin-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(lib));
+return true;
+  } else {
+return false;
+  }
+}
+
+bool tryAppendBuiltinBitcodeGivenPaths(
+ 

[PATCH] D50106: [libc++] Fix tuple assignment from types derived from a tuple-like

2021-02-17 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: libcxx/include/tuple:432
+void __memberwise_copy_assign(_Dest& __dest, _Source const& __source, 
__tuple_indices<_Np...>) {
+__swallow(((_VSTD::get<_Np>(__dest) = _VSTD::get<_Np>(__source)), void(), 
int())...);
+}

Your friendly neighborhood ADL hater says: `_VSTD::__swallow` plz
(and line 438)
(and maybe `int()` is a sillier-than-necessary way to write `0`?)



Comment at: libcxx/include/tuple:891
+{
+__memberwise_copy_assign(*this, __tuple,
+typename __make_tuple_indices::type());

Your friendly neighborhood ADL hater says: `_VSTD::` plz
(and line 900)
(and line 931)
(and line 986)
(and line 1002)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D50106

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


[PATCH] D96802: [Clang] Add proper target checks for SwiftAsync convention.

2021-02-17 Thread Varun Gandhi via Phabricator via cfe-commits
varungandhi-apple abandoned this revision.
varungandhi-apple added a comment.

I've updated the earlier patch https://reviews.llvm.org/D95561 to include this 
change, so that we don't have an in-between state where we erroneously claim 
that we support a bunch of targets which we don't actually support.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96802

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


[PATCH] D96877: [libomptarget] Try a fallback devicertl if the preferred one is missing

2021-02-17 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

Please also update the test.

In D96877#2569861 , @JonChesterfield 
wrote:

> Suggestion is to resolve libomptarget-nvptx-unknown.bc to a cp of the bitcode 
> libary built for the newest sm_xx and ptx version clang knows of.

Why a copy instead of a symlink?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96877

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


[PATCH] D96877: [libomptarget] Try a fallback devicertl if the preferred one is missing

2021-02-17 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:265
   "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Please use --libomptarget-%1-bc-path to specify %1 bitcode 
library.">;
+def warn_drv_omp_offload_target_missingbcruntime : Warning<"No library '%0' 
found in the default clang lib directory or in LIBRARY_PATH, using '%1' 
instead. Please use --libomptarget-%2-bc-path to specify %2 bitcode library.">;
 def err_drv_omp_offload_target_bcruntime_not_found : Error<"Bitcode library 
'%0' does not exist.">;

JonChesterfield wrote:
> tianshilei1992 wrote:
> > Besides, we might also need to tell users this bitcode library might not 
> > work as expected.
> Could you propose preferred wording?
maybe the following one?
```
def warn_drv_omp_offload_target_missingbcruntime : Warning<"No library '%0' 
found in the default clang lib directory or in LIBRARY_PATH. Fall back to '%1' 
instead.">;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96877

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


[PATCH] D96877: [libomptarget] Try a fallback devicertl if the preferred one is missing

2021-02-17 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Suggestion is to resolve libomptarget-nvptx-unknown.bc to a cp of the bitcode 
libary built for the newest sm_xx and ptx version clang knows of.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96877

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


[PATCH] D96802: [Clang] Add proper target checks for SwiftAsync convention.

2021-02-17 Thread Varun Gandhi via Phabricator via cfe-commits
varungandhi-apple added a comment.

> The TargetInfo classes are already target-architecture-specific, so it's 
> somewhat strange for them all to funnel to a single function that then 
> immediately switches on the target architecture.

IMO ideally, the whole thing would be stored as a table of Target x 
CallingConvention. Each entry of the table would have a CallingConvCheckResult. 
That way, you can quickly figure out both:

- which targets is a calling convention supported for
- what calling conventions are supported for a particular target

Certainly, that's not the state of the code right now. So I do agree with your 
point that it looks a bit strange. However, given that things are somewhat in 
flux for `CC_SwiftAsync`, I think it is valuable to centralize the information 
for it in one place instead of spreading it out over multiple files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96802

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


[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-02-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

What you are telling me here is that -save-temps and -emit-llvm(-bc) can't work 
together right now. If that is so, why not fix it there instead of introducing 
a AMDGPU solution? There are other reasons you might want to combine those to 
options after all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

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


[PATCH] D96905: Add missing fixed point literal CursorKind to cindex.py

2021-02-17 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers created this revision.
Herald added a subscriber: arphaman.
vabridgers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Experimenting with parsing AST from Python using cindex.py, I discovered
that a CursorKind defintion for fixed point literals was missing. This
change simply adds this defintion following the defintion in
clang/include/clang-c/Index.h


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96905

Files:
  clang/bindings/python/clang/cindex.py


Index: clang/bindings/python/clang/cindex.py
===
--- clang/bindings/python/clang/cindex.py
+++ clang/bindings/python/clang/cindex.py
@@ -1084,6 +1084,9 @@
 # Represents an @available(...) check.
 CursorKind.OBJC_AVAILABILITY_CHECK_EXPR = CursorKind(148)
 
+# A fixed point literal
+CursorKind.FIXED_POINT_LITERAL = CursorKind(149)
+
 
 # A statement whose specific kind is not exposed via this interface.
 #


Index: clang/bindings/python/clang/cindex.py
===
--- clang/bindings/python/clang/cindex.py
+++ clang/bindings/python/clang/cindex.py
@@ -1084,6 +1084,9 @@
 # Represents an @available(...) check.
 CursorKind.OBJC_AVAILABILITY_CHECK_EXPR = CursorKind(148)
 
+# A fixed point literal
+CursorKind.FIXED_POINT_LITERAL = CursorKind(149)
+
 
 # A statement whose specific kind is not exposed via this interface.
 #
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-02-17 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Debugged this because I need save-temps (or hack up a binary by hand) to debug 
something else. The problem is addClangTargetOptions gets called to add target 
options to clang. With save temps, an early clang invocation runs the 
preprocessor alone. That gets passed the target specific flags, something like:

  "clang-13" "-cc1" "-mllvm" "--amdhsa-code-object-version=3" "-triple" 
"amdgcn-amd-amdhsa" "-aux-triple" "x86_64-pc-linux-gnu" "-E" "-save-temps=cwd" 
"-disable-free" "-main-file-name" "firstprivate.c" "-target-cpu" "gfx906" 
"-fcuda-is-device" "-emit-llvm-bc" "-mlink-builtin-bitcode" 
"/home/amd/llvm-install/lib/libomptarget-amdgcn-gfx906.bc" 
"-fno-split-dwarf-inlining" "-debugger-tuning=gdb" "-O2" 
"-fdebug-compilation-dir" "/home/amd/aomp/aomp/test/smoke/firstprivate" 
"-ferror-limit" "19" "-fmessage-length=102" "-fopenmp" 
"-fopenmp-cuda-parallel-target-regions" "-fgnuc-version=4.2.1" 
"-fopenmp-is-device" "-munsafe-fp-atomics" "-faddrsig" "-o" 
"firstprivate-openmp-amdgcn-amd-amdhsa.i" "-x" "c" "firstprivate.c"

Deleted some parts of that. The "-E" gives preprocessor behaviour. Things like 
-O2 or munsafe-fp-atomics don't matter to the preprocessor but are passed 
anyway, so there's prior art for it ignoring arguments when called as save 
temps. Whichever of emit-llvm-bc and E comes last wins, and the target options 
come after the E, so currently clang emits (binary) bytecode which is later 
interpreted as cpp-output, which can't handle bytecode.

With this patch applied, the problem of overriding the E flag is sidestepped. 
There are alternatives, but this approach looks cleaner than the others I can 
think of.

Note that it isn't a complete fix for save-temps, but it gets me as far as 
`multiple definition of `__dummy.omp_offloading.entry'`, which I vaguely 
remember marking as a weak symbol for the aomp toolchain. It lets clang get as 
far as emitting the device binary I wanted access to, so I'm now very sure this 
patch works.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

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


[PATCH] D96807: Modify TypePrinter to differentiate between anonymous struct and unnamed struct

2021-02-17 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik marked an inline comment as done.
shafik added inline comments.



Comment at: clang/lib/AST/TypePrinter.cpp:1308
+} else if ((isa(D) && 
cast(D)->isAnonymousStructOrUnion()) ||
+isa(D)) {
   OS << "anonymous";

aaron.ballman wrote:
> I think `EnumDecl` should probably be `unnamed` rather than `anonymous` 
> because there's no term of art for an anonymous enumeration (there's only 
> anonymous structures and anonymous unions). WDYT?
I thought I saw that wording but when I looked back I realize you are correct.


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

https://reviews.llvm.org/D96807

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


[PATCH] D96807: Modify TypePrinter to differentiate between anonymous struct and unnamed struct

2021-02-17 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 324431.
shafik added a comment.

- Went with unnamed enums Vs anonymous enums


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

https://reviews.llvm.org/D96807

Files:
  clang/lib/AST/TypePrinter.cpp
  clang/test/AST/ast-dump-decl-json.c
  clang/test/AST/ast-dump-enum-json.cpp
  clang/test/AST/ast-dump-openmp-cancel.c
  clang/test/AST/ast-dump-openmp-cancellation-point.c
  clang/test/AST/ast-dump-openmp-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-distribute-simd.c
  clang/test/AST/ast-dump-openmp-distribute.c
  clang/test/AST/ast-dump-openmp-for-simd.c
  clang/test/AST/ast-dump-openmp-for.c
  clang/test/AST/ast-dump-openmp-ordered.c
  clang/test/AST/ast-dump-openmp-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-parallel-for.c
  clang/test/AST/ast-dump-openmp-parallel-sections.c
  clang/test/AST/ast-dump-openmp-parallel.c
  clang/test/AST/ast-dump-openmp-section.c
  clang/test/AST/ast-dump-openmp-sections.c
  clang/test/AST/ast-dump-openmp-simd.c
  clang/test/AST/ast-dump-openmp-single.c
  clang/test/AST/ast-dump-openmp-target-data.c
  clang/test/AST/ast-dump-openmp-target-enter-data.c
  clang/test/AST/ast-dump-openmp-target-exit-data.c
  clang/test/AST/ast-dump-openmp-target-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-target-parallel-for.c
  clang/test/AST/ast-dump-openmp-target-parallel.c
  clang/test/AST/ast-dump-openmp-target-simd.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-simd.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute.c
  clang/test/AST/ast-dump-openmp-target-teams.c
  clang/test/AST/ast-dump-openmp-target-update.c
  clang/test/AST/ast-dump-openmp-target.c
  clang/test/AST/ast-dump-openmp-task.c
  clang/test/AST/ast-dump-openmp-taskgroup.c
  clang/test/AST/ast-dump-openmp-taskloop-simd.c
  clang/test/AST/ast-dump-openmp-taskloop.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-teams-distribute-simd.c
  clang/test/AST/ast-dump-openmp-teams-distribute.c
  clang/test/AST/ast-dump-openmp-teams.c
  clang/test/AST/ast-dump-records-json.cpp
  clang/test/AST/ast-dump-records.c
  clang/test/AST/ast-dump-records.cpp
  clang/test/AST/ast-dump-stmt-json.m
  clang/test/ASTMerge/struct/test.c
  clang/test/Analysis/cfg.cpp
  clang/test/Analysis/padding_c.c
  clang/test/Index/print-type.c
  clang/test/Index/print-type.cpp
  clang/test/Layout/ms-x86-alias-avoidance-padding.cpp
  clang/test/PCH/stmt-openmp_structured_block-bit.cpp
  clang/test/Sema/assign.c
  clang/test/Sema/switch.c
  clang/test/SemaCXX/condition.cpp
  clang/test/SemaCXX/enum.cpp
  clang/test/SemaCXX/warn-sign-conversion.cpp
  
lldb/test/Shell/SymbolFile/DWARF/clang-ast-from-dwarf-unamed-and-anon-structs.cpp
  lldb/test/Shell/SymbolFile/DWARF/debug-types-missing-signature.test

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


[PATCH] D96903: [WebAssembly] Remove dependency of reference types from EH

2021-02-17 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin created this revision.
aheejin added reviewers: dschuff, tlively.
Herald added subscribers: wingo, ecnelises, sunfish, jgravelle-google, sbc100.
aheejin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The new spec does not have `exnref` so EH does not have dependency of
the reference types proposal anymore.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96903

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/test/Driver/wasm-toolchain.c


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -79,11 +79,11 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_SIGN_EXT %s
 // PTHREAD_NO_SIGN_EXT: invalid argument '-pthread' not allowed with 
'-mno-sign-ext'
 
-// '-fwasm-exceptions' sets +exception-handling and +reference-types
+// '-fwasm-exceptions' sets +exception-handling
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fwasm-exceptions 2>&1 \
 // RUN:  | FileCheck -check-prefix=WASM_EXCEPTIONS %s
-// WASM_EXCEPTIONS: clang{{.*}}" "-cc1" {{.*}} "-target-feature" 
"+exception-handling" "-target-feature" "+reference-types"
+// WASM_EXCEPTIONS: clang{{.*}}" "-cc1" {{.*}} "-target-feature" 
"+exception-handling"
 
 // '-fwasm-exceptions' not allowed with '-mno-exception-handling'
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
@@ -91,12 +91,6 @@
 // RUN:   | FileCheck -check-prefix=WASM_EXCEPTIONS_NO_EH %s
 // WASM_EXCEPTIONS_NO_EH: invalid argument '-fwasm-exceptions' not allowed 
with '-mno-exception-handling'
 
-// '-fwasm-exceptions' not allowed with '-mno-reference-types'
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
-// RUN: --sysroot=/foo %s -fwasm-exceptions -mno-reference-types 2>&1 \
-// RUN:   | FileCheck -check-prefix=WASM_EXCEPTIONS_NO_REFTYPES %s
-// WASM_EXCEPTIONS_NO_REFTYPES: invalid argument '-fwasm-exceptions' not 
allowed with '-mno-reference-types'
-
 // '-fwasm-exceptions' not allowed with
 // '-mllvm -enable-emscripten-cxx-exceptions'
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -282,12 +282,6 @@
   getDriver().Diag(diag::err_drv_argument_not_allowed_with)
   << "-fwasm-exceptions"
   << "-mno-exception-handling";
-// '-fwasm-exceptions' is not compatible with '-mno-reference-types'
-if (DriverArgs.hasFlag(options::OPT_mno_reference_types,
-   options::OPT_mexception_handing, false))
-  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
-  << "-fwasm-exceptions"
-  << "-mno-reference-types";
 // '-fwasm-exceptions' is not compatible with
 // '-mllvm -enable-emscripten-cxx-exceptions'
 for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
@@ -296,11 +290,9 @@
 << "-fwasm-exceptions"
 << "-mllvm -enable-emscripten-cxx-exceptions";
 }
-// '-fwasm-exceptions' implies exception-handling and reference-types
+// '-fwasm-exceptions' implies exception-handling feature
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+exception-handling");
-CC1Args.push_back("-target-feature");
-CC1Args.push_back("+reference-types");
   }
 }
 


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -79,11 +79,11 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_SIGN_EXT %s
 // PTHREAD_NO_SIGN_EXT: invalid argument '-pthread' not allowed with '-mno-sign-ext'
 
-// '-fwasm-exceptions' sets +exception-handling and +reference-types
+// '-fwasm-exceptions' sets +exception-handling
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fwasm-exceptions 2>&1 \
 // RUN:  | FileCheck -check-prefix=WASM_EXCEPTIONS %s
-// WASM_EXCEPTIONS: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+exception-handling" "-target-feature" "+reference-types"
+// WASM_EXCEPTIONS: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+exception-handling"
 
 // '-fwasm-exceptions' not allowed with '-mno-exception-handling'
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
@@ -91,12 +91,6 @@
 // RUN:   | FileCheck -check-prefix=WASM_EXCEPTIONS_NO_EH %s
 // WASM_EXCEPTIONS_NO_EH: invalid argument '-fwasm-exceptions' not allowed with '-mno-exception-handling'
 
-// '-fwasm-exceptions' not allowed with '-mno-reference-types'
-// RUN: %clang -### -no-canonical-prefixes -target 

[PATCH] D96456: [ThinLTO, NewPM] Register sanitizers with OptimizerLastPassBuilderHook

2021-02-17 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1070-1071
+// ThinLTOIndexFile is provideds so we must be in ThinLTO PostLink.
+// For -O0 ThinLTO PreLink does basic optimization and triggers
+// OptimizerLastEPCallbacks. PostLink will not
+// run optimizations and this callback should

vitalybuka wrote:
> tejohnson wrote:
> > vitalybuka wrote:
> > > aeubanks wrote:
> > > > We could fix this. It doesn't make sense for only -O0 to run 
> > > > OptimizerLastEPCallbacks prelink. Would that help simplify this?
> > > Do you mean move optimizer of -O0 into PostLink as well?
> > > Yes, this would be more consistent.
> > > Still I guess it should a separate patch.
> > > 
> > Or does it make sense to go the other way, i.e. find a way to add the 
> > sanitizer passes to the end of the pre-link of ThinLTO like for regular 
> > LTO? The ThinLTO pre-link doesn't execute the module optimization pipeline, 
> > but presumably at the end of buildThinLTOPreLinkDefaultPipeline we could 
> > invoke the OptimizerLastEPCallbacks? That avoids the issue of trying to get 
> > this working separately for in-process ThinLTO. And would be more 
> > consistent with regular LTO.
> I started from PreLink approach but @aeubanks advised the PostLink. At this 
> point I slightly prefer it over PreLink. 
> 
> Sanitizers In PostLink pros:
> + instrumentation of optimized code produces smaller binary
> + optimizer called after instrumentation may removes some checks and we miss 
> some bugs (It's the case for non-LTO for at least msan. It stops reporting 
> some bugs. Maybe just a bug in msan.)
> + StackSafetyAnalysis supports ThinLTO and can be used to optimize sanitizers.
> + consistent with non-LTO pipeline
> + OptimizerLastEPCallbacks called once per module (I guess not true for full 
> LTO).
> 
> 
> Sanitizers In PreLink pros:
> + in-process ThinLTO. does not need special handling
> + Simpler patch
> + Can keep inconsistent -O0 pipeline (not sure why)
> + consistent with regular LTO (but why regular LTO is not consistent with 
> ThinLTO here?)
> 
> WDYT if ThinLTO PreLink with sanitizer use buildO0DefaultPipeline?
> Sanitizers In PostLink pros:
> + instrumentation of optimized code produces smaller binary

Strangely it's an opposite. On our "internal large binary" I see smaller 
Asan/Msan sizes if we instrument PreLink.
So this pro can be discarded.

At this point I don't have strong preference.

How can we agree which approach to use?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96456

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


[PATCH] D96568: [CFE, SystemZ] Emit s390.tdc instrincic for __builtin_isnan in Constrained FP mode.

2021-02-17 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre added a comment.

In D96568#2569296 , @jonpa wrote:

>> Sounds good to me. Hopefully I'll get round to __builtin_isinf soon and a 
>> single hook will make the patch slightly smaller.
>
> Patch updated to call the new hook testFPKind() and make it take a BuiltinID 
> as argument (that seems to work at least for the moment - maybe an enum type 
> will become necessary at some point per your suggestion..?)
>
> I am not sure if this is "only" or "typically" used in constrained FP mode, 
> or if the mode should be independent of calling this hook. The patch as it is 
> asserts that it is called for an FP type but leaves it to the target to 
> decide based on the FP mode, where SystemZ opts out unless it is constrained 
> (which I think is what is wanted...).

LGTM, we can adapt the hook later if needed. I do not know whether allowing the 
hook to be used for non constrained FP will prove useful but it is easy enough 
to ignore it for non FP so why not. Thanks for changing that!


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

https://reviews.llvm.org/D96568

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


[PATCH] D95753: [Coverage] Store compilation dir separately in coverage mapping

2021-02-17 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 324423.
phosek marked 2 inline comments as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95753

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CoverageMapping/abspath.cpp
  clang/test/Profile/profile-prefix-map.c
  compiler-rt/include/profile/InstrProfData.inc
  llvm/docs/CoverageMappingFormat.rst
  llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
  llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h
  llvm/include/llvm/ProfileData/Coverage/CoverageMappingWriter.h
  llvm/include/llvm/ProfileData/InstrProfData.inc
  llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
  llvm/test/tools/llvm-cov/Inputs/binary-formats.v6.linux64l
  llvm/test/tools/llvm-cov/binary-formats.c
  llvm/unittests/ProfileData/CoverageMappingTest.cpp

Index: llvm/unittests/ProfileData/CoverageMappingTest.cpp
===
--- llvm/unittests/ProfileData/CoverageMappingTest.cpp
+++ llvm/unittests/ProfileData/CoverageMappingTest.cpp
@@ -129,6 +129,7 @@
 struct CoverageMappingTest : ::testing::TestWithParam> {
   bool UseMultipleReaders;
   StringMap Files;
+  std::vector Filenames;
   std::vector InputFunctions;
   std::vector OutputFunctions;
 
@@ -146,7 +147,7 @@
 auto R = Files.find(Name);
 if (R != Files.end())
   return R->second;
-unsigned Index = Files.size();
+unsigned Index = Files.size() + 1;
 Files.try_emplace(Name, Index);
 return Index;
   }
@@ -200,11 +201,12 @@
 
   void readCoverageRegions(const std::string ,
OutputFunctionCoverageData ) {
-SmallVector Filenames(Files.size());
+Filenames.resize(Files.size() + 1);
 for (const auto  : Files)
-  Filenames[E.getValue()] = E.getKey();
+  Filenames[E.getValue()] = E.getKey().str();
 std::vector Expressions;
-RawCoverageMappingReader Reader(Coverage, Filenames, Data.Filenames,
+ArrayRef FilenameRefs = llvm::makeArrayRef(Filenames);
+RawCoverageMappingReader Reader(Coverage, FilenameRefs, Data.Filenames,
 Expressions, Data.Regions);
 EXPECT_THAT_ERROR(Reader.read(), Succeeded());
   }
@@ -895,7 +897,7 @@
   std::pair({true, true})),);
 
 TEST(CoverageMappingTest, filename_roundtrip) {
-  std::vector Paths({"a", "b", "c", "d", "e"});
+  std::vector Paths({"", "a", "b", "c", "d", "e"});
 
   for (bool Compress : {false, true}) {
 std::string EncodedFilenames;
@@ -905,16 +907,12 @@
   Writer.write(OS, Compress);
 }
 
-std::vector ReadFilenames;
+std::vector ReadFilenames;
 RawCoverageFilenamesReader Reader(EncodedFilenames, ReadFilenames);
-BinaryCoverageReader::DecompressedData Decompressed;
-EXPECT_THAT_ERROR(Reader.read(CovMapVersion::CurrentVersion, Decompressed),
-  Succeeded());
-if (!Compress)
-  ASSERT_EQ(Decompressed.size(), 0U);
+EXPECT_THAT_ERROR(Reader.read(CovMapVersion::CurrentVersion), Succeeded());
 
 ASSERT_EQ(ReadFilenames.size(), Paths.size());
-for (unsigned I = 0; I < Paths.size(); ++I)
+for (unsigned I = 1; I < Paths.size(); ++I)
   ASSERT_TRUE(ReadFilenames[I] == Paths[I]);
   }
 }
Index: llvm/test/tools/llvm-cov/binary-formats.c
===
--- llvm/test/tools/llvm-cov/binary-formats.c
+++ llvm/test/tools/llvm-cov/binary-formats.c
@@ -8,5 +8,6 @@
 // RUN: llvm-cov show %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
 // RUN: llvm-cov show %S/Inputs/binary-formats.macho32b -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
 // RUN: llvm-cov show %S/Inputs/binary-formats.v3.macho64l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
+// RUN: llvm-cov show %S/Inputs/binary-formats.v6.linux64l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
 
 // RUN: llvm-cov export %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata | FileCheck %S/Inputs/binary-formats.canonical.json
Index: llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
===
--- llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
+++ llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
@@ -27,7 +27,7 @@
 using namespace coverage;
 
 CoverageFilenamesSectionWriter::CoverageFilenamesSectionWriter(
-ArrayRef Filenames)
+ArrayRef Filenames)
 : Filenames(Filenames) {
 #ifndef NDEBUG
   StringSet<> NameSet;
Index: 

[PATCH] D96572: [Clang][ASan] Introduce `-fsanitize-address-destructor-kind=` driver & frontend option.

2021-02-17 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka resigned from this revision.
vitalybuka added a comment.

LGTM, but leaving for others


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96572

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


[PATCH] D95396: Improve static_assert/_Static_assert diagnostics

2021-02-17 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:874-876
+if (!getLangOpts().CPlusPlus)
+  Diag(Tok, diag::warn_cxx_static_assert_in_c)
+  << FixItHint::CreateReplacement(Tok.getLocation(), "_Static_assert");

aaron.ballman wrote:
> rsmith wrote:
> > aaron.ballman wrote:
> > > aaron.ballman wrote:
> > > > rsmith wrote:
> > > > > I don't think this diagnostic is useful as-is: on Windows, including 
> > > > > `` doesn't help because it doesn't `#define static_assert`. 
> > > > > And people hitting this also can't switch to using `_Static_assert`, 
> > > > > because MSVC doesn't provide it, only `static_assert`.
> > > > > 
> > > > > If we want to warn here, we could perhaps check whether `` 
> > > > > has been included, but getting that check correct across PCH / 
> > > > > modules is not straightforward. (If we knew what include guard the 
> > > > > CRT's `assert.h` used (if any), I guess we could check whether that's 
> > > > > defined, but that'd be a bit of a hack.) But I'm somewhat inclined to 
> > > > > think we don't have a good way to distinguish between the good cases 
> > > > > and the bad ones, so we shouldn't warn. Hopefully MS will fix their 
> > > > > CRT at some point and we can stop providing this compatibility hack 
> > > > > entirely (or start warning on it by default).
> > > > Are you sure they don't support `_Static_assert` yet? I seem to be able 
> > > > to use it fine: https://godbolt.org/z/vG47he
> > > > 
> > > > That said, this does appear to be only available in newer versions of 
> > > > MSVC, so perhaps you're correct about the diagnostic being a bit 
> > > > unhelpful. My primary concern is that use of `static_assert` in C is a 
> > > > nonconforming extension and we default to `-fms-compatibility` on 
> > > > Windows when Clang is built by MSVC. So it's not difficult to 
> > > > accidentally run into this, but the only warning we give on it with 
> > > > `-Weverything -pedantic` is how it's not compatible with C++98.
> > > > 
> > > > WDYT?
> > > I suppose one option would be to look at what version of MSVC we're 
> > > trying to be compatible with to see if that's a version that supports 
> > > `/std:c11` and only emit this diagnostic in that case, but tbh, that 
> > > feels like it'll lead to confusing diagnostic behavior (esp given that we 
> > > default to ms compatibility mode silently when you build Clang with MSVC 
> > > on Windows).
> > > 
> > > Given that MSVC does support `_Static_assert` when you enable C11 or 
> > > later language mode, I'm inclined to warn on this construct by default.
> > > 
> > > WDYT?
> > Well, it's good to see that they've made progress, but it [looks 
> > like](https://godbolt.org/z/YfEhGW) their `` still doesn't 
> > `#define static_assert`, so I think we still don't have an actionable 
> > warning we can produce here. We can't reasonably tell people to include 
> > `` (as this patch does) because that doesn't work. And it doesn't 
> > seem reasonable to tell people to use `_Static_assert` instead, if they 
> > actually have included ``. (I don't think we want to encourage 
> > people to use `_Static_assert` instead of `` + `static_assert`.)
> > 
> > So I don't think MSVC adding support for `_Static_assert` really changes 
> > anything here -- until their `` works, or we find some good way 
> > to detect whether it was properly included, this warning will fire on both 
> > correct code and incorrect code, which doesn't seem all that useful.
> >  And it doesn't seem reasonable to tell people to use _Static_assert 
> > instead, if they actually have included . (I don't think we want 
> > to encourage people to use _Static_assert instead of  + 
> > static_assert.)
> 
> Ideally, yes. But this isn't ideal -- we produce no diagnostic for this 
> nonconforming extension and that's causing pain in practice. As an example of 
> where I ran into this: I had a header file that was shared between C and 
> (mostly) C++ code and added a `static_assert` to it but forgot to add 
> `#include `. This compiled great in MSVC and clang-cl, but when 
> compiled with clang on CI is when I finally found the issue. e.g., like this: 
> https://godbolt.org/z/cs8YGb
> 
> If I had to pick between behaviors, I think I'd prefer pushing people towards 
> using `_Static_assert` even if `assert.h` is included over silently accepting 
> a nonconforming extension in pedantic mode.
> 
> Rather than trying to see what header guard was used by ``, 
> couldn't we assume that if `assert` is defined as a macro then `` 
> must have been included (or the user triggered UB and gets what they get)? So 
> the logic could be: only diagnose use of the `static_assert` (keyword) in C 
> mode if `assert` is not defined?
> 
> > We can't reasonably tell people to include  (as this patch does) 
> > because that doesn't work.
> 
> But it does (as far as the user is concerned)? In MS compatibility mode, 
> `static_assert` is 

[PATCH] D96847: [clang][cli] Store additional optimization remarks info

2021-02-17 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/include/clang/Basic/CodeGenOptions.h:306-307
 
+  // The kind of optimization remark argument on the command line.
+  RemarkKind OptimizationRemarkKind;
   /// Regular expression to select optimizations for which we should enable

Can this just be a `Kind` field in `RemarkPattern`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96847

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


[PATCH] D96716: [flang][driver] Add debug dump options

2021-02-17 Thread Faris Rehman via Phabricator via cfe-commits
FarisRehman added a comment.

In D96716#2569594 , @awarzynski wrote:

> We need `%f18` to be replaced with `%flang_fc1`, but we don't need 
> `-fsyntax-only`, right?

Makes sense thanks, I'll remove before committing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96716

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


[PATCH] D96886: [Driver] Clean up some Separate form options

2021-02-17 Thread Fangrui Song 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 rG0c2bb6b446c5: [Driver] Clean up some Separate form options 
(authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96886

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/debug-comp-dir.S
  clang/test/Driver/debug.c
  clang/test/Driver/rewrite-map-files.c
  clang/test/Driver/rewrite-map-in-diagnostics.c
  clang/test/Driver/symbol-rewriter.c
  clang/test/Driver/working-directory.c

Index: clang/test/Driver/working-directory.c
===
--- clang/test/Driver/working-directory.c
+++ clang/test/Driver/working-directory.c
@@ -8,4 +8,4 @@
 
 // CHECK_WORKS: "-coverage-notes-file" "{{[^"]+}}test{{/|}}Driver{{/|}}Inputs{{/|}}pchfile.gcno"
 // CHECK_WORKS: "-working-directory" "{{[^"]+}}test{{/|}}Driver{{/|}}Inputs"
-// CHECK_WORKS: "-fdebug-compilation-dir" "{{[^"]+}}test{{/|}}Driver{{/|}}Inputs"
+// CHECK_WORKS: "-fdebug-compilation-dir={{[^"]+}}test{{/|}}Driver{{/|}}Inputs"
Index: clang/test/Driver/symbol-rewriter.c
===
--- clang/test/Driver/symbol-rewriter.c
+++ clang/test/Driver/symbol-rewriter.c
@@ -1,21 +1,7 @@
-// RUN: %clang -frewrite-map-file %S/Inputs/rewrite.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-SINGLE
+// RUN: %clang -frewrite-map-file=%S/Inputs/rewrite.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-SINGLE
 
-// CHECK-SINGLE: "-frewrite-map-file" "{{.*[\\/]}}rewrite.map"
+// CHECK-SINGLE: "-frewrite-map-file={{.*[\\/]}}rewrite.map"
 
-// RUN: %clang -frewrite-map-file %S/Inputs/rewrite-1.map -frewrite-map-file %S/Inputs/rewrite-2.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MULTIPLE
-
-// CHECK-MULTIPLE: "-frewrite-map-file" "{{.*[\\/]}}rewrite-1.map" "-frewrite-map-file" "{{.*[\\/]}}rewrite-2.map"
-
-// RUN: %clang -frewrite-map-file=%S/Inputs/rewrite.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-SINGLE-EQ
-
-// CHECK-SINGLE-EQ: "-frewrite-map-file" "{{.*[\\/]}}rewrite.map"
-
-// RUN: %clang -frewrite-map-file=%S/Inputs/rewrite-1.map -frewrite-map-file=%S/Inputs/rewrite-2.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MULTIPLE-EQ
-
-// CHECK-MULTIPLE-EQ: "-frewrite-map-file" "{{.*[\\/]}}rewrite-1.map"
-// CHECK-MULTIPLE-EQ: "-frewrite-map-file" "{{.*[\\/]}}rewrite-2.map"
-
-// RUN: %clang -frewrite-map-file %S/Inputs/rewrite-1.map -frewrite-map-file=%S/Inputs/rewrite-2.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MIXED
-
-// CHECK-MIXED: "-frewrite-map-file" "{{.*[\\/]}}rewrite-1.map" "-frewrite-map-file" "{{.*[\\/]}}rewrite-2.map"
+// RUN: %clang -frewrite-map-file=%S/Inputs/rewrite-1.map -frewrite-map-file=%S/Inputs/rewrite-2.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MULTIPLE
 
+// CHECK-MULTIPLE: "-frewrite-map-file={{.*[\\/]}}rewrite-1.map" "-frewrite-map-file={{.*[\\/]}}rewrite-2.map"
Index: clang/test/Driver/rewrite-map-in-diagnostics.c
===
--- clang/test/Driver/rewrite-map-in-diagnostics.c
+++ clang/test/Driver/rewrite-map-in-diagnostics.c
@@ -1,7 +1,7 @@
 // RUN: rm -rf "%t"
 // RUN: mkdir -p "%t"
 // RUN: env TMPDIR="%t" TEMP="%t" TMP="%t" RC_DEBUG_OPTION=1 \
-// RUN: not %clang -fsyntax-only -frewrite-map-file %p/Inputs/rewrite.map %s 2>&1 \
+// RUN: not %clang -fsyntax-only -frewrite-map-file=%p/Inputs/rewrite.map %s 2>&1 \
 // RUN:   | FileCheck %s
 
 #pragma clang __debug parser_crash
Index: clang/test/Driver/rewrite-map-files.c
===
--- clang/test/Driver/rewrite-map-files.c
+++ clang/test/Driver/rewrite-map-files.c
@@ -1,2 +1,2 @@
-// RUN: %clang -### -frewrite-map-file %t.map -c %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -### -frewrite-map-file=%t.map -c %s -o /dev/null 2>&1 | FileCheck %s
 // CHECK: error: no such file or directory:
Index: clang/test/Driver/debug.c
===
--- clang/test/Driver/debug.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// RUN: cd %S && %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-PWD %s
-// CHECK-PWD: {{"-fdebug-compilation-dir" ".*Driver.*"}}
Index: clang/test/Driver/debug-comp-dir.S
===
--- clang/test/Driver/debug-comp-dir.S
+++ clang/test/Driver/debug-comp-dir.S
@@ -1,2 +1,3 @@
 // RUN: cd %S && %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-PWD %s
-// CHECK-PWD: {{"-fdebug-compilation-dir" ".*Driver.*"}}
+// RUN: cd %S && %clang -x c -### -g %s -c 2>&1 | FileCheck 

[clang] 0c2bb6b - [Driver] Clean up some Separate form options

2021-02-17 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-02-17T13:49:41-08:00
New Revision: 0c2bb6b446c584ab8a8b1231a136f657fa070e47

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

LOG: [Driver] Clean up some Separate form options

Drop the `Separate` form of `-fmodule-name X`, `-fprofile-remapping-file X`, 
and `-frewrite-map-file X`.
To the best of my knowledge they are not used. Their conventional Joined forms 
(`-fFOO=`) should be used instead.

`-fdebug-compilation-dir X` is used in several places, e.g.  
chromium/infra/goma.
It is also advertised in 
http://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html
So we keep it but make the EQ form canonical and the Separate form an alias.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/clang_f_opts.c
clang/test/Driver/debug-comp-dir.S
clang/test/Driver/rewrite-map-files.c
clang/test/Driver/rewrite-map-in-diagnostics.c
clang/test/Driver/symbol-rewriter.c
clang/test/Driver/working-directory.c

Removed: 
clang/test/Driver/debug.c



diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0451fa829c00..13d3dcd868ab 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1096,13 +1096,13 @@ def fauto_profile_accurate : Flag<["-"], 
"fauto-profile-accurate">,
 Group, Alias;
 def fno_auto_profile_accurate : Flag<["-"], "fno-auto-profile-accurate">,
 Group, Alias;
-def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">,
+def fdebug_compilation_dir_EQ : Joined<["-"], "fdebug-compilation-dir=">,
 Group, Flags<[CC1Option, CC1AsOption, CoreOption]>,
-HelpText<"The compilation directory to embed in the debug info.">,
+HelpText<"The compilation directory to embed in the debug info">,
 MarshallingInfoString>;
-def fdebug_compilation_dir_EQ : Joined<["-"], "fdebug-compilation-dir=">,
+def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">,
 Group, Flags<[CC1Option, CC1AsOption, CoreOption]>,
-Alias;
+Alias;
 defm debug_info_for_profiling : BoolFOption<"debug-info-for-profiling",
   CodeGenOpts<"DebugInfoForProfiling">, DefaultFalse,
   PosFlag,
@@ -1122,8 +1122,6 @@ def fprofile_remapping_file_EQ : Joined<["-"], 
"fprofile-remapping-file=">,
 Group, Flags<[CC1Option, CoreOption]>, MetaVarName<"">,
 HelpText<"Use the remappings described in  to match the profile data 
against names in the program">,
 MarshallingInfoString>;
-def fprofile_remapping_file : Separate<["-"], "fprofile-remapping-file">,
-Group, Flags<[CoreOption]>, Alias;
 defm coverage_mapping : BoolFOption<"coverage-mapping",
   CodeGenOpts<"CoverageMapping">, DefaultFalse,
   PosFlag,
@@ -1654,13 +1652,10 @@ defm delete_null_pointer_checks : 
BoolFOption<"delete-null-pointer-checks",
   PosFlag,
   BothFlags<[CoreOption]>>;
 
-def frewrite_map_file : Separate<["-"], "frewrite-map-file">,
-Group,
-Flags<[ NoXarchOption, CC1Option ]>,
-
MarshallingInfoStringVector>;
 def frewrite_map_file_EQ : Joined<["-"], "frewrite-map-file=">,
Group,
-   Flags<[NoXarchOption]>;
+   Flags<[NoXarchOption, CC1Option]>,
+   
MarshallingInfoStringVector>;
 
 defm use_line_directives : BoolFOption<"use-line-directives",
   PreprocessorOutputOpts<"UseLineDirectives">, DefaultFalse,
@@ -1984,7 +1979,6 @@ def fmodule_name_EQ : Joined<["-"], "fmodule-name=">, 
Group,
   Flags<[NoXarchOption,CC1Option]>, MetaVarName<"">,
   HelpText<"Specify the name of the module to build">,
   MarshallingInfoString>;
-def fmodule_name : Separate<["-"], "fmodule-name">, Alias;
 def fmodule_implementation_of : Separate<["-"], "fmodule-implementation-of">,
   Flags<[CC1Option]>, Alias;
 def fsystem_module : Flag<["-"], "fsystem-module">, Flags<[CC1Option]>,

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 02f4f478031f..f684ea7c93f7 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1484,8 +1484,7 @@ void Driver::generateCompilationDiagnostics(
 }
   }
 
-  for (const auto  : C.getArgs().filtered(options::OPT_frewrite_map_file,
-options::OPT_frewrite_map_file_EQ))
+  for (const auto  : C.getArgs().filtered(options::OPT_frewrite_map_file_EQ))
 Diag(clang::diag::note_drv_command_failed_diag_msg) << A->getValue();
 
   

[PATCH] D57835: Fix -ftime-report with -x ir

2021-02-17 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

ping


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

https://reviews.llvm.org/D57835

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


[PATCH] D96716: [flang][driver] Add debug dump options

2021-02-17 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D96716#2569160 , @FarisRehman wrote:

> They do require updating as `-fdebug-dump-symbol` and 
> `-fdebug-dump-parse-tree` are otherwise not tested by the new driver in this 
> patch.

Apologies, I wasn't clear (realized after submitting). We need `%f18` to be 
replaced with `%flang_fc1`, but we don't need `-fsyntax-only`, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96716

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


[PATCH] D96147: [SEMA] Added warn_decl_shadow support for structured bindings

2021-02-17 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thanks!




Comment at: clang/lib/Sema/SemaDecl.cpp:7571
+  NamedDecl *ShadowedDecl = R.getFoundDecl();
+  return isa(ShadowedDecl) || isa(ShadowedDecl)
+ ? ShadowedDecl

rsmith wrote:
> I think we should also warn if a `BindingDecl` shadows another `BindingDecl`, 
> or if a `VarDecl` shadows a `BindingDecl`.
`isa(ShadowedDecl) || isa(ShadowedDecl)` can be simplified 
to `isa(ShadowedDecl)`.



Comment at: clang/lib/Sema/SemaDecl.cpp:7571-7573
+  return isa(ShadowedDecl) || isa(ShadowedDecl)
+ ? ShadowedDecl
+ : nullptr;

I think we should also warn if a `BindingDecl` shadows another `BindingDecl`, 
or if a `VarDecl` shadows a `BindingDecl`.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:872-874
+// Diagnose shadowed variables if this isn't a redeclaration.
+if (ShadowedDecl && !D.isRedeclaration())
+  CheckShadow(BD, ShadowedDecl, Previous);

Should this be an `else` for the `if (!Previous.empty())` below? Do we get two 
diagnostics for:

```
int a;
struct X { int n; };
auto [a] = X();
```

(one for shadowing and one for redefinition)?



Comment at: clang/test/SemaCXX/warn-shadow.cpp:274
+#ifndef USE_STD
+// Machinery required for custom structured bindings decomposition.
+typedef unsigned long size_t;

It doesn't seem important to test different kinds of bindings here, since the 
shadowing check for bindings doesn't depend on how we perform the 
decomposition. So I'd suggest you simplify this test by using only built-in 
bindings, eg:

```
namespace structured_binding_tests {
int x; // expected-note {{previous declaration is here}}
int y; // expected-note {{previous declaration is here}}
struct S { int a, b; };

void test1() {
  const auto [x, y] = S(); // expected-warning 2 {{declaration shadows a 
variable in namespace 'structured_binding_tests'}}
}
```


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

https://reviews.llvm.org/D96147

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


[PATCH] D96896: [clang-format] Respect spaces in line comment section without an active column limit

2021-02-17 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: MyDeveloperDay, curdeius.
HazardyKnusperkeks added a project: clang-format.
HazardyKnusperkeks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Before line comments were not touched at all with `ColumnLimit == 0`, so this 
is a real change. But at least for me it was unexpected that the comments were 
not fixed with `ColumnLimit == 0`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96896

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/unittests/Format/FormatTestComments.cpp

Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -3793,6 +3793,189 @@
"int i;//  A Comment to be moved\n"
"  //   with indent\n",
Style));
+
+  Style = getLLVMStyleWithColumns(0);
+  EXPECT_EQ("// Free comment without space\n"
+"\n"
+"//   Free comment with 3 spaces\n"
+"\n"
+"/// Free Doxygen without space\n"
+"\n"
+"///   Free Doxygen with 3 spaces\n"
+"\n"
+"/// A Doxygen Comment with a nested list:\n"
+"/// - Foo\n"
+"/// - Bar\n"
+"///   - Baz\n"
+"///   - End\n"
+"/// of the inner list\n"
+"///   .\n"
+"/// .\n"
+"\n"
+"namespace Foo {\n"
+"bool bar(bool b) {\n"
+"  bool ret1 = true; ///< Doxygenstyle without space\n"
+"  bool ret2 = true; ///<   Doxygenstyle with 3 spaces\n"
+"  if (b) {\n"
+"// Foo\n"
+"\n"
+"//   In function comment\n"
+"ret2 = false;\n"
+"  } // End of if\n"
+"\n"
+"  //  if (ret1) {\n"
+"  //return ret2;\n"
+"  //  }\n"
+"\n"
+"  // if (ret1) {\n"
+"  //   return ret2;\n"
+"  // }\n"
+"\n"
+"  return ret1 && ret2;\n"
+"}\n"
+"} // namespace Foo\n"
+"\n"
+"namespace Bar {\n"
+"int foo();\n"
+"} //  namespace Bar\n"
+"//@Nothing added because of the non ascii char\n"
+"\n"
+"//@  Nothing removed because of the non ascii char\n"
+"\n"
+"//  Comment to move to the left\n"
+"// But not this?\n"
+"//  @but this\n"
+"\n"
+"// Comment to move to the right\n"
+"//@ this stays\n"
+"\n"
+"//} will not move\n"
+"\n"
+"// vv will only move\n"
+"// } if the line above does\n",
+format(Code, Style));
+
+  Style.SpacesInLineCommentPrefix = {0, 0};
+  EXPECT_EQ("//Free comment without space\n"
+"\n"
+"//Free comment with 3 spaces\n"
+"\n"
+"///Free Doxygen without space\n"
+"\n"
+"///Free Doxygen with 3 spaces\n"
+"\n"
+"///A Doxygen Comment with a nested list:\n"
+"///- Foo\n"
+"///- Bar\n"
+"///  - Baz\n" // Here we keep the relative indentation
+"///  - End\n"
+"///of the inner list\n"
+"///  .\n"
+"///.\n"
+"\n"
+"namespace Foo {\n"
+"bool bar(bool b) {\n"
+"  bool ret1 = true; ///= ColumnLimit)
+  if (ColumnLimit != 0 && Current.UnbreakableTailLength >= ColumnLimit)
 return {0, false};
   // ColumnWidth was already accounted into State.Column before calling
   // breakProtrudingToken.
@@ -2040,158 +2040,165 @@
 // compressed.
 bool TryReflow = Reflow;
 // Break the current token until we can fit the rest of the line.
-while (ContentStartColumn + RemainingTokenColumns > ColumnLimit) {
-  LLVM_DEBUG(llvm::dbgs() << "Over limit, need: "
-  << (ContentStartColumn + RemainingTokenColumns)
-  << ", space: " << ColumnLimit
-  << ", reflown prefix: " << ContentStartColumn
-  << ", offset in line: " << TailOffset << "\n");
-  // If the current token doesn't fit, find the latest possible split in the
-  // current line so that breaking at it will be under the column limit.
-  // FIXME: Use the earliest possible split while reflowing to correctly
-  // compress whitespace within a line.
-  BreakableToken::Split Split =
-  Token->getSplit(LineIndex, TailOffset, ColumnLimit,
-  ContentStartColumn, 

[PATCH] D96512: [PowerPC] Add option for ROP Protection

2021-02-17 Thread Stefan Pintilie via Phabricator via cfe-commits
stefanp updated this revision to Diff 324408.
stefanp added a comment.

Added missing FeatureROPProtection to P8AdditionalFeatures.

The P9  and P10  
features list will inherit from the P8  list.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96512

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Driver/ppc-mrop-protection-support-check.c
  clang/test/Preprocessor/init-ppc64.c
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h
  llvm/test/CodeGen/PowerPC/future-check-features.ll

Index: llvm/test/CodeGen/PowerPC/future-check-features.ll
===
--- llvm/test/CodeGen/PowerPC/future-check-features.ll
+++ llvm/test/CodeGen/PowerPC/future-check-features.ll
@@ -1,7 +1,7 @@
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma \
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protection \
 ; RUN:   -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
 ; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma \
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protection \
 ; RUN:   -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \
 ; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
 
Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -112,6 +112,7 @@
   bool HasPrefixInstrs;
   bool HasPCRelativeMemops;
   bool HasMMA;
+  bool HasROPProtection;
   bool HasFCPSGN;
   bool HasFSQRT;
   bool HasFRE, HasFRES, HasFRSQRTE, HasFRSQRTES;
@@ -273,6 +274,7 @@
   bool hasPrefixInstrs() const { return HasPrefixInstrs; }
   bool hasPCRelativeMemops() const { return HasPCRelativeMemops; }
   bool hasMMA() const { return HasMMA; }
+  bool hasROPProtection() const { return HasROPProtection; }
   bool pairedVectorMemops() const { return PairedVectorMemops; }
   bool hasMFOCRF() const { return HasMFOCRF; }
   bool hasISEL() const { return HasISEL; }
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -87,6 +87,7 @@
   HasP9Vector = false;
   HasP9Altivec = false;
   HasMMA = false;
+  HasROPProtection = false;
   HasP10Vector = false;
   HasPrefixInstrs = false;
   HasPCRelativeMemops = false;
Index: llvm/lib/Target/PowerPC/PPC.td
===
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -252,6 +252,9 @@
   "Enable MMA instructions",
   [FeatureP8Vector, FeatureP9Altivec,
FeaturePairedVectorMemops]>;
+def FeatureROPProtection :
+  SubtargetFeature<"rop-protection", "HasROPProtection", "false",
+   "Add ROP protection">;
 
 def FeaturePredictableSelectIsExpensive :
   SubtargetFeature<"predictable-select-expensive",
@@ -320,7 +323,8 @@
  FeatureDirectMove,
  FeatureICBT,
  FeaturePartwordAtomic,
- FeaturePredictableSelectIsExpensive
+ FeaturePredictableSelectIsExpensive,
+ FeatureROPProtection
 ];
 
   list P8SpecificFeatures = [FeatureAddiLoadFusion,
Index: clang/test/Preprocessor/init-ppc64.c
===
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -566,6 +566,7 @@
 // PPCPWR8-NOT:#define _ARCH_PWR6X 1
 // PPCPWR8:#define _ARCH_PWR7 1
 // PPCPWR8:#define _ARCH_PWR8 1
+// PPCPWR8-NOT:#define __ROP_PROTECTION__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power8 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCPOWER8 %s
 //
@@ -583,6 +584,7 @@
 // PPCPOWER8-NOT:#define _ARCH_PWR6X 1
 // PPCPOWER8:#define _ARCH_PWR7 1
 // PPCPOWER8:#define _ARCH_PWR8 1
+// PPCPOWER8-NOT:#define __ROP_PROTECTION__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr9 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCPWR9 %s
 //
@@ -597,6 +599,7 @@
 // PPCPWR9-NOT:#define _ARCH_PWR6X 1
 // PPCPWR9:#define _ARCH_PWR7 1
 // PPCPWR9:#define _ARCH_PWR9 1
+// PPCPWR9-NOT:#define __ROP_PROTECTION__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power9 -fno-signed-char < /dev/null | FileCheck 

[PATCH] D96760: [clang-format] Suppress diagnostics on second parse

2021-02-17 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 324407.
HazardyKnusperkeks marked an inline comment as done.
HazardyKnusperkeks added a comment.

Added DiagHandlerCtxt.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96760

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp

Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1394,8 +1394,9 @@
 }
 
 std::error_code parseConfiguration(llvm::MemoryBufferRef Config,
-   FormatStyle *Style,
-   bool AllowUnknownOptions) {
+   FormatStyle *Style, bool AllowUnknownOptions,
+   llvm::SourceMgr::DiagHandlerTy DiagHandler,
+   void *DiagHandlerCtxt) {
   assert(Style);
   FormatStyle::LanguageKind Language = Style->Language;
   assert(Language != FormatStyle::LK_None);
@@ -1403,7 +1404,8 @@
 return make_error_code(ParseError::Error);
   Style->StyleSet.Clear();
   std::vector Styles;
-  llvm::yaml::Input Input(Config);
+  llvm::yaml::Input Input(Config, /*Ctxt=*/nullptr, DiagHandler,
+  DiagHandlerCtxt);
   // DocumentListTraits> uses the context to get default
   // values for the fields, keys for which are missing from the configuration.
   // Mapping also uses the context to get the language to find the correct
@@ -2990,6 +2992,8 @@
   FilesToLookFor.push_back(".clang-format");
   FilesToLookFor.push_back("_clang-format");
 
+  auto dropDiagnosticHandler = [](const llvm::SMDiagnostic &, void *) {};
+
   for (StringRef Directory = Path; !Directory.empty();
Directory = llvm::sys::path::parent_path(Directory)) {
 
@@ -3034,7 +3038,8 @@
   LLVM_DEBUG(llvm::dbgs() << "Applying child configurations\n");
 
   for (const auto& MemBuf : llvm::reverse(ChildFormatTextToApply)){
-auto Ec = parseConfiguration(*MemBuf, , AllowUnknownOptions);
+auto Ec = parseConfiguration(*MemBuf, , AllowUnknownOptions,
+ dropDiagnosticHandler);
 // It was already correctly parsed.
 assert(!Ec);
 static_cast(Ec);
@@ -3069,8 +3074,9 @@
 LLVM_DEBUG(llvm::dbgs()
<< "Applying child configuration on fallback style\n");
 
-auto Ec = parseConfiguration(*ChildFormatTextToApply.front(),
- , AllowUnknownOptions);
+auto Ec =
+parseConfiguration(*ChildFormatTextToApply.front(), ,
+   AllowUnknownOptions, dropDiagnosticHandler);
 // It was already correctly parsed.
 assert(!Ec);
 static_cast(Ec);
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -19,6 +19,7 @@
 #include "clang/Tooling/Inclusions/IncludeStyle.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/Regex.h"
+#include "llvm/Support/SourceMgr.h"
 #include 
 
 namespace llvm {
@@ -3269,9 +3270,11 @@
 private:
   FormatStyleSet StyleSet;
 
-  friend std::error_code parseConfiguration(llvm::MemoryBufferRef Config,
-FormatStyle *Style,
-bool AllowUnknownOptions);
+  friend std::error_code
+  parseConfiguration(llvm::MemoryBufferRef Config, FormatStyle *Style,
+ bool AllowUnknownOptions,
+ llvm::SourceMgr::DiagHandlerTy DiagHandler,
+ void *DiagHandlerCtxt);
 };
 
 /// Returns a format style complying with the LLVM coding standards:
@@ -3329,9 +3332,13 @@
 ///
 /// If AllowUnknownOptions is true, no errors are emitted if unknown
 /// format options are occured.
-std::error_code parseConfiguration(llvm::MemoryBufferRef Config,
-   FormatStyle *Style,
-   bool AllowUnknownOptions = false);
+///
+/// If set all diagnostics are emitted through the DiagHandler.
+std::error_code
+parseConfiguration(llvm::MemoryBufferRef Config, FormatStyle *Style,
+   bool AllowUnknownOptions = false,
+   llvm::SourceMgr::DiagHandlerTy DiagHandler = nullptr,
+   void *DiagHandlerCtx = nullptr);
 
 /// Like above but accepts an unnamed buffer.
 inline std::error_code parseConfiguration(StringRef Config, FormatStyle *Style,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96832: [Clang][Attributes] Allow not_tail_called attribute to be applied to virtual function.

2021-02-17 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

In D96832#2568257 , @aaron.ballman 
wrote:

> It was explicitly disallowed in the initial patch: 
> https://reviews.llvm.org/D12922 and the original author said "I'm still 
> trying to figure out the best way to handle c++ virtual functions: this 
> attribute is not very useful for someone who is looking for a way to reliably 
> prevent tail-call to a virtual function." and "I made this change because 
> this attribute isn't useful when the compiler cannot resolve the function 
> call statically at compile time and it isn't important for the use case I 
> have." Has this situation changed in the backend?

Oh, I didn't see that. But when I tested `not_tail_called` on normal functions, 
 it seems like not working(https://godbolt.org/z/znr5b5, `f1` is marked as 
`not_tail_called`, it still get inlined). Or, I misunderstand how to use it 
properly?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96832

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


[PATCH] D96802: [Clang] Add proper target checks for SwiftAsync convention.

2021-02-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

The TargetInfo classes are already target-architecture-specific, so it's 
somewhat strange for them all to funnel to a single function that then 
immediately switches on the target architecture.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96802

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


[PATCH] D95753: [Coverage] Store compilation dir separately in coverage mapping

2021-02-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1131
   NegFlag, 
BothFlags<[CoreOption]>>;
+def fcoverage_compilation_dir : Separate<["-"], "fcoverage-compilation-dir">,
+Group, Flags<[CC1Option, CC1AsOption, CoreOption]>,

phosek wrote:
> MaskRay wrote:
> > Using fcoverage_compilation_dir_EQ for both driver option and CC1 option is 
> > preferred.
> > 
> > Can you drop fcoverage_compilation_dir ?
> I've been following `-fdebug-compilation-dir` which supports both variants. 
> Should we drop `-fdebug-compilation-dir` as well? I'd like to keep these 
> consistent.
We cannot drop the driver option `-fdebug-compilation-dir X` now for 
compatibility reasons: D96886.

Newer options should stick with the convention, not adding more Separate< forms.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95753

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


[PATCH] D96113: [ASTMatchers] Fix hasParent while ignoring unwritten nodes

2021-02-17 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: clang/lib/AST/ParentMapContext.cpp:174
+{
+  auto AncestorNodes = matchParents(
+  ParentList, this);

aaron.ballman wrote:
> Not needing to be solved in this patch, but do we eventually need to do 
> something for `ObjCForCollectionStmt` the same as we do for `CXXForRangeStmt`?
Perhaps. I'm not familiar with it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96113

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


[PATCH] D96113: [ASTMatchers] Fix hasParent while ignoring unwritten nodes

2021-02-17 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 324396.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96113

Files:
  clang/include/clang/AST/ParentMapContext.h
  clang/lib/AST/ParentMapContext.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -2933,6 +2933,37 @@
 EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
 EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
   }
+  {
+auto M = ifStmt(hasParent(compoundStmt(hasParent(cxxForRangeStmt();
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_TRUE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+  {
+auto M = cxxForRangeStmt(
+has(varDecl(hasName("i"), hasParent(cxxForRangeStmt();
+EXPECT_FALSE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_TRUE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+  {
+auto M = cxxForRangeStmt(hasDescendant(varDecl(
+hasName("i"), hasParent(declStmt(hasParent(cxxForRangeStmt()));
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+  {
+auto M = cxxForRangeStmt(hasRangeInit(declRefExpr(
+to(varDecl(hasName("arr"))), hasParent(cxxForRangeStmt();
+EXPECT_FALSE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_TRUE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+
+  {
+auto M = cxxForRangeStmt(hasRangeInit(declRefExpr(
+to(varDecl(hasName("arr"))), hasParent(varDecl(hasParent(declStmt(
+ hasParent(cxxForRangeStmt();
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
 
   Code = R"cpp(
   struct Range {
@@ -3035,6 +3066,15 @@
 matchesConditionally(Code, traverse(TK_IgnoreUnlessSpelledInSource, M),
  true, {"-std=c++20"}));
   }
+  {
+auto M = cxxForRangeStmt(hasInitStatement(declStmt(
+hasSingleDecl(varDecl(hasName("a"))), hasParent(cxxForRangeStmt();
+EXPECT_TRUE(
+matchesConditionally(Code, traverse(TK_AsIs, M), true, {"-std=c++20"}));
+EXPECT_TRUE(
+matchesConditionally(Code, traverse(TK_IgnoreUnlessSpelledInSource, M),
+ true, {"-std=c++20"}));
+  }
 
   Code = R"cpp(
   struct Range {
@@ -3511,6 +3551,20 @@
forFunction(functionDecl(hasName("func13"))),
   langCxx20OrLater()));
 
+  EXPECT_TRUE(matches(Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   compoundStmt(hasParent(lambdaExpr(forFunction(
+   functionDecl(hasName("func13"))),
+  langCxx20OrLater()));
+
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   templateTypeParmDecl(hasName("TemplateType"),
+hasParent(lambdaExpr(forFunction(
+functionDecl(hasName("func14"))),
+  langCxx20OrLater()));
+
   EXPECT_TRUE(matches(
   Code,
   traverse(TK_IgnoreUnlessSpelledInSource,
@@ -3635,6 +3689,16 @@
 matchesConditionally(Code, traverse(TK_IgnoreUnlessSpelledInSource, M),
  true, {"-std=c++20"}));
   }
+  {
+auto M = cxxRewrittenBinaryOperator(
+hasLHS(expr(hasParent(cxxRewrittenBinaryOperator(,
+hasRHS(expr(hasParent(cxxRewrittenBinaryOperator();
+EXPECT_FALSE(
+matchesConditionally(Code, traverse(TK_AsIs, M), true, {"-std=c++20"}));
+EXPECT_TRUE(
+matchesConditionally(Code, traverse(TK_IgnoreUnlessSpelledInSource, M),
+ true, {"-std=c++20"}));
+  }
   {
 EXPECT_TRUE(matchesConditionally(
 Code,
Index: clang/lib/AST/ParentMapContext.cpp
===
--- clang/lib/AST/ParentMapContext.cpp
+++ clang/lib/AST/ParentMapContext.cpp
@@ -49,7 +49,17 @@
   return N;
 }
 
+template 
+std::tuple
+matchParents(const DynTypedNodeList ,
+ ParentMapContext::ParentMap *ParentMap);
+
+template  struct MatchParents;
+
 class ParentMapContext::ParentMap {
+
+  template  friend struct ::MatchParents;
+
   /// Contains parents of a node.
   using ParentVector = llvm::SmallVector;
 
@@ -117,11 +127,72 @@
 if (Node.getNodeKind().hasPointerIdentity()) {
   auto ParentList =
   getDynNodeFromMap(Node.getMemoizationData(), PointerParents);
- 

[clang] e741916 - Basic block sections should enable not function sections implicitly.

2021-02-17 Thread Sriraman Tallam via cfe-commits

Author: Sriraman Tallam
Date: 2021-02-17T12:37:50-08:00
New Revision: e74191633036905388245818f54553813c880f83

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

LOG: Basic block sections should enable not function sections implicitly.

Basic block sections enables function sections implicitly, this is not needed
and is inefficient with "=list" option.

We had basic block sections enable function sections implicitly in clang. This
is particularly inefficient with "=list" option as it places functions that do
not have any basic block sections in separate sections. This causes unnecessary
object file overhead for large applications.

This patch disables this implicit behavior. It only creates function sections
for those functions that require basic block sections.

This patch is the second of two patches and this patch removes the implicit
enabling of function sections with basic block sections in clang.

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/basic-block-sections.c

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index f92964732688..a49c97860324 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1383,8 +1383,7 @@ void CompilerInvocation::GenerateCodeGenArgs(
   GenerateArg(Args, OPT_ftime_report, SA);
   }
 
-  if (Opts.FunctionSections &&
-  (Opts.BBSections == "none" || Opts.BBSections == "labels"))
+  if (Opts.FunctionSections)
 GenerateArg(Args, OPT_ffunction_sections, SA);
 
   if (Opts.PrepareForLTO && !Opts.PrepareForThinLTO)
@@ -1678,9 +1677,7 @@ bool 
CompilerInvocation::ParseCodeGenArgsImpl(CodeGenOptions ,
   }
 
   // Basic Block Sections implies Function Sections.
-  Opts.FunctionSections =
-  Args.hasArg(OPT_ffunction_sections) ||
-  (Opts.BBSections != "none" && Opts.BBSections != "labels");
+  Opts.FunctionSections = Args.hasArg(OPT_ffunction_sections);
 
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
   Opts.PrepareForThinLTO = false;

diff  --git a/clang/test/CodeGen/basic-block-sections.c 
b/clang/test/CodeGen/basic-block-sections.c
index ee0dc90e2d02..a61b8dd4ac37 100644
--- a/clang/test/CodeGen/basic-block-sections.c
+++ b/clang/test/CodeGen/basic-block-sections.c
@@ -32,10 +32,9 @@ int another(int a) {
 // BB_WORLD: world:
 // BB_WORLD: .section .text.world,"ax",@progbits,unique
 // BB_WORLD: world.__part.1:
-// BB_WORLD: .section .text.another,"ax",@progbits
-// BB_ALL: .section .text.another,"ax",@progbits,unique
+// BB_ALL: .section .text.another,"ax",@progbits
 // BB_ALL: another.__part.1:
-// BB_LIST-NOT: .section .text.another,"ax",@progbits,unique
+// BB_LIST-NOT: .section .text.another,"ax",@progbits
 // BB_LIST: another:
 // BB_LIST-NOT: another.__part.1:
 //



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


[PATCH] D96803: EntryExitInstrumenter: Move to a module pass and enable at all optimization levels (PR49143)

2021-02-17 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D96803#2568179 , @zatrazz wrote:

> In D96803#2566322 , @aeubanks wrote:
>
>> why is this now a module pass?
>
> Mainly to avoid the default rule from new pass manager to *not* apply any 
> FunctionPass for optnone (which is the main issue for PR49143). Is there a 
> better way to accomplish it? I noted also that 
> createModuleToFunctionPassAdaptor basically creates a adaptor that applies 
> the pass to all function on the module.

It's always good to make the pass as specific as possible (e.g. prefer a 
function pass rather than a module pass) so it doesn't have to worry about 
infra. For example, just iterating over functions doesn't skip declarations.

The whole point of `isRequired()` is to make the pass always run when it's 
added to the pipeline, so making it a module pass shouldn't be necessary with 
that line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96803

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


[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

2021-02-17 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D86465#2569403 , @ASDenysPetrov 
wrote:

> @vsavchenko 
> Hi, I actually want this patch goes developing and be loaded. It's really the 
> worth one. Is it abandoned?

Hi, nope.  Just got postponed, I'll address the review comments soon!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

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


[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

2021-02-17 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@vsavchenko 
Hi, I actually want this patch goes developing and be loaded. It's really the 
worth one. Is it abandoned?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

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


[PATCH] D96848: [clang][cli] Don't emit manufactured warnings

2021-02-17 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2347-2353
+// This warning was manufactured, don't put it on the command line.
+if (Warning == "no-stdlibcxx-not-found" && T.isOSDarwin() &&
+DashX.isPreprocessed())
+  continue;
+// This warning was manufactured, don't put it on the command line.
+if (Warning == "spir-compat" && T.isSPIR())
+  continue;

It seems reasonable to skip generating them if they're implied by other 
command-line options, but I'm not sure "manufactured" is the right word to use 
as a distinguishing characteristic. The entire CompilerInvocation could have 
been created programmatically. I suggest instead saying the warning flag is 
implied by the other command-line options.

Also, note that when created programmatically, one could have pushed 
`stdlibcxx-not-found` *after* pushing `no-stdlibcxx-not-found`. Since that's 
impossible to recreate, maybe there should be an assertion to catch this? 
Alternatively, should this kind of imply-diagnostic-options logic be moved to 
the driver?

Relatedly, unlike most command-line options, GenerateDiagnosticArgs is not 
canonicalizing the options. For example, if `-Wabc` implies `-Wdef`, it'd be 
nice to generate just `-Wabc` from initial command-lines of either `-Wabc 
-Wdef` or `-Wdef -Wabc` / to drop the first of `-Wno-abc -Wabc` / etc.

IMO, something akin to an initial DiagnosticsEngine::DiagState (likely renamed) 
could be stored in DiagnosticOptions (effectively, the resulting state from 
calling ProcessWarningOptions). Parsing could translate command-line options to 
this initial state. The state could be modified programmatically; it'd also be 
used to initialize DiagnosticsEngine. Generating command-line options would 
emit a canonical set of options that would recreate the state. But that's a 
pretty big refactoring, and I think it's okay to make progress without that.

As an initial fix, this is probably fine, but I think the comments and/or 
FIXMEs should acknowledge that it's a bit fragile and point in a more sound / 
less fragile direction (doesn't have to be my suggestion).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96848

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


[PATCH] D96886: [Driver] Clean up some Separate form options

2021-02-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 324390.
MaskRay added a comment.

Move HelpText to EQ.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96886

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/debug-comp-dir.S
  clang/test/Driver/debug.c
  clang/test/Driver/rewrite-map-files.c
  clang/test/Driver/rewrite-map-in-diagnostics.c
  clang/test/Driver/symbol-rewriter.c
  clang/test/Driver/working-directory.c

Index: clang/test/Driver/working-directory.c
===
--- clang/test/Driver/working-directory.c
+++ clang/test/Driver/working-directory.c
@@ -8,4 +8,4 @@
 
 // CHECK_WORKS: "-coverage-notes-file" "{{[^"]+}}test{{/|}}Driver{{/|}}Inputs{{/|}}pchfile.gcno"
 // CHECK_WORKS: "-working-directory" "{{[^"]+}}test{{/|}}Driver{{/|}}Inputs"
-// CHECK_WORKS: "-fdebug-compilation-dir" "{{[^"]+}}test{{/|}}Driver{{/|}}Inputs"
+// CHECK_WORKS: "-fdebug-compilation-dir={{[^"]+}}test{{/|}}Driver{{/|}}Inputs"
Index: clang/test/Driver/symbol-rewriter.c
===
--- clang/test/Driver/symbol-rewriter.c
+++ clang/test/Driver/symbol-rewriter.c
@@ -1,21 +1,7 @@
-// RUN: %clang -frewrite-map-file %S/Inputs/rewrite.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-SINGLE
+// RUN: %clang -frewrite-map-file=%S/Inputs/rewrite.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-SINGLE
 
-// CHECK-SINGLE: "-frewrite-map-file" "{{.*[\\/]}}rewrite.map"
+// CHECK-SINGLE: "-frewrite-map-file={{.*[\\/]}}rewrite.map"
 
-// RUN: %clang -frewrite-map-file %S/Inputs/rewrite-1.map -frewrite-map-file %S/Inputs/rewrite-2.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MULTIPLE
-
-// CHECK-MULTIPLE: "-frewrite-map-file" "{{.*[\\/]}}rewrite-1.map" "-frewrite-map-file" "{{.*[\\/]}}rewrite-2.map"
-
-// RUN: %clang -frewrite-map-file=%S/Inputs/rewrite.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-SINGLE-EQ
-
-// CHECK-SINGLE-EQ: "-frewrite-map-file" "{{.*[\\/]}}rewrite.map"
-
-// RUN: %clang -frewrite-map-file=%S/Inputs/rewrite-1.map -frewrite-map-file=%S/Inputs/rewrite-2.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MULTIPLE-EQ
-
-// CHECK-MULTIPLE-EQ: "-frewrite-map-file" "{{.*[\\/]}}rewrite-1.map"
-// CHECK-MULTIPLE-EQ: "-frewrite-map-file" "{{.*[\\/]}}rewrite-2.map"
-
-// RUN: %clang -frewrite-map-file %S/Inputs/rewrite-1.map -frewrite-map-file=%S/Inputs/rewrite-2.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MIXED
-
-// CHECK-MIXED: "-frewrite-map-file" "{{.*[\\/]}}rewrite-1.map" "-frewrite-map-file" "{{.*[\\/]}}rewrite-2.map"
+// RUN: %clang -frewrite-map-file=%S/Inputs/rewrite-1.map -frewrite-map-file=%S/Inputs/rewrite-2.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MULTIPLE
 
+// CHECK-MULTIPLE: "-frewrite-map-file={{.*[\\/]}}rewrite-1.map" "-frewrite-map-file={{.*[\\/]}}rewrite-2.map"
Index: clang/test/Driver/rewrite-map-in-diagnostics.c
===
--- clang/test/Driver/rewrite-map-in-diagnostics.c
+++ clang/test/Driver/rewrite-map-in-diagnostics.c
@@ -1,7 +1,7 @@
 // RUN: rm -rf "%t"
 // RUN: mkdir -p "%t"
 // RUN: env TMPDIR="%t" TEMP="%t" TMP="%t" RC_DEBUG_OPTION=1 \
-// RUN: not %clang -fsyntax-only -frewrite-map-file %p/Inputs/rewrite.map %s 2>&1 \
+// RUN: not %clang -fsyntax-only -frewrite-map-file=%p/Inputs/rewrite.map %s 2>&1 \
 // RUN:   | FileCheck %s
 
 #pragma clang __debug parser_crash
Index: clang/test/Driver/rewrite-map-files.c
===
--- clang/test/Driver/rewrite-map-files.c
+++ clang/test/Driver/rewrite-map-files.c
@@ -1,2 +1,2 @@
-// RUN: %clang -### -frewrite-map-file %t.map -c %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -### -frewrite-map-file=%t.map -c %s -o /dev/null 2>&1 | FileCheck %s
 // CHECK: error: no such file or directory:
Index: clang/test/Driver/debug.c
===
--- clang/test/Driver/debug.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// RUN: cd %S && %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-PWD %s
-// CHECK-PWD: {{"-fdebug-compilation-dir" ".*Driver.*"}}
Index: clang/test/Driver/debug-comp-dir.S
===
--- clang/test/Driver/debug-comp-dir.S
+++ clang/test/Driver/debug-comp-dir.S
@@ -1,2 +1,3 @@
 // RUN: cd %S && %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-PWD %s
-// CHECK-PWD: {{"-fdebug-compilation-dir" ".*Driver.*"}}
+// RUN: cd %S && %clang -x c -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-PWD %s
+// CHECK-PWD: "-fdebug-compilation-dir={{.*Driver.*}}"
Index: clang/test/Driver/clang_f_opts.c

[PATCH] D95561: [Clang] Introduce Swift async calling convention.

2021-02-17 Thread Varun Gandhi via Phabricator via cfe-commits
varungandhi-apple updated this revision to Diff 324389.
varungandhi-apple added a comment.

- Remove semantic restriction of swift_async_context being only applicable to 
swiftasynccall.
- Update target checks to make sure we only allow supported targets.
- Update doc comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95561

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/Features.def
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/CodeGen/SwiftCallingConv.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/SystemZ.h
  clang/lib/Basic/Targets/WebAssembly.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/arm-swiftcall.c
  clang/test/CodeGen/debug-info-cc.c
  clang/test/CodeGen/swift-call-conv.c
  clang/test/Sema/attr-c2x.c
  clang/test/Sema/attr-swiftcall.c
  clang/test/Sema/no_callconv.cpp
  clang/test/SemaCXX/attr-swiftcall.cpp
  clang/tools/libclang/CXType.cpp
  llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
  llvm/lib/Demangle/MicrosoftDemangle.cpp
  llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
  llvm/test/Demangle/ms-mangle.test

Index: llvm/test/Demangle/ms-mangle.test
===
--- llvm/test/Demangle/ms-mangle.test
+++ llvm/test/Demangle/ms-mangle.test
@@ -341,6 +341,9 @@
 ?swift_func@@YSXXZ
 ; CHECK: void __attribute__((__swiftcall__)) swift_func(void)
 
+?swift_async_func@@YTXXZ
+; CHECK: void __attribute__((__swiftasynccall__)) swift_async_func(void)
+
 ??$fn_tmpl@$1?extern_c_func@@YAXXZ@@YAXXZ
 ; CHECK: void __cdecl fn_tmpl< __cdecl extern_c_func(void)>(void)
 
Index: llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
===
--- llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
+++ llvm/lib/Demangle/MicrosoftDemangleNodes.cpp
@@ -110,6 +110,9 @@
   case CallingConv::Swift:
 OS << "__attribute__((__swiftcall__)) ";
 break;
+  case CallingConv::SwiftAsync:
+OS << "__attribute__((__swiftasynccall__)) ";
+break;
   default:
 break;
   }
Index: llvm/lib/Demangle/MicrosoftDemangle.cpp
===
--- llvm/lib/Demangle/MicrosoftDemangle.cpp
+++ llvm/lib/Demangle/MicrosoftDemangle.cpp
@@ -1713,6 +1713,8 @@
 return CallingConv::Vectorcall;
   case 'S':
 return CallingConv::Swift;
+  case 'T':
+return CallingConv::SwiftAsync;
   }
 
   return CallingConv::None;
Index: llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
===
--- llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
+++ llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h
@@ -67,7 +67,8 @@
   Eabi,
   Vectorcall,
   Regcall,
-  Swift, // Clang-only
+  Swift,  // Clang-only
+  SwiftAsync, // Clang-only
 };
 
 enum class ReferenceKind : uint8_t { None, LValueRef, RValueRef };
Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -664,6 +664,7 @@
   TCALLINGCONV(AAPCS_VFP);
   TCALLINGCONV(IntelOclBicc);
   TCALLINGCONV(Swift);
+  TCALLINGCONV(SwiftAsync);
   TCALLINGCONV(PreserveMost);
   TCALLINGCONV(PreserveAll);
 case CC_SpirFunction: return CXCallingConv_Unexposed;
Index: clang/test/SemaCXX/attr-swiftcall.cpp
===
--- clang/test/SemaCXX/attr-swiftcall.cpp
+++ clang/test/SemaCXX/attr-swiftcall.cpp
@@ -1,14 +1,20 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
 
 #define SWIFTCALL __attribute__((swiftcall))
+#define SWIFTASYNCCALL __attribute__((swiftasynccall))
 #define INDIRECT_RESULT __attribute__((swift_indirect_result))
 #define ERROR_RESULT __attribute__((swift_error_result))
 #define CONTEXT __attribute__((swift_context))
+#define ASYNC_CONTEXT __attribute__((swift_async_context))
 
 int notAFunction SWIFTCALL; // expected-warning {{'swiftcall' only applies to function types; type here is 'int'}}
+int notAnAsyncFunction SWIFTASYNCCALL; // expected-warning {{'swiftasynccall' only applies to function types; type here is 'int'}}
 void variadic(int x, ...) SWIFTCALL; // expected-error {{variadic function cannot use swiftcall calling convention}}
+void variadic_async(int x, ...) SWIFTASYNCCALL; // expected-error {{variadic function cannot use swiftasynccall 

[PATCH] D89870: [clangd] Drop template argument lists from completions followed by

2021-02-17 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 324386.
kbobyrev marked 4 inline comments as done.
kbobyrev added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89870

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -3114,10 +3114,13 @@
   Contains(AllOf(Labeled("Container(int Size)"),
  SnippetSuffix("<${1:typename T}>(${2:int Size})"),
  Kind(CompletionItemKind::Constructor;
-  // FIXME(kirillbobyrev): It would be nice to still produce the template
-  // snippet part: in this case it should be "<${1:typename T}>".
   EXPECT_THAT(
   completions(Context + "Container c = Cont^()", {}, Opts).Completions,
+  Contains(AllOf(Labeled("Container(int Size)"),
+ SnippetSuffix("<${1:typename T}>"),
+ Kind(CompletionItemKind::Constructor;
+  EXPECT_THAT(
+  completions(Context + "Container c = Cont^()", {}, 
Opts).Completions,
   Contains(AllOf(Labeled("Container(int Size)"),
  SnippetSuffix(""),
  Kind(CompletionItemKind::Constructor;
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -452,18 +452,51 @@
   std::string summarizeSnippet() const {
 if (IsUsingDeclaration)
   return "";
-// Suppress function argument snippets if args are already present.
-if ((Completion.Kind == CompletionItemKind::Function ||
- Completion.Kind == CompletionItemKind::Method ||
- Completion.Kind == CompletionItemKind::Constructor) &&
-NextTokenKind == tok::l_paren)
-  return "";
 auto *Snippet = onlyValue<::SnippetSuffix>();
 if (!Snippet)
   // All bundles are function calls.
   // FIXME(ibiryukov): sometimes add template arguments to a snippet, e.g.
   // we need to complete 'forward<$1>($0)'.
   return "($0)";
+// Suppress function argument snippets cursor is followed by left
+// parenthesis (and potentially arguments) or if there are potentially
+// template arguments. There are cases where it would be wrong (e.g. next
+// '<' token is a comparison rather than template argument list start) but
+// it is less common and suppressing snippet provides better UX.
+if (Completion.Kind == CompletionItemKind::Function ||
+Completion.Kind == CompletionItemKind::Method ||
+Completion.Kind == CompletionItemKind::Constructor) {
+  // Potentially followed by argument list.
+  if (NextTokenKind == tok::l_paren) {
+// If snippet contains template arguments we will emit them and drop
+// function arguments. Example:
+//
+// fu^(42) -> function(42);
+if (Snippet->front() == '<') {
+  // Find matching '>'. Snippet->find('>') will not work in cases like
+  // template >. Hence, iterate through
+  // the snippet until the angle bracket balance reaches zero.
+  unsigned Balance, Index;
+  for (Balance = 1, Index = 1; Balance && (Index != Snippet->size());
+   ++Index) {
+if (Snippet->at(Index) == '>')
+  --Balance;
+if (Snippet->at(Index) == '<')
+  ++Balance;
+  }
+  return Snippet->substr(0, Index);
+}
+return "";
+  }
+  // If there is a potential template argument list, drop snippet and just
+  // complete symbol name. Ideally, this could generate an edit that would
+  // paste function arguments after template argument list but it would be
+  // complicated. Example:
+  //
+  // fu^(42) -> function(42);
+  if (NextTokenKind == tok::less && Snippet->front() == '<')
+return "";
+}
 if (EnableFunctionArgSnippets)
   return *Snippet;
 


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -3114,10 +3114,13 @@
   Contains(AllOf(Labeled("Container(int Size)"),
  SnippetSuffix("<${1:typename T}>(${2:int Size})"),
  Kind(CompletionItemKind::Constructor;
-  // FIXME(kirillbobyrev): It would be nice to still produce the template
-  // snippet part: in this case it should be "<${1:typename T}>".
   EXPECT_THAT(
   completions(Context + 

[PATCH] D96886: [Driver] Clean up some Separate form options

2021-02-17 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Driver/Options.td:1104
 Group, Flags<[CC1Option, CC1AsOption, CoreOption]>,
 HelpText<"The compilation directory to embed in the debug info.">,
+Alias;

Should the help text move the the now-canonical _EQ form?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96886

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


[PATCH] D96888: [NFC][clang] Bump up DIAG_SIZE_SEMA for downstream diagnostics

2021-02-17 Thread Zixu Wang via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe320cf23f093: [NFC][clang] Bump up DIAG_SIZE_SEMA for 
downstream diagnostics (authored by zixuw).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96888

Files:
  clang/include/clang/Basic/DiagnosticIDs.h


Index: clang/include/clang/Basic/DiagnosticIDs.h
===
--- clang/include/clang/Basic/DiagnosticIDs.h
+++ clang/include/clang/Basic/DiagnosticIDs.h
@@ -36,7 +36,7 @@
   DIAG_SIZE_AST   =  250,
   DIAG_SIZE_COMMENT   =  100,
   DIAG_SIZE_CROSSTU   =  100,
-  DIAG_SIZE_SEMA  = 4000,
+  DIAG_SIZE_SEMA  = 4500,
   DIAG_SIZE_ANALYSIS  =  100,
   DIAG_SIZE_REFACTORING   = 1000,
 };


Index: clang/include/clang/Basic/DiagnosticIDs.h
===
--- clang/include/clang/Basic/DiagnosticIDs.h
+++ clang/include/clang/Basic/DiagnosticIDs.h
@@ -36,7 +36,7 @@
   DIAG_SIZE_AST   =  250,
   DIAG_SIZE_COMMENT   =  100,
   DIAG_SIZE_CROSSTU   =  100,
-  DIAG_SIZE_SEMA  = 4000,
+  DIAG_SIZE_SEMA  = 4500,
   DIAG_SIZE_ANALYSIS  =  100,
   DIAG_SIZE_REFACTORING   = 1000,
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e320cf2 - [NFC][clang] Bump up DIAG_SIZE_SEMA for downstream diagnostics

2021-02-17 Thread Zixu Wang via cfe-commits

Author: Zixu Wang
Date: 2021-02-17T11:54:43-08:00
New Revision: e320cf23f0939307bca54f06039b71fcc2bffa85

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

LOG: [NFC][clang] Bump up DIAG_SIZE_SEMA for downstream diagnostics

Bump DIAG_SIZE_SEMA up by 500 to accommodate extra downstream diagnostics

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticIDs.h

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticIDs.h 
b/clang/include/clang/Basic/DiagnosticIDs.h
index 7fd107c4add7..288504def5eb 100644
--- a/clang/include/clang/Basic/DiagnosticIDs.h
+++ b/clang/include/clang/Basic/DiagnosticIDs.h
@@ -36,7 +36,7 @@ namespace clang {
   DIAG_SIZE_AST   =  250,
   DIAG_SIZE_COMMENT   =  100,
   DIAG_SIZE_CROSSTU   =  100,
-  DIAG_SIZE_SEMA  = 4000,
+  DIAG_SIZE_SEMA  = 4500,
   DIAG_SIZE_ANALYSIS  =  100,
   DIAG_SIZE_REFACTORING   = 1000,
 };



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


[PATCH] D96888: [NFC][clang] Bump up DIAG_SIZE_SEMA for downstream diagnostics

2021-02-17 Thread Zixu Wang via Phabricator via cfe-commits
zixuw created this revision.
zixuw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Bump DIAG_SIZE_SEMA up by 500 to accommodate extra downstream diagnostics


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96888

Files:
  clang/include/clang/Basic/DiagnosticIDs.h


Index: clang/include/clang/Basic/DiagnosticIDs.h
===
--- clang/include/clang/Basic/DiagnosticIDs.h
+++ clang/include/clang/Basic/DiagnosticIDs.h
@@ -36,7 +36,7 @@
   DIAG_SIZE_AST   =  250,
   DIAG_SIZE_COMMENT   =  100,
   DIAG_SIZE_CROSSTU   =  100,
-  DIAG_SIZE_SEMA  = 4000,
+  DIAG_SIZE_SEMA  = 4500,
   DIAG_SIZE_ANALYSIS  =  100,
   DIAG_SIZE_REFACTORING   = 1000,
 };


Index: clang/include/clang/Basic/DiagnosticIDs.h
===
--- clang/include/clang/Basic/DiagnosticIDs.h
+++ clang/include/clang/Basic/DiagnosticIDs.h
@@ -36,7 +36,7 @@
   DIAG_SIZE_AST   =  250,
   DIAG_SIZE_COMMENT   =  100,
   DIAG_SIZE_CROSSTU   =  100,
-  DIAG_SIZE_SEMA  = 4000,
+  DIAG_SIZE_SEMA  = 4500,
   DIAG_SIZE_ANALYSIS  =  100,
   DIAG_SIZE_REFACTORING   = 1000,
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96568: [CFE, SystemZ] Emit s390.tdc instrincic for __builtin_isnan in Constrained FP mode.

2021-02-17 Thread Jonas Paulsson via Phabricator via cfe-commits
jonpa updated this revision to Diff 324376.
jonpa added a comment.

> Sounds good to me. Hopefully I'll get round to __builtin_isinf soon and a 
> single hook will make the patch slightly smaller.

Patch updated to call the new hook testFPKind() and make it take a BuiltinID as 
argument (that seems to work at least for the moment - maybe an enum type will 
become necessary at some point per your suggestion..?)

I am not sure if this is "only" or "typically" used in constrained FP mode, or 
if the mode should be independent of calling this hook. The patch as it is 
asserts that it is called for an FP type but leaves it to the target to decide 
based on the FP mode, where SystemZ opts out unless it is constrained (which I 
think is what is wanted...).


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

https://reviews.llvm.org/D96568

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/test/CodeGen/SystemZ/strictfp_builtins.c

Index: clang/test/CodeGen/SystemZ/strictfp_builtins.c
===
--- /dev/null
+++ clang/test/CodeGen/SystemZ/strictfp_builtins.c
@@ -0,0 +1,43 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 %s -emit-llvm -ffp-exception-behavior=maytrap -o - -triple s390x-linux-gnu | FileCheck %s
+
+#pragma float_control(except, on)
+
+// CHECK-LABEL: @test_isnan_float(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[F_ADDR:%.*]] = alloca float, align 4
+// CHECK-NEXT:store float [[F:%.*]], float* [[F_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* [[F_ADDR]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f32(float [[TMP0]], i64 15) [[ATTR2:#.*]]
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int test_isnan_float(float f) {
+  return __builtin_isnan(f);
+}
+
+// CHECK-LABEL: @test_isnan_double(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.s390.tdc.f64(double [[TMP0]], i64 15) [[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int test_isnan_double(double d) {
+  return __builtin_isnan(d);
+}
+
+// CHECK-LABEL: @test_isnan_long_double(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LD_ADDR:%.*]] = alloca fp128, align 8
+// CHECK-NEXT:[[LD:%.*]] = load fp128, fp128* [[TMP0:%.*]], align 8
+// CHECK-NEXT:store fp128 [[LD]], fp128* [[LD_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load fp128, fp128* [[LD_ADDR]], align 8
+// CHECK-NEXT:[[TMP2:%.*]] = call i32 @llvm.s390.tdc.f128(fp128 [[TMP1]], i64 15) [[ATTR2]]
+// CHECK-NEXT:ret i32 [[TMP2]]
+//
+int test_isnan_long_double(long double ld) {
+  return __builtin_isnan(ld);
+}
+
Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
 #define LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
 
+#include "CGBuilder.h"
 #include "CodeGenModule.h"
 #include "CGValue.h"
 #include "clang/AST/Type.h"
@@ -126,6 +127,16 @@
 return Address;
   }
 
+  /// Performs a target specific test of a floating point value for things
+  /// like IsNaN, Infinity, ... Nullptr is returned if no implementation
+  /// exists.
+  virtual llvm::Value *
+  testFPKind(llvm::Value *V, unsigned BuiltinID, CGBuilderTy ,
+ CodeGenModule ) const {
+assert(V->getType()->isFloatingPointTy() && "V should have an FP type.");
+return nullptr;
+  }
+
   /// Corrects the low-level LLVM type for a given constraint and "usual"
   /// type.
   ///
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/RecordLayout.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/DiagnosticFrontend.h"
+#include "clang/Basic/Builtins.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "clang/CodeGen/SwiftCallingConv.h"
 #include "llvm/ADT/SmallBitVector.h"
@@ -30,6 +31,7 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
+#include "llvm/IR/IntrinsicsS390.h"
 #include "llvm/IR/Type.h"
 #include "llvm/Support/raw_ostream.h"
 #include  // std::sort
@@ -7200,8 +7202,37 @@
   SystemZTargetCodeGenInfo(CodeGenTypes , bool HasVector, bool SoftFloatABI)
   : TargetCodeGenInfo(
 std::make_unique(CGT, HasVector, SoftFloatABI)) {}
-};
 
+  llvm::Value *testFPKind(llvm::Value *V, unsigned BuiltinID,
+  CGBuilderTy ,
+  CodeGenModule ) 

[PATCH] D96886: [Driver] Clean up some Separate form options

2021-02-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: phosek, thakis.
Herald added subscribers: jansvoboda11, dang.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Drop the `Separate` form of `-fmodule-name X`, `-fprofile-remapping-file X`, 
and `-frewrite-map-file X`.
To the best of my knowledge they are not used. Their conventional Joined forms 
(`-fFOO=`) should be used instead.

`-fdebug-compilation-dir X` is used in several places, e.g.  
chromium/infra/goma.
It is also advertised in 
http://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html
So we keep it but make the EQ form canonical and the Separate form an alias.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96886

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/debug-comp-dir.S
  clang/test/Driver/debug.c
  clang/test/Driver/rewrite-map-files.c
  clang/test/Driver/rewrite-map-in-diagnostics.c
  clang/test/Driver/symbol-rewriter.c
  clang/test/Driver/working-directory.c

Index: clang/test/Driver/working-directory.c
===
--- clang/test/Driver/working-directory.c
+++ clang/test/Driver/working-directory.c
@@ -8,4 +8,4 @@
 
 // CHECK_WORKS: "-coverage-notes-file" "{{[^"]+}}test{{/|}}Driver{{/|}}Inputs{{/|}}pchfile.gcno"
 // CHECK_WORKS: "-working-directory" "{{[^"]+}}test{{/|}}Driver{{/|}}Inputs"
-// CHECK_WORKS: "-fdebug-compilation-dir" "{{[^"]+}}test{{/|}}Driver{{/|}}Inputs"
+// CHECK_WORKS: "-fdebug-compilation-dir={{[^"]+}}test{{/|}}Driver{{/|}}Inputs"
Index: clang/test/Driver/symbol-rewriter.c
===
--- clang/test/Driver/symbol-rewriter.c
+++ clang/test/Driver/symbol-rewriter.c
@@ -1,21 +1,7 @@
-// RUN: %clang -frewrite-map-file %S/Inputs/rewrite.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-SINGLE
+// RUN: %clang -frewrite-map-file=%S/Inputs/rewrite.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-SINGLE
 
-// CHECK-SINGLE: "-frewrite-map-file" "{{.*[\\/]}}rewrite.map"
+// CHECK-SINGLE: "-frewrite-map-file={{.*[\\/]}}rewrite.map"
 
-// RUN: %clang -frewrite-map-file %S/Inputs/rewrite-1.map -frewrite-map-file %S/Inputs/rewrite-2.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MULTIPLE
-
-// CHECK-MULTIPLE: "-frewrite-map-file" "{{.*[\\/]}}rewrite-1.map" "-frewrite-map-file" "{{.*[\\/]}}rewrite-2.map"
-
-// RUN: %clang -frewrite-map-file=%S/Inputs/rewrite.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-SINGLE-EQ
-
-// CHECK-SINGLE-EQ: "-frewrite-map-file" "{{.*[\\/]}}rewrite.map"
-
-// RUN: %clang -frewrite-map-file=%S/Inputs/rewrite-1.map -frewrite-map-file=%S/Inputs/rewrite-2.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MULTIPLE-EQ
-
-// CHECK-MULTIPLE-EQ: "-frewrite-map-file" "{{.*[\\/]}}rewrite-1.map"
-// CHECK-MULTIPLE-EQ: "-frewrite-map-file" "{{.*[\\/]}}rewrite-2.map"
-
-// RUN: %clang -frewrite-map-file %S/Inputs/rewrite-1.map -frewrite-map-file=%S/Inputs/rewrite-2.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MIXED
-
-// CHECK-MIXED: "-frewrite-map-file" "{{.*[\\/]}}rewrite-1.map" "-frewrite-map-file" "{{.*[\\/]}}rewrite-2.map"
+// RUN: %clang -frewrite-map-file=%S/Inputs/rewrite-1.map -frewrite-map-file=%S/Inputs/rewrite-2.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MULTIPLE
 
+// CHECK-MULTIPLE: "-frewrite-map-file={{.*[\\/]}}rewrite-1.map" "-frewrite-map-file={{.*[\\/]}}rewrite-2.map"
Index: clang/test/Driver/rewrite-map-in-diagnostics.c
===
--- clang/test/Driver/rewrite-map-in-diagnostics.c
+++ clang/test/Driver/rewrite-map-in-diagnostics.c
@@ -1,7 +1,7 @@
 // RUN: rm -rf "%t"
 // RUN: mkdir -p "%t"
 // RUN: env TMPDIR="%t" TEMP="%t" TMP="%t" RC_DEBUG_OPTION=1 \
-// RUN: not %clang -fsyntax-only -frewrite-map-file %p/Inputs/rewrite.map %s 2>&1 \
+// RUN: not %clang -fsyntax-only -frewrite-map-file=%p/Inputs/rewrite.map %s 2>&1 \
 // RUN:   | FileCheck %s
 
 #pragma clang __debug parser_crash
Index: clang/test/Driver/rewrite-map-files.c
===
--- clang/test/Driver/rewrite-map-files.c
+++ clang/test/Driver/rewrite-map-files.c
@@ -1,2 +1,2 @@
-// RUN: %clang -### -frewrite-map-file %t.map -c %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -### -frewrite-map-file=%t.map -c %s -o /dev/null 2>&1 | FileCheck %s
 // CHECK: error: no such file or directory:
Index: clang/test/Driver/debug.c
===
--- clang/test/Driver/debug.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// RUN: cd %S && %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-PWD %s
-// CHECK-PWD: {{"-fdebug-compilation-dir" 

[PATCH] D96884: [flang][driver] Add more -fdebug options

2021-02-17 Thread Faris Rehman via Phabricator via cfe-commits
FarisRehman created this revision.
Herald added subscribers: jansvoboda11, dang, mgorny.
Herald added a reviewer: sscalpone.
Herald added a reviewer: awarzynski.
FarisRehman requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Add the following options:

- -fdebug-parsing-log
- -fdebug-measure-parse-tree
- -fdebug-pre-fir-tree

Summary of changes:

- Add 3 new frontend actions: DebugParsingLogAction, 
DebugMeasureParseTreeAction and DebugPreFIRTreeAction
- Add MeasurementVisitor to FrontendActions.h
- Make reportFatalSemanticErrors return true if there are any fatal errors
- Port most of the `-fdebug-pre-fir-tree` tests to use the new driver if built, 
otherwise use f18.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96884

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CMakeLists.txt
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/debug-measure-parse-tree.f90
  flang/test/Flang-Driver/debug-parsing-log.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Lower/pre-fir-tree01.f90
  flang/test/Lower/pre-fir-tree02.f90
  flang/test/Lower/pre-fir-tree03.f90
  flang/test/Lower/pre-fir-tree05.f90

Index: flang/test/Lower/pre-fir-tree05.f90
===
--- flang/test/Lower/pre-fir-tree05.f90
+++ flang/test/Lower/pre-fir-tree05.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -fdebug-pre-fir-tree -fsyntax-only -fopenacc %s | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fdebug-pre-fir-tree -fopenacc %s | FileCheck %s
 
 ! Test structure of the Pre-FIR tree with OpenACC construct
 
Index: flang/test/Lower/pre-fir-tree03.f90
===
--- flang/test/Lower/pre-fir-tree03.f90
+++ flang/test/Lower/pre-fir-tree03.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -fdebug-pre-fir-tree -fsyntax-only -fopenmp %s | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fdebug-pre-fir-tree -fopenmp %s | FileCheck %s
 
 ! Test Pre-FIR Tree captures OpenMP related constructs
 
Index: flang/test/Lower/pre-fir-tree02.f90
===
--- flang/test/Lower/pre-fir-tree02.f90
+++ flang/test/Lower/pre-fir-tree02.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -fdebug-pre-fir-tree -fsyntax-only %s | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fdebug-pre-fir-tree %s | FileCheck %s
 
 ! Test Pre-FIR Tree captures all the intended nodes from the parse-tree
 ! Coarray and OpenMP related nodes are tested in other files.
Index: flang/test/Lower/pre-fir-tree01.f90
===
--- flang/test/Lower/pre-fir-tree01.f90
+++ flang/test/Lower/pre-fir-tree01.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -fdebug-pre-fir-tree -fsyntax-only %s | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fdebug-pre-fir-tree %s | FileCheck %s
 
 ! Test structure of the Pre-FIR tree
 
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -59,6 +59,10 @@
 ! HELP-FC1-NEXT: -fdebug-dump-parse-tree Dump the parse tree
 ! HELP-FC1-NEXT: -fdebug-dump-provenance Dump provenance
 ! HELP-FC1-NEXT: -fdebug-dump-symbolsDump symbols after the semantic analysis
+! HELP-FC1-NEXT: -fdebug-measure-parse-tree
+! HELP-FC1-NEXT: Measure the parse tree
+! HELP-FC1-NEXT: -fdebug-parsing-log Dump the parsing log
+! HELP-FC1-NEXT: -fdebug-pre-fir-treeDump the pre-FIR tree
 ! HELP-FC1-NEXT: -fdebug-unparse-with-symbols
 ! HELP-FC1-NEXT:Unparse and stop.
 ! HELP-FC1-NEXT: -fdebug-unparseUnparse and stop.
Index: flang/test/Flang-Driver/debug-parsing-log.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/debug-parsing-log.f90
@@ -0,0 +1,25 @@
+! Ensure argument -fdebug-parsing-log works as expected.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: not %flang-new -fdebug-parsing-log %s  2>&1 | FileCheck %s --check-prefix=FLANG
+
+!
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!
+! RUN: %flang-new -fc1 -fdebug-parsing-log %s  2>&1 | FileCheck %s --check-prefix=FRONTEND
+
+!--
+! EXPECTED OUTPUT WITH `flang-new`
+!--
+! FLANG:warning: argument unused during compilation: '-fdebug-parsing-log'
+
+!---
+! EXPECTED OUTPUT WITH `flang-new -fc1`

[PATCH] D96716: [flang][driver] Add debug dump options

2021-02-17 Thread Faris Rehman via Phabricator via cfe-commits
FarisRehman added a comment.

In D96716#2569102 , @awarzynski wrote:

> This patch doesn't require the tests to be updated, does it?

They do require updating as `-fdebug-dump-symbol` is otherwise not tested by 
the new driver in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96716

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


[PATCH] D96760: [clang-format] Suppress diagnostics on second parse

2021-02-17 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D96760#2565171 , @njames93 wrote:

> I did have another plan for a different way to go about this, not sure if its 
> really any better though.
> It involved building a vector of the edits the config would apply to its 
> parent. Then after the parent is parsed just applying those edits.
> It results in only 1 pass over the config file however it's a little more 
> involved to get it to work.

But then I need to rewrite the complete parsing process? Because in a normal 
style I can not parse, because it is not apparent which entries are changed 
because of the config, or do I oversee something?

In D93844#2536354 , @njames93 wrote:

> As a follow up it may be wise to pass a diag handler to parseConfiguration as 
> when we parse it a second time, we probably want to disregard any warnings 
> (like unknown key) detected as they will have been printed on the first pass.

And this is what you proposed. :)




Comment at: clang/include/clang/Format/Format.h:3339
+   bool AllowUnknownOptions = false,
+   llvm::SourceMgr::DiagHandlerTy DiagHandler = nullptr);
 

njames93 wrote:
> I know this is sufficient for the purpose of this patch, however it doesn't 
> make sense to accept take the handler parameter without also taking a void* 
> for its context.
Will do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96760

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


[PATCH] D96716: [flang][driver] Add debug dump options

2021-02-17 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski accepted this revision.
awarzynski added a comment.
This revision is now accepted and ready to land.

This patch doesn't require the tests to be updated, does it? Also: 
https://reviews.llvm.org/D96870. So it looks these are unrelated changes. Could 
you remove them before merging?

Otherwise, LGTM. Thanks for working on this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96716

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


[PATCH] D96877: [libomptarget] Try a fallback devicertl if the preferred one is missing

2021-02-17 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:265
   "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Please use --libomptarget-%1-bc-path to specify %1 bitcode 
library.">;
+def warn_drv_omp_offload_target_missingbcruntime : Warning<"No library '%0' 
found in the default clang lib directory or in LIBRARY_PATH, using '%1' 
instead. Please use --libomptarget-%2-bc-path to specify %2 bitcode library.">;
 def err_drv_omp_offload_target_bcruntime_not_found : Error<"Bitcode library 
'%0' does not exist.">;

tianshilei1992 wrote:
> Besides, we might also need to tell users this bitcode library might not work 
> as expected.
Could you propose preferred wording?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96877

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


[PATCH] D96877: [libomptarget] Try a fallback devicertl if the preferred one is missing

2021-02-17 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield marked an inline comment as done.
JonChesterfield added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1647
+llvm::Twine lib) {
+  for (StringRef LibraryPath : LibraryPaths) {
+SmallString<128> TargetFile(LibraryPath);

^clang-tidy warning about a twine in a parameter list [llvm-twine-local] looks 
like a bug



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1695
 
-std::string LibOmpTargetName =
-"libomptarget-" + BitcodeSuffix.str() + ".bc";
-
-for (StringRef LibraryPath : LibraryPaths) {
-  SmallString<128> LibOmpTargetFile(LibraryPath);
-  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
-  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
-CC1Args.push_back("-mlink-builtin-bitcode");
-CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
-FoundBCLibrary = true;
-break;
+llvm::Twine LibOmpTargetName = "libomptarget-" + BitcodeSuffix + ".bc";
+llvm::Twine FallbackTargetName =

tianshilei1992 wrote:
> If you're using `Twine`, `+` is not needed.
> ```
> llvm::Twine LibOmpTargetName("libomptarget-", BitcodeSuffix ,".bc");
> ```
This doesn't appear to be the case. Doesn't compile anyway, no matching 
constructor.

The discussion around the clang-tidy warning states that Twine variables 
shouldn't be used as local variables because they don't make copies of the 
arguments, so one can hit use after free. I don't agree with that, but it 
doesn't matter very much so have changed to std::string.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1697
+llvm::Twine FallbackTargetName =
+"libomptarget-" + ArchPrefix + "-unknown.bc";
+

tianshilei1992 wrote:
> The `BitcodeSuffix` for NVPTX consists of three parts: `nvptx`, `cuda_xxx`, 
> and `sm_yy`. We might want to have an unknown for every `sm`?
Lets not go there. 'Unknown' is a reasonably strong indicator for 'this might 
not work'. One per sm suggests we've somehow tested whether it's going to be OK 
or not.

I'd prefer we stick with 'using a cuda that didn't exist when your clang 
shipped is a bad idea, get a newer clang or an older cuda'. This is a sketch of 
how we could go the other way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96877

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


[PATCH] D96771: [OpenCL] Add distinct file extension for C++ for OpenCL

2021-02-17 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Driver/Types.cpp:265
.Case("cl", TY_CL)
+   .Case("clcpp", TY_CLCXX)
.Case("cp", TY_CXX)

svenvh wrote:
> mantognini wrote:
> > I'm not sure we want that -- I'm actually fine if we don't -- but I see 
> > below `c++` and `cxx` are supported in addition to `cpp`. Should we 
> > therefore also have `clc++` and `clcxx` as file valid extensions for 
> > consistency? I wonder what the general opinion is.
> And there is also `.cc` above.  Since you're asking for opinions, my personal 
> opinion is that one extension should be enough, and providing a CL 
> counterpart for all existing C++ file extensions does not bring more value.
FYI, there are some more discussions on RFC thread 
https://lists.llvm.org/pipermail/cfe-dev/2021-February/067703.html


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

https://reviews.llvm.org/D96771

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


[PATCH] D96877: [libomptarget] Try a fallback devicertl if the preferred one is missing

2021-02-17 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 324354.
JonChesterfield added a comment.

- review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96877

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1628,6 +1628,33 @@
   }
 }
 
+namespace {
+bool tryAppendBuiltinBitcode(const llvm::opt::ArgList ,
+ llvm::opt::ArgStringList , StringRef lib) 
{
+  if (llvm::sys::fs::exists(lib)) {
+CC1Args.push_back("-mlink-builtin-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(lib));
+return true;
+  } else {
+return false;
+  }
+}
+
+bool tryAppendBuiltinBitcodeGivenPaths(
+const SmallVector ,
+const llvm::opt::ArgList , llvm::opt::ArgStringList ,
+StringRef lib) {
+  for (StringRef LibraryPath : LibraryPaths) {
+SmallString<128> TargetFile(LibraryPath);
+llvm::sys::path::append(TargetFile, lib);
+if (tryAppendBuiltinBitcode(DriverArgs, CC1Args, TargetFile)) {
+  return true;
+}
+  }
+  return false;
+}
+} // namespace
+
 void tools::addOpenMPDeviceRTL(const Driver ,
const llvm::opt::ArgList ,
llvm::opt::ArgStringList ,
@@ -1658,27 +1685,24 @@
   // First check whether user specifies bc library
   if (const Arg *A = DriverArgs.getLastArg(LibomptargetBCPathOpt)) {
 std::string LibOmpTargetName(A->getValue());
-if (llvm::sys::fs::exists(LibOmpTargetName)) {
-  CC1Args.push_back("-mlink-builtin-bitcode");
-  CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetName));
-} else {
+if (!tryAppendBuiltinBitcode(DriverArgs, CC1Args, LibOmpTargetName)) {
   D.Diag(diag::err_drv_omp_offload_target_bcruntime_not_found)
   << LibOmpTargetName;
 }
   } else {
-bool FoundBCLibrary = false;
-
-std::string LibOmpTargetName =
-"libomptarget-" + BitcodeSuffix.str() + ".bc";
-
-for (StringRef LibraryPath : LibraryPaths) {
-  SmallString<128> LibOmpTargetFile(LibraryPath);
-  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
-  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
-CC1Args.push_back("-mlink-builtin-bitcode");
-CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
-FoundBCLibrary = true;
-break;
+std::string Root = "libomptarget-";
+std::string LibOmpTargetName = Root + BitcodeSuffix.str() + ".bc";
+std::string FallbackTargetName = Root + ArchPrefix.str() + "-unknown.bc";
+
+bool FoundBCLibrary = tryAppendBuiltinBitcodeGivenPaths(
+LibraryPaths, DriverArgs, CC1Args, LibOmpTargetName);
+
+if (!FoundBCLibrary) {
+  FoundBCLibrary = tryAppendBuiltinBitcodeGivenPaths(
+  LibraryPaths, DriverArgs, CC1Args, FallbackTargetName);
+  if (FoundBCLibrary) {
+D.Diag(diag::warn_drv_omp_offload_target_missingbcruntime)
+<< LibOmpTargetName << FallbackTargetName << ArchPrefix;
   }
 }
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -262,6 +262,7 @@
   "The option -fopenmp-targets must be used in conjunction with a -fopenmp 
option compatible with offloading, please use -fopenmp=libomp or 
-fopenmp=libiomp5.">;
 def err_drv_omp_offload_target_missingbcruntime : Error<
   "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Please use --libomptarget-%1-bc-path to specify %1 bitcode 
library.">;
+def warn_drv_omp_offload_target_missingbcruntime : Warning<"No library '%0' 
found in the default clang lib directory or in LIBRARY_PATH, using '%1' 
instead. Please use --libomptarget-%2-bc-path to specify %2 bitcode library.">;
 def err_drv_omp_offload_target_bcruntime_not_found : Error<"Bitcode library 
'%0' does not exist.">;
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">,


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1628,6 +1628,33 @@
   }
 }
 
+namespace {
+bool tryAppendBuiltinBitcode(const llvm::opt::ArgList ,
+ llvm::opt::ArgStringList , StringRef lib) {
+  if (llvm::sys::fs::exists(lib)) {
+CC1Args.push_back("-mlink-builtin-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(lib));
+return true;
+  } else {
+   

[PATCH] D95753: [Coverage] Store compilation dir separately in coverage mapping

2021-02-17 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1131
   NegFlag, 
BothFlags<[CoreOption]>>;
+def fcoverage_compilation_dir : Separate<["-"], "fcoverage-compilation-dir">,
+Group, Flags<[CC1Option, CC1AsOption, CoreOption]>,

MaskRay wrote:
> Using fcoverage_compilation_dir_EQ for both driver option and CC1 option is 
> preferred.
> 
> Can you drop fcoverage_compilation_dir ?
I've been following `-fdebug-compilation-dir` which supports both variants. 
Should we drop `-fdebug-compilation-dir` as well? I'd like to keep these 
consistent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95753

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


[PATCH] D96865: [Driver] Honor "-gdwarf-N" at any position for assembler sources

2021-02-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/Driver/debug-options-as.c:65
+// Check that -gdwarf-N can be placed before other options of the "-g" group.
+// RUN: %clang -### -c -g -gdwarf-3 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF3 %s

Nit: use the more common spelling `-fintegrated-as`

`-triple %itanium_abi_triple`

msvc windows triples ideally don't need `-dwarf-version=`, but that can be a 
separate clean-up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96865

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


[PATCH] D96835: [HIP] Support device sanitizer

2021-02-17 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/include/clang/Driver/Options.td:939
   "__cyg_profile_func_enter and __cyg_profile_func_exit">;
+def fgpu_sanitize : Flag<["-"], "fgpu-sanitize">,
+  HelpText<"Enable sanitizer for AMDGPU target.">;

We do have `BoolFOption` for `-fsomething`/`-fno-something` options. 



Comment at: clang/lib/Driver/ToolChains/HIP.cpp:117
+   false))
+TC.addHIPDeviceLibArgs(Args, LldArgs, /*UseMLinkOpt=*/false);
+

I'd pass the library prefix argument as a string, instead of a boolean flag. 
Makes it easier to tell what's going on without having to annotate it as a 
comment. 

Also, maybe consider separating "get the list of bitcode files" from "construct 
aguments for tool X for the given list of bitcode files". Right now 
`addHIPDeviceLibArgs` does both and has to plumb the `UseMLinkOpt`through 
multiple function calls. Adding the prefix argument can be done at the 
`constructLldCommand`/`addClangTargetOptions`. 


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

https://reviews.llvm.org/D96835

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


[PATCH] D96381: [AArch64] Adding SHA3 Intrinsics support

2021-02-17 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic updated this revision to Diff 324347.
rsanthir.quic added a comment.

Removed extra whitespace


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

https://reviews.llvm.org/D96381

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/include/clang/Basic/arm_neon_incl.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-range-checks.c
  clang/test/CodeGen/aarch64-neon-sha3.c
  clang/utils/TableGen/NeonEmitter.cpp
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/neon-sha3.ll

Index: llvm/test/CodeGen/AArch64/neon-sha3.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/neon-sha3.ll
@@ -0,0 +1,106 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc %s -mtriple=aarch64 -mattr=+v8.3a,+sha3 -o - | FileCheck %s
+
+define <2 x i64> @test_vsha512h(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c) {
+; CHECK-LABEL: test_vsha512h:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sha512h q0, q1, v2.2d
+; CHECK-NEXT:ret
+entry:
+  %vsha512h.i = tail call <2 x i64> @llvm.aarch64.crypto.sha512h(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c)
+  ret <2 x i64> %vsha512h.i
+}
+
+define <2 x i64> @test_vsha512h2(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c) {
+; CHECK-LABEL: test_vsha512h2:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sha512h2 q0, q1, v2.2d
+; CHECK-NEXT:ret
+entry:
+  %vsha512h2.i = tail call <2 x i64> @llvm.aarch64.crypto.sha512h2(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c)
+  ret <2 x i64> %vsha512h2.i
+}
+
+define <2 x i64> @test_vsha512su0(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vsha512su0:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sha512su0 v0.2d, v1.2d
+; CHECK-NEXT:ret
+entry:
+  %vsha512su0.i = tail call <2 x i64> @llvm.aarch64.crypto.sha512su0(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %vsha512su0.i
+}
+
+define <2 x i64> @test_vsha512su1(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c) {
+; CHECK-LABEL: test_vsha512su1:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sha512su1 v0.2d, v1.2d, v2.2d
+; CHECK-NEXT:ret
+entry:
+  %vsha512su1.i = tail call <2 x i64> @llvm.aarch64.crypto.sha512su1(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c)
+  ret <2 x i64> %vsha512su1.i
+}
+
+define <2 x i64> @test_vrax1(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vrax1:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:rax1 v0.2d, v0.2d, v1.2d
+; CHECK-NEXT:ret
+entry:
+  %vrax1.i = tail call <2 x i64> @llvm.aarch64.crypto.rax1(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %vrax1.i
+}
+
+define <2 x i64> @test_vxar(<2 x i64> %a,  <2 x i64> %b) {
+; CHECK-LABEL: test_vxar:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:xar v0.2d, v0.2d, v1.2d, #1
+; CHECK-NEXT:ret
+entry:
+  %vxar.i = tail call  <2 x i64> @llvm.aarch64.crypto.xar(<2 x i64> %a, <2 x i64> %b, i64 1)
+  ret <2 x i64> %vxar.i
+}
+
+define <16 x i8> @test_bcax_8(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c) {
+; CHECK-LABEL: test_bcax_8:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:bcax v0.16b, v0.16b, v1.16b, v2.16b
+; CHECK-NEXT:ret
+entry:
+  %vbcax_8.i = tail call <16 x i8> @llvm.aarch64.crypto.bcaxu.v16i8(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c)
+  ret <16 x i8> %vbcax_8.i
+}
+
+define <16 x i8> @test_eor3_8(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c) {
+; CHECK-LABEL: test_eor3_8:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:eor3 v0.16b, v0.16b, v1.16b, v2.16b
+; CHECK-NEXT:ret
+entry:
+  %veor3_8.i = tail call <16 x i8> @llvm.aarch64.crypto.eor3u.v16i8(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c)
+  ret <16 x i8> %veor3_8.i
+}
+
+declare <2 x i64> @llvm.aarch64.crypto.sha512h(<2 x i64>, <2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.aarch64.crypto.sha512h2(<2 x i64>, <2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.aarch64.crypto.sha512su0(<2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.aarch64.crypto.sha512su1(<2 x i64>, <2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.aarch64.crypto.rax1(<2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.aarch64.crypto.xar(<2 x i64>, <2 x i64>, i64 immarg)
+declare <16 x i8> @llvm.aarch64.crypto.bcaxu.v16i8(<16 x i8>, <16 x i8>, <16 x i8>)
+declare <8 x i16> @llvm.aarch64.crypto.bcaxu.v8i16(<8 x i16>, <8 x i16>, <8 x i16>)
+declare <4 x i32> @llvm.aarch64.crypto.bcaxu.v4i32(<4 x i32>, <4 x i32>, <4 x i32>)
+declare <2 x i64> @llvm.aarch64.crypto.bcaxu.v2i64(<2 x i64>, <2 x i64>, <2 x i64>)
+declare <16 x i8> @llvm.aarch64.crypto.bcaxs.v16i8(<16 x i8>, <16 x i8>, <16 x i8>)
+declare <8 x i16> @llvm.aarch64.crypto.bcaxs.v8i16(<8 x i16>, <8 x i16>, <8 x i16>)
+declare <4 x i32> @llvm.aarch64.crypto.bcaxs.v4i32(<4 x i32>, <4 x i32>, <4 x i32>)
+declare <2 x i64> @llvm.aarch64.crypto.bcaxs.v2i64(<2 x i64>, <2 x i64>, <2 x i64>)
+declare <16 x i8> @llvm.aarch64.crypto.eor3u.v16i8(<16 x 

[PATCH] D96877: [libomptarget] Try a fallback devicertl if the preferred one is missing

2021-02-17 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:265
   "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Please use --libomptarget-%1-bc-path to specify %1 bitcode 
library.">;
+def warn_drv_omp_offload_target_missingbcruntime : Warning<"No library '%0' 
found in the default clang lib directory or in LIBRARY_PATH, using '%1' 
instead. Please use --libomptarget-%2-bc-path to specify %2 bitcode library.">;
 def err_drv_omp_offload_target_bcruntime_not_found : Error<"Bitcode library 
'%0' does not exist.">;

Besides, we might also need to tell users this bitcode library might not work 
as expected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96877

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


[PATCH] D92715: [Clang][RISCV] Define RISC-V V builtin types

2021-02-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92715

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


  1   2   >