[PATCH] D77229: [Analyzer][NFC] Avoid handling of LazyCompundVals in IteratorModeling

2020-09-24 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Oh, I think now what do you mean: iterators stored in containers, thus 
iterators iterating over iterators. Yes, the current working of the checker 
does not support it because it stores iterator positions for both the prvalues 
and the glvalues. This is so from the beginning and this patch does not change 
anything about this behavior. Of course, this design concept is questionable, 
we can change it in the future. But not in this patch, this one is purely an 
NFC: it has exactly the same functionality as the previous versions, the only 
difference is that it does not hamper anymore with `LazyCompoundVal`s but 
reaches the real region of the objects (and only in case of objects by value, I 
check the AST type for paramters), exactly as you requested.

Anyway, to me storing iterators in containers sounds dangerous. Iterators are 
like lighted matches which you use and then extinguish. You do not put them 
into the drawer on into a paper box. If you store iterators in a container, how 
can you track which one of them is invalidated? This sounds a very bad practice 
to me.

Anyway, we can change the whole iterator modeling and checking in the future to 
support even this bad practice, but in their current state it is much more 
beneficial for the users to reduce the huge number of false positives and add 
note tags for the reported bugs, I think. Maybe we could better explain the 
current working in the comments at the beginning, and put FIXME-s there. 
Eventually we can also add such test cases, but with the current functionality 
even that cannot be done, because we currently do not keep track the content of 
the containers.


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

https://reviews.llvm.org/D77229

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


[PATCH] D87737: Add -fprofile-update={atomic,prefer-atomic,single}

2020-09-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 294232.
MaskRay marked an inline comment as done.
MaskRay added a comment.

Thanks for review!  I will wait until next week.

Fixed a typo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87737

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/code-coverage-tsan.c
  clang/test/CodeGen/tsan-instrprof-atomic.c
  clang/test/Driver/fprofile-update.c

Index: clang/test/Driver/fprofile-update.c
===
--- /dev/null
+++ clang/test/Driver/fprofile-update.c
@@ -0,0 +1,15 @@
+/// For -fprofile-instr-generate and -fprofile-arcs, increment counters atomically
+/// if -fprofile-update={atomic,prefer-atomic} or -fsanitize=thread is specified.
+// RUN: %clang -### %s -c -target x86_64-linux -fsanitize=thread %s 2>&1 | FileCheck %s
+// RUN: %clang -### %s -c -fprofile-update=atomic 2>&1 | FileCheck %s
+// RUN: %clang -### %s -c -fprofile-update=prefer-atomic 2>&1 | FileCheck %s
+
+// CHECK: "-fprofile-update=atomic"
+
+// RUN: %clang -### %s -c -fprofile-update=atomic -fprofile-update=single 2>&1 | FileCheck %s --check-prefix=SINGLE
+
+// SINGLE-NOT: "-fprofile-update=atomic"
+
+// RUN: not %clang %s -c -fprofile-update=unknown 2>&1 | FileCheck %s --check-prefix=ERROR
+
+// ERROR: error: unsupported argument 'unknown' to option 'fprofile-update='
Index: clang/test/CodeGen/tsan-instrprof-atomic.c
===
--- clang/test/CodeGen/tsan-instrprof-atomic.c
+++ clang/test/CodeGen/tsan-instrprof-atomic.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -fprofile-instrument=clang -fsanitize=thread -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -fprofile-instrument=clang -fprofile-update=atomic -o - | FileCheck %s
 
 // CHECK: define {{.*}}@foo
 // CHECK-NOT: load {{.*}}foo
Index: clang/test/CodeGen/code-coverage-tsan.c
===
--- clang/test/CodeGen/code-coverage-tsan.c
+++ clang/test/CodeGen/code-coverage-tsan.c
@@ -1,11 +1,12 @@
-/// -fsanitize=thread requires the (potentially concurrent) counter updates to be atomic.
-// RUN: %clang_cc1 %s -triple x86_64 -emit-llvm -fsanitize=thread -femit-coverage-notes -femit-coverage-data \
+/// -fprofile-update=atomic (implied by -fsanitize=thread) requires the
+/// (potentially concurrent) counter updates to be atomic.
+// RUN: %clang_cc1 %s -triple x86_64 -emit-llvm -fprofile-update=atomic -femit-coverage-notes -femit-coverage-data \
 // RUN:   -coverage-notes-file /dev/null -coverage-data-file /dev/null -o - | FileCheck %s
 
 // CHECK-LABEL: void @foo()
 /// Two counters are incremented by __tsan_atomic64_fetch_add.
-// CHECK: call i64 @__tsan_atomic64_fetch_add
-// CHECK-NEXT:call i32 @__tsan_atomic32_fetch_sub
+// CHECK: atomicrmw add i64* {{.*}} @__llvm_gcov_ctr
+// CHECK-NEXT:atomicrmw sub i32*
 
 _Atomic(int) cnt;
 void foo() { cnt--; }
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -884,6 +884,7 @@
   Opts.DebugRangesBaseAddress = Args.hasArg(OPT_fdebug_ranges_base_address);
 
   setPGOInstrumentor(Opts, Args, Diags);
+  Opts.AtomicProfileUpdate = Args.hasArg(OPT_fprofile_update_EQ);
   Opts.InstrProfileOutput =
   std::string(Args.getLastArgValue(OPT_fprofile_instrument_path_EQ));
   Opts.ProfileInstrumentUsePath =
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -868,6 +868,17 @@
 CmdArgs.push_back(Args.MakeArgString(Twine("-fprofile-filter-files=" + v)));
   }
 
+  if (const auto *A = Args.getLastArg(options::OPT_fprofile_update_EQ)) {
+StringRef Val = A->getValue();
+if (Val == "atomic" || Val == "prefer-atomic")
+  CmdArgs.push_back("-fprofile-update=atomic");
+else if (Val != "single")
+  D.Diag(diag::err_drv_unsupported_option_argument)
+  << A->getOption().getName() << Val;
+  } else if (TC.getSanitizerArgs().needsTsanRt()) {
+CmdArgs.push_back("-fprofile-update=atomic");
+  }
+
   // Leave -fprofile-dir= an unused argument unless .gcda emission is
   // enabled. To be polite, with '-fprofile-arcs -fno-profile-arcs' consider
   // the flag used. There is no -fno-profile-dir, so the user has no
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -570,7 +570,7 @@
   Options.NoRedZon

[PATCH] D87737: Add -fprofile-update={atomic,prefer-atomic,single}

2020-09-24 Thread David Li via Phabricator via cfe-commits
davidxl accepted this revision.
davidxl added a comment.
This revision is now accepted and ready to land.

Looks good. Makes the tsan and instrumentation interaction also cleaner.




Comment at: clang/test/CodeGen/code-coverage-tsan.c:1
-/// -fsanitize=thread requires the (potentially concurrent) counter updates to 
be atomic.
-// RUN: %clang_cc1 %s -triple x86_64 -emit-llvm -fsanitize=thread 
-femit-coverage-notes -femit-coverage-data \
+/// -fprofile-update=atmomic (implied by -fsanitize=thread) requires the
+/// (potentially concurrent) counter updates to be atomic.

Fix typo: atmomic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87737

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


[PATCH] D88278: [PowerPC] Add builtins for xvtdiv(dp|sp) and xvtsqrt(dp|sp).

2020-09-24 Thread Qing Shan Zhang via Phabricator via cfe-commits
steven.zhang added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCInstrVSX.td:2584
 
+// Vector test software functions.
+def : Pat<(i32 (int_ppc_vsx_xvtdivdp v2f64:$A, v2f64:$B)),

Vector test for software divide and sqrt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88278

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


[PATCH] D87822: [FPEnv] Evaluate constant expressions under non-default rounding modes

2020-09-24 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:2438
+/// Check if the given evaluation result is allowed for constant evaluation.
+static bool checkFloatingPointResult(EvalInfo &Info, const Expr *E,
+ APFloat::opStatus St) {

mibintc wrote:
> If the result is this false, shall this routine create a Note diag explaining 
> the false result? 
It makes sense. Added respective diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87822

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


[PATCH] D87822: [FPEnv] Evaluate constant expressions under non-default rounding modes

2020-09-24 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 294230.
sepavloff added a comment.

Added diagnostic message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87822

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/test/AST/const-fpfeatures-diag.c
  clang/test/AST/const-fpfeatures.c
  clang/test/AST/const-fpfeatures.cpp

Index: clang/test/AST/const-fpfeatures.cpp
===
--- /dev/null
+++ clang/test/AST/const-fpfeatures.cpp
@@ -0,0 +1,81 @@
+// RUN: %clang_cc1 -S -emit-llvm -triple i386-linux -std=c++2a -Wno-unknown-pragmas %s -o - | FileCheck %s
+
+// nextUp(1.F) == 0x1.02p0F
+
+constexpr float add_round_down(float x, float y) {
+  #pragma STDC FENV_ROUND FE_DOWNWARD
+  float res = x;
+  res += y;
+  return res;
+}
+
+constexpr float add_round_up(float x, float y) {
+  #pragma STDC FENV_ROUND FE_UPWARD
+  float res = x;
+  res += y;
+  return res;
+}
+
+float V1 = add_round_down(1.0F, 0x0.01p0F);
+float V2 = add_round_up(1.0F, 0x0.01p0F);
+// CHECK: @V1 = {{.*}} float 1.00e+00
+// CHECK: @V2 = {{.*}} float 0x3FF02000
+
+constexpr float add_cast_round_down(float x, double y) {
+  #pragma STDC FENV_ROUND FE_DOWNWARD
+  float res = x;
+  res += y;
+  return res;
+}
+
+constexpr float add_cast_round_up(float x, double y) {
+  #pragma STDC FENV_ROUND FE_UPWARD
+  float res = x;
+  res += y;
+  return res;
+}
+
+float V3 = add_cast_round_down(1.0F, 0x0.01p0F);
+float V4 = add_cast_round_up(1.0F, 0x0.01p0F);
+
+// CHECK: @V3 = {{.*}} float 1.00e+00
+// CHECK: @V4 = {{.*}} float 0x3FF02000
+
+// The next three variables use the same function as initializer, only rounding
+// modes differ.
+
+float V5 = []() -> float {
+  return [](float x, float y)->float {
+#pragma STDC FENV_ROUND FE_UPWARD
+return x + y;
+  }([](float x, float y) -> float {
+  #pragma STDC FENV_ROUND FE_UPWARD
+  return x + y;
+}(1.0F, 0x0.01p0F),
+  0x0.01p0F);
+}();
+// CHECK: @V5 = {{.*}} float 0x3FF04000
+
+float V6 = []() -> float {
+  return [](float x, float y)->float {
+#pragma STDC FENV_ROUND FE_DOWNWARD
+return x + y;
+  }([](float x, float y) -> float {
+  #pragma STDC FENV_ROUND FE_UPWARD
+  return x + y;
+}(1.0F, 0x0.01p0F),
+  0x0.01p0F);
+}();
+// CHECK: @V6 = {{.*}} float 0x3FF02000
+
+float V7 = []() -> float {
+  return [](float x, float y)->float {
+#pragma STDC FENV_ROUND FE_DOWNWARD
+return x + y;
+  }([](float x, float y) -> float {
+  #pragma STDC FENV_ROUND FE_DOWNWARD
+  return x + y;
+}(1.0F, 0x0.01p0F),
+  0x0.01p0F);
+}();
+// CHECK: @V7 = {{.*}} float 1.00e+00
Index: clang/test/AST/const-fpfeatures.c
===
--- /dev/null
+++ clang/test/AST/const-fpfeatures.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -S -emit-llvm -Wno-unknown-pragmas %s -o - | FileCheck %s
+
+// nextUp(1.F) == 0x1.02p0F
+
+const double _Complex C0 = 0x1.01p0 + 0x1.01p0I;
+
+#pragma STDC FENV_ROUND FE_UPWARD
+
+float F1u = 1.0F + 0x0.02p0F;
+float F2u = 1.0F + 0x0.01p0F;
+float F3u = 0x1.01p0;
+// CHECK: @F1u = {{.*}} float 0x3FF02000
+// CHECK: @F2u = {{.*}} float 0x3FF02000
+// CHECK: @F3u = {{.*}} float 0x3FF02000
+
+float _Complex C1u = C0;
+// CHECK: @C1u = {{.*}} { float, float } { float 0x3FF02000, float 0x3FF02000 }
+
+
+#pragma STDC FENV_ROUND FE_DOWNWARD
+
+float F1d = 1.0F + 0x0.02p0F;
+float F2d = 1.0F + 0x0.01p0F;
+float F3d = 0x1.01p0;
+
+// CHECK: @F1d = {{.*}} float 0x3FF02000
+// CHECK: @F2d = {{.*}} float 1.00e+00
+// CHECK: @F3d = {{.*}} float 1.00e+00
+
+float _Complex C1d = C0;
+// CHECK: @C1d = {{.*}} { float, float } { float 1.00e+00, float 1.00e+00 }
Index: clang/test/AST/const-fpfeatures-diag.c
===
--- /dev/null
+++ clang/test/AST/const-fpfeatures-diag.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify -ffp-exception-behavior=strict -Wno-unknown-pragmas %s
+
+#pragma STDC FENV_ROUND FE_DYNAMIC
+
+// nextUp(1.F) == 0x1.02p0F
+
+float F1 = 0x1.00p0F + 0x0.02p0F;
+float F2 = 0x1.00p0F + 0x0.01p0F; // expected-error{{initializer element is not a compile-time constant}}
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -981,7 +981,9 @@
 void Sema::setRoundingMode(SourceLocation Loc, llvm::RoundingMode FPR) {
   // C2x: 7.6.2p3  If the FE_DYNAMIC mode is specified and FENV_ACCESS is "off",
   // the translator may assume that the default

[PATCH] D88278: [PowerPC] Add builtins for xvtdiv(dp|sp) and xvtsqrt(dp|sp).

2020-09-24 Thread EsmeYi via Phabricator via cfe-commits
Esme created this revision.
Esme added reviewers: steven.zhang, masoud.ataei, shchenz, jsji, qiucf.
Herald added subscribers: llvm-commits, cfe-commits, kbarton, hiraditya, 
nemanjai.
Herald added projects: clang, LLVM.
Esme requested review of this revision.

This patch implements the builtins for `xvtdivdp, xvtdivsp, xvtsqrtdp, 
xvtsqrtsp`.
The instructions correspond to the following builtins:

  int vec_test_swdiv(vector double v1, vector double v2);
  int vec_test_swdivs(vector float v1, vector float v2);
  int vec_test_swsqrt(vector double v1, vector double v2);
  int vec_test_swsqrts(vector float v1, vector float v2);

This patch depends on D88274 , which fixes the 
bug in copying from CRRC to GRC.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88278

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-vsx.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/PowerPC/vsx_builtins.ll

Index: llvm/test/CodeGen/PowerPC/vsx_builtins.ll
===
--- llvm/test/CodeGen/PowerPC/vsx_builtins.ll
+++ llvm/test/CodeGen/PowerPC/vsx_builtins.ll
@@ -54,3 +54,55 @@
 }
 ; Function Attrs: nounwind readnone
 declare void @llvm.ppc.vsx.stxvd2x.be(<2 x double>, i8*)
+
+define i32 @test_vec_test_swdiv(<2 x double> %a, <2 x double> %b) {
+; CHECK-LABEL: test_vec_test_swdiv:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xvtdivdp cr0, v2, v3
+; CHECK-NEXT:mfocrf r3, 128
+; CHECK-NEXT:srwi r3, r3, 28
+; CHECK-NEXT:blr
+  entry:
+%0 = tail call i32 @llvm.ppc.vsx.xvtdivdp(<2 x double> %a, <2 x double> %b)
+ret i32 %0
+}
+declare i32 @llvm.ppc.vsx.xvtdivdp(<2 x double>, <2 x double>)
+
+define i32 @test_vec_test_swdivs(<4 x float> %a, <4 x float> %b) {
+; CHECK-LABEL: test_vec_test_swdivs:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xvtdivsp cr0, v2, v3
+; CHECK-NEXT:mfocrf r3, 128
+; CHECK-NEXT:srwi r3, r3, 28
+; CHECK-NEXT:blr
+  entry:
+%0 = tail call i32 @llvm.ppc.vsx.xvtdivsp(<4 x float> %a, <4 x float> %b)
+ret i32 %0
+}
+declare i32 @llvm.ppc.vsx.xvtdivsp(<4 x float>, <4 x float>)
+
+define i32 @test_vec_test_swsqrt(<2 x double> %a) {
+; CHECK-LABEL: test_vec_test_swsqrt:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xvtsqrtdp cr0, v2
+; CHECK-NEXT:mfocrf r3, 128
+; CHECK-NEXT:srwi r3, r3, 28
+; CHECK-NEXT:blr
+  entry:
+%0 = tail call i32 @llvm.ppc.vsx.xvtsqrtdp(<2 x double> %a)
+ret i32 %0
+}
+declare i32 @llvm.ppc.vsx.xvtsqrtdp(<2 x double>)
+
+define i32 @test_vec_test_swsqrts(<4 x float> %a) {
+; CHECK-LABEL: test_vec_test_swsqrts:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xvtsqrtsp cr0, v2
+; CHECK-NEXT:mfocrf r3, 128
+; CHECK-NEXT:srwi r3, r3, 28
+; CHECK-NEXT:blr
+  entry:
+%0 = tail call i32 @llvm.ppc.vsx.xvtsqrtsp(<4 x float> %a)
+ret i32 %0
+}
+declare i32 @llvm.ppc.vsx.xvtsqrtsp(<4 x float>)
Index: llvm/lib/Target/PowerPC/PPCInstrVSX.td
===
--- llvm/lib/Target/PowerPC/PPCInstrVSX.td
+++ llvm/lib/Target/PowerPC/PPCInstrVSX.td
@@ -2581,6 +2581,16 @@
 def : Pat<(int_ppc_vsx_xvdivdp v2f64:$A, v2f64:$B),
   (XVDIVDP $A, $B)>;
 
+// Vector test software functions.
+def : Pat<(i32 (int_ppc_vsx_xvtdivdp v2f64:$A, v2f64:$B)),
+  (COPY_TO_REGCLASS (XVTDIVDP $A, $B), GPRC)>;
+def : Pat<(i32 (int_ppc_vsx_xvtdivsp v4f32:$A, v4f32:$B)),
+  (COPY_TO_REGCLASS (XVTDIVSP $A, $B), GPRC)>;
+def : Pat<(i32 (int_ppc_vsx_xvtsqrtdp v2f64:$A)),
+  (COPY_TO_REGCLASS (XVTSQRTDP $A), GPRC)>;
+def : Pat<(i32 (int_ppc_vsx_xvtsqrtsp v4f32:$A)),
+  (COPY_TO_REGCLASS (XVTSQRTSP $A), GPRC)>;
+
 // Reciprocal estimate
 def : Pat<(int_ppc_vsx_xvresp v4f32:$A),
   (XVRESP $A)>;
Index: llvm/include/llvm/IR/IntrinsicsPowerPC.td
===
--- llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -1249,6 +1249,16 @@
 def int_ppc_vsx_xvtlsbb :
   PowerPC_VSX_Intrinsic<"xvtlsbb", [llvm_i32_ty],
 [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>;
+def int_ppc_vsx_xvtdivdp :
+  PowerPC_VSX_Intrinsic<"xvtdivdp", [llvm_i32_ty],
+[llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>;
+def int_ppc_vsx_xvtdivsp :
+  PowerPC_VSX_Intrinsic<"xvtdivsp", [llvm_i32_ty],
+[llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>;
+def int_ppc_vsx_xvtsqrtdp :
+  PowerPC_VSX_Intrinsic<"xvtsqrtdp", [llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
+def int_ppc_vsx_xvtsqrtsp :
+  PowerPC_VSX_Intrinsic<"xvtsqrtsp", [llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
 def int_ppc_vsx_xxeval :
   PowerPC_VSX_Intrinsic<"xxeval", [llvm_v2i64_ty],
 

[clang] 7db7a35 - Fix uninitialized XRayArg

2020-09-24 Thread Ian Levesque via cfe-commits

Author: Ian Levesque
Date: 2020-09-25T00:20:36-04:00
New Revision: 7db7a355453887906d12ffb67df8fbaa5e9e873d

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

LOG: Fix uninitialized XRayArg

Added: 


Modified: 
clang/include/clang/Driver/XRayArgs.h

Removed: 




diff  --git a/clang/include/clang/Driver/XRayArgs.h 
b/clang/include/clang/Driver/XRayArgs.h
index 4c18fecd2763..6ed99a127669 100644
--- a/clang/include/clang/Driver/XRayArgs.h
+++ b/clang/include/clang/Driver/XRayArgs.h
@@ -33,7 +33,7 @@ class XRayArgs {
   bool XRayIgnoreLoops = false;
   bool XRayFunctionIndex;
   int XRayFunctionGroups = 1;
-  int XRaySelectedFunctionGroup;
+  int XRaySelectedFunctionGroup = 0;
 
 public:
   /// Parses the XRay arguments from an argument list.



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


[PATCH] D75574: RFC: Implement objc_direct_protocol attribute to remove protocol metadata

2020-09-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGObjC.cpp:490
+  llvm::UniqueVector FoundProtocols;
+  std::set DeclaredProtocols;
+

You should use llvm::DenseSet for this.  But in general there are more sets 
here than I think you really need, and you're building them eagerly when you 
don't have to.  I would suggest:

1. Walk the list of declared protocols, adding the runtime protocols to the 
main result list and the first runtime protocols implied by the non-runtime 
protocols to a different list.

2. If there are any protocols in the first-implied list (which is unlikely), 
build the implied-protocols set for all the protocols in the main list 
(inclusive of the protocols there) and the first-implied list (exclusive).  It 
would be totally reasonable to add a method to make this easier: `void 
ObjCProtocolDecl::getImpliedProtocols(llvm::DenseSet 
&) const;`

3. Add any protocols that are in the first-implied list but not the implied set 
back to the main list.

Also, protocols can be redeclared, so you should make sure to map to the 
canonical decl before adding them to a set (or UniqueVector).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75574

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


[PATCH] D88130: [PPC] [AIX] Implement calling convention IR for C99 complex types on AIX

2020-09-24 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA accepted this revision.
ZarkoCA 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/D88130/new/

https://reviews.llvm.org/D88130

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


[PATCH] D88105: [NFC] [PPC] Add PowerPC expected IR tests for C99 complex

2020-09-24 Thread Zarko Todorovski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG64b8a633a872: [NFC] [PPC] Add PowerPC expected IR tests for 
C99 complex (authored by cebowleratibm, committed by ZarkoCA).

Changed prior to commit:
  https://reviews.llvm.org/D88105?vs=293917&id=294222#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88105

Files:
  clang/test/CodeGen/powerpc-c99complex.c


Index: clang/test/CodeGen/powerpc-c99complex.c
===
--- /dev/null
+++ clang/test/CodeGen/powerpc-c99complex.c
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux -emit-llvm %s -o - | 
FileCheck %s --check-prefixes=PPC64LNX
+// RUN: %clang_cc1 -triple ppc64le-unknown-linux -emit-llvm %s -o - | 
FileCheck %s --check-prefixes=PPC64LNX
+// RUN: %clang_cc1 -triple powerpc-unknown-linux -emit-llvm %s -o - | 
FileCheck %s --check-prefix=PPC32LNX
+
+_Complex float foo1(_Complex float x) {
+  return x;
+// PPC64LNX-LABEL:   define { float, float } @foo1(float %x.{{.*}}, float 
%x.{{.*}}) #0 {
+// PPC64LNX: ret { float, float }
+
+// PPC32LNX-LABEL:   define void @foo1({ float, float }* noalias sret 
align 4 %agg.result, { float, float }* byval({ float, float }) align 4 %x) #0 {
+// PPC32LNX: [[RETREAL:%.*]] = getelementptr inbounds { float, 
float }, { float, float }* %agg.result, i32 0, i32 0
+// PPC32LNX-NEXT:[[RETIMAG:%.*]] = getelementptr inbounds { float, 
float }, { float, float }* %agg.result, i32 0, i32 1
+// PPC32LNX-NEXT:store float %{{.*}}, float* [[RETREAL]], align 4
+// PPC32LNX-NEXT:store float %{{.*}}, float* [[RETIMAG]], align 4
+}
+
+_Complex double foo2(_Complex double x) {
+  return x;
+// PPC64LNX-LABEL:   define { double, double } @foo2(double %x.{{.*}}, 
double %x.{{.*}}) #0 {
+// PPC64LNX: ret { double, double }
+
+// PPC32LNX-LABEL:   define void @foo2({ double, double }* noalias sret 
align 8 %agg.result, { double, double }* byval({ double, double }) align 8 %x) 
#0 {
+// PPC32LNX: [[RETREAL:%.*]] = getelementptr inbounds { double, 
double }, { double, double }* %agg.result, i32 0, i32 0
+// PPC32LNX-NEXT:[[RETIMAG:%.*]] = getelementptr inbounds { double, 
double }, { double, double }* %agg.result, i32 0, i32 1
+// PPC32LNX-NEXT:store double %{{.*}}, double* [[RETREAL]], align 8
+// PPC32LNX-NEXT:store double %{{.*}}, double* [[RETIMAG]], align 8
+}
+
+_Complex long double foo3(_Complex long double x) {
+  return x;
+// PPC64LNX-LABEL:  define { ppc_fp128, ppc_fp128 } @foo3(ppc_fp128 
%x.{{.*}}, ppc_fp128 %x.{{.*}}) #0 {
+// PPC64LNX:ret { ppc_fp128, ppc_fp128 }
+
+// PPC32LNX-LABEL:  define void @foo3({ ppc_fp128, ppc_fp128 }* noalias 
sret align 16 %agg.result, { ppc_fp128, ppc_fp128 }* byval({ ppc_fp128, 
ppc_fp128 }) align 16 %x) #0 {
+// PPC32LNX:[[RETREAL:%.*]] = getelementptr inbounds { ppc_fp128, 
ppc_fp128 }, { ppc_fp128, ppc_fp128 }* %agg.result, i32 0, i32 0
+// PPC32LNX-NEXT:   [[RETIMAG:%.*]] = getelementptr inbounds { ppc_fp128, 
ppc_fp128 }, { ppc_fp128, ppc_fp128 }* %agg.result, i32 0, i32 1
+// PPC32LNX-NEXT:   store ppc_fp128 %{{.*}}, ppc_fp128* [[RETREAL]], align 
16
+// PPC32LNX-NEXT:   store ppc_fp128 %{{.*}}, ppc_fp128* [[RETIMAG]], align 
16
+}


Index: clang/test/CodeGen/powerpc-c99complex.c
===
--- /dev/null
+++ clang/test/CodeGen/powerpc-c99complex.c
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux -emit-llvm %s -o - | FileCheck %s --check-prefixes=PPC64LNX
+// RUN: %clang_cc1 -triple ppc64le-unknown-linux -emit-llvm %s -o - | FileCheck %s --check-prefixes=PPC64LNX
+// RUN: %clang_cc1 -triple powerpc-unknown-linux -emit-llvm %s -o - | FileCheck %s --check-prefix=PPC32LNX
+
+_Complex float foo1(_Complex float x) {
+  return x;
+// PPC64LNX-LABEL:   define { float, float } @foo1(float %x.{{.*}}, float %x.{{.*}}) #0 {
+// PPC64LNX: ret { float, float }
+
+// PPC32LNX-LABEL:   define void @foo1({ float, float }* noalias sret align 4 %agg.result, { float, float }* byval({ float, float }) align 4 %x) #0 {
+// PPC32LNX: [[RETREAL:%.*]] = getelementptr inbounds { float, float }, { float, float }* %agg.result, i32 0, i32 0
+// PPC32LNX-NEXT:[[RETIMAG:%.*]] = getelementptr inbounds { float, float }, { float, float }* %agg.result, i32 0, i32 1
+// PPC32LNX-NEXT:store float %{{.*}}, float* [[RETREAL]], align 4
+// PPC32LNX-NEXT:store float %{{.*}}, float* [[RETIMAG]], align 4
+}
+
+_Complex double foo2(_Complex double x) {
+  return x;
+// PPC64LNX-LABEL:   define { double, double } @foo2(double %x.{{.*}}, double %x.{{.*}}) #0 {
+// PPC64LNX: ret { double, double }
+
+// PPC32LNX-LABEL:   define void @foo2(

[clang] 64b8a63 - [NFC] [PPC] Add PowerPC expected IR tests for C99 complex

2020-09-24 Thread Zarko Todorovski via cfe-commits

Author: Chris Bowler
Date: 2020-09-24T23:28:40-04:00
New Revision: 64b8a633a872f25c8b3f9414c22165405400ea10

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

LOG: [NFC] [PPC] Add PowerPC expected IR tests for C99 complex

Adding this test so that I can extend it in a follow on patch with
expected IR for AIX when I implement complex handling in
AIXABIInfo.

Reviewed By: daltenty, ZarkoCA

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

Added: 
clang/test/CodeGen/powerpc-c99complex.c

Modified: 


Removed: 




diff  --git a/clang/test/CodeGen/powerpc-c99complex.c 
b/clang/test/CodeGen/powerpc-c99complex.c
new file mode 100644
index ..95c71ee4ec81
--- /dev/null
+++ b/clang/test/CodeGen/powerpc-c99complex.c
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux -emit-llvm %s -o - | 
FileCheck %s --check-prefixes=PPC64LNX
+// RUN: %clang_cc1 -triple ppc64le-unknown-linux -emit-llvm %s -o - | 
FileCheck %s --check-prefixes=PPC64LNX
+// RUN: %clang_cc1 -triple powerpc-unknown-linux -emit-llvm %s -o - | 
FileCheck %s --check-prefix=PPC32LNX
+
+_Complex float foo1(_Complex float x) {
+  return x;
+// PPC64LNX-LABEL:   define { float, float } @foo1(float %x.{{.*}}, float 
%x.{{.*}}) #0 {
+// PPC64LNX: ret { float, float }
+
+// PPC32LNX-LABEL:   define void @foo1({ float, float }* noalias sret 
align 4 %agg.result, { float, float }* byval({ float, float }) align 4 %x) #0 {
+// PPC32LNX: [[RETREAL:%.*]] = getelementptr inbounds { float, 
float }, { float, float }* %agg.result, i32 0, i32 0
+// PPC32LNX-NEXT:[[RETIMAG:%.*]] = getelementptr inbounds { float, 
float }, { float, float }* %agg.result, i32 0, i32 1
+// PPC32LNX-NEXT:store float %{{.*}}, float* [[RETREAL]], align 4
+// PPC32LNX-NEXT:store float %{{.*}}, float* [[RETIMAG]], align 4
+}
+
+_Complex double foo2(_Complex double x) {
+  return x;
+// PPC64LNX-LABEL:   define { double, double } @foo2(double %x.{{.*}}, 
double %x.{{.*}}) #0 {
+// PPC64LNX: ret { double, double }
+
+// PPC32LNX-LABEL:   define void @foo2({ double, double }* noalias sret 
align 8 %agg.result, { double, double }* byval({ double, double }) align 8 %x) 
#0 {
+// PPC32LNX: [[RETREAL:%.*]] = getelementptr inbounds { double, 
double }, { double, double }* %agg.result, i32 0, i32 0
+// PPC32LNX-NEXT:[[RETIMAG:%.*]] = getelementptr inbounds { double, 
double }, { double, double }* %agg.result, i32 0, i32 1
+// PPC32LNX-NEXT:store double %{{.*}}, double* [[RETREAL]], align 8
+// PPC32LNX-NEXT:store double %{{.*}}, double* [[RETIMAG]], align 8
+}
+
+_Complex long double foo3(_Complex long double x) {
+  return x;
+// PPC64LNX-LABEL:  define { ppc_fp128, ppc_fp128 } @foo3(ppc_fp128 
%x.{{.*}}, ppc_fp128 %x.{{.*}}) #0 {
+// PPC64LNX:ret { ppc_fp128, ppc_fp128 }
+
+// PPC32LNX-LABEL:  define void @foo3({ ppc_fp128, ppc_fp128 }* noalias 
sret align 16 %agg.result, { ppc_fp128, ppc_fp128 }* byval({ ppc_fp128, 
ppc_fp128 }) align 16 %x) #0 {
+// PPC32LNX:[[RETREAL:%.*]] = getelementptr inbounds { ppc_fp128, 
ppc_fp128 }, { ppc_fp128, ppc_fp128 }* %agg.result, i32 0, i32 0
+// PPC32LNX-NEXT:   [[RETIMAG:%.*]] = getelementptr inbounds { ppc_fp128, 
ppc_fp128 }, { ppc_fp128, ppc_fp128 }* %agg.result, i32 0, i32 1
+// PPC32LNX-NEXT:   store ppc_fp128 %{{.*}}, ppc_fp128* [[RETREAL]], align 
16
+// PPC32LNX-NEXT:   store ppc_fp128 %{{.*}}, ppc_fp128* [[RETIMAG]], align 
16
+}



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


