[PATCH] D148439: [clang-rename] Exit gracefully when no input provided

2023-04-25 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

Ping for reivew.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148439

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


[PATCH] D148457: [clangd] Support macro evaluation on hover

2023-04-25 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Thanks for the patch and the thorough testcase!

I wonder if we should make this a bit more strict: if the macro expansion 
itself is an expression, show the value of //that// expression, but not e.g. an 
enclosing expression. Otherwise, the `Definition` field of the hover (which 
shows the tokens of the macro expansion) and the `Value` and `Type` fields 
(which show the value and type of a larger expression) could be out of sync and 
confusing.

A (somewhat contrived) example would be:

  #define PLUS_TWO + 2
  int x = 40 PLUS_TW^O;  // huh, the value of "+ 2" is "42"?

Of your existing testcases, I think the only one this stricter rule would break 
is #6 (`define_lambda_begin`), and I think that's fine.




Comment at: clang-tools-extra/clangd/Hover.cpp:728
   }
+  SelectionTree::createEach(
+  AST.getASTContext(), AST.getTokens(), SM.getFileOffset(Tok.location()),

Why `createEach()` when the [non-macro 
case](https://searchfox.org/llvm/rev/be9c91843bab5bb46574c27836bfcd9ad6fc9ef5/clang-tools-extra/clangd/Hover.cpp#1270)
 uses `createRight()`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148457

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


[PATCH] D148987: [clang][Interp] Check Neg ops for errors

2023-04-25 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 517054.

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

https://reviews.llvm.org/D148987

Files:
  clang/lib/AST/Interp/Integral.h
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/PrimType.h
  clang/test/AST/Interp/literals.cpp


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -80,6 +80,12 @@
 static_assert(~INT_MIN == INT_MAX, "");
 static_assert(~INT_MAX == INT_MIN, "");
 
+static_assert(-(1 << 31), ""); // expected-error {{not an integral constant 
expression}} \
+   // expected-note {{outside the range of 
representable values}} \
+   // ref-error {{not an integral constant 
expression}} \
+   // ref-note {{outside the range of 
representable values}} \
+
+
 enum E {};
 constexpr E e = static_cast(0);
 static_assert(~e == -1, "");
Index: clang/lib/AST/Interp/PrimType.h
===
--- clang/lib/AST/Interp/PrimType.h
+++ clang/lib/AST/Interp/PrimType.h
@@ -42,6 +42,8 @@
   PT_FnPtr,
 };
 
+constexpr bool isIntegralType(PrimType T) { return T <= PT_Uint64; }
+
 /// Mapping from primitive types to their representation.
 template  struct PrimConv;
 template <> struct PrimConv { using T = Integral<8, true>; };
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -425,12 +425,31 @@
 
 template ::T>
 bool Neg(InterpState , CodePtr OpPC) {
-  const T  = S.Stk.pop();
+  const T  = S.Stk.pop();
   T Result;
-  T::neg(Val, );
 
+  if (!T::neg(Value, )) {
+S.Stk.push(Result);
+return true;
+  }
+
+  assert(isIntegralType(Name));
   S.Stk.push(Result);
-  return true;
+
+  APSInt NegatedValue = -Value.toAPSInt(Value.bitWidth() + 1);
+  const Expr *E = S.Current->getExpr(OpPC);
+  QualType Type = E->getType();
+
+  if (S.checkingForUndefinedBehavior()) {
+SmallString<32> Trunc;
+NegatedValue.trunc(Result.bitWidth()).toString(Trunc, 10);
+auto Loc = E->getExprLoc();
+S.report(Loc, diag::warn_integer_constant_overflow) << Trunc << Type;
+return true;
+  }
+
+  S.CCEDiag(E, diag::note_constexpr_overflow) << NegatedValue << Type;
+  return S.noteUndefinedBehavior();
 }
 
 enum class PushVal : bool {
Index: clang/lib/AST/Interp/Integral.h
===
--- clang/lib/AST/Interp/Integral.h
+++ clang/lib/AST/Interp/Integral.h
@@ -234,6 +234,9 @@
   }
 
   static bool neg(Integral A, Integral *R) {
+if (Signed && A.isMin())
+  return true;
+
 *R = -A;
 return false;
   }


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -80,6 +80,12 @@
 static_assert(~INT_MIN == INT_MAX, "");
 static_assert(~INT_MAX == INT_MIN, "");
 
+static_assert(-(1 << 31), ""); // expected-error {{not an integral constant expression}} \
+   // expected-note {{outside the range of representable values}} \
+   // ref-error {{not an integral constant expression}} \
+   // ref-note {{outside the range of representable values}} \
+
+
 enum E {};
 constexpr E e = static_cast(0);
 static_assert(~e == -1, "");
Index: clang/lib/AST/Interp/PrimType.h
===
--- clang/lib/AST/Interp/PrimType.h
+++ clang/lib/AST/Interp/PrimType.h
@@ -42,6 +42,8 @@
   PT_FnPtr,
 };
 
+constexpr bool isIntegralType(PrimType T) { return T <= PT_Uint64; }
+
 /// Mapping from primitive types to their representation.
 template  struct PrimConv;
 template <> struct PrimConv { using T = Integral<8, true>; };
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -425,12 +425,31 @@
 
 template ::T>
 bool Neg(InterpState , CodePtr OpPC) {
-  const T  = S.Stk.pop();
+  const T  = S.Stk.pop();
   T Result;
-  T::neg(Val, );
 
+  if (!T::neg(Value, )) {
+S.Stk.push(Result);
+return true;
+  }
+
+  assert(isIntegralType(Name));
   S.Stk.push(Result);
-  return true;
+
+  APSInt NegatedValue = -Value.toAPSInt(Value.bitWidth() + 1);
+  const Expr *E = S.Current->getExpr(OpPC);
+  QualType Type = E->getType();
+
+  if (S.checkingForUndefinedBehavior()) {
+SmallString<32> Trunc;
+NegatedValue.trunc(Result.bitWidth()).toString(Trunc, 10);
+auto Loc = E->getExprLoc();
+S.report(Loc, diag::warn_integer_constant_overflow) << Trunc << Type;
+return true;
+  }
+
+  S.CCEDiag(E, diag::note_constexpr_overflow) << 

[PATCH] D149154: [clang][Interp] Emit diagnostic when comparing function pointers

2023-04-25 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/Interp.h:652-653
+  const SourceInfo  = S.Current->getSource(OpPC);
+  S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_unspecified)
+  << LS << RS;
+  return false;

aaron.ballman wrote:
> tbaeder wrote:
> > aaron.ballman wrote:
> > > Can we pass in the result of `getType()` instead of doing this string 
> > > conversion dance?
> > Well the diagnostic doesn't print the result of the LHS/RHS:
> > ```
> > ./array.cpp:202:18: error: constexpr variable 'u13' must be initialized by 
> > a constant expression
> >   202 |   constexpr bool u13 = pf < pg; // ref-warning {{ordered comparison 
> > of function pointers}}
> >   |  ^ ~~~
> > ./array.cpp:202:27: note: comparison between '' and '' has unspecified 
> > value
> >   202 |   constexpr bool u13 = pf < pg; // ref-warning {{ordered comparison 
> > of function pointers}}
> >   |   ^
> > ```
> > 
> > I'm not exactly a fan of how the code looks though. I might add a helper 
> > function for this later.
> Ah of course, good point. And yeah, a helper function for this would probably 
> not be a bad idea.
Do you like the `toDiagnosticString()` from https://reviews.llvm.org/D149172 
better?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149154

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


[PATCH] D147610: [RISCV][MC] Add support for experimental Zfbfmin extension

2023-04-25 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D147610#4297533 , @joshua-arch1 
wrote:

>> The RVI toolchain SIG is supposed to be setting up a task group to define 
>> intrinsics for all extensions.
>
> Where should I discuss this intrinsic issue right now?

I guess https://github.com/riscv-non-isa/riscv-c-api-doc


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

https://reviews.llvm.org/D147610

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


[PATCH] D149215: [MemProf] Control availability of hot/cold operator new from LTO link

2023-04-25 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson updated this revision to Diff 517044.
tejohnson added a comment.

Remove extraneous call


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149215

Files:
  clang/test/CodeGen/thinlto-distributed-supports-hot-cold-new.ll
  llvm/include/llvm/IR/ModuleSummaryIndex.h
  llvm/include/llvm/LTO/LTO.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/IR/ModuleSummaryIndex.cpp
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
  llvm/test/LTO/X86/memprof-supports-hot-cold-new.ll
  llvm/test/ThinLTO/X86/memprof-basic.ll
  llvm/test/ThinLTO/X86/memprof-duplicate-context-ids.ll
  llvm/test/ThinLTO/X86/memprof-duplicate-context-ids2.ll
  llvm/test/ThinLTO/X86/memprof-funcassigncloning.ll
  llvm/test/ThinLTO/X86/memprof-indirectcall.ll
  llvm/test/ThinLTO/X86/memprof-inlined.ll
  llvm/test/ThinLTO/X86/memprof-inlined2.ll
  llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll
  llvm/test/Transforms/MemProfContextDisambiguation/basic.ll
  llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids.ll
  llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids2.ll
  llvm/test/Transforms/MemProfContextDisambiguation/funcassigncloning.ll
  llvm/test/Transforms/MemProfContextDisambiguation/indirectcall.ll
  llvm/test/Transforms/MemProfContextDisambiguation/inlined.ll
  llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll

Index: llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll
@@ -42,7 +42,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:	-memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; RUN:	%s -S 2>&1 | FileCheck %s --check-prefix=DUMP
 
Index: llvm/test/Transforms/MemProfContextDisambiguation/inlined.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/inlined.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/inlined.ll
@@ -41,7 +41,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:	-memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; RUN:	-memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \
 ; RUN:  -stats -pass-remarks=memprof-context-disambiguation \
Index: llvm/test/Transforms/MemProfContextDisambiguation/indirectcall.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/indirectcall.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/indirectcall.ll
@@ -51,7 +51,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:  -memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; RUN:  -memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \
 ; RUN:  -stats -pass-remarks=memprof-context-disambiguation \
Index: llvm/test/Transforms/MemProfContextDisambiguation/funcassigncloning.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/funcassigncloning.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/funcassigncloning.ll
@@ -45,7 +45,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:  -memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; RUN:  -stats -pass-remarks=memprof-context-disambiguation \
 ; RUN:  %s -S 2>&1 | FileCheck %s --check-prefix=DUMP --check-prefix=IR \
Index: llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids2.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids2.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids2.ll
@@ -93,7 +93,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:  -memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; RUN:  -memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \
 ; RUN:  

[PATCH] D149215: [MemProf] Control availability of hot/cold operator new from LTO link

2023-04-25 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson updated this revision to Diff 517043.
tejohnson added a comment.

Rebase onto latest D149117  to remove 
extraneous test diffs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149215

Files:
  clang/test/CodeGen/thinlto-distributed-supports-hot-cold-new.ll
  llvm/include/llvm/IR/ModuleSummaryIndex.h
  llvm/include/llvm/LTO/LTO.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/IR/ModuleSummaryIndex.cpp
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
  llvm/test/LTO/X86/memprof-supports-hot-cold-new.ll
  llvm/test/ThinLTO/X86/memprof-basic.ll
  llvm/test/ThinLTO/X86/memprof-duplicate-context-ids.ll
  llvm/test/ThinLTO/X86/memprof-duplicate-context-ids2.ll
  llvm/test/ThinLTO/X86/memprof-funcassigncloning.ll
  llvm/test/ThinLTO/X86/memprof-indirectcall.ll
  llvm/test/ThinLTO/X86/memprof-inlined.ll
  llvm/test/ThinLTO/X86/memprof-inlined2.ll
  llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll
  llvm/test/Transforms/MemProfContextDisambiguation/basic.ll
  llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids.ll
  llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids2.ll
  llvm/test/Transforms/MemProfContextDisambiguation/funcassigncloning.ll
  llvm/test/Transforms/MemProfContextDisambiguation/indirectcall.ll
  llvm/test/Transforms/MemProfContextDisambiguation/inlined.ll
  llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll

Index: llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll
@@ -42,7 +42,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:	-memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; RUN:	%s -S 2>&1 | FileCheck %s --check-prefix=DUMP
 
Index: llvm/test/Transforms/MemProfContextDisambiguation/inlined.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/inlined.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/inlined.ll
@@ -41,7 +41,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:	-memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; RUN:	-memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \
 ; RUN:  -stats -pass-remarks=memprof-context-disambiguation \
Index: llvm/test/Transforms/MemProfContextDisambiguation/indirectcall.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/indirectcall.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/indirectcall.ll
@@ -51,7 +51,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:  -memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; RUN:  -memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \
 ; RUN:  -stats -pass-remarks=memprof-context-disambiguation \
Index: llvm/test/Transforms/MemProfContextDisambiguation/funcassigncloning.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/funcassigncloning.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/funcassigncloning.ll
@@ -45,7 +45,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:  -memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; RUN:  -stats -pass-remarks=memprof-context-disambiguation \
 ; RUN:  %s -S 2>&1 | FileCheck %s --check-prefix=DUMP --check-prefix=IR \
Index: llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids2.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids2.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids2.ll
@@ -93,7 +93,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:  -memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; 

[PATCH] D147844: [clang][Sema]Print diagnostic warning about precedence when integer expression is used without parentheses in an conditional operator expression

2023-04-25 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav added a comment.

Added parentheses to lots of files to fix the precedence warning. Still a lot 
to change in OpenMP.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

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


[PATCH] D147844: [clang][Sema]Print diagnostic warning about precedence when integer expression is used without parentheses in an conditional operator expression

2023-04-25 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav updated this revision to Diff 517042.
chaitanyav added a comment.
Herald added subscribers: jplehr, kosarev, jdoerfert, sstefan1, kerbowa, 
jvesely.
Herald added a reviewer: jdoerfert.

Fix tests/code by adding parentheses around the conditional operator expression


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/Interp/constexpr-nqueens.cpp
  clang/test/AST/Interp/literals.cpp
  clang/test/Analysis/copypaste/macro-complexity.cpp
  clang/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
  clang/test/Analysis/malloc-overflow.c
  clang/test/Analysis/misc-ps.m
  clang/test/Analysis/nullability.mm
  clang/test/Analysis/runtime-regression.c
  clang/test/Analysis/uninit-vals.c
  clang/test/Analysis/use-after-move.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/partial-ordering.cpp
  clang/test/Frontend/macros.c
  clang/test/OpenMP/cancel_if_messages.cpp
  clang/test/OpenMP/distribute_collapse_messages.cpp
  clang/test/OpenMP/distribute_dist_schedule_messages.cpp
  clang/test/OpenMP/distribute_firstprivate_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_collapse_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_copyin_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_dist_schedule_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_if_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_private_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_schedule_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_shared_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_aligned_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_collapse_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_copyin_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_dist_schedule_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_safelen_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_schedule_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_shared_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_simdlen_messages.cpp
  clang/test/OpenMP/distribute_private_messages.cpp
  clang/test/OpenMP/distribute_simd_aligned_messages.cpp
  clang/test/OpenMP/distribute_simd_collapse_messages.cpp
  clang/test/OpenMP/distribute_simd_dist_schedule_messages.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_messages.cpp
  clang/test/OpenMP/distribute_simd_if_messages.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_messages.cpp
  clang/test/OpenMP/distribute_simd_linear_messages.cpp
  clang/test/OpenMP/distribute_simd_private_messages.cpp
  clang/test/OpenMP/distribute_simd_reduction_messages.cpp
  clang/test/OpenMP/distribute_simd_safelen_messages.cpp
  clang/test/OpenMP/distribute_simd_simdlen_messages.cpp
  clang/test/OpenMP/for_collapse_messages.cpp
  clang/test/OpenMP/for_firstprivate_messages.cpp
  clang/test/OpenMP/for_lastprivate_messages.cpp
  clang/test/OpenMP/for_linear_messages.cpp
  clang/test/OpenMP/for_ordered_clause.cpp
  clang/test/OpenMP/for_private_messages.cpp
  clang/test/OpenMP/for_reduction_messages.cpp
  clang/test/OpenMP/for_schedule_messages.cpp
  clang/test/OpenMP/for_simd_aligned_messages.cpp
  clang/test/OpenMP/for_simd_collapse_messages.cpp
  clang/test/OpenMP/for_simd_firstprivate_messages.cpp
  clang/test/OpenMP/for_simd_if_messages.cpp
  clang/test/OpenMP/for_simd_lastprivate_messages.cpp
  clang/test/OpenMP/for_simd_linear_messages.cpp
  clang/test/OpenMP/for_simd_private_messages.cpp
  clang/test/OpenMP/for_simd_reduction_messages.cpp
  clang/test/OpenMP/for_simd_safelen_messages.cpp
  clang/test/OpenMP/for_simd_schedule_messages.cpp
  clang/test/OpenMP/for_simd_simdlen_messages.cpp
  clang/test/OpenMP/masked_taskloop_collapse_messages.cpp
  clang/test/OpenMP/masked_taskloop_final_messages.cpp
  clang/test/OpenMP/masked_taskloop_firstprivate_messages.cpp
  clang/test/OpenMP/masked_taskloop_grainsize_messages.cpp
  clang/test/OpenMP/masked_taskloop_in_reduction_messages.cpp
  

[clang] e037880 - [clang-repl] Only enable dynamic-library test on x86_64

2023-04-25 Thread Anubhab Ghosh via cfe-commits

Author: Anubhab Ghosh
Date: 2023-04-26T09:46:38+05:30
New Revision: e037880b8eff2b425ff80ea9d6337fda27a64337

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

LOG: [clang-repl] Only enable dynamic-library test on x86_64

This test includes a precompiled library for x86_64 Linux

Added: 


Modified: 
clang/test/Interpreter/dynamic-library.cpp

Removed: 




diff  --git a/clang/test/Interpreter/dynamic-library.cpp 
b/clang/test/Interpreter/dynamic-library.cpp
index e2bfc81a383a7..6c4621f729c1c 100644
--- a/clang/test/Interpreter/dynamic-library.cpp
+++ b/clang/test/Interpreter/dynamic-library.cpp
@@ -1,4 +1,4 @@
-// REQUIRES: host-supports-jit, system-linux
+// REQUIRES: host-supports-jit, x86_64-linux
 
 // To generate libdynamic-library-test.so :
 // clang -xc++ -o libdynamic-library-test.so -fPIC -shared



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


[PATCH] D133863: [RISCV] Add MC support of RISCV zcmt Extension

