[llvm-branch-commits] [llvm] 0826716 - [Mips] support "sp" named register
Author: Nick Desaulniers
Date: 2022-03-04T23:40:41-08:00
New Revision: 0826716786cd4a8c7cbcb8c01e4d9fac46b7a17a
URL:
https://github.com/llvm/llvm-project/commit/0826716786cd4a8c7cbcb8c01e4d9fac46b7a17a
DIFF:
https://github.com/llvm/llvm-project/commit/0826716786cd4a8c7cbcb8c01e4d9fac46b7a17a.diff
LOG: [Mips] support "sp" named register
After Linux kernel commit
commit 200ed341b864 ("mips: Implement "current_stack_pointer"")
We observe the following build error when compiling the Linux kernel
targeting Mips:
fatal error: error in backend: Invalid register name global variable
Fixes: https://github.com/llvm/llvm-project/issues/54174
Link: https://github.com/ClangBuiltLinux/linux/issues/1608
Reviewed By: atanasyan
Differential Revision: https://reviews.llvm.org/D120926
(cherry picked from commit e0adc3be132922776a867a623959e176f29f9965)
Added:
Modified:
llvm/lib/Target/Mips/MipsISelLowering.cpp
llvm/test/CodeGen/Mips/named-register-n32.ll
llvm/test/CodeGen/Mips/named-register-n64.ll
llvm/test/CodeGen/Mips/named-register-o32.ll
Removed:
diff --git a/llvm/lib/Target/Mips/MipsISelLowering.cpp
b/llvm/lib/Target/Mips/MipsISelLowering.cpp
index 0c2e129b8f1fc..8534a0ad886ec 100644
--- a/llvm/lib/Target/Mips/MipsISelLowering.cpp
+++ b/llvm/lib/Target/Mips/MipsISelLowering.cpp
@@ -4732,18 +4732,19 @@ MipsTargetLowering::emitPseudoD_SELECT(MachineInstr &MI,
Register
MipsTargetLowering::getRegisterByName(const char *RegName, LLT VT,
const MachineFunction &MF) const {
- // Named registers is expected to be fairly rare. For now, just support $28
- // since the linux kernel uses it.
+ // The Linux kernel uses $28 and sp.
if (Subtarget.isGP64bit()) {
Register Reg = StringSwitch(RegName)
- .Case("$28", Mips::GP_64)
- .Default(Register());
+ .Case("$28", Mips::GP_64)
+ .Case("sp", Mips::SP_64)
+ .Default(Register());
if (Reg)
return Reg;
} else {
Register Reg = StringSwitch(RegName)
- .Case("$28", Mips::GP)
- .Default(Register());
+ .Case("$28", Mips::GP)
+ .Case("sp", Mips::SP)
+ .Default(Register());
if (Reg)
return Reg;
}
diff --git a/llvm/test/CodeGen/Mips/named-register-n32.ll
b/llvm/test/CodeGen/Mips/named-register-n32.ll
index 5074438255ba7..112e04e14b2ac 100644
--- a/llvm/test/CodeGen/Mips/named-register-n32.ll
+++ b/llvm/test/CodeGen/Mips/named-register-n32.ll
@@ -1,18 +1,29 @@
-; RUN: llc -mtriple=mips64 -relocation-model=static -mattr=+noabicalls
-target-abi n32 < %s | FileCheck %s
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=mips64 -relocation-model=static -mattr=+noabicalls \
+; RUN: -target-abi n32 < %s | FileCheck %s
-define i32* @get_gp() {
-entry:
- %0 = call i64 @llvm.read_register.i64(metadata !0)
- %1 = trunc i64 %0 to i32
- %2 = inttoptr i32 %1 to i32*
- ret i32* %2
-}
+declare i64 @llvm.read_register.i64(metadata)
+define i64 @get_gp() {
; CHECK-LABEL: get_gp:
-; CHECK: sll $2, $gp, 0
+; CHECK: # %bb.0:
+; CHECK-NEXT:jr $ra
+; CHECK-NEXT:move $2, $gp
+ %1 = call i64 @llvm.read_register.i64(metadata !0)
+ ret i64 %1
+}
-declare i64 @llvm.read_register.i64(metadata)
+define i64 @get_sp() {
+; CHECK-LABEL: get_sp:
+; CHECK: # %bb.0:
+; CHECK-NEXT:jr $ra
+; CHECK-NEXT:move $2, $sp
+ %1 = call i64 @llvm.read_register.i64(metadata !1)
+ ret i64 %1
+}
!llvm.named.register.$28 = !{!0}
+!llvm.named.register.sp = !{!1}
!0 = !{!"$28"}
+!1 = !{!"sp"}
diff --git a/llvm/test/CodeGen/Mips/named-register-n64.ll
b/llvm/test/CodeGen/Mips/named-register-n64.ll
index c771b2b1d0b57..42d9ba1e1f15c 100644
--- a/llvm/test/CodeGen/Mips/named-register-n64.ll
+++ b/llvm/test/CodeGen/Mips/named-register-n64.ll
@@ -1,17 +1,29 @@
-; RUN: llc -mtriple=mips64 -relocation-model=static -mattr=+noabicalls < %s |
FileCheck %s
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=mips64 -relocation-model=static -mattr=+noabicalls \
+; RUN: < %s | FileCheck %s
-define i32* @get_gp() {
-entry:
- %0 = call i64 @llvm.read_register.i64(metadata !0)
- %1 = inttoptr i64 %0 to i32*
- ret i32* %1
-}
+declare i64 @llvm.read_register.i64(metadata)
+define i64 @get_gp() {
; CHECK-LABEL: get_gp:
-; CHECK: move $2, $gp
+; CHECK: # %bb.0:
+; CHECK-NEXT:jr $ra
+; CHECK-NEXT:move $2, $gp
+ %1 = call i64 @llvm.read_register.i64(metadata !0)
+ ret i64 %1
+}
-declare i64 @llvm.read_register.i64(metadata)
+define i64 @get_sp() {
+; CHECK-LABEL: get_sp:
+; CHECK: # %bb.0:
+; CHECK-NEXT:jr $ra
+; CHECK-NEXT:move
[llvm-branch-commits] [llvm] 1e3d5cc - Add cmake to source release tarballs
Author: Konrad Kleine
Date: 2022-03-04T23:43:45-08:00
New Revision: 1e3d5ccab6b616baa91448462951b43f28bd5601
URL:
https://github.com/llvm/llvm-project/commit/1e3d5ccab6b616baa91448462951b43f28bd5601
DIFF:
https://github.com/llvm/llvm-project/commit/1e3d5ccab6b616baa91448462951b43f28bd5601.diff
LOG: Add cmake to source release tarballs
I've split the git archive generation into three steps:
1. generate pure tarball
2. append top-level cmake directory to all tarballs
3. compress the archive
This was inspired by D118252 and can be considered an alternative
approach for all projects to have access to the shared cmake
directory when building in standalone mode.
When generating source tarballs on my local laptop it takes 9 minutes and 45
seconds WITH this patch applied. When this patch is not applied, it takes
9minutes and 38 seconds. That means, this patch introduces a slowdown of 7
seconds, which seems fair.
Reviewed By: tstellar
Differential Revision: https://reviews.llvm.org/D118481
Added:
Modified:
llvm/utils/release/export.sh
Removed:
diff --git a/llvm/utils/release/export.sh b/llvm/utils/release/export.sh
index 3a318aee10d3d..43bb71d09bea8 100755
--- a/llvm/utils/release/export.sh
+++ b/llvm/utils/release/export.sh
@@ -131,7 +131,14 @@ export_sources() {
for proj in $projects; do
echo "Creating tarball for $proj ..."
pushd $llvm_src_dir/$proj
-git archive --prefix=$proj-$release$rc.src/ $tree_id . | xz
>$target_dir/$(template_file $proj)
+target_archive_file=$target_dir/$(template_file $proj)
+trap "rm -fv $target_archive_file.tmp" EXIT
+git archive --prefix=$proj-$release$rc.src/ -o
$target_archive_file.tmp $tree_id .
+# Get relative path to top-level cmake directory to be packaged
+# alongside the project. Append that path to the tarball.
+cmake_rel_path=$(realpath --relative-to=. $llvm_src_dir/cmake)
+tar --append -f $target_archive_file.tmp $cmake_rel_path
+cat $target_archive_file.tmp | xz > $target_archive_file
popd
done
}
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 0205cc0 - [OpenMP][FIX] Ensure custom state machine works
Author: Johannes Doerfert
Date: 2022-03-04T23:41:16-08:00
New Revision: 0205cc086e506fe85fdc48734e9a297299160eb1
URL:
https://github.com/llvm/llvm-project/commit/0205cc086e506fe85fdc48734e9a297299160eb1
DIFF:
https://github.com/llvm/llvm-project/commit/0205cc086e506fe85fdc48734e9a297299160eb1.diff
LOG: [OpenMP][FIX] Ensure custom state machine works
The custom state machine had a check for surplus threads that filtered
the main thread if the kernel was executed by a single warp only. We
now first check for the main thread, then for surplus threads, avoiding
to filter the former out.
Fixes #54214.
Reviewed By: jhuber6
Differential Revision: https://reviews.llvm.org/D121011
(cherry picked from commit f9c2d6005ef06a37a99e324e72ce247d0472cf4e)
Added:
Modified:
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/test/Transforms/OpenMP/custom_state_machines.ll
llvm/test/Transforms/OpenMP/spmdization.ll
llvm/test/Transforms/OpenMP/spmdization_guarding.ll
llvm/test/Transforms/OpenMP/spmdization_guarding_two_reaching_kernels.ll
Removed:
diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 5113c0c67acc6..7205ae178d21f 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -3712,9 +3712,9 @@ struct AAKernelInfoFunction : AAKernelInfo {
// __kmpc_get_hardware_num_threads_in_block();
// WarpSize = __kmpc_get_warp_size();
// BlockSize = BlockHwSize - WarpSize;
-// if (InitCB >= BlockSize) return;
-// IsWorkerCheckBB: bool IsWorker = InitCB >= 0;
+// IsWorkerCheckBB: bool IsWorker = InitCB != -1;
// if (IsWorker) {
+// if (InitCB >= BlockSize) return;
// SMBeginBB: __kmpc_barrier_simple_generic(...);
// void *WorkFn;
// bool Active = __kmpc_kernel_parallel(&WorkFn);
@@ -3771,6 +3771,13 @@ struct AAKernelInfoFunction : AAKernelInfo {
ReturnInst::Create(Ctx, StateMachineFinishedBB)->setDebugLoc(DLoc);
InitBB->getTerminator()->eraseFromParent();
+Instruction *IsWorker =
+ICmpInst::Create(ICmpInst::ICmp, llvm::CmpInst::ICMP_NE, KernelInitCB,
+ ConstantInt::get(KernelInitCB->getType(), -1),
+ "thread.is_worker", InitBB);
+IsWorker->setDebugLoc(DLoc);
+BranchInst::Create(IsWorkerCheckBB, UserCodeEntryBB, IsWorker, InitBB);
+
Module &M = *Kernel->getParent();
auto &OMPInfoCache = static_cast(A.getInfoCache());
FunctionCallee BlockHwSizeFn =
@@ -3780,29 +3787,22 @@ struct AAKernelInfoFunction : AAKernelInfo {
OMPInfoCache.OMPBuilder.getOrCreateRuntimeFunction(
M, OMPRTL___kmpc_get_warp_size);
CallInst *BlockHwSize =
-CallInst::Create(BlockHwSizeFn, "block.hw_size", InitBB);
+CallInst::Create(BlockHwSizeFn, "block.hw_size", IsWorkerCheckBB);
OMPInfoCache.setCallingConvention(BlockHwSizeFn, BlockHwSize);
BlockHwSize->setDebugLoc(DLoc);
-CallInst *WarpSize = CallInst::Create(WarpSizeFn, "warp.size", InitBB);
+CallInst *WarpSize =
+CallInst::Create(WarpSizeFn, "warp.size", IsWorkerCheckBB);
OMPInfoCache.setCallingConvention(WarpSizeFn, WarpSize);
WarpSize->setDebugLoc(DLoc);
-Instruction *BlockSize =
-BinaryOperator::CreateSub(BlockHwSize, WarpSize, "block.size", InitBB);
+Instruction *BlockSize = BinaryOperator::CreateSub(
+BlockHwSize, WarpSize, "block.size", IsWorkerCheckBB);
BlockSize->setDebugLoc(DLoc);
-Instruction *IsMainOrWorker =
-ICmpInst::Create(ICmpInst::ICmp, llvm::CmpInst::ICMP_SLT, KernelInitCB,
- BlockSize, "thread.is_main_or_worker", InitBB);
+Instruction *IsMainOrWorker = ICmpInst::Create(
+ICmpInst::ICmp, llvm::CmpInst::ICMP_SLT, KernelInitCB, BlockSize,
+"thread.is_main_or_worker", IsWorkerCheckBB);
IsMainOrWorker->setDebugLoc(DLoc);
-BranchInst::Create(IsWorkerCheckBB, StateMachineFinishedBB, IsMainOrWorker,
- InitBB);
-
-Instruction *IsWorker =
-ICmpInst::Create(ICmpInst::ICmp, llvm::CmpInst::ICMP_NE, KernelInitCB,
- ConstantInt::get(KernelInitCB->getType(), -1),
- "thread.is_worker", IsWorkerCheckBB);
-IsWorker->setDebugLoc(DLoc);
-BranchInst::Create(StateMachineBeginBB, UserCodeEntryBB, IsWorker,
- IsWorkerCheckBB);
+BranchInst::Create(StateMachineBeginBB, StateMachineFinishedBB,
+ IsMainOrWorker, IsWorkerCheckBB);
// Create local storage for the work function pointer.
const DataLayout &DL = M.getDataLayout();
diff --git a/llvm/test/Trans
