15 #ifndef LLVM_SUPPORT_COMPILER_H 16 #define LLVM_SUPPORT_COMPILER_H 18 #include "llvm/Config/llvm-config.h" 28 # define __has_feature(x) 0 31 #ifndef __has_extension 32 # define __has_extension(x) 0 35 #ifndef __has_attribute 36 # define __has_attribute(x) 0 39 #ifndef __has_cpp_attribute 40 # define __has_cpp_attribute(x) 0 44 # define __has_builtin(x) 0 50 #ifndef LLVM_GNUC_PREREQ 51 # if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) 52 # define LLVM_GNUC_PREREQ(maj, min, patch) \ 53 ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) + __GNUC_PATCHLEVEL__ >= \ 54 ((maj) << 20) + ((min) << 10) + (patch)) 55 # elif defined(__GNUC__) && defined(__GNUC_MINOR__) 56 # define LLVM_GNUC_PREREQ(maj, min, patch) \ 57 ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) >= ((maj) << 20) + ((min) << 10)) 59 # define LLVM_GNUC_PREREQ(maj, min, patch) 0 68 #define LLVM_MSC_PREREQ(version) (_MSC_VER >= (version)) 71 #if !LLVM_MSC_PREREQ(1900) 72 #error LLVM requires at least MSVC 2015. 76 #define LLVM_MSC_PREREQ(version) 0 83 #if __has_feature(cxx_rvalue_references) || LLVM_GNUC_PREREQ(4, 8, 1) 84 #define LLVM_HAS_RVALUE_REFERENCE_THIS 1 86 #define LLVM_HAS_RVALUE_REFERENCE_THIS 0 93 #if LLVM_HAS_RVALUE_REFERENCE_THIS 94 #define LLVM_LVALUE_FUNCTION & 96 #define LLVM_LVALUE_FUNCTION 104 #if (__has_attribute(visibility) || LLVM_GNUC_PREREQ(4, 0, 0)) && \ 105 !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_WIN32) 106 #define LLVM_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden"))) 108 #define LLVM_LIBRARY_VISIBILITY 111 #if defined(__GNUC__) 112 #define LLVM_PREFETCH(addr, rw, locality) __builtin_prefetch(addr, rw, locality) 114 #define LLVM_PREFETCH(addr, rw, locality) 117 #if __has_attribute(used) || LLVM_GNUC_PREREQ(3, 1, 0) 118 #define LLVM_ATTRIBUTE_USED __attribute__((__used__)) 120 #define LLVM_ATTRIBUTE_USED 124 #if __cplusplus > 201402L && __has_cpp_attribute(nodiscard) 125 #define LLVM_NODISCARD [[nodiscard]] 129 #define LLVM_NODISCARD 130 #elif __has_cpp_attribute(clang::warn_unused_result) 131 #define LLVM_NODISCARD [[clang::warn_unused_result]] 133 #define LLVM_NODISCARD 144 #if __has_attribute(unused) || LLVM_GNUC_PREREQ(3, 1, 0) 145 #define LLVM_ATTRIBUTE_UNUSED __attribute__((__unused__)) 147 #define LLVM_ATTRIBUTE_UNUSED 151 #if (__has_attribute(weak) || LLVM_GNUC_PREREQ(4, 0, 0)) && \ 152 (!defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_WIN32)) 153 #define LLVM_ATTRIBUTE_WEAK __attribute__((__weak__)) 155 #define LLVM_ATTRIBUTE_WEAK 160 #if defined(__clang__) || defined(__GNUC__) 162 #define LLVM_READNONE __attribute__((__const__)) 164 #define LLVM_READNONE 167 #if __has_attribute(pure) || defined(__GNUC__) 169 #define LLVM_READONLY __attribute__((__pure__)) 171 #define LLVM_READONLY 174 #if __has_builtin(__builtin_expect) || LLVM_GNUC_PREREQ(4, 0, 0) 175 #define LLVM_LIKELY(EXPR) __builtin_expect((bool)(EXPR), true) 176 #define LLVM_UNLIKELY(EXPR) __builtin_expect((bool)(EXPR), false) 178 #define LLVM_LIKELY(EXPR) (EXPR) 179 #define LLVM_UNLIKELY(EXPR) (EXPR) 184 #if __has_attribute(noinline) || LLVM_GNUC_PREREQ(3, 4, 0) 185 #define LLVM_ATTRIBUTE_NOINLINE __attribute__((noinline)) 186 #elif defined(_MSC_VER) 187 #define LLVM_ATTRIBUTE_NOINLINE __declspec(noinline) 189 #define LLVM_ATTRIBUTE_NOINLINE 196 #if __has_attribute(always_inline) || LLVM_GNUC_PREREQ(4, 0, 0) 197 #define LLVM_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline)) 198 #elif defined(_MSC_VER) 199 #define LLVM_ATTRIBUTE_ALWAYS_INLINE __forceinline 201 #define LLVM_ATTRIBUTE_ALWAYS_INLINE 205 #define LLVM_ATTRIBUTE_NORETURN __attribute__((noreturn)) 206 #elif defined(_MSC_VER) 207 #define LLVM_ATTRIBUTE_NORETURN __declspec(noreturn) 209 #define LLVM_ATTRIBUTE_NORETURN 212 #if __has_attribute(returns_nonnull) || LLVM_GNUC_PREREQ(4, 9, 0) 213 #define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull)) 214 #elif defined(_MSC_VER) 215 #define LLVM_ATTRIBUTE_RETURNS_NONNULL _Ret_notnull_ 217 #define LLVM_ATTRIBUTE_RETURNS_NONNULL 223 #define LLVM_ATTRIBUTE_RETURNS_NOALIAS __attribute__((__malloc__)) 224 #elif defined(_MSC_VER) 225 #define LLVM_ATTRIBUTE_RETURNS_NOALIAS __declspec(restrict) 227 #define LLVM_ATTRIBUTE_RETURNS_NOALIAS 231 #if __cplusplus > 201402L && __has_cpp_attribute(fallthrough) 232 #define LLVM_FALLTHROUGH [[fallthrough]] 233 #elif __has_cpp_attribute(gnu::fallthrough) 234 #define LLVM_FALLTHROUGH [[gnu::fallthrough]] 238 #define LLVM_FALLTHROUGH 239 #elif __has_cpp_attribute(clang::fallthrough) 240 #define LLVM_FALLTHROUGH [[clang::fallthrough]] 242 #define LLVM_FALLTHROUGH 248 #define LLVM_EXTENSION __extension__ 250 #define LLVM_EXTENSION 254 #if __has_feature(attribute_deprecated_with_message) 255 # define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \ 256 decl __attribute__((deprecated(message))) 257 #elif defined(__GNUC__) 258 # define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \ 259 decl __attribute__((deprecated)) 260 #elif defined(_MSC_VER) 261 # define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \ 262 __declspec(deprecated(message)) decl 264 # define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \ 271 #if __has_builtin(__builtin_unreachable) || LLVM_GNUC_PREREQ(4, 5, 0) 272 # define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable() 273 #elif defined(_MSC_VER) 274 # define LLVM_BUILTIN_UNREACHABLE __assume(false) 279 #if __has_builtin(__builtin_trap) || LLVM_GNUC_PREREQ(4, 3, 0) 280 # define LLVM_BUILTIN_TRAP __builtin_trap() 281 #elif defined(_MSC_VER) 286 # define LLVM_BUILTIN_TRAP __debugbreak() 288 # define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0 294 #if __has_builtin(__builtin_debugtrap) 295 # define LLVM_BUILTIN_DEBUGTRAP __builtin_debugtrap() 296 #elif defined(_MSC_VER) 300 # define LLVM_BUILTIN_DEBUGTRAP __debugbreak() 305 # define LLVM_BUILTIN_DEBUGTRAP 310 #if __has_builtin(__builtin_assume_aligned) || LLVM_GNUC_PREREQ(4, 7, 0) 311 # define LLVM_ASSUME_ALIGNED(p, a) __builtin_assume_aligned(p, a) 312 #elif defined(LLVM_BUILTIN_UNREACHABLE) 314 # define LLVM_ASSUME_ALIGNED(p, a) \ 315 (((uintptr_t(p) % (a)) == 0) ? (p) : (LLVM_BUILTIN_UNREACHABLE, (p))) 317 # define LLVM_ASSUME_ALIGNED(p, a) (p) 322 #if __GNUC__ && !__has_feature(cxx_alignas) && !LLVM_GNUC_PREREQ(4, 8, 1) 323 # define LLVM_ALIGNAS(x) __attribute__((aligned(x))) 325 # define LLVM_ALIGNAS(x) alignas(x) 347 # define LLVM_PACKED(d) __pragma(pack(push, 1)) d __pragma(pack(pop)) 348 # define LLVM_PACKED_START __pragma(pack(push, 1)) 349 # define LLVM_PACKED_END __pragma(pack(pop)) 351 # define LLVM_PACKED(d) d __attribute__((packed)) 352 # define LLVM_PACKED_START _Pragma("pack(push, 1)") 353 # define LLVM_PACKED_END _Pragma("pack(pop)") 360 #ifdef __SIZEOF_POINTER__ 361 # define LLVM_PTR_SIZE __SIZEOF_POINTER__ 362 #elif defined(_WIN64) 363 # define LLVM_PTR_SIZE 8 364 #elif defined(_WIN32) 365 # define LLVM_PTR_SIZE 4 366 #elif defined(_MSC_VER) 367 # error "could not determine LLVM_PTR_SIZE as a constant int for MSVC" 369 # define LLVM_PTR_SIZE sizeof(void *) 374 #if __has_feature(memory_sanitizer) 375 # define LLVM_MEMORY_SANITIZER_BUILD 1 376 # include <sanitizer/msan_interface.h> 378 # define LLVM_MEMORY_SANITIZER_BUILD 0 379 # define __msan_allocated_memory(p, size) 380 # define __msan_unpoison(p, size) 385 #if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) 386 # define LLVM_ADDRESS_SANITIZER_BUILD 1 387 # include <sanitizer/asan_interface.h> 389 # define LLVM_ADDRESS_SANITIZER_BUILD 0 390 # define __asan_poison_memory_region(p, size) 391 # define __asan_unpoison_memory_region(p, size) 396 #if __has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__) 397 # define LLVM_THREAD_SANITIZER_BUILD 1 399 # define LLVM_THREAD_SANITIZER_BUILD 0 402 #if LLVM_THREAD_SANITIZER_BUILD 409 void AnnotateHappensAfter(
const char *
file,
int line,
const volatile void *cv);
410 void AnnotateHappensBefore(
const char *file,
int line,
const volatile void *cv);
411 void AnnotateIgnoreWritesBegin(
const char *file,
int line);
412 void AnnotateIgnoreWritesEnd(
const char *file,
int line);
420 # define TsanHappensBefore(cv) AnnotateHappensBefore(__FILE__, __LINE__, cv) 423 # define TsanHappensAfter(cv) AnnotateHappensAfter(__FILE__, __LINE__, cv) 426 # define TsanIgnoreWritesBegin() AnnotateIgnoreWritesBegin(__FILE__, __LINE__) 429 # define TsanIgnoreWritesEnd() AnnotateIgnoreWritesEnd(__FILE__, __LINE__) 431 # define TsanHappensBefore(cv) 432 # define TsanHappensAfter(cv) 433 # define TsanIgnoreWritesBegin() 434 # define TsanIgnoreWritesEnd() 439 #if __has_attribute(no_sanitize) 440 #define LLVM_NO_SANITIZE(KIND) __attribute__((no_sanitize(KIND))) 442 #define LLVM_NO_SANITIZE(KIND) 451 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 452 #define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED 454 #define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE 462 #if defined(_MSC_VER) 463 #define LLVM_PRETTY_FUNCTION __FUNCSIG__ 464 #elif defined(__GNUC__) || defined(__clang__) 465 #define LLVM_PRETTY_FUNCTION __PRETTY_FUNCTION__ 467 #define LLVM_PRETTY_FUNCTION __func__ 482 #if LLVM_ENABLE_THREADS 483 #if __has_feature(cxx_thread_local) 484 #define LLVM_THREAD_LOCAL thread_local 485 #elif defined(_MSC_VER) 487 #define LLVM_THREAD_LOCAL __declspec(thread) 491 #define LLVM_THREAD_LOCAL __thread 493 #else // !LLVM_ENABLE_THREADS 496 #define LLVM_THREAD_LOCAL 501 #if __has_feature(cxx_exceptions) 502 #define LLVM_ENABLE_EXCEPTIONS 1 503 #elif defined(__GNUC__) && defined(__EXCEPTIONS) 504 #define LLVM_ENABLE_EXCEPTIONS 1 505 #elif defined(_MSC_VER) && defined(_CPPUNWIND) 506 #define LLVM_ENABLE_EXCEPTIONS 1 521 return ::operator
new(Size
522 #if __cpp_aligned_new 524 std::align_val_t(Alignment)
537 ::operator
delete(Ptr
538 #if __cpp_sized_deallocation 542 #if __cpp_aligned_new 544 std::align_val_t(Alignment)
Compute iterated dominance frontiers using a linear time algorithm.
void * allocate_buffer(size_t Size, size_t Alignment)
Allocate a buffer of memory with the given size and alignment.
dot regions Print regions of function to dot file(with no function bodies)"
void deallocate_buffer(void *Ptr, size_t Size, size_t Alignment)
Deallocate a buffer of memory with the given size and alignment.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.