Skip to content

Commit

Permalink
Merged main:675231eb09ca into amd-gfx:a6e32de5b204
Browse files Browse the repository at this point in the history
Local branch amd-gfx a6e32de Merged main:7cd7b9533c77 into amd-gfx:78fd3d96689b
Remote branch main 675231e [SVE ACLE] Allow default zero initialisation for svcount_t. (llvm#69321)
  • Loading branch information
SC llvm team authored and SC llvm team committed Oct 18, 2023
2 parents a6e32de + 675231e commit b9f9dea
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 9 deletions.
9 changes: 5 additions & 4 deletions clang/lib/Index/USRGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "clang/Index/USRGeneration.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/DeclVisitor.h"
#include "clang/Basic/FileManager.h"
Expand Down Expand Up @@ -368,14 +369,14 @@ void USRGenerator::VisitTemplateTemplateParmDecl(
}

void USRGenerator::VisitNamespaceDecl(const NamespaceDecl *D) {
if (IgnoreResults)
return;
VisitDeclContext(D->getDeclContext());
if (D->isAnonymousNamespace()) {
Out << "@aN";
return;
}

VisitDeclContext(D->getDeclContext());
if (!IgnoreResults)
Out << "@N@" << D->getName();
Out << "@N@" << D->getName();
}

void USRGenerator::VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
Expand Down
18 changes: 18 additions & 0 deletions clang/test/CodeGenCXX/aarch64-sve-vector-init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
// CHECK-NEXT: [[B8:%.*]] = alloca <vscale x 16 x i1>, align 2
// CHECK-NEXT: [[B8X2:%.*]] = alloca <vscale x 32 x i1>, align 2
// CHECK-NEXT: [[B8X4:%.*]] = alloca <vscale x 64 x i1>, align 2
// CHECK-NEXT: [[CNT:%.*]] = alloca target("aarch64.svcount"), align 2
// CHECK-NEXT: store <vscale x 16 x i8> zeroinitializer, ptr [[S8]], align 16
// CHECK-NEXT: store <vscale x 8 x i16> zeroinitializer, ptr [[S16]], align 16
// CHECK-NEXT: store <vscale x 4 x i32> zeroinitializer, ptr [[S32]], align 16
Expand Down Expand Up @@ -106,6 +107,7 @@
// CHECK-NEXT: store <vscale x 16 x i1> zeroinitializer, ptr [[B8]], align 2
// CHECK-NEXT: store <vscale x 32 x i1> zeroinitializer, ptr [[B8X2]], align 2
// CHECK-NEXT: store <vscale x 64 x i1> zeroinitializer, ptr [[B8X4]], align 2
// CHECK-NEXT: store target("aarch64.svcount") zeroinitializer, ptr [[CNT]], align 2
// CHECK-NEXT: ret void
//
void test_locals(void) {
Expand Down Expand Up @@ -164,6 +166,8 @@ void test_locals(void) {
__SVBool_t b8{};
__clang_svboolx2_t b8x2{};
__clang_svboolx4_t b8x4{};

__SVCount_t cnt{};
}

// CHECK-LABEL: define dso_local void @_Z12test_copy_s8u10__SVInt8_t
Expand Down Expand Up @@ -879,3 +883,17 @@ void test_copy_b8x2(__clang_svboolx2_t a) {
void test_copy_b8x4(__clang_svboolx4_t a) {
__clang_svboolx4_t b{a};
}

// CHECK-LABEL: define dso_local void @_Z13test_copy_cntu11__SVCount_t
// CHECK-SAME: (target("aarch64.svcount") [[A:%.*]]) #[[ATTR0]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: [[A_ADDR:%.*]] = alloca target("aarch64.svcount"), align 2
// CHECK-NEXT: [[B:%.*]] = alloca target("aarch64.svcount"), align 2
// CHECK-NEXT: store target("aarch64.svcount") [[A]], ptr [[A_ADDR]], align 2
// CHECK-NEXT: [[TMP0:%.*]] = load target("aarch64.svcount"), ptr [[A_ADDR]], align 2
// CHECK-NEXT: store target("aarch64.svcount") [[TMP0]], ptr [[B]], align 2
// CHECK-NEXT: ret void
//
void test_copy_cnt(__SVCount_t a) {
__SVCount_t b{a};
}
14 changes: 14 additions & 0 deletions clang/test/Index/USR/decl-context.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: c-index-test core -print-source-symbols -- -std=c++20 %s | FileCheck %s

namespace ns {
namespace {
struct Foo {};
// CHECK: [[@LINE-1]]:8 | struct/C | Foo | c:decl-context.cpp@N@ns@aN@S@Foo
}
}
namespace ns2 {
namespace {
struct Foo {};
// CHECK: [[@LINE-1]]:8 | struct/C | Foo | c:decl-context.cpp@N@ns2@aN@S@Foo
}
}
1 change: 1 addition & 0 deletions clang/unittests/Driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set(LLVM_LINK_COMPONENTS
add_clang_unittest(ClangDriverTests
DistroTest.cpp
DXCModeTest.cpp
GCCVersionTest.cpp
ToolChainTest.cpp
ModuleCacheTest.cpp
MultilibBuilderTest.cpp
Expand Down
52 changes: 52 additions & 0 deletions clang/unittests/Driver/GCCVersionTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//===- unittests/Driver/GCCVersionTest.cpp --- GCCVersion parser tests ----===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Unit tests for Generic_GCC::GCCVersion
//
//===----------------------------------------------------------------------===//

#include "../../lib/Driver/ToolChains/Gnu.h"
#include "gtest/gtest.h"

using namespace clang;
using namespace clang::driver;

namespace {

struct VersionParseTest {
std::string Text;

int Major, Minor, Patch;
std::string MajorStr, MinorStr, PatchSuffix;
};

const VersionParseTest TestCases[] = {
{"5", 5, -1, -1, "5", "", ""},
{"4.4", 4, 4, -1, "4", "4", ""},
{"4.4-patched", 4, 4, -1, "4", "4", "-patched"},
{"4.4.0", 4, 4, 0, "4", "4", ""},
{"4.4.x", 4, 4, -1, "4", "4", ""},
{"4.4.2-rc4", 4, 4, 2, "4", "4", "-rc4"},
{"4.4.x-patched", 4, 4, -1, "4", "4", ""},
{"not-a-version", -1, -1, -1, "", "", ""},
};

TEST(GCCVersionTest, Parse) {
for (const auto &TC : TestCases) {
auto V = toolchains::Generic_GCC::GCCVersion::Parse(TC.Text);
EXPECT_EQ(V.Text, TC.Text);
EXPECT_EQ(V.Major, TC.Major);
EXPECT_EQ(V.Minor, TC.Minor);
EXPECT_EQ(V.Patch, TC.Patch);
EXPECT_EQ(V.MajorStr, TC.MajorStr);
EXPECT_EQ(V.MinorStr, TC.MinorStr);
EXPECT_EQ(V.PatchSuffix, TC.PatchSuffix);
}
}

} // end anonymous namespace
3 changes: 2 additions & 1 deletion compiler-rt/lib/builtins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,9 @@ set(aarch64_SOURCES
aarch64/fp_mode.c
)

if(COMPILER_RT_HAS_ASM_SME)
if(COMPILER_RT_HAS_ASM_SME AND (COMPILER_RT_HAS_AUXV OR COMPILER_RT_BAREMETAL_BUILD))
list(APPEND aarch64_SOURCES aarch64/sme-abi.S aarch64/sme-abi-init.c)
message(STATUS "AArch64 SME ABI routines enabled")
else()
message(STATUS "AArch64 SME ABI routines disabled")
endif()
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Config/llvm-config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/* Indicate that this is LLVM compiled from the amd-gfx branch. */
#define LLVM_HAVE_BRANCH_AMD_GFX
#define LLVM_MAIN_REVISION 477846
#define LLVM_MAIN_REVISION 477852

/* Define if LLVM_ENABLE_DUMP is enabled */
#cmakedefine LLVM_ENABLE_DUMP
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Object/XCOFFObjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ class XCOFFSymbolRef : public SymbolRef {
const XCOFFSymbolEntry32 *getSymbol32() const {
return reinterpret_cast<const XCOFFSymbolEntry32 *>(getRawDataRefImpl().p);
}

const XCOFFSymbolEntry64 *getSymbol64() const {
return reinterpret_cast<const XCOFFSymbolEntry64 *>(getRawDataRefImpl().p);
}
Expand Down
6 changes: 6 additions & 0 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1738,6 +1738,12 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value *V) {
if (const auto *NC = dyn_cast<NoCFIValue>(C))
return getValue(NC->getGlobalValue());

if (VT == MVT::aarch64svcount) {
assert(C->isNullValue() && "Can only zero this target type!");
return DAG.getNode(ISD::BITCAST, getCurSDLoc(), VT,
DAG.getConstant(0, getCurSDLoc(), MVT::nxv16i1));
}

VectorType *VecTy = cast<VectorType>(V->getType());

// Now that we know the number and type of the elements, get that number of
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/IR/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,8 @@ static TargetTypeInfo getTargetTypeInfo(const TargetExtType *Ty) {

// Opaque types in the AArch64 name space.
if (Name == "aarch64.svcount")
return TargetTypeInfo(ScalableVectorType::get(Type::getInt1Ty(C), 16));
return TargetTypeInfo(ScalableVectorType::get(Type::getInt1Ty(C), 16),
TargetExtType::HasZeroInit);

return TargetTypeInfo(Type::getVoidTy(C));
}
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Object/SymbolSize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ llvm::object::computeSymbolSizes(const ObjectFile &O) {
}

if (const auto *E = dyn_cast<XCOFFObjectFile>(&O)) {
auto Syms = E->symbols();
for (XCOFFSymbolRef Sym : Syms)
for (XCOFFSymbolRef Sym : E->symbols())
Ret.push_back({Sym, Sym.getSize()});
return Ret;
}
Expand Down
7 changes: 7 additions & 0 deletions llvm/test/CodeGen/AArch64/sve-zeroinit.ll
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,10 @@ define <vscale x 16 x i1> @test_zeroinit_16xi1() {
; CHECK-NEXT: ret
ret <vscale x 16 x i1> zeroinitializer
}

define target("aarch64.svcount") @test_zeroinit_svcount() "target-features"="+sme2" {
; CHECK-LABEL: test_zeroinit_svcount
; CHECK: pfalse p0.b
; CHECK-NEXT: ret
ret target("aarch64.svcount") zeroinitializer
}
1 change: 1 addition & 0 deletions llvm/utils/gn/secondary/clang/unittests/Driver/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ unittest("ClangDriverTests") {
sources = [
"DXCModeTest.cpp",
"DistroTest.cpp",
"GCCVersionTest.cpp",
"ModuleCacheTest.cpp",
"MultilibBuilderTest.cpp",
"MultilibTest.cpp",
Expand Down

0 comments on commit b9f9dea

Please sign in to comment.