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 143 #if __has_cpp_attribute(clang::reinitializes) 144 #define LLVM_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]] 146 #define LLVM_ATTRIBUTE_REINITIALIZES 157 #if __has_attribute(unused) || LLVM_GNUC_PREREQ(3, 1, 0) 158 #define LLVM_ATTRIBUTE_UNUSED __attribute__((__unused__)) 160 #define LLVM_ATTRIBUTE_UNUSED 164 #if (__has_attribute(weak) || LLVM_GNUC_PREREQ(4, 0, 0)) && \ 165 (!defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_WIN32)) 166 #define LLVM_ATTRIBUTE_WEAK __attribute__((__weak__)) 168 #define LLVM_ATTRIBUTE_WEAK 173 #if defined(__clang__) || defined(__GNUC__) 175 #define LLVM_READNONE __attribute__((__const__)) 177 #define LLVM_READNONE 180 #if __has_attribute(pure) || defined(__GNUC__) 182 #define LLVM_READONLY __attribute__((__pure__)) 184 #define LLVM_READONLY 187 #if __has_builtin(__builtin_expect) || LLVM_GNUC_PREREQ(4, 0, 0) 188 #define LLVM_LIKELY(EXPR) __builtin_expect((bool)(EXPR), true) 189 #define LLVM_UNLIKELY(EXPR) __builtin_expect((bool)(EXPR), false) 191 #define LLVM_LIKELY(EXPR) (EXPR) 192 #define LLVM_UNLIKELY(EXPR) (EXPR) 197 #if __has_attribute(noinline) || LLVM_GNUC_PREREQ(3, 4, 0) 198 #define LLVM_ATTRIBUTE_NOINLINE __attribute__((noinline)) 199 #elif defined(_MSC_VER) 200 #define LLVM_ATTRIBUTE_NOINLINE __declspec(noinline) 202 #define LLVM_ATTRIBUTE_NOINLINE 209 #if __has_attribute(always_inline) || LLVM_GNUC_PREREQ(4, 0, 0) 210 #define LLVM_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline)) 211 #elif defined(_MSC_VER) 212 #define LLVM_ATTRIBUTE_ALWAYS_INLINE __forceinline 214 #define LLVM_ATTRIBUTE_ALWAYS_INLINE 218 #define LLVM_ATTRIBUTE_NORETURN __attribute__((noreturn)) 219 #elif defined(_MSC_VER) 220 #define LLVM_ATTRIBUTE_NORETURN __declspec(noreturn) 222 #define LLVM_ATTRIBUTE_NORETURN 225 #if __has_attribute(returns_nonnull) || LLVM_GNUC_PREREQ(4, 9, 0) 226 #define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull)) 227 #elif defined(_MSC_VER) 228 #define LLVM_ATTRIBUTE_RETURNS_NONNULL _Ret_notnull_ 230 #define LLVM_ATTRIBUTE_RETURNS_NONNULL 236 #define LLVM_ATTRIBUTE_RETURNS_NOALIAS __attribute__((__malloc__)) 237 #elif defined(_MSC_VER) 238 #define LLVM_ATTRIBUTE_RETURNS_NOALIAS __declspec(restrict) 240 #define LLVM_ATTRIBUTE_RETURNS_NOALIAS 244 #if __cplusplus > 201402L && __has_cpp_attribute(fallthrough) 245 #define LLVM_FALLTHROUGH [[fallthrough]] 246 #elif __has_cpp_attribute(gnu::fallthrough) 247 #define LLVM_FALLTHROUGH [[gnu::fallthrough]] 251 #define LLVM_FALLTHROUGH 252 #elif __has_cpp_attribute(clang::fallthrough) 253 #define LLVM_FALLTHROUGH [[clang::fallthrough]] 255 #define LLVM_FALLTHROUGH 261 #define LLVM_EXTENSION __extension__ 263 #define LLVM_EXTENSION 267 #if __has_feature(attribute_deprecated_with_message) 268 # define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \ 269 decl __attribute__((deprecated(message))) 270 #elif defined(__GNUC__) 271 # define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \ 272 decl __attribute__((deprecated)) 273 #elif defined(_MSC_VER) 274 # define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \ 275 __declspec(deprecated(message)) decl 277 # define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \ 284 #if __has_builtin(__builtin_unreachable) || LLVM_GNUC_PREREQ(4, 5, 0) 285 # define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable() 286 #elif defined(_MSC_VER) 287 # define LLVM_BUILTIN_UNREACHABLE __assume(false) 292 #if __has_builtin(__builtin_trap) || LLVM_GNUC_PREREQ(4, 3, 0) 293 # define LLVM_BUILTIN_TRAP __builtin_trap() 294 #elif defined(_MSC_VER) 299 # define LLVM_BUILTIN_TRAP __debugbreak() 301 # define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0 307 #if __has_builtin(__builtin_debugtrap) 308 # define LLVM_BUILTIN_DEBUGTRAP __builtin_debugtrap() 309 #elif defined(_MSC_VER) 313 # define LLVM_BUILTIN_DEBUGTRAP __debugbreak() 318 # define LLVM_BUILTIN_DEBUGTRAP 323 #if __has_builtin(__builtin_assume_aligned) || LLVM_GNUC_PREREQ(4, 7, 0) 324 # define LLVM_ASSUME_ALIGNED(p, a) __builtin_assume_aligned(p, a) 325 #elif defined(LLVM_BUILTIN_UNREACHABLE) 327 # define LLVM_ASSUME_ALIGNED(p, a) \ 328 (((uintptr_t(p) % (a)) == 0) ? (p) : (LLVM_BUILTIN_UNREACHABLE, (p))) 330 # define LLVM_ASSUME_ALIGNED(p, a) (p) 335 #if __GNUC__ && !__has_feature(cxx_alignas) && !LLVM_GNUC_PREREQ(4, 8, 1) 336 # define LLVM_ALIGNAS(x) __attribute__((aligned(x))) 338 # define LLVM_ALIGNAS(x) alignas(x) 360 # define LLVM_PACKED(d) __pragma(pack(push, 1)) d __pragma(pack(pop)) 361 # define LLVM_PACKED_START __pragma(pack(push, 1)) 362 # define LLVM_PACKED_END __pragma(pack(pop)) 364 # define LLVM_PACKED(d) d __attribute__((packed)) 365 # define LLVM_PACKED_START _Pragma("pack(push, 1)") 366 # define LLVM_PACKED_END _Pragma("pack(pop)") 373 #ifdef __SIZEOF_POINTER__ 374 # define LLVM_PTR_SIZE __SIZEOF_POINTER__ 375 #elif defined(_WIN64) 376 # define LLVM_PTR_SIZE 8 377 #elif defined(_WIN32) 378 # define LLVM_PTR_SIZE 4 379 #elif defined(_MSC_VER) 380 # error "could not determine LLVM_PTR_SIZE as a constant int for MSVC" 382 # define LLVM_PTR_SIZE sizeof(void *) 387 #if __has_feature(memory_sanitizer) 388 # define LLVM_MEMORY_SANITIZER_BUILD 1 389 # include <sanitizer/msan_interface.h> 391 # define LLVM_MEMORY_SANITIZER_BUILD 0 392 # define __msan_allocated_memory(p, size) 393 # define __msan_unpoison(p, size) 398 #if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) 399 # define LLVM_ADDRESS_SANITIZER_BUILD 1 400 # include <sanitizer/asan_interface.h> 402 # define LLVM_ADDRESS_SANITIZER_BUILD 0 403 # define __asan_poison_memory_region(p, size) 404 # define __asan_unpoison_memory_region(p, size) 409 #if __has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__) 410 # define LLVM_THREAD_SANITIZER_BUILD 1 412 # define LLVM_THREAD_SANITIZER_BUILD 0 415 #if LLVM_THREAD_SANITIZER_BUILD 422 void AnnotateHappensAfter(
const char *
file,
int line,
const volatile void *cv);
423 void AnnotateHappensBefore(
const char *file,
int line,
const volatile void *cv);
424 void AnnotateIgnoreWritesBegin(
const char *file,
int line);
425 void AnnotateIgnoreWritesEnd(
const char *file,
int line);
433 # define TsanHappensBefore(cv) AnnotateHappensBefore(__FILE__, __LINE__, cv) 436 # define TsanHappensAfter(cv) AnnotateHappensAfter(__FILE__, __LINE__, cv) 439 # define TsanIgnoreWritesBegin() AnnotateIgnoreWritesBegin(__FILE__, __LINE__) 442 # define TsanIgnoreWritesEnd() AnnotateIgnoreWritesEnd(__FILE__, __LINE__) 444 # define TsanHappensBefore(cv) 445 # define TsanHappensAfter(cv) 446 # define TsanIgnoreWritesBegin() 447 # define TsanIgnoreWritesEnd() 452 #if __has_attribute(no_sanitize) 453 #define LLVM_NO_SANITIZE(KIND) __attribute__((no_sanitize(KIND))) 455 #define LLVM_NO_SANITIZE(KIND) 464 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 465 #define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED 467 #define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE 475 #if defined(_MSC_VER) 476 #define LLVM_PRETTY_FUNCTION __FUNCSIG__ 477 #elif defined(__GNUC__) || defined(__clang__) 478 #define LLVM_PRETTY_FUNCTION __PRETTY_FUNCTION__ 480 #define LLVM_PRETTY_FUNCTION __func__ 495 #if LLVM_ENABLE_THREADS 496 #if __has_feature(cxx_thread_local) 497 #define LLVM_THREAD_LOCAL thread_local 498 #elif defined(_MSC_VER) 500 #define LLVM_THREAD_LOCAL __declspec(thread) 504 #define LLVM_THREAD_LOCAL __thread 506 #else // !LLVM_ENABLE_THREADS 509 #define LLVM_THREAD_LOCAL 514 #if __has_feature(cxx_exceptions) 515 #define LLVM_ENABLE_EXCEPTIONS 1 516 #elif defined(__GNUC__) && defined(__EXCEPTIONS) 517 #define LLVM_ENABLE_EXCEPTIONS 1 518 #elif defined(_MSC_VER) && defined(_CPPUNWIND) 519 #define LLVM_ENABLE_EXCEPTIONS 1 534 return ::operator
new(Size
535 #ifdef __cpp_aligned_new 537 std::align_val_t(Alignment)
550 ::operator
delete(Ptr
551 #ifdef __cpp_sized_deallocation 555 #ifdef __cpp_aligned_new 557 std::align_val_t(Alignment)
*ViewGraph Emit a dot run run gv on the postscript file
This class represents lattice values for constants.
void * allocate_buffer(size_t Size, size_t Alignment)
Allocate a buffer of memory with the given size and alignment.
void deallocate_buffer(void *Ptr, size_t Size, size_t Alignment)
Deallocate a buffer of memory with the given size and alignment.