Skip to content

Commit 0bb3d2d

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:63a9662f6cc41658f36ccddfb565d3dc5ad0135f into amd-gfx:b4e97c5e1144
Local branch amd-gfx b4e97c5 Merged main:a1d73ace13a20ed122a66d3d59f0cbae58d0f669 into amd-gfx:df3bf34a3c95 Remote branch main 63a9662 [libc] Fix readlink tests on 32-bit systems (llvm#98168)
2 parents b4e97c5 + 63a9662 commit 0bb3d2d

File tree

16 files changed

+687
-1081
lines changed

16 files changed

+687
-1081
lines changed

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 83 additions & 915 deletions
Large diffs are not rendered by default.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// REQUIRES: aarch64-registered-target
2+
// RUN: %clang_cc1 -triple arm64-apple-ios -S -o - %s | FileCheck %s
3+
4+
// CHECK: _restartable_function:
5+
// CHECK-NEXT: ldr x11, [x0]
6+
// CHECK-NEXT: add x11, x11, #1
7+
// CHECK-NEXT: str x11, [x0]
8+
// CHECK-NEXT: Ltmp0:
9+
// CHECK-NEXT: b Ltmp0
10+
// CHECK-NEXT: LExit_restartable_function:
11+
// CHECK-NEXT: ret
12+
asm(".align 4\n"
13+
" .text\n"
14+
" .private_extern _restartable_function\n"
15+
"_restartable_function:\n"
16+
" ldr x11, [x0]\n"
17+
" add x11, x11, #1\n"
18+
" str x11, [x0]\n"
19+
"1:\n"
20+
" b 1b\n"
21+
"LExit_restartable_function:\n"
22+
" ret\n"
23+
);

compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ set(ALL_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64}
3232
${LOONGARCH64})
3333
set(ALL_ASAN_ABI_SUPPORTED_ARCH ${X86_64} ${ARM64} ${ARM64_32})
3434
set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${LOONGARCH64})
35-
set(ALL_RTSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64}
36-
${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
37-
${LOONGARCH64})
35+
#set(ALL_RTSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64}
36+
# ${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
37+
# ${LOONGARCH64})
3838

3939
if(ANDROID)
4040
set(OS_NAME "Android")