[PATCH] D88275: [ASTMatchers] Add matcher `hasParentIgnoringImplicit`.

2020-09-24 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: gribozavr2.
Herald added a project: clang.
ymandel requested review of this revision.

This matcher combines the features of the `hasParent` matcher with
skip-implicit-expression-nodes behavior of `ignoringImplicit`. It finds the
first ancestor which is reachable through only implict expression nodes and
matches the given argument matcher.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88275

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -3190,6 +3190,26 @@
compoundStmt(hasParent(recordDecl();
 }
 
+TEST(HasParentIgnoringImplicit, MatchesExplicitParents) {
+  std::string Input = R"cc(
+float f() {
+int x = 3;
+int y = 3.0;
+return y;
+}
+  )cc";
+  EXPECT_TRUE(
+  matches(Input, declRefExpr(hasParentIgnoringImplicit(returnStmt();
+  EXPECT_TRUE(
+  matches(Input, floatLiteral(hasParentIgnoringImplicit(varDecl();
+  EXPECT_TRUE(
+  matches(Input, integerLiteral(hasParentIgnoringImplicit(varDecl();
+
+  // Make sure it only ignores implicit ancestors.
+  EXPECT_TRUE(
+  notMatches(Input, integerLiteral(hasParentIgnoringImplicit(declStmt();
+}
+
 TEST(HasParent, NoDuplicateParents) {
   class HasDuplicateParents : public BoundNodesCallback {
   public:
Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -544,9 +544,14 @@
 // don't invalidate any iterators.
 if (ResultCache.size() > MaxMemoizationEntries)
   ResultCache.clear();
-if (MatchMode == AncestorMatchMode::AMM_ParentOnly)
+switch (MatchMode) {
+case AncestorMatchMode::AMM_ParentOnly:
   return matchesParentOf(Node, Matcher, Builder);
-return matchesAnyAncestorOf(Node, Ctx, Matcher, Builder);
+case AncestorMatchMode::AMM_FirstExplicitOnly:
+  return matchesFirstExplicitAncestorOf(Node, Matcher, Builder);
+case AncestorMatchMode::AMM_All:
+  return matchesAnyAncestorOf(Node, Ctx, Matcher, Builder);
+}
   }
 
   // Matches all registered matchers on the given node and calls the
@@ -714,6 +719,33 @@
 return false;
   }
 
+  // Returns whether the first explicit (`Expr`) ancestor of \p Node matches \p
+  // Matcher. That is, like matchesParentOf but skipping implicit parents.
+  // Unlike matchesAnyAncestorOf there's no memoization: it doesn't save much.
+  bool matchesFirstExplicitAncestorOf(const DynTypedNode &Node,
+  const DynTypedMatcher &Matcher,
+  BoundNodesTreeBuilder *Builder) {
+for (const auto &Parent : ActiveASTContext->getParents(Node)) {
+  if (const auto *E = Parent.get())
+// If the parent is an implicit node, match on *its* parents
+// instead. Use DFS, since we expect that expressions are relatively
+// shallow.
+if (clang::isa(E) || clang::isa(E) ||
+clang::isa(E) ||
+clang::isa(E)) {
+  if (matchesFirstExplicitAncestorOf(Parent, Matcher, Builder))
+return true;
+  continue;
+}
+  BoundNodesTreeBuilder BuilderCopy = *Builder;
+  if (Matcher.matches(Parent, this, &BuilderCopy)) {
+*Builder = std::move(BuilderCopy);
+return true;
+  }
+}
+return false;
+  }
+
   // Returns whether an ancestor of \p Node matches \p Matcher.
   //
   // The order of matching (which can lead to different nodes being bound in
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -985,7 +985,11 @@
 AMM_All,
 
 /// Direct parent only.
-AMM_ParentOnly
+AMM_ParentOnly,
+
+/// Considers the first non-implicit `Expr` ancestor. Intuitively, like
+/// `ignoringImplicit` for matching parents.
+AMM_FirstExplicitOnly
   };
 
   virtual ~ASTMatchFinder() = default;
@@ -1515,6 +1519,26 @@
   }
 };
 
+/// Matches nodes of type \c T that have a parent node for which the given inner
+/// matcher matches. If the parent is an implicit expression, considers the
+/// parent's parent (and so on) instead, until an explicit parent is found. That
+/// is, looks for an ancestor that is separated from `Node` only by implicit
+/// expression nodes and matches `ParentMatcher`.
+tem

[PATCH] D72218: [clang-tidy] new altera kernel name restriction check

2020-09-24 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/altera-kernel-name-restriction.rst:4
+altera-kernel-name-restriction
+
+

Please make same length as text above.


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

https://reviews.llvm.org/D72218

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


[PATCH] D72218: [clang-tidy] new altera kernel name restriction check

2020-09-24 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 294215.
ffrankies edited the summary of this revision.
ffrankies added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

- Rebased code and fixed merge conflicts with  D66564 

- Added KernelNameRestrictionCheck.cpp to BUILD.gn


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

https://reviews.llvm.org/D72218

Files:
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp
  clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/altera-kernel-name-restriction.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/KERNEL.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/VHDL.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/Verilog.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/kernel.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/kernel.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/other_Verilog.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/otherdir/vhdl.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/otherthing.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/some/dir/kernel.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/some_kernel.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/somedir/verilog.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/thing.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/vERILOG.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/verilog.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/vhdl.CL
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/vhdl.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/vhdl_number_two.cl
  clang-tools-extra/test/clang-tidy/checkers/altera-kernel-name-restriction.cpp
  llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/altera/BUILD.gn

Index: llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/altera/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/altera/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/altera/BUILD.gn
@@ -13,6 +13,7 @@
   ]
   sources = [
 "AlteraTidyModule.cpp",
+"KernelNameRestrictionCheck.cpp",
 "StructPackAlignCheck.cpp",
   ]
 }
Index: clang-tools-extra/test/clang-tidy/checkers/altera-kernel-name-restriction.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-kernel-name-restriction.cpp
@@ -0,0 +1,42 @@
+// RUN: %check_clang_tidy %s altera-kernel-name-restriction %t -- -- -I%S/Inputs/altera-kernel-name-restriction
+
+// These are the banned kernel filenames, and should trigger warnings
+#include "kernel.cl"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: The imported kernel source file is named 'kernel.cl','Verilog.cl', or 'VHDL.cl', which could cause compilation errors. [altera-kernel-name-restriction]
+#include "Verilog.cl"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: The imported kernel source file is named 'kernel.cl','Verilog.cl', or 'VHDL.cl', which could cause compilation errors. [altera-kernel-name-restriction]
+#include "VHDL.cl"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: The imported kernel source file is named 'kernel.cl','Verilog.cl', or 'VHDL.cl', which could cause compilation errors. [altera-kernel-name-restriction]
+
+// The warning should be triggered regardless of capitalization
+#include "KERNEL.cl"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: The imported kernel source file is named 'kernel.cl','Verilog.cl', or 'VHDL.cl', which could cause compilation errors. [altera-kernel-name-restriction]
+#include "vERILOG.cl"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: The imported kernel source file is named 'kernel.cl','Verilog.cl', or 'VHDL.cl', which could cause compilation errors. [altera-kernel-name-restriction]
+#include "vhdl.CL"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: The imported kernel source file is named 'kernel.cl','Verilog.cl', or 'VHDL.cl', which could cause compilation errors. [altera-kernel-name-restriction]
+
+// The warning should be triggered if the names are within a directory
+#i

[PATCH] D87953: [xray] Function coverage groups

2020-09-24 Thread Ian Levesque via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6f7fbdd2857f: [xray] Function coverage groups (authored by 
ianlevesque).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87953

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/XRayArgs.h
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/XRayArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/xray-function-groups.cpp
  llvm/docs/XRay.rst

Index: llvm/docs/XRay.rst
===
--- llvm/docs/XRay.rst
+++ llvm/docs/XRay.rst
@@ -62,17 +62,18 @@
 
   clang -fxray-instrument ...
 
-By default, functions that have at least 200 instructions will get XRay
-instrumentation points. You can tweak that number through the
+By default, functions that have at least 200 instructions (or contain a loop) will
+get XRay instrumentation points. You can tweak that number through the
 ``-fxray-instruction-threshold=`` flag:
 
 ::
 
   clang -fxray-instrument -fxray-instruction-threshold=1 ...
 
-You can also specifically instrument functions in your binary to either always
-or never be instrumented using source-level attributes. You can do it using the
-GCC-style attributes or C++11-style attributes.
+The loop detection can be disabled with ``-fxray-ignore-loops`` to use only the
+instruction threshold. You can also specifically instrument functions in your
+binary to either always or never be instrumented using source-level attributes.
+You can do it using the GCC-style attributes or C++11-style attributes.
 
 .. code-block:: c++
 
@@ -309,6 +310,35 @@
   instrumentation map in XRay-instrumented object files and binaries. The
   ``extract`` and ``stack`` subcommands uses this particular library.
 
+
+Minimizing Binary Size
+--
+
+XRay supports several different instrumentation points including ``function-entry``,
+``function-exit``, ``custom``, and ``typed`` points. These can be enabled individually
+using the ``-fxray-instrumentaton-bundle=`` flag. For example if you only wanted to
+instrument function entry and custom points you could specify:
+
+::
+
+  clang -fxray-instrument -fxray-instrumentation-bundle=function-entry,custom ...
+
+This will omit the other sled types entirely, reducing the binary size. You can also
+instrument just a sampled subset of functions using instrumentation groups.
+For example, to instrument only a quarter of available functions invoke:
+
+::
+
+  clang -fxray-instrument -fxray-function-groups=4
+
+A subset will be chosen arbitrarily based on a hash of the function name. To sample a
+different subset you can specify ``-fxray-selected-function-group=`` with a group number
+in the range of 0 to ``xray-function-groups`` - 1.  Together these options could be used
+to produce multiple binaries with different instrumented subsets. If all you need is
+runtime control over which functions are being traced at any given time it is better
+to selectively patch and unpatch the individual functions you need using the XRay
+Runtime Library's ``__xray_patch_function()`` method.
+
 Future Work
 ===
 
Index: clang/test/CodeGen/xray-function-groups.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xray-function-groups.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -fxray-instrument -fxray-instruction-threshold=1 -fxray-function-groups=3 -fxray-selected-function-group=0 \
+// RUN:-emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck --check-prefix=GROUP0 %s
+
+// RUN: %clang_cc1 -fxray-instrument -fxray-instruction-threshold=1 -fxray-function-groups=3 -fxray-selected-function-group=1 \
+// RUN:-emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck --check-prefix=GROUP1 %s
+
+// RUN: %clang_cc1 -fxray-instrument -fxray-instruction-threshold=1 -fxray-function-groups=3 -fxray-selected-function-group=2 \
+// RUN:-emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck --check-prefix=GROUP2 %s
+
+static int foo() { // part of group 0
+  return 1;
+}
+
+int bar() { // part of group 2
+  return 1;
+}
+
+int yarr() { // part of group 1
+  foo();
+  return 1;
+}
+
+[[clang::xray_always_instrument]] int always() { // part of group 0
+  return 1;
+}
+
+[[clang::xray_never_instrument]] int never() { // part of group 1
+  return 1;
+}
+
+// GROUP0: define{{.*}} i32 @_Z3barv() #[[ATTRS_BAR:[0-9]+]] {
+// GROUP0: define{{.*}} i32 @_Z4yarrv() #[[ATTRS_BAR]] {
+// GROUP0: define{{.*}} i32 @_ZL3foov() #[[ATTRS_FOO:[0-9]+]] {
+// GROUP0: define{{.*}} i32 @_Z6alwaysv() #[[ATTRS_ALWAYS:[0-9]+]] {
+// GROUP0: define{{.*}} i32 @_Z5neverv() #[[ATTRS_NEVER:[0-9]+]] {
+// GROUP0-DAG: attributes #[[ATTRS_BAR]] = {{.*}} "function-instrument"="xray-never" {{.*}}
+// GRO

[clang] 6f7fbdd - [xray] Function coverage groups

2020-09-24 Thread Ian Levesque via cfe-commits

Author: Ian Levesque
Date: 2020-09-24T22:09:53-04:00
New Revision: 6f7fbdd2857fc8a7280afbb26fd4e1a6450069e4

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

LOG: [xray] Function coverage groups

Add the ability to selectively instrument a subset of functions by dividing the 
functions into N logical groups and then selecting a group to cover. By 
selecting different groups over time you could cover the entire application 
incrementally with lower overhead than instrumenting the entire application at 
once.

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

Added: 
clang/test/CodeGen/xray-function-groups.cpp

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/include/clang/Driver/XRayArgs.h
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/Driver/XRayArgs.cpp
clang/lib/Frontend/CompilerInvocation.cpp
llvm/docs/XRay.rst

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index b5da2a9cde1a..a259218b29c6 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -120,6 +120,12 @@ CODEGENOPT(XRayOmitFunctionIndex , 1, 0)
 ///< XRay instrumentation.
 VALUE_CODEGENOPT(XRayInstructionThreshold , 32, 200)
 
+///< Only instrument 1 in N functions, by dividing functions into N total 
groups and
+///< instrumenting only the specified group at a time. Group numbers start at 0
+///< and end at N-1.
+VALUE_CODEGENOPT(XRayTotalFunctionGroups, 32, 1)
+VALUE_CODEGENOPT(XRaySelectedFunctionGroup, 32, 0)
+
 VALUE_CODEGENOPT(PatchableFunctionEntryCount , 32, 0) ///< Number of NOPs at 
function entry
 VALUE_CODEGENOPT(PatchableFunctionEntryOffset , 32, 0)
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d7c2496b8a5d..a1f3d7a4316f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1339,6 +1339,17 @@ def fxray_instrumentation_bundle :
   Group, Flags<[CC1Option]>,
   HelpText<"Select which XRay instrumentation points to emit. Options: all, 
none, function-entry, function-exit, function, custom. Default is 'all'.  
'function' includes both 'function-entry' and 'function-exit'.">;
 
+def fxray_function_groups :
+  Joined<["-"], "fxray-function-groups=">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Only instrument 1 of N groups">;
+
+def fxray_selected_function_group :
+  Joined<["-"], "fxray-selected-function-group=">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"When using -fxray-function-groups, select which group of functions 
to instrument. Valid range is 0 to fxray-function-groups - 1">;
+
+
 def ffine_grained_bitfield_accesses : Flag<["-"],
   "ffine-grained-bitfield-accesses">, Group, Flags<[CC1Option]>,
   HelpText<"Use separate accesses for consecutive bitfield runs with legal 
widths and alignments.">;

diff  --git a/clang/include/clang/Driver/XRayArgs.h 
b/clang/include/clang/Driver/XRayArgs.h
index 2f055e5c6d7d..4c18fecd2763 100644
--- a/clang/include/clang/Driver/XRayArgs.h
+++ b/clang/include/clang/Driver/XRayArgs.h
@@ -32,6 +32,8 @@ class XRayArgs {
   bool XRayRT = true;
   bool XRayIgnoreLoops = false;
   bool XRayFunctionIndex;
+  int XRayFunctionGroups = 1;
+  int XRaySelectedFunctionGroup;
 
 public:
   /// Parses the XRay arguments from an argument list.

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 016c7105b52d..47ef5c830723 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -32,6 +32,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Dominators.h"
@@ -40,6 +41,7 @@
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/Operator.h"
+#include "llvm/Support/CRC.h"
 #include "llvm/Transforms/Utils/PromoteMemToReg.h"
 using namespace clang;
 using namespace CodeGen;
@@ -772,13 +774,16 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
 SanOpts.Mask &= ~SanitizerKind::Null;
 
   // Apply xray attributes to the function (as a string, for now)
+  bool AlwaysXRayAttr = false;
   if (const auto *XRayAttr = D ? D->getAttr() : nullptr) {
 if (CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
 XRayInstrKind::FunctionEntry) ||
 CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
 XRayInstrKind::FunctionExit)) {
-  if (XRayAttr->alwaysXRayInstrument() && ShouldXRayInstrumentFunction())
+  if

[clang] 8c98c88 - PR47176: Don't read from an inactive union member if a friend function

2020-09-24 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-09-24T19:02:27-07:00
New Revision: 8c98c8803430804010da06a07cfb291dab59067c

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

LOG: PR47176: Don't read from an inactive union member if a friend function
has default arguments and an exception specification.

Added: 


Modified: 
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/test/Parser/cxx0x-decl.cpp

Removed: 




diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 570f60fb9479..ee08cfc589e1 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -1367,7 +1367,7 @@ class Parser : public CodeCompletionHandler {
 
 void ParseLexedMethodDeclarations() override;
 
-Parser* Self;
+Parser *Self;
 
 /// Method - The method declaration.
 Decl *Method;

diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index d6b2eb8a9877..79628cfed1b2 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -6486,6 +6486,10 @@ void Parser::ParseFunctionDeclarator(Declarator &D,
   InitCXXThisScopeForDeclaratorIfRelevant(D, DS, ThisScope);
 
   // Parse exception-specification[opt].
+  // FIXME: Per [class.mem]p6, all exception-specifications at class scope
+  // should be delayed, including those for non-members (eg, friend
+  // declarations). But only applying this to member declarations is
+  // consistent with what other implementations do.
   bool Delayed = D.isFirstDeclarationOfMember() &&
  D.isFunctionDeclaratorAFunctionDeclaration();
   if (Delayed && Actions.isLibstdcxxEagerExceptionSpecHack(D) &&

diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
b/clang/lib/Parse/ParseDeclCXX.cpp
index 290b3c5df959..059d875d683d 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -2186,17 +2186,20 @@ void Parser::HandleMemberFunctionDeclDelays(Declarator& 
DeclaratorInfo,
 auto LateMethod = new LateParsedMethodDeclaration(this, ThisDecl);
 getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
 
-// Stash the exception-specification tokens in the late-pased method.
-LateMethod->ExceptionSpecTokens = FTI.ExceptionSpecTokens;
-FTI.ExceptionSpecTokens = nullptr;
-
-// Push tokens for each parameter.  Those that do not have
-// defaults will be NULL.
+// Push tokens for each parameter. Those that do not have defaults will be
+// NULL. We need to track all the parameters so that we can push them into
+// scope for later parameters and perhaps for the exception specification.
 LateMethod->DefaultArgs.reserve(FTI.NumParams);
 for (unsigned ParamIdx = 0; ParamIdx < FTI.NumParams; ++ParamIdx)
   LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
   FTI.Params[ParamIdx].Param,
   std::move(FTI.Params[ParamIdx].DefaultArgTokens)));
+
+// Stash the exception-specification tokens in the late-pased method.
+if (FTI.getExceptionSpecType() == EST_Unparsed) {
+  LateMethod->ExceptionSpecTokens = FTI.ExceptionSpecTokens;
+  FTI.ExceptionSpecTokens = nullptr;
+}
   }
 }
 

diff  --git a/clang/test/Parser/cxx0x-decl.cpp 
b/clang/test/Parser/cxx0x-decl.cpp
index 4ddcb8ccfd0f..8be98d6ef299 100644
--- a/clang/test/Parser/cxx0x-decl.cpp
+++ b/clang/test/Parser/cxx0x-decl.cpp
@@ -199,6 +199,11 @@ namespace AliasDeclEndLocation {
   B something_else;
 }
 
+class PR47176 {
+  friend void f(PR47176, int = 0) noexcept(true) {}
+};
+static_assert(noexcept(f(PR47176())), "");
+
 struct Base { virtual void f() = 0; virtual void g() = 0; virtual void h() = 
0; };
 struct MemberComponentOrder : Base {
   void f() override __asm__("foobar") __attribute__(( )) {}



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


[PATCH] D54222: [clang-tidy] Add a check to detect returning static locals in public headers

2020-09-24 Thread Joe Ranieri via Phabricator via cfe-commits
jranieri-grammatech added a comment.

In D54222#1290789 , @JonasToth wrote:

> I agree with @Eugene.Zelenko that this check should rather live in 
> `bugprone-` as the issue its diagnosing is not LLVM specific. It is ok to add 
> an alias into the llvm module.

Here are the warnings it issues with the patch's matcher:

  clang/include/clang/StaticAnalyzer/Core/CheckerManager.h:625:43: warning: 
address of static local variable 'tag' may not be identical across library 
boundaries [llvm-problematic-statics]
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:219:1:
 warning: address of static local variable 'Index' may not be identical across 
library boundaries [llvm-problematic-statics]
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h:25:1:
 warning: address of static local variable 'Index' may not be identical across 
library boundaries [llvm-problematic-statics]

And here are the additional warnings it issues when relaxing the matcher (to be 
`unless(isExpansionInMainFile())`):

  clang/lib/StaticAnalyzer/Checkers/Iterator.h:130:47: warning: address of 
static local variable 'Index' may not be identical across library boundaries 
[llvm-problematic-statics]
  clang/lib/StaticAnalyzer/Checkers/Iterator.h:136:47: warning: address of 
static local variable 'Index' may not be identical across library boundaries 
[llvm-problematic-statics]
  clang/lib/StaticAnalyzer/Checkers/Iterator.h:142:47: warning: address of 
static local variable 'Index' may not be identical across library boundaries 
[llvm-problematic-statics]
  clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h:60:5: warning: 
address of static local variable 'index' may not be identical across library 
boundaries [llvm-problematic-statics]
  llvm/utils/unittest/googletest/src/gtest.cc:3989:3: warning: address of 
static local variable 'instance' may not be identical across library boundaries 
[llvm-problematic-statics]

And also this one, which was hidden by default but made running tidy noisier by 
always saying there was a hidden warning:

  /usr/bin/../include/c++/v1/functional:1960:9: warning: address of static 
local variable '__policy_' may not be identical across library boundaries 
[llvm-problematic-statics]

All of the first set of warnings might be actual problems, but the second set 
definitely aren't problems because they aren't going to be used across shared 
library boundaries. By making this be a LLVM-specific check, we can avoid the 
noise of these false positives. Also, I looked through the C++ Core Guidelines 
for any rules that might address this but didn't see anything relevant.

Thoughts?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D54222

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


[PATCH] D87953: [xray] Function coverage groups

2020-09-24 Thread Ian Levesque via Phabricator via cfe-commits
ianlevesque updated this revision to Diff 294213.
ianlevesque added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Add static function to the test case, update documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87953

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/XRayArgs.h
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/XRayArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/xray-function-groups.cpp
  llvm/docs/XRay.rst

Index: llvm/docs/XRay.rst
===
--- llvm/docs/XRay.rst
+++ llvm/docs/XRay.rst
@@ -62,17 +62,18 @@
 
   clang -fxray-instrument ...
 
-By default, functions that have at least 200 instructions will get XRay
-instrumentation points. You can tweak that number through the
+By default, functions that have at least 200 instructions (or contain a loop) will
+get XRay instrumentation points. You can tweak that number through the
 ``-fxray-instruction-threshold=`` flag:
 
 ::
 
   clang -fxray-instrument -fxray-instruction-threshold=1 ...
 
-You can also specifically instrument functions in your binary to either always
-or never be instrumented using source-level attributes. You can do it using the
-GCC-style attributes or C++11-style attributes.
+The loop detection can be disabled with ``-fxray-ignore-loops`` to use only the
+instruction threshold. You can also specifically instrument functions in your
+binary to either always or never be instrumented using source-level attributes.
+You can do it using the GCC-style attributes or C++11-style attributes.
 
 .. code-block:: c++
 
@@ -309,6 +310,35 @@
   instrumentation map in XRay-instrumented object files and binaries. The
   ``extract`` and ``stack`` subcommands uses this particular library.
 
+
+Minimizing Binary Size
+--
+
+XRay supports several different instrumentation points including ``function-entry``,
+``function-exit``, ``custom``, and ``typed`` points. These can be enabled individually
+using the ``-fxray-instrumentaton-bundle=`` flag. For example if you only wanted to
+instrument function entry and custom points you could specify:
+
+::
+
+  clang -fxray-instrument -fxray-instrumentation-bundle=function-entry,custom ...
+
+This will omit the other sled types entirely, reducing the binary size. You can also
+instrument just a sampled subset of functions using instrumentation groups.
+For example, to instrument only a quarter of available functions invoke:
+
+::
+
+  clang -fxray-instrument -fxray-function-groups=4
+
+A subset will be chosen arbitrarily based on a hash of the function name. To sample a
+different subset you can specify ``-fxray-selected-function-group=`` with a group number
+in the range of 0 to ``xray-function-groups`` - 1.  Together these options could be used
+to produce multiple binaries with different instrumented subsets. If all you need is
+runtime control over which functions are being traced at any given time it is better
+to selectively patch and unpatch the individual functions you need using the XRay
+Runtime Library's ``__xray_patch_function()`` method.
+
 Future Work
 ===
 
Index: clang/test/CodeGen/xray-function-groups.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xray-function-groups.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -fxray-instrument -fxray-instruction-threshold=1 -fxray-function-groups=3 -fxray-selected-function-group=0 \
+// RUN:-emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck --check-prefix=GROUP0 %s
+
+// RUN: %clang_cc1 -fxray-instrument -fxray-instruction-threshold=1 -fxray-function-groups=3 -fxray-selected-function-group=1 \
+// RUN:-emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck --check-prefix=GROUP1 %s
+
+// RUN: %clang_cc1 -fxray-instrument -fxray-instruction-threshold=1 -fxray-function-groups=3 -fxray-selected-function-group=2 \
+// RUN:-emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck --check-prefix=GROUP2 %s
+
+static int foo() { // part of group 0
+  return 1;
+}
+
+int bar() { // part of group 2
+  return 1;
+}
+
+int yarr() { // part of group 1
+  foo();
+  return 1;
+}
+
+[[clang::xray_always_instrument]] int always() { // part of group 0
+  return 1;
+}
+
+[[clang::xray_never_instrument]] int never() { // part of group 1
+  return 1;
+}
+
+// GROUP0: define{{.*}} i32 @_Z3barv() #[[ATTRS_BAR:[0-9]+]] {
+// GROUP0: define{{.*}} i32 @_Z4yarrv() #[[ATTRS_BAR]] {
+// GROUP0: define{{.*}} i32 @_ZL3foov() #[[ATTRS_FOO:[0-9]+]] {
+// GROUP0: define{{.*}} i32 @_Z6alwaysv() #[[ATTRS_ALWAYS:[0-9]+]] {
+// GROUP0: define{{.*}} i32 @_Z5neverv() #[[ATTRS_NEVER:[0-9]+]] {
+// GROUP0-DAG: attributes #[[ATTRS_BAR]] = {{.*}} "fun

[PATCH] D87953: [xray] Function coverage groups

2020-09-24 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris accepted this revision.
dberris added a comment.
This revision is now accepted and ready to land.

Okay, I think I understand the motivation a little bit more now (i.e. sampling 
seems to be a useful thing to do anyway, regardless of whether we have the 
other facilities).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87953

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


[PATCH] D88227: [clang-format] Add a SpaceBeforePointerQualifiers style option

2020-09-24 Thread Mark Zeren via Phabricator via cfe-commits
mzeren-vmw added a comment.

Perhaps PointerAlignment should be an enum of Left, Middle, Right?
We maintain an internal patch that adds "ReferenceAlignment" as separate from 
PointerAlignment. So one could have:

  PointerAlignment: Middle
  ReferenceAlignment: Left


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88227

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


[PATCH] D87953: [xray] Function coverage groups

2020-09-24 Thread Ian Levesque via Phabricator via cfe-commits
ianlevesque added a comment.

I can update the docs @MaskRay, not a problem. I'll tweak the test a little too 
per your comment.

@dberris I think if we wanted to control it in a non-'random' (the crc32 was 
chosen so it would be consistent even though it's not really predictable up 
front) way we'd have to emit some lists of function attributes and use the 
-fxray-attr-list=FILE option to really dial that in. If we wanted entire 
modules we could have the build system apply xray's flags to each module 
differently, but we are unlikely to want to instrument every function of a 
module at the same time so we are back to having to use instruction thresholds 
to cut down on it.  Ultimately I think those two suggestions are legitimate 
alternative use cases but don't, for what we're trying to do, replace this 
strategy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87953

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


[PATCH] D75574: RFC: Implement objc_direct_protocol attribute to remove protocol metadata

2020-09-24 Thread Nathan Lanza via Phabricator via cfe-commits
lanza added inline comments.



Comment at: clang/lib/CodeGen/CGObjC.cpp:466
+  for (; begin != end; ++begin)
+AppendFirstRuntimeProtocols(*begin, PDs);
+

rjmccall wrote:
> Should this make an effort to avoid declaring redundant bases?  e.g.
> 
> ```
> @protocol Base @end
> @protocol NonRuntime @end
> @protocol Runtime @end
> @interface MyClass  @end
> @implementation MyClass @end
> ```
> 
> Ideally `MyClass` only declares conformance to `Runtime` rather than 
> redundantly declaring conformance to `Base`, which I think you'd naturally 
> get from this algorithm.
You are right. I fixed this but excluded the case where the declaration 
explicitly lists in it's `<>` declaration that it does inherit from a protocol. 
e.g. In the test case:

```
@protocol C @endp
@protocol B  @end
@protocol A  @end
__attribute__((objc_non_runtime_protocol)) @protocol Alpha @end
__attribute__((objc_non_runtime_protocol)) @protocol Beta @end
@interface Implementer : Root  @end
@implementation Implementer @end
```

The non-runtime removing algorithm generates `A,B,C` as the list but B and C 
are both redundant. It makes sense to remove `B` for that reason but since the 
declaration explicitly mentions `C` I vote that it makes sense to leave it 
included as that's what one would expect from a `class_copyProtocolList`. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75574

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


[PATCH] D75574: RFC: Implement objc_direct_protocol attribute to remove protocol metadata

2020-09-24 Thread Nathan Lanza via Phabricator via cfe-commits
lanza marked 5 inline comments as done.
lanza added a comment.

Fixed and added a test under the `REDUNDANCY` prefix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75574

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


[PATCH] D87332: [profile] Add %t LLVM_PROFILE_FILE option to substitute $TMPDIR

2020-09-24 Thread Ethan Vaughan via Phabricator via cfe-commits
ejvaughan accepted this revision.
ejvaughan added a comment.
This revision is now accepted and ready to land.

Changes look good to me. Thanks for implementing this, Vedant!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87332

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


[PATCH] D75574: RFC: Implement objc_direct_protocol attribute to remove protocol metadata

2020-09-24 Thread Nathan Lanza via Phabricator via cfe-commits
lanza updated this revision to Diff 294207.
lanza added a comment.

Fix duplicate inheritance issue


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75574

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/DeclObjC.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CGObjCRuntime.h
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/test/CodeGenObjC/non-runtime-protocol.m
  clang/test/Misc/pragma-attribute-supported-attributes-list.test

Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -118,6 +118,7 @@
 // CHECK-NEXT: ObjCExternallyRetained (SubjectMatchRule_variable_not_is_parameter, SubjectMatchRule_function, SubjectMatchRule_block, SubjectMatchRule_objc_method)
 // CHECK-NEXT: ObjCMethodFamily (SubjectMatchRule_objc_method)
 // CHECK-NEXT: ObjCNonLazyClass (SubjectMatchRule_objc_interface, SubjectMatchRule_objc_implementation)
+// CHECK-NEXT: ObjCNonRuntimeProtocol (SubjectMatchRule_objc_protocol)
 // CHECK-NEXT: ObjCPreciseLifetime (SubjectMatchRule_variable)
 // CHECK-NEXT: ObjCRequiresPropertyDefs (SubjectMatchRule_objc_interface)
 // CHECK-NEXT: ObjCRequiresSuper (SubjectMatchRule_objc_method)
Index: clang/test/CodeGenObjC/non-runtime-protocol.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/non-runtime-protocol.m
@@ -0,0 +1,142 @@
+// RUN: not %clang_cc1 -emit-llvm -fobjc-arc -triple x86_64-apple-darwin10 %s -DPROTOEXPR -o - 2>&1 \
+// RUN: | FileCheck -check-prefix=PROTOEXPR %s
+
+// RUN: %clang_cc1 -emit-llvm -fobjc-arc -triple x86_64-apple-darwin10 %s -DREDUNDANCY -o - \
+// RUN: | FileCheck -check-prefix=REDUNDANCY1 %s
+// RUN: %clang_cc1 -emit-llvm -fobjc-arc -triple x86_64-apple-darwin10 %s -DREDUNDANCY -o - \
+// RUN: | FileCheck -check-prefix=REDUNDANCY2 %s
+
+// RUN: %clang_cc1 -emit-llvm -fobjc-arc -triple x86_64-apple-darwin10 %s -DBASE -o - \
+// RUN: | FileCheck -check-prefix=NONFRAGILE %s
+// RUN: %clang_cc1 -emit-llvm -fobjc-arc -triple x86_64-apple-darwin10 %s -DINHERITANCE -o - \
+// RUN: | FileCheck -check-prefix=INHERITANCE %s
+
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s -DBASE -o - \
+// RUN: | FileCheck -check-prefix=FRAGILE %s
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s -DINHERITANCE -o - \
+// RUN: | FileCheck -check-prefix=FRAGILEINHERITANCE %s
+
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fobjc-runtime=gnustep %s -DBASE -o - \
+// RUN: | FileCheck -check-prefix=GNU %s
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fobjc-runtime=gnustep %s -DINHERITANCE -o - \
+// RUN: | FileCheck -check-prefix=GNUINHERITANCE %s
+//
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fobjc-runtime=gnustep-2 %s -DBASE -o - \
+// RUN: | FileCheck -check-prefix=GNU2 %s
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fobjc-runtime=gnustep-2 %s -DINHERITANCE -o - \
+// RUN: | FileCheck -check-prefix=GNU2INHERITANCE %s
+
+__attribute__((objc_root_class))
+@interface Root
+@end
+@implementation Root
+@end
+
+#ifdef REDUNDANCY
+// REDUNDANCY1-NOT: _OBJC_CLASS_PROTOCOLS_$_Implementer{{.*}}_OBJC_PROTOCOL_$_B
+// REDUNDANCY2: _OBJC_CLASS_PROTOCOLS_$_Implementer{{.*}}_OBJC_PROTOCOL_$_A{{.*}}_OBJC_PROTOCOL_$_C
+@protocol C
+@end
+@protocol B 
+@end
+@protocol A 
+@end
+__attribute__((objc_non_runtime_protocol)) @protocol Alpha
+@end
+__attribute__((objc_non_runtime_protocol)) @protocol Beta
+@end
+@interface Implementer : Root 
+@end
+@implementation Implementer
+@end
+#endif
+
+#ifdef BASE
+// Confirm that we're not emitting protocol information for the
+// NONFRAGILE-NOT: OBJC_CLASS_NAME{{.*}}NonRuntimeProtocol
+// NONFRAGILE-NOT: _OBJC_$_PROTOCOL_INSTANCE_METHODS_NonRuntimeProtocol
+// NONFRAGILE-NOT: _OBJC_$_PROTOCOL_CLASS_METHODS_NonRuntimeProtocol
+// NONFRAGILE-NOT: _OBJC_PROTOCOL_$_NonRuntimeProtocol
+// NONFRAGILE-NOT: _OBJC_LABEL_PROTOCOL_$_NonRuntimeProtocol
+// NONFRAGILE-NOT: _OBJC_CLASS_PROTOCOLS_$_NonRuntimeImplementer
+// FRAGILE-NOT: OBJC_CLASS_NAME_.{{.*}}"Runtime\00"
+// FRAGILE-NOT: OBJC_PROTOCOL_NonRuntime
+// FRAGILE_NOT: OBJC_PROTOCOLS_NonRuntimeImplementer
+// GNU-NOT: private unnamed_addr constant {{.*}} c"NonRuntimeProtocol\00"
+// GNU-NOT: @.objc_protocol {{.*}}
+// GNU2-NOT: private unnamed_addr constant {{.*}} c"NonRuntimeProtocol\00"
+// GNU2-NOT: @.objc_protocol {{.*}}
+__attribute__((objc_

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

2020-09-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D80344#2293954 , @tentzen wrote:

> In D80344#2291926 , @rjmccall wrote:
>
>> Okay.  I think we're on the same page about representation now.  If you can 
>> come up with a good replacement for "eha" in the intrinsic names, I think 
>> this is pretty much ready to go.
>
> how about seh.cppscope.begin() and seh.cppscope.end()? or any suggestion?

I like that better.  Maybe even just `seh.scope.begin`?  Or 
`seh.cleanupscope.begin`?  Cleanups aren't *inherently* a C++ feature, it's 
just that C doesn't officially have them and MSVC doesn't really support any 
non-C++ languages that do.

> As for pairing question, we simply utilizes existent Cleanup mechanism as you 
> described in which abnormal exits and normal fall-through are merged in a 
> 'cleanup' pad.  What this implementation does is to inject a scope.begin 
> right after a ctor and a scope.end right before dtor in cleanup-pad.  Use the 
> same example, it will be something like below:
>
>   void test(int x, int &state) {
> int jumpdest;
> state = 0;
> std::string a;  
> **seh.cppscope.begin();  // for object a**
> state = 1;
> if (x > 0) {
>   state = 2;
>   std::string b;
>   **seh.cppscope.begin();  // for b**
>   state = 3;
>   if (x > 10) {
> state = 4;
> jumpdest = 0;
> goto destroy_b;
>   }
>   state = 5;
>   std::string c;
>   **seh.cppscope.begin();  // for c**
>   state = 6;
>   **seh.cppscope.end(); // for c dtor**
>   c.~std::string();
>   jumpdest = 1;
> destroy_b:
>   **seh.cppscope.end();   // for b dtor**
>   b.~std::string();
>   switch (jumpdest) {
>   case 0: goto destroy_a;
>   case 1: goto fallthrough;
>   }
> fallthrough:
>   ;
> }
> state = 7;
>   destroy_a:
> **seh.cppscope.begin();  // for a dtor **
> a.~std::string();
>   }

Okay.  I feel fairly convinced that this will work for most cleanup situations. 
 You might need to do some IR-testing work in Clang to make sure Clang calls 
seh.scope.begin the right way when emitting conditional cleanups:

- We need to call it at some dominating point rather than at the current IP 
when we push the cleanup.
- We need to call it in the right order for the cleanups we enter.

Conditional cleanups come up when we need a cleanup in code that's not 
unconditionally run during a expression evaluation, like in the 2nd or 3rd 
operand of `?:` or in the RHS of `&&`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

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


[clang] 276f68e - Revert "Add a static_assert confirming that DiagnosticBuilder is small"

2020-09-24 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-09-24T16:39:46-07:00
New Revision: 276f68eace7c27f6805d69a30a4b2f186e42c56c

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

LOG: Revert "Add a static_assert confirming that DiagnosticBuilder is small"

This reverts commit a32feed0dbeac7606d042d0d7e041c9eaf12cd51.

This assert doesn't hold in 32-bit builds, I didn't do the math right.

Added: 


Modified: 
clang/lib/Basic/Diagnostic.cpp

Removed: 




diff  --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp
index c98fa6ebf817..661eabf9bc7c 100644
--- a/clang/lib/Basic/Diagnostic.cpp
+++ b/clang/lib/Basic/Diagnostic.cpp
@@ -40,9 +40,6 @@
 
 using namespace clang;
 
-static_assert(sizeof(DiagnosticBuilder) <= 2 * sizeof(void *),
-  "DiagnosticBuilder should be small, see class doc comments");
-
 const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB,
DiagNullabilityKind nullability) {
   StringRef string;



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


[clang] a32feed - Add a static_assert confirming that DiagnosticBuilder is small

2020-09-24 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-09-24T16:38:41-07:00
New Revision: a32feed0dbeac7606d042d0d7e041c9eaf12cd51

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

LOG: Add a static_assert confirming that DiagnosticBuilder is small

Added: 


Modified: 
clang/lib/Basic/Diagnostic.cpp

Removed: 




diff  --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp
index 661eabf9bc7c..c98fa6ebf817 100644
--- a/clang/lib/Basic/Diagnostic.cpp
+++ b/clang/lib/Basic/Diagnostic.cpp
@@ -40,6 +40,9 @@
 
 using namespace clang;
 
+static_assert(sizeof(DiagnosticBuilder) <= 2 * sizeof(void *),
+  "DiagnosticBuilder should be small, see class doc comments");
+
 const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB,
DiagNullabilityKind nullability) {
   StringRef string;



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


[PATCH] D68364: Implement C++20's P0784 (More constexpr containers)

2020-09-24 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

Hi. Our GCC builders are failing with

  [182/12433] CXX kernel-x64-gcc/obj/kernel/lib/ktl/ktl.dummy-new.cc.o
  FAILED: kernel-x64-gcc/obj/kernel/lib/ktl/ktl.dummy-new.cc.o
  /b/s/w/ir/k/fuchsia/prebuilt/third_party/goma/linux-x64/gomacc  
../../prebuilt/third_party/gcc/linux-x64/bin/x86_64-elf-g++ -MD -MF 
kernel-x64-gcc/obj/kernel/lib/ktl/ktl.dummy-new.cc.o.d -o kernel-x64...
  In file included from ../../zircon/kernel/lib/ktl/dummy-new.cc:7:
  ../../prebuilt/third_party/clang/linux-x64/include/c++/v1/new: In function 
'constexpr void* std::__2::__libcpp_allocate(size_t, size_t)':
  ../../prebuilt/third_party/clang/linux-x64/include/c++/v1/new:252:24: error: 
call to non-'constexpr' function 'void* operator new(size_t)'
252 |   return ::operator new(__size);
|  ~~^~~~
  In file included from ../../zircon/kernel/lib/ktl/dummy-new.cc:7:
  ../../prebuilt/third_party/clang/linux-x64/include/c++/v1/new:186:66: note: 
'void* operator new(size_t)' declared here
186 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* 
operator new(std::size_t __sz) _THROW_BAD_ALLOC;
|  
^~~~

I presume it's because `_LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE` is defined 
from

  #if !__has_builtin(__builtin_operator_new) || 
!__has_builtin(__builtin_operator_delete)
  #define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
  #endif

Is there a recommended way for working around this? We're using GCC 10.2.1. 
Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68364

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


[clang] ecfc9b9 - [MS] For unknown ISAs, pass non-trivially copyable arguments indirectly

2020-09-24 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-09-24T16:29:48-07:00
New Revision: ecfc9b971269a86b101cddf1fd9f0976be4096d0

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

LOG: [MS] For unknown ISAs, pass non-trivially copyable arguments indirectly

Passing them directly is likely to be non-conforming, since it usually
involves copying the bytes of the record. For unknown architectures, we
don't know what MSVC does or will do, but we should at least try to
conform as well as we can.

Added: 
clang/test/CodeGenCXX/microsoft-abi-unknown-arch.cpp

Modified: 
clang/lib/CodeGen/MicrosoftCXXABI.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp 
b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index 5fcb892f7fb8..cae79099dd6b 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -825,7 +825,7 @@ MicrosoftCXXABI::getRecordArgABI(const CXXRecordDecl *RD) 
const {
   switch (CGM.getTarget().getTriple().getArch()) {
   default:
 // FIXME: Implement for other architectures.
-return RAA_Default;
+return RAA_Indirect;
 
   case llvm::Triple::thumb:
 // Pass things indirectly for now because it is simple.

diff  --git a/clang/test/CodeGenCXX/microsoft-abi-unknown-arch.cpp 
b/clang/test/CodeGenCXX/microsoft-abi-unknown-arch.cpp
new file mode 100644
index ..bb0364186eb4
--- /dev/null
+++ b/clang/test/CodeGenCXX/microsoft-abi-unknown-arch.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=ppc64-windows-msvc | FileCheck %s
+
+// The purpose of this test is to see that we do something reasonable for
+// architectures where we haven't checked what MSVC does.
+
+struct A {
+  A() : a(42) {}
+  A(const A &o) : a(o.a) {}
+  ~A() {}
+  int a;
+};
+
+struct B {
+  A foo(A o);
+};
+
+A B::foo(A x) {
+  return x;
+}
+
+// CHECK-LABEL: define void @"?foo@B@@QEAA?AUA@@U2@@Z"(%struct.B* %this, 
%struct.A* noalias sret align 4 %agg.result, %struct.A* %x)



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


[clang] b8a50e9 - [MS] Simplify rules for passing C++ records

2020-09-24 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-09-24T16:29:47-07:00
New Revision: b8a50e920704436ddcbe0cc9d2020935d7e37095

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

LOG: [MS] Simplify rules for passing C++ records

Regardless of the target architecture, we should always use the C rules
(RAA_Default) for records that "canBePassedInRegisters". Those are
trivially copyable things, and things marked with [[trivial_abi]].

This should be NFC, although it changes where the final decision about
x86_32 overaligned records is made. The current x86_32 C rules say that
overaligned things are passed indirectly, so there is no functional
difference.

Added: 


Modified: 
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/test/CodeGenCXX/inalloca-overaligned.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp 
b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index 4f725793cb94..5fcb892f7fb8 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -816,16 +816,22 @@ class MicrosoftCXXABI : public CGCXXABI {
 
 CGCXXABI::RecordArgABI
 MicrosoftCXXABI::getRecordArgABI(const CXXRecordDecl *RD) const {
+  // Use the default C calling convention rules for things that can be passed 
in
+  // registers, i.e. non-trivially copyable records or records marked with
+  // [[trivial_abi]].
+  if (RD->canPassInRegisters())
+return RAA_Default;
+
   switch (CGM.getTarget().getTriple().getArch()) {
   default:
 // FIXME: Implement for other architectures.
 return RAA_Default;
 
   case llvm::Triple::thumb:
-// Use the simple Itanium rules for now.
+// Pass things indirectly for now because it is simple.
 // FIXME: This is incompatible with MSVC for arguments with a dtor and no
 // copy ctor.
-return !RD->canPassInRegisters() ? RAA_Indirect : RAA_Default;
+return RAA_Indirect;
 
   case llvm::Triple::x86: {
 // If the argument has *required* alignment greater than four bytes, pass
@@ -838,17 +844,12 @@ MicrosoftCXXABI::getRecordArgABI(const CXXRecordDecl *RD) 
const {
 
 // If C++ prohibits us from making a copy, construct the arguments directly
 // into argument memory.
-if (!RD->canPassInRegisters())
-  return RAA_DirectInMemory;
-
-// Otherwise, construct the argument into a temporary and copy the bytes
-// into the outgoing argument memory.
-return RAA_Default;
+return RAA_DirectInMemory;
   }
 
   case llvm::Triple::x86_64:
   case llvm::Triple::aarch64:
-return !RD->canPassInRegisters() ? RAA_Indirect : RAA_Default;
+return RAA_Indirect;
   }
 
   llvm_unreachable("invalid enum");

diff  --git a/clang/test/CodeGenCXX/inalloca-overaligned.cpp 
b/clang/test/CodeGenCXX/inalloca-overaligned.cpp
index 83eb4d1c61a4..60b9da4f0861 100644
--- a/clang/test/CodeGenCXX/inalloca-overaligned.cpp
+++ b/clang/test/CodeGenCXX/inalloca-overaligned.cpp
@@ -85,3 +85,27 @@ int pass_inalloca_both() {
 // CHECK: [[TMP:%[^ ]*]] = alloca %struct.Both, align 8
 // CHECK: call x86_thiscallcc %struct.Both* @"??0Both@@QAE@XZ"(%struct.Both* 
[[TMP]])
 // CHECK: call i32 @"?receive_inalloca_both@@Y{{.*}}"(<{ %struct.NonTrivial, 
%struct.Both* }>* inalloca %argmem)
+
+// Here we have a type that is:
+// - overaligned
+// - not trivially copyable
+// - can be "passed in registers" due to [[trivial_abi]]
+// Clang should pass it directly.
+struct [[trivial_abi]] alignas(8) MyPtr {
+  MyPtr();
+  MyPtr(const MyPtr &o);
+  ~MyPtr();
+  int *ptr;
+};
+
+int receiveMyPtr(MyPtr o) { return *o.ptr; }
+
+// CHECK-LABEL: define dso_local i32 @"?receiveMyPtr@@Y{{.*}}"
+// CHECK-SAME: (%struct.MyPtr* %o)
+
+int passMyPtr() { return receiveMyPtr(MyPtr()); }
+
+// CHECK-LABEL: define dso_local i32 @"?passMyPtr@@Y{{.*}}"
+// CHECK: [[TMP:%[^ ]*]] = alloca %struct.MyPtr, align 8
+// CHECK: call x86_thiscallcc %struct.MyPtr* 
@"??0MyPtr@@QAE@XZ"(%struct.MyPtr* [[TMP]])
+// CHECK: call i32 @"?receiveMyPtr@@Y{{.*}}"(%struct.MyPtr* [[TMP]])



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


[PATCH] D87953: [xray] Function coverage groups

2020-09-24 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris added a comment.

There's two tensions I'm trying to resolve in my mind with this patch:

- Is there a way to make this more deterministic, instead of using a random 
sampling mechanism based on the name?
- This looks like it's a subset of a more general facility to group functions 
by "module" or some logical grouping mechanism. Will this be superseded by a 
feature that allows for example to provide filters in the driver to define 
groupings? If so, wouldn't something like that be more flexible for your needs 
(group names in the IR)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87953

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


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

2020-09-24 Thread Ten Tzen via Phabricator via cfe-commits
tentzen added a comment.

In D80344#2291926 , @rjmccall wrote:

> Okay.  I think we're on the same page about representation now.  If you can 
> come up with a good replacement for "eha" in the intrinsic names, I think 
> this is pretty much ready to go.

how about seh.cppscope.begin() and seh.cppscope.end()? or any suggestion?

> This is a very emission-centric description of the intrinsic. Maybe something 
> like:

Very good writing for LangRef.rst:-).  Will update it with your writing. Thanks!

As for pairing question, we simply utilizes existent Cleanup mechanism as you 
described in which abnormal exits and normal fall-through are merged in a 
'cleanup' pad.  What this implementation does is to inject a scope.begin right 
after a ctor and a scope.end right before dtor in cleanup-pad.  Use the same 
example, it will be something like below:

  void test(int x, int &state) {
int jumpdest;
state = 0;
std::string a;  
**seh.cppscope.begin();  // for object a**
state = 1;
if (x > 0) {
  state = 2;
  std::string b;
  **seh.cppscope.begin();  // for b**
  state = 3;
  if (x > 10) {
state = 4;
jumpdest = 0;
goto destroy_b;
  }
  state = 5;
  std::string c;
  **seh.cppscope.begin();  // for c**
  state = 6;
  **seh.cppscope.end(); // for c dtor**
  c.~std::string();
  jumpdest = 1;
destroy_b:
  **seh.cppscope.end();   // for b dtor**
  b.~std::string();
  switch (jumpdest) {
  case 0: goto destroy_a;
  case 1: goto fallthrough;
  }
fallthrough:
  ;
}
state = 7;
  destroy_a:
**seh.cppscope.begin();  // for a dtor **
a.~std::string();
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

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


[PATCH] D88227: [clang-format] Add a SpaceBeforePointerQualifiers style option

2020-09-24 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: clang/include/clang/Format/Format.h:2181
+  /// \endcode
+  bool SpaceBeforePointerQualifiers;
+

MyDeveloperDay wrote:
> I wonder if a request would ever say they wanted this Space before to be 
> Left/Middle/Right? perhaps this should not be a bool?
> 
> ```
> void* const *x;
> void * const *x;
> void *const *x;
> ```
> 
> ```
> void* const *x;
> void * const *x;
> void *const *x;
> ```
> 
> ```
> void* const * x;
> void * const * x;
> void *const * x;
> ```
> 
> ```
> void* const* x;
> void * const* x;
> void *const* x;
> ```
Shouldn't be too hard to implement so why not. How about 
PointerAlignmentForQualifiers as the setting name?

We will have to ensure that the default value matches PointerAlignment if it's 
not set since otherwise you'd get really weird code formatting after updating 
clang-format if you don't change the config file.
Are there and other settings that behave this way? If not I think I'd rather 
keep the boolean option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88227

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


[PATCH] D88105: [NFC] [PPC] Add PowerPC expected IR tests for C99 complex

2020-09-24 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

Off-list discussion seems to indicate that only the NFC portion of the patch 
was intended to be approved.
That is, the scope of this patch is supposed to be 
https://reviews.llvm.org/D88105?id=293625 plus formatting changes.


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

https://reviews.llvm.org/D88105

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


[PATCH] D88239: [clang-format] Fix spaces around */& in multi-variable declarations

2020-09-24 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:6636
+  verifyFormat("a* a = aaa, * b = 
bb,\n"
+   "   * b = bbb, * d = ;",
Style);

MyDeveloperDay wrote:
> huh! the original tests doesn't look like LEFT aligned but now we also lose 
> the alignment, should we care I wonder?
I looked at the git log and it seems like it was changed from left to right in 
https://github.com/llvm/llvm-project/commit/bea1ab46d9ffdfc50108580c712596a54323a94c



Comment at: clang/unittests/Format/FormatTest.cpp:6636
+  verifyFormat("a* a = aaa, * b = 
bb,\n"
+   "   * b = bbb, * d = ;",
Style);

arichardson wrote:
> MyDeveloperDay wrote:
> > huh! the original tests doesn't look like LEFT aligned but now we also lose 
> > the alignment, should we care I wonder?
> I looked at the git log and it seems like it was changed from left to right 
> in 
> https://github.com/llvm/llvm-project/commit/bea1ab46d9ffdfc50108580c712596a54323a94c
Losing the alignment is annoying but I don't quite understand why it changed. 
Hopefully there aren't too many multi line multi variable declarations.



Comment at: clang/unittests/Format/FormatTest.cpp:6639
   verifyFormat("vector a, b;", Style);
+  verifyFormat("for (int* p, * q; p != q; p = p->next) {\n}", Style);
+  verifyFormat("char* x, * const* y = NULL;", Style);

MyDeveloperDay wrote:
> I don't get why `*q` would be `* q`
Yeah I'm not sure what the best way to format multi-variable declarations with 
left alignment. We usually have a space before the name so I thought I'd do the 
same here (even though it looks a bit odd).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88239

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


[PATCH] D88265: Fix comma with half vectors.

2020-09-24 Thread Alexandre Rames via Phabricator via cfe-commits
arames created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
arames requested review of this revision.

The current half vector was enforcing an assert expecting
 "(LHS is half vector) == (RHS is half vector)"
for comma.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88265

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/fp16vec-sema.c


Index: clang/test/Sema/fp16vec-sema.c
===
--- clang/test/Sema/fp16vec-sema.c
+++ clang/test/Sema/fp16vec-sema.c
@@ -26,6 +26,7 @@
   sv0 = hv0 > hv1;
   sv0 = hv0 <= hv1;
   sv0 = hv0 >= hv1;
+  hv0, 1; // expected-warning 2 {{expression result unused}}
   sv0 = hv0 || hv1; // expected-error{{logical expression with vector types 
'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
   sv0 = hv0 && hv1; // expected-error{{logical expression with vector types 
'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
 
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13933,9 +13933,10 @@
   // float vectors and truncating the result back to half vector. For now, we 
do
   // this only when HalfArgsAndReturn is set (that is, when the target is arm 
or
   // arm64).
-  assert(isVector(RHS.get()->getType(), Context.HalfTy) ==
- isVector(LHS.get()->getType(), Context.HalfTy) &&
- "both sides are half vectors or neither sides are");
+  assert(Opc == BO_Comma ||
+ isVector(RHS.get()->getType(), Context.HalfTy) ==
+ isVector(LHS.get()->getType(), Context.HalfTy) &&
+ "both sides are half vectors or neither sides are");
   ConvertHalfVec =
   needsConversionOfHalfVec(ConvertHalfVec, Context, LHS.get(), RHS.get());
 


Index: clang/test/Sema/fp16vec-sema.c
===
--- clang/test/Sema/fp16vec-sema.c
+++ clang/test/Sema/fp16vec-sema.c
@@ -26,6 +26,7 @@
   sv0 = hv0 > hv1;
   sv0 = hv0 <= hv1;
   sv0 = hv0 >= hv1;
+  hv0, 1; // expected-warning 2 {{expression result unused}}
   sv0 = hv0 || hv1; // expected-error{{logical expression with vector types 'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
   sv0 = hv0 && hv1; // expected-error{{logical expression with vector types 'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}}
 
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13933,9 +13933,10 @@
   // float vectors and truncating the result back to half vector. For now, we do
   // this only when HalfArgsAndReturn is set (that is, when the target is arm or
   // arm64).
-  assert(isVector(RHS.get()->getType(), Context.HalfTy) ==
- isVector(LHS.get()->getType(), Context.HalfTy) &&
- "both sides are half vectors or neither sides are");
+  assert(Opc == BO_Comma ||
+ isVector(RHS.get()->getType(), Context.HalfTy) ==
+ isVector(LHS.get()->getType(), Context.HalfTy) &&
+ "both sides are half vectors or neither sides are");
   ConvertHalfVec =
   needsConversionOfHalfVec(ConvertHalfVec, Context, LHS.get(), RHS.get());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c9b53b3 - Fix regex in test.

2020-09-24 Thread Bill Wendling via cfe-commits

Author: Bill Wendling
Date: 2020-09-24T15:21:28-07:00
New Revision: c9b53b3bf20d20d5752876be32a9e5887c702e53

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

LOG: Fix regex in test.

Added: 


Modified: 
clang/test/Modules/asm-goto.c

Removed: 




diff  --git a/clang/test/Modules/asm-goto.c b/clang/test/Modules/asm-goto.c
index f1a6f4217cf9..feef193b2750 100644
--- a/clang/test/Modules/asm-goto.c
+++ b/clang/test/Modules/asm-goto.c
@@ -4,7 +4,7 @@
 #include "a.h"
 
 // CHECK-LABEL: define {{.*}} @foo(
-// CHECK: callbr {{.*}} "=r,X,{{.*}}"(i8* blockaddress(@foo, %indirect))
+// CHECK: callbr {{.*}} "=r,X{{.*}} blockaddress(@foo, %indirect))
 // CHECK-NEXT: to label %asm.fallthrough [label %indirect]
 
 int bar(void) {



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


[PATCH] D87029: [AIX] Implement AIX special bitfield related alignment rules

2020-09-24 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 294157.
Xiangling_L added a comment.

Rebased on the NFC patch;


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

https://reviews.llvm.org/D87029

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Layout/aix-bitfield-alignment.cpp
  clang/test/Layout/aix-oversized-bitfield.cpp

Index: clang/test/Layout/aix-oversized-bitfield.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-oversized-bitfield.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only %s | \
+// RUN:   FileCheck --check-prefix=CHECK64 %s
+
+struct A
+{
+long long l : 64; // expected-error{{width of bit-field 'l' (64 bits) exceeds size of its type (32 bits)}}
+};
+
+int a = sizeof(A);
+
+// CHECK64:  *** Dumping AST Record Layout
+// CHECK64-NEXT:  0 | struct A
+// CHECK64-NEXT: 0:0-63 |   long long l
+// CHECK64-NEXT:| [sizeof=8, dsize=8, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=8, nvalign=8, preferrednvalign=8]
Index: clang/test/Layout/aix-bitfield-alignment.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-bitfield-alignment.cpp
@@ -0,0 +1,146 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -faix-pragma-pack -x c++ %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK32 %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \
+// RUN: -fsyntax-only -faix-pragma-pack -x c++ %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK64 %s
+
+struct A {
+  bool b : 3;
+  unsigned char c : 2;
+  unsigned short s : 6;
+};
+
+int a = sizeof(A);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct A
+// CHECK-NEXT:  0:0-2 |   _Bool b
+// CHECK-NEXT:  0:3-4 |   unsigned char c
+// CHECK-NEXT: 0:5-10 |   unsigned short s
+// CHECK-NEXT:| [sizeof=4, dsize=4, align=4, preferredalign=4,
+// CHECK-NEXT:|  nvsize=4, nvalign=4, preferrednvalign=4]
+
+struct B {
+  char c;
+  int : 0;
+};
+
+int b = sizeof(B);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct B
+// CHECK-NEXT:  0 |   char c
+// CHECK-NEXT:4:- |   int 
+// CHECK-NEXT:| [sizeof=4, dsize=4, align=4, preferredalign=4,
+// CHECK-NEXT:|  nvsize=4, nvalign=4, preferrednvalign=4]
+
+struct C {
+  signed int a1 : 6;
+  signed char a2 : 4;
+  short int a3 : 2;
+  int a4 : 2;
+  signed long a5 : 5;
+  long long int a6 : 6;
+  unsigned long a7 : 8;
+};
+
+int c = sizeof(C);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct C
+// CHECK-NEXT:  0:0-5 |   int a1
+// CHECK-NEXT:  0:6-9 |   signed char a2
+// CHECK-NEXT:  1:2-3 |   short a3
+// CHECK-NEXT:  1:4-5 |   int a4
+// CHECK-NEXT: 1:6-10 |   long a5
+// CHECK-NEXT:  2:3-8 |   long long a6
+// CHECK32: 4:0-7 |   unsigned long a7
+// CHECK32:   | [sizeof=8, dsize=8, align=4, preferredalign=4,
+// CHECK32:   |  nvsize=8, nvalign=4, preferrednvalign=4]
+// CHECK64: 3:1-8 |   unsigned long a7
+// CHECK64:   | [sizeof=8, dsize=8, align=8, preferredalign=8,
+// CHECK64:   |  nvsize=8, nvalign=8, preferrednvalign=8]
+
+#pragma align(packed)
+struct C1 {
+  signed int a1 : 6;
+  signed char a2 : 4;
+  short int a3 : 2;
+  int a4 : 2;
+  signed long a5 : 5;
+  long long int a6 : 6;
+  unsigned long a7 : 8;
+};
+#pragma align(reset)
+
+int c1 = sizeof(C1);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct C1
+// CHECK-NEXT:  0:0-5 |   int a1
+// CHECK-NEXT:  0:6-9 |   signed char a2
+// CHECK-NEXT:  1:2-3 |   short a3
+// CHECK-NEXT:  1:4-5 |   int a4
+// CHECK-NEXT: 1:6-10 |   long a5
+// CHECK-NEXT:  2:3-8 |   long long a6
+// CHECK-NEXT:  3:1-8 |   unsigned long a7
+// CHECK-NEXT:| [sizeof=5, dsize=5, align=1, preferredalign=1,
+// CHECK-NEXT:|  nvsize=5, nvalign=1, preferrednvalign=1]
+
+#pragma pack(4)
+struct C2 {
+  signed int a1 : 6;
+  signed char a2 : 4;
+  short int a3 : 2;
+  int a4 : 2;
+  signed long a5 : 5;
+  long long int a6 : 6;
+  unsigned long a7 : 8;
+};
+#pragma pack(pop)
+
+int c2 = sizeof(C2);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct C2
+// CHECK-NEXT:  0:0-5 |   int a1
+// CHECK-NEXT:  0:6-9 |   signed char a2
+// CHECK-NEXT:  1:2-3 |   short a3
+// CHECK-NEXT:  1:4-5 |   int a4
+// CHECK-NEXT: 1:6-10 |   long a5
+// CHECK-NEXT:  2:3-8 |   long long a6
+// CHECK-NEXT:  3:1-8 |   unsigned long a7
+// CHECK-NEXT:|

[PATCH] D88263: Sema: remove unnecessary parameter for SwiftName handling (NFCI)

2020-09-24 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added reviewers: aaron.ballman, gribozavr2.
Herald added a project: clang.
compnerd requested review of this revision.

This code never actually did anything in the implementation.

`mergeDeclAttribute` is declared as `static`, and referenced exactly
once in the file: from `Sema::mergeDeclAttributes`.

`Sema::mergeDeclAttributes` sets `LocalAMK` to `AMK_None`.  If the
attribute is `DeprecatedAttr`, `UnavailableAttr`, or `AvailabilityAttr`
then the `LocalAMK` is updated.  However, because we are dealing with a
`SwiftNameDeclAttr` here, `LocalAMK` remains `AMK_None`.  This is then
passed to the function which will as a result pass the value of
`AMK_None == AMK_Override` aka `false`.  Simply propagate the value
through and erase the dead codepath.

Thanks to Aaron Ballman for flagging the use of the availability merge
kind here leading to this simplification!


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88263

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp


Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4282,13 +4282,8 @@
 }
 
 SwiftNameAttr *Sema::mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA,
-StringRef Name, bool Override) {
+StringRef Name) {
   if (const auto *PrevSNA = D->getAttr()) {
-if (Override) {
-  // FIXME: warn about incompatible override
-  return nullptr;
-}
-
 if (PrevSNA->getName() != Name && !PrevSNA->isImplicit()) {
   Diag(PrevSNA->getLocation(), diag::err_attributes_are_not_compatible)
   << PrevSNA << &SNA;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2593,8 +2593,7 @@
   } else if (const auto *MA = dyn_cast(Attr))
 NewAttr = S.mergeMinSizeAttr(D, *MA);
   else if (const auto *SNA = dyn_cast(Attr))
-NewAttr = S.mergeSwiftNameAttr(D, *SNA, SNA->getName(),
-   AMK == Sema::AMK_Override);
+NewAttr = S.mergeSwiftNameAttr(D, *SNA, SNA->getName());
   else if (const auto *OA = dyn_cast(Attr))
 NewAttr = S.mergeOptimizeNoneAttr(D, *OA);
   else if (const auto *InternalLinkageA = dyn_cast(Attr))
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -3070,7 +3070,7 @@
   mergeSpeculativeLoadHardeningAttr(Decl *D,
 const SpeculativeLoadHardeningAttr &AL);
   SwiftNameAttr *mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA,
-StringRef Name, bool Override);
+StringRef Name);
   OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D,
   const AttributeCommonInfo &CI);
   InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL);


Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4282,13 +4282,8 @@
 }
 
 SwiftNameAttr *Sema::mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA,
-StringRef Name, bool Override) {
+StringRef Name) {
   if (const auto *PrevSNA = D->getAttr()) {
-if (Override) {
-  // FIXME: warn about incompatible override
-  return nullptr;
-}
-
 if (PrevSNA->getName() != Name && !PrevSNA->isImplicit()) {
   Diag(PrevSNA->getLocation(), diag::err_attributes_are_not_compatible)
   << PrevSNA << &SNA;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2593,8 +2593,7 @@
   } else if (const auto *MA = dyn_cast(Attr))
 NewAttr = S.mergeMinSizeAttr(D, *MA);
   else if (const auto *SNA = dyn_cast(Attr))
-NewAttr = S.mergeSwiftNameAttr(D, *SNA, SNA->getName(),
-   AMK == Sema::AMK_Override);
+NewAttr = S.mergeSwiftNameAttr(D, *SNA, SNA->getName());
   else if (const auto *OA = dyn_cast(Attr))
 NewAttr = S.mergeOptimizeNoneAttr(D, *OA);
   else if (const auto *InternalLinkageA = dyn_cast(Attr))
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -3070,7 +3070,7 @@
   mergeSpeculativeLoadHardeningAttr(Decl *D,
 const SpeculativeLoadHardeningAttr &AL);
   SwiftNameAttr *mergeSwiftNameAttr(Decl *D, const

[PATCH] D87808: [DebugInfo] Fix bug in constructor homing for classes with trivial constructors.

2020-09-24 Thread Amy Huang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc8df781e54a4: [DebugInfo] Fix bug in constructor homing with 
classes with trivial (authored by akhuang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87808

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-limited-ctor.cpp


Index: clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
===
--- clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -20,14 +20,56 @@
 };
 D::D() {}
 
+// Test for constexpr constructor.
 // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: 
"E"{{.*}}DIFlagTypePassByValue
 struct E {
   constexpr E(){};
 } TestE;
 
+// Test for trivial constructor.
 // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: 
"F"{{.*}}DIFlagTypePassByValue
 struct F {
   F() = default;
   F(int) {}
   int i;
 } TestF;
+
+// Test for trivial constructor.
+// CHECK-DAG: ![[G:.*]] ={{.*}}!DICompositeType({{.*}}name: 
"G"{{.*}}DIFlagTypePassByValue
+// CHECK-DAG: !DICompositeType({{.*}}scope: ![[G]], {{.*}}DIFlagTypePassByValue
+struct G {
+  G() : g_(0) {}
+  struct {
+int g_;
+  };
+} TestG;
+
+// Test for an aggregate class with an implicit non-trivial default constructor
+// that is not instantiated.
+// CHECK-DAG: !DICompositeType({{.*}}name: "H",{{.*}}DIFlagTypePassByValue
+struct H {
+  B b;
+};
+void f(H h) {}
+
+// Test for an aggregate class with an implicit non-trivial default constructor
+// that is instantiated.
+// CHECK-DAG: !DICompositeType({{.*}}name: "J",{{.*}}DIFlagTypePassByValue
+struct J {
+  B b;
+};
+void f(decltype(J()) j) {}
+
+// Test for a class with trivial default constructor that is not instantiated.
+// CHECK-DAG: !DICompositeType({{.*}}name: "K",{{.*}}DIFlagTypePassByValue
+class K {
+  int i;
+};
+void f(K k) {}
+
+// Test that we don't use constructor homing on lambdas.
+// CHECK-DAG: ![[L:.*]] ={{.*}}!DISubprogram({{.*}}name: "L"
+// CHECK-DAG: !DICompositeType({{.*}}scope: ![[L]], {{.*}}DIFlagTypePassByValue
+void L() {
+  auto func = [&]() {};
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2281,22 +2281,20 @@
 }
 
 static bool canUseCtorHoming(const CXXRecordDecl *RD) {
-  // Constructor homing can be used for classes that have at least one
-  // constructor and have no trivial or constexpr constructors.
+  // Constructor homing can be used for classes that cannnot be constructed
+  // without emitting code for one of their constructors. This is classes that
+  // don't have trivial or constexpr constructors, or can be created from
+  // aggregate initialization. Also skip lambda objects because they don't call
+  // constructors.
+
   // Skip this optimization if the class or any of its methods are marked
   // dllimport.
-  if (RD->isLambda() || RD->hasConstexprNonCopyMoveConstructor() ||
-  isClassOrMethodDLLImport(RD))
-return false;
-
-  if (RD->ctors().empty())
+  if (isClassOrMethodDLLImport(RD))
 return false;
 
-  for (const auto *Ctor : RD->ctors())
-if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor())
-  return false;
-
-  return true;
+  return !RD->isLambda() && !RD->isAggregate() &&
+ !RD->hasTrivialDefaultConstructor() &&
+ !RD->hasConstexprNonCopyMoveConstructor();
 }
 
 static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,


Index: clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
===
--- clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -20,14 +20,56 @@
 };
 D::D() {}
 
+// Test for constexpr constructor.
 // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "E"{{.*}}DIFlagTypePassByValue
 struct E {
   constexpr E(){};
 } TestE;
 
+// Test for trivial constructor.
 // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "F"{{.*}}DIFlagTypePassByValue
 struct F {
   F() = default;
   F(int) {}
   int i;
 } TestF;
+
+// Test for trivial constructor.
+// CHECK-DAG: ![[G:.*]] ={{.*}}!DICompositeType({{.*}}name: "G"{{.*}}DIFlagTypePassByValue
+// CHECK-DAG: !DICompositeType({{.*}}scope: ![[G]], {{.*}}DIFlagTypePassByValue
+struct G {
+  G() : g_(0) {}
+  struct {
+int g_;
+  };
+} TestG;
+
+// Test for an aggregate class with an implicit non-trivial default constructor
+// that is not instantiated.
+// CHECK-DAG: !DICompositeType({{.*}}name: "H",{{.*}}DIFlagTypePassByValue
+struct H {
+  B b;
+};
+void f(H h) {}
+
+// Test for an aggregate class with an implicit non-trivial default constructor
+// that is instantiated.
+// CHECK-DAG: !DICompositeType({{.*}}name: "J"

[clang] c8df781 - [DebugInfo] Fix bug in constructor homing with classes with trivial

2020-09-24 Thread Amy Huang via cfe-commits

Author: Amy Huang
Date: 2020-09-24T14:43:48-07:00
New Revision: c8df781e54a43593eafd993a5a5cd647866955f8

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

LOG: [DebugInfo] Fix bug in constructor homing with classes with trivial
constructors.

This changes the code to avoid using constructor homing for aggregate
classes and classes with trivial default constructors, instead of trying
to loop through the constructors.

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

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-limited-ctor.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 1fdb6814c7bd..27c584ff0795 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2281,22 +2281,20 @@ static bool 
hasExplicitMemberDefinition(CXXRecordDecl::method_iterator I,
 }
 
 static bool canUseCtorHoming(const CXXRecordDecl *RD) {
-  // Constructor homing can be used for classes that have at least one
-  // constructor and have no trivial or constexpr constructors.
+  // Constructor homing can be used for classes that cannnot be constructed
+  // without emitting code for one of their constructors. This is classes that
+  // don't have trivial or constexpr constructors, or can be created from
+  // aggregate initialization. Also skip lambda objects because they don't call
+  // constructors.
+
   // Skip this optimization if the class or any of its methods are marked
   // dllimport.
-  if (RD->isLambda() || RD->hasConstexprNonCopyMoveConstructor() ||
-  isClassOrMethodDLLImport(RD))
-return false;
-
-  if (RD->ctors().empty())
+  if (isClassOrMethodDLLImport(RD))
 return false;
 
-  for (const auto *Ctor : RD->ctors())
-if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor())
-  return false;
-
-  return true;
+  return !RD->isLambda() && !RD->isAggregate() &&
+ !RD->hasTrivialDefaultConstructor() &&
+ !RD->hasConstexprNonCopyMoveConstructor();
 }
 
 static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,

diff  --git a/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp 
b/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
index 89dd2b16b75b..cf2e89e35522 100644
--- a/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ b/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -20,14 +20,56 @@ struct D {
 };
 D::D() {}
 
+// Test for constexpr constructor.
 // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: 
"E"{{.*}}DIFlagTypePassByValue
 struct E {
   constexpr E(){};
 } TestE;
 
+// Test for trivial constructor.
 // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: 
"F"{{.*}}DIFlagTypePassByValue
 struct F {
   F() = default;
   F(int) {}
   int i;
 } TestF;
+
+// Test for trivial constructor.
+// CHECK-DAG: ![[G:.*]] ={{.*}}!DICompositeType({{.*}}name: 
"G"{{.*}}DIFlagTypePassByValue
+// CHECK-DAG: !DICompositeType({{.*}}scope: ![[G]], {{.*}}DIFlagTypePassByValue
+struct G {
+  G() : g_(0) {}
+  struct {
+int g_;
+  };
+} TestG;
+
+// Test for an aggregate class with an implicit non-trivial default constructor
+// that is not instantiated.
+// CHECK-DAG: !DICompositeType({{.*}}name: "H",{{.*}}DIFlagTypePassByValue
+struct H {
+  B b;
+};
+void f(H h) {}
+
+// Test for an aggregate class with an implicit non-trivial default constructor
+// that is instantiated.
+// CHECK-DAG: !DICompositeType({{.*}}name: "J",{{.*}}DIFlagTypePassByValue
+struct J {
+  B b;
+};
+void f(decltype(J()) j) {}
+
+// Test for a class with trivial default constructor that is not instantiated.
+// CHECK-DAG: !DICompositeType({{.*}}name: "K",{{.*}}DIFlagTypePassByValue
+class K {
+  int i;
+};
+void f(K k) {}
+
+// Test that we don't use constructor homing on lambdas.
+// CHECK-DAG: ![[L:.*]] ={{.*}}!DISubprogram({{.*}}name: "L"
+// CHECK-DAG: !DICompositeType({{.*}}scope: ![[L]], {{.*}}DIFlagTypePassByValue
+void L() {
+  auto func = [&]() {};
+}



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


[clang] f97b68e - Fix testcase.

2020-09-24 Thread Bill Wendling via cfe-commits

Author: Bill Wendling
Date: 2020-09-24T14:34:28-07:00
New Revision: f97b68ef4ddd28a685e502653768c2a34c314cba

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

LOG: Fix testcase.

Added: 


Modified: 
clang/test/Modules/asm-goto.c

Removed: 




diff  --git a/clang/test/Modules/asm-goto.c b/clang/test/Modules/asm-goto.c
index fc6e45dd98fd..f1a6f4217cf9 100644
--- a/clang/test/Modules/asm-goto.c
+++ b/clang/test/Modules/asm-goto.c
@@ -3,7 +3,7 @@
 // RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c -I%S/Inputs/asm-goto 
-emit-llvm -o - %s -fmodule-file=%t/a.pcm | FileCheck %s
 #include "a.h"
 
-// CHECK-LABEL: define i32 @foo(
+// CHECK-LABEL: define {{.*}} @foo(
 // CHECK: callbr {{.*}} "=r,X,{{.*}}"(i8* blockaddress(@foo, %indirect))
 // CHECK-NEXT: to label %asm.fallthrough [label %indirect]
 



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


[PATCH] D88250: [CUDA] Added dim3/uint3 conversion functions to builtin vars.

2020-09-24 Thread Artem Belevich 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 rG30514f0afa3e: [CUDA] Added conversion functions to builtin 
vars. (authored by tra).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88250

Files:
  clang/lib/Headers/__clang_cuda_builtin_vars.h
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h

Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -377,30 +377,38 @@
 // Out-of-line implementations from __clang_cuda_builtin_vars.h.  These need to
 // come after we've pulled in the definition of uint3 and dim3.
 
+__device__ inline __cuda_builtin_threadIdx_t::operator dim3() const {
+  return dim3(x, y, z);
+}
+
 __device__ inline __cuda_builtin_threadIdx_t::operator uint3() const {
-  uint3 ret;
-  ret.x = x;
-  ret.y = y;
-  ret.z = z;
-  return ret;
+  return {x, y, z};
+}
+
+__device__ inline __cuda_builtin_blockIdx_t::operator dim3() const {
+  return dim3(x, y, z);
 }
 
 __device__ inline __cuda_builtin_blockIdx_t::operator uint3() const {
-  uint3 ret;
-  ret.x = x;
-  ret.y = y;
-  ret.z = z;
-  return ret;
+  return {x, y, z};
 }
 
 __device__ inline __cuda_builtin_blockDim_t::operator dim3() const {
   return dim3(x, y, z);
 }
 
+__device__ inline __cuda_builtin_blockDim_t::operator uint3() const {
+  return {x, y, z};
+}
+
 __device__ inline __cuda_builtin_gridDim_t::operator dim3() const {
   return dim3(x, y, z);
 }
 
+__device__ inline __cuda_builtin_gridDim_t::operator uint3() const {
+  return {x, y, z};
+}
+
 #include <__clang_cuda_cmath.h>
 #include <__clang_cuda_intrinsics.h>
 #include <__clang_cuda_complex_builtins.h>
Index: clang/lib/Headers/__clang_cuda_builtin_vars.h
===
--- clang/lib/Headers/__clang_cuda_builtin_vars.h
+++ clang/lib/Headers/__clang_cuda_builtin_vars.h
@@ -55,7 +55,9 @@
   __CUDA_DEVICE_BUILTIN(z,__nvvm_read_ptx_sreg_tid_z());
   // threadIdx should be convertible to uint3 (in fact in nvcc, it *is* a
   // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator dim3() const;
   __attribute__((device)) operator uint3() const;
+
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_threadIdx_t);
 };
@@ -66,7 +68,9 @@
   __CUDA_DEVICE_BUILTIN(z,__nvvm_read_ptx_sreg_ctaid_z());
   // blockIdx should be convertible to uint3 (in fact in nvcc, it *is* a
   // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator dim3() const;
   __attribute__((device)) operator uint3() const;
+
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_blockIdx_t);
 };
@@ -78,6 +82,8 @@
   // blockDim should be convertible to dim3 (in fact in nvcc, it *is* a
   // dim3).  This function is defined after we pull in vector_types.h.
   __attribute__((device)) operator dim3() const;
+  __attribute__((device)) operator uint3() const;
+
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_blockDim_t);
 };
@@ -89,6 +95,8 @@
   // gridDim should be convertible to dim3 (in fact in nvcc, it *is* a
   // dim3).  This function is defined after we pull in vector_types.h.
   __attribute__((device)) operator dim3() const;
+  __attribute__((device)) operator uint3() const;
+
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_gridDim_t);
 };
@@ -108,5 +116,6 @@
 #undef __CUDA_DEVICE_BUILTIN
 #undef __CUDA_BUILTIN_VAR
 #undef __CUDA_DISALLOW_BUILTINVAR_ACCESS
+#undef __DELETE
 
 #endif /* __CUDA_BUILTIN_VARS_H */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 30514f0 - [CUDA] Added conversion functions to builtin vars.

2020-09-24 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2020-09-24T14:33:04-07:00
New Revision: 30514f0afa3ee1e6da6bf9c41e83c28e884f0740

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

LOG: [CUDA] Added conversion functions to builtin vars.

This is needed to compile some headers in CUDA-11 that assume that threadIdx is
implicitly convertible to dim3. With NVCC, threadIdx is uint3 and there's
dim3(uint3) constructor. Clang uses a special type for the builtin variables, so
that path does not work. Instead, this patch adds conversion function to the
builtin variable classes. that will allow them to be converted to dim3 and 
uint3.

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

Added: 


Modified: 
clang/lib/Headers/__clang_cuda_builtin_vars.h
clang/lib/Headers/__clang_cuda_runtime_wrapper.h

Removed: 




diff  --git a/clang/lib/Headers/__clang_cuda_builtin_vars.h 
b/clang/lib/Headers/__clang_cuda_builtin_vars.h
index 2ba1521f2580..412e823a827f 100644
--- a/clang/lib/Headers/__clang_cuda_builtin_vars.h
+++ b/clang/lib/Headers/__clang_cuda_builtin_vars.h
@@ -55,7 +55,9 @@ struct __cuda_builtin_threadIdx_t {
   __CUDA_DEVICE_BUILTIN(z,__nvvm_read_ptx_sreg_tid_z());
   // threadIdx should be convertible to uint3 (in fact in nvcc, it *is* a
   // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator dim3() const;
   __attribute__((device)) operator uint3() const;
+
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_threadIdx_t);
 };
@@ -66,7 +68,9 @@ struct __cuda_builtin_blockIdx_t {
   __CUDA_DEVICE_BUILTIN(z,__nvvm_read_ptx_sreg_ctaid_z());
   // blockIdx should be convertible to uint3 (in fact in nvcc, it *is* a
   // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator dim3() const;
   __attribute__((device)) operator uint3() const;
+
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_blockIdx_t);
 };
@@ -78,6 +82,8 @@ struct __cuda_builtin_blockDim_t {
   // blockDim should be convertible to dim3 (in fact in nvcc, it *is* a
   // dim3).  This function is defined after we pull in vector_types.h.
   __attribute__((device)) operator dim3() const;
+  __attribute__((device)) operator uint3() const;
+
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_blockDim_t);
 };
@@ -89,6 +95,8 @@ struct __cuda_builtin_gridDim_t {
   // gridDim should be convertible to dim3 (in fact in nvcc, it *is* a
   // dim3).  This function is defined after we pull in vector_types.h.
   __attribute__((device)) operator dim3() const;
+  __attribute__((device)) operator uint3() const;
+
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_gridDim_t);
 };
