Skip to content

Commit a3c88f8

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into inferas_for_spirv
2 parents a707363 + 700d9ac commit a3c88f8

File tree

15 files changed

+1613
-23
lines changed

15 files changed

+1613
-23
lines changed

libc/config/linux/riscv/entrypoints.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ set(TARGET_LIBC_ENTRYPOINTS
251251
libc.src.sys.mman.munmap
252252
libc.src.sys.mman.remap_file_pages
253253
libc.src.sys.mman.posix_madvise
254-
libc.src.sys.mman.process_mrelease
254+
# TODO: disabled due to buildbot failure. further investigation needed.
255+
# libc.src.sys.mman.process_mrelease
255256
libc.src.sys.mman.shm_open
256257
libc.src.sys.mman.shm_unlink
257258

libc/src/sys/mman/linux/process_mrelease.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
namespace LIBC_NAMESPACE_DECL {
2020

2121
LLVM_LIBC_FUNCTION(int, process_mrelease, (int pidfd, unsigned int flags)) {
22+
#ifdef SYS_process_mrelease
2223
long ret =
2324
LIBC_NAMESPACE::syscall_impl<int>(SYS_process_mrelease, pidfd, flags);
2425

@@ -28,6 +29,13 @@ LLVM_LIBC_FUNCTION(int, process_mrelease, (int pidfd, unsigned int flags)) {
2829
}
2930

3031
return 0;
32+
#else
33+
// The system call is not available.
34+
(void)pidfd;
35+
(void)flags;
36+
libc_errno = ENOSYS;
37+
return -1;
38+
#endif
3139
}
3240

3341
} // namespace LIBC_NAMESPACE_DECL

libc/test/src/sys/mman/linux/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ add_libc_unittest(
197197
libc.src.signal.kill
198198
libc.include.signal
199199
libc.src.stdlib.exit
200+
libc.src.signal.raise
200201
libc.src.__support.OSUtil.osutil
201202
libc.src.__support.threads.sleep
202203
libc.test.UnitTest.ErrnoSetterMatcher

libc/test/src/sys/mman/linux/process_mrelease_test.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
10-
#include "src/__support/threads/sleep.h"
1110
#include "src/errno/libc_errno.h"
1211
#include "src/signal/kill.h"
12+
#include "src/signal/raise.h"
1313
#include "src/stdlib/exit.h"
1414
#include "src/sys/mman/process_mrelease.h"
1515
#include "src/unistd/close.h"
@@ -18,7 +18,7 @@
1818
#include "test/UnitTest/LibcTest.h"
1919

2020
#include <sys/syscall.h>
21-
21+
#if defined(SYS_process_mrelease) && defined(SYS_pidfd_open)
2222
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
2323

2424
int pidfd_open(pid_t pid, unsigned int flags) {
@@ -30,13 +30,11 @@ TEST(LlvmLibcProcessMReleaseTest, NoError) {
3030
EXPECT_GE(child_pid, 0);
3131

3232
if (child_pid == 0) {
33-
// Child process: wait a bit then exit gracefully.
34-
LIBC_NAMESPACE::sleep_briefly();
35-
LIBC_NAMESPACE::exit(0);
33+
// pause the child process
34+
LIBC_NAMESPACE::raise(SIGSTOP);
3635
} else {
3736
// Parent process: wait a bit and then kill the child.
3837
// Give child process some time to start.
39-
LIBC_NAMESPACE::sleep_briefly();
4038
int pidfd = pidfd_open(child_pid, 0);
4139
EXPECT_GE(pidfd, 0);
4240

@@ -54,12 +52,9 @@ TEST(LlvmLibcProcessMReleaseTest, ErrorNotKilled) {
5452
EXPECT_GE(child_pid, 0);
5553

5654
if (child_pid == 0) {
57-
// Child process: wait a bit then exit gracefully.
58-
LIBC_NAMESPACE::sleep_briefly();
59-
LIBC_NAMESPACE::exit(0);
55+
// pause the child process
56+
LIBC_NAMESPACE::raise(SIGSTOP);
6057
} else {
61-
// Give child process some time to start.
62-
LIBC_NAMESPACE::sleep_briefly();
6358
int pidfd = pidfd_open(child_pid, 0);
6459
EXPECT_GE(pidfd, 0);
6560

@@ -72,3 +67,4 @@ TEST(LlvmLibcProcessMReleaseTest, ErrorNotKilled) {
7267
TEST(LlvmLibcProcessMReleaseTest, ErrorNonExistingPidfd) {
7368
EXPECT_THAT(LIBC_NAMESPACE::process_mrelease(-1, 0), Fails(EBADF));
7469
}
70+
#endif

llvm/lib/Analysis/VectorUtils.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,13 @@ bool llvm::isVectorIntrinsicWithScalarOpAtArg(Intrinsic::ID ID,
118118
unsigned ScalarOpdIdx) {
119119
switch (ID) {
120120
case Intrinsic::abs:
121+
case Intrinsic::vp_abs:
121122
case Intrinsic::ctlz:
123+
case Intrinsic::vp_ctlz:
122124
case Intrinsic::cttz:
125+
case Intrinsic::vp_cttz:
123126
case Intrinsic::is_fpclass:
127+
case Intrinsic::vp_is_fpclass:
124128
case Intrinsic::powi:
125129
return (ScalarOpdIdx == 1);
126130
case Intrinsic::smul_fix:
@@ -145,10 +149,13 @@ bool llvm::isVectorIntrinsicWithOverloadTypeAtArg(
145149
case Intrinsic::fptoui_sat:
146150
case Intrinsic::lrint:
147151
case Intrinsic::llrint:
152+
case Intrinsic::vp_lrint:
153+
case Intrinsic::vp_llrint:
148154
case Intrinsic::ucmp:
149155
case Intrinsic::scmp:
150156
return OpdIdx == -1 || OpdIdx == 0;
151157
case Intrinsic::is_fpclass:
158+
case Intrinsic::vp_is_fpclass:
152159
return OpdIdx == 0;
153160
case Intrinsic::powi:
154161
return OpdIdx == -1 || OpdIdx == 1;

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,15 @@ InstructionCost VPWidenIntrinsicRecipe::computeCost(ElementCount VF,
993993
for (const auto &[Idx, Op] : enumerate(operands())) {
994994
auto *V = Op->getUnderlyingValue();
995995
if (!V) {
996+
// Push all the VP Intrinsic's ops into the Argments even if is nullptr.
997+
// Some VP Intrinsic's cost will assert the number of parameters.
998+
// Mainly appears in the following two scenarios:
999+
// 1. EVL Op is nullptr
1000+
// 2. The Argmunt of the VP Intrinsic is also the VP Intrinsic
1001+
if (VPIntrinsic::isVPIntrinsic(VectorIntrinsicID)) {
1002+
Arguments.push_back(V);
1003+
continue;
1004+
}
9961005
if (auto *UI = dyn_cast_or_null<CallBase>(getUnderlyingValue())) {
9971006
Arguments.push_back(UI->getArgOperand(Idx));
9981007
continue;

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,26 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
14811481
VPValue *NewMask = GetNewMask(Red->getCondOp());
14821482
return new VPReductionEVLRecipe(*Red, EVL, NewMask);
14831483
})
1484+
.Case<VPWidenIntrinsicRecipe>(
1485+
[&](VPWidenIntrinsicRecipe *CInst) -> VPRecipeBase * {
1486+
auto *CI = cast<CallInst>(CInst->getUnderlyingInstr());
1487+
Intrinsic::ID VPID = VPIntrinsic::getForIntrinsic(
1488+
CI->getCalledFunction()->getIntrinsicID());
1489+
if (VPID == Intrinsic::not_intrinsic)
1490+
return nullptr;
1491+
1492+
SmallVector<VPValue *> Ops(CInst->operands());
1493+
assert(VPIntrinsic::getMaskParamPos(VPID) &&
1494+
VPIntrinsic::getVectorLengthParamPos(VPID) &&
1495+
"Expected VP intrinsic");
1496+
VPValue *Mask = Plan.getOrAddLiveIn(ConstantInt::getTrue(
1497+
IntegerType::getInt1Ty(CI->getContext())));
1498+
Ops.push_back(Mask);
1499+
Ops.push_back(&EVL);
1500+
return new VPWidenIntrinsicRecipe(
1501+
*CI, VPID, Ops, TypeInfo.inferScalarType(CInst),
1502+
CInst->getDebugLoc());
1503+
})
14841504
.Case<VPWidenSelectRecipe>([&](VPWidenSelectRecipe *Sel) {
14851505
SmallVector<VPValue *> Ops(Sel->operands());
14861506
Ops.push_back(&EVL);

0 commit comments

Comments
 (0)