diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-01-17 20:45:01 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-01-17 20:45:01 +0000 |
commit | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (patch) | |
tree | 4adf86a776049cbf7f69a1929c4babcbbef925eb /llvm | |
parent | 7cc9cf2bf09f069cb2dd947ead05d0b54301fb71 (diff) | |
download | src-706b4fc47bbc608932d3b491ae19a3b9cde9497b.tar.gz src-706b4fc47bbc608932d3b491ae19a3b9cde9497b.zip |
Vendor import of llvm-project master e26a78e70, the last commit beforevendor/llvm-project/llvmorg-10-init-17466-ge26a78e7085
the llvmorg-11-init tag, from which release/10.x was branched.
Notes
Notes:
svn path=/vendor/llvm-project/master/; revision=356843
svn path=/vendor/llvm-project/llvmorg-10-init-17466-ge26a78e7085/; revision=356844; tag=vendor/llvm-project/llvmorg-10-init-17466-ge26a78e7085
Diffstat (limited to 'llvm')
1930 files changed, 85089 insertions, 36779 deletions
diff --git a/llvm/include/llvm-c/Analysis.h b/llvm/include/llvm-c/Analysis.h index cb9e8ece3c53..270b145a4d27 100644 --- a/llvm/include/llvm-c/Analysis.h +++ b/llvm/include/llvm-c/Analysis.h @@ -19,11 +19,10 @@ #ifndef LLVM_C_ANALYSIS_H #define LLVM_C_ANALYSIS_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMCAnalysis Analysis @@ -58,8 +57,6 @@ void LLVMViewFunctionCFGOnly(LLVMValueRef Fn); * @} */ -#ifdef __cplusplus -} -#endif +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/BitReader.h b/llvm/include/llvm-c/BitReader.h index b307ee979f8a..012c0e63d3bb 100644 --- a/llvm/include/llvm-c/BitReader.h +++ b/llvm/include/llvm-c/BitReader.h @@ -19,11 +19,10 @@ #ifndef LLVM_C_BITREADER_H #define LLVM_C_BITREADER_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMCBitReader Bit Reader @@ -78,8 +77,6 @@ LLVMBool LLVMGetBitcodeModule2(LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutM); * @} */ -#ifdef __cplusplus -} -#endif +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/BitWriter.h b/llvm/include/llvm-c/BitWriter.h index 187051555b9a..ea84b6593d12 100644 --- a/llvm/include/llvm-c/BitWriter.h +++ b/llvm/include/llvm-c/BitWriter.h @@ -19,11 +19,10 @@ #ifndef LLVM_C_BITWRITER_H #define LLVM_C_BITWRITER_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMCBitWriter Bit Writer @@ -52,8 +51,6 @@ LLVMMemoryBufferRef LLVMWriteBitcodeToMemoryBuffer(LLVMModuleRef M); * @} */ -#ifdef __cplusplus -} -#endif +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/Comdat.h b/llvm/include/llvm-c/Comdat.h index 81fee3fc9a6b..45b4007695fd 100644 --- a/llvm/include/llvm-c/Comdat.h +++ b/llvm/include/llvm-c/Comdat.h @@ -14,11 +14,10 @@ #ifndef LLVM_C_COMDAT_H #define LLVM_C_COMDAT_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN typedef enum { LLVMAnyComdatSelectionKind, ///< The linker may choose any COMDAT. @@ -68,8 +67,6 @@ LLVMComdatSelectionKind LLVMGetComdatSelectionKind(LLVMComdatRef C); */ void LLVMSetComdatSelectionKind(LLVMComdatRef C, LLVMComdatSelectionKind Kind); -#ifdef __cplusplus -} -#endif +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h index b84970956666..7a39731d3e0c 100644 --- a/llvm/include/llvm-c/Core.h +++ b/llvm/include/llvm-c/Core.h @@ -16,11 +16,10 @@ #define LLVM_C_CORE_H #include "llvm-c/ErrorHandling.h" +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMC LLVM-C: C interface to LLVM @@ -127,6 +126,7 @@ typedef enum { LLVMShuffleVector = 52, LLVMExtractValue = 53, LLVMInsertValue = 54, + LLVMFreeze = 68, /* Atomic operators */ LLVMFence = 55, @@ -1600,6 +1600,7 @@ LLVMTypeRef LLVMX86MMXType(void); macro(ExtractValueInst) \ macro(LoadInst) \ macro(VAArgInst) \ + macro(FreezeInst) \ macro(AtomicCmpXchgInst) \ macro(AtomicRMWInst) \ macro(FenceInst) @@ -3907,6 +3908,8 @@ LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal, LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal, LLVMValueRef EltVal, unsigned Index, const char *Name); +LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef, LLVMValueRef Val, + const char *Name); LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val, const char *Name); @@ -4086,8 +4089,6 @@ LLVMBool LLVMIsMultithreaded(void); * @} */ -#ifdef __cplusplus -} -#endif +LLVM_C_EXTERN_C_END #endif /* LLVM_C_CORE_H */ diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h index 41e9f96bbb92..e933fe4b3f92 100644 --- a/llvm/include/llvm-c/DebugInfo.h +++ b/llvm/include/llvm-c/DebugInfo.h @@ -17,10 +17,9 @@ #define LLVM_C_DEBUGINFO_H #include "llvm-c/Core.h" +#include "llvm-c/ExternC.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * Debug info flags. @@ -284,15 +283,15 @@ LLVMDIBuilderCreateFile(LLVMDIBuilderRef Builder, const char *Filename, * \param ConfigMacrosLen The length of the C string passed to \c ConfigMacros. * \param IncludePath The path to the module map file. * \param IncludePathLen The length of the C string passed to \c IncludePath. - * \param ISysRoot The Clang system root (value of -isysroot). - * \param ISysRootLen The length of the C string passed to \c ISysRoot. + * \param SysRoot The Clang system root (value of -isysroot). + * \param SysRootLen The length of the C string passed to \c SysRoot. */ LLVMMetadataRef LLVMDIBuilderCreateModule(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentScope, const char *Name, size_t NameLen, const char *ConfigMacros, size_t ConfigMacrosLen, const char *IncludePath, size_t IncludePathLen, - const char *ISysRoot, size_t ISysRootLen); + const char *SysRoot, size_t SysRootLen); /** * Creates a new descriptor for a namespace with the specified parent scope. @@ -875,7 +874,7 @@ LLVMMetadataRef LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, - LLVMMetadataRef Scope); + LLVMMetadataRef Scope, uint32_t AlignInBits); /** * Create debugging information entry to establish inheritance relationship @@ -1353,8 +1352,6 @@ void LLVMInstructionSetDebugLoc(LLVMValueRef Inst, LLVMMetadataRef Loc); */ LLVMMetadataKind LLVMGetMetadataKind(LLVMMetadataRef Metadata); -#ifdef __cplusplus -} /* end extern "C" */ -#endif +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/Disassembler.h b/llvm/include/llvm-c/Disassembler.h index 3adcc3c47a3f..b1cb35da6687 100644 --- a/llvm/include/llvm-c/Disassembler.h +++ b/llvm/include/llvm-c/Disassembler.h @@ -16,6 +16,7 @@ #define LLVM_C_DISASSEMBLER_H #include "llvm-c/DisassemblerTypes.h" +#include "llvm-c/ExternC.h" /** * @defgroup LLVMCDisassembler Disassembler @@ -24,9 +25,7 @@ * @{ */ -#ifdef __cplusplus -extern "C" { -#endif /* !defined(__cplusplus) */ +LLVM_C_EXTERN_C_BEGIN /** * Create a disassembler for the TripleName. Symbolic disassembly is supported @@ -106,8 +105,6 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DC, uint8_t *Bytes, * @} */ -#ifdef __cplusplus -} -#endif /* !defined(__cplusplus) */ +LLVM_C_EXTERN_C_END #endif /* LLVM_C_DISASSEMBLER_H */ diff --git a/llvm/include/llvm-c/Error.h b/llvm/include/llvm-c/Error.h index 52943063c697..92f81bf38304 100644 --- a/llvm/include/llvm-c/Error.h +++ b/llvm/include/llvm-c/Error.h @@ -14,9 +14,9 @@ #ifndef LLVM_C_ERROR_H #define LLVM_C_ERROR_H -#ifdef __cplusplus -extern "C" { -#endif +#include "llvm-c/ExternC.h" + +LLVM_C_EXTERN_C_BEGIN #define LLVMErrorSuccess 0 @@ -62,8 +62,6 @@ void LLVMDisposeErrorMessage(char *ErrMsg); */ LLVMErrorTypeId LLVMGetStringErrorTypeId(void); -#ifdef __cplusplus -} -#endif +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/ErrorHandling.h b/llvm/include/llvm-c/ErrorHandling.h index 4927349d8983..c6f7ff3ed693 100644 --- a/llvm/include/llvm-c/ErrorHandling.h +++ b/llvm/include/llvm-c/ErrorHandling.h @@ -14,9 +14,9 @@ #ifndef LLVM_C_ERROR_HANDLING_H #define LLVM_C_ERROR_HANDLING_H -#ifdef __cplusplus -extern "C" { -#endif +#include "llvm-c/ExternC.h" + +LLVM_C_EXTERN_C_BEGIN typedef void (*LLVMFatalErrorHandler)(const char *Reason); @@ -42,8 +42,6 @@ void LLVMResetFatalErrorHandler(void); */ void LLVMEnablePrettyStackTrace(void); -#ifdef __cplusplus -} -#endif +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/ExecutionEngine.h b/llvm/include/llvm-c/ExecutionEngine.h index ef714cd06384..f31b97ad7623 100644 --- a/llvm/include/llvm-c/ExecutionEngine.h +++ b/llvm/include/llvm-c/ExecutionEngine.h @@ -19,13 +19,12 @@ #ifndef LLVM_C_EXECUTIONENGINE_H #define LLVM_C_EXECUTIONENGINE_H +#include "llvm-c/ExternC.h" #include "llvm-c/Target.h" #include "llvm-c/TargetMachine.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMCExecutionEngine Execution Engine @@ -193,8 +192,6 @@ LLVMJITEventListenerRef LLVMCreatePerfJITEventListener(void); * @} */ -#ifdef __cplusplus -} -#endif /* defined(__cplusplus) */ +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/ExternC.h b/llvm/include/llvm-c/ExternC.h new file mode 100644 index 000000000000..4240f7c31a3b --- /dev/null +++ b/llvm/include/llvm-c/ExternC.h @@ -0,0 +1,39 @@ +/*===- llvm-c/ExternC.h - Wrapper for 'extern "C"' ----------------*- C -*-===*\ +|* *| +|* 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 *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This file defines an 'extern "C"' wrapper *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_C_EXTERN_C_H +#define LLVM_C_EXTERN_C_H + +#ifdef __clang__ +#define LLVM_C_STRICT_PROTOTYPES_BEGIN \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic error \"-Wstrict-prototypes\"") +#define LLVM_C_STRICT_PROTOTYPES_END _Pragma("clang diagnostic pop") +#else +#define LLVM_C_STRICT_PROTOTYPES_BEGIN +#define LLVM_C_STRICT_PROTOTYPES_END +#endif + +#ifdef __cplusplus +#define LLVM_C_EXTERN_C_BEGIN \ + extern "C" { \ + LLVM_C_STRICT_PROTOTYPES_BEGIN +#define LLVM_C_EXTERN_C_END \ + LLVM_C_STRICT_PROTOTYPES_END \ + } +#else +#define LLVM_C_EXTERN_C_BEGIN LLVM_C_STRICT_PROTOTYPES_BEGIN +#define LLVM_C_EXTERN_C_END LLVM_C_STRICT_PROTOTYPES_END +#endif + +#endif diff --git a/llvm/include/llvm-c/IRReader.h b/llvm/include/llvm-c/IRReader.h index 4d0b696e9583..5a3f633c3d91 100644 --- a/llvm/include/llvm-c/IRReader.h +++ b/llvm/include/llvm-c/IRReader.h @@ -14,11 +14,10 @@ #ifndef LLVM_C_IRREADER_H #define LLVM_C_IRREADER_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * Read LLVM IR from a memory buffer and convert it into an in-memory Module @@ -33,8 +32,6 @@ LLVMBool LLVMParseIRInContext(LLVMContextRef ContextRef, LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutM, char **OutMessage); -#ifdef __cplusplus -} -#endif +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/Initialization.h b/llvm/include/llvm-c/Initialization.h index 36c41dbd8d31..0d59de8728c8 100644 --- a/llvm/include/llvm-c/Initialization.h +++ b/llvm/include/llvm-c/Initialization.h @@ -16,11 +16,10 @@ #ifndef LLVM_C_INITIALIZATION_H #define LLVM_C_INITIALIZATION_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMCInitialization Initialization Routines @@ -49,8 +48,6 @@ void LLVMInitializeTarget(LLVMPassRegistryRef R); * @} */ -#ifdef __cplusplus -} -#endif +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/LinkTimeOptimizer.h b/llvm/include/llvm-c/LinkTimeOptimizer.h index 19b4f5cf7491..9ae65b8fe5e0 100644 --- a/llvm/include/llvm-c/LinkTimeOptimizer.h +++ b/llvm/include/llvm-c/LinkTimeOptimizer.h @@ -15,9 +15,9 @@ #ifndef LLVM_C_LINKTIMEOPTIMIZER_H #define LLVM_C_LINKTIMEOPTIMIZER_H -#ifdef __cplusplus -extern "C" { -#endif +#include "llvm-c/ExternC.h" + +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMCLinkTimeOptimizer Link Time Optimization @@ -61,8 +61,6 @@ extern "C" { * @} */ -#ifdef __cplusplus -} -#endif + LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/Linker.h b/llvm/include/llvm-c/Linker.h index 908513041661..1ad9cc958753 100644 --- a/llvm/include/llvm-c/Linker.h +++ b/llvm/include/llvm-c/Linker.h @@ -14,11 +14,10 @@ #ifndef LLVM_C_LINKER_H #define LLVM_C_LINKER_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /* This enum is provided for backwards-compatibility only. It has no effect. */ typedef enum { @@ -34,8 +33,6 @@ typedef enum { */ LLVMBool LLVMLinkModules2(LLVMModuleRef Dest, LLVMModuleRef Src); -#ifdef __cplusplus -} -#endif +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/Object.h b/llvm/include/llvm-c/Object.h index 1e9b703a68ff..9a9596aaa08c 100644 --- a/llvm/include/llvm-c/Object.h +++ b/llvm/include/llvm-c/Object.h @@ -19,12 +19,11 @@ #ifndef LLVM_C_OBJECT_H #define LLVM_C_OBJECT_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" #include "llvm/Config/llvm-config.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMCObject Object file reading and writing @@ -226,8 +225,6 @@ LLVMBool LLVMIsSymbolIteratorAtEnd(LLVMObjectFileRef ObjectFile, * @} */ -#ifdef __cplusplus -} -#endif /* defined(__cplusplus) */ +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/OrcBindings.h b/llvm/include/llvm-c/OrcBindings.h index 9e92371b5a3a..11cdade7c26f 100644 --- a/llvm/include/llvm-c/OrcBindings.h +++ b/llvm/include/llvm-c/OrcBindings.h @@ -23,12 +23,11 @@ #define LLVM_C_ORCBINDINGS_H #include "llvm-c/Error.h" +#include "llvm-c/ExternC.h" #include "llvm-c/Object.h" #include "llvm-c/TargetMachine.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN typedef struct LLVMOrcOpaqueJITStack *LLVMOrcJITStackRef; typedef uint64_t LLVMOrcModuleHandle; @@ -165,8 +164,6 @@ void LLVMOrcRegisterJITEventListener(LLVMOrcJITStackRef JITStack, LLVMJITEventLi */ void LLVMOrcUnregisterJITEventListener(LLVMOrcJITStackRef JITStack, LLVMJITEventListenerRef L); -#ifdef __cplusplus -} -#endif /* extern "C" */ +LLVM_C_EXTERN_C_END #endif /* LLVM_C_ORCBINDINGS_H */ diff --git a/llvm/include/llvm-c/Remarks.h b/llvm/include/llvm-c/Remarks.h index 5444aebddd60..ffe647a6554a 100644 --- a/llvm/include/llvm-c/Remarks.h +++ b/llvm/include/llvm-c/Remarks.h @@ -15,14 +15,16 @@ #ifndef LLVM_C_REMARKS_H #define LLVM_C_REMARKS_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" #ifdef __cplusplus #include <cstddef> -extern "C" { #else #include <stddef.h> #endif /* !defined(__cplusplus) */ +LLVM_C_EXTERN_C_BEGIN + /** * @defgroup LLVMCREMARKS Remarks * @ingroup LLVMC @@ -337,8 +339,6 @@ extern uint32_t LLVMRemarkVersion(void); * @} // endgoup LLVMCREMARKS */ -#ifdef __cplusplus -} -#endif /* !defined(__cplusplus) */ +LLVM_C_EXTERN_C_END #endif /* LLVM_C_REMARKS_H */ diff --git a/llvm/include/llvm-c/Support.h b/llvm/include/llvm-c/Support.h index 097f784246c5..866df32efa98 100644 --- a/llvm/include/llvm-c/Support.h +++ b/llvm/include/llvm-c/Support.h @@ -15,11 +15,10 @@ #define LLVM_C_SUPPORT_H #include "llvm-c/DataTypes.h" +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * This function permanently loads the dynamic library at the given path. @@ -58,8 +57,6 @@ void *LLVMSearchForAddressOfSymbol(const char *symbolName); */ void LLVMAddSymbol(const char *symbolName, void *symbolValue); -#ifdef __cplusplus -} -#endif +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/Target.h b/llvm/include/llvm-c/Target.h index 4ef641eaf232..518b46d55bc3 100644 --- a/llvm/include/llvm-c/Target.h +++ b/llvm/include/llvm-c/Target.h @@ -19,12 +19,11 @@ #ifndef LLVM_C_TARGET_H #define LLVM_C_TARGET_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" #include "llvm/Config/llvm-config.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMCTarget Target information @@ -288,8 +287,6 @@ unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef TD, * @} */ -#ifdef __cplusplus -} -#endif /* defined(__cplusplus) */ +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/TargetMachine.h b/llvm/include/llvm-c/TargetMachine.h index 28d7c096871e..f82edd948b59 100644 --- a/llvm/include/llvm-c/TargetMachine.h +++ b/llvm/include/llvm-c/TargetMachine.h @@ -19,12 +19,12 @@ #ifndef LLVM_C_TARGETMACHINE_H #define LLVM_C_TARGETMACHINE_H +#include "llvm-c/ExternC.h" #include "llvm-c/Target.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN + typedef struct LLVMOpaqueTargetMachine *LLVMTargetMachineRef; typedef struct LLVMTarget *LLVMTargetRef; @@ -156,8 +156,6 @@ char* LLVMGetHostCPUFeatures(void); /** Adds the target-specific analysis passes to the pass manager. */ void LLVMAddAnalysisPasses(LLVMTargetMachineRef T, LLVMPassManagerRef PM); -#ifdef __cplusplus -} -#endif +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/Transforms/AggressiveInstCombine.h b/llvm/include/llvm-c/Transforms/AggressiveInstCombine.h index c0b0141c3da1..db061a7ad1fc 100644 --- a/llvm/include/llvm-c/Transforms/AggressiveInstCombine.h +++ b/llvm/include/llvm-c/Transforms/AggressiveInstCombine.h @@ -15,11 +15,10 @@ #ifndef LLVM_C_TRANSFORMS_AGGRESSIVEINSTCOMBINE_H #define LLVM_C_TRANSFORMS_AGGRESSIVEINSTCOMBINE_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMCTransformsAggressiveInstCombine Aggressive Instruction Combining transformations @@ -35,9 +34,7 @@ void LLVMAddAggressiveInstCombinerPass(LLVMPassManagerRef PM); * @} */ -#ifdef __cplusplus -} -#endif /* defined(__cplusplus) */ +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/Transforms/Coroutines.h b/llvm/include/llvm-c/Transforms/Coroutines.h index 227e7cf0a360..15798af7d661 100644 --- a/llvm/include/llvm-c/Transforms/Coroutines.h +++ b/llvm/include/llvm-c/Transforms/Coroutines.h @@ -19,11 +19,10 @@ #ifndef LLVM_C_TRANSFORMS_COROUTINES_H #define LLVM_C_TRANSFORMS_COROUTINES_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMCTransformsCoroutines Coroutine transformations @@ -32,24 +31,22 @@ extern "C" { * @{ */ -/** See llvm::createCoroEarlyPass function. */ +/** See llvm::createCoroEarlyLegacyPass function. */ void LLVMAddCoroEarlyPass(LLVMPassManagerRef PM); -/** See llvm::createCoroSplitPass function. */ +/** See llvm::createCoroSplitLegacyPass function. */ void LLVMAddCoroSplitPass(LLVMPassManagerRef PM); -/** See llvm::createCoroElidePass function. */ +/** See llvm::createCoroElideLegacyPass function. */ void LLVMAddCoroElidePass(LLVMPassManagerRef PM); -/** See llvm::createCoroCleanupPass function. */ +/** See llvm::createCoroCleanupLegacyPass function. */ void LLVMAddCoroCleanupPass(LLVMPassManagerRef PM); /** * @} */ -#ifdef __cplusplus -} -#endif /* defined(__cplusplus) */ +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/Transforms/IPO.h b/llvm/include/llvm-c/Transforms/IPO.h index 51d007581283..cde3d2460920 100644 --- a/llvm/include/llvm-c/Transforms/IPO.h +++ b/llvm/include/llvm-c/Transforms/IPO.h @@ -15,11 +15,10 @@ #ifndef LLVM_C_TRANSFORMS_IPO_H #define LLVM_C_TRANSFORMS_IPO_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMCTransformsIPO Interprocedural transformations @@ -95,8 +94,6 @@ void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM); * @} */ -#ifdef __cplusplus -} -#endif /* defined(__cplusplus) */ +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/Transforms/InstCombine.h b/llvm/include/llvm-c/Transforms/InstCombine.h index 166f278d9a69..ebe17d667061 100644 --- a/llvm/include/llvm-c/Transforms/InstCombine.h +++ b/llvm/include/llvm-c/Transforms/InstCombine.h @@ -15,11 +15,10 @@ #ifndef LLVM_C_TRANSFORMS_INSTCOMBINE_H #define LLVM_C_TRANSFORMS_INSTCOMBINE_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMCTransformsInstCombine Instruction Combining transformations @@ -35,9 +34,7 @@ void LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM); * @} */ -#ifdef __cplusplus -} -#endif /* defined(__cplusplus) */ +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/Transforms/PassManagerBuilder.h b/llvm/include/llvm-c/Transforms/PassManagerBuilder.h index d164c00d49c5..6e13e18e063b 100644 --- a/llvm/include/llvm-c/Transforms/PassManagerBuilder.h +++ b/llvm/include/llvm-c/Transforms/PassManagerBuilder.h @@ -14,13 +14,12 @@ #ifndef LLVM_C_TRANSFORMS_PASSMANAGERBUILDER_H #define LLVM_C_TRANSFORMS_PASSMANAGERBUILDER_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" typedef struct LLVMOpaquePassManagerBuilder *LLVMPassManagerBuilderRef; -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMCTransformsPassManagerBuilder Pass manager builder @@ -83,8 +82,6 @@ void LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB, * @} */ -#ifdef __cplusplus -} -#endif +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/Transforms/Scalar.h b/llvm/include/llvm-c/Transforms/Scalar.h index 6f3a3d8b3750..93d79a205195 100644 --- a/llvm/include/llvm-c/Transforms/Scalar.h +++ b/llvm/include/llvm-c/Transforms/Scalar.h @@ -19,11 +19,10 @@ #ifndef LLVM_C_TRANSFORMS_SCALAR_H #define LLVM_C_TRANSFORMS_SCALAR_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMCTransformsScalar Scalar transformations @@ -166,8 +165,6 @@ void LLVMAddUnifyFunctionExitNodesPass(LLVMPassManagerRef PM); * @} */ -#ifdef __cplusplus -} -#endif /* defined(__cplusplus) */ +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/Transforms/Utils.h b/llvm/include/llvm-c/Transforms/Utils.h index 63594abfa460..30d1ae63de1d 100644 --- a/llvm/include/llvm-c/Transforms/Utils.h +++ b/llvm/include/llvm-c/Transforms/Utils.h @@ -19,11 +19,10 @@ #ifndef LLVM_C_TRANSFORMS_UTILS_H #define LLVM_C_TRANSFORMS_UTILS_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMCTransformsUtils Transformation Utilities @@ -45,9 +44,7 @@ void LLVMAddAddDiscriminatorsPass(LLVMPassManagerRef PM); * @} */ -#ifdef __cplusplus -} -#endif /* defined(__cplusplus) */ +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/Transforms/Vectorize.h b/llvm/include/llvm-c/Transforms/Vectorize.h index e383481fe4f4..0de458381399 100644 --- a/llvm/include/llvm-c/Transforms/Vectorize.h +++ b/llvm/include/llvm-c/Transforms/Vectorize.h @@ -20,11 +20,10 @@ #ifndef LLVM_C_TRANSFORMS_VECTORIZE_H #define LLVM_C_TRANSFORMS_VECTORIZE_H +#include "llvm-c/ExternC.h" #include "llvm-c/Types.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMCTransformsVectorize Vectorization transformations @@ -43,8 +42,6 @@ void LLVMAddSLPVectorizePass(LLVMPassManagerRef PM); * @} */ -#ifdef __cplusplus -} -#endif /* defined(__cplusplus) */ +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/Types.h b/llvm/include/llvm-c/Types.h index 612c7d3eff32..4e02498a2348 100644 --- a/llvm/include/llvm-c/Types.h +++ b/llvm/include/llvm-c/Types.h @@ -15,10 +15,9 @@ #define LLVM_C_TYPES_H #include "llvm-c/DataTypes.h" +#include "llvm-c/ExternC.h" -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * @defgroup LLVMCSupportTypes Types and Enumerations @@ -172,8 +171,6 @@ typedef struct LLVMOpaqueBinary *LLVMBinaryRef; * @} */ -#ifdef __cplusplus -} -#endif +LLVM_C_EXTERN_C_END #endif diff --git a/llvm/include/llvm-c/lto.h b/llvm/include/llvm-c/lto.h index 41e6067cf44f..97a8f4823320 100644 --- a/llvm/include/llvm-c/lto.h +++ b/llvm/include/llvm-c/lto.h @@ -16,6 +16,8 @@ #ifndef LLVM_C_LTO_H #define LLVM_C_LTO_H +#include "llvm-c/ExternC.h" + #ifdef __cplusplus #include <cstddef> #else @@ -44,7 +46,7 @@ typedef bool lto_bool_t; * @{ */ -#define LTO_API_VERSION 25 +#define LTO_API_VERSION 26 /** * \since prior to LTO_API_VERSION=3 @@ -98,9 +100,7 @@ typedef struct LLVMOpaqueLTOCodeGenerator *lto_code_gen_t; /** opaque reference to a thin code generator */ typedef struct LLVMOpaqueThinLTOCodeGenerator *thinlto_code_gen_t; -#ifdef __cplusplus -extern "C" { -#endif +LLVM_C_EXTERN_C_BEGIN /** * Returns a printable string. @@ -514,12 +514,25 @@ lto_api_version(void); /** * Sets options to help debug codegen bugs. * + * This function takes one or more options separated by spaces. + * Warning: passing file paths through this function may confuse the argument + * parser if the paths contain spaces. + * * \since prior to LTO_API_VERSION=3 */ extern void lto_codegen_debug_options(lto_code_gen_t cg, const char *); /** + * Same as the previous function, but takes every option separately through an + * array. + * + * \since prior to LTO_API_VERSION=26 + */ +extern void lto_codegen_debug_options_array(lto_code_gen_t cg, + const char *const *, int number); + +/** * Initializes LLVM disassemblers. * FIXME: This doesn't really belong here. * @@ -900,8 +913,6 @@ extern void thinlto_codegen_set_cache_size_files(thinlto_code_gen_t cg, * @} // endgroup LLVMCTLTO_CACHING */ -#ifdef __cplusplus -} -#endif +LLVM_C_EXTERN_C_END #endif /* LLVM_C_LTO_H */ diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h index 1c4969733791..ed25b2cd89f1 100644 --- a/llvm/include/llvm/ADT/APFloat.h +++ b/llvm/include/llvm/ADT/APFloat.h @@ -38,6 +38,7 @@ class StringRef; class APFloat; class raw_ostream; +template <typename T> class Expected; template <typename T> class SmallVectorImpl; /// Enum that represents what fraction of the LSB truncated bits of an fp number @@ -143,7 +144,7 @@ struct APFloatBase { static const unsigned integerPartWidth = APInt::APINT_BITS_PER_WORD; /// A signed type to represent a floating point numbers unbiased exponent. - typedef signed short ExponentType; + typedef int32_t ExponentType; /// \name Floating Point Semantics. /// @{ @@ -299,7 +300,7 @@ public: bool, roundingMode); opStatus convertFromZeroExtendedInteger(const integerPart *, unsigned int, bool, roundingMode); - opStatus convertFromString(StringRef, roundingMode); + Expected<opStatus> convertFromString(StringRef, roundingMode); APInt bitcastToAPInt() const; double convertToDouble() const; float convertToFloat() const; @@ -486,7 +487,8 @@ private: integerPart addSignificand(const IEEEFloat &); integerPart subtractSignificand(const IEEEFloat &, integerPart); lostFraction addOrSubtractSignificand(const IEEEFloat &, bool subtract); - lostFraction multiplySignificand(const IEEEFloat &, const IEEEFloat *); + lostFraction multiplySignificand(const IEEEFloat &, IEEEFloat); + lostFraction multiplySignificand(const IEEEFloat&); lostFraction divideSignificand(const IEEEFloat &); void incrementSignificand(); void initialize(const fltSemantics *); @@ -525,8 +527,8 @@ private: bool *) const; opStatus convertFromUnsignedParts(const integerPart *, unsigned int, roundingMode); - opStatus convertFromHexadecimalString(StringRef, roundingMode); - opStatus convertFromDecimalString(StringRef, roundingMode); + Expected<opStatus> convertFromHexadecimalString(StringRef, roundingMode); + Expected<opStatus> convertFromDecimalString(StringRef, roundingMode); char *convertNormalToHexString(char *, unsigned int, bool, roundingMode) const; opStatus roundSignificandWithExponent(const integerPart *, unsigned int, int, @@ -648,7 +650,7 @@ public: cmpResult compare(const DoubleAPFloat &RHS) const; bool bitwiseIsEqual(const DoubleAPFloat &RHS) const; APInt bitcastToAPInt() const; - opStatus convertFromString(StringRef, roundingMode); + Expected<opStatus> convertFromString(StringRef, roundingMode); opStatus next(bool nextDown); opStatus convertToInteger(MutableArrayRef<integerPart> Input, @@ -851,6 +853,9 @@ public: APFloat(const fltSemantics &Semantics) : U(Semantics) {} APFloat(const fltSemantics &Semantics, StringRef S); APFloat(const fltSemantics &Semantics, integerPart I) : U(Semantics, I) {} + template <typename T, typename = typename std::enable_if< + std::is_floating_point<T>::value>::type> + APFloat(const fltSemantics &Semantics, T V) = delete; // TODO: Remove this constructor. This isn't faster than the first one. APFloat(const fltSemantics &Semantics, uninitializedTag) : U(Semantics, uninitialized) {} @@ -1105,7 +1110,7 @@ public: APFLOAT_DISPATCH_ON_SEMANTICS( convertFromZeroExtendedInteger(Input, InputSize, IsSigned, RM)); } - opStatus convertFromString(StringRef, roundingMode); + Expected<opStatus> convertFromString(StringRef, roundingMode); APInt bitcastToAPInt() const { APFLOAT_DISPATCH_ON_SEMANTICS(bitcastToAPInt()); } diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index 8dce5a621bb3..0791a6d686a3 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/include/llvm/ADT/APInt.h @@ -389,6 +389,11 @@ public: /// \returns true if this APInt is positive. bool isStrictlyPositive() const { return isNonNegative() && !isNullValue(); } + /// Determine if this APInt Value is non-positive (<= 0). + /// + /// \returns true if this APInt is non-positive. + bool isNonPositive() const { return !isStrictlyPositive(); } + /// Determine if all bits are set /// /// This checks to see if the value has all bits of the APInt are set or not. @@ -595,8 +600,8 @@ public: /// Constructs an APInt value that has a contiguous range of bits set. The /// bits from loBit (inclusive) to hiBit (exclusive) will be set. All other /// bits will be zero. For example, with parameters(32, 0, 16) you would get - /// 0x0000FFFF. If hiBit is less than loBit then the set bits "wrap". For - /// example, with parameters (32, 28, 4), you would get 0xF000000F. + /// 0x0000FFFF. Please call getBitsSetWithWrap if \p loBit may be greater than + /// \p hiBit. /// /// \param numBits the intended bit width of the result /// \param loBit the index of the lowest bit set. @@ -604,11 +609,23 @@ public: /// /// \returns An APInt value with the requested bits set. static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit) { + assert(loBit <= hiBit && "loBit greater than hiBit"); APInt Res(numBits, 0); Res.setBits(loBit, hiBit); return Res; } + /// Wrap version of getBitsSet. + /// If \p hiBit is no less than \p loBit, this is same with getBitsSet. + /// If \p hiBit is less than \p loBit, the set bits "wrap". For example, with + /// parameters (32, 28, 4), you would get 0xF000000F. + static APInt getBitsSetWithWrap(unsigned numBits, unsigned loBit, + unsigned hiBit) { + APInt Res(numBits, 0); + Res.setBitsWithWrap(loBit, hiBit); + return Res; + } + /// Get a value with upper bits starting at loBit set. /// /// Constructs an APInt value that has a contiguous range of bits set. The @@ -1109,6 +1126,10 @@ public: APInt uadd_sat(const APInt &RHS) const; APInt ssub_sat(const APInt &RHS) const; APInt usub_sat(const APInt &RHS) const; + APInt smul_sat(const APInt &RHS) const; + APInt umul_sat(const APInt &RHS) const; + APInt sshl_sat(const APInt &RHS) const; + APInt ushl_sat(const APInt &RHS) const; /// Array-indexing support. /// @@ -1245,7 +1266,7 @@ public: /// \returns true if *this <= RHS when considered signed. bool sle(uint64_t RHS) const { return !sgt(RHS); } - /// Unsigned greather than comparison + /// Unsigned greater than comparison /// /// Regards both *this and RHS as unsigned quantities and compares them for /// the validity of the greater-than relationship. @@ -1264,7 +1285,7 @@ public: return (!isSingleWord() && getActiveBits() > 64) || getZExtValue() > RHS; } - /// Signed greather than comparison + /// Signed greater than comparison /// /// Regards both *this and RHS as signed quantities and compares them for the /// validity of the greater-than relationship. @@ -1342,6 +1363,19 @@ public: /// that is greater than or equal to the current width. APInt trunc(unsigned width) const; + /// Truncate to new width with unsigned saturation. + /// + /// If the APInt, treated as unsigned integer, can be losslessly truncated to + /// the new bitwidth, then return truncated APInt. Else, return max value. + APInt truncUSat(unsigned width) const; + + /// Truncate to new width with signed saturation. + /// + /// If this APInt, treated as signed integer, can be losslessly truncated to + /// the new bitwidth, then return truncated APInt. Else, return either + /// signed min value if the APInt was negative, or signed max value. + APInt truncSSat(unsigned width) const; + /// Sign extend to a new width. /// /// This operation sign extends the APInt to a new width. If the high order @@ -1414,6 +1448,21 @@ public: } /// Set the bits from loBit (inclusive) to hiBit (exclusive) to 1. + /// This function handles "wrap" case when \p loBit > \p hiBit, and calls + /// setBits when \p loBit <= \p hiBit. + void setBitsWithWrap(unsigned loBit, unsigned hiBit) { + assert(hiBit <= BitWidth && "hiBit out of range"); + assert(loBit <= BitWidth && "loBit out of range"); + if (loBit <= hiBit) { + setBits(loBit, hiBit); + return; + } + setLowBits(hiBit); + setHighBits(BitWidth - loBit); + } + + /// Set the bits from loBit (inclusive) to hiBit (exclusive) to 1. + /// This function handles case when \p loBit <= \p hiBit. void setBits(unsigned loBit, unsigned hiBit) { assert(hiBit <= BitWidth && "hiBit out of range"); assert(loBit <= BitWidth && "loBit out of range"); @@ -1723,13 +1772,13 @@ public: return BitsToDouble(getWord(0)); } - /// Converts APInt bits to a double + /// Converts APInt bits to a float /// /// The conversion does not do a translation from integer to float, it just /// re-interprets the bits as a float. Note that it is valid to do this on /// any bit width. Exactly 32 bits will be translated. float bitsToFloat() const { - return BitsToFloat(getWord(0)); + return BitsToFloat(static_cast<uint32_t>(getWord(0))); } /// Converts a double to APInt bits. @@ -2158,7 +2207,7 @@ inline float RoundAPIntToFloat(const APInt &APIVal) { /// Converts the given APInt to a float value. /// -/// Treast the APInt as a signed value for conversion purposes. +/// Treats the APInt as a signed value for conversion purposes. inline float RoundSignedAPIntToFloat(const APInt &APIVal) { return float(APIVal.signedRoundToDouble()); } @@ -2194,7 +2243,7 @@ APInt RoundingSDiv(const APInt &A, const APInt &B, APInt::Rounding RM); /// count as an overflow, but here we want to allow values to decrease /// and increase as long as they are within the same interval. /// Specifically, adding of two negative numbers should not cause an -/// overflow (as long as the magnitude does not exceed the bith width). +/// overflow (as long as the magnitude does not exceed the bit width). /// On the other hand, given a positive number, adding a negative /// number to it can give a negative result, which would cause the /// value to go from [-2^BW, 0) to [0, 2^BW). In that sense, zero is @@ -2216,6 +2265,12 @@ APInt RoundingSDiv(const APInt &A, const APInt &B, APInt::Rounding RM); /// coefficients. Optional<APInt> SolveQuadraticEquationWrap(APInt A, APInt B, APInt C, unsigned RangeWidth); + +/// Compare two values, and if they are different, return the position of the +/// most significant bit that is different in the values. +Optional<unsigned> GetMostSignificantDifferentBit(const APInt &A, + const APInt &B); + } // End of APIntOps namespace // See friend declaration above. This additional declaration is required in diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h index f6455d3fa412..3d22442918cd 100644 --- a/llvm/include/llvm/ADT/ArrayRef.h +++ b/llvm/include/llvm/ADT/ArrayRef.h @@ -97,9 +97,19 @@ namespace llvm { /*implicit*/ constexpr ArrayRef(const T (&Arr)[N]) : Data(Arr), Length(N) {} /// Construct an ArrayRef from a std::initializer_list. +#if LLVM_GNUC_PREREQ(9, 0, 0) +// Disable gcc's warning in this constructor as it generates an enormous amount +// of messages. Anyone using ArrayRef should already be aware of the fact that +// it does not do lifetime extension. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winit-list-lifetime" +#endif /*implicit*/ ArrayRef(const std::initializer_list<T> &Vec) : Data(Vec.begin() == Vec.end() ? (T*)nullptr : Vec.begin()), Length(Vec.size()) {} +#if LLVM_GNUC_PREREQ(9, 0, 0) +#pragma GCC diagnostic pop +#endif /// Construct an ArrayRef<const T*> from ArrayRef<T*>. This uses SFINAE to /// ensure that only ArrayRefs of pointers can be converted. diff --git a/llvm/include/llvm/ADT/BitVector.h b/llvm/include/llvm/ADT/BitVector.h index fabf5d9cd348..5284be8c4a02 100644 --- a/llvm/include/llvm/ADT/BitVector.h +++ b/llvm/include/llvm/ADT/BitVector.h @@ -71,7 +71,7 @@ public: }; class BitVector { - typedef unsigned long BitWord; + typedef uintptr_t BitWord; enum { BITWORD_SIZE = (unsigned)sizeof(BitWord) * CHAR_BIT }; @@ -187,12 +187,12 @@ public: /// all - Returns true if all bits are set. bool all() const { for (unsigned i = 0; i < Size / BITWORD_SIZE; ++i) - if (Bits[i] != ~0UL) + if (Bits[i] != ~BitWord(0)) return false; // If bits remain check that they are ones. The unused bits are always zero. if (unsigned Remainder = Size % BITWORD_SIZE) - return Bits[Size / BITWORD_SIZE] == (1UL << Remainder) - 1; + return Bits[Size / BITWORD_SIZE] == (BitWord(1) << Remainder) - 1; return true; } @@ -285,7 +285,7 @@ public: unsigned LastBit = (End - 1) % BITWORD_SIZE; Copy |= maskTrailingZeros<BitWord>(LastBit + 1); } - if (Copy != ~0UL) { + if (Copy != ~BitWord(0)) { unsigned Result = i * BITWORD_SIZE + countTrailingOnes(Copy); return Result < size() ? Result : -1; } @@ -317,7 +317,7 @@ public: Copy |= maskTrailingOnes<BitWord>(FirstBit); } - if (Copy != ~0UL) { + if (Copy != ~BitWord(0)) { unsigned Result = (CurrentWord + 1) * BITWORD_SIZE - countLeadingOnes(Copy) - 1; return Result < Size ? Result : -1; @@ -414,21 +414,21 @@ public: if (I == E) return *this; if (I / BITWORD_SIZE == E / BITWORD_SIZE) { - BitWord EMask = 1UL << (E % BITWORD_SIZE); - BitWord IMask = 1UL << (I % BITWORD_SIZE); + BitWord EMask = BitWord(1) << (E % BITWORD_SIZE); + BitWord IMask = BitWord(1) << (I % BITWORD_SIZE); BitWord Mask = EMask - IMask; Bits[I / BITWORD_SIZE] |= Mask; return *this; } - BitWord PrefixMask = ~0UL << (I % BITWORD_SIZE); + BitWord PrefixMask = ~BitWord(0) << (I % BITWORD_SIZE); Bits[I / BITWORD_SIZE] |= PrefixMask; I = alignTo(I, BITWORD_SIZE); for (; I + BITWORD_SIZE <= E; I += BITWORD_SIZE) - Bits[I / BITWORD_SIZE] = ~0UL; + Bits[I / BITWORD_SIZE] = ~BitWord(0); - BitWord PostfixMask = (1UL << (E % BITWORD_SIZE)) - 1; + BitWord PostfixMask = (BitWord(1) << (E % BITWORD_SIZE)) - 1; if (I < E) Bits[I / BITWORD_SIZE] |= PostfixMask; @@ -453,21 +453,21 @@ public: if (I == E) return *this; if (I / BITWORD_SIZE == E / BITWORD_SIZE) { - BitWord EMask = 1UL << (E % BITWORD_SIZE); - BitWord IMask = 1UL << (I % BITWORD_SIZE); + BitWord EMask = BitWord(1) << (E % BITWORD_SIZE); + BitWord IMask = BitWord(1) << (I % BITWORD_SIZE); BitWord Mask = EMask - IMask; Bits[I / BITWORD_SIZE] &= ~Mask; return *this; } - BitWord PrefixMask = ~0UL << (I % BITWORD_SIZE); + BitWord PrefixMask = ~BitWord(0) << (I % BITWORD_SIZE); Bits[I / BITWORD_SIZE] &= ~PrefixMask; I = alignTo(I, BITWORD_SIZE); for (; I + BITWORD_SIZE <= E; I += BITWORD_SIZE) - Bits[I / BITWORD_SIZE] = 0UL; + Bits[I / BITWORD_SIZE] = BitWord(0); - BitWord PostfixMask = (1UL << (E % BITWORD_SIZE)) - 1; + BitWord PostfixMask = (BitWord(1) << (E % BITWORD_SIZE)) - 1; if (I < E) Bits[I / BITWORD_SIZE] &= ~PostfixMask; @@ -868,7 +868,7 @@ private: // Then set any stray high bits of the last used word. unsigned ExtraBits = Size % BITWORD_SIZE; if (ExtraBits) { - BitWord ExtraBitMask = ~0UL << ExtraBits; + BitWord ExtraBitMask = ~BitWord(0) << ExtraBits; if (t) Bits[UsedWords-1] |= ExtraBitMask; else diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h index 948a6e6bfb38..148d319c8603 100644 --- a/llvm/include/llvm/ADT/DenseMap.h +++ b/llvm/include/llvm/ADT/DenseMap.h @@ -1006,13 +1006,10 @@ public: } void grow(unsigned AtLeast) { - if (AtLeast >= InlineBuckets) + if (AtLeast > InlineBuckets) AtLeast = std::max<unsigned>(64, NextPowerOf2(AtLeast-1)); if (Small) { - if (AtLeast < InlineBuckets) - return; // Nothing to do. - // First move the inline buckets into a temporary storage. AlignedCharArrayUnion<BucketT[InlineBuckets]> TmpStorage; BucketT *TmpBegin = reinterpret_cast<BucketT *>(TmpStorage.buffer); @@ -1035,10 +1032,13 @@ public: P->getFirst().~KeyT(); } - // Now make this map use the large rep, and move all the entries back - // into it. - Small = false; - new (getLargeRep()) LargeRep(allocateBuckets(AtLeast)); + // AtLeast == InlineBuckets can happen if there are many tombstones, + // and grow() is used to remove them. Usually we always switch to the + // large rep here. + if (AtLeast > InlineBuckets) { + Small = false; + new (getLargeRep()) LargeRep(allocateBuckets(AtLeast)); + } this->moveFromOldBuckets(TmpBegin, TmpEnd); return; } diff --git a/llvm/include/llvm/ADT/DirectedGraph.h b/llvm/include/llvm/ADT/DirectedGraph.h index f6a358d99cd2..cfe98e178a91 100644 --- a/llvm/include/llvm/ADT/DirectedGraph.h +++ b/llvm/include/llvm/ADT/DirectedGraph.h @@ -48,6 +48,9 @@ public: static_cast<const DGEdge<NodeType, EdgeType> &>(*this).getTargetNode()); } + /// Set the target node this edge connects to. + void setTargetNode(const NodeType &N) { TargetNode = N; } + protected: // As the default implementation use address comparison for equality. bool isEqualTo(const EdgeType &E) const { return this == &E; } diff --git a/llvm/include/llvm/ADT/EnumeratedArray.h b/llvm/include/llvm/ADT/EnumeratedArray.h new file mode 100644 index 000000000000..a9528115618c --- /dev/null +++ b/llvm/include/llvm/ADT/EnumeratedArray.h @@ -0,0 +1,48 @@ +//===- llvm/ADT/EnumeratedArray.h - Enumerated Array-------------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// This file defines an array type that can be indexed using scoped enum values. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ADT_ENUMERATEDARRAY_H +#define LLVM_ADT_ENUMERATEDARRAY_H + +#include <cassert> + +namespace llvm { + +template <typename ValueType, typename Enumeration, + Enumeration LargestEnum = Enumeration::Last, typename IndexType = int, + IndexType Size = 1 + static_cast<IndexType>(LargestEnum)> +class EnumeratedArray { +public: + EnumeratedArray() = default; + EnumeratedArray(ValueType V) { + for (IndexType IX = 0; IX < Size; ++IX) { + Underlying[IX] = V; + } + } + inline const ValueType &operator[](const Enumeration Index) const { + auto IX = static_cast<const IndexType>(Index); + assert(IX >= 0 && IX < Size && "Index is out of bounds."); + return Underlying[IX]; + } + inline ValueType &operator[](const Enumeration Index) { + return const_cast<ValueType &>( + static_cast<const EnumeratedArray<ValueType, Enumeration, LargestEnum, + IndexType, Size> &>(*this)[Index]); + } + +private: + ValueType Underlying[Size]; +}; + +} // namespace llvm + +#endif // LLVM_ADT_ENUMERATEDARRAY_H diff --git a/llvm/include/llvm/ADT/FloatingPointMode.h b/llvm/include/llvm/ADT/FloatingPointMode.h new file mode 100644 index 000000000000..670b2368da9f --- /dev/null +++ b/llvm/include/llvm/ADT/FloatingPointMode.h @@ -0,0 +1,62 @@ +//===- llvm/Support/FloatingPointMode.h -------------------------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// Utilities for dealing with flags related to floating point mode controls. +// +//===----------------------------------------------------------------------===/ + +#ifndef LLVM_FLOATINGPOINTMODE_H +#define LLVM_FLOATINGPOINTMODE_H + +#include "llvm/ADT/StringSwitch.h" + +namespace llvm { + +/// Represent handled modes for denormal (aka subnormal) modes in the floating +/// point environment. +enum class DenormalMode { + Invalid = -1, + + /// IEEE-754 denormal numbers preserved. + IEEE, + + /// The sign of a flushed-to-zero number is preserved in the sign of 0 + PreserveSign, + + /// Denormals are flushed to positive zero. + PositiveZero +}; + +/// Parse the expected names from the denormal-fp-math attribute. +inline DenormalMode parseDenormalFPAttribute(StringRef Str) { + // Assume ieee on unspecified attribute. + return StringSwitch<DenormalMode>(Str) + .Cases("", "ieee", DenormalMode::IEEE) + .Case("preserve-sign", DenormalMode::PreserveSign) + .Case("positive-zero", DenormalMode::PositiveZero) + .Default(DenormalMode::Invalid); +} + +/// Return the name used for the denormal handling mode used by the the +/// expected names from the denormal-fp-math attribute. +inline StringRef denormalModeName(DenormalMode Mode) { + switch (Mode) { + case DenormalMode::IEEE: + return "ieee"; + case DenormalMode::PreserveSign: + return "preserve-sign"; + case DenormalMode::PositiveZero: + return "positive-zero"; + default: + return ""; + } +} + +} + +#endif // LLVM_FLOATINGPOINTMODE_H diff --git a/llvm/include/llvm/ADT/FoldingSet.h b/llvm/include/llvm/ADT/FoldingSet.h index d5837e51bcfc..4968b1ea7780 100644 --- a/llvm/include/llvm/ADT/FoldingSet.h +++ b/llvm/include/llvm/ADT/FoldingSet.h @@ -85,17 +85,17 @@ namespace llvm { /// /// MyNode *M = MyFoldingSet.FindNodeOrInsertPos(ID, InsertPoint); /// -/// If found then M with be non-NULL, else InsertPoint will point to where it +/// If found then M will be non-NULL, else InsertPoint will point to where it /// should be inserted using InsertNode. /// -/// 3) If you get a NULL result from FindNodeOrInsertPos then you can as a new -/// node with FindNodeOrInsertPos; +/// 3) If you get a NULL result from FindNodeOrInsertPos then you can insert a +/// new node with InsertNode; /// -/// InsertNode(N, InsertPoint); +/// MyFoldingSet.InsertNode(M, InsertPoint); /// /// 4) Finally, if you want to remove a node from the folding set call; /// -/// bool WasRemoved = RemoveNode(N); +/// bool WasRemoved = MyFoldingSet.RemoveNode(M); /// /// The result indicates whether the node existed in the folding set. diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h index b22606bdb518..adcc5cf54da9 100644 --- a/llvm/include/llvm/ADT/Hashing.h +++ b/llvm/include/llvm/ADT/Hashing.h @@ -45,6 +45,7 @@ #define LLVM_ADT_HASHING_H #include "llvm/Support/DataTypes.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/SwapByteOrder.h" #include "llvm/Support/type_traits.h" #include <algorithm> @@ -256,7 +257,7 @@ inline uint64_t hash_short(const char *s, size_t length, uint64_t seed) { /// Currently, the algorithm for computing hash codes is based on CityHash and /// keeps 56 bytes of arbitrary state. struct hash_state { - uint64_t h0, h1, h2, h3, h4, h5, h6; + uint64_t h0 = 0, h1 = 0, h2 = 0, h3 = 0, h4 = 0, h5 = 0, h6 = 0; /// Create a new hash_state structure and initialize it based on the /// seed and the first 64-byte chunk. @@ -491,7 +492,7 @@ namespace detail { /// useful at minimizing the code in the recursive calls to ease the pain /// caused by a lack of variadic functions. struct hash_combine_recursive_helper { - char buffer[64]; + char buffer[64] = {}; hash_state state; const uint64_t seed; @@ -539,7 +540,7 @@ public: // store types smaller than the buffer. if (!store_and_advance(buffer_ptr, buffer_end, data, partial_store_size)) - abort(); + llvm_unreachable("buffer smaller than stored type"); } return buffer_ptr; } |