@@ -108,5 +116,6 @@ __attribute__((device)) const int warpSize = 32;
 #undef __CUDA_DEVICE_BUILTIN
 #undef __CUDA_BUILTIN_VAR
 #undef __CUDA_DISALLOW_BUILTINVAR_ACCESS
+#undef __DELETE
 
 #endif /* __CUDA_BUILTIN_VARS_H */

diff  --git a/clang/lib/Headers/__clang_cuda_runtime_wrapper.h 
b/clang/lib/Headers/__clang_cuda_runtime_wrapper.h
index f43ed55de489..f88c39a9b6e5 100644
--- a/clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ b/clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -377,30 +377,38 @@ __device__ static inline void *malloc(size_t __size) {
 // Out-of-line implementations from __clang_cuda_builtin_vars.h.  These need to
 // come after we've pulled in the definition of uint3 and dim3.
 
+__device__ inline __cuda_builtin_threadIdx_t::operator dim3() const {
+  return dim3(x, y, z);
+}
+
 __device__ inline __cuda_builtin_threadIdx_t::operator uint3() const {
-  uint3 ret;
-  ret.x = x;
-  ret.y = y;
-  ret.z = z;
-  return ret;
+  return {x, y, z};
+}
+
+__device__ inline __cuda_builtin_blockIdx_t::operator dim3() const {
+  return dim3(x, y, z);
 }
 
 __device__ inline __cuda_builtin_blockIdx_t::operator uint3() const {
-  uint3 ret;
-  ret.x = x;
-  ret.y = y;
-  ret.z = z;
-  return ret;
+  return {x, y, z};
 }
 
 __device__ inline __cuda_builtin_blockDim_t::operator dim3() const {
   return dim3(x, y, z);
 }
 
+__device__ inline __cuda_builtin_blockDim_t::operator uint3() const {
+  return {x, y, z};
+}
+
 __device__ inline __cuda_builtin_gridDim_t::operator dim3() const {
   return dim3(x, y, z);
 }
 
+__device__ inline __cuda_builtin_gridDim_t::operator uint3() const {
+  return {x, y, z};
+}
+
 #include <__clang_cuda_cmath.h>
 #include <__clang_cuda_intrinsics.h>
 #include <__clang_cuda_complex_builtins.h>



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


[PATCH] D88239: [clang-format] Fix spaces around */& in multi-variable declarations

2020-09-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2889
+  return true;
+return Style.PointerAlignment != FormatStyle::PAS_Left;
   }

