Skip to content

Commit

Permalink
Merged main:b6bc9d72f65a into amd-gfx:bef2fdeea257
Browse files Browse the repository at this point in the history
Local branch amd-gfx bef2fde Merged main:b797a6aede3d into amd-gfx:a757a754c785
Remote branch main b6bc9d7 [libc] Mass replace enclosing namespace (llvm#67032)
  • Loading branch information
SC llvm team authored and SC llvm team committed Sep 26, 2023
2 parents bef2fde + b6bc9d7 commit 2b22973
Show file tree
Hide file tree
Showing 2,050 changed files with 10,248 additions and 8,372 deletions.
3 changes: 0 additions & 3 deletions .github/new-prs-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,6 @@ mlir:vector:
mlir:execution-engine:
- mlir/**/ExecutionEngine/**

mlir:affine:
- mlir/**/Affine/**/*

mlir:presburger:
- mlir/**/*Presburger*/**

Expand Down
20 changes: 14 additions & 6 deletions compiler-rt/lib/scudo/standalone/combined.h
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,7 @@ class Allocator {
atomic_u32 DeallocationTid;
};

MemMapT MemMap;
atomic_uptr Pos;
u32 Size;
// An array of Size (at least one) elements of type Entry is immediately
Expand Down Expand Up @@ -1492,12 +1493,15 @@ class Allocator {
static_cast<u32>(getFlags()->allocation_ring_buffer_size);
if (AllocationRingBufferSize < 1)
return;
RawRingBuffer = static_cast<char *>(
map(/*Addr=*/nullptr,
roundUp(ringBufferSizeInBytes(AllocationRingBufferSize),
getPageSizeCached()),
"scudo:ring_buffer"));
MemMapT MemMap;
MemMap.map(
/*Addr=*/0U,
roundUp(ringBufferSizeInBytes(AllocationRingBufferSize),
getPageSizeCached()),
"scudo:ring_buffer");
RawRingBuffer = reinterpret_cast<char *>(MemMap.getBase());
auto *RingBuffer = reinterpret_cast<AllocationRingBuffer *>(RawRingBuffer);
RingBuffer->MemMap = MemMap;
RingBuffer->Size = AllocationRingBufferSize;
static_assert(sizeof(AllocationRingBuffer) %
alignof(typename AllocationRingBuffer::Entry) ==
Expand All @@ -1506,7 +1510,11 @@ class Allocator {
}

void unmapRingBuffer() {
unmap(RawRingBuffer, roundUp(getRingBufferSize(), getPageSizeCached()));
auto *RingBuffer = getRingBuffer();
if (RingBuffer != nullptr) {
MemMapT MemMap = RingBuffer->MemMap;
MemMap.unmap(MemMap.getBase(), MemMap.getCapacity());
}
RawRingBuffer = nullptr;
}

Expand Down
2 changes: 1 addition & 1 deletion libc/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function(add_libc_multi_impl_benchmark name)
get_target_property(entrypoint_object_file ${fq_config_name} "OBJECT_FILE_RAW")
target_link_libraries(${benchmark_name} PUBLIC json ${entrypoint_object_file})
string(TOUPPER ${name} name_upper)
target_compile_definitions(${benchmark_name} PRIVATE "-DLIBC_BENCHMARK_FUNCTION_${name_upper}=__llvm_libc::${name}" "-DLIBC_BENCHMARK_FUNCTION_NAME=\"${fq_config_name}\"")
target_compile_definitions(${benchmark_name} PRIVATE "-DLIBC_BENCHMARK_FUNCTION_${name_upper}=LIBC_NAMESPACE::${name}" "-DLIBC_BENCHMARK_FUNCTION_NAME=\"${fq_config_name}\"")
llvm_update_compile_flags(${benchmark_name})
else()
message(STATUS "Skipping benchmark for '${fq_config_name}' insufficient host cpu features '${required_cpu_features}'")
Expand Down
16 changes: 8 additions & 8 deletions libc/benchmarks/LibcDefaultImplementations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "llvm/ADT/ArrayRef.h"
#include <cstddef>

namespace __llvm_libc {
namespace LIBC_NAMESPACE {

extern void *memcpy(void *__restrict, const void *__restrict, size_t);
extern void *memmove(void *, const void *, size_t);
Expand All @@ -11,7 +11,7 @@ extern void bzero(void *, size_t);
extern int memcmp(const void *, const void *, size_t);
extern int bcmp(const void *, const void *, size_t);

} // namespace __llvm_libc
} // namespace LIBC_NAMESPACE

// List of implementations to test.

Expand All @@ -23,31 +23,31 @@ using llvm::libc_benchmarks::MemsetConfiguration;

llvm::ArrayRef<MemcpyConfiguration> getMemcpyConfigurations() {
static constexpr MemcpyConfiguration kMemcpyConfigurations[] = {
{__llvm_libc::memcpy, "__llvm_libc::memcpy"}};
{LIBC_NAMESPACE::memcpy, "LIBC_NAMESPACE::memcpy"}};
return llvm::ArrayRef(kMemcpyConfigurations);
}
llvm::ArrayRef<MemmoveConfiguration> getMemmoveConfigurations() {
static constexpr MemmoveConfiguration kMemmoveConfigurations[] = {
{__llvm_libc::memmove, "__llvm_libc::memmove"}};
{LIBC_NAMESPACE::memmove, "LIBC_NAMESPACE::memmove"}};
return llvm::ArrayRef(kMemmoveConfigurations);
}
llvm::ArrayRef<MemcmpOrBcmpConfiguration> getMemcmpConfigurations() {
static constexpr MemcmpOrBcmpConfiguration kMemcmpConfiguration[] = {
{__llvm_libc::memcmp, "__llvm_libc::memcmp"}};
{LIBC_NAMESPACE::memcmp, "LIBC_NAMESPACE::memcmp"}};
return llvm::ArrayRef(kMemcmpConfiguration);
}
llvm::ArrayRef<MemcmpOrBcmpConfiguration> getBcmpConfigurations() {
static constexpr MemcmpOrBcmpConfiguration kBcmpConfigurations[] = {
{__llvm_libc::bcmp, "__llvm_libc::bcmp"}};
{LIBC_NAMESPACE::bcmp, "LIBC_NAMESPACE::bcmp"}};
return llvm::ArrayRef(kBcmpConfigurations);
}
llvm::ArrayRef<MemsetConfiguration> getMemsetConfigurations() {
static constexpr MemsetConfiguration kMemsetConfigurations[] = {
{__llvm_libc::memset, "__llvm_libc::memset"}};
{LIBC_NAMESPACE::memset, "LIBC_NAMESPACE::memset"}};
return llvm::ArrayRef(kMemsetConfigurations);
}
llvm::ArrayRef<BzeroConfiguration> getBzeroConfigurations() {
static constexpr BzeroConfiguration kBzeroConfigurations[] = {
{__llvm_libc::bzero, "__llvm_libc::bzero"}};
{LIBC_NAMESPACE::bzero, "LIBC_NAMESPACE::bzero"}};
return llvm::ArrayRef(kBzeroConfigurations);
}
2 changes: 1 addition & 1 deletion libc/benchmarks/LibcMemoryBenchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace libc_benchmarks {
struct StudyConfiguration {
// One of 'memcpy', 'memset', 'memcmp'.
// The underlying implementation is always the llvm libc one.
// e.g. 'memcpy' will test '__llvm_libc::memcpy'
// e.g. 'memcpy' will test 'LIBC_NAMESPACE::memcpy'
std::string Function;

// The number of trials to run for this benchmark.
Expand Down
4 changes: 2 additions & 2 deletions libc/benchmarks/LibcMemoryBenchmarkMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <cstring>
#include <unistd.h>

namespace __llvm_libc {
namespace LIBC_NAMESPACE {

extern void *memcpy(void *__restrict, const void *__restrict, size_t);
extern void *memmove(void *, const void *, size_t);
Expand All @@ -30,7 +30,7 @@ extern void bzero(void *, size_t);
extern int memcmp(const void *, const void *, size_t);
extern int bcmp(const void *, const void *, size_t);

} // namespace __llvm_libc
} // namespace LIBC_NAMESPACE

namespace llvm {
namespace libc_benchmarks {
Expand Down
12 changes: 6 additions & 6 deletions libc/benchmarks/automemcpy/lib/CodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace functions {
// static void memcpy_0xB20D4702493C397E(char *__restrict dst,
// const char *__restrict src,
// size_t size) {
// using namespace __llvm_libc::x86;
// using namespace LIBC_NAMESPACE::x86;
// if(size == 0) return;
// if(size == 1) return copy<_1>(dst, src);
// if(size < 4) return copy<HeadTail<_2>>(dst, src, size);
Expand Down Expand Up @@ -249,7 +249,7 @@ static raw_ostream &operator<<(raw_ostream &Stream,
const auto &Ctx = FI.Ctx;
Stream << "static " << Ctx.FunctionReturnType << ' ' << FI.Name
<< Ctx.FunctionArgs << " {\n";
Stream << kIndent << "using namespace __llvm_libc::" << FI.ElementClass
Stream << kIndent << "using namespace LIBC_NAMESPACE::" << FI.ElementClass
<< ";\n";
for (const auto &I : FI.Individuals)
if (I.Element.Size == 0)
Expand Down Expand Up @@ -428,7 +428,7 @@ namespace configurations {
// ------------------------------------------------------------
// e.g.
// llvm::ArrayRef<MemcpyConfiguration> getMemcpyConfigurations() {
// using namespace __llvm_libc;
// using namespace LIBC_NAMESPACE;
// static constexpr MemcpyConfiguration kConfigurations[] = {
// {Wrap<memcpy_0xE00E29EE73994E2B>, "memcpy_0xE00E29EE73994E2B"},
// {Wrap<memcpy_0x8661D80472487AB5>, "memcpy_0x8661D80472487AB5"},
Expand Down Expand Up @@ -504,7 +504,7 @@ static raw_ostream &operator<<(raw_ostream &Stream, const Configuration &C) {
if (C.Descriptors.empty())
Stream << kIndent << "return {};\n";
else {
Stream << kIndent << "using namespace __llvm_libc;\n";
Stream << kIndent << "using namespace LIBC_NAMESPACE;\n";
Stream << kIndent << "static constexpr " << C.Type
<< " kConfigurations[] = {\n";
Stream << C.Descriptors;
Expand Down Expand Up @@ -542,11 +542,11 @@ static void Serialize(raw_ostream &Stream,
Stream << "using llvm::libc_benchmarks::MemmoveConfiguration;\n";
Stream << "using llvm::libc_benchmarks::MemsetConfiguration;\n";
Stream << "\n";
Stream << "namespace __llvm_libc {\n";
Stream << "namespace LIBC_NAMESPACE {\n";
Stream << "\n";
codegen::functions::Serialize(Stream, Descriptors);
Stream << "\n";
Stream << "} // namespace __llvm_libc\n";
Stream << "} // namespace LIBC_NAMESPACE\n";
Stream << "\n";
Stream << "namespace llvm {\n";
Stream << "namespace automemcpy {\n";
Expand Down
24 changes: 12 additions & 12 deletions libc/benchmarks/automemcpy/unittests/CodeGenTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ using llvm::libc_benchmarks::MemcpyConfiguration;
using llvm::libc_benchmarks::MemmoveConfiguration;
using llvm::libc_benchmarks::MemsetConfiguration;
namespace __llvm_libc {
namespace LIBC_NAMESPACE {
static void memcpy_0xE00E29EE73994E2B(char *__restrict dst, const char *__restrict src, size_t size) {
using namespace __llvm_libc::x86;
using namespace LIBC_NAMESPACE::x86;
return copy<Accelerator>(dst, src, size);
}
static void memcpy_0x7381B60C7BE75EF9(char *__restrict dst, const char *__restrict src, size_t size) {
using namespace __llvm_libc::x86;
using namespace LIBC_NAMESPACE::x86;
if(size == 0) return;
if(size == 1) return copy<_1>(dst, src);
if(size == 2) return copy<_2>(dst, src);
Expand All @@ -84,7 +84,7 @@ static void memcpy_0x7381B60C7BE75EF9(char *__restrict dst, const char *__restri
return copy<Loop<_64>>(dst, src, size);
}
static int memcmp_0x348D7BA6DB0EE033(const char * lhs, const char * rhs, size_t size) {
using namespace __llvm_libc::x86;
using namespace LIBC_NAMESPACE::x86;
if(size == 0) return 0;
if(size == 1) return three_way_compare<_1>(lhs, rhs);
if(size < 4) return three_way_compare<HeadTail<_2>>(lhs, rhs, size);
Expand All @@ -95,7 +95,7 @@ static int memcmp_0x348D7BA6DB0EE033(const char * lhs, const char * rhs, size_t
return three_way_compare<Align<_16,Arg::Lhs>::Then<Loop<_16>>>(lhs, rhs, size);
}
static void memset_0x71E761699B999863(char * dst, int value, size_t size) {
using namespace __llvm_libc::x86;
using namespace LIBC_NAMESPACE::x86;
if(size == 0) return;
if(size == 1) return splat_set<_1>(dst, value);
if(size < 4) return splat_set<HeadTail<_2>>(dst, value, size);
Expand All @@ -108,7 +108,7 @@ static void memset_0x71E761699B999863(char * dst, int value, size_t size) {
return splat_set<Align<_16,Arg::Dst>::Then<Loop<_32>>>(dst, value, size);
}
static void memset_0x3DF0F44E2ED6A50F(char * dst, int value, size_t size) {
using namespace __llvm_libc::x86;
using namespace LIBC_NAMESPACE::x86;
if(size == 0) return;
if(size == 1) return splat_set<_1>(dst, value);
if(size < 4) return splat_set<HeadTail<_2>>(dst, value, size);
Expand All @@ -121,7 +121,7 @@ static void memset_0x3DF0F44E2ED6A50F(char * dst, int value, size_t size) {
return splat_set<Align<_32,Arg::Dst>::Then<Loop<_32>>>(dst, value, size);
}
static void bzero_0x475977492C218AD4(char * dst, size_t size) {
using namespace __llvm_libc::x86;
using namespace LIBC_NAMESPACE::x86;
if(size == 0) return;
if(size == 1) return splat_set<_1>(dst, 0);
if(size == 2) return splat_set<_2>(dst, 0);
Expand All @@ -134,7 +134,7 @@ static void bzero_0x475977492C218AD4(char * dst, size_t size) {
return splat_set<Align<_32,Arg::Dst>::Then<Loop<_32>>>(dst, 0, size);
}
} // namespace __llvm_libc
} // namespace LIBC_NAMESPACE
namespace llvm {
namespace automemcpy {
Expand Down Expand Up @@ -163,7 +163,7 @@ void *Wrap(void *__restrict dst, const void *__restrict src, size_t size) {
return dst;
}
llvm::ArrayRef<MemcpyConfiguration> getMemcpyConfigurations() {
using namespace __llvm_libc;
using namespace LIBC_NAMESPACE;
static constexpr MemcpyConfiguration kConfigurations[] = {
{Wrap<memcpy_0xE00E29EE73994E2B>, "memcpy_0xE00E29EE73994E2B"},
{Wrap<memcpy_0x7381B60C7BE75EF9>, "memcpy_0x7381B60C7BE75EF9"},
Expand All @@ -178,7 +178,7 @@ int Wrap(const void *lhs, const void *rhs, size_t size) {
reinterpret_cast<const char *>(rhs), size);
}
llvm::ArrayRef<MemcmpOrBcmpConfiguration> getMemcmpConfigurations() {
using namespace __llvm_libc;
using namespace LIBC_NAMESPACE;
static constexpr MemcmpOrBcmpConfiguration kConfigurations[] = {
{Wrap<memcmp_0x348D7BA6DB0EE033>, "memcmp_0x348D7BA6DB0EE033"},
};
Expand All @@ -194,7 +194,7 @@ template <MemsetStub Foo> void *Wrap(void *dst, int value, size_t size) {
return dst;
}
llvm::ArrayRef<MemsetConfiguration> getMemsetConfigurations() {
using namespace __llvm_libc;
using namespace LIBC_NAMESPACE;
static constexpr MemsetConfiguration kConfigurations[] = {
{Wrap<memset_0x71E761699B999863>, "memset_0x71E761699B999863"},
{Wrap<memset_0x3DF0F44E2ED6A50F>, "memset_0x3DF0F44E2ED6A50F"},
Expand All @@ -207,7 +207,7 @@ template <BzeroStub Foo> void Wrap(void *dst, size_t size) {
Foo(reinterpret_cast<char *>(dst), size);
}
llvm::ArrayRef<BzeroConfiguration> getBzeroConfigurations() {
using namespace __llvm_libc;
using namespace LIBC_NAMESPACE;
static constexpr BzeroConfiguration kConfigurations[] = {
{Wrap<bzero_0x475977492C218AD4>, "bzero_0x475977492C218AD4"},
};
Expand Down
4 changes: 2 additions & 2 deletions libc/config/linux/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <stdint.h>

namespace __llvm_libc {
namespace LIBC_NAMESPACE {

// Data structure to capture properties of the linux/ELF TLS image.
struct TLSImage {
Expand Down Expand Up @@ -106,6 +106,6 @@ void init_tls(TLSDescriptor &tls);
// Cleanup the TLS area as described in |tls_descriptor|.
void cleanup_tls(uintptr_t tls_addr, uintptr_t tls_size);

} // namespace __llvm_libc
} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_CONFIG_LINUX_APP_H
16 changes: 8 additions & 8 deletions libc/docs/dev/clang_tidy_checks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ implementation-in-namespace
---------------------------

It is part of our implementation standards that all implementation pieces live
under the ``__llvm_libc`` namespace. This prevents pollution of the global
under the ``LIBC_NAMESPACE`` namespace. This prevents pollution of the global
namespace. Without a formal check to ensure this, an implementation might
compile and pass unit tests, but not produce a usable libc function.

This check that ensures any function call resolves to a function within the
``__llvm_libc`` namespace.
``LIBC_NAMESPACE`` namespace.

.. code-block:: c++

// Correct: implementation inside the correct namespace.
namespace __llvm_libc {
namespace LIBC_NAMESPACE {
void LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) {}
// Namespaces within __llvm_libc namespace are allowed.
// Namespaces within LIBC_NAMESPACE namespace are allowed.
namespace inner{
int localVar = 0;
}
Expand All @@ -67,7 +67,7 @@ creates some uncertainty about which library a call resolves to especially when
a public header with non-namespaced functions like ``string.h`` is included.

This check ensures any function call resolves to a function within the
__llvm_libc namespace.
LIBC_NAMESPACE namespace.

There are exceptions for the following functions:
``__errno_location`` so that ``errno`` can be set;
Expand All @@ -76,10 +76,10 @@ are always external and can be intercepted.

.. code-block:: c++

namespace __llvm_libc {
namespace LIBC_NAMESPACE {

// Allow calls with the fully qualified name.
__llvm_libc::strlen("hello");
LIBC_NAMESPACE::strlen("hello");

// Allow calls to compiler provided functions.
(void)__builtin_abs(-1);
Expand All @@ -93,4 +93,4 @@ are always external and can be intercepted.
// Allow calling into specific global functions (explained above)
::malloc(10);

} // namespace __llvm_libc
} // namespace LIBC_NAMESPACE
2 changes: 1 addition & 1 deletion libc/docs/dev/code_style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ this:

...

__llvm_libc::AllocChecker ac;
LIBC_NAMESPACE::AllocChecker ac;
auto *obj = new (ac) Type(...);
if (!ac) {
// handle allocator failure.
Expand Down
Loading

0 comments on commit 2b22973

Please sign in to comment.