libc/test/src/unistd/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ add_libc_unittest(
262262
libc.include.unistd
263263
libc.src.errno.errno
264264
libc.src.unistd.readlink
265+
libc.src.string.string_utils
265266
libc.src.unistd.symlink
266267
libc.src.unistd.unlink
267268
libc.src.__support.CPP.string_view
@@ -279,6 +280,7 @@ add_libc_unittest(
279280
libc.include.unistd
280281
libc.src.errno.errno
281282
libc.src.unistd.readlinkat
283+
libc.src.string.string_utils
282284
libc.src.unistd.symlink
283285
libc.src.unistd.unlink
284286
libc.src.__support.CPP.string_view

libc/test/src/unistd/readlink_test.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "src/__support/CPP/string_view.h"
1010
#include "src/errno/libc_errno.h"
11+
#include "src/string/string_utils.h"
1112
#include "src/unistd/readlink.h"
1213
#include "src/unistd/symlink.h"
1314
#include "src/unistd/unlink.h"
@@ -30,8 +31,9 @@ TEST(LlvmLibcReadlinkTest, CreateAndUnlink) {
3031
// 3. Cleanup the symlink created in step #1.
3132
ASSERT_THAT(LIBC_NAMESPACE::symlink(LINK_VAL, LINK), Succeeds(0));
3233

33-
char buf[sizeof(LINK_VAL)];
34-
ssize_t len = LIBC_NAMESPACE::readlink(LINK, buf, sizeof(buf));
34+
char buf[256];
35+
ssize_t len = LIBC_NAMESPACE::readlink(
36+
LINK, buf, LIBC_NAMESPACE::internal::string_length(FILENAME));
3537
ASSERT_ERRNO_SUCCESS();
3638
ASSERT_EQ(cpp::string_view(buf, len), cpp::string_view(LINK_VAL));
3739

@@ -40,7 +42,8 @@ TEST(LlvmLibcReadlinkTest, CreateAndUnlink) {
4042

4143
TEST(LlvmLibcReadlinkTest, ReadlinkInNonExistentPath) {
4244
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
43-
char buf[8];
44-
ASSERT_THAT(LIBC_NAMESPACE::readlink("non-existent-link", buf, sizeof(buf)),
45+
constexpr auto LEN = 8;
46+
char buf[LEN];
47+
ASSERT_THAT(LIBC_NAMESPACE::readlink("non-existent-link", buf, LEN),
4548
Fails(ENOENT));
4649
}

libc/test/src/unistd/readlinkat_test.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "src/__support/CPP/string_view.h"
1010
#include "src/errno/libc_errno.h"
11+
#include "src/string/string_utils.h"
1112
#include "src/unistd/readlinkat.h"
1213
#include "src/unistd/symlink.h"
1314
#include "src/unistd/unlink.h"
@@ -32,8 +33,9 @@ TEST(LlvmLibcReadlinkatTest, CreateAndUnlink) {
3233
// 3. Cleanup the symlink created in step #1.
3334
ASSERT_THAT(LIBC_NAMESPACE::symlink(LINK_VAL, LINK), Succeeds(0));
3435

35-
char buf[sizeof(LINK_VAL)];
36-
ssize_t len = LIBC_NAMESPACE::readlinkat(AT_FDCWD, LINK, buf, sizeof(buf));
36+
char buf[256];
37+
ssize_t len = LIBC_NAMESPACE::readlinkat(
38+
AT_FDCWD, LINK, buf, LIBC_NAMESPACE::internal::string_length(FILENAME));
3739
ASSERT_ERRNO_SUCCESS();
3840
ASSERT_EQ(cpp::string_view(buf, len), cpp::string_view(LINK_VAL));
3941

@@ -42,8 +44,9 @@ TEST(LlvmLibcReadlinkatTest, CreateAndUnlink) {
4244

4345
TEST(LlvmLibcReadlinkatTest, ReadlinkInNonExistentPath) {
4446
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
45-
char buf[8];
46-
ASSERT_THAT(LIBC_NAMESPACE::readlinkat(AT_FDCWD, "non-existent-link", buf,
47-
sizeof(buf)),
48-
Fails(ENOENT));
47+
constexpr auto LEN = 8;
48+
char buf[LEN];
49+
ASSERT_THAT(
50+
LIBC_NAMESPACE::readlinkat(AT_FDCWD, "non-existent-link", buf, LEN),
51+
Fails(ENOENT));
4952
}

libunwind/src/UnwindCursor.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,6 +2589,14 @@ void UnwindCursor<A, R>::setInfoBasedOnIPRegister(bool isReturnAddress) {
25892589
--pc;
25902590
#endif
25912591

2592+
#if !(defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && defined(_WIN32))
2593+
// In case of this is frame of signal handler, the IP saved in the signal
2594+
// handler points to first non-executed instruction, while FDE/CIE expects IP
2595+
// to be after the first non-executed instruction.
2596+
if (_isSignalFrame)
2597+
++pc;
2598+
#endif
2599+
25922600
// Ask address space object to find unwind sections for this pc.
25932601
UnwindInfoSections sects;
25942602
if (_addressSpace.findUnwindSections(pc, sects)) {

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 504363
19+
#define LLVM_MAIN_REVISION 504372
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/include/llvm/IR/IntrinsicInst.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,43 @@ class MinMaxIntrinsic : public IntrinsicInst {
834834
}
835835
};
836836

837+
/// This class represents a ucmp/scmp intrinsic
838+
class CmpIntrinsic : public IntrinsicInst {
839+
public:
840+
static bool classof(const IntrinsicInst *I) {
841+
switch (I->getIntrinsicID()) {
842+
case Intrinsic::scmp:
843+
case Intrinsic::ucmp:
844+
return true;
845+
default:
846+
return false;
847+
}
848+
}
849+
static bool classof(const Value *V) {
850+
return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
851+
}
852+
853+
Value *getLHS() const { return const_cast<Value *>(getArgOperand(0)); }
854+
Value *getRHS() const { return const_cast<Value *>(getArgOperand(1)); }
855+
856+
static bool isSigned(Intrinsic::ID ID) { return ID == Intrinsic::scmp; }
857+
bool isSigned() const { return isSigned(getIntrinsicID()); }
858+
859+
static CmpInst::Predicate getGTPredicate(Intrinsic::ID ID) {
860+
return isSigned(ID) ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT;
861+
}
862+
CmpInst::Predicate getGTPredicate() const {
863+
return getGTPredicate(getIntrinsicID());
864+
}
865+
866+
static CmpInst::Predicate getLTPredicate(Intrinsic::ID ID) {
867+
return isSigned(ID) ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT;
868+
}
869+
CmpInst::Predicate getLTPredicate() const {
870+
return getLTPredicate(getIntrinsicID());
871+
}
872+
};
873+
837874
/// This class represents an intrinsic that is based on a binary operation.
838875
/// This includes op.with.overflow and saturating add/sub intrinsics.
839876
class BinaryOpIntrinsic : public IntrinsicInst {

llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,16 @@ void AsmPrinter::emitInlineAsm(StringRef Str, const MCSubtargetInfo &STI,
113113
if (!TAP)
114114
report_fatal_error("Inline asm not supported by this streamer because"
115115
" we don't have an asm parser for this target\n");
116-
Parser->setAssemblerDialect(Dialect);
116+
117+
// Respect inlineasm dialect on X86 targets only
118+
if (TM.getTargetTriple().isX86()) {
119+
Parser->setAssemblerDialect(Dialect);
120+
// Enable lexing Masm binary and hex integer literals in intel inline
121+
// assembly.
122+
if (Dialect == InlineAsm::AD_Intel)
123+
Parser->getLexer().setLexMasmIntegers(true);
124+
}
117125
Parser->setTargetParser(*TAP);
118-
// Enable lexing Masm binary and hex integer literals in intel inline
119-
// assembly.
120-
if (Dialect == InlineAsm::AD_Intel)
121-
Parser->getLexer().setLexMasmIntegers(true);
122126

123127
emitInlineAsmStart();
124128
// Don't implicitly switch to the text section before the asm.

0 commit comments

Comments
 (0)