[llvm-branch-commits] [compiler-rt] [sanitizer_common] Make sanitizer_linux.cpp kernel_stat* handling Lin… (PR #104916)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/104916
___
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] 9301cd5 - [sanitizer_common] Make sanitizer_linux.cpp kernel_stat* handling Linux-specific

2024-08-26 Thread Rainer Orth via llvm-branch-commits

Author: Rainer Orth
Date: 2024-08-20T13:34:13+02:00
New Revision: 9301cd5b57c09214256edf19753e2e047a5b5f91

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

LOG: [sanitizer_common] Make sanitizer_linux.cpp kernel_stat* handling 
Linux-specific

fcd6bd5587cc376cd8f43b60d1c7d61fdfe0f535 broke the Solaris/sparcv9 buildbot:
```
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:39:14: fatal error: 
'asm/unistd.h' file not found
   39 | #include 
  |  ^~
```
That section should have been Linux-specific in the first place, which is
what this patch does.

Tested on sparcv9-sun-solaris2.11.

(cherry picked from commit 16e9bb9cd7f50ae2ec7f29a80bc3b95f528bfdbf)

Added: 


Modified: 
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Removed: 




diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index 8d375ffcd079c9..648df0c4e5a760 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -35,7 +35,7 @@
 // access stat from asm/stat.h, without conflicting with definition in
 // sys/stat.h, we use this trick.  sparc64 is similar, using
 // syscall(__NR_stat64) and struct kernel_stat64.
-#  if SANITIZER_MIPS64 || SANITIZER_SPARC64
+#  if SANITIZER_LINUX && (SANITIZER_MIPS64 || SANITIZER_SPARC64)
 #include 
 #include 
 #define stat kernel_stat