I wish more of these horrendous expressions all over the code were written like 
this, early exit and with a comment! have an A+




Comment at: clang/unittests/Format/FormatTest.cpp:6636
+  verifyFormat("a* a = aaa, * b = 
bb,\n"
+   "   * b = bbb, * d = ;",
Style);

huh! the original tests doesn't look like LEFT aligned but now we also lose the 
alignment, should we care I wonder?



Comment at: clang/unittests/Format/FormatTest.cpp:6639
   verifyFormat("vector a, b;", Style);
+  verifyFormat("for (int* p, * q; p != q; p = p->next) {\n}", Style);
+  verifyFormat("char* x, * const* y = NULL;", Style);

I don't get why `*q` would be `* q`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88239

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


[PATCH] D87720: Sema: add support for `__attribute__((__swift_private__))`

2020-09-24 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 294167.
compnerd marked an inline comment as done.
compnerd added a comment.

- address all feedback, add more test cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87720

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/AST/attr-swift_private.m
  clang/test/SemaObjC/attr-swift_private.m

Index: clang/test/SemaObjC/attr-swift_private.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-swift_private.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc %s
+
+__attribute__((__swift_private__))
+@protocol P
+@end
+
+__attribute__((__swift_private__))
+@interface I
+@end
+
+@interface J
+@property id property __attribute__((__swift_private__));
+- (void)instanceMethod __attribute__((__swift_private__));
++ (void)classMethod __attribute__((__swift_private__));
+@end
+
+void f(void) __attribute__((__swift_private__));
+
+struct __attribute__((__swift_private__)) S {};
+
+enum __attribute__((__swift_private__)) E {
+  one,
+  two,
+};
+
+typedef struct { } T __attribute__((__swift_private__));
+
+void g(void) __attribute__((__swift_private__("private")));
+// expected-error@-1 {{'__swift_private__' attribute takes no arguments}}
Index: clang/test/AST/attr-swift_private.m
===
--- /dev/null
+++ clang/test/AST/attr-swift_private.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -ast-dump %s | FileCheck %s
+
+@interface I
+- (void)method __attribute__((__swift_private__));
+@end
+
+// CHECK: ObjCInterfaceDecl {{.*}} I
+// CHECK: ObjCMethodDecl {{.*}} method 'void'
+// CHECK: SwiftPrivateAttr
+
+@interface J : I
+- (void)method;
+@end
+
+// CHECK: ObjCInterfaceDecl {{.*}} J
+// CHECK: ObjCMethodDecl {{.*}} method 'void'
+// CHECK: SwiftPrivateAttr {{.*}} Inherited
+
+void f(void) __attribute__((__swift_private__));
+// CHECK: FunctionDecl {{.*}} f 'void (void)'
+// CHECK: SwiftPrivateAttr
+
+void f(void) {
+}
+// CHECK: FunctionDecl {{.*}} f 'void (void)'
+// CHECK: SwiftPrivateAttr {{.*}} Inherited
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -7904,6 +7904,9 @@
   case ParsedAttr::AT_SwiftObjCMembers:
 handleSimpleAttribute(S, D, AL);
 break;
+  case ParsedAttr::AT_SwiftPrivate:
+handleSimpleAttribute(S, D, AL);
+break;
 
   // XRay attributes.
   case ParsedAttr::AT_XRayLogArgs:
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -3653,6 +3653,19 @@
   }];
 }
 
+def SwiftPrivateDocs : Documentation {
+  let Category = SwiftDocs;
+  let Heading = "swift_private";
+  let Content = [{
+Declarations marked with the ``swift_private`` attribute are hidden from the
+framework client but are still made available for use within the framework or
+Swift SDK overlay.
+
+The purpose of this attribute is to permit a more idomatic implementation of
+declarations in Swift while hiding the non-idiomatic one.
+  }];
+}
+
 def OMPDeclareSimdDocs : Documentation {
   let Category = DocCatFunction;
   let Heading = "#pragma omp declare simd";
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -2177,6 +2177,11 @@
   let HasCustomParsing = 1;
 }
 
