[llvm-branch-commits] [clang-tools-extra] 7d1982f - Revert "[c++20] P1907R1: Support for generalized non-type template arguments of scalar type."

2024-01-24 Thread via llvm-branch-commits

Author: Erich Keane
Date: 2024-01-24T07:11:33-08:00
New Revision: 7d1982f62bfc9ec897d8dc8837100c6c2f2de156

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

LOG: Revert "[c++20] P1907R1: Support for generalized non-type template 
arguments of scalar type."

Added: 


Modified: 
clang-tools-extra/clangd/DumpAST.cpp
clang-tools-extra/clangd/FindTarget.cpp
clang/include/clang/AST/ODRHash.h
clang/include/clang/AST/PropertiesBase.td
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/AST/TemplateArgumentVisitor.h
clang/include/clang/AST/TemplateBase.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/AST/ODRHash.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/AST/TemplateBase.cpp
clang/lib/AST/TypeLoc.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/Index/USRGeneration.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateVariadic.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/CXX/drs/dr18xx.cpp
clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
clang/test/CodeGenCXX/mangle-ms-templates.cpp
clang/test/CodeGenCXX/mangle-template.cpp
clang/test/Modules/odr_hash.cpp
clang/test/SemaCXX/warn-bool-conversion.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CXCursor.cpp
clang/www/cxx_status.html
lldb/include/lldb/lldb-enumerations.h
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 
clang/test/CodeGenCXX/template-arguments.cpp
clang/test/Index/USR/structural-value-tpl-arg.cpp



diff  --git a/clang-tools-extra/clangd/DumpAST.cpp 
b/clang-tools-extra/clangd/DumpAST.cpp
index 9a525efb938e8d5..b0cec65c39fa31d 100644
--- a/clang-tools-extra/clangd/DumpAST.cpp
+++ b/clang-tools-extra/clangd/DumpAST.cpp
@@ -143,7 +143,6 @@ class DumpVisitor : public RecursiveASTVisitor 
{
   TEMPLATE_ARGUMENT_KIND(Declaration);
   TEMPLATE_ARGUMENT_KIND(Template);
   TEMPLATE_ARGUMENT_KIND(TemplateExpansion);
-  TEMPLATE_ARGUMENT_KIND(StructuralValue);
 #undef TEMPLATE_ARGUMENT_KIND
 }
 llvm_unreachable("Unhandled ArgKind enum");

diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index e702c6b3537a098..3d73e77b16aff4e 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -1039,7 +1039,6 @@ class ExplicitReferenceCollector
 case TemplateArgument::Pack:
 case TemplateArgument::Type:
 case TemplateArgument::Expression:
-case TemplateArgument::StructuralValue:
   break; // Handled by VisitType and VisitExpression.
 };
 return RecursiveASTVisitor::TraverseTemplateArgumentLoc(A);

diff  --git a/clang/include/clang/AST/ODRHash.h 
b/clang/include/clang/AST/ODRHash.h
index a1caa6d39a87c3c..cedf644520fc320 100644
--- a/clang/include/clang/AST/ODRHash.h
+++ b/clang/include/clang/AST/ODRHash.h
@@ -25,7 +25,6 @@
 
 namespace clang {
 
-class APValue;
 class Decl;
 class IdentifierInfo;
 class NestedNameSpecifier;
@@ -102,8 +101,6 @@ class ODRHash {
   // Save booleans until the end to lower the size of data to process.
   void AddBoolean(bool value);
 
-  void AddStructuralValue(const APValue &);
-
   static bool isSubDeclToBeProcessed(const Decl *D, const DeclContext *Parent);
 
 private:

diff  --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index 0270c086d06b6ad..d86c4eba6a22511 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -808,20 +808,6 @@ let Class = PropertyTypeCase 
in {
 return TemplateArgument(ctx, value, type, isDefaulted);
   }]>;
 }
