[llvm-branch-commits] [libcxx] Add Testing Configuration for LLVM libc (PR #165120)
llvmbot wrote:
@llvm/pr-subscribers-libcxx
Author: Aiden Grossman (boomanaiden154)
Changes
This patch adds a CMake cache, and the testing configs to build libc++
and run the tests against LLVM libc.
---
Full diff: https://github.com/llvm/llvm-project/pull/165120.diff
3 Files Affected:
- (added) libcxx/cmake/caches/Generic-llvm-libc.cmake (+65)
- (added) libcxx/test/configs/llvm-libc++-llvm-libc.cfg.in (+27)
- (added) libcxxabi/test/configs/llvm-libc++abi-llvm-libc.cfg.in (+27)
``diff
diff --git a/libcxx/cmake/caches/Generic-llvm-libc.cmake
b/libcxx/cmake/caches/Generic-llvm-libc.cmake
new file mode 100644
index 0..88440bb7966bd
--- /dev/null
+++ b/libcxx/cmake/caches/Generic-llvm-libc.cmake
@@ -0,0 +1,65 @@
+set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBUNWIND_INSTALL_LIBRARY ON CACHE BOOL "")
+set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+
+set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
+set(COMPILER_RT_CXX_LIBRARY "libcxx" CACHE STRING "")
+
+set(COMPILER_RT_USE_LLVM_UNWINDER OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_BUILTINS ON CACHE BOOL "")
+set(COMPILER_RT_BUILD_CRT ON CACHE BOOL "")
+set(COMPILER_RT_BUILD_STANDALONE_LIBATOMIC OFF CACHE BOOL "")
+set(COMPILER_RT_HAS_FNO_BUILTIN_FLAG ON CACHE BOOL "")
+set(COMPILER_RT_BUILTINS_HIDE_SYMBOLS ON CACHE BOOL "")
+set(COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG ON CACHE BOOL "")
+set(COMPILER_RT_BUILD_MEMPROF OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_PROFILE OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_SANITIZERS ON CACHE BOOL "")
+set(COMPILER_RT_BUILD_XRAY OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_ORC OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
+set(COMPILER_RT_DEBUG OFF CACHE BOOL "")
+set(COMPILER_RT_CRT_USE_EH_FRAME_REGISTRY ON CACHE BOOL "")
+
+set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBCXXABI_USE_LLVM_UNWINDER OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
+set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBCXX_INCLUDE_BENCHMARKS OFF CACHE BOOL "")
+
+set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
+set(LIBCXX_INSTALL_LIBRARY ON CACHE BOOL "")
+set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "")
+
+# confirmed not available in libc
+set(LIBCXX_ENABLE_LOCALIZATION OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_WIDE_CHARACTERS OFF CACHE BOOL "")
+
+# missing at least `` and `utimes`
+set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
+
+# missing at least `ioctl`
+set(LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")
+
+# unclear what this is missing
+set(LIBCXX_ENABLE_MONOTONIC_CLOCK OFF CACHE BOOL "")
+
+# requires LIBCXX_ENABLE_MONOTONIC_CLOCK=ON
+set(LIBCXX_ENABLE_THREADS OFF CACHE BOOL "")
+set(LIBCXXABI_ENABLE_THREADS OFF CACHE BOOL "")
+
+# these are fine
+set(LIBCXX_ENABLE_UNICODE ON CACHE BOOL "")
+set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
+set(LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
+set(LIBCXX_ENABLE_RTTI OFF CACHE BOOL "")
+set(RUNTIMES_USE_LIBC "llvm-libc" CACHE STRING "")
+
+set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libc;libunwind;libcxxabi;libcxx" CACHE
STRING "")
+set(LLVM_LIBC_FULL_BUILD ON CACHE BOOL "")
+set(LLVM_LIBC_INCLUDE_SCUDO ON CACHE BOOL "")
+set(COMPILER_RT_BUILD_GWP_ASAN OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC ON CACHE BOOL "")
+
+#set(CMAKE_SYSROOT "/home/gha/libc-sysroot" CACHE STRING "")
diff --git a/libcxx/test/configs/llvm-libc++-llvm-libc.cfg.in
b/libcxx/test/configs/llvm-libc++-llvm-libc.cfg.in
new file mode 100644
index 0..051d131ab78cd
--- /dev/null
+++ b/libcxx/test/configs/llvm-libc++-llvm-libc.cfg.in
@@ -0,0 +1,27 @@
+# This testing configuration handles running the test suite against LLVM's
libc++
+# using a static library.
+
+lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
+
+config.substitutions.append(('%{flags}',
+'-pthread' + (' -isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if
'@CMAKE_OSX_SYSROOT@' else '')
+))
+config.substitutions.append(('%{compile_flags}',
+'-nostdinc++ -I %{include-dir} -I %{target-include-dir} -I
/home/gha/llvm-project/build-runtimes/libc/include -I
%{libcxx-dir}/test/support'
+))
+config.substitutions.append(('%{link_flags}',
+'-nodefaultlibs -nostartfiles -L %{lib-dir} -lc++ -lc++abi
/home/gha/llvm-project/build-runtimes/libc/startup/linux/crt1.o
/home/gha/llvm-project/build-runtimes/libc/lib/libc.a
/home/gha/llvm-project/build-runtimes/libc/lib/libm.a -static
-fno-use-cxa-atexit
/home/gha/llvm-project/build-runtimes/compiler-rt/lib/linux/libclang_rt.builtins-x86_64.a'
+))
+config.substitutions.append(('%{exec}',
+'%{executor} --execdir %{temp} -- '
+))
+
+import os, site
+site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils'))
+import libcxx.test.params, libcxx.test.config
+libcxx.test.config.configure(
+libcxx.test.params.DEFAULT_PARAMETERS,
+libcxx.test.features.DEFAULT_FEATURES,
+config,
+lit_config
+)
diff --git a/libcxxabi
[llvm-branch-commits] [libcxx] Add Testing Configuration for LLVM libc (PR #165120)
boomanaiden154 wrote: This still needs some work. Then there is still quite a bit of functionality needed in libc to get the tests passing for `check-cxx` (`check-cxxabi` already works). But once this is ready, I think landing it would probably make sense so there is a central configuration for people to hack on to get things working. https://github.com/llvm/llvm-project/pull/165120 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] Add Testing Configuration for LLVM libc (PR #165120)
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/165120 This patch adds a CMake cache, and the testing configs to build libc++ and run the tests against LLVM libc. ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] Add Testing Configuration for LLVM libc (PR #165120)
https://github.com/boomanaiden154 converted_to_draft https://github.com/llvm/llvm-project/pull/165120 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] [OpenMP] Add codegen support for dyn_groupprivate clause (PR #152830)
https://github.com/kevinsala updated
https://github.com/llvm/llvm-project/pull/152830
>From f66e5faa93cf2f40bd2a6bd7a95abddf78fb6076 Mon Sep 17 00:00:00 2001
From: Kevin Sala
Date: Fri, 8 Aug 2025 11:04:06 -0700
Subject: [PATCH 1/2] [OpenMP] Add codegen support for dyn_groupprivate clause
---
clang/lib/CodeGen/CGOpenMPRuntime.cpp | 40 ---
.../llvm/Frontend/OpenMP/OMPIRBuilder.h | 7 +++-
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 10 -
3 files changed, 39 insertions(+), 18 deletions(-)
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index a5f2f0efa2c3b..d9121827a813a 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9489,18 +9489,30 @@ static llvm::Value *emitDeviceID(
return DeviceID;
}
-static llvm::Value *emitDynCGGroupMem(const OMPExecutableDirective &D,
- CodeGenFunction &CGF) {
- llvm::Value *DynCGroupMem = CGF.Builder.getInt32(0);
-
- if (auto *DynMemClause = D.getSingleClause()) {
-CodeGenFunction::RunCleanupsScope DynCGroupMemScope(CGF);
-llvm::Value *DynCGroupMemVal = CGF.EmitScalarExpr(
-DynMemClause->getSize(), /*IgnoreResultAssign=*/true);
-DynCGroupMem = CGF.Builder.CreateIntCast(DynCGroupMemVal, CGF.Int32Ty,
- /*isSigned=*/false);
- }
- return DynCGroupMem;
+static std::pair
+emitDynCGroupMem(const OMPExecutableDirective &D, CodeGenFunction &CGF) {
+ llvm::Value *DynGP = CGF.Builder.getInt32(0);
+ bool DynGPFallback = false;
+
+ if (auto *DynGPClause = D.getSingleClause()) {
+CodeGenFunction::RunCleanupsScope DynGPScope(CGF);
+llvm::Value *DynGPVal =
+CGF.EmitScalarExpr(DynGPClause->getSize(),
/*IgnoreResultAssign=*/true);
+DynGP = CGF.Builder.CreateIntCast(DynGPVal, CGF.Int32Ty,
+ /*isSigned=*/false);
+DynGPFallback = (DynGPClause->getFirstDynGroupprivateModifier() !=
+ OMPC_DYN_GROUPPRIVATE_strict &&
+ DynGPClause->getSecondDynGroupprivateModifier() !=
+ OMPC_DYN_GROUPPRIVATE_strict);
+ } else if (auto *OMPXDynCGClause =
+ D.getSingleClause()) {
+CodeGenFunction::RunCleanupsScope DynCGMemScope(CGF);
+llvm::Value *DynCGMemVal = CGF.EmitScalarExpr(OMPXDynCGClause->getSize(),
+ /*IgnoreResultAssign=*/true);
+DynGP = CGF.Builder.CreateIntCast(DynCGMemVal, CGF.Int32Ty,
+ /*isSigned=*/false);
+ }
+ return {DynGP, DynGPFallback};
}
static void genMapInfoForCaptures(
MappableExprsHandler &MEHandler, CodeGenFunction &CGF,
@@ -9710,7 +9722,7 @@ static void emitTargetCallKernelLaunch(
llvm::Value *RTLoc = OMPRuntime->emitUpdateLocation(CGF, D.getBeginLoc());
llvm::Value *NumIterations =
OMPRuntime->emitTargetNumIterationsCall(CGF, D, SizeEmitter);
-llvm::Value *DynCGGroupMem = emitDynCGGroupMem(D, CGF);
+auto [DynCGroupMem, DynCGroupMemFallback] = emitDynCGroupMem(D, CGF);
llvm::OpenMPIRBuilder::InsertPointTy AllocaIP(
CGF.AllocaInsertPt->getParent(), CGF.AllocaInsertPt->getIterator());
@@ -9720,7 +9732,7 @@ static void emitTargetCallKernelLaunch(
llvm::OpenMPIRBuilder::TargetKernelArgs Args(
NumTargetItems, RTArgs, NumIterations, NumTeams, NumThreads,
-DynCGGroupMem, HasNoWait);
+DynCGroupMem, HasNoWait, DynCGroupMemFallback);
llvm::OpenMPIRBuilder::InsertPointTy AfterIP =
cantFail(OMPRuntime->getOMPBuilder().emitKernelLaunch(
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index 19a4058b64382..ebc50eecb551e 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -2341,17 +2341,20 @@ class OpenMPIRBuilder {
Value *DynCGGroupMem = nullptr;
/// True if the kernel has 'no wait' clause.
bool HasNoWait = false;
+/// True if the dynamic shared memory may fallback.
+bool MayFallbackDynCGroupMem = false;
// Constructors for TargetKernelArgs.
TargetKernelArgs() {}
TargetKernelArgs(unsigned NumTargetItems, TargetDataRTArgs RTArgs,
Value *NumIterations, ArrayRef NumTeams,
ArrayRef NumThreads, Value *DynCGGroupMem,
- bool HasNoWait)
+ bool HasNoWait, bool MayFallbackDynCGroupMem)
: NumTargetItems(NumTargetItems), RTArgs(RTArgs),
NumIterations(NumIterations), NumTeams(NumTeams),
NumThreads(NumThreads), DynCGGroupMem(DynCGGroupMem),
- HasNoWait(HasNoWait) {}
+ HasNoWait(HasNoWait),
+ MayFallbackDynCGroupMem(MayFallbackDynCGroupMem) {}
};
/// Create the kernel args vector used by emitTargetKernel. This function
[llvm-branch-commits] [lit] Add support for setting limits to unlimited (PR #165123)
llvmbot wrote:
@llvm/pr-subscribers-testing-tools
Author: Aiden Grossman (boomanaiden154)
Changes
This is used by a couple compiler-rt tests.
---
Full diff: https://github.com/llvm/llvm-project/pull/165123.diff
3 Files Affected:
- (modified) llvm/utils/lit/lit/TestRunner.py (+5-1)
- (added) llvm/utils/lit/tests/Inputs/shtest-ulimit/ulimit_unlimited.txt (+6)
- (modified) llvm/utils/lit/tests/shtest-ulimit.py (+7-1)
``diff
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index a48df097403c7..ee7670d4a9961 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -12,6 +12,7 @@
import shutil
import tempfile
import threading
+import resource
import typing
import traceback
from typing import Optional, Tuple
@@ -605,7 +606,10 @@ def executeBuiltinUlimit(cmd, shenv):
if len(cmd.args) != 3:
raise InternalShellError(cmd, "'ulimit' requires two arguments")
try:
-new_limit = int(cmd.args[2])
+if cmd.args[2] == "unlimited":
+new_limit = resource.RLIM_INFINITY
+else:
+new_limit = int(cmd.args[2])
except ValueError as err:
raise InternalShellError(cmd, "Error: 'ulimit': %s" % str(err))
if cmd.args[1] == "-v":
diff --git a/llvm/utils/lit/tests/Inputs/shtest-ulimit/ulimit_unlimited.txt
b/llvm/utils/lit/tests/Inputs/shtest-ulimit/ulimit_unlimited.txt
new file mode 100644
index 0..b8aa3d5071712
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-ulimit/ulimit_unlimited.txt
@@ -0,0 +1,6 @@
+# RUN: ulimit -f 5
+# RUN: %{python} %S/print_limits.py
+# RUN: ulimit -f unlimited
+# RUN: %{python} %S/print_limits.py
+# Fail the test so that we can assert on the output.
+# RUN: not echo return
diff --git a/llvm/utils/lit/tests/shtest-ulimit.py
b/llvm/utils/lit/tests/shtest-ulimit.py
index ba3de8b1bfced..d63a92f1c18e3 100644
--- a/llvm/utils/lit/tests/shtest-ulimit.py
+++ b/llvm/utils/lit/tests/shtest-ulimit.py
@@ -11,7 +11,7 @@
# RUN: not %{lit} -a -v %{inputs}/shtest-ulimit --order=lexical \
# RUN: | FileCheck -DBASE_NOFILE_LIMIT=%{readfile:%t.nofile_limit} %s
-# CHECK: -- Testing: 3 tests{{.*}}
+# CHECK: -- Testing: 4 tests{{.*}}
# CHECK-LABEL: FAIL: shtest-ulimit :: ulimit-bad-arg.txt ({{[^)]*}})
# CHECK: ulimit -n
@@ -27,3 +27,9 @@
# CHECK-LABEL: FAIL: shtest-ulimit :: ulimit_reset.txt ({{[^)]*}})
# CHECK: RLIMIT_NOFILE=[[BASE_NOFILE_LIMIT]]
+
+# CHECK-LABEL: FAIL: shtest-ulimit :: ulimit_unlimited.txt ({{[^)]*}})
+# CHECK: ulimit -f 5
+# CHECK: RLIMIT_FSIZE=5
+# CHECK: ulimit -f unlimited
+# CHECK: RLIMIT_FSIZE=-1
``
https://github.com/llvm/llvm-project/pull/165123
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lit] Add support for setting limits to unlimited (PR #165123)
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/165123 This is used by a couple compiler-rt tests. ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [X86][NewPM] Port X86LowerAMXType to NewPM (PR #165084)
llvmbot wrote:
@llvm/pr-subscribers-backend-x86
Author: Aiden Grossman (boomanaiden154)
Changes
To enable the eventual migration of everything to the NewPM. There are
two tests using this pass that rely on it running on functions marked
optnone. Leave these as TODOs for now, probably coming back to them in
the future when we have a way to override the optnone pass
instrumentation through a CLI flag or something.
---
Full diff: https://github.com/llvm/llvm-project/pull/165084.diff
13 Files Affected:
- (modified) llvm/lib/Target/X86/X86.h (+13-1)
- (modified) llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp (+1)
- (modified) llvm/lib/Target/X86/X86LowerAMXType.cpp (+57-39)
- (modified) llvm/lib/Target/X86/X86PassRegistry.def (+6-1)
- (modified) llvm/lib/Target/X86/X86TargetMachine.cpp (+1-1)
- (modified) llvm/test/CodeGen/X86/AMX/amx-combine-undef.ll (+2-1)
- (modified) llvm/test/CodeGen/X86/AMX/amx-combine.ll (+2-1)
- (modified) llvm/test/CodeGen/X86/AMX/amx-configO2toO0-lower.ll (+2-1)
- (modified) llvm/test/CodeGen/X86/AMX/amx-type.ll (+2-1)
- (modified) llvm/test/CodeGen/X86/AMX/lat-combine-amx-bitcast.ll (+2-1)
- (modified) llvm/test/CodeGen/X86/AMX/lat-transform-amx-bitcast.ll (+2-1)
- (modified) llvm/test/CodeGen/X86/amx_tile_pair_lower_type_O0.ll (+3-1)
- (modified) llvm/test/CodeGen/X86/amx_tile_pair_lower_type_O2.ll (+2-1)
``diff
diff --git a/llvm/lib/Target/X86/X86.h b/llvm/lib/Target/X86/X86.h
index 706ab2b62bc1b..bac26baa6322e 100644
--- a/llvm/lib/Target/X86/X86.h
+++ b/llvm/lib/Target/X86/X86.h
@@ -14,7 +14,10 @@
#ifndef LLVM_LIB_TARGET_X86_X86_H
#define LLVM_LIB_TARGET_X86_X86_H
+#include "llvm/IR/Analysis.h"
+#include "llvm/IR/PassManager.h"
#include "llvm/Support/CodeGen.h"
+#include "llvm/Target/TargetMachine.h"
namespace llvm {
@@ -162,7 +165,16 @@ FunctionPass *createX86WinEHUnwindV2Pass();
/// The pass transforms load/store <256 x i32> to AMX load/store intrinsics
/// or split the data to two <128 x i32>.
-FunctionPass *createX86LowerAMXTypePass();
+class X86LowerAMXTypePass : public PassInfoMixin {
+private:
+ const TargetMachine &TM;
+
+public:
+ X86LowerAMXTypePass(const TargetMachine &TM) : TM(TM) {}
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
+};
+
+FunctionPass *createX86LowerAMXTypeLegacyPass();
/// The pass transforms amx intrinsics to scalar operation if the function has
/// optnone attribute or it is O0.
diff --git a/llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp
b/llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp
index d979517e12af6..2c0443da673a8 100644
--- a/llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp
+++ b/llvm/lib/Target/X86/X86CodeGenPassBuilder.cpp
@@ -10,6 +10,7 @@
/// TODO: Port CodeGen passes to new pass manager.
//===--===//
+#include "X86.h"
#include "X86ISelDAGToDAG.h"
#include "X86TargetMachine.h"
diff --git a/llvm/lib/Target/X86/X86LowerAMXType.cpp
b/llvm/lib/Target/X86/X86LowerAMXType.cpp
index 0ba71ada8638e..74c9a46ab5c00 100644
--- a/llvm/lib/Target/X86/X86LowerAMXType.cpp
+++ b/llvm/lib/Target/X86/X86LowerAMXType.cpp
@@ -46,12 +46,14 @@
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/CodeGen/ValueTypes.h"
+#include "llvm/IR/Analysis.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/IntrinsicsX86.h"
+#include "llvm/IR/PassManager.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
@@ -64,7 +66,7 @@
using namespace llvm;
using namespace PatternMatch;
-#define DEBUG_TYPE "lower-amx-type"
+#define DEBUG_TYPE "x86-lower-amx-type"
static bool isAMXCast(Instruction *II) {
return match(II,
@@ -137,7 +139,7 @@ static Instruction
*getFirstNonAllocaInTheEntryBlock(Function &F) {
class ShapeCalculator {
private:
- TargetMachine *TM = nullptr;
+ const TargetMachine *TM = nullptr;
// In AMX intrinsics we let Shape = {Row, Col}, but the
// RealCol = Col / ElementSize. We may use the RealCol
@@ -145,7 +147,7 @@ class ShapeCalculator {
std::map Col2Row, Row2Col;
public:
- ShapeCalculator(TargetMachine *TargetM) : TM(TargetM) {}
+ ShapeCalculator(const TargetMachine *TargetM) : TM(TargetM) {}
std::pair getShape(IntrinsicInst *II, unsigned OpNo);
std::pair getShape(PHINode *Phi);
Value *getRowFromCol(Instruction *II, Value *V, unsigned Granularity);
@@ -1432,8 +1434,58 @@ bool X86LowerAMXCast::transformAllAMXCast() {
return Change;
}
+bool lowerAmxType(Function &F, const TargetMachine *TM,
+ TargetLibraryInfo *TLI) {
+ // Performance optimization: most code doesn't use AMX, so return early if
+ // there are no instructions that produce AMX values. This is sufficient, as
+ // AMX arguments and constants are not allowed -- so any pro
[llvm-branch-commits] [X86][NewPM] Port X86LowerAMXType to NewPM (PR #165084)
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/165084 To enable the eventual migration of everything to the NewPM. There are two tests using this pass that rely on it running on functions marked optnone. Leave these as TODOs for now, probably coming back to them in the future when we have a way to override the optnone pass instrumentation through a CLI flag or something. ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [X86][NewPM] Port X86LowerAMXType to NewPM (PR #165084)
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/165084 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [X86][NewPM] Port X86LowerAMXType to NewPM (PR #165084)
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/165084 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [SpecialCaseList] Add RadixTree for substring matching (PR #164545)
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/164545 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [SpecialCaseList] Add RadixTree for substring matching (PR #164545)
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/164545 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [SpecialCaseList] Flip RadixTree key order (PR #164544)
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/164544 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [SpecialCaseList] Flip RadixTree key order (PR #164544)
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/164544 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] RuntimeLibcalls: Split lowering decisions into LibcallLoweringInfo (PR #164987)
@@ -193,6 +193,58 @@ struct MemOp {
}
};
+class LibcallLoweringInfo {
+private:
+ LLVM_ABI const RTLIB::RuntimeLibcallsInfo &RTLCI;
+ /// Stores the implementation choice for each each libcall.
+ LLVM_ABI RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {
+ RTLIB::Unsupported};
+
+public:
+ LLVM_ABI LibcallLoweringInfo(const RTLIB::RuntimeLibcallsInfo &RTLCI);
+
+ /// Get the libcall routine name for the specified libcall.
+ // FIXME: This should be removed. Only LibcallImpl should have a name.
+ LLVM_ABI const char *getLibcallName(RTLIB::Libcall Call) const {
+// FIXME: Return StringRef
arsenm wrote:
No, just more churn that's unrelated to this patch
https://github.com/llvm/llvm-project/pull/164987
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] RuntimeLibcalls: Split lowering decisions into LibcallLoweringInfo (PR #164987)
@@ -193,6 +193,58 @@ struct MemOp {
}
};
+class LibcallLoweringInfo {
+private:
+ LLVM_ABI const RTLIB::RuntimeLibcallsInfo &RTLCI;
+ /// Stores the implementation choice for each each libcall.
+ LLVM_ABI RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {
+ RTLIB::Unsupported};
+
+public:
+ LLVM_ABI LibcallLoweringInfo(const RTLIB::RuntimeLibcallsInfo &RTLCI);
+
+ /// Get the libcall routine name for the specified libcall.
+ // FIXME: This should be removed. Only LibcallImpl should have a name.
+ LLVM_ABI const char *getLibcallName(RTLIB::Libcall Call) const {
+// FIXME: Return StringRef
arsenm wrote:
But the main issue is all the places relying on null checks of this. It's more
a matter of migrating to direct supported checks instead of string based logic
https://github.com/llvm/llvm-project/pull/164987
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] RuntimeLibcalls: Split lowering decisions into LibcallLoweringInfo (PR #164987)
@@ -193,6 +193,58 @@ struct MemOp {
}
};
+class LibcallLoweringInfo {
+private:
+ LLVM_ABI const RTLIB::RuntimeLibcallsInfo &RTLCI;
+ /// Stores the implementation choice for each each libcall.
+ LLVM_ABI RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {
+ RTLIB::Unsupported};
+
+public:
+ LLVM_ABI LibcallLoweringInfo(const RTLIB::RuntimeLibcallsInfo &RTLCI);
+
+ /// Get the libcall routine name for the specified libcall.
+ // FIXME: This should be removed. Only LibcallImpl should have a name.
+ LLVM_ABI const char *getLibcallName(RTLIB::Libcall Call) const {
+// FIXME: Return StringRef
+return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(LibcallImpls[Call])
+.data();
+ }
+
+ /// Return the lowering's selection of implementation call for \p Call
+ LLVM_ABI RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const {
+return LibcallImpls[Call];
+ }
+
+ /// Rename the default libcall routine name for the specified libcall.
+ LLVM_ABI void setLibcallImpl(RTLIB::Libcall Call, RTLIB::LibcallImpl Impl) {
+LibcallImpls[Call] = Impl;
+ }
+
+ // FIXME: Remove this wrapper in favor of directly using
+ // getLibcallImplCallingConv
+ LLVM_ABI CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const {
+return RTLCI.LibcallImplCallingConvs[LibcallImpls[Call]];
+ }
+
+ /// Get the CallingConv that should be used for the specified libcall.
+ LLVM_ABI CallingConv::ID
+ getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const {
+return RTLCI.LibcallImplCallingConvs[Call];
+ }
+
+ /// Return a function name compatible with RTLIB::MEMCPY, or nullptr if fully
+ /// unsupported.
+ LLVM_ABI StringRef getMemcpyName() const {
+RTLIB::LibcallImpl Memcpy = getLibcallImpl(RTLIB::MEMCPY);
+if (Memcpy != RTLIB::Unsupported)
+ return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(Memcpy);
+
+// Fallback to memmove if memcpy isn't available.
+return getLibcallName(RTLIB::MEMMOVE);
arsenm wrote:
This was just a code move
https://github.com/llvm/llvm-project/pull/164987
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] RuntimeLibcalls: Split lowering decisions into LibcallLoweringInfo (PR #164987)
@@ -193,6 +193,58 @@ struct MemOp {
}
};
+class LibcallLoweringInfo {
+private:
+ LLVM_ABI const RTLIB::RuntimeLibcallsInfo &RTLCI;
+ /// Stores the implementation choice for each each libcall.
+ LLVM_ABI RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {
+ RTLIB::Unsupported};
+
+public:
+ LLVM_ABI LibcallLoweringInfo(const RTLIB::RuntimeLibcallsInfo &RTLCI);
+
+ /// Get the libcall routine name for the specified libcall.
+ // FIXME: This should be removed. Only LibcallImpl should have a name.
+ LLVM_ABI const char *getLibcallName(RTLIB::Libcall Call) const {
+// FIXME: Return StringRef
+return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(LibcallImpls[Call])
+.data();
+ }
+
+ /// Return the lowering's selection of implementation call for \p Call
+ LLVM_ABI RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const {
+return LibcallImpls[Call];
+ }
+
+ /// Rename the default libcall routine name for the specified libcall.
+ LLVM_ABI void setLibcallImpl(RTLIB::Libcall Call, RTLIB::LibcallImpl Impl) {
+LibcallImpls[Call] = Impl;
+ }
+
+ // FIXME: Remove this wrapper in favor of directly using
+ // getLibcallImplCallingConv
+ LLVM_ABI CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const {
+return RTLCI.LibcallImplCallingConvs[LibcallImpls[Call]];
arsenm wrote:
This is moving code, I don't want to mix other style changes in
https://github.com/llvm/llvm-project/pull/164987
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [SpecialCaseList] Add RadixTree for substring matching (PR #164545)
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/164545 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [SpecialCaseList] Add RadixTree for substring matching (PR #164545)
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/164545 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [X86][NewPM] Port lower-amx-intrinsics to NewPM (PR #165113)
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/165113 None ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [X86][NewPM] Port lower-amx-intrinsics to NewPM (PR #165113)
llvmbot wrote:
@llvm/pr-subscribers-backend-x86
Author: Aiden Grossman (boomanaiden154)
Changes
---
Full diff: https://github.com/llvm/llvm-project/pull/165113.diff
6 Files Affected:
- (modified) llvm/lib/Target/X86/X86.h (+12-1)
- (modified) llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp (+42-10)
- (modified) llvm/lib/Target/X86/X86PassRegistry.def (+1-1)
- (modified) llvm/lib/Target/X86/X86TargetMachine.cpp (+1-1)
- (modified) llvm/test/CodeGen/X86/AMX/amx-low-intrinsics-no-amx-bitcast.ll
(+2-1)
- (modified) llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll (+2-1)
``diff
diff --git a/llvm/lib/Target/X86/X86.h b/llvm/lib/Target/X86/X86.h
index 51b540a7a51d0..bdb43cfb4adb4 100644
--- a/llvm/lib/Target/X86/X86.h
+++ b/llvm/lib/Target/X86/X86.h
@@ -179,7 +179,18 @@ FunctionPass *createX86LowerAMXTypeLegacyPass();
/// The pass transforms amx intrinsics to scalar operation if the function has
/// optnone attribute or it is O0.
-FunctionPass *createX86LowerAMXIntrinsicsPass();
+class X86LowerAMXIntrinsicsPass
+: public PassInfoMixin {
+private:
+ const TargetMachine *TM;
+
+public:
+ X86LowerAMXIntrinsicsPass(const TargetMachine *TM) : TM(TM) {}
+ PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
+ static bool isRequired() { return true; }
+};
+
+FunctionPass *createX86LowerAMXIntrinsicsLegacyPass();
InstructionSelector *createX86InstructionSelector(const X86TargetMachine &TM,
const X86Subtarget &,
diff --git a/llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
b/llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
index 7f3393910da2c..38165736fde9a 100644
--- a/llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
+++ b/llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
@@ -23,12 +23,15 @@
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/CodeGen/ValueTypes.h"
+#include "llvm/IR/Analysis.h"
#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/IntrinsicsX86.h"
+#include "llvm/IR/PassManager.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
@@ -40,7 +43,7 @@
using namespace llvm;
using namespace PatternMatch;
-#define DEBUG_TYPE "lower-amx-intrinsics"
+#define DEBUG_TYPE "x86-lower-amx-intrinsics"
#ifndef NDEBUG
static bool isV256I32Ty(Type *Ty) {
@@ -626,6 +629,41 @@ bool X86LowerAMXIntrinsics::visit() {
return C;
}
+namespace {
+bool shouldRunLowerAMXIntrinsics(Function &F, const TargetMachine *TM) {
+ if (!X86ScalarizeAMX)
+return false;
+ if (!F.hasFnAttribute(Attribute::OptimizeNone) &&
+ TM->getOptLevel() != CodeGenOptLevel::None)
+return false;
+ return true;
+}
+
+bool runLowerAMXIntrinsics(Function &F, DominatorTree *DT, LoopInfo *LI) {
+ DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
+
+ X86LowerAMXIntrinsics LAT(F, DTU, LI);
+ return LAT.visit();
+}
+} // namespace
+
+PreservedAnalyses X86LowerAMXIntrinsicsPass::run(Function &F,
+ FunctionAnalysisManager &FAM)
{
+ if (!shouldRunLowerAMXIntrinsics(F, TM))
+return PreservedAnalyses::all();
+
+ DominatorTree &DT = FAM.getResult(F);
+ LoopInfo &LI = FAM.getResult(F);
+ bool Changed = runLowerAMXIntrinsics(F, &DT, &LI);
+ if (!Changed)
+return PreservedAnalyses::all();
+
+ PreservedAnalyses PA = PreservedAnalyses::none();
+ PA.preserve();
+ PA.preserve();
+ return PA;
+}
+
namespace {
class X86LowerAMXIntrinsicsLegacyPass : public FunctionPass {
public:
@@ -634,21 +672,15 @@ class X86LowerAMXIntrinsicsLegacyPass : public
FunctionPass {
X86LowerAMXIntrinsicsLegacyPass() : FunctionPass(ID) {}
bool runOnFunction(Function &F) override {
-if (!X86ScalarizeAMX)
- return false;
TargetMachine *TM =
&getAnalysis().getTM();
-if (!F.hasFnAttribute(Attribute::OptimizeNone) &&
-TM->getOptLevel() != CodeGenOptLevel::None)
+if (!shouldRunLowerAMXIntrinsics(F, TM))
return false;
auto *DTWP = getAnalysisIfAvailable();
auto *DT = DTWP ? &DTWP->getDomTree() : nullptr;
auto *LIWP = getAnalysisIfAvailable();
auto *LI = LIWP ? &LIWP->getLoopInfo() : nullptr;
-DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
-
-X86LowerAMXIntrinsics LAT(F, DTU, LI);
-return LAT.visit();
+return runLowerAMXIntrinsics(F, DT, LI);
}
StringRef getPassName() const override { return "Lower AMX intrinsics"; }
@@ -668,6 +700,6 @@ INITIALIZE_PASS_DEPENDENCY(TargetPassConfig)
INITIALIZE_PASS_END(X86LowerAMXIntrinsicsLegacyPass, DEBUG_TYPE, PassName,
false, false)
-FunctionPass *llvm::createX86LowerAMXIntrinsicsPass() {
+FunctionPass *llvm::createX86LowerAMXIntrinsicsLegacyPass() {
return new X86LowerAMXIntrinsicsLegacyPass