+def SwiftPrivate : InheritableAttr {
+  let Spellings = [GNU<"swift_private">];
+  let Documentation = [SwiftPrivateDocs];
+}
+
 def NoDeref : TypeAttr {
   let Spellings = [Clang<"noderef">];
   let Documentation = [NoDerefDocs];
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87720: Sema: add support for `__attribute__((__swift_private__))`

2020-09-24 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd marked an inline comment as done.
compnerd added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:2613-2614
SNA->getName(), AMK == Sema::AMK_Override);
+  else if (isa(Attr) && AMK == Sema::AMK_Override)
+NewAttr = nullptr;
   else if (const auto *OA = dyn_cast(Attr))

aaron.ballman wrote:
> Hmm, I'm a bit confused. The attribute is an inheritable attribute, but when 
> we try to merge attributes between declarations, we drop it?
Discussed offline - this is dead code.  Removed and added a test case to 
demonstrate the beahviour.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87720

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


[PATCH] D88227: [clang-format] Add a SpaceBeforePointerQualifiers style option

2020-09-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/include/clang/Format/Format.h:2181
+  /// \endcode
+  bool SpaceBeforePointerQualifiers;
+

I wonder if a request would ever say they wanted this Space before to be 
Left/Middle/Right? perhaps this should not be a bool?

```
void* const *x;
void * const *x;
void *const *x;
```

```
void* const *x;
void * const *x;
void *const *x;
```

```
void* const * x;
void * const * x;
void *const * x;
```