-let Class = PropertyTypeCase in {
-  def : Property<"value", APValue> {
-let Read = [{ node.getAsStructuralValue() }];
-  }
-  def : Property<"type", QualType> {
-let Read = [{ node.getStructuralValueType() }];
-  }
-  def : Property<"isDefaulted", Bool> {
-let Read = [{ node.getIsDefaulted() }];
-  }
-  def : Creator<[{
-return TemplateArgument(ctx, type, value, isDefaulted);
-  }]>;
-}
 let Class = PropertyTypeCase in {
  

[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79253 (PR #79323)

2024-01-24 Thread via llvm-branch-commits

https://github.com/github-actions[bot] created 
https://github.com/llvm/llvm-project/pull/79323

resolves llvm/llvm-project#79253

>From f64342ff287483b98a7739b7ec44236a362ed43f Mon Sep 17 00:00:00 2001
From: Weining Lu 
Date: Wed, 24 Jan 2024 11:03:14 +0800
Subject: [PATCH] [test] Update dwarf-loongarch-relocs.ll

Address buildbot faiures:
http://45.33.8.238/macm1/77360/step_11.txt
http://45.33.8.238/linux/128902/step_12.txt

(cherry picked from commit baba7e4175b6ca21e83b1cf8229f29dbba02e979)
---
 .../LoongArch/dwarf-loongarch-relocs.ll   | 37 ---
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/llvm/test/DebugInfo/LoongArch/dwarf-loongarch-relocs.ll 
b/llvm/test/DebugInfo/LoongArch/dwarf-loongarch-relocs.ll
index e03b4c1d34de157..07443a62b93391b 100644
--- a/llvm/test/DebugInfo/LoongArch/dwarf-loongarch-relocs.ll
+++ b/llvm/test/DebugInfo/LoongArch/dwarf-loongarch-relocs.ll
@@ -1,19 +1,22 @@
 ; RUN: llc --filetype=obj --mtriple=loongarch64 --mattr=-relax %s -o %t.o
 ; RUN: llvm-readobj -r %t.o | FileCheck 
--check-prefixes=RELOCS-BOTH,RELOCS-NORL %s
-; RUN: llvm-objdump --source %t.o | FileCheck --check-prefix=SOURCE %s
-; RUN: llvm-dwarfdump --debug-info --debug-line %t.o | FileCheck 
--check-prefix=DWARF %s
+; RUN: llvm-objdump --source %t.o | FileCheck 
--check-prefixes=SOURCE,SOURCE-NORL %s
+; RUN: llvm-dwarfdump --debug-info --debug-line %t.o | FileCheck 
--check-prefixes=DWARF,DWARF-NORL %s
 
 ; RUN: llc --filetype=obj --mtriple=loongarch64 --mattr=+relax %s -o %t.r.o
 ; RUN: llvm-readobj -r %t.r.o | FileCheck 
--check-prefixes=RELOCS-BOTH,RELOCS-ENRL %s
-; RUN: llvm-objdump --source %t.r.o | FileCheck --check-prefix=SOURCE %s
-; RUN: llvm-dwarfdump --debug-info --debug-line %t.r.o | FileCheck 
--check-prefix=DWARF %s
+; RUN: llvm-objdump --source %t.r.o | FileCheck 
--check-prefixes=SOURCE,SOURCE-ENRL %s
+; RUN: llvm-dwarfdump --debug-info --debug-line %t.r.o | FileCheck 
--check-prefixes=DWARF,DWARF-ENRL %s
 
 ; RELOCS-BOTH:   Relocations [
 ; RELOCS-BOTH-NEXT:Section ({{.*}}) .rela.text {
-; RELOCS-BOTH-NEXT:  0x14 R_LARCH_PCALA_HI20 sym 0x0
-; RELOCS-ENRL-NEXT:  0x14 R_LARCH_RELAX - 0x0
-; RELOCS-BOTH-NEXT:  0x18 R_LARCH_PCALA_LO12 sym 0x0
-; RELOCS-ENRL-NEXT:  0x18 R_LARCH_RELAX - 0x0
+; RELOCS-NORL-NEXT:  0x14 R_LARCH_PCALA_HI20 sym 0x0
+; RELOCS-NORL-NEXT:  0x18 R_LARCH_PCALA_LO12 sym 0x0
+; RELOCS-ENRL-NEXT:  0x0 R_LARCH_ALIGN .Lla-relax-align0 0x5
+; RELOCS-ENRL-NEXT:  0x30 R_LARCH_PCALA_HI20 sym 0x0
+; RELOCS-ENRL-NEXT:  0x30 R_LARCH_RELAX - 0x0
+; RELOCS-ENRL-NEXT:  0x34 R_LARCH_PCALA_LO12 sym 0x0
+; RELOCS-ENRL-NEXT:  0x34 R_LARCH_RELAX - 0x0
 ; RELOCS-BOTH-NEXT:}
 ; RELOCS-BOTH: Section ({{.*}}) .rela.debug_frame {
 ; RELOCS-NORL-NEXT:  0x1C R_LARCH_32 .debug_frame 0x0
@@ -36,7 +39,8 @@
 ; RELOCS-BOTH-NEXT:}
 ; RELOCS-BOTH-NEXT:  ]
 
-; SOURCE:   :
+; SOURCE-NORL:   :
+; SOURCE-ENRL:  001c :
 ; SOURCE:  ; {
 ; SOURCE:  ;   asm volatile(
 ; SOURCE:  ;   return 0;
@@ -87,11 +91,16 @@
 ; DWARF-EMPTY:
 ; DWARF-NEXT:  AddressLine   Column File   ISA Discriminator 
OpIndex Flags
 ; DWARF-NEXT:  -- -- -- -- --- - 
--- -
-; DWARF-NEXT:  0x  2  0  0   0 0   
0  is_stmt
-; DWARF-NEXT:  0x0010  3  3  0   0 0   
0  is_stmt prologue_end
-; DWARF-NEXT:  0x0020 10  3  0   0 0   
0  is_stmt
-; DWARF-NEXT:  0x002c 10  3  0   0 0   
0  epilogue_begin
-; DWARF-NEXT:  0x0034 10  3  0   0 0   
0  end_sequence
+; DWARF-NORL-NEXT:  0x  2  0  0   0 0  
 0  is_stmt
+; DWARF-NORL-NEXT:  0x0010  3  3  0   0 0  
 0  is_stmt prologue_end
+; DWARF-NORL-NEXT:  0x0020 10  3  0   0 0  
 0  is_stmt
+; DWARF-NORL-NEXT:  0x002c 10  3  0   0 0  
 0  epilogue_begin
+; DWARF-NORL-NEXT:  0x0034 10  3  0   0 0  
 0  end_sequence
+; DWARF-ENRL-NEXT:  0x001c  2  0  0   0 0  
 0  is_stmt
+; DWARF-ENRL-NEXT:  0x002c  3  3  0   0 0  
 0  is_stmt prologue_end
+; DWARF-ENRL-NEXT:  0x003c 10  3  0   0 0  
 0  is_stmt
+; DWARF-ENRL-NEXT:  0x0048 10  3  0   0 0  
 0  epilogue_begin
+; DWARF-ENRL-NEXT:  0x0050 10  3  0   0 0  
 0  end_sequence
 
 ; ModuleID = 'dwarf-loongarch-relocs.c'
 source_filename = "dwarf-loongarch-relocs.c"

___
llvm-branch-commits mailing list
llvm-branch

[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79253 (PR #79323)

2024-01-24 Thread via llvm-branch-commits

https://github.com/github-actions[bot] milestoned 
https://github.com/llvm/llvm-project/pull/79323
___
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#79277 (PR #79340)

2024-01-24 Thread via llvm-branch-commits

https://github.com/github-actions[bot] milestoned 
https://github.com/llvm/llvm-project/pull/79340
___
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#79277 (PR #79340)

2024-01-24 Thread via llvm-branch-commits

github-actions[bot] wrote:

@mariusz-sikora-at-amd What do you think about merging this PR to the release 
branch?

https://github.com/llvm/llvm-project/pull/79340
___
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#79279 (PR #79341)

2024-01-24 Thread via llvm-branch-commits

https://github.com/github-actions[bot] created 
https://github.com/llvm/llvm-project/pull/79341

resolves llvm/llvm-project#79279

>From 85063b024a4fafcfbdf78737cae3b7def1ade11a Mon Sep 17 00:00:00 2001
From: Shengchen Kan 
Date: Wed, 24 Jan 2024 17:10:28 +0800
Subject: [PATCH] [X86][CodeGen] Fix crash when commute operands of Instruction
 for code size (#79245)

Reported in 134fcc62786d31ab73439201dce2d73808d1785a

Incorrect opcode is used  b/c there is a `[[fallthrough]]` at line 2386.

(cherry picked from commit 33ecef9812e2c9bfadef035b8e34a949acae2abc)
---
 llvm/lib/Target/X86/X86InstrInfo.cpp| 35 +
 llvm/test/CodeGen/X86/commute-blend-avx2.ll |  9 ++
 2 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp 
b/llvm/lib/Target/X86/X86InstrInfo.cpp
index d6f9aa6d6acec09..9ac1f783b7f0a19 100644
--- a/llvm/lib/Target/X86/X86InstrInfo.cpp
+++ b/llvm/lib/Target/X86/X86InstrInfo.cpp
@@ -2354,33 +2354,26 @@ MachineInstr 
*X86InstrInfo::commuteInstructionImpl(MachineInstr &MI, bool NewMI,
   case X86::VBLENDPSrri:
 // If we're optimizing for size, try to use MOVSD/MOVSS.
 if (MI.getParent()->getParent()->getFunction().hasOptSize()) {
-  unsigned Mask;
-  switch (Opc) {
-  default:
-llvm_unreachable("Unreachable!");
-  case X86::BLENDPDrri:
-Opc = X86::MOVSDrr;
-Mask = 0x03;
-break;
-  case X86::BLENDPSrri:
-Opc = X86::MOVSSrr;
-Mask = 0x0F;
-break;
-  case X86::VBLENDPDrri:
-Opc = X86::VMOVSDrr;
-Mask = 0x03;
-break;
-  case X86::VBLENDPSrri:
-Opc = X86::VMOVSSrr;
-Mask = 0x0F;
-break;
-  }
+  unsigned Mask = (Opc == X86::BLENDPDrri || Opc == X86::VBLENDPDrri) ? 
0x03: 0x0F;
   if ((MI.getOperand(3).getImm() ^ Mask) == 1) {
+#define FROM_TO(FROM, TO)  
\
+  case X86::FROM:  
\
+Opc = X86::TO; 
\
+break;
+switch (Opc) {
+default:
+  llvm_unreachable("Unreachable!");
+FROM_TO(BLENDPDrri, MOVSDrr)
+FROM_TO(BLENDPSrri, MOVSSrr)
+FROM_TO(VBLENDPDrri, VMOVSDrr)
+FROM_TO(VBLENDPSrri, VMOVSSrr)
+}
 WorkingMI = CloneIfNew(MI);
 WorkingMI->setDesc(get(Opc));
 WorkingMI->removeOperand(3);
 break;
   }
+#undef FROM_TO
 }
 [[fallthrough]];
   case X86::PBLENDWrri:
diff --git a/llvm/test/CodeGen/X86/commute-blend-avx2.ll 
b/llvm/test/CodeGen/X86/commute-blend-avx2.ll
index b5ffe78d29a610d..75511104580e903 100644
--- a/llvm/test/CodeGen/X86/commute-blend-avx2.ll
+++ b/llvm/test/CodeGen/X86/commute-blend-avx2.ll
@@ -88,3 +88,12 @@ define <4 x double> @commute_fold_vblendpd_256(<4 x double> 
%a, ptr %b) #0 {
   ret <4 x double> %2
 }
 declare <4 x double> @llvm.x86.avx.blend.pd.256(<4 x double>, <4 x double>, 
i8) nounwind readnone
+
+define <4 x float> @commute_vblendpd_128_for_code_size(<4 x float> %a, <4 x 
float> %b) optsize {
+; CHECK-LABEL: commute_vblendpd_128_for_code_size:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:vblendps {{.*#+}} xmm0 = xmm1[0],xmm0[1],xmm1[2,3]
+; CHECK-NEXT:retq
+  %r = shufflevector <4 x float> %b, <4 x float> %a, <4 x i32> 
+  ret <4 x float> %r
+}

___
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#79279 (PR #79341)

2024-01-24 Thread via llvm-branch-commits

https://github.com/github-actions[bot] milestoned 
https://github.com/llvm/llvm-project/pull/79341
___
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#79279 (PR #79341)

2024-01-24 Thread via llvm-branch-commits

github-actions[bot] wrote:

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

https://github.com/llvm/llvm-project/pull/79341
___
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] [compiler-rt] [NFC]Precommit test case to show function summary and global values when a function has instructions annotated with vtable profiles and indirect call profile

2024-01-24 Thread Mingming Liu via llvm-branch-commits

https://github.com/minglotus-6 ready_for_review 
https://github.com/llvm/llvm-project/pull/79233
___
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] [compiler-rt] [ThinLTO][TypeProfiling]Add annotated vtable GUID as referenced variables in per function summary, and update bitcode writer to create value-ids for these re

2024-01-24 Thread Mingming Liu via llvm-branch-commits

minglotus-6 wrote:

Hi, 
  Sorry for the message but I'm about to re-create a new PR for review with 
shorter title name, so that branch name is shorter.

  I get a message that the length branch name (thereby length file names) 
causes some build-bot failures on Windows where there is a 256-character 
filename length limit (they are fixing the bot to not fetch from branch 
`users//spr` meanwhile).  p.s. I just filed a [feature request 
to `spr`](https://github.com/getcord/spr/issues/186) to support explicit 
specification of branch name.

https://github.com/llvm/llvm-project/pull/79234
___
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#79339 (PR #79357)

2024-01-24 Thread via llvm-branch-commits

https://github.com/github-actions[bot] milestoned 
https://github.com/llvm/llvm-project/pull/79357
___
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#79339 (PR #79357)

2024-01-24 Thread via llvm-branch-commits

github-actions[bot] wrote:

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

https://github.com/llvm/llvm-project/pull/79357
___
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#79339 (PR #79357)

2024-01-24 Thread via llvm-branch-commits

https://github.com/github-actions[bot] created 
https://github.com/llvm/llvm-project/pull/79357

resolves llvm/llvm-project#79339

>From 386e80ad4afb1a5231e54ce8c9eb9d848f973538 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Wed, 24 Jan 2024 08:53:36 -0800
Subject: [PATCH] [ELF] Don't resolve relocations referencing SHN_ABS to
 tombstone in non-SHF_ALLOC sections (#79238)

A SHN_ABS symbol has never been considered for
InputSection::relocateNonAlloc.
Before #74686, the code did made it work in the absence of `-z
dead-reloc-in-nonalloc=`.
There is now a report about such SHN_ABS uses

(https://github.com/llvm/llvm-project/pull/74686#issuecomment-1904101711)
and I think it makes sense for non-SHF_ALLOC to support SHN_ABS, like
SHF_ALLOC sections do.

```
// clang -g
__attribute__((weak)) int symbol;
int *foo() { return &symbol; }

0x0023:   DW_TAG_variable [2]   (0x000c)
...
DW_AT_location [DW_FORM_exprloc](DW_OP_addrx 0x0)

```

.debug_addr references `symbol`, which can be redefined by a symbol
assignment or --defsym to become a SHN_ABS symbol.

The problem is that `!sym.getOutputSection()` cannot discern SHN_ABS
from a symbol whose section has been discarded. Since commit
1981b1b6b92f7579a30c9ed32dbdf3bc749c1b40, a symbol relative to a
discarded section is changed to `Undefined`, so the `SHN_ABS` check
become trivial.

We currently apply tombstone for a relocation referencing
`SharedSymbol`. This patch does not change the behavior.

(cherry picked from commit 8abf8d124ae346016c56209de7f57b85671d4367)
---
 lld/ELF/InputSection.cpp  | 13 ++---
 lld/test/ELF/dead-reloc-in-nonalloc.s |  2 +-
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index c728dd6c6306aa..0e0b9783bd88a0 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -961,12 +961,11 @@ void InputSection::relocateNonAlloc(uint8_t *buf, 
ArrayRef rels) {
   // vector. The computed value is st_value plus a non-negative offset.
   // Negative values are invalid, so -1 can be used as the tombstone value.
   //
-  // If the referenced symbol is discarded (made Undefined), or the
-  // section defining the referenced symbol is garbage collected,
-  // sym.getOutputSection() is nullptr. `ds->folded` catches the ICF folded
-  // case. However, resolving a relocation in .debug_line to -1 would stop
-  // debugger users from setting breakpoints on the folded-in function, so
-  // exclude .debug_line.
+  // If the referenced symbol is relative to a discarded section (due to
+  // --gc-sections, COMDAT, etc), it has been converted to a Undefined.
+  // `ds->folded` catches the ICF folded case. However, resolving a
+  // relocation in .debug_line to -1 would stop debugger users from setting
+  // breakpoints on the folded-in function, so exclude .debug_line.
   //
   // For pre-DWARF-v5 .debug_loc and .debug_ranges, -1 is a reserved value
   // (base address selection entry), use 1 (which is used by GNU ld for
@@ -974,7 +973,7 @@ void InputSection::relocateNonAlloc(uint8_t *buf, 
ArrayRef rels) {
   //
   // TODO To reduce disruption, we use 0 instead of -1 as the tombstone
   // value. Enable -1 in a future release.
-  if (!sym.getOutputSection() || (ds && ds->folded && !isDebugLine)) {
+  if (!ds || (ds->folded && !isDebugLine)) {
 // If -z dead-reloc-in-nonalloc= is specified, respect it.
 uint64_t value = SignExtend64(*tombstone);
 // For a 32-bit local TU reference in .debug_names, X86_64::relocate
diff --git a/lld/test/ELF/dead-reloc-in-nonalloc.s 
b/lld/test/ELF/dead-reloc-in-nonalloc.s
index 145604eb883a9a..b675fc50fc2ea2 100644
--- a/lld/test/ELF/dead-reloc-in-nonalloc.s
+++ b/lld/test/ELF/dead-reloc-in-nonalloc.s
@@ -17,7 +17,7 @@
 # AA:  Contents of section .debug_info:
 # AA-NEXT:   [[ADDR]]   
 # AA:  Contents of section .not_debug:
-# AA-NEXT:       .
+# AA-NEXT:    2a00   .
 
 ## Specifying zero can get a behavior similar to GNU ld.
 # RUN: ld.lld --icf=all -z dead-reloc-in-nonalloc=.debug_info=0 %t.o %tabs.o 
-o %tzero

___
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#79355 (PR #79361)

2024-01-24 Thread via llvm-branch-commits

https://github.com/github-actions[bot] milestoned 
https://github.com/llvm/llvm-project/pull/79361
___
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#79355 (PR #79361)

2024-01-24 Thread via llvm-branch-commits

https://github.com/github-actions[bot] created 
https://github.com/llvm/llvm-project/pull/79361

resolves llvm/llvm-project#79355

>From f99049f248ad367455b07c9db31f1728927b3df1 Mon Sep 17 00:00:00 2001
From: erichkeane 
Date: Wed, 24 Jan 2024 12:07:22 -0800
Subject: [PATCH] Fix comparison of Structural Values

Fixes a regression from #78041 as reported in the review.  The original
patch failed to compare the canonical type, which this adds.  A slightly
modified test of the original report is added.

(cherry picked from commit e3ee3762304aa81e4a240500844bfdd003401b36)
---
 clang/lib/AST/TemplateBase.cpp |  3 ++-
 .../SemaTemplate/temp_arg_nontype_cxx20.cpp| 18 ++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp
index 2bdbeb08ef2046..3310d7dc24c59d 100644
--- a/clang/lib/AST/TemplateBase.cpp
+++ b/clang/lib/AST/TemplateBase.cpp
@@ -450,7 +450,8 @@ bool TemplateArgument::structurallyEquals(const 
TemplateArgument &Other) const {
getAsIntegral() == Other.getAsIntegral();
 
   case StructuralValue: {
-if (getStructuralValueType() != Other.getStructuralValueType())
+if (getStructuralValueType().getCanonicalType() !=
+Other.getStructuralValueType().getCanonicalType())
   return false;
 
 llvm::FoldingSetNodeID A, B;
diff --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp 
b/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
index b5b8cadc909ce0..834174cdf6a32d 100644
--- a/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -336,3 +336,21 @@ template void bar(B b) {
   (b.operator Tbar(), ...);
 }
 }
+
+namespace ReportedRegression1 {
+  const char kt[] = "dummy";
+
+  template 
+class SomeTempl { };
+
+  template 
+class SomeTempl {
+  public:
+int exit_code() const { return 0; }
+};
+
+  int use() {
+SomeTempl dummy;
+return dummy.exit_code();
+  }
+}

___
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] [compiler-rt] [NFC]Precommit test (PR #79363)

2024-01-24 Thread Mingming Liu via llvm-branch-commits

https://github.com/minglotus-6 edited 
https://github.com/llvm/llvm-project/pull/79363
___
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] [compiler-rt] [NFC]Precommit test case to show function summary and global values when a function has instructions annotated with vtable profiles and indirect call profile

2024-01-24 Thread Mingming Liu via llvm-branch-commits

https://github.com/minglotus-6 closed 
https://github.com/llvm/llvm-project/pull/79233
___
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] [llvm] [NFC]Precommit test (PR #79363)

2024-01-24 Thread Mingming Liu via llvm-branch-commits

https://github.com/minglotus-6 created 
https://github.com/llvm/llvm-project/pull/79363

None


___
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] [llvm] [NFC]Precommit test case to show function summary and global values when a function has instructions annotated with vtable profiles and indirect call profile

2024-01-24 Thread Mingming Liu via llvm-branch-commits

minglotus-6 wrote:

Abandon this in favor of https://github.com/llvm/llvm-project/pull/79363 (same 
content with shorter branch name, otherwise windows build bot might fail due to 
length filename).

https://github.com/llvm/llvm-project/pull/79233
___
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] [llvm] [NFC]Precommit test (PR #79363)

2024-01-24 Thread Mingming Liu via llvm-branch-commits

https://github.com/minglotus-6 updated 
https://github.com/llvm/llvm-project/pull/79363

>From 050c3889c3327ecec4add706fc7d593caa32bdb6 Mon Sep 17 00:00:00 2001
From: mingmingl 
Date: Wed, 24 Jan 2024 13:46:47 -0800
Subject: [PATCH] polish test with profile-summary information

Created using spr 1.3.4
---
 .../thinlto-func-summary-vtableref-pgo.ll | 38 ++-
 1 file changed, 29 insertions(+), 9 deletions(-)

diff --git a/llvm/test/Bitcode/thinlto-func-summary-vtableref-pgo.ll 
b/llvm/test/Bitcode/thinlto-func-summary-vtableref-pgo.ll
index 375e3c290cc986d..78b175caca85f01 100644
--- a/llvm/test/Bitcode/thinlto-func-summary-vtableref-pgo.ll
+++ b/llvm/test/Bitcode/thinlto-func-summary-vtableref-pgo.ll
@@ -10,32 +10,52 @@
 ; CHECK-NEXT:   
 ; The `VALUE_GUID` below represents the "_ZN4Base4funcEv" referenced by the
 ; indirect call instruction.
-; CHECK-NEXT:   
+; CHECK-NEXT:   
 ;  has the format [valueid, flags, instcount, funcflags,
 ; numrefs, rorefcnt, worefcnt,
 ; n x (valueid, hotness+tailcall)]
-; CHECK-NEXT:   
+; CHECK-NEXT:   
 ; CHECK-NEXT:  
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
-define i32 @_Z4testP4Base(ptr %0) !prof !0 {
-  %2 = load ptr, ptr %0, !prof !1
+; Function has one BB and an entry count of 150, so the BB is hot according to
+; ProfileSummary and reflected so in the bitcode (see llvm-dis output).
+define i32 @_Z4testP4Base(ptr %0) !prof !15 {
+  %2 = load ptr, ptr %0, !prof !16
   %3 = load ptr, ptr %2
-  %4 = tail call i32 %3(ptr %0), !prof !2
+  %4 = tail call i32 %3(ptr %0), !prof !17
   ret i32 %4
 }
 
-!0 = !{!"function_entry_count", i32 150}
+!llvm.module.flags = !{!1}
+
+
+!1 = !{i32 1, !"ProfileSummary", !2}
+!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
+!3 = !{!"ProfileFormat", !"InstrProf"}
+!4 = !{!"TotalCount", i64 1}
+!5 = !{!"MaxCount", i64 200}
+!6 = !{!"MaxInternalCount", i64 200}
+!7 = !{!"MaxFunctionCount", i64 200}
+!8 = !{!"NumCounts", i64 3}
+!9 = !{!"NumFunctions", i64 3}
+!10 = !{!"DetailedSummary", !11}
+!11 = !{!12, !13, !14}
+!12 = !{i32 1, i64 100, i32 1}
+!13 = !{i32 99, i64 100, i32 1}
+!14 = !{i32 99, i64 1, i32 2}
+
+!15 = !{!"function_entry_count", i32 150}
 ; 1960855528937986108 is the MD5 hash of _ZTV4Base
-!1 = !{!"VP", i32 2, i64 1600, i64 1960855528937986108, i64 1600}
+!16 = !{!"VP", i32 2, i64 1600, i64 1960855528937986108, i64 1600}
 ; 5459407273543877811 is the MD5 hash of _ZN4Base4funcEv
-!2 = !{!"VP", i32 0, i64 1600, i64 5459407273543877811, i64 1600}
+!17 = !{!"VP", i32 0, i64 1600, i64 5459407273543877811, i64 1600}
 
 ; ModuleSummaryIndex stores  map in std::map; so
 ; global value summares are printed out in the order that gv's guid increases.
 ; DIS: ^0 = module: (path: "{{.*}}", hash: (0, 0, 0, 0, 0))
 ; DIS: ^1 = gv: (guid: 5459407273543877811)
-; DIS: ^2 = gv: (name: "_Z4testP4Base", summaries: (function: (module: ^0, 
flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 
0, dsoLocal: 0, canAutoHide: 0), insts: 4, funcFlags: (readNone: 0, readOnly: 
0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 
0, mayThrow: 0, hasUnknownCall: 1, mustBeUnreachable: 0), calls: ((callee: ^1, 
hotness: none) ; guid = 15857150948103218965
+; DIS: ^2 = gv: (name: "_Z4testP4Base", summaries: (function: (module: ^0, 
flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 
0, dsoLocal: 0, canAutoHide: 0), insts: 4, funcFlags: (readNone: 0, readOnly: 
0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 
0, mayThrow: 0, hasUnknownCall: 1, mustBeUnreachable: 0), calls: ((callee: ^1, 
hotness: hot) ; guid = 15857150948103218965
 ; DIS: ^3 = blockcount: 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] [compiler-rt] [llvm] [ThinLTO] (PR #79381)

2024-01-24 Thread Mingming Liu via llvm-branch-commits

https://github.com/minglotus-6 created 
https://github.com/llvm/llvm-project/pull/79381

None


___
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] [llvm] [ThinLTO][TypeProf] Implement vtable def import (PR #79381)

2024-01-24 Thread Mingming Liu via llvm-branch-commits

https://github.com/minglotus-6 edited 
https://github.com/llvm/llvm-project/pull/79381
___
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] [compiler-rt] [ThinLTO][TypeProf] Implement vtable def import (PR #79381)

2024-01-24 Thread Mingming Liu via llvm-branch-commits

https://github.com/minglotus-6 edited 
https://github.com/llvm/llvm-project/pull/79381
___
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] [llvm] [ThinLTO][TypeProfiling]Add annotated vtable GUID as referenced variables in per function summary, and update bitcode writer to create value-ids for these re

2024-01-24 Thread Mingming Liu via llvm-branch-commits

minglotus-6 wrote:

I'll abandon this pr in favor of 
https://github.com/llvm/llvm-project/pull/79381 (which has a shorter branch 
name). Going to delete this lengthy branch from `llvm/llvm-project` shortly 
after.

Sorry for the noise and inconvenience!

https://github.com/llvm/llvm-project/pull/79234
___
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] [llvm] [ThinLTO][TypeProfiling]Add annotated vtable GUID as referenced variables in per function summary, and update bitcode writer to create value-ids for these re

2024-01-24 Thread Mingming Liu via llvm-branch-commits

https://github.com/minglotus-6 closed 
https://github.com/llvm/llvm-project/pull/79234
___
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] [llvm] [ThinLTO][TypeProf] Implement vtable def import (PR #79381)

2024-01-24 Thread Mingming Liu via llvm-branch-commits

https://github.com/minglotus-6 ready_for_review 
https://github.com/llvm/llvm-project/pull/79381
___
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] [llvm] [ThinLTO][TypeProf] Implement vtable def import (PR #79381)

2024-01-24 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-analysis

Author: Mingming Liu (minglotus-6)


Changes

Add annotated vtable GUID as referenced variables in per function summary, and 
update bitcode writer to create value-ids for these referenced vtables. 
* This is the part3 of type profiling work, and described in the ["Virtual 
Table Definition Import" section of the 
RFC](https://github.com/llvm/llvm-project/pull/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).
 This pull request depends on [part 
2](https://github.com/llvm/llvm-project/pull/66825) which introduces the new 
value type.




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


5 Files Affected:

- (modified) llvm/include/llvm/ProfileData/InstrProf.h (+11-1) 
- (modified) llvm/lib/Analysis/ModuleSummaryAnalysis.cpp (+22) 
- (modified) llvm/lib/Bitcode/Writer/BitcodeWriter.cpp (+11-2) 
- (modified) llvm/lib/ProfileData/InstrProf.cpp (+46-21) 
- (modified) llvm/test/Bitcode/thinlto-func-summary-vtableref-pgo.ll (+11-5) 


``diff
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h 
b/llvm/include/llvm/ProfileData/InstrProf.h
index d936f38741e1e3a..248f62c7a810592 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -283,7 +283,7 @@ void annotateValueSite(Module &M, Instruction &Inst,
 
 /// Extract the value profile data from \p Inst which is annotated with
 /// value profile meta data. Return false if there is no value data annotated,
-/// otherwise  return true.
+/// otherwise return true.
 bool getValueProfDataFromInst(const Instruction &Inst,
   InstrProfValueKind ValueKind,
   uint32_t MaxNumValueData,
@@ -291,6 +291,16 @@ bool getValueProfDataFromInst(const Instruction &Inst,
   uint32_t &ActualNumValueData, uint64_t &TotalC,
   bool GetNoICPValue = false);
 
+/// Extract the value profile data from \p Inst and returns them if \p Inst is
+/// annotated with value profile data. Returns nullptr otherwise. It's similar
+/// to `getValueProfDataFromInst` above except that an array is allocated only
+/// after a preliminary checking that the value profiles of kind `ValueKind`
+/// exist.
+std::unique_ptr
+getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind,
+ uint32_t MaxNumValueData, uint32_t 
&ActualNumValueData,
+ uint64_t &TotalC, bool GetNoICPValue = false);
+
 inline StringRef getPGOFuncNameMetadataName() { return "PGOFuncName"; }
 
 /// Return the PGOFuncName meta data associated with a function.
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp 
b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index 1f15e94783240a7..fc8c31de0f4501f 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -124,6 +124,28 @@ static bool findRefEdges(ModuleSummaryIndex &Index, const 
User *CurUser,
 Worklist.push_back(Operand);
 }
   }
+
+  const Instruction *I = dyn_cast(CurUser);
+  if (I) {
+uint32_t ActualNumValueData = 0;
+uint64_t TotalCount = 0;
+// 24 is the maximum number of values preserved for one instrumented site,
+// defined by INSTR_PROF_DEFAULT_NUM_VAL_PER_SITE in
+// compiler-rt/lib/profile/InstrProfilingValue.c; passing 24 as
+// `MaxNumValueData` controls the max number of elements in the returned
+// array. The actual number of values is gated by the number of ops in 
!prof
+// metadata.
+auto ValueDataArray = getValueProfDataFromInst(
+*I, IPVK_VTableTarget, 24 /* MaxNumValueData */, ActualNumValueData,
+TotalCount);
+
+if (ValueDataArray.get()) {
+  for (uint32_t j = 0; j < ActualNumValueData; j++) {
+RefEdges.insert(Index.getOrInsertValueInfo(
+ValueDataArray[j].Value /* VTableGUID */));
+  }
+}
+  }
   return HasBlockAddress;
 }
 
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp 
b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index a5fc267b1883bfe..432a99d35efeab4 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -199,7 +199,7 @@ class ModuleBitcodeWriterBase : public BitcodeWriterBase {
 for (const auto &GUIDSummaryLists : *Index)
   // Examine all summaries for this GUID.
   for (auto &Summary : GUIDSummaryLists.second.SummaryList)
-if (auto FS = dyn_cast(Summary.get()))
+if (auto FS = dyn_cast(Summary.get())) {
   // For each call in the function summary, see if the call
   // is to a GUID (which means it is for an indirect call,
   // otherwise we would have a Value for it). If so, synthesize
@@ -207,6 +207,15 @@ class ModuleBitcodeWriterBase : public BitcodeWriterBase {
   for (auto &CallEdge : FS->calls())
 if (!CallEdge.first.haveGVs() || !CallEdge.first.getValue())
   assi

[llvm-branch-commits] [compiler-rt] [llvm] [ThinLTO][TypeProf] Implement vtable def import (PR #79381)

2024-01-24 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-lto

Author: Mingming Liu (minglotus-6)


Changes

Add annotated vtable GUID as referenced variables in per function summary, and 
update bitcode writer to create value-ids for these referenced vtables. 
* This is the part3 of type profiling work, and described in the ["Virtual 
Table Definition Import" section of the 
RFC](https://github.com/llvm/llvm-project/pull/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).
 This pull request depends on [part 
2](https://github.com/llvm/llvm-project/pull/66825) which introduces the new 
value type.




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


5 Files Affected:

- (modified) llvm/include/llvm/ProfileData/InstrProf.h (+11-1) 
- (modified) llvm/lib/Analysis/ModuleSummaryAnalysis.cpp (+22) 
- (modified) llvm/lib/Bitcode/Writer/BitcodeWriter.cpp (+11-2) 
- (modified) llvm/lib/ProfileData/InstrProf.cpp (+46-21) 
- (modified) llvm/test/Bitcode/thinlto-func-summary-vtableref-pgo.ll (+11-5) 


``diff
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h 
b/llvm/include/llvm/ProfileData/InstrProf.h
index d936f38741e1e3a..248f62c7a810592 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -283,7 +283,7 @@ void annotateValueSite(Module &M, Instruction &Inst,
 
 /// Extract the value profile data from \p Inst which is annotated with
 /// value profile meta data. Return false if there is no value data annotated,
-/// otherwise  return true.
+/// otherwise return true.
 bool getValueProfDataFromInst(const Instruction &Inst,
   InstrProfValueKind ValueKind,
   uint32_t MaxNumValueData,
@@ -291,6 +291,16 @@ bool getValueProfDataFromInst(const Instruction &Inst,
   uint32_t &ActualNumValueData, uint64_t &TotalC,
   bool GetNoICPValue = false);
 
+/// Extract the value profile data from \p Inst and returns them if \p Inst is
+/// annotated with value profile data. Returns nullptr otherwise. It's similar
+/// to `getValueProfDataFromInst` above except that an array is allocated only
+/// after a preliminary checking that the value profiles of kind `ValueKind`
+/// exist.
+std::unique_ptr
+getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind,
+ uint32_t MaxNumValueData, uint32_t 
&ActualNumValueData,
+ uint64_t &TotalC, bool GetNoICPValue = false);
+
 inline StringRef getPGOFuncNameMetadataName() { return "PGOFuncName"; }
 
 /// Return the PGOFuncName meta data associated with a function.
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp 
b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index 1f15e94783240a7..fc8c31de0f4501f 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -124,6 +124,28 @@ static bool findRefEdges(ModuleSummaryIndex &Index, const 
User *CurUser,
 Worklist.push_back(Operand);
 }
   }
+
+  const Instruction *I = dyn_cast(CurUser);
+  if (I) {
+uint32_t ActualNumValueData = 0;
+uint64_t TotalCount = 0;
+// 24 is the maximum number of values preserved for one instrumented site,
+// defined by INSTR_PROF_DEFAULT_NUM_VAL_PER_SITE in
+// compiler-rt/lib/profile/InstrProfilingValue.c; passing 24 as
+// `MaxNumValueData` controls the max number of elements in the returned
+// array. The actual number of values is gated by the number of ops in 
!prof
+// metadata.
+auto ValueDataArray = getValueProfDataFromInst(
+*I, IPVK_VTableTarget, 24 /* MaxNumValueData */, ActualNumValueData,
+TotalCount);
+
+if (ValueDataArray.get()) {
+  for (uint32_t j = 0; j < ActualNumValueData; j++) {
+RefEdges.insert(Index.getOrInsertValueInfo(
+ValueDataArray[j].Value /* VTableGUID */));
+  }
+}
+  }
   return HasBlockAddress;
 }
 
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp 
b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index a5fc267b1883bfe..432a99d35efeab4 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -199,7 +199,7 @@ class ModuleBitcodeWriterBase : public BitcodeWriterBase {
 for (const auto &GUIDSummaryLists : *Index)
   // Examine all summaries for this GUID.
   for (auto &Summary : GUIDSummaryLists.second.SummaryList)
-if (auto FS = dyn_cast(Summary.get()))
+if (auto FS = dyn_cast(Summary.get())) {
   // For each call in the function summary, see if the call
   // is to a GUID (which means it is for an indirect call,
   // otherwise we would have a Value for it). If so, synthesize
@@ -207,6 +207,15 @@ class ModuleBitcodeWriterBase : public BitcodeWriterBase {
   for (auto &CallEdge : FS->calls())
 if (!CallEdge.first.haveGVs() || !CallEdge.first.getValue())
   assignValueId(

[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79279 (PR #79341)

2024-01-24 Thread Phoebe Wang via llvm-branch-commits

phoebewang wrote:

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

The fix is required and has low risk, LGTM.

https://github.com/llvm/llvm-project/pull/79341
___
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 924701311aa79180e86ad8ce43d253f27d25ec7d to 18.x (PR #79400)

2024-01-24 Thread via llvm-branch-commits

https://github.com/alexfh edited 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] [clang] [libcxx] revert 924701311aa79180e86ad8ce43d253f27d25ec7d to 18.x (PR #79400)

2024-01-24 Thread via llvm-branch-commits

https://github.com/alexfh edited 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] [clang] [libcxx] Revert "[SemaCXX] Implement CWG2137 (list-initialization from objects of the same type) (#77768)" in release/18.x (PR #79400)

2024-01-24 Thread via llvm-branch-commits

https://github.com/alexfh edited 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] [clang] [libcxx] Revert "[SemaCXX] Implement CWG2137 (list-initialization from objects of the same type) (#77768)" in release/18.x (PR #79400)

2024-01-24 Thread via llvm-branch-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 93248729cfae82a5ca2323d4a8e15aa3b9b9c707 
dc630b5c321ecbbdffe00b9da7fc71a02e1cbd56 -- clang/lib/Sema/SemaInit.cpp 
clang/lib/Sema/SemaOverload.cpp clang/test/CXX/drs/dr14xx.cpp 
clang/test/CXX/drs/dr21xx.cpp clang/test/CXX/drs/dr23xx.cpp 
libcxx/include/__config 
libcxx/test/std/utilities/utility/pairs/pairs.pair/ctor.pair_U_V_move.pass.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index c9eb678983..018043c3b3 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1568,8 +1568,8 @@ TryUserDefinedConversion(Sema &S, Expr *From, QualType 
ToType,
 //   called for those cases.
 if (CXXConstructorDecl *Constructor
   = dyn_cast(ICS.UserDefined.ConversionFunction)) {
-  QualType FromCanon
-= S.Context.getCanonicalType(From->getType().getUnqualifiedType());
+  QualType FromCanon =
+  S.Context.getCanonicalType(From->getType().getUnqualifiedType());
   QualType ToCanon
 = S.Context.getCanonicalType(ToType).getUnqualifiedType();
   if (Constructor->isCopyConstructor() &&

``




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] [clang] [libcxx] Revert "[SemaCXX] Implement CWG2137 (list-initialization from objects of the same type) (#77768)" in release/18.x (PR #79400)

2024-01-24 Thread via llvm-branch-commits

https://github.com/alexfh edited 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] [clang] [libcxx] Revert "[SemaCXX] Implement CWG2137 (list-initialization from objects of the same type) (#77768)" in release/18.x (PR #79400)

2024-01-24 Thread via llvm-branch-commits

https://github.com/alexfh ready_for_review 
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] [clang] [libcxx] Revert "[SemaCXX] Implement CWG2137 (list-initialization from objects of the same type) (#77768)" in release/18.x (PR #79400)

2024-01-24 Thread via llvm-branch-commits

llvmbot wrote:



@llvm/pr-subscribers-libcxx

@llvm/pr-subscribers-clang

Author: None (alexfh)


Changes

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


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


8 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (-5) 
- (modified) clang/lib/Sema/SemaInit.cpp (+10-30) 
- (modified) clang/lib/Sema/SemaOverload.cpp (+10-28) 
- (modified) clang/test/CXX/drs/dr14xx.cpp (+10) 
- (modified) clang/test/CXX/drs/dr21xx.cpp (-45) 
- (modified) clang/test/CXX/drs/dr23xx.cpp (-85) 
- (modified) clang/www/cxx_dr_status.html (+2-2) 
- (modified) 
libcxx/test/std/utilities/utility/pairs/pairs.pair/ctor.pair_U_V_move.pass.cpp 
(+1-20) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 060bc7669b72a5e..edc05a0d208dedb 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.
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 91e4cb7b68a24a9..457fa377355a97c 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -4200,7 +4200,7 @@ static OverloadingResult ResolveConstructorOverload(
 /// \param IsListInit Is this list-initialization?
 /// \param IsInitListCopy Is this non-list-initialization resulting from a
 ///   list-initialization from {x} where x is the same
-///   aggregate type as the entity?
+///   type as the entity?
 static void TryConstructorInitialization(Sema &S,
  const InitializedEntity &Entity,
  const InitializationKind &Kind,
@@ -4230,14 +4230,6 @@ static void TryConstructorInitialization(Sema &S,
 Entity.getKind() !=
 InitializedEntity::EK_LambdaToBlockConversionBlockElement);
 
-  bool CopyElisionPossible = false;
-  auto ElideConstructor = [&] {
-// Convert qualifications if necessary.
-Sequence.AddQualificationConversionStep(DestType, VK_PRValue);
-if (ILE)
-  Sequence.RewrapReferenceInitList(DestType, ILE);
-  };
-
   // C++17 [dcl.init]p17:
   // - If the initializer expression is a prvalue and the cv-unqualified
   //   version of the source type is the same class as the class of the
@@ -4250,17 +4242,11 @@ static void TryConstructorInitialization(Sema &S,
   if (S.getLangOpts().CPlusPlus17 && !RequireActualConstructor &&
   UnwrappedArgs.size() == 1 && UnwrappedArgs[0]->isPRValue() &&
   S.Context.hasSameUnqualifiedType(UnwrappedArgs[0]->getType(), DestType)) 
{
-if (ILE && !DestType->isAggregateType()) {
-  // CWG2311: T{ prvalue_of_type_T } is not eligible for copy elision
-  // Make this an elision if this won't call an initializer-list
-  // constructor. (Always on an aggregate type or check constructors 
first.)
-  assert(!IsInitListCopy &&
- "IsInitListCopy only possible with aggregate types");
-  CopyElisionPossible = true;
-} else {
-  ElideConstructor();
-  return;
-}
+// Convert qualifications if necessary.
+Sequence.AddQualificationConversionStep(DestType, VK_PRValue);
+if (ILE)
+  Sequence.RewrapReferenceInitList(DestType, ILE);
+return;
   }
 
   const RecordType *DestRecordType = DestType->getAs();
@@ -4305,12 +4291,6 @@ static void TryConstructorInitialization(Sema &S,
   S, Kind.getLocation(), Args, CandidateSet, DestType, Ctors, Best,
   CopyInitialization, AllowExplicit,
   /*OnlyListConstructors=*/true, IsListInit, RequireActualConstructor);
-
-if (CopyElisionPossible && Result == OR_No_Viable_Function) {
-  // No initializer list candidate
-  ElideConstructor();
-  return;
-}
   }
 
   // C++11 [over.match.list]p1:
@@ -4592,9 +4572,9 @@ static void TryListInitialization(Sema &S,
 return;
   }
 
-  // C++11 [dcl.init.list]p3, per DR1467 and DR2137:
-  // - If T is an aggregate class and the initializer list has a single element
-  //   of type cv U, where U is T or a class derived from T, the object is
+  // C++11 [dcl.init.list]