___
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] [sanitizer_common] Make sanitizer_linux.cpp kernel_stat* handling Lin… (PR #104916)

2024-08-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@rorth (or anyone else). If you would like to add a note about this fix in the 
release notes (completely optional). Please reply to this comment with a one or 
two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/104916
___
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/19.x: [clang][modules] Built-in modules are not correctly enabled for Mac Catalyst (#104872) (PR #105093)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/105093

>From 9dc4bdf9fd1e4be051fe19998d64230d999b777d Mon Sep 17 00:00:00 2001
From: Ian Anderson 
Date: Tue, 20 Aug 2024 03:29:11 -0700
Subject: [PATCH] [clang][modules] Built-in modules are not correctly enabled
 for Mac Catalyst (#104872)

Mac Catalyst is the iOS platform, but it builds against the macOS SDK
and so it needs to be checking the macOS SDK version instead of the iOS
one. Add tests against a greater-than SDK version just to make sure this
works beyond the initially supporting SDKs.

(cherry picked from commit b9864387d9d00e1d4888181460d05dbc92364d75)
---
 clang/lib/Driver/ToolChains/Darwin.cpp | 10 +-
 .../test/Driver/Inputs/MacOSX15.0.sdk/SDKSettings.json |  2 +-
 .../test/Driver/Inputs/MacOSX15.1.sdk/SDKSettings.json |  1 +
 clang/test/Driver/darwin-builtin-modules.c |  3 +++
 4 files changed, 14 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Driver/Inputs/MacOSX15.1.sdk/SDKSettings.json

diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 17d57b2f7eedab..e576efaf5ca884 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2953,7 +2953,15 @@ static bool sdkSupportsBuiltinModules(
   case Darwin::MacOS:
 return SDKVersion >= VersionTuple(15U);
   case Darwin::IPhoneOS:
-return SDKVersion >= VersionTuple(18U);
+switch (TargetEnvironment) {
+case Darwin::MacCatalyst:
+  // Mac Catalyst uses `-target arm64-apple-ios18.0-macabi` so the platform
+  // is iOS, but it builds with the macOS SDK, so it's the macOS SDK 
version
+  // that's relevant.
+  return SDKVersion >= VersionTuple(15U);
+default:
+  return SDKVersion >= VersionTuple(18U);
+}
   case Darwin::TvOS:
 return SDKVersion >= VersionTuple(18U);
   case Darwin::WatchOS:
diff --git a/clang/test/Driver/Inputs/MacOSX15.0.sdk/SDKSettings.json 
b/clang/test/Driver/Inputs/MacOSX15.0.sdk/SDKSettings.json
index 77b70e1a83c19c..ced45d5c219962 100644
--- a/clang/test/Driver/Inputs/MacOSX15.0.sdk/SDKSettings.json
+++ b/clang/test/Driver/Inputs/MacOSX15.0.sdk/SDKSettings.json
@@ -1 +1 @@
-{"Version":"990.0", "MaximumDeploymentTarget": "99.0.99"}
+{"Version":"15.0", "MaximumDeploymentTarget": "15.0.99"}
diff --git a/clang/test/Driver/Inputs/MacOSX15.1.sdk/SDKSettings.json 
b/clang/test/Driver/Inputs/MacOSX15.1.sdk/SDKSettings.json
new file mode 100644
index 00..d46295b2ab5a17
--- /dev/null
+++ b/clang/test/Driver/Inputs/MacOSX15.1.sdk/SDKSettings.json
@@ -0,0 +1 @@
+{"Version":"15.1", "MaximumDeploymentTarget": "15.1.99"}
diff --git a/clang/test/Driver/darwin-builtin-modules.c 
b/clang/test/Driver/darwin-builtin-modules.c
index ec515133be8aba..4564d7317d7abe 100644
--- a/clang/test/Driver/darwin-builtin-modules.c
+++ b/clang/test/Driver/darwin-builtin-modules.c
@@ -8,5 +8,8 @@
 
 // RUN: %clang -isysroot %S/Inputs/MacOSX15.0.sdk -target 
x86_64-apple-macos14.0 -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
 // RUN: %clang -isysroot %S/Inputs/MacOSX15.0.sdk -target 
x86_64-apple-macos15.0 -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
+// RUN: %clang -isysroot %S/Inputs/MacOSX15.0.sdk -target 
x86_64-apple-ios18.0-macabi -### %s 2>&1 | FileCheck 
--check-prefix=CHECK_FUTURE %s
+// RUN: %clang -isysroot %S/Inputs/MacOSX15.1.sdk -target 
x86_64-apple-macos15.1 -darwin-target-variant x86_64-apple-ios18.1-macabi -### 
%s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
+// RUN: %clang -isysroot %S/Inputs/MacOSX15.1.sdk -target 
x86_64-apple-ios18.1-macabi -darwin-target-variant x86_64-apple-macos15.1 -### 
%s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
 // RUN: %clang -isysroot %S/Inputs/DriverKit23.0.sdk -target 
arm64-apple-driverkit23.0 -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE 
%s
 // CHECK_FUTURE-NOT: -fbuiltin-headers-in-system-modules

___
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] 9dc4bdf - [clang][modules] Built-in modules are not correctly enabled for Mac Catalyst (#104872)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

Author: Ian Anderson
Date: 2024-08-26T09:08:34+02:00
New Revision: 9dc4bdf9fd1e4be051fe19998d64230d999b777d

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

LOG: [clang][modules] Built-in modules are not correctly enabled for Mac 
Catalyst (#104872)

Mac Catalyst is the iOS platform, but it builds against the macOS SDK
and so it needs to be checking the macOS SDK version instead of the iOS
one. Add tests against a greater-than SDK version just to make sure this
works beyond the initially supporting SDKs.

(cherry picked from commit b9864387d9d00e1d4888181460d05dbc92364d75)

Added: 
clang/test/Driver/Inputs/MacOSX15.1.sdk/SDKSettings.json

Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/Inputs/MacOSX15.0.sdk/SDKSettings.json
clang/test/Driver/darwin-builtin-modules.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 17d57b2f7eedab..e576efaf5ca884 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2953,7 +2953,15 @@ static bool sdkSupportsBuiltinModules(
   case Darwin::MacOS:
 return SDKVersion >= VersionTuple(15U);
   case Darwin::IPhoneOS:
-return SDKVersion >= VersionTuple(18U);
+switch (TargetEnvironment) {
+case Darwin::MacCatalyst:
+  // Mac Catalyst uses `-target arm64-apple-ios18.0-macabi` so the platform
+  // is iOS, but it builds with the macOS SDK, so it's the macOS SDK 
version
+  // that's relevant.
+  return SDKVersion >= VersionTuple(15U);
+default:
+  return SDKVersion >= VersionTuple(18U);
+}
   case Darwin::TvOS:
 return SDKVersion >= VersionTuple(18U);
   case Darwin::WatchOS:

diff  --git a/clang/test/Driver/Inputs/MacOSX15.0.sdk/SDKSettings.json 
b/clang/test/Driver/Inputs/MacOSX15.0.sdk/SDKSettings.json
index 77b70e1a83c19c..ced45d5c219962 100644
--- a/clang/test/Driver/Inputs/MacOSX15.0.sdk/SDKSettings.json
+++ b/clang/test/Driver/Inputs/MacOSX15.0.sdk/SDKSettings.json
@@ -1 +1 @@
-{"Version":"990.0", "MaximumDeploymentTarget": "99.0.99"}
+{"Version":"15.0", "MaximumDeploymentTarget": "15.0.99"}

diff  --git a/clang/test/Driver/Inputs/MacOSX15.1.sdk/SDKSettings.json 
b/clang/test/Driver/Inputs/MacOSX15.1.sdk/SDKSettings.json
new file mode 100644
index 00..d46295b2ab5a17
--- /dev/null
+++ b/clang/test/Driver/Inputs/MacOSX15.1.sdk/SDKSettings.json
@@ -0,0 +1 @@
+{"Version":"15.1", "MaximumDeploymentTarget": "15.1.99"}

diff  --git a/clang/test/Driver/darwin-builtin-modules.c 
b/clang/test/Driver/darwin-builtin-modules.c
index ec515133be8aba..4564d7317d7abe 100644
--- a/clang/test/Driver/darwin-builtin-modules.c
+++ b/clang/test/Driver/darwin-builtin-modules.c
@@ -8,5 +8,8 @@
 
 // RUN: %clang -isysroot %S/Inputs/MacOSX15.0.sdk -target 
x86_64-apple-macos14.0 -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
 // RUN: %clang -isysroot %S/Inputs/MacOSX15.0.sdk -target 
x86_64-apple-macos15.0 -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
+// RUN: %clang -isysroot %S/Inputs/MacOSX15.0.sdk -target 
x86_64-apple-ios18.0-macabi -### %s 2>&1 | FileCheck 
--check-prefix=CHECK_FUTURE %s
+// RUN: %clang -isysroot %S/Inputs/MacOSX15.1.sdk -target 
x86_64-apple-macos15.1 -darwin-target-variant x86_64-apple-ios18.1-macabi -### 
%s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
+// RUN: %clang -isysroot %S/Inputs/MacOSX15.1.sdk -target 
x86_64-apple-ios18.1-macabi -darwin-target-variant x86_64-apple-macos15.1 -### 
%s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
 // RUN: %clang -isysroot %S/Inputs/DriverKit23.0.sdk -target 
arm64-apple-driverkit23.0 -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE 
%s
 // CHECK_FUTURE-NOT: -fbuiltin-headers-in-system-modules



___
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/19.x: [clang][modules] Built-in modules are not correctly enabled for Mac Catalyst (#104872) (PR #105093)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/105093
___
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/19.x: [clang][modules] Built-in modules are not correctly enabled for Mac Catalyst (#104872) (PR #105093)

2024-08-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@ian-twilightcoder (or anyone else). If you would like to add a note about this 
fix in the release notes (completely optional). Please reply to this comment 
with a one or two sentence description of the fix.  When you are done, please 
add the release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/105093
___
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] release/19.x: [SPARC] Remove assertions in printOperand for inline asm operands (#104692) (PR #105096)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/105096

>From 8ea372d8b628b0a11016f5282d47c372e3843b93 Mon Sep 17 00:00:00 2001
From: Koakuma 
Date: Tue, 20 Aug 2024 20:05:06 +0700
Subject: [PATCH] [SPARC] Remove assertions in printOperand for inline asm
 operands (#104692)

Inline asm operands could contain any kind of relocation, so remove the
checks.

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

(cherry picked from commit 576b7a781aac6b1d60a72248894b50e565e9185a)
---
 llvm/lib/Target/Sparc/SparcAsmPrinter.cpp | 51 ---
 llvm/test/CodeGen/SPARC/inlineasm.ll  | 10 +
 2 files changed, 10 insertions(+), 51 deletions(-)

diff --git a/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp 
b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
index 6855471840e9db..71ec01aeb011ca 100644
--- a/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
+++ b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
@@ -314,57 +314,6 @@ void SparcAsmPrinter::printOperand(const MachineInstr *MI, 
int opNum,
   const MachineOperand &MO = MI->getOperand (opNum);
   SparcMCExpr::VariantKind TF = (SparcMCExpr::VariantKind) MO.getTargetFlags();
 
-#ifndef NDEBUG
-  // Verify the target flags.
-  if (MO.isGlobal() || MO.isSymbol() || MO.isCPI()) {
-if (MI->getOpcode() == SP::CALL)
-  assert(TF == SparcMCExpr::VK_Sparc_None &&
- "Cannot handle target flags on call address");
-else if (MI->getOpcode() == SP::SETHIi)
-  assert((TF == SparcMCExpr::VK_Sparc_HI
-  || TF == SparcMCExpr::VK_Sparc_H44
-  || TF == SparcMCExpr::VK_Sparc_HH
-  || TF == SparcMCExpr::VK_Sparc_LM
-  || TF == SparcMCExpr::VK_Sparc_TLS_GD_HI22
-  || TF == SparcMCExpr::VK_Sparc_TLS_LDM_HI22
-  || TF == SparcMCExpr::VK_Sparc_TLS_LDO_HIX22
-  || TF == SparcMCExpr::VK_Sparc_TLS_IE_HI22
-  || TF == SparcMCExpr::VK_Sparc_TLS_LE_HIX22) &&
- "Invalid target flags for address operand on sethi");
-else if (MI->getOpcode() == SP::TLS_CALL)
-  assert((TF == SparcMCExpr::VK_Sparc_None
-  || TF == SparcMCExpr::VK_Sparc_TLS_GD_CALL
-  || TF == SparcMCExpr::VK_Sparc_TLS_LDM_CALL) &&
- "Cannot handle target flags on tls call address");
-else if (MI->getOpcode() == SP::TLS_ADDrr)
-  assert((TF == SparcMCExpr::VK_Sparc_TLS_GD_ADD
-  || TF == SparcMCExpr::VK_Sparc_TLS_LDM_ADD
-  || TF == SparcMCExpr::VK_Sparc_TLS_LDO_ADD
-  || TF == SparcMCExpr::VK_Sparc_TLS_IE_ADD) &&
- "Cannot handle target flags on add for TLS");
-else if (MI->getOpcode() == SP::TLS_LDrr)
-  assert(TF == SparcMCExpr::VK_Sparc_TLS_IE_LD &&
- "Cannot handle target flags on ld for TLS");
-else if (MI->getOpcode() == SP::TLS_LDXrr)
-  assert(TF == SparcMCExpr::VK_Sparc_TLS_IE_LDX &&
- "Cannot handle target flags on ldx for TLS");
-else if (MI->getOpcode() == SP::XORri)
-  assert((TF == SparcMCExpr::VK_Sparc_TLS_LDO_LOX10
-  || TF == SparcMCExpr::VK_Sparc_TLS_LE_LOX10) &&
- "Cannot handle target flags on xor for TLS");
-else
-  assert((TF == SparcMCExpr::VK_Sparc_LO
-  || TF == SparcMCExpr::VK_Sparc_M44
-  || TF == SparcMCExpr::VK_Sparc_L44
-  || TF == SparcMCExpr::VK_Sparc_HM
-  || TF == SparcMCExpr::VK_Sparc_TLS_GD_LO10
-  || TF == SparcMCExpr::VK_Sparc_TLS_LDM_LO10
-  || TF == SparcMCExpr::VK_Sparc_TLS_IE_LO10 ) &&
- "Invalid target flags for small address operand");
-  }
-#endif
-
-
   bool CloseParen = SparcMCExpr::printVariantKind(O, TF);
 
   switch (MO.getType()) {
diff --git a/llvm/test/CodeGen/SPARC/inlineasm.ll 
b/llvm/test/CodeGen/SPARC/inlineasm.ll
index 14ea0a2a126027..e2853f03a002e6 100644
--- a/llvm/test/CodeGen/SPARC/inlineasm.ll
+++ b/llvm/test/CodeGen/SPARC/inlineasm.ll
@@ -152,3 +152,13 @@ define i64 @test_twinword(){
   %1 = tail call i64 asm sideeffect "rd %asr5, ${0:L} \0A\09 srlx ${0:L}, 32, 
${0:H}", "={i0}"()
   ret i64 %1
 }
+
+; CHECK-LABEL: test_symbol:
+; CHECK: ba,a brtarget
+define void @test_symbol() {
+Entry:
+  call void asm sideeffect "ba,a ${0}", "X"(ptr @brtarget)
+  unreachable
+}
+
+declare void @brtarget()

___
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] 8ea372d - [SPARC] Remove assertions in printOperand for inline asm operands (#104692)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

Author: Koakuma
Date: 2024-08-26T09:10:42+02:00
New Revision: 8ea372d8b628b0a11016f5282d47c372e3843b93

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

LOG: [SPARC] Remove assertions in printOperand for inline asm operands (#104692)

Inline asm operands could contain any kind of relocation, so remove the
checks.

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

(cherry picked from commit 576b7a781aac6b1d60a72248894b50e565e9185a)

Added: 


Modified: 
llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
llvm/test/CodeGen/SPARC/inlineasm.ll

Removed: 




diff  --git a/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp 
b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
index 6855471840e9db..71ec01aeb011ca 100644
--- a/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
+++ b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
@@ -314,57 +314,6 @@ void SparcAsmPrinter::printOperand(const MachineInstr *MI, 
int opNum,
   const MachineOperand &MO = MI->getOperand (opNum);
   SparcMCExpr::VariantKind TF = (SparcMCExpr::VariantKind) MO.getTargetFlags();
 
-#ifndef NDEBUG
-  // Verify the target flags.
-  if (MO.isGlobal() || MO.isSymbol() || MO.isCPI()) {
-if (MI->getOpcode() == SP::CALL)
-  assert(TF == SparcMCExpr::VK_Sparc_None &&
- "Cannot handle target flags on call address");
-else if (MI->getOpcode() == SP::SETHIi)
-  assert((TF == SparcMCExpr::VK_Sparc_HI
-  || TF == SparcMCExpr::VK_Sparc_H44
-  || TF == SparcMCExpr::VK_Sparc_HH
-  || TF == SparcMCExpr::VK_Sparc_LM
-  || TF == SparcMCExpr::VK_Sparc_TLS_GD_HI22
-  || TF == SparcMCExpr::VK_Sparc_TLS_LDM_HI22
-  || TF == SparcMCExpr::VK_Sparc_TLS_LDO_HIX22
-  || TF == SparcMCExpr::VK_Sparc_TLS_IE_HI22
-  || TF == SparcMCExpr::VK_Sparc_TLS_LE_HIX22) &&
- "Invalid target flags for address operand on sethi");
-else if (MI->getOpcode() == SP::TLS_CALL)
-  assert((TF == SparcMCExpr::VK_Sparc_None
-  || TF == SparcMCExpr::VK_Sparc_TLS_GD_CALL
-  || TF == SparcMCExpr::VK_Sparc_TLS_LDM_CALL) &&
- "Cannot handle target flags on tls call address");
-else if (MI->getOpcode() == SP::TLS_ADDrr)
-  assert((TF == SparcMCExpr::VK_Sparc_TLS_GD_ADD
-  || TF == SparcMCExpr::VK_Sparc_TLS_LDM_ADD
-  || TF == SparcMCExpr::VK_Sparc_TLS_LDO_ADD
-  || TF == SparcMCExpr::VK_Sparc_TLS_IE_ADD) &&
- "Cannot handle target flags on add for TLS");
-else if (MI->getOpcode() == SP::TLS_LDrr)
-  assert(TF == SparcMCExpr::VK_Sparc_TLS_IE_LD &&
- "Cannot handle target flags on ld for TLS");
-else if (MI->getOpcode() == SP::TLS_LDXrr)
-  assert(TF == SparcMCExpr::VK_Sparc_TLS_IE_LDX &&
- "Cannot handle target flags on ldx for TLS");
-else if (MI->getOpcode() == SP::XORri)
-  assert((TF == SparcMCExpr::VK_Sparc_TLS_LDO_LOX10
-  || TF == SparcMCExpr::VK_Sparc_TLS_LE_LOX10) &&
- "Cannot handle target flags on xor for TLS");
-else
-  assert((TF == SparcMCExpr::VK_Sparc_LO
-  || TF == SparcMCExpr::VK_Sparc_M44
-  || TF == SparcMCExpr::VK_Sparc_L44
-  || TF == SparcMCExpr::VK_Sparc_HM
-  || TF == SparcMCExpr::VK_Sparc_TLS_GD_LO10
-  || TF == SparcMCExpr::VK_Sparc_TLS_LDM_LO10
-  || TF == SparcMCExpr::VK_Sparc_TLS_IE_LO10 ) &&
- "Invalid target flags for small address operand");
-  }
-#endif
-
-
   bool CloseParen = SparcMCExpr::printVariantKind(O, TF);
 
   switch (MO.getType()) {

diff  --git a/llvm/test/CodeGen/SPARC/inlineasm.ll 
b/llvm/test/CodeGen/SPARC/inlineasm.ll
index 14ea0a2a126027..e2853f03a002e6 100644
--- a/llvm/test/CodeGen/SPARC/inlineasm.ll
+++ b/llvm/test/CodeGen/SPARC/inlineasm.ll
@@ -152,3 +152,13 @@ define i64 @test_twinword(){
   %1 = tail call i64 asm sideeffect "rd %asr5, ${0:L} \0A\09 srlx ${0:L}, 32, 
${0:H}", "={i0}"()
   ret i64 %1
 }
+
+; CHECK-LABEL: test_symbol:
+; CHECK: ba,a brtarget
+define void @test_symbol() {
+Entry:
+  call void asm sideeffect "ba,a ${0}", "X"(ptr @brtarget)
+  unreachable
+}
+
+declare void @brtarget()



___
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] release/19.x: [SPARC] Remove assertions in printOperand for inline asm operands (#104692) (PR #105096)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/105096
___
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] Add AIX and PPC Clang/LLVM release notes for LLVM 19. (PR #105099)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/105099

>From 6420a2ea06b6fc21547907eb447035be3e2b6b16 Mon Sep 17 00:00:00 2001
From: Amy Kwan 
Date: Tue, 20 Aug 2024 10:30:09 -0500
Subject: [PATCH] Add AIX/PPC Clang/LLVM release notes for LLVM 19.

---
 clang/docs/ReleaseNotes.rst | 17 +
 llvm/docs/ReleaseNotes.rst  | 14 ++
 2 files changed, 31 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 17ddbfe910f878..b68b823ae6761d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1276,6 +1276,14 @@ RISC-V Support
   accesses may be created. ``-m[no-]strict-align`` applies to both scalar and
   vector.
 
+PowerPC Support
+^^^
+
+- Clang now emits errors for impossible ``__attribute__((musttail))``.
+- Added support for ``-mcpu=[pwr11 | power11]`` and ``-mtune=[pwr11 | 
power11]``.
+- Added support for ``builtin_cpu_supports`` on AIX, along with a subset of
+  features that can be queried.
+
 CUDA/HIP Language Changes
 ^
 
@@ -1294,6 +1302,14 @@ AIX Support
   base is encoded as an immediate operand.
   This access sequence is not used for TLS variables larger than 32KB, and is
   currently only supported on 64-bit mode.
+- Introduced the options ``-mtocdata/-mno-tocdata`` to enable/disable TOC data
+  transformations for the listed suitable variables.
+- Introduced the ``-maix-shared-lib-tls-model-opt`` option to enable the tuning
+  of changing local-dynamic mode access(es) to initial-exec access(es) at the
+  function level on 64-bit mode.
+- Clang now emits errors for ``-gdwarf-5``.
+- Added the support of the OpenMP runtime libomp on AIX. OpenMP applications 
can be
+  compiled with ``-fopenmp`` and execute on AIX.
 
 NetBSD Support
 ^^
@@ -1451,6 +1467,7 @@ OpenMP Support
 --
 
 - Added support for the `[[omp::assume]]` attribute.
+- AIX added an include directory for ``omp.h`` at 
``/opt/IBM/openxlCSDK/include/openmp``.
 
 Additional Information
 ==
diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 60b6c6e786df89..ac7bdf723a168d 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -113,6 +113,8 @@ Changes to TableGen
 Changes to Interprocedural Optimizations
 
 
+* Hot cold region splitting analysis improvements for overlapping cold regions.
+
 Changes to the AArch64 Backend
 --
 
@@ -194,6 +196,16 @@ Changes to the MIPS Backend
 Changes to the PowerPC Backend
 --
 
+* PPC big-endian Linux now supports ``-fpatchable-function-entry``.
+* PPC AIX now supports local-dynamic TLS mode.
+* PPC AIX saves the Git revision in binaries when built with 
LLVM_APPEND_VC_REV=ON.
+* PPC AIX now supports toc-data attribute for large code model.
+* PPC AIX now supports passing arguments by value having greater alignment than
+  the pointer size. Currently only compatible with the IBM XL C compiler.
+* Add support for the per global code model attribute on AIX.
+* Support spilling non-volatile registers for traceback table accuracy on AIX.
+* Codegen improvements and bug fixes.
+
 Changes to the RISC-V Backend
 -
 
@@ -436,6 +448,8 @@ Changes to the LLVM tools
   be disabled by ``--no-verify-note-sections``. (`#90458
   `).
 
+* llvm-objdump now supports the ``--file-headers`` option for XCOFF object 
files.
+
 Changes to LLDB
 -
 

___
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] 6420a2e - Add AIX/PPC Clang/LLVM release notes for LLVM 19.

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

Author: Amy Kwan
Date: 2024-08-26T09:11:14+02:00
New Revision: 6420a2ea06b6fc21547907eb447035be3e2b6b16

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

LOG: Add AIX/PPC Clang/LLVM release notes for LLVM 19.

Added: 


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

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 17ddbfe910f878..b68b823ae6761d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1276,6 +1276,14 @@ RISC-V Support
   accesses may be created. ``-m[no-]strict-align`` applies to both scalar and
   vector.
 
+PowerPC Support
+^^^
+
+- Clang now emits errors for impossible ``__attribute__((musttail))``.
+- Added support for ``-mcpu=[pwr11 | power11]`` and ``-mtune=[pwr11 | 
power11]``.
+- Added support for ``builtin_cpu_supports`` on AIX, along with a subset of
+  features that can be queried.
+
 CUDA/HIP Language Changes
 ^
 
@@ -1294,6 +1302,14 @@ AIX Support
   base is encoded as an immediate operand.
   This access sequence is not used for TLS variables larger than 32KB, and is
   currently only supported on 64-bit mode.
+- Introduced the options ``-mtocdata/-mno-tocdata`` to enable/disable TOC data
+  transformations for the listed suitable variables.
+- Introduced the ``-maix-shared-lib-tls-model-opt`` option to enable the tuning
+  of changing local-dynamic mode access(es) to initial-exec access(es) at the
+  function level on 64-bit mode.
+- Clang now emits errors for ``-gdwarf-5``.
+- Added the support of the OpenMP runtime libomp on AIX. OpenMP applications 
can be
+  compiled with ``-fopenmp`` and execute on AIX.
 
 NetBSD Support
 ^^
@@ -1451,6 +1467,7 @@ OpenMP Support
 --
 
 - Added support for the `[[omp::assume]]` attribute.
+- AIX added an include directory for ``omp.h`` at 
``/opt/IBM/openxlCSDK/include/openmp``.
 
 Additional Information
 ==

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 60b6c6e786df89..ac7bdf723a168d 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -113,6 +113,8 @@ Changes to TableGen
 Changes to Interprocedural Optimizations
 
 
+* Hot cold region splitting analysis improvements for overlapping cold regions.
+
 Changes to the AArch64 Backend
 --
 
@@ -194,6 +196,16 @@ Changes to the MIPS Backend
 Changes to the PowerPC Backend
 --
 
+* PPC big-endian Linux now supports ``-fpatchable-function-entry``.
+* PPC AIX now supports local-dynamic TLS mode.
+* PPC AIX saves the Git revision in binaries when built with 
LLVM_APPEND_VC_REV=ON.
+* PPC AIX now supports toc-data attribute for large code model.
+* PPC AIX now supports passing arguments by value having greater alignment than
+  the pointer size. Currently only compatible with the IBM XL C compiler.
+* Add support for the per global code model attribute on AIX.
+* Support spilling non-volatile registers for traceback table accuracy on AIX.
+* Codegen improvements and bug fixes.
+
 Changes to the RISC-V Backend
 -
 
@@ -436,6 +448,8 @@ Changes to the LLVM tools
   be disabled by ``--no-verify-note-sections``. (`#90458
   `).
 
+* llvm-objdump now supports the ``--file-headers`` option for XCOFF object 
files.
+
 Changes to LLDB
 -
 



___
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] Add AIX and PPC Clang/LLVM release notes for LLVM 19. (PR #105099)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/105099
___
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] release/19.x: [SPARC] Remove assertions in printOperand for inline asm operands (#104692) (PR #105096)

2024-08-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@s-barannikov (or anyone else). If you would like to add a note about this fix 
in the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/105096
___
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] use default intrinsic attrs for BPF packet loads (PR #105314)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/105314

>From 38f3dbefab0a4965abad99aa23eced96d5d8dc16 Mon Sep 17 00:00:00 2001
From: Bryce Kahle 
Date: Tue, 20 Aug 2024 12:25:33 -0700
Subject: [PATCH] use default intrinsic attrs for BPF packet loads

The BPF packet load intrinsics lost attribute WillReturn due to 0b20c30. The 
attribute loss causes excessive bitshifting, resulting in previously working 
programs failing the BPF verifier due to instruction/complexity limits.

cherry picked only the BPF changes from 99a10f1

Signed-off-by: Bryce Kahle 
---
 llvm/include/llvm/IR/IntrinsicsBPF.td  |  6 ++--
 llvm/test/CodeGen/BPF/sockex2.ll   |  2 +-
 llvm/test/Transforms/DCE/intrinsics-bpf.ll | 33 ++
 3 files changed, 37 insertions(+), 4 deletions(-)
 create mode 100644 llvm/test/Transforms/DCE/intrinsics-bpf.ll

diff --git a/llvm/include/llvm/IR/IntrinsicsBPF.td 
b/llvm/include/llvm/IR/IntrinsicsBPF.td
index c7ec0916f1d1f8..d02eaa6d0dff69 100644
--- a/llvm/include/llvm/IR/IntrinsicsBPF.td
+++ b/llvm/include/llvm/IR/IntrinsicsBPF.td
@@ -13,11 +13,11 @@
 // Specialized loads from packet
 let TargetPrefix = "bpf" in {  // All intrinsics start with "llvm.bpf."
   def int_bpf_load_byte : ClangBuiltin<"__builtin_bpf_load_byte">,
-  Intrinsic<[llvm_i64_ty], [llvm_ptr_ty, llvm_i64_ty], 
[IntrReadMem]>;
+  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_ptr_ty, llvm_i64_ty], 
[IntrReadMem]>;
   def int_bpf_load_half : ClangBuiltin<"__builtin_bpf_load_half">,
-  Intrinsic<[llvm_i64_ty], [llvm_ptr_ty, llvm_i64_ty], 
[IntrReadMem]>;
+  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_ptr_ty, llvm_i64_ty], 
[IntrReadMem]>;
   def int_bpf_load_word : ClangBuiltin<"__builtin_bpf_load_word">,
-  Intrinsic<[llvm_i64_ty], [llvm_ptr_ty, llvm_i64_ty], 
[IntrReadMem]>;
+  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_ptr_ty, llvm_i64_ty], 
[IntrReadMem]>;
   def int_bpf_pseudo : ClangBuiltin<"__builtin_bpf_pseudo">,
   Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty]>;
   def int_bpf_preserve_field_info : 
ClangBuiltin<"__builtin_bpf_preserve_field_info">,
diff --git a/llvm/test/CodeGen/BPF/sockex2.ll b/llvm/test/CodeGen/BPF/sockex2.ll
index 4131d9dac31d88..b1264099f64c60 100644
--- a/llvm/test/CodeGen/BPF/sockex2.ll
+++ b/llvm/test/CodeGen/BPF/sockex2.ll
@@ -311,7 +311,7 @@ flow_dissector.exit.thread:   ; preds = 
%86, %12, %196, %199
 ; CHECK-LABEL: bpf_prog2:
 ; CHECK: r0 = *(u16 *)skb[12] # encoding: 
[0x28,0x00,0x00,0x00,0x0c,0x00,0x00,0x00]
 ; CHECK: r0 = *(u16 *)skb[16] # encoding: 
[0x28,0x00,0x00,0x00,0x10,0x00,0x00,0x00]
-; CHECK: implicit-def: $r8
+; CHECK: implicit-def: $r7
 ; CHECK: r1 =
 ; CHECK: call 1 # encoding: [0x85,0x00,0x00,0x00,0x01,0x00,0x00,0x00]
 ; CHECK: call 2 # encoding: [0x85,0x00,0x00,0x00,0x02,0x00,0x00,0x00]
diff --git a/llvm/test/Transforms/DCE/intrinsics-bpf.ll 
b/llvm/test/Transforms/DCE/intrinsics-bpf.ll
new file mode 100644
index 00..135588ba21cbb1
--- /dev/null
+++ b/llvm/test/Transforms/DCE/intrinsics-bpf.ll
@@ -0,0 +1,33 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 5
+; RUN: opt -S < %s -passes=dce  | FileCheck %s
+
+declare i64 @llvm.bpf.load.half(ptr, i64)
+declare i64 @llvm.bpf.load.word(ptr, i64)
+declare i64 @llvm.bpf.load.byte(ptr, i64)
+
+define void @test_bpf_load_half(ptr %a, i64 %b) {
+; CHECK-LABEL: define void @test_bpf_load_half(
+; CHECK-SAME: ptr [[A:%.*]], i64 [[B:%.*]]) {
+; CHECK-NEXT:ret void
+;
+  %v = call i64 @llvm.bpf.load.half(ptr %a, i64 %b)
+  ret void
+}
+
+define void @test_bpf_load_word(ptr %a, i64 %b) {
+; CHECK-LABEL: define void @test_bpf_load_word(
+; CHECK-SAME: ptr [[A:%.*]], i64 [[B:%.*]]) {
+; CHECK-NEXT:ret void
+;
+  %v = call i64 @llvm.bpf.load.word(ptr %a, i64 %b)
+  ret void
+}
+
+define void @test_bpf_load_byte(ptr %a, i64 %b) {
+; CHECK-LABEL: define void @test_bpf_load_byte(
+; CHECK-SAME: ptr [[A:%.*]], i64 [[B:%.*]]) {
+; CHECK-NEXT:ret void
+;
+  %v = call i64 @llvm.bpf.load.byte(ptr %a, i64 %b)
+  ret void
+}

___
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] 38f3dbe - use default intrinsic attrs for BPF packet loads

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

Author: Bryce Kahle
Date: 2024-08-26T09:11:33+02:00
New Revision: 38f3dbefab0a4965abad99aa23eced96d5d8dc16

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

LOG: use default intrinsic attrs for BPF packet loads

The BPF packet load intrinsics lost attribute WillReturn due to 0b20c30. The 
attribute loss causes excessive bitshifting, resulting in previously working 
programs failing the BPF verifier due to instruction/complexity limits.

cherry picked only the BPF changes from 99a10f1

Signed-off-by: Bryce Kahle 

Added: 
llvm/test/Transforms/DCE/intrinsics-bpf.ll

Modified: 
llvm/include/llvm/IR/IntrinsicsBPF.td
llvm/test/CodeGen/BPF/sockex2.ll

Removed: 




diff  --git a/llvm/include/llvm/IR/IntrinsicsBPF.td 
b/llvm/include/llvm/IR/IntrinsicsBPF.td
index c7ec0916f1d1f8..d02eaa6d0dff69 100644
--- a/llvm/include/llvm/IR/IntrinsicsBPF.td
+++ b/llvm/include/llvm/IR/IntrinsicsBPF.td
@@ -13,11 +13,11 @@
 // Specialized loads from packet
 let TargetPrefix = "bpf" in {  // All intrinsics start with "llvm.bpf."
   def int_bpf_load_byte : ClangBuiltin<"__builtin_bpf_load_byte">,
-  Intrinsic<[llvm_i64_ty], [llvm_ptr_ty, llvm_i64_ty], 
[IntrReadMem]>;
+  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_ptr_ty, llvm_i64_ty], 
[IntrReadMem]>;
   def int_bpf_load_half : ClangBuiltin<"__builtin_bpf_load_half">,
-  Intrinsic<[llvm_i64_ty], [llvm_ptr_ty, llvm_i64_ty], 
[IntrReadMem]>;
+  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_ptr_ty, llvm_i64_ty], 
[IntrReadMem]>;
   def int_bpf_load_word : ClangBuiltin<"__builtin_bpf_load_word">,
-  Intrinsic<[llvm_i64_ty], [llvm_ptr_ty, llvm_i64_ty], 
[IntrReadMem]>;
+  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_ptr_ty, llvm_i64_ty], 
[IntrReadMem]>;
   def int_bpf_pseudo : ClangBuiltin<"__builtin_bpf_pseudo">,
   Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty]>;
   def int_bpf_preserve_field_info : 
ClangBuiltin<"__builtin_bpf_preserve_field_info">,

diff  --git a/llvm/test/CodeGen/BPF/sockex2.ll 
b/llvm/test/CodeGen/BPF/sockex2.ll
index 4131d9dac31d88..b1264099f64c60 100644
--- a/llvm/test/CodeGen/BPF/sockex2.ll
+++ b/llvm/test/CodeGen/BPF/sockex2.ll
@@ -311,7 +311,7 @@ flow_dissector.exit.thread:   ; preds = 
%86, %12, %196, %199
 ; CHECK-LABEL: bpf_prog2:
 ; CHECK: r0 = *(u16 *)skb[12] # encoding: 
[0x28,0x00,0x00,0x00,0x0c,0x00,0x00,0x00]
 ; CHECK: r0 = *(u16 *)skb[16] # encoding: 
[0x28,0x00,0x00,0x00,0x10,0x00,0x00,0x00]
-; CHECK: implicit-def: $r8
+; CHECK: implicit-def: $r7
 ; CHECK: r1 =
 ; CHECK: call 1 # encoding: [0x85,0x00,0x00,0x00,0x01,0x00,0x00,0x00]
 ; CHECK: call 2 # encoding: [0x85,0x00,0x00,0x00,0x02,0x00,0x00,0x00]

diff  --git a/llvm/test/Transforms/DCE/intrinsics-bpf.ll 
b/llvm/test/Transforms/DCE/intrinsics-bpf.ll
new file mode 100644
index 00..135588ba21cbb1
--- /dev/null
+++ b/llvm/test/Transforms/DCE/intrinsics-bpf.ll
@@ -0,0 +1,33 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 5
+; RUN: opt -S < %s -passes=dce  | FileCheck %s
+
+declare i64 @llvm.bpf.load.half(ptr, i64)
+declare i64 @llvm.bpf.load.word(ptr, i64)
+declare i64 @llvm.bpf.load.byte(ptr, i64)
+
+define void @test_bpf_load_half(ptr %a, i64 %b) {
+; CHECK-LABEL: define void @test_bpf_load_half(
+; CHECK-SAME: ptr [[A:%.*]], i64 [[B:%.*]]) {
+; CHECK-NEXT:ret void
+;
+  %v = call i64 @llvm.bpf.load.half(ptr %a, i64 %b)
+  ret void
+}
+
+define void @test_bpf_load_word(ptr %a, i64 %b) {
+; CHECK-LABEL: define void @test_bpf_load_word(
+; CHECK-SAME: ptr [[A:%.*]], i64 [[B:%.*]]) {
+; CHECK-NEXT:ret void
+;
+  %v = call i64 @llvm.bpf.load.word(ptr %a, i64 %b)
+  ret void
+}
+
+define void @test_bpf_load_byte(ptr %a, i64 %b) {
+; CHECK-LABEL: define void @test_bpf_load_byte(
+; CHECK-SAME: ptr [[A:%.*]], i64 [[B:%.*]]) {
+; CHECK-NEXT:ret void
+;
+  %v = call i64 @llvm.bpf.load.byte(ptr %a, i64 %b)
+  ret void
+}



___
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] use default intrinsic attrs for BPF packet loads (PR #105314)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/105314
___
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] Add AIX and PPC Clang/LLVM release notes for LLVM 19. (PR #105099)

2024-08-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@amy-kwan (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/105099
___
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] use default intrinsic attrs for BPF packet loads (PR #105314)

2024-08-26 Thread via llvm-branch-commits

github-actions[bot] wrote:



@brycekahle Congratulations on having your first Pull Request (PR) merged into 
the LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a 
problem with a build, you may receive a report in an email or a comment on this 
PR.

Please check whether problems have been caused by your change specifically, as 
the builds can include changes from many authors. It is not uncommon for your 
change to be included in a build that fails due to someone else's changes, or 
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself. This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


https://github.com/llvm/llvm-project/pull/105314
___
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] release/19.x: [AMDGPU] Disable inline constants for pseudo scalar transcendentals (#104395) (PR #105472)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/105472

>From 43b455b2d2e5107e19d7d47e77ba513d1f9f5e2f Mon Sep 17 00:00:00 2001
From: Carl Ritson 
Date: Sat, 17 Aug 2024 16:52:38 +0900
Subject: [PATCH] [AMDGPU] Disable inline constants for pseudo scalar
 transcendentals (#104395)

Prevent operand folding from inlining constants into pseudo scalar
transcendental f16 instructions.
However still allow literal constants.

(cherry picked from commit fc6300a5f7ef430e4ec86d16be0b146de7fbd16b)
---
 llvm/lib/Target/AMDGPU/GCNSubtarget.h |   6 +
 llvm/lib/Target/AMDGPU/SIInstrInfo.cpp|   4 +
 llvm/lib/Target/AMDGPU/SIInstrInfo.h  |   8 ++
 .../AMDGPU/pseudo-scalar-transcendental.mir   | 120 ++
 4 files changed, 138 insertions(+)
 create mode 100644 llvm/test/CodeGen/AMDGPU/pseudo-scalar-transcendental.mir

diff --git a/llvm/lib/Target/AMDGPU/GCNSubtarget.h 
b/llvm/lib/Target/AMDGPU/GCNSubtarget.h
index def89c785b8552..902f51ae358d59 100644
--- a/llvm/lib/Target/AMDGPU/GCNSubtarget.h
+++ b/llvm/lib/Target/AMDGPU/GCNSubtarget.h
@@ -1289,6 +1289,12 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
   /// and STOREcnt rather than VMcnt, LGKMcnt and VScnt respectively.
   bool hasExtendedWaitCounts() const { return getGeneration() >= GFX12; }
 
+  /// \returns true if inline constants are not supported for F16 pseudo
+  /// scalar transcendentals.
+  bool hasNoF16PseudoScalarTransInlineConstants() const {
+return getGeneration() == GFX12;
+  }
+
   /// \returns The maximum number of instructions that can be enclosed in an
   /// S_CLAUSE on the given subtarget, or 0 for targets that do not support 
that
   /// instruction.
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp 
b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index 463737f645d459..27b8c1b17422af 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -5768,6 +5768,10 @@ bool SIInstrInfo::isOperandLegal(const MachineInstr &MI, 
unsigned OpIdx,
   return false;
   }
 }
+  } else if (ST.hasNoF16PseudoScalarTransInlineConstants() && !MO->isReg() &&
+ isF16PseudoScalarTrans(MI.getOpcode()) &&
+ isInlineConstant(*MO, OpInfo)) {
+return false;
   }
 
   if (MO->isReg()) {
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.h 
b/llvm/lib/Target/AMDGPU/SIInstrInfo.h
index 1712dfe8d406cc..91855fb14f6f37 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.h
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.h
@@ -946,6 +946,14 @@ class SIInstrInfo final : public AMDGPUGenInstrInfo {
Opcode == AMDGPU::DS_GWS_BARRIER;
   }
 
+  static bool isF16PseudoScalarTrans(unsigned Opcode) {
+return Opcode == AMDGPU::V_S_EXP_F16_e64 ||
+   Opcode == AMDGPU::V_S_LOG_F16_e64 ||
+   Opcode == AMDGPU::V_S_RCP_F16_e64 ||
+   Opcode == AMDGPU::V_S_RSQ_F16_e64 ||
+   Opcode == AMDGPU::V_S_SQRT_F16_e64;
+  }
+
   static bool doesNotReadTiedSource(const MachineInstr &MI) {
 return MI.getDesc().TSFlags & SIInstrFlags::TiedSourceNotRead;
   }
diff --git a/llvm/test/CodeGen/AMDGPU/pseudo-scalar-transcendental.mir 
b/llvm/test/CodeGen/AMDGPU/pseudo-scalar-transcendental.mir
new file mode 100644
index 00..17bed38bd046d7
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/pseudo-scalar-transcendental.mir
@@ -0,0 +1,120 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py 
UTC_ARGS: --version 5
+# RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx1200 -run-pass=si-fold-operands 
-verify-machineinstrs -o - %s | FileCheck --check-prefix=GCN %s
+
+# Do not use inline constants for f16 pseudo scalar transcendentals.
+# But allow literal constants.
+
+---
+name: exp_f16_imm
+tracksRegLiveness: true
+body: |
+  bb.0:
+; GCN-LABEL: name: exp_f16_imm
+; GCN: [[S_MOV_B32_:%[0-9]+]]:sgpr_32 = S_MOV_B32 15360
+; GCN-NEXT: [[V_S_EXP_F16_e64_:%[0-9]+]]:sgpr_32 = V_S_EXP_F16_e64 1, 
[[S_MOV_B32_]], 0, 0, implicit $mode, implicit $exec
+%0:sgpr_32 = S_MOV_B32 15360
+%1:sgpr_32 = V_S_EXP_F16_e64 1, %0:sgpr_32, 0, 0, implicit $mode, implicit 
$exec
+...
+
+---
+name: exp_f16_literal
+tracksRegLiveness: true
+body: |
+  bb.0:
+; GCN-LABEL: name: exp_f16_literal
+; GCN: [[V_S_EXP_F16_e64_:%[0-9]+]]:sgpr_32 = V_S_EXP_F16_e64 1, 16960, 0, 
0, implicit $mode, implicit $exec
+%0:sgpr_32 = S_MOV_B32 16960
+%1:sgpr_32 = V_S_EXP_F16_e64 1, %0:sgpr_32, 0, 0, implicit $mode, implicit 
$exec
+...
+
+---
+name: log_f16_imm
+tracksRegLiveness: true
+body: |
+  bb.0:
+; GCN-LABEL: name: log_f16_imm
+; GCN: [[S_MOV_B32_:%[0-9]+]]:sgpr_32 = S_MOV_B32 15360
+; GCN-NEXT: [[V_S_LOG_F16_e64_:%[0-9]+]]:sgpr_32 = V_S_LOG_F16_e64 1, 
[[S_MOV_B32_]], 0, 0, implicit $mode, implicit $exec
+%0:sgpr_32 = S_MOV_B32 15360
+%1:sgpr_32 = V_S_LOG_F16_e64 1, %0:sgpr_32, 0, 0, implicit $mode, implicit 
$exec
+...
+
+---
+name: log_f16_literal
+tracksRegLiveness: true
+body:

[llvm-branch-commits] [llvm] 43b455b - [AMDGPU] Disable inline constants for pseudo scalar transcendentals (#104395)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

Author: Carl Ritson
Date: 2024-08-26T09:12:08+02:00
New Revision: 43b455b2d2e5107e19d7d47e77ba513d1f9f5e2f

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

LOG: [AMDGPU] Disable inline constants for pseudo scalar transcendentals 
(#104395)

Prevent operand folding from inlining constants into pseudo scalar
transcendental f16 instructions.
However still allow literal constants.

(cherry picked from commit fc6300a5f7ef430e4ec86d16be0b146de7fbd16b)

Added: 
llvm/test/CodeGen/AMDGPU/pseudo-scalar-transcendental.mir

Modified: 
llvm/lib/Target/AMDGPU/GCNSubtarget.h
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.h

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/GCNSubtarget.h 
b/llvm/lib/Target/AMDGPU/GCNSubtarget.h
index def89c785b8552..902f51ae358d59 100644
--- a/llvm/lib/Target/AMDGPU/GCNSubtarget.h
+++ b/llvm/lib/Target/AMDGPU/GCNSubtarget.h
@@ -1289,6 +1289,12 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
   /// and STOREcnt rather than VMcnt, LGKMcnt and VScnt respectively.
   bool hasExtendedWaitCounts() const { return getGeneration() >= GFX12; }
 
+  /// \returns true if inline constants are not supported for F16 pseudo
+  /// scalar transcendentals.
+  bool hasNoF16PseudoScalarTransInlineConstants() const {
+return getGeneration() == GFX12;
+  }
+
   /// \returns The maximum number of instructions that can be enclosed in an
   /// S_CLAUSE on the given subtarget, or 0 for targets that do not support 
that
   /// instruction.

diff  --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp 
b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index 463737f645d459..27b8c1b17422af 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -5768,6 +5768,10 @@ bool SIInstrInfo::isOperandLegal(const MachineInstr &MI, 
unsigned OpIdx,
   return false;
   }
 }
+  } else if (ST.hasNoF16PseudoScalarTransInlineConstants() && !MO->isReg() &&
+ isF16PseudoScalarTrans(MI.getOpcode()) &&
+ isInlineConstant(*MO, OpInfo)) {
+return false;
   }
 
   if (MO->isReg()) {

diff  --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.h 
b/llvm/lib/Target/AMDGPU/SIInstrInfo.h
index 1712dfe8d406cc..91855fb14f6f37 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.h
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.h
@@ -946,6 +946,14 @@ class SIInstrInfo final : public AMDGPUGenInstrInfo {
Opcode == AMDGPU::DS_GWS_BARRIER;
   }
 
+  static bool isF16PseudoScalarTrans(unsigned Opcode) {
+return Opcode == AMDGPU::V_S_EXP_F16_e64 ||
+   Opcode == AMDGPU::V_S_LOG_F16_e64 ||
+   Opcode == AMDGPU::V_S_RCP_F16_e64 ||
+   Opcode == AMDGPU::V_S_RSQ_F16_e64 ||
+   Opcode == AMDGPU::V_S_SQRT_F16_e64;
+  }
+
   static bool doesNotReadTiedSource(const MachineInstr &MI) {
 return MI.getDesc().TSFlags & SIInstrFlags::TiedSourceNotRead;
   }

diff  --git a/llvm/test/CodeGen/AMDGPU/pseudo-scalar-transcendental.mir 
b/llvm/test/CodeGen/AMDGPU/pseudo-scalar-transcendental.mir
new file mode 100644
index 00..17bed38bd046d7
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/pseudo-scalar-transcendental.mir
@@ -0,0 +1,120 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py 
UTC_ARGS: --version 5
+# RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx1200 -run-pass=si-fold-operands 
-verify-machineinstrs -o - %s | FileCheck --check-prefix=GCN %s
+
+# Do not use inline constants for f16 pseudo scalar transcendentals.
+# But allow literal constants.
+
+---
+name: exp_f16_imm
+tracksRegLiveness: true
+body: |
+  bb.0:
+; GCN-LABEL: name: exp_f16_imm
+; GCN: [[S_MOV_B32_:%[0-9]+]]:sgpr_32 = S_MOV_B32 15360
+; GCN-NEXT: [[V_S_EXP_F16_e64_:%[0-9]+]]:sgpr_32 = V_S_EXP_F16_e64 1, 
[[S_MOV_B32_]], 0, 0, implicit $mode, implicit $exec
+%0:sgpr_32 = S_MOV_B32 15360
+%1:sgpr_32 = V_S_EXP_F16_e64 1, %0:sgpr_32, 0, 0, implicit $mode, implicit 
$exec
+...
+
+---
+name: exp_f16_literal
+tracksRegLiveness: true
+body: |
+  bb.0:
+; GCN-LABEL: name: exp_f16_literal
+; GCN: [[V_S_EXP_F16_e64_:%[0-9]+]]:sgpr_32 = V_S_EXP_F16_e64 1, 16960, 0, 
0, implicit $mode, implicit $exec
+%0:sgpr_32 = S_MOV_B32 16960
+%1:sgpr_32 = V_S_EXP_F16_e64 1, %0:sgpr_32, 0, 0, implicit $mode, implicit 
$exec
+...
+
+---
+name: log_f16_imm
+tracksRegLiveness: true
+body: |
+  bb.0:
+; GCN-LABEL: name: log_f16_imm
+; GCN: [[S_MOV_B32_:%[0-9]+]]:sgpr_32 = S_MOV_B32 15360
+; GCN-NEXT: [[V_S_LOG_F16_e64_:%[0-9]+]]:sgpr_32 = V_S_LOG_F16_e64 1, 
[[S_MOV_B32_]], 0, 0, implicit $mode, implicit $exec
+%0:sgpr_32 = S_MOV_B32 15360
+%1:sgpr_32 = V_S_LOG_F16_e64 1, %0:sgpr_32, 0, 0, implicit $mode, implicit 
$exec
+...
+
+---
+name: log_f16_litera

[llvm-branch-commits] [llvm] release/19.x: [AMDGPU] Disable inline constants for pseudo scalar transcendentals (#104395) (PR #105472)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/105472
___
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] use default intrinsic attrs for BPF packet loads (PR #105314)

2024-08-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@brycekahle (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/105314
___
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] release/19.x: [AMDGPU] Disable inline constants for pseudo scalar transcendentals (#104395) (PR #105472)

2024-08-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@perlfu (or anyone else). If you would like to add a note about this fix in the 
release notes (completely optional). Please reply to this comment with a one or 
two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/105472
___
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] release/19.x: [PowerPC] Respect endianness when bitcasting to fp128 (#95931) (PR #105623)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

tru wrote:

@chenzheng1030 Hi! Thanks for the backport. What's the impact of this PR and is 
it a regression fix or a major issue fix? At this point in the release we don't 
want to be to  experimental. I would also love a review from someone with 
knowledge of the domain before I merge.

https://github.com/llvm/llvm-project/pull/105623
___
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] release/19.x: [DAGCombiner] Fix ReplaceAllUsesOfValueWith mutation bug in visitFREEZE (#104924) (PR #105627)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/105627

>From b6a562d90fa08543171bafbb9c897c03f6cf691f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Pettersson?= 
Date: Wed, 21 Aug 2024 17:56:27 +0200
Subject: [PATCH] [DAGCombiner] Fix ReplaceAllUsesOfValueWith mutation bug in
 visitFREEZE (#104924)

In visitFREEZE we have been collecting a set/vector of
MaybePoisonOperands that later was iterated over, applying a freeze to
those operands. However, C-level fuzzy testing has discovered that the
recursiveness of ReplaceAllUsesOfValueWith may cause later operands in
the MaybePoisonOperands vector to be replaced when replacing an earlier
operand. That would then turn up as
   Assertion `N1.getOpcode() != ISD::DELETED_NODE &&
  "Operand is DELETED_NODE!"' failed.
failures when trying to freeze those later operands.

So we need to make sure that the vector with MaybePoisonOperands is
mutated as well when needed. Or as the solution used in this patch, make
sure to keep track of operand numbers that should be frozen instead of
having a vector of SDValues. And then we can refetch the operands while
iterating over operand numbers.

The problem was seen after adding SELECT_CC to the set of operations
including in "AllowMultipleMaybePoisonOperands". I'm not sure, but I
guess that this could happen for other operations as well for which we
allow multiple maybe poison operands.

(cherry picked from commit 278fc8efdf004a1959a31bb4c208df5ee733d5c8)
---
 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 22 ++---
 .../CodeGen/AArch64/dag-combine-freeze.ll | 31 +++
 2 files changed, 49 insertions(+), 4 deletions(-)
 create mode 100644 llvm/test/CodeGen/AArch64/dag-combine-freeze.ll

diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index aa9032ea2574c4..71cdec91e5f67a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -15680,13 +15680,16 @@ SDValue DAGCombiner::visitFREEZE(SDNode *N) {
 }
   }
 
-  SmallSetVector MaybePoisonOperands;
-  for (SDValue Op : N0->ops()) {
+  SmallSet MaybePoisonOperands;
+  SmallVector MaybePoisonOperandNumbers;
+  for (auto [OpNo, Op] : enumerate(N0->ops())) {
 if (DAG.isGuaranteedNotToBeUndefOrPoison(Op, /*PoisonOnly*/ false,
  /*Depth*/ 1))
   continue;
 bool HadMaybePoisonOperands = !MaybePoisonOperands.empty();
-bool IsNewMaybePoisonOperand = MaybePoisonOperands.insert(Op);
+bool IsNewMaybePoisonOperand = MaybePoisonOperands.insert(Op).second;
+if (IsNewMaybePoisonOperand)
+  MaybePoisonOperandNumbers.push_back(OpNo);
 if (!HadMaybePoisonOperands)
   continue;
 if (IsNewMaybePoisonOperand && !AllowMultipleMaybePoisonOperands) {
@@ -15698,7 +15701,18 @@ SDValue DAGCombiner::visitFREEZE(SDNode *N) {
   // it could create undef or poison due to it's poison-generating flags.
   // So not finding any maybe-poison operands is fine.
 
-  for (SDValue MaybePoisonOperand : MaybePoisonOperands) {
+  for (unsigned OpNo : MaybePoisonOperandNumbers) {
+// N0 can mutate during iteration, so make sure to refetch the maybe poison
+// operands via the operand numbers. The typical scenario is that we have
+// something like this
+//   t262: i32 = freeze t181
+//   t150: i32 = ctlz_zero_undef t262
+//   t184: i32 = ctlz_zero_undef t181
+//   t268: i32 = select_cc t181, Constant:i32<0>, t184, t186, setne:ch
+// When freezing the t181 operand we get t262 back, and then the
+// ReplaceAllUsesOfValueWith call will not only replace t181 by t262, but
+// also recursively replace t184 by t150.
+SDValue MaybePoisonOperand = N->getOperand(0).getOperand(OpNo);
 // Don't replace every single UNDEF everywhere with frozen UNDEF, though.
 if (MaybePoisonOperand.getOpcode() == ISD::UNDEF)
   continue;
diff --git a/llvm/test/CodeGen/AArch64/dag-combine-freeze.ll 
b/llvm/test/CodeGen/AArch64/dag-combine-freeze.ll
new file mode 100644
index 00..4f0c3d0ce18006
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/dag-combine-freeze.ll
@@ -0,0 +1,31 @@
+; RUN: llc -mtriple aarch64 -o /dev/null %s
+
+; This used to fail with:
+;Assertion `N1.getOpcode() != ISD::DELETED_NODE &&
+;   "Operand is DELETED_NODE!"' failed.
+; Just make sure we do not crash here.
+define void @test_fold_freeze_over_select_cc(i15 %a, ptr %p1, ptr %p2) {
+entry:
+  %a2 = add nsw i15 %a, 1
+  %sext = sext i15 %a2 to i32
+  %ashr = ashr i32 %sext, 31
+  %lshr = lshr i32 %ashr, 7
+  ; Setup an already frozen input to ctlz.
+  %freeze = freeze i32 %lshr
+  %ctlz = call i32 @llvm.ctlz.i32(i32 %freeze, i1 true)
+  store i32 %ctlz, ptr %p1, align 1
+  ; Here is another ctlz, which is used by a frozen select.
+  ; DAGCombiner::visitFREEZE will to try to fold the freeze over a SELECT_CC,
+  ; and when dealing with 

[llvm-branch-commits] [llvm] b6a562d - [DAGCombiner] Fix ReplaceAllUsesOfValueWith mutation bug in visitFREEZE (#104924)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

Author: Björn Pettersson
Date: 2024-08-26T09:14:32+02:00
New Revision: b6a562d90fa08543171bafbb9c897c03f6cf691f

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

LOG: [DAGCombiner] Fix ReplaceAllUsesOfValueWith mutation bug in visitFREEZE 
(#104924)

In visitFREEZE we have been collecting a set/vector of
MaybePoisonOperands that later was iterated over, applying a freeze to
those operands. However, C-level fuzzy testing has discovered that the
recursiveness of ReplaceAllUsesOfValueWith may cause later operands in
the MaybePoisonOperands vector to be replaced when replacing an earlier
operand. That would then turn up as
   Assertion `N1.getOpcode() != ISD::DELETED_NODE &&
  "Operand is DELETED_NODE!"' failed.
failures when trying to freeze those later operands.

So we need to make sure that the vector with MaybePoisonOperands is
mutated as well when needed. Or as the solution used in this patch, make
sure to keep track of operand numbers that should be frozen instead of
having a vector of SDValues. And then we can refetch the operands while
iterating over operand numbers.

The problem was seen after adding SELECT_CC to the set of operations
including in "AllowMultipleMaybePoisonOperands". I'm not sure, but I
guess that this could happen for other operations as well for which we
allow multiple maybe poison operands.

(cherry picked from commit 278fc8efdf004a1959a31bb4c208df5ee733d5c8)

Added: 
llvm/test/CodeGen/AArch64/dag-combine-freeze.ll

Modified: 
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index aa9032ea2574c4..71cdec91e5f67a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -15680,13 +15680,16 @@ SDValue DAGCombiner::visitFREEZE(SDNode *N) {
 }
   }
 
-  SmallSetVector MaybePoisonOperands;
-  for (SDValue Op : N0->ops()) {
+  SmallSet MaybePoisonOperands;
+  SmallVector MaybePoisonOperandNumbers;
+  for (auto [OpNo, Op] : enumerate(N0->ops())) {
 if (DAG.isGuaranteedNotToBeUndefOrPoison(Op, /*PoisonOnly*/ false,
  /*Depth*/ 1))
   continue;
 bool HadMaybePoisonOperands = !MaybePoisonOperands.empty();
-bool IsNewMaybePoisonOperand = MaybePoisonOperands.insert(Op);
+bool IsNewMaybePoisonOperand = MaybePoisonOperands.insert(Op).second;
+if (IsNewMaybePoisonOperand)
+  MaybePoisonOperandNumbers.push_back(OpNo);
 if (!HadMaybePoisonOperands)
   continue;
 if (IsNewMaybePoisonOperand && !AllowMultipleMaybePoisonOperands) {
@@ -15698,7 +15701,18 @@ SDValue DAGCombiner::visitFREEZE(SDNode *N) {
   // it could create undef or poison due to it's poison-generating flags.
   // So not finding any maybe-poison operands is fine.
 
-  for (SDValue MaybePoisonOperand : MaybePoisonOperands) {
+  for (unsigned OpNo : MaybePoisonOperandNumbers) {
+// N0 can mutate during iteration, so make sure to refetch the maybe poison
+// operands via the operand numbers. The typical scenario is that we have
+// something like this
+//   t262: i32 = freeze t181
+//   t150: i32 = ctlz_zero_undef t262
+//   t184: i32 = ctlz_zero_undef t181
+//   t268: i32 = select_cc t181, Constant:i32<0>, t184, t186, setne:ch
+// When freezing the t181 operand we get t262 back, and then the
+// ReplaceAllUsesOfValueWith call will not only replace t181 by t262, but
+// also recursively replace t184 by t150.
+SDValue MaybePoisonOperand = N->getOperand(0).getOperand(OpNo);
 // Don't replace every single UNDEF everywhere with frozen UNDEF, though.
 if (MaybePoisonOperand.getOpcode() == ISD::UNDEF)
   continue;

diff  --git a/llvm/test/CodeGen/AArch64/dag-combine-freeze.ll 
b/llvm/test/CodeGen/AArch64/dag-combine-freeze.ll
new file mode 100644
index 00..4f0c3d0ce18006
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/dag-combine-freeze.ll
@@ -0,0 +1,31 @@
+; RUN: llc -mtriple aarch64 -o /dev/null %s
+
+; This used to fail with:
+;Assertion `N1.getOpcode() != ISD::DELETED_NODE &&
+;   "Operand is DELETED_NODE!"' failed.
+; Just make sure we do not crash here.
+define void @test_fold_freeze_over_select_cc(i15 %a, ptr %p1, ptr %p2) {
+entry:
+  %a2 = add nsw i15 %a, 1
+  %sext = sext i15 %a2 to i32
+  %ashr = ashr i32 %sext, 31
+  %lshr = lshr i32 %ashr, 7
+  ; Setup an already frozen input to ctlz.
+  %freeze = freeze i32 %lshr
+  %ctlz = call i32 @llvm.ctlz.i32(i32 %freeze, i1 true)
+  store i32 %ctlz, ptr %p1, align 1
+  ; Here is another ctlz, which is used by a frozen select.
+  ; DAGCombiner::visitFREEZE will to try to fold the freeze over a SELECT_CC,
+  ; and

[llvm-branch-commits] [llvm] release/19.x: [DAGCombiner] Fix ReplaceAllUsesOfValueWith mutation bug in visitFREEZE (#104924) (PR #105627)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/105627
___
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/19.x: [X86] Use correct fp immediate types in _mm_set_ss/sd (PR #105638)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/105638

>From 691d91dfc45a7123f3cb9f1b1d1c3b678230aa4f Mon Sep 17 00:00:00 2001
From: Simon Pilgrim 
Date: Tue, 20 Aug 2024 11:11:33 +0100
Subject: [PATCH 1/2] [X86] Add clang codegen test coverage for #104848

(cherry picked from commit 3b49d274e6f16d1c8db5f4557eb7866a4bafffa5)
---
 clang/test/CodeGen/X86/strictfp_patterns.c | 32 ++
 1 file changed, 32 insertions(+)
 create mode 100644 clang/test/CodeGen/X86/strictfp_patterns.c

diff --git a/clang/test/CodeGen/X86/strictfp_patterns.c 
b/clang/test/CodeGen/X86/strictfp_patterns.c
new file mode 100644
index 00..fd1ecdb262d812
--- /dev/null
+++ b/clang/test/CodeGen/X86/strictfp_patterns.c
@@ -0,0 +1,32 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 %s -O2 -emit-llvm -o - -triple x86_64-unknown-unknown 
-ffreestanding -ffp-exception-behavior=maytrap -Wall -Werror | FileCheck %s
+
+#include 
+
+// TODO: PR104848 - ensure the _mm_set_ss/d headers don't implicity promote 
any integer/fp values.
+
+// CHECK-LABEL: @test_mm_set_ss(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VECINIT_I:%.*]] = insertelement <4 x float> poison, float 
[[NUM:%.*]], i64 0
+// CHECK-NEXT:[[CONV_I:%.*]] = tail call float 
@llvm.experimental.constrained.sitofp.f32.i32(i32 0, metadata 
!"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR2:[0-9]+]]
+// CHECK-NEXT:[[VECINIT1_I:%.*]] = insertelement <4 x float> 
[[VECINIT_I]], float [[CONV_I]], i64 1
+// CHECK-NEXT:[[VECINIT3_I:%.*]] = insertelement <4 x float> 
[[VECINIT1_I]], float [[CONV_I]], i64 2
+// CHECK-NEXT:[[VECINIT5_I:%.*]] = insertelement <4 x float> 
[[VECINIT3_I]], float [[CONV_I]], i64 3
+// CHECK-NEXT:ret <4 x float> [[VECINIT5_I]]
+//
+__m128 test_mm_set_ss(float num)
+{
+return _mm_set_ss(num);
+}
+
+// CHECK-LABEL: @test_mm_set_sd(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VECINIT_I:%.*]] = insertelement <2 x double> poison, 
double [[NUM:%.*]], i64 0
+// CHECK-NEXT:[[CONV_I:%.*]] = tail call double 
@llvm.experimental.constrained.sitofp.f64.i32(i32 0, metadata 
!"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR2]]
+// CHECK-NEXT:[[VECINIT1_I:%.*]] = insertelement <2 x double> 
[[VECINIT_I]], double [[CONV_I]], i64 1
+// CHECK-NEXT:ret <2 x double> [[VECINIT1_I]]
+//
+__m128d test_mm_set_sd(double num)
+{
+return _mm_set_sd(num);
+}

>From 9b89fdaee3104abe9886bf08914029b5d9632121 Mon Sep 17 00:00:00 2001
From: Simon Pilgrim 
Date: Tue, 20 Aug 2024 11:51:18 +0100
Subject: [PATCH 2/2] [X86] Use correct fp immediate types in _mm_set_ss/sd

Avoids implicit sint_to_fp which wasn't occurring on strict fp codegen

Fixes #104848

(cherry picked from commit 6dcce422ca06601f2b00e85cc18c745ede245ca6)
---
 clang/lib/Headers/emmintrin.h  |  2 +-
 clang/lib/Headers/xmmintrin.h  |  2 +-
 clang/test/CodeGen/X86/strictfp_patterns.c | 14 --
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/clang/lib/Headers/emmintrin.h b/clang/lib/Headers/emmintrin.h
index e85bfc47aa5cce..4dff6421350c00 100644
--- a/clang/lib/Headers/emmintrin.h
+++ b/clang/lib/Headers/emmintrin.h
@@ -1771,7 +1771,7 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS 
_mm_undefined_pd(void) {
 ///lower 64 bits contain the value of the parameter. The upper 64 bits are
 ///set to zero.
 static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_set_sd(double __w) {
-  return __extension__(__m128d){__w, 0};
+  return __extension__(__m128d){__w, 0.0};
 }
 
 /// Constructs a 128-bit floating-point vector of [2 x double], with each
diff --git a/clang/lib/Headers/xmmintrin.h b/clang/lib/Headers/xmmintrin.h
index 1ef89de9c9f562..6fb27297af9279 100644
--- a/clang/lib/Headers/xmmintrin.h
+++ b/clang/lib/Headers/xmmintrin.h
@@ -1910,7 +1910,7 @@ _mm_undefined_ps(void)
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_set_ss(float __w)
 {
-  return __extension__ (__m128){ __w, 0, 0, 0 };
+  return __extension__ (__m128){ __w, 0.0f, 0.0f, 0.0f };
 }
 
 /// Constructs a 128-bit floating-point vector of [4 x float], with each
diff --git a/clang/test/CodeGen/X86/strictfp_patterns.c 
b/clang/test/CodeGen/X86/strictfp_patterns.c
index fd1ecdb262d812..55d85f22c3ba3d 100644
--- a/clang/test/CodeGen/X86/strictfp_patterns.c
+++ b/clang/test/CodeGen/X86/strictfp_patterns.c
@@ -3,16 +3,12 @@
 
 #include 
 
-// TODO: PR104848 - ensure the _mm_set_ss/d headers don't implicity promote 
any integer/fp values.
+// PR104848 - ensure the _mm_set_ss/d headers don't implicity promote any 
integer/fp values.
 
 // CHECK-LABEL: @test_mm_set_ss(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[VECINIT_I:%.*]] = insertelement <4 x float> poison, float 
[[NUM:%.*]], i64 0
-// CHECK-NEXT:[[CONV_I:%.*]] = tail call float 
@llvm.experimental.constrained.sitofp.f32.i32(i32 0, metadata 
!"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR2:[0-9]+]]
-// C

[llvm-branch-commits] [clang] release/19.x: [X86] Use correct fp immediate types in _mm_set_ss/sd (PR #105638)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/105638

>From 1503d18171e569996bf3e107364b1f0fd5f750e9 Mon Sep 17 00:00:00 2001
From: Simon Pilgrim 
Date: Tue, 20 Aug 2024 11:11:33 +0100
Subject: [PATCH] [X86] Use correct fp immediate types in _mm_set_ss/sd

Avoids implicit sint_to_fp which wasn't occurring on strict fp codegen

Fixes #104848

(cherry picked from commit 6dcce422ca06601f2b00e85cc18c745ede245ca6)
---
 clang/lib/Headers/emmintrin.h  |  2 +-
 clang/lib/Headers/xmmintrin.h  |  2 +-
 clang/test/CodeGen/X86/strictfp_patterns.c | 26 ++
 3 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/CodeGen/X86/strictfp_patterns.c

diff --git a/clang/lib/Headers/emmintrin.h b/clang/lib/Headers/emmintrin.h
index e85bfc47aa5cce..4dff6421350c00 100644
--- a/clang/lib/Headers/emmintrin.h
+++ b/clang/lib/Headers/emmintrin.h
@@ -1771,7 +1771,7 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS 
_mm_undefined_pd(void) {
 ///lower 64 bits contain the value of the parameter. The upper 64 bits are
 ///set to zero.
 static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_set_sd(double __w) {
-  return __extension__(__m128d){__w, 0};
+  return __extension__(__m128d){__w, 0.0};
 }
 
 /// Constructs a 128-bit floating-point vector of [2 x double], with each
diff --git a/clang/lib/Headers/xmmintrin.h b/clang/lib/Headers/xmmintrin.h
index 1ef89de9c9f562..6fb27297af9279 100644
--- a/clang/lib/Headers/xmmintrin.h
+++ b/clang/lib/Headers/xmmintrin.h
@@ -1910,7 +1910,7 @@ _mm_undefined_ps(void)
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_set_ss(float __w)
 {
-  return __extension__ (__m128){ __w, 0, 0, 0 };
+  return __extension__ (__m128){ __w, 0.0f, 0.0f, 0.0f };
 }
 
 /// Constructs a 128-bit floating-point vector of [4 x float], with each
diff --git a/clang/test/CodeGen/X86/strictfp_patterns.c 
b/clang/test/CodeGen/X86/strictfp_patterns.c
new file mode 100644
index 00..55d85f22c3ba3d
--- /dev/null
+++ b/clang/test/CodeGen/X86/strictfp_patterns.c
@@ -0,0 +1,26 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 %s -O2 -emit-llvm -o - -triple x86_64-unknown-unknown 
-ffreestanding -ffp-exception-behavior=maytrap -Wall -Werror | FileCheck %s
+
+#include 
+
+// PR104848 - ensure the _mm_set_ss/d headers don't implicity promote any 
integer/fp values.
+
+// CHECK-LABEL: @test_mm_set_ss(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VECINIT3_I:%.*]] = insertelement <4 x float> , float 
[[NUM:%.*]], i64 0
+// CHECK-NEXT:ret <4 x float> [[VECINIT3_I]]
+//
+__m128 test_mm_set_ss(float num)
+{
+return _mm_set_ss(num);
+}
+
+// CHECK-LABEL: @test_mm_set_sd(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VECINIT1_I:%.*]] = insertelement <2 x double> , double [[NUM:%.*]], i64 0
+// CHECK-NEXT:ret <2 x double> [[VECINIT1_I]]
+//
+__m128d test_mm_set_sd(double num)
+{
+return _mm_set_sd(num);
+}

___
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] 1503d18 - [X86] Use correct fp immediate types in _mm_set_ss/sd

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

Author: Simon Pilgrim
Date: 2024-08-26T09:16:13+02:00
New Revision: 1503d18171e569996bf3e107364b1f0fd5f750e9

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

LOG: [X86] Use correct fp immediate types in _mm_set_ss/sd

Avoids implicit sint_to_fp which wasn't occurring on strict fp codegen

Fixes #104848

(cherry picked from commit 6dcce422ca06601f2b00e85cc18c745ede245ca6)

Added: 
clang/test/CodeGen/X86/strictfp_patterns.c

Modified: 
clang/lib/Headers/emmintrin.h
clang/lib/Headers/xmmintrin.h

Removed: 




diff  --git a/clang/lib/Headers/emmintrin.h b/clang/lib/Headers/emmintrin.h
index e85bfc47aa5cce..4dff6421350c00 100644
--- a/clang/lib/Headers/emmintrin.h
+++ b/clang/lib/Headers/emmintrin.h
@@ -1771,7 +1771,7 @@ static __inline__ __m128d __DEFAULT_FN_ATTRS 
_mm_undefined_pd(void) {
 ///lower 64 bits contain the value of the parameter. The upper 64 bits are
 ///set to zero.
 static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_set_sd(double __w) {
-  return __extension__(__m128d){__w, 0};
+  return __extension__(__m128d){__w, 0.0};
 }
 
 /// Constructs a 128-bit floating-point vector of [2 x double], with each

diff  --git a/clang/lib/Headers/xmmintrin.h b/clang/lib/Headers/xmmintrin.h
index 1ef89de9c9f562..6fb27297af9279 100644
--- a/clang/lib/Headers/xmmintrin.h
+++ b/clang/lib/Headers/xmmintrin.h
@@ -1910,7 +1910,7 @@ _mm_undefined_ps(void)
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_set_ss(float __w)
 {
-  return __extension__ (__m128){ __w, 0, 0, 0 };
+  return __extension__ (__m128){ __w, 0.0f, 0.0f, 0.0f };
 }
 
 /// Constructs a 128-bit floating-point vector of [4 x float], with each

diff  --git a/clang/test/CodeGen/X86/strictfp_patterns.c 
b/clang/test/CodeGen/X86/strictfp_patterns.c
new file mode 100644
index 00..55d85f22c3ba3d
--- /dev/null
+++ b/clang/test/CodeGen/X86/strictfp_patterns.c
@@ -0,0 +1,26 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 %s -O2 -emit-llvm -o - -triple x86_64-unknown-unknown 
-ffreestanding -ffp-exception-behavior=maytrap -Wall -Werror | FileCheck %s
+
+#include 
+
+// PR104848 - ensure the _mm_set_ss/d headers don't implicity promote any 
integer/fp values.
+
+// CHECK-LABEL: @test_mm_set_ss(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VECINIT3_I:%.*]] = insertelement <4 x float> , float 
[[NUM:%.*]], i64 0
+// CHECK-NEXT:ret <4 x float> [[VECINIT3_I]]
+//
+__m128 test_mm_set_ss(float num)
+{
+return _mm_set_ss(num);
+}
+
+// CHECK-LABEL: @test_mm_set_sd(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[VECINIT1_I:%.*]] = insertelement <2 x double> , double [[NUM:%.*]], i64 0
+// CHECK-NEXT:ret <2 x double> [[VECINIT1_I]]
+//
+__m128d test_mm_set_sd(double num)
+{
+return _mm_set_sd(num);
+}



___
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/19.x: [X86] Use correct fp immediate types in _mm_set_ss/sd (PR #105638)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/105638
___
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/19.x: [clang-format] Don't insert a space between :: and * (#105043) (PR #105773)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/105773

>From 1241c762c165972690c4edfb82ec7421c1e64658 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Thu, 22 Aug 2024 20:02:48 -0700
Subject: [PATCH] [clang-format] Don't insert a space between :: and *
 (#105043)

Also, don't insert a space after ::* for method pointers.

See
https://github.com/llvm/llvm-project/pull/86253#issuecomment-2298404887.

Fixes #100841.

(cherry picked from commit 714033a6bf3a81b1350f969ddd83bcd9fbb703e8)
---
 clang/lib/Format/TokenAnnotator.cpp   | 16 +
 clang/unittests/Format/FormatTest.cpp | 36 +--
 clang/unittests/Format/QualifierFixerTest.cpp | 36 +--
 3 files changed, 45 insertions(+), 43 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 6b9253613788c0..851f79895ac5ac 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4467,10 +4467,8 @@ bool TokenAnnotator::spaceRequiredBetween(const 
AnnotatedLine &Line,
   }
   if (Left.is(tok::colon))
 return Left.isNot(TT_ObjCMethodExpr);
-  if (Left.is(tok::coloncolon)) {
-return Right.is(tok::star) && Right.is(TT_PointerOrReference) &&
-   Style.PointerAlignment != FormatStyle::PAS_Left;
-  }
+  if (Left.is(tok::coloncolon))
+return false;
   if (Left.is(tok::less) || Right.isOneOf(tok::greater, tok::less)) {
 if (Style.Language == FormatStyle::LK_TextProto ||
 (Style.Language == FormatStyle::LK_Proto &&
@@ -4580,8 +4578,14 @@ bool TokenAnnotator::spaceRequiredBetween(const 
AnnotatedLine &Line,
 if (!BeforeLeft)
   return false;
 if (BeforeLeft->is(tok::coloncolon)) {
-  return Left.is(tok::star) &&
- Style.PointerAlignment != FormatStyle::PAS_Right;
+  if (Left.isNot(tok::star))
+return false;
+  assert(Style.PointerAlignment != FormatStyle::PAS_Right);
+  if (!Right.startsSequence(tok::identifier, tok::r_paren))
+return true;
+  assert(Right.Next);
+  const auto *LParen = Right.Next->MatchingParen;
+  return !LParen || LParen->isNot(TT_FunctionTypeLParen);
 }
 return !BeforeLeft->isOneOf(tok::l_paren, tok::l_square);
   }
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 39fcbab3447a7b..82af149e048c94 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -3646,8 +3646,8 @@ TEST_F(FormatTest, FormatsClasses) {
": public aaa {};");
   verifyFormat("template \n"
-   "struct A\n"
-   ": A {};");
+   "struct A\n"
+   ": A {};");
   verifyFormat("class ::A::B {};");
 }
 
@@ -11141,10 +11141,10 @@ TEST_F(FormatTest, UnderstandsBinaryOperators) {
 }
 
 TEST_F(FormatTest, UnderstandsPointersToMembers) {
-  verifyFormat("int A:: *x;");
-  verifyFormat("int (S:: *func)(void *);");
-  verifyFormat("void f() { int (S:: *func)(void *); }");
-  verifyFormat("typedef bool *(Class:: *Member)() const;");
+  verifyFormat("int A::*x;");
+  verifyFormat("int (S::*func)(void *);");
+  verifyFormat("void f() { int (S::*func)(void *); }");
+  verifyFormat("typedef bool *(Class::*Member)() const;");
   verifyFormat("void f() {\n"
"  (a->*f)();\n"
"  a->*x;\n"
@@ -11162,16 +11162,16 @@ TEST_F(FormatTest, UnderstandsPointersToMembers) {
 
   FormatStyle Style = getLLVMStyle();
   EXPECT_EQ(Style.PointerAlignment, FormatStyle::PAS_Right);
-  verifyFormat("typedef bool *(Class:: *Member)() const;", Style);
-  verifyFormat("void f(int A:: *p) { int A:: *v = &A::B; }", Style);
+  verifyFormat("typedef bool *(Class::*Member)() const;", Style);
+  verifyFormat("void f(int A::*p) { int A::*v = &A::B; }", Style);
 
   Style.PointerAlignment = FormatStyle::PAS_Left;
-  verifyFormat("typedef bool* (Class::* Member)() const;", Style);
+  verifyFormat("typedef bool* (Class::*Member)() const;", Style);
   verifyFormat("void f(int A::* p) { int A::* v = &A::B; }", Style);
 
   Style.PointerAlignment = FormatStyle::PAS_Middle;
-  verifyFormat("typedef bool * (Class:: * Member)() const;", Style);
-  verifyFormat("void f(int A:: * p) { int A:: * v = &A::B; }", Style);
+  verifyFormat("typedef bool * (Class::*Member)() const;", Style);
+  verifyFormat("void f(int A::* p) { int A::* v = &A::B; }", Style);
 }
 
 TEST_F(FormatTest, UnderstandsUnaryOperators) {
@@ -12514,7 +12514,7 @@ TEST_F(FormatTest, FormatsFunctionTypes) {
   verifyFormat("int (*func)(void *);");
   verifyFormat("void f() { int (*func)(void *); }");
   verifyFormat("template \n"
-   "using Callback = void (CallbackClass:: *)(SomeObject *Data);");
+   "using MyCallback = void (CallbackClass::*)(SomeObject 
*Data);");
 
   verifyGoogleFormat("A;");
   verifyGoogleFormat("void* 

[llvm-branch-commits] [clang] 1241c76 - [clang-format] Don't insert a space between :: and * (#105043)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

Author: Owen Pan
Date: 2024-08-26T09:18:31+02:00
New Revision: 1241c762c165972690c4edfb82ec7421c1e64658

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

LOG: [clang-format] Don't insert a space between :: and * (#105043)

Also, don't insert a space after ::* for method pointers.

See
https://github.com/llvm/llvm-project/pull/86253#issuecomment-2298404887.

Fixes #100841.

(cherry picked from commit 714033a6bf3a81b1350f969ddd83bcd9fbb703e8)

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/QualifierFixerTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 6b9253613788c0..851f79895ac5ac 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4467,10 +4467,8 @@ bool TokenAnnotator::spaceRequiredBetween(const 
AnnotatedLine &Line,
   }
   if (Left.is(tok::colon))
 return Left.isNot(TT_ObjCMethodExpr);
-  if (Left.is(tok::coloncolon)) {
-return Right.is(tok::star) && Right.is(TT_PointerOrReference) &&
-   Style.PointerAlignment != FormatStyle::PAS_Left;
-  }
+  if (Left.is(tok::coloncolon))
+return false;
   if (Left.is(tok::less) || Right.isOneOf(tok::greater, tok::less)) {
 if (Style.Language == FormatStyle::LK_TextProto ||
 (Style.Language == FormatStyle::LK_Proto &&
@@ -4580,8 +4578,14 @@ bool TokenAnnotator::spaceRequiredBetween(const 
AnnotatedLine &Line,
 if (!BeforeLeft)
   return false;
 if (BeforeLeft->is(tok::coloncolon)) {
-  return Left.is(tok::star) &&
- Style.PointerAlignment != FormatStyle::PAS_Right;
+  if (Left.isNot(tok::star))
+return false;
+  assert(Style.PointerAlignment != FormatStyle::PAS_Right);
+  if (!Right.startsSequence(tok::identifier, tok::r_paren))
+return true;
+  assert(Right.Next);
+  const auto *LParen = Right.Next->MatchingParen;
+  return !LParen || LParen->isNot(TT_FunctionTypeLParen);
 }
 return !BeforeLeft->isOneOf(tok::l_paren, tok::l_square);
   }

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 39fcbab3447a7b..82af149e048c94 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -3646,8 +3646,8 @@ TEST_F(FormatTest, FormatsClasses) {
": public aaa {};");
   verifyFormat("template \n"
-   "struct A\n"
-   ": A {};");
+   "struct A\n"
+   ": A {};");
   verifyFormat("class ::A::B {};");
 }
 
@@ -11141,10 +11141,10 @@ TEST_F(FormatTest, UnderstandsBinaryOperators) {
 }
 
 TEST_F(FormatTest, UnderstandsPointersToMembers) {
-  verifyFormat("int A:: *x;");
-  verifyFormat("int (S:: *func)(void *);");
-  verifyFormat("void f() { int (S:: *func)(void *); }");
-  verifyFormat("typedef bool *(Class:: *Member)() const;");
+  verifyFormat("int A::*x;");
+  verifyFormat("int (S::*func)(void *);");
+  verifyFormat("void f() { int (S::*func)(void *); }");
+  verifyFormat("typedef bool *(Class::*Member)() const;");
   verifyFormat("void f() {\n"
"  (a->*f)();\n"
"  a->*x;\n"
@@ -11162,16 +11162,16 @@ TEST_F(FormatTest, UnderstandsPointersToMembers) {
 
   FormatStyle Style = getLLVMStyle();
   EXPECT_EQ(Style.PointerAlignment, FormatStyle::PAS_Right);
-  verifyFormat("typedef bool *(Class:: *Member)() const;", Style);
-  verifyFormat("void f(int A:: *p) { int A:: *v = &A::B; }", Style);
+  verifyFormat("typedef bool *(Class::*Member)() const;", Style);
+  verifyFormat("void f(int A::*p) { int A::*v = &A::B; }", Style);
 
   Style.PointerAlignment = FormatStyle::PAS_Left;
-  verifyFormat("typedef bool* (Class::* Member)() const;", Style);
+  verifyFormat("typedef bool* (Class::*Member)() const;", Style);
   verifyFormat("void f(int A::* p) { int A::* v = &A::B; }", Style);
 
   Style.PointerAlignment = FormatStyle::PAS_Middle;
-  verifyFormat("typedef bool * (Class:: * Member)() const;", Style);
-  verifyFormat("void f(int A:: * p) { int A:: * v = &A::B; }", Style);
+  verifyFormat("typedef bool * (Class::*Member)() const;", Style);
+  verifyFormat("void f(int A::* p) { int A::* v = &A::B; }", Style);
 }
 
 TEST_F(FormatTest, UnderstandsUnaryOperators) {
@@ -12514,7 +12514,7 @@ TEST_F(FormatTest, FormatsFunctionTypes) {
   verifyFormat("int (*func)(void *);");
   verifyFormat("void f() { int (*func)(void *); }");
   verifyFormat("template \n"
-   "using Callback = void (CallbackClass:: *)(SomeObject *Data);");
+   "using MyCallback = void (CallbackClass::*)(SomeObject 

[llvm-branch-commits] [clang] release/19.x: [clang-format] Don't insert a space between :: and * (#105043) (PR #105773)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/105773
___
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] release/19.x: [ConstraintElim] Fix miscompilation caused by PR97974 (#105790) (PR #105797)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/105797

>From 3ff9d92aae0945daa85ec6f85f05a3aeaaa9f962 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Fri, 23 Aug 2024 16:06:00 +0800
Subject: [PATCH] [ConstraintElim] Fix miscompilation caused by PR97974
 (#105790)

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

(cherry picked from commit 85b6aac7c25f9d2a976a76045ace1e7afebb5965)
---
 .../Scalar/ConstraintElimination.cpp  |  2 +-
 .../ConstraintElimination/pr105785.ll | 46 +++
 2 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/Transforms/ConstraintElimination/pr105785.ll

diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp 
b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index c31173879af1e6..37022104d0a9bd 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -1464,7 +1464,7 @@ static bool checkAndReplaceCmp(CmpIntrinsic *I, 
ConstraintInfo &Info,
 ToRemove.push_back(I);
 return true;
   }
-  if (checkCondition(ICmpInst::ICMP_EQ, LHS, RHS, I, Info)) {
+  if (checkCondition(ICmpInst::ICMP_EQ, LHS, RHS, I, Info).value_or(false)) {
 I->replaceAllUsesWith(ConstantInt::get(I->getType(), 0));
 ToRemove.push_back(I);
 return true;
diff --git a/llvm/test/Transforms/ConstraintElimination/pr105785.ll 
b/llvm/test/Transforms/ConstraintElimination/pr105785.ll
new file mode 100644
index 00..6c340a11dd2e2c
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/pr105785.ll
@@ -0,0 +1,46 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 5
+; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
+
+define void @pr105785(ptr %p) {
+; CHECK-LABEL: define void @pr105785(
+; CHECK-SAME: ptr [[P:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*]]:
+; CHECK-NEXT:br label %[[FOR_COND:.*]]
+; CHECK:   [[FOR_COND]]:
+; CHECK-NEXT:[[FOR_IND:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ 1, 
%[[FOR_COND1:.*]] ]
+; CHECK-NEXT:[[CMP:%.*]] = icmp eq i32 [[FOR_IND]], 0
+; CHECK-NEXT:br i1 [[CMP]], label %[[FOR_COND1]], label %[[FOR_END6:.*]]
+; CHECK:   [[FOR_COND1]]:
+; CHECK-NEXT:[[FOR_IND2:%.*]] = phi i32 [ [[INC:%.*]], %[[FOR_BODY3:.*]] 
], [ 0, %[[FOR_COND]] ]
+; CHECK-NEXT:[[CMP2:%.*]] = icmp ult i32 [[FOR_IND2]], 3
+; CHECK-NEXT:br i1 [[CMP2]], label %[[FOR_BODY3]], label %[[FOR_COND]]
+; CHECK:   [[FOR_BODY3]]:
+; CHECK-NEXT:[[SCMP:%.*]] = call i32 @llvm.scmp.i32.i32(i32 [[FOR_IND]], 
i32 1)
+; CHECK-NEXT:store i32 [[SCMP]], ptr [[P]], align 4
+; CHECK-NEXT:[[INC]] = add nuw nsw i32 [[FOR_IND2]], 1
+; CHECK-NEXT:br label %[[FOR_COND1]]
+; CHECK:   [[FOR_END6]]:
+; CHECK-NEXT:ret void
+;
+entry:
+  br label %for.cond
+
+for.cond: ; preds = %for.cond1, %entry
+  %for.ind = phi i32 [ 0, %entry ], [ 1, %for.cond1 ]
+  %cmp = icmp eq i32 %for.ind, 0
+  br i1 %cmp, label %for.cond1, label %for.end6
+
+for.cond1:; preds = %for.cond, 
%for.body3
+  %for.ind2 = phi i32 [ %inc, %for.body3 ], [ 0, %for.cond ]
+  %cmp2 = icmp ult i32 %for.ind2, 3
+  br i1 %cmp2, label %for.body3, label %for.cond
+
+for.body3:; preds = %for.cond1
+  %scmp = call i32 @llvm.scmp.i32.i32(i32 %for.ind, i32 1)
+  store i32 %scmp, ptr %p, align 4
+  %inc = add nuw nsw i32 %for.ind2, 1
+  br label %for.cond1
+
+for.end6:
+  ret void
+}

___
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] 3ff9d92 - [ConstraintElim] Fix miscompilation caused by PR97974 (#105790)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

Author: Yingwei Zheng
Date: 2024-08-26T09:19:02+02:00
New Revision: 3ff9d92aae0945daa85ec6f85f05a3aeaaa9f962

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

LOG: [ConstraintElim] Fix miscompilation caused by PR97974 (#105790)

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

(cherry picked from commit 85b6aac7c25f9d2a976a76045ace1e7afebb5965)

Added: 
llvm/test/Transforms/ConstraintElimination/pr105785.ll

Modified: 
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp 
b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index c31173879af1e6..37022104d0a9bd 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -1464,7 +1464,7 @@ static bool checkAndReplaceCmp(CmpIntrinsic *I, 
ConstraintInfo &Info,
 ToRemove.push_back(I);
 return true;
   }
-  if (checkCondition(ICmpInst::ICMP_EQ, LHS, RHS, I, Info)) {
+  if (checkCondition(ICmpInst::ICMP_EQ, LHS, RHS, I, Info).value_or(false)) {
 I->replaceAllUsesWith(ConstantInt::get(I->getType(), 0));
 ToRemove.push_back(I);
 return true;

diff  --git a/llvm/test/Transforms/ConstraintElimination/pr105785.ll 
b/llvm/test/Transforms/ConstraintElimination/pr105785.ll
new file mode 100644
index 00..6c340a11dd2e2c
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/pr105785.ll
@@ -0,0 +1,46 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 5
+; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
+
+define void @pr105785(ptr %p) {
+; CHECK-LABEL: define void @pr105785(
+; CHECK-SAME: ptr [[P:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*]]:
+; CHECK-NEXT:br label %[[FOR_COND:.*]]
+; CHECK:   [[FOR_COND]]:
+; CHECK-NEXT:[[FOR_IND:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ 1, 
%[[FOR_COND1:.*]] ]
+; CHECK-NEXT:[[CMP:%.*]] = icmp eq i32 [[FOR_IND]], 0
+; CHECK-NEXT:br i1 [[CMP]], label %[[FOR_COND1]], label %[[FOR_END6:.*]]
+; CHECK:   [[FOR_COND1]]:
+; CHECK-NEXT:[[FOR_IND2:%.*]] = phi i32 [ [[INC:%.*]], %[[FOR_BODY3:.*]] 
], [ 0, %[[FOR_COND]] ]
+; CHECK-NEXT:[[CMP2:%.*]] = icmp ult i32 [[FOR_IND2]], 3
+; CHECK-NEXT:br i1 [[CMP2]], label %[[FOR_BODY3]], label %[[FOR_COND]]
+; CHECK:   [[FOR_BODY3]]:
+; CHECK-NEXT:[[SCMP:%.*]] = call i32 @llvm.scmp.i32.i32(i32 [[FOR_IND]], 
i32 1)
+; CHECK-NEXT:store i32 [[SCMP]], ptr [[P]], align 4
+; CHECK-NEXT:[[INC]] = add nuw nsw i32 [[FOR_IND2]], 1
+; CHECK-NEXT:br label %[[FOR_COND1]]
+; CHECK:   [[FOR_END6]]:
+; CHECK-NEXT:ret void
+;
+entry:
+  br label %for.cond
+
+for.cond: ; preds = %for.cond1, %entry
+  %for.ind = phi i32 [ 0, %entry ], [ 1, %for.cond1 ]
+  %cmp = icmp eq i32 %for.ind, 0
+  br i1 %cmp, label %for.cond1, label %for.end6
+
+for.cond1:; preds = %for.cond, 
%for.body3
+  %for.ind2 = phi i32 [ %inc, %for.body3 ], [ 0, %for.cond ]
+  %cmp2 = icmp ult i32 %for.ind2, 3
+  br i1 %cmp2, label %for.body3, label %for.cond
+
+for.body3:; preds = %for.cond1
+  %scmp = call i32 @llvm.scmp.i32.i32(i32 %for.ind, i32 1)
+  store i32 %scmp, ptr %p, align 4
+  %inc = add nuw nsw i32 %for.ind2, 1
+  br label %for.cond1
+
+for.end6:
+  ret void
+}



___
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] release/19.x: [ConstraintElim] Fix miscompilation caused by PR97974 (#105790) (PR #105797)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/105797
___
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] release/19.x: [DAGCombiner] Fix ReplaceAllUsesOfValueWith mutation bug in visitFREEZE (#104924) (PR #105627)

2024-08-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@nikic (or anyone else). If you would like to add a note about this fix in the 
release notes (completely optional). Please reply to this comment with a one or 
two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/105627
___
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] release/19.x: [MCA][X86] Add missing 512-bit vpscatterqd/vscatterqps schedule data (REAPPLIED) (PR #105815)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru updated https://github.com/llvm/llvm-project/pull/105815

>From cfe8eb89cbb8b8d873579123555a5238d9ad502c Mon Sep 17 00:00:00 2001
From: Simon Pilgrim 
Date: Thu, 1 Aug 2024 16:08:33 +0100
Subject: [PATCH] [MCA][X86] Add missing 512-bit vpscatterqd/vscatterqps
 schedule data (REAPPLIED)

This doesn't match uops.info yet - but it matches the existing 
vpscatterdq/vscatterqpd entries like uops.info says it should

Reapplied with codegen fix for scatter-schedule.ll

Fixes #105675

(cherry picked from commit cf6cd1fd67356ca0c2972992928592d2430043d2)
---
 llvm/lib/Target/X86/X86SchedIceLake.td|  2 +
 llvm/lib/Target/X86/X86SchedSkylakeServer.td  |  2 +
 llvm/test/CodeGen/X86/scatter-schedule.ll |  4 +-
 .../llvm-mca/X86/Generic/resources-avx512.s   | 35 +++-
 .../llvm-mca/X86/Generic/resources-avx512vl.s | 54 ++-
 .../X86/IceLakeServer/resources-avx512.s  | 35 +++-
 .../X86/IceLakeServer/resources-avx512vl.s| 54 ++-
 .../X86/SapphireRapids/resources-avx512.s | 35 +++-
 .../X86/SapphireRapids/resources-avx512vl.s   | 54 ++-
 .../X86/SkylakeServer/resources-avx512.s  | 35 +++-
 .../X86/SkylakeServer/resources-avx512vl.s| 54 ++-
 .../llvm-mca/X86/Znver4/resources-avx512.s| 35 +++-
 .../llvm-mca/X86/Znver4/resources-avx512vl.s  | 54 ++-
 13 files changed, 441 insertions(+), 12 deletions(-)

diff --git a/llvm/lib/Target/X86/X86SchedIceLake.td 
b/llvm/lib/Target/X86/X86SchedIceLake.td
index 186d4d84c25104..b68be9be6d4731 100644
--- a/llvm/lib/Target/X86/X86SchedIceLake.td
+++ b/llvm/lib/Target/X86/X86SchedIceLake.td
@@ -1510,8 +1510,10 @@ def ICXWriteResGroup113 : 
SchedWriteRes<[ICXPort0,ICXPort49,ICXPort78,ICXPort015
   let ReleaseAtCycles = [1,8,8,2];
 }
 def: InstRW<[ICXWriteResGroup113], (instrs VPSCATTERDQZmr,
+   VPSCATTERQDZmr,
VPSCATTERQQZmr,
VSCATTERDPDZmr,
+   VSCATTERQPSZmr,
VSCATTERQPDZmr)>;
 
 def ICXWriteResGroup114 : 
SchedWriteRes<[ICXPort0,ICXPort49,ICXPort5,ICXPort78,ICXPort0156]> {
diff --git a/llvm/lib/Target/X86/X86SchedSkylakeServer.td 
b/llvm/lib/Target/X86/X86SchedSkylakeServer.td
index 4fded44085e897..2423602d06c470 100644
--- a/llvm/lib/Target/X86/X86SchedSkylakeServer.td
+++ b/llvm/lib/Target/X86/X86SchedSkylakeServer.td
@@ -1499,8 +1499,10 @@ def SKXWriteResGroup113 : 
SchedWriteRes<[SKXPort0,SKXPort4,SKXPort237,SKXPort015
   let ReleaseAtCycles = [1,8,8,2];
 }
 def: InstRW<[SKXWriteResGroup113], (instrs VPSCATTERDQZmr,
+   VPSCATTERQDZmr,
VPSCATTERQQZmr,
VSCATTERDPDZmr,
+   VSCATTERQPSZmr,
VSCATTERQPDZmr)>;
 
 def SKXWriteResGroup114 : 
SchedWriteRes<[SKXPort0,SKXPort4,SKXPort5,SKXPort237,SKXPort0156]> {
diff --git a/llvm/test/CodeGen/X86/scatter-schedule.ll 
b/llvm/test/CodeGen/X86/scatter-schedule.ll
index c841e23eab76b2..762a050247a87e 100644
--- a/llvm/test/CodeGen/X86/scatter-schedule.ll
+++ b/llvm/test/CodeGen/X86/scatter-schedule.ll
@@ -10,8 +10,8 @@ define void @test(i64 %x272, <16 x ptr> %x335, <16 x i32> 
%x270) {
 ; CHECK-LABEL: test:
 ; CHECK:   # %bb.0:
 ; CHECK-NEXT:kxnorw %k0, %k0, %k1
-; CHECK-NEXT:kxnorw %k0, %k0, %k2
-; CHECK-NEXT:vpscatterqd %ymm2, (,%zmm0) {%k2}
+; CHECK-NEXT:vpscatterqd %ymm2, (,%zmm0) {%k1}
+; CHECK-NEXT:kxnorw %k0, %k0, %k1
 ; CHECK-NEXT:vextracti64x4 $1, %zmm2, %ymm0
 ; CHECK-NEXT:vpscatterqd %ymm0, (,%zmm1) {%k1}
 ; CHECK-NEXT:vzeroupper
diff --git a/llvm/test/tools/llvm-mca/X86/Generic/resources-avx512.s 
b/llvm/test/tools/llvm-mca/X86/Generic/resources-avx512.s
index a8937f7dcfd117..c3453d890d76d5 100644
--- a/llvm/test/tools/llvm-mca/X86/Generic/resources-avx512.s
+++ b/llvm/test/tools/llvm-mca/X86/Generic/resources-avx512.s
@@ -298,6 +298,9 @@ vdivps%zmm16, %zmm17, %zmm19 {z}{k1}
 vdivps(%rax), %zmm17, %zmm19 {z}{k1}
 vdivps(%rax){1to16}, %zmm17, %zmm19 {z}{k1}
 
+{evex} vextractps $1, %xmm0, %rcx
+{evex} vextractps $1, %xmm0, (%rax)
+
 vfmadd132pd   %zmm16, %zmm17, %zmm19
 vfmadd132pd   (%rax), %zmm17, %zmm19
 vfmadd132pd   (%rax){1to8}, %zmm17, %zmm19
@@ -811,6 +814,11 @@ vpermq%zmm16, %zmm17, %zmm19 {z}{k1}
 vpermq(%rax), %zmm17, %zmm19 {z}{k1}
 vpermq(%rax){1to8}, %zmm17, %zmm19 {z}{k1}
 
+vpscatterdd   %zmm1, (%rdx,%zmm0,4) {%k1}
+vpscatterdq   %zmm1, (%rdx,%ymm0,4) {%k1}
+vpscatterqd   %ymm1, (%rdx,%zmm0,4) {%k1}
+vpscatterqq   %zmm1, (%rdx,%zmm0,4) {%k1}
+
 vpshufd   $0, %zmm16, %zmm19
 vpshufd 

[llvm-branch-commits] [llvm] cfe8eb8 - [MCA][X86] Add missing 512-bit vpscatterqd/vscatterqps schedule data (REAPPLIED)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

Author: Simon Pilgrim
Date: 2024-08-26T09:20:20+02:00
New Revision: cfe8eb89cbb8b8d873579123555a5238d9ad502c

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

LOG: [MCA][X86] Add missing 512-bit vpscatterqd/vscatterqps schedule data 
(REAPPLIED)

This doesn't match uops.info yet - but it matches the existing 
vpscatterdq/vscatterqpd entries like uops.info says it should

Reapplied with codegen fix for scatter-schedule.ll

Fixes #105675

(cherry picked from commit cf6cd1fd67356ca0c2972992928592d2430043d2)

Added: 


Modified: 
llvm/lib/Target/X86/X86SchedIceLake.td
llvm/lib/Target/X86/X86SchedSkylakeServer.td
llvm/test/CodeGen/X86/scatter-schedule.ll
llvm/test/tools/llvm-mca/X86/Generic/resources-avx512.s
llvm/test/tools/llvm-mca/X86/Generic/resources-avx512vl.s
llvm/test/tools/llvm-mca/X86/IceLakeServer/resources-avx512.s
llvm/test/tools/llvm-mca/X86/IceLakeServer/resources-avx512vl.s
llvm/test/tools/llvm-mca/X86/SapphireRapids/resources-avx512.s
llvm/test/tools/llvm-mca/X86/SapphireRapids/resources-avx512vl.s
llvm/test/tools/llvm-mca/X86/SkylakeServer/resources-avx512.s
llvm/test/tools/llvm-mca/X86/SkylakeServer/resources-avx512vl.s
llvm/test/tools/llvm-mca/X86/Znver4/resources-avx512.s
llvm/test/tools/llvm-mca/X86/Znver4/resources-avx512vl.s

Removed: 




diff  --git a/llvm/lib/Target/X86/X86SchedIceLake.td 
b/llvm/lib/Target/X86/X86SchedIceLake.td
index 186d4d84c25104..b68be9be6d4731 100644
--- a/llvm/lib/Target/X86/X86SchedIceLake.td
+++ b/llvm/lib/Target/X86/X86SchedIceLake.td
@@ -1510,8 +1510,10 @@ def ICXWriteResGroup113 : 
SchedWriteRes<[ICXPort0,ICXPort49,ICXPort78,ICXPort015
   let ReleaseAtCycles = [1,8,8,2];
 }
 def: InstRW<[ICXWriteResGroup113], (instrs VPSCATTERDQZmr,
+   VPSCATTERQDZmr,
VPSCATTERQQZmr,
VSCATTERDPDZmr,
+   VSCATTERQPSZmr,
VSCATTERQPDZmr)>;
 
 def ICXWriteResGroup114 : 
SchedWriteRes<[ICXPort0,ICXPort49,ICXPort5,ICXPort78,ICXPort0156]> {

diff  --git a/llvm/lib/Target/X86/X86SchedSkylakeServer.td 
b/llvm/lib/Target/X86/X86SchedSkylakeServer.td
index 4fded44085e897..2423602d06c470 100644
--- a/llvm/lib/Target/X86/X86SchedSkylakeServer.td
+++ b/llvm/lib/Target/X86/X86SchedSkylakeServer.td
@@ -1499,8 +1499,10 @@ def SKXWriteResGroup113 : 
SchedWriteRes<[SKXPort0,SKXPort4,SKXPort237,SKXPort015
   let ReleaseAtCycles = [1,8,8,2];
 }
 def: InstRW<[SKXWriteResGroup113], (instrs VPSCATTERDQZmr,
+   VPSCATTERQDZmr,
VPSCATTERQQZmr,
VSCATTERDPDZmr,
+   VSCATTERQPSZmr,
VSCATTERQPDZmr)>;
 
 def SKXWriteResGroup114 : 
SchedWriteRes<[SKXPort0,SKXPort4,SKXPort5,SKXPort237,SKXPort0156]> {

diff  --git a/llvm/test/CodeGen/X86/scatter-schedule.ll 
b/llvm/test/CodeGen/X86/scatter-schedule.ll
index c841e23eab76b2..762a050247a87e 100644
--- a/llvm/test/CodeGen/X86/scatter-schedule.ll
+++ b/llvm/test/CodeGen/X86/scatter-schedule.ll
@@ -10,8 +10,8 @@ define void @test(i64 %x272, <16 x ptr> %x335, <16 x i32> 
%x270) {
 ; CHECK-LABEL: test:
 ; CHECK:   # %bb.0:
 ; CHECK-NEXT:kxnorw %k0, %k0, %k1
-; CHECK-NEXT:kxnorw %k0, %k0, %k2
-; CHECK-NEXT:vpscatterqd %ymm2, (,%zmm0) {%k2}
+; CHECK-NEXT:vpscatterqd %ymm2, (,%zmm0) {%k1}
+; CHECK-NEXT:kxnorw %k0, %k0, %k1
 ; CHECK-NEXT:vextracti64x4 $1, %zmm2, %ymm0
 ; CHECK-NEXT:vpscatterqd %ymm0, (,%zmm1) {%k1}
 ; CHECK-NEXT:vzeroupper

diff  --git a/llvm/test/tools/llvm-mca/X86/Generic/resources-avx512.s 
b/llvm/test/tools/llvm-mca/X86/Generic/resources-avx512.s
index a8937f7dcfd117..c3453d890d76d5 100644
--- a/llvm/test/tools/llvm-mca/X86/Generic/resources-avx512.s
+++ b/llvm/test/tools/llvm-mca/X86/Generic/resources-avx512.s
@@ -298,6 +298,9 @@ vdivps%zmm16, %zmm17, %zmm19 {z}{k1}
 vdivps(%rax), %zmm17, %zmm19 {z}{k1}
 vdivps(%rax){1to16}, %zmm17, %zmm19 {z}{k1}
 
+{evex} vextractps $1, %xmm0, %rcx
+{evex} vextractps $1, %xmm0, (%rax)
+
 vfmadd132pd   %zmm16, %zmm17, %zmm19
 vfmadd132pd   (%rax), %zmm17, %zmm19
 vfmadd132pd   (%rax){1to8}, %zmm17, %zmm19
@@ -811,6 +814,11 @@ vpermq%zmm16, %zmm17, %zmm19 {z}{k1}
 vpermq(%rax), %zmm17, %zmm19 {z}{k1}
 vpermq(%rax){1to8}, %zmm17, %zmm19 {z}{k1}
 
+vpscatterdd   %zmm1, (%rdx,%zmm0,4) {%k1}
+vpscatterdq   %zmm1, (%rdx,%ymm0,4) {%k1}
+vpscatterqd   %ymm1, (%rdx,%zmm0,4) {%k1}
+vpscatterqq   

[llvm-branch-commits] [llvm] release/19.x: [MCA][X86] Add missing 512-bit vpscatterqd/vscatterqps schedule data (REAPPLIED) (PR #105815)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/105815
___
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] release/19.x: [DwarfEhPrepare] Assign dummy debug location for more inserted _Unwind_Resume calls (#105513) (PR #105846)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

https://github.com/tru closed https://github.com/llvm/llvm-project/pull/105846
___
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] release/19.x: [AMDGPU] Remove one case of vmcnt loop header flushing for GFX12 (#105550) (PR #105808)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

tru wrote:

> I'm not sure if I should have done three different backport requests for the 
> three commits. It could be confusing if they get squash-and-merged onto the 
> release branch.

It's fine - I can merge it as three separate commits.

https://github.com/llvm/llvm-project/pull/105808
___
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] release/19.x: [MIPS] Optimize sortRelocs for o32 (PR #106008)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

tru wrote:

I am not convinced that we should take something that's a pure optimization 
between RC3 and final unless this is fixing a regression or is very important. 
I want to avoid risk now so that we don't end up making things worse for the 
final release.

https://github.com/llvm/llvm-project/pull/106008
___
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/19.x: [Clang][Concepts] Fix the constraint equivalence checking involving parameter packs (#102131) (PR #106043)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

tru wrote:

Is this a major fix or regression fix?

https://github.com/llvm/llvm-project/pull/106043
___
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] release/19.x: [MIPS] Optimize sortRelocs for o32 (PR #106008)

2024-08-26 Thread Alex Rønne Petersen via llvm-branch-commits

alexrp wrote:

@tru please see the numbers in 
https://github.com/llvm/llvm-project/issues/104562#issue-2469758971. The Zig 
project has no choice but to keep all MIPS32 testing (both local and in CI) 
disabled until this fix is in effect. So I'd say it's reasonably important.

https://github.com/llvm/llvm-project/pull/106008
___
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] release/19.x: [DAGCombiner] Fix ReplaceAllUsesOfValueWith mutation bug in visitFREEZE (#104924) (PR #105627)

2024-08-26 Thread Björn Pettersson via llvm-branch-commits

bjope wrote:

> @nikic (or anyone else). If you would like to add a note about this fix in 
> the release notes (completely optional). Please reply to this comment with a 
> one or two sentence description of the fix. When you are done, please add the 
> release:note label to this PR.

I've only seen this problem when SELECT_CC is involved, and that started 
happening after a patch that landed on trunk about a month ago. So this fixes a 
problem that otherwise would be introduced in LLVM 19.1.0, and then I guess it 
isn't interesting for release notes. Right?

https://github.com/llvm/llvm-project/pull/105627
___
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] release/19.x: [MIPS] Optimize sortRelocs for o32 (PR #106008)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

tru wrote:

It seems like this was present in LLVM 18.x as well? so it's not in a strict 
sense a regression? what's the risk of taking this on? @brad0 @MaskRay ?

https://github.com/llvm/llvm-project/pull/106008
___
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] release/19.x: [DAGCombiner] Fix ReplaceAllUsesOfValueWith mutation bug in visitFREEZE (#104924) (PR #105627)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

tru wrote:

That's fine - I only really use the comment release notes for post-final anyway.

https://github.com/llvm/llvm-project/pull/105627
___
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/19.x: [X86] Use correct fp immediate types in _mm_set_ss/sd (PR #105638)

2024-08-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@RKSimon (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/105638
___
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/19.x: [clang-format] Don't insert a space between :: and * (#105043) (PR #105773)

2024-08-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@owenca (or anyone else). If you would like to add a note about this fix in the 
release notes (completely optional). Please reply to this comment with a one or 
two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/105773
___
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] release/19.x: [DAGCombiner] Fix ReplaceAllUsesOfValueWith mutation bug in visitFREEZE (#104924) (PR #105627)

2024-08-26 Thread Nikita Popov via llvm-branch-commits

nikic wrote:

> That's fine - I only really use the comment release notes for post-final 
> anyway.

We should disable the comment for RCs then :)

https://github.com/llvm/llvm-project/pull/105627
___
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] release/19.x: [DAGCombiner] Fix ReplaceAllUsesOfValueWith mutation bug in visitFREEZE (#104924) (PR #105627)

2024-08-26 Thread Tobias Hieta via llvm-branch-commits

tru wrote:

> > That's fine - I only really use the comment release notes for post-final 
> > anyway.
> 
> We should disable the comment for RCs then :)

yes I think that would be good.

https://github.com/llvm/llvm-project/pull/105627
___
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] release/19.x: [ConstraintElim] Fix miscompilation caused by PR97974 (#105790) (PR #105797)

2024-08-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@dtcxzyw (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/105797
___
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] release/19.x: [MCA][X86] Add missing 512-bit vpscatterqd/vscatterqps schedule data (REAPPLIED) (PR #105815)

2024-08-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@RKSimon (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/105815
___
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] release/19.x: [DwarfEhPrepare] Assign dummy debug location for more inserted _Unwind_Resume calls (#105513) (PR #105846)

2024-08-26 Thread via llvm-branch-commits

github-actions[bot] wrote:

@sunfishcode (or anyone else). If you would like to add a note about this fix 
in the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

https://github.com/llvm/llvm-project/pull/105846
___
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/19.x: [Clang][Concepts] Fix the constraint equivalence checking involving parameter packs (#102131) (PR #106043)

2024-08-26 Thread Younan Zhang via llvm-branch-commits

zyn0217 wrote:

> Is this a major fix or regression fix?

It is a follow-up fix for the previous bug fix incorporated in 19. 
https://github.com/llvm/llvm-project/commit/04d20b17050203e07394b4f9ee61b5affe2d5347

But this isn't a regression since clang wasn't working properly in such cases, 
nor a major fix as I don't think it would affect much but rather ensure more 
correctness.

We have a report from @yuxuanchen1997 that some production codes rely on this 
to compile, so I think it merits a backport.


https://github.com/llvm/llvm-project/pull/106043
___
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] release/19.x: [PowerPC] Respect endianness when bitcasting to fp128 (#95931) (PR #105623)

2024-08-26 Thread Trevor Gross via llvm-branch-commits

tgross35 wrote:

(I'm not really involved with LLVM but I am doing a lot of f128 work and 
requested the backport)

This seems unlikely to be a regression. There have a handful of f128-related 
bugs on various ppc platforms so I suspect this is just something that hadn't 
been tested before now.

The problem this fixes is pretty fundamental, it means any sort of soft float 
operations are completely broken on some ppc targets. This is how I originally 
identified the issue, in 
https://github.com/rust-lang/compiler-builtins/pull/606#issuecomment-2105657287.
 Backporting isn't critical; at this time it probably only affects those of us 
that are experimenting with f128 support, there can't be many/any end users. I 
was just hoping for a fix soonish to get ppc f128 caught up to the other 
targets, since is one of the few popular 64-bit linux target to still have bugs 
(our more complete list: 
https://github.com/rust-lang/rust/blob/3f121b9461cce02a703a0e7e450568849dfaa074/library/std/build.rs#L123-L141)

https://github.com/llvm/llvm-project/pull/105623
___
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] release/19.x: [MIPS] Optimize sortRelocs for o32 (PR #106008)

2024-08-26 Thread Alex Rønne Petersen via llvm-branch-commits

alexrp wrote:

Yeah, this has been an issue for a while AIUI.

I don't think it affects C/C++ projects in general because of separate 
compilation. Zig, OTOH, uses a compilation model that's more like a "unity 
build", which results in tons of relocations in the single module that goes 
through `MipsELFObjectWriter`, so we're really badly affected by this. It's 
only recently that we've started getting our MIPS port up to a high standard of 
quality, so it's hurting us quite a bit now that we actually want to do regular 
testing for it.

https://github.com/llvm/llvm-project/pull/106008
___
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 taint analysis slowdown regression fix (PR #105516)

2024-08-26 Thread Balazs Benics via llvm-branch-commits

steakhal wrote:

@Xazax-hun 

https://github.com/llvm/llvm-project/pull/105516
___
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] [flang] [flang] Introduce custom loop nest generation for loops in workshare construct (PR #101445)

2024-08-26 Thread Sergio Afonso via llvm-branch-commits

skatrak wrote:

> No you are right, sorry for the back and forth, as you said, since a wsloop 
> can only be nested in a omp.parallel it is immediately obvious that it binds 
> to the omp.parallel threads so that makes sense.
> 
> My only concern was that at some point some transformation (perhaps in the 
> future, because I don't think anything transforms `wsloop`s currently) could 
> make the assumption that either all or none of the threads of the team an 
> `omp.parallel` launches will execute the parent block of a `wsloop` that 
> binds to that team. (for example an optimization/transformation could add an 
> operation immediately before the wsloop which is supposed to be executed by 
> all threads (or none) in the omp.parallel. that operation would then be 
> erroneously wrapped in an omp.single in LowerWorkshare.)
> 
> I thought this was a fair assumption for an optimization/transformation to 
> make because if for example only one of the threads executes a wsloop it 
> would not produce the intended result. So the intention was to guard against 
> a potential error like that. Let me know if I am wrong here since I am sure 
> people here have more experience than me on this.

Thank you for bringing attention to this potential issue I hadn't considered, I 
think it's a productive discussion. I'm not aware of any transformations like 
that existing at the moment either, but it looks like they would certainly 
break if they ran while the `omp.workshare` operation still remained. However, 
they would work if they ran after the pass lowering `omp.workshare` to a set of 
`omp.single` for the code in between `omp.wsloop`s. That way we would not have 
to introduce a new loop wrapper and also we could create passes assuming the 
parent of region of an `omp.wsloop` is executed by all threads in the team. I 
don't think that should be an issue, since in principle it makes sense to me 
that the `omp.workshare` transformation would run immediately after PFT to MLIR 
lowering. What do you think about that alternative?

https://github.com/llvm/llvm-project/pull/101445
___
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] 5153817 - Revert "[FixIrreducible] Use CycleInfo instead of a custom SCC traversal (#10…"

2024-08-26 Thread via llvm-branch-commits

Author: Alexey Bataev
Date: 2024-08-26T08:09:35-04:00
New Revision: 5153817e36dbaaf6800a5befb8c7a54363840e81

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

LOG: Revert "[FixIrreducible] Use CycleInfo instead of a custom SCC traversal 
(#10…"

This reverts commit fa4cc9ddd58eb9fef2497e678873ff3b495340a3.

Added: 


Modified: 
llvm/include/llvm/ADT/GenericCycleInfo.h
llvm/lib/Transforms/Utils/FixIrreducible.cpp
llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
llvm/test/Transforms/FixIrreducible/basic.ll
llvm/test/Transforms/FixIrreducible/bug45623.ll
llvm/test/Transforms/FixIrreducible/nested.ll
llvm/test/Transforms/FixIrreducible/switch.ll
llvm/test/Transforms/FixIrreducible/unreachable.ll
llvm/test/Transforms/StructurizeCFG/workarounds/needs-fix-reducible.ll
llvm/test/Transforms/StructurizeCFG/workarounds/needs-fr-ule.ll

Removed: 




diff  --git a/llvm/include/llvm/ADT/GenericCycleInfo.h 
b/llvm/include/llvm/ADT/GenericCycleInfo.h
index 8c2fa0490e638a..55034844d30b0d 100644
--- a/llvm/include/llvm/ADT/GenericCycleInfo.h
+++ b/llvm/include/llvm/ADT/GenericCycleInfo.h
@@ -107,13 +107,6 @@ template  class GenericCycle {
 return is_contained(Entries, Block);
   }
 
-  /// \brief Replace all entries with \p Block as single entry.
-  void setSingleEntry(BlockT *Block) {
-assert(contains(Block));
-Entries.clear();
-Entries.push_back(Block);
-  }
-
   /// \brief Return whether \p Block is contained in the cycle.
   bool contains(const BlockT *Block) const { return Blocks.contains(Block); }
 
@@ -199,16 +192,11 @@ template  class GenericCycle {
   //@{
   using const_entry_iterator =
   typename SmallVectorImpl::const_iterator;
-  const_entry_iterator entry_begin() const { return Entries.begin(); }
-  const_entry_iterator entry_end() const { return Entries.end(); }
+
   size_t getNumEntries() const { return Entries.size(); }
   iterator_range entries() const {
-return llvm::make_range(entry_begin(), entry_end());
+return llvm::make_range(Entries.begin(), Entries.end());
   }
-  using const_reverse_entry_iterator =
-  typename SmallVectorImpl::const_reverse_iterator;
-  const_reverse_entry_iterator entry_rbegin() const { return Entries.rbegin(); 
}
-  const_reverse_entry_iterator entry_rend() const { return Entries.rend(); }
   //@}
 
   Printable printEntries(const ContextT &Ctx) const {
@@ -267,6 +255,12 @@ template  class GenericCycleInfo {
   /// the subtree.
   void moveTopLevelCycleToNewParent(CycleT *NewParent, CycleT *Child);
 
+  /// Assumes that \p Cycle is the innermost cycle containing \p Block.
+  /// \p Block will be appended to \p Cycle and all of its parent cycles.
+  /// \p Block will be added to BlockMap with \p Cycle and
+  /// BlockMapTopLevel with \p Cycle's top level parent cycle.
+  void addBlockToCycle(BlockT *Block, CycleT *Cycle);
+
 public:
   GenericCycleInfo() = default;
   GenericCycleInfo(GenericCycleInfo &&) = default;
@@ -284,12 +278,6 @@ template  class GenericCycleInfo {
   unsigned getCycleDepth(const BlockT *Block) const;
   CycleT *getTopLevelParentCycle(BlockT *Block);
 
-  /// Assumes that \p Cycle is the innermost cycle containing \p Block.
-  /// \p Block will be appended to \p Cycle and all of its parent cycles.
-  /// \p Block will be added to BlockMap with \p Cycle and
-  /// BlockMapTopLevel with \p Cycle's top level parent cycle.
-  void addBlockToCycle(BlockT *Block, CycleT *Cycle);
-
   /// Methods for debug and self-test.
   //@{
   void verifyCycleNest(bool VerifyFull = false) const;

diff  --git a/llvm/lib/Transforms/Utils/FixIrreducible.cpp 
b/llvm/lib/Transforms/Utils/FixIrreducible.cpp
index 67fb806d3eae54..cdd4b36d2d9ebf 100644
--- a/llvm/lib/Transforms/Utils/FixIrreducible.cpp
+++ b/llvm/lib/Transforms/Utils/FixIrreducible.cpp
@@ -6,66 +6,50 @@
 //
 
//===--===//
 //
-// INPUT CFG: The blocks H and B form an irreducible cycle with two headers.
+// An irreducible SCC is one which has multiple "header" blocks, i.e., blocks
+// with control-flow edges incident from outside the SCC.  This pass converts a
+// irreducible SCC into a natural loop by applying the following 
transformation:
+//
+// 1. Collect the set of headers H of the SCC.
+// 2. Collect the set of predecessors P of these headers. These may be inside 
as
+//well as outside the SCC.
+// 3. Create block N and redirect every edge from set P to set H through N.
+//
+// This converts the SCC into a natural loop with N as the header: N is the 
only
+// block with edges incident from outside the SCC, and all backedges in the SCC
+// are incident on N, i.e., for every backedge, the head now dominates the 
tail.
+//
+// INPUT CFG: The blocks A an

[llvm-branch-commits] [flang] [Flang][OpenMP] Move loop privatization out of dispatch (PR #106066)

2024-08-26 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak created 
https://github.com/llvm/llvm-project/pull/106066

This patch moves the creation of `DataSharingProcessor` instances for loop 
constructs out of `genOMPDispatch()` and into their corresponding codegen 
functions. This is a necessary first step to enable a proper handling of 
privatization on composite constructs.

Some tests are updated due to a change of order between clause processing and 
privatization.

>From 23983c7dff8f61877943a8a8d2332b485e879549 Mon Sep 17 00:00:00 2001
From: Sergio Afonso 
Date: Mon, 26 Aug 2024 13:29:52 +0100
Subject: [PATCH] [Flang][OpenMP] Move loop privatization out of dispatch

This patch moves the creation of `DataSharingProcessor` instances for loop
constructs out of `genOMPDispatch()` and into their corresponding codegen
functions. This is a necessary first step to enable a proper handling of
privatization on composite constructs.

Some tests are updated due to a change of order between clause processing and
privatization.
---
 flang/lib/Lower/OpenMP/OpenMP.cpp | 142 +++---
 .../test/Lower/OpenMP/parallel-reduction3.f90 |  14 +-
 .../wsloop-reduction-array-assumed-shape.f90  |  14 +-
 .../Lower/OpenMP/wsloop-reduction-array.f90   |  18 +--
 .../Lower/OpenMP/wsloop-reduction-array2.f90  |  18 +--
 .../wsloop-reduction-multiple-clauses.f90 |  22 +--
 6 files changed, 127 insertions(+), 101 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index d614db8b68ef65..307cf47247b743 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1044,7 +1044,6 @@ static void genDistributeClauses(lower::AbstractConverter 
&converter,
   cp.processAllocate(clauseOps);
   cp.processDistSchedule(stmtCtx, clauseOps);
   cp.processOrder(clauseOps);
-  // TODO Support delayed privatization.
 }
 
 static void genFlushClauses(lower::AbstractConverter &converter,
@@ -1128,7 +1127,6 @@ static void genSimdClauses(lower::AbstractConverter 
&converter,
   cp.processSafelen(clauseOps);
   cp.processSimdlen(clauseOps);
 
-  // TODO Support delayed privatization.
   cp.processTODO(
   loc, llvm::omp::Directive::OMPD_simd);
 }
@@ -1299,7 +1297,6 @@ static void genWsloopClauses(
   cp.processOrdered(clauseOps);
   cp.processReduction(loc, clauseOps, &reductionTypes, &reductionSyms);
   cp.processSchedule(stmtCtx, clauseOps);
-  // TODO Support delayed privatization.
 
   cp.processTODO(
   loc, llvm::omp::Directive::OMPD_do);
@@ -1918,17 +1915,25 @@ genTeamsOp(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
 // also be a leaf of a composite construct
 
//===--===//
 
-static void genStandaloneDistribute(
-lower::AbstractConverter &converter, lower::SymMap &symTable,
-semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
-mlir::Location loc, const ConstructQueue &queue,
-ConstructQueue::const_iterator item, DataSharingProcessor &dsp) {
+static void genStandaloneDistribute(lower::AbstractConverter &converter,
+lower::SymMap &symTable,
+semantics::SemanticsContext &semaCtx,
+lower::pft::Evaluation &eval,
+mlir::Location loc,
+const ConstructQueue &queue,
+ConstructQueue::const_iterator item) {
   lower::StatementContext stmtCtx;
 
   mlir::omp::DistributeOperands distributeClauseOps;
   genDistributeClauses(converter, semaCtx, stmtCtx, item->clauses, loc,
distributeClauseOps);
 
+  // TODO: Support delayed privatization.
+  DataSharingProcessor dsp(converter, semaCtx, item->clauses, eval,
+   /*shouldCollectPreDeterminedSymbols=*/true,
+   /*useDelayedPrivatization=*/false, &symTable);
+  dsp.processStep1();
+
   mlir::omp::LoopNestOperands loopNestClauseOps;
   llvm::SmallVector iv;
   genLoopNestClauses(converter, semaCtx, eval, item->clauses, loc,
@@ -1949,8 +1954,7 @@ static void genStandaloneDo(lower::AbstractConverter 
&converter,
 semantics::SemanticsContext &semaCtx,
 lower::pft::Evaluation &eval, mlir::Location loc,
 const ConstructQueue &queue,
-ConstructQueue::const_iterator item,
-DataSharingProcessor &dsp) {
+ConstructQueue::const_iterator item) {
   lower::StatementContext stmtCtx;
 
   mlir::omp::WsloopOperands wsloopClauseOps;
@@ -1959,6 +1963,12 @@ static void genStandaloneDo(lower::AbstractConverter 
&converter,
   genWsloopClauses(converter, semaCtx, stmtCtx, item->clauses, loc,
wsloopClauseOps, reductionTypes, reductionSyms);
 
+  // TODO: Support delayed privati

[llvm-branch-commits] [flang] [Flang][OpenMP] Move loop privatization out of dispatch (PR #106066)

2024-08-26 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-flang-fir-hlfir

Author: Sergio Afonso (skatrak)


Changes

This patch moves the creation of `DataSharingProcessor` instances for loop 
constructs out of `genOMPDispatch()` and into their corresponding codegen 
functions. This is a necessary first step to enable a proper handling of 
privatization on composite constructs.

Some tests are updated due to a change of order between clause processing and 
privatization.

---

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


6 Files Affected:

- (modified) flang/lib/Lower/OpenMP/OpenMP.cpp (+84-58) 
- (modified) flang/test/Lower/OpenMP/parallel-reduction3.f90 (+7-7) 
- (modified) flang/test/Lower/OpenMP/wsloop-reduction-array-assumed-shape.f90 
(+7-7) 
- (modified) flang/test/Lower/OpenMP/wsloop-reduction-array.f90 (+9-9) 
- (modified) flang/test/Lower/OpenMP/wsloop-reduction-array2.f90 (+9-9) 
- (modified) flang/test/Lower/OpenMP/wsloop-reduction-multiple-clauses.f90 
(+11-11) 


``diff
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index d614db8b68ef65..307cf47247b743 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1044,7 +1044,6 @@ static void genDistributeClauses(lower::AbstractConverter 
&converter,
   cp.processAllocate(clauseOps);
   cp.processDistSchedule(stmtCtx, clauseOps);
   cp.processOrder(clauseOps);
-  // TODO Support delayed privatization.
 }
 
 static void genFlushClauses(lower::AbstractConverter &converter,
@@ -1128,7 +1127,6 @@ static void genSimdClauses(lower::AbstractConverter 
&converter,
   cp.processSafelen(clauseOps);
   cp.processSimdlen(clauseOps);
 
-  // TODO Support delayed privatization.
   cp.processTODO(
   loc, llvm::omp::Directive::OMPD_simd);
 }
@@ -1299,7 +1297,6 @@ static void genWsloopClauses(
   cp.processOrdered(clauseOps);
   cp.processReduction(loc, clauseOps, &reductionTypes, &reductionSyms);
   cp.processSchedule(stmtCtx, clauseOps);
-  // TODO Support delayed privatization.
 
   cp.processTODO(
   loc, llvm::omp::Directive::OMPD_do);
@@ -1918,17 +1915,25 @@ genTeamsOp(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
 // also be a leaf of a composite construct
 
//===--===//
 
-static void genStandaloneDistribute(
-lower::AbstractConverter &converter, lower::SymMap &symTable,
-semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
-mlir::Location loc, const ConstructQueue &queue,
-ConstructQueue::const_iterator item, DataSharingProcessor &dsp) {
+static void genStandaloneDistribute(lower::AbstractConverter &converter,
+lower::SymMap &symTable,
+semantics::SemanticsContext &semaCtx,
+lower::pft::Evaluation &eval,
+mlir::Location loc,
+const ConstructQueue &queue,
+ConstructQueue::const_iterator item) {
   lower::StatementContext stmtCtx;
 
   mlir::omp::DistributeOperands distributeClauseOps;
   genDistributeClauses(converter, semaCtx, stmtCtx, item->clauses, loc,
distributeClauseOps);
 
+  // TODO: Support delayed privatization.
+  DataSharingProcessor dsp(converter, semaCtx, item->clauses, eval,
+   /*shouldCollectPreDeterminedSymbols=*/true,
+   /*useDelayedPrivatization=*/false, &symTable);
+  dsp.processStep1();
+
   mlir::omp::LoopNestOperands loopNestClauseOps;
   llvm::SmallVector iv;
   genLoopNestClauses(converter, semaCtx, eval, item->clauses, loc,
@@ -1949,8 +1954,7 @@ static void genStandaloneDo(lower::AbstractConverter 
&converter,
 semantics::SemanticsContext &semaCtx,
 lower::pft::Evaluation &eval, mlir::Location loc,
 const ConstructQueue &queue,
-ConstructQueue::const_iterator item,
-DataSharingProcessor &dsp) {
+ConstructQueue::const_iterator item) {
   lower::StatementContext stmtCtx;
 
   mlir::omp::WsloopOperands wsloopClauseOps;
@@ -1959,6 +1963,12 @@ static void genStandaloneDo(lower::AbstractConverter 
&converter,
   genWsloopClauses(converter, semaCtx, stmtCtx, item->clauses, loc,
wsloopClauseOps, reductionTypes, reductionSyms);
 
+  // TODO: Support delayed privatization.
+  DataSharingProcessor dsp(converter, semaCtx, item->clauses, eval,
+   /*shouldCollectPreDeterminedSymbols=*/true,
+   /*useDelayedPrivatization=*/false, &symTable);
+  dsp.processStep1();
+
   mlir::omp::LoopNestOperands loopNestClauseOps;
   llvm::SmallVector iv;
   genLoopNestClauses(converte

[llvm-branch-commits] [clang-tools-extra] [clangd] Add clangd 19 release notes (PR #105975)

2024-08-26 Thread Haojian Wu via llvm-branch-commits

https://github.com/hokein commented:

Thanks. I’ll leave the final approval to @kadircet.

Should we mention the module support, even though it’s still in the initial 
stages?



https://github.com/llvm/llvm-project/pull/105975
___
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] [libc] [libc][math][c23] Add logf16 C23 math function (PR #106072)

2024-08-26 Thread via llvm-branch-commits

https://github.com/overmighty created 
https://github.com/llvm/llvm-project/pull/106072

Part of #95250.

>From efc9ccab9373b3dcc31b520873eaf2fff40b8b58 Mon Sep 17 00:00:00 2001
From: OverMighty 
Date: Mon, 26 Aug 2024 15:30:54 +0200
Subject: [PATCH] [libc][math][c23] Add logf16 C23 math function

Part of #95250.
---
 libc/config/gpu/entrypoints.txt  |   1 +
 libc/config/linux/x86_64/entrypoints.txt |   1 +
 libc/docs/math/index.rst |   2 +-
 libc/spec/stdc.td|   1 +
 libc/src/math/CMakeLists.txt |   1 +
 libc/src/math/generic/CMakeLists.txt |  22 
 libc/src/math/generic/expxf16.h  |  26 
 libc/src/math/generic/logf16.cpp | 158 +++
 libc/src/math/logf16.h   |  21 +++
 libc/test/UnitTest/FPMatcher.h   |  13 ++
 libc/test/src/math/CMakeLists.txt|  11 ++
 libc/test/src/math/logf16_test.cpp   |  40 ++
 libc/test/src/math/smoke/CMakeLists.txt  |  12 ++
 libc/test/src/math/smoke/logf16_test.cpp |  47 +++
 14 files changed, 355 insertions(+), 1 deletion(-)
 create mode 100644 libc/src/math/generic/logf16.cpp
 create mode 100644 libc/src/math/logf16.h
 create mode 100644 libc/test/src/math/logf16_test.cpp
 create mode 100644 libc/test/src/math/smoke/logf16_test.cpp

diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index b206bb7c936f39..e6a8e381a9212a 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -532,6 +532,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llrintf16
 libc.src.math.llroundf16
 libc.src.math.logbf16
+libc.src.math.logf16
 libc.src.math.lrintf16
 libc.src.math.lroundf16
 libc.src.math.modff16
diff --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index b702a7ff482a5c..69944ce3904562 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -643,6 +643,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llrintf16
 libc.src.math.llroundf16
 libc.src.math.logbf16
+libc.src.math.logf16
 libc.src.math.lrintf16
 libc.src.math.lroundf16
 libc.src.math.modff16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index de88f14426799f..e958312b313589 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -306,7 +306,7 @@ Higher Math Functions
 
+---+--+-++--++++
 | lgamma|  | ||
  || 7.12.8.3   | F.10.5.3  
 |
 
+---+--+-++--++++
-| log   | |check|  | |check| ||
  || 7.12.6.11  | F.10.3.11 
 |
+| log   | |check|  | |check| || 
|check|  || 7.12.6.11  | 
F.10.3.11  |
 
+---+--+-++--++++
 | log10 | |check|  | |check| ||
  || 7.12.6.12  | F.10.3.12 
 |
 
+---+--+-++--++++
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 043762bb227456..c3115b19349ff4 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -565,6 +565,7 @@ def StdC : StandardSpec<"stdc"> {
 
   FunctionSpec<"log", RetValSpec, [ArgSpec]>,
   FunctionSpec<"logf", RetValSpec, [ArgSpec]>,
+  GuardedFunctionSpec<"logf16", RetValSpec, 
[ArgSpec], "LIBC_TYPES_HAS_FLOAT16">,
 
   FunctionSpec<"logb", RetValSpec, [ArgSpec]>,
   FunctionSpec<"logbf", RetValSpec, [ArgSpec]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index be05903d4a1c6e..47c4ad188ef6df 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -331,6 +331,7 @@ add_math_entrypoint_object(log2f)
 
 add_math_entrypoint_object(log)
 add_math_entrypoint_object(logf)
+add_math_entrypoint_object(logf16)
 
 add_math_entrypoint_object(logb)
 add_math_entrypoint_object(logbf)
diff --git a/libc/src/math/generic/CMakeLists.txt 
b/libc/src/math/generic/CMakeLists.txt
index 9534d17426486b..6a9d9f02f190f0 100644
--- a/libc/src/math/gen

[llvm-branch-commits] [libc] [libc][math][c23] Add logf16 C23 math function (PR #106072)

2024-08-26 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libc

Author: OverMighty (overmighty)


Changes

Part of #95250.

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


14 Files Affected:

- (modified) libc/config/gpu/entrypoints.txt (+1) 
- (modified) libc/config/linux/x86_64/entrypoints.txt (+1) 
- (modified) libc/docs/math/index.rst (+1-1) 
- (modified) libc/spec/stdc.td (+1) 
- (modified) libc/src/math/CMakeLists.txt (+1) 
- (modified) libc/src/math/generic/CMakeLists.txt (+22) 
- (modified) libc/src/math/generic/expxf16.h (+26) 
- (added) libc/src/math/generic/logf16.cpp (+158) 
- (added) libc/src/math/logf16.h (+21) 
- (modified) libc/test/UnitTest/FPMatcher.h (+13) 
- (modified) libc/test/src/math/CMakeLists.txt (+11) 
- (added) libc/test/src/math/logf16_test.cpp (+40) 
- (modified) libc/test/src/math/smoke/CMakeLists.txt (+12) 
- (added) libc/test/src/math/smoke/logf16_test.cpp (+47) 


``diff
diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index b206bb7c936f39..e6a8e381a9212a 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -532,6 +532,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llrintf16
 libc.src.math.llroundf16
 libc.src.math.logbf16
+libc.src.math.logf16
 libc.src.math.lrintf16
 libc.src.math.lroundf16
 libc.src.math.modff16
diff --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index b702a7ff482a5c..69944ce3904562 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -643,6 +643,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llrintf16
 libc.src.math.llroundf16
 libc.src.math.logbf16
+libc.src.math.logf16
 libc.src.math.lrintf16
 libc.src.math.lroundf16
 libc.src.math.modff16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index de88f14426799f..e958312b313589 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -306,7 +306,7 @@ Higher Math Functions
 
+---+--+-++--++++
 | lgamma|  | ||
  || 7.12.8.3   | F.10.5.3  
 |
 
+---+--+-++--++++
-| log   | |check|  | |check| ||
  || 7.12.6.11  | F.10.3.11 
 |
+| log   | |check|  | |check| || 
|check|  || 7.12.6.11  | 
F.10.3.11  |
 
+---+--+-++--++++
 | log10 | |check|  | |check| ||
  || 7.12.6.12  | F.10.3.12 
 |
 
+---+--+-++--++++
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 043762bb227456..c3115b19349ff4 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -565,6 +565,7 @@ def StdC : StandardSpec<"stdc"> {
 
   FunctionSpec<"log", RetValSpec, [ArgSpec]>,
   FunctionSpec<"logf", RetValSpec, [ArgSpec]>,
+  GuardedFunctionSpec<"logf16", RetValSpec, 
[ArgSpec], "LIBC_TYPES_HAS_FLOAT16">,
 
   FunctionSpec<"logb", RetValSpec, [ArgSpec]>,
   FunctionSpec<"logbf", RetValSpec, [ArgSpec]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index be05903d4a1c6e..47c4ad188ef6df 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -331,6 +331,7 @@ add_math_entrypoint_object(log2f)
 
 add_math_entrypoint_object(log)
 add_math_entrypoint_object(logf)
+add_math_entrypoint_object(logf16)
 
 add_math_entrypoint_object(logb)
 add_math_entrypoint_object(logbf)
diff --git a/libc/src/math/generic/CMakeLists.txt 
b/libc/src/math/generic/CMakeLists.txt
index 9534d17426486b..6a9d9f02f190f0 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -2210,6 +2210,28 @@ add_entrypoint_object(
 -O3
 )
 
+add_entrypoint_object(
+  logf16
+  SRCS
+logf16.cpp
+  HDRS
+../logf16.h
+  DEPENDS
+.expxf16
+libc.hdr.errno_macros
+libc.hdr.fenv_macros
+libc.src.__support.CPP.array
+libc.src.__support.FPUtil.except_value_utils
+libc.src.__support.FPUtil

[llvm-branch-commits] [libunwind] release/19.x: [libunwind] Stop installing the mach-o module map (#105616) (PR #105896)

2024-08-26 Thread Louis Dionne via llvm-branch-commits

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

CI failures look like flukes unrelated to the patch (the CI machines got 
updated and some tests started XPASSing).

LGTM

https://github.com/llvm/llvm-project/pull/105896
___
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] [libc] [libc][math][c23] Add log2f16 C23 math function (PR #106084)

2024-08-26 Thread via llvm-branch-commits

https://github.com/overmighty created 
https://github.com/llvm/llvm-project/pull/106084

Part of #95250.

>From 2f0d352e311301b0853346587cf03d5137b22d76 Mon Sep 17 00:00:00 2001
From: OverMighty 
Date: Mon, 26 Aug 2024 16:36:19 +0200
Subject: [PATCH] [libc][math][c23] Add log2f16 C23 math function

Part of #95250.
---
 libc/config/gpu/entrypoints.txt   |   1 +
 libc/config/linux/x86_64/entrypoints.txt  |   1 +
 libc/docs/math/index.rst  |   2 +-
 libc/spec/stdc.td |   1 +
 libc/src/math/CMakeLists.txt  |   1 +
 libc/src/math/generic/CMakeLists.txt  |  21 
 libc/src/math/generic/expxf16.h   |  14 +++
 libc/src/math/generic/log2f16.cpp | 147 ++
 libc/src/math/log2f16.h   |  21 
 libc/test/src/math/CMakeLists.txt |  11 ++
 libc/test/src/math/log2f16_test.cpp   |  40 ++
 libc/test/src/math/smoke/CMakeLists.txt   |  12 ++
 libc/test/src/math/smoke/log2f16_test.cpp |  47 +++
 13 files changed, 318 insertions(+), 1 deletion(-)
 create mode 100644 libc/src/math/generic/log2f16.cpp
 create mode 100644 libc/src/math/log2f16.h
 create mode 100644 libc/test/src/math/log2f16_test.cpp
 create mode 100644 libc/test/src/math/smoke/log2f16_test.cpp

diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index e6a8e381a9212a..279e397287d8e3 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -531,6 +531,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llogbf16
 libc.src.math.llrintf16
 libc.src.math.llroundf16
+libc.src.math.log2f16
 libc.src.math.logbf16
 libc.src.math.logf16
 libc.src.math.lrintf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index 69944ce3904562..3fd279071ccb1d 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -642,6 +642,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llogbf16
 libc.src.math.llrintf16
 libc.src.math.llroundf16
+libc.src.math.log2f16
 libc.src.math.logbf16
 libc.src.math.logf16
 libc.src.math.lrintf16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index e958312b313589..6b30cac1366d6b 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -314,7 +314,7 @@ Higher Math Functions
 
+---+--+-++--++++
 | log1p | |check|  | |check| ||
  || 7.12.6.14  | F.10.3.14 
 |
 
+---+--+-++--++++
-| log2  | |check|  | |check| ||
  || 7.12.6.15  | F.10.3.15 
 |
+| log2  | |check|  | |check| || 
|check|  || 7.12.6.15  | 
F.10.3.15  |
 
+---+--+-++--++++
 | log2p1|  | ||
  || 7.12.6.16  | F.10.3.16 
 |
 
+---+--+-++--++++
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index c3115b19349ff4..de4b8f85e94d11 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -562,6 +562,7 @@ def StdC : StandardSpec<"stdc"> {
 
   FunctionSpec<"log2", RetValSpec, [ArgSpec]>,
   FunctionSpec<"log2f", RetValSpec, [ArgSpec]>,
+  GuardedFunctionSpec<"log2f16", RetValSpec, 
[ArgSpec], "LIBC_TYPES_HAS_FLOAT16">,
 
   FunctionSpec<"log", RetValSpec, [ArgSpec]>,
   FunctionSpec<"logf", RetValSpec, [ArgSpec]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 47c4ad188ef6df..23c35828b576f4 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -328,6 +328,7 @@ add_math_entrypoint_object(log1pf)
 
 add_math_entrypoint_object(log2)
 add_math_entrypoint_object(log2f)
+add_math_entrypoint_object(log2f16)
 
 add_math_entrypoint_object(log)
 add_math_entrypoint_object(logf)
diff --git a/libc/src/math/generic/CMakeLists.txt 
b/libc/src/math/generic/CMakeLists.txt
index 6a9d9f02f190f0..0af3d2ad24e0a3 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/sr

[llvm-branch-commits] [libc] [libc][math][c23] Add log2f16 C23 math function (PR #106084)

2024-08-26 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libc

Author: OverMighty (overmighty)


Changes

Part of #95250.

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


13 Files Affected:

- (modified) libc/config/gpu/entrypoints.txt (+1) 
- (modified) libc/config/linux/x86_64/entrypoints.txt (+1) 
- (modified) libc/docs/math/index.rst (+1-1) 
- (modified) libc/spec/stdc.td (+1) 
- (modified) libc/src/math/CMakeLists.txt (+1) 
- (modified) libc/src/math/generic/CMakeLists.txt (+21) 
- (modified) libc/src/math/generic/expxf16.h (+14) 
- (added) libc/src/math/generic/log2f16.cpp (+147) 
- (added) libc/src/math/log2f16.h (+21) 
- (modified) libc/test/src/math/CMakeLists.txt (+11) 
- (added) libc/test/src/math/log2f16_test.cpp (+40) 
- (modified) libc/test/src/math/smoke/CMakeLists.txt (+12) 
- (added) libc/test/src/math/smoke/log2f16_test.cpp (+47) 


``diff
diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index e6a8e381a9212a..279e397287d8e3 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -531,6 +531,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llogbf16
 libc.src.math.llrintf16
 libc.src.math.llroundf16
+libc.src.math.log2f16
 libc.src.math.logbf16
 libc.src.math.logf16
 libc.src.math.lrintf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index 69944ce3904562..3fd279071ccb1d 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -642,6 +642,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llogbf16
 libc.src.math.llrintf16
 libc.src.math.llroundf16
+libc.src.math.log2f16
 libc.src.math.logbf16
 libc.src.math.logf16
 libc.src.math.lrintf16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index e958312b313589..6b30cac1366d6b 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -314,7 +314,7 @@ Higher Math Functions
 
+---+--+-++--++++
 | log1p | |check|  | |check| ||
  || 7.12.6.14  | F.10.3.14 
 |
 
+---+--+-++--++++
-| log2  | |check|  | |check| ||
  || 7.12.6.15  | F.10.3.15 
 |
+| log2  | |check|  | |check| || 
|check|  || 7.12.6.15  | 
F.10.3.15  |
 
+---+--+-++--++++
 | log2p1|  | ||
  || 7.12.6.16  | F.10.3.16 
 |
 
+---+--+-++--++++
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index c3115b19349ff4..de4b8f85e94d11 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -562,6 +562,7 @@ def StdC : StandardSpec<"stdc"> {
 
   FunctionSpec<"log2", RetValSpec, [ArgSpec]>,
   FunctionSpec<"log2f", RetValSpec, [ArgSpec]>,
+  GuardedFunctionSpec<"log2f16", RetValSpec, 
[ArgSpec], "LIBC_TYPES_HAS_FLOAT16">,
 
   FunctionSpec<"log", RetValSpec, [ArgSpec]>,
   FunctionSpec<"logf", RetValSpec, [ArgSpec]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 47c4ad188ef6df..23c35828b576f4 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -328,6 +328,7 @@ add_math_entrypoint_object(log1pf)
 
 add_math_entrypoint_object(log2)
 add_math_entrypoint_object(log2f)
+add_math_entrypoint_object(log2f16)
 
 add_math_entrypoint_object(log)
 add_math_entrypoint_object(logf)
diff --git a/libc/src/math/generic/CMakeLists.txt 
b/libc/src/math/generic/CMakeLists.txt
index 6a9d9f02f190f0..0af3d2ad24e0a3 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -2171,6 +2171,27 @@ add_entrypoint_object(
 -O3
 )
 
+add_entrypoint_object(
+  log2f16
+  SRCS
+log2f16.cpp
+  HDRS
+../log2f16.h
+  DEPENDS
+.expxf16
+libc.hdr.errno_macros
+libc.hdr.fenv_macros
+libc.src.__support.FPUtil.except_value_utils
+libc.src.__support.FPUtil.fenv_impl
+libc.src.__support.FPUtil.fp_bits
+libc.src.__support.FPU

[llvm-branch-commits] [libc] [libc][math][c23] Add logf16 C23 math function (PR #106072)

2024-08-26 Thread via llvm-branch-commits

https://github.com/overmighty updated 
https://github.com/llvm/llvm-project/pull/106072

>From efc9ccab9373b3dcc31b520873eaf2fff40b8b58 Mon Sep 17 00:00:00 2001
From: OverMighty 
Date: Mon, 26 Aug 2024 15:30:54 +0200
Subject: [PATCH 1/2] [libc][math][c23] Add logf16 C23 math function

Part of #95250.
---
 libc/config/gpu/entrypoints.txt  |   1 +
 libc/config/linux/x86_64/entrypoints.txt |   1 +
 libc/docs/math/index.rst |   2 +-
 libc/spec/stdc.td|   1 +
 libc/src/math/CMakeLists.txt |   1 +
 libc/src/math/generic/CMakeLists.txt |  22 
 libc/src/math/generic/expxf16.h  |  26 
 libc/src/math/generic/logf16.cpp | 158 +++
 libc/src/math/logf16.h   |  21 +++
 libc/test/UnitTest/FPMatcher.h   |  13 ++
 libc/test/src/math/CMakeLists.txt|  11 ++
 libc/test/src/math/logf16_test.cpp   |  40 ++
 libc/test/src/math/smoke/CMakeLists.txt  |  12 ++
 libc/test/src/math/smoke/logf16_test.cpp |  47 +++
 14 files changed, 355 insertions(+), 1 deletion(-)
 create mode 100644 libc/src/math/generic/logf16.cpp
 create mode 100644 libc/src/math/logf16.h
 create mode 100644 libc/test/src/math/logf16_test.cpp
 create mode 100644 libc/test/src/math/smoke/logf16_test.cpp

diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index b206bb7c936f39..e6a8e381a9212a 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -532,6 +532,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llrintf16
 libc.src.math.llroundf16
 libc.src.math.logbf16
+libc.src.math.logf16
 libc.src.math.lrintf16
 libc.src.math.lroundf16
 libc.src.math.modff16
diff --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index b702a7ff482a5c..69944ce3904562 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -643,6 +643,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llrintf16
 libc.src.math.llroundf16
 libc.src.math.logbf16
+libc.src.math.logf16
 libc.src.math.lrintf16
 libc.src.math.lroundf16
 libc.src.math.modff16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index de88f14426799f..e958312b313589 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -306,7 +306,7 @@ Higher Math Functions
 
+---+--+-++--++++
 | lgamma|  | ||
  || 7.12.8.3   | F.10.5.3  
 |
 
+---+--+-++--++++
-| log   | |check|  | |check| ||
  || 7.12.6.11  | F.10.3.11 
 |
+| log   | |check|  | |check| || 
|check|  || 7.12.6.11  | 
F.10.3.11  |
 
+---+--+-++--++++
 | log10 | |check|  | |check| ||
  || 7.12.6.12  | F.10.3.12 
 |
 
+---+--+-++--++++
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 043762bb227456..c3115b19349ff4 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -565,6 +565,7 @@ def StdC : StandardSpec<"stdc"> {
 
   FunctionSpec<"log", RetValSpec, [ArgSpec]>,
   FunctionSpec<"logf", RetValSpec, [ArgSpec]>,
+  GuardedFunctionSpec<"logf16", RetValSpec, 
[ArgSpec], "LIBC_TYPES_HAS_FLOAT16">,
 
   FunctionSpec<"logb", RetValSpec, [ArgSpec]>,
   FunctionSpec<"logbf", RetValSpec, [ArgSpec]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index be05903d4a1c6e..47c4ad188ef6df 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -331,6 +331,7 @@ add_math_entrypoint_object(log2f)
 
 add_math_entrypoint_object(log)
 add_math_entrypoint_object(logf)
+add_math_entrypoint_object(logf16)
 
 add_math_entrypoint_object(logb)
 add_math_entrypoint_object(logbf)
diff --git a/libc/src/math/generic/CMakeLists.txt 
b/libc/src/math/generic/CMakeLists.txt
index 9534d17426486b..6a9d9f02f190f0 100644
--- a/libc/src/math/generic/CMakeLis

[llvm-branch-commits] [libc] [libc][math][c23] Add logf16 C23 math function (PR #106072)

2024-08-26 Thread via llvm-branch-commits


@@ -287,6 +287,34 @@ template  LIBC_INLINE float16 
eval_sinh_or_cosh(float16 x) {
   lo, half_p_odd * exp2_hi_mid_diff, half_p_even * exp2_hi_mid_sum));
 }
 
+// Generated by Sollya with the following commands:
+//   > display = hexadecimal;
+//   > for i from 0 to 31 do print(round(log(1 + i * 2^-5), SG, RN));
+constexpr cpp::array LOGF_F = {
+0x0p+0f,0x1.f829bp-6f,  0x1.f0a30cp-5f, 0x1.6f0d28p-4f,
+0x1.e27076p-4f, 0x1.29553p-3f,  0x1.5ff308p-3f, 0x1.9525aap-3f,
+0x1.c8ff7cp-3f, 0x1.fb9186p-3f, 0x1.1675cap-2f, 0x1.2e8e2cp-2f,
+0x1.4618bcp-2f, 0x1.5d1bdcp-2f, 0x1.739d8p-2f,  0x1.89a338p-2f,
+0x1.9f323ep-2f, 0x1.b44f78p-2f, 0x1.c8ff7cp-2f, 0x1.dd46ap-2f,
+0x1.f128f6p-2f, 0x1.02552ap-1f, 0x1.0be72ep-1f, 0x1.154c3ep-1f,
+0x1.1e85f6p-1f, 0x1.2795e2p-1f, 0x1.307d74p-1f, 0x1.393e0ep-1f,
+0x1.41d8fep-1f, 0x1.4a4f86p-1f, 0x1.52a2d2p-1f, 0x1.5ad404p-1f,
+};
+
+// Generated by Sollya with the following commands:
+//   > display = hexadecimal;
+//   > for i from 0 to 31 do print(round(1 / (1 + i * 2^-5), SG, RN));
+constexpr cpp::array ONE_OVER_F = {

overmighty wrote:

Maybe I shouldn't have used the same `ONE_OVER_F` name that common_constants.h 
uses for the `double` 1/f lookup table.

https://github.com/llvm/llvm-project/pull/106072
___
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] release/19.x: [PowerPC] Fix mask for __st[d/w/h/b]cx builtins (#104453) (PR #106085)

2024-08-26 Thread via llvm-branch-commits

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

Backport 327edbe07ab4370ceb20ea7c805f64950871d835

Requested by: @syzaara

>From 18efd919f5a0408d95b70510d201ab0d7a7a3aa4 Mon Sep 17 00:00:00 2001
From: Zaara Syeda 
Date: Thu, 22 Aug 2024 09:55:46 -0400
Subject: [PATCH] [PowerPC] Fix mask for __st[d/w/h/b]cx builtins (#104453)

These builtins are currently returning CR0 which will have the format
[0, 0, flag_true_if_saved, XER].
We only want to return flag_true_if_saved. This patch adds a shift to
remove the XER bit before returning.

(cherry picked from commit 327edbe07ab4370ceb20ea7c805f64950871d835)
---
 llvm/lib/Target/PowerPC/PPCInstr64Bit.td |  4 ++--
 llvm/lib/Target/PowerPC/PPCInstrInfo.td  | 12 ++--
 ...-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll |  2 +-
 .../builtins-ppc-xlcompat-LoadReserve-StoreCond.ll   |  9 ++---
 4 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/llvm/lib/Target/PowerPC/PPCInstr64Bit.td 
b/llvm/lib/Target/PowerPC/PPCInstr64Bit.td
index 8f5afbae01de15..ed39fc67a0a730 100644
--- a/llvm/lib/Target/PowerPC/PPCInstr64Bit.td
+++ b/llvm/lib/Target/PowerPC/PPCInstr64Bit.td
@@ -2014,9 +2014,9 @@ def SLBSYNC : XForm_0<31, 338, (outs), (ins), "slbsync", 
IIC_SprSLBSYNC, []>;
 } // IsISA3_0
 
 def : Pat<(int_ppc_stdcx ForceXForm:$dst, g8rc:$A),
-  (STDCX g8rc:$A, ForceXForm:$dst)>;
+  (RLWINM (STDCX g8rc:$A, ForceXForm:$dst), 31, 31, 31)>;
 def : Pat<(PPCStoreCond ForceXForm:$dst, g8rc:$A, 8),
-  (STDCX g8rc:$A, ForceXForm:$dst)>;
+  (RLWINM (STDCX g8rc:$A, ForceXForm:$dst), 31, 31, 31)>;
 
 def : Pat<(i64 (int_ppc_mfspr timm:$SPR)),
   (MFSPR8 $SPR)>;
diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.td 
b/llvm/lib/Target/PowerPC/PPCInstrInfo.td
index 1686249c0f89d4..69f8ddc0ea7010 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrInfo.td
+++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.td
@@ -5286,13 +5286,13 @@ def : Pat<(i64 (bitreverse i64:$A)),
   (OR8 (RLDICR DWBytes7654.DWord, 32, 31), DWBytes3210.DWord)>;
 
 def : Pat<(int_ppc_stwcx ForceXForm:$dst, gprc:$A),
-  (STWCX gprc:$A, ForceXForm:$dst)>;
+  (RLWINM (STWCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
 def : Pat<(PPCStoreCond ForceXForm:$dst, gprc:$A, 4),
-  (STWCX gprc:$A, ForceXForm:$dst)>;
+  (RLWINM (STWCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
 def : Pat<(int_ppc_stbcx ForceXForm:$dst, gprc:$A),
-  (STBCX gprc:$A, ForceXForm:$dst)>;
+  (RLWINM (STBCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
 def : Pat<(PPCStoreCond ForceXForm:$dst, gprc:$A, 1),
-  (STBCX gprc:$A, ForceXForm:$dst)>;
+  (RLWINM (STBCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
 
 def : Pat<(int_ppc_fcfid f64:$A),
 (XSCVSXDDP $A)>;
@@ -5322,9 +5322,9 @@ def : Pat<(int_ppc_mtmsr gprc:$RS),
 
 let Predicates = [IsISA2_07] in {
   def : Pat<(int_ppc_sthcx ForceXForm:$dst, gprc:$A),
-(STHCX gprc:$A, ForceXForm:$dst)>;
+(RLWINM (STHCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
   def : Pat<(PPCStoreCond ForceXForm:$dst, gprc:$A, 2),
-(STHCX gprc:$A, ForceXForm:$dst)>;
+(RLWINM (STHCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
 }
 def : Pat<(int_ppc_dcbtstt ForceXForm:$dst),
   (DCBTST 16, ForceXForm:$dst)>;
diff --git 
a/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
 
b/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
index ddfdcda7a61a75..d765f0845641c6 100644
--- 
a/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
+++ 
b/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
@@ -26,7 +26,7 @@ define dso_local i64 @test_stdcx(ptr %a, i64 %b) {
 ; CHECK-NEXT:stdcx. 4, 0, 3
 ; CHECK-NEXT:mfocrf 3, 128
 ; CHECK-NEXT:srwi 3, 3, 28
-; CHECK-NEXT:extsw 3, 3
+; CHECK-NEXT:rlwinm 3, 3, 31, 31, 31
 ; CHECK-NEXT:blr
 entry:
   %0 = tail call i32 @llvm.ppc.stdcx(ptr %a, i64 %b)
diff --git 
a/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll 
b/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
index 8d90c5cb882064..778fd0a37a1ede 100644
--- a/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
+++ b/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
@@ -36,7 +36,7 @@ define dso_local signext i32 @test_stwcx(ptr %a, i32 signext 
%b) {
 ; CHECK-64-NEXT:stwcx. 4, 0, 3
 ; CHECK-64-NEXT:mfocrf 3, 128
 ; CHECK-64-NEXT:srwi 3, 3, 28
-; CHECK-64-NEXT:extsw 3, 3
+; CHECK-64-NEXT:rlwinm 3, 3, 31, 31, 31
 ; CHECK-64-NEXT:blr
 ;
 ; CHECK-32-LABEL: test_stwcx:
@@ -44,6 +44,7 @@ define dso_local signext i32 @test_stwcx(ptr %a, i32 signext 
%b) {
 ; CHECK-32-NEXT:stwcx. 4, 0, 3
 ; CHECK-32-NEXT:mfocrf 3, 128
 ; CHECK-32-NEXT:srwi 3, 3, 28
+; CHECK-32-NEXT:rlwin

[llvm-branch-commits] [llvm] release/19.x: [PowerPC] Fix mask for __st[d/w/h/b]cx builtins (#104453) (PR #106085)

2024-08-26 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/106085
___
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] release/19.x: [PowerPC] Fix mask for __st[d/w/h/b]cx builtins (#104453) (PR #106085)

2024-08-26 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-powerpc

Author: None (llvmbot)


Changes

Backport 327edbe07ab4370ceb20ea7c805f64950871d835

Requested by: @syzaara

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


4 Files Affected:

- (modified) llvm/lib/Target/PowerPC/PPCInstr64Bit.td (+2-2) 
- (modified) llvm/lib/Target/PowerPC/PPCInstrInfo.td (+6-6) 
- (modified) 
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
 (+1-1) 
- (modified) 
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll (+6-3) 


``diff
diff --git a/llvm/lib/Target/PowerPC/PPCInstr64Bit.td 
b/llvm/lib/Target/PowerPC/PPCInstr64Bit.td
index 8f5afbae01de15..ed39fc67a0a730 100644
--- a/llvm/lib/Target/PowerPC/PPCInstr64Bit.td
+++ b/llvm/lib/Target/PowerPC/PPCInstr64Bit.td
@@ -2014,9 +2014,9 @@ def SLBSYNC : XForm_0<31, 338, (outs), (ins), "slbsync", 
IIC_SprSLBSYNC, []>;
 } // IsISA3_0
 
 def : Pat<(int_ppc_stdcx ForceXForm:$dst, g8rc:$A),
-  (STDCX g8rc:$A, ForceXForm:$dst)>;
+  (RLWINM (STDCX g8rc:$A, ForceXForm:$dst), 31, 31, 31)>;
 def : Pat<(PPCStoreCond ForceXForm:$dst, g8rc:$A, 8),
-  (STDCX g8rc:$A, ForceXForm:$dst)>;
+  (RLWINM (STDCX g8rc:$A, ForceXForm:$dst), 31, 31, 31)>;
 
 def : Pat<(i64 (int_ppc_mfspr timm:$SPR)),
   (MFSPR8 $SPR)>;
diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.td 
b/llvm/lib/Target/PowerPC/PPCInstrInfo.td
index 1686249c0f89d4..69f8ddc0ea7010 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrInfo.td
+++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.td
@@ -5286,13 +5286,13 @@ def : Pat<(i64 (bitreverse i64:$A)),
   (OR8 (RLDICR DWBytes7654.DWord, 32, 31), DWBytes3210.DWord)>;
 
 def : Pat<(int_ppc_stwcx ForceXForm:$dst, gprc:$A),
-  (STWCX gprc:$A, ForceXForm:$dst)>;
+  (RLWINM (STWCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
 def : Pat<(PPCStoreCond ForceXForm:$dst, gprc:$A, 4),
-  (STWCX gprc:$A, ForceXForm:$dst)>;
+  (RLWINM (STWCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
 def : Pat<(int_ppc_stbcx ForceXForm:$dst, gprc:$A),
-  (STBCX gprc:$A, ForceXForm:$dst)>;
+  (RLWINM (STBCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
 def : Pat<(PPCStoreCond ForceXForm:$dst, gprc:$A, 1),
-  (STBCX gprc:$A, ForceXForm:$dst)>;
+  (RLWINM (STBCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
 
 def : Pat<(int_ppc_fcfid f64:$A),
 (XSCVSXDDP $A)>;
@@ -5322,9 +5322,9 @@ def : Pat<(int_ppc_mtmsr gprc:$RS),
 
 let Predicates = [IsISA2_07] in {
   def : Pat<(int_ppc_sthcx ForceXForm:$dst, gprc:$A),
-(STHCX gprc:$A, ForceXForm:$dst)>;
+(RLWINM (STHCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
   def : Pat<(PPCStoreCond ForceXForm:$dst, gprc:$A, 2),
-(STHCX gprc:$A, ForceXForm:$dst)>;
+(RLWINM (STHCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
 }
 def : Pat<(int_ppc_dcbtstt ForceXForm:$dst),
   (DCBTST 16, ForceXForm:$dst)>;
diff --git 
a/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
 
b/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
index ddfdcda7a61a75..d765f0845641c6 100644
--- 
a/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
+++ 
b/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond-64bit-only.ll
@@ -26,7 +26,7 @@ define dso_local i64 @test_stdcx(ptr %a, i64 %b) {
 ; CHECK-NEXT:stdcx. 4, 0, 3
 ; CHECK-NEXT:mfocrf 3, 128
 ; CHECK-NEXT:srwi 3, 3, 28
-; CHECK-NEXT:extsw 3, 3
+; CHECK-NEXT:rlwinm 3, 3, 31, 31, 31
 ; CHECK-NEXT:blr
 entry:
   %0 = tail call i32 @llvm.ppc.stdcx(ptr %a, i64 %b)
diff --git 
a/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll 
b/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
index 8d90c5cb882064..778fd0a37a1ede 100644
--- a/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
+++ b/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-LoadReserve-StoreCond.ll
@@ -36,7 +36,7 @@ define dso_local signext i32 @test_stwcx(ptr %a, i32 signext 
%b) {
 ; CHECK-64-NEXT:stwcx. 4, 0, 3
 ; CHECK-64-NEXT:mfocrf 3, 128
 ; CHECK-64-NEXT:srwi 3, 3, 28
-; CHECK-64-NEXT:extsw 3, 3
+; CHECK-64-NEXT:rlwinm 3, 3, 31, 31, 31
 ; CHECK-64-NEXT:blr
 ;
 ; CHECK-32-LABEL: test_stwcx:
@@ -44,6 +44,7 @@ define dso_local signext i32 @test_stwcx(ptr %a, i32 signext 
%b) {
 ; CHECK-32-NEXT:stwcx. 4, 0, 3
 ; CHECK-32-NEXT:mfocrf 3, 128
 ; CHECK-32-NEXT:srwi 3, 3, 28
+; CHECK-32-NEXT:rlwinm 3, 3, 31, 31, 31
 ; CHECK-32-NEXT:blr
 entry:
   %0 = tail call i32 @llvm.ppc.stwcx(ptr %a, i32 %b)
@@ -57,7 +58,7 @@ define dso_local signext i32 @test_sthcx(ptr %a, i16 signext 
%val) {
 ; CHECK-64-NEXT:sthcx. 4, 0, 3
 ; CHECK-64-NEXT:mfocrf 3, 128
 ; CHECK-64-NEXT:srwi 3, 3, 28
-; CHECK-64-NEXT:extsw 3, 3
+; CHECK-64-NEXT:rlwinm 3, 3, 31, 31

[llvm-branch-commits] [llvm] release/19.x: [PowerPC] Fix mask for __st[d/w/h/b]cx builtins (#104453) (PR #106085)

2024-08-26 Thread Amy Kwan via llvm-branch-commits

https://github.com/amy-kwan approved this pull request.

LGTM.

https://github.com/llvm/llvm-project/pull/106085
___
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] [libc] [libc][math][c23] Add log10f16 C23 math function (PR #106091)

2024-08-26 Thread via llvm-branch-commits

https://github.com/overmighty created 
https://github.com/llvm/llvm-project/pull/106091

Part of #95250.

>From 57972717618c3d4ccc836c81fdbf3a66c6da53fa Mon Sep 17 00:00:00 2001
From: OverMighty 
Date: Mon, 26 Aug 2024 17:23:01 +0200
Subject: [PATCH] [libc][math][c23] Add log10f16 C23 math function

Part of #95250.
---
 libc/config/gpu/entrypoints.txt|   1 +
 libc/config/linux/x86_64/entrypoints.txt   |   1 +
 libc/docs/math/index.rst   |   2 +-
 libc/spec/stdc.td  |   1 +
 libc/src/math/CMakeLists.txt   |   1 +
 libc/src/math/generic/CMakeLists.txt   |  21 +++
 libc/src/math/generic/expxf16.h|  14 ++
 libc/src/math/generic/log10f16.cpp | 163 +
 libc/src/math/log10f16.h   |  21 +++
 libc/test/src/math/CMakeLists.txt  |  11 ++
 libc/test/src/math/log10f16_test.cpp   |  40 +
 libc/test/src/math/smoke/CMakeLists.txt|  12 ++
 libc/test/src/math/smoke/log10f16_test.cpp |  47 ++
 13 files changed, 334 insertions(+), 1 deletion(-)
 create mode 100644 libc/src/math/generic/log10f16.cpp
 create mode 100644 libc/src/math/log10f16.h
 create mode 100644 libc/test/src/math/log10f16_test.cpp
 create mode 100644 libc/test/src/math/smoke/log10f16_test.cpp

diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index 279e397287d8e3..7faad9fbb8a9d1 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -531,6 +531,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llogbf16
 libc.src.math.llrintf16
 libc.src.math.llroundf16
+libc.src.math.log10f16
 libc.src.math.log2f16
 libc.src.math.logbf16
 libc.src.math.logf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index 3fd279071ccb1d..785cbc4ce62a9e 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -642,6 +642,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llogbf16
 libc.src.math.llrintf16
 libc.src.math.llroundf16
+libc.src.math.log10f16
 libc.src.math.log2f16
 libc.src.math.logbf16
 libc.src.math.logf16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index 6b30cac1366d6b..c4723893455333 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -308,7 +308,7 @@ Higher Math Functions
 
+---+--+-++--++++
 | log   | |check|  | |check| || 
|check|  || 7.12.6.11  | 
F.10.3.11  |
 
+---+--+-++--++++
-| log10 | |check|  | |check| ||
  || 7.12.6.12  | F.10.3.12 
 |
+| log10 | |check|  | |check| || 
|check|  || 7.12.6.12  | 
F.10.3.12  |
 
+---+--+-++--++++
 | log10p1   |  | ||
  || 7.12.6.13  | F.10.3.13 
 |
 
+---+--+-++--++++
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index de4b8f85e94d11..fe6ee9ad683a47 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -556,6 +556,7 @@ def StdC : StandardSpec<"stdc"> {
 
   FunctionSpec<"log10", RetValSpec, [ArgSpec]>,
   FunctionSpec<"log10f", RetValSpec, [ArgSpec]>,
+  GuardedFunctionSpec<"log10f16", RetValSpec, 
[ArgSpec], "LIBC_TYPES_HAS_FLOAT16">,
 
   FunctionSpec<"log1p", RetValSpec, [ArgSpec]>,
   FunctionSpec<"log1pf", RetValSpec, [ArgSpec]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 23c35828b576f4..994daf8db742ab 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -322,6 +322,7 @@ add_math_entrypoint_object(ldexpf128)
 
 add_math_entrypoint_object(log10)
 add_math_entrypoint_object(log10f)
+add_math_entrypoint_object(log10f16)
 
 add_math_entrypoint_object(log1p)
 add_math_entrypoint_object(log1pf)
diff --git a/libc/src/math/generic/CMakeLists.txt 
b/libc/src/math/generic/CMakeLists.txt
index 0af3d2ad24e0a3..18d520deb2832a 100644
--- a/libc/src/math/generic

[llvm-branch-commits] [libc] [libc][math][c23] Add log10f16 C23 math function (PR #106091)

2024-08-26 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libc

Author: OverMighty (overmighty)


Changes

Part of #95250.

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


13 Files Affected:

- (modified) libc/config/gpu/entrypoints.txt (+1) 
- (modified) libc/config/linux/x86_64/entrypoints.txt (+1) 
- (modified) libc/docs/math/index.rst (+1-1) 
- (modified) libc/spec/stdc.td (+1) 
- (modified) libc/src/math/CMakeLists.txt (+1) 
- (modified) libc/src/math/generic/CMakeLists.txt (+21) 
- (modified) libc/src/math/generic/expxf16.h (+14) 
- (added) libc/src/math/generic/log10f16.cpp (+163) 
- (added) libc/src/math/log10f16.h (+21) 
- (modified) libc/test/src/math/CMakeLists.txt (+11) 
- (added) libc/test/src/math/log10f16_test.cpp (+40) 
- (modified) libc/test/src/math/smoke/CMakeLists.txt (+12) 
- (added) libc/test/src/math/smoke/log10f16_test.cpp (+47) 


``diff
diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index 279e397287d8e3..7faad9fbb8a9d1 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -531,6 +531,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llogbf16
 libc.src.math.llrintf16
 libc.src.math.llroundf16
+libc.src.math.log10f16
 libc.src.math.log2f16
 libc.src.math.logbf16
 libc.src.math.logf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index 3fd279071ccb1d..785cbc4ce62a9e 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -642,6 +642,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llogbf16
 libc.src.math.llrintf16
 libc.src.math.llroundf16
+libc.src.math.log10f16
 libc.src.math.log2f16
 libc.src.math.logbf16
 libc.src.math.logf16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index 6b30cac1366d6b..c4723893455333 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -308,7 +308,7 @@ Higher Math Functions
 
+---+--+-++--++++
 | log   | |check|  | |check| || 
|check|  || 7.12.6.11  | 
F.10.3.11  |
 
+---+--+-++--++++
-| log10 | |check|  | |check| ||
  || 7.12.6.12  | F.10.3.12 
 |
+| log10 | |check|  | |check| || 
|check|  || 7.12.6.12  | 
F.10.3.12  |
 
+---+--+-++--++++
 | log10p1   |  | ||
  || 7.12.6.13  | F.10.3.13 
 |
 
+---+--+-++--++++
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index de4b8f85e94d11..fe6ee9ad683a47 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -556,6 +556,7 @@ def StdC : StandardSpec<"stdc"> {
 
   FunctionSpec<"log10", RetValSpec, [ArgSpec]>,
   FunctionSpec<"log10f", RetValSpec, [ArgSpec]>,
+  GuardedFunctionSpec<"log10f16", RetValSpec, 
[ArgSpec], "LIBC_TYPES_HAS_FLOAT16">,
 
   FunctionSpec<"log1p", RetValSpec, [ArgSpec]>,
   FunctionSpec<"log1pf", RetValSpec, [ArgSpec]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 23c35828b576f4..994daf8db742ab 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -322,6 +322,7 @@ add_math_entrypoint_object(ldexpf128)
 
 add_math_entrypoint_object(log10)
 add_math_entrypoint_object(log10f)
+add_math_entrypoint_object(log10f16)
 
 add_math_entrypoint_object(log1p)
 add_math_entrypoint_object(log1pf)
diff --git a/libc/src/math/generic/CMakeLists.txt 
b/libc/src/math/generic/CMakeLists.txt
index 0af3d2ad24e0a3..18d520deb2832a 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -2094,6 +2094,27 @@ add_entrypoint_object(
 -O3
 )
 
+add_entrypoint_object(
+  log10f16
+  SRCS
+log10f16.cpp
+  HDRS
+../log10f16.h
+  DEPENDS
+.expxf16
+libc.hdr.errno_macros
+libc.hdr.fenv_macros
+libc.src.__support.FPUtil.except_value_utils
+libc.src.__support.FPUtil.fenv_impl
+libc.src.__support.FPUtil.fp_bits
+  

[llvm-branch-commits] [libc] [libc][math][c23] Add log2f16 C23 math function (PR #106084)

2024-08-26 Thread via llvm-branch-commits

https://github.com/overmighty updated 
https://github.com/llvm/llvm-project/pull/106084

>From 2f0d352e311301b0853346587cf03d5137b22d76 Mon Sep 17 00:00:00 2001
From: OverMighty 
Date: Mon, 26 Aug 2024 16:36:19 +0200
Subject: [PATCH 1/2] [libc][math][c23] Add log2f16 C23 math function

Part of #95250.
---
 libc/config/gpu/entrypoints.txt   |   1 +
 libc/config/linux/x86_64/entrypoints.txt  |   1 +
 libc/docs/math/index.rst  |   2 +-
 libc/spec/stdc.td |   1 +
 libc/src/math/CMakeLists.txt  |   1 +
 libc/src/math/generic/CMakeLists.txt  |  21 
 libc/src/math/generic/expxf16.h   |  14 +++
 libc/src/math/generic/log2f16.cpp | 147 ++
 libc/src/math/log2f16.h   |  21 
 libc/test/src/math/CMakeLists.txt |  11 ++
 libc/test/src/math/log2f16_test.cpp   |  40 ++
 libc/test/src/math/smoke/CMakeLists.txt   |  12 ++
 libc/test/src/math/smoke/log2f16_test.cpp |  47 +++
 13 files changed, 318 insertions(+), 1 deletion(-)
 create mode 100644 libc/src/math/generic/log2f16.cpp
 create mode 100644 libc/src/math/log2f16.h
 create mode 100644 libc/test/src/math/log2f16_test.cpp
 create mode 100644 libc/test/src/math/smoke/log2f16_test.cpp

diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index e6a8e381a9212a..279e397287d8e3 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -531,6 +531,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llogbf16
 libc.src.math.llrintf16
 libc.src.math.llroundf16
+libc.src.math.log2f16
 libc.src.math.logbf16
 libc.src.math.logf16
 libc.src.math.lrintf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index 69944ce3904562..3fd279071ccb1d 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -642,6 +642,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llogbf16
 libc.src.math.llrintf16
 libc.src.math.llroundf16
+libc.src.math.log2f16
 libc.src.math.logbf16
 libc.src.math.logf16
 libc.src.math.lrintf16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index e958312b313589..6b30cac1366d6b 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -314,7 +314,7 @@ Higher Math Functions
 
+---+--+-++--++++
 | log1p | |check|  | |check| ||
  || 7.12.6.14  | F.10.3.14 
 |
 
+---+--+-++--++++
-| log2  | |check|  | |check| ||
  || 7.12.6.15  | F.10.3.15 
 |
+| log2  | |check|  | |check| || 
|check|  || 7.12.6.15  | 
F.10.3.15  |
 
+---+--+-++--++++
 | log2p1|  | ||
  || 7.12.6.16  | F.10.3.16 
 |
 
+---+--+-++--++++
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index c3115b19349ff4..de4b8f85e94d11 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -562,6 +562,7 @@ def StdC : StandardSpec<"stdc"> {
 
   FunctionSpec<"log2", RetValSpec, [ArgSpec]>,
   FunctionSpec<"log2f", RetValSpec, [ArgSpec]>,
+  GuardedFunctionSpec<"log2f16", RetValSpec, 
[ArgSpec], "LIBC_TYPES_HAS_FLOAT16">,
 
   FunctionSpec<"log", RetValSpec, [ArgSpec]>,
   FunctionSpec<"logf", RetValSpec, [ArgSpec]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 47c4ad188ef6df..23c35828b576f4 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -328,6 +328,7 @@ add_math_entrypoint_object(log1pf)
 
 add_math_entrypoint_object(log2)
 add_math_entrypoint_object(log2f)
+add_math_entrypoint_object(log2f16)
 
 add_math_entrypoint_object(log)
 add_math_entrypoint_object(logf)
diff --git a/libc/src/math/generic/CMakeLists.txt 
b/libc/src/math/generic/CMakeLists.txt
index 6a9d9f02f190f0..0af3d2ad24e0a3 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generi

[llvm-branch-commits] [libc] [libc][math][c23] Add logf16 C23 math function (PR #106072)

2024-08-26 Thread via llvm-branch-commits

https://github.com/overmighty updated 
https://github.com/llvm/llvm-project/pull/106072

>From efc9ccab9373b3dcc31b520873eaf2fff40b8b58 Mon Sep 17 00:00:00 2001
From: OverMighty 
Date: Mon, 26 Aug 2024 15:30:54 +0200
Subject: [PATCH 1/3] [libc][math][c23] Add logf16 C23 math function

Part of #95250.
---
 libc/config/gpu/entrypoints.txt  |   1 +
 libc/config/linux/x86_64/entrypoints.txt |   1 +
 libc/docs/math/index.rst |   2 +-
 libc/spec/stdc.td|   1 +
 libc/src/math/CMakeLists.txt |   1 +
 libc/src/math/generic/CMakeLists.txt |  22 
 libc/src/math/generic/expxf16.h  |  26 
 libc/src/math/generic/logf16.cpp | 158 +++
 libc/src/math/logf16.h   |  21 +++
 libc/test/UnitTest/FPMatcher.h   |  13 ++
 libc/test/src/math/CMakeLists.txt|  11 ++
 libc/test/src/math/logf16_test.cpp   |  40 ++
 libc/test/src/math/smoke/CMakeLists.txt  |  12 ++
 libc/test/src/math/smoke/logf16_test.cpp |  47 +++
 14 files changed, 355 insertions(+), 1 deletion(-)
 create mode 100644 libc/src/math/generic/logf16.cpp
 create mode 100644 libc/src/math/logf16.h
 create mode 100644 libc/test/src/math/logf16_test.cpp
 create mode 100644 libc/test/src/math/smoke/logf16_test.cpp

diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index b206bb7c936f39..e6a8e381a9212a 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -532,6 +532,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llrintf16
 libc.src.math.llroundf16
 libc.src.math.logbf16
+libc.src.math.logf16
 libc.src.math.lrintf16
 libc.src.math.lroundf16
 libc.src.math.modff16
diff --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index b702a7ff482a5c..69944ce3904562 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -643,6 +643,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llrintf16
 libc.src.math.llroundf16
 libc.src.math.logbf16
+libc.src.math.logf16
 libc.src.math.lrintf16
 libc.src.math.lroundf16
 libc.src.math.modff16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index de88f14426799f..e958312b313589 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -306,7 +306,7 @@ Higher Math Functions
 
+---+--+-++--++++
 | lgamma|  | ||
  || 7.12.8.3   | F.10.5.3  
 |
 
+---+--+-++--++++
-| log   | |check|  | |check| ||
  || 7.12.6.11  | F.10.3.11 
 |
+| log   | |check|  | |check| || 
|check|  || 7.12.6.11  | 
F.10.3.11  |
 
+---+--+-++--++++
 | log10 | |check|  | |check| ||
  || 7.12.6.12  | F.10.3.12 
 |
 
+---+--+-++--++++
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 043762bb227456..c3115b19349ff4 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -565,6 +565,7 @@ def StdC : StandardSpec<"stdc"> {
 
   FunctionSpec<"log", RetValSpec, [ArgSpec]>,
   FunctionSpec<"logf", RetValSpec, [ArgSpec]>,
+  GuardedFunctionSpec<"logf16", RetValSpec, 
[ArgSpec], "LIBC_TYPES_HAS_FLOAT16">,
 
   FunctionSpec<"logb", RetValSpec, [ArgSpec]>,
   FunctionSpec<"logbf", RetValSpec, [ArgSpec]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index be05903d4a1c6e..47c4ad188ef6df 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -331,6 +331,7 @@ add_math_entrypoint_object(log2f)
 
 add_math_entrypoint_object(log)
 add_math_entrypoint_object(logf)
+add_math_entrypoint_object(logf16)
 
 add_math_entrypoint_object(logb)
 add_math_entrypoint_object(logbf)
diff --git a/libc/src/math/generic/CMakeLists.txt 
b/libc/src/math/generic/CMakeLists.txt
index 9534d17426486b..6a9d9f02f190f0 100644
--- a/libc/src/math/generic/CMakeLis

[llvm-branch-commits] [llvm] [MC][NFC] Statically allocate storage for decoded pseudo probes and function records (PR #102789)

2024-08-26 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/102789

>From ddcbb593f72ca47acaa82f9c14a7fd2c4e30903b Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Tue, 13 Aug 2024 03:51:31 -0700
Subject: [PATCH 1/3] Pass CurChildIndex by value

Created using spr 1.3.4
---
 llvm/include/llvm/MC/MCPseudoProbe.h |  6 --
 llvm/lib/MC/MCPseudoProbe.cpp| 26 +++---
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/llvm/include/llvm/MC/MCPseudoProbe.h 
b/llvm/include/llvm/MC/MCPseudoProbe.h
index a46188e565c7e8..32d7a4e9129eca 100644
--- a/llvm/include/llvm/MC/MCPseudoProbe.h
+++ b/llvm/include/llvm/MC/MCPseudoProbe.h
@@ -474,11 +474,13 @@ class MCPseudoProbeDecoder {
   }
 
 private:
+  // Recursively parse an inlining tree encoded in pseudo_probe section. 
Returns
+  // whether the the top-level node should be skipped.
   template 
-  void buildAddress2ProbeMap(MCDecodedPseudoProbeInlineTree *Cur,
+  bool buildAddress2ProbeMap(MCDecodedPseudoProbeInlineTree *Cur,
  uint64_t &LastAddr, const Uint64Set &GuildFilter,
  const Uint64Map &FuncStartAddrs,
- uint32_t &CurChild);
+ const uint32_t CurChildIndex);
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/MC/MCPseudoProbe.cpp b/llvm/lib/MC/MCPseudoProbe.cpp
index c4c2dfcec40564..e6f6e797b4ee71 100644
--- a/llvm/lib/MC/MCPseudoProbe.cpp
+++ b/llvm/lib/MC/MCPseudoProbe.cpp
@@ -420,17 +420,17 @@ bool MCPseudoProbeDecoder::buildGUID2FuncDescMap(const 
uint8_t *Start,
 }
 
 template 
-void MCPseudoProbeDecoder::buildAddress2ProbeMap(
+bool MCPseudoProbeDecoder::buildAddress2ProbeMap(
 MCDecodedPseudoProbeInlineTree *Cur, uint64_t &LastAddr,
 const Uint64Set &GuidFilter, const Uint64Map &FuncStartAddrs,
-uint32_t &CurChild) {
+const uint32_t CurChildIndex) {
   // The pseudo_probe section encodes an inline forest and each tree has a
   // format defined in MCPseudoProbe.h
 
   uint32_t Index = 0;
   if (IsTopLevelFunc) {
 // Use a sequential id for top level inliner.
-Index = CurChild;
+Index = CurChildIndex;
   } else {
 // Read inline site for inlinees
 Index = cantFail(errorOrToExpected(readUnsignedNumber()));
@@ -446,19 +446,14 @@ void MCPseudoProbeDecoder::buildAddress2ProbeMap(
   // If the incoming node is null, all its children nodes should be disgarded.
   if (Cur) {
 // Switch/add to a new tree node(inlinee)
-Cur->Children[CurChild] = MCDecodedPseudoProbeInlineTree(Guid, Index, Cur);
-Cur = &Cur->Children[CurChild];
+Cur->Children[CurChildIndex] =
+MCDecodedPseudoProbeInlineTree(Guid, Index, Cur);
+Cur = &Cur->Children[CurChildIndex];
 if (IsTopLevelFunc && !EncodingIsAddrBased) {
   if (auto V = FuncStartAddrs.lookup(Guid))
 LastAddr = V;
 }
   }
-  // Advance CurChild for non-skipped top-level functions and unconditionally
-  // for inlined functions.
-  if (IsTopLevelFunc)
-CurChild += !!Cur;
-  else
-++CurChild;
 
   // Read number of probes in the current node.
   uint32_t NodeCount =
@@ -519,9 +514,10 @@ void MCPseudoProbeDecoder::buildAddress2ProbeMap(
 InlineTreeVec.resize(InlineTreeVec.size() + ChildrenToProcess);
 Cur->Children = 
MutableArrayRef(InlineTreeVec).take_back(ChildrenToProcess);
   }
-  for (uint32_t I = 0; I < ChildrenToProcess;) {
+  for (uint32_t I = 0; I < ChildrenToProcess; I++) {
 buildAddress2ProbeMap(Cur, LastAddr, GuidFilter, FuncStartAddrs, I);
   }
+  return Cur;
 }
 
 template 
@@ -630,10 +626,10 @@ bool MCPseudoProbeDecoder::buildAddress2ProbeMap(
   Data = Start;
   End = Data + Size;
   uint64_t LastAddr = 0;
-  uint32_t Child = 0;
+  uint32_t CurChildIndex = 0;
   while (Data < End)
-buildAddress2ProbeMap(&DummyInlineRoot, LastAddr, GuidFilter,
-FuncStartAddrs, Child);
+CurChildIndex += buildAddress2ProbeMap(
+&DummyInlineRoot, LastAddr, GuidFilter, FuncStartAddrs, CurChildIndex);
   assert(Data == End && "Have unprocessed data in pseudo_probe section");
   return true;
 }

>From 73d808abad1e66b6d7f5a9a52f9617b5267ee4c0 Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Wed, 14 Aug 2024 07:50:31 -0700
Subject: [PATCH 2/3] s/ChildrenType/InlinedProbeTreeMap

Created using spr 1.3.4
---
 llvm/include/llvm/MC/MCPseudoProbe.h | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/llvm/include/llvm/MC/MCPseudoProbe.h 
b/llvm/include/llvm/MC/MCPseudoProbe.h
index 0f21d89971f7ab..c21aff7b277aa6 100644
--- a/llvm/include/llvm/MC/MCPseudoProbe.h
+++ b/llvm/include/llvm/MC/MCPseudoProbe.h
@@ -214,11 +214,11 @@ class MCDecodedPseudoProbe : public MCPseudoProbeBase {
 };
 
 template 
+  typename InlinedProbeTreeMap>
 class MCPseudoProbeInlineTreeBase {
 protected:
   // Track children (e.g. inlinees) of current context
-  ChildrenType Children;
+  InlinedProbeTreeMap Children

[llvm-branch-commits] [llvm] [MC][NFC] Statically allocate storage for decoded pseudo probes and function records (PR #102789)

2024-08-26 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/102789

>From ddcbb593f72ca47acaa82f9c14a7fd2c4e30903b Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Tue, 13 Aug 2024 03:51:31 -0700
Subject: [PATCH 1/3] Pass CurChildIndex by value

Created using spr 1.3.4
---
 llvm/include/llvm/MC/MCPseudoProbe.h |  6 --
 llvm/lib/MC/MCPseudoProbe.cpp| 26 +++---
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/llvm/include/llvm/MC/MCPseudoProbe.h 
b/llvm/include/llvm/MC/MCPseudoProbe.h
index a46188e565c7e8..32d7a4e9129eca 100644
--- a/llvm/include/llvm/MC/MCPseudoProbe.h
+++ b/llvm/include/llvm/MC/MCPseudoProbe.h
@@ -474,11 +474,13 @@ class MCPseudoProbeDecoder {
   }
 
 private:
+  // Recursively parse an inlining tree encoded in pseudo_probe section. 
Returns
+  // whether the the top-level node should be skipped.
   template 
-  void buildAddress2ProbeMap(MCDecodedPseudoProbeInlineTree *Cur,
+  bool buildAddress2ProbeMap(MCDecodedPseudoProbeInlineTree *Cur,
  uint64_t &LastAddr, const Uint64Set &GuildFilter,
  const Uint64Map &FuncStartAddrs,
- uint32_t &CurChild);
+ const uint32_t CurChildIndex);
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/MC/MCPseudoProbe.cpp b/llvm/lib/MC/MCPseudoProbe.cpp
index c4c2dfcec40564..e6f6e797b4ee71 100644
--- a/llvm/lib/MC/MCPseudoProbe.cpp
+++ b/llvm/lib/MC/MCPseudoProbe.cpp
@@ -420,17 +420,17 @@ bool MCPseudoProbeDecoder::buildGUID2FuncDescMap(const 
uint8_t *Start,
 }
 
 template 
-void MCPseudoProbeDecoder::buildAddress2ProbeMap(
+bool MCPseudoProbeDecoder::buildAddress2ProbeMap(
 MCDecodedPseudoProbeInlineTree *Cur, uint64_t &LastAddr,
 const Uint64Set &GuidFilter, const Uint64Map &FuncStartAddrs,
-uint32_t &CurChild) {
+const uint32_t CurChildIndex) {
   // The pseudo_probe section encodes an inline forest and each tree has a
   // format defined in MCPseudoProbe.h
 
   uint32_t Index = 0;
   if (IsTopLevelFunc) {
 // Use a sequential id for top level inliner.
-Index = CurChild;
+Index = CurChildIndex;
   } else {
 // Read inline site for inlinees
 Index = cantFail(errorOrToExpected(readUnsignedNumber()));
@@ -446,19 +446,14 @@ void MCPseudoProbeDecoder::buildAddress2ProbeMap(
   // If the incoming node is null, all its children nodes should be disgarded.
   if (Cur) {
 // Switch/add to a new tree node(inlinee)
-Cur->Children[CurChild] = MCDecodedPseudoProbeInlineTree(Guid, Index, Cur);
-Cur = &Cur->Children[CurChild];
+Cur->Children[CurChildIndex] =
+MCDecodedPseudoProbeInlineTree(Guid, Index, Cur);
+Cur = &Cur->Children[CurChildIndex];
 if (IsTopLevelFunc && !EncodingIsAddrBased) {
   if (auto V = FuncStartAddrs.lookup(Guid))
 LastAddr = V;
 }
   }
-  // Advance CurChild for non-skipped top-level functions and unconditionally
-  // for inlined functions.
-  if (IsTopLevelFunc)
-CurChild += !!Cur;
-  else
-++CurChild;
 
   // Read number of probes in the current node.
   uint32_t NodeCount =
@@ -519,9 +514,10 @@ void MCPseudoProbeDecoder::buildAddress2ProbeMap(
 InlineTreeVec.resize(InlineTreeVec.size() + ChildrenToProcess);
 Cur->Children = 
MutableArrayRef(InlineTreeVec).take_back(ChildrenToProcess);
   }
-  for (uint32_t I = 0; I < ChildrenToProcess;) {
+  for (uint32_t I = 0; I < ChildrenToProcess; I++) {
 buildAddress2ProbeMap(Cur, LastAddr, GuidFilter, FuncStartAddrs, I);
   }
+  return Cur;
 }
 
 template 
@@ -630,10 +626,10 @@ bool MCPseudoProbeDecoder::buildAddress2ProbeMap(
   Data = Start;
   End = Data + Size;
   uint64_t LastAddr = 0;
-  uint32_t Child = 0;
+  uint32_t CurChildIndex = 0;
   while (Data < End)
-buildAddress2ProbeMap(&DummyInlineRoot, LastAddr, GuidFilter,
-FuncStartAddrs, Child);
+CurChildIndex += buildAddress2ProbeMap(
+&DummyInlineRoot, LastAddr, GuidFilter, FuncStartAddrs, CurChildIndex);
   assert(Data == End && "Have unprocessed data in pseudo_probe section");
   return true;
 }

>From 73d808abad1e66b6d7f5a9a52f9617b5267ee4c0 Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Wed, 14 Aug 2024 07:50:31 -0700
Subject: [PATCH 2/3] s/ChildrenType/InlinedProbeTreeMap

Created using spr 1.3.4
---
 llvm/include/llvm/MC/MCPseudoProbe.h | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/llvm/include/llvm/MC/MCPseudoProbe.h 
b/llvm/include/llvm/MC/MCPseudoProbe.h
index 0f21d89971f7ab..c21aff7b277aa6 100644
--- a/llvm/include/llvm/MC/MCPseudoProbe.h
+++ b/llvm/include/llvm/MC/MCPseudoProbe.h
@@ -214,11 +214,11 @@ class MCDecodedPseudoProbe : public MCPseudoProbeBase {
 };
 
 template 
+  typename InlinedProbeTreeMap>
 class MCPseudoProbeInlineTreeBase {
 protected:
   // Track children (e.g. inlinees) of current context
-  ChildrenType Children;
+  InlinedProbeTreeMap Children

[llvm-branch-commits] [llvm] [MC][NFC] Reduce Address2ProbesMap size (PR #102904)

2024-08-26 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/102904

>From 3ffb03f8e4bcb2fa235ae989320c466af4a3cda8 Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Mon, 12 Aug 2024 14:40:57 -0700
Subject: [PATCH 1/2] stable_sort

Created using spr 1.3.4
---
 llvm/lib/MC/MCPseudoProbe.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/MC/MCPseudoProbe.cpp b/llvm/lib/MC/MCPseudoProbe.cpp
index 45fe95e176ff24..1c81630dda4dd9 100644
--- a/llvm/lib/MC/MCPseudoProbe.cpp
+++ b/llvm/lib/MC/MCPseudoProbe.cpp
@@ -638,7 +638,7 @@ bool MCPseudoProbeDecoder::buildAddress2ProbeMap(
   std::vector> SortedA2P(ProbeCount);
   for (const auto &[I, Probe] : llvm::enumerate(PseudoProbeVec))
 SortedA2P[I] = {Probe.getAddress(), I};
-  llvm::sort(SortedA2P, llvm::less_first());
+  llvm::stable_sort(SortedA2P, llvm::less_first());
   Address2ProbesMap.reserve(ProbeCount);
   for (const uint32_t I : llvm::make_second_range(SortedA2P))
 Address2ProbesMap.emplace_back(PseudoProbeVec[I]);

>From 445b646bbf9718f98689cae92d9bc71366d80e31 Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Fri, 16 Aug 2024 10:34:40 -0700
Subject: [PATCH 2/2] Check find addr

Created using spr 1.3.4
---
 llvm/include/llvm/MC/MCPseudoProbe.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/include/llvm/MC/MCPseudoProbe.h 
b/llvm/include/llvm/MC/MCPseudoProbe.h
index edac9b94e28f44..559e8ff9055df9 100644
--- a/llvm/include/llvm/MC/MCPseudoProbe.h
+++ b/llvm/include/llvm/MC/MCPseudoProbe.h
@@ -228,6 +228,8 @@ class AddressProbesMap
 auto FromIt = getIt(Address);
 if (FromIt == end())
   return llvm::make_range(end(), end());
+if (FromIt->get().getAddress() != Address)
+  return llvm::make_range(end(), end());
 auto ToIt = getIt(Address + 1);
 return llvm::make_range(FromIt, ToIt);
   }

___
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] [MC][NFC] Reduce Address2ProbesMap size (PR #102904)

2024-08-26 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/102904

>From 3ffb03f8e4bcb2fa235ae989320c466af4a3cda8 Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Mon, 12 Aug 2024 14:40:57 -0700
Subject: [PATCH 1/2] stable_sort

Created using spr 1.3.4
---
 llvm/lib/MC/MCPseudoProbe.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/MC/MCPseudoProbe.cpp b/llvm/lib/MC/MCPseudoProbe.cpp
index 45fe95e176ff24..1c81630dda4dd9 100644
--- a/llvm/lib/MC/MCPseudoProbe.cpp
+++ b/llvm/lib/MC/MCPseudoProbe.cpp
@@ -638,7 +638,7 @@ bool MCPseudoProbeDecoder::buildAddress2ProbeMap(
   std::vector> SortedA2P(ProbeCount);
   for (const auto &[I, Probe] : llvm::enumerate(PseudoProbeVec))
 SortedA2P[I] = {Probe.getAddress(), I};
-  llvm::sort(SortedA2P, llvm::less_first());
+  llvm::stable_sort(SortedA2P, llvm::less_first());
   Address2ProbesMap.reserve(ProbeCount);
   for (const uint32_t I : llvm::make_second_range(SortedA2P))
 Address2ProbesMap.emplace_back(PseudoProbeVec[I]);

>From 445b646bbf9718f98689cae92d9bc71366d80e31 Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Fri, 16 Aug 2024 10:34:40 -0700
Subject: [PATCH 2/2] Check find addr

Created using spr 1.3.4
---
 llvm/include/llvm/MC/MCPseudoProbe.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/include/llvm/MC/MCPseudoProbe.h 
b/llvm/include/llvm/MC/MCPseudoProbe.h
index edac9b94e28f44..559e8ff9055df9 100644
--- a/llvm/include/llvm/MC/MCPseudoProbe.h
+++ b/llvm/include/llvm/MC/MCPseudoProbe.h
@@ -228,6 +228,8 @@ class AddressProbesMap
 auto FromIt = getIt(Address);
 if (FromIt == end())
   return llvm::make_range(end(), end());
+if (FromIt->get().getAddress() != Address)
+  return llvm::make_range(end(), end());
 auto ToIt = getIt(Address + 1);
 return llvm::make_range(FromIt, ToIt);
   }

___
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] [MC][NFC] Use vector for GUIDProbeFunctionMap (PR #102905)

2024-08-26 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/102905

>From 284c701cc57a613d11130a349aba522397946f12 Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Fri, 16 Aug 2024 03:30:54 -0700
Subject: [PATCH] Assert func desc size

Created using spr 1.3.4
---
 llvm/lib/MC/MCPseudoProbe.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/MC/MCPseudoProbe.cpp b/llvm/lib/MC/MCPseudoProbe.cpp
index 10def15275fac3..90d7588407068a 100644
--- a/llvm/lib/MC/MCPseudoProbe.cpp
+++ b/llvm/lib/MC/MCPseudoProbe.cpp
@@ -425,6 +425,8 @@ bool MCPseudoProbeDecoder::buildGUID2FuncDescMap(const 
uint8_t *Start,
 GUID2FuncDescMap.emplace_back(GUID, Hash, Name.copy(FuncNameAllocator));
   }
   assert(Data == End && "Have unprocessed data in pseudo_probe_desc section");
+  assert(GUID2FuncDescMap.size() == FuncDescCount &&
+ "Mismatching function description count pre- and post-parsing");
   llvm::sort(GUID2FuncDescMap, [](const auto &LHS, const auto &RHS) {
 return LHS.FuncGUID < RHS.FuncGUID;
   });

___
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] [MC][NFC] Use vector for GUIDProbeFunctionMap (PR #102905)

2024-08-26 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/102905

>From 284c701cc57a613d11130a349aba522397946f12 Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Fri, 16 Aug 2024 03:30:54 -0700
Subject: [PATCH] Assert func desc size

Created using spr 1.3.4
---
 llvm/lib/MC/MCPseudoProbe.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/MC/MCPseudoProbe.cpp b/llvm/lib/MC/MCPseudoProbe.cpp
index 10def15275fac3..90d7588407068a 100644
--- a/llvm/lib/MC/MCPseudoProbe.cpp
+++ b/llvm/lib/MC/MCPseudoProbe.cpp
@@ -425,6 +425,8 @@ bool MCPseudoProbeDecoder::buildGUID2FuncDescMap(const 
uint8_t *Start,
 GUID2FuncDescMap.emplace_back(GUID, Hash, Name.copy(FuncNameAllocator));
   }
   assert(Data == End && "Have unprocessed data in pseudo_probe_desc section");
+  assert(GUID2FuncDescMap.size() == FuncDescCount &&
+ "Mismatching function description count pre- and post-parsing");
   llvm::sort(GUID2FuncDescMap, [](const auto &LHS, const auto &RHS) {
 return LHS.FuncGUID < RHS.FuncGUID;
   });

___
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] [libc] [libc][math][c23] Add sqrtf16 C23 math function (PR #106102)

2024-08-26 Thread via llvm-branch-commits

https://github.com/overmighty created 
https://github.com/llvm/llvm-project/pull/106102

Part of #95250.

>From 681fcf579c010e1f45e396114930355a6a28d403 Mon Sep 17 00:00:00 2001
From: OverMighty 
Date: Mon, 26 Aug 2024 18:43:12 +0200
Subject: [PATCH] [libc][math][c23] Add sqrtf16 C23 math function

Part of #95250.
---
 libc/config/gpu/entrypoints.txt   |  1 +
 libc/config/linux/aarch64/entrypoints.txt |  1 +
 libc/config/linux/x86_64/entrypoints.txt  |  1 +
 libc/docs/math/index.rst  |  2 +-
 libc/spec/stdc.td |  1 +
 libc/src/__support/FPUtil/generic/sqrt.h  |  3 ++-
 libc/src/math/CMakeLists.txt  |  1 +
 libc/src/math/generic/CMakeLists.txt  | 12 ++
 libc/src/math/generic/sqrtf16.cpp | 20 
 libc/src/math/sqrtf16.h   | 21 +
 libc/test/src/math/CMakeLists.txt | 11 +
 libc/test/src/math/smoke/CMakeLists.txt   | 12 ++
 libc/test/src/math/smoke/sqrtf16_test.cpp | 13 +++
 libc/test/src/math/sqrtf16_test.cpp   | 28 +++
 14 files changed, 125 insertions(+), 2 deletions(-)
 create mode 100644 libc/src/math/generic/sqrtf16.cpp
 create mode 100644 libc/src/math/sqrtf16.h
 create mode 100644 libc/test/src/math/smoke/sqrtf16_test.cpp
 create mode 100644 libc/test/src/math/sqrtf16_test.cpp

diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index 7faad9fbb8a9d1..2d25f28c5adc89 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -554,6 +554,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.setpayloadf16
 libc.src.math.setpayloadsigf16
 libc.src.math.sinhf16
+libc.src.math.sqrtf16
 libc.src.math.tanhf16
 libc.src.math.totalorderf16
 libc.src.math.totalordermagf16
diff --git a/libc/config/linux/aarch64/entrypoints.txt 
b/libc/config/linux/aarch64/entrypoints.txt
index d22bd1153598eb..805436361e0b54 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -661,6 +661,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.scalbnf16
 libc.src.math.setpayloadf16
 libc.src.math.setpayloadsigf16
+libc.src.math.sqrtf16
 libc.src.math.totalorderf16
 libc.src.math.totalordermagf16
 libc.src.math.truncf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index 785cbc4ce62a9e..3b2e6a09f6e193 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -665,6 +665,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.setpayloadf16
 libc.src.math.setpayloadsigf16
 libc.src.math.sinhf16
+libc.src.math.sqrtf16
 libc.src.math.tanhf16
 libc.src.math.totalorderf16
 libc.src.math.totalordermagf16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index c4723893455333..5ca3b5db102b1d 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -340,7 +340,7 @@ Higher Math Functions
 
+---+--+-++--++++
 | sinpi | |check|  | ||
  || 7.12.4.13  | F.10.1.13 
 |
 
+---+--+-++--++++
-| sqrt  | |check|  | |check| | |check||
  | |check|| 7.12.7.10  | F.10.4.10 
 |
+| sqrt  | |check|  | |check| | |check|| 
|check|  | |check|| 7.12.7.10  | 
F.10.4.10  |
 
+---+--+-++--++++
 | tan   | |check|  | |check| ||
  || 7.12.4.7   | F.10.1.7  
 |
 
+---+--+-++--++++
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index fe6ee9ad683a47..c0d24f1655b556 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -668,6 +668,7 @@ def StdC : StandardSpec<"stdc"> {
   FunctionSpec<"sqrt", RetValSpec, [ArgSpec]>,
   FunctionSpec<"sqrtf", RetValSpec, [ArgSpec]>,
   FunctionSpec<"sqrtl", RetValSpec, 
[ArgSpec]>,
+  GuardedFunctionSpec<"sqrtf16", RetValSpec, 
[ArgSpec], "LIBC_TYPES_HAS_FLOAT16">,
   GuardedFunc

[llvm-branch-commits] [libc] [libc][math][c23] Add sqrtf16 C23 math function (PR #106102)

2024-08-26 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libc

Author: OverMighty (overmighty)


Changes

Part of #95250.

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


14 Files Affected:

- (modified) libc/config/gpu/entrypoints.txt (+1) 
- (modified) libc/config/linux/aarch64/entrypoints.txt (+1) 
- (modified) libc/config/linux/x86_64/entrypoints.txt (+1) 
- (modified) libc/docs/math/index.rst (+1-1) 
- (modified) libc/spec/stdc.td (+1) 
- (modified) libc/src/__support/FPUtil/generic/sqrt.h (+2-1) 
- (modified) libc/src/math/CMakeLists.txt (+1) 
- (modified) libc/src/math/generic/CMakeLists.txt (+12) 
- (added) libc/src/math/generic/sqrtf16.cpp (+20) 
- (added) libc/src/math/sqrtf16.h (+21) 
- (modified) libc/test/src/math/CMakeLists.txt (+11) 
- (modified) libc/test/src/math/smoke/CMakeLists.txt (+12) 
- (added) libc/test/src/math/smoke/sqrtf16_test.cpp (+13) 
- (added) libc/test/src/math/sqrtf16_test.cpp (+28) 


``diff
diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index 7faad9fbb8a9d1..2d25f28c5adc89 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -554,6 +554,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.setpayloadf16
 libc.src.math.setpayloadsigf16
 libc.src.math.sinhf16
+libc.src.math.sqrtf16
 libc.src.math.tanhf16
 libc.src.math.totalorderf16
 libc.src.math.totalordermagf16
diff --git a/libc/config/linux/aarch64/entrypoints.txt 
b/libc/config/linux/aarch64/entrypoints.txt
index d22bd1153598eb..805436361e0b54 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -661,6 +661,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.scalbnf16
 libc.src.math.setpayloadf16
 libc.src.math.setpayloadsigf16
+libc.src.math.sqrtf16
 libc.src.math.totalorderf16
 libc.src.math.totalordermagf16
 libc.src.math.truncf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index 785cbc4ce62a9e..3b2e6a09f6e193 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -665,6 +665,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.setpayloadf16
 libc.src.math.setpayloadsigf16
 libc.src.math.sinhf16
+libc.src.math.sqrtf16
 libc.src.math.tanhf16
 libc.src.math.totalorderf16
 libc.src.math.totalordermagf16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index c4723893455333..5ca3b5db102b1d 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -340,7 +340,7 @@ Higher Math Functions
 
+---+--+-++--++++
 | sinpi | |check|  | ||
  || 7.12.4.13  | F.10.1.13 
 |
 
+---+--+-++--++++
-| sqrt  | |check|  | |check| | |check||
  | |check|| 7.12.7.10  | F.10.4.10 
 |
+| sqrt  | |check|  | |check| | |check|| 
|check|  | |check|| 7.12.7.10  | 
F.10.4.10  |
 
+---+--+-++--++++
 | tan   | |check|  | |check| ||
  || 7.12.4.7   | F.10.1.7  
 |
 
+---+--+-++--++++
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index fe6ee9ad683a47..c0d24f1655b556 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -668,6 +668,7 @@ def StdC : StandardSpec<"stdc"> {
   FunctionSpec<"sqrt", RetValSpec, [ArgSpec]>,
   FunctionSpec<"sqrtf", RetValSpec, [ArgSpec]>,
   FunctionSpec<"sqrtl", RetValSpec, 
[ArgSpec]>,
+  GuardedFunctionSpec<"sqrtf16", RetValSpec, 
[ArgSpec], "LIBC_TYPES_HAS_FLOAT16">,
   GuardedFunctionSpec<"sqrtf128", RetValSpec, 
[ArgSpec], "LIBC_TYPES_HAS_FLOAT128">,
 
   FunctionSpec<"trunc", RetValSpec, [ArgSpec]>,
diff --git a/libc/src/__support/FPUtil/generic/sqrt.h 
b/libc/src/__support/FPUtil/generic/sqrt.h
index 4502cc07d32b31..8eea5e4f25310b 100644
--- a/libc/src/__support/FPUtil/generic/sqrt.h
+++ b/libc/src/__support/FPUtil/generic/sqrt.h
@@ -138,7 +138,8 @@ sqrt(InType x) {
   for (InStorageTy

[llvm-branch-commits] [clang] [clang][test] remove unused `run` overload in `BoundNodesCallback` (PR #94244)

2024-08-26 Thread via llvm-branch-commits

Sirraide wrote:

> This pr was actually part of a stack,

Oh yeah, my bad, I didn’t notice that the target branch wasn’t main.

https://github.com/llvm/llvm-project/pull/94244
___
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] [ctx_prof] Add support for ICP (PR #105469)

2024-08-26 Thread Mircea Trofin via llvm-branch-commits

https://github.com/mtrofin edited 
https://github.com/llvm/llvm-project/pull/105469
___
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] [ctx_prof] Add support for ICP (PR #105469)

2024-08-26 Thread Mircea Trofin via llvm-branch-commits

https://github.com/mtrofin updated 
https://github.com/llvm/llvm-project/pull/105469

>From 0ff81a0fb355f31a863ded1ce677b8dad26b3c0f Mon Sep 17 00:00:00 2001
From: Mircea Trofin 
Date: Tue, 20 Aug 2024 21:32:23 -0700
Subject: [PATCH] [ctx_prof] Add support for ICP

---
 llvm/include/llvm/Analysis/CtxProfAnalysis.h  |  17 +-
 llvm/include/llvm/IR/IntrinsicInst.h  |   2 +
 .../llvm/ProfileData/PGOCtxProfReader.h   |  22 +++
 .../Transforms/Utils/CallPromotionUtils.h |   4 +
 llvm/lib/Analysis/CtxProfAnalysis.cpp |  79 +---
 llvm/lib/IR/IntrinsicInst.cpp |  10 +
 .../Transforms/Utils/CallPromotionUtils.cpp   |  86 +
 .../Utils/CallPromotionUtilsTest.cpp  | 178 ++
 8 files changed, 366 insertions(+), 32 deletions(-)

diff --git a/llvm/include/llvm/Analysis/CtxProfAnalysis.h 
b/llvm/include/llvm/Analysis/CtxProfAnalysis.h
index 0b4dd8ae3a0dc7..10aef6f6067b6f 100644
--- a/llvm/include/llvm/Analysis/CtxProfAnalysis.h
+++ b/llvm/include/llvm/Analysis/CtxProfAnalysis.h
@@ -73,6 +73,12 @@ class PGOContextualProfile {
 return 
FuncInfo.find(getDefinedFunctionGUID(F))->second.NextCallsiteIndex++;
   }
 
+  using ConstVisitor = function_ref;
+  using Visitor = function_ref;
+
+  void update(Visitor, const Function *F = nullptr);
+  void visit(ConstVisitor, const Function *F = nullptr) const;
+
   const CtxProfFlatProfile flatten() const;
 
   bool invalidate(Module &, const PreservedAnalyses &PA,
@@ -105,13 +111,18 @@ class CtxProfAnalysis : public 
AnalysisInfoMixin {
 
 class CtxProfAnalysisPrinterPass
 : public PassInfoMixin {
-  raw_ostream &OS;
-
 public:
-  explicit CtxProfAnalysisPrinterPass(raw_ostream &OS) : OS(OS) {}
+  enum class PrintMode { Everything, JSON };
+  explicit CtxProfAnalysisPrinterPass(raw_ostream &OS,
+  PrintMode Mode = PrintMode::Everything)
+  : OS(OS), Mode(Mode) {}
 
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
   static bool isRequired() { return true; }
+
+private:
+  raw_ostream &OS;
+  const PrintMode Mode;
 };
 
 /// Assign a GUID to functions as metadata. GUID calculation takes linkage into
diff --git a/llvm/include/llvm/IR/IntrinsicInst.h 
b/llvm/include/llvm/IR/IntrinsicInst.h
index b45c89cadb0fde..71a96e0671c2f1 100644
--- a/llvm/include/llvm/IR/IntrinsicInst.h
+++ b/llvm/include/llvm/IR/IntrinsicInst.h
@@ -1535,6 +1535,7 @@ class InstrProfCntrInstBase : public InstrProfInstBase {
   ConstantInt *getNumCounters() const;
   // The index of the counter that this instruction acts on.
   ConstantInt *getIndex() const;
+  void setIndex(uint32_t Idx);
 };
 
 /// This represents the llvm.instrprof.cover intrinsic.
@@ -1585,6 +1586,7 @@ class InstrProfCallsite : public InstrProfCntrInstBase {
 return isa(V) && classof(cast(V));
   }
   Value *getCallee() const;
+  void setCallee(Value *Callee);
 };
 
 /// This represents the llvm.instrprof.timestamp intrinsic.
diff --git a/llvm/include/llvm/ProfileData/PGOCtxProfReader.h 
b/llvm/include/llvm/ProfileData/PGOCtxProfReader.h
index 190deaeeacd085..f7f88966f7573f 100644
--- a/llvm/include/llvm/ProfileData/PGOCtxProfReader.h
+++ b/llvm/include/llvm/ProfileData/PGOCtxProfReader.h
@@ -57,9 +57,25 @@ class PGOCtxProfContext final {
 
   GlobalValue::GUID guid() const { return GUID; }
   const SmallVectorImpl &counters() const { return Counters; }
+  SmallVectorImpl &counters() { return Counters; }
+
+  uint64_t getEntrycount() const {
+assert(!Counters.empty() &&
+   "Functions are expected to have at their entry BB instrumented, so "
+   "there should always be at least 1 counter.");
+return Counters[0];
+  }
+
   const CallsiteMapTy &callsites() const { return Callsites; }
   CallsiteMapTy &callsites() { return Callsites; }
 
+  void ingestContext(uint32_t CSId, PGOCtxProfContext &&Other) {
+auto [Iter, _] = callsites().try_emplace(CSId, CallTargetMapTy());
+Iter->second.emplace(Other.guid(), std::move(Other));
+  }
+
+  void resizeCounters(uint32_t Size) { Counters.resize(Size); }
+
   bool hasCallsite(uint32_t I) const {
 return Callsites.find(I) != Callsites.end();
   }
@@ -68,6 +84,12 @@ class PGOCtxProfContext final {
 assert(hasCallsite(I) && "Callsite not found");
 return Callsites.find(I)->second;
   }
+
+  CallTargetMapTy &callsite(uint32_t I) {
+assert(hasCallsite(I) && "Callsite not found");
+return Callsites.find(I)->second;
+  }
+
   void getContainedGuids(DenseSet &Guids) const;
 };
 
diff --git a/llvm/include/llvm/Transforms/Utils/CallPromotionUtils.h 
b/llvm/include/llvm/Transforms/Utils/CallPromotionUtils.h
index 385831f457038d..58af26f31417b0 100644
--- a/llvm/include/llvm/Transforms/Utils/CallPromotionUtils.h
+++ b/llvm/include/llvm/Transforms/Utils/CallPromotionUtils.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_TRANSFORMS_UTILS_CALLPROMOTIONUTILS_H
 #define LLVM_TRANSFORMS_UTILS_CALLPROMOTIONUTILS_H
 
+#include "llvm/Analysis/CtxProfAnaly

[llvm-branch-commits] [clang] release/19.x: [clang][AArch64] Add SME2.1 feature macros (#105657) (PR #106135)

2024-08-26 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/106135
___
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/19.x: [clang][AArch64] Add SME2.1 feature macros (#105657) (PR #106135)

2024-08-26 Thread via llvm-branch-commits

llvmbot wrote:

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

https://github.com/llvm/llvm-project/pull/106135
___
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/19.x: [clang][AArch64] Add SME2.1 feature macros (#105657) (PR #106135)

2024-08-26 Thread via llvm-branch-commits

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

Backport 2617023923175b0fd2a8cb94ad677c061c01627f

Requested by: @sdesmalen-arm

>From 8eb8aa328a788447b69ea5f76b8b22f6c10ad518 Mon Sep 17 00:00:00 2001
From: SpencerAbson 
Date: Fri, 23 Aug 2024 14:27:49 +0100
Subject: [PATCH] [clang][AArch64] Add SME2.1 feature macros (#105657)

(cherry picked from commit 2617023923175b0fd2a8cb94ad677c061c01627f)
---
 clang/lib/Basic/Targets/AArch64.cpp   | 40 ++-
 clang/lib/Basic/Targets/AArch64.h |  3 ++
 .../Preprocessor/aarch64-target-features.c| 16 
 3 files changed, 50 insertions(+), 9 deletions(-)

diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 6ba31cc05a0d75..63fc15f916c558 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -471,23 +471,25 @@ void AArch64TargetInfo::getTargetDefines(const 
LangOptions &Opts,
   if (HasSVE2 && HasSVE2SM4)
 Builder.defineMacro("__ARM_FEATURE_SVE2_SM4", "1");
 
+  if (HasSVEB16B16)
+Builder.defineMacro("__ARM_FEATURE_SVE_B16B16", "1");
+
   if (HasSME) {
 Builder.defineMacro("__ARM_FEATURE_SME");
 Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
   }
 
-  if (HasSME2) {
-Builder.defineMacro("__ARM_FEATURE_SME", "1");
+  if (HasSME2)
 Builder.defineMacro("__ARM_FEATURE_SME2", "1");
-Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
-  }
 
-  if (HasSME2p1) {
-Builder.defineMacro("__ARM_FEATURE_SME", "1");
-Builder.defineMacro("__ARM_FEATURE_SME2", "1");
+  if (HasSME2p1)
 Builder.defineMacro("__ARM_FEATURE_SME2p1", "1");
-Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
-  }
+
+  if (HasSMEF16F16)
+Builder.defineMacro("__ARM_FEATURE_SME_F16F16", "1");
+
+  if (HasSMEB16B16)
+Builder.defineMacro("__ARM_FEATURE_SME_B16B16", "1");
 
   if (HasCRC)
 Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
@@ -749,6 +751,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const 
{
   .Case("sve", FPU & SveMode)
   .Case("sve-bf16", FPU & SveMode && HasBFloat16)
   .Case("sve-i8mm", FPU & SveMode && HasMatMul)
+  .Case("sve-b16b16", HasSVEB16B16)
   .Case("f32mm", FPU & SveMode && HasMatmulFP32)
   .Case("f64mm", FPU & SveMode && HasMatmulFP64)
   .Case("sve2", FPU & SveMode && HasSVE2)
@@ -763,6 +766,8 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const 
{
   .Case("sme-f64f64", HasSMEF64F64)
   .Case("sme-i16i64", HasSMEI16I64)
   .Case("sme-fa64", HasSMEFA64)
+  .Case("sme-f16f16", HasSMEF16F16)
+  .Case("sme-b16b16", HasSMEB16B16)
   .Cases("memtag", "memtag2", HasMTE)
   .Case("sb", HasSB)
   .Case("predres", HasPredRes)
@@ -863,6 +868,8 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasSVE2 = true;
   HasSVE2SM4 = true;
 }
+if (Feature == "+sve-b16b16")
+  HasSVEB16B16 = true;
 if (Feature == "+sve2-bitperm") {
   FPU |= NeonMode;
   FPU |= SveMode;
@@ -919,6 +926,21 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasSVE2 = true;
   HasSMEFA64 = true;
 }
+if (Feature == "+sme-f16f16") {
+  HasSME = true;
+  HasSME2 = true;
+  HasBFloat16 = true;
+  HasFullFP16 = true;
+  HasSMEF16F16 = true;
+}
+if (Feature == "+sme-b16b16") {
+  HasSME = true;
+  HasSME2 = true;
+  HasBFloat16 = true;
+  HasFullFP16 = true;
+  HasSVEB16B16 = true;
+  HasSMEB16B16 = true;
+}
 if (Feature == "+sb")
   HasSB = true;
 if (Feature == "+predres")
diff --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 7bdf5a2b4106e4..526f7f30a38618 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -53,6 +53,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   bool HasSVE2AES = false;
   bool HasSVE2SHA3 = false;
   bool HasSVE2SM4 = false;
+  bool HasSVEB16B16 = false;
   bool HasSVE2BitPerm = false;
   bool HasMatmulFP64 = false;
   bool HasMatmulFP32 = false;
@@ -71,6 +72,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   bool HasSME2 = false;
   bool HasSMEF64F64 = false;
   bool HasSMEI16I64 = false;
+  bool HasSMEF16F16 = false;
+  bool HasSMEB16B16 = false;
   bool HasSME2p1 = false;
   bool HasSB = false;
   bool HasPredRes = false;
diff --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index 87bd3e142d2c40..ae2bdda6f536c5 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -709,3 +709,19 @@
 // CHECK-SME2p1: __ARM_FEATURE_SME 1
 // CHECK-SME2p1: __ARM_FEATURE_SME2 1
 // CHECK-SME2p1: __ARM_FEATURE_SME2p1 1
+
+// RUN: %clang --target=aarch64 -march=armv9-a+sve-b16b

[llvm-branch-commits] [clang] release/19.x: [clang][AArch64] Add SME2.1 feature macros (#105657) (PR #106135)

2024-08-26 Thread via llvm-branch-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-aarch64

Author: None (llvmbot)


Changes

Backport 2617023923175b0fd2a8cb94ad677c061c01627f

Requested by: @sdesmalen-arm

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


3 Files Affected:

- (modified) clang/lib/Basic/Targets/AArch64.cpp (+31-9) 
- (modified) clang/lib/Basic/Targets/AArch64.h (+3) 
- (modified) clang/test/Preprocessor/aarch64-target-features.c (+16) 


``diff
diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 6ba31cc05a0d75..63fc15f916c558 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -471,23 +471,25 @@ void AArch64TargetInfo::getTargetDefines(const 
LangOptions &Opts,
   if (HasSVE2 && HasSVE2SM4)
 Builder.defineMacro("__ARM_FEATURE_SVE2_SM4", "1");
 
+  if (HasSVEB16B16)
+Builder.defineMacro("__ARM_FEATURE_SVE_B16B16", "1");
+
   if (HasSME) {
 Builder.defineMacro("__ARM_FEATURE_SME");
 Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
   }
 
-  if (HasSME2) {
-Builder.defineMacro("__ARM_FEATURE_SME", "1");
+  if (HasSME2)
 Builder.defineMacro("__ARM_FEATURE_SME2", "1");
-Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
-  }
 
-  if (HasSME2p1) {
-Builder.defineMacro("__ARM_FEATURE_SME", "1");
-Builder.defineMacro("__ARM_FEATURE_SME2", "1");
+  if (HasSME2p1)
 Builder.defineMacro("__ARM_FEATURE_SME2p1", "1");
-Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
-  }
+
+  if (HasSMEF16F16)
+Builder.defineMacro("__ARM_FEATURE_SME_F16F16", "1");
+
+  if (HasSMEB16B16)
+Builder.defineMacro("__ARM_FEATURE_SME_B16B16", "1");
 
   if (HasCRC)
 Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
@@ -749,6 +751,7 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const 
{
   .Case("sve", FPU & SveMode)
   .Case("sve-bf16", FPU & SveMode && HasBFloat16)
   .Case("sve-i8mm", FPU & SveMode && HasMatMul)
+  .Case("sve-b16b16", HasSVEB16B16)
   .Case("f32mm", FPU & SveMode && HasMatmulFP32)
   .Case("f64mm", FPU & SveMode && HasMatmulFP64)
   .Case("sve2", FPU & SveMode && HasSVE2)
@@ -763,6 +766,8 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const 
{
   .Case("sme-f64f64", HasSMEF64F64)
   .Case("sme-i16i64", HasSMEI16I64)
   .Case("sme-fa64", HasSMEFA64)
+  .Case("sme-f16f16", HasSMEF16F16)
+  .Case("sme-b16b16", HasSMEB16B16)
   .Cases("memtag", "memtag2", HasMTE)
   .Case("sb", HasSB)
   .Case("predres", HasPredRes)
@@ -863,6 +868,8 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasSVE2 = true;
   HasSVE2SM4 = true;
 }
+if (Feature == "+sve-b16b16")
+  HasSVEB16B16 = true;
 if (Feature == "+sve2-bitperm") {
   FPU |= NeonMode;
   FPU |= SveMode;
@@ -919,6 +926,21 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasSVE2 = true;
   HasSMEFA64 = true;
 }
+if (Feature == "+sme-f16f16") {
+  HasSME = true;
+  HasSME2 = true;
+  HasBFloat16 = true;
+  HasFullFP16 = true;
+  HasSMEF16F16 = true;
+}
+if (Feature == "+sme-b16b16") {
+  HasSME = true;
+  HasSME2 = true;
+  HasBFloat16 = true;
+  HasFullFP16 = true;
+  HasSVEB16B16 = true;
+  HasSMEB16B16 = true;
+}
 if (Feature == "+sb")
   HasSB = true;
 if (Feature == "+predres")
diff --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 7bdf5a2b4106e4..526f7f30a38618 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -53,6 +53,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   bool HasSVE2AES = false;
   bool HasSVE2SHA3 = false;
   bool HasSVE2SM4 = false;
+  bool HasSVEB16B16 = false;
   bool HasSVE2BitPerm = false;
   bool HasMatmulFP64 = false;
   bool HasMatmulFP32 = false;
@@ -71,6 +72,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   bool HasSME2 = false;
   bool HasSMEF64F64 = false;
   bool HasSMEI16I64 = false;
+  bool HasSMEF16F16 = false;
+  bool HasSMEB16B16 = false;
   bool HasSME2p1 = false;
   bool HasSB = false;
   bool HasPredRes = false;
diff --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index 87bd3e142d2c40..ae2bdda6f536c5 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -709,3 +709,19 @@
 // CHECK-SME2p1: __ARM_FEATURE_SME 1
 // CHECK-SME2p1: __ARM_FEATURE_SME2 1
 // CHECK-SME2p1: __ARM_FEATURE_SME2p1 1
+
+// RUN: %clang --target=aarch64 -march=armv9-a+sve-b16b16 -x c -E -dM %s -o - 
| FileCheck --check-prefix=CHECK-SVEB16B16 %s
+// CHECK-SVEB16B16: __ARM_FEATURE_SVE_B16B16 1
+
+// RUN: %clang --target=aarch64 -march=armv9-a+sme-f16f16 -x c -E -dM %s 

[llvm-branch-commits] [clang] release/19.x: [clang][AArch64] Add SME2.1 feature macros (#105657) (PR #106135)

2024-08-26 Thread Sander de Smalen via llvm-branch-commits

sdesmalen-arm wrote:

Rationale; this helps people who use LLVM 19 to write code for the SME2.1 
intrinsics, which the compiler already supports, but without the macros set a 
user couldn't write compliant code, e.g. `#if defined __ARM_FEATURE_SME_B16B16, 
, #endif`, because the macro would not be set.

https://github.com/llvm/llvm-project/pull/106135
___
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/19.x: [clang][AArch64] Add SME2.1 feature macros (#105657) (PR #106135)

2024-08-26 Thread Sander de Smalen via llvm-branch-commits

https://github.com/sdesmalen-arm approved this pull request.


https://github.com/llvm/llvm-project/pull/106135
___
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] [ctx_prof] Add support for ICP (PR #105469)

2024-08-26 Thread Mircea Trofin via llvm-branch-commits

https://github.com/mtrofin updated 
https://github.com/llvm/llvm-project/pull/105469

>From 44201f1b7d371f156a8ae02b329f2321cad503d2 Mon Sep 17 00:00:00 2001
From: Mircea Trofin 
Date: Tue, 20 Aug 2024 21:32:23 -0700
Subject: [PATCH] [ctx_prof] Add support for ICP

---
 llvm/include/llvm/Analysis/CtxProfAnalysis.h  |  17 +-
 llvm/include/llvm/IR/IntrinsicInst.h  |   2 +
 .../llvm/ProfileData/PGOCtxProfReader.h   |  22 +++
 .../Transforms/Utils/CallPromotionUtils.h |   4 +
 llvm/lib/Analysis/CtxProfAnalysis.cpp |  79 +---
 llvm/lib/IR/IntrinsicInst.cpp |  10 +
 .../Transforms/Utils/CallPromotionUtils.cpp   |  86 +
 .../Utils/CallPromotionUtilsTest.cpp  | 174 ++
 8 files changed, 362 insertions(+), 32 deletions(-)

diff --git a/llvm/include/llvm/Analysis/CtxProfAnalysis.h 
b/llvm/include/llvm/Analysis/CtxProfAnalysis.h
index 0b4dd8ae3a0dc7..10aef6f6067b6f 100644
--- a/llvm/include/llvm/Analysis/CtxProfAnalysis.h
+++ b/llvm/include/llvm/Analysis/CtxProfAnalysis.h
@@ -73,6 +73,12 @@ class PGOContextualProfile {
 return 
FuncInfo.find(getDefinedFunctionGUID(F))->second.NextCallsiteIndex++;
   }
 
+  using ConstVisitor = function_ref;
+  using Visitor = function_ref;
+
+  void update(Visitor, const Function *F = nullptr);
+  void visit(ConstVisitor, const Function *F = nullptr) const;
+
   const CtxProfFlatProfile flatten() const;
 
   bool invalidate(Module &, const PreservedAnalyses &PA,
@@ -105,13 +111,18 @@ class CtxProfAnalysis : public 
AnalysisInfoMixin {
 
 class CtxProfAnalysisPrinterPass
 : public PassInfoMixin {
-  raw_ostream &OS;
-
 public:
-  explicit CtxProfAnalysisPrinterPass(raw_ostream &OS) : OS(OS) {}
+  enum class PrintMode { Everything, JSON };
+  explicit CtxProfAnalysisPrinterPass(raw_ostream &OS,
+  PrintMode Mode = PrintMode::Everything)
+  : OS(OS), Mode(Mode) {}
 
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
   static bool isRequired() { return true; }
+
+private:
+  raw_ostream &OS;
+  const PrintMode Mode;
 };
 
 /// Assign a GUID to functions as metadata. GUID calculation takes linkage into
diff --git a/llvm/include/llvm/IR/IntrinsicInst.h 
b/llvm/include/llvm/IR/IntrinsicInst.h
index b45c89cadb0fde..71a96e0671c2f1 100644
--- a/llvm/include/llvm/IR/IntrinsicInst.h
+++ b/llvm/include/llvm/IR/IntrinsicInst.h
@@ -1535,6 +1535,7 @@ class InstrProfCntrInstBase : public InstrProfInstBase {
   ConstantInt *getNumCounters() const;
   // The index of the counter that this instruction acts on.
   ConstantInt *getIndex() const;
+  void setIndex(uint32_t Idx);
 };
 
 /// This represents the llvm.instrprof.cover intrinsic.
@@ -1585,6 +1586,7 @@ class InstrProfCallsite : public InstrProfCntrInstBase {
 return isa(V) && classof(cast(V));
   }
   Value *getCallee() const;
+  void setCallee(Value *Callee);
 };
 
 /// This represents the llvm.instrprof.timestamp intrinsic.
diff --git a/llvm/include/llvm/ProfileData/PGOCtxProfReader.h 
b/llvm/include/llvm/ProfileData/PGOCtxProfReader.h
index 190deaeeacd085..f7f88966f7573f 100644
--- a/llvm/include/llvm/ProfileData/PGOCtxProfReader.h
+++ b/llvm/include/llvm/ProfileData/PGOCtxProfReader.h
@@ -57,9 +57,25 @@ class PGOCtxProfContext final {
 
   GlobalValue::GUID guid() const { return GUID; }
   const SmallVectorImpl &counters() const { return Counters; }
+  SmallVectorImpl &counters() { return Counters; }
+
+  uint64_t getEntrycount() const {
+assert(!Counters.empty() &&
+   "Functions are expected to have at their entry BB instrumented, so "
+   "there should always be at least 1 counter.");
+return Counters[0];
+  }
+
   const CallsiteMapTy &callsites() const { return Callsites; }
   CallsiteMapTy &callsites() { return Callsites; }
 
+  void ingestContext(uint32_t CSId, PGOCtxProfContext &&Other) {
+auto [Iter, _] = callsites().try_emplace(CSId, CallTargetMapTy());
+Iter->second.emplace(Other.guid(), std::move(Other));
+  }
+
+  void resizeCounters(uint32_t Size) { Counters.resize(Size); }
+
   bool hasCallsite(uint32_t I) const {
 return Callsites.find(I) != Callsites.end();
   }
@@ -68,6 +84,12 @@ class PGOCtxProfContext final {
 assert(hasCallsite(I) && "Callsite not found");
 return Callsites.find(I)->second;
   }
+
+  CallTargetMapTy &callsite(uint32_t I) {
+assert(hasCallsite(I) && "Callsite not found");
+return Callsites.find(I)->second;
+  }
+
   void getContainedGuids(DenseSet &Guids) const;
 };
 
diff --git a/llvm/include/llvm/Transforms/Utils/CallPromotionUtils.h 
b/llvm/include/llvm/Transforms/Utils/CallPromotionUtils.h
index 385831f457038d..58af26f31417b0 100644
--- a/llvm/include/llvm/Transforms/Utils/CallPromotionUtils.h
+++ b/llvm/include/llvm/Transforms/Utils/CallPromotionUtils.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_TRANSFORMS_UTILS_CALLPROMOTIONUTILS_H
 #define LLVM_TRANSFORMS_UTILS_CALLPROMOTIONUTILS_H
 
+#include "llvm/Analysis/CtxProfAnaly

[llvm-branch-commits] [runtimes] Allow building against an installed LLVM tree (PR #86209)

2024-08-26 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson updated 
https://github.com/llvm/llvm-project/pull/86209


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


  1   2   >