```
void* const* x;
void * const* x;
void *const* x;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88227

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


[PATCH] D75044: [AArch64] __builtin_return_address for PAuth.

2020-09-24 Thread Daniel Kiss via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2a96f47c5ffc: [AArch64] __builtin_return_address for PAuth. 
(authored by danielkiss).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75044

Files:
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/test/CodeGen/AArch64/aarch64-signedreturnaddress.ll
  llvm/test/CodeGen/AArch64/arm64-returnaddr.ll
  llvm/test/CodeGen/AArch64/arm64_32.ll
  llvm/test/CodeGen/AArch64/returnaddr.ll

Index: llvm/test/CodeGen/AArch64/returnaddr.ll
===
--- llvm/test/CodeGen/AArch64/returnaddr.ll
+++ llvm/test/CodeGen/AArch64/returnaddr.ll
@@ -3,6 +3,7 @@
 define i8* @rt0(i32 %x) nounwind readnone {
 entry:
 ; CHECK-LABEL: rt0:
+; CHECK: hint #7
 ; CHECK: mov x0, x30
   %0 = tail call i8* @llvm.returnaddress(i32 0)
   ret i8* %0
@@ -13,7 +14,9 @@
 ; CHECK-LABEL: rt2:
 ; CHECK: ldr x[[reg:[0-9]+]], [x29]
 ; CHECK: ldr x[[reg]], [x[[reg]]]
-; CHECK: ldr x0, [x[[reg]], #8]
+; CHECK: ldr x30, [x[[reg]], #8]
+; CHECK: hint #7
+; CHECK: mov x0, x30
   %0 = tail call i8* @llvm.returnaddress(i32 2)
   ret i8* %0
 }
Index: llvm/test/CodeGen/AArch64/arm64_32.ll
===
--- llvm/test/CodeGen/AArch64/arm64_32.ll
+++ llvm/test/CodeGen/AArch64/arm64_32.ll
@@ -253,7 +253,9 @@
 define i8* @test_deep_returnaddr() {
 ; CHECK-LABEL: test_deep_returnaddr:
 ; CHECK: ldr x[[FRAME_REC:[0-9]+]], [x29]
-; CHECK-OPT: ldr x0, [x[[FRAME_REC]], #8]
+; CHECK-OPT: ldr x30, [x[[FRAME_REC]], #8]
+; CHECK-OPT: hint #7
+; CHECK-OPT: mov x0, x30
 ; CHECK-FAST: ldr [[TMP:x[0-9]+]], [x[[FRAME_REC]], #8]
 ; CHECK-FAST: and x0, [[TMP]], #0x
   %val = call i8* @llvm.returnaddress(i32 1)
Index: llvm/test/CodeGen/AArch64/arm64-returnaddr.ll
===
--- llvm/test/CodeGen/AArch64/arm64-returnaddr.ll
+++ llvm/test/CodeGen/AArch64/arm64-returnaddr.ll
@@ -3,6 +3,7 @@
 define i8* @rt0(i32 %x) nounwind readnone {
 entry:
 ; CHECK-LABEL: rt0:
+; CHECK: hint #7
 ; CHECK: mov x0, x30
 ; CHECK: ret
   %0 = tail call i8* @llvm.returnaddress(i32 0)
@@ -16,7 +17,9 @@
 ; CHECK: mov x29, sp
 ; CHECK: ldr x[[REG:[0-9]+]], [x29]
 ; CHECK: ldr x[[REG2:[0-9]+]], [x[[REG]]]
-; CHECK: ldr x0, [x[[REG2]], #8]
+; CHECK: ldr x30, [x[[REG2]], #8]
+; CHECK: hint #7
+; CHECK: mov x0, x30
 ; CHECK: ldp x29, x30, [sp], #16
 ; CHECK: ret
   %0 = tail call i8* @llvm.returnaddress(i32 2)
Index: llvm/test/CodeGen/AArch64/aarch64-signedreturnaddress.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/aarch64-signedreturnaddress.ll
@@ -0,0 +1,49 @@
+; RUN: llc < %s -mtriple=arm64-eabi -asm-verbose=false -mattr=v8.2a | FileCheck %s
+; RUN: llc < %s -mtriple=arm64-eabi -asm-verbose=false -mattr=v8.3a | FileCheck %s --check-prefix=CHECKV83
+
+; Armv8.3-A Pointer Authetication requires a special intsruction to strip the
+; pointer authentication code from the pointer.
+; The XPACLRI instruction assembles to a hint-space instruction before Armv8.3-A
+; therefore this instruction can be safely used for any pre Armv8.3-A architectures.
+; On Armv8.3-A and onwards XPACI is available so use that instead.
+
+define i8* @ra0() nounwind readnone {
+entry:
+; CHECK-LABEL: ra0:
+; CHECK-NEXT: str x30, [sp, #-16]!
+; CHECK-NEXT: hint#7
+; CHECK-NEXT: mov x0, x30
+; CHECK-NEXT: ldr x30, [sp], #16
+; CHECK-NEXT: ret
+; CHECKV83:   str x30, [sp, #-16]!
+; CHECKV83-NEXT:  xpaci   x30
+; CHECKV83-NEXT:  mov x0, x30
+; CHECKV83-NEXT:  ldr x30, [sp], #16
+; CHECKV83-NEXT:  ret
+  %0 = tail call i8* @llvm.returnaddress(i32 0)
+  ret i8* %0
+}
+
+define i8* @ra1() nounwind readnone #0 {
+entry:
+; CHECK-LABEL: ra1:
+; CHECK:  hint#25
+; CHECK-NEXT: str x30, [sp, #-16]!
+; CHECK-NEXT: hint#7
+; CHECK-NEXT: mov x0, x30
+; CHECK-NEXT: ldr x30, [sp], #16
+; CHECK-NEXT: hint#29
+; CHECK-NEXT: ret
+; CHECKV83:   paciasp
+; CHECKV83-NEXT:  str x30, [sp, #-16]!
+; CHECKV83-NEXT:  xpaci   x30
+; CHECKV83-NEXT:  mov x0, x30
+; CHECKV83-NEXT:  ldr x30, [sp], #16
+; CHECKV83-NEXT:  retaa
+  %0 = tail call i8* @llvm.returnaddress(i32 0)
+  ret i8* %0
+}
+
+attributes #0 = { "sign-return-address"="all" }
+
+declare i8* @llvm.returnaddress(i32) nounwind readnone
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -6628,17 +6628,34 @@
   EVT VT = Op.getValueType();
   SDLoc DL(Op);
   unsigned Depth = cast(Op.getOperand(0))->getZExtValue();
+  SDValue ReturnAddress;
   if (Depth) 

[PATCH] D52676: [clang-format] tweaked another case of lambda formatting

2020-09-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

@oleg.smolsky  I agree, what you have here covers a myriad of other cases and 
was committed in 2018, we can't call this commit a regression it was a feature 
;-), if we want to improve the feature that is something else.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D52676

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


[PATCH] D87451: add new clang option -mno-xcoff-visibility

2020-09-24 Thread David Tenty via Phabricator via cfe-commits
daltenty added inline comments.



Comment at: llvm/include/llvm/Target/TargetMachine.h:265
+  /// corresponding to -mno-xcoff-visibility.
+  bool getNoXCOFFVisibility() const { return Options.NoXCOFFVisibility; }
+

DiggerLin wrote:
> jasonliu wrote:
> > DiggerLin wrote:
> > > daltenty wrote:
> > > > This seems like it needs the corresponding comand-line option for llc 
> > > > added and an llc test.
> > > I think it will be in another separate  patch.
> > I would actually prefer to have that in the same patch, as that would give 
> > us a full picture. It's not a huge patch even if we combine them. 
> yes, it is not huge patch, one patch for the clang with option 
> -mno-xcoff-visibility, another patch for llc option -no-xcoff-visibility , I 
> think it is different functionality. and I have post the 
> https://reviews.llvm.org/D88234 "add new option -no-xcoff-visibility for llc"
But the problem is this patch actually introduces the backend functionality 
with no test in the LLVM component itself, because the test here is Clang only. 
Either the patches should be merged so both components get tests in one patch 
or both refactored so we have one llc/LLVM patch and one clang patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87451

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


[clang] 34ca5b3 - Remove stale assert.

2020-09-24 Thread Bill Wendling via cfe-commits

Author: Bill Wendling
Date: 2020-09-24T13:59:42-07:00
New Revision: 34ca5b3392ced08e2320fb4236cca5c7df4ec6e9

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

LOG: Remove stale assert.

This is triggered during serialization. The test is for modules, but
will occur for any serialization effort using asm goto.

Reviewed By: nickdesaulniers, jyknight

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

Added: 
clang/test/Modules/Inputs/asm-goto/a.h
clang/test/Modules/Inputs/asm-goto/module.modulemap
clang/test/Modules/asm-goto.c

Modified: 
clang/lib/AST/Stmt.cpp

Removed: 




diff  --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp
index bdfaf410131c..e7024b2105fc 100644
--- a/clang/lib/AST/Stmt.cpp
+++ b/clang/lib/AST/Stmt.cpp
@@ -528,7 +528,6 @@ void GCCAsmStmt::setOutputsAndInputsAndClobbers(const 
ASTContext &C,
   this->NumInputs = NumInputs;
   this->NumClobbers = NumClobbers;
   this->NumLabels = NumLabels;
-  assert(!(NumOutputs && NumLabels) && "asm goto cannot have outputs");
 
   unsigned NumExprs = NumOutputs + NumInputs + NumLabels;
 

diff  --git a/clang/test/Modules/Inputs/asm-goto/a.h 
b/clang/test/Modules/Inputs/asm-goto/a.h
new file mode 100644
index ..877213c5d009
--- /dev/null
+++ b/clang/test/Modules/Inputs/asm-goto/a.h
@@ -0,0 +1,13 @@
+int foo(void) {
+  int x;
+
+  asm goto(""
+   : "=r"(x)
+   :
+   :
+   : indirect);
+  x = 42;
+
+indirect:
+  return x;
+}

diff  --git a/clang/test/Modules/Inputs/asm-goto/module.modulemap 
b/clang/test/Modules/Inputs/asm-goto/module.modulemap
new file mode 100644
index ..caf888fc474c
--- /dev/null
+++ b/clang/test/Modules/Inputs/asm-goto/module.modulemap
@@ -0,0 +1 @@
+module a { header "a.h" export * }

diff  --git a/clang/test/Modules/asm-goto.c b/clang/test/Modules/asm-goto.c
new file mode 100644
index ..fc6e45dd98fd
--- /dev/null
+++ b/clang/test/Modules/asm-goto.c
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c -I%S/Inputs/asm-goto 
-emit-module %S/Inputs/asm-goto/module.modulemap -fmodule-name=a -o %t/a.pcm
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c -I%S/Inputs/asm-goto 
-emit-llvm -o - %s -fmodule-file=%t/a.pcm | FileCheck %s
+#include "a.h"
+
+// CHECK-LABEL: define i32 @foo(
+// CHECK: callbr {{.*}} "=r,X,{{.*}}"(i8* blockaddress(@foo, %indirect))
+// CHECK-NEXT: to label %asm.fallthrough [label %indirect]
+
+int bar(void) {
+  return foo();
+}



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


[PATCH] D88195: Remove stale assert.

2020-09-24 Thread Bill Wendling via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG34ca5b3392ce: Remove stale assert. (authored by void).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88195

Files:
  clang/lib/AST/Stmt.cpp
  clang/test/Modules/Inputs/asm-goto/a.h
  clang/test/Modules/Inputs/asm-goto/module.modulemap
  clang/test/Modules/asm-goto.c


Index: clang/test/Modules/asm-goto.c
===
--- /dev/null
+++ clang/test/Modules/asm-goto.c
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c -I%S/Inputs/asm-goto 
-emit-module %S/Inputs/asm-goto/module.modulemap -fmodule-name=a -o %t/a.pcm
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c -I%S/Inputs/asm-goto 
-emit-llvm -o - %s -fmodule-file=%t/a.pcm | FileCheck %s
+#include "a.h"
+
+// CHECK-LABEL: define i32 @foo(
+// CHECK: callbr {{.*}} "=r,X,{{.*}}"(i8* blockaddress(@foo, %indirect))
+// CHECK-NEXT: to label %asm.fallthrough [label %indirect]
+
+int bar(void) {
+  return foo();
+}
Index: clang/test/Modules/Inputs/asm-goto/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/asm-goto/module.modulemap
@@ -0,0 +1 @@
+module a { header "a.h" export * }
Index: clang/test/Modules/Inputs/asm-goto/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/asm-goto/a.h
@@ -0,0 +1,13 @@
+int foo(void) {
+  int x;
+
+  asm goto(""
+   : "=r"(x)
+   :
+   :
+   : indirect);
+  x = 42;
+
+indirect:
+  return x;
+}
Index: clang/lib/AST/Stmt.cpp
===
--- clang/lib/AST/Stmt.cpp
+++ clang/lib/AST/Stmt.cpp
@@ -528,7 +528,6 @@
   this->NumInputs = NumInputs;
   this->NumClobbers = NumClobbers;
   this->NumLabels = NumLabels;
-  assert(!(NumOutputs && NumLabels) && "asm goto cannot have outputs");
 
   unsigned NumExprs = NumOutputs + NumInputs + NumLabels;
 


Index: clang/test/Modules/asm-goto.c
===
--- /dev/null
+++ clang/test/Modules/asm-goto.c
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c -I%S/Inputs/asm-goto -emit-module %S/Inputs/asm-goto/module.modulemap -fmodule-name=a -o %t/a.pcm
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c -I%S/Inputs/asm-goto -emit-llvm -o - %s -fmodule-file=%t/a.pcm | FileCheck %s
+#include "a.h"
+
+// CHECK-LABEL: define i32 @foo(
+// CHECK: callbr {{.*}} "=r,X,{{.*}}"(i8* blockaddress(@foo, %indirect))
+// CHECK-NEXT: to label %asm.fallthrough [label %indirect]
+
+int bar(void) {
+  return foo();
+}
Index: clang/test/Modules/Inputs/asm-goto/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/asm-goto/module.modulemap
@@ -0,0 +1 @@
+module a { header "a.h" export * }
Index: clang/test/Modules/Inputs/asm-goto/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/asm-goto/a.h
@@ -0,0 +1,13 @@
+int foo(void) {
+  int x;
+
+  asm goto(""
+   : "=r"(x)
+   :
+   :
+   : indirect);
+  x = 42;
+
+indirect:
+  return x;
+}
Index: clang/lib/AST/Stmt.cpp
===
--- clang/lib/AST/Stmt.cpp
+++ clang/lib/AST/Stmt.cpp
@@ -528,7 +528,6 @@
   this->NumInputs = NumInputs;
   this->NumClobbers = NumClobbers;
   this->NumLabels = NumLabels;
-  assert(!(NumOutputs && NumLabels) && "asm goto cannot have outputs");
 
   unsigned NumExprs = NumOutputs + NumInputs + NumLabels;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88195: Remove stale assert.

2020-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.

In D88195#2293637 , @jyknight wrote:

> In D88195#2293597 , @nickdesaulniers 
> wrote:
>
>> In D88195#2293589 , @void wrote:
>>
>>> Clarify commit message.
>>
>> Phabricator unfortunately won't amend the review description when the commit 
>> message is updated; you'll need to manually edit the description via phab's 
>> UI for other reviewers to observe the update. :(
>
> You can see the description separately, under the "Commits" tab, but yea.
> Also, if you use `arc diff --verbatim` to upload the new review, it'll update 
> the review message at the same time.
>
>   --verbatim
>   When creating a revision, try to use the working copy commit
>   message verbatim, without prompting to edit it. When updating a
>   revision, update some fields from the local commit message.

TIL, thanks for that power up.  Thanks for the fix, Bill!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88195

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


[PATCH] D77229: [Analyzer] Avoid handling of LazyCompundVals in IteratorModeling

2020-09-24 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 294156.
baloghadamsoftware added a comment.

Test coverage was hugely increased by rebasing this patch to D88216 
. Two kind of tests failed. This last update 
addreses them:

1. Handle the assignment operator of iterator objects. This is necessary for 
assignments more complex than an assignment to a variable (which is handled by 
`checkBind()`), such as an assignment to a structure/class member.

2. Put back post-checking of `MaterializeTemporaryExpr`. This special kind of 
expression is not only used to materialize temporary expressions from 
`LazyCompoundVal`s but also for temporaries as return values.

Furthermore I added some comments explaining the functions which retrieve an 
iterator argument and iterator return value.

Now all tests pass again with the increased coverage. @NoQ if you are still in 
doubt, please suggest me further test cases to explore. I understand your 
concerns but cannot address them without some suggestions where my solution 
could fail.


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

https://reviews.llvm.org/D77229

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugIteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/InvalidatedIteratorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.h
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
  clang/test/Analysis/iterator-modeling.cpp

Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -42,7 +42,7 @@
 
   if (i != v.begin()) {
 clang_analyzer_warnIfReached();
-  }
+}
 }
 
 void end(const std::vector &v) {
@@ -1034,6 +1034,7 @@
 
   clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning-re {{$V.begin(){{$
   // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expecte warning $i1 - 1
+
 }
 
 void vector_insert_ahead_of_end(std::vector &V, int n) {
@@ -1942,6 +1943,55 @@
   clang_analyzer_eval(clang_analyzer_iterator_container(j) == &V); // expected-warning{{TRUE}}
 }
 
+template 
+struct delegated_ctor_iterator {
+  delegated_ctor_iterator(const T&, int);
+  delegated_ctor_iterator(const T& t) : delegated_ctor_iterator(t, 0) {}
+  delegated_ctor_iterator operator++();
+  delegated_ctor_iterator operator++(int);
+  T& operator*();
+};
+
+template 
+struct container_with_delegated_ctor_iterator {
+  typedef delegated_ctor_iterator iterator;
+  iterator begin() const { return delegated_ctor_iterator(T()); }
+};
+
+void
+test_delegated_ctor_iterator(
+const container_with_delegated_ctor_iterator &c) {
+  auto i = c.begin(); // no-crash
+  clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()");
+  clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning{{$c.begin()}}
+}
+
+template 
+struct base_ctor_iterator {
+  base_ctor_iterator(const T&);
+  base_ctor_iterator operator++();
+  base_ctor_iterator operator++(int);
+  T& operator*();
+};
+
+template 
+struct derived_ctor_iterator: public base_ctor_iterator {
+  derived_ctor_iterator(const T& t) : base_ctor_iterator(t) {}
+};
+
+template 
+struct container_with_derived_ctor_iterator {
+  typedef derived_ctor_iterator iterator;
+  iterator begin() const { return derived_ctor_iterator(T()); }
+};
+
+void
+test_derived_ctor_iterator(const container_with_derived_ctor_iterator &c) {
+  auto i = c.begin();
+  clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()");
+  clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning{{$c.begin()}}
+}
+
 void clang_analyzer_printState();
 
 void print_state(std::vector &V) {
Index: clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
@@ -24,12 +24,12 @@
 namespace {
 
 class STLAlgorithmModeling : public Checker {
-  bool evalFind(CheckerContext &C, const CallExpr *CE) const;
+  void evalFind(CheckerContext &C, const CallExpr *CE, SVal Begin,
+SVal End) const;
 
-  void Find(CheckerContext &C, const CallExpr *CE, unsigned paramNum) const;
-
-  using FnCheck = bool (STLAlgorithmModeling::*)(CheckerContext &,
-const CallExpr *) const;
+  using FnCheck = void (STLAlgorithmModeling::*)(CheckerContext &,
+ const CallExpr *, SVal Begin,
+ 

[PATCH] D88195: Remove stale assert.

2020-09-24 Thread James Y Knight via Phabricator via cfe-commits
jyknight accepted this revision.
jyknight added a comment.
This revision is now accepted and ready to land.

In D88195#2293597 , @nickdesaulniers 
wrote:

> In D88195#2293589 , @void wrote:
>
>> Clarify commit message.
>
> Phabricator unfortunately won't amend the review description when the commit 
> message is updated; you'll need to manually edit the description via phab's 
> UI for other reviewers to observe the update. :(

You can see the description separately, under the "Commits" tab, but yea.
Also, if you use `arc diff --verbatim` to upload the new review, it'll update 
the review message at the same time.

  --verbatim
  When creating a revision, try to use the working copy commit
  message verbatim, without prompting to edit it. When updating a
  revision, update some fields from the local commit message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88195

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


[PATCH] D88260: [NFC][FE] Replace TypeSize with StorageUnitSize

2020-09-24 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L created this revision.
Xiangling_L added reviewers: jasonliu, hubert.reinterpretcast, efriedma.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Xiangling_L requested review of this revision.

On some targets like AIX, last bitfield size is not always equal to last 
bitfield type size. Some bitfield like bool will have the same alignment as 
[unsigned]. So we'd like to use a more general term `StorageUnit` to replace 
`type` in this field.

This patch serves as a parent patch for us to add AIX bitfield related 
alignment rules in : https://reviews.llvm.org/D87029.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88260

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp

Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -622,9 +622,10 @@
   /// an adjacent bitfield if necessary.  The unit in question is usually
   /// a byte, but larger units are used if IsMsStruct.
   unsigned char UnfilledBitsInLastUnit;
-  /// LastBitfieldTypeSize - If IsMsStruct, represents the size of the type
-  /// of the previous field if it was a bitfield.
-  unsigned char LastBitfieldTypeSize;
+
+  /// LastBitfieldStorageUnitSize - If IsMsStruct, represents the size of the
+  /// storage unit of the previous field if it was a bitfield.
+  unsigned char LastBitfieldStorageUnitSize;
 
   /// MaxFieldAlignment - The maximum allowed field alignment. This is set by
   /// #pragma pack.
@@ -693,7 +694,7 @@
 UnadjustedAlignment(CharUnits::One()), UseExternalLayout(false),
 InferAlignment(false), Packed(false), IsUnion(false),
 IsMac68kAlign(false), IsMsStruct(false), UnfilledBitsInLastUnit(0),
-LastBitfieldTypeSize(0), MaxFieldAlignment(CharUnits::Zero()),
+LastBitfieldStorageUnitSize(0), MaxFieldAlignment(CharUnits::Zero()),
 DataSize(0), NonVirtualSize(CharUnits::Zero()),
 NonVirtualAlignment(CharUnits::One()),
 PreferredNVAlignment(CharUnits::One()),
@@ -708,7 +709,7 @@
 
   void LayoutFields(const RecordDecl *D);
   void LayoutField(const FieldDecl *D, bool InsertExtraPadding);
-  void LayoutWideBitField(uint64_t FieldSize, uint64_t TypeSize,
+  void LayoutWideBitField(uint64_t FieldSize, uint64_t StorageUnitSize,
   bool FieldPacked, const FieldDecl *D);
   void LayoutBitField(const FieldDecl *D);
 
@@ -1451,7 +1452,7 @@
 }
 
 void ItaniumRecordLayoutBuilder::LayoutWideBitField(uint64_t FieldSize,
-uint64_t TypeSize,
+uint64_t StorageUnitSize,
 bool FieldPacked,
 const FieldDecl *D) {
   assert(Context.getLangOpts().CPlusPlus &&
@@ -1481,7 +1482,7 @@
 
   // We're not going to use any of the unfilled bits in the last byte.
   UnfilledBitsInLastUnit = 0;
-  LastBitfieldTypeSize = 0;
+  LastBitfieldStorageUnitSize = 0;
 
   uint64_t FieldOffset;
   uint64_t UnpaddedFieldOffset = getDataSizeInBits() - UnfilledBitsInLastUnit;
@@ -1520,7 +1521,7 @@
   bool FieldPacked = Packed || D->hasAttr();
   uint64_t FieldSize = D->getBitWidthValue(Context);
   TypeInfo FieldInfo = Context.getTypeInfo(D->getType());
-  uint64_t TypeSize = FieldInfo.Width;
+  uint64_t StorageUnitSize = FieldInfo.Width;
   unsigned FieldAlign = FieldInfo.Align;
 
   // UnfilledBitsInLastUnit is the difference between the end of the
@@ -1529,7 +1530,7 @@
   // first bit offset available for non-bitfields).  The current data
   // size in bits is always a multiple of the char size; additionally,
   // for ms_struct records it's also a multiple of the
-  // LastBitfieldTypeSize (if set).
+  // LastBitfieldStorageUnitSize (if set).
 
   // The struct-layout algorithm is dictated by the platform ABI,
   // which in principle could use almost any rules it likes.  In
@@ -1583,26 +1584,26 @@
   // First, some simple bookkeeping to perform for ms_struct structs.
   if (IsMsStruct) {
 // The field alignment for integer types is always the size.
-FieldAlign = TypeSize;
+FieldAlign = StorageUnitSize;
 
 // If the previous field was not a bitfield, or was a bitfield
 // with a different storage unit size, or if this field doesn't fit into
 // the current storage unit, we're done with that storage unit.
-if (LastBitfieldTypeSize != TypeSize ||
+if (LastBitfieldStorageUnitSize != StorageUnitSize ||
 UnfilledBitsInLastUnit < FieldSize) {
   // Also, ignore zero-length bitfields after non-bitfields.
-  if (!LastBitfieldTypeSize && !FieldSize)
+  if (!LastBitfieldStorageUnitSize && !FieldSize)
 FieldAlign = 1;
 
   UnfilledBitsInLastUnit = 0;
-  LastBitfieldTypeSize = 0;
+  LastBitfieldStorageUnitSize = 0;
 }
   }
 
   // If t

[PATCH] D88222: [AST] Use data-recursion when building ParentMap, avoid stack overflow.

2020-09-24 Thread Sam McCall 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 rG1ad94624f8a0: [AST] Use data-recursion when building 
ParentMap, avoid stack overflow. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88222

Files:
  clang/lib/AST/ParentMapContext.cpp

Index: clang/lib/AST/ParentMapContext.cpp
===
--- clang/lib/AST/ParentMapContext.cpp
+++ clang/lib/AST/ParentMapContext.cpp
@@ -211,8 +211,6 @@
 /// Note that the relationship described here is purely in terms of AST
 /// traversal - there are other relationships (for example declaration context)
 /// in the AST that are better modeled by special matchers.
-///
-/// FIXME: Currently only builds up the map using \c Stmt and \c Decl nodes.
 class ParentMapContext::ParentMap::ASTVisitor
 : public RecursiveASTVisitor {
 public:
@@ -227,51 +225,60 @@
 
   bool shouldVisitImplicitCode() const { return true; }
 
+  /// Record the parent of the node we're visiting.
+  /// MapNode is the child, the parent is on top of ParentStack.
+  /// Parents is the parent storage (either PointerParents or OtherParents).
+  template 
+  void addParent(MapNodeTy MapNode, MapTy *Parents) {
+if (ParentStack.empty())
+  return;
+
+// FIXME: Currently we add the same parent multiple times, but only
+// when no memoization data is available for the type.
+// For example when we visit all subexpressions of template
+// instantiations; this is suboptimal, but benign: the only way to
+// visit those is with hasAncestor / hasParent, and those do not create
+// new matches.
+// The plan is to enable DynTypedNode to be storable in a map or hash
+// map. The main problem there is to implement hash functions /
+// comparison operators for all types that DynTypedNode supports that
+// do not have pointer identity.
+auto &NodeOrVector = (*Parents)[MapNode];
+if (NodeOrVector.isNull()) {
+  if (const auto *D = ParentStack.back().get())
+NodeOrVector = D;
+  else if (const auto *S = ParentStack.back().get())
+NodeOrVector = S;
+  else
+NodeOrVector = new DynTypedNode(ParentStack.back());
+} else {
+  if (!NodeOrVector.template is()) {
+auto *Vector = new ParentVector(
+1, getSingleDynTypedNodeFromParentMap(NodeOrVector));
+delete NodeOrVector.template dyn_cast();
+NodeOrVector = Vector;
+  }
+
+  auto *Vector = NodeOrVector.template get();
+  // Skip duplicates for types that have memoization data.
+  // We must check that the type has memoization data before calling
+  // std::find() because DynTypedNode::operator== can't compare all
+  // types.
+  bool Found = ParentStack.back().getMemoizationData() &&
+   std::find(Vector->begin(), Vector->end(),
+ ParentStack.back()) != Vector->end();
+  if (!Found)
+Vector->push_back(ParentStack.back());
+}
+  }
+
   template 
   bool TraverseNode(T Node, MapNodeTy MapNode, BaseTraverseFn BaseTraverse,
 MapTy *Parents) {
 if (!Node)
   return true;
-if (ParentStack.size() > 0) {
-  // FIXME: Currently we add the same parent multiple times, but only
-  // when no memoization data is available for the type.
-  // For example when we visit all subexpressions of template
-  // instantiations; this is suboptimal, but benign: the only way to
-  // visit those is with hasAncestor / hasParent, and those do not create
-  // new matches.
-  // The plan is to enable DynTypedNode to be storable in a map or hash
-  // map. The main problem there is to implement hash functions /
-  // comparison operators for all types that DynTypedNode supports that
-  // do not have pointer identity.
-  auto &NodeOrVector = (*Parents)[MapNode];
-  if (NodeOrVector.isNull()) {
-if (const auto *D = ParentStack.back().get())
-  NodeOrVector = D;
-else if (const auto *S = ParentStack.back().get())
-  NodeOrVector = S;
-else
-  NodeOrVector = new DynTypedNode(ParentStack.back());
-  } else {
-if (!NodeOrVector.template is()) {
-  auto *Vector = new ParentVector(
-  1, getSingleDynTypedNodeFromParentMap(NodeOrVector));
-  delete NodeOrVector.template dyn_cast();
-  NodeOrVector = Vector;
-}
-
-auto *Vector = NodeOrVector.template get();
-// Skip duplicates for types that have memoization data.
-// We must check that the type has memoization data before calling
-// std::find() because DynTypedNode::operator== can't compare all
-// types.
-bool Found = ParentStack.back().getMemoizationData() &

[clang] 1ad9462 - [AST] Use data-recursion when building ParentMap, avoid stack overflow.

2020-09-24 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-09-24T22:49:44+02:00
New Revision: 1ad94624f8a092fbfcb74685e11243c186b04c8f

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

LOG: [AST] Use data-recursion when building ParentMap, avoid stack overflow.

The following crashes on my system before this patch, but not after:

  void foo(int i) {
switch (i) {
  case 1:
  case 2:
  ... 10 cases ...
;
}
  }

  clang-query -c="match stmt(hasAncestor(stmt()))" deep.c

I'm not sure it's actually a sane testcase to run though, it's pretty slow :-)

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

Added: 


Modified: 
clang/lib/AST/ParentMapContext.cpp

Removed: 




diff  --git a/clang/lib/AST/ParentMapContext.cpp 
b/clang/lib/AST/ParentMapContext.cpp
index b73b32774b53..bae4d016ff6b 100644
--- a/clang/lib/AST/ParentMapContext.cpp
+++ b/clang/lib/AST/ParentMapContext.cpp
@@ -211,8 +211,6 @@ DynTypedNode createDynTypedNode(const 
NestedNameSpecifierLoc &Node) {
 /// Note that the relationship described here is purely in terms of AST
 /// traversal - there are other relationships (for example declaration context)
 /// in the AST that are better modeled by special matchers.
-///
-/// FIXME: Currently only builds up the map using \c Stmt and \c Decl nodes.
 class ParentMapContext::ParentMap::ASTVisitor
 : public RecursiveASTVisitor {
 public:
@@ -227,51 +225,60 @@ class ParentMapContext::ParentMap::ASTVisitor
 
   bool shouldVisitImplicitCode() const { return true; }
 
+  /// Record the parent of the node we're visiting.
+  /// MapNode is the child, the parent is on top of ParentStack.
+  /// Parents is the parent storage (either PointerParents or OtherParents).
+  template 
+  void addParent(MapNodeTy MapNode, MapTy *Parents) {
+if (ParentStack.empty())
+  return;
+
+// FIXME: Currently we add the same parent multiple times, but only
+// when no memoization data is available for the type.
+// For example when we visit all subexpressions of template
+// instantiations; this is suboptimal, but benign: the only way to
+// visit those is with hasAncestor / hasParent, and those do not create
+// new matches.
+// The plan is to enable DynTypedNode to be storable in a map or hash
+// map. The main problem there is to implement hash functions /
+// comparison operators for all types that DynTypedNode supports that
+// do not have pointer identity.
+auto &NodeOrVector = (*Parents)[MapNode];
+if (NodeOrVector.isNull()) {
+  if (const auto *D = ParentStack.back().get())
+NodeOrVector = D;
+  else if (const auto *S = ParentStack.back().get())
+NodeOrVector = S;
+  else
+NodeOrVector = new DynTypedNode(ParentStack.back());
+} else {
+  if (!NodeOrVector.template is()) {
+auto *Vector = new ParentVector(
+1, getSingleDynTypedNodeFromParentMap(NodeOrVector));
+delete NodeOrVector.template dyn_cast();
+NodeOrVector = Vector;
+  }
+
+  auto *Vector = NodeOrVector.template get();
+  // Skip duplicates for types that have memoization data.
+  // We must check that the type has memoization data before calling
+  // std::find() because DynTypedNode::operator== can't compare all
+  // types.
+  bool Found = ParentStack.back().getMemoizationData() &&
+   std::find(Vector->begin(), Vector->end(),
+ ParentStack.back()) != Vector->end();
+  if (!Found)
+Vector->push_back(ParentStack.back());
+}
+  }
+
   template 
   bool TraverseNode(T Node, MapNodeTy MapNode, BaseTraverseFn BaseTraverse,
 MapTy *Parents) {
 if (!Node)
   return true;
-if (ParentStack.size() > 0) {
-  // FIXME: Currently we add the same parent multiple times, but only
-  // when no memoization data is available for the type.
-  // For example when we visit all subexpressions of template
-  // instantiations; this is suboptimal, but benign: the only way to
-  // visit those is with hasAncestor / hasParent, and those do not create
-  // new matches.
-  // The plan is to enable DynTypedNode to be storable in a map or hash
-  // map. The main problem there is to implement hash functions /
-  // comparison operators for all types that DynTypedNode supports that
-  // do not have pointer identity.
-  auto &NodeOrVector = (*Parents)[MapNode];
-  if (NodeOrVector.isNull()) {
-if (const auto *D = ParentStack.back().get())
-  NodeOrVector = D;
-else if (const auto *S = ParentStack.back().get())
-  NodeOrVector = S;
-else
-  NodeOrVector = new DynTypedNode(ParentStack.back());
-  } else {

[PATCH] D88222: [AST] Use data-recursion when building ParentMap, avoid stack overflow.

2020-09-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 294154.
sammccall marked an inline comment as done.
sammccall added a comment.

Address comments.

Also remove a stale fixme, and simplify a little.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88222

Files:
  clang/lib/AST/ParentMapContext.cpp

Index: clang/lib/AST/ParentMapContext.cpp
===
--- clang/lib/AST/ParentMapContext.cpp
+++ clang/lib/AST/ParentMapContext.cpp
@@ -211,8 +211,6 @@
 /// Note that the relationship described here is purely in terms of AST
 /// traversal - there are other relationships (for example declaration context)
 /// in the AST that are better modeled by special matchers.
-///
-/// FIXME: Currently only builds up the map using \c Stmt and \c Decl nodes.
 class ParentMapContext::ParentMap::ASTVisitor
 : public RecursiveASTVisitor {
 public:
@@ -227,51 +225,60 @@
 
   bool shouldVisitImplicitCode() const { return true; }
 
+  /// Record the parent of the node we're visiting.
+  /// MapNode is the child, the parent is on top of ParentStack.
+  /// Parents is the parent storage (either PointerParents or OtherParents).
+  template 
+  void addParent(MapNodeTy MapNode, MapTy *Parents) {
+if (ParentStack.empty())
+  return;
+
+// FIXME: Currently we add the same parent multiple times, but only
+// when no memoization data is available for the type.
+// For example when we visit all subexpressions of template
+// instantiations; this is suboptimal, but benign: the only way to
+// visit those is with hasAncestor / hasParent, and those do not create
+// new matches.
+// The plan is to enable DynTypedNode to be storable in a map or hash
+// map. The main problem there is to implement hash functions /
+// comparison operators for all types that DynTypedNode supports that
+// do not have pointer identity.
+auto &NodeOrVector = (*Parents)[MapNode];
+if (NodeOrVector.isNull()) {
+  if (const auto *D = ParentStack.back().get())
+NodeOrVector = D;
+  else if (const auto *S = ParentStack.back().get())
+NodeOrVector = S;
+  else
+NodeOrVector = new DynTypedNode(ParentStack.back());
+} else {
+  if (!NodeOrVector.template is()) {
+auto *Vector = new ParentVector(
+1, getSingleDynTypedNodeFromParentMap(NodeOrVector));
+delete NodeOrVector.template dyn_cast();
+NodeOrVector = Vector;
+  }
+
+  auto *Vector = NodeOrVector.template get();
+  // Skip duplicates for types that have memoization data.
+  // We must check that the type has memoization data before calling
+  // std::find() because DynTypedNode::operator== can't compare all
+  // types.
+  bool Found = ParentStack.back().getMemoizationData() &&
+   std::find(Vector->begin(), Vector->end(),
+ ParentStack.back()) != Vector->end();
+  if (!Found)
+Vector->push_back(ParentStack.back());
+}
+  }
+
   template 
   bool TraverseNode(T Node, MapNodeTy MapNode, BaseTraverseFn BaseTraverse,
 MapTy *Parents) {
 if (!Node)
   return true;
-if (ParentStack.size() > 0) {
-  // FIXME: Currently we add the same parent multiple times, but only
-  // when no memoization data is available for the type.
-  // For example when we visit all subexpressions of template
-  // instantiations; this is suboptimal, but benign: the only way to
-  // visit those is with hasAncestor / hasParent, and those do not create
-  // new matches.
-  // The plan is to enable DynTypedNode to be storable in a map or hash
-  // map. The main problem there is to implement hash functions /
-  // comparison operators for all types that DynTypedNode supports that
-  // do not have pointer identity.
-  auto &NodeOrVector = (*Parents)[MapNode];
-  if (NodeOrVector.isNull()) {
-if (const auto *D = ParentStack.back().get())
-  NodeOrVector = D;
-else if (const auto *S = ParentStack.back().get())
-  NodeOrVector = S;
-else
-  NodeOrVector = new DynTypedNode(ParentStack.back());
-  } else {
-if (!NodeOrVector.template is()) {
-  auto *Vector = new ParentVector(
-  1, getSingleDynTypedNodeFromParentMap(NodeOrVector));
-  delete NodeOrVector.template dyn_cast();
-  NodeOrVector = Vector;
-}
-
-auto *Vector = NodeOrVector.template get();
-// Skip duplicates for types that have memoization data.
-// We must check that the type has memoization data before calling
-// std::find() because DynTypedNode::operator== can't compare all
-// types.
-bool Found = ParentStack.back().getMemoizationData() &&
- std::find(Vector->begin(), Vector->end(),
-

[PATCH] D52676: [clang-format] tweaked another case of lambda formatting

2020-09-24 Thread Oleg Smolsky via Phabricator via cfe-commits
oleg.smolsky added a comment.

@MyDeveloperDay that's the exact point. I authored this change to close a gap 
in some lambda formatting cases. The tests (existing, modified and added) 
express all relevant cases that I knew at the time.

@jaafar, @curdeius - this is just C++ code. Nothing is set in stone. Of course 
there are other cases that are effected by this change. The right way forward 
here is for you guys to author a new change. Ideally, the change will bring the 
new test, format it to your liking and change nothing else.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D52676

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


[PATCH] D88195: Remove stale assert.

2020-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D88195#2293589 , @void wrote:

> Clarify commit message.

Phabricator unfortunately won't amend the review description when the commit 
message is updated; you'll need to manually edit the description via phab's UI 
for other reviewers to observe the update. :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88195

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


[PATCH] D87451: add new clang option -mno-xcoff-visibility

2020-09-24 Thread Digger via Phabricator via cfe-commits
DiggerLin marked an inline comment as done.
DiggerLin added inline comments.



Comment at: llvm/include/llvm/Target/TargetMachine.h:265
+  /// corresponding to -mno-xcoff-visibility.
+  bool getNoXCOFFVisibility() const { return Options.NoXCOFFVisibility; }
+

jasonliu wrote:
> DiggerLin wrote:
> > daltenty wrote:
> > > This seems like it needs the corresponding comand-line option for llc 
> > > added and an llc test.
> > I think it will be in another separate  patch.
> I would actually prefer to have that in the same patch, as that would give us 
> a full picture. It's not a huge patch even if we combine them. 
yes, it is not huge patch, one patch for the clang with option 
-mno-xcoff-visibility, another patch for llc option -no-xcoff-visibility , I 
think it is different functionality. and I have post the 
https://reviews.llvm.org/D88234 "add new option -no-xcoff-visibility for llc"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87451

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


[PATCH] D88195: Remove stale assert.

2020-09-24 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 294150.
void added a comment.

Clarify commit message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88195

Files:
  clang/lib/AST/Stmt.cpp
  clang/test/Modules/Inputs/asm-goto/a.h
  clang/test/Modules/Inputs/asm-goto/module.modulemap
  clang/test/Modules/asm-goto.c


Index: clang/test/Modules/asm-goto.c
===
--- /dev/null
+++ clang/test/Modules/asm-goto.c
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c -I%S/Inputs/asm-goto 
-emit-module %S/Inputs/asm-goto/module.modulemap -fmodule-name=a -o %t/a.pcm
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c -I%S/Inputs/asm-goto 
-emit-llvm -o - %s -fmodule-file=%t/a.pcm | FileCheck %s
+#include "a.h"
+
+// CHECK-LABEL: define i32 @foo(
+// CHECK: callbr {{.*}} "=r,X,{{.*}}"(i8* blockaddress(@foo, %indirect))
+// CHECK-NEXT: to label %asm.fallthrough [label %indirect]
+
+int bar(void) {
+  return foo();
+}
Index: clang/test/Modules/Inputs/asm-goto/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/asm-goto/module.modulemap
@@ -0,0 +1 @@
+module a { header "a.h" export * }
Index: clang/test/Modules/Inputs/asm-goto/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/asm-goto/a.h
@@ -0,0 +1,13 @@
+int foo(void) {
+  int x;
+
+  asm goto(""
+   : "=r"(x)
+   :
+   :
+   : indirect);
+  x = 42;
+
+indirect:
+  return x;
+}
Index: clang/lib/AST/Stmt.cpp
===
--- clang/lib/AST/Stmt.cpp
+++ clang/lib/AST/Stmt.cpp
@@ -528,7 +528,6 @@
   this->NumInputs = NumInputs;
   this->NumClobbers = NumClobbers;
   this->NumLabels = NumLabels;
-  assert(!(NumOutputs && NumLabels) && "asm goto cannot have outputs");
 
   unsigned NumExprs = NumOutputs + NumInputs + NumLabels;
 


Index: clang/test/Modules/asm-goto.c
===
--- /dev/null
+++ clang/test/Modules/asm-goto.c
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c -I%S/Inputs/asm-goto -emit-module %S/Inputs/asm-goto/module.modulemap -fmodule-name=a -o %t/a.pcm
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c -I%S/Inputs/asm-goto -emit-llvm -o - %s -fmodule-file=%t/a.pcm | FileCheck %s
+#include "a.h"
+
+// CHECK-LABEL: define i32 @foo(
+// CHECK: callbr {{.*}} "=r,X,{{.*}}"(i8* blockaddress(@foo, %indirect))
+// CHECK-NEXT: to label %asm.fallthrough [label %indirect]
+
+int bar(void) {
+  return foo();
+}
Index: clang/test/Modules/Inputs/asm-goto/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/asm-goto/module.modulemap
@@ -0,0 +1 @@
+module a { header "a.h" export * }
Index: clang/test/Modules/Inputs/asm-goto/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/asm-goto/a.h
@@ -0,0 +1,13 @@
+int foo(void) {
+  int x;
+
+  asm goto(""
+   : "=r"(x)
+   :
+   :
+   : indirect);
+  x = 42;
+
+indirect:
+  return x;
+}
Index: clang/lib/AST/Stmt.cpp
===
--- clang/lib/AST/Stmt.cpp
+++ clang/lib/AST/Stmt.cpp
@@ -528,7 +528,6 @@
   this->NumInputs = NumInputs;
   this->NumClobbers = NumClobbers;
   this->NumLabels = NumLabels;
-  assert(!(NumOutputs && NumLabels) && "asm goto cannot have outputs");
 
   unsigned NumExprs = NumOutputs + NumInputs + NumLabels;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88195: Remove stale assert.

2020-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D88195#2293559 , @nickdesaulniers 
wrote:

> In D88195#2293533 , @void wrote:
>
>> In D88195#2293165 , 
>> @nickdesaulniers wrote:
>>
>>> I'm super confused between the commit message and initial hunk, that seem 
>>> to make sense and probably should go in clang-11 if it's not too late, and 
>>> the additional tests for modules which the commit message does not address. 
>>>  Were these meant to be separate commits, because otherwise it looks like 
>>> you uploaded unrelated stuff.  Are C++20 modules broken with `asm goto`, or 
>>> are you just adding additional test coverage for that?
>>
>> The assert only triggers for modules, so yeah modules are broken with "asm 
>> goto", but only if asserts are enabled.
>
> The assert was removed from AST/Stmt.cpp; it doesn't look module related.  
> Wouldn't it be triggered by ANY `GCCAsmStmt`?  (I have patches that use ASM 
> goto w/ outputs on the kernel, let me try an assertions enabled build).  It's 
> not obvious to me why the method modified would only trigger for modules.

Indeed, I don't trip the assertion in kernel builds using outputs.  Is 
`GCCAsmStmt::setOutputsAndInputsAndClobbers` only called for modules? If so, 
why?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88195

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


[PATCH] D88195: Remove stale assert.

2020-09-24 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

In D88195#2293559 , @nickdesaulniers 
wrote:

> In D88195#2293533 , @void wrote:
>
>> In D88195#2293165 , 
>> @nickdesaulniers wrote:
>>
>>> I'm super confused between the commit message and initial hunk, that seem 
>>> to make sense and probably should go in clang-11 if it's not too late, and 
>>> the additional tests for modules which the commit message does not address. 
>>>  Were these meant to be separate commits, because otherwise it looks like 
>>> you uploaded unrelated stuff.  Are C++20 modules broken with `asm goto`, or 
>>> are you just adding additional test coverage for that?
>>
>> The assert only triggers for modules, so yeah modules are broken with "asm 
>> goto", but only if asserts are enabled.
>
> The assert was removed from AST/Stmt.cpp; it doesn't look module related.  
> Wouldn't it be triggered by ANY `GCCAsmStmt`?  (I have patches that use ASM 
> goto w/ outputs on the kernel, let me try an assertions enabled build).  It's 
> not obvious to me why the method modified would only trigger for modules.

Yes, but that particular function is only called during serialization reading. 
It would trigger for any serialization, this just happens to be for modules. 
I'll edit the commit message to be clearer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88195

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


[PATCH] D87808: [DebugInfo] Fix bug in constructor homing where it would use ctor homing when a class only has copy/move constructors

2020-09-24 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 294149.
akhuang added a comment.

Add to comment for lambdas.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87808

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-limited-ctor.cpp


Index: clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
===
--- clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -20,14 +20,56 @@
 };
 D::D() {}
 
+// Test for constexpr constructor.
 // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: 
"E"{{.*}}DIFlagTypePassByValue
 struct E {
   constexpr E(){};
 } TestE;
 
+// Test for trivial constructor.
 // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: 
"F"{{.*}}DIFlagTypePassByValue
 struct F {
   F() = default;
   F(int) {}
   int i;
 } TestF;
+
+// Test for trivial constructor.
+// CHECK-DAG: ![[G:.*]] ={{.*}}!DICompositeType({{.*}}name: 
"G"{{.*}}DIFlagTypePassByValue
+// CHECK-DAG: !DICompositeType({{.*}}scope: ![[G]], {{.*}}DIFlagTypePassByValue
+struct G {
+  G() : g_(0) {}
+  struct {
+int g_;
+  };
+} TestG;
+
+// Test for an aggregate class with an implicit non-trivial default constructor
+// that is not instantiated.
+// CHECK-DAG: !DICompositeType({{.*}}name: "H",{{.*}}DIFlagTypePassByValue
+struct H {
+  B b;
+};
+void f(H h) {}
+
+// Test for an aggregate class with an implicit non-trivial default constructor
+// that is instantiated.
+// CHECK-DAG: !DICompositeType({{.*}}name: "J",{{.*}}DIFlagTypePassByValue
+struct J {
+  B b;
+};
+void f(decltype(J()) j) {}
+
+// Test for a class with trivial default constructor that is not instantiated.
+// CHECK-DAG: !DICompositeType({{.*}}name: "K",{{.*}}DIFlagTypePassByValue
+class K {
+  int i;
+};
+void f(K k) {}
+
+// Test that we don't use constructor homing on lambdas.
+// CHECK-DAG: ![[L:.*]] ={{.*}}!DISubprogram({{.*}}name: "L"
+// CHECK-DAG: !DICompositeType({{.*}}scope: ![[L]], {{.*}}DIFlagTypePassByValue
+void L() {
+  auto func = [&]() {};
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2281,22 +2281,20 @@
 }
 
 static bool canUseCtorHoming(const CXXRecordDecl *RD) {
-  // Constructor homing can be used for classes that have at least one
-  // constructor and have no trivial or constexpr constructors.
+  // Constructor homing can be used for classes that cannnot be constructed
+  // without emitting code for one of their constructors. This is classes that
+  // don't have trivial or constexpr constructors, or can be created from
+  // aggregate initialization. Also skip lambda objects because they don't call
+  // constructors.
+
   // Skip this optimization if the class or any of its methods are marked
   // dllimport.
-  if (RD->isLambda() || RD->hasConstexprNonCopyMoveConstructor() ||
-  isClassOrMethodDLLImport(RD))
-return false;
-
-  if (RD->ctors().empty())
+  if (isClassOrMethodDLLImport(RD))
 return false;
 
-  for (const auto *Ctor : RD->ctors())
-if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor())
-  return false;
-
-  return true;
+  return !RD->isLambda() && !RD->isAggregate() &&
+ !RD->hasTrivialDefaultConstructor() &&
+ !RD->hasConstexprNonCopyMoveConstructor();
 }
 
 static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,


Index: clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
===
--- clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -20,14 +20,56 @@
 };
 D::D() {}
 
+// Test for constexpr constructor.
 // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "E"{{.*}}DIFlagTypePassByValue
 struct E {
   constexpr E(){};
 } TestE;
 
+// Test for trivial constructor.
 // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "F"{{.*}}DIFlagTypePassByValue
 struct F {
   F() = default;
   F(int) {}
   int i;
 } TestF;
+
+// Test for trivial constructor.
+// CHECK-DAG: ![[G:.*]] ={{.*}}!DICompositeType({{.*}}name: "G"{{.*}}DIFlagTypePassByValue
+// CHECK-DAG: !DICompositeType({{.*}}scope: ![[G]], {{.*}}DIFlagTypePassByValue
+struct G {
+  G() : g_(0) {}
+  struct {
+int g_;
+  };
+} TestG;
+
+// Test for an aggregate class with an implicit non-trivial default constructor
+// that is not instantiated.
+// CHECK-DAG: !DICompositeType({{.*}}name: "H",{{.*}}DIFlagTypePassByValue
+struct H {
+  B b;
+};
+void f(H h) {}
+
+// Test for an aggregate class with an implicit non-trivial default constructor
+// that is instantiated.
+// CHECK-DAG: !DICompositeType({{.*}}name: "J",{{.*}}DIFlagTypePassByValue
+struct J {
+  B b;
+};
+void f(decltype(J()) j) {}
+
+// Test for a 

[clang] 579c422 - [OPENMP]Fix PR47621: Variable used by task inside a template function is not made firstprivate by default

2020-09-24 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-09-24T16:18:09-04:00
New Revision: 579c42225ac373688dbdbe3a1ce62986a6bf638a

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

LOG: [OPENMP]Fix PR47621: Variable used by task inside a template function is 
not made firstprivate by default

Need to fix a check for the variable if it is declared in the inner
OpenMP region to be able to firstprivatize it.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
clang/test/OpenMP/task_codegen.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 12b6c2810597..91897cbe25b4 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -159,6 +159,7 @@ class DSAStackTy {
 OpenMPDirectiveKind Directive = OMPD_unknown;
 DeclarationNameInfo DirectiveName;
 Scope *CurScope = nullptr;
+DeclContext *Context = nullptr;
 SourceLocation ConstructLoc;
 /// Set of 'depend' clauses with 'sink|source' dependence kind. Required to
 /// get the data (loop counters etc.) about enclosing loop-based construct.
@@ -918,6 +919,7 @@ class DSAStackTy {
 const SharingMapTy *Top = getTopOfStackOrNull();
 return Top ? Top->CurScope : nullptr;
   }
+  void setContext(DeclContext *DC) { getTopOfStack().Context = DC; }
   SourceLocation getConstructLoc() const {
 const SharingMapTy *Top = getTopOfStackOrNull();
 return Top ? Top->ConstructLoc : SourceLocation();
@@ -1531,11 +1533,17 @@ bool DSAStackTy::isOpenMPLocal(VarDecl *D, 
const_iterator I) const {
   for (const_iterator E = end(); I != E; ++I) {
 if (isImplicitOrExplicitTaskingRegion(I->Directive) ||
 isOpenMPTargetExecutionDirective(I->Directive)) {
-  Scope *TopScope = I->CurScope ? I->CurScope->getParent() : nullptr;
-  Scope *CurScope = getCurScope();
-  while (CurScope && CurScope != TopScope && !CurScope->isDeclScope(D))
-CurScope = CurScope->getParent();
-  return CurScope != TopScope;
+  if (I->CurScope) {
+Scope *TopScope = I->CurScope->getParent();
+Scope *CurScope = getCurScope();
+while (CurScope && CurScope != TopScope && !CurScope->isDeclScope(D))
+  CurScope = CurScope->getParent();
+return CurScope != TopScope;
+  }
+  for (DeclContext *DC = D->getDeclContext(); DC; DC = DC->getParent())
+if (I->Context == DC)
+  return true;
+  return false;
 }
   }
   return false;
@@ -4148,6 +4156,7 @@ void Sema::ActOnOpenMPRegionStart(OpenMPDirectiveKind 
DKind, Scope *CurScope) {
   default:
 llvm_unreachable("Unknown OpenMP directive");
   }
+  DSAStack->setContext(CurContext);
 }
 
 int Sema::getNumberOfConstructScopes(unsigned Level) const {

diff  --git 
a/clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp 
b/clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
index 8f814de05b70..aefe00f1cadf 100644
--- a/clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
+++ b/clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp 
-fopenmp-cuda-mode -internal-isystem %S/../Headers/Inputs/include 
-internal-isystem %S/../../lib/Headers/openmp_wrappers -include 
__clang_openmp_device_functions.h -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp 
-fopenmp-cuda-mode -internal-isystem %S/../Headers/Inputs/include 
-internal-isystem %S/../../lib/Headers/openmp_wrappers -include 
__clang_openmp_device_functions.h -triple nvptx64-unknown-unknown -aux-triple 
powerpc64le-unknown-unknown  -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp 
-fopenmp-cuda-mode -internal-isystem %S/../Headers/Inputs/include 
-internal-isystem %S/../../lib/Headers/openmp_wrappers -include 
__clang_openmp_device_functions.h -triple i386-unknown-unknown 
-fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
-// RUN: %clang_cc1 -x c++ -O1 -disable-llvm-optzns -verify -fopenmp 
-fopenmp-cuda-mode -internal-isystem %S/../Headers/Inputs/include 
-internal-isystem %S/../../lib/Headers/openmp_wrappers -include 
__clang_openmp_device_functions.h -triple nvptx-unknown-unknown -aux-triple 
powerpc64le-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s 
-fopenmp-is-devi

[PATCH] D74455: [MS] Pass aligned, non-trivially copyable things indirectly on x86

2020-09-24 Thread Reid Kleckner via Phabricator via cfe-commits
rnk abandoned this revision.
rnk added a comment.

I actually forgot about this change entirely and uploaded and landed a new one:
https://reviews.llvm.org/D87923

I suppose they are functionally different: if we have an overaligned type that 
can be passed in registers due to [[trivial_abi]], we should do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74455

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


[PATCH] D88195: Remove stale assert.

2020-09-24 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D88195#2293533 , @void wrote:

> In D88195#2293165 , @nickdesaulniers 
> wrote:
>
>> I'm super confused between the commit message and initial hunk, that seem to 
>> make sense and probably should go in clang-11 if it's not too late, and the 
>> additional tests for modules which the commit message does not address.  
>> Were these meant to be separate commits, because otherwise it looks like you 
>> uploaded unrelated stuff.  Are C++20 modules broken with `asm goto`, or are 
>> you just adding additional test coverage for that?
>
> The assert only triggers for modules, so yeah modules are broken with "asm 
> goto", but only if asserts are enabled.

The assert was removed from AST/Stmt.cpp; it doesn't look module related.  
Wouldn't it be triggered by ANY `GCCAsmStmt`?  (I have patches that use ASM 
goto w/ outputs on the kernel, let me try an assertions enabled build).  It's 
not obvious to me why the method modified would only trigger for modules.

> The official release doesn't have asserts, so I don't know if this counts as 
> a blocker. But it's not a change in semantics, only to remove an assert...

That's fair.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88195

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


[clang] f8a92ad - Remove dead branch identified by @rsmith on post-commit for D88236

2020-09-24 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2020-09-24T13:05:15-07:00
New Revision: f8a92adfa242a94052f583ef7b483ae1b493ebdc

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

LOG: Remove dead branch identified by @rsmith on post-commit for D88236

Added: 


Modified: 
clang/lib/CodeGen/CGExprConstant.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprConstant.cpp 
b/clang/lib/CodeGen/CGExprConstant.cpp
index 5b3631087f45..b0a37531dfe1 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -2141,15 +2141,6 @@ llvm::Constant *ConstantEmitter::tryEmitPrivate(const 
APValue &Value,
   Elts.push_back(C);
 }
 
-// This means that the array type is probably "IncompleteType" or some
-// type that is not ConstantArray.
-if (!Filler && !NumInitElts) {
-  CommonElementType = 
CGM.getTypes().ConvertType(ArrayTy->getElementType());
-  llvm::ArrayType *AType =
-  llvm::ArrayType::get(CommonElementType, NumElements);
-  return llvm::ConstantAggregateZero::get(AType);
-}
-
 llvm::ArrayType *Desired =
 cast(CGM.getTypes().ConvertType(DestType));
 return EmitArrayConstant(CGM, Desired, CommonElementType, NumElements, 
Elts,



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


[PATCH] D87349: [clang] adapt c++17 behavior for dependent decltype-specifiers

2020-09-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/include/clang/AST/Type.h:4499-4508
 /// Internal representation of canonical, dependent
 /// decltype(expr) types.
 ///
 /// This class is used internally by the ASTContext to manage
 /// canonical, dependent types, only. Clients will only see instances
 /// of this class via DecltypeType nodes.
+class DependentDecltypeType : public DecltypeType {

rsmith wrote:
> Can we remove this class now?
yeah I think it is possible, but I would rather do it in a follow-up patch -- 
the current patch seems large enough. Added a FIXME.



Comment at: clang/test/CodeGenCXX/mangle.cpp:805
 
-  // CHECK-LABEL: define weak_odr void 
@_ZN6test341fIiEEvDTstDTplcvT__EcvS1__EEE
+  // CHECK-LABEL: define weak_odr void @_ZN6test341fIiEEvm
   template void f(decltype(sizeof(1)));

rsmith wrote:
> hokein wrote:
> > rsmith wrote:
> > > rsmith wrote:
> > > > sammccall wrote:
> > > > > sammccall wrote:
> > > > > > GCC mangles this as `_ZN6test341fIiEEvDTstDTplcvT__EcvS1__EEE`, so 
> > > > > > we're breaking compat here :-\
> > > > > > 
> > > > > > And in fact we're just incorrect. 
> > > > > > https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling:
> > > > > > 
> > > > > > > If the operand expression of decltype is not 
> > > > > > > instantiation-dependent then the resulting type is encoded 
> > > > > > > directly.
> > > > > > 
> > > > > > Here, instantiation-dependent *is* explicitly defined as 
> > > > > > "type-dependent or value-dependent or ...". And therefore these 
> > > > > > cases must not be "encoded directly", including the motivating case 
> > > > > > (decltype(N) where N is a typed constant whose initializer is 
> > > > > > value-dependent).
> > > > > > 
> > > > > > We could consider not two but *three* types of decltypetypes:
> > > > > >  - decltype(type-dependent), which is sugar for a canonical 
> > > > > > DependentDeclTypeType
> > > > > >  - decltype(instantiation-but-not-type-dependent), which is still 
> > > > > > sugar for a concrete canonical type (per C++17) but mangles using 
> > > > > > the expr (per cxxabi)
> > > > > >  - decltype(non-dependent), which is sugar for a concrete canonical 
> > > > > > type and mangles directly
> > > > > > 
> > > > > > This only works if it's OK for mangling to depend on non-canonical 
> > > > > > type details - I don't know whether this is the case. @rsmith - any 
> > > > > > hints here?
> > > > > Hmm, my naive reading of the mangle code matches what I described.
> > > > > 
> > > > > The big comment in ItaniumMangle talks about related issues: 
> > > > > https://github.com/llvm/llvm-project/blob/24238f09edb98b0f460aa41139874ae5d4e5cd8d/clang/lib/AST/ItaniumMangle.cpp#L2541-L2572
> > > > > 
> > > > > I don't really understand what's going on here, sorry.
> > > > Looks like we need the single-step-desugaring loop below the big 
> > > > comment you quoted to stop when it hits a `decltype` type. That's 
> > > > presumably where we step from the 
> > > > instantiation-dependent-but-not-type-dependent `decltype` node to its 
> > > > desugared type.
> > > Also... the FIXME from that comment will apply here too. Given:
> > > ```
> > > template void f(decltype(sizeof(T)), decltype(sizeof(T))) {}
> > > template void f(unsigned long, unsigned long);
> > > ```
> > > we currently (correctly, as far as I can see) use a substitution for the 
> > > second parameter type, but with the change here, I don't think we will do 
> > > so any more. We could fix that by deduplicating `DecltypeType`s when 
> > > they're instantiation dependent but not dependent; that's what we do for 
> > > `ConstantArrayType`'s size expression, for example. If we do that, we'll 
> > > need to store the actual expression on the `DecltypeTypeLoc`, since we 
> > > can't rely on the `DecltypeType` having the right expression any more 
> > > (only an expression that's equivalent to it).
> > Thanks for the hints and explanations.
> > 
> > > we currently (correctly, as far as I can see) use a substitution for the 
> > > second parameter type, but with the change here, I don't think we will do 
> > > so any more.
> > 
> > thanks for the example, yeah, the behavior was changed with the prior 
> > change of this patch. 
> > 
> > > We could fix that by deduplicating DecltypeTypes when they're 
> > > instantiation dependent but not dependent; that's what we do for 
> > > ConstantArrayType's size expression, for example. If we do that, we'll 
> > > need to store the actual expression on the DecltypeTypeLoc, since we 
> > > can't rely on the DecltypeType having the right expression any more (only 
> > > an expression that's equivalent to it).
> > 
> > It took me sometime to understand the whole piece here, but I'm afraid that 
> > I still don't fully understand the second part -- any reason why we can't 
> > rely on the underlying expression of DecltypeType when doing the 
> > deduplication? If we store the actual

[PATCH] D88195: Remove stale assert.

2020-09-24 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

In D88195#2293165 , @nickdesaulniers 
wrote:

> I'm super confused between the commit message and initial hunk, that seem to 
> make sense and probably should go in clang-11 if it's not too late, and the 
> additional tests for modules which the commit message does not address.  Were 
> these meant to be separate commits, because otherwise it looks like you 
> uploaded unrelated stuff.  Are C++20 modules broken with `asm goto`, or are 
> you just adding additional test coverage for that?

The assert only triggers for modules, so yeah modules are broken with "asm 
goto", but only if asserts are enabled. The official release doesn't have 
asserts, so I don't know if this counts as a blocker. But it's not a change in 
semantics, only to remove an assert...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88195

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


[PATCH] D87349: [clang] adapt c++17 behavior for dependent decltype-specifiers

2020-09-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 294143.
hokein marked 2 inline comments as done.
hokein added a comment.

store the actual expression in DecltypeTypeLoc and address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87349

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGenCXX/mangle.cpp
  clang/test/Sema/invalid-bitwidth-expr.mm
  clang/test/SemaCXX/invalid-template-base-specifier.cpp
  clang/test/SemaTemplate/dependent-expr.cpp
  clang/test/SemaTemplate/temp_arg_template_cxx1z.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp
@@ -121,4 +121,18 @@
   DeclRefExprVisitor::Lang_OBJCXX11));
 }
 
+TEST(RecursiveASTVisitor,
+ VisitInstantiationDependentDecltypeTypeUnderlyingExpr) {
+  DeclRefExprVisitor Visitor;
+  Visitor.ExpectMatch("x", 3, 57);
+  Visitor.ExpectMatch("x", 4, 57);
+  EXPECT_TRUE(Visitor.runOver(
+  R"cpp(
+  int x;
+  template void f(decltype(sizeof(T().f(x;
+  template void g(decltype(sizeof(T().f(x;
+)cpp",
+  DeclRefExprVisitor::Lang_CXX17));
+}
+
 } // end anonymous namespace
Index: clang/test/SemaTemplate/temp_arg_template_cxx1z.cpp
===
--- clang/test/SemaTemplate/temp_arg_template_cxx1z.cpp
+++ clang/test/SemaTemplate/temp_arg_template_cxx1z.cpp
@@ -115,6 +115,6 @@
 
   int n;
   template struct SubstFailure;
-  TInt isf; // FIXME: this should be ill-formed
+  TInt isf; // expected-error {{template template argument has different template parameters than its corresponding template template parameter}}
   TIntPtr ipsf;
 }
Index: clang/test/SemaTemplate/dependent-expr.cpp
===
--- clang/test/SemaTemplate/dependent-expr.cpp
+++ clang/test/SemaTemplate/dependent-expr.cpp
@@ -129,7 +129,7 @@
   template void f() {
 decltype(({})) x; // expected-error {{incomplete type}}
   }
-  template void f(); // expected-note {{instantiation of}}
+  template void f();
 
   template auto g() {
 auto c = [](auto, int) -> decltype(({})) {};
Index: clang/test/SemaCXX/invalid-template-base-specifier.cpp
===
--- clang/test/SemaCXX/invalid-template-base-specifier.cpp
+++ clang/test/SemaCXX/invalid-template-base-specifier.cpp
@@ -12,11 +12,12 @@
 template 
 using Alias = decltype(Foo(T())); // expected-error {{no matching function for call to 'Foo'}}
 template 
-struct Crash2 : decltype(Alias()) { // expected-note {{in instantiation of template type alias 'Alias' requested here}}
+struct Crash2 : decltype(Alias()) { // expected-note {{in instantiation of template type alias 'Alias' requested here}} \
+  expected-error {{base specifier must name a class}}
   Crash2(){};
 };
 
-void test2() { Crash2(); } // expected-note {{in instantiation of template class 'Crash2' requested here}}
+void test2() { Crash2(); } // expected-note2 {{in instantiation of template class 'Crash2' requested here}}
 
 template 
 class Base {};
Index: clang/test/Sema/invalid-bitwidth-expr.mm
===
--- clang/test/Sema/invalid-bitwidth-expr.mm
+++ clang/test/Sema/invalid-bitwidth-expr.mm
@@ -25,7 +25,8 @@
 template 
 auto func() {
   // error-bit should be propagated from TemplateArgument to NestNameSpecifier.
-  class Base::type C; // expected-error {{no matching function for call to 'Foo'}}
+  class Base::type C; // expected-error {{no matching function for call to 'Foo'}} \
+ expected-error {{no class named 'type' in}}
   return C;
 }
 struct Z {
Index: clang/test/CodeGenCXX/mangle.cpp
===
--- clang/test/CodeGenCXX/mangle.cpp
+++ clang/test/CodeGenCXX/mangle.cpp
@@ -805,6 +805,10 @@
   // CHECK-LABEL: define weak_odr void @_ZN6test341fIiEEvDTstDTplcvT__EcvS1__EEE
   template void f(decltype(sizeof(1)));
 
+  template  void f(decltype(sizeof(T)), decltype(sizeof(T))) {}
+  // CHECK-LABEL: define weak_odr void @_ZN6test341fIiEEvDTstT_ES2_
+  template void f(uns

[PATCH] D88195: Remove stale assert.

2020-09-24 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 294141.
void added a comment.

Fix test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88195

Files:
  clang/lib/AST/Stmt.cpp
  clang/test/Modules/Inputs/asm-goto/a.h
  clang/test/Modules/Inputs/asm-goto/module.modulemap
  clang/test/Modules/asm-goto.c


Index: clang/test/Modules/asm-goto.c
===
--- /dev/null
+++ clang/test/Modules/asm-goto.c
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c -I%S/Inputs/asm-goto 
-emit-module %S/Inputs/asm-goto/module.modulemap -fmodule-name=a -o %t/a.pcm
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c -I%S/Inputs/asm-goto 
-emit-llvm -o - %s -fmodule-file=%t/a.pcm | FileCheck %s
+#include "a.h"
+
+// CHECK-LABEL: define i32 @foo(
+// CHECK: callbr {{.*}} "=r,X,{{.*}}"(i8* blockaddress(@foo, %indirect))
+// CHECK-NEXT: to label %asm.fallthrough [label %indirect]
+
+int bar(void) {
+  return foo();
+}
Index: clang/test/Modules/Inputs/asm-goto/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/asm-goto/module.modulemap
@@ -0,0 +1 @@
+module a { header "a.h" export * }
Index: clang/test/Modules/Inputs/asm-goto/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/asm-goto/a.h
@@ -0,0 +1,13 @@
+int foo(void) {
+  int x;
+
+  asm goto(""
+   : "=r"(x)
+   :
+   :
+   : indirect);
+  x = 42;
+
+indirect:
+  return x;
+}
Index: clang/lib/AST/Stmt.cpp
===
--- clang/lib/AST/Stmt.cpp
+++ clang/lib/AST/Stmt.cpp
@@ -528,7 +528,6 @@
   this->NumInputs = NumInputs;
   this->NumClobbers = NumClobbers;
   this->NumLabels = NumLabels;
-  assert(!(NumOutputs && NumLabels) && "asm goto cannot have outputs");
 
   unsigned NumExprs = NumOutputs + NumInputs + NumLabels;
 


Index: clang/test/Modules/asm-goto.c
===
--- /dev/null
+++ clang/test/Modules/asm-goto.c
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c -I%S/Inputs/asm-goto -emit-module %S/Inputs/asm-goto/module.modulemap -fmodule-name=a -o %t/a.pcm
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -x c -I%S/Inputs/asm-goto -emit-llvm -o - %s -fmodule-file=%t/a.pcm | FileCheck %s
+#include "a.h"
+
+// CHECK-LABEL: define i32 @foo(
+// CHECK: callbr {{.*}} "=r,X,{{.*}}"(i8* blockaddress(@foo, %indirect))
+// CHECK-NEXT: to label %asm.fallthrough [label %indirect]
+
+int bar(void) {
+  return foo();
+}
Index: clang/test/Modules/Inputs/asm-goto/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/asm-goto/module.modulemap
@@ -0,0 +1 @@
+module a { header "a.h" export * }
Index: clang/test/Modules/Inputs/asm-goto/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/asm-goto/a.h
@@ -0,0 +1,13 @@
+int foo(void) {
+  int x;
+
+  asm goto(""
+   : "=r"(x)
+   :
+   :
+   : indirect);
+  x = 42;
+
+indirect:
+  return x;
+}
Index: clang/lib/AST/Stmt.cpp
===
--- clang/lib/AST/Stmt.cpp
+++ clang/lib/AST/Stmt.cpp
@@ -528,7 +528,6 @@
   this->NumInputs = NumInputs;
   this->NumClobbers = NumClobbers;
   this->NumLabels = NumLabels;
-  assert(!(NumOutputs && NumLabels) && "asm goto cannot have outputs");
 
   unsigned NumExprs = NumOutputs + NumInputs + NumLabels;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87720: Sema: add support for `__attribute__((__swift_private__))`

2020-09-24 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 294140.
compnerd added a comment.

add more tests to cover the confusing case of attribute merge handling


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87720

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/AST/attr-swift_private.m
  clang/test/SemaObjC/attr-swift_private.m

Index: clang/test/SemaObjC/attr-swift_private.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-swift_private.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc %s
+
+__attribute__((__swift_private__))
+@protocol P
+@end
+
+__attribute__((__swift_private__))
+@interface I
+@end
+
+@interface J
+@property id property __attribute__((__swift_private__));
+- (void)instanceMethod __attribute__((__swift_private__));
++ (void)classMethod __attribute__((__swift_private__));
+@end
+
+void f(void) __attribute__((__swift_private__));
+
+struct __attribute__((__swift_private__)) S {};
+
+enum __attribute__((__swift_private__)) E {
+  one,
+  two,
+};
+
+typedef struct { } T __attribute__((__swift_private__));
+
+void g(void) __attribute__((__swift_private__("private")));
+// expected-error@-1 {{'__swift_private__' attribute takes no arguments}}
Index: clang/test/AST/attr-swift_private.m
===
--- /dev/null
+++ clang/test/AST/attr-swift_private.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -ast-dump %s | FileCheck %s
+
+@interface I
+- (void)method __attribute__((__swift_private__));
+@end
+
+// CHECK: ObjCInterfaceDecl {{.*}} I
+// CHECK: ObjCMethodDecl {{.*}} method 'void'
+// CHECK: SwiftPrivateAttr
+
+@interface J : I
+- (void)method;
+@end
+
+// CHECK: ObjCInterfaceDecl {{.*}} J
+// CHECK: ObjCMethodDecl {{.*}} method 'void'
+// CHECK: SwiftPrivateAttr {{.*}} Inherited
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -7904,6 +7904,9 @@
   case ParsedAttr::AT_SwiftObjCMembers:
 handleSimpleAttribute(S, D, AL);
 break;
+  case ParsedAttr::AT_SwiftPrivate:
+handleSimpleAttribute(S, D, AL);
+break;
 
   // XRay attributes.
   case ParsedAttr::AT_XRayLogArgs:
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2595,6 +2595,8 @@
   else if (const auto *SNA = dyn_cast(Attr))
 NewAttr = S.mergeSwiftNameAttr(D, *SNA, SNA->getName(),
AMK == Sema::AMK_Override);
+  else if (isa(Attr) && AMK == Sema::AMK_Override)
+NewAttr = nullptr;
   else if (const auto *OA = dyn_cast(Attr))
 NewAttr = S.mergeOptimizeNoneAttr(D, *OA);
   else if (const auto *InternalLinkageA = dyn_cast(Attr))
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -3653,6 +3653,19 @@
   }];
 }
 
+def SwiftPrivateDocs : Documentation {
+  let Category = SwiftDocs;
+  let Heading = "swift_private";
+  let Content = [{
+Declarations marked with the ``swift_private`` attribute are hidden from the
+framework client but are still made available for use within the framework or
+Swift SDK overlay.
+
+The purpose of this attribute is to permit a more idomatic implementation of
+declarations in Swift while hiding the non-idiomatic one.
+  }];
+}
+
 def OMPDeclareSimdDocs : Documentation {
   let Category = DocCatFunction;
   let Heading = "#pragma omp declare simd";
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -2177,6 +2177,11 @@
   let HasCustomParsing = 1;
 }
 
+def SwiftPrivate : InheritableAttr {
+  let Spellings = [GNU<"swift_private">];
+  let Documentation = [SwiftPrivateDocs];
+}
+
 def NoDeref : TypeAttr {
   let Spellings = [Clang<"noderef">];
   let Documentation = [NoDerefDocs];
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87029: [AIX] Implement AIX special bitfield related alignment rules

2020-09-24 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L marked an inline comment as done.
Xiangling_L added a comment.

In D87029#2285398 , @jasonliu wrote:

> I think it would help the review if we could put the NFC portion(e.g. 
> TypeSize -> StorageUnitSize) to a new patch, and give some rationale about 
> the NFC change.

Sure, will do.


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

https://reviews.llvm.org/D87029

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


[clang] 9eba6b2 - Revert "[Modules] Add stats to measure performance of building and loading modules."

2020-09-24 Thread Volodymyr Sapsai via cfe-commits

Author: Volodymyr Sapsai
Date: 2020-09-24T12:36:06-07:00
New Revision: 9eba6b20a0579d3441e1b0f3cb3942f86d32679f

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

LOG: Revert "[Modules] Add stats to measure performance of building and loading 
modules."

This reverts commit c4bacc3c9b333bb7032fb96f41d6f5b851623132.

Test "LLVM :: ThinLTO/X86/funcimport-stats.ll" is failing. Reverting now
and will recommit after making the test not fail with the added stats.

Added: 


Modified: 
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Serialization/ASTReader.cpp
llvm/lib/Support/MemoryBuffer.cpp
llvm/lib/Support/Path.cpp
llvm/lib/Support/Unix/Path.inc
llvm/lib/Support/Windows/Path.inc

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 445049324780..4613ed8d7f61 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -55,10 +55,6 @@
 
 using namespace clang;
 
-#define DEBUG_TYPE "modules"
-
-ALWAYS_ENABLED_STATISTIC(NumCompiledModules, "Number of compiled modules.");
-
 CompilerInstance::CompilerInstance(
 std::shared_ptr PCHContainerOps,
 InMemoryModuleCache *SharedModuleCache)
@@ -1067,7 +1063,6 @@ compileModuleImpl(CompilerInstance &ImportingInstance, 
SourceLocation ImportLoc,
   llvm::function_ref PostBuildStep =
   [](CompilerInstance &) {}) {
   llvm::TimeTraceScope TimeScope("Module Compile", ModuleName);
-  ++NumCompiledModules;
 
   // Construct a compiler invocation for creating this module.
   auto Invocation =

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index e71d73310d52..b2780db85166 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -100,7 +100,6 @@
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
@@ -143,15 +142,6 @@ using namespace clang::serialization::reader;
 using llvm::BitstreamCursor;
 using llvm::RoundingMode;
 
-#define DEBUG_TYPE "modules"
-
-ALWAYS_ENABLED_STATISTIC(NumTryLoadModule, "Number of times tried to load a "
-   "module. Includes failed attempts "
-   "and using cached results.");
-ALWAYS_ENABLED_STATISTIC(NumReadASTCore,
- "Number of ReadASTCore() invocations. Includes only "
- "actual AST core parsing and ignores cached 
results.");
-
 
//===--===//
 // ChainedASTReaderListener implementation
 
//===--===//
@@ -4213,7 +4203,6 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef 
FileName,
 SourceLocation ImportLoc,
 unsigned ClientLoadCapabilities,
 SmallVectorImpl 
*Imported) {
-  ++NumTryLoadModule;
   llvm::SaveAndRestore
 SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
 
@@ -4563,7 +4552,6 @@ ASTReader::ReadASTCore(StringRef FileName,
 return Failure;
   }
 
-  ++NumReadASTCore;
   // This is used for compatibility with older PCH formats.
   bool HaveReadControlBlock = false;
   while (true) {

diff  --git a/llvm/lib/Support/MemoryBuffer.cpp 
b/llvm/lib/Support/MemoryBuffer.cpp
index 4b851a20fc48..248fb72c4968 100644
--- a/llvm/lib/Support/MemoryBuffer.cpp
+++ b/llvm/lib/Support/MemoryBuffer.cpp
@@ -12,7 +12,6 @@
 
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/Statistic.h"
 #include "llvm/Config/config.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Errno.h"
@@ -35,12 +34,6 @@
 #endif
 using namespace llvm;
 
-#define DEBUG_TYPE "memory-buffer"
-
-ALWAYS_ENABLED_STATISTIC(NumMmapFile, "Number of mmap-ed files.");
-ALWAYS_ENABLED_STATISTIC(NumAllocFile,
- "Number of files read into allocated memory buffer.");
-
 
//===--===//
 // MemoryBuffer implementation itself.
 
//===--===//
@@ -456,10 +449,8 @@ getOpenFileImpl(sys::fs::file_t FD, const Twine &Filename, 
uint64_t FileSize,
   // buffer by copying off the stream.
   sys::fs::file_type Type = Status.type();
   if (Type != sys::fs::file_type::regular_file &&
-  Type != sys::fs::file_type::block_fil

[PATCH] D86895: [Modules] Add stats to measure performance of building and loading modules.

2020-09-24 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the reviews!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86895

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


[PATCH] D88236: [PR47636] Fix tryEmitPrivate to handle non-constantarraytypes

2020-09-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Ok then, I'll take a look to see what it would take to make the 
MaterializeTemporaryExpr be created with the complete type here instead.  
Thanks!




Comment at: clang/lib/CodeGen/CGExprConstant.cpp:2148
+CommonElementType == nullptr && !NumInitElts) {
   const ArrayType *AT = CGM.getContext().getAsArrayType(DestType);
   CommonElementType = CGM.getTypes().ConvertType(AT->getElementType());

rsmith wrote:
> rjmccall wrote:
> > `AT` is now just `ArrayTy`, and I think you can just check `!Filler && 
> > !NumInitElts`.
> `Filler` is null if and only if `NumElements == NumInitElts`, and 
> `NumInitElts <= NumElements`, so this condition reduces to `if 
> (!NumElements)`. `EmitArrayConstant` responds to that case by creating a 
> `ConstantAggregateZero` of its destination type. So it seems to me that we 
> probably don't need this special case at all.
I'll submit a patch to remove this branch then, thanks!


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

https://reviews.llvm.org/D88236

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


[PATCH] D86895: [Modules] Add stats to measure performance of building and loading modules.

2020-09-24 Thread Volodymyr Sapsai 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 rGc4bacc3c9b33: [Modules] Add stats to measure performance of 
building and loading modules. (authored by vsapsai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86895

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Serialization/ASTReader.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/Unix/Path.inc
  llvm/lib/Support/Windows/Path.inc

Index: llvm/lib/Support/Windows/Path.inc
===
--- llvm/lib/Support/Windows/Path.inc
+++ llvm/lib/Support/Windows/Path.inc
@@ -710,6 +710,7 @@
 }
 
 std::error_code status(const Twine &path, file_status &result, bool Follow) {
+  ++NumStatusCalls;
   SmallString<128> path_storage;
   SmallVector path_utf16;
 
@@ -742,11 +743,13 @@
 }
 
 std::error_code status(int FD, file_status &Result) {
+  ++NumStatusCalls;
   HANDLE FileHandle = reinterpret_cast(_get_osfhandle(FD));
   return getStatus(FileHandle, Result);
 }
 
 std::error_code status(file_t FileHandle, file_status &Result) {
+  ++NumStatusCalls;
   return getStatus(FileHandle, Result);
 }
 
Index: llvm/lib/Support/Unix/Path.inc
===
--- llvm/lib/Support/Unix/Path.inc
+++ llvm/lib/Support/Unix/Path.inc
@@ -736,6 +736,7 @@
 }
 
 std::error_code status(const Twine &Path, file_status &Result, bool Follow) {
+  ++NumStatusCalls;
   SmallString<128> PathStorage;
   StringRef P = Path.toNullTerminatedStringRef(PathStorage);
 
@@ -745,6 +746,7 @@
 }
 
 std::error_code status(int FD, file_status &Result) {
+  ++NumStatusCalls;
   struct stat Status;
   int StatRet = ::fstat(FD, &Status);
   return fillStatus(StatRet, Status, Result);
Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -12,6 +12,7 @@
 
 #include "llvm/Support/Path.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Errc.h"
@@ -31,6 +32,10 @@
 using namespace llvm;
 using namespace llvm::support::endian;
 
+#define DEBUG_TYPE "file-system"
+
+ALWAYS_ENABLED_STATISTIC(NumStatusCalls, "Number of `status` calls.");
+
 namespace {
   using llvm::StringRef;
   using llvm::sys::path::is_separator;
Index: llvm/lib/Support/MemoryBuffer.cpp
===
--- llvm/lib/Support/MemoryBuffer.cpp
+++ llvm/lib/Support/MemoryBuffer.cpp
@@ -12,6 +12,7 @@
 
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/Config/config.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Errno.h"
@@ -34,6 +35,12 @@
 #endif
 using namespace llvm;
 
+#define DEBUG_TYPE "memory-buffer"
+
+ALWAYS_ENABLED_STATISTIC(NumMmapFile, "Number of mmap-ed files.");
+ALWAYS_ENABLED_STATISTIC(NumAllocFile,
+ "Number of files read into allocated memory buffer.");
+
 //===--===//
 // MemoryBuffer implementation itself.
 //===--===//
@@ -449,8 +456,10 @@
   // buffer by copying off the stream.
   sys::fs::file_type Type = Status.type();
   if (Type != sys::fs::file_type::regular_file &&
-  Type != sys::fs::file_type::block_file)
+  Type != sys::fs::file_type::block_file) {
+++NumAllocFile;
 return getMemoryBufferForStream(FD, Filename);
+  }
 
   FileSize = Status.getSize();
 }
@@ -463,8 +472,10 @@
 std::unique_ptr Result(
 new (NamedBufferAlloc(Filename)) MemoryBufferMMapFile(
 RequiresNullTerminator, FD, MapSize, Offset, EC));
-if (!EC)
+if (!EC) {
+  ++NumMmapFile;
   return std::move(Result);
+}
   }
 
   auto Buf = WritableMemoryBuffer::getNewUninitMemBuffer(MapSize, Filename);
@@ -475,6 +486,7 @@
   }
 
   // Read until EOF, zero-initialize the rest.
+  ++NumAllocFile;
   MutableArrayRef ToRead = Buf->getBuffer();
   while (!ToRead.empty()) {
 Expected ReadBytes =
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -100,6 +100,7 @@
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
@@ -142,6 +143,15 @@
 using llvm::BitstreamCursor;
 using llvm::RoundingMode;
 
+#def

[PATCH] D88236: [PR47636] Fix tryEmitPrivate to handle non-constantarraytypes

2020-09-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:2148
+CommonElementType == nullptr && !NumInitElts) {
   const ArrayType *AT = CGM.getContext().getAsArrayType(DestType);
   CommonElementType = CGM.getTypes().ConvertType(AT->getElementType());

rjmccall wrote:
> `AT` is now just `ArrayTy`, and I think you can just check `!Filler && 
> !NumInitElts`.
`Filler` is null if and only if `NumElements == NumInitElts`, and `NumInitElts 
<= NumElements`, so this condition reduces to `if (!NumElements)`. 
`EmitArrayConstant` responds to that case by creating a `ConstantAggregateZero` 
of its destination type. So it seems to me that we probably don't need this 
special case at all.


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

https://reviews.llvm.org/D88236

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


[clang] c4bacc3 - [Modules] Add stats to measure performance of building and loading modules.

2020-09-24 Thread Volodymyr Sapsai via cfe-commits

Author: Volodymyr Sapsai
Date: 2020-09-24T12:23:47-07:00
New Revision: c4bacc3c9b333bb7032fb96f41d6f5b851623132

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

LOG: [Modules] Add stats to measure performance of building and loading modules.

Measure amount of high-level or fixed-cost operations performed during
building/loading modules and during header search. High-level operations
like building a module or processing a .pcm file are motivated by
previous issues where clang was re-building modules or re-reading .pcm
files unnecessarily. Fixed-cost operations like `stat` calls are tracked
because clang cannot change how long each operation takes but it can
perform fewer of such operations to improve the compile time.

Also tracking such stats over time can help us detect compile-time
regressions. Added stats are more stable than the actual measured
compilation time, so expect the detected regressions to be less noisy.

rdar://problem/55715134

Reviewed By: aprantl, bruno

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Serialization/ASTReader.cpp
llvm/lib/Support/MemoryBuffer.cpp
llvm/lib/Support/Path.cpp
llvm/lib/Support/Unix/Path.inc
llvm/lib/Support/Windows/Path.inc

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 4613ed8d7f61..445049324780 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -55,6 +55,10 @@
 
 using namespace clang;
 
+#define DEBUG_TYPE "modules"
+
+ALWAYS_ENABLED_STATISTIC(NumCompiledModules, "Number of compiled modules.");
+
 CompilerInstance::CompilerInstance(
 std::shared_ptr PCHContainerOps,
 InMemoryModuleCache *SharedModuleCache)
@@ -1063,6 +1067,7 @@ compileModuleImpl(CompilerInstance &ImportingInstance, 
SourceLocation ImportLoc,
   llvm::function_ref PostBuildStep =
   [](CompilerInstance &) {}) {
   llvm::TimeTraceScope TimeScope("Module Compile", ModuleName);
+  ++NumCompiledModules;
 
   // Construct a compiler invocation for creating this module.
   auto Invocation =

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index b2780db85166..e71d73310d52 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -100,6 +100,7 @@
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
@@ -142,6 +143,15 @@ using namespace clang::serialization::reader;
 using llvm::BitstreamCursor;
 using llvm::RoundingMode;
 
+#define DEBUG_TYPE "modules"
+
+ALWAYS_ENABLED_STATISTIC(NumTryLoadModule, "Number of times tried to load a "
+   "module. Includes failed attempts "
+   "and using cached results.");
+ALWAYS_ENABLED_STATISTIC(NumReadASTCore,
+ "Number of ReadASTCore() invocations. Includes only "
+ "actual AST core parsing and ignores cached 
results.");
+
 
//===--===//
 // ChainedASTReaderListener implementation
 
//===--===//
@@ -4203,6 +4213,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef 
FileName,
 SourceLocation ImportLoc,
 unsigned ClientLoadCapabilities,
 SmallVectorImpl 
*Imported) {
+  ++NumTryLoadModule;
   llvm::SaveAndRestore
 SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
 
@@ -4552,6 +4563,7 @@ ASTReader::ReadASTCore(StringRef FileName,
 return Failure;
   }
 
+  ++NumReadASTCore;
   // This is used for compatibility with older PCH formats.
   bool HaveReadControlBlock = false;
   while (true) {

diff  --git a/llvm/lib/Support/MemoryBuffer.cpp 
b/llvm/lib/Support/MemoryBuffer.cpp
index 248fb72c4968..4b851a20fc48 100644
--- a/llvm/lib/Support/MemoryBuffer.cpp
+++ b/llvm/lib/Support/MemoryBuffer.cpp
@@ -12,6 +12,7 @@
 
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/Config/config.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Errno.h"
@@ -34,6 +35,12 @@
 #endif
 using namespace llvm;
 
+#define DEBUG_TYPE "memory-buffer"
+
+ALWAYS_ENABLED_STATISTIC(NumMmapFile, "Number of mmap-ed files.");
+ALWAYS_ENABLED_STATISTIC(NumAllocFile,
+

[PATCH] D77229: [Analyzer] Avoid handling of LazyCompundVals in IteratorModeling

2020-09-24 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/Iterator.cpp:330-336
+SVal getReturnIterator(const CallEvent &Call) {
+  Optional RetValUnderConstr = Call.getReturnValueUnderConstruction();
+  if (RetValUnderConstr.hasValue())
+return *RetValUnderConstr;
+
+  return Call.getReturnValue();
+}

baloghadamsoftware wrote:
> baloghadamsoftware wrote:
> > NoQ wrote:
> > > baloghadamsoftware wrote:
> > > > baloghadamsoftware wrote:
> > > > > NoQ wrote:
> > > > > > baloghadamsoftware wrote:
> > > > > > > NoQ wrote:
> > > > > > > > NoQ wrote:
> > > > > > > > > NoQ wrote:
> > > > > > > > > > I still believe you have not addressed the problem while 
> > > > > > > > > > moving the functions from D81718 to this patch. The caller 
> > > > > > > > > > of this function has no way of knowing whether the return 
> > > > > > > > > > value is the prvalue of the iterator or the glvalue of the 
> > > > > > > > > > iterator.
> > > > > > > > > > 
> > > > > > > > > > Looks like most callers are safe because they expect the 
> > > > > > > > > > object of interest to also be already tracked. But it's 
> > > > > > > > > > quite possible that both are tracked, say:
> > > > > > > > > > 
> > > > > > > > > > ```lang=c++
> > > > > > > > > >   Container1 container1 = ...;
> > > > > > > > > >   Container2 container2 = { 
> > > > > > > > > > container1.begin() };
> > > > > > > > > >   container2.begin(); // ???
> > > > > > > > > > ```
> > > > > > > > > > 
> > > > > > > > > > Suppose `Container1::iterator` is implemented as an object 
> > > > > > > > > > and `Container2::iterator` is implemented as a pointer. In 
> > > > > > > > > > this case `getIteratorPosition(getReturnIterator())` would 
> > > > > > > > > > yield the position of `container1.begin()` whereas the 
> > > > > > > > > > correct answer is the position of `container2.begin()`.
> > > > > > > > > > 
> > > > > > > > > > This problem may seem artificial but it is trivial to avoid 
> > > > > > > > > > if you simply stop defending your convoluted solution of 
> > > > > > > > > > looking at value classes instead of AST types.
> > > > > > > > > Ugh, the problem is much worse. D82185 is entirely broken for 
> > > > > > > > > the exact reason i described above and you only didn't notice 
> > > > > > > > > it because you wrote almost no tests.
> > > > > > > > > 
> > > > > > > > > Consider the test you've added in D82185:
> > > > > > > > > 
> > > > > > > > > ```lang=c++
> > > > > > > > > void begin_ptr_iterator(const cont_with_ptr_iterator &c) 
> > > > > > > > > {
> > > > > > > > >   auto i = c.begin();
> > > > > > > > > 
> > > > > > > > >   clang_analyzer_eval(clang_analyzer_iterator_container(i) == 
> > > > > > > > > &c); // expected-warning{{TRUE}}
> > > > > > > > > }
> > > > > > > > > ```
> > > > > > > > > 
> > > > > > > > > It breaks very easily if you modify it slightly:
> > > > > > > > > ```lang=c++
> > > > > > > > > void begin_ptr_iterator(const cont_with_ptr_iterator &c) 
> > > > > > > > > {
> > > > > > > > >   auto i = c.begin();
> > > > > > > > >   ++i; // <==
> > > > > > > > > 
> > > > > > > > >   clang_analyzer_eval(clang_analyzer_iterator_container(i) == 
> > > > > > > > > &c); // Says FALSE!
> > > > > > > > > }
> > > > > > > > > ```
> > > > > > > > > The iterator obviously still points to the same container, so 
> > > > > > > > > why does the test fail? Because you're tracking the wrong 
> > > > > > > > > iterator: you treated your `&SymRegion{conj_$3}` as a glvalue 
> > > > > > > > > whereas you should have treated it as a prvalue. In other 
> > > > > > > > > words, your checker thinks that `&SymRegion{conj_$3}` is the 
> > > > > > > > > location of an iterator object rather than the iterator 
> > > > > > > > > itself, and after you increment the pointer it thinks that 
> > > > > > > > > it's a completely unrelated iterator.
> > > > > > > > > 
> > > > > > > > > There's a separate concern about why does it say `FALSE` 
> > > > > > > > > (should be `UNKNOWN`) but you get the point.
> > > > > > > > The better way to test D82185 would be to make all existing 
> > > > > > > > tests with iterator objects pass with iterator pointers as 
> > > > > > > > well. Like, make existing container mocks use either iterator 
> > > > > > > > objects or iterator pointers depending on a macro and make two 
> > > > > > > > run-lines in each test file, one with `-D` and one without it. 
> > > > > > > > Most of the old tests should have worked out of the box if you 
> > > > > > > > did it right; the few that don't pass would be hidden under 
> > > > > > > > #ifdef for future investigation.
> > > > > > > Thank you for your review and especially for this tip! It is 
> > > > > > > really a good idea. I changed it now and it indeed shows the 
> > > > > > > problem you reported. It seems that my checker mixes up the 
> > > > > > > region of the pointer-typed variable (`&i` and `&j`) with the 
> > > > > > > region they point t

[PATCH] D88236: [PR47636] Fix tryEmitPrivate to handle non-constantarraytypes

2020-09-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Yeah, that would also be a completely reasonable approach.  We already preserve 
the source spelling of the incomplete array type in the appropriate expression.


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

https://reviews.llvm.org/D88236

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


[PATCH] D88250: [CUDA] Added dim3/uint3 conversion functions to builtin vars.

2020-09-24 Thread Artem Belevich via Phabricator via cfe-commits
tra marked an inline comment as done.
tra added a comment.

In D88250#2293346 , @tra wrote:

> In D88250#2293270 , @jlebar wrote:
>
>> I know it comes in a separate change, but can we add a check to the 
>> test-suite?
>
> Will do.

https://reviews.llvm.org/D88255


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88250

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


[PATCH] D88236: [PR47636] Fix tryEmitPrivate to handle non-constantarraytypes

2020-09-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/test/CodeGenCXX/pr47636.cpp:2
+// RUN: %clang_cc1 -o - -emit-llvm -triple x86_64-linux-pc %s | FileCheck %s
+int(&&intu_rvref)[] {1,2,3,4};
+// CHECK: @_ZGR10intu_rvref_ = internal global [4 x i32] [i32 1, i32 2, i32 3, 
i32 4]

The AST we generate for this is:

```
`-VarDecl 0x106e7630 <:1:1, col:29> col:7 intu_rvref 'int (&&)[4]' 
listinit
  `-ExprWithCleanups 0x106e7908  'int []':'int []' xvalue