2023-04-25 Thread Craig Topper via Phabricator via cfe-commits
craig.topper requested changes to this revision.
craig.topper added inline comments.
This revision now requires changes to proceed.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:853
 Error RISCVISAInfo::checkDependency() {
+  bool HasC = Exts.count("c") != 0;
   bool HasD = Exts.count("d") != 0;

This variable is unused.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:913
 
+  if (HasZcmt && (HasD || HasZcd))
+return createStringError(

It wouldn't be incompatible with Zca + D without Zcd would it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133863

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


[PATCH] D133863: [RISCV] Add MC support of RISCV zcmt Extension

2023-04-25 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng 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/D133863/new/

https://reviews.llvm.org/D133863

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


[PATCH] D148992: [clang-repl] Fix dynamic library test to avoid cstdio and linker

2023-04-25 Thread Anubhab Ghosh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7f96ce5e133b: [clang-repl] Fix dynamic library test to avoid 
cstdio and linker (authored by argentite).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148992

Files:
  clang/test/Interpreter/Inputs/dynamic-library-test.cpp
  clang/test/Interpreter/Inputs/libdynamic-library-test.so
  clang/test/Interpreter/dynamic-library.cpp


Index: clang/test/Interpreter/dynamic-library.cpp
===
--- clang/test/Interpreter/dynamic-library.cpp
+++ clang/test/Interpreter/dynamic-library.cpp
@@ -1,13 +1,25 @@
 // REQUIRES: host-supports-jit, system-linux
-// UNSUPPORTED: target={{.*-(ps4|ps5)}}
 
-// RUN: %clang -xc++ -o %T/libdynamic-library-test.so -fPIC -shared -DLIBRARY 
%S/Inputs/dynamic-library-test.cpp
-// RUN: cat %s | env LD_LIBRARY_PATH=%T:$LD_LIBRARY_PATH clang-repl | 
FileCheck %s
+// To generate libdynamic-library-test.so :
+// clang -xc++ -o libdynamic-library-test.so -fPIC -shared
+//
+// extern "C" {
+//
+// int ultimate_answer = 0;
+// 
+// int calculate_answer() {
+//   ultimate_answer = 42;
+//   return 5;
+// }
+//
+// }
 
-#include 
+// RUN: cat %s | env LD_LIBRARY_PATH=%S/Inputs:$LD_LIBRARY_PATH clang-repl | 
FileCheck %s
 
-extern int ultimate_answer;
-int calculate_answer();
+extern "C" int printf(const char* format, ...);
+
+extern "C" int ultimate_answer;
+extern "C" int calculate_answer();
 
 %lib libdynamic-library-test.so
 
Index: clang/test/Interpreter/Inputs/dynamic-library-test.cpp
===
--- clang/test/Interpreter/Inputs/dynamic-library-test.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-int ultimate_answer = 0;
-
-int calculate_answer() {
-  ultimate_answer = 42;
-  return 5;
-}


Index: clang/test/Interpreter/dynamic-library.cpp
===
--- clang/test/Interpreter/dynamic-library.cpp
+++ clang/test/Interpreter/dynamic-library.cpp
@@ -1,13 +1,25 @@
 // REQUIRES: host-supports-jit, system-linux
-// UNSUPPORTED: target={{.*-(ps4|ps5)}}
 
-// RUN: %clang -xc++ -o %T/libdynamic-library-test.so -fPIC -shared -DLIBRARY %S/Inputs/dynamic-library-test.cpp
-// RUN: cat %s | env LD_LIBRARY_PATH=%T:$LD_LIBRARY_PATH clang-repl | FileCheck %s
+// To generate libdynamic-library-test.so :
+// clang -xc++ -o libdynamic-library-test.so -fPIC -shared
+//
+// extern "C" {
+//
+// int ultimate_answer = 0;
+// 
+// int calculate_answer() {
+//   ultimate_answer = 42;
+//   return 5;
+// }
+//
+// }
 
-#include 
+// RUN: cat %s | env LD_LIBRARY_PATH=%S/Inputs:$LD_LIBRARY_PATH clang-repl | FileCheck %s
 
-extern int ultimate_answer;
-int calculate_answer();
+extern "C" int printf(const char* format, ...);
+
+extern "C" int ultimate_answer;
+extern "C" int calculate_answer();
 
 %lib libdynamic-library-test.so
 
Index: clang/test/Interpreter/Inputs/dynamic-library-test.cpp
===
--- clang/test/Interpreter/Inputs/dynamic-library-test.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-int ultimate_answer = 0;
-
-int calculate_answer() {
-  ultimate_answer = 42;
-  return 5;
-}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7f96ce5 - [clang-repl] Fix dynamic library test to avoid cstdio and linker

2023-04-25 Thread Anubhab Ghosh via cfe-commits

Author: Anubhab Ghosh
Date: 2023-04-26T09:11:09+05:30
New Revision: 7f96ce5e133be54891af177adbf8952d413e0f85

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

LOG: [clang-repl] Fix dynamic library test to avoid cstdio and linker

Some platforms do not have a working linker present. The goal is to
only test the loading of a shared library in clang-repl. A precompiled
library is used instead.

The cstdio header may also not be present. We only need printf.

Related discussion in D141824

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

Added: 
clang/test/Interpreter/Inputs/libdynamic-library-test.so

Modified: 
clang/test/Interpreter/dynamic-library.cpp

Removed: 
clang/test/Interpreter/Inputs/dynamic-library-test.cpp



diff  --git a/clang/test/Interpreter/Inputs/dynamic-library-test.cpp 
b/clang/test/Interpreter/Inputs/dynamic-library-test.cpp
deleted file mode 100644
index 1f143ba040cb6..0
--- a/clang/test/Interpreter/Inputs/dynamic-library-test.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-int ultimate_answer = 0;
-
-int calculate_answer() {
-  ultimate_answer = 42;
-  return 5;
-}

diff  --git a/clang/test/Interpreter/Inputs/libdynamic-library-test.so 
b/clang/test/Interpreter/Inputs/libdynamic-library-test.so
new file mode 100755
index 0..bb7c7b5a54317
Binary files /dev/null and 
b/clang/test/Interpreter/Inputs/libdynamic-library-test.so 
diff er

diff  --git a/clang/test/Interpreter/dynamic-library.cpp 
b/clang/test/Interpreter/dynamic-library.cpp
index 145c58bc2ae26..e2bfc81a383a7 100644
--- a/clang/test/Interpreter/dynamic-library.cpp
+++ b/clang/test/Interpreter/dynamic-library.cpp
@@ -1,13 +1,25 @@
 // REQUIRES: host-supports-jit, system-linux
-// UNSUPPORTED: target={{.*-(ps4|ps5)}}
 
-// RUN: %clang -xc++ -o %T/libdynamic-library-test.so -fPIC -shared -DLIBRARY 
%S/Inputs/dynamic-library-test.cpp
-// RUN: cat %s | env LD_LIBRARY_PATH=%T:$LD_LIBRARY_PATH clang-repl | 
FileCheck %s
+// To generate libdynamic-library-test.so :
+// clang -xc++ -o libdynamic-library-test.so -fPIC -shared
+//
+// extern "C" {
+//
+// int ultimate_answer = 0;
+// 
+// int calculate_answer() {
+//   ultimate_answer = 42;
+//   return 5;
+// }
+//
+// }
 
-#include 
+// RUN: cat %s | env LD_LIBRARY_PATH=%S/Inputs:$LD_LIBRARY_PATH clang-repl | 
FileCheck %s
 
-extern int ultimate_answer;
-int calculate_answer();
+extern "C" int printf(const char* format, ...);
+
+extern "C" int ultimate_answer;
+extern "C" int calculate_answer();
 
 %lib libdynamic-library-test.so
 



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


[PATCH] D149205: [Headers][doc] Add "gather" intrinsic descriptions to avx2intrin.h

2023-04-25 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.

LGTM with one nit.




Comment at: clang/lib/Headers/avx2intrin.h:942
+///
+/// \code
+/// FOR element := 0 to 1

Use `\code{.operation}` please, the same below. Our internal tool will 
recognize this pattern.


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

https://reviews.llvm.org/D149205

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


[PATCH] D125272: [clang] Add -fcheck-new support

2023-04-25 Thread Pedro Falcato via Phabricator via cfe-commits
heatd updated this revision to Diff 517029.
heatd added a comment.

Update the test to work with tip (completely forgot, apologies)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125272

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ExprCXX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CodeGenCXX/fcheck-new.cpp
  clang/test/Driver/clang_f_opts.c

Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -298,7 +298,6 @@
 // RUN: -fno-reorder-blocks -freorder-blocks  \
 // RUN: -fno-schedule-insns2 -fschedule-insns2\
 // RUN: -fno-stack-check  \
-// RUN: -fno-check-new -fcheck-new\
 // RUN: -ffriend-injection\
 // RUN: -fno-implement-inlines -fimplement-inlines\
 // RUN: -fstack-check \
Index: clang/test/CodeGenCXX/fcheck-new.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/fcheck-new.cpp
@@ -0,0 +1,12 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -fcheck-new -triple x86_64-linux-gnu -S -disable-O0-optnone \
+// RUN: -emit-llvm -o - %s | opt -S -passes=mem2reg | FileCheck %s
+
+// CHECK-LABEL: @_Z5test0v(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CALL:%.*]] = call noalias noundef ptr @_Znwm(i64 noundef 4) #[[ATTR2:[0-9]+]]
+// CHECK-NEXT:ret ptr [[CALL]]
+//
+int *test0() {
+  return new int;
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -3143,7 +3143,8 @@
 // Global allocation functions should always be visible.
 Alloc->setVisibleDespiteOwningModule();
 
-if (HasBadAllocExceptionSpec && getLangOpts().NewInfallible)
+if (HasBadAllocExceptionSpec && getLangOpts().NewInfallible &&
+!getLangOpts().CheckNew)
   Alloc->addAttr(
   ReturnsNonNullAttr::CreateImplicit(Context, Alloc->getLocation()));
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16057,7 +16057,11 @@
   //   indicates failure by returning a null pointer value. Any other allocation
   //   function never returns a null pointer value and indicates failure only by
   //   throwing an exception [...]
-  if (!IsNothrow && !FD->hasAttr())
+  //
+  // However, -fcheck-new invalidates this possible assumption, so don't add
+  // NonNull when that is enabled.
+  if (!IsNothrow && !FD->hasAttr() &&
+  !getLangOpts().CheckNew)
 FD->addAttr(ReturnsNonNullAttr::CreateImplicit(Context, FD->getLocation()));
 
   // C++2a [basic.stc.dynamic.allocation]p2:
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6125,6 +6125,9 @@
Triple.hasDefaultEmulatedTLS()))
 CmdArgs.push_back("-femulated-tls");
 
+  Args.addOptInFlag(CmdArgs, options::OPT_fcheck_new,
+options::OPT_fno_check_new);
+
   if (Arg *A = Args.getLastArg(options::OPT_fzero_call_used_regs_EQ)) {
 // FIXME: There's no reason for this to be restricted to X86. The backend
 // code needs to be changed to include the appropriate function calls
Index: clang/lib/AST/ExprCXX.cpp
===
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -276,6 +276,8 @@
 }
 
 bool CXXNewExpr::shouldNullCheckAllocation() const {
+  if (getOperatorNew()->getLangOpts().CheckNew)
+return true;
   return !getOperatorNew()->hasAttr() &&
  getOperatorNew()
  ->getType()
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4912,7 +4912,11 @@
 // ignore it for now to avoid breaking builds that use it.
 def fdiagnostics_show_location_EQ : Joined<["-"], "fdiagnostics-show-location=">, Group;
 
-defm fcheck_new : BooleanFFlag<"check-new">, Group;
+defm check_new : BoolOption<"f", "check-new",
+  LangOpts<"CheckNew">, DefaultFalse,
+  PosFlag,
+  NegFlag, BothFlags<[CC1Option]>>;
+
 defm caller_saves : 

[PATCH] D149017: [RISCV] Rewrite all found class-based subroutines to functions

2023-04-25 Thread Michael Maitland via Phabricator via cfe-commits
michaelmaitland accepted this revision.
michaelmaitland 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/D149017/new/

https://reviews.llvm.org/D149017

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


[PATCH] D149017: [RISCV] Rewrite all found class-based subroutines to functions

2023-04-25 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td:703
 class VPseudoUSLoadMask :
-  Pseudo<(outs GetVRegNoV0.R:$rd),
-  (ins GetVRegNoV0.R:$merge,
+  Pseudo<(outs GetVRegNoV0'(RetClass):$rd),
+  (ins GetVRegNoV0'(RetClass):$merge,

michaelmaitland wrote:
> Typo with the `'`? This also happens multiple times below.
> 
> 
No, it is by design. A single quote is added before `(` to solve the grammar 
ambiguity between DAG and function call. The design may be changed however.
Please see 
https://discourse.llvm.org/t/tablegen-introduce-function-and-lambda/70160#h-13-function-call-5
 also. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149017

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


[PATCH] D125272: [clang] Add -fcheck-new support

2023-04-25 Thread Pedro Falcato via Phabricator via cfe-commits
heatd updated this revision to Diff 517020.
heatd added a comment.

Address MaskRay's comments on Options.td, adjust the help message, rebase to 
current tip


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125272

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ExprCXX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CodeGenCXX/fcheck-new.cpp
  clang/test/Driver/clang_f_opts.c

Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -298,7 +298,6 @@
 // RUN: -fno-reorder-blocks -freorder-blocks  \
 // RUN: -fno-schedule-insns2 -fschedule-insns2\
 // RUN: -fno-stack-check  \
-// RUN: -fno-check-new -fcheck-new\
 // RUN: -ffriend-injection\
 // RUN: -fno-implement-inlines -fimplement-inlines\
 // RUN: -fstack-check \
Index: clang/test/CodeGenCXX/fcheck-new.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/fcheck-new.cpp
@@ -0,0 +1,12 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -fcheck-new -triple x86_64-linux-gnu -S -disable-O0-optnone \
+// RUN: -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+// CHECK-LABEL: @_Z5test0v(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[CALL:%.*]] = call noalias noundef ptr @_Znwm(i64 noundef 4) #[[ATTR2:[0-9]+]]
+// CHECK-NEXT:ret ptr [[CALL]]
+//
+int *test0() {
+  return new int;
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -3143,7 +3143,8 @@
 // Global allocation functions should always be visible.
 Alloc->setVisibleDespiteOwningModule();
 
-if (HasBadAllocExceptionSpec && getLangOpts().NewInfallible)
+if (HasBadAllocExceptionSpec && getLangOpts().NewInfallible &&
+!getLangOpts().CheckNew)
   Alloc->addAttr(
   ReturnsNonNullAttr::CreateImplicit(Context, Alloc->getLocation()));
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16057,7 +16057,11 @@
   //   indicates failure by returning a null pointer value. Any other allocation
   //   function never returns a null pointer value and indicates failure only by
   //   throwing an exception [...]
-  if (!IsNothrow && !FD->hasAttr())
+  //
+  // However, -fcheck-new invalidates this possible assumption, so don't add
+  // NonNull when that is enabled.
+  if (!IsNothrow && !FD->hasAttr() &&
+  !getLangOpts().CheckNew)
 FD->addAttr(ReturnsNonNullAttr::CreateImplicit(Context, FD->getLocation()));
 
   // C++2a [basic.stc.dynamic.allocation]p2:
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6125,6 +6125,9 @@
Triple.hasDefaultEmulatedTLS()))
 CmdArgs.push_back("-femulated-tls");
 
+  Args.addOptInFlag(CmdArgs, options::OPT_fcheck_new,
+options::OPT_fno_check_new);
+
   if (Arg *A = Args.getLastArg(options::OPT_fzero_call_used_regs_EQ)) {
 // FIXME: There's no reason for this to be restricted to X86. The backend
 // code needs to be changed to include the appropriate function calls
Index: clang/lib/AST/ExprCXX.cpp
===
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -276,6 +276,8 @@
 }
 
 bool CXXNewExpr::shouldNullCheckAllocation() const {
+  if (getOperatorNew()->getLangOpts().CheckNew)
+return true;
   return !getOperatorNew()->hasAttr() &&
  getOperatorNew()
  ->getType()
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4912,7 +4912,11 @@
 // ignore it for now to avoid breaking builds that use it.
 def fdiagnostics_show_location_EQ : Joined<["-"], "fdiagnostics-show-location=">, Group;
 
-defm fcheck_new : BooleanFFlag<"check-new">, Group;
+defm check_new : BoolOption<"f", "check-new",
+  LangOpts<"CheckNew">, DefaultFalse,
+  PosFlag,
+  NegFlag, BothFlags<[CC1Option]>>;
+
 defm 

[PATCH] D149163: [NFC][CLANG] Fix coverity remarks about large copy by values

2023-04-25 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 517018.
Manna edited the summary of this revision.

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

https://reviews.llvm.org/D149163

Files:
  clang/lib/CodeGen/CGGPUBuiltin.cpp
  clang/lib/CodeGen/CGNonTrivialStruct.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -4553,7 +4553,7 @@
   return false;
 }
 
-static bool IsNoDerefableChunk(DeclaratorChunk Chunk) {
+static bool IsNoDerefableChunk(const DeclaratorChunk ) {
   return (Chunk.Kind == DeclaratorChunk::Pointer ||
   Chunk.Kind == DeclaratorChunk::Array);
 }
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1711,7 +1711,7 @@
 
   /// Emit the module flag metadata used to pass options controlling the
   /// the backend to LLVM.
-  void EmitBackendOptionsMetadata(const CodeGenOptions CodeGenOpts);
+  void EmitBackendOptionsMetadata(const CodeGenOptions );
 
   /// Emits OpenCL specific Metadata e.g. OpenCL version.
   void EmitOpenCLMetadata();
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -990,7 +990,7 @@
 }
 
 void CodeGenModule::EmitBackendOptionsMetadata(
-const CodeGenOptions CodeGenOpts) {
+const CodeGenOptions ) {
   if (getTriple().isRISCV()) {
 getModule().addModuleFlag(llvm::Module::Min, "SmallDataLimit",
   CodeGenOpts.SmallDataLimit);
Index: clang/lib/CodeGen/CGNonTrivialStruct.cpp
===
--- clang/lib/CodeGen/CGNonTrivialStruct.cpp
+++ clang/lib/CodeGen/CGNonTrivialStruct.cpp
@@ -323,7 +323,7 @@
 template 
 static std::array getParamAddrs(std::index_sequence 
IntSeq,
 std::array 
Alignments,
-FunctionArgList Args,
+const FunctionArgList ,
 CodeGenFunction *CGF) {
   return std::array{
   {Address(CGF->Builder.CreateLoad(CGF->GetAddrOfLocalVar(Args[Ints])),
Index: clang/lib/CodeGen/CGGPUBuiltin.cpp
===
--- clang/lib/CodeGen/CGGPUBuiltin.cpp
+++ clang/lib/CodeGen/CGGPUBuiltin.cpp
@@ -125,7 +125,7 @@
   }
 }
 
-bool containsNonScalarVarargs(CodeGenFunction *CGF, CallArgList Args) {
+bool containsNonScalarVarargs(CodeGenFunction *CGF, const CallArgList ) {
   return llvm::any_of(llvm::drop_begin(Args), [&](const CallArg ) {
 return !A.getRValue(*CGF).isScalar();
   });


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -4553,7 +4553,7 @@
   return false;
 }
 
-static bool IsNoDerefableChunk(DeclaratorChunk Chunk) {
+static bool IsNoDerefableChunk(const DeclaratorChunk ) {
   return (Chunk.Kind == DeclaratorChunk::Pointer ||
   Chunk.Kind == DeclaratorChunk::Array);
 }
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1711,7 +1711,7 @@
 
   /// Emit the module flag metadata used to pass options controlling the
   /// the backend to LLVM.
-  void EmitBackendOptionsMetadata(const CodeGenOptions CodeGenOpts);
+  void EmitBackendOptionsMetadata(const CodeGenOptions );
 
   /// Emits OpenCL specific Metadata e.g. OpenCL version.
   void EmitOpenCLMetadata();
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -990,7 +990,7 @@
 }
 
 void CodeGenModule::EmitBackendOptionsMetadata(
-const CodeGenOptions CodeGenOpts) {
+const CodeGenOptions ) {
   if (getTriple().isRISCV()) {
 getModule().addModuleFlag(llvm::Module::Min, "SmallDataLimit",
   CodeGenOpts.SmallDataLimit);
Index: clang/lib/CodeGen/CGNonTrivialStruct.cpp
===
--- clang/lib/CodeGen/CGNonTrivialStruct.cpp
+++ clang/lib/CodeGen/CGNonTrivialStruct.cpp
@@ -323,7 +323,7 @@
 template 
 static std::array getParamAddrs(std::index_sequence IntSeq,
 std::array Alignments,
-FunctionArgList Args,
+const FunctionArgList ,
  

[PATCH] D149009: [Sema]Select correct lexical context during template instantiate

2023-04-25 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 updated this revision to Diff 517019.
HerrCai0907 added a comment.

change LexicalDeclContext


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149009

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaTemplate/template-friend-definition-in-template.cpp


Index: clang/test/SemaTemplate/template-friend-definition-in-template.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/template-friend-definition-in-template.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+template  int foo1(F1 X1);
+
+template  struct A {
+  template  friend int foo1(F2 X2) {
+return A1;
+  }
+};
+
+template struct A<1>;
+int main() { 
+  foo1(1.0);
+}
+
+template  int foo2(F1 X1);
+
+template  struct B {
+  template  friend int foo2(F2 X2) {
+return A1;
+  }
+};
+
+template struct B<1>;
+template int foo2(float X1);
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4662,11 +4662,7 @@
   ActiveInstType  = SemaRef.CodeSynthesisContexts.back();
   if (ActiveInst.Kind == ActiveInstType::ExplicitTemplateArgumentSubstitution 
||
   ActiveInst.Kind == ActiveInstType::DeducedTemplateArgumentSubstitution) {
-if (FunctionTemplateDecl *FunTmpl
-  = dyn_cast(ActiveInst.Entity)) {
-  assert(FunTmpl->getTemplatedDecl() == Tmpl &&
- "Deduction from the wrong function template?");
-  (void) FunTmpl;
+if (isa(ActiveInst.Entity)) {
   SemaRef.InstantiatingSpecializations.erase(
   {ActiveInst.Entity->getCanonicalDecl(), ActiveInst.Kind});
   atTemplateEnd(SemaRef.TemplateInstCallbacks, SemaRef, ActiveInst);
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3591,11 +3591,28 @@
   DeclContext *Owner = FunctionTemplate->getDeclContext();
   if (FunctionTemplate->getFriendObjectKind())
 Owner = FunctionTemplate->getLexicalDeclContext();
+  FunctionDecl *FD = FunctionTemplate->getTemplatedDecl();
+  // additional check for inline friend, 
+  // ```
+  //   template  int foo(F1 X);
+  //   template  struct A {
+  // template  friend int foo(F1 X) { return A1; }
+  //   };
+  //   template struct A<1>;
+  //   int a = foo(1.0);
+  // ```
+  const FunctionDecl *FDFriend;
+  if (FD->getFriendObjectKind() == Decl::FriendObjectKind::FOK_None &&
+  FD->isDefined(FDFriend, /*CheckForPendingFriendDefinition*/ true) &&
+  FDFriend->getFriendObjectKind() != Decl::FriendObjectKind::FOK_None) {
+FD = const_cast(FDFriend);
+Owner = FD->getLexicalDeclContext();
+  }
   MultiLevelTemplateArgumentList SubstArgs(
   FunctionTemplate, CanonicalDeducedArgumentList->asArray(),
   /*Final=*/false);
   Specialization = cast_or_null(
-  SubstDecl(FunctionTemplate->getTemplatedDecl(), Owner, SubstArgs));
+  SubstDecl(FD, Owner, SubstArgs));
   if (!Specialization || Specialization->isInvalidDecl())
 return TDK_SubstitutionFailure;
 


Index: clang/test/SemaTemplate/template-friend-definition-in-template.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/template-friend-definition-in-template.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+template  int foo1(F1 X1);
+
+template  struct A {
+  template  friend int foo1(F2 X2) {
+return A1;
+  }
+};
+
+template struct A<1>;
+int main() { 
+  foo1(1.0);
+}
+
+template  int foo2(F1 X1);
+
+template  struct B {
+  template  friend int foo2(F2 X2) {
+return A1;
+  }
+};
+
+template struct B<1>;
+template int foo2(float X1);
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4662,11 +4662,7 @@
   ActiveInstType  = SemaRef.CodeSynthesisContexts.back();
   if (ActiveInst.Kind == ActiveInstType::ExplicitTemplateArgumentSubstitution ||
   ActiveInst.Kind == ActiveInstType::DeducedTemplateArgumentSubstitution) {
-if (FunctionTemplateDecl *FunTmpl
-  = dyn_cast(ActiveInst.Entity)) {
-  assert(FunTmpl->getTemplatedDecl() == Tmpl &&
- "Deduction from the wrong function template?");
-  (void) FunTmpl;
+if (isa(ActiveInst.Entity)) {
   SemaRef.InstantiatingSpecializations.erase(
   {ActiveInst.Entity->getCanonicalDecl(), ActiveInst.Kind});
   atTemplateEnd(SemaRef.TemplateInstCallbacks, SemaRef, 

[PATCH] D148769: Split out `CodeGenTypes` from `CodeGen` for LLT/MVT

2023-04-25 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: wdng.

I feel like this should have documentation explaining the library split, but 
not sure where the best place to put that would be


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148769

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


[PATCH] D149119: [CMake] Use llvm-nm to extract symbols for staged LTO builds on Windows

2023-04-25 Thread Igor Kudrin via Phabricator via cfe-commits
ikudrin added a comment.

In D149119#4295110 , @tmatheson wrote:

> This looks like a nice addition. Would it make sense to use llvm-nm always, 
> not restricted to bootstrap builds? And would that work on Windows and allow 
> us to simplify this script substantially by using one tool for all platforms?

If I understand it right, we might not be able to build `llvm-nm` in cases like 
cross-platform building, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149119

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


[PATCH] D147610: [RISCV][MC] Add support for experimental Zfbfmin extension

2023-04-25 Thread Jun Sha via Phabricator via cfe-commits
joshua-arch1 added a comment.

> The RVI toolchain SIG is supposed to be setting up a task group to define 
> intrinsics for all extensions.

Where should I discuss this intrinsic issue right now?


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

https://reviews.llvm.org/D147610

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


[PATCH] D148757: [clang] Apply -fcoverage-prefix-map reverse order

2023-04-25 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem updated this revision to Diff 517012.
gulfem marked an inline comment as done.
gulfem added a comment.

Added more info into HelpText and reversed prefix map in the first place to 
incorporate coworker feedback.
GCC uses a linked list to store the prefix mappings in reverse order:
https://github.com/gcc-mirror/gcc/blob/master/gcc/file-prefix-map.cc#L27


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148757

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Profile/coverage-prefix-map.c


Index: clang/test/Profile/coverage-prefix-map.c
===
--- clang/test/Profile/coverage-prefix-map.c
+++ clang/test/Profile/coverage-prefix-map.c
@@ -19,3 +19,13 @@
 
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-compilation-dir=/custom 
-fcoverage-prefix-map=/custom=/nonsense -o - | FileCheck 
--check-prefix=COVERAGE-COMPILATION-DIR %s
 // COVERAGE-COMPILATION-DIR: @__llvm_coverage_mapping = {{.*"\\02.*}}nonsense
+
+// Test that last -fcoverage-prefix-map option 
(-fcoverage-prefix-map==newpath) is applied.
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-prefix-map=%/t/root=. 
-fcoverage-prefix-map==newpath -o - | FileCheck 
--check-prefix=COVERAGE-PREFIX-MAP-ORDER %s
+// COVERAGE-PREFIX-MAP-ORDER: @__llvm_coverage_mapping = 
{{.*"\\02.*newpath.*root.*nested.*coverage-prefix-map\.c}}
+
+// Test that last -fcoverage-prefix-map option 
(-fcoverage-prefix-map=%/t/root=.) is applied.
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-prefix-map==newpath 
-fcoverage-prefix-map=%/t/root=. -o - | FileCheck 
--check-prefix=COVERAGE-PREFIX-MAP-REORDER %s
+// COVERAGE-PREFIX-MAP-REORDER: @__llvm_coverage_mapping =
+// COVERAGE-PREFIX-MAP-REORDER-NOT: newpath
+// COVERAGE-PREFIX-MAP-REORDER-SAME: nested{{.*coverage-prefix-map\.c}}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1701,9 +1701,12 @@
 
   for (const auto  : Args.getAllArgValues(OPT_fcoverage_prefix_map_EQ)) {
 auto Split = StringRef(Arg).split('=');
-Opts.CoveragePrefixMap.insert(
-{std::string(Split.first), std::string(Split.second)});
+Opts.CoveragePrefixMap.emplace_back(Split.first, Split.second);
   }
+  // Reverse prefix replacement map because if there are multiple options,
+  // the last such option is the one that is effective.
+  if (!Opts.CoveragePrefixMap.empty())
+std::reverse(Opts.CoveragePrefixMap.begin(), Opts.CoveragePrefixMap.end());
 
   const llvm::Triple::ArchType DebugEntryValueArchs[] = {
   llvm::Triple::x86, llvm::Triple::x86_64, llvm::Triple::aarch64,
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1648,8 +1648,8 @@
 std::string CoverageMappingModuleGen::normalizeFilename(StringRef Filename) {
   llvm::SmallString<256> Path(Filename);
   llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
-  for (const auto  : CGM.getCodeGenOpts().CoveragePrefixMap) {
-if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second))
+  for (const auto &[From, To] : CGM.getCodeGenOpts().CoveragePrefixMap) {
+if (llvm::sys::path::replace_path_prefix(Path, From, To))
   break;
   }
   return Path.str().str();
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3223,7 +3223,8 @@
 def fcoverage_prefix_map_EQ
   : Joined<["-"], "fcoverage-prefix-map=">, Group,
 Flags<[CC1Option]>,
-HelpText<"remap file source paths in coverage mapping">;
+MetaVarName<"=">,
+HelpText<"remap file source paths  to  in coverage mapping. If 
there are multiple options, the last such option is the one that is effective">;
 def ffile_prefix_map_EQ
   : Joined<["-"], "ffile-prefix-map=">, Group,
 HelpText<"remap file source paths in debug info, predefined preprocessor "
Index: clang/include/clang/Basic/CodeGenOptions.h
===
--- 

[PATCH] D149017: [RISCV] Rewrite all found class-based subroutines to functions

2023-04-25 Thread Michael Maitland via Phabricator via cfe-commits
michaelmaitland added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td:703
 class VPseudoUSLoadMask :
-  Pseudo<(outs GetVRegNoV0.R:$rd),
-  (ins GetVRegNoV0.R:$merge,
+  Pseudo<(outs GetVRegNoV0'(RetClass):$rd),
+  (ins GetVRegNoV0'(RetClass):$merge,

Typo with the `'`? This also happens multiple times below.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149017

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


[PATCH] D148490: [AIX] use system assembler for assembly files

2023-04-25 Thread ChenZheng via Phabricator via cfe-commits
shchenz updated this revision to Diff 517011.
shchenz added a comment.

address @qiucf comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148490

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/aix-assembler.s


Index: clang/test/Driver/aix-assembler.s
===
--- /dev/null
+++ clang/test/Driver/aix-assembler.s
@@ -0,0 +1,30 @@
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit.
+// RUN: %clang %s -### -c -fintegrated-as 2>&1 \
+// RUN: --target=powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefixes=AS64,CHECK %s
+
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --target=powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefixes=AS64,CHECK %s
+
+// RUN: %clang %s -### -c -fno-integrated-as 2>&1 \
+// RUN: --target=powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefixes=AS64,CHECK %s
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit.
+// RUN: %clang %s -### -c -fintegrated-as 2>&1 \
+// RUN: --target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefixes=AS32,CHECK %s
+
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefixes=AS32,CHECK %s
+
+// RUN: %clang %s -### -c 2>&1 -fno-integrated-as \
+// RUN: --target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefixes=AS32,CHECK %s
+
+// CHECK: "{{.*}}as{{(.exe)?}}"
+// AS32: "-a32"
+// AS64: "-a64"
+// CHECK: "-many"
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -662,7 +662,8 @@
   if (D.IsFlangMode() && getDriver().ShouldUseFlangCompiler(JA)) return 
getFlang();
   if (getDriver().ShouldUseClangCompiler(JA)) return getClang();
   Action::ActionClass AC = JA.getKind();
-  if (AC == Action::AssembleJobClass && useIntegratedAs())
+  if (AC == Action::AssembleJobClass && useIntegratedAs() &&
+  !getTriple().isOSAIX())
 return getClangAs();
   return getTool(AC);
 }


Index: clang/test/Driver/aix-assembler.s
===
--- /dev/null
+++ clang/test/Driver/aix-assembler.s
@@ -0,0 +1,30 @@
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit.
+// RUN: %clang %s -### -c -fintegrated-as 2>&1 \
+// RUN: --target=powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefixes=AS64,CHECK %s
+
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --target=powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefixes=AS64,CHECK %s
+
+// RUN: %clang %s -### -c -fno-integrated-as 2>&1 \
+// RUN: --target=powerpc64-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefixes=AS64,CHECK %s
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit.
+// RUN: %clang %s -### -c -fintegrated-as 2>&1 \
+// RUN: --target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefixes=AS32,CHECK %s
+
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefixes=AS32,CHECK %s
+
+// RUN: %clang %s -### -c 2>&1 -fno-integrated-as \
+// RUN: --target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefixes=AS32,CHECK %s
+
+// CHECK: "{{.*}}as{{(.exe)?}}"
+// AS32: "-a32"
+// AS64: "-a64"
+// CHECK: "-many"
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -662,7 +662,8 @@
   if (D.IsFlangMode() && getDriver().ShouldUseFlangCompiler(JA)) return getFlang();
   if (getDriver().ShouldUseClangCompiler(JA)) return getClang();
   Action::ActionClass AC = JA.getKind();
-  if (AC == Action::AssembleJobClass && useIntegratedAs())
+  if (AC == Action::AssembleJobClass && useIntegratedAs() &&
+  !getTriple().isOSAIX())
 return getClangAs();
   return getTool(AC);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149163: [NFC][CLANG] Fix coverity remarks about large copy by values

2023-04-25 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 517010.

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

https://reviews.llvm.org/D149163

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/SemaType.cpp
  clang/tools/libclang/CIndexCodeCompletion.cpp
  clang/unittests/Sema/CodeCompleteTest.cpp

Index: clang/unittests/Sema/CodeCompleteTest.cpp
===
--- clang/unittests/Sema/CodeCompleteTest.cpp
+++ clang/unittests/Sema/CodeCompleteTest.cpp
@@ -54,7 +54,7 @@
 CompletedFuncDecls(CompletedFuncDecls),
 CCTUInfo(std::make_shared()) {}
 
-  void ProcessCodeCompleteResults(Sema , CodeCompletionContext Context,
+  void ProcessCodeCompleteResults(Sema , const CodeCompletionContext ,
   CodeCompletionResult *Results,
   unsigned NumResults) override {
 for (unsigned I = 0; I < NumResults; ++I) {
@@ -89,7 +89,7 @@
   : CodeCompleteConsumer(/*CodeCompleteOpts=*/{}), ResultCtx(ResultCtx),
 CCTUInfo(std::make_shared()) {}
 
-  void ProcessCodeCompleteResults(Sema , CodeCompletionContext Context,
+  void ProcessCodeCompleteResults(Sema , const CodeCompletionContext ,
   CodeCompletionResult *Results,
   unsigned NumResults) override {
 ResultCtx.VisitedNamespaces =
Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- clang/tools/libclang/CIndexCodeCompletion.cpp
+++ clang/tools/libclang/CIndexCodeCompletion.cpp
@@ -572,8 +572,8 @@
   CCTUInfo(Results.CodeCompletionAllocator), TU(TranslationUnit) {}
 ~CaptureCompletionResults() override { Finish(); }
 
-void ProcessCodeCompleteResults(Sema , 
-CodeCompletionContext Context,
+void ProcessCodeCompleteResults(Sema ,
+const CodeCompletionContext ,
 CodeCompletionResult *Results,
 unsigned NumResults) override {
   StoredResults.reserve(StoredResults.size() + NumResults);
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -4553,7 +4553,7 @@
   return false;
 }
 
-static bool IsNoDerefableChunk(DeclaratorChunk Chunk) {
+static bool IsNoDerefableChunk(const DeclaratorChunk ) {
   return (Chunk.Kind == DeclaratorChunk::Pointer ||
   Chunk.Kind == DeclaratorChunk::Array);
 }
Index: clang/lib/Sema/CodeCompleteConsumer.cpp
===
--- clang/lib/Sema/CodeCompleteConsumer.cpp
+++ clang/lib/Sema/CodeCompleteConsumer.cpp
@@ -638,8 +638,8 @@
 }
 
 void PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(
-Sema , CodeCompletionContext Context, CodeCompletionResult *Results,
-unsigned NumResults) {
+Sema , const CodeCompletionContext ,
+CodeCompletionResult *Results, unsigned NumResults) {
   std::stable_sort(Results, Results + NumResults);
 
   if (!Context.getPreferredType().isNull())
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -1952,7 +1952,8 @@
|  (1LL << CodeCompletionContext::CCC_ClassOrStructTag);
 }
 
-void ProcessCodeCompleteResults(Sema , CodeCompletionContext Context,
+void ProcessCodeCompleteResults(Sema ,
+const CodeCompletionContext ,
 CodeCompletionResult *Results,
 unsigned NumResults) override;
 
@@ -2063,10 +2064,9 @@
   }
 }
 
-void AugmentedCodeCompleteConsumer::ProcessCodeCompleteResults(Sema ,
-CodeCompletionContext Context,
-CodeCompletionResult *Results,
-unsigned NumResults) {
+void AugmentedCodeCompleteConsumer::ProcessCodeCompleteResults(
+Sema , const CodeCompletionContext ,
+CodeCompletionResult *Results, unsigned NumResults) {
   // Merge the results we were given with the results we cached.
   bool AddedResult = false;
   uint64_t InContexts =
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1711,7 +1711,7 @@
 
   /// Emit the module flag metadata used to pass options controlling the
   /// the backend to LLVM.
-  void 

[PATCH] D148975: -fdebug-prefix-map=: make the last win when multiple prefixes match

2023-04-25 Thread Douglas Yung via Phabricator via cfe-commits
dyung added inline comments.



Comment at: llvm/test/MC/ELF/debug-prefix-map.s:54
+
+# MAPABS_V5_A:DW_AT_comp_dir [DW_FORM_string] ("{{(/|\\)+}}src_root/bar")
+# MAPABS_V5_A:DW_AT_decl_file [DW_FORM_data4] 
("/src_root{{(/|\\)+}}bar{{(/|\\)+}}src.s")

This might need another regex for the path separator between src_root and bar.
https://lab.llvm.org/buildbot/#/builders/216/builds/20460/steps/7/logs/FAIL__LLVM__debug-prefix-map_s
```
:11:2: note: possible intended match here
 DW_AT_comp_dir [DW_FORM_string] ("/src_root\\bar")
 ^
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148975

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


[PATCH] D148975: -fdebug-prefix-map=: make the last win when multiple prefixes match

2023-04-25 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

@MaskRay , a test you modified, debug-prefix-map.s is failing on the PS5 
Windows bot. Can you take a look?

https://lab.llvm.org/buildbot/#/builders/216/builds/20460


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148975

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


[PATCH] D149193: [Driver] Add -dumpdir and change -gsplit-dwarf .dwo names for linking

2023-04-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 517004.
MaskRay retitled this revision from "[Driver] -gsplit-dwarf: derive .dwo names 
from -o for link actions" to "[Driver] Add -dumpdir and change -gsplit-dwarf 
.dwo names for linking".
MaskRay edited the summary of this revision.
MaskRay added a comment.

expose -dumpdir
add release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149193

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/hip-gsplit-dwarf-options.hip
  clang/test/Driver/split-debug.c

Index: clang/test/Driver/split-debug.c
===
--- clang/test/Driver/split-debug.c
+++ clang/test/Driver/split-debug.c
@@ -9,6 +9,7 @@
 
 // INLINE: "-fsplit-dwarf-inlining"
 // NOINLINE-NOT: "-fsplit-dwarf-inlining"
+// SPLIT-NOT:  "-dumpdir"
 // SPLIT:  "-debug-info-kind=constructor"
 // SPLIT-SAME: "-ggnu-pubnames"
 // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo"
@@ -54,8 +55,29 @@
 // SINGLE_WITH_FILENAME: "-split-dwarf-file" "{{.*}}foo.o"
 // SINGLE_WITH_FILENAME-NOT: "-split-dwarf-output"
 
-/// Without -c, clang performs linking as well. The output is unchanged.
-// RUN: %clang -### -target x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o ignore.d 2>&1 | FileCheck %s --check-prefix=SPLIT
+/// If linking is the final phase, the .dwo filename is derived from -o (if specified) or "a".
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o obj/out 2>&1 | FileCheck %s --check-prefix=SPLIT_LINK
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT_LINK_A
+
+// SPLIT_LINK:  "-dumpdir" "obj/out-"
+// SPLIT_LINK:  "-debug-info-kind=constructor"
+// SPLIT_LINK-SAME: "-split-dwarf-file" "obj/out-split-debug.dwo" "-split-dwarf-output" "obj/out-split-debug.dwo"
+// SPLIT_LINK_A:  "-dumpdir" "a-"
+// SPLIT_LINK_A-SAME: "-split-dwarf-file" "a-split-debug.dwo" "-split-dwarf-output" "a-split-debug.dwo"
+
+/// GCC special cases /dev/null (HOST_BIT_BUCKET) but not other special files like /dev/zero.
+/// We don't apply special rules at all.
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=SPLIT_LINK_NULL
+
+// SPLIT_LINK_NULL:  "-dumpdir" "/dev/null-"
+// SPLIT_LINK_NULL-SAME: "-split-dwarf-output" "/dev/null-split-debug.dwo"
+
+/// If -dumpdir is specified, use its value to derive the .dwo filename.
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o obj/out -dumpdir pf/x -c 2>&1 | FileCheck %s --check-prefix=DUMPDIR
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o obj/out -dumpdir pf/x 2>&1 | FileCheck %s --check-prefix=DUMPDIR
+
+// DUMPDIR:  "-dumpdir" "pf/x"
+// DUMPDIR-SAME: "-split-dwarf-output" "pf/xsplit-debug.dwo"
 
 /// -fsplit-dwarf-inlining
 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=split -g -fsplit-dwarf-inlining %s 2>&1 | FileCheck %s --check-prefixes=INLINE,SPLIT
Index: clang/test/Driver/hip-gsplit-dwarf-options.hip
===
--- clang/test/Driver/hip-gsplit-dwarf-options.hip
+++ clang/test/Driver/hip-gsplit-dwarf-options.hip
@@ -13,13 +13,17 @@
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu \
 // RUN:   --offload-arch=gfx906:xnack+ %s -nogpulib -nogpuinc \
 // RUN:   --offload-arch=gfx900 \
-// RUN:   -ggdb -gsplit-dwarf 2>&1 | FileCheck %s
+// RUN:   -ggdb -gsplit-dwarf 2>&1 | FileCheck %s --check-prefix=LINK
 
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu \
 // RUN:   -fgpu-rdc --offload-arch=gfx906:xnack+ %s -nogpulib -nogpuinc \
 // RUN:   --offload-arch=gfx900 \
-// RUN:   -ggdb -gsplit-dwarf 2>&1 | FileCheck %s
+// RUN:   -ggdb -gsplit-dwarf 2>&1 | FileCheck %s --check-prefix=LINK
 
 // CHECK-DAG: {{".*clang.*".* "-target-cpu" "gfx906".* "-split-dwarf-output" "hip-gsplit-dwarf-options_gfx906:xnack\+.dwo"}}
 // CHECK-DAG: {{".*clang.*".* "-target-cpu" "gfx900".* "-split-dwarf-output" "hip-gsplit-dwarf-options_gfx900.dwo"}}
 // CHECK-DAG: {{".*clang.*".* "-target-cpu" "x86-64".* "-split-dwarf-output" "hip-gsplit-dwarf-options.dwo"}}
+
+// LINK-DAG: {{".*clang.*".* "-target-cpu" "gfx906".* "-split-dwarf-output" "a-hip-gsplit-dwarf-options_gfx906:xnack\+.dwo"}}
+// LINK-DAG: {{".*clang.*".* "-target-cpu" "gfx900".* "-split-dwarf-output" "a-hip-gsplit-dwarf-options_gfx900.dwo"}}
+// LINK-DAG: {{".*clang.*".* "-target-cpu" "x86-64".* "-split-dwarf-output" "a-hip-gsplit-dwarf-options.dwo"}}
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ 

[PATCH] D147844: [clang][Sema]Print diagnostic warning about precedence when integer expression is used without parentheses in an conditional operator expression

2023-04-25 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav added a comment.

In D147844#4293299 , @cjdb wrote:

> I think this is a good diagnostic to add: it improves readability and 
> eliminates ambiguities. My only request is that if there isn't already a 
> FixIt hint, one be added, please.

@cjb quick question, should we restrict to

  >, <, >=, <= 

I am finding lots of files in the project with ` ==` and `?:` precedence 
warnings.




Comment at: clang/test/Sema/parentheses.c:94
 
   (void)(x + y > 0 ? 1 : 2); // no warning
   (void)(x + (y > 0) ? 1 : 2); // expected-warning {{operator '?:' has lower 
precedence than '+'}} expected-note 2{{place parentheses}}

cjdb wrote:
> I think this should also warn.
@cjdb am looking into this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

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


[PATCH] D148757: [clang] Apply -fcoverage-prefix-map reverse order

2023-04-25 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem marked 2 inline comments as done.
gulfem added inline comments.



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:1638
 : CGM(CGM), SourceInfo(SourceInfo) {
-  CoveragePrefixMap = CGM.getCodeGenOpts().CoveragePrefixMap;
+  for (const auto &[From, To] : CGM.getCodeGenOpts().CoveragePrefixMap)
+CoveragePrefixMap.emplace_back(From, To);

MaskRay wrote:
> `CoveragePrefixMap` can be removed. I just removed `DebugPrefixMap` as well:)
I'm marking this `Done` as you removed it in 
https://github.com/llvm/llvm-project/commit/d3e121780ac2724969a030415f3092170f3c7589.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148757

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


[PATCH] D148757: [clang] Apply -fcoverage-prefix-map reverse order

2023-04-25 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem updated this revision to Diff 516993.
gulfem added a comment.

Added a comment about reverse traversal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148757

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Profile/coverage-prefix-map.c


Index: clang/test/Profile/coverage-prefix-map.c
===
--- clang/test/Profile/coverage-prefix-map.c
+++ clang/test/Profile/coverage-prefix-map.c
@@ -19,3 +19,13 @@
 
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-compilation-dir=/custom 
-fcoverage-prefix-map=/custom=/nonsense -o - | FileCheck 
--check-prefix=COVERAGE-COMPILATION-DIR %s
 // COVERAGE-COMPILATION-DIR: @__llvm_coverage_mapping = {{.*"\\02.*}}nonsense
+
+// Test that last -fcoverage-prefix-map option 
(-fcoverage-prefix-map==newpath) is applied.
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-prefix-map=%/t/root=. 
-fcoverage-prefix-map==newpath -o - | FileCheck 
--check-prefix=COVERAGE-PREFIX-MAP-ORDER %s
+// COVERAGE-PREFIX-MAP-ORDER: @__llvm_coverage_mapping = 
{{.*"\\02.*newpath.*root.*nested.*coverage-prefix-map\.c}}
+
+// Test that last -fcoverage-prefix-map option 
(-fcoverage-prefix-map=%/t/root=.) is applied.
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-prefix-map==newpath 
-fcoverage-prefix-map=%/t/root=. -o - | FileCheck 
--check-prefix=COVERAGE-PREFIX-MAP-REORDER %s
+// COVERAGE-PREFIX-MAP-REORDER: @__llvm_coverage_mapping =
+// COVERAGE-PREFIX-MAP-REORDER-NOT: newpath
+// COVERAGE-PREFIX-MAP-REORDER-SAME: nested{{.*coverage-prefix-map\.c}}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1701,8 +1701,7 @@
 
   for (const auto  : Args.getAllArgValues(OPT_fcoverage_prefix_map_EQ)) {
 auto Split = StringRef(Arg).split('=');
-Opts.CoveragePrefixMap.insert(
-{std::string(Split.first), std::string(Split.second)});
+Opts.CoveragePrefixMap.emplace_back(Split.first, Split.second);
   }
 
   const llvm::Triple::ArchType DebugEntryValueArchs[] = {
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1648,8 +1648,12 @@
 std::string CoverageMappingModuleGen::normalizeFilename(StringRef Filename) {
   llvm::SmallString<256> Path(Filename);
   llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
-  for (const auto  : CGM.getCodeGenOpts().CoveragePrefixMap) {
-if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second))
+
+  // Traverse coverage prefix replacement mapping options that are provided in
+  // reverse order to apply them.
+  for (const auto &[From, To] :
+   llvm::reverse(CGM.getCodeGenOpts().CoveragePrefixMap)) {
+if (llvm::sys::path::replace_path_prefix(Path, From, To))
   break;
   }
   return Path.str().str();
Index: clang/include/clang/Basic/CodeGenOptions.h
===
--- clang/include/clang/Basic/CodeGenOptions.h
+++ clang/include/clang/Basic/CodeGenOptions.h
@@ -207,7 +207,9 @@
   std::string RecordCommandLine;
 
   llvm::SmallVector, 0> DebugPrefixMap;
-  std::map CoveragePrefixMap;
+
+  /// Prefix replacement map for source-based code coverage.
+  llvm::SmallVector, 0> CoveragePrefixMap;
 
   /// The ABI to use for passing floating point arguments.
   std::string FloatABI;


Index: clang/test/Profile/coverage-prefix-map.c
===
--- clang/test/Profile/coverage-prefix-map.c
+++ clang/test/Profile/coverage-prefix-map.c
@@ -19,3 +19,13 @@
 
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c %t/root/nested/coverage-prefix-map.c -fcoverage-compilation-dir=/custom -fcoverage-prefix-map=/custom=/nonsense -o - | FileCheck --check-prefix=COVERAGE-COMPILATION-DIR %s
 // COVERAGE-COMPILATION-DIR: @__llvm_coverage_mapping = {{.*"\\02.*}}nonsense
+
+// Test that last -fcoverage-prefix-map option (-fcoverage-prefix-map==newpath) is applied.
+// RUN: %clang_cc1 -fprofile-instrument=clang 

[PATCH] D148757: [clang] Apply -fcoverage-prefix-map reverse order

2023-04-25 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem updated this revision to Diff 516989.
gulfem added a comment.

Addressed feedback and rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148757

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Profile/coverage-prefix-map.c


Index: clang/test/Profile/coverage-prefix-map.c
===
--- clang/test/Profile/coverage-prefix-map.c
+++ clang/test/Profile/coverage-prefix-map.c
@@ -19,3 +19,13 @@
 
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-compilation-dir=/custom 
-fcoverage-prefix-map=/custom=/nonsense -o - | FileCheck 
--check-prefix=COVERAGE-COMPILATION-DIR %s
 // COVERAGE-COMPILATION-DIR: @__llvm_coverage_mapping = {{.*"\\02.*}}nonsense
+
+// Test that last -fcoverage-prefix-map option 
(-fcoverage-prefix-map==newpath) is applied.
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-prefix-map=%/t/root=. 
-fcoverage-prefix-map==newpath -o - | FileCheck 
--check-prefix=COVERAGE-PREFIX-MAP-ORDER %s
+// COVERAGE-PREFIX-MAP-ORDER: @__llvm_coverage_mapping = 
{{.*"\\02.*newpath.*root.*nested.*coverage-prefix-map\.c}}
+
+// Test that last -fcoverage-prefix-map option 
(-fcoverage-prefix-map=%/t/root=.) is applied.
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-prefix-map==newpath 
-fcoverage-prefix-map=%/t/root=. -o - | FileCheck 
--check-prefix=COVERAGE-PREFIX-MAP-REORDER %s
+// COVERAGE-PREFIX-MAP-REORDER: @__llvm_coverage_mapping =
+// COVERAGE-PREFIX-MAP-REORDER-NOT: newpath
+// COVERAGE-PREFIX-MAP-REORDER-SAME: nested{{.*coverage-prefix-map\.c}}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1701,8 +1701,7 @@
 
   for (const auto  : Args.getAllArgValues(OPT_fcoverage_prefix_map_EQ)) {
 auto Split = StringRef(Arg).split('=');
-Opts.CoveragePrefixMap.insert(
-{std::string(Split.first), std::string(Split.second)});
+Opts.CoveragePrefixMap.emplace_back(Split.first, Split.second);
   }
 
   const llvm::Triple::ArchType DebugEntryValueArchs[] = {
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1648,8 +1648,9 @@
 std::string CoverageMappingModuleGen::normalizeFilename(StringRef Filename) {
   llvm::SmallString<256> Path(Filename);
   llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
-  for (const auto  : CGM.getCodeGenOpts().CoveragePrefixMap) {
-if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second))
+  for (const auto &[From, To] :
+   llvm::reverse(CGM.getCodeGenOpts().CoveragePrefixMap)) {
+if (llvm::sys::path::replace_path_prefix(Path, From, To))
   break;
   }
   return Path.str().str();
Index: clang/include/clang/Basic/CodeGenOptions.h
===
--- clang/include/clang/Basic/CodeGenOptions.h
+++ clang/include/clang/Basic/CodeGenOptions.h
@@ -207,7 +207,9 @@
   std::string RecordCommandLine;
 
   llvm::SmallVector, 0> DebugPrefixMap;
-  std::map CoveragePrefixMap;
+
+  /// Prefix replacement map for source-based code coverage.
+  llvm::SmallVector, 0> CoveragePrefixMap;
 
   /// The ABI to use for passing floating point arguments.
   std::string FloatABI;


Index: clang/test/Profile/coverage-prefix-map.c
===
--- clang/test/Profile/coverage-prefix-map.c
+++ clang/test/Profile/coverage-prefix-map.c
@@ -19,3 +19,13 @@
 
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c %t/root/nested/coverage-prefix-map.c -fcoverage-compilation-dir=/custom -fcoverage-prefix-map=/custom=/nonsense -o - | FileCheck --check-prefix=COVERAGE-COMPILATION-DIR %s
 // COVERAGE-COMPILATION-DIR: @__llvm_coverage_mapping = {{.*"\\02.*}}nonsense
+
+// Test that last -fcoverage-prefix-map option (-fcoverage-prefix-map==newpath) is applied.
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 

[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-04-25 Thread Dan Liew via Phabricator via cfe-commits
delcypher added inline comments.



Comment at: 
clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected:12
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[X]], align 4
+// CHECK-NEXT:ret i32 [[TMP1]]
+//

@hnrklssn I just noticed we don't have a `CHECK` for what `META2` actually 
refers to. Should we?

Not something that has to be fixed in this patch, more just an observation.



Comment at: llvm/utils/UpdateTestChecks/common.py:703
   def get_ir_prefix_from_ir_value_match(self, match):
-return self.ir_prefix, self.check_prefix
+return re.search(self.ir_prefix, match[0])[0], self.check_prefix
 

Is this call to `re.search(...)` guaranteed to always succeed?



Comment at: llvm/utils/UpdateTestChecks/common.py:779
 NamelessValue(r'ACC_GRP', '!' , r'!llvm.access.group ' , r'![0-9]+'
 , None ) ,
+NamelessValue(r'META'   , '!' , r'![a-z.]+ '   , r'![0-9]+'
 , None ) ,
 ]

There may be some value in having `!annotations` matched explicitly as well as 
there being a fallback. In the current patch it looks like:

* `metadata` is assigned variables with the `META` prefix on `CHECK` lines
* `!annotation` is assigned variables with the `META` prefix on `CHECK` lines
* Anything else that matches `r'![a-z.]+ ' `  is assigned variables with the 
`META` prefix on `CHECK` lines

When looking a large test having everything lumped into `META` variables could 
make the generated tests a little harder to read.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

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


[PATCH] D149210: [IR] Change shufflevector undef mask to poison

2023-04-25 Thread LiDongjin via Phabricator via cfe-commits
LiDongjin added inline comments.



Comment at: llvm/include/llvm-c/Core.h:4088
  * \returns a constant that specifies that the result of a \c ShuffleVectorInst
  * is undefined.
  */

undefined to poison


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149210

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


[PATCH] D149215: [MemProf] Control availability of hot/cold operator new from LTO link

2023-04-25 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

This was refactored out of patch 3 (the applyImport stuff that I refactored 
into patch 4 in D149117 ). Previously I was 
controlling this behavior via the MemProfContextDisambiguation pass itself, but 
in refactoring I realized that it is much cleaner and more sensible to be 
controlling it separately via LTO. I also realized it wasn't being tested, so 
added some new tests here.




Comment at: llvm/test/ThinLTO/X86/memprof-basic.ll:80
 
-;; Try again but with distributed ThinLTO
-; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \

Ignore this and similar differences, need to rebase this on top of my more 
recent version of D149117 that removed these duplicate invocations of test RUN 
lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149215

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


[PATCH] D149193: [Driver] -gsplit-dwarf: derive .dwo names from -o for link actions

2023-04-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 516980.
MaskRay edited the summary of this revision.
MaskRay added a comment.
Herald added a subscriber: ormris.

add notes and more test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149193

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/hip-gsplit-dwarf-options.hip
  clang/test/Driver/split-debug.c

Index: clang/test/Driver/split-debug.c
===
--- clang/test/Driver/split-debug.c
+++ clang/test/Driver/split-debug.c
@@ -9,6 +9,7 @@
 
 // INLINE: "-fsplit-dwarf-inlining"
 // NOINLINE-NOT: "-fsplit-dwarf-inlining"
+// SPLIT-NOT:  "-dumpdir"
 // SPLIT:  "-debug-info-kind=constructor"
 // SPLIT-SAME: "-ggnu-pubnames"
 // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo"
@@ -54,8 +55,22 @@
 // SINGLE_WITH_FILENAME: "-split-dwarf-file" "{{.*}}foo.o"
 // SINGLE_WITH_FILENAME-NOT: "-split-dwarf-output"
 
-/// Without -c, clang performs linking as well. The output is unchanged.
-// RUN: %clang -### -target x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o ignore.d 2>&1 | FileCheck %s --check-prefix=SPLIT
+/// If linking is the final phase, the .dwo filename is derived from -o (if specified) or "a".
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o obj/out 2>&1 | FileCheck %s --check-prefix=SPLIT_LINK
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT_LINK_A
+
+// SPLIT_LINK:  "-dumpdir" "obj/out-"
+// SPLIT_LINK:  "-debug-info-kind=constructor"
+// SPLIT_LINK-SAME: "-split-dwarf-file" "obj/out-split-debug.dwo" "-split-dwarf-output" "obj/out-split-debug.dwo"
+// SPLIT_LINK_A:  "-dumpdir" "a-"
+// SPLIT_LINK_A-SAME: "-split-dwarf-file" "a-split-debug.dwo" "-split-dwarf-output" "a-split-debug.dwo"
+
+/// GCC special cases /dev/null (HOST_BIT_BUCKET) but not other special files like /dev/zero.
+/// We don't apply special rules at all.
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=SPLIT_LINK_NULL
+
+// SPLIT_LINK_NULL:  "-dumpdir" "/dev/null-"
+// SPLIT_LINK_NULL-SAME: "-split-dwarf-output" "/dev/null-split-debug.dwo"
 
 /// -fsplit-dwarf-inlining
 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=split -g -fsplit-dwarf-inlining %s 2>&1 | FileCheck %s --check-prefixes=INLINE,SPLIT
Index: clang/test/Driver/hip-gsplit-dwarf-options.hip
===
--- clang/test/Driver/hip-gsplit-dwarf-options.hip
+++ clang/test/Driver/hip-gsplit-dwarf-options.hip
@@ -13,13 +13,17 @@
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu \
 // RUN:   --offload-arch=gfx906:xnack+ %s -nogpulib -nogpuinc \
 // RUN:   --offload-arch=gfx900 \
-// RUN:   -ggdb -gsplit-dwarf 2>&1 | FileCheck %s
+// RUN:   -ggdb -gsplit-dwarf 2>&1 | FileCheck %s --check-prefix=LINK
 
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu \
 // RUN:   -fgpu-rdc --offload-arch=gfx906:xnack+ %s -nogpulib -nogpuinc \
 // RUN:   --offload-arch=gfx900 \
-// RUN:   -ggdb -gsplit-dwarf 2>&1 | FileCheck %s
+// RUN:   -ggdb -gsplit-dwarf 2>&1 | FileCheck %s --check-prefix=LINK
 
 // CHECK-DAG: {{".*clang.*".* "-target-cpu" "gfx906".* "-split-dwarf-output" "hip-gsplit-dwarf-options_gfx906:xnack\+.dwo"}}
 // CHECK-DAG: {{".*clang.*".* "-target-cpu" "gfx900".* "-split-dwarf-output" "hip-gsplit-dwarf-options_gfx900.dwo"}}
 // CHECK-DAG: {{".*clang.*".* "-target-cpu" "x86-64".* "-split-dwarf-output" "hip-gsplit-dwarf-options.dwo"}}
+
+// LINK-DAG: {{".*clang.*".* "-target-cpu" "gfx906".* "-split-dwarf-output" "a-hip-gsplit-dwarf-options_gfx906:xnack\+.dwo"}}
+// LINK-DAG: {{".*clang.*".* "-target-cpu" "gfx900".* "-split-dwarf-output" "a-hip-gsplit-dwarf-options_gfx900.dwo"}}
+// LINK-DAG: {{".*clang.*".* "-target-cpu" "x86-64".* "-split-dwarf-output" "a-hip-gsplit-dwarf-options.dwo"}}
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1248,23 +1248,21 @@
 if (StringRef(A->getValue()) == "single")
   return Args.MakeArgString(Output.getFilename());
 
+  SmallString<128> T;
   Arg *FinalOutput = Args.getLastArg(options::OPT_o);
   if (FinalOutput && Args.hasArg(options::OPT_c)) {
-SmallString<128> T(FinalOutput->getValue());
+T = FinalOutput->getValue();
 llvm::sys::path::remove_filename(T);
 llvm::sys::path::append(T, llvm::sys::path::stem(FinalOutput->getValue()));
 AddPostfix(T);
 return Args.MakeArgString(T);
-  } else {
-// Use the compilation dir.
-Arg *A = 

[PATCH] D149205: [Headers][doc] Add "gather" intrinsic descriptions to avx2intrin.h

2023-04-25 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n accepted this revision.
goldstein.w.n added a comment.
This revision is now accepted and ready to land.

LGTM. I'm not a maintainer so wait a day to push so others can take a look.




Comment at: clang/lib/Headers/avx2intrin.h:789
 
-
 static __inline__ __m128i __DEFAULT_FN_ATTRS128

Remove extrenous change?


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

https://reviews.llvm.org/D149205

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


[PATCH] D149215: [MemProf] Control availability of hot/cold operator new from LTO link

2023-04-25 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added a reviewer: snehasish.
Herald added subscribers: hoy, ormris, arphaman, steven_wu, hiraditya, 
inglorion.
Herald added a project: All.
tejohnson requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

Adds an LTO option to indicate that whether we are linking with an
allocator that supports hot/cold operator new interfaces. If not,
at the start of the LTO backends any existing memprof hot/cold
attributes are removed from the IR, and we also remove memprof metadata
so that post-LTO inlining doesn't add any new attributes. This is done
via setting a new flag in the module summary index. It is important to
communicate via the index to the LTO backends so distributed ThinLTO
handles this correctly, as it is invoked by a separate process and the
combined index is how we communicate information from the LTO link.

Additionally, when the LTO option is disabled, exit early from the
MemProfContextDisambiguation handling performed during LTO, as this is
unnecessary.

Depends on D149117  and D149192 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149215

Files:
  clang/test/CodeGen/thinlto-distributed-supports-hot-cold-new.ll
  llvm/include/llvm/IR/ModuleSummaryIndex.h
  llvm/include/llvm/LTO/LTO.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/IR/ModuleSummaryIndex.cpp
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
  llvm/test/LTO/X86/memprof-supports-hot-cold-new.ll
  llvm/test/ThinLTO/X86/memprof-basic.ll
  llvm/test/ThinLTO/X86/memprof-duplicate-context-ids.ll
  llvm/test/ThinLTO/X86/memprof-duplicate-context-ids2.ll
  llvm/test/ThinLTO/X86/memprof-funcassigncloning.ll
  llvm/test/ThinLTO/X86/memprof-indirectcall.ll
  llvm/test/ThinLTO/X86/memprof-inlined.ll
  llvm/test/ThinLTO/X86/memprof-inlined2.ll
  llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll
  llvm/test/Transforms/MemProfContextDisambiguation/basic.ll
  llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids.ll
  llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids2.ll
  llvm/test/Transforms/MemProfContextDisambiguation/funcassigncloning.ll
  llvm/test/Transforms/MemProfContextDisambiguation/indirectcall.ll
  llvm/test/Transforms/MemProfContextDisambiguation/inlined.ll
  llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll

Index: llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll
@@ -42,7 +42,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:	-memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; RUN:	%s -S 2>&1 | FileCheck %s --check-prefix=DUMP
 
Index: llvm/test/Transforms/MemProfContextDisambiguation/inlined.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/inlined.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/inlined.ll
@@ -41,7 +41,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:	-memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; RUN:	-memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \
 ; RUN:  -stats -pass-remarks=memprof-context-disambiguation \
Index: llvm/test/Transforms/MemProfContextDisambiguation/indirectcall.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/indirectcall.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/indirectcall.ll
@@ -51,7 +51,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:  -memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; RUN:  -memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \
 ; RUN:  -stats -pass-remarks=memprof-context-disambiguation \
Index: llvm/test/Transforms/MemProfContextDisambiguation/funcassigncloning.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/funcassigncloning.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/funcassigncloning.ll
@@ -45,7 +45,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt 

[PATCH] D149193: [Driver] -gsplit-dwarf: derive .dwo names from -o for link actions

2023-04-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D149193#4297043 , @scott.linder 
wrote:

> I'm a bit confused after trying to work out the rules for the GCC version of 
> `-dumpdir` over at 
> https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#index-dumpdir but it 
> at least seems like our version is a subset of theirs.

Yes, it's quite complex I think we'll just port the reasonable subset of 
rules (like `clang -g -gsplit-dwarf a.c b.c -o out`, but not the more complex 
ones)...

It seems that `-dumpdir` is the most useful option. `-dumpbase` appends a `-`, 
which can be undesired, if we intend to expose an option to place auxiliary 
files.

  gcc -g -gsplit-dwarf -dumpdir f a.c => fa.dwo
  gcc -g -gsplit-dwarf -dumpdir f/ a.c => f/a.dwo
  gcc -g -gsplit-dwarf -dumpbase f a.c => f-a.dwo
  gcc -g -gsplit-dwarf -dumpbase f/ a.c => f/-a.dwo

What's more complex is that `-dumpdir` and `-dumpbase` can be used together. I 
have played a bit and haven't thought of a case that the combination is useful.

> Do we support any of the other `-dump*` options GCC does? E.g. 
> https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#index-dumpbase and 
> https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#index-dumpbase-ext ? 
> I don't think we need to in order to add and use `-dumpdir`, but they do have 
> a somewhat unique inter-dependence in that the exact value of one can cause 
> another to be completely ignored.

We don't. Having just `-dumpdir` perhaps will be useful enough when we make 
`-save-temps` inter-operate with `-dumpdir` (control `*.i`, `*.s`, `*.bc`, etc)

> Also, would it be worth adding tests for the following cases:
>
>> It defaults to the location of the output file, unless the output file is a 
>> special file like /dev/null. Options -save-temps=cwd and -save-temps=obj 
>> override this default, just like an explicit -dumpdir option. In case 
>> multiple such options are given, the last one prevails:

GCC special cases `/dev/null`, but it doesn't treat other special files 
differently.

  gcc -g -gsplit-dwarf a.c -o /dev/null  # a.dwo
  gcc -g -gsplit-dwarf a.c -o /dev/zero  # /dev/zero-a.dwo (likely fail to 
create)
  gcc -g -gsplit-dwarf a.c -o /dev/zero -save-temp=obj  # /dev/null-a.i (likely 
fail to create)

I suggest that we don't have the special rule.

  clang -g -gsplit-dwarf a.c -o /dev/null  # /dev/null-a.dwo (likely fail to 
create)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149193

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


[PATCH] D148601: [Clang] Handle Error message to output proper Prefix

2023-04-25 Thread Usman Akinyemi via Phabricator via cfe-commits
Unique_Usman added a comment.

In D148601#4295719 , @tbaeder wrote:

> In D148601#4279604 , @Unique_Usman 
> wrote:
>
>> In D148601#4279334 , @tbaeder 
>> wrote:
>>
>>> I am not 100% sure about the semantics of passing multiple prefixes, i.e. 
>>> if the error is emitted for all prefixes individually or if it's only 
>>> emitted if no `expected` line for any of the prefixes is found. In the 
>>> latter case we should probably add all the prefixes to the error message.
>>
>> I tested different scenerios e.g added more than one RUN lines with 
>> different value of -verify, what I concluded on is that if we have multiple  
>> RUN lines with each of them having no directive, the prefixes generated is 
>> always of the first occurence  with no  expected directive so, the error is 
>> always generated for the first occurence with no expected directive.
>
> Yeah but I think you can do `-verify=foo,bar`(?) in which case the list f 
> prefixes would actually have more than one item.

I used -verify=foo,bar but, the prefixes still have just only one item, in the 
case bar. Does this the implementation of getting the prefixes is faulty?


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

https://reviews.llvm.org/D148601

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


[PATCH] D149210: [IR] Change shufflevector undef mask to poison

2023-04-25 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito created this revision.
ManuelJBrito added reviewers: aqjune, efriedma, RKSimon, nikic, nlopes, spatel.
Herald added a reviewer: deadalnix.
Herald added subscribers: luke, kosarev, StephenFan, frasercrmck, okura, kuter, 
lebedev.ri, kerbowa, luismarques, apazos, sameer.abuasal, pengfei, s.egerton, 
dmgreen, Jim, jocewei, PkmX, arphaman, the_o, brucehoult, MartinMosbeck, 
rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, 
rbar, asb, kbarton, hiraditya, jvesely, nemanjai.
Herald added a reviewer: lebedev.ri.
Herald added a project: All.
ManuelJBrito requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added projects: clang, LLVM.

With this patch an undefined mask in a shufflevector will be printed as poison.
This change is done to support the new shufflevector semantics for undefined 
mask elements (see  D148637 ).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149210

Files:
  clang/test/CodeGen/PowerPC/builtins-ppc-p10vector.c
  clang/test/CodeGen/PowerPC/builtins-ppc-p9vector.c
  clang/test/CodeGen/builtins-nondeterministic-value.c
  clang/test/CodeGen/builtinshufflevector2.c
  clang/test/CodeGen/ext-vector.c
  clang/test/CodeGenOpenCL/as_type.cl
  clang/test/CodeGenOpenCL/partial_initializer.cl
  clang/test/CodeGenOpenCL/preserve_vec3.cl
  clang/test/CodeGenOpenCL/vector_literals.cl
  clang/test/CodeGenOpenCL/vector_shufflevector.cl
  llvm/include/llvm-c/Core.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/IR/Instructions.h
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/Analysis/VectorUtils.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
  llvm/lib/Target/X86/X86TargetTransformInfo.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
  llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/lib/Transforms/Vectorize/VectorCombine.cpp
  llvm/test/Analysis/CostModel/RISCV/shuffle-extract_subvector.ll
  llvm/test/Analysis/CostModel/RISCV/shuffle-insert_subvector.ll
  llvm/test/Analysis/CostModel/X86/reduction.ll
  llvm/test/Analysis/CostModel/X86/shuffle-extract_subvector-codesize.ll
  llvm/test/Analysis/CostModel/X86/shuffle-extract_subvector-latency.ll
  llvm/test/Analysis/CostModel/X86/shuffle-extract_subvector-sizelatency.ll
  llvm/test/Analysis/CostModel/X86/shuffle-extract_subvector.ll
  llvm/test/Analysis/CostModel/X86/shuffle-insert_subvector-codesize.ll
  llvm/test/Analysis/CostModel/X86/shuffle-insert_subvector-latency.ll
  llvm/test/Analysis/CostModel/X86/shuffle-insert_subvector-sizelatency.ll
  llvm/test/Analysis/CostModel/X86/shuffle-insert_subvector.ll
  llvm/test/Analysis/CostModel/X86/shuffle-single-src-codesize.ll
  llvm/test/Analysis/CostModel/X86/shuffle-single-src-latency.ll
  llvm/test/Analysis/CostModel/X86/shuffle-single-src-sizelatency.ll
  llvm/test/Analysis/CostModel/X86/shuffle-single-src.ll
  llvm/test/CodeGen/AMDGPU/amdgpu-codegenprepare-break-large-phis-heuristics.ll
  llvm/test/CodeGen/AMDGPU/rewrite-out-arguments.ll
  llvm/test/CodeGen/Generic/expand-experimental-reductions.ll
  llvm/test/CodeGen/PowerPC/arg_promotion.ll
  llvm/test/Instrumentation/MemorySanitizer/avx-intrinsics-x86.ll
  llvm/test/Transforms/Attributor/nofpclass.ll
  llvm/test/Transforms/CodeGenPrepare/X86/x86-shuffle-sink-inseltpoison.ll
  llvm/test/Transforms/CodeGenPrepare/X86/x86-shuffle-sink.ll
  llvm/test/Transforms/DeadStoreElimination/masked-dead-store-inseltpoison.ll
  llvm/test/Transforms/DeadStoreElimination/masked-dead-store.ll
  llvm/test/Transforms/InstCombine/AArch64/demandelts.ll
  
llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-demanded-vector-elts-inseltpoison.ll
  llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-demanded-vector-elts.ll
  llvm/test/Transforms/InstCombine/X86/x86-addsub-inseltpoison.ll
  llvm/test/Transforms/InstCombine/X86/x86-addsub.ll
  llvm/test/Transforms/InstCombine/X86/x86-avx2-inseltpoison.ll
  llvm/test/Transforms/InstCombine/X86/x86-avx2.ll
  llvm/test/Transforms/InstCombine/X86/x86-avx512-inseltpoison.ll
  llvm/test/Transforms/InstCombine/X86/x86-avx512.ll
  llvm/test/Transforms/InstCombine/X86/x86-muldq-inseltpoison.ll
  llvm/test/Transforms/InstCombine/X86/x86-muldq.ll
  llvm/test/Transforms/InstCombine/X86/x86-pack-inseltpoison.ll
  

[PATCH] D149193: [Driver] -gsplit-dwarf: derive .dwo names from -o for link actions

2023-04-25 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

I'm a bit confused after trying to work out the rules for the GCC version of 
`-dumpdir` over at 
https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#index-dumpdir but it at 
least seems like our version is a subset of theirs.

Do we support any of the other `-dump*` options GCC does? E.g. 
https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#index-dumpbase and 
https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#index-dumpbase-ext ? I 
don't think we need to in order to add and use `-dumpdir`, but they do have a 
somewhat unique inter-dependence in that the exact value of one can cause 
another to be completely ignored.

Also, would it be worth adding tests for the following cases:

> It defaults to the location of the output file, unless the output file is a 
> special file like /dev/null. Options -save-temps=cwd and -save-temps=obj 
> override this default, just like an explicit -dumpdir option. In case 
> multiple such options are given, the last one prevails:




Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1250-1267
 
+  SmallString<128> T;
+  if (const Arg *A = Args.getLastArg(options::OPT_dumpdir))
+T = A->getValue();
+
   Arg *FinalOutput = Args.getLastArg(options::OPT_o);
   if (FinalOutput && Args.hasArg(options::OPT_c)) {

There is an extra check for `dumpdir` and a string copy in the `OPT_c` case, 
maybe it can just move past that case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149193

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


[PATCH] D125272: [clang] Add -fcheck-new support

2023-04-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:4117
+  if (const Arg *A = Args.getLastArg(OPT_fcheck_new))
+Opts.CheckNew = true;
+

heatd wrote:
> MaskRay wrote:
> > Use `CodeGenOpts<"CheckNew">` and avoid change to this file. CodeGenOpts 
> > seems more suitable than LangOpts.
> Sorry, I haven't looked at this rev in a good while due to $REASONS. Could 
> you elaborate on this? I'm not opposed to moving it to CodeGenOpts per se, 
> but I would like to understand your reasoning. It seems to me that fcheck-new 
> is more of a language change (since it removes the implicit [[nonnull]] on 
> the result of operator new) than a codegen change, although it does have its 
> effects on codegen, naturally. A quick look at CodeGenOpts in Options.td 
> would hint to me that these mostly/only affect codegen itself. What do you 
> think? 
OK. LangOpts looks good since it affects Sema and in GCC this option is a C++ 
dialect option 
(https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html).

Can you use `MarshallingInfoFlaghttps://reviews.llvm.org/D125272/new/

https://reviews.llvm.org/D125272

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


[clang] d3e1217 - [CodeGen] Remove unneeded CoveragePrefixMap. NFC

2023-04-25 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-04-25T15:21:15-07:00
New Revision: d3e121780ac2724969a030415f3092170f3c7589

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

LOG: [CodeGen] Remove unneeded CoveragePrefixMap. NFC

Added: 


Modified: 
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/CodeGen/CoverageMappingGen.h

Removed: 




diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index bac01c7ff67f..273d991c16c7 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1634,9 +1634,7 @@ static void dump(llvm::raw_ostream , StringRef 
FunctionName,
 
 CoverageMappingModuleGen::CoverageMappingModuleGen(
 CodeGenModule , CoverageSourceInfo )
-: CGM(CGM), SourceInfo(SourceInfo) {
-  CoveragePrefixMap = CGM.getCodeGenOpts().CoveragePrefixMap;
-}
+: CGM(CGM), SourceInfo(SourceInfo) {}
 
 std::string CoverageMappingModuleGen::getCurrentDirname() {
   if (!CGM.getCodeGenOpts().CoverageCompilationDir.empty())
@@ -1650,7 +1648,7 @@ std::string CoverageMappingModuleGen::getCurrentDirname() 
{
 std::string CoverageMappingModuleGen::normalizeFilename(StringRef Filename) {
   llvm::SmallString<256> Path(Filename);
   llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
-  for (const auto  : CoveragePrefixMap) {
+  for (const auto  : CGM.getCodeGenOpts().CoveragePrefixMap) {
 if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second))
   break;
   }

diff  --git a/clang/lib/CodeGen/CoverageMappingGen.h 
b/clang/lib/CodeGen/CoverageMappingGen.h
index f5282601b640..eca68d9abd79 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.h
+++ b/clang/lib/CodeGen/CoverageMappingGen.h
@@ -107,7 +107,6 @@ class CoverageMappingModuleGen {
   llvm::SmallDenseMap FileEntries;
   std::vector FunctionNames;
   std::vector FunctionRecords;
-  std::map CoveragePrefixMap;
 
   std::string getCurrentDirname();
   std::string normalizeFilename(StringRef Filename);



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


[PATCH] D148757: [clang] Apply -fcoverage-prefix-map reverse order

2023-04-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

LGTM




Comment at: clang/include/clang/Basic/CodeGenOptions.h:211
+
+  /// Prefix replacement map for coverage.
+  llvm::SmallVector, 0> CoveragePrefixMap;

While adding a comment, clarify what coverage it is? There are multiple 
coverage instrumentation features in Clang.



Comment at: clang/lib/CodeGen/CoverageMappingGen.cpp:1638
 : CGM(CGM), SourceInfo(SourceInfo) {
-  CoveragePrefixMap = CGM.getCodeGenOpts().CoveragePrefixMap;
+  for (const auto &[From, To] : CGM.getCodeGenOpts().CoveragePrefixMap)
+CoveragePrefixMap.emplace_back(From, To);

`CoveragePrefixMap` can be removed. I just removed `DebugPrefixMap` as well:)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148757

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


[PATCH] D145441: [AMDGPU] Define data layout entries for buffers

2023-04-25 Thread Krzysztof Drewniak via Phabricator via cfe-commits
krzysz00 updated this revision to Diff 516953.
krzysz00 edited the summary of this revision.
krzysz00 added a comment.

Make address space 8 non-integral as well because that's a good idea and we'll 
have an address space cast intrinsic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145441

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/test/CodeGen/target-data.c
  clang/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl
  llvm/docs/AMDGPUUsage.rst
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/AMDGPU/AMDGPU.h
  llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.f32-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.f32-rtn.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.f64.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.v2f16-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.v2f16-rtn.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-non-integral-address-spaces.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.atomic.dim.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.dim.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.2d.d16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.2d.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.2darraymsaa.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.3d.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.d.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.g16.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.g16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.store.2d.d16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.image.atomic.dim.mir
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.add.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.cmpswap.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.fadd-with-ret.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.fadd.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.load.format.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.load.format.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.store.format.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.store.format.f32.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.store.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.load.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.store.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.store.i8.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.store.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.add.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.cmpswap.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.fadd-with-ret.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.fadd.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.load.format.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.load.format.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.load.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.store.format.f16.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.store.format.f32.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.store.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.tbuffer.load.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.tbuffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.image.load.1d.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.image.sample.1d.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.raw.buffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.struct.buffer.load.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.struct.buffer.store.ll
  llvm/test/CodeGen/AMDGPU/addrspacecast-captured.ll
  llvm/test/CodeGen/AMDGPU/annotate-kernel-features-hsa.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f32-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f32-rtn.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f64.ll
  

[PATCH] D148975: -fdebug-prefix-map=: make the last win when multiple prefixes match

2023-04-25 Thread Fangrui Song via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdaad48d6b236: -fdebug-prefix-map=: make the last win when 
multiple prefixes match (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148975

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-prefix-map.c
  clang/tools/driver/cc1as_main.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/lib/MC/MCContext.cpp
  llvm/test/MC/ELF/debug-prefix-map.s

Index: llvm/test/MC/ELF/debug-prefix-map.s
===
--- llvm/test/MC/ELF/debug-prefix-map.s
+++ llvm/test/MC/ELF/debug-prefix-map.s
@@ -14,9 +14,13 @@
 # RUN: cd %t.foo/bar
 # RUN: llvm-mc -triple=x86_64 -g -dwarf-version=4 %t.foo%{fs-sep}bar%{fs-sep}src.s -filetype=obj -o mapabs.4.o -fdebug-prefix-map=%t.foo=/broken_root -fdebug-prefix-map=%t.foo%{fs-sep}bar=/src_root
 # RUN: llvm-dwarfdump -v -debug-info -debug-line mapabs.4.o | FileCheck --check-prefix=MAPABS_V4 %s
-# RUN: llvm-mc -triple=x86_64 -g -dwarf-version=5 %t.foo%{fs-sep}bar%{fs-sep}src.s -filetype=obj -o mapabs.5.o -fdebug-prefix-map=%t.foo%{fs-sep}bar=/src_root -fdebug-prefix-map=%t.foo=/broken_root
+# RUN: llvm-mc -triple=x86_64 -g -dwarf-version=5 %t.foo%{fs-sep}bar%{fs-sep}src.s -filetype=obj -o mapabs.5.o -fdebug-prefix-map=%t.foo=/broken_root -fdebug-prefix-map=%t.foo%{fs-sep}bar=/src_root
 # RUN: llvm-dwarfdump -v -debug-info -debug-line mapabs.5.o | FileCheck --check-prefix=MAPABS_V5 %s
 
+## The last -fdebug-prefix-map= wins even if the prefix is shorter.
+# RUN: llvm-mc -triple=x86_64 -g -dwarf-version=5 %t.foo%{fs-sep}bar%{fs-sep}src.s -filetype=obj -o mapabs.5.o -fdebug-prefix-map=%t.foo%{fs-sep}bar=/broken_root -fdebug-prefix-map=%t.foo=/src_root
+# RUN: llvm-dwarfdump -v -debug-info -debug-line mapabs.5.o | FileCheck --check-prefix=MAPABS_V5_A %s
+
 f:
   nop
 
@@ -46,3 +50,6 @@
 # MAPABS_V5:  DW_AT_comp_dir [DW_FORM_string] ("{{(/|\\)+}}src_root")
 # MAPABS_V5:  DW_AT_decl_file [DW_FORM_data4] ("/src_root{{(/|\\)+}}src.s")
 # MAPABS_V5:  include_directories[ 0] = .debug_line_str[0x] = "/src_root"
+
+# MAPABS_V5_A:DW_AT_comp_dir [DW_FORM_string] ("{{(/|\\)+}}src_root/bar")
+# MAPABS_V5_A:DW_AT_decl_file [DW_FORM_data4] ("/src_root{{(/|\\)+}}bar{{(/|\\)+}}src.s")
Index: llvm/lib/MC/MCContext.cpp
===
--- llvm/lib/MC/MCContext.cpp
+++ llvm/lib/MC/MCContext.cpp
@@ -881,11 +881,11 @@
 
 void MCContext::addDebugPrefixMapEntry(const std::string ,
const std::string ) {
-  DebugPrefixMap.insert(std::make_pair(From, To));
+  DebugPrefixMap.emplace_back(From, To);
 }
 
 void MCContext::remapDebugPath(SmallVectorImpl ) {
-  for (const auto &[From, To] : DebugPrefixMap)
+  for (const auto &[From, To] : llvm::reverse(DebugPrefixMap))
 if (llvm::sys::path::replace_path_prefix(Path, From, To))
   break;
 }
Index: llvm/include/llvm/MC/MCContext.h
===
--- llvm/include/llvm/MC/MCContext.h
+++ llvm/include/llvm/MC/MCContext.h
@@ -190,7 +190,7 @@
   SmallString<128> CompilationDir;
 
   /// Prefix replacement map for source file information.
-  std::map> DebugPrefixMap;
+  SmallVector, 0> DebugPrefixMap;
 
   /// The main file name if passed in explicitly.
   std::string MainFileName;
Index: clang/tools/driver/cc1as_main.cpp
===
--- clang/tools/driver/cc1as_main.cpp
+++ clang/tools/driver/cc1as_main.cpp
@@ -97,7 +97,7 @@
   std::string DwarfDebugFlags;
   std::string DwarfDebugProducer;
   std::string DebugCompilationDir;
-  std::map DebugPrefixMap;
+  llvm::SmallVector, 0> DebugPrefixMap;
   llvm::DebugCompressionType CompressDebugSections =
   llvm::DebugCompressionType::None;
   std::string MainFileName;
@@ -275,8 +275,7 @@
 
   for (const auto  : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) {
 auto Split = StringRef(Arg).split('=');
-Opts.DebugPrefixMap.insert(
-{std::string(Split.first), std::string(Split.second)});
+Opts.DebugPrefixMap.emplace_back(Split.first, Split.second);
   }
 
   // Frontend Options
Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -9,6 +9,10 @@
 // RUN: %clang -g -fdebug-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
 // RUN: %clang -g -ffile-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | 

[clang] daad48d - -fdebug-prefix-map=: make the last win when multiple prefixes match

2023-04-25 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-04-25T15:12:17-07:00
New Revision: daad48d6b236d74c6b29daebba46289b98104241

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

LOG: -fdebug-prefix-map=: make the last win when multiple prefixes match

For
`clang -c -g -fdebug-prefix-map=a/b=y -fdebug-prefix-map=a=x a/b/c.c`,
we apply the longest prefix substitution, but
GCC has always been picking the last applicable option (`a=x`, see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109591).

I feel that GCC's behavior is reasonable given the convention that the last
value wins for the same option.

Before D49466, Clang appeared to apply the shortest prefix substitution,
which likely made the least sense.

Reviewed By: #debug-info, scott.linder

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

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/debug-prefix-map.c
clang/tools/driver/cc1as_main.cpp
llvm/include/llvm/MC/MCContext.h
llvm/lib/MC/MCContext.cpp
llvm/test/MC/ELF/debug-prefix-map.s

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 6192d3fafd411..662271fc025d4 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -206,7 +206,7 @@ class CodeGenOptions : public CodeGenOptionsBase {
   /// if non-empty.
   std::string RecordCommandLine;
 
-  std::map DebugPrefixMap;
+  llvm::SmallVector, 0> DebugPrefixMap;
   std::map CoveragePrefixMap;
 
   /// The ABI to use for passing floating point arguments.

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index eb48c142e84dd..c8f505a92a7c8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3218,7 +3218,8 @@ def fdebug_default_version: Joined<["-"], 
"fdebug-default-version=">, Group;
+MetaVarName<"=">,
+HelpText<"For paths in debug info, remap directory  to . If 
multiple options match a path, the last option wins">;
 def fcoverage_prefix_map_EQ
   : Joined<["-"], "fcoverage-prefix-map=">, Group,
 Flags<[CC1Option]>,

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 5100d6c65baa4..2cf7b025744ac 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -73,8 +73,6 @@ CGDebugInfo::CGDebugInfo(CodeGenModule )
 : CGM(CGM), DebugKind(CGM.getCodeGenOpts().getDebugInfo()),
   DebugTypeExtRefs(CGM.getCodeGenOpts().DebugTypeExtRefs),
   DBuilder(CGM.getModule()) {
-  for (const auto  : CGM.getCodeGenOpts().DebugPrefixMap)
-DebugPrefixMap[KV.first] = KV.second;
   CreateCompileUnit();
 }
 
@@ -470,12 +468,9 @@ llvm::DIFile *CGDebugInfo::createFile(
 }
 
 std::string CGDebugInfo::remapDIPath(StringRef Path) const {
-  if (DebugPrefixMap.empty())
-return Path.str();
-
   SmallString<256> P = Path;
-  for (const auto  : DebugPrefixMap)
-if (llvm::sys::path::replace_path_prefix(P, Entry.first, Entry.second))
+  for (auto &[From, To] : llvm::reverse(CGM.getCodeGenOpts().DebugPrefixMap))
+if (llvm::sys::path::replace_path_prefix(P, From, To))
   break;
   return P.str().str();
 }

diff  --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 5a3839d7f3946..5c42d3620bdbd 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -86,9 +86,6 @@ class CGDebugInfo {
   /// Cache of previously constructed Types.
   llvm::DenseMap TypeCache;
 
-  std::map>
-  DebugPrefixMap;
-
   /// Cache that maps VLA types to size expressions for that type,
   /// represented by instantiated Metadata nodes.
   llvm::SmallDenseMap SizeExprCache;

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 71204debce13d..a1481365daf98 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1696,8 +1696,7 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions 
, ArgList ,
 
   for (const auto  : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) {
 auto Split = StringRef(Arg).split('=');
-Opts.DebugPrefixMap.insert(
-{std::string(Split.first), std::string(Split.second)});
+Opts.DebugPrefixMap.emplace_back(Split.first, Split.second);
   }
 
   for (const auto  : Args.getAllArgValues(OPT_fcoverage_prefix_map_EQ)) {

diff  --git a/clang/test/CodeGen/debug-prefix-map.c 
b/clang/test/CodeGen/debug-prefix-map.c
index f604f1643ba02..e2421806b055b 100644
--- 

[PATCH] D148665: Change -fsanitize=function to place two words before the function entry

2023-04-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148665

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


[PATCH] D148596: [KMSAN] Enable on SystemZ

2023-04-25 Thread Ilya Leoshkevich via Phabricator via cfe-commits
iii updated this revision to Diff 516926.
iii added a comment.
Herald added a subscriber: hoy.

- Fixed an issue with copyRegSaveArea() overwriting shadow of caller's locals. 
The problem was that the kernel is compiled with "packed-stack", so register 
save areas may be smaller than 160 bytes. Since the kernel is compiled with 
"use-soft-float", it's enough (and also correct) to copy only 56 bytes. Now all 
kernel selftests pass.
- Added a test for this case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148596

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/test/Instrumentation/MemorySanitizer/SystemZ/basic-kernel.ll
  llvm/test/Instrumentation/MemorySanitizer/SystemZ/vararg-kernel.ll

Index: llvm/test/Instrumentation/MemorySanitizer/SystemZ/vararg-kernel.ll
===
--- llvm/test/Instrumentation/MemorySanitizer/SystemZ/vararg-kernel.ll
+++ llvm/test/Instrumentation/MemorySanitizer/SystemZ/vararg-kernel.ll
@@ -3,9 +3,60 @@
 target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"
 target triple = "s390x-unknown-linux-gnu"
 
-declare i64 @foo(i64 %guard, ...) #0
+%struct.__va_list = type { i64, i64, ptr, ptr }
+declare void @llvm.lifetime.start.p0(i64, ptr)
+declare void @llvm.va_start(ptr)
+declare void @llvm.va_end(ptr)
+declare void @llvm.lifetime.end.p0(i64, ptr)
+
+define i64 @foo(i64 %guard, ...) #1 {
+  %vl = alloca %struct.__va_list
+  call void @llvm.lifetime.start.p0(i64 32, ptr %vl)
+  call void @llvm.va_start(ptr %vl)
+  call void @llvm.va_end(ptr %vl)
+  call void @llvm.lifetime.end.p0(i64 32, ptr %vl)
+  ret i64 0
+}
 
-attributes #0 = { "target-features"="+soft-float" "use-soft-float"="true" }
+; CHECK-LABEL: define {{[^@]+}}@foo(
+
+; Callers store variadic arguments' shadow and origins into va_arg_shadow and
+; va_arg_origin. Their layout is: the register save area (160 bytes) followed
+; by the overflow arg area. It does not depend on "packed-stack".
+; Check that callees correctly backup shadow into a local variable.
+
+; CHECK: [[TMP:%.*]] = alloca { ptr, ptr }
+; CHECK: [[OverflowSize:%.*]] = load i64, ptr %va_arg_overflow_size
+; CHECK: [[MetaSize:%.*]] = add i64 160, [[OverflowSize]]
+; CHECK: [[ShadowBackup:%.*]] = alloca {{.*}} [[MetaSize]]
+; CHECK: [[MetaCopySize:%.*]] = call i64 @llvm.umin.i64(i64 [[MetaSize]], i64 800)
+; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[ShadowBackup]], ptr align 8 %va_arg_shadow, i64 [[MetaCopySize]], i1 false)
+; CHECK: [[OverflowBackup:%.*]] = alloca {{.*}} [[MetaSize]]
+; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[OverflowBackup]], ptr align 8 %va_arg_origin, i64 [[MetaCopySize]], i1 false)
+
+; Check that va_start() correctly copies the shadow backup into the shadow of
+; the va_list. Register save area and overflow arg area are copied separately.
+; Only 56 bytes of the register save area is copied, because of
+; "use-soft-float".
+
+; CHECK: call void @llvm.va_start(ptr %vl)
+; CHECK: [[VlAddr:%.*]] = ptrtoint ptr %vl to i64
+; CHECK: [[RegSaveAreaAddrAddr:%.*]] = add i64 [[VlAddr]], 24
+; CHECK: [[RegSaveAreaAddr:%.*]] = inttoptr i64 [[RegSaveAreaAddrAddr]] to ptr
+; CHECK: [[RegSaveArea:%.*]] = load ptr, ptr [[RegSaveAreaAddr]]
+; CHECK: call void @__msan_metadata_ptr_for_store_1(ptr [[TMP]], ptr [[RegSaveArea]])
+; CHECK: [[RegSaveAreaMeta:%.*]] = load { ptr, ptr }, ptr [[TMP]]
+; CHECK: [[RegSaveAreaShadow:%.*]] = extractvalue { ptr, ptr } [[RegSaveAreaMeta]], 0
+; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[RegSaveAreaShadow]], ptr align 8 [[ShadowBackup]], i64 56, i1 false)
+; CHECK: [[VlAddr:%.*]] = ptrtoint ptr %vl to i64
+; CHECK: [[OverflowAddrAddr:%.*]] = add i64 [[VlAddr]], 16
+; CHECK: [[OverflowAddr:%.*]] = inttoptr i64 [[OverflowAddrAddr]] to ptr
+; CHECK: [[Overflow:%.*]] = load ptr, ptr [[OverflowAddr]]
+; CHECK: call void @__msan_metadata_ptr_for_store_1(ptr [[TMP]], ptr [[Overflow]])
+; CHECK: [[OverflowMeta:%.*]] = load { ptr, ptr }, ptr [[TMP]]
+; CHECK: [[OverflowShadow:%.*]] = extractvalue { ptr, ptr } [[OverflowMeta]], 0
+; CHECK: [[OverflowShadowBackup:%.*]] = getelementptr i8, ptr [[ShadowBackup]], i32 160
+; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[OverflowShadow]], ptr align 8 [[OverflowShadowBackup]], i64 [[OverflowSize]], i1 false)
 
 declare i32 @random_i32()
 declare i64 @random_i64()
Index: llvm/test/Instrumentation/MemorySanitizer/SystemZ/basic-kernel.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/MemorySanitizer/SystemZ/basic-kernel.ll
@@ -0,0 +1,169 @@
+; RUN: opt < %s -S -mcpu=z13 -msan-kernel=1 -float-abi=soft -passes=msan 2>&1 | FileCheck %s
+
+target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"
+target triple = "s390x-unknown-linux-gnu"
+
+define 

[PATCH] D148975: -fdebug-prefix-map=: make the last win when multiple prefixes match

2023-04-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D148975#4296625 , @scott.linder 
wrote:

> LGTM, thank you!
>
> Does this warrant a release note, as it is changing the behavior in a 
> backwards-incompatible manner? I do think changing to match GCC is 
> worthwhile, even if it means a change in behavior for Clang.
>
> I also don't think the "longest first" heuristic is useful enough to outweigh 
> the benefits of behaving like GCC; it seems like the user can always sort 
> their own options to get the same effect.

Thank you! I feel that specifying multiple `-fdebug-prefix-map=` is a very 
uncommon situation, so a release note entry is likely overkill.
I updated the HelpText, though.

In D148975#4289159 , @joerg wrote:

> For me long matching prefix makes more sense, but if the same prefix is used 
> multiple times, the last option should win.

"if the same prefix is used multiple times, the last option should win." I 
think this interpretation will add some complexity, e.g. whether we prefer 
`-fdebug-prefix-map=a/=b` or `-fdebug-prefix-map=a=c`. GCC's current rule 
(simple) seems quite reasonable.

From the discussion on https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109591 , 
GCC will likely remain the current behavior and will improve the documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148975

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


[PATCH] D148975: -fdebug-prefix-map=: make the last win when multiple prefixes match

2023-04-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 516924.
MaskRay marked an inline comment as done.
MaskRay added a comment.

Update HelpText


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148975

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-prefix-map.c
  clang/tools/driver/cc1as_main.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/lib/MC/MCContext.cpp
  llvm/test/MC/ELF/debug-prefix-map.s

Index: llvm/test/MC/ELF/debug-prefix-map.s
===
--- llvm/test/MC/ELF/debug-prefix-map.s
+++ llvm/test/MC/ELF/debug-prefix-map.s
@@ -14,9 +14,13 @@
 # RUN: cd %t.foo/bar
 # RUN: llvm-mc -triple=x86_64 -g -dwarf-version=4 %t.foo%{fs-sep}bar%{fs-sep}src.s -filetype=obj -o mapabs.4.o -fdebug-prefix-map=%t.foo=/broken_root -fdebug-prefix-map=%t.foo%{fs-sep}bar=/src_root
 # RUN: llvm-dwarfdump -v -debug-info -debug-line mapabs.4.o | FileCheck --check-prefix=MAPABS_V4 %s
-# RUN: llvm-mc -triple=x86_64 -g -dwarf-version=5 %t.foo%{fs-sep}bar%{fs-sep}src.s -filetype=obj -o mapabs.5.o -fdebug-prefix-map=%t.foo%{fs-sep}bar=/src_root -fdebug-prefix-map=%t.foo=/broken_root
+# RUN: llvm-mc -triple=x86_64 -g -dwarf-version=5 %t.foo%{fs-sep}bar%{fs-sep}src.s -filetype=obj -o mapabs.5.o -fdebug-prefix-map=%t.foo=/broken_root -fdebug-prefix-map=%t.foo%{fs-sep}bar=/src_root
 # RUN: llvm-dwarfdump -v -debug-info -debug-line mapabs.5.o | FileCheck --check-prefix=MAPABS_V5 %s
 
+## The last -fdebug-prefix-map= wins even if the prefix is shorter.
+# RUN: llvm-mc -triple=x86_64 -g -dwarf-version=5 %t.foo%{fs-sep}bar%{fs-sep}src.s -filetype=obj -o mapabs.5.o -fdebug-prefix-map=%t.foo%{fs-sep}bar=/broken_root -fdebug-prefix-map=%t.foo=/src_root
+# RUN: llvm-dwarfdump -v -debug-info -debug-line mapabs.5.o | FileCheck --check-prefix=MAPABS_V5_A %s
+
 f:
   nop
 
@@ -46,3 +50,6 @@
 # MAPABS_V5:  DW_AT_comp_dir [DW_FORM_string] ("{{(/|\\)+}}src_root")
 # MAPABS_V5:  DW_AT_decl_file [DW_FORM_data4] ("/src_root{{(/|\\)+}}src.s")
 # MAPABS_V5:  include_directories[ 0] = .debug_line_str[0x] = "/src_root"
+
+# MAPABS_V5_A:DW_AT_comp_dir [DW_FORM_string] ("{{(/|\\)+}}src_root/bar")
+# MAPABS_V5_A:DW_AT_decl_file [DW_FORM_data4] ("/src_root{{(/|\\)+}}bar{{(/|\\)+}}src.s")
Index: llvm/lib/MC/MCContext.cpp
===
--- llvm/lib/MC/MCContext.cpp
+++ llvm/lib/MC/MCContext.cpp
@@ -881,11 +881,11 @@
 
 void MCContext::addDebugPrefixMapEntry(const std::string ,
const std::string ) {
-  DebugPrefixMap.insert(std::make_pair(From, To));
+  DebugPrefixMap.emplace_back(From, To);
 }
 
 void MCContext::remapDebugPath(SmallVectorImpl ) {
-  for (const auto &[From, To] : DebugPrefixMap)
+  for (const auto &[From, To] : llvm::reverse(DebugPrefixMap))
 if (llvm::sys::path::replace_path_prefix(Path, From, To))
   break;
 }
Index: llvm/include/llvm/MC/MCContext.h
===
--- llvm/include/llvm/MC/MCContext.h
+++ llvm/include/llvm/MC/MCContext.h
@@ -190,7 +190,7 @@
   SmallString<128> CompilationDir;
 
   /// Prefix replacement map for source file information.
-  std::map> DebugPrefixMap;
+  SmallVector, 0> DebugPrefixMap;
 
   /// The main file name if passed in explicitly.
   std::string MainFileName;
Index: clang/tools/driver/cc1as_main.cpp
===
--- clang/tools/driver/cc1as_main.cpp
+++ clang/tools/driver/cc1as_main.cpp
@@ -97,7 +97,7 @@
   std::string DwarfDebugFlags;
   std::string DwarfDebugProducer;
   std::string DebugCompilationDir;
-  std::map DebugPrefixMap;
+  llvm::SmallVector, 0> DebugPrefixMap;
   llvm::DebugCompressionType CompressDebugSections =
   llvm::DebugCompressionType::None;
   std::string MainFileName;
@@ -275,8 +275,7 @@
 
   for (const auto  : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) {
 auto Split = StringRef(Arg).split('=');
-Opts.DebugPrefixMap.insert(
-{std::string(Split.first), std::string(Split.second)});
+Opts.DebugPrefixMap.emplace_back(Split.first, Split.second);
   }
 
   // Frontend Options
Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -9,6 +9,10 @@
 // RUN: %clang -g -fdebug-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
 // RUN: %clang -g -ffile-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
 
+// RUN: rm -rf %t && mkdir -p %t/a/b && cp %s %t/a/b/c.c
+// RUN: %clang_cc1 

[PATCH] D149206: [clang][driver] Enable MisExpect diagnostics flag outside of CC!

2023-04-25 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth created this revision.
paulkirth added reviewers: hans, tejohnson, phosek.
Herald added a project: All.
paulkirth requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Previously we only accepted the `-fdiagnostics-misexpect-tolerance=` at
CC1, when it should have been handled identically to
`-fdiagnostics-hotness-threshold=`. It should not have been required to
pass this flag w/ `-Xclang` as reported here:
https://reviews.llvm.org/D115907#inline-1440745


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149206

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Profile/misexpect-branch.c


Index: clang/test/Profile/misexpect-branch.c
===
--- clang/test/Profile/misexpect-branch.c
+++ clang/test/Profile/misexpect-branch.c
@@ -7,6 +7,7 @@
 
 // there should be no diagnostics when the tolerance is sufficiently high, or 
when -Wmisexpect is not requested
 // RUN: %clang_cc1 %s -O2 -o - -emit-llvm 
-fprofile-instrument-use-path=%t.profdata -verify=foo 
-fdiagnostics-misexpect-tolerance=10 -Wmisexpect 
-debug-info-kind=line-tables-only
+// RUN: %clang -c -S %s -O2 -o - -emit-llvm -fprofile-instr-use=%t.profdata 
-Xclang -verify=foo -fdiagnostics-misexpect-tolerance=10 -Wmisexpect 
-gline-tables-only
 // RUN: %clang_cc1 %s -O2 -o - -disable-llvm-passes -emit-llvm 
-fprofile-instrument-use-path=%t.profdata -verify=foo
 
 // Ensure we emit an error when we don't use pgo with tolerance threshold
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4027,6 +4027,13 @@
 CmdArgs.push_back(Args.MakeArgString(Opt));
   }
 
+  if (const Arg *A =
+  Args.getLastArg(options::OPT_fdiagnostics_misexpect_tolerance_EQ)) {
+std::string Opt =
+std::string("-fdiagnostics-misexpect-tolerance=") + A->getValue();
+CmdArgs.push_back(Args.MakeArgString(Opt));
+  }
+
   if (const Arg *A = Args.getLastArg(options::OPT_fdiagnostics_format_EQ)) {
 CmdArgs.push_back("-fdiagnostics-format");
 CmdArgs.push_back(A->getValue());


Index: clang/test/Profile/misexpect-branch.c
===
--- clang/test/Profile/misexpect-branch.c
+++ clang/test/Profile/misexpect-branch.c
@@ -7,6 +7,7 @@
 
 // there should be no diagnostics when the tolerance is sufficiently high, or when -Wmisexpect is not requested
 // RUN: %clang_cc1 %s -O2 -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata -verify=foo -fdiagnostics-misexpect-tolerance=10 -Wmisexpect -debug-info-kind=line-tables-only
+// RUN: %clang -c -S %s -O2 -o - -emit-llvm -fprofile-instr-use=%t.profdata -Xclang -verify=foo -fdiagnostics-misexpect-tolerance=10 -Wmisexpect -gline-tables-only
 // RUN: %clang_cc1 %s -O2 -o - -disable-llvm-passes -emit-llvm -fprofile-instrument-use-path=%t.profdata -verify=foo
 
 // Ensure we emit an error when we don't use pgo with tolerance threshold
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4027,6 +4027,13 @@
 CmdArgs.push_back(Args.MakeArgString(Opt));
   }
 
+  if (const Arg *A =
+  Args.getLastArg(options::OPT_fdiagnostics_misexpect_tolerance_EQ)) {
+std::string Opt =
+std::string("-fdiagnostics-misexpect-tolerance=") + A->getValue();
+CmdArgs.push_back(Args.MakeArgString(Opt));
+  }
+
   if (const Arg *A = Args.getLastArg(options::OPT_fdiagnostics_format_EQ)) {
 CmdArgs.push_back("-fdiagnostics-format");
 CmdArgs.push_back(A->getValue());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149205: [Headers][doc] Add "gather" intrinsic descriptions to avx2intrin.h

2023-04-25 Thread Paul Robinson via Phabricator via cfe-commits
probinson created this revision.
probinson added reviewers: pengfei, RKSimon, goldstein.w.n, craig.topper.
Herald added a project: All.
probinson requested review of this revision.

https://reviews.llvm.org/D149205

Files:
  clang/lib/Headers/avx2intrin.h

Index: clang/lib/Headers/avx2intrin.h
===
--- clang/lib/Headers/avx2intrin.h
+++ clang/lib/Headers/avx2intrin.h
@@ -786,7 +786,6 @@
   return (__m128i)__builtin_shufflevector((__v8hi)__X, (__v8hi)__X, 0, 0, 0, 0, 0, 0, 0, 0);
 }
 
-
 static __inline__ __m128i __DEFAULT_FN_ATTRS128
 _mm_broadcastd_epi32(__m128i __X)
 {
@@ -935,102 +934,810 @@
   return (__m128i)__builtin_ia32_psrlv2di((__v2di)__X, (__v2di)__Y);
 }
 
+/// Conditionally gathers two 64-bit floating-point values, either from the
+///128-bit vector of [2 x double] in \a a, or from memory \a m using scaled
+///indexes from the 128-bit vector of [4 x i32] in \a i. The 128-bit vector
+///of [2 x double] in \a mask determines the source for each element.
+///
+/// \code
+/// FOR element := 0 to 1
+///   j := element*64
+///   k := element*32
+///   IF mask[j+63] == 0
+/// result[j+63:j] := a[j+63:j]
+///   ELSE
+/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
+///   FI
+/// ENDFOR
+/// \endcode
+///
+/// \headerfile 
+///
+/// \code
+/// __m128d _mm_mask_i32gather_pd(__m128d a, const double *m, __m128i i,
+///   __m128d mask, const int s);
+/// \endcode
+///
+/// This intrinsic corresponds to the \c VGATHERDPD instruction.
+///
+/// \param a
+///A 128-bit vector of [2 x double] used as the source when a mask bit is
+///zero.
+/// \param m
+///A pointer to the memory used for loading values.
+/// \param i
+///A 128-bit vector of [4 x i32] containing signed indexes into \a m. Only
+///the first two elements are used.
+/// \param mask
+///A 128-bit vector of [2 x double] containing the mask. The most
+///significant bit of each element in the mask vector represents the mask
+///bits. If a mask bit is zero, the corresponding value from vector \a a
+///is gathered; otherwise the value is loaded from memory.
+/// \param s
+///A literal constant scale factor for the indexes in \a i. Must be
+///1, 2, 4, or 8.
+/// \returns A 128-bit vector of [2 x double] containing the gathered values.
 #define _mm_mask_i32gather_pd(a, m, i, mask, s) \
   ((__m128d)__builtin_ia32_gatherd_pd((__v2df)(__m128i)(a), \
   (double const *)(m), \
   (__v4si)(__m128i)(i), \
   (__v2df)(__m128d)(mask), (s)))
 
+/// Conditionally gathers four 64-bit floating-point values, either from the
+///256-bit vector of [4 x double] in \a a, or from memory \a m using scaled
+///indexes from the 128-bit vector of [4 x i32] in \a i. The 256-bit vector
+///of [4 x double] in \a mask determines the source for each element.
+///
+/// \code
+/// FOR element := 0 to 3
+///   j := element*64
+///   k := element*32
+///   IF mask[j+63] == 0
+/// result[j+63:j] := a[j+63:j]
+///   ELSE
+/// result[j+63:j] := Load64(m + SignExtend(i[k+31:k])*s)
+///   FI
+/// ENDFOR
+/// \endcode
+///
+/// \headerfile 
+///
+/// \code
+/// __m256d _mm256_mask_i32gather_pd(__m256d a, const double *m, __m128i i,
+///  __m256d mask, const int s);
+/// \endcode
+///
+/// This intrinsic corresponds to the \c VGATHERDPD instruction.
+///
+/// \param a
+///A 256-bit vector of [4 x double] used as the source when a mask bit is
+///zero.
+/// \param m
+///A pointer to the memory used for loading values.
+/// \param i
+///A 128-bit vector of [4 x i32] containing signed indexes into \a m.
+/// \param mask
+///A 256-bit vector of [4 x double] containing the mask. The most
+///significant bit of each element in the mask vector represents the mask
+///bits. If a mask bit is zero, the corresponding value from vector \a a
+///is gathered; otherwise the value is loaded from memory.
+/// \param s
+///A literal constant scale factor for the indexes in \a i. Must be
+///1, 2, 4, or 8.
+/// \returns A 256-bit vector of [4 x double] containing the gathered values.
 #define _mm256_mask_i32gather_pd(a, m, i, mask, s) \
   ((__m256d)__builtin_ia32_gatherd_pd256((__v4df)(__m256d)(a), \
  (double const *)(m), \
  (__v4si)(__m128i)(i), \
  (__v4df)(__m256d)(mask), (s)))
 
+/// Conditionally gathers two 64-bit floating-point values, either from the
+///128-bit vector of [2 x double] in \a a, or from memory \a m using scaled
+///indexes from the 128-bit vector of [2 x i64] in \a i. The 128-bit vector
+///of [2 x double] in \a mask determines the source for each element.
+///
+/// \code
+/// FOR element := 0 

[PATCH] D149009: [Sema]Select correct lexical context during template instantiate

2023-04-25 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:3598
+  FD->isDefined(FDFriend, true) &&
+  FDFriend->getFriendObjectKind() != Decl::FriendObjectKind::FOK_None) {
+// if Function defined by inline friend, use inline fried as DeclContext

erichkeane wrote:
> HerrCai0907 wrote:
> > erichkeane wrote:
> > > So in what case would the currently-instantiated definition NOT also be a 
> > > friend?  I would think this last condition should be able to be an assert 
> > > instead.
> > Last condition cannot be an assert, define and declare in difference place 
> > is common case, what we need to identifier in here is inlined friend define.
> Can you be more clear here?  WHEN can a definition and declaration NOT have 
> the same friend object kind?  THAT is probably incorrect a bug.
Sorry I cannot get the point. 
Here I have 3 conditions:
1. FD->getFriendObjectKind() == Decl::FriendObjectKind::FOK_None
FD(declaration) is not friend object.
2. FD->isDefined(FDFriend, true)
get FDFriend(definition) from FD(declaration).
3. FDFriend->getFriendObjectKind() != Decl::FriendObjectKind::FOK_None)
FDFriend(definition) is friend object.

matching those 3 condition and then we can say FDFriend is a inline friend like
```
template  int foo(F1 X); // FD
template  struct A {
template  friend int foo(F1 X) { return A1; } // FDFriend
};
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149009

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


[PATCH] D149193: [Driver] -gsplit-dwarf: derive .dwo names from -o for link actions

2023-04-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: dblaikie, phosek, yaxunl.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When the final phase is linking, Clang currently
places auxiliary files in the CWD, ignoring `-o`.
(the `-c` behavior for multiple inputs).
Strangely, -fdebug-compilation-dir=/-ffile-compilation-dir= is considered, which
is untested.

GCC has a (IMHO) more reasonable behavior that derives auxiliary filenames from
the final output (-o).

  gcc -c -g -gsplit-dwarf d/a.c d/b.c  # a.dwo b.dwo
  gcc -g -gsplit-dwarf d/a.c d/b.c -o e/x  # e/x-a.dwo e/x-b.dwo
  gcc -g -gsplit-dwarf d/a.c d/b.c # a-a.dwo a-b.dwo
  # -fdebug-compilation-dir= doesn't affect the .dwo filename.

Port the GCC behavior to Clang.

- When the final phase is link, add -dumpdir
- Forward -dumpdir to -cc1 command lines
- tools::SplitDebugName prefers -dumpdir

-dumpdir is a -cc1 only option for now. We consider making it a driver option 
when
more options generating auxiliary files has a sensible behavior when the final
phase is linking.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149193

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/hip-gsplit-dwarf-options.hip
  clang/test/Driver/split-debug.c

Index: clang/test/Driver/split-debug.c
===
--- clang/test/Driver/split-debug.c
+++ clang/test/Driver/split-debug.c
@@ -9,6 +9,7 @@
 
 // INLINE: "-fsplit-dwarf-inlining"
 // NOINLINE-NOT: "-fsplit-dwarf-inlining"
+// SPLIT-NOT:  "-dumpdir"
 // SPLIT:  "-debug-info-kind=constructor"
 // SPLIT-SAME: "-ggnu-pubnames"
 // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo"
@@ -54,8 +55,15 @@
 // SINGLE_WITH_FILENAME: "-split-dwarf-file" "{{.*}}foo.o"
 // SINGLE_WITH_FILENAME-NOT: "-split-dwarf-output"
 
-/// Without -c, clang performs linking as well. The output is unchanged.
-// RUN: %clang -### -target x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o ignore.d 2>&1 | FileCheck %s --check-prefix=SPLIT
+/// If linking is the final phase, the .dwo filename is derived from -o (if specified) or "a".
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o obj/out 2>&1 | FileCheck %s --check-prefix=SPLIT_LINK
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT_LINK_A
+
+// SPLIT_LINK:  "-dumpdir" "obj/out-"
+// SPLIT_LINK:  "-debug-info-kind=constructor"
+// SPLIT_LINK-SAME: "-split-dwarf-file" "obj/out-split-debug.dwo" "-split-dwarf-output" "obj/out-split-debug.dwo"
+// SPLIT_LINK_A:  "-dumpdir" "a-"
+// SPLIT_LINK_A-SAME: "-split-dwarf-file" "a-split-debug.dwo" "-split-dwarf-output" "a-split-debug.dwo"
 
 /// -fsplit-dwarf-inlining
 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=split -g -fsplit-dwarf-inlining %s 2>&1 | FileCheck %s --check-prefixes=INLINE,SPLIT
Index: clang/test/Driver/hip-gsplit-dwarf-options.hip
===
--- clang/test/Driver/hip-gsplit-dwarf-options.hip
+++ clang/test/Driver/hip-gsplit-dwarf-options.hip
@@ -13,13 +13,17 @@
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu \
 // RUN:   --offload-arch=gfx906:xnack+ %s -nogpulib -nogpuinc \
 // RUN:   --offload-arch=gfx900 \
-// RUN:   -ggdb -gsplit-dwarf 2>&1 | FileCheck %s
+// RUN:   -ggdb -gsplit-dwarf 2>&1 | FileCheck %s --check-prefix=LINK
 
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu \
 // RUN:   -fgpu-rdc --offload-arch=gfx906:xnack+ %s -nogpulib -nogpuinc \
 // RUN:   --offload-arch=gfx900 \
-// RUN:   -ggdb -gsplit-dwarf 2>&1 | FileCheck %s
+// RUN:   -ggdb -gsplit-dwarf 2>&1 | FileCheck %s --check-prefix=LINK
 
 // CHECK-DAG: {{".*clang.*".* "-target-cpu" "gfx906".* "-split-dwarf-output" "hip-gsplit-dwarf-options_gfx906:xnack\+.dwo"}}
 // CHECK-DAG: {{".*clang.*".* "-target-cpu" "gfx900".* "-split-dwarf-output" "hip-gsplit-dwarf-options_gfx900.dwo"}}
 // CHECK-DAG: {{".*clang.*".* "-target-cpu" "x86-64".* "-split-dwarf-output" "hip-gsplit-dwarf-options.dwo"}}
+
+// LINK-DAG: {{".*clang.*".* "-target-cpu" "gfx906".* "-split-dwarf-output" "a-hip-gsplit-dwarf-options_gfx906:xnack\+.dwo"}}
+// LINK-DAG: {{".*clang.*".* "-target-cpu" "gfx900".* "-split-dwarf-output" "a-hip-gsplit-dwarf-options_gfx900.dwo"}}
+// LINK-DAG: {{".*clang.*".* "-target-cpu" "x86-64".* "-split-dwarf-output" "a-hip-gsplit-dwarf-options.dwo"}}
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1248,23 +1248,22 @@
 if (StringRef(A->getValue()) == "single")
   return 

[PATCH] D149144: [clang][dataflow] Eliminate intermediate `ReferenceValue`s from `Environment::DeclToLoc`.

2023-04-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp:43
 
+namespace {
+

mboehme wrote:
> There were a number of pre-existing declarations that were ODR violation 
> risks. I'm adding a new file-local function below, so instead of making it 
> static, I decided to put everything that's supposed to be file-local in an 
> anonymous namespace.
https://llvm.org/docs/CodingStandards.html#anonymous-namespaces

"Avoid putting declarations other than classes into anonymous namespaces"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149144

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


[PATCH] D148372: [clang] add diagnose when member function contains invalid default argument

2023-04-25 Thread Congcong Cai 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 rGe12753ed: [clang] add diagnose when member function 
contains invalid default argument (authored by HerrCai0907).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148372

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Parse/ParseDecl.cpp
  clang/test/Parser/cxx-member-initializers.cpp


Index: clang/test/Parser/cxx-member-initializers.cpp
===
--- clang/test/Parser/cxx-member-initializers.cpp
+++ clang/test/Parser/cxx-member-initializers.cpp
@@ -108,4 +108,9 @@
   // expected-error@-2 {{type name requires a specifier or qualifier}}
   // expected-error@-3 {{expected '>'}}
   // expected-note@-4 {{to match this '<'}}
+
+  void n(int x = 1 ? 2) {}
+  // expected-error@-1 {{expected ':'}}
+  // expected-note@-2 {{to match this '?'}}
+  // expected-error@-3 {{expected expression}}
 };
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -7381,13 +7381,9 @@
   DefArgToks.reset(new CachedTokens);
 
   SourceLocation ArgStartLoc = NextToken().getLocation();
-  if (!ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument)) {
-DefArgToks.reset();
-Actions.ActOnParamDefaultArgumentError(Param, EqualLoc);
-  } else {
-Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
-  ArgStartLoc);
-  }
+  ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument);
+  Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
+ArgStartLoc);
 } else {
   // Consume the '='.
   ConsumeToken();
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -321,6 +321,8 @@
   (`#61885 `_)
 - Clang constexpr evaluator now treats comparison of [[gnu::weak]]-attributed
   member pointer as an invalid expression.
+- Fix crash when member function contains invalid default argument.
+  (`#62122 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/Parser/cxx-member-initializers.cpp
===
--- clang/test/Parser/cxx-member-initializers.cpp
+++ clang/test/Parser/cxx-member-initializers.cpp
@@ -108,4 +108,9 @@
   // expected-error@-2 {{type name requires a specifier or qualifier}}
   // expected-error@-3 {{expected '>'}}
   // expected-note@-4 {{to match this '<'}}
+
+  void n(int x = 1 ? 2) {}
+  // expected-error@-1 {{expected ':'}}
+  // expected-note@-2 {{to match this '?'}}
+  // expected-error@-3 {{expected expression}}
 };
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -7381,13 +7381,9 @@
   DefArgToks.reset(new CachedTokens);
 
   SourceLocation ArgStartLoc = NextToken().getLocation();
-  if (!ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument)) {
-DefArgToks.reset();
-Actions.ActOnParamDefaultArgumentError(Param, EqualLoc);
-  } else {
-Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
-  ArgStartLoc);
-  }
+  ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument);
+  Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
+ArgStartLoc);
 } else {
   // Consume the '='.
   ConsumeToken();
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -321,6 +321,8 @@
   (`#61885 `_)
 - Clang constexpr evaluator now treats comparison of [[gnu::weak]]-attributed
   member pointer as an invalid expression.
+- Fix crash when member function contains invalid default argument.
+  (`#62122 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3333e12 - [clang] add diagnose when member function contains invalid default argument

2023-04-25 Thread Congcong Cai via cfe-commits

Author: Congcong Cai
Date: 2023-04-25T23:08:30+02:00
New Revision: e12753ed9c27fc25c73858a990081b0ceb11

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

LOG: [clang] add diagnose when member function contains invalid default argument

Fixed: https://github.com/llvm/llvm-project/issues/62122
This change pointer to add diagnose message for this code.
```
struct S {
static int F(int n = 0 ? 0) {
return 0;
}
};
```
For default parameter, we should set it as unparsed even if meeting
syntax error because it should be issued in real parser time instead of
set is as invalid directly without diagnose.

Reviewed By: rsmith

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Parse/ParseDecl.cpp
clang/test/Parser/cxx-member-initializers.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a1bb925e8ae24..55ec1cdef52fa 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -321,6 +321,8 @@ Bug Fixes in This Version
   (`#61885 `_)
 - Clang constexpr evaluator now treats comparison of [[gnu::weak]]-attributed
   member pointer as an invalid expression.
+- Fix crash when member function contains invalid default argument.
+  (`#62122 `_)
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 18897188828f1..728879e20de78 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -7381,13 +7381,9 @@ void Parser::ParseParameterDeclarationClause(
   DefArgToks.reset(new CachedTokens);
 
   SourceLocation ArgStartLoc = NextToken().getLocation();
-  if (!ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument)) {
-DefArgToks.reset();
-Actions.ActOnParamDefaultArgumentError(Param, EqualLoc);
-  } else {
-Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
-  ArgStartLoc);
-  }
+  ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument);
+  Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
+ArgStartLoc);
 } else {
   // Consume the '='.
   ConsumeToken();

diff  --git a/clang/test/Parser/cxx-member-initializers.cpp 
b/clang/test/Parser/cxx-member-initializers.cpp
index c29260b731223..57f707cee52be 100644
--- a/clang/test/Parser/cxx-member-initializers.cpp
+++ b/clang/test/Parser/cxx-member-initializers.cpp
@@ -108,4 +108,9 @@ class G {
   // expected-error@-2 {{type name requires a specifier or qualifier}}
   // expected-error@-3 {{expected '>'}}
   // expected-note@-4 {{to match this '<'}}
+
+  void n(int x = 1 ? 2) {}
+  // expected-error@-1 {{expected ':'}}
+  // expected-note@-2 {{to match this '?'}}
+  // expected-error@-3 {{expected expression}}
 };



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


[PATCH] D129700: [clang] Don't emit type tests for dllexport/import classes

2023-04-25 Thread Arthur Eubanks 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 rGf34ecb50e2c0: [clang] Dont emit type tests for 
dllexport/import classes (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129700

Files:
  clang/lib/CodeGen/CGVTables.cpp
  clang/test/CodeGenCXX/lto-visibility-inference.cpp


Index: clang/test/CodeGenCXX/lto-visibility-inference.cpp
===
--- clang/test/CodeGenCXX/lto-visibility-inference.cpp
+++ clang/test/CodeGenCXX/lto-visibility-inference.cpp
@@ -74,10 +74,10 @@
   // MS: type.test{{.*}}!"?AUC2@@"
   c2->f();
   // ITANIUM: type.test{{.*}}!"_ZTS2C3"
-  // MS: type.test{{.*}}!"?AUC3@@"
+  // MS-NOT: type.test{{.*}}!"?AUC3@@"
   c3->f();
   // ITANIUM: type.test{{.*}}!"_ZTS2C4"
-  // MS: type.test{{.*}}!"?AUC4@@"
+  // MS-NOT: type.test{{.*}}!"?AUC4@@"
   c4->f();
   // ITANIUM-NOT: type.test{{.*}}!"_ZTS2C5"
   // MS-NOT: type.test{{.*}}!"?AUC5@@"
Index: clang/lib/CodeGen/CGVTables.cpp
===
--- clang/lib/CodeGen/CGVTables.cpp
+++ clang/lib/CodeGen/CGVTables.cpp
@@ -1212,7 +1212,8 @@
 }
 
 bool CodeGenModule::AlwaysHasLTOVisibilityPublic(const CXXRecordDecl *RD) {
-  if (RD->hasAttr() || RD->hasAttr())
+  if (RD->hasAttr() || RD->hasAttr() ||
+  RD->hasAttr() || RD->hasAttr())
 return true;
 
   if (!getCodeGenOpts().LTOVisibilityPublicStd)
@@ -1239,13 +1240,9 @@
   if (!isExternallyVisible(LV.getLinkage()))
 return true;
 
-  if (getTriple().isOSBinFormatCOFF()) {
-if (RD->hasAttr() || RD->hasAttr())
-  return false;
-  } else {
-if (LV.getVisibility() != HiddenVisibility)
-  return false;
-  }
+  if (!getTriple().isOSBinFormatCOFF() &&
+  LV.getVisibility() != HiddenVisibility)
+return false;
 
   return !AlwaysHasLTOVisibilityPublic(RD);
 }


Index: clang/test/CodeGenCXX/lto-visibility-inference.cpp
===
--- clang/test/CodeGenCXX/lto-visibility-inference.cpp
+++ clang/test/CodeGenCXX/lto-visibility-inference.cpp
@@ -74,10 +74,10 @@
   // MS: type.test{{.*}}!"?AUC2@@"
   c2->f();
   // ITANIUM: type.test{{.*}}!"_ZTS2C3"
-  // MS: type.test{{.*}}!"?AUC3@@"
+  // MS-NOT: type.test{{.*}}!"?AUC3@@"
   c3->f();
   // ITANIUM: type.test{{.*}}!"_ZTS2C4"
-  // MS: type.test{{.*}}!"?AUC4@@"
+  // MS-NOT: type.test{{.*}}!"?AUC4@@"
   c4->f();
   // ITANIUM-NOT: type.test{{.*}}!"_ZTS2C5"
   // MS-NOT: type.test{{.*}}!"?AUC5@@"
Index: clang/lib/CodeGen/CGVTables.cpp
===
--- clang/lib/CodeGen/CGVTables.cpp
+++ clang/lib/CodeGen/CGVTables.cpp
@@ -1212,7 +1212,8 @@
 }
 
 bool CodeGenModule::AlwaysHasLTOVisibilityPublic(const CXXRecordDecl *RD) {
-  if (RD->hasAttr() || RD->hasAttr())
+  if (RD->hasAttr() || RD->hasAttr() ||
+  RD->hasAttr() || RD->hasAttr())
 return true;
 
   if (!getCodeGenOpts().LTOVisibilityPublicStd)
@@ -1239,13 +1240,9 @@
   if (!isExternallyVisible(LV.getLinkage()))
 return true;
 
-  if (getTriple().isOSBinFormatCOFF()) {
-if (RD->hasAttr() || RD->hasAttr())
-  return false;
-  } else {
-if (LV.getVisibility() != HiddenVisibility)
-  return false;
-  }
+  if (!getTriple().isOSBinFormatCOFF() &&
+  LV.getVisibility() != HiddenVisibility)
+return false;
 
   return !AlwaysHasLTOVisibilityPublic(RD);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f34ecb5 - [clang] Don't emit type tests for dllexport/import classes

2023-04-25 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2023-04-25T14:00:57-07:00
New Revision: f34ecb50e2c03e27b5785576545aab07b3b19a94

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

LOG: [clang] Don't emit type tests for dllexport/import classes

According to https://clang.llvm.org/docs/LTOVisibility.html, classes on
Windows with dllimport/export receive public LTO visibility and
therefore should not participate in WPD.

Reviewed By: pcc

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

Added: 


Modified: 
clang/lib/CodeGen/CGVTables.cpp
clang/test/CodeGenCXX/lto-visibility-inference.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index a257de859d4e8..32259d1e4cbff 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -1212,7 +1212,8 @@ void CodeGenModule::EmitDeferredVTables() {
 }
 
 bool CodeGenModule::AlwaysHasLTOVisibilityPublic(const CXXRecordDecl *RD) {
-  if (RD->hasAttr() || RD->hasAttr())
+  if (RD->hasAttr() || RD->hasAttr() ||
+  RD->hasAttr() || RD->hasAttr())
 return true;
 
   if (!getCodeGenOpts().LTOVisibilityPublicStd)
@@ -1239,13 +1240,9 @@ bool CodeGenModule::HasHiddenLTOVisibility(const 
CXXRecordDecl *RD) {
   if (!isExternallyVisible(LV.getLinkage()))
 return true;
 
-  if (getTriple().isOSBinFormatCOFF()) {
-if (RD->hasAttr() || RD->hasAttr())
-  return false;
-  } else {
-if (LV.getVisibility() != HiddenVisibility)
-  return false;
-  }
+  if (!getTriple().isOSBinFormatCOFF() &&
+  LV.getVisibility() != HiddenVisibility)
+return false;
 
   return !AlwaysHasLTOVisibilityPublic(RD);
 }

diff  --git a/clang/test/CodeGenCXX/lto-visibility-inference.cpp 
b/clang/test/CodeGenCXX/lto-visibility-inference.cpp
index 1246743115604..e7ce3436a88b1 100644
--- a/clang/test/CodeGenCXX/lto-visibility-inference.cpp
+++ b/clang/test/CodeGenCXX/lto-visibility-inference.cpp
@@ -74,10 +74,10 @@ void f(C1 *c1, C2 *c2, C3 *c3, C4 *c4, C5 *c5, C6 *c6, 
std::C7 *c7,
   // MS: type.test{{.*}}!"?AUC2@@"
   c2->f();
   // ITANIUM: type.test{{.*}}!"_ZTS2C3"
-  // MS: type.test{{.*}}!"?AUC3@@"
+  // MS-NOT: type.test{{.*}}!"?AUC3@@"
   c3->f();
   // ITANIUM: type.test{{.*}}!"_ZTS2C4"
-  // MS: type.test{{.*}}!"?AUC4@@"
+  // MS-NOT: type.test{{.*}}!"?AUC4@@"
   c4->f();
   // ITANIUM-NOT: type.test{{.*}}!"_ZTS2C5"
   // MS-NOT: type.test{{.*}}!"?AUC5@@"



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


[PATCH] D148975: -fdebug-prefix-map=: make the last win when multiple prefixes match

2023-04-25 Thread Scott Linder via Phabricator via cfe-commits
scott.linder accepted this revision.
scott.linder added a comment.
This revision is now accepted and ready to land.

LGTM, thank you!

Does this warrant a release note, as it is changing the behavior in a 
backwards-incompatible manner? I do think changing to match GCC is worthwhile, 
even if it means a change in behavior for Clang.

I also don't think the "longest first" heuristic is useful enough to outweigh 
the benefits of behaving like GCC; it seems like the user can always sort their 
own options to get the same effect.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148975

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


[PATCH] D148372: [clang] add diagnose when member function contains invalid default argument

2023-04-25 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 added a comment.

> Are there any calls to Sema::ActOnParamDefaultArgumentError left?

Yes, it has.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148372

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


[PATCH] D129700: [clang] Don't emit type tests for dllexport/import classes

2023-04-25 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc 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/D129700/new/

https://reviews.llvm.org/D129700

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


[PATCH] D129700: [clang] Don't emit type tests for dllexport/import classes

2023-04-25 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.
Herald added a subscriber: bd1976llvm.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129700

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


[PATCH] D72538: [ThinLTO] Add additional ThinLTO pipeline testing with new PM

2023-04-25 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72538

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


[PATCH] D72538: [ThinLTO] Add additional ThinLTO pipeline testing with new PM

2023-04-25 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D72538#4296277 , @nikic wrote:

> In D72538#4296119 , @tejohnson wrote:
>
>> In D72538#4291552 , @nikic wrote:
>>
>>> Would it be possible to cut down the Clang side tests to only check parts 
>>> that Clang controls in some way, e.g. that SLPVectorizer is enabled? This 
>>> test is something of a PITA because it tests LLVM implementation details 
>>> but is not part of the LLVM tests, so it usually gets missed when doing 
>>> pipeline changes.
>>
>> I think we can cut this down significantly, since the llvm tests added here 
>> check the full ThinLTO default pipeline setup at different opt levels. 
>> However, the point of the clang test is to make sure that for a distributed 
>> ThinLTO backend we correctly invoke thinBackend() which should set up the 
>> ThinLTO default pipeline. So how about I cut this down to check a single 
>> pass that is only invoked in the LTO backends? Specifically, I'm thinking of 
>> WholeProgramDevirtPass.
>
> That sounds reasonable to me!

Done in e5b0276dc882f7c5b2a349e2f02abf16b1d41322 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72538

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


[clang] e5b0276 - [ThinLTO] Reduce pipeline clang test to avoid churn from LLVM changes

2023-04-25 Thread Teresa Johnson via cfe-commits

Author: Teresa Johnson
Date: 2023-04-25T13:33:09-07:00
New Revision: e5b0276dc882f7c5b2a349e2f02abf16b1d41322

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

LOG: [ThinLTO] Reduce pipeline clang test to avoid churn from LLVM changes

This test was added in D72538, along with multiple LLVM pipeline tests,
to ensure that distributed ThinLTO backends invoked via clang set up the
expected ThinLTO optimization pipeline. However, this introduces churn
to clang tests from LLVM pipeline changes (see recent comment in that
patch).

Since the full pipeline setup is tested by LLVM, I have changed this
test to simply look for a single pass that is only invoked during LTO
backends, to make sure that clang is provoking the an LTO backend
pipeline setup.

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
index c85ce0f6a27d..9967586fea9b 100644
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -1,7 +1,12 @@
 ; FIXME: This test should use CHECK-NEXT to keep up-to-date.
 ; REQUIRES: x86-registered-target
 
-; Validate ThinLTO post link pipeline at O2 and O3
+;; Validate that we set up the ThinLTO post link pipeline at O2 and O3
+;; for a ThinLTO distributed backend invoked via clang.
+;; Since LLVM tests already more thoroughly test this pipeline, and to
+;; avoid making this clang test too sensitive to LLVM pipeline changes,
+;; here we simply confirm that an LTO backend-specific pass is getting
+;; invoked (WPD).
 
 ; RUN: opt -thinlto-bc -o %t.o %s
 
@@ -17,94 +22,9 @@
 ; RUN: %clang -target x86_64-grtev4-linux-gnu \
 ; RUN:   -O3 -Xclang -fdebug-pass-manager \
 ; RUN:   -c -fthinlto-index=%t.o.thinlto.bc \
-; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck 
-check-prefixes=CHECK-O,CHECK-O3 %s --dump-input=fail
+; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck -check-prefixes=CHECK-O %s 
--dump-input=fail
 
 ; CHECK-O: Running pass: WholeProgramDevirtPass
-; CHECK-O: Running pass: LowerTypeTestsPass
-; CHECK-O: Running pass: PGOIndirectCallPromotion
-; CHECK-O: Running pass: InferFunctionAttrsPass
-; CHECK-O: Running pass: LowerExpectIntrinsicPass on main
-; CHECK-O: Running pass: SimplifyCFGPass on main
-; CHECK-O: Running pass: SROAPass on main
-; CHECK-O: Running pass: EarlyCSEPass on main
-; CHECK-O3: Running pass: CallSiteSplittingPass on main
-; CHECK-O: Running pass: LowerTypeTestsPass
-; CHECK-O: Running pass: IPSCCPPass
-; CHECK-O: Running pass: CalledValuePropagationPass
-; CHECK-O: Running pass: GlobalOptPass
-; CHECK-O: Running pass: PromotePass
-; CHECK-O: Running pass: InstCombinePass on main
-; CHECK-O: Running pass: SimplifyCFGPass on main
-; CHECK-O: Running pass: InlinerPass on (main)
-; CHECK-O: Running pass: PostOrderFunctionAttrsPass on (main)
-; CHECK-O3: Running pass: ArgumentPromotionPass on (main)
-; CHECK-O: Running pass: SROAPass on main
-; CHECK-O: Running pass: EarlyCSEPass on main
-; CHECK-O: Running pass: SpeculativeExecutionPass on main
-; CHECK-O: Running pass: JumpThreadingPass on main
-; CHECK-O: Running pass: CorrelatedValuePropagationPass on main
-; CHECK-O: Running pass: SimplifyCFGPass on main
-; CHECK-O: Running pass: InstCombinePass on main
-; CHECK-O3: Running pass: AggressiveInstCombinePass on main
-; CHECK-O: Running pass: LibCallsShrinkWrapPass on main
-; CHECK-O: Running pass: TailCallElimPass on main
-; CHECK-O: Running pass: SimplifyCFGPass on main
-; CHECK-O: Running pass: ReassociatePass on main
-; CHECK-O: Running pass: LoopSimplifyPass on main
-; CHECK-O: Running pass: LCSSAPass on main
-; CHECK-O: Running pass: SimplifyCFGPass on main
-; CHECK-O: Running pass: InstCombinePass on main
-; CHECK-O: Running pass: LoopSimplifyPass on main
-; CHECK-O: Running pass: LCSSAPass on main
-; CHECK-O: Running pass: SROAPass on main
-; CHECK-O: Running pass: MergedLoadStoreMotionPass on main
-; CHECK-O: Running pass: GVNPass on main
-; CHECK-O: Running pass: SCCPPass on main
-; CHECK-O: Running pass: BDCEPass on main
-; CHECK-O: Running pass: InstCombinePass on main
-; CHECK-O: Running pass: JumpThreadingPass on main
-; CHECK-O: Running pass: CorrelatedValuePropagationPass on main
-; CHECK-O: Running pass: ADCEPass on main
-; CHECK-O: Running pass: MemCpyOptPass on main
-; CHECK-O: Running pass: DSEPass on main
-; CHECK-O: Running pass: LoopSimplifyPass on main
-; CHECK-O: Running pass: LCSSAPass on main
-; CHECK-O: Running pass: SimplifyCFGPass on main
-; CHECK-O: Running pass: InstCombinePass on main
-; CHECK-O: Running pass: DeadArgumentEliminationPass
-; CHECK-O: Running pass: GlobalOptPass
-; CHECK-O: Running pass: GlobalDCEPass
-; 

[PATCH] D149187: [clang] Canonicalize system headers in dependency file when -canonical-prefixes

2023-04-25 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Clang was writing paths to the dependency file that don't exist when using a 
sysroot with symlinks, causing everything to get rebuilt every time. This is 
reproducible on Linux by creating a symlink to '/', using that as the sysroot, 
and trying to build something with ninja that includes the C++ stdlib (e.g. a 
typical build of LLVM).

This fixes https://github.com/ninja-build/ninja/issues/1330 and somewhat 
matches gcc.

gcc canonicalizes system headers in dependency files under a 
-f[no-]canonical-system-headers, but it makes more sense to look at 
-canonical-prefixes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149187

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/DependencyOutputOptions.h
  clang/include/clang/Frontend/Utils.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/test/Driver/canonical-system-headers.c
  clang/test/Preprocessor/Inputs/canonical-system-headers/a.h
  clang/test/Preprocessor/canonical-system-headers.c

Index: clang/test/Preprocessor/canonical-system-headers.c
===
--- /dev/null
+++ clang/test/Preprocessor/canonical-system-headers.c
@@ -0,0 +1,16 @@
+// don't create symlinks on windows
+// UNSUPPORTED: system-windows
+// REQUIRES: shell
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/foo/
+// RUN: ln -f -s %S/Inputs/canonical-system-headers %t/foo/include
+// RUN: %clang_cc1 -isystem %T/foo/include -sys-header-deps -MT foo.o -dependency-file %t2 %s -fsyntax-only
+// RUN: FileCheck %s --check-prefix=NOCANON --implicit-check-not=a.h < %t2
+// RUN: %clang_cc1 -isystem %T/foo/include -sys-header-deps -MT foo.o -dependency-file %t2 %s -fsyntax-only -canonical-system-headers
+// RUN: FileCheck %s --check-prefix=CANON --implicit-check-not=a.h < %t2
+
+// NOCANON: foo/include/a.h
+// CANON: Inputs/canonical-system-headers/a.h
+
+#include 
Index: clang/test/Driver/canonical-system-headers.c
===
--- /dev/null
+++ clang/test/Driver/canonical-system-headers.c
@@ -0,0 +1,6 @@
+// RUN: %clang -MD -no-canonical-prefixes -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-NO
+// RUN: %clang -MD -canonical-prefixes -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-YES
+// RUN: %clang -MD -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-YES
+
+// CHECK-YES: "-canonical-system-headers"
+// CHECK-NO-NOT: "-canonical-system-headers"
Index: clang/lib/Frontend/DependencyFile.cpp
===
--- clang/lib/Frontend/DependencyFile.cpp
+++ clang/lib/Frontend/DependencyFile.cpp
@@ -49,6 +49,7 @@
   DepCollector.maybeAddDependency(
   llvm::sys::path::remove_leading_dotslash(*Filename),
   /*FromModule*/ false, isSystem(FileType), /*IsModuleFile*/ false,
+  (),
   /*IsMissing*/ false);
   }
 
@@ -56,9 +57,11 @@
SrcMgr::CharacteristicKind FileType) override {
 StringRef Filename =
 llvm::sys::path::remove_leading_dotslash(SkippedFile.getName());
-DepCollector.maybeAddDependency(Filename, /*FromModule=*/false,
+DepCollector.maybeAddDependency(Filename,
+/*FromModule=*/false,
 /*IsSystem=*/isSystem(FileType),
 /*IsModuleFile=*/false,
+(),
 /*IsMissing=*/false);
   }
 
@@ -69,9 +72,12 @@
   StringRef RelativePath, const Module *Imported,
   SrcMgr::CharacteristicKind FileType) override {
 if (!File)
-  DepCollector.maybeAddDependency(FileName, /*FromModule*/false,
- /*IsSystem*/false, /*IsModuleFile*/false,
- /*IsMissing*/true);
+  DepCollector.maybeAddDependency(FileName,
+  /*FromModule*/ false,
+  /*IsSystem*/ false,
+  /*IsModuleFile*/ false,
+  (),
+  /*IsMissing*/ true);
 // Files that actually exist are handled by FileChanged.
   }
 
@@ -82,9 +88,11 @@
   return;
 StringRef Filename =
 llvm::sys::path::remove_leading_dotslash(File->getName());
-DepCollector.maybeAddDependency(Filename, /*FromModule=*/false,
+DepCollector.maybeAddDependency(Filename,
+/*FromModule=*/false,
 /*IsSystem=*/isSystem(FileType),
 /*IsModuleFile=*/false,
+

[PATCH] D149163: [NFC][CLANG] Fix coverity remarks about large copy by values

2023-04-25 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 516883.
Manna added a comment.
Herald added a subscriber: kadircet.
Herald added a project: clang-tools-extra.

Fix bot failures


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

https://reviews.llvm.org/D149163

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/SemaType.cpp
  clang/tools/libclang/CIndexCodeCompletion.cpp
  clang/unittests/Sema/CodeCompleteTest.cpp

Index: clang/unittests/Sema/CodeCompleteTest.cpp
===
--- clang/unittests/Sema/CodeCompleteTest.cpp
+++ clang/unittests/Sema/CodeCompleteTest.cpp
@@ -54,7 +54,7 @@
 CompletedFuncDecls(CompletedFuncDecls),
 CCTUInfo(std::make_shared()) {}
 
-  void ProcessCodeCompleteResults(Sema , CodeCompletionContext Context,
+  void ProcessCodeCompleteResults(Sema , const CodeCompletionContext ,
   CodeCompletionResult *Results,
   unsigned NumResults) override {
 for (unsigned I = 0; I < NumResults; ++I) {
@@ -89,7 +89,7 @@
   : CodeCompleteConsumer(/*CodeCompleteOpts=*/{}), ResultCtx(ResultCtx),
 CCTUInfo(std::make_shared()) {}
 
-  void ProcessCodeCompleteResults(Sema , CodeCompletionContext Context,
+  void ProcessCodeCompleteResults(Sema , const CodeCompletionContext ,
   CodeCompletionResult *Results,
   unsigned NumResults) override {
 ResultCtx.VisitedNamespaces =
Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- clang/tools/libclang/CIndexCodeCompletion.cpp
+++ clang/tools/libclang/CIndexCodeCompletion.cpp
@@ -572,8 +572,8 @@
   CCTUInfo(Results.CodeCompletionAllocator), TU(TranslationUnit) {}
 ~CaptureCompletionResults() override { Finish(); }
 
-void ProcessCodeCompleteResults(Sema , 
-CodeCompletionContext Context,
+void ProcessCodeCompleteResults(Sema ,
+const CodeCompletionContext ,
 CodeCompletionResult *Results,
 unsigned NumResults) override {
   StoredResults.reserve(StoredResults.size() + NumResults);
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -4553,7 +4553,7 @@
   return false;
 }
 
-static bool IsNoDerefableChunk(DeclaratorChunk Chunk) {
+static bool IsNoDerefableChunk(const DeclaratorChunk ) {
   return (Chunk.Kind == DeclaratorChunk::Pointer ||
   Chunk.Kind == DeclaratorChunk::Array);
 }
Index: clang/lib/Sema/CodeCompleteConsumer.cpp
===
--- clang/lib/Sema/CodeCompleteConsumer.cpp
+++ clang/lib/Sema/CodeCompleteConsumer.cpp
@@ -638,8 +638,8 @@
 }
 
 void PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(
-Sema , CodeCompletionContext Context, CodeCompletionResult *Results,
-unsigned NumResults) {
+Sema , const CodeCompletionContext ,
+CodeCompletionResult *Results, unsigned NumResults) {
   std::stable_sort(Results, Results + NumResults);
 
   if (!Context.getPreferredType().isNull())
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -1952,7 +1952,8 @@
|  (1LL << CodeCompletionContext::CCC_ClassOrStructTag);
 }
 
-void ProcessCodeCompleteResults(Sema , CodeCompletionContext Context,
+void ProcessCodeCompleteResults(Sema ,
+const CodeCompletionContext ,
 CodeCompletionResult *Results,
 unsigned NumResults) override;
 
@@ -2063,10 +2064,9 @@
   }
 }
 
-void AugmentedCodeCompleteConsumer::ProcessCodeCompleteResults(Sema ,
-CodeCompletionContext Context,
-CodeCompletionResult *Results,
-unsigned NumResults) {
+void AugmentedCodeCompleteConsumer::ProcessCodeCompleteResults(
+Sema , const CodeCompletionContext ,
+CodeCompletionResult *Results, unsigned NumResults) {
   // Merge the results we were given with the results we cached.
   bool AddedResult = false;
   uint64_t InContexts =
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1711,7 +1711,7 @@
 
 

[PATCH] D149182: Remove -Wpacked false positive for non-pod types where the layout isn't directly changed

2023-04-25 Thread David Blaikie via Phabricator via cfe-commits
dblaikie created this revision.
dblaikie added a reviewer: aaron.ballman.
Herald added a project: All.
dblaikie requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The packed attribute can still be useful in this case if the struct is
then placed inside another packed struct - the non-pod element type's
packed attribute declares that it's OK to misalign this element inside
the packed structure. (otherwise the non-pod element is not packed/its
alignment is preserved, as per D117616 
/2771233 
)

Fixes PR62353


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149182

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/CodeGenCXX/warn-padded-packed.cpp


Index: clang/test/CodeGenCXX/warn-padded-packed.cpp
===
--- clang/test/CodeGenCXX/warn-padded-packed.cpp
+++ clang/test/CodeGenCXX/warn-padded-packed.cpp
@@ -167,6 +167,16 @@
 } __attribute__((packed)); // no warning
 static_assert(alignof(S29) == 1, "");
 
+struct S30 {
+protected:
+ short s;
+} __attribute__((packed)); // no warning
+struct S30_use {
+  char c;
+  S30 u;
+} __attribute__((packed));
+static_assert(sizeof(S30_use) == 3, "");
+
 // The warnings are emitted when the layout of the structs is computed, so we 
have to use them.
 void f(S1*, S2*, S3*, S4*, S5*, S6*, S7*, S8*, S9*, S10*, S11*, S12*, S13*,
S14*, S15*, S16*, S17*, S18*, S19*, S20*, S21*, S22*, S23*, S24*, S25*,
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2198,11 +2198,14 @@
   << (InBits ? 1 : 0); // (byte|bit)
 }
 
+const auto *CXXRD = dyn_cast(RD);
+
 // Warn if we packed it unnecessarily, when the unpacked alignment is not
 // greater than the one after packing, the size in bits doesn't change and
 // the offset of each field is identical.
 if (Packed && UnpackedAlignment <= Alignment &&
-UnpackedSizeInBits == getSizeInBits() && !HasPackedField)
+UnpackedSizeInBits == getSizeInBits() && !HasPackedField &&
+(!CXXRD || CXXRD->isPOD()))
   Diag(D->getLocation(), diag::warn_unnecessary_packed)
   << Context.getTypeDeclType(RD);
   }


Index: clang/test/CodeGenCXX/warn-padded-packed.cpp
===
--- clang/test/CodeGenCXX/warn-padded-packed.cpp
+++ clang/test/CodeGenCXX/warn-padded-packed.cpp
@@ -167,6 +167,16 @@
 } __attribute__((packed)); // no warning
 static_assert(alignof(S29) == 1, "");
 
+struct S30 {
+protected:
+ short s;
+} __attribute__((packed)); // no warning
+struct S30_use {
+  char c;
+  S30 u;
+} __attribute__((packed));
+static_assert(sizeof(S30_use) == 3, "");
+
 // The warnings are emitted when the layout of the structs is computed, so we have to use them.
 void f(S1*, S2*, S3*, S4*, S5*, S6*, S7*, S8*, S9*, S10*, S11*, S12*, S13*,
S14*, S15*, S16*, S17*, S18*, S19*, S20*, S21*, S22*, S23*, S24*, S25*,
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -2198,11 +2198,14 @@
   << (InBits ? 1 : 0); // (byte|bit)
 }
 
+const auto *CXXRD = dyn_cast(RD);
+
 // Warn if we packed it unnecessarily, when the unpacked alignment is not
 // greater than the one after packing, the size in bits doesn't change and
 // the offset of each field is identical.
 if (Packed && UnpackedAlignment <= Alignment &&
-UnpackedSizeInBits == getSizeInBits() && !HasPackedField)
+UnpackedSizeInBits == getSizeInBits() && !HasPackedField &&
+(!CXXRD || CXXRD->isPOD()))
   Diag(D->getLocation(), diag::warn_unnecessary_packed)
   << Context.getTypeDeclType(RD);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148094: [DRAFT][clang][CodeGen] Break up TargetInfo.cpp [6/6]

2023-04-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

This refactoring looks reasonable to me as well. In `clang/lib/Driver`, we have 
D30372  that splits some huge files into 
target-specific files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

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


[PATCH] D148094: [DRAFT][clang][CodeGen] Break up TargetInfo.cpp [6/6]

2023-04-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: efriedma.
aaron.ballman added a comment.

I think this is a reasonable refactoring, but I'm hoping the CodeGen code 
owners can chime in with their thoughts as well given how large the changes are 
in their area. (I did not verify that the refactoring didn't change 
functionality, but spot-checking did not find any differences.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

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


[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-04-25 Thread Henrik G Olsson via Phabricator via cfe-commits
hnrklssn added a comment.

In D148216#4266201 , @nikic wrote:

> We should probably just use the `META` fallback for all metadata not already 
> explicitly handled. I think there's pretty little value in adding a special 
> name for each metadata kind.

I added a fallback, and some logic to extract the metadata kind name from the 
IR, because I do find it useful to emit checks named after the type of IR they 
match against.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

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


[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-04-25 Thread Henrik G Olsson via Phabricator via cfe-commits
hnrklssn added a comment.

In D148216#4266174 , @arichardson 
wrote:

> Change looks good to me, but if clang can't emit these yet we should probably 
> wait until committing this? Do you have a link to a review that uses this 
> metadata?

It can emit them, we just use them a bit more frequently downstream. I've found 
an example and added a lit test as an example of how it works.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

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


[PATCH] D148901: [clang][Interp] Fix post-inc/dec operator result

2023-04-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman 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/D148901/new/

https://reviews.llvm.org/D148901

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


[PATCH] D148975: -fdebug-prefix-map=: make the last win when multiple prefixes match

2023-04-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked an inline comment as done.
MaskRay added inline comments.



Comment at: clang/include/clang/Basic/CodeGenOptions.h:209
 
-  std::map DebugPrefixMap;
+  llvm::SmallVector, 0> DebugPrefixMap;
   std::map CoveragePrefixMap;

scott.linder wrote:
> MaskRay wrote:
> > scott.linder wrote:
> > > What benefit does forcing allocation have? Why not use the default, or 
> > > switch to `std::vector`?
> > This doesn't force allocation. I use inline element size 0 to make the 
> > member variable smaller than a `std::vector`.
> > `std::vector` likely compiles to larger code.
> Sorry, I just didn't realize this was idiomatic (i.e. I hadn't read 
> https://llvm.org/docs/ProgrammersManual.html#vector), and I didn't see other 
> similar uses in the file.
> 
> There are 15 `std::vector` members of `CodeGenOptions`, but no 
> `SmallVector<_, 0>` members; maybe the rest can be converted in an NFC patch, 
> so things are consistent?
It seems that SmallVector is used more frequently but std::vector is used as 
well. I'd prefer that we don't change the types for existing variables...
```
% rg SmallVector lib -l | wc -l => 439
% rg std::vector lib -l | wc -l => 255
```



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:72-79
 CGDebugInfo::CGDebugInfo(CodeGenModule )
 : CGM(CGM), DebugKind(CGM.getCodeGenOpts().getDebugInfo()),
   DebugTypeExtRefs(CGM.getCodeGenOpts().DebugTypeExtRefs),
   DBuilder(CGM.getModule()) {
-  for (const auto  : CGM.getCodeGenOpts().DebugPrefixMap)
-DebugPrefixMap[KV.first] = KV.second;
+  for (const auto &[From, To] : CGM.getCodeGenOpts().DebugPrefixMap)
+DebugPrefixMap.emplace_back(From, To);
   CreateCompileUnit();

scott.linder wrote:
> MaskRay wrote:
> > scott.linder wrote:
> > > Can you use the member-initializer-list here?
> > No, this doesn't work. We convert a vector of `std::string` to a vector of 
> > `StringRef`.
> If all we are doing is creating another vector which shares the underlying 
> strings with the original, why not just save a reference to the original 
> vector? Is the cost of the extra dereference when accessing it greater than 
> the cost of traversing it plus the extra storage for the `StringRef`s?
> 
> It seems like the original utility was just to get the `std::map` sorting 
> behavior, which we no longer need.
Thanks for the giving this more attention. Actually I found that the variable 
can be removed. Removed:)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148975

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


[PATCH] D148975: -fdebug-prefix-map=: make the last win when multiple prefixes match

2023-04-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 516863.
MaskRay marked 3 inline comments as done.
MaskRay added a comment.

remove a DebugPrefixMap variable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148975

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-prefix-map.c
  clang/tools/driver/cc1as_main.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/lib/MC/MCContext.cpp
  llvm/test/MC/ELF/debug-prefix-map.s

Index: llvm/test/MC/ELF/debug-prefix-map.s
===
--- llvm/test/MC/ELF/debug-prefix-map.s
+++ llvm/test/MC/ELF/debug-prefix-map.s
@@ -14,9 +14,13 @@
 # RUN: cd %t.foo/bar
 # RUN: llvm-mc -triple=x86_64 -g -dwarf-version=4 %t.foo%{fs-sep}bar%{fs-sep}src.s -filetype=obj -o mapabs.4.o -fdebug-prefix-map=%t.foo=/broken_root -fdebug-prefix-map=%t.foo%{fs-sep}bar=/src_root
 # RUN: llvm-dwarfdump -v -debug-info -debug-line mapabs.4.o | FileCheck --check-prefix=MAPABS_V4 %s
-# RUN: llvm-mc -triple=x86_64 -g -dwarf-version=5 %t.foo%{fs-sep}bar%{fs-sep}src.s -filetype=obj -o mapabs.5.o -fdebug-prefix-map=%t.foo%{fs-sep}bar=/src_root -fdebug-prefix-map=%t.foo=/broken_root
+# RUN: llvm-mc -triple=x86_64 -g -dwarf-version=5 %t.foo%{fs-sep}bar%{fs-sep}src.s -filetype=obj -o mapabs.5.o -fdebug-prefix-map=%t.foo=/broken_root -fdebug-prefix-map=%t.foo%{fs-sep}bar=/src_root
 # RUN: llvm-dwarfdump -v -debug-info -debug-line mapabs.5.o | FileCheck --check-prefix=MAPABS_V5 %s
 
+## The last -fdebug-prefix-map= wins even if the prefix is shorter.
+# RUN: llvm-mc -triple=x86_64 -g -dwarf-version=5 %t.foo%{fs-sep}bar%{fs-sep}src.s -filetype=obj -o mapabs.5.o -fdebug-prefix-map=%t.foo%{fs-sep}bar=/broken_root -fdebug-prefix-map=%t.foo=/src_root
+# RUN: llvm-dwarfdump -v -debug-info -debug-line mapabs.5.o | FileCheck --check-prefix=MAPABS_V5_A %s
+
 f:
   nop
 
@@ -46,3 +50,6 @@
 # MAPABS_V5:  DW_AT_comp_dir [DW_FORM_string] ("{{(/|\\)+}}src_root")
 # MAPABS_V5:  DW_AT_decl_file [DW_FORM_data4] ("/src_root{{(/|\\)+}}src.s")
 # MAPABS_V5:  include_directories[ 0] = .debug_line_str[0x] = "/src_root"
+
+# MAPABS_V5_A:DW_AT_comp_dir [DW_FORM_string] ("{{(/|\\)+}}src_root/bar")
+# MAPABS_V5_A:DW_AT_decl_file [DW_FORM_data4] ("/src_root{{(/|\\)+}}bar{{(/|\\)+}}src.s")
Index: llvm/lib/MC/MCContext.cpp
===
--- llvm/lib/MC/MCContext.cpp
+++ llvm/lib/MC/MCContext.cpp
@@ -881,11 +881,11 @@
 
 void MCContext::addDebugPrefixMapEntry(const std::string ,
const std::string ) {
-  DebugPrefixMap.insert(std::make_pair(From, To));
+  DebugPrefixMap.emplace_back(From, To);
 }
 
 void MCContext::remapDebugPath(SmallVectorImpl ) {
-  for (const auto &[From, To] : DebugPrefixMap)
+  for (const auto &[From, To] : llvm::reverse(DebugPrefixMap))
 if (llvm::sys::path::replace_path_prefix(Path, From, To))
   break;
 }
Index: llvm/include/llvm/MC/MCContext.h
===
--- llvm/include/llvm/MC/MCContext.h
+++ llvm/include/llvm/MC/MCContext.h
@@ -190,7 +190,7 @@
   SmallString<128> CompilationDir;
 
   /// Prefix replacement map for source file information.
-  std::map> DebugPrefixMap;
+  SmallVector, 0> DebugPrefixMap;
 
   /// The main file name if passed in explicitly.
   std::string MainFileName;
Index: clang/tools/driver/cc1as_main.cpp
===
--- clang/tools/driver/cc1as_main.cpp
+++ clang/tools/driver/cc1as_main.cpp
@@ -97,7 +97,7 @@
   std::string DwarfDebugFlags;
   std::string DwarfDebugProducer;
   std::string DebugCompilationDir;
-  std::map DebugPrefixMap;
+  llvm::SmallVector, 0> DebugPrefixMap;
   llvm::DebugCompressionType CompressDebugSections =
   llvm::DebugCompressionType::None;
   std::string MainFileName;
@@ -275,8 +275,7 @@
 
   for (const auto  : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) {
 auto Split = StringRef(Arg).split('=');
-Opts.DebugPrefixMap.insert(
-{std::string(Split.first), std::string(Split.second)});
+Opts.DebugPrefixMap.emplace_back(Split.first, Split.second);
   }
 
   // Frontend Options
Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -9,6 +9,10 @@
 // RUN: %clang -g -fdebug-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
 // RUN: %clang -g -ffile-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL
 
+// RUN: rm -rf %t && mkdir -p %t/a/b && cp %s %t/a/b/c.c
+// RUN: %clang_cc1 -emit-llvm 

[PATCH] D149154: [clang][Interp] Emit diagnostic when comparing function pointers

2023-04-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/AST/Interp/Interp.h:652-653
+  const SourceInfo  = S.Current->getSource(OpPC);
+  S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_unspecified)
+  << LS << RS;
+  return false;

tbaeder wrote:
> aaron.ballman wrote:
> > Can we pass in the result of `getType()` instead of doing this string 
> > conversion dance?
> Well the diagnostic doesn't print the result of the LHS/RHS:
> ```
> ./array.cpp:202:18: error: constexpr variable 'u13' must be initialized by a 
> constant expression
>   202 |   constexpr bool u13 = pf < pg; // ref-warning {{ordered comparison 
> of function pointers}}
>   |  ^ ~~~
> ./array.cpp:202:27: note: comparison between '' and '' has unspecified 
> value
>   202 |   constexpr bool u13 = pf < pg; // ref-warning {{ordered comparison 
> of function pointers}}
>   |   ^
> ```
> 
> I'm not exactly a fan of how the code looks though. I might add a helper 
> function for this later.
Ah of course, good point. And yeah, a helper function for this would probably 
not be a bad idea.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149154

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


[PATCH] D148987: [clang][Interp] Check Neg ops for errors

2023-04-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/Interp/Interp.h:438-441
+  // FIXME: This code Just Works[tm] for floats, but it's probably not doing
+  //   the right thing. At least the diagnostic could be better without
+  //   the conversion to an APInt.
+

tbaeder wrote:
> aaron.ballman wrote:
> > I'm confused -- why would negation be UB for a floating-point type? For 
> > integer types, it's a matter of not being able to represent the value when 
> > the source is `INT_MIN`.
> No idea, this was just something that came to mind when I wrote the code. If 
> it's not an issue, that's even better can I can just remove the comment.
I think we should probably assert that the failure only occurs for integer 
types and not other arithmetic types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148987

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


[PATCH] D148967: Disable atexit()-based lowering when LTO'ing kernel/kext code

2023-04-25 Thread Julian Lettner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc3f0153ec27a: [MachO] Disable atexit()-based lowering when 
LTOing kernel/kext code (authored by yln).

Changed prior to commit:
  https://reviews.llvm.org/D148967?vs=515929=516862#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148967

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-ld-lto.c
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/test/CodeGen/ARM/ctors_dtors.ll


Index: llvm/test/CodeGen/ARM/ctors_dtors.ll
===
--- llvm/test/CodeGen/ARM/ctors_dtors.ll
+++ llvm/test/CodeGen/ARM/ctors_dtors.ll
@@ -1,4 +1,5 @@
 ; RUN: llc < %s -mtriple=arm-apple-darwin  | FileCheck %s -check-prefix=DARWIN
+; RUN: llc < %s -mtriple=arm-apple-darwin 
-disable-atexit-based-global-dtor-lowering  | FileCheck %s 
-check-prefix=DARWIN-LEGACY
 ; RUN: llc < %s -mtriple=arm-linux-gnu -target-abi=apcs  | FileCheck %s 
-check-prefix=ELF
 ; RUN: llc < %s -mtriple=arm-linux-gnueabi | FileCheck %s -check-prefix=GNUEABI
 
@@ -7,6 +8,10 @@
 ; DARWIN: .section __DATA,__mod_init_func,mod_init_funcs
 ; DARWIN-NOT: __mod_term_func
 
+; DARWIN-LEGACY-NOT: atexit
+; DARWIN-LEGACY: .section  __DATA,__mod_init_func,mod_init_funcs
+; DARWIN-LEGACY: .section  __DATA,__mod_term_func,mod_term_funcs
+
 ; ELF: .section .ctors,"aw",%progbits
 ; ELF: .section .dtors,"aw",%progbits
 
Index: llvm/lib/CodeGen/TargetPassConfig.cpp
===
--- llvm/lib/CodeGen/TargetPassConfig.cpp
+++ llvm/lib/CodeGen/TargetPassConfig.cpp
@@ -100,6 +100,9 @@
 cl::desc("Disable Copy Propagation pass"));
 static cl::opt 
DisablePartialLibcallInlining("disable-partial-libcall-inlining",
 cl::Hidden, cl::desc("Disable Partial Libcall Inlining"));
+static cl::opt DisableAtExitBasedGlobalDtorLowering(
+"disable-atexit-based-global-dtor-lowering", cl::Hidden,
+cl::desc("For MachO, disable atexit()-based global destructor lowering"));
 static cl::opt EnableImplicitNullChecks(
 "enable-implicit-null-checks",
 cl::desc("Fold null checks into faulting memory operations"),
@@ -878,7 +881,8 @@
 
   // For MachO, lower @llvm.global_dtors into @llvm.global_ctors with
   // __cxa_atexit() calls to avoid emitting the deprecated __mod_term_func.
-  if (TM->getTargetTriple().isOSBinFormatMachO())
+  if (TM->getTargetTriple().isOSBinFormatMachO() &&
+  !DisableAtExitBasedGlobalDtorLowering)
 addPass(createLowerGlobalDtorsLegacyPass());
 
   // Make sure that no unreachable blocks are instruction selected.
Index: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===
--- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -1202,7 +1202,12 @@
 
 MCSection *TargetLoweringObjectFileMachO::getStaticDtorSection(
 unsigned Priority, const MCSymbol *KeySym) const {
-  report_fatal_error("@llvm.global_dtors should have been lowered already");
+  return StaticDtorSection;
+  // In userspace, we lower global destructors via atexit(), but kernel/kext
+  // environments do not provide this function so we still need to support the
+  // legacy way here.
+  // See the -disable-atexit-based-global-dtor-lowering CodeGen flag for more
+  // context.
 }
 
 void TargetLoweringObjectFileMachO::emitModuleMetadata(MCStreamer ,
Index: clang/test/Driver/darwin-ld-lto.c
===
--- clang/test/Driver/darwin-ld-lto.c
+++ clang/test/Driver/darwin-ld-lto.c
@@ -40,3 +40,11 @@
 // GISEL: {{ld(.exe)?"}}
 // GISEL: "-mllvm" "-global-isel"
 // GISEL: "-mllvm" "-global-isel-abort=0"
+
+
+// Check that we disable atexit()-based global destructor lowering when
+// compiling/linking for kernel/kext/freestanding.
+// RUN: %clang -target arm64-apple-darwin %s -flto -fapple-kext -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEXT %s
+// KEXT: {{ld(.exe)?"}}
+// KEXT: "-mllvm" "-disable-atexit-based-global-dtor-lowering"
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -393,6 +393,13 @@
 }
   }
 
+  if (Args.hasArg(options::OPT_mkernel) ||
+  Args.hasArg(options::OPT_fapple_kext) ||
+  Args.hasArg(options::OPT_ffreestanding)) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-disable-atexit-based-global-dtor-lowering");
+  }
+
   Args.AddLastArg(CmdArgs, options::OPT_prebind);
   Args.AddLastArg(CmdArgs, options::OPT_noprebind);
   Args.AddLastArg(CmdArgs, options::OPT_nofixprebinding);


Index: llvm/test/CodeGen/ARM/ctors_dtors.ll

[clang] c3f0153 - [MachO] Disable atexit()-based lowering when LTO'ing kernel/kext code

2023-04-25 Thread Julian Lettner via cfe-commits

Author: Julian Lettner
Date: 2023-04-25T12:13:40-07:00
New Revision: c3f0153ec27a5e2cff97179d319ab99651c4c539

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

LOG: [MachO] Disable atexit()-based lowering when LTO'ing kernel/kext code

The kernel and kext environments do not provide the `__cxa_atexit()`
function, so we can't use it for lowering global module destructors.

Unfortunately, just querying for "compiling for kernel/kext?" in the LTO
pipeline isn't possible (kernel/kext identifier isn't part of the triple
yet) so we need to pass down a CodeGen flag.

rdar://93536111

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-ld-lto.c
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/lib/CodeGen/TargetPassConfig.cpp
llvm/test/CodeGen/ARM/ctors_dtors.ll

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 11e65358bec05..35b30e6044411 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -393,6 +393,13 @@ void darwin::Linker::AddLinkArgs(Compilation , const 
ArgList ,
 }
   }
 
+  if (Args.hasArg(options::OPT_mkernel) ||
+  Args.hasArg(options::OPT_fapple_kext) ||
+  Args.hasArg(options::OPT_ffreestanding)) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-disable-atexit-based-global-dtor-lowering");
+  }
+
   Args.AddLastArg(CmdArgs, options::OPT_prebind);
   Args.AddLastArg(CmdArgs, options::OPT_noprebind);
   Args.AddLastArg(CmdArgs, options::OPT_nofixprebinding);

diff  --git a/clang/test/Driver/darwin-ld-lto.c 
b/clang/test/Driver/darwin-ld-lto.c
index efa28b6746fac..2e049769b0cd4 100644
--- a/clang/test/Driver/darwin-ld-lto.c
+++ b/clang/test/Driver/darwin-ld-lto.c
@@ -40,3 +40,11 @@
 // GISEL: {{ld(.exe)?"}}
 // GISEL: "-mllvm" "-global-isel"
 // GISEL: "-mllvm" "-global-isel-abort=0"
+
+
+// Check that we disable atexit()-based global destructor lowering when
+// compiling/linking for kernel/kext/freestanding.
+// RUN: %clang -target arm64-apple-darwin %s -flto -fapple-kext -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEXT %s
+// KEXT: {{ld(.exe)?"}}
+// KEXT: "-mllvm" "-disable-atexit-based-global-dtor-lowering"

diff  --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp 
b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index c81b6bb623b96..db1a4369e1291 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -1202,7 +1202,12 @@ void TargetLoweringObjectFileMachO::Initialize(MCContext 
,
 
 MCSection *TargetLoweringObjectFileMachO::getStaticDtorSection(
 unsigned Priority, const MCSymbol *KeySym) const {
-  report_fatal_error("@llvm.global_dtors should have been lowered already");
+  return StaticDtorSection;
+  // In userspace, we lower global destructors via atexit(), but kernel/kext
+  // environments do not provide this function so we still need to support the
+  // legacy way here.
+  // See the -disable-atexit-based-global-dtor-lowering CodeGen flag for more
+  // context.
 }
 
 void TargetLoweringObjectFileMachO::emitModuleMetadata(MCStreamer ,

diff  --git a/llvm/lib/CodeGen/TargetPassConfig.cpp 
b/llvm/lib/CodeGen/TargetPassConfig.cpp
index 32fa6cc17d53f..86490c0d6417d 100644
--- a/llvm/lib/CodeGen/TargetPassConfig.cpp
+++ b/llvm/lib/CodeGen/TargetPassConfig.cpp
@@ -100,6 +100,9 @@ static cl::opt DisableCopyProp("disable-copyprop", 
cl::Hidden,
 cl::desc("Disable Copy Propagation pass"));
 static cl::opt 
DisablePartialLibcallInlining("disable-partial-libcall-inlining",
 cl::Hidden, cl::desc("Disable Partial Libcall Inlining"));
+static cl::opt DisableAtExitBasedGlobalDtorLowering(
+"disable-atexit-based-global-dtor-lowering", cl::Hidden,
+cl::desc("For MachO, disable atexit()-based global destructor lowering"));
 static cl::opt EnableImplicitNullChecks(
 "enable-implicit-null-checks",
 cl::desc("Fold null checks into faulting memory operations"),
@@ -878,7 +881,8 @@ void TargetPassConfig::addIRPasses() {
 
   // For MachO, lower @llvm.global_dtors into @llvm.global_ctors with
   // __cxa_atexit() calls to avoid emitting the deprecated __mod_term_func.
-  if (TM->getTargetTriple().isOSBinFormatMachO())
+  if (TM->getTargetTriple().isOSBinFormatMachO() &&
+  !DisableAtExitBasedGlobalDtorLowering)
 addPass(createLowerGlobalDtorsLegacyPass());
 
   // Make sure that no unreachable blocks are instruction selected.

diff  --git a/llvm/test/CodeGen/ARM/ctors_dtors.ll 
b/llvm/test/CodeGen/ARM/ctors_dtors.ll
index 066c250ca1448..f3d65ee982b58 100644
--- a/llvm/test/CodeGen/ARM/ctors_dtors.ll
+++ 

[PATCH] D72538: [ThinLTO] Add additional ThinLTO pipeline testing with new PM

2023-04-25 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

In D72538#4296119 , @tejohnson wrote:

> In D72538#4291552 , @nikic wrote:
>
>> Would it be possible to cut down the Clang side tests to only check parts 
>> that Clang controls in some way, e.g. that SLPVectorizer is enabled? This 
>> test is something of a PITA because it tests LLVM implementation details but 
>> is not part of the LLVM tests, so it usually gets missed when doing pipeline 
>> changes.
>
> I think we can cut this down significantly, since the llvm tests added here 
> check the full ThinLTO default pipeline setup at different opt levels. 
> However, the point of the clang test is to make sure that for a distributed 
> ThinLTO backend we correctly invoke thinBackend() which should set up the 
> ThinLTO default pipeline. So how about I cut this down to check a single pass 
> that is only invoked in the LTO backends? Specifically, I'm thinking of 
> WholeProgramDevirtPass.

That sounds reasonable to me!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72538

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


[PATCH] D149123: [AArch64][InlineAsm]Add Clang support for flag output constraints

2023-04-25 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:1216
+// Returns the length of cc constraint.
+static unsigned matchAsmCCConstraint(const char *) {
+  constexpr unsigned len = 5;

davidxl wrote:
> Name is not modified in this method, so perhaps dropping '&'?
Yeah, looks like this was copied from D57394. Probably both places should be 
fixed.

A `char *&` is a code smell.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:1310
+// CC condition
+if (auto Len = matchAsmCCConstraint(Name)) {
+  Name += Len - 1;

please don't use `auto` here.


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

https://reviews.llvm.org/D149123

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


[PATCH] D115907: [misexpect] Re-implement MisExpect Diagnostics

2023-04-25 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.

In D115907#4296154 , @hans wrote:

> In D115907#4295923 , @paulkirth 
> wrote:
>
>>> 2. Due to inlining etc., it often gets the source locations wrong, which 
>>> means it points at code where again there were no expectations -- but 
>>> perhaps that code got inlined into an expectations somewhere else. (e.g. 
>>> https://crbug.com/1434989#c9)
>>
>> The checking depends somewhat on the instrumentation type (frontend vs. 
>> backend instrumentation) In the case of frontend instrumentation, when the 
>> expect intrinsic is lowered (very early in the pipeline) we can report the 
>> diagnostic right away, since branch weights from profiling have already been 
>> attached. The //should// mean that you should get fairly accurate source 
>> information, since this happens before any optimizations run.
>
> We use the backend instrumentation since that gives the best performance, but 
> it's good to hear that the locations may be more accurate with frontend 
> instrumentation. Maybe we should add that to the docs?

Let me look into this a bit. I'm not sure if this is just we're not doing the 
best practice when printing the diagnostic, or if the resolution is being 
degraded due to optimizations. We may want to update the documentation anyway, 
but I'd like to be certain.




Comment at: clang/include/clang/Driver/Options.td:1434
+def fdiagnostics_misexpect_tolerance_EQ : Joined<["-"], 
"fdiagnostics-misexpect-tolerance=">,
+Group, Flags<[CC1Option]>, MetaVarName<"">,
+HelpText<"Prevent misexpect diagnostics from being output if the profile 
counts are within N% of the expected. ">;

hans wrote:
> paulkirth wrote:
> > hans wrote:
> > > Should this be a driver mode option and not just cc1? The doc suggests 
> > > using it, which currently won't work without an `-Xclang` prefix.
> > That should also work from clang w/o `-Xclang`, shouldn't it? This is used 
> > exactly like `-fdiagnostics-hotness-threshold=`, so IIRC that should still 
> > work from clang.
> Hmm, if I add `-fdiagnostics-misexpect-tolerance=10` I get errors about the 
> flag being unused. I had to use `-Xclang` for it to work.
That isn't WAI then. I'll try to address that today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115907

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


[PATCH] D149000: Update with warning message for comparison to NULL pointer

2023-04-25 Thread Krishna Narayanan via Phabricator via cfe-commits
Krishna-13-cyber updated this revision to Diff 516857.
Krishna-13-cyber added a comment.

- Updated with reviewed changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149000

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/conditional-expr.c
  clang/test/Sema/warn-tautological-compare.c


Index: clang/test/Sema/warn-tautological-compare.c
===
--- clang/test/Sema/warn-tautological-compare.c
+++ clang/test/Sema/warn-tautological-compare.c
@@ -93,3 +93,9 @@
   x = array ? 1 : 0; // expected-warning {{address of array}}
   x =  ? 1 : 0;// expected-warning {{address of 'x'}}
 }
+
+void test4(void)
+{
+int *a = (void *) 0;
+int b = () == ((void *) 0); // expected-warning {{comparison of address of 
'a' equal to a null pointer is always false}}
+}
Index: clang/test/Sema/conditional-expr.c
===
--- clang/test/Sema/conditional-expr.c
+++ clang/test/Sema/conditional-expr.c
@@ -86,7 +86,7 @@
 
 int Postgresql(void) {
   char x;
-  return ) != ((void *) 0)) ? (*() = ((char) 1)) : (void) ((void *) 
0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids 
conditional expressions with only one void side}}
+  return ) != ((void *) 0)) ? (*() = ((char) 1)) : (void) ((void *) 
0)), (unsigned long) ((void *) 0)); // expected-warning {{comparison of address 
of 'x' not equal to a null pointer is always true}}
 }
 
 #define nil ((void*) 0)
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -14723,7 +14723,7 @@
 
   bool IsAddressOf = false;
 
-  if (UnaryOperator *UO = dyn_cast(E)) {
+  if (UnaryOperator *UO = dyn_cast(E->IgnoreParenCasts())) {
 if (UO->getOpcode() != UO_AddrOf)
   return;
 IsAddressOf = true;


Index: clang/test/Sema/warn-tautological-compare.c
===
--- clang/test/Sema/warn-tautological-compare.c
+++ clang/test/Sema/warn-tautological-compare.c
@@ -93,3 +93,9 @@
   x = array ? 1 : 0; // expected-warning {{address of array}}
   x =  ? 1 : 0;// expected-warning {{address of 'x'}}
 }
+
+void test4(void)
+{
+int *a = (void *) 0;
+int b = () == ((void *) 0); // expected-warning {{comparison of address of 'a' equal to a null pointer is always false}}
+}
Index: clang/test/Sema/conditional-expr.c
===
--- clang/test/Sema/conditional-expr.c
+++ clang/test/Sema/conditional-expr.c
@@ -86,7 +86,7 @@
 
 int Postgresql(void) {
   char x;
-  return ) != ((void *) 0)) ? (*() = ((char) 1)) : (void) ((void *) 0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids conditional expressions with only one void side}}
+  return ) != ((void *) 0)) ? (*() = ((char) 1)) : (void) ((void *) 0)), (unsigned long) ((void *) 0)); // expected-warning {{comparison of address of 'x' not equal to a null pointer is always true}}
 }
 
 #define nil ((void*) 0)
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -14723,7 +14723,7 @@
 
   bool IsAddressOf = false;
 
-  if (UnaryOperator *UO = dyn_cast(E)) {
+  if (UnaryOperator *UO = dyn_cast(E->IgnoreParenCasts())) {
 if (UO->getOpcode() != UO_AddrOf)
   return;
 IsAddressOf = true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147281: Stop modifying trailing return types.

2023-04-25 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this caused a change in behavior: 
https://github.com/llvm/llvm-project/issues/62361


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147281

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


[PATCH] D103930: [clang][HeaderSearch] Fix implicit module when using header maps

2023-04-25 Thread Andrew Gallagher via Phabricator via cfe-commits
andrewjcg added a comment.

@ivanmurashko: Sorry for the delay getting back to you here.  Feel free to 
commandeer, as I don't have plans to get to this soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103930

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


[PATCH] D148967: Disable atexit()-based lowering when LTO'ing kernel/kext code

2023-04-25 Thread Ahmed Bougacha via Phabricator via cfe-commits
ab accepted this revision.
ab added a comment.
This revision is now accepted and ready to land.

A comment inline, but LGTM otherwise, thanks!




Comment at: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp:1208
+  // -disable-atexit-based-global-dtor-lowering CodeGen flag.
+  // report_fatal_error("@llvm.global_dtors should have been lowered already");
 }

stray fatal_error?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148967

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


[PATCH] D146386: [MS ABI] Fix mangling references to declarations.

2023-04-25 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added a comment.

Ping.


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

https://reviews.llvm.org/D146386

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


[PATCH] D103930: [clang][HeaderSearch] Fix implicit module when using header maps

2023-04-25 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.



> Looks like this patch causes a number of issues for us, I will work with 
> @jansvoboda11 to see if there's some way to resolve them.

If you can share a reproducer I'm pretty sure @ivanmurashko can help make it 
work for y'all too. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103930

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


[PATCH] D148757: [clang] Apply last -fcoverage-prefix-map option

2023-04-25 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem updated this revision to Diff 516853.
gulfem added a comment.

Updated the text.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148757

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Profile/coverage-prefix-map.c


Index: clang/test/Profile/coverage-prefix-map.c
===
--- clang/test/Profile/coverage-prefix-map.c
+++ clang/test/Profile/coverage-prefix-map.c
@@ -19,3 +19,13 @@
 
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-compilation-dir=/custom 
-fcoverage-prefix-map=/custom=/nonsense -o - | FileCheck 
--check-prefix=COVERAGE-COMPILATION-DIR %s
 // COVERAGE-COMPILATION-DIR: @__llvm_coverage_mapping = {{.*"\\02.*}}nonsense
+
+// Test that last -fcoverage-prefix-map option 
(-fcoverage-prefix-map==newpath) is applied.
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-prefix-map=%/t/root=. 
-fcoverage-prefix-map==newpath -o - | FileCheck 
--check-prefix=COVERAGE-PREFIX-MAP-ORDER %s
+// COVERAGE-PREFIX-MAP-ORDER: @__llvm_coverage_mapping = 
{{.*"\\02.*newpath.*root.*nested.*coverage-prefix-map\.c}}
+
+// Test that last -fcoverage-prefix-map option 
(-fcoverage-prefix-map=%/t/root=.) is applied.
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-prefix-map==newpath 
-fcoverage-prefix-map=%/t/root=. -o - | FileCheck 
--check-prefix=COVERAGE-PREFIX-MAP-REORDER %s
+// COVERAGE-PREFIX-MAP-REORDER: @__llvm_coverage_mapping =
+// COVERAGE-PREFIX-MAP-REORDER-NOT: newpath
+// COVERAGE-PREFIX-MAP-REORDER-SAME: nested{{.*coverage-prefix-map\.c}}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1702,8 +1702,7 @@
 
   for (const auto  : Args.getAllArgValues(OPT_fcoverage_prefix_map_EQ)) {
 auto Split = StringRef(Arg).split('=');
-Opts.CoveragePrefixMap.insert(
-{std::string(Split.first), std::string(Split.second)});
+Opts.CoveragePrefixMap.emplace_back(Split.first, Split.second);
   }
 
   const llvm::Triple::ArchType DebugEntryValueArchs[] = {
Index: clang/lib/CodeGen/CoverageMappingGen.h
===
--- clang/lib/CodeGen/CoverageMappingGen.h
+++ clang/lib/CodeGen/CoverageMappingGen.h
@@ -107,7 +107,10 @@
   llvm::SmallDenseMap FileEntries;
   std::vector FunctionNames;
   std::vector FunctionRecords;
-  std::map CoveragePrefixMap;
+
+  /// Prefix replacement map for coverage.
+  llvm::SmallVector, 0>
+  CoveragePrefixMap;
 
   std::string getCurrentDirname();
   std::string normalizeFilename(StringRef Filename);
Index: clang/lib/CodeGen/CoverageMappingGen.cpp
===
--- clang/lib/CodeGen/CoverageMappingGen.cpp
+++ clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1635,7 +1635,8 @@
 CoverageMappingModuleGen::CoverageMappingModuleGen(
 CodeGenModule , CoverageSourceInfo )
 : CGM(CGM), SourceInfo(SourceInfo) {
-  CoveragePrefixMap = CGM.getCodeGenOpts().CoveragePrefixMap;
+  for (const auto &[From, To] : CGM.getCodeGenOpts().CoveragePrefixMap)
+CoveragePrefixMap.emplace_back(From, To);
 }
 
 std::string CoverageMappingModuleGen::getCurrentDirname() {
@@ -1650,10 +1651,13 @@
 std::string CoverageMappingModuleGen::normalizeFilename(StringRef Filename) {
   llvm::SmallString<256> Path(Filename);
   llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
-  for (const auto  : CoveragePrefixMap) {
-if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second))
+
+  // Traverse coverage prefix mapping options that are provided in reverse
+  // order.
+  for (const auto &[From, To] : llvm::reverse(CoveragePrefixMap))
+if (llvm::sys::path::replace_path_prefix(Path, From, To))
   break;
-  }
+
   return Path.str().str();
 }
 
Index: clang/include/clang/Basic/CodeGenOptions.h
===
--- clang/include/clang/Basic/CodeGenOptions.h
+++ clang/include/clang/Basic/CodeGenOptions.h
@@ -207,7 +207,9 @@
   std::string RecordCommandLine;
 
   std::map DebugPrefixMap;
-  std::map CoveragePrefixMap;
+
+  /// Prefix replacement map for coverage.
+  llvm::SmallVector, 0> CoveragePrefixMap;
 
   /// The 

[PATCH] D115907: [misexpect] Re-implement MisExpect Diagnostics

2023-04-25 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D115907#4295923 , @paulkirth wrote:

>> 2. Due to inlining etc., it often gets the source locations wrong, which 
>> means it points at code where again there were no expectations -- but 
>> perhaps that code got inlined into an expectations somewhere else. (e.g. 
>> https://crbug.com/1434989#c9)
>
> The checking depends somewhat on the instrumentation type (frontend vs. 
> backend instrumentation) In the case of frontend instrumentation, when the 
> expect intrinsic is lowered (very early in the pipeline) we can report the 
> diagnostic right away, since branch weights from profiling have already been 
> attached. The //should// mean that you should get fairly accurate source 
> information, since this happens before any optimizations run.

We use the backend instrumentation since that gives the best performance, but 
it's good to hear that the locations may be more accurate with frontend 
instrumentation. Maybe we should add that to the docs?

> The log also reported several places where expected hot code was never 
> executed. If that isn't desirable, I'd also suggest that you could use the 
> `-fdiagnostic-hotness-threshold=` to ignore reporting about branches that are 
> not executed some minimum number of times. MisExpect is remarks based, so I 
> beleive that is currently working. If not I'm happy to add that functionality.

Oh nice, I will try that flag.




Comment at: clang/include/clang/Driver/Options.td:1434
+def fdiagnostics_misexpect_tolerance_EQ : Joined<["-"], 
"fdiagnostics-misexpect-tolerance=">,
+Group, Flags<[CC1Option]>, MetaVarName<"">,
+HelpText<"Prevent misexpect diagnostics from being output if the profile 
counts are within N% of the expected. ">;

paulkirth wrote:
> hans wrote:
> > Should this be a driver mode option and not just cc1? The doc suggests 
> > using it, which currently won't work without an `-Xclang` prefix.
> That should also work from clang w/o `-Xclang`, shouldn't it? This is used 
> exactly like `-fdiagnostics-hotness-threshold=`, so IIRC that should still 
> work from clang.
Hmm, if I add `-fdiagnostics-misexpect-tolerance=10` I get errors about the 
flag being unused. I had to use `-Xclang` for it to work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115907

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


[PATCH] D148975: -fdebug-prefix-map=: make the last win when multiple prefixes match

2023-04-25 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added inline comments.



Comment at: clang/include/clang/Basic/CodeGenOptions.h:209
 
-  std::map DebugPrefixMap;
+  llvm::SmallVector, 0> DebugPrefixMap;
   std::map CoveragePrefixMap;

MaskRay wrote:
> scott.linder wrote:
> > What benefit does forcing allocation have? Why not use the default, or 
> > switch to `std::vector`?
> This doesn't force allocation. I use inline element size 0 to make the member 
> variable smaller than a `std::vector`.
> `std::vector` likely compiles to larger code.
Sorry, I just didn't realize this was idiomatic (i.e. I hadn't read 
https://llvm.org/docs/ProgrammersManual.html#vector), and I didn't see other 
similar uses in the file.

There are 15 `std::vector` members of `CodeGenOptions`, but no `SmallVector<_, 
0>` members; maybe the rest can be converted in an NFC patch, so things are 
consistent?



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:72-79
 CGDebugInfo::CGDebugInfo(CodeGenModule )
 : CGM(CGM), DebugKind(CGM.getCodeGenOpts().getDebugInfo()),
   DebugTypeExtRefs(CGM.getCodeGenOpts().DebugTypeExtRefs),
   DBuilder(CGM.getModule()) {
-  for (const auto  : CGM.getCodeGenOpts().DebugPrefixMap)
-DebugPrefixMap[KV.first] = KV.second;
+  for (const auto &[From, To] : CGM.getCodeGenOpts().DebugPrefixMap)
+DebugPrefixMap.emplace_back(From, To);
   CreateCompileUnit();

MaskRay wrote:
> scott.linder wrote:
> > Can you use the member-initializer-list here?
> No, this doesn't work. We convert a vector of `std::string` to a vector of 
> `StringRef`.
If all we are doing is creating another vector which shares the underlying 
strings with the original, why not just save a reference to the original 
vector? Is the cost of the extra dereference when accessing it greater than the 
cost of traversing it plus the extra storage for the `StringRef`s?

It seems like the original utility was just to get the `std::map` sorting 
behavior, which we no longer need.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148975

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


[PATCH] D149172: [clang][Interp] Emit proper diagnostic when comparing unrelated pointers

2023-04-25 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Also adds `toDiagnosticString()` to `Pointer` so we can use that when emitting 
the diagnostic.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149172

Files:
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/Pointer.cpp
  clang/lib/AST/Interp/Pointer.h
  clang/test/AST/Interp/literals.cpp


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -125,6 +125,35 @@
   static_assert(!!FP, "");
 }
 
+namespace PointerComparison {
+
+  struct S { int a, b; } s;
+  constexpr void *null = 0;
+  constexpr void *pv = (void*)
+  constexpr void *qv = (void*)
+  constexpr bool v1 = null < (int*)0;
+  constexpr bool v2 = null < pv; // expected-error {{must be initialized by a 
constant expression}} \
+ // expected-note {{comparison between 
'nullptr' and '' has unspecified value}} \
+ // ref-error {{must be initialized by a 
constant expression}} \
+ // ref-note {{comparison between 'nullptr' 
and '' has unspecified value}} \
+
+  constexpr bool v3 = null == pv; // ok
+  constexpr bool v4 = qv == pv; // ok
+
+  /// FIXME: These two are rejected by the current interpreter, but
+  ///   accepted by GCC.
+  constexpr bool v5 = qv >= pv; // ref-error {{constant expression}} \
+// ref-note {{unequal pointers to void}}
+  constexpr bool v8 = qv > (void*) // ref-error {{constant expression}} \
+// ref-note {{unequal pointers to 
void}}
+  constexpr bool v6 = qv > null; // expected-error {{must be initialized by a 
constant expression}} \
+ // expected-note {{comparison between '' 
and 'nullptr' has unspecified value}} \
+ // ref-error {{must be initialized by a 
constant expression}} \
+ // ref-note {{comparison between '' and 
'nullptr' has unspecified value}}
+
+  constexpr bool v7 = qv <= (void*) // ok
+}
+
 namespace SizeOf {
   constexpr int soint = sizeof(int);
   constexpr int souint = sizeof(unsigned int);
Index: clang/lib/AST/Interp/Pointer.h
===
--- clang/lib/AST/Interp/Pointer.h
+++ clang/lib/AST/Interp/Pointer.h
@@ -79,6 +79,9 @@
   /// Converts the pointer to an APValue.
   APValue toAPValue() const;
 
+  /// Converts the pointer to a string usable in diagnostics.
+  std::string toDiagnosticString(const ASTContext ) const;
+
   /// Converts the pointer to an APValue that is an rvalue.
   APValue toRValue(const Context ) const;
 
Index: clang/lib/AST/Interp/Pointer.cpp
===
--- clang/lib/AST/Interp/Pointer.cpp
+++ clang/lib/AST/Interp/Pointer.cpp
@@ -150,6 +150,13 @@
   return APValue(Base, Offset, Path, IsOnePastEnd, IsNullPtr);
 }
 
+std::string Pointer::toDiagnosticString(const ASTContext ) const {
+  if (!Pointee)
+return "nullptr";
+
+  return toAPValue().getAsString(Ctx, getType());
+}
+
 bool Pointer::isInitialized() const {
   assert(Pointee && "Cannot check if null pointer was initialized");
   Descriptor *Desc = getFieldDesc();
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -671,7 +671,9 @@
 
   if (!Pointer::hasSameBase(LHS, RHS)) {
 const SourceInfo  = S.Current->getSource(OpPC);
-S.FFDiag(Loc, diag::note_invalid_subexpr_in_const_expr);
+S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_unspecified)
+<< LHS.toDiagnosticString(S.getCtx())
+<< RHS.toDiagnosticString(S.getCtx());
 return false;
   } else {
 unsigned VL = LHS.getByteOffset();


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -125,6 +125,35 @@
   static_assert(!!FP, "");
 }
 
+namespace PointerComparison {
+
+  struct S { int a, b; } s;
+  constexpr void *null = 0;
+  constexpr void *pv = (void*)
+  constexpr void *qv = (void*)
+  constexpr bool v1 = null < (int*)0;
+  constexpr bool v2 = null < pv; // expected-error {{must be initialized by a constant expression}} \
+ // expected-note {{comparison between 'nullptr' and '' has unspecified value}} \
+ // ref-error {{must be initialized by a constant expression}} \
+ // ref-note {{comparison between 

[PATCH] D149123: [AArch64][InlineAsm]Add Clang support for flag output constraints

2023-04-25 Thread David Li via Phabricator via cfe-commits
davidxl added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:1216
+// Returns the length of cc constraint.
+static unsigned matchAsmCCConstraint(const char *) {
+  constexpr unsigned len = 5;

Name is not modified in this method, so perhaps dropping '&'?


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

https://reviews.llvm.org/D149123

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


[PATCH] D72538: [ThinLTO] Add additional ThinLTO pipeline testing with new PM

2023-04-25 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D72538#4291552 , @nikic wrote:

> Would it be possible to cut down the Clang side tests to only check parts 
> that Clang controls in some way, e.g. that SLPVectorizer is enabled? This 
> test is something of a PITA because it tests LLVM implementation details but 
> is not part of the LLVM tests, so it usually gets missed when doing pipeline 
> changes.

I think we can cut this down significantly, since the llvm tests added here 
check the full ThinLTO default pipeline setup at different opt levels. However, 
the point of the clang test is to make sure that for a distributed ThinLTO 
backend we correctly invoke thinBackend() which should set up the ThinLTO 
default pipeline. So how about I cut this down to check a single pass that is 
only invoked in the LTO backends? Specifically, I'm thinking of 
WholeProgramDevirtPass.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72538

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


  1   2   >