[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80585 (PR #80776)

2024-02-06 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru approved this pull request.


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


[llvm-branch-commits] [compiler-rt] PR for llvm/llvm-project#80808 (PR #80811)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/80811

resolves llvm/llvm-project#80808

>From 1a273a583fdf88a29923fa3f960f7e587131ccb7 Mon Sep 17 00:00:00 2001
From: Zequan Wu 
Date: Mon, 5 Feb 2024 15:27:34 -0500
Subject: [PATCH] [Profile][Windows] Drop extern for __buildid. (#80700)

(cherry picked from commit dd22140e21f2ef51cf031354966a3d41c191c6e7)
---
 compiler-rt/lib/profile/InstrProfilingPlatformWindows.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c 
b/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c
index c976776ae59e9c..0751b28f81d0ac 100644
--- a/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c
@@ -77,7 +77,7 @@ ValueProfNode *EndVNode = &VNodesEnd;
 /* lld-link provides __buildid symbol which ponits to the 16 bytes build id 
when
  * using /build-id flag. https://lld.llvm.org/windows_support.html#lld-flags */
 #define BUILD_ID_LEN 16
-COMPILER_RT_WEAK extern uint8_t __buildid[BUILD_ID_LEN];
+COMPILER_RT_WEAK uint8_t __buildid[BUILD_ID_LEN];
 COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) {
   if (*__buildid) {
 if (Writer &&

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


[llvm-branch-commits] [compiler-rt] PR for llvm/llvm-project#80808 (PR #80811)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/80811
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] PR for llvm/llvm-project#80808 (PR #80811)

2024-02-06 Thread via llvm-branch-commits

llvmbot wrote:

@nikic What do you think about merging this PR to the release branch?

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


[llvm-branch-commits] [compiler-rt] PR for llvm/llvm-project#80808 (PR #80811)

2024-02-06 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-pgo

Author: None (llvmbot)


Changes

resolves llvm/llvm-project#80808

---
Full diff: https://github.com/llvm/llvm-project/pull/80811.diff


1 Files Affected:

- (modified) compiler-rt/lib/profile/InstrProfilingPlatformWindows.c (+1-1) 


``diff
diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c 
b/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c
index c976776ae59e9..0751b28f81d0a 100644
--- a/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c
@@ -77,7 +77,7 @@ ValueProfNode *EndVNode = &VNodesEnd;
 /* lld-link provides __buildid symbol which ponits to the 16 bytes build id 
when
  * using /build-id flag. https://lld.llvm.org/windows_support.html#lld-flags */
 #define BUILD_ID_LEN 16
-COMPILER_RT_WEAK extern uint8_t __buildid[BUILD_ID_LEN];
+COMPILER_RT_WEAK uint8_t __buildid[BUILD_ID_LEN];
 COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) {
   if (*__buildid) {
 if (Writer &&

``




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


[llvm-branch-commits] [compiler-rt] PR for llvm/llvm-project#80808 (PR #80811)

2024-02-06 Thread Martin Storsjö via llvm-branch-commits

https://github.com/mstorsjo approved this pull request.

LGTM

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


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79861 (PR #80832)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/80832
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79861 (PR #80832)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/80832

resolves llvm/llvm-project#79861

>From 2fa03f1b20281a5a7f79b912dc5b2ab5aa1d3c76 Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Thu, 1 Feb 2024 12:57:59 +0100
Subject: [PATCH 1/3] [IndVars] Add tests for #79861 (NFC)

(cherry picked from commit c105848fd29d3b46eeb794bb6b10dad04f903b09)
---
 .../test/Transforms/IndVarSimplify/pr79861.ll | 104 ++
 1 file changed, 104 insertions(+)
 create mode 100644 llvm/test/Transforms/IndVarSimplify/pr79861.ll

diff --git a/llvm/test/Transforms/IndVarSimplify/pr79861.ll 
b/llvm/test/Transforms/IndVarSimplify/pr79861.ll
new file mode 100644
index 0..a8e2aa42a365c
--- /dev/null
+++ b/llvm/test/Transforms/IndVarSimplify/pr79861.ll
@@ -0,0 +1,104 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt -S -passes=indvars < %s | FileCheck %s
+
+target datalayout = "n64"
+
+declare void @use(i64)
+
+define void @or_disjoint() {
+; CHECK-LABEL: define void @or_disjoint() {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[LOOP:%.*]]
+; CHECK:   loop:
+; CHECK-NEXT:[[IV:%.*]] = phi i64 [ 2, [[ENTRY:%.*]] ], [ [[IV_DEC:%.*]], 
[[LOOP]] ]
+; CHECK-NEXT:[[OR:%.*]] = or disjoint i64 [[IV]], 1
+; CHECK-NEXT:call void @use(i64 [[OR]])
+; CHECK-NEXT:[[IV_DEC]] = add nsw i64 [[IV]], -1
+; CHECK-NEXT:[[EXIT_COND:%.*]] = icmp eq i64 [[IV_DEC]], 0
+; CHECK-NEXT:br i1 [[EXIT_COND]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK:   exit:
+; CHECK-NEXT:ret void
+;
+entry:
+  br label %loop
+
+loop:
+  %iv = phi i64 [ 2, %entry ], [ %iv.dec, %loop ]
+  %or = or disjoint i64 %iv, 1
+  %add = add nsw i64 %iv, 1
+  %sel = select i1 false, i64 %or, i64 %add
+  call void @use(i64 %sel)
+
+  %iv.dec = add nsw i64 %iv, -1
+  %exit.cond = icmp eq i64 %iv.dec, 0
+  br i1 %exit.cond, label %exit, label %loop
+
+exit:
+  ret void
+}
+
+define void @add_nowrap_flags(i64 %n) {
+; CHECK-LABEL: define void @add_nowrap_flags(
+; CHECK-SAME: i64 [[N:%.*]]) {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:br label [[LOOP:%.*]]
+; CHECK:   loop:
+; CHECK-NEXT:[[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_INC:%.*]], 
[[LOOP]] ]
+; CHECK-NEXT:[[ADD1:%.*]] = add nuw nsw i64 [[IV]], 123
+; CHECK-NEXT:call void @use(i64 [[ADD1]])
+; CHECK-NEXT:[[IV_INC]] = add i64 [[IV]], 1
+; CHECK-NEXT:[[EXIT_COND:%.*]] = icmp eq i64 [[IV_INC]], [[N]]
+; CHECK-NEXT:br i1 [[EXIT_COND]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK:   exit:
+; CHECK-NEXT:ret void
+;
+entry:
+  br label %loop
+
+loop:
+  %iv = phi i64 [ 0, %entry ], [ %iv.inc, %loop ]
+  %add1 = add nuw nsw i64 %iv, 123
+  %add2 = add i64 %iv, 123
+  %sel = select i1 false, i64 %add1, i64 %add2
+  call void @use(i64 %sel)
+
+  %iv.inc = add i64 %iv, 1
+  %exit.cond = icmp eq i64 %iv.inc, %n
+  br i1 %exit.cond, label %exit, label %loop
+
+exit:
+  ret void
+}
+
+
+define void @expander_or_disjoint(i64 %n) {
+; CHECK-LABEL: define void @expander_or_disjoint(
+; CHECK-SAME: i64 [[N:%.*]]) {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[OR:%.*]] = or i64 [[N]], 1
+; CHECK-NEXT:br label [[LOOP:%.*]]
+; CHECK:   loop:
+; CHECK-NEXT:[[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_INC:%.*]], 
[[LOOP]] ]
+; CHECK-NEXT:[[IV_INC]] = add i64 [[IV]], 1
+; CHECK-NEXT:[[ADD:%.*]] = add i64 [[IV]], [[OR]]
+; CHECK-NEXT:call void @use(i64 [[ADD]])
+; CHECK-NEXT:[[EXITCOND:%.*]] = icmp ne i64 [[IV_INC]], [[OR]]
+; CHECK-NEXT:br i1 [[EXITCOND]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK:   exit:
+; CHECK-NEXT:ret void
+;
+entry:
+  %or = or disjoint i64 %n, 1
+  br label %loop
+
+loop:
+  %iv = phi i64 [ 0, %entry ], [ %iv.inc, %loop ]
+  %iv.inc = add i64 %iv, 1
+  %add = add i64 %iv, %or
+  call void @use(i64 %add)
+  %cmp = icmp ult i64 %iv, %n
+  br i1 %cmp, label %loop, label %exit
+
+exit:
+  ret void
+}

>From 181baacaf52e766a8247b8af83d60c2a16b14752 Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Fri, 2 Feb 2024 10:52:05 +0100
Subject: [PATCH 2/3] [SCEVExpander] Do not reuse disjoint or (#80281)

SCEV treats "or disjoint" the same as "add nsw nuw". However, when
expanding, we cannot generally replace an add SCEV node with an "or
disjoint" instruction. Just dropping the poison flag is insufficient in
this case, we would have to actually convert the or into an add.

This is a partial fix for #79861.

(cherry picked from commit 5b8e1a6ebf11b6e93bcc96a0d009febe4bb3d7bc)
---
 llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | 7 +++
 llvm/test/Transforms/IndVarSimplify/pr79861.ll| 5 +++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp 
b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index a1d7f0f9ba0f7..e6f93e72c98a7 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms

[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79861 (PR #80832)

2024-02-06 Thread via llvm-branch-commits

llvmbot wrote:

@fhahn @fhahn What do you think about merging this PR to the release branch?

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


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79861 (PR #80832)

2024-02-06 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: None (llvmbot)


Changes

resolves llvm/llvm-project#79861

---
Full diff: https://github.com/llvm/llvm-project/pull/80832.diff


4 Files Affected:

- (modified) llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp (+7) 
- (modified) llvm/lib/Transforms/Utils/SimplifyIndVar.cpp (+16-2) 
- (modified) llvm/test/Transforms/IndVarSimplify/pr55925.ll (+2-2) 
- (added) llvm/test/Transforms/IndVarSimplify/pr79861.ll (+107) 


``diff
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp 
b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index a1d7f0f9ba0f7..e6f93e72c98a7 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -1401,6 +1401,13 @@ canReuseInstruction(ScalarEvolution &SE, const SCEV *S, 
Instruction *I,
 if (!I)
   return false;
 
+// Disjoint or instructions are interpreted as adds by SCEV. However, we
+// can't replace an arbitrary add with disjoint or, even if we drop the
+// flag. We would need to convert the or into an add.
+if (auto *PDI = dyn_cast(I))
+  if (PDI->isDisjoint())
+return false;
+
 // FIXME: Ignore vscale, even though it technically could be poison. Do 
this
 // because SCEV currently assumes it can't be poison. Remove this special
 // case once we proper model when vscale can be poison.
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp 
b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index 0ed3324a27b6c..1b142f14d8113 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -16,6 +16,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/LoopInfo.h"
+#include "llvm/Analysis/ValueTracking.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/Instructions.h"
@@ -713,8 +714,11 @@ bool 
SimplifyIndvar::replaceFloatIVWithIntegerIV(Instruction *UseInst) {
 bool SimplifyIndvar::eliminateIdentitySCEV(Instruction *UseInst,
Instruction *IVOperand) {
   if (!SE->isSCEVable(UseInst->getType()) ||
-  (UseInst->getType() != IVOperand->getType()) ||
-  (SE->getSCEV(UseInst) != SE->getSCEV(IVOperand)))
+  UseInst->getType() != IVOperand->getType())
+return false;
+
+  const SCEV *UseSCEV = SE->getSCEV(UseInst);
+  if (UseSCEV != SE->getSCEV(IVOperand))
 return false;
 
   // getSCEV(X) == getSCEV(Y) does not guarantee that X and Y are related in 
the
@@ -742,6 +746,16 @@ bool SimplifyIndvar::eliminateIdentitySCEV(Instruction 
*UseInst,
   if (!LI->replacementPreservesLCSSAForm(UseInst, IVOperand))
 return false;
 
+  // Make sure the operand is not more poisonous than the instruction.
+  if (!impliesPoison(IVOperand, UseInst)) {
+SmallVector DropPoisonGeneratingInsts;
+if (!SE->canReuseInstruction(UseSCEV, IVOperand, 
DropPoisonGeneratingInsts))
+  return false;
+
+for (Instruction *I : DropPoisonGeneratingInsts)
+  I->dropPoisonGeneratingFlagsAndMetadata();
+  }
+
   LLVM_DEBUG(dbgs() << "INDVARS: Eliminated identity: " << *UseInst << '\n');
 
   SE->forgetValue(UseInst);
diff --git a/llvm/test/Transforms/IndVarSimplify/pr55925.ll 
b/llvm/test/Transforms/IndVarSimplify/pr55925.ll
index 420fc209949d4..312a8295ccdc9 100644
--- a/llvm/test/Transforms/IndVarSimplify/pr55925.ll
+++ b/llvm/test/Transforms/IndVarSimplify/pr55925.ll
@@ -18,9 +18,9 @@ define void @test(ptr %p) personality ptr undef {
 ; CHECK-NEXT:[[RES:%.*]] = invoke i32 @foo(i32 returned [[TMP0]])
 ; CHECK-NEXT:to label [[LOOP_LATCH]] unwind label [[EXIT:%.*]]
 ; CHECK:   loop.latch:
-; CHECK-NEXT:[[INDVARS_IV_NEXT]] = add i64 [[INDVARS_IV]], 1
 ; CHECK-NEXT:[[TMP1:%.*]] = trunc i64 [[INDVARS_IV]] to i32
 ; CHECK-NEXT:[[TMP2:%.*]] = call i32 @foo(i32 [[TMP1]])
+; CHECK-NEXT:[[INDVARS_IV_NEXT]] = add i64 [[INDVARS_IV]], 1
 ; CHECK-NEXT:br label [[LOOP]]
 ; CHECK:   exit:
 ; CHECK-NEXT:[[LP:%.*]] = landingpad { ptr, i32 }
@@ -64,8 +64,8 @@ define void @test_critedge(i1 %c, ptr %p) personality ptr 
undef {
 ; CHECK-NEXT:br label [[LOOP_LATCH]]
 ; CHECK:   loop.latch:
 ; CHECK-NEXT:[[PHI:%.*]] = phi i32 [ [[TMP1]], [[LOOP_INVOKE]] ], [ 0, 
[[LOOP_OTHER]] ]
-; CHECK-NEXT:[[INDVARS_IV_NEXT]] = add i64 [[INDVARS_IV]], 1
 ; CHECK-NEXT:[[TMP2:%.*]] = call i32 @foo(i32 [[PHI]])
+; CHECK-NEXT:[[INDVARS_IV_NEXT]] = add i64 [[INDVARS_IV]], 1
 ; CHECK-NEXT:br label [[LOOP]]
 ; CHECK:   exit:
 ; CHECK-NEXT:[[LP:%.*]] = landingpad { ptr, i32 }
diff --git a/llvm/test/Transforms/IndVarSimplify/pr79861.ll 
b/llvm/test/Transforms/IndVarSimplify/pr79861.ll
new file mode 100644
index 0..6625094496139
--- /dev/null
+++ b/llvm/test/Transforms/IndVarSimplify/pr79861.ll
@@ -0,0 +1,107 @@
+; NOTE: Assertions have been autogenerated b

[llvm-branch-commits] [clang] PR for llvm/llvm-project#80843 (PR #80845)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/80845

resolves llvm/llvm-project#80843

>From f7c85e61fb243b209438ad58852a17d57925e47f Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Tue, 6 Feb 2024 06:23:22 -0800
Subject: [PATCH] [CLANG] Fix INF/NAN warning. (#80290)

In https://github.com/llvm/llvm-project/pull/76873 a warning was added
when the macros INFINITY and NAN are used in binary expressions when
-menable-no-nans or -menable-no-infs are used. If the user uses an
option that nullifies these two options, the warning will still be
generated. This patch adds an additional information to the warning
comment to let the user know about this. It also suppresses the warning
when #ifdef INFINITY, #ifdef NAN, #ifdef NAN or #ifndef NAN are used in
the code.

(cherry picked from commit 62c352e13c145b5606ace88ecbe9164ff011b5cf)
---
 .../clang/Basic/DiagnosticCommonKinds.td  |  2 +-
 clang/include/clang/Basic/DiagnosticDocs.td   |  9 +++
 clang/include/clang/Lex/Preprocessor.h| 11 ++--
 clang/lib/Lex/PPDirectives.cpp|  2 +-
 clang/lib/Lex/PPExpressions.cpp   |  4 +-
 .../Sema/warn-infinity-nan-disabled-lnx.cpp   | 60 ---
 .../Sema/warn-infinity-nan-disabled-win.cpp   | 60 ---
 7 files changed, 126 insertions(+), 22 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index b1bada65cb6b2..08bb1d81ba29f 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -73,7 +73,7 @@ def warn_pragma_debug_unexpected_argument : Warning<
 def warn_fp_nan_inf_when_disabled : Warning<
   "use of %select{infinity|NaN}0%select{| via a macro}1 is undefined behavior "
   "due to the currently enabled floating-point options">,
-  InGroup>;
+  InGroup>;
 }
 
 // Parse && Sema
diff --git a/clang/include/clang/Basic/DiagnosticDocs.td 
b/clang/include/clang/Basic/DiagnosticDocs.td
index e9862422b4997..8c024b5cad740 100644
--- a/clang/include/clang/Basic/DiagnosticDocs.td
+++ b/clang/include/clang/Basic/DiagnosticDocs.td
@@ -87,3 +87,12 @@ program by treating all string literals as having type 
``const char *``
 instead of ``char *``. This can cause unexpected behaviors with type-sensitive
 constructs like ``_Generic``.
 }];
+
+defvar NanInfDisabledDocs = [{
+This warning is enabled when source code using the macros ``INFINITY`` or 
``NAN``
+is compiled with floating-point options preventing these two values. This can
+lead to undefined behavior. Check the order of command line arguments that 
modify
+this behavior, such as ``-ffast-math``, ``-fhonor-infinities``, and
+``-fhonor-nans`` (etc), as well as ``#pragma`` directives if this diagnostic is
+generated unexpectedly.
+}];
diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 2d9c53cdf5bde..b0a8ec0fec5e9 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2828,7 +2828,8 @@ class Preprocessor {
 return AnnotationInfos.find(II)->second;
   }
 
-  void emitMacroExpansionWarnings(const Token &Identifier) const {
+  void emitMacroExpansionWarnings(const Token &Identifier,
+  bool IsIfnDef = false) const {
 IdentifierInfo *Info = Identifier.getIdentifierInfo();
 if (Info->isDeprecatedMacro())
   emitMacroDeprecationWarning(Identifier);
@@ -2837,12 +2838,12 @@ class Preprocessor {
 !SourceMgr.isInMainFile(Identifier.getLocation()))
   emitRestrictExpansionWarning(Identifier);
 
-if (Info->getName() == "INFINITY")
-  if (getLangOpts().NoHonorInfs)
+if (!IsIfnDef) {
+  if (Info->getName() == "INFINITY" && getLangOpts().NoHonorInfs)
 emitRestrictInfNaNWarning(Identifier, 0);
-if (Info->getName() == "NAN")
-  if (getLangOpts().NoHonorNaNs)
+  if (Info->getName() == "NAN" && getLangOpts().NoHonorNaNs)
 emitRestrictInfNaNWarning(Identifier, 1);
+}
   }
 
   static void processPathForFileMacro(SmallVectorImpl &Path,
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 9f82a6d073e3b..a980f4bcbae12 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -3288,7 +3288,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result,
 return;
   }
 
-  emitMacroExpansionWarnings(MacroNameTok);
+  emitMacroExpansionWarnings(MacroNameTok, /*IsIfnDef=*/true);
 
   // Check to see if this is the last token on the #if[n]def line.
   CheckEndOfDirective(isIfndef ? "ifndef" : "ifdef");
diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index 1feb0eb18d71e..8f25c67ec9dfb 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/lib/Lex/PPExpressions.cpp
@@ -133,7 +133,9 @@ static bool EvaluateDefined(PPValue &Result, Token 
&PeekTok, DefinedTracker &DT,
   Result.Val.setIs

[llvm-branch-commits] [clang] PR for llvm/llvm-project#80843 (PR #80845)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/80845
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] PR for llvm/llvm-project#80843 (PR #80845)

2024-02-06 Thread via llvm-branch-commits

llvmbot wrote:

@AaronBallman What do you think about merging this PR to the release branch?

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


[llvm-branch-commits] [clang] PR for llvm/llvm-project#80843 (PR #80845)

2024-02-06 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (llvmbot)


Changes

resolves llvm/llvm-project#80843

---
Full diff: https://github.com/llvm/llvm-project/pull/80845.diff


7 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticCommonKinds.td (+1-1) 
- (modified) clang/include/clang/Basic/DiagnosticDocs.td (+9) 
- (modified) clang/include/clang/Lex/Preprocessor.h (+6-5) 
- (modified) clang/lib/Lex/PPDirectives.cpp (+1-1) 
- (modified) clang/lib/Lex/PPExpressions.cpp (+3-1) 
- (modified) clang/test/Sema/warn-infinity-nan-disabled-lnx.cpp (+53-7) 
- (modified) clang/test/Sema/warn-infinity-nan-disabled-win.cpp (+53-7) 


``diff
diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index b1bada65cb6b2..08bb1d81ba29f 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -73,7 +73,7 @@ def warn_pragma_debug_unexpected_argument : Warning<
 def warn_fp_nan_inf_when_disabled : Warning<
   "use of %select{infinity|NaN}0%select{| via a macro}1 is undefined behavior "
   "due to the currently enabled floating-point options">,
-  InGroup>;
+  InGroup>;
 }
 
 // Parse && Sema
diff --git a/clang/include/clang/Basic/DiagnosticDocs.td 
b/clang/include/clang/Basic/DiagnosticDocs.td
index e9862422b4997..8c024b5cad740 100644
--- a/clang/include/clang/Basic/DiagnosticDocs.td
+++ b/clang/include/clang/Basic/DiagnosticDocs.td
@@ -87,3 +87,12 @@ program by treating all string literals as having type 
``const char *``
 instead of ``char *``. This can cause unexpected behaviors with type-sensitive
 constructs like ``_Generic``.
 }];
+
+defvar NanInfDisabledDocs = [{
+This warning is enabled when source code using the macros ``INFINITY`` or 
``NAN``
+is compiled with floating-point options preventing these two values. This can
+lead to undefined behavior. Check the order of command line arguments that 
modify
+this behavior, such as ``-ffast-math``, ``-fhonor-infinities``, and
+``-fhonor-nans`` (etc), as well as ``#pragma`` directives if this diagnostic is
+generated unexpectedly.
+}];
diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 2d9c53cdf5bde..b0a8ec0fec5e9 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2828,7 +2828,8 @@ class Preprocessor {
 return AnnotationInfos.find(II)->second;
   }
 
-  void emitMacroExpansionWarnings(const Token &Identifier) const {
+  void emitMacroExpansionWarnings(const Token &Identifier,
+  bool IsIfnDef = false) const {
 IdentifierInfo *Info = Identifier.getIdentifierInfo();
 if (Info->isDeprecatedMacro())
   emitMacroDeprecationWarning(Identifier);
@@ -2837,12 +2838,12 @@ class Preprocessor {
 !SourceMgr.isInMainFile(Identifier.getLocation()))
   emitRestrictExpansionWarning(Identifier);
 
-if (Info->getName() == "INFINITY")
-  if (getLangOpts().NoHonorInfs)
+if (!IsIfnDef) {
+  if (Info->getName() == "INFINITY" && getLangOpts().NoHonorInfs)
 emitRestrictInfNaNWarning(Identifier, 0);
-if (Info->getName() == "NAN")
-  if (getLangOpts().NoHonorNaNs)
+  if (Info->getName() == "NAN" && getLangOpts().NoHonorNaNs)
 emitRestrictInfNaNWarning(Identifier, 1);
+}
   }
 
   static void processPathForFileMacro(SmallVectorImpl &Path,
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 9f82a6d073e3b..a980f4bcbae12 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -3288,7 +3288,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result,
 return;
   }
 
-  emitMacroExpansionWarnings(MacroNameTok);
+  emitMacroExpansionWarnings(MacroNameTok, /*IsIfnDef=*/true);
 
   // Check to see if this is the last token on the #if[n]def line.
   CheckEndOfDirective(isIfndef ? "ifndef" : "ifdef");
diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index 1feb0eb18d71e..8f25c67ec9dfb 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/lib/Lex/PPExpressions.cpp
@@ -133,7 +133,9 @@ static bool EvaluateDefined(PPValue &Result, Token 
&PeekTok, DefinedTracker &DT,
   Result.Val.setIsUnsigned(false); // Result is signed intmax_t.
   DT.IncludedUndefinedIds = !Macro;
 
-  PP.emitMacroExpansionWarnings(PeekTok);
+  PP.emitMacroExpansionWarnings(
+  PeekTok,
+  (II->getName() == "INFINITY" || II->getName() == "NAN") ? true : false);
 
   // If there is a macro, mark it used.
   if (Result.Val != 0 && ValueLive)
diff --git a/clang/test/Sema/warn-infinity-nan-disabled-lnx.cpp 
b/clang/test/Sema/warn-infinity-nan-disabled-lnx.cpp
index 8a610fa0e737e..03a432e05851d 100644
--- a/clang/test/Sema/warn-infinity-nan-disabled-lnx.cpp
+++ b/clang/test/Sema/warn-infinity-nan-disabled-lnx.cpp
@@ -1,13 +1,31 @@
-// RUN: %clang_cc1 -x c++ -verify=no-inf-no-nan -triple 
p

[llvm-branch-commits] [clang] PR for llvm/llvm-project#80844 (PR #80846)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/80846
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] PR for llvm/llvm-project#80844 (PR #80846)

2024-02-06 Thread via llvm-branch-commits

llvmbot wrote:

@kmclaughlin-arm What do you think about merging this PR to the release branch?

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


[llvm-branch-commits] [clang] PR for llvm/llvm-project#80844 (PR #80846)

2024-02-06 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (llvmbot)


Changes

resolves llvm/llvm-project#80844

---

Patch is 113.68 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/80846.diff


49 Files Affected:

- (modified) clang/include/clang/Basic/arm_sme.td (+16-12) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_add-i32.c 
(+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_add-i64.c 
(+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_cnt.c (+3-3) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ld1.c (+3-3) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ld1_vnum.c 
(+3-3) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ldr.c (+3-3) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mopa-za32.c 
(+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mopa-za64.c 
(+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mops-za32.c 
(+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_mops-za64.c 
(+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_read.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_st1.c (+3-3) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_st1_vnum.c 
(+3-3) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_str.c (+3-3) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_write.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_zero.c (+3-3) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_add.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_bmop.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_clamp.c 
(+10-10) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_cvt.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_cvtn.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_frint.c 
(+5-5) 
- (modified) 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti2_lane_zt.c (+3-3) 
- (modified) 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti2_lane_zt_x2.c (+3-3) 
- (modified) 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti2_lane_zt_x4.c (+3-3) 
- (modified) 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti4_lane_zt.c (+3-3) 
- (modified) 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti4_lane_zt_x2.c (+3-3) 
- (modified) 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti4_lane_zt_x4.c (+3-3) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_max.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_maxnm.c 
(+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_min.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_minnm.c 
(+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_mop.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_read.c (+3-3) 
- (modified) 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_reinterpret_svcount_svbool.c
 (+4-4) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_sub.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_unpkx2.c 
(+6-6) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_unpkx4.c 
(+6-6) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_vector_add.c 
(+5-5) 
- (modified) 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_vector_qrshr.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_vector_rshl.c 
(+5-5) 
- (modified) 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_vector_selx2.c (+5-5) 
- (modified) 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_vector_selx4.c (+5-5) 
- (modified) 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_vector_uzpx2.c (+5-5) 
- (modified) 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_vector_uzpx4.c (+5-5) 
- (modified) 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_vector_zipx2.c (+5-5) 
- (modified) 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_vector_zipx4.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write.c 
(+5-5) 


``diff
diff --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index 695e1bddf9ffc..2da0e8d2aba9a 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -44,6 +44,7 @@ defm SVLD1_ZA32 : ZALoad<"za32", "i", "aarch64_sme_ld1w", 
[ImmCheck<0, ImmCheck0
 defm SVLD1_ZA64 : ZALoad<"za64", "l", "aarch64_sme_ld1d", [ImmCheck<0, 
ImmCheck0_7>]>;
 defm SVLD1_ZA128 : ZALoad<"za128", "q", "aarch64_sme_ld1q", [ImmCheck<0, 
ImmCheck0_15>]>;
 
+let TargetGuard = "sme" in {
 def SVLDR_VNUM_ZA : MInst<"svldr_vnum_za", "vmQl

[llvm-branch-commits] [clang] PR for llvm/llvm-project#80843 (PR #80845)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/80845

>From 3ba4e5fda3394a633604c97b7180947cd928e41d Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Tue, 6 Feb 2024 06:23:22 -0800
Subject: [PATCH] [CLANG] Fix INF/NAN warning. (#80290)

In https://github.com/llvm/llvm-project/pull/76873 a warning was added
when the macros INFINITY and NAN are used in binary expressions when
-menable-no-nans or -menable-no-infs are used. If the user uses an
option that nullifies these two options, the warning will still be
generated. This patch adds an additional information to the warning
comment to let the user know about this. It also suppresses the warning
when #ifdef INFINITY, #ifdef NAN, #ifdef NAN or #ifndef NAN are used in
the code.

(cherry picked from commit 62c352e13c145b5606ace88ecbe9164ff011b5cf)
---
 .../clang/Basic/DiagnosticCommonKinds.td  |  2 +-
 clang/include/clang/Basic/DiagnosticDocs.td   |  9 +++
 clang/include/clang/Lex/Preprocessor.h| 11 ++--
 clang/lib/Lex/PPDirectives.cpp|  2 +-
 clang/lib/Lex/PPExpressions.cpp   |  4 +-
 .../Sema/warn-infinity-nan-disabled-lnx.cpp   | 60 ---
 .../Sema/warn-infinity-nan-disabled-win.cpp   | 60 ---
 7 files changed, 126 insertions(+), 22 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index b1bada65cb6b2..08bb1d81ba29f 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -73,7 +73,7 @@ def warn_pragma_debug_unexpected_argument : Warning<
 def warn_fp_nan_inf_when_disabled : Warning<
   "use of %select{infinity|NaN}0%select{| via a macro}1 is undefined behavior "
   "due to the currently enabled floating-point options">,
-  InGroup>;
+  InGroup>;
 }
 
 // Parse && Sema
diff --git a/clang/include/clang/Basic/DiagnosticDocs.td 
b/clang/include/clang/Basic/DiagnosticDocs.td
index e9862422b4997..8c024b5cad740 100644
--- a/clang/include/clang/Basic/DiagnosticDocs.td
+++ b/clang/include/clang/Basic/DiagnosticDocs.td
@@ -87,3 +87,12 @@ program by treating all string literals as having type 
``const char *``
 instead of ``char *``. This can cause unexpected behaviors with type-sensitive
 constructs like ``_Generic``.
 }];
+
+defvar NanInfDisabledDocs = [{
+This warning is enabled when source code using the macros ``INFINITY`` or 
``NAN``
+is compiled with floating-point options preventing these two values. This can
+lead to undefined behavior. Check the order of command line arguments that 
modify
+this behavior, such as ``-ffast-math``, ``-fhonor-infinities``, and
+``-fhonor-nans`` (etc), as well as ``#pragma`` directives if this diagnostic is
+generated unexpectedly.
+}];
diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 2d9c53cdf5bde..b0a8ec0fec5e9 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2828,7 +2828,8 @@ class Preprocessor {
 return AnnotationInfos.find(II)->second;
   }
 
-  void emitMacroExpansionWarnings(const Token &Identifier) const {
+  void emitMacroExpansionWarnings(const Token &Identifier,
+  bool IsIfnDef = false) const {
 IdentifierInfo *Info = Identifier.getIdentifierInfo();
 if (Info->isDeprecatedMacro())
   emitMacroDeprecationWarning(Identifier);
@@ -2837,12 +2838,12 @@ class Preprocessor {
 !SourceMgr.isInMainFile(Identifier.getLocation()))
   emitRestrictExpansionWarning(Identifier);
 
-if (Info->getName() == "INFINITY")
-  if (getLangOpts().NoHonorInfs)
+if (!IsIfnDef) {
+  if (Info->getName() == "INFINITY" && getLangOpts().NoHonorInfs)
 emitRestrictInfNaNWarning(Identifier, 0);
-if (Info->getName() == "NAN")
-  if (getLangOpts().NoHonorNaNs)
+  if (Info->getName() == "NAN" && getLangOpts().NoHonorNaNs)
 emitRestrictInfNaNWarning(Identifier, 1);
+}
   }
 
   static void processPathForFileMacro(SmallVectorImpl &Path,
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 9f82a6d073e3b..a980f4bcbae12 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -3288,7 +3288,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result,
 return;
   }
 
-  emitMacroExpansionWarnings(MacroNameTok);
+  emitMacroExpansionWarnings(MacroNameTok, /*IsIfnDef=*/true);
 
   // Check to see if this is the last token on the #if[n]def line.
   CheckEndOfDirective(isIfndef ? "ifndef" : "ifdef");
diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index 1feb0eb18d71e..8f25c67ec9dfb 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/lib/Lex/PPExpressions.cpp
@@ -133,7 +133,9 @@ static bool EvaluateDefined(PPValue &Result, Token 
&PeekTok, DefinedTracker &DT,
   Result.Val.setIsUnsigned(false); // Result is sign

[llvm-branch-commits] [clang] PR for llvm/llvm-project#80843 (PR #80845)

2024-02-06 Thread Aaron Ballman via llvm-branch-commits

https://github.com/AaronBallman approved this pull request.

LGTM!

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


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80877 (PR #80878)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/80878

resolves llvm/llvm-project#80877

>From 1454e3a8c7714197e6d4cf962bd454a61c68289c Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Tue, 6 Feb 2024 09:23:33 -0800
Subject: [PATCH] [MIPS] Use generic isBlockOnlyReachableByFallthrough (#80799)

FastISel may create a redundant BGTZ terminal which fallthroughes.
```
  BGTZ %2:gpr32, %bb.1, implicit-def $at

bb.1.bb1:
; predecessors: %bb.0
```

The `!I->isBarrier()` check in
MipsAsmPrinter::isBlockOnlyReachableByFallthrough
will incorrectly not print a label, leading to a `Undefined temporary
symbol `
error when we try assembling the output assembly file. See the updated
`Fast-ISel/pr40325.ll` and
https://github.com/rust-lang/rust/issues/108835

In addition, the `SwitchInst` condition is too conservative and prints
many unneeded labels (see the updated tests).

Just use the generic isBlockOnlyReachableByFallthrough, updated by
commit 1995b9fead62f2f6c0ad217bd00ce3184f741fdb for SPARC, which also
handles MIPS.

(cherry picked from commit 6b2fd7aed66d592738f26c76caa8fff95e168598)
---
 llvm/lib/Target/Mips/MipsAsmPrinter.cpp   | 39 ---
 llvm/lib/Target/Mips/MipsAsmPrinter.h |  2 -
 llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll   |  2 +-
 .../GlobalISel/llvm-ir/jump_table_and_brjt.ll |  8 ++--
 .../unsafe-in-forbidden-slot.ll   |  4 +-
 .../Mips/indirect-jump-hazard/jumptables.ll   | 16 
 llvm/test/CodeGen/Mips/jump-table-mul.ll  |  2 +-
 llvm/test/CodeGen/Mips/pseudo-jump-fill.ll|  2 +-
 8 files changed, 17 insertions(+), 58 deletions(-)

diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp 
b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
index 718844bc36ff9..66b2b0de8d52a 100644
--- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -471,45 +471,6 @@ void MipsAsmPrinter::emitBasicBlockEnd(const 
MachineBasicBlock &MBB) {
 TS.emitDirectiveInsn();
 }
 
-/// isBlockOnlyReachableByFallthough - Return true if the basic block has
-/// exactly one predecessor and the control transfer mechanism between
-/// the predecessor and this block is a fall-through.
-bool MipsAsmPrinter::isBlockOnlyReachableByFallthrough(const MachineBasicBlock*
-   MBB) const {
-  // The predecessor has to be immediately before this block.
-  const MachineBasicBlock *Pred = *MBB->pred_begin();
-
-  // If the predecessor is a switch statement, assume a jump table
-  // implementation, so it is not a fall through.
-  if (const BasicBlock *bb = Pred->getBasicBlock())
-if (isa(bb->getTerminator()))
-  return false;
-
-  // If this is a landing pad, it isn't a fall through.  If it has no preds,
-  // then nothing falls through to it.
-  if (MBB->isEHPad() || MBB->pred_empty())
-return false;
-
-  // If there isn't exactly one predecessor, it can't be a fall through.
-  if (MBB->pred_size() != 1)
-return false;
-
-  // The predecessor has to be immediately before this block.
-  if (!Pred->isLayoutSuccessor(MBB))
-return false;
-
-  // If the block is completely empty, then it definitely does fall through.
-  if (Pred->empty())
-return true;
-
-  // Otherwise, check the last instruction.
-  // Check if the last terminator is an unconditional branch.
-  MachineBasicBlock::const_iterator I = Pred->end();
-  while (I != Pred->begin() && !(--I)->isTerminator()) ;
-
-  return !I->isBarrier();
-}
-
 // Print out an operand for an inline asm expression.
 bool MipsAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
  const char *ExtraCode, raw_ostream &O) {
diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.h 
b/llvm/lib/Target/Mips/MipsAsmPrinter.h
index 64424b181504a..0b55089385d79 100644
--- a/llvm/lib/Target/Mips/MipsAsmPrinter.h
+++ b/llvm/lib/Target/Mips/MipsAsmPrinter.h
@@ -142,8 +142,6 @@ class LLVM_LIBRARY_VISIBILITY MipsAsmPrinter : public 
AsmPrinter {
   void emitFunctionBodyStart() override;
   void emitFunctionBodyEnd() override;
   void emitBasicBlockEnd(const MachineBasicBlock &MBB) override;
-  bool isBlockOnlyReachableByFallthrough(
-   const MachineBasicBlock* MBB) const 
override;
   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
const char *ExtraCode, raw_ostream &O) override;
   bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
diff --git a/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll 
b/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll
index 9e64d7b2fa039..c276515920d52 100644
--- a/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll
+++ b/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll
@@ -11,7 +11,7 @@ define void @test(i32 %x, ptr %p) nounwind {
 ; CHECK-NEXT:andi $1, $4, 1
 ; CHECK-NEXT:bgtz $1, $BB0_1
 ; CHECK-NEXT:nop
-; CHECK-NEXT:  # %bb.1: # %foo
+; CHECK-NEXT:  $BB0_1: # %foo
 ; CHECK-NEXT:jr $ra
 ;

[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80877 (PR #80878)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/80878
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80877 (PR #80878)

2024-02-06 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-globalisel

Author: None (llvmbot)


Changes

resolves llvm/llvm-project#80877

---
Full diff: https://github.com/llvm/llvm-project/pull/80878.diff


8 Files Affected:

- (modified) llvm/lib/Target/Mips/MipsAsmPrinter.cpp (-39) 
- (modified) llvm/lib/Target/Mips/MipsAsmPrinter.h (-2) 
- (modified) llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll (+1-1) 
- (modified) llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/jump_table_and_brjt.ll 
(+4-4) 
- (modified) llvm/test/CodeGen/Mips/compactbranches/unsafe-in-forbidden-slot.ll 
(+2-2) 
- (modified) llvm/test/CodeGen/Mips/indirect-jump-hazard/jumptables.ll (+8-8) 
- (modified) llvm/test/CodeGen/Mips/jump-table-mul.ll (+1-1) 
- (modified) llvm/test/CodeGen/Mips/pseudo-jump-fill.ll (+1-1) 


``diff
diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp 
b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
index 718844bc36ff9..66b2b0de8d52a 100644
--- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -471,45 +471,6 @@ void MipsAsmPrinter::emitBasicBlockEnd(const 
MachineBasicBlock &MBB) {
 TS.emitDirectiveInsn();
 }
 
-/// isBlockOnlyReachableByFallthough - Return true if the basic block has
-/// exactly one predecessor and the control transfer mechanism between
-/// the predecessor and this block is a fall-through.
-bool MipsAsmPrinter::isBlockOnlyReachableByFallthrough(const MachineBasicBlock*
-   MBB) const {
-  // The predecessor has to be immediately before this block.
-  const MachineBasicBlock *Pred = *MBB->pred_begin();
-
-  // If the predecessor is a switch statement, assume a jump table
-  // implementation, so it is not a fall through.
-  if (const BasicBlock *bb = Pred->getBasicBlock())
-if (isa(bb->getTerminator()))
-  return false;
-
-  // If this is a landing pad, it isn't a fall through.  If it has no preds,
-  // then nothing falls through to it.
-  if (MBB->isEHPad() || MBB->pred_empty())
-return false;
-
-  // If there isn't exactly one predecessor, it can't be a fall through.
-  if (MBB->pred_size() != 1)
-return false;
-
-  // The predecessor has to be immediately before this block.
-  if (!Pred->isLayoutSuccessor(MBB))
-return false;
-
-  // If the block is completely empty, then it definitely does fall through.
-  if (Pred->empty())
-return true;
-
-  // Otherwise, check the last instruction.
-  // Check if the last terminator is an unconditional branch.
-  MachineBasicBlock::const_iterator I = Pred->end();
-  while (I != Pred->begin() && !(--I)->isTerminator()) ;
-
-  return !I->isBarrier();
-}
-
 // Print out an operand for an inline asm expression.
 bool MipsAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
  const char *ExtraCode, raw_ostream &O) {
diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.h 
b/llvm/lib/Target/Mips/MipsAsmPrinter.h
index 64424b181504a..0b55089385d79 100644
--- a/llvm/lib/Target/Mips/MipsAsmPrinter.h
+++ b/llvm/lib/Target/Mips/MipsAsmPrinter.h
@@ -142,8 +142,6 @@ class LLVM_LIBRARY_VISIBILITY MipsAsmPrinter : public 
AsmPrinter {
   void emitFunctionBodyStart() override;
   void emitFunctionBodyEnd() override;
   void emitBasicBlockEnd(const MachineBasicBlock &MBB) override;
-  bool isBlockOnlyReachableByFallthrough(
-   const MachineBasicBlock* MBB) const 
override;
   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
const char *ExtraCode, raw_ostream &O) override;
   bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
diff --git a/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll 
b/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll
index 9e64d7b2fa039..c276515920d52 100644
--- a/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll
+++ b/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll
@@ -11,7 +11,7 @@ define void @test(i32 %x, ptr %p) nounwind {
 ; CHECK-NEXT:andi $1, $4, 1
 ; CHECK-NEXT:bgtz $1, $BB0_1
 ; CHECK-NEXT:nop
-; CHECK-NEXT:  # %bb.1: # %foo
+; CHECK-NEXT:  $BB0_1: # %foo
 ; CHECK-NEXT:jr $ra
 ; CHECK-NEXT:nop
   %y = and i32 %x, 1
diff --git a/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/jump_table_and_brjt.ll 
b/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/jump_table_and_brjt.ll
index 4c10fedaa4a88..74765ff0e8f10 100644
--- a/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/jump_table_and_brjt.ll
+++ b/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/jump_table_and_brjt.ll
@@ -25,7 +25,7 @@ define i32 @mod4_0_to_11(i32 %a) {
 ; MIPS32-NEXT:sltu $1, $1, $2
 ; MIPS32-NEXT:bnez $1, $BB0_6
 ; MIPS32-NEXT:nop
-; MIPS32-NEXT:  $BB0_1: # %entry
+; MIPS32-NEXT:  # %bb.1: # %entry
 ; MIPS32-NEXT:lw $2, 28($sp) # 4-byte Folded Reload
 ; MIPS32-NEXT:lui $1, %hi($JTI0_0)
 ; MIPS32-NEXT:sll $2, $2, 2
@@ -65,7 +65,7 @@ define i32 @mod4_0_to_11(i32 %a) {
 ; MIPS32-NEXT:sltu $1, $1, $2
 ; MIPS32-NEXT:bnez $1, $BB0_13
 ; MIPS32-

[llvm-branch-commits] [clang] [llvm] PR for llvm/llvm-project#80565 (PR #80566)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/80566

>From ad0fb418badbb695b5db9335985e67c67e69c554 Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Fri, 2 Feb 2024 11:35:08 -0800
Subject: [PATCH] [CMake][PGO] Add option for using an external project to
 generate profile data (#78879)

The new CLANG_PGO_TRAINING_DATA_SOURCE_DIR allows users to specify a
CMake project to use for generating the profile data. For example, to
use the llvm-test-suite to generate profile data you would do:

$ cmake -G Ninja -B build -S llvm -C /clang/cmake/caches/PGO.cmake \
-DBOOTSTRAP_CLANG_PGO_TRAINING_DATA_SOURCE_DIR=
\
-DBOOTSTRAP_CLANG_PGO_TRAINING_DEPS=runtimes

Note that the CLANG_PERF_TRAINING_DEPS has been renamed to
CLANG_PGO_TRAINING_DEPS.

-

Co-authored-by: Petr Hosek 
(cherry picked from commit dd0356d741aefa25ece973d6cc4b55dcb73b84b4)
---
 clang/utils/perf-training/CMakeLists.txt | 15 ++---
 clang/utils/perf-training/perf-helper.py | 16 --
 llvm/docs/AdvancedBuilds.rst | 27 ++--
 3 files changed, 46 insertions(+), 12 deletions(-)

diff --git a/clang/utils/perf-training/CMakeLists.txt 
b/clang/utils/perf-training/CMakeLists.txt
index c6d51863fb1b5..93744f4606023 100644
--- a/clang/utils/perf-training/CMakeLists.txt
+++ b/clang/utils/perf-training/CMakeLists.txt
@@ -1,6 +1,10 @@
+include(LLVMExternalProjectUtils)
+
 set(CLANG_PGO_TRAINING_DATA "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH
   "The path to a lit testsuite containing samples for PGO and order file 
generation"
   )
+set(CLANG_PGO_TRAINING_DATA_SOURCE_DIR OFF CACHE STRING "Path to source 
directory containing cmake project with source files to use for generating pgo 
data")
+set(CLANG_PGO_TRAINING_DEPS "" CACHE STRING "Extra dependencies needed to 
build the PGO training data.")
 
 if(LLVM_BUILD_INSTRUMENTED)
   configure_lit_site_cfg(
@@ -11,11 +15,11 @@ if(LLVM_BUILD_INSTRUMENTED)
   add_lit_testsuite(generate-profraw "Generating clang PGO data"
 ${CMAKE_CURRENT_BINARY_DIR}/pgo-data/
 EXCLUDE_FROM_CHECK_ALL
-DEPENDS clang clear-profraw ${CLANG_PERF_TRAINING_DEPS}
+DEPENDS clang clear-profraw ${CLANG_PGO_TRAINING_DEPS}
 )
 
   add_custom_target(clear-profraw
-COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
clean ${CMAKE_CURRENT_BINARY_DIR} profraw
+COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
clean ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}/profiles/ profraw
 COMMENT "Clearing old profraw data")
 
   if(NOT LLVM_PROFDATA)
@@ -26,9 +30,14 @@ if(LLVM_BUILD_INSTRUMENTED)
 message(STATUS "To enable merging PGO data LLVM_PROFDATA has to point to 
llvm-profdata")
   else()
 add_custom_target(generate-profdata
-  COMMAND "${Python3_EXECUTABLE}" 
${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} 
${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR}
+  COMMAND "${Python3_EXECUTABLE}" 
${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} 
${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR} 
${CMAKE_BINARY_DIR}/profiles/
   COMMENT "Merging profdata"
   DEPENDS generate-profraw)
+if (CLANG_PGO_TRAINING_DATA_SOURCE_DIR)
+  llvm_ExternalProject_Add(generate-profraw-external 
${CLANG_PGO_TRAINING_DATA_SOURCE_DIR}
+  USE_TOOLCHAIN EXLUDE_FROM_ALL NO_INSTALL DEPENDS 
generate-profraw)
+  add_dependencies(generate-profdata generate-profraw-external)
+endif()
   endif()
 endif()
 
diff --git a/clang/utils/perf-training/perf-helper.py 
b/clang/utils/perf-training/perf-helper.py
index 99d6ab6ef..3e92cd38a7145 100644
--- a/clang/utils/perf-training/perf-helper.py
+++ b/clang/utils/perf-training/perf-helper.py
@@ -30,26 +30,28 @@ def findFilesWithExtension(path, extension):
 
 
 def clean(args):
-if len(args) != 2:
+if len(args) < 2:
 print(
-"Usage: %s clean  \n" % __file__
+"Usage: %s clean  \n" % __file__
 + "\tRemoves all files with extension from ."
 )
 return 1
-for filename in findFilesWithExtension(args[0], args[1]):
-os.remove(filename)
+for path in args[1:-1]:
+for filename in findFilesWithExtension(path, args[-1]):
+os.remove(filename)
 return 0
 
 
 def merge(args):
-if len(args) != 3:
+if len(args) < 3:
 print(
-"Usage: %s merge   \n" % __file__
+"Usage: %s merge   \n" % __file__
 + "\tMerges all profraw files from path into output."
 )
 return 1
 cmd = [args[0], "merge", "-o", args[1]]
-cmd.extend(findFilesWithExtension(args[2], "profraw"))
+for path in args[2:]:
+cmd.extend(findFilesWithExtension(path, "profraw"))
 subprocess.check_call(cmd)
 return 0
 
diff --git a/llvm/docs/AdvancedBuilds.rst b/llvm/docs/AdvancedBuilds.rst
index 960b19fa5317f..ee

[llvm-branch-commits] [clang] ad0fb41 - [CMake][PGO] Add option for using an external project to generate profile data (#78879)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

Author: Tom Stellard
Date: 2024-02-06T11:49:07-08:00
New Revision: ad0fb418badbb695b5db9335985e67c67e69c554

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

LOG: [CMake][PGO] Add option for using an external project to generate profile 
data (#78879)

The new CLANG_PGO_TRAINING_DATA_SOURCE_DIR allows users to specify a
CMake project to use for generating the profile data. For example, to
use the llvm-test-suite to generate profile data you would do:

$ cmake -G Ninja -B build -S llvm -C /clang/cmake/caches/PGO.cmake \
-DBOOTSTRAP_CLANG_PGO_TRAINING_DATA_SOURCE_DIR=
\
-DBOOTSTRAP_CLANG_PGO_TRAINING_DEPS=runtimes

Note that the CLANG_PERF_TRAINING_DEPS has been renamed to
CLANG_PGO_TRAINING_DEPS.

-

Co-authored-by: Petr Hosek 
(cherry picked from commit dd0356d741aefa25ece973d6cc4b55dcb73b84b4)

Added: 


Modified: 
clang/utils/perf-training/CMakeLists.txt
clang/utils/perf-training/perf-helper.py
llvm/docs/AdvancedBuilds.rst

Removed: 




diff  --git a/clang/utils/perf-training/CMakeLists.txt 
b/clang/utils/perf-training/CMakeLists.txt
index c6d51863fb1b5c..93744f46060236 100644
--- a/clang/utils/perf-training/CMakeLists.txt
+++ b/clang/utils/perf-training/CMakeLists.txt
@@ -1,6 +1,10 @@
+include(LLVMExternalProjectUtils)
+
 set(CLANG_PGO_TRAINING_DATA "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH
   "The path to a lit testsuite containing samples for PGO and order file 
generation"
   )
+set(CLANG_PGO_TRAINING_DATA_SOURCE_DIR OFF CACHE STRING "Path to source 
directory containing cmake project with source files to use for generating pgo 
data")
+set(CLANG_PGO_TRAINING_DEPS "" CACHE STRING "Extra dependencies needed to 
build the PGO training data.")
 
 if(LLVM_BUILD_INSTRUMENTED)
   configure_lit_site_cfg(
@@ -11,11 +15,11 @@ if(LLVM_BUILD_INSTRUMENTED)
   add_lit_testsuite(generate-profraw "Generating clang PGO data"
 ${CMAKE_CURRENT_BINARY_DIR}/pgo-data/
 EXCLUDE_FROM_CHECK_ALL
-DEPENDS clang clear-profraw ${CLANG_PERF_TRAINING_DEPS}
+DEPENDS clang clear-profraw ${CLANG_PGO_TRAINING_DEPS}
 )
 
   add_custom_target(clear-profraw
-COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
clean ${CMAKE_CURRENT_BINARY_DIR} profraw
+COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
clean ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}/profiles/ profraw
 COMMENT "Clearing old profraw data")
 
   if(NOT LLVM_PROFDATA)
@@ -26,9 +30,14 @@ if(LLVM_BUILD_INSTRUMENTED)
 message(STATUS "To enable merging PGO data LLVM_PROFDATA has to point to 
llvm-profdata")
   else()
 add_custom_target(generate-profdata
-  COMMAND "${Python3_EXECUTABLE}" 
${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} 
${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR}
+  COMMAND "${Python3_EXECUTABLE}" 
${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} 
${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR} 
${CMAKE_BINARY_DIR}/profiles/
   COMMENT "Merging profdata"
   DEPENDS generate-profraw)
+if (CLANG_PGO_TRAINING_DATA_SOURCE_DIR)
+  llvm_ExternalProject_Add(generate-profraw-external 
${CLANG_PGO_TRAINING_DATA_SOURCE_DIR}
+  USE_TOOLCHAIN EXLUDE_FROM_ALL NO_INSTALL DEPENDS 
generate-profraw)
+  add_dependencies(generate-profdata generate-profraw-external)
+endif()
   endif()
 endif()
 

diff  --git a/clang/utils/perf-training/perf-helper.py 
b/clang/utils/perf-training/perf-helper.py
index 99d6ab6ef0..3e92cd38a71451 100644
--- a/clang/utils/perf-training/perf-helper.py
+++ b/clang/utils/perf-training/perf-helper.py
@@ -30,26 +30,28 @@ def findFilesWithExtension(path, extension):
 
 
 def clean(args):
-if len(args) != 2:
+if len(args) < 2:
 print(
-"Usage: %s clean  \n" % __file__
+"Usage: %s clean  \n" % __file__
 + "\tRemoves all files with extension from ."
 )
 return 1
-for filename in findFilesWithExtension(args[0], args[1]):
-os.remove(filename)
+for path in args[1:-1]:
+for filename in findFilesWithExtension(path, args[-1]):
+os.remove(filename)
 return 0
 
 
 def merge(args):
-if len(args) != 3:
+if len(args) < 3:
 print(
-"Usage: %s merge   \n" % __file__
+"Usage: %s merge   \n" % __file__
 + "\tMerges all profraw files from path into output."
 )
 return 1
 cmd = [args[0], "merge", "-o", args[1]]
-cmd.extend(findFilesWithExtension(args[2], "profraw"))
+for path in args[2:]:
+cmd.extend(findFilesWithExtension(path, "profraw"))
 subprocess.check_call(cmd)
 return 0
 

diff  --git a/llvm/d

[llvm-branch-commits] [clang] [llvm] PR for llvm/llvm-project#80565 (PR #80566)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80566
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] PR for llvm/llvm-project#80887 (PR #80903)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/80903

resolves llvm/llvm-project#80887

>From 3ca557399309882e376abebe7c41e82628db4f6f Mon Sep 17 00:00:00 2001
From: Shafik Yaghmour 
Date: Mon, 5 Feb 2024 14:40:07 -0800
Subject: [PATCH] [Clang][Sema] Fix regression due to missing ambiguity check
 before attempting access check. (#80730)

Previously when fixing ambiguous lookup diagnostics in
cc1b6668c57170cd440d321037ced89d6a61a9cb The change refactored
`LookupResult` to split out diagnosing access and ambiguous lookups. The
call to `getSema().CheckLookupAccess(...)` should have guarded by a
check for isAmbiguous(). This change adds that guard.

Fixes: https://github.com/llvm/llvm-project/issues/80435
(cherry picked from commit a7bc9cb6ffa91ff0ebabc45c0c7263c7c2c3a4de)
---
 clang/include/clang/Sema/Lookup.h |  3 ++-
 .../class.derived/class.member.lookup/p11.cpp | 22 +++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Sema/Lookup.h 
b/clang/include/clang/Sema/Lookup.h
index 9c93bf1e6fb42..2f2f2607a937f 100644
--- a/clang/include/clang/Sema/Lookup.h
+++ b/clang/include/clang/Sema/Lookup.h
@@ -754,7 +754,8 @@ class LookupResult {
 
 private:
   void diagnoseAccess() {
-if (isClassLookup() && getSema().getLangOpts().AccessControl)
+if (!isAmbiguous() && isClassLookup() &&
+getSema().getLangOpts().AccessControl)
   getSema().CheckLookupAccess(*this);
   }
 
diff --git a/clang/test/CXX/class.derived/class.member.lookup/p11.cpp 
b/clang/test/CXX/class.derived/class.member.lookup/p11.cpp
index e0899b227e69b..a42febaca3f04 100644
--- a/clang/test/CXX/class.derived/class.member.lookup/p11.cpp
+++ b/clang/test/CXX/class.derived/class.member.lookup/p11.cpp
@@ -23,3 +23,25 @@ struct D: I1, I2, B2 {
 int D::* mpD = &D::i; // expected-error {{non-static member 'i' found in 
multiple base-class subobjects of type 'B1'}}
   }
 };
+
+namespace GH80435 {
+struct A {
+  void *data; // expected-note {{member found by ambiguous name lookup}}
+};
+
+class B {
+  void *data; // expected-note {{member found by ambiguous name lookup}}
+};
+
+struct C : A, B {};
+
+decltype(C().data) x; // expected-error {{member 'data' found in multiple base 
classes of different types}}
+
+struct D { // expected-note {{candidate constructor (the implicit copy 
constructor) not viable: no known conversion from 'C' to 'const D' for 1st 
argument}}
+   // expected-note@-1{{candidate constructor (the implicit move 
constructor) not viable: no known conversion from 'C' to 'D' for 1st argument}}
+  template 
+  D(Container); // expected-note {{candidate template ignored: substitution 
failure [with Container = C]: member 'data' found in multiple base classes of 
different types}}
+};
+
+D y(C{}); // expected-error {{no matching constructor for initialization of 
'D'}}
+}

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


[llvm-branch-commits] [clang] PR for llvm/llvm-project#80887 (PR #80903)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/80903
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] PR for llvm/llvm-project#80887 (PR #80903)

2024-02-06 Thread via llvm-branch-commits

llvmbot wrote:

@shafik What do you think about merging this PR to the release branch?

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


[llvm-branch-commits] [clang] PR for llvm/llvm-project#80887 (PR #80903)

2024-02-06 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (llvmbot)


Changes

resolves llvm/llvm-project#80887

---
Full diff: https://github.com/llvm/llvm-project/pull/80903.diff


2 Files Affected:

- (modified) clang/include/clang/Sema/Lookup.h (+2-1) 
- (modified) clang/test/CXX/class.derived/class.member.lookup/p11.cpp (+22) 


``diff
diff --git a/clang/include/clang/Sema/Lookup.h 
b/clang/include/clang/Sema/Lookup.h
index 9c93bf1e6fb428..2f2f2607a937fe 100644
--- a/clang/include/clang/Sema/Lookup.h
+++ b/clang/include/clang/Sema/Lookup.h
@@ -754,7 +754,8 @@ class LookupResult {
 
 private:
   void diagnoseAccess() {
-if (isClassLookup() && getSema().getLangOpts().AccessControl)
+if (!isAmbiguous() && isClassLookup() &&
+getSema().getLangOpts().AccessControl)
   getSema().CheckLookupAccess(*this);
   }
 
diff --git a/clang/test/CXX/class.derived/class.member.lookup/p11.cpp 
b/clang/test/CXX/class.derived/class.member.lookup/p11.cpp
index e0899b227e69bd..a42febaca3f041 100644
--- a/clang/test/CXX/class.derived/class.member.lookup/p11.cpp
+++ b/clang/test/CXX/class.derived/class.member.lookup/p11.cpp
@@ -23,3 +23,25 @@ struct D: I1, I2, B2 {
 int D::* mpD = &D::i; // expected-error {{non-static member 'i' found in 
multiple base-class subobjects of type 'B1'}}
   }
 };
+
+namespace GH80435 {
+struct A {
+  void *data; // expected-note {{member found by ambiguous name lookup}}
+};
+
+class B {
+  void *data; // expected-note {{member found by ambiguous name lookup}}
+};
+
+struct C : A, B {};
+
+decltype(C().data) x; // expected-error {{member 'data' found in multiple base 
classes of different types}}
+
+struct D { // expected-note {{candidate constructor (the implicit copy 
constructor) not viable: no known conversion from 'C' to 'const D' for 1st 
argument}}
+   // expected-note@-1{{candidate constructor (the implicit move 
constructor) not viable: no known conversion from 'C' to 'D' for 1st argument}}
+  template 
+  D(Container); // expected-note {{candidate template ignored: substitution 
failure [with Container = C]: member 'data' found in multiple base classes of 
different types}}
+};
+
+D y(C{}); // expected-error {{no matching constructor for initialization of 
'D'}}
+}

``




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


[llvm-branch-commits] [clang] PR for llvm/llvm-project#80887 (PR #80903)

2024-02-06 Thread via llvm-branch-commits

https://github.com/cor3ntin approved this pull request.

This fixes a regression introduced in 18 and the fix is small,

Ship it :)

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


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80877 (PR #80878)

2024-02-06 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay approved this pull request.


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


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80877 (PR #80878)

2024-02-06 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

This PR, if merged into 18.1, should fix 
https://github.com/rust-lang/rust/issues/108835

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


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80699 (PR #80729)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/80729

>From 8835ba873031a412595de2ce90e46fb65e93d214 Mon Sep 17 00:00:00 2001
From: Jeremy Morse 
Date: Wed, 24 Jan 2024 17:45:43 +
Subject: [PATCH] [BPI] Transfer value-handles when assign/move constructing
 BPI (#4)

Background: BPI stores a collection of edge branch-probabilities, and
also a set of Callback value-handles for the blocks in the
edge-collection. When a block is deleted, BPI's eraseBlock method is
called to clear the edge-collection of references to that block, to
avoid dangling pointers.

However, when move-constructing or assigning a BPI object, the
edge-collection gets moved, but the value-handles are discarded. This
can lead to to stale entries in the edge-collection when blocks are
deleted without the callback -- not normally a problem, but if a new
block is allocated with the same address as an old block, spurious
branch probabilities will be recorded about it. The fix is to transfer
the handles from the source BPI object.

This was exposed by an unrelated debug-info change, it probably just
shifted around allocation orders to expose this. Detected as
nondeterminism and reduced by Zequan Wu:

https://github.com/llvm/llvm-project/commit/f1b0a544514f3d343f32a41de9d6fb0b6cbb6021#commitcomment-136737090

(No test because IMHO testing for a behaviour that varies with memory
allocators is likely futile; I can add the reproducer with a CHECK for
the relevant branch weights if it's desired though)

(cherry picked from commit 604a6c409e8473b212952b8633d92bbdb22a45c9)
---
 llvm/include/llvm/Analysis/BranchProbabilityInfo.h | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/Analysis/BranchProbabilityInfo.h 
b/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
index 6b9d1781820111..91e1872e9bd6ff 100644
--- a/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
+++ b/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
@@ -122,16 +122,23 @@ class BranchProbabilityInfo {
   }
 
   BranchProbabilityInfo(BranchProbabilityInfo &&Arg)
-  : Probs(std::move(Arg.Probs)), LastF(Arg.LastF),
-EstimatedBlockWeight(std::move(Arg.EstimatedBlockWeight)) {}
+  : Handles(std::move(Arg.Handles)), Probs(std::move(Arg.Probs)),
+LastF(Arg.LastF),
+EstimatedBlockWeight(std::move(Arg.EstimatedBlockWeight)) {
+for (auto &Handle : Handles)
+  Handle.setBPI(this);
+  }
 
   BranchProbabilityInfo(const BranchProbabilityInfo &) = delete;
   BranchProbabilityInfo &operator=(const BranchProbabilityInfo &) = delete;
 
   BranchProbabilityInfo &operator=(BranchProbabilityInfo &&RHS) {
 releaseMemory();
+Handles = std::move(RHS.Handles);
 Probs = std::move(RHS.Probs);
 EstimatedBlockWeight = std::move(RHS.EstimatedBlockWeight);
+for (auto &Handle : Handles)
+  Handle.setBPI(this);
 return *this;
   }
 
@@ -279,6 +286,8 @@ class BranchProbabilityInfo {
 }
 
   public:
+void setBPI(BranchProbabilityInfo *BPI) { this->BPI = BPI; }
+
 BasicBlockCallbackVH(const Value *V, BranchProbabilityInfo *BPI = nullptr)
 : CallbackVH(const_cast(V)), BPI(BPI) {}
   };

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


[llvm-branch-commits] [llvm] 8835ba8 - [BPI] Transfer value-handles when assign/move constructing BPI (#77774)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

Author: Jeremy Morse
Date: 2024-02-06T15:38:30-08:00
New Revision: 8835ba873031a412595de2ce90e46fb65e93d214

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

LOG: [BPI] Transfer value-handles when assign/move constructing BPI (#4)

Background: BPI stores a collection of edge branch-probabilities, and
also a set of Callback value-handles for the blocks in the
edge-collection. When a block is deleted, BPI's eraseBlock method is
called to clear the edge-collection of references to that block, to
avoid dangling pointers.

However, when move-constructing or assigning a BPI object, the
edge-collection gets moved, but the value-handles are discarded. This
can lead to to stale entries in the edge-collection when blocks are
deleted without the callback -- not normally a problem, but if a new
block is allocated with the same address as an old block, spurious
branch probabilities will be recorded about it. The fix is to transfer
the handles from the source BPI object.

This was exposed by an unrelated debug-info change, it probably just
shifted around allocation orders to expose this. Detected as
nondeterminism and reduced by Zequan Wu:

https://github.com/llvm/llvm-project/commit/f1b0a544514f3d343f32a41de9d6fb0b6cbb6021#commitcomment-136737090

(No test because IMHO testing for a behaviour that varies with memory
allocators is likely futile; I can add the reproducer with a CHECK for
the relevant branch weights if it's desired though)

(cherry picked from commit 604a6c409e8473b212952b8633d92bbdb22a45c9)

Added: 


Modified: 
llvm/include/llvm/Analysis/BranchProbabilityInfo.h

Removed: 




diff  --git a/llvm/include/llvm/Analysis/BranchProbabilityInfo.h 
b/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
index 6b9d178182011..91e1872e9bd6f 100644
--- a/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
+++ b/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
@@ -122,16 +122,23 @@ class BranchProbabilityInfo {
   }
 
   BranchProbabilityInfo(BranchProbabilityInfo &&Arg)
-  : Probs(std::move(Arg.Probs)), LastF(Arg.LastF),
-EstimatedBlockWeight(std::move(Arg.EstimatedBlockWeight)) {}
+  : Handles(std::move(Arg.Handles)), Probs(std::move(Arg.Probs)),
+LastF(Arg.LastF),
+EstimatedBlockWeight(std::move(Arg.EstimatedBlockWeight)) {
+for (auto &Handle : Handles)
+  Handle.setBPI(this);
+  }
 
   BranchProbabilityInfo(const BranchProbabilityInfo &) = delete;
   BranchProbabilityInfo &operator=(const BranchProbabilityInfo &) = delete;
 
   BranchProbabilityInfo &operator=(BranchProbabilityInfo &&RHS) {
 releaseMemory();
+Handles = std::move(RHS.Handles);
 Probs = std::move(RHS.Probs);
 EstimatedBlockWeight = std::move(RHS.EstimatedBlockWeight);
+for (auto &Handle : Handles)
+  Handle.setBPI(this);
 return *this;
   }
 
@@ -279,6 +286,8 @@ class BranchProbabilityInfo {
 }
 
   public:
+void setBPI(BranchProbabilityInfo *BPI) { this->BPI = BPI; }
+
 BasicBlockCallbackVH(const Value *V, BranchProbabilityInfo *BPI = nullptr)
 : CallbackVH(const_cast(V)), BPI(BPI) {}
   };



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


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80699 (PR #80729)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80729
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80597 (PR #80731)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/80731

>From 7a9e4184fbb17d31265253f69b3bf5217c0d967c Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Tue, 6 Feb 2024 01:29:38 +0800
Subject: [PATCH] [InstCombine] Fix assertion failure in issue80597 (#80614)

The assertion in #80597 failed when we were trying to compute known bits
of a value in an unreachable BB.

https://github.com/llvm/llvm-project/blob/859b09da08c2a47026ba0a7d2f21b7dca705864d/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp#L749-L810

In this case, `SignBits` is 30 (deduced from instr info), but `Known` is
`110101011101000101000?0?`
(deduced from dom cond). Setting high bits of `lshr Known, 1` will lead
to conflict.

This patch masks out high bits of `Known.Zero` to address this problem.

Fixes #80597.

(cherry picked from commit cb8d83a77c25e529f58eba17bb1ec76069a04e90)
---
 .../InstCombineSimplifyDemanded.cpp   |  3 ++
 llvm/test/Transforms/InstCombine/pr80597.ll   | 33 +++
 2 files changed, 36 insertions(+)
 create mode 100644 llvm/test/Transforms/InstCombine/pr80597.ll

diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index a8a5f9831e15e3..79873a9b4cbb4c 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -802,6 +802,9 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, 
APInt DemandedMask,
 return InsertNewInstWith(LShr, I->getIterator());
   } else if (Known.One[BitWidth-ShiftAmt-1]) { // New bits are known one.
 Known.One |= HighBits;
+// SignBits may be out-of-sync with Known.countMinSignBits(). Mask out
+// high bits of Known.Zero to avoid conflicts.
+Known.Zero &= ~HighBits;
   }
 } else {
   computeKnownBits(I, Known, Depth, CxtI);
diff --git a/llvm/test/Transforms/InstCombine/pr80597.ll 
b/llvm/test/Transforms/InstCombine/pr80597.ll
new file mode 100644
index 00..5feae4a06c45c0
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/pr80597.ll
@@ -0,0 +1,33 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt -S -passes=instcombine < %s | FileCheck %s
+
+define i64 @pr80597(i1 %cond) {
+; CHECK-LABEL: define i64 @pr80597(
+; CHECK-SAME: i1 [[COND:%.*]]) {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[ADD:%.*]] = select i1 [[COND]], i64 0, i64 -12884901888
+; CHECK-NEXT:[[SEXT1:%.*]] = add nsw i64 [[ADD]], 8836839514384105472
+; CHECK-NEXT:[[CMP:%.*]] = icmp ult i64 [[SEXT1]], -34359738368
+; CHECK-NEXT:br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK:   if.else:
+; CHECK-NEXT:[[SEXT2:%.*]] = ashr exact i64 [[ADD]], 1
+; CHECK-NEXT:[[ASHR:%.*]] = or i64 [[SEXT2]], 4418419761487020032
+; CHECK-NEXT:ret i64 [[ASHR]]
+; CHECK:   if.then:
+; CHECK-NEXT:ret i64 0
+;
+entry:
+  %add = select i1 %cond, i64 0, i64 4294967293
+  %add8 = shl i64 %add, 32
+  %sext1 = add i64 %add8, 8836839514384105472
+  %cmp = icmp ult i64 %sext1, -34359738368
+  br i1 %cmp, label %if.then, label %if.else
+
+if.else:
+  %sext2 = or i64 %add8, 8836839522974040064
+  %ashr = ashr i64 %sext2, 1
+  ret i64 %ashr
+
+if.then:
+  ret i64 0
+}

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


[llvm-branch-commits] [llvm] 7a9e418 - [InstCombine] Fix assertion failure in issue80597 (#80614)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

Author: Yingwei Zheng
Date: 2024-02-06T15:40:40-08:00
New Revision: 7a9e4184fbb17d31265253f69b3bf5217c0d967c

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

LOG: [InstCombine] Fix assertion failure in issue80597 (#80614)

The assertion in #80597 failed when we were trying to compute known bits
of a value in an unreachable BB.

https://github.com/llvm/llvm-project/blob/859b09da08c2a47026ba0a7d2f21b7dca705864d/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp#L749-L810

In this case, `SignBits` is 30 (deduced from instr info), but `Known` is
`110101011101000101000?0?`
(deduced from dom cond). Setting high bits of `lshr Known, 1` will lead
to conflict.

This patch masks out high bits of `Known.Zero` to address this problem.

Fixes #80597.

(cherry picked from commit cb8d83a77c25e529f58eba17bb1ec76069a04e90)

Added: 
llvm/test/Transforms/InstCombine/pr80597.ll

Modified: 
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index a8a5f9831e15e3..79873a9b4cbb4c 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -802,6 +802,9 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, 
APInt DemandedMask,
 return InsertNewInstWith(LShr, I->getIterator());
   } else if (Known.One[BitWidth-ShiftAmt-1]) { // New bits are known one.
 Known.One |= HighBits;
+// SignBits may be out-of-sync with Known.countMinSignBits(). Mask out
+// high bits of Known.Zero to avoid conflicts.
+Known.Zero &= ~HighBits;
   }
 } else {
   computeKnownBits(I, Known, Depth, CxtI);

diff  --git a/llvm/test/Transforms/InstCombine/pr80597.ll 
b/llvm/test/Transforms/InstCombine/pr80597.ll
new file mode 100644
index 00..5feae4a06c45c0
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/pr80597.ll
@@ -0,0 +1,33 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt -S -passes=instcombine < %s | FileCheck %s
+
+define i64 @pr80597(i1 %cond) {
+; CHECK-LABEL: define i64 @pr80597(
+; CHECK-SAME: i1 [[COND:%.*]]) {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[ADD:%.*]] = select i1 [[COND]], i64 0, i64 -12884901888
+; CHECK-NEXT:[[SEXT1:%.*]] = add nsw i64 [[ADD]], 8836839514384105472
+; CHECK-NEXT:[[CMP:%.*]] = icmp ult i64 [[SEXT1]], -34359738368
+; CHECK-NEXT:br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK:   if.else:
+; CHECK-NEXT:[[SEXT2:%.*]] = ashr exact i64 [[ADD]], 1
+; CHECK-NEXT:[[ASHR:%.*]] = or i64 [[SEXT2]], 4418419761487020032
+; CHECK-NEXT:ret i64 [[ASHR]]
+; CHECK:   if.then:
+; CHECK-NEXT:ret i64 0
+;
+entry:
+  %add = select i1 %cond, i64 0, i64 4294967293
+  %add8 = shl i64 %add, 32
+  %sext1 = add i64 %add8, 8836839514384105472
+  %cmp = icmp ult i64 %sext1, -34359738368
+  br i1 %cmp, label %if.then, label %if.else
+
+if.else:
+  %sext2 = or i64 %add8, 8836839522974040064
+  %ashr = ashr i64 %sext2, 1
+  ret i64 %ashr
+
+if.then:
+  ret i64 0
+}



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


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80597 (PR #80731)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80731
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80585 (PR #80776)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/80776

>From 588526bc582ab197cbb38638945564787c072b9b Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Sat, 3 Feb 2024 21:42:40 -0800
Subject: [PATCH 1/2] [workflows] Only run code formatter on the main branch
 (#80348)

Modifying a cherry-picked patch to fix code formatting issues can be
risky, so we don't typically do this. Therefore, it's not necessary to
run this job on the release branches.

(cherry picked from commit 2193c95e2459887e7e6e4f9f4aacf9252e99858f)
---
 .github/workflows/pr-code-format.yml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/.github/workflows/pr-code-format.yml 
b/.github/workflows/pr-code-format.yml
index 5223089ee8a93d..c8fd541fd34db9 100644
--- a/.github/workflows/pr-code-format.yml
+++ b/.github/workflows/pr-code-format.yml
@@ -1,5 +1,8 @@
 name: "Check code formatting"
 on: pull_request_target
+  branches:
+- main
+
 permissions:
   pull-requests: write
 

>From 6e9fd6b99e6b18650e90432dd9920de763578e42 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Sun, 4 Feb 2024 21:33:30 -0800
Subject: [PATCH 2/2] [Github] Fix triggers formatting in code format action

A recent comment modified the job to only run on the main branch, but
the formatting was slightly off, causing the job to not run. This patch
fixes the formatting so the job will run as expected.

(cherry picked from commit 4b34558f43121df9b863ff2492f74fb2e65a5af1)
---
 .github/workflows/pr-code-format.yml | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/pr-code-format.yml 
b/.github/workflows/pr-code-format.yml
index c8fd541fd34db9..3d0c23917bd403 100644
--- a/.github/workflows/pr-code-format.yml
+++ b/.github/workflows/pr-code-format.yml
@@ -1,7 +1,8 @@
 name: "Check code formatting"
-on: pull_request_target
-  branches:
-- main
+on:
+  pull_request_target:
+branches:
+  - main
 
 permissions:
   pull-requests: write

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


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80585 (PR #80776)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80776
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] PR for llvm/llvm-project#80789 (PR #80790)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

tstellar wrote:

This has a failing CI test that needs to be fixed.

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


[llvm-branch-commits] [compiler-rt] PR for llvm/llvm-project#80808 (PR #80811)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/80811

>From c92b81dde8a3068d90f5c4e7c012ffa34ede7da5 Mon Sep 17 00:00:00 2001
From: Zequan Wu 
Date: Mon, 5 Feb 2024 15:27:34 -0500
Subject: [PATCH] [Profile][Windows] Drop extern for __buildid. (#80700)

(cherry picked from commit dd22140e21f2ef51cf031354966a3d41c191c6e7)
---
 compiler-rt/lib/profile/InstrProfilingPlatformWindows.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c 
b/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c
index c976776ae59e9c..0751b28f81d0ac 100644
--- a/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c
@@ -77,7 +77,7 @@ ValueProfNode *EndVNode = &VNodesEnd;
 /* lld-link provides __buildid symbol which ponits to the 16 bytes build id 
when
  * using /build-id flag. https://lld.llvm.org/windows_support.html#lld-flags */
 #define BUILD_ID_LEN 16
-COMPILER_RT_WEAK extern uint8_t __buildid[BUILD_ID_LEN];
+COMPILER_RT_WEAK uint8_t __buildid[BUILD_ID_LEN];
 COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) {
   if (*__buildid) {
 if (Writer &&

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


[llvm-branch-commits] [compiler-rt] c92b81d - [Profile][Windows] Drop extern for __buildid. (#80700)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

Author: Zequan Wu
Date: 2024-02-06T15:45:32-08:00
New Revision: c92b81dde8a3068d90f5c4e7c012ffa34ede7da5

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

LOG: [Profile][Windows] Drop extern for __buildid. (#80700)

(cherry picked from commit dd22140e21f2ef51cf031354966a3d41c191c6e7)

Added: 


Modified: 
compiler-rt/lib/profile/InstrProfilingPlatformWindows.c

Removed: 




diff  --git a/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c 
b/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c
index c976776ae59e9c..0751b28f81d0ac 100644
--- a/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformWindows.c
@@ -77,7 +77,7 @@ ValueProfNode *EndVNode = &VNodesEnd;
 /* lld-link provides __buildid symbol which ponits to the 16 bytes build id 
when
  * using /build-id flag. https://lld.llvm.org/windows_support.html#lld-flags */
 #define BUILD_ID_LEN 16
-COMPILER_RT_WEAK extern uint8_t __buildid[BUILD_ID_LEN];
+COMPILER_RT_WEAK uint8_t __buildid[BUILD_ID_LEN];
 COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) {
   if (*__buildid) {
 if (Writer &&



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


[llvm-branch-commits] [compiler-rt] PR for llvm/llvm-project#80808 (PR #80811)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80811
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] PR for llvm/llvm-project#80843 (PR #80845)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/80845

>From ecd1cee3e0d7e8bbe7ce98ca81c9c96e1804709c Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Tue, 6 Feb 2024 06:23:22 -0800
Subject: [PATCH] [CLANG] Fix INF/NAN warning. (#80290)

In https://github.com/llvm/llvm-project/pull/76873 a warning was added
when the macros INFINITY and NAN are used in binary expressions when
-menable-no-nans or -menable-no-infs are used. If the user uses an
option that nullifies these two options, the warning will still be
generated. This patch adds an additional information to the warning
comment to let the user know about this. It also suppresses the warning
when #ifdef INFINITY, #ifdef NAN, #ifdef NAN or #ifndef NAN are used in
the code.

(cherry picked from commit 62c352e13c145b5606ace88ecbe9164ff011b5cf)
---
 .../clang/Basic/DiagnosticCommonKinds.td  |  2 +-
 clang/include/clang/Basic/DiagnosticDocs.td   |  9 +++
 clang/include/clang/Lex/Preprocessor.h| 11 ++--
 clang/lib/Lex/PPDirectives.cpp|  2 +-
 clang/lib/Lex/PPExpressions.cpp   |  4 +-
 .../Sema/warn-infinity-nan-disabled-lnx.cpp   | 60 ---
 .../Sema/warn-infinity-nan-disabled-win.cpp   | 60 ---
 7 files changed, 126 insertions(+), 22 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index b1bada65cb6b28..08bb1d81ba29f1 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -73,7 +73,7 @@ def warn_pragma_debug_unexpected_argument : Warning<
 def warn_fp_nan_inf_when_disabled : Warning<
   "use of %select{infinity|NaN}0%select{| via a macro}1 is undefined behavior "
   "due to the currently enabled floating-point options">,
-  InGroup>;
+  InGroup>;
 }
 
 // Parse && Sema
diff --git a/clang/include/clang/Basic/DiagnosticDocs.td 
b/clang/include/clang/Basic/DiagnosticDocs.td
index e9862422b4997e..8c024b5cad740a 100644
--- a/clang/include/clang/Basic/DiagnosticDocs.td
+++ b/clang/include/clang/Basic/DiagnosticDocs.td
@@ -87,3 +87,12 @@ program by treating all string literals as having type 
``const char *``
 instead of ``char *``. This can cause unexpected behaviors with type-sensitive
 constructs like ``_Generic``.
 }];
+
+defvar NanInfDisabledDocs = [{
+This warning is enabled when source code using the macros ``INFINITY`` or 
``NAN``
+is compiled with floating-point options preventing these two values. This can
+lead to undefined behavior. Check the order of command line arguments that 
modify
+this behavior, such as ``-ffast-math``, ``-fhonor-infinities``, and
+``-fhonor-nans`` (etc), as well as ``#pragma`` directives if this diagnostic is
+generated unexpectedly.
+}];
diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 2d9c53cdf5bde8..b0a8ec0fec5e94 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2828,7 +2828,8 @@ class Preprocessor {
 return AnnotationInfos.find(II)->second;
   }
 
-  void emitMacroExpansionWarnings(const Token &Identifier) const {
+  void emitMacroExpansionWarnings(const Token &Identifier,
+  bool IsIfnDef = false) const {
 IdentifierInfo *Info = Identifier.getIdentifierInfo();
 if (Info->isDeprecatedMacro())
   emitMacroDeprecationWarning(Identifier);
@@ -2837,12 +2838,12 @@ class Preprocessor {
 !SourceMgr.isInMainFile(Identifier.getLocation()))
   emitRestrictExpansionWarning(Identifier);
 
-if (Info->getName() == "INFINITY")
-  if (getLangOpts().NoHonorInfs)
+if (!IsIfnDef) {
+  if (Info->getName() == "INFINITY" && getLangOpts().NoHonorInfs)
 emitRestrictInfNaNWarning(Identifier, 0);
-if (Info->getName() == "NAN")
-  if (getLangOpts().NoHonorNaNs)
+  if (Info->getName() == "NAN" && getLangOpts().NoHonorNaNs)
 emitRestrictInfNaNWarning(Identifier, 1);
+}
   }
 
   static void processPathForFileMacro(SmallVectorImpl &Path,
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 9f82a6d073e3ba..a980f4bcbae124 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -3288,7 +3288,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result,
 return;
   }
 
-  emitMacroExpansionWarnings(MacroNameTok);
+  emitMacroExpansionWarnings(MacroNameTok, /*IsIfnDef=*/true);
 
   // Check to see if this is the last token on the #if[n]def line.
   CheckEndOfDirective(isIfndef ? "ifndef" : "ifdef");
diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index 1feb0eb18d71e6..8f25c67ec9dfbe 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/lib/Lex/PPExpressions.cpp
@@ -133,7 +133,9 @@ static bool EvaluateDefined(PPValue &Result, Token 
&PeekTok, DefinedTracker &DT,
   Result.Val.setIsUnsigned(false); // Resu

[llvm-branch-commits] [clang] ecd1cee - [CLANG] Fix INF/NAN warning. (#80290)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

Author: Zahira Ammarguellat
Date: 2024-02-06T15:46:29-08:00
New Revision: ecd1cee3e0d7e8bbe7ce98ca81c9c96e1804709c

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

LOG: [CLANG] Fix INF/NAN warning. (#80290)

In https://github.com/llvm/llvm-project/pull/76873 a warning was added
when the macros INFINITY and NAN are used in binary expressions when
-menable-no-nans or -menable-no-infs are used. If the user uses an
option that nullifies these two options, the warning will still be
generated. This patch adds an additional information to the warning
comment to let the user know about this. It also suppresses the warning
when #ifdef INFINITY, #ifdef NAN, #ifdef NAN or #ifndef NAN are used in
the code.

(cherry picked from commit 62c352e13c145b5606ace88ecbe9164ff011b5cf)

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticCommonKinds.td
clang/include/clang/Basic/DiagnosticDocs.td
clang/include/clang/Lex/Preprocessor.h
clang/lib/Lex/PPDirectives.cpp
clang/lib/Lex/PPExpressions.cpp
clang/test/Sema/warn-infinity-nan-disabled-lnx.cpp
clang/test/Sema/warn-infinity-nan-disabled-win.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index b1bada65cb6b28..08bb1d81ba29f1 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -73,7 +73,7 @@ def warn_pragma_debug_unexpected_argument : Warning<
 def warn_fp_nan_inf_when_disabled : Warning<
   "use of %select{infinity|NaN}0%select{| via a macro}1 is undefined behavior "
   "due to the currently enabled floating-point options">,
-  InGroup>;
+  InGroup>;
 }
 
 // Parse && Sema

diff  --git a/clang/include/clang/Basic/DiagnosticDocs.td 
b/clang/include/clang/Basic/DiagnosticDocs.td
index e9862422b4997e..8c024b5cad740a 100644
--- a/clang/include/clang/Basic/DiagnosticDocs.td
+++ b/clang/include/clang/Basic/DiagnosticDocs.td
@@ -87,3 +87,12 @@ program by treating all string literals as having type 
``const char *``
 instead of ``char *``. This can cause unexpected behaviors with type-sensitive
 constructs like ``_Generic``.
 }];
+
+defvar NanInfDisabledDocs = [{
+This warning is enabled when source code using the macros ``INFINITY`` or 
``NAN``
+is compiled with floating-point options preventing these two values. This can
+lead to undefined behavior. Check the order of command line arguments that 
modify
+this behavior, such as ``-ffast-math``, ``-fhonor-infinities``, and
+``-fhonor-nans`` (etc), as well as ``#pragma`` directives if this diagnostic is
+generated unexpectedly.
+}];

diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 2d9c53cdf5bde8..b0a8ec0fec5e94 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2828,7 +2828,8 @@ class Preprocessor {
 return AnnotationInfos.find(II)->second;
   }
 
-  void emitMacroExpansionWarnings(const Token &Identifier) const {
+  void emitMacroExpansionWarnings(const Token &Identifier,
+  bool IsIfnDef = false) const {
 IdentifierInfo *Info = Identifier.getIdentifierInfo();
 if (Info->isDeprecatedMacro())
   emitMacroDeprecationWarning(Identifier);
@@ -2837,12 +2838,12 @@ class Preprocessor {
 !SourceMgr.isInMainFile(Identifier.getLocation()))
   emitRestrictExpansionWarning(Identifier);
 
-if (Info->getName() == "INFINITY")
-  if (getLangOpts().NoHonorInfs)
+if (!IsIfnDef) {
+  if (Info->getName() == "INFINITY" && getLangOpts().NoHonorInfs)
 emitRestrictInfNaNWarning(Identifier, 0);
-if (Info->getName() == "NAN")
-  if (getLangOpts().NoHonorNaNs)
+  if (Info->getName() == "NAN" && getLangOpts().NoHonorNaNs)
 emitRestrictInfNaNWarning(Identifier, 1);
+}
   }
 
   static void processPathForFileMacro(SmallVectorImpl &Path,

diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 9f82a6d073e3ba..a980f4bcbae124 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -3288,7 +3288,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result,
 return;
   }
 
-  emitMacroExpansionWarnings(MacroNameTok);
+  emitMacroExpansionWarnings(MacroNameTok, /*IsIfnDef=*/true);
 
   // Check to see if this is the last token on the #if[n]def line.
   CheckEndOfDirective(isIfndef ? "ifndef" : "ifdef");

diff  --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index 1feb0eb18d71e6..8f25c67ec9dfbe 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/lib/Lex/PPExpressions.cpp
@@ -133,7 +133,9 @@ static bool EvaluateDefined(PPValue &Result, Token 
&PeekTok, DefinedTra

[llvm-branch-commits] [clang] PR for llvm/llvm-project#80843 (PR #80845)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80845
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80877 (PR #80878)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/80878

>From 36cecd98cfd006e2b3b044e1433a8914916c98b9 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Tue, 6 Feb 2024 09:23:33 -0800
Subject: [PATCH] [MIPS] Use generic isBlockOnlyReachableByFallthrough (#80799)

FastISel may create a redundant BGTZ terminal which fallthroughes.
```
  BGTZ %2:gpr32, %bb.1, implicit-def $at

bb.1.bb1:
; predecessors: %bb.0
```

The `!I->isBarrier()` check in
MipsAsmPrinter::isBlockOnlyReachableByFallthrough
will incorrectly not print a label, leading to a `Undefined temporary
symbol `
error when we try assembling the output assembly file. See the updated
`Fast-ISel/pr40325.ll` and
https://github.com/rust-lang/rust/issues/108835

In addition, the `SwitchInst` condition is too conservative and prints
many unneeded labels (see the updated tests).

Just use the generic isBlockOnlyReachableByFallthrough, updated by
commit 1995b9fead62f2f6c0ad217bd00ce3184f741fdb for SPARC, which also
handles MIPS.

(cherry picked from commit 6b2fd7aed66d592738f26c76caa8fff95e168598)
---
 llvm/lib/Target/Mips/MipsAsmPrinter.cpp   | 39 ---
 llvm/lib/Target/Mips/MipsAsmPrinter.h |  2 -
 llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll   |  2 +-
 .../GlobalISel/llvm-ir/jump_table_and_brjt.ll |  8 ++--
 .../unsafe-in-forbidden-slot.ll   |  4 +-
 .../Mips/indirect-jump-hazard/jumptables.ll   | 16 
 llvm/test/CodeGen/Mips/jump-table-mul.ll  |  2 +-
 llvm/test/CodeGen/Mips/pseudo-jump-fill.ll|  2 +-
 8 files changed, 17 insertions(+), 58 deletions(-)

diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp 
b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
index 718844bc36ff93..66b2b0de8d52a3 100644
--- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -471,45 +471,6 @@ void MipsAsmPrinter::emitBasicBlockEnd(const 
MachineBasicBlock &MBB) {
 TS.emitDirectiveInsn();
 }
 
-/// isBlockOnlyReachableByFallthough - Return true if the basic block has
-/// exactly one predecessor and the control transfer mechanism between
-/// the predecessor and this block is a fall-through.
-bool MipsAsmPrinter::isBlockOnlyReachableByFallthrough(const MachineBasicBlock*
-   MBB) const {
-  // The predecessor has to be immediately before this block.
-  const MachineBasicBlock *Pred = *MBB->pred_begin();
-
-  // If the predecessor is a switch statement, assume a jump table
-  // implementation, so it is not a fall through.
-  if (const BasicBlock *bb = Pred->getBasicBlock())
-if (isa(bb->getTerminator()))
-  return false;
-
-  // If this is a landing pad, it isn't a fall through.  If it has no preds,
-  // then nothing falls through to it.
-  if (MBB->isEHPad() || MBB->pred_empty())
-return false;
-
-  // If there isn't exactly one predecessor, it can't be a fall through.
-  if (MBB->pred_size() != 1)
-return false;
-
-  // The predecessor has to be immediately before this block.
-  if (!Pred->isLayoutSuccessor(MBB))
-return false;
-
-  // If the block is completely empty, then it definitely does fall through.
-  if (Pred->empty())
-return true;
-
-  // Otherwise, check the last instruction.
-  // Check if the last terminator is an unconditional branch.
-  MachineBasicBlock::const_iterator I = Pred->end();
-  while (I != Pred->begin() && !(--I)->isTerminator()) ;
-
-  return !I->isBarrier();
-}
-
 // Print out an operand for an inline asm expression.
 bool MipsAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
  const char *ExtraCode, raw_ostream &O) {
diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.h 
b/llvm/lib/Target/Mips/MipsAsmPrinter.h
index 64424b181504a7..0b55089385d79d 100644
--- a/llvm/lib/Target/Mips/MipsAsmPrinter.h
+++ b/llvm/lib/Target/Mips/MipsAsmPrinter.h
@@ -142,8 +142,6 @@ class LLVM_LIBRARY_VISIBILITY MipsAsmPrinter : public 
AsmPrinter {
   void emitFunctionBodyStart() override;
   void emitFunctionBodyEnd() override;
   void emitBasicBlockEnd(const MachineBasicBlock &MBB) override;
-  bool isBlockOnlyReachableByFallthrough(
-   const MachineBasicBlock* MBB) const 
override;
   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
const char *ExtraCode, raw_ostream &O) override;
   bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
diff --git a/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll 
b/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll
index 9e64d7b2fa039b..c276515920d52a 100644
--- a/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll
+++ b/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll
@@ -11,7 +11,7 @@ define void @test(i32 %x, ptr %p) nounwind {
 ; CHECK-NEXT:andi $1, $4, 1
 ; CHECK-NEXT:bgtz $1, $BB0_1
 ; CHECK-NEXT:nop
-; CHECK-NEXT:  # %bb.1: # %foo
+; CHECK-NEXT:  $BB0_1: # %foo
 ; CHECK-NEXT:jr $ra
 ; CHECK-NEXT:nop
   %y = 

[llvm-branch-commits] [llvm] 36cecd9 - [MIPS] Use generic isBlockOnlyReachableByFallthrough (#80799)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

Author: Fangrui Song
Date: 2024-02-06T15:49:23-08:00
New Revision: 36cecd98cfd006e2b3b044e1433a8914916c98b9

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

LOG: [MIPS] Use generic isBlockOnlyReachableByFallthrough (#80799)

FastISel may create a redundant BGTZ terminal which fallthroughes.
```
  BGTZ %2:gpr32, %bb.1, implicit-def $at

bb.1.bb1:
; predecessors: %bb.0
```

The `!I->isBarrier()` check in
MipsAsmPrinter::isBlockOnlyReachableByFallthrough
will incorrectly not print a label, leading to a `Undefined temporary
symbol `
error when we try assembling the output assembly file. See the updated
`Fast-ISel/pr40325.ll` and
https://github.com/rust-lang/rust/issues/108835

In addition, the `SwitchInst` condition is too conservative and prints
many unneeded labels (see the updated tests).

Just use the generic isBlockOnlyReachableByFallthrough, updated by
commit 1995b9fead62f2f6c0ad217bd00ce3184f741fdb for SPARC, which also
handles MIPS.

(cherry picked from commit 6b2fd7aed66d592738f26c76caa8fff95e168598)

Added: 


Modified: 
llvm/lib/Target/Mips/MipsAsmPrinter.cpp
llvm/lib/Target/Mips/MipsAsmPrinter.h
llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll
llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/jump_table_and_brjt.ll
llvm/test/CodeGen/Mips/compactbranches/unsafe-in-forbidden-slot.ll
llvm/test/CodeGen/Mips/indirect-jump-hazard/jumptables.ll
llvm/test/CodeGen/Mips/jump-table-mul.ll
llvm/test/CodeGen/Mips/pseudo-jump-fill.ll

Removed: 




diff  --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp 
b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
index 718844bc36ff93..66b2b0de8d52a3 100644
--- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -471,45 +471,6 @@ void MipsAsmPrinter::emitBasicBlockEnd(const 
MachineBasicBlock &MBB) {
 TS.emitDirectiveInsn();
 }
 
-/// isBlockOnlyReachableByFallthough - Return true if the basic block has
-/// exactly one predecessor and the control transfer mechanism between
-/// the predecessor and this block is a fall-through.
-bool MipsAsmPrinter::isBlockOnlyReachableByFallthrough(const MachineBasicBlock*
-   MBB) const {
-  // The predecessor has to be immediately before this block.
-  const MachineBasicBlock *Pred = *MBB->pred_begin();
-
-  // If the predecessor is a switch statement, assume a jump table
-  // implementation, so it is not a fall through.
-  if (const BasicBlock *bb = Pred->getBasicBlock())
-if (isa(bb->getTerminator()))
-  return false;
-
-  // If this is a landing pad, it isn't a fall through.  If it has no preds,
-  // then nothing falls through to it.
-  if (MBB->isEHPad() || MBB->pred_empty())
-return false;
-
-  // If there isn't exactly one predecessor, it can't be a fall through.
-  if (MBB->pred_size() != 1)
-return false;
-
-  // The predecessor has to be immediately before this block.
-  if (!Pred->isLayoutSuccessor(MBB))
-return false;
-
-  // If the block is completely empty, then it definitely does fall through.
-  if (Pred->empty())
-return true;
-
-  // Otherwise, check the last instruction.
-  // Check if the last terminator is an unconditional branch.
-  MachineBasicBlock::const_iterator I = Pred->end();
-  while (I != Pred->begin() && !(--I)->isTerminator()) ;
-
-  return !I->isBarrier();
-}
-
 // Print out an operand for an inline asm expression.
 bool MipsAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
  const char *ExtraCode, raw_ostream &O) {

diff  --git a/llvm/lib/Target/Mips/MipsAsmPrinter.h 
b/llvm/lib/Target/Mips/MipsAsmPrinter.h
index 64424b181504a7..0b55089385d79d 100644
--- a/llvm/lib/Target/Mips/MipsAsmPrinter.h
+++ b/llvm/lib/Target/Mips/MipsAsmPrinter.h
@@ -142,8 +142,6 @@ class LLVM_LIBRARY_VISIBILITY MipsAsmPrinter : public 
AsmPrinter {
   void emitFunctionBodyStart() override;
   void emitFunctionBodyEnd() override;
   void emitBasicBlockEnd(const MachineBasicBlock &MBB) override;
-  bool isBlockOnlyReachableByFallthrough(
-   const MachineBasicBlock* MBB) const 
override;
   bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
const char *ExtraCode, raw_ostream &O) override;
   bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,

diff  --git a/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll 
b/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll
index 9e64d7b2fa039b..c276515920d52a 100644
--- a/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll
+++ b/llvm/test/CodeGen/Mips/Fast-ISel/pr40325.ll
@@ -11,7 +11,7 @@ define void @test(i32 %x, ptr %p) nounwind {
 ; CHECK-NEXT:andi $1, $4, 1
 ; CHECK-NEXT:bgtz $1, $BB0_1
 ; CHECK-NEXT:nop
-; CHECK-

[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80877 (PR #80878)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80878
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [llvm] PR for llvm/llvm-project#79614 (PR #79870)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/79870

>From ae6cfa24d6f4a04a74734e75f23905041b6c276f Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas 
Date: Mon, 29 Jan 2024 16:37:09 +
Subject: [PATCH] [AArch64][TargetParser] Add mcpu alias for Microsoft Azure
 Cobalt 100. (#79614)

With a690e86 we added -mcpu/mtune=native support to handle the Microsoft
Azure Cobalt 100 CPU as a Neoverse N2. This patch adds a CPU alias in
TargetParser to maintain compatibility with GCC.

(cherry picked from commit ae8005ffb6cd18900de8ed5a86f60a4a16975471)
---
 clang/test/Driver/aarch64-mcpu.c | 3 +++
 clang/test/Misc/target-invalid-cpu-note.c| 4 ++--
 llvm/include/llvm/TargetParser/AArch64TargetParser.h | 3 ++-
 llvm/unittests/TargetParser/TargetParserTest.cpp | 2 +-
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/clang/test/Driver/aarch64-mcpu.c b/clang/test/Driver/aarch64-mcpu.c
index 511482a420da2..3e07f3597f340 100644
--- a/clang/test/Driver/aarch64-mcpu.c
+++ b/clang/test/Driver/aarch64-mcpu.c
@@ -72,6 +72,9 @@
 // RUN: %clang --target=aarch64 -mcpu=cortex-r82  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEXR82 %s
 // CORTEXR82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-r82"
 
+// RUN: %clang --target=aarch64 -mcpu=cobalt-100 -### -c %s 2>&1 | FileCheck 
-check-prefix=COBALT-100 %s
+// COBALT-100: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n2"
+
 // RUN: %clang --target=aarch64 -mcpu=grace -### -c %s 2>&1 | FileCheck 
-check-prefix=GRACE %s
 // GRACE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "neoverse-v2"
 
diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 84aed5c9c36fe..2f10bfb1fd82f 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -5,11 +5,11 @@
 
 // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix AARCH64
 // AARCH64: error: unknown target CPU 'not-a-cpu'
-// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a57, cortex-a65, 
cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, 
cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, 
cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, 
neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, 
apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, 
falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, 
thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, grace{{$}}
+// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a57, cortex-a65, 
cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, 
cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, 
cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, 
neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, 
apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, 
falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, 
thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, cobalt-100, 
grace{{$}}
 
 // RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE_AARCH64
 // TUNE_AARCH64: error: unknown target CPU 'not-a-cpu'
-// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, 
cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a57, 
cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, 
cortex-a76ae, cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, 
cortex-a720, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, 
cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, 
apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, 
falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, 
thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, grace{{$}}
+// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, 
cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a57, 
cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex

[llvm-branch-commits] [llvm] ae6cfa2 - [AArch64][TargetParser] Add mcpu alias for Microsoft Azure Cobalt 100. (#79614)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

Author: Alexandros Lamprineas
Date: 2024-02-06T15:51:16-08:00
New Revision: ae6cfa24d6f4a04a74734e75f23905041b6c276f

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

LOG: [AArch64][TargetParser] Add mcpu alias for Microsoft Azure Cobalt 100. 
(#79614)

With a690e86 we added -mcpu/mtune=native support to handle the Microsoft
Azure Cobalt 100 CPU as a Neoverse N2. This patch adds a CPU alias in
TargetParser to maintain compatibility with GCC.

(cherry picked from commit ae8005ffb6cd18900de8ed5a86f60a4a16975471)

Added: 


Modified: 
clang/test/Driver/aarch64-mcpu.c
clang/test/Misc/target-invalid-cpu-note.c
llvm/include/llvm/TargetParser/AArch64TargetParser.h
llvm/unittests/TargetParser/TargetParserTest.cpp

Removed: 




diff  --git a/clang/test/Driver/aarch64-mcpu.c 
b/clang/test/Driver/aarch64-mcpu.c
index 511482a420da26..3e07f3597f3408 100644
--- a/clang/test/Driver/aarch64-mcpu.c
+++ b/clang/test/Driver/aarch64-mcpu.c
@@ -72,6 +72,9 @@
 // RUN: %clang --target=aarch64 -mcpu=cortex-r82  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEXR82 %s
 // CORTEXR82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-r82"
 
+// RUN: %clang --target=aarch64 -mcpu=cobalt-100 -### -c %s 2>&1 | FileCheck 
-check-prefix=COBALT-100 %s
+// COBALT-100: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n2"
+
 // RUN: %clang --target=aarch64 -mcpu=grace -### -c %s 2>&1 | FileCheck 
-check-prefix=GRACE %s
 // GRACE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "neoverse-v2"
 

diff  --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 84aed5c9c36fe4..2f10bfb1fd82fe 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -5,11 +5,11 @@
 
 // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix AARCH64
 // AARCH64: error: unknown target CPU 'not-a-cpu'
-// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a57, cortex-a65, 
cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, 
cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, 
cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, 
neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, 
apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, 
falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, 
thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, grace{{$}}
+// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a57, cortex-a65, 
cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, 
cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, 
cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, 
neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, 
apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, 
falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, 
thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, cobalt-100, 
grace{{$}}
 
 // RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE_AARCH64
 // TUNE_AARCH64: error: unknown target CPU 'not-a-cpu'
-// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, 
cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a57, 
cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, 
cortex-a76ae, cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, 
cortex-a720, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, 
cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, 
apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, 
falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, 
thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, grace{{$}}
+// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, 
cortex-a35, cortex-a53, cortex-a55, cortex-a510, 

[llvm-branch-commits] [clang] [llvm] PR for llvm/llvm-project#79614 (PR #79870)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/79870
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#80877 (PR #80878)

2024-02-06 Thread Brad Smith via llvm-branch-commits

brad0 wrote:

> This PR, if merged into 18.1, should fix 
> [rust-lang/rust#108835](https://github.com/rust-lang/rust/issues/108835)

Ya, that's especially why I pushed it.

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


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#78621 (PR #80260)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/80260

>From 42512617acf38425909676a190ed1b0ce9335616 Mon Sep 17 00:00:00 2001
From: Florian Hahn 
Date: Wed, 24 Jan 2024 11:56:02 +
Subject: [PATCH 1/2] [ConstraintElim] Add tests for #78621.

Tests with umin where the result may be poison for
https://github.com/llvm/llvm-project/issues/78621.

(cherry picked from commit c83180c1248615cf6ea8842eb4e0cebebba4ab57)
---
 .../umin-result-may-be-poison.ll  | 60 +++
 1 file changed, 60 insertions(+)
 create mode 100644 
llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll

diff --git 
a/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll 
b/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll
new file mode 100644
index 00..35ac72e54d1894
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll
@@ -0,0 +1,60 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt -p constraint-elimination -S %s | FileCheck %s
+
+; Tests for https://github.com/llvm/llvm-project/issues/78621.
+
+define i1 @umin_not_used(i32 %arg) {
+; CHECK-LABEL: define i1 @umin_not_used(
+; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80)
+; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:ret i1 false
+;
+  %icmp = icmp slt i32 %arg, 0
+  %shl = shl nuw nsw i32 %arg, 3
+  call i32 @llvm.umin.i32(i32 %shl, i32 80)
+  %cmp2 = shl nuw nsw i32 %arg, 3
+  ret i1 %icmp
+}
+
+define i1 @umin_poison_is_UB_via_call(i32 %arg) {
+; CHECK-LABEL: define i1 @umin_poison_is_UB_via_call(
+; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:[[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80)
+; CHECK-NEXT:call void @noundef(i32 noundef [[MIN]])
+; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:ret i1 false
+;
+  %icmp = icmp slt i32 %arg, 0
+  %shl = shl nuw nsw i32 %arg, 3
+  %min = call i32 @llvm.umin.i32(i32 %shl, i32 80)
+  call void @noundef(i32 noundef %min)
+  %cmp2 = shl nuw nsw i32 %arg, 3
+  ret i1 %icmp
+}
+
+define i1 @umin_poison_call_before_UB(i32 %arg) {
+; CHECK-LABEL: define i1 @umin_poison_call_before_UB(
+; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:[[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80)
+; CHECK-NEXT:call void @fn()
+; CHECK-NEXT:call void @noundef(i32 noundef [[MIN]])
+; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:ret i1 false
+;
+  %icmp = icmp slt i32 %arg, 0
+  %shl = shl nuw nsw i32 %arg, 3
+  %min = call i32 @llvm.umin.i32(i32 %shl, i32 80)
+  call void @fn()
+  call void @noundef(i32 noundef %min)
+  %cmp2 = shl nuw nsw i32 %arg, 3
+  ret i1 %icmp
+}
+
+declare i32 @llvm.umin.i32(i32, i32) #0
+
+declare void @noundef(i32 noundef)
+declare void @fn()

>From 56c50a4e0b50fb59ae1f1b322b31a5546522a928 Mon Sep 17 00:00:00 2001
From: Florian Hahn 
Date: Wed, 24 Jan 2024 14:25:54 +
Subject: [PATCH 2/2] [ConstraintElim] Make sure min/max intrinsic results are
 not poison.

The result of umin may be poison and in that case the added constraints
are not be valid in contexts where poison doesn't cause UB. Only queue
facts for min/max intrinsics if the result is guaranteed to not be
poison.

This could be improved in the future, by only adding the fact when
solving conditions using the result value.

Fixes https://github.com/llvm/llvm-project/issues/78621.

(cherry picked from commit 3d91d9613e294b242d853039209b40a0cb7853f2)
---
 llvm/lib/Transforms/Scalar/ConstraintElimination.cpp   | 7 ++-
 llvm/test/Transforms/ConstraintElimination/minmax.ll   | 4 +++-
 .../ConstraintElimination/umin-result-may-be-poison.ll | 6 --
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp 
b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 8f09569d0d9cc9..7b672e89b67aae 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -1061,11 +1061,16 @@ void State::addInfoFor(BasicBlock &BB) {
   FactOrCheck::getCheck(DT.getNode(&BB), cast(&I)));
   break;
 // Enqueue the intrinsics to add extra info.
-case Intrinsic::abs:
 case Intrinsic::umin:
 case Intrinsic::umax:
 case Intrinsic::smin:
 case Intrinsic::smax:
+  // TODO: Check if it is possible to instead only added the min/max facts
+  // when simplifying uses of the min/max intrinsics.
+  if (!isGuaranteedNotToBePoison(&I))
+break;
+  [[fallthrough]];
+case Intrinsic::abs:
   WorkList.push_back(FactOrCheck::g

[llvm-branch-commits] [llvm] 4251261 - [ConstraintElim] Add tests for #78621.

2024-02-06 Thread Tom Stellard via llvm-branch-commits

Author: Florian Hahn
Date: 2024-02-06T16:05:15-08:00
New Revision: 42512617acf38425909676a190ed1b0ce9335616

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

LOG: [ConstraintElim] Add tests for #78621.

Tests with umin where the result may be poison for
https://github.com/llvm/llvm-project/issues/78621.

(cherry picked from commit c83180c1248615cf6ea8842eb4e0cebebba4ab57)

Added: 
llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll

Modified: 


Removed: 




diff  --git 
a/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll 
b/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll
new file mode 100644
index 00..35ac72e54d1894
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll
@@ -0,0 +1,60 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt -p constraint-elimination -S %s | FileCheck %s
+
+; Tests for https://github.com/llvm/llvm-project/issues/78621.
+
+define i1 @umin_not_used(i32 %arg) {
+; CHECK-LABEL: define i1 @umin_not_used(
+; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80)
+; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:ret i1 false
+;
+  %icmp = icmp slt i32 %arg, 0
+  %shl = shl nuw nsw i32 %arg, 3
+  call i32 @llvm.umin.i32(i32 %shl, i32 80)
+  %cmp2 = shl nuw nsw i32 %arg, 3
+  ret i1 %icmp
+}
+
+define i1 @umin_poison_is_UB_via_call(i32 %arg) {
+; CHECK-LABEL: define i1 @umin_poison_is_UB_via_call(
+; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:[[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80)
+; CHECK-NEXT:call void @noundef(i32 noundef [[MIN]])
+; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:ret i1 false
+;
+  %icmp = icmp slt i32 %arg, 0
+  %shl = shl nuw nsw i32 %arg, 3
+  %min = call i32 @llvm.umin.i32(i32 %shl, i32 80)
+  call void @noundef(i32 noundef %min)
+  %cmp2 = shl nuw nsw i32 %arg, 3
+  ret i1 %icmp
+}
+
+define i1 @umin_poison_call_before_UB(i32 %arg) {
+; CHECK-LABEL: define i1 @umin_poison_call_before_UB(
+; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:[[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80)
+; CHECK-NEXT:call void @fn()
+; CHECK-NEXT:call void @noundef(i32 noundef [[MIN]])
+; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:ret i1 false
+;
+  %icmp = icmp slt i32 %arg, 0
+  %shl = shl nuw nsw i32 %arg, 3
+  %min = call i32 @llvm.umin.i32(i32 %shl, i32 80)
+  call void @fn()
+  call void @noundef(i32 noundef %min)
+  %cmp2 = shl nuw nsw i32 %arg, 3
+  ret i1 %icmp
+}
+
+declare i32 @llvm.umin.i32(i32, i32) #0
+
+declare void @noundef(i32 noundef)
+declare void @fn()



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


[llvm-branch-commits] [llvm] 56c50a4 - [ConstraintElim] Make sure min/max intrinsic results are not poison.

2024-02-06 Thread Tom Stellard via llvm-branch-commits

Author: Florian Hahn
Date: 2024-02-06T16:05:16-08:00
New Revision: 56c50a4e0b50fb59ae1f1b322b31a5546522a928

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

LOG: [ConstraintElim] Make sure min/max intrinsic results are not poison.

The result of umin may be poison and in that case the added constraints
are not be valid in contexts where poison doesn't cause UB. Only queue
facts for min/max intrinsics if the result is guaranteed to not be
poison.

This could be improved in the future, by only adding the fact when
solving conditions using the result value.

Fixes https://github.com/llvm/llvm-project/issues/78621.

(cherry picked from commit 3d91d9613e294b242d853039209b40a0cb7853f2)

Added: 


Modified: 
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
llvm/test/Transforms/ConstraintElimination/minmax.ll
llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp 
b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 8f09569d0d9cc..7b672e89b67aa 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -1061,11 +1061,16 @@ void State::addInfoFor(BasicBlock &BB) {
   FactOrCheck::getCheck(DT.getNode(&BB), cast(&I)));
   break;
 // Enqueue the intrinsics to add extra info.
-case Intrinsic::abs:
 case Intrinsic::umin:
 case Intrinsic::umax:
 case Intrinsic::smin:
 case Intrinsic::smax:
+  // TODO: Check if it is possible to instead only added the min/max facts
+  // when simplifying uses of the min/max intrinsics.
+  if (!isGuaranteedNotToBePoison(&I))
+break;
+  [[fallthrough]];
+case Intrinsic::abs:
   WorkList.push_back(FactOrCheck::getInstFact(DT.getNode(&BB), &I));
   break;
 }

diff  --git a/llvm/test/Transforms/ConstraintElimination/minmax.ll 
b/llvm/test/Transforms/ConstraintElimination/minmax.ll
index a31cf6845ad67..82b932f14c4ff 100644
--- a/llvm/test/Transforms/ConstraintElimination/minmax.ll
+++ b/llvm/test/Transforms/ConstraintElimination/minmax.ll
@@ -306,7 +306,9 @@ define i1 @smin_branchless(i32 %x, i32 %y) {
 ; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]]) {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[MIN:%.*]] = call i32 @llvm.smin.i32(i32 [[X]], i32 [[Y]])
-; CHECK-NEXT:[[RET:%.*]] = xor i1 true, false
+; CHECK-NEXT:[[CMP1:%.*]] = icmp sle i32 [[MIN]], [[X]]
+; CHECK-NEXT:[[CMP2:%.*]] = icmp sgt i32 [[MIN]], [[X]]
+; CHECK-NEXT:[[RET:%.*]] = xor i1 [[CMP1]], [[CMP2]]
 ; CHECK-NEXT:ret i1 [[RET]]
 ;
 entry:

diff  --git 
a/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll 
b/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll
index 35ac72e54d189..6d1d95ec4fdba 100644
--- a/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll
+++ b/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll
@@ -6,10 +6,11 @@
 define i1 @umin_not_used(i32 %arg) {
 ; CHECK-LABEL: define i1 @umin_not_used(
 ; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT:[[ICMP:%.*]] = icmp slt i32 [[ARG]], 0
 ; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3
 ; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80)
 ; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3
-; CHECK-NEXT:ret i1 false
+; CHECK-NEXT:ret i1 [[ICMP]]
 ;
   %icmp = icmp slt i32 %arg, 0
   %shl = shl nuw nsw i32 %arg, 3
@@ -38,12 +39,13 @@ define i1 @umin_poison_is_UB_via_call(i32 %arg) {
 define i1 @umin_poison_call_before_UB(i32 %arg) {
 ; CHECK-LABEL: define i1 @umin_poison_call_before_UB(
 ; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT:[[ICMP:%.*]] = icmp slt i32 [[ARG]], 0
 ; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3
 ; CHECK-NEXT:[[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80)
 ; CHECK-NEXT:call void @fn()
 ; CHECK-NEXT:call void @noundef(i32 noundef [[MIN]])
 ; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3
-; CHECK-NEXT:ret i1 false
+; CHECK-NEXT:ret i1 [[ICMP]]
 ;
   %icmp = icmp slt i32 %arg, 0
   %shl = shl nuw nsw i32 %arg, 3



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


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#78621 (PR #80260)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80260
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] PR for llvm/llvm-project#78892 (PR #80259)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/80259

>From 024f45e9ed23da66802c49847b82151dfdb70766 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Wed, 31 Jan 2024 20:20:26 -0800
Subject: [PATCH] [clang-format] Simplify the AfterPlacementOperator option
 (#79796)

Change AfterPlacementOperator to a boolean and deprecate SBPO_Never,
which meant never inserting a space except when after new/delete.

Fixes #78892.

(cherry picked from commit 908fd09a13b2e89a52282478544f7f70cf0a887f)
---
 clang/docs/ClangFormatStyleOptions.rst | 42 +
 clang/include/clang/Format/Format.h| 43 ++
 clang/lib/Format/Format.cpp| 23 +---
 clang/lib/Format/TokenAnnotator.cpp|  9 +
 clang/unittests/Format/ConfigParseTest.cpp | 19 +-
 clang/unittests/Format/FormatTest.cpp  | 32 +++-
 6 files changed, 38 insertions(+), 130 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 4dc0de3a90f26..0b887288fe2cb 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -5277,15 +5277,9 @@ the configuration (without a prefix: ``Auto``).
   Possible values:
 
   * ``SBPO_Never`` (in configuration: ``Never``)
-Never put a space before opening parentheses.
-
-.. code-block:: c++
-
-   void f() {
- if(true) {
-   f();
- }
-   }
+This is **deprecated** and replaced by ``Custom`` below, with all
+``SpaceBeforeParensOptions`` but ``AfterPlacementOperator`` set to
+``false``.
 
   * ``SBPO_ControlStatements`` (in configuration: ``ControlStatements``)
 Put a space before opening parentheses only after control statement
@@ -5425,32 +5419,14 @@ the configuration (without a prefix: ``Auto``).
void operator++ (int a);vs.void operator++(int a);
object.operator++ (10);object.operator++(10);
 
-  * ``AfterPlacementOperatorStyle AfterPlacementOperator`` 
:versionbadge:`clang-format 18`
-
-Defines in which cases to put a space between ``new/delete`` operators
-and opening parentheses.
-
-Possible values:
-
-* ``APO_Never`` (in configuration: ``Never``)
-  Remove space after ``new/delete`` operators and before ``(``.
-
-  .. code-block:: c++
-
- new(buf) T;
- delete(buf) T;
-
-* ``APO_Always`` (in configuration: ``Always``)
-  Always add space after ``new/delete`` operators and before ``(``.
+  * ``bool AfterPlacementOperator`` If ``true``, put a space between operator 
``new``/``delete`` and opening
+parenthesis.
 
-  .. code-block:: c++
-
- new (buf) T;
- delete (buf) T;
-
-* ``APO_Leave`` (in configuration: ``Leave``)
-  Leave placement ``new/delete`` expressions as they are.
+.. code-block:: c++
 
+   true:  false:
+   new (buf) T;vs.new(buf) T;
+   delete (buf) T;delete(buf) T;
 
   * ``bool AfterRequiresInClause`` If ``true``, put space between requires 
keyword in a requires clause and
 opening parentheses, if there is one.
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index bc9eecd42f9eb..efcb4e1d87ea4 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4157,14 +4157,9 @@ struct FormatStyle {
 
   /// Different ways to put a space before opening parentheses.
   enum SpaceBeforeParensStyle : int8_t {
-/// Never put a space before opening parentheses.
-/// \code
-///void f() {
-///  if(true) {
-///f();
-///  }
-///}
-/// \endcode
+/// This is **deprecated** and replaced by ``Custom`` below, with all
+/// ``SpaceBeforeParensOptions`` but ``AfterPlacementOperator`` set to
+/// ``false``.
 SBPO_Never,
 /// Put a space before opening parentheses only after control statement
 /// keywords (``for/if/while...``).
@@ -4273,28 +4268,14 @@ struct FormatStyle {
 ///object.operator++ (10);object.operator++(10);
 /// \endcode
 bool AfterOverloadedOperator;
-/// Styles for adding spacing between ``new/delete`` operators and opening
-/// parentheses.
-enum AfterPlacementOperatorStyle : int8_t {
-  /// Remove space after ``new/delete`` operators and before ``(``.
-  /// \code
-  ///new(buf) T;
-  ///delete(buf) T;
-  /// \endcode
-  APO_Never,
-  /// Always add space after ``new/delete`` operators and before ``(``.
-  /// \code
-  ///new (buf) T;
-  ///delete (buf) T;
-  /// \endcode
-  APO_Always,
-  /// Leave placement ``new/delete`` expressions as they are.
-  APO_Leave,
-};
-/// Defines in which cases to put a space between ``new/delete`` operators
-/// and opening p

[llvm-branch-commits] [clang] 024f45e - [clang-format] Simplify the AfterPlacementOperator option (#79796)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

Author: Owen Pan
Date: 2024-02-06T16:07:18-08:00
New Revision: 024f45e9ed23da66802c49847b82151dfdb70766

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

LOG: [clang-format] Simplify the AfterPlacementOperator option (#79796)

Change AfterPlacementOperator to a boolean and deprecate SBPO_Never,
which meant never inserting a space except when after new/delete.

Fixes #78892.

(cherry picked from commit 908fd09a13b2e89a52282478544f7f70cf0a887f)

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/ConfigParseTest.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 4dc0de3a90f26..0b887288fe2cb 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -5277,15 +5277,9 @@ the configuration (without a prefix: ``Auto``).
   Possible values:
 
   * ``SBPO_Never`` (in configuration: ``Never``)
-Never put a space before opening parentheses.
-
-.. code-block:: c++
-
-   void f() {
- if(true) {
-   f();
- }
-   }
+This is **deprecated** and replaced by ``Custom`` below, with all
+``SpaceBeforeParensOptions`` but ``AfterPlacementOperator`` set to
+``false``.
 
   * ``SBPO_ControlStatements`` (in configuration: ``ControlStatements``)
 Put a space before opening parentheses only after control statement
@@ -5425,32 +5419,14 @@ the configuration (without a prefix: ``Auto``).
void operator++ (int a);vs.void operator++(int a);
object.operator++ (10);object.operator++(10);
 
-  * ``AfterPlacementOperatorStyle AfterPlacementOperator`` 
:versionbadge:`clang-format 18`
-
-Defines in which cases to put a space between ``new/delete`` operators
-and opening parentheses.
-
-Possible values:
-
-* ``APO_Never`` (in configuration: ``Never``)
-  Remove space after ``new/delete`` operators and before ``(``.
-
-  .. code-block:: c++
-
- new(buf) T;
- delete(buf) T;
-
-* ``APO_Always`` (in configuration: ``Always``)
-  Always add space after ``new/delete`` operators and before ``(``.
+  * ``bool AfterPlacementOperator`` If ``true``, put a space between operator 
``new``/``delete`` and opening
+parenthesis.
 
-  .. code-block:: c++
-
- new (buf) T;
- delete (buf) T;
-
-* ``APO_Leave`` (in configuration: ``Leave``)
-  Leave placement ``new/delete`` expressions as they are.
+.. code-block:: c++
 
+   true:  false:
+   new (buf) T;vs.new(buf) T;
+   delete (buf) T;delete(buf) T;
 
   * ``bool AfterRequiresInClause`` If ``true``, put space between requires 
keyword in a requires clause and
 opening parentheses, if there is one.

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index bc9eecd42f9eb..efcb4e1d87ea4 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4157,14 +4157,9 @@ struct FormatStyle {
 
   /// Different ways to put a space before opening parentheses.
   enum SpaceBeforeParensStyle : int8_t {
-/// Never put a space before opening parentheses.
-/// \code
-///void f() {
-///  if(true) {
-///f();
-///  }
-///}
-/// \endcode
+/// This is **deprecated** and replaced by ``Custom`` below, with all
+/// ``SpaceBeforeParensOptions`` but ``AfterPlacementOperator`` set to
+/// ``false``.
 SBPO_Never,
 /// Put a space before opening parentheses only after control statement
 /// keywords (``for/if/while...``).
@@ -4273,28 +4268,14 @@ struct FormatStyle {
 ///object.operator++ (10);object.operator++(10);
 /// \endcode
 bool AfterOverloadedOperator;
-/// Styles for adding spacing between ``new/delete`` operators and opening
-/// parentheses.
-enum AfterPlacementOperatorStyle : int8_t {
-  /// Remove space after ``new/delete`` operators and before ``(``.
-  /// \code
-  ///new(buf) T;
-  ///delete(buf) T;
-  /// \endcode
-  APO_Never,
-  /// Always add space after ``new/delete`` operators and before ``(``.
-  /// \code
-  ///new (buf) T;
-  ///delete (buf) T;
-  /// \endcode
-  APO_Always,
-  /// Leave placement ``new/delete`` expressions as they are.
-  APO_Leave,
-};
-/// Defines in which cases to put a space between ``new/delete`` operators
-/// and opening par

[llvm-branch-commits] [clang] PR for llvm/llvm-project#78892 (PR #80259)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80259
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] PR for llvm/llvm-project#79568 (PR #80120)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80120
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] d0e9101 - PR for llvm/llvm-project#79568 (#80120)

2024-02-06 Thread via llvm-branch-commits

Author: Younan Zhang
Date: 2024-02-06T16:11:28-08:00
New Revision: d0e9101d9f1e49c828a0a88a04c2abde46bec88d

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

LOG: PR for llvm/llvm-project#79568 (#80120)

Backporting https://github.com/llvm/llvm-project/pull/79568 to clang 18.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaConcept.cpp
clang/test/SemaTemplate/concepts-lambda.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3ec187058db42..0c187d5e0dc1a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1054,6 +1054,11 @@ Bug Fixes to C++ Support
   Fixes (`#78830 `_)
   Fixes (`#60085 `_)
 
+
+- Fixed a bug where variables referenced by requires-clauses inside
+  nested generic lambdas were not properly injected into the constraint scope.
+  (`#73418 `_)
+
 - Fix incorrect code generation caused by the object argument of ``static 
operator()`` and ``static operator[]`` calls not being evaluated.
   Fixes (`#67976 `_)
 

diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index acfc00f412540..88fc846c89e42 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -612,8 +612,12 @@ bool Sema::SetupConstraintScope(
 
 // If this is a member function, make sure we get the parameters that
 // reference the original primary template.
-if (const auto *FromMemTempl =
-PrimaryTemplate->getInstantiatedFromMemberTemplate()) {
+// We walk up the instantiated template chain so that nested lambdas get
+// handled properly.
+for (FunctionTemplateDecl *FromMemTempl =
+ PrimaryTemplate->getInstantiatedFromMemberTemplate();
+ FromMemTempl;
+ FromMemTempl = FromMemTempl->getInstantiatedFromMemberTemplate()) {
   if (addInstantiatedParametersToScope(FD, 
FromMemTempl->getTemplatedDecl(),
Scope, MLTAL))
 return true;

diff  --git a/clang/test/SemaTemplate/concepts-lambda.cpp 
b/clang/test/SemaTemplate/concepts-lambda.cpp
index 7e431529427df..0b7580f91043c 100644
--- a/clang/test/SemaTemplate/concepts-lambda.cpp
+++ b/clang/test/SemaTemplate/concepts-lambda.cpp
@@ -149,3 +149,21 @@ void foo() {
   auto caller = make_caller.operator()<&S1::f1>();
 }
 } // namespace ReturnTypeRequirementInLambda
+
+namespace GH73418 {
+void foo() {
+  int x;
+  [&x](auto) {
+return [](auto y) {
+  return [](auto obj, auto... params)
+requires requires {
+  sizeof...(params);
+  [](auto... pack) {
+return sizeof...(pack);
+  }(params...);
+}
+  { return false; }(y);
+}(x);
+  }(x);
+}
+} // namespace GH73418



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


[llvm-branch-commits] [clang] [lld] [llvm] [docs] Add release notes for Windows specific changes in 18.x (PR #80011)

2024-02-06 Thread Tom Stellard via llvm-branch-commits
Martin =?utf-8?q?Storsjö?= 
Message-ID:
In-Reply-To: 


https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80011
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] d0149a5 - [docs] Add release notes for Windows specific changes in 18.x (#80011)

2024-02-06 Thread via llvm-branch-commits

Author: Martin Storsjö
Date: 2024-02-06T16:20:10-08:00
New Revision: d0149a593b21f0d3969888063bf5935cef187209

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

LOG: [docs] Add release notes for Windows specific changes in 18.x (#80011)

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
lld/docs/ReleaseNotes.rst
llvm/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0c187d5e0dc1ad..ba9b773c7772ee 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1203,6 +1203,8 @@ Windows Support
   linking may succeed but the resulting executables may expose issues at
   runtime.
 
+- Clang now passes relevant LTO options to the linker (LLD) in MinGW mode.
+
 LoongArch Support
 ^
 - Added builtins support for all LSX (128-bits SIMD) and LASX (256-bits SIMD)

diff  --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst
index 21a075ad8c4eff..fa0e7f2bc0b3ea 100644
--- a/lld/docs/ReleaseNotes.rst
+++ b/lld/docs/ReleaseNotes.rst
@@ -83,9 +83,29 @@ COFF Improvements
 * Added support for ``--time-trace`` and associated 
``--time-trace-granularity``.
   This generates a .json profile trace of the linker execution.
 
+* LLD now prefers library paths specified with ``-libpath:`` over the 
implicitly
+  detected toolchain paths.
+
 MinGW Improvements
 --
 
+* Added support for many LTO and ThinLTO options (most LTO options supported
+  by the ELF driver, that are implemented by the COFF backend as well,
+  should be supported now).
+
+* LLD no longer tries to autodetect and use library paths from MSVC/WinSDK
+  installations when run in MinGW mode; that mode of operation shouldn't
+  ever be needed in MinGW mode, and could be a source of unexpected
+  behaviours.
+
+* The ``--icf=safe`` option now works as expected; it was previously a no-op.
+
+* More correctly handle LTO of files that define ``__imp_`` prefixed dllimport
+  redirections.
+
+* The strip flags ``-S`` and ``-s`` now can be used to strip out DWARF debug
+  info and symbol tables while emitting a PDB debug info file.
+
 MachO Improvements
 --
 

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 0e70a4e08159e9..2c2d5b2a90a806 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -320,6 +320,19 @@ Changes to the LLVM tools
 * llvm-objcopy now supports ``--gap-fill`` and ``--pad-to`` options, for
   ELF input and binary output files only.
 
+* llvm-rc and llvm-windres now accept file path references in ``.rc`` files
+  concatenated from multiple string literals.
+
+* The llvm-windres option ``--preprocessor`` now resolves its argument
+  in the PATH environment variable as expected, and options passed with
+  ``--preprocessor-arg`` are placed before the input file as they should
+  be.
+
+* The llvm-windres option ``--preprocessor`` has been updated with the
+  breaking behaviour change from GNU windres from binutils 2.36, where
+  the whole argument is considered as one path, not considered as a
+  sequence of tool name and parameters.
+
 Changes to LLDB
 -
 
@@ -360,6 +373,8 @@ Changes to LLDB
   fields are present, however this is not always possible or entirely
   accurate. If in doubt, refer to the numerical value.
 
+* On Windows, LLDB can now read the thread names.
+
 Changes to Sanitizers
 -
 * HWASan now defaults to detecting use-after-scope bugs.



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


[llvm-branch-commits] [libcxx] b82aea1 - [libcxx] Add a release note for Clang-cl specific features (#80010)

2024-02-06 Thread via llvm-branch-commits

Author: Martin Storsjö
Date: 2024-02-06T16:36:23-08:00
New Revision: b82aea1fa13b09f4616b89f194f3bacfe22e8fa6

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

LOG: [libcxx] Add a release note for Clang-cl specific features (#80010)

Added: 


Modified: 
libcxx/docs/ReleaseNotes/18.rst

Removed: 




diff  --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fb3d2af544c287..450a6f25d1ea5e 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -342,3 +342,6 @@ Build System Changes
   them so that they can interoperate with other system-provided libraries that 
might be using a 
diff erent unwinding
   library (such as ``libgcc_s``), you should pass 
``LIBCXXABI_USE_LLVM_UNWINDER=OFF`` and ``COMPILER_RT_USE_LLVM_UNWINDER=OFF``
   to make sure the system-provided unwinding library is used by the LLVM 
runtimes.
+
+- In Clang-cl configurations, libc++ can now be built against the static and/or
+  debug MSVC C runtimes



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


[llvm-branch-commits] [libcxx] [libcxx] Add a release note for Clang-cl specific features (PR #80010)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80010
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#78725 (PR #79986)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/79986

>From 8091f1be3dc8c7b7c35452dc97f35b9d27aa6d69 Mon Sep 17 00:00:00 2001
From: Graham Hunter 
Date: Fri, 26 Jan 2024 11:30:35 +
Subject: [PATCH] [LV] Fix handling of interleaving linear args (#78725)

Currently when interleaving vector calls with linear arguments,
the Part is ignored and all vector calls use the initial value
from the first lane of the current iteration.

Fix this to extract from the correct part of the linear vector.

(cherry picked from commit d4c01714239e80d21e441c3886749fc56b743f81)
---
 .../lib/Transforms/Vectorize/VPlanRecipes.cpp | 12 +++--
 .../AArch64/vector-call-linear-args.ll| 54 ---
 2 files changed, 42 insertions(+), 24 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp 
b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index bbeb5da2cfec3e..ae2fc522ba4002 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -597,13 +597,15 @@ void VPWidenCallRecipe::execute(VPTransformState &State) {
 for (const auto &I : enumerate(operands())) {
   // Some intrinsics have a scalar argument - don't replace it with a
   // vector.
-  // Some vectorized function variants may also take a scalar argument,
-  // e.g. linear parameters for pointers.
   Value *Arg;
-  if ((VFTy && !VFTy->getParamType(I.index())->isVectorTy()) ||
-  (UseIntrinsic &&
-   isVectorIntrinsicWithScalarOpAtArg(VectorIntrinsicID, I.index(
+  if (UseIntrinsic &&
+  isVectorIntrinsicWithScalarOpAtArg(VectorIntrinsicID, I.index()))
 Arg = State.get(I.value(), VPIteration(0, 0));
+  // Some vectorized function variants may also take a scalar argument,
+  // e.g. linear parameters for pointers. This needs to be the scalar value
+  // from the start of the respective part when interleaving.
+  else if (VFTy && !VFTy->getParamType(I.index())->isVectorTy())
+Arg = State.get(I.value(), VPIteration(Part, 0));
   else
 Arg = State.get(I.value(), Part);
   if (UseIntrinsic &&
diff --git 
a/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll 
b/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
index 29440ca174248f..f60ab5e848dd3a 100644
--- a/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
+++ b/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
@@ -21,7 +21,8 @@ define void @test_linear8(ptr noalias %a, ptr readnone %b, 
i64 %n) {
 ; NEON_INTERLEAVE-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], i64 
[[N:%.*]]) {
 ; NEON_INTERLEAVE:[[TMP4:%.*]] = extractelement <2 x ptr> [[TMP2:%.*]], 
i32 0
 ; NEON_INTERLEAVE:[[TMP5:%.*]] = call <2 x i64> 
@vec_foo_linear8_nomask_neon(ptr [[TMP4]])
-; NEON_INTERLEAVE:[[TMP6:%.*]] = call <2 x i64> 
@vec_foo_linear8_nomask_neon(ptr [[TMP4]])
+; NEON_INTERLEAVE:[[TMP6:%.*]] = extractelement <2 x ptr> [[TMP3:%.*]], 
i32 0
+; NEON_INTERLEAVE:[[TMP7:%.*]] = call <2 x i64> 
@vec_foo_linear8_nomask_neon(ptr [[TMP6]])
 ; NEON_INTERLEAVE:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) 
#[[ATTR0:[0-9]+]]
 ;
 ; SVE_OR_NEON-LABEL: define void @test_linear8
@@ -34,8 +35,9 @@ define void @test_linear8(ptr noalias %a, ptr readnone %b, 
i64 %n) {
 ; SVE_OR_NEON_INTERLEAVE-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], 
i64 [[N:%.*]]) #[[ATTR0:[0-9]+]] {
 ; SVE_OR_NEON_INTERLEAVE:[[TMP33:%.*]] = extractelement  
[[TMP31:%.*]], i32 0
 ; SVE_OR_NEON_INTERLEAVE:[[TMP34:%.*]] = call  
@vec_foo_linear8_mask_sve(ptr [[TMP33]],  
[[ACTIVE_LANE_MASK:%.*]])
-; SVE_OR_NEON_INTERLEAVE:[[TMP35:%.*]] = call  
@vec_foo_linear8_mask_sve(ptr [[TMP33]],  
[[ACTIVE_LANE_MASK2:%.*]])
-; SVE_OR_NEON_INTERLEAVE:[[TMP47:%.*]] = extractelement  
[[TMP45:%.*]], i32 0
+; SVE_OR_NEON_INTERLEAVE:[[TMP35:%.*]] = extractelement  
[[TMP32:%.*]], i32 0
+; SVE_OR_NEON_INTERLEAVE:[[TMP36:%.*]] = call  
@vec_foo_linear8_mask_sve(ptr [[TMP35]],  
[[ACTIVE_LANE_MASK2:%.*]])
+; SVE_OR_NEON_INTERLEAVE:[[TMP48:%.*]] = extractelement  
[[TMP46:%.*]], i32 0
 ; SVE_OR_NEON_INTERLEAVE:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) 
#[[ATTR4:[0-9]+]]
 ;
 ; SVE_TF-LABEL: define void @test_linear8
@@ -49,8 +51,9 @@ define void @test_linear8(ptr noalias %a, ptr readnone %b, 
i64 %n) {
 ; SVE_TF_INTERLEAVE-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], i64 
[[N:%.*]]) #[[ATTR0:[0-9]+]] {
 ; SVE_TF_INTERLEAVE:[[TMP33:%.*]] = extractelement  
[[TMP31:%.*]], i32 0
 ; SVE_TF_INTERLEAVE:[[TMP34:%.*]] = call  
@vec_foo_linear8_mask_sve(ptr [[TMP33]],  
[[ACTIVE_LANE_MASK:%.*]])
-; SVE_TF_INTERLEAVE:[[TMP35:%.*]] = call  
@vec_foo_linear8_mask_sve(ptr [[TMP33]],  
[[ACTIVE_LANE_MASK2:%.*]])
-; SVE_TF_INTERLEAVE:[[TMP47:%.*]] = extractelement  
[[TMP45:%.*]], i32 0
+; SVE_TF_INTERLEAVE:[[TMP35:%.*]] = 

[llvm-branch-commits] [llvm] PR for llvm/llvm-project#78725 (PR #79986)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/79986

>From 6e9673f87d40983187b50cabd51926c43fd9b4e9 Mon Sep 17 00:00:00 2001
From: Graham Hunter 
Date: Fri, 26 Jan 2024 11:30:35 +
Subject: [PATCH] [LV] Fix handling of interleaving linear args (#78725)

Currently when interleaving vector calls with linear arguments,
the Part is ignored and all vector calls use the initial value
from the first lane of the current iteration.

Fix this to extract from the correct part of the linear vector.

(cherry picked from commit d4c01714239e80d21e441c3886749fc56b743f81)
---
 .../lib/Transforms/Vectorize/VPlanRecipes.cpp | 12 +++--
 .../AArch64/vector-call-linear-args.ll| 54 ---
 2 files changed, 42 insertions(+), 24 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp 
b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index bbeb5da2cfec3e..ae2fc522ba4002 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -597,13 +597,15 @@ void VPWidenCallRecipe::execute(VPTransformState &State) {
 for (const auto &I : enumerate(operands())) {
   // Some intrinsics have a scalar argument - don't replace it with a
   // vector.
-  // Some vectorized function variants may also take a scalar argument,
-  // e.g. linear parameters for pointers.
   Value *Arg;
-  if ((VFTy && !VFTy->getParamType(I.index())->isVectorTy()) ||
-  (UseIntrinsic &&
-   isVectorIntrinsicWithScalarOpAtArg(VectorIntrinsicID, I.index(
+  if (UseIntrinsic &&
+  isVectorIntrinsicWithScalarOpAtArg(VectorIntrinsicID, I.index()))
 Arg = State.get(I.value(), VPIteration(0, 0));
+  // Some vectorized function variants may also take a scalar argument,
+  // e.g. linear parameters for pointers. This needs to be the scalar value
+  // from the start of the respective part when interleaving.
+  else if (VFTy && !VFTy->getParamType(I.index())->isVectorTy())
+Arg = State.get(I.value(), VPIteration(Part, 0));
   else
 Arg = State.get(I.value(), Part);
   if (UseIntrinsic &&
diff --git 
a/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll 
b/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
index 29440ca174248f..f60ab5e848dd3a 100644
--- a/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
+++ b/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
@@ -21,7 +21,8 @@ define void @test_linear8(ptr noalias %a, ptr readnone %b, 
i64 %n) {
 ; NEON_INTERLEAVE-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], i64 
[[N:%.*]]) {
 ; NEON_INTERLEAVE:[[TMP4:%.*]] = extractelement <2 x ptr> [[TMP2:%.*]], 
i32 0
 ; NEON_INTERLEAVE:[[TMP5:%.*]] = call <2 x i64> 
@vec_foo_linear8_nomask_neon(ptr [[TMP4]])
-; NEON_INTERLEAVE:[[TMP6:%.*]] = call <2 x i64> 
@vec_foo_linear8_nomask_neon(ptr [[TMP4]])
+; NEON_INTERLEAVE:[[TMP6:%.*]] = extractelement <2 x ptr> [[TMP3:%.*]], 
i32 0
+; NEON_INTERLEAVE:[[TMP7:%.*]] = call <2 x i64> 
@vec_foo_linear8_nomask_neon(ptr [[TMP6]])
 ; NEON_INTERLEAVE:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) 
#[[ATTR0:[0-9]+]]
 ;
 ; SVE_OR_NEON-LABEL: define void @test_linear8
@@ -34,8 +35,9 @@ define void @test_linear8(ptr noalias %a, ptr readnone %b, 
i64 %n) {
 ; SVE_OR_NEON_INTERLEAVE-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], 
i64 [[N:%.*]]) #[[ATTR0:[0-9]+]] {
 ; SVE_OR_NEON_INTERLEAVE:[[TMP33:%.*]] = extractelement  
[[TMP31:%.*]], i32 0
 ; SVE_OR_NEON_INTERLEAVE:[[TMP34:%.*]] = call  
@vec_foo_linear8_mask_sve(ptr [[TMP33]],  
[[ACTIVE_LANE_MASK:%.*]])
-; SVE_OR_NEON_INTERLEAVE:[[TMP35:%.*]] = call  
@vec_foo_linear8_mask_sve(ptr [[TMP33]],  
[[ACTIVE_LANE_MASK2:%.*]])
-; SVE_OR_NEON_INTERLEAVE:[[TMP47:%.*]] = extractelement  
[[TMP45:%.*]], i32 0
+; SVE_OR_NEON_INTERLEAVE:[[TMP35:%.*]] = extractelement  
[[TMP32:%.*]], i32 0
+; SVE_OR_NEON_INTERLEAVE:[[TMP36:%.*]] = call  
@vec_foo_linear8_mask_sve(ptr [[TMP35]],  
[[ACTIVE_LANE_MASK2:%.*]])
+; SVE_OR_NEON_INTERLEAVE:[[TMP48:%.*]] = extractelement  
[[TMP46:%.*]], i32 0
 ; SVE_OR_NEON_INTERLEAVE:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) 
#[[ATTR4:[0-9]+]]
 ;
 ; SVE_TF-LABEL: define void @test_linear8
@@ -49,8 +51,9 @@ define void @test_linear8(ptr noalias %a, ptr readnone %b, 
i64 %n) {
 ; SVE_TF_INTERLEAVE-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], i64 
[[N:%.*]]) #[[ATTR0:[0-9]+]] {
 ; SVE_TF_INTERLEAVE:[[TMP33:%.*]] = extractelement  
[[TMP31:%.*]], i32 0
 ; SVE_TF_INTERLEAVE:[[TMP34:%.*]] = call  
@vec_foo_linear8_mask_sve(ptr [[TMP33]],  
[[ACTIVE_LANE_MASK:%.*]])
-; SVE_TF_INTERLEAVE:[[TMP35:%.*]] = call  
@vec_foo_linear8_mask_sve(ptr [[TMP33]],  
[[ACTIVE_LANE_MASK2:%.*]])
-; SVE_TF_INTERLEAVE:[[TMP47:%.*]] = extractelement  
[[TMP45:%.*]], i32 0
+; SVE_TF_INTERLEAVE:[[TMP35:%.*]] = 

[llvm-branch-commits] [llvm] 6e9673f - [LV] Fix handling of interleaving linear args (#78725)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

Author: Graham Hunter
Date: 2024-02-06T16:47:15-08:00
New Revision: 6e9673f87d40983187b50cabd51926c43fd9b4e9

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

LOG: [LV] Fix handling of interleaving linear args (#78725)

Currently when interleaving vector calls with linear arguments,
the Part is ignored and all vector calls use the initial value
from the first lane of the current iteration.

Fix this to extract from the correct part of the linear vector.

(cherry picked from commit d4c01714239e80d21e441c3886749fc56b743f81)

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp 
b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index bbeb5da2cfec3e..ae2fc522ba4002 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -597,13 +597,15 @@ void VPWidenCallRecipe::execute(VPTransformState &State) {
 for (const auto &I : enumerate(operands())) {
   // Some intrinsics have a scalar argument - don't replace it with a
   // vector.
-  // Some vectorized function variants may also take a scalar argument,
-  // e.g. linear parameters for pointers.
   Value *Arg;
-  if ((VFTy && !VFTy->getParamType(I.index())->isVectorTy()) ||
-  (UseIntrinsic &&
-   isVectorIntrinsicWithScalarOpAtArg(VectorIntrinsicID, I.index(
+  if (UseIntrinsic &&
+  isVectorIntrinsicWithScalarOpAtArg(VectorIntrinsicID, I.index()))
 Arg = State.get(I.value(), VPIteration(0, 0));
+  // Some vectorized function variants may also take a scalar argument,
+  // e.g. linear parameters for pointers. This needs to be the scalar value
+  // from the start of the respective part when interleaving.
+  else if (VFTy && !VFTy->getParamType(I.index())->isVectorTy())
+Arg = State.get(I.value(), VPIteration(Part, 0));
   else
 Arg = State.get(I.value(), Part);
   if (UseIntrinsic &&

diff  --git 
a/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll 
b/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
index 29440ca174248f..f60ab5e848dd3a 100644
--- a/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
+++ b/llvm/test/Transforms/LoopVectorize/AArch64/vector-call-linear-args.ll
@@ -21,7 +21,8 @@ define void @test_linear8(ptr noalias %a, ptr readnone %b, 
i64 %n) {
 ; NEON_INTERLEAVE-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], i64 
[[N:%.*]]) {
 ; NEON_INTERLEAVE:[[TMP4:%.*]] = extractelement <2 x ptr> [[TMP2:%.*]], 
i32 0
 ; NEON_INTERLEAVE:[[TMP5:%.*]] = call <2 x i64> 
@vec_foo_linear8_nomask_neon(ptr [[TMP4]])
-; NEON_INTERLEAVE:[[TMP6:%.*]] = call <2 x i64> 
@vec_foo_linear8_nomask_neon(ptr [[TMP4]])
+; NEON_INTERLEAVE:[[TMP6:%.*]] = extractelement <2 x ptr> [[TMP3:%.*]], 
i32 0
+; NEON_INTERLEAVE:[[TMP7:%.*]] = call <2 x i64> 
@vec_foo_linear8_nomask_neon(ptr [[TMP6]])
 ; NEON_INTERLEAVE:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) 
#[[ATTR0:[0-9]+]]
 ;
 ; SVE_OR_NEON-LABEL: define void @test_linear8
@@ -34,8 +35,9 @@ define void @test_linear8(ptr noalias %a, ptr readnone %b, 
i64 %n) {
 ; SVE_OR_NEON_INTERLEAVE-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], 
i64 [[N:%.*]]) #[[ATTR0:[0-9]+]] {
 ; SVE_OR_NEON_INTERLEAVE:[[TMP33:%.*]] = extractelement  
[[TMP31:%.*]], i32 0
 ; SVE_OR_NEON_INTERLEAVE:[[TMP34:%.*]] = call  
@vec_foo_linear8_mask_sve(ptr [[TMP33]],  
[[ACTIVE_LANE_MASK:%.*]])
-; SVE_OR_NEON_INTERLEAVE:[[TMP35:%.*]] = call  
@vec_foo_linear8_mask_sve(ptr [[TMP33]],  
[[ACTIVE_LANE_MASK2:%.*]])
-; SVE_OR_NEON_INTERLEAVE:[[TMP47:%.*]] = extractelement  
[[TMP45:%.*]], i32 0
+; SVE_OR_NEON_INTERLEAVE:[[TMP35:%.*]] = extractelement  
[[TMP32:%.*]], i32 0
+; SVE_OR_NEON_INTERLEAVE:[[TMP36:%.*]] = call  
@vec_foo_linear8_mask_sve(ptr [[TMP35]],  
[[ACTIVE_LANE_MASK2:%.*]])
+; SVE_OR_NEON_INTERLEAVE:[[TMP48:%.*]] = extractelement  
[[TMP46:%.*]], i32 0
 ; SVE_OR_NEON_INTERLEAVE:[[DATA:%.*]] = call i64 @foo(ptr [[GEPB:%.*]]) 
#[[ATTR4:[0-9]+]]
 ;
 ; SVE_TF-LABEL: define void @test_linear8
@@ -49,8 +51,9 @@ define void @test_linear8(ptr noalias %a, ptr readnone %b, 
i64 %n) {
 ; SVE_TF_INTERLEAVE-SAME: (ptr noalias [[A:%.*]], ptr readnone [[B:%.*]], i64 
[[N:%.*]]) #[[ATTR0:[0-9]+]] {
 ; SVE_TF_INTERLEAVE:[[TMP33:%.*]] = extractelement  
[[TMP31:%.*]], i32 0
 ; SVE_TF_INTERLEAVE:[[TMP34:%.*]] = call  
@vec_foo_linear8_mask_sve(ptr [[TMP33]],  
[[ACTIVE_LANE_MASK:%.*]])
-; SVE_TF_INTERLEAVE:[[TMP35:%.*]] = call  
@vec_foo_linear8_mask_sve(ptr [[TMP33]],  
[[ACTIVE_L

[llvm-branch-commits] [llvm] PR for llvm/llvm-project#78725 (PR #79986)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/79986
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79675 (PR #79721)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/79721

>From 0328b878e8e34fddf318758f9d4c4449a5ae0dbc Mon Sep 17 00:00:00 2001
From: Shengchen Kan 
Date: Sun, 28 Jan 2024 09:06:27 +0800
Subject: [PATCH] [X86][tablgen] Fix the broadcast tables (#79675)

(cherry picked from commit 7c3ee7cbe6419ea5e37ce2723cc1a1688380581f)
---
 .../include/llvm/Support/X86FoldTablesUtils.h |  11 +-
 llvm/lib/Target/X86/X86InstrAVX512.td |   2 +-
 llvm/lib/Target/X86/X86InstrFoldTables.cpp|  11 +-
 llvm/test/TableGen/x86-fold-tables.inc| 378 +-
 llvm/utils/TableGen/X86FoldTablesEmitter.cpp  |  58 +--
 5 files changed, 223 insertions(+), 237 deletions(-)

diff --git a/llvm/include/llvm/Support/X86FoldTablesUtils.h 
b/llvm/include/llvm/Support/X86FoldTablesUtils.h
index ed244febc38d3a..77d32cc7fb37ed 100644
--- a/llvm/include/llvm/Support/X86FoldTablesUtils.h
+++ b/llvm/include/llvm/Support/X86FoldTablesUtils.h
@@ -46,11 +46,12 @@ enum {
   // Broadcast type.
   // (stored in bits 12 - 14)
   TB_BCAST_TYPE_SHIFT = TB_ALIGN_SHIFT + 3,
-  TB_BCAST_D = 0 << TB_BCAST_TYPE_SHIFT,
-  TB_BCAST_Q = 1 << TB_BCAST_TYPE_SHIFT,
-  TB_BCAST_SS = 2 << TB_BCAST_TYPE_SHIFT,
-  TB_BCAST_SD = 3 << TB_BCAST_TYPE_SHIFT,
-  TB_BCAST_SH = 4 << TB_BCAST_TYPE_SHIFT,
+  TB_BCAST_W = 0 << TB_BCAST_TYPE_SHIFT,
+  TB_BCAST_D = 1 << TB_BCAST_TYPE_SHIFT,
+  TB_BCAST_Q = 2 << TB_BCAST_TYPE_SHIFT,
+  TB_BCAST_SS = 3 << TB_BCAST_TYPE_SHIFT,
+  TB_BCAST_SD = 4 << TB_BCAST_TYPE_SHIFT,
+  TB_BCAST_SH = 5 << TB_BCAST_TYPE_SHIFT,
   TB_BCAST_MASK = 0x7 << TB_BCAST_TYPE_SHIFT,
 
   // Unused bits 15-16
diff --git a/llvm/lib/Target/X86/X86InstrAVX512.td 
b/llvm/lib/Target/X86/X86InstrAVX512.td
index fe7d90fbcdf707..bb5e22c7142793 100644
--- a/llvm/lib/Target/X86/X86InstrAVX512.td
+++ b/llvm/lib/Target/X86/X86InstrAVX512.td
@@ -12422,7 +12422,7 @@ multiclass GF2P8AFFINE_avx512_rmb_imm Op, 
string OpStr, SDNode OpNode,
: avx512_3Op_rm_imm8 {
   let ExeDomain = VTI.ExeDomain in
   defm rmbi : AVX512_maskableTheDef;
-  StringRef RegInstName = RegRec->getName();
-  StringRef MemInstName = MemInst->TheDef->getName();
-  Record *Domain = RegRec->getValueAsDef("ExeDomain");
-  bool IsSSEPackedInt = Domain->getName() == "SSEPackedInt";
-  if ((RegInstName.contains("DZ") || RegInstName.contains("DWZ") ||
-   RegInstName.contains("Dr") || RegInstName.contains("I32")) &&
-  IsSSEPackedInt) {
-assert((MemInstName.contains("DZ") || RegInstName.contains("DWZ") ||
-MemInstName.contains("Dr") || MemInstName.contains("I32")) &&
-   "Unmatched names for broadcast");
-Result.BroadcastKind = X86FoldTableEntry::BCAST_D;
-  } else if ((RegInstName.contains("QZ") || RegInstName.contains("QBZ") ||
-  RegInstName.contains("Qr") || RegInstName.contains("I64")) &&
- IsSSEPackedInt) {
-assert((MemInstName.contains("QZ") || MemInstName.contains("QBZ") ||
-MemInstName.contains("Qr") || MemInstName.contains("I64")) &&
-   "Unmatched names for broadcast");
-Result.BroadcastKind = X86FoldTableEntry::BCAST_Q;
-  } else if ((RegInstName.contains("PS") || RegInstName.contains("F32") ||
-  RegInstName.contains("CPH")) &&
- !RegInstName.contains("PH2PS")) {
-assert((MemInstName.contains("PS") || MemInstName.contains("F32") ||
-MemInstName.contains("CPH")) &&
-   "Unmatched names for broadcast");
-Result.BroadcastKind = X86FoldTableEntry::BCAST_SS;
-  } else if ((RegInstName.contains("PD") || RegInstName.contains("F64")) &&
- !RegInstName.contains("PH2PD")) {
-assert((MemInstName.contains("PD") || MemInstName.contains("F64")) &&
-   "Unmatched names for broadcast");
-Result.BroadcastKind = X86FoldTableEntry::BCAST_SD;
-  } else if (RegInstName.contains("PH")) {
-assert(MemInstName.contains("PH") && "Unmatched names for broadcast");
-Result.BroadcastKind = X86FoldTableEntry::BCAST_SH;
-  } else {
-errs() << RegInstName << ", " << MemInstName << "\n";
-llvm_unreachable("Name is not canoicalized for broadcast or "
- "ExeDomain is incorrect");
+  DagInit *In = MemInst->TheDef->getValueAsDag("InOperandList");
+  for (unsigned I = 0, E = In->getNumArgs(); I != E; ++I) {
+Result.BroadcastKind =
+
StringSwitch(In->getArg(I)->getAsString())
+.Case("i16mem", X86FoldTableEntry::BCAST_W)
+.Case("i32mem", X86FoldTableEntry::BCAST_D)
+.Case("i64mem", X86FoldTableEntry::BCAST_Q)
+.Case("f16mem", X86FoldTableEntry::BCAST_SH)
+.Case("f32mem", X86FoldTableEntry::BCAST_SS)
+.Case("f64mem", X86FoldTableEntry::BCAST_SD)
+.Default(X86FoldTableEntry::BCAST_NONE);
+if (Result.BroadcastKind != X86FoldTableEntry::BCAST_NONE)
+  break;
   }
+  assert(Result.BroadcastKind != X86FoldTableEntry::BCAST_NONE &&
+ "Unknown memory operand for broadcast"

[llvm-branch-commits] [llvm] 0328b87 - [X86][tablgen] Fix the broadcast tables (#79675)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

Author: Shengchen Kan
Date: 2024-02-06T16:57:46-08:00
New Revision: 0328b878e8e34fddf318758f9d4c4449a5ae0dbc

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

LOG: [X86][tablgen] Fix the broadcast tables (#79675)

(cherry picked from commit 7c3ee7cbe6419ea5e37ce2723cc1a1688380581f)

Added: 


Modified: 
llvm/include/llvm/Support/X86FoldTablesUtils.h
llvm/lib/Target/X86/X86InstrAVX512.td
llvm/lib/Target/X86/X86InstrFoldTables.cpp
llvm/test/TableGen/x86-fold-tables.inc
llvm/utils/TableGen/X86FoldTablesEmitter.cpp

Removed: 




diff  --git a/llvm/include/llvm/Support/X86FoldTablesUtils.h 
b/llvm/include/llvm/Support/X86FoldTablesUtils.h
index ed244febc38d3a..77d32cc7fb37ed 100644
--- a/llvm/include/llvm/Support/X86FoldTablesUtils.h
+++ b/llvm/include/llvm/Support/X86FoldTablesUtils.h
@@ -46,11 +46,12 @@ enum {
   // Broadcast type.
   // (stored in bits 12 - 14)
   TB_BCAST_TYPE_SHIFT = TB_ALIGN_SHIFT + 3,
-  TB_BCAST_D = 0 << TB_BCAST_TYPE_SHIFT,
-  TB_BCAST_Q = 1 << TB_BCAST_TYPE_SHIFT,
-  TB_BCAST_SS = 2 << TB_BCAST_TYPE_SHIFT,
-  TB_BCAST_SD = 3 << TB_BCAST_TYPE_SHIFT,
-  TB_BCAST_SH = 4 << TB_BCAST_TYPE_SHIFT,
+  TB_BCAST_W = 0 << TB_BCAST_TYPE_SHIFT,
+  TB_BCAST_D = 1 << TB_BCAST_TYPE_SHIFT,
+  TB_BCAST_Q = 2 << TB_BCAST_TYPE_SHIFT,
+  TB_BCAST_SS = 3 << TB_BCAST_TYPE_SHIFT,
+  TB_BCAST_SD = 4 << TB_BCAST_TYPE_SHIFT,
+  TB_BCAST_SH = 5 << TB_BCAST_TYPE_SHIFT,
   TB_BCAST_MASK = 0x7 << TB_BCAST_TYPE_SHIFT,
 
   // Unused bits 15-16

diff  --git a/llvm/lib/Target/X86/X86InstrAVX512.td 
b/llvm/lib/Target/X86/X86InstrAVX512.td
index fe7d90fbcdf707..bb5e22c7142793 100644
--- a/llvm/lib/Target/X86/X86InstrAVX512.td
+++ b/llvm/lib/Target/X86/X86InstrAVX512.td
@@ -12422,7 +12422,7 @@ multiclass GF2P8AFFINE_avx512_rmb_imm Op, 
string OpStr, SDNode OpNode,
: avx512_3Op_rm_imm8 {
   let ExeDomain = VTI.ExeDomain in
   defm rmbi : AVX512_maskableTheDef;
-  StringRef RegInstName = RegRec->getName();
-  StringRef MemInstName = MemInst->TheDef->getName();
-  Record *Domain = RegRec->getValueAsDef("ExeDomain");
-  bool IsSSEPackedInt = Domain->getName() == "SSEPackedInt";
-  if ((RegInstName.contains("DZ") || RegInstName.contains("DWZ") ||
-   RegInstName.contains("Dr") || RegInstName.contains("I32")) &&
-  IsSSEPackedInt) {
-assert((MemInstName.contains("DZ") || RegInstName.contains("DWZ") ||
-MemInstName.contains("Dr") || MemInstName.contains("I32")) &&
-   "Unmatched names for broadcast");
-Result.BroadcastKind = X86FoldTableEntry::BCAST_D;
-  } else if ((RegInstName.contains("QZ") || RegInstName.contains("QBZ") ||
-  RegInstName.contains("Qr") || RegInstName.contains("I64")) &&
- IsSSEPackedInt) {
-assert((MemInstName.contains("QZ") || MemInstName.contains("QBZ") ||
-MemInstName.contains("Qr") || MemInstName.contains("I64")) &&
-   "Unmatched names for broadcast");
-Result.BroadcastKind = X86FoldTableEntry::BCAST_Q;
-  } else if ((RegInstName.contains("PS") || RegInstName.contains("F32") ||
-  RegInstName.contains("CPH")) &&
- !RegInstName.contains("PH2PS")) {
-assert((MemInstName.contains("PS") || MemInstName.contains("F32") ||
-MemInstName.contains("CPH")) &&
-   "Unmatched names for broadcast");
-Result.BroadcastKind = X86FoldTableEntry::BCAST_SS;
-  } else if ((RegInstName.contains("PD") || RegInstName.contains("F64")) &&
- !RegInstName.contains("PH2PD")) {
-assert((MemInstName.contains("PD") || MemInstName.contains("F64")) &&
-   "Unmatched names for broadcast");
-Result.BroadcastKind = X86FoldTableEntry::BCAST_SD;
-  } else if (RegInstName.contains("PH")) {
-assert(MemInstName.contains("PH") && "Unmatched names for broadcast");
-Result.BroadcastKind = X86FoldTableEntry::BCAST_SH;
-  } else {
-errs() << RegInstName << ", " << MemInstName << "\n";
-llvm_unreachable("Name is not canoicalized for broadcast or "
- "ExeDomain is incorrect");
+  DagInit *In = MemInst->TheDef->getValueAsDag("InOperandList");
+  for (unsigned I = 0, E = In->getNumArgs(); I != E; ++I) {
+Result.BroadcastKind =
+
StringSwitch(In->getArg(I)->getAsString())
+.Case("i16mem", X86FoldTableEntry::BCAST_W)
+.Case("i32mem", X86FoldTableEntry::BCAST_D)
+.Case("i64mem", X86FoldTableEntry::BCAST_Q)
+.Case("f16mem", X86FoldTableEntry::BCAST_SH)
+.Case("f32mem", X86FoldTableEntry::BCAST_SS)
+.Case("f64mem", X86FoldTableEntry::BCAST_SD)
+.Default(X86FoldTableEntry::BCAST_NONE);
+if (Result.BroadcastKind != X86FoldTableEntry::BCAST_NONE)
+  break;
   }
+  assert(Result.BroadcastKind != X86Fol

[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79675 (PR #79721)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/79721
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 7fb1186 - Refactor recomputeLiveIns to operate on whole CFG (#79498) (#79641)

2024-02-06 Thread via llvm-branch-commits

Author: Oskar Wirga
Date: 2024-02-06T17:01:01-08:00
New Revision: 7fb11860b05092d8aa071d13a1c40ef4ced0d224

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

LOG: Refactor recomputeLiveIns to operate on whole CFG (#79498) (#79641)

Currently, the way that recomputeLiveIns works is that it will recompute
the livein registers for that MachineBasicBlock but it matters what
order you call recomputeLiveIn which can result in incorrect register
allocations down the line.

Now we do not recompute the entire CFG but we do ensure that the newly
added MBB do reach convergence. This fixes a register allocation bug
introduced in AArch64 stack probing.

(cherry picked from commit ff4636a4ab00b633c15eb3942c26126ceb2662e6)

Added: 


Modified: 
llvm/include/llvm/CodeGen/LivePhysRegs.h
llvm/include/llvm/CodeGen/MachineBasicBlock.h
llvm/lib/CodeGen/BranchFolding.cpp
llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
llvm/lib/Target/PowerPC/PPCExpandAtomicPseudoInsts.cpp
llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
llvm/lib/Target/X86/X86FrameLowering.cpp
llvm/test/CodeGen/SystemZ/branch-folder-hoist-livein.mir
llvm/test/CodeGen/Thumb2/LowOverheadLoops/spillingmove.mir

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/LivePhysRegs.h 
b/llvm/include/llvm/CodeGen/LivePhysRegs.h
index 76bb34d270a26d..1d40b1cbb0eaa3 100644
--- a/llvm/include/llvm/CodeGen/LivePhysRegs.h
+++ b/llvm/include/llvm/CodeGen/LivePhysRegs.h
@@ -193,11 +193,18 @@ void addLiveIns(MachineBasicBlock &MBB, const 
LivePhysRegs &LiveRegs);
 void computeAndAddLiveIns(LivePhysRegs &LiveRegs,
   MachineBasicBlock &MBB);
 
-/// Convenience function for recomputing live-in's for \p MBB.
-static inline void recomputeLiveIns(MachineBasicBlock &MBB) {
+/// Convenience function for recomputing live-in's for a MBB. Returns true if
+/// any changes were made.
+static inline bool recomputeLiveIns(MachineBasicBlock &MBB) {
   LivePhysRegs LPR;
+  auto oldLiveIns = MBB.getLiveIns();
+
   MBB.clearLiveIns();
   computeAndAddLiveIns(LPR, MBB);
+  MBB.sortUniqueLiveIns();
+
+  auto newLiveIns = MBB.getLiveIns();
+  return oldLiveIns != newLiveIns;
 }
 
 } // end namespace llvm

diff  --git a/llvm/include/llvm/CodeGen/MachineBasicBlock.h 
b/llvm/include/llvm/CodeGen/MachineBasicBlock.h
index c84fd281c6a549..dc2035fa598c46 100644
--- a/llvm/include/llvm/CodeGen/MachineBasicBlock.h
+++ b/llvm/include/llvm/CodeGen/MachineBasicBlock.h
@@ -111,6 +111,10 @@ class MachineBasicBlock
 
 RegisterMaskPair(MCPhysReg PhysReg, LaneBitmask LaneMask)
 : PhysReg(PhysReg), LaneMask(LaneMask) {}
+
+bool operator==(const RegisterMaskPair &other) const {
+  return PhysReg == other.PhysReg && LaneMask == other.LaneMask;
+}
   };
 
 private:
@@ -473,6 +477,8 @@ class MachineBasicBlock
   /// Remove entry from the livein set and return iterator to the next.
   livein_iterator removeLiveIn(livein_iterator I);
 
+  std::vector getLiveIns() const { return LiveIns; }
+
   class liveout_iterator {
   public:
 using iterator_category = std::input_iterator_tag;

diff  --git a/llvm/lib/CodeGen/BranchFolding.cpp 
b/llvm/lib/CodeGen/BranchFolding.cpp
index a9f78358e57b92..ecf7bc30913f51 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -2048,8 +2048,10 @@ bool 
BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) {
   FBB->erase(FBB->begin(), FIB);
 
   if (UpdateLiveIns) {
-recomputeLiveIns(*TBB);
-recomputeLiveIns(*FBB);
+bool anyChange = false;
+do {
+  anyChange = recomputeLiveIns(*TBB) || recomputeLiveIns(*FBB);
+} while (anyChange);
   }
 
   ++NumHoist;

diff  --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
index d55deec9760092..732e787d2a321d 100644
--- a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
@@ -4339,8 +4339,10 @@ AArch64FrameLowering::inlineStackProbeLoopExactMultiple(
   ExitMBB->transferSuccessorsAndUpdatePHIs(&MBB);
   MBB.addSuccessor(LoopMBB);
   // Update liveins.
-  recomputeLiveIns(*LoopMBB);
-  recomputeLiveIns(*ExitMBB);
+  bool anyChange = false;
+  do {
+anyChange = recomputeLiveIns(*ExitMBB) || recomputeLiveIns(*LoopMBB);
+  } while (anyChange);
 
   return ExitMBB->begin();
 }

diff  --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp 
b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
index 13e9d9725cc2ed..9b4bb7c88bc821 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp

[llvm-branch-commits] [llvm] Refactor recomputeLiveIns to operate on whole CFG (#79498) (PR #79641)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/79641
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] [🍒] Unconditionally lower std::string's alignment requirement from 16 to 8 (#68925) (PR #79480)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/79480
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] 5de1bcb - [🍒] Unconditionally lower std::string's alignment requirement from 16 to 8 (#68925) (#79480)

2024-02-06 Thread via llvm-branch-commits

Author: Eric
Date: 2024-02-06T17:01:38-08:00
New Revision: 5de1bcb70db21cfd2c28ef70c67fd1833ce1e6da

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

LOG: [🍒] Unconditionally lower std::string's alignment requirement from 16 to 8 
(#68925) (#79480)

This change saves memory by providing the allocator more freedom to
allocate the most
efficient size class by dropping the alignment requirements for
std::string's
pointer from 16 to 8. This changes the output of std::string::max_size,
which makes it ABI breaking.

That said, the discussion concluded that we don't care about this ABI
break. and would like this change enabled universally.

The ABI break isn't one of layout or "class size", but rather the value
of "max_size()" changes, which in turn changes whether `std::bad_alloc`
or `std::length_error` is thrown for large allocations.

This change is the child of PR #68807, which enabled the change behind
an ABI flag.

Added: 


Modified: 
libcxx/docs/ReleaseNotes/18.rst
libcxx/include/__config
libcxx/include/string

libcxx/test/libcxx/strings/basic.string/string.capacity/allocation_size.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.capacity/max_size.pass.cpp
libcxx/test/std/strings/basic.string/string.capacity/max_size.pass.cpp

Removed: 




diff  --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index 450a6f25d1ea5e..391e0ebc52a428 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -275,11 +275,10 @@ ABI Affecting Changes
   results in an ABI break, however in practice we expect uses of 
``std::projected`` in ABI-sensitive places to be
   extremely rare. Any error resulting from this change should result in a 
link-time error.
 
-- Under the unstable ABI, the internal alignment requirements for heap 
allocations
-  inside ``std::string`` has decreased from 16 to 8. This saves memory since 
string requests fewer additional
-  bytes than it did previously. However, this also changes the return value of 
``std::string::max_size``
-  and can cause code compiled against older libc++ versions but linked at 
runtime to a new version
-  to throw a 
diff erent exception when attempting allocations that are too large
+- The internal alignment requirements for heap allocations inside 
``std::string`` has decreased from 16 to 8. This
+  saves memory since string requests fewer additional bytes than it did 
previously. However, this also changes the
+  return value of ``std::string::max_size`` and can cause code compiled 
against older libc++ versions but linked at
+  runtime to a new version to throw a 
diff erent exception when attempting allocations that are too large
   (``std::bad_alloc`` vs ``std::length_error``).
 
 - The layout of some range adaptors that use the ``movable-box`` 
exposition-only type as an implementation

diff  --git a/libcxx/include/__config b/libcxx/include/__config
index 1b8fc4f7ba15cd..8b2eaf69d17042 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -174,11 +174,6 @@
 // The implementation moved to the header, but we still export the symbols from
 // the dylib for backwards compatibility.
 #define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
-// Save memory by providing the allocator more freedom to allocate the most
-// efficient size class by dropping the alignment requirements for 
std::string's
-// pointer from 16 to 8. This changes the output of std::string::max_size,
-// which makes it ABI breaking
-#define _LIBCPP_ABI_STRING_8_BYTE_ALIGNMENT
 #  elif _LIBCPP_ABI_VERSION == 1
 #if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || 
defined(_LIBCPP_OBJECT_FORMAT_XCOFF))
 // Enable compiling copies of now inline methods into the dylib to support

diff  --git a/libcxx/include/string b/libcxx/include/string
index e97139206d4fa7..ba169c3dbfc9e6 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -1937,12 +1937,7 @@ private:
 return (__s + (__a - 1)) & ~(__a - 1);
   }
   enum {
-__alignment =
-#ifdef _LIBCPP_ABI_STRING_8_BYTE_ALIGNMENT
-8
-#else
-16
-#endif
+__alignment = 8
   };
   static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type 
__recommend(size_type __s) _NOEXCEPT {
 if (__s < __min_cap) {

diff  --git 
a/libcxx/test/libcxx/strings/basic.string/string.capacity/allocation_size.pass.cpp
 
b/libcxx/test/libcxx/strings/basic.string/string.capacity/allocation_size.pass.cpp
index c7df56c815a805..1110e3d3ec568a 100644
--- 
a/libcxx/test/libcxx/strings/basic.string/string.capacity/allocation_size.pass.cpp
+++ 
b/libcxx/test/libcxx/strings/basic.string/string.capacity/allocation_size.pass.cpp
@@ -6,6 +6,8 @@
 //
 
//===--===//
 

[llvm-branch-commits] [clang] 73cd40d - Revert "[SemaCXX] Implement CWG2137 (list-initialization from objects of the same type) (#77768)" in release/18.x (#79400)

2024-02-06 Thread via llvm-branch-commits

Author: alexfh
Date: 2024-02-06T17:02:12-08:00
New Revision: 73cd40db8e861051c3cad61d2e5f192895cb777d

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

LOG: Revert "[SemaCXX] Implement CWG2137 (list-initialization from objects of 
the same type) (#77768)" in release/18.x (#79400)

- Revert "[SemaCXX] Implement CWG2137 (list-initialization from objects
of the same type) (#77768)", see
https://github.com/llvm/llvm-project/pull/77768#issuecomment-1908946696

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ba9b773c7772e..42a6b59026dc4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -234,11 +234,6 @@ C++2c Feature Support
 
 Resolutions to C++ Defect Reports
 ^
-- Implemented `CWG2137 `_ which allows
-  list-initialization from objects of the same type.
-- Implemented `CWG2311 `_: given a prvalue ``e`` of 
object type
-  ``T``, ``T{e}`` will try to resolve an initializer list constructor and will 
use it if successful (CWG2137).
-  Otherwise, if there is no initializer list constructor, the copy will be 
elided as if it was ``T(e)``.
 
 - Implemented `CWG2598 `_ and `CWG2096 
`_,
   making unions (that have either no members or at least one literal member) 
literal types.



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


[llvm-branch-commits] [clang] [libcxx] Revert "[SemaCXX] Implement CWG2137 (list-initialization from objects of the same type) (#77768)" in release/18.x (PR #79400)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/79400
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lldb] 0542e00 - Revert "Support statistics dump summary only mode (#80745)"

2024-02-06 Thread via llvm-branch-commits

Author: Wanyi
Date: 2024-02-06T20:04:15-05:00
New Revision: 0542e00e3a5753fe7e724b2d0e75224f8aa4df1f

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

LOG: Revert "Support statistics dump summary only mode (#80745)"

This reverts commit 2217837c3377c22bffb6c498a732ce4672b8b535.

Added: 


Modified: 
lldb/bindings/headers.swig
lldb/bindings/interfaces.swig
lldb/include/lldb/API/LLDB.h
lldb/include/lldb/API/SBDefines.h
lldb/include/lldb/API/SBTarget.h
lldb/include/lldb/Target/Statistics.h
lldb/include/lldb/Target/Target.h
lldb/include/lldb/lldb-forward.h
lldb/source/API/CMakeLists.txt
lldb/source/API/SBTarget.cpp
lldb/source/Commands/CommandObjectStats.cpp
lldb/source/Commands/Options.td
lldb/source/Target/Statistics.cpp
lldb/source/Target/Target.cpp
lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
lldb/test/API/functionalities/stats_api/main.c

Removed: 
lldb/bindings/interface/SBStatisticsOptionsDocStrings.i
lldb/include/lldb/API/SBStatisticsOptions.h
lldb/source/API/SBStatisticsOptions.cpp



diff  --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig
index e8d0cda288141c..408db90b925f15 100644
--- a/lldb/bindings/headers.swig
+++ b/lldb/bindings/headers.swig
@@ -54,7 +54,6 @@
 #include "lldb/API/SBScriptObject.h"
 #include "lldb/API/SBSection.h"
 #include "lldb/API/SBSourceManager.h"
-#include "lldb/API/SBStatisticsOptions.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/API/SBStringList.h"
 #include "lldb/API/SBStructuredData.h"

diff  --git a/lldb/bindings/interface/SBStatisticsOptionsDocStrings.i 
b/lldb/bindings/interface/SBStatisticsOptionsDocStrings.i
deleted file mode 100644
index f72cf84319e19b..00
--- a/lldb/bindings/interface/SBStatisticsOptionsDocStrings.i
+++ /dev/null
@@ -1,8 +0,0 @@
-%feature("docstring",
-"A container for options to use when dumping statistics."
-) lldb::SBStatisticsOptions;
-
-%feature("docstring", "Sets whether the statistics should only dump a summary."
-) lldb::SBStatisticsOptions::SetSummaryOnly;
-%feature("docstring", "Gets whether the statistics only dump a summary."
-) lldb::SBStatisticsOptions::GetSummaryOnly;

diff  --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
index a31a0b4af1eb6c..9ca479218f621c 100644
--- a/lldb/bindings/interfaces.swig
+++ b/lldb/bindings/interfaces.swig
@@ -56,7 +56,6 @@
 %include "./interface/SBReproducerDocstrings.i"
 %include "./interface/SBSectionDocstrings.i"
 %include "./interface/SBSourceManagerDocstrings.i"
-%include "./interface/SBStatisticsOptionsDocstrings.i"
 %include "./interface/SBStreamDocstrings.i"
 %include "./interface/SBStringListDocstrings.i"
 %include "./interface/SBStructuredDataDocstrings.i"
@@ -132,7 +131,6 @@
 %include "lldb/API/SBScriptObject.h"
 %include "lldb/API/SBSection.h"
 %include "lldb/API/SBSourceManager.h"
-%include "lldb/API/SBStatisticsOptions.h"
 %include "lldb/API/SBStream.h"
 %include "lldb/API/SBStringList.h"
 %include "lldb/API/SBStructuredData.h"

diff  --git a/lldb/include/lldb/API/LLDB.h b/lldb/include/lldb/API/LLDB.h
index c83eb92fcfb30a..f5f1b87a046c2a 100644
--- a/lldb/include/lldb/API/LLDB.h
+++ b/lldb/include/lldb/API/LLDB.h
@@ -56,7 +56,6 @@
 #include "lldb/API/SBReproducer.h"
 #include "lldb/API/SBSection.h"
 #include "lldb/API/SBSourceManager.h"
-#include "lldb/API/SBStatisticsOptions.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/API/SBStringList.h"
 #include "lldb/API/SBStructuredData.h"

diff  --git a/lldb/include/lldb/API/SBDefines.h 
b/lldb/include/lldb/API/SBDefines.h
index 1181920677b46f..92d823fa1dfe25 100644
--- a/lldb/include/lldb/API/SBDefines.h
+++ b/lldb/include/lldb/API/SBDefines.h
@@ -99,7 +99,6 @@ class LLDB_API SBReproducer;
 class LLDB_API SBScriptObject;
 class LLDB_API SBSection;
 class LLDB_API SBSourceManager;
-class LLDB_API SBStatisticsOptions;
 class LLDB_API SBStream;
 class LLDB_API SBStringList;
 class LLDB_API SBStructuredData;

diff  --git a/lldb/include/lldb/API/SBStatisticsOptions.h 
b/lldb/include/lldb/API/SBStatisticsOptions.h
deleted file mode 100644
index 8019ed4315ca21..00
--- a/lldb/include/lldb/API/SBStatisticsOptions.h
+++ /dev/null
@@ -1,36 +0,0 @@
-//===-- SBStatisticsOptions.h ---*- C++ 
-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#ifndef LLDB_API_SBSTATISTICSOPTIONS_H
-#define LLDB_API_SBSTATISTICSOPTIONS_H
-
-#include "lldb/API/SBDefines.h"
-
-namespace lldb {
-
-/// This class handles

[llvm-branch-commits] [clang] PR for llvm/llvm-project#80887 (PR #80903)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/80903

>From 2427c85a1ac967389be92b613925f8a71f443ce3 Mon Sep 17 00:00:00 2001
From: Shafik Yaghmour 
Date: Mon, 5 Feb 2024 14:40:07 -0800
Subject: [PATCH] [Clang][Sema] Fix regression due to missing ambiguity check
 before attempting access check. (#80730)

Previously when fixing ambiguous lookup diagnostics in
cc1b6668c57170cd440d321037ced89d6a61a9cb The change refactored
`LookupResult` to split out diagnosing access and ambiguous lookups. The
call to `getSema().CheckLookupAccess(...)` should have guarded by a
check for isAmbiguous(). This change adds that guard.

Fixes: https://github.com/llvm/llvm-project/issues/80435
(cherry picked from commit a7bc9cb6ffa91ff0ebabc45c0c7263c7c2c3a4de)
---
 clang/include/clang/Sema/Lookup.h |  3 ++-
 .../class.derived/class.member.lookup/p11.cpp | 22 +++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Sema/Lookup.h 
b/clang/include/clang/Sema/Lookup.h
index 9c93bf1e6fb428..2f2f2607a937fe 100644
--- a/clang/include/clang/Sema/Lookup.h
+++ b/clang/include/clang/Sema/Lookup.h
@@ -754,7 +754,8 @@ class LookupResult {
 
 private:
   void diagnoseAccess() {
-if (isClassLookup() && getSema().getLangOpts().AccessControl)
+if (!isAmbiguous() && isClassLookup() &&
+getSema().getLangOpts().AccessControl)
   getSema().CheckLookupAccess(*this);
   }
 
diff --git a/clang/test/CXX/class.derived/class.member.lookup/p11.cpp 
b/clang/test/CXX/class.derived/class.member.lookup/p11.cpp
index e0899b227e69bd..a42febaca3f041 100644
--- a/clang/test/CXX/class.derived/class.member.lookup/p11.cpp
+++ b/clang/test/CXX/class.derived/class.member.lookup/p11.cpp
@@ -23,3 +23,25 @@ struct D: I1, I2, B2 {
 int D::* mpD = &D::i; // expected-error {{non-static member 'i' found in 
multiple base-class subobjects of type 'B1'}}
   }
 };
+
+namespace GH80435 {
+struct A {
+  void *data; // expected-note {{member found by ambiguous name lookup}}
+};
+
+class B {
+  void *data; // expected-note {{member found by ambiguous name lookup}}
+};
+
+struct C : A, B {};
+
+decltype(C().data) x; // expected-error {{member 'data' found in multiple base 
classes of different types}}
+
+struct D { // expected-note {{candidate constructor (the implicit copy 
constructor) not viable: no known conversion from 'C' to 'const D' for 1st 
argument}}
+   // expected-note@-1{{candidate constructor (the implicit move 
constructor) not viable: no known conversion from 'C' to 'D' for 1st argument}}
+  template 
+  D(Container); // expected-note {{candidate template ignored: substitution 
failure [with Container = C]: member 'data' found in multiple base classes of 
different types}}
+};
+
+D y(C{}); // expected-error {{no matching constructor for initialization of 
'D'}}
+}

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


[llvm-branch-commits] [clang] 2427c85 - [Clang][Sema] Fix regression due to missing ambiguity check before attempting access check. (#80730)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

Author: Shafik Yaghmour
Date: 2024-02-06T17:04:46-08:00
New Revision: 2427c85a1ac967389be92b613925f8a71f443ce3

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

LOG: [Clang][Sema] Fix regression due to missing ambiguity check before 
attempting access check. (#80730)

Previously when fixing ambiguous lookup diagnostics in
cc1b6668c57170cd440d321037ced89d6a61a9cb The change refactored
`LookupResult` to split out diagnosing access and ambiguous lookups. The
call to `getSema().CheckLookupAccess(...)` should have guarded by a
check for isAmbiguous(). This change adds that guard.

Fixes: https://github.com/llvm/llvm-project/issues/80435
(cherry picked from commit a7bc9cb6ffa91ff0ebabc45c0c7263c7c2c3a4de)

Added: 


Modified: 
clang/include/clang/Sema/Lookup.h
clang/test/CXX/class.derived/class.member.lookup/p11.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Lookup.h 
b/clang/include/clang/Sema/Lookup.h
index 9c93bf1e6fb42..2f2f2607a937f 100644
--- a/clang/include/clang/Sema/Lookup.h
+++ b/clang/include/clang/Sema/Lookup.h
@@ -754,7 +754,8 @@ class LookupResult {
 
 private:
   void diagnoseAccess() {
-if (isClassLookup() && getSema().getLangOpts().AccessControl)
+if (!isAmbiguous() && isClassLookup() &&
+getSema().getLangOpts().AccessControl)
   getSema().CheckLookupAccess(*this);
   }
 

diff  --git a/clang/test/CXX/class.derived/class.member.lookup/p11.cpp 
b/clang/test/CXX/class.derived/class.member.lookup/p11.cpp
index e0899b227e69b..a42febaca3f04 100644
--- a/clang/test/CXX/class.derived/class.member.lookup/p11.cpp
+++ b/clang/test/CXX/class.derived/class.member.lookup/p11.cpp
@@ -23,3 +23,25 @@ struct D: I1, I2, B2 {
 int D::* mpD = &D::i; // expected-error {{non-static member 'i' found in 
multiple base-class subobjects of type 'B1'}}
   }
 };
+
+namespace GH80435 {
+struct A {
+  void *data; // expected-note {{member found by ambiguous name lookup}}
+};
+
+class B {
+  void *data; // expected-note {{member found by ambiguous name lookup}}
+};
+
+struct C : A, B {};
+
+decltype(C().data) x; // expected-error {{member 'data' found in multiple base 
classes of 
diff erent types}}
+
+struct D { // expected-note {{candidate constructor (the implicit copy 
constructor) not viable: no known conversion from 'C' to 'const D' for 1st 
argument}}
+   // expected-note@-1{{candidate constructor (the implicit move 
constructor) not viable: no known conversion from 'C' to 'D' for 1st argument}}
+  template 
+  D(Container); // expected-note {{candidate template ignored: substitution 
failure [with Container = C]: member 'data' found in multiple base classes of 
diff erent types}}
+};
+
+D y(C{}); // expected-error {{no matching constructor for initialization of 
'D'}}
+}



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


[llvm-branch-commits] [clang] PR for llvm/llvm-project#80887 (PR #80903)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80903
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [Release Notes][FMV] Document support for rcpc3 and mops features. (PR #80152)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80152
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 9eda0ec - [Release Notes][FMV] Document support for rcpc3 and mops features. (#80152)

2024-02-06 Thread via llvm-branch-commits

Author: Alexandros Lamprineas
Date: 2024-02-06T17:11:39-08:00
New Revision: 9eda0ecd556cc332a08cf3d4c0a9bce5cd584e3a

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

LOG: [Release Notes][FMV] Document support for rcpc3 and mops features. (#80152)

Documents support for Load-Acquire RCpc instructions v3 (rcpc3) as well
as Memory Copy and Memory Set Acceleration instructions (mops) when
targeting AArch64.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 42a6b59026dc4..c0c894f9327a8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1167,6 +1167,12 @@ Arm and AArch64 Support
   * Cortex-A720 (cortex-a720).
   * Cortex-X4 (cortex-x4).
 
+- Function Multi Versioning has been extended to support Load-Acquire RCpc
+  instructions v3 (rcpc3) as well as Memory Copy and Memory Set Acceleration
+  instructions (mops) when targeting AArch64. The feature identifiers (in
+  parenthesis) can be used with either of the ``target_version`` and
+  ``target_clones`` attributes.
+
 Android Support
 ^^^
 



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


[llvm-branch-commits] [clang] [llvm] [AArch64] Add some release notes items (PR #79983)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar updated 
https://github.com/llvm/llvm-project/pull/79983

>From d647f6a4754807648dd11480b3e942571a9e1e25 Mon Sep 17 00:00:00 2001
From: Momchil Velikov 
Date: Tue, 30 Jan 2024 11:13:42 +
Subject: [PATCH] [AArch64] Add some release notes items

---
 clang/docs/ReleaseNotes.rst | 5 +
 llvm/docs/ReleaseNotes.rst  | 8 
 2 files changed, 13 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 060bc7669b72a5..ab5fb5aee61a85 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1164,6 +1164,11 @@ Arm and AArch64 Support
   * Cortex-A720 (cortex-a720).
   * Cortex-X4 (cortex-x4).
 
+- Alpha support has been added for SVE2.1 intrinsics.
+
+- Support has been added for `-fstack-clash-protection` and 
`-mstack-probe-size`
+  command line options.
+
 Android Support
 ^^^
 
diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 7b6a3f10d63777..990f5a5f73e847 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -105,6 +105,14 @@ Changes to the AArch64 Backend
   Armv9.0a has the same features enabled as Armv8.5a, with the exception
   of crypto.
 
+* Assembler/disassembler support has been added for 2023 architecture
+  extensions.
+
+* Support has been added for Stack Clash Protection. During function frame
+  creation and dynamic stack allocations, the compiler will issue memory
+  accesses at reguilar intervals so that a guard area at the top of the stack
+  can't be skipped over.
+
 Changes to the AMDGPU Backend
 -
 

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


[llvm-branch-commits] [clang] PR for llvm/llvm-project#78965 (PR #80593)

2024-02-06 Thread Owen Pan via llvm-branch-commits

https://github.com/owenca approved this pull request.


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


[llvm-branch-commits] [clang] PR for llvm/llvm-project#78965 (PR #80593)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/80593

>From 56437aee69e4c86e048787e68ede281aaf7c587d Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Fri, 26 Jan 2024 18:32:03 -0800
Subject: [PATCH] [clang-format] Fix a bug in
 AnnotatingParser::rParenEndsCast() (#79549)

Fixes #78965.

(cherry picked from commit f826f55b2ab68c2515fae751dc2d6ef77f37b172)
---
 clang/lib/Format/TokenAnnotator.cpp   | 2 ++
 clang/unittests/Format/TokenAnnotatorTest.cpp | 5 +
 2 files changed, 7 insertions(+)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 3dbcb50c2e087c..d0c4273cfc7e58 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2488,6 +2488,8 @@ class AnnotatingParser {
 (Tok.Next->Next->is(tok::numeric_constant) || Line.InPPDirective)) {
   return false;
 }
+if (Line.InPPDirective && Tok.Next->is(tok::minus))
+  return false;
 // Search for unexpected tokens.
 for (FormatToken *Prev = Tok.Previous; Prev != Tok.MatchingParen;
  Prev = Prev->Previous) {
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 3dbf504c35ed55..67678c18963b1f 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -611,6 +611,11 @@ TEST_F(TokenAnnotatorTest, UnderstandsCasts) {
   EXPECT_TOKEN(Tokens[13], tok::r_paren, TT_Unknown);
   EXPECT_TOKEN(Tokens[14], tok::star, TT_BinaryOperator);
 
+  Tokens = annotate("#define foo(i) ((i) - bar)");
+  ASSERT_EQ(Tokens.size(), 14u) << Tokens;
+  EXPECT_TOKEN(Tokens[9], tok::r_paren, TT_Unknown);
+  EXPECT_TOKEN(Tokens[10], tok::minus, TT_BinaryOperator);
+
   Tokens = annotate("return (Foo) & 10;");
   ASSERT_EQ(Tokens.size(), 8u) << Tokens;
   EXPECT_TOKEN(Tokens[3], tok::r_paren, TT_Unknown);

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


[llvm-branch-commits] [clang] PR for llvm/llvm-project#78965 (PR #80593)

2024-02-06 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/80593

>From d5e2f0e64809589071e9d14f5cbdd5716525272a Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Fri, 26 Jan 2024 18:32:03 -0800
Subject: [PATCH] [clang-format] Fix a bug in
 AnnotatingParser::rParenEndsCast() (#79549)

Fixes #78965.

(cherry picked from commit f826f55b2ab68c2515fae751dc2d6ef77f37b172)
---
 clang/lib/Format/TokenAnnotator.cpp   | 2 ++
 clang/unittests/Format/TokenAnnotatorTest.cpp | 5 +
 2 files changed, 7 insertions(+)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 3dbcb50c2e087c..d0c4273cfc7e58 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2488,6 +2488,8 @@ class AnnotatingParser {
 (Tok.Next->Next->is(tok::numeric_constant) || Line.InPPDirective)) {
   return false;
 }
+if (Line.InPPDirective && Tok.Next->is(tok::minus))
+  return false;
 // Search for unexpected tokens.
 for (FormatToken *Prev = Tok.Previous; Prev != Tok.MatchingParen;
  Prev = Prev->Previous) {
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 3dbf504c35ed55..67678c18963b1f 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -611,6 +611,11 @@ TEST_F(TokenAnnotatorTest, UnderstandsCasts) {
   EXPECT_TOKEN(Tokens[13], tok::r_paren, TT_Unknown);
   EXPECT_TOKEN(Tokens[14], tok::star, TT_BinaryOperator);
 
+  Tokens = annotate("#define foo(i) ((i) - bar)");
+  ASSERT_EQ(Tokens.size(), 14u) << Tokens;
+  EXPECT_TOKEN(Tokens[9], tok::r_paren, TT_Unknown);
+  EXPECT_TOKEN(Tokens[10], tok::minus, TT_BinaryOperator);
+
   Tokens = annotate("return (Foo) & 10;");
   ASSERT_EQ(Tokens.size(), 8u) << Tokens;
   EXPECT_TOKEN(Tokens[3], tok::r_paren, TT_Unknown);

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


[llvm-branch-commits] [clang] d5e2f0e - [clang-format] Fix a bug in AnnotatingParser::rParenEndsCast() (#79549)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

Author: Owen Pan
Date: 2024-02-06T21:26:58-08:00
New Revision: d5e2f0e64809589071e9d14f5cbdd5716525272a

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

LOG: [clang-format] Fix a bug in AnnotatingParser::rParenEndsCast() (#79549)

Fixes #78965.

(cherry picked from commit f826f55b2ab68c2515fae751dc2d6ef77f37b172)

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 3dbcb50c2e087c..d0c4273cfc7e58 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2488,6 +2488,8 @@ class AnnotatingParser {
 (Tok.Next->Next->is(tok::numeric_constant) || Line.InPPDirective)) {
   return false;
 }
+if (Line.InPPDirective && Tok.Next->is(tok::minus))
+  return false;
 // Search for unexpected tokens.
 for (FormatToken *Prev = Tok.Previous; Prev != Tok.MatchingParen;
  Prev = Prev->Previous) {

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 3dbf504c35ed55..67678c18963b1f 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -611,6 +611,11 @@ TEST_F(TokenAnnotatorTest, UnderstandsCasts) {
   EXPECT_TOKEN(Tokens[13], tok::r_paren, TT_Unknown);
   EXPECT_TOKEN(Tokens[14], tok::star, TT_BinaryOperator);
 
+  Tokens = annotate("#define foo(i) ((i) - bar)");
+  ASSERT_EQ(Tokens.size(), 14u) << Tokens;
+  EXPECT_TOKEN(Tokens[9], tok::r_paren, TT_Unknown);
+  EXPECT_TOKEN(Tokens[10], tok::minus, TT_BinaryOperator);
+
   Tokens = annotate("return (Foo) & 10;");
   ASSERT_EQ(Tokens.size(), 8u) << Tokens;
   EXPECT_TOKEN(Tokens[3], tok::r_paren, TT_Unknown);



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


[llvm-branch-commits] [clang] PR for llvm/llvm-project#78965 (PR #80593)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80593
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] a9a790e - [AArch64] Add some release notes items (#79983)

2024-02-06 Thread via llvm-branch-commits

Author: Momchil Velikov
Date: 2024-02-06T21:29:25-08:00
New Revision: a9a790e0e2a1dd1503944ef4ed038a4203940107

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

LOG: [AArch64] Add some release notes items (#79983)

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
llvm/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c0c894f9327a8..0e4bda7d8f350 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1167,6 +1167,11 @@ Arm and AArch64 Support
   * Cortex-A720 (cortex-a720).
   * Cortex-X4 (cortex-x4).
 
+- Alpha support has been added for SVE2.1 intrinsics.
+
+- Support has been added for `-fstack-clash-protection` and 
`-mstack-probe-size`
+  command line options.
+
 - Function Multi Versioning has been extended to support Load-Acquire RCpc
   instructions v3 (rcpc3) as well as Memory Copy and Memory Set Acceleration
   instructions (mops) when targeting AArch64. The feature identifiers (in

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 2c2d5b2a90a80..82f4a7a15c9c1 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -105,6 +105,14 @@ Changes to the AArch64 Backend
   Armv9.0a has the same features enabled as Armv8.5a, with the exception
   of crypto.
 
+* Assembler/disassembler support has been added for 2023 architecture
+  extensions.
+
+* Support has been added for Stack Clash Protection. During function frame
+  creation and dynamic stack allocations, the compiler will issue memory
+  accesses at reguilar intervals so that a guard area at the top of the stack
+  can't be skipped over.
+
 Changes to the AMDGPU Backend
 -
 



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


[llvm-branch-commits] [clang] [llvm] [AArch64] Add some release notes items (PR #79983)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/79983
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [backport] [C++20] [Modules] Backport the ability to skip ODR checks in GMF (PR #80249)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar updated 
https://github.com/llvm/llvm-project/pull/80249

>From a0e1cc0aefbc879cb2861003e487576e9a6b3c93 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Mon, 29 Jan 2024 11:42:08 +0800
Subject: [PATCH 1/3] [C++20] [Modules] Don't perform ODR checks in GMF

Close https://github.com/llvm/llvm-project/issues/79240.

See the linked issue for details. Given the frequency of issue reporting
about false positive ODR checks (I received private issue reports too),
I'd like to backport this to 18.x too.
---
 clang/docs/ReleaseNotes.rst   |  5 ++
 clang/include/clang/Serialization/ASTReader.h |  4 ++
 clang/lib/Serialization/ASTReader.cpp |  3 ++
 clang/lib/Serialization/ASTReaderDecl.cpp | 37 +
 clang/lib/Serialization/ASTWriter.cpp |  8 ++-
 clang/lib/Serialization/ASTWriterDecl.cpp | 13 +++--
 clang/test/Modules/concept.cppm   | 14 ++---
 clang/test/Modules/no-eager-load.cppm | 53 ---
 clang/test/Modules/polluted-operator.cppm |  8 ++-
 clang/test/Modules/pr76638.cppm   |  6 +--
 10 files changed, 68 insertions(+), 83 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0e4bda7d8f3505..ce94b3e44b955c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -188,6 +188,11 @@ C++20 Feature Support
   This feature is still experimental. Accordingly, 
``__cpp_nontype_template_args`` was not updated.
   However, its support can be tested with 
``__has_extension(cxx_generalized_nttp)``.
 
+- Clang won't perform ODR checks for decls in the global module fragment any
+  more to ease the implementation and improve the user's using experience.
+  This follows the MSVC's behavior.
+  (`#79240 `_).
+
 C++23 Feature Support
 ^
 - Implemented `P0847R7: Deducing this `_. Some 
related core issues were also
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index dd1451bbf2d2c9..ba06ab0cd45097 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -2452,6 +2452,10 @@ class BitsUnpacker {
   uint32_t CurrentBitsIndex = ~0;
 };
 
+inline bool isFromExplicitGMF(const Decl *D) {
+  return D->getOwningModule() && 
D->getOwningModule()->isExplicitGlobalModule();
+}
+
 } // namespace clang
 
 #endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index fecd94e875f671..e91c5fe08a043f 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -9743,6 +9743,9 @@ void ASTReader::finishPendingActions() {
 
 if (!FD->isLateTemplateParsed() &&
 !NonConstDefn->isLateTemplateParsed() &&
+// We only perform ODR checks for decls not in the explicit
+// global module fragment.
+!isFromExplicitGMF(FD) &&
 FD->getODRHash() != NonConstDefn->getODRHash()) {
   if (!isa(FD)) {
 PendingFunctionOdrMergeFailures[FD].push_back(NonConstDefn);
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index a149d82153037f..7697f29b9054b4 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -804,8 +804,10 @@ void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) {
   ED->setScopedUsingClassTag(EnumDeclBits.getNextBit());
   ED->setFixed(EnumDeclBits.getNextBit());
 
-  ED->setHasODRHash(true);
-  ED->ODRHash = Record.readInt();
+  if (!isFromExplicitGMF(ED)) {
+ED->setHasODRHash(true);
+ED->ODRHash = Record.readInt();
+  }
 
   // If this is a definition subject to the ODR, and we already have a
   // definition, merge this one into it.
@@ -827,7 +829,9 @@ void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) {
   Reader.MergedDeclContexts.insert(std::make_pair(ED, OldDef));
   ED->demoteThisDefinitionToDeclaration();
   Reader.mergeDefinitionVisibility(OldDef, ED);
-  if (OldDef->getODRHash() != ED->getODRHash())
+  // We don't want to check the ODR hash value for declarations from global
+  // module fragment.
+  if (!isFromExplicitGMF(ED) && OldDef->getODRHash() != ED->getODRHash())
 Reader.PendingEnumOdrMergeFailures[OldDef].push_back(ED);
 } else {
   OldDef = ED;
@@ -866,6 +870,9 @@ ASTDeclReader::VisitRecordDeclImpl(RecordDecl *RD) {
 
 void ASTDeclReader::VisitRecordDecl(RecordDecl *RD) {
   VisitRecordDeclImpl(RD);
+  // We should only reach here if we're in C/Objective-C. There is no
+  // global module fragment.
+  assert(!isFromExplicitGMF(RD));
   RD->setODRHash(Record.readInt());
 
   // Maintain the invariant of a redeclaration chain containing only
@@ -1094,8 +1101,10 @@ void ASTDeclReader::VisitFunctionDecl

[llvm-branch-commits] [clang] a0e1cc0 - [C++20] [Modules] Don't perform ODR checks in GMF

2024-02-06 Thread Tom Stellard via llvm-branch-commits

Author: Chuanqi Xu
Date: 2024-02-06T21:30:14-08:00
New Revision: a0e1cc0aefbc879cb2861003e487576e9a6b3c93

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

LOG: [C++20] [Modules] Don't perform ODR checks in GMF

Close https://github.com/llvm/llvm-project/issues/79240.

See the linked issue for details. Given the frequency of issue reporting
about false positive ODR checks (I received private issue reports too),
I'd like to backport this to 18.x too.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Serialization/ASTReader.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/Modules/concept.cppm
clang/test/Modules/no-eager-load.cppm
clang/test/Modules/polluted-operator.cppm
clang/test/Modules/pr76638.cppm

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0e4bda7d8f3505..ce94b3e44b955c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -188,6 +188,11 @@ C++20 Feature Support
   This feature is still experimental. Accordingly, 
``__cpp_nontype_template_args`` was not updated.
   However, its support can be tested with 
``__has_extension(cxx_generalized_nttp)``.
 
+- Clang won't perform ODR checks for decls in the global module fragment any
+  more to ease the implementation and improve the user's using experience.
+  This follows the MSVC's behavior.
+  (`#79240 `_).
+
 C++23 Feature Support
 ^
 - Implemented `P0847R7: Deducing this `_. Some 
related core issues were also

diff  --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index dd1451bbf2d2c9..ba06ab0cd45097 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -2452,6 +2452,10 @@ class BitsUnpacker {
   uint32_t CurrentBitsIndex = ~0;
 };
 
+inline bool isFromExplicitGMF(const Decl *D) {
+  return D->getOwningModule() && 
D->getOwningModule()->isExplicitGlobalModule();
+}
+
 } // namespace clang
 
 #endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index fecd94e875f671..e91c5fe08a043f 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -9743,6 +9743,9 @@ void ASTReader::finishPendingActions() {
 
 if (!FD->isLateTemplateParsed() &&
 !NonConstDefn->isLateTemplateParsed() &&
+// We only perform ODR checks for decls not in the explicit
+// global module fragment.
+!isFromExplicitGMF(FD) &&
 FD->getODRHash() != NonConstDefn->getODRHash()) {
   if (!isa(FD)) {
 PendingFunctionOdrMergeFailures[FD].push_back(NonConstDefn);

diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index a149d82153037f..7697f29b9054b4 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -804,8 +804,10 @@ void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) {
   ED->setScopedUsingClassTag(EnumDeclBits.getNextBit());
   ED->setFixed(EnumDeclBits.getNextBit());
 
-  ED->setHasODRHash(true);
-  ED->ODRHash = Record.readInt();
+  if (!isFromExplicitGMF(ED)) {
+ED->setHasODRHash(true);
+ED->ODRHash = Record.readInt();
+  }
 
   // If this is a definition subject to the ODR, and we already have a
   // definition, merge this one into it.
@@ -827,7 +829,9 @@ void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) {
   Reader.MergedDeclContexts.insert(std::make_pair(ED, OldDef));
   ED->demoteThisDefinitionToDeclaration();
   Reader.mergeDefinitionVisibility(OldDef, ED);
-  if (OldDef->getODRHash() != ED->getODRHash())
+  // We don't want to check the ODR hash value for declarations from global
+  // module fragment.
+  if (!isFromExplicitGMF(ED) && OldDef->getODRHash() != ED->getODRHash())
 Reader.PendingEnumOdrMergeFailures[OldDef].push_back(ED);
 } else {
   OldDef = ED;
@@ -866,6 +870,9 @@ ASTDeclReader::VisitRecordDeclImpl(RecordDecl *RD) {
 
 void ASTDeclReader::VisitRecordDecl(RecordDecl *RD) {
   VisitRecordDeclImpl(RD);
+  // We should only reach here if we're in C/Objective-C. There is no
+  // global module fragment.
+  assert(!isFromExplicitGMF(RD));
   RD->setODRHash(Record.readInt());
 
   // Maintain the invariant of a redeclaration chain containing only
@@ -1094,8 +1101,10 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
   if (F

[llvm-branch-commits] [clang] 70195e0 - [C++20] [Modules] Remove previous workaround for odr hashing enums

2024-02-06 Thread Tom Stellard via llvm-branch-commits

Author: Chuanqi Xu
Date: 2024-02-06T21:30:14-08:00
New Revision: 70195e0d67080c2d0d1f321db69ebb40042a1c7a

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

LOG: [C++20] [Modules] Remove previous workaround for odr hashing enums

Previosly we land
https://github.com/llvm/llvm-project/commit/085eae6b863881fb9fda323e5b672b04a00ed19e
to workaround the false positive ODR violations in
https://github.com/llvm/llvm-project/issues/76638.

However, we decided to not perform ODR checks for decls from GMF in
https://github.com/llvm/llvm-project/issues/79240 and we land the
corresponding change. So we should be able to remove the workaround now.

The original tests get remained.

Added: 
clang/test/Modules/cxx20-modules-enum-odr.cppm

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/AST/ODRHash.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ce94b3e44b955..d335be78a499b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1041,9 +1041,6 @@ Bug Fixes to C++ Support
   in 
diff erent visibility.
   Fixes (`#67893 `_)
 
-- Fix a false-positive ODR violation for 
diff erent definitions for `std::align_val_t`.
-  Fixes (`#76638 `_)
-
 - Remove recorded `#pragma once` state for headers included in named modules.
   Fixes (`#77995 `_)
 

diff  --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp
index 5b98646a1e8dc..2dbc259138a89 100644
--- a/clang/lib/AST/ODRHash.cpp
+++ b/clang/lib/AST/ODRHash.cpp
@@ -745,55 +745,8 @@ void ODRHash::AddEnumDecl(const EnumDecl *Enum) {
   if (Enum->isScoped())
 AddBoolean(Enum->isScopedUsingClassTag());
 
-  if (Enum->getIntegerTypeSourceInfo()) {
-// FIMXE: This allows two enums with 
diff erent spellings to have the same
-// hash.
-//
-//  // mod1.cppm
-//  module;
-//  extern "C" {
-//  typedef unsigned __int64 size_t;
-//  }
-//  namespace std {
-//  using :: size_t;
-//  }
-//
-//  extern "C++" {
-//  namespace std {
-//  enum class align_val_t : std::size_t {};
-//  }
-//  }
-//
-//  export module mod1;
-//  export using std::align_val_t;
-//
-//  // mod2.cppm
-//  module;
-//  extern "C" {
-//  typedef unsigned __int64 size_t;
-//  }
-//
-//  extern "C++" {
-//  namespace std {
-//  enum class align_val_t : size_t {};
-//  }
-//  }
-//
-//  export module mod2;
-//  import mod1;
-//  export using std::align_val_t;
-//
-// The above example should be disallowed since it violates
-// [basic.def.odr]p14:
-//
-//Each such definition shall consist of the same sequence of tokens
-//
-// The definitions of `std::align_val_t` in two module units have 
diff erent
-// spellings but we failed to give an error here.
-//
-// See https://github.com/llvm/llvm-project/issues/76638 for details.
+  if (Enum->getIntegerTypeSourceInfo())
 AddQualType(Enum->getIntegerType().getCanonicalType());
-  }
 
   // Filter out sub-Decls which will not be processed in order to get an
   // accurate count of Decl's.

diff  --git a/clang/test/Modules/cxx20-modules-enum-odr.cppm 
b/clang/test/Modules/cxx20-modules-enum-odr.cppm
new file mode 100644
index 0..831c01143a27b
--- /dev/null
+++ b/clang/test/Modules/cxx20-modules-enum-odr.cppm
@@ -0,0 +1,51 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/mod1.cppm -emit-module-interface -o 
%t/mod1.pcm
+// RUN: %clang_cc1 -std=c++20 %t/mod2.cppm -emit-module-interface -o 
%t/mod2.pcm
+// RUN: %clang_cc1 -std=c++20 %t/test.cpp -fprebuilt-module-path=%t -verify 
-fsyntax-only
+
+//--- size_t.h
+
+extern "C" {
+typedef unsigned int size_t;
+}
+
+//--- csize_t
+namespace std {
+using :: size_t;
+}
+
+//--- align.h
+namespace std {
+enum class align_val_t : size_t {};
+}
+
+//--- mod1.cppm
+module;
+#include "size_t.h"
+#include "align.h"
+export module mod1;
+namespace std {
+export using std::align_val_t;
+}
+
+//--- mod2.cppm
+module;
+#include "size_t.h"
+#include "csize_t"
+#include "align.h"
+export module mod2;
+namespace std {
+export using std::align_val_t;
+}
+
+//--- test.cpp
+// expected-no-diagnostics
+import mod1;
+import mod2;
+void test() {
+std::align_val_t v;
+}
+



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


[llvm-branch-commits] [clang] [backport] [C++20] [Modules] Backport the ability to skip ODR checks in GMF (PR #80249)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80249
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] c6c8696 - [C++20] [Modules] Introduce -fskip-odr-check-in-gmf (#79959)

2024-02-06 Thread Tom Stellard via llvm-branch-commits

Author: Chuanqi Xu
Date: 2024-02-06T21:30:14-08:00
New Revision: c6c86965d967886ca5a2ed8968c949cd42cdd49a

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

LOG: [C++20] [Modules] Introduce -fskip-odr-check-in-gmf (#79959)

Close https://github.com/llvm/llvm-project/issues/79240

Cite the comment from @mizvekov in
//github.com/llvm/llvm-project/issues/79240:

> There are two kinds of bugs / issues relevant here:
>
> Clang bugs that this change hides
> Here we can add a Frontend flag that disables the GMF ODR check, just
> so
> we can keep tracking, testing and fixing these issues.
> The Driver would just always pass that flag.
> We could add that flag in this current issue.
> Bugs in user code:
> I don't think it's worth adding a corresponding Driver flag for
> controlling the above Frontend flag, since we intend it's behavior to
> become default as we fix the problems, and users interested in testing
> the more strict behavior can just use the Frontend flag directly.

This patch follows the suggestion:
- Introduce the CC1 flag `-fskip-odr-check-in-gmf` which is by default
off, so that the every existing test will still be tested with checking
ODR violations.
- Passing `-fskip-odr-check-in-gmf` in the driver to keep the behavior
we intended.
- Edit the document to tell the users who are still interested in more
strict checks can use `-Xclang -fno-skip-odr-check-in-gmf` to get the
existing behavior.

Added: 
clang/test/Driver/modules-skip-odr-check-in-gmf.cpp
clang/test/Modules/skip-odr-check-in-gmf.cppm

Modified: 
clang/docs/ReleaseNotes.rst
clang/docs/StandardCPlusPlusModules.rst
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/include/clang/Serialization/ASTReader.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/Modules/concept.cppm
clang/test/Modules/polluted-operator.cppm
clang/test/Modules/pr76638.cppm

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d335be78a499b9..b05c72c7f2c3eb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -190,7 +190,8 @@ C++20 Feature Support
 
 - Clang won't perform ODR checks for decls in the global module fragment any
   more to ease the implementation and improve the user's using experience.
-  This follows the MSVC's behavior.
+  This follows the MSVC's behavior. Users interested in testing the more strict
+  behavior can use the flag '-Xclang -fno-skip-odr-check-in-gmf'.
   (`#79240 `_).
 
 C++23 Feature Support

diff  --git a/clang/docs/StandardCPlusPlusModules.rst 
b/clang/docs/StandardCPlusPlusModules.rst
index 81043ff25be02e..0f85065f464a8f 100644
--- a/clang/docs/StandardCPlusPlusModules.rst
+++ b/clang/docs/StandardCPlusPlusModules.rst
@@ -457,6 +457,29 @@ Note that **currently** the compiler doesn't consider 
inconsistent macro definit
 Currently Clang would accept the above example. But it may produce surprising 
results if the
 debugging code depends on consistent use of ``NDEBUG`` also in other 
translation units.
 
+Definitions consistency
+^^^
+
+The C++ language defines that same declarations in 
diff erent translation units should have
+the same definition, as known as ODR (One Definition Rule). Prior to modules, 
the translation
+units don't dependent on each other and the compiler itself can't perform a 
strong
+ODR violation check. With the introduction of modules, now the compiler have
+the chance to perform ODR violations with language semantics across 
translation units.
+
+However, in the practice, we found the existing ODR checking mechanism is not 
stable
+enough. Many people suffers from the false positive ODR violation diagnostics, 
AKA,
+the compiler are complaining two identical declarations have 
diff erent definitions
+incorrectly. Also the true positive ODR violations are rarely reported.
+Also we learned that MSVC don't perform ODR check for declarations in the 
global module
+fragment.
+
+So in order to get better user experience, save the time checking ODR and keep 
consistent
+behavior with MSVC, we disabled the ODR check for the declarations in the 
global module
+fragment by default. Users who want more strict check can still use the
+``-Xclang -fno-skip-odr-check-in-gmf`` flag to get the ODR check enabled. It 
is also
+encouraged to report issues if users find false positive ODR violations or 
false negative ODR
+violations with the flag enabled.
+
 ABI Impacts
 ---
 

diff  --git a/clang/include/clang/Basic/La

[llvm-branch-commits] [Clang][RISCV] Refactor builtins to TableGen (PR #80280)

2024-02-06 Thread Wang Pengcheng via llvm-branch-commits

wangpc-pp wrote:

Ping.

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


  1   2   >