`-MaterializeTemporaryExpr 0x106e78a8  'int []':'int []' 
xvalue extended by Var 0x106e7630 'intu_rvref' 'int (&&)[4]'
  `-InitListExpr 0x106e77c0  'int [4]'
|-IntegerLiteral 0x106e76e0  'int' 1
|-IntegerLiteral 0x106e7700  'int' 2
|-IntegerLiteral 0x106e7720  'int' 3
`-IntegerLiteral 0x106e7740  'int' 4
```

... which looks surprising to me -- `MaterializeTemporaryExpr` corresponds to 
allocating storage for an object of type `T`, so `T` being incomplete is at 
least surprising, and it would seem more consistent to complete the type of the 
MTE in the same way we would complete the type of a corresponding `VarDecl`.

We also crash while processing

```
constexpr int f() { int (&&intu_rvref)[] {1,2,3,4}; return intu_rvref[0]; }
```

... due to the same unexpected AST representation.

I don't know if we would need this `CodeGen` change in other cases; it seems 
like if we ever supported constant initialization of a class with a flexible 
array member, we'd want to do something like this. For now at least, we refuse 
to constant-evaluate things such as `struct A { int n; int arr[]; } a = {1, 2, 
3};` to an `APValue` and use the lowering-from-`Expr` path in `CGExprConstant` 
for such cases instead. So I suspect if we change the AST representation to use 
a complete type here, the code change here will be unreachable at least in the 
short term.

On the other hand, if we did choose to support constant initialization of 
flexible array members, it might be natural to treat objects of incomplete 
array type analogously to flexible array members, giving them an incomplete 
type whose size is determined from its initializer, and with that viewpoint the 
AST representation we're currently using wouldn't really be wrong. But I'm 
inclined to think that `MaterializeTemporaryExpr` should mirror the behavior of 
a `VarDecl`: the array bound should be filled in in the AST representation 
based on the initializer.


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

https://reviews.llvm.org/D88236

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


[PATCH] D88236: [PR47636] Fix tryEmitPrivate to handle non-constantarraytypes

2020-09-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane closed this revision.
erichkeane added a comment.

Gah, forgot 'Differential Revision' again :/


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

https://reviews.llvm.org/D88236

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


[PATCH] D70378: [LLD][COFF] Cover usage of LLD as a library

2020-09-24 Thread Alexandre Ganea 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 rGf2efb5742cc9: [LLD][COFF] Cover usage of LLD-as-a-library in 
tests (authored by aganea).

Changed prior to commit:
  https://reviews.llvm.org/D70378?vs=287952&id=294129#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70378

Files:
  lld/COFF/Driver.cpp
  lld/COFF/Writer.cpp
  lld/COFF/Writer.h
  lld/Common/ErrorHandler.cpp
  lld/ELF/Driver.cpp
  lld/MachO/Driver.cpp
  lld/include/lld/Common/Driver.h
  lld/include/lld/Common/ErrorHandler.h
  lld/lib/Driver/DarwinLdDriver.cpp
  lld/test/COFF/lit.local.cfg
  lld/tools/lld/lld.cpp
  lld/wasm/Driver.cpp

Index: lld/wasm/Driver.cpp
===
--- lld/wasm/Driver.cpp
+++ lld/wasm/Driver.cpp
@@ -85,6 +85,8 @@
   lld::stdoutOS = &stdoutOS;
   lld::stderrOS = &stderrOS;
 
+  errorHandler().cleanupCallback = []() { freeArena(); };
+
   errorHandler().logName = args::getFilenameWithoutExe(args[0]);
   errorHandler().errorLimitExceededMsg =
   "too many errors emitted, stopping now (use "
@@ -103,7 +105,6 @@
   if (canExitEarly)
 exitLld(errorCount() ? 1 : 0);
 
-  freeArena();
   return !errorCount();
 }
 
@@ -776,6 +777,7 @@
   v.push_back("wasm-ld (LLVM option parsing)");
   for (auto *arg : args.filtered(OPT_mllvm))
 v.push_back(arg->getValue());
+  cl::ResetAllOptionOccurrences();
   cl::ParseCommandLineOptions(v.size(), v.data());
 
   errorHandler().errorLimit = args::getInteger(args, OPT_error_limit, 20);
Index: lld/tools/lld/lld.cpp
===
--- lld/tools/lld/lld.cpp
+++ lld/tools/lld/lld.cpp
@@ -26,6 +26,7 @@
 //===--===//
 
 #include "lld/Common/Driver.h"
+#include "lld/Common/ErrorHandler.h"
 #include "lld/Common/Memory.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
@@ -33,12 +34,19 @@
 #include "llvm/ADT/Triple.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PluginLoader.h"
+#include "llvm/Support/Signals.h"
 #include 
 
+#if !defined(_MSC_VER) && !defined(__MINGW32__)
+#include  // for raise
+#include  // for _exit
+#endif
+
 using namespace lld;
 using namespace llvm;
 using namespace llvm::sys;
@@ -133,36 +141,103 @@
   return parseProgname(arg0);
 }
 
-// If this function returns true, lld calls _exit() so that it quickly
-// exits without invoking destructors of globally allocated objects.
-//
-// We don't want to do that if we are running tests though, because
-// doing that breaks leak sanitizer. So, lit sets this environment variable,
-// and we use it to detect whether we are running tests or not.
-static bool canExitEarly() { return StringRef(getenv("LLD_IN_TEST")) != "1"; }
-
 /// Universal linker main(). This linker emulates the gnu, darwin, or
 /// windows linker based on the argv[0] or -flavor option.
-int main(int argc, const char **argv) {
-  InitLLVM x(argc, argv);
-
+static int lldMain(int argc, const char **argv, llvm::raw_ostream &stdoutOS,
+   llvm::raw_ostream &stderrOS, bool exitEarly = true) {
   std::vector args(argv, argv + argc);
   switch (parseFlavor(args)) {
   case Gnu:
 if (isPETarget(args))
-  return !mingw::link(args, canExitEarly(), llvm::outs(), llvm::errs());
-return !elf::link(args, canExitEarly(), llvm::outs(), llvm::errs());
+  return !mingw::link(args, exitEarly, stdoutOS, stderrOS);
+return !elf::link(args, exitEarly, stdoutOS, stderrOS);
   case WinLink:
-return !coff::link(args, canExitEarly(), llvm::outs(), llvm::errs());
+return !coff::link(args, exitEarly, stdoutOS, stderrOS);
   case Darwin:
-return !mach_o::link(args, canExitEarly(), llvm::outs(), llvm::errs());
+return !mach_o::link(args, exitEarly, stdoutOS, stderrOS);
   case DarwinNew:
-return !macho::link(args, canExitEarly(), llvm::outs(), llvm::errs());
+return !macho::link(args, exitEarly, stdoutOS, stderrOS);
   case Wasm:
-return !wasm::link(args, canExitEarly(), llvm::outs(), llvm::errs());
+return !lld::wasm::link(args, exitEarly, stdoutOS, stderrOS);
   default:
 die("lld is a generic driver.\n"
 "Invoke ld.lld (Unix), ld64.lld (macOS), lld-link (Windows), wasm-ld"
 " (WebAssembly) instead");
   }
 }
+
+// Similar to lldMain except that exceptions are caught.
+SafeReturn lld::safeLldMain(int argc, const char **argv,
+llvm::raw_ostream &stdoutOS,
+llvm::raw_ostream &stderrOS) {
+  int r = 0;
+  {
+// The crash recovery is here only to be able to recover from ar

[clang] 606a734 - [PR47636] Fix tryEmitPrivate to handle non-constantarraytypes

2020-09-24 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2020-09-24T12:09:22-07:00
New Revision: 606a734755d1fb6c35a17680d0c251f834b79334

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

LOG: [PR47636] Fix tryEmitPrivate to handle non-constantarraytypes

As mentioned in the bug report, tryEmitPrivate chokes on the
MaterializeTemporaryExpr in the reproducers, since it assumes that if
there are elements, than it must be a ConstantArrayType. However, the
MaterializeTemporaryExpr (which matches exactly the AST when it is NOT a
global/static) has an incomplete array type.

This changes the section where the number-of-elements is non-zero to
properly handle non-CAT types by just extracting it as an array type
(since all we needed was the element type out of it).

Added: 
clang/test/CodeGenCXX/pr47636.cpp

Modified: 
clang/lib/CodeGen/CGExprConstant.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprConstant.cpp 
b/clang/lib/CodeGen/CGExprConstant.cpp
index c6b2930faece..5b3631087f45 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -2108,8 +2108,7 @@ llvm::Constant *ConstantEmitter::tryEmitPrivate(const 
APValue &Value,
   case APValue::Union:
 return ConstStructBuilder::BuildStruct(*this, Value, DestType);
   case APValue::Array: {
-const ConstantArrayType *CAT =
-CGM.getContext().getAsConstantArrayType(DestType);
+const ArrayType *ArrayTy = CGM.getContext().getAsArrayType(DestType);
 unsigned NumElements = Value.getArraySize();
 unsigned NumInitElts = Value.getArrayInitializedElts();
 
@@ -2117,7 +2116,7 @@ llvm::Constant *ConstantEmitter::tryEmitPrivate(const 
APValue &Value,
 llvm::Constant *Filler = nullptr;
 if (Value.hasArrayFiller()) {
   Filler = tryEmitAbstractForMemory(Value.getArrayFiller(),
-CAT->getElementType());
+ArrayTy->getElementType());
   if (!Filler)
 return nullptr;
 }
@@ -2132,7 +2131,7 @@ llvm::Constant *ConstantEmitter::tryEmitPrivate(const 
APValue &Value,
 llvm::Type *CommonElementType = nullptr;
 for (unsigned I = 0; I < NumInitElts; ++I) {
   llvm::Constant *C = tryEmitPrivateForMemory(
-  Value.getArrayInitializedElt(I), CAT->getElementType());
+  Value.getArrayInitializedElt(I), ArrayTy->getElementType());
   if (!C) return nullptr;
 
   if (I == 0)
@@ -2144,11 +2143,10 @@ llvm::Constant *ConstantEmitter::tryEmitPrivate(const 
APValue &Value,
 
 // This means that the array type is probably "IncompleteType" or some
 // type that is not ConstantArray.
-if (CAT == nullptr && CommonElementType == nullptr && !NumInitElts) {
-  const ArrayType *AT = CGM.getContext().getAsArrayType(DestType);
-  CommonElementType = CGM.getTypes().ConvertType(AT->getElementType());
-  llvm::ArrayType *AType = llvm::ArrayType::get(CommonElementType,
-NumElements);
+if (!Filler && !NumInitElts) {
+  CommonElementType = 
CGM.getTypes().ConvertType(ArrayTy->getElementType());
+  llvm::ArrayType *AType =
+  llvm::ArrayType::get(CommonElementType, NumElements);
   return llvm::ConstantAggregateZero::get(AType);
 }
 

diff  --git a/clang/test/CodeGenCXX/pr47636.cpp 
b/clang/test/CodeGenCXX/pr47636.cpp
new file mode 100644
index ..ac64400e1daa
--- /dev/null
+++ b/clang/test/CodeGenCXX/pr47636.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -o - -emit-llvm -triple x86_64-linux-pc %s | FileCheck %s
+int(&&intu_rvref)[] {1,2,3,4};
+// CHECK: @_ZGR10intu_rvref_ = internal global [4 x i32] [i32 1, i32 2, i32 3, 
i32 4]
+// CHECK: @intu_rvref = constant [4 x i32]* @_ZGR10intu_rvref_
+
+void foo() {
+  static const int(&&intu_rvref)[] {1,2,3,4};
+  // CHECK: @_ZZ3foovE10intu_rvref = internal constant [4 x i32]* 
@_ZGRZ3foovE10intu_rvref_
+  // CHECK: @_ZGRZ3foovE10intu_rvref_ = internal constant [4 x i32] [i32 1, 
i32 2, i32 3, i32 4]
+}



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


[PATCH] D88236: [PR47636] Fix tryEmitPrivate to handle non-constantarraytypes

2020-09-24 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


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

https://reviews.llvm.org/D88236

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


[PATCH] D75574: RFC: Implement objc_direct_protocol attribute to remove protocol metadata

2020-09-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Okay, the result of internal review is that we're comfortable with this feature.

Reviewers brought up the point that it would be interesting to add some way to 
ensure unique emission of a protocol, so that protocols that can't be 
non-runtime could avoid bloating binary sizes outside the defining module.  
Maybe this could be deployment-gated so that builds targeting iOS 21 can take 
advantage of NSMoveOnlyType being exported but builds targeting iOS 20 still 
have to emit their own copy.  But that's a separable improvement and doesn't 
need to block this work.




Comment at: clang/include/clang/Basic/AttrDocs.td:4505
+intend to use protocols to implement compile time behaviors then the metadata 
is
+uneeded overhead.
+  }];

Suggestion:

  The ``objc_non_runtime_protocol`` attribute can be used to mark that an
  Objective-C protocol is only used during static type-checking and doesn't
  need to be represented dynamically.  This avoids several small code-size
  and run-time overheads associated with handling the protocol's metadata.
  A non-runtime protocol cannot be used as the operand of a ``@protocol``
  expression, and dynamic attempts to find it with ``objc_getProtocol`` will 
fail.

  If a non-runtime protocol inherits from any ordinary protocols, classes and
  derived protocols that declare conformance to the non-runtime protocol
  will dynamically list their conformance to those base protocols.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:1062
+  "non_runtime_protocol attribute on protocol %0 ignored (not implemented by 
this Objective-C runtime)">,
+  InGroup;
 def err_objc_direct_dynamic_property : Error<

This is dead now.



Comment at: clang/lib/CodeGen/CGObjC.cpp:466
+  for (; begin != end; ++begin)
+AppendFirstRuntimeProtocols(*begin, PDs);
+

Should this make an effort to avoid declaring redundant bases?  e.g.

```
@protocol Base @end
@protocol NonRuntime @end
@protocol Runtime @end
@interface MyClass  @end
@implementation MyClass @end
```

Ideally `MyClass` only declares conformance to `Runtime` rather than 
redundantly declaring conformance to `Base`, which I think you'd naturally get 
from this algorithm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75574

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


[PATCH] D88250: [CUDA] Added dim3/uint3 conversion functions to builtin vars.

2020-09-24 Thread Artem Belevich via Phabricator via cfe-commits
tra marked an inline comment as done.
tra added a comment.

In D88250#2293270 , @jlebar wrote:

> I know it comes in a separate change, but can we add a check to the 
> test-suite?

Will do.




Comment at: clang/lib/Headers/__clang_cuda_runtime_wrapper.h:381
+__device__ inline __cuda_builtin_threadIdx_t::operator dim3() const {
+  return {x, y, z};
+}

jlebar wrote:
> This is a C++11-ism (right?).  Do we support compiling without C++11?
Fixed. 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88250

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


[PATCH] D87451: add new clang option -mno-xcoff-visibility

2020-09-24 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: llvm/include/llvm/Target/TargetMachine.h:265
+  /// corresponding to -mno-xcoff-visibility.
+  bool getNoXCOFFVisibility() const { return Options.NoXCOFFVisibility; }
+

DiggerLin wrote:
> daltenty wrote:
> > This seems like it needs the corresponding comand-line option for llc added 
> > and an llc test.
> I think it will be in another separate  patch.
I would actually prefer to have that in the same patch, as that would give us a 
full picture. It's not a huge patch even if we combine them. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87451

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


[PATCH] D88250: [CUDA] Added dim3/uint3 conversion functions to builtin vars.

2020-09-24 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 294125.
tra edited the summary of this revision.
tra added a comment.

Fixed compatibility with pre-c++11


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88250

Files:
  clang/lib/Headers/__clang_cuda_builtin_vars.h
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h

Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -377,30 +377,38 @@
 // Out-of-line implementations from __clang_cuda_builtin_vars.h.  These need to
 // come after we've pulled in the definition of uint3 and dim3.
 
+__device__ inline __cuda_builtin_threadIdx_t::operator dim3() const {
+  return dim3(x, y, z);
+}
+
 __device__ inline __cuda_builtin_threadIdx_t::operator uint3() const {
-  uint3 ret;
-  ret.x = x;
-  ret.y = y;
-  ret.z = z;
-  return ret;
+  return {x, y, z};
+}
+
+__device__ inline __cuda_builtin_blockIdx_t::operator dim3() const {
+  return dim3(x, y, z);
 }
 
 __device__ inline __cuda_builtin_blockIdx_t::operator uint3() const {
-  uint3 ret;
-  ret.x = x;
-  ret.y = y;
-  ret.z = z;
-  return ret;
+  return {x, y, z};
 }
 
 __device__ inline __cuda_builtin_blockDim_t::operator dim3() const {
   return dim3(x, y, z);
 }
 
+__device__ inline __cuda_builtin_blockDim_t::operator uint3() const {
+  return {x, y, z};
+}
+
 __device__ inline __cuda_builtin_gridDim_t::operator dim3() const {
   return dim3(x, y, z);
 }
 
+__device__ inline __cuda_builtin_gridDim_t::operator uint3() const {
+  return {x, y, z};
+}
+
 #include <__clang_cuda_cmath.h>
 #include <__clang_cuda_intrinsics.h>
 #include <__clang_cuda_complex_builtins.h>
Index: clang/lib/Headers/__clang_cuda_builtin_vars.h
===
--- clang/lib/Headers/__clang_cuda_builtin_vars.h
+++ clang/lib/Headers/__clang_cuda_builtin_vars.h
@@ -55,7 +55,9 @@
   __CUDA_DEVICE_BUILTIN(z,__nvvm_read_ptx_sreg_tid_z());
   // threadIdx should be convertible to uint3 (in fact in nvcc, it *is* a
   // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator dim3() const;
   __attribute__((device)) operator uint3() const;
+
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_threadIdx_t);
 };
@@ -66,7 +68,9 @@
   __CUDA_DEVICE_BUILTIN(z,__nvvm_read_ptx_sreg_ctaid_z());
   // blockIdx should be convertible to uint3 (in fact in nvcc, it *is* a
   // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator dim3() const;
   __attribute__((device)) operator uint3() const;
+
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_blockIdx_t);
 };
@@ -78,6 +82,8 @@
   // blockDim should be convertible to dim3 (in fact in nvcc, it *is* a
   // dim3).  This function is defined after we pull in vector_types.h.
   __attribute__((device)) operator dim3() const;
+  __attribute__((device)) operator uint3() const;
+
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_blockDim_t);
 };
@@ -89,6 +95,8 @@
   // gridDim should be convertible to dim3 (in fact in nvcc, it *is* a
   // dim3).  This function is defined after we pull in vector_types.h.
   __attribute__((device)) operator dim3() const;
+  __attribute__((device)) operator uint3() const;
+
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_gridDim_t);
 };
@@ -108,5 +116,6 @@
 #undef __CUDA_DEVICE_BUILTIN
 #undef __CUDA_BUILTIN_VAR
 #undef __CUDA_DISALLOW_BUILTINVAR_ACCESS
+#undef __DELETE
 
 #endif /* __CUDA_BUILTIN_VARS_H */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d34c8c7 - Basic: add an extra newline for sphinx (NFC)

2020-09-24 Thread Saleem Abdulrasool via cfe-commits

Author: Saleem Abdulrasool
Date: 2020-09-24T18:51:10Z
New Revision: d34c8c70aae2a5421337c2ccac91130c70511f94

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

LOG: Basic: add an extra newline for sphinx (NFC)

This should resolve the "Bullet list ends without a blank line" warning.

Added: 


Modified: 
clang/include/clang/Basic/AttrDocs.td

Removed: 




diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 8930b61cced9..a68d37ace089 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -3639,6 +3639,7 @@ typedef.
 * ``swift_newtype(enum)`` means that a Swift enum will be created for this
 ypedef.
 
+
   .. code-block:: c
 
 // Import UIFontTextStyle as an enum type, with enumerated values being



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


[PATCH] D87720: Sema: add support for `__attribute__((__swift_private__))`

2020-09-24 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 294124.
compnerd marked an inline comment as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87720

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaObjC/attr-swift_private.m

Index: clang/test/SemaObjC/attr-swift_private.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-swift_private.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc %s
+
+__attribute__((__swift_private__))
+@protocol P
+@end
+
+__attribute__((__swift_private__))
+@interface I
+@end
+
+@interface J
+@property id property __attribute__((__swift_private__));
+- (void)instanceMethod __attribute__((__swift_private__));
++ (void)classMethod __attribute__((__swift_private__));
+@end
+
+void f(void) __attribute__((__swift_private__));
+
+struct __attribute__((__swift_private__)) S {};
+
+enum __attribute__((__swift_private__)) E {
+  one,
+  two,
+};
+
+typedef struct { } T __attribute__((__swift_private__));
+
+void g(void) __attribute__((__swift_private__("private")));
+// expected-error@-1 {{'__swift_private__' attribute takes no arguments}}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -7904,6 +7904,9 @@
   case ParsedAttr::AT_SwiftObjCMembers:
 handleSimpleAttribute(S, D, AL);
 break;
+  case ParsedAttr::AT_SwiftPrivate:
+handleSimpleAttribute(S, D, AL);
+break;
 
   // XRay attributes.
   case ParsedAttr::AT_XRayLogArgs:
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2595,6 +2595,8 @@
   else if (const auto *SNA = dyn_cast(Attr))
 NewAttr = S.mergeSwiftNameAttr(D, *SNA, SNA->getName(),
AMK == Sema::AMK_Override);
+  else if (isa(Attr) && AMK == Sema::AMK_Override)
+NewAttr = nullptr;
   else if (const auto *OA = dyn_cast(Attr))
 NewAttr = S.mergeOptimizeNoneAttr(D, *OA);
   else if (const auto *InternalLinkageA = dyn_cast(Attr))
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -3652,6 +3652,19 @@
   }];
 }
 
+def SwiftPrivateDocs : Documentation {
+  let Category = SwiftDocs;
+  let Heading = "swift_private";
+  let Content = [{
+Declarations marked with the ``swift_private`` attribute are hidden from the
+framework client but are still made available for use within the framework or
+Swift SDK overlay.
+
+The purpose of this attribute is to permit a more idomatic implementation of
+declarations in Swift while hiding the non-idiomatic one.
+  }];
+}
+
 def OMPDeclareSimdDocs : Documentation {
   let Category = DocCatFunction;
   let Heading = "#pragma omp declare simd";
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -2177,6 +2177,11 @@
   let HasCustomParsing = 1;
 }
 
+def SwiftPrivate : InheritableAttr {
+  let Spellings = [GNU<"swift_private">];
+  let Documentation = [SwiftPrivateDocs];
+}
+
 def NoDeref : TypeAttr {
   let Spellings = [Clang<"noderef">];
   let Documentation = [NoDerefDocs];
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >